Optimize CMP/CPX/CPY instructions
parent
23528e5ab0
commit
45504ea22b
20
src/main.asm
20
src/main.asm
|
@ -8102,8 +8102,7 @@ AlterYP:
|
|||
cmp $02 ; compare to maximum speed
|
||||
bmi ChkUpM ; if less than preset value, skip this part
|
||||
lda SprObject_Y_MoveForce,x
|
||||
cmp #$80 ; if less positively than preset maximum, skip this part
|
||||
bcc ChkUpM
|
||||
bpl ChkUpM ; if less positively than preset maximum ($80), skip this part (cmp optimization)
|
||||
lda $02
|
||||
sta SprObject_Y_Speed,x ; keep vertical speed within maximum value
|
||||
lda #$00
|
||||
|
@ -8126,8 +8125,7 @@ ChkUpM:
|
|||
cmp $07 ; compare vertical speed to two's compliment
|
||||
bpl ExVMove ; if less negatively than preset maximum, skip this part
|
||||
lda SprObject_Y_MoveForce,x
|
||||
cmp #$80 ; check if fractional part is above certain amount,
|
||||
bcs ExVMove ; and if so, branch to leave
|
||||
bmi ExVMove ; check if fractional part is above certain amount ($80), and if so, branch to leave (cmp optimization)
|
||||
lda $07
|
||||
sta SprObject_Y_Speed,x ; keep vertical speed within maximum value
|
||||
lda #$ff
|
||||
|
@ -8217,9 +8215,8 @@ FindLoop:
|
|||
lda Player_Y_Position ; check to see if the player is at the correct position
|
||||
cmp LoopCmdYPosition,y ; if not, branch to check for world 7
|
||||
bne WrongChk
|
||||
lda Player_State ; check to see if the player is
|
||||
cmp #$00 ; on solid ground (i.e. not jumping or falling)
|
||||
bne WrongChk ; if not, player fails to pass loop, and loopback
|
||||
lda Player_State ; check to see if the player is on solid ground (i.e. not jumping or falling)
|
||||
bne WrongChk ; if not, player fails to pass loop, and loopback (cmp optimization)
|
||||
lda WorldNumber ; are we in world 7? (check performed on correct
|
||||
cmp #World7 ; vertical position and on solid ground)
|
||||
bne InitMLp ; if not, initialize flags used there, otherwise
|
||||
|
@ -10716,8 +10713,7 @@ HammerChk:
|
|||
jsr SpawnHammerObj ; execute sub on every fourth frame to spawn misc object (hammer)
|
||||
SetHmrTmr:
|
||||
lda Enemy_Y_Position,x ; get current vertical position
|
||||
cmp #$80 ; if still above a certain point
|
||||
bcc ChkFireB ; then skip to world number check for flames
|
||||
bpl ChkFireB ; if still above a certain point ($80) then skip to world number check for flames (cmp optimization)
|
||||
lda PseudoRandomBitReg,x
|
||||
and #%00000011 ; get pseudorandom offset
|
||||
tay
|
||||
|
@ -12627,8 +12623,7 @@ ContSChk:
|
|||
bne ExCSM ; branch to leave if set
|
||||
jmp StopPlayerMove ; otherwise jump to impede player's movement
|
||||
ChkPBtm:
|
||||
ldy Player_State ; get player's state
|
||||
cpy #$00 ; check for player's state set to normal
|
||||
ldy Player_State ; check for player's state set to normal (cpy optimization)
|
||||
bne StopPlayerMove ; if not, branch to impede player's movement
|
||||
ldy PlayerFacingDir ; get player's facing direction
|
||||
dey
|
||||
|
@ -15080,8 +15075,7 @@ CntPl:
|
|||
ldy SwimmingFlag ; if swimming flag set, branch to
|
||||
beq FindPlayerAction ; different part, do not return
|
||||
lda Player_State
|
||||
cmp #$00 ; if player status normal,
|
||||
beq FindPlayerAction ; branch and do not return
|
||||
beq FindPlayerAction ; if player status normal, branch and do not return (cmp optimization)
|
||||
jsr FindPlayerAction ; otherwise jump and return
|
||||
lda FrameCounter
|
||||
and #%00000100 ; check frame counter for d2 set (8 frames every
|
||||
|
|
Loading…
Reference in New Issue