mirror of
https://github.com/JanNeuendorf/SVC16.git
synced 2025-06-04 18:45:27 +00:00
Reworked the sync function to reduce input-lag by one frame and changed confusing documentation.
This commit is contained in:
parent
cf3306eeb2
commit
29f215ff9e
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -539,7 +539,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "svc16"
|
name = "svc16"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "svc16"
|
name = "svc16"
|
||||||
version = "0.9.0"
|
version = "0.9.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Jan Neuendorf"]
|
authors = ["Jan Neuendorf"]
|
||||||
description = "An emulator for a simple virtual computer"
|
description = "An emulator for a simple virtual computer"
|
||||||
|
@ -104,7 +104,7 @@ These keys are supposed to represent the face buttons of an NES controller.
|
|||||||
The codes for the *A* and *B* keys also represent the left and right mouse buttons.
|
The codes for the *A* and *B* keys also represent the left and right mouse buttons.
|
||||||
|
|
||||||
On synchronization the new input is loaded into the input-buffer.
|
On synchronization the new input is loaded into the input-buffer.
|
||||||
Before the first synchronization, both input codes are zero.
|
Before the first synchronization, the input codes are not accessible.
|
||||||
|
|
||||||
The *position code* is the index of the pixel, the mouse is currently on.
|
The *position code* is the index of the pixel, the mouse is currently on.
|
||||||
It follows the same convention as the screen index explained in @screen.
|
It follows the same convention as the screen index explained in @screen.
|
||||||
|
@ -25,8 +25,8 @@ pub struct Engine {
|
|||||||
screen_buffer: [u16; MEMSIZE],
|
screen_buffer: [u16; MEMSIZE],
|
||||||
utility_buffer: [u16; MEMSIZE],
|
utility_buffer: [u16; MEMSIZE],
|
||||||
instruction_pointer: u16,
|
instruction_pointer: u16,
|
||||||
pos_code: u16,
|
pos_code_dest: u16,
|
||||||
key_code: u16,
|
key_code_dest: u16,
|
||||||
sync_called: bool,
|
sync_called: bool,
|
||||||
expansion_triggered: bool,
|
expansion_triggered: bool,
|
||||||
}
|
}
|
||||||
@ -62,8 +62,8 @@ impl Engine {
|
|||||||
screen_buffer: [0; MEMSIZE],
|
screen_buffer: [0; MEMSIZE],
|
||||||
utility_buffer: [0; MEMSIZE],
|
utility_buffer: [0; MEMSIZE],
|
||||||
instruction_pointer: 0,
|
instruction_pointer: 0,
|
||||||
pos_code: 0,
|
pos_code_dest: 0,
|
||||||
key_code: 0,
|
key_code_dest: 0,
|
||||||
sync_called: false,
|
sync_called: false,
|
||||||
expansion_triggered: false,
|
expansion_triggered: false,
|
||||||
}
|
}
|
||||||
@ -72,8 +72,8 @@ impl Engine {
|
|||||||
return self.sync_called;
|
return self.sync_called;
|
||||||
}
|
}
|
||||||
pub fn set_input(&mut self, pos_code: u16, key_code: u16) {
|
pub fn set_input(&mut self, pos_code: u16, key_code: u16) {
|
||||||
self.pos_code = pos_code;
|
self.set(self.pos_code_dest, pos_code);
|
||||||
self.key_code = key_code;
|
self.set(self.key_code_dest, key_code);
|
||||||
}
|
}
|
||||||
pub fn perform_sync(
|
pub fn perform_sync(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -81,9 +81,9 @@ impl Engine {
|
|||||||
key_code: u16,
|
key_code: u16,
|
||||||
buffer: &mut [u16; MEMSIZE],
|
buffer: &mut [u16; MEMSIZE],
|
||||||
) -> () {
|
) -> () {
|
||||||
self.set_input(pos_code, key_code);
|
|
||||||
self.sync_called = false;
|
self.sync_called = false;
|
||||||
*buffer = self.screen_buffer;
|
*buffer = self.screen_buffer;
|
||||||
|
self.set_input(pos_code, key_code);
|
||||||
if self.expansion_triggered {
|
if self.expansion_triggered {
|
||||||
self.expansion_triggered = false;
|
self.expansion_triggered = false;
|
||||||
self.utility_buffer = [0; MEMSIZE];
|
self.utility_buffer = [0; MEMSIZE];
|
||||||
@ -216,8 +216,8 @@ impl Engine {
|
|||||||
}
|
}
|
||||||
SYNC => {
|
SYNC => {
|
||||||
self.sync_called = true;
|
self.sync_called = true;
|
||||||
self.set(arg1, self.pos_code);
|
self.pos_code_dest = arg1;
|
||||||
self.set(arg2, self.key_code);
|
self.key_code_dest = arg2;
|
||||||
if arg3 > 0 {
|
if arg3 > 0 {
|
||||||
self.expansion_triggered = true;
|
self.expansion_triggered = true;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,6 @@ async fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
ipf += 1;
|
ipf += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gamepad")]
|
#[cfg(feature = "gamepad")]
|
||||||
while let Some(event) = gilrs.next_event() {
|
while let Some(event) = gilrs.next_event() {
|
||||||
gilrs.update(&event);
|
gilrs.update(&event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user