WindEmu/WindCore/emu.h

73 lines
1.9 KiB
C
Raw Normal View History

2019-12-19 00:27:23 +00:00
#pragma once
#include "arm710a.h"
2019-12-19 00:27:23 +00:00
#include "wind_hw.h"
#include "etna.h"
2019-12-19 17:40:49 +00:00
#include <unordered_set>
2019-12-19 00:27:23 +00:00
class Emu : public ARM710a {
2019-12-21 11:09:58 +00:00
public:
2019-12-19 00:27:23 +00:00
uint8_t ROM[0x1000000];
uint8_t MemoryBlockC0[0x800000];
uint8_t MemoryBlockC1[0x800000];
uint8_t MemoryBlockD0[0x800000];
uint8_t MemoryBlockD1[0x800000];
enum { MemoryBlockMask = 0x7FFFFF };
2019-12-19 00:27:23 +00:00
2019-12-21 11:09:58 +00:00
private:
2019-12-19 00:27:23 +00:00
uint16_t pendingInterrupts = 0;
uint16_t interruptMask = 0;
uint32_t portValues = 0;
uint32_t portDirections = 0;
uint32_t pwrsr = 0x00002000; // cold start flag
uint32_t lcdControl = 0;
uint32_t lcdAddress = 0;
uint32_t kScan = 0;
uint32_t rtc = 0;
int64_t passedCycles = 0;
2019-12-19 00:27:23 +00:00
int64_t nextTickAt = 0;
Timer tc1, tc2;
UART uart1, uart2;
Etna etna;
bool halted = false, asleep = false;
2019-12-19 00:27:23 +00:00
std::unordered_set<uint32_t> _breakpoints;
2019-12-19 00:27:23 +00:00
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:
bool isPhysAddressValid(uint32_t addr) const;
MaybeU32 readPhysical(uint32_t physAddr, ValueSize valueSize) override;
bool writePhysical(uint32_t value, uint32_t physAddr, ValueSize valueSize) override;
2019-12-19 00:27:23 +00:00
const uint8_t *getLCDBuffer() const;
private:
bool configured = false;
void configure();
void printRegs();
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);
uint8_t readKeyboard();
public:
bool keyboardKeys[8*7] = {0};
public:
Emu();
void loadROM(const char *path);
void dumpRAM(const char *path);
void executeUntil(int64_t cycles);
std::unordered_set<uint32_t> &breakpoints() { return _breakpoints; }
uint64_t currentCycles() const { return passedCycles; }
2019-12-19 00:27:23 +00:00
};