add datetime device, revise device handling, remove tracing code

This commit is contained in:
Lobo 2025-12-19 00:31:36 -03:00
parent 56a3398c8f
commit cf31dc5564
8 changed files with 115 additions and 119 deletions

View file

@ -6,7 +6,8 @@ module Make () : Uxn.Device.DEVICE with type state = state = struct
type nonrec state = state
let state = { banks = Array.init 15 (fun _ -> Bytes.create 65536) }
let can_handle port = port >= 0x00 && port <= 0x0f
let dei_ports = Uxn.Device.Int_set.of_list [ 0x04; 0x05 ]
let deo_ports = Uxn.Device.Int_set.of_list [ 0x02; 0x04; 0x05; 0x0e; 0x0f ]
let print_stack ~name (Machine.Stack { data; sp }) =
Printf.eprintf "%s " name;
@ -76,13 +77,13 @@ module Make () : Uxn.Device.DEVICE with type state = state = struct
match port with
| 0x04 ->
let (Machine.Stack { sp; _ }) = Machine.wst m in
Some sp
sp
| 0x05 ->
let (Machine.Stack { sp; _ }) = Machine.rst m in
Some sp
| _ -> None
sp
| _ -> assert false
let dei2 _ _ = None
let dei2 _ _ = assert false
let deo mach port value =
match port with
@ -100,5 +101,5 @@ module Make () : Uxn.Device.DEVICE with type state = state = struct
Out_channel.flush stderr
end
| 0x0f -> Bytes.set_uint8 (Machine.dev mach) 0x0f value
| _ -> ()
| _ -> assert false
end