Added TAP file injection. Still incomplete.
This commit is contained in:
@@ -850,6 +850,13 @@ namespace Desktop
|
||||
mnemonic = $"LD (IX{sign}{d}), 0x{n:X2}";
|
||||
instructionLength = 4;
|
||||
}
|
||||
else if (ddOpcode == 0x5E) // LD E, (IX+d)
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
mnemonic = $"LD E, (IX{sign}{d})";
|
||||
instructionLength = 3;
|
||||
}
|
||||
else if (ddOpcode == 0x74) // LD (IX+d), H
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
@@ -864,6 +871,20 @@ namespace Desktop
|
||||
mnemonic = $"LD (IX{sign}{d}), L";
|
||||
instructionLength = 3;
|
||||
}
|
||||
else if (ddOpcode == 0x7E) // LD A, (IX+d)
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
mnemonic = $"LD A, (IX{sign}{d})";
|
||||
instructionLength = 3;
|
||||
}
|
||||
else if (ddOpcode == 0xBE) // CP (IX+d)
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
mnemonic = $"CP (IX{sign}{d})";
|
||||
instructionLength = 3;
|
||||
}
|
||||
else if (ddOpcode == 0xE1) // POP IX
|
||||
{
|
||||
mnemonic = "POP IX";
|
||||
|
||||
43
Desktop/Form1.Designer.cs
generated
43
Desktop/Form1.Designer.cs
generated
@@ -29,37 +29,72 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
picScreen = new PictureBox();
|
||||
menuStrip1 = new MenuStrip();
|
||||
fileToolStripMenuItem = new ToolStripMenuItem();
|
||||
openToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)picScreen).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// picScreen
|
||||
//
|
||||
picScreen.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
picScreen.BackColor = Color.Black;
|
||||
picScreen.Location = new Point(13, 13);
|
||||
picScreen.Location = new Point(13, 33);
|
||||
picScreen.Margin = new Padding(4);
|
||||
picScreen.Name = "picScreen";
|
||||
picScreen.Size = new Size(960, 768);
|
||||
picScreen.Size = new Size(900, 720);
|
||||
picScreen.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
picScreen.TabIndex = 0;
|
||||
picScreen.TabStop = false;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(24, 24);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(922, 33);
|
||||
menuStrip1.TabIndex = 1;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// fileToolStripMenuItem
|
||||
//
|
||||
fileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { openToolStripMenuItem });
|
||||
fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
fileToolStripMenuItem.Size = new Size(54, 29);
|
||||
fileToolStripMenuItem.Text = "File";
|
||||
//
|
||||
// openToolStripMenuItem
|
||||
//
|
||||
openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||
openToolStripMenuItem.Size = new Size(158, 34);
|
||||
openToolStripMenuItem.Text = "Open";
|
||||
openToolStripMenuItem.Click += loadTAPToolStripMenuItem_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(987, 791);
|
||||
ClientSize = new Size(922, 760);
|
||||
Controls.Add(picScreen);
|
||||
Controls.Add(menuStrip1);
|
||||
KeyPreview = true;
|
||||
MainMenuStrip = menuStrip1;
|
||||
Margin = new Padding(4);
|
||||
Name = "Form1";
|
||||
Text = "Parsons Sinclair ZX Spectrum 48K - 2026";
|
||||
((System.ComponentModel.ISupportInitialize)picScreen).EndInit();
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox picScreen;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem fileToolStripMenuItem;
|
||||
private ToolStripMenuItem openToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Desktop
|
||||
private Z80 _cpu = null!;
|
||||
private MemoryBus _memoryBus = null!;
|
||||
private IO_Bus _simpleIoBus = null!;
|
||||
private TapManager _tapManager = null!;
|
||||
private int _ulaFrameCount = 0;
|
||||
|
||||
// The 16 physical colors of the ZX Spectrum (ARGB format)
|
||||
@@ -52,12 +53,12 @@ namespace Desktop
|
||||
{
|
||||
_memoryBus = new MemoryBus();
|
||||
_simpleIoBus = new IO_Bus();
|
||||
|
||||
_tapManager = new TapManager();
|
||||
_memoryBus.CrapRAMData();
|
||||
byte[] romData = RomLoader.Load("48.rom");
|
||||
_memoryBus.LoadRom(romData);
|
||||
|
||||
_cpu = new Z80(_memoryBus, _simpleIoBus);
|
||||
_cpu = new Z80(_memoryBus, _simpleIoBus, _tapManager);
|
||||
|
||||
// Pass 'this' so the DebuggerForm can talk back to this main window
|
||||
DebuggerForm debugger = new DebuggerForm(_cpu, _memoryBus, this);
|
||||
@@ -69,6 +70,25 @@ namespace Desktop
|
||||
}
|
||||
}
|
||||
|
||||
// Inside Desktop/Form1.cs
|
||||
private void loadTAPToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (OpenFileDialog ofd = new OpenFileDialog())
|
||||
{
|
||||
ofd.Filter = "Spectrum TAP Files|*.tap";
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// The Desktop UI reads the file from the hard drive
|
||||
byte[] tapBytes = System.IO.File.ReadAllBytes(ofd.FileName);
|
||||
|
||||
// The pure Core logic processes the bytes
|
||||
_cpu._tapManager.LoadTapData(tapBytes);
|
||||
|
||||
MessageBox.Show("Tape inserted! Type LOAD \"\" and press Enter.", "Tape Deck");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Public so the Debugger's background thread can call it 50 times a second
|
||||
public void RenderScreen()
|
||||
{
|
||||
|
||||
@@ -117,4 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user