Also Featured on Hack A Day! Wow! I’m flattered!
If you live anywhere in the world (except the US maybe) you may have seen one of these:
You can seem to find them in any place that sells imported crap from China, usually along with more traditional Famicom clones like the Polystation with its countless variations and piles of pirate cartridges. They can be yours for 10 to 20 US dollars, complete with two joypads, a light gun, a mouse and an operating system cartridge.
These are basically another Famicom clone with a keyboard built in. They tend to come with “educational” software like typing and math games, sometimes they even come with a mediocre knockoff of a popular graphical operating system like Microsoft™ Windows, and of course a plethora of unlicensed 1st generation Famicom games.
One of the peculiarities is that they usually come with word processing software. If you’ve actually used it you’ll notice that the software contains a Print option in its menus, and if you select it the computer seems to try to establish a connection with a printer. You might be wondering why is that even there, since these cheap computer knockoffs don’t have any means of interfacing with other devices save for game controllers (they can’t even save your data!). You might have heard vague legends about some of these machines actually having a built-in printer port, but they’re nowhere to be seen. Until now!
I managed to score this one in 2008 for the whole sum of US$2 by wandering around on a local street market. It didn’t come with any hookups, controllers or software but I was able to get those pretty quickly. It seems like your average vanilla Famicom Keyboard clone, until you take a look at the rear ports:
Power input, A/V outputs, RF out and… DB-25 parallel port?!
This is one of the legendary Famiclones with printer ports! I hooked it up to an old dot matrix printer that had a standard PC parallel port interface and I was able to print out text from the word processing software. I even recorded a video of it in action and uploaded it to YouTube. Here it is, printing text in all its 8 bit glory:
This is really cool for a crappy clone of an 8 bit gaming system that took over the world and that I happen to love so much, but aside from the cool factor the usefulness of this is pretty limited. The computers are packed with crappy software, they don’t have any means of saving user generated data and the word processing software is primitive at best. It’s a cool little gadget if you’re into retro gaming and pirate crap, but aside from that it spends most of its days in storage.
Then I stumbled across the PLAYPOWER Project, a global open source community that aims to create useful software for these Famicom clone computers as a means to bring computer literacy to the emerging middle class in developing countries, by taking advantage of the ubiquity and low price point of these devices. Coupled with the right software, these inexpensive machines could become effective learning tools and help transform the economy of developing families around the world. Here’s a 5 minute video that explains everything in great detail.
Actually, I didn’t stumble across the project. I was contacted by Derek himself through a YouTube message. He asked me if I would like to get involved in the project, and sure I’d like to! But I’m not a programmer or a graphic designer or a learning specialist. My skills are hardware and electronics oriented. One of my hobbies is retro gaming, with a special interest (or should I say obsession) on the Nintendo Famicom. There must be something I could do for such a great project. It got myself thinking for a few days when I finally remembered about that Famicom keyboard clone with a printer port that I have somewhere.
Printing on the $12 computer?
As useless as it might seem, having a means to connect a standard printer could be a great enhancement to these cheap 8 bit computers. If you don’t have access to word processing, being able to type and print out your resume in one of these could make a big difference in getting you accepted for a job, for example. We tend to take word processing for granted these days, it has become such an integral part of our lives, but it’s still a luxury for a large portion of the world’s population. I’m not that much of a writer, but even I’m able to notice that a computer can help you set your creative mind free, as some sort of ‘mind accelerator’.
Technically speaking, the printer interface is an addon to the standard Famicom core system. Since the Chinese manufacturers’ ultimate goal is to keep costs down, the interface is probably done in the simplest way possible, with a minimum of external components and most likely doing the bulk of the work in software. Unfortunately it’s not very easy to find keyboard Famiclones with printer ports, and thus there’s no information about their inner workings. Since I own one of these and I have the knowledge and the skills to reverse engineer the printer interface, I can come up with detailed documentation that could prove to be very useful for the PLAYPOWER project.
Getting to know the interface
Based on my previous assumptions, by removing the cover of the keyboard Famiclone I should find a simple electronic circuit to interface the printer port with the main system, using the bare minimum of hardware components and most likely doing the communication protocol in software, in order to keep costs down.
The main Famicom board is in the center, the power, video and keyboard interface in the far right and the printer interface is in the left side of the machine, interconnected together by ribbon cables of various sizes. The keyboard itself is a standard conductive membrane matrix, just like in any modern PC keyboard. Let’s take a closer look at the printer interface:
Turns out I was right! The interface was done in the simplest way possible! The hardware itself consists of two standard TTL logic chips and one capacitor, and it communicates with the main Famicom board using the same data and control lines used by the game cartridge slot, eliminating the need for costly expansions to the base hardware.
Further analysis reveals that the chips only buffer the data from the CPU data bus and make it available on the parallel port, proving my theory that most of the hard work is done in software. This is great news for the PLAYPOWER people. The port is completely software controlled, this means that a programmer can take advantage of it and design a better featured word processing software (with the right code it could even print out graphics), or even create programs to interface with other kinds of hardware besides printers!
After a couple of hours of probing around with the multimeter and drawing terrible diagrams, I was able to come up with a full schematic of the interface and some basic notions of how it works on the software side.
A non-messy version of the schematic and full documentation follows.
Famicom Compatible Printer Port Interface
Here’s the full schematic of the hardware interface:
Pin numbers on the signal lines correspond to the Famicom cartridge port, unless noted with the LPT prefix, in that case they correspond to the pins on the DB-25F connector. Complete pinouts and more info can be found here:
There are two glue logic chips in the interface. IC1 is a 74HC138, which is a 3-to-8 line multiplexer with inverted outputs and multiple enable pins. This is used as an address decoder for the parallel interface. IC2 is a 74LS273, which is an octal D-type flip flop with common clock and clear inputs. The flip flops store the actual data that goes into the printer port, as instructed by the address decoder logic. Given the intrinsic characteristics of the flip flops, the port is strictly unidirectional.
Clocking the flip flops stores the currently present byte in the PRG ROM data lines and makes it available on the parallel port’s data pins. To avoid ‘garbage’ data from reaching the port, the flip flops are clocked only under certain conditions. The 680pF capacitor seems to smooth out possible glitches in the clock signal.
In order to drive a standard PC parallel printer, the data byte must be made available on the data pins, the Busy line (Pin 11) must be monitored to check if the printer is busy (if it is it won’t accept any data). If the printer is not busy, then the Strobe line (Pin 1) goes low for a short time to signal that a valid byte is present in the port. The printer will indicate that it is busy processing data via the Busy line. Other control signals exist but these are the bare minimum to engage a successful communication between computer and printer.
The address decoder responds to two specific patterns in the CPU address range, by monitoring the highest address lines (A11 through A14), the PRG /CE signal and the Phi2 clock signal. One address will clock the flip flops in IC2, storing the current data byte and making it available at the printer port, this will be called writing to the port from now on. The other address produces a low state in the Strobe line, in order to signal the printer that there’s valid data in the port, this will be called strobing the port. Here’s a clever bit of Chinese engineering: The monitoring of the Busy line is done by the Serial Data line from Controller port 1. Since this pin is an active-low input and the Busy signal is active low too, it seems like a perfect candidate for the job. Pin 11 of the printer port thus hooks up directly with controller 1′s data input. Other lines like /Autofeed and /Select are permanently tied low at the DB-25F connector. The rest of the control lines are simply left unconnected.
In order to write or strobe the port, the following conditions must be fulfilled:
- PRG A12 and A13 must be low.
- PRG /CE must be high (ROM access needs to be disabled to avoid bus conflicts).
- Phi2 clock must be high (I think this is related with how the CPU accesses data from the bus).
PRG A11 and A14 are used for the actual address decoding. The actual port addresses are:
- $800 – Write to the port.
- $4800 – Strobe the port.
Address lines A0 through A10 are ignored by the interface, so the actual address ranges for write and strobe are $800 to $FFF and $4800 to $4FFF, respectively. Both fall well under the PRG ROM address space. I’m not a NES developer so I’m not fond of the intricate details of the Famicom CPU addressing space, but it seems that both of these addresses are unused in standard conditions.
A write to $800 will store the current byte on the CPU data bus and present it to the parallel port, a write to $4800 will assert a Strobe (pull the line low). A write elsewhere will de-assert the Strobe (pull it high), and checking the state of the Busy line is done by reading Bit 0 of $4016 (Joypad Input Register 0).
Notes about the Interface: It has been observed that plugging in the printer sometimes disables operation of the keyboard and possibly the controller. I haven’t investigated further but it seems that it’s due to the Busy line keeping the controller data pin low. In that case, a switch could be fitted to disable this pin but a simpler solution is to plug in the printer only when you’re going to print something.
And there you have it. An 8 bit parallel port with two control lines and the communication protocol totally done in software. With the information above you could perfectly implement a parallel port for connecting a printer into keyboard Famiclones without the port built-in, other types of Famicom clones, an original Famicom or even a NES (though the usefulness of the latter is really questionable). Given the electrical characteristics of the interface, a cartridge pass-through adapter could be designed to add printer port functionality to any Famiclone computer just by plugging it into the cartridge slot, putting the game cartridge on top and running a cable to the first controller port.
For the programmer types, it gets a whole lot more interesting. Having total control over the comm protocol, there are no hard limits on what can be done. A ‘better’ word processor could print out more than just plain text. Software could control other things besides printers. A bit banged serial interface could be created by using the Strobe line and one or two data bits. Bi-directionality can be provided through the Busy input. This has the potential to be the solution to the problem of not being able to save user data on the computer. Hobbyists have been using comm ports to control various devices since the dawn of computing, this could be “The” port that would enable the same for the $12 computer platform.
My best wishes to the PLAYPOWER project. This was just my two cents to help build a better world 8 bits at a time! But this is only the beginning, I’ll be contributing to the project in any way I can!