Datacorder - implement basic manual tape block navigation (i.e. NextBlock, PrevBlock)
This commit is contained in:
parent
e6d43fa5d2
commit
c7fe4c2887
|
@ -315,6 +315,66 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
_currentDataBlockIndex = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs a block skip operation on the current tape
|
||||
/// TRUE: skip forward
|
||||
/// FALSE: skip backward
|
||||
/// </summary>
|
||||
/// <param name="skipForward"></param>
|
||||
public void SkipBlock(bool skipForward)
|
||||
{
|
||||
int blockCount = _dataBlocks.Count;
|
||||
int targetBlockId = _currentDataBlockIndex;
|
||||
|
||||
if (skipForward)
|
||||
{
|
||||
if (_currentDataBlockIndex == blockCount - 1)
|
||||
{
|
||||
// last block, go back to beginning
|
||||
targetBlockId = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetBlockId++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_currentDataBlockIndex == 0)
|
||||
{
|
||||
// already first block, goto last block
|
||||
targetBlockId = blockCount - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetBlockId--;
|
||||
}
|
||||
}
|
||||
|
||||
var bl = _dataBlocks[targetBlockId];
|
||||
|
||||
StringBuilder sbd = new StringBuilder();
|
||||
sbd.Append("(");
|
||||
sbd.Append((targetBlockId + 1) + " of " + _dataBlocks.Count());
|
||||
sbd.Append(") : ");
|
||||
//sbd.Append("ID" + bl.BlockID.ToString("X2") + " - ");
|
||||
sbd.Append(bl.BlockDescription);
|
||||
if (bl.MetaData.Count > 0)
|
||||
{
|
||||
sbd.Append(" - ");
|
||||
sbd.Append(bl.MetaData.First().Key + ": " + bl.MetaData.First().Value);
|
||||
//sbd.Append("\n");
|
||||
//sbd.Append(bl.MetaData.Skip(1).First().Key + ": " + bl.MetaData.Skip(1).First().Value);
|
||||
}
|
||||
|
||||
if (skipForward)
|
||||
_machine.Spectrum.OSD_TapeNextBlock(sbd.ToString());
|
||||
else
|
||||
_machine.Spectrum.OSD_TapePrevBlock(sbd.ToString());
|
||||
|
||||
CurrentDataBlockIndex = targetBlockId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a new tape and sets up the tape device accordingly
|
||||
/// </summary>
|
||||
|
|
|
@ -15,12 +15,16 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
string Record = "Record Tape";
|
||||
string NextTape = "Insert Next Tape";
|
||||
string PrevTape = "Insert Previous Tape";
|
||||
string NextBlock = "Next Tape Block";
|
||||
string PrevBlock = "Prev Tape Block";
|
||||
|
||||
bool pressed_Play = false;
|
||||
bool pressed_Stop = false;
|
||||
bool pressed_RTZ = false;
|
||||
bool pressed_NextTape = false;
|
||||
bool pressed_PrevTape = false;
|
||||
bool pressed_NextBlock = false;
|
||||
bool pressed_PrevBlock = false;
|
||||
|
||||
public void PollInput()
|
||||
{
|
||||
|
@ -147,6 +151,30 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
}
|
||||
else
|
||||
pressed_PrevTape = false;
|
||||
|
||||
if (Spectrum._controller.IsPressed(NextBlock))
|
||||
{
|
||||
if (!pressed_NextBlock)
|
||||
{
|
||||
Spectrum.OSD_FireInputMessage(NextBlock);
|
||||
TapeDevice.SkipBlock(true);
|
||||
pressed_NextBlock = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
pressed_NextBlock = false;
|
||||
|
||||
if (Spectrum._controller.IsPressed(PrevBlock))
|
||||
{
|
||||
if (!pressed_PrevBlock)
|
||||
{
|
||||
Spectrum.OSD_FireInputMessage(PrevBlock);
|
||||
TapeDevice.SkipBlock(false);
|
||||
pressed_PrevBlock = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
pressed_PrevBlock = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -178,6 +178,28 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tape message that is fired when user has manually skipped to the next block
|
||||
/// </summary>
|
||||
public void OSD_TapeNextBlock(string blockinfo)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("Manual Skip Next " + blockinfo);
|
||||
|
||||
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tape message that is fired when user has manually skipped to the next block
|
||||
/// </summary>
|
||||
public void OSD_TapePrevBlock(string blockinfo)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("Manual Skip Prev " + blockinfo);
|
||||
|
||||
SendMessage(sb.ToString().TrimEnd('\n'), MessageCategory.Tape);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue