From 35a844ebd36bb2f805f40b77fc3dd2762450c8b5 Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Tue, 3 Oct 2023 21:53:28 +0100 Subject: [PATCH] code rev --- sdl2-hyper-sonic-drivers/CMakeLists.txt | 2 +- .../{AdLibPart.cpp => AdLibChannel.cpp} | 8 +++--- .../{AdLibPart.hpp => AdLibChannel.hpp} | 4 +-- .../midi/scummvm/AdLibPercussionChannel.cpp | 2 +- .../midi/scummvm/AdLibPercussionChannel.hpp | 4 +-- .../drivers/midi/scummvm/AdlibVoice.h | 4 +-- .../drivers/midi/scummvm/MidiDriver_ADLIB.cpp | 28 +++++++++---------- .../drivers/midi/scummvm/MidiDriver_ADLIB.hpp | 10 +++---- 8 files changed, 31 insertions(+), 31 deletions(-) rename sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/{AdLibPart.cpp => AdLibChannel.cpp} (76%) rename sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/{AdLibPart.hpp => AdLibChannel.hpp} (90%) diff --git a/sdl2-hyper-sonic-drivers/CMakeLists.txt b/sdl2-hyper-sonic-drivers/CMakeLists.txt index 11ffcc98..7080d607 100644 --- a/sdl2-hyper-sonic-drivers/CMakeLists.txt +++ b/sdl2-hyper-sonic-drivers/CMakeLists.txt @@ -108,7 +108,7 @@ target_sources(${LIB_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibInstrument.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPart.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibChannel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPart.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibChannel.cpp similarity index 76% rename from sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPart.cpp rename to sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibChannel.cpp index ed9097ad..fa70ac60 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPart.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibChannel.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -8,14 +8,14 @@ namespace HyperSonicDrivers::drivers::midi::scummvm { using utils::logW; - AdLibPart::AdLibPart(const uint8_t channel) : + AdLibChannel::AdLibChannel(const uint8_t channel) : IMidiChannel(channel) { memset(&_partInstr, 0, sizeof(_partInstr)); memset(&_partInstrSecondary, 0, sizeof(_partInstrSecondary)); } - void AdLibPart::setInstr(const bool isOpl3) noexcept + void AdLibChannel::setInstr(const bool isOpl3) noexcept { if (isOpl3) { @@ -28,7 +28,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm } } - void AdLibPart::setCustomInstr(const uint8_t* instr) noexcept + void AdLibChannel::setCustomInstr(const uint8_t* instr) noexcept { memcpy(&_partInstr, instr, sizeof(AdLibInstrument)); } diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPart.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibChannel.hpp similarity index 90% rename from sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPart.hpp rename to sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibChannel.hpp index 0351b562..c8118a38 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPart.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibChannel.hpp @@ -9,10 +9,10 @@ namespace HyperSonicDrivers::drivers::midi::scummvm { struct AdLibVoice; - class AdLibPart : public IMidiChannel + class AdLibChannel : public IMidiChannel { public: - explicit AdLibPart(const uint8_t channel); + explicit AdLibChannel(const uint8_t channel); inline const AdLibInstrument* getInstr() const noexcept { return &_partInstr; }; inline const AdLibInstrument* getInstrSecondary() const noexcept { return &_partInstrSecondary; }; diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.cpp index 46f6f729..f357ec1c 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.cpp @@ -11,7 +11,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm using utils::logW; AdLibPercussionChannel::AdLibPercussionChannel() : - AdLibPart(audio::midi::MIDI_PERCUSSION_CHANNEL) + AdLibChannel(audio::midi::MIDI_PERCUSSION_CHANNEL) { priEff = 0; volume = 127; diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.hpp index 77330769..6e794087 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdLibPercussionChannel.hpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include @@ -14,7 +14,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm // will be done through the MidiChannel base class as opposed to the // AdLibPart base class. If this were NOT the case, all the functions // listed below would need to be virtual in AdLibPart as well as MidiChannel. - class AdLibPercussionChannel : public AdLibPart + class AdLibPercussionChannel : public AdLibChannel { public: AdLibPercussionChannel(); diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h index a79f153c..2361579e 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/AdlibVoice.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include namespace HyperSonicDrivers::drivers::midi::scummvm @@ -62,7 +62,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm AdLibVoice() = default; inline void setNote(const uint8_t note) { m_note = note; } inline void setFree(const bool free) { m_free = free; }; - inline void setChannel(AdLibPart* chan) { m_channel = chan; }; + inline void setChannel(AdLibChannel* chan) { m_channel = chan; }; inline void setWaitForPedal(const bool waitForPedal) { m_sustain = waitForPedal; }; }; } diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp index 2d1a141f..64e3e054 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -90,12 +90,12 @@ namespace HyperSonicDrivers::drivers::midi::scummvm 242, 243, 245, 247, 249, 251, 252, 254 }; - constexpr AdLibPart* toAdlibPart(IMidiChannel* mc) + constexpr AdLibChannel* toAdlibPart(IMidiChannel* mc) { - return dynamic_cast(mc); + return dynamic_cast(mc); } - static AdLibPart* toAdlibPart(const std::unique_ptr& ap) + static AdLibChannel* toAdlibPart(const std::unique_ptr& ap) { return toAdlibPart(ap.get()); } @@ -114,11 +114,11 @@ namespace HyperSonicDrivers::drivers::midi::scummvm std::ranges::fill(_curNotTable, 0); for (int i = 0; i < MIDI_PERCUSSION_CHANNEL; ++i) - m_channels[i] = std::make_unique(static_cast(i)); + m_channels[i] = std::make_unique(static_cast(i)); m_channels[MIDI_PERCUSSION_CHANNEL] = std::make_unique(); for (int i = MIDI_PERCUSSION_CHANNEL + 1; i < MIDI_MAX_CHANNELS; i++) - m_channels[i] = std::make_unique(static_cast(i)); + m_channels[i] = std::make_unique(static_cast(i)); std::ranges::fill(_channelTable2, 0); m_percussion = dynamic_cast(m_channels[MIDI_PERCUSSION_CHANNEL].get()); @@ -221,7 +221,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm if (m_opl3Mode) return; - AdLibPart* part = toAdlibPart(m_channels[channel]); + AdLibChannel* part = toAdlibPart(m_channels[channel]); part->pitchBendFactor = range; for (AdLibVoice* voice = part->voice; voice; voice = voice->next) { @@ -624,7 +624,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm void MidiDriver_ADLIB::mcIncStuff(AdLibVoice* voice, Struct10* s10, Struct11* s11) { - const AdLibPart* part = toAdlibPart(voice->getChannel()); + const AdLibChannel* part = toAdlibPart(voice->getChannel()); const uint8_t code = struct10OnTimer(s10, s11); if (code & 1) { @@ -882,7 +882,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm return _randSeed * a >> 8; } - void MidiDriver_ADLIB::partKeyOff(AdLibPart* part, uint8_t note) + void MidiDriver_ADLIB::partKeyOff(AdLibChannel* part, uint8_t note) { for (AdLibVoice* voice = part->voice; voice; voice = voice->next) { @@ -896,12 +896,12 @@ namespace HyperSonicDrivers::drivers::midi::scummvm } } - AdLibPart* MidiDriver_ADLIB::getChannel(const uint8_t channel) const noexcept + AdLibChannel* MidiDriver_ADLIB::getChannel(const uint8_t channel) const noexcept { return toAdlibPart(m_channels[channel]); } - void MidiDriver_ADLIB::partKeyOn(AdLibPart* part, const AdLibInstrument* instr, uint8_t note, uint8_t velocity, const AdLibInstrument* second, uint8_t pan) { + void MidiDriver_ADLIB::partKeyOn(AdLibChannel* part, const AdLibInstrument* instr, uint8_t note, uint8_t velocity, const AdLibInstrument* second, uint8_t pan) { AdLibVoice* voice; voice = allocateVoice(part->priEff); @@ -946,7 +946,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm return best; } - void MidiDriver_ADLIB::linkMc(AdLibPart* part, AdLibVoice* voice) + void MidiDriver_ADLIB::linkMc(AdLibChannel* part, AdLibVoice* voice) { voice->setFree(false); voice->setChannel(part); @@ -960,7 +960,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm void MidiDriver_ADLIB::mcKeyOn(AdLibVoice* voice, const AdLibInstrument* instr, uint8_t note, uint8_t velocity, const AdLibInstrument* second, uint8_t pan) { - const AdLibPart* part = toAdlibPart(voice->getChannel()); + const AdLibChannel* part = toAdlibPart(voice->getChannel()); uint8_t vol1, vol2; uint8_t secVol1 = 0, secVol2 = 0; @@ -1127,7 +1127,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm void MidiDriver_ADLIB::mcInitStuff(AdLibVoice* voice, Struct10* s10, Struct11* s11, uint8_t flags, const InstrumentExtra* ie) { - const AdLibPart* part = toAdlibPart(voice->getChannel()); + const AdLibChannel* part = toAdlibPart(voice->getChannel()); s11->modifyVal = 0; s11->flag0x40 = flags & 0x40; s10->loop = flags & 0x20; diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.hpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.hpp index d3c4420b..174377f1 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.hpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/midi/scummvm/MidiDriver_ADLIB.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include @@ -88,10 +88,10 @@ namespace HyperSonicDrivers::drivers::midi::scummvm int _timerIncrease = 0xD69; int _timerThreshold = 0x411B; - AdLibPart* getChannel(const uint8_t channel) const noexcept; + AdLibChannel* getChannel(const uint8_t channel) const noexcept; - void partKeyOn(AdLibPart* part, const AdLibInstrument* instr, uint8_t note, uint8_t velocity, const AdLibInstrument* second, uint8_t pan); - void partKeyOff(AdLibPart* part, uint8_t note); + void partKeyOn(AdLibChannel* part, const AdLibInstrument* instr, uint8_t note, uint8_t velocity, const AdLibInstrument* second, uint8_t pan); + void partKeyOff(AdLibChannel* part, uint8_t note); void adlibKeyOff(int chan); void adlibNoteOn(int chan, uint8_t note, int mod); @@ -111,7 +111,7 @@ namespace HyperSonicDrivers::drivers::midi::scummvm void mcOff(AdLibVoice* voice); - static void linkMc(AdLibPart* part, AdLibVoice* voice); + static void linkMc(AdLibChannel* part, AdLibVoice* voice); void mcIncStuff(AdLibVoice* voice, Struct10* s10, Struct11* s11); void mcInitStuff(AdLibVoice* voice, Struct10* s10, Struct11* s11, uint8_t flags, const InstrumentExtra* ie);