Changed the switch tracks to allow for more than just one switch
This commit is contained in:
@@ -127,8 +127,6 @@ Sprite_Minecart_Long:
|
|||||||
{
|
{
|
||||||
PHB : PHK : PLB
|
PHB : PHK : PLB
|
||||||
|
|
||||||
print "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: ", pc
|
|
||||||
|
|
||||||
JSR Sprite_Minecart_DrawTop ; Draw behind Link
|
JSR Sprite_Minecart_DrawTop ; Draw behind Link
|
||||||
JSR Sprite_Minecart_DrawBottom ; Draw in front of Link
|
JSR Sprite_Minecart_DrawBottom ; Draw in front of Link
|
||||||
|
|
||||||
@@ -976,30 +974,35 @@ CheckForCornerTiles:
|
|||||||
HandleDynamicSwitchTileDirections:
|
HandleDynamicSwitchTileDirections:
|
||||||
{
|
{
|
||||||
; Check for the switch tile.
|
; Check for the switch tile.
|
||||||
LDA.w SPRTILE : CMP.b #$BF : BEQ .onSwitchTile
|
LDA.w SPRTILE : CMP.b #$D0 : BEQ .onSwitchTile
|
||||||
|
CMP.b #$D1 : BEQ .onSwitchTile
|
||||||
|
CMP.b #$D2 : BEQ .onSwitchTile
|
||||||
|
CMP.b #$D3 : BEQ .onSwitchTile
|
||||||
CLC
|
CLC
|
||||||
RTS
|
RTS
|
||||||
.onSwitchTile
|
.onSwitchTile
|
||||||
|
|
||||||
; Find out if the sprite $B0 is in the room.
|
; Find out if the sprite $B0 is in the room and if we are
|
||||||
JSR CheckSpritePresence : BCS .B0Present
|
; currently touching it.
|
||||||
|
JSR CheckTrackSpritePresence : BCS .B0Present
|
||||||
CLC
|
CLC
|
||||||
RTS
|
RTS
|
||||||
.B0Present
|
.B0Present
|
||||||
|
|
||||||
LDA.w SprMiscB, X
|
LDA.w SprMiscB, X
|
||||||
ASL #3 ; Multiply by 8 to offset rows in the lookup table
|
ASL #3 ; Multiply by 8 to offset rows in the lookup table
|
||||||
STA.b $07 ; Store the action index in $07
|
STA.b $07 ; Store the action index in $07
|
||||||
|
|
||||||
; Get the type (TL, BL, TR, BL) of the track by taking the subtype and
|
; Get the subtype of the track so that we can get its on/off state.
|
||||||
; cutting out the extra data. Then x2 so we get the correct data from
|
LDA.w SprSubtype, Y : TAY
|
||||||
; the table.
|
|
||||||
LDY.b $04
|
; Normalize the tile data and get the type of track (TL, BL, TR, BR) and
|
||||||
LDA.w SprSubtype, Y : AND.b #$18 : LSR #2
|
; x2 so that we can read the correct column in the table.
|
||||||
|
LDA.w SPRTILE : SEC : SBC.b #$D0 : ASL
|
||||||
|
|
||||||
; Add the current direction and the state of the switch to determine
|
; Add the current direction and the state of the switch to determine
|
||||||
; which direction we should go next.
|
; which direction we should go next.
|
||||||
CLC : ADC.b SwitchRam : CLC : ADC.b $07 : TAY
|
CLC : ADC.w SwitchRam, Y : CLC : ADC.b $07 : TAY
|
||||||
LDA.w .DirectionTileLookup, Y
|
LDA.w .DirectionTileLookup, Y
|
||||||
CMP.b #$01 : BEQ .move_north
|
CMP.b #$01 : BEQ .move_north
|
||||||
CMP.b #$02 : BEQ .move_east
|
CMP.b #$02 : BEQ .move_east
|
||||||
@@ -1047,10 +1050,11 @@ HandleDynamicSwitchTileDirections:
|
|||||||
db $03, $00, $01, $03, $00, $00, $00, $01 ; West
|
db $03, $00, $01, $03, $00, $00, $00, $01 ; West
|
||||||
}
|
}
|
||||||
|
|
||||||
; TL turns into TR when on.
|
; $D0 TL turns into TR when on.
|
||||||
; TR turns into BR when on.
|
; $D1 BL turns into TL when on.
|
||||||
; BR turns into BL when on.
|
; $D2 TR turns into BR when on.
|
||||||
; BL turns into TL when on.
|
; $D3 BR turns into BL when on.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
; Unused?
|
; Unused?
|
||||||
@@ -1114,22 +1118,30 @@ RoundCoords:
|
|||||||
|
|
||||||
; $04 = sprite index of sprite ID $B0
|
; $04 = sprite index of sprite ID $B0
|
||||||
; SEC if sprite is present.
|
; SEC if sprite is present.
|
||||||
CheckSpritePresence:
|
CheckTrackSpritePresence:
|
||||||
{
|
{
|
||||||
PHX
|
LDY.b #$10
|
||||||
CLC ; Assume sprite ID $B0 is not present
|
.loop
|
||||||
LDX.b #$10
|
DEY
|
||||||
.x_loop
|
; Check if the sprite is $B0
|
||||||
DEX
|
LDA.w $0E20, Y : CMP.b #$B0 : BNE .not_b0
|
||||||
LDA $0E20, X : CMP.b #$B0 : BNE .not_b0
|
; Check if the high bytes of the coordinates match.
|
||||||
SEC ; Set flag indicating sprite ID $B0 is present
|
LDA.w SprYH, X : CMP.w SprYH, Y : BNE .not_b0
|
||||||
STX.w $04
|
LDA.w SprXH, X : CMP.w SprXH, Y : BNE .not_b0
|
||||||
BRA .done
|
; Check if the low bytes match but round the cart's coordinates.
|
||||||
|
; Offset the Y by 8 so that we match the cart
|
||||||
|
LDA.w SprY, X : CLC : ADC.b #$04 : AND.b #$F8 : CLC : ADC.b #$08
|
||||||
|
CMP.w SprY, Y : BNE .not_b0
|
||||||
|
LDA.w SprX, X : CLC : ADC.b #$04 : AND.b #$F8
|
||||||
|
CMP.w SprX, Y : BNE .not_b0
|
||||||
|
STY.b $04
|
||||||
|
SEC ; Set flag indicating sprite ID $B0 is present.
|
||||||
|
BRA .done
|
||||||
.not_b0
|
.not_b0
|
||||||
CPX.b #$00 : BNE .x_loop
|
CPY.b #$00 : BNE .loop
|
||||||
|
CLC ; Assume sprite ID $B0 is not present
|
||||||
|
|
||||||
.done
|
.done
|
||||||
PLX
|
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,11 @@ Sprite_LeverSwitch_Prep:
|
|||||||
PHB : PHK : PLB
|
PHB : PHK : PLB
|
||||||
|
|
||||||
LDA.b #$00 : STA.w SprDefl, X
|
LDA.b #$00 : STA.w SprDefl, X
|
||||||
LDA.w SwitchRam : STA.w SprAction, X : STA.w SprFrame, X
|
|
||||||
|
; Get the subtype of the switch so that we can get its on/off state.
|
||||||
|
LDA.w SprSubtype, X : TAY
|
||||||
|
|
||||||
|
LDA.w SwitchRam, Y : STA.w SprAction, X : STA.w SprFrame, X
|
||||||
LDA.b #$00 : STA.w SprTileDie, X
|
LDA.b #$00 : STA.w SprTileDie, X
|
||||||
STZ.w SprBulletproof, X
|
STZ.w SprBulletproof, X
|
||||||
|
|
||||||
@@ -81,8 +85,11 @@ Sprite_LeverSwitch_Main:
|
|||||||
JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage
|
JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage
|
||||||
LDA #$25 : STA $012F
|
LDA #$25 : STA $012F
|
||||||
|
|
||||||
|
; Get the subtype of the switch so that we can get its on/off state.
|
||||||
|
LDA.w SprSubtype, X : TAY
|
||||||
|
|
||||||
; Turn the switch on.
|
; Turn the switch on.
|
||||||
LDA #$01 : STA.b SwitchRam
|
LDA #$01 : STA.w SwitchRam, Y
|
||||||
LDA #$10 : STA.w SprTimerA, X
|
LDA #$10 : STA.w SprTimerA, X
|
||||||
%GotoAction(1)
|
%GotoAction(1)
|
||||||
.NoDamage
|
.NoDamage
|
||||||
@@ -95,9 +102,12 @@ Sprite_LeverSwitch_Main:
|
|||||||
LDA.w SprTimerA, X : BNE .NoDamage
|
LDA.w SprTimerA, X : BNE .NoDamage
|
||||||
JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage
|
JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage
|
||||||
LDA #$25 : STA $012F
|
LDA #$25 : STA $012F
|
||||||
|
|
||||||
|
; Get the subtype of the switch so that we can get its on/off state.
|
||||||
|
LDA.w SprSubtype, X : TAY
|
||||||
|
|
||||||
; Turn the switch off.
|
; Turn the switch off.
|
||||||
STZ.w SwitchRam
|
LDA #$00 : STA.w SwitchRam, Y
|
||||||
LDA #$10 : STA.w SprTimerA, X
|
LDA #$10 : STA.w SprTimerA, X
|
||||||
%GotoAction(0)
|
%GotoAction(0)
|
||||||
.NoDamage
|
.NoDamage
|
||||||
|
|||||||
@@ -50,7 +50,20 @@ Sprite_RotatingTrack_Prep:
|
|||||||
{
|
{
|
||||||
PHB : PHK : PLB
|
PHB : PHK : PLB
|
||||||
LDA.b #$80 : STA.w SprDefl, X
|
LDA.b #$80 : STA.w SprDefl, X
|
||||||
LDA.w SprSubtype, X : AND.b #$18 : LSR #3
|
|
||||||
|
; Setup Minecart position to look for tile IDs
|
||||||
|
; We use AND #$F8 to clamp to a 8x8 grid.
|
||||||
|
; Subtract 8 from the Y position to get the tile right above instead.
|
||||||
|
LDA.w SprY, X : AND #$F8 : SEC : SBC.b #$08 : 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
|
||||||
|
|
||||||
|
; Fetch tile attributes based on current coordinates
|
||||||
|
LDA.b #$00 : JSL Sprite_GetTileAttr
|
||||||
|
|
||||||
|
LDA.w SPRTILE : SEC : SBC.b #$D0 : STA.w SprAction, X
|
||||||
|
|
||||||
; Run the main frame once so that the animation frame is
|
; Run the main frame once so that the animation frame is
|
||||||
; started correctly.
|
; started correctly.
|
||||||
@@ -66,59 +79,67 @@ Sprite_RotatingTrack_Prep:
|
|||||||
; 2 = BottomRight -> BottomLeft
|
; 2 = BottomRight -> BottomLeft
|
||||||
; 3 = BottomLeft -> TopLeft
|
; 3 = BottomLeft -> TopLeft
|
||||||
|
|
||||||
SwitchRam = $37
|
; The state of each switch. Up to $0250 used which is all free ram.
|
||||||
|
SwitchRam = $0230
|
||||||
|
|
||||||
Sprite_RotatingTrack_Main:
|
Sprite_RotatingTrack_Main:
|
||||||
{
|
{
|
||||||
|
; Get the subtype of the track so that we can get its on/off state.
|
||||||
|
LDA.w SprSubtype, X : TAY
|
||||||
|
|
||||||
LDA.w SprAction, X
|
LDA.w SprAction, X
|
||||||
JSL UseImplicitRegIndexedLocalJumpTable
|
JSL UseImplicitRegIndexedLocalJumpTable
|
||||||
|
|
||||||
dw TopLeftToTopRight
|
dw TopLeftToTopRight
|
||||||
|
dw BottomLeftToTopLeft
|
||||||
dw TopRightToBottomRight
|
dw TopRightToBottomRight
|
||||||
dw BottomRightToBottomLeft
|
dw BottomRightToBottomLeft
|
||||||
dw BottomLeftToTopLeft
|
|
||||||
|
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
; 00 = TopLeft -> TopRight
|
; 00 = TopLeft -> TopRight
|
||||||
TopLeftToTopRight:
|
TopLeftToTopRight:
|
||||||
{
|
{
|
||||||
LDA.w SwitchRam : BNE part2
|
LDA.w SwitchRam, Y : BNE .part2
|
||||||
%PlayAnimation(0,0,4)
|
LDA.b #$00 : STA.w SprFrame, X
|
||||||
part2:
|
RTS
|
||||||
%PlayAnimation(1,1,4)
|
.part2
|
||||||
|
LDA.b #$01 : STA.w SprFrame, X
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
|
|
||||||
; -------------------------------------------------------
|
; -------------------------------------------------------
|
||||||
; 01 = TopRight -> BottomRight
|
; 01 = BottomLeft -> TopLeft
|
||||||
TopRightToBottomRight:
|
|
||||||
{
|
|
||||||
LDA.w SwitchRam : BNE part2_a
|
|
||||||
%PlayAnimation(1,1,4)
|
|
||||||
part2_a:
|
|
||||||
%PlayAnimation(2,2,4)
|
|
||||||
RTS
|
|
||||||
}
|
|
||||||
|
|
||||||
; -------------------------------------------------------
|
|
||||||
; 02 = BottomRight -> BottomLeft
|
|
||||||
BottomRightToBottomLeft:
|
|
||||||
{
|
|
||||||
LDA.w SwitchRam : BEQ part2_b
|
|
||||||
%PlayAnimation(2,2,4)
|
|
||||||
part2_b:
|
|
||||||
%PlayAnimation(3,3,4)
|
|
||||||
RTS
|
|
||||||
}
|
|
||||||
|
|
||||||
; -------------------------------------------------------
|
|
||||||
; 03 = BottomLeft -> TopLeft
|
|
||||||
BottomLeftToTopLeft:
|
BottomLeftToTopLeft:
|
||||||
{
|
{
|
||||||
LDA.w SwitchRam : BNE part2_c
|
LDA.w SwitchRam, Y : BNE .part2_c
|
||||||
%PlayAnimation(3,3,4)
|
LDA.b #$03 : STA.w SprFrame, X
|
||||||
part2_c:
|
RTS
|
||||||
%PlayAnimation(0,0,4)
|
.part2_c
|
||||||
|
LDA.b #$00 : STA.w SprFrame, X
|
||||||
|
RTS
|
||||||
|
}
|
||||||
|
|
||||||
|
; -------------------------------------------------------
|
||||||
|
; 02 = TopRight -> BottomRight
|
||||||
|
TopRightToBottomRight:
|
||||||
|
{
|
||||||
|
LDA.w SwitchRam, Y : BNE .part2_a
|
||||||
|
LDA.b #$01 : STA.w SprFrame, X
|
||||||
|
RTS
|
||||||
|
.part2_a
|
||||||
|
LDA.b #$02 : STA.w SprFrame, X
|
||||||
|
RTS
|
||||||
|
}
|
||||||
|
|
||||||
|
; -------------------------------------------------------
|
||||||
|
; 03 = BottomRight -> BottomLeft
|
||||||
|
BottomRightToBottomLeft:
|
||||||
|
{
|
||||||
|
LDA.w SwitchRam, Y : BEQ .part2_b
|
||||||
|
LDA.b #$03 : STA.w SprFrame, X
|
||||||
|
RTS
|
||||||
|
.part2_b
|
||||||
|
LDA.b #$02 : STA.w SprFrame, X
|
||||||
RTS
|
RTS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,10 +211,10 @@ Sprite_RotatingTrack_Draw:
|
|||||||
db $44
|
db $44
|
||||||
db $44
|
db $44
|
||||||
.properties
|
.properties
|
||||||
db $0D
|
db $3D
|
||||||
db $4D
|
db $7D
|
||||||
db $CD
|
db $FD
|
||||||
db $8D
|
db $BD
|
||||||
}
|
}
|
||||||
|
|
||||||
; =========================================================
|
; =========================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user