SNES Sprites

This was very large and I had to write more sections in different parts of the tutorial, so please tell me if anything is confusing. I have not proofread any of this.

Sprites are important to every game. They are coined after the objects that move in a game, and there are ALOT of moving objects in a game! So... sprites are very important to any demo or game, capiche?

I want you to read the S ...

Sprites

The SNES has 128 independent sprites. The sprite definitions are stored in Object Attribute Memory, or OAM.

OAM

OAM consists of 544 bytes, organized into a low table of 512 bytes and a high table of 32 bytes. Both tables are made up of 128 records. OAM is accessed by setting the word address in register $2102, the "table select" in bit 0 of $2103, then writing to &#36 ...

How to display sprites

Just like the NES, the SNES has a special area of memory called the OAM, that stores the attributes of sprites. For the NES using sprites is pretty straight forward:

  1. During the main game routine, write sprites to an OAM buffer.

  2. At the end of the main game routine, move the unused sprites in the OAM buffer offscreen.

  3. During vblank period, DMA the OAM buffer, into OAM.

Each sp ...

Registers

Address Bus B Registers

TODO: note on fast access time

Register Address Name Style Access Timing
Screen Display Register $2100 INIDISP single write any time
Object Size and ...

Widespread Myths

These are myths that frequently show up that mislead people into writing bad code based on false perception of what the system actually does.

Myth: The PPU steals cycles from the CPU if there are a lot of sprites on-screen.

Fact: The PPU does not steal cycles. What takes CPU time is calculating where each sprite is moving and writing the sprites to the OAM. If you need to use a lot of sprite ...

Timing

This is a document intended to describe various aspects of SNES timing. It will probably not be useful unless you already know a good bit about the SNES.

BTW, special credit to byuu for the critical observation that the SNES returns to a known timing position on reset. Thus, a deterministic ROM (i.e. it doesn't depend on user input or any other randomness) will always give the same results on r ...

Finding free VRAM spots for 32x32 and 16x16 sprites

This code will allow you to automatically find an empty space in VRAM so you can fit a 16x16 or 32x32 sprite pattern as needed.

If you need to find an open 32x32 VRAM sprite slot, jump to the "find_32x32_slot" routine, and it will return the CHR number in the accumulator, for use in the OAM. Same with finding an open 16x16 slot. To find the VRAM address to DMA the sprite, multiply the CHR num ...

BS-X RAM Map

This page contains the RAM Map of the BS-X.

 $7E00AC - BS-X Token Interpreter Current Address (24-bit)
 
 $7E0725 - Text Settings

 $7E13C5 - Error Number

 $7E1427 - Copy Type
 
 $7E1430 - Current Month
 $7E1431 - Current Day
 $7E1432 - Data Type
 $7E1433 - Seconds before timeout
 $7E1437 - Ticks before timeout

 $7E1C00:$7E1E20 - ...