diff --git a/BizHawk.Client.Common/BizHawk.Client.Common.csproj b/BizHawk.Client.Common/BizHawk.Client.Common.csproj index 0cfa24639a..5619cb5705 100644 --- a/BizHawk.Client.Common/BizHawk.Client.Common.csproj +++ b/BizHawk.Client.Common/BizHawk.Client.Common.csproj @@ -147,6 +147,10 @@ {866F8D13-0678-4FF9-80A4-A3993FD4D8A3} BizHawk.Common + + {e1a23168-b571-411c-b360-2229e7225e0e} + BizHawk.Emulation.Common + {f51946ea-827f-4d82-b841-1f2f6d060312} BizHawk.Emulation.DiscSystem diff --git a/BizHawk.Client.Common/FirmwareManager.cs b/BizHawk.Client.Common/FirmwareManager.cs index b173cdddb9..afc207b639 100644 --- a/BizHawk.Client.Common/FirmwareManager.cs +++ b/BizHawk.Client.Common/FirmwareManager.cs @@ -3,6 +3,7 @@ using System.IO; using System.Collections.Generic; using BizHawk.Common; +using BizHawk.Emulation.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) //this would be adviseable if we end up with a very large firmware file diff --git a/BizHawk.Client.Common/Global.cs b/BizHawk.Client.Common/Global.cs index ea702843c1..779f609537 100644 --- a/BizHawk.Client.Common/Global.cs +++ b/BizHawk.Client.Common/Global.cs @@ -1,4 +1,5 @@ -using BizHawk.Emulation.DiscSystem; +using BizHawk.Emulation.Common; +using BizHawk.Emulation.DiscSystem; namespace BizHawk.Client.Common { diff --git a/BizHawk.Client.Common/PathManager.cs b/BizHawk.Client.Common/PathManager.cs index 2aa63a6b66..9de45d23a7 100644 --- a/BizHawk.Client.Common/PathManager.cs +++ b/BizHawk.Client.Common/PathManager.cs @@ -3,6 +3,8 @@ using System.Linq; using System.IO; using System.Reflection; +using BizHawk.Emulation.Common; + namespace BizHawk.Client.Common { public static class PathManager diff --git a/BizHawk.Client.Common/RomGame.cs b/BizHawk.Client.Common/RomGame.cs index 6d745de961..99458054f0 100644 --- a/BizHawk.Client.Common/RomGame.cs +++ b/BizHawk.Client.Common/RomGame.cs @@ -2,6 +2,7 @@ using System.Globalization; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { diff --git a/BizHawk.Client.Common/XmlGame.cs b/BizHawk.Client.Common/XmlGame.cs index 3305856bac..49f451ec2a 100644 --- a/BizHawk.Client.Common/XmlGame.cs +++ b/BizHawk.Client.Common/XmlGame.cs @@ -4,6 +4,7 @@ using System.IO; using System.Xml; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Client.Common { diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 281941da08..7431a8dcb6 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -4,6 +4,8 @@ using System.Drawing; using System.Collections.Generic; using System.Collections; +using BizHawk.Emulation.Common; + namespace BizHawk.Client.Common { public class Config diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index d69c96ddd0..7ab8a0f804 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -1006,6 +1006,10 @@ {866F8D13-0678-4FF9-80A4-A3993FD4D8A3} BizHawk.Common + + {e1a23168-b571-411c-b360-2229e7225e0e} + BizHawk.Emulation.Common + {f51946ea-827f-4d82-b841-1f2f6d060312} BizHawk.Emulation.DiscSystem diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 74afbead9c..ac416f43eb 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -11,6 +11,7 @@ using System.Windows.Forms; using BizHawk.Common; using BizHawk.Client.Common; using BizHawk.Emulation; +using BizHawk.Emulation.Common; using BizHawk.Emulation.Computers.Commodore64; using BizHawk.Emulation.Consoles.Calculator; using BizHawk.Emulation.Consoles.Coleco; diff --git a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs index 001ebf4100..ff57a97fae 100644 --- a/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs +++ b/BizHawk.Client.EmuHawk/config/FirmwaresConfig.cs @@ -10,6 +10,7 @@ using System.Text; using System.Windows.Forms; using BizHawk.Client.Common; +using BizHawk.Emulation.Common; //notes: eventually, we intend to have a "firmware acquisition interface" exposed to the emulator cores. //it will be implemented by the multiclient, and use firmware keys to fetch the firmware content. diff --git a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj new file mode 100644 index 0000000000..dc6728254c --- /dev/null +++ b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {E1A23168-B571-411C-B360-2229E7225E0E} + Library + Properties + BizHawk.Emulation.Common + BizHawk.Emulation.Common + v4.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + {866f8d13-0678-4ff9-80a4-a3993fd4d8a3} + BizHawk.Common + + + + + \ No newline at end of file diff --git a/BizHawk.Emulation/Database/CRC32.cs b/BizHawk.Emulation.Common/Database/CRC32.cs similarity index 91% rename from BizHawk.Emulation/Database/CRC32.cs rename to BizHawk.Emulation.Common/Database/CRC32.cs index b2af5ff423..128b1d86e7 100644 --- a/BizHawk.Emulation/Database/CRC32.cs +++ b/BizHawk.Emulation.Common/Database/CRC32.cs @@ -1,7 +1,7 @@ //we could get a little list of crcs from here and make it clear which crc this class was for, and expose others //http://www.ross.net/crc/download/crc_v3.txt -namespace BizHawk +namespace BizHawk.Emulation.Common { public static class CRC32 { diff --git a/BizHawk.Emulation/Database/Database.cs b/BizHawk.Emulation.Common/Database/Database.cs similarity index 95% rename from BizHawk.Emulation/Database/Database.cs rename to BizHawk.Emulation.Common/Database/Database.cs index fbbd9d6b71..838111529b 100644 --- a/BizHawk.Emulation/Database/Database.cs +++ b/BizHawk.Emulation.Common/Database/Database.cs @@ -5,9 +5,9 @@ using System.Threading; using BizHawk.Common; -namespace BizHawk +namespace BizHawk.Emulation.Common { - internal class CompactGameInfo + public class CompactGameInfo { public string Name; public string System; diff --git a/BizHawk.Emulation/Database/FirmwareDatabase.cs b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs similarity index 97% rename from BizHawk.Emulation/Database/FirmwareDatabase.cs rename to BizHawk.Emulation.Common/Database/FirmwareDatabase.cs index d50f79024f..375347fa92 100644 --- a/BizHawk.Emulation/Database/FirmwareDatabase.cs +++ b/BizHawk.Emulation.Common/Database/FirmwareDatabase.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Collections.Generic; -namespace BizHawk +namespace BizHawk.Emulation.Common { public static class FirmwareDatabase { diff --git a/BizHawk.Emulation/Database/GameInfo.cs b/BizHawk.Emulation.Common/Database/GameInfo.cs similarity index 94% rename from BizHawk.Emulation/Database/GameInfo.cs rename to BizHawk.Emulation.Common/Database/GameInfo.cs index a8bea0045b..25dab9da51 100644 --- a/BizHawk.Emulation/Database/GameInfo.cs +++ b/BizHawk.Emulation.Common/Database/GameInfo.cs @@ -4,7 +4,7 @@ using System.Globalization; using BizHawk.Common; -namespace BizHawk +namespace BizHawk.Emulation.Common { public enum RomStatus { diff --git a/BizHawk.Emulation.Common/Properties/AssemblyInfo.cs b/BizHawk.Emulation.Common/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..426319886a --- /dev/null +++ b/BizHawk.Emulation.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("BizHawk.Emulation.Common")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("BizHawk.Emulation.Common")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b4ade60b-b857-4604-860b-fa0d27f99171")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/BizHawk.Emulation/BizHawk.Emulation.csproj b/BizHawk.Emulation/BizHawk.Emulation.csproj index 0a19461cc0..8fbe69447a 100644 --- a/BizHawk.Emulation/BizHawk.Emulation.csproj +++ b/BizHawk.Emulation/BizHawk.Emulation.csproj @@ -452,10 +452,6 @@ - - - - @@ -542,6 +538,10 @@ {866F8D13-0678-4FF9-80A4-A3993FD4D8A3} BizHawk.Common + + {e1a23168-b571-411c-b360-2229e7225e0e} + BizHawk.Emulation.Common + {f51946ea-827f-4d82-b841-1f2f6d060312} BizHawk.Emulation.DiscSystem diff --git a/BizHawk.Emulation/Computers/Commodore64/C64.cs b/BizHawk.Emulation/Computers/Commodore64/C64.cs index c7c775e350..96f6a13e36 100644 --- a/BizHawk.Emulation/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation/Computers/Commodore64/C64.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Computers.Commodore64 { @@ -11,8 +12,8 @@ namespace BizHawk.Emulation.Computers.Commodore64 private bool _islag = true; private int _lagcount = 0; private int _frame = 0; - private int cyclesPerFrame; - private InputFileInfo inputFileInfo; + private int cyclesPerFrame; + private InputFileInfo inputFileInfo; // bizhawk I/O public CoreComm CoreComm { get; private set; } diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs index f0590f753c..c76b384735 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk { diff --git a/BizHawk.Emulation/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation/Consoles/Atari/7800/Atari7800.cs index 5287df40dd..9d38d02c31 100644 --- a/BizHawk.Emulation/Consoles/Atari/7800/Atari7800.cs +++ b/BizHawk.Emulation/Consoles/Atari/7800/Atari7800.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using BizHawk.Common; +using BizHawk.Emulation.Common; using EMU7800.Core; namespace BizHawk.Emulation diff --git a/BizHawk.Emulation/Consoles/Calculator/TI83.cs b/BizHawk.Emulation/Consoles/Calculator/TI83.cs index 5d406f9e2d..360ed03309 100644 --- a/BizHawk.Emulation/Consoles/Calculator/TI83.cs +++ b/BizHawk.Emulation/Consoles/Calculator/TI83.cs @@ -4,6 +4,7 @@ using System.IO; using System.Collections.Generic; using BizHawk.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.CPUs.Z80; //http://www.ticalc.org/pub/text/calcinfo/ diff --git a/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs index 930c7aacc1..d074bb6ecd 100644 --- a/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation/Consoles/Coleco/ColecoVision.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using BizHawk.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.CPUs.Z80; using BizHawk.Emulation.Sound; diff --git a/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs index 82d117aa30..ef35e44c19 100644 --- a/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs @@ -1,6 +1,8 @@ using System; using System.IO; using System.Collections.Generic; + +using BizHawk.Emulation.Common; using BizHawk.Emulation.CPUs.CP1610; namespace BizHawk.Emulation.Consoles.Intellivision diff --git a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs index e29797fff6..a64212b26a 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Consoles.GB { diff --git a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/GambatteLink.cs index e7fa68826b..6e42142ab8 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Consoles.GB { diff --git a/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs index b5831414d9..0966879637 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/N64/N64.cs @@ -5,6 +5,7 @@ using System.Runtime.InteropServices; using System.Threading; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Consoles.Nintendo.N64 { diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs index 1f921c9334..f0fd509fda 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs @@ -4,6 +4,7 @@ using System.IO; using System.Collections.Generic; using BizHawk.Common; +using BizHawk.Emulation.Common; //TODO - consider bytebuffer for mirroring //TODO - could stringpool the bootgod DB for a pedantic optimization @@ -404,7 +405,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo public class CartInfo { public NESGameInfo game; - public BizHawk.GameInfo DB_GameInfo; + public GameInfo DB_GameInfo; public short chr_size; public short prg_size; diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index 3b1b3db0bc..3367ce3e32 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -4,6 +4,7 @@ using System.IO; using System.Collections.Generic; using BizHawk.Common; +using BizHawk.Emulation.Common; //TODO - redo all timekeeping in terms of master clock namespace BizHawk.Emulation.Consoles.Nintendo diff --git a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs index a3ab0f1322..e4dde62e70 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using System.Runtime.InteropServices; using BizHawk.Common; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Consoles.Nintendo.SNES { diff --git a/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs index 44d1b4ef1d..425c0ba656 100644 --- a/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using BizHawk.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.CPUs.H6280; using BizHawk.Emulation.DiscSystem; using BizHawk.Emulation.Sound; diff --git a/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/EEPROM.cs b/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/EEPROM.cs index 80d04bba77..50223955c5 100644 --- a/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/EEPROM.cs +++ b/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/EEPROM.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +using BizHawk.Emulation.Common; + namespace BizHawk.Emulation.Consoles.Sega { partial class Genesis diff --git a/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/SaveRAM.cs b/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/SaveRAM.cs index da84efd0b7..da1437b498 100644 --- a/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/SaveRAM.cs +++ b/BizHawk.Emulation/Consoles/Sega/Genesis/Cart/SaveRAM.cs @@ -1,49 +1,50 @@ using System; +using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Consoles.Sega { - partial class Genesis - { - bool SaveRamEnabled; - bool SaveRamEveryOtherByte; - int SaveRamStartOffset; - int SaveRamEndOffset; - int SaveRamLength; + partial class Genesis + { + bool SaveRamEnabled; + bool SaveRamEveryOtherByte; + int SaveRamStartOffset; + int SaveRamEndOffset; + int SaveRamLength; - byte[] SaveRAM = new byte[0]; + byte[] SaveRAM = new byte[0]; - void InitializeSaveRam(GameInfo game) - { - if (EepromEnabled) - return; + void InitializeSaveRam(GameInfo game) + { + if (EepromEnabled) + return; - if (game["DisableSaveRam"] || RH_SRamPresent == false) - return; + if (game["DisableSaveRam"] || RH_SRamPresent == false) + return; - SaveRamEnabled = true; - SaveRamEveryOtherByte = RH_SRamCode != 0; - SaveRamStartOffset = RH_SRamStart; - SaveRamEndOffset = RH_SRamEnd; + SaveRamEnabled = true; + SaveRamEveryOtherByte = RH_SRamCode != 0; + SaveRamStartOffset = RH_SRamStart; + SaveRamEndOffset = RH_SRamEnd; - if (game["SaveRamStartOffset"]) - SaveRamStartOffset = game.GetHexValue("SaveRamStartOffset"); - if (game["SaveRamEndOffset"]) - SaveRamEndOffset = game.GetHexValue("SaveRamEndOffset"); + if (game["SaveRamStartOffset"]) + SaveRamStartOffset = game.GetHexValue("SaveRamStartOffset"); + if (game["SaveRamEndOffset"]) + SaveRamEndOffset = game.GetHexValue("SaveRamEndOffset"); - SaveRamLength = (SaveRamEndOffset - SaveRamStartOffset) + 1; + SaveRamLength = (SaveRamEndOffset - SaveRamStartOffset) + 1; - if (SaveRamEveryOtherByte) - SaveRamLength = ((SaveRamEndOffset - SaveRamStartOffset) / 2) + 1; + if (SaveRamEveryOtherByte) + SaveRamLength = ((SaveRamEndOffset - SaveRamStartOffset) / 2) + 1; - SaveRAM = new byte[SaveRamLength]; + SaveRAM = new byte[SaveRamLength]; - Console.WriteLine("SaveRAM enabled. Start: ${0:X6} End: ${1:X6} Length: ${2:X} Mode: {3}", SaveRamStartOffset, SaveRamEndOffset, SaveRamLength, RH_SRamInterpretation()); - } + Console.WriteLine("SaveRAM enabled. Start: ${0:X6} End: ${1:X6} Length: ${2:X} Mode: {3}", SaveRamStartOffset, SaveRamEndOffset, SaveRamLength, RH_SRamInterpretation()); + } public byte[] ReadSaveRam() { return (byte[])SaveRAM.Clone(); } public void StoreSaveRam(byte[] data) { Array.Copy(data, SaveRAM, data.Length); } public void ClearSaveRam() { SaveRAM = new byte[SaveRAM.Length]; } public bool SaveRamModified { get; set; } - } + } } diff --git a/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs index 49bd228e94..30c039b7a6 100644 --- a/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs @@ -6,6 +6,7 @@ using System.IO; using System.Runtime.InteropServices; using BizHawk.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.CPUs.M68000; using BizHawk.Emulation.CPUs.Z80; using BizHawk.Emulation.Sound; @@ -67,13 +68,13 @@ namespace BizHawk.Emulation.Consoles.Sega // A total of 3420 mclks per line, but 2560 mclks are active display and 860 mclks are blanking. #if MUSASHI - VdpCallback _vdp; - ReadCallback read8; - ReadCallback read16; - ReadCallback read32; - WriteCallback write8; - WriteCallback write16; - WriteCallback write32; + VdpCallback _vdp; + ReadCallback read8; + ReadCallback read16; + ReadCallback read32; + WriteCallback write8; + WriteCallback write16; + WriteCallback write32; #endif public Genesis(CoreComm comm, GameInfo game, byte[] rom) @@ -81,8 +82,8 @@ namespace BizHawk.Emulation.Consoles.Sega CoreComm = comm; MainCPU = new MC68000(); SoundCPU = new Z80A(); - YM2612 = new YM2612() { MaxVolume = 23405 }; - PSG = new SN76489() { MaxVolume = 4681 }; + YM2612 = new YM2612() { MaxVolume = 23405 }; + PSG = new SN76489() { MaxVolume = 4681 }; VDP = new GenVDP(); VDP.DmaReadFrom68000 = ReadWord; SoundMixer = new SoundMixer(YM2612, PSG); @@ -93,27 +94,27 @@ namespace BizHawk.Emulation.Consoles.Sega MainCPU.WriteByte = WriteByte; MainCPU.WriteWord = WriteWord; MainCPU.WriteLong = WriteLong; - MainCPU.IrqCallback = InterruptCallback; + MainCPU.IrqCallback = InterruptCallback; - // ---------------------- musashi ----------------------- + // ---------------------- musashi ----------------------- #if MUSASHI - _vdp = vdpcallback; - read8 = Read8; - read16 = Read16; - read32 = Read32; - write8 = Write8; - write16 = Write16; - write32 = Write32; + _vdp = vdpcallback; + read8 = Read8; + read16 = Read16; + read32 = Read32; + write8 = Write8; + write16 = Write16; + write32 = Write32; - Musashi.RegisterVdpCallback(Marshal.GetFunctionPointerForDelegate(_vdp)); - Musashi.RegisterRead8(Marshal.GetFunctionPointerForDelegate(read8)); - Musashi.RegisterRead16(Marshal.GetFunctionPointerForDelegate(read16)); - Musashi.RegisterRead32(Marshal.GetFunctionPointerForDelegate(read32)); - Musashi.RegisterWrite8(Marshal.GetFunctionPointerForDelegate(write8)); - Musashi.RegisterWrite16(Marshal.GetFunctionPointerForDelegate(write16)); - Musashi.RegisterWrite32(Marshal.GetFunctionPointerForDelegate(write32)); + Musashi.RegisterVdpCallback(Marshal.GetFunctionPointerForDelegate(_vdp)); + Musashi.RegisterRead8(Marshal.GetFunctionPointerForDelegate(read8)); + Musashi.RegisterRead16(Marshal.GetFunctionPointerForDelegate(read16)); + Musashi.RegisterRead32(Marshal.GetFunctionPointerForDelegate(read32)); + Musashi.RegisterWrite8(Marshal.GetFunctionPointerForDelegate(write8)); + Musashi.RegisterWrite16(Marshal.GetFunctionPointerForDelegate(write16)); + Musashi.RegisterWrite32(Marshal.GetFunctionPointerForDelegate(write32)); #endif - // ---------------------- musashi ----------------------- + // ---------------------- musashi ----------------------- SoundCPU.ReadMemory = ReadMemoryZ80; SoundCPU.WriteMemory = WriteMemoryZ80; @@ -127,35 +128,35 @@ namespace BizHawk.Emulation.Consoles.Sega SetupMemoryDomains(); #if MUSASHI - Musashi.Init(); - Musashi.Reset(); - VDP.GetPC = () => Musashi.PC; + Musashi.Init(); + Musashi.Reset(); + VDP.GetPC = () => Musashi.PC; #else MainCPU.Reset(); VDP.GetPC = () => MainCPU.PC; #endif - InitializeCartHardware(game); - } + InitializeCartHardware(game); + } - void InitializeCartHardware(GameInfo game) - { - LogCartInfo(); - InitializeEeprom(game); - InitializeSaveRam(game); - } + void InitializeCartHardware(GameInfo game) + { + LogCartInfo(); + InitializeEeprom(game); + InitializeSaveRam(game); + } public void FrameAdvance(bool render, bool rendersound) { lagged = true; - Controller.UpdateControls(Frame++); + Controller.UpdateControls(Frame++); PSG.BeginFrame(SoundCPU.TotalExecutedCycles); - YM2612.BeginFrame(SoundCPU.TotalExecutedCycles); + YM2612.BeginFrame(SoundCPU.TotalExecutedCycles); - // Do start-of-frame events - VDP.HIntLineCounter = VDP.Registers[10]; - //VDP.VdpStatusWord &= - unchecked { VDP.VdpStatusWord &= (ushort)~GenVDP.StatusVerticalBlanking; } + // Do start-of-frame events + VDP.HIntLineCounter = VDP.Registers[10]; + //VDP.VdpStatusWord &= + unchecked { VDP.VdpStatusWord &= (ushort)~GenVDP.StatusVerticalBlanking; } for (VDP.ScanLine = 0; VDP.ScanLine < 262; VDP.ScanLine++) { @@ -164,45 +165,45 @@ namespace BizHawk.Emulation.Consoles.Sega if (VDP.ScanLine < VDP.FrameHeight) VDP.RenderLine(); - Exec68k(365); - RunZ80(171); + Exec68k(365); + RunZ80(171); - // H-Int now? + // H-Int now? - VDP.HIntLineCounter--; - if (VDP.HIntLineCounter < 0 && VDP.ScanLine < 224) // FIXME - { - VDP.HIntLineCounter = VDP.Registers[10]; - VDP.VdpStatusWord |= GenVDP.StatusHorizBlanking; - - if (VDP.HInterruptsEnabled) - { - Set68kIrq(4); - //Console.WriteLine("Fire hint!"); - } - - } - - Exec68k(488 - 365); - RunZ80(228 - 171); - - if (VDP.ScanLine == 224) + VDP.HIntLineCounter--; + if (VDP.HIntLineCounter < 0 && VDP.ScanLine < 224) // FIXME { - VDP.VdpStatusWord |= GenVDP.StatusVerticalInterruptPending; - VDP.VdpStatusWord |= GenVDP.StatusVerticalBlanking; - Exec68k(16); // this is stupidly wrong. + VDP.HIntLineCounter = VDP.Registers[10]; + VDP.VdpStatusWord |= GenVDP.StatusHorizBlanking; + + if (VDP.HInterruptsEnabled) + { + Set68kIrq(4); + //Console.WriteLine("Fire hint!"); + } + + } + + Exec68k(488 - 365); + RunZ80(228 - 171); + + if (VDP.ScanLine == 224) + { + VDP.VdpStatusWord |= GenVDP.StatusVerticalInterruptPending; + VDP.VdpStatusWord |= GenVDP.StatusVerticalBlanking; + Exec68k(16); // this is stupidly wrong. // End-frame stuff - if (VDP.VInterruptEnabled) - Set68kIrq(6); + if (VDP.VInterruptEnabled) + Set68kIrq(6); SoundCPU.Interrupt = true; - //The INT output is asserted every frame for exactly one scanline, and it can't be disabled. A very short Z80 interrupt routine would be triggered multiple times if it finishes within 228 Z80 clock cycles. I think (but cannot recall the specifics) that some games have delay loops in the interrupt handler for this very reason. + //The INT output is asserted every frame for exactly one scanline, and it can't be disabled. A very short Z80 interrupt routine would be triggered multiple times if it finishes within 228 Z80 clock cycles. I think (but cannot recall the specifics) that some games have delay loops in the interrupt handler for this very reason. } } PSG.EndFrame(SoundCPU.TotalExecutedCycles); - YM2612.EndFrame(SoundCPU.TotalExecutedCycles); + YM2612.EndFrame(SoundCPU.TotalExecutedCycles); + - if (lagged) { @@ -213,45 +214,45 @@ namespace BizHawk.Emulation.Consoles.Sega islag = false; } - void Exec68k(int cycles) - { + void Exec68k(int cycles) + { #if MUSASHI - Musashi.Execute(cycles); + Musashi.Execute(cycles); #else MainCPU.ExecuteCycles(cycles); #endif - } + } - void RunZ80(int cycles) - { - // I emulate the YM2612 synced to Z80 clock, for better or worse. - // So we still need to keep the Z80 cycle count accurate even if the Z80 isn't running. + void RunZ80(int cycles) + { + // I emulate the YM2612 synced to Z80 clock, for better or worse. + // So we still need to keep the Z80 cycle count accurate even if the Z80 isn't running. - if (Z80Runnable) - SoundCPU.ExecuteCycles(cycles); - else - SoundCPU.TotalExecutedCycles += cycles; - } + if (Z80Runnable) + SoundCPU.ExecuteCycles(cycles); + else + SoundCPU.TotalExecutedCycles += cycles; + } - void Set68kIrq(int irq) - { + void Set68kIrq(int irq) + { #if MUSASHI - Musashi.SetIRQ(irq); + Musashi.SetIRQ(irq); #else MainCPU.Interrupt = irq; #endif - } + } - int vdpcallback(int level) // Musashi handler - { - InterruptCallback(level); - return -1; - } + int vdpcallback(int level) // Musashi handler + { + InterruptCallback(level); + return -1; + } - void InterruptCallback(int level) - { - unchecked { VDP.VdpStatusWord &= (ushort)~GenVDP.StatusVerticalInterruptPending; } - } + void InterruptCallback(int level) + { + unchecked { VDP.VdpStatusWord &= (ushort)~GenVDP.StatusVerticalInterruptPending; } + } public CoreComm CoreComm { get; private set; } @@ -276,139 +277,139 @@ namespace BizHawk.Emulation.Consoles.Sega public string BoardName { get { return null; } } - public void SaveStateText(TextWriter writer) - { - var buf = new byte[141501 + SaveRAM.Length]; - var stream = new MemoryStream(buf); - var bwriter = new BinaryWriter(stream); - SaveStateBinary(bwriter); - - writer.WriteLine("Version 1"); - writer.Write("BigFatBlob "); - buf.SaveAsHex(writer); + public void SaveStateText(TextWriter writer) + { + var buf = new byte[141501 + SaveRAM.Length]; + var stream = new MemoryStream(buf); + var bwriter = new BinaryWriter(stream); + SaveStateBinary(bwriter); - /*writer.WriteLine("[MegaDrive]"); - MainCPU.SaveStateText(writer, "Main68K"); - SoundCPU.SaveStateText(writer); - PSG.SaveStateText(writer); - VDP.SaveStateText(writer); + writer.WriteLine("Version 1"); + writer.Write("BigFatBlob "); + buf.SaveAsHex(writer); + + /*writer.WriteLine("[MegaDrive]"); + MainCPU.SaveStateText(writer, "Main68K"); + SoundCPU.SaveStateText(writer); + PSG.SaveStateText(writer); + VDP.SaveStateText(writer); writer.WriteLine("Frame {0}", Frame); writer.WriteLine("Lag {0}", _lagcount); writer.WriteLine("IsLag {0}", islag); - writer.Write("MainRAM "); - Ram.SaveAsHex(writer); - writer.Write("Z80RAM "); - Z80Ram.SaveAsHex(writer); - writer.WriteLine("[/MegaDrive]");*/ - } + writer.Write("MainRAM "); + Ram.SaveAsHex(writer); + writer.Write("Z80RAM "); + Z80Ram.SaveAsHex(writer); + writer.WriteLine("[/MegaDrive]");*/ + } - public void LoadStateText(TextReader reader) - { - var buf = new byte[141501 + SaveRAM.Length]; - var version = reader.ReadLine(); - if (version != "Version 1") - throw new Exception("Not a valid state vesrion! sorry! your state is bad! Robust states will be added later!"); - var omgstate = reader.ReadLine().Split(' ')[1]; - buf.ReadFromHex(omgstate); - LoadStateBinary(new BinaryReader(new MemoryStream(buf))); + public void LoadStateText(TextReader reader) + { + var buf = new byte[141501 + SaveRAM.Length]; + var version = reader.ReadLine(); + if (version != "Version 1") + throw new Exception("Not a valid state vesrion! sorry! your state is bad! Robust states will be added later!"); + var omgstate = reader.ReadLine().Split(' ')[1]; + buf.ReadFromHex(omgstate); + LoadStateBinary(new BinaryReader(new MemoryStream(buf))); - /*while (true) - { - string[] args = reader.ReadLine().Split(' '); - if (args[0].Trim() == "") continue; - if (args[0] == "[MegaDrive]") continue; - if (args[0] == "[/MegaDrive]") break; - if (args[0] == "MainRAM") - Ram.ReadFromHex(args[1]); - else if (args[0] == "Z80RAM") - Z80Ram.ReadFromHex(args[1]); - else if (args[0] == "[Main68K]") - MainCPU.LoadStateText(reader, "Main68K"); - else if (args[0] == "[Z80]") - SoundCPU.LoadStateText(reader); + /*while (true) + { + string[] args = reader.ReadLine().Split(' '); + if (args[0].Trim() == "") continue; + if (args[0] == "[MegaDrive]") continue; + if (args[0] == "[/MegaDrive]") break; + if (args[0] == "MainRAM") + Ram.ReadFromHex(args[1]); + else if (args[0] == "Z80RAM") + Z80Ram.ReadFromHex(args[1]); + else if (args[0] == "[Main68K]") + MainCPU.LoadStateText(reader, "Main68K"); + else if (args[0] == "[Z80]") + SoundCPU.LoadStateText(reader); else if (args[0] == "Frame") Frame = int.Parse(args[1]); else if (args[0] == "Lag") _lagcount = int.Parse(args[1]); else if (args[0] == "IsLag") islag = bool.Parse(args[1]); - else if (args[0] == "[PSG]") - PSG.LoadStateText(reader); - else if (args[0] == "[VDP]") - VDP.LoadStateText(reader); - else - Console.WriteLine("Skipping unrecognized identifier " + args[0]); - }*/ - } + else if (args[0] == "[PSG]") + PSG.LoadStateText(reader); + else if (args[0] == "[VDP]") + VDP.LoadStateText(reader); + else + Console.WriteLine("Skipping unrecognized identifier " + args[0]); + }*/ + } public void SaveStateBinary(BinaryWriter writer) { - Musashi.SaveStateBinary(writer); // 124 - SoundCPU.SaveStateBinary(writer); // 46 - PSG.SaveStateBinary(writer); // 15 - VDP.SaveStateBinary(writer); // 65781 - YM2612.SaveStateBinary(writer); // 1785 - - writer.Write(Ram); // 65535 - writer.Write(Z80Ram); // 8192 + Musashi.SaveStateBinary(writer); // 124 + SoundCPU.SaveStateBinary(writer); // 46 + PSG.SaveStateBinary(writer); // 15 + VDP.SaveStateBinary(writer); // 65781 + YM2612.SaveStateBinary(writer); // 1785 - writer.Write(Frame); // 4 - writer.Write(M68000HasZ80Bus); // 1 - writer.Write(Z80Reset); // 1 - writer.Write(BankRegion); // 4 + writer.Write(Ram); // 65535 + writer.Write(Z80Ram); // 8192 - for (int i = 0; i < 3; i++) - { - writer.Write(IOPorts[i].Data); - writer.Write(IOPorts[i].TxData); - writer.Write(IOPorts[i].RxData); - writer.Write(IOPorts[i].SCtrl); - } + writer.Write(Frame); // 4 + writer.Write(M68000HasZ80Bus); // 1 + writer.Write(Z80Reset); // 1 + writer.Write(BankRegion); // 4 - if (SaveRAM.Length > 0) - writer.Write(SaveRAM); + for (int i = 0; i < 3; i++) + { + writer.Write(IOPorts[i].Data); + writer.Write(IOPorts[i].TxData); + writer.Write(IOPorts[i].RxData); + writer.Write(IOPorts[i].SCtrl); + } - // TODO: EEPROM/cart HW state - // TODO: lag counter crap + if (SaveRAM.Length > 0) + writer.Write(SaveRAM); + + // TODO: EEPROM/cart HW state + // TODO: lag counter crap } public void LoadStateBinary(BinaryReader reader) { - Musashi.LoadStateBinary(reader); - SoundCPU.LoadStateBinary(reader); - PSG.LoadStateBinary(reader); - VDP.LoadStateBinary(reader); - YM2612.LoadStateBinary(reader); + Musashi.LoadStateBinary(reader); + SoundCPU.LoadStateBinary(reader); + PSG.LoadStateBinary(reader); + VDP.LoadStateBinary(reader); + YM2612.LoadStateBinary(reader); - Ram = reader.ReadBytes(Ram.Length); - Z80Ram = reader.ReadBytes(Z80Ram.Length); + Ram = reader.ReadBytes(Ram.Length); + Z80Ram = reader.ReadBytes(Z80Ram.Length); - Frame = reader.ReadInt32(); - M68000HasZ80Bus = reader.ReadBoolean(); - Z80Reset = reader.ReadBoolean(); - BankRegion = reader.ReadInt32(); + Frame = reader.ReadInt32(); + M68000HasZ80Bus = reader.ReadBoolean(); + Z80Reset = reader.ReadBoolean(); + BankRegion = reader.ReadInt32(); - for (int i = 0; i < 3; i++) - { - IOPorts[i].Data = reader.ReadByte(); - IOPorts[i].TxData = reader.ReadByte(); - IOPorts[i].RxData = reader.ReadByte(); - IOPorts[i].SCtrl = reader.ReadByte(); - } + for (int i = 0; i < 3; i++) + { + IOPorts[i].Data = reader.ReadByte(); + IOPorts[i].TxData = reader.ReadByte(); + IOPorts[i].RxData = reader.ReadByte(); + IOPorts[i].SCtrl = reader.ReadByte(); + } - if (SaveRAM.Length > 0) - SaveRAM = reader.ReadBytes(SaveRAM.Length); + if (SaveRAM.Length > 0) + SaveRAM = reader.ReadBytes(SaveRAM.Length); } public byte[] SaveStateBinary() { - var buf = new byte[141501+SaveRAM.Length]; - var stream = new MemoryStream(buf); - var writer = new BinaryWriter(stream); - SaveStateBinary(writer); - //Console.WriteLine("buf len = {0}", stream.Position); - writer.Close(); - return buf; + var buf = new byte[141501 + SaveRAM.Length]; + var stream = new MemoryStream(buf); + var writer = new BinaryWriter(stream); + SaveStateBinary(writer); + //Console.WriteLine("buf len = {0}", stream.Position); + writer.Close(); + return buf; } public bool BinarySaveStatesPreferred { get { return false; } } diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs index 88ee7f740f..649f18d5c1 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using BizHawk.Common; +using BizHawk.Emulation.Common; using BizHawk.Emulation.CPUs.Z80; using BizHawk.Emulation.Sound; diff --git a/BizHawk.sln b/BizHawk.sln index 288451e22d..96154c355a 100644 --- a/BizHawk.sln +++ b/BizHawk.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Client.DiscoHawk", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Emulation.DiscSystem", "BizHawk.Emulation.DiscSystem\BizHawk.Emulation.DiscSystem.csproj", "{F51946EA-827F-4D82-B841-1F2F6D060312}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Emulation.Common", "BizHawk.Emulation.Common\BizHawk.Emulation.Common.csproj", "{E1A23168-B571-411C-B360-2229E7225E0E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -99,6 +101,18 @@ Global {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|Mixed Platforms.Build.0 = Release|Any CPU {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|Win32.ActiveCfg = Release|Any CPU {F51946EA-827F-4D82-B841-1F2F6D060312}.Release|x86.ActiveCfg = Release|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|Win32.ActiveCfg = Debug|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Debug|x86.ActiveCfg = Debug|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Release|Any CPU.Build.0 = Release|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Release|Win32.ActiveCfg = Release|Any CPU + {E1A23168-B571-411C-B360-2229E7225E0E}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE