Tuesday 30 January 2018

Back from the Grave: Commodore 128D (incorrect character and colour display)

Commodore's attempt to supersede the infamous Commodore 64, the C128 was designed to take the C64 and give it a significant boost in its general computing and business credentials.  The MOS 6510 was replaced with an MOS 8502 able to run at twice the speed (2MHz), the RAM was doubled to 128KB (expandable to 1MB), the BASIC interpreter was upgraded and a second, high resolution VDC was added - complete with its own video RAM - and even a numeric keypad was now standard on the keyboard.  Not only that, but a Zilog Z80 (running at 4MHz, though only really 2MHz effectively) was included to enable what is generally considered the best implementation of 8-bit CP/M.

Unfortunately, the juggernaut that was the Commodore 64 would ultimately prove its undoing.  As the C128 boasted near 100% backwards compatibility with its predecessor, most software was still developed for the older, cheaper system to ensure a broader user install base.  Between that and the rising popularity of x86-based systems in businesses, in 1989 the C128 was discontinued.
Note that this is not a complete recount of all the steps taken.  As this was our first such project there were multiple unsuccessful and, as it turns out, completely misguided attempts at diagnosis and repair.  While these were indeed valuable lessons for us, I have decided to omit them in order to limit any possible confusion with regards to remedying the actual issue at hand.


This particular Commodore 128 - a 128D variant (not to be confused with the US 128D, known as the 128DCR in other territories) - came into our possession in the late '80s.  It served me and my brothers for most of our childhood, both for education and entertainment.  Once we started to acquire x86-based computers, however, it ultimately found its way into storage where it sat for 20 years before being powered on again.

Sadly, upon being powered up it was discovered that an issue had developed.  Any reference to the character ROM or colour RAM would display as though bit 4 (base 0) was set to 0.  So typing the sequence "12345678" would result in "12125656" being displayed, as it was reading character data some 16 bits (exactly 2 characters) out in those cases.  Other than this, the system itself was running perfectly - but this was enough to render the system nigh unusable.

Following some unsuccessful attempts at diagnostics, the issue did change; though its fair to say it wasn't really for the better.  Bit 4 was now active, but it was sometimes holding its value when it shouldn't.  Spaces would have quotation marks, "12345678" would sometimes display as "34347878" (though these would sometimes only have the first 1-2 lines of the incorrect character), and we could make the situation better or worse depending on the amount of characters involving bit 4 were visible on the screen - more characters which were meant to have bit 4 active made it worse, fewer made it better.

Diagnosing the root cause of this issue came in two parts: both software and hardware.

Through software, we were able to determine that the issue was in reading back the character ROM or colour RAM for display only.  The character ROM itself could be read from the CPU and copied to system RAM, which could then be activated for a perfectly stable display, and colours could be written and read from their respective RAM without any problem.  That it was "fighting" to display the correct results also meant that it was able to be written and read properly, given the right circumstances.

Further software testing involved pure bitmap graphics.  While many games make use of ASCII characters for their scenery, the C128 in native mode provides easy access to a graphics screen.  Any and all data displayed on such a graphics screen was perfectly stable whether it occupied the entire screen, most of it, or just a strip across the top, where any text on partial graphics screens was still corrupted.  VIC-II E (the graphics chip) was clearly able to read and display the data perfectly - it was just receiving bad information when it came to text.

On the hardware side, the paths on the motherboard responsible for reading bit 4's data were traced back towards the VIC with an oscilloscope to find when the bad information it was clearly receiving became the good information it was supposed to be using.  Since it affected both colour and characters identically, it had to be something common to both and the display.  This left a total of just 3 chips in question: VIC itself, a 74LS275 multiplexer (U14) and a 74LS373 tri-state latch (U17), and both VIC and the multiplexer had proven to be working (the multiplexer is how the CPU communicates with VIC, thus essential for bitmap graphics).

The output from both the colour RAM and character ROM were rather clearly defined square waves - these chips were providing good, sensible information.  However their input was, for lack of a better term, garbage.  While it was still arguably a square wave, it had no defined peak nor any real reason for its pattern, so they were simply providing the right answer to the wrong question.  Following the signal back to the 373, its input was found to be similarly clean as to the output from the other chips.  It would seem that the latch has failed.

During this process, the issue in fact became worse, allowing a more confident diagnosis.  Bit 5 had now begun the same process, returning 0s at all times.  As a result, we simply had to find the point in the line where bit 5's data flatlined.  Once again it was this same 373 where good input became useless output, this time as a clearly defined 0 (high).  Our diagnosis had been confirmed, and upon replacing the suspect 373 chip the display stabilised perfectly and permanently.

That's all for this BftG.  Our childhood friend now lives again, and has been given a thorough inspection by way of multiple, nostalgia-fueled gaming binges - strictly for testing purposes, of course.  It's not quite perfect yet, though, as the floppy drive doesn't work; but that's a subject for another time.

Remember that electricity can be dangerous to both property and life.  If you don't respect it you can wind up seriously hurting or even killing yourself or others, and chances are it's going to be painful while it's happening.  Unless you're sure of what you're doing, avoid tampering with any electrical circuit - especially when it's live or mains powered - and always ensure you have a nearby assistant who can contact emergency services.

No comments:

Post a Comment