Fixed indentation and TODOs
This commit is contained in:
parent
1e9564a337
commit
f7c15bfd0f
|
@ -315,7 +315,7 @@ namespace BizHawk.Emulation.Common
|
||||||
case ".T64":
|
case ".T64":
|
||||||
case ".G64":
|
case ".G64":
|
||||||
case ".CRT":
|
case ".CRT":
|
||||||
case ".TAP":
|
case ".TAP":
|
||||||
game.System = "C64";
|
game.System = "C64";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -2932,9 +2932,9 @@ namespace BizHawk.Emulation.Cores.Components.M6502
|
||||||
mi++;
|
mi++;
|
||||||
} //ExecuteOne
|
} //ExecuteOne
|
||||||
|
|
||||||
public bool AtInstructionStart()
|
public bool AtInstructionStart()
|
||||||
{
|
{
|
||||||
return Microcode[opcode][mi] >= Uop.End;
|
return Microcode[opcode][mi] >= Uop.End;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,110 +51,110 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanStep(StepType type)
|
public bool CanStep(StepType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case StepType.Into:
|
case StepType.Into:
|
||||||
case StepType.Over:
|
case StepType.Over:
|
||||||
case StepType.Out:
|
case StepType.Out:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Step(StepType type)
|
public void Step(StepType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case StepType.Into:
|
case StepType.Into:
|
||||||
StepInto();
|
StepInto();
|
||||||
break;
|
break;
|
||||||
case StepType.Out:
|
case StepType.Out:
|
||||||
StepOut();
|
StepOut();
|
||||||
break;
|
break;
|
||||||
case StepType.Over:
|
case StepType.Over:
|
||||||
StepOver();
|
StepOver();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StepInto()
|
private void StepInto()
|
||||||
{
|
{
|
||||||
while (board.cpu.AtInstructionStart())
|
while (board.cpu.AtInstructionStart())
|
||||||
{
|
{
|
||||||
DoCycle();
|
DoCycle();
|
||||||
}
|
}
|
||||||
while (!board.cpu.AtInstructionStart())
|
while (!board.cpu.AtInstructionStart())
|
||||||
{
|
{
|
||||||
DoCycle();
|
DoCycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StepOver()
|
private void StepOver()
|
||||||
{
|
{
|
||||||
var instruction = board.cpu.Peek(board.cpu.PC);
|
var instruction = board.cpu.Peek(board.cpu.PC);
|
||||||
|
|
||||||
if (instruction == JSR)
|
if (instruction == JSR)
|
||||||
{
|
{
|
||||||
var destination = board.cpu.PC + JSRSize;
|
var destination = board.cpu.PC + JSRSize;
|
||||||
while (board.cpu.PC != destination)
|
while (board.cpu.PC != destination)
|
||||||
{
|
{
|
||||||
StepInto();
|
StepInto();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StepInto();
|
StepInto();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StepOut()
|
private void StepOut()
|
||||||
{
|
{
|
||||||
var instr = board.cpu.Peek(board.cpu.PC);
|
var instr = board.cpu.Peek(board.cpu.PC);
|
||||||
|
|
||||||
JSRCount = instr == JSR ? 1 : 0;
|
JSRCount = instr == JSR ? 1 : 0;
|
||||||
|
|
||||||
var bailOutFrame = Frame + 1;
|
var bailOutFrame = Frame + 1;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
StepInto();
|
StepInto();
|
||||||
instr = board.cpu.Peek(board.cpu.PC);
|
instr = board.cpu.Peek(board.cpu.PC);
|
||||||
if (instr == JSR)
|
if (instr == JSR)
|
||||||
{
|
{
|
||||||
JSRCount++;
|
JSRCount++;
|
||||||
}
|
}
|
||||||
else if ((instr == RTS || instr == RTI) && JSRCount <= 0)
|
else if ((instr == RTS || instr == RTI) && JSRCount <= 0)
|
||||||
{
|
{
|
||||||
StepInto();
|
StepInto();
|
||||||
JSRCount = 0;
|
JSRCount = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (instr == RTS || instr == RTI)
|
else if (instr == RTS || instr == RTI)
|
||||||
{
|
{
|
||||||
JSRCount--;
|
JSRCount--;
|
||||||
}
|
}
|
||||||
else //Emergency Bailout Logic
|
else //Emergency Bailout Logic
|
||||||
{
|
{
|
||||||
if (Frame == bailOutFrame)
|
if (Frame == bailOutFrame)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int JSRCount = 0;
|
private int JSRCount = 0;
|
||||||
|
|
||||||
private const byte JSR = 0x20;
|
private const byte JSR = 0x20;
|
||||||
private const byte RTI = 0x40;
|
private const byte RTI = 0x40;
|
||||||
private const byte RTS = 0x60;
|
private const byte RTS = 0x60;
|
||||||
|
|
||||||
private const byte JSRSize = 3;
|
private const byte JSRSize = 3;
|
||||||
|
|
||||||
public IMemoryCallbackSystem MemoryCallbacks { get; private set; }
|
public IMemoryCallbackSystem MemoryCallbacks { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,32 +5,26 @@ using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
{
|
{
|
||||||
public partial class C64 : IDisassemblable
|
public partial class C64 : IDisassemblable
|
||||||
{
|
{
|
||||||
public string Cpu
|
public string Cpu
|
||||||
{
|
{
|
||||||
get
|
get { return "6510"; }
|
||||||
{
|
}
|
||||||
return "6510";
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string PCRegisterName
|
public string PCRegisterName
|
||||||
{
|
{
|
||||||
get { return "PC"; }
|
get { return "PC"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> AvailableCpus
|
public IEnumerable<string> AvailableCpus
|
||||||
{
|
{
|
||||||
get { yield return "6510"; }
|
get { yield return "6510"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Disassemble(MemoryDomain m, uint addr, out int length)
|
public string Disassemble(MemoryDomain m, uint addr, out int length)
|
||||||
{
|
{
|
||||||
return Components.M6502.MOS6502X.Disassemble((ushort)addr, out length, (a) => m.PeekByte(a));
|
return Components.M6502.MOS6502X.Disassemble((ushort)addr, out length, (a) => m.PeekByte(a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
|
|
||||||
private C64 _c64;
|
private C64 _c64;
|
||||||
|
|
||||||
public Motherboard(C64 c64, Region initRegion)
|
public Motherboard(C64 c64, DisplayType initRegion)
|
||||||
{
|
{
|
||||||
// note: roms need to be added on their own externally
|
// note: roms need to be added on their own externally
|
||||||
_c64 = c64;
|
_c64 = c64;
|
||||||
|
@ -59,8 +59,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
sid = MOS6581.Create(44100, initRegion);
|
sid = MOS6581.Create(44100, initRegion);
|
||||||
switch (initRegion)
|
switch (initRegion)
|
||||||
{
|
{
|
||||||
case Region.NTSC: vic = MOS6567.Create(); break;
|
case DisplayType.NTSC: vic = MOS6567.Create(); break;
|
||||||
case Region.PAL: vic = MOS6569.Create(); break;
|
case DisplayType.PAL: vic = MOS6569.Create(); break;
|
||||||
}
|
}
|
||||||
userPort = new UserPortDevice();
|
userPort = new UserPortDevice();
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
sid.HardReset();
|
sid.HardReset();
|
||||||
vic.HardReset();
|
vic.HardReset();
|
||||||
userPort.HardReset();
|
userPort.HardReset();
|
||||||
cassPort.HardReset();
|
cassPort.HardReset();
|
||||||
|
|
||||||
// because of how mapping works, the cpu needs to be hard reset twice
|
// because of how mapping works, the cpu needs to be hard reset twice
|
||||||
cpu.HardReset();
|
cpu.HardReset();
|
||||||
|
|
|
@ -8,22 +8,15 @@ using System.Windows.Forms;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
{
|
{
|
||||||
// TODO: use the EMulation.Common Region enum
|
|
||||||
public enum Region
|
|
||||||
{
|
|
||||||
NTSC,
|
|
||||||
PAL
|
|
||||||
}
|
|
||||||
|
|
||||||
[CoreAttributes(
|
[CoreAttributes(
|
||||||
"C64Hawk",
|
"C64Hawk",
|
||||||
"SaxxonPIke",
|
"SaxxonPIke",
|
||||||
isPorted: false,
|
isPorted: false,
|
||||||
isReleased: false
|
isReleased: false
|
||||||
)]
|
)]
|
||||||
[ServiceNotApplicable(typeof(IRegionable), typeof(ISettable<,>))]
|
[ServiceNotApplicable(typeof(ISettable<,>))]
|
||||||
sealed public partial class C64 : IEmulator, IStatable, IInputPollable, IDriveLight, IDebuggable, IDisassemblable
|
sealed public partial class C64 : IEmulator, IStatable, IInputPollable, IDriveLight, IDebuggable, IDisassemblable, IRegionable
|
||||||
{
|
{
|
||||||
// framework
|
// framework
|
||||||
public C64(CoreComm comm, GameInfo game, byte[] rom, string romextension)
|
public C64(CoreComm comm, GameInfo game, byte[] rom, string romextension)
|
||||||
{
|
{
|
||||||
|
@ -34,37 +27,37 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
inputFileInfo.Data = rom;
|
inputFileInfo.Data = rom;
|
||||||
inputFileInfo.Extension = romextension;
|
inputFileInfo.Extension = romextension;
|
||||||
CoreComm = comm;
|
CoreComm = comm;
|
||||||
Nullable<Region> region = queryUserForRegion();
|
Region = queryUserForRegion();
|
||||||
if (region == null)
|
Init(Region);
|
||||||
{
|
|
||||||
throw new Exception("Can't construct new C64 because you didn't choose anything");
|
|
||||||
}
|
|
||||||
Init(region.Value);
|
|
||||||
cyclesPerFrame = board.vic.CyclesPerFrame;
|
cyclesPerFrame = board.vic.CyclesPerFrame;
|
||||||
SetupMemoryDomains();
|
SetupMemoryDomains();
|
||||||
MemoryCallbacks = new MemoryCallbackSystem();
|
MemoryCallbacks = new MemoryCallbackSystem();
|
||||||
HardReset();
|
HardReset();
|
||||||
|
|
||||||
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(board.vic);
|
(ServiceProvider as BasicServiceProvider).Register<IVideoProvider>(board.vic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Nullable<Region> queryUserForRegion()
|
private DisplayType queryUserForRegion()
|
||||||
{
|
{
|
||||||
Form prompt = new Form() { Width = 160, Height = 120, FormBorderStyle = FormBorderStyle.FixedDialog, Text = "Region selector", StartPosition = FormStartPosition.CenterScreen };
|
Form prompt = new Form() { Width = 160, Height = 120, FormBorderStyle = FormBorderStyle.FixedDialog, Text = "Region selector", StartPosition = FormStartPosition.CenterScreen };
|
||||||
Label textLabel = new Label() { Left = 10, Top = 10, Width = 260, Text = "Please choose a region:" };
|
Label textLabel = new Label() { Left = 10, Top = 10, Width = 260, Text = "Please choose a region:" };
|
||||||
RadioButton palButton = new RadioButton() { Left = 10, Top = 30, Width = 70, Text = "PAL", Checked = true };
|
RadioButton palButton = new RadioButton() { Left = 10, Top = 30, Width = 70, Text = "PAL", Checked = true };
|
||||||
RadioButton ntscButton = new RadioButton() { Left = 80, Top = 30, Width = 70, Text = "NTSC" };
|
RadioButton ntscButton = new RadioButton() { Left = 80, Top = 30, Width = 70, Text = "NTSC" };
|
||||||
Button confirmation = new Button() { Text = "Ok", Left = 40, Width = 80, Top = 60, DialogResult = DialogResult.OK };
|
Button confirmation = new Button() { Text = "Ok", Left = 40, Width = 80, Top = 60, DialogResult = DialogResult.OK };
|
||||||
confirmation.Click += (sender, e) => { prompt.Close(); };
|
confirmation.Click += (sender, e) => { prompt.Close(); };
|
||||||
prompt.Controls.Add(textLabel);
|
prompt.Controls.Add(textLabel);
|
||||||
prompt.Controls.Add(palButton);
|
prompt.Controls.Add(palButton);
|
||||||
prompt.Controls.Add(ntscButton);
|
prompt.Controls.Add(ntscButton);
|
||||||
prompt.Controls.Add(confirmation);
|
prompt.Controls.Add(confirmation);
|
||||||
prompt.AcceptButton = confirmation;
|
prompt.AcceptButton = confirmation;
|
||||||
|
|
||||||
return prompt.ShowDialog() == DialogResult.OK ? palButton.Checked ? new Nullable<Region>(Region.PAL) : ntscButton.Checked ? new Nullable<Region>(Region.NTSC) : null : null;
|
if (prompt.ShowDialog() != DialogResult.OK || !palButton.Checked && !ntscButton.Checked)
|
||||||
}
|
{
|
||||||
|
throw new Exception("Can't construct new C64 because you didn't choose anything");
|
||||||
|
}
|
||||||
|
return palButton.Checked ? DisplayType.PAL : DisplayType.NTSC;
|
||||||
|
}
|
||||||
|
|
||||||
// internal variables
|
// internal variables
|
||||||
private int _frame = 0;
|
private int _frame = 0;
|
||||||
|
@ -88,8 +81,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
_frame = 0;
|
_frame = 0;
|
||||||
_lagcount = 0;
|
_lagcount = 0;
|
||||||
_islag = false;
|
_islag = false;
|
||||||
frameCycles = 0;
|
frameCycles = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// audio/video
|
// audio/video
|
||||||
public void EndAsyncSound() { } //TODO
|
public void EndAsyncSound() { } //TODO
|
||||||
|
@ -118,6 +111,12 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
|
|
||||||
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
public IEmulatorServiceProvider ServiceProvider { get; private set; }
|
||||||
|
|
||||||
|
public DisplayType Region
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (board.sid != null)
|
if (board.sid != null)
|
||||||
|
@ -127,69 +126,69 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int frameCycles;
|
int frameCycles;
|
||||||
|
|
||||||
private void DoCycle()
|
// process frame
|
||||||
{
|
public void FrameAdvance(bool render, bool rendersound)
|
||||||
if (frameCycles == 0) {
|
|
||||||
board.inputRead = false;
|
|
||||||
board.PollInput();
|
|
||||||
board.cpu.LagCycles = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//disk.Execute();
|
|
||||||
board.Execute();
|
|
||||||
frameCycles++;
|
|
||||||
|
|
||||||
// load PRG file if needed
|
|
||||||
if (loadPrg)
|
|
||||||
{
|
|
||||||
// check to see if cpu PC is at the BASIC warm start vector
|
|
||||||
if (board.cpu.PC == ((board.ram.Peek(0x0303) << 8) | board.ram.Peek(0x0302)))
|
|
||||||
{
|
|
||||||
//board.ram.Poke(0x0302, 0xAE);
|
|
||||||
//board.ram.Poke(0x0303, 0xA7);
|
|
||||||
////board.ram.Poke(0x0302, board.ram.Peek(0x0308));
|
|
||||||
////board.ram.Poke(0x0303, board.ram.Peek(0x0309));
|
|
||||||
|
|
||||||
//if (inputFileInfo.Data.Length >= 6)
|
|
||||||
//{
|
|
||||||
// board.ram.Poke(0x0039, inputFileInfo.Data[4]);
|
|
||||||
// board.ram.Poke(0x003A, inputFileInfo.Data[5]);
|
|
||||||
//}
|
|
||||||
PRG.Load(board.pla, inputFileInfo.Data);
|
|
||||||
loadPrg = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frameCycles == cyclesPerFrame)
|
|
||||||
{
|
|
||||||
board.Flush();
|
|
||||||
_islag = !board.inputRead;
|
|
||||||
|
|
||||||
if (_islag)
|
|
||||||
_lagcount++;
|
|
||||||
frameCycles -= cyclesPerFrame;
|
|
||||||
_frame++;
|
|
||||||
|
|
||||||
//Console.WriteLine("CPUPC: " + C64Util.ToHex(board.cpu.PC, 4) + " 1541PC: " + C64Util.ToHex(disk.PC, 4));
|
|
||||||
|
|
||||||
int test = board.cpu.LagCycles;
|
|
||||||
DriveLightOn = DriveLED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// process frame
|
|
||||||
public void FrameAdvance(bool render, bool rendersound)
|
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
DoCycle();
|
DoCycle();
|
||||||
}
|
}
|
||||||
while (frameCycles != 0);
|
while (frameCycles != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleFirmwareError(string file)
|
private void DoCycle()
|
||||||
|
{
|
||||||
|
if (frameCycles == 0) {
|
||||||
|
board.inputRead = false;
|
||||||
|
board.PollInput();
|
||||||
|
board.cpu.LagCycles = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//disk.Execute();
|
||||||
|
board.Execute();
|
||||||
|
frameCycles++;
|
||||||
|
|
||||||
|
// load PRG file if needed
|
||||||
|
if (loadPrg)
|
||||||
|
{
|
||||||
|
// check to see if cpu PC is at the BASIC warm start vector
|
||||||
|
if (board.cpu.PC == ((board.ram.Peek(0x0303) << 8) | board.ram.Peek(0x0302)))
|
||||||
|
{
|
||||||
|
//board.ram.Poke(0x0302, 0xAE);
|
||||||
|
//board.ram.Poke(0x0303, 0xA7);
|
||||||
|
////board.ram.Poke(0x0302, board.ram.Peek(0x0308));
|
||||||
|
////board.ram.Poke(0x0303, board.ram.Peek(0x0309));
|
||||||
|
|
||||||
|
//if (inputFileInfo.Data.Length >= 6)
|
||||||
|
//{
|
||||||
|
// board.ram.Poke(0x0039, inputFileInfo.Data[4]);
|
||||||
|
// board.ram.Poke(0x003A, inputFileInfo.Data[5]);
|
||||||
|
//}
|
||||||
|
PRG.Load(board.pla, inputFileInfo.Data);
|
||||||
|
loadPrg = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frameCycles == cyclesPerFrame)
|
||||||
|
{
|
||||||
|
board.Flush();
|
||||||
|
_islag = !board.inputRead;
|
||||||
|
|
||||||
|
if (_islag)
|
||||||
|
_lagcount++;
|
||||||
|
frameCycles -= cyclesPerFrame;
|
||||||
|
_frame++;
|
||||||
|
|
||||||
|
//Console.WriteLine("CPUPC: " + C64Util.ToHex(board.cpu.PC, 4) + " 1541PC: " + C64Util.ToHex(disk.PC, 4));
|
||||||
|
|
||||||
|
int test = board.cpu.LagCycles;
|
||||||
|
DriveLightOn = DriveLED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleFirmwareError(string file)
|
||||||
{
|
{
|
||||||
System.Windows.Forms.MessageBox.Show("the C64 core is referencing a firmware file which could not be found. Please make sure it's in your configured C64 firmwares folder. The referenced filename is: " + file);
|
System.Windows.Forms.MessageBox.Show("the C64 core is referencing a firmware file which could not be found. Please make sure it's in your configured C64 firmwares folder. The referenced filename is: " + file);
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
|
@ -206,7 +205,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Init(Region initRegion)
|
private void Init(DisplayType initRegion)
|
||||||
{
|
{
|
||||||
board = new Motherboard(this, initRegion);
|
board = new Motherboard(this, initRegion);
|
||||||
InitRoms();
|
InitRoms();
|
||||||
|
@ -228,13 +227,13 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
{
|
{
|
||||||
board.cartPort.Connect(cart);
|
board.cartPort.Connect(cart);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case @".TAP":
|
case @".TAP":
|
||||||
CassettePort.Tape tape = CassettePort.Tape.Load(inputFileInfo.Data);
|
CassettePort.Tape tape = CassettePort.Tape.Load(inputFileInfo.Data);
|
||||||
if (tape != null)
|
if (tape != null)
|
||||||
{
|
{
|
||||||
board.cassPort.Connect(tape);
|
board.cassPort.Connect(tape);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case @".PRG":
|
case @".PRG":
|
||||||
if (inputFileInfo.Data.Length > 2)
|
if (inputFileInfo.Data.Length > 2)
|
||||||
|
@ -261,5 +260,5 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
|
||||||
board.HardReset();
|
board.HardReset();
|
||||||
//disk.HardReset();
|
//disk.HardReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,33 +9,33 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.CassettePort
|
||||||
{
|
{
|
||||||
public class CassettePortDevice
|
public class CassettePortDevice
|
||||||
{
|
{
|
||||||
public Func<bool> ReadDataOutput;
|
public Func<bool> ReadDataOutput;
|
||||||
public Func<bool> ReadMotor;
|
public Func<bool> ReadMotor;
|
||||||
Commodore64.CassettePort.Tape tape;
|
Commodore64.CassettePort.Tape tape;
|
||||||
|
|
||||||
public void HardReset()
|
public void HardReset()
|
||||||
{
|
{
|
||||||
if (tape != null) tape.rewind();
|
if (tape != null) tape.rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual public bool ReadDataInputBuffer()
|
virtual public bool ReadDataInputBuffer()
|
||||||
{
|
{
|
||||||
return tape != null && !ReadMotor() ? tape.read() : true;
|
return tape != null && !ReadMotor() ? tape.read() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual public bool ReadSenseBuffer()
|
virtual public bool ReadSenseBuffer()
|
||||||
{
|
{
|
||||||
return tape == null; // Just assume that "play" is constantly pressed as long as a tape is inserted
|
return tape == null; // Just assume that "play" is constantly pressed as long as a tape is inserted
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SyncState(Serializer ser)
|
public void SyncState(Serializer ser)
|
||||||
{
|
{
|
||||||
SaveState.SyncObject(ser, this);
|
SaveState.SyncObject(ser, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Connect(Tape tape)
|
internal void Connect(Tape tape)
|
||||||
{
|
{
|
||||||
this.tape = tape;
|
this.tape = tape;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,85 +9,85 @@ using BizHawk.Common;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Computers.Commodore64.CassettePort
|
namespace BizHawk.Emulation.Cores.Computers.Commodore64.CassettePort
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This class represents a tape. Only TAP-style tapes are supported for now.
|
* This class represents a tape. Only TAP-style tapes are supported for now.
|
||||||
*/
|
*/
|
||||||
class Tape
|
class Tape
|
||||||
{
|
{
|
||||||
private byte[] tapeData;
|
private byte[] tapeData;
|
||||||
private byte version;
|
private byte version;
|
||||||
private uint pos, cycle, start, end;
|
private uint pos, cycle, start, end;
|
||||||
|
|
||||||
public Tape(byte version, byte[] tapeData, uint start, uint end)
|
public Tape(byte version, byte[] tapeData, uint start, uint end)
|
||||||
{
|
{
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.tapeData = tapeData;
|
this.tapeData = tapeData;
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
rewind();
|
rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rewinds the tape back to start
|
// Rewinds the tape back to start
|
||||||
public void rewind()
|
public void rewind()
|
||||||
{
|
{
|
||||||
pos = start;
|
pos = start;
|
||||||
cycle = 0;
|
cycle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads from tape, this will tell the caller if the flag pin should be raised
|
// Reads from tape, this will tell the caller if the flag pin should be raised
|
||||||
public bool read()
|
public bool read()
|
||||||
{
|
{
|
||||||
if (cycle == 0)
|
if (cycle == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Tape @ " + pos.ToString());
|
Console.WriteLine("Tape @ " + pos.ToString());
|
||||||
if (pos >= end)
|
if (pos >= end)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cycle = ((uint)tapeData[pos++])*8;
|
cycle = ((uint)tapeData[pos++])*8;
|
||||||
if (cycle == 0)
|
if (cycle == 0)
|
||||||
{
|
{
|
||||||
if (version == 0)
|
if (version == 0)
|
||||||
{
|
{
|
||||||
cycle = 256 * 8; // unspecified overflow condition
|
cycle = 256 * 8; // unspecified overflow condition
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cycle = BitConverter.ToUInt32(tapeData, (int)pos-1)>>8;
|
cycle = BitConverter.ToUInt32(tapeData, (int)pos-1)>>8;
|
||||||
pos += 3;
|
pos += 3;
|
||||||
if (cycle == 0)
|
if (cycle == 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Bad tape data");
|
throw new Exception("Bad tape data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a single negative pulse at the end of a cycle
|
// Send a single negative pulse at the end of a cycle
|
||||||
return --cycle != 0;
|
return --cycle != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to construct a tape file from file data. Returns null if not a tape file, throws exceptions for bad tape files.
|
// Try to construct a tape file from file data. Returns null if not a tape file, throws exceptions for bad tape files.
|
||||||
// (Note that some error conditions aren't caught right here.)
|
// (Note that some error conditions aren't caught right here.)
|
||||||
static public Tape Load(byte[] tapeFile)
|
static public Tape Load(byte[] tapeFile)
|
||||||
{
|
{
|
||||||
Tape result = null;
|
Tape result = null;
|
||||||
|
|
||||||
if (System.Text.Encoding.ASCII.GetString(tapeFile, 0, 12) == "C64-TAPE-RAW")
|
if (System.Text.Encoding.ASCII.GetString(tapeFile, 0, 12) == "C64-TAPE-RAW")
|
||||||
{
|
{
|
||||||
byte version = tapeFile[12];
|
byte version = tapeFile[12];
|
||||||
if (version > 1) throw new Exception("This tape has an unsupported version");
|
if (version > 1) throw new Exception("This tape has an unsupported version");
|
||||||
uint size = BitConverter.ToUInt32(tapeFile, 16);
|
uint size = BitConverter.ToUInt32(tapeFile, 16);
|
||||||
if (size + 20 != tapeFile.Length)
|
if (size + 20 != tapeFile.Length)
|
||||||
{
|
{
|
||||||
throw new Exception("Tape file header specifies a length that doesn't match the file size");
|
throw new Exception("Tape file header specifies a length that doesn't match the file size");
|
||||||
}
|
}
|
||||||
result = new Tape(version, tapeFile, 20, (uint)tapeFile.Length);
|
result = new Tape(version, tapeFile, 20, (uint)tapeFile.Length);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,18 +99,18 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
lagCycles = value;
|
lagCycles = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool AtInstructionStart()
|
internal bool AtInstructionStart()
|
||||||
{
|
{
|
||||||
return cpu.AtInstructionStart();
|
return cpu.AtInstructionStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
public ushort PC
|
public ushort PC
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -233,7 +233,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
LatchedPort portA;
|
LatchedPort portA;
|
||||||
LatchedPort portB;
|
LatchedPort portB;
|
||||||
|
|
||||||
public MOS6526_2(Region region)
|
public MOS6526_2(Common.DisplayType region)
|
||||||
{
|
{
|
||||||
a = new CiaTimer(serialPortA, underFlowA);
|
a = new CiaTimer(serialPortA, underFlowA);
|
||||||
b = new CiaTimer(serialPortB, underFlowB);
|
b = new CiaTimer(serialPortB, underFlowB);
|
||||||
|
@ -241,10 +241,10 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
portB = new LatchedPort();
|
portB = new LatchedPort();
|
||||||
switch (region)
|
switch (region)
|
||||||
{
|
{
|
||||||
case Region.NTSC:
|
case Common.DisplayType.NTSC:
|
||||||
tod_period = 14318181 / 140;
|
tod_period = 14318181 / 140;
|
||||||
break;
|
break;
|
||||||
case Region.PAL:
|
case Common.DisplayType.PAL:
|
||||||
tod_period = 17734472 / 180;
|
tod_period = 17734472 / 180;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4119,7 +4119,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static public Sid Create(int newSampleRate, Region newRegion)
|
static public Sid Create(int newSampleRate, Common.DisplayType newRegion)
|
||||||
{
|
{
|
||||||
return new Sid(waveTable, newSampleRate, newRegion);
|
return new Sid(waveTable, newSampleRate, newRegion);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
public Func<byte> ReadPotX;
|
public Func<byte> ReadPotX;
|
||||||
public Func<byte> ReadPotY;
|
public Func<byte> ReadPotY;
|
||||||
|
|
||||||
public Sid(int[][] newWaveformTable, int newSampleRate, Region newRegion)
|
public Sid(int[][] newWaveformTable, int newSampleRate, Common.DisplayType newRegion)
|
||||||
{
|
{
|
||||||
uint cyclesPerSec = 0;
|
uint cyclesPerSec = 0;
|
||||||
uint cyclesNum;
|
uint cyclesNum;
|
||||||
|
@ -51,8 +51,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
|
|
||||||
switch (newRegion)
|
switch (newRegion)
|
||||||
{
|
{
|
||||||
case Region.NTSC: cyclesNum = 14318181; cyclesDen = 14; break;
|
case Common.DisplayType.NTSC: cyclesNum = 14318181; cyclesDen = 14; break;
|
||||||
case Region.PAL: cyclesNum = 17734472; cyclesDen = 18; break;
|
case Common.DisplayType.PAL: cyclesNum = 17734472; cyclesDen = 18; break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,8 +145,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
}
|
}
|
||||||
else if (parseba == 0x1000)
|
else if (parseba == 0x1000)
|
||||||
{
|
{
|
||||||
pinBA = !badline;
|
pinBA = !badline;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parsecycleBAsprite0 = (parseba & 0x000F);
|
parsecycleBAsprite0 = (parseba & 0x000F);
|
||||||
|
|
|
@ -74,9 +74,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64.MOS
|
||||||
lastRasterLine = rasterLine;
|
lastRasterLine = rasterLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// display enable compare
|
// display enable compare
|
||||||
if (rasterLine == 0)
|
if (rasterLine == 0)
|
||||||
badlineEnable = false;
|
badlineEnable = false;
|
||||||
|
|
||||||
if (rasterLine == 0x030)
|
if (rasterLine == 0x030)
|
||||||
badlineEnable |= displayEnable;
|
badlineEnable |= displayEnable;
|
||||||
|
|
Loading…
Reference in New Issue