Skip to content

Commit

Permalink
[Decompilation] [th01] Shootout lasers: Update/collision/render function
Browse files Browse the repository at this point in the history
A public interface of two functions… nice.

Part of P0122, funded by Yanga.
  • Loading branch information
nmlgc committed Oct 6, 2020
1 parent 243dbf8 commit 60c1031
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 106 deletions.
36 changes: 36 additions & 0 deletions th01/main/bullet/laser_s.cpp
Expand Up @@ -126,3 +126,39 @@ void CShootoutLaser::hittest_and_render(void)
grcg_off_func();
}
}

void CShootoutLaser::update_hittest_and_render(void)
{
if(!alive) {
return;
}
if(age >= moveout_at_age) {
ray_i_left.v = ray_start_left.v;
ray_i_y.v = ray_start_y.v;

put_flag = SL_RAY_UNPUT;
hittest_and_render();

// hittest_and_render() has conveniently advanced [ray_i_*] by
// [ray_moveout_speed]...
ray_start_left.v = ray_i_left.v;
ray_start_y.v = ray_i_y.v;
if(
(ray_start_left.v >= to_laser_pixel(PLAYFIELD_RIGHT)) ||
(ray_start_left.v < to_laser_pixel(PLAYFIELD_LEFT)) ||
(ray_start_y.v < to_laser_pixel(PLAYFIELD_TOP)) ||
(ray_start_y.v >= to_laser_pixel(PLAYFIELD_BOTTOM))
) {
alive = false;
return;
}
} else {
ray_length += ray_extend_speed;
}
age++;
ray_i_left.v = ray_start_left.v;
ray_i_y.v = ray_start_y.v;

put_flag = SL_RAY_PUT;
hittest_and_render();
}
3 changes: 3 additions & 0 deletions th01/main/bullet/laser_s.hpp
Expand Up @@ -85,6 +85,9 @@ class CShootoutLaser {
int moveout_at_age,
int w
);

// Directly sets [done] if the laser collides with the player.
void update_hittest_and_render(void);
};

extern CShootoutLaser shootout_lasers[SHOOTOUT_LASER_COUNT];
112 changes: 6 additions & 106 deletions th01_reiiden.asm
Expand Up @@ -3820,46 +3820,11 @@ loc_DD66:
call sub_2EE7D

loc_DD6B:
push ds
push offset shootout_laser_0
call sub_12347
add sp, 4
push ds
push offset shootout_laser_1
call sub_12347
add sp, 4
push ds
push offset shootout_laser_2
call sub_12347
add sp, 4
push ds
push offset shootout_laser_3
call sub_12347
add sp, 4
push ds
push offset shootout_laser_4
call sub_12347
add sp, 4
push ds
push offset shootout_laser_5
call sub_12347
add sp, 4
push ds
push offset shootout_laser_6
call sub_12347
add sp, 4
push ds
push offset shootout_laser_7
call sub_12347
add sp, 4
push ds
push offset shootout_laser_8
call sub_12347
add sp, 4
push ds
push offset shootout_laser_9
call sub_12347
add sp, 4
@@i = 0
rept SHOOTOUT_LASER_COUNT
call @CShootoutLaser@update_hittest_and_render$qv c, offset _shootout_lasers[@@i * size CShootoutLaser], ds
@@i = @@i + 1
endm
push [bp+@@stage]
call sub_C766
cmp _paused, 1
Expand Down Expand Up @@ -4572,79 +4537,14 @@ main_14_TEXT ends
; Segment type: Pure code
main_15_TEXT segment byte public 'CODE' use16
extern @CShootoutLaser@spawn$qiiiiiucii:proc
extern @CShootoutLaser@hittest_and_render$qv:proc
extern @CShootoutLaser@update_hittest_and_render$qv:proc
main_15_TEXT ends

main_15__TEXT segment byte public 'CODE' use16
assume cs:main_15
;org 0Dh
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_12347 proc far

arg_0 = dword ptr 6

push bp
mov bp, sp
les bx, [bp+arg_0]
cmp word ptr es:[bx+3Ah], 0
jz loc_12408
les bx, [bp+arg_0]
mov ax, es:[bx+3Ch]
cmp ax, es:[bx+3Eh]
jl short loc_123D2
mov eax, es:[bx+8]
mov es:[bx+10h], eax
mov eax, es:[bx+0Ch]
mov es:[bx+14h], eax
mov byte ptr es:[bx+44h], 0
call @CShootoutLaser@hittest_and_render$qv c, bx, word ptr [bp+arg_0+2]
les bx, [bp+arg_0]
mov eax, es:[bx+10h]
mov es:[bx+8], eax
mov eax, es:[bx+14h]
mov es:[bx+0Ch], eax
cmp dword ptr es:[bx+8], 28000h
jge short loc_123C7
cmp dword ptr es:[bx+8], 0
jl short loc_123C7
cmp dword ptr es:[bx+0Ch], 4000h
jl short loc_123C7
cmp dword ptr es:[bx+0Ch], 19000h
jl short loc_123DD

loc_123C7:
les bx, [bp+arg_0]
mov word ptr es:[bx+3Ah], 0
pop bp
retf
; ---------------------------------------------------------------------------

loc_123D2:
les bx, [bp+arg_0]
mov ax, es:[bx+36h]
add es:[bx+18h], ax

loc_123DD:
les bx, [bp+arg_0]
inc word ptr es:[bx+3Ch]
mov eax, es:[bx+8]
mov es:[bx+10h], eax
mov eax, es:[bx+0Ch]
mov es:[bx+14h], eax
mov byte ptr es:[bx+44h], 1
call @CShootoutLaser@hittest_and_render$qv c, bx, word ptr [bp+arg_0+2]

loc_12408:
pop bp
retf
sub_12347 endp


; =============== S U B R O U T I N E =======================================

; Attributes: bp-based frame
Expand Down

0 comments on commit 60c1031

Please sign in to comment.