From d5ec2220ec5346af9ed79dfc973bebd700565104 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Thu, 4 Nov 2021 22:14:32 +0100 Subject: [PATCH] [Decompilation] [th01] Boss defeat sequence: Drawing white lines Part of P0167, funded by Ember2528. --- Makefile.mak | 2 +- th01/main/boss/defeat.cpp | 18 +++++++++ th01/main_17.cpp | 6 +++ th01_reiiden.asm | 79 +++++++++++---------------------------- 4 files changed, 46 insertions(+), 59 deletions(-) create mode 100644 th01/main/boss/defeat.cpp create mode 100644 th01/main_17.cpp diff --git a/Makefile.mak b/Makefile.mak index 40bcf5a3..13cdce67 100644 --- a/Makefile.mak +++ b/Makefile.mak @@ -48,7 +48,7 @@ bin\th01\op.exe: bin\piloadc.obj bin\th01\op.obj th01\op_01.cpp bin\th01\frmdela $** | -bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_010.cpp th01\main_011.cpp th01\main_012.cpp bin\th01\frmdelay.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj bin\th01\vplanset.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\grz.obj th01\main_09.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\main_13.cpp th01\main_13_.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp th01\main_23.cpp th01\main_24.cpp th01\main_25.cpp th01\main_26.cpp th01\main_27.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_32_.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp +bin\th01\reiiden.exe: bin\piloadc.obj bin\th01\reiiden.obj th01\main_010.cpp th01\main_011.cpp th01\main_012.cpp bin\th01\frmdelay.obj bin\th01\vsync.obj bin\th01\ztext.obj bin\th01\initexit.obj bin\th01\graph.obj bin\th01\ptn_0to1.obj bin\th01\vplanset.obj th01\main_07.cpp bin\th01\ptn.obj th01\main_08.cpp bin\th01\grz.obj th01\main_09.cpp th01\grpinv32.cpp bin\th01\resstuff.obj th01\main_13.cpp th01\main_13_.cpp th01\main_14.cpp th01\main_15.cpp bin\th01\mdrv2.obj th01\main_17.cpp th01\main_19.cpp th01\main_20.cpp th01\main_21.cpp th01\main_23.cpp th01\main_24.cpp th01\main_25.cpp th01\main_26.cpp th01\main_27.cpp th01\main_29.cpp th01\main_30.cpp th01\main_31.cpp th01\main_32.cpp th01\main_32_.cpp th01\main_33.cpp th01\main_34.cpp th01\main_35.cpp th01\main_36.cpp th01\main_37.cpp th01\main_38.cpp $(CC) $(CFLAGS) $(LARGE_LFLAGS) -3 -Z -d -DGAME=1 -DBINARY='M' -nbin\th01\ -eREIIDEN.EXE @&&| $** | diff --git a/th01/main/boss/defeat.cpp b/th01/main/boss/defeat.cpp new file mode 100644 index 00000000..12dfd1c2 --- /dev/null +++ b/th01/main/boss/defeat.cpp @@ -0,0 +1,18 @@ +extern "C" { +#include "platform.h" +#include "pc98.h" +#include "planar.h" +#include "th01/v_colors.hpp" +#include "th01/hardware/graph.h" +} + +void grcg_whiteline(screen_y_t y) +{ + vram_offset_t vo = vram_offset_muldiv(0, y); + grcg_setcolor_rmw(V_WHITE); + for(vram_word_amount_t x = 0; x < (ROW_SIZE / sizeof(dots16_t)); x++) { + grcg_put(vo, 0xFFFF, 16); + vo += static_cast(sizeof(dots16_t)); + } + grcg_off(); +} diff --git a/th01/main_17.cpp b/th01/main_17.cpp new file mode 100644 index 00000000..34aa53b6 --- /dev/null +++ b/th01/main_17.cpp @@ -0,0 +1,6 @@ +/* ReC98 + * ----- + * Code segment #17 of TH01's REIIDEN.EXE + */ + +#include "th01/main/boss/defeat.cpp" diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 18ec1b3d..45b53ec2 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -62,6 +62,7 @@ BOSS_STAGE = (STAGES_PER_SCENE - 1) .seq main_01 group main_010_TEXT, main_011_TEXT, main_012_TEXT, main_013_TEXT main_15 group main_15_TEXT, main_15__TEXT +main_17 group main_17_TEXT, main_17__TEXT main_19 group main_19_TEXT, main_19__TEXT main_21 group main_21_TEXT, main_21__TEXT main_29 group main_29_TEXT, main_29__TEXT @@ -3628,48 +3629,14 @@ mdrv2_TEXT ends ; Segment type: Pure code main_17_TEXT segment byte public 'CODE' use16 - assume cs:main_17_TEXT +main_17_TEXT ends + +main_17__TEXT segment byte public 'CODE' use16 + assume cs:main_17 ;org 5 assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_125E5 proc far - -arg_0 = word ptr 6 - - push bp - mov bp, sp - push si - push di - mov ax, [bp+arg_0] - imul ax, 50h - mov si, ax - call _grcg_setcolor_rmw stdcall, 7 - pop cx - xor di, di - jmp short loc_1260D -; --------------------------------------------------------------------------- - -loc_125FE: - les bx, _VRAM_PLANE_B - add bx, si - mov word ptr es:[bx], 0FFFFh - add si, 2 - inc di - -loc_1260D: - cmp di, 28h ; '(' - jl short loc_125FE - call _grcg_off_func - pop di - pop si - pop bp - retf -sub_125E5 endp - + extern @grcg_whiteline$qi:proc ; =============== S U B R O U T I N E ======================================= @@ -3682,8 +3649,8 @@ var_C = word ptr -0Ch var_A = word ptr -0Ah var_8 = word ptr -8 var_6 = word ptr -6 -var_4 = word ptr -4 -var_2 = word ptr -2 +@@bottom = word ptr -4 +@@top = word ptr -2 enter 0Eh, 0 push si @@ -3693,32 +3660,30 @@ var_2 = word ptr -2 pop cx mov ax, boss.BE_cur_top add ax, 48 - mov [bp+var_2], ax + mov [bp+@@top], ax mov ax, boss.BE_cur_top add ax, 48 - mov [bp+var_4], ax + mov [bp+@@bottom], ax loc_12640: - cmp [bp+var_2], 0 + cmp [bp+@@top], 0 jl short loc_1264E - push [bp+var_2] - call sub_125E5 + call @grcg_whiteline$qi stdcall, [bp+@@top] pop cx loc_1264E: - cmp [bp+var_4], 18Fh + cmp [bp+@@bottom], (RES_Y - 1) jg short loc_1265D - push [bp+var_4] - call sub_125E5 + call @grcg_whiteline$qi stdcall, [bp+@@bottom] pop cx loc_1265D: - dec [bp+var_2] - inc [bp+var_4] + dec [bp+@@top] + inc [bp+@@bottom] inc [bp+var_8] - cmp [bp+var_2], 0 + cmp [bp+@@top], 0 jge short loc_12673 - cmp [bp+var_4], 18Fh + cmp [bp+@@bottom], (RES_Y - 1) jg short loc_126C3 loc_12673: @@ -4063,15 +4028,13 @@ var_6 = word ptr -6 loc_12A5F: cmp [bp+@@orb_center_x], PLAYFIELD_LEFT jl short loc_12A6D - push [bp+@@orb_center_x] - call sub_125E5 + call @grcg_whiteline$qi stdcall, [bp+@@orb_center_x] pop cx loc_12A6D: cmp [bp+@@orb_center_y], (PLAYFIELD_BOTTOM - 1) jg short loc_12A7C - push [bp+@@orb_center_y] - call sub_125E5 + call @grcg_whiteline$qi stdcall, [bp+@@orb_center_y] pop cx loc_12A7C: @@ -4232,7 +4195,7 @@ loc_12BA2: retf sub_12A3A endp -main_17_TEXT ends +main_17__TEXT ends ; ===========================================================================