Tuesday, November 16, 2010

Sprite Support Implemented

A big step forward; I now have full sprite support in my framework.

Furthermore, I have ported all the low-level OutRun routines from 68k to C++ that abstract the sprite hardware from the general game code. This was a considerable effort and required some serious debugging.

You can think of the dependencies as follows:

High-Level OutRun Game Code (68k) -> Low-Level OutRun Sprite Routines (68k) -> Video Hardware.

I'm at the stage where the second two components in this sequence are done. The ported routines control some of the following areas:

  • Initializing and caching sprite palette data in RAM
  • Ordering sprites based on priority
  • Converting the programmer friendly format used by OutRun game objects to the format required by hardware
  • Setting horizontal and vertical zoom settings from a lookup table
  • Setting the height and width from a lookup table in relation to the above
  • Setting the sprite anchor point
  • Setting rendering hints based on horizontal flip bits etc.

Here's a slightly dull screenshot, which shows the OutRun logo being rendered. Well most of it, the observant among you will notice I didn't hook up the bird sprites as it was getting late:


It doesn't look like much, but the important thing is I can initialize a sprite simply by setting a few jump table properties using fully ported code. Here's an example of the code required to initialize a sprite object, where 'e' is a jump table entry:

e->jump_index = 0;
e->x = 0;
e->y = 0x70;
e->road_priority = 0xFF;
e->priority = 0x1FA;
e->zoom = 0x7F;
e->pal_src = 0x99;
e->draw_props = 0;
e->control = 0;
e->shadow = 3;
e->addr = ADDRESS_OF_SPRITE_DATA;
map_palette(e);
do_spr_order_shadows(e);


So progress is good. Once I get to the stage where there is something more interesting, I'll release a demo build.

No comments: