[nostalgia] Remove remaining C-style casts

This commit is contained in:
Gary Talent 2020-01-14 18:50:30 -06:00
parent 6287663957
commit 1e879b93b7
4 changed files with 25 additions and 25 deletions

View File

@ -13,7 +13,7 @@ if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA")
set(OX_USE_STDLIB OFF) set(OX_USE_STDLIB OFF)
else() else()
set(NOSTALGIA_BUILD_STUDIO ON) set(NOSTALGIA_BUILD_STUDIO ON)
#set(CMAKE_PREFIX_PATH ${NOSTALGIA_QT_PATH}) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${NOSTALGIA_QT_PATH})
endif() 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} -Wmissing-field-initializers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor") 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} -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} -Woverloaded-virtual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare")

View File

@ -12,40 +12,40 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// I/O Registers // I/O Registers
#define REG_DISPCNT *((volatile uint32_t*) 0x04000000) #define REG_DISPCNT *reinterpret_cast<volatile uint32_t*>(0x04000000)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// background registers // background registers
// background control registers // background control registers
#define REG_BG0CNT *((volatile uint32_t*) 0x04000008) #define REG_BG0CNT *reinterpret_cast<volatile uint32_t*>(0x04000008)
#define REG_BG1CNT *((volatile uint32_t*) 0x0400000a) #define REG_BG1CNT *reinterpret_cast<volatile uint32_t*>(0x0400000a)
#define REG_BG2CNT *((volatile uint32_t*) 0x0400000c) #define REG_BG2CNT *reinterpret_cast<volatile uint32_t*>(0x0400000c)
#define REG_BG3CNT *((volatile uint32_t*) 0x0400000e) #define REG_BG3CNT *reinterpret_cast<volatile uint32_t*>(0x0400000e)
// background horizontal scrolling registers // background horizontal scrolling registers
#define REG_BG0HOFS *((volatile uint32_t*) 0x04000010) #define REG_BG0HOFS *reinterpret_cast<volatile uint32_t*>(0x04000010)
#define REG_BG1HOFS *((volatile uint32_t*) 0x04000014) #define REG_BG1HOFS *reinterpret_cast<volatile uint32_t*>(0x04000014)
#define REG_BG2HOFS *((volatile uint32_t*) 0x04000018) #define REG_BG2HOFS *reinterpret_cast<volatile uint32_t*>(0x04000018)
#define REG_BG3HOFS *((volatile uint32_t*) 0x0400001c) #define REG_BG3HOFS *reinterpret_cast<volatile uint32_t*>(0x0400001c)
// background vertical scrolling registers // background vertical scrolling registers
#define REG_BG0VOFS *((volatile uint32_t*) 0x04000012) #define REG_BG0VOFS *reinterpret_cast<volatile uint32_t*>(0x04000012)
#define REG_BG1VOFS *((volatile uint32_t*) 0x04000016) #define REG_BG1VOFS *reinterpret_cast<volatile uint32_t*>(0x04000016)
#define REG_BG2VOFS *((volatile uint32_t*) 0x0400001a) #define REG_BG2VOFS *reinterpret_cast<volatile uint32_t*>(0x0400001a)
#define REG_BG3VOFS *((volatile uint32_t*) 0x0400001e) #define REG_BG3VOFS *reinterpret_cast<volatile uint32_t*>(0x0400001e)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Memory Addresses // Memory Addresses
#define MEM_PALETTE_BG ((uint16_t*) 0x05000000) #define MEM_PALETTE_BG reinterpret_cast<uint16_t*>(0x05000000)
#define MEM_PALETTE_SPRITE ((uint16_t*) 0x05000200) #define MEM_PALETTE_SPRITE reinterpret_cast<uint16_t*>(0x05000200)
typedef uint16_t BgMapTile[1024]; typedef uint16_t BgMapTile[1024];
#define MEM_BG_MAP ((BgMapTile*) 0x06000000) #define MEM_BG_MAP reinterpret_cast<BgMapTile*>(0x06000000)
#define MEM_ROM *((uint8_t*) 0x08000000) #define MEM_ROM *reinterpret_cast<uint8_t*>(0x08000000)
#define MEM_WRAM_BEGIN ((uint8_t*) 0x02000000) #define MEM_WRAM_BEGIN reinterpret_cast<uint8_t*>(0x02000000)
#define MEM_WRAM_END ((uint8_t*) 0x0203FFFF) #define MEM_WRAM_END reinterpret_cast<uint8_t*>(0x0203FFFF)

View File

@ -23,7 +23,7 @@ uint8_t *loadRom(const char*) {
constexpr auto headerP2Len = 16; constexpr auto headerP2Len = 16;
constexpr auto headerLen = headerP1Len + headerP2Len + 1; 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<uint8_t*>(0x0a000000); current += headerLen) {
if (ox_memcmp(current, headerP1, headerP1Len) == 0 && if (ox_memcmp(current, headerP1, headerP1Len) == 0 &&
ox_memcmp(current + headerP1Len, headerP2, headerP2Len) == 0) { ox_memcmp(current + headerP1Len, headerP2, headerP2Len) == 0) {
return current + headerLen; return current + headerLen;

View File

@ -21,7 +21,7 @@ struct HeapSegment {
HeapSegment *next; HeapSegment *next;
uint8_t *end() { uint8_t *end() {
return ((uint8_t*) this) + this->size; return reinterpret_cast<uint8_t*>(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 // update size for the heap segment now that it is to be considered
// allocated // allocated
seg->size = fullSize; seg->size = fullSize;
seg->next = (HeapSegment*) (((uint8_t*) seg) + fullSize); seg->next = reinterpret_cast<HeapSegment*>(reinterpret_cast<uint8_t*>(seg) + fullSize);
seg->inUse = true; seg->inUse = true;
auto out = seg + 1; auto out = seg + 1;
@ -79,7 +79,7 @@ void *malloc(std::size_t allocSize) {
void free(void *ptrIn) { void free(void *ptrIn) {
// get ptr back down to the meta data // get ptr back down to the meta data
auto *ptr = ((HeapSegment*) ptrIn) - 1; auto *ptr = reinterpret_cast<HeapSegment*>(ptrIn) - 1;
HeapSegment *prev = nullptr; HeapSegment *prev = nullptr;
auto current = _heapIdx; auto current = _heapIdx;
while (current && current != ptr) { while (current && current != ptr) {