update minecart directional logic
This commit is contained in:
@@ -455,10 +455,6 @@ Sprite_Minecart_Main:
|
|||||||
|
|
||||||
; =========================================================
|
; =========================================================
|
||||||
|
|
||||||
North = $00
|
|
||||||
East = $01
|
|
||||||
South = $02
|
|
||||||
West = $03
|
|
||||||
|
|
||||||
HandleTileDirections:
|
HandleTileDirections:
|
||||||
{
|
{
|
||||||
@@ -516,13 +512,13 @@ HandleTileDirections:
|
|||||||
.stop_east
|
.stop_east
|
||||||
; Set the new direction to east and flip the cart's orientation
|
; Set the new direction to east and flip the cart's orientation
|
||||||
LDA.b #West : STA SprSubtype, X : STA.w !MinecartDirection
|
LDA.b #West : STA SprSubtype, X : STA.w !MinecartDirection
|
||||||
LDA #$03 : STA !SpriteDirection, X
|
LDA #$02 : STA !SpriteDirection, X
|
||||||
JMP .go_horiz
|
JMP .go_horiz
|
||||||
|
|
||||||
.stop_west
|
.stop_west
|
||||||
; Set the new direction to west and flip the cart's orientation
|
; Set the new direction to west and flip the cart's orientation
|
||||||
LDA.b #East : STA SprSubtype, X : STA.w !MinecartDirection
|
LDA.b #East : STA SprSubtype, X : STA.w !MinecartDirection
|
||||||
LDA #$02 : STA !SpriteDirection, X
|
LDA #$03 : STA !SpriteDirection, X
|
||||||
|
|
||||||
; -----------------------------------------------
|
; -----------------------------------------------
|
||||||
.go_horiz
|
.go_horiz
|
||||||
@@ -546,9 +542,11 @@ HandleTileDirections:
|
|||||||
; Are we moving left or right?
|
; Are we moving left or right?
|
||||||
LDA SprSubtype, X : CMP.b #$03 : BEQ .inverse_horiz_velocity
|
LDA SprSubtype, X : CMP.b #$03 : BEQ .inverse_horiz_velocity
|
||||||
LDA.b #!MinecartSpeed : STA SprXSpeed, X
|
LDA.b #!MinecartSpeed : STA SprXSpeed, X
|
||||||
|
LDA.b #East : STA !MinecartDirection
|
||||||
JMP .done
|
JMP .done
|
||||||
.inverse_horiz_velocity
|
.inverse_horiz_velocity
|
||||||
LDA.b #-!MinecartSpeed : STA SprXSpeed, X
|
LDA.b #-!MinecartSpeed : STA SprXSpeed, X
|
||||||
|
LDA.b #West : STA !MinecartDirection
|
||||||
JMP .done
|
JMP .done
|
||||||
.vert
|
.vert
|
||||||
; Are we moving up or down?
|
; Are we moving up or down?
|
||||||
@@ -651,9 +649,9 @@ HandleDynamicSwitchTileDirections:
|
|||||||
JSL CheckIfHitBoxesOverlap : BCC .no_b0
|
JSL CheckIfHitBoxesOverlap : BCC .no_b0
|
||||||
|
|
||||||
LDA !MinecartDirection : CMP.b #$00 : BEQ .east_or_west
|
LDA !MinecartDirection : CMP.b #$00 : BEQ .east_or_west
|
||||||
CMP.b #$01 : BEQ .north_or_south
|
CMP.b #$01 : BEQ .north_or_south
|
||||||
CMP.b #$02 : BEQ .east_or_west
|
CMP.b #$02 : BEQ .east_or_west
|
||||||
CMP.b #$03 : BEQ .north_or_south
|
CMP.b #$03 : BEQ .north_or_south
|
||||||
|
|
||||||
.no_b0
|
.no_b0
|
||||||
RTS
|
RTS
|
||||||
@@ -661,31 +659,35 @@ HandleDynamicSwitchTileDirections:
|
|||||||
.east_or_west
|
.east_or_west
|
||||||
LDA SwitchRam : BNE .go_west
|
LDA SwitchRam : BNE .go_west
|
||||||
LDA #$01 : STA SprSubtype, X
|
LDA #$01 : STA SprSubtype, X
|
||||||
|
STA.w !MinecartDirection
|
||||||
LDA #$03 : STA !SpriteDirection, X
|
LDA #$03 : STA !SpriteDirection, X
|
||||||
%GotoAction(3) ; Minecart_MoveEast
|
%GotoAction(3) ; Minecart_MoveEast
|
||||||
LDA SprY, X : AND #$F8 : STA SprY, X
|
; LDA SprY, X : AND #$F8 : STA SprY, X
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
.go_west
|
.go_west
|
||||||
LDA #$03 : STA SprSubtype, X
|
LDA #$03 : STA SprSubtype, X
|
||||||
|
STA.w !MinecartDirection
|
||||||
LDA #$02 : STA !SpriteDirection, X
|
LDA #$02 : STA !SpriteDirection, X
|
||||||
%GotoAction(5) ; Minecart_MoveWest
|
%GotoAction(5) ; Minecart_MoveWest
|
||||||
LDA SprY, X : AND #$F8 : STA SprY, X
|
; LDA SprY, X : AND #$F8 : STA SprY, X
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
.north_or_south
|
.north_or_south
|
||||||
LDA SwitchRam : BEQ .go_south
|
LDA SwitchRam : BNE .go_south
|
||||||
LDA #$00 : STA SprSubtype, X
|
LDA #$00 : STA SprSubtype, X
|
||||||
|
STA.w !MinecartDirection
|
||||||
STA !SpriteDirection, X
|
STA !SpriteDirection, X
|
||||||
%GotoAction(2) ; Minecart_MoveNorth
|
%GotoAction(2) ; Minecart_MoveNorth
|
||||||
LDA SprX, X : AND #$F8 : STA SprX, X
|
; LDA SprX, X : AND #$F8 : STA SprX, X
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
.go_south
|
.go_south
|
||||||
LDA #$02 : STA SprSubtype, X
|
LDA #$02 : STA SprSubtype, X
|
||||||
|
STA.w !MinecartDirection
|
||||||
LDA #$01 : STA !SpriteDirection, X
|
LDA #$01 : STA !SpriteDirection, X
|
||||||
%GotoAction(4) ; Minecart_MoveSouth
|
%GotoAction(4) ; Minecart_MoveSouth
|
||||||
LDA SprX, X : AND #$F8 : STA SprX, X
|
; LDA SprX, X : AND #$F8 : STA SprX, X
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
|
||||||
@@ -726,45 +728,53 @@ CheckSpritePresence:
|
|||||||
|
|
||||||
CheckForPlayerInput:
|
CheckForPlayerInput:
|
||||||
{
|
{
|
||||||
; Setup Minecart position to look for tile IDs
|
; Setup Minecart position to look for tile IDs
|
||||||
LDA.w SprY, X : AND #$F8 : STA.b $00 : LDA.w SprYH, X : STA.b $01
|
LDA.w SprY, X : AND #$F8 : STA.b $00 : LDA.w SprYH, X : STA.b $01
|
||||||
LDA.w SprX, X : AND #$F8 : STA.b $02 : LDA.w SprXH, X : STA.b $03
|
LDA.w SprX, X : AND #$F8 : STA.b $02 : LDA.w SprXH, X : STA.b $03
|
||||||
|
|
||||||
; Fetch tile attributes based on current coordinates
|
; Fetch tile attributes based on current coordinates
|
||||||
LDA.b #$00 : JSL Sprite_GetTileAttr
|
LDA.b #$00 : JSL Sprite_GetTileAttr
|
||||||
|
|
||||||
; Load the tile index
|
; Load the tile index
|
||||||
LDA $0FA5 : CLC : CMP.b #$B6 : BNE .cant_input
|
LDA $0FA5 : CLC : CMP.b #$B6 : BNE .cant_input
|
||||||
|
|
||||||
; Check for input from the user (u,d,l,r)
|
; Check for input from the user (u,d,l,r)
|
||||||
LDY !SpriteDirection, X
|
LDY !SpriteDirection, X
|
||||||
LDA $F0 : AND .d_pad_press, Y : STA $00 : AND.b #$08 : BEQ .not_pressing_up
|
LDA $F0 : AND .d_pad_press, Y : STA $00 : AND.b #$08 : BEQ .not_pressing_up
|
||||||
LDA.b #$00 : STA !SpriteDirection, X ; Moving Up
|
LDA.b #$00 : STA !SpriteDirection, X ; Moving Up
|
||||||
STA SprSubtype, X
|
|
||||||
%GotoAction(2) ; Minecart_MoveNorth
|
|
||||||
BRA .return
|
|
||||||
|
|
||||||
.not_pressing_up:
|
LDA.b #North : STA !MinecartDirection
|
||||||
LDA $00 : AND.b #$04 : BEQ .not_pressing_down
|
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.b #$01 : STA !SpriteDirection, X
|
||||||
LDA #$02 : STA SprSubtype, X
|
|
||||||
|
LDA.b #South : STA !MinecartDirection
|
||||||
|
STA SprSubtype, X
|
||||||
%GotoAction(4) ; Minecart_MoveSouth
|
%GotoAction(4) ; Minecart_MoveSouth
|
||||||
BRA .return
|
BRA .return
|
||||||
|
|
||||||
.not_pressing_down
|
.not_pressing_down
|
||||||
LDA $00 : AND.b #$02 : BEQ .not_pressing_left
|
LDA $00 : AND.b #$02 : BEQ .not_pressing_left
|
||||||
LDA.b #$02 : STA !SpriteDirection, X
|
LDA.b #$02 : STA !SpriteDirection, X
|
||||||
LDA #$03 : STA SprSubtype, X
|
|
||||||
|
LDA.b #West : STA !MinecartDirection
|
||||||
|
STA SprSubtype, X
|
||||||
%GotoAction(5) ; Minecart_MoveWest
|
%GotoAction(5) ; Minecart_MoveWest
|
||||||
BRA .return
|
BRA .return
|
||||||
|
|
||||||
.not_pressing_left
|
.not_pressing_left
|
||||||
LDA $00 : AND.b #$01 : BEQ .always
|
LDA $00 : AND.b #$01 : BEQ .always
|
||||||
LDA.b #$03 : STA !SpriteDirection, X
|
LDA.b #$03 : STA !SpriteDirection, X
|
||||||
STA SprSubtype, X
|
|
||||||
|
LDA.b #East : STA !MinecartDirection
|
||||||
|
STA SprSubtype, X
|
||||||
%GotoAction(3) ; Minecart_MoveEast
|
%GotoAction(3) ; Minecart_MoveEast
|
||||||
|
|
||||||
.always
|
.always
|
||||||
|
|
||||||
; LDA !SpriteDirection, X : CMP.b #$03 : BNE .not_going_right
|
; LDA !SpriteDirection, X : CMP.b #$03 : BNE .not_going_right
|
||||||
; ; Default heading in reaction to this tile is going up.
|
; ; Default heading in reaction to this tile is going up.
|
||||||
|
|||||||
Reference in New Issue
Block a user