diff --git a/CMakeLists.txt b/CMakeLists.txt index 3796a9da2e..0fbfab1814 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,8 @@ set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 20) if (CMAKE_SYSTEM_NAME STREQUAL Linux) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter -fPIC") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-register -fPIC") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas -Wno-unused-variable -Wno-unused-parameter -fPIC -Wno-error -Wno-c++11-narrowing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -stdlib=libc++ -Wno-register -fPIC -Wno-error -Wno-c++11-narrowing") set(CMAKE_PREFIX_PATH /usr) set(CMAKE_LIBRARY_ARCHITECTURE x86_64-linux-gnu) set(CMAKE_LIBRARY_PATH "/usr/lib64" "/usr/lib/x86_64-linux-gnu" CACHE PATH "") @@ -1337,8 +1337,9 @@ set(REL_FILES ) set(DUSK_FILES - src/dusk/imgui.cpp - src/dusk/stubs.c + #src/dusk/imgui.cpp + #src/dusk/stubs.c + src/dusk/extras.c ) source_group("dolzel" FILES ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${SSYSTEM_FILES} ${JSYSTEM_FILES} ${REL_FILES}) @@ -1348,7 +1349,7 @@ add_library(game SHARED ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${SSYSTEM_FILES} ${J target_compile_definitions(game PRIVATE TARGET_PC VERSION=0 NDEBUG=1 NDEBUG_DEFINED=1 DEBUG_DEFINED=0) # TODO: version handling for res includes set(DUSK_TP_VERSION GZ2E01) -target_include_directories(game PRIVATE include src assets/${DUSK_TP_VERSION} ${CMAKE_BINARY_DIR}/../${DUSK_TP_VERSION}/include src/PowerPC_EABI_Support/MSL/MSL_C++/MSL_Common/Include src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common_Embedded/Math/Include) +target_include_directories(game PRIVATE include src assets/${DUSK_TP_VERSION} ${CMAKE_BINARY_DIR}/../${DUSK_TP_VERSION}/include) target_link_libraries(game PRIVATE aurora::core aurora::gx aurora::si aurora::vi aurora::pad) add_executable(dusk src/dusk/main.cpp) diff --git a/include/JSystem/JStudio/JStudio/jstudio-math.h b/include/JSystem/JStudio/JStudio/jstudio-math.h index 27df37a634..92b7ef0415 100644 --- a/include/JSystem/JStudio/JStudio/jstudio-math.h +++ b/include/JSystem/JStudio/JStudio/jstudio-math.h @@ -5,6 +5,9 @@ #include #define m_PI_D 3.141592653589793 +#ifndef __MWERKS__ +#include "dusk/math.h" +#endif namespace JStudio { namespace math { diff --git a/include/d/dolzel.h b/include/d/dolzel.h index 4d0d322a03..d51eb22372 100644 --- a/include/d/dolzel.h +++ b/include/d/dolzel.h @@ -7,4 +7,8 @@ #include "d/dolzel.pch" #endif +#ifndef __MWERKS__ +#include "dusk/math.h" +#endif + #endif // dolzel.h diff --git a/include/dusk/extras.h b/include/dusk/extras.h new file mode 100644 index 0000000000..242cd0478c --- /dev/null +++ b/include/dusk/extras.h @@ -0,0 +1,15 @@ +#ifndef _SRC_EXTRAS_H_ +#define _SRC_EXTRAS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int strnicmp(const char* str1, const char* str2, int n); +int stricmp(const char* str1, const char* str2); + +#ifdef __cplusplus +} +#endif + +#endif // _SRC_EXTRAS_H_ diff --git a/include/dusk/math.h b/include/dusk/math.h new file mode 100644 index 0000000000..578ff80398 --- /dev/null +++ b/include/dusk/math.h @@ -0,0 +1,17 @@ +#ifndef _SRC_DUSK_MATH_H_ +#define _SRC_DUSK_MATH_H_ + +#include + +#define M_PI 3.14159265358979323846f +#define M_SQRT3 1.73205f + +#define DEG_TO_RAD(degrees) (degrees * (M_PI / 180.0f)) +#define RAD_TO_DEG(radians) (radians * (180.0f / M_PI)) + +inline float i_sinf(float x) { return sin(x); } +inline float i_cosf(float x) { return cos(x); } +inline float i_tanf(float x) { return tan(x); } +inline float i_acosf(float x) { return acos(x); } + +#endif // _SRC_DUSK_MATH_H_ diff --git a/src/JSystem/J2DGraph/J2DPane.cpp b/src/JSystem/J2DGraph/J2DPane.cpp index ccaa67aaa4..11cb5b1230 100644 --- a/src/JSystem/J2DGraph/J2DPane.cpp +++ b/src/JSystem/J2DGraph/J2DPane.cpp @@ -6,6 +6,9 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/JSupport/JSURandomInputStream.h" #include "JSystem/JUtility/JUTResource.h" +#ifndef __MWERKS__ +#include "dusk/math.h" +#endif J2DPane::J2DPane() : mBounds(), mGlobalBounds(), mClipRect(), mPaneTree(this) { mTransform = NULL; diff --git a/src/JSystem/J2DGraph/J2DTevs.cpp b/src/JSystem/J2DGraph/J2DTevs.cpp index 88d1c1c69b..de02858ce1 100644 --- a/src/JSystem/J2DGraph/J2DTevs.cpp +++ b/src/JSystem/J2DGraph/J2DTevs.cpp @@ -6,7 +6,11 @@ #include "JSystem/J2DGraph/J2DTevs.h" #include "JSystem/J2DGraph/J2DMaterial.h" +#ifdef __MWERKS__ #include +#else +#include "dusk/math.h" +#endif #include "dolphin/gx.h" void J2DTexMtx::load(u32 mtxIdx) { diff --git a/src/JSystem/JAudio2/JASReport.cpp b/src/JSystem/JAudio2/JASReport.cpp index be97131868..7afbe68684 100644 --- a/src/JSystem/JAudio2/JASReport.cpp +++ b/src/JSystem/JAudio2/JASReport.cpp @@ -9,6 +9,9 @@ #include "JSystem/JAudio2/JASMutex.h" #include "JSystem/JKernel/JKRHeap.h" #include +#ifndef __MWERKS__ +#include +#endif static OSMutex sMutex; diff --git a/src/JSystem/JKernel/JKRAssertHeap.cpp b/src/JSystem/JKernel/JKRAssertHeap.cpp index 635922d6d8..34e936405e 100644 --- a/src/JSystem/JKernel/JKRAssertHeap.cpp +++ b/src/JSystem/JKernel/JKRAssertHeap.cpp @@ -1,6 +1,9 @@ #include "JSystem/JSystem.h" // IWYU pragma: keep #include "JSystem/JKernel/JKRAssertHeap.h" +#ifndef __MWERKS__ +#include +#endif JKRAssertHeap::JKRAssertHeap(void* data, u32 size, JKRHeap* parent, bool errorFlag) : JKRHeap(data, size, parent, errorFlag) {} diff --git a/src/JSystem/JUtility/JUTDbPrint.cpp b/src/JSystem/JUtility/JUTDbPrint.cpp index 9adab8141b..469db1ad3a 100644 --- a/src/JSystem/JUtility/JUTDbPrint.cpp +++ b/src/JSystem/JUtility/JUTDbPrint.cpp @@ -5,6 +5,9 @@ #include "JSystem/JKernel/JKRHeap.h" #include "JSystem/JUtility/JUTVideo.h" #include +#ifndef __MWERKS__ +#include +#endif JUTDbPrint::JUTDbPrint(JUTFont* pFont, JKRHeap* pHeap) { mFont = pFont; diff --git a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath index 3040fbfe62..a9e6715c74 100644 --- a/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath +++ b/src/PowerPC_EABI_Support/MSL/MSL_C/MSL_Common/Include/cmath @@ -2,6 +2,7 @@ #define MSL_CMATH_H_ #include +//#include #define NAN (*(float*) __float_nan) #define HUGE_VALF (*(float*) __float_huge) diff --git a/src/d/actor/d_a_mirror.cpp b/src/d/actor/d_a_mirror.cpp index a15d2fd2ce..8ad5a997e8 100644 --- a/src/d/actor/d_a_mirror.cpp +++ b/src/d/actor/d_a_mirror.cpp @@ -14,6 +14,10 @@ #include "dolphin/gf/GFLight.h" #include "m_Do/m_Do_lib.h" +#ifndef __MWERKS__ +#include "dusk/math.h" +#endif + static BOOL daMirror_c_createHeap(fopAc_ac_c* i_this) { return ((daMirror_c*)i_this)->createHeap(); } diff --git a/src/d/actor/d_a_obj_lv4chandelier.cpp b/src/d/actor/d_a_obj_lv4chandelier.cpp index 07b2b90775..918cd4da77 100644 --- a/src/d/actor/d_a_obj_lv4chandelier.cpp +++ b/src/d/actor/d_a_obj_lv4chandelier.cpp @@ -12,6 +12,10 @@ #include "d/d_cc_d.h" #include "d/d_cc_uty.h" +#ifndef __MWERKS__ +#include "dusk/math.h" +#endif + #if DEBUG class daObjLv4Chan_HIO_c : public mDoHIO_entry_c { public: diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index b0597577b6..f5ddeef3bc 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -25,6 +25,10 @@ #include "d/actor/d_a_player.h" #include "SSystem/SComponent/c_math.h" +#ifndef __MWERKS__ +#include "dusk/math.h" +#endif + #if DEBUG //#pragma nosyminline on #endif diff --git a/src/d/d_resorce.cpp b/src/d/d_resorce.cpp index f47814388a..b3ed40f77f 100644 --- a/src/d/d_resorce.cpp +++ b/src/d/d_resorce.cpp @@ -16,6 +16,11 @@ #include "m_Do/m_Do_graphic.h" #include +#ifndef __MWERKS__ +#include +#include "dusk/extras.h" +#endif + dRes_info_c::dRes_info_c() { mCount = 0; mDMCommand = NULL; diff --git a/src/d/d_s_room.cpp b/src/d/d_s_room.cpp index 836a9a1a18..ec5e740203 100644 --- a/src/d/d_s_room.cpp +++ b/src/d/d_s_room.cpp @@ -11,6 +11,9 @@ #include "d/d_s_room.h" #include "m_Do/m_Do_Reset.h" #include +#ifndef __MWERKS__ +#include "dusk/extras.h" +#endif static int dScnRoom_Draw(room_of_scene_class* i_this) { return 1; diff --git a/src/dusk/extras.c b/src/dusk/extras.c new file mode 100644 index 0000000000..1dcb6ae49f --- /dev/null +++ b/src/dusk/extras.c @@ -0,0 +1,45 @@ +#include "dusk/extras.h" +#include + +int stricmp(const char* str1, const char* str2) { + char a_var; + char b_var; + + do { + b_var = tolower(*str1++); + a_var = tolower(*str2++); + + if (b_var < a_var) { + return -1; + } + if (b_var > a_var) { + return 1; + } + } while (b_var != 0); + + return 0; +} + +int strnicmp(const char* str1, const char* str2, int n) { + int i; + char c1, c2; + + for (i = 0; i < n; i++) { + c1 = tolower(*str1++); + c2 = tolower(*str2++); + + if (c1 < c2) { + return -1; + } + + if (c1 > c2) { + return 1; + } + + if (c1 == '\0') { + return 0; + } + } + + return 0; +}