[stella] Sprite position to Tombstone Matrix conversion

Subject: [stella] Sprite position to Tombstone Matrix conversion
From: Glenn Saunders <mos6507@xxxxxxxxxxx>
Date: Sun, 18 Jan 2004 18:46:56 -0800
I'm working on creating a lookup table I can use in the collision routine for Death Derby where given the gremlin's X and Y, I figure out which RAM strip to write to, which row of the RAM strip, and which bit to turn on.

Here is the preliminary in HTML with some assembly tables at the bottom:


Given this data structure what do you think the fastest lookup routing would be?

I'm thinking the flow would be (in pcode):

copy Gremlin_X to a Gremlin_X_Temp

if (Gremlin_X_Temp > 79)
	flag Temp_PF_Right for overwrite
	Gremlin_X_Temp = Gremlin_X_Temp - 80 + 16
	flag Temp_PF_Left for overwrite

loop through
Tombstone_Cell_Lookup_Table using index of "Cell"

if (current table number > Gremlin_X_Temp)
	break out of loop

loop through
Row_Lookup_Table: using index of "Row"
find out which row we're on
if (current table number < Gremlin_Y)
	break out of loop

use the Cell as in index into the
Temp_PF_Bit_Set_Table table and use that byte as a mask.

Set the bit of either the left or right RAM strip, indexed forward based on the "Row"

This seems pretty straightforward, I hope.

But what I don't like is the two loops, which could result in a maximum of 11 iterations on rows and 8 iterations on cells.

Is there a faster approach?

If the row boundaries are every 16 scanlines and the tombstone cell boundaries are every 8 pixels then I'm thinking some kind of left/right shift approach could be used instead?

Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread