Email or username:

Password:

Forgot your password?
Mark Moxon

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!

github.com/markmoxon/elite-sou

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

53 comments
Mark Moxon

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 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!

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 original source files
The same code in the fully documented sources
:jan:‍:abreath:‍‍🌬:dandelion:

@markmoxon Oh wow! Wow. and so cleanly and clearly done too! I love it :ablobmeltsoblove:

Mark Moxon

@Crazypedia Thank you, that’s good to hear! I tried hard to make it easy to read, so even people who don’t know 6502 assembly can follow along. Or that’s the idea, anyway… 😀

Kroc Camen

@markmoxon Congrats :) I was just looking at this today, and sorry to nitpick but I wanted to explain this bit: github.com/markmoxon/elite-sou
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: c64os.com/post/6510procport

Mark Moxon

@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!).

Kroc Camen

@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?

Mark Moxon

@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! 👍

Stu

@markmoxon Nothing to add except to thank you! I love so much that this exists.

Mark Moxon

@tehstu Thank you Stu! I also love that this exists… what I’d have given to have this back in the day. 😀

VM (Vicky) Brasseur

@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?

Mark Moxon

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

github.com/markmoxon/elite-sou

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

VM (Vicky) Brasseur

@markmoxon Thanks for that pointer! I overlooked it in my quick skim of the repo.

Mark Moxon

@baglodush Lovely, those original big box versions of Elite are things of rare beauty! 🤩

Pensador Louco :fuck_verify:

@markmoxon I used to play it a lot, back when I had an MSX computer. 😍

★ STMAN ★ 🏳️‍🌈

@markmoxon Ideal comments, perfect ones, like all assembler source code should be commented.

Mark Moxon

@stman Thank you, that’s really good to hear!

★ STMAN ★ 🏳️‍🌈

@markmoxon It's the way I comment my assembler code too myself, and all my life I've been complaining about all those who don't write such kind of comments, with same quality, and regularity, when coding in assembler. It's absolutely essential, including for one as a coder, because it's a way to double check your own code when writing a comment, and I found a lot of bugs I did thanks to that.

Mark Moxon

@stman Absolutely! The only issue is if you change the code and forget to update the comments - I’ve made that mistake more than once! - but that isn’t a problem when analysing a game like Elite, as the code doesn’t change. Anyway, glad to hear from someone else who likes comments; I don’t really believe in self-documenting code…

JaK

@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!

Mark Moxon

@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:

elite.bbcelite.com/deep_dives/

JaK

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

C.S.Strowbridge

@markmoxon

I remember playing that game on my C64.

I now feel very old.

Mark Moxon

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

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

killabees

@markmoxon I cannot tell you how much this game influenced young me. What a gift, thank you.

Mark Moxon

@killabees Same here, this game was far and away the most influential bit of software from my youth. Spent months playing it, literally! It made me really curious as to how it worked… hence this project, I guess. Right on, Commander!

Wintermute_BBS :verified: ⛔

@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.

Herr Bischoff

@markmoxon Wow. I have no words. I couldn’t even begin to understand the complexities of coding a game like Elite entirely in Assembly. Also, this is my childhood.

Mark Moxon

@herrbischoff It was massive part of my childhood too - I literally played this game for months! I’ve still got the muscle memory: S, X, <, >, A, ?, space… I don’t think I’ll ever forget. 😀

Panda

@markmoxon a magical game which I never ever mastered but I'm fascinated with. Have it on the "lets try again list for 2025" on PC ;)

Mark Moxon

@panda It’s definitely worth a go. It’s pretty unforgiving and a challenge to master, but I still fire it up regularly, and it still holds up. The flight model is such a delight - what a masterpiece!

Panda

@markmoxon Aye, I think I played Frontier First Encouters back then - until running into some serious trouble.
With the current game I didn't manage to get the flying license, I but I guess I should try again with a controller. While I like flying, exploring and trading, I don't like battle.

Paul

@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?

Mark Moxon

@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:

github.com/stardot/beebasm?tab

@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.

Keith Bradnam 📈

@markmoxon So many happy memories of playing this game.

Tony West

@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.

Mark Moxon

@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.

Tony West

@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.

Mark Moxon

@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!

dbolli

@markmoxon Great work 👍 🥰
I like BeebAsm but cc65 which includes ca65 6502 assembler is also good.
github.com/cc65/cc65

Mark Moxon

@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!

dbolli

@markmoxon There was a fairy. His name was "Nuff". Fairy Nuff 🙂 👍

dbolli

@markmoxon Also BeebDis which dissasembles 6502 .bin files into BeebAsm format .asm files.
github.com/prime6809/BeebDis

Mark Moxon

@dbolli Yeah, I started out with BeebDis, but py8dis is my disassembler of choice now. It’s brilliant, much more flexible than BeebDis. github.com/ZornsLemma/py8dis

dbolli

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

Go Up