aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAstatin <[email protected]>2025-08-24 17:19:47 +0200
committerAstatin <[email protected]>2025-08-24 17:19:47 +0200
commit219157faec53a8f2df8912ef3ae4e7941fa23305 (patch)
treea89ddbe02bf3502b3c2e0379f1aebec1da7b7e73
parent70b95279579146bf46910257f8e0ecb1ff62b24f (diff)
Fix serial read_controlHEADlatestmain
-rw-r--r--src/desktop/audio.rs8
-rw-r--r--src/desktop/input.rs8
-rw-r--r--src/desktop/serial.rs7
-rw-r--r--src/io.rs2
-rw-r--r--src/opcodes.rs2
5 files changed, 18 insertions, 9 deletions
diff --git a/src/desktop/audio.rs b/src/desktop/audio.rs
index 42dc129..6913d30 100644
--- a/src/desktop/audio.rs
+++ b/src/desktop/audio.rs
@@ -8,9 +8,9 @@ use crate::logs::{log, LogLevel};
use std::mem;
use std::time::{SystemTime, Duration};
-const BUFFER_SIZE: usize = 256;
-const RODIO_BUFFER_SIZE: usize = 1024;
-const RODIO_BUFFER_SINK_LATE_EXPECTED: f32 = 0.;
+const BUFFER_SIZE: usize = 16;
+const RODIO_BUFFER_SIZE: usize = 2048;
+const RODIO_BUFFER_SINK_LATE_EXPECTED: f32 = 2.;
const LATE_SPEEDUP_INTENSITY_INV: f32 = 2048.0;
const SPEEDUP_SKIP_LIMIT: f32 = 1.008;
@@ -107,7 +107,7 @@ impl<I: Iterator<Item = f32>> Source for RodioBuffer<I> {
impl Audio for RodioAudio {
fn new(wave: MutableWave) -> Self {
- let stream = OutputStreamBuilder::from_default_device().unwrap().with_sample_rate(SAMPLE_RATE).with_buffer_size(BufferSize::Fixed(RODIO_BUFFER_SIZE as u32)).open_stream().unwrap();
+ let stream = OutputStreamBuilder::from_default_device().unwrap().with_buffer_size(BufferSize::Fixed(RODIO_BUFFER_SIZE as u32)).open_stream().unwrap();
let sink = Sink::connect_new(stream.mixer());
let wave = RodioWave(wave, 0);
diff --git a/src/desktop/input.rs b/src/desktop/input.rs
index bc8b29d..760158c 100644
--- a/src/desktop/input.rs
+++ b/src/desktop/input.rs
@@ -327,6 +327,14 @@ impl Input for GamepadReplay {
self.action_reg = inputs[0];
self.direction_reg = inputs[1];
+ log(
+ LogLevel::Debug,
+ format!(
+ "input update on cycle {} ! 0x{:02x} 0x{:02x}",
+ cycles, self.action_reg, self.direction_reg
+ ),
+ );
+
let mut cycles_le: [u8; 16] = [0; 16];
self.next_cycle_update = match self.record_file.read_exact(&mut cycles_le) {
diff --git a/src/desktop/serial.rs b/src/desktop/serial.rs
index 36cfba8..c7c3d6f 100644
--- a/src/desktop/serial.rs
+++ b/src/desktop/serial.rs
@@ -4,6 +4,7 @@ use std::net::{TcpListener, TcpStream};
use std::sync::mpsc::{self, Receiver, Sender};
use std::thread;
+use crate::logs::{log, LogLevel};
use crate::consts::CPU_CLOCK_SPEED;
use crate::io::Serial;
@@ -166,7 +167,7 @@ impl TcpSerial {
thread::spawn(move || {
match TcpListener::bind(("0.0.0.0", port)).unwrap().accept() {
Ok((socket, addr)) => {
- println!("Connection on {:?}", addr);
+ log(LogLevel::Infos, format!("Connection on {:?}", addr));
Self::handle_stream(socket, tx, rx);
}
_ => (),
@@ -193,7 +194,7 @@ impl TcpSerial {
let (output, rx) = mpsc::channel::<u8>();
thread::spawn(move || {
if let Ok(socket) = TcpStream::connect(&addr) {
- println!("Connected to {:?}", addr);
+ log(LogLevel::Infos, format!("Connected to {:?}", addr));
Self::handle_stream(socket, tx, rx);
}
});
@@ -251,8 +252,8 @@ impl Serial for TcpSerial {
self.current_data = x;
self.external_clock = true;
self.transfer_requested = false;
+ self.next_byte_transfer_cycle = cycles + ((CPU_CLOCK_SPEED as u128) / 1024);
}
- self.next_byte_transfer_cycle = cycles + ((CPU_CLOCK_SPEED as u128) / 16384);
true
} else if !self.external_clock && !self.current_transfer && self.transfer_requested {
if cycles > self.next_byte_transfer_cycle {
diff --git a/src/io.rs b/src/io.rs
index f2ed8d0..d2cc429 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -55,7 +55,7 @@ impl<T: Serial + ?Sized> Serial for Box<T> {
(**self).read_data()
}
fn read_control(&self) -> u8 {
- (**self).read_data()
+ (**self).read_control()
}
fn write_data(&mut self, data: u8) {
(**self).write_data(data);
diff --git a/src/opcodes.rs b/src/opcodes.rs
index 87d921e..62e41c9 100644
--- a/src/opcodes.rs
+++ b/src/opcodes.rs
@@ -753,7 +753,7 @@ impl<S: Serial, A: Audio> GBState<S, A> {
0b011 | 0b100 | 0b101 => unimplemented!(),
0b010 => {
self.cpu.print_debug();
- 4
+ 0
}
0b110 => {
self.mem.ime = false;