make #010e DEO print stack in the recommended repr
This commit is contained in:
parent
b71cf4343e
commit
bc1bae5977
8 changed files with 837 additions and 52 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -9,9 +9,13 @@ module Make () : Uxn.Device.DEVICE with type state = state = struct
|
|||
let can_handle port = port >= 0x00 && port <= 0x0f
|
||||
|
||||
let print_stack ~name (Machine.Stack { data; sp }) =
|
||||
Fmt.epr "%s: @[%a@]@." name
|
||||
(Fmt.on_bytes (Fmt.octets ()))
|
||||
(Bytes.sub data 0 sp)
|
||||
Printf.eprintf "%s " name;
|
||||
for i = sp - 8 to sp - 1 do
|
||||
Printf.eprintf "%02x%s"
|
||||
(Bytes.get_uint8 data (i land 0xff))
|
||||
(if i land 0xff == 0xff then "|" else " ")
|
||||
done;
|
||||
Printf.eprintf "<%02x\n" sp
|
||||
|
||||
let get_bank mach bank =
|
||||
if bank = 0 then Machine.ram mach
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
(library
|
||||
(name varvara)
|
||||
(libraries uxn fmt unix))
|
||||
(libraries uxn unix))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue