diff options
Diffstat (limited to '_log/matrix-digital-rain.md')
| -rw-r--r-- | _log/matrix-digital-rain.md | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/_log/matrix-digital-rain.md b/_log/matrix-digital-rain.md index e10593f..1a8d9cb 100644 --- a/_log/matrix-digital-rain.md +++ b/_log/matrix-digital-rain.md @@ -1,29 +1,29 @@ --- -title: 'Matrix rain: 2025 refactor' +title: Matrix rain (2022) refactor date: 2025-12-21 layout: post project: true thumbnail: thumb_sm.png --- -2022 version worked but had loose ends. Unicode support was -incomplete--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. +2022 version worked but had loose ends. Unicode support was incomplete—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. <video style="max-width:100%;" controls="" poster="poster.png"> <source src="matrix.mp4" type="video/mp4"> </video> -Moved phosphor decay into the 4th byte of the RGB union--should’ve done this -in 2022; What was I thinking. +Moved the phosphor decay factor into the 4th byte of the RGB union—should’ve +done this in 2022; What was I thinking. -Kept the RGB union. Portability not a concern. All my systems are little-endian -and the code is cleaner this way. +Kept the RGB union. Portability is not a concern. All my systems are +little-endian and the code is cleaner this way. -Fixed Unicode by introducing a charset array. UNICODE(min, max) macro 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: +Fixed Unicode issues by introducing a charset array and a macro that packs +Unicode ranges into 64-bit unsigned integers: low four bytes for start, high +four bytes for end. insert_code() unpacks a random block and picks a character +from it: ``` #define UNICODE(min, max) (((uint64_t)max << 32) | min) @@ -47,9 +47,9 @@ static inline void insert_code(matrix *mat, ``` Full-width Katakana breaks column alignment. Stick to half-width -(U+FF61-U+FF9F) range. Compile with -DNOKANA to disable Katakana altogether. +(U+FF61-U+FF9F) range. Added -DNOKANA flag to disable Katakana altogether. -blend() for screen decay is still good. Left it alone: +blend() function is still good. Left it alone: ``` static inline void blend(matrix *mat, @@ -64,7 +64,7 @@ static inline void blend(matrix *mat, } ``` -Optimized RNG--xorshift instead of rand(): +Replaced rand() with xorshift: ``` static inline uint32_t xor(void) @@ -78,10 +78,10 @@ static inline uint32_t xor(void) } ``` -NOTE: Non-linear variants (xorshitr+) for more speed. +Came across faster non-linear variants (xorshiftr+). Xorshift was good enough. -Tossed license and automake cruft. Just `cc -O3 main.c -o matrix` now. Don't -need the ceremony. +Tossed the license and the 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. |
