allow customisation of the backtrace website

This commit is contained in:
Corwin 2024-04-20 14:52:08 +01:00
parent 4419dfb0b5
commit 91da2c926a
No known key found for this signature in database

View file

@ -11,6 +11,8 @@ use crate::{
mod text; mod text;
static WEBSITE: Option<&str> = core::option_env!("AGBRS_BACKTRACE_WEBSITE");
pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! { pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! {
critical_section::with(|_cs| { critical_section::with(|_cs| {
dma3_exclusive(|| { dma3_exclusive(|| {
@ -20,7 +22,13 @@ pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! {
gba.dma.dma().dma3.disable(); gba.dma.dma().dma3.disable();
let mut gfx = gba.display.video.bitmap3(); let mut gfx = gba.display.video.bitmap3();
let qrcode_string_data = format!("https://agbrs.dev/crash#{trace}"); let website = WEBSITE.unwrap_or("https://agbrs.dev/crash");
let qrcode_string_data = if website.is_empty() {
format!("{trace}")
} else {
format!("{website}#{trace}")
};
crate::println!("Stack trace: {qrcode_string_data}"); crate::println!("Stack trace: {qrcode_string_data}");
let location = draw_qr_code(&mut gfx, &qrcode_string_data); let location = draw_qr_code(&mut gfx, &qrcode_string_data);
@ -29,7 +37,8 @@ pub fn render_backtrace(trace: &backtrace::Frames, info: &PanicInfo) -> ! {
text::BitmapTextRender::new(&mut gfx, (location, 8).into(), 0x0000); text::BitmapTextRender::new(&mut gfx, (location, 8).into(), 0x0000);
let _ = write!( let _ = write!(
&mut trace_text_render, &mut trace_text_render,
"The game crashed :(\nhttps://agbrs.dev/crash\n{trace}" "The game crashed :({}{website}\n{trace}",
if website.is_empty() { "" } else { "\n" }
); );
let mut panic_text_render = let mut panic_text_render =