#include "../Video.h" #include #include "Events.h" #include "../../util/Asm.h" #define VGA_DAC_ADDR_RD 0x3c7 #define VGA_DAC_ADDR_WR 0x3c8 #define VGA_DAC_DATA 0x3c9 #define VGA_EXT_INPUT_STATUS 0x3da #define VGA_EXT_INPUT_STATUS_VRETRACE 8 Video video; Video::Video() { // TODO } Video::~Video() { Exit(); } void Video::Enter() { } void Video::Exit() { } void Video::SetMode(uint8_t mode) { switch (mode) { default: case 0x13: _fb = 0; // TODO get from SDL } } uint8_t Video::GetMode() { // Fixed return 0x13; } void Video::SetPaletteEntry(uint8_t index, PaletteEntry entry) { SetPaletteEntry(index, &entry); } Video::PaletteEntry Video::GetPaletteEntry(uint8_t index) { PaletteEntry entry; GetPaletteEntry(index, &entry); return entry; } void Video::SetPaletteEntry(uint8_t index, PaletteEntry *entry) { // TODO } void Video::GetPaletteEntry(uint8_t index, PaletteEntry *entry) { // TODO } void *Video::GetFB() { return _renderBuffer; } void Video::WaitForVerticalSync() { // TODO } void Video::UpdateRect(const Rect &rect) { // Merge rect if it overlaps with an existing rect for (auto i = 0; i < _updateRectIndex; i++) { auto &r = _updatedRects[i]; if (r.overlaps(rect)) { r += rect; return; } } // Add a new rect to the list _updatedRects[_updateRectIndex++] = rect; } void Video::Flip() { for (auto i = 0; i <= MAX_UPDATE_RECT_INDEX; i++) { auto &rect = _updatedRects[i]; for (auto y = rect.y1; y <= rect.y2; y++) { auto yOffset = y * SCREEN_WIDTH; for (auto x = rect.x1; x <= rect.x2; x++) { // TODO } } } _updateRectIndex = 0; events.poll(); }