Update sprite macros for draw code, add new macros

This commit is contained in:
scawful
2024-12-19 09:44:08 -05:00
parent 548379f95a
commit 2a996a69e5
7 changed files with 179 additions and 310 deletions

View File

@@ -1,47 +1,57 @@
; Write Sprite Properties in the rom MACRO
macro Set_Sprite_Properties(SprPrep, SprMain)
{
pushpc ; Save writing Position for the sprite
org $0DB080+!SPRID ; Oam Harmless ($0E40)
db ((!Harmless<<7)|(!HVelocity<<6)|!NbrTiles)
pushpc ; Save writing Position for the sprite
org $0DB080+!SPRID ; Oam Harmless ($0E40)
db ((!Harmless<<7)|(!HVelocity<<6)|!NbrTiles)
org $0DB173+!SPRID ; Sprite HP ($0E50)
db !Health
org $0DB173+!SPRID ; Sprite HP ($0E50)
db !Health
org $0DB266+!SPRID ; Sprite Damage ($0CD2)
db !Damage
org $0DB266+!SPRID ; Sprite Damage ($0CD2)
db !Damage
org $0DB359+!SPRID ; Sprite Data ($0E60 / $0F50)
db ((!DeathAnimation<<7)|(!ImperviousAll<<6)|(!SmallShadow<<5)|(!Shadow<<4)|(!Palette<<1))
org $0DB359+!SPRID ; Sprite Data ($0E60 / $0F50)
db ((!DeathAnimation<<7)|(!ImperviousAll<<6)|(!SmallShadow<<5)|(!Shadow<<4)|(!Palette<<1))
org $0DB44C+!SPRID ; Sprite Hitbox ($0F60)
db ((!CollisionLayer<<7)|(!Statis<<6)|(!Persist<<5)|(!Hitbox))
org $0DB44C+!SPRID ; Sprite Hitbox ($0F60)
db ((!CollisionLayer<<7)|(!Statis<<6)|(!Persist<<5)|(!Hitbox))
org $0DB53F+!SPRID ; Sprite Fall ($0B6B)
db ((!DeflectArrow<<3)|(!Boss<<1)|!CanFall)
org $0DB53F+!SPRID ; Sprite Fall ($0B6B)
db ((!DeflectArrow<<3)|(!Boss<<1)|!CanFall)
org $0DB632+!SPRID ; Sprite Prize ($0BE0)
db ((!Interaction<<7)|(!WaterSprite<<6)|(!Blockable<<5)|(!Sound<<4)|!Prize)
org $0DB632+!SPRID ; Sprite Prize ($0BE0)
db ((!Interaction<<7)|(!WaterSprite<<6)|(!Blockable<<5)|(!Sound<<4)|!Prize)
org $0DB725+!SPRID ; Sprite ($0CAA)
db ($40|(!Statue<<5)|(!DeflectProjectiles<<4)|(!ImpervSwordHammer<<2)|(!ImperviousArrow<<1))
org $0DB725+!SPRID ; Sprite ($0CAA)
db ($40|(!Statue<<5)|(!DeflectProjectiles<<4)|(!ImpervSwordHammer<<2)|(!ImperviousArrow<<1))
org $069283+(!SPRID*2) ; Vanilla Sprite Main Pointer
dw NewMainSprFunction
org $069283+(!SPRID*2) ; Vanilla Sprite Main Pointer
dw NewMainSprFunction
org $06865B+(!SPRID*2) ; Vanilla Sprite Prep Pointer
dw NewSprPrepFunction
org $06865B+(!SPRID*2) ; Vanilla Sprite Prep Pointer
dw NewSprPrepFunction
org NewSprRoutinesLong+(!SPRID*3) ; New Long Sprite Pointer
dl <SprMain>
org NewSprPrepRoutinesLong+(!SPRID*3) ; New Long Sprite Pointer
dl <SprPrep>
pullpc ; Get back the writing position for the sprite
org NewSprRoutinesLong+(!SPRID*3) ; New Long Sprite Pointer
dl <SprMain>
org NewSprPrepRoutinesLong+(!SPRID*3) ; New Long Sprite Pointer
dl <SprPrep>
pullpc ; Get back the writing position for the sprite
}
endmacro
macro loop(body, ...)
!x #= 0
while !x < sizeof(...)
!x #= !x+1
endwhile
endmacro
macro sta(...)
%loop(STA, ...)
endmacro
; Go to the action specified ID can be Hex or Decimal
macro GotoAction(action)
LDA.b #<action> : STA.w SprAction, X
endmacro
@@ -70,12 +80,14 @@ macro SetMode(bit_mode)
endmacro
macro ScopedMode(bit_mode, body)
SetMode bit_mode
body
if <bit_mode> == "16bit"
SetMode "8bit"
%SetMode("16bit")
<body>
%SetMode("8bit")
elseif <bit_mode> == "8bit"
SetMode "16bit"
%SetMode("8bit")
<body>
%SetMode("16bit")
endif
endmacro
@@ -307,3 +319,44 @@ macro SetupDistanceFromSprite()
LDA.w SprY, X : STA $05
endmacro
macro DrawSprite()
{
JSL Sprite_PrepOamCoord
JSL Sprite_OAM_AllocateDeferToPlayer
LDA.w SprGfx, X : CLC : ADC.w SprFrame, X : TAY
LDA.w .start_index, Y : STA $06
LDA.w SprFlash, X : STA $08
PHX
LDX .nbr_of_tiles, Y ; amount of tiles -1
LDY.b #$00
.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
REP #$20
LDA $00 : CLC : ADC .x_offsets, X : STA ($90), Y
AND.w #$0100 : STA $0E
INY
LDA $02 : CLC : ADC .y_offsets, X : STA ($90), Y
CLC : ADC #$0010 : CMP.w #$0100
SEP #$20
BCC .on_screen_y
; Put the sprite out of the way
LDA.b #$F0 : STA ($90), Y : STA $0E
.on_screen_y
PLX ; Pullback Animation Index Offset (without the *2 not 16bit anymore)
INY
LDA .chr, X : STA ($90), Y
INY
LDA .properties, X : ORA $08 : STA ($90), Y
PHY
TYA : LSR #2 : TAY
LDA .sizes, X : ORA $0F : STA ($92), Y ; store size in oam buffer
PLY : INY
PLX : DEX : BPL .nextTile
PLX
RTS
}
endmacro