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!
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! 53 comments
@markmoxon Oh wow! Wow. and so cleanly and clearly done too! I love it :ablobmeltsoblove: @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… 😀 @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 @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! 👍 @tehstu Thank you Stu! I also love that this exists… what I’d have given to have this back in the day. 😀 @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: Not much I can do about that, but it’s up to you how much notice you take of the legalities, of course. @markmoxon Thanks for that pointer! I overlooked it in my quick skim of the repo. @markmoxon Ideal comments, perfect ones, like all assembler source code should be commented. @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. @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… @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: @markmoxon dude, that’s a book by itself!! I need to print it! Looks like you wrote a great piece of CS archeology! @csstrowbridge The good thing about feeling old? It means you can relive your youth. Welcome to my 8-bit Elite project from 1985. 🤣 @markmoxon I cannot tell you how much this game influenced young me. What a gift, thank you. @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! @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 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. @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. 😀 @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 ;) @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! @markmoxon Aye, I think I played Frontier First Encouters back then - until running into some serious trouble. @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? @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 👍 🥰 @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 Also BeebDis which dissasembles 6502 .bin files into BeebAsm format .asm files. @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 @markmoxon Ooh, thanks, I must investigate and test on some of Tricky's (Richard Broadhurst) 6502 Beeb code 👍 |
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!
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.