From 789c910c88c7b73a2a35164717fa00c4b64db839 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Fri, 13 Sep 2019 11:44:21 +0200 Subject: [PATCH] [Reverse-engineering] [th04/th05] Playfield fill-around function names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are used from quite a few places, so it seems best to just name them after the rect on the playfield they leave out, which is then typically where the background picture goes. …*except* that in doing this, we quickly run up against the symbol length limit of 32 characters. TASM can expand it via the /mv option, but TCC only lets you *reduce* it to even less. (Why?) So, my initial idea of `playfield_fill_around_(x)_(y)_(w)_(h)` wouldn't have worked. But those coordinates are kinda important, I'd say… Well then, let's just go with `fillm` instead of `fill_around` then. "Fill with mask at the given coordinates"… yeah, that would work. Part of P0029, funded by zorg. --- th04/hardware/fillm64-56_256-256.asm | 40 +++++++++++ th04_main.asm | 101 ++++++++------------------- th05_main.asm | 83 ++++++---------------- 3 files changed, 93 insertions(+), 131 deletions(-) create mode 100644 th04/hardware/fillm64-56_256-256.asm diff --git a/th04/hardware/fillm64-56_256-256.asm b/th04/hardware/fillm64-56_256-256.asm new file mode 100644 index 00000000..70376cf6 --- /dev/null +++ b/th04/hardware/fillm64-56_256-256.asm @@ -0,0 +1,40 @@ +; Fills the playfield around the 256×256 pixels starting at (64, 56) with the +; current GRCG tile. +; Assumes that the GRCG is set to TDW mode. + +; void pascal playfield_fillm_64_56_256_256(); +public playfield_fillm_64_56_256_256 +playfield_fillm_64_56_256_256 proc near + push di + mov ax, GRAM_400 + (PLAYFIELD_Y * ROW_SIZE) shr 4 + mov es, ax + assume es:nothing + mov di, (55 * ROW_SIZE) + PLAYFIELD_VRAM_X + nop + +@@rows_next: + mov cx, PLAYFIELD_VRAM_W / 4 + +@@rows_top_and_bottom: + mov es:[di+(312 * ROW_SIZE)], eax + stosd + loop @@rows_top_and_bottom + sub di, ROW_SIZE + PLAYFIELD_VRAM_W + jge short @@rows_next + mov ax, GRAM_400 + ((56 + PLAYFIELD_Y) * ROW_SIZE) shr 4 + mov es, ax + assume es:nothing + mov di, (255 * ROW_SIZE) + PLAYFIELD_VRAM_X + nop + +@@cols: + mov es:[di+(320 / 8)], eax + stosd + mov es:[di+(320 / 8)], eax + stosd + sub di, ROW_SIZE + 8 + jge short @@cols + pop di + retn +playfield_fillm_64_56_256_256 endp + even diff --git a/th04_main.asm b/th04_main.asm index 041ae948..f4f5638f 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -2200,53 +2200,14 @@ sub_BE68 endp ; =============== S U B R O U T I N E ======================================= -sub_BECC proc near +playfield_fillm_0_0_384_112 proc near push di GRCG_FILL_PLAYFIELD_ROWS 112, 256 pop di retn -sub_BECC endp +playfield_fillm_0_0_384_112 endp - -; =============== S U B R O U T I N E ======================================= - - -sub_BEDA proc near - push di - mov ax, GRAM_400 + (PLAYFIELD_Y * ROW_SIZE) shr 4 - mov es, ax - assume es:nothing - mov di, (55 * ROW_SIZE) + PLAYFIELD_VRAM_X - nop - -loc_BEE4: - mov cx, PLAYFIELD_VRAM_W / 4 - -loc_BEE7: - mov es:[di+(312 * ROW_SIZE)], eax - stosd - loop loc_BEE7 - sub di, ROW_SIZE + PLAYFIELD_VRAM_W - jge short loc_BEE4 - mov ax, GRAM_400 + ((56 + PLAYFIELD_Y) * ROW_SIZE) shr 4 - mov es, ax - assume es:nothing - mov di, (255 * ROW_SIZE) + PLAYFIELD_VRAM_X - nop - -loc_BF00: - mov es:[di+(320 / 8)], eax - stosd - mov es:[di+(320 / 8)], eax - stosd - sub di, ROW_SIZE + 8 - jge short loc_BF00 - pop di - retn -sub_BEDA endp - -; --------------------------------------------------------------------------- - nop +include th04/hardware/fillm64-56_256-256.asm ; =============== S U B R O U T I N E ======================================= @@ -2377,7 +2338,7 @@ sub_BF94 endp ; =============== S U B R O U T I N E ======================================= -sub_BFF8 proc near +playfield_fillm_96_112_288_256 proc near push di mov ax, GRAM_400 + ((112 + PLAYFIELD_Y) * ROW_SIZE) shr 4 mov es, ax @@ -2385,16 +2346,16 @@ sub_BFF8 proc near mov di, (255 * ROW_SIZE) + PLAYFIELD_VRAM_X nop -loc_C002: +@@left_rect: stosd stosd stosd sub di, ROW_SIZE + 12 - jge short loc_C002 + jge short @@left_rect GRCG_FILL_PLAYFIELD_ROWS 0, 112 pop di retn -sub_BFF8 endp +playfield_fillm_96_112_288_256 endp ; =============== S U B R O U T I N E ======================================= @@ -2588,12 +2549,12 @@ sub_C0FC endp ; =============== S U B R O U T I N E ======================================= -sub_C148 proc near +playfield_fillm_0_0_384_192 proc near push di GRCG_FILL_PLAYFIELD_ROWS 192, 176 pop di retn -sub_C148 endp +playfield_fillm_0_0_384_192 endp include th04/hardware/grcg_modecol.asm @@ -7301,13 +7262,13 @@ sub_E8A3 endp ; =============== S U B R O U T I N E ======================================= -sub_EA70 proc near +playfield_fillm_0_80_384_112 proc near push di GRCG_FILL_PLAYFIELD_ROWS 192, 192 GRCG_FILL_PLAYFIELD_ROWS 0, 80 pop di retn -sub_EA70 endp +playfield_fillm_0_80_384_112 endp ; --------------------------------------------------------------------------- nop @@ -7776,7 +7737,7 @@ sub_ED71 endp ; =============== S U B R O U T I N E ======================================= -sub_EDE2 proc near +playfield_fillm_0_120_384_128 proc near push di GRCG_FILL_PLAYFIELD_ROWS 0, 120, dx cli @@ -7790,7 +7751,7 @@ sub_EDE2 proc near GRCG_FILL_PLAYFIELD_ROWS 248, 120 pop di retn -sub_EDE2 endp +playfield_fillm_0_120_384_128 endp ; =============== S U B R O U T I N E ======================================= @@ -10252,7 +10213,7 @@ var_1 = byte ptr -1 call _grcg_setmode_tdw mov ah, 0Fh call _grcg_setcolor_direct_noint_1 - call sub_1200A + call playfield_fillm_0_40_384_274 GRCG_OFF_CLOBBERING dx push (32 shl 16) or 56 push 0 @@ -10327,7 +10288,7 @@ var_2 = word ptr -2 call _grcg_setmode_tdw mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_1200A + call playfield_fillm_0_40_384_274 GRCG_OFF_CLOBBERING dx push (32 shl 16) or 56 push 0 @@ -13747,13 +13708,13 @@ sub_11FC8 endp ; =============== S U B R O U T I N E ======================================= -sub_1200A proc near +playfield_fillm_0_40_384_274 proc near push di GRCG_FILL_PLAYFIELD_ROWS 0, 40 GRCG_FILL_PLAYFIELD_ROWS 314, 54 pop di retn -sub_1200A endp +playfield_fillm_0_40_384_274 endp ; --------------------------------------------------------------------------- nop @@ -13795,12 +13756,12 @@ sub_12024 endp ; =============== S U B R O U T I N E ======================================= -sub_1205A proc near +playfield_fill proc near push di GRCG_FILL_PLAYFIELD_ROWS 0, PLAYFIELD_H pop di retn -sub_1205A endp +playfield_fill endp include th04/hardware/grcg_fill_rows.asm @@ -14141,7 +14102,7 @@ loc_12309: call _grcg_setmode_tdw mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_BEDA + call playfield_fillm_64_56_256_256 GRCG_OFF_CLOBBERING dx push (96 shl 16) or 72 push 16 @@ -14219,7 +14180,7 @@ loc_12396: call _grcg_setmode_tdw mov ah, GC_BRGI call _grcg_setcolor_direct_noint_1 - call sub_BFF8 + call playfield_fillm_96_112_288_256 GRCG_OFF_CLOBBERING dx push (128 shl 16) or 128 push 16 @@ -14887,7 +14848,7 @@ var_1 = byte ptr -1 jnz short loc_12921 mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_1205A + call playfield_fill GRCG_OFF_CLOBBERING dx cmp _boss_phase_frame, 2 jnz loc_12975 @@ -14930,7 +14891,7 @@ loc_12921: call _grcg_setcolor_direct_noint_1 cmp [bp+var_1], 8 jnb short loc_12944 - call sub_1205A + call playfield_fill jmp short loc_12947 ; --------------------------------------------------------------------------- @@ -14957,7 +14918,7 @@ loc_12958: loc_12964: mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_1205A + call playfield_fill GRCG_OFF_CLOBBERING dx loc_12972: @@ -15010,7 +14971,7 @@ loc_129B4: call _grcg_setmode_tdw mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_C148 + call playfield_fillm_0_0_384_192 GRCG_OFF_CLOBBERING dx push (32 shl 16) or 16 push 16 @@ -35735,7 +35696,7 @@ sub_1DFEF proc far mov _boss_sprite, 128 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (16 shl 4) - mov _boss_backdrop_colorfill, offset sub_EDE2 + mov _boss_backdrop_colorfill, offset playfield_fillm_0_120_384_128 push ds push offset aSt00_bmt ; "st00.bmt" call super_entry_bfnt @@ -35779,7 +35740,7 @@ sub_1E0B3 proc far mov _boss_sprite, 0 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_EA70 + mov _boss_backdrop_colorfill, offset playfield_fillm_0_80_384_112 push ds push offset aSt01_bmt ; "st01.bmt" call super_entry_bfnt @@ -35825,7 +35786,7 @@ sub_1E186 proc far mov _boss_sprite, 134 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_BECC + mov _boss_backdrop_colorfill, offset playfield_fillm_0_0_384_112 push ds push offset aSt02_bmt ; "st02.bmt" call super_entry_bfnt @@ -35906,7 +35867,7 @@ loc_1E371: mov _boss_sprite, 128 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_BEDA + mov _boss_backdrop_colorfill, offset playfield_fillm_64_56_256_256 push ds push offset aSt03_bmt ; "st03.bmt" call super_entry_bfnt @@ -35955,7 +35916,7 @@ sub_1E3C2 proc far mov _boss_sprite, 128 mov _boss_hitbox_radius.x, (26 shl 4) mov _boss_hitbox_radius.y, (26 shl 4) - mov _boss_backdrop_colorfill, offset sub_BFF8 + mov _boss_backdrop_colorfill, offset playfield_fillm_96_112_288_256 call _cdg_load_single_noalpha pascal, 16, ds, offset aSt04bk_cdg, 0 call bb_stage_load pascal, ds, offset aSt04_bb call _cdg_load_single_noalpha pascal, 17, ds, offset aSt04_cdg, 0 @@ -36040,7 +36001,7 @@ sub_1E518 proc far mov _boss_sprite, 128 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (48 shl 4) - mov _boss_backdrop_colorfill, offset sub_C148 + mov _boss_backdrop_colorfill, offset playfield_fillm_0_0_384_192 mov byte_2D01E, 0 call _cdg_load_single_noalpha pascal, 16, ds, offset aSt06bk_cdg, 0 call bb_stage_load pascal, ds, offset aSt06_bb diff --git a/th05_main.asm b/th05_main.asm index aa4b9dd6..5168b934 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -4136,7 +4136,7 @@ loc_D124: call _grcg_setmode_tdw mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_DEA6 + call playfield_fillm_0_0_384_192__1 GRCG_OFF_CLOBBERING dx push (32 shl 16) or 16 push 16 @@ -4212,7 +4212,7 @@ loc_D1B0: call _grcg_setmode_tdw mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_DEB4 + call playfield_fillm_0_205_384_163 GRCG_OFF_CLOBBERING dx push (32 shl 16) or 221 push 16 @@ -4289,7 +4289,7 @@ loc_D23E: call _grcg_setmode_tdw mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_DEC2 + call playfield_fillm_64_56_256_256 GRCG_OFF_CLOBBERING dx push (96 shl 16) or 72 push 16 @@ -4362,7 +4362,7 @@ loc_D2C7: call _grcg_setmode_tdw mov ah, GC_RGI call _grcg_setcolor_direct_noint_1 - call sub_E01E + call playfield_fillm_0_0_384_192__2 GRCG_OFF_CLOBBERING dx push (32 shl 16) or 16 push 16 @@ -5745,7 +5745,7 @@ sub_DCDB endp ; =============== S U B R O U T I N E ======================================= -sub_DD42 proc near +playfield_fillm_32_0_320_192 proc near push di cli mov dx, 7Eh ; '~' @@ -5768,7 +5768,7 @@ loc_DD61: jge short loc_DD61 pop di retn -sub_DD42 endp +playfield_fillm_32_0_320_192 endp ; --------------------------------------------------------------------------- nop @@ -5970,64 +5970,25 @@ sub_DE7A endp ; =============== S U B R O U T I N E ======================================= -sub_DEA6 proc near +playfield_fillm_0_0_384_192__1 proc near push di GRCG_FILL_PLAYFIELD_ROWS 192, 176 pop di retn -sub_DEA6 endp +playfield_fillm_0_0_384_192__1 endp ; =============== S U B R O U T I N E ======================================= -sub_DEB4 proc near +playfield_fillm_0_205_384_163 proc near push di GRCG_FILL_PLAYFIELD_ROWS 0, 205 pop di retn -sub_DEB4 endp - - -; =============== S U B R O U T I N E ======================================= - - -sub_DEC2 proc near - push di - mov ax, GRAM_400 + (PLAYFIELD_Y * ROW_SIZE) shr 4 - mov es, ax - mov di, (55 * ROW_SIZE) + PLAYFIELD_VRAM_X - nop - -loc_DECC: - mov cx, PLAYFIELD_VRAM_W / 4 - -loc_DECF: - mov es:[di+(312 * ROW_SIZE)], eax - stosd - loop loc_DECF - sub di, ROW_SIZE + PLAYFIELD_VRAM_W - jge short loc_DECC - mov ax, GRAM_400 + ((56 + PLAYFIELD_Y) * ROW_SIZE) shr 4 - mov es, ax - assume es:nothing - mov di, (255 * ROW_SIZE) + PLAYFIELD_VRAM_X - nop - -loc_DEE8: - mov es:[di+(320 / 8)], eax - stosd - mov es:[di+(320 / 8)], eax - stosd - sub di, ROW_SIZE + 8 - jge short loc_DEE8 - pop di - retn -sub_DEC2 endp - -; --------------------------------------------------------------------------- - nop +playfield_fillm_0_205_384_163 endp +include th04/hardware/fillm64-56_256-256.asm include th05/formats/bb_load.asm ; =============== S U B R O U T I N E ======================================= @@ -6161,12 +6122,12 @@ sub_DFBA endp ; =============== S U B R O U T I N E ======================================= -sub_E01E proc near +playfield_fillm_0_0_384_192__2 proc near push di GRCG_FILL_PLAYFIELD_ROWS 192, 176 pop di retn -sub_E01E endp +playfield_fillm_0_0_384_192__2 endp ; --------------------------------------------------------------------------- word_E02C dw 0 @@ -7118,13 +7079,13 @@ sub_E8FE endp ; =============== S U B R O U T I N E ======================================= -sub_E914 proc near +playfield_fillm_0_104_384_192 proc near push di GRCG_FILL_PLAYFIELD_ROWS 0, 104 GRCG_FILL_PLAYFIELD_ROWS 296, 72 pop di retn -sub_E914 endp +playfield_fillm_0_104_384_192 endp ; --------------------------------------------------------------------------- nop @@ -17940,7 +17901,7 @@ sub_14544 proc near mov _boss_sprite_left, 186 mov _boss_sprite_right, 184 mov _boss_sprite_stay, 180 - mov _boss_backdrop_colorfill, offset sub_DD42 + mov _boss_backdrop_colorfill, offset playfield_fillm_32_0_320_192 push ds push offset aSt00_bmt ; "st00.bmt" call super_entry_bfnt @@ -17982,7 +17943,7 @@ sub_14613 proc near mov _boss_sprite, 180 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_DEA6 + mov _boss_backdrop_colorfill, offset playfield_fillm_0_0_384_192__1 push ds push offset aSt01_bmt ; "st01.bmt" call super_entry_bfnt @@ -18024,7 +17985,7 @@ sub_146D0 proc near mov _boss_sprite, 180 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_DEB4 + mov _boss_backdrop_colorfill, offset playfield_fillm_0_205_384_163 mov _boss_sprite_left, 188 mov _boss_sprite_right, 186 mov _boss_sprite_stay, 180 @@ -18074,7 +18035,7 @@ sub_1479F proc near mov _yuki_sprite, 180 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_DEC2 + mov _boss_backdrop_colorfill, offset playfield_fillm_64_56_256_256 push ds push offset aSt03_bmt ; "st03.bmt" call super_entry_bfnt @@ -18120,7 +18081,7 @@ sub_14879 proc near mov _boss_sprite, 180 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_E01E + mov _boss_backdrop_colorfill, offset playfield_fillm_0_0_384_192__2 push ds push offset aSt04_bmt ; "st04.bmt" call super_entry_bfnt @@ -18162,7 +18123,7 @@ sub_14976 proc near mov _boss_sprite, 180 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_E914 + mov _boss_backdrop_colorfill, offset playfield_fillm_0_104_384_192 call _cdg_load_all_noalpha pascal, 16, ds, offset aSt05bk_cdg call _cdg_load_all_noalpha pascal, 17, ds, offset aSt05bk2_cdg call bb_stage_load pascal, ds, offset aSt05_bb @@ -18201,7 +18162,7 @@ sub_14A06 proc near mov _boss_sprite, 180 mov _boss_hitbox_radius.x, (24 shl 4) mov _boss_hitbox_radius.y, (24 shl 4) - mov _boss_backdrop_colorfill, offset sub_E914 + mov _boss_backdrop_colorfill, offset playfield_fillm_0_104_384_192 push ds push offset aSt06_bmt ; "st06.bmt" call super_entry_bfnt