Posts Tagged ‘Commodore 64 emulator’

This will be a course covering the basics of computers and programming. It is designed for those who have not programmed before, it will introduce the core concepts and principals of programming.

For this task I will use a Commodore 64 emulator and the Programming Language Microsoft BASIC Commodore Enhanced Version 2.0. Why?

  • There is no API to learn, no piles of classes and language semantics to learn first. I won’t need to give you a skeleton program which handles all the start up you need
  • It is small enough to fit in your head with 64K of RAM running at 1Mhz, you will out think it and it will do things slowly
  • It is standard, the Commodore 64 has been the same for the last 30 years and it will be the same for the next 30 years. If I teach you how to program in C++90 in Visual Studio 2103 for Windows 7, it won’t work on Windows 8, or 9 or 10, OSX 10.6, iOS etc. So people in the future will still be able to use this, as will you if you upgrade switch to a new machine.
  • The emulator is fully sandboxed so you are free to do what you want and experiment without risk of damaging your computer or files
  • There are a lot of books at the basic level for it if you want to read more

My Commodore 64 emulator of choice is VICE, it is open source and has pre-compiled binaries for Windows, OSX PPC, OSX Intel, Unix, BeOS, Amiga and a host of others, if your favourite is not there, you can just compile it. You can get it here http://vice-emu.sourceforge.net/

You can get Commodore V2 basic as an iPhone app, this will suffice for the early parts of the tutorial but eventually to do something exciting we will need to make use of the Commodore 64’s hardware features which the App does NOT support.

Once you have installed it on your system, find and run x64.

Setting up x64.
In the menu, select settings, then keyboard settings.., make sure it is in Symbolic US. This way when you type on a keyboard you get what you press and don’t need to remember/know the Commodore 64 keyboard. If you have a non US keyboard, alas you will need to map your keyboard to a US one. E.g. On a UK Keyboard the @ symbol is actually the ”

Select Save Current Settings option so you won’t have to do it next time.


Anatomy of a BASIC program

You should see this

Lesson 1_1

So lets make a program at the READY prompt type the following : note the C64 types in caps by default so you don’t need to press shift

10 PRINT "HELLO" ( press return/enter key )

Lesson 1_2Lets test the program
RUN (return)
you should see it printed out hello on the screen.

Lesson 1_3
Back to the anotomy
Line Number Command Param
the Line Number can be any number ( under 100 000 ) and tells the computer where in the list of instructions this line of code sits. So line 20 comes after 10, as would line 300, 9 comes before. The numbers don’t have to be sequential just higher than the line you want the instructions to be after. As a beginner it is wise to leave room between you initial instructions for when you forget something and need to add something later. A gap of 10 is the standard used by most programmers.
The Command is a BASIC instruction, this command is PRINT and it Prints something to the screen.
The Param is in the case is the string Hello, which is what the PRINT command is to print.

What is a string? A string is a string of characters, that make up a word or sentence. You tell BASIC you want a string with the ” character. All Strings must start and end with a “. The Commodore 64 has lots of special character codes and inputs for strings, so be careful not to press the arrow keys while you have a ” open or you will see some strange characters being typed.

Lets modify the program to print something else.


LIST ( return )

this will show you the program again.

now type

10 PRINT "( something you want)" (return)


Now you have learn’t how to update an existing line. If you enter a new line with the same line number as an existing Line, you will replace it with the new line.


Read Full Post »