[stella] P2C+Cartesian to Polar = Full Co-ordinate Conversion

Subject: [stella] P2C+Cartesian to Polar = Full Co-ordinate Conversion
From: "Roger Williams" <mer02@xxxxxxxxxxxxx>
Date: Sat, 3 Nov 2001 21:13:12 -0800
It's taken me awhile to get this out because of a nasty little
bug lurking in the demo code (hint: if you are adding a 2's
complement 8-bit value to a 16-bit value, you better make
sure you check the high bit and add $FF instead of 0 when
the source is negative.)

This demonstrates full co-ordinate conversion.  You "drive"
a familiar looking tank around a baseball field made up of
the other player, ball, and missiles.  The resolution is
execrable because it's only good to 1 in 64 and there are
three conversions involved in locating an object, so the
errors propagate.  This can be solved, at the expense of
some clock cycles (next project!).  Single-pixel resolution
(at least at the level of this demo) should be possible.

You could adapt this code readily to 3D, but the errors
would be even worse.  With an extension to 10-bit angles
that should become acceptable (though at some cost on
the timing)

My P2C demo had been anticipated by Gyruss, though
used a brute-force table in a paged 8K game to do what
I did in about 1.5K.  That wouldn't work with this.  I don't
think it's ever been done on Stella, even at this limited level.
If it has I'd be *very* interested in hearing about it,
because I'm actually starting to get the itch to make a
playable game out of this idea.

--Roger Williams

P.S. These conversion routines are useful in many contexts
and I'm not jealous of them.  One interesting
project would be to add fine motion control to Combat.
I may do that if no one else is interested just as a practice
exercise.  I've put them in the public domain, if you feel you
could use them please do.

Attachment: c2pdemo.asm
Description: Binary data

Attachment: c2pdemo.bin
Description: Binary data

Current Thread