cleanup minecart and switch track

This commit is contained in:
scawful
2024-07-04 15:42:12 -04:00
parent 9f0f17ebf3
commit 3f9fad8c7f
2 changed files with 194 additions and 245 deletions

View File

@@ -248,8 +248,8 @@ HandleTossedCart:
Sprite_Minecart_Main: Sprite_Minecart_Main:
{ {
LDA.w SprAction, X ; Load the SprAction LDA.w SprAction, X
JSL UseImplicitRegIndexedLocalJumpTable ; Goto the SprAction JSL UseImplicitRegIndexedLocalJumpTable
dw Minecart_WaitHoriz ; 0x00 dw Minecart_WaitHoriz ; 0x00
dw Minecart_WaitVert ; 0x01 dw Minecart_WaitVert ; 0x01
@@ -264,8 +264,8 @@ Sprite_Minecart_Main:
Minecart_WaitHoriz: Minecart_WaitHoriz:
{ {
%PlayAnimation(0,1,8) %PlayAnimation(0,1,8)
LDA SprTimerA, X : BNE .not_ready
LDA !LinkCarryOrToss : AND #$03 : BNE .lifting LDA !LinkCarryOrToss : AND #$03 : BNE .lifting
LDA SprTimerA, X : BNE .not_ready
JSR CheckIfPlayerIsOn : BCC .not_ready JSR CheckIfPlayerIsOn : BCC .not_ready
LDA.w SprMiscF, X : BNE .active_cart LDA.w SprMiscF, X : BNE .active_cart
LDA $F4 : AND.b #$80 : BEQ .not_ready ; Check for B button LDA $F4 : AND.b #$80 : BEQ .not_ready ; Check for B button
@@ -291,6 +291,7 @@ Sprite_Minecart_Main:
.not_ready .not_ready
.lifting .lifting
JSR HandleLiftAndToss JSR HandleLiftAndToss
JSL ThrownSprite_TileAndSpriteInteraction_long
RTS RTS
} }
@@ -299,8 +300,8 @@ Sprite_Minecart_Main:
Minecart_WaitVert: Minecart_WaitVert:
{ {
%PlayAnimation(2,3,8) %PlayAnimation(2,3,8)
LDA SprTimerA, X : BNE .not_ready
LDA !LinkCarryOrToss : AND #$03 : BNE .lifting LDA !LinkCarryOrToss : AND #$03 : BNE .lifting
LDA SprTimerA, X : BNE .not_ready
JSR CheckIfPlayerIsOn : BCC .not_ready JSR CheckIfPlayerIsOn : BCC .not_ready
LDA.w SprMiscF, X : BNE .active_cart LDA.w SprMiscF, X : BNE .active_cart
LDA $F4 : AND.b #$80 : BEQ .not_ready ; Check for B button LDA $F4 : AND.b #$80 : BEQ .not_ready ; Check for B button
@@ -326,6 +327,7 @@ Sprite_Minecart_Main:
.not_ready .not_ready
.lifting .lifting
JSR HandleLiftAndToss JSR HandleLiftAndToss
JSL ThrownSprite_TileAndSpriteInteraction_long
RTS RTS
} }
@@ -453,7 +455,6 @@ Sprite_Minecart_Main:
; ========================================================= ; =========================================================
HandleTileDirections: HandleTileDirections:
{ {
LDA SprTimerA, X : BEQ + LDA SprTimerA, X : BEQ +
@@ -616,18 +617,6 @@ HandleTileDirections:
db $00, $02, $00, $04 ; South db $00, $02, $00, $04 ; South
db $03, $01, $00, $00 ; West db $03, $01, $00, $00 ; West
} }
.unused_tile_ids
{
; TL, BL, TR, BR
; db $B2, $B3, $B4, $B5
; db $B0 - Horiz
; db $B1 | Vert
; db $B8 Stop North
; db $B9 Stop South
; db $BA Stop East
; db $BB Stop West
; db $BE + any direction
}
} }
; ========================================================= ; =========================================================
@@ -638,21 +627,17 @@ HandleDynamicSwitchTileDirections:
{ {
; Find out if the sprite $B0 is in the room ; Find out if the sprite $B0 is in the room
JSR CheckSpritePresence : BCC .no_b0 JSR CheckSpritePresence : BCC .no_b0
PHX
PHX : LDA $02 : TAX LDA $02 : TAX
JSL Link_SetupHitBox JSL Link_SetupHitBox
JSL Sprite_SetupHitBox ; X is now the ID of the sprite $B0
; X is now the ID of the sprite $B0
JSL Sprite_SetupHitBox
PLX PLX
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
@@ -662,7 +647,6 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection 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.w SprY, X
RTS RTS
.go_west .go_west
@@ -670,7 +654,6 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection 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.w SprY, X
RTS RTS
.north_or_south .north_or_south
@@ -679,7 +662,6 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection STA.w !MinecartDirection
STA !SpriteDirection, X STA !SpriteDirection, X
%GotoAction(2) ; Minecart_MoveNorth %GotoAction(2) ; Minecart_MoveNorth
; LDA SprX, X : AND #$F8 : STA.w SprX, X
RTS RTS
.go_south .go_south
@@ -687,10 +669,7 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection 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.w SprX, X
RTS RTS
} }
; ========================================================= ; =========================================================
@@ -789,18 +768,17 @@ CheckIfPlayerIsOn:
REP #$20 REP #$20
LDA $22 : CLC : ADC #$0009 : CMP $0FD8 : BCC .left LDA $22 : CLC : ADC #$0009 : CMP $0FD8 : BCC .left
LDA $22 : SEC : SBC #$0009 : CMP $0FD8 : BCS .right LDA $22 : SEC : SBC #$0009 : CMP $0FD8 : BCS .right
LDA $20 : CLC : ADC #$0012 : CMP $0FDA : BCC .up LDA $20 : CLC : ADC #$0012 : CMP $0FDA : BCC .up
LDA $20 : SEC : SBC #$0012 : CMP $0FDA : BCS .down LDA $20 : SEC : SBC #$0012 : CMP $0FDA : BCS .down
SEP #$21
SEP #$21 : RTS ; Return with carry set RTS ; Return with carry set
.left .left
.right .right
.up .up
.down .down
SEP #$20 SEP #$20
CLC : RTS ; Return with carry cleared CLC
RTS ; Return with carry cleared
} }
@@ -852,19 +830,16 @@ FollowerDraw_CalculateOAMCoords:
LDA.b $02 : STA.b ($90),Y LDA.b $02 : STA.b ($90),Y
INY INY
CLC : ADC.w #$0080 CLC : ADC.w #$0080 : CMP.w #$0180 : BCS .off_screen
CMP.w #$0180 : BCS .off_screen
LDA.b $02 : AND.w #$0100 : STA.b $74 LDA.b $02 : AND.w #$0100 : STA.b $74
LDA.b $00 : STA.b ($90),Y LDA.b $00 : STA.b ($90),Y
CLC : ADC.w #$0010 CLC : ADC.w #$0010 : CMP.w #$0100 : BCC .on_screen
CMP.w #$0100 : BCC .on_screen
.off_screen: .off_screen:
LDA.w #$00F0 : STA.b ($90),Y LDA.w #$00F0 : STA.b ($90),Y
.on_screen: .on_screen:
SEP #$20 SEP #$20
INY INY
RTS RTS

View File

@@ -3,7 +3,7 @@
; ========================================================= ; =========================================================
!SPRID = $B0 ; The sprite ID you are overwriting (HEX) !SPRID = $B0 ; The sprite ID you are overwriting (HEX)
!NbrTiles = 04 ; Number of tiles used in a frame !NbrTiles = 02 ; Number of tiles used in a frame
!Harmless = 00 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless !Harmless = 00 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless
!HVelocity = 00 ; Is your sprite going super fast? put 01 if it is !HVelocity = 00 ; Is your sprite going super fast? put 01 if it is
!Health = 01 ; Number of Health the sprite have !Health = 01 ; Number of Health the sprite have
@@ -13,7 +13,7 @@
!SmallShadow = 00 ; 01 = small shadow, 00 = no shadow !SmallShadow = 00 ; 01 = small shadow, 00 = no shadow
!Shadow = 00 ; 00 = don't draw shadow, 01 = draw a shadow !Shadow = 00 ; 00 = don't draw shadow, 01 = draw a shadow
!Palette = 00 ; Unused in this template (can be 0 to 7) !Palette = 00 ; Unused in this template (can be 0 to 7)
!Hitbox = $1C ; 00 to 31, can be viewed in sprite draw tool !Hitbox = 00 ; 00 to 31, can be viewed in sprite draw tool
!Persist = 01 ; 01 = your sprite continue to live offscreen !Persist = 01 ; 01 = your sprite continue to live offscreen
!Statis = 00 ; 00 = is sprite is alive?, (kill all enemies room) !Statis = 00 ; 00 = is sprite is alive?, (kill all enemies room)
!CollisionLayer = 00 ; 01 = will check both layer for collision !CollisionLayer = 00 ; 01 = will check both layer for collision
@@ -87,11 +87,9 @@ Sprite_RotatingTrack_Main:
; 00 = TopLeft -> TopRight ; 00 = TopLeft -> TopRight
TopLeftToTopRight: TopLeftToTopRight:
{ {
LDA SwitchRam : BEQ part2 LDA SwitchRam : BNE part2
%PlayAnimation(0,0,4) %PlayAnimation(0,0,4)
part2: part2:
%PlayAnimation(1,1,4) %PlayAnimation(1,1,4)
RTS RTS
} }
@@ -101,10 +99,8 @@ Sprite_RotatingTrack_Main:
TopRightToBottomRight: TopRightToBottomRight:
{ {
LDA SwitchRam : BNE part2_a LDA SwitchRam : BNE part2_a
%PlayAnimation(1,1,4) %PlayAnimation(1,1,4)
part2_a: part2_a:
%PlayAnimation(2,2,4) %PlayAnimation(2,2,4)
RTS RTS
} }
@@ -114,10 +110,8 @@ Sprite_RotatingTrack_Main:
BottomRightToBottomLeft: BottomRightToBottomLeft:
{ {
LDA SwitchRam : BNE part2_b LDA SwitchRam : BNE part2_b
%PlayAnimation(2,2,4) %PlayAnimation(2,2,4)
part2_b: part2_b:
%PlayAnimation(3,3,4) %PlayAnimation(3,3,4)
RTS RTS
} }
@@ -127,11 +121,8 @@ Sprite_RotatingTrack_Main:
BottomLeftToTopLeft: BottomLeftToTopLeft:
{ {
LDA SwitchRam : BNE part2_c LDA SwitchRam : BNE part2_c
%PlayAnimation(3,3,4) %PlayAnimation(3,3,4)
part2_c: part2_c:
%PlayAnimation(0,0,4) %PlayAnimation(0,0,4)
RTS RTS
} }
@@ -141,10 +132,8 @@ Sprite_RotatingTrack_Main:
TopRightToTopLeft: TopRightToTopLeft:
{ {
LDA SwitchRam : BNE part2_d LDA SwitchRam : BNE part2_d
%StartOnFrame(1) %StartOnFrame(1)
%PlayAnimation(1,1,4) %PlayAnimation(1,1,4)
part2_d: part2_d:
%StartOnFrame(0) %StartOnFrame(0)
%PlayAnimation(0,0,4) %PlayAnimation(0,0,4)
@@ -178,10 +167,10 @@ Sprite_RotatingTrack_Draw:
REP #$20 REP #$20
LDA $00 : CLC : ADC .x_offsets, X : STA ($90), Y LDA $00 : STA ($90), Y
AND.w #$0100 : STA $0E AND.w #$0100 : STA $0E
INY INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y LDA $02 : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100 CLC : ADC #$0010 : CMP.w #$0100
SEP #$20 SEP #$20
BCC .on_screen_y BCC .on_screen_y
@@ -200,7 +189,7 @@ Sprite_RotatingTrack_Draw:
TYA : LSR #2 : TAY TYA : LSR #2 : TAY
LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer LDA.b #$02 : ORA $0F : STA ($92), Y ; store size in oam buffer
PLY : INY PLY : INY
@@ -215,16 +204,6 @@ Sprite_RotatingTrack_Draw:
db $00, $01, $02, $03 db $00, $01, $02, $03
.nbr_of_tiles .nbr_of_tiles
db 0, 0, 0, 0 db 0, 0, 0, 0
.x_offsets
dw 0
dw 0
dw 0
dw 0
.y_offsets
dw 0
dw 0
dw 0
dw 0
.chr .chr
db $44 db $44
db $44 db $44
@@ -235,9 +214,4 @@ Sprite_RotatingTrack_Draw:
db $3D db $3D
db $FD db $FD
db $BD db $BD
.sizes
db $02
db $02
db $02
db $02
} }