From 612b821ce0b76722e1ce7d652b5a689adb366fcc Mon Sep 17 00:00:00 2001 From: Troy Schrapel Date: Mon, 4 Sep 2023 22:11:50 +0930 Subject: [PATCH] Compile with all warnings, warnings as errors --- CMakeLists.txt | 10 ++++++++++ src/vrEmuTms9918.c | 8 +++++--- src/vrEmuTms9918Util.c | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c575c5..35d3b0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,16 @@ if (NOT BUILD_SHARED_LIBS) add_definitions(-DVR_EMU_TMS9918_STATIC) endif() +if (PROJECT_IS_TOP_LEVEL) + if(MSVC) + add_compile_options(/W4 /WX) + add_compile_options(/arch:AVX2 /Ox) + else() + add_compile_options(-Wall -Wextra -Wpedantic -Werror) + add_compile_options(-march=native) + endif() +endif() + include(CTest) add_subdirectory(src) \ No newline at end of file diff --git a/src/vrEmuTms9918.c b/src/vrEmuTms9918.c index 70f37d7..2f8e3d7 100644 --- a/src/vrEmuTms9918.c +++ b/src/vrEmuTms9918.c @@ -438,8 +438,10 @@ static void __time_critical_func(vrEmuTms9918OutputSprites)(VrEmuTms9918* tms991 if (spritesShown == 0) { - int *rsbInt = (int*)tms9918->rowSpriteBits; - for (int i = 0; i < sizeof(tms9918->rowSpriteBits) / sizeof(int); ++i) + int* rsbInt = (int*)tms9918->rowSpriteBits; + int* end = rsbInt + sizeof(tms9918->rowSpriteBits) / sizeof(int); + + while (rsbInt < end) { *rsbInt++ = 0; } @@ -571,7 +573,7 @@ static void __time_critical_func(vrEmuTms9918GraphicsIIScanLine)(VrEmuTms9918* t const uint8_t nameMask = ((tms9918->registers[TMS_REG_COLOR_TABLE] & 0x7f) << 3) | 0x07; const uint16_t pageThird = ((tileY & 0x18) >> 3) - & (tms9918->registers[TMS_REG_PATTERN_TABLE] & 0x03); /* which page? 0-2 */ + & (tms9918->registers[TMS_REG_PATTERN_TABLE] & 0x03); /* which page? 0-2 */ const uint16_t pageOffset = pageThird << 11; /* offset (0, 0x800 or 0x1000) */ const uint8_t* patternTable = tms9918->vram + tmsPatternTableAddr(tms9918) + pageOffset; diff --git a/src/vrEmuTms9918Util.c b/src/vrEmuTms9918Util.c index 9c3c393..30603fe 100644 --- a/src/vrEmuTms9918Util.c +++ b/src/vrEmuTms9918Util.c @@ -107,4 +107,4 @@ void vrEmuTms9918InitialiseGfxII(VrEmuTms9918* tms9918) vrEmuTms9918WriteData(tms9918, i & 0xff); } -} \ No newline at end of file +}