Commodore Archives

30 years after its release it’s time to re-kindle with my first computer spirit – the C64. This was my first computer which changed my life forever. Thanks to VICE we can now enjoy the little guy again on modern hardware. Here are all my notes on how to talk to him, and his other friends from the 8 Bit Age.

How to build a time of day clock on the Commodore 64

In this video I’ll demonstrate how to build a simple clock on the C64. We’ll go through this process step by step, including the built-in TI and TI$ variables, string formatting with LEFT$, RIGHT$ and MID$, as well as screen formatting. Here’s the code I’m writing – works in Commodore BASIC v2 and above: 5 … Read more

How to create random YouTube URLs in Commodore BASIC v2

In this episode I’ll demonstrate how to create those seemingly random YouTube Video IDs using a Commodore 64. Here’s the code I’m writing – works in BASIC v2 and above: 10 print chr$(14) 20 gosub 100:x=rnd(-ti):cn=1 30 a$=”” 40 for i=1 to 11 50 rn=int(rnd(0)*62)+1 60 a$=a$+yt$(rn) 70 next 80 print:print cn;” : “;a$ 85 … Read more

String Operations on Commodore Computers

Commodore BASIC has some interesting and simple string functions built in. Three of them are self explanatory: LEN, LEFT$ and RIGHT$. But others, like the mysterious MID$ and INSTR functions, are a little tricker, and I can never remember how they works. So here’s a quick recap on how they all work. LEN (A$) Returns … Read more

How to play sounds and music on the Commodore Plus/4

The Plus/4 has a total of two voices thanks to its integrated TED chip, which is also responsible for rendering text and graphics on screen. The first voice can play square waves, while the second one can generate either square wave sounds or white noise.

Let’s see how we can make him play a tune.

We can use some BASIC keywords to make the Plus/4 be all musical. First we need to turn up the volume by using the VOL command. We can set this to anything between 0 and 8.


Next we can use the SOUND command to make each channel play a note, like so:

SOUND 1,400,60

This will play a one-second long note on channel 1.

Read more

How to use direct block access commands in Commodore DOS

Commodore-Logo-PaddedWe can access each sector’s raw data on Commodore disk drives with direct block access commands. Supported drives include the 1541, 1571, the VICE emulator as well as the SD2IEC card reader (for the most part).

Each single sided floppy contains 35 sectors, while a double sided 1571 formatted disk contains 70 sectors. Each track contains between 17 and 21 sectors depending on how far inside or outside they are. Each sector contains 255 bytes we can read or write.

Sectors are the same as blocks: only the directory refers to them as “blocks” and shows us how many we have available.

We’ll need to open two channels to our disk drives: a command channel and a data channel. Here’s how to do it:

Read more

How to create relative data files on your Commodore 128

The CBM DOS can write “relative data” onto disk, based on individual records. The advantage is that all space is allocated once and then randomly accessed if and when it’s needed – much like the tracks on a CD. This approach is different from sequential files, which have to read or write the whole file … Read more

How to create sequential files on your Commodore C128

Sequential files are files to which we can write arbitrary data and read it back later. We can even append data to the file later without having to re-write the whole file. This works with the Datasette (tape drive) as well as floppy drives. Here’s how to do it in CBM BASIC 7.0: Creating Sequential … Read more