mirror of
https://github.com/exoticorn/microw8.git
synced 2026-11-13 23:17:19 +01:00
Compare commits
4
Commits
v0.4.0
...
f4fa9e9c62
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4fa9e9c62 | ||
|
|
4c1ce8075e | ||
|
|
94764d631e | ||
|
|
8913fdaf6b |
No files matched your search
Generated
+334
-424
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -28,4 +28,4 @@ tokio-stream = { version = "0.1.15", features = ["sync"], optional = true }
|
||||
webbrowser = { version = "0.8.13", optional = true }
|
||||
ansi_term = "0.12.1"
|
||||
cpal = { version = "0.15.3", optional = true }
|
||||
rubato = { version = "0.15.0", optional = true }
|
||||
rubato = { version = "0.12.0", optional = true }
|
||||
@@ -15,9 +15,9 @@ See [here](https://exoticorn.github.io/microw8/) for more information and docs.
|
||||
|
||||
## Downloads
|
||||
|
||||
* [Linux](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.4.0-linux.tgz)
|
||||
* [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.4.0-macos.tgz)
|
||||
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.4.0-windows.zip)
|
||||
* [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.4.0/microw8-0.4.0-macos.tgz)
|
||||
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.4.0/microw8-0.4.0-windows.zip)
|
||||
|
||||
The download includes
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html><head><meta charset="utf8"><title>MicroW8</title><link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@500&display=swap" rel="stylesheet"><style>html,body,canvas{margin:0;padding:0}html{color:#808070;background-color:#202024;height:100%;font-family:Josefin Sans,Verdana,Arial Black,sans-serif}body{grid-template-rows:1fr 0fr;height:100%;display:grid}#uw8{position:absolute}#uw8 a{font-size:130%}#centered{place-self:center}a{color:#303630}a:hover{color:#405040}.screen{image-rendering:pixelated;background-color:#202428;border:4px solid #303040;width:320px;height:240px;margin-bottom:8px;box-shadow:5px 5px 20px #000}#screen{cursor:none}#start{font-size:150%}#timer:before{content:"";background-color:red;border-radius:6px;width:12px;height:12px;margin-right:3px;display:inline-block}#message{margin-bottom:8px}.error{color:#e04030}button{color:#808070;background-color:#303440;border:1px solid #404040;border-radius:4px;padding:4px;font-family:inherit}button:hover{background-color:#202010}button:active{background-color:#504450}@media (width>=680px) and (height>=620px){.screen{width:640px;height:480px}}@media (width>=1000px) and (height>=800px){.screen{width:960px;height:720px}}@media (width:640px) and (height:480px){.screen{border:0;width:640px;height:480px;margin:0}body{overflow:hidden}}</style></head><body> <div id="uw8"> <a href="https://exoticorn.github.io/microw8">MicroW8</a> 0.4.0 </div> <div id="centered"> <canvas class="screen" id="screen" width="320" height="240"> </canvas> <button class="screen" id="start" style="display:none">Click to start</button> <div id="timer" hidden></div> <div id="message"></div> <button id="cartButton" style="visibility:hidden">Load cart...</button> </div> <div id="footer"> <a href="http://unlicense.org/" ref="license">Unlicense</a> </div> </body><script type="module">function e(e){return e&&e.__esModule?e.default:e}var t={};t="data:application/wasm;base64,AGFzbQEAAAABFQRgAX8Bf2ACf38Bf2ADf39%2FAGAAAAIPAQNlbnYGbWVtb3J5AgAEAwkIAAABAgEAAAMGEAN%2FAUEAC38BQQALfwFBAAsHGQIIbG9hZF91dzgAAAp1bmNvbXByZXNzAAQIAQcKngUIxwEBB39BAC0AAEEBayIBQQBIBEAgAA8LQYDAByAAaiECIAFBAXEEQEEBQYHABxAEIQIFQYDAB0EAIAAQAwtBAEGAhA9BCBADQYiEDyEDQQghBEGBwAchBQNAIAUgAkggAyMATiAFLQAAIAMtAABMcnEEQCAEIAQgBRACIgZqIQQgAyMASCAFLQAAIAMtAABGcQRAIAMgAxABaiEDCyAFIAZqIQUMAQsgAyMASARAIAQgBCADEAIiB2ohBCADIAdq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Z1E0vdpidtMzv1uwHCp986mNDT3qK4nWbwOpG52kVtkmac18T9g428D%2BeyJW82GG1hJmGV%2F39FlEB5hxbyFZINNLLAfNwG08itW25ATJ7QxZ%2FAX8zoz%2FT7oLugeHUeMBtvBF%2Bt40Wh2n%2FvjehShTKyMYUvlDZTTzBq34hcaBhCNCHTEHV8bRzoBK3%2Fx0qmeTW2l8vG7KCizhl8VoxALJiY84Isnu1OAS8vKw35FHVUWXDfXLUJw0WooJ%2BdxHnwkxlGBfeNGdWY0zJyRe3CgvsBiGlxC5nABF4pFYBMEOIGR6ev%2F3rrkXL34LdvKr2PkRuMr1gjvb8gGszxhBS40uxdOoWZLRyLA5OZ07W5nHTFbL5l6wKfJrIbrl8ZRamKdD5IXHETRJZq%2BlF3KOS0Jug3R8cjVTtBWYH4QDRXEym7uWNetxnlA5tTOlLine truncated
|
||||
+2
-2
@@ -395,8 +395,8 @@ fn init_sound(
|
||||
None
|
||||
} else {
|
||||
let rs = rubato::FftFixedIn::new(44100, sample_rate, 128, 1, 2)?;
|
||||
let input_buffers = rs.input_buffer_allocate(true);
|
||||
let output_buffers = rs.output_buffer_allocate(true);
|
||||
let input_buffers = rs.input_buffer_allocate();
|
||||
let output_buffers = rs.output_buffer_allocate();
|
||||
Some(Resampler {
|
||||
resampler: rs,
|
||||
input_buffers,
|
||||
|
||||
Generated
+371
-540
File diff suppressed because it is too large.
Load diff
@@ -6,11 +6,11 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
winit = "0.29.15"
|
||||
env_logger = "0.11.3"
|
||||
winit = "0.28.6"
|
||||
log = "0.4"
|
||||
pico-args = "0.5"
|
||||
wgpu = "0.19.3"
|
||||
wgpu = "0.17"
|
||||
pollster = "0.3.0"
|
||||
bytemuck = { version = "1.15", features = [ "derive" ] }
|
||||
anyhow = "1"
|
||||
|
||||
+83
-94
@@ -1,16 +1,16 @@
|
||||
use crate::{Input, WindowConfig, WindowImpl};
|
||||
use anyhow::{anyhow, Result};
|
||||
use std::{sync::Arc, time::Instant};
|
||||
use std::time::Instant;
|
||||
|
||||
use winit::{
|
||||
dpi::PhysicalSize,
|
||||
event::{Event, WindowEvent},
|
||||
event::{Event, VirtualKeyCode, WindowEvent},
|
||||
event_loop::{ControlFlow, EventLoop},
|
||||
keyboard::{Key, KeyCode, NamedKey, PhysicalKey},
|
||||
platform::pump_events::{EventLoopExtPumpEvents, PumpStatus},
|
||||
window::{Fullscreen, WindowBuilder},
|
||||
};
|
||||
|
||||
use winit::platform::run_return::EventLoopExtRunReturn;
|
||||
|
||||
mod crt;
|
||||
mod fast_crt;
|
||||
mod square;
|
||||
@@ -21,7 +21,7 @@ use square::SquareFilter;
|
||||
|
||||
pub struct Window {
|
||||
_instance: wgpu::Instance,
|
||||
surface: wgpu::Surface<'static>,
|
||||
surface: wgpu::Surface,
|
||||
_adapter: wgpu::Adapter,
|
||||
device: wgpu::Device,
|
||||
queue: wgpu::Queue,
|
||||
@@ -29,7 +29,7 @@ pub struct Window {
|
||||
surface_config: wgpu::SurfaceConfiguration,
|
||||
filter: Box<dyn Filter>,
|
||||
event_loop: EventLoop<()>,
|
||||
window: Arc<winit::window::Window>,
|
||||
window: winit::window::Window,
|
||||
gamepads: [u8; 4],
|
||||
next_frame: Instant,
|
||||
is_fullscreen: bool,
|
||||
@@ -39,7 +39,7 @@ pub struct Window {
|
||||
impl Window {
|
||||
pub fn new(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()
|
||||
.with_inner_size(PhysicalSize::new(
|
||||
(320. * window_config.scale).round() as u32,
|
||||
@@ -56,10 +56,8 @@ impl Window {
|
||||
|
||||
window.set_cursor_visible(false);
|
||||
|
||||
let window = Arc::new(window);
|
||||
|
||||
let instance = wgpu::Instance::new(Default::default());
|
||||
let surface = instance.create_surface(window.clone())?;
|
||||
let surface = unsafe { instance.create_surface(&window) }?;
|
||||
let adapter = instance
|
||||
.request_adapter(&wgpu::RequestAdapterOptions {
|
||||
power_preference: wgpu::PowerPreference::LowPower,
|
||||
@@ -121,93 +119,88 @@ impl Window {
|
||||
impl WindowImpl for Window {
|
||||
fn begin_frame(&mut self) -> Input {
|
||||
let mut reset = false;
|
||||
self.event_loop
|
||||
.set_control_flow(ControlFlow::WaitUntil(self.next_frame));
|
||||
while self.is_open {
|
||||
let timeout = self.next_frame.saturating_duration_since(Instant::now());
|
||||
let status = self.event_loop.pump_events(Some(timeout), |event, elwt| {
|
||||
let mut new_filter = None;
|
||||
match event {
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::Resized(new_size) => {
|
||||
self.surface_config.width = new_size.width;
|
||||
self.surface_config.height = new_size.height;
|
||||
self.surface.configure(&self.device, &self.surface_config);
|
||||
self.filter.resize(&self.queue, new_size);
|
||||
}
|
||||
WindowEvent::CloseRequested => {
|
||||
elwt.exit();
|
||||
}
|
||||
WindowEvent::KeyboardInput { event, .. } => {
|
||||
fn gamepad_button(input: &winit::event::KeyEvent) -> u8 {
|
||||
match input.physical_key {
|
||||
PhysicalKey::Code(KeyCode::KeyZ) => 16,
|
||||
PhysicalKey::Code(KeyCode::KeyX) => 32,
|
||||
PhysicalKey::Code(KeyCode::KeyA) => 64,
|
||||
PhysicalKey::Code(KeyCode::KeyS) => 128,
|
||||
_ => match input.logical_key {
|
||||
Key::Named(NamedKey::ArrowUp) => 1,
|
||||
Key::Named(NamedKey::ArrowDown) => 2,
|
||||
Key::Named(NamedKey::ArrowLeft) => 4,
|
||||
Key::Named(NamedKey::ArrowRight) => 8,
|
||||
_ => 0,
|
||||
},
|
||||
}
|
||||
self.event_loop.run_return(|event, _, control_flow| {
|
||||
*control_flow = ControlFlow::WaitUntil(self.next_frame);
|
||||
let mut new_filter = None;
|
||||
match event {
|
||||
Event::WindowEvent { event, .. } => match event {
|
||||
WindowEvent::Resized(new_size) => {
|
||||
self.surface_config.width = new_size.width;
|
||||
self.surface_config.height = new_size.height;
|
||||
self.surface.configure(&self.device, &self.surface_config);
|
||||
self.filter.resize(&self.queue, new_size);
|
||||
}
|
||||
WindowEvent::CloseRequested => {
|
||||
self.is_open = false;
|
||||
*control_flow = ControlFlow::Exit;
|
||||
}
|
||||
WindowEvent::KeyboardInput { input, .. } => {
|
||||
fn gamepad_button(input: &winit::event::KeyboardInput) -> u8 {
|
||||
match input.scancode {
|
||||
44 => 16,
|
||||
45 => 32,
|
||||
30 => 64,
|
||||
31 => 128,
|
||||
_ => match input.virtual_keycode {
|
||||
Some(VirtualKeyCode::Up) => 1,
|
||||
Some(VirtualKeyCode::Down) => 2,
|
||||
Some(VirtualKeyCode::Left) => 4,
|
||||
Some(VirtualKeyCode::Right) => 8,
|
||||
_ => 0,
|
||||
},
|
||||
}
|
||||
if event.state == winit::event::ElementState::Pressed {
|
||||
match event.logical_key {
|
||||
Key::Named(NamedKey::Escape) => {
|
||||
elwt.exit();
|
||||
}
|
||||
Key::Character(ref c) => match c.as_str() {
|
||||
"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),
|
||||
_ => (),
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
if input.state == winit::event::ElementState::Pressed {
|
||||
match input.virtual_keycode {
|
||||
Some(VirtualKeyCode::Escape) => {
|
||||
self.is_open = false;
|
||||
*control_flow = ControlFlow::Exit;
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
self.gamepads[0] &= !gamepad_button(&event);
|
||||
}
|
||||
self.gamepads[0] |= gamepad_button(&input);
|
||||
} else {
|
||||
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 Instant::now() >= self.next_frame {
|
||||
break;
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
Input {
|
||||
gamepads: self.gamepads,
|
||||
reset,
|
||||
@@ -243,12 +236,10 @@ impl WindowImpl for Window {
|
||||
b: 0.0,
|
||||
a: 1.0,
|
||||
}),
|
||||
store: wgpu::StoreOp::Store,
|
||||
store: true,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
timestamp_writes: None,
|
||||
occlusion_query_set: None,
|
||||
});
|
||||
|
||||
self.filter.render(&mut render_pass);
|
||||
@@ -550,12 +541,10 @@ impl PaletteScreenMode {
|
||||
resolve_target: None,
|
||||
ops: wgpu::Operations {
|
||||
load: wgpu::LoadOp::Load,
|
||||
store: wgpu::StoreOp::Store,
|
||||
store: true,
|
||||
},
|
||||
})],
|
||||
depth_stencil_attachment: None,
|
||||
timestamp_writes: None,
|
||||
occlusion_query_set: None,
|
||||
});
|
||||
|
||||
render_pass.set_pipeline(&self.pipeline);
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<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 id="centered">
|
||||
<canvas class="screen" id="screen" width="320" height="240">
|
||||
|
||||
Reference in new issue
Block a user