use core::sync::atomic::Ordering;
use bevy::{platform::sync::atomic::AtomicBool, prelude::*};
use super::*;
#[derive(Default)]
pub struct AgbUnpackPlugin;
impl Plugin for AgbUnpackPlugin {
fn build(&self, app: &mut App) {
static UNPACKED: AtomicBool = AtomicBool::new(false);
if UNPACKED.swap(true, Ordering::AcqRel) {
return;
}
#[expect(unsafe_code, reason = "unpacking Gba is unsafe")]
let gba = unsafe { agb::Gba::new_in_entry() };
let agb::Gba {
display,
sound,
mixer,
save,
timers,
dma,
..
} = gba;
app.insert_non_send_resource(timers)
.insert_non_send_resource(sound)
.insert_non_send_resource(mixer)
.insert_non_send_resource(save)
.insert_non_send_resource(display)
.insert_non_send_resource(dma);
}
}