[Decompilation] [th01] Player shots: Reset function

Why the sloppyness of unblitting a whole 16×16 rectangle *if you have
a dedicated function to precisely unblit a .PTN sprite using its alpha
mask*???
Oh well, it's not the regular function called in the main loop, so who
cares…?

Part of P0098, funded by Yanga.
This commit is contained in:
nmlgc 2020-06-11 19:15:43 +02:00
parent f453625e30
commit d158d186e2
4 changed files with 31 additions and 70 deletions

View File

@ -1,7 +1,15 @@
#include "th01/snd/mdrv2.h"
#include "th01/formats/ptn.hpp"
#include "th01/hardware/egc.h"
#include "th01/main/playfld.hpp"
#include "th01/main/player/shots.hpp"
static const int SHOT_W = PTN_QUARTER_W;
static const int SHOT_H = PTN_QUARTER_H;
#define sloppy_unput(i) \
egc_copy_rect_1_to_0(left[i], top[i], SHOT_W, SHOT_H);
void CShots::add(int new_left, int new_top)
{
if(new_left < PLAYFIELD_LEFT || new_left > (PLAYFIELD_RIGHT - 1)) {
@ -22,3 +30,18 @@ void CShots::add(int new_left, int new_top)
return;
}
}
void CShots::unput_and_reset_all(void)
{
for(int i = 0; i < SHOT_COUNT; i++) {
if(moving[i]) {
sloppy_unput(i);
moving[i] = false;
} else if(decay_frame[i]) {
sloppy_unput(i);
decay_frame[i] = false;
}
}
}
#undef sloppy_unput

View File

@ -10,6 +10,7 @@ struct CShots {
unsigned char decay_frame[SHOT_COUNT];
void add(int new_left, int new_top);
void unput_and_reset_all(void);
};
extern CShots Shots;

View File

@ -8,6 +8,7 @@
extern "C" {
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "th01/main/player/shots.cpp"
}

View File

@ -3501,7 +3501,7 @@ loc_D7E4:
push offset unk_37635
call sub_30DEE
add sp, 4
call CShots_2FCAD c, offset _Shots, ds
call @CShots@unput_and_reset_all$qv c, offset _Shots, ds
mov word ptr [bp+s1+2], ds
mov word ptr [bp+s1], 1250h
mov byte_34ADF, 0
@ -4408,7 +4408,7 @@ loc_E224:
loc_E244:
inc si
call sub_CE5C
call CShots_2FCAD c, offset _Shots, ds
call @CShots@unput_and_reset_all$qv c, offset _Shots, ds
push ds
push offset unk_37635
call sub_30DEE
@ -7567,7 +7567,7 @@ arg_0 = word ptr 6
enter 6, 0
push si
push di
call CShots_2FCAD c, offset _Shots, ds
call @CShots@unput_and_reset_all$qv c, offset _Shots, ds
push ds
push offset unk_37635
call sub_30DEE
@ -18563,7 +18563,7 @@ loc_1AE85:
push ax
call _egc_copy_rect_1_to_0
add sp, 8
call CShots_2FCAD c, offset _Shots, ds
call @CShots@unput_and_reset_all$qv c, offset _Shots, ds
push ds
push offset unk_37635
call sub_30E54
@ -49271,7 +49271,7 @@ loc_2C835:
jnz loc_2CAA8
mov word_3A6CA, 0
mov word_3B433, 18Fh
call CShots_2FCAD c, offset _Shots, ds
call @CShots@unput_and_reset_all$qv c, offset _Shots, ds
push ds
push offset unk_37635
call sub_30DEE
@ -54631,71 +54631,7 @@ main_38__TEXT segment byte public 'CODE' use16
assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing
extern @CShots@add$qii:proc
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
CShots_2FCAD proc far
@@CShots = dword ptr 6
push bp
mov bp, sp
push si
xor si, si
jmp short loc_2FD20
; ---------------------------------------------------------------------------
loc_2FCB5:
les bx, [bp+@@CShots]
add bx, si
cmp es:[bx+CShots.SHOT_moving], 0
jz short loc_2FCEB
push (16 shl 16) or 16
mov ax, si
add ax, ax
mov bx, word ptr [bp+@@CShots]
add bx, ax
push es:[bx+CShots.SHOT_top]
push es:[bx+CShots.SHOT_left]
call _egc_copy_rect_1_to_0
add sp, 8
les bx, [bp+@@CShots]
add bx, si
mov es:[bx+CShots.SHOT_moving], 0
jmp short loc_2FD1F
; ---------------------------------------------------------------------------
loc_2FCEB:
les bx, [bp+@@CShots]
add bx, si
cmp es:[bx+CShots.SHOT_decay_frame], 0
jz short loc_2FD1F
push (16 shl 16) or 16
mov ax, si
add ax, ax
mov bx, word ptr [bp+@@CShots]
add bx, ax
push es:[bx+CShots.SHOT_top]
push es:[bx+CShots.SHOT_left]
call _egc_copy_rect_1_to_0
add sp, 8
les bx, [bp+@@CShots]
add bx, si
mov es:[bx+CShots.SHOT_decay_frame], 0
loc_2FD1F:
inc si
loc_2FD20:
cmp si, SHOT_COUNT
jl short loc_2FCB5
pop si
pop bp
retf
CShots_2FCAD endp
extern @CShots@unput_and_reset_all$qv:proc
; =============== S U B R O U T I N E =======================================