Skip to content

Commit

Permalink
[Reverse-engineering] [th04/th05] Clearing the playfield's text RAM area
Browse files Browse the repository at this point in the history
master.lib's text_boxfillca() function would have been perfectly
suitable here…

Part of P0089, funded by [Anonymous] and Blue Bolt.
  • Loading branch information
nmlgc committed May 3, 2020
1 parent 98be2f1 commit 5f047fd
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 196 deletions.
8 changes: 8 additions & 0 deletions th02/main/playfld.h
Expand Up @@ -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
56 changes: 56 additions & 0 deletions th02/main/playfld.inc
Expand Up @@ -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
Expand Down
60 changes: 12 additions & 48 deletions th02_main.asm
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 =======================================

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
7 changes: 7 additions & 0 deletions th04/main/playfld.h
@@ -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);

0 comments on commit 5f047fd

Please sign in to comment.