make #010e DEO print stack in the recommended repr

This commit is contained in:
Lobo 2025-12-18 15:50:34 -03:00
parent b71cf4343e
commit bc1bae5977
8 changed files with 837 additions and 52 deletions

View file

@ -5,24 +5,21 @@ type file_state =
| Dir_read of Unix.dir_handle * string (* dir_handle, filepath *)
| Dir_write
type file_device = {
type state = {
mutable filepath : string option;
mutable state : file_state;
mutable length : int;
}
module type ADDR = sig
val start_addr : int
val start : int
end
module Make (Addr : ADDR) : Uxn.Device.DEVICE with type state = file_device =
struct
type state = file_device
module Make (Addr : ADDR) : Uxn.Device.DEVICE with type state = state = struct
type nonrec state = state
let state = { filepath = None; state = Idle; length = 0 }
let can_handle port =
port >= Addr.start_addr && port <= Addr.start_addr + 0x0f
let can_handle port = port >= Addr.start && port <= Addr.start + 0x0f
let read_cstring ram addr =
let buf = Buffer.create 256 in
@ -204,17 +201,15 @@ struct
let open Uxn in
let ram = Machine.ram mach in
let dev = Machine.dev mach in
let with_success result =
file_success dev (Addr.start_addr + 0x02) result
in
match port - Addr.start_addr with
let with_success result = file_success dev (Addr.start + 0x02) result in
match port - Addr.start with
| 0x0a -> state.length <- value
| 0x04 -> file_stat (Machine.ram mach) value state.length |> with_success
| 0x06 -> file_delete () |> with_success
| 0x08 -> file_init (Machine.ram mach) value |> with_success
| 0x0c -> file_read (Machine.ram mach) value state.length |> with_success
| 0x0e ->
let append = Bytes.get_uint8 dev (Addr.start_addr + 0x07) in
let append = Bytes.get_uint8 dev (Addr.start + 0x07) in
file_write ram value state.length append |> with_success
| _ -> ()
end