/*--------------------------------------------------------------------------------- memory.h -- Declaration of memory regions Copyright (C) 2005 Michael Noland (joat) and Jason Rogers (dovoto) This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ---------------------------------------------------------------------------------*/ /*! \file memory.h \brief Defines for many of the regions of memory on the DS as well as a few control functions for memory bus access */ #ifndef NDS_MEMORY_INCLUDE #define NDS_MEMORY_INCLUDE #include "ndstypes.h" #ifdef ARM9 #define REG_EXMEMCNT (*(vu16*)0x04000204) #else #define REG_EXMEMSTAT (*(vu16*)0x04000204) #endif #define ARM7_MAIN_RAM_PRIORITY BIT(15) #define ARM7_OWNS_CARD BIT(11) #define ARM7_OWNS_ROM BIT(7) // Protection register (write-once sadly) #ifdef ARM7 #define PROTECTION (*(vu32*)0x04000308) #endif #define ALLRAM ((u8*)0x00000000) /*! \brief 8 bit pointer to main ram */ #define MAINRAM8 ((u8*)0x02000000) /*! \brief 16 bit pointer to main ram */ #define MAINRAM16 ((u16*)0x02000000) /*! \brief 32 bit pointer to main ram */ #define MAINRAM32 ((u32*)0x02000000) // fixme: shared RAM // GBA_BUS is volatile, while GBAROM is not /*! \brief 16 bit pointer to the GBA slot bus */ #define GBA_BUS ((vu16 *)(0x08000000)) #define GBAROM ((u16*)0x08000000) /*! \brief 8 bit pointer to GBA slot Save ram */ #define SRAM ((u8*)0x0A000000) #ifdef ARM7 #define VRAM ((u16*)0x06000000) #endif /*! * \brief the GBA file header format */ typedef struct sGBAHeader { u32 entryPoint; u8 logo[156]; char title[0xC]; char gamecode[0x4]; u16 makercode; u8 is96h; u8 unitcode; u8 devicecode; u8 unused[7]; u8 version; u8 complement; u16 checksum; } __attribute__ ((__packed__)) tGBAHeader; #define GBA_HEADER (*(tGBAHeader *)0x08000000) /*! * \brief the NDS file header format */ typedef struct sNDSHeader { char gameTitle[12]; char gameCode[4]; char makercode[2]; u8 unitCode; u8 deviceType; // type of device in the game card u8 deviceSize; // device capacity (1<