Commodore 64 Game Maps Scrolling

How scrolling works on the Commodore 64

Back in the early 70’s/80s computers began flooding the home markets. They were popular in store outlets, such as Radio Shack and Sears. During that time the world was discovering that a television set could be used for much more than just watching movies and TV shows. Video games were just being produced and now people could interact with graphic shapes on their screen made popular with Commodore 64 Screen Scrolling! This was possibly since many computers contained an RF modulator that can be plugged into any television set allowing a person to interact with their computer through their television.

In the early 80s a company came into production called Commodore Business Machines (CBM for short). This company wanted to capture a market for their new machine, so they created a language called Basic that could be used to write software and help people solve problems more quickly.

Much later after the Commodore 64 was manufactured from a line of other computers through Commodore, such as the VIC 20. This machine had a strong focus on visual output because of their multi-color sprites and graphics. This eventually grew in popularity and many other companies starting producing games in the market.

Deep inside the Commodore 64 computer is a processor that feeds instructions all throughout. This processor manages everything from the keyboard, screen, memory, plug in devices, disk drive, and so on. Since it manages a lot of things with the computer, it is no surprise that the main chip is called a microprocessor since it handles so many tasks

Understanding Screens and Scrolling

The Basic language could not only be used to write helpful software, but eventually people started learning how to create their own mini games. While it is fun to tell Basic how to place dots on the screen and get things moving around, it is very slow. This is because Basic (Beginners All Symbolic Instruction Code) has to interrupt commands and their functionality, which in turn causes it to execute commands at a snail pace. So creating a really fun and professional game can not be done successfully in Basic. Since Basic utilizes the computers natural language (known as machine language), programmers realized that they could create a faster game writing directly to the machine’s hardware and using Commodore 64 Screen Scrolling.

One of the more popular aspects of the games in the markets during those times was the ability to scroll a screen. The technical term is known as “fine scrolling”. Fine scrolling works by copying a screen to a hidden back buffer and displaying it on the screen during a timed interrupt. Since monitors were not capable of producing scrolling smoothly, machine language was the answer to creating fast results to the screen.

Creating a character on the screen

In order to accomplish Commodore 64 Screen Scrolling, first it is important to understand how a screen works. If you peer closely at your Commodore 64 you will notice it is made up of dots. These dots are called pixels. The Commodore 64 and other computers contain a set of characters (known as PET Ascii) that are used to fill the screen with graphics. Examine a character, such as the letter A. The computer draws this character on the screen in a 8 x 8 grid. Looking at a piece of graph paper, you will see it is made up of squares. Arranged in a grid (8 rows across, and 8 rows deep) is how the computer manages the space within a character. I won’t go into all the aspects of how to create a character, but just understand that is necessary to display information on the screen, made up of the entire character set.

Each pixel is managed by the processor. The actual term for the individual blocks are called bits. Each bit can be added up to generate the graphic seen on the screen (look at the letter ‘A’ above). These bits are multiplied by the power of two to create what is known as a byte. A byte represented the total of the bits. If you number them from left to right they count as 128, 64, 32, 16, 8, 4, 2, 1. Add up all of the bits (or display pixels) and you get 255. By filling in all the dots a line would be drawn across the top part of the A character above. To finish the character, you fill in all of the corresponding lines below and add up their digits.

The Screen and Map explained

The screen itself can place these characters side by side to create words and pictures. Each row can fit 40 characters. They can occupy the space vertically as deep as 25 characters. The screen also can fill a character with color by utilizing what is known as color memory. The colors can be filled in any space, occupying 16 colors. All of this is important to know since scrolling will take into account of placing characters on the screen, filling that area with color, and managing the space on the screen. Each section is controls by something known as a memory location to fill that section. The upper left part begins at an area in memory starting at 1024. Drawing a line across the screen will consist of 40 characters, which ends at 1064. Then the next line down will start at 1065 and continue from left to right.

When utilizing Commodore 64 Screen Scrolling, it is important to take into account of filling up that space. So the Commodore 64 can draw lines in that manner across the screen. Games contain a map that will appear slowly on the screen as a character moves up, down, left, or right. Look at some of the popular games out there on the Commodore 64 and you will see that they bring a map into view any time a game character (known as a sprite) moves around the screen.

The scrolling works by grabbing data from the image to the left, right, up, or down area and moving it on the screen into view. When scrolling a screen to the right for example, the Commodore 64 draws a line down the screen on the far right side and copies the map off the hidden screen to the right to shift it onto the screen on the left. It also takes the data that is in that current column and shifts it in the opposing direction. I will provide a better example later. This process is repeated slowly in order to move the map graphics onto the screen. When it is being scrolled vertically, it draws a line straight across the top or bottom and moves the hidden map (off the screen, in memory) onto the visual screen so that the map comes into view.

Creating Maps in CharPad

Maps can be created for the Commodore 64 very quickly using a Windows tool called CharPad (short for “Character Pad”). You can design a map to be made up of 8 x 8 characters as we discussed, or even 2 x 2, 4×4, etc. The more popular games use 4 x 4, and my example follows the same path. This is because it takes less memory and allows character grids to be placed side by side. Examine this character in CharPad and notice how pixels fill those sections and it contains 8 x 8 block grids side by side. So there are 4 in each row. That is why it is called a 4 x 4 tile. The Character Set window contains the character set that is defined to fill the pixels in the Tile Editor window. Then once a character is created, it can be placed onto a larger grid that contains the game map, as seen here in the Metal Warrior example.

When the Commodore 64 became popular, teams set out to design software that could “emulate” a Commodore 64 real time. This “emulator” created is called VICE. It can be used to run any type of Commodore programs and games. It also allows a user to write programs in Basic and contains a keyboard map that emulates the real Commodore 64 system. VICE is used in my map example to demonstrate the scrolling technique I have learned about.

The memory map example you see here was the work of a team I put together in 2017. It became known as the Machine Language Project. This latest screen was a map I created during that time and I now have learned how to extract the data from CharPad and place it on the screen. My goal was to gather a group of people that had Commodore 64 skills and work on creating a game already in production. We decided on a game called Spelunker since it was very popular during it’s initial release, contained scrolling, and had some fancy game play implemented within.

The Future of Game Mapping

To demonstrate the scrolling, I took some of the CharPad example that came packaged with the software download. A popular game called Metal Warrior (by Lasse Oorni) was included. My ultimate goal was to generate that map on the screen and start scrolling it. Now this was no easy task, and if it were not for the team I came to know that worked on the Machine Language Project, none of this would have been a reality.

However, I am now happy to present the scrolling example for Metal Warrior, other games, and the original Spelunker Clone my team was hard at work on. The Spelunker Clone is seen at the end of the video to save the best for last. I met a guy from Australia named Siggy when the team was assembled that extracted code segments from a game called Supernatural. This game didn’t contain any scrolling, but Siggy was able to use a lot of the concepts to create our game project. Watch the video (coming soon) below to see how this was accomplished. I’m on my way!

This means that very soon I will be able to create and possibly finish the Spelunker Clone game in given time now that I have added a new tool to my belt in mastering screen scrolling. This was my main purpose ever since I started working on video games back in the early 80’s. I had such a passion for game design, but could never get the scrolling to work. Hopefully in the near future, I may be able to release a game on cartridge for Psytronik Software website. Time will tell. All of this will only be possible if I stay consistent with my goal of studying assembly language, building maps, and learning more about Commodore 64 game design.

My goal is to eventually explain the Spelunker scrolling code completely. This will allow the reader to follow how the logic works in copying data to a back buffer and moving it back to the screen to save timing cycles when generating the map display. This works through a raster timed interrupt. So stay tuned as I work to accomplish this. In the meantime, you can still refer to the Machine Language Project tutorials found on this website, which highlights the progress we made in 2017 when working on the Spelunker Clone game through Google Hangouts, live on YouTube.