diff --git a/Cargo.lock b/Cargo.lock index af66e89..680a1a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,9 +97,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.34" +version = "1.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9" +checksum = "baee610e9452a8f6f0a1b6194ec09ff9e2d85dea54432acdae41aa0761c95d70" dependencies = [ "shlex", ] @@ -173,6 +173,17 @@ dependencies = [ "logos", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -241,9 +252,9 @@ checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" dependencies = [ "allocator-api2", "equivalent", @@ -253,14 +264,14 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#87cb77a553d68d45c4ade7a71cae5a56edcf686b" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#87cb77a553d68d45c4ade7a71cae5a56edcf686b" dependencies = [ - "hashbrown 0.15.0", + "hashbrown 0.15.1", "hbbytecode", "hbvm", "log", @@ -270,7 +281,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e8f1d2af8ca7520bbb695dcaf1029a348f29592e" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#87cb77a553d68d45c4ade7a71cae5a56edcf686b" dependencies = [ "hbbytecode", ] @@ -299,13 +310,142 @@ dependencies = [ ] [[package]] -name = "idna" -version = "0.5.0" +name = "icu_collections" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -315,7 +455,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -334,7 +474,7 @@ dependencies = [ "aarch64-cpu", "crossbeam-queue", "derive_more", - "hashbrown 0.15.0", + "hashbrown 0.15.1", "hbvm", "limine", "log", @@ -366,6 +506,12 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02034f8f6b3e7bf050f310fbaf6db0018b8e54b75598d0a4c97172054752fede" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -663,6 +809,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "str-reader" version = "0.1.2" @@ -687,19 +839,25 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.8.0" +name = "synstructure" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ - "tinyvec_macros", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "tinyvec_macros" -version = "0.1.1" +name = "tinystr" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] [[package]] name = "tock-registers" @@ -752,27 +910,12 @@ dependencies = [ "x86", ] -[[package]] -name = "unicode-bidi" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" - [[package]] name = "unicode-ident" version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-xid" version = "0.2.6" @@ -802,15 +945,27 @@ dependencies = [ [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "versioning" version = "0.1.3" @@ -986,6 +1141,18 @@ dependencies = [ "memchr", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "x2apic" version = "0.4.3" @@ -1042,8 +1209,75 @@ dependencies = [ "serde", ] +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zeroize" version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/sysdata/libraries/render/src/software.hb b/sysdata/libraries/render/src/software.hb index 588eee2..8f15843 100644 --- a/sysdata/libraries/render/src/software.hb +++ b/sysdata/libraries/render/src/software.hb @@ -1,6 +1,6 @@ .{math, memory, dt} := @use("../../stn/src/lib.hb"); .{Color, text} := @use("lib.hb"); -.{get_glyph, Font} := text; +.{get_glyph, get_glyph_unicode, Font, UNC_TABLE_SIZE} := text; .{Vec2} := math // safety: don't use before init() or you will get a memory access violation @@ -266,29 +266,90 @@ put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str: current_char := str loop if *current_char == 0 break else { - if *current_char == 10 { - cursor.x = pos.x - cursor.y += font.height + font.line_gap + glyph_data := memory.dangling(^u8) + + if font.unicode != null { + code_point := @as(uint, 0) + first_byte := *current_char + num_bytes := 1 + + if (first_byte & 0x80) == 0 { + code_point = first_byte + } else if (first_byte & 0xE0) == 0xC0 { + num_bytes = 2 + code_point = first_byte & 0x1F + } else if (first_byte & 0xF0) == 0xE0 { + num_bytes = 3 + code_point = first_byte & 0xF + } else if (first_byte & 0xF8) == 0xF0 { + // handle later + current_char += 1 + continue + } else { + current_char += 1 + continue + } + + valid_sequence := true + i := 1 + loop if i >= num_bytes break else { + current_char += 1 + // have to check twice due to odd compiler bug...? + if *current_char == 0 | (*current_char & 0xC0) != 0x80 { + valid_sequence = false + } + if valid_sequence == false { + break + } + code_point = code_point << 6 | *current_char & 0x3F + i += 1 + } + + if valid_sequence == false { + current_char += 1 + continue + } + + current_char += 1 + + if code_point == 10 { + cursor.x = pos.x + cursor.y += font.height + font.line_gap + continue + } + + if code_point < UNC_TABLE_SIZE { + glyph_index := *(font.unicode + code_point) + + if glyph_index == 0xFFFF { + continue + } + glyph_data = font.data + glyph_index * font.bytes_per_glyph + } else { + continue + } + } else { + if *current_char > font.num_glyphs { + continue + } + glyph_data = @inline(get_glyph, font, *current_char) + if *current_char == 10 { + cursor.x = pos.x + cursor.y += font.height + font.line_gap + current_char += 1 + continue + } current_char += 1 - continue } - glyph_data := @inline(get_glyph, font, @intcast(*current_char)) - // ! cool null check don't disable :dead: - // !! i disabled the cool null check because compiler - // if glyph_data == null { - // current_char += 1 - // continue - // } + if cursor.y + font.height > surface.height break if cursor.x % surface.width + font.width >= surface.width { cursor.x = pos.x cursor.y += font.height + font.line_gap } - if cursor.y + font.height > surface.height break dest := @inline(indexptr, surface, cursor.x, cursor.y) - src := glyph_data rows_remaining := font.height loop if rows_remaining == 0 break else { @@ -303,7 +364,7 @@ put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str: } pixel_dest += 1 mask >>= 1 - if mask == 0 { + if mask == 0 & bits_remaining > 0 { glyph_data += 1 byte = *glyph_data mask = 0x80 @@ -311,13 +372,14 @@ put_text := fn(surface: Surface, font: Font, pos: Vec2(uint), color: Color, str: bits_remaining -= 1 } - glyph_data += 1 + if mask != 0x80 { + glyph_data += 1 + } dest += surface.width rows_remaining -= 1 } cursor.x += font.width + font.char_gap - current_char += 1 } return diff --git a/sysdata/libraries/render/src/text.hb b/sysdata/libraries/render/src/text.hb index 37cabf7..5a70a07 100644 --- a/sysdata/libraries/render/src/text.hb +++ b/sysdata/libraries/render/src/text.hb @@ -1,4 +1,4 @@ -.{log} := @use("../../stn/src/lib.hb") +.{log, memory} := @use("../../stn/src/lib.hb") PSF1Header := packed struct { magic: u16, @@ -23,9 +23,9 @@ Font := struct { height: uint, num_glyphs: uint, bytes_per_glyph: uint, - has_unicode_table: bool, line_gap: uint, char_gap: uint, + unicode: ?^u16, } font_from_psf1 := fn(psf: ^u8): ?Font { @@ -43,13 +43,13 @@ font_from_psf1 := fn(psf: ^u8): ?Font { header.character_size, 256, header.character_size, - false, 0, 0, + null, ) } -font_from_psf2 := fn(psf: ^u8): ?Font { +font_from_psf2 := fn(psf: ^u8, unicode: bool): ?Font { header := @as(^PSF2Header, @bitcast(psf)) if header.magic != 0x864AB572 { log.error("failed to load psf font: not a psf2 font, idiot\0") @@ -58,18 +58,105 @@ font_from_psf2 := fn(psf: ^u8): ?Font { psf += header.header_size - return .( + font := Font.( psf, header.width, header.height, header.num_glyph, header.bytes_per_glyph, - (header.flags & 1) != 0, 0, 0, + null, ) + if (header.flags & 1) != 0 & unicode { + init_unicode(&font) + } + return font } -get_glyph := fn(font: Font, index: uint): ^u8 { - return font.data + index * font.bytes_per_glyph +get_glyph := fn(font: Font, index: u8): ^u8 { + return font.data + @as(uint, index) * font.bytes_per_glyph +} + +UNC_TABLE_SIZE := 1 << 16 + +init_unicode := fn(font: ^Font): void { + font.unicode = memory.alloc(u16, UNC_TABLE_SIZE) + + @inline(memory.set, u16, &0xFFFF, font.unicode, UNC_TABLE_SIZE) + + table := font.data + font.num_glyphs * font.bytes_per_glyph + curr_glyph := @as(u16, 0) + + loop if curr_glyph >= font.num_glyphs break else { + loop { + byte := *table + table += 1 + + if byte == 0xFF break + if byte == 0xFE { + continue + } + + unicode := @as(uint, 0) + bytes_to_read := @as(uint, 1) + + if (byte & 0x80) == 0 { + unicode = byte + } else if (byte & 0xE0) == 0xC0 { + unicode = byte & 0x1F + bytes_to_read = 2 + } else if (byte & 0xF0) == 0xE0 { + unicode = byte & 0xF + bytes_to_read = 3 + } else if (byte & 0xF8) == 0xF0 { + unicode = byte & 0x7 + bytes_to_read = 4 + } else { + continue + } + + valid := true + loop if bytes_to_read <= 1 break else { + next_byte := *table + if (next_byte & 0xC0) != 0x80 { + valid = false + } + if valid == false { + break + } + unicode = unicode << 6 | next_byte & 0x3F + table += 1 + bytes_to_read -= 1 + } + + if valid == false continue + + if bytes_to_read == 4 { + if unicode < 0x10000 | unicode > 0x10FFFF continue + + if unicode <= 0xFFFF { + if unicode < UNC_TABLE_SIZE { + *(@unwrap(font.unicode) + unicode) = curr_glyph + } + } else { + unicode -= 0x10000 + high_surrogate := 0xD800 | unicode >> 10 & 0x3FF + low_surrogate := 0xDC00 | unicode & 0x3FF + + if high_surrogate < UNC_TABLE_SIZE { + *(@unwrap(font.unicode) + high_surrogate) = curr_glyph + } + if low_surrogate < UNC_TABLE_SIZE { + *(@unwrap(font.unicode) + low_surrogate) = curr_glyph + } + } + } else { + if unicode < UNC_TABLE_SIZE { + *(@unwrap(font.unicode) + unicode) = curr_glyph + } + } + } + curr_glyph += 1 + } } \ No newline at end of file diff --git a/sysdata/libraries/stn/src/buffer.hb b/sysdata/libraries/stn/src/buffer.hb index f2fad6b..680aec8 100644 --- a/sysdata/libraries/stn/src/buffer.hb +++ b/sysdata/libraries/stn/src/buffer.hb @@ -1,6 +1,6 @@ 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): void { return @eca(4, buffer_id, memory_map_location, @sizeof(Expr)) } diff --git a/sysdata/libraries/stn/src/string.hb b/sysdata/libraries/stn/src/string.hb index 5551b5c..71a8bcb 100644 --- a/sysdata/libraries/stn/src/string.hb +++ b/sysdata/libraries/stn/src/string.hb @@ -1,4 +1,3 @@ - length := fn(ptr: ^u8): uint { len := 0 loop if *(ptr + len) == 0 return len else len += 1 diff --git a/sysdata/programs/render_example/src/examples/text.hb b/sysdata/programs/render_example/src/examples/text.hb index 92c66f5..f13770f 100644 --- a/sysdata/programs/render_example/src/examples/text.hb +++ b/sysdata/programs/render_example/src/examples/text.hb @@ -1,37 +1,163 @@ +.{memory, log, string} := @use("../../../../libraries/stn/src/lib.hb") render := @use("../../../../libraries/render/src/lib.hb") /* expected result: - extended unicode test */ + trash notepad app, colours should change with r,g,b,w keys */ psf := @embed("../../../../consolefonts/tamsyn/10x20r.psf") +send_byte := fn(byte: u8): u8 { + memory.outb(96, byte) + return memory.inb(96) +} + example := fn(): void { - screen := render.init(false) - font := render.text.font_from_psf2(@bitcast(&psf)) + screen := render.init(true) + font := render.text.font_from_psf2(@bitcast(&psf), false) - str := "Extended unicode test: + msg := "ableboard (tm) (patent pending):\n\0" + msg_len := string.length(msg) -ABCDEFGHIJKLMNOPQRSTUVWXYZ -abcdefghijklmnopqrstuvwxyz -0123456789 -!\"#$%&'()*+,-./:;<=>?@[]^_`{|}~ -ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞß -àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ -ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğ -ĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿ -„‟†‡•‣․‥…‧ -₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵₶₷₸₹₺₻₼₽₾₿ -∀∁∂∃∄∅∆∇∈∉∊∋∌∍∎∏∐∑−∓∔∕∖∗∘∙√∛∜∝∞∟ -─│┌┐└┘├┤┬┴┼╋╭╮╯╰╱╲╳╴╵╶╷╸╹╺╻╼╽╾╿ -▀▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▐░▒▓▔▕▖▗▘▙▚▛▜▝▞▟ -■□▢▣▤▥▦▧▨▩▪▫▬▭▮▯▰▱▲△▴▵▶▷▸▹►▻▼▽▾▿◀◁◂◃◄◅◆◇◈◉◊○ -←↑→↓↔↕↖↗↘↙↚↛↜↝↞↟↠↡↢↣↤↥↦↧↨↩↪↫↬↭↮↯↰↱↲↳↴↵↶↷↸↹↺↻ - 、。〃〄々〆〇〈〉《》「」『』【】〒〓〔〕〖〗〘〙〚〛〜〝〞〟 -✀✁✂✃✄✅✆✇✈✉✊✋✌✍✎✏✐✑✒✓✔✕✖✗✘✙✚✛✜✝✞✟ -✠✡✢✣✤✥✦✧✨✩✪✫✬✭✮✯✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿\0" + buf := memory.alloc(u8, 4096) + + @inline(memory.copy, u8, msg, buf, msg_len) + cursor := buf + msg_len + + if font == null { + return + } + + _ = send_byte(238) + log.info("PS/2 Driver Loaded\0") + if send_byte(238) == 238 { + log.info("PS/2 Keyboard Echoed\0") + } + if send_byte(244) == 250 { + log.info("Enabled scanning\0") + } + + color := render.white + + prev_input := 250 + + loop { + input := memory.inb(96) + if input != prev_input { + prev_input = input + char := map_keys(input) + if char != 0 { + if char == 0xA { + *cursor = 32 + cursor += 1; + *cursor = 92 + cursor += 1 + } else if char == 0x72 { + color = render.red + } else if char == 0x67 { + color = render.green + } else if char == 0x62 { + color = render.blue + } else if char == 0x77 { + color = render.white + }; + *cursor = char + cursor += 1 + } + } + render.clear(screen, render.black) + render.put_text(screen, font, .(0, 0), color, buf) + render.sync(screen) + } - render.clear(screen, render.black) - render.put_text(screen, @unwrap(font), .(0, 0), render.white, str) - render.sync(screen) return +} + +map_keys := fn(inp: u8): u8 { + if inp == 0x29 { + return 0x7E + } else if inp == 0x2 { + return 0x31 + } else if inp == 0x3 { + return 0x32 + } else if inp == 0x4 { + return 0x33 + } else if inp == 0x5 { + return 0x34 + } else if inp == 0x6 { + return 0x35 + } else if inp == 0x7 { + return 0x36 + } else if inp == 0x8 { + return 0x37 + } else if inp == 0x9 { + return 0x38 + } else if inp == 0xA { + return 0x39 + } else if inp == 0xB { + return 0x30 + } else if inp == 0xC { + return 0x2D + } else if inp == 0xD { + return 0x3D + } else if inp == 0x1C { + return 0xA + } else if inp == 0x10 { + return 0x71 + } else if inp == 0x11 { + return 0x77 + } else if inp == 0x12 { + return 0x65 + } else if inp == 0x13 { + return 0x72 + } else if inp == 0x14 { + return 0x74 + } else if inp == 0x15 { + return 0x79 + } else if inp == 0x16 { + return 0x75 + } else if inp == 0x17 { + return 0x69 + } else if inp == 0x18 { + return 0x6F + } else if inp == 0x19 { + return 0x70 + } else if inp == 0x1E { + return 0x61 + } else if inp == 0x1F { + return 0x73 + } else if inp == 0x20 { + return 0x64 + } else if inp == 0x21 { + return 0x66 + } else if inp == 0x22 { + return 0x67 + } else if inp == 0x23 { + return 0x68 + } else if inp == 0x24 { + return 0x6A + } else if inp == 0x25 { + return 0x6B + } else if inp == 0x26 { + return 0x6C + } else if inp == 0x2C { + return 0x7A + } else if inp == 0x2D { + return 0x78 + } else if inp == 0x2E { + return 0x63 + } else if inp == 0x2F { + return 0x76 + } else if inp == 0x30 { + return 0x62 + } else if inp == 0x31 { + return 0x6E + } else if inp == 0x32 { + return 0x6D + } else if inp == 0x2B { + return 0x5C + } else if inp == 0x39 { + return 32 + } else { + return 0 + } } \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 0491a37..9a9ccbb 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" @@ -58,8 +58,8 @@ path = "boot:///ps2_keyboard_driver.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"