1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#![feature(restricted_std)]
use libctru::raw::{
aptMainLoop, consoleInit, gfxExit, gfxFlushBuffers, gfxInitDefault, gfxScreen_t_GFX_BOTTOM,
gfxSwapBuffers, gspWaitForEvent, hidKeysDown, hidScanInput, GSPGPU_Event_GSPGPU_EVENT_VBlank0,
KEY_START,
};
use std::{
os::raw::{c_char, c_int},
ptr::null_mut,
};
#[no_mangle]
pub extern "C" fn main(_argc: c_int, _argv: *const *const c_char) -> c_int {
std::panic::set_hook(Box::new(|info| unsafe {
consoleInit(gfxScreen_t_GFX_BOTTOM, null_mut());
println!("Rust panic: \n {}\nPress start to crash", info);
while aptMainLoop() {
hidScanInput();
let keys = hidKeysDown();
if keys & (KEY_START as u32) != 0 {
break;
}
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForEvent(GSPGPU_Event_GSPGPU_EVENT_VBlank0, true);
}
}));
unsafe {
gfxInitDefault();
while aptMainLoop() {
hidScanInput();
let keys = hidKeysDown();
if keys & (KEY_START as u32) != 0 {
break;
}
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForEvent(GSPGPU_Event_GSPGPU_EVENT_VBlank0, true);
}
gfxExit();
}
0
}
|