mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +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:
parent
30d4a7c662
commit
d3634488e6
@ -42,7 +42,7 @@ OricTAP::~OricTAP()
|
|||||||
|
|
||||||
void OricTAP::virtual_reset()
|
void OricTAP::virtual_reset()
|
||||||
{
|
{
|
||||||
// fseek(_file, 0, SEEK_SET);
|
fseek(_file, 0, SEEK_SET);
|
||||||
_bit_count = 13;
|
_bit_count = 13;
|
||||||
_phase = _next_phase = LeadIn;
|
_phase = _next_phase = LeadIn;
|
||||||
_phase_counter = 0;
|
_phase_counter = 0;
|
||||||
@ -69,6 +69,10 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
|
|||||||
_phase_counter++;
|
_phase_counter++;
|
||||||
if(_phase_counter == 259) // 256 artificial bytes plus the three in the file = 259
|
if(_phase_counter == 259) // 256 artificial bytes plus the three in the file = 259
|
||||||
{
|
{
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(fgetc(_file) != 0x16) break;
|
||||||
|
}
|
||||||
_next_phase = Header;
|
_next_phase = Header;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -106,20 +110,18 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
|
|||||||
|
|
||||||
case Data:
|
case Data:
|
||||||
next_byte = (uint8_t)fgetc(_file);
|
next_byte = (uint8_t)fgetc(_file);
|
||||||
if(feof(_file)) _phase = End;
|
_phase_counter++;
|
||||||
// _phase_counter++;
|
if(_phase_counter >= (_data_end_address - _data_start_address)+1)
|
||||||
// if(_phase_counter == (_data_end_address - _data_start_address)+1)
|
{
|
||||||
// {
|
if(next_byte == 0x16)
|
||||||
// _phase_counter = 0;
|
{
|
||||||
// if((size_t)ftell(_file) == _file_length)
|
_next_phase = LeadIn;
|
||||||
// {
|
}
|
||||||
// _next_phase = End;
|
else if(feof(_file))
|
||||||
// }
|
{
|
||||||
// else
|
_next_phase = End;
|
||||||
// {
|
}
|
||||||
// _next_phase = LeadIn;
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case End:
|
case End:
|
||||||
@ -148,8 +150,10 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
|
|||||||
return pulse;
|
return pulse;
|
||||||
|
|
||||||
case Gap:
|
case Gap:
|
||||||
next_bit = 1;
|
_bit_count = 13;
|
||||||
break;
|
pulse.type = Pulse::Zero;
|
||||||
|
pulse.length.length = 100;
|
||||||
|
return pulse;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
next_bit = _current_value & 1;
|
next_bit = _current_value & 1;
|
||||||
|
@ -42,14 +42,15 @@ class OricTAP: public Tape {
|
|||||||
FILE *_file;
|
FILE *_file;
|
||||||
size_t _file_length;
|
size_t _file_length;
|
||||||
|
|
||||||
|
// byte serialisation and output
|
||||||
uint16_t _current_value;
|
uint16_t _current_value;
|
||||||
int _bit_count;
|
int _bit_count;
|
||||||
int _pulse_counter;
|
int _pulse_counter;
|
||||||
int _phase_counter;
|
|
||||||
|
|
||||||
enum Phase {
|
enum Phase {
|
||||||
LeadIn, Header, Data, Gap, End
|
LeadIn, Header, Data, Gap, End
|
||||||
} _phase, _next_phase;
|
} _phase, _next_phase;
|
||||||
|
int _phase_counter;
|
||||||
uint16_t _data_end_address, _data_start_address;
|
uint16_t _data_end_address, _data_start_address;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user