begin work on new device module system

This commit is contained in:
Lobo 2025-12-18 13:03:39 -03:00
parent 7b8871ffd9
commit 5769f6d470
11 changed files with 190 additions and 112 deletions

21
lib/Varvara/Console.ml Normal file
View file

@ -0,0 +1,21 @@
type state = { mutable console_vector : int }
module Make () : Uxn.Device.DEVICE with type state = state = struct
type nonrec state = state
let state = { console_vector = 0 }
let can_handle port = port >= 0x10 && port <= 0x1f
let dei _ _ = None
let dei2 _ _ = None
let deo _ port value =
match port with
| 0x10 -> state.console_vector <- value
| 0x18 ->
print_char (Char.chr value);
Out_channel.flush stdout
| 0x19 ->
prerr_char (Char.chr value);
Out_channel.flush stderr
| _ -> ()
end