pouët.net

Go to bottom

Mashi - A compressor for JS/WASM 64k intros

category: code [glöplog]
 
Hi friends, I just released the first version of Mashi, which is a compressor for JS/WASM 64k intros. It is based on the core compression routines of Squishy by Ferris/Logicoma, which I'm sure most of you are familiar with.

It is intended as a replacement for Compeko or JsExe or any other kind of tool that relies on the browser's built-in Deflate implementation. I built it primarily for use for compression of WASM (with a tiny amount of JS needed for browser interop) and for that reason it adds a full WASM context model that really improves compression of those kinds of binaries. The decompressor is hand-written in WASM so if you're interested to see what hell looks like, check out "decompress.wat" in the repo linked below.

However, intros that are pure JS can also benefit, although in my unscientific testing the results varied. 0b5vr's 0mix intro went from 64k to 48k, but Luminosity by Bypass was almost unchanged. So YMMV.

Anyway, feel free to test it out. Binaries are available at https://github.com/datatrash/mashi/releases and the source code is at https://github.com/datatrash/mashi

It's all a bit untested (especially under Linux and on non-Chrome-based browsers), but I thought that with Revision coming our way it could already be of use to someone.

Btw, pull requests that reduce final binary size are of course very welcome :)

And a big shout out to Ferris for allowing me to use Squishy as a basis for this, obviously!
added on the 2026-02-14 12:38:35 by sagacity sagacity
Nice 👍
added on the 2026-02-14 12:53:34 by neoman neoman
👍
added on the 2026-02-15 11:55:46 by rc55 rc55
That 2.5k stub handwritten in .wat 😅
added on the 2026-02-15 12:27:07 by pestis pestis
Very cool!
added on the 2026-02-16 16:59:45 by tomkh tomkh
wtf
added on the 2026-02-16 17:05:48 by 0b5vr 0b5vr
Ahh it's context modeling based on Squishy, very very nice contribution. Would try this later
added on the 2026-02-16 17:08:13 by 0b5vr 0b5vr
Yes, to be clear, WASM compression has a lot of extra logic to improve compression. JS doesn't, but it should still be nice improvement over just Deflate.
added on the 2026-02-16 19:07:43 by sagacity sagacity
BB Image
added on the 2026-02-16 22:32:21 by wullon wullon
Wow, the handdone WASM based depacker is super impressive.

Reading the context modelling code for Squishy was super instructive. My code for my packer is just bog standard LZMA1, with a super tiny (500 bytes) x86/x64 depacker. Should port to ARM/68k/WASM.
added on the 2026-02-17 19:33:59 by ^ML!^ ^ML!^
@^ML!^: I'm fairly sure people would find that very suitable for 4k intros :)
added on the 2026-02-17 20:01:58 by sagacity sagacity
Quote:
@^ML!^: I'm fairly sure people would find that very suitable for 4k intros :)


I wonder how hard it would be to modify crinkler to allow for the depacker. That seems to be the goto standard for Windows compressing linkers these days.

Or even do a custom packer ala 1kpack, but specifically made for GL4.6 (bindless could help there). Linux is interesting in that there is solutions out there for that.
added on the 2026-02-17 20:41:16 by ^ML!^ ^ML!^
Nice!
Also sounds like a dutch MicroW8 thingy for easter to me...? ;)
added on the 2026-02-17 23:56:07 by hfr hfr
hfr: That would be inaccurate, I'm afraid :)
added on the 2026-02-18 14:22:03 by sagacity sagacity
very nice!

Quote:
can also be used for JS-only productions


can this work together, with other wasm stuff, like sointu ?
added on the 2026-02-20 18:44:34 by pandur pandur
@pandur, in theory, yes. Currently mashi always generates an index.html, but I could provide a 'raw mode' that just outputs a compressed WASM that you can call manually from your JS to depack.

Let me know if you want to discuss this further, or feel free to open a GitHub issue where we can hash this out :)
added on the 2026-02-23 09:59:59 by sagacity sagacity
Quote:
@pandur, in theory, yes. Currently mashi always generates an index.html, but I could provide a 'raw mode' that just outputs a compressed WASM that you can call manually from your JS to depack.

Let me know if you want to discuss this further, or feel free to open a GitHub issue where we can hash this out :)


I wonder if this could be extended to WASM in general, like even Emscripten. Not sure if Emscripten allows linking raw WASM modules with compiled C/C++ code, would be really nice.
added on the 2026-02-24 06:56:40 by ^ML!^ ^ML!^
Yay, excited for this! This could be the future of the size coding categories. Intros that people can download and see. Like in the old days.

Thanks for doing this, I'll be trying it.
added on the 2026-02-25 06:32:54 by iq iq
@iq: This was indeed my goal. I love 64k intros, but it's sad that they're getting increasingly difficult to watch (or even download, when they're flagged as malware). If this tool leads to 1% more people watching 64k intros it's a win :)
added on the 2026-02-25 09:52:31 by sagacity sagacity
Quote:
Yay, excited for this! This could be the future of the size coding categories. Intros that people can download and see. Like in the old days.

Thanks for doing this, I'll be trying it.


The influx of fantasy consoles helps a ton there as well, since its all WASM. I am hoping there is someway Enscriptem would be supported by the packer.
added on the 2026-02-25 17:13:46 by ^ML!^ ^ML!^
I guess if I provide a raw mode that just emits a WASM module then you can do whatever you like to run the depacker and get back the depacked WASM. I don't have any experience with Emscripten though, so I don't know exactly what your requirements would be. Feel free to open a GitHub issue with details.
added on the 2026-02-26 11:35:38 by sagacity sagacity
Quote:
Intros that people can download and see. Like in the old days.

It's a bit sad that the typical 4K is so rich with sharp details and then viewed almost exclusively through mediocre-to-bad video encodes. :-/
added on the 2026-02-26 12:25:46 by Sesse Sesse
Quote:
I guess if I provide a raw mode that just emits a WASM module then you can do whatever you like to run the depacker and get back the depacked WASM. I don't have any experience with Emscripten though, so I don't know exactly what your requirements would be. Feel free to open a GitHub issue with details.


I did some digging myself as I always wanted to get into fantasy consoles (since I don't have a real C64 with needed flashcart hardware or a Amiga at all, or a PAL N64 with Everdrive), and it seems Emscripten does its own "relocated" WASM modules. So it seems to be its own thing :/, unless WAT scripts could be compiled into such a module as part of the C/C++ process.
added on the 2026-02-27 02:17:49 by ^ML!^ ^ML!^

login

Go to top