Wednesday 16 January 2013

Virtual MSX disk drive

When I was a kid I had an MSX, a SVI-728 to be more precise, it's just a Z80 based computer with 64Kb of RAM. Mine used cassette tapes to load games and the loading times were eternal not to mentioned all the loading errors that required restarting the load from the beginning.

Other friends of mine had an MSX with a disk drive but I got still stuck with the tapes :-(

So... Revenge! I decided to build my own disk unit :-)

MSX's with a disk drive come with a disk BIOS that handles all the disk operations, from the lowest level (i.e.: read sector 23) to extending BASIC with new commands to list the available files in the disk, formating, deleting and creating files, and so on.

My first step was to get a disk BIOS from a MSX with a disk unit and patch the sector reading/writing routine so instead of talking to a disk unit, it would talk to another device, an Arduino.

Unfortunately I can't fit an 720Kb disk in an Arduino but since it has a USB connection it can ask my PC to get that sector form an certain disk image in my PC's hard's disk and send it thought the USB cable.

For that I need some gluing hardware between the MSX and the Arduino, here is the pic of the setup

Breadboard with arduino-msx gluing logic

And here are the schematics of the interface:


The trick of the trade

It all works thanks to the Z80's /WAIT pin, when an IN or an OUT instruction happens for an port below 31 the logic gates put this pin to a low sate making the Z80 wait, the Arduino notices that and can fetch the data from the computer and put it onto the 74245 buffer, then the Arduino will raise the /WAIT pin to make the Z80 resume the execution so the OUT instruction gets the data from the buffer.

The software bit on the MSX side...

My computer didn't have a disk BIOS so I had to get one, fortunately Arjen Zeilemaker had disassembled some and put the asm code in sourceforge. All I had to do was to write the DSKIO function to talk with my arduino, the code was so simple that I just used notepad and worked on the second run. I took a game cartridge and replaced the game's ROM with an 16Kb EEPROM I got from EBAY. As for writing the EEPROM I used a reader/writer I built once as a quick hack, I used for that a ATMEGA128 since it has enough pins to driver teh 28 pins you need to set in order to write or read an EEPROM.

Simple flash memory reader on the top, game cartridge on the bottom

The two white cables sticking out of the Atmega128 are the serial port, I wont tell what are the black and red ones :-)

..and on the PC side

I just used Python to read the commands coming from them MSX, the script will take the 512 bytes sector and will send it to the arduino and 1Mbit per second. The Arduino will send byte by byte to the Z80 at a similar speed.

Here is the video, sorry for the shaky hand :-) On the left you have the python script, on the right VLC media player.

Source code! :)

Ok here are the sources, sorry I didn't document the code so much, please let me know if you have any questions.


  1. Hi, nice work. Still eagerly awaiting the "polished" docs you were gonna make on this :)

    best regards!

  2. This comment has been removed by a blog administrator.

  3. Hi,

    Please send me an email with the text of the autoexec.bat or. Bas or zipped files. Loved the menu to select games. Also'm bloger. I'm from Brazil and I still have a msx with an emulator diskettes (100 disks in one pendrive 720k).


  4. Hi Raul,

    I would like to get in touch with you, cause I'm interested on doing an article on this Arduino Project for the MSX.

    Please check my weblog


  5. Hi Raul,

    I recently aqcuired a couple of msx machines and really would like to have some drive for it. I probably could adapt your sketch to use a Arduindo SD card shield I've lying around. But I need to make a cartridge with the bios. Are there any schemas of the cartridge you used ? I have a cnc router for milling boards.
    What kind of eeprom is used ? Could I use a eeprom shield like this one ?

    Regards and best wishes.

    Luc De pauw


  6. Hi MegaMobile, I'm currently on holidays :) could you send me a reminder in a week so I can get back to you? As a quick response I used a game cartridge where I just replaced the eprom

  7. Amazing!

    Indeed the Wait signal was designed for being used like this.

    What about integrating the SD card library with your project and turn it into a disk drive emulator?

    Best regards!

  8. I mean, a standalone drive emulator :)

  9. Amazing job man!! it's excty what i was looking for.. pls when can I put the 11 and 10 Pins from arduino in order to get (iswriting/iswaiting function) ?
    tks in adv

    1. Hi! Thanks! The IsWriting should be connected to the /WR (or the /RD not sure!) and the is waiting to the /WAIT

  10. Hi Raul, thak you very much for this nice project!
    Do you have a cleaner documentation and a parlist used on the breadboard?
    I'm sorry to bother but i've some difficulties understanding the circuit schematic...

  11. Hey there!! amazing project here! actuallyI was looking for something similar to do using a rpi and yesterday I found you and YOU MAKE MY DAY! I'll learn how to use arduinos only for this. Thanks!!
    I have a couple of questions (surely caused by my lack of electronics knowledge):
    - as I understand, the mac files (z80 asm) you provided in your zip are the modified versions you wrote included on the DISK.ROM, isn't it?
    - In the pictures showing the connectings (the one with the breadboard) I see that you connect the arduino inouts to the secondary expansion port, and the disk rom to the first one. Can this be done in just one slot?

    Do you think that all this can be easily ported to a raspi? If its GPIO system there is enough? It would be nice to have all system in one single external board.


  12. I´ve been opening some of my cartridges looking for something similar to yours. I´ve only small ROM cartridges and Konami cartridges with a mapper.

    (like this , before adding a flash) Is it possible to do the same whith these cartridges??


  13. Hi Raul, nice project, I tried to implement it, but I fail. Then your project was the starting point for mine, Rookie drive. Take a look: (in spanish sorry)

    Thank you

  14. your schemmatic is incomplete, there is no line going to the arduino from the computer, so the arduino knows about a request. its a fake.

  15. to use roms<50k in msx , convert roms using Caslink3 to wav 320k
    and play it using vlc in andorid phone :D
    (using msx cas cable)
    i reencode it to mp3 and work, :D
    >.< need more info to your proyect :D