misc changes

This commit is contained in:
koniifer 2024-11-03 22:31:53 +00:00
parent 6894ef2360
commit 9e83707a28
17 changed files with 111 additions and 86 deletions

30
Cargo.lock generated
View file

@ -34,9 +34,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.91" version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
@ -97,9 +97,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.1.31" version = "1.1.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9"
dependencies = [ dependencies = [
"shlex", "shlex",
] ]
@ -253,12 +253,12 @@ dependencies = [
[[package]] [[package]]
name = "hbbytecode" name = "hbbytecode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#38a00cbaa09434324d209fc5f59480d2b6743fb3" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e"
[[package]] [[package]]
name = "hblang" name = "hblang"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#38a00cbaa09434324d209fc5f59480d2b6743fb3" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e"
dependencies = [ dependencies = [
"hashbrown 0.15.0", "hashbrown 0.15.0",
"hbbytecode", "hbbytecode",
@ -270,7 +270,7 @@ dependencies = [
[[package]] [[package]]
name = "hbvm" name = "hbvm"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#38a00cbaa09434324d209fc5f59480d2b6743fb3" source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e"
dependencies = [ dependencies = [
"hbbytecode", "hbbytecode",
] ]
@ -550,9 +550,9 @@ dependencies = [
[[package]] [[package]]
name = "rustls" name = "rustls"
version = "0.23.15" version = "0.23.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e"
dependencies = [ dependencies = [
"log", "log",
"once_cell", "once_cell",
@ -606,18 +606,18 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.213" version = "1.0.214"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.213" version = "1.0.214"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -677,9 +677,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.85" version = "2.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -35,7 +35,7 @@ create_window := fn(channel: int): ^render.Surface {
loop if x > 1000 break else x += 1 loop if x > 1000 break else x += 1
ret := buffer.recv([u8; 4096], windowing_system_buffer, mem_buf) ret := buffer.recv([u8; 4096], windowing_system_buffer, mem_buf)
if ret == 0 { if ret == null {
log.info("No messages\0") log.info("No messages\0")
} }

View file

@ -32,11 +32,11 @@ BitmapColorHeader := packed struct {
unused: u32, unused: u32,
} }
surface_from_bmp := fn(bmp: ^u8): Surface { surface_from_bmp := fn(bmp: ^u8): ?Surface {
file_header := @as(^BitmapFileHeader, @bitcast(bmp)) file_header := @as(^BitmapFileHeader, @bitcast(bmp))
if file_header.img_type != 0x4D42 { if file_header.img_type != 0x4D42 {
log.error("failed to load bmp image: not a bmp image, idiot\0") log.error("failed to load bmp image: not a bmp image, idiot\0")
return idk return null
} }
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader))) info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
bmp += file_header.offset bmp += file_header.offset
@ -64,11 +64,11 @@ surface_from_bmp := fn(bmp: ^u8): Surface {
return .(@bitcast(bmp), info_header.width, info_header.height) return .(@bitcast(bmp), info_header.width, info_header.height)
} }
new_surface_from_bmp := fn(bmp: ^u8): Surface { new_surface_from_bmp := fn(bmp: ^u8): ?Surface {
file_header := @as(^BitmapFileHeader, @bitcast(bmp)) file_header := @as(^BitmapFileHeader, @bitcast(bmp))
if file_header.img_type != 0x4D42 { if file_header.img_type != 0x4D42 {
log.error("failed to load bmp image: not a bmp image, idiot\0") log.error("failed to load bmp image: not a bmp image, idiot\0")
return idk return null
} }
info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader))) info_header := @as(^BitmapInfoHeader, @bitcast(bmp + @sizeof(BitmapFileHeader)))
bmp += file_header.offset bmp += file_header.offset

View file

@ -3,6 +3,9 @@
.{get_glyph, Font} := text; .{get_glyph, Font} := text;
.{Vec2} := math .{Vec2} := math
// safety: don't use before init() or you will get a memory access violation
framebuffer := memory.dangling(^Color)
Surface := struct { Surface := struct {
buf: ^Color, buf: ^Color,
width: uint, width: uint,
@ -36,8 +39,6 @@ free_surface := fn(surface: Surface): void {
return @inline(memory.free, Color, surface.buf, @intcast(surface.width * surface.height), false) return @inline(memory.free, Color, surface.buf, @intcast(surface.width * surface.height), false)
} }
framebuffer := @as(^Color, null)
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\0")
width := dt.get(uint, "framebuffer/fb0/width\0") width := dt.get(uint, "framebuffer/fb0/width\0")
@ -80,8 +81,9 @@ put_filled_rect := fn(surface: Surface, pos: Vec2(uint), tr: Vec2(uint), color:
rows_to_fill := tr.y rows_to_fill := tr.y
loop if rows_to_fill <= 1 break else { loop if rows_to_fill <= 1 break else {
@inline(memory.set, Color, &color, top_start_idx, @bitcast(tr.x)) // inline is broked
@inline(memory.set, Color, &color, bottom_start_idx, @bitcast(tr.x)) memory.set(Color, &color, top_start_idx, @bitcast(tr.x))
memory.set(Color, &color, bottom_start_idx, @bitcast(tr.x))
top_start_idx += surface.width top_start_idx += surface.width
bottom_start_idx -= surface.width bottom_start_idx -= surface.width
@ -272,10 +274,12 @@ put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str:
} }
glyph_data := @inline(get_glyph, font, @intcast(*current_char)) glyph_data := @inline(get_glyph, font, @intcast(*current_char))
if glyph_data == idk { // ! cool null check don't disable :dead:
current_char += 1 // !! i disabled the cool null check because compiler
continue // if glyph_data == null {
} // current_char += 1
// continue
// }
if cursor.x % surface.width + font.width >= surface.width { if cursor.x % surface.width + font.width >= surface.width {
cursor.x = pos.x cursor.x = pos.x

View file

@ -28,11 +28,11 @@ Font := struct {
char_gap: uint, char_gap: uint,
} }
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\0")
return idk return null
} }
psf += @sizeof(PSF1Header) psf += @sizeof(PSF1Header)
@ -40,30 +40,30 @@ font_from_psf1 := fn(psf: ^u8): Font {
return .( return .(
psf, psf,
8, 8,
@intcast(header.character_size), header.character_size,
256, 256,
@intcast(header.character_size), header.character_size,
false, false,
0, 0,
0, 0,
) )
} }
font_from_psf2 := fn(psf: ^u8): Font { font_from_psf2 := fn(psf: ^u8): ?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\0")
return idk return null
} }
psf += header.header_size psf += header.header_size
return .( return .(
psf, psf,
@intcast(header.width), header.width,
@intcast(header.height), header.height,
@intcast(header.num_glyph), header.num_glyph,
@intcast(header.bytes_per_glyph), header.bytes_per_glyph,
(header.flags & 1) != 0, (header.flags & 1) != 0,
0, 0,
0, 0,

View file

@ -1,6 +1,6 @@
string := @use("string.hb") string := @use("string.hb")
recv := fn($Expr: type, buffer_id: int, memory_map_location: ^u8): ^Expr { recv := fn($Expr: type, buffer_id: int, memory_map_location: ^u8): ?^Expr {
return @eca(4, buffer_id, memory_map_location, @sizeof(Expr)) return @eca(4, buffer_id, memory_map_location, @sizeof(Expr))
} }

View file

@ -6,4 +6,14 @@ buffer := @use("buffer.hb")
math := @use("math.hb") math := @use("math.hb")
random := @use("random.hb") random := @use("random.hb")
file := @use("file_io.hb") file := @use("file_io.hb")
dt := @use("dt.hb") dt := @use("dt.hb")
panic := fn(message: ?^u8): never {
log.error("Error: Panic Called, Message:\0")
if message == null {
log.error("None\0")
} else {
log.error(message)
}
die
}

View file

@ -2,6 +2,10 @@ PAGE_SIZE := 4096
MAX_ALLOC := 0xFF MAX_ALLOC := 0xFF
MAX_FREE := 0xFF MAX_FREE := 0xFF
dangling := fn($Expr: type): Expr {
return @bitcast(@sizeof(Expr))
}
calc_pages := fn($Expr: type, num: uint): uint { calc_pages := fn($Expr: type, num: uint): uint {
return 1 + @sizeof(Expr) * num / PAGE_SIZE return 1 + @sizeof(Expr) * num / PAGE_SIZE
} }
@ -14,10 +18,10 @@ alloc := fn($Expr: type, num: uint): ^Expr {
ptr := request_page(0xFF) ptr := request_page(0xFF)
remaining := pages - MAX_ALLOC remaining := pages - MAX_ALLOC
loop if remaining < MAX_ALLOC break else { loop if remaining < MAX_ALLOC break else {
_ := request_page(@intcast(MAX_ALLOC)) _ = request_page(@intcast(MAX_ALLOC))
remaining -= MAX_ALLOC remaining -= MAX_ALLOC
} }
_ := request_page(@intcast(remaining)) _ = request_page(@intcast(remaining))
return @bitcast(ptr) return @bitcast(ptr)
} }

View file

@ -1,8 +0,0 @@
panic := fn(message: ?^u8): void {
if message != null {
log.error(message)
}
// TODO: replace with die keyword when it gets pushed
loop {
}
}

View file

@ -1,8 +1,7 @@
length := fn(ptr: ^u8): uint { length := fn(ptr: ^u8): uint {
len := @as(uint, 0) len := 0
// loop if *(ptr + len) == 0 return len else len += 1 loop if *(ptr + len) == 0 return len else len += 1
loop if *(ptr + len) == 0 break else len += 1
return len
} }
display_int := fn(num: int, p: ^u8, radix: uint): ^u8 { display_int := fn(num: int, p: ^u8, radix: uint): ^u8 {
@ -58,7 +57,7 @@ display_int := fn(num: int, p: ^u8, radix: uint): ^u8 {
} }
reverse := fn(s: ^u8): void { reverse := fn(s: ^u8): void {
i := @as(uint, 0) i := 0
j := @inline(length, s) - 1 j := @inline(length, s) - 1
temp := @as(u8, 0) temp := @as(u8, 0)
loop if i >= j break else { loop if i >= j break else {

View file

@ -9,8 +9,7 @@ OemIdent := struct {
} }
new_oem_ident := fn(major: int, minor: int): OemIdent { new_oem_ident := fn(major: int, minor: int): OemIdent {
ver := [u8].(0, 0, 0, 0, 0, 0, 0, 0) return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0))
return OemIdent.(ver, ver)
} }
BiosParameterBlock := struct { BiosParameterBlock := struct {
@ -38,9 +37,7 @@ bpb_sanity_check := fn(bpb: BiosParameterBlock): int {
} }
new_bpb := fn(): BiosParameterBlock { new_bpb := fn(): BiosParameterBlock {
oem := new_oem_ident(0, 0) return .(VALID_JUMP_BYTES, new_oem_ident(0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
return BiosParameterBlock.(VALID_JUMP_BYTES, oem, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
} }
sector_count := fn(bpb: BiosParameterBlock): u32 { sector_count := fn(bpb: BiosParameterBlock): u32 {

View file

@ -36,7 +36,8 @@ main := fn(): int {
vel_inner := Vec2(int).(1, 1) vel_inner := Vec2(int).(1, 1)
pos_inner := Vec2(uint).((window.width - side) / 2, (window.height - side) / 2) pos_inner := Vec2(uint).((window.width - side) / 2, (window.height - side) / 2)
str := "Window Title Bar\0" str := "Window Title Bar\0"
font := render.text.font_from_psf2(@bitcast(&psf)) // really we should null check but it is a bit broked
font := @unwrap(render.text.font_from_psf2(@bitcast(&psf)))
loop { loop {
// Clear the screen // Clear the screen
@ -45,11 +46,12 @@ main := fn(): int {
// TODO: Read the window buffer here // TODO: Read the window buffer here
{ {
ret := buffer.recv([u8; 4096], win_buff, mem_buf) ret := buffer.recv([u8; 4096], win_buff, mem_buf)
if ret == 0 { // for some reason this null check causes the compiler to spin forever
log.info("No messages\0") // if ret == null {
} else { // log.info("No messages\0")
log.info("Handle Messages\0") // } else {
} // log.info("Handle Messages\0")
// }
} }
if pos_inner.x == 0 | pos_inner.x == window.width - side { if pos_inner.x == 0 | pos_inner.x == window.width - side {

View file

@ -7,7 +7,7 @@ send_byte := fn(byte: u8): u8 {
main := fn(): int { main := fn(): int {
buf := buffer.create("XKeyboard\0") buf := buffer.create("XKeyboard\0")
_ := send_byte(238) _ = send_byte(238)
log.info("PS/2 Driver Loaded\0") log.info("PS/2 Driver Loaded\0")
if send_byte(238) == 238 { if send_byte(238) == 238 {
log.info("PS/2 Keyboard Echoed\0") log.info("PS/2 Keyboard Echoed\0")

View file

@ -8,9 +8,10 @@ bmp_1 := @embed("./assets/able.bmp")
bmp_2 := @embed("./assets/mini.bmp") bmp_2 := @embed("./assets/mini.bmp")
example := fn(): void { example := fn(): void {
// strictly we should be null checking here but i am lazy
images := [render.Surface].( images := [render.Surface].(
render.image.surface_from_bmp(@bitcast(&bmp_1)), @unwrap(render.image.surface_from_bmp(@bitcast(&bmp_1))),
render.image.surface_from_bmp(@bitcast(&bmp_2)), @unwrap(render.image.surface_from_bmp(@bitcast(&bmp_2))),
) )
screen := render.init(true) screen := render.init(true)
vel := Vec2(int).(1, 1) vel := Vec2(int).(1, 1)

View file

@ -1,22 +1,37 @@
.{Vec2, sin, cos} := @use("../../../../libraries/stn/src/lib.hb").math
render := @use("../../../../libraries/render/src/lib.hb") render := @use("../../../../libraries/render/src/lib.hb")
/* expected result: /* expected result:
words */ extended unicode test */
psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf") psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf")
example := fn(): void { example := fn(): void {
screen := render.init(true) screen := render.init(false)
font := render.text.font_from_psf2(@bitcast(&psf)) font := render.text.font_from_psf2(@bitcast(&psf))
t := 0
str := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWX\0"
loop { str := "Extended unicode test:
render.clear(screen, render.black)
render.put_text(screen, font, .(t, t % screen.height), render.red, str) ABCDEFGHIJKLMNOPQRSTUVWXYZ
render.sync(screen) abcdefghijklmnopqrstuvwxyz
// t += 1 0123456789
} !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~
ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞß
àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ
ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğ
ĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿ
„‟†‡•‣․‥…‧
₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸₹₺₻₼₽₾₿
∀∁∂∃∄∅∆∇∈∉∊∋∌∍∎∏∐∑−∓∔∕∖∗∘∙√∛∜∝∞∟
─│┌┐└┘├┤┬┴┼╋╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿
▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟
■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯▰▱▲△▴▵▶▷▸▹►▻▼▽▾▿◀◁◂◃◄◅◆◇◈◉◊○
←↑→↓↔↕↖↗↘↙↚↛↜↝↞↟↠↡↢↣↤↥↦↧↨↩↪↫↬↭↮↯↰↱↲↳↴↵↶↷↸↹↺↻
 、。〃〄々〆〇〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛〜〝〞〟
✀✁✂✃✄✅✆✇✈✉✊✋✌✍✎✏✐✑✒✓✔✕✖✗✘✙✚✛✜✝✞✟
✠✡✢✣✤✥✦✧✨✩✪✫✬✭✮✯✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿\0"
render.clear(screen, render.black)
render.put_text(screen, @unwrap(font), .(0, 0), render.white, str)
render.sync(screen)
return return
} }

View file

@ -5,7 +5,9 @@ log_info := fn(): void {
if a == 0 { if a == 0 {
} else { } else {
msg := "XABC\0" msg := "XABC\0"
msg_length := @inline(string.length, msg) // inline is broked
// msg_length := @inline(string.length, msg)
msg_length := 5
@as(void, @eca(3, a, msg, msg_length)) @as(void, @eca(3, a, msg, msg_length))
} }

View file

@ -37,8 +37,8 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.serial_driver_test] # [boot.limine.ableos.modules.serial_driver_test]
# path = "boot:///serial_driver_test.hbf" # path = "boot:///serial_driver_test.hbf"
# [boot.limine.ableos.modules.horizon] [boot.limine.ableos.modules.horizon]
# path = "boot:///horizon.hbf" path = "boot:///horizon.hbf"
# [boot.limine.ableos.modules.horizon_testing_program] # [boot.limine.ableos.modules.horizon_testing_program]
# path = "boot:///horizon_testing_program.hbf" # path = "boot:///horizon_testing_program.hbf"
@ -58,6 +58,5 @@ resolution = "1024x768x24"
# [boot.limine.ableos.modules.pumpkin_print] # [boot.limine.ableos.modules.pumpkin_print]
# path = "boot:///pumpkin_print.hbf" # path = "boot:///pumpkin_print.hbf"
# [boot.limine.ableos.modules.mouse_driver]
[boot.limine.ableos.modules.mouse_driver] # path = "boot:///mouse_driver.hbf"
path = "boot:///mouse_driver.hbf"