2017-02-19 23:55:54 +00:00
|
|
|
#ifndef __DISKII_H
|
|
|
|
#define __DISKII_H
|
|
|
|
|
|
|
|
#ifdef TEENSYDUINO
|
|
|
|
#include <Arduino.h>
|
|
|
|
#else
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "filemanager.h"
|
|
|
|
#include "applemmu.h"
|
2017-07-14 00:31:47 +00:00
|
|
|
#include "Slot.h"
|
2017-02-19 23:55:54 +00:00
|
|
|
|
|
|
|
#include "RingBuffer.h"
|
|
|
|
#include "nibutil.h"
|
|
|
|
|
|
|
|
class DiskII : public Slot {
|
|
|
|
public:
|
|
|
|
DiskII(AppleMMU *mmu);
|
|
|
|
virtual ~DiskII();
|
|
|
|
|
|
|
|
virtual void Reset(); // used by BIOS cold-boot
|
|
|
|
virtual uint8_t readSwitches(uint8_t s);
|
|
|
|
virtual void writeSwitches(uint8_t s, uint8_t v);
|
|
|
|
virtual void loadROM(uint8_t *toWhere);
|
|
|
|
|
|
|
|
void insertDisk(int8_t driveNum, const char *filename, bool drawIt = true);
|
|
|
|
void ejectDisk(int8_t driveNum);
|
|
|
|
|
|
|
|
const char *DiskName(int8_t num);
|
2017-02-27 11:20:18 +00:00
|
|
|
void flushTrack(int8_t track, int8_t sel);
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2017-02-27 00:59:51 +00:00
|
|
|
void fillDiskBuffer(); // called from main loop
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
private:
|
|
|
|
void step(uint8_t phase);
|
|
|
|
|
|
|
|
bool isWriteProtected();
|
|
|
|
void setWriteMode(bool enable);
|
|
|
|
void select(int8_t which); // 0 or 1 for drives 1 and 2, respectively
|
|
|
|
uint8_t readOrWriteByte();
|
|
|
|
|
2017-02-27 11:20:18 +00:00
|
|
|
void checkFlush(int8_t track);
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
#ifndef TEENSYDUINO
|
|
|
|
void convertDskToNib(const char *outFN);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
2017-12-29 03:49:20 +00:00
|
|
|
volatile uint8_t curTrack[2];
|
2017-02-27 11:20:18 +00:00
|
|
|
volatile bool trackDirty; // does this track need flushing to disk?
|
2017-02-27 00:59:51 +00:00
|
|
|
uint8_t readWriteLatch;
|
2017-02-19 23:55:54 +00:00
|
|
|
RingBuffer *trackBuffer; // nibblized data
|
|
|
|
uint8_t *rawTrackBuffer; // not nibblized data
|
|
|
|
|
|
|
|
bool writeMode;
|
|
|
|
bool writeProt;
|
|
|
|
AppleMMU *mmu;
|
|
|
|
|
2017-12-29 03:49:20 +00:00
|
|
|
int trackPos[2];
|
|
|
|
int prevTrack[2];
|
|
|
|
int stepperPhases[2];
|
|
|
|
int curPhase[2];
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
int8_t disk[2];
|
2017-02-27 00:59:51 +00:00
|
|
|
volatile uint8_t indicatorIsOn[2];
|
2017-02-19 23:55:54 +00:00
|
|
|
uint8_t diskType[2];
|
|
|
|
|
2017-02-27 00:59:51 +00:00
|
|
|
volatile int8_t trackToRead; // -1 when we're idle; not -1 when we need to read a track.
|
2017-02-27 11:20:18 +00:00
|
|
|
volatile int8_t selectedDisk;
|
|
|
|
volatile int8_t trackToFlush; // -1 when there's none
|
|
|
|
volatile int8_t diskToFlush; // which selected disk are we writing to?
|
2017-02-19 23:55:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|