diff --git a/.circleci/config.yml b/.circleci/config.yml
index cdffd01d3..434f3dabb 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -28,6 +28,28 @@ jobs:
- run: /opt/devkitpro/portlibs/switch/bin/aarch64-none-elf-cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
- run: cmake --build build -j 2
- store_artifacts: {path: ./build/devilutionx.nro, destination: devilutionx.nro}
+ wii:
+ docker:
+ - image: devkitpro/devkitppc:latest
+ working_directory: ~/repo
+ steps:
+ - checkout
+ - run: apt-get update -y
+ - run: apt-get install -y gettext smpq
+ - run: /opt/devkitpro/portlibs/wii/bin/powerpc-eabi-cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ - run: cmake --build build -j 2
+ - store_artifacts: {path: ./build/devilutionx.dol, destination: devilutionx.dol}
+ wiiu:
+ docker:
+ - image: devkitpro/devkitppc:latest
+ working_directory: ~/repo
+ steps:
+ - checkout
+ - run: apt-get update -y
+ - run: apt-get install -y gettext smpq
+ - run: /opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ - run: cmake --build build -j 2
+ - store_artifacts: {path: ./build/devilutionx.rpx, destination: devilutionx.rpx}
3ds:
docker:
- image: devkitpro/devkitarm:latest
@@ -73,5 +95,7 @@ workflows:
- linux_x86_64
- switch
- 3ds
+ - wii
+ - wiiu
- amigaos-m68k
- vita
diff --git a/CMake/Platforms.cmake b/CMake/Platforms.cmake
index 56e138f1b..ee2de3454 100644
--- a/CMake/Platforms.cmake
+++ b/CMake/Platforms.cmake
@@ -47,6 +47,14 @@ if(NINTENDO_3DS)
include(platforms/n3ds)
endif()
+if(NINTENDO_WII)
+ include(platforms/wii)
+endif()
+
+if(WIIU)
+ include(platforms/wiiu)
+endif()
+
if(VITA)
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)
include(platforms/vita)
diff --git a/CMake/platforms/wii.cmake b/CMake/platforms/wii.cmake
new file mode 100644
index 000000000..dbe006711
--- /dev/null
+++ b/CMake/platforms/wii.cmake
@@ -0,0 +1,48 @@
+#General compilation options
+set(ASAN OFF)
+set(UBSAN OFF)
+set(BUILD_TESTING OFF)
+set(BUILD_ASSETS_MPQ OFF)
+set(DEVILUTIONX_SYSTEM_LIBSODIUM OFF)
+set(DEVILUTIONX_SYSTEM_LIBFMT OFF)
+set(DEVILUTIONX_SYSTEM_SDL_IMAGE OFF)
+set(DEVILUTIONX_STATIC_LIBSODIUM ON)
+set(DEVILUTIONX_STATIC_LIBFMT ON)
+set(DISABLE_ZERO_TIER ON)
+set(LIBMPQ_FILE_BUFFER_SIZE 32768)
+set(PREFILL_PLAYER_NAME ON)
+set(DEVILUTIONX_GAMEPAD_TYPE Nintendo)
+set(NOEXIT ON)
+set(NONET ON)
+set(USE_SDL1 ON)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/threads-stub")
+
+list(APPEND DEVILUTIONX_PLATFORM_COMPILE_DEFINITIONS __WII__)
+
+# The 3ds build handles the stripping in a custom way.
+set(DEVILUTIONX_DISABLE_STRIP ON)
+
+#SDL Joystick axis mapping (circle-pad/C-stick)
+set(JOY_AXIS_LEFTX 0)
+set(JOY_AXIS_LEFTY 1)
+set(JOY_AXIS_RIGHTX 2)
+set(JOY_AXIS_RIGHTY 3)
+#SDL Joystick hat mapping (D-pad)
+set(JOY_HAT_DPAD_UP_HAT 0)
+set(JOY_HAT_DPAD_RIGHT_HAT 0)
+set(JOY_HAT_DPAD_DOWN_HAT 0)
+set(JOY_HAT_DPAD_LEFT_HAT 0)
+set(JOY_HAT_DPAD_UP 1)
+set(JOY_HAT_DPAD_RIGHT 2)
+set(JOY_HAT_DPAD_DOWN 4)
+set(JOY_HAT_DPAD_LEFT 8)
+#SDL Joystick button mapping (A / B and X / Y inverted)
+set(JOY_BUTTON_A 0)
+set(JOY_BUTTON_B 1)
+set(JOY_BUTTON_X 2)
+set(JOY_BUTTON_Y 3)
+set(JOY_BUTTON_LEFTSHOULDER 8)
+set(JOY_BUTTON_RIGHTSHOULDER 7)
+set(JOY_BUTTON_BACK 4)
+set(JOY_BUTTON_START 5)
diff --git a/CMake/platforms/wiiu.cmake b/CMake/platforms/wiiu.cmake
new file mode 100644
index 000000000..2dffcfaed
--- /dev/null
+++ b/CMake/platforms/wiiu.cmake
@@ -0,0 +1,23 @@
+#General compilation options
+set(ASAN OFF)
+set(UBSAN OFF)
+set(BUILD_TESTING OFF)
+set(BUILD_ASSETS_MPQ OFF)
+set(DEVILUTIONX_SYSTEM_LIBSODIUM OFF)
+set(DEVILUTIONX_SYSTEM_LIBFMT OFF)
+set(DEVILUTIONX_SYSTEM_SDL_IMAGE OFF)
+set(DEVILUTIONX_STATIC_LIBSODIUM ON)
+set(DEVILUTIONX_STATIC_LIBFMT ON)
+set(DISABLE_ZERO_TIER ON)
+set(LIBMPQ_FILE_BUFFER_SIZE 32768)
+set(PREFILL_PLAYER_NAME ON)
+set(DEVILUTIONX_GAMEPAD_TYPE Nintendo)
+set(NOEXIT ON)
+set(NONET ON)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/threads-stub")
+
+list(APPEND DEVILUTIONX_PLATFORM_COMPILE_DEFINITIONS __WIIU__)
+
+# The 3ds build handles the stripping in a custom way.
+set(DEVILUTIONX_DISABLE_STRIP ON)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa31c8305..ee6488a11 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -445,6 +445,23 @@ if(PS4)
"DVLX00001" "DevilutionX" "${PROJECT_VERSION}")
endif()
+if(NINTENDO_WII)
+ target_link_libraries(${BIN_TARGET} PUBLIC aesnd wiikeyboard fat)
+ ogc_create_dol(${BIN_TARGET})
+ string(TIMESTAMP WII_DATE "%Y%m%d000000")
+ configure_file(Packaging/wii/meta.xml.in Packaging/wii/meta.xml @ONLY)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/devilutionx.dol
+ RENAME boot.dol
+ DESTINATION devilutionx COMPONENT wii)
+ install(FILES Packaging/wii/icon.png
+ ${CMAKE_CURRENT_BINARY_DIR}/Packaging/wii/meta.xml
+ DESTINATION devilutionx COMPONENT wii)
+endif()
+
+if(WIIU)
+ wut_create_rpx(${BIN_TARGET})
+endif()
+
if(NINTENDO_3DS)
set(APP_TITLE "DevilutionX")
set(APP_DESCRIPTION "DevilutionX port for 3DS")
diff --git a/Packaging/wii/icon.png b/Packaging/wii/icon.png
new file mode 100644
index 000000000..d9b7db443
Binary files /dev/null and b/Packaging/wii/icon.png differ
diff --git a/Packaging/wii/meta.xml.in b/Packaging/wii/meta.xml.in
new file mode 100644
index 000000000..4b045a785
--- /dev/null
+++ b/Packaging/wii/meta.xml.in
@@ -0,0 +1,9 @@
+
+
+ DevilutionX
+ Diasurgical
+ @PLAYER_VERSION_FULL@
+ @WII_DATE@
+ Diablo 1 port
+ DevilutionX is a port of Diablo and Hellfire that strives to make it simple to run the game while providing engine improvements, bugfixes, and some optional quality of life features.
+
diff --git a/Source/storm/storm_net.cpp b/Source/storm/storm_net.cpp
index ba347c6f4..830aa5e15 100644
--- a/Source/storm/storm_net.cpp
+++ b/Source/storm/storm_net.cpp
@@ -20,7 +20,11 @@ namespace devilution {
namespace {
std::unique_ptr dvlnet_inst;
bool GameIsPublic = {};
+#ifdef __WIIU__
+uint32_t dwLastError = 0;
+#else
thread_local uint32_t dwLastError = 0;
+#endif
#ifndef NONET
SdlMutex storm_net_mutex;
diff --git a/Source/utils/sdl2_to_1_2_backports.cpp b/Source/utils/sdl2_to_1_2_backports.cpp
index 7e4879de2..5804afd18 100644
--- a/Source/utils/sdl2_to_1_2_backports.cpp
+++ b/Source/utils/sdl2_to_1_2_backports.cpp
@@ -696,7 +696,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
#else
namespace {
-#if !defined(__QNXNTO__) && !defined(__amigaos__)
+#if !defined(__QNXNTO__) && !defined(__amigaos__) && !defined(__WII__)
char *readSymLink(const char *path)
{
// From sdl2-2.0.9/src/filesystem/unix/SDL_sysfilesystem.c
@@ -780,6 +780,8 @@ char *SDL_GetBasePath()
retval = SDL_strdup("file:sdmc:/3ds/devilutionx/");
#elif defined(__amigaos__)
retval = SDL_strdup("PROGDIR:");
+#elif defined(__WII__)
+ retval = SDL_strdup("");
#else
/* is a Linux-style /proc filesystem available? */