-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
target = "xbox.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "rustnxdk" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
|
||
# Default cargo profile | ||
[profile.dev] | ||
panic = "abort" | ||
|
||
[profile.release] | ||
panic = "abort" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
PROJECT_NAME = rustnxdk | ||
XISO_NAME = rusttest | ||
XBE_TITLE = rusttest | ||
NXDK_DIR = /home/$(USER)/nxdk | ||
OUTPUT_DIR = bin | ||
RUSTFLAGS := --target xbox.json -Zbuild-std=core | ||
|
||
CXBE = $(NXDK_DIR)/tools/cxbe/cxbe | ||
XISO = $(NXDK_DIR)/tools/extract-xiso/build/extract-xiso | ||
|
||
EXEC_DIR = target/xbox/release | ||
|
||
ifeq ($(DEBUG),y) | ||
EXEC_DIR = target/xbox/debug | ||
else | ||
RUSTFLAGS += --release | ||
endif | ||
|
||
all: | ||
@mkdir -p $(OUTPUT_DIR) | ||
@cargo build $(RUSTFLAGS) | ||
@cp $(EXEC_DIR)/$(PROJECT_NAME).exe ./main.exe | ||
$(CXBE) -OUT:default.xbe -TITLE:$(XBE_TITLE) ./main.exe | ||
@mv default.xbe $(OUTPUT_DIR) | ||
$(XISO) -c $(OUTPUT_DIR) $(XISO_NAME).iso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extern crate core; | ||
use std::env; | ||
|
||
fn main() { | ||
let nxdk_dir = match env::var("NXDK_DIR") { | ||
Ok(value) => value, | ||
Err(e) => panic!("Error getting NXDK_DIR variable: {}", e) | ||
}; | ||
|
||
println!("cargo:build-std=core"); | ||
println!("cargo:rustc-link-search={}/lib/xboxkrnl", nxdk_dir); | ||
println!("cargo:rustc-link-lib=static=libxboxkrnl"); | ||
println!("cargo:rustc-link-search={}/lib/", nxdk_dir); | ||
println!("cargo:rustc-link-lib=static=libpdclib"); | ||
println!("cargo:rustc-link-lib=static=libwinapi"); | ||
println!("cargo:rustc-link-lib=static=libxboxrt"); | ||
println!("cargo:rustc-link-lib=static=libnxdk_hal"); | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#![no_std] // don't link the Rust standard library | ||
#![no_main] // disable all Rust-level entry points | ||
|
||
use core::panic::PanicInfo; | ||
|
||
#[link (name="libnxdk_hal")] | ||
extern "C" { | ||
fn XVideoSetMode(_: i32, _: i32, _: i32, _:i32); | ||
fn debugPrint(_: &str); | ||
} | ||
|
||
#[no_mangle] | ||
fn main() -> i32 { | ||
unsafe { | ||
// 640x480, 32bpp, 60Hz | ||
XVideoSetMode(640, 480, 32, 60); | ||
debugPrint("Hello from Rust"); | ||
} | ||
loop { | ||
|
||
} | ||
} | ||
|
||
// This function is called on panic. | ||
#[panic_handler] | ||
fn panic(_info: &PanicInfo) -> ! { | ||
loop {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"abi-return-struct-as-int": true, | ||
"arch": "x86", | ||
"cpu": "pentium3", | ||
"data-layout": "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32-a:0:32-S32", | ||
"dll-prefix": "", | ||
"dll-suffix": ".dll", | ||
"env": "msvc", | ||
"exe-suffix": ".exe", | ||
"executables": true, | ||
"is-like-msvc": false, | ||
"is-like-windows": true, | ||
"linker-flavor": "lld-link", | ||
"linker-is-gnu": false, | ||
"lld-flavor": "link", | ||
"llvm-target": "i386-pc-win32", | ||
"max-atomic-width": 64, | ||
"os": "none", | ||
"pre-link-args": { | ||
"lld-link": [ | ||
"-subsystem:windows", | ||
"-fixed", | ||
"-base:0x00010000", | ||
"-stack:65536", | ||
"-merge:.edata=.edataxb" | ||
] | ||
}, | ||
"requires-uwtable": true, | ||
"target-pointer-width": "32", | ||
"target-family": "windows", | ||
"vendor": "pc" | ||
} |