I cannot believe I'm writing this. On an absolute whim, I found the source code to Sega's Saxman compressor, used for Sonic 2's sound engine and music files. Saxman is not completely custom: it's based on some public-domain Japanese LZSS code from 1989, by Haruhiko Okumura. The only modification, to my knowledge, is the addition of Saxman's unique ability to compress runs of 00 bytes - this is a mere eight-line edit. You can find the code here, in a file called "LZSS.C": https://web.archive.org/web/1999020...edu/pub/simtelnet/msdos/arcutils/lz_comp2.zip Here's the modification to make it produce zero-run matches: Code (Text): void InsertNode(int r) /* Inserts string of length F, text_buf[r..r+F-1], into one of the trees (text_buf[r]'th tree) and returns the longest-match position and length via the global variables match_position and match_length. If match_length = F, then removes the old node in favor of the new one, because the old one will be deleted sooner. Note r plays double role, as tree node and position in buffer. */ { int i, p, cmp; unsigned char *key; cmp = 1; key = &text_buf[r]; p = N + 1 + key[0]; rson[r] = lson[r] = NIL; match_length = 0; for ( ; ; ) { if (cmp >= 0) { if (rson[p] != NIL) p = rson[p]; else { rson[p] = r; dad[r] = p; return; } } else { if (lson[p] != NIL) p = lson[p]; else { lson[p] = r; dad[r] = p; return; } } /* NEW CODE START */ if (ftell(infile) < 0xFFF - THRESHOLD) { for (i = 0; i < F; i++) if ((cmp = key[i] - 0) != 0) break; if (i > match_length) { match_position = 0xFFF - F - THRESHOLD; if ((match_length = i) >= F) break; } } /* NEW CODE END */ for (i = 1; i < F; i++) if ((cmp = key[i] - text_buf[p + i]) != 0) break; if (i > match_length) { match_position = p; if ((match_length = i) >= F) break; } } dad[r] = dad[p]; lson[r] = lson[p]; rson[r] = rson[p]; dad[lson[p]] = r; dad[rson[p]] = r; if (rson[dad[p]] == p) rson[dad[p]] = r; else lson[dad[p]] = r; dad[p] = NIL; /* remove p */ } I still can't believe this... I never thought I'd see this code in my life. Just this morning, I started writing my own Saxman compressor, in the hopes of making it able to produce files identical to the original (so far, every community-made Saxman compressor is inaccurate), but I hit a brick wall when I realised the original files have no pattern to how they select dictionary-matches - sometimes they use the earliest data in the file, sometimes they use the latest, and sometimes they use data in the middle, even when there's perfectly good data before and after. Having been stumped by this issue, I decided to check-out an old 1989 compressor I read about on Wikipedia, to see how devs would compress LZSS files back-in-the-day. To my absolute amazement, I saw the compression format shared numerous similarities with Saxman - heck, even the decompressor shared similarities with the 68k/Z80 ASM decompressors used in Sonic 2: just look at how they detect when the descriptor field is empty! LZSS.C: Code (Text): if (((flags >>= 1) & 256) == 0) { if ((c = getc(infile)) == EOF) break; flags = c | 0xff00; /* uses higher byte cleverly */ } /* to count eight */ Sonic 2's 68k decompressor: Code (Text): lsr.w #1,d6 ; Next descriptor bit btst #8,d6 ; Check if we've run out of bits bne.s + ; (lsr 'shifts in' 0's) jsr SaxDec_GetByte(pc) move.b d0,d6 ori.w #$FF00,d6 ; These set bits will disappear from the high byte as the register is shifted + Sonic 2's Z80 decompressor: Code (Text): srl c ; c >> 1 (active control byte) srl b ; b >> 1 (just a mask that lets us know when we need to reload) bit 0,b ; test next bit of 'b' jr nz,+ ; if it's set, we still have bits left in 'c'; jump to '+' ; If you get here, we're out of bits in 'c'! call zDecEndOrGetByte ; get next byte -> 'a' ld c,a ; a -> 'c' ld b,0FFh ; b = FFh (8 new bits in 'c') + And, yes, it produces identical files. You know... for years, I've wanted to know the real names of the various compression formats used in the Mega Drive Sonic games. Time after time we've come so close, be it through leaked function names in Sonic 2's Nick Arcade prototype, leftover compilation data in Sonic & Knuckles Collection, or a complete symbol-list in Sonic CD PS2. Each time, the names of the decompression functions were conveniently absent. At least now, we finally have some closure on Saxman - it doesn't have a name! It's just 'LZSS.C'... EDIT (2020/10/07): It turns out there's a much simpler way to make LZSS.C produce Saxman files: just change both uses of the ASCII space character to 0. I've updated Sega Retro's Saxman page with instructions.
So... it does indeed have a name, being just a small variation of LZSS. I mean, same as Sinclair Basic on the ZX Spectrum is just a small variation of Sinclair Basic on the ZX81 and they're called the same.
Late, I know, but looking at the C file for myself, alongside ValleyBell's comments on the equivalent SSRG thread, I noticed this line in the section that is now to be modified: As you have now noticed, replacing the space character (0x20) with zeroes (0x00) generates Saxman-compressed files. Makes sense: when dealing with plain text, spaces are the most common character you'll find, but with code, you see zeroes far more often. I imagine if there was a file that had a bunch of plaintext 1s in it, it would make more sense to change that space to a 1. At this point, I'd inclined to drop the Saxman name and just call it LZSS compression...
Saxman and Kosinski are both LZSS, so the name is more to differentiate Saxman from other LZSS variants than anything.
Besides which, he was the one who cracked it to begin with, so I think we should stick with the moniker in his honor.
That's an understatement. LZSS is a "general model", not really a "format", the theorem proposed by Lempel and Ziv (in 77/78), then further improved by Storer and Szymanski (in 82) provides the idea in a generic form, and does not provide thorough specifics for how the offset/length are stored, nor the marker to decide between using offset/length vs an uncompressed block (or in this case, an addition of a 00 blank). You would also have to specify the bit format in the name too, along with any prerequisites (such as a length or entropy setup for formats which have them), such a naming scheme can get out of hand given we have multiple compression formats which utilise the general model, something which would not have been a problem for a company with limit use of LZ given it's patent history at the time, and could lightly name their file "LZSS.c" without giving much of a damn. Furthermore, Blastfrog's got the right idea. We name these compressions the same way scientists name elements, the person who cracks the format gets to name it, or it becomes named after them through casual communication, "We need to decompress this file, it's in that format Saxman cracked, yeah, in Saxman's compression...". Chemistry would be interesting if we renamed Chlorine to "Hologen 2" or Iron to "Element C8R4" suddenly after all these years, doing the same to the KENS family seems unnecessary.
Admittedly, I'm new to this compression thing, which may have limited my understanding of what was going on, but here's what I'm getting from this: LZSS is a method while Kosinski and Saxman are implementations of that method. I guess, alternatively, this would be akin to LZSS being an element with Kosinski and Saxman being isotopes thereof. Thanks for the heads up. I guess my concern was against acting like Saxman was its own format when its actual nature was discovered... but you know what? Okumura didn't name his name anything beyond LZSS.C, and I imagine Sonic 2's source code probably just says "songdecode" or something, so I won't go telling people not to call it Saxman (not that I had planned to).