[Coco] A Great Old-Timey Game-Programming Hack - Tom Moertel’s Blog

John Kowalski sockmaster at gmail.com
Wed Jan 1 22:26:14 EST 2014


on Wed Jan 1 15:45:15 EST 2014, Mathieu Bouchard wrote:
>BTW, in the early 90s on the x86, there was « sprite compilation » : the
>immediate mode of the cpu was so much faster than loading array data from
>the normal data path, that in some cases it was worth making a massive
>loop unrolling so that there isn't a loop anymore, and then pouring ALL of
>the array's data in it so that the machine code doesn't even look at the
>array. Did anybody do that on the CoCo ? Was it ever useful on that CPU ?

Definitely.  There were a number of CoCo 3 games that used compiled sprites.
There is a huge speed gain by doing this, at the expense of larger
code.  I don't remember off-hand how many others did, but (Jeremy
Spiller's) Zenix and Crystal City did, and I used this technique in
Donkey Kong as well.  In addition to sprites, all the background
tiles/fonts were also compiled into code.  (It was the only way I
could hope to get the game's emulation of the arcade graphics hardware
running at a decent frame rate.)

There are further gains when you add optimising to the sprite compiler
itself..  use words when possible, bytes when you have to, load a word
but write the two bytes to different locations, recycling/reusing
loaded words/bytes across several store operations even when the
multiple store operations are not sequential...
A lot of effort can go into a graphics data compiler to try to make
sure that it could detect when optimisations could be used and make
the most cycle efficient choices between them (when/where/what to load
/ store, in what order, when to use offsets (STD nn,X) and when to
resort to a LEAX or use ABX instead if possible (even if B happens to
contain a graphics byte).  (LEAX and autoincrement (X++) being rather
expensive cycle-wise compared to offset (n,X) and ABX operations on
the 6809)

In Zenix even the sprite graphics were deliberately drawn in such a
way that bytes were reused frequently when the sprites were compiled.

-- 
John Kowalski / Sock Master
http://users.aei.ca/twilight/sock



More information about the Coco mailing list