start Emulation.Common project and move the Emulation/Database folder files to it

This commit is contained in:
adelikat 2013-11-04 01:06:36 +00:00
parent 4f5d8b89c9
commit 348171bdc5
35 changed files with 392 additions and 242 deletions

View File

@ -147,6 +147,10 @@
<Project>{866F8D13-0678-4FF9-80A4-A3993FD4D8A3}</Project>
<Name>BizHawk.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Emulation.Common\BizHawk.Emulation.Common.csproj">
<Project>{e1a23168-b571-411c-b360-2229e7225e0e}</Project>
<Name>BizHawk.Emulation.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Emulation.DiscSystem\BizHawk.Emulation.DiscSystem.csproj">
<Project>{f51946ea-827f-4d82-b841-1f2f6d060312}</Project>
<Name>BizHawk.Emulation.DiscSystem</Name>

View File

@ -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

View File

@ -1,4 +1,5 @@
using BizHawk.Emulation.DiscSystem;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.DiscSystem;
namespace BizHawk.Client.Common
{

View File

@ -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

View File

@ -2,6 +2,7 @@
using System.Globalization;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
{

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Xml;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
{

View File

@ -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

View File

@ -1006,6 +1006,10 @@
<Project>{866F8D13-0678-4FF9-80A4-A3993FD4D8A3}</Project>
<Name>BizHawk.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Emulation.Common\BizHawk.Emulation.Common.csproj">
<Project>{e1a23168-b571-411c-b360-2229e7225e0e}</Project>
<Name>BizHawk.Emulation.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Emulation.DiscSystem\BizHawk.Emulation.DiscSystem.csproj">
<Project>{f51946ea-827f-4d82-b841-1f2f6d060312}</Project>
<Name>BizHawk.Emulation.DiscSystem</Name>

View File

@ -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;

View File

@ -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.

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E1A23168-B571-411C-B360-2229E7225E0E}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BizHawk.Emulation.Common</RootNamespace>
<AssemblyName>BizHawk.Emulation.Common</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Database\CRC32.cs" />
<Compile Include="Database\Database.cs" />
<Compile Include="Database\FirmwareDatabase.cs" />
<Compile Include="Database\GameInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BizHawk.Common\BizHawk.Common.csproj">
<Project>{866f8d13-0678-4ff9-80a4-a3993fd4d8a3}</Project>
<Name>BizHawk.Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -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
{

View File

@ -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;

View File

@ -2,7 +2,7 @@
using System.Linq;
using System.Collections.Generic;
namespace BizHawk
namespace BizHawk.Emulation.Common
{
public static class FirmwareDatabase
{

View File

@ -4,7 +4,7 @@ using System.Globalization;
using BizHawk.Common;
namespace BizHawk
namespace BizHawk.Emulation.Common
{
public enum RomStatus
{

View File

@ -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")]

View File

@ -452,10 +452,6 @@
<Compile Include="CPUs\Z80\Registers.cs" />
<Compile Include="CPUs\Z80\Tables.cs" />
<Compile Include="CPUs\Z80\Z80A.cs" />
<Compile Include="Database\CRC32.cs" />
<Compile Include="Database\Database.cs" />
<Compile Include="Database\FirmwareDatabase.cs" />
<Compile Include="Database\GameInfo.cs" />
<Compile Include="Interfaces\Base Implementations\IPS.cs" />
<Compile Include="Interfaces\Base Implementations\Movies.cs" />
<Compile Include="Interfaces\Base Implementations\NullController.cs" />
@ -542,6 +538,10 @@
<Project>{866F8D13-0678-4FF9-80A4-A3993FD4D8A3}</Project>
<Name>BizHawk.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Emulation.Common\BizHawk.Emulation.Common.csproj">
<Project>{e1a23168-b571-411c-b360-2229e7225e0e}</Project>
<Name>BizHawk.Emulation.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Emulation.DiscSystem\BizHawk.Emulation.DiscSystem.csproj">
<Project>{f51946ea-827f-4d82-b841-1f2f6d060312}</Project>
<Name>BizHawk.Emulation.DiscSystem</Name>

View File

@ -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; }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk
{

View File

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

View File

@ -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/

View File

@ -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;

View File

@ -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

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Consoles.GB
{

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Consoles.GB
{

View File

@ -5,6 +5,7 @@ using System.Runtime.InteropServices;
using System.Threading;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Consoles.Nintendo.N64
{

View File

@ -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;

View File

@ -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

View File

@ -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
{

View File

@ -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;

View File

@ -1,6 +1,8 @@
using System;
using System.Globalization;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Consoles.Sega
{
partial class Genesis

View File

@ -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; }
}
}
}

View File

@ -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; } }

View File

@ -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;

View File

@ -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