Fix bug with Sprite_SelectNewDirection data bank long jump

This commit is contained in:
scawful
2024-11-27 13:41:02 -05:00
parent 834da79237
commit c11e112a40
3 changed files with 23 additions and 41 deletions

View File

@@ -143,7 +143,7 @@ Sprite_FloatAwayFromPlayer:
Sprite_BounceFromTileCollision: Sprite_BounceFromTileCollision:
{ {
JSL Sprite_CheckTileCollision : AND.b #$03 : BEQ ++ JSL Sprite_CheckTileCollision : AND.b #$03 : BEQ ++
LDA.w SprXSpeed, X : EOR.b #$FF : INC : STA.w SprXSpeed, X LDA.w SprXSpeed, X : EOR.b #$FF : INC : STA.w SprXSpeed, X
++ LDA.w SprCollision, X : AND.b #$0C : BEQ ++ ++ LDA.w SprCollision, X : AND.b #$0C : BEQ ++
@@ -168,34 +168,30 @@ Sprite_BounceOffWall:
Sprite_InvertSpeed_XY: Sprite_InvertSpeed_XY:
JSL Sprite_InvertSpeed_Y JSL Sprite_InvertSpeed_Y
; =========================================================
Sprite_InvertSpeed_X: Sprite_InvertSpeed_X:
LDA.w SprXSpeed, X LDA.w SprXSpeed, X
EOR.b #$FF EOR.b #$FF
INC A INC A
STA.w SprXSpeed, X STA.w SprXSpeed, X
RTL RTL
; =========================================================
Sprite_InvertSpeed_Y: Sprite_InvertSpeed_Y:
LDA.w SprYSpeed,X LDA.w SprYSpeed,X
EOR.b #$FF EOR.b #$FF
INC A INC A
STA.w SprYSpeed,X STA.w SprYSpeed,X
RTL RTL
; ========================================================= ; =========================================================
Sprite_SelectNewDirection: Sprite_SelectNewDirection:
{ {
PHB : PHK : PLB
JSL GetRandomInt : AND.b #$07 : TAY JSL GetRandomInt : AND.b #$07 : TAY
LDA.w .speed_x, Y : STA.w SprXSpeed, X LDA.w .speed_x, Y : STA.w SprXSpeed, X
LDA.w .speed_y, Y : STA.w SprYSpeed, X LDA.w .speed_y, Y : STA.w SprYSpeed, X
LDA.w .timers, Y : STA.w SprTimerA, X LDA.w .timers, Y : STA.w SprTimerA, X
PLB
RTL RTL
.speed_x .speed_x
@@ -277,9 +273,7 @@ DragPlayer:
Sprite_DamageFlash_Long: Sprite_DamageFlash_Long:
{ {
PHB : PHK : PLB PHB : PHK : PLB
JSR Sprite_Damage_Flash JSR Sprite_Damage_Flash
PLB PLB
RTL RTL
} }
@@ -292,15 +286,14 @@ Sprite_Damage_Flash:
; Change the palette to the next in the cycle ; Change the palette to the next in the cycle
LDA.w SprFlash, X : INC : CMP.b #$08 : BNE .dontReset LDA.w SprFlash, X : INC : CMP.b #$08 : BNE .dontReset
LDA.b #$00 LDA.b #$00
.dontReset
.dontReset
STA.w SprFlash, X STA.w SprFlash, X
BRA .flash BRA .flash
.dontFlash .dontFlash
STZ.w SprFlash, X STZ.w SprFlash, X
.flash .flash
RTS RTS
} }
@@ -324,13 +317,10 @@ Link_CheckNewY_ButtonPress_Long:
Link_SetupHitBox: Link_SetupHitBox:
{ {
LDA.b #$08 : STA $02 : STA $03 LDA.b #$08 : STA $02 : STA $03
LDA $22 : CLC : ADC.b #$04 : STA $00 LDA $22 : CLC : ADC.b #$04 : STA $00
LDA $23 : ADC.b #$00 : STA $08 LDA $23 : ADC.b #$00 : STA $08
LDA $20 : ADC.b #$08 : STA $01 LDA $20 : ADC.b #$08 : STA $01
LDA $21 : ADC.b #$00 : STA $09 LDA $21 : ADC.b #$00 : STA $09
RTL RTL
} }
@@ -343,15 +333,11 @@ Sprite_SetupHitBox:
PHY PHY
LDA.w SprHitbox, X : AND.b #$1F : TAY LDA.w SprHitbox, X : AND.b #$1F : TAY
LDA.w SprX, X : CLC : ADC.w .offset_x_low, Y : STA.b $04 LDA.w SprX, X : CLC : ADC.w .offset_x_low, Y : STA.b $04
LDA.w SprXH, X : ADC.w .offset_x_high, Y : STA.b $0A LDA.w SprXH, X : ADC.w .offset_x_high, Y : STA.b $0A
LDA.w SprY, X : CLC : ADC.w .offset_y_low, Y LDA.w SprY, X : CLC : ADC.w .offset_y_low, Y
PHP PHP
SEC : SBC.w SprHeight, X : STA.b $05 SEC : SBC.w SprHeight, X : STA.b $05
LDA.w SprYH, X : SBC.b #$00 LDA.w SprYH, X : SBC.b #$00
PLP PLP
ADC.w .offset_y_high, Y : STA.b $0B ADC.w .offset_y_high, Y : STA.b $0B
@@ -876,6 +862,7 @@ MovieEffect:
} }
Sprite_CheckIfRecoiling: Sprite_CheckIfRecoiling:
{
PHB : PHK : PLB PHB : PHK : PLB
LDA.w $0EA0, X : BEQ .exit LDA.w $0EA0, X : BEQ .exit
@@ -948,5 +935,6 @@ Sprite_CheckIfRecoiling:
PLB PLB
RTL RTL
.masks .masks
db $03, $01, $00, $00, $0C, $03 db $03, $01, $00, $00, $0C, $03
}

View File

@@ -53,7 +53,7 @@ endmacro
macro PlayAnimation(frame_start, frame_end, frame_wait) 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 : CMP.b #<frame_end>+1 : BCC .noframereset LDA.w SprFrame, X : INC : STA.w SprFrame, X : CMP.b #<frame_end>+1 : BCC .noframereset
LDA.b #<frame_start> : STA.w SprFrame, X LDA.b #<frame_start> : STA.w SprFrame, X
.noframereset .noframereset
LDA.b #<frame_wait> : STA.w SprTimerB, X LDA.b #<frame_wait> : STA.w SprTimerB, X
+ +
@@ -70,9 +70,9 @@ endmacro
; Return Carry Set if message is displayed ; Return Carry Set if message is displayed
; can use BCC .label <> .label to see if message have been displayed ; can use BCC .label <> .label to see if message have been displayed
macro ShowSolicitedMessage(message_id) macro ShowSolicitedMessage(message_id)
LDY.b #(<message_id>)>>8 LDY.b #(<message_id>)>>8
LDA.b #<message_id> LDA.b #<message_id>
JSL Sprite_ShowSolicitedMessageIfPlayerFacing JSL Sprite_ShowSolicitedMessageIfPlayerFacing
endmacro endmacro
macro ShowMessageOnContact(message_id) macro ShowMessageOnContact(message_id)
@@ -110,12 +110,12 @@ macro SetHarmless(value)
LDA.w SprNbrOAM, X LDA.w SprNbrOAM, X
AND #$7F AND #$7F
if <value> != 0 if <value> != 0
ORA.b #(<value>)<<7 ORA.b #(<value>)<<7
endif endif
STA.w SprNbrOAM, X STA.w SprNbrOAM, X
endmacro endmacro
; Set Room Flag (Chest 6) ; Set Room Flag (Chest 6)
; Do not use if you have more than 5 chests or a small key under a pot ; Do not use if you have more than 5 chests or a small key under a pot
; in that room unless you want it to be already opened/taken ; in that room unless you want it to be already opened/taken
macro SetRoomFlag(value) macro SetRoomFlag(value)

View File

@@ -1,24 +1,21 @@
pushpc pushpc
org $06FFF8 ; New Jumptable for sprites org $06FFF8 ; New Jumptable for sprites
NewMainSprFunction: NewMainSprFunction:
JSL SpriteActiveExp_MainLong JSL SpriteActiveExp_MainLong
RTS RTS
org $068EB9 org $068EB9
NewSprPrepFunction: NewSprPrepFunction:
JSL Sprite_PrepExp_Long JSL Sprite_PrepExp_Long
RTS RTS
pullpc pullpc
SpriteActiveExp_MainLong: SpriteActiveExp_MainLong:
{ {
PHB : PHK : PLB PHB : PHK : PLB
JSL NewSprTable JSL NewSprTable
PLB PLB
RTL RTL
} }
@@ -34,8 +31,8 @@ NewSprTable:
LDA NewSprRoutinesLong, Y ; Load sprite Address LDA NewSprRoutinesLong, Y ; Load sprite Address
STA $06 STA $06
SEP #$20 ; Previously SEP #$30 -_- (that's fine for sprites below ~0x40 over that it will crash) SEP #$20
LDA NewSprRoutinesLong+2, Y LDA NewSprRoutinesLong+2, Y
STA $08 STA $08
SEP #$30 SEP #$30
JMP [$0006] JMP [$0006]
@@ -46,18 +43,15 @@ NewSprTable:
Sprite_PrepExp_Long: Sprite_PrepExp_Long:
{ {
PHB : PHK : PLB PHB : PHK : PLB
JSL NewSprPrepTable JSL NewSprPrepTable
PLB PLB
RTL RTL
} }
NewSprPrepTable: NewSprPrepTable:
{ {
LDA $0E20, X ; Load Sprite ID LDA $0E20, X ; Load Sprite ID
REP #$30 REP #$30
AND.w #$00FF AND.w #$00FF
STA $06 STA $06
ASL A ; *2 ASL A ; *2
@@ -67,7 +61,7 @@ NewSprPrepTable:
LDA NewSprPrepRoutinesLong, Y ; Load sprite Address LDA NewSprPrepRoutinesLong, Y ; Load sprite Address
STA $06 STA $06
SEP #$20 ; Previously SEP #$30 -_- (that's fine for sprites below ~0x40 over that it will crash) SEP #$20 ; Previously SEP #$30 -_- (that's fine for sprites below ~0x40 over that it will crash)
LDA NewSprPrepRoutinesLong+2, Y LDA NewSprPrepRoutinesLong+2, Y
STA $08 STA $08
SEP #$30 SEP #$30
JMP [$0006] JMP [$0006]