Expanded ToP interleave detection to DKJM2, minor fix

This commit is contained in:
n-a-c-h
2003-07-20 13:08:09 +00:00
parent 0fa8db07c4
commit fe35d7d395

View File

@@ -56,6 +56,15 @@ bool validChecksum(unsigned char *ROM, int BankLoc)
return(false); return(false);
} }
bool EHiHeader(unsigned char *ROM, int BankLoc)
{
if (validChecksum(ROM, BankLoc) && ROM[BankLoc+21] == 53)
{
return(true);
}
return(false);
}
void swapBlocks(char *blocks) void swapBlocks(char *blocks)
{ {
int i,j,k; int i,j,k;
@@ -109,7 +118,8 @@ void CheckIntl1(unsigned char *ROM)
else if (validChecksum(ROM, Lo) && !validChecksum(ROM, Hi) && else if (validChecksum(ROM, Lo) && !validChecksum(ROM, Hi) &&
ROM[Lo+25] < 14 && //Country code ROM[Lo+25] < 14 && //Country code
//Rom make up //Rom make up
(ROM[Lo+21] == 33 || ROM[Lo+21] == 49 || ROM[Lo+21] == 53)) (ROM[Lo+21] == 33 || ROM[Lo+21] == 49 ||
ROM[Lo+21] == 53 || ROM[Lo+21] == 58))
{ {
if (ROM[Lo+20] == 32 ||//Check that Header name did not overflow if (ROM[Lo+20] == 32 ||//Check that Header name did not overflow
!(ROM[Lo+21] == ROM[Lo+20] || ROM[Lo+21] == ROM[Lo+19] || !(ROM[Lo+21] == ROM[Lo+20] || ROM[Lo+21] == ROM[Lo+19] ||
@@ -121,10 +131,15 @@ void CheckIntl1(unsigned char *ROM)
} }
} }
void deintToP() void CheckIntlEHi(unsigned char *ROM)
{ {
//Swap 2MB and 4MB ROMs if (EHiHeader(ROM, Lo))
unsigned int temp, i, *loc1 = romdata, *loc2 = romdata + 0x80000; {
unsigned int temp, i, oldNumBanks = NumofBanks,
*loc1 = romdata,
*loc2 = romdata + ((NumofBytes - 0x400000)/4);
//Swap 4MB ROM with the other one
for (i = 0; i < 0x100000; i++) for (i = 0; i < 0x100000; i++)
{ {
temp = loc1[i]; temp = loc1[i];
@@ -136,16 +151,18 @@ void deintToP()
NumofBanks = 128; NumofBanks = 128;
deintlv1(); deintlv1();
//Now the 2MB one //Now the other one
NumofBanks = 64; NumofBanks = oldNumBanks - 128;
romdata += 0x100000; //Ofset pointer romdata += 0x100000; //Ofset pointer
deintlv1(); deintlv1();
//Now fix the data and we're done //Now fix the data and we're done
NumofBanks = 192; NumofBanks = oldNumBanks;
romdata -= 0x100000; romdata -= 0x100000;
}
Interleaved = true;
}
}
//ROM loading functions, which some strangly enough were in guiload.inc //ROM loading functions, which some strangly enough were in guiload.inc
bool AllASCII(char *b, int size) bool AllASCII(char *b, int size)
@@ -164,6 +181,7 @@ bool AllASCII(char *b, int size)
int InfoScore(char *Buffer) int InfoScore(char *Buffer)
{ {
int score = 0; int score = 0;
if (validChecksum(Buffer, 0)) { score += 3; }
if (Buffer[26] == 0x33) { score += 2; } if (Buffer[26] == 0x33) { score += 2; }
if ((Buffer[21] & 0xf) < 4) { score += 2; } if ((Buffer[21] & 0xf) < 4) { score += 2; }
if (!(Buffer[61] & 0x80)) { score -= 4; } if (!(Buffer[61] & 0x80)) { score -= 4; }
@@ -184,12 +202,10 @@ void BankCheck()
if (NumofBytes >= 0x500000) if (NumofBytes >= 0x500000)
{ {
if (validChecksum(ROM, 0x207FC0)) //Deinterleave if neccesary
{ CheckIntlEHi(ROM);
deintToP();
Interleaved = true; if (EHiHeader(ROM, EHi))
}
if (validChecksum(ROM, EHi))
{ {
romtype = 2; romtype = 2;
infoloc = EHi; infoloc = EHi;
@@ -204,10 +220,7 @@ void BankCheck()
CheckIntl1(ROM); CheckIntl1(ROM);
loscore = InfoScore(ROM+Lo); loscore = InfoScore(ROM+Lo);
if (validChecksum(ROM, Lo)) { loscore += 3; }
hiscore = InfoScore(ROM+Hi); hiscore = InfoScore(ROM+Hi);
if (validChecksum(ROM, Hi)) { hiscore += 3; }
switch(ROM[Lo + 21]) switch(ROM[Lo + 21])
{ {