From d2c9a7b88adae1e949af60b7f276364592e49869 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Thu, 25 Dec 2025 22:37:22 +0800 Subject: Matrix 1980s style. --- _log/matrix-digital-rain.md | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to '_log') diff --git a/_log/matrix-digital-rain.md b/_log/matrix-digital-rain.md index d4ea301..4958eed 100644 --- a/_log/matrix-digital-rain.md +++ b/_log/matrix-digital-rain.md @@ -6,39 +6,28 @@ project: true thumbnail: thumb_sm.png --- -Fixed the Unicode issue finally. Can now mix ASCII + Katakana. - -Took me 2 hours to decipher how this even works. For future me: mat.col[] -stores shuffled column indices, mat.row[] tracks last updated row per column. -shuffle() randomizes the working set, index i (line 333) and lines 364-370 draw -one column at a time, swap() rotates columns in and out. That's the rain. - -Moved Phosphor decay level into the LSB of the RGB union - should've done this -in 2022 instead of separate array. WTF was I thinking? - -Keeping the RGB/PD union as it is. I know the 'portability' nerds hate it, but -I’m on a little-endian machine, and I’m the only one reading this. It’s -cleaner. - -New charset array works. UNICODE(min, max) macro packs the range into uint64. -insert_code() picks random block, unpacks it, and picks random char. Elegant. - -Looks a lot like the original now: +Unicode support added. ASCII + Katakana working: -Using half-width Katakana (U+FF61-U+FF9F) because full-width characters break -columns. +Algorithm notes: mat.col[] = shuffled column indices, mat.row[] = last row per +column. shuffle() sets working set, main loop draws columns via index i (line +333), swap() rotates set. + +Phosphor decay moved to LSB of RGB union. Should have done this originally. + +RGB/PD union stays. Little-endian machine, portability not a concern. + +Charset via UNICODE(min, max) macro - packs range into uint64, insert_code() +unpacks and selects random char. -blend() is still good, left it alone. +Half-width Katakana (U+FF61-U+FF9F) for column alignment. -Tossed the license and automake cruft. Just `cc -O3 main.c -o matrix`. Don't -need the ceremony. +Removed license, automake files. Build: cc -O3 main.c -o matrix -Performance regressions: none. Runs like a charm on the T490. 2% CPU. No -whirring fans. +Performance: 2% CPU, OpenBSD, T490. Commit: [03f8d87](https://git.asciimx.com/matrix-digital-rain/commit/?id=03f8d87ba7c2e46bd3f3cc4c772fb3a2ac740c92) -- cgit v1.2.3