set up a system to handle detection of bogus roms by header instead of by extension. fix poly sorting which was broken when changed to a stable sort (will make some invisible gui elements reappear)
This commit is contained in:
parent
1828745e5d
commit
53aaa6850f
|
@ -766,7 +766,7 @@ int NDS_LoadROM( const char *filename,
|
|||
else if ( !strcasecmp(extROM, ".gba") && !strcasecmp(extROM2, ".ds"))
|
||||
type = ROM_DSGBA;
|
||||
else
|
||||
return -1;
|
||||
type = ROM_NDS;
|
||||
|
||||
file = reader->Init(filename);
|
||||
if (!file)
|
||||
|
@ -819,9 +819,15 @@ int NDS_LoadROM( const char *filename,
|
|||
//decrypt if necessary..
|
||||
//but this is untested and suspected to fail on big endian, so lets not support this on big endian
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
DecryptSecureArea(data,size);
|
||||
bool okRom = DecryptSecureArea(data,size);
|
||||
|
||||
if(!okRom) {
|
||||
printf("Specified file is not a valid rom\n");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
MMU_unsetRom();
|
||||
NDS_SetROM(data, mask);
|
||||
NDS_Reset();
|
||||
|
|
|
@ -1412,8 +1412,9 @@ static bool gfx3d_ysort_compare(int num1, int num2)
|
|||
const POLY &poly1 = polylist->list[num1];
|
||||
const POLY &poly2 = polylist->list[num2];
|
||||
|
||||
if (poly1.maxy > poly2.maxy) return true;
|
||||
if (poly1.maxy < poly2.maxy) return false;
|
||||
//this may be verified by checking the game create menus in harvest moon island of happiness
|
||||
if (poly1.maxy > poly2.maxy) return false;
|
||||
if (poly1.maxy < poly2.maxy) return true;
|
||||
if (poly1.miny < poly2.miny) return true;
|
||||
if (poly1.miny > poly2.miny) return false;
|
||||
return false; //equal should always return false "strict weak ordering"
|
||||
|
|
|
@ -449,7 +449,7 @@ static void decrypt_arm9(u32 cardheader_gamecode, unsigned char *data)
|
|||
}
|
||||
|
||||
|
||||
void DecryptSecureArea(u8 *romdata, long romlen)
|
||||
bool DecryptSecureArea(u8 *romdata, long romlen)
|
||||
{
|
||||
//this looks like it will only work on little endian hosts
|
||||
Header* header = (Header*)romdata;
|
||||
|
@ -465,6 +465,9 @@ void DecryptSecureArea(u8 *romdata, long romlen)
|
|||
unsigned int sbox_offsets = 0x2800;
|
||||
#endif
|
||||
|
||||
if(romType == ROMTYPE_INVALID)
|
||||
return false;
|
||||
|
||||
// check if ROM is already encrypted
|
||||
if (romType == ROMTYPE_NDSDUMPED)
|
||||
{
|
||||
|
@ -498,4 +501,6 @@ void DecryptSecureArea(u8 *romdata, long romlen)
|
|||
{
|
||||
printf("File doesn't appear to have a secure area.\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@
|
|||
#ifndef _DECRYPT_H_
|
||||
#define _DECRYPT_H_
|
||||
|
||||
void DecryptSecureArea(u8 *romdata, long romlen);
|
||||
bool DecryptSecureArea(u8 *romdata, long romlen);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -69,6 +69,10 @@
|
|||
int DetectRomType(const Header& header, char* romdata)
|
||||
{
|
||||
unsigned int * data = (unsigned int*)(romdata + 0x4000);
|
||||
|
||||
//this is attempting to check for an utterly invalid nds header
|
||||
if(header.unitcode != 0) return ROMTYPE_INVALID;
|
||||
|
||||
if (header.arm9_rom_offset < 0x4000) return ROMTYPE_HOMEBREW;
|
||||
if (data[0] == 0x00000000 && data[1] == 0x00000000) return ROMTYPE_MULTIBOOT;
|
||||
if (data[0] == 0xE7FFDEFF && data[1] == 0xE7FFDEFF) return ROMTYPE_NDSDUMPED;
|
||||
|
|
|
@ -129,5 +129,6 @@ unsigned short CalcSecureAreaCRC(bool encrypt);
|
|||
#define ROMTYPE_NDSDUMPED 2 // decrypted secure area
|
||||
#define ROMTYPE_ENCRSECURE 3
|
||||
#define ROMTYPE_MASKROM 4 // unknown layout
|
||||
#define ROMTYPE_INVALID 5 // rejected; can't be a supported rom
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue