Skip to content

Commit

Permalink
Update SDL3 to 15/9 release date, resolve a bunch of warnings all aro…
Browse files Browse the repository at this point in the history
…und from MSVC and clang, happier compilers.
  • Loading branch information
coornio committed Sep 21, 2024
1 parent ca7413e commit 9e434c5
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/Assistants/BasicAudioSpec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class AudioSpecBlock {
auto getVolumeNorm() const noexcept { return mVolume / 255.0f; }

auto getSampleRate(f32 framerate) const noexcept {
return framerate ? mSpec.freq / framerate : 0.0f;
return std::fabs(framerate) > 1e-6f ? mSpec.freq / framerate : 0.0f;
}

void setVolume(s32 value) noexcept {
Expand Down
2 changes: 1 addition & 1 deletion src/Assistants/BasicInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void BasicKeyboard::updateCopy() {
std::copy_n(
std::execution::par_unseq,
SDL_GetKeyboardState(nullptr),
static_cast<Uint32>(SDL_NUM_SCANCODES),
SDL_SCANCODE_COUNT,
oldState.data()
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Assistants/BasicInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum BIC_Button {
#pragma region BasicKeyboard Singleton Class

class BasicKeyboard final {
std::array<Uint8, SDL_NUM_SCANCODES> oldState{};
std::array<Uint8, SDL_SCANCODE_COUNT> oldState{};

BasicKeyboard() noexcept = default;
~BasicKeyboard() noexcept = default;
Expand Down
17 changes: 10 additions & 7 deletions src/Assistants/BasicVideoSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
#include <SDL3/SDL_platform_defines.h>

#ifdef SDL_PLATFORM_WIN32
#pragma warning(push)
#pragma warning(disable : 5039)
#include <dwmapi.h>
#pragma comment (lib, "Dwmapi")
#pragma warning(pop)
#endif

#include "BasicVideoSpec.hpp"
Expand All @@ -23,7 +26,7 @@ BasicVideoSpec::BasicVideoSpec() noexcept
: enableBuzzGlow{ true }
{
if (!SDL_InitSubSystem(SDL_INIT_VIDEO)) {
showErrorBox("Failed SDL_INIT_VIDEO!");
showErrorBox("Failed SDL_INIT_VIDEO");
return;
}

Expand All @@ -46,20 +49,20 @@ void BasicVideoSpec::createWindow(const s32 window_W, const s32 window_H) {
window = SDL_CreateWindow(nullptr, window_W, window_H, 0);

if (!window) {
showErrorBox("Failed to create SDL_Window!");
showErrorBox("Failed to create SDL_Window");
} else {
const auto windowHandle{
static_cast<HWND>(SDL_GetPointerProperty(
SDL_GetPointerProperty(
SDL_GetWindowProperties(window),
SDL_PROP_WINDOW_WIN32_HWND_POINTER,
nullptr
))
)
};

if (windowHandle) {
const auto windowRound{ DWMWCP_DONOTROUND };
DwmSetWindowAttribute(
windowHandle,
static_cast<HWND>(windowHandle),
DWMWA_WINDOW_CORNER_PREFERENCE,
&windowRound,
sizeof(windowRound)
Expand All @@ -74,7 +77,7 @@ void BasicVideoSpec::createRenderer() {
renderer = SDL_CreateRenderer(window, nullptr);

if (!renderer) {
showErrorBox("Failed to create SDL_Renderer!");
showErrorBox("Failed to create SDL_Renderer");
}
}

Expand All @@ -92,7 +95,7 @@ void BasicVideoSpec::createTexture(s32 texture_W, s32 texture_H) {
);

if (!texture) {
showErrorBox("Failed to create SDL_Texture!");
showErrorBox("Failed to create SDL_Texture");
} else {
SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST);
ppitch = texture_W * 4;
Expand Down
2 changes: 2 additions & 0 deletions src/Assistants/HomeDirManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

/*==================================================================*/

[[maybe_unused]]
static auto getFileModTime(const fsPath& filePath) noexcept {
std::error_code error;
return std::filesystem::last_write_time(filePath, error);
}

[[maybe_unused]]
static auto getFileSize(const fsPath& filePath) noexcept {
std::error_code error;
return std::filesystem::file_size(filePath, error);
Expand Down
2 changes: 1 addition & 1 deletion src/Systems/BYTEPUSHER/BytePusher_CoreInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BytePusher_CoreInterface : public EmuInterface {

public:
BytePusher_CoreInterface() noexcept;
~BytePusher_CoreInterface() noexcept;
~BytePusher_CoreInterface() noexcept override;

void processFrame() override;

Expand Down
4 changes: 2 additions & 2 deletions src/Systems/CHIP8/Chip8_CoreInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void Chip8_CoreInterface::copyGameToMemory(
}

void Chip8_CoreInterface::copyFontToMemory(
u8* dest, const u32 offset, const u32 size
u8* dest, const u32 offset, const usz size
) noexcept {
std::copy_n(
std::execution::unseq,
Expand All @@ -315,7 +315,7 @@ void Chip8_CoreInterface::copyFontToMemory(
}

void Chip8_CoreInterface::copyColorsToCore(
u32* dest, const u32 size
u32* dest, const usz size
) noexcept {
std::copy_n(
std::execution::unseq,
Expand Down
6 changes: 3 additions & 3 deletions src/Systems/CHIP8/Chip8_CoreInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ class Chip8_CoreInterface : public EmuInterface {
bool getPermaRegs(const s32 X) noexcept;

void copyGameToMemory(u8* dest, const u32 offset) noexcept;
void copyFontToMemory(u8* dest, const u32 offset, const u32 size) noexcept;
void copyColorsToCore(u32* dest, const u32 size) noexcept;
void copyFontToMemory(u8* dest, const u32 offset, const usz size) noexcept;
void copyColorsToCore(u32* dest, const usz size) noexcept;

virtual void handlePreFrameInterrupt() noexcept;
virtual void handleEndFrameInterrupt() noexcept;
Expand All @@ -166,7 +166,7 @@ class Chip8_CoreInterface : public EmuInterface {

public:
Chip8_CoreInterface() noexcept;
~Chip8_CoreInterface() noexcept;
~Chip8_CoreInterface() noexcept override;

void processFrame() override;

Expand Down
16 changes: 8 additions & 8 deletions src/Systems/CHIP8/Cores/CHIP8_MODERN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,25 +339,25 @@ void CHIP8_MODERN::renderVideoData() {
}
void CHIP8_MODERN::instruction_8xy5(const s32 X, const s32 Y) noexcept {
const bool nborrow{ mRegisterV[X] >= mRegisterV[Y] };
mRegisterV[X] = mRegisterV[X] - mRegisterV[Y];
mRegisterV[0xF] = nborrow;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] - mRegisterV[Y]);
mRegisterV[0xF] = static_cast<u8>(nborrow);
}
void CHIP8_MODERN::instruction_8xy7(const s32 X, const s32 Y) noexcept {
const bool nborrow{ mRegisterV[Y] >= mRegisterV[X] };
mRegisterV[X] = mRegisterV[Y] - mRegisterV[X];
mRegisterV[0xF] = nborrow;
mRegisterV[X] = static_cast<u8>(mRegisterV[Y] - mRegisterV[X]);
mRegisterV[0xF] = static_cast<u8>(nborrow);
}
void CHIP8_MODERN::instruction_8xy6(const s32 X, const s32 Y) noexcept {
if (!Quirk.shiftVX) { mRegisterV[X] = mRegisterV[Y]; }
const bool lsb{ (mRegisterV[X] & 1) == 1 };
mRegisterV[X] = mRegisterV[X] >> 1;
mRegisterV[0xF] = lsb;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] >> 1);
mRegisterV[0xF] = static_cast<u8>(lsb);
}
void CHIP8_MODERN::instruction_8xyE(const s32 X, const s32 Y) noexcept {
if (!Quirk.shiftVX) { mRegisterV[X] = mRegisterV[Y]; }
const bool msb{ (mRegisterV[X] >> 7) == 1 };
mRegisterV[X] = mRegisterV[X] << 1;
mRegisterV[0xF] = msb;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] << 1);
mRegisterV[0xF] = static_cast<u8>(msb);
}

#pragma endregion
Expand Down
32 changes: 17 additions & 15 deletions src/Systems/CHIP8/Cores/MEGACHIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ MEGACHIP::MEGACHIP()
mFramerate = cRefreshRate;

prepDisplayArea(Resolution::LO);
setNewBlendAlgorithm(BlendMode::NORMAL);
setNewBlendAlgorithm(BlendMode::ALPHA_BLEND);
initializeFontColors();
}
}
Expand Down Expand Up @@ -461,7 +461,7 @@ void MEGACHIP::setNewBlendAlgorithm(const s32 mode) noexcept {
break;

default:
case BlendMode::NORMAL:
case BlendMode::ALPHA_BLEND:
fpBlendAlgorithm = [](const f32 src, const f32)
noexcept { return src; };
break;
Expand Down Expand Up @@ -735,23 +735,23 @@ void MEGACHIP::scrollBuffersRT() {
}
void MEGACHIP::instruction_8xy5(const s32 X, const s32 Y) noexcept {
const bool nborrow{ mRegisterV[X] >= mRegisterV[Y] };
mRegisterV[X] = mRegisterV[X] - mRegisterV[Y];
mRegisterV[0xF] = nborrow;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] - mRegisterV[Y]);
mRegisterV[0xF] = static_cast<u8>(nborrow);
}
void MEGACHIP::instruction_8xy7(const s32 X, const s32 Y) noexcept {
const bool nborrow{ mRegisterV[Y] >= mRegisterV[X] };
mRegisterV[X] = mRegisterV[Y] - mRegisterV[X];
mRegisterV[0xF] = nborrow;
mRegisterV[X] = static_cast<u8>(mRegisterV[Y] - mRegisterV[X]);
mRegisterV[0xF] = static_cast<u8>(nborrow);
}
void MEGACHIP::instruction_8xy6(const s32 X, const s32 ) noexcept {
const bool lsb{ (mRegisterV[X] & 1) == 1 };
mRegisterV[X] = mRegisterV[X] >> 1;
mRegisterV[0xF] = lsb;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] >> 1);
mRegisterV[0xF] = static_cast<u8>(lsb);
}
void MEGACHIP::instruction_8xyE(const s32 X, const s32 ) noexcept {
const bool msb{ (mRegisterV[X] >> 7) == 1 };
mRegisterV[X] = mRegisterV[X] << 1;
mRegisterV[0xF] = msb;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] << 1);
mRegisterV[0xF] = static_cast<u8>(msb);
}

#pragma endregion
Expand Down Expand Up @@ -926,13 +926,13 @@ void MEGACHIP::scrollBuffersRT() {
const auto originX{ mRegisterV[X] & 0x78 };
const auto originY{ mRegisterV[Y] & 0x3F };

mRegisterV[0xF] = 0;
auto collisions{ 0 };

if (N == 0) {
for (auto rowN{ 0 }; rowN < 16; ++rowN) {
const auto offsetY{ originY + rowN };

mRegisterV[0xF] += drawSingleBytes(
collisions += drawSingleBytes(
originX, offsetY, offsetX ? 24 : 16,
(readMemoryI(2 * rowN + 0) << 8 | \
readMemoryI(2 * rowN + 1)) << offsetX
Expand All @@ -943,31 +943,33 @@ void MEGACHIP::scrollBuffersRT() {
for (auto rowN{ 0 }; rowN < N; ++rowN) {
const auto offsetY{ originY + rowN };

mRegisterV[0xF] += drawSingleBytes(
collisions += drawSingleBytes(
originX, offsetY, offsetX ? 16 : 8,
readMemoryI(rowN) << offsetX
);
if (offsetY == 0x3F) { break; }
}
}
mRegisterV[0xF] = static_cast<u8>(collisions);
}
else {
const auto offsetX{ 8 - (mRegisterV[X] * 2 & 7) };
const auto originX{ mRegisterV[X] * 2 & 0x78 };
const auto originY{ mRegisterV[Y] * 2 & 0x3F };
const auto lengthN{ N == 0 ? 16 : N };

mRegisterV[0xF] = 0;
auto collisions{ 0 };

for (auto rowN{ 0 }; rowN < lengthN; ++rowN) {
const auto offsetY{ originY + rowN * 2 };

mRegisterV[0xF] |= drawDoubleBytes(
collisions += drawDoubleBytes(
originX, offsetY, offsetX ? 24 : 16,
bitBloat(readMemoryI(rowN)) << offsetX
);
if (offsetY == 0x3E) { break; }
}
mRegisterV[0xF] = static_cast<u8>(collisions != 0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Systems/CHIP8/Cores/MEGACHIP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MEGACHIP final : public Chip8_CoreInterface {
u32 blendPixel(const u32 srcPixel, const u32 dstPixel) const noexcept;

enum BlendMode {
NORMAL = 0,
ALPHA_BLEND = 0,
LINEAR_DODGE = 4,
MULTIPLY = 5,
};
Expand Down
29 changes: 16 additions & 13 deletions src/Systems/CHIP8/Cores/SCHIP_LEGACY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,23 +412,23 @@ void SCHIP_LEGACY::scrollDisplayRT() {
}
void SCHIP_LEGACY::instruction_8xy5(const s32 X, const s32 Y) noexcept {
const bool nborrow{ mRegisterV[X] >= mRegisterV[Y] };
mRegisterV[X] = mRegisterV[X] - mRegisterV[Y];
mRegisterV[0xF] = nborrow;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] - mRegisterV[Y]);
mRegisterV[0xF] = static_cast<u8>(nborrow);
}
void SCHIP_LEGACY::instruction_8xy7(const s32 X, const s32 Y) noexcept {
const bool nborrow{ mRegisterV[Y] >= mRegisterV[X] };
mRegisterV[X] = mRegisterV[Y] - mRegisterV[X];
mRegisterV[0xF] = nborrow;
mRegisterV[X] = static_cast<u8>(mRegisterV[Y] - mRegisterV[X]);
mRegisterV[0xF] = static_cast<u8>(nborrow);
}
void SCHIP_LEGACY::instruction_8xy6(const s32 X, const s32 ) noexcept {
const bool lsb{ (mRegisterV[X] & 1) == 1 };
mRegisterV[X] = mRegisterV[X] >> 1;
mRegisterV[0xF] = lsb;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] >> 1);
mRegisterV[0xF] = static_cast<u8>(lsb);
}
void SCHIP_LEGACY::instruction_8xyE(const s32 X, const s32 ) noexcept {
const bool msb{ (mRegisterV[X] >> 7) == 1 };
mRegisterV[X] = mRegisterV[X] << 1;
mRegisterV[0xF] = msb;
mRegisterV[X] = static_cast<u8>(mRegisterV[X] << 1);
mRegisterV[0xF] = static_cast<u8>(msb);
}

#pragma endregion
Expand Down Expand Up @@ -537,13 +537,13 @@ void SCHIP_LEGACY::scrollDisplayRT() {
const auto originX{ mRegisterV[X] & 0x78 };
const auto originY{ mRegisterV[Y] & 0x3F };

mRegisterV[0xF] = 0;
auto collisions{ 0 };

if (N == 0) {
for (auto rowN{ 0 }; rowN < 16; ++rowN) {
const auto offsetY{ originY + rowN };

mRegisterV[0xF] += drawSingleBytes(
collisions += drawSingleBytes(
originX, offsetY, offsetX ? 24 : 16,
(readMemoryI(2 * rowN + 0) << 8 | \
readMemoryI(2 * rowN + 1)) << offsetX
Expand All @@ -554,31 +554,34 @@ void SCHIP_LEGACY::scrollDisplayRT() {
for (auto rowN{ 0 }; rowN < N; ++rowN) {
const auto offsetY{ originY + rowN };

mRegisterV[0xF] += drawSingleBytes(
collisions += drawSingleBytes(
originX, offsetY, offsetX ? 16 : 8,
readMemoryI(rowN) << offsetX
);
if (offsetY == 0x3F) { break; }
}
}
mRegisterV[0xF] = static_cast<u8>(collisions);
}
else {
const auto offsetX{ 8 - (mRegisterV[X] * 2 & 7) };
const auto originX{ mRegisterV[X] * 2 & 0x78 };
const auto originY{ mRegisterV[Y] * 2 & 0x3F };
const auto lengthN{ N == 0 ? 16 : N };

mRegisterV[0xF] = 0;
auto collisions{ 0 };

for (auto rowN{ 0 }; rowN < lengthN; ++rowN) {
const auto offsetY{ originY + rowN * 2 };

mRegisterV[0xF] |= drawDoubleBytes(
collisions += drawDoubleBytes(
originX, offsetY, offsetX ? 24 : 16,
bitBloat(readMemoryI(rowN)) << offsetX
);

if (offsetY == 0x3E) { break; }
}
mRegisterV[0xF] = static_cast<u8>(collisions != 0);
}
}

Expand Down
Loading

0 comments on commit 9e434c5

Please sign in to comment.