From 9b95f811472a15280e67f99c90c0013987b32ee2 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Fri, 26 Dec 2025 12:29:47 +0800 Subject: Technical notebook style. --- _site/log/matrix-digital-rain/index.html | 50 ++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to '_site/log/matrix-digital-rain/index.html') diff --git a/_site/log/matrix-digital-rain/index.html b/_site/log/matrix-digital-rain/index.html index 3d393cd..f254ed2 100644 --- a/_site/log/matrix-digital-rain/index.html +++ b/_site/log/matrix-digital-rain/index.html @@ -44,32 +44,52 @@

MATRIX RAIN: 2025 REFACTOR

21 DECEMBER 2025

-

Fixed the Unicode issue finally. Can now mix ASCII + Katakana.

+

The 2022 version worked but had some loose ends. Unicode support was +inflexible–couldn’t mix ASCII with Katakana; Phosphor decay was stored in a +separate array when it should’ve been packed with RGB; Code was harder to read +than it needed to be.

-

Moved Phosphor decay level into the 4th byte of the RGB union - should’ve done -this in 2022 instead of separate array. What was I thinking.

+

Moved phosphor decay into the 4th byte of the RGB union–should’ve done this +in 2022. What was I thinking.

-

Keeping the RGB/PD union as it is. I’m aware of the portability issues, but I’m -on a little-endian machine, and I’m the only one reading this anyway. It’s -cleaner.

+

Keeping the RGB union despite portability concerns. All my systems are +little-endian and the code is cleaner this way.

-

New charset array works. UNICODE(min, max) macro packs the range into uint64. -insert_code() unpacks block and picks random char.

+

Fixed Unicode by introducing a charset array. UNICODE(min, max) packs Unicode +ranges into uint64–low four bytes for start, high four bytes for end. +insert_code() unpacks a random block and picks a character from it:

-

Full-width Katakana breaks columns. Stick to half-width (U+FF61-U+FF9F) range . -Compile with -DNOKANA to disable Katakana altogether.

+
static uint64_t glyphs[] = {
+    UNICODE(0x0021, 0x007E), /* ASCII */
+    UNICODE(0xFF65, 0xFF9F), /* Half-width Katakana */
+};
+
-

blend() is still good, left it alone.

+

Full-width Katakana breaks column alignment. Stick to half-width +(U+FF61-U+FF9F) range. Compile with -DNOKANA to disable Katakana altogether.

-

Tossed license and automake cruft. Just cc -O3 main.c -o matrix. Don’t need -the ceremony.

+

blend() simulates phosphor decay by eroding RGB channels toward +background color:

-

Performance regressions: none. Runs like a charm on the T490. 2% CPU. No -whirring fans.

+
static inline void blend(matrix *mat, size_t row, size_t col)
+{
+    unsigned char *color = mat->rgb[index(mat, row, col)].color;
+    color[R] = color[R] - (color[R] - RGB_BG_RED) / DECAY_MPLIER;
+    color[G] = color[G] - (color[G] - RGB_BG_GRN) / DECAY_MPLIER;
+    color[B] = color[B] - (color[B] - RGB_BG_BLU) / DECAY_MPLIER;
+}
+
+ +

That’s still good. Leaving it alone.

+ +

Tossed license and automake cruft. Just cc -O3 main.c -o matrix now. Don’t +need the ceremony.

+ +

Runs at 2-3% CPU on OpenBSD (T490). No regressions. Fans are quiet.

Commit: 03f8d87

-- cgit v1.2.3