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.

10 years of me

I’ve been writing online for 10 years. Well, strictly speaking it’s longer than that because my Geocities site was last modified in 1997 and it’s still alive. I might yet import that site into this blog at some stage. Thankfully I had enough of HTML frames after that. I created a simple site on indigo.ie in late 1997 but then moved everything to http://members.xoom.com/xeer/ which later became members.nbci.com and is now long gone. xoom.com is now quite a different site!

I called the site DemoNix. It never had permalinks, but I did update it with a Perl script that built static html pages with a basic theme and then FTPed them to xoom.com. That script and the build files are long gone but thanks to the Wayback Machine I recovered a fair portion of it. All the original content I could scrape together is now in the Demonix category on this blog. I generally wrote about Linux demoscene news, code tutorials, gossip and my first 2 GPLed projects: “Time Sheets for Networks” and “Install Sendmail”. TSN as I fondly called it doesn’t exist any more but it was my 4th year college project. It was terrible. Buy me a pint some day and I’ll reveal just how bad it was. I wrote Install Sendmail because Sendmail was such a bitch to configure in those days. It was wildly popular, even being linked from the Fetchmail homepage. It still exists although the download link is now broken. It’s a sign of the times that nobody has complained about that.

Dave Polaschek recently reminded me that the web was a much smaller place back then. It was much easier to be noticed and get to the top of the pile if you posted consistently and well. My DemoNix site was read by many and even linked from a Slashdot story about Bladeenc in 1998. I’m sure it’s a simple coincidence that members.xoom.com went offline around the same time for a day or so ..

I could write more, but it’s all contained in the archives of this site. Everything from enthusiastic exclamations about the latest demos or code snippets to the short announcement of my mother’s death in December 1998. I still remember the email Mark sent me after I made that post. There were no comments in those days.

Awareness of Reality As this is a self indulgent look into the past, grab a Commodore 64 emulator and download donnchac64.zip. It’s a collection of demos and bits and bobs I wrote (or co-wrote) on that machine from early 1992 to late 1993.
Emulating a Commodore 64 is not without it’s problems. “Awareness of Reality” doesn’t seem to load properly in Vice. The speed loader I used doesn’t like the emulator and I have yet to figure out what the “left arrow key” is on a PC keyboard. That key is used in AOR and “Ionsai on Gealach”, my award winning Galaxians mod! It’s great to hear those old tunes again though.

10 years down, many more to come I hope. I’m now a dad, married to my beautiful Jacinta and work at the cutting edge of blogging with the WordPress folks. Great times.

AOR disk listing

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.

Youtube feeds my C64 Nostalgia

It’s all Mark’s fault. He mentioned Codemasters, then Dizzy, then he posted this movie of Magicland Dizzy completed in super-fast time. I had to search for more.

The following post contains several Youtube videos so click more if you want to see Gyroscope, Ghosts and Goblins, Barbarian and other Commodore 64 classics brought to life again!

Continue reading “Youtube feeds my C64 Nostalgia”