Tell me what you think of this idea for building a dynamic SNES sprite table. (Or share you ideas).
The hardest part of building the table would seem to be setting up the 32 byte table at the end of the list (whatever it's technically called).
My idea for making this easy would be constructing 2 256 byte tables, for 128 sprites.
One table would contain values where the size bit is 0, and the other one would contain a size bit of 1. Each sprite would store the address of the table to use. The table pointer would remain the same throughout the 'life' of the sprite, and only need to be set when the sprite was initially added.
Each table would contain:
%000000x0 (x is the size bit)
%000000x1
%0000x000
%0000x100
%00x00000
%00x10000
%x0000000
%x1000000
.. repeated for the entire 256 bytes. (This could use 8 bytes, but the time spent masking the pointer probably wouldn't be worth saving 248 bytes per table).
At the beginning of the sort routine, the entire 640 bytes of sprite memory would be cleared.
An offset pointer, to the correct table entry, would be set up at the beginning of the routine, and incremented by two each time.
The upper byte of the sprite x position, would be added to the table offset pointer. The value, obtained from the table, would be or'ed with the current location in the sprite table. There would be no need for masking, as the byte would be cleared at the beginning, and be built up sequentially.
I would probably process 4 sprites at a time, this would allow me to:
1) Store the temporary value in a zero page memory location, and write it as a single byte to the sprite table.
2) Increment the sprite table address for each 4 sprites.
The 'shadow' sprite list would have to be padded out to 4 sprites increments by the sorting routine.
Does this sound reasonable, or is there a faster/easier way?
Could it be done in the vertical retrace, assuming the routine was fairly well written (in asm)?
The hardest part of building the table would seem to be setting up the 32 byte table at the end of the list (whatever it's technically called).
My idea for making this easy would be constructing 2 256 byte tables, for 128 sprites.
One table would contain values where the size bit is 0, and the other one would contain a size bit of 1. Each sprite would store the address of the table to use. The table pointer would remain the same throughout the 'life' of the sprite, and only need to be set when the sprite was initially added.
Each table would contain:
%000000x0 (x is the size bit)
%000000x1
%0000x000
%0000x100
%00x00000
%00x10000
%x0000000
%x1000000
.. repeated for the entire 256 bytes. (This could use 8 bytes, but the time spent masking the pointer probably wouldn't be worth saving 248 bytes per table).
At the beginning of the sort routine, the entire 640 bytes of sprite memory would be cleared.
An offset pointer, to the correct table entry, would be set up at the beginning of the routine, and incremented by two each time.
The upper byte of the sprite x position, would be added to the table offset pointer. The value, obtained from the table, would be or'ed with the current location in the sprite table. There would be no need for masking, as the byte would be cleared at the beginning, and be built up sequentially.
I would probably process 4 sprites at a time, this would allow me to:
1) Store the temporary value in a zero page memory location, and write it as a single byte to the sprite table.
2) Increment the sprite table address for each 4 sprites.
The 'shadow' sprite list would have to be padded out to 4 sprites increments by the sorting routine.
Does this sound reasonable, or is there a faster/easier way?
Could it be done in the vertical retrace, assuming the routine was fairly well written (in asm)?