Skip to content

Commit 57d1a68

Browse files
committed
wii
- don't use wut, but ogc, these two libraries conflict with each other! (wut is for wiiu only) - fix libromfs, also support wii
1 parent 495f0cd commit 57d1a68

File tree

7 files changed

+128
-21
lines changed

7 files changed

+128
-21
lines changed

platforms/build-wii.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export OGC_MACHINE="rvl"
1313

1414
export PORTLIBS_PATH="$DEVKITPRO/portlibs"
1515
export LIBOGC="$DEVKITPRO/libogc"
16-
export WUT="$DEVKITPRO/wut"
1716

1817
export PORTLIBS_PATH_OGC="$PORTLIBS_PATH/$OGC_CONSOLE"
1918
export PORTLIBS_PATH_PPC="$PORTLIBS_PATH/ppc"
@@ -56,9 +55,9 @@ export ENDIANESS="big"
5655

5756
export COMMON_FLAGS="'-m${OGC_MACHINE}','-mcpu=750','-meabi','-mhard-float','-ffunction-sections','-fdata-sections'"
5857

59-
export COMPILE_FLAGS="'-D__WII__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-D_OGC_','-DGEKKO','-isystem', '$LIBOGC/include', '-isystem', '$WUT/include', '-I$PORTLIBS_PATH_PPC/include', '-I$PORTLIBS_PATH_OGC/include'"
58+
export COMPILE_FLAGS="'-D__WII__','-D__CONSOLE__','-D__NINTENDO_CONSOLE__','-D_OGC_','-DGEKKO','-isystem', '$LIBOGC/include', '-I$PORTLIBS_PATH_PPC/include', '-I$PORTLIBS_PATH_OGC/include'"
6059

61-
export LINK_FLAGS="'-L$LIBOGC_LIB','-L$WUT/lib','-L$PORTLIBS_LIB_PPC','-L$PORTLIBS_LIB_OGC'"
60+
export LINK_FLAGS="'-L$LIBOGC_LIB','-L$PORTLIBS_LIB_PPC','-L$PORTLIBS_LIB_OGC'"
6261

6362
export CROSS_FILE="./platforms/crossbuild-wii.ini"
6463

@@ -108,7 +107,7 @@ cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
108107
[properties]
109108
pkg_config_libdir = '$PKG_CONFIG_PATH'
110109
needs_exe_wrapper = true
111-
library_dirs= ['$LIBOGC_LIB', '$WUT/lib', '$PORTLIBS_LIB_OGC','$PORTLIBS_LIB_PPC']
110+
library_dirs= ['$LIBOGC_LIB', '$PORTLIBS_LIB_OGC','$PORTLIBS_LIB_PPC']
112111
113112
USE_META_XML = true
114113

platforms/wii/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ wii_dependencies_native = [
2929
'SDL2main',
3030
'wiikeyboard',
3131
'wiiuse',
32-
'wut',
3332
]
3433

3534
foreach dep : wii_dependencies

src/helper/console_helpers.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include <3ds.h>
1313
#include <cstdlib>
1414
#elif defined(__WII__)
15-
#include <coreinit/debug.h>
16-
#include <wut.h>
15+
#include <debug.h>
1716

1817
#include <romfs-wiiu.h>
1918
#endif
@@ -26,8 +25,8 @@ void console::debug_write(const char* text, size_t size) {
2625
#elif defined(__SWITCH__)
2726
svcOutputDebugString(text, size);
2827
#elif defined(__WII__)
29-
//TODO: maybe use OSReportVerbose
30-
OSConsoleWrite(text, size);
28+
UNUSED(text);
29+
UNUSED(size);
3130
#else
3231
#error "not implemented"
3332
#endif

src/input/console_buttons.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ namespace {
145145
}; // namespace
146146

147147

148-
#include <wut.h>
149-
#include <padscore/wpad.h>
148+
#include <wiiuse/wpad.h>
150149

151150

152151
//using C enum (not enum class) on purpose
@@ -168,14 +167,14 @@ enum JOYCON {
168167
JOYCON_A = BIT_REVERSE(WPAD_BUTTON_A), ///! The A button.
169168
JOYCON_B = BIT_REVERSE(WPAD_BUTTON_B), ///! The B button.
170169

171-
JOYCON_C = BIT_REVERSE(WPAD_BUTTON_C), ///! The C button on the Nunchuk extension.
172-
JOYCON_Z = BIT_REVERSE(WPAD_BUTTON_Z), ///! The Z button on the Nunchuk extension.
170+
NUNCHUK_C = BIT_REVERSE(WPAD_NUNCHUK_BUTTON_C), ///! The C button on the Nunchuk extension.
171+
NUNCHUK_Z = BIT_REVERSE(WPAD_NUNCHUK_BUTTON_Z), ///! The Z button on the Nunchuk extension.
173172

174173
JOYCON_HOME = BIT_REVERSE(WPAD_BUTTON_HOME), ///! The HOME button.
175174
};
176175

177176
/// Creates a bitmask from a bit number.
178-
#define BIT(n) (1U<<(n))
177+
#define BIT(n) (1U << (n))
179178

180179
// some static asserts to check if BIT_REVERSE works as expected
181180
static_assert(BIT(JOYCON_LEFT) == WPAD_BUTTON_LEFT);

subprojects/libromfs.wrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ directory = libromfs-0.7
55
url = https://github.com/yawut/libromfs-wiiu.git
66
revision = master
77
depth = 1
8-
98
patch_directory = libromfs
9+
diff_files = libromfs-0.7_wii.diff
1010

1111
[provide]
1212
libromfs = libromfs_dep
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
diff --git a/source/romfs.c b/source/romfs.c
2+
index 02d6bd5..a3c2c2a 100644
3+
--- a/source/romfs.c
4+
+++ b/source/romfs.c
5+
@@ -15,7 +15,18 @@
6+
#include <sys/param.h>
7+
#include <stdint.h>
8+
#include <unistd.h>
9+
+
10+
+#if defined(__WII__)
11+
+#include <gccore.h>
12+
+
13+
+#define OSBlockMove(dest, src, size, flush) memmove((dest), (src), (size))
14+
+
15+
+#elif defined(__WIIU__)
16+
#include <coreinit/memory.h>
17+
+#else
18+
+#error "Unsupported platform"
19+
+#endif
20+
+
21+
22+
23+
/* include the implementation files (needed for static functions) */
24+
@@ -34,41 +45,41 @@ static int32_t romfs_initialised = 0;
25+
/* romfsInit: intialize romfs */
26+
int32_t romfsInit(void)
27+
{
28+
- /* already initialized */
29+
- if (romfs_initialised)
30+
- return 0;
31+
+ /* already initialized */
32+
+ if (romfs_initialised)
33+
+ return 0;
34+
35+
- /* create romfs file entries */
36+
- tar_create_entries(_binary_romfs_tar_start, _binary_romfs_tar_end);
37+
+ /* create romfs file entries */
38+
+ tar_create_entries(_binary_romfs_tar_start, _binary_romfs_tar_end);
39+
40+
- /* add the romfs devoptab to devices list */
41+
- if (AddDevice(&romfs_devoptab) == -1)
42+
- {
43+
- node_destroytree(NULL, 0);
44+
- return -1;
45+
- }
46+
+ /* add the romfs devoptab to devices list */
47+
+ if (AddDevice(&romfs_devoptab) == -1)
48+
+ {
49+
+ node_destroytree(NULL, 0);
50+
+ return -1;
51+
+ }
52+
53+
- /* set the intialized flag */
54+
- romfs_initialised = 1;
55+
+ /* set the intialized flag */
56+
+ romfs_initialised = 1;
57+
58+
- return 0;
59+
+ return 0;
60+
}
61+
62+
/* romfsExit: exit romfs */
63+
int32_t romfsExit(void)
64+
{
65+
- /* never initialized */
66+
- if (!romfs_initialised)
67+
- return -1;
68+
+ /* never initialized */
69+
+ if (!romfs_initialised)
70+
+ return -1;
71+
72+
- /* remove the romfs devoptab from devices list */
73+
- RemoveDevice("romfs:");
74+
+ /* remove the romfs devoptab from devices list */
75+
+ RemoveDevice("romfs:");
76+
77+
- /* deallocate the file tree */
78+
- node_destroytree(NULL, 0);
79+
+ /* deallocate the file tree */
80+
+ node_destroytree(NULL, 0);
81+
82+
- /* clear the initialized flag */
83+
- romfs_initialised = 0;
84+
+ /* clear the initialized flag */
85+
+ romfs_initialised = 0;
86+
87+
- return 0;
88+
+ return 0;
89+
}

subprojects/packagefiles/libromfs/meson.build

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,20 @@ if meson.is_cross_build()
2525

2626
c = meson.get_compiler('c')
2727

28-
deps += c.find_library(
29-
'wut',
30-
required: true,
31-
dirs: library_dirs,
32-
)
28+
if host_machine.system() == 'wiiu'
29+
deps += c.find_library(
30+
'wut',
31+
required: true,
32+
dirs: library_dirs,
33+
)
34+
elif host_machine.system() == 'wii'
35+
36+
deps += c.find_library(
37+
'ogc',
38+
required: true,
39+
dirs: library_dirs,
40+
)
41+
endif
3342

3443
else
3544
error('not supported platform: ' + host_machine.system())
@@ -70,13 +79,26 @@ romfs_tar = custom_target(
7079
output: [romfs_tar_name],
7180
)
7281

82+
binary_start_name = (
83+
'_binary' + (
84+
romfs_tar.full_path().replace(meson.global_build_root(), '').replace(
85+
'/',
86+
'_',
87+
).replace('.', '_').replace('-', '_')
88+
)
89+
)
90+
binary_final_name = '_binary_romfs_tar'
91+
7392
romfs_object = custom_target(
7493
romfs_obj_name,
7594
command: [
7695
objcopy,
7796
'--input-target', 'binary',
7897
'--output-target', object_target,
7998
'--binary-architecture', binary_arch,
99+
'--redefine-sym', binary_start_name + '_start=' + binary_final_name + '_start',
100+
'--redefine-sym', binary_start_name + '_end=' + binary_final_name + '_end',
101+
'--redefine-sym', binary_start_name + '_size=' + binary_final_name + '_size',
80102
'@INPUT@',
81103
'@OUTPUT@',
82104
],
@@ -87,7 +109,7 @@ romfs_object = custom_target(
87109
inc_dirs = include_directories('include')
88110

89111
libromfs_lib = library(
90-
'libromfs',
112+
'romfs',
91113
files('source/romfs.c'),
92114
c_args: ['-D_POSIX_C_SOURCE=200809'],
93115
include_directories: inc_dirs,

0 commit comments

Comments
 (0)