[stella] Positioning two objects

Subject: [stella] Positioning two objects
From: emooney@xxxxxxxxxxxxxxxx (Erik Mooney)
Date: Fri, 15 May 1998 03:11:28 GMT
The past couple days, I've been wondering if a routine to position two
objects in any positions on a single scanline could be done, allowing more
objects with less vertical space between them.  Obviously, a delay loop
between the objects is impossible (what if the objects are in the same
position?) unless they're forced to be apart, maybe on opposite sides of
the screen like Street Racer or something.  The only way I can think of to
do it is use self-modifying code with a large chunk of RAM (SC or megacart)
to put it in.  The kernel code would be generated by offscreen code, and
it'd go something like this:

We make some sort of single-cycle precision delay (Andrew's previous posts
on this might be quite helpful) and then the STA RESP0 [1]... the STA RESP0
happens at the earliest possible time so that the object can be HMOVEd into
the correct position... example, if the object is to be at pixel 61
onscreen (129 from wsync), we delay 36 cycles, then hit RESP0, which puts
it at pixel (36 cycles + 3 for the RESP0) * 3 + the "mystery 5 pixels" =
122, then put -7 into HMP0. [2]  Then, we delay as long as necessary to get
the second object into position, with the same method.  Look at the
worst-case scenario - the objects are in the same position.  In this case,
the code would do the STA RESP1 immediately after the STA RESP0, putting it
3 cycles = 9 pixels after the first player, or at pixel 131.  We then put
+2 into HMP1, getting it to pixel 129.

Make sense?  Might it work?  You'd need enough RAM to hold the generated
kernel for every time you want to position two objects together, probably
about 30 bytes per pair, which kills any chance of zeropage. But SC or
megacart RAM could hold the 300-450 bytes for this.  And three objects on a
line can't be done if they're all in the same position, but if they can be
forced far enough apart, it could be done.

[1] The code would have to figure out which object is leftmost and make
sure to position that one first.  This would be easier if it didn't matter
which object was which - suppose a player and its missile were to be used
for two Breakout balls or two Missile Command missiles... you could always
use player 1 for the left object and missile 1 for the right object.

[2] Of course, that -7 goes into the top four bits of HMP0, and it'd be a
good idea to do that during the 36 cycle delay.  And a WSYNC is done
immediately after the second positioning, and the HMOVE immediately after
that.

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

Current Thread