forked from AbleOS/ableos
code churn to save the universe
This commit is contained in:
parent
5659ae1d0a
commit
82382d2a99
|
@ -9,18 +9,18 @@ widgets := @use("widgets/widgets.hb")
|
||||||
ui := @use("ui.hb")
|
ui := @use("ui.hb")
|
||||||
|
|
||||||
WindowID := struct {
|
WindowID := struct {
|
||||||
host_id: int,
|
host_id: uint,
|
||||||
window_id: int,
|
window_id: uint,
|
||||||
}
|
}
|
||||||
|
|
||||||
VoidWindowID := WindowID.(0, 0)
|
VoidWindowID := WindowID.(0, 0)
|
||||||
|
|
||||||
create_window := fn(channel: int): ^render.Surface {
|
create_window := fn(channel: uint): ^render.Surface {
|
||||||
// get the horizon buffer
|
// get the horizon buffer
|
||||||
// request a new window and provide the callback buffer
|
// request a new window and provide the callback buffer
|
||||||
// wait to recieve a message
|
// wait to recieve a message
|
||||||
|
|
||||||
windowing_system_buffer := buffer.search("XHorizon\0")
|
windowing_system_buffer := buffer.search("XHorizon")
|
||||||
mem_buf := memory.request_page(1)
|
mem_buf := memory.request_page(1)
|
||||||
|
|
||||||
if windowing_system_buffer == 0 {
|
if windowing_system_buffer == 0 {
|
||||||
|
@ -31,11 +31,11 @@ create_window := fn(channel: int): ^render.Surface {
|
||||||
|
|
||||||
ret := buffer.recv([4096]u8, windowing_system_buffer, mem_buf)
|
ret := buffer.recv([4096]u8, windowing_system_buffer, mem_buf)
|
||||||
if ret == null {
|
if ret == null {
|
||||||
log.info("No messages\0")
|
log.info("No messages")
|
||||||
}
|
}
|
||||||
|
|
||||||
if *mem_buf == 0 {
|
if *mem_buf == 0 {
|
||||||
log.info("No messages\0")
|
log.info("No messages")
|
||||||
}
|
}
|
||||||
|
|
||||||
return @as(^render.Surface, idk)
|
return @as(^render.Surface, idk)
|
||||||
|
|
|
@ -6,7 +6,7 @@ render := @use("../../../libraries/render/src/lib.hb");
|
||||||
.{Surface} := render;
|
.{Surface} := render;
|
||||||
.{Font} := render.text
|
.{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,
|
// children: ^^u8,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,29 +19,26 @@ render_ui := fn(surface: Surface, ui: UI): void {
|
||||||
render.put_surface(surface, ui.surface, pos, false)
|
render.put_surface(surface, ui.surface, pos, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
sexpr_parser := fn(sexpr: ^u8): UI {
|
sexpr_parser := fn(sexpr: []u8): UI {
|
||||||
cursor := sexpr
|
i := 0
|
||||||
paren_balance := 0
|
paren_balance := 0
|
||||||
loop {
|
loop {
|
||||||
if *cursor == 0 {
|
if i == sexpr.len {
|
||||||
if paren_balance != 0 {
|
if paren_balance != 0 {
|
||||||
log.error("Unbalanced Parens\0")
|
log.error("Unbalanced Parens")
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
} else if *cursor == 40 {
|
} else if sexpr[i] == '(' {
|
||||||
log.info("Open paren\0")
|
log.info("Open paren")
|
||||||
paren_balance += 1
|
paren_balance += 1
|
||||||
} else if *cursor == 41 {
|
} else if sexpr[i] == ')' {
|
||||||
log.info("Closed paren\0")
|
log.info("Closed paren")
|
||||||
paren_balance -= 1
|
paren_balance -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor += 1
|
i += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
length := string.length(sexpr)
|
|
||||||
|
|
||||||
ui_surface := render.new_surface(100, 100)
|
ui_surface := render.new_surface(100, 100)
|
||||||
|
return UI.(sexpr, true, ui_surface)
|
||||||
return UI.(sexpr, length, true, ui_surface)
|
|
||||||
}
|
}
|
|
@ -10,27 +10,22 @@ Label := struct {
|
||||||
magic: uint,
|
magic: uint,
|
||||||
is_dirty: bool,
|
is_dirty: bool,
|
||||||
surface: Surface,
|
surface: Surface,
|
||||||
text: ^u8,
|
text: []u8,
|
||||||
text_length: uint,
|
|
||||||
bg: Color,
|
bg: Color,
|
||||||
fg: 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_surface := render.Surface.new(width, 20)
|
||||||
text_length := string.length(text)
|
label := Self.(3, true, text_surface, text, render.BLACK, render.WHITE)
|
||||||
label := Self.(3, true, text_surface, text, text_length, render.BLACK, render.WHITE)
|
|
||||||
return label
|
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.is_dirty = true
|
||||||
self.text = text
|
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.bg = bg
|
||||||
self.fg = fg
|
self.fg = fg
|
||||||
self.is_dirty = true
|
self.is_dirty = true
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("../../stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{log, buffer, memory} := stn
|
.{log, buffer, memory} := stn
|
||||||
keycodes := @use("keycodes.hb")
|
keycodes := @use("keycodes.hb")
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ events := @use("events.hb");
|
||||||
recieve_key_event := fn(): ?KeyEvent {
|
recieve_key_event := fn(): ?KeyEvent {
|
||||||
kevent := KeyEvent.(false, false, 0)
|
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
|
// Read out of the Keyboard buffer here
|
||||||
buffer.recv(KeyEvent, buf_id, &kevent)
|
buffer.recv(KeyEvent, buf_id, &kevent)
|
||||||
|
@ -23,7 +23,7 @@ recieve_key_event := fn(): ?KeyEvent {
|
||||||
recieve_mouse_event := fn(): ?MouseEvent {
|
recieve_mouse_event := fn(): ?MouseEvent {
|
||||||
mevent := MouseEvent.(0, 0, false, false, false)
|
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
|
// Read out of the Mouse buffer here
|
||||||
buffer.recv(MouseEvent, buf_id, &mevent)
|
buffer.recv(MouseEvent, buf_id, &mevent)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{string, memory, buffer, log} := @use("../../stn/src/lib.hb")
|
.{string, memory, buffer, log} := @use("stn")
|
||||||
|
|
||||||
PCIAddress := struct {
|
PCIAddress := struct {
|
||||||
bus: u8,
|
bus: u8,
|
||||||
|
@ -51,9 +51,9 @@ check_device := fn(bus: u8, device: u8): PciDeviceInfo {
|
||||||
pci_id := get_ids(bus, device, 0)
|
pci_id := get_ids(bus, device, 0)
|
||||||
|
|
||||||
if pci_id.vendor == 0xFFFF {
|
if pci_id.vendor == 0xFFFF {
|
||||||
log.warn(":|\0")
|
log.warn(":|")
|
||||||
} else {
|
} else {
|
||||||
log.info(":)\0")
|
log.info(":)")
|
||||||
}
|
}
|
||||||
address := calculate_address(bus, device, 0, 0x8)
|
address := calculate_address(bus, device, 0, 0x8)
|
||||||
reg2 := config_read32(bus, device, 0, 0x8)
|
reg2 := config_read32(bus, device, 0, 0x8)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.{Color, Surface, new_surface, put_surface} := @use("../lib.hb");
|
.{Color, Surface, new_surface, put_surface} := @use("lib:render");
|
||||||
.{log} := @use("../../../stn/src/lib.hb")
|
.{log} := @use("stn")
|
||||||
|
|
||||||
BitmapFileHeader := packed struct {
|
BitmapFileHeader := packed struct {
|
||||||
magic: u16,
|
magic: u16,
|
||||||
|
@ -37,7 +37,7 @@ from := fn(bmp: ^u8): ?Surface {
|
||||||
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
|
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
|
||||||
|
|
||||||
if file_header.magic != 0x4D42 | info_header.width == 0 | info_header.height == 0 {
|
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
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.{log} := @use("../../../stn/src/lib.hb");
|
.{log} := @use("stn");
|
||||||
.{Surface} := @use("../lib.hb")
|
.{Surface} := @use("lib:render")
|
||||||
bmp := @use("bmp.hb")
|
bmp := @use("bmp.hb")
|
||||||
qoi := @use("qoi.hb")
|
qoi := @use("qoi.hb")
|
||||||
$BMP := 0x4D42
|
$BMP := 0x4D42
|
||||||
|
@ -19,7 +19,7 @@ from := fn(file: ^u8): ?Surface {
|
||||||
format := get_format(file)
|
format := get_format(file)
|
||||||
|
|
||||||
if format == null {
|
if format == null {
|
||||||
log.error("Could not detect image format.\0")
|
log.error("Could not detect image format.")
|
||||||
return null
|
return null
|
||||||
} else if format == BMP {
|
} else if format == BMP {
|
||||||
return bmp.from(file)
|
return bmp.from(file)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.{Color, Surface, new_surface} := @use("../lib.hb");
|
.{Color, Surface, new_surface} := @use("lib:render");
|
||||||
.{log} := @use("../../../stn/src/lib.hb")
|
.{log} := @use("stn")
|
||||||
|
|
||||||
/* source:
|
/* source:
|
||||||
https://github.com/phoboslab/qoi/blob/master/qoi.h */
|
https://github.com/phoboslab/qoi/blob/master/qoi.h */
|
||||||
|
@ -40,7 +40,7 @@ from := fn(qoi: ^u8): ?Surface {
|
||||||
height := be_to_le(header.height)
|
height := be_to_le(header.height)
|
||||||
|
|
||||||
if be_to_le(header.magic) != QOI_MAGIC | width == 0 | height == 0 | header.channels < 3 | header.channels > 4 {
|
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
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@ 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 {
|
init := fn(doublebuffer: bool): Surface {
|
||||||
framebuffer = dt.get(^Color, "framebuffer/fb0/ptr\0")
|
framebuffer = dt.get(^Color, "framebuffer/fb0/ptr")
|
||||||
width := dt.get(uint, "framebuffer/fb0/width\0")
|
width := dt.get(uint, "framebuffer/fb0/width")
|
||||||
height := dt.get(uint, "framebuffer/fb0/height\0")
|
height := dt.get(uint, "framebuffer/fb0/height")
|
||||||
if doublebuffer {
|
if doublebuffer {
|
||||||
return Surface.new(width, height)
|
return Surface.new(width, height)
|
||||||
} else {
|
} 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)
|
cursor := Vec2(uint).(pos.x, pos.y)
|
||||||
|
|
||||||
max_y := self.height - font.height
|
max_y := self.height - font.height
|
||||||
|
@ -314,48 +314,50 @@ Surface := struct {
|
||||||
char_advance := font.width + font.char_gap
|
char_advance := font.width + font.char_gap
|
||||||
self_width := self.width
|
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
|
if cursor.y > max_y break
|
||||||
|
|
||||||
glyph_data := @as(^u8, idk)
|
glyph_data := @as(^u8, idk)
|
||||||
code_point := @as(uint, 0)
|
code_point := @as(uint, 0)
|
||||||
|
|
||||||
if (*str & 0x80) == 0 {
|
if (str[i] & 0x80) == 0 {
|
||||||
if *str == 10 {
|
if str[i] == '\n' {
|
||||||
cursor.x = pos.x
|
cursor.x = pos.x
|
||||||
cursor.y += next_line_y
|
cursor.y += next_line_y
|
||||||
str += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if font.unicode == null {
|
if font.unicode == null {
|
||||||
if *str > font.num_glyphs {
|
if str[i] > font.num_glyphs {
|
||||||
str += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glyph_data = get_glyph(font, *str)
|
glyph_data = get_glyph(font, str[i])
|
||||||
} else {
|
} else {
|
||||||
if *str < UNC_TABLE_SIZE {
|
if str[i] < UNC_TABLE_SIZE {
|
||||||
glyph_index := *(font.unicode + *str)
|
glyph_index := *(font.unicode + str[i])
|
||||||
if glyph_index == 0xFFFF {
|
if glyph_index == 0xFFFF {
|
||||||
str += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
glyph_data = font.data + glyph_index * font.bytes_per_glyph
|
glyph_data = font.data + glyph_index * font.bytes_per_glyph
|
||||||
} else {
|
} else {
|
||||||
str += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str += 1
|
i += 1
|
||||||
} else if font.unicode != null {
|
} else if font.unicode != null {
|
||||||
first_byte := *str
|
first_byte := str[i]
|
||||||
num_bytes := @as(uint, 0)
|
num_bytes := @as(uint, 0)
|
||||||
|
|
||||||
num_bytes = utf8_len_table[first_byte >> 5 & 0x3]
|
num_bytes = utf8_len_table[first_byte >> 5 & 0x3]
|
||||||
|
|
||||||
if num_bytes == 0 {
|
if num_bytes == 0 {
|
||||||
str += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,25 +367,25 @@ Surface := struct {
|
||||||
bytes_processed := 1
|
bytes_processed := 1
|
||||||
|
|
||||||
loop if bytes_processed >= num_bytes break else {
|
loop if bytes_processed >= num_bytes break else {
|
||||||
str += 1
|
i += 1
|
||||||
if *str == 0 | (*str & 0xC0) != 0x80 {
|
if i == str.len | (str[i] & 0xC0) != 0x80 {
|
||||||
valid_sequence = false
|
valid_sequence = false
|
||||||
}
|
}
|
||||||
if valid_sequence == false {
|
if valid_sequence == false {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
code_point = code_point << 6 | *str & 0x3F
|
code_point = code_point << 6 | str[i] & 0x3F
|
||||||
bytes_processed += 1
|
bytes_processed += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if valid_sequence == false {
|
if valid_sequence == false {
|
||||||
str += 1
|
i += 1
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
str += 1
|
i += 1
|
||||||
|
|
||||||
if code_point == 10 {
|
if code_point == '\n' {
|
||||||
cursor.x = pos.x
|
cursor.x = pos.x
|
||||||
cursor.y += next_line_y
|
cursor.y += next_line_y
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{log, memory} := @use("../../stn/src/lib.hb")
|
.{log, memory} := @use("stn")
|
||||||
|
|
||||||
PSF1Header := packed struct {
|
PSF1Header := packed struct {
|
||||||
magic: u16,
|
magic: u16,
|
||||||
|
@ -31,7 +31,7 @@ Font := struct {
|
||||||
font_from_psf1 := fn(psf: ^u8): ?Font {
|
font_from_psf1 := fn(psf: ^u8): ?Font {
|
||||||
header := @as(^PSF1Header, @bitcast(psf))
|
header := @as(^PSF1Header, @bitcast(psf))
|
||||||
if header.magic != 0x436 {
|
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
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ font_from_psf1 := fn(psf: ^u8): ?Font {
|
||||||
font_from_psf2 := fn(psf: ^u8, unicode: bool): ?Font {
|
font_from_psf2 := fn(psf: ^u8, unicode: bool): ?Font {
|
||||||
header := @as(^PSF2Header, @bitcast(psf))
|
header := @as(^PSF2Header, @bitcast(psf))
|
||||||
if header.magic != 0x864AB572 {
|
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
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{log, panic, memory} := @use("../lib.hb")
|
.{log, panic, memory} := @use("stn")
|
||||||
alloc_return := @use("alloc_return.hb")
|
alloc_return := @use("alloc_return.hb")
|
||||||
|
|
||||||
/* the block size is 64 bytes, 64 blocks of 64 bytes.
|
/* the block size is 64 bytes, 64 blocks of 64 bytes.
|
||||||
|
@ -30,7 +30,7 @@ BlockAlloc := struct {
|
||||||
offset += 1
|
offset += 1
|
||||||
return .(0, null)
|
return .(0, null)
|
||||||
} else {
|
} else {
|
||||||
log.info("Already Allocated\0")
|
log.info("Already Allocated")
|
||||||
}
|
}
|
||||||
|
|
||||||
// else {
|
// else {
|
||||||
|
@ -40,7 +40,7 @@ BlockAlloc := struct {
|
||||||
// if self.ptr != null {
|
// if self.ptr != null {
|
||||||
// return .(64, self.ptr + offset * 64)
|
// return .(64, self.ptr + offset * 64)
|
||||||
// } else {
|
// } else {
|
||||||
// // panic.panic("Allocator is not inited.\0")
|
// // panic.panic("Allocator is not inited.")
|
||||||
// // return .(0, null)
|
// // return .(0, null)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
.{string} := @use("../../stn/src/lib.hb")
|
$get := fn($Expr: type, query: []u8): Expr {
|
||||||
|
return @eca(3, 5, query, query.len)
|
||||||
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
|
.{DiskID, FileID} := acs
|
||||||
|
|
||||||
// Paths without a node-disk component are to be treated as local files.
|
// Paths without a node-disk component are to be treated as local files.
|
||||||
// file_path := "DID:/test\0"
|
// file_path := "DID:/test"
|
||||||
Path := struct {
|
Path := struct {
|
||||||
// DiskID holds the host id
|
// DiskID holds the host id
|
||||||
disk_id: DiskID,
|
disk_id: DiskID,
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
.{math, random} := @use("../lib.hb")
|
.{math, random} := @use("stn")
|
||||||
|
|
||||||
$ARBITRARY0 := 0x243F6A8885A308D3
|
$ARBITRARY0 := 0x243F6A8885A308D3
|
||||||
$ARBITRARY1 := 0x13198A2E03707344
|
$ARBITRARY1 := 0x13198A2E03707344
|
||||||
|
|
|
@ -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)
|
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))
|
@eca(3, 1, LogMsg.(opts.log, print_buffer, len), @sizeof(LogMsg))
|
||||||
print(len, .{})
|
|
||||||
memory.set(u8, &0, print_buffer, len)
|
memory.set(u8, &0, print_buffer, len)
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
.{log, memory} := @use("stn")
|
// todo: splice function
|
||||||
|
|
||||||
reverse := fn(str: []u8): void {
|
reverse := fn(str: []u8): void {
|
||||||
if str.len == 0 return;
|
if str.len == 0 return;
|
||||||
|
@ -14,8 +14,15 @@ reverse := fn(str: []u8): void {
|
||||||
} else return
|
} else return
|
||||||
}
|
}
|
||||||
|
|
||||||
$equals := fn(lhs: []u8, rhs: []u8): bool {
|
equals := fn(lhs: []u8, rhs: []u8): bool {
|
||||||
return lhs.ptr == rhs.ptr & lhs.len == rhs.len
|
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 {
|
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)
|
T := @TypeOf(needle)
|
||||||
|
i := 0
|
||||||
if T == []u8 {
|
if T == []u8 {
|
||||||
if needle.len == 0 return null
|
if needle.len == 0 return null
|
||||||
i := 0
|
|
||||||
loop if i == haystack.len return null else {
|
|
||||||
if haystack[i] == needle[0] {
|
|
||||||
h := i
|
|
||||||
n := 0
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
n += 1
|
if i + needle.len > haystack.len return null
|
||||||
h += 1
|
if haystack[i] == needle[0] {
|
||||||
if needle[n] == 0 {
|
matches := true
|
||||||
return haystack[h..]
|
n := 1
|
||||||
} else if haystack[h] == 0 | haystack[h] != needle[n] {
|
loop {
|
||||||
|
if n == needle.len break
|
||||||
|
if haystack[i + n] != needle[n] {
|
||||||
|
matches = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
n += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if matches return .(haystack[0..i], haystack[i + needle.len..])
|
||||||
}
|
}
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
} else if T == u8 {
|
} else if T == u8 {
|
||||||
i := 0
|
loop {
|
||||||
loop if haystack[i] == needle return haystack[i..] else if i == haystack.len return null else i += 1
|
if haystack[i] == needle {
|
||||||
|
return .(haystack[0..i], haystack[i + 1..])
|
||||||
|
} else if i == haystack.len return null
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
@error("Type of needle must be []u8 or u8.")
|
@error("Type of needle must be []u8 or u8.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SplitIter := fn($T: type): type {
|
split := fn(iter: []u8, needle: @Any()): struct {
|
||||||
return struct {
|
|
||||||
str: []u8,
|
str: []u8,
|
||||||
needle: T,
|
needle: @TypeOf(needle),
|
||||||
done: bool,
|
done: bool,
|
||||||
|
|
||||||
next := fn(self: ^Self): ?[]u8 {
|
next := fn(self: ^Self): ?[]u8 {
|
||||||
if self.done return null;
|
if self.done return null;
|
||||||
|
|
||||||
if @TypeOf(self.needle) == u8 {
|
splits := split_once(self.str, self.needle)
|
||||||
i := 0
|
if splits != null {
|
||||||
loop if i == self.str.len {
|
self.str = splits.right
|
||||||
self.done = true
|
return splits.left
|
||||||
return self.str
|
|
||||||
} else if self.str[i] == self.needle {
|
|
||||||
result := self.str[..i]
|
|
||||||
self.str = self.str[i + 1..]
|
|
||||||
return result
|
|
||||||
} else {
|
} 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
|
|
||||||
}
|
|
||||||
|
|
||||||
self.done = true
|
self.done = true
|
||||||
return self.str
|
return self.str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} {
|
||||||
|
|
||||||
split := fn(iter: []u8, needle: @Any()): SplitIter(@TypeOf(needle)) {
|
|
||||||
T := @TypeOf(needle)
|
T := @TypeOf(needle)
|
||||||
if T != []u8 & T != u8 {
|
if T != []u8 & T != u8 {
|
||||||
@error("Type of needle must be []u8 or u8.")
|
@error("Type of needle must be []u8 or u8.")
|
||||||
|
@ -117,38 +93,45 @@ split := fn(iter: []u8, needle: @Any()): SplitIter(@TypeOf(needle)) {
|
||||||
return .(iter, needle, false)
|
return .(iter, needle, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
find_once := fn(haystack: ^u8, needle: @Any()): ?uint {
|
chars := fn(iter: []u8): struct {
|
||||||
return @bitcast(@inline(split_once, haystack, needle) - haystack)
|
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 {
|
count := fn(haystack: []u8, needle: @Any()): uint {
|
||||||
T := @TypeOf(needle)
|
T := @TypeOf(needle)
|
||||||
|
i := 0
|
||||||
c := 0
|
c := 0
|
||||||
if T == u8 {
|
if T == []u8 {
|
||||||
i := 0
|
if needle.len == 0 return null
|
||||||
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 haystack[i] == needle[0] {
|
|
||||||
h := i
|
|
||||||
n := 0
|
|
||||||
|
|
||||||
loop {
|
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
|
n += 1
|
||||||
h += 1
|
|
||||||
if n == needle.len {
|
|
||||||
c += 1
|
|
||||||
i = h - 1
|
|
||||||
break
|
|
||||||
} else if h == haystack.len | haystack[h] != needle[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
|
i += 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -162,9 +145,28 @@ left_trim := fn(str: []u8, sub: []u8): []u8 {
|
||||||
loop if i == sub.len {
|
loop if i == sub.len {
|
||||||
return str[i..str.len]
|
return str[i..str.len]
|
||||||
} else if str[i] != sub[i] | i == str.len {
|
} else if str[i] != sub[i] | i == str.len {
|
||||||
return str
|
break
|
||||||
} else {
|
} else {
|
||||||
i += 1
|
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)
|
||||||
}
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
.{math: .{Vec2}, buffer, log, memory, string} := @use("../../stn/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.hb");
|
.{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("../../render/src/lib.hb")
|
.{Surface, Color} := @use("lib:render")
|
||||||
|
|
||||||
// ! in the future this should be safely handled
|
// ! in the future this should be safely handled
|
||||||
channel := Channel.(0, 0)
|
channel := Channel.(0, 0)
|
||||||
|
|
||||||
find_server := fn(): void {
|
find_server := fn(): void {
|
||||||
log.info("client: locating server\0")
|
log.info("client: locating server")
|
||||||
channel2 := await_channel()
|
channel2 := await_channel()
|
||||||
channel.server = channel2.server
|
channel.server = channel2.server
|
||||||
channel.client = channel2.client
|
channel.client = channel2.client
|
||||||
log.info("client: server located\0")
|
log.info("client: server located")
|
||||||
}
|
}
|
||||||
|
|
||||||
new := fn(props: WindowProps): ?Window {
|
new := fn(props: WindowProps): ?Window {
|
||||||
|
@ -19,13 +19,13 @@ new := fn(props: WindowProps): ?Window {
|
||||||
if response.header.kind != message.ack {
|
if response.header.kind != message.ack {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
log.info("client: recv ack\0")
|
log.info("client: recv ack")
|
||||||
send_message(WindowProps, message.props, props, response.body.server)
|
send_message(WindowProps, message.props, props, response.body.server)
|
||||||
windowdata := await_message(WindowData, response.body.client)
|
windowdata := await_message(WindowData, response.body.client)
|
||||||
if windowdata.header.kind != message.ack {
|
if windowdata.header.kind != message.ack {
|
||||||
return null
|
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)
|
surface := Surface.new(windowdata.body.props.dimensions.x, windowdata.body.props.dimensions.y)
|
||||||
return .(windowdata.body, surface)
|
return .(windowdata.body, surface)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
.{math: .{Vec2}, buffer, memory} := @use("stn");
|
.{math: .{Vec2}, buffer, memory} := @use("stn");
|
||||||
.{Surface} := @use("../../render/src/lib.hb")
|
.{Surface} := @use("lib:render")
|
||||||
|
|
||||||
$BUFFER_SERVER := "sunset_server\0"
|
$BUFFER_SERVER := "sunset_server"
|
||||||
$BUFFER_CLIENT := "sunset_client\0"
|
$BUFFER_CLIENT := "sunset_client"
|
||||||
|
|
||||||
Channel := packed struct {
|
Channel := packed struct {
|
||||||
client: uint,
|
client: uint,
|
||||||
|
@ -85,8 +85,7 @@ Message := fn($Expr: type): type {
|
||||||
WindowProps := struct {
|
WindowProps := struct {
|
||||||
position: Vec2(uint),
|
position: Vec2(uint),
|
||||||
dimensions: Vec2(uint),
|
dimensions: Vec2(uint),
|
||||||
// ! replace with owned string type later
|
title: []u8,
|
||||||
title: ^u8,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowData := struct {
|
WindowData := struct {
|
||||||
|
|
|
@ -13,12 +13,12 @@ WindowServer := struct {
|
||||||
// ! in the future this should be safely handled
|
// ! in the future this should be safely handled
|
||||||
server := @as(WindowServer, idk)
|
server := @as(WindowServer, idk)
|
||||||
|
|
||||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||||
|
|
||||||
start := fn(): void {
|
start := fn(): void {
|
||||||
font := text.font_from_psf2(@bitcast(&psf), false)
|
font := text.font_from_psf2(@bitcast(&psf), false)
|
||||||
if font == null {
|
if font == null {
|
||||||
log.error("server: failed to load asset\0")
|
log.error("server: failed to load asset")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
server = .(
|
server = .(
|
||||||
|
@ -27,7 +27,7 @@ start := fn(): void {
|
||||||
.[null, null, null, null, null, null, null, null, null, null],
|
.[null, null, null, null, null, null, null, null, null, null],
|
||||||
@as(text.Font, font),
|
@as(text.Font, font),
|
||||||
)
|
)
|
||||||
log.info("server: started server\0")
|
log.info("server: started server")
|
||||||
}
|
}
|
||||||
|
|
||||||
incoming := fn(): bool {
|
incoming := fn(): bool {
|
||||||
|
@ -36,14 +36,14 @@ incoming := fn(): bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if msg.kind == message.syn {
|
if msg.kind == message.syn {
|
||||||
log.info("server: recv syn\0")
|
log.info("server: recv syn")
|
||||||
channel := Channel.(buffer.create_nameless(), buffer.create_nameless())
|
channel := Channel.(buffer.create_nameless(), buffer.create_nameless())
|
||||||
send_message(Channel, message.ack, channel, server.channel.client)
|
send_message(Channel, message.ack, channel, server.channel.client)
|
||||||
props := await_message(WindowProps, channel.server)
|
props := await_message(WindowProps, channel.server)
|
||||||
if props.header.kind != message.props {
|
if props.header.kind != message.props {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
log.info("server: recv props\0")
|
log.info("server: recv props")
|
||||||
// ! do inspection of requested props here
|
// ! do inspection of requested props here
|
||||||
data := WindowData.(props.body, channel, permissions.default)
|
data := WindowData.(props.body, channel, permissions.default)
|
||||||
send_message(WindowData, message.ack, data, channel.client)
|
send_message(WindowData, message.ack, data, channel.client)
|
||||||
|
@ -51,8 +51,7 @@ incoming := fn(): bool {
|
||||||
// decorations
|
// decorations
|
||||||
{
|
{
|
||||||
title := data.props.title
|
title := data.props.title
|
||||||
title_length := string.length(title)
|
deco_length := title.len * 10
|
||||||
deco_length := title_length * 10
|
|
||||||
// draw the window tab bar
|
// draw the window tab bar
|
||||||
surface.put_filled_rect(.(0, 0), .(data.props.dimensions.x + DECO_WIDTH + deco_length, DECO_HEIGHT_TOP), DECO_COLOUR)
|
surface.put_filled_rect(.(0, 0), .(data.props.dimensions.x + DECO_WIDTH + deco_length, DECO_HEIGHT_TOP), DECO_COLOUR)
|
||||||
// Draw the window tab
|
// Draw the window tab
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
stn := @use("stn")
|
||||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
sunset := @use("lib:sunset_proto")
|
||||||
render := @use("../../../libraries/render/src/lib.hb")
|
render := @use("lib:render")
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||||
.{Vec2} := stn.math
|
horizon_api := @use("lib:horizon_api");
|
||||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
|
||||||
|
|
||||||
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
|
.{set_color, render_label_to_surface, Label} := horizon_api.widgets.label
|
||||||
|
|
||||||
main := fn(): void {
|
main := fn(): void {
|
||||||
sunset.client.find_server()
|
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))
|
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false))
|
||||||
// pos := Vec2(uint).(1, 100)
|
// pos := Vec2(uint).(1, 100)
|
||||||
|
|
||||||
if window == null {
|
if window == null {
|
||||||
log.error("got no window\0")
|
log.error("got no window")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
text_label := Label.new_label("kernel : akern 0.2.0\0", 300)
|
text_label := Label.new_label("kernel : akern 0.2.0", 300)
|
||||||
text_label_2 := Label.new_label("os : ableos\0", 300)
|
text_label_2 := Label.new_label("os : ableos", 300)
|
||||||
text_label_3 := Label.new_label("wm : sunset\0", 300)
|
text_label_3 := Label.new_label("wm : sunset", 300)
|
||||||
text_label.set_color(render.BLACK, render.WHITE)
|
text_label.set_color(render.BLACK, render.WHITE)
|
||||||
|
|
||||||
text_label_2.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_2, font, pos2)
|
||||||
render_label_to_surface(window.surface, text_label_3, font, pos3)
|
render_label_to_surface(window.surface, text_label_3, font, pos3)
|
||||||
loop {
|
loop {
|
||||||
// stn.log.info("AAAA\0")
|
// stn.log.info("AAAA")
|
||||||
_ = sunset.client.send_frame(window)
|
_ = sunset.client.send_frame(window)
|
||||||
// stn.sleep.sleep_until_interrupt(100)
|
// stn.sleep.sleep_until_interrupt(100)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ MonitoredProcess := struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
log.info("Angels Halo reincarnation server started.\0")
|
log.info("Angels Halo reincarnation server started.")
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
.{memory, buffer, log} := @use("../../../libraries/stn/src/lib.hb");
|
.{memory, buffer, log} := @use("stn");
|
||||||
.{inb, outb} := memory
|
.{inb, outb} := memory
|
||||||
|
|
||||||
regs := @use("regs.hb");
|
regs := @use("regs.hb");
|
||||||
|
@ -28,7 +28,7 @@ sloop := fn(i: u8): void {
|
||||||
// identify := fn(): u8 {
|
// identify := fn(): u8 {
|
||||||
// a := inb(ATA_PRIMARY_COMM_REGSTAT)
|
// a := inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_DRIVE_HEAD, 0xA0)
|
// 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)
|
// a = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// outb(ATA_PRIMARY_SECCOUNT, 0)
|
// outb(ATA_PRIMARY_SECCOUNT, 0)
|
||||||
|
@ -43,10 +43,10 @@ sloop := fn(i: u8): void {
|
||||||
// outb(ATA_PRIMARY_COMM_REGSTAT, 0xE7)
|
// outb(ATA_PRIMARY_COMM_REGSTAT, 0xE7)
|
||||||
|
|
||||||
// status := inb(ATA_PRIMARY_COMM_REGSTAT)
|
// status := inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// log.info("Waiting for status.\0")
|
// log.info("Waiting for status.")
|
||||||
// loop {
|
// loop {
|
||||||
// if (status & STAT_BSY) == 0 {
|
// if (status & STAT_BSY) == 0 {
|
||||||
// log.info("Status got.\0")
|
// log.info("Status got.")
|
||||||
// break
|
// break
|
||||||
// } else {
|
// } else {
|
||||||
// sloop()
|
// sloop()
|
||||||
|
@ -54,14 +54,14 @@ sloop := fn(i: u8): void {
|
||||||
// status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
// status = inb(ATA_PRIMARY_COMM_REGSTAT)
|
||||||
// }
|
// }
|
||||||
// if status == 0 {
|
// if status == 0 {
|
||||||
// log.error("No drive detected.\0")
|
// log.error("No drive detected.")
|
||||||
|
|
||||||
// return 0
|
// 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 {
|
// loop {
|
||||||
// if (status & STAT_BSY) == 0 {
|
// if (status & STAT_BSY) == 0 {
|
||||||
// log.info("Status got.\0")
|
// log.info("Status got.")
|
||||||
// break
|
// break
|
||||||
// } else {
|
// } else {
|
||||||
// sloop()
|
// sloop()
|
||||||
|
@ -73,7 +73,7 @@ sloop := fn(i: u8): void {
|
||||||
// hi := inb(ATA_PRIMARY_LBA_HI)
|
// hi := inb(ATA_PRIMARY_LBA_HI)
|
||||||
|
|
||||||
// if (mid | hi) == 0 {
|
// 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
|
// return 0
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ sloop := fn(i: u8): void {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
drive_reset := fn(): void {
|
drive_reset := fn(): void {
|
||||||
log.warn("Drive resetting.\0")
|
log.warn("Drive resetting.")
|
||||||
outb(ATA_PRIMARY_DEVCTL, 0x4)
|
outb(ATA_PRIMARY_DEVCTL, 0x4)
|
||||||
sloop(4)
|
sloop(4)
|
||||||
outb(ATA_PRIMARY_DEVCTL, 0x0)
|
outb(ATA_PRIMARY_DEVCTL, 0x0)
|
||||||
|
@ -100,17 +100,17 @@ poll := fn(): u8 {
|
||||||
|
|
||||||
status = inb(ATA_PRIMARY_IO + ATA_REG_STAT)
|
status = inb(ATA_PRIMARY_IO + ATA_REG_STAT)
|
||||||
if (status & ATA_SR_DF) == 0 {
|
if (status & ATA_SR_DF) == 0 {
|
||||||
log.error("ATA PRIMARY DRIVE FAULT\0")
|
log.error("ATA PRIMARY DRIVE FAULT")
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status & ATA_SR_ERR) == 0 {
|
if (status & ATA_SR_ERR) == 0 {
|
||||||
log.error("ATA PRIMARY ERR\0")
|
log.error("ATA PRIMARY ERR")
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status & ATA_SR_DRQ) == 0 {
|
if (status & ATA_SR_DRQ) == 0 {
|
||||||
log.error("ATA PRIMARY DRQ\0")
|
log.error("ATA PRIMARY DRQ")
|
||||||
return 3
|
return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ main := fn(): int {
|
||||||
a := inb(0x4600)
|
a := inb(0x4600)
|
||||||
b := inb(0x4700)
|
b := inb(0x4700)
|
||||||
|
|
||||||
// c := buffer.search("XNumber\0")
|
// c := buffer.search("XNumber")
|
||||||
// c := identify()
|
// c := identify()
|
||||||
|
|
||||||
d := drive_reset()
|
d := drive_reset()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
READ_ONLY := @as(u32, 0x1)
|
$READ_ONLY := 0x1
|
||||||
HIDDEN := @as(u32, 0x2)
|
$HIDDEN := 0x2
|
||||||
SYSTEM := @as(u32, 0x4)
|
$SYSTEM := 0x4
|
||||||
VOLUME_ID := @as(u32, 0x8)
|
$VOLUME_ID := 0x8
|
||||||
DIRECTORY := @as(u32, 0x10)
|
$DIRECTORY: 0x10
|
||||||
ARCHIVE := @as(u32, 0x20)
|
$ARCHIVE := 0x20
|
||||||
LFN := READ_ONLY | HIDDEN | SYSTEM | VOLUME_ID
|
LFN := READ_ONLY | HIDDEN | SYSTEM | VOLUME_ID
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
VALID_JUMP_BYTES := u8.[0xEB, 0x3C, 0x90]
|
VALID_JUMP_BYTES := u8.[0xEB, 0x3C, 0x90]
|
||||||
|
@ -89,22 +89,22 @@ ExtendedBootRecord := struct {
|
||||||
sanity_check := fn(ebr: ExtendedBootRecord): int {
|
sanity_check := fn(ebr: ExtendedBootRecord): int {
|
||||||
ret := 0
|
ret := 0
|
||||||
if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 {
|
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 {
|
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
|
// ! comparison between [u8] is not supported in hblang
|
||||||
// if ebr.system_identifier_string != VALID_SYSTEM_IDENTIFIER_STRING {
|
// 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
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
new := fn(): ExtendedBootRecord {
|
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]
|
fmt_res := u8.[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
vol_name := @as([11]u8, idk)
|
vol_name := @as([11]u8, idk)
|
||||||
boot_code := @as([420]u8, idk)
|
boot_code := @as([420]u8, idk)
|
||||||
|
@ -146,19 +146,19 @@ FSInfo := struct {
|
||||||
ret := 0
|
ret := 0
|
||||||
if fs_info.lead_signature != VALID_LEAD_FS_INFO {
|
if fs_info.lead_signature != VALID_LEAD_FS_INFO {
|
||||||
ret &= 1
|
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 {
|
if fs_info.last_known_free_cluster_count == 0xFFFFFFFF {
|
||||||
ret &= 2
|
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 {
|
if fs_info.last_known_avalible_cluster == 0xFFFFFFFF {
|
||||||
ret &= 4
|
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 {
|
if fs_info.trail_signature != VALID_TRAIL_FS_INFO {
|
||||||
ret &= 8
|
ret &= 8
|
||||||
log.warn("Invalid trailing signature in FSInfo.\0")
|
log.warn("Invalid trailing signature in FSInfo.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
attributes := @use("attributes.hb")
|
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;
|
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
||||||
.{BiosParameterBlock, ExtendedBootRecord, FSInfo} := bios_parameter_block
|
.{BiosParameterBlock, ExtendedBootRecord, FSInfo} := bios_parameter_block
|
||||||
|
|
||||||
FAT12_THRESHOLD := 4085
|
$FAT12_THRESHOLD := 4085
|
||||||
FAT16_THRESHOLD := 65525
|
$FAT16_THRESHOLD := 65525
|
||||||
|
|
||||||
ExFAT := 0
|
$EXFAT := 0
|
||||||
FAT12 := 1
|
$FAT12 := 1
|
||||||
FAT16 := 2
|
$FAT16 := 2
|
||||||
FAT32 := 3
|
$FAT32 := 3
|
||||||
|
|
||||||
calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
||||||
if sector_size == 0 {
|
if sector_size == 0 {
|
||||||
return ExFAT
|
return EXFAT
|
||||||
} else if total_clusters < 4085 {
|
} else if total_clusters < 4085 {
|
||||||
return FAT12
|
return FAT12
|
||||||
} else if total_clusters < 65525 {
|
} else if total_clusters < 65525 {
|
||||||
|
@ -36,7 +36,7 @@ main := fn(): int {
|
||||||
fat_type := calculate_fat_type(1, 100)
|
fat_type := calculate_fat_type(1, 100)
|
||||||
|
|
||||||
if fat_type != FAT32 {
|
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()
|
bsc := bpb.sanity_check()
|
||||||
|
@ -49,7 +49,7 @@ main := fn(): int {
|
||||||
// Open file
|
// Open file
|
||||||
if msg_type == 0 {
|
if msg_type == 0 {
|
||||||
// Paths without a node-disk component are to be treated as local files.
|
// 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 {
|
} else {
|
||||||
// error
|
// error
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{string, memory, buffer, random, log} := stn;
|
.{string, memory, buffer, random, log} := stn;
|
||||||
.{Vec2} := stn.math
|
.{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;
|
.{new_label, render_label_to_surface, set_label_text} := horizon_api.widgets.label;
|
||||||
.{sexpr_parser, render_ui} := horizon_api.ui
|
.{sexpr_parser, render_ui} := horizon_api.ui
|
||||||
|
|
||||||
render := @use("../../../libraries/render/src/lib.hb");
|
render := @use("lib:render");
|
||||||
.{Surface} := render;
|
.{Surface} := render;
|
||||||
.{Font} := render.text
|
.{Font} := render.text
|
||||||
|
|
||||||
intouch := @use("../../../libraries/intouch/src/lib.hb")
|
intouch := @use("lib:intouch")
|
||||||
|
|
||||||
Window := struct {
|
Window := struct {
|
||||||
// TODO: Replace this with widgets
|
// TODO: Replace this with widgets
|
||||||
|
@ -21,23 +21,23 @@ Window := struct {
|
||||||
y: int,
|
y: int,
|
||||||
}
|
}
|
||||||
|
|
||||||
psf := @embed("../../../assets/consolefonts/tamsyn/10x20r.psf")
|
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||||
img := @embed("../../../assets/wallpaper.qoi")
|
img := @embed("sysdata:assets/wallpaper.qoi")
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
win_buff := buffer.create("XHorizon\0")
|
win_buff := buffer.create("XHorizon")
|
||||||
|
|
||||||
screen := render.init(true)
|
screen := render.init(true)
|
||||||
|
|
||||||
// Clear the screen to black.
|
// Clear the screen to black.
|
||||||
render.clear(screen, render.black)
|
screen.clear(render.BLACK)
|
||||||
|
|
||||||
wallpaper := render.image.from(@bitcast(&img))
|
wallpaper := render.image.from(@bitcast(&img))
|
||||||
if wallpaper == null {
|
if wallpaper == null {
|
||||||
return 1
|
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)
|
mem_buf := memory.request_page(1)
|
||||||
color := random.any(render.Color)
|
color := random.any(render.Color)
|
||||||
|
@ -48,16 +48,16 @@ main := fn(): int {
|
||||||
|
|
||||||
mouse_x := @as(i16, 0)
|
mouse_x := @as(i16, 0)
|
||||||
mouse_y := @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)
|
// ui := sexpr_parser(widgets)
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// Clear the screen
|
// 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
|
// TODO: Read the window buffer here
|
||||||
{
|
{
|
||||||
|
@ -65,33 +65,33 @@ main := fn(): int {
|
||||||
|
|
||||||
if false {
|
if false {
|
||||||
// Scroll bar :ThumbsUp:
|
// Scroll bar :ThumbsUp:
|
||||||
render.put_rect(screen, .(100, 100), .(100, 10), render.white)
|
screen.put_rect(.(100, 100), .(100, 10), render.WHITE)
|
||||||
render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white)
|
screen.put_filled_rect(.(110, 100), .(20, 10), render.WHITE)
|
||||||
|
|
||||||
render.put_rect(screen, .(90, 110), .(10, 100), render.white)
|
screen.put_rect(.(90, 110), .(10, 100), render.WHITE)
|
||||||
render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white)
|
screen.put_filled_rect(.(90, 120), .(10, 20), render.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// osu dots
|
// osu dots
|
||||||
render.put_rect(screen, .(400, 100), .(100, 100), render.red)
|
screen.put_rect(.(400, 100), .(100, 100), render.RED)
|
||||||
render.put_rect(screen, .(100, 100 + 300), .(100, 100), render.red)
|
screen.put_rect(.(100, 100 + 300), .(100, 100), render.RED)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
pos := Vec2(uint).(1, screen.height - 21)
|
pos := Vec2(uint).(1, screen.height - 21)
|
||||||
render_label_to_surface(screen, text_label, font, pos)
|
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
|
// 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
|
// get input events from drivers via intouch
|
||||||
if false {
|
if false {
|
||||||
key_event := intouch.recieve_key_event()
|
key_event := intouch.recieve_key_event()
|
||||||
if key_event != null {
|
if key_event != null {
|
||||||
log.info("Key event \0")
|
log.info("Key event ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ main := fn(): int {
|
||||||
//
|
//
|
||||||
|
|
||||||
if mouse_event != null {
|
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 := @as(i16, mouse_event.x_change)
|
||||||
change_x = change_x << 8
|
change_x = change_x << 8
|
||||||
|
@ -127,18 +127,18 @@ main := fn(): int {
|
||||||
mouse_y -= change_y
|
mouse_y -= change_y
|
||||||
|
|
||||||
if mouse_event.left {
|
if mouse_event.left {
|
||||||
set_label_text(text_label, "LEFT CLICK\0")
|
set_label_text(text_label, "LEFT CLICK")
|
||||||
}
|
}
|
||||||
if mouse_event.middle {
|
if mouse_event.middle {
|
||||||
set_label_text(text_label, "MIDDLE CLICK\0")
|
set_label_text(text_label, "MIDDLE CLICK")
|
||||||
}
|
}
|
||||||
if mouse_event.right {
|
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)
|
screen.put_filled_rect(.(mouse_x, mouse_y), .(20, 20), render.BLACK)
|
||||||
render.put_rect(screen, .(mouse_x, mouse_y), .(20, 20), render.white)
|
screen.put_rect(.(mouse_x, mouse_y), .(20, 20), render.WHITE)
|
||||||
|
|
||||||
// Send events to focused window
|
// Send events to focused window
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ main := fn(): int {
|
||||||
// TODO: Get windows out of a collection and iter through
|
// TODO: Get windows out of a collection and iter through
|
||||||
|
|
||||||
// Sync the screen
|
// Sync the screen
|
||||||
render.sync(screen)
|
screen.sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1,25 +1,25 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{string, memory, buffer, log} := 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
|
.{create_window} := horizon_api
|
||||||
|
|
||||||
ignim := @use("../../../libraries/ignim/src/lib.hb");
|
ignim := @use("lib:ignim");
|
||||||
.{errors} := ignim
|
.{errors} := ignim
|
||||||
|
|
||||||
psf := @embed("../../../consolefonts/tamsyn/10x20r.psf")
|
psf := @embed("sysdata:assets/consolefonts/tamsyn/10x20r.psf")
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
x := 0
|
x := 0
|
||||||
// loop if x > 10000 break else x += 1
|
// loop if x > 10000 break else x += 1
|
||||||
|
|
||||||
windowing_system_buffer := buffer.search("XHorizon\0")
|
windowing_system_buffer := buffer.search("XHorizon")
|
||||||
// TODO: get WindowID
|
// TODO: get WindowID
|
||||||
wid := create_window(windowing_system_buffer)
|
wid := create_window(windowing_system_buffer)
|
||||||
if false {
|
if false {
|
||||||
program_name := "Horizon Testing Program\0"
|
program_name := "Horizon Testing Program"
|
||||||
program_version := ignim.version.make_version(0, 1, 0)
|
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)
|
engine_version := ignim.version.make_version(0, 0, 0)
|
||||||
api_version := ignim.version.make_api_version(0, 1, 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
|
// // TODO: recursively follow this https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance
|
||||||
ret := ignim.instance.create_instance(&create_info, 0, &instance)
|
ret := ignim.instance.create_instance(&create_info, 0, &instance)
|
||||||
if ret == errors.IncompatibleDriver {
|
if ret == errors.IncompatibleDriver {
|
||||||
log.error("Driver Incompatible with Vulkan\0")
|
log.error("Driver Incompatible with Vulkan")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{memory, buffer, log, string, math} := stn;
|
.{memory, buffer, log, string, math} := stn;
|
||||||
.{inb, outb} := memory
|
.{inb, outb} := memory
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
.{memory, log} := @use("../../../libraries/stn/src/lib.hb");
|
.{memory, log} := @use("stn");
|
||||||
.{bit0, bit1, bit5, bit6, bit7} := @use("bits.hb");
|
.{bit0, bit1, bit5, bit6, bit7} := @use("bits.hb");
|
||||||
.{Port, PORT_AT_STARTUP} := @use("port.hb")
|
.{Port, PORT_AT_STARTUP} := @use("port.hb")
|
||||||
|
|
||||||
|
@ -88,15 +88,15 @@ init := fn(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port1.exists | port2.exists) == false {
|
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 {
|
if port1.exists {
|
||||||
log.info("Port 1 exists.\0")
|
log.info("Port 1 exists.")
|
||||||
enable_port1()
|
enable_port1()
|
||||||
}
|
}
|
||||||
if port2.exists {
|
if port2.exists {
|
||||||
log.info("Port 2 exists.\0")
|
log.info("Port 2 exists.")
|
||||||
enable_port2()
|
enable_port2()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
.{memory, log, buffer, string} := @use("../../../libraries/stn/src/lib.hb");
|
.{memory, log, buffer, string} := @use("stn");
|
||||||
.{MouseEvent} := @use("../../../libraries/intouch/src/lib.hb").events;
|
.{MouseEvent} := @use("lib:intouch").events;
|
||||||
.{bit0, bit1, bit2, bit3, bit4} := @use("bits.hb")
|
.{bit0, bit1, bit2, bit3, bit4} := @use("bits.hb")
|
||||||
devices := @use("devices.hb")
|
devices := @use("devices.hb")
|
||||||
controller := @use("controller.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
|
port.device.value = port.packet[1] | port.packet[0] << 8
|
||||||
enable_streaming(port)
|
enable_streaming(port)
|
||||||
}
|
}
|
||||||
log.info("Identified device!\0")
|
log.info("Identified device!")
|
||||||
log.print(port.device.value, .{radix: 16})
|
log.print(port.device.value, .{radix: 16})
|
||||||
} else {
|
} else {
|
||||||
log.info("KEY PRESSED\0")
|
log.info("KEY PRESSED")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,12 +107,12 @@ check_complete := fn(port: ^controller.Port): bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): void {
|
main := fn(): void {
|
||||||
mouse_buffer = buffer.create("PS/2 Mouse\0")
|
mouse_buffer = buffer.create("PS/2 Mouse")
|
||||||
|
|
||||||
controller.init()
|
controller.init()
|
||||||
|
|
||||||
if controller.port1.exists {
|
if controller.port1.exists {
|
||||||
//log.info("Port 1 exists.\0")
|
//log.info("Port 1 exists.")
|
||||||
controller.send_byte(@bitcast(0), 0xF4)
|
controller.send_byte(@bitcast(0), 0xF4)
|
||||||
}
|
}
|
||||||
if controller.port2.exists {
|
if controller.port2.exists {
|
||||||
|
@ -123,10 +123,10 @@ main := fn(): void {
|
||||||
info = controller.get_info()
|
info = controller.get_info()
|
||||||
|
|
||||||
if controller.timed_out(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) {
|
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) {
|
if controller.has_input(info) {
|
||||||
|
|
|
@ -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
|
Vec2 := math.Vec2
|
||||||
|
|
||||||
intouch := @use("../../../libraries/intouch/src/lib.hb");
|
intouch := @use("lib:intouch");
|
||||||
.{MouseEvent} := intouch.events
|
.{MouseEvent} := intouch.events
|
||||||
|
|
||||||
i9 := packed struct {sign: bool, value: u8}
|
i9 := packed struct {sign: bool, value: u8}
|
||||||
|
@ -21,7 +21,7 @@ reset_mouse := fn(): void {
|
||||||
@inline(send_byte, 0x64, 0xD4)
|
@inline(send_byte, 0x64, 0xD4)
|
||||||
@inline(send_byte, 0x60, 0xFF)
|
@inline(send_byte, 0x60, 0xFF)
|
||||||
loop if memory.inb(0x60) == 0xAA {
|
loop if memory.inb(0x60) == 0xAA {
|
||||||
log.info("Self check passed.\0")
|
log.info("Self check passed.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,11 +82,11 @@ set_up_mouse := fn(): void {
|
||||||
button_states := @as(u8, 0)
|
button_states := @as(u8, 0)
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
mouse_buffer := buffer.create("PS/2 Mouse\0")
|
mouse_buffer := buffer.create("PS/2 Mouse")
|
||||||
format_page := memory.alloc(u8, 1024)
|
format_page := memory.alloc(u8, 1024)
|
||||||
|
|
||||||
send_byte(0x64, 0xA8)
|
send_byte(0x64, 0xA8)
|
||||||
log.info("Aux mouse device enabled.\0")
|
log.info("Aux mouse device enabled.")
|
||||||
|
|
||||||
set_up_mouse()
|
set_up_mouse()
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ main := fn(): int {
|
||||||
|
|
||||||
if status == 0xAA {
|
if status == 0xAA {
|
||||||
loop if memory.inb(0x60) == 0 break
|
loop if memory.inb(0x60) == 0 break
|
||||||
log.info("Mouse plugged in!\0")
|
log.info("Mouse plugged in!")
|
||||||
set_up_mouse()
|
set_up_mouse()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb")
|
stn := @use("stn")
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
stn.log.info("\r
|
stn.log.info("\r
|
||||||
|
@ -9,7 +9,7 @@ main := fn(): int {
|
||||||
| : '=.:.=' : |\r
|
| : '=.:.=' : |\r
|
||||||
| : :'.___.': : |\r
|
| : :'.___.': : |\r
|
||||||
'-:__:__:__:__:-'\r
|
'-:__:__:__:__:-'\r
|
||||||
\0")
|
")
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -10,7 +10,7 @@ example := fn(): void {
|
||||||
image_bmp := render.image.from(@bitcast(&@embed("sysdata:assets/mini.bmp")))
|
image_bmp := render.image.from(@bitcast(&@embed("sysdata:assets/mini.bmp")))
|
||||||
|
|
||||||
if image_qoi == null | image_bmp == null {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ example := fn(): void {
|
||||||
window := @as(?sunset.Window, null)
|
window := @as(?sunset.Window, null)
|
||||||
if USE_SUNSET {
|
if USE_SUNSET {
|
||||||
sunset.client.find_server()
|
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 {
|
if window == null {
|
||||||
log.error("got no window\0")
|
log.error("got no window")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
screen = window.surface
|
screen = window.surface
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.{random} := @use("../../../../libraries/stn/src/lib.hb")
|
.{random} := @use("stn")
|
||||||
render := @use("../../../../libraries/render/src/lib.hb")
|
render := @use("lib:render")
|
||||||
|
|
||||||
example := fn(): void {
|
example := fn(): void {
|
||||||
screen := render.init(false)
|
screen := render.init(false)
|
||||||
|
|
|
@ -39,7 +39,7 @@ example := fn(): void {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := "sticky note:\n\0"
|
msg := "sticky note:\n"
|
||||||
msg_len := string.length(msg)
|
msg_len := string.length(msg)
|
||||||
|
|
||||||
buf := memory.alloc(u8, 4096)
|
buf := memory.alloc(u8, 4096)
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{sleep, log, memory} := stn
|
.{sleep, log, memory} := stn
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
loop {
|
loop {
|
||||||
log.info("BEFORE\0")
|
log.info("BEFORE")
|
||||||
sleep.sleep_until_interrupt(8)
|
sleep.sleep_until_interrupt(8)
|
||||||
log.info("AFTER\0")
|
log.info("AFTER")
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
sunset := @use("lib:sunset_proto")
|
||||||
render := @use("../../../libraries/render/src/lib.hb")
|
render := @use("lib:render")
|
||||||
|
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{log} := stn;
|
.{log} := stn;
|
||||||
.{Vec2} := stn.math
|
.{Vec2} := stn.math
|
||||||
|
|
||||||
|
@ -26,17 +26,17 @@ GameState := struct {
|
||||||
main := fn(): void {
|
main := fn(): void {
|
||||||
sunset.client.find_server()
|
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 {
|
if window == null {
|
||||||
log.error("got no window\0")
|
log.error("got no window")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
game_state := GameState.new()
|
game_state := GameState.new()
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
render.clear(window.surface, render.black)
|
window.surface.clear(render.BLACK)
|
||||||
width := 100
|
width := 100
|
||||||
idx := 1
|
idx := 1
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ main := fn(): void {
|
||||||
if idx >= width {
|
if idx >= width {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
render.put_vline(window.surface, idx, 10, 100, render.white)
|
window.surface.put_vline(idx, 10, 100, render.WHITE)
|
||||||
idx += 1
|
idx += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
letter := @as(u8, 0)
|
||||||
loop if *ptr == 0 break else {
|
i := 0
|
||||||
letter = *ptr
|
loop if i == str.len break else {
|
||||||
|
letter = str[i]
|
||||||
memory.outb(0xF803, letter)
|
memory.outb(0xF803, letter)
|
||||||
ptr += 1
|
i += 1
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_println := fn(ptr: ^u8): void {
|
serial_println := fn(str: []u8): void {
|
||||||
serial_print(ptr)
|
serial_print(str)
|
||||||
memory.outb(0xF803, 12)
|
memory.outb(0xF803, 12)
|
||||||
memory.outb(0xF803, 13)
|
memory.outb(0xF803, 13)
|
||||||
return
|
return
|
||||||
|
@ -19,28 +20,28 @@ serial_println := fn(ptr: ^u8): void {
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
// This must be done first and foremost to prevent racing
|
// This must be done first and foremost to prevent racing
|
||||||
a := buffer.create("XNumber\0")
|
a := buffer.create("XNumber")
|
||||||
serial_println("Starting Serial Driver.\0")
|
serial_println("Starting Serial Driver.")
|
||||||
|
|
||||||
mem := memory.request_page(1)
|
mem := memory.request_page(1)[1..memory.PAGE_SIZE]
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
ptr := @as(^u8, @eca(4, a, mem, 0x1000))
|
ptr := @as(^u8, @eca(4, a, mem, 0x1000))
|
||||||
if ptr == 0 {
|
if ptr == 0 {
|
||||||
serial_println("No message\0")
|
serial_println("No message")
|
||||||
}
|
}
|
||||||
if ptr > 0 {
|
if ptr > 0 {
|
||||||
serial_println("Yes message\0")
|
serial_println("Yes message")
|
||||||
serial_println(mem)
|
serial_println(mem)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that the first byte is reserved, pad accordingly.
|
// Note that the first byte is reserved, pad accordingly.
|
||||||
b := buffer.search("XNumber\0")
|
b := buffer.search("XNumber")
|
||||||
|
|
||||||
if a == b {
|
if a == b {
|
||||||
serial_println("Stopping Serial Driver.\0")
|
serial_println("Stopping Serial Driver.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
.{log} := @use("stn")
|
||||||
sunset := @use("../../../libraries/sunset_proto/src/lib.hb")
|
sunset := @use("lib:sunset_proto")
|
||||||
render := @use("../../../libraries/render/src/lib.hb")
|
render := @use("lib:render")
|
||||||
|
|
||||||
bmp := @embed("../../../assets/mini.bmp")
|
bmp := @embed("sysdata:assets/mini.bmp")
|
||||||
|
|
||||||
main := fn(): void {
|
main := fn(): void {
|
||||||
sunset.client.find_server()
|
sunset.client.find_server()
|
||||||
|
|
||||||
image := render.image.bmp.from(@bitcast(&bmp))
|
image := render.image.bmp.from(@bitcast(&bmp))
|
||||||
if image == null {
|
if image == null {
|
||||||
log.error("got no image\0")
|
log.error("got no image")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
window := sunset.client.new(.(.(400, 400), .(200, 200), "Hello\0"))
|
window := sunset.client.new(.(.(400, 400), .(200, 200), "Hello"))
|
||||||
|
|
||||||
if window == null {
|
if window == null {
|
||||||
log.error("got no window\0")
|
log.error("got no window")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
x := 0
|
x := 0
|
||||||
loop {
|
loop {
|
||||||
screen.clear(window.surface, render.BLACK)
|
window.surface.clear(render.BLACK)
|
||||||
render.put_surface(window.surface, image, .(image.width + x % window.data.props.dimensions.x, 20), false)
|
window.surface.put_surface(image, .(image.width + x % window.data.props.dimensions.x, 20), false)
|
||||||
_ = sunset.client.send_frame(window)
|
_ = sunset.client.send_frame(window)
|
||||||
x += 1
|
x += 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -38,7 +38,7 @@ Mouse := struct {
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
sunset.server.start()
|
sunset.server.start()
|
||||||
defer {
|
defer {
|
||||||
stn.log.info("Sunset Server Exit\0")
|
stn.log.info("Sunset Server Exit")
|
||||||
}
|
}
|
||||||
|
|
||||||
screen := render.init(true)
|
screen := render.init(true)
|
||||||
|
@ -47,7 +47,7 @@ main := fn(): int {
|
||||||
|
|
||||||
wallpaper := render.image.from(@bitcast(&img))
|
wallpaper := render.image.from(@bitcast(&img))
|
||||||
if wallpaper == null {
|
if wallpaper == null {
|
||||||
// stn.panic("Wallpaper not loaded\0")
|
// stn.panic("Wallpaper not loaded")
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ main := fn(): int {
|
||||||
mouse := Mouse.new(screen.width, screen.height)
|
mouse := Mouse.new(screen.width, screen.height)
|
||||||
//mouse.center()
|
//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)
|
text_label.set_color(sunset.server.DECO_COLOUR, render.BLACK)
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
@ -88,13 +88,13 @@ main := fn(): int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if mouse_event.left {
|
if mouse_event.left {
|
||||||
text_label.set_label_text("LEFT CLICK\0")
|
text_label.set_label_text("LEFT CLICK")
|
||||||
}
|
}
|
||||||
if mouse_event.middle {
|
if mouse_event.middle {
|
||||||
text_label.set_label_text("MIDDLE CLICK\0")
|
text_label.set_label_text("MIDDLE CLICK")
|
||||||
}
|
}
|
||||||
if mouse_event.right {
|
if mouse_event.right {
|
||||||
text_label.set_label_text("RIGHT CLICK\0")
|
text_label.set_label_text("RIGHT CLICK")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{string, memory, buffer, log} := stn
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
pci := @use("../../../libraries/pci/src/lib.hb");
|
pci := @use("lib:pci");
|
||||||
.{PCIAddress, get_ids, config_read32} := pci
|
.{PCIAddress, get_ids, config_read32} := pci
|
||||||
|
|
||||||
reg := @use("./reg.hb")
|
reg := @use("./reg.hb")
|
||||||
|
@ -71,7 +71,7 @@ svga_device := fn(): SVGADevice {
|
||||||
|
|
||||||
// TODO : this function is broken
|
// TODO : this function is broken
|
||||||
GetBARAddr := fn(addr: PCIAddress, index: int): u32 {
|
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)
|
bar := config_read32(0, 3, 0, 0)
|
||||||
PCI_CONF_BAR_IO := 0
|
PCI_CONF_BAR_IO := 0
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ setup_device := fn(svga_dev: ^SVGADevice): void {
|
||||||
pci_dev := pci.check_device(0, 3)
|
pci_dev := pci.check_device(0, 3)
|
||||||
|
|
||||||
if pci_dev.device_id.vendor != PCI_VENDOR_ID_VMWARE {
|
if pci_dev.device_id.vendor != PCI_VENDOR_ID_VMWARE {
|
||||||
log.error("SVGA device not found\0")
|
log.error("SVGA device not found")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//| pci_dev.device_id.device != PCI_DEVICE_ID_VMWARE_SVGA2 {
|
//| 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.fbSize = svga_dev.width * svga_dev.height * svga_dev.bpp / 8
|
||||||
|
|
||||||
svga_dev.vramSize = read_reg(svga_dev, 0x10)
|
svga_dev.vramSize = read_reg(svga_dev, 0x10)
|
||||||
log.info("SVGA device initialized successfully\0")
|
log.info("SVGA device initialized successfully")
|
||||||
|
|
||||||
return
|
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_HEIGHT, svga_dev.height)
|
||||||
write_reg(svga_dev, reg.SVGA_REG_BITS_PER_PIXEL, svga_dev.bpp)
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
device := @use("device.hb")
|
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
|
.{string, memory, buffer, log} := stn
|
||||||
|
|
||||||
reg := @use("reg.hb")
|
reg := @use("reg.hb")
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{sleep} := stn
|
.{sleep, buffer} := stn
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
tmpfs_buffer := buffer.create("TmpFS\0")
|
tmpfs_buffer := buffer.create("TmpFS")
|
||||||
loop {
|
loop {
|
||||||
// TODO
|
// TODO
|
||||||
// sleep.sleep_until_buffer(tmpfs_buffer)
|
// sleep.sleep_until_buffer(tmpfs_buffer)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
.{string, buffer} := @use("../../../../libraries/stn/src/lib.hb")
|
.{string, buffer} := @use("stn")
|
||||||
|
|
||||||
log_info := fn(): void {
|
log_info := fn(): void {
|
||||||
a := buffer.search("XNumber\0")
|
a := buffer.search("XNumber")
|
||||||
if a == 0 {
|
if a == 0 {
|
||||||
} else {
|
} else {
|
||||||
msg := "XABC\0"
|
msg := "XABC"
|
||||||
msg_length := string.length(msg)
|
msg_length := string.length(msg)
|
||||||
@eca(3, a, msg, msg_length)
|
@eca(3, a, msg, msg_length)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
stn := @use("../../../../../libraries/stn/src/lib.hb");
|
stn := @use("stn");
|
||||||
.{allocators, panic, log} := stn
|
.{allocators, panic, log} := stn
|
||||||
|
|
||||||
AStruct := struct {
|
AStruct := struct {
|
||||||
|
@ -20,10 +20,10 @@ test := fn(): uint {
|
||||||
}
|
}
|
||||||
bstruct := balloc.alloc(AStruct, 2)
|
bstruct := balloc.alloc(AStruct, 2)
|
||||||
if bstruct.ptr == null {
|
if bstruct.ptr == null {
|
||||||
log.info("Hi\0")
|
log.info("Hi")
|
||||||
// panic.panic("BlockAlloc actually didn't allocate.")
|
// panic.panic("BlockAlloc actually didn't allocate.")
|
||||||
} else {
|
} else {
|
||||||
log.info("Allocator functioned.\0")
|
log.info("Allocator functioned.")
|
||||||
}
|
}
|
||||||
balloc.dealloc(&bstruct.ptr, AStruct, 2)
|
balloc.dealloc(&bstruct.ptr, AStruct, 2)
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
.{log} := @use("../../../libraries/stn/src/lib.hb")
|
.{log, sleep} := @use("stn")
|
||||||
|
|
||||||
main := fn(): void {
|
main := fn(): void {
|
||||||
log.info("Hello, World!\0")
|
log.info("Hello, World!")
|
||||||
loop {
|
// fake interrupt, sleep forever
|
||||||
}
|
sleep.sleep_until_interrupt(100)
|
||||||
}
|
}
|
Binary file not shown.
|
@ -1,15 +1,15 @@
|
||||||
.{dt, log} := @use("stn")
|
.{dt, log} := @use("stn")
|
||||||
|
|
||||||
test := fn(): uint {
|
test := fn(): uint {
|
||||||
log.print(dt.get(int, "framebuffer/fb0/width\0"), .{})
|
log.print(dt.get(int, "framebuffer/fb0/width"), .{})
|
||||||
log.print(dt.get(int, "framebuffer/fb0/height\0"), .{})
|
log.print(dt.get(int, "framebuffer/fb0/height"), .{})
|
||||||
log.print(dt.get(^uint, "framebuffer/fb0/ptr\0"), .{})
|
log.print(dt.get(^uint, "framebuffer/fb0/ptr"), .{})
|
||||||
log.print(dt.get(int, "cpu/cpu0/architecture\0"), .{})
|
log.print(dt.get(int, "cpu/cpu0/architecture"), .{})
|
||||||
|
|
||||||
// 0 -> memory mapped
|
// 0 -> memory mapped
|
||||||
// 1 -> port 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
|
return 0
|
||||||
}
|
}
|
|
@ -21,6 +21,5 @@ test := fn(): uint {
|
||||||
d := hasher.finish()
|
d := hasher.finish()
|
||||||
log.printf("matches: {}, string: {}, hash: {}", .(d == correct, strings[i], d), .{radix: 16})
|
log.printf("matches: {}, string: {}, hash: {}", .(d == correct, strings[i], d), .{radix: 16})
|
||||||
}
|
}
|
||||||
log.print("done", .{})
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -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")
|
exe := @embed("./assets/hello_world_and_spin.hbf")
|
||||||
|
|
||||||
test := fn(): uint {
|
test := fn(): uint {
|
||||||
buf := "\0\0\0\0\0\0\0"
|
|
||||||
loop {
|
loop {
|
||||||
log.info(
|
log.print(process.spawn(@bitcast(&exe), 356), .{})
|
||||||
string.display_int(
|
|
||||||
@bitcast(process.spawn(@bitcast(&exe), 356)),
|
|
||||||
buf,
|
|
||||||
10,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
// spin so we don't spawn 10 quattuordecillion processes
|
// spin so we don't spawn 10 quattuordecillion processes
|
||||||
i := 0
|
i := 0
|
||||||
loop if i == 1000000 break else i += 1
|
loop if i == 20000000 break else i += 1
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
.{sleep, log} := @use("../../../../../libraries/stn/src/lib.hb")
|
.{sleep, log} := @use("stn")
|
||||||
|
|
||||||
test := fn(): uint {
|
test := fn(): uint {
|
||||||
log.info("BEFORE\0")
|
log.info("BEFORE")
|
||||||
sleep.sleep_until_interrupt(32)
|
sleep.sleep_until_interrupt(32)
|
||||||
log.info("AFTER\0")
|
log.info("AFTER")
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
|
@ -63,8 +63,5 @@ parse_str_to_path := fn(full_path: []u8): ?Path {
|
||||||
if path == null {
|
if path == null {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
root := full_path[..full_path.len - path.len]
|
return Path.(path.left, path.right)
|
||||||
bpath := full_path[full_path.len - path.len + 1..]
|
|
||||||
|
|
||||||
return Path.(root, bpath)
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue