More OpCodes - working towards ZEXALL perfection
This commit is contained in:
@@ -26,6 +26,7 @@ namespace Desktop
|
||||
public double FramesPerSecond = 0;
|
||||
public double TotalFrameTime = 0;
|
||||
public double FrameTime = 0;
|
||||
public bool exceptionRaised = false;
|
||||
|
||||
|
||||
public Form1()
|
||||
@@ -40,10 +41,10 @@ namespace Desktop
|
||||
{
|
||||
_baseTitle = this.Text;
|
||||
_memoryBus = new MemoryBus();
|
||||
_simpleIoBus = new IO_Bus();
|
||||
_tapManager = new TapManager();
|
||||
_simpleIoBus = new IO_Bus(_tapManager);
|
||||
_ula = new ULA(_memoryBus, _simpleIoBus);
|
||||
_beeper = new BeeperDevice();
|
||||
_tapManager = new TapManager();
|
||||
_memoryBus.CrapRAMData();
|
||||
byte[] romData = RomLoader.Load("48.rom");
|
||||
_memoryBus.LoadRom(romData);
|
||||
@@ -92,13 +93,19 @@ namespace Desktop
|
||||
continue;
|
||||
}
|
||||
|
||||
long tStatesBefore = _cpu.TotalTStates;
|
||||
|
||||
// --- Execute Instruction ---
|
||||
_cpu.Step();
|
||||
|
||||
int elapsedTStates = (int)(_cpu.TotalTStates - tStatesBefore);
|
||||
_tapManager.Update(elapsedTStates);
|
||||
|
||||
//Process audio at the correct time
|
||||
while (_cpu.TotalTStates >= (long)(audioSampleCount * 79.365))
|
||||
{
|
||||
_beeper.AddSample(_simpleIoBus.BeeperState);
|
||||
bool finalAudioOutput = _simpleIoBus.BeeperState ^ _tapManager.EarBit;
|
||||
_beeper.AddSample(finalAudioOutput);
|
||||
audioSampleCount++;
|
||||
}
|
||||
|
||||
@@ -119,7 +126,7 @@ namespace Desktop
|
||||
this.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
UpdateScreenBitmap();
|
||||
this.Text = $"{_baseTitle} - FPS: {FramesPerSecond:F1}";
|
||||
this.Text = $"{_baseTitle} - FPS: {FramesPerSecond:F1} - Fast Loading: {_cpu.EnableFastLoad.ToString()}";
|
||||
});
|
||||
TotalFrameCount++;
|
||||
|
||||
@@ -129,7 +136,7 @@ namespace Desktop
|
||||
|
||||
if (elapsedMs < targetTimeMs)
|
||||
{
|
||||
Thread.Sleep((int)(targetTimeMs - elapsedMs));
|
||||
//Thread.Sleep((int)(targetTimeMs - elapsedMs));
|
||||
}
|
||||
TotalFrameTime += fpsStopwatch.Elapsed.TotalMilliseconds;
|
||||
if (TotalFrameCount % 50 == 0)
|
||||
@@ -150,6 +157,7 @@ namespace Desktop
|
||||
this.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
MessageBox.Show(ex.Message, "CPU Crash", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -188,6 +196,15 @@ namespace Desktop
|
||||
}
|
||||
_isPaused = false;
|
||||
}
|
||||
|
||||
private void fastLoadingToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Toggle the checkmark UI
|
||||
fastLoadingToolStripMenuItem.Checked = !fastLoadingToolStripMenuItem.Checked;
|
||||
|
||||
// Tell the CPU to enable or disable the ROM hijack
|
||||
_cpu.EnableFastLoad = fastLoadingToolStripMenuItem.Checked;
|
||||
}
|
||||
private void openSNAToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_isPaused = true;
|
||||
@@ -203,6 +220,39 @@ namespace Desktop
|
||||
_isPaused = false;
|
||||
}
|
||||
|
||||
private void btnRunZexDoc_Click(object sender, EventArgs e)
|
||||
{
|
||||
_isPaused = true;
|
||||
|
||||
using (OpenFileDialog ofd = new OpenFileDialog())
|
||||
{
|
||||
ofd.Filter = "CP/M Binaries (*.com, *.bin)|*.com;*.bin";
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
byte[] zexdocBytes = System.IO.File.ReadAllBytes(ofd.FileName);
|
||||
|
||||
// 1. Wipe the RAM completely clean
|
||||
_memoryBus.CleanRAMData();
|
||||
|
||||
// 2. Load ZEXDOC exactly at CP/M start address 0x0100
|
||||
for (int i = 0; i < zexdocBytes.Length; i++)
|
||||
{
|
||||
_memoryBus.Write((ushort)(0x0100 + i), zexdocBytes[i]);
|
||||
}
|
||||
|
||||
// 3. Configure the CPU for CP/M
|
||||
_cpu.IsZexDocMode = true;
|
||||
_cpu.PC = 0x0100; // Execution starts here
|
||||
_cpu.SP = 0xFFFF; // Put the stack at the very top of memory
|
||||
|
||||
// 4. Fake a RET address at 0x0000 so the test terminates gracefully when finished
|
||||
_memoryBus.Write(0x0000, 0xD3); // OUT (n), A (A fake halt sequence)
|
||||
|
||||
// Unpause and watch the Visual Studio Output window!
|
||||
_isPaused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void btnRun_Click(object sender, EventArgs e) => _isPaused = false;
|
||||
|
||||
private void btnPause_Click(object sender, EventArgs e) => _isPaused = true;
|
||||
|
||||
Reference in New Issue
Block a user