Move Buffer.cs and Util.cs from BizHawk.Emulation to BizHawk.Common, and add 1234832983 usings

This commit is contained in:
adelikat 2013-11-04 00:36:15 +00:00
parent fe7da7c5b5
commit 7b03fc0bc0
155 changed files with 4194 additions and 4062 deletions

View File

@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using BizHawk.Common;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
public class Controller : IController public class Controller : IController

View File

@ -2,6 +2,8 @@
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
//IDEA: put filesizes in DB too. then scans can go real quick by only scanning filesizes that match (and then scanning filesizes that dont match, in case of an emergency) //IDEA: put filesizes in DB too. then scans can go real quick by only scanning filesizes that match (and then scanning filesizes that dont match, in case of an emergency)
//this would be adviseable if we end up with a very large firmware file //this would be adviseable if we end up with a very large firmware file

View File

@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
public static class MnemonicConstants public static class MnemonicConstants

View File

@ -12,6 +12,7 @@ using System.Drawing.Imaging;
//using dx=SlimDX; //using dx=SlimDX;
//using d3d=SlimDX.Direct3D9; //using d3d=SlimDX.Direct3D9;
using BizHawk.Common;
using BizHawk.Client.Common; using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk

View File

@ -6,6 +6,7 @@ using System.Threading;
using SlimDX.DirectInput; using SlimDX.DirectInput;
#endif #endif
using BizHawk.Common;
using BizHawk.Client.Common; using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk

View File

@ -44,6 +44,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Buffer.cs" />
<Compile Include="Extensions.cs" /> <Compile Include="Extensions.cs" />
<Compile Include="HawkFile.cs" /> <Compile Include="HawkFile.cs" />
<Compile Include="MruStack.cs" /> <Compile Include="MruStack.cs" />
@ -51,6 +52,7 @@
<Compile Include="Types.cs" /> <Compile Include="Types.cs" />
<Compile Include="UndoHistory.cs" /> <Compile Include="UndoHistory.cs" />
<Compile Include="Util.cs" /> <Compile Include="Util.cs" />
<Compile Include="Util.String.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -1,7 +1,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace BizHawk namespace BizHawk.Common
{ {
/// <summary> /// <summary>
/// Implements a data simple data buffer with proper life cycle and no bounds checking /// Implements a data simple data buffer with proper life cycle and no bounds checking

View File

@ -0,0 +1,8 @@
namespace BizHawk.Common
{
//TODO: delete me
public unsafe static partial class Util
{
}
}

View File

@ -1,11 +1,919 @@
public unsafe static class Util using System;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace BizHawk.Common
{ {
static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; public static class Colors
static System.Runtime.InteropServices.GCHandle HexConvHandle;
public static char* HexConvPtr;
static unsafe Util()
{ {
HexConvHandle = System.Runtime.InteropServices.GCHandle.Alloc(HexConvArr, System.Runtime.InteropServices.GCHandleType.Pinned); public static int ARGB(byte red, byte green, byte blue)
HexConvPtr = (char*)HexConvHandle.AddrOfPinnedObject().ToPointer(); {
return (int)((uint)((red << 0x10) | (green << 8) | blue | (0xFF << 0x18)));
}
public static int ARGB(byte red, byte green, byte blue, byte alpha)
{
return (int)((uint)((red << 0x10) | (green << 8) | blue | (alpha << 0x18)));
}
public static int Luminosity(byte lum)
{
return (int)((uint)((lum << 0x10) | (lum << 8) | lum | (0xFF << 0x18)));
}
} }
}
public unsafe static partial class Util
{
static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
static System.Runtime.InteropServices.GCHandle HexConvHandle;
public static char* HexConvPtr;
static unsafe Util()
{
HexConvHandle = System.Runtime.InteropServices.GCHandle.Alloc(HexConvArr, System.Runtime.InteropServices.GCHandleType.Pinned);
HexConvPtr = (char*)HexConvHandle.AddrOfPinnedObject().ToPointer();
}
public static string Hash_MD5(byte[] data, int offset, int len)
{
using (var md5 = System.Security.Cryptography.MD5.Create())
{
md5.TransformFinalBlock(data, offset, len);
return Util.BytesToHexString(md5.Hash);
}
}
public static string Hash_SHA1(byte[] data, int offset, int len)
{
using (var sha1 = System.Security.Cryptography.SHA1.Create())
{
sha1.TransformFinalBlock(data, offset, len);
return Util.BytesToHexString(sha1.Hash);
}
}
public static bool IsPowerOfTwo(int x)
{
if (x == 0) return true;
if (x == 1) return true;
return (x & (x - 1)) == 0;
}
public static int SaveRamBytesUsed(byte[] SaveRAM)
{
for (int j = SaveRAM.Length - 1; j >= 0; j--)
if (SaveRAM[j] != 0)
return j + 1;
return 0;
}
// Read bytes from a BinaryReader and translate them into the UTF-8 string they represent.
public static string ReadStringFixedAscii(this BinaryReader r, int bytes)
{
byte[] read = new byte[bytes];
for (int b = 0; b < bytes; b++)
read[b] = r.ReadByte();
return System.Text.Encoding.UTF8.GetString(read);
}
public static string ReadStringAsciiZ(this BinaryReader r)
{
StringBuilder sb = new StringBuilder();
for(;;)
{
int b = r.ReadByte();
if(b <= 0) break;
sb.Append((char)b);
}
return sb.ToString();
}
/// <summary>
/// conerts bytes to an uppercase string of hex numbers in upper case without any spacing or anything
/// //could be extension method
/// </summary>
public static string BytesToHexString(byte[] bytes)
{
StringBuilder sb = new StringBuilder();
foreach (byte b in bytes)
sb.AppendFormat("{0:X2}", b);
return sb.ToString();
}
//could be extension method
public static byte[] HexStringToBytes(string str)
{
MemoryStream ms = new MemoryStream();
if (str.Length % 2 != 0) throw new ArgumentException();
int len = str.Length / 2;
for (int i = 0; i < len; i++)
{
int d = 0;
for (int j = 0; j < 2; j++)
{
char c = char.ToLower(str[i * 2 + j]);
if (c >= '0' && c <= '9')
d += (c - '0');
else if (c >= 'a' && c <= 'f')
d += (c - 'a') + 10;
else throw new ArgumentException();
if (j == 0) d <<= 4;
}
ms.WriteByte((byte)d);
}
return ms.ToArray();
}
//could be extension method
public static void WriteByteBuffer(BinaryWriter bw, byte[] data)
{
if (data == null) bw.Write(0);
else
{
bw.Write(data.Length);
bw.Write(data);
}
}
public static short[] ByteBufferToShortBuffer(byte[] buf)
{
int num = buf.Length / 2;
short[] ret = new short[num];
for (int i = 0; i < num; i++)
{
ret[i] = (short)(buf[i * 2] | (buf[i * 2 + 1] << 8));
}
return ret;
}
public static byte[] ShortBufferToByteBuffer(short[] buf)
{
int num = buf.Length;
byte[] ret = new byte[num * 2];
for (int i = 0; i < num; i++)
{
ret[i * 2 + 0] = (byte)(buf[i] & 0xFF);
ret[i * 2 + 1] = (byte)((buf[i] >> 8) & 0xFF);
}
return ret;
}
public static uint[] ByteBufferToUintBuffer(byte[] buf)
{
int num = buf.Length / 4;
uint[] ret = new uint[num];
for (int i = 0; i < num; i++)
{
ret[i] = (uint)(buf[i * 4] | (buf[i * 4 + 1] << 8) | (buf[i * 4 + 2] << 16) | (buf[i * 4 + 3] << 24));
}
return ret;
}
public static byte[] UintBufferToByteBuffer(uint[] buf)
{
int num = buf.Length;
byte[] ret = new byte[num * 4];
for (int i = 0; i < num; i++)
{
ret[i * 4 + 0] = (byte)(buf[i] & 0xFF);
ret[i * 4 + 1] = (byte)((buf[i] >> 8) & 0xFF);
ret[i * 4 + 2] = (byte)((buf[i] >> 16) & 0xFF);
ret[i * 4 + 3] = (byte)((buf[i] >> 24) & 0xFF);
}
return ret;
}
public static int[] ByteBufferToIntBuffer(byte[] buf)
{
int num = buf.Length / 4;
int[] ret = new int[num];
for (int i = 0; i < num; i++)
{
ret[i] = buf[(i * 4) + 3];
ret[i] <<= 8;
ret[i] |= buf[(i * 4) + 2];
ret[i] <<= 8;
ret[i] |= buf[(i * 4) + 1];
ret[i] <<= 8;
ret[i] |= buf[(i * 4)];
}
return ret;
}
public static byte[] IntBufferToByteBuffer(int[] buf)
{
int num = buf.Length;
byte[] ret = new byte[num * 4];
for (int i = 0; i < num; i++)
{
ret[i * 4 + 0] = (byte)(buf[i] & 0xFF);
ret[i * 4 + 1] = (byte)((buf[i] >> 8) & 0xFF);
ret[i * 4 + 2] = (byte)((buf[i] >> 16) & 0xFF);
ret[i * 4 + 3] = (byte)((buf[i] >> 24) & 0xFF);
}
return ret;
}
public static byte[] ReadByteBuffer(BinaryReader br, bool return_null)
{
int len = br.ReadInt32();
if (len == 0 && return_null) return null;
byte[] ret = new byte[len];
int ofs = 0;
while (len > 0)
{
int done = br.Read(ret, ofs, len);
ofs += done;
len -= done;
}
return ret;
}
public static unsafe int memcmp(void* a, string b, int len)
{
fixed (byte* bp = System.Text.Encoding.ASCII.GetBytes(b))
return memcmp(a, bp, len);
}
public static unsafe int memcmp(void* a, void* b, int len)
{
byte* ba = (byte*)a;
byte* bb = (byte*)b;
for (int i = 0; i < len; i++)
{
byte _a = ba[i];
byte _b = bb[i];
int c = _a - _b;
if (c != 0) return c;
}
return 0;
}
public static unsafe void memset(void* ptr, int val, int len)
{
byte* bptr = (byte*)ptr;
for (int i = 0; i < len; i++)
bptr[i] = (byte)val;
}
public static unsafe void memset32(void* ptr, int val, int len)
{
System.Diagnostics.Debug.Assert(len % 4 == 0);
int dwords = len / 4;
int* dwptr = (int*)ptr;
for (int i = 0; i < dwords; i++)
dwptr[i] = val;
}
public static byte[] ReadAllBytes(Stream stream)
{
const int BUFF_SIZE = 4096;
byte[] buffer = new byte[BUFF_SIZE];
int bytesRead = 0;
var inStream = new BufferedStream(stream);
var outStream = new MemoryStream();
while ((bytesRead = inStream.Read(buffer, 0, BUFF_SIZE)) > 0)
{
outStream.Write(buffer, 0, bytesRead);
}
return outStream.ToArray();
}
public static byte BinToBCD(this byte v)
{
return (byte) (((v / 10) * 16) + (v % 10));
}
public static byte BCDtoBin(this byte v)
{
return (byte) (((v / 16) * 10) + (v % 16));
}
public static string FormatFileSize(long filesize)
{
Decimal size = (Decimal)filesize;
Decimal OneKiloByte = 1024M;
Decimal OneMegaByte = OneKiloByte * 1024M;
Decimal OneGigaByte = OneMegaByte * 1024M;
string suffix;
if (size > 1024 * 1024 * 1024)
{
size /= 1024 * 1024 * 1024;
suffix = "GB";
}
else if (size > 1024 * 1024)
{
size /= 1024 * 1024;
suffix = "MB";
}
else if (size > 1024)
{
size /= 1024;
suffix = "KB";
}
else
{
suffix = " B";
}
string precision = "2";
return String.Format("{0:N" + precision + "}{1}", size, suffix);
}
}
public unsafe class Serializer
{
BinaryReader br;
BinaryWriter bw;
TextReader tr;
TextWriter tw;
public BinaryReader BinaryReader { get { return br; } }
public BinaryWriter BinaryWriter { get { return bw; } }
public TextReader TextReader { get { return tr; } }
public TextWriter TextWriter { get { return tw; } }
public Serializer() { }
public Serializer(BinaryWriter _bw) { StartWrite(_bw); }
public Serializer(BinaryReader _br) { StartRead(_br); }
public Serializer(TextWriter _tw) { StartWrite(_tw); }
public Serializer(TextReader _tr) { StartRead(_tr); }
public static Serializer CreateBinaryWriter(BinaryWriter _bw) { return new Serializer(_bw); }
public static Serializer CreateBinaryReader(BinaryReader _br) { return new Serializer(_br); }
public static Serializer CreateTextWriter(TextWriter _tw) { return new Serializer(_tw); }
public static Serializer CreateTextReader(TextReader _tr) { return new Serializer(_tr); }
public void StartWrite(BinaryWriter _bw) { this.bw = _bw; isReader = false; }
public void StartRead(BinaryReader _br) { this.br = _br; isReader = true; }
public void StartWrite(TextWriter _tw) { this.tw = _tw; isReader = false; isText = true; }
public void StartRead(TextReader _tr) {
this.tr = _tr;
isReader = true;
isText = true;
BeginTextBlock();
}
public bool IsReader { get { return isReader; } }
public bool IsWriter { get { return !IsReader; } }
public bool IsText { get { return isText; } }
bool isText;
bool isReader;
Stack<string> sections = new Stack<string>();
class Section : Dictionary<string, Section>
{
public string Name;
public Dictionary<string, string> Items = new Dictionary<string, string>();
}
Section ReaderSection, CurrSection;
Stack<Section> SectionStack = new Stack<Section>();
void BeginTextBlock()
{
if (!IsText) return;
if (IsWriter) return;
ReaderSection = new Section();
ReaderSection.Name = "";
Stack<Section> ss = new Stack<Section>();
ss.Push(ReaderSection);
Section curs = ReaderSection;
var rxEnd = new System.Text.RegularExpressions.Regex(@"\[/(.*?)\]",System.Text.RegularExpressions.RegexOptions.Compiled);
var rxBegin = new System.Text.RegularExpressions.Regex(@"\[(.*?)\]",System.Text.RegularExpressions.RegexOptions.Compiled);
//read the entire file into a data structure for flexi-parsing
string str;
while ((str = tr.ReadLine()) != null)
{
var end = rxEnd.Match(str);
var begin = rxBegin.Match(str);
if (end.Success)
{
string name = end.Groups[1].Value;
if (name != curs.Name) throw new InvalidOperationException("Mis-formed savestate blob");
curs = ss.Pop();
// consume no data past the end of the last proper section
if (curs == ReaderSection)
{
CurrSection = curs;
return;
}
}
else if (begin.Success)
{
string name = begin.Groups[1].Value;
ss.Push(curs);
var news = new Section();
news.Name = name;
if (!curs.ContainsKey(name))
curs[name] = news;
else
throw new Exception(string.Format("Duplicate key \"{0}\" in serializer savestate!", name));
curs = news;
}
else
{
//add to current section
if (str.Trim().Length == 0) continue;
var parts = str.Split(' ');
var key = parts[0];
//UGLY: adds whole string instead of splitting the key. later, split the key, and have the individual Sync methods give up that responsibility
if (!curs.Items.ContainsKey(key))
curs.Items[key] = parts[1];
else
throw new Exception(string.Format("Duplicate key \"{0}\" in serializer savestate!", key));
}
}
CurrSection = ReaderSection;
}
public void BeginSection(string name)
{
sections.Push(name);
if (IsText)
if (IsWriter) { tw.WriteLine("[{0}]", name); }
else
{
SectionStack.Push(CurrSection);
CurrSection = CurrSection[name];
}
}
public void EndSection()
{
string name = sections.Pop();
if (IsText)
if (IsWriter) tw.WriteLine("[/{0}]", name);
else
{
CurrSection = SectionStack.Pop();
}
}
string Item(string key)
{
return CurrSection.Items[key];
}
bool Present(string key)
{
return CurrSection.Items.ContainsKey(key);
}
public void SyncEnum<T>(string name, ref T val) where T : struct
{
if (typeof(T).BaseType != typeof(System.Enum))
throw new InvalidOperationException();
if (isText) SyncEnumText<T>(name, ref val);
else if (IsReader) val = (T)Enum.ToObject(typeof(T), br.ReadInt32());
else bw.Write(Convert.ToInt32(val));
}
public void SyncEnumText<T>(string name, ref T val) where T : struct
{
if (IsReader) { if (Present(name)) val = (T)Enum.Parse(typeof(T), Item(name)); }
else tw.WriteLine("{0} {1}", name, val.ToString());
}
void SyncBuffer(string name, int elemsize, int len, void* ptr)
{
if (IsReader)
{
byte[] temp = null;
Sync(name, ref temp, false);
int todo = Math.Min(temp.Length, len * elemsize);
System.Runtime.InteropServices.Marshal.Copy(temp, 0, new IntPtr(ptr), todo);
}
else
{
int todo = len * elemsize;
byte[] temp = new byte[todo];
System.Runtime.InteropServices.Marshal.Copy(new IntPtr(ptr), temp, 0, todo);
Sync(name, ref temp, false);
}
}
public void Sync(string name, ref ByteBuffer byteBuf)
{
SyncBuffer(name, 1, byteBuf.len, byteBuf.ptr);
}
public void Sync(string name, ref IntBuffer byteBuf)
{
SyncBuffer(name, 4, byteBuf.len, byteBuf.ptr);
}
public void Sync(string name, ref byte[] val, bool use_null)
{
if (IsText) SyncText(name, ref val, use_null);
else if (IsReader) val = Util.ReadByteBuffer(br, use_null);
else Util.WriteByteBuffer(bw, val);
}
public void SyncText(string name, ref byte[] val, bool use_null)
{
if (IsReader)
{
if(Present(name)) val = Util.HexStringToBytes(Item(name));
if (val != null && val.Length == 0 && use_null) val = null;
}
else
{
byte[] temp = val;
if (temp == null) temp = new byte[0];
tw.WriteLine("{0} {1}", name, Util.BytesToHexString(temp));
}
}
public void Sync(string name, ref short[] val, bool use_null)
{
if (IsText) SyncText(name, ref val, use_null);
else if (IsReader)
{
val = Util.ByteBufferToShortBuffer(Util.ReadByteBuffer(br, false));
if (val == null && !use_null) val = new short[0];
}
else Util.WriteByteBuffer(bw, Util.ShortBufferToByteBuffer(val));
}
public void SyncText(string name, ref short[] val, bool use_null)
{
if (IsReader)
{
if (Present(name))
{
byte[] bytes = Util.HexStringToBytes(Item(name));
val = Util.ByteBufferToShortBuffer(bytes);
}
if (val != null && val.Length == 0 && use_null) val = null;
}
else
{
short[] temp = val;
if (temp == null) temp = new short[0];
tw.WriteLine("{0} {1}", name, Util.BytesToHexString(Util.ShortBufferToByteBuffer(temp)));
}
}
public void Sync(string name, ref int[] val, bool use_null)
{
if (IsText) SyncText(name, ref val, use_null);
else if (IsReader)
{
val = Util.ByteBufferToIntBuffer(Util.ReadByteBuffer(br, false));
if (val == null && !use_null) val = new int[0];
}
else Util.WriteByteBuffer(bw, Util.IntBufferToByteBuffer(val));
}
public void SyncText(string name, ref int[] val, bool use_null)
{
if (IsReader)
{
if (Present(name))
{
byte[] bytes = Util.HexStringToBytes(Item(name));
val = Util.ByteBufferToIntBuffer(bytes);
}
if (val != null && val.Length == 0 && use_null) val = null;
}
else
{
int[] temp = val;
if (temp == null) temp = new int[0];
tw.WriteLine("{0} {1}", name, Util.BytesToHexString(Util.IntBufferToByteBuffer(temp)));
}
}
public void Sync(string name, ref uint[] val, bool use_null)
{
if (IsText) SyncText(name, ref val, use_null);
else if (IsReader)
{
val = Util.ByteBufferToUintBuffer(Util.ReadByteBuffer(br, false));
if (val == null && !use_null) val = new uint[0];
}
else Util.WriteByteBuffer(bw, Util.UintBufferToByteBuffer(val));
}
public void SyncText(string name, ref uint[] val, bool use_null)
{
if (IsReader)
{
if(Present(name))
{
byte[] bytes = Util.HexStringToBytes(Item(name));
val = Util.ByteBufferToUintBuffer(bytes);
}
if (val != null && val.Length == 0 && use_null) val = null;
}
else
{
uint[] temp = val;
if (temp == null) temp = new uint[0];
tw.WriteLine("{0} {1}", name, Util.BytesToHexString(Util.UintBufferToByteBuffer(temp)));
}
}
public void Sync(string name, ref Bit val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
public void SyncText(string name, ref Bit val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void Sync(string name, ref byte val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
void SyncText(string name, ref byte val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void Sync(string name, ref ushort val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
void SyncText(string name, ref ushort val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void Sync(string name, ref uint val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
void SyncText(string name, ref uint val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void Sync(string name, ref sbyte val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
void SyncText(string name, ref sbyte val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void Sync(string name, ref short val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
void SyncText(string name, ref short val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void Sync(string name, ref int val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
void SyncText(string name, ref int val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void Sync(string name, ref bool val)
{
if (IsText) SyncText(name, ref val);
else if (IsReader) Read(ref val);
else Write(ref val);
}
void SyncText(string name, ref bool val)
{
if (IsReader) ReadText(name, ref val);
else WriteText(name, ref val);
}
public void SyncFixedString(string name, ref string val, int length)
{
//TODO - this could be made more efficient perhaps just by writing values right out of the string..
if (IsReader)
{
char[] buf = new char[length];
if (isText)
{
tr.Read(buf, 0, length);
}
else
{
br.Read(buf, 0, length);
}
int len = 0;
for (; len < length; len++)
{
if (buf[len] == 0) break;
}
val = new string(buf, 0, len);
}
else
{
if (name.Length > length) throw new InvalidOperationException("SyncFixedString too long");
char[] buf = val.ToCharArray();
char[] remainder = new char[length - buf.Length];
if (IsText)
{
tw.Write(buf);
tw.Write(remainder);
}
else
{
bw.Write(buf);
bw.Write(remainder);
}
}
}
void Read(ref Bit val) { val = br.ReadBit(); }
void Write(ref Bit val) { bw.WriteBit(val); }
void ReadText(string name, ref Bit val) { if(Present(name)) val = (Bit)int.Parse(Item(name)); }
void WriteText(string name, ref Bit val) { tw.WriteLine("{0} {1}", name, (int)val); }
void Read(ref byte val) { val = br.ReadByte(); }
void Write(ref byte val) { bw.Write(val); }
void ReadText(string name, ref byte val) { if (Present(name)) val = byte.Parse(Item(name).Replace("0x", ""), NumberStyles.HexNumber); }
void WriteText(string name, ref byte val) { tw.WriteLine("{0} 0x{1:X2}", name, val); }
void Read(ref ushort val) { val = br.ReadUInt16(); }
void Write(ref ushort val) { bw.Write(val); }
void ReadText(string name, ref ushort val) { if (Present(name)) val = ushort.Parse(Item(name).Replace("0x", ""), NumberStyles.HexNumber); }
void WriteText(string name, ref ushort val) { tw.WriteLine("{0} 0x{1:X4}", name, val); }
void Read(ref uint val) { val = br.ReadUInt32(); }
void Write(ref uint val) { bw.Write(val); }
void ReadText(string name, ref uint val) { if (Present(name)) val = uint.Parse(Item(name).Replace("0x", ""), NumberStyles.HexNumber); }
void WriteText(string name, ref uint val) { tw.WriteLine("{0} 0x{1:X8}", name, val); }
void Read(ref sbyte val) { val = br.ReadSByte(); }
void Write(ref sbyte val) { bw.Write(val); }
void ReadText(string name, ref sbyte val) { if (Present(name)) val = sbyte.Parse(Item(name).Replace("0x", ""), NumberStyles.HexNumber); }
void WriteText(string name, ref sbyte val) { tw.WriteLine("{0} 0x{1:X2}", name, val); }
void Read(ref short val) { val = br.ReadInt16(); }
void Write(ref short val) { bw.Write(val); }
void ReadText(string name, ref short val) { if (Present(name)) val = short.Parse(Item(name).Replace("0x", ""), NumberStyles.HexNumber); }
void WriteText(string name, ref short val) { tw.WriteLine("{0} 0x{1:X4}", name, val); }
void Read(ref int val) { val = br.ReadInt32(); }
void Write(ref int val) { bw.Write(val); }
void ReadText(string name, ref int val) { if (Present(name)) val = int.Parse(Item(name).Replace("0x", ""), NumberStyles.HexNumber); }
void WriteText(string name, ref int val) { tw.WriteLine("{0} 0x{1:X8}", name, val); }
void Read(ref bool val) { val = br.ReadBoolean(); }
void Write(ref bool val) { bw.Write(val); }
void ReadText(string name, ref bool val) { if (Present(name)) val = bool.Parse(Item(name)); }
void WriteText(string name, ref bool val) { tw.WriteLine("{0} {1}", name, val); }
}
public static class BITREV
{
public static byte[] byte_8;
static BITREV()
{
make_byte_8();
}
static void make_byte_8()
{
int bits = 8;
int n = 1 << 8;
byte_8 = new byte[n];
int m = 1;
int a = n >> 1;
int j = 2;
byte_8[0] = 0;
byte_8[1] = (byte)a;
while ((--bits) != 0)
{
m <<= 1;
a >>= 1;
for (int i = 0; i < m; i++)
byte_8[j++] = (byte)(byte_8[i] + a);
}
}
public static uint reverse_32(uint v)
{
return (uint)((byte_8[v & 0xff] << 24) |
(byte_8[(v >> 8) & 0xff] << 16) |
(byte_8[(v >> 16) & 0xff] << 8) |
(byte_8[(v >> 24) & 0xff]));
}
}
/// <summary>
/// a Dictionary-of-lists with key K and values List&lt;V&gt;
/// </summary>
[Serializable]
public class Bag<K, V> : BagBase<K, V, Dictionary<K, List<V>>, List<V>> { }
/// <summary>
/// a Dictionary-of-lists with key K and values List&lt;V&gt;
/// </summary>
[Serializable]
public class SortedBag<K, V> : BagBase<K, V, SortedDictionary<K, List<V>>, List<V>> { }
/// <summary>
/// A dictionary that creates new values on the fly as necessary so that any key you need will be defined.
/// </summary>
/// <typeparam name="K">dictionary keys</typeparam>
/// <typeparam name="V">dictionary values</typeparam>
public class WorkingDictionary<K, V> : Dictionary<K, V> where V : new()
{
public new V this[K key]
{
get
{
V temp;
if (!TryGetValue(key, out temp))
temp = this[key] = new V();
return temp;
}
set { base[key] = value; }
}
}
/// <summary>
/// base class for Bag and SortedBag
/// </summary>
/// <typeparam name="K">dictionary keys</typeparam>
/// <typeparam name="V">list values</typeparam>
/// <typeparam name="D">dictionary type</typeparam>
/// <typeparam name="L">list type</typeparam>
[Serializable]
public class BagBase<K, V, D, L> : IEnumerable<V>
where D : IDictionary<K, L>, new()
where L : IList<V>, IEnumerable<V>, new()
{
D dictionary = new D();
public void Add(K key, V val)
{
this[key].Add(val);
}
public bool ContainsKey(K key) { return dictionary.ContainsKey(key); }
IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); }
public IEnumerator<V> GetEnumerator()
{
foreach (L lv in dictionary.Values)
foreach (V v in lv)
yield return v;
}
public IEnumerable KeyValuePairEnumerator { get { return dictionary; } }
/// <summary>
/// the list of keys contained herein
/// </summary>
public IList<K> Keys { get { return new List<K>(dictionary.Keys); } }
public L this[K key]
{
get
{
L slot;
if (!dictionary.TryGetValue(key, out slot))
dictionary[key] = slot = new L();
return slot;
}
set
{
dictionary[key] = value;
}
}
}
public class NotTestedException : Exception
{
}
}

View File

@ -45,7 +45,6 @@
<Compile Include="Blobs\Blob_ECM.cs" /> <Compile Include="Blobs\Blob_ECM.cs" />
<Compile Include="Blobs\Blob_WaveFile.cs" /> <Compile Include="Blobs\Blob_WaveFile.cs" />
<Compile Include="Blobs\RiffMaster.cs" /> <Compile Include="Blobs\RiffMaster.cs" />
<Compile Include="Buffer.cs" />
<Compile Include="CCD_format.cs" /> <Compile Include="CCD_format.cs" />
<Compile Include="cdfs\EndianBitConverter.cs" /> <Compile Include="cdfs\EndianBitConverter.cs" />
<Compile Include="cdfs\ISODirectoryNode.cs" /> <Compile Include="cdfs\ISODirectoryNode.cs" />

View File

@ -1,118 +0,0 @@
using System;
using System.Runtime.InteropServices;
//TODO: quick fix, this is the same file as BizHawk.Emulation, move it to BizHawk.Common
namespace BizHawk.Emulation.DiscSystem
{
/// <summary>
/// Implements a data simple data buffer with proper life cycle and no bounds checking
/// </summary>
public unsafe class CBuffer<T> : IDisposable
{
public GCHandle hnd;
public T[] arr;
public void* ptr;
public byte* byteptr;
public int len;
public int itemsize;
public static CBuffer<T> malloc(int amt, int itemsize)
{
return new CBuffer<T>(amt, itemsize);
}
public void Write08(uint addr, byte val) { byteptr[addr] = val; }
public void Write16(uint addr, ushort val) { *(ushort*)(byteptr + addr) = val; }
public void Write32(uint addr, uint val) { *(uint*)(byteptr + addr) = val; }
public void Write64(uint addr, ulong val) { *(ulong*)(byteptr + addr) = val; }
public byte Read08(uint addr) { return byteptr[addr]; }
public ushort Read16(uint addr) { return *(ushort*)(byteptr + addr); }
public uint Read32(uint addr) { return *(uint*)(byteptr + addr); }
public ulong Read64(uint addr) { return *(ulong*)(byteptr + addr); }
public void Write08(int addr, byte val) { byteptr[addr] = val; }
public void Write16(int addr, ushort val) { *(ushort*)(byteptr + addr) = val; }
public void Write32(int addr, uint val) { *(uint*)(byteptr + addr) = val; }
public void Write64(int addr, ulong val) { *(ulong*)(byteptr + addr) = val; }
public byte Read08(int addr) { return byteptr[addr]; }
public ushort Read16(int addr) { return *(ushort*)(byteptr + addr); }
public uint Read32(int addr) { return *(uint*)(byteptr + addr); }
public ulong Read64(int addr) { return *(ulong*)(byteptr + addr); }
public CBuffer(T[] arr, int itemsize)
{
this.itemsize = itemsize;
len = arr.Length;
this.arr = arr;
hnd = GCHandle.Alloc(arr, GCHandleType.Pinned);
ptr = hnd.AddrOfPinnedObject().ToPointer();
byteptr = (byte*)ptr;
}
public CBuffer(int amt, int itemsize)
{
this.itemsize = itemsize;
len = amt;
arr = new T[amt];
hnd = GCHandle.Alloc(arr, GCHandleType.Pinned);
ptr = hnd.AddrOfPinnedObject().ToPointer();
byteptr = (byte*)ptr;
Util.memset(byteptr, 0, len * itemsize);
}
public void Dispose()
{
if (arr != null)
hnd.Free();
arr = null;
}
~CBuffer() { Dispose(); }
}
public class ByteBuffer : CBuffer<byte>
{
public ByteBuffer(int amt) : base(amt,1) { }
public ByteBuffer(byte[] arr) : base(arr,1) { }
public byte this[int index]
{
#if DEBUG
get { return arr[index]; }
set { arr[index] = value; }
#else
set { Write08(index, value); }
get { return Read08(index);}
#endif
}
}
public class IntBuffer : CBuffer<int>
{
public IntBuffer(int amt) : base(amt, 4) { }
public IntBuffer(int[] arr) : base(arr,4) { }
public int this[int index]
{
#if DEBUG
get { return arr[index]; }
set { arr[index] = value; }
#else
set { Write32(index<<2, (uint) value); }
get { return (int)Read32(index<<2);}
#endif
}
}
public class ShortBuffer : CBuffer<short>
{
public ShortBuffer(int amt) : base(amt, 2) { }
public ShortBuffer(short[] arr) : base(arr, 2) { }
public short this[int index]
{
#if DEBUG
get { return arr[index]; }
set { arr[index] = value; }
#else
set { Write32(index << 1, (uint)value); }
get { return (short)Read16(index << 1); }
#endif
}
}
}

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
//main apis for emulator core routine use //main apis for emulator core routine use
namespace BizHawk.Emulation.DiscSystem namespace BizHawk.Emulation.DiscSystem

View File

@ -28,6 +28,8 @@
//Corlett's ECM uses our same fundamental approach as well. //Corlett's ECM uses our same fundamental approach as well.
//I can't figure out what winUAE is doing. //I can't figure out what winUAE is doing.
using BizHawk.Common;
namespace BizHawk.Emulation.DiscSystem namespace BizHawk.Emulation.DiscSystem
{ {
static class ECM static class ECM

View File

@ -9,11 +9,11 @@ using System.IO;
using System.Text; using System.Text;
using BizHawk.Common; using BizHawk.Common;
/*
namespace BizHawk.Emulation.DiscSystem namespace BizHawk.Emulation.DiscSystem
{ {
//TODO: QUICK FIX, this is the same file as BizHawk.Emulation, move to BizHawk.Common and get rid of this //TODO: QUICK FIX, this is the same file as BizHawk.Emulation, move to BizHawk.Common and get rid of this
public static class Colors internal static class Colors
{ {
public static int ARGB(byte red, byte green, byte blue) public static int ARGB(byte red, byte green, byte blue)
{ {
@ -31,7 +31,7 @@ namespace BizHawk.Emulation.DiscSystem
} }
} }
public unsafe static class Util internal unsafe static class Util
{ {
static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; static readonly char[] HexConvArr = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
static System.Runtime.InteropServices.GCHandle HexConvHandle; static System.Runtime.InteropServices.GCHandle HexConvHandle;
@ -920,3 +920,4 @@ namespace BizHawk.Emulation.DiscSystem
{ {
} }
} }
*/

View File

@ -82,7 +82,6 @@
<Compile Include="..\VersionInfo.cs"> <Compile Include="..\VersionInfo.cs">
<Link>VersionInfo.cs</Link> <Link>VersionInfo.cs</Link>
</Compile> </Compile>
<Compile Include="Buffer.cs" />
<Compile Include="Computers\Commodore64\C64.Core.cs" /> <Compile Include="Computers\Commodore64\C64.Core.cs" />
<Compile Include="Computers\Commodore64\C64.cs" /> <Compile Include="Computers\Commodore64\C64.cs" />
<Compile Include="Computers\Commodore64\C64.Motherboard.cs" /> <Compile Include="Computers\Commodore64\C64.Motherboard.cs" />
@ -507,7 +506,6 @@
<Compile Include="Consoles\Sega\SMS\SMS.cs" /> <Compile Include="Consoles\Sega\SMS\SMS.cs" />
<Compile Include="Consoles\Sega\SMS\VDP.cs" /> <Compile Include="Consoles\Sega\SMS\VDP.cs" />
<Compile Include="Sound\YM2413.cs" /> <Compile Include="Sound\YM2413.cs" />
<Compile Include="Util.cs" />
<Compile Include="Sound\Utilities\Waves.cs" /> <Compile Include="Sound\Utilities\Waves.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,6 +1,8 @@
using System; using System;
using System.IO; using System.IO;
using BizHawk.Common;
namespace BizHawk.Emulation.CPUs.M6502 namespace BizHawk.Emulation.CPUs.M6502
{ {
public sealed partial class MOS6502X public sealed partial class MOS6502X

View File

@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using BizHawk.Common;
namespace BizHawk.Emulation.CPUs.M6502 namespace BizHawk.Emulation.CPUs.M6502
{ {
/// <summary> /// <summary>

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using BizHawk.Common;
namespace BizHawk.Emulation.CPUs.M6502 namespace BizHawk.Emulation.CPUs.M6502
{ {
public static class MOS6502X_DLL public static class MOS6502X_DLL

View File

@ -1,11 +1,13 @@
using BizHawk.Emulation.Computers.Commodore64.MOS; using BizHawk.Emulation.Computers.Commodore64.MOS;
using System.Reflection; using System.Reflection;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64 namespace BizHawk.Emulation.Computers.Commodore64
{ {
/// <summary> /// <summary>
/// Contains the onboard chipset and glue. /// Contains the onboard chipset and glue.
/// </summary> /// </summary>
sealed public partial class Motherboard sealed public partial class Motherboard
{ {
// chips // chips
@ -24,7 +26,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
// ports // ports
public CartridgePort cartPort; public CartridgePort cartPort;
public CassettePort cassPort; public CassettePort cassPort;
public IController controller; public IController controller;
public SerialPort serPort; public SerialPort serPort;
public UserPort userPort; public UserPort userPort;
@ -32,8 +34,8 @@ namespace BizHawk.Emulation.Computers.Commodore64
//public int address; //public int address;
public byte bus; public byte bus;
public bool inputRead; public bool inputRead;
public bool irq; public bool irq;
public bool nmi; public bool nmi;
public Motherboard(Region initRegion) public Motherboard(Region initRegion)
{ {
@ -42,7 +44,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
cartPort = new CartridgePort(); cartPort = new CartridgePort();
cassPort = new CassettePort(); cassPort = new CassettePort();
cia0 = new MOS6526(initRegion); cia0 = new MOS6526(initRegion);
cia1 = new MOS6526(initRegion); cia1 = new MOS6526(initRegion);
colorRam = new Chip2114(); colorRam = new Chip2114();
cpu = new MOS6510(); cpu = new MOS6510();
pla = new MOSPLA(); pla = new MOSPLA();
@ -61,22 +63,22 @@ namespace BizHawk.Emulation.Computers.Commodore64
public void Execute() public void Execute()
{ {
vic.ExecutePhase1(); vic.ExecutePhase1();
cpu.ExecutePhase1(); cpu.ExecutePhase1();
cia0.ExecutePhase1(); cia0.ExecutePhase1();
cia1.ExecutePhase1(); cia1.ExecutePhase1();
vic.ExecutePhase2(); vic.ExecutePhase2();
cpu.ExecutePhase2(); cpu.ExecutePhase2();
cia0.ExecutePhase2(); cia0.ExecutePhase2();
cia1.ExecutePhase2(); cia1.ExecutePhase2();
sid.ExecutePhase2(); sid.ExecutePhase2();
} }
public void Flush() public void Flush()
{ {
sid.Flush(); sid.Flush();
} }
// ----------------------------------------- // -----------------------------------------
@ -101,32 +103,32 @@ namespace BizHawk.Emulation.Computers.Commodore64
public void Init() public void Init()
{ {
cartPort.ReadIRQ = Glue_ReadIRQ; cartPort.ReadIRQ = Glue_ReadIRQ;
cartPort.ReadNMI = cia1.ReadIRQBuffer; cartPort.ReadNMI = cia1.ReadIRQBuffer;
cassPort.ReadDataOutput = CassPort_ReadDataOutput; cassPort.ReadDataOutput = CassPort_ReadDataOutput;
cassPort.ReadMotor = CassPort_ReadMotor; cassPort.ReadMotor = CassPort_ReadMotor;
cia0.ReadCNT = Cia0_ReadCnt; cia0.ReadCNT = Cia0_ReadCnt;
cia0.ReadFlag = cassPort.ReadDataInputBuffer; cia0.ReadFlag = cassPort.ReadDataInputBuffer;
cia0.ReadPortA = Cia0_ReadPortA; cia0.ReadPortA = Cia0_ReadPortA;
cia0.ReadPortB = Cia0_ReadPortB; cia0.ReadPortB = Cia0_ReadPortB;
cia0.ReadSP = Cia0_ReadSP; cia0.ReadSP = Cia0_ReadSP;
cia1.ReadCNT = Cia1_ReadCnt; cia1.ReadCNT = Cia1_ReadCnt;
cia1.ReadFlag = userPort.ReadFlag2; cia1.ReadFlag = userPort.ReadFlag2;
cia1.ReadPortA = Cia1_ReadPortA; cia1.ReadPortA = Cia1_ReadPortA;
cia1.ReadPortB = userPort.ReadData; cia1.ReadPortB = userPort.ReadData;
cia1.ReadSP = Cia1_ReadSP; cia1.ReadSP = Cia1_ReadSP;
cpu.PeekMemory = pla.Peek; cpu.PeekMemory = pla.Peek;
cpu.PokeMemory = pla.Poke; cpu.PokeMemory = pla.Poke;
cpu.ReadAEC = vic.ReadAECBuffer; cpu.ReadAEC = vic.ReadAECBuffer;
cpu.ReadIRQ = Glue_ReadIRQ; cpu.ReadIRQ = Glue_ReadIRQ;
cpu.ReadNMI = cia1.ReadIRQBuffer; cpu.ReadNMI = cia1.ReadIRQBuffer;
cpu.ReadPort = Cpu_ReadPort; cpu.ReadPort = Cpu_ReadPort;
cpu.ReadRDY = vic.ReadBABuffer; cpu.ReadRDY = vic.ReadBABuffer;
cpu.ReadMemory = pla.Read; cpu.ReadMemory = pla.Read;
cpu.WriteMemory = pla.Write; cpu.WriteMemory = pla.Write;
pla.PeekBasicRom = basicRom.Peek; pla.PeekBasicRom = basicRom.Peek;
@ -152,93 +154,93 @@ namespace BizHawk.Emulation.Computers.Commodore64
pla.PokeMemory = ram.Poke; pla.PokeMemory = ram.Poke;
pla.PokeSid = sid.Poke; pla.PokeSid = sid.Poke;
pla.PokeVic = vic.Poke; pla.PokeVic = vic.Poke;
pla.ReadAEC = vic.ReadAECBuffer; pla.ReadAEC = vic.ReadAECBuffer;
pla.ReadBA = vic.ReadBABuffer; pla.ReadBA = vic.ReadBABuffer;
pla.ReadBasicRom = basicRom.Read; pla.ReadBasicRom = basicRom.Read;
pla.ReadCartridgeHi = cartPort.ReadHiRom; pla.ReadCartridgeHi = cartPort.ReadHiRom;
pla.ReadCartridgeLo = cartPort.ReadLoRom; pla.ReadCartridgeLo = cartPort.ReadLoRom;
pla.ReadCharen = Pla_ReadCharen; pla.ReadCharen = Pla_ReadCharen;
pla.ReadCharRom = charRom.Read; pla.ReadCharRom = charRom.Read;
pla.ReadCia0 = Pla_ReadCia0; pla.ReadCia0 = Pla_ReadCia0;
pla.ReadCia1 = cia1.Read; pla.ReadCia1 = cia1.Read;
pla.ReadColorRam = Pla_ReadColorRam; pla.ReadColorRam = Pla_ReadColorRam;
pla.ReadExpansionHi = cartPort.ReadHiExp; pla.ReadExpansionHi = cartPort.ReadHiExp;
pla.ReadExpansionLo = cartPort.ReadLoExp; pla.ReadExpansionLo = cartPort.ReadLoExp;
pla.ReadExRom = cartPort.ReadExRom; pla.ReadExRom = cartPort.ReadExRom;
pla.ReadGame = cartPort.ReadGame; pla.ReadGame = cartPort.ReadGame;
pla.ReadHiRam = Pla_ReadHiRam; pla.ReadHiRam = Pla_ReadHiRam;
pla.ReadKernalRom = kernalRom.Read; pla.ReadKernalRom = kernalRom.Read;
pla.ReadLoRam = Pla_ReadLoRam; pla.ReadLoRam = Pla_ReadLoRam;
pla.ReadMemory = ram.Read; pla.ReadMemory = ram.Read;
pla.ReadSid = sid.Read; pla.ReadSid = sid.Read;
pla.ReadVic = vic.Read; pla.ReadVic = vic.Read;
pla.WriteCartridgeHi = cartPort.WriteHiRom; pla.WriteCartridgeHi = cartPort.WriteHiRom;
pla.WriteCartridgeLo = cartPort.WriteLoRom; pla.WriteCartridgeLo = cartPort.WriteLoRom;
pla.WriteCia0 = cia0.Write; pla.WriteCia0 = cia0.Write;
pla.WriteCia1 = cia1.Write; pla.WriteCia1 = cia1.Write;
pla.WriteColorRam = colorRam.Write; pla.WriteColorRam = colorRam.Write;
pla.WriteExpansionHi = cartPort.WriteHiExp; pla.WriteExpansionHi = cartPort.WriteHiExp;
pla.WriteExpansionLo = cartPort.WriteLoExp; pla.WriteExpansionLo = cartPort.WriteLoExp;
pla.WriteMemory = ram.Write; pla.WriteMemory = ram.Write;
pla.WriteSid = sid.Write; pla.WriteSid = sid.Write;
pla.WriteVic = vic.Write; pla.WriteVic = vic.Write;
serPort.ReadAtnOut = SerPort_ReadAtnOut; serPort.ReadAtnOut = SerPort_ReadAtnOut;
serPort.ReadClockOut = SerPort_ReadClockOut; serPort.ReadClockOut = SerPort_ReadClockOut;
serPort.ReadDataOut = SerPort_ReadDataOut; serPort.ReadDataOut = SerPort_ReadDataOut;
sid.ReadPotX = Sid_ReadPotX; sid.ReadPotX = Sid_ReadPotX;
sid.ReadPotY = Sid_ReadPotY; sid.ReadPotY = Sid_ReadPotY;
vic.ReadMemory = Vic_ReadMemory; vic.ReadMemory = Vic_ReadMemory;
vic.ReadColorRam = colorRam.Read; vic.ReadColorRam = colorRam.Read;
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
ser.BeginSection("motherboard"); ser.BeginSection("motherboard");
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
ser.EndSection(); ser.EndSection();
ser.BeginSection("cartridge"); ser.BeginSection("cartridge");
cartPort.SyncState(ser); cartPort.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("cassette"); ser.BeginSection("cassette");
cassPort.SyncState(ser); cassPort.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("cia0"); ser.BeginSection("cia0");
cia0.SyncState(ser); cia0.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("cia1"); ser.BeginSection("cia1");
cia1.SyncState(ser); cia1.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("colorram"); ser.BeginSection("colorram");
colorRam.SyncState(ser); colorRam.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("cpu"); ser.BeginSection("cpu");
cpu.SyncState(ser); cpu.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("pla"); ser.BeginSection("pla");
pla.SyncState(ser); pla.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("ram"); ser.BeginSection("ram");
ram.SyncState(ser); ram.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("sid"); ser.BeginSection("sid");
sid.SyncState(ser); sid.SyncState(ser);
ser.EndSection(); ser.EndSection();
ser.BeginSection("vic"); ser.BeginSection("vic");
vic.SyncState(ser); vic.SyncState(ser);
ser.EndSection(); ser.EndSection();
} }
} }
} }

View File

@ -1,5 +1,7 @@
using System.IO; using System.IO;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64 namespace BizHawk.Emulation.Computers.Commodore64
{ {
sealed public partial class C64 : IEmulator sealed public partial class C64 : IEmulator
@ -51,9 +53,9 @@ namespace BizHawk.Emulation.Computers.Commodore64
void SyncState(Serializer ser) void SyncState(Serializer ser)
{ {
ser.BeginSection("core"); ser.BeginSection("core");
board.SyncState(ser); board.SyncState(ser);
ser.EndSection(); ser.EndSection();
} }
} }
} }

View File

@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Computers.Commodore64.Cartridge
{ {
// this is the base cartridge class // this is the base cartridge class
@ -236,7 +238,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.Cartridge
public virtual void SyncState(Serializer ser) public virtual void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
public bool Valid public bool Valid

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Computers.Commodore64.Cartridge
{ {
public class Mapper0005 : Cart public class Mapper0005 : Cart

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Computers.Commodore64.Cartridge
{ {
// This is a mapper used commonly by System 3. It is // This is a mapper used commonly by System 3. It is

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Computers.Commodore64.Cartridge
{ {
public class Mapper0012 : Cart public class Mapper0012 : Cart

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Computers.Commodore64.Cartridge
{ {

View File

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Cartridge namespace BizHawk.Emulation.Computers.Commodore64.Cartridge
{ {

View File

@ -3,17 +3,19 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
public class Cassette public class Cassette
{ {
public Func<bool> InputData; public Func<bool> InputData;
public Func<bool> InputMotor; public Func<bool> InputMotor;
virtual public bool Data { get { return true; } } virtual public bool Data { get { return true; } }
public bool OutputData() { return Data; } public bool OutputData() { return Data; }
public bool OutputSense() { return Sense; } public bool OutputSense() { return Sense; }
virtual public bool Sense { get { return true; } } virtual public bool Sense { get { return true; } }
virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,31 +3,33 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
sealed public partial class Cia sealed public partial class Cia
{ {
public Func<bool> InputCNT; public Func<bool> InputCNT;
public Func<bool> InputFlag; public Func<bool> InputFlag;
public Func<int> InputPortA; public Func<int> InputPortA;
public Func<int> InputPortB; public Func<int> InputPortB;
public Func<bool> InputSP; public Func<bool> InputSP;
public bool CNT { get { return true; } } public bool CNT { get { return true; } }
public bool IRQ { get { return true; } } public bool IRQ { get { return true; } }
public bool OutputCNT() { return CNT; } public bool OutputCNT() { return CNT; }
public bool OutputIRQ() { return IRQ; } public bool OutputIRQ() { return IRQ; }
public bool OutputPC() { return PC; } public bool OutputPC() { return PC; }
public int OutputPortA() { return PortA; } public int OutputPortA() { return PortA; }
public int OutputPortB() { return PortB; } public int OutputPortB() { return PortB; }
public bool OutputSP() { return SP; } public bool OutputSP() { return SP; }
public bool PC { get { return true; } } public bool PC { get { return true; } }
public int PortA { get { return 0xFF; } } public int PortA { get { return 0xFF; } }
public int PortB { get { return 0xFF; } } public int PortB { get { return 0xFF; } }
public bool PortA0 { get { return true; } } public bool PortA0 { get { return true; } }
public bool SP { get { return true; } } public bool SP { get { return true; } }
public void Clock() { } public void Clock() { }
public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,36 +3,38 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
sealed public partial class Cpu sealed public partial class Cpu
{ {
public Func<bool> InputAEC; public Func<bool> InputAEC;
public Func<bool> InputIRQ; public Func<bool> InputIRQ;
public Func<bool> InputNMI; public Func<bool> InputNMI;
public Func<int> InputPort; public Func<int> InputPort;
public Func<bool> InputRDY; public Func<bool> InputRDY;
public Func<int, int> ReadMemory; public Func<int, int> ReadMemory;
public Action<int, int> WriteMemory; public Action<int, int> WriteMemory;
public int OutputPort() { return Port; } public int OutputPort() { return Port; }
public bool OutputPort0() { return Port0; } public bool OutputPort0() { return Port0; }
public bool OutputPort1() { return Port1; } public bool OutputPort1() { return Port1; }
public bool OutputPort2() { return Port2; } public bool OutputPort2() { return Port2; }
public bool OutputPort3() { return Port3; } public bool OutputPort3() { return Port3; }
public bool OutputPort4() { return Port4; } public bool OutputPort4() { return Port4; }
public bool OutputPort5() { return Port5; } public bool OutputPort5() { return Port5; }
public bool OutputPort6() { return Port6; } public bool OutputPort6() { return Port6; }
public bool OutputPort7() { return Port7; } public bool OutputPort7() { return Port7; }
public int Port { get { return (portLatch | (~portDirection)) & 0xFF; } } public int Port { get { return (portLatch | (~portDirection)) & 0xFF; } }
public bool Port0 { get { return (Port & 0x01) != 0; } } public bool Port0 { get { return (Port & 0x01) != 0; } }
public bool Port1 { get { return (Port & 0x02) != 0; } } public bool Port1 { get { return (Port & 0x02) != 0; } }
public bool Port2 { get { return (Port & 0x04) != 0; } } public bool Port2 { get { return (Port & 0x04) != 0; } }
public bool Port3 { get { return (Port & 0x08) != 0; } } public bool Port3 { get { return (Port & 0x08) != 0; } }
public bool Port4 { get { return (Port & 0x10) != 0; } } public bool Port4 { get { return (Port & 0x10) != 0; } }
public bool Port5 { get { return (Port & 0x20) != 0; } } public bool Port5 { get { return (Port & 0x20) != 0; } }
public bool Port6 { get { return (Port & 0x40) != 0; } } public bool Port6 { get { return (Port & 0x40) != 0; } }
public bool Port7 { get { return (Port & 0x80) != 0; } } public bool Port7 { get { return (Port & 0x80) != 0; } }
public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,18 +3,20 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
public class Expansion public class Expansion
{ {
virtual public bool ExRom { get { return true; } } virtual public bool ExRom { get { return true; } }
virtual public bool Game { get { return true; } } virtual public bool Game { get { return true; } }
virtual public bool IRQ { get { return true; } } virtual public bool IRQ { get { return true; } }
virtual public bool NMI { get { return true; } } virtual public bool NMI { get { return true; } }
public bool OutputExRom() { return ExRom; } public bool OutputExRom() { return ExRom; }
public bool OutputGame() { return Game; } public bool OutputGame() { return Game; }
public bool OutputIRQ() { return IRQ; } public bool OutputIRQ() { return IRQ; }
public bool OutputNMI() { return NMI; } public bool OutputNMI() { return NMI; }
virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,14 +3,16 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
public class Joystick public class Joystick
{ {
virtual public int Data { get { return 0xFF; } } virtual public int Data { get { return 0xFF; } }
public int OutputData() { return Data; } public int OutputData() { return Data; }
public int OutputPot() { return Pot; } public int OutputPot() { return Pot; }
virtual public int Pot { get { return 0xFF; } } virtual public int Pot { get { return 0xFF; } }
virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,16 +3,18 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
public class Keyboard public class Keyboard
{ {
virtual public int Column { get { return 0xFF; } } virtual public int Column { get { return 0xFF; } }
public int OutputColumn() { return Column; } public int OutputColumn() { return Column; }
public bool OutputRestore() { return Restore; } public bool OutputRestore() { return Restore; }
public int OutputRow() { return Row; } public int OutputRow() { return Row; }
virtual public bool Restore { get { return true; } } virtual public bool Restore { get { return true; } }
virtual public int Row { get { return 0xFF; } } virtual public int Row { get { return 0xFF; } }
virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,41 +3,43 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
sealed public class Ram sealed public class Ram
{ {
int addressMask; int addressMask;
int dataMask; int dataMask;
int[] memory; int[] memory;
public Ram(int size, int addressMask, int dataMask) public Ram(int size, int addressMask, int dataMask)
{ {
this.addressMask = addressMask; this.addressMask = addressMask;
this.dataMask = dataMask; this.dataMask = dataMask;
this.memory = new int[size]; this.memory = new int[size];
} }
public int Peek(int addr) public int Peek(int addr)
{ {
return memory[addr & addressMask]; return memory[addr & addressMask];
} }
public void Poke(int addr, int val) public void Poke(int addr, int val)
{ {
memory[addr & addressMask] = val; memory[addr & addressMask] = val;
} }
public int Read(int addr) public int Read(int addr)
{ {
return memory[addr & addressMask]; return memory[addr & addressMask];
} }
public void Write(int addr, int val) public void Write(int addr, int val)
{ {
memory[addr & addressMask] = val & dataMask; memory[addr & addressMask] = val & dataMask;
} }
public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,31 +3,33 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
public class Rom public class Rom
{ {
int addressMask; int addressMask;
int[] memory; int[] memory;
public Rom(int size, int addressMask, byte[] data) public Rom(int size, int addressMask, byte[] data)
{ {
this.addressMask = addressMask; this.addressMask = addressMask;
this.memory = new int[size]; this.memory = new int[size];
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
memory[i] = data[i]; memory[i] = data[i];
} }
public int Peek(int addr) public int Peek(int addr)
{ {
return memory[addr & addressMask]; return memory[addr & addressMask];
} }
public int Read(int addr) public int Read(int addr)
{ {
return memory[addr & addressMask]; return memory[addr & addressMask];
} }
public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,21 +3,23 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
public class Serial public class Serial
{ {
public Func<bool> InputATN; public Func<bool> InputATN;
public Func<bool> InputClock; public Func<bool> InputClock;
public Func<bool> InputData; public Func<bool> InputData;
public Func<bool> InputReset; public Func<bool> InputReset;
virtual public bool Clock { get { return true; } } virtual public bool Clock { get { return true; } }
virtual public bool Data { get { return true; } } virtual public bool Data { get { return true; } }
public bool OutputClock() { return Clock; } public bool OutputClock() { return Clock; }
public bool OutputData() { return Data; } public bool OutputData() { return Data; }
public bool OutputSRQ() { return SRQ; } public bool OutputSRQ() { return SRQ; }
virtual public bool SRQ { get { return true; } } virtual public bool SRQ { get { return true; } }
virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); } virtual public void SyncState(Serializer ser) { SaveState.SyncObject(ser, this); }
} }
} }

View File

@ -3,10 +3,12 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
sealed public partial class Sid sealed public partial class Sid
{ {
public void SyncState(Serializer ser) { } public void SyncState(Serializer ser) { }
} }
} }

View File

@ -3,12 +3,14 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
sealed public partial class Vic sealed public partial class Vic
{ {
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
} }
} }
} }

View File

@ -3,18 +3,20 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete #pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete
namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
{ {
sealed public partial class Vic : IVideoProvider sealed public partial class Vic : IVideoProvider
{ {
int screenHeight; int screenHeight;
int screenWidth; int screenWidth;
int[] videoBuffer; int[] videoBuffer;
// palette // palette
static private int[] palette = static private int[] palette =
{ {
Colors.ARGB(0x00, 0x00, 0x00), Colors.ARGB(0x00, 0x00, 0x00),
Colors.ARGB(0xFF, 0xFF, 0xFF), Colors.ARGB(0xFF, 0xFF, 0xFF),
@ -34,29 +36,29 @@ namespace BizHawk.Emulation.Computers.Commodore64.Experimental.Chips.Internals
Colors.ARGB(0x95, 0x95, 0x95) Colors.ARGB(0x95, 0x95, 0x95)
}; };
public int[] GetVideoBuffer() public int[] GetVideoBuffer()
{ {
return videoBuffer; return videoBuffer;
} }
public int VirtualWidth public int VirtualWidth
{ {
get { return screenWidth; } get { return screenWidth; }
} }
public int BufferWidth public int BufferWidth
{ {
get { return screenWidth; } get { return screenWidth; }
} }
public int BufferHeight public int BufferHeight
{ {
get { return screenHeight; } get { return screenHeight; }
} }
public int BackgroundColor public int BackgroundColor
{ {
get { return palette[0]; } get { return palette[0]; }
} }
} }
} }

View File

@ -1,15 +1,17 @@
using System; using System;
using BizHawk.Common;
using BizHawk.Emulation.Computers.Commodore64.Cartridge; using BizHawk.Emulation.Computers.Commodore64.Cartridge;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
sealed public class CartridgePort sealed public class CartridgePort
{ {
public Func<bool> ReadIRQ; public Func<bool> ReadIRQ;
public Func<bool> ReadNMI; public Func<bool> ReadNMI;
Cart cart; Cart cart;
bool connected; bool connected;
public CartridgePort() public CartridgePort()
{ {
@ -29,9 +31,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public void PokeLoExp(int addr, byte val) { if (connected) { cart.PokeDE00(addr & 0x00FF, val); } } public void PokeLoExp(int addr, byte val) { if (connected) { cart.PokeDE00(addr & 0x00FF, val); } }
public void PokeLoRom(int addr, byte val) { if (connected) { cart.Poke8000(addr & 0x1FFF, val); } } public void PokeLoRom(int addr, byte val) { if (connected) { cart.Poke8000(addr & 0x1FFF, val); } }
public bool ReadExRom() { if (connected) { return cart.ExRom; } else { return true; } } public bool ReadExRom() { if (connected) { return cart.ExRom; } else { return true; } }
public bool ReadGame() { if (connected) { return cart.Game; } else { return true; } } public bool ReadGame() { if (connected) { return cart.Game; } else { return true; } }
public byte ReadHiExp(int addr) { if (connected) { return cart.ReadDF00((addr & 0x00FF)); } else { return 0xFF; } } public byte ReadHiExp(int addr) { if (connected) { return cart.ReadDF00((addr & 0x00FF)); } else { return 0xFF; } }
public byte ReadHiRom(int addr) { if (connected) { return cart.ReadA000((addr & 0x1FFF)); } else { return 0xFF; } } public byte ReadHiRom(int addr) { if (connected) { return cart.ReadA000((addr & 0x1FFF)); } else { return 0xFF; } }
public byte ReadLoExp(int addr) { if (connected) { return cart.ReadDE00((addr & 0x00FF)); } else { return 0xFF; } } public byte ReadLoExp(int addr) { if (connected) { return cart.ReadDE00((addr & 0x00FF)); } else { return 0xFF; } }
public byte ReadLoRom(int addr) { if (connected) { return cart.Read8000((addr & 0x1FFF)); } else { return 0xFF; } } public byte ReadLoRom(int addr) { if (connected) { return cart.Read8000((addr & 0x1FFF)); } else { return 0xFF; } }
@ -68,19 +70,19 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
} }
} }
public bool ReadIRQBuffer() public bool ReadIRQBuffer()
{
return true;
}
public bool ReadNMIBuffer()
{
return true;
}
public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); return true;
}
public bool ReadNMIBuffer()
{
return true;
}
public void SyncState(Serializer ser)
{
SaveState.SyncObject(ser, this);
} }
} }
} }

View File

@ -1,29 +1,30 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
public class CassettePort public class CassettePort
{ {
public Func<bool> ReadDataOutput; public Func<bool> ReadDataOutput;
public Func<bool> ReadMotor; public Func<bool> ReadMotor;
public void HardReset() public void HardReset()
{ {
} }
virtual public bool ReadDataInputBuffer() virtual public bool ReadDataInputBuffer()
{ {
return true; return true;
} }
virtual public bool ReadSenseBuffer() virtual public bool ReadSenseBuffer()
{ {
return true; return true;
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
} }
} }

View File

@ -1,10 +1,12 @@
namespace BizHawk.Emulation.Computers.Commodore64.MOS using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
// used as Color RAM in C64 // used as Color RAM in C64
sealed public class Chip2114 sealed public class Chip2114
{ {
byte[] ram; byte[] ram;
public Chip2114() public Chip2114()
{ {
@ -31,15 +33,15 @@
return ram[addr & 0x3FF]; return ram[addr & 0x3FF];
} }
public int ReadInt(int addr) public int ReadInt(int addr)
{ {
return ram[addr & 0x3FF]; return ram[addr & 0x3FF];
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
public void Write(int addr, byte val) public void Write(int addr, byte val)
{ {

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
@ -53,7 +54,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
} }
} }

View File

@ -1,19 +1,21 @@
namespace BizHawk.Emulation.Computers.Commodore64.MOS using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
// DRAM for the c64 // DRAM for the c64
// 4164 = 64 kbit // 4164 = 64 kbit
// 4464 = 256 kbit // 4464 = 256 kbit
// 4864 = 512 kbit // 4864 = 512 kbit
// for purposes of simplification we'll just // for purposes of simplification we'll just
// use one 4864, the C64 can use sets of 4164 or // use one 4864, the C64 can use sets of 4164 or
// 4464 typically // 4464 typically
// memory is striped 00/FF at intervals of 0x40 // memory is striped 00/FF at intervals of 0x40
sealed public class Chip4864 sealed public class Chip4864
{ {
byte[] ram; byte[] ram;
public Chip4864() public Chip4864()
{ {
@ -35,22 +37,22 @@
public void Poke(int addr, byte val) public void Poke(int addr, byte val)
{ {
ram[addr] = val; ram[addr] = val;
} }
public byte Read(int addr) public byte Read(int addr)
{ {
return ram[addr]; return ram[addr];
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
public void Write(int addr, byte val) public void Write(int addr, byte val)
{ {
ram[addr] = val; ram[addr] = val;
} }
} }
} }

View File

@ -3,18 +3,20 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
// an extension of the 6502 processor // an extension of the 6502 processor
sealed public class MOS6510 sealed public class MOS6510
{ {
// ------------------------------------ // ------------------------------------
MOS6502X cpu; MOS6502X cpu;
bool pinNMILast; bool pinNMILast;
LatchedPort port; LatchedPort port;
bool thisNMI; bool thisNMI;
public Func<int, byte> PeekMemory; public Func<int, byte> PeekMemory;
public Action<int, byte> PokeMemory; public Action<int, byte> PokeMemory;
@ -23,65 +25,65 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public Func<bool> ReadNMI; public Func<bool> ReadNMI;
public Func<bool> ReadRDY; public Func<bool> ReadRDY;
public Func<int, byte> ReadMemory; public Func<int, byte> ReadMemory;
public Func<byte> ReadPort; public Func<byte> ReadPort;
public Action<int, byte> WriteMemory; public Action<int, byte> WriteMemory;
// ------------------------------------ // ------------------------------------
public MOS6510() public MOS6510()
{ {
cpu = new MOS6502X(); cpu = new MOS6502X();
// configure cpu r/w // configure cpu r/w
cpu.DummyReadMemory = Read; cpu.DummyReadMemory = Read;
cpu.ReadMemory = Read; cpu.ReadMemory = Read;
cpu.WriteMemory = Write; cpu.WriteMemory = Write;
// perform hard reset // perform hard reset
HardReset(); HardReset();
} }
public void HardReset() public void HardReset()
{ {
// configure CPU defaults // configure CPU defaults
cpu.Reset(); cpu.Reset();
cpu.FlagI = true; cpu.FlagI = true;
cpu.BCD_Enabled = true; cpu.BCD_Enabled = true;
if (ReadMemory != null) if (ReadMemory != null)
cpu.PC = (ushort)(ReadMemory(0x0FFFC) | (ReadMemory(0x0FFFD) << 8)); cpu.PC = (ushort)(ReadMemory(0x0FFFC) | (ReadMemory(0x0FFFD) << 8));
// configure data port defaults // configure data port defaults
port = new LatchedPort(); port = new LatchedPort();
port.Direction = 0x00; port.Direction = 0x00;
port.Latch = 0xFF; port.Latch = 0xFF;
// NMI is high on startup (todo: verify) // NMI is high on startup (todo: verify)
pinNMILast = true; pinNMILast = true;
} }
// ------------------------------------ // ------------------------------------
public void ExecutePhase1() public void ExecutePhase1()
{ {
cpu.IRQ = !ReadIRQ(); cpu.IRQ = !ReadIRQ();
} }
public void ExecutePhase2() public void ExecutePhase2()
{ {
cpu.RDY = ReadRDY(); cpu.RDY = ReadRDY();
// the 6502 core expects active high // the 6502 core expects active high
// so we reverse the polarity here // so we reverse the polarity here
thisNMI = ReadNMI(); thisNMI = ReadNMI();
if (!thisNMI && pinNMILast) if (!thisNMI && pinNMILast)
cpu.NMI = true; cpu.NMI = true;
if (ReadAEC()) if (ReadAEC())
{ {
cpu.ExecuteOne(); cpu.ExecuteOne();
pinNMILast = thisNMI; pinNMILast = thisNMI;
} }
} }
// ------------------------------------ // ------------------------------------
@ -91,10 +93,10 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
return cpu.PC; return cpu.PC;
} }
set set
{ {
cpu.PC = value; cpu.PC = value;
} }
} }
public byte Peek(int addr) public byte Peek(int addr)
@ -109,7 +111,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public void Poke(int addr, byte val) public void Poke(int addr, byte val)
{ {
if (addr == 0x0000) if (addr == 0x0000)
port.Direction = val; port.Direction = val;
else if (addr == 0x0001) else if (addr == 0x0001)
port.Latch = val; port.Latch = val;
@ -117,19 +119,19 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
PokeMemory(addr, val); PokeMemory(addr, val);
} }
public byte PortData public byte PortData
{ {
get get
{ {
return port.ReadInput(ReadPort()); return port.ReadInput(ReadPort());
} }
set set
{ {
port.Latch = value; port.Latch = value;
} }
} }
public byte Read(ushort addr) public byte Read(ushort addr)
{ {
if (addr == 0x0000) if (addr == 0x0000)
return port.Direction; return port.Direction;
@ -139,13 +141,13 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
return ReadMemory(addr); return ReadMemory(addr);
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
cpu.SyncState(ser); cpu.SyncState(ser);
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
public void Write(ushort addr, byte val) public void Write(ushort addr, byte val)
{ {
if (addr == 0x0000) if (addr == 0x0000)
port.Direction = val; port.Direction = val;

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {

View File

@ -1,84 +1,85 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
sealed public class LatchedPort sealed public class LatchedPort
{ {
public byte Direction; public byte Direction;
public byte Latch; public byte Latch;
public LatchedPort() public LatchedPort()
{ {
Direction = 0x00; Direction = 0x00;
Latch = 0x00; Latch = 0x00;
} }
// data works like this in these types of systems: // data works like this in these types of systems:
// //
// directionA directionB result // directionA directionB result
// 0 0 1 // 0 0 1
// 1 0 latchA // 1 0 latchA
// 0 1 latchB // 0 1 latchB
// 1 1 latchA && latchB // 1 1 latchA && latchB
// //
// however because this uses transistor logic, there are cases where wired-ands // however because this uses transistor logic, there are cases where wired-ands
// cause the pull-up resistors not to be enough to keep the bus bit set to 1 when // cause the pull-up resistors not to be enough to keep the bus bit set to 1 when
// both the direction and latch are 1 (the keyboard and joystick port 2 can do this.) // both the direction and latch are 1 (the keyboard and joystick port 2 can do this.)
// the class does not handle this case as it must be handled differently in every occurrence. // the class does not handle this case as it must be handled differently in every occurrence.
public byte ReadInput(byte bus) public byte ReadInput(byte bus)
{ {
return (byte)((Latch & Direction) | ((Direction ^ 0xFF) & bus)); return (byte)((Latch & Direction) | ((Direction ^ 0xFF) & bus));
} }
public byte ReadOutput() public byte ReadOutput()
{ {
return (byte)((Latch & Direction) | (Direction ^ 0xFF)); return (byte)((Latch & Direction) | (Direction ^ 0xFF));
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
} }
sealed public class LatchedBooleanPort sealed public class LatchedBooleanPort
{ {
public bool Direction; public bool Direction;
public bool Latch; public bool Latch;
public LatchedBooleanPort() public LatchedBooleanPort()
{ {
Direction = false; Direction = false;
Latch = false; Latch = false;
} }
// data dir bus out // data dir bus out
// 0 0 0 0 // 0 0 0 0
// 0 0 1 1 // 0 0 1 1
// 0 1 0 0 // 0 1 0 0
// 0 1 1 0 // 0 1 1 0
// 1 0 0 0 // 1 0 0 0
// 1 0 1 1 // 1 0 1 1
// 1 1 0 1 // 1 1 0 1
// 1 1 1 1 // 1 1 1 1
public bool ReadInput(bool bus) public bool ReadInput(bool bus)
{ {
return (Direction && Latch) || (!Direction && bus); return (Direction && Latch) || (!Direction && bus);
} }
public bool ReadOutput() public bool ReadOutput()
{ {
return (Latch || !Direction); return (Latch || !Direction);
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
@ -7,9 +8,9 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
sealed public class SerialPort sealed public class SerialPort
{ {
public Func<bool> ReadAtnOut; public Func<bool> ReadAtnOut;
public Func<bool> ReadClockOut; public Func<bool> ReadClockOut;
public Func<bool> ReadDataOut; public Func<bool> ReadDataOut;
public SerialPort() public SerialPort()
{ {
@ -19,19 +20,19 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
public bool WriteClockIn() public bool WriteClockIn()
{ {
return true; return true;
} }
public bool WriteDataIn() public bool WriteDataIn()
{ {
return true; return true;
} }
} }
} }

View File

@ -3,31 +3,33 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
sealed public partial class Sid sealed public partial class Sid
{ {
sealed class Envelope sealed class Envelope
{ {
const int stateAttack = 0; const int stateAttack = 0;
const int stateDecay = 1; const int stateDecay = 1;
const int stateRelease = 2; const int stateRelease = 2;
int attack; int attack;
int decay; int decay;
bool delay; bool delay;
int envCounter; int envCounter;
int expCounter; int expCounter;
int expPeriod; int expPeriod;
bool freeze; bool freeze;
int lfsr; int lfsr;
bool gate; bool gate;
int rate; int rate;
int release; int release;
int state; int state;
int sustain; int sustain;
static int[] adsrTable = new int[] static int[] adsrTable = new int[]
{ {
0x7F00, 0x0006, 0x003C, 0x0330, 0x7F00, 0x0006, 0x003C, 0x0330,
0x20C0, 0x6755, 0x3800, 0x500E, 0x20C0, 0x6755, 0x3800, 0x500E,
@ -35,217 +37,217 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
0x3840, 0x77E2, 0x7625, 0x0A93 0x3840, 0x77E2, 0x7625, 0x0A93
}; };
static int[] expCounterTable = new int[] static int[] expCounterTable = new int[]
{ {
0xFF, 0x5D, 0x36, 0x1A, 0x0E, 0x06, 0x00 0xFF, 0x5D, 0x36, 0x1A, 0x0E, 0x06, 0x00
}; };
static int[] expPeriodTable = new int[] static int[] expPeriodTable = new int[]
{ {
0x01, 0x02, 0x04, 0x08, 0x10, 0x1E, 0x01 0x01, 0x02, 0x04, 0x08, 0x10, 0x1E, 0x01
}; };
static int[] sustainTable = new int[] static int[] sustainTable = new int[]
{ {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
}; };
public Envelope() public Envelope()
{ {
HardReset(); HardReset();
} }
public void ExecutePhase2() public void ExecutePhase2()
{ {
{ {
if (!delay) if (!delay)
{ {
envCounter--; envCounter--;
delay = true; delay = true;
UpdateExpCounter(); UpdateExpCounter();
} }
if (lfsr != rate) if (lfsr != rate)
{ {
int feedback = ((lfsr >> 14) ^ (lfsr >> 13)) & 0x1; int feedback = ((lfsr >> 14) ^ (lfsr >> 13)) & 0x1;
lfsr = ((lfsr << 1) & 0x7FFF) | feedback; lfsr = ((lfsr << 1) & 0x7FFF) | feedback;
return; return;
} }
lfsr = 0x7FFF; lfsr = 0x7FFF;
if (state == stateAttack || ++expCounter == expPeriod) if (state == stateAttack || ++expCounter == expPeriod)
{ {
expCounter = 0; expCounter = 0;
if (freeze) if (freeze)
return; return;
switch (state) switch (state)
{ {
case stateAttack: case stateAttack:
envCounter++; envCounter++;
if (envCounter == 0xFF) if (envCounter == 0xFF)
{ {
state = stateDecay; state = stateDecay;
rate = adsrTable[decay]; rate = adsrTable[decay];
} }
break; break;
case stateDecay: case stateDecay:
if (envCounter == sustainTable[sustain]) if (envCounter == sustainTable[sustain])
{ {
return; return;
} }
if (expPeriod != 1) if (expPeriod != 1)
{ {
delay = false; delay = false;
return; return;
} }
envCounter--; envCounter--;
break; break;
case stateRelease: case stateRelease:
if (expPeriod != 1) if (expPeriod != 1)
{ {
delay = false; delay = false;
return; return;
} }
envCounter--; envCounter--;
break; break;
} }
envCounter &= 0xFF; envCounter &= 0xFF;
UpdateExpCounter(); UpdateExpCounter();
} }
} }
} }
public void HardReset() public void HardReset()
{ {
attack = 0; attack = 0;
decay = 0; decay = 0;
delay = true; delay = true;
envCounter = 0; envCounter = 0;
expCounter = 0; expCounter = 0;
expPeriod = expPeriodTable[0]; expPeriod = expPeriodTable[0];
freeze = false; freeze = false;
gate = false; gate = false;
lfsr = 0x7FFF; lfsr = 0x7FFF;
rate = adsrTable[release]; rate = adsrTable[release];
release = 0; release = 0;
state = stateRelease; state = stateRelease;
sustain = 0; sustain = 0;
} }
private void UpdateExpCounter() private void UpdateExpCounter()
{ {
{ {
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
{ {
if (envCounter == expCounterTable[i]) if (envCounter == expCounterTable[i])
expPeriod = expPeriodTable[i]; expPeriod = expPeriodTable[i];
} }
if (envCounter == 0) if (envCounter == 0)
freeze = true; freeze = true;
} }
} }
// ------------------------------------ // ------------------------------------
public int Attack public int Attack
{ {
get get
{ {
return attack; return attack;
} }
set set
{ {
attack = (value & 0xF); attack = (value & 0xF);
if (state == stateAttack) if (state == stateAttack)
rate = adsrTable[attack]; rate = adsrTable[attack];
} }
} }
public int Decay public int Decay
{ {
get get
{ {
return decay; return decay;
} }
set set
{ {
decay = (value & 0xF); decay = (value & 0xF);
if (state == stateDecay) if (state == stateDecay)
rate = adsrTable[decay]; rate = adsrTable[decay];
} }
} }
public bool Gate public bool Gate
{ {
get get
{ {
return gate; return gate;
} }
set set
{ {
bool nextGate = value; bool nextGate = value;
if (nextGate && !gate) if (nextGate && !gate)
{ {
state = stateAttack; state = stateAttack;
rate = adsrTable[attack]; rate = adsrTable[attack];
delay = true; delay = true;
freeze = false; freeze = false;
} }
else if (!nextGate && gate) else if (!nextGate && gate)
{ {
state = stateRelease; state = stateRelease;
rate = adsrTable[release]; rate = adsrTable[release];
} }
gate = nextGate; gate = nextGate;
} }
} }
public int Level public int Level
{ {
get get
{ {
return envCounter; return envCounter;
} }
} }
public int Release public int Release
{ {
get get
{ {
return release; return release;
} }
set set
{ {
release = (value & 0xF); release = (value & 0xF);
if (state == stateRelease) if (state == stateRelease)
rate = adsrTable[release]; rate = adsrTable[release];
} }
} }
public int Sustain public int Sustain
{ {
get get
{ {
return sustain; return sustain;
} }
set set
{ {
sustain = (value & 0xF); sustain = (value & 0xF);
} }
} }
// ------------------------------------ // ------------------------------------
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
// ------------------------------------ // ------------------------------------
} }
} }
} }

View File

@ -3,342 +3,344 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
sealed public partial class Sid sealed public partial class Sid
{ {
sealed class Voice sealed class Voice
{ {
int accBits; int accBits;
int accNext; int accNext;
int accumulator; int accumulator;
bool controlTestPrev; bool controlTestPrev;
int controlWavePrev; int controlWavePrev;
int delay; int delay;
int floatOutputTTL; int floatOutputTTL;
int frequency; int frequency;
bool msbRising; bool msbRising;
int noise; int noise;
int noNoise; int noNoise;
int noNoiseOrNoise; int noNoiseOrNoise;
int noPulse; int noPulse;
int output; int output;
int pulse; int pulse;
int pulseWidth; int pulseWidth;
bool ringMod; bool ringMod;
int ringMsbMask; int ringMsbMask;
int shiftRegister; int shiftRegister;
int shiftRegisterReset; int shiftRegisterReset;
bool sync; bool sync;
bool test; bool test;
int[] wave; int[] wave;
int waveform; int waveform;
int waveformIndex; int waveformIndex;
int[][] waveTable; int[][] waveTable;
public Voice(int[][] newWaveTable) public Voice(int[][] newWaveTable)
{ {
waveTable = newWaveTable; waveTable = newWaveTable;
HardReset(); HardReset();
} }
public void HardReset() public void HardReset()
{ {
accumulator = 0; accumulator = 0;
delay = 0; delay = 0;
floatOutputTTL = 0; floatOutputTTL = 0;
frequency = 0; frequency = 0;
msbRising = false; msbRising = false;
noNoise = 0xFFF; noNoise = 0xFFF;
noPulse = 0xFFF; noPulse = 0xFFF;
output = 0x000; output = 0x000;
pulse = 0xFFF; pulse = 0xFFF;
pulseWidth = 0; pulseWidth = 0;
ringMsbMask = 0; ringMsbMask = 0;
sync = false; sync = false;
test = false; test = false;
wave = waveTable[0]; wave = waveTable[0];
waveform = 0; waveform = 0;
ResetShiftReg(); ResetShiftReg();
} }
public void ExecutePhase2() public void ExecutePhase2()
{ {
{ {
if (test) if (test)
{ {
if (shiftRegisterReset != 0 && --shiftRegisterReset == 0) if (shiftRegisterReset != 0 && --shiftRegisterReset == 0)
{ {
ResetShiftReg(); ResetShiftReg();
} }
pulse = 0xFFF; pulse = 0xFFF;
} }
else else
{ {
accNext = (accumulator + frequency) & 0xFFFFFF; accNext = (accumulator + frequency) & 0xFFFFFF;
accBits = ~accumulator & accNext; accBits = ~accumulator & accNext;
accumulator = accNext; accumulator = accNext;
msbRising = ((accBits & 0x800000) != 0); msbRising = ((accBits & 0x800000) != 0);
if ((accBits & 0x080000) != 0) if ((accBits & 0x080000) != 0)
delay = 2; delay = 2;
else if (delay != 0 && --delay == 0) else if (delay != 0 && --delay == 0)
ClockShiftReg(); ClockShiftReg();
} }
} }
} }
// ------------------------------------ // ------------------------------------
private void ClockShiftReg() private void ClockShiftReg()
{ {
{ {
shiftRegister = ((shiftRegister << 1) | shiftRegister = ((shiftRegister << 1) |
(((shiftRegister >> 22) ^ (shiftRegister >> 17)) & 0x1) (((shiftRegister >> 22) ^ (shiftRegister >> 17)) & 0x1)
) & 0x7FFFFF; ) & 0x7FFFFF;
SetNoise(); SetNoise();
} }
} }
private void ResetShiftReg() private void ResetShiftReg()
{ {
{ {
shiftRegister = 0x7FFFFF; shiftRegister = 0x7FFFFF;
shiftRegisterReset = 0; shiftRegisterReset = 0;
SetNoise(); SetNoise();
} }
} }
private void SetNoise() private void SetNoise()
{ {
{ {
noise = noise =
((shiftRegister & 0x100000) >> 9) | ((shiftRegister & 0x100000) >> 9) |
((shiftRegister & 0x040000) >> 8) | ((shiftRegister & 0x040000) >> 8) |
((shiftRegister & 0x004000) >> 5) | ((shiftRegister & 0x004000) >> 5) |
((shiftRegister & 0x000800) >> 3) | ((shiftRegister & 0x000800) >> 3) |
((shiftRegister & 0x000200) >> 2) | ((shiftRegister & 0x000200) >> 2) |
((shiftRegister & 0x000020) << 1) | ((shiftRegister & 0x000020) << 1) |
((shiftRegister & 0x000004) << 3) | ((shiftRegister & 0x000004) << 3) |
((shiftRegister & 0x000001) << 4); ((shiftRegister & 0x000001) << 4);
noNoiseOrNoise = noNoise | noise; noNoiseOrNoise = noNoise | noise;
} }
} }
private void WriteShiftReg() private void WriteShiftReg()
{ {
{ {
output &= output &=
0xBB5DA | 0xBB5DA |
((output & 0x800) << 9) | ((output & 0x800) << 9) |
((output & 0x400) << 8) | ((output & 0x400) << 8) |
((output & 0x200) << 5) | ((output & 0x200) << 5) |
((output & 0x100) << 3) | ((output & 0x100) << 3) |
((output & 0x040) >> 1) | ((output & 0x040) >> 1) |
((output & 0x020) >> 3) | ((output & 0x020) >> 3) |
((output & 0x010) >> 4); ((output & 0x010) >> 4);
noise &= output; noise &= output;
noNoiseOrNoise = noNoise | noise; noNoiseOrNoise = noNoise | noise;
} }
} }
// ------------------------------------ // ------------------------------------
public int Control public int Control
{ {
set set
{ {
controlWavePrev = waveform; controlWavePrev = waveform;
controlTestPrev = test; controlTestPrev = test;
sync = ((value & 0x02) != 0); sync = ((value & 0x02) != 0);
ringMod = ((value & 0x04) != 0); ringMod = ((value & 0x04) != 0);
test = ((value & 0x08) != 0); test = ((value & 0x08) != 0);
waveform = (value >> 4) & 0x0F; waveform = (value >> 4) & 0x0F;
wave = waveTable[waveform & 0x07]; wave = waveTable[waveform & 0x07];
ringMsbMask = ((~value >> 5) & (value >> 2) & 0x1) << 23; ringMsbMask = ((~value >> 5) & (value >> 2) & 0x1) << 23;
noNoise = ((waveform & 0x8) != 0) ? 0x000 : 0xFFF; noNoise = ((waveform & 0x8) != 0) ? 0x000 : 0xFFF;
noNoiseOrNoise = noNoise | noise; noNoiseOrNoise = noNoise | noise;
noPulse = ((waveform & 0x4) != 0) ? 0x000 : 0xFFF; noPulse = ((waveform & 0x4) != 0) ? 0x000 : 0xFFF;
if (!controlTestPrev && test) if (!controlTestPrev && test)
{ {
accumulator = 0; accumulator = 0;
delay = 0; delay = 0;
shiftRegisterReset = 0x8000; shiftRegisterReset = 0x8000;
} }
else if (controlTestPrev && !test) else if (controlTestPrev && !test)
{ {
shiftRegister = ((shiftRegister << 1) | shiftRegister = ((shiftRegister << 1) |
((~shiftRegister >> 17) & 0x1) ((~shiftRegister >> 17) & 0x1)
) & 0x7FFFFF; ) & 0x7FFFFF;
SetNoise(); SetNoise();
} }
if (waveform == 0 && controlWavePrev != 0) if (waveform == 0 && controlWavePrev != 0)
floatOutputTTL = 0x28000; floatOutputTTL = 0x28000;
} }
} }
public int Frequency public int Frequency
{ {
get get
{ {
return frequency; return frequency;
} }
set set
{ {
frequency = value; frequency = value;
} }
} }
public int FrequencyLo public int FrequencyLo
{ {
get get
{ {
return (frequency & 0xFF); return (frequency & 0xFF);
} }
set set
{ {
frequency &= 0xFF00; frequency &= 0xFF00;
frequency |= value & 0x00FF; frequency |= value & 0x00FF;
} }
} }
public int FrequencyHi public int FrequencyHi
{ {
get get
{ {
return (frequency >> 8); return (frequency >> 8);
} }
set set
{ {
frequency &= 0x00FF; frequency &= 0x00FF;
frequency |= (value & 0x00FF) << 8; frequency |= (value & 0x00FF) << 8;
} }
} }
public int Oscillator public int Oscillator
{ {
get get
{ {
return output; return output;
} }
} }
public int Output(Voice ringModSource) public int Output(Voice ringModSource)
{ {
{ {
if (waveform != 0) if (waveform != 0)
{ {
waveformIndex = (accumulator ^ (ringModSource.accumulator & ringMsbMask)) >> 12; waveformIndex = (accumulator ^ (ringModSource.accumulator & ringMsbMask)) >> 12;
output = wave[waveformIndex] & (noPulse | pulse) & noNoiseOrNoise; output = wave[waveformIndex] & (noPulse | pulse) & noNoiseOrNoise;
if (waveform > 8) if (waveform > 8)
WriteShiftReg(); WriteShiftReg();
} }
else else
{ {
if (floatOutputTTL != 0 && --floatOutputTTL == 0) if (floatOutputTTL != 0 && --floatOutputTTL == 0)
output = 0x000; output = 0x000;
} }
pulse = ((accumulator >> 12) >= pulseWidth) ? 0xFFF : 0x000; pulse = ((accumulator >> 12) >= pulseWidth) ? 0xFFF : 0x000;
return output; return output;
} }
} }
public int PulseWidth public int PulseWidth
{ {
get get
{ {
return pulseWidth; return pulseWidth;
} }
set set
{ {
pulseWidth = value; pulseWidth = value;
} }
} }
public int PulseWidthLo public int PulseWidthLo
{ {
get get
{ {
return (pulseWidth & 0xFF); return (pulseWidth & 0xFF);
} }
set set
{ {
pulseWidth &= 0x0F00; pulseWidth &= 0x0F00;
pulseWidth |= value & 0x00FF; pulseWidth |= value & 0x00FF;
} }
} }
public int PulseWidthHi public int PulseWidthHi
{ {
get get
{ {
return (pulseWidth >> 8); return (pulseWidth >> 8);
} }
set set
{ {
pulseWidth &= 0x00FF; pulseWidth &= 0x00FF;
pulseWidth |= (value & 0x000F) << 8; pulseWidth |= (value & 0x000F) << 8;
} }
} }
public bool RingMod public bool RingMod
{ {
get get
{ {
return ringMod; return ringMod;
} }
} }
public bool Sync public bool Sync
{ {
get get
{ {
return sync; return sync;
} }
} }
public void Synchronize(Voice target, Voice source) public void Synchronize(Voice target, Voice source)
{ {
if (msbRising && target.sync && !(sync && source.msbRising)) if (msbRising && target.sync && !(sync && source.msbRising))
target.accumulator = 0; target.accumulator = 0;
} }
public bool Test public bool Test
{ {
get get
{ {
return test; return test;
} }
} }
public int Waveform public int Waveform
{ {
get get
{ {
return waveform; return waveform;
} }
} }
// ------------------------------------ // ------------------------------------
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
if (ser.IsReader) if (ser.IsReader)
wave = waveTable[waveform]; wave = waveTable[waveform];
} }
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
#pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete #pragma warning disable 649 //adelikat: Disable dumb warnings until this file is complete
#pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete #pragma warning disable 169 //adelikat: Disable dumb warnings until this file is complete

View File

@ -1,72 +1,73 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
public class UserPort public class UserPort
{ {
public Func<bool> ReadCounter1; public Func<bool> ReadCounter1;
public Func<bool> ReadCounter2; public Func<bool> ReadCounter2;
public Func<bool> ReadHandshake; public Func<bool> ReadHandshake;
public Func<bool> ReadSerial1; public Func<bool> ReadSerial1;
public Func<bool> ReadSerial2; public Func<bool> ReadSerial2;
public UserPort() public UserPort()
{ {
} }
virtual public void HardReset() virtual public void HardReset()
{ {
// note: this will not disconnect any attached media // note: this will not disconnect any attached media
} }
virtual public bool ReadAtn() virtual public bool ReadAtn()
{ {
return true; return true;
} }
virtual public bool ReadCounter1Buffer() virtual public bool ReadCounter1Buffer()
{ {
return true; return true;
} }
virtual public bool ReadCounter2Buffer() virtual public bool ReadCounter2Buffer()
{ {
return true; return true;
} }
virtual public byte ReadData() virtual public byte ReadData()
{ {
return 0xFF; return 0xFF;
} }
virtual public bool ReadFlag2() virtual public bool ReadFlag2()
{ {
return true; return true;
} }
virtual public bool ReadPA2() virtual public bool ReadPA2()
{ {
return true; return true;
} }
virtual public bool ReadReset() virtual public bool ReadReset()
{ {
return true; return true;
} }
virtual public bool ReadSerial1Buffer() virtual public bool ReadSerial1Buffer()
{ {
return true; return true;
} }
virtual public bool ReadSerial2Buffer() virtual public bool ReadSerial2Buffer()
{ {
return true; return true;
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
} }
} }

View File

@ -3,61 +3,63 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
sealed public partial class Vic sealed public partial class Vic
{ {
sealed class SpriteGenerator sealed class SpriteGenerator
{ {
public bool collideData; public bool collideData;
public bool collideSprite; public bool collideSprite;
public int color; public int color;
public bool display; public bool display;
public bool dma; public bool dma;
public bool enable; public bool enable;
public int mc; public int mc;
public int mcbase; public int mcbase;
public bool multicolor; public bool multicolor;
public bool multicolorCrunch; public bool multicolorCrunch;
public int pointer; public int pointer;
public bool priority; public bool priority;
public bool shiftEnable; public bool shiftEnable;
public int sr; public int sr;
public int x; public int x;
public bool xCrunch; public bool xCrunch;
public bool xExpand; public bool xExpand;
public int y; public int y;
public bool yCrunch; public bool yCrunch;
public bool yExpand; public bool yExpand;
public void HardReset() public void HardReset()
{ {
collideData = false; collideData = false;
collideSprite = false; collideSprite = false;
color = 0; color = 0;
display = false; display = false;
dma = false; dma = false;
enable = false; enable = false;
mc = 0; mc = 0;
mcbase = 0; mcbase = 0;
multicolor = false; multicolor = false;
multicolorCrunch = false; multicolorCrunch = false;
pointer = 0; pointer = 0;
priority = false; priority = false;
shiftEnable = false; shiftEnable = false;
sr = 0; sr = 0;
x = 0; x = 0;
xCrunch = false; xCrunch = false;
xExpand = false; xExpand = false;
y = 0; y = 0;
yCrunch = false; yCrunch = false;
yExpand = false; yExpand = false;
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
} }
} }
} }
} }

View File

@ -4,184 +4,186 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
sealed public partial class Vic sealed public partial class Vic
{ {
int backgroundColor0; int backgroundColor0;
int backgroundColor1; int backgroundColor1;
int backgroundColor2; int backgroundColor2;
int backgroundColor3; int backgroundColor3;
int baCount; int baCount;
bool badline; bool badline;
bool badlineEnable; bool badlineEnable;
int bitmapColumn; int bitmapColumn;
bool bitmapMode; bool bitmapMode;
int borderB; int borderB;
bool borderCheckLEnable; bool borderCheckLEnable;
bool borderCheckREnable; bool borderCheckREnable;
int borderColor; int borderColor;
int borderL; int borderL;
bool borderOnMain; bool borderOnMain;
bool borderOnVertical; bool borderOnVertical;
int borderR; int borderR;
int borderT; int borderT;
int[] bufferC; int[] bufferC;
int[] bufferG; int[] bufferG;
int cycle; int cycle;
int cycleIndex; int cycleIndex;
bool columnSelect; bool columnSelect;
int dataC; int dataC;
int dataG; int dataG;
bool displayEnable; bool displayEnable;
int displayC; int displayC;
bool enableIntLightPen; bool enableIntLightPen;
bool enableIntRaster; bool enableIntRaster;
bool enableIntSpriteCollision; bool enableIntSpriteCollision;
bool enableIntSpriteDataCollision; bool enableIntSpriteDataCollision;
bool extraColorMode; bool extraColorMode;
bool hblank; bool hblank;
bool idle; bool idle;
bool intLightPen; bool intLightPen;
bool intRaster; bool intRaster;
bool intSpriteCollision; bool intSpriteCollision;
bool intSpriteDataCollision; bool intSpriteDataCollision;
int hblankEnd; int hblankEnd;
int hblankStart; int hblankStart;
bool hblankCheckEnableL; bool hblankCheckEnableL;
bool hblankCheckEnableR; bool hblankCheckEnableR;
int lastRasterLine; int lastRasterLine;
int lightPenX; int lightPenX;
int lightPenY; int lightPenY;
bool multicolorMode; bool multicolorMode;
bool pinAEC = true; bool pinAEC = true;
bool pinBA = true; bool pinBA = true;
bool pinIRQ = true; bool pinIRQ = true;
int pointerCB; int pointerCB;
int pointerVM; int pointerVM;
int rasterInterruptLine; int rasterInterruptLine;
int rasterLine; int rasterLine;
int rasterX; int rasterX;
bool rasterXHold; bool rasterXHold;
int rc; int rc;
int refreshCounter; int refreshCounter;
bool renderEnabled; bool renderEnabled;
bool rowSelect; bool rowSelect;
int spriteMulticolor0; int spriteMulticolor0;
int spriteMulticolor1; int spriteMulticolor1;
SpriteGenerator[] sprites; SpriteGenerator[] sprites;
int sr; int sr;
int srMask; int srMask;
int srMask1; int srMask1;
int srMask2; int srMask2;
int srMask3; int srMask3;
int srMaskMC; int srMaskMC;
int srSpriteMask; int srSpriteMask;
int srSpriteMask1; int srSpriteMask1;
int srSpriteMask2; int srSpriteMask2;
int srSpriteMask3; int srSpriteMask3;
int srSpriteMaskMC; int srSpriteMaskMC;
bool vblank; bool vblank;
int vblankEnd; int vblankEnd;
int vblankStart; int vblankStart;
int vc; int vc;
int vcbase; int vcbase;
int vmli; int vmli;
int xScroll; int xScroll;
int yScroll; int yScroll;
public void HardReset() public void HardReset()
{ {
// *** SHIFT REGISTER BITMASKS *** // *** SHIFT REGISTER BITMASKS ***
srMask1 = 0x20000; srMask1 = 0x20000;
srMask2 = srMask1 << 1; srMask2 = srMask1 << 1;
srMask3 = srMask1 | srMask2; srMask3 = srMask1 | srMask2;
srMask = srMask2; srMask = srMask2;
srMaskMC = srMask3; srMaskMC = srMask3;
srSpriteMask1 = 0x400000; srSpriteMask1 = 0x400000;
srSpriteMask2 = srSpriteMask1 << 1; srSpriteMask2 = srSpriteMask1 << 1;
srSpriteMask3 = srSpriteMask1 | srSpriteMask2; srSpriteMask3 = srSpriteMask1 | srSpriteMask2;
srSpriteMask = srSpriteMask2; srSpriteMask = srSpriteMask2;
srSpriteMaskMC = srSpriteMask3; srSpriteMaskMC = srSpriteMask3;
pinAEC = true; pinAEC = true;
pinBA = true; pinBA = true;
pinIRQ = true; pinIRQ = true;
bufOffset = 0; bufOffset = 0;
backgroundColor0 = 0; backgroundColor0 = 0;
backgroundColor1 = 0; backgroundColor1 = 0;
backgroundColor2 = 0; backgroundColor2 = 0;
backgroundColor3 = 0; backgroundColor3 = 0;
baCount = baResetCounter; baCount = baResetCounter;
badline = false; badline = false;
badlineEnable = false; badlineEnable = false;
bitmapMode = false; bitmapMode = false;
borderCheckLEnable = false; borderCheckLEnable = false;
borderCheckREnable = false; borderCheckREnable = false;
borderColor = 0; borderColor = 0;
borderOnMain = true; borderOnMain = true;
borderOnVertical = true; borderOnVertical = true;
columnSelect = false; columnSelect = false;
displayEnable = false; displayEnable = false;
enableIntLightPen = false; enableIntLightPen = false;
enableIntRaster = false; enableIntRaster = false;
enableIntSpriteCollision = false; enableIntSpriteCollision = false;
enableIntSpriteDataCollision = false; enableIntSpriteDataCollision = false;
extraColorMode = false; extraColorMode = false;
hblank = true; hblank = true;
idle = true; idle = true;
intLightPen = false; intLightPen = false;
intRaster = false; intRaster = false;
intSpriteCollision = false; intSpriteCollision = false;
intSpriteDataCollision = false; intSpriteDataCollision = false;
lastRasterLine = 0; lastRasterLine = 0;
lightPenX = 0; lightPenX = 0;
lightPenY = 0; lightPenY = 0;
multicolorMode = false; multicolorMode = false;
pointerCB = 0; pointerCB = 0;
pointerVM = 0; pointerVM = 0;
rasterInterruptLine = 0; rasterInterruptLine = 0;
rasterLine = 0; rasterLine = 0;
rasterX = 0; rasterX = 0;
rc = 7; rc = 7;
refreshCounter = 0xFF; refreshCounter = 0xFF;
rowSelect = false; rowSelect = false;
spriteMulticolor0 = 0; spriteMulticolor0 = 0;
spriteMulticolor1 = 0; spriteMulticolor1 = 0;
sr = 0; sr = 0;
vblank = true; vblank = true;
vc = 0; vc = 0;
vcbase = 0; vcbase = 0;
vmli = 0; vmli = 0;
xScroll = 0; xScroll = 0;
yScroll = 0; yScroll = 0;
// reset sprites // reset sprites
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
sprites[i].HardReset(); sprites[i].HardReset();
// clear C buffer // clear C buffer
for (int i = 0; i < 40; i++) for (int i = 0; i < 40; i++)
{ {
bufferC[i] = 0; bufferC[i] = 0;
bufferG[i] = 0; bufferG[i] = 0;
} }
pixBuffer = new int[pixBufferSize]; pixBuffer = new int[pixBufferSize];
UpdateBorder(); UpdateBorder();
} }
public void SyncState(Serializer ser) public void SyncState(Serializer ser)
{ {
SaveState.SyncObject(ser, this); SaveState.SyncObject(ser, this);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
ser.BeginSection("sprite" + i.ToString()); ser.BeginSection("sprite" + i.ToString());
SaveState.SyncObject(ser, sprites[i]); SaveState.SyncObject(ser, sprites[i]);
ser.EndSection(); ser.EndSection();
} }
} }
} }
} }

View File

@ -1,17 +1,18 @@
using System.Drawing; using System.Drawing;
using BizHawk.Common;
namespace BizHawk.Emulation.Computers.Commodore64.MOS namespace BizHawk.Emulation.Computers.Commodore64.MOS
{ {
sealed public partial class Vic : IVideoProvider sealed public partial class Vic : IVideoProvider
{ {
int[] buf; int[] buf;
int bufHeight; int bufHeight;
int bufLength; int bufLength;
int bufOffset; int bufOffset;
int bufWidth; int bufWidth;
int pixBufferSize = 12; int pixBufferSize = 12;
int[] pixBuffer; int[] pixBuffer;
int pixBufferIndex; int pixBufferIndex;
// palette // palette
int[] palette = int[] palette =
@ -56,7 +57,7 @@ namespace BizHawk.Emulation.Computers.Commodore64.MOS
public int VirtualWidth public int VirtualWidth
{ {
get { return bufWidth; } get { return bufWidth; }
} }
} }
} }

View File

@ -1,7 +1,9 @@
using System; using System;
using BizHawk.Emulation.CPUs.M6502; using BizHawk.Emulation.CPUs.M6502;
using BizHawk.Emulation.Consoles.Atari; using BizHawk.Emulation.Consoles.Atari;
using BizHawk.Emulation.Consoles.Atari._2600; using BizHawk.Emulation.Consoles.Atari._2600;
using BizHawk.Common;
namespace BizHawk namespace BizHawk
{ {

View File

@ -2,6 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using BizHawk.Common;
namespace BizHawk namespace BizHawk
{ {
public partial class Atari2600 : IEmulator public partial class Atari2600 : IEmulator

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari
{ {
// Emulates the M6532 RIOT Chip // Emulates the M6532 RIOT Chip
public class M6532 public class M6532

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
3E (Boulderdash 3E (Boulderdash

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
3F (Tigervision) 3F (Tigervision)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
4A50 (no name) 4A50 (no name)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
This was used by Commavid. It allowed for both ROM and RAM on the cartridge, This was used by Commavid. It allowed for both ROM and RAM on the cartridge,

View File

@ -1,4 +1,6 @@
namespace BizHawk using BizHawk.Common;
namespace BizHawk
{ {
partial class Atari2600 partial class Atari2600
{ {

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
E0 (Parker Bros) E0 (Parker Bros)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
E7 (M-Network) E7 (M-Network)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
EF (no name?) EF (no name?)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
F0 (Megaboy) F0 (Megaboy)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
F4 (Atari style 32K) F4 (Atari style 32K)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
F6 (Atari style 16K) F6 (Atari style 16K)

View File

@ -1,4 +1,6 @@
namespace BizHawk using BizHawk.Common;
namespace BizHawk
{ {
partial class Atari2600 partial class Atari2600
{ {

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
FA (RAM Plus) FA (RAM Plus)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
UA (UA Ltd) UA (UA Ltd)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Atari._2600 using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari._2600
{ {
/* /*
X07 (Atariage) X07 (Atariage)

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Atari namespace BizHawk.Emulation.Consoles.Atari
{ {
// Emulates the TIA // Emulates the TIA

View File

@ -1,6 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using BizHawk.Common;
using EMU7800.Core; using EMU7800.Core;
namespace BizHawk.Emulation namespace BizHawk.Emulation

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
using BizHawk.Emulation.Sound; using BizHawk.Emulation.Sound;
//http://wiki.nesdev.com/w/index.php/APU_Mixer_Emulation //http://wiki.nesdev.com/w/index.php/APU_Mixer_Emulation

View File

@ -3,6 +3,8 @@ using System.Xml;
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Common;
//TODO - consider bytebuffer for mirroring //TODO - consider bytebuffer for mirroring
//TODO - could stringpool the bootgod DB for a pedantic optimization //TODO - could stringpool the bootgod DB for a pedantic optimization

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//AKA half of mapper 034 (the other half is BxROM which is entirely different..) //AKA half of mapper 034 (the other half is BxROM which is entirely different..)
public sealed class AVE_NINA_001 : NES.NESBoardBase public sealed class AVE_NINA_001 : NES.NESBoardBase

View File

@ -1,3 +1,5 @@
using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//generally mapper7 //generally mapper7

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
public sealed class BANDAI_74_161_02_74 : NES.NESBoardBase public sealed class BANDAI_74_161_02_74 : NES.NESBoardBase
{ {

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
public sealed class BANDAI_74_161_161_32 : NES.NESBoardBase public sealed class BANDAI_74_161_161_32 : NES.NESBoardBase
{ {

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//AKA half of mapper 034 (the other half is AVE_NINA_001 which is entirely different..) //AKA half of mapper 034 (the other half is AVE_NINA_001 which is entirely different..)
public sealed class BxROM : NES.NESBoardBase public sealed class BxROM : NES.NESBoardBase

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {

View File

@ -1,6 +1,7 @@
using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {
public sealed class CPROM : NES.NESBoardBase public sealed class CPROM : NES.NESBoardBase
{ {
//generally mapper 13 //generally mapper 13
@ -61,7 +62,5 @@ namespace BizHawk.Emulation.Consoles.Nintendo
base.SyncState(ser); base.SyncState(ser);
ser.Sync("chr",ref chr); ser.Sync("chr",ref chr);
} }
} }
} }

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
//simplifications/approximations: //simplifications/approximations:
//* "Note that no commercial games rely on this mirroring -- therefore you can take the easy way out and simply give all MMC5 games 64k PRG-RAM." //* "Note that no commercial games rely on this mirroring -- therefore you can take the easy way out and simply give all MMC5 games 64k PRG-RAM."
@ -12,7 +13,6 @@
//TODO - tweak nametable / chr viewer to be more useful //TODO - tweak nametable / chr viewer to be more useful
//FUTURE - we may need to split this into a separate MMC5 class. but for now it is just a pain. //FUTURE - we may need to split this into a separate MMC5 class. but for now it is just a pain.
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {
[NES.INESBoardImplPriority] [NES.INESBoardImplPriority]

View File

@ -1,4 +1,5 @@
using System; using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {

View File

@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo namespace BizHawk.Emulation.Consoles.Nintendo
{ {

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//Mapper 77 //Mapper 77
//Napoleon Senki //Napoleon Senki

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//iNES Mapper 97 //iNES Mapper 97
//Kaiketsu Yanchamaru (Kid Niki 1) //Kaiketsu Yanchamaru (Kid Niki 1)

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//AKA mapper 032 //AKA mapper 032

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//AKA mapper 65 //AKA mapper 65

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//Mapper 86 //Mapper 86

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//iNES Mapper 72 //iNES Mapper 72
//Example Games: //Example Games:

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
public sealed class JALECO_SS8806 : NES.NESBoardBase public sealed class JALECO_SS8806 : NES.NESBoardBase
{ {

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
/* /*
* Life Span: October 1986 - April 1987 * Life Span: October 1986 - April 1987

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
public sealed class Mapper012 : MMC3Board_Base public sealed class Mapper012 : MMC3Board_Base
{ {

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
// mmc3 multi, PAL, "Super Mario Bros. / Tetris / Nintendo World Cup" // mmc3 multi, PAL, "Super Mario Bros. / Tetris / Nintendo World Cup"
public sealed class Mapper037 : MMC3Board_Base public sealed class Mapper037 : MMC3Board_Base

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
//http://wiki.nesdev.com/w/index.php/INES_Mapper_044 //http://wiki.nesdev.com/w/index.php/INES_Mapper_044
public class Mapper044 : MMC3Board_Base public class Mapper044 : MMC3Board_Base

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
// Fire Emblem (Ch) // Fire Emblem (Ch)
// mmc3 with mmc2-style chr swapping // mmc3 with mmc2-style chr swapping

View File

@ -1,4 +1,6 @@
namespace BizHawk.Emulation.Consoles.Nintendo using BizHawk.Common;
namespace BizHawk.Emulation.Consoles.Nintendo
{ {
public sealed class Mapper189 : MMC3Board_Base public sealed class Mapper189 : MMC3Board_Base
{ {

Some files were not shown because too many files have changed in this diff Show More