Added Golden Axe Warrior. Added Debugger.
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Audio\" />
|
<Folder Include="Audio\" />
|
||||||
<Folder Include="Cpu\" />
|
<Folder Include="Cpu\" />
|
||||||
<Folder Include="Io\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -53,12 +53,12 @@ namespace Core.Cpu
|
|||||||
|
|
||||||
// The Memory Bus
|
// The Memory Bus
|
||||||
private readonly IMemory _memory;
|
private readonly IMemory _memory;
|
||||||
private readonly IO_Bus _simpleIoBus;
|
private readonly IIoBus _simpleIoBus;
|
||||||
|
|
||||||
//External Timing interface
|
//External Timing interface
|
||||||
public Func<ushort, long, int>? WaitStateCallback { get; set; }
|
public Func<ushort, long, int>? WaitStateCallback { get; set; }
|
||||||
|
|
||||||
public Z80(IMemory memory, IO_Bus ioBus)
|
public Z80(IMemory memory, IIoBus ioBus)
|
||||||
{
|
{
|
||||||
_memory = memory;
|
_memory = memory;
|
||||||
_simpleIoBus = ioBus;
|
_simpleIoBus = ioBus;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
public interface IIoBus
|
public interface IIoBus
|
||||||
{
|
{
|
||||||
byte Read(ushort port);
|
byte ReadPort(ushort port);
|
||||||
void Write(ushort port, byte value);
|
void WritePort(ushort port, byte value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
62
Core/Io/SmsIoBus.cs
Normal file
62
Core/Io/SmsIoBus.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using Core.Interfaces;
|
||||||
|
|
||||||
|
namespace Core.Io
|
||||||
|
{
|
||||||
|
public class SmsIoBus : IIoBus
|
||||||
|
{
|
||||||
|
// We will wire these up in the next phases!
|
||||||
|
// public Vdp VideoProcessor { get; set; }
|
||||||
|
// public Psg AudioProcessor { get; set; }
|
||||||
|
|
||||||
|
// Joypad State (0xFF means no buttons pressed - the SMS uses Active-Low logic!)
|
||||||
|
public byte Joypad1State { get; set; } = 0xFF;
|
||||||
|
public byte Joypad2State { get; set; } = 0xFF;
|
||||||
|
|
||||||
|
public byte ReadPort(ushort port)
|
||||||
|
{
|
||||||
|
// The Z80 can output 16-bit port addresses, but the Master System
|
||||||
|
// hardware only physically wires up the bottom 8 bits.
|
||||||
|
byte lowerPort = (byte)(port & 0xFF);
|
||||||
|
|
||||||
|
if (lowerPort >= 0x80 && lowerPort <= 0xBF)
|
||||||
|
{
|
||||||
|
// VDP Read (Usually 0xBE for VRAM Data, 0xBF for Status Flags)
|
||||||
|
// return VideoProcessor.ReadPort(lowerPort);
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
if (lowerPort == 0xDC)
|
||||||
|
{
|
||||||
|
// Port 0xDC: Player 1 (Up, Down, Left, Right, 1, 2) + Player 2 (Up, Down)
|
||||||
|
return Joypad1State;
|
||||||
|
}
|
||||||
|
if (lowerPort == 0xDD)
|
||||||
|
{
|
||||||
|
// Port 0xDD: Player 2 (Left, Right, 1, 2) + Reset Button
|
||||||
|
return Joypad2State;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0xFF; // Floating bus
|
||||||
|
}
|
||||||
|
|
||||||
|
public void WritePort(ushort port, byte value)
|
||||||
|
{
|
||||||
|
byte lowerPort = (byte)(port & 0xFF);
|
||||||
|
|
||||||
|
if (lowerPort >= 0x40 && lowerPort <= 0x7F)
|
||||||
|
{
|
||||||
|
// PSG Audio Write (Usually written exactly to 0x7F)
|
||||||
|
// AudioProcessor.WriteData(value);
|
||||||
|
}
|
||||||
|
else if (lowerPort >= 0x80 && lowerPort <= 0xBF)
|
||||||
|
{
|
||||||
|
// VDP Write (Usually 0xBE for VRAM Data, 0xBF for Control Registers)
|
||||||
|
// VideoProcessor.WritePort(lowerPort, value);
|
||||||
|
}
|
||||||
|
else if (lowerPort <= 0x3F)
|
||||||
|
{
|
||||||
|
// Port 0x3E is used by the BIOS to enable/disable the cartridge slot
|
||||||
|
// We can usually ignore this if we are just directly booting game ROMs!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
61
Core/SmsMachine.cs
Normal file
61
Core/SmsMachine.cs
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
using Core.Cpu;
|
||||||
|
using Core.Io;
|
||||||
|
using Core.Memory;
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
public class SmsMachine
|
||||||
|
{
|
||||||
|
public Z80 Cpu { get; private set; }
|
||||||
|
public SmsMemoryBus MemoryBus { get; private set; }
|
||||||
|
public SmsIoBus IoBus { get; private set; }
|
||||||
|
public ushort? Breakpoint { get; set; } = null;
|
||||||
|
|
||||||
|
// NTSC SMS T-States per frame
|
||||||
|
public const int TStatesPerFrame = 59736;
|
||||||
|
public long TotalFrameCount { get; private set; } = 0;
|
||||||
|
public double FramesPerSecond { get; private set; } = 0;
|
||||||
|
public double FrameTime { get; private set; } = 0;
|
||||||
|
|
||||||
|
public SmsMachine()
|
||||||
|
{
|
||||||
|
MemoryBus = new SmsMemoryBus();
|
||||||
|
IoBus = new SmsIoBus();
|
||||||
|
Cpu = new Z80(MemoryBus, IoBus);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadCartridge(byte[] romData)
|
||||||
|
{
|
||||||
|
MemoryBus.LoadCartridge(romData);
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
MemoryBus.CleanRAMData();
|
||||||
|
Cpu.Reset();
|
||||||
|
|
||||||
|
// We will reset the VDP and PSG here later!
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RunFrame()
|
||||||
|
{
|
||||||
|
long currentFrameTStates = 0;
|
||||||
|
|
||||||
|
while (currentFrameTStates < TStatesPerFrame)
|
||||||
|
{
|
||||||
|
int tStates = Cpu.Step();
|
||||||
|
currentFrameTStates += tStates;
|
||||||
|
|
||||||
|
// --- FUTURE EXPANSION ---
|
||||||
|
// VideoProcessor.Update(tStates);
|
||||||
|
// AudioProcessor.Update(tStates);
|
||||||
|
|
||||||
|
// if (VideoProcessor.IsVBlanking && VideoProcessor.InterruptsEnabled)
|
||||||
|
// {
|
||||||
|
// Cpu.RequestInterrupt();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
414
Desktop/DebuggerForm.Designer.cs
generated
Normal file
414
Desktop/DebuggerForm.Designer.cs
generated
Normal file
@@ -0,0 +1,414 @@
|
|||||||
|
namespace Desktop
|
||||||
|
{
|
||||||
|
partial class DebuggerForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
lblAF = new Label();
|
||||||
|
lblBC = new Label();
|
||||||
|
lblDE = new Label();
|
||||||
|
lblHL = new Label();
|
||||||
|
lblPC = new Label();
|
||||||
|
lblSP = new Label();
|
||||||
|
lblFlags = new Label();
|
||||||
|
lblTStates = new Label();
|
||||||
|
txtMemoryStart = new TextBox();
|
||||||
|
btnRefreshMemory = new Button();
|
||||||
|
txtMemoryView = new RichTextBox();
|
||||||
|
lstDisassembly = new ListBox();
|
||||||
|
lstStack = new ListBox();
|
||||||
|
label1 = new Label();
|
||||||
|
txtBreakpoint = new TextBox();
|
||||||
|
label2 = new Label();
|
||||||
|
lblIX = new Label();
|
||||||
|
lblIY = new Label();
|
||||||
|
lblIff1 = new Label();
|
||||||
|
lblIff2 = new Label();
|
||||||
|
lblIE = new Label();
|
||||||
|
btnReset = new Button();
|
||||||
|
uiUpdateTimer = new System.Windows.Forms.Timer(components);
|
||||||
|
lblFrames = new Label();
|
||||||
|
lblFPS = new Label();
|
||||||
|
lblFrameTime = new Label();
|
||||||
|
richTextBox1 = new RichTextBox();
|
||||||
|
button1 = new Button();
|
||||||
|
button2 = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblAF
|
||||||
|
//
|
||||||
|
lblAF.AutoSize = true;
|
||||||
|
lblAF.Location = new Point(10, 7);
|
||||||
|
lblAF.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblAF.Name = "lblAF";
|
||||||
|
lblAF.Size = new Size(26, 20);
|
||||||
|
lblAF.TabIndex = 0;
|
||||||
|
lblAF.Text = "AF";
|
||||||
|
//
|
||||||
|
// lblBC
|
||||||
|
//
|
||||||
|
lblBC.AutoSize = true;
|
||||||
|
lblBC.Location = new Point(9, 48);
|
||||||
|
lblBC.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblBC.Name = "lblBC";
|
||||||
|
lblBC.Size = new Size(27, 20);
|
||||||
|
lblBC.TabIndex = 1;
|
||||||
|
lblBC.Text = "BC";
|
||||||
|
//
|
||||||
|
// lblDE
|
||||||
|
//
|
||||||
|
lblDE.AutoSize = true;
|
||||||
|
lblDE.Location = new Point(10, 100);
|
||||||
|
lblDE.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblDE.Name = "lblDE";
|
||||||
|
lblDE.Size = new Size(28, 20);
|
||||||
|
lblDE.TabIndex = 2;
|
||||||
|
lblDE.Text = "DE";
|
||||||
|
//
|
||||||
|
// lblHL
|
||||||
|
//
|
||||||
|
lblHL.AutoSize = true;
|
||||||
|
lblHL.Location = new Point(10, 150);
|
||||||
|
lblHL.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblHL.Name = "lblHL";
|
||||||
|
lblHL.Size = new Size(27, 20);
|
||||||
|
lblHL.TabIndex = 3;
|
||||||
|
lblHL.Text = "HL";
|
||||||
|
//
|
||||||
|
// lblPC
|
||||||
|
//
|
||||||
|
lblPC.AutoSize = true;
|
||||||
|
lblPC.Location = new Point(9, 200);
|
||||||
|
lblPC.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblPC.Name = "lblPC";
|
||||||
|
lblPC.Size = new Size(26, 20);
|
||||||
|
lblPC.TabIndex = 4;
|
||||||
|
lblPC.Text = "PC";
|
||||||
|
//
|
||||||
|
// lblSP
|
||||||
|
//
|
||||||
|
lblSP.AutoSize = true;
|
||||||
|
lblSP.Location = new Point(9, 252);
|
||||||
|
lblSP.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblSP.Name = "lblSP";
|
||||||
|
lblSP.Size = new Size(25, 20);
|
||||||
|
lblSP.TabIndex = 6;
|
||||||
|
lblSP.Text = "SP";
|
||||||
|
//
|
||||||
|
// lblFlags
|
||||||
|
//
|
||||||
|
lblFlags.AutoSize = true;
|
||||||
|
lblFlags.Location = new Point(88, 52);
|
||||||
|
lblFlags.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblFlags.Name = "lblFlags";
|
||||||
|
lblFlags.Size = new Size(43, 20);
|
||||||
|
lblFlags.TabIndex = 7;
|
||||||
|
lblFlags.Text = "Flags";
|
||||||
|
//
|
||||||
|
// lblTStates
|
||||||
|
//
|
||||||
|
lblTStates.AutoSize = true;
|
||||||
|
lblTStates.Location = new Point(88, 7);
|
||||||
|
lblTStates.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblTStates.Name = "lblTStates";
|
||||||
|
lblTStates.Size = new Size(63, 20);
|
||||||
|
lblTStates.TabIndex = 8;
|
||||||
|
lblTStates.Text = "T-States";
|
||||||
|
//
|
||||||
|
// txtMemoryStart
|
||||||
|
//
|
||||||
|
txtMemoryStart.Location = new Point(300, 21);
|
||||||
|
txtMemoryStart.Margin = new Padding(2);
|
||||||
|
txtMemoryStart.Name = "txtMemoryStart";
|
||||||
|
txtMemoryStart.Size = new Size(121, 27);
|
||||||
|
txtMemoryStart.TabIndex = 9;
|
||||||
|
txtMemoryStart.Text = "Memory Start";
|
||||||
|
txtMemoryStart.TextAlign = HorizontalAlignment.Center;
|
||||||
|
txtMemoryStart.TextChanged += btnRefreshMemory_Click;
|
||||||
|
//
|
||||||
|
// btnRefreshMemory
|
||||||
|
//
|
||||||
|
btnRefreshMemory.Location = new Point(425, 21);
|
||||||
|
btnRefreshMemory.Margin = new Padding(2);
|
||||||
|
btnRefreshMemory.Name = "btnRefreshMemory";
|
||||||
|
btnRefreshMemory.Size = new Size(90, 27);
|
||||||
|
btnRefreshMemory.TabIndex = 14;
|
||||||
|
btnRefreshMemory.Text = "Refresh Memory";
|
||||||
|
btnRefreshMemory.UseVisualStyleBackColor = true;
|
||||||
|
btnRefreshMemory.Click += btnRefreshMemory_Click;
|
||||||
|
//
|
||||||
|
// txtMemoryView
|
||||||
|
//
|
||||||
|
txtMemoryView.Location = new Point(88, 80);
|
||||||
|
txtMemoryView.Margin = new Padding(2);
|
||||||
|
txtMemoryView.Name = "txtMemoryView";
|
||||||
|
txtMemoryView.Size = new Size(443, 895);
|
||||||
|
txtMemoryView.TabIndex = 15;
|
||||||
|
txtMemoryView.Text = "Memory View Window";
|
||||||
|
//
|
||||||
|
// lstDisassembly
|
||||||
|
//
|
||||||
|
lstDisassembly.FormattingEnabled = true;
|
||||||
|
lstDisassembly.Location = new Point(567, 8);
|
||||||
|
lstDisassembly.Margin = new Padding(2);
|
||||||
|
lstDisassembly.Name = "lstDisassembly";
|
||||||
|
lstDisassembly.Size = new Size(252, 264);
|
||||||
|
lstDisassembly.TabIndex = 16;
|
||||||
|
//
|
||||||
|
// lstStack
|
||||||
|
//
|
||||||
|
lstStack.FormattingEnabled = true;
|
||||||
|
lstStack.Location = new Point(823, 8);
|
||||||
|
lstStack.Margin = new Padding(2);
|
||||||
|
lstStack.Name = "lstStack";
|
||||||
|
lstStack.Size = new Size(130, 264);
|
||||||
|
lstStack.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(568, 298);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(81, 20);
|
||||||
|
label1.TabIndex = 19;
|
||||||
|
label1.Text = "Breakpoint";
|
||||||
|
//
|
||||||
|
// txtBreakpoint
|
||||||
|
//
|
||||||
|
txtBreakpoint.Location = new Point(655, 295);
|
||||||
|
txtBreakpoint.Name = "txtBreakpoint";
|
||||||
|
txtBreakpoint.Size = new Size(125, 27);
|
||||||
|
txtBreakpoint.TabIndex = 20;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(233, 21);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(62, 20);
|
||||||
|
label2.TabIndex = 21;
|
||||||
|
label2.Text = "Address";
|
||||||
|
//
|
||||||
|
// lblIX
|
||||||
|
//
|
||||||
|
lblIX.AutoSize = true;
|
||||||
|
lblIX.Location = new Point(9, 298);
|
||||||
|
lblIX.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblIX.Name = "lblIX";
|
||||||
|
lblIX.Size = new Size(22, 20);
|
||||||
|
lblIX.TabIndex = 22;
|
||||||
|
lblIX.Text = "IX";
|
||||||
|
//
|
||||||
|
// lblIY
|
||||||
|
//
|
||||||
|
lblIY.AutoSize = true;
|
||||||
|
lblIY.Location = new Point(10, 344);
|
||||||
|
lblIY.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblIY.Name = "lblIY";
|
||||||
|
lblIY.Size = new Size(21, 20);
|
||||||
|
lblIY.TabIndex = 23;
|
||||||
|
lblIY.Text = "IY";
|
||||||
|
//
|
||||||
|
// lblIff1
|
||||||
|
//
|
||||||
|
lblIff1.AutoSize = true;
|
||||||
|
lblIff1.Location = new Point(567, 411);
|
||||||
|
lblIff1.Name = "lblIff1";
|
||||||
|
lblIff1.Size = new Size(35, 20);
|
||||||
|
lblIff1.TabIndex = 24;
|
||||||
|
lblIff1.Text = "IFF1";
|
||||||
|
//
|
||||||
|
// lblIff2
|
||||||
|
//
|
||||||
|
lblIff2.AutoSize = true;
|
||||||
|
lblIff2.Location = new Point(567, 458);
|
||||||
|
lblIff2.Name = "lblIff2";
|
||||||
|
lblIff2.Size = new Size(35, 20);
|
||||||
|
lblIff2.TabIndex = 25;
|
||||||
|
lblIff2.Text = "IFF2";
|
||||||
|
//
|
||||||
|
// lblIE
|
||||||
|
//
|
||||||
|
lblIE.AutoSize = true;
|
||||||
|
lblIE.Location = new Point(568, 370);
|
||||||
|
lblIE.Name = "lblIE";
|
||||||
|
lblIE.Size = new Size(109, 20);
|
||||||
|
lblIE.TabIndex = 26;
|
||||||
|
lblIE.Text = "Interrupt Mode";
|
||||||
|
//
|
||||||
|
// btnReset
|
||||||
|
//
|
||||||
|
btnReset.Location = new Point(651, 327);
|
||||||
|
btnReset.Margin = new Padding(2);
|
||||||
|
btnReset.Name = "btnReset";
|
||||||
|
btnReset.Size = new Size(132, 27);
|
||||||
|
btnReset.TabIndex = 27;
|
||||||
|
btnReset.Text = "Set Breakpoint";
|
||||||
|
btnReset.UseVisualStyleBackColor = true;
|
||||||
|
btnReset.Click += btnSetBreakpoint_Click;
|
||||||
|
//
|
||||||
|
// uiUpdateTimer
|
||||||
|
//
|
||||||
|
uiUpdateTimer.Enabled = true;
|
||||||
|
uiUpdateTimer.Interval = 1;
|
||||||
|
uiUpdateTimer.Tick += uiUpdateTimer_Tick;
|
||||||
|
//
|
||||||
|
// lblFrames
|
||||||
|
//
|
||||||
|
lblFrames.AutoSize = true;
|
||||||
|
lblFrames.Location = new Point(567, 682);
|
||||||
|
lblFrames.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblFrames.Name = "lblFrames";
|
||||||
|
lblFrames.Size = new Size(124, 20);
|
||||||
|
lblFrames.TabIndex = 28;
|
||||||
|
lblFrames.Text = "Frames Rendered";
|
||||||
|
//
|
||||||
|
// lblFPS
|
||||||
|
//
|
||||||
|
lblFPS.AutoSize = true;
|
||||||
|
lblFPS.Location = new Point(659, 759);
|
||||||
|
lblFPS.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblFPS.Name = "lblFPS";
|
||||||
|
lblFPS.Size = new Size(32, 20);
|
||||||
|
lblFPS.TabIndex = 29;
|
||||||
|
lblFPS.Text = "FPS";
|
||||||
|
//
|
||||||
|
// lblFrameTime
|
||||||
|
//
|
||||||
|
lblFrameTime.AutoSize = true;
|
||||||
|
lblFrameTime.Location = new Point(604, 718);
|
||||||
|
lblFrameTime.Margin = new Padding(2, 0, 2, 0);
|
||||||
|
lblFrameTime.Name = "lblFrameTime";
|
||||||
|
lblFrameTime.Size = new Size(87, 20);
|
||||||
|
lblFrameTime.TabIndex = 30;
|
||||||
|
lblFrameTime.Text = "Frame Time";
|
||||||
|
//
|
||||||
|
// richTextBox1
|
||||||
|
//
|
||||||
|
richTextBox1.Enabled = false;
|
||||||
|
richTextBox1.Location = new Point(567, 509);
|
||||||
|
richTextBox1.Name = "richTextBox1";
|
||||||
|
richTextBox1.ReadOnly = true;
|
||||||
|
richTextBox1.Size = new Size(304, 128);
|
||||||
|
richTextBox1.TabIndex = 32;
|
||||||
|
richTextBox1.Text = "Sega Master System Memory Map:\n0x0000 - 0x3FFF: ROM Slot 0 (16KB)\n0x4000 - 0x7FFF: ROM Slot 1 (16KB)\n0x8000 - 0xBFFF: ROM Slot 2 (16KB)\n0xC000 - 0xDFFF: System RAM (8KB)\n0xE000 - 0xFFFF: RAM Mirror";
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(555, 824);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 33;
|
||||||
|
button1.Text = "CPU Step";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += btnStep_Click;
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(555, 883);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(94, 29);
|
||||||
|
button2.TabIndex = 34;
|
||||||
|
button2.Text = "CPU Run";
|
||||||
|
button2.UseVisualStyleBackColor = true;
|
||||||
|
button2.Click += btnStep_Click;
|
||||||
|
//
|
||||||
|
// DebuggerForm
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(965, 990);
|
||||||
|
Controls.Add(button2);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Controls.Add(richTextBox1);
|
||||||
|
Controls.Add(lblFrameTime);
|
||||||
|
Controls.Add(lblFPS);
|
||||||
|
Controls.Add(lblFrames);
|
||||||
|
Controls.Add(btnReset);
|
||||||
|
Controls.Add(lblIE);
|
||||||
|
Controls.Add(lblIff2);
|
||||||
|
Controls.Add(lblIff1);
|
||||||
|
Controls.Add(lblIY);
|
||||||
|
Controls.Add(lblIX);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(txtBreakpoint);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(lstStack);
|
||||||
|
Controls.Add(lstDisassembly);
|
||||||
|
Controls.Add(txtMemoryView);
|
||||||
|
Controls.Add(btnRefreshMemory);
|
||||||
|
Controls.Add(txtMemoryStart);
|
||||||
|
Controls.Add(lblTStates);
|
||||||
|
Controls.Add(lblFlags);
|
||||||
|
Controls.Add(lblSP);
|
||||||
|
Controls.Add(lblPC);
|
||||||
|
Controls.Add(lblHL);
|
||||||
|
Controls.Add(lblDE);
|
||||||
|
Controls.Add(lblBC);
|
||||||
|
Controls.Add(lblAF);
|
||||||
|
Margin = new Padding(2);
|
||||||
|
Name = "DebuggerForm";
|
||||||
|
Text = "Debugger";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label lblAF;
|
||||||
|
private Label lblBC;
|
||||||
|
private Label lblDE;
|
||||||
|
private Label lblHL;
|
||||||
|
private Label lblPC;
|
||||||
|
private Label lblSP;
|
||||||
|
private Label lblFlags;
|
||||||
|
private Label lblTStates;
|
||||||
|
private TextBox txtMemoryStart;
|
||||||
|
private Button btnRefreshMemory;
|
||||||
|
private RichTextBox txtMemoryView;
|
||||||
|
private ListBox lstStack;
|
||||||
|
public ListBox lstDisassembly;
|
||||||
|
private Label label1;
|
||||||
|
private TextBox txtBreakpoint;
|
||||||
|
private Label label2;
|
||||||
|
private Label lblIX;
|
||||||
|
private Label lblIY;
|
||||||
|
private Label lblIff1;
|
||||||
|
private Label lblIff2;
|
||||||
|
private Label lblIE;
|
||||||
|
private Button btnReset;
|
||||||
|
private System.Windows.Forms.Timer uiUpdateTimer;
|
||||||
|
private Label lblFrames;
|
||||||
|
private Label lblFPS;
|
||||||
|
private Label lblFrameTime;
|
||||||
|
private RichTextBox richTextBox1;
|
||||||
|
private Button button1;
|
||||||
|
private Button button2;
|
||||||
|
//private TextBox textBox4;
|
||||||
|
}
|
||||||
|
}
|
||||||
1346
Desktop/DebuggerForm.cs
Normal file
1346
Desktop/DebuggerForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
123
Desktop/DebuggerForm.resx
Normal file
123
Desktop/DebuggerForm.resx
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="uiUpdateTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
@@ -9,11 +9,21 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Core\Core.csproj" />
|
<None Remove="ROMS\Golden Axe Warrior.sms" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="ROMS\" />
|
<EmbeddedResource Include="ROMS\Golden Axe Warrior.sms">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Vortice.XInput" Version="3.8.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Core\Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
29
Desktop/Form1.Designer.cs
generated
29
Desktop/Form1.Designer.cs
generated
@@ -28,12 +28,33 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
button1 = new Button();
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
SuspendLayout();
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
//
|
||||||
this.Text = "Form1";
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(304, 268);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(94, 29);
|
||||||
|
button1.TabIndex = 0;
|
||||||
|
button1.Text = "button1";
|
||||||
|
button1.UseVisualStyleBackColor = true;
|
||||||
|
button1.Click += button1_Click;
|
||||||
|
//
|
||||||
|
// Form1
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(button1);
|
||||||
|
Name = "Form1";
|
||||||
|
Text = "Form1";
|
||||||
|
Click += button1_Click;
|
||||||
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private Button button1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,50 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Reflection.PortableExecutable;
|
||||||
|
using Core;
|
||||||
namespace Desktop
|
namespace Desktop
|
||||||
{
|
{
|
||||||
public partial class Form1 : Form
|
public partial class Form1 : Form
|
||||||
{
|
{
|
||||||
|
private SmsMachine _machine = null!;
|
||||||
|
private DebuggerForm _debugger;
|
||||||
|
|
||||||
|
public ushort? Breakpoint
|
||||||
|
{
|
||||||
|
get => _machine?.Breakpoint;
|
||||||
|
set { if (_machine != null) _machine.Breakpoint = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_machine = new SmsMachine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void button1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// 1. Load a commercial Master System ROM!
|
||||||
|
|
||||||
|
byte[] rom = File.ReadAllBytes(@"C:\Parsons\Local Code Projects\ParsonsMasterSystem2026\Desktop\ROMS\Golden Axe Warrior.sms");
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
// 2. Jam it into the Sega Mapper
|
||||||
|
_machine.LoadCartridge(rom);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Open the Debugger to look around
|
||||||
|
if (_debugger == null || _debugger.IsDisposed)
|
||||||
|
{
|
||||||
|
_debugger = new DebuggerForm(_machine.Cpu, _machine.MemoryBus, this);
|
||||||
|
_debugger.Show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Desktop/ROMS/Golden Axe Warrior.sms
Normal file
BIN
Desktop/ROMS/Golden Axe Warrior.sms
Normal file
Binary file not shown.
Reference in New Issue
Block a user