[Reverse-engineering] [th04/th05] Clearing the playfield's text RAM area

master.lib's text_boxfillca() function would have been perfectly
suitable here…

Part of P0089, funded by [Anonymous] and Blue Bolt.
This commit is contained in:
nmlgc 2020-04-21 21:19:31 +02:00
parent 98be2f19a5
commit 5f047fdab1
6 changed files with 111 additions and 196 deletions

View File

@ -13,5 +13,13 @@
#define PLAYFIELD_VRAM_RIGHT (PLAYFIELD_RIGHT / 8)
#define PLAYFIELD_TRAM_X (PLAYFIELD_X / 8)
#define PLAYFIELD_TRAM_Y (PLAYFIELD_Y / 16)
#define PLAYFIELD_TRAM_W (PLAYFIELD_W / 8)
#define PLAYFIELD_TRAM_RIGHT (PLAYFIELD_RIGHT / 8)
#define PLAYFIELD_TRAM_BOTTOM (PLAYFIELD_BOTTOM / 16)
#if (GAME == 2)
// Fills the playfield's area on the text RAM with transparency.
// (Future games use a near function.)
void far playfield_tram_wipe(void);
#endif

View File

@ -13,8 +13,64 @@ PLAYFIELD_VRAM_W = PLAYFIELD_W / 8
PLAYFIELD_VRAM_RIGHT = PLAYFIELD_RIGHT / 8
PLAYFIELD_TRAM_X = PLAYFIELD_X / 8
PLAYFIELD_TRAM_Y = PLAYFIELD_Y / 16
PLAYFIELD_TRAM_W = PLAYFIELD_W / 8
PLAYFIELD_TRAM_RIGHT = PLAYFIELD_RIGHT / 8
PLAYFIELD_TRAM_BOTTOM = PLAYFIELD_BOTTOM / 16
if GAME eq 5
playfield_tram_x_loop macro @@atrb:req
call text_putsa pascal, PLAYFIELD_TRAM_X, si, _PLAYFIELD_BLANK_ROW, @@atrb
endm
else
playfield_tram_x_loop macro @@atrb:req
local @@x_loop, @@x_more?
mov di, PLAYFIELD_TRAM_X
jmp short @@x_more?
; ---------------------------------------------------------------------------
@@x_loop:
call text_putca pascal, di, si, (' ' shl 16) + @@atrb
inc di
@@x_more?:
cmp di, PLAYFIELD_TRAM_RIGHT
jl short @@x_loop
endm
endif
playfield_tram_loop macro @@atrb:req
mov si, PLAYFIELD_TRAM_Y
jmp short @@y_more?
; ---------------------------------------------------------------------------
@@y_loop:
playfield_tram_x_loop <@@atrb>
inc si
@@y_more?:
cmp si, PLAYFIELD_TRAM_BOTTOM
jl short @@y_loop
endm
playfield_tram_loop_func macro @@funcname:req, @@dist:req, @@atrb:req
public @@funcname
@@funcname proc @@dist
push bp
mov bp, sp
push si
if GAME ne 5
push di
playfield_tram_loop <@@atrb>
pop di
else
playfield_tram_loop <@@atrb>
endif
pop si
pop bp
ret
@@funcname endp
endm
TILE_W = 16
TILE_H = 16

View File

@ -2124,7 +2124,7 @@ var_C = byte ptr -0Ch
call graph_clear
graph_showpage 0
call hud_put
call sub_FBE9
call _playfield_tram_wipe
call _pi_slot_palette_apply stdcall, 0
call _pi_slot_palette_apply stdcall, 0
call _pi_slot_put stdcall, 96, large 144
@ -3396,9 +3396,9 @@ loc_C3FB:
loc_C400:
cmp _key_det, 0
jz short loc_C3FB
call sub_FBE9
call _playfield_tram_wipe
call sub_1C9FE
call sub_FBE9
call _playfield_tram_wipe
les bx, _resident
cmp es:[bx+mikoconfig_t.continues_used], 3
jnb loc_C4F5
@ -3504,7 +3504,7 @@ loc_C516:
mov power_overflow_level, 10
mov PaletteTone, 100
call far ptr palette_show
call sub_FBE9
call _playfield_tram_wipe
mov ax, di
pop di
pop si
@ -8208,7 +8208,7 @@ loc_EB5D:
inc byte_21A55
cmp byte_21A55, 12h
jb short loc_EB7C
call sub_FBE9
call _playfield_tram_wipe
mov word_218B6, 84h
loc_EB7C:
@ -9434,43 +9434,7 @@ loc_FBDF:
retn 0Ah
sub_FB42 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_FBE9 proc far
push bp
mov bp, sp
push si
push di
mov si, 1
jmp short loc_FC0C
; ---------------------------------------------------------------------------
loc_FBF3:
mov di, 4
jmp short loc_FC06
; ---------------------------------------------------------------------------
loc_FBF8:
call text_putca pascal, di, si, (' ' shl 16) + TX_WHITE
inc di
loc_FC06:
cmp di, 52
jl short loc_FBF8
inc si
loc_FC0C:
cmp si, 24
jl short loc_FBF3
pop di
pop si
pop bp
retf
sub_FBE9 endp
playfield_tram_loop_func _playfield_tram_wipe, far, <TX_WHITE>
; =============== S U B R O U T I N E =======================================
@ -9531,7 +9495,7 @@ var_4 = dword ptr -4
push offset gBONUS
mov cx, 6
call SCOPY@
call sub_FBE9
call _playfield_tram_wipe
mov PaletteTone, 62
call far ptr palette_show
push (24 shl 16) + 4
@ -9693,7 +9657,7 @@ var_4 = dword ptr -4
push offset gBONUS_0
mov cx, 6
call SCOPY@
call sub_FBE9
call _playfield_tram_wipe
mov PaletteTone, 62
call far ptr palette_show
push (24 shl 16) + 4
@ -15551,13 +15515,13 @@ var_2 = word ptr -2
push si
push di
mov di, 32
nopcall sub_FBE9
nopcall _playfield_tram_wipe
call sub_DE4E
call graph_scrollup pascal, _scroll_line
mov PaletteTone, 100
call far ptr palette_show
graph_accesspage _page_front
nopcall sub_FBE9
nopcall _playfield_tram_wipe
mov si, 320
add si, _scroll_line
cmp si, RES_Y
@ -15627,7 +15591,7 @@ var_2 = word ptr -2
push si
push di
mov di, 20h ; ' '
nopcall sub_FBE9
nopcall _playfield_tram_wipe
mov si, 320
add si, _scroll_line
cmp si, RES_Y
@ -16431,7 +16395,7 @@ sub_13414 endp
sub_13439 proc near
push bp
mov bp, sp
nopcall sub_FBE9
nopcall _playfield_tram_wipe
kajacall KAJA_SONG_STOP
pop cx
push 69h ; 'i'

7
th04/main/playfld.h Normal file
View File

@ -0,0 +1,7 @@
#include "th02/main/playfld.h"
// Fills the playfield area on the text RAM with transparent spaces.
void near playfield_tram_wipe(void);
// Fills the playfield area on the text RAM with black, effectively hiding the
// playfield in the process.
void near playfield_tram_black(void);

View File

@ -711,7 +711,7 @@ loc_AF4A:
mov PaletteTone, 0
call far ptr palette_show
call main_01:sub_12024
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
call main_01:sub_B1D0
nopcall main_01:hud_put
call main_01:sub_B616
@ -877,7 +877,7 @@ loc_B156:
call palette_black_out
mov PaletteTone, 100
call far ptr palette_show
call main_01:sub_10D77
call main_01:_playfield_tram_black
call main_01:tiles_render_all
mov _page_back, 1
mov _page_front, 0
@ -3677,7 +3677,7 @@ loc_D6DC:
; ---------------------------------------------------------------------------
loc_D6E4:
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
pop di
pop si
leave
@ -3693,7 +3693,7 @@ sub_D6EB proc far
push bp
mov bp, sp
call main_01:sub_D729
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
mov PaletteTone, 100
call far ptr palette_show
graph_accesspage _page_front
@ -5337,7 +5337,7 @@ var_1 = byte ptr -1
push di
cmp byte_25660, 24h ; '$'
jb short loc_E47B
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
mov _overlay_text_fp, offset nullfunc_near
mov al, 1
jmp short loc_E4CD
@ -5413,7 +5413,7 @@ var_1 = byte ptr -1
push di
cmp byte_25660, 0
jnz short loc_E4EB
call main_01:sub_10D77
call main_01:_playfield_tram_black
mov _overlay_text_fp, offset nullfunc_near
mov al, 1
jmp short loc_E53D
@ -5545,7 +5545,7 @@ loc_E5EF:
jl short loc_E5C2
call gaiji_putsa pascal, (20 shl 16) + 12, ds, offset gGAMEOVER, TX_WHITE
call input_wait_for_change pascal, 0
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
call main_01:sub_E67A
mov ah, 0
mov [bp+var_2], ax
@ -5576,7 +5576,7 @@ loc_E63F:
; ---------------------------------------------------------------------------
loc_E64F:
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
jmp short loc_E675
; ---------------------------------------------------------------------------
@ -9930,80 +9930,8 @@ loc_10BFA:
sub_10ABF endp
include th04/main/player/render.asm
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_10D4B proc near
push bp
mov bp, sp
push si
push di
mov si, 1
jmp short loc_10D6E
; ---------------------------------------------------------------------------
loc_10D55:
mov di, 4
jmp short loc_10D68
; ---------------------------------------------------------------------------
loc_10D5A:
call text_putca pascal, di, si, (' ' shl 16) + TX_WHITE
inc di
loc_10D68:
cmp di, 52
jl short loc_10D5A
inc si
loc_10D6E:
cmp si, 24
jl short loc_10D55
pop di
pop si
pop bp
retn
sub_10D4B endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_10D77 proc near
push bp
mov bp, sp
push si
push di
mov si, 1
jmp short loc_10D9A
; ---------------------------------------------------------------------------
loc_10D81:
mov di, 4
jmp short loc_10D94
; ---------------------------------------------------------------------------
loc_10D86:
call text_putca pascal, di, si, (' ' shl 16) + TX_BLACK + TX_REVERSE
inc di
loc_10D94:
cmp di, 52
jl short loc_10D86
inc si
loc_10D9A:
cmp si, 24
jl short loc_10D81
pop di
pop si
pop bp
retn
sub_10D77 endp
playfield_tram_loop_func _playfield_tram_wipe, near, <TX_WHITE>
playfield_tram_loop_func _playfield_tram_black, near, <TX_BLACK + TX_REVERSE>
; =============== S U B R O U T I N E =======================================
@ -10018,7 +9946,7 @@ var_1 = byte ptr -1
push di
cmp byte_22EA2, 48h ; 'H'
jb short loc_10DE5
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
les bx, _resident
cmp es:[bx+resident_t.demo_num], 0
jnz short loc_10DC6
@ -10104,7 +10032,7 @@ var_1 = byte ptr -1
push di
cmp byte_22EA2, 0
jnz short loc_10E51
call main_01:sub_10D77
call main_01:_playfield_tram_black
mov _overlay_text_fp, offset nullfunc_near
jmp short loc_10EA1
; ---------------------------------------------------------------------------
@ -10257,7 +10185,7 @@ sub_10F36 proc near
jb loc_10FED
cmp _popup_byte_unknown, 0C0h
jnz short loc_10F53
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
mov byte_22EF6, 0
jmp short loc_10F5E
; ---------------------------------------------------------------------------
@ -10490,7 +10418,7 @@ sub_11195 proc near
jb short loc_11211
cmp byte_22EA3, 0C0h
jnz short loc_111B0
call main_01:sub_10D4B
call main_01:_playfield_tram_wipe
mov byte_22EF6, 0
jmp short loc_111BB
; ---------------------------------------------------------------------------

View File

@ -798,7 +798,7 @@ loc_B2DD:
mov PaletteTone, 0
call far ptr palette_show
call sub_CFEE
call sub_118D1
call _playfield_tram_wipe
call sub_B55A
nopcall hud_put
call sub_BA66
@ -1008,7 +1008,7 @@ loc_B4BB:
call palette_black_out
mov PaletteTone, 100
call far ptr palette_show
call sub_118F3
call _playfield_tram_black
call tiles_render_all
mov _page_back, 1
mov _page_front, 0
@ -6423,7 +6423,7 @@ loc_F2AB:
; ---------------------------------------------------------------------------
loc_F2AE:
call sub_118D1
call _playfield_tram_wipe
pop si
leave
retn
@ -6472,7 +6472,7 @@ loc_F318:
loc_F333:
call cdg_free pascal, 0
call sub_118D1
call _playfield_tram_wipe
mov PaletteTone, 100
call far ptr palette_show
graph_accesspage _page_front
@ -6895,7 +6895,7 @@ var_1 = byte ptr -1
push di
cmp byte_2C99C, 24h ; '$'
jb short loc_F8B0
call sub_118D1
call _playfield_tram_wipe
mov _overlay_text_fp, offset nullfunc_near
mov al, 1
jmp short loc_F902
@ -6971,7 +6971,7 @@ var_1 = byte ptr -1
push di
cmp byte_2C99C, 0
jnz short loc_F920
call sub_118F3
call _playfield_tram_black
mov _overlay_text_fp, offset nullfunc_near
mov al, 1
jmp short loc_F972
@ -7098,7 +7098,7 @@ loc_FA18:
jl short loc_F9EB
call gaiji_putsa pascal, (20 shl 16) + 12, ds offset gGAMEOVER, TX_WHITE
call input_wait_for_change pascal, 0
call sub_118D1
call _playfield_tram_wipe
call sub_FAA3
mov ah, 0
mov [bp+var_2], ax
@ -7129,7 +7129,7 @@ loc_FA68:
; ---------------------------------------------------------------------------
loc_FA78:
call sub_118D1
call _playfield_tram_wipe
jmp short loc_FA9E
; ---------------------------------------------------------------------------
@ -10051,56 +10051,8 @@ loc_118CD:
retn
midboss5_render endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_118D1 proc near
push bp
mov bp, sp
push si
mov si, 1
jmp short loc_118EB
; ---------------------------------------------------------------------------
loc_118DA:
call text_putsa pascal, 4, si, _PLAYFIELD_BLANK_ROW, TX_WHITE
inc si
loc_118EB:
cmp si, 24
jl short loc_118DA
pop si
pop bp
retn
sub_118D1 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_118F3 proc near
push bp
mov bp, sp
push si
mov si, 1
jmp short loc_1190C
; ---------------------------------------------------------------------------
loc_118FC:
call text_putsa pascal, 4, si, _PLAYFIELD_BLANK_ROW, TX_BLACK + TX_REVERSE
inc si
loc_1190C:
cmp si, 24
jl short loc_118FC
pop si
pop bp
retn
sub_118F3 endp
playfield_tram_loop_func _playfield_tram_wipe, near, <TX_WHITE>
playfield_tram_loop_func _playfield_tram_black, near, <TX_BLACK + TX_REVERSE>
; =============== S U B R O U T I N E =======================================
@ -10115,7 +10067,7 @@ var_1 = byte ptr -1
push di
cmp byte_2288A, 48h ; 'H'
jb short loc_1195D
call sub_118D1
call _playfield_tram_wipe
les bx, _resident
assume es:nothing
cmp es:[bx+resident_t.demo_num], 0
@ -10206,7 +10158,7 @@ var_1 = byte ptr -1
push di
cmp byte_2288A, 0
jnz short loc_119C9
call sub_118F3
call _playfield_tram_black
mov _overlay_text_fp, offset nullfunc_near
jmp short loc_11A19
; ---------------------------------------------------------------------------
@ -10359,7 +10311,7 @@ sub_11AAE proc near
jb loc_11B65
cmp _popup_byte_unknown, 0C0h
jnz short loc_11ACB
call sub_118D1
call _playfield_tram_wipe
mov byte_228EC, 0
jmp short loc_11AD6
; ---------------------------------------------------------------------------
@ -10553,7 +10505,7 @@ sub_11CBB proc near
jb short loc_11D37
cmp byte_2288B, 0C0h
jnz short loc_11CD6
call sub_118D1
call _playfield_tram_wipe
mov byte_228EC, 0
jmp short loc_11CE1
; ---------------------------------------------------------------------------