Sunday 21 January 2024

Converting VIC20 Multi-Part Games - Outback

Another VIC20 Cartridge Conversion from the Patreon archive.

Outback is a quirky little shooting game where the player can only move up and down and fire, with a bit of a hint of Lemmings, and a stronger hint of Pooyan.

Outback was another of the challenging ones. First off was actually finding a working version. There were several tap files online, but none of them seemed to load fully, they would just run on after the final part was meant to have loaded.

There isn't anything to say there is a problem, it just sits there doing nothing. But, it has been set to black text on a black background. If I change the text colour, you can see the problem.

TFW8b had a cassette, and recorded tap files of both sides. Side A did the same thing, but finally the version from side B loaded.

It appears to be in many parts. The first parts goes straight to loading a second.


The second puts up a title screen with the "LEAVE THE TAPE" message, and it is presumably loading things in the background.

Changing the text colour again, this time it is loading correctly.

There may be several parts being loaded at this point.

Finally we arrive at "PRESS BUTTON".

Next you are prompted to enter a skill level.

And then the game begins.

For some reason the player wonn't move up or down and just autofires. I am told it works correctly on real hardware, but it did not work on vice.

That was the point I gave up at last time, as I thought the file was still damaged. However, now I think I know what was happening, I thought it warranted further investigation.

Further Investigation

This is a four part loader.

The first part does some copy protection, then loads the second part.

The second part loads the third and forth parts and then runs the game.

The first, second and forth parts are BASIC. The third is character data and assembled code.

Part one is mainly pokes. Let's see what is going on.

POKE 198,6 sets the keyboard buffer count to 6

POKE 632...POKE 636 puts 6 characters into the keyboard buffer. These are L, shift+O, return, R, shift+U, return.

L + shift O is the shortcut for LOAD and R + shift U is RUN. This loads and runs the second program.

POKE 648,30 sets video address to $1E00 (which is where it would already be on an unexpanded VIC20)

POKE 808, PEEK(808)+2 disables the stop key by changing the error handler from $F770 to $F772

POKE 37150, PEEK(37150) AND 127 This is the interrupt register on VIA#1 and sending 0111 1111 will disable all interrupts, including the restore key.

IF PEEK(56) > 30 THEN POKE 642,32 

If 8K or more is installed, this rearranges the memory to use the screen at $1E00

SYS 64824

64824 is $FD38, a call into the KERNAL ROM which will process the characters in the keyboard buffer as stored above (LOAD and then RUN)

Not sure why it does that as that would happen anyway when the program ends?

Program 2 then loads, lets have a look at that.

This uses a trick to detect when a program is run multiple times. At first run, A will equal 0, so the first statement will set A to 1, and then the ON A GOTO will GOTO 30.

30 prints up a title screen. POKE 36879,8 set the border and background to black.

It then does LOAD "",1,1 which will load from cassette to the address in the file. 

After the load, whatever program is in memory will be run. The program it has loaded has a load address of $1800, so that has gone into the memory at $1800. When it comes to do the RUN, the original program 2 is still in memory at the default load address of $1001, so that gets run for a second time.

Now, A goes to 2, and the ON A GOTO now GOes TO line 1000. Here it does the same keyboard buffer trick with LOAD and RUN as program one, and then the forth and final program is loaded and run.

This is a BASIC program, and is finally the game itself.

It starts with RUN 510, which jumps to the line which prints "PRESS BUTTON".

The Conversion Process

I worked out I only needed the following lines from the first program to disable run/stop and restore. 

POKE 808, PEEK(808)+2 : POKE 37150, PEEK(37150) AND 127

The rest is to do with loading part two and rearranging the memory if required. I control the memory arrangement for the game when loaded from cartridge, so it will not be needed.

I only needed the title screen from the second program, so I made a new BASIC program with the bits from program one and two combined.

I got rid of the ON A GOTO stuff and all the LOAD and keyboard buffer prep. We don't need that anymore.

I changed LEAVE THE TAPE to PRESS A KEY and added a simple wait on key press and then a SYS call back into the cartridge ROM.

Back in the cartridge ROM, it loads the character data to $1800, and the final program to the usual address of $1001 and then runs it.

I made one change to the game program, I change the RUN line at the start to bypass the "press button" / high score screen and go straight to the skill level selection screen. That screen is still displayed when you lose the game, it is only skipped on the first run.

I put it all together and tried it in the emulator and it worked, the player could move and fire.

I realised what it was that was stopping the player moving, the problem previously seen in Bandits (http://blog.tynemouthsoftware.co.uk/2023/08/inexplicable-autofire-explained.html) where the joystick read is done without masking the bits. If you still have play pressed on the datasette, it will read wrong. 

My cartridge version didn't use the datasette, so it is not a problem. I tested the tap version again in the emulator, and verified it wasn't moving. Then I stopped the datasette and the autofire immediately stopped and I was able to move and fire at last.



Advertisements

Penultimate +2 Cartridge

The Penultimate +2 Cartridge is in stock at The Future Was 8 bit, note the new website is TFW8b.com.

More info in a previous post:


Patreon

You can support me via Patreon, and get access to advance previews of posts like this and behind the scenes updates. This also includes access to my Patreon only Discord server for even more regular updates.

https://www.patreon.com/tynemouthsoftware