Fix some cargo-clippy, and broken sub-crates

Former-commit-id: 93db7bc11bff9a48f4d66e0a378cd77ab42ca197
Former-commit-id: a6ce714c2a6a4112ff30d748c0686b1b2da41c6b
This commit is contained in:
Michel Heily 2022-09-05 00:31:38 +03:00
parent 255806ff69
commit 12d9edf5c4
16 changed files with 40 additions and 32 deletions

3
Cargo.lock generated
View file

@ -1413,6 +1413,7 @@ dependencies = [
"jni",
"log 0.4.11",
"rustboyadvance-core",
"rustboyadvance-utils",
]
[[package]]
@ -1425,6 +1426,7 @@ dependencies = [
"libretro-sys",
"log 0.4.11",
"rustboyadvance-core",
"rustboyadvance-utils",
"unsafe_unwrap",
]
@ -1472,6 +1474,7 @@ dependencies = [
"js-sys",
"log 0.4.11",
"rustboyadvance-core",
"rustboyadvance-utils",
"wasm-bindgen",
"wasm-bindgen-console-logger",
"wasm-bindgen-test",

View file

@ -265,7 +265,7 @@ fn arm_decode(i: u32) -> (&'static str, String) {
}
(0b010, 0b0001) => {
if 0b010 == i.bit_range(20..23) {
Some(("BranchExchange", format!("exec_arm_bx")))
Some(("BranchExchange", "exec_arm_bx".to_string()))
} else {
None
}

View file

@ -336,9 +336,7 @@ impl<I: MemoryInterface> Arm7tdmiCore<I> {
}
if !LOAD || base_reg != dest_reg {
if !PRE_INDEX {
self.set_reg(base_reg, effective_addr);
} else if WRITEBACK {
if !PRE_INDEX || WRITEBACK{
self.set_reg(base_reg, effective_addr);
}
}

View file

@ -496,8 +496,6 @@ mod registers {
#[cfg(test)]
mod tests {
use super::*;
use std::cell::Cell;
use std::rc::Rc;
fn transmit(rtc: &mut Rtc, gpio_state: &GpioState, bit: u8) {
rtc.write(&gpio_state, 0b0100_u16 | (u16::from(bit) << 1));
@ -617,7 +615,7 @@ mod tests {
let mut bytes = [0];
receive_bytes(&mut rtc, &gpio_state, &mut bytes);
let mut read_status = registers::StatusRegister(bytes[0]);
let read_status = registers::StatusRegister(bytes[0]);
assert_eq!(read_status.mode_24h(), true);
}

View file

@ -577,18 +577,18 @@ mod tests {
macro_rules! update {
($cycles:expr) => {
sched.update($cycles);
let (event, cycles_late) = sched.pop_pending_event().unwrap();
assert_eq!(cycles_late, 0);
match event {
let (event, event_time) = sched.pop_pending_event().unwrap();
assert_eq!(event_time, sched.timestamp());
let next_event = match event {
EventType::Gpu(event) => gpu.on_event(
event,
cycles_late,
&mut dma_notifier,
#[cfg(not(feature = "no_video_interface"))]
&video_clone,
),
_ => panic!("Found unexpected event in queue!"),
}
};
sched.schedule(next_event);
};
}

View file

@ -109,12 +109,15 @@ pub struct Scheduler {
pub type SharedScheduler = Shared<Scheduler>;
impl Scheduler {
pub fn new_shared() -> SharedScheduler {
let sched = Scheduler {
pub fn new() -> Scheduler {
Scheduler {
timestamp: 0,
events: BinaryHeap::with_capacity(NUM_EVENTS),
};
SharedScheduler::new(sched)
}
}
pub fn new_shared() -> SharedScheduler {
Scheduler::new().make_shared()
}
pub fn make_shared(self) -> SharedScheduler {

View file

@ -11,6 +11,7 @@ crate-type = ["staticlib", "cdylib"]
[dependencies]
rustboyadvance-core = {path = "../../core/", features = ["no_video_interface"]}
rustboyadvance-utils = {path = "../../utils/" }
jni = "0.17.0"
log = {version = "0.4.8", features = ["release_max_level_info", "max_level_debug"]}

View file

@ -4,7 +4,7 @@ use std::sync::mpsc::{channel, Sender};
use std::thread;
use std::thread::JoinHandle;
use rustboyadvance_core::util::audio::Consumer;
use rustboyadvance_utils::audio::Consumer;
use jni::JavaVM;

View file

@ -1,5 +1,5 @@
use rustboyadvance_core::prelude::*;
use rustboyadvance_core::util::audio::{AudioRingBuffer, Producer};
use rustboyadvance_utils::audio::{AudioRingBuffer, Producer};
// use rustboyadvance_core::util::FpsCounter;
use std::cell::RefCell;

View file

@ -289,7 +289,7 @@ pub mod bindings {
pub unsafe extern "C" fn Java_com_mrmichel_rustboyadvance_EmulatorBindings_log(
_env: JNIEnv,
_obj: JClass,
ctx: jlong,
_ctx: jlong,
) {
info!("unimplemented")
}

View file

@ -11,6 +11,7 @@ crate-type = ["cdylib"]
[dependencies]
rustboyadvance-core = { path = "../../core/", features = ["no_video_interface"] }
rustboyadvance-utils = { path = "../../utils" }
log = "0.4.8"
libc = "0.2"
libretro-sys = "0.1.1"

View file

@ -13,7 +13,7 @@ use unsafe_unwrap::UnsafeUnwrap;
use rustboyadvance_core::keypad::Keys as GbaButton;
use rustboyadvance_core::prelude::*;
use rustboyadvance_core::util::audio::AudioRingBuffer;
use rustboyadvance_utils::audio::AudioRingBuffer;
use std::path::Path;
@ -115,7 +115,7 @@ impl libretro_backend::Core for RustBoyAdvanceCore {
let hwif = Rc::new(RefCell::new(HwInterface {
key_state: rustboyadvance_core::keypad::KEYINPUT_ALL_RELEASED,
audio_ring_buffer: AudioRingBuffer::new(),
audio_ring_buffer: Default::default(),
}));
let gba = GameBoyAdvance::new(
bios.into_boxed_slice(),

View file

@ -48,6 +48,7 @@ use rustboyadvance_core::prelude::*;
use rustboyadvance_utils::FpsCounter;
const LOG_DIR: &str = ".logs";
#[cfg(feature = "gdb")]
const DEFAULT_GDB_SERVER_ADDR: &'static str = "localhost:1337";
const CANVAS_WIDTH: u32 = SCREEN_WIDTH;
@ -243,6 +244,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
if with_gdbserver {
spawn_and_run_gdb_server(&mut gba, DEFAULT_GDB_SERVER_ADDR)?;
}
#[cfg(not(feature = "gdb"))]
if with_gdbserver {
panic!("Please compile me with 'gdb' feature")
}
let mut fps_counter = FpsCounter::default();
let frame_time = time::Duration::new(0, 1_000_000_000u32 / 60);

View file

@ -14,6 +14,7 @@ default = ["console_error_panic_hook"]
js-sys = "0.3.37"
wasm-bindgen = "0.2"
rustboyadvance-core = { path = "../../core" }
rustboyadvance-utils = { path = "../../utils" }
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires

View file

@ -11,7 +11,7 @@ use web_sys::CanvasRenderingContext2d;
use rustboyadvance_core::keypad as gba_keypad;
use rustboyadvance_core::prelude::*;
use rustboyadvance_core::util::audio::AudioRingBuffer;
use rustboyadvance_utils::audio::AudioRingBuffer;
use bit::BitIndex;
@ -42,7 +42,7 @@ impl Interface {
keyinput: gba_keypad::KEYINPUT_ALL_RELEASED,
sample_rate: audio_ctx.sample_rate() as i32,
audio_ctx: audio_ctx,
audio_ring_buffer: AudioRingBuffer::new(),
audio_ring_buffer: Default::default(),
})
}
}
@ -61,7 +61,7 @@ impl VideoInterface for Interface {
}
fn convert_sample(s: i16) -> f32 {
((s as f32) / 32767_f32)
(s as f32) / 32767_f32
}
impl AudioInterface for Interface {
@ -156,7 +156,7 @@ impl Emulator {
}
pub fn test_fps(&mut self) {
use rustboyadvance_core::util::FpsCounter;
use rustboyadvance_utils::FpsCounter;
let mut fps_counter = FpsCounter::default();

View file

@ -29,7 +29,7 @@ pub fn read_bin_file(filename: &Path) -> io::Result<Vec<u8>> {
Ok(buf)
}
pub fn write_bin_file(filename: &Path, data: &Vec<u8>) -> io::Result<()> {
pub fn write_bin_file(filename: &Path, data: &[u8]) -> io::Result<()> {
let mut f = File::create(filename)?;
f.write_all(data)?;
@ -94,11 +94,13 @@ pub mod audio {
cons: Consumer<i16>,
}
impl AudioRingBuffer {
pub fn new() -> AudioRingBuffer {
impl Default for AudioRingBuffer {
fn default() -> AudioRingBuffer {
AudioRingBuffer::new_with_capacity(2 * 4096)
}
}
impl AudioRingBuffer {
pub fn new_with_capacity(capacity: usize) -> AudioRingBuffer {
let rb = RingBuffer::new(capacity);
let (prod, cons) = rb.split();
@ -192,10 +194,6 @@ impl<T> Shared<T> {
pub fn new(t: T) -> Shared<T> {
Shared(Rc::new(UnsafeCell::new(t)))
}
pub unsafe fn inner_unsafe(&self) -> &mut T {
&mut (*self.0.get())
}
}
impl<T> Shared<T>