DS: Attempt to detect if a game is homebrew

This commit is contained in:
Vicki Pfau 2017-04-12 00:54:32 -07:00
parent f96a8f78eb
commit 9a35691a03
3 changed files with 16 additions and 0 deletions

View File

@ -17,6 +17,7 @@ Misc:
- ARM9: Implement SMLAW<y> and SMULW<y> - ARM9: Implement SMLAW<y> and SMULW<y>
- Qt: Add .nds files to the extension list in Info.plist - Qt: Add .nds files to the extension list in Info.plist
- ARM9: Implement STRD/LDRD - ARM9: Implement STRD/LDRD
- DS: Attempt to detect if a game is homebrew
0.6.0: (Future) 0.6.0: (Future)
Features: Features:

View File

@ -123,6 +123,8 @@ struct DS {
struct mTimingEvent divEvent; struct mTimingEvent divEvent;
struct mTimingEvent sqrtEvent; struct mTimingEvent sqrtEvent;
bool isHomebrew;
}; };
struct DSCartridge { struct DSCartridge {
@ -158,6 +160,15 @@ struct DSCartridge {
uint32_t iconOffset; uint32_t iconOffset;
uint16_t secureAreaCrc16; uint16_t secureAreaCrc16;
uint16_t secureAreaDelay; uint16_t secureAreaDelay;
uint32_t arm9Autoload;
uint32_t arm7Autoload;
uint8_t secureAreaDisable[8];
uint32_t usedSize;
uint32_t romHeaderSize;
uint8_t reserved2[56];
uint8_t logo[156];
uint16_t logoCrc16;
uint16_t headerCrc16;
// TODO: Fill in more // TODO: Fill in more
// And ROM data... // And ROM data...
}; };

View File

@ -294,6 +294,7 @@ void DS7Reset(struct ARMCore* cpu) {
DS7IOInit(ds); DS7IOInit(ds);
DSConfigureWRAM(&ds->memory, 3); DSConfigureWRAM(&ds->memory, 3);
ds->isHomebrew = false;
struct DSCartridge* header = ds->romVf->map(ds->romVf, sizeof(*header), MAP_READ); struct DSCartridge* header = ds->romVf->map(ds->romVf, sizeof(*header), MAP_READ);
if (header) { if (header) {
@ -304,6 +305,9 @@ void DS7Reset(struct ARMCore* cpu) {
ds->memory.ram[0x3FFC40 >> 2] = 1; ds->memory.ram[0x3FFC40 >> 2] = 1;
memcpy(&ds->memory.ram[0x3FFE00 >> 2], header, 0x170); memcpy(&ds->memory.ram[0x3FFE00 >> 2], header, 0x170);
DS7IOWrite32(ds, DS_REG_ROMCNT_LO, header->busTiming | 0x2700000); DS7IOWrite32(ds, DS_REG_ROMCNT_LO, header->busTiming | 0x2700000);
ds->isHomebrew = memcmp(&header->logoCrc16, DS_ROM_MAGIC, sizeof(header->logoCrc16));
// TODO: Error check // TODO: Error check
ds->romVf->seek(ds->romVf, header->arm7Offset, SEEK_SET); ds->romVf->seek(ds->romVf, header->arm7Offset, SEEK_SET);
uint32_t base = header->arm7Base; uint32_t base = header->arm7Base;