5 ZEXALL tests now complete. Going to implement ALL remaining OpCOdes
This commit is contained in:
103
Desktop/Form1.cs
103
Desktop/Form1.cs
@@ -26,7 +26,8 @@ namespace Desktop
|
||||
public double FramesPerSecond = 0;
|
||||
public double TotalFrameTime = 0;
|
||||
public double FrameTime = 0;
|
||||
public bool exceptionRaised = false;
|
||||
public bool highSpeed = false;
|
||||
public bool tapeLoaded = false;
|
||||
|
||||
|
||||
public Form1()
|
||||
@@ -102,18 +103,24 @@ namespace Desktop
|
||||
_tapManager.Update(elapsedTStates);
|
||||
|
||||
//Process audio at the correct time
|
||||
//while (_cpu.TotalTStates >= (long)(audioSampleCount * 79.365))
|
||||
//{
|
||||
// bool finalAudioOutput = _simpleIoBus.BeeperState ^ _tapManager.EarBit;
|
||||
// _beeper.AddSample(finalAudioOutput);
|
||||
// audioSampleCount++;
|
||||
//}
|
||||
if (!highSpeed)
|
||||
{
|
||||
while (_cpu.TotalTStates >= (long)(audioSampleCount * 79.365))
|
||||
{
|
||||
bool finalAudioOutput = _simpleIoBus.BeeperState ^ _tapManager.EarBit;
|
||||
_beeper.AddSample(finalAudioOutput);
|
||||
audioSampleCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Check for End of Frame ---
|
||||
if (_cpu.TotalTStates >= nextScanlineTarget)
|
||||
{
|
||||
// Tell the ULA to draw one line of pixels
|
||||
_ula.RenderScanline((int)scanlineCount % 312);
|
||||
if (!highSpeed || (TotalFrameCount % 10 == 0))
|
||||
{
|
||||
_ula.RenderScanline((int)scanlineCount % 312);
|
||||
}
|
||||
|
||||
nextScanlineTarget += 224; // Advance target by ONE line (224 T-States)
|
||||
scanlineCount++;
|
||||
@@ -122,22 +129,41 @@ namespace Desktop
|
||||
if (scanlineCount % 312 == 0)
|
||||
{
|
||||
_cpu.RequestInterrupt(); // 50Hz interrupt
|
||||
|
||||
this.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
UpdateScreenBitmap();
|
||||
this.Text = $"{_baseTitle} - FPS: {FramesPerSecond:F1} - Fast Loading: {_cpu.EnableFastLoad.ToString()}";
|
||||
});
|
||||
TotalFrameCount++;
|
||||
|
||||
// Throttle to real-time (50 FPS = 20ms)
|
||||
//long targetTimeMs = (scanlineCount / 312) * 20;
|
||||
//long elapsedMs = stopwatch.ElapsedMilliseconds;
|
||||
if (highSpeed)
|
||||
{
|
||||
if (TotalFrameCount % 10 == 0)
|
||||
{
|
||||
this.BeginInvoke((MethodInvoker)delegate
|
||||
{
|
||||
UpdateScreenBitmap();
|
||||
this.Text = $"{_baseTitle} - FPS: {FramesPerSecond:F1}";
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
UpdateScreenBitmap();
|
||||
this.Text = $"{_baseTitle} - FPS: {FramesPerSecond:F1} - Tape Loaded: {tapeLoaded.ToString()}";
|
||||
});
|
||||
}
|
||||
|
||||
//if (elapsedMs < targetTimeMs)
|
||||
//{
|
||||
// Thread.Sleep((int)(targetTimeMs - elapsedMs));
|
||||
//}
|
||||
|
||||
// Throttle to real-time (50 FPS = 20ms)
|
||||
if (!highSpeed)
|
||||
{
|
||||
long targetTimeMs = (scanlineCount / 312) * 20;
|
||||
long elapsedMs = stopwatch.ElapsedMilliseconds;
|
||||
|
||||
if (elapsedMs < targetTimeMs)
|
||||
{
|
||||
Thread.Sleep((int)(targetTimeMs - elapsedMs));
|
||||
}
|
||||
}
|
||||
TotalFrameTime += fpsStopwatch.Elapsed.TotalMilliseconds;
|
||||
if (TotalFrameCount % 50 == 0)
|
||||
{
|
||||
@@ -192,6 +218,7 @@ namespace Desktop
|
||||
{
|
||||
byte[] tapBytes = File.ReadAllBytes(ofd.FileName);
|
||||
_cpu._tapManager.LoadTapData(tapBytes);
|
||||
tapeLoaded = true;
|
||||
}
|
||||
}
|
||||
_isPaused = false;
|
||||
@@ -220,38 +247,10 @@ namespace Desktop
|
||||
_isPaused = false;
|
||||
}
|
||||
|
||||
private void btnRunZexDoc_Click(object sender, EventArgs e)
|
||||
private void btnHighSpeedToggle_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;
|
||||
}
|
||||
}
|
||||
this.HighSpeedToolStripMenuItem.Checked = !this.HighSpeedToolStripMenuItem.Checked;
|
||||
highSpeed = this.HighSpeedToolStripMenuItem.Checked ? true : false;
|
||||
}
|
||||
private void btnRun_Click(object sender, EventArgs e) => _isPaused = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user