Re: [stella] I did it!(SFCaves 2600)

Subject: Re: [stella] I did it!(SFCaves 2600)
From: Mark De Smet <de-smet@xxxxxxxxxxxxxxx>
Date: Mon, 2 Oct 2000 23:30:49 -0500 (CDT)
> - Store the contents of X in memory and use the X and Y registers for
> indexing at the left and right border together. This could look like
> that:

I like this idea.  My only concern is how the stores to PFx will work out.
I'll have to try it to find out!

> - If you have the chance to determine (from the contents of X and Y),
> if the left/right half of the line is full/empty you could gain some
> extra time (i did this in Thrust)

Yes, there will be many lines that are full, but once I get this free
time, what do I do with it?  The player objects are never drawn on lines
that are full.  There will be few lines that are all empty, and the player
objects will be drawn on those, but also partially filled lines.

> - Make sure that the indexes and branches never cross a bank (align
> your code and data). Then you have the chance to get the 3 extra
> cycles from WSYNC.

I hadn't thought of that, I'll have to do the alignment so that I can do

> I think you are wasting far to many cycles with this. Try to avoid
> those complex lines, or find a solution where you can handle them in
> one line. You'll need much more free cycles for the player object,
> than you might expect now. ;-)

> BTW: I don't know how your tables look like, but why do you use AND in
> the first and ORA in he second half? Always using ORA might help to
> solve the complex line problems.

Here's how it works.  I've limited the caves shapes to these 4.  The lines
indicate the path of the cave.  I will force the cave generation routines
to only allow these types.

1. dip only.(never rises) ex:
2. rise only. (the opposite of 1)
3. middle dip.(fall then rise) ex:
  \      -
   -\   /
4. middle rise.(the opposite of 3)

Types 1 and 2 are a special case of types 3 and 4.  I will copy the kernal
twice, once for type 3 and once for type 4(which type is predetermined in
the cave generation routine).  The current routine does case 3.

I cannot remove the case where both the cave top and bottom appear in the
same line because then the cave could not have a steep slope, which is
needed for game play.

The question came to me, how do I store the cave in memory, then get that
data into a form to put into PFx?  The best way I could figure out was to
keep two sets of data, a line shift for the left side, and one for the
right.  This line shift is how many blocks over the edge of the cave is on
this line from the last line.  This is a very complex way to generate the
cave, but I think it is the only way I can do it and still be able to draw
it on the screen.  So currrightcol and currleftcol store the column number
where the edge is.  Then I add on the shift(or subtract for the right
side) and re-save it for the next line.  I use this to take the
precomputed PF data out of the tables.

The tables:
There are 12 tables.  6 for one side, and 6 for the other.(The 6 represent
the 6 bytes neccesary to load into the PF registers).  The tables are
generated so that if you grab entry 1 then you have the data for when the
edge is on the first column.  Entry 2 has the data for when the edge is on
the second column.  Continued on for all 40 possibilities.  The first 6
tables have the data with the 1's on the left and the 0's on the right.
The second 6 have the data in the opposite order.(ie. they are exact

In the first two lines I am doing the top half, so I need to AND the left
and right sides because the 1's will overlap.  In the second two lines, I
am doing the bottom half, so I need to OR the left and right sides because
the 0's overlap.

Here's the thing with putting the top and bottom in the same lines:  I
will need to do the AND of the top set of left/right, and the OR of the
bottom set of left/right, then OR those togather.  Do you think I can do
all of that in less time than my doubleing effort?  I think the only
savings will be in the PF writes, but I have to do the extra OR work to do

I agree, If I can get a whole line free, everything would be great!

Thanks for your help!

Archives (includes files) at
Unsub & more at

Current Thread