Core Code Cleanup

This commit is contained in:
alyosha-tas 2018-12-05 09:01:25 -06:00
parent 49a497eb3f
commit 59f43b144e
17 changed files with 115 additions and 171 deletions

View File

@ -34,7 +34,6 @@ using BizHawk.Emulation.Cores.Nintendo.SNES9X;
using BizHawk.Emulation.Cores.Consoles.SNK; using BizHawk.Emulation.Cores.Consoles.SNK;
using BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive; using BizHawk.Emulation.Cores.Consoles.Sega.PicoDrive;
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Atari.A7800Hawk;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
@ -1776,10 +1775,7 @@ namespace BizHawk.Client.EmuHawk
AtariSubMenu.Visible = true; AtariSubMenu.Visible = true;
break; break;
case "A78": case "A78":
if (Emulator is A7800Hawk) A7800SubMenu.Visible = true;
{
A7800SubMenu.Visible = true;
}
break; break;
case "PSX": case "PSX":
PSXSubMenu.Visible = true; PSXSubMenu.Visible = true;

View File

@ -153,14 +153,14 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
[DisplayName("Port 1 Device")] [DisplayName("Port 1 Device")]
[Description("The type of controller plugged into the first controller port")] [Description("The type of controller plugged into the first controller port")]
[TypeConverter(typeof(DescribableEnumConverter))] [TypeConverter(typeof(DescribableEnumConverter))]
public Atari2600ControllerTypes Port1 { get; set; } = Atari2600ControllerTypes.Joystick; public Atari2600ControllerTypes Port1 { get; set; } = Atari2600ControllerTypes.Joystick;
[DefaultValue(Atari2600ControllerTypes.Joystick)] [DefaultValue(Atari2600ControllerTypes.Joystick)]
[DisplayName("Port 2 Device")] [DisplayName("Port 2 Device")]
[Description("The type of controller plugged into the second controller port")] [Description("The type of controller plugged into the second controller port")]
[TypeConverter(typeof(DescribableEnumConverter))] [TypeConverter(typeof(DescribableEnumConverter))]
public Atari2600ControllerTypes Port2 { get; set; } = Atari2600ControllerTypes.Joystick; public Atari2600ControllerTypes Port2 { get; set; } = Atari2600ControllerTypes.Joystick;
[DisplayName("Black and White Mode")] [DisplayName("Black and White Mode")]
[Description("Set the TV Type switch on the console to B&W or Color. This only affects the displayed image if the game supports it.")] [Description("Set the TV Type switch on the console to B&W or Color. This only affects the displayed image if the game supports it.")]
[DefaultValue(false)] [DefaultValue(false)]

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using BizHawk.Common.BufferExtensions; using BizHawk.Common.BufferExtensions;

View File

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using BizHawk.Common; using BizHawk.Common;

View File

@ -1,5 +1,4 @@
using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -162,13 +161,10 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
tia._hsyncCnt++; tia._hsyncCnt++;
tia._hsyncCnt %= 454; tia._hsyncCnt %= 454;
// do the audio sampling // do the audio sampling of TIA audio
if (tia._hsyncCnt == 113 || tia._hsyncCnt == 340) if (tia._hsyncCnt == 113 || tia._hsyncCnt == 340)
{ {
temp_s_tia = tia.Execute(0); temp_s_tia = tia.Execute(0);
// even though its clocked seperately, we sample the Pokey here
//if (is_pokey) { pokey.sample(); }
} }
// tick the m6532 timer, which is still active although not recommended to use // tick the m6532 timer, which is still active although not recommended to use
@ -435,6 +431,5 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
} }
#endregion #endregion
} }
} }

View File

@ -1,104 +1,102 @@
using System; using System;
using System.ComponentModel; using Newtonsoft.Json;
using Newtonsoft.Json; using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Common;
using BizHawk.Emulation.Common; namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{
namespace BizHawk.Emulation.Cores.Atari.A7800Hawk public partial class A7800Hawk : IEmulator, IStatable, ISettable<A7800Hawk.A7800Settings, A7800Hawk.A7800SyncSettings>
{ {
public partial class A7800Hawk : IEmulator, IStatable, ISettable<A7800Hawk.A7800Settings, A7800Hawk.A7800SyncSettings> public A7800Settings GetSettings()
{ {
public A7800Settings GetSettings() return _settings.Clone();
{ }
return _settings.Clone();
} public A7800SyncSettings GetSyncSettings()
{
public A7800SyncSettings GetSyncSettings() return _syncSettings.Clone();
{ }
return _syncSettings.Clone();
} public bool PutSettings(A7800Settings o)
{
public bool PutSettings(A7800Settings o) _settings = o;
{ return false;
_settings = o; }
return false;
} public bool PutSyncSettings(A7800SyncSettings o)
{
public bool PutSyncSettings(A7800SyncSettings o) bool ret = A7800SyncSettings.NeedsReboot(_syncSettings, o);
{ _syncSettings = o;
bool ret = A7800SyncSettings.NeedsReboot(_syncSettings, o); return ret;
_syncSettings = o; }
return ret;
} private A7800Settings _settings = new A7800Settings();
public A7800SyncSettings _syncSettings = new A7800SyncSettings();
private A7800Settings _settings = new A7800Settings();
public A7800SyncSettings _syncSettings = new A7800SyncSettings(); public class A7800Settings
{
public class A7800Settings public A7800Settings Clone()
{ {
public A7800Settings Clone() return (A7800Settings)MemberwiseClone();
{ }
return (A7800Settings)MemberwiseClone(); }
}
} public class A7800SyncSettings
{
public class A7800SyncSettings private string _port1 = A7800HawkControllerDeck.DefaultControllerName;
{ private string _port2 = A7800HawkControllerDeck.DefaultControllerName;
private string _port1 = A7800HawkControllerDeck.DefaultControllerName; private string _Filter = "None";
private string _port2 = A7800HawkControllerDeck.DefaultControllerName;
private string _Filter = "None"; [JsonIgnore]
public string Filter
[JsonIgnore] {
public string Filter get { return _Filter; }
{ set
get { return _Filter; } {
set _Filter = value;
{ }
_Filter = value; }
}
} [JsonIgnore]
public string Port1
[JsonIgnore] {
public string Port1 get { return _port1; }
{ set
get { return _port1; } {
set if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value))
{ {
if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value)) throw new InvalidOperationException("Invalid controller type: " + value);
{ }
throw new InvalidOperationException("Invalid controller type: " + value);
} _port1 = value;
}
_port1 = value; }
}
} [JsonIgnore]
public string Port2
[JsonIgnore] {
public string Port2 get { return _port2; }
{ set
get { return _port2; } {
set if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value))
{ {
if (!A7800HawkControllerDeck.ValidControllerTypes.ContainsKey(value)) throw new InvalidOperationException("Invalid controller type: " + value);
{ }
throw new InvalidOperationException("Invalid controller type: " + value);
} _port2 = value;
}
_port2 = value; }
}
} public A7800SyncSettings Clone()
{
public A7800SyncSettings Clone() return (A7800SyncSettings)MemberwiseClone();
{ }
return (A7800SyncSettings)MemberwiseClone();
} public static bool NeedsReboot(A7800SyncSettings x, A7800SyncSettings y)
{
public static bool NeedsReboot(A7800SyncSettings x, A7800SyncSettings y) return !DeepEquality.DeepEquals(x, y);
{ }
return !DeepEquality.DeepEquals(x, y); }
} }
} }
}
}

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;

View File

@ -1,5 +1,4 @@
using System; using System;
using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
using BizHawk.Common; using BizHawk.Common;

View File

@ -1,8 +1,5 @@
using System; using System;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;
// X = don't care // X = don't care
/* /*
1. TIA 0000 00XX 0000 0000 - 0000 00XX 0001 1111 1. TIA 0000 00XX 0000 0000 - 0000 00XX 0001 1111

View File

@ -1,5 +1,4 @@
using System; using System;
using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
using BizHawk.Common; using BizHawk.Common;
@ -330,6 +329,5 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
ser.EndSection(); ser.EndSection();
} }
} }
} }

View File

@ -1,7 +1,4 @@
using System; using System;
using System.Numerics;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Atari.A7800Hawk namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
{ {
@ -39,34 +36,10 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
LocalAudioCycles = 0; LocalAudioCycles = 0;
LocalAudioCycles += (AUD[0].Cycle() / 2); LocalAudioCycles += (AUD[0].Cycle() / 2);
LocalAudioCycles += (AUD[1].Cycle() / 2); LocalAudioCycles += (AUD[1].Cycle() / 2);
//AudioClocks++;
return LocalAudioCycles; return LocalAudioCycles;
} }
/*
public void GetSamples(short[] samples)
{
if (AudioClocks > 0)
{
var samples31Khz = new short[AudioClocks]; // mono
for (int i = 0; i < AudioClocks; i++)
{
samples31Khz[i] = LocalAudioCycles[i];
LocalAudioCycles[i] = 0;
}
// convert from 31khz to 44khz
for (var i = 0; i < samples.Length / 2; i++)
{
samples[i * 2] = samples31Khz[(int)(((double)samples31Khz.Length / (double)(samples.Length / 2)) * i)];
samples[(i * 2) + 1] = samples[i * 2];
}
}
AudioClocks = 0;
}
*/
public byte ReadMemory(ushort addr, bool peek) public byte ReadMemory(ushort addr, bool peek)
{ {
var maskedAddr = (ushort)(addr & 0x000F); var maskedAddr = (ushort)(addr & 0x000F);

View File

@ -2,7 +2,6 @@
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.ColecoVision namespace BizHawk.Emulation.Cores.ColecoVision
{ {

View File

@ -73,8 +73,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
int changes_1 = change1 > 0 ? (int)Math.Floor(change1) : (int)Math.Ceiling(change1); int changes_1 = change1 > 0 ? (int)Math.Floor(change1) : (int)Math.Ceiling(change1);
int changes_2 = change2 > 0 ? (int)Math.Floor(change2) : (int)Math.Ceiling(change2); int changes_2 = change2 > 0 ? (int)Math.Floor(change2) : (int)Math.Ceiling(change2);
for (int scanLine = 0; scanLine < 262; scanLine++) for (int scanLine = 0; scanLine < 262; scanLine++)
{ {
_vdp.RenderScanline(scanLine); _vdp.RenderScanline(scanLine);

View File

@ -1,7 +1,5 @@
using System; using System;
using BizHawk.Common;
using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.ColecoVision namespace BizHawk.Emulation.Cores.ColecoVision

View File

@ -78,7 +78,5 @@ namespace BizHawk.Emulation.Cores.ColecoVision
SyncAllByteArrayDomains(); SyncAllByteArrayDomains();
} }
} }
private byte[] _stateBuffer;
} }
} }

View File

@ -1,5 +1,4 @@
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Components;
using BizHawk.Emulation.Cores.Components.Z80A; using BizHawk.Emulation.Cores.Components.Z80A;
using System; using System;
@ -52,8 +51,12 @@ namespace BizHawk.Emulation.Cores.ColecoVision
} }
use_SGM = _syncSettings.UseSGM; use_SGM = _syncSettings.UseSGM;
Console.WriteLine("Using the Super Game Module");
if (use_SGM)
{
Console.WriteLine("Using the Super Game Module");
}
LoadRom(rom, skipbios); LoadRom(rom, skipbios);
SetupMemoryDomains(); SetupMemoryDomains();
@ -103,7 +106,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
is_MC = true; is_MC = true;
_romData = rom; _romData = rom;
} }
// hack to skip colecovision title screen // hack to skip colecovision title screen

View File

@ -1,9 +1,7 @@
using System.Collections.Generic; using System;
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions; using BizHawk.Common.NumberExtensions;
using System;
namespace BizHawk.Emulation.Cores.ColecoVision namespace BizHawk.Emulation.Cores.ColecoVision
{ {
@ -144,7 +142,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
public void generate_sound(int cycles_to_do) public void generate_sound(int cycles_to_do)
{ {
// there are 16 cpu cycles for every psg cycle // there are 16 cpu cycles for every psg cycle
for (int i = 0; i < cycles_to_do; i++) for (int i = 0; i < cycles_to_do; i++)
{ {
psg_clock++; psg_clock++;
@ -195,7 +192,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision
noise_clock *= 2; noise_clock *= 2;
} }
if (clock_A == 0) if (clock_A == 0)
{ {