From 884d0104b824eff3cc43b8c3794ba544ee18821b Mon Sep 17 00:00:00 2001 From: James Braid Date: Sat, 21 Nov 2026 19:45:05 -0700 Subject: [PATCH] gr2: use only the low byte of a textport colour OpenBSD's GR2 console sends PUC_COLOR as rasops' 8-bit colour with the index repeated in all four bytes (0x07070707 for index 7). PUC_COLOR loaded the low 12 bits into the red channel, 0x707, which the default pixel format clamps to 255. Every kernel message in OpenBSD 6.9's installer drew white glyphs on a white cell: white rectangles (#775). A textport pixel is one byte, so take the low byte. The PROM and NetBSD send small indices and are unaffected. Tested: a new unit test sends 0x07070707 and expects pixel 7, and fails without the change (255). OpenBSD 6.9's boot log is readable on an indigo2_ip28 with a GR2 XZ, white on blue. The GR2 PROM menu is byte-identical before and after. What the real microcode does with the upper bytes is inferred from OpenBSD working on real boards, not known. Fixes: 5d07b4d6b866 ("added gr2 support") --- src/dev/gr2/hq2.rs | 3 ++- src/dev/gr2/hq2_tests.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/dev/gr2/hq2.rs b/src/dev/gr2/hq2.rs index 496ec0ca9..804997075 100644 --- a/src/dev/gr2/hq2.rs +++ b/src/dev/gr2/hq2.rs @@ -1515,7 +1515,8 @@ impl Hq2Engine { match cmd { PUC_INIT => self.init(out), PUC_COLOR => { - out.reg(re3::REG_R, (a[0] & 0xfff) << 11); + // The pixel is one byte; OpenBSD repeats the index in all four (rasops). + out.reg(re3::REG_R, (a[0] & 0xff) << 11); out.reg(re3::REG_G, 0); out.reg(re3::REG_B, 0); } diff --git a/src/dev/gr2/hq2_tests.rs b/src/dev/gr2/hq2_tests.rs index c3540290d..83bbfc814 100644 --- a/src/dev/gr2/hq2_tests.rs +++ b/src/dev/gr2/hq2_tests.rs @@ -76,6 +76,20 @@ fn textport_clear_and_rect() { assert_eq!(pixel(g, 10, 22), 0); } +/// OpenBSD passes rasops' 8-bit colour, the index repeated in all four bytes. +#[test] +fn textport_color_uses_the_low_byte_as_the_pixel() { + let g = &live_gr2(Gr2Variant::Xz); + tp_init(g); + cmd(g, hq2::PUC_COLOR, 0x0707_0707); + cmd(g, hq2::PUC_RECTI2D, 10); + data(g, 20); + data(g, 12); + data(g, 21); + g.wait_idle(); + assert_eq!(pixel(g, 10, 20), 7); +} + #[test] fn textport_drawchar_places_glyph_bottom_row_first() { let g = &live_gr2(Gr2Variant::Xz);