Showing posts with label 6502. Show all posts
Showing posts with label 6502. Show all posts

Friday, 10 April 2026

Emulating a Commodore Chessmate

 A couple of years ago, Hackaday published a short piece on the Commodore Chessmate. As is usual with their articles, its shortness of length was more than made up by the breadth of its links. The last of these led to Hans Otten's Retro Computing page. 

(One of the few comments beneath the article is by Peter Jennings, creator of the original Microchess program, linking to his reminiscences about the Chessmate: well worth a read!)

Chessmate by Commodore

Anyway the article caught my attention because I'd had one of these as a nerdy kid. I remember opening it up, hoping to find... I don't know what, maybe a sort of PET? but not recognising many of the components; nowadays I could just Google it, and probably end up at Hans's page.

Among a wealth of other information, Hans provides ROM dumps and a memory map. I thought, should be pretty easy to write an emulation of that, and so it was. (The hardest part was probably mapping the 7-segment LEDs onto the TFT screen, which is to say: not very. Probably about a weekend in all.)

Chessmate by me

(The emulation uses r65emu, my emulator library for Arduino, running on an esp8266 connected to a TFT screen.)

Time passed and r65emu slowly improved. One update was to support other kinds of displays and keyboards besides the original TFT and PS/2. Sometime after this I decided to build a retro-modern version of the Chessmate with an anachronous mix of whatever parts I had lying around, and knocked it together on a couple of breadboards. 

I don't have a picture of that, but it was an unholy mess of wires, and languished on the side of my desk for over a year before I sat down with KiCad to turn it into something more permanent. I must have been in a rush because I made several mistakes with that PCB, getting some footprints wrong. I fixed them and parked the design, slightly depressed.

Things might have stayed like that for yet another couple of years, had I not been contacted out-of-the-blue by Liam from PCBWay who expressed interest in sponsoring r65emu. And so...
Chessmate by me and PCBWay

This uses a node32s microcontroller, push-button switches, a buzzer and 7-segment LED displays. The four status LEDs are represented by decimal points. Its software and hardware lives on GitHub.

It would be interesting to run a modern chess program on this hardware; one possible candidate is by Sergey Urusov.

(Incidentally, Michael Gardi has a much nicer modern rebuild of the Chessmate, complete with 3D-printed replica case!)


Friday, 14 June 2024

Testing a 6502 CPU

 It's relatively easy to test the UK101's discrete TTL chips using a simple Arduino-based IC Tester, and the ROMs can be read by an EPROM programmer but what to do about the more esoteric chips, i.e., the CPU and ACIA?

As CPUs go, the 6502 is a masterpiece of simplicity. It turns out that you can have it run the most basic of programs with no support logic whatsoever! This is the well-known NOP test, in which the CPU is fed an endless stream of No-Operation instructions, see for example here.


Breadboard 6502 flanked by Clock Circuit (L) and Logic Analyzer (R)

The image shows the test-set-up. The board on the left is a Micro UK101 which is only used as a power-supply, reset switch and clock source. (This is a more rewarding way of testing CPU and ACIA, but only if they both work!)

The CPU does not need many connections to run the NOP test: its data-bus is hard-wired to EA (the opcode for NOP), it also has IRQ and NMI tied high, and the input clock and reset line from the Micro UK101.
 
The logic analyser on the right is a cheap 8-channel model which works with PulseView. It is triggered by the reset pin (high-to-low transition) and samples A0, A1, A2 and the output clock.

When powered up and reset, the 6502 reads its reset vector at $FFFC and $FFFD. Unsurprisingly it reads the address $EAEA and jumps there. It then reads an endless stream of NOPs at every address between $0000 and $FFFF. Its address pins will show this.

Or they would show this, if the CPU was working. The screenshot below shows what happens most of the time:

Dead

The top trace is the reset line and the bottom one is the output clock, which seems to be working. The three lines in the middle are A0, A1 and A2 with nada.

However sometimes the CPU shows signs of life. About every 10 resets, there would be a short burst of activity for a few microseconds:
Some signs of life

So it looks as if this CPU is a goner. It was made by Synertek in the 35th week of 1980 and spent the last 40-odd years in a cold damp attic, where it expired: RIP.

Update: Hans Otten has written about NOP testers here.
Update #2: It seems my test-setup above was flakey and the CPU is actually OK: stay tuned!



Wednesday, 20 August 2014

Retrocomputer Resurrection

"What's a Computer?"
This chimera is a microcontroller emulation of a UK101, an 8-bit microcomputer from the early 1980s. Needless to say I had one; it is a shocking thirty-three years since, as a spotty teenager, I soldered one together over the course of a few days. I recall the kit cost the equally shocking sum of £99.95 (a lot of pocket-money), and had to be smuggled through Irish customs in my parents' car because the Single European Market was at that time merely a twinkle in M. Delors' eye. In its original configuration it had 1k of user RAM, 1k of display RAM, 8k ROM Basic (from Microsoft) and a 2k ROM monitor. When it went to its present resting place in the attic a couple of years later, it had 16k of user RAM, 2k of display RAM and an additional 6k of utility ROM, all piggy-backed on the original chips.

The last time I had patently too much time on my hands, in 1997 (seventeen years!), I hacked together a software simulation of it. I had intended this to be a general purpose simulator but it fell by the wayside after the UK101. In the intervening time I'd often regretted not writing the simulator in Java (indeed, a very good Java-based simulator now exists) but luckily where microcontrollers are concerned, C/C++ is still the only game in town, and most of the code compiled under the Energia IDE.

The hardware is almost insultingly simple, there are five components:
  • A Stellaris Launchpad from Texas Instruments,
  • An SD card drive,
  • A TFT LCD boosterpack,
  • A PS/2 socket,
  • A PS/2 keyboard.
While the Launchpad has only 16k of RAM, of which 12k is used for the main memory and 2k for the display, it does have 256k of flash, easily enough to contain all of the ROMs I've collected for it. (Another UK101 hardware instantiation can support the full 40k of user RAM.)

This build's main limitations are the display (only 30 lines of 40 characters vs the original's 32x48 ---  affordable TFT screens max-out at 240x320 pixels these days) and the keyboard (a lot of the games use the Control, Left-shift and Right-shift keys, which aren't available individually from the off-the-shelf PS/2 keyboard library).

However it has one modern advantages over the original which almost makes it enjoyable to use: checkpointing and restoring the machine state using the SD card. This allows creation of initial game images (which load instantly since they're only 14k) and progressive checkpoints, as adventure games are completed, for instance, or new programs developed.

Space Invaders: it doesn't get much better than this!
Code and programs are at GitHub, should you care.

The final thing is to find a suitably retrotacular housing for it. Something like this would be about right...

Kim Greist in "Brazil" by Terry Gilliam