Thrust Disassembly

reminisce about bbc micro & electron games like chuckie egg, repton, elite & exile

Related forum: adventures


User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Thrust Disassembly

Postby kieranhj » Fri Nov 27, 2015 11:27 pm

For reasons that I haven't quite determined (perhaps in small tribute to Jeremy C. Smith) I have decided to disassemble and document my favourite game, Thrust. I thought I would share with you all the first piece of that project. Attached should be a source file that is buildable using BeebAsm on the command line:

Code: Select all

beebasm.exe -i thrust6.6502 -do thrust6.ssd -boot Thrust6 -v

It was created with the assistance of the awesome BeebDis by Phill Harvey-Smith (does anyone know if he is lurking on here BTW, or whether BeebDis has continued to be developed?)

[If you're wondering why it is called Thrust6, the original executable on the ssd is Thrust3. This is encrypted so I named the decrypted version Thrust4. This then has to be relocated in memory, Thrust5, then finally I had to patch the bootstrap to build and run correctly, so Thrust6.]

I continue to document the disassembly and will share the final results with you as soon as it's ready. I was always so beguiled by this game when I used to play it back in the day, so have a strange urge to find out exactly how it was written..!
Attachments
thrust6.zip
Thrust source for beebasm
(25.52 KiB) Downloaded 120 times

User avatar
davidb
Posts: 1832
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Thrust Disassembly

Postby davidb » Fri Nov 27, 2015 11:51 pm

Sounds like an interesting project. :)

I briefly looked at the idea of figuring out the format of the maps in the game one lazy Sunday afternoon, but it looked like it might take a bit longer than that. ;)

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Sat Nov 28, 2015 12:18 am

Yeah, given that Jeremy and Peter went on to create the most technically sophisticated game ever made for the BBC Micro, I'm assuming they were both ninja programmers and therefore this is a non-trivial endeavour..!

User avatar
jms2
Posts: 1811
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK

Re: Thrust Disassembly

Postby jms2 » Sat Nov 28, 2015 7:21 am

I once did the same thing myself. .. I didn't figure out everything about the code, but it was fascinating and I discovered quite a few things about the game.

if I can find my notes, do you want them?

User avatar
Arcadian
Posts: 2734
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: Thrust Disassembly

Postby Arcadian » Sat Nov 28, 2015 7:45 am

kieranhj wrote:Phill Harvey-Smith (does anyone know if he is lurking on here BTW, or whether BeebDis has continued to be developed?)

Phill is a regular contributor here at StarDot and posts as 'Prime'.
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk

Image
ABug Leicestershire (17-19 November 2017)

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Sat Nov 28, 2015 4:04 pm

jms2 wrote:I once did the same thing myself. .. I didn't figure out everything about the code, but it was fascinating and I discovered quite a few things about the game.

if I can find my notes, do you want them?

Yes, please! That would be very helpful.

User avatar
jms2
Posts: 1811
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK

Re: Thrust Disassembly

Postby jms2 » Sat Nov 28, 2015 9:42 pm

Here they are - I did this back in 2003! :D

My approach was not to comment the disassembly (for some reason). Instead I wrote a separate file of notes which explains key points of how the code works.

I think I probably scribbled on a hard copy of the disassembly, and only wrote up some of my discoveries in the explanation file. I might be able to find the paper copy as well.

I hope it is helpful. This was the first game I disassembled and I found the process fascinating. Time consuming though.
Attachments
Thrust disassembly notes.zip
Thrust disassembly and comments file (word format)
(132.11 KiB) Downloaded 125 times

User avatar
jms2
Posts: 1811
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK

Re: Thrust Disassembly

Postby jms2 » Sat Nov 28, 2015 9:49 pm

davidb wrote:Sounds like an interesting project. :)

I briefly looked at the idea of figuring out the format of the maps in the game one lazy Sunday afternoon, but it looked like it might take a bit longer than that. ;)


I can shed some light on that.

The game maps are deceptively simple. The horizontal lines seen on the screen are not a stylistic feature, they are actually an artefact of how the screens are stored. Each line of the level comprises a left hand "solid part", a middle "gap part" and a right hand "solid part". So each line is just two bytes (or might be two words, I can't remember), giving the X co-ordinates of the start and end of the gap (or maybe the start of the gap followed by the width).

I really must find my marked up paper version!

User avatar
davidb
Posts: 1832
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Thrust Disassembly

Postby davidb » Sat Nov 28, 2015 11:17 pm

jms2 wrote:The game maps are deceptively simple. The horizontal lines seen on the screen are not a stylistic feature, they are actually an artefact of how the screens are stored. Each line of the level comprises a left hand "solid part", a middle "gap part" and a right hand "solid part". So each line is just two bytes (or might be two words, I can't remember), giving the X co-ordinates of the start and end of the gap (or maybe the start of the gap followed by the width).

Ah, so simple! Thanks. :)

Maybe one day I'll write an editor for it.

User avatar
jms2
Posts: 1811
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK

Re: Thrust Disassembly

Postby jms2 » Sun Nov 29, 2015 10:06 am

davidb wrote:
jms2 wrote:The game maps are deceptively simple. The horizontal lines seen on the screen are not a stylistic feature, they are actually an artefact of how the screens are stored. Each line of the level comprises a letft hand "solid part", a middle "gap part" and a right hand "solid part". So each line is just two bytes (or might be two words, I can't remember), giving the X co-ordinates of the start and end of the gap (or maybe the start of the gap followed by the width).

Ah, so simple! Thanks. :)

Maybe one day I'll write an editor for it.


As a consequence of the way the levels are stored, you can never have a situation where the cave divides (except purely horizontally, and then you are limited by the max width which is presumably 256). Given this limitation, I doubt it would be possible to improve on the current levels very much. Also bear in mind that features such as the sliding doors are written as custom code for the relevant levels.

Taking these factors into account, I think your talents would be better employed elsewhere!

User avatar
davidb
Posts: 1832
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Thrust Disassembly

Postby davidb » Sun Nov 29, 2015 12:56 pm

jms2 wrote:As a consequence of the way the levels are stored, you can never have a situation where the cave divides (except purely horizontally, and then you are limited by the max width which is presumably 256). Given this limitation, I doubt it would be possible to improve on the current levels very much. Also bear in mind that features such as the sliding doors are written as custom code for the relevant levels.

Taking these factors into account, I think your talents would be better employed elsewhere!

Thanks. :)

The next logical step was the scrolling map in Exile, I suppose. Thrust 2 looks like it was a very different game on the other platforms.

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Sun Nov 29, 2015 1:42 pm

jms2 wrote:Here they are - I did this back in 2003! :D

My approach was not to comment the disassembly (for some reason). Instead I wrote a separate file of notes which explains key points of how the code works.

I think I probably scribbled on a hard copy of the disassembly, and only wrote up some of my discoveries in the explanation file. I might be able to find the paper copy as well.

I hope it is helpful. This was the first game I disassembled and I found the process fascinating. Time consuming though.

What a star, thank you! This is amazingly helpful and is going to save me a ton of time. :) I've commented the code pretty much through to the end of all the setup so having the full memory map and entry points for the main game routines is exceptionally useful. I wanted to make the game buildable so that anyone (starting with myself, I guess) could then make changes to and experiment with the code.

A level editor would be interesting or perhaps just a simple way of converting bitmaps to level data for instance. Anyway, I will carry on down the rabbit hole of disassembly and we can have a discussion about what might be fun to do with it. What could Thrust 1.5 look like? :D

User avatar
jms2
Posts: 1811
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK

Re: Thrust Disassembly

Postby jms2 » Sun Nov 29, 2015 11:43 pm

Pleased to be of help! :D

My best suggestion would be to use sideways ram perhaps to create new levels. Other than that, I would say that Thrust is more or less perfect.

User avatar
Rich Talbot-Watkins
Posts: 1090
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca

Re: Thrust Disassembly

Postby Rich Talbot-Watkins » Mon Nov 30, 2015 9:49 am

Interesting stuff! Never looked deeply into how Thrust works. One thing that surprised me is that it stores all the graphics as bitmaps rather than drawing them as line segments (as their design so wants you to believe!). I guess that's how it was able to render so smoothly. Very nice game, and interesting to see which aspects of it found their way to Exile later on (the scrolling mechanism, the physics simulation).

Just to add, it looks like there are a few blocks of code in your disassembly which are still rendered as EQUBs - e.g. 3A9F looks like code to me (from what I can disassemble "by eye", it looks like it's reading the keyboard directly from the hardware). Also 2BC6 and 3B40 look like code too (no idea what they do though).

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Mon Nov 30, 2015 12:29 pm

Thanks Rich. You have a good eye - I found the keyboard reading routine last night and you're right it is still EQUB's. As the data blocks are interleaved through a lot of the code, I had to give BeebDis directives as to what to treat as data blocks rather than wade through a massive chunk of illegal opcodes. I definitely missed a few spots.

I tend to agree with jms2 that Thrust is more or less perfect, hence being my favourite game. :)

Anyway, I'm making good progress but now the working week is getting in the way. More updates soon.

tom_seddon
Posts: 80
Joined: Mon Aug 29, 2005 11:42 pm
Contact:

Re: Thrust Disassembly

Postby tom_seddon » Mon Jan 11, 2016 2:23 am

Looking forward to seeing more of this. I always wondered what magic (or, perhaps, just trickery...) it did to scroll the screen so nicely, since it didn't appear to be using hardware scrolling.

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Sat Jan 16, 2016 5:24 pm

I haven't forgotten about this but has turned out to be substantially more work than I thought. (Who is surprised? ;) Going through 9000+ lines of assembler and data has proven to be fairly time consuming plus I have a day job to do (it does make my train commute pass pretty quickly though.)

I have made substantial progress however - I've located every subsystem, isolated and named every function, identified and named every variable (even if I don't know exactly what all of them do yet) of which there are well over 100 (most of zero page), identified every pointer table and data set - so it is possible to compile your own levels. :) Oh yeah, there was a load of self-modifying code to isolate and document - par for the course when squeezing the most of out the humble Beeb, I should have realised.

I always thought of Thrust as a such a wonderful and elegant game, even more so now after attempting to "become one" with the code. Perhaps because the game itself is so simple and "sparse" in design, certainly compared with something like Exile, I naively thought it wouldn't be that epic but it really does fill all of memory and is finely tuned to make the most of the Beeb. There is not much fat here at all.

I reckon I must have clocked up at least 60 hours on this so far and TBH I'm looking forward to writing some of my own code for a change. The source is a bit of a mess at the moment but I think what I'll do is try to clean up what I've got ASAP and upload here. That was we can use the collective brainpower of the *. community to really reverse engineer & (ideally) document how all of the different subsystems work.

In answer to your question, no the screen isn't hardware scrolled but redrawn as required by keeping track of the left & right extents of each line of terrain that is visible within the window. If you notice there is a limitation on the angles of the terrain - they only slope by 4 pixels (1 byte) per line. A lot of the player maths is also interesting as x coordinates are 8.8 fixed-point whilst the y coordinates are 10.8 fixed-point (levels are deep not wide.)

Maybe I should have chosen something simpler, like Chuckie Egg, to start with. :D

User avatar
davidb
Posts: 1832
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Thrust Disassembly

Postby davidb » Sat Jan 16, 2016 7:22 pm

Sounds like an impressive feat - both the original game and your disassembly of it! :)

You'll be doing the Electron version next, I hope. ;) Then Kees can port the game to the Atom. :D

User avatar
billcarr2005
Posts: 1058
Joined: Fri Sep 09, 2005 3:01 pm
Location: UK
Contact:

Re: Thrust Disassembly

Postby billcarr2005 » Mon Feb 08, 2016 6:41 pm

Found the following - on BBC-PD disk 134, written by Martin Burchell in 1992 which changes the 6 original levels (in the file "ThrExt"), so added it onto the original disk and made sure it loads up OK. Modified "ThrLoad" because it used to give the option to load from cassette or PIAS versions.

Here's a message contained with "TXMCode"

Code: Select all

Thrust Extra Missions written by Martin Burchell (C) 1992.
Original Thrust game by Jeremy C. Smith.
David Braben allegedly says "Play Thrust Extra Missions today - It's much better than Zarch, Elite or Exile!"
Where is David Braben these days anyway?
What ever happened to the Elite sequel?
If you have enjoyed playing these extra missions or think a dog could do better why not write and tell me at 100 Pinkerton Road, Basingstoke (someone has to live there), RG22 6RN.
Perhaps you would like to see a mission designer.
If there is enough response (and I gain sufficient enthusiasm) one will be written!
Hi to everyone who knows or knew me (note the originality - listing a load of people I may have some loose connection with) including Andy "Saloon Cars" Swain - soon to defect to Microprose, Diluk Dias of "The Yorkshire Boys" (I bet they're hard), Myles Rix, Joe "JVM modest graphic designer" Myers (both last seen at QMC), Edward Ramsden, Ben Corby, Chris Milward, Nick Lewis, Richard "say it" Louder, Peter Robinson, everyone at The Centre of Excellence and Jeremy "C" Smith who I don't know but thought I'd include by way of apology - I mean how would you like to have your "highly addictive yet simple and fun to play" (or something like that) game totally ruined by some half-crazed undergraduate with nothing better to do?
Where are all the great BBC games writers today?
Have they found respectable careers?
Answers on a postcard........................................

Welcome to this month's Beeb User.
Later in this issue some reviews of games that are useless but we've still awarded them 80% to please the advertisers.
But first it seems that some people still haven't got the hang of our checksums so here again is our blindingly obvious guide to using them.
First of all make sure you are in the same room as your computer and you are in such a position as to reach your keyboard.
Now turn your micro ON (that's the large switch at the back of your machine)...

PROBLEMS PATRONISED
Q.  I am working on a GCSE project which involves controlling motors from a BBC model B.  Can you show me the circuit diagram I will need?
A.  I can't see why I have to tell you what to do - after all it's your project isn't it?  Instead I'm going to refer you to one of my articles which is now about five years old so you won't be able to order it from our back issues service.

Q.  I own a BBC computer and it doesn't work.  Can you please tell me what's wrong?
A.  Well first of all I'm going to patronise you for being so vague.  I mean how am I supposed to know if you tell me "it doesn't work"?

Next I shall use some jargon you won't understand to sound very knowledgable.

LETTERS PAGE.  * My eight-year-old son bought a tape from our computer game shop which wouldn't load.  We took it back but they said they wouldn't replace it, showing us the large notices in the store reminding customers of this.  I am very angry because now we have a useless tape and a bawling kid...  * I thought I'd let you have some "hints for beginners" which appear every year on the letters page but you seem to publish them despite this.  In fact any old mug could look them up in the User Guide.  @ Well done.  I'm sure these tips for beginners will be very useful.  Have `10.  * I'd just like to give a bit of free advertising to the supplier who was very helpful when my machine recently failed to work.  Words can not describe how grateful I am.  Lick, lick.  Slurp, slurp etc.  * I still don't understand the checksums.  Can you help?
Attachments
Thrust.zip
Thrust with 6 new levels
(37.42 KiB) Downloaded 64 times

User avatar
MartinB
Posts: 4512
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Thrust Disassembly

Postby MartinB » Mon Feb 08, 2016 7:46 pm

Ha ha, brilliant sense of humour :lol:

Always nice to see people not taking computing too seriously..... :D =D>

User avatar
Wookie
Posts: 342
Joined: Sat Aug 27, 2005 10:06 am
Location: Lost in a fog of PSU capacitor smoke

Re: Thrust Disassembly

Postby Wookie » Mon Feb 08, 2016 8:20 pm

billcarr2005 wrote:Found the following - on BBC-PD disk 134, written by Martin Burchell in 1992


Nice One =D>

I think I need to practice the original gane as these new levels are seriously hard.

Thanks for posting it.
cheers Wookie
Overclocked StrongARM RiscPC + Viewfinder
Overclocked Arm3 8MB A310 + vidc extender
BBC Master with Matchbox CoPro
BBC B+ 64K
My original Electron from 1985 with Slogger MasterRam/Turbo,AP1,AP2 rom, AP3+4 & New AP6

User avatar
streaks
Posts: 194
Joined: Thu Oct 13, 2005 2:08 pm
Contact:

Re: Thrust Disassembly

Postby streaks » Tue Feb 09, 2016 12:05 am

Sheesh.. Everyone in this forum is brainy. What do y'all do for a living?
streaksy (at) gmail (dot) com

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Wed Feb 10, 2016 1:11 pm

Cool! I will definitely take a look. I still haven't forgotten about posting the disassembly. Work has become painfully busy of late but I will get something out in the next couple of weeks. It won't be complete but I'm hoping you lot can crowd-source the rest of the reverse engineering with me. :)

User avatar
jms2
Posts: 1811
Joined: Mon Jan 08, 2007 6:38 am
Location: Derby, UK

Re: Thrust Disassembly

Postby jms2 » Wed Feb 10, 2016 9:23 pm

Hey Kieran,

I had a bit of a tidy up in the attic the other day and found my hand-amended Thrust disassembly. I don't know whether my last amendments made it into the Word file, but my guess is that they did not. There's quite a bit of scribbling on there, would you like me to scan it all in and send it to you?

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Thu Feb 11, 2016 11:07 am

Yes please! All information is helpful. I went back to it last night after a month off (to write some of my own code for a change) and the scope of it is daunting. Currently tidying everything up with consistent naming and commenting to make it easier for others to digest and help document the final pieces in crowd form.

User avatar
sirmorris
Posts: 702
Joined: Wed Feb 11, 2009 12:18 pm
Location: oxfordshire uk
Contact:

Re: Thrust Disassembly

Postby sirmorris » Mon Feb 15, 2016 12:17 pm

One thing I always think about in cases like this is a 'documenting emulator' - an emulation which logs addresses of executed instructions, data reads and writes. At its simplest you take an array of 64k bytes and set a bit to mark each of those events. Dump it out at the end and you have - pretty much - an accurate model of the memory usage.

Obv. I've never done this but if you have an open source emulator I don't imagine the work needed to implement this would be prohibitive.

C

User avatar
ash73
Posts: 35
Joined: Wed Feb 03, 2016 10:51 pm
Location: Cheshire, UK

Re: Thrust Disassembly

Postby ash73 » Mon Feb 15, 2016 1:05 pm

Rich Talbot-Watkins wrote:One thing that surprised me is that it stores all the graphics as bitmaps rather than drawing them as line segments (as their design so wants you to believe!)


I read somewhere Elite on the NES was implemented like that, too.

SteveBagley
Posts: 128
Joined: Sun Mar 15, 2015 8:44 pm

Re: Thrust Disassembly

Postby SteveBagley » Mon Feb 15, 2016 6:43 pm

sirmorris wrote:One thing I always think about in cases like this is a 'documenting emulator' - an emulation which logs addresses of executed instructions, data reads and writes. At its simplest you take an array of 64k bytes and set a bit to mark each of those events. Dump it out at the end and you have - pretty much - an accurate model of the memory usage.


I did something like this with an ARM simulator to mark student coursework. I found if you make it a 2D array with the row being the address read/written and the column being the PC of the instruction performing the read/write then you can tell a heck of a lot about the way the program works from the patterns of access. You'd very quickly be able to tell which routines accessed the screen etc. just by drawing the array as a picture.

Steve

User avatar
sirmorris
Posts: 702
Joined: Wed Feb 11, 2009 12:18 pm
Location: oxfordshire uk
Contact:

Re: Thrust Disassembly

Postby sirmorris » Mon Feb 15, 2016 7:56 pm

Nice!

User avatar
kieranhj
Posts: 489
Joined: Sat Sep 19, 2015 10:11 pm
Location: Farnham, Surrey, UK

Re: Thrust Disassembly

Postby kieranhj » Tue Feb 16, 2016 1:18 pm

On the topic of emulators. There is an effort to put BeebEm into GitHub so it can continue to be developed (see thread in the Emulators board) - I'm sure it would be possible to add the self-documenting capabilty into that, or on a fork. The B-Em source is also readily available although I had some trouble getting it built with the latest version of the dependent libraries (Allegro, OpenAL.)

Matt Godbolt has also posited adding some sort of source disassembly side-band functionality to jsbeeb. This could be particularly useful for the OS sources when stepping through in the debugger etc. Would be great to be able to add game sources along side this, like Exile or Thrust etc.

I have set myself a deadline of this weekend to tidy up what I have and share it with you all. Won't be perfect but hopefully enough for everyone to dig through the various routines and properly document how each of the algorithms work.


Return to “software: classic games”

Who is online

Users browsing this forum: No registered users and 3 guests