Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
Christian Westrom | d35b2bd891 | ||
Christian Westrom | ded53aa08a | ||
Christian Westrom | b23f90df2e | ||
Christian Westrom | 87c9d1f003 |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
target/
|
||||
.direnv
|
||||
|
|
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -19,9 +19,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.95"
|
||||
version = "1.0.94"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04"
|
||||
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
|
@ -73,9 +73,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.5"
|
||||
version = "1.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e"
|
||||
checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
@ -175,9 +175,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
|||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.4"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
|
||||
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
|
@ -213,12 +213,12 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9fe8d6bbff0c9a2f9d8989635a9758bf9b2ed566"
|
||||
|
||||
[[package]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9fe8d6bbff0c9a2f9d8989635a9758bf9b2ed566"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
"hbbytecode",
|
||||
|
@ -229,7 +229,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbvm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9fe8d6bbff0c9a2f9d8989635a9758bf9b2ed566"
|
||||
dependencies = [
|
||||
"hbbytecode",
|
||||
]
|
||||
|
@ -421,9 +421,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.169"
|
||||
version = "0.2.168"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
|
||||
checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d"
|
||||
|
||||
[[package]]
|
||||
name = "limine"
|
||||
|
@ -726,9 +726,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.91"
|
||||
version = "2.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035"
|
||||
checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
18
bacon.toml
Normal file
18
bacon.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
default_job = "build"
|
||||
env.CARGO_TERM_COLOR = "always"
|
||||
|
||||
[jobs.build]
|
||||
command = ["cargo", "repbuild", "build"]
|
||||
need_stdout = false
|
||||
|
||||
[jobs.run]
|
||||
command = ["cargo", "repbuild", "run", "--release"]
|
||||
need_stdout = false
|
||||
|
||||
[jobs.check]
|
||||
command = ["cargo", "check"]
|
||||
need_stdout = false
|
||||
|
||||
[jobs.clippy-all]
|
||||
command = ["cargo", "clippy", "--all-targets"]
|
||||
need_stdout = false
|
15
flake.nix
15
flake.nix
|
@ -2,13 +2,20 @@
|
|||
description = "A devShell example";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs {
|
||||
|
|
|
@ -9,7 +9,7 @@ ktest = []
|
|||
[dependencies]
|
||||
# embedded-graphics = "0.8"
|
||||
hbvm = { git = "https://git.ablecorp.us/AbleOS/holey-bytes.git", features = [
|
||||
"nightly", "alloc", "disasm"
|
||||
"nightly",
|
||||
] }
|
||||
ktest_macro = { path = "ktest_macro" }
|
||||
log = "0.4"
|
||||
|
|
|
@ -15,10 +15,8 @@ fn calc_start_of_page(ptr: u64) -> u64 {
|
|||
panic!("unaligned");
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Memory {
|
||||
// TODO: map page aligned segments of memory into a table or some sort here
|
||||
logger: hbvm::mem::InstrLogger,
|
||||
}
|
||||
|
||||
impl Memory {
|
||||
|
@ -58,11 +56,4 @@ impl hbvm::mem::Memory for Memory {
|
|||
unsafe fn prog_read<T: Copy>(&mut self, addr: Address) -> T {
|
||||
(addr.get() as *const T).read()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn log_instr(&mut self, at: Address, regs: &[hbvm::value::Value]) {
|
||||
//log::debug!("exec: [{:02x}] {}", at.get(), unsafe {
|
||||
// self.logger.display_instr(at, regs)
|
||||
//});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ impl ExecThread {
|
|||
|
||||
pub unsafe fn new(program: &[u8], entrypoint: Address) -> Self {
|
||||
let mut vm = Vm::new(
|
||||
mem::Memory::default(),
|
||||
mem::Memory {},
|
||||
Address::new(program.as_ptr() as u64 + entrypoint.get()),
|
||||
);
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ fatfs = { version = "0.3", default-features = false, features = [
|
|||
] }
|
||||
toml = "0.8"
|
||||
hblang.git = "https://git.ablecorp.us/AbleOS/holey-bytes.git"
|
||||
# hblang.path = "../../holey-bytes/lang/"
|
||||
log = "0.4"
|
||||
raw-cpuid = "11"
|
||||
ureq = { version = "2", default-features = false, features = ["tls"] }
|
||||
|
|
|
@ -109,7 +109,7 @@ impl Package {
|
|||
std::fs::write(format!("target/programs/{}.hbf", self.name), &out)?;
|
||||
out.clear();
|
||||
|
||||
let err = hblang::run_compiler(
|
||||
hblang::run_compiler(
|
||||
&path,
|
||||
Options {
|
||||
resolver: Some(hblang::ABLEOS_PATH_RESOLVER),
|
||||
|
@ -119,10 +119,9 @@ impl Package {
|
|||
},
|
||||
out,
|
||||
&mut warnings,
|
||||
);
|
||||
)?;
|
||||
std::fs::write(format!("target/programs/{}.hba", self.name), &out)?;
|
||||
out.clear();
|
||||
return err;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -253,10 +253,10 @@ TERM_BACKDROP={}
|
|||
);
|
||||
match p.build(&mut out) {
|
||||
Ok(()) => {}
|
||||
Err(e) => {
|
||||
writeln!(errors, "========= while compiling {} {} =========", path, e)
|
||||
Err(_) => {
|
||||
writeln!(errors, "========= while compiling {} =========", path)
|
||||
.unwrap();
|
||||
errors.push_str(&String::from_utf8_lossy(&out));
|
||||
errors.push_str(core::str::from_utf8(&out).expect("no"));
|
||||
out.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,18 +9,18 @@ widgets := @use("widgets/widgets.hb")
|
|||
ui := @use("ui.hb")
|
||||
|
||||
WindowID := struct {
|
||||
host_id: uint,
|
||||
window_id: uint,
|
||||
host_id: int,
|
||||
window_id: int,
|
||||
}
|
||||
|
||||
VoidWindowID := WindowID.(0, 0)
|
||||
|
||||
create_window := fn(channel: uint): ^render.Surface {
|
||||
create_window := fn(channel: int): ^render.Surface {
|
||||
// get the horizon buffer
|
||||
// request a new window and provide the callback buffer
|
||||
// wait to recieve a message
|
||||
|
||||
windowing_system_buffer := buffer.search("XHorizon")
|
||||
windowing_system_buffer := buffer.search("XHorizon\0")
|
||||
mem_buf := memory.request_page(1)
|
||||
|
||||
if windowing_system_buffer == 0 {
|
||||
|
@ -29,13 +29,13 @@ create_window := fn(channel: uint): ^render.Surface {
|
|||
x := 0
|
||||
loop if x > 1000 break else x += 1
|
||||
|
||||
ret := buffer.recv([4096]u8, windowing_system_buffer, mem_buf)
|
||||
ret := buffer.recv([u8; 4096], windowing_system_buffer, mem_buf)
|
||||
if ret == null {
|
||||
log.info("No messages")
|
||||
log.info("No messages\0")
|
||||
}
|
||||
|
||||
if *mem_buf == 0 {
|
||||
log.info("No messages")
|
||||
log.info("No messages\0")
|
||||
}
|
||||
|
||||
return @as(^render.Surface, idk)
|
||||
|
|
|
@ -6,7 +6,7 @@ render := @use("../../../libraries/render/src/lib.hb");
|
|||
.{Surface} := render;
|
||||
.{Font} := render.text
|
||||
|
||||
UI := struct {raw: []u8, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte
|
||||
UI := struct {raw: ^u8, raw_length: uint, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte
|
||||
// children: ^^u8,
|
||||
}
|
||||
|
||||
|
@ -19,26 +19,29 @@ render_ui := fn(surface: Surface, ui: UI): void {
|
|||
render.put_surface(surface, ui.surface, pos, false)
|
||||
}
|
||||
|
||||
sexpr_parser := fn(sexpr: []u8): UI {
|
||||
i := 0
|
||||
sexpr_parser := fn(sexpr: ^u8): UI {
|
||||
cursor := sexpr
|
||||
paren_balance := 0
|
||||
loop {
|
||||
if i == sexpr.len {
|
||||
if *cursor == 0 {
|
||||
if paren_balance != 0 {
|
||||
log.error("Unbalanced Parens")
|
||||
log.error("Unbalanced Parens\0")
|
||||
}
|
||||
break
|
||||
} else if sexpr[i] == '(' {
|
||||
log.info("Open paren")
|
||||
} else if *cursor == 40 {
|
||||
log.info("Open paren\0")
|
||||
paren_balance += 1
|
||||
} else if sexpr[i] == ')' {
|
||||
log.info("Closed paren")
|
||||
} else if *cursor == 41 {
|
||||
log.info("Closed paren\0")
|
||||
paren_balance -= 1
|
||||
}
|
||||
|
||||
i += 1
|
||||
cursor += 1
|
||||
}
|
||||
|
||||
length := string.length(sexpr)
|
||||
|
||||
ui_surface := render.new_surface(100, 100)
|
||||
return UI.(sexpr, true, ui_surface)
|
||||
|
||||
return UI.(sexpr, length, true, ui_surface)
|
||||
}
|
|
@ -10,22 +10,27 @@ Label := struct {
|
|||
magic: uint,
|
||||
is_dirty: bool,
|
||||
surface: Surface,
|
||||
text: []u8,
|
||||
text: ^u8,
|
||||
text_length: uint,
|
||||
bg: Color,
|
||||
fg: Color,
|
||||
|
||||
new_label := fn(text: []u8, width: uint): Self {
|
||||
new_label := fn(text: ^u8, width: uint): Self {
|
||||
text_surface := render.Surface.new(width, 20)
|
||||
label := Self.(3, true, text_surface, text, render.BLACK, render.WHITE)
|
||||
text_length := string.length(text)
|
||||
label := Self.(3, true, text_surface, text, text_length, render.BLACK, render.WHITE)
|
||||
return label
|
||||
}
|
||||
|
||||
$set_label_text := fn(self: ^Self, text: []u8): void {
|
||||
set_label_text := fn(self: Self, text: ^u8): void {
|
||||
text_length := string.length(text)
|
||||
|
||||
self.is_dirty = true
|
||||
self.text = text
|
||||
self.text_length = text_length
|
||||
}
|
||||
|
||||
$set_color := fn(self: ^Self, bg: Color, fg: Color): void {
|
||||
$set_color := fn(self: Self, bg: Color, fg: Color): void {
|
||||
self.bg = bg
|
||||
self.fg = fg
|
||||
self.is_dirty = true
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../stn/src/lib.hb");
|
||||
.{log, buffer, memory} := stn
|
||||
keycodes := @use("keycodes.hb")
|
||||
|
||||
|
@ -8,7 +8,7 @@ events := @use("events.hb");
|
|||
recieve_key_event := fn(): ?KeyEvent {
|
||||
kevent := KeyEvent.(false, false, 0)
|
||||
|
||||
buf_id := buffer.search("PS/2 Keyboard")
|
||||
buf_id := buffer.search("PS/2 Keyboard\0")
|
||||
|
||||
// Read out of the Keyboard buffer here
|
||||
buffer.recv(KeyEvent, buf_id, &kevent)
|
||||
|
@ -23,7 +23,7 @@ recieve_key_event := fn(): ?KeyEvent {
|
|||
recieve_mouse_event := fn(): ?MouseEvent {
|
||||
mevent := MouseEvent.(0, 0, false, false, false)
|
||||
|
||||
buf_id := buffer.search("PS/2 Mouse")
|
||||
buf_id := buffer.search("PS/2 Mouse\0")
|
||||
|
||||
// Read out of the Mouse buffer here
|
||||
buffer.recv(MouseEvent, buf_id, &mevent)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.{string, memory, buffer, log} := @use("stn")
|
||||
.{string, memory, buffer, log} := @use("../../stn/src/lib.hb")
|
||||
|
||||
PCIAddress := struct {
|
||||
bus: u8,
|
||||
|
@ -51,9 +51,9 @@ check_device := fn(bus: u8, device: u8): PciDeviceInfo {
|
|||
pci_id := get_ids(bus, device, 0)
|
||||
|
||||
if pci_id.vendor == 0xFFFF {
|
||||
log.warn(":|")
|
||||
log.warn(":|\0")
|
||||
} else {
|
||||
log.info(":)")
|
||||
log.info(":)\0")
|
||||
}
|
||||
address := calculate_address(bus, device, 0, 0x8)
|
||||
reg2 := config_read32(bus, device, 0, 0x8)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.{Color, Surface, new_surface, put_surface} := @use("lib:render");
|
||||
.{log} := @use("stn")
|
||||
.{Color, Surface, new_surface, put_surface} := @use("../lib.hb");
|
||||
.{log} := @use("../../../stn/src/lib.hb")
|
||||
|
||||
BitmapFileHeader := packed struct {
|
||||
magic: u16,
|
||||
|
@ -37,7 +37,7 @@ from := fn(bmp: ^u8): ?Surface {
|
|||
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
|
||||
|
||||
if file_header.magic != 0x4D42 | info_header.width == 0 | info_header.height == 0 {
|
||||
log.error("Invalid BMP image.")
|
||||
log.error("Invalid BMP image.\0")
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.{log} := @use("stn");
|
||||
.{Surface} := @use("lib:render")
|
||||
.{log} := @use("../../../stn/src/lib.hb");
|
||||
.{Surface} := @use("../lib.hb")
|
||||
bmp := @use("bmp.hb")
|
||||
qoi := @use("qoi.hb")
|
||||
$BMP := 0x4D42
|
||||
|
@ -19,7 +19,7 @@ from := fn(file: ^u8): ?Surface {
|
|||
format := get_format(file)
|
||||
|
||||
if format == null {
|
||||
log.error("Could not detect image format.")
|
||||
log.error("Could not detect image format.\0")
|
||||
return null
|
||||
} else if format == BMP {
|
||||
return bmp.from(file)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.{Color, Surface, new_surface} := @use("lib:render");
|
||||
.{log} := @use("stn")
|
||||
.{Color, Surface, new_surface} := @use("../lib.hb");
|
||||
.{log} := @use("../../../stn/src/lib.hb")
|
||||
|
||||
/* source:
|
||||
https://github.com/phoboslab/qoi/blob/master/qoi.h */
|
||||
|
@ -40,12 +40,12 @@ from := fn(qoi: ^u8): ?Surface {
|
|||
height := be_to_le(header.height)
|
||||
|
||||
if be_to_le(header.magic) != QOI_MAGIC | width == 0 | height == 0 | header.channels < 3 | header.channels > 4 {
|
||||
log.error("Invalid QOI image.")
|
||||
log.error("Invalid QOI image.\0")
|
||||
return null
|
||||
}
|
||||
|
||||
surface := Surface.new(width, height)
|
||||
index := @as([64]Color, idk)
|
||||
index := @as([Color; 64], idk)
|
||||
|
||||
run := 0
|
||||
px := Color.(0, 0, 0, 255)
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
// safety: don't use before init() or you will get a memory access violation
|
||||
framebuffer := memory.dangling(Color)
|
||||
utf8_len_table := u8.[0, 0, 2, 3]
|
||||
utf8_len_table := [u8].(0, 0, 2, 3)
|
||||
|
||||
init := fn(doublebuffer: bool): Surface {
|
||||
framebuffer = dt.get(^Color, "framebuffer/fb0/ptr")
|
||||
width := dt.get(uint, "framebuffer/fb0/width")
|
||||
height := dt.get(uint, "framebuffer/fb0/height")
|
||||
framebuffer = dt.get(^Color, "framebuffer/fb0/ptr\0")
|
||||
width := dt.get(uint, "framebuffer/fb0/width\0")
|
||||
height := dt.get(uint, "framebuffer/fb0/height\0")
|
||||
if doublebuffer {
|
||||
return Surface.new(width, height)
|
||||
} else {
|
||||
|
@ -306,7 +306,7 @@ Surface := struct {
|
|||
}
|
||||
}
|
||||
|
||||
put_text := fn(self: Self, font: Font, pos: Vec2(uint), color: Color, str: []u8): void {
|
||||
put_text := fn(self: Self, font: Font, pos: Vec2(uint), color: Color, str: ^u8): void {
|
||||
cursor := Vec2(uint).(pos.x, pos.y)
|
||||
|
||||
max_y := self.height - font.height
|
||||
|
@ -314,50 +314,48 @@ Surface := struct {
|
|||
char_advance := font.width + font.char_gap
|
||||
self_width := self.width
|
||||
|
||||
i := 0
|
||||
|
||||
loop if i >= str.len break else {
|
||||
loop if *str == 0 break else {
|
||||
if cursor.y > max_y break
|
||||
|
||||
glyph_data := @as(^u8, idk)
|
||||
code_point := @as(uint, 0)
|
||||
|
||||
if (str[i] & 0x80) == 0 {
|
||||
if str[i] == '\n' {
|
||||
if (*str & 0x80) == 0 {
|
||||
if *str == 10 {
|
||||
cursor.x = pos.x
|
||||
cursor.y += next_line_y
|
||||
i += 1
|
||||
str += 1
|
||||
continue
|
||||
}
|
||||
|
||||
if font.unicode == null {
|
||||
if str[i] > font.num_glyphs {
|
||||
i += 1
|
||||
if *str > font.num_glyphs {
|
||||
str += 1
|
||||
continue
|
||||
}
|
||||
glyph_data = get_glyph(font, str[i])
|
||||
glyph_data = get_glyph(font, *str)
|
||||
} else {
|
||||
if str[i] < UNC_TABLE_SIZE {
|
||||
glyph_index := *(font.unicode + str[i])
|
||||
if *str < UNC_TABLE_SIZE {
|
||||
glyph_index := *(font.unicode + *str)
|
||||
if glyph_index == 0xFFFF {
|
||||
i += 1
|
||||
str += 1
|
||||
continue
|
||||
}
|
||||
glyph_data = font.data + glyph_index * font.bytes_per_glyph
|
||||
} else {
|
||||
i += 1
|
||||
str += 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
i += 1
|
||||
str += 1
|
||||
} else if font.unicode != null {
|
||||
first_byte := str[i]
|
||||
first_byte := *str
|
||||
num_bytes := @as(uint, 0)
|
||||
|
||||
num_bytes = utf8_len_table[first_byte >> 5 & 0x3]
|
||||
|
||||
if num_bytes == 0 {
|
||||
i += 1
|
||||
str += 1
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -367,25 +365,25 @@ Surface := struct {
|
|||
bytes_processed := 1
|
||||
|
||||
loop if bytes_processed >= num_bytes break else {
|
||||
i += 1
|
||||
if i == str.len | (str[i] & 0xC0) != 0x80 {
|
||||
str += 1
|
||||
if *str == 0 | (*str & 0xC0) != 0x80 {
|
||||
valid_sequence = false
|
||||
}
|
||||
if valid_sequence == false {
|
||||
break
|
||||
}
|
||||
code_point = code_point << 6 | str[i] & 0x3F
|
||||
code_point = code_point << 6 | *str & 0x3F
|
||||
bytes_processed += 1
|
||||
}
|
||||
|
||||
if valid_sequence == false {
|
||||
i += 1
|
||||
str += 1
|
||||
continue
|
||||
}
|
||||
|
||||
i += 1
|
||||
str += 1
|
||||
|
||||
if code_point == '\n' {
|
||||
if code_point == 10 {
|
||||
cursor.x = pos.x
|
||||
cursor.y += next_line_y
|
||||
continue
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.{log, memory} := @use("stn")
|
||||
.{log, memory} := @use("../../stn/src/lib.hb")
|
||||
|
||||
PSF1Header := packed struct {
|
||||
magic: u16,
|
||||
|
@ -31,7 +31,7 @@ Font := struct {
|
|||
font_from_psf1 := fn(psf: ^u8): ?Font {
|
||||
header := @as(^PSF1Header, @bitcast(psf))
|
||||
if header.magic != 0x436 {
|
||||
log.error("failed to load psf font: not a psf1 font, idiot")
|
||||
log.error("failed to load psf font: not a psf1 font, idiot\0")
|
||||
return null
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ font_from_psf1 := fn(psf: ^u8): ?Font {
|
|||
font_from_psf2 := fn(psf: ^u8, unicode: bool): ?Font {
|
||||
header := @as(^PSF2Header, @bitcast(psf))
|
||||
if header.magic != 0x864AB572 {
|
||||
log.error("failed to load psf font: not a psf2 font, idiot")
|
||||
log.error("failed to load psf font: not a psf2 font, idiot\0")
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.{log, panic, memory} := @use("stn")
|
||||
.{log, panic, memory} := @use("../lib.hb")
|
||||
alloc_return := @use("alloc_return.hb")
|
||||
|
||||
/* the block size is 64 bytes, 64 blocks of 64 bytes.
|
||||
|
@ -30,7 +30,7 @@ BlockAlloc := struct {
|
|||
offset += 1
|
||||
return .(0, null)
|
||||
} else {
|
||||
log.info("Already Allocated")
|
||||
log.info("Already Allocated\0")
|
||||
}
|
||||
|
||||
// else {
|
||||
|
@ -40,7 +40,7 @@ BlockAlloc := struct {
|
|||
// if self.ptr != null {
|
||||
// return .(64, self.ptr + offset * 64)
|
||||
// } else {
|
||||
// // panic.panic("Allocator is not inited.")
|
||||
// // panic.panic("Allocator is not inited.\0")
|
||||
// // return .(0, null)
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -22,8 +22,9 @@ $write_length := fn(length: uint, msg: ^u8, buffer_id: uint): void {
|
|||
|
||||
BufferMsg := packed struct {operation: u8, msg: ^u8, msg_len: uint}
|
||||
|
||||
$create := fn(msg: []u8): uint {
|
||||
return @eca(3, 0, BufferMsg.(0, msg.ptr, msg.len), @sizeof(BufferMsg))
|
||||
create := fn(msg: ^u8): uint {
|
||||
// for some reason not inlining here breaks things
|
||||
return @eca(3, 0, BufferMsg.(0, msg, @inline(string.length, msg)), @sizeof(BufferMsg))
|
||||
}
|
||||
|
||||
$create_nameless := fn(): uint {
|
||||
|
@ -34,6 +35,7 @@ $delete_buffer := fn(buffer_id: uint): void {
|
|||
return @eca(2, buffer_id)
|
||||
}
|
||||
|
||||
$search := fn(msg: []u8): uint {
|
||||
return @eca(3, 0, BufferMsg.(3, msg.ptr, msg.len), @sizeof(BufferMsg))
|
||||
search := fn(msg: ^u8): uint {
|
||||
// for some reason not inlining here breaks things
|
||||
return @eca(3, 0, BufferMsg.(3, msg, @inline(string.length, msg)), @sizeof(BufferMsg))
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
$get := fn($Expr: type, query: []u8): Expr {
|
||||
return @eca(3, 5, query, query.len)
|
||||
.{string} := @use("../../stn/src/lib.hb")
|
||||
|
||||
get := fn($Expr: type, query: ^u8): Expr {
|
||||
return @eca(3, 5, query, string.length(query))
|
||||
}
|
|
@ -2,7 +2,7 @@ acs := @use("acs.hb");
|
|||
.{DiskID, FileID} := acs
|
||||
|
||||
// Paths without a node-disk component are to be treated as local files.
|
||||
// file_path := "DID:/test"
|
||||
// file_path := "DID:/test\0";
|
||||
Path := struct {
|
||||
// DiskID holds the host id
|
||||
disk_id: DiskID,
|
||||
|
|
|
@ -1,273 +0,0 @@
|
|||
.{Kind, usize, string, signed_int, panic, float, integer, memory, log: .{LogLevel}} := @use("stn")
|
||||
|
||||
fmt_int := fn(v: @Any(), str: []u8, radix: @TypeOf(v)): uint {
|
||||
is_negative := signed_int(@TypeOf(v)) & v < 0
|
||||
prefix_len := 0
|
||||
if is_negative {
|
||||
v = -v
|
||||
str[0] = '-'
|
||||
prefix_len += 1
|
||||
}
|
||||
|
||||
if radix == 16 {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0x".ptr)
|
||||
prefix_len += 2
|
||||
} else if radix == 2 {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0b".ptr)
|
||||
prefix_len += 2
|
||||
} else if radix == 8 {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0o".ptr)
|
||||
prefix_len += 2
|
||||
}
|
||||
|
||||
if v == 0 {
|
||||
str[prefix_len] = '0'
|
||||
return prefix_len + 1
|
||||
}
|
||||
|
||||
i := prefix_len
|
||||
loop if v <= 0 break else {
|
||||
remainder := v % radix
|
||||
v /= radix
|
||||
if remainder > 9 {
|
||||
str[i] = @intcast(remainder - 10 + 'A')
|
||||
} else {
|
||||
str[i] = @intcast(remainder + '0')
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
|
||||
string.reverse(str[prefix_len..i])
|
||||
return i
|
||||
}
|
||||
|
||||
fmt_bool := fn(v: bool, str: []u8): uint {
|
||||
if v {
|
||||
*@as(^[4]u8, @bitcast(str.ptr)) = *@bitcast("true".ptr)
|
||||
return 4
|
||||
} else {
|
||||
*@as(^[5]u8, @bitcast(str.ptr)) = *@bitcast("false".ptr)
|
||||
return 5
|
||||
}
|
||||
}
|
||||
|
||||
$FP_TOLERANCE := 0.00000001
|
||||
|
||||
fmt_float := fn(v: @Any(), str: []u8, precision: uint, radix: int): uint {
|
||||
is_negative := v < 0
|
||||
|
||||
prefix_len := 0
|
||||
|
||||
if is_negative {
|
||||
v = -v
|
||||
str[0] = '-'
|
||||
prefix_len += 1
|
||||
}
|
||||
|
||||
if radix == 16 {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0x".ptr)
|
||||
prefix_len += 2
|
||||
} else if radix == 2 {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0b".ptr)
|
||||
prefix_len += 2
|
||||
} else if radix == 8 {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + prefix_len)) = *@bitcast("0o".ptr)
|
||||
prefix_len += 2
|
||||
}
|
||||
|
||||
integer_part := @fti(v)
|
||||
fractional_part := v - @itf(integer_part)
|
||||
|
||||
i := prefix_len
|
||||
loop if integer_part == 0 & i > prefix_len break else {
|
||||
remainder := integer_part % radix
|
||||
integer_part /= radix
|
||||
if remainder > 9 {
|
||||
str[i] = @intcast(remainder - 10 + 'A')
|
||||
} else {
|
||||
str[i] = @intcast(remainder + '0')
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
|
||||
string.reverse(str[prefix_len..i])
|
||||
str[i] = '.'
|
||||
i += 1
|
||||
|
||||
p := precision
|
||||
loop if p <= 0 | fractional_part < FP_TOLERANCE break else {
|
||||
fractional_part *= @itf(radix)
|
||||
digit := @fti(fractional_part)
|
||||
if digit > 9 {
|
||||
str[i] = @intcast(digit - 10 + 'A')
|
||||
} else {
|
||||
str[i] = @intcast(digit + '0')
|
||||
}
|
||||
i += 1
|
||||
fractional_part -= @itf(digit)
|
||||
p -= 1
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
|
||||
fmt_container := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
||||
T2 := @TypeOf(v)
|
||||
kind := Kind.of(T2)
|
||||
i := 0
|
||||
len := 0
|
||||
if kind == .Struct {
|
||||
*@as(^[@intcast(@nameof(T2).len)]u8, @bitcast(str.ptr + len)) = *@bitcast(@nameof(T2).ptr)
|
||||
len += @nameof(T2).len;
|
||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".(".ptr)
|
||||
len += 2
|
||||
} else if kind == .Slice {
|
||||
*@as(^[@intcast(@nameof(@ChildOf(T2)).len)]u8, @bitcast(str.ptr + len)) = *@bitcast(@nameof(@ChildOf(T2)).ptr)
|
||||
len += @nameof(@ChildOf(T2)).len;
|
||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".[".ptr)
|
||||
len += 2
|
||||
} else if kind == .Tuple {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".(".ptr)
|
||||
len += 2
|
||||
}
|
||||
$loop {
|
||||
v_sub := v[i]
|
||||
len += @inline(format, v_sub, str[len..], opts)
|
||||
i += 1
|
||||
if i == @lenof(T2) break else {
|
||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(", ".ptr)
|
||||
len += 2
|
||||
}
|
||||
}
|
||||
if kind == .Struct | kind == .Tuple {
|
||||
*@as(^[1]u8, @bitcast(str.ptr + len)) = *@bitcast(")".ptr)
|
||||
len += 1
|
||||
} else if kind == .Slice {
|
||||
*@as(^[1]u8, @bitcast(str.ptr + len)) = *@bitcast("]".ptr)
|
||||
len += 1
|
||||
}
|
||||
return len
|
||||
}
|
||||
|
||||
fmt_nullable := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
||||
if v == null {
|
||||
*@as(^[4]u8, @bitcast(str.ptr)) = *@bitcast("null".ptr)
|
||||
return 4
|
||||
} else {
|
||||
return @inline(format, @as(@ChildOf(@TypeOf(v)), v), str, opts)
|
||||
}
|
||||
}
|
||||
|
||||
fmt_enum := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
||||
T := @TypeOf(v)
|
||||
len := @nameof(T).len;
|
||||
*@as(^[@intcast(@nameof(T).len)]u8, @bitcast(str.ptr)) = *@bitcast(@nameof(T).ptr);
|
||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(".(".ptr)
|
||||
len += 2
|
||||
len += fmt_int(@as(usize(T), @bitcast(v)), str[len..], 10);
|
||||
*@as(^[2]u8, @bitcast(str.ptr + len)) = *@bitcast(")".ptr)
|
||||
return len + 1
|
||||
}
|
||||
|
||||
/* TODO:
|
||||
* Custom formatters using struct methods (T._fmt(self, str): uint),
|
||||
* Format struct fields "Name.{a: x, b: y, c: z}"
|
||||
* Optionally tabulate
|
||||
* Add more FormatOption fields
|
||||
* Support scientific notation for floating point
|
||||
* Support format string
|
||||
*/
|
||||
|
||||
FormatOptions := struct {
|
||||
precision: uint = 2,
|
||||
radix: uint = 10,
|
||||
// temporarily here, will change later maybe
|
||||
log: LogLevel = .Info,
|
||||
}
|
||||
|
||||
/* SAFETY:
|
||||
* Assumes the buffer is wide enough for the formatted text and a null char
|
||||
* Does not clear the buffer for you
|
||||
*/
|
||||
|
||||
format := fn(v: @Any(), str: []u8, opts: FormatOptions): uint {
|
||||
T := @TypeOf(v)
|
||||
match Kind.of(T) {
|
||||
.Pointer => return @inline(fmt_int, @as(uint, @bitcast(v)), str, 16),
|
||||
.Builtin => {
|
||||
if integer(T) {
|
||||
return @inline(fmt_int, v, str, @intcast(opts.radix))
|
||||
} else if T == bool {
|
||||
return @inline(fmt_bool, v, str)
|
||||
} else if float(T) {
|
||||
return @inline(fmt_float, v, str, opts.precision, @intcast(opts.radix))
|
||||
}
|
||||
},
|
||||
.Opt => return @inline(fmt_nullable, v, str, opts),
|
||||
.Enum => return @inline(fmt_enum, v, str, opts),
|
||||
.Struct => return @inline(fmt_container, v, str, opts),
|
||||
.Tuple => return @inline(fmt_container, v, str, opts),
|
||||
.Slice => if T != []u8 return @inline(fmt_container, v, str, opts) else {
|
||||
i := 0
|
||||
loop if i == v.len break else {
|
||||
str[i] = v[i]
|
||||
i += 1
|
||||
}
|
||||
return v.len
|
||||
},
|
||||
_ => @error("Type: \"", T, "\" is not supported."),
|
||||
}
|
||||
}
|
||||
|
||||
format_with_str := fn(v: @Any(), read: []u8, write: []u8, opts: FormatOptions): uint {
|
||||
T := @TypeOf(v)
|
||||
n := string.count(read, '{')
|
||||
if n != string.count(read, '}') panic("Missing closing '}' in format string.")
|
||||
if Kind.of(T) == .Tuple {
|
||||
if @lenof(T) != n panic("Format string has different number of '{}' than args given.")
|
||||
m := 0
|
||||
i := 0
|
||||
j := 0
|
||||
$loop if m > @lenof(T) break else {
|
||||
if m == @lenof(T) {
|
||||
loop if i == read.len break else {
|
||||
write[j] = read[i]
|
||||
i += 1
|
||||
j += 1
|
||||
}
|
||||
m += 1
|
||||
} else {
|
||||
v2 := v[m]
|
||||
loop if i == read.len break else {
|
||||
if read[i] == '{' & read[i + 1] == '}' {
|
||||
j += format(v2, write[j..], opts)
|
||||
i += 2
|
||||
break
|
||||
} else {
|
||||
write[j] = read[i]
|
||||
i += 1
|
||||
j += 1
|
||||
}
|
||||
}
|
||||
m += 1
|
||||
}
|
||||
}
|
||||
return j
|
||||
} else if n > 1 {
|
||||
panic("Format string has multiple '{}' but value provided is not a tuple.")
|
||||
} else {
|
||||
i := 0
|
||||
j := 0
|
||||
loop if i == read.len break else {
|
||||
if read[i] == '{' & read[i + 1] == '}' {
|
||||
j += format(v, write[j..], opts)
|
||||
i += 2
|
||||
} else {
|
||||
write[j] = read[i]
|
||||
i += 1
|
||||
j += 1
|
||||
}
|
||||
}
|
||||
return j
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@
|
|||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*/;
|
||||
|
||||
.{math, random} := @use("stn")
|
||||
.{math, random} := @use("../lib.hb")
|
||||
|
||||
$ARBITRARY0 := 0x243F6A8885A308D3
|
||||
$ARBITRARY1 := 0x13198A2E03707344
|
||||
|
@ -38,7 +38,7 @@ $ARBITRARY6 := 0xC0AC29B7C97C50DD
|
|||
$ARBITRARY7 := 0x3F84D5B5B5470917
|
||||
$ARBITRARY8 := 0x9216D5D98979FB1B
|
||||
$ARBITRARY9 := 0xD1310BA698DFB5AC
|
||||
$FIXED_GLOBAL_SEED := uint.[ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7]
|
||||
$FIXED_GLOBAL_SEED := [uint].(ARBITRARY4, ARBITRARY5, ARBITRARY6, ARBITRARY7)
|
||||
|
||||
global_seed := 0
|
||||
|
||||
|
@ -103,7 +103,7 @@ hash_bytes_long := fn(bytes: ^u8, len: uint, s0: uint, s1: uint, s2: uint, s3: u
|
|||
|
||||
if remainder > 0 {
|
||||
remainder_start := bytes + len - math.max(uint, remainder, 16)
|
||||
return @inline(hash_bytes_medium, remainder_start, math.max(uint, remainder, 16), s0, s1, fold_seed)
|
||||
return hash_bytes_medium(remainder_start, math.max(uint, remainder, 16), s0, s1, fold_seed)
|
||||
}
|
||||
|
||||
return s0 ^ s1
|
||||
|
@ -159,9 +159,17 @@ FoldHasher := struct {
|
|||
}
|
||||
self.accumulator = folded_multiply(s0, s1)
|
||||
} else if len < 256 {
|
||||
self.accumulator = @inline(hash_bytes_medium, bytes, len, s0, s1, self.fold_seed)
|
||||
self.accumulator = hash_bytes_medium(bytes, len, s0, s1, self.fold_seed)
|
||||
} else {
|
||||
self.accumulator = @inline(hash_bytes_long, bytes, len, s0, s1, self.expand_seed2, self.expand_seed3, self.fold_seed)
|
||||
self.accumulator = hash_bytes_long(
|
||||
bytes,
|
||||
len,
|
||||
s0,
|
||||
s1,
|
||||
self.expand_seed2,
|
||||
self.expand_seed3,
|
||||
self.fold_seed,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
acs := @use("acs.hb")
|
||||
allocators := @use("alloc/lib.hb")
|
||||
fmt := @use("fmt.hb")
|
||||
hashers := @use("hash/lib.hb")
|
||||
string := @use("string.hb")
|
||||
log := @use("log.hb")
|
||||
|
@ -13,28 +12,15 @@ dt := @use("dt.hb")
|
|||
process := @use("process.hb")
|
||||
sleep := @use("sleep.hb")
|
||||
|
||||
panic := fn(message: ?[]u8): never {
|
||||
log.printf("HBLang Panic: {}", message, .{log: .Error})
|
||||
die
|
||||
}
|
||||
|
||||
Kind := enum {
|
||||
Builtin,
|
||||
Struct,
|
||||
Tuple,
|
||||
Enum,
|
||||
Union,
|
||||
Pointer,
|
||||
Slice,
|
||||
Opt,
|
||||
Function,
|
||||
Template,
|
||||
Global,
|
||||
Const,
|
||||
Module,
|
||||
$of := fn($T: type): Self {
|
||||
return @bitcast(@kindof(T))
|
||||
// todo: replace with comptime message (for zero cost)
|
||||
panic := fn(message: ?^u8): never {
|
||||
log.error("Error: Panic Called, Message:\0")
|
||||
if message == null {
|
||||
log.error("None\0")
|
||||
} else {
|
||||
log.error(message)
|
||||
}
|
||||
die
|
||||
}
|
||||
|
||||
$unsigned_int := fn($T: type): bool {
|
||||
|
@ -53,14 +39,10 @@ $float := fn($T: type): bool {
|
|||
return T == f32 | T == f64
|
||||
}
|
||||
|
||||
$usize := fn($T: type): type {
|
||||
if @sizeof(T) == 1 return u8 else if @sizeof(T) == 2 return u16 else if @sizeof(T) == 4 return u32 else return uint
|
||||
$primitive := fn($T: type): bool {
|
||||
return integer(T) | float(T) | T == bool
|
||||
}
|
||||
|
||||
$bits := fn($T: type): usize(T) {
|
||||
return @sizeof(T) << 3
|
||||
}
|
||||
|
||||
$bitmask := fn($T: type): usize(T) {
|
||||
return -1
|
||||
$float_bytes := fn($T: type): type {
|
||||
if T == f64 return uint else if T == f32 return u32
|
||||
}
|
|
@ -1,41 +1,13 @@
|
|||
.{string, fmt, memory} := @use("stn")
|
||||
string := @use("string.hb")
|
||||
|
||||
LogMsg := packed struct {level: LogLevel, string: ^u8, strlen: uint}
|
||||
LogMsg := packed struct {level: u8, string: ^u8, strlen: uint}
|
||||
|
||||
LogLevel := enum {
|
||||
Error,
|
||||
Warn,
|
||||
Info,
|
||||
Debug,
|
||||
Trace,
|
||||
log := fn(level: u8, message: ^u8): void {
|
||||
return @eca(3, 1, LogMsg.(level, message, @inline(string.length, message)), @sizeof(LogMsg))
|
||||
}
|
||||
|
||||
$log := fn(level: LogLevel, message: []u8): void {
|
||||
return @eca(3, 1, LogMsg.(level, message.ptr, message.len), @sizeof(LogMsg))
|
||||
}
|
||||
|
||||
$error := fn(message: []u8): void return log(LogLevel.Error, message)
|
||||
$warn := fn(message: []u8): void return log(LogLevel.Warn, message)
|
||||
$info := fn(message: []u8): void return log(LogLevel.Info, message)
|
||||
$debug := fn(message: []u8): void return log(LogLevel.Debug, message)
|
||||
$trace := fn(message: []u8): void return log(LogLevel.Trace, message)
|
||||
|
||||
print_buffer := memory.dangling(u8)
|
||||
|
||||
print := fn(v: @Any(), opts: fmt.FormatOptions): void {
|
||||
if print_buffer == memory.dangling(u8) {
|
||||
print_buffer = memory.request_page(1)
|
||||
}
|
||||
len := @inline(fmt.format, v, print_buffer[0..memory.PAGE_SIZE], opts)
|
||||
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
||||
memory.set(u8, &0, print_buffer, len)
|
||||
}
|
||||
|
||||
printf := fn(str: []u8, v: @Any(), opts: fmt.FormatOptions): void {
|
||||
if print_buffer == memory.dangling(u8) {
|
||||
print_buffer = memory.request_page(1)
|
||||
}
|
||||
len := @inline(fmt.format_with_str, v, str, print_buffer[0..memory.PAGE_SIZE], opts)
|
||||
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
||||
memory.set(u8, &0, print_buffer, len)
|
||||
}
|
||||
error := fn(message: ^u8): void return @inline(log, 0, message)
|
||||
warn := fn(message: ^u8): void return @inline(log, 1, message)
|
||||
info := fn(message: ^u8): void return @inline(log, 2, message)
|
||||
debug := fn(message: ^u8): void return @inline(log, 3, message)
|
||||
trace := fn(message: ^u8): void return @inline(log, 4, message)
|
File diff suppressed because one or more lines are too long
|
@ -1,172 +1,216 @@
|
|||
// todo: splice function
|
||||
length := fn(ptr: ^u8): uint {
|
||||
len := 0
|
||||
loop if *(ptr + len) == 0 return len else len += 1
|
||||
}
|
||||
|
||||
reverse := fn(str: []u8): void {
|
||||
if str.len == 0 return;
|
||||
j := str.len - 1
|
||||
i := 0
|
||||
display_int := fn(num: int, p: ^u8, radix: uint): ^u8 {
|
||||
is_negative := num < 0
|
||||
if is_negative num = -num
|
||||
|
||||
ptr := p
|
||||
|
||||
if num == 0 {
|
||||
*ptr = 0x30;
|
||||
*(ptr + 1) = 0
|
||||
return p
|
||||
}
|
||||
|
||||
loop if num == 0 break else {
|
||||
remainder := num % @bitcast(radix)
|
||||
num /= @bitcast(radix);
|
||||
*ptr = @intcast(remainder + 0x30)
|
||||
if remainder > 9 {
|
||||
*ptr = @intcast(remainder - 10 + 0x41)
|
||||
}
|
||||
ptr += 1
|
||||
}
|
||||
|
||||
if is_negative {
|
||||
*ptr = 0x2D
|
||||
ptr += 1
|
||||
}
|
||||
// ! it gets broked when you do this ??
|
||||
// *ptr = 0
|
||||
|
||||
@inline(reverse, p)
|
||||
return p
|
||||
}
|
||||
|
||||
reverse := fn(s: ^u8): void {
|
||||
j := s + @inline(length, s) - 1
|
||||
temp := @as(u8, 0)
|
||||
loop if i < j {
|
||||
temp = str[i]
|
||||
str[i] = str[j]
|
||||
str[j] = temp
|
||||
i += 1
|
||||
loop if s < j {
|
||||
temp = *s;
|
||||
*s = *j;
|
||||
*j = temp
|
||||
s += 1
|
||||
j -= 1
|
||||
} else return
|
||||
}
|
||||
|
||||
equals := fn(lhs: []u8, rhs: []u8): bool {
|
||||
if lhs.len != rhs.len return false
|
||||
if lhs.ptr == rhs.ptr return true
|
||||
i := 0
|
||||
loop if i == lhs.len break else {
|
||||
if lhs[i] != rhs[i] return false
|
||||
i += 1
|
||||
equals := fn(lhs: ^u8, rhs: ^u8): bool {
|
||||
if lhs == rhs {
|
||||
return true
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
clear := fn(str: []u8): void {
|
||||
i := 0
|
||||
loop if i == str.len break else {
|
||||
str[i] = 0
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
|
||||
split_once := fn(haystack: []u8, needle: @Any()): ?struct {left: []u8, right: []u8} {
|
||||
T := @TypeOf(needle)
|
||||
i := 0
|
||||
if T == []u8 {
|
||||
if needle.len == 0 return null
|
||||
loop {
|
||||
if i + needle.len > haystack.len return null
|
||||
if haystack[i] == needle[0] {
|
||||
matches := true
|
||||
n := 1
|
||||
loop {
|
||||
if n == needle.len break
|
||||
if haystack[i + n] != needle[n] {
|
||||
matches = false
|
||||
break
|
||||
}
|
||||
n += 1
|
||||
}
|
||||
|
||||
if matches return .(haystack[0..i], haystack[i + needle.len..])
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
} else if T == u8 {
|
||||
loop {
|
||||
if haystack[i] == needle {
|
||||
return .(haystack[0..i], haystack[i + 1..])
|
||||
} else if i == haystack.len return null
|
||||
i += 1
|
||||
}
|
||||
loop if *lhs != *rhs {
|
||||
return false
|
||||
} else if *lhs == 0 {
|
||||
return true
|
||||
} else {
|
||||
@error("Type of needle must be []u8 or u8.")
|
||||
lhs += 1
|
||||
rhs += 1
|
||||
}
|
||||
}
|
||||
|
||||
split := fn(iter: []u8, needle: @Any()): struct {
|
||||
str: []u8,
|
||||
needle: @TypeOf(needle),
|
||||
clear := fn(ptr: ^u8): void {
|
||||
loop if *ptr == 0 break else {
|
||||
*ptr = 0
|
||||
ptr += 1
|
||||
}
|
||||
}
|
||||
|
||||
split_once := fn(haystack: ^u8, needle: u8): ?^u8 {
|
||||
loop if *haystack == needle return haystack else if *haystack == 0 return null else haystack += 1
|
||||
}
|
||||
|
||||
split_once_str := fn(haystack: ^u8, needle: ^u8): ?^u8 {
|
||||
if *needle == 0 return null
|
||||
|
||||
loop if *haystack == 0 return null else {
|
||||
if *haystack == *needle {
|
||||
h := haystack
|
||||
n := needle
|
||||
|
||||
loop {
|
||||
n += 1
|
||||
h += 1
|
||||
if *n == 0 {
|
||||
return haystack
|
||||
} else if *h == 0 | *h != *n {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
haystack += 1
|
||||
}
|
||||
}
|
||||
|
||||
Split := struct {
|
||||
str: ^u8,
|
||||
needle: u8,
|
||||
done: bool,
|
||||
|
||||
next := fn(self: ^Self): ?[]u8 {
|
||||
if self.done return null;
|
||||
|
||||
splits := split_once(self.str, self.needle)
|
||||
if splits != null {
|
||||
self.str = splits.right
|
||||
return splits.left
|
||||
} else {
|
||||
self.done = true
|
||||
return self.str
|
||||
}
|
||||
}
|
||||
} {
|
||||
T := @TypeOf(needle)
|
||||
if T != []u8 & T != u8 {
|
||||
@error("Type of needle must be []u8 or u8.")
|
||||
}
|
||||
return .(iter, needle, false)
|
||||
}
|
||||
|
||||
chars := fn(iter: []u8): struct {
|
||||
str: []u8,
|
||||
|
||||
next := fn(self: ^Self): ?u8 {
|
||||
if self.str.len == 0 return null
|
||||
self.str = self.str[1..]
|
||||
return self.str[0]
|
||||
}
|
||||
} {
|
||||
return .(iter)
|
||||
split := fn(iter: ^u8, needle: u8): Split {
|
||||
return .(
|
||||
iter,
|
||||
needle,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
count := fn(haystack: []u8, needle: @Any()): uint {
|
||||
T := @TypeOf(needle)
|
||||
i := 0
|
||||
iter_split := fn(iter: ^Split): ?^u8 {
|
||||
if iter.done | *iter.str == 0 {
|
||||
return null
|
||||
}
|
||||
|
||||
next := split_once(iter.str + 1, iter.needle)
|
||||
|
||||
if next == null {
|
||||
iter.done = true
|
||||
return iter.str
|
||||
}
|
||||
s := iter.str
|
||||
iter.str = next + 1
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
SplitStr := struct {
|
||||
str: ^u8,
|
||||
needle: ^u8,
|
||||
done: bool,
|
||||
}
|
||||
|
||||
split_str := fn(iter: ^u8, needle: ^u8): SplitStr {
|
||||
return .(
|
||||
iter,
|
||||
needle,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
iter_split_str := fn(iter: ^SplitStr): ?^u8 {
|
||||
if iter.done | *iter.str == 0 {
|
||||
return null
|
||||
}
|
||||
|
||||
next := split_once_str(iter.str, iter.needle)
|
||||
|
||||
if next == null {
|
||||
iter.done = true
|
||||
return iter.str
|
||||
}
|
||||
|
||||
s := iter.str
|
||||
|
||||
iter.str = next + length(iter.needle)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
find_once := fn(haystack: ^u8, needle: u8): ?uint {
|
||||
return @bitcast(@inline(split_once, haystack, needle) - haystack)
|
||||
}
|
||||
|
||||
find_once_str := fn(haystack: ^u8, needle: ^u8): ?uint {
|
||||
return @bitcast(@inline(split_once_str, haystack, needle) - haystack)
|
||||
}
|
||||
|
||||
count := fn(haystack: ^u8, needle: ^u8): uint {
|
||||
c := 0
|
||||
if T == []u8 {
|
||||
if needle.len == 0 return null
|
||||
loop {
|
||||
if i + needle.len > haystack.len return c
|
||||
if haystack[i] == needle[0] {
|
||||
matches := true
|
||||
n := 1
|
||||
loop {
|
||||
if n == needle.len break
|
||||
if haystack[i + n] != needle[n] {
|
||||
matches = false
|
||||
break
|
||||
}
|
||||
n += 1
|
||||
loop if *haystack == needle {
|
||||
c += 1
|
||||
haystack += 1
|
||||
} else if *haystack == 0 return c else haystack += 1
|
||||
}
|
||||
|
||||
count_str := fn(haystack: ^u8, needle: ^u8): uint {
|
||||
if *needle == 0 return 0
|
||||
c := 0
|
||||
loop if *haystack == 0 return c else {
|
||||
if *haystack == *needle {
|
||||
h := haystack
|
||||
n := needle
|
||||
|
||||
loop {
|
||||
n += 1
|
||||
h += 1
|
||||
if *n == 0 {
|
||||
c += 1
|
||||
break
|
||||
} else if *h == 0 | *h != *n {
|
||||
break
|
||||
}
|
||||
|
||||
if matches c += 1
|
||||
}
|
||||
i += 1
|
||||
}
|
||||
} else if T == u8 {
|
||||
loop {
|
||||
if haystack[i] == needle c += 1 else if i == haystack.len return c
|
||||
i += 1
|
||||
}
|
||||
} else {
|
||||
@error("Type of needle must be []u8 or u8.")
|
||||
haystack += 1
|
||||
}
|
||||
}
|
||||
|
||||
left_trim := fn(str: []u8, sub: []u8): []u8 {
|
||||
i := 0
|
||||
if str[0] == sub[0] {
|
||||
loop if i == sub.len {
|
||||
return str[i..str.len]
|
||||
} else if str[i] != sub[i] | i == str.len {
|
||||
break
|
||||
left_trim := fn(str: ^u8, sub: ^u8): ^u8 {
|
||||
original := str
|
||||
if *str == *sub {
|
||||
loop if *sub == 0 {
|
||||
return str
|
||||
} else if *str != *sub {
|
||||
return original
|
||||
} else if *str == 0 {
|
||||
return original
|
||||
} else {
|
||||
i += 1
|
||||
str += 1
|
||||
sub += 1
|
||||
}
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
right_trim := fn(str: []u8, sub: []u8): []u8 {
|
||||
i := 0
|
||||
if str[str.len - 1] == sub[sub.len - 1] {
|
||||
loop if i == sub.len {
|
||||
return str[0..str.len - i]
|
||||
} else if str[str.len - i - 1] != sub[sub.len - i - 1] | i == str.len {
|
||||
break
|
||||
} else {
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
||||
trim := fn(str: []u8, sub: []u8): []u8 {
|
||||
return right_trim(left_trim(str, sub), sub)
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
.{math: .{Vec2}, buffer, log, memory, string} := @use("stn");
|
||||
.{Channel, Window, send_header, send_message, await_channel, await_header, await_message, message, BUFFER_SERVER, BUFFER_CLIENT, WindowProps, WindowData} := @use("lib:sunset_proto");
|
||||
.{Surface, Color} := @use("lib:render")
|
||||
.{math: .{Vec2}, buffer, log, memory, string} := @use("../../stn/src/lib.hb");
|
||||
.{Channel, Window, send_header, send_message, await_channel, await_header, await_message, message, BUFFER_SERVER, BUFFER_CLIENT, WindowProps, WindowData} := @use("./lib.hb");
|
||||
.{Surface, Color} := @use("../../render/src/lib.hb")
|
||||
|
||||
// ! in the future this should be safely handled
|
||||
channel := Channel.(0, 0)
|
||||
|
||||
find_server := fn(): void {
|
||||
log.info("client: locating server")
|
||||
log.info("client: locating server\0")
|
||||
channel2 := await_channel()
|
||||
channel.server = channel2.server
|
||||
channel.client = channel2.client
|
||||
log.info("client: server located")
|
||||
log.info("client: server located\0")
|
||||
}
|
||||
|
||||
new := fn(props: WindowProps): ?Window {
|
||||
|
@ -19,13 +19,13 @@ new := fn(props: WindowProps): ?Window {
|
|||
if response.header.kind != message.ack {
|
||||
return null
|
||||
}
|
||||
log.info("client: recv ack")
|
||||
log.info("client: recv ack\0")
|
||||
send_message(WindowProps, message.props, props, response.body.server)
|
||||
windowdata := await_message(WindowData, response.body.client)
|
||||
if windowdata.header.kind != message.ack {
|
||||
return null
|
||||
}
|
||||
log.info("client: recv windowdata")
|
||||
log.info("client: recv windowdata\0")
|
||||
surface := Surface.new(windowdata.body.props.dimensions.x, windowdata.body.props.dimensions.y)
|
||||
return .(windowdata.body, surface)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
.{math: .{Vec2}, buffer, memory} := @use("stn");
|
||||
.{Surface} := @use("lib:render")
|
||||
.{Surface} := @use("../../render/src/lib.hb")
|
||||
|
||||
$BUFFER_SERVER := "sunset_server"
|
||||
$BUFFER_CLIENT := "sunset_client"
|
||||
$BUFFER_SERVER := "sunset_server\0"
|
||||
$BUFFER_CLIENT := "sunset_client\0"
|
||||
|
||||
Channel := packed struct {
|
||||
client: uint,
|
||||
|
@ -85,7 +85,8 @@ Message := fn($Expr: type): type {
|
|||
WindowProps := struct {
|
||||
position: Vec2(uint),
|
||||
dimensions: Vec2(uint),
|
||||
title: []u8,
|
||||
// ! replace with owned string type later
|
||||
title: ^u8,
|
||||
}
|
||||
|
||||
WindowData := struct {
|
||||
|
|
|
@ -6,28 +6,28 @@ WindowServer := struct {
|
|||
window_count: uint,
|
||||
channel: Channel,
|
||||
// ! replace this with a collection when we get an allocator
|
||||
windows: [10]?Window,
|
||||
windows: [?Window; 10],
|
||||
font: text.Font,
|
||||
}
|
||||
|
||||
// ! in the future this should be safely handled
|
||||
server := @as(WindowServer, idk)
|
||||
|
||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||
|
||||
start := fn(): void {
|
||||
font := text.font_from_psf2(@bitcast(&psf), false)
|
||||
if font == null {
|
||||
log.error("server: failed to load asset")
|
||||
log.error("server: failed to load asset\0")
|
||||
return
|
||||
}
|
||||
server = .(
|
||||
0,
|
||||
.{client: buffer.create(BUFFER_CLIENT), server: buffer.create(BUFFER_SERVER)},
|
||||
.[null, null, null, null, null, null, null, null, null, null],
|
||||
.(null, null, null, null, null, null, null, null, null, null),
|
||||
@as(text.Font, font),
|
||||
)
|
||||
log.info("server: started server")
|
||||
log.info("server: started server\0")
|
||||
}
|
||||
|
||||
incoming := fn(): bool {
|
||||
|
@ -36,14 +36,14 @@ incoming := fn(): bool {
|
|||
return true
|
||||
}
|
||||
if msg.kind == message.syn {
|
||||
log.info("server: recv syn")
|
||||
log.info("server: recv syn\0")
|
||||
channel := Channel.(buffer.create_nameless(), buffer.create_nameless())
|
||||
send_message(Channel, message.ack, channel, server.channel.client)
|
||||
props := await_message(WindowProps, channel.server)
|
||||
if props.header.kind != message.props {
|
||||
return true
|
||||
}
|
||||
log.info("server: recv props")
|
||||
log.info("server: recv props\0")
|
||||
// ! do inspection of requested props here
|
||||
data := WindowData.(props.body, channel, permissions.default)
|
||||
send_message(WindowData, message.ack, data, channel.client)
|
||||
|
@ -51,7 +51,8 @@ incoming := fn(): bool {
|
|||
// decorations
|
||||
{
|
||||
title := data.props.title
|
||||
deco_length := title.len * 10
|
||||
title_length := string.length(title)
|
||||
deco_length := title_length * 10
|
||||
// draw the window tab bar
|
||||
surface.put_filled_rect(.(0, 0), .(data.props.dimensions.x + DECO_WIDTH + deco_length, DECO_HEIGHT_TOP), DECO_COLOUR)
|
||||
// Draw the window tab
|
||||
|
|
|
@ -1,43 +1,46 @@
|
|||
stn := @use("stn")
|
||||
sunset := @use("lib:sunset_proto")
|
||||
render := @use("lib:render")
|
||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||
horizon_api := @use("lib:horizon_api");
|
||||
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{Vec2} := stn.math
|
||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||
|
||||
.{Vec2} := stn.math;
|
||||
.{log} := stn;
|
||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||
.{set_color, render_label_to_surface, Label} := horizon_api.widgets.label
|
||||
|
||||
main := fn(): void {
|
||||
sunset.client.find_server()
|
||||
|
||||
window := sunset.client.new(.(.(10, 10), .(400, 300), "ableFetch!"))
|
||||
window := sunset.client.new(.(.(400, 100), .(400, 300), "ableFetch!\0"))
|
||||
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
||||
// pos := Vec2(uint).(1, 100)
|
||||
|
||||
if window == null {
|
||||
log.error("got no window")
|
||||
log.error("got no window\0")
|
||||
return
|
||||
}
|
||||
|
||||
text_label := Label.new_label("kernel : akern 0.2.0", 300)
|
||||
text_label_2 := Label.new_label("os : ableos", 300)
|
||||
text_label_3 := Label.new_label("wm : sunset", 300)
|
||||
text_label.set_color(render.BLACK, render.WHITE)
|
||||
text_label := Label.new_label("kernel : akern 0.2.0\0", 300)
|
||||
text_label.set_color(sunset.server.DECO_COLOUR, render.BLACK)
|
||||
|
||||
text_label_2.set_color(render.BLACK, render.WHITE)
|
||||
text_label_3.set_color(render.BLACK, render.WHITE)
|
||||
text_label_2 := Label.new_label("os : ableos\0", 300)
|
||||
text_label_2.set_color(sunset.server.DECO_COLOUR, render.BLACK)
|
||||
text_label_3 := Label.new_label("wm : sunset\0", 300)
|
||||
text_label_3.set_color(sunset.server.DECO_COLOUR, render.BLACK)
|
||||
|
||||
pos1 := Vec2(uint).(1, 1)
|
||||
pos2 := Vec2(uint).(1, 20)
|
||||
pos3 := Vec2(uint).(1, 40)
|
||||
|
||||
render_label_to_surface(window.surface, text_label, font, pos1)
|
||||
render_label_to_surface(window.surface, text_label_2, font, pos2)
|
||||
render_label_to_surface(window.surface, text_label_3, font, pos3)
|
||||
loop {
|
||||
// stn.log.info("AAAA")
|
||||
render.clear(window.surface, render.BLACK)
|
||||
// render.put_surface(window.surface, image, .(image.width + x % window.data.props.dimensions.x, 40), false)
|
||||
pos := Vec2(uint).(1, 100)
|
||||
|
||||
render_label_to_surface(window.surface, text_label, font, pos)
|
||||
pos = Vec2(uint).(1, 120)
|
||||
|
||||
render_label_to_surface(window.surface, text_label_2, font, pos)
|
||||
|
||||
pos = Vec2(uint).(1, 140)
|
||||
render_label_to_surface(window.surface, text_label_3, font, pos)
|
||||
|
||||
_ = sunset.client.send_frame(window)
|
||||
// stn.sleep.sleep_until_interrupt(100)
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
# angels_halo
|
||||
|
||||
A Minix 3 style reincarnation service.
|
||||
|
||||
Running in the background restarting your drivers.
|
|
@ -1,7 +0,0 @@
|
|||
(pkg angels-halo
|
||||
(authors ("able"))
|
||||
(version 0 1 0))
|
||||
|
||||
(dependencies
|
||||
(libraries ())
|
||||
(programs (hblang)))
|
|
@ -1,18 +0,0 @@
|
|||
stn := @use("stn");
|
||||
.{log} := stn;
|
||||
.{ProcessID} := stn.acs
|
||||
|
||||
Strategy := enum {
|
||||
None,
|
||||
Restart,
|
||||
}
|
||||
|
||||
MonitoredProcess := struct {
|
||||
pid: ProcessID,
|
||||
}
|
||||
|
||||
main := fn(): int {
|
||||
log.info("Angels Halo reincarnation server started.")
|
||||
|
||||
return 0
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
.{memory, buffer, log} := @use("stn");
|
||||
.{memory, buffer, log} := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{inb, outb} := memory
|
||||
|
||||
regs := @use("regs.hb");
|
||||
|
@ -28,7 +28,7 @@ sloop := fn(i: u8): void {
|
|||
// identify := fn(): u8 {
|
||||
// a := inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||
// outb(ATA_PRIMARY_DRIVE_HEAD, 0xA0)
|
||||
// log.info("Primary drive head set.")
|
||||
// log.info("Primary drive head set.\0")
|
||||
|
||||
// a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||
// outb(ATA_PRIMARY_SECCOUNT, 0)
|
||||
|
@ -43,10 +43,10 @@ sloop := fn(i: u8): void {
|
|||
// outb(ATA_PRIMARY_COMM_REGSTAT, 0xE7)
|
||||
|
||||
// status := inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||
// log.info("Waiting for status.")
|
||||
// log.info("Waiting for status.\0")
|
||||
// loop {
|
||||
// if (status & STAT_BSY) == 0 {
|
||||
// log.info("Status got.")
|
||||
// log.info("Status got.\0")
|
||||
// break
|
||||
// } else {
|
||||
// sloop()
|
||||
|
@ -54,14 +54,14 @@ sloop := fn(i: u8): void {
|
|||
// status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||
// }
|
||||
// if status == 0 {
|
||||
// log.error("No drive detected.")
|
||||
// log.error("No drive detected.\0")
|
||||
|
||||
// return 0
|
||||
// }
|
||||
// log.info("Status indicates presence of a drive. Polling while STAT_BSY... ")
|
||||
// log.info("Status indicates presence of a drive. Polling while STAT_BSY... \0")
|
||||
// loop {
|
||||
// if (status & STAT_BSY) == 0 {
|
||||
// log.info("Status got.")
|
||||
// log.info("Status got.\0")
|
||||
// break
|
||||
// } else {
|
||||
// sloop()
|
||||
|
@ -73,7 +73,7 @@ sloop := fn(i: u8): void {
|
|||
// hi := inb(ATA_PRIMARY_LBA_HI)
|
||||
|
||||
// if (mid | hi) == 0 {
|
||||
// log.error("The drive is not ATA. (Who knows what it is.)")
|
||||
// log.error("The drive is not ATA. (Who knows what it is.)\0")
|
||||
// return 0
|
||||
// }
|
||||
|
||||
|
@ -81,7 +81,7 @@ sloop := fn(i: u8): void {
|
|||
// }
|
||||
|
||||
drive_reset := fn(): void {
|
||||
log.warn("Drive resetting.")
|
||||
log.warn("Drive resetting.\0")
|
||||
outb(ATA_PRIMARY_DEVCTL, 0x4)
|
||||
sloop(4)
|
||||
outb(ATA_PRIMARY_DEVCTL, 0x0)
|
||||
|
@ -100,17 +100,17 @@ poll := fn(): u8 {
|
|||
|
||||
status = inb(ATA_PRIMARY_IO + ATA_REG_STAT)
|
||||
if (status & ATA_SR_DF) == 0 {
|
||||
log.error("ATA PRIMARY DRIVE FAULT")
|
||||
log.error("ATA PRIMARY DRIVE FAULT\0")
|
||||
return 1
|
||||
}
|
||||
|
||||
if (status & ATA_SR_ERR) == 0 {
|
||||
log.error("ATA PRIMARY ERR")
|
||||
log.error("ATA PRIMARY ERR\0")
|
||||
return 2
|
||||
}
|
||||
|
||||
if (status & ATA_SR_DRQ) == 0 {
|
||||
log.error("ATA PRIMARY DRQ")
|
||||
log.error("ATA PRIMARY DRQ\0")
|
||||
return 3
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ main := fn(): int {
|
|||
a := inb(0x4600)
|
||||
b := inb(0x4700)
|
||||
|
||||
// c := buffer.search("XNumber")
|
||||
// c := buffer.search("XNumber\0")
|
||||
// c := identify()
|
||||
|
||||
d := drive_reset()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$READ_ONLY := 0x1
|
||||
$HIDDEN := 0x2
|
||||
$SYSTEM := 0x4
|
||||
$VOLUME_ID := 0x8
|
||||
$DIRECTORY: 0x10
|
||||
$ARCHIVE := 0x20
|
||||
READ_ONLY := @as(u32, 0x1)
|
||||
HIDDEN := @as(u32, 0x2)
|
||||
SYSTEM := @as(u32, 0x4)
|
||||
VOLUME_ID := @as(u32, 0x8)
|
||||
DIRECTORY := @as(u32, 0x10)
|
||||
ARCHIVE := @as(u32, 0x20)
|
||||
LFN := READ_ONLY | HIDDEN | SYSTEM | VOLUME_ID
|
|
@ -1,19 +1,19 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, log} := stn
|
||||
|
||||
VALID_JUMP_BYTES := u8.[0xEB, 0x3C, 0x90]
|
||||
VALID_JUMP_BYTES := [u8].(0xEB, 0x3C, 0x90)
|
||||
|
||||
OemIdent := struct {
|
||||
dos_version: [8]u8,
|
||||
dos_version_name: [8]u8,
|
||||
dos_version: [u8; 8],
|
||||
dos_version_name: [u8; 8],
|
||||
|
||||
new := fn(major: int, minor: int): OemIdent {
|
||||
return .(.[0, 0, 0, 0, 0, 0, 0, 0], .[0, 0, 0, 0, 0, 0, 0, 0])
|
||||
return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0))
|
||||
}
|
||||
}
|
||||
|
||||
BiosParameterBlock := struct {
|
||||
jump_bytes: [3]u8,
|
||||
jump_bytes: [u8; 3],
|
||||
oem_ident: OemIdent,
|
||||
bytes_per_sector: u16,
|
||||
sectors_per_cluster: u8,
|
||||
|
@ -53,16 +53,16 @@ FatVersionNumber := struct {
|
|||
minor_version: u8,
|
||||
}
|
||||
|
||||
FormatReservation := [12]u8
|
||||
FormatReservation := [u8; 12]
|
||||
|
||||
// Padded with spaces.
|
||||
VolumeName := [11]u8
|
||||
VolumeName := [u8; 11]
|
||||
|
||||
SystemIdentifierString := [8]u8
|
||||
VALID_SYSTEM_IDENTIFIER_STRING := u8.[46, 41, 54, 33, 32, 20, 20, 20]
|
||||
SystemIdentifierString := [u8; 8]
|
||||
VALID_SYSTEM_IDENTIFIER_STRING := [u8].(46, 41, 54, 33, 32, 20, 20, 20)
|
||||
BOOTABLE_PARTITION_SIGNATURE := @as(u32, 0xAA55)
|
||||
|
||||
BootCode := [420]u8
|
||||
BootCode := [u8; 420]
|
||||
|
||||
ExtendedBootRecord := struct {
|
||||
sectors_per_fat: u32,
|
||||
|
@ -89,25 +89,25 @@ ExtendedBootRecord := struct {
|
|||
sanity_check := fn(ebr: ExtendedBootRecord): int {
|
||||
ret := 0
|
||||
if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 {
|
||||
log.warn("EBR-Drive-Number sanity check failed")
|
||||
log.warn("EBR-Drive-Number sanity check failed\0")
|
||||
}
|
||||
|
||||
if ebr.signature != 0x28 | ebr.signature != 0x29 {
|
||||
log.warn("EBR-Signature sanity check failed")
|
||||
log.warn("EBR-Signature sanity check failed\0")
|
||||
}
|
||||
|
||||
// ! comparison between [u8] is not supported in hblang
|
||||
// if ebr.system_identifier_string != VALID_SYSTEM_IDENTIFIER_STRING {
|
||||
// log.warn("EBR-Signature-Identifier-String sanity check failed")
|
||||
// log.warn("EBR-Signature-Identifier-String sanity check failed\0")
|
||||
// }
|
||||
return 0
|
||||
}
|
||||
|
||||
new := fn(): ExtendedBootRecord {
|
||||
version := FatVersionNumber.(0, 0)
|
||||
fmt_res := u8.[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
vol_name := @as([11]u8, idk)
|
||||
boot_code := @as([420]u8, idk)
|
||||
fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
vol_name := @as([u8; 11], idk)
|
||||
boot_code := @as([u8; 420], idk)
|
||||
|
||||
return ExtendedBootRecord.(
|
||||
0,
|
||||
|
@ -135,38 +135,38 @@ VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
|
|||
FSInfo := struct {
|
||||
// Must be 0x41615252 to indicate a valid FSInfo structure
|
||||
lead_signature: u32,
|
||||
lead_reserved: [480]u8,
|
||||
lead_reserved: [u8; 480],
|
||||
// If the value is 0xFFFFFFFF, then the free count is unknown and must be computed. However, this value might be incorrect and should at least be range checked (<= volume cluster count)
|
||||
last_known_free_cluster_count: u32,
|
||||
last_known_avalible_cluster: u32,
|
||||
trail_reserved: [12]u8,
|
||||
trail_reserved: [u8; 12],
|
||||
trail_signature: u32,
|
||||
|
||||
sanity_check := fn(fs_info: FSInfo): uint {
|
||||
ret := 0
|
||||
if fs_info.lead_signature != VALID_LEAD_FS_INFO {
|
||||
ret &= 1
|
||||
log.warn("Invalid leading signature in FSInfo.")
|
||||
log.warn("Invalid leading signature in FSInfo.\0")
|
||||
}
|
||||
if fs_info.last_known_free_cluster_count == 0xFFFFFFFF {
|
||||
ret &= 2
|
||||
log.warn("Last known free cluster count unknown.")
|
||||
log.warn("Last known free cluster count unknown.\0")
|
||||
}
|
||||
if fs_info.last_known_avalible_cluster == 0xFFFFFFFF {
|
||||
ret &= 4
|
||||
log.warn("Last known avalible cluster count unknown.")
|
||||
log.warn("Last known avalible cluster count unknown.\0")
|
||||
}
|
||||
if fs_info.trail_signature != VALID_TRAIL_FS_INFO {
|
||||
ret &= 8
|
||||
log.warn("Invalid trailing signature in FSInfo.")
|
||||
log.warn("Invalid trailing signature in FSInfo.\0")
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
new := fn(): FSInfo {
|
||||
lead_reserved := @as([480]u8, idk)
|
||||
trail_reserved := @as([12]u8, idk)
|
||||
lead_reserved := @as([u8; 480], idk)
|
||||
trail_reserved := @as([u8; 12], idk)
|
||||
return FSInfo.(
|
||||
VALID_LEAD_FS_INFO,
|
||||
lead_reserved,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
attributes := @use("attributes.hb")
|
||||
datetime := @use("datetime.hb")
|
||||
|
||||
FileName := [11]u8
|
||||
FileName := [u8; 11]
|
||||
|
||||
// This is the File Allocation Table entry that tells us where on disk the File is.
|
||||
FileEntry := struct {
|
||||
|
@ -18,4 +18,4 @@ FileEntry := struct {
|
|||
last_modification_date: datetime.date,
|
||||
low_cluster_number: u16,
|
||||
file_size: u32,
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, log} := stn
|
||||
|
||||
attributes := @use("attributes.hb")
|
||||
|
@ -8,17 +8,17 @@ bios_parameter_block := @use("bios_parameter_block.hb");
|
|||
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
||||
.{BiosParameterBlock, ExtendedBootRecord, FSInfo} := bios_parameter_block
|
||||
|
||||
$FAT12_THRESHOLD := 4085
|
||||
$FAT16_THRESHOLD := 65525
|
||||
FAT12_THRESHOLD := 4085
|
||||
FAT16_THRESHOLD := 65525
|
||||
|
||||
$EXFAT := 0
|
||||
$FAT12 := 1
|
||||
$FAT16 := 2
|
||||
$FAT32 := 3
|
||||
ExFAT := 0
|
||||
FAT12 := 1
|
||||
FAT16 := 2
|
||||
FAT32 := 3
|
||||
|
||||
calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
||||
if sector_size == 0 {
|
||||
return EXFAT
|
||||
return ExFAT
|
||||
} else if total_clusters < 4085 {
|
||||
return FAT12
|
||||
} else if total_clusters < 65525 {
|
||||
|
@ -36,7 +36,7 @@ main := fn(): int {
|
|||
fat_type := calculate_fat_type(1, 100)
|
||||
|
||||
if fat_type != FAT32 {
|
||||
log.warn("filesystem_fat32 driver only supports Fat32.")
|
||||
log.warn("filesystem_fat32 driver only supports Fat32.\0")
|
||||
}
|
||||
|
||||
bsc := bpb.sanity_check()
|
||||
|
@ -49,7 +49,7 @@ main := fn(): int {
|
|||
// Open file
|
||||
if msg_type == 0 {
|
||||
// Paths without a node-disk component are to be treated as local files.
|
||||
file_path := "node-disk:/test"
|
||||
file_path := "node-disk:/test\0"
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, random, log} := stn;
|
||||
.{Vec2} := stn.math
|
||||
|
||||
horizon_api := @use("lib:horizon_api");
|
||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||
.{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets.label;
|
||||
.{sexpr_parser, render_ui} := horizon_api.ui
|
||||
|
||||
render := @use("lib:render");
|
||||
render := @use("../../../libraries/render/src/lib.hb");
|
||||
.{Surface} := render;
|
||||
.{Font} := render.text
|
||||
|
||||
intouch := @use("lib:intouch")
|
||||
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
||||
|
||||
Window := struct {
|
||||
// TODO: Replace this with widgets
|
||||
|
@ -21,23 +21,23 @@ Window := struct {
|
|||
y: int,
|
||||
}
|
||||
|
||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("sysdata:assets/wallpaper.qoi")
|
||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("../../../assets/wallpaper.qoi")
|
||||
|
||||
main := fn(): int {
|
||||
win_buff := buffer.create("XHorizon")
|
||||
win_buff := buffer.create("XHorizon\0")
|
||||
|
||||
screen := render.init(true)
|
||||
|
||||
// Clear the screen to black.
|
||||
screen.clear(render.BLACK)
|
||||
render.clear(screen, render.black)
|
||||
|
||||
wallpaper := render.image.from(@bitcast(&img))
|
||||
if wallpaper == null {
|
||||
return 1
|
||||
}
|
||||
|
||||
window := render.Surface.new(screen.width / 3, screen.height / 3)
|
||||
window := render.new_surface(screen.width / 3, screen.height / 3)
|
||||
|
||||
mem_buf := memory.request_page(1)
|
||||
color := random.any(render.Color)
|
||||
|
@ -48,16 +48,16 @@ main := fn(): int {
|
|||
|
||||
mouse_x := @as(i16, 0)
|
||||
mouse_y := @as(i16, 0)
|
||||
text_label := new_label("Hi")
|
||||
text_label := new_label("Hi\0")
|
||||
|
||||
// widgets := "()"
|
||||
// widgets := "()\0"
|
||||
// ui := sexpr_parser(widgets)
|
||||
|
||||
loop {
|
||||
// Clear the screen
|
||||
screen.clear(render.BLACK)
|
||||
render.clear(screen, render.black)
|
||||
|
||||
screen.put_surface(wallpaper, .(0, 0), false)
|
||||
render.put_surface(screen, wallpaper, .(0, 0), false)
|
||||
|
||||
// TODO: Read the window buffer here
|
||||
{
|
||||
|
@ -65,33 +65,33 @@ main := fn(): int {
|
|||
|
||||
if false {
|
||||
// Scroll bar :ThumbsUp:
|
||||
screen.put_rect(.(100, 100), .(100, 10), render.WHITE)
|
||||
screen.put_filled_rect(.(110, 100), .(20, 10), render.WHITE)
|
||||
render.put_rect(screen, .(100, 100), .(100, 10), render.white)
|
||||
render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
|
||||
|
||||
screen.put_rect(.(90, 110), .(10, 100), render.WHITE)
|
||||
screen.put_filled_rect(.(90, 120), .(10, 20), render.WHITE)
|
||||
render.put_rect(screen, .(90, 110), .(10, 100), render.white)
|
||||
render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white)
|
||||
}
|
||||
|
||||
{
|
||||
// osu dots
|
||||
screen.put_rect(.(400, 100), .(100, 100), render.RED)
|
||||
screen.put_rect(.(100, 100 + 300), .(100, 100), render.RED)
|
||||
render.put_rect(screen, .(400, 100), .(100, 100), render.red)
|
||||
render.put_rect(screen, .(100, 100 + 300), .(100, 100), render.red)
|
||||
}
|
||||
|
||||
{
|
||||
pos := Vec2(uint).(1, screen.height - 21)
|
||||
render_label_to_surface(screen, text_label, font, pos)
|
||||
screen.put_rect(.(0, screen.height - 21), .(screen.width - 1, 20), render.WHITE)
|
||||
render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white)
|
||||
}
|
||||
|
||||
// Screen border
|
||||
screen.put_rect(.(0, 0), .(screen.width - 1, screen.height - 1), render.WHITE)
|
||||
render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white)
|
||||
|
||||
// get input events from drivers via intouch
|
||||
if false {
|
||||
key_event := intouch.recieve_key_event()
|
||||
if key_event != null {
|
||||
log.info("Key event ")
|
||||
log.info("Key event \0")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ main := fn(): int {
|
|||
//
|
||||
|
||||
if mouse_event != null {
|
||||
// log.warn("Mouse event received")
|
||||
// log.warn("Mouse event received\0")
|
||||
|
||||
change_x := @as(i16, mouse_event.x_change)
|
||||
change_x = change_x << 8
|
||||
|
@ -127,18 +127,18 @@ main := fn(): int {
|
|||
mouse_y -= change_y
|
||||
|
||||
if mouse_event.left {
|
||||
set_label_text(text_label, "LEFT CLICK")
|
||||
set_label_text(text_label, "LEFT CLICK\0")
|
||||
}
|
||||
if mouse_event.middle {
|
||||
set_label_text(text_label, "MIDDLE CLICK")
|
||||
set_label_text(text_label, "MIDDLE CLICK\0")
|
||||
}
|
||||
if mouse_event.right {
|
||||
set_label_text(text_label, "RIGHT CLICK")
|
||||
set_label_text(text_label, "RIGHT CLICK\0")
|
||||
}
|
||||
}
|
||||
|
||||
screen.put_filled_rect(.(mouse_x, mouse_y), .(20, 20), render.BLACK)
|
||||
screen.put_rect(.(mouse_x, mouse_y), .(20, 20), render.WHITE)
|
||||
render.put_filled_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.black)
|
||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
||||
|
||||
// Send events to focused window
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ main := fn(): int {
|
|||
// TODO: Get windows out of a collection and iter through
|
||||
|
||||
// Sync the screen
|
||||
screen.sync()
|
||||
render.sync(screen)
|
||||
}
|
||||
|
||||
return 0
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, log} := stn
|
||||
|
||||
horizon_api := @use("lib:horizon_api");
|
||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||
.{create_window} := horizon_api
|
||||
|
||||
ignim := @use("lib:ignim");
|
||||
ignim := @use("../../../libraries/ignim/src/lib.hb");
|
||||
.{errors} := ignim
|
||||
|
||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
||||
|
||||
main := fn(): int {
|
||||
x := 0
|
||||
// loop if x > 10000 break else x += 1
|
||||
|
||||
windowing_system_buffer := buffer.search("XHorizon")
|
||||
windowing_system_buffer := buffer.search("XHorizon\0")
|
||||
// TODO: get WindowID
|
||||
wid := create_window(windowing_system_buffer)
|
||||
if false {
|
||||
program_name := "Horizon Testing Program"
|
||||
program_name := "Horizon Testing Program\0"
|
||||
program_version := ignim.version.make_version(0, 1, 0)
|
||||
engine_name := "None"
|
||||
engine_name := "None\0"
|
||||
engine_version := ignim.version.make_version(0, 0, 0)
|
||||
api_version := ignim.version.make_api_version(0, 1, 0, 0)
|
||||
|
||||
|
@ -32,7 +32,7 @@ main := fn(): int {
|
|||
// // TODO: recursively follow this https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance
|
||||
ret := ignim.instance.create_instance(&create_info, 0, &instance)
|
||||
if ret == errors.IncompatibleDriver {
|
||||
log.error("Driver Incompatible with Vulkan")
|
||||
log.error("Driver Incompatible with Vulkan\0")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{memory, buffer, log, string, math} := stn;
|
||||
.{inb, outb} := memory
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.{memory, log} := @use("stn");
|
||||
.{memory, log} := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{bit0, bit1, bit5, bit6, bit7} := @use("bits.hb");
|
||||
.{Port, PORT_AT_STARTUP} := @use("port.hb")
|
||||
|
||||
|
@ -87,15 +87,15 @@ init := fn(): void {
|
|||
}
|
||||
|
||||
if (port1.exists | port2.exists) == false {
|
||||
log.error("No ports detected! No input will be processed! Cannot handle this!")
|
||||
log.error("No ports detected! No input will be processed! Cannot handle this!\0")
|
||||
}
|
||||
|
||||
if port1.exists {
|
||||
log.info("Port 1 exists.")
|
||||
log.info("Port 1 exists.\0")
|
||||
enable_port1()
|
||||
}
|
||||
if port2.exists {
|
||||
log.info("Port 2 exists.")
|
||||
log.info("Port 2 exists.\0")
|
||||
enable_port2()
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
.{memory, log, buffer, string} := @use("stn");
|
||||
.{MouseEvent} := @use("lib:intouch").events;
|
||||
.{memory, log, buffer, string} := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{MouseEvent} := @use("../../../libraries/intouch/src/lib.hb").events;
|
||||
.{bit0, bit1, bit2, bit3, bit4} := @use("bits.hb")
|
||||
devices := @use("devices.hb")
|
||||
controller := @use("controller.hb");
|
||||
.{Info, Port} := controller
|
||||
mouse := @use("mouse.hb")
|
||||
format_page := memory.dangling(u8)
|
||||
|
||||
mouse_buffer := 0
|
||||
keyboard_buffer := 0
|
||||
|
@ -71,10 +72,10 @@ process := fn(port: ^controller.Port): void {
|
|||
port.device.value = port.packet[1] | port.packet[0] << 8
|
||||
enable_streaming(port)
|
||||
}
|
||||
log.info("Identified device!")
|
||||
log.print(port.device.value, .{radix: 16})
|
||||
log.info("Identified device!\0")
|
||||
log.info(string.display_int(port.device.value, format_page, 16))
|
||||
} else {
|
||||
log.info("KEY PRESSED")
|
||||
log.info("KEY PRESSED\0")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,12 +108,13 @@ check_complete := fn(port: ^controller.Port): bool {
|
|||
}
|
||||
|
||||
main := fn(): void {
|
||||
mouse_buffer = buffer.create("PS/2 Mouse")
|
||||
mouse_buffer = buffer.create("PS/2 Mouse\0")
|
||||
format_page = memory.alloc(u8, 1024)
|
||||
|
||||
controller.init()
|
||||
|
||||
if controller.port1.exists {
|
||||
//log.info("Port 1 exists.")
|
||||
//log.info("Port 1 exists.\0")
|
||||
controller.send_byte(@bitcast(0), 0xF4)
|
||||
}
|
||||
if controller.port2.exists {
|
||||
|
@ -123,10 +125,10 @@ main := fn(): void {
|
|||
info = controller.get_info()
|
||||
|
||||
if controller.timed_out(info) {
|
||||
log.error("Timeout error! Cannot handle these!")
|
||||
log.error("Timeout error! Cannot handle these!\0")
|
||||
}
|
||||
if controller.check_parity(info) {
|
||||
log.error("Parity error! Cannot handle these!")
|
||||
log.error("Parity error! Cannot handle these!\0")
|
||||
}
|
||||
/*
|
||||
if controller.has_input(info) {
|
||||
|
|
|
@ -7,7 +7,7 @@ $Reboot := State.(1)
|
|||
Port := packed struct {
|
||||
exists: bool,
|
||||
device: DeviceID,
|
||||
packet: [8]u8,
|
||||
packet: [u8; 8],
|
||||
packet_length: u8,
|
||||
can_hot_plug: bool,
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ Port := packed struct {
|
|||
$PORT_AT_STARTUP := Port.(
|
||||
true,
|
||||
NO_DEVICE,
|
||||
.[0, 0, 0, 0, 0, 0, 0, 0],
|
||||
.(0, 0, 0, 0, 0, 0, 0, 0),
|
||||
0,
|
||||
true,
|
||||
)
|
|
@ -1,7 +1,7 @@
|
|||
.{memory, buffer, log, string, math} := @use("stn")
|
||||
.{memory, buffer, log, string, math} := @use("../../../libraries/stn/src/lib.hb")
|
||||
Vec2 := math.Vec2
|
||||
|
||||
intouch := @use("lib:intouch");
|
||||
intouch := @use("../../../libraries/intouch/src/lib.hb");
|
||||
.{MouseEvent} := intouch.events
|
||||
|
||||
i9 := packed struct {sign: bool, value: u8}
|
||||
|
@ -21,7 +21,7 @@ reset_mouse := fn(): void {
|
|||
@inline(send_byte, 0x64, 0xD4)
|
||||
@inline(send_byte, 0x60, 0xFF)
|
||||
loop if memory.inb(0x60) == 0xAA {
|
||||
log.info("Self check passed.")
|
||||
log.info("Self check passed.\0")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -82,11 +82,11 @@ set_up_mouse := fn(): void {
|
|||
button_states := @as(u8, 0)
|
||||
|
||||
main := fn(): int {
|
||||
mouse_buffer := buffer.create("PS/2 Mouse")
|
||||
mouse_buffer := buffer.create("PS/2 Mouse\0")
|
||||
format_page := memory.alloc(u8, 1024)
|
||||
|
||||
send_byte(0x64, 0xA8)
|
||||
log.info("Aux mouse device enabled.")
|
||||
log.info("Aux mouse device enabled.\0")
|
||||
|
||||
set_up_mouse()
|
||||
|
||||
|
@ -102,7 +102,7 @@ main := fn(): int {
|
|||
|
||||
if status == 0xAA {
|
||||
loop if memory.inb(0x60) == 0 break
|
||||
log.info("Mouse plugged in!")
|
||||
log.info("Mouse plugged in!\0")
|
||||
set_up_mouse()
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
stn := @use("stn")
|
||||
stn := @use("../../../libraries/stn/src/lib.hb")
|
||||
|
||||
main := fn(): int {
|
||||
stn.log.info("\r
|
||||
|
@ -9,7 +9,7 @@ main := fn(): int {
|
|||
| : '=.:.=' : |\r
|
||||
| : :'.___.': : |\r
|
||||
'-:__:__:__:__:-'\r
|
||||
")
|
||||
\0")
|
||||
|
||||
return 0
|
||||
}
|
|
@ -10,7 +10,7 @@ example := fn(): void {
|
|||
image_bmp := render.image.from(@bitcast(&@embed("sysdata:assets/mini.bmp")))
|
||||
|
||||
if image_qoi == null | image_bmp == null {
|
||||
log.error("failed to load images for whatever reason")
|
||||
log.error("failed to load images for whatever reason\0")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -14,27 +14,26 @@ $Y_MAX := 1.12
|
|||
// $Y_MIN := 0.31
|
||||
// $Y_MAX := 0.306
|
||||
|
||||
// zoom into that weird curve part of the main cardioid
|
||||
// $X_MIN := 0.25
|
||||
// $X_MAX := 0.34
|
||||
// $Y_MIN := -0.075
|
||||
// $Y_MAX := 0.075
|
||||
|
||||
$MAX_ITERATION := 300
|
||||
|
||||
$USE_SUNSET := true
|
||||
$USE_SUNSET := false
|
||||
|
||||
palette := render.Color.[.(50, 0, 60, 0), .(93, 0, 157, 0), .(140, 98, 229, 0), .(191, 190, 255, 0), .(226, 234, 255, 0), .(242, 250, 255, 0), .(226, 234, 255, 0), .(191, 190, 255, 0), .(140, 98, 229, 0), .(93, 0, 157, 0), .(50, 0, 60, 0)]
|
||||
palette := [render.Color].(render.LIGHT_RED, render.LIGHT_YELLOW, render.LIGHT_GREEN, render.LIGHT_CYAN, render.LIGHT_BLUE, render.LIGHT_MAGENTA)
|
||||
$LEN_PALETTE := @sizeof(@TypeOf(palette)) / @sizeof(render.Color)
|
||||
|
||||
example := fn(): void {
|
||||
z := math.log(f32, 10.0, 100.0)
|
||||
z2 := math.sign(f32, 10.0)
|
||||
z = math.min(f32, 10.0, 100.0)
|
||||
z = math.max(f32, 10.0, 100.0)
|
||||
|
||||
screen := @as(render.Surface, idk)
|
||||
window := @as(?sunset.Window, null)
|
||||
if USE_SUNSET {
|
||||
sunset.client.find_server()
|
||||
window = sunset.client.new(.(.(450, 140), .(400, 400), "Mandelbrot Set"))
|
||||
window = sunset.client.new(.(.(400, 140), .(400, 400), "Mandelbrot Set\0"))
|
||||
if window == null {
|
||||
log.error("got no window")
|
||||
log.error("got no window\0")
|
||||
return
|
||||
}
|
||||
screen = window.surface
|
||||
|
@ -92,7 +91,4 @@ example := fn(): void {
|
|||
_ = sunset.client.send_frame(window)
|
||||
}
|
||||
}
|
||||
if USE_SUNSET loop {
|
||||
_ = sunset.client.send_frame(window)
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
math := @use("stn:math")
|
||||
render := @use("lib:render")
|
||||
|
||||
/* expected result:
|
||||
red tangent graph
|
||||
*/
|
||||
|
||||
$f := fn(x: uint): int {
|
||||
x_f := @as(f32, @itf(@bitcast(x)))
|
||||
y_f := math.tan(x_f * 0.03) * 20
|
||||
return @fti(y_f)
|
||||
}
|
||||
|
||||
y_asymptote := fn(screen: render.Surface, x: uint): void {
|
||||
y := 0
|
||||
loop if y >= screen.height break else {
|
||||
screen.put_pixel(.(x, y), render.GRAY)
|
||||
y += 4
|
||||
}
|
||||
}
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(false)
|
||||
x := 0
|
||||
height := @as(int, @bitcast(screen.height))
|
||||
width := @as(int, @bitcast(screen.width))
|
||||
screen.put_hline(screen.height / 2, 0, screen.width, render.LIGHT_GRAY)
|
||||
loop if x >= screen.width break else {
|
||||
y1 := height / 2 - f(x)
|
||||
y2 := height / 2 - f(x + 1)
|
||||
if y1 > height y1 = height else if y1 < 0 {
|
||||
y_asymptote(screen, x)
|
||||
x += 1
|
||||
continue
|
||||
}
|
||||
if y2 > height {
|
||||
y_asymptote(screen, x)
|
||||
x += 1
|
||||
continue
|
||||
} else if y2 < 0 y2 = 0
|
||||
|
||||
if math.abs(int, y2 - y1) > 1 {
|
||||
screen.put_vline(x, @bitcast(y1), @bitcast(y2), render.RED)
|
||||
} else {
|
||||
screen.put_pixel(.(x, @bitcast(y1)), render.RED)
|
||||
screen.put_pixel(.(x, @bitcast(y2)), render.RED)
|
||||
}
|
||||
|
||||
x += 1
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
.{random} := @use("stn")
|
||||
render := @use("lib:render")
|
||||
.{random} := @use("../../../../libraries/stn/src/lib.hb")
|
||||
render := @use("../../../../libraries/render/src/lib.hb")
|
||||
|
||||
example := fn(): void {
|
||||
screen := render.init(false)
|
||||
|
|
|
@ -39,7 +39,7 @@ example := fn(): void {
|
|||
return
|
||||
}
|
||||
|
||||
msg := "sticky note:\n"
|
||||
msg := "sticky note:\n\0"
|
||||
msg_len := string.length(msg)
|
||||
|
||||
buf := memory.alloc(u8, 4096)
|
||||
|
@ -240,4 +240,4 @@ map_keys := fn(scancode: u8): u8 {
|
|||
}
|
||||
return ps2_table[scancode]
|
||||
}
|
||||
ps2_table := u8.[0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
ps2_table := [u8].(0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
|
@ -1,11 +1,11 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{sleep, log, memory} := stn
|
||||
|
||||
main := fn(): int {
|
||||
loop {
|
||||
log.info("BEFORE")
|
||||
log.info("BEFORE\0")
|
||||
sleep.sleep_until_interrupt(8)
|
||||
log.info("AFTER")
|
||||
log.info("AFTER\0")
|
||||
}
|
||||
|
||||
return 0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
sunset := @use("lib:sunset_proto")
|
||||
render := @use("lib:render")
|
||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
|
||||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{log} := stn;
|
||||
.{Vec2} := stn.math
|
||||
|
||||
|
@ -26,17 +26,17 @@ GameState := struct {
|
|||
main := fn(): void {
|
||||
sunset.client.find_server()
|
||||
|
||||
window := sunset.client.new(.(.(600, 400), .(200, 200), "SDoom"))
|
||||
window := sunset.client.new(.(.(600, 400), .(200, 200), "SDoom\0"))
|
||||
|
||||
if window == null {
|
||||
log.error("got no window")
|
||||
log.error("got no window\0")
|
||||
return
|
||||
}
|
||||
|
||||
game_state := GameState.new()
|
||||
|
||||
loop {
|
||||
window.surface.clear(render.BLACK)
|
||||
render.clear(window.surface, render.black)
|
||||
width := 100
|
||||
idx := 1
|
||||
|
||||
|
@ -44,7 +44,7 @@ main := fn(): void {
|
|||
if idx >= width {
|
||||
break
|
||||
}
|
||||
window.surface.put_vline(idx, 10, 100, render.WHITE)
|
||||
render.put_vline(window.surface, idx, 10, 100, render.white)
|
||||
idx += 1
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
.{memory, buffer} := @use("stn")
|
||||
.{memory, buffer} := @use("../../../libraries/stn/src/lib.hb")
|
||||
|
||||
serial_print := fn(str: []u8): void {
|
||||
serial_print := fn(ptr: ^u8): void {
|
||||
letter := @as(u8, 0)
|
||||
i := 0
|
||||
loop if i == str.len break else {
|
||||
letter = str[i]
|
||||
loop if *ptr == 0 break else {
|
||||
letter = *ptr
|
||||
memory.outb(0xF803, letter)
|
||||
i += 1
|
||||
ptr += 1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
serial_println := fn(str: []u8): void {
|
||||
serial_print(str)
|
||||
serial_println := fn(ptr: ^u8): void {
|
||||
serial_print(ptr)
|
||||
memory.outb(0xF803, 12)
|
||||
memory.outb(0xF803, 13)
|
||||
return
|
||||
|
@ -20,28 +19,28 @@ serial_println := fn(str: []u8): void {
|
|||
|
||||
main := fn(): int {
|
||||
// This must be done first and foremost to prevent racing
|
||||
a := buffer.create("XNumber")
|
||||
serial_println("Starting Serial Driver.")
|
||||
a := buffer.create("XNumber\0")
|
||||
serial_println("Starting Serial Driver.\0")
|
||||
|
||||
mem := memory.request_page(1)[1..memory.PAGE_SIZE]
|
||||
mem := memory.request_page(1)
|
||||
|
||||
loop {
|
||||
ptr := @as(^u8, @eca(4, a, mem, 0x1000))
|
||||
if ptr == 0 {
|
||||
serial_println("No message")
|
||||
serial_println("No message\0")
|
||||
}
|
||||
if ptr > 0 {
|
||||
serial_println("Yes message")
|
||||
serial_println("Yes message\0")
|
||||
serial_println(mem)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Note that the first byte is reserved, pad accordingly.
|
||||
b := buffer.search("XNumber")
|
||||
b := buffer.search("XNumber\0")
|
||||
|
||||
if a == b {
|
||||
serial_println("Stopping Serial Driver.")
|
||||
serial_println("Stopping Serial Driver.\0")
|
||||
}
|
||||
|
||||
return 0
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
.{log} := @use("stn")
|
||||
sunset := @use("lib:sunset_proto")
|
||||
render := @use("lib:render")
|
||||
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
|
||||
bmp := @embed("sysdata:assets/mini.bmp")
|
||||
bmp := @embed("../../../assets/mini.bmp")
|
||||
|
||||
main := fn(): void {
|
||||
sunset.client.find_server()
|
||||
|
||||
image := render.image.bmp.from(@bitcast(&bmp))
|
||||
if image == null {
|
||||
log.error("got no image")
|
||||
log.error("got no image\0")
|
||||
return
|
||||
}
|
||||
|
||||
window := sunset.client.new(.(.(400, 400), .(200, 200), "Hello"))
|
||||
window := sunset.client.new(.(.(100, 100), .(200, 200), "Hello,\0"))
|
||||
|
||||
if window == null {
|
||||
log.error("got no window")
|
||||
log.error("got no window\0")
|
||||
return
|
||||
}
|
||||
x := 0
|
||||
loop {
|
||||
window.surface.clear(render.BLACK)
|
||||
window.surface.put_surface(image, .(image.width + x % window.data.props.dimensions.x, 20), false)
|
||||
render.clear(window.surface, render.black)
|
||||
render.put_surface(window.surface, image, .(image.width + x % window.data.props.dimensions.x, 20), false)
|
||||
_ = sunset.client.send_frame(window)
|
||||
x += 1
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "angels_halo"
|
||||
authors = ["able"]
|
||||
name = "sunset_client_2"
|
||||
authors = ["koniifer"]
|
||||
|
||||
[dependants.libraries]
|
||||
|
29
sysdata/programs/sunset_client_2/src/main.hb
Normal file
29
sysdata/programs/sunset_client_2/src/main.hb
Normal file
|
@ -0,0 +1,29 @@
|
|||
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
|
||||
bmp := @embed("../../../assets/able.bmp")
|
||||
|
||||
main := fn(): void {
|
||||
sunset.client.find_server()
|
||||
|
||||
image := render.image.bmp.from(@bitcast(&bmp))
|
||||
if image == null {
|
||||
log.error("got no image\0")
|
||||
return
|
||||
}
|
||||
|
||||
window := sunset.client.new(.(.(400, 100), .(400, 240), "Sunset!\0"))
|
||||
|
||||
if window == null {
|
||||
log.error("got no window\0")
|
||||
return
|
||||
}
|
||||
x := 0
|
||||
loop {
|
||||
render.clear(window.surface, render.black)
|
||||
render.put_surface(window.surface, image, .(image.width + x % window.data.props.dimensions.x, 40), false)
|
||||
_ = sunset.client.send_frame(window)
|
||||
x += 1
|
||||
}
|
||||
}
|
|
@ -1,44 +1,20 @@
|
|||
sunset := @use("lib:sunset_proto")
|
||||
render := @use("lib:render")
|
||||
intouch := @use("lib:intouch")
|
||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
||||
render := @use("../../../libraries/render/src/lib.hb")
|
||||
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
||||
|
||||
horizon_api := @use("lib:horizon_api");
|
||||
horizon_api := @use("../../../libraries/horizon_api/src/lib.hb");
|
||||
.{set_color, render_label_to_surface, Label} := horizon_api.widgets.label
|
||||
|
||||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{Vec2} := stn.math
|
||||
|
||||
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("sysdata:assets/wallpaper.qoi")
|
||||
|
||||
Mouse := struct {
|
||||
x: uint,
|
||||
y: uint,
|
||||
// TODO: Make this configurable via wm config
|
||||
cursor_width: u8,
|
||||
|
||||
max_x: uint,
|
||||
max_y: uint,
|
||||
|
||||
new := fn(max_x: uint, max_y: uint): Self {
|
||||
center_x := max_x / 2
|
||||
center_y := max_y / 2
|
||||
|
||||
return Self.(center_x, center_y, 3, max_x, max_y)
|
||||
}
|
||||
/*
|
||||
center := fn(self: Self){
|
||||
center_x := max_x / 2
|
||||
center_y := max_y / 2
|
||||
|
||||
return Self.(center_x, center_y, 3, max_x, max_y)
|
||||
}*/
|
||||
}
|
||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
||||
img := @embed("../../../assets/wallpaper.qoi")
|
||||
|
||||
main := fn(): int {
|
||||
sunset.server.start()
|
||||
defer {
|
||||
stn.log.info("Sunset Server Exit")
|
||||
stn.log.info("Sunset Server Exit\0")
|
||||
}
|
||||
|
||||
screen := render.init(true)
|
||||
|
@ -47,17 +23,14 @@ main := fn(): int {
|
|||
|
||||
wallpaper := render.image.from(@bitcast(&img))
|
||||
if wallpaper == null {
|
||||
// stn.panic("Wallpaper not loaded")
|
||||
// stn.panic("Wallpaper not loaded\0")
|
||||
return 1
|
||||
}
|
||||
|
||||
// mouse_x := 100
|
||||
// mouse_y := 100
|
||||
mouse_x := 100
|
||||
mouse_y := 100
|
||||
|
||||
mouse := Mouse.new(screen.width, screen.height)
|
||||
//mouse.center()
|
||||
|
||||
text_label := Label.new_label("", 1024)
|
||||
text_label := Label.new_label("\0", 1024)
|
||||
text_label.set_color(sunset.server.DECO_COLOUR, render.BLACK)
|
||||
|
||||
loop {
|
||||
|
@ -67,34 +40,34 @@ main := fn(): int {
|
|||
change_x = change_x << 8
|
||||
change_x = change_x >> 8
|
||||
|
||||
mouse.x += change_x
|
||||
if mouse.x <= 0 {
|
||||
mouse.x = 0
|
||||
mouse_x += change_x
|
||||
if mouse_x <= 0 {
|
||||
mouse_x = 0
|
||||
}
|
||||
if mouse.x >= screen.width - 20 {
|
||||
mouse.x = @intcast(screen.width - 21)
|
||||
if mouse_x >= screen.width - 20 {
|
||||
mouse_x = @intcast(screen.width - 21)
|
||||
}
|
||||
|
||||
change_y := @as(i16, mouse_event.y_change)
|
||||
change_y = change_y << 8
|
||||
change_y = change_y >> 8
|
||||
|
||||
mouse.y -= change_y
|
||||
if mouse.y < 0 {
|
||||
mouse.y = 1
|
||||
mouse_y -= change_y
|
||||
if mouse_y < 0 {
|
||||
mouse_y = 1
|
||||
}
|
||||
if mouse.y >= screen.height - 20 {
|
||||
mouse.y = @intcast(screen.height - 21)
|
||||
if mouse_y >= screen.height - 20 {
|
||||
mouse_y = @intcast(screen.height - 21)
|
||||
}
|
||||
|
||||
if mouse_event.left {
|
||||
text_label.set_label_text("LEFT CLICK")
|
||||
text_label.set_label_text("LEFT CLICK\0")
|
||||
}
|
||||
if mouse_event.middle {
|
||||
text_label.set_label_text("MIDDLE CLICK")
|
||||
text_label.set_label_text("MIDDLE CLICK\0")
|
||||
}
|
||||
if mouse_event.right {
|
||||
text_label.set_label_text("RIGHT CLICK")
|
||||
text_label.set_label_text("RIGHT CLICK\0")
|
||||
}
|
||||
}
|
||||
{
|
||||
|
@ -119,8 +92,8 @@ main := fn(): int {
|
|||
|
||||
// Mouse cursor
|
||||
{
|
||||
screen.put_filled_circle(.(mouse.x, mouse.y), mouse.cursor_width, sunset.server.DECO_COLOUR_DARKER)
|
||||
screen.put_circle(.(mouse.x, mouse.y), mouse.cursor_width, sunset.server.DECO_COLOUR)
|
||||
screen.put_filled_circle(.(mouse_x, mouse_y), 10, sunset.server.DECO_COLOUR_DARKER)
|
||||
screen.put_circle(.(mouse_x, mouse_y), 10, sunset.server.DECO_COLOUR)
|
||||
}
|
||||
|
||||
screen.sync()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, log} := stn
|
||||
|
||||
pci := @use("lib:pci");
|
||||
pci := @use("../../../libraries/pci/src/lib.hb");
|
||||
.{PCIAddress, get_ids, config_read32} := pci
|
||||
|
||||
reg := @use("./reg.hb")
|
||||
|
@ -71,7 +71,7 @@ svga_device := fn(): SVGADevice {
|
|||
|
||||
// TODO : this function is broken
|
||||
GetBARAddr := fn(addr: PCIAddress, index: int): u32 {
|
||||
//bar := config_read32(addr, offsetof(PCIConfigSpace, BAR[index]))
|
||||
//bar := config_read32(addr, offsetof(PCIConfigSpace, BAR[index]));
|
||||
bar := config_read32(0, 3, 0, 0)
|
||||
PCI_CONF_BAR_IO := 0
|
||||
|
||||
|
@ -94,7 +94,7 @@ setup_device := fn(svga_dev: ^SVGADevice): void {
|
|||
pci_dev := pci.check_device(0, 3)
|
||||
|
||||
if pci_dev.device_id.vendor != PCI_VENDOR_ID_VMWARE {
|
||||
log.error("SVGA device not found")
|
||||
log.error("SVGA device not found\0")
|
||||
return
|
||||
}
|
||||
//| pci_dev.device_id.device != PCI_DEVICE_ID_VMWARE_SVGA2 {
|
||||
|
@ -115,7 +115,7 @@ setup_device := fn(svga_dev: ^SVGADevice): void {
|
|||
svga_dev.fbSize = svga_dev.width * svga_dev.height * svga_dev.bpp / 8
|
||||
|
||||
svga_dev.vramSize = read_reg(svga_dev, 0x10)
|
||||
log.info("SVGA device initialized successfully")
|
||||
log.info("SVGA device initialized successfully\0")
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ setup_framebuffer := fn(svga_dev: ^SVGADevice): void {
|
|||
write_reg(svga_dev, reg.SVGA_REG_HEIGHT, svga_dev.height)
|
||||
write_reg(svga_dev, reg.SVGA_REG_BITS_PER_PIXEL, svga_dev.bpp)
|
||||
|
||||
log.info("Framebuffer setup complete")
|
||||
log.info("Framebuffer setup complete\0")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
device := @use("device.hb")
|
||||
pci := @use("lib:pci")
|
||||
pci := @use("../../../libraries/pci/src/lib.hb")
|
||||
|
||||
stn := @use("stn");
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{string, memory, buffer, log} := stn
|
||||
|
||||
reg := @use("reg.hb")
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
stn := @use("stn");
|
||||
.{sleep, buffer} := stn
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
.{sleep} := stn
|
||||
|
||||
main := fn(): int {
|
||||
tmpfs_buffer := buffer.create("TmpFS")
|
||||
tmpfs_buffer := buffer.create("TmpFS\0")
|
||||
loop {
|
||||
// TODO
|
||||
// sleep.sleep_until_buffer(tmpfs_buffer)
|
||||
|
|
|
@ -3,5 +3,5 @@ serial_driver := @use("./tests/serial_driver.hb")
|
|||
|
||||
main := fn(): uint {
|
||||
// return serial_driver.test()
|
||||
return stn.hashers.test()
|
||||
return stn.sleep.test()
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
.{string, buffer} := @use("stn")
|
||||
.{string, buffer} := @use("../../../../libraries/stn/src/lib.hb")
|
||||
|
||||
log_info := fn(): void {
|
||||
a := buffer.search("XNumber")
|
||||
a := buffer.search("XNumber\0")
|
||||
if a == 0 {
|
||||
} else {
|
||||
msg := "XABC"
|
||||
msg := "XABC\0"
|
||||
msg_length := string.length(msg)
|
||||
@eca(3, a, msg, msg_length)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
stn := @use("stn");
|
||||
stn := @use("../../../../../libraries/stn/src/lib.hb");
|
||||
.{allocators, panic, log} := stn
|
||||
|
||||
AStruct := struct {
|
||||
|
@ -20,10 +20,10 @@ test := fn(): uint {
|
|||
}
|
||||
bstruct := balloc.alloc(AStruct, 2)
|
||||
if bstruct.ptr == null {
|
||||
log.info("Hi")
|
||||
log.info("Hi\0")
|
||||
// panic.panic("BlockAlloc actually didn't allocate.")
|
||||
} else {
|
||||
log.info("Allocator functioned.")
|
||||
log.info("Allocator functioned.\0")
|
||||
}
|
||||
balloc.dealloc(&bstruct.ptr, AStruct, 2)
|
||||
return 0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
.{log, sleep} := @use("stn")
|
||||
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
||||
|
||||
main := fn(): void {
|
||||
log.info("Hello, World!")
|
||||
// fake interrupt, sleep forever
|
||||
sleep.sleep_until_interrupt(100)
|
||||
log.info("Hello, World!\0")
|
||||
loop {
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,15 +1,18 @@
|
|||
.{dt, log} := @use("stn")
|
||||
.{dt, memory, string, log} := @use("../../../../../libraries/stn/src/lib.hb")
|
||||
|
||||
test := fn(): uint {
|
||||
log.print(dt.get(int, "framebuffer/fb0/width"), .{})
|
||||
log.print(dt.get(int, "framebuffer/fb0/height"), .{})
|
||||
log.print(dt.get(^uint, "framebuffer/fb0/ptr"), .{})
|
||||
log.print(dt.get(int, "cpu/cpu0/architecture"), .{})
|
||||
buffer := memory.request_page(1)
|
||||
|
||||
log.info(string.display_int(dt.get(int, "framebuffer/fb0/width\0"), buffer, 10))
|
||||
string.clear(buffer)
|
||||
|
||||
log.info(string.display_int(dt.get(int, "cpu/cpu0/architecture\0"), buffer, 10))
|
||||
string.clear(buffer)
|
||||
|
||||
// 0 -> memory mapped
|
||||
// 1 -> port mapped
|
||||
|
||||
log.print(dt.get(int, "serial_ports/sp0/mapping"), .{})
|
||||
log.info(string.display_int(dt.get(int, "serial_ports/sp0/mapping\0"), buffer, 10))
|
||||
|
||||
return 0
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
.{log, math} := @use("stn");
|
||||
.{Color} := @use("lib:render")
|
||||
|
||||
StructThingy := struct {
|
||||
a: uint,
|
||||
b: int,
|
||||
c: SubStructThingy,
|
||||
}
|
||||
|
||||
SubStructThingy := struct {
|
||||
a: f32,
|
||||
b: bool,
|
||||
}
|
||||
|
||||
EnumThingy := enum {
|
||||
The,
|
||||
TheOther,
|
||||
}
|
||||
|
||||
test := fn(): uint {
|
||||
log.print(@nameof(?u8), .{log: .Error})
|
||||
log.print("Hello, World", .{})
|
||||
log.print(EnumThingy.The, .{})
|
||||
log.print(StructThingy.(-100, -100, .(-math.PI, true)), .{log: .Warn})
|
||||
log.print(SubStructThingy.(-math.E, false), .{})
|
||||
log.print(Color.{r: 255, g: 254, b: 253, a: 252}, .{radix: 2})
|
||||
log.print(@as(f64, math.LN_2), .{radix: 16, precision: 1 << 32})
|
||||
log.print(u8.[1, 2, 3], .{})
|
||||
log.print(&SubStructThingy.(0.0, true), .{})
|
||||
log.print(@as(?u32, null), .{})
|
||||
log.print(@as(?u32, 200), .{})
|
||||
log.print(.(@as(?u32, null), 200, 3.14), .{})
|
||||
log.printf("{}, {}, {}", .("Hello", math.PI, Color.{r: 101, g: 102, b: 103, a: 104}), .{})
|
||||
log.printf("{}", "Goodbye", .{})
|
||||
|
||||
return 0
|
||||
}
|
|
@ -1,25 +1,32 @@
|
|||
.{hashers, log, memory, fmt, string, math} := @use("stn")
|
||||
.{hashers, log, memory, string} := @use("../../../../../libraries/stn/src/lib.hb")
|
||||
|
||||
test := fn(): uint {
|
||||
target := "abcdefghijklmnop"
|
||||
strings := .["abcdefshijklmnop", "abcdefghijklnnop", "abcdefshijklmnop", "abcdefghijklmnop", "abcdefghijflmnop", "dbcdefghijklmnop", "abcdefghijklmnop"]
|
||||
len := @sizeof(@TypeOf(strings)) / @sizeof([]u8)
|
||||
buffer := memory.request_page(1)
|
||||
target := "abcdefghijklmnop\0"
|
||||
strings := [^u8].("abcdefshijklmnop\0", "abcdefghijklnnop\0", "abcdefshijklmnop\0", "abcdefghijklmnop\0", "abcdefghijflmnop\0", "dbcdefghijklmnop\0", "abcdefghijklmnop\0")
|
||||
len := @sizeof(@TypeOf(strings)) / @sizeof(^u8)
|
||||
strlen := string.length(target)
|
||||
|
||||
// hasher := hashers.foldhash.FoldHasher.new(1)
|
||||
hasher := hashers.foldhash.FoldHasher.default()
|
||||
hasher.write(target.ptr, target.len)
|
||||
hasher.write(target, strlen)
|
||||
correct := hasher.finish()
|
||||
|
||||
log.printf("target string: {}, target hash: {}", .(target, correct), .{radix: 16})
|
||||
log.warn("target:\0")
|
||||
log.warn(target)
|
||||
|
||||
i := 0
|
||||
loop if i == len break else {
|
||||
defer i += 1
|
||||
|
||||
hasher.reset()
|
||||
hasher.write(strings[i].ptr, strings[i].len)
|
||||
hasher.write(strings[i], strlen)
|
||||
d := hasher.finish()
|
||||
log.printf("matches: {}, string: {}, hash: {}", .(d == correct, strings[i], d), .{radix: 16})
|
||||
if d == correct {
|
||||
log.warn("match found\0")
|
||||
}
|
||||
log.info(strings[i])
|
||||
log.debug(string.display_int(@bitcast(d), buffer, 16))
|
||||
string.clear(buffer)
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -2,5 +2,4 @@ hashers := @use("./hashers.hb")
|
|||
allocators := @use("./allocators.hb")
|
||||
sleep := @use("./sleep.hb")
|
||||
dt := @use("./dt.hb")
|
||||
process := @use("./process.hb")
|
||||
fmt := @use("./fmt.hb")
|
||||
process := @use("./process.hb")
|
|
@ -1,13 +1,20 @@
|
|||
.{process, log} := @use("stn")
|
||||
.{process, log, string, memory} := @use("../../../../../libraries/stn/src/lib.hb")
|
||||
|
||||
exe := @embed("./assets/hello_world_and_spin.hbf")
|
||||
|
||||
test := fn(): uint {
|
||||
buf := "\0\0\0\0\0\0\0"
|
||||
loop {
|
||||
log.print(process.spawn(@bitcast(&exe), 356), .{})
|
||||
log.info(
|
||||
string.display_int(
|
||||
@bitcast(process.spawn(@bitcast(&exe), 356)),
|
||||
buf,
|
||||
10,
|
||||
),
|
||||
)
|
||||
// spin so we don't spawn 10 quattuordecillion processes
|
||||
i := 0
|
||||
loop if i == 20000000 break else i += 1
|
||||
loop if i == 1000000 break else i += 1
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
.{sleep, log} := @use("stn")
|
||||
.{sleep, log} := @use("../../../../../libraries/stn/src/lib.hb")
|
||||
|
||||
test := fn(): uint {
|
||||
log.info("BEFORE")
|
||||
log.info("BEFORE\0")
|
||||
sleep.sleep_until_interrupt(32)
|
||||
log.info("AFTER")
|
||||
log.info("AFTER\0")
|
||||
return 0
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
# vfsaur
|
|
@ -1,11 +0,0 @@
|
|||
[package]
|
||||
name = "vfsaur"
|
||||
authors = [""]
|
||||
|
||||
[dependants.libraries]
|
||||
|
||||
[dependants.binaries]
|
||||
hblang.version = "1.0.0"
|
||||
|
||||
[build]
|
||||
command = "hblang src/main.hb"
|
|
@ -1,67 +0,0 @@
|
|||
stn := @use("stn");
|
||||
|
||||
.{string, buffer, log, acs} := stn;
|
||||
.{info} := log;
|
||||
.{BufferID} := acs
|
||||
|
||||
FilesystemServiceListing := struct {
|
||||
// The Root to match against of the file system
|
||||
root: []u8,
|
||||
// The buffer to forward fs requests to.
|
||||
buffer_id: BufferID,
|
||||
|
||||
new := fn(root: []u8, buffer_id: BufferID): Self {
|
||||
return .(root, buffer_id)
|
||||
}
|
||||
}
|
||||
|
||||
Path := struct {
|
||||
root: []u8,
|
||||
path: []u8,
|
||||
}
|
||||
|
||||
MessageTypes := enum {
|
||||
Create,
|
||||
Delete,
|
||||
// Used to register filesystem handlers.
|
||||
Mount,
|
||||
}
|
||||
|
||||
VFSMessage := struct {
|
||||
msg_type: MessageTypes,
|
||||
}
|
||||
|
||||
main := fn(): int {
|
||||
log.info("VFSaur starting.")
|
||||
vfs_buff := buffer.create("VFS")
|
||||
|
||||
bid := BufferID.(0, 0)
|
||||
fsl := FilesystemServiceListing.new("acs", bid)
|
||||
fsl2 := FilesystemServiceListing.new("boot", bid)
|
||||
|
||||
full_path := "acs:/path/to/a/file"
|
||||
a := parse_str_to_path(full_path)
|
||||
if a != null {
|
||||
log.info(a.root)
|
||||
log.info(a.path)
|
||||
}
|
||||
vfs_event := VFSMessage.(MessageTypes.Mount)
|
||||
|
||||
loop {
|
||||
buffer.recv(VFSMessage, vfs_buff, &vfs_event)
|
||||
if vfs_event.msg_type == MessageTypes.Mount {
|
||||
// TODO: get info from the message itself
|
||||
fsl3 := FilesystemServiceListing.new("acs", bid)
|
||||
}
|
||||
// TODO: sleep till vfs_buff message
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
parse_str_to_path := fn(full_path: []u8): ?Path {
|
||||
path := string.split_once(full_path, ':')
|
||||
if path == null {
|
||||
return null
|
||||
}
|
||||
return Path.(path.left, path.right)
|
||||
}
|
|
@ -23,8 +23,8 @@ resolution = "1024x768x24"
|
|||
|
||||
[boot.limine.ableos.modules]
|
||||
|
||||
# [boot.limine.ableos.modules.render_example]
|
||||
# path = "boot:///render_example.hbf"
|
||||
[boot.limine.ableos.modules.render_example]
|
||||
path = "boot:///render_example.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.sunset_server]
|
||||
# path = "boot:///sunset_server.hbf"
|
||||
|
@ -38,20 +38,11 @@ resolution = "1024x768x24"
|
|||
# [boot.limine.ableos.modules.ps2_driver]
|
||||
# path = "boot:///ps2_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.sunset_client_2]
|
||||
# path = "boot:///sunset_client_2.hbf"
|
||||
# [boot.limine.ableos.modules.sunset_client]
|
||||
# path = "boot:///sunset_client.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.ablefetch]
|
||||
# path = "boot:///ablefetch.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.diskio_driver]
|
||||
# path = "boot:///diskio_driver.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.angels_halo]
|
||||
# path = "boot:///angels_halo.hbf"
|
||||
|
||||
# [boot.limine.ableos.modules.test]
|
||||
# path = "boot:///test.hbf"
|
||||
|
||||
[boot.limine.ableos.modules.vfsaur]
|
||||
path = "boot:///vfsaur.hbf"
|
||||
|
|
Loading…
Reference in a new issue