The original thread was authored in Brazilian Portuguese and published (on December 26th, 2016) at:
This translation into English was contributed by my friend Seth Schoen. Thanks, Seth!
(PATINHO FEIO
Built in 1971/1972
by the students at USP
being considered the
1st Brazilian computer)
I’ve already told a little tiny bit of this story in a post on my blog (in English) at:
http://mamedev.emulab.it/fsanches/2015/11/18/a-pleasant-visit-to-the-university/9
But here I’m going to go into further detail and try to recount everything that’s happened up to now, and, maybe, updates on the project’s next steps. This project concerns the historic preservation of the Patinho Feio [Portuguese: ‘Ugly Duckling’] computer, which was designed at the University of São Paulo (USP) in 1971.
In November 2015, I was very interested in 3D scanning arcade game cabinets and video game consoles, and, as a result, I went to USP to try to speak to somebody from LSI (the USP Integrated Systems Laboratory) or Caverna Digital, in the hope of finding a 3D scanner. I didn’t manage to find Prof. Roseli de Deus Lopes (from LSI) on that trip, but I ended up meeting Prof. João José Neto.
In the course of my conversation with Prof. JJNeto, I mentioned that I’ve already worked for several years as a volunteer on initiatives for the historic preservation of computers and video games (and, in fact, all sorts of digital devices) by means of emulation and that, in support of this, I’ve contributed to emulator implementations for the MAME Project.
I ended up showing the professor some of my MAME drivers and he, in return, handed me a document from 1977 called “Assembler for Patinho Feio”. It’s a user manual for an assembler program for the machine language of the Patinho Feio CPU. Since supposedly no other copy of this work was known to exist, I grew quite worried, because it was a nearly 40-year-old document that had been extremely well preserved up to that point. And now this rare artifact was being placed in my clumsy hands…
I was terrified! I ran home, taking care to protect the document, and I started the process of digitizing it the moment I got to my house. Since it didn’t fit in my scanner (the pages were a tiny bit bigger than standard A4 size), I simply took photos of each page with my phone. I saved all the photos in high resolution in a GitHub repository and then I made a little script to scale and compress the pages and then combine them into a PDF with reasonable quality and size. The resulting PDF was published on the Internet Archive and can be found here:
https://archive.org/stream/Montador_do_Patinho_Feio__Julho1977/PatinhoFeio
Next, I read through the document carefully and observed that it would be possible to use the information it contained to implement an emulator for the Patinho Feio’s CPU. But in order to test the emulator, I would need access to programs written for the machine. And at that point the only thing I had access to was a little “Hello World” whose machine code was readable in the photograph of a little strip of punched paper tape that appeared in a picture in the book itself.
I manually transcribed each byte from the tape in the picture, producing a file that could be loaded into my emulator, and then used this program to debug my implementation. This way, I managed to make the tiny program work in the emulator and see characters displayed on my screen which originally were sent to the teletype - a writing machine with a serial interface to communicate with the computer. The characters were being sent gradually one by one: P - A - T - I - N - H - O - [space] - F - E - I - O followed by a linefeed command (to advance the paper by one line) and then a carriage return (to make the print head return to the left corner of the page).
Emulation of the “Hello World” program
Using a technology called emscripten, I compiled the MAME driver to Javascript, which allows the emulator to run directly in a web browser. At that point I set up a web page to host this demo. You can see it here:
http://felipesanches.github.io/emuladores/patinho.html
Sometime later, I went back to the USP Polytechnic along with Armando Neto (one of our friend from here on Fiozera!), and we took some photos of the actual computer, which is on display nowadays in the administration building of the Polytechnic Institute.
Based on these photos, I redrew the entire panel in Inkscape (a free software application for vector art), and, now that I had a vector file of the panel artwork, I started building a replica of the Patinho Feio, outsourcing the laser cutting and printing of a sticker of the art to a printing bureau near my house.
Below you can see the vectorization of the front panel art:
The corresponding vector file is available here.
I bought red LEDs, buttons, and switches in the Santa Ifigênia neighborhood of São Paulo and added appropriate holes to the laser cutting schematic:
When I finished building the physical part of the front-panel replica, I took it for to Prof. JJNeto to see. It looks like he liked it:
Then I added a black picture frame, and nowadays the panel looks like this:
Over time, I’ve also been collecting autographs on the back of the panel from professors who were involved in the development of this project in the 1970s at USP:
In response to my original blog post about the discovery of the assembler manual, a friend added this comment:
Daniel Rosa Franzini
NOVEMBER 19, 2015 AT 9:47 AM
Juca,
In the the Electrical [Engineering] library there’s a section that nobody has ever looked at (except me). I remember that there’s a lot of good stuff there, including databooks, books, theses, and old bound documents in good or bad condition. I think it’s worth paying a visit. It’s way at the back (at least, it used to be), on the right side as you go in.
=> REPLY
I can’t remember whether it was because of this, or not, that I set out on the next phase of this project. But I did, in fact, go to the library, and, with the help of Prof. JJNeto (who used his library card because mine had ceased to be valid when I left USP), took out some theses related to the subject. Over the course of the next few months, I gradually scanned in each of the master’s and doctor’s theses that had any connection to the Patinho Feio project. In all they numbered around 15 documents (I’m not sure of the exact number offhand). Each one has had its pages scanned in high resolution and pulished in individual repositories in my GitHub account, although the final PDFs were first grouped into a central repository here:
I’m currently also putting the PDFs up on the Internet Archive at:
https://archive.org/search.php?query=subject%3A"patinho+feio"
Well… I guess there’s already a LOT of information in this post. I hope you have fun digesting all of that! There’s a lot more to say, but it will be saved for future posts. My current goal is finishing the installation of the miniature panel wiring, and porting the MAME emulation code to run on an Arduino that controls the lights and reads the switches. Again, I’ll post more messages here as I continue making progress on this project.
Happy Hacking!
Felipe “Juca” Sanches