-
Notifications
You must be signed in to change notification settings - Fork 4
/
cart_easyflash.h
126 lines (103 loc) · 3.46 KB
/
cart_easyflash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#pragma once
class Cart;
class CartEasyFlash;
class EasyFlashChip
{
public:
enum EEasyFlashMode
{
Read = 0,
AutoSelect = 1,
ByteProgram = 2,
ChipErase = 3,
SectorErase = 4,
SectorEraseSuspend = 5,
ChipEraseSuspend = 6,
};
EasyFlashChip();
virtual ~EasyFlashChip();
EasyFlashChip(const EasyFlashChip&) = delete;
EasyFlashChip& operator=(const EasyFlashChip&) = delete;
EasyFlashChip(EasyFlashChip&&) = delete;
EasyFlashChip& operator=(EasyFlashChip&&) = delete;
static const int MAXEASYFLASHBANKS = 64;
HRESULT Init(CartEasyFlash *pCartEasyFlash, int chipNumber);
void CleanUp() noexcept;
void Detach() noexcept;
void Reset(ICLK sysclock);
bit8 ReadByte(bit16 address);
void WriteByte(bit16 address, bit8 data);
void CheckForPendingWrite(ICLK clock);
bit8 MonReadByte(bit16 address);
void MonWriteByte(bit16 address, bit8 data);
void PreventClockOverflow();
void SetCurrentClock(ICLK sysclock);
protected:
struct SsState
{
bit32 size;
bit32 m_iLastCommandWriteClock;
bit8 m_iCommandByte;
bit8 m_iCommandCycle;
bit8 m_iStatus;
bit8 m_iByteWritten;
bit8 m_mode;
};
virtual unsigned int GetStateBytes(void *pstate);
virtual HRESULT SetStateBytes(void *pstate, unsigned int size);
private:
CartEasyFlash *m_pCartEasyFlash;
ICLK m_iLastCommandWriteClock;
bit8 m_iCommandByte;
bit8 m_iCommandCycle;
bit8 m_iStatus;
bit8 m_iByteWritten;
EEasyFlashMode m_mode;
vector<bit8> m_vecPendingSectorErase;
CrtBankList *m_plstBank;
int m_chipNumber;
bit8 *m_pBlankData;
friend CartEasyFlash;
};
class CartEasyFlash : public CartCommon
{
public:
CartEasyFlash(const CrtHeader& crtHeader, IC6510* pCpu, IVic* pVic, bit8* pC64RamMemory);
virtual ~CartEasyFlash();
CartEasyFlash() = delete;
CartEasyFlash(const CartEasyFlash&) = delete;
CartEasyFlash& operator=(const CartEasyFlash&) = delete;
CartEasyFlash(CartEasyFlash&&) = delete;
CartEasyFlash& operator=(CartEasyFlash&&) = delete;
void Reset(ICLK sysclock, bool poweronreset) override;
bit8 ReadRegister(bit16 address, ICLK sysclock) override;
void WriteRegister(bit16 address, ICLK sysclock, bit8 data) override;
bit8 ReadROML(bit16 address) override;
bit8 ReadROMH(bit16 address) override;
bit8 ReadUltimaxROML(bit16 address) override;
bit8 ReadUltimaxROMH(bit16 address) override;
void WriteROML(bit16 address, bit8 data) override;
void WriteROMH(bit16 address, bit8 data) override;
void WriteUltimaxROML(bit16 address, bit8 data) override;
void WriteUltimaxROMH(bit16 address, bit8 data) override;
bit8 MonReadROML(bit16 address) override;
bit8 MonReadROMH(bit16 address) override;
bit8 MonReadUltimaxROML(bit16 address) override;
bit8 MonReadUltimaxROMH(bit16 address) override;
void MonWriteROML(bit16 address, bit8 data) override;
void MonWriteROMH(bit16 address, bit8 data) override;
void MonWriteUltimaxROML(bit16 address, bit8 data) override;
void MonWriteUltimaxROMH(bit16 address, bit8 data) override;
void PreventClockOverflow() override;
ICLK GetCurrentClock() override;
void SetCurrentClock(ICLK sysclock) override;
HRESULT InitCart(CartData& cartData) override;
unsigned int GetStateBytes(int version, void* pstate) override;
HRESULT SetStateBytes(int version, void* pstate, unsigned int size) override;
protected:
void UpdateIO() override;
private:
EasyFlashChip m_EasyFlashChipROML;
EasyFlashChip m_EasyFlashChipROMH;
friend EasyFlashChip;
};