1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-04 18:29:40 +00:00

Made an attempt better to deal with multiple-file TAPs; also started using a zero level for the header/data gap.

This commit is contained in:
Thomas Harte 2016-10-24 21:59:06 -04:00
parent 30d4a7c662
commit d3634488e6
2 changed files with 23 additions and 18 deletions

View File

@ -42,7 +42,7 @@ OricTAP::~OricTAP()
void OricTAP::virtual_reset()
{
// fseek(_file, 0, SEEK_SET);
fseek(_file, 0, SEEK_SET);
_bit_count = 13;
_phase = _next_phase = LeadIn;
_phase_counter = 0;
@ -69,6 +69,10 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
_phase_counter++;
if(_phase_counter == 259) // 256 artificial bytes plus the three in the file = 259
{
while(1)
{
if(fgetc(_file) != 0x16) break;
}
_next_phase = Header;
}
break;
@ -106,20 +110,18 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
case Data:
next_byte = (uint8_t)fgetc(_file);
if(feof(_file)) _phase = End;
// _phase_counter++;
// if(_phase_counter == (_data_end_address - _data_start_address)+1)
// {
// _phase_counter = 0;
// if((size_t)ftell(_file) == _file_length)
// {
// _next_phase = End;
// }
// else
// {
// _next_phase = LeadIn;
// }
// }
_phase_counter++;
if(_phase_counter >= (_data_end_address - _data_start_address)+1)
{
if(next_byte == 0x16)
{
_next_phase = LeadIn;
}
else if(feof(_file))
{
_next_phase = End;
}
}
break;
case End:
@ -148,8 +150,10 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
return pulse;
case Gap:
next_bit = 1;
break;
_bit_count = 13;
pulse.type = Pulse::Zero;
pulse.length.length = 100;
return pulse;
default:
next_bit = _current_value & 1;

View File

@ -42,14 +42,15 @@ class OricTAP: public Tape {
FILE *_file;
size_t _file_length;
// byte serialisation and output
uint16_t _current_value;
int _bit_count;
int _pulse_counter;
int _phase_counter;
enum Phase {
LeadIn, Header, Data, Gap, End
} _phase, _next_phase;
int _phase_counter;
uint16_t _data_end_address, _data_start_address;
};