Sprite housekeeping

This commit is contained in:
scawful
2024-11-21 21:29:50 -05:00
parent d4843293f2
commit daf8d4c39d
3 changed files with 107 additions and 133 deletions

View File

@@ -11,7 +11,7 @@
!DeathAnimation = 00 ; 00 = normal death, 01 = no death animation
!ImperviousAll = 00 ; 00 = Can be attack, 01 = attack will clink on it
!SmallShadow = 00 ; 01 = small shadow, 00 = no shadow
!Shadow = 00 ; 00 = don't draw shadow, 01 = draw a shadow
!Shadow = 00 ; 00 = don't draw shadow, 01 = draw a shadow
!Palette = 00 ; Unused in this template (can be 0 to 7)
!Hitbox = 00 ; 00 to 31, can be viewed in sprite draw tool
!Persist = 00 ; 01 = your sprite continue to live offscreen
@@ -37,17 +37,13 @@
Sprite_Booki_Long:
{
PHB : PHK : PLB
JSR Sprite_Booki_Draw ; Call the draw code
JSR Sprite_Booki_Draw
JSL Sprite_DrawShadow
JSL Sprite_CheckActive ; Check if game is not paused
BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive
JSR Sprite_Booki_Main ; Call the main sprite code
JSL Sprite_CheckActive : BCC .SpriteIsNotActive
JSR Sprite_Booki_Main
.SpriteIsNotActive
PLB ; Get back the databank we stored previously
RTL ; Go back to original code
PLB
RTL
}
; =========================================================
@@ -55,11 +51,9 @@ Sprite_Booki_Long:
Sprite_Booki_Prep:
{
PHB : PHK : PLB
LDA.l SWORD : DEC A : TAY
LDA.w .health, Y : STA.w SprHealth, X
STZ.w SprMiscB, X
PLB
RTL
@@ -153,7 +147,7 @@ Sprite_Booki_Move:
PHX
JSL Sprite_DirectionToFacePlayer
LDA.b $0E : CMP.b #$1A : BCS .NotTooClose
LDA.b $0F : CMP.b #$1A : BCS .NotTooClose
LDA.b #$01 : STA.w SprMiscB, X
@@ -169,7 +163,7 @@ Sprite_Booki_Move:
{
JSL GetRandomInt : AND.b #$04
JSL Sprite_FloatAwayFromPlayer
PHX
JSL Sprite_DirectionToFacePlayer
LDA.b $0E : CMP.b #$1B : BCC .NotTooClose
@@ -193,7 +187,7 @@ Sprite_Booki_Draw:
LDA.w SprGfx, X : CLC : ADC.w SprFrame, X : TAY;Animation Frame
LDA .start_index, Y : STA $06
LDA.w SprFlash, X : STA $08
LDA.w SprMiscC, X : STA $09
@@ -203,17 +197,17 @@ Sprite_Booki_Draw:
.nextTile
PHX ; Save current Tile Index?
TXA : CLC : ADC $06 ; Add Animation Index Offset
PHA ; Keep the value with animation index offset?
ASL A : TAX
ASL A : TAX
REP #$20
LDA $00 : STA ($90), Y
AND.w #$0100 : STA $0E
AND.w #$0100 : STA $0E
INY
LDA $02 : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100
@@ -236,14 +230,14 @@ Sprite_Booki_Draw:
.Prop
ORA $08 : STA ($90), Y
PHY
PHY
TYA : LSR #2 : TAY
LDA.b #$02 : ORA $0F : STA ($92), Y ; store size in oam buffer
PLY : INY
PLX : DEX : BPL .nextTile
PLX
@@ -268,4 +262,4 @@ Sprite_Booki_Draw:
db $2C
db $0C
db $0E
}
}

View File

@@ -34,97 +34,82 @@
Sprite_Poltergeist_Long:
{
PHB : PHK : PLB
JSR Sprite_Poltergeist_Draw ; Call the draw code
LDA $E0 : CMP #$F0 : BNE .onscreen
LDA.w SprMiscA, X : BEQ .SpriteIsNotActive
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
JSR Sprite_Poltergeist_Main ; Call the main sprite code
.SpriteIsNotActive
PLB ; Get back the databank we stored previously
RTL ; Go back to original code
PHB : PHK : PLB
JSR Sprite_Poltergeist_Draw
LDA $E0 : CMP #$F0 : BNE .onscreen
LDA.w SprMiscA, X : BEQ .SpriteIsNotActive
STZ.w SprState, X ; kill the sprite if offscreen and activated
.onscreen
JSL Sprite_CheckActive : BCC .SpriteIsNotActive
JSR Sprite_Poltergeist_Main
.SpriteIsNotActive
PLB
RTL
}
; =========================================================
Sprite_Poltergeist_Prep:
{
PHB : PHK : PLB
PHB : PHK : PLB
LDA #$00 : STA.w SprHitbox, X ; Persist
LDA #$00 : STA.w SprDefl, X ; Sprite persist in dungeon
LDA #$02 : STA.w SprNbrOAM, X ;1 tile by default
LDA #$01 : STA.w SprAction, X ; by default it's a chair
LDA #$00 : STA.w SprHitbox, X ; Persist
LDA #$00 : STA.w SprDefl, X ; Sprite persist in dungeon
LDA #$02 : STA.w SprNbrOAM, X ;1 tile by default
LDA #$01 : STA.w SprAction, X ; by default it's a chair
LDA.w SprSubtype, X : CMP #$10 : BNE .notPictureFrame
STZ.w SprMiscA, X
STZ.w SprAction, X
JMP .done
LDA.w SprSubtype, X : CMP #$10 : BNE .notPictureFrame
STZ.w SprMiscA, X
STZ.w SprAction, X
JMP .done
.notPictureFrame
.notPictureFrame
CMP #$11 : BNE .notAxe
LDA #$07 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
LDA #$04 : STA.w SprNbrOAM, X
BRA .done
.notAxe
CMP #$11 : BNE .notAxe
LDA #$07 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
LDA #$04 : STA.w SprNbrOAM, X
BRA .done
CMP #$12 : BNE .notKnife
LDA #15 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
BRA .done
.notKnife
.notAxe
CMP #$13 : BNE .notFork
LDA #37 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
BRA .done
.notFork
CMP #$12 : BNE .notKnife
LDA #15 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
BRA .done
CMP #$14 : BNE .notBed
LDA #5 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X
LDA #$06 : STA.w SprNbrOAM, X
BRA .done
.notBed
.notKnife
CMP #$15 : BNE .notDoor
LDA #36 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X
LDA #$04 : STA.w SprNbrOAM, X
LDA.w SprY, X : SEC : SBC #$0C : STA.w SprY, X
LDA.w SprX, X : CLC : ADC #$08 : STA.w SprX, X
BRA .done
.notDoor
CMP #$13 : BNE .notFork
LDA #37 : STA.w SprFrame, X
LDA #$02 : STA.w SprAction, X
BRA .done
LDA.w SprSubtype, X : AND #$08 : BNE .secondset ;2nd set
LDA.w SprSubtype, X : CLC : ADC #23 : STA.w SprFrame, X
BRA .done
.secondset
.notFork
LDA.w SprSubtype, X : AND #$07 : CLC : ADC #30 : STA.w SprFrame, X
LDA.w SprSubtype, X
CMP #$14 : BNE .notBed
LDA #5 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X
LDA #$06 : STA.w SprNbrOAM, X
BRA .done
.notBed
CMP #$15 : BNE .notDoor
LDA #36 : STA.w SprFrame, X
LDA #$01 : STA.w SprAction, X
LDA #$04 : STA.w SprNbrOAM, X
LDA.w SprY, X : SEC : SBC #$0C : STA.w SprY, X
LDA.w SprX, X : CLC : ADC #$08 : STA.w SprX, X
BRA .done
.notDoor
LDA.w SprSubtype, X : AND #$08 : BNE .secondset ;2nd set
LDA.w SprSubtype, X : CLC : ADC #23 : STA.w SprFrame, X
BRA .done
.secondset
LDA.w SprSubtype, X : AND #$07 : CLC : ADC #30 : STA.w SprFrame, X
LDA.w SprSubtype, X
.done
PLB
RTL
.done
PLB
RTL
}
; Subtype:
@@ -153,12 +138,12 @@ Sprite_Poltergeist_Prep:
Sprite_Poltergeist_Main:
{
LDA.w SprAction, X : JSL UseImplicitRegIndexedLocalJumpTable
LDA.w SprAction, X : JSL UseImplicitRegIndexedLocalJumpTable
dw PictureFrame
dw Chair
dw Axe
dw SpawnerTester
dw PictureFrame
dw Chair
dw Axe
dw SpawnerTester
}
PictureFrame:
@@ -392,23 +377,20 @@ Axe:
PlayAxe:
{
%PlayAnimation(7, 14, 6)
RTS
%PlayAnimation(7, 14, 6)
RTS
}
PlayFork:
{
%PlayAnimation(37, 44, 6)
RTS
%PlayAnimation(37, 44, 6)
RTS
}
PlayKnife:
{
%PlayAnimation(15, 22, 6)
RTS
%PlayAnimation(15, 22, 6)
RTS
}
SpawnerTester:

View File

@@ -45,10 +45,10 @@ Sprite_MoveHoriz:
; make the sprite move both directions (also height)
Sprite_MoveXyz:
JSL Sprite_MoveAltitude
JSL Sprite_MoveAltitude
Sprite_Move:
JSL Sprite_MoveHoriz
; no RTL, just continue into Sprite_MoveVert
JSL Sprite_MoveHoriz
; no RTL, just continue into Sprite_MoveVert
; =========================================================
; make the sprite move Y axis
@@ -96,15 +96,14 @@ Sprite_MoveAltitude:
; =========================================================
; make the sprite bounce toward player
; movement, collision are handled by this function
; movement, collision are handled by this function
; $09 = speed, $08 = max height ( e.g. height:20 = vitreous)
Sprite_BounceTowardPlayer:
{
JSL Sprite_MoveAltitude
DEC.w SprTimerF, X : DEC.w SprTimerF, X
LDA.w SprHeight, X : BPL .aloft
JSL Sprite_MoveAltitude
DEC.w SprTimerF, X : DEC.w SprTimerF, X
LDA.w SprHeight, X : BPL .aloft
STZ.w SprHeight, X
LDA.b $08 : STA.w SprTimerF, X ; set height from 08
LDA.b $09 : JSL Sprite_ApplySpeedTowardsPlayer
@@ -113,7 +112,7 @@ Sprite_BounceTowardPlayer:
LDA.w SprHeight, X : BEQ .dontmove
JSL Sprite_Move
.dontmove
RTL
RTL
}
; A = Speed
@@ -237,7 +236,7 @@ DragPlayer:
INC.w DragYL
.x_done
; Changing the modifier adjusts links position in the cart
; Changing the modifier adjusts links position in the cart
LDA.w SprCachedY : SEC : SBC.w #$0008
CMP $20 : BEQ .y_done : BPL .y_too_low
DEC.w DragXL
@@ -293,7 +292,7 @@ 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
STA.w SprFlash, X
BRA .flash
@@ -325,13 +324,13 @@ 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
}
@@ -604,7 +603,7 @@ Sprite_ApplySpeedTowardsPlayerXOrY:
;player_to_the_Left
REP #$20
LDA.w SprCachedX : SEC : SBC $22 ; delta X
CMP $01 : BCS .XGreaterThanY1
;YGreaterThanX
SEP #$20
@@ -700,7 +699,6 @@ GetDistance8bit_Long:
RTL
}
; =========================================================
Intro_Dungeon_Main:
@@ -714,7 +712,7 @@ Intro_Dungeon_Main:
LDA $1C : ORA.b #$01 : STA $1C ;turn on BG2 (Body)
.didNotRun
STZ.b SpriteRanCheck
.not_sprite_body_boss
@@ -764,7 +762,7 @@ MoveCamera:
;CameraAbovePoint ;right
ADC.w #$0001 : STA $E2 : STA $E0 : STA $011E : STA $0120 ;move the camera right by 1
BRA .dontMoveX
.CameraBelowPointX
SEC : SBC.w #$0001 : STA $E2 : STA $E0 : STA $011E : STA $0120 ;move the camera left by 1
@@ -837,7 +835,7 @@ SetupMovieEffect:
LDA.b #$01 : STA.l MovieEffectA
LDA.b #$00 : STA.l MovieEffectB
;Below screen
;Below screen
LDA.b #$20 : STA.l MovieEffectC
LDA.b #$0F : STA.l MovieEffectD
@@ -864,7 +862,7 @@ MovieEffect:
SEP #$20
LDA.b #$20 : STA $9B ;Do the HDMA instead of $420C
; LDA $9B : ORA #$20 : STA $9B
; LDA $9B : ORA #$20 : STA $9B
; LDA.b #$02 : STA $13 ;controls the brightness of the screen
RTS