Optimize checks on upper bit
parent
54d1bc7511
commit
fd54208307
64
src/main.asm
64
src/main.asm
|
@ -3473,8 +3473,7 @@ ProcADLoop:
|
||||||
bpl RdyDecode ; if buffer not negative, branch, otherwise
|
bpl RdyDecode ; if buffer not negative, branch, otherwise
|
||||||
iny
|
iny
|
||||||
lda (AreaData),y ; get second byte of area object
|
lda (AreaData),y ; get second byte of area object
|
||||||
asl ; check for page select bit (d7), branch if not set
|
bpl Chk1Row13 ; check for page select bit (d7), branch if not set
|
||||||
bcc Chk1Row13
|
|
||||||
lda AreaObjectPageSel ; check page select
|
lda AreaObjectPageSel ; check page select
|
||||||
bne Chk1Row13
|
bne Chk1Row13
|
||||||
inc AreaObjectPageSel ; if not already set, set it now
|
inc AreaObjectPageSel ; if not already set, set it now
|
||||||
|
@ -6648,8 +6647,7 @@ FireballXSpdData:
|
||||||
FireballObjCore:
|
FireballObjCore:
|
||||||
stx ObjectOffset ; store offset as current object
|
stx ObjectOffset ; store offset as current object
|
||||||
lda Fireball_State,x ; check for d7 = 1
|
lda Fireball_State,x ; check for d7 = 1
|
||||||
asl
|
bmi FireballExplosion ; if so, branch to get relative coordinates and draw explosion
|
||||||
bcs FireballExplosion ; if so, branch to get relative coordinates and draw explosion
|
|
||||||
ldy Fireball_State,x ; if fireball inactive, branch to leave
|
ldy Fireball_State,x ; if fireball inactive, branch to leave
|
||||||
beq NoFBall
|
beq NoFBall
|
||||||
dey ; if fireball state set to 1, skip this part and just run it
|
dey ; if fireball state set to 1, skip this part and just run it
|
||||||
|
@ -7380,8 +7378,7 @@ MiscLoop:
|
||||||
stx ObjectOffset ; store misc object offset here
|
stx ObjectOffset ; store misc object offset here
|
||||||
lda Misc_State,x ; check misc object state
|
lda Misc_State,x ; check misc object state
|
||||||
beq MiscLoopBack ; branch to check next slot
|
beq MiscLoopBack ; branch to check next slot
|
||||||
asl ; otherwise shift d7 into carry
|
bpl ProcJumpCoin ; otherwise, if d7 not set, jumping coin, thus skip to rest of code here
|
||||||
bcc ProcJumpCoin ; if d7 not set, jumping coin, thus skip to rest of code here
|
|
||||||
jsr ProcHammerObj ; otherwise go to process hammer,
|
jsr ProcHammerObj ; otherwise go to process hammer,
|
||||||
jmp MiscLoopBack ; then check next slot
|
jmp MiscLoopBack ; then check next slot
|
||||||
|
|
||||||
|
@ -7527,8 +7524,7 @@ PowerUpObjHandler:
|
||||||
stx ObjectOffset
|
stx ObjectOffset
|
||||||
lda Enemy_State+5 ; check power-up object's state
|
lda Enemy_State+5 ; check power-up object's state
|
||||||
beq ExitPUp ; if not set, branch to leave
|
beq ExitPUp ; if not set, branch to leave
|
||||||
asl ; shift to check if d7 was set in object state
|
bpl GrowThePowerUp ; if d7 not set in object state, branch ahead to skip this part
|
||||||
bcc GrowThePowerUp ; if not set, branch ahead to skip this part
|
|
||||||
lda TimerControl ; if master timer control set,
|
lda TimerControl ; if master timer control set,
|
||||||
bne RunPUSubs ; branch ahead to enemy object routines
|
bne RunPUSubs ; branch ahead to enemy object routines
|
||||||
lda PowerUpType ; check power-up type
|
lda PowerUpType ; check power-up type
|
||||||
|
@ -8152,10 +8148,7 @@ ExVMove:
|
||||||
|
|
||||||
EnemiesAndLoopsCore:
|
EnemiesAndLoopsCore:
|
||||||
lda Enemy_Flag,x ; check data here for MSB set
|
lda Enemy_Flag,x ; check data here for MSB set
|
||||||
pha ; save in stack
|
bmi ChkBowserF ; if MSB set in enemy flag, branch ahead of jumps
|
||||||
asl
|
|
||||||
bcs ChkBowserF ; if MSB set in enemy flag, branch ahead of jumps
|
|
||||||
pla ; get from stack
|
|
||||||
beq ChkAreaTsk ; if data zero, branch
|
beq ChkAreaTsk ; if data zero, branch
|
||||||
jmp RunEnemyObjectsCore ; otherwise, jump to run enemy subroutines
|
jmp RunEnemyObjectsCore ; otherwise, jump to run enemy subroutines
|
||||||
ChkAreaTsk:
|
ChkAreaTsk:
|
||||||
|
@ -8165,7 +8158,6 @@ ChkAreaTsk:
|
||||||
beq ExitELCore
|
beq ExitELCore
|
||||||
jmp ProcLoopCommand ; otherwise, jump to process loop command/load enemies
|
jmp ProcLoopCommand ; otherwise, jump to process loop command/load enemies
|
||||||
ChkBowserF:
|
ChkBowserF:
|
||||||
pla ; get data from stack
|
|
||||||
and #%00001111 ; mask out high nybble
|
and #%00001111 ; mask out high nybble
|
||||||
tay
|
tay
|
||||||
lda Enemy_Flag,y ; use as pointer and load same place with different offset
|
lda Enemy_Flag,y ; use as pointer and load same place with different offset
|
||||||
|
@ -8309,8 +8301,7 @@ CheckRightBounds:
|
||||||
ldy EnemyDataOffset
|
ldy EnemyDataOffset
|
||||||
iny
|
iny
|
||||||
lda (EnemyData),y ; if MSB of enemy object is clear, branch to check for row $0f
|
lda (EnemyData),y ; if MSB of enemy object is clear, branch to check for row $0f
|
||||||
asl
|
bpl CheckPageCtrlRow
|
||||||
bcc CheckPageCtrlRow
|
|
||||||
lda EnemyObjectPageSel ; if page select already set, do not set again
|
lda EnemyObjectPageSel ; if page select already set, do not set again
|
||||||
bne CheckPageCtrlRow
|
bne CheckPageCtrlRow
|
||||||
inc EnemyObjectPageSel ; otherwise, if MSB is set, set page select
|
inc EnemyObjectPageSel ; otherwise, if MSB is set, set page select
|
||||||
|
@ -9759,9 +9750,7 @@ MoveNormalEnemy:
|
||||||
and #%01000000 ; check enemy state for d6 set, if set skip
|
and #%01000000 ; check enemy state for d6 set, if set skip
|
||||||
bne FallE ; to move enemy vertically, then horizontally if necessary
|
bne FallE ; to move enemy vertically, then horizontally if necessary
|
||||||
lda Enemy_State,x
|
lda Enemy_State,x
|
||||||
asl ; check enemy state for d7 set
|
bmi SteadM ; if d7 of enemy state set, branch to move enemy horizontally
|
||||||
bcs SteadM ; if set, branch to move enemy horizontally
|
|
||||||
lda Enemy_State,x
|
|
||||||
and #%00100000 ; check enemy state for d5 set
|
and #%00100000 ; check enemy state for d5 set
|
||||||
bne MoveDefeatedEnemy ; if set, branch to move defeated enemy object
|
bne MoveDefeatedEnemy ; if set, branch to move defeated enemy object
|
||||||
lda Enemy_State,x
|
lda Enemy_State,x
|
||||||
|
@ -11624,8 +11613,7 @@ ExScrnBd:
|
||||||
FireballEnemyCollision:
|
FireballEnemyCollision:
|
||||||
lda Fireball_State,x ; check to see if fireball state is set at all
|
lda Fireball_State,x ; check to see if fireball state is set at all
|
||||||
beq ExitFBallEnemy ; branch to leave if not
|
beq ExitFBallEnemy ; branch to leave if not
|
||||||
asl
|
bmi ExitFBallEnemy ; branch to leave also if d7 in state is set
|
||||||
bcs ExitFBallEnemy ; branch to leave also if d7 in state is set
|
|
||||||
lda FrameCounter
|
lda FrameCounter
|
||||||
lsr ; get LSB of frame counter
|
lsr ; get LSB of frame counter
|
||||||
bcs ExitFBallEnemy ; branch to leave if set (do routine every other frame)
|
bcs ExitFBallEnemy ; branch to leave if set (do routine every other frame)
|
||||||
|
@ -11918,10 +11906,8 @@ HandlePECollisions:
|
||||||
lda AreaType ; branch if water type level
|
lda AreaType ; branch if water type level
|
||||||
beq InjurePlayer
|
beq InjurePlayer
|
||||||
lda Enemy_State,x ; branch if d7 of enemy state was set
|
lda Enemy_State,x ; branch if d7 of enemy state was set
|
||||||
asl
|
bmi ChkForPlayerInjury
|
||||||
bcs ChkForPlayerInjury
|
and #%00000111 ; mask out all but 3 LSB of enemy state
|
||||||
lda Enemy_State,x ; mask out all but 3 LSB of enemy state
|
|
||||||
and #%00000111
|
|
||||||
cmp #$02 ; branch if enemy is in normal or falling state
|
cmp #$02 ; branch if enemy is in normal or falling state
|
||||||
bcc ChkForPlayerInjury
|
bcc ChkForPlayerInjury
|
||||||
lda Enemy_ID,x ; branch to leave if goomba in defeated state
|
lda Enemy_ID,x ; branch to leave if goomba in defeated state
|
||||||
|
@ -12216,8 +12202,7 @@ ProcEnemyCollisions:
|
||||||
cmp #HammerBro ; if hammer bro found in alt state, branch to leave
|
cmp #HammerBro ; if hammer bro found in alt state, branch to leave
|
||||||
beq ExitProcessEColl
|
beq ExitProcessEColl
|
||||||
lda Enemy_State,y ; check first enemy state for d7 set
|
lda Enemy_State,y ; check first enemy state for d7 set
|
||||||
asl
|
bpl ShellCollisions ; branch if d7 is clear
|
||||||
bcc ShellCollisions ; branch if d7 is clear
|
|
||||||
lda #$06
|
lda #$06
|
||||||
jsr SetupFloateyNumber ; award 1000 points for killing enemy
|
jsr SetupFloateyNumber ; award 1000 points for killing enemy
|
||||||
jsr ShellOrBlockDefeat ; then kill enemy, then load
|
jsr ShellOrBlockDefeat ; then kill enemy, then load
|
||||||
|
@ -13144,14 +13129,12 @@ LandEnemyProperly:
|
||||||
and #%01000000 ; branch if d6 in enemy state is set
|
and #%01000000 ; branch if d6 in enemy state is set
|
||||||
bne LandEnemyInitState
|
bne LandEnemyInitState
|
||||||
lda Enemy_State,x
|
lda Enemy_State,x
|
||||||
asl ; branch if d7 in enemy state is not set
|
bpl ChkLandedEnemyState ; branch if d7 in enemy state is not set
|
||||||
bcc ChkLandedEnemyState
|
|
||||||
SChkA:
|
SChkA:
|
||||||
jmp DoEnemySideCheck ; if lower nybble < $0d, d7 set but d6 not set, jump here
|
jmp DoEnemySideCheck ; if lower nybble < $0d, d7 set but d6 not set, jump here
|
||||||
|
|
||||||
ChkLandedEnemyState:
|
ChkLandedEnemyState:
|
||||||
lda Enemy_State,x ; if enemy in normal state, branch back to jump here
|
beq SChkA ; if enemy in normal state, branch back to jump here
|
||||||
beq SChkA
|
|
||||||
cmp #$05 ; if in state used by spiny's egg
|
cmp #$05 ; if in state used by spiny's egg
|
||||||
beq ProcEnemyDirection ; then branch elsewhere
|
beq ProcEnemyDirection ; then branch elsewhere
|
||||||
cmp #$03 ; if already in state used by koopas and buzzy beetles
|
cmp #$03 ; if already in state used by koopas and buzzy beetles
|
||||||
|
@ -13221,9 +13204,7 @@ ChkForRedKoopa:
|
||||||
Chk2MSBSt:
|
Chk2MSBSt:
|
||||||
lda Enemy_State,x ; save enemy state into Y
|
lda Enemy_State,x ; save enemy state into Y
|
||||||
tay
|
tay
|
||||||
asl ; check for d7 set
|
bpl GetSteFromD ; branch if d7 not set
|
||||||
bcc GetSteFromD ; branch if not set
|
|
||||||
lda Enemy_State,x
|
|
||||||
ora #%01000000 ; set d6
|
ora #%01000000 ; set d6
|
||||||
jmp SetD6Ste ; jump ahead of this part
|
jmp SetD6Ste ; jump ahead of this part
|
||||||
GetSteFromD:
|
GetSteFromD:
|
||||||
|
@ -13263,8 +13244,7 @@ ChkForBump_HammerBroJ:
|
||||||
cpx #$05 ; check if we're on the special use slot
|
cpx #$05 ; check if we're on the special use slot
|
||||||
beq NoBump ; and if so, branch ahead and do not play sound
|
beq NoBump ; and if so, branch ahead and do not play sound
|
||||||
lda Enemy_State,x ; if enemy state d7 not set, branch
|
lda Enemy_State,x ; if enemy state d7 not set, branch
|
||||||
asl ; ahead and do not play sound
|
bpl NoBump ; ahead and do not play sound
|
||||||
bcc NoBump
|
|
||||||
lda #Sfx_Bump ; otherwise, play bump sound
|
lda #Sfx_Bump ; otherwise, play bump sound
|
||||||
sta Square1SoundQueue ; sound will never be played if branching from ChkForRedKoopa
|
sta Square1SoundQueue ; sound will never be played if branching from ChkForRedKoopa
|
||||||
NoBump:
|
NoBump:
|
||||||
|
@ -14061,14 +14041,12 @@ SChk5:
|
||||||
sta Sprite_Y_Position+16,y
|
sta Sprite_Y_Position+16,y
|
||||||
SChk6:
|
SChk6:
|
||||||
pla ; get bits from stack
|
pla ; get bits from stack
|
||||||
asl ; rotate d2 into carry
|
bpl SLChk ; check d2
|
||||||
bcc SLChk ; save to stack
|
|
||||||
lda #$f8
|
lda #$f8
|
||||||
sta Sprite_Y_Position+20,y ; if d2 was set, move sixth sprite offscreen
|
sta Sprite_Y_Position+20,y ; if d2 was set, move sixth sprite offscreen
|
||||||
SLChk:
|
SLChk:
|
||||||
lda Enemy_OffscreenBits ; check d7 of offscreen bits
|
lda Enemy_OffscreenBits ; check d7 of offscreen bits
|
||||||
asl ; and if d7 is not set, skip sub
|
bpl ExDLPl ; and if d7 is not set, skip sub
|
||||||
bcc ExDLPl
|
|
||||||
jmp MoveSixSpritesOffscreen ; otherwise branch to move all sprites offscreen
|
jmp MoveSixSpritesOffscreen ; otherwise branch to move all sprites offscreen
|
||||||
ExDLPl:
|
ExDLPl:
|
||||||
rts
|
rts
|
||||||
|
@ -14899,8 +14877,7 @@ DChunks:
|
||||||
lda Block_OffscreenBits ; get offscreen bits for block object
|
lda Block_OffscreenBits ; get offscreen bits for block object
|
||||||
jsr ChkLeftCo ; do sub to move left half of sprites offscreen if necessary
|
jsr ChkLeftCo ; do sub to move left half of sprites offscreen if necessary
|
||||||
lda Block_OffscreenBits ; get offscreen bits again
|
lda Block_OffscreenBits ; get offscreen bits again
|
||||||
asl ; shift d7 into carry
|
bpl ChnkOfs ; if d7 not set, branch to last part
|
||||||
bcc ChnkOfs ; if d7 not set, branch to last part
|
|
||||||
lda #$f8
|
lda #$f8
|
||||||
jsr DumpTwoSpr ; otherwise move top sprites offscreen
|
jsr DumpTwoSpr ; otherwise move top sprites offscreen
|
||||||
ChnkOfs:
|
ChnkOfs:
|
||||||
|
@ -15350,9 +15327,8 @@ ActionSwimming:
|
||||||
lda JumpSwimTimer ; check jump/swim timer
|
lda JumpSwimTimer ; check jump/swim timer
|
||||||
ora PlayerAnimCtrl ; and animation frame control
|
ora PlayerAnimCtrl ; and animation frame control
|
||||||
bne FourFrameExtent ; if any one of these set, branch ahead
|
bne FourFrameExtent ; if any one of these set, branch ahead
|
||||||
lda A_B_Buttons
|
lda A_B_Buttons ; check for A button pressed
|
||||||
asl ; check for A button pressed
|
bmi FourFrameExtent ; branch to same place if A button pressed
|
||||||
bcs FourFrameExtent ; branch to same place if A button pressed
|
|
||||||
|
|
||||||
GetCurrentAnimOffset:
|
GetCurrentAnimOffset:
|
||||||
lda PlayerAnimCtrl ; get animation frame control
|
lda PlayerAnimCtrl ; get animation frame control
|
||||||
|
|
Loading…
Reference in New Issue