mirror of
https://github.com/yellows8/dsi.git
synced 2025-06-18 19:25:42 -04:00
143 lines
4.6 KiB
C
143 lines
4.6 KiB
C
#pragma once
|
|
#include <nds.h>
|
|
|
|
#define NDSHEADER ((tNDSHeader *)0x02FFFE00)
|
|
#define TWLNDSHEADER ((tTWLNDSHeader *)0x02FFE000)
|
|
#define BOOTFLAG *((vu8*)0x02FFFDFB)
|
|
|
|
#define BOOTLDR_NDS 0x02300000
|
|
#define BOOTLDR_NDSHEADER ((tNDSHeader *)BOOTLDR_NDS)
|
|
#define BOOTLDR_TWLNDSHEADER ((tTWLNDSHeader *)BOOTLDR_NDS)
|
|
|
|
typedef struct sTWLNDSHeader {
|
|
char gameTitle[12]; //!< 12 characters for the game title.
|
|
char gameCode[4]; //!< 4 characters for the game code.
|
|
char makercode[2]; //!< identifies the (commercial) developer.
|
|
u8 unitCode; //!< identifies the required hardware.
|
|
u8 deviceType; //!< type of device in the game card
|
|
u8 deviceSize; //!< capacity of the device (1 << n Mbit)
|
|
u8 reserved1[9];
|
|
u8 romversion; //!< version of the ROM.
|
|
u8 flags; //!< bit 2: auto-boot flag.
|
|
|
|
u32 arm9romOffset; //!< offset of the arm9 binary in the nds file.
|
|
u32 arm9executeAddress; //!< adress that should be executed after the binary has been copied.
|
|
u32 arm9destination; //!< destination address to where the arm9 binary should be copied.
|
|
u32 arm9binarySize; //!< size of the arm9 binary.
|
|
|
|
u32 arm7romOffset; //!< offset of the arm7 binary in the nds file.
|
|
u32 arm7executeAddress; //!< adress that should be executed after the binary has been copied.
|
|
u32 arm7destination; //!< destination address to where the arm7 binary should be copied.
|
|
u32 arm7binarySize; //!< size of the arm7 binary.
|
|
|
|
u32 filenameOffset; //!< File Name Table (FNT) offset.
|
|
u32 filenameSize; //!< File Name Table (FNT) size.
|
|
u32 fatOffset; //!< File Allocation Table (FAT) offset.
|
|
u32 fatSize; //!< File Allocation Table (FAT) size.
|
|
|
|
u32 arm9overlaySource; //!< File arm9 overlay offset.
|
|
u32 arm9overlaySize; //!< File arm9 overlay size.
|
|
u32 arm7overlaySource; //!< File arm7 overlay offset.
|
|
u32 arm7overlaySize; //!< File arm7 overlay size.
|
|
|
|
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)
|
|
u32 bannerOffset; //!< offset to the banner with icon and titles etc.
|
|
|
|
u16 secureCRC16; //!< Secure Area Checksum, CRC-16.
|
|
|
|
u16 readTimeout; //!< Secure Area Loading Timeout.
|
|
|
|
u32 unknownRAM1; //!< ARM9 Auto Load List RAM Address (?)
|
|
u32 unknownRAM2; //!< ARM7 Auto Load List RAM Address (?)
|
|
|
|
u32 bfPrime1; //!< Secure Area Disable part 1.
|
|
u32 bfPrime2; //!< Secure Area Disable part 2.
|
|
u32 romSize; //!< total size of the ROM.
|
|
|
|
u32 headerSize; //!< ROM header size.
|
|
u32 zeros88[14];
|
|
u8 gbaLogo[156]; //!< Nintendo logo needed for booting the game.
|
|
u16 logoCRC16; //!< Nintendo Logo Checksum, CRC-16.
|
|
u16 headerCRC16; //!< header checksum, CRC-16.
|
|
|
|
u32 debugRomSource; //!< debug ROM offset.
|
|
u32 debugRomSize; //!< debug size.
|
|
u32 debugRomDestination; //!< debug RAM destination.
|
|
u32 offset_0x16C; //reserved?
|
|
u8 debug_reserved[0x10];
|
|
|
|
u8 config_settings[52];
|
|
u32 access_control;//0x1b4
|
|
u32 scfg_ext_mask;
|
|
u32 reserved_1bc;
|
|
|
|
u32 arm9iromOffset;
|
|
u32 arm9ireserved;
|
|
u32 arm9idestination;
|
|
u32 arm9ibinarySize;
|
|
|
|
u32 arm7iromOffset;
|
|
u32 arm7ititleparams;
|
|
u32 arm7idestination;
|
|
u32 arm7ibinarySize;
|
|
|
|
u32 digest_ntr_offset;
|
|
u32 digest_ntr_size;
|
|
u32 digest_twl_offset;
|
|
u32 digest_twl_size;
|
|
|
|
u32 digest_sector_hashtable_offset;
|
|
u32 digest_sector_hashtable_size;
|
|
u32 digest_block_hashtable_offset;
|
|
u32 digest_block_hashtable_size;
|
|
|
|
u32 digest_sector_size;
|
|
u32 digest_block_sectorcount;
|
|
|
|
u8 reserved_208[24];
|
|
|
|
u32 modcrypt1_offset;
|
|
u32 modcrypt1_size;
|
|
u32 modcrypt2_offset;
|
|
u32 modcrypt2_size;
|
|
|
|
u64 titleid;
|
|
u32 publicsav_size;
|
|
u32 privatesav_size;
|
|
|
|
u8 reserved_238[192];
|
|
|
|
u8 arm9_sec_hmac[20];//sha1 hmac /w encrypted secure area
|
|
u8 arm7_hmac[20];
|
|
u8 digest_master_hmac[20];
|
|
u8 banner_hmac[20];
|
|
u8 arm9i_hmac[20];
|
|
u8 arm7i_hmac[20];
|
|
|
|
u8 reserved_378[40];
|
|
u8 arm9_unsec_hmac[20];//without secure area
|
|
|
|
u8 reserved_3b4[2636];
|
|
u8 reserved_debugargs[0x180];
|
|
|
|
u8 signature[0x80];
|
|
|
|
} __attribute__ ((__packed__)) tTWLNDSHeader;
|
|
|
|
typedef unsigned int size_t;
|
|
void* memset(void* buffer, int val, size_t len);
|
|
void* memcpy(void* a, const void* b, size_t len);
|
|
void* memcpy16(void* a, const void* b, size_t len);
|
|
void memset_addrs(void* start, void* end);
|
|
void memcpy_addrs(void* start, void* end, void* dst);
|
|
void memcpy16_addrs(void* start, void* end, void* dst);
|
|
void* memcpy_arm9(u32 *a, u32 *b, size_t len);
|
|
void* memset_arm9(u32 *buffer, int val, size_t len);
|
|
|
|
void memset_arm7(u32 *buffer, int val, size_t len);
|
|
void memcpy_arm7(u32 *a, u32 *b, size_t len);
|
|
void memcpy8_arm7(u8 *a, u8 *b, size_t len);
|
|
void memset_addrs_arm7(u32 start, u32 end);
|
|
void memset8_arm7(u8 *buffer, int val, size_t len);
|