unify coreinputcomm and coreoutputcomm. there is a slight chance your console will be messed up until i fix a teeny tiny something, since i didnt test them all, since with more recent cores i dunno what roms are working anyway. let me know if i broke anything.

This commit is contained in:
zeromus 2012-12-10 00:43:43 +00:00
parent 6ef2913ed8
commit a4b442abda
40 changed files with 372 additions and 391 deletions

View File

@ -40,13 +40,13 @@ namespace BizHawk.Emulation.Computers.Commodore64
InitMedia();
// configure video
CoreOutputComm.VsyncDen = board.vic.CyclesPerFrame;
CoreOutputComm.VsyncNum = board.vic.CyclesPerSecond;
CoreComm.VsyncDen = board.vic.CyclesPerFrame;
CoreComm.VsyncNum = board.vic.CyclesPerSecond;
}
private void InitDisk(Region initRegion)
{
string sourceFolder = CoreInputComm.C64_FirmwaresPath;
string sourceFolder = CoreComm.C64_FirmwaresPath;
if (sourceFolder == null)
sourceFolder = @".\C64\Firmwares";
string diskFile = "dos1541";
@ -78,7 +78,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
private void InitRoms()
{
string sourceFolder = CoreInputComm.C64_FirmwaresPath;
string sourceFolder = CoreComm.C64_FirmwaresPath;
if (sourceFolder == null)
sourceFolder = @".\C64\Firmwares";

View File

@ -13,15 +13,14 @@ namespace BizHawk.Emulation.Computers.Commodore64
private string extension;
private byte[] inputFile;
public C64(GameInfo game, byte[] rom, string romextension)
public C64(CoreComm comm, GameInfo game, byte[] rom, string romextension)
{
CoreComm = comm;
inputFile = rom;
extension = romextension;
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
Init(Region.PAL);
cyclesPerFrame = (uint)board.vic.CyclesPerFrame;
CoreOutputComm.UsesDriveLed = true;
CoreComm.UsesDriveLed = true;
SetupMemoryDomains();
}
@ -31,8 +30,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
private int _frame = 0;
// bizhawk I/O
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
// game/rom specific
public GameInfo game;
@ -126,7 +124,7 @@ namespace BizHawk.Emulation.Computers.Commodore64
Console.WriteLine("CPUPC: " + C64Util.ToHex(board.cpu.PC, 4) + " 1541PC: " + C64Util.ToHex(disk.PC, 4));
CoreOutputComm.DriveLED = DriveLED;
CoreComm.DriveLED = DriveLED;
}
private void HandleFirmwareError(string file)

View File

@ -113,9 +113,9 @@ namespace BizHawk
{
byte temp = mapper.ReadMemory((ushort)(addr&0x1FFF));
if (CoreInputComm.MemoryCallbackSystem.HasRead)
if (CoreComm.MemoryCallbackSystem.HasRead)
{
CoreInputComm.MemoryCallbackSystem.TriggerRead(addr);
CoreComm.MemoryCallbackSystem.TriggerRead(addr);
}
return temp;
@ -132,9 +132,9 @@ namespace BizHawk
{
mapper.WriteMemory((ushort)(addr & 0x1FFF), value);
if (CoreInputComm.MemoryCallbackSystem.HasWrite)
if (CoreComm.MemoryCallbackSystem.HasWrite)
{
CoreInputComm.MemoryCallbackSystem.TriggerWrite(addr);
CoreComm.MemoryCallbackSystem.TriggerWrite(addr);
}
}
@ -195,7 +195,7 @@ namespace BizHawk
//cpu.PC = 0x0000; //set the initial PC
// show mapper class on romstatusdetails
CoreOutputComm.RomStatusDetails =
CoreComm.RomStatusDetails =
string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\nMapper Impl \"{3}\"",
game.Name,
Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom)),
@ -215,8 +215,8 @@ namespace BizHawk
tia.execute(1);
m6532.timer.tick();
if (CoreInputComm.Tracer.Enabled)
CoreInputComm.Tracer.Put(cpu.TraceState());
if (CoreComm.Tracer.Enabled)
CoreComm.Tracer.Put(cpu.TraceState());
cpu.ExecuteOne();
//if (cpu.PendingCycles <= 0)
//{
@ -236,7 +236,7 @@ namespace BizHawk
public byte ReadControls1(bool peek)
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
byte value = 0xFF;
if (Controller["P1 Up"]) value &= 0xEF;
@ -250,7 +250,7 @@ namespace BizHawk
public byte ReadControls2(bool peek)
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
byte value = 0xFF;
if (Controller["P2 Up"]) value &= 0xEF;

View File

@ -9,22 +9,20 @@ namespace BizHawk
public string SystemId { get { return "A26"; } }
public GameInfo game;
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public IVideoProvider VideoProvider { get { return tia; } }
public ISoundProvider SoundProvider { get { return dcfilter; } }
public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(dcfilter, 735); } }
public bool StartAsyncSound() { return true; }
public void EndAsyncSound() { }
public Atari2600(GameInfo game, byte[] rom)
public Atari2600(CoreComm comm, GameInfo game, byte[] rom)
{
CoreComm = comm;
var domains = new List<MemoryDomain>(1);
domains.Add(new MemoryDomain("Main RAM", 128, Endian.Little, addr => ram[addr & 127], (addr, value) => ram[addr & 127] = value));
memoryDomains = domains.AsReadOnly();
CoreOutputComm = new CoreOutputComm();
CoreOutputComm.CpuTraceAvailable = true;
CoreInputComm = new CoreInputComm();
CoreComm.CpuTraceAvailable = true;
this.rom = rom;
this.game = game;
Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]);

View File

@ -699,12 +699,12 @@ namespace BizHawk.Emulation.Consoles.Atari
// Pick the pixel color from collisions
uint pixelColor = 0x000000;
if (core.CoreInputComm.Atari2600_ShowBG)
if (core.CoreComm.Atari2600_ShowBG)
{
pixelColor = palette[playField.bkColor];
}
if ((collisions & CXPF) != 0 && core.CoreInputComm.Atari2600_ShowPF)
if ((collisions & CXPF) != 0 && core.CoreComm.Atari2600_ShowPF)
{
if (playField.score)
{
@ -726,7 +726,7 @@ namespace BizHawk.Emulation.Consoles.Atari
if ((collisions & CXBL) != 0)
{
ball.collisions |= collisions;
if (core.CoreInputComm.Atari2600_ShowBall)
if (core.CoreComm.Atari2600_ShowBall)
{
pixelColor = palette[playField.pfColor];
}
@ -735,7 +735,7 @@ namespace BizHawk.Emulation.Consoles.Atari
if ((collisions & CXM1) != 0)
{
player1.missile.collisions |= collisions;
if (core.CoreInputComm.Atari2600_ShowMissle2)
if (core.CoreComm.Atari2600_ShowMissle2)
{
pixelColor = palette[player1.color];
}
@ -744,7 +744,7 @@ namespace BizHawk.Emulation.Consoles.Atari
if ((collisions & CXP1) != 0)
{
player1.collisions |= collisions;
if (core.CoreInputComm.Atari2600_ShowPlayer2)
if (core.CoreComm.Atari2600_ShowPlayer2)
{
pixelColor = palette[player1.color];
}
@ -753,7 +753,7 @@ namespace BizHawk.Emulation.Consoles.Atari
if ((collisions & CXM0) != 0)
{
player0.missile.collisions |= collisions;
if (core.CoreInputComm.Atari2600_ShowMissle1)
if (core.CoreComm.Atari2600_ShowMissle1)
{
pixelColor = palette[player0.color];
}
@ -762,13 +762,13 @@ namespace BizHawk.Emulation.Consoles.Atari
if ((collisions & CXP0) != 0)
{
player0.collisions |= collisions;
if (core.CoreInputComm.Atari2600_ShowPlayer1)
if (core.CoreComm.Atari2600_ShowPlayer1)
{
pixelColor = palette[player0.color];
}
}
if (playField.priority && (collisions & CXPF) != 0 && core.CoreInputComm.Atari2600_ShowPF)
if (playField.priority && (collisions & CXPF) != 0 && core.CoreComm.Atari2600_ShowPF)
{
if (playField.score)
{

View File

@ -29,8 +29,7 @@ namespace BizHawk
}
/* TODO */
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public ISyncSoundProvider SyncSoundProvider { get { return null; } }
public bool StartAsyncSound() { return true; }
public void EndAsyncSound() { }
@ -89,14 +88,14 @@ namespace BizHawk
}
};
public Atari7800(GameInfo game, byte[] rom, byte[] ntsc_bios, byte[] pal_bios, byte[] highscoreBIOS)
public Atari7800(CoreComm comm, GameInfo game, byte[] rom, byte[] ntsc_bios, byte[] pal_bios, byte[] highscoreBIOS)
{
CoreComm = comm;
//TODO: store both the ntsc bios and the pal bios
var domains = new List<MemoryDomain>(1);
domains.Add(new MemoryDomain("Main RAM", 1, Endian.Little, addr => 0xFF, null)); //TODO
memoryDomains = domains.AsReadOnly();
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
this.rom = rom;
this.game = game;
this.hsbios = highscoreBIOS;
@ -111,7 +110,7 @@ namespace BizHawk
{
_lagcount = 0;
// show mapper class on romstatusdetails
CoreOutputComm.RomStatusDetails =
CoreComm.RomStatusDetails =
string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\nMapper Impl \"{3}\"",
game.Name,
Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom)),

View File

@ -39,9 +39,9 @@ namespace BizHawk.Emulation.Consoles.Calculator
ret = rom[romPage * 0x4000 + addr - 0x4000]; //other rom page
else ret = ram[addr - 0x8000];
if (CoreInputComm.MemoryCallbackSystem.HasRead)
if (CoreComm.MemoryCallbackSystem.HasRead)
{
CoreInputComm.MemoryCallbackSystem.TriggerRead(addr);
CoreComm.MemoryCallbackSystem.TriggerRead(addr);
}
return ret;
@ -55,9 +55,9 @@ namespace BizHawk.Emulation.Consoles.Calculator
return; //other rom page
else ram[addr - 0x8000] = value;
if (CoreInputComm.MemoryCallbackSystem.HasWrite)
if (CoreComm.MemoryCallbackSystem.HasWrite)
{
CoreInputComm.MemoryCallbackSystem.TriggerWrite(addr);
CoreComm.MemoryCallbackSystem.TriggerWrite(addr);
}
}
@ -136,7 +136,7 @@ namespace BizHawk.Emulation.Consoles.Calculator
byte ReadKeyboard()
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
//ref TI-9X
int ret = 0xFF;
@ -326,9 +326,9 @@ namespace BizHawk.Emulation.Consoles.Calculator
}
}
public TI83(GameInfo game, byte[] rom)
public TI83(CoreComm comm, GameInfo game, byte[] rom)
{
CoreOutputComm = new CoreOutputComm();
CoreComm = comm;
cpu.ReadMemory = ReadMemory;
cpu.WriteMemory = WriteMemory;
cpu.ReadHardware = ReadHardware;
@ -362,8 +362,7 @@ namespace BizHawk.Emulation.Consoles.Calculator
}
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
protected byte[] vram = new byte[0x300];
class MyVideoProvider : IVideoProvider

View File

@ -20,8 +20,10 @@ namespace BizHawk.Emulation.Consoles.Coleco
public SN76489 PSG;
public byte[] Ram = new byte[1024];
public ColecoVision(GameInfo game, byte[] rom, string biosPath, bool skipbios)
public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, string biosPath, bool skipbios)
{
CoreComm = comm;
Cpu = new Z80A();
Cpu.ReadMemory = ReadMemory;
Cpu.WriteMemory = WriteMemory;
@ -34,11 +36,8 @@ namespace BizHawk.Emulation.Consoles.Coleco
// TODO: hack to allow bios-less operation would be nice, no idea if its feasible
BiosRom = File.ReadAllBytes(biosPath);
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
if (game["NoSkip"])
skipbios = false;
if (game["NoSkip"])
skipbios = false;
LoadRom(rom, skipbios);
this.game = game;
SetupMemoryDomains();
@ -239,8 +238,7 @@ namespace BizHawk.Emulation.Consoles.Coleco
public string SystemId { get { return "Coleco"; } }
public GameInfo game;
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public IVideoProvider VideoProvider { get { return VDP; } }
public ISoundProvider SoundProvider { get { return PSG; } }

View File

@ -38,8 +38,10 @@ namespace BizHawk.Emulation.Consoles.Intellivision
if (GraphicsRom.Length != 2048) throw new ApplicationException("GROM file is wrong size - expected 2048 bytes");
}
public Intellivision(GameInfo game, byte[] rom)
public Intellivision(CoreComm comm, GameInfo game, byte[] rom)
{
CoreComm = comm;
Rom = rom;
Game = game;
Cart = new Intellicart();
@ -65,8 +67,6 @@ namespace BizHawk.Emulation.Consoles.Intellivision
Connect();
CoreOutputComm = new CoreOutputComm();
Cpu.LogData();
}
@ -162,8 +162,7 @@ namespace BizHawk.Emulation.Consoles.Intellivision
return new byte[0];
}
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public IList<MemoryDomain> MemoryDomains
{

View File

@ -115,9 +115,9 @@ namespace BizHawk.Emulation.Consoles.Intellivision
break;
}
if (CoreInputComm.MemoryCallbackSystem.HasRead)
if (CoreComm.MemoryCallbackSystem.HasRead)
{
CoreInputComm.MemoryCallbackSystem.TriggerRead(addr);
CoreComm.MemoryCallbackSystem.TriggerRead(addr);
}
if (cart != null)
@ -286,9 +286,9 @@ namespace BizHawk.Emulation.Consoles.Intellivision
}
}
if (CoreInputComm.MemoryCallbackSystem.HasWrite)
if (CoreComm.MemoryCallbackSystem.HasWrite)
{
CoreInputComm.MemoryCallbackSystem.TriggerWrite(addr);
CoreComm.MemoryCallbackSystem.TriggerWrite(addr);
}
return (cart || stic || psg);

View File

@ -21,6 +21,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
public ControllerDefinition ControllerDefinition { get { return GBAController; } }
public IController Controller { get; set; }
public GBA(CoreComm comm)
{
CoreComm = comm;
comm.VsyncNum = 262144;
comm.VsyncDen = 4389;
comm.CpuTraceAvailable = true;
comm.TraceHeader = " -Addr--- -Opcode- -Instruction------------------- -R0----- -R1----- -R2----- -R3----- -R4----- -R5----- -R6----- -R7----- -R8----- -R9----- -R10---- -R11---- -R12---- -R13(SP) -R14(LR) -R15(PC) -CPSR--- -SPSR---";
comm.NominalWidth = 240;
comm.NominalHeight = 160;
}
public void Load(byte[] rom, byte[] bios)
{
if (bios.Length != 16384)
@ -43,7 +54,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
if (Controller["Power"])
LibMeteor.libmeteor_hardreset();
// due to the design of the tracing api, we have to poll whether it's active each frame
LibMeteor.libmeteor_settracecallback(CoreInputComm.Tracer.Enabled ? tracecallback : null);
LibMeteor.libmeteor_settracecallback(CoreComm.Tracer.Enabled ? tracecallback : null);
if (!coredead)
LibMeteor.libmeteor_frameadvance();
if (IsLagFrame)
@ -169,20 +180,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
#endregion
public CoreInputComm CoreInputComm { get; set; }
CoreOutputComm _CoreOutputComm = new CoreOutputComm
{
VsyncNum = 262144,
VsyncDen = 4389,
CpuTraceAvailable = true,
TraceHeader = " -Addr--- -Opcode- -Instruction------------------- -R0----- -R1----- -R2----- -R3----- -R4----- -R5----- -R6----- -R7----- -R8----- -R9----- -R10---- -R11---- -R12---- -R13(SP) -R14(LR) -R15(PC) -CPSR--- -SPSR---",
NominalWidth = 240,
NominalHeight = 160
};
public CoreOutputComm CoreOutputComm { get { return _CoreOutputComm; } }
public CoreComm CoreComm { get; private set; }
#region memorydomains
List<MemoryDomain> _MemoryDomains = new List<MemoryDomain>();
@ -377,7 +376,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.GBA
void Trace(string msg)
{
CoreInputComm.Tracer.Put(msg);
CoreComm.Tracer.Put(msg);
}
Action EndOfFrameCallback = null;

View File

@ -26,8 +26,10 @@ namespace BizHawk.Emulation.Consoles.GB
/// </summary>
LibGambatte.Buttons CurrentButtons = 0;
public Gameboy(GameInfo game, byte[] romdata)
public Gameboy(CoreComm comm, GameInfo game, byte[] romdata)
{
CoreComm = comm;
ThrowExceptionForBadRom(romdata);
GambatteState = LibGambatte.gambatte_create();
@ -64,7 +66,7 @@ namespace BizHawk.Emulation.Consoles.GB
InitMemoryDomains();
GbOutputComm.RomStatusDetails = string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n",
CoreComm.RomStatusDetails = string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n",
game.Name,
Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(romdata)),
Util.BytesToHexString(System.Security.Cryptography.MD5.Create().ComputeHash(romdata))
@ -89,7 +91,7 @@ namespace BizHawk.Emulation.Consoles.GB
LibGambatte.Buttons ControllerCallback()
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
IsLagFrame = false;
return CurrentButtons;
}
@ -140,7 +142,7 @@ namespace BizHawk.Emulation.Consoles.GB
LibGambatte.gambatte_reset(GambatteState);
RefreshMemoryCallbacks();
if (CoreInputComm.Tracer.Enabled)
if (CoreComm.Tracer.Enabled)
tracecb = MakeTrace;
else
tracecb = null;
@ -391,7 +393,7 @@ namespace BizHawk.Emulation.Consoles.GB
void RefreshMemoryCallbacks()
{
var mcs = CoreInputComm.MemoryCallbackSystem;
var mcs = CoreComm.MemoryCallbackSystem;
// we RefreshMemoryCallbacks() after the triggers in case the trigger turns itself off at that point
@ -412,23 +414,7 @@ namespace BizHawk.Emulation.Consoles.GB
#endregion
public CoreInputComm CoreInputComm { get; set; }
CoreOutputComm GbOutputComm = new CoreOutputComm
{
VsyncNum = 262144,
VsyncDen = 4389,
RomStatusAnnotation = null, //"Bizwhackin it up",
RomStatusDetails = null, //"LEVAR BURTON",
CpuTraceAvailable = true,
NominalWidth = 160,
NominalHeight = 144
};
public CoreOutputComm CoreOutputComm
{
get { return GbOutputComm; }
}
public CoreComm CoreComm { get; set; }
LibGambatte.TraceCallback tracecb;
@ -438,7 +424,7 @@ namespace BizHawk.Emulation.Consoles.GB
System.Runtime.InteropServices.Marshal.Copy(_s, s, 0, 13);
ushort unused;
CoreInputComm.Tracer.Put(string.Format(
CoreComm.Tracer.Put(string.Format(
"{13} SP:{2:x2} A:{3:x2} B:{4:x2} C:{5:x2} D:{6:x2} E:{7:x2} F:{8:x2} H:{9:x2} L:{10:x2} {11} Cy:{0}",
s[0],
s[1] & 0xffff,

View File

@ -154,9 +154,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
cpu.SetCallbacks(ReadMemory, ReadMemory, PeekMemory, WriteMemory, (h) => DisposeList.Add(h));
cpu.FetchCallback = () =>
{
if (CoreInputComm.Tracer.Enabled)
if (CoreComm.Tracer.Enabled)
{
CoreInputComm.Tracer.Put(cpu.TraceState());
CoreComm.Tracer.Put(cpu.TraceState());
}
};
cpu.BCD_Enabled = false;
@ -178,8 +178,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
case "NES-PAL-B":
apu = new APU(this, apu, true);
ppu.region = PPU.Region.PAL;
CoreOutputComm.VsyncNum = 50;
CoreOutputComm.VsyncDen = 1;
CoreComm.VsyncNum = 50;
CoreComm.VsyncDen = 1;
cpuclockrate = 1662607;
cpu_sequence = cpu_sequence_PAL;
break;
@ -203,8 +203,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
case "Dendy":
apu = new APU(this, apu, false);
ppu.region = PPU.Region.Dendy;
CoreOutputComm.VsyncNum = 50;
CoreOutputComm.VsyncDen = 1;
CoreComm.VsyncNum = 50;
CoreComm.VsyncDen = 1;
cpuclockrate = 1773448;
cpu_sequence = cpu_sequence_NTSC;
break;
@ -405,7 +405,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
byte read_joyport(int addr)
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
return handle_read_joyport(addr, false);
}
@ -602,9 +602,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
ret = sysbus_watch[addr].ApplyGameGenie(ret);
}
if (CoreInputComm.MemoryCallbackSystem.HasRead)
if (CoreComm.MemoryCallbackSystem.HasRead)
{
CoreInputComm.MemoryCallbackSystem.TriggerRead(addr);
CoreComm.MemoryCallbackSystem.TriggerRead(addr);
}
DB = ret;
@ -665,9 +665,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
board.WritePRG(addr - 0x8000, value);
}
if (CoreInputComm.MemoryCallbackSystem.HasWrite)
if (CoreComm.MemoryCallbackSystem.HasWrite)
{
CoreInputComm.MemoryCallbackSystem.TriggerWrite(addr);
CoreComm.MemoryCallbackSystem.TriggerWrite(addr);
}
}

View File

@ -16,11 +16,10 @@ namespace BizHawk.Emulation.Consoles.Nintendo
static readonly bool USE_DATABASE = true;
public RomStatus RomStatus;
public NES(GameInfo game, byte[] rom, byte[] fdsbios = null)
public NES(CoreComm comm, GameInfo game, byte[] rom, byte[] fdsbios = null)
{
CoreOutputComm = new CoreOutputComm();
CoreOutputComm.CpuTraceAvailable = true;
CoreInputComm = new BizHawk.CoreInputComm();
CoreComm = comm;
CoreComm.CpuTraceAvailable = true;
BootGodDB.Initialize();
SetPalette(Palettes.FCEUX_Standard);
videoProvider = new MyVideoProvider(this);
@ -33,8 +32,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
for (int i = 0; i < b.NumSides; i++)
ControllerDefinition.BoolButtons.Add("FDS Insert " + i);
CoreOutputComm.UsesDriveLed = true;
b.SetDriveLightCallback((val) => CoreOutputComm.DriveLED = val);
CoreComm.UsesDriveLed = true;
b.SetDriveLightCallback((val) => CoreComm.DriveLED = val);
}
if (vs_io)
{
@ -149,8 +148,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
NESWatch[] watches;
}
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public DisplayType DisplayType { get { return BizHawk.DisplayType.NTSC; } }
@ -176,8 +174,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public void FillFrameBuffer()
{
int backdrop = 0;
if (emu.CoreInputComm != null)
backdrop = emu.CoreInputComm.NES_BackdropColor;
if (emu.CoreComm != null)
backdrop = emu.CoreComm.NES_BackdropColor;
bool useBackdrop = (backdrop & 0xFF000000) != 0;
//TODO - we could recalculate this on the fly (and invalidate/recalculate it when the palette is changed)
@ -201,7 +199,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
public int BackgroundColor { get { return 0; } }
}
public int FirstDrawLine { get { return videoProvider.top; } set { videoProvider.top = value; CoreOutputComm.ScreenLogicalOffsetY = videoProvider.top; } }
public int FirstDrawLine { get { return videoProvider.top; } set { videoProvider.top = value; CoreComm.ScreenLogicalOffsetY = videoProvider.top; } }
public int LastDrawLine { get { return videoProvider.bottom; } set { videoProvider.bottom = value; } }
public void SetClipLeftAndRight(bool clip)
@ -217,7 +215,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
videoProvider.right = 255;
}
CoreOutputComm.ScreenLogicalOffsetX = videoProvider.left;
CoreComm.ScreenLogicalOffsetX = videoProvider.left;
videoProvider.FillFrameBuffer();
}
@ -698,17 +696,17 @@ namespace BizHawk.Emulation.Consoles.Nintendo
if (origin == EDetectionOrigin.BootGodDB)
{
RomStatus = RomStatus.GoodDump;
CoreOutputComm.RomStatusAnnotation = "Identified from BootGod's database";
CoreComm.RomStatusAnnotation = "Identified from BootGod's database";
}
if (origin == EDetectionOrigin.UNIF)
{
RomStatus = RomStatus.NotInDatabase;
CoreOutputComm.RomStatusAnnotation = "Inferred from UNIF header; somewhat suspicious";
CoreComm.RomStatusAnnotation = "Inferred from UNIF header; somewhat suspicious";
}
if (origin == EDetectionOrigin.INES)
{
RomStatus = RomStatus.NotInDatabase;
CoreOutputComm.RomStatusAnnotation = "Inferred from iNES header; potentially wrong";
CoreComm.RomStatusAnnotation = "Inferred from iNES header; potentially wrong";
}
if (origin == EDetectionOrigin.GameDB)
{
@ -723,7 +721,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
}
LoadReport.Flush();
CoreOutputComm.RomStatusDetails = LoadReport.ToString();
CoreComm.RomStatusDetails = LoadReport.ToString();
//create the board's rom and vrom
if (iNesHeaderInfo != null)

View File

@ -223,7 +223,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
pixelcolor |= 0x8000; //whats this? i think its a flag to indicate a hidden background to be used by the canvas filling logic later
}
if (!nes.CoreInputComm.NES_ShowBG)
if (!nes.CoreComm.NES_ShowBG)
pixelcolor = 0x8000; //whats this? i think its a flag to indicate a hidden background to be used by the canvas filling logic later
//look for a sprite to be drawn
@ -259,7 +259,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
Reg2002_objhit |= (oam->index == 0 && pixel != 0 && rasterpos < 255);
//priority handling, if in front of BG:
bool drawsprite = !(((oam->oam[2] & 0x20) != 0) && ((pixel & 3) != 0));
if (drawsprite && nes.CoreInputComm.NES_ShowOBJ)
if (drawsprite && nes.CoreComm.NES_ShowOBJ)
{
//bring in the palette bits and palettize
spixel |= (oam->oam[2] & 3) << 2;
@ -300,7 +300,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
if (oamcount >= 8 && reg_2001.PPUON)
{
Reg2002_objoverflow = true;
if(!nes.CoreInputComm.NES_UnlimitedSprites)
if(!nes.CoreComm.NES_UnlimitedSprites)
break;
}
//just copy some bytes into the internal sprite buffer

View File

@ -405,7 +405,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
if (hint == "msu1.rom") return "";
//build romfilename
string test = Path.Combine(CoreInputComm.SNES_FirmwaresPath ?? "", hint);
string test = Path.Combine(CoreComm.SNES_FirmwaresPath ?? "", hint);
//does it exist?
if (!File.Exists(test))
@ -422,7 +422,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
void snes_trace(string msg)
{
CoreInputComm.Tracer.Put(msg);
CoreComm.Tracer.Put(msg);
}
public SnesColors.ColorType CurrPalette { get; private set; }
@ -435,8 +435,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_color_lut((IntPtr)p);
}
public LibsnesCore()
public LibsnesCore(CoreComm comm)
{
CoreComm = comm;
}
public void Load(GameInfo game, byte[] romData, byte[] sgbRomData, bool DeterministicEmulation)
@ -506,16 +507,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
if (LibsnesDll.snes_get_region() == LibsnesDll.SNES_REGION.NTSC)
{
//similar to what aviout reports from snes9x and seems logical from bsnes first principles. bsnes uses that numerator (ntsc master clockrate) for sure.
CoreOutputComm.VsyncNum = 21477272;
CoreOutputComm.VsyncDen = 4 * 341 * 262;
CoreComm.VsyncNum = 21477272;
CoreComm.VsyncDen = 4 * 341 * 262;
}
else
{
CoreOutputComm.VsyncNum = 50;
CoreOutputComm.VsyncDen = 1;
CoreComm.VsyncNum = 50;
CoreComm.VsyncDen = 1;
}
CoreOutputComm.CpuTraceAvailable = true;
CoreComm.CpuTraceAvailable = true;
LibsnesDll.snes_power();
@ -547,7 +548,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
ushort snes_input_state(int port, int device, int index, int id)
{
if (!nocallbacks && CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (!nocallbacks && CoreComm.InputCallback != null) CoreComm.InputCallback();
//Console.WriteLine("{0} {1} {2} {3}", port, device, index, id);
string key = "P" + (1 + port) + " ";
@ -663,7 +664,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
savestatebuff = ms.ToArray();
}
if (!nocallbacks && CoreInputComm.Tracer.Enabled)
if (!nocallbacks && CoreComm.Tracer.Enabled)
LibsnesDll.snes_set_trace_callback(tracecb);
else
LibsnesDll.snes_set_trace_callback(null);
@ -680,18 +681,18 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
bool powerSignal = Controller["Power"];
if (powerSignal) LibsnesDll.snes_power();
LibsnesDll.snes_set_layer_enable(0, 0, CoreInputComm.SNES_ShowBG1_0);
LibsnesDll.snes_set_layer_enable(0, 1, CoreInputComm.SNES_ShowBG1_1);
LibsnesDll.snes_set_layer_enable(1, 0, CoreInputComm.SNES_ShowBG2_0);
LibsnesDll.snes_set_layer_enable(1, 1, CoreInputComm.SNES_ShowBG2_1);
LibsnesDll.snes_set_layer_enable(2, 0, CoreInputComm.SNES_ShowBG3_0);
LibsnesDll.snes_set_layer_enable(2, 1, CoreInputComm.SNES_ShowBG3_1);
LibsnesDll.snes_set_layer_enable(3, 0, CoreInputComm.SNES_ShowBG4_0);
LibsnesDll.snes_set_layer_enable(3, 1, CoreInputComm.SNES_ShowBG4_1);
LibsnesDll.snes_set_layer_enable(4, 0, CoreInputComm.SNES_ShowOBJ_0);
LibsnesDll.snes_set_layer_enable(4, 1, CoreInputComm.SNES_ShowOBJ_1);
LibsnesDll.snes_set_layer_enable(4, 2, CoreInputComm.SNES_ShowOBJ_2);
LibsnesDll.snes_set_layer_enable(4, 3, CoreInputComm.SNES_ShowOBJ_3);
LibsnesDll.snes_set_layer_enable(0, 0, CoreComm.SNES_ShowBG1_0);
LibsnesDll.snes_set_layer_enable(0, 1, CoreComm.SNES_ShowBG1_1);
LibsnesDll.snes_set_layer_enable(1, 0, CoreComm.SNES_ShowBG2_0);
LibsnesDll.snes_set_layer_enable(1, 1, CoreComm.SNES_ShowBG2_1);
LibsnesDll.snes_set_layer_enable(2, 0, CoreComm.SNES_ShowBG3_0);
LibsnesDll.snes_set_layer_enable(2, 1, CoreComm.SNES_ShowBG3_1);
LibsnesDll.snes_set_layer_enable(3, 0, CoreComm.SNES_ShowBG4_0);
LibsnesDll.snes_set_layer_enable(3, 1, CoreComm.SNES_ShowBG4_1);
LibsnesDll.snes_set_layer_enable(4, 0, CoreComm.SNES_ShowOBJ_0);
LibsnesDll.snes_set_layer_enable(4, 1, CoreComm.SNES_ShowOBJ_1);
LibsnesDll.snes_set_layer_enable(4, 2, CoreComm.SNES_ShowOBJ_2);
LibsnesDll.snes_set_layer_enable(4, 3, CoreComm.SNES_ShowOBJ_3);
// if the input poll callback is called, it will set this to false
IsLagFrame = true;
@ -1015,10 +1016,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
#endregion
// Arbitrary extensible core comm mechanism
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get { return _CoreOutputComm; } }
CoreOutputComm _CoreOutputComm = new CoreOutputComm();
public CoreComm CoreComm { get; private set; }
// ----- Client Debugging API stuff -----
unsafe MemoryDomain MakeMemoryDomain(string name, LibsnesDll.SNES_MEMORY id, Endian endian)

View File

@ -39,7 +39,7 @@
byte ReadInput()
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
byte value = 0x3F;
int player = SelectedController + 1;

View File

@ -33,9 +33,9 @@
return 0xFF;
}
if (CoreInputComm.MemoryCallbackSystem.HasRead)
if (CoreComm.MemoryCallbackSystem.HasRead)
{
CoreInputComm.MemoryCallbackSystem.TriggerRead(addr);
CoreComm.MemoryCallbackSystem.TriggerRead(addr);
}
Log.Error("MEM", "UNHANDLED READ: {0:X6}", addr);
@ -74,9 +74,9 @@
else
Log.Error("MEM", "UNHANDLED WRITE: {0:X6}:{1:X2}", addr, value);
if (CoreInputComm.MemoryCallbackSystem.HasWrite)
if (CoreComm.MemoryCallbackSystem.HasWrite)
{
CoreInputComm.MemoryCallbackSystem.TriggerWrite(addr);
CoreComm.MemoryCallbackSystem.TriggerWrite(addr);
}
}
}

View File

@ -51,10 +51,10 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
// 21,477,270 Machine clocks / sec
// 7,159,090 Cpu cycles / sec
public PCEngine(GameInfo game, byte[] rom)
public PCEngine(CoreComm comm, GameInfo game, byte[] rom)
{
CoreOutputComm = new CoreOutputComm();
CoreOutputComm.CpuTraceAvailable = true;
CoreComm = comm;
CoreComm.CpuTraceAvailable = true;
switch (game.System)
{
@ -70,17 +70,17 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
Init(game, rom);
}
public PCEngine(GameInfo game, Disc disc, byte[] rom)
public PCEngine(CoreComm comm, GameInfo game, Disc disc, byte[] rom)
{
CoreComm = comm;
CoreComm.CpuTraceAvailable = true;
CoreComm.UsesDriveLed = true;
systemid = "PCECD";
CoreOutputComm = new CoreOutputComm();
CoreOutputComm.CpuTraceAvailable = true;
CoreOutputComm.UsesDriveLed = true;
Type = NecSystemType.TurboCD;
this.disc = disc;
Init(game, rom);
// the default RomStatusDetails don't do anything with Disc
CoreOutputComm.RomStatusDetails = string.Format("{0}\r\nDisk partial hash:{1}", game.Name, disc.GetHash());
CoreComm.RomStatusDetails = string.Format("{0}\r\nDisk partial hash:{1}", game.Name, disc.GetHash());
}
void Init(GameInfo game, byte[] rom)
@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
PSG = new HuC6280PSG();
SCSI = new ScsiCDBus(this, disc);
Cpu.Logger = (s) => CoreInputComm.Tracer.Put(s);
Cpu.Logger = (s) => CoreComm.Tracer.Put(s);
if (TurboGrafx)
{
@ -244,12 +244,12 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public void FrameAdvance(bool render, bool rendersound)
{
lagged = true;
CoreOutputComm.DriveLED = false;
CoreComm.DriveLED = false;
Controller.UpdateControls(Frame++);
PSG.BeginFrame(Cpu.TotalExecutedCycles);
Cpu.Debug = CoreInputComm.Tracer.Enabled;
Cpu.Debug = CoreComm.Tracer.Enabled;
if (SuperGrafx)
VPC.ExecFrame(render);
else
@ -268,8 +268,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
islag = false;
}
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public IVideoProvider VideoProvider
{

View File

@ -166,7 +166,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
if (DataReadInProgress && pce.Cpu.TotalExecutedCycles > DataReadWaitTimer)
{
if (SectorsLeftToRead > 0)
pce.CoreOutputComm.DriveLED = true;
pce.CoreComm.DriveLED = true;
if (DataIn.Count == 0)
{

View File

@ -108,8 +108,8 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
if (ActiveLine >= FrameHeight)
return;
RenderBackgroundScanline(pce.CoreInputComm.PCE_ShowBG1);
RenderSpritesScanline(pce.CoreInputComm.PCE_ShowOBJ1);
RenderBackgroundScanline(pce.CoreComm.PCE_ShowBG1);
RenderSpritesScanline(pce.CoreComm.PCE_ShowOBJ1);
}
void RenderBackgroundScanline(bool show)

View File

@ -267,16 +267,16 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
switch (EffectivePriorityMode)
{
case 0:
RenderBackgroundScanline(VDC1, 12, PCE.CoreInputComm.PCE_ShowBG1);
RenderBackgroundScanline(VDC2, 2, PCE.CoreInputComm.PCE_ShowBG2);
RenderSpritesScanline(VDC1, 11, 14, PCE.CoreInputComm.PCE_ShowOBJ1);
RenderSpritesScanline(VDC2, 1, 3, PCE.CoreInputComm.PCE_ShowOBJ2);
RenderBackgroundScanline(VDC1, 12, PCE.CoreComm.PCE_ShowBG1);
RenderBackgroundScanline(VDC2, 2, PCE.CoreComm.PCE_ShowBG2);
RenderSpritesScanline(VDC1, 11, 14, PCE.CoreComm.PCE_ShowOBJ1);
RenderSpritesScanline(VDC2, 1, 3, PCE.CoreComm.PCE_ShowOBJ2);
break;
case 1:
RenderBackgroundScanline(VDC1, 12, PCE.CoreInputComm.PCE_ShowBG1);
RenderBackgroundScanline(VDC2, 2, PCE.CoreInputComm.PCE_ShowBG2);
RenderSpritesScanline(VDC1, 11, 14, PCE.CoreInputComm.PCE_ShowOBJ1);
RenderSpritesScanline(VDC2, 1, 13, PCE.CoreInputComm.PCE_ShowOBJ2);
RenderBackgroundScanline(VDC1, 12, PCE.CoreComm.PCE_ShowBG1);
RenderBackgroundScanline(VDC2, 2, PCE.CoreComm.PCE_ShowBG2);
RenderSpritesScanline(VDC1, 11, 14, PCE.CoreComm.PCE_ShowOBJ1);
RenderSpritesScanline(VDC2, 1, 13, PCE.CoreComm.PCE_ShowOBJ2);
break;
}
}

View File

@ -14,8 +14,7 @@ namespace BizHawk.Emulation.Consoles.PSX
private int[] frameBuffer = new int[0];
private Random rand = new Random();
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public IVideoProvider VideoProvider { get { return this; } }
public ISoundProvider SoundProvider { get { return this; } }
public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(this, 735); } }
@ -50,11 +49,10 @@ namespace BizHawk.Emulation.Consoles.PSX
//BizHawk.Emulation.Consoles.Nintendo.SNES.LibsnesDll.snes_set_audio_sample(null);
}
public Octoshock()
public Octoshock(CoreComm comm)
{
var domains = new List<MemoryDomain>();
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
CoreComm = comm;
VirtualWidth = BufferWidth = 256;
BufferHeight = 192;
}
@ -121,7 +119,7 @@ namespace BizHawk.Emulation.Consoles.PSX
if (parts[0] != "$psx") throw new InvalidOperationException("Octoshock using some weird path we dont handle yet");
if (parts[1] == "firmware")
{
fname = Path.Combine(CurrOctoshockCore.CoreInputComm.PSX_FirmwaresPath, parts[2]);
fname = Path.Combine(CurrOctoshockCore.CoreComm.PSX_FirmwaresPath, parts[2]);
if (!File.Exists(fname))
{
System.Windows.Forms.MessageBox.Show("the Octoshock core is referencing a firmware file which could not be found. Please make sure it's in your configured PSX firmwares folder. The referenced filename is: " + parts[1]);

View File

@ -73,9 +73,9 @@ namespace BizHawk.Emulation.Consoles.Sega
WriteCallback write32;
#endif
public Genesis(GameInfo game, byte[] rom)
public Genesis(CoreComm comm, GameInfo game, byte[] rom)
{
CoreOutputComm = new CoreOutputComm();
CoreComm = comm;
MainCPU = new MC68000();
SoundCPU = new Z80A();
YM2612 = new YM2612() { MaxVolume = 23405 };
@ -250,8 +250,7 @@ namespace BizHawk.Emulation.Consoles.Sega
unchecked { VDP.VdpStatusWord &= (ushort)~GenVDP.StatusVerticalInterruptPending; }
}
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public IVideoProvider VideoProvider
{

View File

@ -106,7 +106,7 @@
void ReadController(ref byte data)
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
data &= 0xC0;
if ((data & 0x40) != 0) // TH high
{

View File

@ -18,7 +18,7 @@
byte ReadControls1()
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
lagged = false;
byte value = 0xFF;
@ -37,7 +37,7 @@
byte ReadControls2()
{
if (CoreInputComm.InputCallback != null) CoreInputComm.InputCallback();
if (CoreComm.InputCallback != null) CoreComm.InputCallback();
lagged = false;
byte value = 0xFF;

View File

@ -43,9 +43,9 @@
ret = SystemRam[address & RamSizeMask];
}
if (CoreInputComm.MemoryCallbackSystem.HasRead)
if (CoreComm.MemoryCallbackSystem.HasRead)
{
CoreInputComm.MemoryCallbackSystem.TriggerRead(address);
CoreComm.MemoryCallbackSystem.TriggerRead(address);
}
return ret;
@ -81,9 +81,9 @@
return;
}
if (CoreInputComm.MemoryCallbackSystem.HasWrite)
if (CoreComm.MemoryCallbackSystem.HasWrite)
{
CoreInputComm.MemoryCallbackSystem.TriggerWrite(address);
CoreComm.MemoryCallbackSystem.TriggerWrite(address);
}
}

View File

@ -85,12 +85,13 @@ namespace BizHawk.Emulation.Consoles.Sega
public DisplayType DisplayType { get; set; }
public bool DeterministicEmulation { get { return true; } }
public SMS(GameInfo game, byte[] rom)
public SMS(CoreComm comm, GameInfo game, byte[] rom)
{
IsGameGear = game.System == "GG";
CoreComm = comm;
IsGameGear = game.System == "GG";
RomData = rom;
CoreOutputComm = new CoreOutputComm();
CoreOutputComm.CpuTraceAvailable = true;
CoreComm.CpuTraceAvailable = true;
if (RomData.Length % BankSize != 0)
Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize);
@ -98,8 +99,8 @@ namespace BizHawk.Emulation.Consoles.Sega
DisplayType = DisplayType.NTSC;
if (game["PAL"]) DisplayType = DisplayType.PAL;
CoreOutputComm.VsyncNum = DisplayType == DisplayType.NTSC ? 60 : 50;
CoreOutputComm.VsyncDen = 1;
CoreComm.VsyncNum = DisplayType == DisplayType.NTSC ? 60 : 50;
CoreComm.VsyncDen = 1;
if (game["Japan"]) Region = "Japan";
if (game.NotInDatabase || game["FM"] && game["UseFM"])
@ -201,9 +202,9 @@ namespace BizHawk.Emulation.Consoles.Sega
lagged = true;
Controller.UpdateControls(Frame++);
PSG.BeginFrame(Cpu.TotalExecutedCycles);
Cpu.Debug = CoreInputComm.Tracer.Enabled;
if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreInputComm/CoreOutputComm first
Cpu.Logger = (s) => CoreInputComm.Tracer.Put(s);
Cpu.Debug = CoreComm.Tracer.Enabled;
if (Cpu.Debug && Cpu.Logger == null) // TODO, lets not do this on each frame. But lets refactor CoreComm/CoreComm first
Cpu.Logger = (s) => CoreComm.Tracer.Put(s);
if (IsGameGear == false)
Cpu.NonMaskableInterrupt = Controller["Pause"];
@ -359,8 +360,7 @@ namespace BizHawk.Emulation.Consoles.Sega
}
public IVideoProvider VideoProvider { get { return Vdp; } }
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
ISoundProvider ActiveSoundProvider;
public ISoundProvider SoundProvider { get { return ActiveSoundProvider; } }

View File

@ -289,7 +289,7 @@ namespace BizHawk.Emulation.Consoles.Sega
if (mode == VdpMode.GameGear)
{
if (Sms.CoreInputComm.GG_ShowClippedRegions == false)
if (Sms.CoreComm.GG_ShowClippedRegions == false)
{
int yStart = (FrameHeight - 144)/2;
for (int y = 0; y < 144; y++)
@ -297,7 +297,7 @@ namespace BizHawk.Emulation.Consoles.Sega
GameGearFrameBuffer[(y * 160) + x] = FrameBuffer[((y + yStart) * 256) + x + 48];
}
if (Sms.CoreInputComm.GG_HighlightActiveDisplayRegion && Sms.CoreInputComm.GG_ShowClippedRegions)
if (Sms.CoreComm.GG_HighlightActiveDisplayRegion && Sms.CoreComm.GG_ShowClippedRegions)
{
// Top 24 scanlines
for (int y = 0; y < 24; y++)

View File

@ -377,28 +377,28 @@ namespace BizHawk.Emulation.Consoles.Sega
return;
}
RenderBackgroundCurrentLine(Sms.CoreInputComm.SMS_ShowBG);
RenderBackgroundCurrentLine(Sms.CoreComm.SMS_ShowBG);
if (EnableDoubledSprites)
RenderSpritesCurrentLineDoubleSize(Sms.CoreInputComm.SMS_ShowOBJ);
RenderSpritesCurrentLineDoubleSize(Sms.CoreComm.SMS_ShowOBJ);
else
RenderSpritesCurrentLine(Sms.CoreInputComm.SMS_ShowOBJ);
RenderSpritesCurrentLine(Sms.CoreComm.SMS_ShowOBJ);
}
else if (TmsMode == 2)
{
if (render == false)
return;
RenderBackgroundM2(Sms.CoreInputComm.SMS_ShowBG);
RenderTmsSprites(Sms.CoreInputComm.SMS_ShowOBJ);
RenderBackgroundM2(Sms.CoreComm.SMS_ShowBG);
RenderTmsSprites(Sms.CoreComm.SMS_ShowOBJ);
}
else if (TmsMode == 0)
{
if (render == false)
return;
RenderBackgroundM0(Sms.CoreInputComm.SMS_ShowBG);
RenderTmsSprites(Sms.CoreInputComm.SMS_ShowOBJ);
RenderBackgroundM0(Sms.CoreComm.SMS_ShowBG);
RenderTmsSprites(Sms.CoreComm.SMS_ShowOBJ);
}
}
@ -496,7 +496,7 @@ namespace BizHawk.Emulation.Consoles.Sega
public int[] GetVideoBuffer()
{
if (mode == VdpMode.SMS || Sms.CoreInputComm.GG_ShowClippedRegions)
if (mode == VdpMode.SMS || Sms.CoreComm.GG_ShowClippedRegions)
return FrameBuffer;
return GameGearFrameBuffer;
}
@ -506,7 +506,7 @@ namespace BizHawk.Emulation.Consoles.Sega
{
get
{
if (mode == VdpMode.SMS || Sms.CoreInputComm.GG_ShowClippedRegions)
if (mode == VdpMode.SMS || Sms.CoreComm.GG_ShowClippedRegions)
return 256;
return 160; // GameGear
}
@ -516,7 +516,7 @@ namespace BizHawk.Emulation.Consoles.Sega
{
get
{
if (mode == VdpMode.SMS || Sms.CoreInputComm.GG_ShowClippedRegions)
if (mode == VdpMode.SMS || Sms.CoreComm.GG_ShowClippedRegions)
return FrameHeight;
return 144; // GameGear
}

View File

@ -11,21 +11,19 @@ namespace BizHawk
private int[] frameBuffer = new int[256 * 192];
private Random rand = new Random();
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public CoreComm CoreComm { get; private set; }
public IVideoProvider VideoProvider { get { return this; } }
public ISoundProvider SoundProvider { get { return this; } }
public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(this, 735); } }
public bool StartAsyncSound() { return true; }
public void EndAsyncSound() { }
public NullEmulator()
public NullEmulator(CoreComm comm)
{
CoreComm = comm;
var domains = new List<MemoryDomain>(1);
domains.Add(new MemoryDomain("Main RAM", 1, Endian.Little, addr => 0, (a, v) => { }));
memoryDomains = domains.AsReadOnly();
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
}
public void ResetFrameCounter()
{

View File

@ -1,7 +1,7 @@
using System.Text;
namespace BizHawk
{
public class CoreInputComm
public class CoreComm
{
public int NES_BackdropColor;
public bool NES_UnlimitedSprites;
@ -32,10 +32,7 @@ namespace BizHawk
public System.Action InputCallback;
public MemoryCallbackSystem MemoryCallbackSystem = new MemoryCallbackSystem();
}
public class CoreOutputComm
{
public double VsyncRate
{
get

View File

@ -62,9 +62,10 @@ namespace BizHawk
void LoadStateBinary(BinaryReader reader);
byte[] SaveStateBinary();
// Arbitrary extensible core comm mechanism
CoreInputComm CoreInputComm { get; set; }
CoreOutputComm CoreOutputComm { get; }
/// <summary>
/// the corecomm module in use by this core.
/// </summary>
CoreComm CoreComm { get; }
// ----- Client Debugging API stuff -----
IList<MemoryDomain> MemoryDomains { get; }

View File

@ -85,8 +85,8 @@ namespace BizHawk.MultiClient
private void buttonAuto_Click(object sender, EventArgs e)
{
numericTextBoxW.Text = Global.Emulator.CoreOutputComm.NominalWidth.ToString();
numericTextBoxH.Text = Global.Emulator.CoreOutputComm.NominalHeight.ToString();
numericTextBoxW.Text = Global.Emulator.CoreComm.NominalWidth.ToString();
numericTextBoxH.Text = Global.Emulator.CoreComm.NominalHeight.ToString();
}
private void buttonOK_Click(object sender, EventArgs e)

View File

@ -21,7 +21,7 @@ namespace BizHawk.MultiClient
public static DisplayManager DisplayManager = new DisplayManager();
public static Config Config;
public static IEmulator Emulator;
public static CoreInputComm CoreInputComm;
public static CoreComm CoreComm;
public static GameInfo Game;
public static Controller SMSControls;
public static Controller PCEControls;

View File

@ -650,8 +650,8 @@ namespace BizHawk.MultiClient
}
else
{
dx -= Global.Emulator.CoreOutputComm.ScreenLogicalOffsetX;
dy -= Global.Emulator.CoreOutputComm.ScreenLogicalOffsetY;
dx -= Global.Emulator.CoreComm.ScreenLogicalOffsetX;
dy -= Global.Emulator.CoreComm.ScreenLogicalOffsetY;
}
Global.OSD.AddGUIText(luaStr.ToString(), dx, dy, alert, GetColor(background), GetColor(forecolor),
@ -871,8 +871,8 @@ namespace BizHawk.MultiClient
Graphics GetGraphics()
{
var g = luaSurface.GetGraphics();
int tx = Global.Emulator.CoreOutputComm.ScreenLogicalOffsetX;
int ty = Global.Emulator.CoreOutputComm.ScreenLogicalOffsetY;
int tx = Global.Emulator.CoreComm.ScreenLogicalOffsetX;
int ty = Global.Emulator.CoreComm.ScreenLogicalOffsetY;
if (tx != 0 || ty != 0)
{
var transform = g.Transform;
@ -1159,23 +1159,23 @@ namespace BizHawk.MultiClient
{
if (Global.Emulator is BizHawk.Emulation.Consoles.Nintendo.NES)
{
Global.CoreInputComm.NES_ShowOBJ = Global.Config.NESDispSprites = (bool)lua_p[0];
Global.CoreInputComm.NES_ShowBG = Global.Config.NESDispBackground = (bool)lua_p[1];
Global.CoreComm.NES_ShowOBJ = Global.Config.NESDispSprites = (bool)lua_p[0];
Global.CoreComm.NES_ShowBG = Global.Config.NESDispBackground = (bool)lua_p[1];
}
else if (Global.Emulator is BizHawk.Emulation.Consoles.TurboGrafx.PCEngine)
{
Global.CoreInputComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1 = (bool)lua_p[0];
Global.CoreInputComm.PCE_ShowBG1 = Global.Config.PCEDispBG1 = (bool)lua_p[1];
Global.CoreComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1 = (bool)lua_p[0];
Global.CoreComm.PCE_ShowBG1 = Global.Config.PCEDispBG1 = (bool)lua_p[1];
if (lua_p.Length > 2)
{
Global.CoreInputComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2 = (bool)lua_p[2];
Global.CoreInputComm.PCE_ShowBG2 = Global.Config.PCEDispBG2 = (bool)lua_p[3];
Global.CoreComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2 = (bool)lua_p[2];
Global.CoreComm.PCE_ShowBG2 = Global.Config.PCEDispBG2 = (bool)lua_p[3];
}
}
else if (Global.Emulator is BizHawk.Emulation.Consoles.Sega.SMS)
{
Global.CoreInputComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ = (bool)lua_p[0];
Global.CoreInputComm.SMS_ShowBG = Global.Config.SMSDispBG = (bool)lua_p[1];
Global.CoreComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ = (bool)lua_p[0];
Global.CoreComm.SMS_ShowBG = Global.Config.SMSDispBG = (bool)lua_p[1];
}
}
@ -1183,7 +1183,7 @@ namespace BizHawk.MultiClient
{
if (luaf != null)
{
Global.Emulator.CoreInputComm.InputCallback = delegate()
Global.Emulator.CoreComm.InputCallback = delegate()
{
try
{
@ -1198,7 +1198,7 @@ namespace BizHawk.MultiClient
};
}
else
Global.Emulator.CoreInputComm.InputCallback = null;
Global.Emulator.CoreComm.InputCallback = null;
}
//----------------------------------------------------
@ -2609,7 +2609,7 @@ namespace BizHawk.MultiClient
public void nes_setdispbackground(bool show)
{
Global.Config.NESDispBackground = show;
Global.MainForm.SyncCoreInputComm();
Global.MainForm.SyncCoreCommInputSignals();
}
public bool nes_getdispsprites()
@ -2620,7 +2620,7 @@ namespace BizHawk.MultiClient
public void nes_setdispsprites(bool show)
{
Global.Config.NESDispSprites = show;
Global.MainForm.SyncCoreInputComm();
Global.MainForm.SyncCoreCommInputSignals();
}
public bool nes_getallowmorethaneightsprites()
@ -2633,7 +2633,7 @@ namespace BizHawk.MultiClient
Global.Config.NESAllowMoreThanEightSprites = allow;
if (Global.Emulator is NES)
{
(Global.Emulator as NES).CoreInputComm.NES_UnlimitedSprites = allow;
(Global.Emulator as NES).CoreComm.NES_UnlimitedSprites = allow;
}
}
@ -2722,8 +2722,8 @@ namespace BizHawk.MultiClient
_addr = LuaInt(address);
}
Global.Emulator.CoreInputComm.MemoryCallbackSystem.ReadAddr = _addr;
Global.Emulator.CoreInputComm.MemoryCallbackSystem.SetReadCallback(delegate(uint addr)
Global.Emulator.CoreComm.MemoryCallbackSystem.ReadAddr = _addr;
Global.Emulator.CoreComm.MemoryCallbackSystem.SetReadCallback(delegate(uint addr)
{
try
{
@ -2740,7 +2740,7 @@ namespace BizHawk.MultiClient
}
else
{
Global.Emulator.CoreInputComm.MemoryCallbackSystem.SetReadCallback(null);
Global.Emulator.CoreComm.MemoryCallbackSystem.SetReadCallback(null);
}
}
@ -2760,8 +2760,8 @@ namespace BizHawk.MultiClient
_addr = LuaInt(address);
}
Global.Emulator.CoreInputComm.MemoryCallbackSystem.WriteAddr = _addr;
Global.Emulator.CoreInputComm.MemoryCallbackSystem.SetWriteCallback(delegate(uint addr)
Global.Emulator.CoreComm.MemoryCallbackSystem.WriteAddr = _addr;
Global.Emulator.CoreComm.MemoryCallbackSystem.SetWriteCallback(delegate(uint addr)
{
try
{
@ -2777,7 +2777,7 @@ namespace BizHawk.MultiClient
}
else
{
Global.Emulator.CoreInputComm.MemoryCallbackSystem.SetWriteCallback(null);
Global.Emulator.CoreComm.MemoryCallbackSystem.SetWriteCallback(null);
}
}
}

View File

@ -23,7 +23,7 @@ namespace BizHawk.MultiClient
private void DumpStatus_Click(object sender, EventArgs e)
{
string details = Global.Emulator.CoreOutputComm.RomStatusDetails;
string details = Global.Emulator.CoreComm.RomStatusDetails;
if (string.IsNullOrEmpty(details)) return;
Global.Sound.StopSound();
LogWindow.ShowReport("Dump Status Report", details, this);
@ -670,7 +670,7 @@ namespace BizHawk.MultiClient
tAStudioToolStripMenuItem.ShortcutKeyDisplayString = Global.Config.TASTudio;
virtualPadToolStripMenuItem.ShortcutKeyDisplayString = Global.Config.OpenVirtualPadBinding;
if (Global.Emulator.CoreOutputComm.CpuTraceAvailable)
if (Global.Emulator.CoreComm.CpuTraceAvailable)
{
traceLoggerToolStripMenuItem.Enabled = true;
}
@ -884,21 +884,21 @@ namespace BizHawk.MultiClient
{
NESGraphicsConfig g = new NESGraphicsConfig();
g.ShowDialog();
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void pceGraphicsSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
PCEGraphicsConfig g = new PCEGraphicsConfig();
g.ShowDialog();
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void smsGraphicsSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
SMSGraphicsConfig g = new SMSGraphicsConfig();
g.ShowDialog();
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
public void MainForm_MouseClick(object sender, MouseEventArgs e)
@ -1815,7 +1815,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_0 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG1_1)
{
Global.OSD.AddMessage("BG 1 Layer On");
@ -1832,7 +1832,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_0 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG2_1)
{
Global.OSD.AddMessage("BG 2 Layer On");
@ -1849,7 +1849,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_0 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG3_1)
{
Global.OSD.AddMessage("BG 3 Layer On");
@ -1866,7 +1866,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_0 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG4_1)
{
Global.OSD.AddMessage("BG 4 Layer On");
@ -1883,7 +1883,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowOBJ1 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ1)
{
Global.OSD.AddMessage("OBJ 1 Layer On");
@ -1900,7 +1900,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowOBJ2 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ2)
{
Global.OSD.AddMessage("OBJ 2 Layer On");
@ -1917,7 +1917,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowOBJ3 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ3)
{
Global.OSD.AddMessage("OBJ 3 Layer On");
@ -1934,7 +1934,7 @@ namespace BizHawk.MultiClient
if (Global.Emulator is LibsnesCore)
{
Global.Config.SNES_ShowOBJ4 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ4)
{
Global.OSD.AddMessage("OBJ 4 Layer On");

View File

@ -129,8 +129,8 @@ namespace BizHawk.MultiClient
return Util.ReadAllBytes(NesCartFile.GetStream());
};
Global.MainForm = this;
Global.CoreInputComm = new CoreInputComm();
SyncCoreInputComm();
//Global.CoreComm = new CoreComm();
//SyncCoreCommInputSignals();
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
@ -165,7 +165,9 @@ namespace BizHawk.MultiClient
Input.Initialize();
InitControls();
Global.Emulator = new NullEmulator();
Global.CoreComm = new CoreComm();
SyncCoreCommInputSignals();
Global.Emulator = new NullEmulator(Global.CoreComm);
Global.ActiveController = Global.NullControls;
Global.AutoFireController = Global.AutofireNullControls;
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
@ -308,7 +310,7 @@ namespace BizHawk.MultiClient
LoadSNESGraphicsDebugger();
if (Global.Config.TraceLoggerAutoLoad)
{
if (Global.Emulator.CoreOutputComm.CpuTraceAvailable)
if (Global.CoreComm.CpuTraceAvailable)
{
LoadTraceLogger();
}
@ -356,47 +358,52 @@ namespace BizHawk.MultiClient
base.Dispose(disposing);
}
public void SyncCoreInputComm()
public void SyncCoreCommInputSignals(CoreComm target)
{
Global.CoreInputComm.NES_BackdropColor = Global.Config.NESBackgroundColor;
Global.CoreInputComm.NES_UnlimitedSprites = Global.Config.NESAllowMoreThanEightSprites;
Global.CoreInputComm.NES_ShowBG = Global.Config.NESDispBackground;
Global.CoreInputComm.NES_ShowOBJ = Global.Config.NESDispSprites;
Global.CoreInputComm.PCE_ShowBG1 = Global.Config.PCEDispBG1;
Global.CoreInputComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1;
Global.CoreInputComm.PCE_ShowBG2 = Global.Config.PCEDispBG2;
Global.CoreInputComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2;
Global.CoreInputComm.SMS_ShowBG = Global.Config.SMSDispBG;
Global.CoreInputComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ;
target.NES_BackdropColor = Global.Config.NESBackgroundColor;
target.NES_UnlimitedSprites = Global.Config.NESAllowMoreThanEightSprites;
target.NES_ShowBG = Global.Config.NESDispBackground;
target.NES_ShowOBJ = Global.Config.NESDispSprites;
target.PCE_ShowBG1 = Global.Config.PCEDispBG1;
target.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1;
target.PCE_ShowBG2 = Global.Config.PCEDispBG2;
target.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2;
target.SMS_ShowBG = Global.Config.SMSDispBG;
target.SMS_ShowOBJ = Global.Config.SMSDispOBJ;
Global.CoreInputComm.PSX_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX");
target.PSX_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathPSXFirmwares, "PSX");
Global.CoreInputComm.C64_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64");
target.C64_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathC64Firmwares, "C64");
Global.CoreInputComm.SNES_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES");
Global.CoreInputComm.SNES_ShowBG1_0 = Global.Config.SNES_ShowBG1_0;
Global.CoreInputComm.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_1;
Global.CoreInputComm.SNES_ShowBG2_0 = Global.Config.SNES_ShowBG2_0;
Global.CoreInputComm.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_1;
Global.CoreInputComm.SNES_ShowBG3_0 = Global.Config.SNES_ShowBG3_0;
Global.CoreInputComm.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_1;
Global.CoreInputComm.SNES_ShowBG4_0 = Global.Config.SNES_ShowBG4_0;
Global.CoreInputComm.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_1;
Global.CoreInputComm.SNES_ShowOBJ_0 = Global.Config.SNES_ShowOBJ1;
Global.CoreInputComm.SNES_ShowOBJ_1 = Global.Config.SNES_ShowOBJ2;
Global.CoreInputComm.SNES_ShowOBJ_2 = Global.Config.SNES_ShowOBJ3;
Global.CoreInputComm.SNES_ShowOBJ_3 = Global.Config.SNES_ShowOBJ4;
target.SNES_FirmwaresPath = PathManager.MakeAbsolutePath(Global.Config.PathSNESFirmwares, "SNES");
target.SNES_ShowBG1_0 = Global.Config.SNES_ShowBG1_0;
target.SNES_ShowBG1_1 = Global.Config.SNES_ShowBG1_1;
target.SNES_ShowBG2_0 = Global.Config.SNES_ShowBG2_0;
target.SNES_ShowBG2_1 = Global.Config.SNES_ShowBG2_1;
target.SNES_ShowBG3_0 = Global.Config.SNES_ShowBG3_0;
target.SNES_ShowBG3_1 = Global.Config.SNES_ShowBG3_1;
target.SNES_ShowBG4_0 = Global.Config.SNES_ShowBG4_0;
target.SNES_ShowBG4_1 = Global.Config.SNES_ShowBG4_1;
target.SNES_ShowOBJ_0 = Global.Config.SNES_ShowOBJ1;
target.SNES_ShowOBJ_1 = Global.Config.SNES_ShowOBJ2;
target.SNES_ShowOBJ_2 = Global.Config.SNES_ShowOBJ3;
target.SNES_ShowOBJ_3 = Global.Config.SNES_ShowOBJ4;
Global.CoreInputComm.GG_HighlightActiveDisplayRegion = Global.Config.GGHighlightActiveDisplayRegion;
Global.CoreInputComm.GG_ShowClippedRegions = Global.Config.GGShowClippedRegions;
target.GG_HighlightActiveDisplayRegion = Global.Config.GGHighlightActiveDisplayRegion;
target.GG_ShowClippedRegions = Global.Config.GGShowClippedRegions;
Global.CoreInputComm.Atari2600_ShowBG = Global.Config.Atari2600_ShowBG;
Global.CoreInputComm.Atari2600_ShowPlayer1 = Global.Config.Atari2600_ShowPlayer1;
Global.CoreInputComm.Atari2600_ShowPlayer2 = Global.Config.Atari2600_ShowPlayer2;
Global.CoreInputComm.Atari2600_ShowMissle1 = Global.Config.Atari2600_ShowMissle1;
Global.CoreInputComm.Atari2600_ShowMissle2 = Global.Config.Atari2600_ShowMissle2;
Global.CoreInputComm.Atari2600_ShowBall = Global.Config.Atari2600_ShowBall;
Global.CoreInputComm.Atari2600_ShowPF = Global.Config.Atari2600_ShowPlayfield;
target.Atari2600_ShowBG = Global.Config.Atari2600_ShowBG;
target.Atari2600_ShowPlayer1 = Global.Config.Atari2600_ShowPlayer1;
target.Atari2600_ShowPlayer2 = Global.Config.Atari2600_ShowPlayer2;
target.Atari2600_ShowMissle1 = Global.Config.Atari2600_ShowMissle1;
target.Atari2600_ShowMissle2 = Global.Config.Atari2600_ShowMissle2;
target.Atari2600_ShowBall = Global.Config.Atari2600_ShowBall;
target.Atari2600_ShowPF = Global.Config.Atari2600_ShowPlayfield;
}
public void SyncCoreCommInputSignals()
{
SyncCoreCommInputSignals(Global.CoreComm);
}
void SyncPresentationMode()
@ -467,7 +474,7 @@ namespace BizHawk.MultiClient
Global.ForceNoThrottle = unthrottled || fastforward;
// realtime throttle is never going to be so exact that using a double here is wrong
throttle.SetCoreFps(Global.Emulator.CoreOutputComm.VsyncRate);
throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate);
throttle.signal_paused = EmulatorPaused || Global.Emulator is NullEmulator;
throttle.signal_unthrottle = unthrottled;
@ -1588,6 +1595,8 @@ namespace BizHawk.MultiClient
IEmulator nextEmulator = null;
RomGame rom = null;
GameInfo game = null;
CoreComm nextComm = new CoreComm();
SyncCoreCommInputSignals(nextComm);
try
{
@ -1649,11 +1658,10 @@ namespace BizHawk.MultiClient
{
case "PSX":
{
var psx = new BizHawk.Emulation.Consoles.PSX.Octoshock();
var psx = new BizHawk.Emulation.Consoles.PSX.Octoshock(nextComm);
nextEmulator = psx;
psx.CoreInputComm = Global.CoreInputComm;
psx.LoadCuePath(file.CanonicalFullPath);
nextEmulator.CoreOutputComm.RomStatusDetails = "PSX etc.";
nextEmulator.CoreComm.RomStatusDetails = "PSX etc.";
}
break;
@ -1690,7 +1698,7 @@ namespace BizHawk.MultiClient
game.FirmwareHash = Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom.RomData));
nextEmulator = new PCEngine(game, disc, rom.RomData);
nextEmulator = new PCEngine(nextComm, game, disc, rom.RomData);
break;
}
}
@ -1706,9 +1714,8 @@ namespace BizHawk.MultiClient
case "SNES":
{
game.System = "SNES";
var snes = new LibsnesCore();
var snes = new LibsnesCore(nextComm);
nextEmulator = snes;
nextEmulator.CoreInputComm = Global.CoreInputComm;
snes.Load(game, rom.FileData, null, deterministicemulation);
}
break;
@ -1718,15 +1725,15 @@ namespace BizHawk.MultiClient
if (Global.Config.SmsAllowOverlock) game.AddOption("AllowOverclock");
if (Global.Config.SmsForceStereoSeparation) game.AddOption("ForceStereo");
if (Global.Config.SmsSpriteLimit) game.AddOption("SpriteLimit");
nextEmulator = new SMS(game, rom.RomData);
nextEmulator = new SMS(nextComm, game, rom.RomData);
break;
case "GG":
if (Global.Config.SmsAllowOverlock) game.AddOption("AllowOverclock");
if (Global.Config.SmsSpriteLimit) game.AddOption("SpriteLimit");
nextEmulator = new SMS(game, rom.RomData);
nextEmulator = new SMS(nextComm, game, rom.RomData);
break;
case "A26":
nextEmulator = new Atari2600(game, rom.FileData);
nextEmulator = new Atari2600(nextComm, game, rom.FileData);
((Atari2600)nextEmulator).SetBw(Global.Config.Atari2600_BW);
((Atari2600)nextEmulator).SetP0Diff(Global.Config.Atari2600_LeftDifficulty);
((Atari2600)nextEmulator).SetP1Diff(Global.Config.Atari2600_RightDifficulty);
@ -1735,13 +1742,13 @@ namespace BizHawk.MultiClient
case "PCECD":
case "SGX":
if (Global.Config.PceSpriteLimit) game.AddOption("ForceSpriteLimit");
nextEmulator = new PCEngine(game, rom.RomData);
nextEmulator = new PCEngine(nextComm, game, rom.RomData);
break;
case "GEN":
nextEmulator = new Genesis(game, rom.RomData);
nextEmulator = new Genesis(nextComm, game, rom.RomData);
break;
case "TI83":
nextEmulator = new TI83(game, rom.RomData);
nextEmulator = new TI83(nextComm, game, rom.RomData);
if (Global.Config.TI83autoloadKeyPad)
LoadTI83KeyPad();
break;
@ -1762,7 +1769,7 @@ namespace BizHawk.MultiClient
}
}
NES nes = new NES(game, rom.FileData, bios);
NES nes = new NES(nextComm, game, rom.FileData, bios);
nes.SoundOn = Global.Config.SoundEnabled;
nes.FirstDrawLine = Global.Config.NESTopLine;
nes.LastDrawLine = Global.Config.NESBottomLine;
@ -1783,7 +1790,7 @@ namespace BizHawk.MultiClient
if (Global.Config.GB_ForceDMG) game.AddOption("ForceDMG");
if (Global.Config.GB_GBACGB) game.AddOption("GBACGB");
if (Global.Config.GB_MulticartCompat) game.AddOption("MulitcartCompat");
Emulation.Consoles.GB.Gameboy gb = new Emulation.Consoles.GB.Gameboy(game, rom.FileData);
Emulation.Consoles.GB.Gameboy gb = new Emulation.Consoles.GB.Gameboy(nextComm, game, rom.FileData);
nextEmulator = gb;
if (gb.IsCGBMode())
{
@ -1832,7 +1839,7 @@ namespace BizHawk.MultiClient
{
game.System = "SNES";
game.AddOption("SGB");
var snes = new LibsnesCore();
var snes = new LibsnesCore(nextComm);
nextEmulator = snes;
game.FirmwareHash = Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(sgbrom));
snes.Load(game, rom.FileData, sgbrom, deterministicemulation);
@ -1849,13 +1856,13 @@ namespace BizHawk.MultiClient
}
else
{
ColecoVision c = new ColecoVision(game, rom.RomData, colbiosPath, Global.Config.ColecoSkipBiosIntro);
ColecoVision c = new ColecoVision(nextComm, game, rom.RomData, colbiosPath, Global.Config.ColecoSkipBiosIntro);
nextEmulator = c;
}
break;
case "INTV":
{
Intellivision intv = new Intellivision(game, rom.RomData);
Intellivision intv = new Intellivision(nextComm, game, rom.RomData);
string eromPath = PathManager.MakeAbsolutePath(Global.Config.PathINTVEROM, "INTV");
if (!File.Exists(eromPath))
throw new InvalidOperationException("Specified EROM path does not exist:\n\n" + eromPath);
@ -1898,12 +1905,11 @@ namespace BizHawk.MultiClient
byte[] PAL_BIOS7800 = File.ReadAllBytes(pal_biospath);
byte[] HighScoreBIOS = File.ReadAllBytes(hsbiospath);
Atari7800 a78 = new Atari7800(game, rom.RomData, NTSC_BIOS7800, PAL_BIOS7800, HighScoreBIOS);
Atari7800 a78 = new Atari7800(nextComm, game, rom.RomData, NTSC_BIOS7800, PAL_BIOS7800, HighScoreBIOS);
nextEmulator = a78;
break;
case "C64":
C64 c64 = new C64(game, rom.RomData, rom.Extension);
c64.CoreInputComm = Global.CoreInputComm;
C64 c64 = new C64(nextComm, game, rom.RomData, rom.Extension);
c64.HardReset();
nextEmulator = c64;
break;
@ -1922,7 +1928,7 @@ namespace BizHawk.MultiClient
MessageBox.Show("Unable to find the required GBA BIOS file - \n" + gbabios, "Unable to load BIOS", MessageBoxButtons.OK, MessageBoxIcon.Error);
throw new Exception();
}
GBA gba = new GBA();
GBA gba = new GBA(nextComm);
gba.Load(rom.RomData, gbabios);
nextEmulator = gba;
}
@ -1932,7 +1938,6 @@ namespace BizHawk.MultiClient
if (nextEmulator == null)
throw new Exception("No core could load the rom.");
nextEmulator.CoreInputComm = Global.CoreInputComm;
}
catch (Exception ex)
{
@ -1945,7 +1950,9 @@ namespace BizHawk.MultiClient
CloseGame();
Global.Emulator.Dispose();
Global.Emulator = nextEmulator;
Global.CoreComm = nextComm;
Global.Game = game;
SyncCoreCommInputSignals();
SyncControls();
if (nextEmulator is LibsnesCore)
@ -1966,9 +1973,9 @@ namespace BizHawk.MultiClient
Text = DisplayNameForSystem(game.System) + " - " + game.Name;
ResetRewindBuffer();
if (Global.Emulator.CoreOutputComm.RomStatusDetails == null)
if (Global.Emulator.CoreComm.RomStatusDetails == null)
{
Global.Emulator.CoreOutputComm.RomStatusDetails =
Global.Emulator.CoreComm.RomStatusDetails =
string.Format("{0}\r\nSHA1:{1}\r\nMD5:{2}\r\n",
game.Name,
Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom.RomData)),
@ -1993,7 +2000,7 @@ namespace BizHawk.MultiClient
////setup the throttle based on platform's specifications
////(one day later for some systems we will need to modify it at runtime as the display mode changes)
//{
// throttle.SetCoreFps(Global.Emulator.CoreOutputComm.VsyncRate);
// throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate);
// SyncThrottle();
//}
RamSearch1.Restart();
@ -2117,8 +2124,8 @@ namespace BizHawk.MultiClient
DumpStatus.Image = BizHawk.MultiClient.Properties.Resources.GreenCheck;
annotation = "Verified good dump";
}
if (!string.IsNullOrEmpty(Global.Emulator.CoreOutputComm.RomStatusAnnotation))
annotation = Global.Emulator.CoreOutputComm.RomStatusAnnotation;
if (!string.IsNullOrEmpty(Global.Emulator.CoreComm.RomStatusAnnotation))
annotation = Global.Emulator.CoreComm.RomStatusAnnotation;
DumpStatus.ToolTipText = annotation;
}
@ -2146,22 +2153,6 @@ namespace BizHawk.MultiClient
catch (IOException) { }
}
private void CloseGame()
{
if (Global.Config.AutoSavestates && Global.Emulator is NullEmulator == false)
SaveState("Auto");
if (Global.Emulator.SaveRamModified)
SaveRam();
StopAVI();
Global.Emulator.Dispose();
Global.Emulator = new NullEmulator();
Global.ActiveController = Global.NullControls;
Global.AutoFireController = Global.AutofireNullControls;
Global.MovieSession.Movie.Stop();
NeedsReboot = false;
SetRebootIconStatus();
}
private static void SaveRam()
{
string path = PathManager.SaveRamPath(Global.Game);
@ -3397,10 +3388,34 @@ namespace BizHawk.MultiClient
LoadRom(file.FullName);
}
//-------------------------------------------------------
//whats the difference between these two methods??
//its very tricky. rename to be more clear or combine them.
private void CloseGame()
{
if (Global.Config.AutoSavestates && Global.Emulator is NullEmulator == false)
SaveState("Auto");
if (Global.Emulator.SaveRamModified)
SaveRam();
StopAVI();
Global.Emulator.Dispose();
Global.CoreComm = new CoreComm();
SyncCoreCommInputSignals();
Global.Emulator = new NullEmulator(Global.CoreComm);
Global.ActiveController = Global.NullControls;
Global.AutoFireController = Global.AutofireNullControls;
Global.MovieSession.Movie.Stop();
NeedsReboot = false;
SetRebootIconStatus();
}
public void CloseROM()
{
CloseGame();
Global.Emulator = new NullEmulator();
Global.CoreComm = new CoreComm();
SyncCoreCommInputSignals();
Global.Emulator = new NullEmulator(Global.CoreComm);
Global.Game = GameInfo.GetNullGame();
MemoryPulse.Clear();
RewireSound();
@ -3426,6 +3441,8 @@ namespace BizHawk.MultiClient
UpdateDumpIcon();
}
//-------------------------------------------------------
private void SaveConfig()
{
if (Global.Config.SaveWindowPosition)
@ -3818,7 +3835,7 @@ namespace BizHawk.MultiClient
try
{
aw.SetMovieParameters(Global.Emulator.CoreOutputComm.VsyncNum, Global.Emulator.CoreOutputComm.VsyncDen);
aw.SetMovieParameters(Global.Emulator.CoreComm.VsyncNum, Global.Emulator.CoreComm.VsyncDen);
if (avwriter_resizew > 0 && avwriter_resizeh > 0)
aw.SetVideoParameters(avwriter_resizew, avwriter_resizeh);
else
@ -3945,10 +3962,10 @@ namespace BizHawk.MultiClient
{
if (CurrAviWriter != null)
{
long nsampnum = 44100 * (long)Global.Emulator.CoreOutputComm.VsyncDen + SoundRemainder;
long nsamp = nsampnum / Global.Emulator.CoreOutputComm.VsyncNum;
long nsampnum = 44100 * (long)Global.Emulator.CoreComm.VsyncDen + SoundRemainder;
long nsamp = nsampnum / Global.Emulator.CoreComm.VsyncNum;
// exactly remember fractional parts of an audio sample
SoundRemainder = nsampnum % Global.Emulator.CoreOutputComm.VsyncNum;
SoundRemainder = nsampnum % Global.Emulator.CoreComm.VsyncNum;
short[] temp = new short[nsamp * 2];
AviSoundInput.GetSamples(temp);
@ -4571,13 +4588,13 @@ namespace BizHawk.MultiClient
private void showClippedRegionsToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.GGShowClippedRegions ^= true;
Global.CoreInputComm.GG_ShowClippedRegions = Global.Config.GGShowClippedRegions;
Global.CoreComm.GG_ShowClippedRegions = Global.Config.GGShowClippedRegions;
}
private void highlightActiveDisplayRegionToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.GGHighlightActiveDisplayRegion ^= true;
Global.CoreInputComm.GG_HighlightActiveDisplayRegion = Global.Config.GGHighlightActiveDisplayRegion;
Global.CoreComm.GG_HighlightActiveDisplayRegion = Global.Config.GGHighlightActiveDisplayRegion;
}
private void loadConfigToolStripMenuItem_Click_1(object sender, EventArgs e)
@ -4612,43 +4629,43 @@ namespace BizHawk.MultiClient
private void showBGToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600_ShowBG ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void showPlayer1ToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600_ShowPlayer1 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void showPlayer2ToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600_ShowPlayer2 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void showMissle1ToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600_ShowMissle1 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void showMissle2ToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600_ShowMissle2 ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void showBallToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600_ShowBall ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void showPlayfieldToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.Atari2600_ShowPlayfield ^= true;
SyncCoreInputComm();
SyncCoreCommInputSignals();
}
private void gPUViewerToolStripMenuItem_Click(object sender, EventArgs e)
@ -4675,13 +4692,13 @@ namespace BizHawk.MultiClient
{
if (StatusSlot0.Visible)
{
if (Global.Emulator.CoreOutputComm.UsesDriveLed)
if (Global.Emulator.CoreComm.UsesDriveLed)
{
if (!StatusBarLedLight.Visible)
{
StatusBarLedLight.Visible = true;
}
if (Global.Emulator.CoreOutputComm.DriveLED)
if (Global.Emulator.CoreComm.DriveLED)
{
StatusBarLedLight.Image = BizHawk.MultiClient.Properties.Resources.LightOn;
}

View File

@ -1376,8 +1376,8 @@ namespace BizHawk.MultiClient
RefreshBGENCheckStatesFromConfig();
suppression = false;
}
Global.MainForm.SyncCoreInputComm();
Global.MainForm.SyncCoreCommInputSignals();
}
private void lblEnPrio0_Click(object sender, EventArgs e)

View File

@ -32,7 +32,7 @@ namespace BizHawk.MultiClient
public void SaveConfigSettings()
{
Global.CoreInputComm.Tracer.Enabled = false;
Global.CoreComm.Tracer.Enabled = false;
Global.Config.TraceLoggerWndx = this.Location.X;
Global.Config.TraceLoggerWndy = this.Location.Y;
}
@ -63,7 +63,7 @@ namespace BizHawk.MultiClient
ClearList();
LoggingEnabled.Checked = true;
Global.CoreInputComm.Tracer.Enabled = true;
Global.CoreComm.Tracer.Enabled = true;
SetTracerBoxTitle();
Restart();
}
@ -81,10 +81,10 @@ namespace BizHawk.MultiClient
}
else
{
if (Global.Emulator.CoreOutputComm.CpuTraceAvailable)
if (Global.Emulator.CoreComm.CpuTraceAvailable)
{
ClearList();
TraceView.Columns[0].Text = Global.Emulator.CoreOutputComm.TraceHeader;
TraceView.Columns[0].Text = Global.Emulator.CoreComm.TraceHeader;
}
else
{
@ -107,7 +107,7 @@ namespace BizHawk.MultiClient
private void LoggingEnabled_CheckedChanged(object sender, EventArgs e)
{
Global.CoreInputComm.Tracer.Enabled = LoggingEnabled.Checked;
Global.CoreComm.Tracer.Enabled = LoggingEnabled.Checked;
SetTracerBoxTitle();
}
@ -133,13 +133,13 @@ namespace BizHawk.MultiClient
{
using (StreamWriter sw = new StreamWriter(LogFile.FullName, true))
{
sw.Write(Global.CoreInputComm.Tracer.TakeContents());
sw.Write(Global.CoreComm.Tracer.TakeContents());
}
}
private void LogToWindow()
{
string[] instructions = Global.CoreInputComm.Tracer.TakeContents().Split('\n');
string[] instructions = Global.CoreComm.Tracer.TakeContents().Split('\n');
if (!String.IsNullOrWhiteSpace(instructions[0]))
{
foreach (string s in instructions)
@ -207,7 +207,7 @@ namespace BizHawk.MultiClient
private void SetTracerBoxTitle()
{
if (Global.CoreInputComm.Tracer.Enabled)
if (Global.CoreComm.Tracer.Enabled)
{
if (ToFileRadio.Checked)
{