Some TapeDevice changes
This commit is contained in:
parent
81e80acf86
commit
22656fd373
BizHawk.Emulation.Cores/Computers/SinclairSpectrum
Hardware/Datacorder
Machine
|
@ -103,12 +103,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
private long _lastCycle = 0;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Edge
|
||||
/// </summary>
|
||||
private int _waitEdge = 0;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// Current tapebit state
|
||||
/// </summary>
|
||||
private bool currentState = false;
|
||||
|
||||
|
@ -132,11 +132,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
|
||||
#region Emulator
|
||||
|
||||
/// <summary>
|
||||
/// This is the address the that ROM will jump to when the spectrum has quit tape playing
|
||||
/// </summary>
|
||||
public const ushort ERROR_ROM_ADDRESS = 0x0008;
|
||||
|
||||
/// <summary>
|
||||
/// Should be fired at the end of every frame
|
||||
/// Primary purpose is to detect tape traps and manage auto play (if/when this is ever implemented)
|
||||
|
@ -522,7 +517,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
_lastCycle = cpuCycle - (long)cycles;
|
||||
|
||||
// play the buzzer
|
||||
_buzzer.ProcessPulseValue(true, currentState);
|
||||
_buzzer.ProcessPulseValue(false, currentState);
|
||||
|
||||
return currentState;
|
||||
}
|
||||
|
@ -598,7 +593,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
_machine.Spectrum.OSD_TapePlayingAuto();
|
||||
}
|
||||
|
||||
_monitorTimeOut = 50;
|
||||
_monitorTimeOut = 250;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -613,7 +608,10 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
|
||||
public void AutoStopTape()
|
||||
{
|
||||
if (!_tapeIsPlaying)
|
||||
if (_tapeIsPlaying)
|
||||
return;
|
||||
|
||||
if (!_machine.Spectrum.Settings.AutoLoadTape)
|
||||
return;
|
||||
|
||||
Stop();
|
||||
|
@ -625,25 +623,27 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
if (_tapeIsPlaying)
|
||||
return;
|
||||
|
||||
if (!_machine.Spectrum.Settings.AutoLoadTape)
|
||||
return;
|
||||
|
||||
Play();
|
||||
_machine.Spectrum.OSD_TapePlayingAuto();
|
||||
}
|
||||
|
||||
private void MonitorFrame()
|
||||
{
|
||||
/*
|
||||
if (_tapeIsPlaying && _machine.Spectrum.Settings.AutoLoadTape)
|
||||
{
|
||||
|
||||
_monitorTimeOut--;
|
||||
|
||||
if (_monitorTimeOut < 0)
|
||||
{
|
||||
// does not work properly - disabled for now (handled elsewhere)
|
||||
|
||||
//Stop();
|
||||
//_machine.Spectrum.OSD_TapeStoppedAuto();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -665,6 +665,23 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// <returns></returns>
|
||||
public bool ReadPort(ushort port, ref int result)
|
||||
{
|
||||
if (TapeIsPlaying)
|
||||
{
|
||||
GetEarBit(_cpu.TotalExecutedCycles);
|
||||
}
|
||||
if (currentState)
|
||||
{
|
||||
result |= TAPE_BIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
result &= ~TAPE_BIT;
|
||||
}
|
||||
|
||||
MonitorRead();
|
||||
|
||||
/*
|
||||
|
||||
if (TapeIsPlaying)
|
||||
{
|
||||
if (GetEarBit(_cpu.TotalExecutedCycles))
|
||||
|
@ -702,6 +719,8 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -713,8 +732,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
/// <returns></returns>
|
||||
public bool WritePort(ushort port, int result)
|
||||
{
|
||||
// not implemented yet
|
||||
return false;
|
||||
if (!TapeIsPlaying)
|
||||
{
|
||||
currentState = ((byte)result & 0x10) != 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -176,36 +176,58 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Monitors ROM access
|
||||
/// Used to auto start/stop the tape device when appropriate
|
||||
/// </summary>
|
||||
/// <param name="addr"></param>
|
||||
public virtual void TestForTapeTraps(int addr)
|
||||
{
|
||||
if (!TapeDevice.TapeIsPlaying)
|
||||
if (TapeDevice.TapeIsPlaying)
|
||||
{
|
||||
// THE 'ERROR' RESTART
|
||||
if (addr == 8)
|
||||
{
|
||||
TapeDevice?.AutoStopTape();
|
||||
return;
|
||||
}
|
||||
|
||||
// THE 'ED-ERROR' SUBROUTINE
|
||||
if (addr == 4223)
|
||||
{
|
||||
TapeDevice?.AutoStopTape();
|
||||
return;
|
||||
}
|
||||
|
||||
// THE 'ERROR-2' ROUTINE
|
||||
if (addr == 83)
|
||||
{
|
||||
TapeDevice?.AutoStopTape();
|
||||
return;
|
||||
}
|
||||
|
||||
// THE 'MASKABLE INTERRUPT' ROUTINE
|
||||
if (addr == 56)
|
||||
{
|
||||
//TapeDevice?.AutoStopTape();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// THE 'LD-BYTES' SUBROUTINE
|
||||
if (addr == 1366)
|
||||
{
|
||||
TapeDevice?.AutoStartTape();
|
||||
return;
|
||||
}
|
||||
|
||||
// THE 'LD-EDGE-2' AND 'LD-EDGE-1' SUBROUTINES
|
||||
if (addr == 1507)
|
||||
{
|
||||
TapeDevice?.AutoStartTape();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
// not a lagframe
|
||||
InputRead = true;
|
||||
|
||||
// tape loading monitor cycle
|
||||
TapeDevice.MonitorRead();
|
||||
|
||||
// process tape INs
|
||||
TapeDevice.ReadPort(port, ref result);
|
||||
}
|
||||
|
@ -229,6 +226,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
|
||||
// Buzzer
|
||||
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
|
||||
TapeDevice.WritePort(port, value);
|
||||
|
||||
// Tape
|
||||
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
|
||||
|
|
|
@ -43,9 +43,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
// not a lagframe
|
||||
InputRead = true;
|
||||
|
||||
// tape loading monitor cycle
|
||||
TapeDevice.MonitorRead();
|
||||
|
||||
// process tape INs
|
||||
TapeDevice.ReadPort(port, ref result);
|
||||
}
|
||||
|
@ -255,6 +252,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
// Buzzer
|
||||
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
|
||||
|
||||
// Tape
|
||||
TapeDevice.WritePort(port, value);
|
||||
|
||||
// Tape
|
||||
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
|
||||
}
|
||||
|
|
|
@ -43,9 +43,6 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
// not a lagframe
|
||||
InputRead = true;
|
||||
|
||||
// tape loading monitor cycle
|
||||
TapeDevice.MonitorRead();
|
||||
|
||||
// process tape INs
|
||||
TapeDevice.ReadPort(port, ref result);
|
||||
}
|
||||
|
@ -182,6 +179,9 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
// Buzzer
|
||||
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
|
||||
|
||||
// Tape
|
||||
TapeDevice.WritePort(port, value);
|
||||
|
||||
// Tape
|
||||
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
|
||||
}
|
||||
|
|
|
@ -40,10 +40,7 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
KeyboardDevice.ReadPort(port, ref result);
|
||||
|
||||
// not a lagframe
|
||||
InputRead = true;
|
||||
|
||||
// tape loading monitor cycle
|
||||
TapeDevice.MonitorRead();
|
||||
InputRead = true;
|
||||
|
||||
// process tape INs
|
||||
TapeDevice.ReadPort(port, ref result);
|
||||
|
@ -120,9 +117,12 @@ namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
|
|||
// Buzzer
|
||||
BuzzerDevice.ProcessPulseValue(false, (value & EAR_BIT) != 0);
|
||||
|
||||
// Tape
|
||||
TapeDevice.WritePort(port, value);
|
||||
|
||||
// Tape mic processing (not implemented yet)
|
||||
//TapeDevice.ProcessMicBit((value & MIC_BIT) != 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue