Skip to content

Commit

Permalink
[Maintenance] [th04/th05] Declare null callbacks in a single place in…
Browse files Browse the repository at this point in the history
… C land

Part of P0089, funded by [Anonymous] and Blue Bolt.
  • Loading branch information
nmlgc committed May 4, 2020
1 parent 8b58e19 commit e1f3af5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 55 deletions.
2 changes: 1 addition & 1 deletion th04/main/boss/reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ char boss_phase_timed_out = 0;

void pascal near boss_reset(void)
{
boss_update = nullsub_1;
boss_update = nullfunc_far;
boss_fg_render = nullfunc_near;
#if GAME == 5
boss_custombullets_render = nullfunc_near;
Expand Down
12 changes: 12 additions & 0 deletions th04/main/null.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public NULLFUNC_NEAR
nullfunc_near proc near
retn
nullfunc_near endp
even


public NULLFUNC_FAR
nullfunc_far proc far
retf
nullfunc_far endp
even
3 changes: 3 additions & 0 deletions th04/main/null.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Null functions for disabling callbacks
void pascal near nullfunc_near(void);
void pascal far nullfunc_far(void);
39 changes: 10 additions & 29 deletions th04_main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1719,27 +1719,8 @@ include th04/main/scroll_y_1.asm
MOTION_UPDATE_DEF 1
include th03/math/randring_fill.asm
RANDRING_NEXT_DEF 1
nop

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

public NULLFUNC_NEAR
nullfunc_near proc near
retn
nullfunc_near endp

; ---------------------------------------------------------------------------
nop

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


nullsub_2 proc far
retf
nullsub_2 endp

; ---------------------------------------------------------------------------
nop
even
include th04/main/null.asm
include th04/main/pointnum/inv_upd.asm
include th04/main/pointnum/render.asm
include th04/main/pointnum/num_put.asm
Expand Down Expand Up @@ -18036,7 +18017,7 @@ var_2 = word ptr -2
loc_16638:
cmp _boss_phase_frame, 0
jnz short loc_16651
setfarfp _stage_vm, nullsub_2
setfarfp _stage_vm, nullfunc_far
mov _midboss_frames_until, 0

loc_16651:
Expand Down Expand Up @@ -20771,7 +20752,7 @@ loc_17E18:
les bx, _std_ip
cmp word ptr es:[bx], 0
jnz short locret_17E3C
setfarfp _stage_vm, nullsub_2
setfarfp _stage_vm, nullfunc_far

locret_17E3C:
leave
Expand Down Expand Up @@ -21899,7 +21880,7 @@ loc_18706:
loc_1872F:
cmp _boss_phase_frame, 0
jnz short loc_1876B
setfarfp _stage_vm, nullsub_2
setfarfp _stage_vm, nullfunc_far
mov _midboss_frames_until, 0
mov fp_259E8, offset sub_180BB
mov byte_259EF, 0
Expand Down Expand Up @@ -24474,7 +24455,7 @@ sub_19EBC proc far
mov bp, sp
mov _midboss_invalidate?, offset nullfunc_near
mov _midboss_render, offset nullfunc_near
setfarfp _midboss_update, nullsub_2
setfarfp _midboss_update, nullfunc_far
mov _midboss_active, 0
mov _midboss_hp, 0
pop bp
Expand Down Expand Up @@ -26621,7 +26602,7 @@ var_2 = word ptr -2
loc_1B497:
cmp _boss_phase_frame, 0
jnz short loc_1B4BA
setfarfp _stage_vm, nullsub_2
setfarfp _stage_vm, nullfunc_far
mov _midboss_frames_until, 0
mov byte_25A08, 0
mov byte_25A1B, 0
Expand Down Expand Up @@ -31698,7 +31679,7 @@ items_update endp
boss_reset proc near
push bp
mov bp, sp
setfarfp _boss_update, nullsub_2
setfarfp _boss_update, nullfunc_far
mov _boss_fg_render, offset nullfunc_near
mov _boss_phase, 0
mov _boss_mode, 0
Expand Down Expand Up @@ -31941,7 +31922,7 @@ stage4_setup endp
stage5_setup proc far
push bp
mov bp, sp
setfarfp _midboss_update_func, nullsub_2
setfarfp _midboss_update_func, nullfunc_far
mov _midboss_render_func, offset nullfunc_near
mov _midboss_frames_until, 60000
call boss_reset
Expand Down Expand Up @@ -31980,7 +31961,7 @@ stage5_setup endp
stage6_setup proc far
push bp
mov bp, sp
setfarfp _midboss_update_func, nullsub_2
setfarfp _midboss_update_func, nullfunc_far
mov _midboss_render_func, offset nullfunc_near
mov _midboss_frames_until, 60000
call boss_reset
Expand Down
2 changes: 1 addition & 1 deletion th05/main/stage/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void pascal near stage5_setup(void)

void pascal near stage6_setup(void)
{
midboss_update_func = nullsub_1;
midboss_update_func = nullfunc_far;
midboss_render_func = nullfunc_near;
midboss.frames_until = 30000;

Expand Down
4 changes: 1 addition & 3 deletions th05/main012.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

extern "C" {
#include "th05/th05.hpp"
#include "th04/main/null.hpp"
#include "th04/main/rank.hpp"
#include "th04/main/item/items.hpp"

void pascal far nullsub_1(void);
void pascal near nullfunc_near(void);

void pascal near playfield_fillm_32_0_320_192(void);
void pascal near playfield_fillm_0_0_384_192__2(void);
void pascal near playfield_fillm_0_205_384_163(void);
Expand Down
25 changes: 4 additions & 21 deletions th05_main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1950,25 +1950,8 @@ include th04/main/scroll_y_1.asm
MOTION_UPDATE_DEF 1
include th03/math/randring_fill.asm
RANDRING_NEXT_DEF 1
nop

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

public NULLFUNC_NEAR
nullfunc_near proc near
retn
nullfunc_near endp
nop

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


public NULLSUB_1
nullsub_1 proc far
retf
nullsub_1 endp
nop

even
include th04/main/null.asm
include th04/main/bullet/pellet_r.asm
include th04/main/spark_render.asm
include th04/main/sparks.asm
Expand Down Expand Up @@ -13242,7 +13225,7 @@ loc_1603F:
les bx, _std_ip
cmp word ptr es:[bx], 0
jnz short locret_16063
setfarfp _stage_vm, nullsub_1
setfarfp _stage_vm, nullfunc_far

locret_16063:
leave
Expand Down Expand Up @@ -14945,7 +14928,7 @@ sub_172FF proc far
mov bp, sp
mov _midboss_invalidate?, offset nullfunc_near
mov _midboss_render, offset nullfunc_near
setfarfp _midboss_update, nullsub_1
setfarfp _midboss_update, nullfunc_far
mov _midboss_hp, 0
pop bp
retf
Expand Down

0 comments on commit e1f3af5

Please sign in to comment.