diff --git a/.gitignore b/.gitignore index d81f12e..4500ed8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /.idea +.direnv diff --git a/Cargo.lock b/Cargo.lock index 8471727..1d5db7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,9 +477,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -1622,9 +1622,9 @@ dependencies = [ [[package]] name = "servicepoint2" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54d49d501f34100406d70730d887775ed5961b6343ccb10d5ef0e105d7b295ae" +checksum = "94d9aecc4d31a71578481de6c6d64383d374126c38469c9689067579c1d910fd" dependencies = [ "bzip2", "flate2", diff --git a/Cargo.toml b/Cargo.toml index d80569f..74bfa8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ license = "GPL-3.0-or-later" [dependencies] # packet parsing -servicepoint2 = "0.4.1" +servicepoint2 = { version = "0.4.2", features = ["all_compressions"] } # gui winit = { version = "0.30", features = ["rwh_05"] } # for creating a window diff --git a/shell.nix b/shell.nix index 0818d4c..c781cf1 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,11 @@ -{ pkgs ? import {} }: - pkgs.mkShell { - nativeBuildInputs = with pkgs.buildPackages; [ rustup pkg-config xe lzma ]; +{pkgs ? import {}}: +pkgs.mkShell { + nativeBuildInputs = with pkgs.buildPackages; [ + rustup + pkg-config + xe + lzma + libxkbcommon + wayland + ]; } diff --git a/src/execute_command.rs b/src/execute_command.rs index 0734e9e..4f7f364 100644 --- a/src/execute_command.rs +++ b/src/execute_command.rs @@ -2,7 +2,8 @@ use std::sync::{RwLock, RwLockWriteGuard}; use log::{debug, error, info, warn}; use servicepoint2::{ - ByteGrid, Command, Origin, PixelGrid, PIXEL_COUNT, PIXEL_WIDTH, TILE_SIZE, + ByteGrid, Command, Grid, Origin, PIXEL_COUNT, PIXEL_WIDTH, PixelGrid, + TILE_SIZE, }; use crate::font::BitmapFont; @@ -25,7 +26,7 @@ pub(crate) fn execute_command( } Command::BitmapLinearWin(Origin(x, y), pixels, _) => { let mut display = display_ref.write().unwrap(); - print_pixel_grid(x as usize, y as usize, &pixels, &mut display); + print_pixel_grid(x, y, &pixels, &mut display); } Command::Cp437Data(origin, grid) => { let mut display = display_ref.write().unwrap(); @@ -37,7 +38,7 @@ pub(crate) fn execute_command( } // TODO: how to deduplicate this code in a rusty way? Command::BitmapLinear(offset, vec, _) => { - if !check_bitmap_valid(offset, vec.len()) { + if !check_bitmap_valid(offset as u16, vec.len()) { return true; } let mut display = display_ref.write().unwrap(); @@ -48,7 +49,7 @@ pub(crate) fn execute_command( } } Command::BitmapLinearAnd(offset, vec, _) => { - if !check_bitmap_valid(offset, vec.len()) { + if !check_bitmap_valid(offset as u16, vec.len()) { return true; } let mut display = display_ref.write().unwrap(); @@ -60,7 +61,7 @@ pub(crate) fn execute_command( } } Command::BitmapLinearOr(offset, vec, _) => { - if !check_bitmap_valid(offset, vec.len()) { + if !check_bitmap_valid(offset as u16, vec.len()) { return true; } let mut display = display_ref.write().unwrap(); @@ -72,7 +73,7 @@ pub(crate) fn execute_command( } } Command::BitmapLinearXor(offset, vec, _) => { - if !check_bitmap_valid(offset, vec.len()) { + if !check_bitmap_valid(offset as u16, vec.len()) { return true; } let mut display = display_ref.write().unwrap(); @@ -85,8 +86,6 @@ pub(crate) fn execute_command( } Command::CharBrightness(origin, grid) => { let Origin(offset_x, offset_y) = origin; - let offset_x = offset_x as usize; - let offset_y = offset_y as usize; let mut luma = luma_ref.write().unwrap(); for inner_y in 0..grid.height() { @@ -130,9 +129,6 @@ fn print_cp437_data( display: &mut RwLockWriteGuard, ) { let Origin(x, y) = origin; - let x = x as usize; - let y = y as usize; - for char_y in 0usize..grid.height() { for char_x in 0usize..grid.width() { let char_code = grid.get(char_x, char_y); @@ -142,8 +138,8 @@ fn print_cp437_data( let bitmap = font.get_bitmap(char_code); if !print_pixel_grid( - tile_x * TILE_SIZE as usize, - tile_y * TILE_SIZE as usize, + tile_x * TILE_SIZE, + tile_y * TILE_SIZE, bitmap, display, ) { @@ -185,8 +181,5 @@ fn print_pixel_grid( fn get_coordinates_for_index(offset: usize, index: usize) -> (usize, usize) { let pixel_index = offset + index; - ( - pixel_index % PIXEL_WIDTH as usize, - pixel_index / PIXEL_WIDTH as usize, - ) + (pixel_index % PIXEL_WIDTH, pixel_index / PIXEL_WIDTH) }