aiie/apple/nibutil.h

45 lines
1.0 KiB
C
Raw Normal View History

#ifdef TEENSYDUINO
#include <Arduino.h>
#else
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#endif
2017-07-14 00:31:47 +00:00
#include "RingBuffer.h"
#define NIBTRACKSIZE 0x1A00
// Minimum viable nibblized sector size. With GAP bytes, could be much longer.
#define MINNIBSECTORSIZE (343 + 13 + 3)
#define nib1(a) (((a & 0xAA) >> 1) | 0xAA)
#define nib2(b) (((b & 0x55) ) | 0xAA)
#define denib(a, b) ((((a) & ~0xAA) << 1) | ((b) & ~0xAA))
#define GAP 0xFF
enum {
dosDisk = 0,
prodosDisk = 1,
nibDisk = 2
};
enum nibErr {
errorNone = 0,
errorShortTrack = 1,
errorMissingSectors = 2
};
void nibblizeTrack(RingBuffer *trackBuffer, uint8_t *rawTrackBuffer,
uint8_t diskType, int8_t track);
nibErr denibblizeTrack(RingBuffer *trackBuffer, uint8_t *rawTrackBuffer,
uint8_t diskType, int8_t track);
bool decodeData(RingBuffer *trackBuffer, uint16_t startAt, uint8_t *output);
void encodeData(RingBuffer *trackBuffer, uint8_t *data);