| 1 | #ifndef VDPDATASTORE_H |
| 2 | #define VDPDATASTORE_H |
| 3 | |
| 4 | #include "SimpleHexRequest.h" |
| 5 | #include <QObject> |
| 6 | #include <cstdint> |
| 7 | #include <optional> |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | class VDPDataStore : public QObject, public SimpleHexRequestUser |
| 12 | { |
| 13 | Q_OBJECT |
| 14 | public: |
| 15 | static VDPDataStore& instance(); |
| 16 | |
| 17 | const uint8_t* getVramPointer() const; |
| 18 | const uint8_t* getDefaultPalettePointer() const; |
| 19 | const uint8_t* getPalettePointer() const; |
| 20 | const uint8_t* getRegsPointer() const; |
| 21 | const uint8_t* getStatusRegsPointer() const; |
| 22 | const uint8_t* getVdpVramPointer() const; |
| 23 | |
| 24 | size_t getVRAMSize() const; |
| 25 | |
| 26 | bool getRegisterLatchAvailable() const { return registerLatchAvailable; } |
| 27 | bool getPaletteLatchAvailable() const { return paletteLatchAvailable; } |
| 28 | bool getDataLatchAvailable() const { return dataLatchAvailable; } |
| 29 | bool getVramAccessStatusAvailable() const { return vramAccessStatusAvailable; } |
| 30 | |
| 31 | void refresh(); |
| 32 | |
| 33 | signals: |
| 34 | void dataRefreshed(); // The refresh got the new data |
| 35 | |
| 36 | /** This might become handy later on, for now we only need the dataRefreshed |
| 37 | * |
| 38 | void dataChanged(); //any of the contained data has changed |
| 39 | void vramChanged(); //only the vram changed |
| 40 | void paletteChanged(); //only the palette changed |
| 41 | void regsChanged(); //only the regs changed |
| 42 | void statusRegsChanged(); //only the regs changed |
| 43 | */ |
| 44 | |
| 45 | private: |
| 46 | VDPDataStore(); |
| 47 | |
| 48 | void DataHexRequestReceived() override; |
| 49 | |
| 50 | void refresh1(); |
| 51 | void refresh2(); |
| 52 | void refresh3(); |
| 53 | |
| 54 | private: |
| 55 | std::vector<uint8_t> vram; |
| 56 | size_t vramSize; |
| 57 | |
| 58 | std::optional<std::string> debuggableNameVRAM; // VRAM debuggable name |
| 59 | |
| 60 | bool registerLatchAvailable = false; |
| 61 | bool paletteLatchAvailable = false; |
| 62 | bool dataLatchAvailable = false; |
| 63 | bool vramAccessStatusAvailable = false; |
| 64 | |
| 65 | friend class VDPDataStoreVersionCheck; |
| 66 | friend class VDPDataStoreDebuggableChecks; |
| 67 | friend class VDPDataStoreVRAMSizeCheck; |
| 68 | }; |
| 69 | |
| 70 | #endif // VDPDATASTORE_H |