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:
{
LDA.w SprAction, X ; Load the SprAction
JSL UseImplicitRegIndexedLocalJumpTable ; Goto the SprAction
LDA.w SprAction, X
JSL UseImplicitRegIndexedLocalJumpTable
dw Minecart_WaitHoriz ; 0x00
dw Minecart_WaitVert ; 0x01
@@ -264,8 +264,8 @@ Sprite_Minecart_Main:
Minecart_WaitHoriz:
{
%PlayAnimation(0,1,8)
LDA SprTimerA, X : BNE .not_ready
LDA !LinkCarryOrToss : AND #$03 : BNE .lifting
LDA SprTimerA, X : BNE .not_ready
JSR CheckIfPlayerIsOn : BCC .not_ready
LDA.w SprMiscF, X : BNE .active_cart
LDA $F4 : AND.b #$80 : BEQ .not_ready ; Check for B button
@@ -291,6 +291,7 @@ Sprite_Minecart_Main:
.not_ready
.lifting
JSR HandleLiftAndToss
JSL ThrownSprite_TileAndSpriteInteraction_long
RTS
}
@@ -299,8 +300,8 @@ Sprite_Minecart_Main:
Minecart_WaitVert:
{
%PlayAnimation(2,3,8)
LDA SprTimerA, X : BNE .not_ready
LDA !LinkCarryOrToss : AND #$03 : BNE .lifting
LDA SprTimerA, X : BNE .not_ready
JSR CheckIfPlayerIsOn : BCC .not_ready
LDA.w SprMiscF, X : BNE .active_cart
LDA $F4 : AND.b #$80 : BEQ .not_ready ; Check for B button
@@ -326,6 +327,7 @@ Sprite_Minecart_Main:
.not_ready
.lifting
JSR HandleLiftAndToss
JSL ThrownSprite_TileAndSpriteInteraction_long
RTS
}
@@ -453,7 +455,6 @@ Sprite_Minecart_Main:
; =========================================================
HandleTileDirections:
{
LDA SprTimerA, X : BEQ +
@@ -616,18 +617,6 @@ HandleTileDirections:
db $00, $02, $00, $04 ; South
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
JSR CheckSpritePresence : BCC .no_b0
PHX : LDA $02 : TAX
PHX
LDA $02 : TAX
JSL Link_SetupHitBox
; X is now the ID of the sprite $B0
JSL Sprite_SetupHitBox
JSL Sprite_SetupHitBox ; X is now the ID of the sprite $B0
PLX
JSL CheckIfHitBoxesOverlap : BCC .no_b0
LDA !MinecartDirection : CMP.b #$00 : BEQ .east_or_west
CMP.b #$01 : BEQ .north_or_south
CMP.b #$02 : BEQ .east_or_west
CMP.b #$03 : BEQ .north_or_south
.no_b0
RTS
@@ -662,7 +647,6 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection
LDA #$03 : STA !SpriteDirection, X
%GotoAction(3) ; Minecart_MoveEast
; LDA SprY, X : AND #$F8 : STA.w SprY, X
RTS
.go_west
@@ -670,7 +654,6 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection
LDA #$02 : STA !SpriteDirection, X
%GotoAction(5) ; Minecart_MoveWest
; LDA SprY, X : AND #$F8 : STA.w SprY, X
RTS
.north_or_south
@@ -679,7 +662,6 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection
STA !SpriteDirection, X
%GotoAction(2) ; Minecart_MoveNorth
; LDA SprX, X : AND #$F8 : STA.w SprX, X
RTS
.go_south
@@ -687,10 +669,7 @@ HandleDynamicSwitchTileDirections:
STA.w !MinecartDirection
LDA #$01 : STA !SpriteDirection, X
%GotoAction(4) ; Minecart_MoveSouth
; LDA SprX, X : AND #$F8 : STA.w SprX, X
RTS
}
; =========================================================
@@ -789,18 +768,17 @@ CheckIfPlayerIsOn:
REP #$20
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 .up
LDA $20 : SEC : SBC #$0012 : CMP $0FDA : BCS .down
SEP #$21 : RTS ; Return with carry set
SEP #$21
RTS ; Return with carry set
.left
.right
.up
.down
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
INY
CLC : ADC.w #$0080
CMP.w #$0180 : BCS .off_screen
CLC : ADC.w #$0080 : CMP.w #$0180 : BCS .off_screen
LDA.b $02 : AND.w #$0100 : STA.b $74
LDA.b $00 : STA.b ($90),Y
CLC : ADC.w #$0010
CMP.w #$0100 : BCC .on_screen
CLC : ADC.w #$0010 : CMP.w #$0100 : BCC .on_screen
.off_screen:
.off_screen:
LDA.w #$00F0 : STA.b ($90),Y
.on_screen:
.on_screen:
SEP #$20
INY
RTS

View File

@@ -3,7 +3,7 @@
; =========================================================
!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
!HVelocity = 00 ; Is your sprite going super fast? put 01 if it is
!Health = 01 ; Number of Health the sprite have
@@ -13,7 +13,7 @@
!SmallShadow = 00 ; 01 = small shadow, 00 = no shadow
!Shadow = 00 ; 00 = don't draw shadow, 01 = draw a shadow
!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
!Statis = 00 ; 00 = is sprite is alive?, (kill all enemies room)
!CollisionLayer = 00 ; 01 = will check both layer for collision
@@ -87,11 +87,9 @@ Sprite_RotatingTrack_Main:
; 00 = TopLeft -> TopRight
TopLeftToTopRight:
{
LDA SwitchRam : BEQ part2
LDA SwitchRam : BNE part2
%PlayAnimation(0,0,4)
part2:
%PlayAnimation(1,1,4)
RTS
}
@@ -101,10 +99,8 @@ Sprite_RotatingTrack_Main:
TopRightToBottomRight:
{
LDA SwitchRam : BNE part2_a
%PlayAnimation(1,1,4)
part2_a:
%PlayAnimation(2,2,4)
RTS
}
@@ -114,10 +110,8 @@ Sprite_RotatingTrack_Main:
BottomRightToBottomLeft:
{
LDA SwitchRam : BNE part2_b
%PlayAnimation(2,2,4)
part2_b:
%PlayAnimation(3,3,4)
RTS
}
@@ -127,11 +121,8 @@ Sprite_RotatingTrack_Main:
BottomLeftToTopLeft:
{
LDA SwitchRam : BNE part2_c
%PlayAnimation(3,3,4)
part2_c:
%PlayAnimation(0,0,4)
RTS
}
@@ -141,10 +132,8 @@ Sprite_RotatingTrack_Main:
TopRightToTopLeft:
{
LDA SwitchRam : BNE part2_d
%StartOnFrame(1)
%PlayAnimation(1,1,4)
part2_d:
%StartOnFrame(0)
%PlayAnimation(0,0,4)
@@ -178,10 +167,10 @@ Sprite_RotatingTrack_Draw:
REP #$20
LDA $00 : CLC : ADC .x_offsets, X : STA ($90), Y
LDA $00 : STA ($90), Y
AND.w #$0100 : STA $0E
INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y
LDA $02 : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100
SEP #$20
BCC .on_screen_y
@@ -200,7 +189,7 @@ Sprite_RotatingTrack_Draw:
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
@@ -215,16 +204,6 @@ Sprite_RotatingTrack_Draw:
db $00, $01, $02, $03
.nbr_of_tiles
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
db $44
db $44
@@ -235,9 +214,4 @@ Sprite_RotatingTrack_Draw:
db $3D
db $FD
db $BD
.sizes
db $02
db $02
db $02
db $02
}