Change HeadPos macros into functions

This commit is contained in:
scawful
2025-01-12 15:25:20 -05:00
parent 2f3faba1a6
commit ac855f7eeb

View File

@@ -52,11 +52,9 @@ Sprite_Manhandla_Long:
} }
pushpc pushpc
; Sprite_DoTheDeath#PrepareEnemyDrop.post_death_stuff ; Sprite_DoTheDeath#PrepareEnemyDrop.post_death_stuff
org $06FA25 org $06FA25
LDA.w $0E20, X : CMP.b #$88 LDA.w $0E20, X : CMP.b #$88
pullpc pullpc
; ========================================================= ; =========================================================
@@ -121,7 +119,7 @@ Sprite_Manhandla_CheckForNextPhaseOrDeath:
; ========================================================= ; =========================================================
macro SetLeftHeadPos() SetLeftHeadPos:
REP #$20 REP #$20
LDA.w SprCachedX : SEC : SBC.w #$0016 LDA.w SprCachedX : SEC : SBC.w #$0016
SEP #$20 SEP #$20
@@ -131,9 +129,9 @@ macro SetLeftHeadPos()
LDA.w SprCachedY : SEC : SBC.w #$000F LDA.w SprCachedY : SEC : SBC.w #$000F
SEP #$20 SEP #$20
STA.w SprY, Y : XBA : STA.w SprYH, Y STA.w SprY, Y : XBA : STA.w SprYH, Y
endmacro RTS
macro SetRightHeadPos() SetRightHeadPos:
REP #$20 REP #$20
LDA.w SprCachedX : CLC : ADC.w #$0016 LDA.w SprCachedX : CLC : ADC.w #$0016
SEP #$20 SEP #$20
@@ -143,9 +141,9 @@ macro SetRightHeadPos()
LDA.w SprCachedY : SEC : SBC.w #$000F LDA.w SprCachedY : SEC : SBC.w #$000F
SEP #$20 SEP #$20
STA.w SprY, Y : XBA : STA.w SprYH, Y STA.w SprY, Y : XBA : STA.w SprYH, Y
endmacro RTS
macro SetCenterHeadPos() SetCenterHeadPos:
REP #$20 REP #$20
LDA.w SprCachedX LDA.w SprCachedX
SEP #$20 SEP #$20
@@ -155,7 +153,7 @@ macro SetCenterHeadPos()
LDA.w SprCachedY LDA.w SprCachedY
SEP #$20 SEP #$20
STA.w SprY, Y : XBA : STA.w SprYH, Y STA.w SprY, Y : XBA : STA.w SprYH, Y
endmacro RTS
Sprite_Manhandla_Main: Sprite_Manhandla_Main:
{ {
@@ -257,7 +255,7 @@ Sprite_Manhandla_Main:
LDY.w Offspring3_Id LDY.w Offspring3_Id
LDA.w SprType, Y : CMP.b #$88 : BNE .not_head3 LDA.w SprType, Y : CMP.b #$88 : BNE .not_head3
LDA.w SprState, Y : BEQ .offspring3_dead LDA.w SprState, Y : BEQ .offspring3_dead
%SetCenterHeadPos() JSR SetCenterHeadPos
.offspring3_dead .offspring3_dead
.not_head3 .not_head3
@@ -267,16 +265,16 @@ Sprite_Manhandla_Main:
Flower_Flicker: Flower_Flicker:
{ {
%PlayAnimation(11, 12, 10) %PlayAnimation(11, 12, 10)
LDA $1C : ORA.b #$01 : STA $1C ;turn on BG2 (Body) LDA $1C : ORA.b #$01 : STA $1C ; turn on BG2 (Body)
; Flicker the body every other frame using the timer ; Flicker the body every other frame using the timer
LDA.w SprTimerA, X : AND.b #$01 : BEQ .flicker LDA.w SprTimerA, X : AND.b #$01 : BEQ .flicker
LDA $1C : AND.b #$FE : STA $1C ;turn off BG2 (Body) LDA $1C : AND.b #$FE : STA $1C ; turn off BG2 (Body)
.flicker .flicker
LDA.w SprTimerA, X : BNE .continue LDA.w SprTimerA, X : BNE .continue
STZ.w $0422 STZ.w $0422
STZ.w $0424 STZ.w $0424
LDA $1C : AND.b #$FE : STA $1C ;turn off BG2 (Body) LDA $1C : AND.b #$FE : STA $1C ; turn off BG2 (Body)
%GotoAction($04) %GotoAction($04)
LDA.b #$10 : STA.w SprTimerC, X LDA.b #$10 : STA.w SprTimerC, X
@@ -285,27 +283,19 @@ Sprite_Manhandla_Main:
LDA #$88 LDA #$88
JSL Sprite_SpawnDynamically : BMI .return JSL Sprite_SpawnDynamically : BMI .return
TYA : STA.w Offspring3_Id TYA : STA.w Offspring3_Id
PHX PHX
%SetCenterHeadPos() JSR SetCenterHeadPos
LDA.b #$08 : STA.w SprSubtype, Y LDA.b #$08 : STA.w SprSubtype, Y
STA.w SprAction, Y STA.w SprAction, Y
LDA.b #$20 : STA.w SprHealth, Y LDA.b #$20 : STA.w SprHealth, Y
LDA.b #$07 : STA.w SprNbrOAM, Y LDA.b #$07 : STA.w SprNbrOAM, Y
LDA.w SprY, Y : CLC : ADC.b #$20 : STA.w SprY, Y LDA.w SprY, Y : CLC : ADC.b #$20 : STA.w SprY, Y
LDA.b #$10 : STA.w SprTimerC, Y LDA.b #$10 : STA.w SprTimerC, Y
TYX TYX
STZ.w SprYRound, X STZ.w SprYRound, X
STZ.w SprXRound, X STZ.w SprXRound, X
PLX PLX
.return .return
.continue .continue
RTS RTS
} }
@@ -328,54 +318,47 @@ Sprite_Manhandla_Main:
LDY.w Offspring1_Id LDY.w Offspring1_Id
LDA.w SprType, Y : CMP.b #$88 : BNE .not_head LDA.w SprType, Y : CMP.b #$88 : BNE .not_head
LDA.w SprState, Y : BEQ .offspring1_dead LDA.w SprState, Y : BEQ .offspring1_dead
%SetLeftHeadPos() JSR SetLeftHeadPos
.offspring1_dead .offspring1_dead
.not_head .not_head
LDY.w Offspring2_Id LDY.w Offspring2_Id
LDA.w SprType, Y : CMP.b #$88 : BNE .not_head2 LDA.w SprType, Y : CMP.b #$88 : BNE .not_head2
LDA.w SprState, Y : BEQ .offspring2_dead LDA.w SprState, Y : BEQ .offspring2_dead
%SetRightHeadPos() JSR SetRightHeadPos
.offspring2_dead .offspring2_dead
.not_head2 .not_head2
LDY.w Offspring3_Id LDY.w Offspring3_Id
LDA.w SprType, Y : CMP.b #$88 : BNE .not_head3 LDA.w SprType, Y : CMP.b #$88 : BNE .not_head3
LDA.w SprState, Y : BEQ .offspring3_dead LDA.w SprState, Y : BEQ .offspring3_dead
%SetCenterHeadPos() JSR SetCenterHeadPos
.offspring3_dead .offspring3_dead
.not_head3 .not_head3
PLX PLX
RTS RTS
} }
BigChuchu_Emerge: BigChuchu_Emerge:
{ {
%PlayAnimation(9, 12, 10) %PlayAnimation(9, 12, 10)
JSL Sprite_DamageFlash_Long JSL Sprite_DamageFlash_Long
LDA.w SprTimerA, X : BNE + LDA.w SprTimerA, X : BNE +
LDA.b #$02 : STA.w SprMiscD, X ; Set phase flag LDA.b #$02 : STA.w SprMiscD, X ; Set phase flag
LDA.b #$20 : STA.w SprTimerA, X LDA.b #$20 : STA.w SprTimerA, X
%GotoAction($05) %GotoAction($05)
+ +
RTS RTS
} }
BigChuchu_Flower: BigChuchu_Flower:
{ {
%PlayAnimation(12, 12, 1) %PlayAnimation(12, 12, 1)
JSL Sprite_DamageFlash_Long JSL Sprite_DamageFlash_Long
LDA.w SprTimerC, X : BEQ + LDA.w SprTimerC, X : BEQ +
LDA.w SprY, X : DEC : STA.w SprY, X LDA.w SprY, X : DEC : STA.w SprY, X
+ +
RTS RTS
} }
@@ -391,11 +374,8 @@ Sprite_Manhandla_Main:
ChuchuBlast: ChuchuBlast:
{ {
%PlayAnimation(3, 4, 4) %PlayAnimation(3, 4, 4)
JSL Sprite_Move JSL Sprite_Move
%DoDamageToPlayerSameLayerOnContact() %DoDamageToPlayerSameLayerOnContact()
RTS RTS
} }
} }
@@ -579,9 +559,6 @@ Sprite_Manhandla_Draw:
RTS RTS
; =========================================================
.start_index .start_index
db $00, $02, $04, $08, $0C, $10, $14, $17, $1A, $1D, $23, $29, $33 db $00, $02, $04, $08, $0C, $10, $14, $17, $1A, $1D, $23, $29, $33
.nbr_of_tiles .nbr_of_tiles
@@ -719,7 +696,6 @@ Sprite_BigChuchu_Draw:
RTS RTS
; =======================================================
.start_index .start_index
db $00, $09, $12, $1B, $1C db $00, $09, $12, $1B, $1C
.nbr_of_tiles .nbr_of_tiles
@@ -761,12 +737,8 @@ Chuchu_SpawnBlast:
PHX PHX
LDA.b #$88 LDA.b #$88
JSL Sprite_SpawnDynamically : BMI .return JSL Sprite_SpawnDynamically : BMI .return
LDA.b #$0A : STA.w SprSubtype, Y : STA.w SprAction, Y
LDA.b #$0A : STA.w SprSubtype, Y
STA.w SprAction, Y
JSL GetRandomInt : AND.b #$01 : TAX JSL GetRandomInt : AND.b #$01 : TAX
LDA.w .speed_and_offset_x, X : STA.w SprXSpeed, Y LDA.w .speed_and_offset_x, X : STA.w SprXSpeed, Y
LDA.w SprX, Y : CLC : ADC.w .speed_and_offset_x, X : STA.w SprX, Y LDA.w SprX, Y : CLC : ADC.w .speed_and_offset_x, X : STA.w SprX, Y
STA.w SprXRound, Y STA.w SprXRound, Y
@@ -779,12 +751,10 @@ Chuchu_SpawnBlast:
LDA.b #$10 : STA.w SprTimerB, Y LDA.b #$10 : STA.w SprTimerB, Y
LDA.b #$00 : STA.w SprNbrOAM, Y LDA.b #$00 : STA.w SprNbrOAM, Y
LDA.b #$03 : STA.w SprHitbox, Y LDA.b #$03 : STA.w SprHitbox, Y
.return .return
PLX PLX
RTS RTS
.speed_and_offset_x .speed_and_offset_x
db -16, 16 db -16, 16
@@ -797,43 +767,27 @@ Mothula_SpawnBeams:
LDA.b #$36 ; SFX3.36 LDA.b #$36 ; SFX3.36
JSL $0DBB8A ; SpriteSFX_QueueSFX3WithPan JSL $0DBB8A ; SpriteSFX_QueueSFX3WithPan
LDA.b #$02 LDA.b #$02 : STA.w $0FB5
STA.w $0FB5
.next_spawn .next_spawn
LDA.b #$89 ; SPRITE 89 LDA.b #$89 ; SPRITE 89
JSL Sprite_SpawnDynamically JSL Sprite_SpawnDynamically : BMI .no_space
BMI .no_space JSL Sprite_SetSpawnedCoordinates
LDA.b $02 : SEC : SBC.b $04
CLC : ADC.b #$03 : STA.w SprY,Y
LDA.b #$10 : STA.w SprTimerA,Y : STA.w SprBulletproof,Y
JSL Sprite_SetSpawnedCoordinates PHX
LDX.w $0FB5
LDA.b $02 : SEC : SBC.b $04 LDA.b $00 : CLC : ADC.w .speed_and_offset_x,X : STA.w SprX,Y
LDA.w .speed_and_offset_x,X : STA.w SprXSpeed,Y
CLC : ADC.b #$03 : STA.w SprY,Y LDA.w .speed_y,X : STA.w SprYSpeed,Y
LDA.b #$00 : STA.w SprHeight,Y
LDA.b #$10 : STA.w SprTimerA,Y : STA.w SprBulletproof,Y PLX
PHX
LDX.w $0FB5
LDA.b $00 : CLC : ADC.w .speed_and_offset_x,X
STA.w SprX,Y
LDA.w .speed_and_offset_x,X : STA.w SprXSpeed,Y
LDA.w .speed_y,X
STA.w SprYSpeed,Y
LDA.b #$00
STA.w SprHeight,Y
PLX
.no_space .no_space
DEC.w $0FB5 DEC.w $0FB5
BPL .next_spawn BPL .next_spawn
RTS RTS
.speed_and_offset_x .speed_and_offset_x
db -20, 0, 20 db -20, 0, 20
@@ -845,23 +799,19 @@ Mothula_SpawnBeams:
SpawnLeftManhandlaHead: SpawnLeftManhandlaHead:
{ {
LDA #$88 LDA #$88
JSL Sprite_SpawnDynamically : BMI .return JSL Sprite_SpawnDynamically : BMI .return
TYA : STA.w Offspring1_Id TYA : STA.w Offspring1_Id
PHX PHX
%SetLeftHeadPos() JSR SetLeftHeadPos
; store the sub-type
LDA.b #$03 : STA.w SprSubtype, Y LDA.b #$03 : STA.w SprSubtype, Y
STA.w SprAction, Y STA.w SprAction, Y
LDA.b #$14 : STA.w SprHealth, Y LDA.b #$14 : STA.w SprHealth, Y
LDA.b #$90 : STA.w SprTileDie, Y LDA.b #$90 : STA.w SprTileDie, Y
LDA.w SprGfxProps : ORA.b #$80 : STA.w SprGfxProps, Y LDA.w SprGfxProps : ORA.b #$80 : STA.w SprGfxProps, Y
TYX TYX
STZ.w SprYRound, X STZ.w SprYRound, X
STZ.w SprXRound, X STZ.w SprXRound, X
PLX PLX
.return .return
RTS RTS
} }
@@ -871,17 +821,14 @@ SpawnRightManhandlaHead:
LDA #$88 LDA #$88
JSL Sprite_SpawnDynamically : BMI .return JSL Sprite_SpawnDynamically : BMI .return
TYA : STA.w Offspring2_Id TYA : STA.w Offspring2_Id
PHX PHX
%SetRightHeadPos() JSR SetRightHeadPos
LDA.b #$02 LDA.b #$02
STA.w SprSubtype, Y STA.w SprSubtype, Y
LDA.b #$14 : STA.w SprHealth, Y LDA.b #$14 : STA.w SprHealth, Y
LDA.b #$90 : STA.w SprTileDie, Y LDA.b #$90 : STA.w SprTileDie, Y
LDA.w SprGfxProps : AND.b #$80 : STA.w SprGfxProps, Y LDA.w SprGfxProps : AND.b #$80 : STA.w SprGfxProps, Y
TYX TYX
STZ.w SprYRound, X STZ.w SprYRound, X
STZ.w SprXRound, X STZ.w SprXRound, X
PLX PLX
@@ -894,18 +841,14 @@ SpawnCenterMandhandlaHead:
LDA #$88 LDA #$88
JSL Sprite_SpawnDynamically : BMI .return JSL Sprite_SpawnDynamically : BMI .return
TYA : STA.w Offspring3_Id TYA : STA.w Offspring3_Id
PHX PHX
%SetCenterHeadPos() JSR SetCenterHeadPos
LDA.b #$01 LDA.b #$01
STA.w SprSubtype, Y STA.w SprSubtype, Y
LDA.b #$14 : STA.w SprHealth, Y LDA.b #$14 : STA.w SprHealth, Y
LDA.b #$90 : STA.w SprTileDie, Y LDA.b #$90 : STA.w SprTileDie, Y
LDA.w SprGfxProps : AND.b #$80 : STA.w SprGfxProps, Y LDA.w SprGfxProps : AND.b #$80 : STA.w SprGfxProps, Y
TYX TYX
STZ.w SprYRound, X STZ.w SprYRound, X
STZ.w SprXRound, X STZ.w SprXRound, X
PLX PLX
@@ -915,45 +858,40 @@ SpawnCenterMandhandlaHead:
ApplyManhandlaPalette: ApplyManhandlaPalette:
{ {
REP #$20 ;Set A in 16bit mode REP #$20 ;Set A in 16bit mode
; note, this uses adresses like 7EC300 and not 7EC500 because the game
;note, this uses adresses like 7EC300 and not 7EC500 because the game ; will fade the colors into 7EC500 based on the colors found in 7EC300
;will fade the colors into 7EC500 based on the colors found in 7EC300 LDA #$7FFF : STA $7EC5E2 ;BG2
LDA #$08D9 : STA $7EC5E4
LDA #$7FFF : STA $7EC5E2 ;BG2 LDA #$1E07 : STA $7EC5E6
LDA #$08D9 : STA $7EC5E4 LDA #$4ACA : STA $7EC5E8
LDA #$1E07 : STA $7EC5E6 LDA #$14A5 : STA $7EC5EA
LDA #$4ACA : STA $7EC5E8 LDA #$133F : STA $7EC5EC
LDA #$14A5 : STA $7EC5EA LDA #$19DF : STA $7EC5EE
LDA #$133F : STA $7EC5EC INC $15
LDA #$19DF : STA $7EC5EE SEP #$20 ;Set A in 8bit mode
RTS
INC $15
SEP #$20 ;Set A in 8bit mode
RTS
} }
ApplyManhandlaGraphics: ApplyManhandlaGraphics:
{ {
PHX PHX
REP #$20 ; A = 16, XY = 8 REP #$20 ; A = 16, XY = 8
LDX #$80 : STX $2100 ; turn the screen off (required) LDX #$80 : STX $2100 ; turn the screen off (required)
LDX #$80 : STX $2115 ; Set the video port register every time we write it increase by 1 LDX #$80 : STX $2115 ; Set the video port register every time we write it increase by 1
LDA #$5000 : STA $2116 ; Destination of the DMA $5800 in vram <- this need to be divided by 2 LDA #$5000 : STA $2116 ; Destination of the DMA $5800 in vram, need to be divided by 2
LDA #$1801 : STA $4300 ; DMA Transfer Mode and destination register LDA #$1801 : STA $4300 ; DMA Transfer Mode and destination register
; "001 => 2 registers write once (2 bytes: p, p+1)" ; "001 => 2 registers write once (2 bytes: p, p+1)"
LDA.w #ManhandlaGraphics : STA $4302 LDA.w #ManhandlaGraphics : STA $4302
LDX.b #ManhandlaGraphics>>16 : STX $4304 LDX.b #ManhandlaGraphics>>16 : STX $4304
LDA #$2000 : STA $4305 ; Size of the transfer 4 sheets of $800 each LDA #$2000 : STA $4305 ; Size of the transfer 4 sheets of $800 each
LDX #$01 : STX $420B ; Do the DMA LDX #$01 : STX $420B ; Do the DMA
LDX #$0F : STX $2100 ; Turn the screen back on LDX #$0F : STX $2100 ; Turn the screen back on
SEP #$30 SEP #$30
PLX PLX
RTS RTS
ManhandlaGraphics: ManhandlaGraphics:
incbin manhandla.bin incbin manhandla.bin