Skip to content

Commit cd71e27

Browse files
authored
fix bug from issue 181 (#182)
read_rom as been replaced by load_from_file to handle .elf roms in main.rs
1 parent 8387a9b commit cd71e27

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

core/src/cartridge/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn try_load_zip(data: &[u8]) -> LoadRomResult {
5656
))
5757
}
5858

59-
pub(super) fn load_from_file(path: &Path) -> LoadRomResult {
59+
pub fn load_from_file(path: &Path) -> LoadRomResult {
6060
let bytes = read_bin_file(path)?;
6161

6262
match path.extension() {

core/src/cartridge/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod rtc;
1818
use gpio::Gpio;
1919

2020
mod builder;
21-
mod loader;
21+
pub mod loader;
2222
pub use builder::GamepakBuilder;
2323

2424
pub const GPIO_PORT_DATA: u32 = 0xC4;

platform/rustboyadvance-sdl2/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use rustboyadvance_core::prelude::*;
2626

2727
use rustboyadvance_utils::FpsCounter;
2828

29+
use rustboyadvance_core::cartridge::loader::{load_from_file, LoadRom};
30+
2931
const LOG_DIR: &str = ".logs";
3032

3133
fn ask_download_bios() {
@@ -161,7 +163,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
161163
let (audio_interface, _sdl_audio_device_new) =
162164
audio::create_audio_player(&sdl_context)?;
163165
_sdl_audio_device = _sdl_audio_device_new;
164-
let rom = opts.read_rom()?.into_boxed_slice();
166+
let rom = match load_from_file(&opts.rom)? {
167+
LoadRom::Raw(data) => data.into_boxed_slice(),
168+
LoadRom::Elf { data, .. } => data.into_boxed_slice(),
169+
};
165170
gba = Box::new(GameBoyAdvance::from_saved_state(
166171
&save,
167172
bios_bin.clone(),

0 commit comments

Comments
 (0)