mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-23 20:29:42 +00:00
Tweaked bit timing decision.
This commit is contained in:
parent
ae1a130843
commit
648618d280
@ -14,27 +14,22 @@ Parser::Parser() :
|
|||||||
::Storage::Tape::Parser<WaveType, SymbolType>(),
|
::Storage::Tape::Parser<WaveType, SymbolType>(),
|
||||||
crc_(0x1021, 0x0000) {}
|
crc_(0x1021, 0x0000) {}
|
||||||
|
|
||||||
int Parser::get_next_bit(const std::shared_ptr<Storage::Tape::Tape> &tape)
|
int Parser::get_next_bit(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||||
{
|
|
||||||
SymbolType symbol = get_next_symbol(tape);
|
SymbolType symbol = get_next_symbol(tape);
|
||||||
return (symbol == SymbolType::One) ? 1 : 0;
|
return (symbol == SymbolType::One) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape)
|
int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||||
{
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
int c = 8;
|
int c = 8;
|
||||||
if(get_next_bit(tape))
|
if(get_next_bit(tape)) {
|
||||||
{
|
|
||||||
set_error_flag();
|
set_error_flag();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
while(c--)
|
while(c--) {
|
||||||
{
|
|
||||||
value = (value >> 1) | (get_next_bit(tape) << 7);
|
value = (value >> 1) | (get_next_bit(tape) << 7);
|
||||||
}
|
}
|
||||||
if(!get_next_bit(tape))
|
if(!get_next_bit(tape)) {
|
||||||
{
|
|
||||||
set_error_flag();
|
set_error_flag();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -42,15 +37,13 @@ int Parser::get_next_byte(const std::shared_ptr<Storage::Tape::Tape> &tape)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Parser::get_next_short(const std::shared_ptr<Storage::Tape::Tape> &tape)
|
int Parser::get_next_short(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||||
{
|
|
||||||
int result = get_next_byte(tape);
|
int result = get_next_byte(tape);
|
||||||
result |= get_next_byte(tape) << 8;
|
result |= get_next_byte(tape) << 8;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Parser::get_next_word(const std::shared_ptr<Storage::Tape::Tape> &tape)
|
int Parser::get_next_word(const std::shared_ptr<Storage::Tape::Tape> &tape) {
|
||||||
{
|
|
||||||
int result = get_next_short(tape);
|
int result = get_next_short(tape);
|
||||||
result |= get_next_short(tape) << 8;
|
result |= get_next_short(tape) << 8;
|
||||||
return result;
|
return result;
|
||||||
@ -59,28 +52,25 @@ int Parser::get_next_word(const std::shared_ptr<Storage::Tape::Tape> &tape)
|
|||||||
void Parser::reset_crc() { crc_.reset(); }
|
void Parser::reset_crc() { crc_.reset(); }
|
||||||
uint16_t Parser::get_crc() { return crc_.get_value(); }
|
uint16_t Parser::get_crc() { return crc_.get_value(); }
|
||||||
|
|
||||||
void Parser::process_pulse(Storage::Tape::Tape::Pulse pulse)
|
void Parser::process_pulse(Storage::Tape::Tape::Pulse pulse) {
|
||||||
{
|
switch(pulse.type) {
|
||||||
switch(pulse.type)
|
|
||||||
{
|
|
||||||
default: break;
|
default: break;
|
||||||
case Storage::Tape::Tape::Pulse::High:
|
case Storage::Tape::Tape::Pulse::High:
|
||||||
case Storage::Tape::Tape::Pulse::Low:
|
case Storage::Tape::Tape::Pulse::Low:
|
||||||
float pulse_length = pulse.length.get_float();
|
float pulse_length = pulse.length.get_float();
|
||||||
if(pulse_length >= 0.35 / 2400.0 && pulse_length < 0.7 / 2400.0) { push_wave(WaveType::Short); return; }
|
if(pulse_length >= 0.35 / 2400.0 && pulse_length < 0.7 / 1200.0) {
|
||||||
if(pulse_length >= 0.35 / 1200.0 && pulse_length < 0.7 / 1200.0) { push_wave(WaveType::Long); return; }
|
push_wave(pulse_length > 1.0 / 3000.0 ? WaveType::Long : WaveType::Short); return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
push_wave(WaveType::Unrecognised);
|
push_wave(WaveType::Unrecognised);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::inspect_waves(const std::vector<WaveType> &waves)
|
void Parser::inspect_waves(const std::vector<WaveType> &waves) {
|
||||||
{
|
|
||||||
if(waves.size() < 2) return;
|
if(waves.size() < 2) return;
|
||||||
|
|
||||||
if(waves[0] == WaveType::Long && waves[1] == WaveType::Long)
|
if(waves[0] == WaveType::Long && waves[1] == WaveType::Long) {
|
||||||
{
|
|
||||||
push_symbol(SymbolType::Zero, 2);
|
push_symbol(SymbolType::Zero, 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -90,8 +80,7 @@ void Parser::inspect_waves(const std::vector<WaveType> &waves)
|
|||||||
if( waves[0] == WaveType::Short &&
|
if( waves[0] == WaveType::Short &&
|
||||||
waves[1] == WaveType::Short &&
|
waves[1] == WaveType::Short &&
|
||||||
waves[2] == WaveType::Short &&
|
waves[2] == WaveType::Short &&
|
||||||
waves[3] == WaveType::Short)
|
waves[3] == WaveType::Short) {
|
||||||
{
|
|
||||||
push_symbol(SymbolType::One, 4);
|
push_symbol(SymbolType::One, 4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user