[Decompilation] [th04] Bullets: Pointless per-difficulty spawn wrappers

Not even "debugging reasons" could explain the presence of these
functions adequately…

Part of P0150, funded by Blue Bolt.
This commit is contained in:
nmlgc 2021-06-22 21:31:26 +02:00
parent 05e4c4a80c
commit 4d7c8bb21f
3 changed files with 84 additions and 151 deletions

View File

@ -175,3 +175,64 @@ void pascal near bullet_template_tune_lunatic(void)
tune_for_playperf();
tune_for_lunatic();
}
void pascal near bullets_add_regular_easy(void)
{
unsigned char speed;
unsigned char count;
if(bullet_zap.active) {
return;
}
count = bullet_template.count;
speed = bullet_template.speed.v;
bullets_add_regular_raw();
bullet_template.count = count;
bullet_template.speed.v = speed;
}
inline void keep_speed_from_being_mutated_when_calling(nearfunc_t_near func) {
unsigned char speed = bullet_template.speed.v;
func();
bullet_template.speed.v = speed;
}
void pascal near bullets_add_regular_normal(void)
{
if(bullet_zap.active) {
return;
}
keep_speed_from_being_mutated_when_calling(bullets_add_regular_raw);
}
void pascal near bullets_add_regular_hard_lunatic(void)
{
if(bullet_zap.active) {
return;
}
keep_speed_from_being_mutated_when_calling(bullets_add_regular_raw);
}
void pascal near bullets_add_special_easy(void)
{
if(bullet_zap.active) {
return;
}
keep_speed_from_being_mutated_when_calling(bullets_add_special_raw);
}
void pascal near bullets_add_special_normal(void)
{
if(bullet_zap.active) {
return;
}
keep_speed_from_being_mutated_when_calling(bullets_add_special_raw);
}
void pascal near bullets_add_special_hard_lunatic(void)
{
if(bullet_zap.active) {
return;
}
keep_speed_from_being_mutated_when_calling(bullets_add_special_raw);
}

View File

@ -221,6 +221,15 @@ extern nearfunc_t_near bullet_template_tune;
void near bullets_add_regular(void);
void near bullets_add_special(void);
#else
// TH04 additionally uses pointless per-difficulty wrappers around these
// spawn functions that don't actually do anything difficulty-specific.
void pascal near bullets_add_regular_easy(void);
void pascal near bullets_add_regular_normal(void);
void pascal near bullets_add_regular_hard_lunatic(void);
void pascal near bullets_add_special_easy(void);
void pascal near bullets_add_special_normal(void);
void pascal near bullets_add_special_hard_lunatic(void);
// Set to the version of the wrapper functions above that match the
// current difficulty.
extern nearfunc_t_near bullets_add_regular;

View File

@ -615,8 +615,8 @@ loc_ADFC:
mov score_2CFFE, 100
mov _playperf_min, 4
mov _playperf_max, 16
mov _bullets_add_regular, offset sub_1CEEE
mov _bullets_add_special, offset sub_1CF4E
mov _bullets_add_regular, offset bullets_add_regular_easy
mov _bullets_add_special, offset bullets_add_special_easy
mov _bullet_template_tune, offset bullet_template_tune_easy
jmp @@ret
; ---------------------------------------------------------------------------
@ -633,8 +633,8 @@ loc_ADFC:
mov score_2CFFE, 400
mov _playperf_min, 20
mov _playperf_max, 32
mov _bullets_add_regular, offset sub_1CF32
mov _bullets_add_special, offset sub_1CF86
mov _bullets_add_regular, offset bullets_add_regular_hard_lunatic
mov _bullets_add_special, offset bullets_add_special_hard_lunatic
mov _bullet_template_tune, offset bullet_template_tune_hard
jmp short @@ret
; ---------------------------------------------------------------------------
@ -644,8 +644,8 @@ loc_ADFC:
mov _playperf, 22
mov _playperf_min, 22
mov _playperf_max, 34
mov _bullets_add_regular, offset sub_1CF32
mov _bullets_add_special, offset sub_1CF86
mov _bullets_add_regular, offset bullets_add_regular_hard_lunatic
mov _bullets_add_special, offset bullets_add_special_hard_lunatic
mov _bullet_template_tune, offset bullet_template_tune_lunatic
jmp short @@ret
; ---------------------------------------------------------------------------
@ -656,8 +656,8 @@ loc_ADFC:
mov _playperf_max, 20
@@tune_normal:
mov _bullets_add_regular, offset sub_1CF16
mov _bullets_add_special, offset sub_1CF6A
mov _bullets_add_regular, offset bullets_add_regular_normal
mov _bullets_add_special, offset bullets_add_special_normal
mov _bullet_template_tune, offset bullet_template_tune_normal
@@ret:
@ -28217,149 +28217,12 @@ main_033_TEXT segment byte public 'CODE' use16
BULLET_TEMPLATE_TUNE_NORMAL procdesc near
BULLET_TEMPLATE_TUNE_HARD procdesc near
BULLET_TEMPLATE_TUNE_LUNATIC procdesc near
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1CEEE proc near
var_2 = byte ptr -2
var_1 = byte ptr -1
enter 2, 0
cmp _bullet_zap_active, 0
jnz short locret_1CF14
mov al, _bullet_template.count
mov [bp+var_2], al
mov al, _bullet_template.speed
mov [bp+var_1], al
call bullets_add_regular_raw
mov al, [bp+var_2]
mov _bullet_template.count, al
mov al, [bp+var_1]
mov _bullet_template.speed, al
locret_1CF14:
leave
retn
sub_1CEEE endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1CF16 proc near
var_1 = byte ptr -1
enter 2, 0
cmp _bullet_zap_active, 0
jnz short locret_1CF30
mov al, _bullet_template.speed
mov [bp+var_1], al
call bullets_add_regular_raw
mov al, [bp+var_1]
mov _bullet_template.speed, al
locret_1CF30:
leave
retn
sub_1CF16 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1CF32 proc near
var_1 = byte ptr -1
enter 2, 0
cmp _bullet_zap_active, 0
jnz short locret_1CF4C
mov al, _bullet_template.speed
mov [bp+var_1], al
call bullets_add_regular_raw
mov al, [bp+var_1]
mov _bullet_template.speed, al
locret_1CF4C:
leave
retn
sub_1CF32 endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1CF4E proc near
var_1 = byte ptr -1
enter 2, 0
cmp _bullet_zap_active, 0
jnz short locret_1CF68
mov al, _bullet_template.speed
mov [bp+var_1], al
call bullets_add_special_raw
mov al, [bp+var_1]
mov _bullet_template.speed, al
locret_1CF68:
leave
retn
sub_1CF4E endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1CF6A proc near
var_1 = byte ptr -1
enter 2, 0
cmp _bullet_zap_active, 0
jnz short locret_1CF84
mov al, _bullet_template.speed
mov [bp+var_1], al
call bullets_add_special_raw
mov al, [bp+var_1]
mov _bullet_template.speed, al
locret_1CF84:
leave
retn
sub_1CF6A endp
; =============== S U B R O U T I N E =======================================
; Attributes: bp-based frame
sub_1CF86 proc near
var_1 = byte ptr -1
enter 2, 0
cmp _bullet_zap_active, 0
jnz short locret_1CFA0
mov al, _bullet_template.speed
mov [bp+var_1], al
call bullets_add_special_raw
mov al, [bp+var_1]
mov _bullet_template.speed, al
locret_1CFA0:
leave
retn
sub_1CF86 endp
BULLETS_ADD_REGULAR_EASY procdesc pascal near
BULLETS_ADD_REGULAR_NORMAL procdesc pascal near
BULLETS_ADD_REGULAR_HARD_LUNATIC procdesc pascal near
BULLETS_ADD_SPECIAL_EASY procdesc pascal near
BULLETS_ADD_SPECIAL_NORMAL procdesc pascal near
BULLETS_ADD_SPECIAL_HARD_LUNATIC procdesc pascal near
; =============== S U B R O U T I N E =======================================