libnds
Data Structures | Defines | Functions | Variables

memory.h File Reference

Defines for many of the regions of memory on the DS as well as a few control functions for memory bus access. More...

#include "ndstypes.h"

Data Structures

struct  sGBAHeader
 the GBA file header format. See gbatek for more info. More...
struct  sNDSBanner
 the NDS banner format. See gbatek for more information. More...
struct  sNDSHeader
 the NDS file header format See gbatek for more info. More...

Defines

#define ALLRAM   ((u8*)0x00000000)
 8 bit pointer to the start of all the ram.
#define GBA_BUS   ((vu16 *)(0x08000000))
 16 bit volatile pointer to the GBA slot bus.
#define GBAROM   ((u16*)0x08000000)
 16 bit pointer to the GBA slot ROM.
#define MAINRAM16   ((u16*)0x02000000)
 16 bit pointer to main ram.
#define MAINRAM32   ((u32*)0x02000000)
 32 bit pointer to main ram.
#define MAINRAM8   ((u8*)0x02000000)
 8 bit pointer to main ram.
#define SRAM   ((u8*)0x0A000000)
 8 bit pointer to GBA slot Save ram.

Functions

struct sGBAHeader __attribute__ ((__packed__)) tGBAHeader
 the GBA file header format. See gbatek for more info.
void sysSetBusOwners (bool arm9rom, bool arm9card)
 Sets the owner of the DS card bus (slot 1) and gba cart bus (slot 2). Only one cpu may access the device at a time.
void sysSetCardOwner (bool arm9)
 Sets the owner of the DS card bus. Both CPUs cannot have access to the DS card bus (slot 1).
void sysSetCartOwner (bool arm9)
 Sets the owner of the GBA cart. Both CPUs cannot have access to the gba cart (slot 2).

Variables

u32 arm7binarySize
 size of the arm7 binary.
u32 arm7destination
 destination address to where the arm7 binary should be copied.
u32 arm7executeAddress
 adress that should be executed after the binary has been copied.
u32 arm7overlaySize
 File arm7 overlay size.
u32 arm7overlaySource
 File arm7 overlay offset.
u32 arm7romOffset
 offset of the arm7 binary in the nds file.
u32 arm9binarySize
 size of the arm9 binary.
u32 arm9destination
 destination address to where the arm9 binary should be copied.
u32 arm9executeAddress
 adress that should be executed after the binary has been copied.
u32 arm9overlaySize
 File arm9 overlay size.
u32 arm9overlaySource
 File arm9 overlay offset.
u32 arm9romOffset
 offset of the arm9 binary in the nds file.
u32 bannerOffset
 offset to the banner with icon and titles etc.
u32 bfPrime1
 Secure Area Disable part 1.
u32 bfPrime2
 Secure Area Disable part 2.
u32 cardControl13
 Port 40001A4h setting for normal commands (used in modes 1 and 3)
u32 cardControlBF
 Port 40001A4h setting for KEY1 commands (used in mode 2)
u16 checksum
 a 16 bit checksum? (gbatek says its unused/reserved).
u8 complement
 complement checksum of the gba header.
u16 crc
 16 bit crc/checksum of the banner.
u32 debugRomDestination
 debug RAM destination.
u32 debugRomSize
 debug size.
u32 debugRomSource
 debug ROM offset.
u8 devicecode
 used by nintedo's hardware debuggers. normally 0.
u8 deviceSize
 capacity of the device (1 << n Mbit)
u8 deviceType
 type of device in the game card
u32 entryPoint
 32 bits arm opcode to jump to executable code.
u32 fatOffset
 File Allocation Table (FAT) offset.
u32 fatSize
 File Allocation Table (FAT) size.
u32 filenameOffset
 File Name Table (FNT) offset.
u32 filenameSize
 File Name Table (FNT) size.
u8 flags
 bit 2: auto-boot flag.
char gamecode [0x4]
 4 characters for the game code. first character is usally A or B, next 2 characters is a short title < and last character is for destination/language.
char gameCode [4]
 4 characters for the game code.
char gameTitle [12]
 12 characters for the game title.
u8 gbaLogo [156]
 Nintendo logo needed for booting the game.
u16 headerCRC16
 header checksum, CRC-16.
u32 headerSize
 ROM header size.
u8 icon [512]
 32*32 icon of the game with 4 bit per pixel.
u8 is96h
 fixed value that is always 96h.
u8 logo [156]
 nintendo logo needed for booting the game.
u16 logoCRC16
 Nintendo Logo Checksum, CRC-16.
u16 makercode
 identifies the (commercial) developer.
u16 palette [16]
 the pallete of the icon.
u16 readTimeout
 Secure Area Loading Timeout.
u32 romSize
 total size of the ROM.
u8 romversion
 version of the ROM.
u16 secureCRC16
 Secure Area Checksum, CRC-16.
char title [0xC]
 12 characters for the game title.
u16 titles [6][128]
 title of the game in 6 different languages.
u8 unitcode
 identifies the required hardware.
u8 unitCode
 identifies the required hardware.
u32 unknownRAM1
 ARM9 Auto Load List RAM Address (?)
u32 unknownRAM2
 ARM7 Auto Load List RAM Address (?)
u8 version
 the version of the game.

Detailed Description

Defines for many of the regions of memory on the DS as well as a few control functions for memory bus access.


Function Documentation

struct sGBAHeader __attribute__ ( (__packed__)  )

the GBA file header format. See gbatek for more info.

the NDS banner format. See gbatek for more information.

the NDS file header format See gbatek for more info.

static void sysSetBusOwners ( bool  arm9rom,
bool  arm9card 
) [inline]

Sets the owner of the DS card bus (slot 1) and gba cart bus (slot 2). Only one cpu may access the device at a time.

Parameters:
arm9romif true the arm9 is the owner of slot 2, otherwise the arm7
arm9cardif true the arm9 is the owner of slot 1, otherwise the arm7
Examples:
card/eeprom/source/main.cpp.
static void sysSetCardOwner ( bool  arm9) [inline]

Sets the owner of the DS card bus. Both CPUs cannot have access to the DS card bus (slot 1).

Parameters:
arm9if true the arm9 is the owner, otherwise the arm7
static void sysSetCartOwner ( bool  arm9) [inline]

Sets the owner of the GBA cart. Both CPUs cannot have access to the gba cart (slot 2).

Parameters:
arm9if true the arm9 is the owner, otherwise the arm7

Variable Documentation

the version of the game.

version of the banner.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines