Add comments and update formatting

This commit is contained in:
scawful
2024-03-30 09:43:58 -04:00
parent e0a20a98cd
commit 58dd5aab1f

View File

@@ -92,17 +92,15 @@ Sprite_Minecart_Prep:
; If link is in a cart, then draw the dummy cart
LDA !LinkInCart : BNE .dummy_continue
.clear_cart
; .clear_cart
STZ.w $0DD0, X ; Otherwise, clear the sprite
PLB
RTL
.continue
; Unused dummy cart code
; LDA.w !LinkInCart : AND.b #$FF : BEQ .dummy_continue
; JMP .clear_cart
.dummy_continue
LDA SprY, X : SEC : SBC.b #$04 : STA SprY, X
@@ -141,7 +139,6 @@ Sprite_Minecart_Prep:
%GotoAction(0) ; Minecart_WaitHoriz
.done
PLB
RTL
}
@@ -238,7 +235,6 @@ Sprite_Minecart_Main:
.lifting
%HandleLiftAndToss()
RTS
}
@@ -255,8 +251,7 @@ Sprite_Minecart_Main:
JSL Player_HaltDashAttack ; Stop the player from dashing
LDA #$02 : STA $02F5 ; Somaria platform and moving
LDA $0FDA : SEC : SBC #$0B : STA $20 ; Adjust player pos
LDA #$01 : STA !LinkInCart
LDA #$01 : STA !LinkInCart ; Set Link in cart flag
; Check if the cart is facing north or south
LDA SprSubtype, X : BEQ .opposite_direction
@@ -384,12 +379,19 @@ Sprite_Minecart_Main:
}
}
; ===========================================================================
; =========================================================
; The purpose of this routine is to determine the direction
; the sprite is facing and then adjust the X and Y positions
; of the tile interaction lookup based on that direction.
; If implemented correctly this would make sure the sprite
; stays centered on the tracks when it makes corner turns.
; Currently, depending on where the tile is placed the
; cart may make a turn too early and appear to be off center.
SetTileLookupPosBasedOnDirection:
{
; Based on the direction of the Minecart, adjust the lookup position
; to be in front of the sprite
; Based on the direction of the Minecart, adjust the
; lookup position to be in front of the sprite
LDA.w !MinecartDirection : CMP.b #$00 : BEQ .north
CMP.b #$01 : BEQ .east
CMP.b #$02 : BEQ .south
@@ -423,6 +425,8 @@ SetTileLookupPosBasedOnDirection:
RTS
}
; =========================================================
print "HandleTileDirections ", pc
HandleTileDirections:
{
@@ -587,8 +591,10 @@ HandleTileDirections:
; db $BE ; + any direction
}
; =========================================================
; Clamp the sprite position to a 16x16 grid
; Slows the game down if you run it too often :(
ClampSpritePositionToGrid:
{
; Check if SprX is already a multiple of 16
@@ -602,6 +608,10 @@ ClampSpritePositionToGrid:
RTS
}
; =========================================================
; Check for the switch_track sprite and move based on the
; state of that sprite.
HandleDynamicSwitchTileDirections:
{
; Find out if the sprite $B0 is in the room
@@ -620,9 +630,7 @@ HandleDynamicSwitchTileDirections:
CMP.b #$02 : BEQ .north_or_south
.east_or_west
LDA SwitchRam : BNE .go_west
LDA #$01 : STA SprSubtype, X
LDA #$03 : STA !SpriteDirection, X
%GotoAction(3) ; Minecart_MoveEast
@@ -651,7 +659,9 @@ HandleDynamicSwitchTileDirections:
RTS
}
; =========================================================
; $00 = flag indicating presence of sprite ID $B0
CheckSpritePresence:
{
PHX
@@ -752,6 +762,7 @@ DragPlayer:
; db -1, 0, 0, 0, -1, 0, -1, 0
}
; =========================================================
CheckForPlayerInput:
{
@@ -775,43 +786,29 @@ CheckForPlayerInput:
LDA $0FA5 : CLC : CMP.b #$B6 : BNE .cant_input
; Check for input from the user (u,d,l,r)
LDY !SpriteDirection, X
LDA $F0 : AND .d_pad_press, Y : STA $00 : AND.b #$08 : BEQ .not_pressing_up
LDA.b #$00 : STA !SpriteDirection, X ; Moving Up
STA SprSubtype, X
%GotoAction(2) ; Minecart_MoveNorth
BRA .return
.not_pressing_up:
LDA $00 : AND.b #$04 : BEQ .not_pressing_down
LDA.b #$01 : STA !SpriteDirection, X
LDA #$02 : STA SprSubtype, X
%GotoAction(4) ; Minecart_MoveSouth
BRA .return
.not_pressing_down
LDA $00 : AND.b #$02 : BEQ .not_pressing_left
LDA.b #$02 : STA !SpriteDirection, X
LDA #$03 : STA SprSubtype, X
%GotoAction(5) ; Minecart_MoveWest
BRA .return
.not_pressing_left
LDA $00 : AND.b #$01 : BEQ .always
LDA.b #$03 : STA !SpriteDirection, X
STA SprSubtype, X
%GotoAction(3) ; Minecart_MoveEast
@@ -819,12 +816,9 @@ CheckForPlayerInput:
.always
; LDA !SpriteDirection, X : CMP.b #$03 : BNE .not_going_right
; ; Default heading in reaction to this tile is going up.
; ; LDA.b #$00 : STA !SpriteDirection, X
; .not_going_right
; ;STZ $0D80, X
.return
@@ -836,26 +830,31 @@ CheckForPlayerInput:
db $0B, $07, $0E, $0D
}
; =========================================================
; Sets carry if player is overlapping the sprite
; Clear carry if player is outside the bounds
CheckIfPlayerIsOn:
{
REP #$20
LDA $22 : CLC : ADC #$0009 : CMP $0FD8 : BCC .OutsideLeft
LDA $22 : SEC : SBC #$0009 : CMP $0FD8 : BCS .OutsideRight
LDA $22 : CLC : ADC #$0009 : CMP $0FD8 : BCC .left
LDA $22 : SEC : SBC #$0009 : CMP $0FD8 : BCS .right
LDA $20 : CLC : ADC #$0012 : CMP $0FDA : BCC .OutsideUp
LDA $20 : SEC : SBC #$0012 : CMP $0FDA : BCS .OutsideDown
LDA $20 : CLC : ADC #$0012 : CMP $0FDA : BCC .up
LDA $20 : SEC : SBC #$0012 : CMP $0FDA : BCS .down
SEP #$21 : RTS ; Return with carry set
.OutsideLeft
.OutsideRight
.OutsideDown
.OutsideUp
.left
.right
.up
.down
SEP #$20
CLC : RTS ; Return with carry cleared
}
; =========================================================
; Draw the portion of the cart which is behind the player
Sprite_Minecart_DrawTop:
{
@@ -945,6 +944,8 @@ Sprite_Minecart_DrawTop:
db $02, $02
}
; =========================================================
; Draw the portion of the cart which is in front of the player
Sprite_Minecart_DrawBottom:
{