Disk adjustment magic numbers lifted out as variables so it will be easier to remember them and adjust them

This commit is contained in:
tudnai 2020-05-06 20:49:15 -07:00
parent 5051c0f8c7
commit 572977f5f8
1 changed files with 5 additions and 2 deletions

View File

@ -254,12 +254,15 @@ uint8_t woz_read() {
clkelpased = m6502.clktime - m6502.clklast;
m6502.clklast = m6502.clktime;
const int clkBeforeAdjusting = 250;
const int magicShiftOffset = 90;
uint16_t usedBytes = woz_trks[track].bytes_used < WOZ_TRACK_BYTE_COUNT ? woz_trks[track].bytes_used : WOZ_TRACK_BYTE_COUNT;
if ( usedBytes ) {
if ( clkelpased > 120 ) {
if ( clkelpased > clkBeforeAdjusting ) {
// printf("NEED SYNC : %llu\n", clkelpased);
bitOffset = (clkelpased >> 2) & 7;
trackOffset += ((clkelpased >> 5) +80) % usedBytes;
trackOffset += ((clkelpased >> 5) + magicShiftOffset) % usedBytes;
WOZread.data = woz_trks[track].data[trackOffset];
}