“Toxic Frenzy” game diary

This is a mini diary of learning 6502 Assembler programming for Commodore 64. It’s actually been a couple of weeks since I started this so will only have some short summaries I can remember and what I can gather from the Commit history of my code to Github.

The Github repository for my game was created on September 19, 2020. But the first commit with any meat was on:
September 22, 2020
Commit comments : “Added libs, charset, sprites and koala image”.
The ‘libs’ used are the ones by Derek Morris. He created them while writing his book and has provided them to the community. I actually copied them from Mike Richmond’s Vegetables Deluxe code he shared with me. I later found out he had commented out code in the libs he didn’t use. I had to un-comment them once I found they were not working 😀

The original Koalapaint image was created using Multipaint and looked something like this:

My C64 Multipaint version
Original image

I tried keeping the colours and design exactly like the Game and Watch LCD screen version of this game. I also designed a lot of the sprites I needed using SpritePad. Then I imported them into CBM PRG Studio and did all future editing and adjustments in that. I had not actually created a customised charset as yet.
The sprites in SpritePad began as this:

There has been some changes since as I’ve re-ordered them for making my coding easier and added other sprites as needed.

September 23, 2020
I had some initial issues with the Koalapaint image code to draw the bmp on the screen. I did not originally fully understand how the code worked. It was provided to me by Mike Richmond. Once I understood it better I ran the code again in the Debugger or VICE emulator and suddenly I had my bitmap displayed correctly! I was surprised as I had not expected it to work.. or at least not work properly. I also was not sure if I had drawn the image correctly while avoiding colour clash due to having too many colours in the one 8×8 character block.
On the same day my commit messages show I updated Mike’s code to have constants and updated more direct addresses to constant labels.

September 24, 2020
I thought I began to understand Zero Page and wanted to store variables there. I soon learned that’s not the way and just used normal memory addresses for variables. I fixed a sprite not displaying correctly issue and tidied things up a bit and defined sprite name constants.

September 25, 2020
I sorted out a lot of sprite positions by setting them up one at a time and manually adjusting X, Y, Enable and other values until they showed up where they should. I also tweaked the background a bit so it would line up with the sprites more correctly. I soon also discovered that even though I had merged a bunch of sprite usage into 1-2 sprites the lowest number I could display on the screen at one time was 9 sprites! The Commodore 64 only has 8 sprites it can display at once and so began my first attempt at multiplexing a sprite. I decided the two ‘misses’ sprites may as well be the ones multiplexed. They displayed similar information and did not change too often. I also found some 6502 code online to help with defining points to add to the Score as well as updating the score when you add the points. This was just updating the Score variables (3 bytes – one each for hundreds, tens and ones). I tested some output and it worked nicely so that saved some trouble.

September 27, 2020
It looks like I took a break for a day on the 26th. Sometimes my brain just wasn’t in the right mood for coding so I watched some of The 100 on Netflix in order to veg out. On this day I used self-modifying code to update the score sprite display and updating. I was happy about that as it was also something I’d not done much of in the past, but it worked! Also, during testing I picked random numbers from 0-9 in each score digit position. I soon discovered during my previous coding I had not tested the number ‘9’ (number 9.. number 9..) and it did not display anywhere. Now it does! I also realised it seemed silly to display a score such as 005 or 021 since even the main Game and Watch game did not show leading zeroes. I soon fixed that, however just leaving off the ‘0’ in the tens column is not useful if the score is 104 — it showed 1 4 instead! Oops! Soon fixed that as well.

September 28, 2020
I’d had enough of getting sprites and stuff to display in the main game part and so decided to try coding a Title Screen. Initially I just wanted a basic design so that when I hit FIRE to start the game it’d jump to displaying the bmp and sprites. I’d later come back to do the ‘proper’ design of the title screen.
I kinda got a bit carried away and soon got busy making a whole design for the title screen! I redefined some characters to build up a big logo and wanted to have some delicious rasterbars behind the main logo.

First take of the title screen

I was very happy with the basic logo design with funky rasterbars behind it. I also added rasterbars behind the PRESS ‘FIRE’ TO START THE GAME! line which went right across the screen into the borders and also a colour-sweep through the text at the bottom. You can see a little bug where the letter “O” in JASON is missing. It’s there but it’s coloured black. I soon fixed that issue. I discovered it was going to be too much to make the PRESS FIRE rasterbars reach all the way into the borders so I turned that off and they were a little more stable. I was using Derek’s libraries to do the raster stuff but could not get it to be stable and there was some flickering in the TOXIC logo.

September 29, 2020
I added some sprites with movement under the TOXIC logo. I found a Windows program on the csdb which let you calculate values for Sine Waves so I got it to output data to move my sprite letters up and down in a wave. OldSkoolCoder helped me stabilise the rasterbars in the logo.

Ooh! Bouncy letters!

In the above image you can see the flickering before it was fixed, but also the colour sweep and bouncing sprites! I was excited! It was coming together as I had pictured it in my mind. I had done little planning. This idea just hit me and I went with it! However, I was not that keen on the letters seemingly being led in their up-down movement by the last letter sprite, so I recoded it to go the other way 😀 I also had to move these sprites to the same memory bank as the charset as there was no longer enough space for the sprites and charset in the same bank as the main game graphics.

September 30, 2020
OSK helped me code a 1-pixel scrolly message along the bottom. I decided there was enough colour and movement on the screen so left this a static colour. I edited the text about 12 times, slightly changing the message each time but keeping to a maximum of 255 letters for making coding easy.
I got the scrolly message going nicely then realised I had not left any space for my “Blue Bilby” logo which I like to have in all my games (well, so far this one and Corey Coolbrew!). I moved it around a few times. It would fit nicely next to TOXIC but that screwed up the rasterbars and I certainly did not want that to happen, so I shrunk the sprite size and squeezed it in to the left of the F in FRENZY. OSK helped me with getting the FIRE button detection to work. I also discovered a bug in VICE where it displays a single white pixel lit up. I tested the code in another emulator and the debugger as well as loading it up on my actual Commodore 64c and it did not show:

Titlescreen with the little Blue Bilby logo!

Testing on my LCD TV:

Short test on LCD TV. No extraneous dot!

October 2, 2020
By this stage my single code file was getting quite large so I split out the title-screen code to its own .asm file. This became really handy later as I began running out of space to store code! I also made the Blue Bilby logo glow, by copying the blue colour-sweep colours to the sprite as well. It made the logo look a bit nicer than a static image 🙂 There were a couple of badlines in the TOXIC logo so I had to redesign the colours a few times but also the rasterbar stripes didn’t look great in my first few designs. I must have retried them about 8 times. I thought by now someone should have made a website where you type in the colours you want to make into rasterbars and it outputs the data you need. All I found were websites or programs you can run to define the colours manually and see how they would turn out. That’s okay, but not ideal. So, lots of trial and error. At this stage my two week work holiday was nearing an end. I had planned the Saturday to drive to Sydney and catch up with some friends, also because one of my friends was giving me one of his Amiga 500 computers! It turns out he gave me TWO of them! So no coding for the next couple of days and I was dog tired after all that driving.

October 5, 2020
Mike Richmond provided me with the music and sound fx I had asked him to design for this game. They are fun tunes. I inserted the code on the title screen and it just worked first go! I was very surprised as I was concerned I was running out of CPU time what with all of those rasterbars etc 😀 I guess hardcore demo coders would know better. Anyway, I tried adding the in-game tune and it’d play but had tiny pauses and skips. I talked it over with OSK and he suggested disabling interrupts while the rastersplit happened when I multiplexed a sprite, then add the music at the bottom. That worked, too! I did have an issue where the bottom ‘misses’ sprite no longer displayed. I worked on the problem with him for about half an hour before I realised that a few days before I had disabled that sprite when you start the game as there are no ‘misses’ to display! I turned it on temporarily to test and it all worked nicely. WHEW! Lucky!!

October 7, 2020
I finished work so decided to get busy. I worked on code to get the man with the barrel — “BarrelMan” in my code — to move and do his basic animation. It worked a treat and I uploaded the code to github then decided to start writing a blog diary before I forgot what I was doing 😀

Title screen and main game with music!

October 11, 2020

It’s been a few days. I’ve not been up to doing any coding so have put it off. I spent the 8th Oct scrubbing my new Amigas’ cases and keys from one keyboard. I had my podcast that night as well. The next couple of days I was in a funk and I won’t force myself to dev if I’m not up to it or it won’t be good.
Today I got quite busy. I set up the drips to pick a random spot on the X-axis. I found some useful Random Number Generator code online and with some tweaking it came up really well. I also defined the Y-axis values for the drips. This changed a few times as tweaking required.
Next I enabled it to play Mike’s “Game Start” ditty and pause the game until the tune had completed playing. That was a nice touch I really like.
More coding got the drips falling down in steps and making a “blip” sound Mike created. Very nice.
Since the ‘catch’ of a drip needs to be only tested once the drip reaches its lowest level, I put a check in the drip code to see if the player’s position was the same as the drip and change the border colour if it is. Just for a test. I’ll expand that in the future.
The last bit for today was testing joystick movement. I got it to test if the joystick was moved Left. I got a result for that and checked all my code into Github.
I keep getting more and more people to greet in my scrolly message. It’s quite amusing. I’m not sure it will be popular enough but I’ve added them all the same 😀

October 17,2020

Another few days, but I’ve had radio shows and a podcast to do so they cut into my C=64 dev time. Oh, well! 🙂
A new direction
I was talking to Vinny from FREEZE64 magazine last night on Twitter. We came to an agreement that Toxic Frenzy will now be an exclusive FREEZE64 Christmas game release! That’s fantastic! I released a Spectrum game earlier this year on itch.io with a ‘choose your own payment’ option. Over 800 people chose “FREE”. Two people paid with the total sales coming to USD$11. Now this will be an exclusive for FREEZE64 Magazine! How cool!
So now there’s been a few changes. The title screen now has “FREEZE64 PRESENTS” and the game background has changed to a Christmas themed version:

We wish you a Merry Christmas… o/~

So far today I’ve managed to get the bottom player sprite to display and drip out liquid if there’s some in the bucket. Now I’m checking if the “BarrelMan” is under the bottom player when tossing out the liquid.
Today I discovered that my score hasn’t been showing for some time. I was so busy working on other things I didn’t even notice it had stopped displaying so most of the rest of this day has been attempting to track down the ‘glitch in the Matrix’.
I’ve also managed to get the score variables to add up correctly when the liquid is dropped to the BarrelMan! Sweet!

October 18, 2020

I finally figured out why the score was not displaying. A call to play a sound effect overwrites register values. I had forgotten this when I added in an effect to play when the score goes up, so the indexing was way out of whack. I will preserve the registers BEFORE calling the sound effect and that should fix the problem! WHEW! I also discovered that the score routine I had used was not counting properly when it came to numbers. 9 + 5 was 14 but stored in the ‘ones’ column which could not show, of course. After the addition I had to subtract $10 and add one to the tens column (and hundreds column when it was that one’s turn to calculate). Sweet!

Time for another screenshot

I animated the man and woman if you drop the liquid on their head. I also added ‘drips’ coming off them when they are in ‘angry’ mode. Using GoatTracker, I created a BUZZ sound effect when animating the man and woman when angry. This game is coming along quite nicely and I’m very excited about it! 🙂

October 20, 2020

I didn’t do any work last night as I have a friend I game with and had not played in a while so I decided to have a little time off and do some gaming with him yesterday.

Today I got busy will detecting when the player’s bucket is full and they try to catch another drip. The comparisons were already programmed and left with a “; TODO <<<< Player’s bucket is full and drip hits the floor”. I set it up to animate the flame sprite I’d already designed and play the BUZZ sound effect above which was used when the people were angry. I also made it add 1 to the TopMissed counter so I could check if they hit 3 misses. I then added in a checkMisses section which only looks to see if you have 2 misses at the top or the bottom. No code has been written yet for the bottom misses but the storage is waiting for it.

By this stage you will need a GAME OVER event to occur so I designed some sprites in spaces I had left where there were sprites designed before but were no longer required. They line up on the screen nicely and add a good ending touch to the game. It also plays the “Game Over” tune which Mike wrote. At this stage it just stops there. In the future I’ll make it go back to the title screen but it does pause on the end screen after Game Over so you can look at your score, check where misses were, etc.

October 22, 2020

When the bucket is full and you try to catch a drip it will fall to the ground and start a fire which animates. I did some tweaking for the Game Over sprites and code.

October 23, 2020

Fixed it so that once you finish a game and go through the Game Over sequence then start a new game all variables are reset to their correct values. Fixed resetting the score to 000, player position and drip position.
During testing I discovered the drips would always start in the middle and the first time the player ‘caught’ a drip it did not register and the drip just restarted at the top of the screen in a new position. I changed it so at the start of every game it’d select a new random location for the drip and this also fixed the drip not being caught. Nice!
Wrote some more code so when you miss a drip because you are not standing at the drip location the drip would fall on the floor and start a fire. Also if the player is standing in the centre of the screen when the Game Over sprites come down to that location it will first move him to the right and out of the way of the sprites.
Top and bottom ‘misses’ sprites were coded and display correctly. Removed an extra ‘drip’ sound effect which wasn’t needed. The guy with the barrel now starts in the correct place for each new game.

October 24, 2020

Added a bonus at 300 points as per original game. If you have any ‘misses’ registered it will remove those and reset them both to zero. I also created a new sound effect in GoatTracker to play when this bonus occurs. Fixed the top and bottom misses sprites so they continue to display while the Game Over tune and animation is happening so you can still see both.
I also added LAST SCORE to the title-screen, gave it some colour flashing and updated the numbers so it shows you the actual last score in the previous game which is nice to know.
A few more tweaks here and there today. I wrote code to speed up the drips after the score increasing to certain points and that’s about it.
I’ve passed it off to a few people for beta testing and will make any changes/fix bugs they find.

October 25, 2020

Mike suggested adding a “Press Fire” bit to the Game Over. Previously it would display “Game Over” and pause for a bit then restart at the title screen. I added the pause so you could see your score and ‘misses’ etc but this sounded like a much better idea. I created sprites in the style of the “Game Over” sprites but with “Press Fire” on them instead, shortened the delay and wrote code for checking if Fire was pressed.
I soon discovered a “CPU Jam” state! It was occurring if you dropped some liquid on the floor and it caught fire. Some investigation revealed an existing label from Derek’s code called “fireDelay” which related to the fire button being pressed. I don’t use that code for my “Press Fire” part but suddenly it was causing issues with my code even though I’d play tested it hundreds of times. I renamed my label to fireDelayLoop and the issue was resolved.
I also decided to add a minor update which I suspected the original game had (and it did!). When you splash liquid on the man or lady the drip up the top would soon continue from where it was. If it happened to nearly be hitting the floor when you wet the man or woman you would not have enough time to catch it and so you’d get two misses too quickly. I updated the code to reset the drips back to the top of the screen instead thereby giving you ample time to catch the drip.

October 27, 2020

Vinny had an idea that you should be able to select “Music + Sound FX” or just “Sound FX” mode. Tonight I rejigged the titlescreen text where I had added in “LAST SCORE” and added “Music + Sound FX” on the same line. I set up the joystick to check for movement up/down and it’d change this option. I also added a note about this to the scrolly message. Works really well and didn’t take long to do!

October 31, 2020

To finish off I decided to check if anyone managed a score over 999. Now normally I’d not expect it to happen, but someone will have an Action Replay cartridge and give infinite ‘lives’ so gotta take that into consideration.
If you get over 999 it will roll over back to 0 but also wipe all of your ‘misses’ as per getting over 300 points. Tested and works very well!
I think that’s about the game done now. Thanks for reading!

This article was written before I decided to release it in the FREEZE64 magazine Christmas Edition. Now I am able to publish it here as well 🙂

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.