#pragma once #include #include #include #include #include class LCD; enum LCDMode : u8 { ModeHBlank = 0b000000000, ModeVBlank = 0b000000001, ModeOAMSearch = 0b000000010, ModeTransferring = 0b000000011, }; enum RegStat : u8 { LycEqual = 0b000000100, IntSourceHBlank = 0b000001000, IntSourceVBlank = 0b000010000, IntSourceOAM = 0b000100000, IntSourceLYC = 0b001000000, }; class LCD : public Mem_device { private: // Graphics sf::RenderTexture screenbuffer; sf::Image tiles[384]; // Emulated device u8 regLY; u8 regLYC; bool intHBlank; bool intVBlank; bool intOAM; bool intLYC; LCDMode currentMode; Palette bgp; Palette obp[2]; u8 vram_raw[0x2000]; // misc Cpu& cpu; bool enabled; bool vram_dirty; void vram_write(u16 addr, u8 data); void generate_tile(int idx); public: LCD(Cpu& cpu); virtual void write8(u16 addr, u8 data); virtual u8 read8(u16 addr); void render(sf::RenderTarget& target); };