Introduction
With
the C64 coming back in different forms. For example The C64 Reloaded,
theC64 Mini and the Ultimate 64 or maybe you own just just the
Commodore 64 or C128 with a 1541Ultimate 2 or just want to code C64
programs for additional emulators. You have come to the right place. I
have also decided to expand things a bit further in 2018, just for fun and hopefully it should be even more interesting.
The
main purpose for this web site is to produce legal future reference for
those of you who would like to be involved with the assembly
programming
side
of the C64. There have been many books that details about subroutines,
mathematics, etc. However I won't go through all of those as that would
just take ages, and I don't have the time for that!. After all
this tutorial is supposed to be fun, not boring.
This
web site differs through various assembly
coding
techniques, commands, etc. by reading through this documentation, you
should
soon end up creating cool, exciting and possibly crazy programs in no
time.
Later on in this documentation, you will learn how to create your own
games,
that involve moving sprites, animating background objects, playing SID
music, adding scores, etc. Hopefully you should be able to make your
first ever demo, intro or have a go at making a C64 game in no time.
The assembler I will be using for each example will be ACME / C64STUDIO
cross-platform assembler.
BACK TO TOP
What is an Assembler?
An
assembler
is an application, or tool that allows you to program a computer by
calling out several commands. We are programmed to do things by
instructions/programming from our brains. You could always say that our
own lives are controlled by a program through our brain. Computer
programs work a similar kind of way, but are given different
instructions by a programmer (yourself) to do amazing things.
Assemblers are completely different compared to BASIC programs. The
listings are completely LDA, STA and all that jazz. For example. In
BASIC we could command a computer to type in commands such as print the
message "I WOULD LIKE A PINT OF CARLING AND A PACKET OF CRISPS
PLEASE!". That can simply be performed by using the command:
10 PRINT "I WOULD LIKE A PINT OF LAGER"
20 PRINT "AND A PACKET OF CRISPS PLEASE!"
In
ACME/C64Studio cross assembly, the instructions are completely
different, and compiling a project is a whole lot faster, compared to
the native C64 assemblers. Plus you can do more in C64Studio than just
code games!
!to "textmessage.prg",cbm
*=$0801 ;Set BASIC SYS start header
!BASIC 2064
*=$0810 ;Set main code
LDX #$00
PRINTMSG
LDA MESSAGE1,X
STA $0400,X
LDA MESSAGE2,X
STA $0400+40,x
INX
CPX #MSGEND-MSGSTART ;Length of message (total no. of characters)
BNE PRINTMSG
RTS
MSGSTART
!CT SCR
MESSAGE1 !TEXT "i would like a pint of lager "
MESSAGE2 !TEXT "and a packet of crisps please! "
MSGENDWhat type of
Assemblers are there?
Various
C64/Cross assemblers
may differ, as different commands are used, but they all do build up
the same
routines when assembled to your Commodore 64 or emulator. You write a program
listing in an assembler, and then you
need
to assemble it before you create a runnable file and test your file.
The most common native C64 assembler which was used was Omicron's Turbo
Assembler. You can find this assembler quite easily on the Internet
from the Turbo Assembler
home page. However, the most practical way to code and debug your own
program would be to use a cross-assembler and WinVice. This is due to
the additional features, and user friendly options they take.BACK TO TOP
Assemblers for the Commodore 64
- 6510+
Assembler by Dave Weaver (A little bit like BASIC, except that you can
assemble your own programs as well, also has its own M/C monitor) (PUBLIC DOMAIN)
- Code
Suck Monitor by Polonus/Science 541 (M/C Montor based assembler) (PUBLIC DOMAIN, can be used with Turbo Assembler))
- Action
Replay MK 6 Cartridge by Datel Electronics (M/C Monitor) (COMMERCIAL)
- Retro Replay by Cyberpunx (Built in Turbo Assembler + M/C Monitor) (PUBLIC DOMAIN!?!?!?)
- Professional
Assembler by Masters Design Group (Assembler) (PUBLIC DOMAIN?!?!)
- Ass
Blaster
V3.0 by Zeldin/Cascade (An advanced assembler with a user-friendly
interface) (PUBLIC DOMAIN)
- Turbo
Assembler by Omicron (Assembler) (PUBLIC DOMAIN)
- ASM
Monitor by Raistlin/Excess (Oldie, and like 6510+) (COMMERCIAL ?!?!?!)
- Smartmon
(M/C Monitor) (UNKNOWN)
- JC-ASS
(Assembler and M/C monitor by JC/Xakk) (PUBLIC DOMAIN)
- Zeus Assembler (Assembler + M/C Monitor) (COMMERCIAL)
- Assembler 64 by CBM (COMMERCIAL)
BACK TO TOPWhat is a
Cross Assembler?
A cross assembler is a PC version of a normal 6502
assembler. It is a small executable compiler / application program, which will
assemble and compile text files (which use the assembly instruction
code) into a chosen assembled program. Basically a cross assembler can
convert all text assembly commands to a 6502 program for any machine
that supports this level of programming. Unlike normal Commodore 64
assemblers, a cross assembler has better limitations than a normal
Commodore 64 assembler, like Turbo Assembler. Cross assemblers can also
import source binary files, i.e. additional C64 graphics, music, data,
etc. Usually by using a command like .INCBIN
or .BINARY or !BIN. You can
also link more than one source file to your assembled production. Every
cross assembler normally comes with its own documentation on line. As
mentioned before the all new ASSEMBLE IT is going to be using
ACME/C64STUDIO for its tutorials.
Cross
assemblers/compilers for the PC to the Commodore 64 (Links to original sources)
- 6502
TurboAssembler
- 64ASM
- KickAssembler by Soci/Singular
- ACME by Smorbord Software
- C64Studio
by Georg Rottensteiner (A full design+development suite, with ACME
assembler related instructions, but slightly different commands).
Features char editor, sprite editor, screen editor, graphics editor and
dir master, plus much more
- X-SLANG (completely
different to assemblers, but does accept
assembly commands)
- CCC65 Assembler
- CBMPRG Studio by Arthur Jordison (A full design+development suite with built in assembler / BASIC tokenizer)
BACK TO TOP
Some
recommended PC-cross platform software to use for developing all kinds
of things
This part gives you
recommended cross platform software for use on your PC for developing
all kinds of things, from graphics to music, and also for linking and
compression, etc.
- CharPad V2.0 -
Charset and game
background building software by Subchrist Software
- Cuneiform - Charset
editor by Scrapdog
- SpritePad V2.0 -
Sprite Editor by Subchrist Software
- 7Up Editor - Sprite
Editor by Mirage
- GangED
- Converts graphics from PC to
Commodore 64 by The Gang
- CONGO - Converts graphics
from PC to
Commodore 64 by ????
- Timanthes -
Bitmap Graphics (Painting
Program) by Focus
- 0xPaint - Bitmap Graphics
(Painting
program) by Fairlight
- Project One -
Bitmap Graphics by Resource
- Goat Tracker V2.7 - C64
music composing utility on your PC by Lasse
- CheeseCutter V2.8 - C64 music composing utility on your PC by Abadon/Fairlight
- MG Tracker - Matt Gray C64 music composing utility on your PC by Samar Productions
- CBMCombine - Linking utility
by Albert Pasi Ojala, updated by iAN CooG/Hokuto Force
- PuCrunch -
High speed cruncher. Fast
decrunching by Albert Pasi Ojala
- Exomizer V2.09 -
Cruncher, but has
more capable abilities compared to PuCrunch by Magnus Lind
- ALZ64 -
Cruncher, compresses better
than Exomizer but extra programming knowledge is required. Very slow
decompression and messy as well. By Kabuto
- D64 Editor -
Transfer your .prg file
into a .D64 by Almighty64
- DIR Master - Similar to C64 editor (by Style)
- Star
Commander Software
- Must
be outside windows to use this program for converting .D64/.PRG files
to your commodore 64 disk drive. (XE1541 required). By Joe Forster/STA
(Very old software - Not supported by modern PCs or Windows 7+
BACK TO TOP
C64 Studio and Setting Things Up
C64
Studio is probably the most common C64 IDE with built in toolkit, which
is used today. I have chosen this particular assembler for the ASSEMBLE
IT tutorials, due to the amount of ease it has on creating and
developing software. It sort of uses the ACME cross assembler module
(Which I originally used to create Woolly Jumper and Sheepoid DX).
There may be some differences with some of the pseudo code, but it is
pretty much straightforward if you are used to ACME :)
C64
Studio also has a few additional editors, which you can use to create
and develop your own sprites and graphics. Although I tend prefer to
use Charpad for designing background graphics, logos, etc. As it eases
designing graphics slightly.
You can grab the editor from THE C64 STUDIO page.
To
set up C64Studio, you'll want to choose a version of VICE which you
find to be much useful. I find X64SC from WinVice V2.4 to be very
handy. I own a C64C and would like to use that version of VICE for
testing for raster dots. On an older C64 these tend to no be noticed,
but on newer C64 hardware like the Commodore 64C back in the late
1980's it was different.
How is C64Studio set up to call VICE?
Easy:
Select from the drop down menu:
- FILE
- SETUP WIZARD
- then select the path where X64SC.EXE is placed
For
assembling, simply click on the BUILD icon or press F5 to build your
program. Should there be any errors in the code, the compiler results
will show the errors and which lines these errors are located at.
Packing/Crunching
There
is a trick known to reducing file sizes by packing/crunching files.
After assembling your own programs you can choose whether or not you
would like to pack/crunch your own productions. If you want to
pack/crunch, the old slow C64 way, using one or two of a variety of
packers/crunchers, etc. You can do exactly that. However, an
alternative choice would be to use EXOMIZER.
IMPLEMENTING EXOMIZER INTO YOUR OWN SOURCE:
First
of all, if you don't want to crunch your program with a standard C64
cruncher. You can easily enough use Exomizer. A fast-compression PC
based tool with a variety of functions. You can disable or program your
very own depack effects, to suit your needs. Although - playing with
depack effects are least important, but may look cool or weird :)
First of all you will need to GET Exomizer from the EXOMIZER HOME PAGE
If
say you were to write your own program in C64Studio and you wanted to
compress your own program. You can call EXOMIZER to your source code to
compress your assembled program. To implement EXOMIZER compression into
your own programs:
- In the project explorer tab, select the source file to be assembled
- RIGHT CLICK on the source file and select PROPERTIES
- Click on the tab BUILD EVENTS
- Ensure build event is set up as POST BUILD
- Enter the correct path and command to where Exomizer is located ... for example
C:\Exomizer\Win32\Exomizer.exe sfx $(JUMP_ADDRESS) SOURCE.PRG -o SOURCE.PRG
(NOTE IF YOU ARE USING THE EXOMIZER V3.0, add a -s "clc" at the end of the command to fix a bug inside the decruncher)
then click on CLOSE.
Say for example:
You
write a game called SpaceBlaster, the source code file is
SpaceBlaster.asm and you use $4000 as the start address of your program
(*=$4000). You can call Exomizer in post build to do exactly this
command below:
C:\Exomizer\Win32\Exomizer.exe sfx $4000 SpaceBlaster.GRAB -o SpaceBlaster.prg
(NOTE IF YOU ARE USING THE EXOMIZER V3.0, add a -s "clc" at the end of the command to fix a bug inside the decruncher)
Basically That's it for this chapter :)
BACK TO TOP