Sunday 17 June 2018

ZX Spectrum+ mystery repair

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

Here we have a ZX Spectrum+, and it's broken, but that's not the unusual bit.
Looking around inside, everything looks good, apart from two things. Firstly, this capacitor appears to have blown itself apart, those black things should be inside the aluminium shell.
Secondly, this resistor is seriously fried.
This board is an issue 4S, which is a Samsung produced board, and is closer to the issue 3B than the 4A or 4B (which is definitely a good thing).
Being a Samsung model, it also has a clear membrane, which are usually still working fine these days. These clear membranes don't seem to suffer from the brittleness that affects the others.
The two parts that failed are parts of the legendarily flaky power supply section. Indicated here on the schematic. (this is actually the 3B schematic, C7 is labelled as C78 on the 4S board).
This is where it gets confusing. Answer me this please anyone. That resistor should be 2K2, and at a guess would be rated 1/4 Watt. So doing some maths, there should be around 7V across it, so the current through it would be 3mA, dissipating around 22mW, well within its capability. At the rated power of 250mW, the current would have to be 10mA, which would only happen if the voltage across it were over 23V. This is unlikely given the power supply arrangements.
However to damage the resistor that badly and char the board underneath, it would need to be several times the rated power, which would mean the voltage across it would have had to be maybe into the hundreds of volts. There just doesn't seem to be enough power around in these circuits to have caused this. Anyone care to suggest how that could have happened? Spontaneous Resistor Combustion?
The worst case I can see would be if the zener diode had failed short (as I had seen on a previous repair of a ZX Spectrum with no -5V). It hasn't, I checked, but even then, that would have put about 12V across 2K2, which is only 5mA. No way would 5mA do that much damage, would it?
The same is likely true of the capacitor, the end has clearly blown off, which would have taken quite a bit of overvoltage. But the rest of the board is apparently unscathed?
With any problem with the power supply on a Spectrum, TR4 is the first thing to blame, and sure enough, that was now acting as a resistor.
Samsung used a different part here, a BC2236A, which has a different pinout to the ZTX650 part Sinclair used.
I replaced that (using the alternate set of pads with the correct pinout) with the slightly uprated ZTX651 I normally use. I had removed TR5 to test that, it did pass, but I decided to replace it anyway, also with an uprated part, a ZTX751. I still can't see how failure of these parts would have caused the damage though.
A new capacitor completed the replacements, ready to try it out.
Success, we have a worker. The voltages all measure correctly, so time for some soak testing.
It looks like the RAM has all survived, no problems detected.
One thing I did notice during testing was the power connector was a bit flaky.
I reflowed those, but it was still intermittent, so I fitted a new connector. That's the usual sequence of events, the connector gets a bit loose or corroded inside, so the user finds if they wiggle it about, it works in certain positions. This continues for a while, with more and more wiggling, until the solder joints start to crack and the connection becomes even more intermittent.
I also found two columns of keys weren't responding 5 down to V and 6 down to N, which is actually the same connection. On the Spectrum+ the membrane is 4 player (to achieve the magic of the " key pressing Symbol Shift and P at the same time) and the two clamps at the top of the keyboard need to be tightened to ensure good contact between the layers. That fixed the missing keys.
More testing, with the divMMC future and all appears well. Nothing is running hot (other than the ULA, but that's to be expected), and the voltages all check out. But I still don't know how it failed. Those components feed the 12V and -5V rails which are exposed on the edge connector, could some external voltage have got on there?
I've got some vague idea that the power supply connector might have lost it's 0V and somehow got a path back to ground via the TV lead and ended up with half mains voltage across it, but I can't quite make that add up. Answers on a postcard please.

Sunday 10 June 2018

ZXBaremulator - Bare metal ZX Spectrum emulator for Raspberry Pi

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

ZXBaremulator is a bare metal ZX Spectrum emulator for the Raspberry Pi by José Luis Sánchez , and something I have been meaning to look at for a while.
This runs directly on the Raspberry Pi, using it as a single board computer, rather than a linux box (in a similar way to the RISC OS Pico I used with the Acorn Electron). Without any operating system in the way, it boots within a few seconds of powering on, and you are greeted with the familiar copyright notice.
From here, you can type away and run BASIC programs.
Press ALT+K to see a cheat sheet of all the keys available.
As nice as that is, you're probably going to want more. Press F1 and you get a menu that allows you to select tap or tzx images (but not z80 it seems).
Once one is selected, you press F1 to go back to the Spectrum, and type LOAD "" as usual.
The tape image then loads as normal (although it is speeded up a bit).
After a short while, the game is loaded and you can play to your hearts content.
CTRL+break resets the Spectrum, and you can then go and select another game.
You can also select 48K, 128K and +2A using ALT+F2, F3 and F4,
I have been running these for a while, through all my usual test titles and it seems to be running well.
Even passes all the diagnostics tests in 48K and 128K mode.
The only issues I found were the top and bottom of the screen, on power on, the top line appears to have a small section missing in the top left.
After selecting a program to load, the gap at the top is gone, but there is now a thin blue line along the bottom of the screen.
The other issue I had was lack of sound, I think that is because I was using version 2.0 of the software. V3.0 apparently has sound, but doesn't work on the Pi Zero.
One of the reasons I wanted to look at this was to check compatibility with my ZX Spectrum USB keyboard kits. I have been using these for many years, mainly with the Fuse emulator, so I expected it to work.
All seemed fine, until I tried to type LOAD "". It seems that symbol shift wasn't being recognised. I had seen a similar issue with an unusual emulator for older Macs that used the right alt key for symbol shift, rather than either control key, as most other emulators use. However, I had been using ctrl+p on a standard USB keyboard during testing.
After further investigation, it turned out that when my Spectrum USB keyboards are switched into emulator mode, I was only sending keypress codes for the shift keys. This isn't an issue normally, and was required by another unusual emulator someone was using. When I set it to send the key as both a keypress and a modifier, it started working.
The ZX Spectrum USB keyboards come with a button on the back to change between modes. In the 'normal' or 'desktop' mode, the keys are remapped to be most useful. Caps lock + keys on the top row give some extra functions, which are handy for starting and selecting games in an emulator for example.
I have produced a revised version of this which includes keys used by ZXBaremulator, F1 to load the menu, Alt+F2/3/4 to select a machine, F8 to stop and start the tape. I've used caps shift+enter to show the keyboard shortcuts, and caps shift+space to reset the Spectrum. Those are all available in the normal mode, press the button on the back to enter emulator mode, where all the keys are passed directly to the Spectrum, and press the button again return to the alternate layout and use the extra keys.
I have build many versions of the 'Raspberry Pi inside a ZX Spectrum' over the years.
These often involved extra power boards and cables, and with the Pi zero, usually a USB hub.
Today, however, I went for a more basic approach. There are many ways to mount a Pi zero, but you could just use a sticky foam pad.
There is an option to use the 4 pin header to wire up the USB keyboard, but you can just use a right angled cable.
The ZX Spectrum USB keyboard kits are available from my Tindie store.

Saturday 2 June 2018

The Ultimate History of the Penultimate Cartridge

It all started out as a mild curiosity in a junk yard...... London 1965... No, where was I? Ah yes, the prologue.
With a new release on the way, I thought it might be interesting to look back over the history of the VIC20 Penultimate Cartridge.
The first VIC20 Cartridge based thing I did was convert a dead Super Expander into a diagnostics cartridge. From that I learned how the cartridge port worked, and decided to make my own simple cartridge.

V1 - VIC20 ROM/RAM Cartridge

This had 32K of RAM (as 3K + 24K or 32K), and eight 8K ROM images, all selectable though seven DIP switches poking out of the top of the cartridge case.
This board has since been repurposed as the ROM/RAM cartridge I use with the diagnostic test harnesses. With the DIP switched based ROM selection, you can launch straight into diagnostics. The later menu based versions aren't much use for diagnostics. If you can boot up, and navigate through the menu to where you would launch a diagnostic cartridge, then you probably don't need one as the system would seem to be working well enough.
The current version comes with a blue soldermask to fit better with the rest of the diagnostics kit. Although it is technically the Penultimate Cartridge V1, it never had that name.

V2 - VIC20 Penultimate Cartridge

When I ran out of boards, I revised that design before ordering more. I added more RAM, so it could achieve the maximum, 35K (3K+32K), and more ROM, to support thirty two 8K or 16K cartridges.
I decided to give this one a name, and there were lots of 'final' and 'ultimate' cartridges, that usually ended up with a V2 and a V3 etc. So I thought I would be honest with this one from the start and call it the Penultimate Cartridge (and it was already on V2.2).
This again was controlled by DIP switches poking out of the top of a standard cartridge case.

V3 - VIC20 Penultimate Cartridge with IEEE-488

Then came a bit of a dead end. For V3, I looked at integrating a disk drive, based on an IEEE-488 interface, with a plan to use a variant of my PET microSD.
That did work, but had the flaw that it needed a ROM in block 5 to be able to use it, so limited the use to 27K of RAM, and meant you couldn't (easily) load ROM images from disk to run cartridge games. Also most VIC20 software is quite small in size, so does not benefit from the faster access speed of IEEE-488 over IEC.

V4 - VIC20 Penultimate Cartridge with Menu

The next step was to get rid of the DIP switches. You can just make out the prototype was based on the V2 board with a microcontroller added to control the DIP switch inputs.
The micrcontroller is accessed via IO ports on the VIC to control the ROM and RAM settings without the need for the DIP switches.
The LEDs helped during testing to indicate which switch settings had been programmed in. Quite a fragile looking board with all those modification, but it still works today, and has only recently been replaced.
To control this, the first version of the menu was very minimal.
But it proved the concept, so onto the PCB version, that became the V4 Penultimate cartridge.
All of these boards had been designed to fit into original VIC 20 cartridge cases, with the section at the top sticking out to access the menu button. At this point I got into discussions with The Future Was 8 bit, who was keen to give the VIC20 platform some love, and prepared to invest rather a lot of money to get some new VIC20 cartridge cases made, if this turned out to be a viable product.
They had already had a great deal of success with an SD2IEC disk drive replacement for the C64 and VIC20, which is a wonderful tiny replica of a 1541 disk drive, in a custom injection moulded case.
Spurred on by the possibility or making such a polished finished product, I produced a new version of the menu software. The release version was much improved over the prototype, with features like a single button to load the file browser from an attached disk drive or SD2IEC, and joystick navigation.
I sold quite a few of these, and one of the people who bought one designed a label for it. Looks quite nice in the standard case.

V5 - VIC20 Penultimate Cartridge production version

With that now proven, it was time to look at the new VIC20 cartridge cases.
The idea was to follow more the style of the C64 cartridges, with the ridges at the top, and a section for a label. We also wanted to add space for one button at either side, using the same buttons as used on the SD2IEC case.
The 3D models looked very nice, so the tool was commissioned and the first run of cases produced. The early versions were a bit orange, a bit shinny, and ever so slightly banana shaped, so needed a little glue in the corners to hold their shape.
For the new case, we needed a new board, with the PCB rearranged by their in house PCB designer to fit in the new case, and to have buttons in the corners within the case. The button on the left is illuminated, this is the menu button, the button on the right is reset.
The initial batch were a sort of 'caramac' colour, almost a chocolate brown.
The shade of brown took a few batches of cases to dial in.
The original plan for a sleeve didn't work out though.
The idea with the case was always to be 'brown', along the lines of the Commodore utility cartridges, and the keys on the VIC20.
With just a hint of British Leyland.
We went through quite a few variations on the way there.
But it turned out very nicely, and worked well with the VIC20 and the SD2IEC.
With each batch of cartridges, the tooling has been refined, so these are now solid and square and fit together really well. Together with a new label, this makes a really professional product I am proud to have my name associated with.
That has been selling well, and has been very popular, with positive reviews from the like of ChinnyVision and the 8 bit guy.
The cartridge case has also been used for individual game releases, such as Cheese and Onion, an original game for the VIC20, the first in a commercially produced 32K cartridge.

V6 - VIC20 Penultimate+

Now it's time to change things up a bit. Add a larger ROM chip, and there can be more content on the cartridge.
My previous development board didn't have enough LEDs, so I made a new one, this time with some really nice hexadecimal display units, to show the mode and ROM selected.
This is V6, the Penultimate+. This now has double the ROM size, so the menu needed a bit of a revamp to make it easier to navigate.
The first attempt added named pages, so it was easier to cycle through, but it needed something a bit more. Whilst speaking to Misfit about adding more of his games to the cartridge, we discussed the options of a more graphical menu.
He produced a demo which looked really nice, but needed a lot of ROM and RAM, and was quite slow to render each time you changed page as it was redefining user defined characters to get around the lack of an actual bitmapped graphics mode in the VIC20.
It took quite a bit of work to both shrink it down to fit and to speed up the important sections with some hand turned assembler in the time critical bits, and to merge all that into the existing code to control the hardware.
This is now V6.1. and it's all a lot nicer to look at and a lot smoother. The graphical version allows more characters on the screen, so there can be fewer pages to scroll through, and we can have games with silly titles like 'Super Starship Space Attack', rather than just 'Gorf'.
The extra space now also contains more Future Was 8 bit titles, such as Cheese and Onion and Spaceship-1, previously only available on dedicated cartridges, and for the first time on cartridge, Pentagorat and more of Misfit's VIC20 games.
Some of these were quite a challenge, as they weren't written to run from cartridge, so I had to use all sorts of tricks to get all the game code loaded, and in the right place, ready to run the games.
One of the issues with the previous releases is some games were designed for NTSC, some for PAL. Some can detect the region, others can be adjusted by means of the arrow keys or joystick. Others just won't fit correctly in the wrong region. As an example, the VIC20 port of Q*Bert is pretty poor to be honest, but is one of the ones we felt we should include, but it will not centre properly on a PAL system. Depending on what sort of monitor you have, the left hand side is not visible.
To get around this, I have split the list of games cartridges by region. This is automatically detected on power on, and so you will only see titles which are designed for the region of your VIC20, or ones that can be adjusted (although you can get to the remaining titles if you want to).
The PAL list is slightly shorter, but includes titles not on the NTSC list as they don't centre correctly on NTSC systems. On power on the region will be automatically detected, and you will be shown the list of games for your region, but you can get to the other list by pressing P for PAL or N for NTSC.
These and other keyboard shortcuts should make accessing the menus even faster. There is now some online help available, press the H key and you will get a list of these hotkeys.
There is also a menu dedicated to text adventures, which, as before, automatically start (no need to type SYS 32592 to start them).
To avoid confusion, the games which need paddle controllers have been separated out to their own menu,
And finally, the utility ROMs are still present, with the addition of a drawing program and a terminal.
I have designed a cardboard sleeve in the style of Commodore releases of the day, in the same way I did for the other cartridges in the range.
The Penultimate+ is now available to order. We currently have a crack team of testers working around the world, around the clock, and it should be shipping very soon.
I've just received a preview proof of the new sleeve.
Just time at the end to roll the credits.
Thank you to all those involved.

*Note, this is a ROM and RAM cartridge with a selection of games on there to demonstrate the capabilities of the VIC20. These games are all in the public domain. If you like them, you should try to track down original cartridges, although these days the only people who would benefit from that would be the ebay sellers. We will remove any titles from future releases if requested to.

2022 Update: The updated version of the Penultimate Cartridge is now available from  The Future Was 8 bit

2023 Update: Now there is the Penultimate +2 Cartridge, available from  The Future Was 8 bit