reorganization and project rename

This commit is contained in:
Lobo 2026-01-03 12:45:30 -03:00
parent 35b0a4f6dd
commit def41120c1
20 changed files with 42 additions and 39 deletions

View file

@ -1,2 +1,5 @@
Yet another Uxn core, this time as an OCaml library.
It has no dependencies, and depends on OCaml >=5.3 for its effect syntax.
# Kestrel
**Kestrel** is an implementation of the
[Uxn](https://wiki.xxiivv.com/site/uxn.html) virtual machine and
[Varvara](https://wiki.xxiivv.com/site/varvara.html) ecosystem in OCaml.

View file

@ -1,11 +1,11 @@
(lang dune 3.20)
(name uxn)
(name kestrel)
(generate_opam_files true)
(source
(codeberg lobo/uxn))
(uri https://git.rhzm.org/lobo/kestrel.git))
(authors "Javier B. Torres <lobo@quiltro.org>")
(maintainers "Javier B. Torres <lobo@quiltro.org>")
@ -13,7 +13,7 @@
(license LICENSE)
(package
(name uxn)
(name kestrel)
(synopsis "Uxn emulator library for OCaml")
(description "Uxn emulator library for OCaml")
(depends (ocaml (>= 5.3))))

View file

@ -1,4 +1,4 @@
(executable
(public_name uxnemu)
(name uxnemu)
(libraries uxn varvara unix))
(public_name kestrel)
(name main)
(libraries kestrel kestrel_varvara unix))

View file

@ -1,4 +1,4 @@
open Uxn
open Kestrel
open Effect.Deep
let devices_deo = Hashtbl.create 256
@ -12,15 +12,15 @@ let register_device (module D : Device.DEVICE) =
(fun port -> Hashtbl.add devices_deo port (module D : Device.DEVICE))
D.deo_ports
module System = Varvara.System.Make ()
module Console = Varvara.Console.Make ()
module Datetime = Varvara.Datetime.Make ()
module System = Kestrel_varvara.System.Make ()
module Console = Kestrel_varvara.Console.Make ()
module Datetime = Kestrel_varvara.Datetime.Make ()
module File_a = Varvara.File.Make (struct
module File_a = Kestrel_varvara.File.Make (struct
let start = 0xa0
end)
module File_b = Varvara.File.Make (struct
module File_b = Kestrel_varvara.File.Make (struct
let start = 0xb0
end)
@ -53,7 +53,7 @@ let run m pc =
let main () =
if Array.length Sys.argv < 2 then (
Printf.eprintf "usage: uxnemu file.rom ...\n";
Printf.eprintf "usage: kestrel file.rom ...\n";
exit 1);
register_device (module System : Device.DEVICE);

View file

@ -5,8 +5,6 @@ description: "Uxn emulator library for OCaml"
maintainer: ["Javier B. Torres <lobo@quiltro.org>"]
authors: ["Javier B. Torres <lobo@quiltro.org>"]
license: "LICENSE"
homepage: "https://codeberg.org/lobo/uxn"
bug-reports: "https://codeberg.org/lobo/uxn/issues"
depends: [
"dune" {>= "3.20"}
"ocaml" {>= "5.3"}
@ -26,5 +24,5 @@ build: [
"@doc" {with-doc}
]
]
dev-repo: "git+https://codeberg.org/lobo/uxn.git"
dev-repo: "https://git.rhzm.org/lobo/kestrel.git"
x-maintenance-intent: ["(latest)"]

View file

@ -1,3 +0,0 @@
(library
(name varvara)
(libraries uxn unix))

View file

@ -1,3 +0,0 @@
(library
(name uxn)
(libraries unix))

2
lib/kestrel/dune Normal file
View file

@ -0,0 +1,2 @@
(library
(name kestrel))

View file

@ -1,11 +1,11 @@
type state = { mutable console_vector : int }
module Make () : Uxn.Device.DEVICE with type state = state = struct
module Make () : Kestrel.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_ports = Kestrel.Device.Int_set.empty
let deo_ports = Kestrel.Device.Int_set.of_list [ 0x10; 0x18; 0x19 ]
let dei _ _ = assert false
let dei2 _ _ = assert false

View file

@ -1,13 +1,13 @@
module Make () : Uxn.Device.DEVICE with type state = unit = struct
module Make () : Kestrel.Device.DEVICE with type state = unit = struct
type state = unit
let state = ()
let dei_ports =
Uxn.Device.Int_set.of_list
Kestrel.Device.Int_set.of_list
[ 0xc0; 0xc2; 0xc3; 0xc4; 0xc5; 0xc6; 0xc7; 0xc8; 0xca ]
let deo_ports = Uxn.Device.Int_set.empty
let deo_ports = Kestrel.Device.Int_set.empty
let dei _ port =
let now = Unix.time () in

View file

@ -15,14 +15,15 @@ module type ADDR = sig
val start : int
end
module Make (Addr : ADDR) : Uxn.Device.DEVICE with type state = state = struct
module Make (Addr : ADDR) : Kestrel.Device.DEVICE with type state = state =
struct
type nonrec state = state
let state = { filepath = None; state = Idle; length = 0 }
let dei_ports = Uxn.Device.Int_set.empty
let dei_ports = Kestrel.Device.Int_set.empty
let deo_ports =
Uxn.Device.Int_set.of_list
Kestrel.Device.Int_set.of_list
[
Addr.start + 0x0a;
Addr.start + 0x04;
@ -213,7 +214,7 @@ module Make (Addr : ADDR) : Uxn.Device.DEVICE with type state = state = struct
let dei2 _ _ = assert false
let deo mach port value =
let open Uxn in
let open Kestrel in
let ram = Machine.ram mach in
let dev = Machine.dev mach in
let with_success result = file_success dev (Addr.start + 0x02) result in

View file

@ -1,15 +1,17 @@
open Uxn
open Kestrel
type state = { banks : bytes array }
module Make () : Uxn.Device.DEVICE with type state = state = struct
module Make () : Kestrel.Device.DEVICE with type state = state = struct
type nonrec state = state
let state = { banks = Array.init 15 (fun _ -> Bytes.create 65536) }
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 dei_ports = Kestrel.Device.Int_set.of_list [ 0x04; 0x05 ]
let print_stack ~name (Machine.Stack { data; sp }) =
let deo_ports =
Kestrel.Device.Int_set.of_list [ 0x02; 0x04; 0x05; 0x0e; 0x0f ]
let print_stack ~name (Kestrel.Machine.Stack { data; sp }) =
Printf.eprintf "%s " name;
for i = sp - 8 to sp - 1 do
Printf.eprintf "%02x%s"

3
lib/kestrel_varvara/dune Normal file
View file

@ -0,0 +1,3 @@
(library
(name kestrel_varvara)
(libraries kestrel unix))