FDS / UNIF / NSF work now

This commit is contained in:
dborth 2009-07-20 08:05:44 +00:00
parent 0f16f3b191
commit 6f609f6943
4 changed files with 52 additions and 33 deletions

View File

@ -761,9 +761,9 @@ int FDSLoad(const char *name, FCEUFILE *fp)
FILE *zp; FILE *zp;
int x; int x;
char *fn; char *fn;
#ifndef GEKKO
FCEU_fseek(fp,0,SEEK_SET); FCEU_fseek(fp,0,SEEK_SET);
#endif
if(!SubLoad(fp)) if(!SubLoad(fp))
return(0); return(0);

View File

@ -156,15 +156,16 @@ static INLINE void BANKSET(uint32 A, uint32 bank)
bank&=NSFMaxBank; bank&=NSFMaxBank;
if(NSFHeader.SoundChip&4) if(NSFHeader.SoundChip&4)
memcpy(ExWRAM+(A-0x6000),NSFDATA+(bank<<12),4096); memcpy(ExWRAM+(A-0x6000),NSFDATA+(bank<<12),4096);
else else
setprg4(A,bank); setprg4(A,bank);
} }
int NSFLoad(FCEUFILE *fp) int NSFLoad(FCEUFILE *fp)
{ {
int x; int x;
#ifndef GEKKO
FCEU_fseek(fp,0,SEEK_SET); FCEU_fseek(fp,0,SEEK_SET);
#endif
FCEU_fread(&NSFHeader,1,0x80,fp); FCEU_fread(&NSFHeader,1,0x80,fp);
if(memcmp(NSFHeader.ID,"NESM\x1a",5)) if(memcmp(NSFHeader.ID,"NESM\x1a",5))
return 0; return 0;
@ -330,7 +331,7 @@ void NSF_init(void)
SetReadHandler(0x3ff0,0x3fff,NSF_read); SetReadHandler(0x3ff0,0x3fff,NSF_read);
if(NSFHeader.SoundChip&1) { if(NSFHeader.SoundChip&1) {
NSFVRC6_Init(); NSFVRC6_Init();
} else if(NSFHeader.SoundChip&2) { } else if(NSFHeader.SoundChip&2) {
NSFVRC7_Init(); NSFVRC7_Init();
@ -369,7 +370,7 @@ static DECLFW(NSF_write)
A&=0xF; A&=0xF;
BANKSET((A*4096),V); BANKSET((A*4096),V);
break; break;
} }
} }
static DECLFR(NSF_read) static DECLFR(NSF_read)
@ -392,13 +393,13 @@ static DECLFR(NSF_read)
BWrite[0x4000+x](0x4000+x,0); BWrite[0x4000+x](0x4000+x,0);
BWrite[0x4015](0x4015,0xF); BWrite[0x4015](0x4015,0xF);
if(NSFHeader.SoundChip&4) if(NSFHeader.SoundChip&4)
{ {
BWrite[0x4017](0x4017,0xC0); /* FDS BIOS writes $C0 */ BWrite[0x4017](0x4017,0xC0); /* FDS BIOS writes $C0 */
BWrite[0x4089](0x4089,0x80); BWrite[0x4089](0x4089,0x80);
BWrite[0x408A](0x408A,0xE8); BWrite[0x408A](0x408A,0xE8);
} }
else else
{ {
memset(ExWRAM,0x00,8192); memset(ExWRAM,0x00,8192);
BWrite[0x4017](0x4017,0xC0); BWrite[0x4017](0x4017,0xC0);
@ -452,8 +453,8 @@ void DrawNSF(uint8 *XBuf)
y=142+((Bufpl[(x*l)>>8]*mul)>>14); y=142+((Bufpl[(x*l)>>8]*mul)>>14);
if(y<240) if(y<240)
XBuf[x+y*256]=3; XBuf[x+y*256]=3;
} }
} }
else if(special==1) else if(special==1)
{ {
if(FSettings.SoundVolume) if(FSettings.SoundVolume)
@ -492,7 +493,7 @@ void DrawNSF(uint8 *XBuf)
n=120+r*sin(t); n=120+r*sin(t);
if(m<256 && n<240) if(m<256 && n<240)
XBuf[m+n*256]=3; XBuf[m+n*256]=3;
} }
for(x=128;x<256;x++) for(x=128;x<256;x++)
@ -532,9 +533,9 @@ void DrawNSF(uint8 *XBuf)
tmp=FCEU_GetJoyJoy(); tmp=FCEU_GetJoyJoy();
if((tmp&JOY_RIGHT) && !(last&JOY_RIGHT)) if((tmp&JOY_RIGHT) && !(last&JOY_RIGHT))
{ {
if(CurrentSong<NSFHeader.TotalSongs) if(CurrentSong<NSFHeader.TotalSongs)
{ {
CurrentSong++; CurrentSong++;
SongReload=0xFF; SongReload=0xFF;
} }
} }

View File

@ -129,7 +129,7 @@ static int DoMirroring(FCEUFILE *fp)
{ {
uint8 t; uint8 t;
t=FCEU_fgetc(fp); t=FCEU_fgetc(fp);
mirrortodo=t; mirrortodo=t;
{ {
static char *stuffo[6]={"Horizontal","Vertical","$2000","$2400","\"Four-screen\"","Controlled by Mapper Hardware"}; static char *stuffo[6]={"Horizontal","Vertical","$2000","$2400","\"Four-screen\"","Controlled by Mapper Hardware"};
@ -266,7 +266,7 @@ static int LoadPRG(FCEUFILE *fp)
else else
FCEU_printf("\n"); FCEU_printf("\n");
SetupCartPRGMapping(z,malloced[z],t,0); SetupCartPRGMapping(z,malloced[z],t,0);
return(1); return(1);
} }
@ -463,13 +463,13 @@ int LoadUNIFChunks(FCEUFILE *fp)
for(;;) for(;;)
{ {
t=FCEU_fread(&uchead,1,4,fp); t=FCEU_fread(&uchead,1,4,fp);
if(t<4) if(t<4)
{ {
if(t>0) if(t>0)
return 0; return 0;
return 1; return 1;
} }
if(!(FCEU_read32le(&uchead.info,fp))) if(!(FCEU_read32le(&uchead.info,fp)))
return 0; return 0;
t=0; t=0;
x=0; x=0;
@ -481,7 +481,7 @@ int LoadUNIFChunks(FCEUFILE *fp)
if(!bfunc[x].init(fp)) if(!bfunc[x].init(fp))
return 0; return 0;
t=1; t=1;
break; break;
} }
x++; x++;
} }
@ -557,10 +557,12 @@ static void UNIFGI(GI h)
int UNIFLoad(const char *name, FCEUFILE *fp) int UNIFLoad(const char *name, FCEUFILE *fp)
{ {
#ifndef GEKKO
FCEU_fseek(fp,0,SEEK_SET); FCEU_fseek(fp,0,SEEK_SET);
#endif
FCEU_fread(&unhead,1,4,fp); FCEU_fread(&unhead,1,4,fp);
if(memcmp(&unhead,"UNIF",4)) if(memcmp(&unhead,"UNIF",4))
return 0; return 0;
ResetCartMapping(); ResetCartMapping();
@ -593,7 +595,7 @@ int UNIFLoad(const char *name, FCEUFILE *fp)
if(!InitializeBoard()) if(!InitializeBoard())
goto aborto; goto aborto;
#ifndef GEKKO #ifndef GEKKO
FCEU_LoadGameSave(&UNIFCart); FCEU_LoadGameSave(&UNIFCart);
#endif #endif

View File

@ -55,22 +55,35 @@ int GCMemROM(int method, int size)
FCEUI_SetSoundVolume(100); // 0-100 FCEUI_SetSoundVolume(100); // 0-100
FCEUI_SetLowPass(0); FCEUI_SetLowPass(0);
memorystream * fceumem = new memorystream((char *) nesrom, size);
FCEUFILE * fceufp = new FCEUFILE(); FCEUFILE * fceufp = new FCEUFILE();
fceufp->size = size; fceufp->size = size;
fceufp->stream = fceumem;
fceufp->filename = romFilename; fceufp->filename = romFilename;
memorystream * fceumem;
romLoaded = false; romLoaded = false;
if (iNESLoad(romFilename, fceufp, 1)) // for some reason FCEU_fseek(fp,0,SEEK_SET); fails, so we will do this
romLoaded = true; fceumem = new memorystream((char *) nesrom, size);
else if (UNIFLoad(romFilename, fceufp)) fceufp->stream = fceumem;
romLoaded = true; romLoaded = iNESLoad(romFilename, fceufp, 1);
else if (NSFLoad(fceufp))
romLoaded = true; if(!romLoaded)
else {
delete fceumem;
fceumem = new memorystream((char *) nesrom, size);
fceufp->stream = fceumem;
romLoaded = UNIFLoad(romFilename, fceufp);
}
if(!romLoaded)
{
delete fceumem;
fceumem = new memorystream((char *) nesrom, size);
fceufp->stream = fceumem;
romLoaded = NSFLoad(fceufp);
}
if(!romLoaded)
{ {
// read FDS BIOS into FDSBIOS - should be 8192 bytes // read FDS BIOS into FDSBIOS - should be 8192 bytes
if (FDSBIOS[1] == 0) if (FDSBIOS[1] == 0)
@ -101,8 +114,11 @@ int GCMemROM(int method, int size)
if (FDSBIOS[1] != 0) if (FDSBIOS[1] != 0)
{ {
// load game // load game
if (FDSLoad(romFilename, fceufp)) delete fceumem;
romLoaded = true; fceumem = new memorystream((char *) nesrom, size);
fceufp->stream = fceumem;
romLoaded = FDSLoad(romFilename, fceufp);
} }
} }