2017-12-29 19:08:49 +00:00
|
|
|
#ifndef __HD32_H
|
|
|
|
#define __HD32_H
|
|
|
|
|
|
|
|
#ifdef TEENSYDUINO
|
|
|
|
#include <Arduino.h>
|
|
|
|
#else
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "filemanager.h"
|
|
|
|
#include "applemmu.h"
|
2018-02-07 15:20:26 +00:00
|
|
|
#include "slot.h"
|
2017-12-29 19:08:49 +00:00
|
|
|
|
2017-12-30 20:20:34 +00:00
|
|
|
#include "LRingBuffer.h"
|
2017-12-29 19:08:49 +00:00
|
|
|
|
|
|
|
class HD32 : public Slot {
|
|
|
|
public:
|
|
|
|
HD32(AppleMMU *mmu);
|
|
|
|
virtual ~HD32();
|
|
|
|
|
2017-12-30 20:20:34 +00:00
|
|
|
virtual bool Serialize(int8_t fd);
|
|
|
|
virtual bool Deserialize(int8_t fd);
|
|
|
|
|
2017-12-29 19:08:49 +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 setEnabled(uint8_t e);
|
|
|
|
|
|
|
|
void insertDisk(int8_t driveNum, const char *filename);
|
|
|
|
void ejectDisk(int8_t driveNum);
|
|
|
|
|
|
|
|
const char *diskName(int8_t num);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint8_t readNextByteFromSelectedDrive();
|
2020-07-08 01:21:11 +00:00
|
|
|
bool readBlockFromSelectedDrive();
|
2017-12-29 19:08:49 +00:00
|
|
|
bool writeBlockToSelectedDrive();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AppleMMU *mmu;
|
|
|
|
|
|
|
|
uint8_t driveSelected; // 0 or 1
|
|
|
|
uint8_t unitSelected; // b7 = drive#; b6..4 = slot#; b3..0 = ?
|
|
|
|
uint8_t command; // CMD_*; FIXME, make enum
|
|
|
|
|
|
|
|
uint8_t enabled;
|
|
|
|
|
|
|
|
uint8_t errorState[2]; // status of last operation
|
2017-12-30 20:20:34 +00:00
|
|
|
uint16_t memBlock[2]; // pointer to memory (for writing blocks to disk)
|
2017-12-29 19:08:49 +00:00
|
|
|
uint16_t diskBlock[2]; // currently selected block
|
|
|
|
|
|
|
|
int8_t fd[2];
|
|
|
|
uint32_t cursor[2]; // seek position on the given file handle
|
2020-07-08 01:21:11 +00:00
|
|
|
|
|
|
|
int32_t cachedBlockNum;
|
|
|
|
uint8_t cachedBlock[512];
|
2017-12-29 19:08:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|