Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Sunday, 17 August 2025

Playing 60 VIC20 Games in One Hour

There are lots of things in the VIC20 Penultimate Cartridge. The current release, the +3 DCR has 271 things.

  • Total items (271)
  • Games (233)
  • Utilities (11)
  • Development (8)
  • Adventure Games (8)
  • Board Games (5)
  • Paddle Games (6)

That lot should keep you entertained for a while.

For example, if you were to play one game a minute, it would take you over 4 hours to get through them all (hold that thought).

I don't think many people have played them all.

I have.

Several times.

Release Testing

Well, when I say "played", maybe not all the way through. But I have at least started them and played them all for a bit.

That is something I do prior to the release of every version of the cartridge. I print out the big list of games, and then pick a couple of random VIC20s from my collection. 

I would say these were carefully, scientifically chosen, but normally it is the first two I find that work, although when I have more time, I pick two broken ones and fix those to give a more representative approach.

One needs to be PAL, one NTSC, and ideally one an older 2 pin, and one a later CR version to give a bit of variety.

I go through each game in turn, start it up, make sure it works. Anything which has recently been added or moved or fixed gets more attention. Previously known problems usually get additional scrutiny as well.

Space is tight in the cartridge and things get removed or compressed and that leaves gaps. The cartridge is organised in 32K blocks, and I try to make sure that each 32K block is full. When gaps are created, I end up doing a sort of manual defragmentation trying to shuffle things around to fill all that gaps. That leaves things that used to be in one place now being elsewhere, so I need to make sure the menu has been correctly updated to the new locations.

During a previous round of testing I had considered trying to automate the testing.

There is a feature that could help with that.

Rod's Random ROM Runner

When activated, this will launch a random game, in this case Froggie.

That will start, and you can enjoy a bit of Hopper / Frogger action.

Once you have activated that mode, the right hand button on the cartridge lights up blue, rather than red as usual.

When it is red, it will reset the VIC, or restart the last game, depending on what you are doing.

When it is blue, pressing it will start a new randomly selected game.

We got "A Country Garden" this time, one of the Centipede clones.

And so on. Play each game for as long as you want, and when you want the next one, press the blue button and you will get a new game (well, there is a 0.5% chance you will get the same game again as it is random).

This is from the "Games" list above. 233 titles in total, although if you have a PAL machine, you will only see 224 of those which can run on your VIC20 (excluding ones that are NTSC only and do not fit on the screen and cannot be adjusted).

NTSC has 190 in total, excluding the ones that do not fit on the screen and cannot be adjusted.

There are fewer NTSC games as the NTSC screen is smaller, and some of the PAL cassette games try to expand the screen as much as they can, and so do not fit on NTSC.

As with the NTSC to PAL conversions, I have patched as many as I can without affecting the games.

The paddle games, adventure games and board games do not appear in this list, nor do utilities, programming tools etc.

Boot to Random Game

The cartridge can also be set to start in this mode by going to the settings menu and selecting "Boot to Random Game"

That is quite a nice way to leave it, every time you switch on, you get a random game to try that you might not have seen before.

At any point, you can press the left hand "Menu" button to get back to the main menu and do what you intended to do, or press the right hand "Random Game" button to try a few more.

AI Game Selector

In one of the recent releases, I did consider changing the title to "AI Game Selector". Using "AI" (in the form of a pseudo-random number generator) to allegedly select the perfect game for you. In the end, I thought better of it in case anyone took it seriously. I would rather not have anything to do with the plague of nonsense currently sweeping the world, poorly trained large language models under the guise of "AI" - the sooner that particular bubble bursts, the better.

Artificial Intelligence is a contradiction in terms.

(to misquote Grouch Marx, who was talking about the similarly oxymoronic military intelligence)

Why are you telling me this?

Oh yes, now, where was I. Ah yes, the prologue.

I was considering automatic the testing. I thought I could setup some hardware to "press" the random game button on the cartridge and then press some keys or wiggle the joystick.

My plan was I could record a couple of hours of that via video capture and then skip through the recording looking for anything untoward.

In the end I concluded that it would be quicker to just get on with it and test all the games as normal, rather than distracting myself setting all that up.

Spoil sport.

A couple of days ago, and Rod suggested something along the same lines, although his version would be simpler to setup as he would be doing the keyboard bashing and joystick waggling, and already had the video capture gear setup.

All it needed with the "press the blue button" bit.

Pressing the blue button

I had a few plans in mind to automatically press that button. I needed a short pulse to press that, then a delay, then another short pulse etc. 1 second on, 59 seconds off seemed a good option.

My scope does have a function generator, and I thought that might be an easy way to do it, but when I tried, it only goes up to 10 seconds, which isn't quite long enough.

I spent far too long today searching around the house for a suitably powerful solenoid or some kind of stepper motor that could be adapted to mechanically press the button. I wasn't going to use it, I just thought it would be good to put some pictures of it here.

I was surprisingly restrained and managed to stop myself ordering a robot arm kit from Amazon.

Or building my own version, courtesy of one of those wonderful 80s Usborne books.

In the end, the easiest option to get something running for Rod was to use an Arduino.

Rod wired this up to his test board.

The buttons on the cartridge are a pretty standard arrangement, one side of the switch is ground, the other is connected to 5V via a pullup resistor. Normally, it reads high, but when the button is pressed, it reads low.

I wrote a simple bit of code which setup one pin as a low output for a second, then turned it to an input for 59 seconds, then back to a low output again for another second and so on.

That is safer than setting it permanently as an output and changing it between high and low, as it only ever drives low, so you can still safely press the button, wire it the wrong way around, or ham-fistedly short the wires together etc.

That worked first time and Rod went straight into an hour long video, playing 60 games for 59 seconds each.

That went down so well, there is now a second hour of games:

With no repeats, and 60 games per video, it would take four videos to cover all the main games (excluding paddle, adventure, board games etc). With the occasional repeat, it would likely need a fifth.

I wonder who is going to keep count to see if they are all being done.

Who am I kidding. It's me, isn't it. I'm the ones who is going to have to go through the videos and check all the games off the big list aren't I. Oh great.


Adverts

The AI-free Penultimate +3 DCR is available from TFW8b.com


Lots of other things are available from my Tindie Store.


Patreon

You can support me via Patreon, and get access to advance previews of development logs on new projects like the Mini PET II and Mini VIC and other behind the scenes updates. New releases like this will be notified to Patreon first, if you want to be sure to get the latest things. This also includes access to my Patreon only Discord server for even more regular updates.

Friday, 8 December 2017

Arduino EEPROM Programmer

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

I saw this kit advertised on Tindie (Simple EEPROM Programmer shield for Arduino Mega) and thought it looked interesting.
I have an upcoming project where I will need to program some EEPROMs in place in a system. I hadn't looked into the programming algorithm, so this seemed like a good way to start.
The kit arrived, very nicely presented with a clear double sided instruction sheet and a nicely laid out board with all the tracks on the back and a copper pour ground plane. I notice things like that. I like things like that.
Assembly was straightforward. I chose to fit an IC socket (I had already stolen the ZIF socket supplied with the kit for something else), as I wasn't planning to change the IC in it very often.
All that was needed was to plug it into an Arduino Mega. The firmware is available from the author's blog. We've all had fun in the past with Arduino code that doesn't build and needs specific old versions of certain libraries, but I am pleased to say it built and programmed fine.
It uses a serial protocol, over a 9600 8N1 connection. The commands are detailed in the code, but basically V shows a version string, Raaaa reads from address 0xaaaa, and Waaaa:dd writes data 0xdd to address 0xaaaa (can be multiple bytes e.g. Waaaa:dddddd).
You can drive this from the serial monitor, but there are two provided front ends, a command line version and a desktop app.
Testing this with a couple of Atmel AT28C64B EEPROMs that I am currently using a lot to test a Commodore 64 cartridge. Yes, I have put labels on the chips, the etched labels can be tricky to read at some angles. No, of course my eyesight isn't getting worse, of course I'm not getting old.
I was able to read in data from the chip fine, but writing didn't seem to work. I checked with the author and he was using the same chips as me, and they were working fine for him. I checked the chips I was using in my usual programmer, and they were programming fine. It was then I noticed the lines about "Software Data Protection".
Checking the AT28C64B datasheet, it seems there is a sequence of instructions that can be sent to the chip to lock it to disable future writes, and to unlock it again. My Minipro programmer was unlocking at the start, programming and then locking again. A sensible precaution against accidental writes.
I tried removing the SDP (Software Data Protection, not the Social Democratic Party) and was then able to successfully program using the Arduino based programmer. There was no code present in there to do SDP which explains why it wasn't working on chips I had already used with my EPROM programmer. I had tried a chip fresh from the tube, but stupidly checked that it was working first by programming it on my EPROM programmer, which locked it. As there wasn't any provision for SDP in the code, so I tried enabling it using write instructions, W1555:AA, W0AAA:55 etc. but that didn't seem to work.
Checking the datasheet, they specified a series of events, so I took the V0.01 code and built a V0.02 with SDP enable and disable built in, trying to follow this sequence. This didn't work either, I tried a few ways around it, but thought it may be timing related. The exiting code has an overly generous 10mS write pulse, which is actually the maximum the chip can support. The datasheet says the chip can work with a pulse as small as 50nS. I tried a 1uS pulse (using the Arduino delayMicroseconds function), and that worked. I left these are separate commands, as they probably only apply to Atmel chips. P to protect the chip, U to unprotect.
The sequence above show testing writing is working, enabling SDP and writing more. Those writes didn't appear. Enabling SDP and repeating and the writes are now retained. Note the first byte is overwritten with 00 during the lock / unlock operation. Some data needs to be written to any address to complete the lock / unlock process. A future improvement may be to read that byte before lock / unlock and write it back afterwards with the original value. There is also a function to erase the whole chip, but that requires a 12V pulse which is not easily available in this case.
So, I bought this kit to learn more about programming EEPROMs, and it certainly worked. I sent my updates to the author, and he has already incorporated them into the official V0.02 release (available on his blog).

Saturday, 1 April 2017

DivMMC Programmer

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Since it's Arduino day, here's a recent project where the Arduino came in very useful.
I posted that picture on twitter and had many suggestions as to what it could be, including:

  • Arcade button controller of some sort?
  • Electric shock russian roulette version of the popular Simon memory game
  • Some sort of video mux 
  • CBM serial port network?
  • For testing cables?
  • Quiz buzzer system?
  • Bespoke Track and Field controller?
  • Three-player controller for Flappy Bird!
  • RGB pattern generator?
  • MIDI? Is it a MIDI thing?

And several people who had presumably been watching the IT Crowd, suggested that it was 'The Internet'. Well, no, as much as I would like to announce that this is 'The Internet - Mark 2", where you can safely type google into google without destroying the universe, it is not.
With the labels on, it may make more sense. This is a programmer and tester.
And that is what it programs and tests, the new DivMMC Future from The Future Was 8 Bit. With lots of orders for this coming it, programming each one individually takes a long time, so this will automate this process and program 4 units in parallel. Not directly, but via a number of remote controlled ZX Spectrums.
The Spectrums are connected via the 4 cables on the bottom. The cable on the side controls an ATX power supply to power the Spectrums and monitors.
That worked out very nicely, the 5V standby supply powers the programmer, and power to the main 5V and 12V can be controlled by the Arduino to turn them on or off. The Spectrums are powered by 5V and 12V from the accessory power connectors (normally used for disk drives etc.). These adapter plug into the 3 pin connector where the 7805 regulator would have connected and feed both 5V and 12V into the board.
The programmer needed to automate the process of powering on the units, loading the programming software, programming the units and then power cycling them and testing them out. The power control was already sorted. Next was loading the programming software. This is a one off project, so I went for an Arduino as a base for the project to get something up and running quickly without a custom PCB or too much handwired prototyping.
I did think about loading the .tap or .tzx file from SD card and getting the Arduino to generate the appropriate tones, but I went for a simpler option and used a Sparkfun MP3 player shield to play an MP3 into the tape port of the Spectrum.
The Spectrums we were using for this were Grey 128K +2 units, which have a built in cassette drive, which includes some signal processing, and feeds the Spectrum with a TTL level signal. I built a simple transistor buffer to generate a TTL level signal from the MP3 player output.
The signal goes through some RC filtering inside the Spectrum, so to avoid any interaction between multiple inputs in parallel, I buffered this signal via a gate in a 74LC04 inverter and then inverted it again via one inverter gate per output.
The system is controller via three large, friendly, illuminated arcade buttons on the top, all wired up to headers on the middle board. These light up to indicate which mode it is in. The software is a state machine which progresses through the steps required for 'Program' and 'Test. The blue and green buttons light up to show the current mode, and turn off when complete. The red buttons always shows if the power status, and pressing it turns the power on or off in any mode.
At the bottom of the board stack is the Arduino. I tried various different boards here. The one on the left is an Atmel ATmega328PB Xplained Mini. This has 'Ardunio compatible' headers on the board, and some extra pads where I planned to attach the cables for the buttons and the connectors.
I was hoping it would be possible to flash this with an Arduino compatible boot loader, but didn't get that working. Instead I use Arduino to build the code, and then programmed the board with the hex file via Atmel Studo. Unfortunately, I couldn't get that to work with the Sparkfun MP3 shield, I think due to an issue with the SPI bus.
I looked around an dug out an old 'Arduino compatible' Lenoardo clone. That also had extra pads for headers. That also didn't work - the SPI pins are in different locations on the Leonardo. Finally, I went back to the Arduino UNO I had been using for development, since that was working.
So we have power and audio, the next was controlling the Spectrum. To do that, I had 4 spare outputs from the Arduino, wired in parallel and fed to each Spectrum. Each one of these would attach to a gate of a 4066 quad analogue switch which would be wired into the keyboard matrix to mimic pressing a key. This is designed to be reversible, so the 4066 is only tacked onto the chip below to steal 0V and 5V. The rest is just pushed into the membrane connectors.
I wired up 4 control lines in case the requirements changed. There needed to be the enter key to start the tape loader (easier on the +2 than J symbol shift+P symbol shift+P on a 48K), space to start the programmer, then arrow keys to navigate the DivMMC menu to load a test program.
During the testing, I found I could narrow this down to enter and 6. 6 was both the down arrow for navigation, and 'any key' to start the programmer.
I'll add some photos of the programmer in use and the 4 Spectrums, once they have been assembled in their new home.

UPDATE

The 4 Spectrum boards have been repaired and assembled and the programmer is now running 4 way.

2022 Update: The production version of the DivMMC future is now available from  The Future Was 8 bit

Saturday, 18 April 2015

Petdisk clone

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

A few weeks ago, I wrote about building a prototype version of Bitfixer's Petdisk, an IEEE-488 disk drive for Commodore Pet computers, using an SD card for storage. Credit again to Bitfixer, the creator of the original Petdisk. This was the first stage of a plan to build my own Pet disk drive emulator, recreate what has already been done to prove the principle.
That version was built on an Arduino UNO, using the same pins to connect to the IEEE-488 port as the original version of Petdisk. This allowed me to load the original firmware in to check everything was working.
I did get some way along the road writing a version in the Arduino environment. I started from scratch, but followed the general lines of the Petdisk firmware. I was hoping this might come out to be a some nice short simple Arduino code using the SD libraries etc. However testing showed the I/O operations needs to be fast, so I had to replace all the nicely wrapped Arduino DigialRead and DigitalWrite calls with direct PORT and DDR access. I ended up removing most of the serial debug I had added as well. But it did work. I started with an empty directory and a simple hard coded 48 byte test program.
Whatever filename was requested, it would return the same 48 bytes. With that working, I started using the Arduino  SD library to load files. That is working, but is unfortunately limited to 8.3 filenames. I didn't get around to writing the directory listing bit, but that should be possible. So, the new firmware can be written, but probably best not in the Arduino environment.
The next step was making a PCB version of the SD card version. This would again use the same connections to the IEEE-488 port as Petdisk, so it could use that firmware. As with the Arduino UNO, I used the ATmega328P. Not the actual chip used on the Petdisk (that was the ATmega168), but similar enough to allow the firmware to be used.
Rather than the diode / resistor level conversion used on Petdisk, I went for a 3.3V LDO regulator, and a 4050 hex buffer working as a level shifter. I also went for a microSD card socket rather than full size SD. I added a power LED and using a spare gate of the buffer, an activity LED.
The board slides into the pins of IEEE-488 24 way 0.156" edge connector and it is soldered down on both sides. I missed out the pass-through connector and the USB power connector and went for a simple two pin header for the power. OK, it's sounding less and less like a clone now, not quite an emulator, but the only thing in common between this and the Petdisk now are the edge connector and the microSD card.
The pins at the back are the power in, the 6 pin Atmel programming header and the three jumpers. Two for the address setting, one can be used for serial out.
I built a few for my machines and a few friends who have also tried but been unable to buy a Petdisk. I have a few boards left if anyone else is in the same position.
With the Petdisk v2.0 beta firmware loaded, that is working nicely. I am in the process of writing some new replacement firmware, I've gone back to plain C in Atmel studio, rather than in the Arduino environment.
In my version, I'd like to add some new features, BASIC 4.0 disk commands like 'DIRECTORY' and DLOAD, shift + RUN/STOP support, non- PRG files and file OPEN commands.
One of the things I've been looking at is an old text adventure game. I've found a D64 image, which contains a .PRG file and many .SEQ data files. With those transferred to an 8250 disk, it loads and runs. With the Petdisk firmware it gets so far but cannot load the instructions or start the game as these use OPEN and INPUT# commands. The aim is to get that working.

2022 Update: I have since designed a much nicer SD drive for a PET. The SD2PET is available from The Future Was 8 bit: SD2PET