From 8b046dad0fbc44d0ed9f852d6e6e79fa23ec9443 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Wed, 17 Nov 2021 22:29:48 +0100 Subject: [PATCH] [Decompilation] [th04/th05] EMS: Rendering the eyecatch image Copied in from EMS memory if available. Completes P0168, funded by Blue Bolt and rosenrose. --- th04/main/ems.cpp | 21 ++++++++++++++++++++ th04/main/ems.hpp | 11 +++++++++++ th04/sprites/main_cdg.h | 3 ++- th04_main.asm | 44 ++--------------------------------------- th05_main.asm | 44 ++--------------------------------------- 5 files changed, 38 insertions(+), 85 deletions(-) diff --git a/th04/main/ems.cpp b/th04/main/ems.cpp index 01ca0492..44916f25 100644 --- a/th04/main/ems.cpp +++ b/th04/main/ems.cpp @@ -136,3 +136,24 @@ void near bomb_bg_load__ems_preload_playchar_cdgs(void) ); } #endif + +void near eyecatch_animate(void) +{ + if(Ems) { + allocate_and_load_from_ems( + cdg_slots[CDG_EYECATCH].seg_colors(), + EMS_EYECATCH_OFFSET, + (cdg_slots[CDG_EYECATCH].bitplane_size * PLANE_COUNT) + ); + } else { + cdg_load_single_noalpha(CDG_EYECATCH, eyename, 0); + } + palette_black(); + cdg_put_noalpha_8( + (PLAYFIELD_LEFT + (PLAYFIELD_W / 2) - (EYECATCH_W / 2)), + (PLAYFIELD_TOP + (PLAYFIELD_H / 2) - (EYECATCH_H / 2)), + CDG_EYECATCH + ); + cdg_free(CDG_EYECATCH); + palette_black_in(1); +} diff --git a/th04/main/ems.hpp b/th04/main/ems.hpp index e59493bf..5c3c72ea 100644 --- a/th04/main/ems.hpp +++ b/th04/main/ems.hpp @@ -68,4 +68,15 @@ void near bomb_bg_load__ems_preload_playchar_cdgs(void); #if (GAME == 5) void pascal near ems_preload_boss_faceset(const char *fn); #endif + +void near eyecatch_animate(void); + +// Helper functions +// ---------------- + +#define allocate_and_load_from_ems(dst_seg, src_off, size) { \ + reinterpret_cast(dst_seg) = hmem_allocbyte(size); \ + ems_read(Ems, src_off, dst_seg, size); \ +} +// ---------------- /// -------------- diff --git a/th04/sprites/main_cdg.h b/th04/sprites/main_cdg.h index 6b8194f2..7353d39b 100644 --- a/th04/sprites/main_cdg.h +++ b/th04/sprites/main_cdg.h @@ -3,7 +3,8 @@ #define FACESET_BOSS_COUNT 6 #define EYECATCH_W 288 - #define EYECATCH_H 130 + // 130 in the file, and therefore shifted towards the top of the playfield. + #define EYECATCH_H 176 #define BOMB_BG_W_MAX ((PLAYFIELD_W / 6) * 5) #define BOMB_BG_H_MAX PLAYFIELD_H diff --git a/th04_main.asm b/th04_main.asm index dbd117c4..28009fc0 100644 --- a/th04_main.asm +++ b/th04_main.asm @@ -710,7 +710,7 @@ loc_AF4A: call main_01:_playfield_tram_wipe call main_01:sub_B1D0 nopcall main_01:hud_put - call main_01:sub_B616 + call @eyecatch_animate$qv call sub_19EBC cmp word_213DE, 0 jz short loc_AFD5 @@ -1055,51 +1055,11 @@ mai_TEXT ends EMS_TEXT segment byte public 'CODE' use16 @ems_allocate_and_preload_eyecatc$qv procdesc near @bomb_bg_load__ems_preload_playch$qv procdesc near + @eyecatch_animate$qv procdesc near EMS_TEXT ends main_TEXT segment word public 'CODE' use16 -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_B616 proc near - push bp - mov bp, sp - cmp _Ems, 0 - jz short loc_B64C - mov ax, _cdg_slots.CDG_plane_size + (size cdg_t * CDG_EYE) - shl ax, 2 - push ax - call hmem_allocbyte - mov _cdg_slots.seg_colors + (size cdg_t * CDG_EYE), ax - push _Ems - pushd 0 - push ax - push 0 - mov ax, _cdg_slots.CDG_plane_size + (size cdg_t * CDG_EYE) - shl ax, 2 - movzx eax, ax - push eax - call ems_read - jmp short loc_B65A -; --------------------------------------------------------------------------- - -loc_B64C: - call cdg_load_single_noalpha pascal, CDG_EYE, [_eyename], 0 - -loc_B65A: - mov PaletteTone, 0 - call far ptr palette_show - call cdg_put_noalpha_8 pascal, large (32 shl 16) or 112, CDG_EYE - call cdg_free pascal, CDG_EYE - push 1 - call palette_black_in - pop bp - retn -sub_B616 endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame diff --git a/th05_main.asm b/th05_main.asm index 2fea091b..b7d6489e 100644 --- a/th05_main.asm +++ b/th05_main.asm @@ -797,7 +797,7 @@ loc_B2DD: call _playfield_tram_wipe call sub_B55A nopcall hud_put - call sub_BA66 + call @eyecatch_animate$qv call sub_172FF cmp word_20A84, 0 jz loc_B3CA @@ -1221,50 +1221,10 @@ EMS_TEXT segment byte public 'CODE' use16 @bomb_bg_load__ems_preload_playch$qv procdesc near @EMS_PRELOAD_BOSS_FACESET$QNXC procdesc pascal near \ fn_seg:word, fn_off:word + @eyecatch_animate$qv procdesc near EMS_TEXT ends CFG_LRES_TEXT segment byte public 'CODE' use16 - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_BA66 proc near - push bp - mov bp, sp - cmp _Ems, 0 - jz short loc_BA9C - mov ax, _cdg_slots.CDG_plane_size + (size cdg_t * CDG_EYE) - shl ax, 2 - push ax - call hmem_allocbyte - mov _cdg_slots.seg_colors + (size cdg_t * CDG_EYE), ax - push _Ems - pushd 0 - push ax - push 0 - mov ax, _cdg_slots.CDG_plane_size + (size cdg_t * CDG_EYE) - shl ax, 2 - movzx eax, ax - push eax - call ems_read - jmp short loc_BAAA -; --------------------------------------------------------------------------- - -loc_BA9C: - call cdg_load_single_noalpha pascal, CDG_EYE, [_eyename], 0 - -loc_BAAA: - mov PaletteTone, 0 - call far ptr palette_show - call cdg_put_noalpha_8 pascal, large (80 shl 16) or 112, CDG_EYE - call cdg_free pascal, CDG_EYE - push 1 - call palette_black_in - pop bp - retn -sub_BA66 endp - _cfg_load_resident_ptr procdesc near CFG_LRES_TEXT ends