MSX Assembly Page

MSX-AUDIO music keyboard

The MSX-AUDIO Y8950 sound chip has a function for an external keyboard. All three MSX-AUDIO modules, the Philips NMS-1205 Music Module, the Toshiba HX-MU900 MSX Music System and the Panasonic FS-CA1 MSX-Audio have a connector for these. The Toshiba and Panasonic’s connectors are compatible; the Philips connector differs from the others.

The keyboards available for the Toshiba and Panasonic modules are the 49-key Toshiba HX-MU901, the Yamaha YK-10, YK-20 and the YK-01 (44 keys). For their Music Module Philips offered a 61-key music keyboard, the NMS-1160. As said, this one is not compatible with the other modules, even though the connector fits the pins are connected differently. Modified Commodore keyboards are also often used.

Reading the keyboard

The keys can be read in a matrix structure of 8x8 bits, which is accessed through the MSX-AUDIO registers at I/O ports 0C0H (address) and 0C1H (data). The address port is write-only, the data port can be read or written to depending on the selected register. A 12 cycle wait (at 3.58 Mhz) is required after all address and data writes.

Note that the Panasonic module has a switch which lets it listen at 0C2H and 0C3H, allowing two modules to be connected at the same time; the Philips and Toshiba modules can also be modified to provide such a switch. You may want to support this, but for this article we will assume the standard ports.

Register I/O Description
05H Read Row bits, 0 = pressed.
See below for the bit/key mapping.
06H Write Row selection, 1 = selected.
Set bit 0 to select row 0, bit 1 to select row 1, etc.

Refer to the MSX-AUDIO application manual for more details on writing / reading register data.

The key matrix is as follows:

Toshiba HX-MU901 and Yamaha YK-01/10/20 matrix
Row 0C 2F#2F 2E 2---D#2D 2C#2
Row 1---C 3B 3A#3---A 3G#2G 2
Row 2---F#3F 3E 3---D#3D 3C#3
Row 3---C 4B 4A#4---A 4G#3G 3
Row 4---F#4F 4E 4---D#4D 4C#4
Row 5---C 5B 5A#5---A 5G#4G 4
Row 6---F#5F 5E 5---D#5D 5C#5
Row 7---C 6B 6A#6---A 6G#5G 5
Philips NMS-1160 matrix
Row 0G 2F#2F 2E 2D#2D 2C#2C 2
Row 1D#3D 3C#3C 3B 3A#3A 3G#2
Row 2B 4A#4A 4G#3G 3F#3F 3E 3
Row 3G 4F#4F 4E 4D#4D 4C#4C 4
Row 4D#5D 5C#5C 5B 5A#5A 5G#4
Row 5B 6A#6A 6G#5G 5F#5F 5E 5
Row 6G 6F#6F 6E 6D#6D 6C#6C 6
Row 7---------C 7B 7A#7A 7G#6

As you can see, unfortunately not only the connectors are different but so are the keyboard matrices. This means that in order to support both, you have to provide a means of selecting which keyboard to use. This can be done in a menu, but can also be done by asking Toshiba and Yamaha keyboard users to press the highest note on their keyboard (C6). This bit is not available on the Philips, so if it gets flagged the software can recognise it is a Toshiba and switch automatically.

Who did it right? According to MSX-Datapack volume 2 section 4.1.4 (page 281), the Toshiba matrix is the official one. The MSX-AUDIO documentation describes yet another layout, but this is likely an editorial error.

As an aside, because the row selection is not exclusive, if multiple rows are selected the pressed notes will overlap each other. This can be used to do a quick check if any notes are pressed at all, and if not, skip the remaining processing.

The Toshiba HX-MU901’s Multi Sensor

Above the keybed, Toshiba also has a “Multi Sensor” with a capacitive ribbon control and two capacitive ENTER and STOP buttons. You might have pressed these and noticed that 8 keys will be flagged at a time. This is because these controls are on two additional rows, which are selected by default.

These two rows are controlled through the MSX-AUDIO’s “general purpose I/O ports”. These aren’t Z80 I/O ports but rather four additional I/O bits which can be accessed through MSX-AUDIO registers 18H and 19H. Toshiba uses bits 0 and 1 to select rows 8 and 9, which can then be read from register 05H.

Register I/O Description
18H Write General purpose I/O port direction control. Default: 0.
Use 00000011B to set the direction of ports 0 and 1 to output.
If an output port is set to input, it will always output 1.
19H Write General purpose I/O port data output.
Set bits 0 and 1 to select matrix rows 8 and 9.
05H Read Row bits, 0 = pressed.
See below for the bit/key mapping.

Whether these additional row bits are also hooked up on the Panasonic module, I don’t know. Also, on the Philips module bits 0 and 3 are used for different purposes (8-bit DAC enable and DAC/Y8950 output select), so you may want to avoid setting them if a Toshiba keyboard was not detected.

The additional matrix rows are as follows:

Toshiba HX-MU901 Multi Sensor matrix
Row 8Ribbon 1ENTERSTOPRibbon 6Ribbon 5Ribbon 4Ribbon 3Ribbon 2
Row 9Ribbon 7------Ribbon 12Ribbon 11Ribbon 10Ribbon 9Ribbon 8

The ribbon is divided into twelve sections, and each section can be pressed individually. So if you want to use it as a linear control you will probably want to average the values.

Also worth noting that there are enough unused bits in the normal key matrix, so technically there would have been no need to introduce these two additional rows.