Introduction to C64 demo coding

ozone
.C:2101   A9 3A      LDA #$3A
.C:2103   CD 12 D0   CMP $D012
.C:2106   D0 FB      BNE $2103
.C:2108   A2 09      LDX #$09
.C:210a   CA         DEX
.C:210b   D0 FD      BNE $210A
.C:210d   A2 00      LDX #$00
.C:210f   BD 00 09   LDA $0900,X
.C:2112   8D 21 D0   STA $D021
.C:2115   8D 20 D0   STA $D020
.C:2118   BC 00 0A   LDY $0A00,X
.C:211b   88         DEY
.C:211c   10 FD      BPL $211B
.C:211e   E8         INX
.C:211f   E0 65      CPX #$65
.C:2121   D0 EC      BNE $210F
.C:2123   A2 01      LDX #$01
.C:2125   CA         DEX
.C:2126   D0 FD      BNE $2125
.C:2128   A9 00      LDA #$00
.C:212a   8D 20 D0   STA $D020
.C:212d   AD 21 D0   LDA $D021

So, who knows what’s happening above? Come on, it’ll come back to you if you look at the screenshot! I found a great tutorial on C64 demo coding. Unfortunately it’s a 404 now, but Google cached it and I downloaded it here for safe keeping: intro-to-programming-c64-demos.html
Look for the part on $d012

$d012 might be the most important address of them all, when it comes to demo programming on the C-64. $d012 has two different functions:

* When read, it returns the number of the current raster line.
* When written, it is used to set the number of the line where the next raster interrupt will occur.

We’ll get back to raster interrupts later. You need to know about $d012 to understand them, so pay attention to the stuff in this section! The first item above is interesting, but it may not be obvious why it is interesting.

The current raster line is the line that is currently being redrawn on your screen. The whole screen is redrawn 50 times per second. Each time it is redrawn from top to bottom, from the left to the right. So, if you want something to happen 50 times per second, all you have to do is to check the current value of $d012, and when it reaches a certain value, call the routine that performs the desired task. When finished, go back to checking $d012.

That blew me away when I found out about that. You could literally change the background colour of the screen halfway down the screen, have multiple text and graphics modes, use more than the default 8 hardware sprites. The PC was disappointing in comparison.

That code above is for Justin who reminded me that Vice has an ASM monitor!

Who or what is Xeer?

I used to go by the handle, “Xeer”. It’s under that name that I coded Commodore 64 demos many years ago. There’s even an entry for me on the C64 Scene Database! Exciting times then, but I’ve often been asked where the name Xeer came from. Now I can reveal it’s very obscure origins.

You may have heard of a space trading game called Elite that was released in 1985. If you haven’t, then don’t worry. You’re a youngster aren’t you? It made serious waves in the games scene for many years and even spawned an awful sequel on the PC a couple of years ago.
Anyway, I came across the game a few years after, probably in 1988 or ’89 and was hooked! I have to be honest, I preferred the shoot-em-up parts to the dry and boring trading bits. Games never lasted very long but it made a lasting impression on me.

One thing led to another, and I became interested in the C64 demo scene, but I needed a handle. Luckily I came across a few cheats for Elite that gave me infinite fuel or some such other nonsense and went looking around the galaxy. Here’s what the galaxy looked like back in the late 80’s.

Elite Galactic Chart

While exploring, I came across the little planet under the cursor above. Can you guess what it’s called? Yup, Xeer. Here’s the info sheet on it.

The planet Xeer

I haven’t seen any large yellow bug-eyed frogs about anywhere but I expect they’ll show up sooner or later.

More Xeer trivia: The traditional Somali Constitution is called Xeer, although the linked page on combackalive.com makes little sense to me. Anyone from that region know more?
For the Elite fans: The Zzap64! review.

I'd rather be blogging

What is your most precious commodity? Mine is time. That’s why I’d rather be blogging than twittering.

  • 85 great photography sites suggested by the readers of DIY Photography, including my photoblog. Thanks for the link!
  • Mark celebrates the 25th birthday of the Commodore 64. Is it that old? Wow. commodore_64.jpg
    More: Wired Gallery, Interview with Jack Tramiel, Apple rejected by Commodore? (phew!)

    With no money to build thousands of Apple II machines, Wozniak and Apple co-founder Steve Jobs both approached Commodore with the Apple II. “Chuck Peddle from Commodore came to the garage and he was one of about three people we showed the Apple II prototype ever,” Wozniak said.

  • Mark welcomes MTOS. (sort of)

PS. almost forgot, Alan Whelan of Trocaire emailed to ask me to mention their ethical Global Gift campaign to help, “poor families around the world this Christmas.” While we’re on the topic of Christmas charity, by supporting Bothar you can help send cows to needy families. A bizarre item on the radio a few days ago involved a reporter accusing Bothar of keeping poor people poor. He reasoned that Bothar need poor people to operate. Weird stuff.

C64 people and the good ol' days..

I’m stuck in work late, yet again, and plouging through a long list of things when I get an email titled, ‘remember me?’ from Andrew Fisher. Andrew was a member of the c64 demo group ‘Ozone’ that I formed with Ciaran Langford many a year ago.
I haven’t heard from Andrew in a long time so I took the opportunity to call him and we had a great chat catching up, and reminising about the ‘good ol’ days’ 🙂
Prompted by a visit to his homepage I searched for mention of the demo I worked on for Ozone and found it nestled away in a C64 demo archive. Thanks Andrew for submitting it there!