framereceiver type

This commit is contained in:
Alex Janka 2023-03-08 11:50:19 +11:00
parent 532f602e77
commit 43d88de1f2
2 changed files with 10 additions and 9 deletions

View file

@ -25,9 +25,11 @@ struct EmuVars {
#[derive(Default)] #[derive(Default)]
pub struct GameboyEmu { pub struct GameboyEmu {
vars: Option<EmuVars>, vars: Option<EmuVars>,
frame_receiver: Arc<Mutex<Option<Receiver<Vec<[u8; 4]>>>>>, frame_receiver: Arc<FrameReceiver>,
} }
type FrameReceiver = Mutex<Option<Receiver<Vec<[u8; 4]>>>>;
const ROM: &[u8; 32768] = include_bytes!("../../test-roms/Tetris.gb"); const ROM: &[u8; 32768] = include_bytes!("../../test-roms/Tetris.gb");
impl Plugin for GameboyEmu { impl Plugin for GameboyEmu {

View file

@ -1,6 +1,6 @@
use std::sync::{ use std::sync::{
mpsc::{self, Receiver, Sender}, mpsc::{self, Receiver, Sender},
Arc, Mutex, Arc,
}; };
use baseview::{ use baseview::{
@ -13,12 +13,14 @@ use gb_emu_lib::{
use nih_plug::prelude::*; use nih_plug::prelude::*;
use pixels::{Pixels, SurfaceTexture}; use pixels::{Pixels, SurfaceTexture};
use crate::FrameReceiver;
pub struct Emulator { pub struct Emulator {
frame_receiver: Arc<Mutex<Option<Receiver<Vec<[u8; 4]>>>>>, frame_receiver: Arc<FrameReceiver>,
} }
impl Emulator { impl Emulator {
pub fn new(frame_receiver: Arc<Mutex<Option<Receiver<Vec<[u8; 4]>>>>>) -> Self { pub fn new(frame_receiver: Arc<FrameReceiver>) -> Self {
Self { frame_receiver } Self { frame_receiver }
} }
} }
@ -61,14 +63,11 @@ impl Editor for Emulator {
pub struct EmulatorWindow { pub struct EmulatorWindow {
pix: Pixels, pix: Pixels,
scale: usize, scale: usize,
frame_receiver: Arc<Mutex<Option<Receiver<Vec<[u8; 4]>>>>>, frame_receiver: Arc<FrameReceiver>,
} }
impl EmulatorWindow { impl EmulatorWindow {
fn new( fn new(window: &mut Window, frame_receiver: Arc<FrameReceiver>) -> Self {
window: &mut Window,
frame_receiver: Arc<Mutex<Option<Receiver<Vec<[u8; 4]>>>>>,
) -> Self {
let info = WindowInfo::from_logical_size(Size::new(WIDTH as f64, HEIGHT as f64), 1.); let info = WindowInfo::from_logical_size(Size::new(WIDTH as f64, HEIGHT as f64), 1.);
let (pix, scale) = init_pixbuf(info, window); let (pix, scale) = init_pixbuf(info, window);