[Decompilation] [th05] Shinki: Background type A initialization and rotation

Oh hey, a uth05win naming convention I have no qualms about adopting,
for once!
(Note from the future: It's actually really smart! The animation you
see is dependent on the state from previous background types, so it
makes sense to reduce the names to the original sequence.)

Part of P0146, funded by -Tom- and Ember2528.
This commit is contained in:
nmlgc 2021-05-30 12:47:10 +02:00
parent aae96aec45
commit b66400b3d2
2 changed files with 82 additions and 153 deletions

View File

@ -6,10 +6,14 @@
#include "platform.h"
#include "pc98.h"
#include "master.hpp"
#include "th01/math/area.hpp"
#include "th01/math/subpixel.hpp"
#include "th04/math/vector.hpp"
#include "th04/math/motion.hpp"
#include "th04/math/randring.h"
#include "th04/main/drawp.hpp"
#include "th04/main/playfld.hpp"
#include "th05/main/boss/boss.hpp"
/// Structures
/// ----------
@ -45,6 +49,77 @@ extern boss_particle_t boss_particles[BOSS_PARTICLE_COUNT];
extern lineset_t linesets[LINESET_COUNT];
/// ----------
/// Stage 6 - Shinki
/// ----------------
static const int SHINKI_LINESET_COUNT = 2;
static const int PARTICLES_UNINITIALIZED = (-1 & 0xFF);
extern unsigned char shinki_bg_linesets_zoomed_out;
extern int shinki_bg_type_a_particles_alive;
void near shinki_bg_type_a_update_part1(void)
{
boss_particle_t near *particle;
int i;
unsigned int angle;
int line_i;
lineset_t near *set;
if(shinki_bg_type_a_particles_alive == PARTICLES_UNINITIALIZED) {
set = linesets;
i = 0;
angle = 0x40;
while(i < SHINKI_LINESET_COUNT) {
for(line_i = 0; line_i < LINESET_LINE_COUNT; line_i++) {
set->center[line_i].x.v = to_sp(PLAYFIELD_W / 2);
set->center[line_i].y.v = to_sp(PLAYFIELD_H / 2);
set->radius[line_i].set(1.0f);
set->angle[line_i] = angle;
}
i++;
set++;
angle -= 0x80;
}
particle = boss_particles;
i = 0;
while(i < BOSS_PARTICLE_COUNT) {
particle->pos.x.v = Subpixel::None();
particle->patnum = 0;
i++;
particle++;
}
shinki_bg_type_a_particles_alive = 0;
}
if(shinki_bg_type_a_particles_alive < BOSS_PARTICLE_COUNT) {
if(((boss.phase_frame % 4) == 0) == true) {
particle = &boss_particles[shinki_bg_type_a_particles_alive];
particle->pos.set((PLAYFIELD_W / 2), (PLAYFIELD_H / 2));
particle->origin.set((PLAYFIELD_W / 2), (PLAYFIELD_H / 2));
particle->angle = randring1_next16();
particle->age = 0;
vector2_at(
particle->velocity,
0.0f, 0.0f,
(randring1_next16_and(to_sp(4.0f) - 1) + to_sp(2.0f)),
particle->angle
);
shinki_bg_type_a_particles_alive++;
}
}
if(boss.phase == 3) {
if((shinki_bg_linesets_zoomed_out % (SHINKI_LINESET_COUNT * 2)) < 2) {
linesets[0].angle[0] += 0x02;
linesets[1].angle[0] += 0x02;
} else {
linesets[0].angle[0] -= 0x02;
linesets[1].angle[0] -= 0x02;
}
}
#undef PARTICLES_UNINITIALIZED
}
// Draws the given line out of [set] with the current GRCG tile and color.
void pascal near grcg_lineset_line_put(lineset_t near &set, int i)
{
@ -72,3 +147,4 @@ void pascal near lineset_forward_copy(lineset_t near &set)
set.radius[i].v = set.radius[i - 1].v;
}
}
/// ----------------

View File

@ -3622,155 +3622,7 @@ loc_D3BA:
retn
sub_D327 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_D3C6 proc near
@@set = word ptr -6
@@line_i = word ptr -4
@@angle = word ptr -2
enter 6, 0
push si
push di
cmp word_21D6E, (-1 and 255)
jnz loc_D456
mov [bp+@@set], offset _linesets
xor di, di
mov [bp+@@angle], 40h
jmp short loc_D433
; ---------------------------------------------------------------------------
loc_D3E4:
mov [bp+@@line_i], 0
jmp short loc_D422
; ---------------------------------------------------------------------------
loc_D3EB:
mov bx, [bp+@@line_i]
shl bx, 2
add bx, [bp+@@set]
mov [bx+lineset_t.LS_center.x], ((PLAYFIELD_W / 2) shl 4)
mov bx, [bp+@@line_i]
shl bx, 2
add bx, [bp+@@set]
mov [bx+lineset_t.LS_center.y], ((PLAYFIELD_H / 2) shl 4)
mov bx, [bp+@@line_i]
add bx, bx
add bx, [bp+@@set]
mov [bx+lineset_t.LS_radius], (1 shl 4)
mov bx, [bp+@@set]
add bx, [bp+@@line_i]
mov al, byte ptr [bp+@@angle]
mov [bx+lineset_t.LS_angle], al
inc [bp+@@line_i]
loc_D422:
cmp [bp+@@line_i], LINESET_LINE_COUNT
jl short loc_D3EB
inc di
add [bp+@@set], size lineset_t
sub [bp+@@angle], 80h
loc_D433:
cmp di, 2
jl short loc_D3E4
mov si, offset _boss_particles
xor di, di
jmp short loc_D44B
; ---------------------------------------------------------------------------
loc_D43F:
mov [si+boss_particle_t.BP_pos.x], SUBPIXEL_NONE
mov [si+boss_particle_t.BP_patnum], 0
inc di
add si, size boss_particle_t
loc_D44B:
cmp di, BOSS_PARTICLE_COUNT
jl short loc_D43F
mov word_21D6E, 0
loc_D456:
cmp word_21D6E, BOSS_PARTICLE_COUNT
jge short loc_D4BE
mov ax, _boss_phase_frame
mov bx, 4
cwd
idiv bx
or dx, dx
jnz short loc_D46F
mov ax, 1
jmp short loc_D471
; ---------------------------------------------------------------------------
loc_D46F:
xor ax, ax
loc_D471:
cmp ax, 1
jnz short loc_D4BE
mov ax, word_21D6E
shl ax, 4
add ax, offset _boss_particles
mov si, ax
mov [si+boss_particle_t.BP_pos.x], ((PLAYFIELD_W / 2) shl 4)
mov [si+boss_particle_t.BP_pos.y], ((PLAYFIELD_H / 2) shl 4)
mov [si+boss_particle_t.BP_origin.x], ((PLAYFIELD_W / 2) shl 4)
mov [si+boss_particle_t.BP_origin.y], ((PLAYFIELD_H / 2) shl 4)
call randring1_next16
mov [si+boss_particle_t.BP_angle], al
mov [si+boss_particle_t.BP_age], 0
lea ax, [si+boss_particle_t.BP_velocity]
push ax
pushd (0 shl 16) or 0
call randring1_next16_and pascal, 3Fh
add ax, (2 shl 4)
push ax
mov al, [si+boss_particle_t.BP_angle]
mov ah, 0
push ax
call vector2_at
inc word_21D6E
loc_D4BE:
cmp _boss_phase, 3
jnz short loc_D4F4
mov al, byte_21D6C
mov ah, 0
mov bx, 4
cwd
idiv bx
cmp dx, 2
jge short loc_D4E4
mov al, lineset0.LS_angle
add al, 2
mov lineset0.LS_angle, al
mov al, lineset1.LS_angle
add al, 2
jmp short loc_D4F1
; ---------------------------------------------------------------------------
loc_D4E4:
mov al, lineset0.LS_angle
add al, -2
mov lineset0.LS_angle, al
mov al, lineset1.LS_angle
add al, -2
loc_D4F1:
mov lineset1.LS_angle, al
loc_D4F4:
pop di
pop si
leave
retn
sub_D3C6 endp
_shinki_bg_type_a_update_part1 procdesc c near
GRCG_LINESET_LINE_PUT procdesc pascal near \
set:near ptr, i:word
LINESET_FORWARD_COPY procdesc pascal near \
@ -3788,7 +3640,7 @@ sub_D5E2 proc near
mov bp, sp
push si
push di
call sub_D3C6
call _shinki_bg_type_a_update_part1
mov si, offset _linesets
xor di, di
jmp short loc_D630
@ -3812,7 +3664,7 @@ loc_D5F1:
call vector2_at
cmp [si+lineset_t.LS_radius], (224 shl 4)
jl short loc_D62B
inc byte_21D6C
inc _shinki_bg_linesets_zoomed_out
mov [si+lineset_t.LS_radius], 0
loc_D62B:
@ -27386,9 +27238,10 @@ byte_21762 db 0
db 0
include th04/sprites/pointnum.asp
include th05/formats/bb_playchar[data].asm
byte_21D6C db 0
public _shinki_bg_linesets_zoomed_out, _shinki_bg_type_a_particles_alive
_shinki_bg_linesets_zoomed_out db 0
db 0
word_21D6E dw (-1 and 255)
_shinki_bg_type_a_particles_alive dw (-1 and 255)
byte_21D70 db 0
db 0
word_21D72 dw 0