From 1345f294b849e7f11cbafede8c1845433ba27b70 Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 8 Nov 2024 14:42:58 -0600 Subject: [PATCH 1/5] changes --- Cargo.lock | 6 +++--- sysdata/libraries/horizon_api/src/widgets/image.hb | 10 +++++----- sysdata/programs/horizon/src/main.hb | 8 -------- sysdata/system_config.toml | 12 ++++++------ 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bdd8f05..d2ffccc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,12 +228,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a299bad75b068f565e6e10b6c3501a9422e283c4" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#29367d8f8bdfc23d8662a74edcecf859285ce265" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a299bad75b068f565e6e10b6c3501a9422e283c4" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#29367d8f8bdfc23d8662a74edcecf859285ce265" dependencies = [ "hashbrown 0.15.1", "hbbytecode", @@ -245,7 +245,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#a299bad75b068f565e6e10b6c3501a9422e283c4" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#29367d8f8bdfc23d8662a74edcecf859285ce265" dependencies = [ "hbbytecode", ] diff --git a/sysdata/libraries/horizon_api/src/widgets/image.hb b/sysdata/libraries/horizon_api/src/widgets/image.hb index faa0d99..67e5391 100644 --- a/sysdata/libraries/horizon_api/src/widgets/image.hb +++ b/sysdata/libraries/horizon_api/src/widgets/image.hb @@ -1,5 +1,5 @@ -Image := struct { - magic: uint, - is_dirty: bool, - surface: Surface, -} \ No newline at end of file +// Image := struct { +// magic: uint, +// is_dirty: bool, +// surface: Surface, +// } \ No newline at end of file diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index 33d3185..5ac1a3a 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -46,14 +46,6 @@ main := fn(): int { // widgets := "()\0" // ui := sexpr_parser(widgets) - mouse_event := intouch.recieve_mouse_event() - - if mouse_event == null { - log.warn("null\0") - } else { - log.warn("not null\0") - } - loop { // Clear the screen render.clear(screen, render.black) diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index dfe4619..34b3a7b 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -28,8 +28,8 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.diskio_driver] # path = "boot:///diskio_driver.hbf" -# [boot.limine.ableos.modules.render_example] -# path = "boot:///render_example.hbf" +[boot.limine.ableos.modules.render_example] +path = "boot:///render_example.hbf" # [boot.limine.ableos.modules.serial_driver] # path = "boot:///serial_driver.hbf" @@ -37,8 +37,8 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.serial_driver_test] # path = "boot:///serial_driver_test.hbf" -[boot.limine.ableos.modules.horizon] -path = "boot:///horizon.hbf" +# [boot.limine.ableos.modules.horizon] +# path = "boot:///horizon.hbf" # [boot.limine.ableos.modules.horizon_testing_program] # path = "boot:///horizon_testing_program.hbf" @@ -58,8 +58,8 @@ path = "boot:///horizon.hbf" # [boot.limine.ableos.modules.pumpkin_print] # path = "boot:///pumpkin_print.hbf" -[boot.limine.ableos.modules.ps2_mouse_driver] -path = "boot:///ps2_mouse_driver.hbf" +# [boot.limine.ableos.modules.ps2_mouse_driver] +# path = "boot:///ps2_mouse_driver.hbf" # [boot.limine.ableos.modules.app_bar] # path = "boot:///app_bar.hbf" From 8b04b275f3e110648f65677e3c3f2a7ee82b70e7 Mon Sep 17 00:00:00 2001 From: koniifer Date: Sat, 9 Nov 2024 01:54:33 +0000 Subject: [PATCH 2/5] text editor is actually a text editor --- Cargo.lock | 10 +- .../render_example/src/examples/text.hb | 201 +++++++++++++----- 2 files changed, 149 insertions(+), 62 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d2ffccc..f408d39 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f" [[package]] name = "anyhow" @@ -228,12 +228,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#29367d8f8bdfc23d8662a74edcecf859285ce265" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#29367d8f8bdfc23d8662a74edcecf859285ce265" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217" dependencies = [ "hashbrown 0.15.1", "hbbytecode", @@ -245,7 +245,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#29367d8f8bdfc23d8662a74edcecf859285ce265" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217" dependencies = [ "hbbytecode", ] diff --git a/sysdata/programs/render_example/src/examples/text.hb b/sysdata/programs/render_example/src/examples/text.hb index 2f2c299..b9301c7 100644 --- a/sysdata/programs/render_example/src/examples/text.hb +++ b/sysdata/programs/render_example/src/examples/text.hb @@ -1,13 +1,15 @@ -.{memory, log, string} := @use("../../../../libraries/stn/src/lib.hb") +.{memory, log, string, math} := @use("../../../../libraries/stn/src/lib.hb") render := @use("../../../../libraries/render/src/lib.hb") -/* expected result: almost-not-trash notepad app - very jank +/* expected result: pretty decent notepad app + slightly jank ----------------- features: - basic keys - holding support with DAS - visible cursor + - l+r arrow key support + - proper insertion and deletion - shift key support */ @@ -15,12 +17,17 @@ psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf") is_shift_pressed := false is_ctrl_pressed := false +is_extended := false $initial_delay := 50 $repeat_delay := 7 +$left_arrow := 0x4B +$right_arrow := 0x4D +$up_arrow := 0x48 +$down_arrow := 0x50 example := fn(): void { screen := render.init(true) - window := render.new_surface(480, 340) + window := render.new_surface(600, 300) font := render.text.font_from_psf2(@bitcast(&psf), false) if font == null { @@ -35,12 +42,10 @@ example := fn(): void { bottom := buf + msg_len @inline(memory.copy, u8, msg, buf, msg_len) - cursor := buf + msg_len; + cursor := bottom - *cursor = 95 - draw_window(window, font, buf) - draw_screen(screen, window); - *cursor = 32 + draw_window(window, font, buf, cursor) + draw_screen(screen, window) memory.outb(96, 238) memory.outb(96, 238) @@ -53,24 +58,35 @@ example := fn(): void { loop { input := memory.inb(96) if input != prev_input { - if (input & 0x80) != 0 { - if (input & 0x7F) == current_key { - current_key = 0 - holding_timer = 0 - } else if input == 0xAA | input == 0xB6 { - is_shift_pressed = false - } else if input == 0x9D { - is_ctrl_pressed = false - } + if input == 0xE0 { + is_extended = true } else { - if input == 0x2A | input == 0x36 { - is_shift_pressed = true - } else if input == 0x1D { - is_ctrl_pressed = true + if (input & 0x80) != 0 { + if (input & 0x7F) == current_key { + current_key = 0 + holding_timer = 0 + } else if input == 0xAA | input == 0xB6 { + is_shift_pressed = false + } else if input == 0x9D { + is_ctrl_pressed = false + } + is_extended = false } else { - current_key = input - holding_timer = 1 - cursor = handle_char(map_keys(current_key), cursor, bottom) + if is_extended { + current_key = input + holding_timer = 1 + cursor = handle_extended_key(input, cursor, bottom, font) + } else { + if input == 0x2A | input == 0x36 { + is_shift_pressed = true + } else if input == 0x1D { + is_ctrl_pressed = true + } else { + current_key = input + holding_timer = 1 + cursor = handle_char(map_keys(current_key), cursor, bottom) + } + } } } prev_input = input @@ -80,14 +96,16 @@ example := fn(): void { holding_timer += 1 if holding_timer >= initial_delay { - cursor = handle_char(map_keys(current_key), cursor, bottom) + if is_extended { + cursor = handle_extended_key(current_key, cursor, bottom, font) + } else { + cursor = handle_char(map_keys(current_key), cursor, bottom) + } holding_timer = initial_delay - repeat_delay } - }; - *cursor = 95 - draw_window(window, font, buf) - draw_screen(screen, window); - *cursor = 32 + } + draw_window(window, font, buf, cursor) + draw_screen(screen, window) if holding_timer > 0 & current_key != 0 { if (memory.inb(96) & 0x80) != 0 { @@ -96,17 +114,87 @@ example := fn(): void { } } } +} - return +handle_extended_key := fn(scancode: u8, cursor: ^u8, bottom: ^u8, font: render.text.Font): ^u8 { + if scancode == left_arrow { + if cursor > bottom { + return cursor - 1 + } + } else if scancode == right_arrow { + if *cursor != 0 { + return cursor + 1 + } + } + return cursor +} + +padding := 3 * @sizeof(render.Color) + +draw_window := fn(window: render.Surface, font: render.text.Font, buf: ^u8, cursor: ^u8): void { + render.clear(window, render.light_yellow) + line := font.height + padding - 1 + render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.black) + + loop if line >= window.height break else { + render.put_hline(window, line, padding, window.width - padding, render.yellow) + line += font.height + } + + render.put_text(window, font, .(padding, padding), render.black, buf) + + cursor_offset := cursor - buf + + y_pos := padding + x_pos := padding + i := 0 + + loop if i >= cursor_offset break else { + if *(buf + i) == 10 { + y_pos += font.height + font.line_gap + x_pos = padding + } else { + if x_pos + font.width >= window.width - padding { + y_pos += font.height + font.line_gap + x_pos = padding - font.width + } + x_pos += font.width + } + i += 1 + } + + render.put_rect(window, .(x_pos, y_pos), .(1, font.height - 1), render.black) +} + +draw_screen := fn(screen: render.Surface, window: render.Surface): void { + render.clear(screen, render.light_blue) + render.put_surface(screen, window, .(100, 100), false) + render.sync(screen) } handle_char := fn(char: u8, cursor: ^u8, bottom: ^u8): ^u8 { if char == 0 { return cursor } + if is_ctrl_pressed & char == 48 { cursor = bottom } else if char != 0x8 { + end := cursor + loop if *end == 0 break else { + end += 1 + } + + if cursor < end { + src := end + dst := end + 1 + loop if src < cursor break else { + *dst = *src + dst -= 1 + src -= 1 + } + }; + *cursor = char return cursor + 1 } else if char == 0xA { @@ -115,37 +203,36 @@ handle_char := fn(char: u8, cursor: ^u8, bottom: ^u8): ^u8 { *cursor = 92 return cursor + 1 } else if cursor > bottom { - cursor -= 1; - *cursor = 32 - return cursor + if cursor == bottom { + return cursor + } + + end := cursor + loop if *end == 0 break else { + end += 1 + } + + if cursor < end { + src := cursor + dst := cursor - 1 + loop if src > end break else { + *dst = *src + dst += 1 + src += 1 + } + return cursor - 1 + } else { + cursor -= 1; + *cursor = 32 + return cursor + } } return cursor } - map_keys := fn(scancode: u8): u8 { if is_shift_pressed { return ps2_table[scancode + 0x40] } return ps2_table[scancode] } - -ps2_table := [u8].(0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) -$padding := 7 - -draw_window := fn(window: render.Surface, font: render.text.Font, buf: ^u8): void { - render.clear(window, render.light_yellow) - line := font.height + font.line_gap + padding - 1 - render.put_rect(window, .(0, 0), .(window.width - 1, window.height - 1), render.black) - loop if line >= window.height break else { - render.put_hline(window, line, padding, window.width - padding, render.yellow) - line += font.height + font.line_gap - } - - render.put_text(window, font, .(padding, padding), render.black, buf) -} - -draw_screen := fn(screen: render.Surface, window: render.Surface): void { - render.clear(screen, render.light_blue) - render.put_surface(screen, window, .(100, 100), false) - render.sync(screen) -} +ps2_table := [u8].(0x0, 0x1B, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x2D, 0x3D, 0x8, 0x9, 0x71, 0x77, 0x65, 0x72, 0x74, 0x79, 0x75, 0x69, 0x6F, 0x70, 0x5B, 0x5D, 0xA, 0x0, 0x61, 0x73, 0x64, 0x66, 0x67, 0x68, 0x6A, 0x6B, 0x6C, 0x3B, 0x27, 0x60, 0x0, 0x5C, 0x7A, 0x78, 0x63, 0x76, 0x62, 0x6E, 0x6D, 0x2C, 0x2E, 0x2F, 0x0, 0x2A, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1B, 0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0x28, 0x29, 0x5F, 0x2B, 0x8, 0x9, 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x55, 0x49, 0x4F, 0x50, 0x7B, 0x7D, 0xA, 0x0, 0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4A, 0x4B, 0x4C, 0x3A, 0x22, 0x7E, 0x0, 0x7C, 0x5A, 0x58, 0x43, 0x56, 0x42, 0x4E, 0x4D, 0x3C, 0x3E, 0x3F, 0x0, 0x0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) \ No newline at end of file From 7723799e765d33e2232b48e770be3fba8dee619e Mon Sep 17 00:00:00 2001 From: Able Date: Sat, 9 Nov 2024 20:44:08 -0600 Subject: [PATCH 3/5] changes or something idk --- sysdata/libraries/intouch/src/events.hb | 4 +-- sysdata/libraries/intouch/src/lib.hb | 6 ++-- sysdata/programs/horizon/src/main.hb | 29 +++++++++---------- sysdata/programs/ps2_mouse_driver/src/main.hb | 6 ++-- sysdata/programs/tests/src/main.hb | 16 ---------- 5 files changed, 20 insertions(+), 41 deletions(-) diff --git a/sysdata/libraries/intouch/src/events.hb b/sysdata/libraries/intouch/src/events.hb index 1d54423..0ede6d5 100644 --- a/sysdata/libraries/intouch/src/events.hb +++ b/sysdata/libraries/intouch/src/events.hb @@ -12,8 +12,8 @@ KeyEvent := struct { } MouseEvent := struct { - x_change: u8, - y_change: u8, + x_change: i8, + y_change: i8, left: u8, middle: u8, right: u8, diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb index ebfde1b..a0e9b4d 100644 --- a/sysdata/libraries/intouch/src/lib.hb +++ b/sysdata/libraries/intouch/src/lib.hb @@ -16,7 +16,7 @@ recieve_key_event := fn(): ?KeyEvent { key_event := KeyEvent.(0, 0, 2) // return key_event - return null + // return null } recieve_mouse_event := fn(): ?MouseEvent { @@ -28,8 +28,8 @@ recieve_mouse_event := fn(): ?MouseEvent { buffer.recv(MouseEvent, buf_id, mem_page) if *mem_page != 0 { log.info("Mouse events\0") - dx := *mem_page - dy := *mem_page + 1 + dx := @as(i8, @bitcast(*mem_page)) + dy := @as(i8, @bitcast(*mem_page + 1)) mevent := MouseEvent.(dx, dy, 0, 0, 0) return mevent } diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index 5ac1a3a..624a659 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -65,14 +65,11 @@ main := fn(): int { // key_event := intouch.recieve_key_event(); // log.info("before mouse event check\0"); { - // Note: MLokis, this inline halts the compiler forever - // mouse_event := @inline(intouch.recieve_mouse_event) - // Note: MLokis, this function returns null unless the mouse is moving mouse_event := intouch.recieve_mouse_event() // if mouse_event != null { - log.warn("Mouse event recieved\0") + // log.warn("Mouse event recieved\0") mouse_x += mouse_event.x_change mouse_y += mouse_event.y_change @@ -85,20 +82,20 @@ main := fn(): int { // TODO: Get windows out of a collection and iter through - render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) - { - // Scroll bar :ThumbsUp: - render.put_rect(screen, .(100, 100), .(100, 10), render.white) - render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white) + // render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) + // { + // // Scroll bar :ThumbsUp: + // render.put_rect(screen, .(100, 100), .(100, 10), render.white) + // render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white) - render.put_rect(screen, .(90, 110), .(10, 100), render.white) - render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white) - } + // render.put_rect(screen, .(90, 110), .(10, 100), render.white) + // render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white) + // } - { - pos := Vec2(uint).(1, screen.height - 21) - render_label_to_surface(screen, text_label, font, pos) - } + // { + // pos := Vec2(uint).(1, screen.height - 21) + // render_label_to_surface(screen, text_label, font, pos) + // } // Sync the screen render.sync(screen) } diff --git a/sysdata/programs/ps2_mouse_driver/src/main.hb b/sysdata/programs/ps2_mouse_driver/src/main.hb index 1f66ada..5e74c07 100644 --- a/sysdata/programs/ps2_mouse_driver/src/main.hb +++ b/sysdata/programs/ps2_mouse_driver/src/main.hb @@ -144,12 +144,10 @@ main := fn(): int { dy.sign = (status & 0x20) == 0 if dy.value != 0 & dx.value != 0 { - y_change := dy.value - x_change := dx.value + y_change := @as(i8, @bitcast(dy.value)) + x_change := @as(i8, @bitcast(dx.value)) event := MouseEvent.(x_change, y_change, 0, 0, 0) buffer.write(MouseEvent, &event, mouse_buffer) - - // mouse_moved(.(dx, dy)) } } diff --git a/sysdata/programs/tests/src/main.hb b/sysdata/programs/tests/src/main.hb index 049e404..02cc278 100644 --- a/sysdata/programs/tests/src/main.hb +++ b/sysdata/programs/tests/src/main.hb @@ -1,19 +1,3 @@ -.{log, string, memory, buffer} := @use("../../../libraries/stn/src/lib.hb") - -service_search := fn(): void { - a := "\{01}\0" - @eca(3, 0, a, 2) - - return -} - main := fn(): int { - //service_search() - buf := "\0\0\0\0" - x := @as(int, 0) - loop if x > 255 break else { - log.info(string.display_int(x, buf, 2)) - x += 1 - } return 0 } \ No newline at end of file From d2152537ad8ff3342633a5995780438ddeab2c38 Mon Sep 17 00:00:00 2001 From: Able Date: Sat, 9 Nov 2024 22:34:24 -0600 Subject: [PATCH 4/5] clean up --- sysdata/programs/test_abc/README.md | 1 - sysdata/programs/test_abc/meta.toml | 11 -------- sysdata/programs/test_abc/src/main.hb | 19 ------------- sysdata/programs/tests/meta.toml | 11 -------- sysdata/programs/tests/src/main.hb | 3 -- sysdata/system_config.toml | 40 ++------------------------- 6 files changed, 2 insertions(+), 83 deletions(-) delete mode 100644 sysdata/programs/test_abc/README.md delete mode 100644 sysdata/programs/test_abc/meta.toml delete mode 100644 sysdata/programs/test_abc/src/main.hb delete mode 100644 sysdata/programs/tests/meta.toml delete mode 100644 sysdata/programs/tests/src/main.hb diff --git a/sysdata/programs/test_abc/README.md b/sysdata/programs/test_abc/README.md deleted file mode 100644 index f569e63..0000000 --- a/sysdata/programs/test_abc/README.md +++ /dev/null @@ -1 +0,0 @@ -# test_abc \ No newline at end of file diff --git a/sysdata/programs/test_abc/meta.toml b/sysdata/programs/test_abc/meta.toml deleted file mode 100644 index 45bb122..0000000 --- a/sysdata/programs/test_abc/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "test_abc" -authors = [""] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/test_abc/src/main.hb b/sysdata/programs/test_abc/src/main.hb deleted file mode 100644 index f00414c..0000000 --- a/sysdata/programs/test_abc/src/main.hb +++ /dev/null @@ -1,19 +0,0 @@ -stn := @use("../../../libraries/stn/src/lib.hb"); -.{log} := stn - -Structure := struct {} - -returner_fn := fn(): ?Structure { - structure := Structure.() - return structure -} - -main := fn(): int { - ret := returner_fn() - if ret != null { - log.info("not null\0") - return 1 - } - - return 0 -} \ No newline at end of file diff --git a/sysdata/programs/tests/meta.toml b/sysdata/programs/tests/meta.toml deleted file mode 100644 index a94c666..0000000 --- a/sysdata/programs/tests/meta.toml +++ /dev/null @@ -1,11 +0,0 @@ -[package] -name = "tests" -authors = ["able"] - -[dependants.libraries] - -[dependants.binaries] -hblang.version = "1.0.0" - -[build] -command = "hblang src/main.hb" diff --git a/sysdata/programs/tests/src/main.hb b/sysdata/programs/tests/src/main.hb deleted file mode 100644 index 02cc278..0000000 --- a/sysdata/programs/tests/src/main.hb +++ /dev/null @@ -1,3 +0,0 @@ -main := fn(): int { - return 0 -} \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 34b3a7b..c46e0a3 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -22,47 +22,11 @@ resolution = "1024x768x24" [boot.limine.ableos.modules] -# [boot.limine.ableos.modules.tests] -# path = "boot:///tests.hbf" - -# [boot.limine.ableos.modules.diskio_driver] -# path = "boot:///diskio_driver.hbf" - [boot.limine.ableos.modules.render_example] path = "boot:///render_example.hbf" -# [boot.limine.ableos.modules.serial_driver] -# path = "boot:///serial_driver.hbf" - -# [boot.limine.ableos.modules.serial_driver_test] -# path = "boot:///serial_driver_test.hbf" - # [boot.limine.ableos.modules.horizon] # path = "boot:///horizon.hbf" -# [boot.limine.ableos.modules.horizon_testing_program] -# path = "boot:///horizon_testing_program.hbf" - -# [boot.limine.ableos.modules.dt_buffer_test] -# path = "boot:///dt_buffer_test.hbf" - -# [boot.limine.ableos.modules.svga_driver] -# path = "boot:///svga_driver.hbf" - -# [boot.limine.ableos.modules.ps2_keyboard_driver] -# path = "boot:///ps2_keyboard_driver.hbf" - -# [boot.limine.ableos.modules.filesystem_fat32] -# path = "boot:///filesystem_fat32.hbf" - -# [boot.limine.ableos.modules.pumpkin_print] -# path = "boot:///pumpkin_print.hbf" - -# [boot.limine.ableos.modules.ps2_mouse_driver] -# path = "boot:///ps2_mouse_driver.hbf" - -# [boot.limine.ableos.modules.app_bar] -# path = "boot:///app_bar.hbf" - -# [boot.limine.ableos.modules.test_abc] -# path = "boot:///test_abc.hbf" +[boot.limine.ableos.modules.ps2_mouse_driver] +path = "boot:///ps2_mouse_driver.hbf" From eea23d967bc275b00312d02c902c90cb7dbd95f3 Mon Sep 17 00:00:00 2001 From: Able Date: Sun, 10 Nov 2024 02:36:37 -0600 Subject: [PATCH 5/5] mouse cursor functional --- .cargo/config.toml | 2 +- Cargo.lock | 6 +- repbuild/src/main.rs | 1 + sysdata/libraries/intouch/src/lib.hb | 2 +- sysdata/programs/horizon/src/main.hb | 62 +++++++++++++------ sysdata/programs/ps2_mouse_driver/src/main.hb | 21 ++++--- sysdata/system_config.toml | 8 +-- 7 files changed, 64 insertions(+), 38 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index b335393..c5b12ff 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,3 @@ [alias] -repbuild = "run --manifest-path ./repbuild/Cargo.toml -r --" +repbuild = "run --manifest-path ./repbuild/Cargo.toml -r -- " dev = "run --manifest-path ./dev/Cargo.toml -r --" diff --git a/Cargo.lock b/Cargo.lock index f408d39..f776aab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,12 +228,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5" dependencies = [ "hashbrown 0.15.1", "hbbytecode", @@ -245,7 +245,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#65e9f272a85cc9d46c31072af9d0f2bc43ef1217" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#42a713aeaef11ca86d96083915191fbe456c47e5" dependencies = [ "hbbytecode", ] diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index 05522e2..39569a9 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -421,6 +421,7 @@ fn run(release: bool, target: Target, do_accel: bool) -> Result<(), Error> { "-bios", &ovmf_path.change_context(Error::OvmfFetch)?, "-drive", "file=target/disk.img,format=raw", "-device", "vmware-svga", + // "-serial", "stdio", "-m", "2G", "-smp", "1", "-parallel", "none", diff --git a/sysdata/libraries/intouch/src/lib.hb b/sysdata/libraries/intouch/src/lib.hb index a0e9b4d..e6a5dc7 100644 --- a/sysdata/libraries/intouch/src/lib.hb +++ b/sysdata/libraries/intouch/src/lib.hb @@ -29,7 +29,7 @@ recieve_mouse_event := fn(): ?MouseEvent { if *mem_page != 0 { log.info("Mouse events\0") dx := @as(i8, @bitcast(*mem_page)) - dy := @as(i8, @bitcast(*mem_page + 1)) + dy := @as(i8, @bitcast(*(mem_page + 1))) mevent := MouseEvent.(dx, dy, 0, 0, 0) return mevent } diff --git a/sysdata/programs/horizon/src/main.hb b/sysdata/programs/horizon/src/main.hb index 624a659..d1da4b2 100644 --- a/sysdata/programs/horizon/src/main.hb +++ b/sysdata/programs/horizon/src/main.hb @@ -40,8 +40,8 @@ main := fn(): int { // really we should null check but it is a bit broked font := @unwrap(render.text.font_from_psf2(@bitcast(&psf), false)) - mouse_x := 0 - mouse_y := 0 + mouse_x := @as(i16, 0) + mouse_y := @as(i16, 0) text_label := new_label("Hi\0") // widgets := "()\0" // ui := sexpr_parser(widgets) @@ -52,7 +52,7 @@ main := fn(): int { // TODO: Read the window buffer here { - ret := buffer.recv([u8; 4096], win_buff, mem_buf) + // ret := buffer.recv([u8; 4096], win_buff, mem_buf) // for some reason this null check causes the compiler to spin forever // if ret == null { // log.info("No messages\0") @@ -64,6 +64,22 @@ main := fn(): int { // get input events from drivers via intouch // key_event := intouch.recieve_key_event(); // log.info("before mouse event check\0"); + + render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) + { + // Scroll bar :ThumbsUp: + render.put_rect(screen, .(100, 100), .(100, 10), render.white) + render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white) + + render.put_rect(screen, .(90, 110), .(10, 100), render.white) + render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white) + } + + { + pos := Vec2(uint).(1, screen.height - 21) + render_label_to_surface(screen, text_label, font, pos) + } + { mouse_event := intouch.recieve_mouse_event() // @@ -71,8 +87,30 @@ main := fn(): int { if mouse_event != null { // log.warn("Mouse event recieved\0") - mouse_x += mouse_event.x_change - mouse_y += mouse_event.y_change + change_x := @as(i16, mouse_event.x_change) + change_x = change_x << 8 + change_x = change_x >> 8 + + mouse_x += change_x + if mouse_x < 0 { + mouse_x = 0 + } + if mouse_x >= screen.width - 20 { + mouse_x = @intcast(screen.width - 21) + } + + change_y := @as(i16, mouse_event.y_change) + change_y = change_y << 8 + change_y = change_y >> 8 + + if mouse_y < 0 { + mouse_y = 0 + } + if mouse_y >= screen.height - 20 { + mouse_y = @intcast(screen.height - 21) + } + mouse_y -= change_y + set_label_text(text_label, "Mouse Moved\0") } // render mouse @@ -82,20 +120,6 @@ main := fn(): int { // TODO: Get windows out of a collection and iter through - // render.put_rect(screen, .(0, 0), .(screen.width - 1, screen.height - 1), render.white) - // { - // // Scroll bar :ThumbsUp: - // render.put_rect(screen, .(100, 100), .(100, 10), render.white) - // render.put_filled_rect(screen, .(110, 100), .(20, 10), render.white) - - // render.put_rect(screen, .(90, 110), .(10, 100), render.white) - // render.put_filled_rect(screen, .(90, 120), .(10, 20), render.white) - // } - - // { - // pos := Vec2(uint).(1, screen.height - 21) - // render_label_to_surface(screen, text_label, font, pos) - // } // Sync the screen render.sync(screen) } diff --git a/sysdata/programs/ps2_mouse_driver/src/main.hb b/sysdata/programs/ps2_mouse_driver/src/main.hb index 5e74c07..d234380 100644 --- a/sysdata/programs/ps2_mouse_driver/src/main.hb +++ b/sysdata/programs/ps2_mouse_driver/src/main.hb @@ -111,6 +111,7 @@ main := fn(): int { loop if (memory.inb(0x64) & 0x20) == 0x20 break status := memory.inb(0x60) + if status == 0xAA { loop if memory.inb(0x60) == 0 break log.info("Mouse plugged in!\0") @@ -132,23 +133,23 @@ main := fn(): int { button_states ^= changes - // log.info(string.display_int(status, format_page, 10)) - dx := i9.(false, 0) dy := i9.(false, 0) dx.value = memory.inb(0x60) dx.sign = (status & 0x10) > 0 - dy.value = -memory.inb(0x60) - dy.sign = (status & 0x20) == 0 + dy.value = memory.inb(0x60) + dy.sign = (status & 0x20) != 0 - if dy.value != 0 & dx.value != 0 { - y_change := @as(i8, @bitcast(dy.value)) - x_change := @as(i8, @bitcast(dx.value)) - event := MouseEvent.(x_change, y_change, 0, 0, 0) - buffer.write(MouseEvent, &event, mouse_buffer) - } + y_change := @as(i8, @bitcast(dy.value)) + x_change := @as(i8, @bitcast(dx.value)) + + event := MouseEvent.(0, 0, 0, 0, 0) + event.x_change = x_change + event.y_change = y_change + + buffer.write(MouseEvent, &event, mouse_buffer) } return 0 diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index c46e0a3..2e9996c 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -22,11 +22,11 @@ resolution = "1024x768x24" [boot.limine.ableos.modules] -[boot.limine.ableos.modules.render_example] -path = "boot:///render_example.hbf" +# [boot.limine.ableos.modules.render_example] +# path = "boot:///render_example.hbf" -# [boot.limine.ableos.modules.horizon] -# path = "boot:///horizon.hbf" +[boot.limine.ableos.modules.horizon] +path = "boot:///horizon.hbf" [boot.limine.ableos.modules.ps2_mouse_driver] path = "boot:///ps2_mouse_driver.hbf"