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
|
|
|
|
|
2019-02-20 12:50:51 +00:00
|
|
|
#include "woz-serializer.h"
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
#include "filemanager.h"
|
|
|
|
#include "applemmu.h"
|
2018-02-07 15:20:26 +00:00
|
|
|
#include "slot.h"
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2017-12-30 20:20:34 +00:00
|
|
|
#include "LRingBuffer.h"
|
2017-02-19 23:55:54 +00:00
|
|
|
#include "nibutil.h"
|
|
|
|
|
|
|
|
class DiskII : public Slot {
|
|
|
|
public:
|
|
|
|
DiskII(AppleMMU *mmu);
|
|
|
|
virtual ~DiskII();
|
|
|
|
|
2017-12-30 20:20:34 +00:00
|
|
|
virtual bool Serialize(int8_t fd);
|
|
|
|
virtual bool Deserialize(int8_t fd);
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
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);
|
|
|
|
|
2019-02-22 06:01:48 +00:00
|
|
|
void maintenance(uint32_t cycles);
|
2017-02-27 00:59:51 +00:00
|
|
|
|
2020-07-04 12:03:13 +00:00
|
|
|
uint8_t selectedDrive();
|
|
|
|
uint8_t headPosition(uint8_t drive);
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
private:
|
2017-12-30 03:16:09 +00:00
|
|
|
void setPhase(uint8_t phase);
|
2017-02-19 23:55:54 +00:00
|
|
|
|
|
|
|
bool isWriteProtected();
|
|
|
|
void setWriteMode(bool enable);
|
|
|
|
void select(int8_t which); // 0 or 1 for drives 1 and 2, respectively
|
|
|
|
uint8_t readOrWriteByte();
|
|
|
|
|
2020-06-27 22:00:59 +00:00
|
|
|
void driveOn();
|
|
|
|
void driveOff();
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
#ifndef TEENSYDUINO
|
|
|
|
void convertDskToNib(const char *outFN);
|
|
|
|
#endif
|
2020-07-01 02:44:50 +00:00
|
|
|
|
|
|
|
int64_t calcExpectedBits();
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2020-06-27 22:00:59 +00:00
|
|
|
public:
|
|
|
|
// debugging
|
|
|
|
WozSerializer *disk[2];
|
2020-07-04 12:03:13 +00:00
|
|
|
private:
|
2017-12-30 03:16:09 +00:00
|
|
|
volatile int8_t curHalfTrack[2];
|
2019-02-20 12:50:51 +00:00
|
|
|
volatile uint8_t curWozTrack[2];
|
2017-12-30 03:16:09 +00:00
|
|
|
volatile int8_t curPhase[2];
|
2020-06-28 02:10:24 +00:00
|
|
|
volatile uint8_t readWriteLatch;
|
|
|
|
volatile uint8_t sequencer, dataRegister; // diskII logic state sequencer vars
|
|
|
|
volatile uint64_t driveSpinupCycles[2];
|
|
|
|
volatile uint64_t deliveredDiskBits[2];
|
2017-02-19 23:55:54 +00:00
|
|
|
|
|
|
|
bool writeMode;
|
|
|
|
bool writeProt;
|
|
|
|
AppleMMU *mmu;
|
|
|
|
|
2019-02-22 06:01:48 +00:00
|
|
|
volatile uint32_t diskIsSpinningUntil[2];
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2017-02-27 11:20:18 +00:00
|
|
|
volatile int8_t selectedDisk;
|
2020-06-28 12:28:49 +00:00
|
|
|
|
|
|
|
volatile uint32_t flushAt[2];
|
2017-02-19 23:55:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|