Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
Also switched to vendored imgui until imgui-winit-support is updated
  • Loading branch information
kelpsyberry committed Dec 3, 2023
1 parent 92865f2 commit 25e3081
Show file tree
Hide file tree
Showing 25 changed files with 750 additions and 257 deletions.
4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ debugger-hooks = ["bft-r", "bft-w"]

[dependencies]
emu-utils = { git = "https://github.com/kelpsyberry/emu-utils" }
proc-bitfield = { version = "0.2", features = ["nightly"] }
bitflags = "1.2"
proc-bitfield = { version = "0.3", features = ["nightly"] }
bitflags = "2.4"
cfg-if = "1.0"
slog = { version = "2.7", optional = true }
serde = { version = "1.0", features = ["derive"] }
Expand Down
11 changes: 3 additions & 8 deletions core/src/cpu/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct MemWatchpointSubTable(pub [Option<Box<MemWatchpointLeafTable>>; 0x800
pub struct MemWatchpointLeafTable(pub [usize; MWLT_ENTRY_COUNT as usize]);

bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct MemWatchpointRwMask: u8 {
const READ = 1 << 0;
const WRITE = 1 << 1;
Expand Down Expand Up @@ -76,15 +77,9 @@ impl MemWatchpointRootTable {

pub(super) fn remove(&mut self, addr: u32, size: u8, rw: MemWatchpointRwMask) {
let root_i = (addr >> 21) as usize;
let sub_table = match &mut self.0[root_i] {
Some(sub_table_ptr) => sub_table_ptr,
None => return,
};
let Some(sub_table) = &mut self.0[root_i] else { return };
let sub_i = (addr >> 10 & 0x7FF) as usize;
let leaf_table = match &mut sub_table.0[sub_i] {
Some(leaf_table_ptr) => leaf_table_ptr,
None => return,
};
let Some(leaf_table) = &mut sub_table.0[sub_i] else { return };
let mut mask = rw.bits() as usize;
for i in 0..size.trailing_zeros() {
mask |= mask << (2 << i);
Expand Down
1 change: 1 addition & 0 deletions core/src/emu/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{cpu, utils::Savestate};
use bitflags::bitflags;

bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Keys: u32 {
const A = 1;
const B = 1 << 1;
Expand Down
23 changes: 11 additions & 12 deletions frontend/desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,18 @@ dust-wgpu-2d = { path = "../../render/wgpu-2d" }
dust-wgpu-3d = { path = "../../render/wgpu-3d", features = ["threaded"] }

# UI
winit = { version = "0.27", features = ["serde"] }
wgpu = "0.14"
# TODO: Switch to imgui 0.9 when it's released with the docking API
imgui = { git = "https://github.com/imgui-rs/imgui-rs", features = ["docking", "tables-api"] }
imgui-winit-support = { git = "https://github.com/imgui-rs/imgui-rs" }
winit = { version = "0.29", features = ["serde"] }
wgpu = { git = "https://github.com/gfx-rs/wgpu" }
imgui = { version = "0.11", features = ["docking", "tables-api"] }
imgui-winit-support = { git = "https://github.com/kelpsyberry/imgui-rs" }
imgui-wgpu = { git = "https://github.com/kelpsyberry/imgui-wgpu" }
opener = "0.5"
opener = "0.6"

# System resources
rfd = "0.10"
rfd = "0.12"
directories = "5.0"
copypasta = "0.8"
cpal = "0.14"
copypasta = "0.10"
cpal = "0.15"
chrono = { version = "0.4", features = ["serde"] }
libc = "0.2"

Expand All @@ -59,8 +58,8 @@ ahash = "0.8"
futures-executor = "0.3"
crossbeam-channel = "0.5"
parking_lot = "0.12"
bitflags = "1.3"
miniz_oxide = { version = "0.6", features = ["simd"] }
bitflags = "2.4"
miniz_oxide = { version = "0.7", features = ["simd"] }
fatfs = { version = "0.3", optional = true }
tempdir = { version = "0.3", optional = true }

Expand All @@ -83,5 +82,5 @@ realfft = { version = "3.0", optional = true }
gdb-protocol = { version = "0.1", optional = true }

[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.24"
cocoa = "0.25"
objc = "0.2"
12 changes: 8 additions & 4 deletions frontend/desktop/src/audio/input/cpal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,30 @@ impl InputStream {
fract: 0.0,
};

let err_callback = |err| panic!("Error in default audio output device stream: {err}");
let err_callback = |err| panic!("Error in default audio input device stream: {err}");
let stream = match supported_input_config.sample_format() {
SampleFormat::U16 => input_device.build_input_stream(
&supported_input_config.config(),
move |data: &[u16], _| input_data.fill(data),
err_callback,
None,
),
SampleFormat::I16 => input_device.build_input_stream(
&supported_input_config.config(),
move |data: &[i16], _| input_data.fill(data),
err_callback,
None,
),
SampleFormat::F32 => input_device.build_input_stream(
&supported_input_config.config(),
move |data: &[f32], _| input_data.fill(data),
err_callback,
None,
),
_ => panic!("Unsupported audio input sample format"),
}
.ok()?;
stream.play().expect("Couldn't start audio output stream");
stream.play().expect("couldn't start audio input stream");

Some(InputStream {
_stream: stream,
Expand Down Expand Up @@ -86,7 +90,7 @@ struct InputData {
}

impl InputData {
fn fill<T: Sample>(&mut self, data: &[T]) {
fn fill<T: Sample>(&mut self, data: &[T]) where f64: cpal::FromSample<T> {
if let Some(interp) = self.interp_rx.try_iter().last() {
self.interp = interp;
}
Expand All @@ -95,7 +99,7 @@ impl InputData {
for input_samples in data.chunks(self.channels as usize) {
let mut input_sample = 0.0;
for sample in input_samples {
input_sample += sample.to_f32() as f64;
input_sample += sample.to_sample::<f64>();
}
self.interp
.push_input_sample([input_sample / self.channels as f64]);
Expand Down
12 changes: 8 additions & 4 deletions frontend/desktop/src/audio/output/cpal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,24 @@ impl OutputStream {
&supported_output_config.config(),
move |data: &mut [u16], _| output_data.fill(data),
err_callback,
None,
),
SampleFormat::I16 => output_device.build_output_stream(
&supported_output_config.config(),
move |data: &mut [i16], _| output_data.fill(data),
err_callback,
None,
),
SampleFormat::F32 => output_device.build_output_stream(
&supported_output_config.config(),
move |data: &mut [f32], _| output_data.fill(data),
err_callback,
None,
),
_ => panic!("Unsupported audio output sample format"),
}
.ok()?;
stream.play().expect("Couldn't start audio output stream");
stream.play().expect("couldn't start audio output stream");

Some(OutputStream {
_stream: stream,
Expand Down Expand Up @@ -143,7 +147,7 @@ struct OutputData {
}

impl OutputData {
fn fill<T: Sample>(&mut self, data: &mut [T]) {
fn fill<T: Sample + cpal::FromSample<f32>>(&mut self, data: &mut [T]) {
if let Some(interp) = self.interp_rx.try_iter().last() {
self.interp = interp;
}
Expand All @@ -170,8 +174,8 @@ impl OutputData {
return;
}
let result = self.interp.get_output_sample(fract);
data[output_i] = T::from(&(result[0] as f32 * volume));
data[output_i + 1] = T::from(&(result[1] as f32 * volume));
data[output_i] = T::from_sample(result[0] as f32 * volume);
data[output_i + 1] = T::from_sample(result[1] as f32 * volume);
fract += sample_rate_ratio;
output_i += 2;
}
Expand Down
1 change: 1 addition & 0 deletions frontend/desktop/src/debug_views/common/disasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use imgui::{Key, MouseButton, StyleColor, StyleVar, Ui, WindowHoveredFlags};
use std::{fmt::Write, num::NonZeroU8};

bitflags::bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Flags: u8 {
// Creation flags
const SHOW_VIEW_OPTIONS = 1 << 0;
Expand Down
1 change: 1 addition & 0 deletions frontend/desktop/src/emu/gdb_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use gdb_protocol::packet::{CheckedPacket, Kind as PacketKind};
use std::{cell::RefCell, io::Write, net::ToSocketAddrs, rc::Rc, str};

bitflags::bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
struct ThreadMask: u8 {
const ARM9 = 1 << 0;
const ARM7 = 1 << 1;
Expand Down
26 changes: 24 additions & 2 deletions frontend/desktop/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ pub use map::Map;
mod state;
pub use state::{Changes, State};
pub mod trigger;
pub mod key_codes;
pub use key_codes::{KeyCode, ScanCode};

use winit::event::{ScanCode, VirtualKeyCode};
use winit::keyboard::PhysicalKey;

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum Action {
Expand All @@ -16,4 +18,24 @@ pub enum Action {
ToggleFullWindowScreen,
}

pub type PressedKey = (Option<VirtualKeyCode>, ScanCode);
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum PressedKey {
KeyCode(KeyCode),
ScanCode(ScanCode),
}

impl TryFrom<PhysicalKey> for PressedKey {
type Error = ();

fn try_from(value: PhysicalKey) -> Result<Self, ()> {
Ok(match value {
PhysicalKey::Code(key_code) => PressedKey::KeyCode(key_code.into()),
PhysicalKey::Unidentified(scan_code) => {
let Ok(scan_code) = scan_code.try_into() else {
return Err(());
};
PressedKey::ScanCode(scan_code)
}
})
}
}
Loading

0 comments on commit 25e3081

Please sign in to comment.