Skip to content

Commit

Permalink
add resources
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Dec 28, 2024
1 parent 99a4eb3 commit 18de67a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ test:
cargo test --release

desktop:
cd examples/desktop && cargo run --release

desktop-dev:
cd examples/desktop && cargo run

terminal:
terminal-dev:
cd examples/terminal && cargo run

terminal:
cd examples/terminal && cargo run --release

web:
cd web && npm run serve

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
> Disclaimer 1.1: Altough the emulator already runs a good amount of games, it is still under development and you can track it development by checking [Tests](#tests) section.
>
| WebGL with WebAssembly | Desktop GUI with Rust |
| --- | --- |
| Web via WebAssembly | Desktop | Terminal |
| --- | --- | --- |
| ![Demo Web with Assembly](resources/demo-web.png) | ![First demo desktop GUI](resources/demo-desktop-1.png) ![Second demo desktop GUI](resources/demo-desktop-2.png) |
| Playing [Cookies Bakery by leafthief](https://leafthief.itch.io/cookies-bakery) | Playing [Unearthed by benjelter](https://benjelter.itch.io/unearthed) |
| Firefox 116.0.3 (64-bit) | macOS 11.6.2, 16GB, Quad-Core Intel Core i7, 1,2 GHz |
| `make web` | `make desktop` |
| Playing [Cookies Bakery by leafthief](https://leafthief.itch.io/cookies-bakery) | Playing [Unearthed by benjelter](https://benjelter.itch.io/unearthed) | ![Pokemon Blue by Nintendo](resources/demo-terminal-1.png) |
| Firefox 116.0.3 (64-bit) | macOS 11.6.2, 16GB, Quad-Core Intel Core i7, 1,2 GHz | Rio Terminal |
| `make web` | `make desktop` | `make terminal` |

## WebAssembly quick demo

Expand Down
Binary file added resources/demo-terminal-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions src/screen/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ use ratatui_image::{
Resize, StatefulImage,
};

const MAX_SCALE: u32 = 4;

pub fn run(gameboy: &mut Gameboy) -> Result<(), Box<dyn Error>> {
let original_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic| {
Expand Down Expand Up @@ -134,6 +136,7 @@ fn size() -> Rect {
Rect::new(0, 0, 30, 16)
}

#[inline]
fn get_image(gameboy: &mut Gameboy, scale: u32) -> image::DynamicImage {
// let harvest_moon = "/Users/rapha/harvest-moon.png";
// image::io::Reader::open(harvest_moon).unwrap().decode().unwrap()
Expand All @@ -142,7 +145,7 @@ fn get_image(gameboy: &mut Gameboy, scale: u32) -> image::DynamicImage {
let height = gameboy.height;

// Get the raw image data as a vector
let input: &Vec<u8> = &gameboy.image().to_vec();
let input: &[u8] = &gameboy.image();

// Allocate a new buffer for the RGB image, 3 bytes per pixel
let mut output_data = vec![0u8; width as usize * height as usize * 3];
Expand Down Expand Up @@ -205,7 +208,7 @@ impl App {
self.reset_images();
}
'o' => {
if self.scale >= 3 {
if self.scale >= MAX_SCALE {
self.scale = 1;
} else {
self.scale += 1;
Expand Down

0 comments on commit 18de67a

Please sign in to comment.