diff options
author | Maxwell Beck <max@rastertail.net> | 2024-12-24 10:54:02 -0600 |
---|---|---|
committer | Maxwell Beck <max@rastertail.net> | 2024-12-24 10:54:02 -0600 |
commit | c684c194bccdb08df75423680ba334739a945fe5 (patch) | |
tree | ea052b7f413936629421fbb784aaea1dedb8133c /src/drive.h |
Initial commit
Diffstat (limited to 'src/drive.h')
-rw-r--r-- | src/drive.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/drive.h b/src/drive.h new file mode 100644 index 0000000..b9fb1f2 --- /dev/null +++ b/src/drive.h @@ -0,0 +1,47 @@ +#ifndef DRIVE_H +#define DRIVE_H + +#include <stdbool.h> +#include <stdint.h> + +#define DRIVE_LOOKAHEAD 16 + +extern const uint8_t SECTORS_PER_TRACK[40]; +extern const uint8_t BITRATE_PER_TRACK[40]; +extern const uint8_t GCR_CONV[16]; + +typedef struct drive_s { + bool spinning; + uint8_t timer; + uint8_t *image; + + uint8_t track; + uint8_t halftrack; + uint32_t image_ptr; + uint8_t sector; + uint8_t byte; + + uint16_t gcr_word; + uint8_t gcr_bits; + uint8_t bit_counter; + + uint8_t gap_remain; + uint8_t sync_remain; + uint8_t header_remain; + uint16_t data_remain; + uint8_t data_checksum; + + uint8_t current_idx; + uint8_t lookahead_idx; + uint16_t unlatched[DRIVE_LOOKAHEAD]; + uint16_t latched[DRIVE_LOOKAHEAD]; + bool sync[DRIVE_LOOKAHEAD]; + bool byte_ready[DRIVE_LOOKAHEAD]; +} drive_t; + +void drive_init(drive_t *drive); +void drive_step_up(drive_t *drive); +void drive_step_down(drive_t *drive); +bool drive_cycle(drive_t *drive, uint8_t cycles, bool advance); + +#endif \ No newline at end of file |