cleanup twinrova, optimize action size

This commit is contained in:
scawful
2024-06-30 14:16:11 -04:00
parent 79b73163d4
commit e9f9f04655

View File

@@ -83,19 +83,19 @@ Sprite_Twinrova_Prep:
; Kill the sprite if the Maiden is present
LDA.l $7EF3CC : CMP.b #$06 : BNE .prep_twinrova
STZ.w $0DD0, X
.prep_twinrova
LDA.b #$5A : STA.w SprHealth, X ; Health
LDA.b #$80 : STA $0CAA, X
LDA.b #$04 : STA $0CD2, X ; Bump damage type (4 hearts, green tunic)
LDA $0E60, X : AND.b #$BF : STA $0E60, X ; Not invincible
LDA.w $0E60, X : AND.b #$BF : STA.w $0E60, X ; Not invincible
%SetSpriteSpeedX(15)
%SetSpriteSpeedX(15)
; Blind Boss startup configuration
LDA #$10 : STA $08
LDA #$10 : STA $09
LDA.b #$10 : STA $08
LDA.b #$10 : STA $09
LDA.b #$60 : STA.w SprTimerC, X
LDA.b #$01 : STA.w SprMiscB, X
@@ -156,6 +156,9 @@ endmacro
Sprite_Twinrova_Main:
{
JSL Sprite_PlayerCantPassThrough
JSL Sprite_DamageFlash_Long
LDA.w SprAction, X
JSL UseImplicitRegIndexedLocalJumpTable
@@ -252,12 +255,9 @@ Sprite_Twinrova_Main:
%DoDamageToPlayerSameLayerOnContact()
PLX
JSL Sprite_DamageFlash_Long
LDA #$10 ; Set speed
JSL Sprite_FloatTowardPlayer
JSL Sprite_CheckTileCollision
JSL Sprite_PlayerCantPassThrough
%GotoAction(1)
RTS
@@ -274,12 +274,9 @@ Sprite_Twinrova_Main:
%DoDamageToPlayerSameLayerOnContact()
PLX
JSL Sprite_DamageFlash_Long
LDA #$20
JSL Sprite_FloatTowardPlayer
JSL Sprite_CheckTileCollision
JSL Sprite_PlayerCantPassThrough
%GotoAction(1)
RTS
@@ -294,8 +291,6 @@ Sprite_Twinrova_Main:
LDA #$01 : STA $0360
JSL Sprite_PlayerCantPassThrough
LDA $0CAA : AND.b #$03 : STA $0CAA
LDA SprTimerD, X : BNE +
LDA $0CAA : ORA.b #$03 : STA $0CAA
@@ -317,7 +312,6 @@ Sprite_Twinrova_Main:
%Twinrova_Ready()
JSR Sprite_Twinrova_FireAttack
JSL Sprite_PlayerCantPassThrough
; Random chance to release fireball
JSL GetRandomInt : AND.b #$3F : BNE ++
@@ -338,7 +332,6 @@ Sprite_Twinrova_Main:
%Twinrova_Ready()
JSR Sprite_Twinrova_IceAttack
JSL Sprite_PlayerCantPassThrough
LDA.w SprTimerD, X : BNE +
%GotoAction(1)
@@ -353,9 +346,6 @@ Sprite_Twinrova_Main:
%StartOnFrame(10)
%Twinrova_Hurt()
JSL Sprite_DamageFlash_Long
JSL Sprite_PlayerCantPassThrough
; Check if hurt timer is zero, if not keep flashing hurt animation
LDA.w SprTimerD, X : BNE .HurtAnimation
@@ -427,7 +417,7 @@ Sprite_Twinrova_Main:
JSL Sprite_SpawnFireball
+++
JSL Sprite_DamageFlash_Long
JSR RageModeMove
LDA SprTimerD, X : BNE +
@@ -458,7 +448,6 @@ Sprite_Twinrova_Main:
++
.not_below
JSL Sprite_DamageFlash_Long
JSR RageModeMove
JSL GetRandomInt : AND.b #$0F : BNE +++
@@ -500,7 +489,7 @@ RageModeMove:
JMP .UpdatePosition
.DetermineMovementMode
.DetermineMovementMode
; Determine random movement mode with weighted probabilities
JSL GetRandomInt
AND.b #$0F
@@ -516,33 +505,33 @@ RageModeMove:
RTS
BRA .StayInPlace
.SetMoveTowardsPlayer
.SetMoveTowardsPlayer
LDA.b #$01 : STA.w SprMiscA, X
LDA.b #$30 : STA.w SprTimerA, X ; Set timer for 48 frames
BRA .MoveTowardsPlayer
.SetRandomStrafe
.SetRandomStrafe
LDA.b #$02 : STA.w SprMiscA, X
LDA.b #$30 : STA.w SprTimerA, X ; Set timer for 48 frames
BRA .RandomStrafe
.SetRandomDodge
.SetRandomDodge
LDA.b #$03 : STA.w SprMiscA, X
LDA.b #$30 : STA.w SprTimerA, X ; Set timer for 48 frames
BRA .RandomDodge
.MoveTowardsPlayer
.MoveTowardsPlayer
; Predictive movement towards player with altitude increase
JSL Sprite_DirectionToFacePlayer
JSL Sprite_ApplySpeedTowardsPlayer
LDA.b #$10 : STA.w SprHeight, X ; Set height
BRA .UpdatePosition
.RandomStrafe
.RandomStrafe
JSR DoRandomStrafe
BRA .UpdatePosition
.RandomDodge
.RandomDodge
; Random dodge with controlled movement
JSL GetRandomInt
AND.b #$03
@@ -553,14 +542,14 @@ RageModeMove:
LDA.b #$10 : STA.w SprHeight, X ; Set height
BRA .UpdatePosition
.StayInPlace
.StayInPlace
; Stay in place to prepare for attack or other action
STZ.w SprXSpeed, X
STZ.w SprYSpeed, X
LDA.b #$10 : STA.w SprHeight, X ; Set height
BRA .UpdatePosition
.Evasive
.Evasive
; Evasive action if too close to player
JSL GetRandomInt
AND.b #$03
@@ -571,13 +560,13 @@ RageModeMove:
LDA.b #$10 : STA.w SprHeight, X ; Set height
BRA .UpdatePosition
.UpdatePosition
.UpdatePosition
; Handle floaty movement with controlled altitude
LDA.w SprHeight, X : CMP #$10 : BNE .CheckGrounded
DEC.w SprHeight, X
DEC.w $0F90, X
.CheckGrounded
.CheckGrounded
; Move sprite
JSL Sprite_Move
@@ -623,8 +612,7 @@ TrinexxBreath_AltEntry:
TAY
LDA SpeedAdjustments, Y : CLC : ADC $0D50, X : STA $0D50, X
LDA SpeedAdjustments+4, Y : CLC : ADC $0D40, X : STA $0D40, X
.no_adjustment
.no_adjustment
JSL Sprite_BounceFromTileCollision
LDA $1A : AND.b #$03 : BNE .no_shake
@@ -652,9 +640,10 @@ TrinexxBreath_AltEntry:
.shake_y
db 0, -1
; Adjustments for xy speeds (small positive, small negative)
SpeedAdjustments:
db $02, $FE, $04, $FC ; Adjustments for X speeds (small positive, small negative)
db $01, $FF, $02, $FE ; Adjustments for Y speeds (small positive, small negative)
db $02, $FE, $04, $FC ; X
db $01, $FF, $02, $FE ; Y
}
Sprite_Twinrova_FireAttack: