Sunday, 23 February 2025

A New Penultimate Cartridge Help Page

The VIC20 Penultimate Cartridge currently has a built in help page, press H and it appears.

It covers some of the main shortcut keys, but I would ideally have added at least another page to cover all the options and give some more information.

The trouble is the cartridge is packed full of things, so much so that I am always running out of space.

That has happened again. I am currently working on adding a new feature to the cartridge, and so for testing, I have been producing versions with the games list removed. That is not needed during the testing, and frees up the space required in order to test the new feature.

You might have noticed that on some recent videos from TFW8b.

I got to thinking, could I solve both problems in one go?

If I extracted the help into a separate program, that would free up space in the cartridge and would also allow me to expand the help.

Perfect.

Should be easy, 5 minute job ....

.... 5 days later .....

Let me go back to the start.

Writing this in BASIC might have been an easier option, but that would probably produce a larger file size which ran slower.

Using anything other than BASIC to write to the screen on a Commodore machine can be a world of pain, as the character code don't match what appears in the video RAM, and the compilers and assemblers attempt to address this in ways that generally make it worse and you get into trying to work out if you should add or remove $40 or $80 or $C0 or some other random number, to each character.

See all the fun I had with cheese and chive on the PET

I decided to try and start with some already working code. 

I had successfully used a few different approaches in the past.

VIC20 Dead Test +

Going back many many years to the VIC20 Dead Test, that had a screen full of text, and was written in assembler.

Here I built up the screen programmatically, using macros to clean up the code.

That took quite a bit of code, drawing the lines for the boxes and adding all the text string.

Penultimate Cartridge Self Test

When I came to do something similar again, I got to thinking it would be easier to just have a pre-formatted screen full of text and just copy it into screen RAM in one go.

That is exactly what I did.

I built up a block of characters in the assembly file, and set it to be based at $1E00, the location of the screen RAM, so it gets loaded into the screen RAM as the program was loaded.

All I needed to do then was set all the colour RAM to have white text and add the few bits of fixed colour text were manually changed.

Help Text

That seemed the best option to use for the help text, I needed multiple pages, so I couldn't use the code loaded direct to screen RAM trick, but I could still pre-format several help pages and copy them into screen RAM as required.

You can see the remnants of the self test screen there in the first go at the help page.

You can also see where the problem starts.

Uppercase inverse text didn't work, I get a double quote instead of a capital M. The rounded corners also did not work, and I got uppercase J and K instead.

But it seemed like it was still the best option, so I set to work fixing those.

That required some user defined graphics. This is where it also gets tricky.

VIC chip addressing

The VIC chip accesses three areas of memory.

  • Screen RAM says the first character is 'A'
  • Colour RAM says the first character is green
  • Character RAM contains the bitmap pattern to produce the 'A'

The colour RAM is fixed, in one of two locations, $9400 or $9600 (for reasons which are unlikely to become clear again at the moment).

The other two can be moved around within the VIC address space. It is important to note that this is arranged differently to the CPU address space.

Borrowing that table from one of the Mini VIC posts, you can see the VIC can access various areas of the internal bits of the VIC20, but nothing in the cartridge port.

The mapping of the different areas is configured using register $9005 (and a bit of $9002).

This is in two halves.

  • Bits 0-3 set the location of the character RAM
  • Bits 4-7 set the location of the screen RAM

By changing those values, you can move the screen and character locations around.

Here is a table of useful values

  • $Cx - Video RAM at $1000
  • $Dx - Video RAM at $1400
  • $Ex - Video RAM at $1800
  • $Fx - Video RAM at $1C00
  • $x0 - Character ROM $8000
  • $x1 - Character ROM $8400
  • $x2 - Character ROM $8800
  • $x3 - Character ROM $8C00

There is also one more thing, bit 7 of $9002. If this is high, then add $0200 to the Video RAM address (i.e. Cx = $1200 etc.)

The default value of $9005 is $F0, and $9002 is $96, so video RAM starts at $1E00 ($1C00 + $0200) and character ROM starts at $8000.

With 8K or more RAM installed, the values change to $C0 and $16, so video RAM now starts at $1000 ($1000 + $0000).

There is also nothing to stop you setting the character ROM as screen RAM or setting them both to the same location or lots of other things that will not work etc.

You can also do odd things like setting the video RAM to $0000 with $9005 = $80, which gives you a visualisation of the first 506 bytes of RAM including zero page and the stack.


Character RAM base address

-
-
$9005 bit 7
$9005 bit 6
$9005 bit 5
$9005 bit 4
-
-
VIC
CPU
A15
A14
A13
A12
A11
A10
A9
A8
Base
Base
0
0
0
0
0
0
0
0
$0000
$8000
0
0
0
0
0
1
0
0
$0400
$8400
0
0
0
0
1
0
0
0
$0800
$8800
0
0
0
0
1
1
0
0
$0C00
$8C00
0
0
1
1
0
0
0
0
$3000
$1000
0
0
1
1
0
1
0
0
$3400
$1400
0
0
1
1
1
0
0
0
$3800
$1800
0
0
1
1
1
1
0
0
$3C00
$1C00

The character memory

This default setup gets all the characters from ROM. Which is fine if you want the standard PETSCII characters, but if you want to define your own, you have to move the start of the character memory into an area of RAM.

To create your own characters, add these to the mix

  • $xC - Character memory at $1000
  • $xD - Character memory at $1400
  • $xE - Character memory at $1800
  • $xF - Character memory at $1C00

The VIC20 character ROM is made up of 8 bytes per character, and so 256 characters takes up 2K. That is a big chunk of available RAM to dedicate to graphics on an unexpanded VIC, but when you have 35K or more to add, it is acceptable.

Screen RAM is a lower requirement, 23 rows of 22 characters, and 1 byte per character, which is 506 bytes.

If you set $900F to $CE, you would have the video RAM at $1000-$11FA, and the character RAM from $1800-$1FFF.

One trick you can use is $CF, set the character memory to start at $1C00. It is 2K long, $0800 bytes, so you might think it would run from $1C00-$23FF. But $2000 upwards is expansion RAM in the cartridge slot, and the VIC cannot access that. What actually happens is the VIC address wraps around and you actually get $1C00-$1FFF for the first 128 characters, and then the second 128 characters come from the character ROM at $8000-$13FF.

Look again at the memory map and it should be easier to see how address wraps around.

It turned out the characters that I needed were not in the section of the character ROM that was visible, so I went for the full 2K option to be able to get all the characters I needed, including the rounded corners and inverse upper and lower case letters.

I was able to start refining things such as making the dash smaller so I didn't need the spaces either side of it.

To match the main menu, I extended the side bars to the edge, so I needed custom rounded bottom corners.

I tried making the navigation buttons big and yellow. Not sure how I feel about those.

Well, now I am here, maybe I could use the logo from the cartridge menu. I wasn't sure if I could make it work, but I tried the first few characters and it looked promising.

It's going to need two lines.

Looks good.

I just need to make the 3 yellow to match.

I also made the navigation buttons smaller, that looks better.

Next came the task of arranging all the text I needed into several pages.

It worked out best as three pages.

I have had to censor a section of page 3 covering the new feature. My Patreon supporters will find out about that in a few days time, if you are not on there, look out for an official announcement from TFW8b #soon.

All that was left was adding that to the Utilities menu.

Sorted.

Now there is more detailed help, and enough space in the menu ROM to add the new functionality. More on that very soon.


Advertisements

The patched versions of Bandits and Multitron are included in the new Penultimate +3 version which also has a built in SD2IEC drive.

Shipping now with the new feature, more on that next week.


Tindie

Minstrel 2 and 3 kits are available from my Tindie store, with worldwide shipping. Versions avaiable for ZX81 case or standalone with keyboard, and also Misntrel 3 with ZXpand microSD card interface (andn now available as PCB only).

I will slowly be moving things over there from my SellMyRetro store, so if there is anything that you want, let me know and I'll add it.

Patreon

You can support me via Patreon, and get access to advance previews of posts like this and behind the scenes updates. This particular post had a section removed on the way the bits add up to make the was originally about twice as long before I cut it down, so if you want all that detail, join the Patreon. This also includes access to my Patreon only Discord server for even more regular updates.