diff options
-rw-r--r-- | src/drive.c | 10 | ||||
-rw-r--r-- | src/drive.h | 3 | ||||
-rw-r--r-- | src/pico1541.c | 1 |
3 files changed, 6 insertions, 8 deletions
diff --git a/src/drive.c b/src/drive.c index 5bc2e3b..e31a964 100644 --- a/src/drive.c +++ b/src/drive.c @@ -9,12 +9,7 @@ const uint8_t SECTORS_PER_TRACK[40] = { 17, 17, 17, 17, 17, 17, 17, 17, 17, 17 }; -const uint8_t BITRATE_PER_TRACK[40] = { - 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, - 68, 68, 68, 68, 68, 68, 68, - 65, 65, 65, 65, 65, 65, - 61 ,61, 61, 61, 61, 61, 61, 61, 61, 61 -}; +const uint8_t BITRATES[4] = { 61, 65, 68, 76 }; const uint8_t GCR_CONV[16] = { 0x0a, 0x0b, 0x12, 0x13, @@ -30,6 +25,7 @@ void drive_init(drive_t *drive) { drive->track = 17; drive->halftrack = 0; + drive->bitrate = 0; drive->image_ptr = 0x16500; drive->sector = 0; drive->byte = 0; @@ -83,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 + BITRATE_PER_TRACK[drive->track]; + uint8_t timer_next = drive->timer + BITRATES[drive->bitrate]; uint16_t prev = drive->unlatched[drive->lookahead_idx]; if (timer_next < drive->timer) { diff --git a/src/drive.h b/src/drive.h index aa72f60..c7e02f2 100644 --- a/src/drive.h +++ b/src/drive.h @@ -17,6 +17,7 @@ typedef struct drive_s { volatile uint8_t track; volatile uint8_t halftrack; + volatile uint8_t bitrate; volatile uint32_t image_ptr; volatile uint8_t sector; uint8_t byte; @@ -45,4 +46,4 @@ void drive_step_down(drive_t *drive); bool drive_advance(drive_t *drive, uint8_t cycles); void drive_cycle(drive_t *drive); -#endif \ No newline at end of file +#endif diff --git a/src/pico1541.c b/src/pico1541.c index 63cb74a..8a02587 100644 --- a/src/pico1541.c +++ b/src/pico1541.c @@ -94,6 +94,7 @@ void via_pb_write(via_t *via, uint8_t cycle) { } drive.spinning = ((via->ddrb & via->orb) & 4) > 0; + drive.bitrate = ((via->ddrb & via->orb) & 0b01100000) >> 5; gpio_put(GPIO_LED, (via->orb & 0b00001000) > 0 && (via->ddrb & 0b00001000) > 0); } |