Skip to content

Commit 4d8c3a5

Browse files
committed
make a freestanding library (which does not need C)
caveat: it does NOT exit cleanly
1 parent 1883fdf commit 4d8c3a5

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ debug = true
1818
[profile.release]
1919
panic = "abort"
2020
lto = true
21-
debug = true
2221

2322
[dependencies]
2423
rlibc = "*"

src/lib.rs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,34 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
88
pub const fn null<T>() -> *mut T { 0 as *mut T }
99

1010
#[no_mangle]
11-
pub unsafe extern fn rust_main() {
12-
consoleInit(null());
13-
gfxInitDefault();
11+
pub extern "C" fn main() -> ! {
12+
unsafe {
13+
consoleInit(null());
14+
gfxInitDefault();
1415

15-
printf("\x1b[16;16HPress PLUS to exit.".as_ptr() as *const i8);
16+
printf("\x1b[16;16HPress PLUS to exit.".as_ptr() as *const i8);
1617

17-
while appletMainLoop() {
18-
hidScanInput();
18+
while appletMainLoop() {
19+
hidScanInput();
1920

20-
let k_down = HidControllerKeys(hidKeysDown(HidControllerID::CONTROLLER_P1_AUTO) as u32);
21+
let k_down = HidControllerKeys(hidKeysDown(HidControllerID::CONTROLLER_P1_AUTO) as u32);
2122

22-
if k_down == HidControllerKeys::KEY_PLUS {
23-
break;
24-
}
23+
if k_down == HidControllerKeys::KEY_PLUS {
24+
break;
25+
}
26+
27+
printf("This key is pressed: %d\n".as_ptr() as *const i8, k_down);
2528

26-
printf("This key is pressed: %d\n".as_ptr() as *const i8, k_down);
29+
gfxFlushBuffers();
30+
gfxSwapBuffers();
31+
gfxWaitForVsync();
32+
}
2733

28-
gfxFlushBuffers();
29-
gfxSwapBuffers();
30-
gfxWaitForVsync();
34+
gfxExit();
3135
}
3236

33-
gfxExit();
37+
// exit(0)
38+
loop {}
3439
}
3540

3641
pub mod lang_items;

src/main.c

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)