From 5db5df4da3b160c599197e722835997d7a22cb8f Mon Sep 17 00:00:00 2001 From: nmlgc Date: Wed, 29 Dec 2021 01:05:30 +0100 Subject: [PATCH] [Decompilation] [th01] Sariel: Shield animation Part of P0175, funded by Ember2528. --- th01/main/boss/b20m.cpp | 15 +++++++++++ th01/main/boss/entity_a.hpp | 9 +++++++ th01_reiiden.asm | 50 ++++--------------------------------- 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/th01/main/boss/b20m.cpp b/th01/main/boss/b20m.cpp index 61432a44..be71b060 100644 --- a/th01/main/boss/b20m.cpp +++ b/th01/main/boss/b20m.cpp @@ -446,3 +446,18 @@ void pascal near birds_reset_fire_spawn_unput_update_render( } } } + +void near shield_render_both(void) +{ + enum { + CELS = 4, + FRAMES_PER_CEL = 10, + }; + if((boss_phase_frame % FRAMES_PER_CEL) != 0) { + return; + } + int cel = ((boss_phase_frame % (FRAMES_PER_CEL * CELS)) / FRAMES_PER_CEL); + ent_shield.bos_image = cel; + graph_accesspage_func(1); ent_shield.move_lock_and_put_8(); + graph_accesspage_func(0); ent_shield.move_lock_and_put_8(); +} diff --git a/th01/main/boss/entity_a.hpp b/th01/main/boss/entity_a.hpp index ddcfe61f..055a61bf 100644 --- a/th01/main/boss/entity_a.hpp +++ b/th01/main/boss/entity_a.hpp @@ -54,6 +54,10 @@ public: pixel_t &h ) const; + void set_image(int image) { + bos_image = image; + } + /// Blitting /// -------- // All functions with an [image] parameter use that image from [bos_slot], @@ -218,6 +222,11 @@ public: int unused, pixel_t delta_x, pixel_t delta_y, int lock_frames ); + void move_lock_and_put_8(void) { + move_lock_frame = 0; + move_lock_and_put_8(0, 0, 0, 3); + } + void move_lock_and_put_image_8(int image) { move_lock_frame = 0; bos_image = image; diff --git a/th01_reiiden.asm b/th01_reiiden.asm index d7df68e1..2b3bf04e 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -22435,6 +22435,7 @@ main_36_TEXT segment byte public 'CODE' use16 @SPAWNRAY_UNPUT_AND_PUT$QIIIII procdesc pascal near \ origin:Point, target_x:word, target_y:word, col:word @BIRDS_RESET_FIRE_SPAWN_UNPUT_UPD$QDDDDC procdesc pascal near + @shield_render_both$qv procdesc near main_36_TEXT ends main_36__TEXT segment byte public 'CODE' use16 @@ -22448,47 +22449,6 @@ sariel_shield equ sariel_dress equ sariel_wand equ -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_28EA6 proc near - -var_2 = word ptr -2 - - enter 2, 0 - mov ax, _boss_phase_frame - mov bx, 10 - cwd - idiv bx - or dx, dx - jnz short locret_28F0F - mov ax, _boss_phase_frame - mov bx, 40 - cwd - idiv bx - mov bx, 10 - mov ax, dx - cwd - idiv bx - mov [bp+var_2], ax - mov sariel_shield.BE_bos_image, ax - push 1 - call _graph_accesspage_func - mov sariel_shield.BE_move_lock_frame, 0 - call @CBossEntity@move_lock_and_put_8$qiiii stdcall, offset sariel_shield, ds, large 0, large 0 or (3 shl 16) - push 0 - call _graph_accesspage_func - mov sariel_shield.BE_move_lock_frame, 0 - call @CBossEntity@move_lock_and_put_8$qiiii stdcall, offset sariel_shield, ds, large 0, large 0 or (3 shl 16) - add sp, 1Ch - -locret_28F0F: - leave - retn -sub_28EA6 endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame @@ -27784,7 +27744,7 @@ loc_2C399: loc_2C3BE: inc _boss_phase_frame inc _sariel_invincibility_frame - call sub_28EA6 + call @shield_render_both$qv call sub_28FC5 fldz sub sp, 8 @@ -27899,7 +27859,7 @@ loc_2C4D8: jnz loc_2C594 inc _boss_phase_frame inc _sariel_invincibility_frame - call sub_28EA6 + call @shield_render_both$qv call sub_28FC5 push 0 call sub_29D8B @@ -27996,7 +27956,7 @@ loc_2C5D6: jnz loc_2C6B0 inc _boss_phase_frame inc _sariel_invincibility_frame - call sub_28EA6 + call @shield_render_both$qv call sub_28FC5 call sub_2A469 cmp word_35E95, 0 @@ -28114,7 +28074,7 @@ loc_2C6F2: jnz loc_2C7F1 inc _boss_phase_frame inc _sariel_invincibility_frame - call sub_28EA6 + call @shield_render_both$qv call sub_28FC5 push 1 call sub_29D8B