Merge pull request #105 from scawful/NewMinecart

Add updated minecart collision, switch track, multi cart, T junction tracks
This commit is contained in:
Justin Scofield
2025-02-12 18:18:24 -05:00
committed by GitHub
6 changed files with 1254 additions and 710 deletions

14
.gitignore vendored
View File

@@ -10,6 +10,18 @@ oos111x.sfc
oos111x.smp.sym oos111x.smp.sym
oos111x.srm oos111x.srm
oos111x.sym 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 Roms
Dungeons/Assets Dungeons/Assets
Items/gfx/jump_frames.xcf Items/gfx/jump_frames.xcf
@@ -144,4 +156,4 @@ Music/wip/twinrova_battle.asm
Sprites/NPCs/piratian.zsm Sprites/NPCs/piratian.zsm
Masks/gfx/moosh.png Masks/gfx/moosh.png
Masks/gfx/moosh.pal Masks/gfx/moosh.pal
Dungeons/DungeonMaps.asm Dungeons/DungeonMaps.asm

View File

@@ -132,9 +132,9 @@ macro PlayAnimation(frame_start, frame_end, frame_wait)
{ {
LDA.w SprTimerB, X : BNE + LDA.w SprTimerB, X : BNE +
LDA.w SprFrame, X : INC : STA.w SprFrame, X 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 LDA.b #<frame_start> : STA.w SprFrame, X
.noframereset ++
LDA.b #<frame_wait> : STA.w SprTimerB, X LDA.b #<frame_wait> : STA.w SprTimerB, X
+ +
} }
@@ -143,9 +143,9 @@ endmacro
macro PlayAnimBackwards(frame_start, frame_end, frame_wait) macro PlayAnimBackwards(frame_start, frame_end, frame_wait)
LDA.w SprTimerB, X : BNE + LDA.w SprTimerB, X : BNE +
LDA.w SprFrame, X : DEC : STA.w SprFrame, X 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 LDA.b #<frame_start> : STA.w SprFrame, X
.noframereset ++
LDA.b #<frame_wait> : STA.w SprTimerB, X LDA.b #<frame_wait> : STA.w SprTimerB, X
+ +
endmacro endmacro

View File

@@ -98,13 +98,13 @@ ZoraBaby_RevertToSprite:
PHX PHX
TAX TAX
LDA.w $1A64, X : AND.b #$03 : STA.w SprMiscE,Y : STA.w SprMiscC,Y LDA.w $1A64, X : AND.b #$03 : STA.w SprMiscE, Y : STA.w SprMiscC, Y
LDA.w $1A00, X : CLC : ADC.b #$02 : STA.w SprY,Y LDA.w $1A00, X : CLC : ADC.b #$02 : STA.w SprY, Y
LDA.w $1A14, X : ADC.b #$00 : STA.w SprYH,Y LDA.w $1A14, X : ADC.b #$00 : STA.w SprYH, Y
LDA.w $1A28, X : CLC : ADC.b #$10 : STA.w SprX,Y LDA.w $1A28, X : CLC : ADC.b #$10 : STA.w SprX, Y
LDA.w $1A3C, X : ADC.b #$00 : STA.w SprXH,Y LDA.w $1A3C, X : ADC.b #$00 : STA.w SprXH, Y
LDA.b $EE : STA.w $0F20,Y LDA.b $EE : STA.w $0F20, Y
LDA.b #$01 : STA.w SprBulletproof,Y : STA.w $0E80,Y LDA.b #$01 : STA.w SprBulletproof, Y : STA.w $0E80, Y
LDA.b #$04 : STA.w SprAction, Y LDA.b #$04 : STA.w SprAction, Y
LDA.b #$FF : STA.w SprTimerB, Y LDA.b #$FF : STA.w SprTimerB, Y
PLX PLX
@@ -168,8 +168,8 @@ ZoraBaby_CheckForWaterSwitchSprite:
PHX PHX
LDX #$10 LDX #$10
- -
LDA.w SprType, X LDA.w SprType, X
CMP #$21 : BEQ ZoraBaby_CheckForWaterGateSwitch_found_switch CMP #$21 : BEQ ZoraBaby_CheckForWaterGateSwitch_found_switch
DEX : BPL - DEX : BPL -
; Water gate switch not found ; Water gate switch not found
PLX PLX
@@ -185,9 +185,9 @@ ZoraBaby_CheckForWaterGateSwitch:
LDX #$10 LDX #$10
- -
LDA.w SprType, X : CMP #$04 : BEQ .found_switch LDA.w SprType, X : CMP #$04 : BEQ .found_switch
DEX : BPL - DEX : BPL -
; Water gate switch not found ; Water gate switch not found
PLX PLX
.not_on_switch .not_on_switch
CLC CLC
RTS RTS
@@ -203,8 +203,8 @@ ZoraBaby_CheckForWaterGateSwitch:
LDA.w SprX, X : SEC : SBC #$09 : CMP.w SprX, Y : BCS .not_on_switch LDA.w SprX, X : SEC : SBC #$09 : CMP.w SprX, Y : BCS .not_on_switch
LDA.w SprY, X : CLC : ADC #$12 : CMP.w SprY, Y : BCC .not_on_switch LDA.w SprY, X : CLC : ADC #$12 : CMP.w SprY, Y : BCC .not_on_switch
LDA.w SprY, X : SEC : SBC #$12 : CMP.w SprY, Y : BCS .not_on_switch LDA.w SprY, X : SEC : SBC #$12 : CMP.w SprY, Y : BCS .not_on_switch
SEC SEC
RTS RTS
} }
ZoraBaby_GlobalBehavior: ZoraBaby_GlobalBehavior:
@@ -295,9 +295,9 @@ Sprite_39_ZoraBaby:
JSL JumpTableLocal JSL JumpTableLocal
dw LockSmith_Chillin dw LockSmith_Chillin
dw ZoraBaby_FollowLink ; Becomes Follower dw ZoraBaby_FollowLink ; Becomes Follower
dw ZoraBaby_OfferService ; I can help! (Follow/Stay) dw ZoraBaby_OfferService ; I can help! (Follow/Stay)
dw ZoraBaby_RespondToAnswer ; Goto FollowLink or JustPromiseOkay dw ZoraBaby_RespondToAnswer ; Goto FollowLink or JustPromiseOkay
dw ZoraBaby_AgreeToWait dw ZoraBaby_AgreeToWait
dw ZoraBaby_PullSwitch dw ZoraBaby_PullSwitch
dw ZoraBaby_PostSwitch dw ZoraBaby_PostSwitch
@@ -609,17 +609,17 @@ pullpc
FollowerDraw_CalculateOAMCoords: FollowerDraw_CalculateOAMCoords:
{ {
REP #$20 REP #$20
LDA.b $02 : STA.b ($90),Y LDA.b $02 : STA.b ($90), Y
INY 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 $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 : 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 LDA.w #$00F0 : STA.b ($90), Y
.on_screen: .on_screen:
SEP #$20 SEP #$20
@@ -784,10 +784,11 @@ MinecartFollower_TransitionToSprite:
JSL Sprite_SpawnDynamically JSL Sprite_SpawnDynamically
TYX TYX
JSL Sprite_SetSpawnedCoords 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 CMP.b #$02 : BEQ .vert_adjust
LDA.w POSY : CLC : ADC #$08 : STA.w SprY, X LDA.w POSY : CLC : ADC #$08 : STA.w SprY, X
LDA.w POSX : STA.w SprX, X LDA.w POSX : STA.w SprX, X
JMP .finish_prep JMP .finish_prep
.vert_adjust .vert_adjust
LDA.w POSY : STA.w SprY, X LDA.w POSY : STA.w SprY, X
@@ -795,11 +796,14 @@ MinecartFollower_TransitionToSprite:
.finish_prep .finish_prep
LDA.w POSYH : STA.w SprYH, X LDA.w POSYH : STA.w SprYH, X
LDA.w POSXH : STA.w SprXH, X LDA.w POSXH : STA.w SprXH, X
LDA.w !MinecartDirection LDA.w !MinecartDirection, X
CLC : ADC.b #$04 CLC : ADC.b #$04 : STA.w SprMiscB, X
STA.w SprSubtype, 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 LDA Minecart_AnimDirection, X : STA $0D90, X
JSL Sprite_Minecart_Prep JSL Sprite_Minecart_Prep
LDA.b #$00 : STA.l $7EF3CC LDA.b #$00 : STA.l $7EF3CC
RTL RTL
@@ -810,7 +814,7 @@ DrawMinecartFollower:
{ {
JSL $099EFC ; Follower_Initialize JSL $099EFC ; Follower_Initialize
LDX !MinecartDirection LDA.w !MinecartDirectionCache : TAX
LDA Minecart_AnimDirection, X : STA $02CF LDA Minecart_AnimDirection, X : STA $02CF
JSR FollowerDraw_CachePosition JSR FollowerDraw_CachePosition
@@ -836,6 +840,13 @@ FollowerDraw_CachePosition:
LDA.w $1A3C, X : STA.b $03 LDA.w $1A3C, X : STA.b $03
LDA.w $1A64, X : STA.b $05 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 AND.b #$20
LSR A LSR A
@@ -851,7 +862,7 @@ FollowerDraw_CachePosition:
; variables based on the follower here and manipulate $72 ; variables based on the follower here and manipulate $72
; if the player was immobile. ; if the player was immobile.
CLC : ADC $04 : STA $04 CLC : ADC $04 : STA $04
TYA : CLC : ADC $04 : STA $04 TYA : CLC : ADC $04 : STA $04
; ------------------------- ; -------------------------
@@ -927,6 +938,12 @@ CheckForFollowerInterroomTransition:
{ {
LDA.w !LinkInCart : BEQ .not_in_cart LDA.w !LinkInCart : BEQ .not_in_cart
LDA.b #$0B : STA $7EF3CC 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 .not_in_cart
JSL $01873A ; Underworld_LoadRoom JSL $01873A ; Underworld_LoadRoom
RTL RTL
@@ -951,7 +968,7 @@ LinkState_Minecart:
STZ.b $48 STZ.b $48
; Move Link based on the direction of the cart ; 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 LDY.b #$00
LDA.w .drag_y_low, Y : CLC : ADC.w $0B7E : STA.w $0B7E 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 LDA.w .drag_y_high, Y : ADC.w $0B7F : STA.w $0B7F

File diff suppressed because it is too large Load Diff

View File

@@ -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 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 LDA.b #$00 : STA.w SprTileDie, X
STZ.w SprBulletproof, X STZ.w SprBulletproof, X
@@ -81,7 +85,11 @@ Sprite_LeverSwitch_Main:
JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage JSL Sprite_CheckDamageFromPlayer : BCC .NoDamage
LDA #$25 : STA $012F 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 LDA #$10 : STA.w SprTimerA, X
%GotoAction(1) %GotoAction(1)
.NoDamage .NoDamage
@@ -94,7 +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
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 LDA #$10 : STA.w SprTimerA, X
%GotoAction(0) %GotoAction(0)
.NoDamage .NoDamage
@@ -129,9 +142,9 @@ Sprite_LeverSwitch_Main:
Sprite_LeverSwitch_Draw: Sprite_LeverSwitch_Draw:
{ {
JSL Sprite_PrepOamCoord 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 $0DC0, X : CLC : ADC $0D90, X : TAY ;Animation Frame
LDA .start_index, Y : STA $06 LDA .start_index, Y : STA $06
@@ -194,8 +207,8 @@ Sprite_LeverSwitch_Draw:
dw 0 dw 0
dw 0 dw 0
.chr .chr
db $64
db $66 db $66
db $64
.properties .properties
db $37 db $37
db $37 db $37

View File

@@ -50,7 +50,24 @@ 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 : 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 PLB
RTL RTL
} }
@@ -61,75 +78,68 @@ Sprite_RotatingTrack_Prep:
; 1 = TopRight -> BottomRight ; 1 = TopRight -> BottomRight
; 2 = BottomRight -> BottomLeft ; 2 = BottomRight -> BottomLeft
; 3 = BottomLeft -> TopLeft ; 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: 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
dw TopRightToTopLeft
; ------------------------------------------------------- ; -------------------------------------------------------
; 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 RTS
} }
; ------------------------------------------------------- ; -------------------------------------------------------
; 04 = TopRight -> TopLeft ; 02 = TopRight -> BottomRight
TopRightToTopLeft: TopRightToBottomRight:
{ {
LDA.w SwitchRam : BNE part2_d LDA.w SwitchRam, Y : BNE .part2_a
%StartOnFrame(1) LDA.b #$01 : STA.w SprFrame, X
%PlayAnimation(1,1,4) RTS
part2_d: .part2_a
%StartOnFrame(0) LDA.b #$02 : STA.w SprFrame, X
%PlayAnimation(0,0,4) 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
} }
} }
@@ -139,7 +149,7 @@ Sprite_RotatingTrack_Main:
Sprite_RotatingTrack_Draw: Sprite_RotatingTrack_Draw:
{ {
JSL Sprite_PrepOamCoord JSL Sprite_PrepOamCoord
JSL Sprite_OAM_AllocateDeferToPlayer LDA.b #$04 : JSL OAM_AllocateFromRegionB
LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame
LDA .start_index, Y : STA $06 LDA .start_index, Y : STA $06
@@ -191,7 +201,6 @@ Sprite_RotatingTrack_Draw:
RTS RTS
.start_index .start_index
db $00, $01, $02, $03 db $00, $01, $02, $03
.nbr_of_tiles .nbr_of_tiles
@@ -202,8 +211,10 @@ Sprite_RotatingTrack_Draw:
db $44 db $44
db $44 db $44
.properties .properties
db $7D
db $3D db $3D
db $7D
db $FD db $FD
db $BD db $BD
} }
; =========================================================