use std::{
  fs::{self, File}, sync::Arc
};

use bgm::format::BgmFormat;
use memmap2::{Mmap, MmapOptions};

pub mod bgm;

pub struct Manager {
  bgm_format: bgm::format::BgmFormat,
  bgm_file: Arc<Mmap>,
}

impl Manager {
  pub fn new() -> Self {
    let bgm_format = BgmFormat::new(fs::read("assets/thbgm.fmt").unwrap());
    let bgm_file = Arc::new(unsafe {
      MmapOptions::new().map(&File::open("./thbgm.dat").unwrap()).expect("failed to open thbgm.dat")
    });
    Self { bgm_format, bgm_file }
  }
}
