Skip to content

Commit

Permalink
Merge pull request #3167 from carstene1ns/feature/wiiu
Browse files Browse the repository at this point in the history
Initial WiiU support
  • Loading branch information
Ghabry authored Dec 20, 2023
2 parents ec039e6 + 3bbe8c6 commit dc933f5
Show file tree
Hide file tree
Showing 15 changed files with 202 additions and 25 deletions.
37 changes: 30 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ if(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL2")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/builds/android/app/src/gamebrowser)
set(PLAYER_BUILD_EXECUTABLE OFF)
endif()

if(NINTENDO_WIIU)
target_compile_definitions(${PROJECT_NAME} PUBLIC PLAYER_NINTENDO)
target_sources(${PROJECT_NAME} PRIVATE
src/platform/wiiu/input_buttons.cpp)
endif()
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "SDL1")
target_sources(${PROJECT_NAME} PRIVATE
src/platform/sdl/sdl_audio.cpp
Expand Down Expand Up @@ -686,11 +692,12 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "amigaos4")
src/platform/sdl/axis.h
src/platform/sdl/sdl_ui.cpp
src/platform/sdl/sdl_ui.h)
else()
message(FATAL_ERROR "Invalid target platform")
endif()

# Shared by homebrew platforms
if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|psvita|switch|wii)$")
if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|psvita|switch|wii)$" OR NINTENDO_WIIU)
target_compile_options(${PROJECT_NAME} PUBLIC -fno-exceptions -fno-rtti)
set(CMAKE_DL_LIBS "") # hack4icu!
set(PLAYER_ENABLE_TESTS OFF)
Expand Down Expand Up @@ -834,7 +841,9 @@ find_package(Pixman REQUIRED)
target_link_libraries(${PROJECT_NAME} PIXMAN::PIXMAN)

# Always enable Wine registry support on non-Windows, but not for console ports
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows" AND NOT ${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$")
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"
AND NOT ${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$"
AND NOT NINTENDO_WIIU)
target_compile_definitions(${PROJECT_NAME} PUBLIC HAVE_WINE=1)
endif()

Expand Down Expand Up @@ -1067,7 +1076,7 @@ if(${PLAYER_AUDIO_BACKEND} MATCHES "^(SDL2|SDL1|libretro|psvita|3ds|switch|wii|a
endif()

# Executable
if(${PLAYER_BUILD_EXECUTABLE} AND (${PLAYER_TARGET_PLATFORM} STREQUAL "SDL2" OR ${PLAYER_TARGET_PLATFORM} STREQUAL "SDL1"))
if(${PLAYER_BUILD_EXECUTABLE} AND ${PLAYER_TARGET_PLATFORM} MATCHES "^SDL(1|2)$" AND NOT NINTENDO_WIIU)
if(APPLE)
set(EXE_NAME "EasyRPG-Player.app")
set_source_files_properties(${${PROJECT_NAME}_BUNDLE_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
Expand Down Expand Up @@ -1157,7 +1166,8 @@ if(${PLAYER_BUILD_EXECUTABLE} AND (${PLAYER_TARGET_PLATFORM} STREQUAL "SDL2" OR
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLAYER_JS_OUTPUT_NAME}.wasm DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
elseif(${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$")
elseif(${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$" OR NINTENDO_WIIU)
set(CPACK_PLATFORM "${PLAYER_TARGET_PLATFORM}")
if(NINTENDO_3DS)
add_executable(easyrpg-player src/platform/3ds/main.cpp)
target_link_libraries(easyrpg-player
Expand Down Expand Up @@ -1209,6 +1219,19 @@ elseif(${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$")
install(FILES resources/wii/icon.png
${CMAKE_CURRENT_BINARY_DIR}/resources/wii/meta.xml
DESTINATION easyrpg-player COMPONENT wii)
elseif(NINTENDO_WIIU)
add_executable(easyrpg-player src/platform/sdl/main.cpp)
target_link_libraries(easyrpg-player ${PROJECT_NAME})
wut_create_rpx(easyrpg-player)
wut_create_wuhb(easyrpg-player
NAME "EasyRPG Player ${PLAYER_VERSION_FULL}"
SHORT_NAME "Player"
AUTHOR "EasyRPG Team"
) # todo icon, splashs)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/easyrpg-player.rpx
${CMAKE_CURRENT_BINARY_DIR}/easyrpg-player.wuhb
DESTINATION . COMPONENT wiiu)
set(CPACK_PLATFORM "wiiu")
elseif(VITA)
set(CMAKE_EXECUTABLE_SUFFIX .elf)
add_executable(easyrpg-player src/platform/psvita/main.cpp)
Expand Down Expand Up @@ -1243,7 +1266,7 @@ elseif(${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$")
endif()
install(TARGETS easyrpg-player RUNTIME DESTINATION . COMPONENT debug)
# debug information
if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|switch|wii)$")
if(${PLAYER_TARGET_PLATFORM} MATCHES "^(3ds|switch|wii)$" OR NINTENDO_WIIU)
dkp_target_generate_symbol_list(easyrpg-player)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/easyrpg-player.map
${CMAKE_CURRENT_BINARY_DIR}/easyrpg-player.lst
Expand All @@ -1257,7 +1280,7 @@ elseif(${PLAYER_TARGET_PLATFORM} MATCHES "^(psvita|3ds|switch|wii)$")
if(PLAYER_VERSIONED_PACKAGES)
string(APPEND CPACK_PACKAGE_FILE_NAME "-${PLAYER_VERSION}")
endif()
set(CPACK_ARCHIVE_DEBUG_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${PLAYER_TARGET_PLATFORM}-debug")
set(CPACK_ARCHIVE_DEBUG_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PLATFORM}-debug")
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF) # we do this manually
include(CPack)
elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "amigaos4")
Expand All @@ -1266,7 +1289,7 @@ elseif(${PLAYER_TARGET_PLATFORM} STREQUAL "amigaos4")
${PROJECT_NAME}
${SDL_LIBRARIES})
# FIXME: packaging?
else()
else() # library
if(${PLAYER_TARGET_PLATFORM} STREQUAL "libretro")
add_library(easyrpg_libretro
src/platform/libretro/audio.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/audio_midi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AudioDecoderMidi;

#include "audio_decoder_base.h"

#if defined(GEKKO) || defined(__3DS__)
#if defined(__wii__) || defined(__3DS__)
# define EP_MIDI_FREQ 22050
#else
# define EP_MIDI_FREQ 44100
Expand Down
12 changes: 11 additions & 1 deletion src/decoder_wildmidi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool WildMidiDecoder::Initialize(std::string& error_message) {
found = FileFinder::Root().Exists(config_file);
}
}
#elif defined(GEKKO)
#elif defined(__wii__)
// preferred under /data
config_file = "usb:/data/wildmidi/wildmidi.cfg";
found = FileFinder::Root().Exists(config_file);
Expand Down Expand Up @@ -140,6 +140,16 @@ bool WildMidiDecoder::Initialize(std::string& error_message) {
config_file = "timidity.cfg";
found = FileFinder::Root().Exists(config_file);
}
#elif defined(__WIIU__)
// preferred SD card directory
config_file = "/vol/external01/data/easyrpg-player/wildmidi.cfg";
found = FileFinder::Root().Exists(config_file);

// Current directory
if (!found) {
config_file = "wildmidi.cfg";
found = FileFinder::Root().Exists(config_file);
}
#elif defined(__3DS__)
// Only wildmidi paths, no timidity because there was never timidity used on 3DS

Expand Down
2 changes: 1 addition & 1 deletion src/decoder_xmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ bool XMPDecoder::Open(Filesystem_Stream::InputStream stream) {

int player_interpolation = 0;
int player_effects = 0;
#if defined(PSP) || defined(__3DS__) || defined(GEKKO)
#if defined(PSP) || defined(__3DS__) || defined(__wii__)
// disable filtering and use low quality interpolation
player_interpolation = XMP_INTERP_NEAREST;
#else
Expand Down
5 changes: 4 additions & 1 deletion src/filefinder_rtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ FileFinder_RTP::FileFinder_RTP(bool no_rtp, bool no_rtp_warnings, std::string rt
std::string const version_str = Player::GetEngineVersion();
assert(!version_str.empty());

#ifdef GEKKO
#ifdef __wii__
AddPath("sd:/data/rtp/" + version_str);
AddPath("usb:/data/rtp/" + version_str);
#elif defined(__WIIU__)
AddPath("./rtp/" + version_str);
AddPath("/data/easyrpg-player/rtp/" + version_str);
#elif defined(__SWITCH__)
AddPath("./rtp/" + version_str);
AddPath("/switch/easyrpg-player/rtp/" + version_str);
Expand Down
6 changes: 4 additions & 2 deletions src/game_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ FilesystemView Game_Config::GetGlobalConfigFilesystem() {
std::string path;

if (config_path.empty()) {
#ifdef GEKKO
path = "sd:/data/easyrpg-player";
#ifdef __wii__
path = "/data/easyrpg-player";
#elif defined(__WIIU__)
path = "/vol/external01/data/easyrpg-player"; // temp
#elif defined(__SWITCH__)
path = "/switch/easyrpg-player";
#elif defined(__3DS__)
Expand Down
2 changes: 1 addition & 1 deletion src/input_buttons_desktop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

// FIXME: Move in platform/generic (?) and handle with CMake
#if !(defined(OPENDINGUX) || defined(GEKKO) || defined(USE_LIBRETRO) || defined(__vita__) || defined(__3DS__) || defined(__SWITCH__))
#if !(defined(OPENDINGUX) || defined(PLAYER_NINTENDO) || defined(PLAYER_UI))

// Headers
#include "input_buttons.h"
Expand Down
2 changes: 1 addition & 1 deletion src/platform/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#if defined(__3DS__)
#include "platform/3ds/clock.h"
using Platform_Clock = CtrClock;
#elif defined(GEKKO)
#elif defined(__wii__)
#include "platform/wii/clock.h"
using Platform_Clock = WiiClock;
#elif defined(__SWITCH__)
Expand Down
27 changes: 27 additions & 0 deletions src/platform/sdl/sdl2_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
# include <SDL_system.h>
#elif defined(EMSCRIPTEN)
# include <emscripten.h>
#elif defined(__WIIU__)
# include <whb/proc.h>
# include <coreinit/debug.h>
#endif
#include "icon.h"

Expand Down Expand Up @@ -137,6 +140,9 @@ Sdl2Ui::Sdl2Ui(long width, long height, const Game_Config& cfg) : BaseUi(cfg)
#ifdef EMSCRIPTEN
SDL_SetHint(SDL_HINT_EMSCRIPTEN_ASYNCIFY, "0");
#endif
#ifdef __WIIU__
//WHBProcInit();
#endif

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
Output::Error("Couldn't initialize SDL.\n{}\n", SDL_GetError());
Expand Down Expand Up @@ -189,6 +195,10 @@ Sdl2Ui::~Sdl2Ui() {
SDL_DestroyWindow(sdl_window);
}
SDL_Quit();

#ifdef __WIIU__
//WHBProcShutdown();
#endif
}

bool Sdl2Ui::vChangeDisplaySurfaceResolution(int new_width, int new_height) {
Expand Down Expand Up @@ -492,6 +502,16 @@ void Sdl2Ui::ToggleZoom() {
#endif
}

bool Sdl2Ui::LogMessage(const std::string &message) {
#ifdef __WIIU__
OSReport("%s\n", message.c_str());
return true;
#else
// not logged
return false;
#endif
}

void Sdl2Ui::ProcessEvents() {
SDL_Event evnt;

Expand Down Expand Up @@ -1189,6 +1209,8 @@ int FilterUntilFocus(const SDL_Event* evnt) {
void Sdl2Ui::vGetConfig(Game_ConfigVideo& cfg) const {
#ifdef EMSCRIPTEN
cfg.renderer.Lock("SDL2 (Software, Emscripten)");
#elif defined(__WIIU__)
cfg.renderer.Lock("SDL2 (Software, Wii U)");
#else
cfg.renderer.Lock("SDL2 (Software)");
#endif
Expand Down Expand Up @@ -1219,6 +1241,11 @@ void Sdl2Ui::vGetConfig(Game_ConfigVideo& cfg) const {
cfg.window_zoom.SetOptionVisible(false);
// Toggling this freezes the web player
cfg.vsync.SetOptionVisible(false);
#elif defined(__WIIU__)
// FIXME: Some options below may crash, better disable for now
cfg.fullscreen.SetOptionVisible(false);
cfg.window_zoom.SetOptionVisible(false);
cfg.vsync.SetOptionVisible(false);
#endif
}

Expand Down
1 change: 1 addition & 0 deletions src/platform/sdl/sdl2_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Sdl2Ui final : public BaseUi {
void UpdateDisplay() override;
void SetTitle(const std::string &title) override;
bool ShowCursor(bool flag) override;
bool LogMessage(const std::string &message) override;
void ProcessEvents() override;
void SetScalingMode(ScalingMode) override;
void ToggleStretch() override;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/sdl/sdl_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ SdlAudio::SdlAudio(const Game_ConfigAudio& cfg) :
return;
}

#ifdef GEKKO
#ifdef __wii__
// Wii's DSP works at 32kHz natively
const int frequency = 32000;
#elif defined(EMSCRIPTEN)
Expand Down
12 changes: 6 additions & 6 deletions src/platform/sdl/sdl_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "player.h"
#include "bitmap.h"

#ifdef GEKKO
#ifdef __wii__
# include "platform/wii/main.h"
#endif

Expand Down Expand Up @@ -61,7 +61,7 @@ SdlUi::SdlUi(long width, long height, const Game_Config& cfg) : BaseUi(cfg)

// Set some SDL environment variables before starting. These are platform
// dependent, so every port needs to set them manually
#ifndef GEKKO
#ifndef __wii__
// Set window position to the middle of the screen
putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center"));
#endif
Expand Down Expand Up @@ -115,7 +115,7 @@ SdlUi::SdlUi(long width, long height, const Game_Config& cfg) : BaseUi(cfg)
format.b.mask,
format.a.mask);

#ifdef GEKKO
#ifdef __wii__
// Eliminate debug spew in on-screen console
Wii::SetConsole();
#endif
Expand Down Expand Up @@ -349,7 +349,7 @@ bool SdlUi::RefreshDisplayMode() {

int bpp = current_display_mode.bpp;

#ifdef GEKKO
#ifdef __wii__
// force for SDL-wii, otherwise 16 bit is used
bpp = 24;
#endif
Expand Down Expand Up @@ -443,7 +443,7 @@ bool SdlUi::ShowCursor(bool flag) {
}

bool SdlUi::LogMessage(const std::string &message) {
#ifdef GEKKO
#ifdef __wii__
return Wii::LogMessage(message);
#else
// not logged
Expand Down Expand Up @@ -750,7 +750,7 @@ int FilterUntilFocus(const SDL_Event* evnt) {
}

void SdlUi::vGetConfig(Game_ConfigVideo& cfg) const {
#ifdef GEKKO
#ifdef __wii__
cfg.renderer.Lock("SDL1 (Software, Wii)");
#else
cfg.renderer.Lock("SDL1 (Software)");
Expand Down
4 changes: 2 additions & 2 deletions src/platform/wii/input_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
Input::ButtonMappingArray Input::GetDefaultButtonMappings() {
return {
// Wiimote
{CANCEL, Keys::JOY_OTHER_0}, // A, shared with Classic Controller (CC)
{DECISION, Keys::JOY_OTHER_1}, // B, shared with CC
{DECISION, Keys::JOY_OTHER_0}, // A, shared with Classic Controller (CC)
{CANCEL, Keys::JOY_OTHER_1}, // B, shared with CC
{CANCEL, Keys::JOY_OTHER_2}, // 1
{DECISION, Keys::JOY_OTHER_3}, // 2
{RESET, Keys::JOY_OTHER_4}, // -, shared with CC
Expand Down
Loading

0 comments on commit dc933f5

Please sign in to comment.