56 lines
975 B
C
56 lines
975 B
C
|
#pragma once
|
||
|
|
||
|
#include <SFML/Graphics.hpp>
|
||
|
#include <memory/device.h>
|
||
|
#include <misc/types.h>
|
||
|
#include <lcd/palette.h>
|
||
|
#include <cpu/cpu.h>
|
||
|
|
||
|
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 tilemap[256];
|
||
|
|
||
|
// 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;
|
||
|
|
||
|
public:
|
||
|
LCD(Cpu& cpu);
|
||
|
|
||
|
virtual void write8(u16 addr, u8 data);
|
||
|
virtual u8 read8(u16 addr);
|
||
|
};
|