kestrel/lib/Varvara/Console.ml

22 lines
635 B
OCaml

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 dei_ports = Uxn.Device.Int_set.empty
let deo_ports = Uxn.Device.Int_set.of_list [ 0x10; 0x18; 0x19 ]
let dei _ _ = assert false
let dei2 _ _ = assert false
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
| _ -> assert false
end