Some minor changes and playing about
This commit is contained in:
BIN
Desktop/48.rom
BIN
Desktop/48.rom
Binary file not shown.
BIN
Desktop/48.rom.bak
Normal file
BIN
Desktop/48.rom.bak
Normal file
Binary file not shown.
@@ -53,7 +53,7 @@ namespace Desktop
|
||||
|
||||
private async void btnRun_Click(object sender, EventArgs e)
|
||||
{
|
||||
// If it is already running, this button acts as a STOP button
|
||||
//Stops
|
||||
if (_isRunning)
|
||||
{
|
||||
_isRunning = false;
|
||||
@@ -61,7 +61,7 @@ namespace Desktop
|
||||
return;
|
||||
}
|
||||
|
||||
// --- NEW: Parse the Breakpoint ---
|
||||
//Parse the Breakpoint
|
||||
if (!string.IsNullOrWhiteSpace(txtBreakpoint.Text))
|
||||
{
|
||||
if (ushort.TryParse(txtBreakpoint.Text, System.Globalization.NumberStyles.HexNumber, null, out ushort parsedBp))
|
||||
@@ -76,18 +76,14 @@ namespace Desktop
|
||||
}
|
||||
else
|
||||
{
|
||||
_breakpoint = null; // No text means no breakpoint
|
||||
_breakpoint = null;
|
||||
}
|
||||
// ---------------------------------
|
||||
|
||||
// Start the run state
|
||||
_isRunning = true;
|
||||
btnRun.Text = "Stop";
|
||||
|
||||
|
||||
|
||||
// Fire up a background thread
|
||||
// Fire up a background thread
|
||||
//Background thread
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
@@ -111,6 +107,13 @@ namespace Desktop
|
||||
|
||||
// --- Execute Instruction ---
|
||||
_cpu.Step();
|
||||
//if (_cpu.TotalTStates % 1000 == 0)
|
||||
//{
|
||||
// this.Invoke((MethodInvoker)delegate
|
||||
// {
|
||||
// UpdateDisplay();
|
||||
// });
|
||||
//}
|
||||
|
||||
// --- Check for End of Frame ---
|
||||
if (_cpu.TotalTStates >= nextFrameTargetTStates)
|
||||
@@ -164,8 +167,7 @@ namespace Desktop
|
||||
}
|
||||
});
|
||||
|
||||
// Whether it stopped because of a breakpoint, a crash, or the user clicking "Stop",
|
||||
// we MUST update the UI when the background thread finishes!
|
||||
//update the UI when the background thread finishes
|
||||
btnRun.Text = "Run";
|
||||
UpdateDisplay();
|
||||
}
|
||||
|
||||
1
Desktop/Form1.Designer.cs
generated
1
Desktop/Form1.Designer.cs
generated
@@ -48,6 +48,7 @@
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(791, 596);
|
||||
Controls.Add(picScreen);
|
||||
KeyPreview = true;
|
||||
Name = "Form1";
|
||||
Text = "Parsons Sinclair ZX Spectrum 48K - 2026";
|
||||
((System.ComponentModel.ISupportInitialize)picScreen).EndInit();
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Desktop
|
||||
{
|
||||
private Z80 _cpu = null!;
|
||||
private MemoryBus _memoryBus = null!;
|
||||
private SimpleIoBus _simpleIoBus = null!;
|
||||
private IO_Bus _simpleIoBus = null!;
|
||||
|
||||
// The 16 physical colors of the ZX Spectrum (ARGB format)
|
||||
private readonly int[] SpectrumColors = new int[]
|
||||
@@ -50,7 +50,7 @@ namespace Desktop
|
||||
try
|
||||
{
|
||||
_memoryBus = new MemoryBus();
|
||||
_simpleIoBus = new SimpleIoBus();
|
||||
_simpleIoBus = new IO_Bus();
|
||||
|
||||
_memoryBus.CrapRAMData();
|
||||
byte[] romData = RomLoader.Load("48.rom");
|
||||
@@ -120,5 +120,67 @@ namespace Desktop
|
||||
if (picScreen.Image != null) picScreen.Image.Dispose();
|
||||
picScreen.Image = bmp;
|
||||
}
|
||||
|
||||
// Helper method to update the IO Bus state
|
||||
private void UpdateMatrix(int row, int col, bool isPressed)
|
||||
{
|
||||
if (isPressed)
|
||||
{
|
||||
// Clear the bit to 0 (Active-Low = Pressed)
|
||||
_simpleIoBus.KeyboardRows[row] &= (byte)~(1 << col);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the bit back to 1 (Unpressed)
|
||||
_simpleIoBus.KeyboardRows[row] |= (byte)(1 << col);
|
||||
}
|
||||
}
|
||||
|
||||
// Hook this to Form1's KeyDown event
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
HandleKey(e.KeyCode, true);
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
// Hook this to Form1's KeyUp event
|
||||
protected override void OnKeyUp(KeyEventArgs e)
|
||||
{
|
||||
HandleKey(e.KeyCode, false);
|
||||
base.OnKeyUp(e);
|
||||
}
|
||||
|
||||
private void HandleKey(Keys key, bool isPressed)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
// Row 6: ENTER, L, K, J, H
|
||||
case Keys.Enter: UpdateMatrix(6, 0, isPressed); break;
|
||||
case Keys.L: UpdateMatrix(6, 1, isPressed); break;
|
||||
case Keys.K: UpdateMatrix(6, 2, isPressed); break;
|
||||
case Keys.J: UpdateMatrix(6, 3, isPressed); break;
|
||||
case Keys.H: UpdateMatrix(6, 4, isPressed); break;
|
||||
|
||||
// Row 7: SPACE, SYM SHIFT, M, N, B
|
||||
case Keys.Space: UpdateMatrix(7, 0, isPressed); break;
|
||||
case Keys.M: UpdateMatrix(7, 2, isPressed); break;
|
||||
case Keys.N: UpdateMatrix(7, 3, isPressed); break;
|
||||
case Keys.B: UpdateMatrix(7, 4, isPressed); break;
|
||||
|
||||
// Row 1: A, S, D, F, G
|
||||
case Keys.A: UpdateMatrix(1, 0, isPressed); break;
|
||||
case Keys.S: UpdateMatrix(1, 1, isPressed); break;
|
||||
case Keys.D: UpdateMatrix(1, 2, isPressed); break;
|
||||
case Keys.F: UpdateMatrix(1, 3, isPressed); break;
|
||||
case Keys.G: UpdateMatrix(1, 4, isPressed); break;
|
||||
|
||||
// Map the rest of the alphabet and numbers here as you need them!
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user