10 Commits

25 changed files with 930 additions and 1374 deletions

View File

@@ -44,7 +44,7 @@ jobs:
- name: Build - name: Build
run: cargo build --release --verbose run: cargo build --release --verbose
- name: Upload artifact - name: Upload artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: uw8-${{ matrix.build }} name: uw8-${{ matrix.build }}
path: target/release/${{ matrix.exe }} path: target/release/${{ matrix.exe }}

762
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "uw8" name = "uw8"
version = "0.3.1" version = "0.4.1"
edition = "2021" 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
@@ -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.3.0-linux.tgz) * [Linux](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-linux.tgz)
* [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.3.0-macos.tgz) * [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-macos.tgz)
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.3.0-windows.zip) * [Windows](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-windows.zip)
The download includes The download includes

Binary file not shown.

View File

@@ -31,19 +31,19 @@ Examplers for older versions:
## Versions ## Versions
### v0.3.0 ### v0.4.1
* [Web runtime](v0.3.0) * [Web runtime](../v0.4.1)
* [Linux](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.3.0-linux.tgz) * [Linux](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-linux.tgz)
* [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.3.0-macos.tgz) * [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-macos.tgz)
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.3.0/microw8-0.3.0-windows.zip) * [Windows](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-windows.zip)
Changes: Changes:
* add blitSprite and grabSprite API calls * Windows: fix bad/inconsistent frame rate
* add support for integer scaling up to 16x for printing text * fix choppy sound on devices with sample rates != 44100 kHz
* fix incompatibility with sound devices only offering 16bit audio formats * add scale mode 'fill' option
* add support for br_table instruction in packed carts
### Older versions ### Older versions

View File

@@ -468,6 +468,7 @@ when using the native runtime:
* `--no-gpu`: Force old cpu-only window code * `--no-gpu`: Force old cpu-only window code
* `--filter FILTER`: Select an upscale filter at startup * `--filter FILTER`: Select an upscale filter at startup
* `--fullscreen`: Start in fullscreen mode * `--fullscreen`: Start in fullscreen mode
* `--scale-fill`: Scale to fill whole screen, potentially cropping parts of the frame buffer.
Note that the cpu-only window does not support fullscreen nor upscale filters. Note that the cpu-only window does not support fullscreen nor upscale filters.
@@ -484,7 +485,7 @@ The upscale filter options are:
5, auto_crt (default) : ss_crt below 960x720, chromatic_crt otherwise 5, auto_crt (default) : ss_crt below 960x720, chromatic_crt otherwise
``` ```
You can switch the upscale filter at any time using the keys 1-5. You can toggle fullscreen with F. You can switch the upscale filter at any time using the keys 1-5. You can toggle fullscreen with F. You can toggle between scale modes 'fit' and 'fill' with M.
## `uw8 pack` ## `uw8 pack`
@@ -594,7 +595,7 @@ a base module provided by MicroW8.
You can generate this base module yourself using You can generate this base module yourself using
`uw8-tool`. As a quick summary, it provides all function `uw8-tool`. As a quick summary, it provides all function
types with up to 5 parameters (i32 or f32) where the types with up to 7 parameters (i32 or f32) where the
`f32` parameters always preceed the `i32` parameters. `f32` parameters always preceed the `i32` parameters.
Then it includes all imports that MicroW8 provides, Then it includes all imports that MicroW8 provides,
a function section with a single function of type a function section with a single function of type

View File

@@ -2,6 +2,33 @@
description = "Versions" description = "Versions"
+++ +++
### v0.4.1
* [Web runtime](../v0.4.1)
* [Linux](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-linux.tgz)
* [MacOS](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-macos.tgz)
* [Windows](https://github.com/exoticorn/microw8/releases/download/v0.4.1/microw8-0.4.1-windows.zip)
Changes:
* Windows: fix bad/inconsistent frame rate
* fix choppy sound on devices with sample rates != 44100 kHz
* add scale mode 'fill' option
### v0.4.0
* [Web runtime](../v0.4.0)
* [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)
Changes:
* add support for sound on mono- and surround-only devices
* update wasmtime dependency to fix performance regression in 0.3.0
* add frame counter since module start at location 72
* add 6 and 7 parameter function types to base module
### v0.3.0 ### v0.3.0
* [Web runtime](../v0.3.0) * [Web runtime](../v0.3.0)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,7 @@
<section> <section>
<h1 class="text-center heading-text">A WebAssembly based fantasy console</h1> <h1 class="text-center heading-text">A WebAssembly based fantasy console</h1>
</section> </section>
<a href="v0.3.0"> <a href="v0.4.1">
<img class="demonstration-gif" style="width:640px;height:480px;image-rendering:pixelated" src="img/technotunnel.png"></img> <img class="demonstration-gif" style="width:640px;height:480px;image-rendering:pixelated" src="img/technotunnel.png"></img>
</a> </a>
</div> </div>

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,

View File

@@ -37,7 +37,7 @@ impl BaseModule {
let mut types = vec![]; let mut types = vec![];
let mut type_map = HashMap::new(); let mut type_map = HashMap::new();
for num_params in 0..6 { for num_params in 0..8 {
for num_f32 in 0..=num_params { for num_f32 in 0..=num_params {
for &result in &[None, Some(ValType::I32), Some(ValType::F32)] { for &result in &[None, Some(ValType::I32), Some(ValType::F32)] {
let mut params = vec![]; let mut params = vec![];

View File

@@ -143,7 +143,6 @@ fn to_val_type(type_: &wasmparser::ValType) -> Result<ValType> {
I64 => ValType::I64, I64 => ValType::I64,
F32 => ValType::F32, F32 => ValType::F32,
F64 => ValType::F64, F64 => ValType::F64,
V128 => ValType::V128,
_ => bail!("Type {:?} isn't a value type", type_), _ => bail!("Type {:?} isn't a value type", type_),
}) })
} }
@@ -973,244 +972,6 @@ fn remap_function(
De::I64TruncSatF64U => En::I64TruncSatF64U, De::I64TruncSatF64U => En::I64TruncSatF64U,
De::MemoryCopy { src_mem, dst_mem } => En::MemoryCopy { src_mem, dst_mem }, De::MemoryCopy { src_mem, dst_mem } => En::MemoryCopy { src_mem, dst_mem },
De::MemoryFill { mem } => En::MemoryFill(mem), De::MemoryFill { mem } => En::MemoryFill(mem),
De::V128Const { value } => En::V128Const(value.i128()),
De::V128Load { memarg } => En::V128Load(mem(memarg)),
De::V128Store { memarg } => En::V128Store(mem(memarg)),
De::V128Load8x8S { memarg } => En::V128Load8x8S(mem(memarg)),
De::V128Load8x8U { memarg } => En::V128Load8x8U(mem(memarg)),
De::V128Load16x4S { memarg } => En::V128Load16x4S(mem(memarg)),
De::V128Load16x4U { memarg } => En::V128Load16x4U(mem(memarg)),
De::V128Load32x2S { memarg } => En::V128Load32x2S(mem(memarg)),
De::V128Load32x2U { memarg } => En::V128Load32x2U(mem(memarg)),
De::V128Load8Splat { memarg } => En::V128Load8Splat(mem(memarg)),
De::V128Load16Splat { memarg } => En::V128Load16Splat(mem(memarg)),
De::V128Load32Splat { memarg } => En::V128Load32Splat(mem(memarg)),
De::V128Load64Splat { memarg } => En::V128Load64Splat(mem(memarg)),
De::V128Load32Zero { memarg } => En::V128Load32Zero(mem(memarg)),
De::V128Load64Zero { memarg } => En::V128Load64Zero(mem(memarg)),
De::V128Load8Lane { memarg, lane } => En::V128Load8Lane { memarg: mem(memarg), lane },
De::V128Load16Lane { memarg, lane } => En::V128Load16Lane { memarg: mem(memarg), lane },
De::V128Load32Lane { memarg, lane } => En::V128Load32Lane { memarg: mem(memarg), lane },
De::V128Load64Lane { memarg, lane } => En::V128Load64Lane { memarg: mem(memarg), lane },
De::V128Store8Lane { memarg, lane } => En::V128Store8Lane { memarg: mem(memarg), lane },
De::V128Store16Lane { memarg, lane } => En::V128Store16Lane { memarg: mem(memarg), lane },
De::V128Store32Lane { memarg, lane } => En::V128Store32Lane { memarg: mem(memarg), lane },
De::V128Store64Lane { memarg, lane } => En::V128Store64Lane { memarg: mem(memarg), lane },
De::I8x16ExtractLaneS { lane } => En::I8x16ExtractLaneS(lane),
De::I8x16ExtractLaneU { lane } => En::I8x16ExtractLaneU(lane),
De::I8x16ReplaceLane { lane } => En::I8x16ReplaceLane(lane),
De::I16x8ExtractLaneS { lane } => En::I16x8ExtractLaneS(lane),
De::I16x8ExtractLaneU { lane } => En::I16x8ExtractLaneU(lane),
De::I16x8ReplaceLane { lane } => En::I16x8ReplaceLane(lane),
De::I32x4ExtractLane { lane } => En::I32x4ExtractLane(lane),
De::I32x4ReplaceLane { lane } => En::I32x4ReplaceLane(lane),
De::I64x2ExtractLane { lane } => En::I64x2ExtractLane(lane),
De::I64x2ReplaceLane { lane } => En::I64x2ReplaceLane(lane),
De::F32x4ExtractLane { lane } => En::F32x4ExtractLane(lane),
De::F32x4ReplaceLane { lane } => En::F32x4ReplaceLane(lane),
De::F64x2ExtractLane { lane } => En::F64x2ExtractLane(lane),
De::F64x2ReplaceLane { lane } => En::F64x2ReplaceLane(lane),
De::I8x16Splat => En::I8x16Splat,
De::I16x8Splat => En::I16x8Splat,
De::I32x4Splat => En::I32x4Splat,
De::I64x2Splat => En::I64x2Splat,
De::F32x4Splat => En::F32x4Splat,
De::F64x2Splat => En::F64x2Splat,
De::I8x16Swizzle => En::I8x16Swizzle,
De::I8x16Add => En::I8x16Add,
De::I16x8Add => En::I16x8Add,
De::I32x4Add => En::I32x4Add,
De::I64x2Add => En::I64x2Add,
De::F32x4Add => En::F32x4Add,
De::F64x2Add => En::F64x2Add,
De::I8x16Sub => En::I8x16Sub,
De::I16x8Sub => En::I16x8Sub,
De::I32x4Sub => En::I32x4Sub,
De::I64x2Sub => En::I64x2Sub,
De::F32x4Sub => En::F32x4Sub,
De::F64x2Sub => En::F64x2Sub,
De::I16x8Mul => En::I16x8Mul,
De::I32x4Mul => En::I32x4Mul,
De::I64x2Mul => En::I64x2Mul,
De::F32x4Mul => En::F32x4Mul,
De::F64x2Mul => En::F64x2Mul,
De::I32x4DotI16x8S => En::I32x4DotI16x8S,
De::I8x16Neg => En::I8x16Neg,
De::I16x8Neg => En::I16x8Neg,
De::I32x4Neg => En::I32x4Neg,
De::I64x2Neg => En::I64x2Neg,
De::F32x4Neg => En::F32x4Neg,
De::F64x2Neg => En::F64x2Neg,
De::I16x8ExtMulLowI8x16S => En::I16x8ExtMulLowI8x16S,
De::I16x8ExtMulHighI8x16S => En::I16x8ExtMulHighI8x16S,
De::I16x8ExtMulLowI8x16U => En::I16x8ExtMulLowI8x16U,
De::I16x8ExtMulHighI8x16U => En::I16x8ExtMulHighI8x16U,
De::I32x4ExtMulLowI16x8S => En::I32x4ExtMulLowI16x8S,
De::I32x4ExtMulHighI16x8S => En::I32x4ExtMulHighI16x8S,
De::I32x4ExtMulLowI16x8U => En::I32x4ExtMulLowI16x8U,
De::I32x4ExtMulHighI16x8U => En::I32x4ExtMulHighI16x8U,
De::I64x2ExtMulLowI32x4S => En::I64x2ExtMulLowI32x4S,
De::I64x2ExtMulHighI32x4S => En::I64x2ExtMulHighI32x4S,
De::I64x2ExtMulLowI32x4U => En::I64x2ExtMulLowI32x4U,
De::I64x2ExtMulHighI32x4U => En::I64x2ExtMulHighI32x4U,
De::I16x8ExtAddPairwiseI8x16S => En::I16x8ExtAddPairwiseI8x16S,
De::I16x8ExtAddPairwiseI8x16U => En::I16x8ExtAddPairwiseI8x16U,
De::I32x4ExtAddPairwiseI16x8S => En::I32x4ExtAddPairwiseI16x8S,
De::I32x4ExtAddPairwiseI16x8U => En::I32x4ExtAddPairwiseI16x8U,
De::I8x16AddSatS => En::I8x16AddSatS,
De::I8x16AddSatU => En::I8x16AddSatU,
De::I16x8AddSatS => En::I16x8AddSatS,
De::I16x8AddSatU => En::I16x8AddSatU,
De::I8x16SubSatS => En::I8x16SubSatS,
De::I8x16SubSatU => En::I8x16SubSatU,
De::I16x8SubSatS => En::I16x8SubSatS,
De::I16x8SubSatU => En::I16x8SubSatU,
De::I16x8Q15MulrSatS => En::I16x8Q15MulrSatS,
De::I8x16MinS => En::I8x16MinS,
De::I8x16MinU => En::I8x16MinU,
De::I16x8MinS => En::I16x8MinS,
De::I16x8MinU => En::I16x8MinU,
De::I32x4MinS => En::I32x4MinS,
De::I32x4MinU => En::I32x4MinU,
De::F32x4Min => En::F32x4Min,
De::F64x2Min => En::F64x2Min,
De::F32x4PMin => En::F32x4PMin,
De::F64x2PMin => En::F64x2PMin,
De::I8x16MaxS => En::I8x16MaxS,
De::I8x16MaxU => En::I8x16MaxU,
De::I16x8MaxS => En::I16x8MaxS,
De::I16x8MaxU => En::I16x8MaxU,
De::I32x4MaxS => En::I32x4MaxS,
De::I32x4MaxU => En::I32x4MaxU,
De::F32x4Max => En::F32x4Max,
De::F64x2Max => En::F64x2Max,
De::F32x4PMax => En::F32x4PMax,
De::F64x2PMax => En::F64x2PMax,
De::I8x16AvgrU => En::I8x16AvgrU,
De::I16x8AvgrU => En::I16x8AvgrU,
De::I8x16Abs => En::I8x16Abs,
De::I16x8Abs => En::I16x8Abs,
De::I32x4Abs => En::I32x4Abs,
De::I64x2Abs => En::I64x2Abs,
De::F32x4Abs => En::F32x4Abs,
De::F64x2Abs => En::F64x2Abs,
De::I8x16Shl => En::I8x16Shl,
De::I16x8Shl => En::I16x8Shl,
De::I32x4Shl => En::I32x4Shl,
De::I64x2Shl => En::I64x2Shl,
De::I8x16ShrS => En::I8x16ShrS,
De::I8x16ShrU => En::I8x16ShrU,
De::I16x8ShrS => En::I16x8ShrS,
De::I16x8ShrU => En::I16x8ShrU,
De::I32x4ShrS => En::I32x4ShrS,
De::I32x4ShrU => En::I32x4ShrU,
De::I64x2ShrS => En::I64x2ShrS,
De::I64x2ShrU => En::I64x2ShrU,
De::V128And => En::V128And,
De::V128Or => En::V128Or,
De::V128Xor => En::V128Xor,
De::V128Not => En::V128Not,
De::V128AndNot => En::V128AndNot,
De::V128Bitselect => En::V128Bitselect,
De::I8x16Popcnt => En::I8x16Popcnt,
De::V128AnyTrue => En::V128AnyTrue,
De::I8x16AllTrue => En::I8x16AllTrue,
De::I16x8AllTrue => En::I16x8AllTrue,
De::I32x4AllTrue => En::I32x4AllTrue,
De::I64x2AllTrue => En::I64x2AllTrue,
De::I8x16Bitmask => En::I8x16Bitmask,
De::I16x8Bitmask => En::I16x8Bitmask,
De::I32x4Bitmask => En::I32x4Bitmask,
De::I64x2Bitmask => En::I64x2Bitmask,
De::I8x16Eq => En::I8x16Eq,
De::I16x8Eq => En::I16x8Eq,
De::I32x4Eq => En::I32x4Eq,
De::I64x2Eq => En::I64x2Eq,
De::F32x4Eq => En::F32x4Eq,
De::F64x2Eq => En::F64x2Eq,
De::I8x16Ne => En::I8x16Ne,
De::I16x8Ne => En::I16x8Ne,
De::I32x4Ne => En::I32x4Ne,
De::I64x2Ne => En::I64x2Ne,
De::F32x4Ne => En::F32x4Ne,
De::F64x2Ne => En::F64x2Ne,
De::I8x16LtS => En::I8x16LtS,
De::I8x16LtU => En::I8x16LtU,
De::I16x8LtS => En::I16x8LtS,
De::I16x8LtU => En::I16x8LtU,
De::I32x4LtS => En::I32x4LtS,
De::I32x4LtU => En::I32x4LtU,
De::F32x4Lt => En::F32x4Lt,
De::F64x2Lt => En::F64x2Lt,
De::I8x16LeS => En::I8x16LeS,
De::I8x16LeU => En::I8x16LeU,
De::I16x8LeS => En::I16x8LeS,
De::I16x8LeU => En::I16x8LeU,
De::I32x4LeS => En::I32x4LeS,
De::I32x4LeU => En::I32x4LeU,
De::F32x4Le => En::F32x4Le,
De::F64x2Le => En::F64x2Le,
De::I8x16GtS => En::I8x16GtS,
De::I8x16GtU => En::I8x16GtU,
De::I16x8GtS => En::I16x8GtS,
De::I16x8GtU => En::I16x8GtU,
De::I32x4GtS => En::I32x4GtS,
De::I32x4GtU => En::I32x4GtU,
De::F32x4Gt => En::F32x4Gt,
De::F64x2Gt => En::F64x2Gt,
De::I8x16GeS => En::I8x16GeS,
De::I8x16GeU => En::I8x16GeU,
De::I16x8GeS => En::I16x8GeS,
De::I16x8GeU => En::I16x8GeU,
De::I32x4GeS => En::I32x4GeS,
De::I32x4GeU => En::I32x4GeU,
De::F32x4Ge => En::F32x4Ge,
De::F64x2Ge => En::F64x2Ge,
De::F32x4Div => En::F32x4Div,
De::F64x2Div => En::F64x2Div,
De::F32x4Sqrt => En::F32x4Sqrt,
De::F64x2Sqrt => En::F64x2Sqrt,
De::F32x4Ceil => En::F32x4Ceil,
De::F64x2Ceil => En::F64x2Ceil,
De::F32x4Floor => En::F32x4Floor,
De::F64x2Floor => En::F64x2Floor,
De::F32x4Trunc => En::F32x4Trunc,
De::F64x2Trunc => En::F64x2Trunc,
De::F32x4Nearest => En::F32x4Nearest,
De::F64x2Nearest => En::F64x2Nearest,
De::F32x4ConvertI32x4S => En::F32x4ConvertI32x4S,
De::F32x4ConvertI32x4U => En::F32x4ConvertI32x4U,
De::F64x2ConvertLowI32x4S => En::F64x2ConvertLowI32x4S,
De::F64x2ConvertLowI32x4U => En::F64x2ConvertLowI32x4U,
De::I32x4TruncSatF32x4S => En::I32x4TruncSatF32x4S,
De::I32x4TruncSatF32x4U => En::I32x4TruncSatF32x4U,
De::I32x4TruncSatF64x2SZero => En::I32x4TruncSatF64x2SZero,
De::I32x4TruncSatF64x2UZero => En::I32x4TruncSatF64x2UZero,
De::F32x4DemoteF64x2Zero => En::F32x4DemoteF64x2Zero,
De::F64x2PromoteLowF32x4 => En::F64x2PromoteLowF32x4,
De::I8x16NarrowI16x8S => En::I8x16NarrowI16x8S,
De::I8x16NarrowI16x8U => En::I8x16NarrowI16x8U,
De::I16x8NarrowI32x4S => En::I16x8NarrowI32x4S,
De::I16x8NarrowI32x4U => En::I16x8NarrowI32x4U,
De::I16x8ExtendLowI8x16S => En::I16x8ExtendLowI8x16S,
De::I16x8ExtendHighI8x16S => En::I16x8ExtendHighI8x16S,
De::I16x8ExtendLowI8x16U => En::I16x8ExtendLowI8x16U,
De::I16x8ExtendHighI8x16U => En::I16x8ExtendHighI8x16U,
De::I32x4ExtendLowI16x8S => En::I32x4ExtendLowI16x8S,
De::I32x4ExtendHighI16x8S => En::I32x4ExtendHighI16x8S,
De::I32x4ExtendLowI16x8U => En::I32x4ExtendLowI16x8U,
De::I32x4ExtendHighI16x8U => En::I32x4ExtendHighI16x8U,
De::I64x2ExtendLowI32x4S => En::I64x2ExtendLowI32x4S,
De::I64x2ExtendHighI32x4S => En::I64x2ExtendHighI32x4S,
De::I64x2ExtendLowI32x4U => En::I64x2ExtendLowI32x4U,
De::I64x2ExtendHighI32x4U => En::I64x2ExtendHighI32x4U,
De::I8x16Shuffle { lanes } => En::I8x16Shuffle(lanes),
other => bail!("Unsupported instruction {:?}", other), other => bail!("Unsupported instruction {:?}", other),
}); });
} }

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,7 +1,7 @@
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use winit::dpi::PhysicalSize; use winit::dpi::PhysicalSize;
use super::Filter; use super::{scale_mode::ScaleMode, Filter};
pub struct CrtFilter { pub struct CrtFilter {
uniform_buffer: wgpu::Buffer, uniform_buffer: wgpu::Buffer,
@@ -15,9 +15,10 @@ impl CrtFilter {
screen: &wgpu::TextureView, screen: &wgpu::TextureView,
resolution: PhysicalSize<u32>, resolution: PhysicalSize<u32>,
surface_format: wgpu::TextureFormat, surface_format: wgpu::TextureFormat,
scale_mode: ScaleMode,
) -> CrtFilter { ) -> CrtFilter {
let uniforms = Uniforms { let uniforms = Uniforms {
texture_scale: texture_scale_from_resolution(resolution), texture_scale: scale_mode.texture_scale_from_resolution(resolution),
}; };
let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
@@ -112,9 +113,9 @@ impl CrtFilter {
} }
impl Filter for CrtFilter { impl Filter for CrtFilter {
fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>) { fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>, scale_mode: ScaleMode) {
let uniforms = Uniforms { let uniforms = Uniforms {
texture_scale: texture_scale_from_resolution(new_size), texture_scale: scale_mode.texture_scale_from_resolution(new_size),
}; };
queue.write_buffer(&self.uniform_buffer, 0, bytemuck::cast_slice(&[uniforms])); queue.write_buffer(&self.uniform_buffer, 0, bytemuck::cast_slice(&[uniforms]));
} }
@@ -126,16 +127,6 @@ impl Filter for CrtFilter {
} }
} }
fn texture_scale_from_resolution(res: PhysicalSize<u32>) -> [f32; 4] {
let scale = ((res.width as f32) / 160.0).min((res.height as f32) / 120.0);
[
res.width as f32 / scale,
res.height as f32 / scale,
2.0 / scale,
0.0,
]
}
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] #[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
struct Uniforms { struct Uniforms {

View File

@@ -17,7 +17,7 @@ fn vs_main(
let i = in_vertex_index / 3u + in_vertex_index % 3u; let i = in_vertex_index / 3u + in_vertex_index % 3u;
let x = -1.0 + f32(i % 2u) * 322.0; let x = -1.0 + f32(i % 2u) * 322.0;
let y = -1.0 + f32(i / 2u) * 242.0; let y = -1.0 + f32(i / 2u) * 242.0;
out.clip_position = vec4<f32>((vec2<f32>(x, y) - vec2<f32>(160.0, 120.0)) / uniforms.texture_scale.xy, 0.0, 1.0); out.clip_position = vec4<f32>((vec2<f32>(x, y) - vec2<f32>(160.0, 120.0)) * uniforms.texture_scale.xy, 0.0, 1.0);
out.tex_coords = vec2<f32>(x, y); out.tex_coords = vec2<f32>(x, y);
return out; return out;
} }

View File

@@ -1,7 +1,7 @@
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use winit::dpi::PhysicalSize; use winit::dpi::PhysicalSize;
use super::Filter; use super::{scale_mode::ScaleMode, Filter};
pub struct FastCrtFilter { pub struct FastCrtFilter {
uniform_buffer: wgpu::Buffer, uniform_buffer: wgpu::Buffer,
@@ -16,9 +16,10 @@ impl FastCrtFilter {
resolution: PhysicalSize<u32>, resolution: PhysicalSize<u32>,
surface_format: wgpu::TextureFormat, surface_format: wgpu::TextureFormat,
chromatic: bool, chromatic: bool,
scale_mode: ScaleMode,
) -> FastCrtFilter { ) -> FastCrtFilter {
let uniforms = Uniforms { let uniforms = Uniforms {
texture_scale: texture_scale_from_resolution(resolution), texture_scale: scale_mode.texture_scale_from_resolution(resolution),
}; };
let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
@@ -131,9 +132,9 @@ impl FastCrtFilter {
} }
impl Filter for FastCrtFilter { impl Filter for FastCrtFilter {
fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>) { fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>, scale_mode: ScaleMode) {
let uniforms = Uniforms { let uniforms = Uniforms {
texture_scale: texture_scale_from_resolution(new_size), texture_scale: scale_mode.texture_scale_from_resolution(new_size),
}; };
queue.write_buffer(&self.uniform_buffer, 0, bytemuck::cast_slice(&[uniforms])); queue.write_buffer(&self.uniform_buffer, 0, bytemuck::cast_slice(&[uniforms]));
} }
@@ -145,16 +146,6 @@ impl Filter for FastCrtFilter {
} }
} }
fn texture_scale_from_resolution(res: PhysicalSize<u32>) -> [f32; 4] {
let scale = ((res.width as f32) / 160.0).min((res.height as f32) / 120.0);
[
scale / res.width as f32,
scale / res.height as f32,
2.0 / scale,
0.0,
]
}
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] #[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
struct Uniforms { struct Uniforms {

View File

@@ -1,18 +1,20 @@
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 scale_mode::ScaleMode;
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;
pub mod scale_mode;
mod square; mod square;
use crt::CrtFilter; use crt::CrtFilter;
@@ -21,7 +23,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,17 +31,18 @@ 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,
is_open: bool, is_open: bool,
scale_mode: ScaleMode,
} }
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 +59,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,
@@ -92,6 +93,7 @@ impl Window {
window.inner_size(), window.inner_size(),
surface_config.format, surface_config.format,
window_config.filter, window_config.filter,
window_config.scale_mode,
); );
surface.configure(&device, &surface_config); surface.configure(&device, &surface_config);
@@ -111,6 +113,7 @@ impl Window {
next_frame: Instant::now(), next_frame: Instant::now(),
is_fullscreen: window_config.fullscreen, is_fullscreen: window_config.fullscreen,
is_open: true, is_open: true,
scale_mode: window_config.scale_mode,
}) })
} }
@@ -121,11 +124,8 @@ 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 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; let mut new_filter = None;
match event { match event {
Event::WindowEvent { event, .. } => match event { Event::WindowEvent { event, .. } => match event {
@@ -133,34 +133,35 @@ impl WindowImpl for Window {
self.surface_config.width = new_size.width; self.surface_config.width = new_size.width;
self.surface_config.height = new_size.height; self.surface_config.height = new_size.height;
self.surface.configure(&self.device, &self.surface_config); self.surface.configure(&self.device, &self.surface_config);
self.filter.resize(&self.queue, new_size); self.filter.resize(&self.queue, new_size, self.scale_mode);
} }
WindowEvent::CloseRequested => { WindowEvent::CloseRequested => {
elwt.exit(); self.is_open = false;
*control_flow = ControlFlow::Exit;
} }
WindowEvent::KeyboardInput { event, .. } => { WindowEvent::KeyboardInput { input, .. } => {
fn gamepad_button(input: &winit::event::KeyEvent) -> u8 { fn gamepad_button(input: &winit::event::KeyboardInput) -> u8 {
match input.physical_key { match input.scancode {
PhysicalKey::Code(KeyCode::KeyZ) => 16, 44 => 16,
PhysicalKey::Code(KeyCode::KeyX) => 32, 45 => 32,
PhysicalKey::Code(KeyCode::KeyA) => 64, 30 => 64,
PhysicalKey::Code(KeyCode::KeyS) => 128, 31 => 128,
_ => match input.logical_key { _ => match input.virtual_keycode {
Key::Named(NamedKey::ArrowUp) => 1, Some(VirtualKeyCode::Up) => 1,
Key::Named(NamedKey::ArrowDown) => 2, Some(VirtualKeyCode::Down) => 2,
Key::Named(NamedKey::ArrowLeft) => 4, Some(VirtualKeyCode::Left) => 4,
Key::Named(NamedKey::ArrowRight) => 8, Some(VirtualKeyCode::Right) => 8,
_ => 0, _ => 0,
}, },
} }
} }
if event.state == winit::event::ElementState::Pressed { if input.state == winit::event::ElementState::Pressed {
match event.logical_key { match input.virtual_keycode {
Key::Named(NamedKey::Escape) => { Some(VirtualKeyCode::Escape) => {
elwt.exit(); self.is_open = false;
*control_flow = ControlFlow::Exit;
} }
Key::Character(ref c) => match c.as_str() { Some(VirtualKeyCode::F) => {
"f" => {
let fullscreen = if self.window.fullscreen().is_some() { let fullscreen = if self.window.fullscreen().is_some() {
None None
} else { } else {
@@ -169,24 +170,44 @@ impl WindowImpl for Window {
self.is_fullscreen = fullscreen.is_some(); self.is_fullscreen = fullscreen.is_some();
self.window.set_fullscreen(fullscreen); self.window.set_fullscreen(fullscreen);
} }
"r" => reset = true, Some(VirtualKeyCode::M) => {
"1" => new_filter = Some(1), self.scale_mode = match self.scale_mode {
"2" => new_filter = Some(2), ScaleMode::Fit => ScaleMode::Fill,
"3" => new_filter = Some(3), ScaleMode::Fill => ScaleMode::Fit,
"4" => new_filter = Some(4), };
"5" => new_filter = Some(5), self.filter.resize(
_ => (), &self.queue,
PhysicalSize {
width: self.surface_config.width,
height: self.surface_config.height,
}, },
self.scale_mode,
);
}
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 { if let Some(new_filter) = new_filter {
@@ -196,18 +217,10 @@ impl WindowImpl for Window {
self.window.inner_size(), self.window.inner_size(),
self.surface_config.format, self.surface_config.format,
new_filter, new_filter,
self.scale_mode,
); );
} }
}); });
match status {
PumpStatus::Exit(_) => self.is_open = false,
_ => (),
}
if Instant::now() >= self.next_frame {
break;
}
}
Input { Input {
gamepads: self.gamepads, gamepads: self.gamepads,
reset, reset,
@@ -243,12 +256,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);
@@ -269,6 +280,7 @@ fn create_filter(
window_size: PhysicalSize<u32>, window_size: PhysicalSize<u32>,
surface_format: wgpu::TextureFormat, surface_format: wgpu::TextureFormat,
filter: u32, filter: u32,
scale_mode: ScaleMode,
) -> Box<dyn Filter> { ) -> Box<dyn Filter> {
match filter { match filter {
1 => Box::new(SquareFilter::new( 1 => Box::new(SquareFilter::new(
@@ -276,6 +288,7 @@ fn create_filter(
screen_texture, screen_texture,
window_size, window_size,
surface_format, surface_format,
scale_mode,
)), )),
2 => Box::new(FastCrtFilter::new( 2 => Box::new(FastCrtFilter::new(
device, device,
@@ -283,12 +296,14 @@ fn create_filter(
window_size, window_size,
surface_format, surface_format,
false, false,
scale_mode,
)), )),
3 => Box::new(CrtFilter::new( 3 => Box::new(CrtFilter::new(
device, device,
screen_texture, screen_texture,
window_size, window_size,
surface_format, surface_format,
scale_mode,
)), )),
4 => Box::new(FastCrtFilter::new( 4 => Box::new(FastCrtFilter::new(
device, device,
@@ -296,18 +311,20 @@ fn create_filter(
window_size, window_size,
surface_format, surface_format,
true, true,
scale_mode,
)), )),
_ => Box::new(AutoCrtFilter::new( _ => Box::new(AutoCrtFilter::new(
device, device,
screen_texture, screen_texture,
window_size, window_size,
surface_format, surface_format,
scale_mode,
)), )),
} }
} }
trait Filter { trait Filter {
fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>); fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>, scale_mode: ScaleMode);
fn render<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>); fn render<'a>(&'a self, render_pass: &mut wgpu::RenderPass<'a>);
} }
@@ -323,9 +340,11 @@ impl AutoCrtFilter {
screen: &wgpu::TextureView, screen: &wgpu::TextureView,
resolution: PhysicalSize<u32>, resolution: PhysicalSize<u32>,
surface_format: wgpu::TextureFormat, surface_format: wgpu::TextureFormat,
scale_mode: ScaleMode,
) -> AutoCrtFilter { ) -> AutoCrtFilter {
let small = CrtFilter::new(device, screen, resolution, surface_format); let small = CrtFilter::new(device, screen, resolution, surface_format, scale_mode);
let large = FastCrtFilter::new(device, screen, resolution, surface_format, true); let large =
FastCrtFilter::new(device, screen, resolution, surface_format, true, scale_mode);
AutoCrtFilter { AutoCrtFilter {
small, small,
large, large,
@@ -335,9 +354,9 @@ impl AutoCrtFilter {
} }
impl Filter for AutoCrtFilter { impl Filter for AutoCrtFilter {
fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>) { fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>, scale_mode: ScaleMode) {
self.small.resize(queue, new_size); self.small.resize(queue, new_size, scale_mode);
self.large.resize(queue, new_size); self.large.resize(queue, new_size, scale_mode);
self.resolution = new_size; self.resolution = new_size;
} }
@@ -550,12 +569,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

@@ -0,0 +1,28 @@
use winit::dpi::PhysicalSize;
#[derive(Debug, Copy, Clone)]
pub enum ScaleMode {
Fit,
Fill,
}
impl Default for ScaleMode {
fn default() -> ScaleMode {
ScaleMode::Fit
}
}
impl ScaleMode {
pub fn texture_scale_from_resolution(&self, res: PhysicalSize<u32>) -> [f32; 4] {
let scale = match self {
ScaleMode::Fit => ((res.width as f32) / 160.0).min((res.height as f32) / 120.0),
ScaleMode::Fill => ((res.width as f32) / 160.0).max((res.height as f32) / 120.0),
};
[
scale / res.width as f32,
scale / res.height as f32,
2.0 / scale,
0.0,
]
}
}

View File

@@ -1,7 +1,7 @@
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use winit::dpi::PhysicalSize; use winit::dpi::PhysicalSize;
use super::Filter; use super::{scale_mode::ScaleMode, Filter};
pub struct SquareFilter { pub struct SquareFilter {
uniform_buffer: wgpu::Buffer, uniform_buffer: wgpu::Buffer,
@@ -15,9 +15,10 @@ impl SquareFilter {
screen: &wgpu::TextureView, screen: &wgpu::TextureView,
resolution: PhysicalSize<u32>, resolution: PhysicalSize<u32>,
surface_format: wgpu::TextureFormat, surface_format: wgpu::TextureFormat,
scale_mode: ScaleMode,
) -> SquareFilter { ) -> SquareFilter {
let uniforms = Uniforms { let uniforms = Uniforms {
texture_scale: texture_scale_from_resolution(resolution), texture_scale: scale_mode.texture_scale_from_resolution(resolution),
}; };
let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { let uniform_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
@@ -126,9 +127,9 @@ impl SquareFilter {
} }
impl Filter for SquareFilter { impl Filter for SquareFilter {
fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>) { fn resize(&mut self, queue: &wgpu::Queue, new_size: PhysicalSize<u32>, scale_mode: ScaleMode) {
let uniforms = Uniforms { let uniforms = Uniforms {
texture_scale: texture_scale_from_resolution(new_size), texture_scale: scale_mode.texture_scale_from_resolution(new_size),
}; };
queue.write_buffer(&self.uniform_buffer, 0, bytemuck::cast_slice(&[uniforms])); queue.write_buffer(&self.uniform_buffer, 0, bytemuck::cast_slice(&[uniforms]));
} }
@@ -140,16 +141,6 @@ impl Filter for SquareFilter {
} }
} }
fn texture_scale_from_resolution(res: PhysicalSize<u32>) -> [f32; 4] {
let scale = ((res.width as f32) / 160.0).min((res.height as f32) / 120.0);
[
scale / res.width as f32,
scale / res.height as f32,
2.0 / scale,
0.0,
]
}
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)] #[derive(Debug, Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
struct Uniforms { struct Uniforms {

View File

@@ -1,4 +1,5 @@
use anyhow::Result; use anyhow::Result;
use gpu::scale_mode::ScaleMode;
use std::time::Instant; use std::time::Instant;
mod cpu; mod cpu;
@@ -73,6 +74,7 @@ pub struct WindowConfig {
fullscreen: bool, fullscreen: bool,
fps_counter: bool, fps_counter: bool,
scale: f32, scale: f32,
scale_mode: ScaleMode,
} }
impl Default for WindowConfig { impl Default for WindowConfig {
@@ -83,6 +85,7 @@ impl Default for WindowConfig {
fullscreen: false, fullscreen: false,
fps_counter: false, fps_counter: false,
scale: 2., scale: 2.,
scale_mode: ScaleMode::Fit,
} }
} }
} }
@@ -109,6 +112,9 @@ impl WindowConfig {
.opt_value_from_str("--scale") .opt_value_from_str("--scale")
.unwrap() .unwrap()
.unwrap_or(self.scale); .unwrap_or(self.scale);
if args.contains("--scale-fill") {
self.scale_mode = ScaleMode::Fill;
}
} }
} }

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.1
</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">