diff --git a/sysdata/libraries/horizon_api/src/lib.hb b/sysdata/libraries/horizon_api/src/lib.hb index 83458a904..2acd07fb4 100644 --- a/sysdata/libraries/horizon_api/src/lib.hb +++ b/sysdata/libraries/horizon_api/src/lib.hb @@ -9,18 +9,18 @@ widgets := @use("widgets/widgets.hb") ui := @use("ui.hb") WindowID := struct { - host_id: int, - window_id: int, + host_id: uint, + window_id: uint, } VoidWindowID := WindowID.(0, 0) -create_window := fn(channel: int): ^render.Surface { +create_window := fn(channel: uint): ^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\0") + windowing_system_buffer := buffer.search("XHorizon") mem_buf := memory.request_page(1) if windowing_system_buffer == 0 { @@ -31,13 +31,13 @@ create_window := fn(channel: int): ^render.Surface { ret := buffer.recv([4096]u8, windowing_system_buffer, mem_buf) if ret == null { - log.info("No messages\0") + log.info("No messages") } if *mem_buf == 0 { - log.info("No messages\0") + log.info("No messages") } return @as(^render.Surface, idk) } -} +} \ No newline at end of file diff --git a/sysdata/libraries/horizon_api/src/ui.hb b/sysdata/libraries/horizon_api/src/ui.hb index e6512a1d3..9cbf25481 100644 --- a/sysdata/libraries/horizon_api/src/ui.hb +++ b/sysdata/libraries/horizon_api/src/ui.hb @@ -6,7 +6,7 @@ render := @use("../../../libraries/render/src/lib.hb"); .{Surface} := render; .{Font} := render.text -UI := struct {raw: ^u8, raw_length: uint, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte +UI := struct {raw: []u8, is_dirty: bool, surface: Surface, // Each child has their WidgetType as their first byte // children: ^^u8, } @@ -19,29 +19,26 @@ render_ui := fn(surface: Surface, ui: UI): void { render.put_surface(surface, ui.surface, pos, false) } -sexpr_parser := fn(sexpr: ^u8): UI { - cursor := sexpr +sexpr_parser := fn(sexpr: []u8): UI { + i := 0 paren_balance := 0 loop { - if *cursor == 0 { + if i == sexpr.len { if paren_balance != 0 { - log.error("Unbalanced Parens\0") + log.error("Unbalanced Parens") } break - } else if *cursor == 40 { - log.info("Open paren\0") + } else if sexpr[i] == '(' { + log.info("Open paren") paren_balance += 1 - } else if *cursor == 41 { - log.info("Closed paren\0") + } else if sexpr[i] == ')' { + log.info("Closed paren") paren_balance -= 1 } - cursor += 1 + i += 1 } - length := string.length(sexpr) - ui_surface := render.new_surface(100, 100) - - return UI.(sexpr, length, true, ui_surface) + return UI.(sexpr, true, ui_surface) } \ No newline at end of file diff --git a/sysdata/libraries/horizon_api/src/widgets/label.hb b/sysdata/libraries/horizon_api/src/widgets/label.hb index aa8b97e4f..72cc9ca94 100644 --- a/sysdata/libraries/horizon_api/src/widgets/label.hb +++ b/sysdata/libraries/horizon_api/src/widgets/label.hb @@ -10,27 +10,22 @@ Label := struct { magic: uint, is_dirty: bool, surface: Surface, - text: ^u8, - text_length: uint, + text: []u8, 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) - text_length := string.length(text) - label := Self.(3, true, text_surface, text, text_length, render.BLACK, render.WHITE) + label := Self.(3, true, text_surface, text, render.BLACK, render.WHITE) return label } - set_label_text := fn(self: Self, text: ^u8): void { - text_length := string.length(text) - + $set_label_text := fn(self: ^Self, text: []u8): void { 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 diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb index 14ac86e13..6130c7aab 100644 --- a/sysdata/libraries/intouch/src/lib.hb +++ b/sysdata/libraries/intouch/src/lib.hb @@ -1,4 +1,4 @@ -stn := @use("../../stn/src/lib.hb"); +stn := @use("stn"); .{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\0") + buf_id := buffer.search("PS/2 Keyboard") // 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\0") + buf_id := buffer.search("PS/2 Mouse") // Read out of the Mouse buffer here buffer.recv(MouseEvent, buf_id, &mevent) diff --git a/sysdata/libraries/pci/src/lib.hb b/sysdata/libraries/pci/src/lib.hb index db2b3668f..9092f1e57 100644 --- a/sysdata/libraries/pci/src/lib.hb +++ b/sysdata/libraries/pci/src/lib.hb @@ -1,4 +1,4 @@ -.{string, memory, buffer, log} := @use("../../stn/src/lib.hb") +.{string, memory, buffer, log} := @use("stn") 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(":|\0") + log.warn(":|") } else { - log.info(":)\0") + log.info(":)") } address := calculate_address(bus, device, 0, 0x8) reg2 := config_read32(bus, device, 0, 0x8) diff --git a/sysdata/libraries/render/src/image/bmp.hb b/sysdata/libraries/render/src/image/bmp.hb index 3efdd95ea..0d08ded1e 100644 --- a/sysdata/libraries/render/src/image/bmp.hb +++ b/sysdata/libraries/render/src/image/bmp.hb @@ -1,5 +1,5 @@ -.{Color, Surface, new_surface, put_surface} := @use("../lib.hb"); -.{log} := @use("../../../stn/src/lib.hb") +.{Color, Surface, new_surface, put_surface} := @use("lib:render"); +.{log} := @use("stn") 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.\0") + log.error("Invalid BMP image.") return null } diff --git a/sysdata/libraries/render/src/image/lib.hb b/sysdata/libraries/render/src/image/lib.hb index eecf6d87b..f2d8907af 100644 --- a/sysdata/libraries/render/src/image/lib.hb +++ b/sysdata/libraries/render/src/image/lib.hb @@ -1,5 +1,5 @@ -.{log} := @use("../../../stn/src/lib.hb"); -.{Surface} := @use("../lib.hb") +.{log} := @use("stn"); +.{Surface} := @use("lib:render") 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.\0") + log.error("Could not detect image format.") return null } else if format == BMP { return bmp.from(file) diff --git a/sysdata/libraries/render/src/image/qoi.hb b/sysdata/libraries/render/src/image/qoi.hb index 9604d5481..98e6cfbe2 100644 --- a/sysdata/libraries/render/src/image/qoi.hb +++ b/sysdata/libraries/render/src/image/qoi.hb @@ -1,5 +1,5 @@ -.{Color, Surface, new_surface} := @use("../lib.hb"); -.{log} := @use("../../../stn/src/lib.hb") +.{Color, Surface, new_surface} := @use("lib:render"); +.{log} := @use("stn") /* source: https://github.com/phoboslab/qoi/blob/master/qoi.h */ @@ -40,7 +40,7 @@ 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.\0") + log.error("Invalid QOI image.") return null } @@ -98,4 +98,4 @@ from := fn(qoi: ^u8): ?Surface { } return surface -} +} \ No newline at end of file diff --git a/sysdata/libraries/render/src/software.hb b/sysdata/libraries/render/src/software.hb index d8fbd49be..5c55d667c 100644 --- a/sysdata/libraries/render/src/software.hb +++ b/sysdata/libraries/render/src/software.hb @@ -8,9 +8,9 @@ framebuffer := memory.dangling(Color) utf8_len_table := u8.[0, 0, 2, 3] init := fn(doublebuffer: bool): Surface { - framebuffer = dt.get(^Color, "framebuffer/fb0/ptr\0") - width := dt.get(uint, "framebuffer/fb0/width\0") - height := dt.get(uint, "framebuffer/fb0/height\0") + framebuffer = dt.get(^Color, "framebuffer/fb0/ptr") + width := dt.get(uint, "framebuffer/fb0/width") + height := dt.get(uint, "framebuffer/fb0/height") 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,48 +314,50 @@ Surface := struct { char_advance := font.width + font.char_gap self_width := self.width - loop if *str == 0 break else { + i := 0 + + loop if i >= str.len break else { if cursor.y > max_y break glyph_data := @as(^u8, idk) code_point := @as(uint, 0) - if (*str & 0x80) == 0 { - if *str == 10 { + if (str[i] & 0x80) == 0 { + if str[i] == '\n' { cursor.x = pos.x cursor.y += next_line_y - str += 1 + i += 1 continue } if font.unicode == null { - if *str > font.num_glyphs { - str += 1 + if str[i] > font.num_glyphs { + i += 1 continue } - glyph_data = get_glyph(font, *str) + glyph_data = get_glyph(font, str[i]) } else { - if *str < UNC_TABLE_SIZE { - glyph_index := *(font.unicode + *str) + if str[i] < UNC_TABLE_SIZE { + glyph_index := *(font.unicode + str[i]) if glyph_index == 0xFFFF { - str += 1 + i += 1 continue } glyph_data = font.data + glyph_index * font.bytes_per_glyph } else { - str += 1 + i += 1 continue } } - str += 1 + i += 1 } else if font.unicode != null { - first_byte := *str + first_byte := str[i] num_bytes := @as(uint, 0) num_bytes = utf8_len_table[first_byte >> 5 & 0x3] if num_bytes == 0 { - str += 1 + i += 1 continue } @@ -365,25 +367,25 @@ Surface := struct { bytes_processed := 1 loop if bytes_processed >= num_bytes break else { - str += 1 - if *str == 0 | (*str & 0xC0) != 0x80 { + i += 1 + if i == str.len | (str[i] & 0xC0) != 0x80 { valid_sequence = false } if valid_sequence == false { break } - code_point = code_point << 6 | *str & 0x3F + code_point = code_point << 6 | str[i] & 0x3F bytes_processed += 1 } if valid_sequence == false { - str += 1 + i += 1 continue } - str += 1 + i += 1 - if code_point == 10 { + if code_point == '\n' { cursor.x = pos.x cursor.y += next_line_y continue diff --git a/sysdata/libraries/render/src/text.hb b/sysdata/libraries/render/src/text.hb index 795855e7d..1b95a8725 100644 --- a/sysdata/libraries/render/src/text.hb +++ b/sysdata/libraries/render/src/text.hb @@ -1,4 +1,4 @@ -.{log, memory} := @use("../../stn/src/lib.hb") +.{log, memory} := @use("stn") 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\0") + log.error("failed to load psf font: not a psf1 font, idiot") 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\0") + log.error("failed to load psf font: not a psf2 font, idiot") return null } diff --git a/sysdata/libraries/stn/src/alloc/block_alloc.hb b/sysdata/libraries/stn/src/alloc/block_alloc.hb index 7cca60624..801cb0446 100644 --- a/sysdata/libraries/stn/src/alloc/block_alloc.hb +++ b/sysdata/libraries/stn/src/alloc/block_alloc.hb @@ -1,4 +1,4 @@ -.{log, panic, memory} := @use("../lib.hb") +.{log, panic, memory} := @use("stn") 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\0") + log.info("Already Allocated") } // else { @@ -40,7 +40,7 @@ BlockAlloc := struct { // if self.ptr != null { // return .(64, self.ptr + offset * 64) // } else { - // // panic.panic("Allocator is not inited.\0") + // // panic.panic("Allocator is not inited.") // // return .(0, null) // } // } diff --git a/sysdata/libraries/stn/src/dt.hb b/sysdata/libraries/stn/src/dt.hb index 543205ac7..d7f03c760 100644 --- a/sysdata/libraries/stn/src/dt.hb +++ b/sysdata/libraries/stn/src/dt.hb @@ -1,5 +1,3 @@ -.{string} := @use("../../stn/src/lib.hb") - -get := fn($Expr: type, query: ^u8): Expr { - return @eca(3, 5, query, string.length(query)) +$get := fn($Expr: type, query: []u8): Expr { + return @eca(3, 5, query, query.len) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/file_io.hb b/sysdata/libraries/stn/src/file_io.hb index 8b3ec8072..d800c28b5 100644 --- a/sysdata/libraries/stn/src/file_io.hb +++ b/sysdata/libraries/stn/src/file_io.hb @@ -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\0" +// file_path := "DID:/test" Path := struct { // DiskID holds the host id disk_id: DiskID, diff --git a/sysdata/libraries/stn/src/hash/foldhash.hb b/sysdata/libraries/stn/src/hash/foldhash.hb index 41831129d..60587054f 100644 --- a/sysdata/libraries/stn/src/hash/foldhash.hb +++ b/sysdata/libraries/stn/src/hash/foldhash.hb @@ -26,7 +26,7 @@ * 3. This notice may not be removed or altered from any source distribution. */; -.{math, random} := @use("../lib.hb") +.{math, random} := @use("stn") $ARBITRARY0 := 0x243F6A8885A308D3 $ARBITRARY1 := 0x13198A2E03707344 diff --git a/sysdata/libraries/stn/src/log.hb b/sysdata/libraries/stn/src/log.hb index 4acc47787..50e23e889 100644 --- a/sysdata/libraries/stn/src/log.hb +++ b/sysdata/libraries/stn/src/log.hb @@ -37,6 +37,5 @@ printf := fn(str: []u8, v: @Any(), opts: fmt.FormatOptions): void { } 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)) - print(len, .{}) memory.set(u8, &0, print_buffer, len) } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/string.hb b/sysdata/libraries/stn/src/string.hb index dcf7db9d2..2c9d73940 100644 --- a/sysdata/libraries/stn/src/string.hb +++ b/sysdata/libraries/stn/src/string.hb @@ -1,4 +1,4 @@ -.{log, memory} := @use("stn") +// todo: splice function reverse := fn(str: []u8): void { if str.len == 0 return; @@ -14,8 +14,15 @@ reverse := fn(str: []u8): void { } else return } -$equals := fn(lhs: []u8, rhs: []u8): bool { - return lhs.ptr == rhs.ptr & lhs.len == rhs.len +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 + } + return true } clear := fn(str: []u8): void { @@ -26,90 +33,59 @@ clear := fn(str: []u8): void { } } -split_once := fn(haystack: []u8, needle: @Any()): ?[]u8 { +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 - i := 0 - loop if i == haystack.len return null else { + loop { + if i + needle.len > haystack.len return null if haystack[i] == needle[0] { - h := i - n := 0 - + matches := true + n := 1 loop { - n += 1 - h += 1 - if needle[n] == 0 { - return haystack[h..] - } else if haystack[h] == 0 | haystack[h] != needle[n] { + 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 { - i := 0 - loop if haystack[i] == needle return haystack[i..] else if i == haystack.len return null else i += 1 + loop { + if haystack[i] == needle { + return .(haystack[0..i], haystack[i + 1..]) + } else if i == haystack.len return null + i += 1 + } } else { @error("Type of needle must be []u8 or u8.") } } -SplitIter := fn($T: type): type { - return struct { - str: []u8, - needle: T, - done: bool, +split := fn(iter: []u8, needle: @Any()): struct { + str: []u8, + needle: @TypeOf(needle), + done: bool, - next := fn(self: ^Self): ?[]u8 { - if self.done return null; - - if @TypeOf(self.needle) == u8 { - i := 0 - loop if i == self.str.len { - self.done = true - return self.str - } else if self.str[i] == self.needle { - result := self.str[..i] - self.str = self.str[i + 1..] - return result - } else { - i += 1 - } - } else if @TypeOf(self.needle) == []u8 { - if self.needle.len == 0 return null - i := 0 - loop if i == self.str.len { - self.done = true - return self.str - } else if self.str[i] == self.needle[0] { - h := i - n := 0 - - loop { - n += 1 - h += 1 - - if n == self.needle.len { - result := self.str[..i] - self.str = self.str[h..] - return result - } else if h == self.str.len | self.str[h] != self.needle[n] { - break - } - } - } - i += 1 - } + 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 } } -} - -split := fn(iter: []u8, needle: @Any()): SplitIter(@TypeOf(needle)) { +} { T := @TypeOf(needle) if T != []u8 & T != u8 { @error("Type of needle must be []u8 or u8.") @@ -117,40 +93,47 @@ split := fn(iter: []u8, needle: @Any()): SplitIter(@TypeOf(needle)) { return .(iter, needle, false) } -find_once := fn(haystack: ^u8, needle: @Any()): ?uint { - return @bitcast(@inline(split_once, haystack, needle) - haystack) +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) } count := fn(haystack: []u8, needle: @Any()): uint { T := @TypeOf(needle) + i := 0 c := 0 - if T == u8 { - i := 0 - loop if haystack[i] == needle { - c += 1 - i += 1 - } else if i == haystack.len return c else i += 1 - } else if T == []u8 { - i := 0 - loop if i == haystack.len return c else { + if T == []u8 { + if needle.len == 0 return null + loop { + if i + needle.len > haystack.len return c if haystack[i] == needle[0] { - h := i - n := 0 - + matches := true + n := 1 loop { - n += 1 - h += 1 - if n == needle.len { - c += 1 - i = h - 1 - break - } else if h == haystack.len | haystack[h] != needle[n] { + if n == needle.len break + if haystack[i + n] != needle[n] { + matches = false break } + n += 1 } + + 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.") } @@ -162,9 +145,28 @@ left_trim := fn(str: []u8, sub: []u8): []u8 { loop if i == sub.len { return str[i..str.len] } else if str[i] != sub[i] | i == str.len { - return str + break } else { i += 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) } \ No newline at end of file diff --git a/sysdata/libraries/sunset_proto/src/client.hb b/sysdata/libraries/sunset_proto/src/client.hb index 981949b46..47294131b 100644 --- a/sysdata/libraries/sunset_proto/src/client.hb +++ b/sysdata/libraries/sunset_proto/src/client.hb @@ -1,16 +1,16 @@ -.{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") +.{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") // ! in the future this should be safely handled channel := Channel.(0, 0) find_server := fn(): void { - log.info("client: locating server\0") + log.info("client: locating server") channel2 := await_channel() channel.server = channel2.server channel.client = channel2.client - log.info("client: server located\0") + log.info("client: server located") } 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\0") + log.info("client: recv ack") 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\0") + log.info("client: recv windowdata") surface := Surface.new(windowdata.body.props.dimensions.x, windowdata.body.props.dimensions.y) return .(windowdata.body, surface) } diff --git a/sysdata/libraries/sunset_proto/src/lib.hb b/sysdata/libraries/sunset_proto/src/lib.hb index 9be50d85f..14960ec23 100644 --- a/sysdata/libraries/sunset_proto/src/lib.hb +++ b/sysdata/libraries/sunset_proto/src/lib.hb @@ -1,8 +1,8 @@ .{math: .{Vec2}, buffer, memory} := @use("stn"); -.{Surface} := @use("../../render/src/lib.hb") +.{Surface} := @use("lib:render") -$BUFFER_SERVER := "sunset_server\0" -$BUFFER_CLIENT := "sunset_client\0" +$BUFFER_SERVER := "sunset_server" +$BUFFER_CLIENT := "sunset_client" Channel := packed struct { client: uint, @@ -85,8 +85,7 @@ Message := fn($Expr: type): type { WindowProps := struct { position: Vec2(uint), dimensions: Vec2(uint), - // ! replace with owned string type later - title: ^u8, + title: []u8, } WindowData := struct { diff --git a/sysdata/libraries/sunset_proto/src/server.hb b/sysdata/libraries/sunset_proto/src/server.hb index d1e323133..c08241084 100644 --- a/sysdata/libraries/sunset_proto/src/server.hb +++ b/sysdata/libraries/sunset_proto/src/server.hb @@ -13,12 +13,12 @@ WindowServer := struct { // ! in the future this should be safely handled server := @as(WindowServer, idk) -psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf") +psf := @embed("sysdata: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\0") + log.error("server: failed to load asset") return } server = .( @@ -27,7 +27,7 @@ start := fn(): void { .[null, null, null, null, null, null, null, null, null, null], @as(text.Font, font), ) - log.info("server: started server\0") + log.info("server: started server") } incoming := fn(): bool { @@ -36,14 +36,14 @@ incoming := fn(): bool { return true } if msg.kind == message.syn { - log.info("server: recv syn\0") + log.info("server: recv syn") 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\0") + log.info("server: recv props") // ! do inspection of requested props here data := WindowData.(props.body, channel, permissions.default) send_message(WindowData, message.ack, data, channel.client) @@ -51,8 +51,7 @@ incoming := fn(): bool { // decorations { title := data.props.title - title_length := string.length(title) - deco_length := title_length * 10 + deco_length := title.len * 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 diff --git a/sysdata/programs/ablefetch/src/main.hb b/sysdata/programs/ablefetch/src/main.hb index ea7e38d11..103116441 100644 --- a/sysdata/programs/ablefetch/src/main.hb +++ b/sysdata/programs/ablefetch/src/main.hb @@ -1,28 +1,28 @@ -.{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") +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"); -horizon_api := @use("../../../libraries/horizon_api/src/lib.hb"); +.{Vec2} := stn.math; +.{log} := stn; .{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!\0")) + window := sunset.client.new(.(.(10, 10), .(400, 300), "ableFetch!")) font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false)) // pos := Vec2(uint).(1, 100) if window == null { - log.error("got no window\0") + log.error("got no window") return } - text_label := Label.new_label("kernel : akern 0.2.0\0", 300) - text_label_2 := Label.new_label("os : ableos\0", 300) - text_label_3 := Label.new_label("wm : sunset\0", 300) + 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_2.set_color(render.BLACK, render.WHITE) @@ -36,7 +36,7 @@ main := fn(): void { 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\0") + // stn.log.info("AAAA") _ = sunset.client.send_frame(window) // stn.sleep.sleep_until_interrupt(100) } diff --git a/sysdata/programs/angels_halo/src/main.hb b/sysdata/programs/angels_halo/src/main.hb index 30614894a..939de4f1e 100644 --- a/sysdata/programs/angels_halo/src/main.hb +++ b/sysdata/programs/angels_halo/src/main.hb @@ -12,7 +12,7 @@ MonitoredProcess := struct { } main := fn(): int { - log.info("Angels Halo reincarnation server started.\0") + log.info("Angels Halo reincarnation server started.") return 0 } \ No newline at end of file diff --git a/sysdata/programs/diskio_driver/src/main.hb b/sysdata/programs/diskio_driver/src/main.hb index c3194fa1d..4937c9600 100644 --- a/sysdata/programs/diskio_driver/src/main.hb +++ b/sysdata/programs/diskio_driver/src/main.hb @@ -1,4 +1,4 @@ -.{memory, buffer, log} := @use("../../../libraries/stn/src/lib.hb"); +.{memory, buffer, log} := @use("stn"); .{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.\0") +// log.info("Primary drive head set.") // 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.\0") +// log.info("Waiting for status.") // loop { // if (status & STAT_BSY) == 0 { -// log.info("Status got.\0") +// log.info("Status got.") // 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.\0") +// log.error("No drive detected.") // return 0 // } -// log.info("Status indicates presence of a drive. Polling while STAT_BSY... \0") +// log.info("Status indicates presence of a drive. Polling while STAT_BSY... ") // loop { // if (status & STAT_BSY) == 0 { -// log.info("Status got.\0") +// log.info("Status got.") // 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.)\0") +// log.error("The drive is not ATA. (Who knows what it is.)") // return 0 // } @@ -81,7 +81,7 @@ sloop := fn(i: u8): void { // } drive_reset := fn(): void { - log.warn("Drive resetting.\0") + log.warn("Drive resetting.") 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\0") + log.error("ATA PRIMARY DRIVE FAULT") return 1 } if (status & ATA_SR_ERR) == 0 { - log.error("ATA PRIMARY ERR\0") + log.error("ATA PRIMARY ERR") return 2 } if (status & ATA_SR_DRQ) == 0 { - log.error("ATA PRIMARY DRQ\0") + log.error("ATA PRIMARY DRQ") return 3 } @@ -124,7 +124,7 @@ main := fn(): int { a := inb(0x4600) b := inb(0x4700) - // c := buffer.search("XNumber\0") + // c := buffer.search("XNumber") // c := identify() d := drive_reset() diff --git a/sysdata/programs/filesystem_fat32/src/attributes.hb b/sysdata/programs/filesystem_fat32/src/attributes.hb index cd9dac66a..adb57aa99 100644 --- a/sysdata/programs/filesystem_fat32/src/attributes.hb +++ b/sysdata/programs/filesystem_fat32/src/attributes.hb @@ -1,7 +1,7 @@ -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) +$READ_ONLY := 0x1 +$HIDDEN := 0x2 +$SYSTEM := 0x4 +$VOLUME_ID := 0x8 +$DIRECTORY: 0x10 +$ARCHIVE := 0x20 LFN := READ_ONLY | HIDDEN | SYSTEM | VOLUME_ID \ No newline at end of file diff --git a/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb b/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb index 6a0d82472..00c08cde8 100644 --- a/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb +++ b/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb @@ -1,4 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{string, memory, buffer, log} := stn VALID_JUMP_BYTES := u8.[0xEB, 0x3C, 0x90] @@ -89,22 +89,22 @@ 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\0") + log.warn("EBR-Drive-Number sanity check failed") } if ebr.signature != 0x28 | ebr.signature != 0x29 { - log.warn("EBR-Signature sanity check failed\0") + log.warn("EBR-Signature sanity check failed") } // ! 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\0") + // log.warn("EBR-Signature-Identifier-String sanity check failed") // } return 0 } new := fn(): ExtendedBootRecord { - version := u8.[0, 0] + 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) @@ -146,19 +146,19 @@ FSInfo := struct { ret := 0 if fs_info.lead_signature != VALID_LEAD_FS_INFO { ret &= 1 - log.warn("Invalid leading signature in FSInfo.\0") + log.warn("Invalid leading signature in FSInfo.") } if fs_info.last_known_free_cluster_count == 0xFFFFFFFF { ret &= 2 - log.warn("Last known free cluster count unknown.\0") + log.warn("Last known free cluster count unknown.") } if fs_info.last_known_avalible_cluster == 0xFFFFFFFF { ret &= 4 - log.warn("Last known avalible cluster count unknown.\0") + log.warn("Last known avalible cluster count unknown.") } if fs_info.trail_signature != VALID_TRAIL_FS_INFO { ret &= 8 - log.warn("Invalid trailing signature in FSInfo.\0") + log.warn("Invalid trailing signature in FSInfo.") } return ret @@ -176,4 +176,4 @@ FSInfo := struct { VALID_TRAIL_FS_INFO, ) } -} +} \ No newline at end of file diff --git a/sysdata/programs/filesystem_fat32/src/main.hb b/sysdata/programs/filesystem_fat32/src/main.hb index 711720084..ee0a23e9e 100644 --- a/sysdata/programs/filesystem_fat32/src/main.hb +++ b/sysdata/programs/filesystem_fat32/src/main.hb @@ -1,4 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{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.\0") + log.warn("filesystem_fat32 driver only supports Fat32.") } 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\0" + file_path := "node-disk:/test" } else { // error } diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index 7ccd0bd4b..59d440e6e 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -1,16 +1,16 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{string, memory, buffer, random, log} := stn; .{Vec2} := stn.math -horizon_api := @use("../../../libraries/horizon_api/src/lib.hb"); +horizon_api := @use("lib:horizon_api"); .{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets.label; .{sexpr_parser, render_ui} := horizon_api.ui -render := @use("../../../libraries/render/src/lib.hb"); +render := @use("lib:render"); .{Surface} := render; .{Font} := render.text -intouch := @use("../../../libraries/intouch/src/lib.hb") +intouch := @use("lib:intouch") Window := struct { // TODO: Replace this with widgets @@ -21,23 +21,23 @@ Window := struct { y: int, } -psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf") -img := @embed("../../../assets/wallpaper.qoi") +psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf") +img := @embed("sysdata:assets/wallpaper.qoi") main := fn(): int { - win_buff := buffer.create("XHorizon\0") + win_buff := buffer.create("XHorizon") screen := render.init(true) // Clear the screen to black. - render.clear(screen, render.black) + screen.clear(render.BLACK) wallpaper := render.image.from(@bitcast(&img)) if wallpaper == null { return 1 } - window := render.new_surface(screen.width / 3, screen.height / 3) + window := render.Surface.new(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\0") + text_label := new_label("Hi") - // widgets := "()\0" + // widgets := "()" // ui := sexpr_parser(widgets) loop { // Clear the screen - render.clear(screen, render.black) + screen.clear(render.BLACK) - render.put_surface(screen, wallpaper, .(0, 0), false) + screen.put_surface(wallpaper, .(0, 0), false) // TODO: Read the window buffer here { @@ -65,33 +65,33 @@ main := fn(): int { if false { // Scroll bar :ThumbsUp: - render.put_rect(screen, .(100, 100), .(100, 10), render.white) - render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white) + screen.put_rect(.(100, 100), .(100, 10), render.WHITE) + screen.put_filled_rect(.(110, 100), .(20, 10), render.WHITE) - render.put_rect(screen, .(90, 110), .(10, 100), render.white) - render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white) + screen.put_rect(.(90, 110), .(10, 100), render.WHITE) + screen.put_filled_rect(.(90, 120), .(10, 20), render.WHITE) } { // osu dots - render.put_rect(screen, .(400, 100), .(100, 100), render.red) - render.put_rect(screen, .(100, 100 + 300), .(100, 100), render.red) + screen.put_rect(.(400, 100), .(100, 100), render.RED) + screen.put_rect(.(100, 100 + 300), .(100, 100), render.RED) } { pos := Vec2(uint).(1, screen.height - 21) render_label_to_surface(screen, text_label, font, pos) - render.put_rect(screen, .(0, screen.height - 21), .(screen.width - 1, 20), render.white) + screen.put_rect(.(0, screen.height - 21), .(screen.width - 1, 20), render.WHITE) } // Screen border - render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) + screen.put_rect(.(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 \0") + log.info("Key event ") } } @@ -100,7 +100,7 @@ main := fn(): int { // if mouse_event != null { - // log.warn("Mouse event received\0") + // log.warn("Mouse event received") 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\0") + set_label_text(text_label, "LEFT CLICK") } if mouse_event.middle { - set_label_text(text_label, "MIDDLE CLICK\0") + set_label_text(text_label, "MIDDLE CLICK") } if mouse_event.right { - set_label_text(text_label, "RIGHT CLICK\0") + set_label_text(text_label, "RIGHT CLICK") } } - 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) + screen.put_filled_rect(.(mouse_x, mouse_y), .(20, 20), render.BLACK) + screen.put_rect(.(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 - render.sync(screen) + screen.sync() } return 0 diff --git a/sysdata/programs/horizon_testing_program/src/main.hb b/sysdata/programs/horizon_testing_program/src/main.hb index d5b6362d6..b3a13de0f 100644 --- a/sysdata/programs/horizon_testing_program/src/main.hb +++ b/sysdata/programs/horizon_testing_program/src/main.hb @@ -1,25 +1,25 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{string, memory, buffer, log} := stn -horizon_api := @use("../../../libraries/horizon_api/src/lib.hb"); +horizon_api := @use("lib:horizon_api"); .{create_window} := horizon_api -ignim := @use("../../../libraries/ignim/src/lib.hb"); +ignim := @use("lib:ignim"); .{errors} := ignim -psf := @embed("../../../consolefonts/tamsyn/10x20r.psf") +psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf") main := fn(): int { x := 0 // loop if x > 10000 break else x += 1 - windowing_system_buffer := buffer.search("XHorizon\0") + windowing_system_buffer := buffer.search("XHorizon") // TODO: get WindowID wid := create_window(windowing_system_buffer) if false { - program_name := "Horizon Testing Program\0" + program_name := "Horizon Testing Program" program_version := ignim.version.make_version(0, 1, 0) - engine_name := "None\0" + engine_name := "None" 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\0") + log.error("Driver Incompatible with Vulkan") } } diff --git a/sysdata/programs/pcspkr/src/main.hb b/sysdata/programs/pcspkr/src/main.hb index 5c5055cbf..20aa18ecd 100644 --- a/sysdata/programs/pcspkr/src/main.hb +++ b/sysdata/programs/pcspkr/src/main.hb @@ -1,4 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{memory, buffer, log, string, math} := stn; .{inb, outb} := memory diff --git a/sysdata/programs/ps2_driver/src/controller.hb b/sysdata/programs/ps2_driver/src/controller.hb index 497b46079..bb98306a5 100644 --- a/sysdata/programs/ps2_driver/src/controller.hb +++ b/sysdata/programs/ps2_driver/src/controller.hb @@ -1,4 +1,4 @@ -.{memory, log} := @use("../../../libraries/stn/src/lib.hb"); +.{memory, log} := @use("stn"); .{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!\0") + log.error("No ports detected! No input will be processed! Cannot handle this!") } if port1.exists { - log.info("Port 1 exists.\0") + log.info("Port 1 exists.") enable_port1() } if port2.exists { - log.info("Port 2 exists.\0") + log.info("Port 2 exists.") enable_port2() } } \ No newline at end of file diff --git a/sysdata/programs/ps2_driver/src/main.hb b/sysdata/programs/ps2_driver/src/main.hb index b07c9c3c5..ea159e6f1 100644 --- a/sysdata/programs/ps2_driver/src/main.hb +++ b/sysdata/programs/ps2_driver/src/main.hb @@ -1,5 +1,5 @@ -.{memory, log, buffer, string} := @use("../../../libraries/stn/src/lib.hb"); -.{MouseEvent} := @use("../../../libraries/intouch/src/lib.hb").events; +.{memory, log, buffer, string} := @use("stn"); +.{MouseEvent} := @use("lib:intouch").events; .{bit0, bit1, bit2, bit3, bit4} := @use("bits.hb") devices := @use("devices.hb") controller := @use("controller.hb"); @@ -71,10 +71,10 @@ process := fn(port: ^controller.Port): void { port.device.value = port.packet[1] | port.packet[0] << 8 enable_streaming(port) } - log.info("Identified device!\0") + log.info("Identified device!") log.print(port.device.value, .{radix: 16}) } else { - log.info("KEY PRESSED\0") + log.info("KEY PRESSED") } } @@ -107,12 +107,12 @@ check_complete := fn(port: ^controller.Port): bool { } main := fn(): void { - mouse_buffer = buffer.create("PS/2 Mouse\0") + mouse_buffer = buffer.create("PS/2 Mouse") controller.init() if controller.port1.exists { - //log.info("Port 1 exists.\0") + //log.info("Port 1 exists.") controller.send_byte(@bitcast(0), 0xF4) } if controller.port2.exists { @@ -123,10 +123,10 @@ main := fn(): void { info = controller.get_info() if controller.timed_out(info) { - log.error("Timeout error! Cannot handle these!\0") + log.error("Timeout error! Cannot handle these!") } if controller.check_parity(info) { - log.error("Parity error! Cannot handle these!\0") + log.error("Parity error! Cannot handle these!") } /* if controller.has_input(info) { diff --git a/sysdata/programs/ps2_mouse_driver/src/main.hb b/sysdata/programs/ps2_mouse_driver/src/main.hb index 1faa4171d..59a6d6d1d 100644 --- a/sysdata/programs/ps2_mouse_driver/src/main.hb +++ b/sysdata/programs/ps2_mouse_driver/src/main.hb @@ -1,7 +1,7 @@ -.{memory, buffer, log, string, math} := @use("../../../libraries/stn/src/lib.hb") +.{memory, buffer, log, string, math} := @use("stn") Vec2 := math.Vec2 -intouch := @use("../../../libraries/intouch/src/lib.hb"); +intouch := @use("lib:intouch"); .{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.\0") + log.info("Self check passed.") 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\0") + mouse_buffer := buffer.create("PS/2 Mouse") format_page := memory.alloc(u8, 1024) send_byte(0x64, 0xA8) - log.info("Aux mouse device enabled.\0") + log.info("Aux mouse device enabled.") 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!\0") + log.info("Mouse plugged in!") set_up_mouse() continue } diff --git a/sysdata/programs/pumpkin_print/src/main.hb b/sysdata/programs/pumpkin_print/src/main.hb index a047fd1f7..914e9a755 100644 --- a/sysdata/programs/pumpkin_print/src/main.hb +++ b/sysdata/programs/pumpkin_print/src/main.hb @@ -1,4 +1,4 @@ -stn := @use("../../../libraries/stn/src/lib.hb") +stn := @use("stn") main := fn(): int { stn.log.info("\r @@ -9,7 +9,7 @@ main := fn(): int { | : '=.:.=' : |\r | : :'.___.': : |\r '-:__:__:__:__:-'\r - \0") + ") return 0 } \ No newline at end of file diff --git a/sysdata/programs/render_example/src/examples/image.hb b/sysdata/programs/render_example/src/examples/image.hb index da9d402fe..fc3f74543 100644 --- a/sysdata/programs/render_example/src/examples/image.hb +++ b/sysdata/programs/render_example/src/examples/image.hb @@ -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\0") + log.error("failed to load images for whatever reason") return } diff --git a/sysdata/programs/render_example/src/examples/mandelbrot.hb b/sysdata/programs/render_example/src/examples/mandelbrot.hb index 0946ed1a4..a9f6460a5 100644 --- a/sysdata/programs/render_example/src/examples/mandelbrot.hb +++ b/sysdata/programs/render_example/src/examples/mandelbrot.hb @@ -32,9 +32,9 @@ example := fn(): void { window := @as(?sunset.Window, null) if USE_SUNSET { sunset.client.find_server() - window = sunset.client.new(.(.(450, 140), .(400, 400), "Mandelbrot Set\0")) + window = sunset.client.new(.(.(450, 140), .(400, 400), "Mandelbrot Set")) if window == null { - log.error("got no window\0") + log.error("got no window") return } screen = window.surface diff --git a/sysdata/programs/render_example/src/examples/random.hb b/sysdata/programs/render_example/src/examples/random.hb index d79df449d..f55c0624d 100644 --- a/sysdata/programs/render_example/src/examples/random.hb +++ b/sysdata/programs/render_example/src/examples/random.hb @@ -1,5 +1,5 @@ -.{random} := @use("../../../../libraries/stn/src/lib.hb") -render := @use("../../../../libraries/render/src/lib.hb") +.{random} := @use("stn") +render := @use("lib:render") example := fn(): void { screen := render.init(false) diff --git a/sysdata/programs/render_example/src/examples/text.hb b/sysdata/programs/render_example/src/examples/text.hb index 67db90199..b06a55bfe 100644 --- a/sysdata/programs/render_example/src/examples/text.hb +++ b/sysdata/programs/render_example/src/examples/text.hb @@ -39,7 +39,7 @@ example := fn(): void { return } - msg := "sticky note:\n\0" + msg := "sticky note:\n" msg_len := string.length(msg) buf := memory.alloc(u8, 4096) diff --git a/sysdata/programs/rtc_driver/src/main.hb b/sysdata/programs/rtc_driver/src/main.hb index cac7f945d..825bab508 100644 --- a/sysdata/programs/rtc_driver/src/main.hb +++ b/sysdata/programs/rtc_driver/src/main.hb @@ -1,11 +1,11 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{sleep, log, memory} := stn main := fn(): int { loop { - log.info("BEFORE\0") + log.info("BEFORE") sleep.sleep_until_interrupt(8) - log.info("AFTER\0") + log.info("AFTER") } return 0 diff --git a/sysdata/programs/sdoom/src/main.hb b/sysdata/programs/sdoom/src/main.hb index 22aebc7ba..189900d69 100644 --- a/sysdata/programs/sdoom/src/main.hb +++ b/sysdata/programs/sdoom/src/main.hb @@ -1,7 +1,7 @@ -sunset := @use("../../../libraries/sunset_proto/src/lib.hb") -render := @use("../../../libraries/render/src/lib.hb") +sunset := @use("lib:sunset_proto") +render := @use("lib:render") -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{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\0")) + window := sunset.client.new(.(.(600, 400), .(200, 200), "SDoom")) if window == null { - log.error("got no window\0") + log.error("got no window") return } game_state := GameState.new() loop { - render.clear(window.surface, render.black) + window.surface.clear(render.BLACK) width := 100 idx := 1 @@ -44,7 +44,7 @@ main := fn(): void { if idx >= width { break } - render.put_vline(window.surface, idx, 10, 100, render.white) + window.surface.put_vline(idx, 10, 100, render.WHITE) idx += 1 } diff --git a/sysdata/programs/serial_driver/src/main.hb b/sysdata/programs/serial_driver/src/main.hb index 513436349..a754547ca 100644 --- a/sysdata/programs/serial_driver/src/main.hb +++ b/sysdata/programs/serial_driver/src/main.hb @@ -1,17 +1,18 @@ -.{memory, buffer} := @use("../../../libraries/stn/src/lib.hb") +.{memory, buffer} := @use("stn") -serial_print := fn(ptr: ^u8): void { +serial_print := fn(str: []u8): void { letter := @as(u8, 0) - loop if *ptr == 0 break else { - letter = *ptr + i := 0 + loop if i == str.len break else { + letter = str[i] memory.outb(0xF803, letter) - ptr += 1 + i += 1 } return } -serial_println := fn(ptr: ^u8): void { - serial_print(ptr) +serial_println := fn(str: []u8): void { + serial_print(str) memory.outb(0xF803, 12) memory.outb(0xF803, 13) return @@ -19,28 +20,28 @@ serial_println := fn(ptr: ^u8): void { main := fn(): int { // This must be done first and foremost to prevent racing - a := buffer.create("XNumber\0") - serial_println("Starting Serial Driver.\0") + a := buffer.create("XNumber") + serial_println("Starting Serial Driver.") - mem := memory.request_page(1) + mem := memory.request_page(1)[1..memory.PAGE_SIZE] loop { ptr := @as(^u8, @eca(4, a, mem, 0x1000)) if ptr == 0 { - serial_println("No message\0") + serial_println("No message") } if ptr > 0 { - serial_println("Yes message\0") + serial_println("Yes message") serial_println(mem) break } } // Note that the first byte is reserved, pad accordingly. - b := buffer.search("XNumber\0") + b := buffer.search("XNumber") if a == b { - serial_println("Stopping Serial Driver.\0") + serial_println("Stopping Serial Driver.") } return 0 diff --git a/sysdata/programs/sunset_client/src/main.hb b/sysdata/programs/sunset_client/src/main.hb index b1498521f..ca3894c8e 100644 --- a/sysdata/programs/sunset_client/src/main.hb +++ b/sysdata/programs/sunset_client/src/main.hb @@ -1,29 +1,29 @@ -.{log} := @use("../../../libraries/stn/src/lib.hb") -sunset := @use("../../../libraries/sunset_proto/src/lib.hb") -render := @use("../../../libraries/render/src/lib.hb") +.{log} := @use("stn") +sunset := @use("lib:sunset_proto") +render := @use("lib:render") -bmp := @embed("../../../assets/mini.bmp") +bmp := @embed("sysdata: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\0") + log.error("got no image") return } - window := sunset.client.new(.(.(400, 400), .(200, 200), "Hello\0")) + window := sunset.client.new(.(.(400, 400), .(200, 200), "Hello")) if window == null { - log.error("got no window\0") + log.error("got no window") return } x := 0 loop { - screen.clear(window.surface, render.BLACK) - render.put_surface(window.surface, image, .(image.width + x % window.data.props.dimensions.x, 20), false) + window.surface.clear(render.BLACK) + window.surface.put_surface(image, .(image.width + x % window.data.props.dimensions.x, 20), false) _ = sunset.client.send_frame(window) x += 1 } -} +} \ No newline at end of file diff --git a/sysdata/programs/sunset_client_2/meta.toml b/sysdata/programs/sunset_client_2/meta.toml deleted file mode 100644 index 399214f03..000000000 --- a/sysdata/programs/sunset_client_2/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "sunset_client_2" -authors = ["koniifer"] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/sunset_client_2/src/main.hb b/sysdata/programs/sunset_client_2/src/main.hb deleted file mode 100644 index fa4625f7f..000000000 --- a/sysdata/programs/sunset_client_2/src/main.hb +++ /dev/null @@ -1,29 +0,0 @@ -.{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/mini.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(.(.(100, 350), .(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 - } -} \ No newline at end of file diff --git a/sysdata/programs/sunset_server/src/main.hb b/sysdata/programs/sunset_server/src/main.hb index 5b3e19163..cbab955a4 100644 --- a/sysdata/programs/sunset_server/src/main.hb +++ b/sysdata/programs/sunset_server/src/main.hb @@ -38,7 +38,7 @@ Mouse := struct { main := fn(): int { sunset.server.start() defer { - stn.log.info("Sunset Server Exit\0") + stn.log.info("Sunset Server Exit") } screen := render.init(true) @@ -47,7 +47,7 @@ main := fn(): int { wallpaper := render.image.from(@bitcast(&img)) if wallpaper == null { - // stn.panic("Wallpaper not loaded\0") + // stn.panic("Wallpaper not loaded") return 1 } @@ -57,7 +57,7 @@ main := fn(): int { mouse := Mouse.new(screen.width, screen.height) //mouse.center() - text_label := Label.new_label("\0", 1024) + text_label := Label.new_label("", 1024) text_label.set_color(sunset.server.DECO_COLOUR, render.BLACK) loop { @@ -88,13 +88,13 @@ main := fn(): int { } if mouse_event.left { - text_label.set_label_text("LEFT CLICK\0") + text_label.set_label_text("LEFT CLICK") } if mouse_event.middle { - text_label.set_label_text("MIDDLE CLICK\0") + text_label.set_label_text("MIDDLE CLICK") } if mouse_event.right { - text_label.set_label_text("RIGHT CLICK\0") + text_label.set_label_text("RIGHT CLICK") } } { diff --git a/sysdata/programs/svga_driver/src/device.hb b/sysdata/programs/svga_driver/src/device.hb index 741d9e4a5..3126a3e7b 100644 --- a/sysdata/programs/svga_driver/src/device.hb +++ b/sysdata/programs/svga_driver/src/device.hb @@ -1,7 +1,7 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{string, memory, buffer, log} := stn -pci := @use("../../../libraries/pci/src/lib.hb"); +pci := @use("lib:pci"); .{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\0") + log.error("SVGA device not found") 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\0") + log.info("SVGA device initialized successfully") 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\0") + log.info("Framebuffer setup complete") return } diff --git a/sysdata/programs/svga_driver/src/main.hb b/sysdata/programs/svga_driver/src/main.hb index dbf24312e..9f70ee854 100644 --- a/sysdata/programs/svga_driver/src/main.hb +++ b/sysdata/programs/svga_driver/src/main.hb @@ -1,7 +1,7 @@ device := @use("device.hb") -pci := @use("../../../libraries/pci/src/lib.hb") +pci := @use("lib:pci") -stn := @use("../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{string, memory, buffer, log} := stn reg := @use("reg.hb") diff --git a/sysdata/programs/tempfs/src/main.hb b/sysdata/programs/tempfs/src/main.hb index 55ef42e3b..5cd186f40 100644 --- a/sysdata/programs/tempfs/src/main.hb +++ b/sysdata/programs/tempfs/src/main.hb @@ -1,8 +1,8 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -.{sleep} := stn +stn := @use("stn"); +.{sleep, buffer} := stn main := fn(): int { - tmpfs_buffer := buffer.create("TmpFS\0") + tmpfs_buffer := buffer.create("TmpFS") loop { // TODO // sleep.sleep_until_buffer(tmpfs_buffer) diff --git a/sysdata/programs/test/src/tests/serial_driver.hb b/sysdata/programs/test/src/tests/serial_driver.hb index 8e27b11d0..e5e338b53 100644 --- a/sysdata/programs/test/src/tests/serial_driver.hb +++ b/sysdata/programs/test/src/tests/serial_driver.hb @@ -1,10 +1,10 @@ -.{string, buffer} := @use("../../../../libraries/stn/src/lib.hb") +.{string, buffer} := @use("stn") log_info := fn(): void { - a := buffer.search("XNumber\0") + a := buffer.search("XNumber") if a == 0 { } else { - msg := "XABC\0" + msg := "XABC" msg_length := string.length(msg) @eca(3, a, msg, msg_length) } diff --git a/sysdata/programs/test/src/tests/stn/allocators.hb b/sysdata/programs/test/src/tests/stn/allocators.hb index ac23ef33f..c1452d30f 100644 --- a/sysdata/programs/test/src/tests/stn/allocators.hb +++ b/sysdata/programs/test/src/tests/stn/allocators.hb @@ -1,4 +1,4 @@ -stn := @use("../../../../../libraries/stn/src/lib.hb"); +stn := @use("stn"); .{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\0") + log.info("Hi") // panic.panic("BlockAlloc actually didn't allocate.") } else { - log.info("Allocator functioned.\0") + log.info("Allocator functioned.") } balloc.dealloc(&bstruct.ptr, AStruct, 2) return 0 diff --git a/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hb b/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hb index 2d75c6b2d..e8d4c92fc 100644 --- a/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hb +++ b/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hb @@ -1,7 +1,7 @@ -.{log} := @use("../../../libraries/stn/src/lib.hb") +.{log, sleep} := @use("stn") main := fn(): void { - log.info("Hello, World!\0") - loop { - } + log.info("Hello, World!") + // fake interrupt, sleep forever + sleep.sleep_until_interrupt(100) } \ No newline at end of file diff --git a/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hbf b/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hbf index 0a7f0e8d2..48b140214 100644 Binary files a/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hbf and b/sysdata/programs/test/src/tests/stn/assets/hello_world_and_spin.hbf differ diff --git a/sysdata/programs/test/src/tests/stn/dt.hb b/sysdata/programs/test/src/tests/stn/dt.hb index b536c9b2a..d994adbef 100644 --- a/sysdata/programs/test/src/tests/stn/dt.hb +++ b/sysdata/programs/test/src/tests/stn/dt.hb @@ -1,15 +1,15 @@ .{dt, log} := @use("stn") test := fn(): uint { - log.print(dt.get(int, "framebuffer/fb0/width\0"), .{}) - log.print(dt.get(int, "framebuffer/fb0/height\0"), .{}) - log.print(dt.get(^uint, "framebuffer/fb0/ptr\0"), .{}) - log.print(dt.get(int, "cpu/cpu0/architecture\0"), .{}) + 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"), .{}) // 0 -> memory mapped // 1 -> port mapped - log.print(dt.get(int, "serial_ports/sp0/mapping\0"), .{}) + log.print(dt.get(int, "serial_ports/sp0/mapping"), .{}) return 0 } \ No newline at end of file diff --git a/sysdata/programs/test/src/tests/stn/hashers.hb b/sysdata/programs/test/src/tests/stn/hashers.hb index 40e0bb008..5c6592510 100644 --- a/sysdata/programs/test/src/tests/stn/hashers.hb +++ b/sysdata/programs/test/src/tests/stn/hashers.hb @@ -21,6 +21,5 @@ test := fn(): uint { d := hasher.finish() log.printf("matches: {}, string: {}, hash: {}", .(d == correct, strings[i], d), .{radix: 16}) } - log.print("done", .{}) return 0 -} +} \ No newline at end of file diff --git a/sysdata/programs/test/src/tests/stn/process.hb b/sysdata/programs/test/src/tests/stn/process.hb index 493e36a71..b08a1c45e 100644 --- a/sysdata/programs/test/src/tests/stn/process.hb +++ b/sysdata/programs/test/src/tests/stn/process.hb @@ -1,20 +1,13 @@ -.{process, log, string, memory} := @use("../../../../../libraries/stn/src/lib.hb") +.{process, log} := @use("stn") exe := @embed("./assets/hello_world_and_spin.hbf") test := fn(): uint { - buf := "\0\0\0\0\0\0\0" loop { - log.info( - string.display_int( - @bitcast(process.spawn(@bitcast(&exe), 356)), - buf, - 10, - ), - ) + log.print(process.spawn(@bitcast(&exe), 356), .{}) // spin so we don't spawn 10 quattuordecillion processes i := 0 - loop if i == 1000000 break else i += 1 + loop if i == 20000000 break else i += 1 } return 0 } \ No newline at end of file diff --git a/sysdata/programs/test/src/tests/stn/sleep.hb b/sysdata/programs/test/src/tests/stn/sleep.hb index 9eaeb31df..aea5a1c60 100644 --- a/sysdata/programs/test/src/tests/stn/sleep.hb +++ b/sysdata/programs/test/src/tests/stn/sleep.hb @@ -1,8 +1,8 @@ -.{sleep, log} := @use("../../../../../libraries/stn/src/lib.hb") +.{sleep, log} := @use("stn") test := fn(): uint { - log.info("BEFORE\0") + log.info("BEFORE") sleep.sleep_until_interrupt(32) - log.info("AFTER\0") + log.info("AFTER") return 0 } \ No newline at end of file diff --git a/sysdata/programs/vfsaur/src/main.hb b/sysdata/programs/vfsaur/src/main.hb index aa031f2fd..a15d7fb78 100644 --- a/sysdata/programs/vfsaur/src/main.hb +++ b/sysdata/programs/vfsaur/src/main.hb @@ -63,8 +63,5 @@ parse_str_to_path := fn(full_path: []u8): ?Path { if path == null { return null } - root := full_path[..full_path.len - path.len] - bpath := full_path[full_path.len - path.len + 1..] - - return Path.(root, bpath) + return Path.(path.left, path.right) } \ No newline at end of file