From 60621f8aa85378a1269d26e8689190e0d9c2ddbe Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 9 Jan 2022 04:28:59 +0100 Subject: [PATCH] [Decompilation] [th01] Sariel: Pattern 11/16 The one where Sariel fires four semicircle spreads from their shield, 10 frames apart. So nice and simple that it warrants trying out a more compact coding style for these `for` loops with two loop variables. The more I look at it, the more I like it? I do think it's good. Completes P0178, funded by Ember2528. --- th01/main/boss/b20m.cpp | 33 ++++++++++++ th01_reiiden.asm | 110 +--------------------------------------- 2 files changed, 35 insertions(+), 108 deletions(-) diff --git a/th01/main/boss/b20m.cpp b/th01/main/boss/b20m.cpp index 9464253e..0f21b1e1 100644 --- a/th01/main/boss/b20m.cpp +++ b/th01/main/boss/b20m.cpp @@ -1996,3 +1996,36 @@ void near pattern_symmetric_birds_from_bottom(void) #undef velocity #undef rays } + +void near pattern_four_semicircle_spreads(void) +{ + enum { + ORIGIN_X = SHIELD_CENTER_X, + ORIGIN_Y = (SHIELD_CENTER_Y - (PELLET_H / 2)), + }; + + int i; + unsigned char angle; + + if(boss_phase_frame < 50) { + return; + } else if(boss_phase_frame == 50) { + for((angle = 0x00, i = 0); i < 20; (angle += 0x07, i++)) { + Pellets.add_single(ORIGIN_X, ORIGIN_Y, angle, to_sp(2.0f)); + } + } else if(boss_phase_frame == 60) { + for((angle = 0x04, i = 0); i < 10; (angle += 0x0C, i++)) { + Pellets.add_single(ORIGIN_X, ORIGIN_Y, angle, to_sp(3.0f)); + } + } else if(boss_phase_frame == 70) { + for((angle = 0x04, i = 0); i < 8; (angle += 0x0E, i++)) { + Pellets.add_single(ORIGIN_X, ORIGIN_Y, angle, to_sp(4.0f)); + } + } else if(boss_phase_frame == 80) { + for((angle = 0x0E, i = 0); i < 10; (angle += 0x0A, i++)) { + Pellets.add_single(ORIGIN_X, ORIGIN_Y, angle, to_sp(3.0f)); + } + } else if(boss_phase_frame > 150) { + boss_phase_frame = 0; + } +} diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 5dc4be4f..ccbd5595 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -22449,6 +22449,7 @@ main_36_TEXT segment byte public 'CODE' use16 @pattern_rain_from_top$qv procdesc near @pattern_radial_stacks_and_lasers$qv procdesc near @pattern_symmetric_birds_from_bot$qv procdesc near + @pattern_four_semicircle_spreads$qv procdesc near main_36_TEXT ends main_36__TEXT segment byte public 'CODE' use16 @@ -22460,113 +22461,6 @@ include th01/main/boss/anim.inc sariel_shield equ -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_2AECE proc near - -@@angle = byte ptr -1 - - enter 2, 0 - push si - cmp _boss_phase_frame, 50 - jl loc_2AFDC - cmp _boss_phase_frame, 50 - jnz short loc_2AF19 - mov [bp+@@angle], 0 - xor si, si - jmp short loc_2AF11 -; --------------------------------------------------------------------------- - -loc_2AEEB: - call @CPellets@add_single$qiiuci15pellet_motion_tiii c, offset _Pellets, ds, large 320 or (160 shl 16), word ptr [bp+@@angle], (2 shl 4), large PM_NORMAL or (0 shl 16), large 0 or (0 shl 16) - mov al, [bp+@@angle] - add al, 7 - mov [bp+@@angle], al - inc si - -loc_2AF11: - cmp si, 14h - jl short loc_2AEEB - jmp loc_2AFDC -; --------------------------------------------------------------------------- - -loc_2AF19: - cmp _boss_phase_frame, 60 - jnz short loc_2AF56 - mov [bp+@@angle], 4 - xor si, si - jmp short loc_2AF4E -; --------------------------------------------------------------------------- - -loc_2AF28: - call @CPellets@add_single$qiiuci15pellet_motion_tiii c, offset _Pellets, ds, large 320 or (160 shl 16), word ptr [bp+@@angle], (3 shl 4), large PM_NORMAL or (0 shl 16), large 0 or (0 shl 16) - mov al, [bp+@@angle] - add al, 0Ch - mov [bp+@@angle], al - inc si - -loc_2AF4E: - cmp si, 0Ah - jl short loc_2AF28 - jmp loc_2AFDC -; --------------------------------------------------------------------------- - -loc_2AF56: - cmp _boss_phase_frame, 70 - jnz short loc_2AF92 - mov [bp+@@angle], 4 - xor si, si - jmp short loc_2AF8B -; --------------------------------------------------------------------------- - -loc_2AF65: - call @CPellets@add_single$qiiuci15pellet_motion_tiii c, offset _Pellets, ds, large 320 or (160 shl 16), word ptr [bp+@@angle], (4 shl 4), large PM_NORMAL or (0 shl 16), large 0 or (0 shl 16) - mov al, [bp+@@angle] - add al, 0Eh - mov [bp+@@angle], al - inc si - -loc_2AF8B: - cmp si, 8 - jl short loc_2AF65 - jmp short loc_2AFDC -; --------------------------------------------------------------------------- - -loc_2AF92: - cmp _boss_phase_frame, 80 - jnz short loc_2AFCE - mov [bp+@@angle], 0Eh - xor si, si - jmp short loc_2AFC7 -; --------------------------------------------------------------------------- - -loc_2AFA1: - call @CPellets@add_single$qiiuci15pellet_motion_tiii c, offset _Pellets, ds, large 320 or (160 shl 16), word ptr [bp+@@angle], (3 shl 4), large PM_NORMAL or (0 shl 16), large 0 or (0 shl 16) - mov al, [bp+@@angle] - add al, 0Ah - mov [bp+@@angle], al - inc si - -loc_2AFC7: - cmp si, 0Ah - jl short loc_2AFA1 - jmp short loc_2AFDC -; --------------------------------------------------------------------------- - -loc_2AFCE: - cmp _boss_phase_frame, 150 - jle short loc_2AFDC - mov _boss_phase_frame, 0 - -loc_2AFDC: - pop si - leave - retn -sub_2AECE endp - - ; =============== S U B R O U T I N E ======================================= ; Attributes: bp-based frame @@ -24892,7 +24786,7 @@ loc_2C6F2: loc_2C751: cmp word_35E95, 1 jnz short loc_2C75D - call sub_2AECE + call @pattern_four_semicircle_spreads$qv jmp short loc_2C767 ; ---------------------------------------------------------------------------