mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-25 16:31:42 +00:00
Adjusted factoring to introduce support for block 10.
This commit is contained in:
parent
2fd071e45d
commit
2d2cefb0b0
@ -162,48 +162,58 @@ void TZX::get_generalised_segment(uint32_t output_symbols, uint8_t max_pulses_pe
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TZX::get_standard_speed_data_block() {
|
void TZX::get_standard_speed_data_block() {
|
||||||
__unused uint16_t pause_after_block = fgetc16le();
|
DataBlock data_block;
|
||||||
uint16_t data_length = fgetc16le();
|
data_block.length_of_pilot_pulse = 2168;
|
||||||
if(!data_length) return;
|
data_block.length_of_sync_first_pulse = 667;
|
||||||
|
data_block.length_of_sync_second_pulse = 735;
|
||||||
|
data_block.length_of_zero_bit_pulse = 855;
|
||||||
|
data_block.length_of_one_bit_pulse = 1710;
|
||||||
|
data_block.number_of_bits_in_final_byte = 8;
|
||||||
|
|
||||||
|
data_block.pause_after_block = fgetc16le();
|
||||||
|
data_block.data_length = fgetc16le();
|
||||||
|
if(!data_block.data_length) return;
|
||||||
|
|
||||||
uint8_t first_byte = (uint8_t)fgetc(file_);
|
uint8_t first_byte = (uint8_t)fgetc(file_);
|
||||||
__unused int pilot_tone_pulses = (first_byte < 128) ? 8063 : 3223;
|
data_block.length_of_pilot_tone = (first_byte < 128) ? 8063 : 3223;
|
||||||
ungetc(first_byte, file_);
|
ungetc(first_byte, file_);
|
||||||
|
|
||||||
// TODO: output pilot_tone_pulses pulses
|
get_data_block(data_block);
|
||||||
// TODO: output data_length bytes, in the Spectrum encoding
|
|
||||||
fseek(file_, data_length, SEEK_CUR);
|
|
||||||
// TODO: output a pause of length paused_after_block ms
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TZX::get_turbo_speed_data_block() {
|
void TZX::get_turbo_speed_data_block() {
|
||||||
uint16_t length_of_pilot_pulse = fgetc16le();
|
DataBlock data_block;
|
||||||
uint16_t length_of_sync_first_pulse = fgetc16le();
|
data_block.length_of_pilot_pulse = fgetc16le();
|
||||||
uint16_t length_of_sync_second_pulse = fgetc16le();
|
data_block.length_of_sync_first_pulse = fgetc16le();
|
||||||
uint16_t length_of_zero_bit_pulse = fgetc16le();
|
data_block.length_of_sync_second_pulse = fgetc16le();
|
||||||
uint16_t length_of_one_bit_pulse = fgetc16le();
|
data_block.length_of_zero_bit_pulse = fgetc16le();
|
||||||
uint16_t length_of_pilot_tone = fgetc16le();
|
data_block.length_of_one_bit_pulse = fgetc16le();
|
||||||
uint8_t number_of_bits_in_final_byte = (uint8_t)fgetc(file_);
|
data_block.length_of_pilot_tone = fgetc16le();
|
||||||
uint16_t pause_after_block = fgetc16le();
|
data_block.number_of_bits_in_final_byte = (uint8_t)fgetc(file_);
|
||||||
long data_length = fgetc16le();
|
data_block.pause_after_block = fgetc16le();
|
||||||
data_length |= (long)(fgetc(file_) << 16);
|
data_block.data_length = fgetc16le();
|
||||||
|
data_block.data_length |= (long)(fgetc(file_) << 16);
|
||||||
|
|
||||||
|
get_data_block(data_block);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TZX::get_data_block(const DataBlock &data_block) {
|
||||||
// Output pilot tone.
|
// Output pilot tone.
|
||||||
while(length_of_pilot_tone--) {
|
for(unsigned int c = 0; c < data_block.length_of_pilot_tone; c++) {
|
||||||
post_pulse(length_of_pilot_pulse);
|
post_pulse(data_block.length_of_pilot_pulse);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output sync pulses.
|
// Output sync pulses.
|
||||||
post_pulse(length_of_sync_first_pulse);
|
post_pulse(data_block.length_of_sync_first_pulse);
|
||||||
post_pulse(length_of_sync_second_pulse);
|
post_pulse(data_block.length_of_sync_second_pulse);
|
||||||
|
|
||||||
// Output data.
|
// Output data.
|
||||||
while(data_length--) {
|
for(unsigned int c = 0; c < data_block.data_length; c++) {
|
||||||
uint8_t next_byte = (uint8_t)fgetc(file_);
|
uint8_t next_byte = (uint8_t)fgetc(file_);
|
||||||
|
|
||||||
int c = data_length ? 8 : number_of_bits_in_final_byte;
|
unsigned int bits = (c != data_block.data_length-1) ? 8 : data_block.number_of_bits_in_final_byte;
|
||||||
while(c--) {
|
while(bits--) {
|
||||||
uint16_t pulse_length = (next_byte & 0x80) ? length_of_one_bit_pulse : length_of_zero_bit_pulse;
|
unsigned int pulse_length = (next_byte & 0x80) ? data_block.length_of_one_bit_pulse : data_block.length_of_zero_bit_pulse;
|
||||||
next_byte <<= 1;
|
next_byte <<= 1;
|
||||||
|
|
||||||
post_pulse(pulse_length);
|
post_pulse(pulse_length);
|
||||||
@ -212,7 +222,7 @@ void TZX::get_turbo_speed_data_block() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Output gap.
|
// Output gap.
|
||||||
post_gap(pause_after_block);
|
post_gap(data_block.pause_after_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TZX::get_pure_tone_data_block() {
|
void TZX::get_pure_tone_data_block() {
|
||||||
|
@ -44,7 +44,20 @@ class TZX: public PulseQueuedTape, public Storage::FileHolder {
|
|||||||
void get_generalised_data_block();
|
void get_generalised_data_block();
|
||||||
void get_pause();
|
void get_pause();
|
||||||
|
|
||||||
|
struct DataBlock {
|
||||||
|
unsigned int length_of_pilot_pulse;
|
||||||
|
unsigned int length_of_sync_first_pulse;
|
||||||
|
unsigned int length_of_sync_second_pulse;
|
||||||
|
unsigned int length_of_zero_bit_pulse;
|
||||||
|
unsigned int length_of_one_bit_pulse;
|
||||||
|
unsigned int length_of_pilot_tone;
|
||||||
|
unsigned int number_of_bits_in_final_byte;
|
||||||
|
unsigned int pause_after_block;
|
||||||
|
long data_length;
|
||||||
|
};
|
||||||
|
|
||||||
void get_generalised_segment(uint32_t output_symbols, uint8_t max_pulses_per_symbol, uint8_t number_of_symbols, bool is_data);
|
void get_generalised_segment(uint32_t output_symbols, uint8_t max_pulses_per_symbol, uint8_t number_of_symbols, bool is_data);
|
||||||
|
void get_data_block(const DataBlock &);
|
||||||
|
|
||||||
void post_pulse(unsigned int length);
|
void post_pulse(unsigned int length);
|
||||||
void post_gap(unsigned int milliseconds);
|
void post_gap(unsigned int milliseconds);
|
||||||
|
Loading…
Reference in New Issue
Block a user