core settings stuff etc

This commit is contained in:
goyuken 2013-12-22 20:41:21 +00:00
parent 7acc64c37e
commit 0347fc5eef
5 changed files with 117 additions and 68 deletions

View File

@ -1,4 +1,5 @@
using System.Drawing; using System;
using System.Drawing;
using System.Collections.Generic; using System.Collections.Generic;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.Gameboy;
@ -307,10 +308,60 @@ namespace BizHawk.Client.Common
public int GifWriterFrameskip = 3; public int GifWriterFrameskip = 3;
public int GifWriterDelay = -1; public int GifWriterDelay = -1;
// emulation core settings #region emulation core settings
public Dictionary<string, object> CoreSettings = new Dictionary<string, object>(); public Dictionary<string, object> CoreSettings = new Dictionary<string, object>();
public Dictionary<string, object> CoreSyncSettings = new Dictionary<string, object>(); public Dictionary<string, object> CoreSyncSettings = new Dictionary<string, object>();
public object GetCoreSettings<T>()
where T : IEmulator
{
return GetCoreSettings(typeof(T));
}
public object GetCoreSettings(Type t)
{
object ret;
CoreSettings.TryGetValue(t.ToString(), out ret);
return ret;
}
public void PutCoreSettings<T>(object o)
where T : IEmulator
{
PutCoreSettings(o, typeof(T));
}
public void PutCoreSettings(object o, Type t)
{
if (o != null)
CoreSettings[t.ToString()] = o;
else
CoreSettings.Remove(t.ToString());
}
public object GetCoreSyncSettings<T>()
where T : IEmulator
{
return GetCoreSyncSettings(typeof(T));
}
public object GetCoreSyncSettings(Type t)
{
object ret;
CoreSyncSettings.TryGetValue(t.ToString(), out ret);
return ret;
}
public void PutCoreSyncSettings<T>(object o)
where T : IEmulator
{
PutCoreSyncSettings(o, typeof(T));
}
public void PutCoreSyncSettings(object o, Type t)
{
if (o != null)
CoreSyncSettings[t.ToString()] = o;
else
CoreSyncSettings.Remove(t.ToString());
}
#endregion
// NESPPU Settings // NESPPU Settings
public bool AutoLoadNESPPU = false; public bool AutoLoadNESPPU = false;
public bool NESPPUSaveWindowPosition = true; public bool NESPPUSaveWindowPosition = true;
@ -591,9 +642,9 @@ namespace BizHawk.Client.Common
public bool GGHighlightActiveDisplayRegion = false; public bool GGHighlightActiveDisplayRegion = false;
// PCEngine Settings // PCEngine Settings
public bool PceSpriteLimit = false; //public bool PceSpriteLimit = false;
public bool PceEqualizeVolume = false; //public bool PceEqualizeVolume = false;
public bool PceArcadeCardRewindHack = true; //public bool PceArcadeCardRewindHack = true;
// Genesis Settings // Genesis Settings

View File

@ -11,6 +11,7 @@ using BizHawk.Emulation.Cores.Calculators;
using BizHawk.Emulation.Cores.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Nintendo.NES; using BizHawk.Emulation.Cores.Nintendo.NES;
using BizHawk.Emulation.Cores.Nintendo.SNES; using BizHawk.Emulation.Cores.Nintendo.SNES;
using BizHawk.Emulation.Cores.PCEngine;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -1235,9 +1236,11 @@ namespace BizHawk.Client.EmuHawk
private void PCESubMenu_DropDownOpened(object sender, EventArgs e) private void PCESubMenu_DropDownOpened(object sender, EventArgs e)
{ {
PCEAlwaysPerformSpriteLimitMenuItem.Checked = Global.Config.PceSpriteLimit; var s = (PCEngine.PCESettings)Global.Emulator.GetSettings();
PCEAlwaysEqualizeVolumesMenuItem.Checked = Global.Config.PceEqualizeVolume;
PCEArcadeCardRewindEnableMenuItem.Checked = Global.Config.PceArcadeCardRewindHack; PCEAlwaysPerformSpriteLimitMenuItem.Checked = s.SpriteLimit;
PCEAlwaysEqualizeVolumesMenuItem.Checked = s.EqualizeVolume;
PCEArcadeCardRewindEnableMenuItem.Checked = s.ArcadeCardRewindHack;
} }
private void PCEBGViewerMenuItem_Click(object sender, EventArgs e) private void PCEBGViewerMenuItem_Click(object sender, EventArgs e)
@ -1247,26 +1250,28 @@ namespace BizHawk.Client.EmuHawk
private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e) private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.PceSpriteLimit ^= true; var s = (PCEngine.PCESettings)Global.Emulator.GetSettings();
FlagNeedsReboot(); s.SpriteLimit ^= true;
PutCoreSettings(s);
} }
private void PCEAlwaysEqualizeVolumesMenuItem_Click(object sender, EventArgs e) private void PCEAlwaysEqualizeVolumesMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.PceEqualizeVolume ^= true; var s = (PCEngine.PCESettings)Global.Emulator.GetSettings();
FlagNeedsReboot(); s.EqualizeVolume ^= true;
PutCoreSettings(s);
} }
private void PCEArcadeCardRewindEnableMenuItem_Click(object sender, EventArgs e) private void PCEArcadeCardRewindEnableMenuItem_Click(object sender, EventArgs e)
{ {
Global.Config.PceArcadeCardRewindHack ^= true; var s = (PCEngine.PCESettings)Global.Emulator.GetSettings();
FlagNeedsReboot(); s.ArcadeCardRewindHack ^= true;
PutCoreSettings(s);
} }
private void PCEGraphicsSettingsMenuItem_Click(object sender, EventArgs e) private void PCEGraphicsSettingsMenuItem_Click(object sender, EventArgs e)
{ {
new PCEGraphicsConfig().ShowDialog(); new PCEGraphicsConfig().ShowDialog();
CoreFileProvider.SyncCoreCommInputSignals();
} }
#endregion #endregion

View File

@ -2152,6 +2152,16 @@ namespace BizHawk.Client.EmuHawk
LoadRom(file.FullName); LoadRom(file.FullName);
} }
/// <summary>
/// send core settings to emu, setting reboot flag if needed
/// </summary>
/// <param name="o"></param>
private void PutCoreSettings(object o)
{
if (Global.Emulator.PutSettings(o))
FlagNeedsReboot();
}
private void SaveConfig() private void SaveConfig()
{ {
if (Global.Config.SaveWindowPosition) if (Global.Config.SaveWindowPosition)
@ -3253,23 +3263,8 @@ namespace BizHawk.Client.EmuHawk
"This game requires a version 3.0 System card and won't run with the system card you've selected. Try selecting a 3.0 System Card in Config->Paths->PC Engine."); "This game requires a version 3.0 System card and won't run with the system card you've selected. Try selecting a 3.0 System Card in Config->Paths->PC Engine.");
} }
if (Global.Config.PceSpriteLimit)
{
game.AddOption("ForceSpriteLimit");
}
if (Global.Config.PceEqualizeVolume)
{
game.AddOption("EqualizeVolumes");
}
if (Global.Config.PceArcadeCardRewindHack)
{
game.AddOption("ArcadeRewindHack");
}
game.FirmwareHash = Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom.RomData)); game.FirmwareHash = Util.BytesToHexString(System.Security.Cryptography.SHA1.Create().ComputeHash(rom.RomData));
nextEmulator = new PCEngine(nextComm, game, disc, rom.RomData); nextEmulator = new PCEngine(nextComm, game, disc, rom.RomData, Global.Config.GetCoreSettings<PCEngine>());
break; break;
} }
} }
@ -3410,12 +3405,7 @@ namespace BizHawk.Client.EmuHawk
case "PCE": case "PCE":
case "PCECD": case "PCECD":
case "SGX": case "SGX":
if (Global.Config.PceSpriteLimit) nextEmulator = new PCEngine(nextComm, game, rom.RomData, Global.Config.GetCoreSettings<PCEngine>());
{
game.AddOption("ForceSpriteLimit");
}
nextEmulator = new PCEngine(nextComm, game, rom.RomData);
break; break;
case "GEN": case "GEN":
{ {
@ -3431,10 +3421,9 @@ namespace BizHawk.Client.EmuHawk
} }
break; break;
case "NES": case "NES":
{ nextEmulator = new NES(nextComm, game, rom.FileData,
var nes = new NES(nextComm, game, rom.FileData, Global.MovieSession.Movie.Header.BoardProperties); Global.Config.GetCoreSettings<NES>(),
nextEmulator = nes; Global.MovieSession.Movie.Header.BoardProperties);
}
break; break;
case "GB": case "GB":
case "GBC": case "GBC":
@ -3559,15 +3548,6 @@ namespace BizHawk.Client.EmuHawk
return false; return false;
} }
// load core settings
{
string typename = nextEmulator.GetType().ToString();
object settings = null;
Global.Config.CoreSettings.TryGetValue(typename, out settings);
if (settings != null)
nextEmulator.PutSettings(settings);
}
CloseGame(); CloseGame();
Global.Emulator.Dispose(); Global.Emulator.Dispose();
Global.Emulator = nextEmulator; Global.Emulator = nextEmulator;
@ -3774,13 +3754,9 @@ namespace BizHawk.Client.EmuHawk
{ {
// save settings object // save settings object
string typename = Global.Emulator.GetType().ToString(); Type t = Global.Emulator.GetType();
object settings = Global.Emulator.GetSettings(); Global.Config.PutCoreSettings(Global.Emulator.GetSettings(), t);
if (settings != null) Global.Config.PutCoreSyncSettings(Global.Emulator.GetSyncSettings(), t);
Global.Config.CoreSettings[typename] = settings;
object syncsettings = Global.Emulator.GetSyncSettings();
if (syncsettings != null)
Global.Config.CoreSyncSettings[typename] = syncsettings;
} }
Global.Emulator.Dispose(); Global.Emulator.Dispose();

View File

@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static readonly bool USE_DATABASE = true; static readonly bool USE_DATABASE = true;
public RomStatus RomStatus; public RomStatus RomStatus;
public NES(CoreComm comm, GameInfo game, byte[] rom, Dictionary<string, string> boardProperties = null) public NES(CoreComm comm, GameInfo game, byte[] rom, object Settings, Dictionary<string, string> boardProperties = null)
{ {
byte[] fdsbios = comm.CoreFileProvider.GetFirmware("NES", "Bios_FDS", false); byte[] fdsbios = comm.CoreFileProvider.GetFirmware("NES", "Bios_FDS", false);
if (fdsbios != null && fdsbios.Length == 40976) if (fdsbios != null && fdsbios.Length == 40976)
@ -48,6 +48,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
CoreComm.UsesDriveLed = true; CoreComm.UsesDriveLed = true;
b.SetDriveLightCallback((val) => CoreComm.DriveLED = val); b.SetDriveLightCallback((val) => CoreComm.DriveLED = val);
} }
PutSettings(Settings);
} }
private NES() private NES()

View File

@ -54,7 +54,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
// 21,477,270 Machine clocks / sec // 21,477,270 Machine clocks / sec
// 7,159,090 Cpu cycles / sec // 7,159,090 Cpu cycles / sec
public PCEngine(CoreComm comm, GameInfo game, byte[] rom) public PCEngine(CoreComm comm, GameInfo game, byte[] rom, object Settings)
{ {
CoreComm = comm; CoreComm = comm;
CoreComm.CpuTraceAvailable = true; CoreComm.CpuTraceAvailable = true;
@ -70,12 +70,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
Type = NecSystemType.SuperGrafx; Type = NecSystemType.SuperGrafx;
break; break;
} }
Init(game, rom); Init(game, rom, (PCESettings)Settings);
} }
public string BoardName { get { return null; } } public string BoardName { get { return null; } }
public PCEngine(CoreComm comm, GameInfo game, Disc disc, byte[] rom) public PCEngine(CoreComm comm, GameInfo game, Disc disc, byte[] rom, object Settings)
{ {
CoreComm = comm; CoreComm = comm;
CoreComm.CpuTraceAvailable = true; CoreComm.CpuTraceAvailable = true;
@ -83,12 +83,12 @@ namespace BizHawk.Emulation.Cores.PCEngine
systemid = "PCECD"; systemid = "PCECD";
Type = NecSystemType.TurboCD; Type = NecSystemType.TurboCD;
this.disc = disc; this.disc = disc;
Init(game, rom); Init(game, rom, (PCESettings)Settings);
// the default RomStatusDetails don't do anything with Disc // the default RomStatusDetails don't do anything with Disc
CoreComm.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) void Init(GameInfo game, byte[] rom, PCESettings Settings)
{ {
Controller = NullController.GetNullController(); Controller = NullController.GetNullController();
Cpu = new HuC6280(); Cpu = new HuC6280();
@ -99,6 +99,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
Cpu.Logger = (s) => CoreComm.Tracer.Put(s); Cpu.Logger = (s) => CoreComm.Tracer.Put(s);
this.Settings = Settings;
if (TurboGrafx) if (TurboGrafx)
{ {
Ram = new byte[0x2000]; Ram = new byte[0x2000];
@ -182,7 +184,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{ {
ArcadeRam = new byte[0x200000]; ArcadeRam = new byte[0x200000];
ArcadeCard = true; ArcadeCard = true;
ArcadeCardRewindHack = game["ArcadeRewindHack"]; ArcadeCardRewindHack = Settings.ArcadeCardRewindHack;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
ArcadePage[i] = new ArcadeCardPage(); ArcadePage[i] = new ArcadeCardPage();
} }
@ -194,7 +196,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
Cpu.WriteMemory21 = WriteMemoryPopulous; Cpu.WriteMemory21 = WriteMemoryPopulous;
} }
if (game["ForceSpriteLimit"] || game.NotInDatabase) if (Settings.SpriteLimit || game.NotInDatabase)
{ {
VDC1.PerformSpriteLimit = true; VDC1.PerformSpriteLimit = true;
if (VDC2 != null) if (VDC2 != null)
@ -207,7 +209,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
PSG.MaxVolume = int.Parse(game.OptionValue("PsgVol")); PSG.MaxVolume = int.Parse(game.OptionValue("PsgVol"));
if (game["AdpcmVol"]) if (game["AdpcmVol"])
ADPCM.MaxVolume = int.Parse(game.OptionValue("AdpcmVol")); ADPCM.MaxVolume = int.Parse(game.OptionValue("AdpcmVol"));
if (game["EqualizeVolumes"] || (game.NotInDatabase && TurboCD)) if (Settings.EqualizeVolume || (game.NotInDatabase && TurboCD))
SoundMixer.EqualizeVolumes(); SoundMixer.EqualizeVolumes();
// Ok, yes, HBlankPeriod's only purpose is game-specific hax. // Ok, yes, HBlankPeriod's only purpose is game-specific hax.
@ -630,8 +632,17 @@ namespace BizHawk.Emulation.Cores.PCEngine
public object GetSyncSettings() { return null; } public object GetSyncSettings() { return null; }
public bool PutSettings(object o) public bool PutSettings(object o)
{ {
Settings = (PCESettings)o; PCESettings n = (PCESettings)o;
return false; bool ret;
if (n.ArcadeCardRewindHack != Settings.ArcadeCardRewindHack ||
n.SpriteLimit != Settings.SpriteLimit ||
n.EqualizeVolume != Settings.EqualizeVolume)
ret = true;
else
ret = false;
Settings = n;
return ret;
} }
public class PCESettings public class PCESettings
@ -641,6 +652,11 @@ namespace BizHawk.Emulation.Cores.PCEngine
public bool ShowBG2 = true; public bool ShowBG2 = true;
public bool ShowOBJ2 = true; public bool ShowOBJ2 = true;
// these three require core reboot to use
public bool SpriteLimit = false;
public bool EqualizeVolume = false;
public bool ArcadeCardRewindHack = true;
public PCESettings Clone() public PCESettings Clone()
{ {
return (PCESettings)MemberwiseClone(); return (PCESettings)MemberwiseClone();