aiie/apple/diskii.h
Jorj Bauer 99d0c8e72c Squashed commit of
* New BIOS interface
 * New linux framebuffer version
 * Unified linuxfb and SDL with Teensy
 * Abstracted VM RAM
 * Fixed disk image corruption due to bad cache handling
 * Variable CPU speed support
2018-02-07 10:28:40 -05:00

74 lines
1.6 KiB
C++

#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"
#include "slot.h"
#include "LRingBuffer.h"
#include "nibutil.h"
class DiskII : public Slot {
public:
DiskII(AppleMMU *mmu);
virtual ~DiskII();
virtual bool Serialize(int8_t fd);
virtual bool Deserialize(int8_t fd);
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);
void flushTrack(int8_t track, int8_t sel);
void fillDiskBuffer(); // called from main loop
private:
void setPhase(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();
void checkFlush(int8_t track);
void readDiskTrack(int8_t diskWeAreUsing, int8_t trackWeAreReading);
#ifndef TEENSYDUINO
void convertDskToNib(const char *outFN);
#endif
private:
volatile int8_t curHalfTrack[2];
volatile int8_t curPhase[2];
uint8_t readWriteLatch;
LRingBuffer *trackBuffer; // nibblized data
uint8_t rawTrackBuffer[4096]; // not nibblized data
bool writeMode;
bool writeProt;
AppleMMU *mmu;
int8_t disk[2];
volatile uint8_t indicatorIsOn[2];
uint8_t diskType[2];
volatile int8_t trackToFlush; // -1 when there's none
volatile int8_t selectedDisk;
};
#endif