Got in decent ROM mirroring, Demon's Crest now works right. Megaman X no longer needs point hacks. Expanded Megaman X SRAM hack to Rockman X. Checksum calculation now uses new mirroring code. Prevented possible crash when calculating Hi/Lo. And a few misc fixes.
This commit is contained in:
@@ -95,7 +95,7 @@ EXTSYM GUIfindUSA,GUIfindEUR,GUIfindJAP,GUIfindZIP,GUIfind1,DTALoc,GUIfindall
|
|||||||
EXTSYM spc7110romptr,allocspc7110
|
EXTSYM spc7110romptr,allocspc7110
|
||||||
EXTSYM SRAMDir,SRAMDrive,cfgloadsdir,fnamest,statefileloc
|
EXTSYM SRAMDir,SRAMDrive,cfgloadsdir,fnamest,statefileloc
|
||||||
EXTSYM ForcePal,ForceROMTiming,ForceHiLoROM,InitDir,InitDrive,enterpress,frameskip
|
EXTSYM ForcePal,ForceROMTiming,ForceHiLoROM,InitDir,InitDrive,enterpress,frameskip
|
||||||
EXTSYM infoloc
|
EXTSYM maxromspace,curromspace,infoloc
|
||||||
EXTSYM gotoroot,headdata,printnum,romispal
|
EXTSYM gotoroot,headdata,printnum,romispal
|
||||||
EXTSYM InitFxTables,SFXSRAM,SfxR1,SfxR2,SfxSCMR,SfxSFR,finterleave
|
EXTSYM InitFxTables,SFXSRAM,SfxR1,SfxR2,SfxSCMR,SfxSFR,finterleave
|
||||||
EXTSYM initregr,initregw,memtabler16,DSP1Read16b3F,memaccessbankr16
|
EXTSYM initregr,initregw,memtabler16,DSP1Read16b3F,memaccessbankr16
|
||||||
@@ -2452,39 +2452,13 @@ NEWSYM initsnes
|
|||||||
mov dword[NoiseDisTemp+4],0
|
mov dword[NoiseDisTemp+4],0
|
||||||
mov byte[MMXSRAMFix],0
|
mov byte[MMXSRAMFix],0
|
||||||
|
|
||||||
|
;Megaman/Rockman X
|
||||||
mov esi,[romdata]
|
mov esi,[romdata]
|
||||||
add esi,7FC0h
|
add esi,7FC0h
|
||||||
cmp dword[esi],'MEGA'
|
|
||||||
jne .notmmx
|
|
||||||
cmp dword[esi+4],'MAN '
|
cmp dword[esi+4],'MAN '
|
||||||
jne .notmmx
|
jne .notmmx
|
||||||
cmp dword[esi+8],'X '
|
cmp dword[esi+8],'X '
|
||||||
jne .notmmx
|
jne .notmmx
|
||||||
mov esi,[romdata]
|
|
||||||
cmp byte[esi+824Ah],0F0h
|
|
||||||
jne .mmxa
|
|
||||||
mov byte[esi+824Ah],080h
|
|
||||||
.mmxa
|
|
||||||
cmp byte[esi+21FC3h],0F0h
|
|
||||||
jne .mmxb
|
|
||||||
mov byte[esi+21FC3h],080h
|
|
||||||
.mmxb
|
|
||||||
cmp byte[esi+2241Bh],0F0h
|
|
||||||
jne .mmxc
|
|
||||||
mov byte[esi+2241Bh],080h
|
|
||||||
.mmxc
|
|
||||||
cmp byte[esi+824Fh],0F0h
|
|
||||||
jne .mmxd
|
|
||||||
mov byte[esi+824Fh],080h
|
|
||||||
.mmxd
|
|
||||||
cmp byte[esi+21FC8h],0F0h
|
|
||||||
jne .mmxe
|
|
||||||
mov byte[esi+21FC8h],080h
|
|
||||||
.mmxe
|
|
||||||
cmp byte[esi+22420h],0F0h
|
|
||||||
jne .mmxf
|
|
||||||
mov byte[esi+22420h],080h
|
|
||||||
.mmxf
|
|
||||||
mov byte[MMXSRAMFix],1
|
mov byte[MMXSRAMFix],1
|
||||||
.notmmx
|
.notmmx
|
||||||
|
|
||||||
@@ -4713,7 +4687,7 @@ NEWSYM loadfileGUI
|
|||||||
mov dword[.curfileofs],0
|
mov dword[.curfileofs],0
|
||||||
mov byte[.first],1
|
mov byte[.first],1
|
||||||
mov byte[.multfound],0
|
mov byte[.multfound],0
|
||||||
mov dword[.curromspace],0
|
mov dword[curromspace],0
|
||||||
; open file
|
; open file
|
||||||
mov edx,fname+1
|
mov edx,fname+1
|
||||||
call Open_File
|
call Open_File
|
||||||
@@ -4745,8 +4719,8 @@ NEWSYM loadfileGUI
|
|||||||
je .no16mb
|
je .no16mb
|
||||||
sub ecx,2097152
|
sub ecx,2097152
|
||||||
.no16mb
|
.no16mb
|
||||||
mov [.maxromspace],ecx
|
mov [maxromspace],ecx
|
||||||
sub dword[.maxromspace],32768
|
sub dword[maxromspace],32768
|
||||||
sub ecx,[.curfileofs]
|
sub ecx,[.curfileofs]
|
||||||
jnc .nooverflow
|
jnc .nooverflow
|
||||||
xor ecx,ecx
|
xor ecx,ecx
|
||||||
@@ -4758,7 +4732,7 @@ NEWSYM loadfileGUI
|
|||||||
|
|
||||||
or eax,eax
|
or eax,eax
|
||||||
jz near .success2
|
jz near .success2
|
||||||
add dword[.curromspace],eax
|
add dword[curromspace],eax
|
||||||
mov esi,[headdata]
|
mov esi,[headdata]
|
||||||
add esi,[.curfileofs]
|
add esi,[.curfileofs]
|
||||||
mov edi,[headdata]
|
mov edi,[headdata]
|
||||||
@@ -4793,7 +4767,7 @@ NEWSYM loadfileGUI
|
|||||||
add edi,512
|
add edi,512
|
||||||
sub eax,512
|
sub eax,512
|
||||||
; move eax # of bytes from edi to esi
|
; move eax # of bytes from edi to esi
|
||||||
sub dword[.curromspace],512
|
sub dword[curromspace],512
|
||||||
sub dword[.curfileofs],512
|
sub dword[.curfileofs],512
|
||||||
.next
|
.next
|
||||||
mov cl,[edi]
|
mov cl,[edi]
|
||||||
@@ -5047,8 +5021,6 @@ SECTION .bss
|
|||||||
.filehand resw 1
|
.filehand resw 1
|
||||||
.temp resb 1
|
.temp resb 1
|
||||||
.fail resb 1
|
.fail resb 1
|
||||||
.maxromspace resd 1
|
|
||||||
.curromspace resd 1
|
|
||||||
NEWSYM GUIloadfailed, resb 1
|
NEWSYM GUIloadfailed, resb 1
|
||||||
|
|
||||||
SECTION .text
|
SECTION .text
|
||||||
@@ -5913,7 +5885,14 @@ NEWSYM CheckROMType
|
|||||||
call GenerateBank0Table
|
call GenerateBank0Table
|
||||||
|
|
||||||
EXTSYM BankCheck
|
EXTSYM BankCheck
|
||||||
|
pushad
|
||||||
call BankCheck
|
call BankCheck
|
||||||
|
popad
|
||||||
|
|
||||||
|
EXTSYM MirrorROM
|
||||||
|
pushad
|
||||||
|
call MirrorROM
|
||||||
|
popad
|
||||||
|
|
||||||
; Chip Detection
|
; Chip Detection
|
||||||
mov byte[SFXEnable],0
|
mov byte[SFXEnable],0
|
||||||
@@ -6394,3 +6373,4 @@ SECTION .text
|
|||||||
|
|
||||||
NEWSYM InitAsmEnd
|
NEWSYM InitAsmEnd
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|||||||
#define Hi 0xFFC0
|
#define Hi 0xFFC0
|
||||||
#define EHi 0x40FFC0
|
#define EHi 0x40FFC0
|
||||||
|
|
||||||
|
#define MB_bytes 0x100000
|
||||||
|
#define Mbit_bytes 0x20000
|
||||||
|
|
||||||
|
|
||||||
//I want to port over the more complicated
|
//I want to port over the more complicated
|
||||||
//functions from init.asm, or replace with
|
//functions from init.asm, or replace with
|
||||||
@@ -41,8 +44,8 @@ extern unsigned char Interleaved;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int maxromspace;
|
||||||
|
unsigned int curromspace;
|
||||||
unsigned int infoloc;
|
unsigned int infoloc;
|
||||||
|
|
||||||
//Deinterleave functions
|
//Deinterleave functions
|
||||||
@@ -231,13 +234,13 @@ void BankCheck()
|
|||||||
}
|
}
|
||||||
switch(ROM[Hi + 21])
|
switch(ROM[Hi + 21])
|
||||||
{
|
{
|
||||||
case 33: case 49: case 53:
|
case 33: case 49: case 53: case 58:
|
||||||
case 128: case 156: case 176: case 188: case 252: //BS
|
case 128: case 156: case 176: case 188: case 252: //BS
|
||||||
hiscore += 1;
|
hiscore += 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ForceHiLoROM)
|
if (ForceHiLoROM)
|
||||||
{
|
{
|
||||||
//asm volatile("int $3");
|
//asm volatile("int $3");
|
||||||
if (forceromtype == 1) { loscore += 50; }
|
if (forceromtype == 1) { loscore += 50; }
|
||||||
@@ -265,7 +268,7 @@ unsigned short sum(unsigned char *array, unsigned int size)
|
|||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
//Prevent crashing by reading too far (needed for messed up ROMs)
|
//Prevent crashing by reading too far (needed for messed up ROMs)
|
||||||
if (array + size > (unsigned char *)romdata + NumofBytes)
|
if (array + size > (unsigned char *)romdata + maxromspace)
|
||||||
{
|
{
|
||||||
return(0xFFFF);
|
return(0xFFFF);
|
||||||
}
|
}
|
||||||
@@ -283,33 +286,52 @@ extern unsigned short Checksumvalue;
|
|||||||
void CalcChecksum()
|
void CalcChecksum()
|
||||||
{
|
{
|
||||||
unsigned char *ROM = (unsigned char *)romdata;
|
unsigned char *ROM = (unsigned char *)romdata;
|
||||||
unsigned short Mbit = NumofBanks >> 2;
|
if (SPC7110Enable)
|
||||||
|
|
||||||
if ((Mbit == 10 || Mbit == 20 || Mbit == 40) && !SPC7110Enable)
|
|
||||||
{
|
|
||||||
unsigned int P1Size = 512 << ROM[infoloc + 23];
|
|
||||||
unsigned short part1 = sum(ROM, P1Size),
|
|
||||||
part2 = sum(ROM+P1Size, NumofBytes-P1Size);
|
|
||||||
Checksumvalue = part1 + part2*4;
|
|
||||||
}
|
|
||||||
else if ((Mbit == 12 || Mbit == 24 || Mbit == 48) && !SPC7110Enable)
|
|
||||||
{
|
|
||||||
unsigned int P1Size = 512 << ROM[infoloc + 23];
|
|
||||||
unsigned short part1 = sum(ROM, P1Size),
|
|
||||||
part2 = sum(ROM+P1Size, NumofBytes-P1Size);
|
|
||||||
Checksumvalue = part1 + part2 + part2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Checksumvalue = sum(ROM, NumofBytes);
|
Checksumvalue = sum(ROM, NumofBytes);
|
||||||
if (BSEnable)
|
if (NumofBanks == 96)
|
||||||
{
|
|
||||||
Checksumvalue -= sum(&ROM[infoloc - 16], 48); //Fix for BS Dumps
|
|
||||||
}
|
|
||||||
else if (Mbit == 24)
|
|
||||||
{
|
{
|
||||||
Checksumvalue += Checksumvalue; //Fix for 24Mb SPC7110 ROMs
|
Checksumvalue += Checksumvalue; //Fix for 24Mb SPC7110 ROMs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Checksumvalue = sum(ROM, curromspace);
|
||||||
|
if (NumofBanks > 128 && maxromspace == 6*MB_bytes)
|
||||||
|
{
|
||||||
|
Checksumvalue += sum(ROM+4*MB_bytes, 2*MB_bytes);
|
||||||
|
}
|
||||||
|
if (BSEnable)
|
||||||
|
{
|
||||||
|
Checksumvalue -= sum(&ROM[infoloc - 16], 48); //Fix for BS Dumps
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Misc functions
|
||||||
|
void MirrorROM()
|
||||||
|
{
|
||||||
|
unsigned char *ROM = (unsigned char *)romdata;
|
||||||
|
int size, StartMirror = 0, ROMSize = curromspace;
|
||||||
|
//This will mirror up non power of two ROMs to powers of two
|
||||||
|
for (size = 1; size <= 64; size +=size)
|
||||||
|
{
|
||||||
|
int fullSize = size * Mbit_bytes,
|
||||||
|
halfSize = fullSize >> 1;
|
||||||
|
if ((ROMSize > halfSize) && (ROMSize < fullSize))
|
||||||
|
{
|
||||||
|
for (StartMirror = halfSize;
|
||||||
|
ROMSize < fullSize && ROMSize < maxromspace;)
|
||||||
|
{
|
||||||
|
ROM[ROMSize++] = ROM[StartMirror++];
|
||||||
|
}
|
||||||
|
curromspace = ROMSize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//This will mirror (now) full sized ROMs through the ROM buffer
|
||||||
|
for (StartMirror = 0; ROMSize < maxromspace;)
|
||||||
|
{
|
||||||
|
ROM[ROMSize++] = ROM[StartMirror++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user