From 6e0f9e568af28e80f7c9381372a87ab16dbed7c6 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 16 Aug 2021 23:13:27 +0200 Subject: [PATCH] [Decompilation] [th01] Sariel: Wand sprite unblitting and background snapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mission accomplished, Sariel unblocked… but what do we now do with the remaining ¾ of this push? I'd really like to focus on Sariel in her own dedicated push series… Part of P0167, funded by Ember2528. --- th01/main/boss/b20m.cpp | 35 ++++++++-- th01_reiiden.asm | 142 +++------------------------------------- 2 files changed, 40 insertions(+), 137 deletions(-) diff --git a/th01/main/boss/b20m.cpp b/th01/main/boss/b20m.cpp index bea5485d..901a273c 100644 --- a/th01/main/boss/b20m.cpp +++ b/th01/main/boss/b20m.cpp @@ -44,9 +44,6 @@ static const screen_y_t WAND_TOP = 48; static const pixel_t WAND_W = 128; // That's 32 more than BOSS6_2.BOS is wide? static const pixel_t WAND_H = 96; - -static const int WAND_PTN_W = (WAND_W / PTN_W); -static const int WAND_PTN_H = (WAND_H / PTN_H); // ----------- #define flash_colors sariel_flash_colors @@ -137,7 +134,7 @@ void sariel_load_and_init(void) boss_palette_snap(); void sariel_setup(void); sariel_setup(); - ptn_new(PTN_SLOT_BG_ENT, ((WAND_PTN_W * WAND_PTN_H) + 4)); // ??? + ptn_new(PTN_SLOT_BG_ENT, (((WAND_W / PTN_W) * (WAND_H / PTN_H)) + 4)); // ? } void sariel_setup(void) @@ -155,3 +152,33 @@ void sariel_setup(void) anm_wand.left = WAND_LEFT; anm_wand.top = WAND_TOP; } + +void near wand_bg_snap(void) +{ + int ptn_x; + int ptn_y; + screen_x_t left = anm_wand.left; + screen_y_t top = anm_wand.top; + int image = 0; + + ptn_snap_rect_from_1_8( + left, top, WAND_W, WAND_H, PTN_SLOT_BG_ENT, image, ptn_x, ptn_y + ); +} + +void near wand_bg_put(void) +{ + int ptn_x; + int ptn_y; + screen_x_t left; + screen_y_t top; + int image; + + image = 0; + left = anm_wand.left; + top = anm_wand.top; + + ptn_put_rect_noalpha_8( + left, top, WAND_W, WAND_H, PTN_SLOT_BG_ENT, image, ptn_x, ptn_y + ) +} diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 04f52453..34daa64f 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -3561,7 +3561,6 @@ graph_TEXT ends SHARED segment byte public 'CODE' use16 extern _vram_planes_set:proc extern _egc_copy_rect_1_to_0_16:proc - extern _ptn_snap_8:proc SHARED ends ; =========================================================================== @@ -3571,7 +3570,6 @@ PTN_GRP_GRZ segment byte public 'CODE' use16 extern _ptn_new:proc extern _ptn_load:proc extern _ptn_free:proc - extern _ptn_put_noalpha_8:proc extern _grp_palette_load_show_sane:proc extern _grp_palette_load_show:proc extern _grp_put_palette_show:proc @@ -23227,6 +23225,8 @@ main_36_TEXT segment byte public 'CODE' use16 extern @sariel_select_for_rank$qmiiiii:proc extern @sariel_entrance$qc:proc extern @sariel_load_and_init$qv:proc + @wand_bg_snap$qv procdesc near + @wand_bg_put$qv procdesc near main_36_TEXT ends main_36__TEXT segment byte public 'CODE' use16 @@ -23242,130 +23242,6 @@ sariel_wand equ PTN_SLOT_BG_ENT = PTN_SLOT_BOSS_1 -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_28852 proc near - -@@image = word ptr -6 -@@top = word ptr -4 -@@left = word ptr -2 - - enter 6, 0 - push si - push di - mov ax, sariel_wand.BA_left - mov [bp+@@left], ax - mov ax, sariel_wand.BA_top - mov [bp+@@top], ax - mov [bp+@@image], 0 - push 1 - call _graph_accesspage_func - pop cx - xor di, di - jmp short loc_288A4 -; --------------------------------------------------------------------------- - -loc_28875: - xor si, si - jmp short loc_2889E -; --------------------------------------------------------------------------- - -loc_28879: - mov ax, [bp+@@image] - add ax, PTN_SLOT_2 - push ax - mov ax, di - shl ax, 5 - add ax, [bp+@@top] - push ax - mov ax, si - shl ax, 5 - add ax, [bp+@@left] - push ax - call _ptn_snap_8 - add sp, 6 - inc [bp+@@image] - inc si - -loc_2889E: - cmp si, 4 - jl short loc_28879 - inc di - -loc_288A4: - cmp di, 3 - jl short loc_28875 - push 0 - call _graph_accesspage_func - pop cx - pop di - pop si - leave - retn -sub_28852 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_288B5 proc near - -@@image = word ptr -6 -@@top = word ptr -4 -@@left = word ptr -2 - - enter 6, 0 - push si - push di - mov [bp+@@image], 0 - mov ax, sariel_wand.BA_left - mov [bp+@@left], ax - mov ax, sariel_wand.BA_top - mov [bp+@@top], ax - xor di, di - jmp short loc_288FF -; --------------------------------------------------------------------------- - -loc_288D0: - xor si, si - jmp short loc_288F9 -; --------------------------------------------------------------------------- - -loc_288D4: - mov ax, [bp+@@image] - add ax, PTN_SLOT_2 - push ax - mov ax, di - shl ax, 5 - add ax, [bp+@@top] - push ax - mov ax, si - shl ax, 5 - add ax, [bp+@@left] - push ax - call _ptn_put_noalpha_8 - add sp, 6 - inc [bp+@@image] - inc si - -loc_288F9: - cmp si, 4 - jl short loc_288D4 - inc di - -loc_288FF: - cmp di, 3 - jl short loc_288D0 - pop di - pop si - leave - retn -sub_288B5 endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame @@ -24074,11 +23950,11 @@ sub_28FA9 proc near mov bp, sp push 1 call _graph_accesspage_func - call sub_288B5 + call @wand_bg_put$qv push 0 call _graph_accesspage_func add sp, 4 - call sub_288B5 + call @wand_bg_put$qv pop bp retn sub_28FA9 endp @@ -29242,7 +29118,7 @@ loc_2C2F2: call @boss_palette_show$qv mov sariel_shield.BE_cur_left, 304 mov sariel_shield.BE_cur_top, 144 - call sub_28852 + call @wand_bg_snap$qv push 1 call sub_28F11 fld flt_35F66 @@ -29394,7 +29270,7 @@ loc_2C4A1: jnz loc_2CDCE mov _boss_phase, 3 mov _boss_phase_frame, 0 - call sub_28852 + call @wand_bg_snap$qv call IRand mov bx, 5 jmp loc_2C82A @@ -29487,7 +29363,7 @@ loc_2C594: jnz loc_2CDCE mov _boss_phase, 5 mov _boss_phase_frame, 0 - call sub_28852 + call @wand_bg_snap$qv call @boss_palette_snap$qv call IRand mov bx, 4 @@ -29605,7 +29481,7 @@ loc_2C6B0: jnz loc_2CDCE mov _boss_phase, 7 mov _boss_phase_frame, 0 - call sub_28852 + call @wand_bg_snap$qv call @boss_palette_snap$qv call IRand mov bx, 5 @@ -29730,7 +29606,7 @@ loc_2C7F1: jnz loc_2CDCE mov _boss_phase, 1 mov _boss_phase_frame, 0 - call sub_28852 + call @wand_bg_snap$qv call @boss_palette_snap$qv call IRand mov bx, 6