Skip to content
This repository was archived by the owner on Dec 29, 2024. It is now read-only.

Commit 9c13a45

Browse files
committed
Ugly hack around static mut warning.
I also opened a bunch of tickets about giving Neotron Applications a critical-section impl (has to go all the way back to the BIOS) so we can just use grounded instead.
1 parent a5b01e3 commit 9c13a45

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

neoplay/src/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#![cfg_attr(target_os = "none", no_std)]
22
#![cfg_attr(target_os = "none", no_main)]
33

4-
use core::fmt::Write;
4+
use core::{fmt::Write, ptr::addr_of_mut};
55

6-
static mut FILE_BUFFER: [u8; 192 * 1024] = [0u8; 192 * 1024];
6+
const FILE_BUFFER_LEN: usize = 192 * 1024;
7+
static mut FILE_BUFFER: [u8; FILE_BUFFER_LEN] = [0u8; FILE_BUFFER_LEN];
78

89
mod player;
910

@@ -32,8 +33,11 @@ fn real_main() -> Result<(), neotron_sdk::Error> {
3233
let _ = writeln!(stdout, "Loading {:?}...", filename);
3334
let path = neotron_sdk::path::Path::new(&filename)?;
3435
let f = neotron_sdk::File::open(path, neotron_sdk::Flags::empty())?;
35-
let n = f.read(unsafe { &mut FILE_BUFFER })?;
36-
let file_buffer = unsafe { &mut FILE_BUFFER[0..n] };
36+
let file_buffer = unsafe {
37+
let file_buffer = &mut *addr_of_mut!(FILE_BUFFER);
38+
let n = f.read(file_buffer)?;
39+
&file_buffer[0..n]
40+
};
3741
drop(f);
3842
// Set 16-bit stereo, 44.1 kHz
3943
let dsp_path = neotron_sdk::path::Path::new("AUDIO:")?;

0 commit comments

Comments
 (0)