1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

A quick hard-wiring of the OricTAP code to get the first file in a .tap correct, damn the rest, and I'm getting some on-screen feedback. Hooray!

This commit is contained in:
Thomas Harte 2016-10-15 21:39:53 -04:00
parent a608bbebfb
commit 952a24f769

View File

@ -42,9 +42,9 @@ 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 = LeadIn; _phase = _next_phase = LeadIn;
_phase_counter = 0; _phase_counter = 0;
_pulse_counter = 0; _pulse_counter = 0;
} }
@ -65,9 +65,9 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
switch(_phase) switch(_phase)
{ {
case LeadIn: case LeadIn:
next_byte = 0x16; next_byte = _phase_counter < 256 ? 0x16 : 0x24;
_phase_counter++; _phase_counter++;
if(_phase_counter == 256) // 256 artificial bytes plus the three in the file = 259 if(_phase_counter == 259) // 256 artificial bytes plus the three in the file = 259
{ {
_next_phase = Header; _next_phase = Header;
} }
@ -75,24 +75,22 @@ Tape::Pulse OricTAP::virtual_get_next_pulse()
case Header: case Header:
// Counts are relative to: // Counts are relative to:
// [0, 2]: value 0x16 // [0, 1]: "two bytes unused" (on the Oric 1)
// 3: value '$' // 2: program type
// [4, 5]: "two bytes unused" (on the Oric 1) // 3: auto indicator
// 6: program type // [4, 5]: end address of data
// 7: auto indicator // [6, 7]: start address of data
// [8, 9]: end address of data // 8: "unused" (on the Oric 1)
// [10, 11]: start address of data // [9...]: filename, up to NULL byte
// 12: "unused" (on the Oric 1)
// [13...]: filename, up to NULL byte
next_byte = (uint8_t)fgetc(_file); next_byte = (uint8_t)fgetc(_file);
if(_phase_counter == 8) _data_end_address = (uint16_t)(next_byte << 8); if(_phase_counter == 4) _data_end_address = (uint16_t)(next_byte << 8);
if(_phase_counter == 9) _data_end_address |= next_byte; if(_phase_counter == 5) _data_end_address |= next_byte;
if(_phase_counter == 10) _data_start_address = (uint16_t)(next_byte << 8); if(_phase_counter == 6) _data_start_address = (uint16_t)(next_byte << 8);
if(_phase_counter == 11) _data_start_address |= next_byte; if(_phase_counter == 7) _data_start_address |= next_byte;
_phase_counter++; _phase_counter++;
if(_phase_counter > 12 && !next_byte) // advance after the filename-ending NULL byte if(_phase_counter >= 9 && !next_byte) // advance after the filename-ending NULL byte
{ {
_next_phase = Gap; _next_phase = Gap;
} }