The Limitations of 1Mhz

The Commodore 64 used a 1 Megahertz 8 bit processor with 64 kb of 8 bit memory. To do 16 bit operations it had to do 2 reads of memory. In these days of 4ghz (4000 times faster), 64 bit buses (8 times more data for each read of memory),  and  typically 8GB of memory (125,000 times more), it seems unbelievably slow. Making the Commodore 64 sing and dance is a real challenge!

1984                       2016                          Multiple
1 MHz                    4000 MHz (4GHz)   4000
64 Kb                     8,000,000 Kb (8Gb) 125,000
8 Bit Memory        64 Bit Memory         8
1 CPU                     4 CPUs (Quad Core)  4

If I am correct, that makes a typical PC today 16 billion times more powerful than the Commodore 64!!! (4000*125,000*8*4). And that’s not taking  other efficiencies into account!

To get Sleepwalker into 64kb I am compressing the screen data. Each uncompressed screen needs approx 1.5kb, if I have 60 screens that’s approximately 90kb, which of course won’t fit into 64kb! I don’t want to be loading from disk, so I’m compressing the screens. That’s great, but there is so much compressed information that it is getting slow to decompress and there is a visible glitch as the game decompresses the data. I am rewriting the screen compressor (again) so that the information will decompress much faster. We are now compressing 18 screens into 4kb, and, once this rewrite is done, it may be even less.

I’m loving the retro challenges of a 1mhz processor!

1 thought on “The Limitations of 1Mhz”

  1. Greetings from Irby !! 😉 – Back in the day John came round to my house in Bebington and gave me some programming advice and also suggested how to improve the sprite animations that my friend has drawn. I was working using tape and a c64 action replay cartridge at the time and things were quite tedius…. I later got some propper tools, but the day job got in the way in the end of the c64 coding !!! – John you may recall this ???

    I was re-visiting the same old C64 game that I never finished a few years ago and was trying to port it to the BBC micro as a challenge/experiment using a hi res 7 colour screen that took up a huge amount of ram itself (20K ?).

    I was only left with a few K (about 12 or so) for the game code, all the levels, Gfx Tiles and c64 sprites. I managed to keep the gfx as native c64 (it was more efficient) and used some sprite plotting code but it was obviously a little slow. Solution was to run at 25 HZ instead of 50 Hz and the BBC Micro runs at 2MHZ.

    To save memory I culled every other frame of some of the sprite animations and added a flip to the sprite plotter, this got all the sprites into about 1/4 or so of the original space and when running a test plotter, the BBC partial test port actually looks just like a C64 but with slightly different colours !!

    The game used 2×2 character tiles, so I wrote some code to look for identical characters and cull them from the char set, this chopped down the character gfx nicely although added a little overhead for the tile defs data which were originally all consecutive, eg 0,1,2,3 – 4,5,6,7 – etc….

    To compress the levels (each used 256 bytes including the colors and sprite positions) I decided against compressing them and wrote a platform and column plotter based on x,y positions,tile type, and a length if needed for the tile type, so 3 or 4 bytes. The tile types data was usually 1 tile or 3 (if it had rounded ends) or you could have longer patterns if required, and if the type was vertical or horizontal…. This worked very well and some levels took as little as 20 bytes or so for the tile map data in the end…. instead of 192 bytes for the whole area !! – I think some of the drawing commands even left out the x and y positions assuming stuff was drawn continuously using some spare high bits in the tile type to plot but I can’t quite recall now.

    I’m guessing you may be able to do something similar but modify to draw ‘big blocks/areas’ also, so x,y,type and height and/or width if required. I’m pretty sure that would work well.

    This is how far I got….
    https://www.youtube.com/watch?v=otCCR6mmzFw / https://www.youtube.com/watch?v=L8fT-R0aTmI

    John, Drop me an email if you get a chance, Thanks, Colin

Leave a Reply

Your email address will not be published. Required fields are marked *