- for (int i = 0; i < pulse_lengths.size(); ++i) {
- int len = lrintf(pulse_lengths[i] * calibration_factor * C64_FREQUENCY / TAP_RESOLUTION);
- //fprintf(stderr, "length: %f (0x%x)\n", t - last_upflank, len);
- printf("0x%x\n", len);
+ std::vector<char> tap_data;
+ for (unsigned i = 0; i < pulses.size(); ++i) {
+ double cycles = pulses[i].len * calibration_factor * C64_FREQUENCY;
+ int len = lrintf(cycles / TAP_RESOLUTION);
+ if (i > 15000 && (cycles < 100 || cycles > 800)) {
+ fprintf(stderr, "Cycle with upflank at %.6f was detected at %.0f cycles; misdetect?\n",
+ pulses[i].time, cycles);
+ }
+ if (len <= 255) {
+ tap_data.push_back(len);
+ } else {
+ int overflow_len = lrintf(cycles);
+ tap_data.push_back(0);
+ tap_data.push_back(overflow_len & 0xff);
+ tap_data.push_back((overflow_len >> 8) & 0xff);
+ tap_data.push_back(overflow_len >> 16);
+ }