Format fishing rod code

This commit is contained in:
scawful
2024-02-24 08:15:20 -05:00
parent 253fe3174d
commit 35d87ec280

View File

@@ -9,31 +9,32 @@
; $7F5BA2 RAM for fishing mode - 1 = rod out, 2 = pull ; $7F5BA2 RAM for fishing mode - 1 = rod out, 2 = pull
; $7F5BA3 RAM Index for the fishing floater ; $7F5BA3 RAM Index for the fishing floater
; Modify the code of the sprite "RunningBoy" 0x74 ; Modify the code of the sprite "RunningBoy" 0x74
;===================================================== ; =========================================================
; Values ; Values
;#$400 ; to show fishing hud ;#$400 ; to show fishing hud
;#$14A ; only the hud ;#$14A ; only the hud
; ================= USED FOR THE FLOATER ================== ; ================= USED FOR THE FLOATER ==================
;(could probably be changed to something else)
org $06C058 ; JSL Sprite_74_RunningBoy org $06C058 ; JSL Sprite_74_RunningBoy
; org $1E9A6D ; Sprite_9F_HauntedGroveRabbit {
JSL FloaterBoySpriteCheck JSL FloaterBoySpriteCheck
RTS RTS
}
;org $07A569 ; Bombos code ; could be changed just need to replace the org with the item you want
org $07AF3E ; Cane of Byrna
JSL FishingRod
RTS
org $07AF3E ; Cane of Byrna - End: $07AFB4
LinkItem_CaneOfByrna:
{
JSL FishingRod
RTS
}
pullpc pullpc
FishingRodExit: FishingRodExit:
PLB PLB
RTL RTL
FishingRod: FishingRod:
{ {
@@ -195,347 +196,332 @@ Prizes:
fishingrodgfx: fishingrodgfx:
incbin gfx/fishingrod.bin incbin gfx/fishingrod.bin
blockgfx: blockgfx:
incbin gfx/blockgfx.bin incbin gfx/blockgfx.bin
canegfx: canegfx:
incbin gfx/canegfx.bin incbin gfx/canegfx.bin
floatergfx: floatergfx:
incbin gfx/floatergfx.bin incbin gfx/floatergfx.bin
hammergfx: hammergfx:
incbin gfx/hammergfx.bin incbin gfx/hammergfx.bin
CheckYButtonPress: CheckYButtonPress:
BIT.b $3A {
BVS .fail BIT.b $3A : BVS .fail
LDA.b $46 : BNE .fail
LDA.b $46 LDA.b $F4 : AND.b #$40 : BEQ .fail
BNE .fail TSB.b $3A
SEC
LDA.b $F4 RTS
AND.b #$40
BEQ .fail
TSB.b $3A
SEC
RTS
.fail
CLC
RTS
.fail
CLC
RTS
}
AltLinkUsingItem: AltLinkUsingItem:
LDA.b $AD {
CMP.b #$02 LDA.b $AD : CMP.b #$02 : BNE .skip
BNE .skip
LDA.w $0322 LDA.w $0322 : AND.b #$03 : CMP.b #$03 : BNE .skip
AND.b #$03
CMP.b #$03
BNE .skip
STZ.b $30 STZ.b $30
STZ.b $31 STZ.b $31
STZ.b $67 STZ.b $67
STZ.b $2A STZ.b $2A
STZ.b $2B STZ.b $2B
STZ.b $6B STZ.b $6B
.skip .skip
LDA.w $02F5 LDA.w $02F5 : BEQ .return
BEQ .return
STZ.b $67 STZ.b $67
.return
RTS
.return
RTS
}
FishingSwapCaneBlockHammerGfx: FishingSwapCaneBlockHammerGfx:
PHX ; keep X {
PHP ; keep processor byte PHX ; keep X
PHP ; keep processor byte
REP #$30 ; 16bit is a bit faster REP #$30 ; 16bit is a bit faster
LDX #$01BE LDX #$01BE
-- --
LDA.l fishingrodgfx, X : STA.l $7E9F40, X LDA.l fishingrodgfx, X : STA.l $7E9F40, X
LDA.l floatergfx, X : STA.l $7EA480, X LDA.l floatergfx, X : STA.l $7EA480, X
DEX : DEX DEX : DEX
BPL -- BPL --
PLP PLP
PLX PLX
RTL RTL
}
RestoreCaneBlockHammerGfx: RestoreCaneBlockHammerGfx:
PHX ; keep X {
PHP ; keep processor byte PHX ; keep X
PHP ; keep processor byte
REP #$30 ; 16bit is a bit faster REP #$30 ; 16bit is a bit faster
LDX #$01BE LDX #$01BE
-- --
LDA.l canegfx, X : STA.l $7E9F40, X LDA.l canegfx, X : STA.l $7E9F40, X
LDA.l blockgfx, X : STA.l $7EA480, X LDA.l blockgfx, X : STA.l $7EA480, X
LDA.l hammergfx, X : STA.l $7E9640, X LDA.l hammergfx, X : STA.l $7E9640, X
DEX : DEX DEX : DEX
BPL -- BPL --
PLP PLP
PLX PLX
RTL RTL
}
FloaterBoySpriteCheck: FloaterBoySpriteCheck:
LDA.w $0E70, X : BEQ .noThatsRunningBoy {
PHB : PHK : PLB LDA.w $0E70, X : BEQ .noThatsRunningBoy
JSR Sprite_Floater PHB : PHK : PLB
PLB JSR Sprite_Floater
RTL PLB
RTL
.noThatsRunningBoy .noThatsRunningBoy
JSL $05E8A2 ; Sprite_74_RunningBoy JSL $05E8A2 ; Sprite_74_RunningBoy
RTL RTL
}
Sprite_CheckIfActive: Sprite_CheckIfActive:
LDA.w $0FC1 ; Remove that if want to be able to pause all other sprites {
BNE .inactive LDA.w $0FC1 ; Remove that if want to be able to pause all other sprites
BNE .inactive
LDA.b $11 LDA.b $11
BNE .inactive BNE .inactive
LDA.w $0CAA,X LDA.w $0CAA,X
BMI .active BMI .active
LDA.w $0F00,X LDA.w $0F00,X
BEQ .active BEQ .active
.inactive .inactive
PLA PLA
PLA PLA
.active .active
RTS RTS
}
;====================================================================== ;======================================================================
;Floater sprite code ;Floater sprite code
SpritePrep_Floater: SpritePrep_Floater:
LDA.b $66 : CMP.b #$03 : BNE .notRight {
LDA.b #$12 : STA.w $0D50, X ; XSpeed LDA.b $66 : CMP.b #$03 : BNE .notRight
BRA .DoInitFloater LDA.b #$12 : STA.w $0D50, X ; XSpeed
.notRight BRA .DoInitFloater
CMP.b #$02 : BNE .notLeft .notRight
LDA.b #$ED : STA.w $0D50, X ; XSpeed CMP.b #$02 : BNE .notLeft
BRA .DoInitFloater LDA.b #$ED : STA.w $0D50, X ; XSpeed
.notLeft BRA .DoInitFloater
CMP.b #$01 : BNE .notDown .notLeft
LDA.b #$12 : STA.w $0D40, X ; YSpeed CMP.b #$01 : BNE .notDown
BRA .DoInitFloater LDA.b #$12 : STA.w $0D40, X ; YSpeed
.notDown BRA .DoInitFloater
CMP.b #$00 : BNE .notUp .notDown
LDA.b #$ED : STA.w $0D40, X ; YSpeed CMP.b #$00 : BNE .notUp
BRA .DoInitFloater LDA.b #$ED : STA.w $0D40, X ; YSpeed
.notUp BRA .DoInitFloater
.notUp
.DoInitFloater .DoInitFloater
LDA.b #$08 : STA.w $0F70, X ; Height LDA.b #$08 : STA.w $0F70, X ; Height
LDA.b #$10 : STA.w $0F80, X ; Gravity LDA.b #$10 : STA.w $0F80, X ; Gravity
LDA.b #$00 : STA.w $0ED0, X ; is it in water? LDA.b #$00 : STA.w $0ED0, X ; is it in water?
LDA.b #$00 : STA.w $0EB0, X ; Wiggling Velocity index LDA.b #$00 : STA.w $0EB0, X ; Wiggling Velocity index
LDA.b #$00 : STA.w $0E90, X ; just for a check LDA.b #$00 : STA.w $0E90, X ; just for a check
LDA.b #$00 : STA.w $0DB0, X ; if we have a fish on line LDA.b #$00 : STA.w $0DB0, X ; if we have a fish on line
;$0EE0 Timer for when floater is in water waiting for a fish to catch ;$0EE0 Timer for when floater is in water waiting for a fish to catch
RTL RTL
}
;--------------------------------------------------------------------- ;---------------------------------------------------------------------
Sprite_Floater: Sprite_Floater:
{
; Floater Draw, allocate 4 tiles to use for the hud
LDA $0ED0, X : BEQ +
JSL $059FFA ; draw water ripple
+
JSR Sprite_Floater_Draw
; Floater Draw, allocate 4 tiles to use for the hud LDA $0ED0, X : BNE +
LDA $0ED0, X : BEQ + JSL $06DC54 ; shadow
JSL $059FFA ; draw water ripple +
+
JSR Sprite_Floater_Draw
LDA $0ED0, X : BNE + JSR Sprite_CheckIfActive
JSL $06DC54 ; shadow
+
JSR Sprite_CheckIfActive LDA.w $0ED0, X : BEQ .noFishOnLine ; is the floater in water?
LDA.w $0ED0, X : BEQ .noFishOnLine ; is the floater in water?
LDA.w $0EE0, X : BNE .noWigglingYet; timerD wait until fish is on line LDA.w $0EE0, X : BNE .noWigglingYet; timerD wait until fish is on line
LDA.w $0DB0, X : BNE .fishOnlineWait LDA.w $0DB0, X : BNE .fishOnlineWait
; start another random timer for the time it'll last ; start another random timer for the time it'll last
JSL $0DBA71 : AND #$3F ; GetRandomInt JSL $0DBA71 : AND #$3F ; GetRandomInt
CLC : ADC.b #$0F : STA.w $0DF0, X ; wiggling timer CLC : ADC.b #$0F : STA.w $0DF0, X ; wiggling timer
INC.w $0DB0, X ; we have a fish on line INC.w $0DB0, X ; we have a fish on line
.noWigglingYet .noWigglingYet
LDA.w $0DB0, X : BEQ .noFishOnLine ; do we already have a fish on line? LDA.w $0DB0, X : BEQ .noFishOnLine ; do we already have a fish on line?
.fishOnlineWait .fishOnlineWait
LDA.w $0DF0, X : BNE .stillwiggling LDA.w $0DF0, X : BNE .stillwiggling
print pc print pc
STZ.w $0DB0, X ; no more fish on line took too much time STZ.w $0DB0, X ; no more fish on line took too much time
JSL $0DBA71 : AND.b #$7F ; GetRandomInt JSL $0DBA71 : AND.b #$7F ; GetRandomInt
CLC : ADC.b #$7F : STA.w $0EE0, X ; reset timer wait until fish is on line CLC : ADC.b #$7F : STA.w $0EE0, X ; reset timer wait until fish is on line
STZ.w $0D50, X STZ.w $0D50, X
STZ.w $0D40, X STZ.w $0D40, X
BRA .noFishOnLine BRA .noFishOnLine
.stillwiggling .stillwiggling
LDY.w $0E10, X LDY.w $0E10, X
LDA.w WigglingTable, Y : STA.w $0D50,X LDA.w WigglingTable, Y : STA.w $0D50,X
LDA.w WigglingTable, Y : STA.w $0D40,X LDA.w WigglingTable, Y : STA.w $0D40,X
LDY.w $0E10, X : BNE + ; use timer to do wiggling LDY.w $0E10, X : BNE + ; use timer to do wiggling
; if = 0 then put it back to F ; if = 0 then put it back to F
LDA.b #$0F : STA.w $0E10, X ; wiggling timer LDA.b #$0F : STA.w $0E10, X ; wiggling timer
+ +
.noFishOnLine .noFishOnLine
JSL $1D808C ; Sprite_Move_XY JSL $1D808C ; Sprite_Move_XY
JSL Sprite_MoveAltitude JSL Sprite_MoveAltitude
LDA.w $0F80,X LDA.w $0F80,X
SEC SEC
SBC.b #$01 SBC.b #$01
STA.w $0F80,X STA.w $0F80,X
LDA.w $0F70,X LDA.w $0F70,X
BPL .aloft BPL .aloft
STZ.w $0F70,X STZ.w $0F70,X
LDA.w $0D50,X LDA.w $0D50,X
ASL A ASL A
ROR.w $0D50,X ROR.w $0D50,X
LDA.w $0D40,X LDA.w $0D40,X
ASL A ASL A
ROR.w $0D40,X ROR.w $0D40,X
LDA.w $0F80,X LDA.w $0F80,X
EOR.b #$FF EOR.b #$FF
INC A INC A
LSR A LSR A
CMP.b #$09 CMP.b #$09
BCS .no_bounce BCS .no_bounce
LDA.w $0E90, X : BNE .not_water_tileLast LDA.w $0E90, X : BNE .not_water_tileLast
INC.w $0E90, X INC.w $0E90, X
JSL $06E496 ; Sprite_CheckTileCollision JSL $06E496 ; Sprite_CheckTileCollision
LDA.w $0FA5 LDA.w $0FA5
CMP.b #$08 ; TILETYPE 08 CMP.b #$08 ; TILETYPE 08
BEQ .water_tileLast BEQ .water_tileLast
CMP.b #$09 ; TILETYPE 09 CMP.b #$09 ; TILETYPE 09
BNE .not_water_tileLast BNE .not_water_tileLast
.water_tileLast .water_tileLast
INC.w $0ED0, X ; Set that so we know floater is in water! INC.w $0ED0, X ; Set that so we know floater is in water!
JSL $1EA820 ; Sprite_SpawnSmallSplash JSL $1EA820 ; Sprite_SpawnSmallSplash
JSL $0DBA71 : AND #$3F ; GetRandomInt JSL $0DBA71 : AND #$3F ; GetRandomInt
CLC : ADC #$3F : STA.w $0EE0, X CLC : ADC #$3F : STA.w $0EE0, X
.not_water_tileLast .not_water_tileLast
STZ.w $0F80,X STZ.w $0F80,X
STZ.w $0D50,X STZ.w $0D50,X
STZ.w $0D40,X STZ.w $0D40,X
BRA .aloft BRA .aloft
.no_bounce .no_bounce
STA.w $0F80,X STA.w $0F80,X
JSL $06E496 ; Sprite_CheckTileCollision JSL $06E496 ; Sprite_CheckTileCollision
LDA.w $0FA5 LDA.w $0FA5
CMP.b #$08 ; TILETYPE 08 CMP.b #$08 ; TILETYPE 08
BEQ .water_tile BEQ .water_tile
CMP.b #$09 ; TILETYPE 09 CMP.b #$09 ; TILETYPE 09
BNE .not_water_tile BNE .not_water_tile
.water_tile .water_tile
;STZ.w $0F80,X ;STZ.w $0F80,X
JSL $1EA820 ; Sprite_SpawnSmallSplash JSL $1EA820 ; Sprite_SpawnSmallSplash
.not_water_tile .not_water_tile
.aloft .aloft
LDA.b #$01 : STA.w $0E70, X ; restore floater sprite seems to be overwriten LDA.b #$01 : STA.w $0E70, X ; restore floater sprite seems to be overwriten
RTS RTS
}
Sprite_Floater_Draw: Sprite_Floater_Draw:
{
LDA.b #$4 ; 1 oam slots
JSL $0DBA88 ; SpriteDraw_AllocateOAMFromRegionC
JSL $06E416 ; Sprite_PrepOamCoord
REP #$20
LDA.b #$4 ; 1 oam slots LDA.b $00 : STA.b ($90),Y
JSL $0DBA88 ; SpriteDraw_AllocateOAMFromRegionC CLC : AND.w #$0100 : STA.b $0E
JSL $06E416 ; Sprite_PrepOamCoord
REP #$20
LDA.b $00 LDA.b $02 : INY
STA.b ($90),Y STA.b ($90),Y
CMP.w #$0100
SEP #$20
BCC .on_screen
CLC LDA.b #$F0 : STA.b ($90),Y
AND.w #$0100
STA.b $0E
LDA.b $02 .on_screen
INY
STA.b ($90),Y
CMP.w #$0100
SEP #$20
BCC .on_screen
LDA.b #$F0 LDA.b #$0C : INY : STA.b ($90),Y
STA.b ($90),Y
.on_screen LDA.b #$32 : INY : STA.b ($90),Y
LDA.b #$0C LDA.b #$02 : STA.b ($92)
INY
STA.b ($90),Y
LDA.b #$32
INY
STA.b ($90),Y
LDA.b #$02
STA.b ($92)
RTS
RTS
}
WigglingTable: WigglingTable: