diff options
author | Maxwell Beck <max@rastertail.net> | 2025-07-19 18:02:26 -0500 |
---|---|---|
committer | Maxwell Beck <max@rastertail.net> | 2025-07-19 18:02:26 -0500 |
commit | 38f2755daa2456a4ebcaadcf3ddd2ff88e4fa838 (patch) | |
tree | 7fd71d1275279160f3769640d4d0c824b00af5dd /src | |
parent | 51e0bafe0304b201652fd32564138d6ca78a819d (diff) |
fix: Various drive corrections
Fixes turn-disk crashes.
Diffstat (limited to 'src')
-rw-r--r-- | src/drive.c | 10 | ||||
-rw-r--r-- | src/drive.h | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/drive.c b/src/drive.c index c71cd1f..9193608 100644 --- a/src/drive.c +++ b/src/drive.c @@ -9,7 +9,7 @@ const uint8_t SECTORS_PER_TRACK[35] = { 17, 17, 17, 17, 17 }; -const uint8_t BITRATES[4] = { 61, 65, 68, 76 }; +const uint16_t BITRATES[4] = { 16221, 17175, 18129, 20038 }; const uint8_t GCR_CONV[16] = { 0x0a, 0x0b, 0x12, 0x13, @@ -25,7 +25,7 @@ void drive_init(drive_t *drive) { drive->track = 17; drive->halftrack = 0; - drive->bitrate = 0; + drive->bitrate = 2; drive->image_ptr = 0x16500; drive->sector = 0; drive->byte = 0; @@ -79,7 +79,7 @@ bool drive_advance(drive_t *drive, uint8_t cycles) { void drive_cycle(drive_t *drive) { while (drive->lookahead_idx != ((drive->current_idx - 1) & (DRIVE_LOOKAHEAD - 1))) { uint8_t j = (drive->lookahead_idx + 1) & (DRIVE_LOOKAHEAD - 1); - uint8_t timer_next = drive->timer + BITRATES[drive->bitrate]; + uint16_t timer_next = drive->timer + BITRATES[drive->bitrate]; uint16_t prev = drive->unlatched[drive->lookahead_idx]; if (timer_next < drive->timer) { @@ -137,13 +137,13 @@ void drive_cycle(drive_t *drive) { break; case 1: case 0: - drive->gcr_word = (GCR_CONV[0x0] << 5) | GCR_CONV[0xf]; + drive->gcr_word = (GCR_CONV[0x0] << 5) | GCR_CONV[0x0]; break; default: { uint8_t b = drive->image[drive->image_ptr + (drive->sector << 8) + drive->byte]; drive->gcr_word = (GCR_CONV[(b & 0xf0) >> 4] << 5) | GCR_CONV[b & 0x0f]; - drive->data_checksum ^= b; + drive->data_checksum ^= b; uint8_t byte_next = drive->byte + 1; uint8_t sector_next = drive->sector; diff --git a/src/drive.h b/src/drive.h index d2e8dd8..a555f15 100644 --- a/src/drive.h +++ b/src/drive.h @@ -7,12 +7,12 @@ #define DRIVE_LOOKAHEAD 8 extern const uint8_t SECTORS_PER_TRACK[35]; -extern const uint8_t BITRATES[4]; +extern const uint16_t BITRATES[4]; extern const uint8_t GCR_CONV[16]; typedef struct drive_s { volatile bool spinning; - uint8_t timer; + uint16_t timer; uint8_t *image; volatile uint8_t track; |