From 3d0e1833b788480b6129425c6321718adb5b7e7e Mon Sep 17 00:00:00 2001 From: scawful Date: Mon, 8 Jan 2024 00:10:02 -0500 Subject: [PATCH] Update Minecart, add switch and track sprite --- Sprites/{ => Enemies}/poltergeist.asm | 0 Sprites/all_sprites.asm | 13 +- Sprites/minecart.asm | 219 +++++++++++++++----------- Sprites/mineswitch.asm | 213 +++++++++++++++++++++++++ Sprites/switch_track.asm | 172 ++++++++++++++++++++ 5 files changed, 519 insertions(+), 98 deletions(-) rename Sprites/{ => Enemies}/poltergeist.asm (100%) create mode 100644 Sprites/mineswitch.asm create mode 100644 Sprites/switch_track.asm diff --git a/Sprites/poltergeist.asm b/Sprites/Enemies/poltergeist.asm similarity index 100% rename from Sprites/poltergeist.asm rename to Sprites/Enemies/poltergeist.asm diff --git a/Sprites/all_sprites.asm b/Sprites/all_sprites.asm index 9986818..06da339 100644 --- a/Sprites/all_sprites.asm +++ b/Sprites/all_sprites.asm @@ -54,9 +54,18 @@ print "End of mask_salesman.asm ", pc incsrc "Sprites/NPCs/deku_scrub.asm" print "End of deku_scrub.asm ", pc -incsrc "Sprites/anti_kirby.asm" +incsrc "Sprites/Enemies/anti_kirby.asm" print "End of anti_kirby.asm ", pc +incsrc "Sprites/Enemies/sea_urchin.asm" +print "End of sea_urchin.asm ", pc + +incsrc "Sprites/switch_track.asm" +print "End of switch_track.asm ", pc + +incsrc "Sprites/mineswitch.asm" +print "End of mineswitch.asm ", pc + incsrc "Sprites/VillageDog/village_dog.asm" print "End of village_dog.asm ", pc @@ -72,7 +81,7 @@ print "End of portal_sprite.asm ", pc incsrc "Sprites/impa.asm" print "End of impa.asm ", pc -incsrc "Sprites/poltergeist.asm" +incsrc "Sprites/Enemies/poltergeist.asm" print "End of poltergeist.asm ", pc incsrc "Sprites/NPCs/bug_net_kid.asm" diff --git a/Sprites/minecart.asm b/Sprites/minecart.asm index 854119d..0b33266 100644 --- a/Sprites/minecart.asm +++ b/Sprites/minecart.asm @@ -54,16 +54,22 @@ Sprite_Minecart_Long: ;============================================================================== +!MinecartSpeed = 20 +!DoubleSpeed = 30 + +; nesw +; 0 - north +; 1 - east +; 2 - south +; 3 - west +!MinecartDirection = $012B + ; $0DE0[0x10] - (Sprite) ;functions ; udlr ; 0 - up ; 1 - down ; 2 - left ; 3 - right - -!MinecartSpeed = 20 -!MinecartDirection = $012B - !SpriteDirection = $0DE0 Sprite_Minecart_Prep: @@ -87,16 +93,19 @@ Sprite_Minecart_Prep: CMP.b #$03 : BEQ .west .north - LDA #$01 : STA !MinecartDirection + STZ.w !MinecartDirection %GotoAction(1) ; Minecart_MoveNorth - JMP .done + JMP .done .east + LDA #$01 : STA !MinecartDirection %GotoAction(0) ; Minecart_MoveEast JMP .done .south + LDA #$02 : STA !MinecartDirection %GotoAction(1) ; Minecart_MoveSouth JMP .done .west + LDA #$03 : STA !MinecartDirection %GotoAction(0) ; Minecart_MoveWest .done @@ -116,6 +125,21 @@ macro HandlePlayerCamera() PLX endmacro +macro InitMovement() + + LDA.b $22 +STA.b $3F + + LDA.b $23 +STA.b $41 + +LDA.b $20 +STA.b $3E + + LDA.b $21 + STA.b $40 +endmacro + Sprite_Minecart_Main: { LDA.w SprAction, X ; Load the SprAction @@ -142,12 +166,14 @@ Sprite_Minecart_Main: LDA #$02 : STA $02F5 ; Somaria platform and moving LDA $0FDA : SEC : SBC #$0B : STA $20 ; Adjust player pos - LDA !MinecartDirection : BNE .opposite_direction + ; Check if the cart is facing east or west + LDA !MinecartDirection : CMP.b #$03 : BNE .opposite_direction LDA #$02 : STA $0DE0, X %GotoAction(5) ; Minecart_MoveWest RTS .opposite_direction + LDA #$03 : STA $0DE0, X %GotoAction(3) ; Minecart_MoveEast .not_on_platform .not_ready @@ -166,7 +192,8 @@ Sprite_Minecart_Main: LDA #$02 : STA $02F5 ; Somaria platform and moving LDA $0FDA : SEC : SBC #$0B : STA $20 ; Adjust player pos - LDA !MinecartDirection : BNE .opposite_direction + ; Check if the cart is facing north or south + LDA !MinecartDirection : CMP.b #$02 : BNE .opposite_direction LDA #$01 : STA $0DE0, X %GotoAction(4) ; Minecart_MoveSouth RTS @@ -184,11 +211,18 @@ Sprite_Minecart_Main: Minecart_MoveNorth: { %PlayAnimation(2,3,8) - LDA.b #-!MinecartSpeed : STA SprYSpeed, X + %InitMovement() + + LDA $36 : BNE .fast_speed + LDA.b #-!MinecartSpeed : STA SprYSpeed, X + JMP .continue + .fast_speed + LDA.b #-!DoubleSpeed : STA SprYSpeed, X + .continue JSL Sprite_MoveVert - LDA SprY, X : SEC : SBC #$04 : STA $20 - LDA SprX, X : CLC : ADC #$02 : STA $22 + ; LDA SprY, X : SEC : SBC #$04 : STA $20 + ; LDA SprX, X : CLC : ADC #$02 : STA $22 JSR DragPlayer JSR CheckForPlayerInput @@ -204,13 +238,15 @@ Sprite_Minecart_Main: Minecart_MoveEast: { %PlayAnimation(0,1,8) - - LDA.b #!MinecartSpeed : STA $0D50, X + %InitMovement() + LDA $36 : BNE .fast_speed + LDA.b #!MinecartSpeed : STA $0D50, X + JMP .continue + .fast_speed + LDA.b #!DoubleSpeed : STA $0D50, X + .continue JSL Sprite_MoveHoriz - ; Make Link move with the minecart - ; LDA SprX, X : STA $22 - JSR DragPlayer JSR CheckForPlayerInput %HandlePlayerCamera() @@ -225,38 +261,38 @@ Sprite_Minecart_Main: Minecart_MoveSouth: { %PlayAnimation(2,3,8) - - LDA.b #!MinecartSpeed : STA SprYSpeed, X + %InitMovement() + LDA $36 : BNE .fast_speed + LDA.b #!MinecartSpeed : STA SprYSpeed, X + JMP .continue + .fast_speed + LDA.b #!DoubleSpeed : STA SprYSpeed, X + .continue JSL Sprite_MoveVert - ; LDA SprY, X : SEC : SBC #$04 : STA $20 - ; LDA SprX, X : CLC : ADC #$02 : STA $22 ; X - JSR DragPlayer JSR CheckForPlayerInput %HandlePlayerCamera() JSR HandleTileDirections - LDA #$35 : STA $012E - - ; LDA $40 : SEC : SBC.b #$FF : STA $40 - ; LDA $68 : SEC : SBC.b #$FF : STA $68 - - + LDA #$35 : STA $012E ; Moving sound effect + RTS } ; --------------------------------------------------------------------------- ; 0x06 - print pc Minecart_MoveWest: { %PlayAnimation(0,1,8) + %InitMovement() + LDA $36 : BNE .fast_speed LDA.b #-!MinecartSpeed : STA $0D50, X + JMP .continue + .fast_speed + LDA.b #-!DoubleSpeed : STA $0D50, X + .continue JSL Sprite_MoveHoriz - ; Make Link move with the minecart - ; LDA SprX, X : STA $22 - JSR DragPlayer JSR CheckForPlayerInput %HandlePlayerCamera() @@ -266,13 +302,17 @@ Sprite_Minecart_Main: RTS } + macro StopCart() + STZ $02F5 + STZ.w SprYSpeed, X + STZ.w SprXSpeed, X + endmacro + ; --------------------------------------------------------------------------- ; 0x07 Minecart_Release: { - STZ $02F5 - STZ.w SprYSpeed, X - STZ.w SprXSpeed, X + %StopCart() LDA SprTimerD, X : BNE .not_ready @@ -282,19 +322,7 @@ Sprite_Minecart_Main: } } -macro StopCart() - STZ $02F5 - STZ.w SprYSpeed, X - STZ.w SprXSpeed, X -endmacro - -macro SwapSubtype() - LDA SprSubtype, X ; Load the current direction subtype - ; Assume the new direction is opposite to the current direction. - ; This is just an example, adjust the logic as needed. - EOR #$03 ; Toggle the least significant 2 bits (0 <-> 3, 1 <-> 2) - STA SprSubtype, X ; Store the new direction subtype -endmacro +; =========================================================================== print "HandleTileDirections ", pc HandleTileDirections: @@ -307,9 +335,9 @@ HandleTileDirections: LDA.b #$00 : JSL Sprite_GetTileAttr ; Load the tile index - LDA $0FA5 + LDA $0FA5 : CLC : CMP.b #$01 : BNE .not_out_of_bounds - CLC : CMP.b #$01 : BNE .not_out_of_bounds + ; If the tile is out of bounds, release the cart LDA #$40 : STA SprTimerD, X %GotoAction(6) ; Minecart_Release RTS @@ -319,43 +347,45 @@ HandleTileDirections: CLC : CMP.b #$B7 : BCS .check_stop ; If tile ID is >= $B8, check for stop tiles .check_stop - CLC : CMP.b #$B7 : BEQ .stop_north - CLC : CMP.b #$B8 : BEQ .stop_south - CLC : CMP.b #$B9 : BEQ .stop_east - CLC : CMP.b #$BA : BEQ .stop_west - JMP .check_for_movement ; if none of the above, continue with normal logic + CLC : CMP.b #$B7 : BEQ .stop_north + CLC : CMP.b #$B8 : BEQ .stop_south + CLC : CMP.b #$B9 : BEQ .stop_east + CLC : CMP.b #$BA : BEQ .stop_west + JMP .check_for_movement ; if none of the above, continue with normal logic .stop_north ; Set the new direction to north and flip the cart's orientation - LDA.b #South : STA SprSubtype, X - STZ.w !MinecartDirection + LDA.b #South : STA SprSubtype, X : STA.w !MinecartDirection + LDA #$01 : STA $0DE0, X JMP .go_vert .stop_south ; Set the new direction to south and flip the cart's orientation - LDA.b #North : STA SprSubtype, X - LDA #$01 : STA !MinecartDirection + LDA.b #North : STA SprSubtype, X : STZ.w !MinecartDirection + LDA #$00 : STA $0DE0, X .go_vert - %SetTimerA($40) - %StopCart() - %GotoAction(1) ; Minecart_WaitVert - RTS + %SetTimerA($40) + %StopCart() + %GotoAction(1) ; Minecart_WaitVert + JSL Player_ResetState + RTS .stop_east ; Set the new direction to east and flip the cart's orientation - LDA.b #West : STA SprSubtype, X - LDA #$01 : STA !MinecartDirection + LDA.b #West : STA SprSubtype, X : STA.w !MinecartDirection + LDA #$03 : STA $0DE0, X JMP .go_horiz .stop_west ; Set the new direction to west and flip the cart's orientation - LDA.b #East : STA SprSubtype, X - STZ.w !MinecartDirection + LDA.b #East : STA SprSubtype, X : STA.w !MinecartDirection + LDA #$02 : STA $0DE0, X .go_horiz - %SetTimerA($40) - %StopCart() - %GotoAction(0) ; Minecart_WaitHoriz - RTS + %SetTimerA($40) + %StopCart() + %GotoAction(0) ; Minecart_WaitHoriz + JSL Player_ResetState + RTS ; --------------------------------------------------------------------------- .check_for_movement @@ -366,16 +396,15 @@ HandleTileDirections: CLC : CMP.b #$B5 : BEQ .check_direction JMP .done - ; Create a composite index based on current direction and tile type - LDA SprSubtype, X ; Load the current direction subtype (0 to 3) - ASL A ; Multiply by 4 (shifting left by 2 bits) to offset rows in the lookup table - TAY ; Transfer to Y to use as an offset for the rows + ; Create a composite index based on current direction and tile type + LDA SprSubtype, X ; Load the current direction subtype (0 to 3) + ASL A ; Multiply by 4 (shifting left by 2 bits) to offset rows in the lookup table + TAY ; Transfer to Y to use as an offset for the rows - LDA $0FA5 ; Load the tile type - SEC : SBC.b #$B3 ; Subtract $B2 to normalize the tile type to 0 to 3 - CLC - ADC.w .DirectionTileLookup, Y ; Add the row and column offsets to index into the lookup table - TAY + ; Load the tile type and subtract $B2 to normalize the tile type to 0 to 3 + LDA $0FA5 : SEC : SBC.b #$B3 + ; Add the row and column offsets to index into the lookup table + CLC : ADC.w .DirectionTileLookup, Y : TAY ; Direction to move on tile collision ; 00 - stop or nothing @@ -465,6 +494,7 @@ DragYHigh = $0B7D DragPlayer: { + ; Get direction of the cart (0 to 3) LDY.w $0DE0, X LDA.w DragPlayer_drag_x_low, Y : CLC : ADC.w DragYLow : STA.w DragYLow LDA.w DragPlayer_drag_x_high, Y : ADC.w DragYHigh : STA DragYHigh @@ -505,32 +535,29 @@ DragPlayer: RTS - ; .drag_x_high - ; db 0, 0, -1, 0, -1 - - ; .drag_x_low - ; db 0, 0, -1, 1, -1, 1, 1 - - ; .drag_y_low - ; db -1, 1, 0, 0, -1, 1, -1, 1 - - ; .drag_y_high - ; db -1, 0, 0, 0, -1, 0, -1, 0 - .drag_x_high - db 0, 0, -1, 0 + db 0, 0, -1, 0 .drag_x_low - db 0, 0, -1, 1 + db 0, 0, -1, 1 .drag_y_low - db -1, 1, 0, 0 + db -1, 1, 0, 0 .drag_y_high - db -1, 0, 0, 0 + db -1, 0, 0, 0 + ; .drag_x_high + ; db 0, 0, -1, 0, -1 + ; .drag_x_low + ; db 0, 0, -1, 1, -1, 1, 1 + ; .drag_y_low + ; db -1, 1, 0, 0, -1, 1, -1, 1 + ; .drag_y_high + ; db -1, 0, 0, 0, -1, 0, -1, 0 } - print "HERE", pc + + CheckForPlayerInput: { ; Setup Minecart position to look for tile IDs diff --git a/Sprites/mineswitch.asm b/Sprites/mineswitch.asm new file mode 100644 index 0000000..4a9ea90 --- /dev/null +++ b/Sprites/mineswitch.asm @@ -0,0 +1,213 @@ + +!SPRID = $AF ; The sprite ID you are overwriting (HEX) +!NbrTiles = 02 ; Number of tiles used in a frame +!Harmless = 01 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless +!HVelocity = 00 ; Is your sprite going super fast? put 01 if it is +!Health = 01 ; Number of Health the sprite have +!Damage = 08 ; (08 is a whole heart), 04 is half heart +!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 +!Palette = 00 ; Unused in this template (can be 0 to 7) +!Hitbox = 00 ; 00 to 31, can be viewed in sprite draw tool +!Persist = 01 ; 01 = your sprite continue to live offscreen +!Statis = 00 ; 00 = is sprite is alive?, (kill all enemies room) +!CollisionLayer = 00 ; 01 = will check both layer for collision +!CanFall = 00 ; 01 sprite can fall in hole, 01 = can't fall +!DeflectArrow = 00 ; 01 = deflect arrows +!WaterSprite = 00 ; 01 = can only walk shallow water +!Blockable = 00 ; 01 = can be blocked by link's shield? +!Prize = 00 ; 00-15 = the prize pack the sprite will drop from +!Sound = 00 ; 01 = Play different sound when taking damage +!Interaction = 00 ; ?? No documentation +!Statue = 00 ; 01 = Sprite is statue +!DeflectProjectiles = 00 ; 01 = Sprite will deflect ALL projectiles +!ImperviousArrow = 00 ; 01 = Impervious to arrows +!ImpervSwordHammer = 00 ; 01 = Impervious to sword and hammer attacks +!Boss = 00 ; 00 = normal sprite, 01 = sprite is a boss + +%Set_Sprite_Properties(Sprite_LeverSwitch_Prep, Sprite_LeverSwitch_Long); + + +Sprite_LeverSwitch_Long: +{ + PHB : PHK : PLB + + JSR Sprite_LeverSwitch_Draw ; Call the draw code + JSL Sprite_CheckActive ; Check if game is not paused + BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive + + JSR Sprite_LeverSwitch_Main ; Call the main sprite code + + .SpriteIsNotActive + PLB ; Get back the databank we stored previously + RTL ; Go back to original code +} + + +Sprite_LeverSwitch_Prep: +{ + PHB : PHK : PLB + + LDA SprSubtype, X : STA SprAction, X + + PLB + RTL +} + + +Sprite_LeverSwitch_Main: +{ + LDA.w SprAction, X + JSL UseImplicitRegIndexedLocalJumpTable + + dw SwitchOff + dw SwitchOn + dw SpeedSwitchOff + dw SpeedSwitchOn + + SwitchOff: + { + %PlayAnimation(0,0,4) + + JSL Sprite_CheckDamageFromPlayerLong + BCC .NoDamage + + LDA #$25 : STA $012F + LDA #$01 : STA $37 + %GotoAction(1) + + .NoDamage + + RTS + } + + SwitchOn: + { + %PlayAnimation(1,1,4) + + JSL Sprite_CheckDamageFromPlayerLong + BCC .NoDamage + + LDA #$25 : STA $012F + STZ.w $37 + %GotoAction(0) + + .NoDamage + + RTS + } + + SpeedSwitchOff: + { + %PlayAnimation(0,0,4) + + JSL Sprite_CheckDamageFromPlayerLong + BCC .NoDamage + + LDA #$25 : STA $012F + LDA.b #$01 : STA $36 + %GotoAction(3) + + .NoDamage + + RTS + } + + SpeedSwitchOn: + { + %PlayAnimation(1,1,4) + + JSL Sprite_CheckDamageFromPlayerLong + BCC .NoDamage + + LDA #$25 : STA $012F + STZ.w $36 + %GotoAction(2) + + .NoDamage + + RTS + } +} + + +Sprite_LeverSwitch_Draw: +{ + JSL Sprite_PrepOamCoord + JSL Sprite_OAM_AllocateDeferToPlayer + + LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame + LDA .start_index, Y : STA $06 + + + 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 + + LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way + 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 : 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 + + + .start_index + db $00, $01 + .nbr_of_tiles + db 0, 0 + .x_offsets + dw 0 + dw 0 + .y_offsets + dw 0 + dw 0 + .chr + db $64 + db $66 + .properties + db $37 + db $37 + .sizes + db $02 + db $02 + +} \ No newline at end of file diff --git a/Sprites/switch_track.asm b/Sprites/switch_track.asm new file mode 100644 index 0000000..f07c7da --- /dev/null +++ b/Sprites/switch_track.asm @@ -0,0 +1,172 @@ +!SPRID = $B0 ; The sprite ID you are overwriting (HEX) +!NbrTiles = 04 ; Number of tiles used in a frame +!Harmless = 00 ; 00 = Sprite is Harmful, 01 = Sprite is Harmless +!HVelocity = 00 ; Is your sprite going super fast? put 01 if it is +!Health = 01 ; Number of Health the sprite have +!Damage = 00 ; (08 is a whole heart), 04 is half heart +!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 +!Palette = 00 ; Unused in this template (can be 0 to 7) +!Hitbox = 00 ; 00 to 31, can be viewed in sprite draw tool +!Persist = 01 ; 01 = your sprite continue to live offscreen +!Statis = 00 ; 00 = is sprite is alive?, (kill all enemies room) +!CollisionLayer = 00 ; 01 = will check both layer for collision +!CanFall = 00 ; 01 sprite can fall in hole, 01 = can't fall +!DeflectArrow = 00 ; 01 = deflect arrows +!WaterSprite = 00 ; 01 = can only walk shallow water +!Blockable = 00 ; 01 = can be blocked by link's shield? +!Prize = 00 ; 00-15 = the prize pack the sprite will drop from +!Sound = 00 ; 01 = Play different sound when taking damage +!Interaction = 00 ; ?? No documentation +!Statue = 00 ; 01 = Sprite is statue +!DeflectProjectiles = 00 ; 01 = Sprite will deflect ALL projectiles +!ImperviousArrow = 00 ; 01 = Impervious to arrows +!ImpervSwordHammer = 00 ; 01 = Impervious to sword and hammer attacks +!Boss = 00 ; 00 = normal sprite, 01 = sprite is a boss + +%Set_Sprite_Properties(Sprite_RotatingTrack_Prep, Sprite_RotatingTrack_Long); + +Sprite_RotatingTrack_Long: +{ + PHB : PHK : PLB + + JSR Sprite_RotatingTrack_Draw ; Call the draw code + JSL Sprite_CheckActive ; Check if game is not paused + BCC .SpriteIsNotActive ; Skip Main code is sprite is innactive + + JSR Sprite_RotatingTrack_Main ; Call the main sprite code + + .SpriteIsNotActive + PLB ; Get back the databank we stored previously + RTL ; Go back to original code +} + +; Modes +; 0 = TopLeft -> TopRight +; 1 = TopRight -> BottomRight +; 2 = BottomRight -> BottomLeft +; 3 = BottomLeft -> TopLeft + +Sprite_RotatingTrack_Prep: +{ + PHB : PHK : PLB + + LDA SprSubtype,X : STA SprAction,X + + PLB + RTL +} + +SwitchRam = $37 + +Sprite_RotatingTrack_Main: +{ + LDA.w SprAction, X + JSL UseImplicitRegIndexedLocalJumpTable + dw TopLeftToTopRight + ; dw TopRightToBottomRight + ; dw BottomRightToBottomLeft + ; dw BottomLeftToTopLeft + + TopLeftToTopRight: + { + LDA SwitchRam : BNE part2 + + %PlayAnimation(0,0,4) + part2: + + %PlayAnimation(1,1,4) + + JSL CheckIfHitBoxesOverlap + + RTS + } +} + +Sprite_RotatingTrack_Draw: +JSL Sprite_PrepOamCoord +JSL Sprite_OAM_AllocateDeferToPlayer + +LDA $0DC0, X : CLC : ADC $0D90, X : TAY;Animation Frame +LDA .start_index, Y : STA $06 + + +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 + +LDA.b #$F0 : STA ($90), Y ;Put the sprite out of the way +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 : 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 + + +.start_index +db $00, $01, $02, $03 +.nbr_of_tiles +db 0, 0, 0, 0 +.x_offsets +dw 0 +dw 0 +dw 0 +dw 0 +.y_offsets +dw 0 +dw 0 +dw 0 +dw 0 +.chr +db $44 +db $44 +db $44 +db $44 +.properties +db $7D +db $3D +db $FD +db $BD +.sizes +db $02 +db $02 +db $02 +db $02 \ No newline at end of file