[Decompilation] [th01] Kikuri: Pattern 8/10

The one where Kikuri fires 6 lasers from her left eye, 30 frames apart,
and randomly aimed within a 120-pixel range around the player.

Part of P0199, funded by Lmocinemod.
This commit is contained in:
nmlgc 2022-06-09 16:00:12 +02:00
parent 46bc4fbe64
commit a8191f029a
2 changed files with 76 additions and 166 deletions

View File

@ -679,6 +679,22 @@ void near pattern_souls_drop_tears_and_move_diagonally(void)
); \
}
inline void fire_random_aimed_eye_laser(
int i,
screen_x_t origin_left,
pixel_t aim_range_x,
const int &speed_multiplied_by_8,
pixel_t w
) {
fire_aimed_eye_laser(
i,
origin_left,
((rand() % (aim_range_x * 2)) - aim_range_x),
speed_multiplied_by_8,
w
);
}
void near pattern_two_crossed_eye_lasers(void)
{
// Yup, first firing on [boss_phase_frame] 400.
@ -761,3 +777,61 @@ int near pattern_4_spiral_along_disc(void)
#undef angle
}
int near pattern_single_lasers_from_left_eye(void)
{
enum {
ORIGIN_X = EYE_LEFT_CENTER_X,
LASER_W = 4,
// Should *technically* subtract (LASER_W / 2), as seen in
// pattern_two_crossed_eye_lasers().
RANGE_X = ((PLAYFIELD_W / 10) - LASER_W),
};
if(boss_phase_frame <= 200) { // (redundant)
return 1;
}
if(boss_phase_frame == 250) {
select_for_rank(pattern_state.speed_multiplied_by_8,
(to_sp(6.5f) / 2),
(to_sp(7.0f) / 2),
(to_sp(7.5f) / 2),
(to_sp(8.0f) / 2)
);
mdrv2_se_play(6);
fire_random_aimed_eye_laser(
0, ORIGIN_X, RANGE_X, pattern_state.speed_multiplied_by_8, LASER_W
);
} else if(boss_phase_frame == 280) {
mdrv2_se_play(6);
fire_random_aimed_eye_laser(
1, ORIGIN_X, RANGE_X, pattern_state.speed_multiplied_by_8, LASER_W
);
} else if(boss_phase_frame == 310) {
mdrv2_se_play(6);
fire_random_aimed_eye_laser(
2, ORIGIN_X, RANGE_X, pattern_state.speed_multiplied_by_8, LASER_W
);
} else if(boss_phase_frame == 340) {
mdrv2_se_play(6);
fire_random_aimed_eye_laser(
3, ORIGIN_X, RANGE_X, pattern_state.speed_multiplied_by_8, LASER_W
);
} else if(boss_phase_frame == 370) {
mdrv2_se_play(6);
fire_random_aimed_eye_laser(
4, ORIGIN_X, RANGE_X, pattern_state.speed_multiplied_by_8, LASER_W
);
} else if(boss_phase_frame == 400) {
mdrv2_se_play(6);
fire_random_aimed_eye_laser(
5, ORIGIN_X, RANGE_X, pattern_state.speed_multiplied_by_8, LASER_W
);
}
if(boss_phase_frame > 500) {
boss_phase_frame = 0;
return 2;
}
return 1;
}

View File

@ -14716,6 +14716,7 @@ main_34_TEXT segment byte public 'CODE' use16
@pattern_two_crossed_eye_lasers$qv procdesc near
@pattern_souls_single_aimed_pelle$qv procdesc near
@pattern_4_spiral_along_disc$qv procdesc near
@pattern_single_lasers_from_left_$qv procdesc near
main_34_TEXT ends
main_34__TEXT segment byte public 'CODE' use16
@ -14723,171 +14724,6 @@ main_34__TEXT segment byte public 'CODE' use16
;org 4
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_24316 proc near
push bp
mov bp, sp
cmp _boss_phase_frame, 200
jle loc_244C9
cmp _boss_phase_frame, 250
jnz short loc_24378
call @kikuri_select_for_rank$qmiiiii stdcall, offset _kikuri_pattern_state, ds, large 34h or (38h shl 16), large 3Ch or (40h shl 16)
push 6
call _mdrv2_se_play
add sp, 0Eh
push 20 or (4 shl 16) ; (moveout_at_age) or (w shl 16)
push 10 ; col
push _kikuri_pattern_state ; speed_multiplied_by_8
push PLAYFIELD_BOTTOM ; target_y
call IRand
mov bx, 120
cwd
idiv bx
add dx, _player_left
add dx, -60
push dx ; target_left
push 307 or (147 shl 16) ; (origin_left) or (origin_y shl 16)
push ds ; this (segment)
push offset shootout_laser_0 ; this (offset)
jmp loc_244AE
; ---------------------------------------------------------------------------
loc_24378:
cmp _boss_phase_frame, 280
jnz short loc_243B7
push 6
call _mdrv2_se_play
pop cx
push 20 or (4 shl 16) ; (moveout_at_age) or (w shl 16)
push 10 ; col
push _kikuri_pattern_state ; speed_multiplied_by_8
push PLAYFIELD_BOTTOM ; target_y
call IRand
mov bx, 120
cwd
idiv bx
add dx, _player_left
add dx, -60
push dx ; target_left
push 307 or (147 shl 16) ; (origin_left) or (origin_y shl 16)
push ds ; this (segment)
push offset shootout_laser_1 ; this (offset)
jmp loc_244AE
; ---------------------------------------------------------------------------
loc_243B7:
cmp _boss_phase_frame, 310
jnz short loc_243F6
push 6
call _mdrv2_se_play
pop cx
push 20 or (4 shl 16) ; (moveout_at_age) or (w shl 16)
push 10 ; col
push _kikuri_pattern_state ; speed_multiplied_by_8
push PLAYFIELD_BOTTOM ; target_y
call IRand
mov bx, 120
cwd
idiv bx
add dx, _player_left
add dx, -60
push dx ; target_left
push 307 or (147 shl 16) ; (origin_left) or (origin_y shl 16)
push ds ; this (segment)
push offset shootout_laser_2 ; this (offset)
jmp loc_244AE
; ---------------------------------------------------------------------------
loc_243F6:
cmp _boss_phase_frame, 340
jnz short loc_24434
push 6
call _mdrv2_se_play
pop cx
push 20 or (4 shl 16) ; (moveout_at_age) or (w shl 16)
push 10 ; col
push _kikuri_pattern_state ; speed_multiplied_by_8
push PLAYFIELD_BOTTOM ; target_y
call IRand
mov bx, 120
cwd
idiv bx
add dx, _player_left
add dx, -60
push dx ; target_left
push 307 or (147 shl 16) ; (origin_left) or (origin_y shl 16)
push ds ; this (segment)
push offset shootout_laser_3 ; this (offset)
jmp short loc_244AE
; ---------------------------------------------------------------------------
loc_24434:
cmp _boss_phase_frame, 370
jnz short loc_24472
push 6
call _mdrv2_se_play
pop cx
push 20 or (4 shl 16) ; (moveout_at_age) or (w shl 16)
push 10 ; col
push _kikuri_pattern_state ; speed_multiplied_by_8
push PLAYFIELD_BOTTOM ; target_y
call IRand
mov bx, 120
cwd
idiv bx
add dx, _player_left
add dx, -60
push dx ; target_left
push 307 or (147 shl 16) ; (origin_left) or (origin_y shl 16)
push ds ; this (segment)
push offset shootout_laser_4 ; this (offset)
jmp short loc_244AE
; ---------------------------------------------------------------------------
loc_24472:
cmp _boss_phase_frame, 400
jnz short loc_244B6
push 6
call _mdrv2_se_play
pop cx
push 20 or (4 shl 16) ; (moveout_at_age) or (w shl 16)
push 10 ; col
push _kikuri_pattern_state ; speed_multiplied_by_8
push PLAYFIELD_BOTTOM ; target_y
call IRand
mov bx, 120
cwd
idiv bx
add dx, _player_left
add dx, -60
push dx ; target_left
push 307 or (147 shl 16) ; (origin_left) or (origin_y shl 16)
push ds ; this (segment)
push offset shootout_laser_5 ; this (offset)
loc_244AE:
call @CShootoutLaser@spawn$qiiiiiiii
add sp, 14h
loc_244B6:
cmp _boss_phase_frame, 500
jle short loc_244C9
mov _boss_phase_frame, 0
mov ax, 2
pop bp
retn
; ---------------------------------------------------------------------------
loc_244C9:
mov ax, 1
pop bp
retn
sub_24316 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
@ -15669,7 +15505,7 @@ loc_24CFA:
loc_24D1C:
cmp word_35D14, 1
jnz short loc_24D28
call sub_24316
call @pattern_single_lasers_from_left_$qv
jmp short loc_24D3E
; ---------------------------------------------------------------------------