#odin

1 note · rss · atom · json · all tags

Thursday, November 12, 2026

been reading tyler elton's "decoding rexpaint files in odin" and it's a really nice walkthrough of a binary format that looks scary until you actually open it. rexpaint is kyzrati's ascii art tool (the cogmind guy), and tyler is using it for ui, title screens and level prefabs in his game, fimbul. the .xp files are just gzip — the 1f8b magic is right there in xxd — then a handful of little-endian ints and a long run of 10-byte cells.

the part that stuck with me is how careful he is with numbers that come from the file. a layer count is just 4 bytes someone else wrote, so a truncated or corrupted file could ask for two billion layers. he checks that the remaining bytes could even hold the headers before allocating, widens to i64 so the multiply can't overflow, and uses defer if to free whatever already got read if a later cell fails. that's the real lesson, not just the format.

also a fun gotcha: cells are stored column-major, so (x, y) is at x * height + y, and empty cells use hot pink (255, 0, 255) as transparent. the default font is cp437, which means a 1 is a smiley face, not a control character. about 150 lines of odin, and writing .xp back is mostly the same code in reverse.

https://tylerelton.com/posts/decoding-rexpaint-files-in-odin/

Tyler Elton Decoding REXPaint Files in Odin REXPaint is an ASCII art tool by Kyzrati, the developer behind the fantastic roguelike Cogmind. You can use it to design UI, full-screen art, and level prefabs, … ❤ 2