A way to transfer MZF files quickly to your Sharp MZ using an Arduino board. The source and other tools are provided on as-is basis: don’t blame me if you foul your beloved 8-bit workhorse.
To use MZduino you need the following pieces of software and hardware:
- A host computer (duh) equipped with a supported operating system. I’ve provided binaries for Linux/x86 and Mac OS X/Intel, and the source should compile easily on any Unix-like POSIX system. A Windows version could probably be made, but I can’t do it myself — reader contributions are welcome.
- A Sharp MZ computer (duh). I’ve been testing on Sharp MZ-700 only, since it’s the only one I’ve got.
- An Arduino board and the Arduino IDE. I’ve tested the code only on Uno, but any recent board like a Mega or Duemilanove should do equally well.
- The cable between Arduino and Sharp. Connect the pins of joystick port 1 this way:
- Pin 5 (ground) to Arduino GND
- Pin 4 (JA2) to Arduino pin 13
- Pin 3 (JA1) to Arduino pin 12
- When looking at the rear of the Sharp the pins are in a descending order starting from 5. So start from the leftmost pin. Sharp joystick plugs are rare beasts, so I used a normal two-row 10-pin flat cable connector. It’ll fit if you file it a bit.
Download the latest MZduino package (see below), unpack it and go through the following steps:
- Upload mzduino.pde to the Arduino board. After this you can quit Arduino since the code will stay on the board even if you unplug it.
- Compile (if needed) the host software and copy it somewhere in the path.
- Upload the transfer software to your Sharp. I’ve provided an MZF of it, which can be recorded onto a tape or played back directly to the cassette port using appropriate tools. Alternatively, you can type the bytes in using the standard Sharp monitor commands. See sharp/mzduino.txt for instructions.
At this point we should be set up and ready to go. If you load the transfer program from a cassette, it’ll automatically start waiting for a file to arrive. Whenever you want to get back to the transfer mode, you can reset the Sharp (it won’t wipe out the program) and type either:
- JCF00 — Downloads a MZF file and starts it
- JCF04 — Downloads a MZF file and returns to the monitor. This is useful if you want to save the game or whatever on a tape.
On the host computer type mzduino blahblah.mzf to upload it to Sharp. At that point you should have started the receiver already. Usually there should be no reason to touch the Arduino board at all. If your Arduino isn’t in the default address, you can either give the port as the second parameter: mzduino blahblah.mzf /dev/ttyACM1, or edit the source and recompile. The host software will print some useful data when sending the file, most notably the parameters for the monitor’s save command.
There’s a simple checksum to catch transmission errors. If the checksum wasn’t ok the machine will reset. The program will still remain in the memory, don’t worry.
If you intend to use MZduino for software development, it’s a good idea to end your program with a JP $CF00. That way you can immediately upload and run an improved version of your program without extra typing.
Troubleshooting and improvements
There are plenty of caveats and things that could be improved. Here’ s a few that come to my mind right now:
- On Mac OS X there are two device files for Arduino Uno. For MZduino use the one with cu, not tty even if it works in the Arduino IDE.
- On Linux you might want to check out whether you have the right to use the serial device. In Uno’s case it’s called /dev/ttyACM0. At least on Ubuntu you need to be in the dialout group for things to work.
- The transfer speeds could be still improved by better optimization or even using both joyports at the same time. Currently I get something like 1.5 kcps. The SPEED constants I’ve used now are rather conservative, so you might want to try smaller values for your system.
- Since the communication is one-way the connection is inherently unreliable. Maybe some other port would do the trick better, but then you would need a more complex setup, too.
- I have no idea if it’ll work directly with an MZ-800. At least in the MZ-700 mode all should be fine. MZ-80 has less memory, so at least the code would need to relocated (does it even have a joystick port?).
- If you have an old Arduino, you might need to reset it after starting the transfer, so that setup() will be run.
- Loading files to S-BASIC is not supported at the moment. I might look into it at some point, but frankly, it’s of no great interest to me.
- At times there’s some unreliability, which seems to be Arduino-related. Resetting the board with the button seems to help. Gotta look into that.
MZduino 0.04. The first public release.