Better CMake dependency handling

This commit is contained in:
Jack Andersen 2019-06-11 16:04:15 -10:00
parent 82c607ec40
commit 51c7163cfd
4 changed files with 18 additions and 15 deletions

View File

@ -4,8 +4,8 @@ project(kabufuda)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(include) unset(KABUFUDA_INCLUDE_DIR CACHE)
set(KABUFUDA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE PATH "kabufuda include path" FORCE) #set(KABUFUDA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE PATH "kabufuda include path" FORCE)
unset(PLAT_SRCS) unset(PLAT_SRCS)
if(WIN32) if(WIN32)
@ -25,5 +25,6 @@ add_library(kabufuda STATIC
include/kabufuda/SRAM.hpp lib/kabufuda/SRAM.cpp include/kabufuda/SRAM.hpp lib/kabufuda/SRAM.cpp
include/kabufuda/WideStringConvert.hpp lib/kabufuda/WideStringConvert.cpp include/kabufuda/WideStringConvert.hpp lib/kabufuda/WideStringConvert.cpp
${PLAT_SRCS}) ${PLAT_SRCS})
target_include_directories(kabufuda PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
add_subdirectory(test) add_subdirectory(test)

View File

@ -24,7 +24,7 @@ class FileHandle {
public: public:
FileHandle() = default; FileHandle() = default;
uint32_t getFileNo() const { return idx; } uint32_t getFileNo() const { return idx; }
operator bool() const { return getFileNo() != -1; } operator bool() const { return getFileNo() != UINT32_MAX; }
}; };
struct ProbeResults { struct ProbeResults {

View File

@ -119,13 +119,15 @@ static inline int32_t SBig(int32_t val) { return bswap32(val); }
static inline uint32_t SBig(uint32_t val) { return bswap32(val); } static inline uint32_t SBig(uint32_t val) { return bswap32(val); }
static inline int64_t SBig(int64_t val) { return bswap64(val); } static inline int64_t SBig(int64_t val) { return bswap64(val); }
static inline uint64_t SBig(uint64_t val) { return bswap64(val); } static inline uint64_t SBig(uint64_t val) { return bswap64(val); }
static inline float SBig(float val) { inline float SBig(float val) {
int32_t ival = bswap32(*((int32_t*)(&val))); union { float f; int32_t i; } uval1 = {val};
return *((float*)(&ival)); union { int32_t i; float f; } uval2 = {bswap32(uval1.i)};
return uval2.f;
} }
static inline double SBig(double val) { inline double SBig(double val) {
int64_t ival = bswap64(*((int64_t*)(&val))); union { double f; int64_t i; } uval1 = {val};
return *((double*)(&ival)); union { int64_t i; double f; } uval2 = {bswap64(uval1.i)};
return uval2.f;
} }
#ifndef SBIG #ifndef SBIG
#define SBIG(q) (((q)&0x000000FF) << 24 | ((q)&0x0000FF00) << 8 | ((q)&0x00FF0000) >> 8 | ((q)&0xFF000000) >> 24) #define SBIG(q) (((q)&0x000000FF) << 24 | ((q)&0x0000FF00) << 8 | ((q)&0x00FF0000) >> 8 | ((q)&0xFF000000) >> 24)

View File

@ -564,12 +564,12 @@ ECardResult Card::getStatus(uint32_t fileNo, CardStat& statOut) const {
statOut.x36_iconSpeed = file->m_animSpeed; statOut.x36_iconSpeed = file->m_animSpeed;
statOut.x38_commentAddr = file->m_commentAddr; statOut.x38_commentAddr = file->m_commentAddr;
if (file->m_iconAddress == -1) { if (file->m_iconAddress == UINT32_MAX) {
statOut.x3c_offsetBanner = -1; statOut.x3c_offsetBanner = UINT32_MAX;
statOut.x40_offsetBannerTlut = -1; statOut.x40_offsetBannerTlut = UINT32_MAX;
for (int i = 0; i < CARD_ICON_MAX; ++i) for (int i = 0; i < CARD_ICON_MAX; ++i)
statOut.x44_offsetIcon[i] = -1; statOut.x44_offsetIcon[i] = UINT32_MAX;
statOut.x64_offsetIconTlut = -1; statOut.x64_offsetIconTlut = UINT32_MAX;
statOut.x68_offsetData = file->m_commentAddr + 64; statOut.x68_offsetData = file->m_commentAddr + 64;
} else { } else {
uint32_t cur = file->m_iconAddress; uint32_t cur = file->m_iconAddress;
@ -589,7 +589,7 @@ ECardResult Card::getStatus(uint32_t fileNo, CardStat& statOut) const {
statOut.x64_offsetIconTlut = cur; statOut.x64_offsetIconTlut = cur;
cur += TlutSize(EImageFormat::C8); cur += TlutSize(EImageFormat::C8);
} else } else
statOut.x64_offsetIconTlut = -1; statOut.x64_offsetIconTlut = UINT32_MAX;
statOut.x68_offsetData = cur; statOut.x68_offsetData = cur;
} }