gamecart: Use the chip ID's TWL flag to check if we should do TWL secure area init.

It's possible to flash a TWL-enhanced ROM image to an NTR dev cart.
This cart would function properly as a Nintendo DS game, but might
have issues on a DSi or 3DS.

GodMode9 couldn't dump this type of cartridge before because the ROM
header indicates TWL, but the cartridge doesn't understand the 0x3D
TWL secure area init command, so key exchange failed.
This commit is contained in:
David Korth 2020-11-12 20:33:56 -05:00 committed by d0k3
parent cadd21508f
commit d63db4bc6d

View File

@ -144,9 +144,14 @@ u32 InitCartRead(CartData* cdata) {
if ((cdata->arm9i_rom_offset < nds_header->ntr_rom_size) ||
(cdata->arm9i_rom_offset + MODC_AREA_SIZE > cdata->data_size))
return 1; // safety first
Cart_Init();
NTR_CmdReadHeader(cdata->twl_header);
if (!NTR_Secure_Init(cdata->twl_header, Cart_GetID(), 1)) return 1;
// Some NTR dev carts have TWL ROMs flashed to them.
// We'll only want to use TWL secure init if this is a TWL cartridge.
if (cdata->cart_id & 0x40000000U) { // TWL cartridge
Cart_Init();
NTR_CmdReadHeader(cdata->twl_header);
if (!NTR_Secure_Init(cdata->twl_header, Cart_GetID(), 1)) return 1;
}
}
// last safety check