I recently updated and released the source code to Sega Sprite Viewer. This tool allows you to view the contents of sprite roms from many popular Sega games of the era.
Hardware that (should) be supported includes:
- Sega Hang-On Hardware (including Enduro Racer & Space Harrier)
- Sega System 16 (Golden Axe, Altered Beast, Shinobi etc.)
- Sega System 18 (Moonwalker, Shadowdancer etc.)
- Sega OutRun (including Super Hang-On)
- Sega X-Board (AfterBurner, Thunderblade etc.)
- Sega Y-Board (Power Drift, G-Loc etc.)
Part 1: Viewing Sprites
Let's take an example System 16 game, in this case Altered Beast. First up, we can establish the configuration of the sprite roms by looking at the MAME System 16 driver here.
- Format 0 specifies System 16 sprite format.
- This example places the sprite roms in a sub-directory named roms/altbeast/
- The offset and length of the files are configured to match the MAME driver.
- You can view the final configuration file here for reference.
s16_viewer altbeast.xml
Part 2: Extracting Palettes
Establish the location of Palette RAM
Altered Beast is a System 16 based game. For System 16 games, the location of palette RAM is allocated dynamically at run-time by the Sega 315-5195 Memory Mapper. (Note, that other Sega hardware titles will configure the location of palette RAM differently - the point is that it's a sensible first step to determine its location).- View the 315-5195 Memory Mapper m_regs configuration.
- The yellow highlighted value ($84) at offset $1d contains the details we are interested in.
- This value is left shifted by $10, giving us the location of palette RAM: $840000
- Often the sprite palette is at offset +$800 within the palette RAM. Therefore $840800. (I know this part through pattern recognition, but it can also be established from decompiling the code further, as we shall see later.)
Establish where Palette RAM is populated from
The main takeaways from this section of code are as follows:
- Address register A2 points to a table of address information containing the source address in ROM and destination address in palette RAM to move the values between.
- Address register A0 is loaded with the source address. (a location in the program ROM)
- Address register A1 is loaded with the destination address. (sprite palette RAM)
- It should be noted that 28 bytes are copied, not the full 32 bytes required by sprite hardware. This is important palette format information we will need later.
- A byte is used (0-255) as an index into the table of entries. So we can assume that the palette table contains 255 entries max (highlighted in yellow and loaded to D0).
- This routine specifies $242a0 as the first sprite palette entry (highlighted in yellow and loaded to A1).
- We established each entry was 28 bytes previously. This means the table is $1be4 in length (28 bytes * 255 entries).
This gives us the final solution to our puzzle. We know where all the palette entries are first stored, before palette RAM is even accessed. We also know how many entries are in the table.