changed futex crate for mac compat (maybe) and image to bitmap assembly converter
This commit is contained in:
@@ -4,11 +4,11 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
atomic-wait = "1.1.0"
|
||||
pixels = "0.15.0"
|
||||
winit = { version = "0.30.13", features = ["x11", "x11-dl", "x11rb", "ahash", "bytemuck", "memmap2", "rwh_06", "sctk", "sctk-adwaita"] }
|
||||
winit_input_helper = "0.17.0"
|
||||
parse_int = { version = "0.9.0", optional = true }
|
||||
wait_on_address = "0.1.4"
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::{
|
||||
sync::atomic::AtomicU32,
|
||||
time::{self, Instant},
|
||||
};
|
||||
|
||||
use wait_on_address::AtomicWait;
|
||||
pub(crate) struct SharedState {
|
||||
pub(crate) keyboard: [AtomicU32; 4],
|
||||
pub(crate) screen_buf: [AtomicU32; 480 * 640],
|
||||
@@ -124,6 +124,7 @@ impl Cond {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)] //depen on features
|
||||
enum Instruction {
|
||||
Copy(Reg, Op2),
|
||||
Add(Reg, Reg, Op2),
|
||||
@@ -599,7 +600,7 @@ impl Computer {
|
||||
}
|
||||
println!("awaiting interupt...");
|
||||
}
|
||||
atomic_wait::wait(&SHARED.external_interupts, 0);
|
||||
SHARED.external_interupts.wait(0);
|
||||
}
|
||||
self.pc = (addr + self.pc as u32) as usize;
|
||||
}
|
||||
@@ -642,7 +643,7 @@ impl Computer {
|
||||
InteruptKind::MMIO => {
|
||||
(&SHARED.external_interupts)
|
||||
.store(0, std::sync::atomic::Ordering::Release);
|
||||
atomic_wait::wake_all(&SHARED.external_interupts);
|
||||
SHARED.external_interupts.notify_one();
|
||||
//no need to check prev because MMIO is the lowest priority
|
||||
self.interupts = InteruptState::Enabled
|
||||
}
|
||||
@@ -687,7 +688,7 @@ impl Computer {
|
||||
(&SHARED.external_enabled_interupts)
|
||||
.store(0, std::sync::atomic::Ordering::Relaxed);
|
||||
(&SHARED.external_interupts).store(0, std::sync::atomic::Ordering::Relaxed);
|
||||
atomic_wait::wake_all(&SHARED.external_interupts);
|
||||
SHARED.external_interupts.notify_all();
|
||||
}
|
||||
Instruction::Swi() => {
|
||||
self.pc += 1;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
use std::env::args;
|
||||
use std::hint::unlikely;
|
||||
use std::io::stdin;
|
||||
use std::process::exit;
|
||||
use std::sync::{
|
||||
Arc,
|
||||
@@ -18,17 +17,16 @@ use std::thread::scope;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use pixels::{Error, Pixels, SurfaceTexture};
|
||||
use wait_on_address::AtomicWait;
|
||||
use winit::application::ApplicationHandler;
|
||||
use winit::dpi::LogicalSize;
|
||||
use winit::event::WindowEvent;
|
||||
use winit::event_loop::EventLoop;
|
||||
use winit::platform::modifier_supplement::KeyEventExtModifierSupplement;
|
||||
use winit::platform::scancode::PhysicalKeyExtScancode;
|
||||
use winit::window::Window;
|
||||
// use winit_input_helper::WinitInputHelper;
|
||||
|
||||
use crate::cpu::{Computer, MMIOInterupt};
|
||||
|
||||
mod cpu;
|
||||
use cpu::SHARED;
|
||||
|
||||
@@ -37,7 +35,7 @@ fn wait_int() {
|
||||
while unlikely(v != 0) {
|
||||
#[cfg(feature = "debug")]
|
||||
println!("wating for interupt clear {v}");
|
||||
atomic_wait::wait(&SHARED.external_interupts, v);
|
||||
SHARED.external_interupts.wait(v);
|
||||
v = (&SHARED.external_interupts).load(Acquire);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +121,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::Keyboard.into(), Release);
|
||||
#[cfg(feature = "debug")]
|
||||
println!("wake due to keyboard event");
|
||||
atomic_wait::wake_all(&SHARED.external_interupts);
|
||||
SHARED.external_interupts.notify_one();
|
||||
}
|
||||
}
|
||||
WindowEvent::CursorMoved { position, .. } => {
|
||||
@@ -152,7 +150,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::MouseMove.into(), Release);
|
||||
#[cfg(feature = "debug")]
|
||||
println!("wake due mouse move");
|
||||
atomic_wait::wake_all(&SHARED.external_interupts);
|
||||
SHARED.external_interupts.notify_one();
|
||||
}
|
||||
}
|
||||
// WindowEvent::MouseWheel {
|
||||
@@ -186,7 +184,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::MouseClick.into(), Release);
|
||||
#[cfg(feature = "debug")]
|
||||
println!("wake mouse click");
|
||||
atomic_wait::wake_all(&SHARED.external_interupts);
|
||||
SHARED.external_interupts.notify_one();
|
||||
}
|
||||
}
|
||||
WindowEvent::ScaleFactorChanged { .. } => {
|
||||
@@ -199,7 +197,7 @@ impl<'a> ApplicationHandler for App<'a> {
|
||||
!= 0;
|
||||
if enabled {
|
||||
(&SHARED.external_interupts).store(MMIOInterupt::VSync.into(), Relaxed);
|
||||
atomic_wait::wake_all(&SHARED.external_interupts);
|
||||
SHARED.external_interupts.notify_one();
|
||||
wait_int();
|
||||
}
|
||||
let pix = self.pixels.as_mut().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user