2019-12-24 23:34:02 +00:00
|
|
|
#pragma once
|
2019-12-25 00:29:03 +00:00
|
|
|
#include "emubase.h"
|
2019-12-24 23:34:02 +00:00
|
|
|
#include "clps7111_defs.h"
|
|
|
|
#include "clps7600.h"
|
|
|
|
#include "hardware.h"
|
|
|
|
#include "etna.h"
|
|
|
|
|
2019-12-25 00:29:03 +00:00
|
|
|
namespace CLPS7111 {
|
|
|
|
class Emulator : public EmuBase {
|
2019-12-24 23:34:02 +00:00
|
|
|
public:
|
|
|
|
uint8_t ROM[0x800000];
|
|
|
|
uint8_t ROM2[0x40000];
|
|
|
|
uint8_t MemoryBlockC0[0x400000];
|
|
|
|
enum { MemoryBlockMask = 0x3FFFFF };
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint16_t pendingInterrupts = 0;
|
|
|
|
uint16_t interruptMask = 0;
|
|
|
|
uint32_t portValues = 0;
|
|
|
|
uint32_t portDirections = 0;
|
|
|
|
uint32_t sysFlg1 = 0x20008000; // constant CL-PS7111 flag and cold start flag
|
|
|
|
uint32_t lcdControl = 0;
|
|
|
|
uint32_t lcdAddress = 0xC0000000;
|
|
|
|
uint32_t rtc = 0;
|
|
|
|
uint32_t rtcDiv = 0;
|
|
|
|
uint64_t lcdPalette = 0;
|
2019-12-25 14:46:08 +00:00
|
|
|
uint16_t lastSyncioRequest = 0;
|
2019-12-24 23:34:02 +00:00
|
|
|
|
2019-12-25 01:53:54 +00:00
|
|
|
uint32_t kScan = 0;
|
|
|
|
uint8_t keyboardColumns[7] = {0,0,0,0,0,0,0};
|
|
|
|
uint8_t keyboardExtra = 0;
|
2019-12-25 14:46:08 +00:00
|
|
|
int32_t touchX = 0, touchY = 0;
|
2019-12-25 01:53:54 +00:00
|
|
|
|
2019-12-24 23:34:02 +00:00
|
|
|
Timer tc1, tc2;
|
|
|
|
CLPS7600 pcCardController;
|
|
|
|
bool halted = false, asleep = false;
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t getRTC();
|
|
|
|
|
|
|
|
uint32_t readReg8(uint32_t reg);
|
|
|
|
uint32_t readReg32(uint32_t reg);
|
|
|
|
void writeReg8(uint32_t reg, uint8_t value);
|
|
|
|
void writeReg32(uint32_t reg, uint32_t value);
|
|
|
|
|
|
|
|
public:
|
|
|
|
MaybeU32 readPhysical(uint32_t physAddr, ValueSize valueSize) override;
|
|
|
|
bool writePhysical(uint32_t value, uint32_t physAddr, ValueSize valueSize) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool configured = false;
|
|
|
|
void configure();
|
|
|
|
|
|
|
|
const char *identifyObjectCon(uint32_t ptr);
|
|
|
|
void fetchStr(uint32_t str, char *buf);
|
|
|
|
void fetchName(uint32_t obj, char *buf);
|
|
|
|
void fetchProcessFilename(uint32_t obj, char *buf);
|
|
|
|
void debugPC(uint32_t pc);
|
|
|
|
void diffPorts(uint32_t oldval, uint32_t newval);
|
2019-12-25 01:53:54 +00:00
|
|
|
uint32_t readKeyboard() const;
|
2019-12-24 23:34:02 +00:00
|
|
|
|
|
|
|
public:
|
2019-12-25 00:29:03 +00:00
|
|
|
Emulator();
|
2019-12-25 23:40:27 +00:00
|
|
|
uint8_t *getROMBuffer() override;
|
|
|
|
size_t getROMSize() override;
|
2019-12-25 00:29:03 +00:00
|
|
|
void loadROM(uint8_t *buffer, size_t size) override;
|
|
|
|
void executeUntil(int64_t cycles) override;
|
|
|
|
int32_t getClockSpeed() const override { return CLOCK_SPEED; }
|
2019-12-25 14:46:08 +00:00
|
|
|
const char *getDeviceName() const override;
|
|
|
|
int getDigitiserWidth() const override;
|
|
|
|
int getDigitiserHeight() const override;
|
|
|
|
int getLCDOffsetX() const override;
|
|
|
|
int getLCDOffsetY() const override;
|
2019-12-25 00:29:03 +00:00
|
|
|
int getLCDWidth() const override;
|
|
|
|
int getLCDHeight() const override;
|
2019-12-25 23:40:27 +00:00
|
|
|
void readLCDIntoBuffer(uint8_t **lines, bool is32BitOutput) const override;
|
2019-12-25 01:53:54 +00:00
|
|
|
void setKeyboardKey(EpocKey key, bool value) override;
|
2019-12-25 14:46:08 +00:00
|
|
|
void updateTouchInput(int32_t x, int32_t y, bool down) override;
|
2019-12-24 23:34:02 +00:00
|
|
|
};
|
2019-12-25 00:29:03 +00:00
|
|
|
}
|