2019-02-20 12:50:51 +00:00
|
|
|
#ifndef __NIBUTIL_H
|
|
|
|
#define __NIBUTIL_H
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
#include <unistd.h>
|
2020-07-06 11:04:22 +00:00
|
|
|
#ifndef TEENSYDUINO
|
2017-02-19 23:55:54 +00:00
|
|
|
#include <fcntl.h>
|
2020-07-06 11:04:22 +00:00
|
|
|
#endif
|
2017-02-19 23:55:54 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2019-02-20 12:50:51 +00:00
|
|
|
#include <stdint.h>
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2017-02-19 23:55:54 +00:00
|
|
|
|
|
|
|
#define NIBTRACKSIZE 0x1A00
|
2019-02-20 12:50:51 +00:00
|
|
|
#define NIBSECTORSIZE 416
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
typedef struct _nibSector {
|
|
|
|
uint8_t gap1[48];
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
uint8_t sectorProlog[3];
|
|
|
|
uint8_t volume44[2];
|
|
|
|
uint8_t track44[2];
|
|
|
|
uint8_t sector44[2];
|
|
|
|
uint8_t checksum44[2];
|
|
|
|
uint8_t sectorEpilog[3];
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
uint8_t gap2[5];
|
|
|
|
|
|
|
|
uint8_t dataProlog[3];
|
|
|
|
uint8_t data62[342];
|
|
|
|
uint8_t checksum;
|
|
|
|
uint8_t dataEpilog[3];
|
|
|
|
} nibSector;
|
2017-02-19 23:55:54 +00:00
|
|
|
|
|
|
|
enum nibErr {
|
|
|
|
errorNone = 0,
|
2019-02-20 12:50:51 +00:00
|
|
|
errorMissingSectors = 1,
|
|
|
|
errorBadData = 2
|
2017-02-19 23:55:54 +00:00
|
|
|
};
|
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
uint32_t nibblizeTrack(uint8_t outputBuffer[NIBTRACKSIZE], const uint8_t rawTrackBuffer[256*16],
|
|
|
|
uint8_t diskType, int8_t track);
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
nibErr denibblizeTrack(const uint8_t input[NIBTRACKSIZE], uint8_t rawTrackBuffer[256*16],
|
2017-02-19 23:55:54 +00:00
|
|
|
uint8_t diskType, int8_t track);
|
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
uint8_t de44(uint8_t nibs[2]);
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
#endif
|