VRAM/OAM read/write implemented
authorJorge Gorbe Moya <jgorbe@dsic.upv.es>
Mon, 16 Jun 2008 12:26:37 +0000 (14:26 +0200)
committerJorge Gorbe Moya <jgorbe@dsic.upv.es>
Mon, 16 Jun 2008 12:26:37 +0000 (14:26 +0200)
GBVideo.cc
GBVideo.h
gbcore.cc

index 8c2c4be2ed9519eb6b86b1354d714b143ae6c317..96aa2b7862f07af22ad632725974d2b75d0111fa 100644 (file)
@@ -2,18 +2,22 @@
 
 u8   GBVideo::read_VRAM (int addr) const
 {
+       return VRAM[addr-VRAM_BASE];
 }
 
 u8   GBVideo::read_OAM  (int addr) const
 {
+       return OAM[addr-OAM_BASE];
 }
 
 void GBVideo::write_VRAM(int addr, u8 value)
 {
+       VRAM[addr-VRAM_BASE] = value;
 }
 
 void GBVideo::write_OAM (int addr, u8 value)
 {
+       OAM[addr-OAM_BASE] = value;
 }
 
 
index 4b32b856c828fb873b81c4db1e474758e681cc7a..660ef94d148afe34281813dc6bcbbf3702100217 100644 (file)
--- a/GBVideo.h
+++ b/GBVideo.h
@@ -5,9 +5,13 @@ class GBVideo
        GameBoy *core;
 
        u8 VRAM[8192];
-       u8 OAM[];
+       u8 OAM[160];
 
        public:
+       static const u16 VRAM_BASE = 0x8000;
+       static const u16 OAM_BASE  = 0xFE00;
+
+
        GBVideo(GameBoy *core):core(core) {}
 
        u8   read_VRAM (int addr) const;
index 392afcc9f97426ce5ac3dca1350650774843109f..0168f867885c6e0ab2d2f20867093a33a857d557 100644 (file)
--- a/gbcore.cc
+++ b/gbcore.cc
@@ -11,7 +11,7 @@
 GameBoy::GameBoy(std::string rom_name, GameBoyType type):
        gameboy_type(type),
        memory(this),
-       video(),
+       video(this),
        rom(0),
        regs(),
        IME(1),