Cleanup Minecart
This commit is contained in:
@@ -67,15 +67,13 @@ Right = $03
|
|||||||
Sprite_Minecart_Long:
|
Sprite_Minecart_Long:
|
||||||
{
|
{
|
||||||
PHB : PHK : PLB
|
PHB : PHK : PLB
|
||||||
|
|
||||||
JSR Sprite_Minecart_DrawTop ; Draws the top half behind Link
|
JSR Sprite_Minecart_DrawTop ; Draws the top half behind Link
|
||||||
JSR Sprite_Minecart_DrawBottom ; Draw the bottom half in front of Link
|
JSR Sprite_Minecart_DrawBottom ; Draw the bottom half in front of Link
|
||||||
JSL Sprite_CheckActive ; Check if game is not paused
|
JSL Sprite_CheckActive : BCC .SpriteIsNotActive
|
||||||
BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive
|
JSR Sprite_Minecart_Main
|
||||||
JSR Sprite_Minecart_Main ; Call the main sprite code
|
|
||||||
.SpriteIsNotActive
|
.SpriteIsNotActive
|
||||||
PLB ; Get back the databank we stored previously
|
PLB
|
||||||
RTL ; Go back to original code
|
RTL
|
||||||
}
|
}
|
||||||
|
|
||||||
; =========================================================
|
; =========================================================
|
||||||
@@ -123,7 +121,6 @@ Sprite_Minecart_Prep:
|
|||||||
LDA.b #West : STA !MinecartDirection
|
LDA.b #West : STA !MinecartDirection
|
||||||
LDA.b #Left : STA !SpriteDirection, X
|
LDA.b #Left : STA !SpriteDirection, X
|
||||||
%GotoAction(0) ; Minecart_WaitHoriz
|
%GotoAction(0) ; Minecart_WaitHoriz
|
||||||
|
|
||||||
.done
|
.done
|
||||||
PLB
|
PLB
|
||||||
RTL
|
RTL
|
||||||
@@ -169,7 +166,7 @@ endmacro
|
|||||||
; the cart is facing and sets the velocity of the cart
|
; the cart is facing and sets the velocity of the cart
|
||||||
; based on the direction it is facing.
|
; based on the direction it is facing.
|
||||||
|
|
||||||
HandleToss:
|
Minecart_HandleToss:
|
||||||
{
|
{
|
||||||
; Check links facing direction $2F and apply velocity
|
; Check links facing direction $2F and apply velocity
|
||||||
LDA $2F : CMP.b #$00 : BEQ .toss_north
|
LDA $2F : CMP.b #$00 : BEQ .toss_north
|
||||||
@@ -205,19 +202,19 @@ HandleToss:
|
|||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleLiftAndToss:
|
Minecart_HandleLiftAndToss:
|
||||||
{
|
{
|
||||||
JSR CheckIfPlayerIsOn : BCC .not_tossing
|
JSR CheckIfPlayerIsOn : BCC .not_tossing
|
||||||
LDA.w LinkCarryOrToss : CMP.b #$02 : BNE .not_tossing
|
LDA.w LinkCarryOrToss : CMP.b #$02 : BNE .not_tossing
|
||||||
JSR HandleToss
|
JSR Minecart_HandleToss
|
||||||
.not_tossing
|
.not_tossing
|
||||||
JSL Sprite_CheckIfLifted
|
JSL Sprite_CheckIfLifted
|
||||||
JSL Sprite_Move
|
JSL Sprite_Move
|
||||||
JSR HandleTossedCart
|
JSR Minecart_HandleTossedCart
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
HandleTossedCart:
|
Minecart_HandleTossedCart:
|
||||||
{
|
{
|
||||||
LDA.w SprMiscG, X : BEQ .not_tossed
|
LDA.w SprMiscG, X : BEQ .not_tossed
|
||||||
LDA.w SprHeight, X : BEQ .low_enough
|
LDA.w SprHeight, X : BEQ .low_enough
|
||||||
@@ -282,7 +279,7 @@ Sprite_Minecart_Main:
|
|||||||
|
|
||||||
.not_ready
|
.not_ready
|
||||||
.lifting
|
.lifting
|
||||||
JSR HandleLiftAndToss
|
JSR Minecart_HandleLiftAndToss
|
||||||
JSL ThrownSprite_TileAndSpriteInteraction_long
|
JSL ThrownSprite_TileAndSpriteInteraction_long
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
@@ -309,7 +306,6 @@ Sprite_Minecart_Main:
|
|||||||
LDA #$01 : STA !SpriteDirection, X
|
LDA #$01 : STA !SpriteDirection, X
|
||||||
%GotoAction(4) ; Minecart_MoveSouth
|
%GotoAction(4) ; Minecart_MoveSouth
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
.opposite_direction
|
.opposite_direction
|
||||||
STA.w !MinecartDirection
|
STA.w !MinecartDirection
|
||||||
LDA #$00 : STA !SpriteDirection, X
|
LDA #$00 : STA !SpriteDirection, X
|
||||||
@@ -318,7 +314,7 @@ Sprite_Minecart_Main:
|
|||||||
|
|
||||||
.not_ready
|
.not_ready
|
||||||
.lifting
|
.lifting
|
||||||
JSR HandleLiftAndToss
|
JSR Minecart_HandleLiftAndToss
|
||||||
JSL ThrownSprite_TileAndSpriteInteraction_long
|
JSL ThrownSprite_TileAndSpriteInteraction_long
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
@@ -329,7 +325,6 @@ Sprite_Minecart_Main:
|
|||||||
{
|
{
|
||||||
%PlayAnimation(2,3,8)
|
%PlayAnimation(2,3,8)
|
||||||
%InitMovement()
|
%InitMovement()
|
||||||
|
|
||||||
LDA $36 : BNE .fast_speed
|
LDA $36 : BNE .fast_speed
|
||||||
LDA.b #-!MinecartSpeed : STA.w SprYSpeed, X
|
LDA.b #-!MinecartSpeed : STA.w SprYSpeed, X
|
||||||
JMP .continue
|
JMP .continue
|
||||||
@@ -344,7 +339,6 @@ Sprite_Minecart_Main:
|
|||||||
JSR CheckForPlayerInput
|
JSR CheckForPlayerInput
|
||||||
%HandlePlayerCamera()
|
%HandlePlayerCamera()
|
||||||
%MoveCart()
|
%MoveCart()
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,12 +348,11 @@ Sprite_Minecart_Main:
|
|||||||
{
|
{
|
||||||
%PlayAnimation(0,1,8)
|
%PlayAnimation(0,1,8)
|
||||||
%InitMovement()
|
%InitMovement()
|
||||||
|
|
||||||
LDA $36 : BNE .fast_speed
|
LDA $36 : BNE .fast_speed
|
||||||
LDA.b #!MinecartSpeed : STA $0D50, X
|
LDA.b #!MinecartSpeed : STA $0D50, X
|
||||||
JMP .continue
|
JMP .continue
|
||||||
.fast_speed
|
.fast_speed
|
||||||
LDA.b #!DoubleSpeed : STA $0D50, X
|
LDA.b #!DoubleSpeed : STA.w SprXSpeed, X
|
||||||
.continue
|
.continue
|
||||||
JSL Sprite_MoveHoriz
|
JSL Sprite_MoveHoriz
|
||||||
|
|
||||||
@@ -369,7 +362,6 @@ Sprite_Minecart_Main:
|
|||||||
JSR CheckForPlayerInput
|
JSR CheckForPlayerInput
|
||||||
%HandlePlayerCamera()
|
%HandlePlayerCamera()
|
||||||
%MoveCart()
|
%MoveCart()
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +371,6 @@ Sprite_Minecart_Main:
|
|||||||
{
|
{
|
||||||
%PlayAnimation(2,3,8)
|
%PlayAnimation(2,3,8)
|
||||||
%InitMovement()
|
%InitMovement()
|
||||||
|
|
||||||
LDA $36 : BNE .fast_speed
|
LDA $36 : BNE .fast_speed
|
||||||
LDA.b #!MinecartSpeed : STA.w SprYSpeed, X
|
LDA.b #!MinecartSpeed : STA.w SprYSpeed, X
|
||||||
JMP .continue
|
JMP .continue
|
||||||
@@ -394,7 +385,6 @@ Sprite_Minecart_Main:
|
|||||||
JSR CheckForPlayerInput
|
JSR CheckForPlayerInput
|
||||||
%HandlePlayerCamera()
|
%HandlePlayerCamera()
|
||||||
%MoveCart()
|
%MoveCart()
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,10 +396,10 @@ Sprite_Minecart_Main:
|
|||||||
%InitMovement()
|
%InitMovement()
|
||||||
|
|
||||||
LDA $36 : BNE .fast_speed
|
LDA $36 : BNE .fast_speed
|
||||||
LDA.b #-!MinecartSpeed : STA $0D50, X
|
LDA.b #-!MinecartSpeed : STA.w SprXSpeed, X
|
||||||
JMP .continue
|
JMP .continue
|
||||||
.fast_speed
|
.fast_speed
|
||||||
LDA.b #-!DoubleSpeed : STA $0D50, X
|
LDA.b #-!DoubleSpeed : STA.w SprXSpeed, X
|
||||||
.continue
|
.continue
|
||||||
JSL Sprite_MoveHoriz
|
JSL Sprite_MoveHoriz
|
||||||
|
|
||||||
@@ -419,7 +409,6 @@ Sprite_Minecart_Main:
|
|||||||
JSR CheckForPlayerInput
|
JSR CheckForPlayerInput
|
||||||
%HandlePlayerCamera()
|
%HandlePlayerCamera()
|
||||||
%MoveCart()
|
%MoveCart()
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +418,6 @@ Sprite_Minecart_Main:
|
|||||||
Minecart_Release:
|
Minecart_Release:
|
||||||
{
|
{
|
||||||
%StopCart()
|
%StopCart()
|
||||||
|
|
||||||
LDA.w SprTimerD, X : BNE .not_ready
|
LDA.w SprTimerD, X : BNE .not_ready
|
||||||
LDA #$40 : STA.w SprTimerA, X
|
LDA #$40 : STA.w SprTimerA, X
|
||||||
LDA.w !SpriteDirection, X : CMP.b #$00 : BEQ .vert
|
LDA.w !SpriteDirection, X : CMP.b #$00 : BEQ .vert
|
||||||
@@ -545,15 +533,15 @@ HandleTileDirections:
|
|||||||
JMP .done
|
JMP .done
|
||||||
.check_direction
|
.check_direction
|
||||||
LDA.w SprSubtype, X
|
LDA.w SprSubtype, X
|
||||||
ASL #2 ; Multiply by 4 (shifting left by 2 bits) to offset rows in the lookup table
|
ASL #2 ; Multiply by 4 to offset rows in the lookup table
|
||||||
STA $07 ; Store the action index in $07
|
STA $07 ; Store the action index in $07
|
||||||
|
|
||||||
LDA $0FA5 ; Load the tile type
|
; Subtract $B2 to normalize the tile type to 0 to 3
|
||||||
SEC : SBC.b #$B2 ; Subtract $B2 to normalize the tile type to 0 to 3
|
LDA.w SPRTILE : SEC : SBC.b #$B2
|
||||||
CLC : ADC.w $07 ; Add the action index to the tile type offset to get the composite index
|
; Add action index to tile type offset for the composite index
|
||||||
TAY ; Transfer to Y to use as an offset for the rows
|
; Transfer to Y to use as an offset for the rows
|
||||||
|
CLC : ADC.w $07 : TAY
|
||||||
LDA.w .DirectionTileLookup, Y : TAY
|
LDA.w .DirectionTileLookup, Y : TAY
|
||||||
|
|
||||||
CPY #$01 : BEQ .move_north
|
CPY #$01 : BEQ .move_north
|
||||||
CPY #$02 : BEQ .move_east
|
CPY #$02 : BEQ .move_east
|
||||||
CPY #$03 : BEQ .move_south
|
CPY #$03 : BEQ .move_south
|
||||||
@@ -682,7 +670,6 @@ CheckSpritePresence:
|
|||||||
CPX.b #$00 : BNE .x_loop
|
CPX.b #$00 : BNE .x_loop
|
||||||
.done
|
.done
|
||||||
PLX
|
PLX
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -939,27 +926,18 @@ Sprite_Minecart_DrawBottom:
|
|||||||
RoomTag_ShutterDoorRequiresCart:
|
RoomTag_ShutterDoorRequiresCart:
|
||||||
{
|
{
|
||||||
LDA.w !LinkInCart : BEQ .no_cart
|
LDA.w !LinkInCart : BEQ .no_cart
|
||||||
#_01C49E: REP #$30
|
REP #$30
|
||||||
|
LDX.w #$0000 : CPX.w $0468 : BEQ .exit
|
||||||
#_01C4A0: LDX.w #$0000
|
STZ.w $0468
|
||||||
#_01C4A3: CPX.w $0468
|
STZ.w $068E
|
||||||
#_01C4A6: BEQ .exit
|
STZ.w $0690
|
||||||
|
SEP #$30
|
||||||
#_01C4A8: STZ.w $0468
|
|
||||||
|
|
||||||
#_01C4AB: STZ.w $068E
|
|
||||||
#_01C4AE: STZ.w $0690
|
|
||||||
|
|
||||||
#_01C4B1: SEP #$30
|
|
||||||
|
|
||||||
#_01C4B3: LDA.b #$1B ; SFX3.1B
|
|
||||||
#_01C4B5: STA.w $012F
|
|
||||||
|
|
||||||
#_01C4B8: LDA.b #$05
|
|
||||||
#_01C4BA: STA.b $11
|
|
||||||
|
|
||||||
|
; SFX3.1B
|
||||||
|
LDA.b #$1B : STA.w $012F
|
||||||
|
LDA.b #$05 : STA.b $11
|
||||||
.exit
|
.exit
|
||||||
#_01C4BC: SEP #$30
|
SEP #$30
|
||||||
.no_cart
|
.no_cart
|
||||||
JML $01CC5A
|
JML $01CC5A
|
||||||
}
|
}
|
||||||
@@ -970,8 +948,7 @@ pushpc
|
|||||||
org $01CC08
|
org $01CC08
|
||||||
RoomTag_Holes3:
|
RoomTag_Holes3:
|
||||||
JML RoomTag_ShutterDoorRequiresCart
|
JML RoomTag_ShutterDoorRequiresCart
|
||||||
; #_01CC08: LDA.b #$06
|
; LDA.b #$06 : BRA RoomTag_TriggerHoles
|
||||||
; #_01CC0A: BRA RoomTag_TriggerHoles
|
|
||||||
|
|
||||||
pullpc
|
pullpc
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user