Memory Map Summary

June 30, 2021 ยท View on GitHub

This is a quick summary of the memory changes made by the SAS Memory Map and by SA-1 Pack.

Hybrid Remapping

It's possible to write code that works with both SA-1 Pack SMW ROMs and regular SMW ROMs by detecting the ROM mapper and using a couple of defines depending of the ROM type detected. Take a look at remap.asm.

More important than making hybrid ASM code, it's understanding how the SA-1 memory map works and how you can make your code potentially much faster and with a higher compatibility on SA-1 SMW ROMs. This document contains a well-summarized information about the SA-1 memory map.

ROM Memory Map

SA-1 features the Super MMC, a memory controller that can support ROMs larger than 4 MB. It offers bank switching support though registers$2220-\$2223, which allows switching ROM data in blocks of 1 MB.

LoROM banks

Applies for any ROM size.

Bank RangeDescription
$00-\$1F1st Mbyte of the ROM. Super MMC register$2220CXB.
$20-\$3F2nd Mbyte of the ROM. Super MMC register$2221DXB.
$80-\$9F3rd Mbyte of the ROM. Super MMC register$2222EXB.
$A0-$BF4th Mbyte of the ROM. Super MMC register$2223FXB.

HiROM banks

Applies for ROMs up to 4 MB.

Bank RangeDescription
$C0-$CF1st Mbyte of the ROM. Super MMC register$2220CXB.
$D0-$DF2nd Mbyte of the ROM. Super MMC register$2221DXB.
$E0-$EF3rd Mbyte of the ROM. Super MMC register$2222EXB.
$F0-$FF4th Mbyte of the ROM. Super MMC register$2223FXB.

ExHiROM banks

Applies for ROMs larger than 4 MB and up to 8 MB. LoROM mapping is not affected for the way SA-1 Pack configures the SAS Memory Map.

Bank RangeDescription
$C0-$CF5th Mbyte of the ROM. Super MMC register$2220CXB.
$D0-$DF6th Mbyte of the ROM. Super MMC register$2221DXB.
$E0-$EF7th Mbyte of the ROM. Super MMC register$2222EXB.
$F0-$FF8th Mbyte of the ROM. Super MMC register$2223FXB.

Dual ROM System

The Dual ROM system works by merging two or more ROMs in a single one and selecting which ROM image to project using the Super MMC registers. For example, two 4 MB ROMs can be merged and the first ROM can be loaded by loading values$00-\$03to the registers$2220-\$2223 and the second ROM can be loaded by loading values$04-\$07to the same registers.

In practice, the Dual ROM system allows to either merge two games together or double the amount of resources available (levels, map16, music, sprites, overworlds, etc.) with the compromise of having to control two or more gamepak ROMs at the same time.

SA-1 Pack currently does not include a Dual ROM system controller.

RAM Memory Map

The SA-1 CPU (C-CPU) can't access the W-RAM, therefore to transfer some routine to it it's required to remap most of the game memory either to I-RAM or BW-RAM. Other than that, both S-CPU and C-CPU memory maps are fairly similar.

RAM banks

BanksAccessDescription
$00-\$3FC-CPUI-RAM at addresses$0000-\$07FF @ 10.74 MHz
$00-\$3FS-CPUW-RAM at addresses$0000-\$1FFF @ 2.68 MHz
$00-\$3FBothI-RAM at addresses$3000-\$37FF @ 10.74 MHz
$00-\$3FBothBW-RAM Virtual Memory at addresses$6000-\$7FFF @ 5.37 MHz
$40-\$4FBothBW-RAM @ 5.37 MHz
$60-\$6FC-CPUBW-RAM Virtual Bitmap Memory @ 5.37 MHz
$7E-\$7FS-CPUW-RAM @ 2.68 MHz
$80-$BFC-CPUI-RAM at addresses$0000-\$07FF @ 10.74 MHz
$80-$BFS-CPUW-RAM at addresses$0000-\$1FFF @ 2.68 MHz
$80-$BFBothI-RAM at addresses$3000-\$37FF @ 10.74 MHz
$80-$BFBothBW-RAM Virtual Memory at addresses$6000-\$7FFF @ 5.37 MHz

16-bit (Absolute) Addresses

FromToComment
$0000-\$00FF$3000-\$30FFNote that you don't need to change direct page opcodes, likeLDA \$19. The remap only applies to 16-bit opcodes such asJML [\$0000]orSTA \$00B6,y.
$0100-\$1FFF$6100-\$7FFFYou also can change data bank to $40 and stay with the address, paying attention to the other RAM addresses outside the range.

24-bit (Absolute Long) Addresses

FromToComment
$7E:1938-\$7E:19B7$41:8A00-\$41:8AFEUsed to be 16-bit (absolute) addressed, now 24-bit (absolute long) to accommodate more sprite entries per level (from 128 to 255).
$7E:C800-\$7E:FFFF$40:C800-\$40:FFFFMap16 low byte plus Overworld related data.
$7F:9A7B-\$7F:9C7A$41:8800-\$41:89FFWiggler's segment buffer.
$7F:C800-\$7F:FFFF$41:C800-\$41:FFFFMap16 high byte.

S-RAM

The S-RAM (static memory) banks used to be banks$70-\$71, but the SAS Memory Map replaces it with BW-RAM, which is also used as work RAM and has is allocated though banks$40-\$43. The remapped addresses are stated below.

FromToComment
$70:0000-\$70:07FF$41:C000-\$41:C7FFOriginal save memory (2 kB big). Not everything is used.
$70:0800-\$70:27FF$41:A000-\$41:BFFFExpansion area planned for SMW hacks.

Sprite Tables

Although the sprite tables are all 16-bit (absolute) addresses and therefore were remapped together to the BW-RAM, Arujus's More Sprites patch had to move them again to accommodate the expanded 22 sprites slots limits. Read more at Sprite Remap doc.