From b9e715d2c232b1e8979e0ed65ebf0ca5a76f9488 Mon Sep 17 00:00:00 2001 From: sinamas Date: Sun, 24 Feb 2013 18:10:13 +0100 Subject: [PATCH] libgambatte/sound/length_counter: formatting/readability --- libgambatte/src/sound/length_counter.cpp | 17 ++++++----------- libgambatte/src/sound/length_counter.h | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/libgambatte/src/sound/length_counter.cpp b/libgambatte/src/sound/length_counter.cpp index 4ebd7449..fba89ef9 100644 --- a/libgambatte/src/sound/length_counter.cpp +++ b/libgambatte/src/sound/length_counter.cpp @@ -22,9 +22,9 @@ namespace gambatte { -LengthCounter::LengthCounter(MasterDisabler &disabler, const unsigned mask) : - disableMaster(disabler), - lengthMask(mask) +LengthCounter::LengthCounter(MasterDisabler &disabler, const unsigned mask) +: disableMaster(disabler) +, lengthMask(mask) { init(false); nr1Change(0, 0, 0); @@ -38,7 +38,9 @@ void LengthCounter::event() { void LengthCounter::nr1Change(const unsigned newNr1, const unsigned nr4, const unsigned long cycleCounter) { lengthCounter = (~newNr1 & lengthMask) + 1; - counter = (nr4 & 0x40) ?( (cycleCounter >> 13) + lengthCounter) << 13 : static_cast(COUNTER_DISABLED); + counter = nr4 & 0x40 + ? ((cycleCounter >> 13) + lengthCounter) << 13 + : static_cast(COUNTER_DISABLED); } void LengthCounter::nr4Change(const unsigned oldNr4, const unsigned newNr4, const unsigned long cycleCounter) { @@ -67,13 +69,6 @@ void LengthCounter::nr4Change(const unsigned oldNr4, const unsigned newNr4, cons counter = COUNTER_DISABLED; } -/*void LengthCounter::reset() { - counter = COUNTER_DISABLED; - - if (cgb) - lengthCounter = lengthMask + 1; -}*/ - void LengthCounter::init(const bool cgb) { this->cgb = cgb; } diff --git a/libgambatte/src/sound/length_counter.h b/libgambatte/src/sound/length_counter.h index 8ae45714..042cdce0 100644 --- a/libgambatte/src/sound/length_counter.h +++ b/libgambatte/src/sound/length_counter.h @@ -27,20 +27,20 @@ namespace gambatte { class MasterDisabler; class LengthCounter : public SoundUnit { +public: + LengthCounter(MasterDisabler &disabler, unsigned lengthMask); + virtual void event(); + void nr1Change(unsigned newNr1, unsigned nr4, unsigned long cc); + void nr4Change(unsigned oldNr4, unsigned newNr4, unsigned long cc); + void init(bool cgb); + void saveState(SaveState::SPU::LCounter &lstate) const; + void loadState(const SaveState::SPU::LCounter &lstate, unsigned long cc); + +private: MasterDisabler &disableMaster; unsigned short lengthCounter; const unsigned char lengthMask; bool cgb; - -public: - LengthCounter(MasterDisabler &disabler, unsigned lengthMask); - void event(); - void nr1Change(unsigned newNr1, unsigned nr4, unsigned long cc); - void nr4Change(unsigned oldNr4, unsigned newNr4, unsigned long cc); -// void reset(); - void init(bool cgb); - void saveState(SaveState::SPU::LCounter &lstate) const; - void loadState(const SaveState::SPU::LCounter &lstate, unsigned long cc); }; }