mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] [th01] Elis: Pattern 2/13
The one where Elis fires missiles from random locations around her sprite, aimed at random angles towards the bottom of the playfield. Part of P0193, funded by Ember2528.
This commit is contained in:
parent
af7dd08626
commit
85a76f74a8
|
@ -12,6 +12,7 @@
|
|||
#include "th01/math/dir.hpp"
|
||||
#include "th01/math/subpixel.hpp"
|
||||
extern "C" {
|
||||
#include "th01/math/vector.hpp"
|
||||
#include "th01/hardware/egc.h"
|
||||
#include "th01/hardware/graph.h"
|
||||
#include "th01/formats/pf.hpp"
|
||||
|
@ -77,6 +78,7 @@ extern bool initial_hp_rendered;
|
|||
static const int CHOOSE_NEW = 0;
|
||||
|
||||
extern union {
|
||||
int angle_range; // ACTUAL TYPE: unsigned char
|
||||
int speed_multiplied_by_8;
|
||||
} pattern_state;
|
||||
// --------
|
||||
|
@ -180,6 +182,56 @@ inline screen_y_t surround_random_top(elis_entity_t relative_to) {
|
|||
}
|
||||
// -------------
|
||||
|
||||
// .GRC entities
|
||||
// -------------
|
||||
|
||||
enum elis_grc_cel_t {
|
||||
RIFT_CELS = 2,
|
||||
|
||||
C_RIFT = 4,
|
||||
C_RIFT_last = (C_RIFT + RIFT_CELS - 1),
|
||||
};
|
||||
|
||||
#define elis_grc_sloppy_unput(entities, i) { \
|
||||
grc_sloppy_unput(entities.left[i], entities.top[i]); \
|
||||
}
|
||||
|
||||
#define elis_grc_put(entities, i, cel, col) { \
|
||||
grc_put_8(entities.left[i], entities.top[i], GRC_SLOT_BOSS_1, cel, col); \
|
||||
}
|
||||
|
||||
#define rifts_update_and_render(rifts, start_frame, end_frame, tmp_cel) { \
|
||||
if( \
|
||||
(boss_phase_frame >= start_frame) && \
|
||||
(boss_phase_frame <= end_frame) && \
|
||||
((boss_phase_frame % 4) == 0) \
|
||||
) { \
|
||||
for(int i = 0; i < rifts.count(); i++) { \
|
||||
/* Unblit */ \
|
||||
if(boss_phase_frame > start_frame) { \
|
||||
elis_grc_sloppy_unput(rifts, i); \
|
||||
} \
|
||||
\
|
||||
/* Initialize */ \
|
||||
if( \
|
||||
((boss_phase_frame % 16) == ((i * 4) % 16)) || \
|
||||
(boss_phase_frame == start_frame) \
|
||||
) { \
|
||||
rifts.left[i] = surround_random_left(ENT_STILL_OR_WAVE); \
|
||||
rifts.top[i] = surround_random_top(ENT_STILL_OR_WAVE); \
|
||||
} \
|
||||
\
|
||||
/* Render */ \
|
||||
if(boss_phase_frame < end_frame) { \
|
||||
tmp_cel = (rand() % RIFT_CELS); \
|
||||
elis_grc_put(rifts, i, (C_RIFT + cel), COL_FX); \
|
||||
} \
|
||||
} \
|
||||
mdrv2_se_play(7); \
|
||||
} \
|
||||
}
|
||||
// -------------
|
||||
|
||||
// .PTN
|
||||
// ----
|
||||
|
||||
|
@ -498,3 +550,41 @@ done:
|
|||
#undef circle_center_y
|
||||
#undef circle_center_x
|
||||
}
|
||||
|
||||
int pattern_random_downwards_missiles(void)
|
||||
{
|
||||
#define rifts pattern1_rifts
|
||||
|
||||
extern CEntities<5> rifts;
|
||||
int cel; // ACTUAL TYPE: elis_grc_cel_t
|
||||
pixel_t velocity_x;
|
||||
pixel_t velocity_y;
|
||||
unsigned char angle;
|
||||
|
||||
if(boss_phase_frame == 50) {
|
||||
ent_unput_and_put_both(ENT_STILL_OR_WAVE, C_HAND);
|
||||
select_for_rank(pattern_state.angle_range, 0x0F, 0x15, 0x19, 0x1D);
|
||||
}
|
||||
|
||||
// That's quite the brave placement for this branch...
|
||||
if((boss_phase_frame > 60) && ((boss_phase_frame % 3) == 0)) {
|
||||
int i = (rand() % rifts.count());
|
||||
angle = (
|
||||
(rand() % pattern_state.angle_range) -
|
||||
((pattern_state.angle_range - 0x01) / 2) +
|
||||
0x40
|
||||
);
|
||||
vector2(velocity_x, velocity_y, 7, angle);
|
||||
Missiles.add(rifts.left[i], rifts.top[i], velocity_x, velocity_y);
|
||||
}
|
||||
|
||||
rifts_update_and_render(rifts, 60, 160, cel);
|
||||
|
||||
if(boss_phase_frame > 170) {
|
||||
boss_phase_frame = 0;
|
||||
return CHOOSE_NEW;
|
||||
}
|
||||
return 2;
|
||||
|
||||
#undef rifts
|
||||
}
|
||||
|
|
216
th01_reiiden.asm
216
th01_reiiden.asm
|
@ -17409,219 +17409,11 @@ ELIS_BASE_TOP = (PLAYFIELD_TOP + ((PLAYFIELD_H / 21) * 5) - (ELIS_GIRL_H / 2))
|
|||
extern @wave_teleport$qii:proc
|
||||
extern @elis_select_for_rank$qmiiiii:proc
|
||||
extern @pattern_11_lasers_across$qv:proc
|
||||
extern @pattern_random_downwards_missile$qv:proc
|
||||
main_35_TEXT ends
|
||||
|
||||
main_35__TEXT segment byte public 'CODE' use16
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
||||
sub_256AA proc far
|
||||
|
||||
var_1E = qword ptr -1Eh
|
||||
var_16 = qword ptr -16h
|
||||
var_A = word ptr -0Ah
|
||||
@@angle = byte ptr -7
|
||||
@@vector_y = word ptr -6
|
||||
@@vector_x = word ptr -4
|
||||
var_2 = word ptr -2
|
||||
|
||||
enter 0Ah, 0
|
||||
push si
|
||||
cmp _boss_phase_frame, 50
|
||||
jnz short loc_25726
|
||||
push 1
|
||||
call _graph_accesspage_func
|
||||
pop cx
|
||||
call @girl_bg_put$qi stdcall, 1
|
||||
pop cx
|
||||
mov elis_still_or_wave.BE_move_lock_frame, 0
|
||||
mov elis_still_or_wave.BE_bos_image, 1
|
||||
call @CBossEntity@move_lock_and_put_8$qiiii c, offset elis_still_or_wave, ds, large 0, large 0 or (3 shl 16)
|
||||
push 0
|
||||
call _graph_accesspage_func
|
||||
pop cx
|
||||
mov elis_still_or_wave.BE_move_lock_frame, 0
|
||||
mov elis_still_or_wave.BE_bos_image, 1
|
||||
call @CBossEntity@move_lock_and_put_8$qiiii c, offset elis_still_or_wave, ds, large 0, large 0 or (3 shl 16)
|
||||
call @elis_select_for_rank$qmiiiii c, offset _elis_pattern_state, ds, large 15 or (21 shl 16), large 25 or (29 shl 16)
|
||||
|
||||
loc_25726:
|
||||
cmp _boss_phase_frame, 60
|
||||
jle loc_257C3
|
||||
mov ax, _boss_phase_frame
|
||||
mov bx, 3
|
||||
cwd
|
||||
idiv bx
|
||||
or dx, dx
|
||||
jnz loc_257C3
|
||||
call IRand
|
||||
mov bx, 5
|
||||
cwd
|
||||
idiv bx
|
||||
mov si, dx
|
||||
call IRand
|
||||
cwd
|
||||
idiv _elis_pattern_state
|
||||
mov ax, _elis_pattern_state
|
||||
dec ax
|
||||
push dx
|
||||
cwd
|
||||
sub ax, dx
|
||||
sar ax, 1
|
||||
pop dx
|
||||
sub dl, al
|
||||
add dl, 40h
|
||||
mov [bp+@@angle], dl
|
||||
push word ptr [bp+@@angle]
|
||||
push 7
|
||||
push ss
|
||||
lea ax, [bp+@@vector_y]
|
||||
push ax
|
||||
push ss
|
||||
lea ax, [bp+@@vector_x]
|
||||
push ax
|
||||
call _vector2
|
||||
add sp, 0Ch
|
||||
push 0 ; char
|
||||
mov ax, [bp+@@vector_y]
|
||||
mov [bp+var_A], ax
|
||||
fild [bp+var_A]
|
||||
sub sp, 8
|
||||
fstp [bp+var_16]
|
||||
fwait
|
||||
mov ax, [bp+var_4]
|
||||
mov [bp+var_A], ax
|
||||
fild [bp+var_A]
|
||||
sub sp, 8
|
||||
fstp [bp+var_1E]
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
fwait
|
||||
push word ptr [bx+5D51h] ; int
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
push word ptr [bx+5D47h] ; int
|
||||
push ds
|
||||
push offset _Missiles ; this
|
||||
call @CMissiles@add$qiiddc
|
||||
add sp, 1Ah
|
||||
|
||||
loc_257C3:
|
||||
cmp _boss_phase_frame, 60
|
||||
jl loc_258AA
|
||||
cmp _boss_phase_frame, 160
|
||||
jg loc_258AA
|
||||
mov ax, _boss_phase_frame
|
||||
mov bx, 4
|
||||
cwd
|
||||
idiv bx
|
||||
or dx, dx
|
||||
jnz loc_258AA
|
||||
xor si, si
|
||||
jmp loc_2589B
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_257EA:
|
||||
cmp _boss_phase_frame, 60
|
||||
jle short loc_2580F
|
||||
push (32 shl 16) or 48
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
push word ptr [bx+5D51h]
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
push word ptr [bx+5D47h]
|
||||
call _egc_copy_rect_1_to_0_16
|
||||
add sp, 8
|
||||
|
||||
loc_2580F:
|
||||
mov ax, _boss_phase_frame
|
||||
mov bx, 16
|
||||
cwd
|
||||
idiv bx
|
||||
mov ax, si
|
||||
shl ax, 2
|
||||
push dx
|
||||
cwd
|
||||
idiv bx
|
||||
pop ax
|
||||
cmp ax, dx
|
||||
jz short loc_2582D
|
||||
cmp _boss_phase_frame, 60
|
||||
jnz short loc_25861
|
||||
|
||||
loc_2582D:
|
||||
call IRand
|
||||
mov bx, 192
|
||||
cwd
|
||||
idiv bx
|
||||
add dx, elis_still_or_wave.BE_cur_left
|
||||
add dx, -32
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
mov [bx+5D47h], dx
|
||||
call IRand
|
||||
mov bx, 128
|
||||
cwd
|
||||
idiv bx
|
||||
add dx, elis_still_or_wave.BE_cur_top
|
||||
add dx, -32
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
mov [bx+5D51h], dx
|
||||
|
||||
loc_25861:
|
||||
cmp _boss_phase_frame, 160
|
||||
jge short loc_2589A
|
||||
call IRand
|
||||
mov bx, 2
|
||||
cwd
|
||||
idiv bx
|
||||
mov [bp+var_2], dx
|
||||
push 4 ; col
|
||||
mov ax, [bp+var_2]
|
||||
add ax, 4
|
||||
push ax ; image
|
||||
push GRC_SLOT_BOSS_1 ; slot
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
push word ptr [bx+5D51h] ; top
|
||||
mov bx, si
|
||||
add bx, bx
|
||||
push word ptr [bx+5D47h] ; left
|
||||
call _grc_put_8
|
||||
add sp, 0Ah
|
||||
|
||||
loc_2589A:
|
||||
inc si
|
||||
|
||||
loc_2589B:
|
||||
cmp si, 5
|
||||
jl loc_257EA
|
||||
push 7
|
||||
call _mdrv2_se_play
|
||||
pop cx
|
||||
|
||||
loc_258AA:
|
||||
cmp _boss_phase_frame, 170
|
||||
jle short loc_258BC
|
||||
mov _boss_phase_frame, 0
|
||||
xor ax, ax
|
||||
jmp short loc_258BF
|
||||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_258BC:
|
||||
mov ax, 2
|
||||
|
||||
loc_258BF:
|
||||
pop si
|
||||
leave
|
||||
retf
|
||||
sub_256AA endp
|
||||
|
||||
|
||||
; =============== S U B R O U T I N E =======================================
|
||||
|
||||
; Attributes: bp-based frame
|
||||
|
@ -18091,7 +17883,7 @@ loc_25DC8:
|
|||
; ---------------------------------------------------------------------------
|
||||
|
||||
loc_25DCE:
|
||||
call sub_256AA
|
||||
call @pattern_random_downwards_missile$qv
|
||||
pop bp
|
||||
retf
|
||||
; ---------------------------------------------------------------------------
|
||||
|
@ -23056,6 +22848,7 @@ _kikuri_invincibility_frame dw ?
|
|||
_kikuri_entrance_ring_radius_base dw ?
|
||||
_kikuri_initial_hp_rendered db ?
|
||||
db ?
|
||||
|
||||
public _boss_hp, _boss_phase_frame, _elis_pattern_state, _boss_phase
|
||||
_boss_hp dw ?
|
||||
_boss_phase_frame dw ?
|
||||
|
@ -23068,7 +22861,8 @@ public _pattern0_circle_radius, _pattern0_direction
|
|||
_pattern0_circle_radius dw ?
|
||||
_pattern0_direction dw ?
|
||||
|
||||
db 20 dup(?)
|
||||
CEntities _pattern1_rifts, 5
|
||||
|
||||
angle_3A6FB db ?
|
||||
word_3A6FC dw ?
|
||||
angle_3A6FE db ?
|
||||
|
|
Loading…
Reference in New Issue