Much better SPC7110 pack loading code.
This commit is contained in:
@@ -43,7 +43,8 @@ EXTSYM regptr,regptw,romdata,SA1Status,debstop4,SDD1BankA,curromsize
|
||||
EXTSYM debuggeron
|
||||
EXTSYM Get_Time,Get_TimeDate
|
||||
EXTSYM spc7110romptr,SPC7110Entries
|
||||
EXTSYM SPC7110IndexSize,SPC7110nfname
|
||||
EXTSYM SPC7110IndexSize,SPC7110nfname,SPC7110filep
|
||||
EXTSYM SPC7_Convert_Upper,SPC7_Convert_Lower
|
||||
EXTSYM Open_File,Close_File,Read_File,File_Seek
|
||||
; EXTSYM Msgptr,MessageOn
|
||||
EXTSYM irqv2,irqv,nmiv2,nmiv
|
||||
@@ -774,8 +775,8 @@ SPC4806w:
|
||||
mov [SPC7110TempPosition],eax
|
||||
mov eax,[edx+8]
|
||||
mov [SPC7110TempLength],eax
|
||||
mov edx,SPC7110nfname
|
||||
add edx,9
|
||||
|
||||
mov edx,dword[SPC7110filep]
|
||||
mov eax,[SPCCompPtr]
|
||||
and eax,0FFFFFFh
|
||||
mov ecx,6
|
||||
@@ -796,7 +797,18 @@ SPC4806w:
|
||||
|
||||
mov edx,SPC7110nfname
|
||||
call Open_File
|
||||
jnc .nocaseerror
|
||||
pushad
|
||||
call SPC7_Convert_Upper
|
||||
popad
|
||||
call Open_File
|
||||
jnc .nocaseerror
|
||||
pushad
|
||||
call SPC7_Convert_Lower
|
||||
popad
|
||||
call Open_File
|
||||
jc .error
|
||||
.nocaseerror
|
||||
mov bx,ax
|
||||
mov dx,[SPC7110TempPosition]
|
||||
mov cx,[SPC7110TempPosition+2]
|
||||
|
||||
@@ -125,6 +125,7 @@ EXTSYM MirrorROM
|
||||
EXTSYM SplittedROM
|
||||
EXTSYM addOnStart
|
||||
EXTSYM addOnSize
|
||||
EXTSYM SPC7PackIndexLoad,SPC7110IndexSize
|
||||
|
||||
EXTSYM SetaCmdEnable,setaramdata
|
||||
EXTSYM setaaccessbankr8,setaaccessbankw8,setaaccessbankr8a,setaaccessbankw8a
|
||||
@@ -3029,21 +3030,16 @@ SECTION .text
|
||||
|
||||
SECTION .data
|
||||
|
||||
SPC7110DIRA db 'FEOEZSP7',0
|
||||
SPC7110DIRB db 'SMHT-SP7',0
|
||||
SDD1DIRA db 'SOCNSDD1',0
|
||||
SDD1DIRB db 'SFZ2SDD1',0
|
||||
SDD1DIRC db 'SFA2SDD1',0
|
||||
SDD1DIRD db 'SF2ESDD1',0
|
||||
SPC7110IndexName db 'index.bin',0
|
||||
SPC7110DirEntry db '*.bin',0
|
||||
NEWSYM SDD1Offset, dd 65536*8
|
||||
%ifndef __LINUX__
|
||||
NEWSYM SDD1nfname, db ' \_00000-0.bin',0
|
||||
NEWSYM SPC7110nfname, db ' \ .bin',0
|
||||
%else
|
||||
NEWSYM SDD1nfname, db ' /_00000-0.bin',0
|
||||
NEWSYM SPC7110nfname, db ' / .bin',0
|
||||
%endif
|
||||
NEWSYM SDD1ifname, db 'sdd1gfx.idx',0
|
||||
NEWSYM SDD1dfname, db 'sdd1gfx.dat',0
|
||||
@@ -3056,7 +3052,6 @@ SECTION .bss
|
||||
SPC7110Allocated resb 1
|
||||
SPC7110CPtr resd 1
|
||||
SPC7110CPtr2 resd 1
|
||||
NEWSYM SPC7110IndexSize, resd 1
|
||||
NEWSYM SPC7110Entries, resd 1
|
||||
SDD1PatchAddr resd 1
|
||||
SDD1PatchOfs resd 1
|
||||
@@ -3119,30 +3114,11 @@ NEWSYM SPC7110Load
|
||||
.noSDD1a
|
||||
ret
|
||||
.spc7110
|
||||
mov edx,SPC7110DIRA
|
||||
cmp al,0F9h
|
||||
je .noSPC7110b
|
||||
mov edx,SPC7110DIRB
|
||||
.noSPC7110b
|
||||
mov eax,[edx]
|
||||
mov [SPC7110nfname],eax
|
||||
mov eax,[edx+4]
|
||||
mov [SPC7110nfname+4],eax
|
||||
call Change_Single_Dir
|
||||
jc near .nodir
|
||||
mov edx,SPC7110IndexName
|
||||
call Open_File
|
||||
jc near .noindex
|
||||
mov bx,ax
|
||||
mov edx,[romdata]
|
||||
add edx,580000h
|
||||
mov ecx,12*32768
|
||||
call Read_File
|
||||
mov [SPC7110IndexSize],eax
|
||||
call Close_File
|
||||
mov dword[SPC7110Entries],0
|
||||
mov edx,PrevDir
|
||||
call Change_Single_Dir
|
||||
pushad
|
||||
call SPC7PackIndexLoad
|
||||
popad
|
||||
cmp dword[SPC7110IndexSize],0
|
||||
je .nodir
|
||||
ret
|
||||
.sdd1b
|
||||
cmp byte[SPC7110Allocated],0
|
||||
|
||||
@@ -19,11 +19,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
#ifdef __LINUX__
|
||||
#include "gblhdr.h"
|
||||
#define DIR_SLASH "/"
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#define DIR_SLASH "\\"
|
||||
#endif
|
||||
#include "zip/zunzip.h"
|
||||
|
||||
@@ -46,6 +48,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#define Mbit_bytes 0x20000
|
||||
|
||||
|
||||
|
||||
void Debug_WriteString(char *str)
|
||||
{
|
||||
FILE *fp = 0;
|
||||
fp = fopen("zsnes.dbg", "w");
|
||||
if (!fp) { return; }
|
||||
fputs(str, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
//I want to port over the more complicated
|
||||
//functions from init.asm, or replace with
|
||||
//better versions from NSRT. -Nach
|
||||
@@ -1274,3 +1287,82 @@ void Setper2exec()
|
||||
opexec358cph = (unsigned char)(opexec358cph*(per2exec*0.01));
|
||||
}
|
||||
|
||||
extern char FEOEZPath[1024];
|
||||
extern char SJNSPath[1024];
|
||||
extern char MDHPath[1024];
|
||||
extern char SPL4Path[1024];
|
||||
char *SPC7110filep;
|
||||
char SPC7110nfname[1024+12]; //12 is / plus 6.3
|
||||
unsigned int SPC7110IndexSize;
|
||||
extern unsigned int SPC7110Entries;
|
||||
void SPC7PackIndexLoad()
|
||||
{
|
||||
unsigned char *ROM = (unsigned char *)romdata;
|
||||
FILE *fp = 0;
|
||||
SPC7110IndexSize = 0;
|
||||
|
||||
//Get correct path for the ROM we just loaded
|
||||
if (!strncmp(ROM+infoloc, "HU TENGAI MAKYO ZERO ", 21))
|
||||
{
|
||||
strcpy(SPC7110nfname, *FEOEZPath ? FEOEZPath : "FEOEZSP7");
|
||||
}
|
||||
else if (!strncmp(ROM+infoloc, "JUMP TENGAIMAKYO ZERO", 21))
|
||||
{
|
||||
strcpy(SPC7110nfname, *SJNSPath ? SJNSPath : "SJNS-SP7");
|
||||
}
|
||||
else if (!strncmp(ROM+infoloc, "MOMOTETSU HAPPY ", 21))
|
||||
{
|
||||
strcpy(SPC7110nfname, *MDHPath ? MDHPath : "MDH-SP7");
|
||||
}
|
||||
else if (!strncmp(ROM+infoloc, "SUPER POWER LEAG 4 ", 21))
|
||||
{
|
||||
strcpy(SPC7110nfname, *SPL4Path ? SPL4Path : "SPL4-SP7");
|
||||
}
|
||||
|
||||
//Add a slash if needed
|
||||
if (SPC7110nfname[strlen(SPC7110nfname)-1] != *DIR_SLASH)
|
||||
{
|
||||
strcat(SPC7110nfname, DIR_SLASH);
|
||||
}
|
||||
|
||||
//Set the pointer to after the slash - needed for sa1regs.asm
|
||||
SPC7110filep = SPC7110nfname+strlen(SPC7110nfname);
|
||||
|
||||
//Index file;
|
||||
strcat(SPC7110nfname, "index.bin");
|
||||
|
||||
//Load the index
|
||||
fp = fopen(SPC7110nfname, "rb");
|
||||
if (!fp) { return; }
|
||||
SPC7110IndexSize = fread(ROM+0x580000, 1, 12*32768, fp);
|
||||
fclose(fp);
|
||||
|
||||
SPC7110Entries = 0;
|
||||
|
||||
//Get file pointer ready for individual pack files
|
||||
strcpy(SPC7110filep, "123456.bin"); //Extension Lower Case
|
||||
}
|
||||
|
||||
void SPC7_Convert_Upper()
|
||||
{
|
||||
char *i = SPC7110filep;
|
||||
while (*i)
|
||||
{
|
||||
if (islower(*i)) { *i = toupper(*i); } //To make extension Upper case
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void SPC7_Convert_Lower()
|
||||
{
|
||||
char *i = SPC7110filep;
|
||||
while (*i)
|
||||
{
|
||||
if (isupper(*i)) { *i = tolower(*i); } //To make everything Lower case
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user