diff --git a/assets/pixel-operator/LICENSE.txt b/assets/pixel-operator/LICENSE.txt deleted file mode 100644 index 0e259d42..00000000 --- a/assets/pixel-operator/LICENSE.txt +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/assets/pixel-operator/PixelOperator-Bold.ttf b/assets/pixel-operator/PixelOperator-Bold.ttf deleted file mode 100644 index 745734f6..00000000 Binary files a/assets/pixel-operator/PixelOperator-Bold.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperator.ttf b/assets/pixel-operator/PixelOperator.ttf deleted file mode 100644 index 34fe947b..00000000 Binary files a/assets/pixel-operator/PixelOperator.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperator8-Bold.ttf b/assets/pixel-operator/PixelOperator8-Bold.ttf deleted file mode 100644 index 10225eb8..00000000 Binary files a/assets/pixel-operator/PixelOperator8-Bold.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperator8.ttf b/assets/pixel-operator/PixelOperator8.ttf deleted file mode 100644 index f9146acf..00000000 Binary files a/assets/pixel-operator/PixelOperator8.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorHB.ttf b/assets/pixel-operator/PixelOperatorHB.ttf deleted file mode 100644 index d63fa398..00000000 Binary files a/assets/pixel-operator/PixelOperatorHB.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorHB8.ttf b/assets/pixel-operator/PixelOperatorHB8.ttf deleted file mode 100644 index 5283cb51..00000000 Binary files a/assets/pixel-operator/PixelOperatorHB8.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorHBSC.ttf b/assets/pixel-operator/PixelOperatorHBSC.ttf deleted file mode 100644 index b8fa149c..00000000 Binary files a/assets/pixel-operator/PixelOperatorHBSC.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorMono-Bold.ttf b/assets/pixel-operator/PixelOperatorMono-Bold.ttf deleted file mode 100644 index 215d4a29..00000000 Binary files a/assets/pixel-operator/PixelOperatorMono-Bold.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorMono.ttf b/assets/pixel-operator/PixelOperatorMono.ttf deleted file mode 100644 index 1c1edcca..00000000 Binary files a/assets/pixel-operator/PixelOperatorMono.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorMono8-Bold.ttf b/assets/pixel-operator/PixelOperatorMono8-Bold.ttf deleted file mode 100644 index fc5b82b1..00000000 Binary files a/assets/pixel-operator/PixelOperatorMono8-Bold.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorMono8.ttf b/assets/pixel-operator/PixelOperatorMono8.ttf deleted file mode 100644 index 9e871eaf..00000000 Binary files a/assets/pixel-operator/PixelOperatorMono8.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorMonoHB.ttf b/assets/pixel-operator/PixelOperatorMonoHB.ttf deleted file mode 100644 index 55410fbd..00000000 Binary files a/assets/pixel-operator/PixelOperatorMonoHB.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorMonoHB8.ttf b/assets/pixel-operator/PixelOperatorMonoHB8.ttf deleted file mode 100644 index 1e10e3b5..00000000 Binary files a/assets/pixel-operator/PixelOperatorMonoHB8.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorSC-Bold.ttf b/assets/pixel-operator/PixelOperatorSC-Bold.ttf deleted file mode 100644 index a44caaf7..00000000 Binary files a/assets/pixel-operator/PixelOperatorSC-Bold.ttf and /dev/null differ diff --git a/assets/pixel-operator/PixelOperatorSC.ttf b/assets/pixel-operator/PixelOperatorSC.ttf deleted file mode 100644 index 06783f81..00000000 Binary files a/assets/pixel-operator/PixelOperatorSC.ttf and /dev/null differ diff --git a/crates/console/prometeu-drivers/src/gfx.rs b/crates/console/prometeu-drivers/src/gfx.rs index c33b2cf4..8cc86272 100644 --- a/crates/console/prometeu-drivers/src/gfx.rs +++ b/crates/console/prometeu-drivers/src/gfx.rs @@ -64,7 +64,7 @@ pub struct Gfx { layer_buckets: [Vec; 4], } -const GLYPH_UNKNOWN: [u8; 5] = [0x7, 0x7, 0x7, 0x7, 0x7]; +// const GLYPH_UNKNOWN: [u8; 5] = [0x7, 0x7, 0x7, 0x7, 0x7]; struct RenderTarget<'a> { back: &'a mut [u16], @@ -81,57 +81,123 @@ struct CachedTileDraw<'a> { tile_size: prometeu_hal::glyph_bank::TileSize, } +pub const HW_FONT_WIDTH: usize = 7; +pub const HW_FONT_HEIGHT: usize = 6; +pub const HW_FONT_SPACING_X: usize = 1; +pub const HW_FONT_SPACING_Y: usize = 2; +pub const HW_FONT_ADVANCE_X: usize = HW_FONT_WIDTH + HW_FONT_SPACING_X; // 8 +pub const HW_FONT_ADVANCE_Y: usize = HW_FONT_HEIGHT + HW_FONT_SPACING_Y; // 8 + +pub const GLYPH_UNKNOWN: [u8; HW_FONT_HEIGHT] = [ + 0x7F, // ####### + 0x41, // #.....# + 0x5D, // #.###.# + 0x55, // #.#.#.# + 0x41, // #.....# + 0x7F, // ####### +]; + +pub const GLYPH_SPACE: [u8; HW_FONT_HEIGHT] = [ + 0x00, // ....... + 0x00, // ....... + 0x00, // ....... + 0x00, // ....... + 0x00, // ....... + 0x00, // ....... +]; + #[inline] -fn glyph_for_char(c: char) -> &'static [u8; 5] { - match c.to_ascii_uppercase() { - '0' => &[0x7, 0x5, 0x5, 0x5, 0x7], - '1' => &[0x2, 0x6, 0x2, 0x2, 0x7], - '2' => &[0x7, 0x1, 0x7, 0x4, 0x7], - '3' => &[0x7, 0x1, 0x7, 0x1, 0x7], - '4' => &[0x5, 0x5, 0x7, 0x1, 0x1], - '5' => &[0x7, 0x4, 0x7, 0x1, 0x7], - '6' => &[0x7, 0x4, 0x7, 0x5, 0x7], - '7' => &[0x7, 0x1, 0x1, 0x1, 0x1], - '8' => &[0x7, 0x5, 0x7, 0x5, 0x7], - '9' => &[0x7, 0x5, 0x7, 0x1, 0x7], - 'A' => &[0x7, 0x5, 0x7, 0x5, 0x5], - 'B' => &[0x6, 0x5, 0x6, 0x5, 0x6], - 'C' => &[0x7, 0x4, 0x4, 0x4, 0x7], - 'D' => &[0x6, 0x5, 0x5, 0x5, 0x6], - 'E' => &[0x7, 0x4, 0x6, 0x4, 0x7], - 'F' => &[0x7, 0x4, 0x6, 0x4, 0x4], - 'G' => &[0x7, 0x4, 0x5, 0x5, 0x7], - 'H' => &[0x5, 0x5, 0x7, 0x5, 0x5], - 'I' => &[0x7, 0x2, 0x2, 0x2, 0x7], - 'J' => &[0x1, 0x1, 0x1, 0x5, 0x2], - 'K' => &[0x5, 0x5, 0x6, 0x5, 0x5], - 'L' => &[0x4, 0x4, 0x4, 0x4, 0x7], - 'M' => &[0x5, 0x7, 0x5, 0x5, 0x5], - 'N' => &[0x5, 0x5, 0x5, 0x5, 0x5], - 'O' => &[0x7, 0x5, 0x5, 0x5, 0x7], - 'P' => &[0x7, 0x5, 0x7, 0x4, 0x4], - 'Q' => &[0x7, 0x5, 0x5, 0x7, 0x1], - 'R' => &[0x7, 0x5, 0x6, 0x5, 0x5], - 'S' => &[0x7, 0x4, 0x7, 0x1, 0x7], - 'T' => &[0x7, 0x2, 0x2, 0x2, 0x2], - 'U' => &[0x5, 0x5, 0x5, 0x5, 0x7], - 'V' => &[0x5, 0x5, 0x5, 0x5, 0x2], - 'W' => &[0x5, 0x5, 0x5, 0x7, 0x5], - 'X' => &[0x5, 0x5, 0x2, 0x5, 0x5], - 'Y' => &[0x5, 0x5, 0x2, 0x2, 0x2], - 'Z' => &[0x7, 0x1, 0x2, 0x4, 0x7], - ':' => &[0x0, 0x2, 0x0, 0x2, 0x0], - '.' => &[0x0, 0x0, 0x0, 0x0, 0x2], - ',' => &[0x0, 0x0, 0x0, 0x2, 0x4], - '!' => &[0x2, 0x2, 0x2, 0x0, 0x2], - '?' => &[0x7, 0x1, 0x2, 0x0, 0x2], - ' ' => &[0x0, 0x0, 0x0, 0x0, 0x0], - '|' => &[0x2, 0x2, 0x2, 0x2, 0x2], - '/' => &[0x1, 0x1, 0x2, 0x4, 0x4], - '(' => &[0x2, 0x4, 0x4, 0x4, 0x2], - ')' => &[0x2, 0x1, 0x1, 0x1, 0x2], - '>' => &[0x4, 0x2, 0x1, 0x2, 0x4], - '<' => &[0x1, 0x2, 0x4, 0x2, 0x1], +pub fn glyph_for_char(c: char) -> &'static [u8; HW_FONT_HEIGHT] { + match c { + '0' => &[0x3E, 0x41, 0x45, 0x49, 0x41, 0x3E], + '1' => &[0x08, 0x18, 0x08, 0x08, 0x08, 0x1C], + '2' => &[0x3E, 0x41, 0x01, 0x0E, 0x30, 0x7F], + '3' => &[0x7E, 0x01, 0x1E, 0x01, 0x41, 0x3E], + '4' => &[0x42, 0x42, 0x42, 0x7F, 0x02, 0x02], + '5' => &[0x7F, 0x40, 0x7E, 0x01, 0x41, 0x3E], + '6' => &[0x3E, 0x40, 0x7E, 0x41, 0x41, 0x3E], + '7' => &[0x7F, 0x01, 0x02, 0x04, 0x08, 0x08], + '8' => &[0x3E, 0x41, 0x3E, 0x41, 0x41, 0x3E], + '9' => &[0x3E, 0x41, 0x41, 0x3F, 0x01, 0x3E], + + 'a' => &[0x00, 0x3E, 0x01, 0x3F, 0x41, 0x3F], + 'b' => &[0x40, 0x40, 0x7E, 0x41, 0x41, 0x7E], + 'c' => &[0x00, 0x3E, 0x41, 0x40, 0x41, 0x3E], + 'd' => &[0x01, 0x01, 0x3F, 0x41, 0x41, 0x3F], + 'e' => &[0x00, 0x3E, 0x41, 0x7F, 0x40, 0x3E], + 'f' => &[0x0E, 0x10, 0x3E, 0x10, 0x10, 0x10], + 'g' => &[0x00, 0x3F, 0x41, 0x3F, 0x01, 0x3E], + 'h' => &[0x40, 0x40, 0x7E, 0x41, 0x41, 0x41], + 'i' => &[0x08, 0x00, 0x18, 0x08, 0x08, 0x1C], + 'j' => &[0x04, 0x00, 0x0C, 0x04, 0x44, 0x38], + 'k' => &[0x40, 0x42, 0x44, 0x78, 0x44, 0x42], + 'l' => &[0x18, 0x08, 0x08, 0x08, 0x08, 0x1C], + 'm' => &[0x00, 0x76, 0x49, 0x49, 0x49, 0x49], + 'n' => &[0x00, 0x7E, 0x41, 0x41, 0x41, 0x41], + 'o' => &[0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E], + 'p' => &[0x00, 0x7E, 0x41, 0x7E, 0x40, 0x40], + 'q' => &[0x00, 0x3F, 0x41, 0x3F, 0x01, 0x01], + 'r' => &[0x00, 0x5E, 0x61, 0x40, 0x40, 0x40], + 's' => &[0x00, 0x3F, 0x40, 0x3E, 0x01, 0x7E], + 't' => &[0x10, 0x10, 0x7C, 0x10, 0x10, 0x0E], + 'u' => &[0x00, 0x41, 0x41, 0x41, 0x43, 0x3D], + 'v' => &[0x00, 0x41, 0x41, 0x22, 0x22, 0x1C], + 'w' => &[0x00, 0x41, 0x49, 0x49, 0x55, 0x22], + 'x' => &[0x00, 0x41, 0x22, 0x1C, 0x22, 0x41], + 'y' => &[0x00, 0x41, 0x41, 0x3F, 0x01, 0x3E], + 'z' => &[0x00, 0x7F, 0x02, 0x0C, 0x10, 0x7F], + + 'A' => &[0x3E, 0x41, 0x41, 0x7F, 0x41, 0x41], + 'B' => &[0x7E, 0x41, 0x7E, 0x41, 0x41, 0x7E], + 'C' => &[0x3E, 0x41, 0x40, 0x40, 0x41, 0x3E], + 'D' => &[0x7E, 0x41, 0x41, 0x41, 0x41, 0x7E], + 'E' => &[0x7F, 0x40, 0x7C, 0x40, 0x40, 0x7F], + 'F' => &[0x7F, 0x40, 0x7C, 0x40, 0x40, 0x40], + 'G' => &[0x3E, 0x41, 0x40, 0x4F, 0x41, 0x3E], + 'H' => &[0x41, 0x41, 0x7F, 0x41, 0x41, 0x41], + 'I' => &[0x7F, 0x08, 0x08, 0x08, 0x08, 0x7F], + 'J' => &[0x01, 0x01, 0x01, 0x41, 0x41, 0x3E], + 'K' => &[0x41, 0x42, 0x7C, 0x42, 0x41, 0x41], + 'L' => &[0x40, 0x40, 0x40, 0x40, 0x40, 0x7F], + 'M' => &[0x41, 0x63, 0x55, 0x49, 0x41, 0x41], + 'N' => &[0x41, 0x61, 0x51, 0x49, 0x45, 0x43], + 'O' => &[0x3E, 0x41, 0x41, 0x41, 0x41, 0x3E], + 'P' => &[0x7E, 0x41, 0x41, 0x7E, 0x40, 0x40], + 'Q' => &[0x3E, 0x41, 0x41, 0x49, 0x45, 0x3F], + 'R' => &[0x7E, 0x41, 0x41, 0x7E, 0x42, 0x41], + 'S' => &[0x3F, 0x40, 0x3E, 0x01, 0x41, 0x3E], + 'T' => &[0x7F, 0x08, 0x08, 0x08, 0x08, 0x08], + 'U' => &[0x41, 0x41, 0x41, 0x41, 0x41, 0x3E], + 'V' => &[0x41, 0x41, 0x41, 0x22, 0x22, 0x1C], + 'W' => &[0x41, 0x41, 0x49, 0x55, 0x63, 0x41], + 'X' => &[0x41, 0x22, 0x1C, 0x1C, 0x22, 0x41], + 'Y' => &[0x41, 0x22, 0x1C, 0x08, 0x08, 0x08], + 'Z' => &[0x7F, 0x02, 0x04, 0x08, 0x10, 0x7F], + + ':' => &[0x00, 0x08, 0x08, 0x00, 0x08, 0x08], + '.' => &[0x00, 0x00, 0x00, 0x00, 0x18, 0x18], + ',' => &[0x00, 0x00, 0x00, 0x00, 0x18, 0x10], + '!' => &[0x08, 0x08, 0x08, 0x08, 0x00, 0x08], + '?' => &[0x3E, 0x41, 0x01, 0x0E, 0x00, 0x08], + + ' ' => &GLYPH_SPACE, + + '|' => &[0x08, 0x08, 0x08, 0x08, 0x08, 0x08], + '/' => &[0x01, 0x02, 0x04, 0x08, 0x10, 0x40], + '\\' => &[0x40, 0x10, 0x08, 0x04, 0x02, 0x01], + '(' => &[0x04, 0x08, 0x10, 0x10, 0x08, 0x04], + ')' => &[0x10, 0x08, 0x04, 0x04, 0x08, 0x10], + '>' => &[0x20, 0x10, 0x08, 0x10, 0x20, 0x00], + '<' => &[0x02, 0x04, 0x08, 0x04, 0x02, 0x00], + '-' => &[0x00, 0x00, 0x7F, 0x00, 0x00, 0x00], + '_' => &[0x00, 0x00, 0x00, 0x00, 0x00, 0x7F], + '+' => &[0x00, 0x08, 0x08, 0x3E, 0x08, 0x08], + '=' => &[0x00, 0x00, 0x3E, 0x00, 0x3E, 0x00], + '*' => &[0x00, 0x22, 0x14, 0x7F, 0x14, 0x22], + '#' => &[0x14, 0x14, 0x7F, 0x14, 0x7F, 0x14], + '%' => &[0x61, 0x62, 0x04, 0x08, 0x13, 0x23], + '@' => &[0x3E, 0x41, 0x5D, 0x55, 0x5E, 0x40], + _ => &GLYPH_UNKNOWN, } } @@ -798,9 +864,23 @@ impl Gfx { pub fn draw_text(&mut self, x: i32, y: i32, text: &str, color: Color) { let mut cx = x; + let mut cy = y; + for c in text.chars() { - self.draw_char(cx, y, c, color); - cx += 4; + match c { + '\n' => { + cx = x; + cy += HW_FONT_ADVANCE_Y as i32; + } + '\r' => {} + '\t' => { + cx += (HW_FONT_ADVANCE_X * 4) as i32; + } + _ => { + self.draw_char(cx, cy, c, color); + cx += HW_FONT_ADVANCE_X as i32; + } + } } } @@ -811,25 +891,32 @@ impl Gfx { let screen_w = self.w as i32; let screen_h = self.h as i32; - if x >= screen_w || y >= screen_h || x + 3 <= 0 || y + 5 <= 0 { + + let glyph_w = HW_FONT_WIDTH as i32; + let glyph_h = HW_FONT_HEIGHT as i32; + + if x >= screen_w || y >= screen_h || x + glyph_w <= 0 || y + glyph_h <= 0 { return; } let glyph = glyph_for_char(c); let raw = color.0; - let row_start = (-y).clamp(0, 5) as usize; - let row_end = (screen_h - y).clamp(0, 5) as usize; - let col_start = (-x).clamp(0, 3) as usize; - let col_end = (screen_w - x).clamp(0, 3) as usize; + let row_start = (-y).clamp(0, glyph_h) as usize; + let row_end = (screen_h - y).clamp(0, glyph_h) as usize; - for (row_idx, row) in - glyph.iter().enumerate().skip(row_start).take(row_end.saturating_sub(row_start)) - { + let col_start = (-x).clamp(0, glyph_w) as usize; + let col_end = (screen_w - x).clamp(0, glyph_w) as usize; + + for row_idx in row_start..row_end { + let row = glyph[row_idx]; let py = (y + row_idx as i32) as usize; let base = py * self.w; + for col_idx in col_start..col_end { - if (row >> (2 - col_idx)) & 1 == 1 { + let bit = HW_FONT_WIDTH - 1 - col_idx; + + if ((row >> bit) & 1) != 0 { let px = (x + col_idx as i32) as usize; self.back[base + px] = raw; } diff --git a/crates/console/prometeu-system/src/programs/prometeu_hub/prometeu_hub.rs b/crates/console/prometeu-system/src/programs/prometeu_hub/prometeu_hub.rs index e6aa0479..89e30089 100644 --- a/crates/console/prometeu-system/src/programs/prometeu_hub/prometeu_hub.rs +++ b/crates/console/prometeu-system/src/programs/prometeu_hub/prometeu_hub.rs @@ -252,11 +252,7 @@ fn draw_button(gfx: &mut dyn GfxBridge, rect: Rect, label: &str, hovered: bool) } fn draw_buffer_text(gfx: &mut dyn GfxBridge, x: i32, y: i32, text: &str, color: Color) { - let mut cx = x; - for ch in text.chars() { - gfx.draw_char(cx, y, ch, color); - cx += 4; - } + gfx.draw_text(x, y, text, color); } #[cfg(test)]