Optimize subroutine tail calls
parent
e2cf3e8ee0
commit
59f2a9b312
88
src/main.asm
88
src/main.asm
|
@ -1281,7 +1281,7 @@ ExitMsgs:
|
|||
|
||||
PlayerEndWorld:
|
||||
lda WorldEndTimer ; check to see if world end timer expired
|
||||
bne EndExitOne ; branch to leave if not
|
||||
bne EndExit ; branch to leave if not
|
||||
ldy WorldNumber ; check world number
|
||||
cpy #World8 ; if on world 8, player is done with game,
|
||||
bcs EndChkBButton ; thus branch to read controller
|
||||
|
@ -1293,20 +1293,18 @@ PlayerEndWorld:
|
|||
inc FetchNewGameTimerFlag ; set flag to load game timer from header
|
||||
lda #GameModeValue
|
||||
sta OperMode ; set mode of operation to game mode
|
||||
EndExitOne:
|
||||
EndExit:
|
||||
rts ; and leave
|
||||
EndChkBButton:
|
||||
lda SavedJoypad1Bits
|
||||
ora SavedJoypad2Bits ; check to see if B button was pressed on
|
||||
and #B_Button ; either controller
|
||||
beq EndExitTwo ; branch to leave if not
|
||||
beq EndExit ; branch to leave if not
|
||||
lda #$01 ; otherwise set world selection flag
|
||||
sta WorldSelectEnableFlag
|
||||
lda #$ff ; remove onscreen player's lives
|
||||
sta NumberofLives
|
||||
jsr TerminateGame ; do sub to continue other player or end game
|
||||
EndExitTwo:
|
||||
rts ; leave
|
||||
jmp TerminateGame ; continue other player or end game
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1335,7 +1333,7 @@ ScoreUpdateData:
|
|||
|
||||
FloateyNumbersRoutine:
|
||||
lda FloateyNum_Control,x ; load control for floatey number
|
||||
beq EndExitOne ; if zero, branch to leave
|
||||
beq EndExit ; if zero, branch to leave
|
||||
cmp #$0b ; if less than $0b, branch
|
||||
bcc ChkNumTimer
|
||||
lda #$0b ; otherwise set to $0b, thus keeping
|
||||
|
@ -2126,8 +2124,7 @@ WriteBlankMT:
|
|||
rts
|
||||
|
||||
ReplaceBlockMetatile:
|
||||
jsr WriteBlockMetatile ; write metatile to vram buffer to replace block object
|
||||
rts ; leave
|
||||
jmp WriteBlockMetatile ; write metatile to vram buffer to replace block object
|
||||
|
||||
DestroyBlockMetatile:
|
||||
lda #$00 ; force blank metatile if branched/jumped to this point
|
||||
|
@ -3186,7 +3183,7 @@ DoAPTasks:
|
|||
jsr AreaParserTasks
|
||||
dec AreaParserTaskNum ; if all tasks not complete do not
|
||||
bne SkipATRender ; render attribute table yet
|
||||
jsr RenderAttributeTables
|
||||
jmp RenderAttributeTables
|
||||
SkipATRender:
|
||||
rts
|
||||
|
||||
|
@ -5614,7 +5611,7 @@ UpdScrollVar:
|
|||
lda #$00 ; reset vram buffer offset used in conjunction with
|
||||
sta VRAM_Buffer2_Offset ; level graphics buffer at $0341-$035f
|
||||
RunParser:
|
||||
jsr AreaParserTaskHandler ; update the name table with more level graphics
|
||||
jmp AreaParserTaskHandler ; update the name table with more level graphics
|
||||
ExitEng:
|
||||
rts ; and after all that, we're finally done!
|
||||
|
||||
|
@ -5996,8 +5993,7 @@ EnterSidePipe:
|
|||
tay ; and nullify controller bit override here
|
||||
RightPipe:
|
||||
tya ; use contents of Y to
|
||||
jsr AutoControlPlayer ; execute player control routine with ctrl bits nulled
|
||||
rts
|
||||
jmp AutoControlPlayer ; execute player control routine with ctrl bits nulled
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -6009,9 +6005,9 @@ PlayerChangeSize:
|
|||
EndChgSize:
|
||||
cmp #$c4 ; check again for another specific moment
|
||||
bne ExitChgSize ; and branch to leave if before or after that point
|
||||
jsr DonePlayerTask ; otherwise do sub to init timer control and set routine
|
||||
jmp DonePlayerTask ; otherwise do sub to init timer control and set routine
|
||||
ExitChgSize:
|
||||
rts ; and then leave
|
||||
rts ; leave
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -6961,7 +6957,7 @@ GiveFPScr:
|
|||
FPGfx:
|
||||
jsr GetEnemyOffscreenBits ; get offscreen information
|
||||
jsr RelativeEnemyPosition ; get relative coordinates
|
||||
jsr FlagpoleGfxHandler ; draw flagpole flag and floatey number
|
||||
jmp FlagpoleGfxHandler ; draw flagpole flag and floatey number
|
||||
ExitFlagP:
|
||||
rts
|
||||
|
||||
|
@ -7223,8 +7219,7 @@ RunBBSubs:
|
|||
jsr PlayerEnemyCollision ; handle player to enemy collisions
|
||||
jmp EnemyGfxHandler ; draw the bullet bill and leave
|
||||
KillBB:
|
||||
jsr EraseEnemyObject ; kill bullet bill and leave
|
||||
rts
|
||||
jmp EraseEnemyObject ; kill bullet bill
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -7321,8 +7316,7 @@ RunHSubs:
|
|||
jsr GetMiscOffscreenBits ; get offscreen information
|
||||
jsr RelativeMiscPosition ; get relative coordinates
|
||||
jsr GetMiscBoundBox ; get bounding box coordinates
|
||||
jsr DrawHammer ; draw the hammer
|
||||
rts ; and we are done here
|
||||
jmp DrawHammer ; draw the hammer
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
; $02 - used to store vertical high nybble offset from block buffer routine
|
||||
|
@ -7578,9 +7572,9 @@ RunPUSubs:
|
|||
jsr GetEnemyBoundBox ; get bounding box coordinates
|
||||
jsr DrawPowerUp ; draw the power-up object
|
||||
jsr PlayerEnemyCollision ; check for collision with player
|
||||
jsr OffscreenBoundsCheck ; check to see if it went offscreen
|
||||
jmp OffscreenBoundsCheck ; check to see if it went offscreen
|
||||
ExitPUp:
|
||||
rts ; and we're done
|
||||
rts
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
; These apply to all routines in this section unless otherwise noted:
|
||||
|
@ -7738,7 +7732,7 @@ ExtraLifeMushBlock:
|
|||
VineBlock:
|
||||
ldx #$05 ; load last slot for enemy object buffer
|
||||
ldy SprDataOffset_Ctrl ; get control bit
|
||||
jsr Setup_Vine ; set up vine object
|
||||
jmp Setup_Vine ; set up vine object
|
||||
|
||||
ExitBlockChk:
|
||||
rts ; leave
|
||||
|
@ -7797,7 +7791,7 @@ CheckTopOfBlock:
|
|||
sta ($06),y ; otherwise put blank metatile where coin was
|
||||
jsr RemoveCoin_Axe ; write blank metatile to vram buffer
|
||||
ldx SprDataOffset_Ctrl ; get control bit
|
||||
jsr SetupJumpCoin ; create jumping coin object and update coin variables
|
||||
jmp SetupJumpCoin ; create jumping coin object and update coin variables
|
||||
TopEx:
|
||||
rts ; leave!
|
||||
|
||||
|
@ -8414,9 +8408,9 @@ StrFre:
|
|||
InitEnemyObject:
|
||||
lda #$00 ; initialize enemy state
|
||||
sta Enemy_State,x
|
||||
jsr CheckpointEnemyID ; jump ahead to run jump engine and subroutines
|
||||
jmp CheckpointEnemyID ; jump ahead to run jump engine and subroutines
|
||||
ExEPar:
|
||||
rts ; then leave
|
||||
rts ; leave
|
||||
|
||||
DoGroup:
|
||||
jmp HandleGroupEnemies ; handle enemy group objects
|
||||
|
@ -9838,7 +9832,7 @@ ChkKillGoomba:
|
|||
lda Enemy_ID,x
|
||||
cmp #Goomba ; check for goomba object
|
||||
bne NKGmba ; branch if not found
|
||||
jsr EraseEnemyObject ; otherwise, kill this goomba object
|
||||
jmp EraseEnemyObject ; otherwise, kill this goomba object
|
||||
NKGmba:
|
||||
rts ; leave!
|
||||
|
||||
|
@ -10975,8 +10969,7 @@ SetupExpl:
|
|||
sta Fireball_Rel_XPos
|
||||
ldy Enemy_SprDataOffset,x ; get OAM data offset
|
||||
lda ExplosionGfxCounter,x ; get explosion graphics counter
|
||||
jsr DrawExplosion_Fireworks ; do a sub to draw the explosion then leave
|
||||
rts
|
||||
jmp DrawExplosion_Fireworks ; do a sub to draw the explosion
|
||||
|
||||
FireworksSoundScore:
|
||||
lda #$00 ; disable enemy buffer flag
|
||||
|
@ -11485,7 +11478,7 @@ YMDown:
|
|||
ChkYPCollision:
|
||||
lda PlatformCollisionFlag,x ; if collision flag not set here, branch
|
||||
bmi ExYPl ; to leave
|
||||
jsr PositionPlayerOnVPlat ; otherwise position player appropriately
|
||||
jmp PositionPlayerOnVPlat ; otherwise position player appropriately
|
||||
ExYPl:
|
||||
rts ; leave
|
||||
|
||||
|
@ -11514,9 +11507,9 @@ PPHSubt:
|
|||
SetPVar:
|
||||
sta Player_PageLoc ; save result to player's page location
|
||||
sty Platform_X_Scroll ; put saved value from second sub here to be used later
|
||||
jsr PositionPlayerOnVPlat ; position player vertically and appropriately
|
||||
jmp PositionPlayerOnVPlat ; position player vertically and appropriately
|
||||
ExXMP:
|
||||
rts ; and we are done here
|
||||
rts ; we are done here
|
||||
|
||||
;--------------------------------
|
||||
|
||||
|
@ -11524,7 +11517,7 @@ DropPlatform:
|
|||
lda PlatformCollisionFlag,x ; if no collision between platform and player
|
||||
bmi ExDPl ; occurred, just leave without moving anything
|
||||
jsr MoveDropPlatform ; otherwise do a sub to move platform down very quickly
|
||||
jsr PositionPlayerOnVPlat ; do a sub to position player appropriately
|
||||
jmp PositionPlayerOnVPlat ; do a sub to position player appropriately
|
||||
ExDPl:
|
||||
rts ; leave
|
||||
|
||||
|
@ -11536,9 +11529,9 @@ RightPlatform:
|
|||
bmi ExRPl ; and platform, branch ahead, leave speed unaltered
|
||||
lda #$10
|
||||
sta Enemy_X_Speed,x ; otherwise set new speed (gets moving if motionless)
|
||||
jsr PositionPlayerOnHPlat ; use saved value from earlier sub to position player
|
||||
jmp PositionPlayerOnHPlat ; use saved value from earlier sub to position player
|
||||
ExRPl:
|
||||
rts ; then leave
|
||||
rts ; leave
|
||||
|
||||
;--------------------------------
|
||||
|
||||
|
@ -11565,9 +11558,9 @@ MoveLiftPlatforms:
|
|||
ChkSmallPlatCollision:
|
||||
lda PlatformCollisionFlag,x ; get bounding box counter saved in collision flag
|
||||
beq ExLiftP ; if none found, leave player position alone
|
||||
jsr PositionPlayerOnS_Plat ; use to position player correctly
|
||||
jmp PositionPlayerOnS_Plat ; use to position player correctly
|
||||
ExLiftP:
|
||||
rts ; then leave
|
||||
rts ; leave
|
||||
|
||||
;-------------------------------------------------------------------------------------
|
||||
; $00 - page location of extended left boundary
|
||||
|
@ -11621,7 +11614,7 @@ ExtendLB:
|
|||
cpy #JumpspringObject ; if jumpspring, do not erase
|
||||
beq ExScrnBd ; erase all others too far to the right
|
||||
TooFar:
|
||||
jsr EraseEnemyObject ; erase object if necessary
|
||||
jmp EraseEnemyObject ; erase object if necessary
|
||||
ExScrnBd:
|
||||
rts ; leave
|
||||
|
||||
|
@ -11855,7 +11848,7 @@ UpToSuper:
|
|||
|
||||
UpToFiery:
|
||||
ldy #$00 ; set value to be used as new player state
|
||||
jsr SetPRout ; set values to stop certain things in motion
|
||||
jmp SetPRout ; set values to stop certain things in motion
|
||||
NoPUp:
|
||||
rts
|
||||
|
||||
|
@ -11950,7 +11943,7 @@ HandlePECollisions:
|
|||
bcs KSPts ; data obtained from the stomp counter + 3
|
||||
lda KickedShellPtsData,y ; otherwise, set points based on proximity to timer expiration
|
||||
KSPts:
|
||||
jsr SetupFloateyNumber ; set values for floatey number now
|
||||
jmp SetupFloateyNumber ; set values for floatey number now
|
||||
ExPEC:
|
||||
rts ; leave!!!
|
||||
|
||||
|
@ -12730,7 +12723,7 @@ ChkGERtn:
|
|||
; $06-$07 - block buffer address
|
||||
|
||||
StopPlayerMove:
|
||||
jsr ImpedePlayerMove ; stop player's movement
|
||||
jmp ImpedePlayerMove ; stop player's movement
|
||||
ExCSM:
|
||||
rts ; leave
|
||||
|
||||
|
@ -13174,9 +13167,9 @@ SetForStn:
|
|||
sta EnemyIntervalTimer,x ; set timer here
|
||||
lda #$03 ; set state here, apparently used to render
|
||||
sta Enemy_State,x ; upside-down koopas and buzzy beetles
|
||||
jsr EnemyLanding ; then land it properly
|
||||
jmp EnemyLanding ; then land it properly
|
||||
ExSteChk:
|
||||
rts ; then leave
|
||||
rts ; leave
|
||||
|
||||
ProcEnemyDirection:
|
||||
lda Enemy_ID,x ; check enemy identifier for goomba
|
||||
|
@ -13902,7 +13895,7 @@ RenderH:
|
|||
lda #$00
|
||||
sta Misc_State,x ; otherwise nullify misc object state
|
||||
lda #$f8
|
||||
jsr DumpTwoSpr ; do sub to move hammer sprites offscreen
|
||||
jmp DumpTwoSpr ; do sub to move hammer sprites offscreen
|
||||
NoHOffscr:
|
||||
rts ; leave
|
||||
|
||||
|
@ -14076,7 +14069,7 @@ SLChk:
|
|||
lda Enemy_OffscreenBits ; check d7 of offscreen bits
|
||||
asl ; and if d7 is not set, skip sub
|
||||
bcc ExDLPl
|
||||
jsr MoveSixSpritesOffscreen ; otherwise branch to move all sprites offscreen
|
||||
jmp MoveSixSpritesOffscreen ; otherwise branch to move all sprites offscreen
|
||||
ExDLPl:
|
||||
rts
|
||||
|
||||
|
@ -14744,7 +14737,7 @@ AllRowC:
|
|||
lda Enemy_Y_HighPos,x ; check high byte of vertical position
|
||||
cmp #$02 ; if not yet past the bottom of the screen, branch
|
||||
bne ExEGHandler
|
||||
jsr EraseEnemyObject ; what it says
|
||||
jmp EraseEnemyObject ; what it says
|
||||
|
||||
ExEGHandler:
|
||||
rts
|
||||
|
@ -16287,8 +16280,7 @@ ContinueGrowItems:
|
|||
lda #$9d ; load contents of other reg directly
|
||||
sta SND_SQUARE2_REG
|
||||
lda PUp_VGrow_FreqData,y ; use secondary counter / 2 as offset for frequency regs
|
||||
jsr SetFreq_Squ2
|
||||
rts
|
||||
jmp SetFreq_Squ2
|
||||
|
||||
StopGrowItems:
|
||||
jmp EmptySfx2Buffer ; branch to stop playing sounds
|
||||
|
|
Loading…
Reference in New Issue