[Decompilation] [th05] Sara: Phase 2 (with externally selected pattern)

Part of P0227, funded by nrook.
This commit is contained in:
nmlgc 2022-12-05 12:14:32 +01:00
parent a6ba9d88ff
commit 6dd29fe5ba
2 changed files with 43 additions and 41 deletions

View File

@ -5,8 +5,28 @@
#include "platform.h" #include "platform.h"
#include "pc98.h" #include "pc98.h"
#include "th01/math/area.hpp"
#include "th01/math/subpixel.hpp" #include "th01/math/subpixel.hpp"
extern "C" {
#include "th04/math/motion.hpp"
#include "th04/snd/snd.h"
#include "th04/main/playfld.hpp"
#include "th04/main/pattern.hpp" #include "th04/main/pattern.hpp"
#include "th04/main/bullet/bullet.hpp"
}
#include "th04/main/gather.hpp"
#include "th05/main/boss/boss.hpp"
// Constants
// ---------
static const int PHASE_2_PATTERN_START_FRAME = 16;
enum sara_colors_t {
COL_GATHER_1 = 9,
COL_GATHER_2 = 8,
};
// ---------
// State // State
// ----- // -----
@ -47,3 +67,24 @@ union sara_state_t {
#define phase_2_3_pattern sara_phase_2_3_pattern #define phase_2_3_pattern sara_phase_2_3_pattern
extern pattern_loop_func_t phase_2_3_pattern; extern pattern_loop_func_t phase_2_3_pattern;
// ----- // -----
void near phase_2_with_pattern(void)
{
if(boss.phase_frame < PHASE_2_PATTERN_START_FRAME) {
gather_add_only_3stack(
(boss.phase_frame - 1), COL_GATHER_1, COL_GATHER_2
);
if(boss.phase_frame == 1) {
snd_se_play(8);
state->phase_2.angle_counterclockwise = 0x80;
state->phase_2.angle_clockwise = 0x00;
state->phase_2.angle_stacks = 0x08;
}
return;
}
if(boss_flystep_random(boss.phase_frame - PHASE_2_PATTERN_START_FRAME)) {
boss.phase_frame = 0;
boss.mode = 0;
}
phase_2_3_pattern();
}

View File

@ -10254,50 +10254,11 @@ MIDBOSS1_TEXT segment byte public 'CODE' use16
MIDBOSS1_TEXT ends MIDBOSS1_TEXT ends
B1_UPDATE_TEXT segment byte public 'CODE' use16 B1_UPDATE_TEXT segment byte public 'CODE' use16
@phase_2_with_pattern$qv procdesc near
B1_UPDATE_TEXT ends B1_UPDATE_TEXT ends
B4_UPDATE_TEXT segment byte public 'CODE' use16 B4_UPDATE_TEXT segment byte public 'CODE' use16
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_181E5 proc near
push bp
mov bp, sp
cmp _boss_phase_frame, 16
jge short loc_1821C
mov ax, _boss_phase_frame
dec ax
call @gather_add_only_3stack$qiii pascal, ax, large (9 shl 16) or 8
cmp _boss_phase_frame, 1
jnz short loc_18239
call snd_se_play pascal, 8
mov _boss_statebyte[15], 80h
mov _boss_statebyte[14], 0
mov _boss_statebyte[13], 8
pop bp
retn
; ---------------------------------------------------------------------------
loc_1821C:
mov ax, _boss_phase_frame
add ax, -16
call @boss_flystep_random$qi pascal, ax
or al, al
jz short loc_18235
mov _boss_phase_frame, 0
mov _boss_mode, 0
loc_18235:
call _sara_phase_2_3_pattern
loc_18239:
pop bp
retn
sub_181E5 endp
; =============== S U B R O U T I N E ======================================= ; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame ; Attributes: bp-based frame
@ -10919,7 +10880,7 @@ loc_187DE:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
loc_18800: loc_18800:
call sub_181E5 call @phase_2_with_pattern$qv
cmp _boss_phase_frame, 0 cmp _boss_phase_frame, 0
jnz short loc_18819 jnz short loc_18819
cmp _boss_statebyte[9], 0Ch cmp _boss_statebyte[9], 0Ch