Fixed fast and slow tape loading and play_stop tape
This commit is contained in:
@@ -145,10 +145,24 @@ namespace Core.Io
|
||||
CalculateNextDataPulse();
|
||||
}
|
||||
break;
|
||||
|
||||
//case TapeState.Pause:
|
||||
// // The .TAP Format Auto-Stop Heuristic:
|
||||
// if (_currentBlock != null && _currentBlock.Length > 0 && _currentBlock[0] == 0x00)
|
||||
// {
|
||||
// // 1. It was a Header block. The ROM is waiting for the Data right now! Keep spinning.
|
||||
// LoadNextBlock();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 2. It was a Data block (or custom). The "file" is done.
|
||||
// // Auto-Stop the tape deck so we don't accidentally play the next level into the void.
|
||||
// _state = TapeState.Idle;
|
||||
// _currentBlock = null;
|
||||
// }
|
||||
// break;
|
||||
case TapeState.Pause:
|
||||
_state = TapeState.Idle;
|
||||
//LoadNextBlock();
|
||||
LoadNextBlock();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -170,12 +184,14 @@ namespace Core.Io
|
||||
|
||||
//public bool HasBlocks => _blocks.Count > 0;
|
||||
// Change this line:
|
||||
public bool HasBlocks => _blocks.Count > 0 || _currentBlock != null;
|
||||
//public bool HasBlocks => _blocks.Count > 0 || _currentBlock != null;
|
||||
// Only consider _currentBlock valid if we are actively playing it!
|
||||
public bool HasBlocks => _blocks.Count > 0 || (_currentBlock != null && _state != TapeState.Idle && _state != TapeState.Pause);
|
||||
|
||||
public byte[] GetNextBlock()
|
||||
{
|
||||
// If a block is loaded into the tape deck, yank it immediately
|
||||
if (_currentBlock != null)
|
||||
// Yank the current block ONLY if it is actively playing
|
||||
if (_currentBlock != null && _state != TapeState.Idle && _state != TapeState.Pause)
|
||||
{
|
||||
byte[] blockToReturn = _currentBlock;
|
||||
_state = TapeState.Idle; // Ensure the tape deck is stopped
|
||||
@@ -183,7 +199,9 @@ namespace Core.Io
|
||||
return blockToReturn;
|
||||
}
|
||||
|
||||
// Otherwise, pull directly from the queue
|
||||
// Otherwise, pull directly from the unplayed queue
|
||||
_state = TapeState.Idle; // Stop the tape deck just in case
|
||||
_currentBlock = null;
|
||||
return _blocks.Count > 0 ? _blocks.Dequeue() : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user