remvove lock_display

This commit is contained in:
2025-10-28 12:36:15 -06:00
parent a7daa4c5fc
commit 1182560582
8 changed files with 23 additions and 55 deletions

View File

@@ -61,10 +61,6 @@ pub mod display {
pub type Pixel565 = Pixel<Rgb565>;
pub fn lock_display(lock: bool) {
abi_sys::lock_display(lock);
}
const BUF_SIZE: usize = 15 * 1024; // tune this for performance
static mut BUF: [CPixel; BUF_SIZE] = [CPixel::new(); BUF_SIZE];
// const BUF_SIZE: usize = 250 * 1024; // tune this for performance

View File

@@ -13,7 +13,7 @@ use strum::{EnumCount, EnumIter};
pub type EntryFn = fn();
pub const ABI_CALL_TABLE_COUNT: usize = 12;
pub const ABI_CALL_TABLE_COUNT: usize = 11;
const _: () = assert!(ABI_CALL_TABLE_COUNT == CallTable::COUNT);
#[derive(Clone, Copy, EnumIter, EnumCount)]
@@ -24,13 +24,12 @@ pub enum CallTable {
PrintString = 2,
SleepMs = 3,
GetMs = 4,
LockDisplay = 5,
DrawIter = 6,
GetKey = 7,
GenRand = 8,
ListDir = 9,
ReadFile = 10,
FileLen = 11,
DrawIter = 5,
GetKey = 6,
GenRand = 7,
ListDir = 8,
ReadFile = 9,
FileLen = 10,
}
#[unsafe(no_mangle)]
@@ -104,15 +103,6 @@ pub extern "C" fn get_ms() -> u64 {
f()
}
pub type LockDisplay = extern "C" fn(lock: bool);
#[unsafe(no_mangle)]
pub extern "C" fn lock_display(lock: bool) {
let f: LockDisplay =
unsafe { core::mem::transmute(CALL_ABI_TABLE[CallTable::LockDisplay as usize]) };
f(lock);
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct CPixel {

View File

@@ -1,6 +1,6 @@
use abi_sys::{
AllocAbi, CLayout, CPixel, DeallocAbi, DrawIterAbi, FileLen, GenRand, GetMsAbi, ListDir,
LockDisplay, PrintAbi, ReadFile, RngRequest, SleepMsAbi, keyboard::*,
PrintAbi, ReadFile, RngRequest, SleepMsAbi, keyboard::*,
};
use alloc::{string::ToString, vec::Vec};
use core::{alloc::GlobalAlloc, sync::atomic::Ordering};
@@ -73,11 +73,6 @@ pub extern "C" fn get_ms() -> u64 {
.as_millis()
}
const _: LockDisplay = lock_display;
pub extern "C" fn lock_display(lock: bool) {
FB_PAUSED.store(lock, Ordering::Release);
}
const _: DrawIterAbi = draw_iter;
pub extern "C" fn draw_iter(cpixels: *const CPixel, len: usize) {
// SAFETY: caller guarantees `ptr` is valid for `len` bytes

View File

@@ -201,7 +201,6 @@ fn patch_abi(
CallTable::PrintString => abi::print as usize,
CallTable::SleepMs => abi::sleep as usize,
CallTable::GetMs => abi::get_ms as usize,
CallTable::LockDisplay => abi::lock_display as usize,
CallTable::DrawIter => abi::draw_iter as usize,
CallTable::GetKey => abi::get_key as usize,
CallTable::GenRand => abi::gen_rand as usize,

View File

@@ -3,7 +3,7 @@
extern crate alloc;
use abi::{
display::{Display, lock_display},
display::Display,
get_key,
keyboard::{KeyCode, KeyState},
print,
@@ -58,8 +58,6 @@ pub fn main() {
loop {
if dirty {
lock_display(true);
let style = PrimitiveStyle::with_fill(Rgb565::BLACK);
if let Some(area) = last_area {
Rectangle::new(area.0.top_left, area.0.size)
@@ -103,7 +101,6 @@ pub fn main() {
eq_layout.draw(&mut display).unwrap();
dirty = false;
lock_display(false);
}
let event = get_key();

View File

@@ -4,7 +4,7 @@
extern crate alloc;
use abi::{
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH, lock_display},
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
fs::{list_dir, read_file},
get_key,
keyboard::{KeyCode, KeyState},
@@ -70,7 +70,6 @@ pub fn main() {
let x = cell_x + (cell_width - bmp_w) / 2;
let y = cell_y + 5; // 5px top margin
lock_display(true);
Image::new(&bmp, Point::new(x, y))
.draw(&mut display)
.unwrap();
@@ -85,8 +84,6 @@ pub fn main() {
.draw(&mut display)
.unwrap();
lock_display(false);
images_drawn += 1;
}
}

View File

@@ -3,7 +3,7 @@
extern crate alloc;
use abi::{
display::{Display, lock_display},
display::Display,
fs::{file_len, read_file},
get_key, get_ms,
keyboard::{KeyCode, KeyState},
@@ -37,28 +37,24 @@ pub fn main() {
let gif = Gif::<Rgb565>::from_slice(&buf).unwrap();
// let mut frame_num = 0;
let mut frame_num = 0;
loop {
for frame in gif.frames() {
let start = get_ms();
// lock_display(true);
frame.draw(&mut display).unwrap();
// lock_display(false);
// frame_num += 1;
frame_num += 1;
if frame_num % 100 == 0 {
let event = get_key();
if event.state != KeyState::Idle {
match event.key {
KeyCode::Esc => return,
_ => (),
};
};
}
sleep(((frame.delay_centis as u64) * 10).saturating_sub(start));
// if frame_num % 100 == 0 {
// let event = get_key();
// if event.state != KeyState::Idle {
// match event.key {
// KeyCode::Esc => return,
// _ => (),
// };
// };
// }
}
}
}

View File

@@ -4,7 +4,7 @@
extern crate alloc;
use abi::{
Rng,
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH, lock_display},
display::{Display, SCREEN_HEIGHT, SCREEN_WIDTH},
get_key,
keyboard::{KeyCode, KeyState},
print, sleep,
@@ -57,10 +57,8 @@ pub fn main() {
};
// ensure all draws show up at once
lock_display(true);
game.pre_draw(&mut display);
game.draw(&mut display);
lock_display(false);
sleep(15);
}