From: slack Date: Sun, 19 Aug 2007 02:44:48 +0000 (+0000) Subject: Cambio logger.h -> Logger.h X-Git-Tag: v0.1~72 X-Git-Url: http://slack.codemaniacs.com/git/?a=commitdiff_plain;h=7dae2e454d7bc01329148a2f69bc6a5a8ce950d8;p=wenboi.git Cambio logger.h -> Logger.h git-svn-id: http://slack.codemaniacs.com/wenboi@7 0666ae3d-8926-0410-aeff-ae84559ff337 --- diff --git a/GBMemory.cc b/GBMemory.cc index c9d1345..a5786b3 100644 --- a/GBMemory.cc +++ b/GBMemory.cc @@ -1,6 +1,7 @@ #include "GBMemory.h" #include "MBC.h" #include "gbcore.h" +#include "Logger.h" u8& GBMemory::operator[](unsigned int addr) { diff --git a/Logger.cc b/Logger.cc new file mode 100644 index 0000000..93bcd3f --- /dev/null +++ b/Logger.cc @@ -0,0 +1,4 @@ +#include "Logger.h" +#include + +Logger Logger::instance(std::cerr); diff --git a/logger.h b/Logger.h similarity index 100% rename from logger.h rename to Logger.h diff --git a/MBC.cc b/MBC.cc index 112ffa3..f208f73 100644 --- a/MBC.cc +++ b/MBC.cc @@ -1,5 +1,6 @@ #include "MBC.h" -#include "logger.h" +#include "Logger.h" +#include using namespace cartridge_types; @@ -14,3 +15,24 @@ MBC *create_MBC(GBRom *rom) return 0; } } + +u8 NoMBC::operator[](unsigned int addr) const +{ + if (addr <= 0x7FFF) + return ROM[addr]; + else if ((addr&0xE000) == 0xA000) //(addr >= 0xA000 && addr <= 0xBFFF) + return RAM[addr-0xA000]; + else + logger.error("NoMBC: Incorrect read"); + return 0; +} + +u8& NoMBC::operator[](unsigned int addr) +{ + if ((addr&0xE000) == 0xA000) //(addr >= 0xA000 && addr <= 0xBFFF) + return RAM[addr-0xA000]; + else + logger.error("NoMBC: trying to write in ROM"); + return *(static_cast(0)); // Shouldn't happen +} + diff --git a/MBC.h b/MBC.h index 2f52f90..81fd79f 100644 --- a/MBC.h +++ b/MBC.h @@ -3,8 +3,6 @@ #include "sized_types.h" #include "GBRom.h" -#include "logger.h" -#include class MBC { @@ -21,26 +19,9 @@ class NoMBC: public MBC public: NoMBC(GBRom *rom) { memcpy(ROM, rom->data, 32768); } + u8 operator[](unsigned int addr) const; + u8& operator[](unsigned int addr); - u8 operator[](unsigned int addr) const - { - if (addr <= 0x7FFF) - return ROM[addr]; - else if ((addr&0xE000) == 0xA000) //(addr >= 0xA000 && addr <= 0xBFFF) - return RAM[addr-0xA000]; - else - logger.error("NoMBC: Incorrect read"); - return 0; - } - - u8& operator[](unsigned int addr) - { - if ((addr&0xE000) == 0xA000) //(addr >= 0xA000 && addr <= 0xBFFF) - return RAM[addr-0xA000]; - else - logger.error("NoMBC: trying to write in ROM"); - return *(static_cast(0)); // Shouldn't happen - } }; diff --git a/Makefile b/Makefile index ca4ff79..b442874 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,20 @@ CXXFLAGS=-g -Wall -Weffc++ -Wstrict-null-sentinel -Wold-style-cast \ -Woverloaded-virtual -all: gbcore.o MBC.o GBMemory.o logger.o +all: gbcore.o MBC.o GBMemory.o Logger.o tests: tests/test_gbrom -logger.o: logger.cc logger.h +Logger.o: Logger.cc Logger.h g++ $(CXXFLAGS) -c -o $@ $< -GBMemory.o: GBMemory.cc GBMemory.h +GBMemory.o: GBMemory.cc GBMemory.h Logger.h g++ $(CXXFLAGS) -c -o $@ $< -MBC.o: MBC.cc MBC.h +MBC.o: MBC.cc MBC.h Logger.h g++ $(CXXFLAGS) -c -o $@ $< -gbcore.o: gbcore.cc gbcore.h GBRom.h logger.h MBC.h GBMemory.h +gbcore.o: gbcore.cc gbcore.h GBRom.h Logger.h MBC.h GBMemory.h g++ $(CXXFLAGS) -c -o $@ $< tests/test_gbrom: GBRom.cc GBRom.h diff --git a/gbcore.cc b/gbcore.cc index f9875ac..bbed7e7 100644 --- a/gbcore.cc +++ b/gbcore.cc @@ -2,7 +2,7 @@ #include "GBRom.h" #include "MBC.h" -#include "logger.h" +#include "Logger.h" #include #include