Monday, September 19, 2016

Retrochallenge 2016/10 entry -- VCF-ELF!

I have had a soft spot in my head (or is that heart?) for the COSMAC ELF ever since I first learned of it years ago. The wire-wrapped construction, the front panel switches, the blinkenlights -- what's not to love? We won't even mention the..."unusual"...architecture of the CPU... :-)

COSMAC Proportions

Anyway...I managed to win a VCF-ELF kit in the auction at VCFMW 11, so now this seems like the perfect project for Retrochallenge 2016/10! I've done plenty of electronics projects in the past, including retro computer builds. But, I've never done any wire-wrapped builds until now. This should be fun...wish me luck!

Cool Runnings

In other news, I have taken-on the task of actually running the Retrochallenge 2016/10 event (and probably the future events as well). Don't worry, I won't declare myself the winner unless everyone else is just lame! Plus, Michael Mulhern from the Retro Computer Roundtable will be assisting in the judging duties -- I'm sure Michael will help to keep me honest... :-)

Wednesday, August 17, 2016

Using A Receipt Printer With The CoCo/MC-10

In Episode 9 of The CoCo Crew Podcast, Neil and I discussed the role of printers in the retrocomputer hobby. For some reason this became one of our most popular segments! We continue to get comments and requests for information about printers and how to make use of them with the CoCo and MC-10...

Upon Receipt

Around that same time, I developed an interest in receipt printers. These thermal printers are a popular target for various microcontroller and "Maker"-style hacking projects, partly because they are readily available through eBay and other surplus vendors. The continued use of such devices in retail also ensures a ready supply of paper to feed them. The fact that many such printers feature an RS-232 serial interface is just icing on the cake! The Epson TM-T88III M129C is just such a device...but not all of them have RS-232 serial ports!

Having acquired a receipt printer with a serial port, I set about to connecting it to my MC-10. This is somewhat trickier that it sounds, since the MC-10 (and the CoCo) redefine the usage of the pins on the serial port depending on whether one is talking to a printer or to a modem, as explained here. With the proper cable in place, there is still the matter of setting the communications parameters, particularly the baud rate. The settings for the printer are handled by setting DIP switches internal to the device, while setting the baud rate used by the internal ROM routines on the CoCo and MC-10 involved setting a value in memory (i.e. "POKE 16932,10" for 4800 baud on the MC-10, or "POKE 150,7" for the same speed on the CoCo).

With the correct cabling and speed settings, printing almost works! Unfortunately, the printer and the CoCo/MC-10 don't agree on what constitutes the end of a line of output. This not only causes delays when printing small amounts of text, it also causes the output itself to be formatted incorrectly.

Hook Me Up

In the distant(?) past, there was some disagreement about how to indicate the start of a new line of text (a.k.a. "newline") in an ASCII-encoded file. In the days of the teletype, "carriage return" (CR) represented physical movement of the print mechanism to the left edge of the paper, while "line feed" (LF) represented moving the paper vertically down to the next line of text. These two functions generally go together, making some folks feel that having two characters to represent one action was redundant. Therefore, some systems used just the CR, some used just the LF, and others continued to use both. The CoCo and MC-10 are in the "CR-only" category, while the receipt printer requires both CR and LF to process a newline.

What needs to happen is to change Color BASIC to output an LF immediately after any CR is sent to the printer. But Color BASIC is in the ROM! How is this possible? Well, it turns-out that the writers of Color BASIC were smart enough to identify several places in the ROM where it seemed potentially useful to let other software take control and modify Color BASIC's behavior. These are called RAM hooks, and there are a number of them. One such hook gets called whenever a byte is output by Color BASIC. We just need a little assembly language program to insert an LF after a CR is sent to the printer, and a way to hook it into Color BASIC...

The CoCo assembly language program looks like this:

DEVNUM  equ        $006f

        pshs       b            save B reg
        ldb        DEVNUM       load device number
        incb                    increment for testing purposes
        puls       b            restore B reg
        beq        exit         if device number == -1, then exit
        bpl        exit         if device number >= 0, then exit

        cmpa       #$0d         is output a CR?
        bne        exit         if not, then exit
        jsr        $a2bf        send CR to line printer
        lda        #$0a         change original CR output to LF

exit    rts                     return from RAM hook

While the MC-10 version looks like this:

DEVNUM  equ        $00e8

        tst        DEVNUM       test device number (only 0 or -2)
        beq        exit         if device number == 0, then exit
        cmpa       #$0d         is output a CR?
        bne        exit         if not, then exit
        jsr        $f9c9        send CR to line printer
        ldaa       #$0a         change original CR output to LF

exit    rts                     return from RAM hook

The assembly language program itself is fairly trivial. It checks the output  device number for a value of "-2" (which represents the printer). If the device number is "-2" then it checks for a CR. For an output value other than CR or for any output device value other than "-2" it simply returns having done nothing. For a value of "-2", the program proceeds to output the CR to the printer, then modifies the output value to LF and allows the program to proceed to output an LF as well.

BASICly Done

The BASIC program that installs the assembly code is a bit more complicated. It starts by determining the highest address in use by the BASIC interpreter. It then uses the CLEAR command to adjust that address downward just enough to leave space for the assembly language program described above. The CLEAR command wipes-out any existing variables, so the program then proceeds to again determine the highest address used by BASIC and saves that information for later. At this point, the BASIC program takes the opportunity to set the printer port baud rate as required by the printer, and to send a reset command sequence to the printer.

At this point the program POKEs the assembly code into memory just above BASIC. Then it pokes the address of the start of the assembly program into the 2nd and 3rd bytes of the character output RAM hook. Finally, the value for a JMP instruction is POKEd into the 1st byte of the character output RAM hook, activating the character output hook program. Now the printer will work with Color BASIC!

Here is the CoCo version of the BASIC code as described above:

10 MT=256*PEEK(35)+PEEK(36)
20 SB=256*PEEK(33)+PEEK(34)
30 SS=MT-SB : NT=MT-21+1
50 MT=256*PEEK(35)+PEEK(36)
60 EX=MT+1
70 POKE 150,7
80 PRINT #-2,CHR$(27)+"@"
90 PRINT #-2,CHR$(10)
100 FOR OF=1 TO 21
140 EH=INT(EX/256):EL=EX-256*EH
150 POKE 360,EH
160 POKE 361,EL
170 POKE 359,126
180 DATA 52,4,214,111,92,53,4,39
190 DATA 11,42,9,129,13,38,5,189
200 DATA 162,191,134,10,57

And, here is the MC-10 version:

10 MT=256*PEEK(161)+PEEK(162)
20 SB=256*PEEK(155)+PEEK(156)
30 SS=MT-SB : NT=MT-15+1
50 MT=256*PEEK(161)+PEEK(162)
60 EX=MT+1
70 POKE 16932,10

80 LPRINT CHR$(27)+"@"+CHR$(10)
90 FOR OF=1 to 15
130 EH=INT(EX/256):EL=EX-256*EH
140 POKE 17033,EH
150 POKE 17034,EL
160 POKE 17032,189
170 DATA 125,0,232,39,9,129,13
180 DATA 38,5,189,249,201,134
190 DATA 10,57 

Those little programs may not look like much, but they sure are handy for giving the CoCo or MC-10 a modern-ish printer that can be fed with off the shelf paper. Plus, they allow for lots of interesting printer output to be driven by Color BASIC rather than having to do it all with assembly language. Not bad for some eBay shopping and a little bit of BASIC code!

This little project has been fun, and I think it could lead to more. These little printers have some cool capabilities, including various graphics capabilities and some point-of-sale features. Maybe we can explore those in the future? If you want to see what comes next then I hope that you will continue to stay tuned!

Tuesday, June 7, 2016

SEGA Genesis Joypad Adapter for CoCo3

In earlier posts on this blog, I have covered a couple of options for building a digital joystick to work with the Tandy Color Computer (i.e. CoCo) or for hacking an existing controller for the same purpose. One complaint I receive is that people want to use their existing (either purchased or home-built) digital controllers without having to modify them for use with a CoCo. Fear not -- there is a solution! Just read on...

Design Basics

This joypad adapter design is fundamentally based upon the design described in "Atari Joystick Adapter" on page 135 of the February 1984 edition of Color Computer Magazine. The direction signals are identical between the "standard" 80's-era Atari joystick and the later SEGA joypads, so an identical circuit handles both types of controllers with regard to direction control.

Schematic blatantly "borrowed" from -- thanks!

The schematic above shows a single button (labelled as "F") with a "straight-through" connection. That works fine for the single button on an Atari joystick. When using a CoCo3, a 2nd "straight-through" connection will handle use of the 2nd button on a SEGA Master System controller as well. Unfortunately, SEGA Genesis (aka Mega Drive) controllers complicate matters...

Genesis Buttons

The hardware used to multiplex the buttons on the Genesis joypad does not merely pull-down the button signal.  Instead it drives the signal either low or high depending on the state of the button presses. This works fine for the Genesis where presumably the button lines are not shared for any other purpose. But on the CoCo, those lines are also used when scanning the keyboard. Using a "straight-through" connection to a Genesis controller will cause some keys on the keyboard to appear "dead" (i.e. unresponsive). Adding reverse-biased diodes in-line with each button signal will prevent the Genesis controller from driving the lines high, thereby avoiding any interference with the keyboard scan on the CoCo. The circuit continues to work fine with Atari joysticks and SEGA Master System controllers as well, of course.

More Is Better

The CoCo3 only supports two buttons on its joystick inputs, so we could stop here. But a little research reveals that the Genesis controller only uses two lines for button inputs, and a third line to drive a multiplexer that switches between B/C and A/Start. If the CoCo3 could drive that multiplexer, then the CoCo3 could also read those extra buttons!

The only easily accessible digital output on the back of the CoCo is the "Transmit" line on the RS-232 serial port. That signal is not electrically compatible with the input to the Genesis controller's multiplexer, but a simple circuit using an NPN transistor and a couple of resistors can condition the CoCo's RS-232 "Transmit" line suitably for the multiplexer. Now the CoCo3 can select the active button pair with the equivalent of a "POKE 65312,0" or "POKE 65312,2". This allows the CoCo3 to read all four buttons on the Genesis controller.

If you are interested in more technical details, please refer to the schematic online.

A dual-joypad version of this adapter was produced and built by my podcasting partner Neil Blanchard.  He had it available for sale at CoCoFEST!, and he continues to take orders for them by email. This device uses the design described above and will support use of all of the buttons on the standard "3-button" SEGA Genesis joypad on the CoCo3. I believe these items have sold well, so now there is a "critical mass" of these items out in the community waiting to be used effectively. Hopefully we all can think of ways to make use of 3 action buttons (plus Start) in a CoCo3 game -- what will you write?  What will I write? Well, stay tuned...

Sunday, November 8, 2015

CoCo Conversion for SMS Joypad

I've never been a huge fan of gaming with a joypad, but many people are. With that said, I do agree that a digital gaming input can certainly be more effective than the CoCo's analog joysticks for any number of games. My preference for digital joysticks on the CoCo was strong enough to lead me to build a CoCo joystick from arcade components for use when showing Fahrfall to the general public. I even published the schematic I used for building the internals of that joystick in an earlier post on this blog.

Using an arcade stick for playing (most) CoCo games is great! But an arcade stick can be a bit large and unwieldy, and it certainly does not travel well. Having a joypad is a nice alternative, but making one from scratch is a lot to manage. Using a donor joypad is an attractive option, but which one? The NES controller fits OK, but it has more buttons than the CoCo can use. It turns-out that the SEGA Master System controller is also a good fit, and it has the same number of buttons as are supported by the CoCo3.

Part of me hates destroying one vintage device to enhance another. However, there are a lot of SMS controllers out in the wild. So, I made the call to sacrifice an SMS controller in order to make the world better for CoCo users! If you think this was a bad choice, well, then I hope you'll forgive me and move on... :-)

Peeking Inside

As a first step, we must open the SMS controller. Inside (at least for the ones I have seen), there are a couple of small PCBs with conductive pads for all the buttons.

The wires from the joystick cable connect to the edge of the PCB holding each button, and a small wire connects the two PCBs for a shared ground signal. This is about as simple as things get..

Cut and Splice

Removing the wires on the direction pad made room for installing the resitors needed for the circuit that turns the button inputs into the analog signals needed by the CoCo. The existing PCB had most of the connections needed, but one problem is that the original SMS controller circuit had each button designed to pull a signal to ground when pressed. As a result, there was one trace that connected to all four direction buttons.
Direction PCB w/ central ground connection
The CoCo circuit needs two of the buttons to connect to Ground, but it needs the other two buttons to connect to +5V. As a results, the PCB needed to be modified to accommodate that connection. A hobby knife was useful here both for breaking the connections and for scraping away enough solder mask to allow for new connections to be made.
Direction PCB w/ modification
Once the direction PCB was modified, it was a trivial (if somewhat tedious) operation to attach the eight resistors need to implement the switched voltage divider circuit used to feed the CoCo's analog joystick inputs.

"Big" resistors connected
One axis completed

Both axes completed
Twist and Tuck

With the resistors added to the direction PCB, all that is left are the finishing touches. The existing cable was retained, but the connector was removed and replaced with the CoCo's 6-pin DIN joystick connector. The wires were connected to the existing PCB holes for the two buttons and ground, and directly to the resistor leads for power and the direction axes. A little creative twisting and some nip and tuck made everything fit neatly back into the original SMS housing.

With everything sealed-up, I used a standard label maker to indicate what I had done. Maybe you can dress yours up more nicely?

That is pretty much it! Please refer to the joystick schematic from my earlier posting for more information about the switched voltage divider circuit. Thanks for reading, and happy CoCo-ing!

Saturday, November 7, 2015

Vectrex CRT Replacement

NOTE: Handling a CRT of any size is a potentially dangerous proposition. Not only are CRTs driven by very high voltages and capable of storing a high voltage charge for long periods of time (even after being turned-off and/or disconnected), but they are also glass tubes containing a powerful vacuum and therefore pose the risk of serious injury associated with implosion. Any attempt to replicate the actions described below is done completely at your own riskTHIS MEANS YOU!

Twenty years or so ago I was fairly deep into arcade collecting, including the "elite" world of collecting vector arcade games. Vector games are a breed apart, using a display technology that is in many ways more closely related to oscilloscopes than to televisions. When I first started arcade collecting, I had never heard of the Vectrex. But it wasn't long before I heard talk from the other vector arcade collectors regarding the Vectrex. Soon I was not only aware of the Vectrex but I was desperate to have one...

In the days before eBay, it was often very difficult (or just extremely lucky) to find any sort of rare item. This was even more true for an item with any age on it. While this was a long time ago, the Vectrex still was more than a dozen years old! Plus, those that I knew who had a Vectrex just weren't interested in parting with it. Finally I came across someone who had two non-working Vectrex machines, which I acquired in hopes of making at least one working machine.

Some of my friends may have seen that back in December of 2013 (after a long hiatus) I succeeded at that goal by swapping the logic boards between the two broken Vectrex machines. Around that time, I also determined that the CRT in the (still) non-working machine had a broken neck. The resulting lack of vacuum in the CRT rendered it completely useless. I had done some research into possible donor CRTs that might be available, but I mostly put the project aside until one day not too long ago I stumbled upon an interesting video on YouTube...


I had long ago heard that no one was making CRTs any longer, and it had not occurred to me to search for a NOS supplier. In my excitement, I ordered a tube and waited for it to arrive. In less than a week I was in possession of a brand new (or at least NOS) CRT that was a perfect match for my Vectrex. Or was it?

Original CRT w/ Mounting Ears

Replacement CRT -- No Ears!

(Not) All Ears

A closer look at the video might have prevented my dilemma. You see, the original CRT is constructed in such a way that the steel band around the edge (which is supposed to limit the possible effects of an implosion) holds in place four mounting lugs for securing the CRT in place. The new CRT has the anti-implosion band but it lacks the mounting lugs. In retrospect, had I realized that this would be the situation then I might not have ordered the replacement CRT at all. In this case, I am glad my excitement was enough to put me in this predicament. :-)

Strap Up!

Inspriation struck when I thought of the strapping material that plumber's use for hanging pipes and a number of other utilitarian purposes. Although I considered using the traditional metal variety, the modern plastic version seemed like it would be easier to fit to the purpose. Plus, I thought that it might be a bit less likely to present an electric shock hazard to anyone that might be poking around inside the Vectrex (e.g. me)...

The Vectrex in question still has the logic board problems that led me to the original logic board swap. So, in order to test the CRT replacement I connected a working logic board to the newly serviced monitor section of the Vectrex in question and I was able to play a rousing game of Minestorm. Overall, the machine is still in the non-working category, but at least the vector monitor is saved!

So, the point is that if you have a Vectrex and the CRT is busted or just worn-out, there is no need to despair. At least for now there are still workable NOS replacements that can save the day. With that said, do make sure that you handle the CRT and other high voltage electronics properly. Otherwise, the dead Vectrex will be the least of your family's worries!

Saturday, August 1, 2015

Down and Out

Hmmm...well, the RetroChallenge 2015/07 event ended yesterday and I have made essentially no progress since my previous post. I guess it is time to acknowledge defeat!

That is not to say that I didn't enjoy any good "retro" time this month. Not only did I (along with my pal Neil Blanchard) record and release our third episode (i.e. "episode 2") of The CoCo Crew Podcast, but I also made it to KansasFest, where I gave talks on the CoCo and on Fahrfall. Unfortunately, travel takes a lot out of me and I just never got back into the swing with my RetroChallenge project this month.

I still want to explore some CoCo cartridge port expansions in the future. When I do so, I will likely be documenting that here. Chances are that there will be some other stuff here from time to time as well! I might even be back for another RetroChallenge in the future. So if you want to keep up with any of that, then I hope you will subscribe to the feed and stay tuned!

Tuesday, July 7, 2015

Not Quite Dead

I was feeling a bit defeated yesterday, perhaps a bit too much. I may be down, but I'm not totally out! Without a breakout board, my circuits may be a bit more tedious to make and they will require more care in transport. Nevertheless, I can still make a little noise...

Optimistic Tone

I started with a simple circuit, a 555 timer wired as an astable multivibrator. I am feeding the output into the CART line on the CoCo cartridge port, which is intended for use as an interrupt signal. As such, it is tied to the PIA which drives the FIRQ signal on the 6809. This circuit gives me a new timing source to use for programs on the CoCo!

I configured the 555 circuit to generate a continuous square(-ish) wave at approximately 4800 Hz. This would require quite a bit less service than the ~15.7 KHz Hsync signal provided by the CoCo's video chip, and it would still be fast enough to generate a wide range of useful tones and/or sound effects. To illustrate the point, I have a test program using this time source to service the 1-bit audio output on the CoCo in order to produce a lovely 2400 Hz tone.

Extended Play

So, at least I have the basis for some Retrochallenge play. With the current circuit, I might build a more flexible synthesizer or sound effects generator, or I might even expand to playback of sampled sound through the CoCo's DAC. Perhaps a simple game is in order? The possibilities are endless! There are at least a few possibilities, anyway...

So, what is next for my now improvised Retrochallenge entry? I'm unsure...I guess you'll just have to stay tuned!