diff --git a/src/Systems/CHIP8/Chip8_CoreInterface.cpp b/src/Systems/CHIP8/Chip8_CoreInterface.cpp index 939304f..7429881 100644 --- a/src/Systems/CHIP8/Chip8_CoreInterface.cpp +++ b/src/Systems/CHIP8/Chip8_CoreInterface.cpp @@ -194,8 +194,8 @@ void Chip8_CoreInterface::startAudio(const s32 duration, const s32 tone) noexcep void Chip8_CoreInterface::startAudioAtChannel(const u32 index, const s32 duration, const s32 tone) noexcept { if (index >= STREAM::COUNT) { return; } - mAudioTimer[index] = duration & 0xFF; - mPhaseStep[index] = (160.0f + (tone ? tone + mAudioTimer[index] = static_cast(duration); + mPhaseStep[index] = (sTonalOffset + (tone ? tone : 8 * ((mCurrentPC >> 1) + mStackTop + 1 & 0x3E) )) / ASB->getFrequency(); } @@ -324,33 +324,16 @@ bool Chip8_CoreInterface::getPermaRegs(const u32 X) noexcept { /*==================================================================*/ -void Chip8_CoreInterface::copyGameToMemory( - u8* dest, const u32 offset -) noexcept { - std::copy_n( - std::execution::unseq, - HDM->getFileData(), - HDM->getFileSize(), - dest + offset - ); +void Chip8_CoreInterface::copyGameToMemory(void* dest) noexcept { + std::memcpy(dest, HDM->getFileData(), HDM->getFileSize()); } -void Chip8_CoreInterface::copyFontToMemory( - u8* dest, const u32 offset, const usz size -) noexcept { - std::copy_n( - std::execution::unseq, - sFontsData.begin(), size, dest + offset - ); +void Chip8_CoreInterface::copyFontToMemory(void* dest, const usz size) noexcept { + std::memcpy(dest, std::data(sFontsData), size); } -void Chip8_CoreInterface::copyColorsToCore( - u32* dest, const usz size -) noexcept { - std::copy_n( - std::execution::unseq, - sBitColors.begin(), size, dest - ); +void Chip8_CoreInterface::copyColorsToCore(void* dest) noexcept { + std::memcpy(dest, std::data(sBitColors), std::size(sBitColors) * sizeof(decltype(sBitColors)::value_type)); } /*==================================================================*/ diff --git a/src/Systems/CHIP8/Chip8_CoreInterface.hpp b/src/Systems/CHIP8/Chip8_CoreInterface.hpp index eac05fb..2663fbe 100644 --- a/src/Systems/CHIP8/Chip8_CoreInterface.hpp +++ b/src/Systems/CHIP8/Chip8_CoreInterface.hpp @@ -15,6 +15,7 @@ class Chip8_CoreInterface : public EmuInterface { protected: static inline Path* sPermaRegsPath{}; static inline Path* sSavestatePath{}; + static inline f32 sTonalOffset{ 160.0f }; std::unique_ptr ASB; @@ -169,9 +170,9 @@ class Chip8_CoreInterface : public EmuInterface { bool setPermaRegs(const u32 X) noexcept; bool getPermaRegs(const u32 X) noexcept; - void copyGameToMemory(u8* dest, const u32 offset) noexcept; - void copyFontToMemory(u8* dest, const u32 offset, const usz size) noexcept; - void copyColorsToCore(u32* dest, const usz size) noexcept; + void copyGameToMemory(void* dest) noexcept; + void copyFontToMemory(void* dest, const usz size) noexcept; + void copyColorsToCore(void* dest) noexcept; virtual void handlePreFrameInterrupt() noexcept; virtual void handleEndFrameInterrupt() noexcept; diff --git a/src/Systems/CHIP8/Cores/CHIP8_MODERN.cpp b/src/Systems/CHIP8/Cores/CHIP8_MODERN.cpp index c9de613..3732937 100644 --- a/src/Systems/CHIP8/Cores/CHIP8_MODERN.cpp +++ b/src/Systems/CHIP8/Cores/CHIP8_MODERN.cpp @@ -4,6 +4,7 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "../../../Assistants/HomeDirManager.hpp" #include "../../../Assistants/BasicVideoSpec.hpp" #include "../../../Assistants/BasicAudioSpec.hpp" #include "../../../Assistants/Well512.hpp" @@ -21,8 +22,8 @@ CHIP8_MODERN::CHIP8_MODERN() { mMemoryBank.end(), u8{ 0xFF } ); - copyGameToMemory(mMemoryBank.data(), cGameLoadPos); - copyFontToMemory(mMemoryBank.data(), 0x0, 0x50); + copyGameToMemory(mMemoryBank.data() + cGameLoadPos); + copyFontToMemory(mMemoryBank.data(), 0x50); setDisplayResolution(cScreenSizeX, cScreenSizeY); diff --git a/src/Systems/CHIP8/Cores/MEGACHIP.cpp b/src/Systems/CHIP8/Cores/MEGACHIP.cpp index bd26ca3..fb7e7e5 100644 --- a/src/Systems/CHIP8/Cores/MEGACHIP.cpp +++ b/src/Systems/CHIP8/Cores/MEGACHIP.cpp @@ -17,8 +17,8 @@ MEGACHIP::MEGACHIP() { if (getCoreState() != EmuState::FATAL) { - copyGameToMemory(mMemoryBank.data(), cGameLoadPos); - copyFontToMemory(mMemoryBank.data(), 0x0, 0xB4); + copyGameToMemory(mMemoryBank.data() + cGameLoadPos); + copyFontToMemory(mMemoryBank.data(), 0xB4); mForegroundBuffer.resize(false, cScreenMegaY, cScreenMegaX); mBackgroundBuffer.resize(false, cScreenMegaY, cScreenMegaX); diff --git a/src/Systems/CHIP8/Cores/SCHIP_LEGACY.cpp b/src/Systems/CHIP8/Cores/SCHIP_LEGACY.cpp index 74a397d..734eeb0 100644 --- a/src/Systems/CHIP8/Cores/SCHIP_LEGACY.cpp +++ b/src/Systems/CHIP8/Cores/SCHIP_LEGACY.cpp @@ -31,8 +31,8 @@ SCHIP_LEGACY::SCHIP_LEGACY() mMemoryBank.end(), u8{ 0xFF } ); - copyGameToMemory(mMemoryBank.data(), cGameLoadPos); - copyFontToMemory(mMemoryBank.data(), 0x0, 0xB4); + copyGameToMemory(mMemoryBank.data() + cGameLoadPos); + copyFontToMemory(mMemoryBank.data(), 0xB4); setDisplayResolution(cScreenSizeX, cScreenSizeY); diff --git a/src/Systems/CHIP8/Cores/SCHIP_MODERN.cpp b/src/Systems/CHIP8/Cores/SCHIP_MODERN.cpp index 96df8c7..0f147be 100644 --- a/src/Systems/CHIP8/Cores/SCHIP_MODERN.cpp +++ b/src/Systems/CHIP8/Cores/SCHIP_MODERN.cpp @@ -23,8 +23,8 @@ SCHIP_MODERN::SCHIP_MODERN() mMemoryBank.end(), u8{ 0xFF } ); - copyGameToMemory(mMemoryBank.data(), cGameLoadPos); - copyFontToMemory(mMemoryBank.data(), 0x0, 0xF0); + copyGameToMemory(mMemoryBank.data() + cGameLoadPos); + copyFontToMemory(mMemoryBank.data(), 0xF0); setDisplayResolution(cScreenSizeX, cScreenSizeY); diff --git a/src/Systems/CHIP8/Cores/XOCHIP.cpp b/src/Systems/CHIP8/Cores/XOCHIP.cpp index 1a79b55..079d176 100644 --- a/src/Systems/CHIP8/Cores/XOCHIP.cpp +++ b/src/Systems/CHIP8/Cores/XOCHIP.cpp @@ -29,9 +29,9 @@ XOCHIP::XOCHIP() mMemoryBank.end(), u8{ 0xFF } ); - copyGameToMemory(mMemoryBank.data(), cGameLoadPos); - copyFontToMemory(mMemoryBank.data(), 0x0, 0x50); - copyColorsToCore(mBitColors.data(), mBitColors.size()); + copyGameToMemory(mMemoryBank.data() + cGameLoadPos); + copyFontToMemory(mMemoryBank.data(), 0x50); + copyColorsToCore(mBitColors.data()); setDisplayResolution(cScreenSizeX, cScreenSizeY);