Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Storing and displaying sprites

Reply to topic
Author Message
  • Joined: 26 Jan 2013
  • Posts: 5
Reply with quote
Storing and displaying sprites
Post Posted: Sat Jan 26, 2013 11:49 pm
I recently started to learn assembly and have gotten stuck on what kind of format can be used to store the layout of the tiles comprising the sprite and how to display them.

My current idea for storage is to have a table (one for each sprite, listing frames for that sprite) that points to another table which contains the layout information. I feel that this is very chunky and probably not the way to go about this.

Here is what I was trying:
sprite0_S:
.dw sprite0_frame0_InfoTable
sprite0_E:

sprite0_frame0_InfoTable:
   .db sprite0_frame0_Tiles_E - sprite0_frame0_Tiles_S ;Sprite tile count
   .dw sprite0_frame0_YOffsets                         ;Pointer to tile Y-offset list
   .dw sprite0_frame0_XOffsets                         ;Pointer to tile X-offset list
   .dw sprite0_frame0_Tiles_S                          ;Pointer to sprite pattern index list

sprite0_frame0_Tiles_S:
   .db $00, $01, $02, $03, $04, $05 ;Pattern index list
sprite0_frame0_Tiles_E:


;Offset lists
;Each byte defines the pixel offset of each tile from the top-left corner of the sprite
;A 2x3 tile rectangle, for example...
sprite0_frame0_XOffsets:
   ;Columns
   ;   0  1
   .db 0, 8 ;Row 0
   .db 0, 8 ;    1
   .db 0, 8 ;    2

sprite0_frame0_YOffsets:
   ;Columns
   ;   0   1
   .db 0,  0  ;Row 0
   .db 8,  8  ;    1
   .db 16, 16 ;    2



When it comes to displaying a sprite using this, I am at a complete loss. I tried to write something to use it, but never got anywhere because I ran out of registers after the first few lines of code. :)

Any advice or new approaches would be much welcomed.
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14745
  • Location: London
Reply with quote
Post Posted: Sun Jan 27, 2013 1:15 am
It seems reasonable. I'd pack x, y, index together and use a sentinel to terminate, rather than separate tables - or something closer to the VRAM layout for fast copying. An alternative is to have a fixed layout and animate the underlying tiles.
  View user's profile Send private message Visit poster's website
  • Joined: 26 Jan 2013
  • Posts: 5
Reply with quote
Post Posted: Sun Jan 27, 2013 2:59 am
Maxim wrote
I'd pack x, y, index together and use a sentinel to terminate, rather than separate tables - or something closer to the VRAM layout for fast copying.

I just tried that out. It's much simpler and now it works.
Thanks!
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!