cleanup some pak switching code
This commit is contained in:
parent
f3d8080a26
commit
e4174c7d4b
@ -31,7 +31,7 @@ pub enum PakType {
|
||||
pub struct PakHandler {
|
||||
pub read: fn(&mut device::Device, usize, u16, usize, usize),
|
||||
pub write: fn(&mut device::Device, usize, u16, usize, usize),
|
||||
pub get_type: fn() -> PakType,
|
||||
pub pak_type: PakType,
|
||||
}
|
||||
|
||||
pub fn process(device: &mut device::Device, channel: usize) {
|
||||
@ -59,7 +59,7 @@ pub fn process(device: &mut device::Device, channel: usize) {
|
||||
if device::events::get_event(device, device::events::EventType::PakSwitch).is_none()
|
||||
{
|
||||
device.pif.channels[channel].change_pak =
|
||||
(device.pif.channels[channel].pak_handler.unwrap().get_type)();
|
||||
device.pif.channels[channel].pak_handler.unwrap().pak_type;
|
||||
device.pif.channels[channel].pak_handler = None;
|
||||
device::events::create_event(
|
||||
device,
|
||||
@ -154,7 +154,7 @@ pub fn pak_switch_event(device: &mut device::Device) {
|
||||
let handler = device::controller::PakHandler {
|
||||
read: device::controller::mempak::read,
|
||||
write: device::controller::mempak::write,
|
||||
get_type: device::controller::mempak::get_type,
|
||||
pak_type: device::controller::PakType::MemPak,
|
||||
};
|
||||
channel.pak_handler = Some(handler);
|
||||
ui::audio::play_pak_switch(&mut device.ui, PakType::MemPak);
|
||||
@ -162,7 +162,7 @@ pub fn pak_switch_event(device: &mut device::Device) {
|
||||
let handler = device::controller::PakHandler {
|
||||
read: device::controller::rumble::read,
|
||||
write: device::controller::rumble::write,
|
||||
get_type: device::controller::rumble::get_type,
|
||||
pak_type: device::controller::PakType::RumblePak,
|
||||
};
|
||||
channel.pak_handler = Some(handler);
|
||||
ui::audio::play_pak_switch(&mut device.ui, PakType::RumblePak);
|
||||
|
||||
@ -90,7 +90,3 @@ pub fn write(device: &mut device::Device, channel: usize, address: u16, data: us
|
||||
device.ui.saves.mempak.1 = true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_type() -> device::controller::PakType {
|
||||
device::controller::PakType::MemPak
|
||||
}
|
||||
|
||||
@ -18,7 +18,3 @@ pub fn write(device: &mut device::Device, channel: usize, address: u16, data: us
|
||||
device::ui::input::set_rumble(&mut device.ui, channel, rumble);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_type() -> device::controller::PakType {
|
||||
device::controller::PakType::RumblePak
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ pub fn init(device: &mut device::Device) {
|
||||
let mempak_handler = device::controller::PakHandler {
|
||||
read: device::controller::mempak::read,
|
||||
write: device::controller::mempak::write,
|
||||
get_type: device::controller::mempak::get_type,
|
||||
pak_type: device::controller::PakType::MemPak,
|
||||
};
|
||||
|
||||
for i in 0..4 {
|
||||
|
||||
Reference in New Issue
Block a user