vt_dsk: Restore the newer bitstream generator, except for the part that was actually broken

This commit is contained in:
AJR 2024-11-20 19:18:27 -05:00
parent 35d7c11f91
commit e3907cb697

View File

@ -94,29 +94,41 @@ std::vector<uint8_t> vtech_common_format::flux_to_image(const floppy_image &imag
continue; continue;
std::vector<bool> bitstream; std::vector<bool> bitstream;
int lpos = -1; int cpos = 0;
bool looped = !((buffer[sz-1] ^ buffer[0]) & floppy_image::MG_MASK); while((buffer[cpos] & floppy_image::MG_MASK) != floppy_image::MG_F) {
int cpos = looped ? sz-1 : 0; cpos++;
while(cpos != lpos) { if(cpos == sz) {
int dt = looped && cpos == sz-1 ? (200000000 - (buffer[cpos] & floppy_image::TIME_MASK)) + (buffer[1] & floppy_image::TIME_MASK) : cpos = -1;
cpos == sz-1 ? 200000000 - (buffer[cpos] & floppy_image::TIME_MASK) : break;
(buffer[cpos+1] & floppy_image::TIME_MASK) - (buffer[cpos] & floppy_image::TIME_MASK); }
}
if(cpos == -1)
continue;
for(;;) {
int npos = cpos;
for(;;) {
npos++;
if(npos == sz)
npos = 0;
if((buffer[npos] & floppy_image::MG_MASK) == floppy_image::MG_F)
break;
}
int dt = (buffer[npos] & floppy_image::TIME_MASK) - (buffer[cpos] & floppy_image::TIME_MASK);
if(dt < 0)
cpos += 200000000;
int t = dt >= 9187 - 143 ? 0 : int t = dt >= 9187 - 143 ? 0 :
dt >= 2237 - 143 && dt <= 2237 + 143 ? 1 : dt >= 2237 - 143 && dt <= 2237 + 143 ? 1 :
2; 2;
if(t <= 1) { if(t <= 1)
if(lpos == -1)
lpos = cpos;
bitstream.push_back(t); bitstream.push_back(t);
} if(npos <= cpos)
cpos += 1; break;
if(cpos == sz) cpos = npos;
cpos = looped ? 1 : 0;
} }
int mode = 0; int mode = 0;
int pos = 0; int pos = 0;
int count = 0; int count = 0;
looped = false; bool looped = false;
uint8_t *dest = nullptr; uint8_t *dest = nullptr;
[[maybe_unused]] uint16_t checksum = 0; [[maybe_unused]] uint16_t checksum = 0;
uint64_t buf = 0; uint64_t buf = 0;