Another of the behind the scenes updates on the Penultimate Cartridge update that my wonderful Patreon supporters got to see back in August.
In the first part of this post (back in July on Patreon), I had freed up quite a lot of space in the VIC20 Penultimate Cartridge, ready to add more new games.
More new games have since been sourced, tested and added.
As I added the last batch of games, I hit a different problem.
There are two sorts of menus on the Penultimate Cartridge, fixed pages, such as the utilities, paddle games, RAM options etc., and dynamically created lists, such as the disk directory listings and the A-Z games menu.
The A-Z list is dynamically generated from a big array of games, which can be filtered by region (PAL or NTSC or both), or by category (space invaders, maze games etc.) or by creator (TFW8b titles, games by Misfit etc.).
ED: We saw the "Centipede type games" menu in a previous post -
From the same pragmatism and paucity of ambition that previously gave us "no one will ever need more than 640K of RAM", the Y2K "Bug" and the forthcoming attraction "Unix Date Rollover" in 2038, comes "we're never going to fit more than 256 games into the Penultimate Cartridge".
For practical reasons of running on an 8 bit microprocessor with limited RAM and processor cycles, using one byte as the index to that array seemed perfectly reasonable when I designed the dynamic menu however many years ago that was.
It was a calculated risk, I think at the time there were about 100 - 150 games in the ROMs, and they were full, and as is the case today, two 1MByte ROMs is the most we are likely to fit into the cartridge as it currently stands.
This list is already a subset of the games on the cartridge, as the programming utilities, text adventures and paddle-only games are excluded from this list and live in their own dedicated menus.
The "up to 256" items in the A-Z list are also the ones selected by the "Rod's Random ROM Runner" random game selection feature, and again there, you wouldn't want to hit a RAM test program, or an Assembler Monitor or a game that needed a different controller to the one you have.
Why Are You Telling Me This?
Ah, well, whenever I add a load of games to the list, I need to remember to hover over the array constructor to check it is still under 256 items. (I don't think the assembler has the equivalent of a #assert, although I must look into that ...)
Ah, 260 items. Whoops.
That is a useful feature of Visual Studio Code, although continuing the rant from a previous blog post, I can't actually edit this file in VS Code as every time I try to type inside the array it "helpfully" blocks out half of the screen with a hovering box.
That is now showing 259 items as I had already removed one. The menu used to contains "Matrix" and "Attack of the Mutant Camels", as the game seems to be known by both names, but both launched the same game.
That used up two menu entries, so I have commented out the "Matrix" one. The game does not give it's name on screen, other than the letters AMC, and that is a better name anyway.
ED: Later I was also running out of space in the menu ROM itself and reversed to "Matrix" as that was 21 bytes shorter, and yes, I was really that short of space. But not space in the overall ROM (which I freed up by adding compression and combining multiple regions of the same game), and not the number of items in the games menu (which I hope is not a spoiler that I will have freed up by the end of this post), but next I was short of space in the ROM which contains that list and the code for the menu and file browser, but more on that in a later post.
Making (more) Space
I still would like to avoid removing any games if I can, since there is still space to fit the binaries in the ROM, the only limitation is the menu entries ... #foreshadowing
Looking thorough the menu ROM, there are a few things that stand out as options. There are several games which have different PAL and NTSC versions. These require two menu items. One which will only appear on the PAL menu, and one which will only appear on the NTSC menu.
When the cartridge starts up, it checks if this is a PAL or NTSC VIC and limits the menu accordingly to games that will run on the current system and removes any which will not fit on the screen or will show screen corruption due to different screen sizes / timings.
If you press the "A" key in the menu (not to be confused with the "ANY" key), it will show you all the items, including the ones that will not work properly on your system, indicated by the X in the right hand column.
There are two versions of Alien Blitz, neither of which has screen adjustment, so the NTSC version is not normally shown here in PAL land. (also neither of them is a Blitz game, although they do contain Aliens, so 50% is OK I suppose)
If you run it the NTSC version, you will see it is off the screen.
Although thanks to the frustrating VIC20 screen settings, that ROM runs correctly in NTSC land.
The PAL version is horizontally centered (although not vertically), but does not work in NTSC.
Also on the the excluded list there was "Alien Sidestep". This is one which does not work on a PAL VIC. I must look into why, it displays the menu, as usual out of place, but it never starts the game.
I have tried pressing all the buttons, the usual fire, space, enter, run/stop, f1-7, and all the others, including the any key. For some reason it is stuck in the title screen and never exits.
The same ROM on NTSC is fine.
Again, Why Are You Telling Me This?
Well, using the technique I developed in the previous post, I can free up some of the menu entries by creating some multi-region versions.
The multi-region version will usually free up even more space in the ROM, but more importantly will replaced the two entries with a single one.
The only problem is I have already tackled the easier ones in the previous post. The few that remain were not modified last time as they looked like they could be tricky, or ones where they were in places that would leave small gaps in the ROM, requiring it to be manually defragmented, which is a long a tedious task, although ultimately rewarding each time you find a combination of games that add up to exactly $80 blocks (32K).
Alien Blitz
Since I have already mentioned it, I will start with Alien Blitz.
This is slightly odd as the NTSC version is a cartridge, and the PAL version is a PRG file, presumably recovered from a tape. I guess the cartridge was more popular in the US and tapes were more common in the UK?
I could just patch the NTSC cartridge version (and maybe do a better job of the alignment and centre it in both directions?), but since there is an original PAL version, I should use that.
I considered a few ways to do this, but this is what I came up with.
The original NTSC cartridge was 4K, and the PAL PRG file is 3.5K.
I extended the 4K NTSC cartridge into an 8K cartridge.
The VIC cartridge header is as follows:
- 2 byte cold start vector
- 2 byte NMI vector
- The letters "A0" (indicating this is a cartridge that lives at A000)
- The letters "CBM" (Commodore Business Machines - Business? in a games cartridge?)
The 4K ROM started with the addresses it would jump to at boot to start the ROM. I modified those to point at a new routine I put in the empty upper 4K of the cartridge ROM.
Here I checked if this was a PAL or NTSC VIC (check the first byte of the VIC settings at $EDE4, if it is $05, this is an NTSC VIC).
If it was NTSC, I jumped back to the start routine in ROM. The NTSC ROM runs as normal with only a slight deviation from the normal start process.
If it is PAL, I go through the initialisation routine (since this is bypassed when starting a ROM cartridge), and then copy the 3.5K game from the end of the ROM into base RAM where it would normally have been loaded to, and call the appropriate BASIC ROM routines to treat it as if it had just been loaded from tape and run it.
The resulting 8K cartridge is now actually slightly larger than the separate PAL and NTSC versions, but I have freed up enough space elsewhere that I can take the 0.5K hit in exchange for saving one menu entry.
Rigel Attack
This was an interesting one, we had two 12K PRG files, one for PAL, one for NTSC, which were clearly built from the same source, but with too many differences due to all the code being relocated when building the different versions.
If you load the wrong region, the player ship falls off the bottom of the screen.
Originally, I had both versions in the Cartridge
12K + 12K = 24K
Later, I exomised both, so that reduced the total to
6K + 6K = 12K
That was using the old system of having two entries on the menu, one for PAL and one for NTSC, when different versions were required. Now with hitting the menu limit, I need a single file and a single menu entry.
Here again, there were a few options, I could have a loader program that would copy either the PAL or NTSC program into the right place in RAM and then run it.
However, due to a stoke of luck, I could use a similar technique to the multi-region Alien Blitz cartridge above.
Normally the PRG header is as follows:
A zero, The first byte in memory ($1200 in this case) is always zero.
A two byte pointer to the end of the header.
Then the first (and usually only) line of code
A two byte line number (normally 10, although I prefer to use 6502)
The code itself
A zero to end the line
Two zeroes to end the header
The line of code is normally something like
10 SYS4621
4621 is the address of the code to run, $120D (I remember that as I used to have a Citizen 120D+ printer for my Amiga 500).
This is stored as $9E, the token for SYS, and then the four characters for "4", "6", "2" and "1".
The code then starts immediately after at $120D.
That means you can change that to any number up to 9999 ($270F), without having to move any code.
In this case, the line was slightly different.
10 SYS 4622
This is jumping to 4622 ($120E) because it is one byte longer, the code includes a space after the SYS command, so everything is moved along one byte.
The code line is now the $9E SYS token, the space character " ", then the address "4", "6", "2" and "2". (N.B. the space after the line number is never stored, it is always added when the program is listed)
The code then follows at 4622 ($120E).
I built up a program with both versions and added some code to launch the appropriate version.
The PAL game runs from $1200 to $3FFF.
The NTSC game follows from $4000 to $6CFF.
The loader code is at $6D00, 27904 in decimal. Five digits.
Because of the extra space in the SYS command, it was possible to change it to a five digit number. Had I been limited to four digits, I couldn't have had the test program below address 10000 in decimal, and that is the middle of the PAL game.
The space and 4622 were changed to 27904 and everything else in the PAL version was left the same.
10 SYS27904
This now runs the code at $6D00 at start up.
This checks the first byte of VIC settings, $05 for NTSC, $0C for PAL. If it detects PAL, it jumps to $120E, and starts the game that is already in place.
If it is NTSC, it copies the NTSC version from $4000 down to $1200, then jumps to $120E and starts that version.
The combined file is 24K, but when exomised, is only 7K.
24K originally, down to 12K in recent versions, finally down to 7K, and also frees up 1 more space in the menu.
Win win.
K-Razy Antiks
This one was a bit k-razy.
The game itself certainly is. No clue what is going on there.
The NTSC version was two 8K ROMs.
The PAL version was a 4K ROM and an 8K ROM.
Looking at the lower 8K ROM of the NTSC version, the first 4K is one byte different to the PAL version, and then the next 4K is seemingly rubbish, random data. Possibly when it was ripped, 8K was read when there was only a 4K ROM present?
The upper 8K ROM is 15 bytes different, presumably region changes.
However, there is one odd difference in some odd code.
It starts off OK, copying what is probably character data, from the ROM at $Axxx range into the RAM at $1xxx.
It then zeroes the whole of zero page ($00xx), which is fair enough. If you don't want to use any KERNAL or BASIC functions that need zero page, go for it.
STA $00,x
Then it zeroes a page of memory from $8000 to $80FF.
STA $8000,x
This area is where the character ROM lives. It is writing to the character ROM, or at least trying to?
Makes no sense.
In the NTSC version, one byte of that is changed, and that line now reads
STA $B000,x
This zeroes a page of memory from $B000 to $B0FF.
$B000 is the cartridge ROM. Now it is trying to write to the cartridge ROM?
If you happen to be running from RAM, this will overwrite some code and stop the game running. Maybe that is intentional copy protection, but then why change it in the NTSC version?
Or maybe did someone patch that in the past to allow it to run from RAM and $8000 was the best thing they could have of changing it to where it would do no harm (other than bus contention, since the VIC address decoding does not include the R/W line, so it will enable the ROM, which will write data to the bus at the same time as the CPU is also trying to write to it, with hilarious consequences, eventually)
The RAM the Penultimate Cartridge runs the game from is read-only, so it is not a problem in this case.
Atlantis
This was an easy one, two 4K carts, one for PAL, one for NTSC.
If you got the wrong region, it would crash horribly.
This one I converted like the ones in the previous post. A new PRG file, containing both cartridge versions.
The appropriate one is selected and copied into RAM and then run.
Originally 2x 4K, the combined program was 8.5K.
That exomised down to 4K and freed up another menu space.
Is That Enough?
Along the same lines as Atlantis, I converted Squishem, Spider City, Terraguard and Sub Chase.
With those I was able to free up enough space to get the menu down to 249 entries.
Safe for now.
Well, it would be if the menu data had not overflowed the available space in the part of the ROM where it lives, so I had to shuffle a lot of code around to make it fit.
But we're OK for now.
Still space for some more games, but limited menu entries available.
I am going to need to make some big changes if I need to add anything significantly more over the next few years.
Maybe I need to start thinking about the Penultimate +4 ...
Adverts
The VIC20 Penultimate Cartridge +3 DCR is available now from the Future Was 8 bit.
All Tynemouth products are still available, and I can ship worldwide.
Including the limited edition 10th anniversary recreation of the very first Penultimate Cartridge:
International shipping is a bit complicated at the moment, so if you want to order from outside the UK, please contact me using the contact link at the top of this page.
See here for more information:
Sorry to have to do this, and I know this is going to affect sales, but please understand it is the only option I have right now.
Stop Press!
I am going to do another batch of Mini PET 40/80s with keyboard, with a few updates.
These are pre-order now, shipping worldwide end of November. £450 kit / £500 built.
Available exclusively from me, contact me using the link at the top of the page to get a price for shipping and any duties, based on your address.
The Mini PET 40/80 internal PET replacement boards are also available now, £350 kit / £375 built.
Again contact me if interested.
Patreon
If you enjoy posts like this, you can support me via Patreon, and get access to advance previews of blog posts, and exclusive posts.
You also get progress updates on new projects and other behind the scenes updates, as well as access to my Patreon only Discord server for even more regular updates, and to discuss your own projects.








































