From fe945355aad21bee4b96e8a5e3c18896eb0d79ee Mon Sep 17 00:00:00 2001 From: pionere Date: Wed, 7 Feb 2024 12:48:20 +0100 Subject: [PATCH 01/15] get rid of a pointless copy in SNetCreateGame --- Source/storm/storm_net.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Source/storm/storm_net.cpp b/Source/storm/storm_net.cpp index dbc0e586901..a1928dd1d0e 100644 --- a/Source/storm/storm_net.cpp +++ b/Source/storm/storm_net.cpp @@ -34,15 +34,12 @@ void SNetUnregisterEventHandler(int evtype) bool SNetCreateGame(unsigned port, const char* pszGamePassword, _uigamedata* gameData, char (&errorText)[256]) { bool result; - // assert(gameData != NULL && pszGamePassword != NULL); dvlnet_inst->make_default_gamename(gpszGameName); SStrCopy(gpszGamePassword, pszGamePassword, sizeof(gpszGamePassword)); result = dvlnet_inst->setup_game(gameData, gpszGameName, port, pszGamePassword, errorText); #ifdef ZEROTIER - if (port == 0) - SStrCopy(gpszGameName, gpszGameName, sizeof(gpszGameName)); - else + if (port != 0) #endif snprintf(gpszGameName, sizeof(gpszGameName), "%s:%d", gpszGameName, port); return result; From 19f1439fe4f1f4d98f6cc616c292661e17b151b5 Mon Sep 17 00:00:00 2001 From: pionere Date: Wed, 7 Feb 2024 12:50:05 +0100 Subject: [PATCH 02/15] fix game-name when connecting to an address without port (port == 0) --- Source/storm/storm_net.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/storm/storm_net.cpp b/Source/storm/storm_net.cpp index a1928dd1d0e..57f29bd93e0 100644 --- a/Source/storm/storm_net.cpp +++ b/Source/storm/storm_net.cpp @@ -47,13 +47,13 @@ bool SNetCreateGame(unsigned port, const char* pszGamePassword, _uigamedata* gam bool SNetJoinGame(const char* pszGameName, unsigned port, const char* pszGamePassword, char (&errorText)[256]) { + const char* format = "%s:%d"; // assert(pszGameName != NULL && pszGamePassword != NULL); #ifdef ZEROTIER if (port == 0) - SStrCopy(gpszGameName, gpszGameName, sizeof(gpszGameName)); - else + format = "%s"; #endif - snprintf(gpszGameName, sizeof(gpszGameName), "%s:%d", pszGameName, port); + snprintf(gpszGameName, sizeof(gpszGameName), format, pszGameName, port); SStrCopy(gpszGamePassword, pszGamePassword, sizeof(gpszGamePassword)); return dvlnet_inst->setup_game(NULL, pszGameName, port, pszGamePassword, errorText); } From f427fa86590ae27b5e1aed0d2cb54d94dbb8d1be Mon Sep 17 00:00:00 2001 From: pionere Date: Wed, 7 Feb 2024 12:54:46 +0100 Subject: [PATCH 03/15] fix compilation on big-endian systems --- Source/town.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/town.cpp b/Source/town.cpp index 6d23d5f85fc..f6436c1c574 100644 --- a/Source/town.cpp +++ b/Source/town.cpp @@ -67,7 +67,7 @@ static void LoadTown() uint32_t* pBuf = (uint32_t*)LoadFileInMem(TOWN_PREDUN); int* dp = &dPiece[0][0]; uint32_t* pTmp = pBuf; - for (x = 0; x < MAXDUNX * MAXDUNY; x++, dp++, pTmp++) + for (int x = 0; x < MAXDUNX * MAXDUNY; x++, dp++, pTmp++) *dp = SwapLE32(*pTmp); mem_free_dbg(pBuf); From b9efd6d3ac2464778bc05d27fdc5c0347d4d72c5 Mon Sep 17 00:00:00 2001 From: pionere Date: Wed, 7 Feb 2024 12:56:25 +0100 Subject: [PATCH 04/15] use appropriate type for stream_end when CAN_SEEKP_BEYOND_EOF is not set --- Source/mpqapi.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index f4b8c758258..796eb37b2de 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -579,7 +579,7 @@ static bool mpqapi_write_file_contents(const char* pszName, const BYTE* pbData, goto on_error; #else // Ensure we do not seekp beyond EOF by filling the missing space. - std::streampos stream_end; + long stream_end; if (!cur_archive.stream.seekp(0, SEEK_END) || !cur_archive.stream.tellp(&stream_end)) goto on_error; std::size_t curSize = stream_end - cur_archive.stream_begin; From f34eecc153b0ead6473a9bdf65876e166fc3cbb8 Mon Sep 17 00:00:00 2001 From: pionere Date: Thu, 8 Feb 2024 09:22:23 +0100 Subject: [PATCH 05/15] fix n3ds build --- Source/platform/ctr/asio/net/if.c | 2 ++ Source/platform/ctr/asio/sys/socket.c | 2 ++ Source/platform/ctr/asio/sys/uio.c | 2 ++ Source/platform/ctr/keyboard.cpp | 4 ++-- Source/platform/ctr/messagebox.cpp | 3 ++- Source/platform/ctr/random.cpp | 7 +++++++ Source/platform/ctr/sockets.cpp | 13 ++++++++++++- Source/platform/ctr/system.cpp | 4 ++-- structs.h | 6 ++++++ 9 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Source/platform/ctr/asio/net/if.c b/Source/platform/ctr/asio/net/if.c index 910cb557701..4e72fa6e42f 100644 --- a/Source/platform/ctr/asio/net/if.c +++ b/Source/platform/ctr/asio/net/if.c @@ -1,3 +1,4 @@ +#ifdef TCPIP #include #include #include @@ -20,3 +21,4 @@ struct if_nameindex *if_nameindex() void if_freenameindex(struct if_nameindex *__ptr) { } +#endif \ No newline at end of file diff --git a/Source/platform/ctr/asio/sys/socket.c b/Source/platform/ctr/asio/sys/socket.c index 30710ec6646..c1dfaa492ef 100644 --- a/Source/platform/ctr/asio/sys/socket.c +++ b/Source/platform/ctr/asio/sys/socket.c @@ -1,3 +1,4 @@ +#ifdef TCPIP #include #include #include @@ -106,3 +107,4 @@ int socketpair(int domain, int type, int protocol, int socket_vector[2]) { return ENOTSUP; } +#endif \ No newline at end of file diff --git a/Source/platform/ctr/asio/sys/uio.c b/Source/platform/ctr/asio/sys/uio.c index 4d6b74a1728..352b862928f 100644 --- a/Source/platform/ctr/asio/sys/uio.c +++ b/Source/platform/ctr/asio/sys/uio.c @@ -1,3 +1,4 @@ +#ifdef TCPIP #include #include #include @@ -11,3 +12,4 @@ ssize_t writev(int __fd, const struct iovec *__iovec, int __count) { return ENOTSUP; } +#endif \ No newline at end of file diff --git a/Source/platform/ctr/keyboard.cpp b/Source/platform/ctr/keyboard.cpp index 4b56b18df49..96882947c6d 100644 --- a/Source/platform/ctr/keyboard.cpp +++ b/Source/platform/ctr/keyboard.cpp @@ -13,7 +13,7 @@ struct vkbdEvent { }; static vkbdEvent events[16]; -static int eventCount = 0; +static unsigned eventCount = 0; void ctr_vkbdInput(const char *hintText, const char *inText, char *outText, int maxLength) { @@ -30,7 +30,7 @@ void ctr_vkbdInput(const char *hintText, const char *inText, char *outText, int void ctr_vkbdFlush() { - for (int i = 0; i < eventCount; i++) { + for (unsigned i = 0; i < eventCount; i++) { vkbdEvent &event = events[i]; SwkbdState swkbd; diff --git a/Source/platform/ctr/messagebox.cpp b/Source/platform/ctr/messagebox.cpp index cee9d1b2e05..bfca1bd5620 100644 --- a/Source/platform/ctr/messagebox.cpp +++ b/Source/platform/ctr/messagebox.cpp @@ -1,6 +1,7 @@ #include <3ds.h> #include #include "utils/sdl2_to_1_2_backports.h" +#include "utils/log.h" int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, @@ -13,7 +14,7 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, bool init = !gspHasGpuRight(); char text[1024]; - snprintf(text, sizeof(text), "%s\n\n%s", title, message) + snprintf(text, sizeof(text), "%s\n\n%s", title, message); if (init) gfxInitDefault(); diff --git a/Source/platform/ctr/random.cpp b/Source/platform/ctr/random.cpp index c18b4944114..aa566ee4be2 100644 --- a/Source/platform/ctr/random.cpp +++ b/Source/platform/ctr/random.cpp @@ -1,3 +1,5 @@ +#include "random.hpp" +#ifndef NONET #include #include #include <3ds.h> @@ -46,3 +48,8 @@ void randombytes_ctrrandom_init() { randombytes_set_implementation(&randombytes_ctrrandom_implementation); } +#else +void randombytes_ctrrandom_init() +{ +} +#endif // !NONET \ No newline at end of file diff --git a/Source/platform/ctr/sockets.cpp b/Source/platform/ctr/sockets.cpp index a3157540344..bc4909fc453 100644 --- a/Source/platform/ctr/sockets.cpp +++ b/Source/platform/ctr/sockets.cpp @@ -1,5 +1,9 @@ +#include "sockets.hpp" +#ifndef NONET #include +#include #include <3ds.h> +#include "utils/log.h" constexpr auto SOC_ALIGN = 0x1000; constexpr auto SOC_BUFFERSIZE = 0x100000; @@ -59,4 +63,11 @@ void n3ds_socInit() atexit([]() { n3ds_socExit(); }); initialized = true; } - +#else +void n3ds_socExit() +{ +} +void n3ds_socInit() +{ +} +#endif // !NONET \ No newline at end of file diff --git a/Source/platform/ctr/system.cpp b/Source/platform/ctr/system.cpp index 815acb36e63..15ca6d97c39 100644 --- a/Source/platform/ctr/system.cpp +++ b/Source/platform/ctr/system.cpp @@ -1,7 +1,7 @@ #include <3ds.h> #include #include -#include "platform/ctr/cfgu_service.hpp +#include "platform/ctr/cfgu_service.hpp" #include "platform/ctr/random.hpp" #include "platform/ctr/sockets.hpp" #include "platform/ctr/system.h" @@ -78,7 +78,7 @@ bool ctr_is_n3ds() bool ctr_should_disable_backlight() { - n3ds::CFGUService cfguService; + dvl::n3ds::CFGUService cfguService; if (!cfguService.IsInitialized()) return false; diff --git a/structs.h b/structs.h index e078f5c79f2..6e678ba43c8 100644 --- a/structs.h +++ b/structs.h @@ -962,6 +962,9 @@ typedef struct LE_UINT32 { void operator=(unsigned val) { _value = SwapLE32(val); }; + void operator=(unsigned long val) { + _value = SwapLE32(val); + }; #if INT_MAX != INT32_MAX void operator=(uint32_t val) { _value = SwapLE32(val); @@ -988,6 +991,9 @@ typedef struct LE_INT32 { void operator=(int val) { _value = SwapLE32(val); }; + void operator=(long val) { + _value = SwapLE32(val); + }; #if INT_MAX != INT32_MAX void operator=(int32_t val) { _value = SwapLE32(val); From 6db9c7914e5859c3c1cc69d4a921fdd5a9c6bad4 Mon Sep 17 00:00:00 2001 From: Daniel Thamdrup Date: Tue, 6 Feb 2024 13:44:58 +0100 Subject: [PATCH 06/15] build 3ds in the nightly job Signed-off-by: Daniel Thamdrup --- .github/workflows/nightly.yml | 77 ++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 20449b10be8..db7acfbf32a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -764,10 +764,10 @@ jobs: artifact: 'hellfire-nightly-vita.vpk' - name: diablo-vita cmakeargs: '-DNONET=ON -D USE_PATCH=ON' - artifact: 'diablo-nightly-vita.vpk' + artifact: 'diablo-nightly-vitap.vpk' - name: hellfire-vita cmakeargs: '-DNONET=ON -D USE_PATCH=ON -DHELLFIRE=ON' - artifact: 'hellfire-nightly-vita.vpk' + artifact: 'hellfire-nightly-vitap.vpk' runs-on: ubuntu-22.04 container: vitasdk/vitasdk:latest steps: @@ -794,6 +794,79 @@ jobs: name: ${{ matrix.artifact }} path: ./build/devilutionx.vpk + # 3ds-builds + build_n3ds: + needs: build_check + if: ${{ needs.build_check.outputs.should_run != 'false' }} + name: Nightly-Nintendo 3DS + strategy: + fail-fast: false + matrix: + #name: [diablo, hellfire] + include: + - name: diablo + cmakeargs: '-DNONET=ON' + artifact: 'diablo-nightly-3ds.3dsx' + cia: 'diablo-nightly-3ds.cia' + - name: hellfire + cmakeargs: '-DNONET=ON -DHELLFIRE=ON' + artifact: 'hellfire-nightly-3ds.3dsx' + cia: 'hellfire-nightly-3ds.cia' + - name: diablo-3ds + cmakeargs: '-DNONET=ON -D USE_PATCH=ON' + artifact: 'diablo-nightly-3dsp.3dsx' + cia: 'diablo-nightly-3dsp.cia' + - name: hellfire-3ds + cmakeargs: '-DNONET=ON -D USE_PATCH=ON -DHELLFIRE=ON' + artifact: 'hellfire-nightly-3dsp.3dsx' + cia: 'hellfire-nightly-3dsp.cia' + runs-on: ubuntu-22.04 + container: devkitpro/devkitarm:latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install dependencies + run: | + apt-get update && \ + apt-get install -y --no-install-recommends --no-install-suggests \ + ffmpeg \ + gettext + + - name: Get external dependencies + run: | + wget https://github.com/diasurgical/bannertool/releases/download/1.2.0/bannertool.zip + unzip -j "bannertool.zip" "linux-x86_64/bannertool" -d "/opt/devkitpro/tools/bin" + wget https://github.com/3DSGuy/Project_CTR/releases/download/makerom-v0.18/makerom-v0.18-ubuntu_x86_64.zip + unzip "makerom-v0.18-ubuntu_x86_64.zip" "makerom" -d "/opt/devkitpro/tools/bin" + chmod a+x /opt/devkitpro/tools/bin/makerom + + - name: Configure CMake + run: | + cmake -S. -Bbuild -GNinja \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNINTENDO_3DS=ON \ + -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake + + - name: Build DevilutionX + run: cmake --build build -j$(nproc) + + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: | + ./build/devilutionx.3dsx + + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.cia }} + path: | + ./build/devilutionx.cia + # Releases release: needs: [build_check, build_msvc, build_mingw, build_mingw_x64, build_mac, build_ios, build_android, build_rg350, build_lepus, build_retrofw, build_ps4] From fe3261ae7703d47e676acf39a8adcad4c0e8829b Mon Sep 17 00:00:00 2001 From: pionere Date: Thu, 8 Feb 2024 09:38:36 +0100 Subject: [PATCH 07/15] fix amiga build --- Source/storm/storm.cpp | 5 ++- structs.h | 75 ++++++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 36 deletions(-) diff --git a/Source/storm/storm.cpp b/Source/storm/storm.cpp index 8b042a003be..b8d25391711 100644 --- a/Source/storm/storm.cpp +++ b/Source/storm/storm.cpp @@ -88,9 +88,12 @@ HANDLE SFileOpenFile(const char* filename) void SStrCopy(char* dest, const char* src, int max_length) { +#ifndef __AMIGA__ if (memccpy(dest, src, '\0', max_length) == NULL) dest[max_length - 1] = '\0'; - //strncpy(dest, src, max_length); +#else + strncpy(dest, src, max_length); +#endif } void SFileEnableDirectAccess(bool enable) diff --git a/structs.h b/structs.h index 6e678ba43c8..f03ef5285b8 100644 --- a/structs.h +++ b/structs.h @@ -3,11 +3,16 @@ * * Various global structures. */ +#ifndef _STRUCTS_H +#define _STRUCTS_H DEVILUTION_BEGIN_NAMESPACE -#ifndef _STRUCTS_H -#define _STRUCTS_H +#ifndef __AMIGA__ +#define static_warning(x, msg) static_assert(x, msg) +#else +#define static_warning(x, msg) +#endif #if INT_MAX == INT32_MAX && INTPTR_MAX == INT32_MAX #define X86_32bit_COMP @@ -136,7 +141,7 @@ typedef struct UniqItemData { } UniqItemData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(UniqItemData) & (sizeof(UniqItemData) - 1)) == 64, "Align UniqItemData to power of 2 for better performance."); +static_warning((sizeof(UniqItemData) & (sizeof(UniqItemData) - 1)) == 64, "Align UniqItemData to power of 2 for better performance."); #endif typedef struct ItemFileData { @@ -148,7 +153,7 @@ typedef struct ItemFileData { } ItemFileData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(ItemFileData) & (sizeof(ItemFileData) - 1)) == 0, "Align ItemFileData to power of 2 for better performance."); +static_warning((sizeof(ItemFileData) & (sizeof(ItemFileData) - 1)) == 0, "Align ItemFileData to power of 2 for better performance."); #endif typedef struct ItemData { @@ -178,7 +183,7 @@ typedef struct ItemData { } ItemData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(ItemData) & (sizeof(ItemData) - 1)) == 0, "Align ItemData to power of 2 for better performance."); +static_warning((sizeof(ItemData) & (sizeof(ItemData) - 1)) == 0, "Align ItemData to power of 2 for better performance."); #endif typedef struct ItemStruct { @@ -266,7 +271,7 @@ typedef struct ItemStruct { } ItemStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(ItemStruct) & (sizeof(ItemStruct) - 1)) == 0, "Align ItemStruct closer to power of 2 for better performance."); +static_warning((sizeof(ItemStruct) & (sizeof(ItemStruct) - 1)) == 0, "Align ItemStruct closer to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -279,7 +284,7 @@ typedef struct PlrAnimType { } PlrAnimType; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(PlrAnimType) & (sizeof(PlrAnimType) - 1)) == 0, "Align PlrAnimType closer to power of 2 for better performance."); +static_warning((sizeof(PlrAnimType) & (sizeof(PlrAnimType) - 1)) == 0, "Align PlrAnimType closer to power of 2 for better performance."); #endif typedef struct PlrAnimStruct { @@ -288,9 +293,9 @@ typedef struct PlrAnimStruct { int paAnimWidth; } PlrAnimStruct; #ifdef X86_32bit_COMP -static_assert((sizeof(PlrAnimStruct) & (sizeof(PlrAnimStruct) - 1)) == 32, "Align PlrAnimStruct closer to power of 2 for better performance."); +static_warning((sizeof(PlrAnimStruct) & (sizeof(PlrAnimStruct) - 1)) == 32, "Align PlrAnimStruct closer to power of 2 for better performance."); #elif defined(X86_64bit_COMP) -static_assert((sizeof(PlrAnimStruct) & (sizeof(PlrAnimStruct) - 1)) == 64, "Align PlrAnimStruct closer to power of 2 for better performance."); +static_warning((sizeof(PlrAnimStruct) & (sizeof(PlrAnimStruct) - 1)) == 64, "Align PlrAnimStruct closer to power of 2 for better performance."); #endif typedef struct PlayerStruct { @@ -445,7 +450,7 @@ typedef struct PlayerStruct { } PlayerStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(PlayerStruct) & (sizeof(PlayerStruct) - 1)) == 0, "Align PlayerStruct closer to power of 2 for better performance."); +static_warning((sizeof(PlayerStruct) & (sizeof(PlayerStruct) - 1)) == 0, "Align PlayerStruct closer to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -479,7 +484,7 @@ typedef struct MissileData { } MissileData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(MissileData) & (sizeof(MissileData) - 1)) == 0, "Align MissileData to power of 2 for better performance."); +static_warning((sizeof(MissileData) & (sizeof(MissileData) - 1)) == 0, "Align MissileData to power of 2 for better performance."); #endif typedef struct MisFileData { @@ -494,7 +499,7 @@ typedef struct MisFileData { ALIGNMENT(2, 14) } MisFileData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(MisFileData) & (sizeof(MisFileData) - 1)) == 0, "Align MisFileData to power of 2 for better performance."); +static_warning((sizeof(MisFileData) & (sizeof(MisFileData) - 1)) == 0, "Align MisFileData to power of 2 for better performance."); #endif typedef struct MissileStruct { @@ -547,9 +552,9 @@ typedef struct MissileStruct { } MissileStruct; #ifdef X86_32bit_COMP -static_assert((sizeof(MissileStruct) & (sizeof(MissileStruct) - 1)) == 128, "Align MissileStruct closer to power of 2 for better performance."); +static_warning((sizeof(MissileStruct) & (sizeof(MissileStruct) - 1)) == 128, "Align MissileStruct closer to power of 2 for better performance."); #elif defined(X86_64bit_COMP) -static_assert((sizeof(MissileStruct) & (sizeof(MissileStruct) - 1)) == 0, "Align MissileStruct closer to power of 2 for better performance."); +static_warning((sizeof(MissileStruct) & (sizeof(MissileStruct) - 1)) == 0, "Align MissileStruct closer to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -588,9 +593,9 @@ typedef struct MonAnimStruct { int maFrameLen; } MonAnimStruct; #ifdef X86_32bit_COMP -static_assert((sizeof(MonAnimStruct) & (sizeof(MonAnimStruct) - 1)) == 32, "Align MonAnimStruct closer to power of 2 for better performance."); +static_warning((sizeof(MonAnimStruct) & (sizeof(MonAnimStruct) - 1)) == 32, "Align MonAnimStruct closer to power of 2 for better performance."); #elif defined(X86_64bit_COMP) -static_assert((sizeof(MonAnimStruct) & (sizeof(MonAnimStruct) - 1)) == 64, "Align MonAnimStruct closer to power of 2 for better performance."); +static_warning((sizeof(MonAnimStruct) & (sizeof(MonAnimStruct) - 1)) == 64, "Align MonAnimStruct closer to power of 2 for better performance."); #endif typedef struct MonsterAI { @@ -626,7 +631,7 @@ typedef struct MonsterData { ALIGNMENT(5, 2) } MonsterData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(MonsterData) & (sizeof(MonsterData) - 1)) == 0, "Align MonsterData to power of 2 for better performance."); +static_warning((sizeof(MonsterData) & (sizeof(MonsterData) - 1)) == 0, "Align MonsterData to power of 2 for better performance."); #endif typedef struct MonFileData { @@ -641,9 +646,9 @@ typedef struct MonFileData { BYTE moAFNum2; } MonFileData; #ifdef X86_32bit_COMP -static_assert((sizeof(MonFileData) & (sizeof(MonFileData) - 1)) == 0, "Align MonFileData to power of 2 for better performance."); +static_warning((sizeof(MonFileData) & (sizeof(MonFileData) - 1)) == 0, "Align MonFileData to power of 2 for better performance."); #elif defined(X86_64bit_COMP) -static_assert((sizeof(MonFileData) & (sizeof(MonFileData) - 1)) == 64, "Align MonFileData to power of 2 for better performance."); +static_warning((sizeof(MonFileData) & (sizeof(MonFileData) - 1)) == 64, "Align MonFileData to power of 2 for better performance."); #endif #pragma pack(push, 1) typedef struct MapMonData { @@ -679,9 +684,9 @@ typedef struct MapMonData { ALIGNMENT(24, 17); } MapMonData; #ifdef X86_32bit_COMP -static_assert((sizeof(MapMonData) & (sizeof(MapMonData) - 1)) == 0, "Align MapMonData closer to power of 2 for better performance."); +static_warning((sizeof(MapMonData) & (sizeof(MapMonData) - 1)) == 0, "Align MapMonData closer to power of 2 for better performance."); #elif defined(X86_64bit_COMP) -static_assert((sizeof(MapMonData) & (sizeof(MapMonData) - 1)) == 512, "Align MapMonData closer to power of 2 for better performance."); +static_warning((sizeof(MapMonData) & (sizeof(MapMonData) - 1)) == 512, "Align MapMonData closer to power of 2 for better performance."); #endif #pragma pack(pop) typedef struct MonsterStruct { @@ -763,7 +768,7 @@ typedef struct MonsterStruct { } MonsterStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(MonsterStruct) & (sizeof(MonsterStruct) - 1)) == 0, "Align MonsterStruct to power of 2 for better performance."); +static_warning((sizeof(MonsterStruct) & (sizeof(MonsterStruct) - 1)) == 0, "Align MonsterStruct to power of 2 for better performance."); #endif typedef struct MonEnemyStruct { @@ -798,7 +803,7 @@ typedef struct UniqMonData { } UniqMonData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(UniqMonData) & (sizeof(UniqMonData) - 1)) == 0, "Align UniqMonData to power of 2 for better performance."); +static_warning((sizeof(UniqMonData) & (sizeof(UniqMonData) - 1)) == 0, "Align UniqMonData to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -833,7 +838,7 @@ typedef struct ObjectData { } ObjectData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(ObjectData) & (sizeof(ObjectData) - 1)) == 0, "Align ObjectData closer to power of 2 for better performance."); +static_warning((sizeof(ObjectData) & (sizeof(ObjectData) - 1)) == 0, "Align ObjectData closer to power of 2 for better performance."); #endif typedef struct ObjFileData { @@ -850,7 +855,7 @@ typedef struct ObjFileData { } ObjFileData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(ObjFileData) & (sizeof(ObjFileData) - 1)) == 0, "Align ObjFileData closer to power of 2 for better performance."); +static_warning((sizeof(ObjFileData) & (sizeof(ObjFileData) - 1)) == 0, "Align ObjFileData closer to power of 2 for better performance."); #endif typedef struct ObjectStruct { @@ -892,7 +897,7 @@ typedef struct ObjectStruct { } ObjectStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(ObjectStruct) & (sizeof(ObjectStruct) - 1)) == 0, "Align ObjectStruct to power of 2 for better performance."); +static_warning((sizeof(ObjectStruct) & (sizeof(ObjectStruct) - 1)) == 0, "Align ObjectStruct to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -907,7 +912,7 @@ typedef struct PortalStruct { } PortalStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(PortalStruct) & (sizeof(PortalStruct) - 1)) == 0, "Align PortalStruct closer to power of 2 for better performance."); +static_warning((sizeof(PortalStruct) & (sizeof(PortalStruct) - 1)) == 0, "Align PortalStruct closer to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -2118,9 +2123,9 @@ typedef struct LevelData { } LevelData; #ifdef X86_32bit_COMP -static_assert((sizeof(LevelData) & (sizeof(LevelData) - 1)) == 0, "Align LevelData to power of 2 for better performance."); +static_warning((sizeof(LevelData) & (sizeof(LevelData) - 1)) == 0, "Align LevelData to power of 2 for better performance."); #elif defined(X86_64bit_COMP) -static_assert((sizeof(LevelData) & (sizeof(LevelData) - 1)) == 64, "Align LevelData to power of 2 for better performance."); +static_warning((sizeof(LevelData) & (sizeof(LevelData) - 1)) == 64, "Align LevelData to power of 2 for better performance."); #endif typedef struct WarpStruct { @@ -2155,7 +2160,7 @@ typedef struct QuestStruct { } QuestStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(QuestStruct) & (sizeof(QuestStruct) - 1)) == 0, "Align QuestStruct to power of 2 for better performance."); +static_warning((sizeof(QuestStruct) & (sizeof(QuestStruct) - 1)) == 0, "Align QuestStruct to power of 2 for better performance."); #endif typedef struct QuestData { @@ -2210,7 +2215,7 @@ typedef struct SpellData { ALIGNMENT64(6) } SpellData; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(SpellData) & (sizeof(SpellData) - 1)) == 0, "Align SpellData to power of 2 for better performance."); +static_warning((sizeof(SpellData) & (sizeof(SpellData) - 1)) == 0, "Align SpellData to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -2327,7 +2332,7 @@ typedef struct ThemeStruct { } ThemeStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(ThemeStruct) & (sizeof(ThemeStruct) - 1)) == 0, "Align ThemeStruct to power of 2 for better performance."); +static_warning((sizeof(ThemeStruct) & (sizeof(ThemeStruct) - 1)) == 0, "Align ThemeStruct to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -2361,7 +2366,7 @@ typedef struct LightListStruct { } LightListStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(LightListStruct) & (sizeof(LightListStruct) - 1)) == 0, "Align LightListStruct closer to power of 2 for better performance."); +static_warning((sizeof(LightListStruct) & (sizeof(LightListStruct) - 1)) == 0, "Align LightListStruct closer to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -2492,7 +2497,7 @@ typedef struct PATHNODE { } PATHNODE; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(PATHNODE) & (sizeof(PATHNODE) - 1)) == 0, "Align PATHNODE closer to power of 2 for better performance."); +static_warning((sizeof(PATHNODE) & (sizeof(PATHNODE) - 1)) == 0, "Align PATHNODE closer to power of 2 for better performance."); #endif ////////////////////////////////////////////////// @@ -2582,7 +2587,7 @@ typedef struct STextStruct { } STextStruct; #if defined(X86_32bit_COMP) || defined(X86_64bit_COMP) -static_assert((sizeof(STextStruct) & (sizeof(STextStruct) - 1)) == 0, "Align STextStruct closer to power of 2 for better performance."); +static_warning((sizeof(STextStruct) & (sizeof(STextStruct) - 1)) == 0, "Align STextStruct closer to power of 2 for better performance."); #endif ////////////////////////////////////////////////// From fb31f4278e4b37f427265e23287d5e0b754a501f Mon Sep 17 00:00:00 2001 From: Daniel Thamdrup Date: Tue, 6 Feb 2024 15:28:17 +0100 Subject: [PATCH 08/15] build amigam68k in the nightly job Signed-off-by: Daniel Thamdrup --- .github/workflows/nightly.yml | 63 ++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index db7acfbf32a..88693dd717b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -768,7 +768,7 @@ jobs: - name: hellfire-vita cmakeargs: '-DNONET=ON -D USE_PATCH=ON -DHELLFIRE=ON' artifact: 'hellfire-nightly-vitap.vpk' - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest container: vitasdk/vitasdk:latest steps: - name: Checkout @@ -792,9 +792,9 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} - path: ./build/devilutionx.vpk + path: build/devilutionx.vpk - # 3ds-builds + # n3ds-builds build_n3ds: needs: build_check if: ${{ needs.build_check.outputs.should_run != 'false' }} @@ -820,7 +820,7 @@ jobs: cmakeargs: '-DNONET=ON -D USE_PATCH=ON -DHELLFIRE=ON' artifact: 'hellfire-nightly-3dsp.3dsx' cia: 'hellfire-nightly-3dsp.cia' - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest container: devkitpro/devkitarm:latest steps: @@ -857,15 +857,62 @@ jobs: uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} - path: | - ./build/devilutionx.3dsx + path: build/devilutionx.3dsx - name: Upload uses: actions/upload-artifact@v4 with: name: ${{ matrix.cia }} - path: | - ./build/devilutionx.cia + path: build/devilutionx.cia + + # amiga-builds + build_amiga: + needs: build_check + if: ${{ needs.build_check.outputs.should_run != 'false' }} + name: Nightly-Amiga M68K + strategy: + fail-fast: false + matrix: + #name: [diablo, hellfire] + include: + - name: diablo + cmakeargs: '-DNONET=ON' + artifact: 'diablo-nightly-amiga' + - name: hellfire + cmakeargs: '-DNONET=ON -DHELLFIRE=ON' + artifact: 'hellfire-nightly-amiga' + - name: diablo-amiga + cmakeargs: '-DNONET=ON -D USE_PATCH=ON' + artifact: 'diablo-nightly-amigap' + - name: hellfire-amiga + cmakeargs: '-DNONET=ON -D USE_PATCH=ON -DHELLFIRE=ON' + artifact: 'hellfire-nightly-amigap' + runs-on: ubuntu-latest + container: amigadev/crosstools:m68k-amigaos-gcc10 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run prep.sh script + run: Packaging/amiga/prep.sh + + - name: Configure CMake + run: | + cmake -S. -Bbuild -GNinja \ + -DM68K_COMMON="-s -ffast-math -O3" \ + -DM68K_CPU=68040 \ + -DM68K_FPU=hard + + - name: Build DevilutionX + run: cmake --build build + + - name: Upload Package + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: ./build/devilutionx # Releases release: From 6de929c46b1484b284e04ffcb44ffef53cb3f3ed Mon Sep 17 00:00:00 2001 From: pionere Date: Thu, 8 Feb 2024 10:22:33 +0100 Subject: [PATCH 09/15] fix switch build --- Source/platform/switch/asio/net/if.c | 2 ++ Source/platform/switch/asio/pause.c | 4 +++- Source/platform/switch/asio/sys/signal.c | 2 ++ Source/platform/switch/docking.cpp | 2 ++ Source/platform/switch/docking.h | 2 ++ Source/platform/switch/network.cpp | 11 +++++++++++ Source/platform/switch/random.cpp | 8 ++++++++ 7 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Source/platform/switch/asio/net/if.c b/Source/platform/switch/asio/net/if.c index 910cb557701..4e72fa6e42f 100644 --- a/Source/platform/switch/asio/net/if.c +++ b/Source/platform/switch/asio/net/if.c @@ -1,3 +1,4 @@ +#ifdef TCPIP #include #include #include @@ -20,3 +21,4 @@ struct if_nameindex *if_nameindex() void if_freenameindex(struct if_nameindex *__ptr) { } +#endif \ No newline at end of file diff --git a/Source/platform/switch/asio/pause.c b/Source/platform/switch/asio/pause.c index 2911968375a..d663ee7c09c 100644 --- a/Source/platform/switch/asio/pause.c +++ b/Source/platform/switch/asio/pause.c @@ -1,7 +1,9 @@ +#ifdef TCPIP #include int pause(void) { errno = ENOSYS; return -1; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/Source/platform/switch/asio/sys/signal.c b/Source/platform/switch/asio/sys/signal.c index 4b9c394d48d..b5c3c99a7b0 100644 --- a/Source/platform/switch/asio/sys/signal.c +++ b/Source/platform/switch/asio/sys/signal.c @@ -1,3 +1,4 @@ +#ifdef TCPIP #include #include @@ -5,3 +6,4 @@ int pthread_sigmask(int, const sigset_t *, sigset_t *) { return ENOTSUP; } +#endif \ No newline at end of file diff --git a/Source/platform/switch/docking.cpp b/Source/platform/switch/docking.cpp index d70639c0cfb..ec70f41d613 100644 --- a/Source/platform/switch/docking.cpp +++ b/Source/platform/switch/docking.cpp @@ -3,6 +3,8 @@ #include #include +#include "utils/display.h" + DEVILUTION_BEGIN_NAMESPACE static int currently_docked = -1; // keep track of docked or handheld mode diff --git a/Source/platform/switch/docking.h b/Source/platform/switch/docking.h index 67348111ef1..235071f44e8 100644 --- a/Source/platform/switch/docking.h +++ b/Source/platform/switch/docking.h @@ -1,5 +1,7 @@ #pragma once +#include "../defs.h" + DEVILUTION_BEGIN_NAMESPACE void HandleDocking(); diff --git a/Source/platform/switch/network.cpp b/Source/platform/switch/network.cpp index 4526f1a619b..195d5797bc4 100644 --- a/Source/platform/switch/network.cpp +++ b/Source/platform/switch/network.cpp @@ -1,3 +1,6 @@ +#include "platform/switch/network.h" + +#ifndef NONET #include #include #include @@ -21,3 +24,11 @@ void switch_disable_network() close(nxlink_sock); socketExit(); } +#else +void switch_enable_network() +{ +} +void switch_disable_network() +{ +} +#endif \ No newline at end of file diff --git a/Source/platform/switch/random.cpp b/Source/platform/switch/random.cpp index 6c16d228cd8..651f788eec6 100644 --- a/Source/platform/switch/random.cpp +++ b/Source/platform/switch/random.cpp @@ -1,3 +1,6 @@ +#include "random.hpp" + +#ifndef NONET #include #include @@ -52,3 +55,8 @@ void randombytes_switchrandom_init() randombytes_set_implementation(&randombytes_switchrandom_implementation); atexit(csrngExit); } +#else +void randombytes_switchrandom_init() +{ +} +#endif // !NONET \ No newline at end of file From bda109953983458f3fd0ba326f2c03732d03e68b Mon Sep 17 00:00:00 2001 From: Daniel Thamdrup Date: Mon, 5 Feb 2024 21:28:10 +0100 Subject: [PATCH 10/15] build switch in the nightly job Signed-off-by: Daniel Thamdrup --- .github/workflows/nightly.yml | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 88693dd717b..a6813f15cc0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -865,6 +865,60 @@ jobs: name: ${{ matrix.cia }} path: build/devilutionx.cia + # switch-builds + build_switch: + needs: build_check + if: ${{ needs.build_check.outputs.should_run != 'false' }} + name: Nightly-Nintendo Switch + strategy: + fail-fast: false + matrix: + #name: [diablo, hellfire] + include: + - name: diablo + cmakeargs: '-DNONET=ON' + artifact: 'diablo-nightly-switch.nro' + - name: hellfire + cmakeargs: '-DNONET=ON -DHELLFIRE=ON' + artifact: 'hellfire-nightly-switch.nro' + - name: diablo-switch + cmakeargs: '-DNONET=ON -D USE_PATCH=ON' + artifact: 'diablo-nightly-switchp.nro' + - name: hellfire-switch + cmakeargs: '-DNONET=ON -D USE_PATCH=ON -DHELLFIRE=ON' + artifact: 'hellfire-nightly-switchp.nro' + runs-on: ubuntu-latest + container: devkitpro/devkita64:latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # - name: Create Build Environment + # run: brew bundle install + - name: Install dependencies + shell: bash + run: | + apt-get update && \ + apt-get install -y --no-install-recommends --no-install-suggests \ + gettext + + - name: Configure CMake + run: | + cmake -S . -B build \ + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -D CMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake + + - name: Build DevilutionX + run: cmake --build build -j$(nproc) + + - name: Upload Package + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: ./build/devilutionx.nro + # amiga-builds build_amiga: needs: build_check @@ -901,6 +955,7 @@ jobs: - name: Configure CMake run: | cmake -S. -Bbuild -GNinja \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ -DM68K_COMMON="-s -ffast-math -O3" \ -DM68K_CPU=68040 \ -DM68K_FPU=hard From 554892a5f0a5c863194bba683e796105ef010729 Mon Sep 17 00:00:00 2001 From: pionere Date: Fri, 9 Feb 2024 08:00:13 +0100 Subject: [PATCH 11/15] fix the new nightly builds --- .github/workflows/nightly.yml | 66 +++++++++++++++++------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index a6813f15cc0..875603e01b3 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -847,7 +847,7 @@ jobs: - name: Configure CMake run: | cmake -S. -Bbuild -GNinja \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DNINTENDO_3DS=ON \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmakeargs }} -DNINTENDO_3DS=ON \ -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake - name: Build DevilutionX @@ -887,37 +887,37 @@ jobs: - name: hellfire-switch cmakeargs: '-DNONET=ON -D USE_PATCH=ON -DHELLFIRE=ON' artifact: 'hellfire-nightly-switchp.nro' - runs-on: ubuntu-latest - container: devkitpro/devkita64:latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # - name: Create Build Environment - # run: brew bundle install - - name: Install dependencies - shell: bash - run: | - apt-get update && \ - apt-get install -y --no-install-recommends --no-install-suggests \ - gettext - - - name: Configure CMake - run: | - cmake -S . -B build \ - -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -D CMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake - - - name: Build DevilutionX - run: cmake --build build -j$(nproc) - - - name: Upload Package - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.artifact }} - path: ./build/devilutionx.nro + runs-on: ubuntu-latest + container: devkitpro/devkita64:latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # - name: Create Build Environment + # run: brew bundle install + - name: Install dependencies + shell: bash + run: | + apt-get update && \ + apt-get install -y --no-install-recommends --no-install-suggests \ + gettext + + - name: Configure CMake + run: | + cmake -S . -B build \ + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmakeargs }} \ + -D CMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake + + - name: Build DevilutionX + run: cmake --build build -j$(nproc) + + - name: Upload Package + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact }} + path: ./build/devilutionx.nro # amiga-builds build_amiga: @@ -955,7 +955,7 @@ jobs: - name: Configure CMake run: | cmake -S. -Bbuild -GNinja \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{ matrix.cmakeargs }} \ -DM68K_COMMON="-s -ffast-math -O3" \ -DM68K_CPU=68040 \ -DM68K_FPU=hard From 0d04cae2d07a67fca7589dcfb8dbc6494cf1dfdf Mon Sep 17 00:00:00 2001 From: pionere Date: Sat, 10 Feb 2024 08:30:33 +0100 Subject: [PATCH 12/15] apply fixes to the patcher --- tools/patcher/mpqapi.cpp | 2 +- tools/patcher/platform/ctr/keyboard.cpp | 4 ++-- tools/patcher/platform/ctr/messagebox.cpp | 3 ++- tools/patcher/platform/ctr/system.cpp | 4 ++-- tools/patcher/platform/switch/docking.cpp | 2 ++ tools/patcher/platform/switch/docking.h | 2 ++ tools/patcher/storm/storm.cpp | 5 ++++- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/patcher/mpqapi.cpp b/tools/patcher/mpqapi.cpp index f4b8c758258..796eb37b2de 100644 --- a/tools/patcher/mpqapi.cpp +++ b/tools/patcher/mpqapi.cpp @@ -579,7 +579,7 @@ static bool mpqapi_write_file_contents(const char* pszName, const BYTE* pbData, goto on_error; #else // Ensure we do not seekp beyond EOF by filling the missing space. - std::streampos stream_end; + long stream_end; if (!cur_archive.stream.seekp(0, SEEK_END) || !cur_archive.stream.tellp(&stream_end)) goto on_error; std::size_t curSize = stream_end - cur_archive.stream_begin; diff --git a/tools/patcher/platform/ctr/keyboard.cpp b/tools/patcher/platform/ctr/keyboard.cpp index 4b56b18df49..96882947c6d 100644 --- a/tools/patcher/platform/ctr/keyboard.cpp +++ b/tools/patcher/platform/ctr/keyboard.cpp @@ -13,7 +13,7 @@ struct vkbdEvent { }; static vkbdEvent events[16]; -static int eventCount = 0; +static unsigned eventCount = 0; void ctr_vkbdInput(const char *hintText, const char *inText, char *outText, int maxLength) { @@ -30,7 +30,7 @@ void ctr_vkbdInput(const char *hintText, const char *inText, char *outText, int void ctr_vkbdFlush() { - for (int i = 0; i < eventCount; i++) { + for (unsigned i = 0; i < eventCount; i++) { vkbdEvent &event = events[i]; SwkbdState swkbd; diff --git a/tools/patcher/platform/ctr/messagebox.cpp b/tools/patcher/platform/ctr/messagebox.cpp index cee9d1b2e05..bfca1bd5620 100644 --- a/tools/patcher/platform/ctr/messagebox.cpp +++ b/tools/patcher/platform/ctr/messagebox.cpp @@ -1,6 +1,7 @@ #include <3ds.h> #include #include "utils/sdl2_to_1_2_backports.h" +#include "utils/log.h" int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, @@ -13,7 +14,7 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, bool init = !gspHasGpuRight(); char text[1024]; - snprintf(text, sizeof(text), "%s\n\n%s", title, message) + snprintf(text, sizeof(text), "%s\n\n%s", title, message); if (init) gfxInitDefault(); diff --git a/tools/patcher/platform/ctr/system.cpp b/tools/patcher/platform/ctr/system.cpp index 8ed89cb85f4..2e661509ede 100644 --- a/tools/patcher/platform/ctr/system.cpp +++ b/tools/patcher/platform/ctr/system.cpp @@ -1,7 +1,7 @@ #include <3ds.h> #include #include -#include "platform/ctr/cfgu_service.hpp +#include "platform/ctr/cfgu_service.hpp" #include "platform/ctr/system.h" bool shouldDisableBacklight; @@ -76,7 +76,7 @@ bool ctr_is_n3ds() bool ctr_should_disable_backlight() { - n3ds::CFGUService cfguService; + dvl::n3ds::CFGUService cfguService; if (!cfguService.IsInitialized()) return false; diff --git a/tools/patcher/platform/switch/docking.cpp b/tools/patcher/platform/switch/docking.cpp index d70639c0cfb..ec70f41d613 100644 --- a/tools/patcher/platform/switch/docking.cpp +++ b/tools/patcher/platform/switch/docking.cpp @@ -3,6 +3,8 @@ #include #include +#include "utils/display.h" + DEVILUTION_BEGIN_NAMESPACE static int currently_docked = -1; // keep track of docked or handheld mode diff --git a/tools/patcher/platform/switch/docking.h b/tools/patcher/platform/switch/docking.h index 67348111ef1..235071f44e8 100644 --- a/tools/patcher/platform/switch/docking.h +++ b/tools/patcher/platform/switch/docking.h @@ -1,5 +1,7 @@ #pragma once +#include "../defs.h" + DEVILUTION_BEGIN_NAMESPACE void HandleDocking(); diff --git a/tools/patcher/storm/storm.cpp b/tools/patcher/storm/storm.cpp index 17722b6b048..051fa25902a 100644 --- a/tools/patcher/storm/storm.cpp +++ b/tools/patcher/storm/storm.cpp @@ -83,9 +83,12 @@ HANDLE SFileOpenFile(const char* filename) void SStrCopy(char* dest, const char* src, int max_length) { +#ifndef __AMIGA__ if (memccpy(dest, src, '\0', max_length) == NULL) dest[max_length - 1] = '\0'; - //strncpy(dest, src, max_length); +#else + strncpy(dest, src, max_length); +#endif } void SFileEnableDirectAccess(bool enable) From 39f5e181b1f59686b701075ace9349507f68dc2e Mon Sep 17 00:00:00 2001 From: pionere Date: Sat, 10 Feb 2024 08:34:41 +0100 Subject: [PATCH 13/15] fix amiga/prep.sh --- Packaging/amiga/prep.sh | 110 ++++++++++++---------------------------- 1 file changed, 32 insertions(+), 78 deletions(-) diff --git a/Packaging/amiga/prep.sh b/Packaging/amiga/prep.sh index 50b1c7a010b..548c2e75cce 100755 --- a/Packaging/amiga/prep.sh +++ b/Packaging/amiga/prep.sh @@ -1,78 +1,32 @@ -#!/usr/bin/env bash - -# exit when any command fails -set -euo pipefail - -#set compiler params -export TARGET='m68k-amigaos' -export SYSROOT=/opt/$TARGET -export M68K_CPU=68040 -export M68K_FPU=hard -export M68K_CPU_FPU="-m${M68K_CPU} -m${M68K_FPU}-float" -export M68K_COMMON="-s -ffast-math -fomit-frame-pointer" -export M68K_CFLAGS="${M68K_CPU_FPU} ${M68K_COMMON}" -export M68K_CXXFLAGS="${M68K_CPU_FPU} ${M68K_COMMON}" - -PARALLELISM="$(getconf _NPROCESSORS_ONLN)" - -declare -ra CMAKE_FLAGS=( - -DM68K_CPU="$M68K_CPU" - -DM68K_FPU="$M68K_FPU" - -DM68K_COMMON="$M68K_COMMON" - -DBUILD_SHARED_LIBS=OFF - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX="${SYSROOT}/usr" -) - -mkdir -p deps -mkdir -p ${SYSROOT}/usr/lib -mkdir -p ${SYSROOT}/usr/include -cd deps - -# ZLIB -wget https://www.zlib.net/zlib-1.2.11.tar.gz -O zlib-1.2.11.tar.gz -tar -xvf zlib-1.2.11.tar.gz -mkdir -p zlib-1.2.11/build -cd zlib-1.2.11 -cmake -S. -Bbuild "${CMAKE_FLAGS[@]}" -O3 -fno-exceptions -w -noixemul -DBIG_ENDIAN -DAMIGA -fpermissive -std=c++14" -cmake --build build -j"$PARALLELISM" --config Release --target install -cd .. - -# SDL1.2 -wget https://github.com/AmigaPorts/libSDL12/archive/master.tar.gz -O SDL-1.2.tar.gz -tar -xvf SDL-1.2.tar.gz -cd libSDL12-master -make PREFX=${SYSROOT} PREF=${SYSROOT} -j"$PARALLELISM" -mkdir -p ${SYSROOT}/usr/lib -mkdir -p ${SYSROOT}/usr/include -cp -fvr libSDL.a ${SYSROOT}/usr/lib/ -cp -fvr include/* ${SYSROOT}/usr/include/ -cd .. - -# SDL_mixer -#wget https://github.com/SDL-mirror/SDL_mixer/archive/SDL-1.2.tar.gz -O SDL_mixer-SDL-1.2.tar.gz -#tar -xvf SDL_mixer-SDL-1.2.tar.gz -#cd SDL_mixer-SDL-1.2 -#./autogen.sh -#SDL_LIBS='-lSDL -ldebug' SDL_CFLAGS="-I${SYSROOT}/usr/include/SDL -noixemul" CFLAGS="${M68K_CFLAGS}" CXXFLAGS="${M68K_CXXFLAGS}" ./configure --disable-sdltest --disable-shared --enable-static --host=${TARGET} --prefix="${SYSROOT}/usr" -#make -j$(getconf _NPROCESSORS_ONLN) -#make install -#cd .. - -# FreeType -#wget https://download.savannah.gnu.org/releases/freetype/freetype-2.10.1.tar.gz -O freetype-2.10.1.tar.gz -#tar -xvf freetype-2.10.1.tar.gz -#mkdir -p freetype-2.10.1/build -#cd freetype-2.10.1 -#cmake -S. -Bbuild -DUNIX=1 -DM68K_CPU="$M68K_CPU" -DM68K_FPU="$M68K_FPU" -DM68K_COMMON="${M68K_COMMON}" -#cmake --build build -j"$PARALLELISM" --config Release --target install -#cd .. - -# SDL_ttf -#wget https://github.com/SDL-mirror/SDL_ttf/archive/SDL-1.2.tar.gz -O SDL_ttf-SDL-1.2.tar.gz -#tar -xvf SDL_ttf-SDL-1.2.tar.gz -#cd SDL_ttf-SDL-1.2 -#./autogen.sh -#LDFLAGS="-L${SYSROOT}/usr/lib" SDL_LIBS='-lSDL -ldebug' SDL_CFLAGS="-L${SYSROOT}/usr/lib -I${SYSROOT}/usr/include/SDL -noixemul" CFLAGS="${M68K_CFLAGS}" CXXFLAGS="${M68K_CXXFLAGS}" FT2_CFLAGS="-L${SYSROOT}/usr/lib -I${SYSROOT}/usr/include/freetype2" FT2_LIBS="-lfreetype -lzlib" ./configure --disable-shared --enable-static --host=${TARGET} --prefix=${SYSROOT}/usr -#make -j$(getconf _NPROCESSORS_ONLN) -#make install +#!/usr/bin/env bash + +# exit when any command fails +set -euo pipefail + +#set compiler params +export TARGET='m68k-amigaos' +export SYSROOT=/opt/$TARGET +export M68K_CPU=68040 +export M68K_FPU=hard +export M68K_CPU_FPU="-m${M68K_CPU} -m${M68K_FPU}-float" +export M68K_COMMON="-s -ffast-math -fomit-frame-pointer" +export M68K_CFLAGS="${M68K_CPU_FPU} ${M68K_COMMON}" +export M68K_CXXFLAGS="${M68K_CPU_FPU} ${M68K_COMMON}" + +PARALLELISM="$(getconf _NPROCESSORS_ONLN)" + +mkdir -p deps +mkdir -p ${SYSROOT}/usr/lib +mkdir -p ${SYSROOT}/usr/include +cd deps + +# SDL1.2 +wget https://github.com/AmigaPorts/libSDL12/archive/master.tar.gz -O SDL-1.2.tar.gz +tar -xvf SDL-1.2.tar.gz +cd libSDL12-master +make PREFX=${SYSROOT} PREF=${SYSROOT} -j"$PARALLELISM" +mkdir -p ${SYSROOT}/usr/lib +mkdir -p ${SYSROOT}/usr/include +cp -fvr libSDL.a ${SYSROOT}/usr/lib/ +cp -fvr include/* ${SYSROOT}/usr/include/ +cd .. From 7523cf86d830d8a887d1598e2d97723fd19d89a6 Mon Sep 17 00:00:00 2001 From: pionere Date: Sat, 10 Feb 2024 11:46:53 +0100 Subject: [PATCH 14/15] fix patcher on 3DS + dont use source files from the game in the patcher --- CMakeLists.txt | 13 ++++++++----- tools/patcher/DiabloUI/diabloui.cpp | 2 ++ tools/patcher/platform/ctr/system.cpp | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f94c02aa9..33d9c6fdd5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -688,15 +688,15 @@ if(USE_PATCH AND NOT ANDROID) if(NINTENDO_SWITCH) list(APPEND devil_patcher_SRCS - Source/platform/switch/docking.cpp - Source/platform/switch/romfs.cpp) + tools/patcher/platform/switch/docking.cpp + tools/patcher/platform/switch/romfs.cpp) endif() if(NINTENDO_3DS) list(APPEND devil_patcher_SRCS - Source/platform/ctr/system.cpp - Source/platform/ctr/display.cpp - Source/platform/ctr/messagebox.cpp) + tools/patcher/platform/ctr/system.cpp + tools/patcher/platform/ctr/display.cpp + tools/patcher/platform/ctr/messagebox.cpp) endif() set(PATCHER_SOURCES ${devil_patcher_SRCS}) @@ -1023,6 +1023,9 @@ if(NINTENDO_3DS) #target_include_directories(${BIN_TARGET} PRIVATE ${TREMOR_INCLUDE_DIRS}) #target_link_libraries(${BIN_TARGET} PRIVATE 3ds::ogg 3ds::mikmod 3ds::mad 3ds::freetype 3ds::bzip2 3ds::png) target_link_libraries(${BIN_TARGET} PRIVATE 3ds::citro3d 3ds::ctrulib) + if(DEVIL_PATCHER) + target_link_libraries(${DEVIL_PATCHER} PRIVATE 3ds::citro3d 3ds::ctrulib) + endif() endif() if(GPERF) diff --git a/tools/patcher/DiabloUI/diabloui.cpp b/tools/patcher/DiabloUI/diabloui.cpp index febce856ba2..493058508a5 100644 --- a/tools/patcher/DiabloUI/diabloui.cpp +++ b/tools/patcher/DiabloUI/diabloui.cpp @@ -462,11 +462,13 @@ void UiRenderAndPoll() #if HAS_GAMECTRL || HAS_JOYSTICK || HAS_KBCTRL || HAS_DPAD HandleMenuMove(); #endif +#if FULL_UI #ifdef __3DS__ // Keyboard blocks until input is finished // so defer until after render and fade-in ctr_vkbdFlush(); #endif +#endif // FULL_UI } static void Render(const UiText* uiArtText) diff --git a/tools/patcher/platform/ctr/system.cpp b/tools/patcher/platform/ctr/system.cpp index 2e661509ede..876a8199e92 100644 --- a/tools/patcher/platform/ctr/system.cpp +++ b/tools/patcher/platform/ctr/system.cpp @@ -109,8 +109,8 @@ void ctr_sys_init() acInit(); atexit([]() { acExit(); }); - n3ds_socInit(); - atexit([]() { n3ds_socExit(); }); + // n3ds_socInit(); + // atexit([]() { n3ds_socExit(); }); // randombytes_ctrrandom_init(); atexit([]() { From 8a65a8d96733b7d831cc9e34926ea74ee16ecc8b Mon Sep 17 00:00:00 2001 From: pionere Date: Sat, 10 Feb 2024 11:48:04 +0100 Subject: [PATCH 15/15] make ctr/keyboard.h/cpp more conform --- Source/platform/ctr/keyboard.cpp | 5 +++-- Source/platform/ctr/keyboard.h | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/platform/ctr/keyboard.cpp b/Source/platform/ctr/keyboard.cpp index 96882947c6d..b41aab96ef4 100644 --- a/Source/platform/ctr/keyboard.cpp +++ b/Source/platform/ctr/keyboard.cpp @@ -1,7 +1,8 @@ +#include "platform/ctr/keyboard.h" + #include #include - -#include "platform/ctr/keyboard.h" +#include <3ds.h> constexpr size_t MAX_TEXT_LENGTH = 255; diff --git a/Source/platform/ctr/keyboard.h b/Source/platform/ctr/keyboard.h index 1fde63234a7..81fbe56dfa7 100644 --- a/Source/platform/ctr/keyboard.h +++ b/Source/platform/ctr/keyboard.h @@ -1,6 +1,4 @@ #pragma once -#include <3ds.h> - void ctr_vkbdInput(const char *title, const char *inText, char *outText, int maxLength); void ctr_vkbdFlush();