FDS corrections

This commit is contained in:
dborth 2009-07-20 07:14:18 +00:00
parent aec5667532
commit f2773a5b9c
2 changed files with 29 additions and 24 deletions

View File

@ -40,7 +40,7 @@
// and the when it can be successfully read/written to. This should
// prevent writes to wrong places OR add code to prevent disk ejects
// when the virtual motor is on(mmm...virtual motor).
extern int disableBatteryLoading;
extern int disableBatteryLoading;
static DECLFR(FDSRead4030);
static DECLFR(FDSRead4031);
@ -94,7 +94,7 @@ void FDSGI(GI h)
}
static void FDSStateRestore(int version)
{
{
int x;
setmirror(((FDSRegs[5]&8)>>3)^1);
@ -133,7 +133,7 @@ static void FDSInit(void)
SetReadHandler(0x4032,0x4032,FDSRead4032);
SetReadHandler(0x4033,0x4033,FDSRead4033);
SetWriteHandler(0x4020,0x4025,FDSWrite);
SetWriteHandler(0x4020,0x4025,FDSWrite);
SetWriteHandler(0x6000,0xdfff,FDSRAMWrite);
SetReadHandler(0x6000,0xdfff,FDSRAMRead);
@ -149,15 +149,15 @@ void FCEU_FDSInsert(void)
{
if(TotalSides==0)
{
FCEU_DispMessage("Not FDS; can't eject disk.");
FCEU_DispMessage("Not FDS; can't eject disk.");
return;
}
if(InDisk==255)
{
FCEU_DispMessage("Disk %d Side %s Inserted",SelectDisk>>1,(SelectDisk&1)?"B":"A");
FCEU_DispMessage("Disk %d Side %s Inserted",SelectDisk>>1,(SelectDisk&1)?"B":"A");
InDisk=SelectDisk;
}
else
else
{
FCEU_DispMessage("Disk %d Side %s Ejected",SelectDisk>>1,(SelectDisk&1)?"B":"A");
InDisk=255;
@ -198,14 +198,14 @@ static void FDSFix(int a)
IRQCount=IRQLatch=0;
}
else
IRQCount=IRQLatch;
IRQCount=IRQLatch;
//IRQCount=IRQLatch; //0xFFFF;
X6502_IRQBegin(FCEU_IQEXT);
//printf("IRQ: %d\n",timestamp);
// printf("IRQ: %d\n",scanline);
}
}
if(DiskSeekIRQ>0)
if(DiskSeekIRQ>0)
{
DiskSeekIRQ-=a;
if(DiskSeekIRQ<=0)
@ -250,14 +250,14 @@ static DECLFR(FDSRead4031)
return z;
}
static DECLFR(FDSRead4032)
{
{
uint8 ret;
ret=X.DB&~7;
if(InDisk==255)
ret|=5;
if(InDisk==255 || !(FDSRegs[5]&1) || (FDSRegs[5]&2))
if(InDisk==255 || !(FDSRegs[5]&1) || (FDSRegs[5]&2))
ret|=2;
return ret;
}
@ -356,7 +356,7 @@ static DECLFW(FDSSWrite)
A-=0x4080;
switch(A)
{
case 0x0:
case 0x0:
case 0x4: if(V&0x80)
amplitude[(A&0xF)>>2]=V&0x3F; //)>0x20?0x20:(V&0x3F);
break;
@ -372,7 +372,7 @@ static DECLFW(FDSSWrite)
break;
}
//if(A>=0x7 && A!=0x8 && A<=0xF)
//if(A==0xA || A==0x9)
//if(A==0xA || A==0x9)
//printf("$%04x:$%02x\n",A,V);
SPSG[A]=V;
}
@ -439,7 +439,7 @@ static INLINE void ClockRise(void)
b19shiftreg60=(SPSG[0x2]|((SPSG[0x3]&0xF)<<8));
b17latch76=(SPSG[0x6]|((SPSG[0x07]&0xF)<<8))+b17latch76;
if(!(SPSG[0x7]&0x80))
if(!(SPSG[0x7]&0x80))
{
int t=fdso.mwave[(b17latch76>>13)&0x1F]&7;
int t2=amplitude[1];
@ -459,13 +459,13 @@ static INLINE void ClockRise(void)
b8shiftreg88=0x80 + adj;
}
else
{
{
b8shiftreg88=0x80;
}
}
else
{
b19shiftreg60<<=1;
b19shiftreg60<<=1;
b8shiftreg88>>=1;
}
// b24adder66=(b24latch68+b19shiftreg60)&0x3FFFFFF;
@ -495,7 +495,7 @@ dogk:
if(fdso.envcount<=0)
{
fdso.envcount+=SPSG[0xA]*3;
DoEnv();
DoEnv();
}
}
if(fdso.count>=32768) goto dogk;
@ -702,7 +702,7 @@ static int SubLoad(FCEUFILE *fp)
}
else
return(0);
}
}
else
TotalSides=header[4];
@ -752,7 +752,7 @@ static void PostSave(void)
for(b=0; b<65500; b++)
diskdata[x][b] ^= diskdatao[x][b];
}
}
}
@ -764,13 +764,13 @@ int FDSLoad(const char *name, FCEUFILE *fp)
FCEU_fseek(fp,0,SEEK_SET);
if(!SubLoad(fp))
if(!SubLoad(fp))
return(0);
#ifndef GEKKO
fn = strdup(FCEU_MakeFName(FCEUMKF_FDSROM,0,0).c_str());
if(!(zp=FCEUD_UTF8fopen(fn,"rb")))
if(!(zp=FCEUD_UTF8fopen(fn,"rb")))
{
FCEU_PrintError("FDS BIOS ROM image missing!");
FreeFDSMemory();
@ -802,7 +802,7 @@ if (!disableBatteryLoading)
diskdatao[x]=(uint8 *)FCEU_malloc(65500);
memcpy(diskdatao[x],diskdata[x],65500);
}
#ifndef GEKKO
if((tp=FCEU_fopen(fn,0,"rb",0)))
{
FreeFDSMemory();
@ -816,6 +816,7 @@ if (!disableBatteryLoading)
DiskWritten=1; /* For save state handling. */
}
free(fn);
#endif
}
GameInfo->type=GIT_FDS;
@ -829,7 +830,7 @@ if (!disableBatteryLoading)
for(x=0;x<TotalSides;x++)
{
char temp[5];
char temp[5];
sprintf(temp,"DDT%d",x);
AddExState(diskdata[x],65500,0,temp);
}
@ -862,6 +863,10 @@ if (!disableBatteryLoading)
void FDSClose(void)
{
#ifdef GEKKO
FreeFDSMemory();
return;
#endif
FILE *fp;
int x;
char *fn=strdup(FCEU_MakeFName(FCEUMKF_FDS,0,0).c_str());
@ -877,7 +882,7 @@ void FDSClose(void)
for(x=0;x<TotalSides;x++)
{
if(fwrite(diskdata[x],1,65500,fp)!=65500)
if(fwrite(diskdata[x],1,65500,fp)!=65500)
{
FCEU_PrintError("Error saving FDS image!");
fclose(fp);

View File

@ -283,7 +283,7 @@ copy_to_xfb (u32 arg)
switch(FDSSwitchRequested)
{
case 1:
// FCEUI_FDSEject(); // eject disk
FCEUI_FDSInsert(); // eject disk
FDSSwitchRequested++;
break;
case 2: