fds - fix up some junk. smb2j runs now

This commit is contained in:
goyuken 2012-10-22 02:50:43 +00:00
parent e84f1d2761
commit fbb46e7054
2 changed files with 25 additions and 11 deletions

View File

@ -5,6 +5,12 @@ using System.Text;
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {
/*
* http://sourceforge.net/p/fceultra/code/2696/tree/fceu/src/fds.cpp - only used for timer info
* http://nesdev.com/FDS%20technical%20reference.txt - implementation is mostly a combination of
* http://wiki.nesdev.com/w/index.php/Family_Computer_Disk_System - these two documents
* http://nesdev.com/diskspec.txt - not useless
*/
[NES.INESBoardImplCancel] [NES.INESBoardImplCancel]
public class FDS : NES.NESBoardBase public class FDS : NES.NESBoardBase
{ {
@ -77,7 +83,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
int timerlatch; int timerlatch;
int timervalue; int timervalue;
bool timeractive; byte timerreg;
byte reg4026; byte reg4026;
@ -94,16 +100,13 @@ namespace BizHawk.Emulation.Consoles.Nintendo
timerirq = false; timerirq = false;
break; break;
case 0x0021: case 0x0021:
timerlatch &= 0xff00; timerlatch &= 0x00ff;
timerlatch |= value << 8; timerlatch |= value << 8;
timerirq = false; timerirq = false;
break; break;
case 0x0022: case 0x0022:
if ((value & 1) != 0) timerreg = (byte)(value & 3);
{
timeractive = true;
timervalue = timerlatch * 3; timervalue = timerlatch * 3;
}
break; break;
case 0x0023: case 0x0023:
diskenable = (value & 1) != 0; diskenable = (value & 1) != 0;
@ -171,12 +174,21 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public override void ClockPPU() public override void ClockPPU()
{ {
if (timeractive) if ((timerreg & 2) != 0 && timervalue > 0)
{ {
timervalue--; timervalue--;
if (timervalue == 0) if (timervalue == 0)
{ {
timeractive = false; if ((timerreg & 1) != 0)
{
timervalue = timerlatch * 3;
}
else
{
timerreg &= unchecked((byte)~2);
timervalue = 0;
timerlatch = 0;
}
timerirq = true; timerirq = true;
} }
} }

View File

@ -25,6 +25,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{ {
// the current circulating .fds dumps are horribly broken. here we attempt to fix them up as best as possible. // the current circulating .fds dumps are horribly broken. here we attempt to fix them up as best as possible.
// todo: implement CRC. since the RamAdapter itself doesn't implement it, broken is not a problem // todo: implement CRC. since the RamAdapter itself doesn't implement it, broken is not a problem
// since its not contained in dumps, no way to be sure that the implementation is right
MemoryStream inp = new MemoryStream(inputdisk, false); MemoryStream inp = new MemoryStream(inputdisk, false);
BinaryReader br = new BinaryReader(inp); BinaryReader br = new BinaryReader(inp);
@ -282,7 +283,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
case RamAdapterState.SPINUP: case RamAdapterState.SPINUP:
state = RamAdapterState.RUNNING; state = RamAdapterState.RUNNING;
SetCycles(); SetCycles();
transferreset = false; //transferreset = false; // this definitely does not happen.
//numcrc = 0; //numcrc = 0;
Console.WriteLine("FDS: Spin up complete! Disk is running"); Console.WriteLine("FDS: Spin up complete! Disk is running");
break; break;
@ -302,7 +303,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
byte readreglatch; byte readreglatch;
byte writereglatch; byte writereglatch;
bool bytetransferflag = false; bool _bytetransferflag;
bool bytetransferflag { get { return _bytetransferflag; } set { _bytetransferflag = value; } }
bool lookingforendofgap = false; bool lookingforendofgap = false;