diff --git a/Makefile.mak b/Makefile.mak index e970bb85..02d83bb0 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -135,7 +135,7 @@ bin\th05\op.exe: bin\th05\op.obj th05\op_01.cpp $** | -bin\th05\main.exe: bin\th05\main.obj th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main011.cpp th05\main012.cpp bin\th05\bullet.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp +bin\th05\main.exe: bin\th05\main.obj th05\main010.cpp th05\p_common.cpp th05\p_reimu.cpp th05\p_marisa.cpp th05\p_mima.cpp th05\p_yuuka.cpp bin\th05\player.obj bin\th05\hud_bar.obj bin\th05\scoreupd.obj th05\main011.cpp th05\main012.cpp bin\th05\bullet.obj th05\main031.cpp th05\main032.cpp th05\main033.cpp $(CC) $(CFLAGS) -ml -3 -Z -DGAME=5 -DBINARY='M' -nbin\th05\ -eMAIN.EXE @&&| $** | diff --git a/th01/math/subpixel.hpp b/th01/math/subpixel.hpp index ee3807df..f64d77e8 100644 --- a/th01/math/subpixel.hpp +++ b/th01/math/subpixel.hpp @@ -42,6 +42,10 @@ public: return v >> 4; } + operator T() const { + return v; + } + static T None() { return to_sp(PIXEL_NONE); } diff --git a/th04/main/drawp.hpp b/th04/main/drawp.hpp new file mode 100644 index 00000000..fe6627eb --- /dev/null +++ b/th04/main/drawp.hpp @@ -0,0 +1,2 @@ +// A random shared point variable used for drawing various things. +extern SPPoint drawpoint; diff --git a/th04/main/drawpoint[bss].asm b/th04/main/drawpoint[bss].asm index 501c899e..08830a4e 100644 --- a/th04/main/drawpoint[bss].asm +++ b/th04/main/drawpoint[bss].asm @@ -1,3 +1,2 @@ -; A random shared point variable used for drawing various things. public _drawpoint _drawpoint Point diff --git a/th04/math/vector.hpp b/th04/math/vector.hpp index 560e0806..0590465f 100644 --- a/th04/math/vector.hpp +++ b/th04/math/vector.hpp @@ -8,5 +8,9 @@ int pascal near vector2_near( ); int pascal vector2_at( - Point near &ret, int origin_x, int origin_y, int length, int angle + SPPoint near &ret, + subpixel_t origin_x, + subpixel_t origin_y, + subpixel_t length, + int angle ); diff --git a/th05/main/boss/render.cpp b/th05/main/boss/render.cpp index 855d9ae6..dd8933cd 100644 --- a/th05/main/boss/render.cpp +++ b/th05/main/boss/render.cpp @@ -3,6 +3,12 @@ * Rendering code for all bosses */ +#include +#include "th01/math/subpixel.hpp" +#include "th04/math/vector.hpp" +#include "th04/main/drawp.hpp" +#include "th04/main/playfld.h" + /// Structures /// ---------- #define BOSS_PARTICLE_COUNT 64 @@ -36,3 +42,21 @@ struct lineset_t { extern boss_particle_t boss_particles[BOSS_PARTICLE_COUNT]; extern lineset_t linesets[LINESET_COUNT]; /// ---------- + +// Draws the given line out of [set] with the current GRCG tile and color. +void pascal near grcg_lineset_line_put(lineset_t near &set, int i) +{ + vector2_at(drawpoint, + set.center[i].x, set.center[i].y, set.radius[i], set.angle[i] + ); + int x1 = (PLAYFIELD_X + drawpoint.x.to_screen()); + int y1 = (PLAYFIELD_Y + drawpoint.y.to_screen()); + + vector2_at(drawpoint, + set.center[i].x, set.center[i].y, set.radius[i], (set.angle[i] + 0x80) + ); + int x2 = (PLAYFIELD_X + drawpoint.x.to_screen()); + int y2 = (PLAYFIELD_Y + drawpoint.y.to_screen()); + + grcg_line(x1, y1, x2, y2); +} diff --git a/th05/main010.cpp b/th05/main010.cpp new file mode 100644 index 00000000..d73f6fed --- /dev/null +++ b/th05/main010.cpp @@ -0,0 +1,10 @@ +/* ReC98 + * ----- + * 1st part of code segment #1 of TH05's MAIN.EXE + */ + +#pragma codeseg main__TEXT main_01 + +extern "C" { +#include "th05/main/boss/render.cpp" +} diff --git a/th05_main.asm b/th05_main.asm index e1d1ec9a..b53d5a56 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -4026,83 +4026,13 @@ loc_D4F4: leave retn sub_D3C6 endp + + GRCG_LINESET_LINE_PUT procdesc pascal near \ + set:near ptr, i:word main__TEXT ends main_0_TEXT segment word public 'CODE' use16 -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_D4F8 proc near - -var_8 = word ptr -8 -var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 -arg_0 = word ptr 4 -arg_2 = word ptr 6 - - enter 8, 0 - push si - push di - mov si, [bp+arg_2] - mov di, [bp+arg_0] - push offset _drawpoint - mov bx, di - shl bx, 2 - push [bx+si+lineset_t.LS_center.x] - mov bx, di - shl bx, 2 - push [bx+si+lineset_t.LS_center.y] - mov bx, di - add bx, bx - push [bx+si+lineset_t.LS_radius] - mov bx, di - mov al, [bx+si+lineset_t.LS_angle] - mov ah, 0 - push ax - call vector2_at - mov ax, _drawpoint.x - sar ax, 4 - add ax, 32 - mov [bp+var_2], ax - mov ax, _drawpoint.y - sar ax, 4 - add ax, 16 - mov [bp+var_4], ax - push offset _drawpoint - mov bx, di - shl bx, 2 - push [bx+si+lineset_t.LS_center.x] - mov bx, di - shl bx, 2 - push [bx+si+lineset_t.LS_center.y] - mov bx, di - add bx, bx - push [bx+si+lineset_t.LS_radius] - mov bx, di - mov al, [bx+si+lineset_t.LS_angle] - mov ah, 0 - add ax, 80h - push ax - call vector2_at - mov ax, _drawpoint.x - sar ax, 4 - add ax, 32 - mov [bp+var_6], ax - mov ax, _drawpoint.y - sar ax, 4 - add ax, 16 - mov [bp+var_8], ax - call grcg_line pascal, [bp+var_2], [bp+var_4], [bp+var_6], ax - pop di - pop si - leave - retn 4 -sub_D4F8 endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame @@ -4201,34 +4131,18 @@ loc_D630: mov ah, GC_BRG call _grcg_setcolor_direct_seg1_raw call sub_D327 - push offset lineset0 - push 12h - call sub_D4F8 - push offset lineset0 - push 0Ch - call sub_D4F8 - push offset lineset1 - push 12h - call sub_D4F8 - push offset lineset1 - push 0Ch - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 18 + call grcg_lineset_line_put pascal, offset lineset0, 12 + call grcg_lineset_line_put pascal, offset lineset1, 18 + call grcg_lineset_line_put pascal, offset lineset1, 12 mov ah, GC_RG call _grcg_setcolor_direct_seg1_raw - push offset lineset0 - push 6 - call sub_D4F8 - push offset lineset1 - push 6 - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 6 + call grcg_lineset_line_put pascal, offset lineset1, 6 mov ah, 0Fh call _grcg_setcolor_direct_seg1_raw - push offset lineset0 - push 0 - call sub_D4F8 - push offset lineset1 - push 0 - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 0 + call grcg_lineset_line_put pascal, offset lineset1, 0 GRCG_OFF_CLOBBERING dx pop di pop si @@ -4462,34 +4376,18 @@ loc_D82E: mov ah, GC_BRG call _grcg_setcolor_direct_seg1_raw call sub_D327 - push offset lineset0 - push 12h - call sub_D4F8 - push offset lineset0 - push 0Ch - call sub_D4F8 - push offset lineset1 - push 12h - call sub_D4F8 - push offset lineset1 - push 0Ch - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 18 + call grcg_lineset_line_put pascal, offset lineset0, 12 + call grcg_lineset_line_put pascal, offset lineset1, 18 + call grcg_lineset_line_put pascal, offset lineset1, 12 mov ah, GC_RG call _grcg_setcolor_direct_seg1_raw - push offset lineset0 - push 6 - call sub_D4F8 - push offset lineset1 - push 6 - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 6 + call grcg_lineset_line_put pascal, offset lineset1, 6 mov ah, 0Fh call _grcg_setcolor_direct_seg1_raw - push offset lineset0 - push 0 - call sub_D4F8 - push offset lineset1 - push 0 - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 0 + call grcg_lineset_line_put pascal, offset lineset1, 0 GRCG_OFF_CLOBBERING dx pop di pop si @@ -4688,34 +4586,18 @@ loc_D9C6: mov ah, GC_BRG call _grcg_setcolor_direct_seg1_raw call sub_D327 - push offset lineset0 - push 12h - call sub_D4F8 - push offset lineset0 - push 0Ch - call sub_D4F8 - push offset lineset1 - push 12h - call sub_D4F8 - push offset lineset1 - push 0Ch - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 18 + call grcg_lineset_line_put pascal, offset lineset0, 12 + call grcg_lineset_line_put pascal, offset lineset1, 18 + call grcg_lineset_line_put pascal, offset lineset1, 12 mov ah, GC_RG call _grcg_setcolor_direct_seg1_raw - push offset lineset0 - push 6 - call sub_D4F8 - push offset lineset1 - push 6 - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 6 + call grcg_lineset_line_put pascal, offset lineset1, 6 mov ah, 0Fh call _grcg_setcolor_direct_seg1_raw - push offset lineset0 - push 0 - call sub_D4F8 - push offset lineset1 - push 0 - call sub_D4F8 + call grcg_lineset_line_put pascal, offset lineset0, 0 + call grcg_lineset_line_put pascal, offset lineset1, 0 GRCG_OFF_CLOBBERING dx pop di pop si