Skip to content

Commit

Permalink
Make vdp wait for frontend vblank on swapBuffers vdu
Browse files Browse the repository at this point in the history
  • Loading branch information
tomm committed Sep 12, 2024
1 parent 76c446e commit 333574e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = ["agon-light-emulator-debugger"]

[workspace.package]
version = "0.9.60"
version = "0.9.61"
edition = "2021"
authors = ["Tom Morton <[email protected]>"]
license = "GPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ vdu 23 0 &88 250 0 50 0 0

## CPU bugs

- [ ] Mixed mode calls set ((ismixed<<1) | isadl). I haven't implemented the ismixed part
- [ ] Mixed mode push ((ismixed<<1) | isadl) to stack. I haven't implemented the ismixed part

## Mañana mañana

Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ pub fn main() -> Result<(), pico_args::Error> {
gpios.b.set_input_pin(1, true);
gpios.b.set_input_pin(1, false);
}
// signal vblank to VDP
unsafe {
(*vdp_interface.signal_vblank)();
}

// shutdown if requested (atomic could be set from the debugger)
if emulator_shutdown.load(std::sync::atomic::Ordering::Relaxed) {
Expand Down
6 changes: 6 additions & 0 deletions src/vdp/rust_glue.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "fabutils.h"
#include "fake_fabgl.h"
#include "fabgl.h"
#include "userspace-vdp-gl/src/displaycontroller.h"
#include "userspace-vdp-gl/src/dispdrivers/vgabasecontroller.h"
#include "userspace-vdp-gl/src/userspace-platform/fake_fabgl.h"
#include "vdp.h"
Expand All @@ -14,6 +15,11 @@ extern void delay(int ms);
bool vdp_debug_logging = false;
uint32_t startup_screen_mode = 0;

extern "C" void signal_vblank(void)
{
fabgl::BaseDisplayController::vblankSignal.store(true);
}

extern "C" void setVdpDebugLogging(bool state)
{
vdp_debug_logging = state;
Expand Down
2 changes: 2 additions & 0 deletions src/vdp_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::Path;
pub struct VdpInterface {
pub vdp_setup: libloading::Symbol<'static, unsafe extern "C" fn() -> ()>,
pub vdp_loop: libloading::Symbol<'static, unsafe extern "C" fn()>,
pub signal_vblank: libloading::Symbol<'static, unsafe extern "C" fn() -> ()>,
pub copyVgaFramebuffer: libloading::Symbol<
'static,
unsafe extern "C" fn(outWidth: *mut u32, outHeight: *mut u32, buffer: *mut u8),
Expand All @@ -28,6 +29,7 @@ impl VdpInterface {
return VdpInterface {
vdp_setup: lib.get(b"vdp_setup").unwrap(),
vdp_loop: lib.get(b"vdp_loop").unwrap(),
signal_vblank: lib.get(b"signal_vblank").unwrap(),
copyVgaFramebuffer: lib.get(b"copyVgaFramebuffer").unwrap(),
z80_send_to_vdp: lib.get(b"z80_send_to_vdp").unwrap(),
z80_recv_from_vdp: lib.get(b"z80_recv_from_vdp").unwrap(),
Expand Down

0 comments on commit 333574e

Please sign in to comment.