2017-02-19 23:55:54 +00:00
|
|
|
#ifndef __APPLEMMU_H
|
|
|
|
#define __APPLEMMU_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "appledisplay.h"
|
2018-02-07 15:20:26 +00:00
|
|
|
#include "slot.h"
|
2017-02-19 23:55:54 +00:00
|
|
|
#include "mmu.h"
|
2018-02-17 14:01:08 +00:00
|
|
|
#include "noslotclock.h"
|
2017-02-19 23:55:54 +00:00
|
|
|
|
|
|
|
// when we read a nondeterministic result, we return FLOATING. Maybe
|
|
|
|
// some day we can come back here and figure out how to return what
|
|
|
|
// the Apple would have.
|
|
|
|
|
|
|
|
#define FLOATING 0
|
|
|
|
|
|
|
|
// Switches activated by various memory locations
|
|
|
|
enum {
|
|
|
|
S_TEXT = 0x0001,
|
|
|
|
S_MIXED = 0x0002,
|
|
|
|
S_HIRES = 0x0004,
|
|
|
|
S_PAGE2 = 0x0008,
|
|
|
|
S_80COL = 0x0010,
|
|
|
|
S_ALTCH = 0x0020,
|
|
|
|
S_80STORE = 0x0040,
|
|
|
|
S_DHIRES = 0x0080
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef bool (*callback_t)(void *);
|
|
|
|
|
|
|
|
class AppleVM;
|
|
|
|
|
|
|
|
class AppleMMU : public MMU {
|
|
|
|
friend class AppleVM;
|
|
|
|
|
|
|
|
public:
|
|
|
|
AppleMMU(AppleDisplay *display);
|
|
|
|
virtual ~AppleMMU();
|
|
|
|
|
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 uint8_t read(uint16_t address);
|
|
|
|
virtual uint8_t readDirect(uint16_t address, uint8_t fromPage);
|
|
|
|
virtual void write(uint16_t address, uint8_t v);
|
|
|
|
|
|
|
|
virtual void Reset();
|
|
|
|
|
|
|
|
void keyboardInput(uint8_t v);
|
|
|
|
void setKeyDown(bool isTrue);
|
|
|
|
|
|
|
|
void triggerPaddleTimer(uint8_t paddle);
|
|
|
|
|
|
|
|
void resetRAM(); // used by BIOS on cold boot
|
|
|
|
|
|
|
|
void setSlot(int8_t slotnum, Slot *peripheral);
|
|
|
|
|
2018-01-10 09:13:04 +00:00
|
|
|
void setAppleKey(int8_t which, bool isDown);
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
protected:
|
2018-02-17 14:01:08 +00:00
|
|
|
bool handleNoSlotClock(uint16_t address, uint8_t *rv);
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
void resetDisplay();
|
|
|
|
uint8_t readSwitches(uint16_t address);
|
|
|
|
void writeSwitches(uint16_t address, uint8_t v);
|
|
|
|
void handleMemorySwitches(uint16_t address, uint16_t lastSwitch);
|
|
|
|
|
|
|
|
void updateMemoryPages();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AppleDisplay *display;
|
|
|
|
uint16_t switches;
|
2017-02-27 00:59:51 +00:00
|
|
|
public: // 'public' for debugging
|
2017-02-19 23:55:54 +00:00
|
|
|
bool auxRamRead;
|
|
|
|
bool auxRamWrite;
|
2017-02-28 18:31:30 +00:00
|
|
|
bool bank2;
|
2017-02-19 23:55:54 +00:00
|
|
|
bool readbsr;
|
|
|
|
bool writebsr;
|
|
|
|
bool altzp;
|
|
|
|
bool intcxrom;
|
|
|
|
bool slot3rom;
|
2017-03-03 14:00:41 +00:00
|
|
|
int8_t slotLatch;
|
2017-02-19 23:55:54 +00:00
|
|
|
|
2017-02-28 18:31:30 +00:00
|
|
|
bool preWriteFlag; // see UTA2E p. 5-23
|
|
|
|
|
2017-02-19 23:55:54 +00:00
|
|
|
Slot *slots[8]; // slots 0-7
|
|
|
|
|
2018-01-10 09:13:04 +00:00
|
|
|
uint16_t readPages[0x100];
|
|
|
|
uint16_t writePages[0x100];
|
2017-02-19 23:55:54 +00:00
|
|
|
|
|
|
|
bool anyKeyDown;
|
2018-02-17 14:01:08 +00:00
|
|
|
|
|
|
|
NoSlotClock *clock;
|
2017-02-19 23:55:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|