TK2048/src/disk2.h

46 lines
1.9 KiB
C

#ifndef _DISK2_HEADER_
#define _DISK2_HEADER_
#include <stdint.h>
#define DII_MAX_TRACK 96
#define DECODING_MAPPING_TABLE_DEFAULT_ADDRESS 0x0356
#define ENCODING_MAPPING_TABLE_DEFAULT_ADDRESS 0x9D56
#define WRITE_SIXES_BUFFER_DEFAULT_ADDRESS 0x9C00
#define WRITE_TWOS_BUFFER_DEFAULT_ADDRESS 0x9D00
void dii_generate_6bit_decoding_mapping_table(uint8_t* dest);
void dii_generate_6bit_encoding_mapping_table(uint8_t* dest);
void dii_encode_gcr62_data(uint8_t *src, uint8_t* dest6, uint8_t* dest2);
void dii_power_on(uint8_t io_offset, uint8_t drive_no);
void dii_power_off(uint8_t io_offset);
void dii_head_reposition(uint8_t io_offset, uint8_t cur_track, uint8_t dest_track);
/**
* Patch the dii_write_sector routine to change the memory addresses used.
* buf2 and buf6 must start at the beginning of a memory page, nibtab must fit completely inside a page.
*/
void dii_patch_write(uint8_t* buf6, uint8_t* buf2, uint8_t *nibtab);
/**
* This routine requires the decoding mapping table to be initialized beforehand at
* DECODING_MAPPING_TABLE_DEFAULT_ADDRESS, and uses space in page 3 as a buffer
*
* If the return value is 0, the read failed
*/
uint8_t dii_read_sector(uint8_t io_offset, uint8_t track, uint8_t sector, uint8_t *buffer, uint8_t aonly);
/**
* Writes gcr 6+2 encoded data to the chosen sector. The track number is used to verify that we're on the correct
* track before writing. This routine does not move the head.
* The data must be pre-encoded.
*
* By default, it writes 86 bytes from the "twos" buffer located at 0x9C00, 256 bytes of "sixes" from the buffer
* at 0x9D00 and using a 63 entries translation table preloaded at 0x9C56.
* If these addresses need to be changes, use the dii_patch_write routine.
*
* If the return value is > 0, the write failed
*/
uint8_t dii_write_sector(uint8_t io_offset, uint8_t track, uint8_t sector);
#endif /* _DISK2_HEADER_ */