More updates from the CPP core guidelines

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-11-11 11:12:09 +00:00
parent 46d7777dbe
commit c18aeb9e63
12 changed files with 42 additions and 84 deletions

View File

@ -10,14 +10,14 @@ namespace EightBit {
namespace GameBoy {
class CharacterDefinition {
public:
CharacterDefinition();
CharacterDefinition() = default;
CharacterDefinition(Ram* ram, uint16_t address);
std::array<int, 8> get(int row) const;
private:
Ram* m_ram;
uint16_t m_address;
Ram* m_ram = nullptr;
uint16_t m_address = ~0;
};
}
}

View File

@ -42,8 +42,8 @@ namespace EightBit {
Ram& m_vram;
const AbstractColourPalette* m_colours;
std::array<ObjectAttribute, 40> m_objectAttributes;
uint8_t m_control;
uint8_t m_scanLine;
uint8_t m_control = 0;
uint8_t m_scanLine = 0;
std::array<int, 4> createPalette(int address);

View File

@ -60,29 +60,29 @@ namespace EightBit {
private:
LR35902 m_cpu;
Rom m_bootRom; // 0x0000 - 0x00ff
Rom m_bootRom = 0x100; // 0x0000 - 0x00ff
std::vector<Rom> m_gameRomBanks; // 0x0000 - 0x3fff, 0x4000 - 0x7fff (switchable)
Ram m_videoRam; // 0x8000 - 0x9fff
Ram m_videoRam = 0x2000; // 0x8000 - 0x9fff
std::vector<Ram> m_ramBanks; // 0xa000 - 0xbfff (switchable)
Ram m_lowInternalRam; // 0xc000 - 0xdfff (mirrored at 0xe000)
Ram m_oamRam; // 0xfe00 - 0xfe9f
Ram m_lowInternalRam = 0x2000; // 0xc000 - 0xdfff (mirrored at 0xe000)
Ram m_oamRam = 0xa0; // 0xfe00 - 0xfe9f
IoRegisters m_ioPorts; // 0xff00 - 0xff7f
Ram m_highInternalRam; // 0xff80 - 0xffff
Ram m_highInternalRam = 0x80; // 0xff80 - 0xffff
bool m_enabledLCD;
bool m_enabledLCD = false;
bool m_disableGameRom;
bool m_disableGameRom = false;
bool m_rom;
bool m_banked;
bool m_ram;
bool m_battery;
bool m_rom = false;
bool m_banked = false;
bool m_ram = false;
bool m_battery = false;
bool m_higherRomBank;
bool m_ramBankSwitching;
bool m_higherRomBank = true;
bool m_ramBankSwitching = false;
int m_romBank;
int m_ramBank;
int m_romBank = 1;
int m_ramBank = 0;
void validateCartridgeType();

View File

@ -166,24 +166,24 @@ namespace EightBit {
private:
Bus& m_bus;
bool m_disableBootRom;
bool m_disableBootRom = false;
register16_t m_divCounter;
int m_timerCounter;
int m_timerRate;
register16_t m_divCounter = { 0xab, 0xcc };
int m_timerCounter = 0;
int m_timerRate = 0;
register16_t m_dmaAddress;
bool m_dmaTransferActive;
register16_t m_dmaAddress = { 0, 0 };
bool m_dmaTransferActive = false;
bool m_scanP15;
bool m_scanP14;
bool m_scanP15 = false;
bool m_scanP14 = false;
bool m_p15; // misc keys
bool m_p14; // direction keys
bool m_p13; // down/start
bool m_p12; // up/select
bool m_p11; // left/b
bool m_p10; // right/a
bool m_p15 = true; // misc keys
bool m_p14 = true; // direction keys
bool m_p13 = true; // down/start
bool m_p12 = true; // up/select
bool m_p11 = true; // left/b
bool m_p10 = true; // right/a
void checkTimer(int cycles);

View File

@ -55,10 +55,10 @@ namespace EightBit {
register16_t de;
register16_t hl;
bool m_ime;
bool m_stopped;
bool m_ime = false;
bool m_stopped = false;
bool m_prefixCB;
bool m_prefixCB = false;
bool& IME() { return m_ime; }

View File

@ -11,7 +11,7 @@ namespace EightBit {
namespace GameBoy {
class ObjectAttribute {
public:
ObjectAttribute();
ObjectAttribute() = default;
ObjectAttribute(Ram& ram, uint16_t address);
uint8_t positionY() const { return m_positionY; }

View File

@ -3,11 +3,6 @@
#include <Ram.h>
EightBit::GameBoy::CharacterDefinition::CharacterDefinition()
: m_ram(nullptr),
m_address(~0) {
}
EightBit::GameBoy::CharacterDefinition::CharacterDefinition(Ram* ram, uint16_t address)
: m_ram(ram),
m_address(address) {

View File

@ -12,9 +12,7 @@ EightBit::GameBoy::Display::Display(const AbstractColourPalette* colours, Bus& b
: m_bus(bus),
m_oam(oam),
m_vram(vram),
m_colours(colours),
m_control(0),
m_scanLine(0) {
m_colours(colours) {
}
const std::vector<uint32_t>& EightBit::GameBoy::Display::pixels() const {

View File

@ -4,24 +4,9 @@
EightBit::GameBoy::Bus::Bus()
: m_cpu(*this),
m_bootRom(0x100),
m_gameRomBanks(1),
m_videoRam(0x2000),
m_ramBanks(0),
m_lowInternalRam(0x2000),
m_oamRam(0xa0),
m_ioPorts(*this),
m_highInternalRam(0x80),
m_enabledLCD(false),
m_disableGameRom(false),
m_rom(false),
m_banked(false),
m_ram(false),
m_battery(false),
m_higherRomBank(true),
m_ramBankSwitching(false),
m_romBank(1),
m_ramBank(0) {
m_ioPorts(*this) {
WrittenByte.connect(std::bind(&GameBoy::Bus::Bus_WrittenByte, this, std::placeholders::_1));
}

View File

@ -4,23 +4,9 @@
EightBit::GameBoy::IoRegisters::IoRegisters(Bus& bus)
: Ram(0x80),
m_bus(bus),
m_disableBootRom(false),
m_timerCounter(0),
m_timerRate(0),
m_dmaTransferActive(false),
m_scanP15(false),
m_scanP14(false),
m_p15(true),
m_p14(true),
m_p13(true),
m_p12(true),
m_p11(true),
m_p10(true) {
m_bus(bus) {
m_bus.ReadingByte.connect(std::bind(&IoRegisters::Bus_ReadingByte, this, std::placeholders::_1));
m_bus.WrittenByte.connect(std::bind(&IoRegisters::Bus_WrittenByte, this, std::placeholders::_1));
m_divCounter.word = 0xabcc;
m_dmaAddress.word = 0;
}
void EightBit::GameBoy::IoRegisters::reset() {

View File

@ -6,10 +6,7 @@
EightBit::GameBoy::LR35902::LR35902(Bus& memory)
: IntelProcessor(memory),
m_bus(memory),
m_ime(false),
m_stopped(false),
m_prefixCB(false) {
m_bus(memory) {
}
void EightBit::GameBoy::LR35902::reset() {

View File

@ -3,9 +3,6 @@
#include <Ram.h>
EightBit::GameBoy::ObjectAttribute::ObjectAttribute() {
}
EightBit::GameBoy::ObjectAttribute::ObjectAttribute(Ram& ram, uint16_t address) {
m_positionY = ram.peek(address);
m_positionX = ram.peek(++address);