Project Write-up: Twittjr

May 12th, 2009

Twittjr running in the CSH server room

Twittjr is a system that allows an IBM PCjr to search the public timeline on Twitter. In case you weren’t aware, Twitter is a social micro-blogging service introduced in 2006 and has over five million active users. The IBM PCjr is a personal computer introduced in 1984 and has a 4.77MHz processor, 128KB of RAM, and uses 360KB floppy disks for storage.

It seemed like a good idea at the time.

A close-up of the PCjr monitor while Twittjr is running

How does that even work?

Let’s say you have a PCjr hooked up to an external dial-up modem, which is connected to a phone line. Elsewhere, you have a modern internet-connected computer (call it the “server”) with another dial-up modem, connected to another phone line. The PCjr calls the server and establishes a modem connection, which it uses to send a request for whatever search term the user enters. The server uses the Twitter Search API to download the three most recent posts on the public timeline that match the search, and shoves them back over the phone line to the PCjr, which displays them on the screen in glorious 16-color ASCII-vision. In the absence of user interaction, the PCjr refreshes the search results every minute or so, providing a sort-of-live feed. 

Note that while a modern PC is involved, the PCjr is far from being a “dumb terminal” in this setup: I intentionally put as much work as I could on the PCjr side, and the server software is tiny in comparison to the pile of BASIC code that runs the client. The only things that aren’t done on the PCjr are the actual download from the internet (good luck cramming all those protocol stacks into 128KB of RAM!) and the XML parsing (which is possible, but not very fun, in BASIC). The two machines exchange data using a super-simple ”protocol” I made up on the spot.

The 5.25-inch floppy drive I installed in my desktop to transfer code for Twittjr

The 5.25-inch floppy drive I installed in my desktop to transfer code for Twittjr

What’s the code written in?

The PCjr software is in Cartridge BASIC, which is essentially BASICA with some extra bits. Cartridge BASIC is the best of the three forms of BASIC that can be used on the PCjr (the others are Disk BASIC and Cassette BASIC), because the interpreter doesn’t take up system memory, it runs almost as fast as compiled code, and you can save your programs to disk. It does, however, require that you have A) the actual Cartridge BASIC cartridge, and B) a DOS disk to boot from.

The “server” software is a small Ruby script that uses only built-in libraries. It should work on any platform that can run Ruby, but I’ve only tested it on Linux.

A picture someone took of Twittjr at ImagineRIT 2009

Twittjr at ImagineRIT 2009

How did Twittjr get started?

As it happens, I’m a member of Computer Science House at RIT, and one day I discovered a fully-functional PCjr gathering dust on a shelf in one of our common rooms. Noticing that it used BASIC, which I was familiar with from my high school days, I figured I could write some eye-catching application that would attract people to our tables at the ImagineRIT innovation fair. Lots of CSHers had been joining Twitter recently, including myself, and someone who saw me fiddling with the PCjr suggested putting Twitter on it. Several weeks later, the first version of Twittjr was serving up tweets to curious open-house visitors.

Can I set this up on my own PCjr? 

Absolutely, as long as you have the following things:

  • One IBM PCjr with DOS boot disk and Cartridge BASIC cartridge
  • One of the following:
    • Internal PCjr modem installed (limited to 300 baud)
    • External serial modem with PCjr serial adapter to attach it
  • A 5.25-inch floppy drive in your own computer, to copy the program
  • A spare 5.25-inch disk (or use your boot disk if it’s writable)
  • Any modern-ish PC to use as a server
  • A modem for said PC that appears to your OS as a serial device
  • A working installation of Ruby on said PC
  • Two phone lines (at least one must be capable of calling the other)

And last but not least, you’ll need the Twittjr code package! It includes a README with basic setup instructions, so make sure you look that over before you start.

  1. cw
    May 13th, 2009 at 18:46
    Reply | Quote | #1

    Neat idea, but I’m wondering if it wouldn’t be easier to just cable the two machines together via a null modem cable so you don’t need to drag the whole PSTN into the mix? I haven’t seen a PCjr in years so I don’t recall if the serial adapter is a rarity or not. Nevertheless a nice way to use some old hardware. I hope it inspires others to try it on some old 8-bit hardware too. (Apple ][‘s and C=64′s (hell – a VIC 20!) could probably do the job.)

  2. Grantovich
    May 13th, 2009 at 22:26
    Reply | Quote | #2

    @cw Sure, you could null-modem it with minimal code modifications. I used dial-up modems for the long-distance factor; at ImagineRIT I had the PCjr at our table in the Golisano college, and the server was sitting in the dorms on the opposite end of campus. I wanted to try it with a cell phone for great wireless PCjr justice (some old phones have serial adapters), but didn’t manage to find one in time.

    I did use the PCjr serial adapter in my setup to connect an external modem, since the machine CSH had hanging around didn’t have the optional internal modem installed. The adapters can be found on eBay for $20 plus shipping; like the PCjr itself, not many of them were made.

  3. Ryan Gavin
    May 13th, 2009 at 23:55
    Reply | Quote | #3

    I’m so upset that my dad got rid of my PCjr! I scored one from a friend’s neighbour a few years back and it was sweet.

  4. davijordan
    May 14th, 2009 at 00:02
    Reply | Quote | #4

    I have not looked at the code, but it would seem that it could be used on any old pc. maybe mmod the code to use ethernet.

  5. kws
    May 14th, 2009 at 01:05
    Reply | Quote | #5

    I can’t recall what I did, but I had a 720K 3.5″ floppy drive in my PCjr. That made transferring files to other computers down the hall a lot easier.

  6. Evan
    May 14th, 2009 at 03:48
    Reply | Quote | #6

    Twitter offers a JSON feed; would that make parsing easier?

    There must be a way to avoid the additional server too, either with a tiny piece of hardware or an existing HTTP to Telnet bridge on the internets…

  7. @Omegatron
    May 14th, 2009 at 08:10
    Reply | Quote | #7

    Hmm, I wonder what it would take to get something running on the TRS-80 I have sitting in the garage here :-)

    Great work overall man, nice mashup of old and new technologies in an interesting display.

  8. MBBrutman
    May 14th, 2009 at 10:05
    Reply | Quote | #8

    Want to get that running natively on a PCjr, complete with Ethernet and TCP/IP on the machine? I’ve got a TCP/IP stack for the Jr you might like. :-)

  9. George
    May 14th, 2009 at 14:01
    Reply | Quote | #9

    It is fairly easy to “port” this code to other systems (ZX Spectrum and MSX in particular come to mind).

    The hard part, actually, is to find working hardware, not the computers per se, but the modems that were pretty rare for some of them. Apple ][s and MSXs got modems aplenty, but when was the last time you saw a modem for the ZX81 or a CoCo?

  10. Grantovich
    May 14th, 2009 at 16:54

    @Evan JSON might make it easier to parse the feed, but that’s a trivial amount of work compared to getting the PCjr “on the internet” with nothing but a modem. Even if you paid for access to a dial-up ISP, you’d need at least a PPP/IP stack to get anywhere, and I don’t know if it’s possible to interact with those through BASIC. I hear old versions of Turbo C++ can compile for the 8088 architecture, though!

    @MBBrutman That is quite something! I salute your superior DOS programming skills. Unfortunately CSH’s PCjr only has the stock 128K of RAM, so even if I had an Ethernet sidecar (which I have seen some people hack together), I think the packet driver alone would take up all my free memory! I’ll keep your TCP/IP stack in mind if I ever stumble on a slightly more powerful DOS machine; a long time ago I had an old 486 laptop that could have used it.

  11. MBBrutman
    May 14th, 2009 at 23:59

    Alex – A stock PCjr has 112KB free after the video memory is allocated. Boot DOS 2.1 and you probably loose 20 or 30K of that.

    The DOS packet drivers are only a handful of K in size. We could sneak an IP stack into 64K fairly easily. And since this isn’t a high performance app, we could forgo some features and buffer space. Just just find a single 128K sidecar and you would have plenty of room.

    Let me know when you are ready. :-)

    BTW – I grant style points for using a stock machine with Cartridge BASIC. The screen shots look great.

  12. Grantovich
    May 15th, 2009 at 13:06

    @MBBrutman As I said earlier, I don’t plan on developing Twittjr much further than where it is now. I have other projects that demand my free time, and I think the Twittjr code will do fine in the hands of the many other CSHers who live here. Of course, you’re welcome to hack away at it, if you have an Ethernet-capable PCjr. Send pics! ;)