Re: [stella] Re: 2600Cookbook - exact horizontal positioning

Subject: Re: [stella] Re: 2600Cookbook - exact horizontal positioning
From: "Erik Mooney" <erik@xxxxxxxxxx>
Date: Wed, 14 Apr 2004 10:33:16 -0500
"Andrew Davie" <atari2600@xxxxxxxxxxxxx> wrote:

> It's not *mine* I stole it from
> (R.Mundschau) who independantly invented it.  It was also discovered by
> Manuel, who noticed it in Battlezone (I think).

Actually, Mr. Mundschau's version does have a significant 
advantage over Battlezone.  By using a lookup table for the HMxx
value rather than calculating it with four shifts, it fits 
(almost) entirely into one scanline.  If it was changed to
just do a single object rather than indexing with X, you'd save
one cycle on each of the STAs and could dispense with the
extra cycle from going over the page boundary.  Those three
cycles could then load the horizontal position from memory into
A within the same scanline instead of needing it preloaded, 
and then the routine is every bit as fast as the big table

(Of course, the ultimately fastest way is to simply calculate the
fine/coarse value outside the kernel and store it separately.)

I hadn't really looked at it before, but it is really clever.
However, I think that as written in that post, it doesn't
quite work for objects far on the left.  If the delay loop
falls through on the first iteration (X-position <= 15), the
STA RESP0 completes at cycle 21, which is too early; that will
try to position the object off the left edge of the screen and
the TIA will "correct" it to be 0.  It needs at least one
(two?) extra cycles before the delay loop.

Apologies if Andrew or someone already covered this somewhere. :)
Archives (includes files) at
Unsub & more at

Current Thread