|
|
@@ -314,22 +314,22 @@ Block_X_Position = $8f |
|
|
Misc_X_Position = $93 |
|
|
Bubble_X_Position = $9c |
|
|
|
|
|
SprObject_Y_Speed = $9f |
|
|
SprObject_Y_Spd_Hi = $9f |
|
|
Player_Y_Speed = $9f |
|
|
Enemy_Y_Speed = $a0 |
|
|
Fireball_Y_Speed = $a6 |
|
|
Block_Y_Speed = $a8 |
|
|
Misc_Y_Speed = $ac |
|
|
|
|
|
SprObject_Y_HighPos = $b5 |
|
|
SprObject_Y_Pos_Pg = $b5 |
|
|
Player_Y_HighPos = $b5 |
|
|
Enemy_Y_HighPos = $b6 |
|
|
Fireball_Y_HighPos = $bc |
|
|
Block_Y_HighPos = $be |
|
|
Misc_Y_HighPos = $c2 |
|
|
Bubble_Y_HighPos = $cb |
|
|
|
|
|
SprObject_Y_Position = $ce |
|
|
SprObject_Y_Pos_Hi = $ce |
|
|
Player_Y_Position = $ce |
|
|
Enemy_Y_Position = $cf |
|
|
Fireball_Y_Position = $d5 |
|
|
@@ -360,12 +360,12 @@ Enemy_SprAttrib = $03c5 |
|
|
SprObject_X_MoveForce = $0400 |
|
|
Enemy_X_MoveForce = $0401 |
|
|
|
|
|
SprObject_YMF_Dummy = $0416 |
|
|
SprObject_Y_Pos_Lo = $0416 |
|
|
Player_YMF_Dummy = $0416 |
|
|
Enemy_YMF_Dummy = $0417 |
|
|
Bubble_YMF_Dummy = $042c |
|
|
|
|
|
SprObject_Y_MoveForce = $0433 |
|
|
SprObject_Y_Spd_Lo = $0433 |
|
|
Player_Y_MoveForce = $0433 |
|
|
Enemy_Y_MoveForce = $0434 |
|
|
Block_Y_MoveForce = $043c |
|
|
@@ -7704,63 +7704,65 @@ RedPTroopaGrav: |
|
|
;------------------------------------------------------------------------------------- |
|
|
;$00 - used for downward force |
|
|
;$01 - used for upward force |
|
|
;$07 - used as adder for vertical position |
|
|
;$02 - used for maximum speed |
|
|
;$07 - used to help set Y page number, and as the negative of max speed (for ChkUpM) |
|
|
;A - used to skip ChkUpM |
|
|
|
|
|
ImposeGravity: |
|
|
pha ;push value to stack |
|
|
lda SprObject_YMF_Dummy,x |
|
|
clc ;add value in movement force to contents of dummy variable |
|
|
adc SprObject_Y_MoveForce,x |
|
|
sta SprObject_YMF_Dummy,x |
|
|
pha ;push value to stack (for skipping ChkUpM) |
|
|
lda SprObject_Y_Pos_Lo,x |
|
|
clc |
|
|
adc SprObject_Y_Spd_Lo,x ;add speed low byte to position low byte |
|
|
sta SprObject_Y_Pos_Lo,x ;and store it |
|
|
ldy #$00 ;set Y to zero by default |
|
|
lda SprObject_Y_Speed,x ;get current vertical speed |
|
|
lda SprObject_Y_Spd_Hi,x ;get current vertical speed |
|
|
bpl AlterYP ;if currently moving downwards, do not decrement Y |
|
|
dey ;otherwise decrement Y |
|
|
AlterYP: sty $07 ;store Y here |
|
|
adc SprObject_Y_Position,x ;add vertical position to vertical speed plus carry |
|
|
sta SprObject_Y_Position,x ;store as new vertical position |
|
|
lda SprObject_Y_HighPos,x |
|
|
adc $07 ;add carry plus contents of $07 to vertical high byte |
|
|
sta SprObject_Y_HighPos,x ;store as new vertical high byte |
|
|
lda SprObject_Y_MoveForce,x |
|
|
adc SprObject_Y_Pos_Hi,x ;add speed and position, plus carry from low byte position |
|
|
sta SprObject_Y_Pos_Hi,x ;store as new vertical position |
|
|
lda SprObject_Y_Pos_Pg,x |
|
|
adc $07 ;add carry plus contents of $07 to Y page number |
|
|
sta SprObject_Y_Pos_Pg,x ;store as new Y page number |
|
|
lda SprObject_Y_Spd_Lo,x |
|
|
clc |
|
|
adc $00 ;add downward movement amount to contents of $0433 |
|
|
sta SprObject_Y_MoveForce,x |
|
|
lda SprObject_Y_Speed,x ;add carry to vertical speed and store |
|
|
adc $00 ;add downward movement amount to Y speed low byte |
|
|
sta SprObject_Y_Spd_Lo,x |
|
|
lda SprObject_Y_Spd_Hi,x ;add carry to Y speed high byte and store |
|
|
adc #$00 |
|
|
sta SprObject_Y_Speed,x |
|
|
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 |
|
|
sta SprObject_Y_Spd_Hi,x |
|
|
cmp $02 ;compare Y speed to maximum speed |
|
|
bmi ChkUpM ;if less than max speed, skip this part |
|
|
lda SprObject_Y_Spd_Lo,x |
|
|
cmp #$80 ;if Y speed low byte < 0x80, skip this part |
|
|
bcc ChkUpM |
|
|
lda $02 |
|
|
sta SprObject_Y_Speed,x ;keep vertical speed within maximum value |
|
|
sta SprObject_Y_Spd_Hi,x ;keep Y speed within maximum value |
|
|
lda #$00 |
|
|
sta SprObject_Y_MoveForce,x ;clear fractional |
|
|
sta SprObject_Y_Spd_Lo,x ;clear Y speed low byte |
|
|
ChkUpM: pla ;get value from stack |
|
|
beq ExVMove ;if set to zero, branch to leave |
|
|
lda $02 |
|
|
eor #%11111111 ;otherwise get two's compliment of maximum speed |
|
|
eor #%11111111 ;otherwise invert sign of max speed |
|
|
tay |
|
|
iny |
|
|
sty $07 ;store two's compliment here |
|
|
lda SprObject_Y_MoveForce,x |
|
|
sty $07 ;store max speed here |
|
|
lda SprObject_Y_Spd_Lo,x |
|
|
sec ;subtract upward movement amount from contents |
|
|
sbc $01 ;of movement force, note that $01 is twice as large as $00, |
|
|
sta SprObject_Y_MoveForce,x ;thus it effectively undoes add we did earlier |
|
|
lda SprObject_Y_Speed,x |
|
|
sbc #$00 ;subtract borrow from vertical speed and store |
|
|
sta SprObject_Y_Speed,x |
|
|
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, |
|
|
sbc $01 ;of Y speed low; note that $01 is twice as large as $00, |
|
|
sta SprObject_Y_Spd_Lo,x ;thus it effectively undoes add we did earlier |
|
|
lda SprObject_Y_Spd_Hi,x |
|
|
sbc #$00 ;subtract carry from Y speed high byte and store |
|
|
sta SprObject_Y_Spd_Hi,x |
|
|
cmp $07 ;compare Y speed to max upward speed |
|
|
bpl ExVMove ;if less negative than max speed, skip this part |
|
|
lda SprObject_Y_Spd_Lo,x |
|
|
cmp #$80 ;check if Y speed low byte is above certain amount, |
|
|
bcs ExVMove ;and if so, branch to leave |
|
|
lda $07 |
|
|
sta SprObject_Y_Speed,x ;keep vertical speed within maximum value |
|
|
lda #$ff |
|
|
sta SprObject_Y_MoveForce,x ;clear fractional |
|
|
sta SprObject_Y_Spd_Hi,x ;keep Y speed within maximum value |
|
|
lda #$ff ;set Y speed low byte to $ff, which reduces max upward |
|
|
sta SprObject_Y_Spd_Lo,x ;speed by nearly 1 full unit (possibly an error?) |
|
|
ExVMove: rts ;leave! |
|
|
|
|
|
;------------------------------------------------------------------------------------- |
|
|
@@ -13075,7 +13077,7 @@ BlockBufferCollision: |
|
|
lsr ;d4 at this point |
|
|
jsr GetBlockBufferAddr ;get address of block buffer into $06, $07 |
|
|
ldy $04 ;get old contents of Y |
|
|
lda SprObject_Y_Position,x ;get vertical coordinate of object |
|
|
lda SprObject_Y_Pos_Hi,x ;get vertical coordinate of object |
|
|
clc |
|
|
adc BlockBuffer_Y_Adder,y ;add it to value obtained using Y as offset |
|
|
and #%11110000 ;mask out low nybble |
|
|
@@ -13088,7 +13090,7 @@ BlockBufferCollision: |
|
|
ldy $04 ;get old contents of Y again |
|
|
pla ;pull A from stack |
|
|
bne RetXC ;if A = 1, branch |
|
|
lda SprObject_Y_Position,x ;if A = 0, load vertical coordinate |
|
|
lda SprObject_Y_Pos_Hi,x ;if A = 0, load vertical coordinate |
|
|
jmp RetYC ;and jump |
|
|
RetXC: lda SprObject_X_Position,x ;otherwise load horizontal coordinate |
|
|
RetYC: and #%00001111 ;and mask out high nybble |
|
|
@@ -14814,7 +14816,7 @@ VariableObjOfsRelPos: |
|
|
rts |
|
|
|
|
|
GetObjRelativePosition: |
|
|
lda SprObject_Y_Position,x ;load vertical coordinate low |
|
|
lda SprObject_Y_Pos_Hi,x ;load vertical coordinate low |
|
|
sta SprObject_Rel_YPos,y ;store here |
|
|
lda SprObject_X_Position,x ;load horizontal coordinate |
|
|
sec ;subtract left edge coordinate |
|
|
@@ -14958,10 +14960,10 @@ GetYOffscreenBits: |
|
|
ldy #$01 ;start with top of screen |
|
|
YOfsLoop: lda HighPosUnitData,y ;load coordinate for edge of vertical unit |
|
|
sec |
|
|
sbc SprObject_Y_Position,x ;subtract from vertical coordinate of object |
|
|
sbc SprObject_Y_Pos_Hi,x ;subtract from vertical coordinate of object |
|
|
sta $07 ;store here |
|
|
lda #$01 ;subtract one from vertical high byte of object |
|
|
sbc SprObject_Y_HighPos,x |
|
|
sbc SprObject_Y_Pos_Pg,x |
|
|
ldx DefaultYOnscreenOfs,y ;load offset value here |
|
|
cmp #$00 |
|
|
bmi YLdBData ;if under top of the screen or beyond bottom, branch |
|
|
|