4 Commits

Author SHA1 Message Date
f4fa9e9c62 revert rubato to 0.12 to fix crackling at 48000
(probably some misuse on my side, need to investigate more)
2025-03-02 13:42:06 +01:00
4c1ce8075e revert to winit 0.28 and wgpu 0.17 to fix fps on windows 2025-03-02 12:57:22 +01:00
94764d631e fix download links in readme 2025-03-01 12:03:26 +01:00
8913fdaf6b update web runtime to 0.4.0 on homepage 2025-01-22 20:25:59 +01:00
9 changed files with 798 additions and 1067 deletions

758
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -28,4 +28,4 @@ tokio-stream = { version = "0.1.15", features = ["sync"], optional = true }
webbrowser = { version = "0.8.13", optional = true } webbrowser = { version = "0.8.13", optional = true }
ansi_term = "0.12.1" ansi_term = "0.12.1"
cpal = { version = "0.15.3", optional = true } cpal = { version = "0.15.3", optional = true }
rubato = { version = "0.15.0", optional = true } rubato = { version = "0.12.0", optional = true }

View File

@@ -15,9 +15,9 @@ See [here](https://exoticorn.github.io/microw8/) for more information and docs.
## Downloads ## Downloads
* [Linux](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.4.0-linux.tgz) * [Linux](https://github.com/exoticorn/microw8/releases/download/v0.4.0/microw8-0.4.0-linux.tgz)
* [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.4.0-macos.tgz) * [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.4.0/microw8-0.4.0-macos.tgz)
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.4.0-windows.zip) * [Windows](https://github.com/exoticorn/microw8/releases/download/v0.4.0/microw8-0.4.0-windows.zip)
The download includes The download includes

File diff suppressed because one or more lines are too long

View File

@@ -395,8 +395,8 @@ fn init_sound(
None None
} else { } else {
let rs = rubato::FftFixedIn::new(44100, sample_rate, 128, 1, 2)?; let rs = rubato::FftFixedIn::new(44100, sample_rate, 128, 1, 2)?;
let input_buffers = rs.input_buffer_allocate(true); let input_buffers = rs.input_buffer_allocate();
let output_buffers = rs.output_buffer_allocate(true); let output_buffers = rs.output_buffer_allocate();
Some(Resampler { Some(Resampler {
resampler: rs, resampler: rs,
input_buffers, input_buffers,

911
uw8-window/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,11 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
winit = "0.29.15"
env_logger = "0.11.3" env_logger = "0.11.3"
winit = "0.28.6"
log = "0.4" log = "0.4"
pico-args = "0.5" pico-args = "0.5"
wgpu = "0.19.3" wgpu = "0.17"
pollster = "0.3.0" pollster = "0.3.0"
bytemuck = { version = "1.15", features = [ "derive" ] } bytemuck = { version = "1.15", features = [ "derive" ] }
anyhow = "1" anyhow = "1"

View File

@@ -1,16 +1,16 @@
use crate::{Input, WindowConfig, WindowImpl}; use crate::{Input, WindowConfig, WindowImpl};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use std::{sync::Arc, time::Instant}; use std::time::Instant;
use winit::{ use winit::{
dpi::PhysicalSize, dpi::PhysicalSize,
event::{Event, WindowEvent}, event::{Event, VirtualKeyCode, WindowEvent},
event_loop::{ControlFlow, EventLoop}, event_loop::{ControlFlow, EventLoop},
keyboard::{Key, KeyCode, NamedKey, PhysicalKey},
platform::pump_events::{EventLoopExtPumpEvents, PumpStatus},
window::{Fullscreen, WindowBuilder}, window::{Fullscreen, WindowBuilder},
}; };
use winit::platform::run_return::EventLoopExtRunReturn;
mod crt; mod crt;
mod fast_crt; mod fast_crt;
mod square; mod square;
@@ -21,7 +21,7 @@ use square::SquareFilter;
pub struct Window { pub struct Window {
_instance: wgpu::Instance, _instance: wgpu::Instance,
surface: wgpu::Surface<'static>, surface: wgpu::Surface,
_adapter: wgpu::Adapter, _adapter: wgpu::Adapter,
device: wgpu::Device, device: wgpu::Device,
queue: wgpu::Queue, queue: wgpu::Queue,
@@ -29,7 +29,7 @@ pub struct Window {
surface_config: wgpu::SurfaceConfiguration, surface_config: wgpu::SurfaceConfiguration,
filter: Box<dyn Filter>, filter: Box<dyn Filter>,
event_loop: EventLoop<()>, event_loop: EventLoop<()>,
window: Arc<winit::window::Window>, window: winit::window::Window,
gamepads: [u8; 4], gamepads: [u8; 4],
next_frame: Instant, next_frame: Instant,
is_fullscreen: bool, is_fullscreen: bool,
@@ -39,7 +39,7 @@ pub struct Window {
impl Window { impl Window {
pub fn new(window_config: WindowConfig) -> Result<Window> { pub fn new(window_config: WindowConfig) -> Result<Window> {
async fn create(window_config: WindowConfig) -> Result<Window> { async fn create(window_config: WindowConfig) -> Result<Window> {
let event_loop = EventLoop::new()?; let event_loop = EventLoop::new();
let window = WindowBuilder::new() let window = WindowBuilder::new()
.with_inner_size(PhysicalSize::new( .with_inner_size(PhysicalSize::new(
(320. * window_config.scale).round() as u32, (320. * window_config.scale).round() as u32,
@@ -56,10 +56,8 @@ impl Window {
window.set_cursor_visible(false); window.set_cursor_visible(false);
let window = Arc::new(window);
let instance = wgpu::Instance::new(Default::default()); let instance = wgpu::Instance::new(Default::default());
let surface = instance.create_surface(window.clone())?; let surface = unsafe { instance.create_surface(&window) }?;
let adapter = instance let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions { .request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::LowPower, power_preference: wgpu::PowerPreference::LowPower,
@@ -121,93 +119,88 @@ impl Window {
impl WindowImpl for Window { impl WindowImpl for Window {
fn begin_frame(&mut self) -> Input { fn begin_frame(&mut self) -> Input {
let mut reset = false; let mut reset = false;
self.event_loop self.event_loop.run_return(|event, _, control_flow| {
.set_control_flow(ControlFlow::WaitUntil(self.next_frame)); *control_flow = ControlFlow::WaitUntil(self.next_frame);
while self.is_open { let mut new_filter = None;
let timeout = self.next_frame.saturating_duration_since(Instant::now()); match event {
let status = self.event_loop.pump_events(Some(timeout), |event, elwt| { Event::WindowEvent { event, .. } => match event {
let mut new_filter = None; WindowEvent::Resized(new_size) => {
match event { self.surface_config.width = new_size.width;
Event::WindowEvent { event, .. } => match event { self.surface_config.height = new_size.height;
WindowEvent::Resized(new_size) => { self.surface.configure(&self.device, &self.surface_config);
self.surface_config.width = new_size.width; self.filter.resize(&self.queue, new_size);
self.surface_config.height = new_size.height; }
self.surface.configure(&self.device, &self.surface_config); WindowEvent::CloseRequested => {
self.filter.resize(&self.queue, new_size); self.is_open = false;
} *control_flow = ControlFlow::Exit;
WindowEvent::CloseRequested => { }
elwt.exit(); WindowEvent::KeyboardInput { input, .. } => {
} fn gamepad_button(input: &winit::event::KeyboardInput) -> u8 {
WindowEvent::KeyboardInput { event, .. } => { match input.scancode {
fn gamepad_button(input: &winit::event::KeyEvent) -> u8 { 44 => 16,
match input.physical_key { 45 => 32,
PhysicalKey::Code(KeyCode::KeyZ) => 16, 30 => 64,
PhysicalKey::Code(KeyCode::KeyX) => 32, 31 => 128,
PhysicalKey::Code(KeyCode::KeyA) => 64, _ => match input.virtual_keycode {
PhysicalKey::Code(KeyCode::KeyS) => 128, Some(VirtualKeyCode::Up) => 1,
_ => match input.logical_key { Some(VirtualKeyCode::Down) => 2,
Key::Named(NamedKey::ArrowUp) => 1, Some(VirtualKeyCode::Left) => 4,
Key::Named(NamedKey::ArrowDown) => 2, Some(VirtualKeyCode::Right) => 8,
Key::Named(NamedKey::ArrowLeft) => 4, _ => 0,
Key::Named(NamedKey::ArrowRight) => 8, },
_ => 0,
},
}
} }
if event.state == winit::event::ElementState::Pressed { }
match event.logical_key { if input.state == winit::event::ElementState::Pressed {
Key::Named(NamedKey::Escape) => { match input.virtual_keycode {
elwt.exit(); Some(VirtualKeyCode::Escape) => {
} self.is_open = false;
Key::Character(ref c) => match c.as_str() { *control_flow = ControlFlow::Exit;
"f" => {
let fullscreen = if self.window.fullscreen().is_some() {
None
} else {
Some(Fullscreen::Borderless(None))
};
self.is_fullscreen = fullscreen.is_some();
self.window.set_fullscreen(fullscreen);
}
"r" => reset = true,
"1" => new_filter = Some(1),
"2" => new_filter = Some(2),
"3" => new_filter = Some(3),
"4" => new_filter = Some(4),
"5" => new_filter = Some(5),
_ => (),
},
_ => (),
} }
Some(VirtualKeyCode::F) => {
let fullscreen = if self.window.fullscreen().is_some() {
None
} else {
Some(Fullscreen::Borderless(None))
};
self.is_fullscreen = fullscreen.is_some();
self.window.set_fullscreen(fullscreen);
}
Some(VirtualKeyCode::R) => reset = true,
Some(VirtualKeyCode::Key1) => new_filter = Some(1),
Some(VirtualKeyCode::Key2) => new_filter = Some(2),
Some(VirtualKeyCode::Key3) => new_filter = Some(3),
Some(VirtualKeyCode::Key4) => new_filter = Some(4),
Some(VirtualKeyCode::Key5) => new_filter = Some(5),
_ => (),
}
self.gamepads[0] |= gamepad_button(&event); self.gamepads[0] |= gamepad_button(&input);
} else { } else {
self.gamepads[0] &= !gamepad_button(&event); self.gamepads[0] &= !gamepad_button(&input);
}
} }
_ => (), }
},
_ => (), _ => (),
},
Event::RedrawEventsCleared => {
if Instant::now() >= self.next_frame
// workaround needed on Wayland until the next winit release
&& self.window.fullscreen().is_some() == self.is_fullscreen
{
*control_flow = ControlFlow::Exit
}
} }
if let Some(new_filter) = new_filter {
self.filter = create_filter(
&self.device,
&self.palette_screen_mode.screen_view,
self.window.inner_size(),
self.surface_config.format,
new_filter,
);
}
});
match status {
PumpStatus::Exit(_) => self.is_open = false,
_ => (), _ => (),
} }
if let Some(new_filter) = new_filter {
if Instant::now() >= self.next_frame { self.filter = create_filter(
break; &self.device,
&self.palette_screen_mode.screen_view,
self.window.inner_size(),
self.surface_config.format,
new_filter,
);
} }
} });
Input { Input {
gamepads: self.gamepads, gamepads: self.gamepads,
reset, reset,
@@ -243,12 +236,10 @@ impl WindowImpl for Window {
b: 0.0, b: 0.0,
a: 1.0, a: 1.0,
}), }),
store: wgpu::StoreOp::Store, store: true,
}, },
})], })],
depth_stencil_attachment: None, depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
}); });
self.filter.render(&mut render_pass); self.filter.render(&mut render_pass);
@@ -550,12 +541,10 @@ impl PaletteScreenMode {
resolve_target: None, resolve_target: None,
ops: wgpu::Operations { ops: wgpu::Operations {
load: wgpu::LoadOp::Load, load: wgpu::LoadOp::Load,
store: wgpu::StoreOp::Store, store: true,
}, },
})], })],
depth_stencil_attachment: None, depth_stencil_attachment: None,
timestamp_writes: None,
occlusion_query_set: None,
}); });
render_pass.set_pipeline(&self.pipeline); render_pass.set_pipeline(&self.pipeline);

View File

@@ -10,7 +10,7 @@
</head> </head>
<body> <body>
<div id="uw8"> <div id="uw8">
<a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.3.1 <a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.4.0
</div> </div>
<div id="centered"> <div id="centered">
<canvas class="screen" id="screen" width="320" height="240"> <canvas class="screen" id="screen" width="320" height="240">