Fixed fast and slow tape loading and play_stop tape

This commit is contained in:
2026-04-29 14:33:39 +01:00
parent 8ef5e1f023
commit 142db4d004
5 changed files with 100 additions and 53 deletions

View File

@@ -30,7 +30,9 @@ namespace Desktop
public double FrameTime = 0;
public bool highSpeed = false;
public bool tapeLoaded = false;
public bool tapePlaying = false;
private volatile bool _pendingReset = false;
private bool _enableFastLoad = true;
// Comment to push a new commit
public Form1()
@@ -57,6 +59,8 @@ namespace Desktop
_memoryBus.LoadRom(romData);
_cpu = new Z80(_memoryBus, _simpleIoBus);
_cpu.WaitStateCallback = _ula.GetContentionDelay;
fastLoadToolStripMenuItem.Checked = _enableFastLoad;
}
catch (Exception ex)
@@ -118,10 +122,10 @@ namespace Desktop
long tStatesBefore = _cpu.TotalTStates;
// --- HARDWARE INTERCEPTS ---
if ((_cpu.PC == 0x0556 || _cpu.PC == 0x0558) && _tapManager.HasBlocks)
if (_enableFastLoad && _cpu.PC == 0x0556 && _tapManager.HasBlocks)
{
HandleInstantTapeLoad();
_cpu.TotalTStates += 100; // Charge some arbitrary time for the fast load
_cpu.TotalTStates += 100;
}
// --- Execute Instruction ---
@@ -302,37 +306,34 @@ namespace Desktop
private void PopulateIncludedTapsMenu()
{
// 1. Get the current assembly (your .exe)
Assembly assembly = Assembly.GetExecutingAssembly();
// 2. Find all embedded resources
string[] resourceNames = assembly.GetManifestResourceNames();
foreach (string resourceName in resourceNames)
{
// Check if it is a TAP file in our TestRoms folder
// (Embedded resources use dot-notation, e.g., "Desktop.TestRoms.ZEXALL.TAP")
if (resourceName.Contains("Desktop.ROMS.TAP.") && resourceName.EndsWith(".TAP", StringComparison.OrdinalIgnoreCase))
{
// Clean up the name for the menu (e.g., "Desktop.TestRoms.ZEXALL.TAP" -> "ZEXALL")
string[] parts = resourceName.Split('.');
string displayName = parts[parts.Length - 2];
// Create the new menu item
ToolStripMenuItem item = new ToolStripMenuItem(displayName);
// Store the full internal path in the Tag so we know what to load when clicked
item.Tag = resourceName;
// Wire up the click event
item.Click += IncludedTapMenuItem_Click;
// Add it to the "Open Included..." dropdown
tAPToolStripMenuItem1.DropDownItems.Add(item);
}
}
}
private void fastLoadToolStripMenuItem_Click(object sender, EventArgs e)
{
this.fastLoadToolStripMenuItem.Checked = !this.fastLoadToolStripMenuItem.Checked;
_enableFastLoad = this.fastLoadToolStripMenuItem.Checked;
}
private void IncludedTapMenuItem_Click(object? sender, EventArgs e)
{
if (sender is ToolStripMenuItem item && item.Tag is string resourceName)
@@ -357,7 +358,7 @@ namespace Desktop
// Feed it directly to your existing TapManager!
_tapManager.LoadTapData(tapBytes);
tapeLoaded = true;
_tapManager.Play();
//_tapManager.Play();
}
}
}
@@ -488,7 +489,7 @@ namespace Desktop
byte[] tapBytes = File.ReadAllBytes(ofd.FileName);
_tapManager.LoadTapData(tapBytes);
tapeLoaded = true;
_tapManager.Play();
//_tapManager.Play();
}
}
_isPaused = false;
@@ -643,11 +644,13 @@ namespace Desktop
{
playTapeToolStripMenuItem.Text = "Stop Tape";
_tapManager.Play();
tapePlaying = true;
}
else
{
playTapeToolStripMenuItem.Text = "Play Tape";
_tapManager.Stop();
tapePlaying = false;
}
}