Optimize ADC and SBC instructions
parent
fd54208307
commit
23528e5ab0
136
src/main.asm
136
src/main.asm
|
@ -1802,8 +1802,7 @@ EndGameText:
|
||||||
dex ; are we printing the world/lives display?
|
dex ; are we printing the world/lives display?
|
||||||
bne CheckPlayerName ; if not, branch to check player's name
|
bne CheckPlayerName ; if not, branch to check player's name
|
||||||
lda NumberofLives ; otherwise, check number of lives
|
lda NumberofLives ; otherwise, check number of lives
|
||||||
clc ; and increment by one for display
|
adc #$01 ; and increment by one for display (clc optimization)
|
||||||
adc #$01
|
|
||||||
cmp #10 ; more than 9 lives?
|
cmp #10 ; more than 9 lives?
|
||||||
bcc PutLives
|
bcc PutLives
|
||||||
sbc #10 ; if so, subtract 10 and put a crown tile
|
sbc #10 ; if so, subtract 10 and put a crown tile
|
||||||
|
@ -2175,8 +2174,7 @@ SaveHAdder:
|
||||||
lda #$00
|
lda #$00
|
||||||
sta $05 ; initialize temp high byte
|
sta $05 ; initialize temp high byte
|
||||||
lda $02 ; get vertical high nybble offset used in block buffer routine
|
lda $02 ; get vertical high nybble offset used in block buffer routine
|
||||||
clc
|
adc #$20 ; add 32 pixels for the status bar (clc optimization)
|
||||||
adc #$20 ; add 32 pixels for the status bar
|
|
||||||
asl
|
asl
|
||||||
rol $05 ; shift and rotate d7 onto d0 and d6 into carry
|
rol $05 ; shift and rotate d7 onto d0 and d6 into carry
|
||||||
asl
|
asl
|
||||||
|
@ -4602,9 +4600,8 @@ GetAreaDataAddrs:
|
||||||
lda AreaPointer ; mask out all but 5 LSB
|
lda AreaPointer ; mask out all but 5 LSB
|
||||||
and #%00011111
|
and #%00011111
|
||||||
sta AreaAddrsLOffset ; save as low offset
|
sta AreaAddrsLOffset ; save as low offset
|
||||||
lda EnemyAddrHOffsets,y ; load base value with 2 altered MSB,
|
lda EnemyAddrHOffsets,y ; load base value with 2 altered MSB, then add base value to 5 LSB,
|
||||||
clc ; then add base value to 5 LSB, result
|
adc AreaAddrsLOffset ; result becomes offset for level data (clc optimization)
|
||||||
adc AreaAddrsLOffset ; becomes offset for level data
|
|
||||||
tay
|
tay
|
||||||
lda EnemyDataAddrLow,y ; use offset to load pointer
|
lda EnemyDataAddrLow,y ; use offset to load pointer
|
||||||
sta EnemyDataLow
|
sta EnemyDataLow
|
||||||
|
@ -6576,9 +6573,8 @@ RghtFrict:
|
||||||
XSpdSign:
|
XSpdSign:
|
||||||
cmp #$00 ; if player not moving or moving to the right,
|
cmp #$00 ; if player not moving or moving to the right,
|
||||||
bpl SetAbsSpd ; branch and leave horizontal speed value unmodified
|
bpl SetAbsSpd ; branch and leave horizontal speed value unmodified
|
||||||
eor #$ff
|
eor #$ff ; otherwise get two's compliment to get absolute
|
||||||
clc ; otherwise get two's compliment to get absolute
|
adc #$01-1 ; unsigned walking/running speed (clc optimization)
|
||||||
adc #$01 ; unsigned walking/running speed
|
|
||||||
SetAbsSpd:
|
SetAbsSpd:
|
||||||
sta Player_XSpeedAbsolute ; store walking/running speed here and leave
|
sta Player_XSpeedAbsolute ; store walking/running speed here and leave
|
||||||
rts
|
rts
|
||||||
|
@ -6869,8 +6865,7 @@ WhirlpoolActivate:
|
||||||
lsr ; shift d0 into carry (to run on every other frame)
|
lsr ; shift d0 into carry (to run on every other frame)
|
||||||
bcc WhPull ; if d0 not set, branch to last part of code
|
bcc WhPull ; if d0 not set, branch to last part of code
|
||||||
lda $01 ; get center
|
lda $01 ; get center
|
||||||
sec
|
sbc Player_X_Position ; subtract player's horizontal coordinate (sec optimization)
|
||||||
sbc Player_X_Position ; subtract player's horizontal coordinate
|
|
||||||
lda $00 ; get page location of center
|
lda $00 ; get page location of center
|
||||||
sbc Player_PageLoc ; subtract borrow
|
sbc Player_PageLoc ; subtract borrow
|
||||||
bpl LeftWh ; if player to the left of center, branch
|
bpl LeftWh ; if player to the left of center, branch
|
||||||
|
@ -6886,8 +6881,7 @@ LeftWh:
|
||||||
lsr ; shift d0 into carry
|
lsr ; shift d0 into carry
|
||||||
bcc WhPull ; if d0 not set, branch
|
bcc WhPull ; if d0 not set, branch
|
||||||
lda Player_X_Position ; otherwise slowly pull player right, towards the center
|
lda Player_X_Position ; otherwise slowly pull player right, towards the center
|
||||||
clc
|
adc #$01-1 ; add one pixel (clc optimization)
|
||||||
adc #$01 ; add one pixel
|
|
||||||
sta Player_X_Position ; set player's new horizontal coordinate
|
sta Player_X_Position ; set player's new horizontal coordinate
|
||||||
lda Player_PageLoc
|
lda Player_PageLoc
|
||||||
adc #$00 ; add carry
|
adc #$00 ; add carry
|
||||||
|
@ -7142,8 +7136,7 @@ FireCannon:
|
||||||
lda Cannon_X_Position,y ; get horizontal coordinate of cannon
|
lda Cannon_X_Position,y ; get horizontal coordinate of cannon
|
||||||
sta Enemy_X_Position,x ; save as horizontal coordinate of bullet bill
|
sta Enemy_X_Position,x ; save as horizontal coordinate of bullet bill
|
||||||
lda Cannon_Y_Position,y ; get vertical coordinate of cannon
|
lda Cannon_Y_Position,y ; get vertical coordinate of cannon
|
||||||
sec
|
sbc #$08-1 ; subtract eight pixels (because enemies are 24 pixels tall) (sec optimization)
|
||||||
sbc #$08 ; subtract eight pixels (because enemies are 24 pixels tall)
|
|
||||||
sta Enemy_Y_Position,x ; save as vertical coordinate of bullet bill
|
sta Enemy_Y_Position,x ; save as vertical coordinate of bullet bill
|
||||||
lda #$01
|
lda #$01
|
||||||
sta Enemy_Y_HighPos,x ; set vertical high byte of bullet bill
|
sta Enemy_Y_HighPos,x ; set vertical high byte of bullet bill
|
||||||
|
@ -7269,8 +7262,7 @@ ProcHammerObj:
|
||||||
beq SetHSpd ; if currently at 2, branch
|
beq SetHSpd ; if currently at 2, branch
|
||||||
bcs SetHPos ; if greater than 2, branch elsewhere
|
bcs SetHPos ; if greater than 2, branch elsewhere
|
||||||
txa
|
txa
|
||||||
clc ; add 13 bytes to use
|
adc #$0d ; add 13 bytes to use proper misc object (clc optimization)
|
||||||
adc #$0d ; proper misc object
|
|
||||||
tax ; return offset to X
|
tax ; return offset to X
|
||||||
lda #$10
|
lda #$10
|
||||||
sta $00 ; set downward movement force
|
sta $00 ; set downward movement force
|
||||||
|
@ -7295,8 +7287,7 @@ SetHSpd:
|
||||||
SetHPos:
|
SetHPos:
|
||||||
dec Misc_State,x ; decrement hammer's state
|
dec Misc_State,x ; decrement hammer's state
|
||||||
lda Enemy_X_Position,y ; get enemy's horizontal position
|
lda Enemy_X_Position,y ; get enemy's horizontal position
|
||||||
clc
|
adc #$02-1 ; set position 2 pixels to the right (clc optimization)
|
||||||
adc #$02 ; set position 2 pixels to the right
|
|
||||||
sta Misc_X_Position,x ; store as hammer's horizontal position
|
sta Misc_X_Position,x ; store as hammer's horizontal position
|
||||||
lda Enemy_PageLoc,y ; get enemy's page location
|
lda Enemy_PageLoc,y ; get enemy's page location
|
||||||
adc #$00 ; add carry
|
adc #$00 ; add carry
|
||||||
|
@ -8723,8 +8714,7 @@ CreateSpiny:
|
||||||
lda #$01 ; put spiny within vertical screen unit
|
lda #$01 ; put spiny within vertical screen unit
|
||||||
sta Enemy_Y_HighPos,x
|
sta Enemy_Y_HighPos,x
|
||||||
lda Enemy_Y_Position,y ; put spiny eight pixels above where lakitu is
|
lda Enemy_Y_Position,y ; put spiny eight pixels above where lakitu is
|
||||||
sec
|
sbc #$08 ; (sec optimization)
|
||||||
sbc #$08
|
|
||||||
sta Enemy_Y_Position,x
|
sta Enemy_Y_Position,x
|
||||||
lda PseudoRandomBitReg,x ; get 2 LSB of LSFR and save to Y
|
lda PseudoRandomBitReg,x ; get 2 LSB of LSFR and save to Y
|
||||||
and #%00000011
|
and #%00000011
|
||||||
|
@ -8856,8 +8846,7 @@ MaxCC:
|
||||||
asl ; otherwise, multiply A by 2
|
asl ; otherwise, multiply A by 2
|
||||||
GSeed:
|
GSeed:
|
||||||
pha ; save to stack
|
pha ; save to stack
|
||||||
clc
|
adc $00 ; add to last two bits of LSFR we saved earlier (clc optimization)
|
||||||
adc $00 ; add to last two bits of LSFR we saved earlier
|
|
||||||
sta $00 ; save it there
|
sta $00 ; save it there
|
||||||
lda PseudoRandomBitReg+1,x
|
lda PseudoRandomBitReg+1,x
|
||||||
and #%00000011 ; if neither of the last two bits of second LSFR set,
|
and #%00000011 ; if neither of the last two bits of second LSFR set,
|
||||||
|
@ -8867,8 +8856,7 @@ GSeed:
|
||||||
sta $00 ; third LSFR part
|
sta $00 ; third LSFR part
|
||||||
RSeed:
|
RSeed:
|
||||||
pla ; get value from stack we saved earlier
|
pla ; get value from stack we saved earlier
|
||||||
clc
|
adc $01 ; add to last two bits of LSFR we saved in other place (clc optimization)
|
||||||
adc $01 ; add to last two bits of LSFR we saved in other place
|
|
||||||
tay ; use as pseudorandom offset here
|
tay ; use as pseudorandom offset here
|
||||||
lda FlyCCXSpeedData,y ; get horizontal speed using pseudorandom offset
|
lda FlyCCXSpeedData,y ; get horizontal speed using pseudorandom offset
|
||||||
sta Enemy_X_Speed,x
|
sta Enemy_X_Speed,x
|
||||||
|
@ -8881,9 +8869,8 @@ RSeed:
|
||||||
and #%00000010
|
and #%00000010
|
||||||
beq D2XPos1 ; if d1 not set, branch
|
beq D2XPos1 ; if d1 not set, branch
|
||||||
lda Enemy_X_Speed,x
|
lda Enemy_X_Speed,x
|
||||||
eor #$ff ; if d1 set, change horizontal speed
|
eor #$ff ; if d1 set, change horizontal speed into two's compliment,
|
||||||
clc ; into two's compliment, thus moving in the opposite
|
adc #$01 ; thus moving in the opposite direction (clc optimization)
|
||||||
adc #$01 ; direction
|
|
||||||
sta Enemy_X_Speed,x
|
sta Enemy_X_Speed,x
|
||||||
inc Enemy_MovingDir,x ; increment to move towards the left
|
inc Enemy_MovingDir,x ; increment to move towards the left
|
||||||
D2XPos1:
|
D2XPos1:
|
||||||
|
@ -9006,8 +8993,7 @@ PutAtRightExtent:
|
||||||
|
|
||||||
SpawnFromMouth:
|
SpawnFromMouth:
|
||||||
lda Enemy_X_Position,y ; get bowser's horizontal position
|
lda Enemy_X_Position,y ; get bowser's horizontal position
|
||||||
sec
|
sbc #$0e ; subtract 14 pixels (sec optimization)
|
||||||
sbc #$0e ; subtract 14 pixels
|
|
||||||
sta Enemy_X_Position,x ; save as flame's horizontal position
|
sta Enemy_X_Position,x ; save as flame's horizontal position
|
||||||
lda Enemy_PageLoc,y
|
lda Enemy_PageLoc,y
|
||||||
sta Enemy_PageLoc,x ; copy page location from bowser to flame
|
sta Enemy_PageLoc,x ; copy page location from bowser to flame
|
||||||
|
@ -9061,9 +9047,8 @@ StarFChk:
|
||||||
lda Enemy_ID,y ; check for presence of star flag object
|
lda Enemy_ID,y ; check for presence of star flag object
|
||||||
cmp #StarFlagObject ; if there isn't a star flag object,
|
cmp #StarFlagObject ; if there isn't a star flag object,
|
||||||
bne StarFChk ; routine goes into infinite loop = crash
|
bne StarFChk ; routine goes into infinite loop = crash
|
||||||
lda Enemy_X_Position,y
|
lda Enemy_X_Position,y ; get horizontal coordinate of star flag object, then
|
||||||
sec ; get horizontal coordinate of star flag object, then
|
sbc #$30 ; subtract 48 pixels from it and save to (sec optimization)
|
||||||
sbc #$30 ; subtract 48 pixels from it and save to
|
|
||||||
pha ; the stack
|
pha ; the stack
|
||||||
lda Enemy_PageLoc,y
|
lda Enemy_PageLoc,y
|
||||||
sbc #$00 ; subtract the carry from the page location
|
sbc #$00 ; subtract the carry from the page location
|
||||||
|
@ -9182,8 +9167,7 @@ FireBulletBill:
|
||||||
|
|
||||||
HandleGroupEnemies:
|
HandleGroupEnemies:
|
||||||
ldy #$00 ; load value for green koopa troopa
|
ldy #$00 ; load value for green koopa troopa
|
||||||
sec
|
sbc #$37-1 ; subtract $37 from second byte read (sec optimization)
|
||||||
sbc #$37 ; subtract $37 from second byte read
|
|
||||||
pha ; save result in stack for now
|
pha ; save result in stack for now
|
||||||
cmp #$04 ; was byte in $3b-$3e range?
|
cmp #$04 ; was byte in $3b-$3e range?
|
||||||
bcs SnglID ; if so, branch
|
bcs SnglID ; if so, branch
|
||||||
|
@ -9227,8 +9211,7 @@ GSltLp:
|
||||||
sta Enemy_PageLoc,x ; store page location for enemy object
|
sta Enemy_PageLoc,x ; store page location for enemy object
|
||||||
lda $03
|
lda $03
|
||||||
sta Enemy_X_Position,x ; store x coordinate for enemy object
|
sta Enemy_X_Position,x ; store x coordinate for enemy object
|
||||||
clc
|
adc #$18 ; add 24 pixels for next enemy (clc optimization)
|
||||||
adc #$18 ; add 24 pixels for next enemy
|
|
||||||
sta $03
|
sta $03
|
||||||
lda $02 ; add carry to page location for
|
lda $02 ; add carry to page location for
|
||||||
adc #$00 ; next enemy
|
adc #$00 ; next enemy
|
||||||
|
@ -9254,8 +9237,7 @@ InitPiranhaPlant:
|
||||||
sta PiranhaPlant_MoveFlag,x ; be used as vertical speed, but not in this case
|
sta PiranhaPlant_MoveFlag,x ; be used as vertical speed, but not in this case
|
||||||
lda Enemy_Y_Position,x
|
lda Enemy_Y_Position,x
|
||||||
sta PiranhaPlantDownYPos,x ; save original vertical coordinate here
|
sta PiranhaPlantDownYPos,x ; save original vertical coordinate here
|
||||||
sec
|
sbc #$18 ; (sec optimization)
|
||||||
sbc #$18
|
|
||||||
sta PiranhaPlantUpYPos,x ; save original vertical coordinate - 24 pixels here
|
sta PiranhaPlantUpYPos,x ; save original vertical coordinate - 24 pixels here
|
||||||
lda #$09
|
lda #$09
|
||||||
jmp SetBBox2 ; set specific value for bounding box control
|
jmp SetBBox2 ; set specific value for bounding box control
|
||||||
|
@ -10000,8 +9982,7 @@ ProcSwimmingB:
|
||||||
pla ; pull 3 LSB of frame counter from the stack
|
pla ; pull 3 LSB of frame counter from the stack
|
||||||
bne BSwimE ; branch to leave, execute code only every eighth frame
|
bne BSwimE ; branch to leave, execute code only every eighth frame
|
||||||
lda Enemy_Y_MoveForce,x
|
lda Enemy_Y_MoveForce,x
|
||||||
clc ; add to movement force to speed up swim
|
adc #$01 ; add to movement force to speed up swim (clc optimization)
|
||||||
adc #$01
|
|
||||||
sta Enemy_Y_MoveForce,x ; set movement force
|
sta Enemy_Y_MoveForce,x ; set movement force
|
||||||
sta BlooperMoveSpeed,x ; set as movement speed
|
sta BlooperMoveSpeed,x ; set as movement speed
|
||||||
cmp #$02
|
cmp #$02
|
||||||
|
@ -10014,8 +9995,7 @@ SlowSwim:
|
||||||
pla ; pull 3 LSB of frame counter from the stack
|
pla ; pull 3 LSB of frame counter from the stack
|
||||||
bne NoSSw ; branch to leave, execute code only every eighth frame
|
bne NoSSw ; branch to leave, execute code only every eighth frame
|
||||||
lda Enemy_Y_MoveForce,x
|
lda Enemy_Y_MoveForce,x
|
||||||
sec ; subtract from movement force to slow swim
|
sbc #$01 ; subtract from movement force to slow swim (sec optimization)
|
||||||
sbc #$01
|
|
||||||
sta Enemy_Y_MoveForce,x ; set movement force
|
sta Enemy_Y_MoveForce,x ; set movement force
|
||||||
sta BlooperMoveSpeed,x ; set as movement speed
|
sta BlooperMoveSpeed,x ; set as movement speed
|
||||||
bne NoSSw ; if any speed, branch to leave
|
bne NoSSw ; if any speed, branch to leave
|
||||||
|
@ -10195,8 +10175,7 @@ SusFbar:
|
||||||
cmp #$18
|
cmp #$18
|
||||||
bne SetupGFB ; if not at twenty-four branch to not change
|
bne SetupGFB ; if not at twenty-four branch to not change
|
||||||
SkpFSte:
|
SkpFSte:
|
||||||
clc
|
adc #$01-1 ; add one to spinning thing to avoid horizontal state (clc optimization)
|
||||||
adc #$01 ; add one to spinning thing to avoid horizontal state
|
|
||||||
sta FirebarSpinState_High,x
|
sta FirebarSpinState_High,x
|
||||||
SetupGFB:
|
SetupGFB:
|
||||||
sta $ef ; save high byte of spinning thing, modified or otherwise
|
sta $ef ; save high byte of spinning thing, modified or otherwise
|
||||||
|
@ -10259,8 +10238,7 @@ AddHA:
|
||||||
sbc $06 ; original one and skip this part
|
sbc $06 ; original one and skip this part
|
||||||
jmp ChkFOfs
|
jmp ChkFOfs
|
||||||
SubtR1:
|
SubtR1:
|
||||||
sec ; subtract original X from the
|
sbc Enemy_Rel_XPos ; subtract original X from the current sprite X (sec optimization)
|
||||||
sbc Enemy_Rel_XPos ; current sprite X
|
|
||||||
ChkFOfs:
|
ChkFOfs:
|
||||||
cmp #$59 ; if difference of coordinates within a certain range,
|
cmp #$59 ; if difference of coordinates within a certain range,
|
||||||
bcc VAHandl ; continue by handling vertical adder
|
bcc VAHandl ; continue by handling vertical adder
|
||||||
|
@ -10321,8 +10299,7 @@ ChkVFBD:
|
||||||
cmp #$f0 ; because, really, what's the point?
|
cmp #$f0 ; because, really, what's the point?
|
||||||
bcs Chk2Ofs
|
bcs Chk2Ofs
|
||||||
lda Sprite_X_Position+4 ; get OAM X coordinate for sprite #1
|
lda Sprite_X_Position+4 ; get OAM X coordinate for sprite #1
|
||||||
clc
|
adc #$04 ; add four pixels (clc optimization)
|
||||||
adc #$04 ; add four pixels
|
|
||||||
sta $04 ; store here
|
sta $04 ; store here
|
||||||
sec ; subtract horizontal coordinate of firebar
|
sec ; subtract horizontal coordinate of firebar
|
||||||
sbc $06 ; from the X coordinate of player's sprite 1
|
sbc $06 ; from the X coordinate of player's sprite 1
|
||||||
|
@ -10371,33 +10348,28 @@ GetFirebarPosition:
|
||||||
cmp #$09
|
cmp #$09
|
||||||
bcc GetHAdder ; if lower than $09, branch ahead
|
bcc GetHAdder ; if lower than $09, branch ahead
|
||||||
eor #%00001111 ; otherwise get two's compliment to oscillate
|
eor #%00001111 ; otherwise get two's compliment to oscillate
|
||||||
clc
|
adc #$01-1 ; (clc optimization)
|
||||||
adc #$01
|
|
||||||
GetHAdder:
|
GetHAdder:
|
||||||
sta $01 ; store result, modified or not, here
|
sta $01 ; store result, modified or not, here
|
||||||
ldy $00 ; load number of firebar ball where we're at
|
ldy $00 ; load number of firebar ball where we're at
|
||||||
lda FirebarTblOffsets,y ; load offset to firebar position data
|
lda FirebarTblOffsets,y ; load offset to firebar position data
|
||||||
clc
|
adc $01 ; add oscillated high byte of spinstate (clc optimization)
|
||||||
adc $01 ; add oscillated high byte of spinstate
|
|
||||||
tay ; to offset here and use as new offset
|
tay ; to offset here and use as new offset
|
||||||
lda FirebarPosLookupTbl,y ; get data here and store as horizontal adder
|
lda FirebarPosLookupTbl,y ; get data here and store as horizontal adder
|
||||||
sta $01
|
sta $01
|
||||||
pla ; pull whatever was in A from the stack
|
pla ; pull whatever was in A from the stack
|
||||||
pha ; save it again because we still need it
|
pha ; save it again because we still need it
|
||||||
clc
|
adc #$08 ; add eight this time, to get vertical adder (clc optimization)
|
||||||
adc #$08 ; add eight this time, to get vertical adder
|
|
||||||
and #%00001111 ; mask out high nybble
|
and #%00001111 ; mask out high nybble
|
||||||
cmp #$09 ; if lower than $09, branch ahead
|
cmp #$09 ; if lower than $09, branch ahead
|
||||||
bcc GetVAdder
|
bcc GetVAdder
|
||||||
eor #%00001111 ; otherwise get two's compliment
|
eor #%00001111 ; otherwise get two's compliment
|
||||||
clc
|
adc #$01-1 ; (clc optimization)
|
||||||
adc #$01
|
|
||||||
GetVAdder:
|
GetVAdder:
|
||||||
sta $02 ; store result here
|
sta $02 ; store result here
|
||||||
ldy $00
|
ldy $00
|
||||||
lda FirebarTblOffsets,y ; load offset to firebar position data again
|
lda FirebarTblOffsets,y ; load offset to firebar position data again
|
||||||
clc
|
adc $02 ; this time add value in $02 to offset here and use as offset (clc optimization)
|
||||||
adc $02 ; this time add value in $02 to offset here and use as offset
|
|
||||||
tay
|
tay
|
||||||
lda FirebarPosLookupTbl,y ; get data here and store as vertica adder
|
lda FirebarPosLookupTbl,y ; get data here and store as vertica adder
|
||||||
sta $02
|
sta $02
|
||||||
|
@ -10444,8 +10416,7 @@ AddCCF:
|
||||||
cmp #$08 ; if result or two's compliment greater than eight,
|
cmp #$08 ; if result or two's compliment greater than eight,
|
||||||
bcs BPGet ; skip to the end without changing movement force
|
bcs BPGet ; skip to the end without changing movement force
|
||||||
lda Enemy_Y_MoveForce,x
|
lda Enemy_Y_MoveForce,x
|
||||||
clc
|
adc #$10 ; otherwise add to it (clc optimization)
|
||||||
adc #$10 ; otherwise add to it
|
|
||||||
sta Enemy_Y_MoveForce,x
|
sta Enemy_Y_MoveForce,x
|
||||||
lsr ; move high nybble to low again
|
lsr ; move high nybble to low again
|
||||||
lsr
|
lsr
|
||||||
|
@ -11246,8 +11217,7 @@ ChkToMoveBalPlat:
|
||||||
lda PlatformCollisionFlag,x ; get collision flag
|
lda PlatformCollisionFlag,x ; get collision flag
|
||||||
bpl ColFlg ; branch if collision
|
bpl ColFlg ; branch if collision
|
||||||
lda Enemy_Y_MoveForce,x
|
lda Enemy_Y_MoveForce,x
|
||||||
clc ; add $05 to contents of moveforce, whatever they be
|
adc #$05 ; add $05 to contents of moveforce, whatever they be (clc optimization)
|
||||||
adc #$05
|
|
||||||
sta $00 ; store here
|
sta $00 ; store here
|
||||||
lda Enemy_Y_Speed,x
|
lda Enemy_Y_Speed,x
|
||||||
adc #$00 ; add carry to vertical speed
|
adc #$00 ; add carry to vertical speed
|
||||||
|
@ -11370,8 +11340,7 @@ GetLRp:
|
||||||
pla ; get second/third copy of vertical speed from stack
|
pla ; get second/third copy of vertical speed from stack
|
||||||
bpl GetHRp ; skip this part if moving downwards or not at all
|
bpl GetHRp ; skip this part if moving downwards or not at all
|
||||||
txa
|
txa
|
||||||
clc
|
adc #$08 ; add eight to vertical coordinate (clc optimization) and
|
||||||
adc #$08 ; add eight to vertical coordinate and
|
|
||||||
tax ; save as X
|
tax ; save as X
|
||||||
GetHRp:
|
GetHRp:
|
||||||
txa ; move vertical coordinate to A
|
txa ; move vertical coordinate to A
|
||||||
|
@ -11780,8 +11749,7 @@ PlayerHammerCollision:
|
||||||
sta Misc_Collision_Flag,x ; otherwise set collision flag now
|
sta Misc_Collision_Flag,x ; otherwise set collision flag now
|
||||||
lda Misc_X_Speed,x
|
lda Misc_X_Speed,x
|
||||||
eor #$ff ; get two's compliment of
|
eor #$ff ; get two's compliment of
|
||||||
clc ; hammer's horizontal speed
|
adc #$01-1 ; hammer's horizontal speed (clc optimization)
|
||||||
adc #$01
|
|
||||||
sta Misc_X_Speed,x ; set to send hammer flying the opposite direction
|
sta Misc_X_Speed,x ; set to send hammer flying the opposite direction
|
||||||
lda StarInvincibleTimer ; if star mario invincibility timer set,
|
lda StarInvincibleTimer ; if star mario invincibility timer set,
|
||||||
bne ExPHC ; branch to leave
|
bne ExPHC ; branch to leave
|
||||||
|
@ -11942,8 +11910,7 @@ ChkInj:
|
||||||
cmp #Bloober
|
cmp #Bloober
|
||||||
bcc ChkETmrs
|
bcc ChkETmrs
|
||||||
lda Player_Y_Position ; add 12 pixels to player's vertical position
|
lda Player_Y_Position ; add 12 pixels to player's vertical position
|
||||||
clc
|
adc #$0c-1 ; (clc optimization)
|
||||||
adc #$0c
|
|
||||||
cmp Enemy_Y_Position,x ; compare modified player's position to enemy's position
|
cmp Enemy_Y_Position,x ; compare modified player's position to enemy's position
|
||||||
bcc EnemyStomped ; branch if this player's position above (less than) enemy's
|
bcc EnemyStomped ; branch if this player's position above (less than) enemy's
|
||||||
ChkETmrs:
|
ChkETmrs:
|
||||||
|
@ -12066,8 +12033,7 @@ HandleStompedShellE:
|
||||||
sta Enemy_State,x
|
sta Enemy_State,x
|
||||||
inc StompChainCounter ; increment the stomp counter
|
inc StompChainCounter ; increment the stomp counter
|
||||||
lda StompChainCounter ; add whatever is in the stomp counter
|
lda StompChainCounter ; add whatever is in the stomp counter
|
||||||
clc ; to whatever is in the stomp timer
|
adc StompTimer ; to whatever is in the stomp timer (clc optimization)
|
||||||
adc StompTimer
|
|
||||||
jsr SetupFloateyNumber ; award points accordingly
|
jsr SetupFloateyNumber ; award points accordingly
|
||||||
inc StompTimer ; increment stomp timer of some sort
|
inc StompTimer ; increment stomp timer of some sort
|
||||||
ldy PrimaryHardMode ; check primary hard mode flag
|
ldy PrimaryHardMode ; check primary hard mode flag
|
||||||
|
@ -12334,8 +12300,7 @@ ChkSmallPlatLoop:
|
||||||
|
|
||||||
MoveBoundBox:
|
MoveBoundBox:
|
||||||
lda BoundingBox_UL_YPos,y ; move bounding box vertical coordinates
|
lda BoundingBox_UL_YPos,y ; move bounding box vertical coordinates
|
||||||
clc ; 128 pixels downwards
|
adc #$80 ; 128 pixels downwards (clc optimization)
|
||||||
adc #$80
|
|
||||||
sta BoundingBox_UL_YPos,y
|
sta BoundingBox_UL_YPos,y
|
||||||
lda BoundingBox_DR_YPos,y
|
lda BoundingBox_DR_YPos,y
|
||||||
clc
|
clc
|
||||||
|
@ -12353,9 +12318,8 @@ ProcSPlatCollisions:
|
||||||
ldx ObjectOffset ; return enemy object buffer offset to X, then continue
|
ldx ObjectOffset ; return enemy object buffer offset to X, then continue
|
||||||
|
|
||||||
ProcLPlatCollisions:
|
ProcLPlatCollisions:
|
||||||
lda BoundingBox_DR_YPos,y ; get difference by subtracting the top
|
lda BoundingBox_DR_YPos,y ; get difference by subtracting the top of the player's bounding box
|
||||||
sec ; of the player's bounding box from the bottom
|
sbc BoundingBox_UL_YPos ; from the bottom of the platform's bounding box (sec optimization)
|
||||||
sbc BoundingBox_UL_YPos ; of the platform's bounding box
|
|
||||||
cmp #$04 ; if difference too large or negative,
|
cmp #$04 ; if difference too large or negative,
|
||||||
bcs ChkForTopCollision ; branch, do not alter vertical speed of player
|
bcs ChkForTopCollision ; branch, do not alter vertical speed of player
|
||||||
lda Player_Y_Speed ; check to see if player's vertical speed is moving down
|
lda Player_Y_Speed ; check to see if player's vertical speed is moving down
|
||||||
|
@ -12426,8 +12390,7 @@ PositionPlayerOnVPlat:
|
||||||
ldy Enemy_Y_HighPos,x
|
ldy Enemy_Y_HighPos,x
|
||||||
cpy #$01 ; if vertical high byte offscreen, skip this
|
cpy #$01 ; if vertical high byte offscreen, skip this
|
||||||
bne ExPlPos
|
bne ExPlPos
|
||||||
sec ; subtract 32 pixels from vertical coordinate
|
sbc #$20 ; subtract 32 pixels from vertical coordinate for the player object's height (sec optimization)
|
||||||
sbc #$20 ; for the player object's height
|
|
||||||
sta Player_Y_Position ; save as player's new vertical coordinate
|
sta Player_Y_Position ; save as player's new vertical coordinate
|
||||||
tya
|
tya
|
||||||
sbc #$00 ; subtract borrow and store as player's
|
sbc #$00 ; subtract borrow and store as player's
|
||||||
|
@ -13292,8 +13255,7 @@ EnemyJump:
|
||||||
jsr SubtEnemyYPos ; do a sub here
|
jsr SubtEnemyYPos ; do a sub here
|
||||||
bcc DoSide ; if enemy vertical coord + 62 < 68, branch to leave
|
bcc DoSide ; if enemy vertical coord + 62 < 68, branch to leave
|
||||||
lda Enemy_Y_Speed,x
|
lda Enemy_Y_Speed,x
|
||||||
clc ; add two to vertical speed
|
adc #$02-1 ; add two to vertical speed (clc optimization)
|
||||||
adc #$02
|
|
||||||
cmp #$03 ; if green paratroopa not falling, branch ahead
|
cmp #$03 ; if green paratroopa not falling, branch ahead
|
||||||
bcc DoSide
|
bcc DoSide
|
||||||
jsr ChkUnderEnemy ; otherwise, check to see if green paratroopa is
|
jsr ChkUnderEnemy ; otherwise, check to see if green paratroopa is
|
||||||
|
@ -13645,8 +13607,7 @@ BlockBufferChk_Enemy:
|
||||||
BlockBufferChk_FBall:
|
BlockBufferChk_FBall:
|
||||||
ldy #$1a ; set offset for block buffer adder data
|
ldy #$1a ; set offset for block buffer adder data
|
||||||
txa
|
txa
|
||||||
clc
|
adc #$07-1 ; add seven bytes to use (clc optimization)
|
||||||
adc #$07 ; add seven bytes to use
|
|
||||||
tax
|
tax
|
||||||
lda #$00 ; set A to return vertical coordinate
|
lda #$00 ; set A to return vertical coordinate
|
||||||
BBChk_E:
|
BBChk_E:
|
||||||
|
@ -14085,8 +14046,7 @@ JCoinGfxHandler:
|
||||||
bcs DrawFloateyNumber_Coin ; branch to draw floatey number
|
bcs DrawFloateyNumber_Coin ; branch to draw floatey number
|
||||||
lda Misc_Y_Position,x ; store vertical coordinate as
|
lda Misc_Y_Position,x ; store vertical coordinate as
|
||||||
sta Sprite_Y_Position,y ; Y coordinate for first sprite
|
sta Sprite_Y_Position,y ; Y coordinate for first sprite
|
||||||
clc
|
adc #$08 ; add eight pixels (clc optimization)
|
||||||
adc #$08 ; add eight pixels
|
|
||||||
sta Sprite_Y_Position+4,y ; store as Y coordinate for second sprite
|
sta Sprite_Y_Position+4,y ; store as Y coordinate for second sprite
|
||||||
lda Misc_Rel_XPos ; get relative horizontal coordinate
|
lda Misc_Rel_XPos ; get relative horizontal coordinate
|
||||||
sta Sprite_X_Position,y
|
sta Sprite_X_Position,y
|
||||||
|
@ -14386,8 +14346,7 @@ ChkRearSte:
|
||||||
and #%00100000 ; if bowser not defeated, do not set flag
|
and #%00100000 ; if bowser not defeated, do not set flag
|
||||||
beq DrawBowser
|
beq DrawBowser
|
||||||
lda $02 ; subtract 16 pixels from
|
lda $02 ; subtract 16 pixels from
|
||||||
sec ; saved vertical coordinate
|
sbc #$10 ; saved vertical coordinate (sec optimization)
|
||||||
sbc #$10
|
|
||||||
sta $02
|
sta $02
|
||||||
jmp FlipBowserOver ; jump to set vertical flip flag
|
jmp FlipBowserOver ; jump to set vertical flip flag
|
||||||
|
|
||||||
|
@ -14561,9 +14520,8 @@ CheckForVerticalFlip:
|
||||||
cmp #$15
|
cmp #$15
|
||||||
bcs FlipEnemyVertically ; also branch if enemy object => $15
|
bcs FlipEnemyVertically ; also branch if enemy object => $15
|
||||||
txa
|
txa
|
||||||
clc
|
|
||||||
adc #$08 ; if not selected objects or => $15, set
|
adc #$08 ; if not selected objects or => $15, set
|
||||||
tax ; offset in X for next row
|
tax ; offset in X for next row (clc optimization)
|
||||||
|
|
||||||
FlipEnemyVertically:
|
FlipEnemyVertically:
|
||||||
lda Sprite_Tilenumber,x ; load first or second row tiles
|
lda Sprite_Tilenumber,x ; load first or second row tiles
|
||||||
|
|
Loading…
Reference in New Issue