Skip to content

Commit 0f8770a

Browse files
authored
Feature/nx (#155)
Add support for Nintendo switch homebrew - Add a C application linking magenboy_core and compiling to nintendo switch using libnx (including CI) - Fix UB in static allocator - Some refactors in common and rpi in order to reuse some modules
1 parent 531b2b7 commit 0f8770a

29 files changed

Lines changed: 1213 additions & 34 deletions

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*target/
2+
.github/
3+
docs/
4+
*Dockerfile

.github/workflows/rust.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,8 @@ jobs:
5656
run: cargo make libretro_desktop
5757

5858
- name: Build libretro android
59-
run: cargo make libretro_android
59+
run: cargo make libretro_android
60+
61+
- name: Build nintendo switch
62+
if: ${{ matrix.os == 'ubuntu-latest' }} # This fails on windows since it does not have docker installed
63+
run: cargo make nx

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ bld/
4040
# Uncomment if you have tasks that create the project's static files in wwwroot
4141
#wwwroot/
4242

43-
#vscode
44-
.vscode/
45-
4643
# Visual Studio 2017 auto generated files
4744
Generated\ Files/
4845

.vscode/settings.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"C_Cpp.clang_format_fallbackStyle": "WebKit",
3+
"C_Cpp.default.includePath": [
4+
"${DEVKITPRO}\\libnx\\include",
5+
"${DEVKITPRO}\\devkitA64\\aarch64-none-elf\\include",
6+
"${DEVKITPRO}\\devkitA64\\lib\\gcc\\aarch64-none-elf\\15.1.0\\include"
7+
],
8+
"rust-analyzer.cargo.extraEnv": {
9+
"RPI": "4"
10+
},
11+
"rust-analyzer.cargo.allTargets": false,
12+
"rust-analyzer.check.workspace": true,
13+
}

Cargo.lock

Lines changed: 21 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ members = [
66
"core",
77
"rpi",
88
"common",
9-
"libretro"
9+
"libretro",
10+
"nx"
1011
]
1112

1213
[workspace.package]
13-
version = "4.1.0"
14+
version = "4.2.0"
1415
authors = ["alloncm <alloncm@gmail.com>"]
1516
rust-version = "1.73" # cause of cargo-ndk used to build for android platform
1617
edition = "2021"

Makefile.toml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install_crate_args=["--locked", "--version", "0.2.5"]
4545
command = "cross"
4646
args = ["build", "--release", "--target", "armv7-unknown-linux-gnueabihf", "--bin", "rpios","--no-default-features", "--features", "os"]
4747

48-
[tasks.pre-rpibm]
48+
[tasks.nightly-install]
4949
command = "rustup"
5050
args = ["toolchain", "install", "--profile", "minimal", "--no-self-update", "${nightly_version}"]
5151

@@ -55,7 +55,7 @@ install_crate = "cargo-binutils"
5555
install_crate_args=["--locked", "--version", "0.3.6"]
5656
command = "rust-objcopy"
5757
args = ["target/armv7a-none-eabihf/release/baremetal", "-O", "binary", "kernel7.img"]
58-
dependencies = ["pre-rpibm", "build_rpi_baremetal","install_llvm_tools"]
58+
dependencies = ["nightly-install", "build_rpi_baremetal","install_llvm_tools"]
5959

6060
[tasks.build_rpi_baremetal]
6161
toolchain = "${nightly_version}"
@@ -85,4 +85,8 @@ dependencies = ["add_android_target"]
8585

8686
[tasks.add_android_target]
8787
command = "rustup"
88-
args = ["target", "add", "aarch64-linux-android"]
88+
args = ["target", "add", "aarch64-linux-android"]
89+
90+
[tasks.nx]
91+
command = "docker"
92+
args = ["build", "--progress=plain", ".", "--file", "nx/Dockerfile", "--target", "export", "--output=.", "--build-arg", "NIGHTLY=${nightly_version}"]

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Install `cargo-make`
1010
```sh
1111
cargo install cargo-make
1212
```
13-
verify you have docker or podman installed
13+
Verify you have cmake and docker or podman installed
1414

1515
### Desktop
1616

@@ -73,6 +73,10 @@ rustup component add llvm-tools-preview
7373

7474
See - [LibretroDocs](docs/Libretro.md)
7575

76+
### Nintendo Switch
77+
78+
See - [NxDocs](docs/Nx.md)
79+
7680
## Running
7781

7882
### Desktop

common/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ edition.workspace = true
1010
magenboy_core = {path = "../core"}
1111
log = "0.4"
1212
cfg-if = "1"
13+
libm = "0.2.15"
1314
crossbeam-channel = {version = "0.5", optional = true}
1415
fern = {version = "0.6", optional = true}
1516
chrono = {version = "0.4", optional = true}
1617

1718
[features]
18-
std = ["chrono", "fern", "crossbeam-channel"]
19+
std = ["chrono", "fern", "crossbeam-channel", "alloc"]
1920
dbg = ["std"]
21+
alloc = []
2022

2123
[dev-dependencies]
2224
criterion = "0.3"

common/src/audio/audio_resampler.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use alloc::{string::String, vec::Vec};
2+
13
use magenboy_core::apu::audio_device::{Sample, AudioDevice, StereoSample, BUFFER_SIZE};
24

35
pub trait AudioResampler{

0 commit comments

Comments
 (0)