W-RAM

December 14, 2018 ยท View on GitHub

W-RAM (work RAM) is the SNES onboard memory. 128 kB (131072 bytes) big, it's clocked at 2.68 MHz and can be accessed though addresses$7E:0000-\$7F:FFFF, as well on addresses$0000-\$1FFFthough banks$00-\$3F/$80-$BFand though ports$2180-\$2183on the address bus B. The SA-1 CPU can't access the W-RAM.

SA-1 Pack moves most of the W-RAM addresses to either I-RAM or BW-RAM to make the contents accessible and faster for the SA-1 system. Because of that, a good portion of the W-RAM is either left unused or modified for another cause which does not involve SA-1 CPU access.

Code Memory

The patch places some routines on the W-RAM for several reasons, but the most important of them is to allow that SA-1 CPU will always access the ROM memory at 10.74 MHz when the SNES CPU is idle or busy doing a process that does not need ROM access.

W-RAM Memory Map

Only modified W-RAM addresses are displayed on this document. For checking other SMW addresses, look for the SMW Central RAM map.

Bank $7E

StartEndDescription
$0000$000FScratch Memory. Some codes does not use the I-RAM at all for certain reasons, such as for executing code on the memory. FuSoYa's SA-1 version of LC_LZ2 and LC_LZ3 implementation are examples of that. The reason of that is ZSNES. See Known Issues to understand why.
$0010$0FFFEmpty. Not cleared.
$1000$1E7FEmpty. Not cleared. Reserved by SA-1 Pack for future expansion.
$1D00-IRQ-as-NMI system (x------e)
  • Bit 0 (e): When set, the V-Blank routine is moved to an IRQ and NMI is disabled.
  • Bit 7 (x): When set, the next IRQ will be the V-Blank routine. Used internally wheneis set.
$1D01-Which scanline should the V-Blank run when$1D00is set.
$1D02-Custom IRQ handler flag. If set, all IRQs, with exception of IRQ-as-NMI handler will run on the pointer located at$1D04-\$1D06instead of running on the regular SMW IRQ handelr.
$1D03-Copy of the register$2224. When setting$2224, make sure to set this address as well. This address is used to restore the$2224register value after an IRQ is executed.
$1D04$1D06Custom IRQ handler pointer. All IRQs will jump to this pointer when$1D02is set.
$1D07-Reserved for future use.
$1D08$1DFFThis is where the IRQ controller is uploaded at game reset and is responsible for controlling all S-CPU IRQs received. Calling$1D08activates the IRQ-as-NMI system on the next IRQ call, if enabled.
$1E00$1E7FEmpty. Not cleared. Reserved by SA-1 Pack for future expansion.
$1E80$1E8DSA-1 Execute Pointer. When called, the routine will invoke the SA-1 CPU to run a certain code and wait until the execution is finished.
$1E8E$1E95The game main loop. It waits for a NMI and then resumes executing.
$1E96$1EA6The wait for H-Blank routine. Waits until h-blank starts. When the emulator is ZSNES, this routine is replaced with a special version.
$1EA7$1EFFEmpty. Not cleared. Reserved by SA-1 Pack for future expansion.
$1F00$1FFFReserved for the SNES CPU stack.
$2000$C7FFUntouched by SA-1 Pack.
$C800$FFFFEmpty. Not cleared. Reserved by SA-1 Pack for future expansion.

Bank $7F

StartEndDescription
$0000$9A7AUntouched by SA-1 Pack.
$9A7B$9C7AEmpty. Not cleared.
$9C7B$C7FFUntouched by SA-1 Pack.
$C800$FFFFEmpty. Not cleared. Reserved by SA-1 Pack for future expansion.