Monday, September 11, 2017

A Post! Now with even more WiFi Modem!



Well, I hope you aren't tired of news about the CTCUG "C64Net WiFi Modem", because it has remained my development focus.  Even as I type this I'm busy adding SSL support to the firmware, and wondering if the feature is really worth the 50k of program space and 5k of global ram it appears to consume.  The answer? Probably Yes.



My last posting talked about the Telnetd server for the Commodore 64.  That program turned out to be my last new application for the standard C64 kernal.  Since then, I've moved onto the Commodore VIC-20.  Some quick tinkering allowed me to discover that this little 22 column wonder can easily do 1200 baud with our new modem.  That was all I needed to know.

I proceeded to port the machine language code for the WiFi modem applications, which I call the "PML" for "Packet Mode Library", to the VIC-20 memory map, which I was surprised to find so closely resembled the C64 memory map as to need almost no changes at all!

After that, it was a simple matter to adapt most of the standard BASIC applications to run on it, provided you had at least a 16K ram expansion for the VIC.

So that means our modem comes with a nice suite of internet programs for the Commodore 64, 128, and the VIC!  I also tried the Plus/4, but we found that the DCD line on our modem was causing problems, and that a Plus/4 version of the modem would have to wait.


The next thing that happened was that our modems went on sale on eBay! You can find it by searching for "C64NET WiFi Card"



Since then, I've been working on porting my internet applications to the GEOS graphical operating system.  Back in the late 90s, I was quite infatuated with coding for this environment, and have found it quite easy to slip back into its elegant arms.

My first step, of course, was figuring out how to do modem I/O from inside an operating system that ignored the existence of the user port.  I quickly decided I would not try to replicate the C64 Kernal routines, which have some notorious speed issues.  Instead I decided to port Ilker Fi├žicilar's "commLib2" library, which claims to be able to do much higher speeds.  You can download it and find other information here.

Porting commLib2 to GEOS was done in several painful steps.  The easiest part was first: I took his binary and ran it through the WFDis interactive disassembler and generated something approaching the original assembly source.  I then stripped out the terminal, which I would not use, and filled in as many labels as I could.

The next step was hardest: actually getting it working in GEOS.  Like the C64 Kernal, commLib2 relies on timer interrupts from the CIA to handle serial.  However, GEOS does not use NMI interrupts, and, by default, uses a memory map that "hides" the CIA addresses from the CPU.  After working through these problems, I uncovered a few minor bugs in the library, and discovered that the timing was optimized for a European PAL C64, which runs slightly slower than my NTSC C64.  Lastly, I replaced his more complex support for large receive buffers with a faster and simpler small-buffer design that used hardware flow control. Getting through all this took the better part of a month, but eventually I had a working driver!


Once the driver was done, I started working on an 80 column ANSI terminal program, which would be my first GEOS application for the modem.  I discovered that the driver does up to 4800 baud without any troubles.  The author says I should be able to get 7200, but I'll probably need to tweek my NTSC timing numbers at some point to actually see this.


Adding the ANSI color support was tricky, since the font is 4 pixels wide, but the C64 hi-resolution screen supports background and foreground colors in pixel blocks of a minimum 8x8.  I went ahead and allowed this fudge to go through, but I don't think it looks too bad at all.

I still have quite a ways to go before it's finished.  It will need a phonebook/dialer, and support for X-Modem file transfers, but after that, it will be ready to release.

It will eventually be followed by an IRC client, CBM graphics "BBS" client, an FTP client, and probably a combination of the WGET/D64WGET program I wrote in BASIC.  At first, all of these programs will be for the C64 version of GEOS (including Wheels, MP3, and gateWay).  For GEOS 128, I would basically need to start from scratch with the driver all the way up, so I'll leave that for the distant future.

Until next time!