; *************************************************************; Removes a sprite from the sprite table; d0 - which sprite to remove; *************************************************************RemoveSprite:lea(spritelist_table),a0; sprite table in a0clr.wd1; clear register d0move.b(sprite_count),d1; sprint count in d0cmp.b#0,d1; are there any sprites in the table?beqSkipRemoveSprite; if not branchlsl.w#$03,d0; calculate sprite table offset (sprite count * sprite size)add.wd0,a0; increment address by offsetmove.w#0,(a0)+; move sprites y position into tablemove.b#0,(a0)+; move sprites demensions into tablemove.b#0,(a0)+; index of next sprite is d5(sprite_count +1) move.b#0,(a0)+; save sprites special bitsmove.b#0,(a0)+; save sprites tile id in tablemove.w#0,(a0)+; save sprites x position in tablesubq#1,(sprite_count); increment sprite counter by 1bsrSortSpriteTableByAddressSkipRemoveSprite:rts; *************************************************************; Sorts the sprite table by address ; a0 - address in sprite table to start sorting from; *************************************************************SortSpriteTableByAddress:clr.wd1; clear register d0move.b(sprite_count),d1; sprint count in d0cmp.b#0,d1; are there any sprites in the table?beqSkipSortSpriteTableByAddress; if not branchmove.w(a0),(a1); address in sprite table to start sortlsl.w#03,d1; sprite table offsetadd.wd1,(a1); last sprite in sprite tableleaa0,(a2); store copy of address in sprite table to start sortaddi.w#8,(a2); temporary scratch for data to moveSortSpriteTableByAddressLoop:move.w(a2)+,(a0)+; save sprites y position into new cellmove.b(a2)+,(a0)+; save sprites demensions into new cell in tablemove.b(a2)+,(a0)+; index of next sprite move.b(a2)+,(a0)+; save sprites special bitsmove.b(a2)+,(a0)+; save sprites tile id in tablemove.w(a2)+,(a0)+; save sprites x position in tablecmpaa0,a1; did we sort all the sprites?bneSortSpriteTableByAddressLoop; if not branchSkipSortSpriteTableByAddress:rts
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.