[Decompilation] [th02] Stage tiles: Re-rendering the entire playfield

Part of P0235, funded by Ember2528.
This commit is contained in:
nmlgc 2023-03-09 09:32:28 +01:00
parent 9c95ddace3
commit 59564b3ecf
3 changed files with 52 additions and 82 deletions

View File

@ -1,4 +1,4 @@
#pragma option -zC_TEXT -G
#pragma option -zC_TEXT -G -2
#include "platform.h"
#include "x86real.h"
@ -39,6 +39,47 @@ void pascal near tile_egc_copy_8(vram_offset_t vo_topleft, int image)
void pascal near tile_grcg_clear_8(vram_offset_t vo_topleft)
;
void tiles_render_all(void)
{
_ES = SEG_PLANE_B;
tile_copy_lines_top = 0;
tile_copy_lines_h = TILE_H;
/* TODO: Replace with the decompiled call
* egc_start_copy_noframe();
* once that function is part of this translation unit */
_asm { push cs; call near ptr egc_start_copy_noframe; }
if(tile_mode == TM_TILES) {
int tile_y = 0;
int image;
vram_offset_t vo_row = vram_offset_shift(PLAYFIELD_LEFT, 0);
while(tile_y < TILES_Y) {
int tile_x = 0;
vram_offset_t vo_col = vo_row;
while(tile_x < TILES_X) {
image = tile_ring[tile_y][tile_x];
// ZUN bloat: Only needs a regular tile copy, which wouldn't
// have needed the [tile_copy_*] assignments above.
tile_egc_copy_lines_8(vo_col, image);
tile_x++;
vo_col += TILE_VRAM_W;
}
tile_y++;
vo_row += (TILE_H * ROW_SIZE);
}
} else {
grcg_setcolor(GC_RMW, 0);
grcg_boxfill_8( \
PLAYFIELD_LEFT, PLAYFIELD_TOP, PLAYFIELD_RIGHT, PLAYFIELD_BOTTOM \
);
grcg_off();
}
egc_off();
}
void pascal tile_ring_set_and_put_both_8(
screen_x_t left_, vram_y_t y_, int image
)

View File

@ -66,4 +66,9 @@ static const vram_x_t TILE_AREA_VRAM_LEFT = (TILE_AREA_LEFT / BYTE_DOTS);
// If `true`, the next call to tiles_egc_render() will unconditionally
// redraw all tiles and then reset this flag to `false`.
extern bool tiles_egc_render_all;
// Blits all tiles in the [tile_ring] from the tile source area to the
// playfield if [tile_mode] to TM_TILES. Fills the playfield with hardware
// palette color 0 in all other modes.
void tiles_render_all(void);
#endif

View File

@ -1614,85 +1614,9 @@ loc_4770:
leave
retf
sub_4692 endp
even
; ---------------------------------------------------------------------------
nop
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_4782 proc far
@@vo = word ptr -6
@@image = word ptr -4
var_2 = word ptr -2
push bp
mov bp, sp
sub sp, 6
push si
push di
mov ax, 0A800h
mov es, ax
assume es:nothing
mov _tile_copy_lines_top, 0
mov _tile_copy_lines_h, TILE_H
call @egc_start_copy_noframe$qv
cmp _tile_mode, TM_TILES
jnz short loc_47E6
mov [bp+var_2], 0
mov [bp+@@vo], PLAYFIELD_VRAM_LEFT
jmp short loc_47DE
; ---------------------------------------------------------------------------
loc_47B2:
xor si, si
mov di, [bp+@@vo]
jmp short loc_47D1
; ---------------------------------------------------------------------------
loc_47B9:
mov bx, [bp+var_2]
imul bx, TILES_X
mov al, _tile_ring[bx+si]
mov ah, 0
mov [bp+@@image], ax
call @tile_egc_copy_lines_8$qii pascal, di, ax
inc si
add di, TILE_VRAM_W
loc_47D1:
cmp si, TILES_X
jl short loc_47B9
inc [bp+var_2]
add [bp+@@vo], (TILE_H * ROW_SIZE)
loc_47DE:
cmp [bp+var_2], TILES_Y
jl short loc_47B2
jmp short loc_4803
; ---------------------------------------------------------------------------
loc_47E6:
push GC_RMW
push 0
nopcall grcg_setcolor
push PLAYFIELD_VRAM_LEFT
push PLAYFIELD_TOP
push PLAYFIELD_VRAM_RIGHT
push PLAYFIELD_BOTTOM
nopcall grcg_byteboxfill_x
nopcall grcg_off
loc_4803:
nopcall egc_off
pop di
pop si
leave
retf
sub_4782 endp
extern @tiles_render_all$qv:proc
extern @TILE_RING_SET_AND_PUT_BOTH_8$QIII:proc
extern @TILE_EGC_ROLL_COPY_8$QIII:proc
_TEXT ends
@ -2281,7 +2205,7 @@ loc_B8B5:
graph_accesspage 1
call sub_4596
graph_accesspage 0
call sub_4782
call @tiles_render_all$qv
call _mpn_free
call mpn_load pascal, ds, offset aMiko_k_mpn ; "miko_k.mpn"
les bx, _resident
@ -2338,9 +2262,9 @@ sub_B98E proc near
call sub_C5B0
mov _player_invincibility_time, CONTINUE_INVINCIBILITY_FRAMES
graph_accesspage _page_front
call sub_4782
call @tiles_render_all$qv
graph_accesspage _page_back
call sub_4782
call @tiles_render_all$qv
call sub_10E0A
mov PaletteTone, 100
call far ptr palette_show