| 1 | #ifndef VRAMBITMAPPEDVIEW |
| 2 | #define VRAMBITMAPPEDVIEW |
| 3 | |
| 4 | #include <QWidget> |
| 5 | #include <QImage> |
| 6 | #include <QPixmap> |
| 7 | #include <QMouseEvent> |
| 8 | #include <QColor> |
| 9 | #include <cstdint> |
| 10 | |
| 11 | class VramBitMappedView : public QWidget |
| 12 | { |
| 13 | Q_OBJECT |
| 14 | public: |
| 15 | VramBitMappedView(QWidget* parent = nullptr); |
| 16 | |
| 17 | void setZoom(float zoom); |
| 18 | |
| 19 | void setScreenMode(int mode); |
| 20 | void setLines(int nrLines); |
| 21 | void setVramSource(const uint8_t* adr); |
| 22 | void setVramAddress(int adr); |
| 23 | void setPaletteSource(const uint8_t* adr); |
| 24 | void setBorderColor(int value); |
| 25 | |
| 26 | void mousePressEvent(QMouseEvent* e) override; |
| 27 | void mouseMoveEvent (QMouseEvent* e) override; |
| 28 | |
| 29 | void refresh(); |
| 30 | |
| 31 | signals: |
| 32 | void imageChanged(); |
| 33 | void imageHovered(int xCoordMsx, int yCoordMsx, int color, |
| 34 | unsigned addr, int byte); |
| 35 | void imageClicked(int xCoordMsx, int yCoordMsx, int color, |
| 36 | unsigned addr, int byte); |
| 37 | |
| 38 | private: |
| 39 | void paintEvent(QPaintEvent* e) override; |
| 40 | |
| 41 | void decode(); |
| 42 | void decodePallet(); |
| 43 | void decodeSCR5(); |
| 44 | void decodeSCR6(); |
| 45 | void decodeSCR7(); |
| 46 | void decodeSCR8(); |
| 47 | void decodeSCR10(); |
| 48 | void decodeSCR12(); |
| 49 | void setPixel2x2(int x, int y, QRgb c); |
| 50 | void setPixel1x2(int x, int y, QRgb c); |
| 51 | QRgb getColor(int c); |
| 52 | |
| 53 | private: |
| 54 | QRgb msxPalette[16]; |
| 55 | QImage image; |
| 56 | QPixmap pixImage; |
| 57 | const uint8_t* palette = nullptr; |
| 58 | const uint8_t* vramBase = nullptr; |
| 59 | float zoomFactor; |
| 60 | unsigned vramAddress = 0; |
| 61 | int lines = 212; |
| 62 | int screenMode = 5; |
| 63 | int borderColor = 0; |
| 64 | }; |
| 65 | |
| 66 | #endif // VRAMBITMAPPEDVIEW |