Various code cleanup

This commit is contained in:
alyosha-tas 2019-07-21 09:05:07 -04:00
parent 6a773ac272
commit fca98ffe34
12 changed files with 112 additions and 213 deletions

View File

@ -69,85 +69,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
throw new NotImplementedException(); throw new NotImplementedException();
} }
public long TotalExecutedCycles => Cpu.TotalExecutedCycles; public long TotalExecutedCycles => Cpu.TotalExecutedCycles;
private int JSRCount = 0;
private const byte JSR = 0x20;
private const byte RTS = 0x60;
// the opsize table is used to quickly grab the instruction sizes (in bytes)
private readonly byte[] opsize =
{
/*0x00*/ 1,2,0,0,0,2,2,0,1,2,1,0,0,3,3,0,
/*0x10*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x20*/ 3,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0x30*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x40*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,
/*0x50*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x60*/ 1,2,0,0,0,2,2,0,1,2,1,0,3,3,3,0,
/*0x70*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0x80*/ 0,2,0,0,2,2,2,0,1,0,1,0,3,3,3,0,
/*0x90*/ 2,2,0,0,2,2,2,0,1,3,1,0,0,3,0,0,
/*0xA0*/ 2,2,2,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0xB0*/ 2,2,0,0,2,2,2,0,1,3,1,0,3,3,3,0,
/*0xC0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0xD0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0,
/*0xE0*/ 2,2,0,0,2,2,2,0,1,2,1,0,3,3,3,0,
/*0xF0*/ 2,2,0,0,0,2,2,0,1,3,0,0,0,3,3,0
};
/*the optype table is a quick way to grab the addressing mode for any 6502 opcode
//
// 0 = Implied\Accumulator\Immediate\Branch\NULL
// 1 = (Indirect,X)
// 2 = Zero Page
// 3 = Absolute
// 4 = (Indirect),Y
// 5 = Zero Page,X
// 6 = Absolute,Y
// 7 = Absolute,X
// 8 = Zero Page,Y
*/
private readonly byte[] optype =
{
/*0x00*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0,
/*0x10*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x20*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0x30*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x40*/ 0,1,0,0,0,2,2,0,0,0,0,0,0,3,3,0,
/*0x50*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x60*/ 0,1,0,0,0,2,2,0,0,0,0,0,3,3,3,0,
/*0x70*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0x80*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0x90*/ 0,4,0,0,5,5,8,0,0,6,0,0,0,7,0,0,
/*0xA0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0xB0*/ 0,4,0,0,5,5,8,0,0,6,0,0,7,7,6,0,
/*0xC0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0xD0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0,
/*0xE0*/ 0,1,0,0,2,2,2,0,0,0,0,0,3,3,3,0,
/*0xF0*/ 0,4,0,0,0,5,5,0,0,6,0,0,0,7,7,0
};
#region Currently Unused Debug hooks
private int CurrentScanLine
{
get { return _tia.LineCount; }
}
private bool IsVsync
{
get { return _tia.IsVSync; }
}
private bool IsVBlank
{
get { return _tia.IsVBlank; }
}
#endregion
} }
} }

View File

@ -602,7 +602,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
} }
// if extended HBLank is active, the screen area still needs a color // if extended HBLank is active, the screen area still needs a color
if (_hsyncCnt >= 68 && _hsyncCnt < 76 && _hmove.LateHBlankReset) if (_hmove.LateHBlankReset && _hsyncCnt >= 68 && _hsyncCnt < 76)
{ {
int pixelColor = 0; int pixelColor = 0;
@ -1154,8 +1154,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_pf0MaxDelay = 3; _pf0MaxDelay = 3;
} }
////_playField.Grp = (uint)((_playField.Grp & 0x0FFFF) + ((ReverseBits(value, 8) & 0x0F) << 16));
} }
else if (maskedAddr == 0x0E) // PF1 else if (maskedAddr == 0x0E) // PF1
{ {
@ -1181,7 +1179,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_pf1MaxDelay = 3; _pf1MaxDelay = 3;
} }
////_playField.Grp = (uint)((_playField.Grp & 0xF00FF) + (value << 8));
} }
else if (maskedAddr == 0x0F) // PF2 else if (maskedAddr == 0x0F) // PF2
{ {
@ -1207,7 +1204,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
{ {
_pf2MaxDelay = 3; _pf2MaxDelay = 3;
} }
////_playField.Grp = (uint)((_playField.Grp & 0xFFF00) + ReverseBits(value, 8));
} }
else if (maskedAddr == 0x10) // RESP0 else if (maskedAddr == 0x10) // RESP0
{ {

View File

@ -196,11 +196,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
if (sel1) if (sel1)
{ {
ppu.bright = (byte)((portA_ret & 0x7F) << 1); ppu.bright = (byte)((portA_ret & 0x7F) << 1);
ppu.bright_int_1 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_1 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x7F); ppu.bright = (byte)(portA_ret & 0x7F);
ppu.bright_int_2 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_2 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x3F); ppu.bright = (byte)(portA_ret & 0x3F);
ppu.bright_int_3 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_3 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
} }
else else
{ {
@ -273,11 +273,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
if (sel1) if (sel1)
{ {
ppu.bright = (byte)((portA_ret & 0x7F) << 1); ppu.bright = (byte)((portA_ret & 0x7F) << 1);
ppu.bright_int_1 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_1 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x7F); ppu.bright = (byte)(portA_ret & 0x7F);
ppu.bright_int_2 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_2 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
ppu.bright = (byte)(portA_ret & 0x3F); ppu.bright = (byte)(portA_ret & 0x3F);
ppu.bright_int_3 = (uint)(0xFF000000 | (ppu.bright << 16) | (ppu.bright << 8) | ppu.bright); ppu.bright_int_3 = (0xFF000000 | (uint)(ppu.bright << 16) | (uint)(ppu.bright << 8) | ppu.bright);
} }
else else
{ {

View File

@ -1,6 +1,5 @@
using System; using System;
using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions;
using BizHawk.Common; using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Consoles.Vectrex namespace BizHawk.Emulation.Cores.Consoles.Vectrex

View File

@ -1,6 +1,5 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;

View File

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

View File

@ -1,101 +1,101 @@
using System; using System;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Nintendo.GBHawk; using BizHawk.Emulation.Cores.Nintendo.GBHawk;
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
{ {
[Core( [Core(
"GBHawkLink", "GBHawkLink",
"", "",
isPorted: false, isPorted: false,
isReleased: true)] isReleased: true)]
[ServiceNotApplicable(typeof(IDriveLight))] [ServiceNotApplicable(typeof(IDriveLight))]
public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable, public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable,
ISettable<GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings> ISettable<GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings>
{ {
// we want to create two GBHawk instances that we will run concurrently // we want to create two GBHawk instances that we will run concurrently
// maybe up to 4 eventually? // maybe up to 4 eventually?
public GBHawk.GBHawk L; public GBHawk.GBHawk L;
public GBHawk.GBHawk R; public GBHawk.GBHawk R;
// if true, the link cable is currently connected // if true, the link cable is currently connected
private bool _cableconnected = true; private bool _cableconnected = true;
// if true, the link cable toggle signal is currently asserted // if true, the link cable toggle signal is currently asserted
private bool _cablediscosignal = false; private bool _cablediscosignal = false;
private bool do_r_next = false; private bool do_r_next = false;
//[CoreConstructor("GB", "GBC")] //[CoreConstructor("GB", "GBC")]
public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings) public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings)
{
var ser = new BasicServiceProvider(this);
linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings();
linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings();
_controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName);
CoreComm = comm;
var temp_set_L = new GBHawk.GBHawk.GBSettings();
var temp_set_R = new GBHawk.GBHawk.GBSettings();
var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings();
var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings();
temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L;
temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R;
temp_sync_L.DivInitialTime = linkSyncSettings.DivInitialTime_L;
temp_sync_R.DivInitialTime = linkSyncSettings.DivInitialTime_R;
temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L;
temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R;
L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
game_L, rom_L, temp_set_L, temp_sync_L);
R = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
game_R, rom_R, temp_set_R, temp_sync_R);
ser.Register<IVideoProvider>(this);
ser.Register<ISoundProvider>(this);
_tracer = new TraceBuffer { Header = L.cpu.TraceHeader };
ser.Register<ITraceable>(_tracer);
ServiceProvider = ser;
SetupMemoryDomains();
HardReset();
}
public void HardReset()
{
L.HardReset();
R.HardReset();
}
public DisplayType Region => DisplayType.NTSC;
public int _frame = 0;
private readonly GBHawkLinkControllerDeck _controllerDeck;
private readonly ITraceable _tracer;
public bool LinkConnected
{
get { return _cableconnected; }
set { _cableconnected = value; }
}
private void ExecFetch(ushort addr)
{ {
uint flags = (uint)(MemoryCallbackFlags.AccessExecute); var ser = new BasicServiceProvider(this);
MemoryCallbacks.CallMemoryCallbacks(addr, 0, flags, "System Bus");
} linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings();
} linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings();
} _controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName);
CoreComm = comm;
var temp_set_L = new GBHawk.GBHawk.GBSettings();
var temp_set_R = new GBHawk.GBHawk.GBSettings();
var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings();
var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings();
temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L;
temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R;
temp_sync_L.DivInitialTime = linkSyncSettings.DivInitialTime_L;
temp_sync_R.DivInitialTime = linkSyncSettings.DivInitialTime_R;
temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L;
temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R;
L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
game_L, rom_L, temp_set_L, temp_sync_L);
R = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
game_R, rom_R, temp_set_R, temp_sync_R);
ser.Register<IVideoProvider>(this);
ser.Register<ISoundProvider>(this);
_tracer = new TraceBuffer { Header = L.cpu.TraceHeader };
ser.Register<ITraceable>(_tracer);
ServiceProvider = ser;
SetupMemoryDomains();
HardReset();
}
public void HardReset()
{
L.HardReset();
R.HardReset();
}
public DisplayType Region => DisplayType.NTSC;
public int _frame = 0;
private readonly GBHawkLinkControllerDeck _controllerDeck;
private readonly ITraceable _tracer;
public bool LinkConnected
{
get { return _cableconnected; }
set { _cableconnected = value; }
}
private void ExecFetch(ushort addr)
{
uint flags = (uint)(MemoryCallbackFlags.AccessExecute);
MemoryCallbacks.CallMemoryCallbacks(addr, 0, flags, "System Bus");
}
}
}

View File

@ -1,10 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy; using BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
{ {

View File

@ -1,10 +1,6 @@
using BizHawk.Common; using BizHawk.Common;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
{ {

View File

@ -1,11 +1,8 @@
using BizHawk.Common.BizInvoke; using BizHawk.Common.BizInvoke;
using BizHawk.Emulation.Cores.Waterbox; using BizHawk.Emulation.Cores.Waterbox;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
{ {

View File

@ -3,12 +3,10 @@ using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Properties; using BizHawk.Emulation.Cores.Properties;
using BizHawk.Emulation.Cores.Waterbox; using BizHawk.Emulation.Cores.Waterbox;
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy
{ {

View File

@ -1,11 +1,8 @@
using System; using System;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Components.Z80A;
using BizHawk.Emulation.Cores.Sega.MasterSystem; using BizHawk.Emulation.Cores.Sega.MasterSystem;
using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Sega.GGHawkLink namespace BizHawk.Emulation.Cores.Sega.GGHawkLink
{ {