Grauw’s web spot

Gunzip for MSX

October 18th, 2015

Lately I’ve been working on a gzip (.gz) decompression implementation for MSX, which as of yesterday is functional. Although I’ve been developing it for VGMPlay, I’ve implemented it as a stand-alone “gunzip” utility.

The gunzip project page is here:

The latest binary can be downloaded here:

And of course it is open source and liberally licensed, so you can reuse the code in any way you want.

I’m pretty happy with the end result because not only does it successfully decompress gzip files, it’s also pretty efficient in doing so. Here are some test results with the first disk of Aleste 2, comparing various decompression formats for MSX:

Test on Philips NMS 8245 MSX2 (openMSX) with Sunrise IDE:

  • gunzip 1.0 (244129 bytes): 133s
  • gunzip 1.1 (244129 bytes): 87s
  • pmext 2.22 (247552 bytes): 619s
  • lhext 1.33 (252614 bytes): 278s
  • tunzip 0.91 (247414 bytes): 341s

Test on Panasonic FS-A1GT turboR (openMSX) with Sunrise IDE:

  • gunzip 1.0 (244129 bytes): 26s
  • gunzip 1.0 (244129 bytes): 18s
  • pmext 2.22 (247552 bytes): 127s
  • lhext 1.33 (252614 bytes): 49s
  • tunzip 0.91 (247414 bytes): 46s

Note, this is just a test with a single file, however it shows the general trend. I’m pretty happy to see this result, it follows from the efficient approach I took to decoding the huffman tree.

Skipping the checksum verification further improves speed by 25% (turboR 20s 13s, MSX2 100s 55s), however I’ll let the code settle for a while before I expose that as a command line option.

Finally, I’ve tested with a fairly large set of gzip files, but if you encounter any errors, please send me the gz file to test with and I will fix it.

[Edit: Added gunzip 1.1 performance results.]


0 comments [reply]

Glass Z80 assembler

January 5th, 2014

My most recent side project is Glass, a Z80 assembler. It’s cross-platform, using the Java 7 runtime. The first version focused on getting it on par with other assemblers in terms of features. It supports regular and repetition macros, and block scopes. A little more advanced feature is that you can reference into scopes by using the dot (.). Recently I also added virtual space definitions and code sections.

In the future I’d like to add some more advanced features, which prompted me to make an assembler in the first place. Some ideas are extending macros to make them more useful for class definitions, multi-compiling procedures, static analysis, automatic optimisations, and debug output with timing information.

» Glass project page


0 comments [reply]

JavaScript enumeration pattern

September 25th, 2012

Although often better handled with subclasses and polymorphism, enumerations can be a convenient light-weight way to indicate some kind of state or non-boolean flag.

When one makes an enumeration in JavaScript, it is typically an old-fashioned list of constants with integer number values:

var MyEnum = {};
MyEnum.FIRST = 0;
MyEnum.SECOND = 1;
MyEnum.THIRD = 2;

A downside of this approach is that it is not type-safe; these values can not be distinguished from any other number. Additionally, it is possible to cheat by hardcoding a value somewhere, which makes code less readable and refactoring a lot harder.

There is a better way however:

function MyEnum() {}
MyEnum.FIRST = new MyEnum();
MyEnum.SECOND = new MyEnum();
MyEnum.THIRD = new MyEnum();

When one of these is passed to a method its type can be checked using instanceof or a function like checkTypes(). And because these are unique object references they are impossible to specify without using the constants.

Additionally, because this effectively defines a class it comes with a lot of power. E.g. you can pass meta-data and handy functions:

function MyEnum(name) { this._name = name; }
MyEnum.prototype.toString = function() { return this._name; };

MyEnum.FIRST = new MyEnum("FIRST");
MyEnum.SECOND = new MyEnum("SECOND");
MyEnum.THIRD = new MyEnum("THIRD");

Finally, as you discover you want to move more and more functionality onto this enumeration, it is easy to upgrade the enumeration to a full-fledged set of subclasses:

function First() {, "FIRST");
extend(MyEnum, First);

function Second() {, "SECOND");
extend(MyEnum, Second);

function Third() {, "THIRD");
extend(MyEnum, Third);


0 comments [reply]

Someone contacted me asking what sysex message to send to the Roland GAIA SH-01 synthesizer to request a MIDI dump of the patch parameters. This so that he could set up his DAW to record the dump, and play it back in a project to initialise the machine.

Let’s start by pointing out that Roland published a “GAIA SH-01 MIDI Implementation” manual on their US site, which basically contains all the necessary information. It can be found here:

» GAIA SH-01 :: Manuals :: Support :: Roland

In this case, we are looking for the “Data Request 1 RQ1 (11H)” message on page 4. Additionally, on page 8 we can find a number of tables which describe the Gaia’s internal memory layout. The topmost table tells us that the temporary patch address is 10 00 00 00 (note: 7-bit), and the second one that the patch content goes from 10 00 00 00 up to 10 00 1D 00.

So, to request a complete dump of the temporary patch, we want to request 1D 00 bytes starting at address 01 00 00 00. When we fill in the data request fields, we get a sysex message that looks like this:

F0 41 7F 00 00 41 11 10 00 00 00 00 00 1D 00 53 F7

If we send this message, the Gaia will respond with the complete patch contents, split up into 25 sysex messages (one for each parameter block).

Now all we have to do is record this response, and replay it to the Gaia when we want to restore it to this state. The input format is exactly the same as the format it outputs.

For an easy way to trigger this particular message in the Gaia Tool, go to the patch you want to dump, set your MIDI editor to record, and then press the “Reload” button at the top right of the temporary patch panel.


1 comment [reply]

Earlier posts
3D model animationsJanuary 14th, 201111
Introducing a Roland GAIA SH-01 toolDecember 7th, 201075
WhiskyJuly 13th, 201012
MSX Computer Magazine online archiveMay 2nd, 20100
Mercurial shallow clones and repository sizesApril 9th, 20107
Eclipse community awards finalistMarch 18th, 20101
The view port element is… which?February 16th, 20101
What’s wrong with feature detection?February 8th, 20100
Object-oriented programming in JavaScriptFebruary 1st, 20100
Saving time with MercurialJanuary 5th, 20102

» All blog entries…

» Blog feed