Google Hangouts for the Commodore 64 - December 2, 2016
This launches a new session for Google Hangouts after a several month sabbatical. During that time, I spent some effort learning Blender and Unity. However, while I was putting together a 3D game, I came across a great comment that taught me to stick with your strengths. It was then that I was reminded of my passion for the Commodore 64 and made my graceful return.
Please NOTE: You can click in the black area above that says Session 1 and Session 2, etc. This will help you navigate between the different tutorial steps.
Commodore 64 Machine Language Project
Therefore, the goal of this series is to teach a YouTube audience step by step how to create a "simulation" from scratch. I told myself that I would not focus on a game, but a rather a demo of something that may one day evolve into something more.
Please understand also that this is not meant to teach you everything about machine language. However, you can learn a little more by visiting the Machine Language page .
CBM Prg Studio 2.8
For this series, we will be utilizing the tool called CBM Prg Studio version 2.8. This is a tool that can compile assembly language listings into object code that can be run directly within an emulator called VICE C64. Essentially, it mirrors a Commodore 64 environment and allows you to create Basic programs, run Machine language programs, and games. We will be running our projects from CBM that will be executed real time in VICE C64 for output. The CBM Prg Editor can also create animation frame sequences to test our creations with. Finally you can export (save) a file as a BIN (binary) that can be uploaded into the CBM Prg Studio editor.
For our sprite display, we will be using the tool called SpritePad by SubChrist Software. This tool will allow us to design sprites using the mouse, set specific multicolor pixels, test animation, and when finished, export your project to be run within the CBM Editor.
Sprites are characters maintained by the VIC-II chip that can move a background display without alterating it. The have measurements of 24 by 21 dots. Individual bits can be turned on and off to showcase the multicolor mode. They can also be any of the 16 colors built into the hardware. Also various bits can be activated to create up to 4 extra colors for each sprite. There can be 8 sprites on the screen at once (numbered 0-7). They all have properties of position, color, size, that can emulate the effects seen in games.
Each sprite can contain its own programmable shape. The total resolution of a sprite is 24 x 21 = 504. This gives us 504 dots (or pixels) to work with. This works out to be 63 bytes (504/8 = 63) since each sprite is drawn 8 dots across times three or (8 x 3 = 24). Then all 63 bytes are classified in 21 rows with 3 bytes each.
Sprite bytes and memory
The Commodore 64 system can control 64k or 65536 (64 x 1024) bytes of memory. Each byte of memory uses a number from 0 to 255. The system can read/write information to any of these 65536 locations by using an address, which is a number from 0-65535. Each byte is comprised of eight binary digits known as 'bits'. These bits manage the Commodore 64's smallest unit of information. However they only use the number one or zero. When combined they can form any number needed.
Singles bits use a number of one or zero (binary). It two bits are combined however, the number increases. Here is an example: 00,01,10,11. This contains four possible combinations. Yet if a third bit is added you get 000,001,010,011,100,101,110,111.
The number of combinations increases up to 256 when these eight bits are placed together. The total of the eight bits are known as a 'byte' and can be used to represent the numbers 0-255.
This numbering system is referred to as binary (base two). It is similiar to the decimal (base ten) system. When using the base 10 numbering system, the digit on the right is known as the one's place, and uses a number from 0-9. The digit to its left is known as the ten's place, and holds a number from 0-9, which corresponds to the number of times the one's place is used in counting (the number of tens)
Within the binary system, we have the one's place, two's place, four's place, and so on. You count the bits from right to left starting with Bit 0. Here are the values of those individual bits:
When all of the bits are accumulated together (128+64+32+16+8+4+2+1 = 255) they add up to 255. This is the maximum value of one byte.
Counting higher than 255 bytes
Suppose you have a program that has to count higher than 255 bytes. What would you do? The answer is to use two bytes. Using a second byte to counter the number of 256's, 65536 combinations is possible (256 x 256). The Commodore 64 uses the same number as the bytes of memory. So any byte can be accessed by a number with a maximum of two bytes.
However, when we want to use large, even units of memory, the second byte, the number of 256s remains alone. These are called pages. Page 0 begins at location zero (0 x 256), Page 1 begins at location 256 (1 x 256) and so on.
There are some terms that are important to know. They are low-byte, high-byte order or LSB (Least Significant Byte), MSB (Most Significant Byte) order. These manage a two-byte address. The byte of the address that represents the number of 256's (MSB) is usually stored higher in memory than the part that saves the leftover value from 0-255 (LSB). To calculate the correct address, you need to add the LSB to 256 x MSB.
In Basic it can be perceived as taking the low byte of a number and calculating to get the high byte of that number. Here is an example below for easier clarity.
POKE 251, LO: POKE 252, HI
The LO represents the "low-byte" and the HI represents the "high-byte". In Commodore 64 Basic, these are POKEd in one address and then the next immediate address. Together they form a pointer (reference) to an address in memory. For example if you set LO=0 and HI=4 then if you calculate the low + high byte x 256 you will get 0 + 4 * 256 = 1024. The address 1024 points to the screen memory for the system. Using the low/high-byte combination like this will allow you to copy bytes in memory, write to the screen, and so much more. For gamers, this can allow you to copy bytes to screen memory and scroll the screen (such as is common in many popular software titles). See the videos below as an example of some amazing scrolling effects.
Project Video #1 is below
Below is the video of the Hangouts that occurred on 12/2/16. We had some technical issues getting setup and ran into some challenges along the way. The purpose of this to get everyone on the same page so that you can all start creating your own masterpieces. This tutorial introduces how to load a sprite from SpritePad, write some code in CBM Prg Studio in assembly language, and show the exported sprite on the VICE C64 Commodore 64 emulator.
Also please excluse the length of the video (about 4-5 hours). I will be starting a new tutorial series very soon that will provide a summary of the points covered in a condensed version. After all, who wants to watch a 5 hour video? The attention span on YouTube is way shorter.
Session 2 is Coming soon
Your patience is appreciated as I continue to expand this page. I am taking the time to research accurate information to ensure this series is valuable to you. Session 2 is now accessible on the link above. You can use these to go backward and forward through the lessons.
Need Help with something?
If there is something you do not understand, then please feel free to contact me. You can use one of the forms before. Currently Disques is experiencing problems on my computer, but that's why I have included Google+ below that. Just scroll down and look for the section that says Questions? Ask here. Thank you.