Merge pull request #105 from scawful/NewMinecart
Add updated minecart collision, switch track, multi cart, T junction tracks
This commit is contained in:
12
.gitignore
vendored
12
.gitignore
vendored
@@ -10,6 +10,18 @@ oos111x.sfc
|
||||
oos111x.smp.sym
|
||||
oos111x.srm
|
||||
oos111x.sym
|
||||
zcompress.exe
|
||||
oos165.sfc
|
||||
oos165x-1.bst
|
||||
oos165x-2.bst
|
||||
oos165x-3.bst
|
||||
oos165x.bp
|
||||
oos165x.cpu.sym
|
||||
oos165x.sfc
|
||||
oos165x.smp.sym
|
||||
oos165x.srm
|
||||
buildJ.bat
|
||||
oos165x.cht
|
||||
Roms
|
||||
Dungeons/Assets
|
||||
Items/gfx/jump_frames.xcf
|
||||
|
||||
@@ -132,9 +132,9 @@ macro PlayAnimation(frame_start, frame_end, frame_wait)
|
||||
{
|
||||
LDA.w SprTimerB, X : BNE +
|
||||
LDA.w SprFrame, X : INC : STA.w SprFrame, X
|
||||
CMP.b #<frame_end>+1 : BCC .noframereset
|
||||
CMP.b #<frame_end>+1 : BCC ++
|
||||
LDA.b #<frame_start> : STA.w SprFrame, X
|
||||
.noframereset
|
||||
++
|
||||
LDA.b #<frame_wait> : STA.w SprTimerB, X
|
||||
+
|
||||
}
|
||||
@@ -143,9 +143,9 @@ endmacro
|
||||
macro PlayAnimBackwards(frame_start, frame_end, frame_wait)
|
||||
LDA.w SprTimerB, X : BNE +
|
||||
LDA.w SprFrame, X : DEC : STA.w SprFrame, X
|
||||
CMP.b #<frame_end> : BCS .noframereset
|
||||
CMP.b #<frame_end> : BCS ++
|
||||
LDA.b #<frame_start> : STA.w SprFrame, X
|
||||
.noframereset
|
||||
++
|
||||
LDA.b #<frame_wait> : STA.w SprTimerB, X
|
||||
+
|
||||
endmacro
|
||||
|
||||
@@ -784,7 +784,8 @@ MinecartFollower_TransitionToSprite:
|
||||
JSL Sprite_SpawnDynamically
|
||||
TYX
|
||||
JSL Sprite_SetSpawnedCoords
|
||||
LDA.w !MinecartDirection : CMP.b #$00 : BEQ .vert_adjust
|
||||
LDA.w !MinecartDirectionCache : STA.w !MinecartDirection, X
|
||||
CMP.b #$00 : BEQ .vert_adjust
|
||||
CMP.b #$02 : BEQ .vert_adjust
|
||||
LDA.w POSY : CLC : ADC #$08 : STA.w SprY, X
|
||||
LDA.w POSX : STA.w SprX, X
|
||||
@@ -795,11 +796,14 @@ MinecartFollower_TransitionToSprite:
|
||||
.finish_prep
|
||||
LDA.w POSYH : STA.w SprYH, X
|
||||
LDA.w POSXH : STA.w SprXH, X
|
||||
LDA.w !MinecartDirection
|
||||
CLC : ADC.b #$04
|
||||
STA.w SprSubtype, X
|
||||
LDA.w !MinecartDirection, X
|
||||
CLC : ADC.b #$04 : STA.w SprMiscB, X
|
||||
|
||||
; Tell the newly spawned cart which track it is on.
|
||||
LDA.w !MinecartTrackCache : STA.w SprSubtype, X
|
||||
|
||||
LDA Minecart_AnimDirection, X : STA $0D90, X
|
||||
|
||||
JSL Sprite_Minecart_Prep
|
||||
LDA.b #$00 : STA.l $7EF3CC
|
||||
RTL
|
||||
@@ -810,7 +814,7 @@ DrawMinecartFollower:
|
||||
{
|
||||
JSL $099EFC ; Follower_Initialize
|
||||
|
||||
LDX !MinecartDirection
|
||||
LDA.w !MinecartDirectionCache : TAX
|
||||
LDA Minecart_AnimDirection, X : STA $02CF
|
||||
|
||||
JSR FollowerDraw_CachePosition
|
||||
@@ -836,6 +840,13 @@ FollowerDraw_CachePosition:
|
||||
LDA.w $1A3C, X : STA.b $03
|
||||
LDA.w $1A64, X : STA.b $05
|
||||
|
||||
; Adjust the coordinate a bit to place it more in line where the
|
||||
; minecart should be relative to Link.
|
||||
REP #$20
|
||||
LDA.b $00 : SEC : SBC.w #$0008 : STA.b $00
|
||||
LDA.b $02 : CLC : ADC.w #$0002 : STA.b $02
|
||||
SEP #$20
|
||||
|
||||
; -------------------------
|
||||
AND.b #$20
|
||||
LSR A
|
||||
@@ -927,6 +938,12 @@ CheckForFollowerInterroomTransition:
|
||||
{
|
||||
LDA.w !LinkInCart : BEQ .not_in_cart
|
||||
LDA.b #$0B : STA $7EF3CC
|
||||
|
||||
; Pause the current cart so that it doesn't draw anymore
|
||||
PHX
|
||||
LDX.w !MinecartCurrent
|
||||
LDA.b #$01 : STA $0F00, X
|
||||
PLX
|
||||
.not_in_cart
|
||||
JSL $01873A ; Underworld_LoadRoom
|
||||
RTL
|
||||
@@ -951,7 +968,7 @@ LinkState_Minecart:
|
||||
STZ.b $48
|
||||
|
||||
; Move Link based on the direction of the cart
|
||||
LDA.w !MinecartDirection : BNE .not_north
|
||||
LDA.w !MinecartDirection, X : BNE .not_north
|
||||
LDY.b #$00
|
||||
LDA.w .drag_y_low, Y : CLC : ADC.w $0B7E : STA.w $0B7E
|
||||
LDA.w .drag_y_high, Y : ADC.w $0B7F : STA.w $0B7F
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -52,7 +52,11 @@ Sprite_LeverSwitch_Prep:
|
||||
PHB : PHK : PLB
|
||||
|
||||
LDA.b #$00 : STA.w SprDefl, X
|
||||
LDA.w SprSubtype, X : STA.w SprAction, 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
|
||||
STZ.w SprBulletproof, X
|
||||
|
||||
@@ -81,7 +85,11 @@ Sprite_LeverSwitch_Main:
|
||||
JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage
|
||||
LDA #$25 : STA $012F
|
||||
|
||||
STZ.w $37
|
||||
; Get the subtype of the switch so that we can get its on/off state.
|
||||
LDA.w SprSubtype, X : TAY
|
||||
|
||||
; Turn the switch on.
|
||||
LDA #$01 : STA.w SwitchRam, Y
|
||||
LDA #$10 : STA.w SprTimerA, X
|
||||
%GotoAction(1)
|
||||
.NoDamage
|
||||
@@ -94,7 +102,12 @@ Sprite_LeverSwitch_Main:
|
||||
LDA.w SprTimerA, X : BNE .NoDamage
|
||||
JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage
|
||||
LDA #$25 : STA $012F
|
||||
LDA #$01 : STA $37
|
||||
|
||||
; Get the subtype of the switch so that we can get its on/off state.
|
||||
LDA.w SprSubtype, X : TAY
|
||||
|
||||
; Turn the switch off.
|
||||
LDA #$00 : STA.w SwitchRam, Y
|
||||
LDA #$10 : STA.w SprTimerA, X
|
||||
%GotoAction(0)
|
||||
.NoDamage
|
||||
@@ -129,7 +142,7 @@ Sprite_LeverSwitch_Main:
|
||||
Sprite_LeverSwitch_Draw:
|
||||
{
|
||||
JSL Sprite_PrepOamCoord
|
||||
JSL Sprite_OAM_AllocateDeferToPlayer
|
||||
LDA.b #$04 : JSL Sprite_OAM_AllocateDeferToPlayer
|
||||
|
||||
LDA $0DC0, X : CLC : ADC $0D90, X : TAY ;Animation Frame
|
||||
LDA .start_index, Y : STA $06
|
||||
@@ -194,8 +207,8 @@ Sprite_LeverSwitch_Draw:
|
||||
dw 0
|
||||
dw 0
|
||||
.chr
|
||||
db $64
|
||||
db $66
|
||||
db $64
|
||||
.properties
|
||||
db $37
|
||||
db $37
|
||||
|
||||
@@ -50,7 +50,24 @@ Sprite_RotatingTrack_Prep:
|
||||
{
|
||||
PHB : PHK : PLB
|
||||
LDA.b #$80 : STA.w SprDefl, X
|
||||
LDA.w SprSubtype, X : STA.w SprAction,X
|
||||
|
||||
; 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
|
||||
; started correctly.
|
||||
JSR Sprite_RotatingTrack_Main
|
||||
PLB
|
||||
RTL
|
||||
}
|
||||
@@ -61,75 +78,68 @@ Sprite_RotatingTrack_Prep:
|
||||
; 1 = TopRight -> BottomRight
|
||||
; 2 = BottomRight -> BottomLeft
|
||||
; 3 = BottomLeft -> TopLeft
|
||||
; 4 = TopRight -> TopLeft
|
||||
|
||||
SwitchRam = $37
|
||||
; The state of each switch. Up to $0250 used which is all free ram.
|
||||
SwitchRam = $0230
|
||||
|
||||
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
|
||||
JSL UseImplicitRegIndexedLocalJumpTable
|
||||
|
||||
dw TopLeftToTopRight
|
||||
dw BottomLeftToTopLeft
|
||||
dw TopRightToBottomRight
|
||||
dw BottomRightToBottomLeft
|
||||
dw BottomLeftToTopLeft
|
||||
dw TopRightToTopLeft
|
||||
|
||||
; -------------------------------------------------------
|
||||
; 00 = TopLeft -> TopRight
|
||||
TopLeftToTopRight:
|
||||
{
|
||||
LDA.w SwitchRam : BNE part2
|
||||
%PlayAnimation(0,0,4)
|
||||
part2:
|
||||
%PlayAnimation(1,1,4)
|
||||
LDA.w SwitchRam, Y : BNE .part2
|
||||
LDA.b #$00 : STA.w SprFrame, X
|
||||
RTS
|
||||
.part2
|
||||
LDA.b #$01 : STA.w SprFrame, X
|
||||
RTS
|
||||
}
|
||||
|
||||
; -------------------------------------------------------
|
||||
; 01 = TopRight -> BottomRight
|
||||
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
|
||||
; 01 = BottomLeft -> TopLeft
|
||||
BottomLeftToTopLeft:
|
||||
{
|
||||
LDA.w SwitchRam : BNE part2_c
|
||||
%PlayAnimation(3,3,4)
|
||||
part2_c:
|
||||
%PlayAnimation(0,0,4)
|
||||
LDA.w SwitchRam, Y : BNE .part2_c
|
||||
LDA.b #$03 : STA.w SprFrame, X
|
||||
RTS
|
||||
.part2_c
|
||||
LDA.b #$00 : STA.w SprFrame, X
|
||||
RTS
|
||||
}
|
||||
|
||||
; -------------------------------------------------------
|
||||
; 04 = TopRight -> TopLeft
|
||||
TopRightToTopLeft:
|
||||
; 02 = TopRight -> BottomRight
|
||||
TopRightToBottomRight:
|
||||
{
|
||||
LDA.w SwitchRam : BNE part2_d
|
||||
%StartOnFrame(1)
|
||||
%PlayAnimation(1,1,4)
|
||||
part2_d:
|
||||
%StartOnFrame(0)
|
||||
%PlayAnimation(0,0,4)
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -139,7 +149,7 @@ Sprite_RotatingTrack_Main:
|
||||
Sprite_RotatingTrack_Draw:
|
||||
{
|
||||
JSL Sprite_PrepOamCoord
|
||||
JSL Sprite_OAM_AllocateDeferToPlayer
|
||||
LDA.b #$04 : JSL OAM_AllocateFromRegionB
|
||||
|
||||
LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame
|
||||
LDA .start_index, Y : STA $06
|
||||
@@ -191,7 +201,6 @@ Sprite_RotatingTrack_Draw:
|
||||
|
||||
RTS
|
||||
|
||||
|
||||
.start_index
|
||||
db $00, $01, $02, $03
|
||||
.nbr_of_tiles
|
||||
@@ -202,8 +211,10 @@ Sprite_RotatingTrack_Draw:
|
||||
db $44
|
||||
db $44
|
||||
.properties
|
||||
db $7D
|
||||
db $3D
|
||||
db $7D
|
||||
db $FD
|
||||
db $BD
|
||||
}
|
||||
|
||||
; =========================================================
|
||||
|
||||
Reference in New Issue
Block a user