I'm really proud to present my fully documented source code for Elite on the Commodore 64.

This is the original 1985 source, recently released by Ian Bell, with every single line of code explained.

It’s a thing of beauty. Enjoy!

https://github.com/markmoxon/elite-source-code-commodore-64

#retrocomputing #retrogaming #8bit #C64 #Commodore64 #Elite

GitHub - markmoxon/elite-source-code-commodore-64: Fully documented and annotated source code for Elite on the Commodore 64

Fully documented and annotated source code for Elite on the Commodore 64 - markmoxon/elite-source-code-commodore-64

GitHub

Here's some more information.

I've taken the original, extremely terse source files from the BBC Micro disc images on Ian Bell’s site, and have converted them into a fully buildable source with a full and detailed commentary.

That's 67,000 lines of heavily commented 6502 assembly that explain how this classic game works.

The C64 commentary comes to 246,255 words. The epic novel "Crime and Punishment" contains 211,591 words.

That's an awful lot of commentary; it's a complex game!

And this isn't AI slop or generated comments - it's 100% handcrafted technical analysis. It is a labour of love, and I hope it shows.

My next step will be to add the commentary to my https://elite.bbcelite.com/ website, to sit alongside the Acorn and NES commentaries I've already done.

I'll also write some deep dives into the C64 version, before turning my attention to the Apple II sources that Ian also released.

Right on, Commanders!

Fully documented source code for Elite on the 6502 (BBC Micro, Acorn Electron, Commodore 64, Apple II, NES)

Fully documented source code for Elite on the 6502 (BBC Micro, Acorn Electron, Commodore 64, Apple II, NES), with more than 100 deep dive articles explaining how every aspect of this iconic game works.

@markmoxon Congrats :) I was just looking at this today, and sorry to nitpick but I wanted to explain this bit: https://github.com/markmoxon/elite-source-code-commodore-64/blob/main/1-source-files/main-sources/elite-source.asm#L471
The first two bytes of RAM are the 6510 Processor Port, one of the things that separates a 6510 from an ordinary 6502. It manages the memory map and tape port. A very thorough description of its workings is available here: https://www.c64os.com/post/6510procport
elite-source-code-commodore-64/1-source-files/main-sources/elite-source.asm at main · markmoxon/elite-source-code-commodore-64

Fully documented and annotated source code for Elite on the Commodore 64 - markmoxon/elite-source-code-commodore-64

GitHub
@Kroc Ha, yes, that probably needs updating. I copied that comment from the Master version, which also skips those bytes, but they are genuinely unused in the Master). I’ll reword it to point out it’s the 6510 control bits, which I explain multiple times elsewhere in the commentary (it’s kinda hard not to understand those two bytes when doing a disassembly like this!).
@markmoxon That's very strange for the Master to skip those too! An early start at the C64 port being folded back into the Master version perhaps?

@Kroc Turns out the Master version is based on the C64 and Apple II versions. The sources very clearly go BBC Micro cassette -> BBC Micro disc -> 6502 Second Processor -> C64 -> Apple II -> BBC Master -> NES, with the Electron branching off the BBC Micro disc and merging into the C64 version. It’s fascinating - I’ll be writing a deep dive at some point.

Incidentally, I have updated that comment to talk about the 6510. Thanks for that! 👍

@markmoxon This is great, thank you for the huge amount of work it must've been!

There's no license on the repo, so it's automatically "all rights reserved." Is that your intention?

@vmbrasseur It is, yes, because I have no choice! This is explained here in the repo README:

https://github.com/markmoxon/elite-source-code-commodore-64?tab=readme-ov-file#user-content-a-note-on-licences-copyright-etc

Not much I can do about that, but it’s up to you how much notice you take of the legalities, of course.

GitHub - markmoxon/elite-source-code-commodore-64: Fully documented and annotated source code for Elite on the Commodore 64

Fully documented and annotated source code for Elite on the Commodore 64 - markmoxon/elite-source-code-commodore-64

GitHub
@markmoxon Thanks for that pointer! I overlooked it in my quick skim of the repo.
@markmoxon
This is from my youth. Thank you.
@baglodush Lovely, those original big box versions of Elite are things of rare beauty! 🤩

@markmoxon that’s an impressive job! 🤯 such dedication is admirable!

any hope to see it becoming something like @fabynou ”Doom Engine Black Book”? That would be fantastic!

@jak Well, it isn’t exactly the Black Book, but my series of deep dives attempts to explain the coding challenges (and solutions) that the Elite authors had to face. Almost all of these apply to the Commodore 64 version, and I’ll be adding some C64-specific dives soon:

https://elite.bbcelite.com/deep_dives/

Index of all deep dive articles - Elite on the BBC Micro and NES

Index of all deep dive articles about BBC Micro Elite

@markmoxon dude, that’s a book by itself!! I need to print it! Looks like you wrote a great piece of CS archeology!

@markmoxon

I remember playing that game on my C64.

I now feel very old.

@csstrowbridge The good thing about feeling old? It means you can relive your youth.

Welcome to my 8-bit Elite project from 1985. 🤣

@markmoxon incredible. truly good work.
@markmoxon what an impressive feat! Thank you for your work, I'd never thought I'd ever be able to take a look at how this fascinating game actually works.

@markmoxon I'm curious about the SKIP <bytes> directive which I've not seen before. e.g.

.RAND

SKIP 4

Is that defining a 4 byte global variable (.RAND), which is then allocated to the memory location wherever the counter happened to be on the zero page at compile time? Thus not having to hard code memory addresses?

@pauld Yes, that’s exactly what it does; SKIP reserves space by simply moving the assembly address on by that many bytes. You can also do the same with multiple EQUB 0 directives to insert the correct number of zeroes, but SKIP is more flexible.

I tend to use SKIP for memory addresses outside of binary files, and EQUBs for memory addresses that get saved as part of binary files (as one is skipping memory while the other explicitly sets a value) but when the value is zero, they do the same thing.

You can see how it fits in with the other BeebAsm directives here:

https://github.com/stardot/beebasm?tab=readme-ov-file#6-ASSEMBLER-DIRECTIVES

GitHub - stardot/beebasm: A portable 6502 assembler with BBC Micro style syntax

A portable 6502 assembler with BBC Micro style syntax - stardot/beebasm

GitHub
@markmoxon So many happy memories of playing this game.
@markmoxon My God, it's full of STAs!
@joegaffey Ha! 🤣 Perfect comment, well done. 🫡
@markmoxon I played Elite on a Sinclair ZX Spectrum. Loved it. Posts like this are making me look at getting Elite Dangerous & reliving those days.
@pasavito Elite Dangerous is great fun! It has a really similar feel to the original, but the learning curve is just as steep - it’s not a perfect game, but in VR in particular it’s astonishing. If you’re on a PC it’s always going on sale on Steam - definitely worth a punt when it’s discounted. And it’s still being developed, which is impressive after a whole decade.
@markmoxon and I found out it’s not on macos. I’ll dig out an old PC over Christmas & hope it’s got enough oomph to run Elite.

@pasavito Yeah, it was on macOS originally but they dropped it some years ago. That’s how I got started with E:D.

I think the PC requirements are pretty modest, so fingers crossed!

@markmoxon Great work 👍 🥰
I like BeebAsm but cc65 which includes ca65 6502 assembler is also good.
https://github.com/cc65/cc65
GitHub - cc65/cc65: cc65 - a freeware C compiler for 6502 based systems

cc65 - a freeware C compiler for 6502 based systems - cc65/cc65

GitHub
@dbolli I’ve also had success with vasm. Lots to choose from! But for trying to stick to the original Beeb source as closely as possible, BeebAsm is pretty hard to beat. 😀 Especially when populating lookup tables - it’s almost cut-and-paste from BBC BASIC , which is great!
@markmoxon There was a fairy. His name was "Nuff". Fairy Nuff 🙂 👍
@markmoxon Also BeebDis which dissasembles 6502 .bin files into BeebAsm format .asm files.
https://github.com/prime6809/BeebDis
GitHub - prime6809/BeebDis: 6502 Disassembler meant as a compliment to BeebAsm

6502 Disassembler meant as a compliment to BeebAsm - prime6809/BeebDis

GitHub
@dbolli Yeah, I started out with BeebDis, but py8dis is my disassembler of choice now. It’s brilliant, much more flexible than BeebDis. https://github.com/ZornsLemma/py8dis
GitHub - ZornsLemma/py8dis: A Python-based programmable static tracing disassembler

A Python-based programmable static tracing disassembler - ZornsLemma/py8dis

GitHub
@markmoxon Ooh, thanks, I must investigate and test on some of Tricky's (Richard Broadhurst) 6502 Beeb code 👍