From c11e112a405e29ac264f9a0f1cd18dd9fa710b4d Mon Sep 17 00:00:00 2001 From: scawful Date: Wed, 27 Nov 2024 13:41:02 -0500 Subject: [PATCH] Fix bug with Sprite_SelectNewDirection data bank long jump --- Sprites/ZSpriteLib/sprite_functions.asm | 30 ++++++++----------------- Sprites/ZSpriteLib/sprite_macros.asm | 12 +++++----- Sprites/ZSpriteLib/sprite_new_table.asm | 22 +++++++----------- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/Sprites/ZSpriteLib/sprite_functions.asm b/Sprites/ZSpriteLib/sprite_functions.asm index e6adcad..44c8093 100644 --- a/Sprites/ZSpriteLib/sprite_functions.asm +++ b/Sprites/ZSpriteLib/sprite_functions.asm @@ -143,7 +143,7 @@ Sprite_FloatAwayFromPlayer: 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 SprCollision, X : AND.b #$0C : BEQ ++ @@ -168,34 +168,30 @@ Sprite_BounceOffWall: Sprite_InvertSpeed_XY: JSL Sprite_InvertSpeed_Y -; ========================================================= - Sprite_InvertSpeed_X: LDA.w SprXSpeed, X EOR.b #$FF INC A STA.w SprXSpeed, X - RTL -; ========================================================= - Sprite_InvertSpeed_Y: LDA.w SprYSpeed,X EOR.b #$FF INC A STA.w SprYSpeed,X - RTL ; ========================================================= Sprite_SelectNewDirection: { + PHB : PHK : PLB JSL GetRandomInt : AND.b #$07 : TAY LDA.w .speed_x, Y : STA.w SprXSpeed, X LDA.w .speed_y, Y : STA.w SprYSpeed, X LDA.w .timers, Y : STA.w SprTimerA, X + PLB RTL .speed_x @@ -277,9 +273,7 @@ DragPlayer: Sprite_DamageFlash_Long: { PHB : PHK : PLB - JSR Sprite_Damage_Flash - PLB RTL } @@ -292,15 +286,14 @@ Sprite_Damage_Flash: ; Change the palette to the next in the cycle LDA.w SprFlash, X : INC : CMP.b #$08 : BNE .dontReset LDA.b #$00 - - .dontReset + .dontReset STA.w SprFlash, X BRA .flash -.dontFlash + .dontFlash STZ.w SprFlash, X -.flash + .flash RTS } @@ -324,13 +317,10 @@ Link_CheckNewY_ButtonPress_Long: Link_SetupHitBox: { LDA.b #$08 : STA $02 : STA $03 - LDA $22 : CLC : ADC.b #$04 : STA $00 LDA $23 : ADC.b #$00 : STA $08 - LDA $20 : ADC.b #$08 : STA $01 LDA $21 : ADC.b #$00 : STA $09 - RTL } @@ -343,15 +333,11 @@ Sprite_SetupHitBox: PHY LDA.w SprHitbox, X : AND.b #$1F : TAY 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 SprY, X : CLC : ADC.w .offset_y_low, Y - PHP SEC : SBC.w SprHeight, X : STA.b $05 LDA.w SprYH, X : SBC.b #$00 - PLP ADC.w .offset_y_high, Y : STA.b $0B @@ -876,6 +862,7 @@ MovieEffect: } Sprite_CheckIfRecoiling: +{ PHB : PHK : PLB LDA.w $0EA0, X : BEQ .exit @@ -948,5 +935,6 @@ Sprite_CheckIfRecoiling: PLB RTL -.masks + .masks db $03, $01, $00, $00, $0C, $03 +} diff --git a/Sprites/ZSpriteLib/sprite_macros.asm b/Sprites/ZSpriteLib/sprite_macros.asm index ee7ddc4..9315474 100644 --- a/Sprites/ZSpriteLib/sprite_macros.asm +++ b/Sprites/ZSpriteLib/sprite_macros.asm @@ -53,7 +53,7 @@ endmacro macro PlayAnimation(frame_start, frame_end, frame_wait) LDA.w SprTimerB, X : BNE + LDA.w SprFrame, X : INC : STA.w SprFrame, X : CMP.b #+1 : BCC .noframereset - LDA.b # : STA.w SprFrame, X + LDA.b # : STA.w SprFrame, X .noframereset LDA.b # : STA.w SprTimerB, X + @@ -70,9 +70,9 @@ endmacro ; Return Carry Set if message is displayed ; can use BCC .label <> .label to see if message have been displayed macro ShowSolicitedMessage(message_id) - LDY.b #()>>8 - LDA.b # - JSL Sprite_ShowSolicitedMessageIfPlayerFacing + LDY.b #()>>8 + LDA.b # + JSL Sprite_ShowSolicitedMessageIfPlayerFacing endmacro macro ShowMessageOnContact(message_id) @@ -110,12 +110,12 @@ macro SetHarmless(value) LDA.w SprNbrOAM, X AND #$7F if != 0 - ORA.b #()<<7 + ORA.b #()<<7 endif STA.w SprNbrOAM, X 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 ; in that room unless you want it to be already opened/taken macro SetRoomFlag(value) diff --git a/Sprites/ZSpriteLib/sprite_new_table.asm b/Sprites/ZSpriteLib/sprite_new_table.asm index 8022bdb..8a26d43 100644 --- a/Sprites/ZSpriteLib/sprite_new_table.asm +++ b/Sprites/ZSpriteLib/sprite_new_table.asm @@ -1,24 +1,21 @@ pushpc org $06FFF8 ; New Jumptable for sprites NewMainSprFunction: -JSL SpriteActiveExp_MainLong -RTS + JSL SpriteActiveExp_MainLong + RTS org $068EB9 NewSprPrepFunction: -JSL Sprite_PrepExp_Long -RTS + JSL Sprite_PrepExp_Long + RTS pullpc SpriteActiveExp_MainLong: { PHB : PHK : PLB - JSL NewSprTable - PLB - RTL } @@ -34,8 +31,8 @@ NewSprTable: LDA NewSprRoutinesLong, Y ; Load sprite Address STA $06 - SEP #$20 ; Previously SEP #$30 -_- (that's fine for sprites below ~0x40 over that it will crash) - LDA NewSprRoutinesLong+2, Y + SEP #$20 + LDA NewSprRoutinesLong+2, Y STA $08 SEP #$30 JMP [$0006] @@ -46,18 +43,15 @@ NewSprTable: Sprite_PrepExp_Long: { PHB : PHK : PLB - JSL NewSprPrepTable - PLB - RTL } NewSprPrepTable: { LDA $0E20, X ; Load Sprite ID - REP #$30 + REP #$30 AND.w #$00FF STA $06 ASL A ; *2 @@ -67,7 +61,7 @@ NewSprPrepTable: LDA NewSprPrepRoutinesLong, Y ; Load sprite Address STA $06 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 SEP #$30 JMP [$0006]