Update poltergeist enemies

This commit is contained in:
scawful
2024-01-25 19:24:28 -05:00
parent 9eb715e85b
commit 77eaebdc2b

View File

@@ -1,7 +1,5 @@
;==============================================================================
; Sprite Properties !SPRID = $A4; The sprite ID you are overwriting (HEX)
;==============================================================================
!SPRID = $B6 ; The sprite ID you are overwriting (HEX)
!NbrTiles = 4 ; Number of tiles used in a frame !NbrTiles = 4 ; Number of tiles used in a frame
!Harmless = 00 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless !Harmless = 00 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless
!HVelocity = 00 ; Is your sprite going super fast? put 01 if it is !HVelocity = 00 ; Is your sprite going super fast? put 01 if it is
@@ -28,29 +26,28 @@
!ImperviousArrow = 00 ; 01 = Impervious to arrows !ImperviousArrow = 00 ; 01 = Impervious to arrows
!ImpervSwordHammer = 00 ; 01 = Impervious to sword and hammer attacks !ImpervSwordHammer = 00 ; 01 = Impervious to sword and hammer attacks
!Boss = 00 ; 00 = normal sprite, 01 = sprite is a boss !Boss = 00 ; 00 = normal sprite, 01 = sprite is a boss
%Set_Sprite_Properties(Sprite_Poltergeist_Prep, Sprite_Poltergeist_Long); %Set_Sprite_Properties(Sprite_Poltergeist_Prep, Sprite_Poltergeist_Long)
;==================================================================================================
; Sprite Long Hook for that sprite
; --------------------------------------------------------------------------------------------------
; This code can be left unchanged
; handle the draw code and if the sprite is active and should move or not
;==================================================================================================
Sprite_Poltergeist_Long: Sprite_Poltergeist_Long:
{ {
PHB : PHK : PLB PHB : PHK : PLB
JSR Sprite_Poltergeist_Draw ; Call the draw code JSR Sprite_Poltergeist_Draw ; Call the draw code
LDA $E0 : CMP #$F0 : BNE .onscreen LDA $E0 : CMP #$F0 : BNE .onscreen
LDA.w SprMiscA, X : BEQ .SpriteIsNotActive LDA.w SprMiscA, X : BEQ .SpriteIsNotActive
STZ.w SprState, X ; kill the sprite if offscreen and activated STZ.w SprState, X ; kill the sprite if offscreen and activated
.onscreen
JSL Sprite_CheckActive ; Check if game is not paused
BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive
.onscreen
JSL Sprite_CheckActive ; Check if game is not paused
BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive
JSR Sprite_Poltergeist_Main ; Call the main sprite code JSR Sprite_Poltergeist_Main ; Call the main sprite code
.SpriteIsNotActive .SpriteIsNotActive
PLB ; Get back the databank we stored previously PLB ; Get back the databank we stored previously
RTL ; Go back to original code RTL ; Go back to original code
} }
@@ -64,37 +61,48 @@ Sprite_Poltergeist_Long:
Sprite_Poltergeist_Prep: Sprite_Poltergeist_Prep:
{ {
PHB : PHK : PLB PHB : PHK : PLB
; LDA #$00 : STA $0F60, X ; Persist ; LDA #$00 : STA $0F60, X ; Persist
LDA #$02 : STA $0E40, X ;1 tile by default LDA #$02 : STA $0E40, X ;1 tile by default
LDA #$01 : STA.w SprAction, X ; by default it's a chair LDA #$01 : STA.w SprAction, X ; by default it's a chair
LDA.w SprSubtype, X : CMP #$10 : BNE .notPictureFrame LDA.w SprSubtype, X : CMP #$10 : BNE .notPictureFrame
STZ.w SprMiscA, X STZ.w SprMiscA, X
STZ.w SprAction, X STZ.w SprAction, X
JMP .done JMP .done
.notPictureFrame .notPictureFrame
CMP #$11 : BNE .notAxe CMP #$11 : BNE .notAxe
LDA #$07 : STA.w SprFrame, X LDA #$07 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X LDA #$02 : STA.w SprAction, X
LDA #$04 : STA $0E40, X LDA #$04 : STA $0E40, X
BRA .done BRA .done
.notAxe .notAxe
CMP #$12 : BNE .notKnife CMP #$12 : BNE .notKnife
LDA #15 : STA.w SprFrame, X LDA #15 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X LDA #$02 : STA.w SprAction, X
BRA .done BRA .done
.notKnife .notKnife
CMP #$13 : BNE .notFork CMP #$13 : BNE .notFork
LDA #37 : STA.w SprFrame, X LDA #37 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X LDA #$02 : STA.w SprAction, X
BRA .done BRA .done
.notFork .notFork
CMP #$14 : BNE .notBed CMP #$14 : BNE .notBed
LDA #5 : STA.w SprFrame, X LDA #5 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X LDA #$01 : STA.w SprAction, X
LDA #$06 : STA $0E40, X LDA #$06 : STA $0E40, X
BRA .done BRA .done
.notBed .notBed
CMP #$15 : BNE .notDoor CMP #$15 : BNE .notDoor
LDA #36 : STA.w SprFrame, X LDA #36 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X LDA #$01 : STA.w SprAction, X
@@ -102,27 +110,24 @@ Sprite_Poltergeist_Prep:
LDA.w SprY, X : SEC : SBC #$0C : STA.w SprY, X LDA.w SprY, X : SEC : SBC #$0C : STA.w SprY, X
LDA.w SprX, X : CLC : ADC #$08 : STA.w SprX, X LDA.w SprX, X : CLC : ADC #$08 : STA.w SprX, X
BRA .done BRA .done
.notDoor .notDoor
LDA.w SprSubtype, X : AND #$08 : BNE .secondset ;2nd set LDA.w SprSubtype, X : AND #$08 : BNE .secondset ;2nd set
LDA.w SprSubtype, X : CLC : ADC #23 : STA.w SprFrame, X LDA.w SprSubtype, X : CLC : ADC #23 : STA.w SprFrame, X
BRA .done BRA .done
.secondset .secondset
LDA.w SprSubtype, X : AND #$07 : CLC : ADC #30 : STA.w SprFrame, X LDA.w SprSubtype, X : AND #$07 : CLC : ADC #30 : STA.w SprFrame, X
LDA.w SprSubtype, X LDA.w SprSubtype, X
.done .done
PLB PLB
RTL RTL
} }
;==================================================================================================
; Sprite Main routines code
; --------------------------------------------------------------------------------------------------
; This is the main local code of your sprite
; This contains all the Subroutines of your sprites you can add more below
;==================================================================================================
; Subtype: ; Subtype:
; 00:chair ; 00:chair
; 01:lantern ; 01:lantern
@@ -155,54 +160,60 @@ Sprite_Poltergeist_Main:
dw Chair dw Chair
dw Axe dw Axe
dw SpawnerTester dw SpawnerTester
}
PictureFrame: PictureFrame:
{ {
JSL Sprite_CheckDamageToPlayer JSL Sprite_CheckDamageToPlayer
REP #$20 REP #$20
JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough
SEP #$20 SEP #$20
LDA #$01 : STA.w SprMiscA, X LDA #$01 : STA.w SprMiscA, X
LDA #$02 : STA.w SprHeight, X LDA #$02 : STA.w SprHeight, X
.notcloseenough .notcloseenough
SEP #$20 SEP #$20
LDA.w SprMiscA, X : BNE .chase LDA.w SprMiscA, X : BNE .chase
RTS RTS
.chase .chase
%PlayAnimation(0, 3, 6) %PlayAnimation(0, 3, 6)
LDA #$0A LDA #$0A
JSL Sprite_ApplySpeedTowardsPlayer JSL Sprite_ApplySpeedTowardsPlayer
JSL Sprite_MoveLong JSL Sprite_MoveLong
+
JSL Sprite_CheckDamageFromPlayer : BCC .noShatter JSL Sprite_CheckDamageFromPlayer : BCC .noShatter
JMP Shatter JMP Shatter
.noShatter .noShatter
RTS RTS
} }
GetLinkDistance16bit: GetLinkDistance16bit:
{ {
LDA $0FD8 ; Sprite X LDA $0FD8 ; Sprite X
SEC : SBC $22 ; - Player X SEC : SBC $22 ; - Player X
BPL + BPL +
EOR #$FFFF : INC EOR #$FFFF : INC
+ +
STA $00 ; Distance X (ABS) STA $00 ; Distance X (ABS)
LDA $0FDA ; Sprite Y LDA $0FDA ; Sprite Y
SEC : SBC $20 ; - Player Y SEC : SBC $20 ; - Player Y
BPL + BPL +
EOR #$FFFF : INC EOR #$FFFF : INC
+ +
; Add it back to X Distance ; Add it back to X Distance
CLC : ADC $00 : STA $00 ; distance total X, Y (ABS) CLC : ADC $00 : STA $00 ; distance total X, Y (ABS)
@@ -213,13 +224,17 @@ Sprite_Poltergeist_Main:
{ {
JSL Sprite_CheckDamageToPlayer JSL Sprite_CheckDamageToPlayer
REP #$20 REP #$20
JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough
SEP #$20 SEP #$20
LDA.w SprMiscA, X : BNE + LDA.w SprMiscA, X : BNE +
LDA #$01 : STA.w SprMiscA, X LDA #$01 : STA.w SprMiscA, X
+ +
.notcloseenough .notcloseenough
SEP #$20 SEP #$20
LDA.w SprMiscA, X : CMP #$01 : BNE + LDA.w SprMiscA, X : CMP #$01 : BNE +
; Prepare to raise in the air ; Prepare to raise in the air
LDA.b #$20 : STA.w SprTimerA, X LDA.b #$20 : STA.w SprTimerA, X
@@ -236,15 +251,17 @@ Sprite_Poltergeist_Main:
INC.w SprMiscA, X INC.w SprMiscA, X
RTS RTS
.stillrising .stillrising
; OPTIONAL DELAY THE INCREASING SPRHEIGHT WITH TIMER ; OPTIONAL DELAY THE INCREASING SPRHEIGHT WITH TIMER
LDA.w SprTimerC, X : BNE .optionalTimer LDA.w SprTimerC, X : BNE .optionalTimer
LDA #$02 : STA.w SprTimerC, X LDA #$02 : STA.w SprTimerC, X
INC.w SprHeight, X INC.w SprHeight, X
.optionalTimer
RTS
.optionalTimer
RTS
+ +
CMP #$03 : BNE + CMP #$03 : BNE +
@@ -293,10 +310,13 @@ Sprite_Poltergeist_Main:
REP #$20 REP #$20
JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough JSR GetLinkDistance16bit : CMP #$0050 : BCS .notcloseenough
SEP #$20 SEP #$20
LDA.w SprMiscA, X : BNE + LDA.w SprMiscA, X : BNE +
LDA #$01 : STA.w SprMiscA, X LDA #$01 : STA.w SprMiscA, X
+ +
.notcloseenough .notcloseenough
SEP #$20 SEP #$20
LDA.w SprMiscA, X : CMP #$01 : BNE + LDA.w SprMiscA, X : CMP #$01 : BNE +
; Prepare to raise in the air ; Prepare to raise in the air
@@ -314,72 +334,90 @@ Sprite_Poltergeist_Main:
INC.w SprMiscA, X INC.w SprMiscA, X
RTS RTS
.stillrising .stillrising
; OPTIONAL DELAY THE INCREASING SPRHEIGHT WITH TIMER ; OPTIONAL DELAY THE INCREASING SPRHEIGHT WITH TIMER
LDA.w SprTimerC, X : BNE .optionalTimer LDA.w SprTimerC, X : BNE .optionalTimer
LDA #$02 : STA.w SprTimerC, X LDA #$02 : STA.w SprTimerC, X
INC.w SprHeight, X INC.w SprHeight, X
.optionalTimer
RTS
.optionalTimer
RTS
+ +
CMP #$03 : BNE + CMP #$03 : BNE +
LDA.w SprSubtype, X : CMP #$11 : BNE .notAxe
LDA.w SprSubtype, X
CMP #$11 : BNE .notAxe
JSR PlayAxe JSR PlayAxe
BRA .done BRA .done
.notAxe .notAxe
CMP #$12 : BNE .notKnife CMP #$12 : BNE .notKnife
JSR PlayKnife JSR PlayKnife
BRA .done BRA .done
.notKnife .notKnife
JSR PlayFork JSR PlayFork
.notFork
.done .done
LDA.w SprTimerA, X : BNE .waitingdelay LDA.w SprTimerA, X : BNE .waitingdelay
JSL Sprite_MoveLong JSL Sprite_MoveLong
JSL Sprite_CheckDamageToPlayer : BCC .noShatter JSL Sprite_CheckDamageToPlayer : BCC .noShatter
JMP Shatter JMP Shatter
JSL Sprite_CheckDamageFromPlayer : BCC .noShatter JSL Sprite_CheckDamageFromPlayer : BCC .noShatter
JMP Shatter JMP Shatter
JSL Sprite_CheckTileCollision : BEQ .noShatter JSL Sprite_CheckTileCollision : BEQ .noShatter
JMP Shatter JMP Shatter
.noShatter .noShatter
RTS RTS
+ +
RTS RTS
.waitingdelay .waitingdelay
LDA #$20 LDA #$20
JSL Sprite_ApplySpeedTowardsPlayer JSL Sprite_ApplySpeedTowardsPlayer
RTS RTS
} }
PlayAxe: PlayAxe:
{
%PlayAnimation(7, 14, 6) %PlayAnimation(7, 14, 6)
RTS RTS
}
PlayFork: PlayFork:
{
%PlayAnimation(37, 44, 6) %PlayAnimation(37, 44, 6)
RTS RTS
}
PlayKnife: PlayKnife:
{
%PlayAnimation(15, 22, 6) %PlayAnimation(15, 22, 6)
RTS RTS
}
SpawnerTester: SpawnerTester:
{ {
LDA.w SprTimerA, X : BEQ + LDA.w SprTimerA, X : BEQ +
RTS RTS
+ +
LDA #$FF : STA.w SprTimerA, X LDA #$FF : STA.w SprTimerA, X
LDA #$00 LDA #$00
JSL Sprite_SpawnDynamically JSL Sprite_SpawnDynamically
@@ -394,37 +432,50 @@ Sprite_Poltergeist_Main:
STA.w SprMiscA, Y STA.w SprMiscA, Y
STA.w SprAction, Y STA.w SprAction, Y
BRA .done BRA .done
.notPictureFrame .notPictureFrame
CMP #$11 : BNE .notAxe CMP #$11 : BNE .notAxe
LDA #$07 : STA.w SprFrame, Y LDA #$07 : STA.w SprFrame, Y
LDA #$02 : STA.w SprAction, Y LDA #$02 : STA.w SprAction, Y
BRA .done BRA .done
.notAxe .notAxe
CMP #$12 : BNE .notKnife CMP #$12 : BNE .notKnife
LDA #15 : STA.w SprFrame, Y LDA #15 : STA.w SprFrame, Y
LDA #$02 : STA.w SprAction, Y LDA #$02 : STA.w SprAction, Y
BRA .done BRA .done
.notKnife .notKnife
CMP #$13 : BNE .notFork CMP #$13 : BNE .notFork
LDA #37 : STA.w SprFrame, Y LDA #37 : STA.w SprFrame, Y
LDA #$02 : STA.w SprAction, Y LDA #$02 : STA.w SprAction, Y
BRA .done BRA .done
.notFork .notFork
CMP #$14 : BNE .notBed CMP #$14 : BNE .notBed
LDA #5 : STA.w SprFrame, Y LDA #5 : STA.w SprFrame, Y
LDA #$01 : STA.w SprAction, Y LDA #$01 : STA.w SprAction, Y
BRA .done BRA .done
.notBed .notBed
CMP #$14 : BNE .notDoor CMP #$14 : BNE .notDoor
LDA #36 : STA.w SprFrame, Y LDA #36 : STA.w SprFrame, Y
LDA #$01 : STA.w SprAction, Y LDA #$01 : STA.w SprAction, Y
BRA .done BRA .done
.notDoor .notDoor
LDA.w SprSubtype, Y : AND #$08 : BNE .secondset ;2nd set LDA.w SprSubtype, Y : AND #$08 : BNE .secondset ;2nd set
LDA.w SprSubtype, Y : CLC : ADC #23 : STA.w SprFrame, Y LDA.w SprSubtype, Y : CLC : ADC #23 : STA.w SprFrame, Y
BRA .done BRA .done
.secondset .secondset
LDA.w SprSubtype, Y : AND #$07 : CLC : ADC #30 : STA.w SprFrame, Y LDA.w SprSubtype, Y : AND #$07 : CLC : ADC #30 : STA.w SprFrame, Y
LDA.w SprSubtype, Y LDA.w SprSubtype, Y
@@ -432,16 +483,10 @@ Sprite_Poltergeist_Main:
RTS RTS
} }
}
;==================================================================================================
; Sprite Draw code
; --------------------------------------------------------------------------------------------------
; Draw the tiles on screen with the data provided by the sprite maker editor
;==================================================================================================
Sprite_Poltergeist_Draw: Sprite_Poltergeist_Draw:
{
LDA.w SprAction, X : CMP #$03 : BNE + LDA.w SprAction, X : CMP #$03 : BNE +
RTS RTS
+ +
@@ -453,10 +498,10 @@ JSL Sprite_OAM_AllocateDeferToPlayer
LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame
LDA .start_index, Y : STA $06 LDA .start_index, Y : STA $06
PHX PHX
LDX .nbr_of_tiles, Y ;amount of tiles -1 LDX .nbr_of_tiles, Y ;amount of tiles -1
LDY.b #$00 LDY.b #$00
.nextTile .nextTile
PHX ; Save current Tile Index? PHX ; Save current Tile Index?
@@ -475,10 +520,11 @@ INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100 CLC : ADC #$0010 : CMP.w #$0100
SEP #$20 SEP #$20
BCC .on_screen_y
BCC .on_screen_y
LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way
STA $0E STA $0E
.on_screen_y .on_screen_y
PLX ; Pullback Animation Index Offset (without the *2 not 16bit anymore) PLX ; Pullback Animation Index Offset (without the *2 not 16bit anymore)
@@ -494,7 +540,6 @@ TYA : LSR #2 : TAY
LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer
PLY : INY PLY : INY
PLX : DEX : BPL .nextTile PLX : DEX : BPL .nextTile
PLX PLX
@@ -502,17 +547,20 @@ LDA.w SprMiscA, X : BEQ .noshadow
JSL Sprite_DrawShadow JSL Sprite_DrawShadow
.noshadow .noshadow
RTS RTS
}
;================================================================================================== ;==================================================================================================
; Sprite Draw Generated Data ; Sprite Draw Generated Data
; -------------------------------------------------------------------------------------------------- ; --------------------------------------------------------------------------------------------------
; This is where the generated Data for the sprite go ; This is where the generated Data for the sprite go
;================================================================================================== ;==================================================================================================
.start_index .start_index
db $00, $02, $04, $06, $08, $09, $0F, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1F, $20, $22, $23, $25, $26, $28, $29, $2A, $2B, $2C, $2D, $2E, $2F, $30, $31, $33, $35, $37, $39, $3B, $3F, $41, $42, $44, $45, $47, $48, $4A db $00, $02, $04, $06, $08, $09, $0F, $15, $16, $17, $18, $19, $1A, $1B, $1C, $1D, $1F, $20, $22, $23, $25, $26, $28, $29, $2A, $2B, $2C, $2D, $2E, $2F, $30, $31, $33, $35, $37, $39, $3B, $3F, $41, $42, $44, $45, $47, $48, $4A
.nbr_of_tiles .nbr_of_tiles
db 1, 1, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 1, 0, 1, 0, 1, 0, 1, 0 db 1, 1, 1, 1, 0, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 1, 0, 1, 0, 1, 0, 1, 0
.x_offsets .x_offsets
dw -8, 8 dw -8, 8
dw -8, 8 dw -8, 8
@@ -559,6 +607,7 @@ dw 4, 4
dw 0 dw 0
dw 0, 8 dw 0, 8
dw 0 dw 0
.y_offsets .y_offsets
dw 0, 0 dw 0, 0
dw 0, 0 dw 0, 0
@@ -605,6 +654,7 @@ dw 0, 8
dw 0 dw 0
dw 4, 4 dw 4, 4
dw 0 dw 0
.chr .chr
db $02, $02 db $02, $02
db $00, $00 db $00, $00
@@ -651,6 +701,7 @@ db $07, $17
db $28 db $28
db $3E, $3F db $3E, $3F
db $28 db $28
.properties .properties
db $3D, $7D db $3D, $7D
db $3D, $7D db $3D, $7D
@@ -697,6 +748,7 @@ db $39, $39
db $39 db $39
db $39, $39 db $39, $39
db $B9 db $B9
.sizes .sizes
db $02, $02 db $02, $02
db $02, $02 db $02, $02