Making A Commodore 64 Maze Game Part 1

107

A Commodore 64 Maze Game looks straightforward at first glance, but precise sprite interaction relies on smart collision checks and grid logic. This article, based on the first video in a new mini-series from Commodore Tutorials, explores how those systems work and how to implement them in Assembly. Anyone eager to build more interactive games will benefit from seeing the inner workings of a Commodore 64 Maze Game.

Laying the Groundwork for the Project

This series is designed for intermediate programmers. It assumes you know basic Assembly commands like LDA and STA. The focus now shifts to building a real Commodore 64 Maze Game, one that tracks coin collection, enemy movement, and dynamic obstacles. Instead of just pushing sprites across the screen, the tutorial explains how to add goals and hazards for deeper gameplay.

All of this depends on reliable, repeatable collision logic.

Understanding the Screen Grid and Sprite Offsets

On the Commodore 64, each screen is a grid of character cells, each cell being eight pixels square. Sprites move one pixel at a time, but background tiles always follow the grid. To make a Commodore 64 Maze Game line up, the code needs to convert pixel coordinates to the grid’s cells.

Because of how the hardware works, a sprite in the top left visible corner is actually at position (24,50), not (0,0). Every collision check must subtract these offsets to keep calculations accurate.

Checking Collision Zones

The main character sprite is 24 pixels wide and 21 pixels tall. It covers roughly three cells horizontally and nearly three vertically. Each time the player moves, the program checks three cells in the intended direction. For instance, moving left checks the upper, middle, and lower left cells. The same goes for the other three directions.

If the game detects a wall in any checked cell, movement stops. If a coin is there, it gets collected and the score increases. This approach keeps the Commodore 64 Maze Game fair and responsive.

Converting Sprite Position to Grid Cells

To find the right row and column for collision, the code divides the adjusted sprite position by eight. Assembly lacks a direct division command, but the LSR instruction shifts bits right, dividing by two each time. Three shifts equal a division by eight, so it’s both fast and easy.

Every eight pixels the sprite moves equals one grid cell, a principle shown clearly in the video.

Using Memory Tables for Fast Lookups

Screen memory is organized in tables: one for low bytes, one for high bytes. Each entry marks the start address of a screen row. Combine these, add the column, and you get the address of any character cell. This method helps the Commodore 64 Maze Game check quickly whether a wall, coin, or exit is ahead.

Streamlining Checks With Macros

To reduce code repetition, the tutorial relies on a macro called check char collision. It takes the sprite type, position, and needed offsets. Each direction simply calls this macro three times for each checked cell. When you want to expand the Commodore 64 Maze Game with new items or hazards, this structure saves time and reduces errors.

Walking Through the Game Loop

No raster interrupts are used, just a clear, timed loop:

  1. Wait for timing
  2. Read the joystick
  3. Move the enemy
  4. Check for collisions
  5. Move the sprite if allowed

This setup makes every part of the logic visible and easy to follow. Watching the video lets you see every step as the program runs.

What’s Ahead in the Mini-Series

This episode focuses on sprite and character collision. Future installments will cover picking up coins, updating counters, opening exit doors, and detecting sprite-to-sprite contacts such as player-enemy crashes.

If you want to master Commodore 64 Maze Game logic in Assembly, following the whole series is your best bet. Each video builds your skills, step by step.

Why Watch the Video?

Reading about the collision logic is useful, but seeing it play out on a real C64 is even better. The video tutorial demonstrates each principle, including bit-shifting, table use, and the flow of movement, making the game logic much easier to grasp.

If you’re ready to make your own Commodore 64 Maze Game, start with this article and the video. You’ll see every part in action and gain the confidence to build your own interactive maze adventure.

You can order Bård’s book Making Games For The Commodore 64 In Assembly Language from the LuLu Bookstore.

Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments