mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-11 08:30:55 +00:00
Fixed: length of 0 is a special case.
This commit is contained in:
parent
33d16ae0cd
commit
ae1a130843
@ -87,6 +87,22 @@ uint8_t CSW::get_next_byte() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t CSW::get_next_int32le() {
|
||||||
|
switch(compression_type_) {
|
||||||
|
case RLE: return fgetc32le();
|
||||||
|
case ZRLE: {
|
||||||
|
if(source_data_pointer_ > source_data_.size() - 4) return 0xffff;
|
||||||
|
uint32_t result = (uint32_t)(
|
||||||
|
(source_data_[source_data_pointer_ + 0] << 0) |
|
||||||
|
(source_data_[source_data_pointer_ + 1] << 8) |
|
||||||
|
(source_data_[source_data_pointer_ + 2] << 16) |
|
||||||
|
(source_data_[source_data_pointer_ + 3] << 24));
|
||||||
|
source_data_pointer_ += 4;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSW::invert_pulse() {
|
void CSW::invert_pulse() {
|
||||||
pulse_.type = (pulse_.type == Pulse::High) ? Pulse::Low : Pulse::High;
|
pulse_.type = (pulse_.type == Pulse::High) ? Pulse::Low : Pulse::High;
|
||||||
}
|
}
|
||||||
@ -108,5 +124,6 @@ void CSW::virtual_reset() {
|
|||||||
Tape::Pulse CSW::virtual_get_next_pulse() {
|
Tape::Pulse CSW::virtual_get_next_pulse() {
|
||||||
invert_pulse();
|
invert_pulse();
|
||||||
pulse_.length.length = get_next_byte();
|
pulse_.length.length = get_next_byte();
|
||||||
|
if(!pulse_.length.length) pulse_.length.length = get_next_int32le();
|
||||||
return pulse_;
|
return pulse_;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ class CSW: public Tape, public Storage::FileHolder {
|
|||||||
} compression_type_;
|
} compression_type_;
|
||||||
|
|
||||||
uint8_t get_next_byte();
|
uint8_t get_next_byte();
|
||||||
|
uint32_t get_next_int32le();
|
||||||
void invert_pulse();
|
void invert_pulse();
|
||||||
|
|
||||||
std::vector<uint8_t> source_data_;
|
std::vector<uint8_t> source_data_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user