SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
sram.h File Reference

SRAM (Static RAM used for save backup) support. More...

#include "mapper.h"
Include dependency graph for sram.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SRAM_CONTROL   MAPPER_BASE
 
#define SRAM_BASE   0x200001
 

Functions

void SRAM_enable (void)
 Enable SRAM in Read Write mode.
 
void SRAM_enableRO (void)
 Enable SRAM in Read Only mode.
 
void SRAM_disable (void)
 Disable SRAM.
 
u8 SRAM_readByte (u32 offset)
 Read a byte from the SRAM.
 
u16 SRAM_readWord (u32 offset)
 Read a word from the SRAM.
 
u32 SRAM_readLong (u32 offset)
 Read a long from the SRAM.
 
void SRAM_writeByte (u32 offset, u8 val)
 Write a byte to the SRAM.
 
void SRAM_writeWord (u32 offset, u16 val)
 Write a word to the SRAM.
 
void SRAM_writeLong (u32 offset, u32 val)
 Write a long to the SRAM.
 

Detailed Description

SRAM (Static RAM used for save backup) support.

Author
Chilly Willy & Stephane Dallongeville
Date
08/2012

This unit provides methods to read from or write to SRAM.
By default we suppose SRAM is 8bit and connected to odd address.
You can change to even address by changing SRAM_BASE from 0x200001 to 0x200000 and rebuild the library.

Informations about SRAM (taken from Segaretro.org):
The regions specified by 0xA130F9-0xA130FF (0x200000-0x3FFFFF) can be either ROM or RAM and can be write-protected.
Here is the layout of the register as far as I know:

7 6 5 4 3 2 1 0
+--------------------—+
|??|??|??|??|??|??|WP|MD|
+--------------------—+

MD: Mode – 0 = ROM, 1 = RAM
WP: Write protect – 0 = writable, 1 = not writable

Function Documentation

◆ SRAM_readByte()

u8 SRAM_readByte ( u32 offset)

Read a byte from the SRAM.

Parameters
offsetOffset where we want to read.
Returns
value.

◆ SRAM_readLong()

u32 SRAM_readLong ( u32 offset)

Read a long from the SRAM.

Parameters
offsetOffset where we want to read.
Returns
value.

◆ SRAM_readWord()

u16 SRAM_readWord ( u32 offset)

Read a word from the SRAM.

Parameters
offsetOffset where we want to read.
Returns
value.

◆ SRAM_writeByte()

void SRAM_writeByte ( u32 offset,
u8 val )

Write a byte to the SRAM.

Parameters
offsetOffset where we want to write.
valValue wto write.

◆ SRAM_writeLong()

void SRAM_writeLong ( u32 offset,
u32 val )

Write a long to the SRAM.

Parameters
offsetOffset where we want to write.
valValue wto write.

◆ SRAM_writeWord()

void SRAM_writeWord ( u32 offset,
u16 val )

Write a word to the SRAM.

Parameters
offsetOffset where we want to write.
valValue wto write.