From 1e879b93b7ed81cddf10cbead1a055d9eab44416 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 14 Jan 2020 18:50:30 -0600 Subject: [PATCH] [nostalgia] Remove remaining C-style casts --- CMakeLists.txt | 4 +-- src/nostalgia/core/gba/addresses.hpp | 38 ++++++++++++++-------------- src/nostalgia/core/gba/media.cpp | 2 +- src/nostalgia/core/gba/mem.cpp | 6 ++--- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f9c457c..d3d6aa33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") set(OX_USE_STDLIB OFF) else() set(NOSTALGIA_BUILD_STUDIO ON) - #set(CMAKE_PREFIX_PATH ${NOSTALGIA_QT_PATH}) + set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${NOSTALGIA_QT_PATH}) endif() @@ -51,7 +51,7 @@ if(NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-field-initializers") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnull-dereference") - #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare") diff --git a/src/nostalgia/core/gba/addresses.hpp b/src/nostalgia/core/gba/addresses.hpp index 4da3144f..7fce5b29 100644 --- a/src/nostalgia/core/gba/addresses.hpp +++ b/src/nostalgia/core/gba/addresses.hpp @@ -12,40 +12,40 @@ ///////////////////////////////////////////////////////////////// // I/O Registers -#define REG_DISPCNT *((volatile uint32_t*) 0x04000000) +#define REG_DISPCNT *reinterpret_cast(0x04000000) ///////////////////////////////////////////////////////////////// // background registers // background control registers -#define REG_BG0CNT *((volatile uint32_t*) 0x04000008) -#define REG_BG1CNT *((volatile uint32_t*) 0x0400000a) -#define REG_BG2CNT *((volatile uint32_t*) 0x0400000c) -#define REG_BG3CNT *((volatile uint32_t*) 0x0400000e) +#define REG_BG0CNT *reinterpret_cast(0x04000008) +#define REG_BG1CNT *reinterpret_cast(0x0400000a) +#define REG_BG2CNT *reinterpret_cast(0x0400000c) +#define REG_BG3CNT *reinterpret_cast(0x0400000e) // background horizontal scrolling registers -#define REG_BG0HOFS *((volatile uint32_t*) 0x04000010) -#define REG_BG1HOFS *((volatile uint32_t*) 0x04000014) -#define REG_BG2HOFS *((volatile uint32_t*) 0x04000018) -#define REG_BG3HOFS *((volatile uint32_t*) 0x0400001c) +#define REG_BG0HOFS *reinterpret_cast(0x04000010) +#define REG_BG1HOFS *reinterpret_cast(0x04000014) +#define REG_BG2HOFS *reinterpret_cast(0x04000018) +#define REG_BG3HOFS *reinterpret_cast(0x0400001c) // background vertical scrolling registers -#define REG_BG0VOFS *((volatile uint32_t*) 0x04000012) -#define REG_BG1VOFS *((volatile uint32_t*) 0x04000016) -#define REG_BG2VOFS *((volatile uint32_t*) 0x0400001a) -#define REG_BG3VOFS *((volatile uint32_t*) 0x0400001e) +#define REG_BG0VOFS *reinterpret_cast(0x04000012) +#define REG_BG1VOFS *reinterpret_cast(0x04000016) +#define REG_BG2VOFS *reinterpret_cast(0x0400001a) +#define REG_BG3VOFS *reinterpret_cast(0x0400001e) ///////////////////////////////////////////////////////////////// // Memory Addresses -#define MEM_PALETTE_BG ((uint16_t*) 0x05000000) -#define MEM_PALETTE_SPRITE ((uint16_t*) 0x05000200) +#define MEM_PALETTE_BG reinterpret_cast(0x05000000) +#define MEM_PALETTE_SPRITE reinterpret_cast(0x05000200) typedef uint16_t BgMapTile[1024]; -#define MEM_BG_MAP ((BgMapTile*) 0x06000000) +#define MEM_BG_MAP reinterpret_cast(0x06000000) -#define MEM_ROM *((uint8_t*) 0x08000000) +#define MEM_ROM *reinterpret_cast(0x08000000) -#define MEM_WRAM_BEGIN ((uint8_t*) 0x02000000) -#define MEM_WRAM_END ((uint8_t*) 0x0203FFFF) +#define MEM_WRAM_BEGIN reinterpret_cast(0x02000000) +#define MEM_WRAM_END reinterpret_cast(0x0203FFFF) diff --git a/src/nostalgia/core/gba/media.cpp b/src/nostalgia/core/gba/media.cpp index 6104ecd6..e39680e7 100644 --- a/src/nostalgia/core/gba/media.cpp +++ b/src/nostalgia/core/gba/media.cpp @@ -23,7 +23,7 @@ uint8_t *loadRom(const char*) { constexpr auto headerP2Len = 16; constexpr auto headerLen = headerP1Len + headerP2Len + 1; - for (auto current = &MEM_ROM; current < ((uint8_t*) 0x0a000000); current += headerLen) { + for (auto current = &MEM_ROM; current < reinterpret_cast(0x0a000000); current += headerLen) { if (ox_memcmp(current, headerP1, headerP1Len) == 0 && ox_memcmp(current + headerP1Len, headerP2, headerP2Len) == 0) { return current + headerLen; diff --git a/src/nostalgia/core/gba/mem.cpp b/src/nostalgia/core/gba/mem.cpp index 49ac6683..81bacdfe 100644 --- a/src/nostalgia/core/gba/mem.cpp +++ b/src/nostalgia/core/gba/mem.cpp @@ -21,7 +21,7 @@ struct HeapSegment { HeapSegment *next; uint8_t *end() { - return ((uint8_t*) this) + this->size; + return reinterpret_cast(this) + this->size; } }; @@ -61,7 +61,7 @@ void *malloc(std::size_t allocSize) { // update size for the heap segment now that it is to be considered // allocated seg->size = fullSize; - seg->next = (HeapSegment*) (((uint8_t*) seg) + fullSize); + seg->next = reinterpret_cast(reinterpret_cast(seg) + fullSize); seg->inUse = true; auto out = seg + 1; @@ -79,7 +79,7 @@ void *malloc(std::size_t allocSize) { void free(void *ptrIn) { // get ptr back down to the meta data - auto *ptr = ((HeapSegment*) ptrIn) - 1; + auto *ptr = reinterpret_cast(ptrIn) - 1; HeapSegment *prev = nullptr; auto current = _heapIdx; while (current && current != ptr) {