Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] (WiiU) wut toolchain port/Aroma compatibility #14925

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -2381,12 +2381,37 @@ ifeq ($(HAVE_STATIC_VIDEO_FILTERS), 1)
gfx/video_filters/upscale_mix_240x160_320x240.o
endif

ifeq ($(WANT_IOSUHAX), 1)
DEFINES += -DHAVE_IOSUHAX
INCLUDE_DIRS += -I$(DEPS_DIR)/libiosuhax/include
OBJ += $(DEPS_DIR)/libiosuhax/source/iosuhax.o \
$(DEPS_DIR)/libiosuhax/source/iosuhax_devoptab.o \
$(DEPS_DIR)/libiosuhax/source/iosuhax_disc_interface.o
ifeq ($(WANT_LIBMOCHA), 1)
DEFINES += -DHAVE_LIBMOCHA
INCLUDE_DIRS += -I$(DEPS_DIR)/libmocha/include
OBJ += $(DEPS_DIR)/libmocha/source/disc_interface.o \
$(DEPS_DIR)/libmocha/source/fsa.o \
$(DEPS_DIR)/libmocha/source/utils.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_chdir.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_chmod.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_close.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_dirclose.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_dirnext.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_diropen.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_dirreset.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_fchmod.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_fstat.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_fsync.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_link.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_mkdir.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_open.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_read.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_rename.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_rmdir.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_seek.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_stat.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_statvfs.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_truncate.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_unlink.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_utils.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_utimes.o \
$(DEPS_DIR)/libmocha/source/devoptab/devoptab_fsa_write.o
endif

ifeq ($(WANT_LIBFAT), 1)
Expand Down
86 changes: 23 additions & 63 deletions Makefile.wiiu
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
TARGET := retroarch_wiiu

BUILD_HBL_ELF = 1
BUILD_RPX = 1
DEBUG = 0
GRIFFIN_BUILD = 0
SALAMANDER_BUILD = 0
SALAMANDER_BUILD ?= 0
HAVE_STATIC_DUMMY ?= 0
WHOLE_ARCHIVE_LINK = 0
WIIU_HID = 1
Expand Down Expand Up @@ -37,25 +35,20 @@ INCDIRS :=
#-----------------------------
# Features and object files

OBJ += wiiu/main.o
OBJ += wiiu/system/memory.o
OBJ += wiiu/system/atomic.o
OBJ += wiiu/system/exception_handler.o
OBJ += wiiu/system/missing_libc_functions.o
OBJ += wiiu/fs/sd_fat_devoptab.o
OBJ += wiiu/fs/fs_utils.o
OBJ += wiiu/hbl.o

RPX_OBJ = $(BUILD_DIR)/wiiu/system/stubs_rpl.o
HBL_ELF_OBJ = $(BUILD_DIR)/wiiu/system/dynamic.o \
$(BUILD_DIR)/wiiu/system/stubs_elf.o

ifeq ($(SALAMANDER_BUILD),1)
DEFINES += -DRARCH_CONSOLE -DIS_SALAMANDER

INCDIRS += -Ideps/libmocha/include

OBJ += frontend/frontend_salamander.o
OBJ += frontend/frontend_driver.o
OBJ += frontend/drivers/platform_wiiu.o
OBJ += deps/libmocha/source/utils.o
OBJ += libretro-common/encodings/encoding_utf.o
OBJ += libretro-common/compat/compat_strcasestr.o
OBJ += libretro-common/compat/fopen_utf8.o
Expand Down Expand Up @@ -110,7 +103,7 @@ endif

INCDIRS += -Ilibretro-common/include/compat/zlib
# for stb, libfat, iosuhax
INCDIRS += -Ideps -Ideps/libfat/include -Ideps/libiosuhax/include
INCDIRS += -Ideps
# pad_functions uses wiiu/input.h
INCDIRS += -Iinput/include
INCDIRS += -Ideps/SPIRV-Cross
Expand All @@ -126,7 +119,6 @@ endif
#DEFINES += -DHAVE_FREETYPE
DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
DEFINES += -DHAVE_HID
DEFINES += -DWANT_LIBFAT -DHAVE_LIBFAT -DWANT_IOSUHAX -DHAVE_IOSUHAX
DEFINES += -DHAVE_CORE_INFO_CACHE
DEFINES += -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS

Expand Down Expand Up @@ -171,7 +163,7 @@ endif
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
WANT_LIBFAT = 1
WANT_IOSUHAX = 1
WANT_LIBMOCHA = 1
HAVE_CORE_INFO_CACHE = 1

include Makefile.common
Expand Down Expand Up @@ -248,15 +240,6 @@ ifeq ($(HAVE_BUILTINZLIB),0)
endif
endif

LDFLAGS += -Wl,--gc-sections

RPX_LDFLAGS := -pie -fPIE
RPX_LDFLAGS += -z common-page-size=64 -z max-page-size=64
RPX_LDFLAGS += -T wiiu/link_rpl.ld
RPX_LDFLAGS += -nostartfiles

HBL_ELF_LDFLAGS := -T wiiu/link_elf.ld

#-----------------------------
# Compiler setup

Expand All @@ -267,7 +250,7 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
endif

export PATH := $(PATH):$(DEVKITPPC)/bin
export PATH := $(PATH):$(DEVKITPPC)/bin:$(DEVKITPRO)/tools/bin

PREFIX := powerpc-eabi-

Expand All @@ -280,25 +263,19 @@ STRIP := $(PREFIX)strip
NM := $(PREFIX)nm
LD := $(CXX)

ELF2RPL := wiiu/wut/elf2rpl/elf2rpl
WUT_ROOT ?= $(DEVKITPRO)/wut

ifneq ($(findstring Linux,$(shell uname -a)),)
else ifneq ($(findstring Darwin,$(shell uname -a)),)
else
ELF2RPL := $(ELF2RPL).exe
endif
RPXSPECS := -specs=$(WUT_ROOT)/share/wut.specs
RPLSPECS := -specs=$(WUT_ROOT)/share/wut.specs -specs=$(WUT_ROOT)/share/rpl.specs

INCDIRS += -I$(WUT_ROOT)/include
LIBDIRS += -L$(WUT_ROOT)/lib
LIBS += -lwut

#-----------------------------
# Targets and build rules

TARGETS :=
ifeq ($(BUILD_RPX), 1)
TARGETS += $(TARGET).rpx
endif

ifeq ($(BUILD_HBL_ELF), 1)
TARGETS += $(TARGET).elf
endif
TARGETS := $(TARGET).rpx

DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.depend

Expand Down Expand Up @@ -334,38 +311,21 @@ $(BUILD_DIR)/%.o: %.s %.depend
%.depend: ;
%.last: ;

$(ELF2RPL):
@$(if $(Q), echo MAKE $@,)
$(Q)$(MAKE) -C wiiu/wut/elf2rpl/

$(BUILD_DIR)/$(TARGET).elf: $(OBJ) $(HBL_ELF_OBJ) libretro_wiiu.a wiiu/link_elf.ld .$(TARGET).elf.last
$(BUILD_DIR)/$(TARGET).rpx.elf: $(OBJ) libretro_wiiu.a
@$(if $(Q), echo LD $@,)
@touch .$(TARGET).elf.last
$(Q)$(LD) $(OBJ) $(HBL_ELF_OBJ) $(LDFLAGS) $(HBL_ELF_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(Q)$(LD) $(OBJ) $(RPXSPECS) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@

$(BUILD_DIR)/$(TARGET).rpx.elf: $(OBJ) $(RPX_OBJ) libretro_wiiu.a wiiu/link_elf.ld
@$(if $(Q), echo LD $@,)
$(Q)$(LD) $(OBJ) $(RPX_OBJ) $(LDFLAGS) $(RPX_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@

$(BUILD_DIR)/$(TARGET).large.rpx: $(BUILD_DIR)/$(TARGET).rpx.elf $(ELF2RPL) .$(TARGET).rpx.large.last
$(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).rpx.elf
@$(if $(Q), echo ELF2RPL $@,)
@touch .$(TARGET).rpx.large.last
$(Q)-$(ELF2RPL) $< $@

$(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).large.rpx .$(TARGET).rpx.last
@$(if $(Q), echo COMPRESS $@,)
@touch .$(TARGET).rpx.large.last
$(Q)wiiurpxtool -c $< $@
$(Q)elf2rpl $< $@

clean:
@$(if $(Q), echo $@,)
$(Q)rm -f $(OBJ) $(RPX_OBJ) $(HBL_ELF_OBJ) $(TARGET).elf $(TARGET).rpx.elf $(TARGET).rpx
$(Q)rm -f $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).large.rpx $(BUILD_DIR)/$(TARGET).rpx
$(Q)rm -f .$(TARGET).elf.last .$(TARGET).rpx.elf.last .$(TARGET).rpx.large.last .$(TARGET).rpx.last
$(Q)rm -f $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
$(Q)$(MAKE) -C wiiu/wut/elf2rpl/ clean
$(Q)rm -f $(OBJ) $(TARGET).rpx.elf $(TARGET).rpx
$(Q)rm -f $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).rpx
$(Q)rm -f $(OBJ:.o=.depend)

.PHONY: clean all
.PRECIOUS: %.depend %.last

-include $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
-include $(OBJ:.o=.depend)
19 changes: 11 additions & 8 deletions audio/drivers/wiiu_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#include <malloc.h>
#include <stdint.h>

#include <wiiu/os.h>
#include <wiiu/ax.h>

#include <sndcore2/core.h>
#include <sndcore2/ra_multivoice.h>
#include <coreinit/cache.h>
#include <coreinit/spinlock.h>
#include <coreinit/thread.h>

#include "../../wiiu/wiiu_dbg.h"
#include "../../wiiu/system/memory.h"
Expand Down Expand Up @@ -75,16 +79,15 @@ void wiiu_ax_callback(void)
}
}

extern void AXRegisterFrameCallback(void *cb);

static void* ax_audio_init(const char* device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
AXVoiceOffsets offsets[2];
u16 setup_buf[0x30] = {0};
setup_buf[0x25] = 2; /* we request 2 channels */
AXInitParams init = {AX_INIT_RENDERER_48KHZ, 0, 0};
DspConfig setup_buf = {0};
setup_buf.multi_ch_count = 2;

AXInitParams init = {AX_INIT_RENDERER_48KHZ, {0, 0}};
AXVoiceVeData ve = {0x8000, 0};
ax_audio_t* ax = (ax_audio_t*)calloc(1, sizeof(ax_audio_t));

Expand All @@ -93,7 +96,7 @@ static void* ax_audio_init(const char* device, unsigned rate, unsigned latency,

AXInitWithParams(&init);

AXAcquireMultiVoice(31, NULL, 0, setup_buf, &ax->mvoice);
AXAcquireMultiVoice(31, NULL, 0, &setup_buf, &ax->mvoice);

if (!ax->mvoice || ax->mvoice->channels != 2)
{
Expand Down
8 changes: 7 additions & 1 deletion config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@
#define DEFAULT_SYSTEMFILES_IN_CONTENT_DIR false
#define DEFAULT_SCREENSHOTS_IN_CONTENT_DIR false

#if defined(RS90) || defined(RETROFW) || defined(MIYOO) || defined(SWITCH) || defined(ORBIS) || defined(__WINRT__)
#if defined(RS90) || defined(RETROFW) || defined(MIYOO) || defined(SWITCH) || defined(ORBIS) || defined(__WINRT__) || defined(WIIU)
#define DEFAULT_MENU_TOGGLE_GAMEPAD_COMBO INPUT_COMBO_START_SELECT
#elif defined(_XBOX1) || defined(__PS3__) || defined(_XBOX360) || defined(DINGUX)
#define DEFAULT_MENU_TOGGLE_GAMEPAD_COMBO INPUT_COMBO_L3_R3
Expand Down Expand Up @@ -943,6 +943,12 @@
#define DEFAULT_ALL_USERS_CONTROL_MENU false
#endif

#if defined(WIIU)
/* On Wii U, whether the HOME button should open the OS's HOME menu, or simply toggle the RetroArch menu (as it did in
* older HBL/Tiramisu builds of RetroArch) */
#define DEFAULT_WIIU_ENABLE_HBM true
#endif

#define DEFAULT_QUIT_PRESS_TWICE true

#define DEFAULT_LOG_TO_FILE false
Expand Down
3 changes: 3 additions & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,9 @@ static struct config_bool_setting *populate_settings_bool(
#endif
#if defined(HAVE_DINPUT) || defined(HAVE_WINRAWINPUT)
SETTING_BOOL("input_nowinkey_enable", &settings->bools.input_nowinkey_enable, true, false, false);
#endif
#ifdef WIIU
SETTING_BOOL("input_wiiu_enable_hbm", &settings->bools.input_wiiu_enable_hbm, true, DEFAULT_WIIU_ENABLE_HBM, false);
#endif
SETTING_BOOL("input_sensors_enable", &settings->bools.input_sensors_enable, true, DEFAULT_INPUT_SENSORS_ENABLE, false);
SETTING_BOOL("vibrate_on_keypress", &settings->bools.vibrate_on_keypress, true, DEFAULT_VIBRATE_ON_KEYPRESS, false);
Expand Down
3 changes: 3 additions & 0 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,9 @@ typedef struct settings
bool input_touch_vmouse_trackball;
bool input_touch_vmouse_gesture;
#endif
#ifdef WIIU
bool input_wiiu_enable_hbm;
#endif

/* Frame time counter */
bool frame_time_counter_reset_after_fastforwarding;
Expand Down
2 changes: 1 addition & 1 deletion deps/libfat/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

/* Platform specific includes */
#if defined (__wiiu__)
#include <iosuhax_disc_interface.h>
#include <mocha/disc_interface.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef int32_t s32;
Expand Down
6 changes: 3 additions & 3 deletions deps/libfat/disc.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ The list is terminated by a NULL/NULL entry.

/* ====================== Wii U ====================== */
#if defined (__wiiu__)
#include <iosuhax_disc_interface.h>
#include <mocha/disc_interface.h>

static const DISC_INTERFACE* get_io_wiiu_sd (void)
{
return &IOSUHAX_sdio_disc_interface;
return &Mocha_sdio_disc_interface;
}

static const DISC_INTERFACE* get_io_wiiu_usb (void)
{
return &IOSUHAX_usb_disc_interface;
return &Mocha_usb_disc_interface;
}

const INTERFACE_ID _FAT_disc_interfaces[] = {
Expand Down
2 changes: 1 addition & 1 deletion deps/libfat/include/fat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extern "C" {
#include <stdint.h>

#if defined (__wiiu__)
# include <iosuhax_disc_interface.h>
# include <mocha/disc_interface.h>
#elif defined(__gamecube__) || defined (__wii__)
# include <ogc/disc_io.h>
#else
Expand Down
4 changes: 3 additions & 1 deletion deps/libfat/mem_allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
malloc is unavailable

Copyright (c) 2006 Michael "Chishm" Chisholm

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Expand Down Expand Up @@ -42,6 +42,8 @@ static inline void* _FAT_mem_align (size_t size)
{
#ifdef __wii__
return memalign (32, size);
#elif defined(__wiiu__)
return memalign (64, size);
#else
return malloc (size);
#endif
Expand Down
25 changes: 0 additions & 25 deletions deps/libiosuhax/.github/workflows/push_image.yml

This file was deleted.

5 changes: 0 additions & 5 deletions deps/libiosuhax/.gitignore

This file was deleted.

Loading