Forgot to restore scheduler pointers when restoring savestate :)
Former-commit-id: c6968e6767f0aa996a908a1444ce63bafd8b427d Former-commit-id: ce636212835f50745c7edeb32e1fed925850b7c8
This commit is contained in:
parent
b003dc950f
commit
fc7ad01cc0
|
@ -2,7 +2,7 @@ use super::arm7tdmi::memory::{MemoryAccess, MemoryInterface};
|
|||
use super::cartridge::BackupMedia;
|
||||
use super::interrupt::{self, Interrupt, InterruptConnect, SharedInterruptFlags};
|
||||
use super::iodev::consts::{REG_FIFO_A, REG_FIFO_B};
|
||||
use super::sched::{EventType, Scheduler, SharedScheduler};
|
||||
use super::sched::{EventType, Scheduler, SchedulerConnect, SharedScheduler};
|
||||
use super::sysbus::SysBus;
|
||||
|
||||
use num::FromPrimitive;
|
||||
|
@ -206,6 +206,12 @@ impl InterruptConnect for DmaController {
|
|||
}
|
||||
}
|
||||
|
||||
impl SchedulerConnect for DmaController {
|
||||
fn connect_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.scheduler = scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
impl DmaController {
|
||||
pub fn new(interrupt_flags: SharedInterruptFlags, scheduler: SharedScheduler) -> DmaController {
|
||||
DmaController {
|
||||
|
|
|
@ -11,7 +11,7 @@ use super::dma::DmaController;
|
|||
use super::gpu::*;
|
||||
use super::interrupt::*;
|
||||
use super::iodev::*;
|
||||
use super::sched::{EventType, Scheduler, SharedScheduler};
|
||||
use super::sched::{EventType, Scheduler, SchedulerConnect, SharedScheduler};
|
||||
use super::sound::SoundController;
|
||||
use super::sysbus::SysBus;
|
||||
use super::timer::Timers;
|
||||
|
@ -134,8 +134,7 @@ impl GameBoyAdvance {
|
|||
let mut cartridge = decoded.cartridge;
|
||||
cartridge.set_rom_bytes(rom);
|
||||
io_devs.connect_irq(interrupts.clone());
|
||||
io_devs.gpu.set_scheduler(scheduler.clone());
|
||||
io_devs.sound.set_scheduler(scheduler.clone());
|
||||
io_devs.connect_scheduler(scheduler.clone());
|
||||
let mut sysbus = Shared::new(SysBus::new_with_memories(
|
||||
scheduler.clone(),
|
||||
io_devs.clone(),
|
||||
|
@ -194,9 +193,8 @@ impl GameBoyAdvance {
|
|||
self.sysbus.set_ewram(decoded.ewram);
|
||||
// Redistribute shared pointers
|
||||
self.io_devs.connect_irq(self.interrupt_flags.clone());
|
||||
self.io_devs.gpu.set_scheduler(self.scheduler.clone());
|
||||
self.io_devs.sound.set_scheduler(self.scheduler.clone());
|
||||
self.sysbus.set_scheduler(self.scheduler.clone());
|
||||
self.io_devs.connect_scheduler(self.scheduler.clone());
|
||||
self.sysbus.connect_scheduler(self.scheduler.clone());
|
||||
self.sysbus.set_io_devices(self.io_devs.clone());
|
||||
self.sysbus.cartridge.update_from(decoded.cartridge);
|
||||
self.sysbus.init(self.cpu.weak_ptr());
|
||||
|
|
|
@ -183,7 +183,7 @@ pub struct Gpu {
|
|||
pub state: GpuState,
|
||||
interrupt_flags: SharedInterruptFlags,
|
||||
|
||||
/// When deserializing this struct using serde, make sure to call Gpu:::set_scheduler
|
||||
/// When deserializing this struct using serde, make sure to call connect_scheduler
|
||||
#[serde(skip)]
|
||||
#[serde(default = "Scheduler::new_shared")]
|
||||
scheduler: SharedScheduler,
|
||||
|
@ -228,6 +228,12 @@ impl InterruptConnect for Gpu {
|
|||
}
|
||||
}
|
||||
|
||||
impl SchedulerConnect for Gpu {
|
||||
fn connect_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.scheduler = scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
impl Gpu {
|
||||
pub fn new(mut scheduler: SharedScheduler, interrupt_flags: SharedInterruptFlags) -> Gpu {
|
||||
scheduler.push_gpu_event(GpuEvent::HDraw, CYCLES_HDRAW);
|
||||
|
@ -268,10 +274,6 @@ impl Gpu {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.scheduler = scheduler;
|
||||
}
|
||||
|
||||
pub fn write_dispcnt(&mut self, value: u16) {
|
||||
let new_dispcnt = DisplayControl(value);
|
||||
let old_mode = self.dispcnt.mode();
|
||||
|
|
|
@ -6,6 +6,7 @@ use super::gpu::regs::WindowFlags;
|
|||
use super::gpu::*;
|
||||
use super::interrupt::{InterruptConnect, InterruptController, SharedInterruptFlags};
|
||||
use super::keypad;
|
||||
use super::sched::{SchedulerConnect, SharedScheduler};
|
||||
use super::sound::SoundController;
|
||||
use super::sysbus::SysBusPtr;
|
||||
use super::timer::Timers;
|
||||
|
@ -77,6 +78,15 @@ impl InterruptConnect for IoDevices {
|
|||
}
|
||||
}
|
||||
|
||||
impl SchedulerConnect for IoDevices {
|
||||
fn connect_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.gpu.connect_scheduler(scheduler.clone());
|
||||
self.sound.connect_scheduler(scheduler.clone());
|
||||
self.dmac.connect_scheduler(scheduler.clone());
|
||||
self.timers.connect_scheduler(scheduler.clone());
|
||||
}
|
||||
}
|
||||
|
||||
impl Bus for IoDevices {
|
||||
fn read_16(&mut self, addr: Addr) -> u16 {
|
||||
let io = self;
|
||||
|
|
|
@ -212,6 +212,10 @@ impl Scheduler {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait SchedulerConnect {
|
||||
fn connect_scheduler(&mut self, scheduler: SharedScheduler);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
|
|
|
@ -105,6 +105,12 @@ pub struct SoundController {
|
|||
output_buffer: Vec<StereoSample<f32>>,
|
||||
}
|
||||
|
||||
impl SchedulerConnect for SoundController {
|
||||
fn connect_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.scheduler = scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
impl SoundController {
|
||||
pub fn new(mut scheduler: SharedScheduler, audio_device_sample_rate: f32) -> SoundController {
|
||||
let resampler = CosineResampler::new(32768_f32, audio_device_sample_rate);
|
||||
|
@ -143,10 +149,6 @@ impl SoundController {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.scheduler = scheduler;
|
||||
}
|
||||
|
||||
pub fn handle_read(&self, io_addr: u32) -> u16 {
|
||||
let value = match io_addr {
|
||||
REG_SOUNDCNT_X => cbit(7, self.mse),
|
||||
|
|
|
@ -7,7 +7,7 @@ use super::bus::*;
|
|||
use super::cartridge::Cartridge;
|
||||
use super::dma::DmaNotifer;
|
||||
use super::iodev::{IoDevices, WaitControl};
|
||||
use super::sched::Scheduler;
|
||||
use super::sched::*;
|
||||
use super::util::{Shared, WeakPointer};
|
||||
|
||||
pub mod consts {
|
||||
|
@ -158,6 +158,12 @@ pub struct SysBus {
|
|||
|
||||
pub type SysBusPtr = WeakPointer<SysBus>;
|
||||
|
||||
impl SchedulerConnect for SysBus {
|
||||
fn connect_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.scheduler = scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
impl SysBus {
|
||||
pub fn new_with_memories(
|
||||
scheduler: Shared<Scheduler>,
|
||||
|
@ -212,10 +218,6 @@ impl SysBus {
|
|||
&self.iwram
|
||||
}
|
||||
|
||||
pub fn set_scheduler(&mut self, s: Shared<Scheduler>) {
|
||||
self.scheduler = s;
|
||||
}
|
||||
|
||||
pub fn set_io_devices(&mut self, io_devs: Shared<IoDevices>) {
|
||||
self.io = io_devs;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::dma::DmaController;
|
||||
use super::interrupt::{self, Interrupt, InterruptConnect, SharedInterruptFlags};
|
||||
use super::iodev::consts::*;
|
||||
use super::sched::{EventType, Scheduler, SharedScheduler};
|
||||
use super::sched::{EventType, Scheduler, SchedulerConnect, SharedScheduler};
|
||||
use super::sound::SoundController;
|
||||
|
||||
use num::FromPrimitive;
|
||||
|
@ -109,6 +109,12 @@ impl InterruptConnect for Timers {
|
|||
}
|
||||
}
|
||||
|
||||
impl SchedulerConnect for Timers {
|
||||
fn connect_scheduler(&mut self, scheduler: SharedScheduler) {
|
||||
self.scheduler = scheduler;
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Index<usize> for Timers {
|
||||
type Output = Timer;
|
||||
fn index(&self, index: usize) -> &Self::Output {
|
||||
|
|
Reference in a new issue