Skip to content

Add platform: WII #155

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

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
96bef82
meson: fix cross build setup, report unknown systems
Totto16 May 18, 2024
105b459
3ds: use hardcoded values from meson, instead of from the cross files
Totto16 May 18, 2024
9ce25d6
desktop file: use dynamic value for desc instead of hardcoded one
Totto16 May 18, 2024
113110e
switch: use dynamic values from meson, instead of hardcoded ones fro…
Totto16 May 18, 2024
1c64316
WII: add basic support
Totto16 May 18, 2024
58d98e4
discord sdk: use newer file meson.options instead of meson_options.txt
Totto16 May 18, 2024
df983ee
Add libromfs: WIP
Totto16 May 18, 2024
52a33da
wii:
Totto16 May 18, 2024
a37e2a0
wii
Totto16 May 18, 2024
886e845
CI: add wii ci
Totto16 May 18, 2024
3f0b3c2
wii: fix input
Totto16 May 18, 2024
66764ea
WII: add readme
Totto16 May 19, 2024
5320939
WII: add correct debug print mechanisms
Totto16 May 19, 2024
f0d9a66
WII:
Totto16 May 19, 2024
cc00815
nintendo: use app icons for 3ds
Totto16 May 19, 2024
78ce9cb
3ds: update build definitions
Totto16 May 19, 2024
16dc972
switch:
Totto16 May 19, 2024
42b5048
wii:
Totto16 May 20, 2024
2f21c78
update libromfs wrap file. so that it uses gnu11 and also works on th…
Totto16 May 20, 2024
3e34bcc
fix location of wii build definitions after rebase
Totto16 May 31, 2024
76f093b
fix std::optional usage after rebase
Totto16 May 31, 2024
f235143
wii: fix a small error in the build script
Totto16 Jun 2, 2024
d76a3a7
wii: fix spdlog std::mutex with wii mutex
Totto16 Jun 2, 2024
0c57d1e
libromfs: detect changes in assets folder correctly and rebuild romfs…
Totto16 Jun 2, 2024
148f309
WIP: this will be removed later
Totto16 Jun 2, 2024
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
4 changes: 4 additions & 0 deletions .github/workflows/nintendo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
extension: nro
container: devkita64

- name: wii
extension: dol
container: devkitppc

steps:
- uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ It is written in [OOP](https://en.wikipedia.org/wiki/Object-oriented_programming

## Platform support

This officially supports Linux, Windows, MacOS, Android, Nintendo Switch and Nintendo 3DS.
This officially supports Linux, Windows, MacOS, Android, Nintendo Switch , Nintendo Wii and Nintendo 3DS.

Why these? Because it was fun to port the application to those platforms 😋

Expand Down
2 changes: 1 addition & 1 deletion assets/oopetris.desktop.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Version=1.0
Type=Application
Name=OOPetris
Comment=A Tetris clone in OOP
Comment=@DESCRIPTION@
Exec=oopetris
Icon=@APP_NAME@
Terminal=false
Expand Down
4 changes: 4 additions & 0 deletions docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ For concrete instructions, see the list below:
[switch](3ds.md)


## Nintendo Wii

[wii](wii.md)

## Android

[android](android.md)
2 changes: 1 addition & 1 deletion docs/switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- a C++23 compatible cross compiler, we only support The [devkitpro](https://devkitpro.org/) one
- meson
- some portlibs from devkitpro, namely sdl2, sld2_ttf, sdl2_mix.
- some portlibs from devkitpro, namely sdl2, sdl2_ttf, sdl2_mix.


## Compiling
Expand Down
37 changes: 37 additions & 0 deletions docs/wii.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Nintendo Wii build

## Prerequisites

- a C++23 compatible cross compiler, we only support The [devkitpro](https://devkitpro.org/) one
- meson
- some portlibs from devkitpro, namely sdl2, sdl2_ttf, sdl2_mix.


## Compiling


Cross Compiling is only possible on linux-like systems.

We use meson and cross-compilation files, everything is wrapped into shell script, so you just need to run:


```bash
./platforms/build-wii.sh

```
After that you can find the runnable executable (also supports emulators)
in `build-wii/oopetris.dol`

Typically this would be moved into a folder on an external SD card of the WII, than you can load it with Homebrew.


The Folder structure would be:

`/apps/OOPetris/`
- `boot.dol`
- `icon.png`
- `meta.xml`

At the moment we don't package that like this, but in the future we might.

The `meta.xml` file is being generated, the `boot.dol` file has to be renamed and the `icon.png` can be taken from the `assets/icon/` folder
11 changes: 4 additions & 7 deletions platforms/build-3ds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,11 @@ needs_exe_wrapper = true
library_dirs= ['$LIBCTRU_LIB','$PORTLIBS_LIB']
libctru='$LIBCTRU'

APP_NAME = 'oopetris'
APP_AUTHOR = 'coder2k'
APP_DESC = 'A Tetris clone in OOP'

USE_SMDH = true

APP_ROMFS='$ROMFS'
USE_SMDH = true

APP_ROMFS = '$ROMFS'
APP_ICON = './assets/icon/48x48.png'
APP_SMALL_ICON='./assets/icon/24x24.png'
EOF

## build sdl2 and libraries (ttf, mixer, image)
Expand Down
5 changes: 1 addition & 4 deletions platforms/build-switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,10 @@ needs_exe_wrapper = true
library_dirs= ['$LIBNX_LIB','$PORTLIBS_LIB']
libnx='$LIBNX'

APP_NAME = 'oopetris'
APP_AUTHOR = 'coder2k'
APP_VERSION = true

USE_NACP = true

APP_ROMFS='$ROMFS'
APP_ICON = './assets/icon/1024x1024.png'

EOF

Expand Down
162 changes: 162 additions & 0 deletions platforms/build-wii.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#!/usr/bin/env bash

set -e

export DEVKITPRO="/opt/devkitpro"
export ARCH_DEVKIT_FOLDER="$DEVKITPRO/devkitPPC"
export COMPILER_BIN="$ARCH_DEVKIT_FOLDER/bin"
export PATH="$DEVKITPRO/tools/bin:$COMPILER_BIN:$PATH"

export OGC_CONSOLE="wii"
export OGC_SUBDIR="wii"
export OGC_MACHINE="rvl"

export PORTLIBS_PATH="$DEVKITPRO/portlibs"
export LIBOGC="$DEVKITPRO/libogc"

export PORTLIBS_PATH_OGC="$PORTLIBS_PATH/$OGC_CONSOLE"
export PORTLIBS_PATH_PPC="$PORTLIBS_PATH/ppc"

export PORTLIBS_LIB_OGC="$PORTLIBS_PATH_OGC/lib"
export PORTLIBS_LIB_PPC="$PORTLIBS_PATH_PPC/lib"
export LIBOGC_LIB="$LIBOGC/lib/$OGC_SUBDIR"

export PKG_CONFIG_PATH_OGC="$PORTLIBS_LIB_OGC/pkgconfig/"
export PKG_CONFIG_PATH_PPC="$PORTLIBS_LIB_PPC/pkgconfig/"
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH_OGC:$PKG_CONFIG_PATH_PPC"

export ROMFS="platforms/romfs"

export BUILD_DIR="build-wii"

export TOOL_PREFIX="powerpc-eabi"

export BIN_DIR_OGC="$PORTLIBS_PATH_OGC/bin"
export BIN_DIR_PPC="$PORTLIBS_LIB_PPC/bin"
export PKG_CONFIG_EXEC="$BIN_DIR_OGC/$TOOL_PREFIX-pkg-config"
export CMAKE="$BIN_DIR_OGC/$TOOL_PREFIX-cmake"

export PATH="$BIN_DIR_PPC:$BIN_DIR_OGC:$PATH"

export CC="$COMPILER_BIN/$TOOL_PREFIX-gcc"
export CXX="$COMPILER_BIN/$TOOL_PREFIX-g++"
export AS="$COMPILER_BIN/$TOOL_PREFIX-as"
export AR="$COMPILER_BIN/$TOOL_PREFIX-gcc-ar"
export RANLIB="$COMPILER_BIN/$TOOL_PREFIX-gcc-ranlib"
export NM="$COMPILER_BIN/$TOOL_PREFIX-gcc-nm"
export OBJCOPY="$COMPILER_BIN/$TOOL_PREFIX-objcopy"
export STRIP="$COMPILER_BIN/$TOOL_PREFIX-strip"

export ARCH="ppc"
export CPU_VERSION="ppc750"
export ENDIANESS="big"

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

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'"

export LINK_FLAGS="'-L$LIBOGC_LIB','-L$PORTLIBS_LIB_PPC','-L$PORTLIBS_LIB_OGC'"

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

cat <<EOF >"$CROSS_FILE"
[host_machine]
system = 'wii'
cpu_family = '$ARCH'
cpu = '$CPU_VERSION'
endian = '$ENDIANESS'

[target_machine]
system = 'wii'
cpu_family = '$ARCH'
cpu = '$CPU_VERSION'
endian = '$ENDIANESS'

[constants]
devkitpro = '$DEVKITPRO'

[binaries]
c = '$CC'
cpp = '$CXX'
c_ld = 'bfd'
cpp_ld = 'bfd'
ar = '$AR'
as = '$AS'
ranlib = '$RANLIB'
strip = '$STRIP'
objcopy = '$OBJCOPY'
nm = '$NM'
pkg-config = '$PKG_CONFIG_EXEC'
cmake='$CMAKE'
freetype-config='$BIN_DIR_PPC/freetype-config'
libpng16-config='$BIN_DIR_PPC/libpng16-config'
libpng-config='$BIN_DIR_PPC/libpng-config'
sdl2-config='$BIN_DIR_OGC/sdl2-config'

[built-in options]
c_std = 'gnu11'
cpp_std = 'c++23'
c_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
cpp_args = [$COMMON_FLAGS, $COMPILE_FLAGS]
c_link_args = [$COMMON_FLAGS, $LINK_FLAGS]
cpp_link_args = [$COMMON_FLAGS, $LINK_FLAGS]


[properties]
pkg_config_libdir = '$PKG_CONFIG_PATH'
needs_exe_wrapper = true
library_dirs= ['$LIBOGC_LIB', '$PORTLIBS_LIB_OGC','$PORTLIBS_LIB_PPC']

USE_META_XML = true


APP_ROMFS='$ROMFS'

EOF

## options: "smart, complete_rebuild"
export COMPILE_TYPE="smart"

export BUILDTYPE="debug"

if [ "$#" -eq 0 ]; then
# nothing
echo "Using compile type '$COMPILE_TYPE'"
elif [ "$#" -eq 1 ]; then
COMPILE_TYPE="$1"
elif [ "$#" -eq 2 ]; then
COMPILE_TYPE="$1"
BUILDTYPE="$2"
else
echo "Too many arguments given, expected 1 or 2"
exit 1
fi

if [ "$COMPILE_TYPE" == "smart" ]; then
: # noop
elif [ "$COMPILE_TYPE" == "complete_rebuild" ]; then
: # noop
else
echo "Invalid COMPILE_TYPE, expected: 'smart' or 'complete_rebuild'"
exit 1
fi

if [ ! -d "$ROMFS" ]; then

mkdir -p "$ROMFS"

cp -r assets "$ROMFS/"

fi

if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then

meson setup "$BUILD_DIR" \
"--wipe" \
--cross-file "$CROSS_FILE" \
"-Dbuildtype=$BUILDTYPE" \
-Ddefault_library=static

fi

meson compile -C "$BUILD_DIR" -j 3
Loading
Loading