From 84db854a06b5ca874af64cbdf472fd450fb79d90 Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Tue, 25 Feb 2020 00:11:10 +0200 Subject: [PATCH] chore: Make GameBoyAdvance the the bios argument as boxed slice rather then a Vec On windows, the Vec may sit on the stack.. Former-commit-id: b8aa77858291c1b7ee6bfbfbec92646f18e819de --- rustboyadvance-jni/src/lib.rs | 2 +- rustboyadvance-minifb/src/main.rs | 2 +- rustboyadvance-sdl2/src/main.rs | 4 ++-- src/core/gba.rs | 4 ++-- src/core/sysbus.rs | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rustboyadvance-jni/src/lib.rs b/rustboyadvance-jni/src/lib.rs index b8d8e1b..e2a1a62 100644 --- a/rustboyadvance-jni/src/lib.rs +++ b/rustboyadvance-jni/src/lib.rs @@ -146,7 +146,7 @@ pub mod bindings { let hw = Hardware { key_state: 0xffff }; let hw = Rc::new(RefCell::new(hw)); - let mut gba = GameBoyAdvance::new(bios_rom, gamepak, hw.clone(), hw.clone(), hw.clone()); + let mut gba = GameBoyAdvance::new(bios_rom.into_boxed_slice(), gamepak, hw.clone(), hw.clone(), hw.clone()); if skip_bios != 0 { gba.skip_bios(); } diff --git a/rustboyadvance-minifb/src/main.rs b/rustboyadvance-minifb/src/main.rs index 66280b3..c0d7a90 100644 --- a/rustboyadvance-minifb/src/main.rs +++ b/rustboyadvance-minifb/src/main.rs @@ -107,7 +107,7 @@ fn main() { let mut fps_counter = FpsCounter::default(); let mut gba = GameBoyAdvance::new( - bios_bin, + bios_bin.into_boxed_slice(), cart, minifb.clone(), minifb.clone(), diff --git a/rustboyadvance-sdl2/src/main.rs b/rustboyadvance-sdl2/src/main.rs index 15bd69a..845f92e 100644 --- a/rustboyadvance-sdl2/src/main.rs +++ b/rustboyadvance-sdl2/src/main.rs @@ -137,7 +137,7 @@ fn main() -> Result<(), Box> { .build()?; let mut gba = GameBoyAdvance::new( - bios_bin, + bios_bin.into_boxed_slice(), gamepak, video.clone(), audio.clone(), @@ -255,7 +255,7 @@ fn main() -> Result<(), Box> { // create a new emulator - TODO, export to a function gba = GameBoyAdvance::new( - bios_bin, + bios_bin.into_boxed_slice(), gamepak, video.clone(), audio.clone(), diff --git a/src/core/gba.rs b/src/core/gba.rs index fb4c91d..5e9ca10 100644 --- a/src/core/gba.rs +++ b/src/core/gba.rs @@ -34,7 +34,7 @@ struct SaveState { impl GameBoyAdvance { pub fn new( - bios_rom: Vec, + bios_rom: Box<[u8]>, gamepak: Cartridge, video_device: Rc>, audio_device: Rc>, @@ -209,7 +209,7 @@ mod tests { impl InputInterface for DummyInterface {} fn make_mock_gba(rom: &[u8]) -> GameBoyAdvance { - let bios = vec![0; 0x4000]; + let bios = vec![0; 0x4000].into_boxed_slice(); let cartridge = GamepakBuilder::new() .buffer(rom) .with_sram() diff --git a/src/core/sysbus.rs b/src/core/sysbus.rs index 749f7fe..519dc91 100644 --- a/src/core/sysbus.rs +++ b/src/core/sysbus.rs @@ -123,11 +123,11 @@ pub struct SysBus { } impl SysBus { - pub fn new(io: IoDevices, bios_rom: Vec, cartridge: Cartridge) -> SysBus { + pub fn new(io: IoDevices, bios_rom: Box<[u8]>, cartridge: Cartridge) -> SysBus { SysBus { io: io, - bios: BoxedMemory::new(bios_rom.into_boxed_slice()), + bios: BoxedMemory::new(bios_rom), onboard_work_ram: BoxedMemory::new(vec![0; WORK_RAM_SIZE].into_boxed_slice()), internal_work_ram: BoxedMemory::new(vec![0; INTERNAL_RAM_SIZE].into_boxed_slice()), cartridge: cartridge,