System – Neo-Geo Programming Guide
Understanding the System
In order to program for the Neo-Geo, you'll need to understand how the hardware works at a basic level. This section covers the memory map for the two CPUs, the interaction between the 68000 and the other hardware, and the functionality and formats of Neo-Geo data.
68000 Memory Map
The 68000 is the heart of the operation, and it's where most of your code will run. You'll be sharing it with the BIOS, the Palette, the RAM, system registers, among others.
Cart systems
Start | End | Short Name | Description |
---|---|---|---|
$000000 | $0FFFFF | Vector Table, first bank of P ROM | |
$100000 | $00F2FF | WORKRAM_USER |
User RAM/Work RAM |
$10F300 | $00FFFF | WORKRAM_BIOS |
RAM reserved for use by the BIOS. |
$200000 | $2FFFFF | P ROM second bank; also bankswitching and special chips | |
$300000 | $39FFFF | Input ports | |
$3A0000 | $3BFFFF | Output ports | |
$3C0000 | $3FFFFF | GPU/LSPC ports | |
$400000 | $401FFF | PALETTES |
Current Palette RAM |
$800000 | $BFFFFF | MEMCARD |
Memory card data (8MB max) |
$C00000 | $C1FFFF | BIOSROM |
BIOS ROM (128KB) |
$D00000 | $D0FFFF | BRAM_START ,MVS_BRAM |
MVS-only Backup RAM (64KB) |
CD systems
On CD systems, the layout is mostly similar, though there are some slight differences. As this guide is mostly geared towards cart system development, please don't consider this table to be 100% accurate.
Start | End | Short Name | Description |
---|---|---|---|
$000000 | $0FFFFF | Vector Table, 68k program (.PRG files), 68k RAM |
|
$100000 | $00F2FF | WORKRAM_USER |
User RAM/Work RAM |
$10F300 | $00FFFF | WORKRAM_BIOS |
RAM reserved for use by the BIOS. |
$200000 | $2FFFFF | ? | |
$300000 | $39FFFF | Input ports | |
$3A0000 | $3BFFFF | Output ports | |
$3C0000 | $3FFFFF | GPU/LSPC ports | |
$400000 | $401FFF | PALETTES |
Current Palette RAM |
$800000 | $803FFF | MEMCARD |
Virtual Memory card (8KB max). 8-bit; even bytes are always $FF . |
$C00000 | $C7FFFF | BIOSROM |
BIOS ROM (512KB) |
$E00000 | $E0FFFF | UPLOAD |
Upload zone (1MB) |
$FF0000 | $FF01FF? | CD and DMA specific I/O registers |
Z80 Memory Map
Start | End | Size | Description |
---|---|---|---|
$0000 | $7FFF | 32KB | Main code bank (start of M1 ROM/.Z80 file) |
$8000 | $BFFF | 16KB | Switchable bank 3 |
$C000 | $DFFF | 8KB | Switchable bank 2 |
$E000 | $EFFF | 4KB | Switchable bank 1 |
$F000 | $F7FF | 2KB | Switchable bank 0 |
$F800 | $FFFF | 2KB | Work RAM |
Registers
Like many computers and consoles from the 1980s and 1990s, the Neo-Geo interfaces
with its hardware via registers located in memory. Registers live between $300000
and
$3FFFFF
, but not every address is used.
(todo: this section needs to have two name columns, in cases where the freemlib defines are different)
I/O Registers
Address | Name | Read | Write |
---|---|---|---|
$300000 | REG_P1CCNT |
||
$300001 | REG_DIPSW |
Read hardware dipswitches | Kick watchdog |
System Registers
System Registers are bytes that can only be written to.
Address | Name | Description |
---|---|---|
$3A0001 | REG_NOSHADOW |
Normal video output |
$3A0003 | REG_BIOSVEC ,REG_SWPBIOS |
Use BIOS vector table |
$3A0005 | REG_CRDUNLOCK1 |
Register 1/2 for enabling writes to memory card |
$3A0007 | REG_CRDLOCK2 |
Register 2/2 for disabling writes to memory card |
$3A0009 | CARD_REGSEL ,REG_CRDREGSEL |
Enable memory card register select |
$3A000B | REG_BRDFIX |
Use the BIOS's fix tiles and M1 ROM. |
$3A000D | REG_SRAMLOCK |
Disables writes to MVS-only Backup RAM |
$3A000F | REG_PALBANK1 |
Use palette bank 1 |
$3A0011 | REG_SHADOW |
Darken video output |
$3A0013 | REG_CARTVEC ,REG_SWPROM |
Use cart's vector table |
$3A0015 | REG_CRDLOCK1 |
Register 1/2 for disabling writes to memory card |
$3A0017 | REG_CRDUNLOCK2 |
Register 2/2 for enabling writes to memory card |
$3A0019 | CARD_NORMAL ,REG_CRDNORMAL |
Disable memory card register select |
$3A001B | REG_CRTFIX |
Use the cart's fix tiles and M1 ROM. |
$3A001D | REG_SRAMULOCK |
Enables writes to MVS-only Backup RAM |
$3A001F | REG_PALBANK0 |
Use palette bank 0 |
GPU/LSPC Registers
These registers control the LSPC/GPU. Byte writes only work on odd addresses and store the same data in MSB and LSB.
Address | Name | Read | Write |
---|---|---|---|
$3C0000 | REG_VRAMADDR |
Read VRAM data | Set VRAM address |
$3C0002 | REG_VRAMRW |
Read VRAM data | Write VRAM data |
$3C0004 | REG_VRAMMOD |
Read VRAM increment value | Set VRAM increment value |
$3C0006 | REG_LSPCMODE |
||
$3C0008 | REG_TIMERHIGH |
(invalid) | Timer reload value (MSB) |
$3C000A | REG_TIMERLOW |
(invalid) | Timer reload value (LSB) |
$3C000C | REG_IRQACK |
(invalid) | |
$3C000E | REG_TIMERSTOP |
(invalid) |
Neo-Geo CD Registers
The CD system registers start at $FF0000
. Most of these registers
have to do with the CD hardware and RAM transfers.
(todo)
Palettes
Palette data is located in its own section of RAM, between $400000
and $401FFF
. The palette RAM can be swapped between two banks, allowing
for many possibilities. In total, there are 4096 slots for palette colors, but 256
of them are used for transparency, so the real number is closer to 3,840 (including
the background).
VERY IMPORTANT: The fix layer is only capable of using the first 16 palette sets ($0-$F). Sprites may use all 256 palette sets ($00-$FF).
Each palette consists of 16 colors, the first of which is used for transparency (so only 15 effective colors per fix tile/sprite).
(todo: Color format)
Fix Layer
The data for the Fix Layer lives in VRAM at $7000-$74FF
.
(todo: VRAM fix section data format)
Extension space is from $7500-$7FFF
, but is only known to be used
on the NEO-CMC chips so far. (Is something similar used in modern third-party games?)
Sprites
Sprite tiles are stored differently depending on if the game is for a cart
system or a CD system. On CD systems, the sprites go in .SPR
files,
while on cart systems, the data is split up into two ROMs.
When it comes to actually manipulating sprites, they take up most of the VRAM space.
Start | End | Description |
---|---|---|
$0000 | $6FFF | Sprite Control Block 1 (SCB1) |
$8000 | $81FF | Sprite Control Block 2 (SCB2) |
$8200 | $83FF | Sprite Control Block 3 (SCB3) |
$8400 | $85FF | Sprite Control Block 4 (SCB4) |
$8600 | $867F | Sprite List for Even Scanlines |
$8680 | $86FF | Sprite List for Odd Scanlines |
Sound
The sound in the Neo-Geo is handled by the Yamaha YM2610 (OPNB). The OPNB is capable of 4 channels of FM sound, 3 channels of Yamaha SSG (equivalent to AY-3-8910, or more closely, the YM2149), 6 channels of fixed sampling rate (18,500Hz) ADPCM (A), and one channel of variable sampling rate (1.8KHz-55.5KHz) ADPCM (B).
Unlike the Sega Mega Drive/Genesis, where the (similar) YM2612 could be controlled by either the 68K or the Z80, the Neo-Geo only lets you control the YM2610 from the Z80. Furthermore, the cartridge systems only allow for 2048 bytes of Z80 RAM, meaning most of your data is going to need to be in ROM.
Overall the sound can be broken down into its various ROM components:
- M1 ROM — Z80 Music Driver and Sequence Data
- V ROMs — ADPCM A and B samples
(todo)