Exile disassembly

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

Related forum: adventures


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

Exile disassembly

Postby Rich Talbot-Watkins » Sun May 22, 2011 3:09 pm

Look what I just came across on the interwebs:

http://www.level7.org.uk/miscellany/exi ... sembly.txt

Is that the work of someone here? I'm gonna start looking through it now and comparing my notes with theirs, but all-in-all, it looks like a pretty comprehensive bit of work!

Impressive stuff!

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

Re: Exile disassembly

Postby davidb » Sun May 22, 2011 5:20 pm

Rich Talbot-Watkins wrote:Impressive stuff!

Indeed! There's also a disassembly of XOR on that site as well: http://www.level7.org.uk/chroma/xor-disassembly.txt

User avatar
The Kraken
Posts: 199
Joined: Tue Oct 21, 2008 4:51 pm

Re: Exile disassembly

Postby The Kraken » Sun May 22, 2011 10:48 pm

Also interesting is that according to that, the second character's name is the Latin word QUAESTOR, rather than QUESTOR as I've usually seen it written :-k

User avatar
Samwise
Posts: 1822
Joined: Mon Mar 14, 2005 9:13 pm
Contact:

Re: Exile disassembly

Postby Samwise » Sun May 22, 2011 11:24 pm

The WHOIS record suggests an Andrew Flintham owns the site.

He contributed a collection of games to the BBC PD #19: Sorcerer's Domain and BBC PD #28: Games discs in '88, I think.

Sam.

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Sun May 22, 2011 11:53 pm

Ahh I didn't think of finding the site owner that way... but I couldn't see any names at all, not even in the source code for his programs.

I think he was also the guy in charge of 'Doggysoft' for RISC OS back in the day...

tautology
Posts: 341
Joined: Wed Sep 01, 2010 2:26 pm

Re: Exile disassembly

Postby tautology » Mon May 23, 2011 6:38 am

Rich Talbot-Watkins wrote:I think he was also the guy in charge of 'Doggysoft' for RISC OS back in the day...


Nah; that was Andrew Clover (who was in charge of Doggysoft), who's still around on t'Internet (I last email him about 4 years ago when I noticed him posting to full-disclosure).

Andrew Flintham (or AMF) was a rather weird character on the RISC OS scene, who did some freeware, including some text adventures and have a rather, erm, weird perspective on some things.

A quick Google finds this page, which may be him.

On disassembly of games; are people still interested in them - I've got half a disassembly on Hobgoblin on my computer, which I stopped doing when I realised that nobody but me would read it.

User avatar
LeeB
Posts: 207
Joined: Sun Aug 20, 2006 1:51 pm

Re: Exile disassembly

Postby LeeB » Tue May 24, 2011 6:41 pm

Wow, that is certainly impressive! A shame assembly code is not something I understand really though!

User avatar
mga1103
Posts: 184
Joined: Mon Jan 24, 2011 4:00 pm
Location: Galway, Ireland

Re: Exile disassembly

Postby mga1103 » Tue May 24, 2011 11:10 pm

tautology wrote:...
On disassembly of games; are people still interested in them - I've got half a disassembly on Hobgoblin on my computer, which I stopped doing when I realised that nobody but me would read it.


I always enjoy browsing them, but I'm not sure my browsing interest is sufficient for anyone busting a gut and going to all that effort!

But if there's stuff already done, bring it on... :wink:

User avatar
Benjy
Posts: 51
Joined: Wed Nov 17, 2010 12:46 am
Location: Stafford
Contact:

Re: Exile disassembly

Postby Benjy » Fri Jun 03, 2011 9:26 pm

It saddens me that Exile fitted onto a floppy disk and current Microsoft operating systems are over a gig in footprint!

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

Re: Exile disassembly

Postby tom_seddon » Mon Sep 12, 2016 10:13 pm

Bump... I've put a buildable copy here: https://github.com/tom-seddon/exile_disassembly

As a bonus, this also creates the sideways RAM version too. (That's mostly the same code, with a few minor changes - search for everywhere the value SRAM is checked - and a big block of it compiled to run from the ROM area rather than RAM. There's also a support file for it, ExileSR, which I didn't disassemble. I think it contains the sound sample data.)

I was going to have a go at making some more interesting changes, but having got this far I'm a bit sick of it for now ;)

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Tue Sep 13, 2016 7:24 am

Awesome work Tom!! =D>

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Tue Sep 13, 2016 12:18 pm

Just had a quick browse through that now. Looks like you've added a few more comments too - great stuff!

Every time I dare to look at the sprite routine, it astonishes me how that was ever able to work at a decent speed. I hate to think how many cycles-per-byte that is, yet it appeared to work surprisingly well in game, with surprisingly little flicker! There are a few things I haven't figured yet: firstly how it deals with plotting sprites which pass through the screen wraparound point at &8000; secondly how it was able to animate with so little flicker - was it unplotting the old and plotting the new in parallel or something mad like that? The genius of filling certain zp locations with different colour byte values to write, and then self-modifying an LDA zp depending on the 2bpp sprite data just astounds me.

And I always thought that's a pretty wacky routine address table too!

Code: Select all

equb (HI(change_to_weapon-1)<<1) OR 1

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

Re: Exile disassembly

Postby tom_seddon » Tue Sep 13, 2016 2:43 pm

That wacky table was the first thing I figured out and I quickly ran out of eyebrows to raise while doing it. The process_keys routine that consumes it is a miniature masterpiece, too!

Regarding the wrapping, it does two cunning things, I think, assuming I've understood the code properly:

First, it goes backwards through memory, so when going from character row to character row (see L1084) it can update the MSB by subtracting 2 (512 bytes/line), then doing ORA #$40 or ORA #$60, since the screen size is a power of two. ($3f | $40 = $7f; $5f | $20 = $7f.)

Secondly, it checks at the start of each line (plot_lines_loop) whether the line will straddle $8000. If it won't, no problem; if it will, it pokes in a reference to L109C at L1070, where L109C is the code that handles the wrap... I think? I didn't look at this bit in any great detail, but it subtracts the screen size from the MSB with `EOR #screen_size_pages-1'...

I'm less certain about the plotting/unplotting question - but I think it unplots the old sprite fully before drawing the new one (many of the references to xxx,X in the sprite routine are used to select between the object's old value and the new value - and the routine gets called once with X=1 then again with X=0). I'm pretty sure you do get flicker sometimes, from memory, but most of the time there's not that much on screen, and with only 128 visible lines on the model B version there's plenty of blank time to draw stuff in. Maybe the SRAM version would have more visible flicker? (Must admit I haven't played it much recently, and certainly not enough to stress it by having lots of objects on screen! I mostly did all of this entirely on the PC, because all I needed to know was whether the assembled code matched the STH disk :))

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Wed Sep 14, 2016 4:43 pm

Having scrutinised it a bit, it looks as if it plots over the beginning of ROM/Sideways RAM, and then notices afterwards that it needs to redo the end bit wrapped round to the beginning of the screen again - must be the first time I've seen Exile doing unnecessary work!

This code is full of mad stuff - I was boggled the first time I saw how it uses the stack as quick scratch space. I think the extra PHA just above L1051 is so that if it reads off the end of the data when plotting a sprite at an odd pixel offset, it doesn't add a random uninitialized byte to the LH edge of the sprite.

There's definitely flicker (e.g. the big pushable floating block) but I'm surprised it's not more pronounced given there must be a ton of cycles between unplotting and plotting, since the sprite routine is so big. It must be easily 200-250 cycles per pixel row for an 'average' sprite. Does it try to sort by Y when plotting or anything like that?

Other things of note: null_function I think is left over from the protection system which used to hang the game on f9 or after a few minutes. Would be interesting to see the untampered binary to compare... one thing I remember is that elsewhere in the code was a check to see if you'd tried to disable the protection and it would fail in this case too. That "(C) 1989BEEBSOFT" string wasn't in the original code from the best of my memory.

sbadger
Posts: 203
Joined: Mon Mar 25, 2013 1:12 pm
Location: Farnham, Surrey

Re: Exile disassembly

Postby sbadger » Thu Sep 15, 2016 12:05 pm

Amazing work here Tom. My assembler has never been as good as my high level langs. Has anyone ever heard of porting asm to c?
Does it even make sense?
A3020 | BBC B x2 | Electrn | Master | RPi x3
A600 | C64 "breadbox"| C64 C | XB360 | GB | GBC | GBA | GBASP | DS | 3DS XL & new | MD | MS
Atari 7600 | PS1-2-3-4 | PSP | Vita | SNES | GC | N64 | Wii & U | Switch | Jamma Cab | Sony PVMx2

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Thu Sep 15, 2016 12:07 pm

The next thing I haven't yet really fathomed is collision. Are objects treated as rectangles, and does it just perform collision of bounding boxes (e.g. when stacking objects)? Clearly collision with background tiles, e.g. angled walls, is less granular. But does it know the wall slope and make a special case for that, or is it actually doing per-pixel checks? I'm thinking that given that the high bits of the pixel colour have special meaning for background, it should be able to use them to determine collisions - but so far I haven't found the code that might do something like that.

Exile's physics model was actually pretty damn good! It must have some notion of which objects are on top of other objects (like a modern physics engine in fact!) so it can transfer momentum to them as the base moves. And all this in 24k... sob.

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Thu Sep 15, 2016 12:14 pm

sbadger wrote:Amazing work here Tom. My assembler has never been as good as my high level langs. Has anyone ever heard of porting asm to c?
Does it even make sense?

I started hand porting the code to C at once point, the idea being to try to get it running as unchanged as possible using GLFW as a basic cross-platform framework. I started with the map tile generating routine, but it was hard going, all the jumps make it very difficult to produce a decent looking C function. As I wanted it as much for self-documentation and readability, I gave up. But it might be worth tackling again one day.

There are tools which can generate compilable C code from 6502 opcodes automatically - but that wouldn't give a readable high-level impression of what it's doing. For this, it really needs to be done by hand.

User avatar
PitfallJones
Posts: 428
Joined: Fri Feb 22, 2008 3:44 pm
Contact:

Re: Exile disassembly

Postby PitfallJones » Thu Sep 15, 2016 12:29 pm

There are tools which can generate compilable C code from 6502 opcodes automatically - but that wouldn't give a readable high-level impression of what it's doing.

Interresting - do you have any links for that software?

Lomas conversion of Chuckie Egg does that but I think he did that by hand:
http://marklomas.net/ch-egg/index.htm

- PJ

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Thu Sep 15, 2016 12:38 pm

It was Michael Foot's conversions I was thinking of, which Mark Lomas used as a starting point for his conversion. There'll always be something to be done by hand regarding graphics and sound, otherwise you essentially just have an emulator. For simpler things it can be almost entirely automated, but the resulting code is horrible, e.g. here is Commodore 64 Basic running natively, compiled from C code generated from 6502. Lovely!

sbadger
Posts: 203
Joined: Mon Mar 25, 2013 1:12 pm
Location: Farnham, Surrey

Re: Exile disassembly

Postby sbadger » Thu Sep 15, 2016 12:45 pm

Rich Talbot-Watkins wrote:I started hand porting the code to C at once point, the idea being to try to get it running as unchanged ....

that's exactly my angle.

Rich Talbot-Watkins wrote:There are tools which can generate compilable C code from 6502 opcodes automatically - but that wouldn't give a readable high-level impression of what it's doing. For this, it really needs to be done by hand.

yes looked at these - but as you say, the code they produce is as unreadable if not more as the machine code.

I remember reading an article about Peter Irvin and the amiga versions and think it mentioned the conversion of the beeb version to amiga much of it was a hand ported from 6502 to c., I wonder if the amiga version might be equivilent but more decipherable.
A3020 | BBC B x2 | Electrn | Master | RPi x3
A600 | C64 "breadbox"| C64 C | XB360 | GB | GBC | GBA | GBASP | DS | 3DS XL & new | MD | MS
Atari 7600 | PS1-2-3-4 | PSP | Vita | SNES | GC | N64 | Wii & U | Switch | Jamma Cab | Sony PVMx2

sbadger
Posts: 203
Joined: Mon Mar 25, 2013 1:12 pm
Location: Farnham, Surrey

Re: Exile disassembly

Postby sbadger » Thu Sep 15, 2016 1:02 pm

in fact here is the article - an interesting read...

http://exile.acornarcade.com/amiga.html
A3020 | BBC B x2 | Electrn | Master | RPi x3
A600 | C64 "breadbox"| C64 C | XB360 | GB | GBC | GBA | GBASP | DS | 3DS XL & new | MD | MS
Atari 7600 | PS1-2-3-4 | PSP | Vita | SNES | GC | N64 | Wii & U | Switch | Jamma Cab | Sony PVMx2

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

Re: Exile disassembly

Postby tom_seddon » Thu Sep 15, 2016 10:46 pm

sbadger wrote:Amazing work here Tom.


The credit has to go to whoever produced the original disassembly! 99% of the code in the repo is copied from that, and the conversion was done mostly automatically (I wrote a Python script to do the bulk of it, and then fixed up a few bits by hand.) I'd never have got anywhere with the sideways RAM thing, or my additional comments, without this to start from!

I've now added a few more comments to the sprite routine, mainly notes on the screen wrapping behaviour and the address calculation - not that I've quite figured it all out just yet - and uploaded it to the repo. You're quite right about how it does the wrapping, Rich... that has to be why the sideways RAM data starts at $8100...

I'll probably be chipping away further at the disassembly in the future, so watch the repo for more updates. Pull requests welcome too of course :)

--Tom

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Fri Sep 16, 2016 11:21 pm

I saw the latest commits - so the sampled sound is using Pulse Width Modulation then (basically all or nothing 1 bit data with variable width pulses)? Surprised it sounds so good! I think I read somewhere that PWM audio is normally louder than the PCM method (essentially using the volume to provide 4 bit samples) but I'd've expected the quality to be terrible. I also just realised I actually have no idea how to create a PWM stream from a PCM sample (like a .wav or whatever).

garfield
Posts: 387
Joined: Mon Jan 03, 2005 1:38 am

Re: Exile disassembly

Postby garfield » Sat Sep 17, 2016 2:56 am

Exile is fantastic, so thanks all for highlighting/bundling the source.

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

Re: Exile disassembly

Postby sirmorris » Sat Sep 17, 2016 6:20 am

PWM audio can sound great - there were a load of CD players (whooooo?) which used technology like '1 bit dac with 16x oversampling' back in the day. It's called DDS or direct digital synthesis. I'm no expert but this is how I understand it.

Given a byte which represents a particular voltage level when fed to a DAC you instead output a PWM signal where the mark/space ratio represents a fraction of the peak to peak voltage in the system you're driving. You have to use a much higher output frequency than the sampling rate used to record the sample in order that you generate more than one pwm cycle per input sample. IIUIC this is oversampling. Interpolation and dithering can also be used to generate intermediate levels between samples, increasing resolution.

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

Re: Exile disassembly

Postby kieranhj » Sat Sep 17, 2016 8:11 am

Hmmm, opportunity for someone to write a general WAV -> Beeb PWM sample player? :) Now you all mention it, I do remember the samples in Exile being a lot louder than the sampled music demos that are available.

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

Re: Exile disassembly

Postby billcarr2005 » Sat Sep 17, 2016 9:44 am

Rich Talbot-Watkins wrote:Other things of note: null_function I think is left over from the protection system which used to hang the game on f9 or after a few minutes. Would be interesting to see the untampered binary to compare... one thing I remember is that elsewhere in the code was a check to see if you'd tried to disable the protection and it would fail in this case too. That "(C) 1989BEEBSOFT" string wasn't in the original code from the best of my memory.


Code: Select all

3948 CLC
3949 ADC #04
394B JMP 3298

394E LDY #44
3950 LDX #02
3952 JSR 313E
3955 EOR 0B63,Y
3958 INY
3959 DEX
395A BNE 3955
395C EOR 07E7,Y
395F BNE 394E
3961 RTS

3962 32 80 80 20



Might've been removed deliberately so the game couldn't be saved?

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

Re: Exile disassembly

Postby Rich Talbot-Watkins » Sat Sep 17, 2016 10:29 am

Ah, thanks Bill :)

That's quite beautifully obfuscated, exactly like I remember. So that routine at 313E (marked as unused in the disassembly) performs a funny operation on the byte stored at 499C (also noted as unused!) which I assume is the checksum from the entered word, then does some further EORing with BA7/BA8, and finally compares it with 82D (marked in the disassembly as "timers and eor"! - I assume it's the 'correct answer' for the novella word). And then infinite loops if it's not equal, but not in a really obvious way.

It looks like it periodically calls that function when it's deciding whether it should spawn Triax, so once in a while so as not to do extra work. Nice!

John_Acorn
Posts: 19
Joined: Fri Jul 07, 2017 8:57 am

Re: Exile disassembly

Postby John_Acorn » Sun Jul 09, 2017 4:26 pm

Rich Talbot-Watkins wrote:The next thing I haven't yet really fathomed is collision. Are objects treated as rectangles, and does it just perform collision of bounding boxes (e.g. when stacking objects)? Clearly collision with background tiles, e.g. angled walls, is less granular. But does it know the wall slope and make a special case for that, or is it actually doing per-pixel checks? I'm thinking that given that the high bits of the pixel colour have special meaning for background, it should be able to use them to determine collisions - but so far I haven't found the code that might do something like that.

Exile's physics model was actually pretty damn good! It must have some notion of which objects are on top of other objects (like a modern physics engine in fact!) so it can transfer momentum to them as the base moves. And all this in 24k... sob.


The other amazing thing was they wrote it one summer holiday using only original Acornkit as far as I know.

dan_daran
Posts: 1
Joined: Thu Sep 28, 2017 7:30 pm

Re: Exile disassembly

Postby dan_daran » Sat Sep 30, 2017 11:02 am

great work here, ! remembering those colours and , journeying through space what a game still nothing like it really, thinking about those messages in the amiga version designed to get hackers to think pjm irvin said but the amiga version had some implemtation of those ideas , there was an extra weapon f5 to activate and also you could never collect a full set of keys in the bbc version also a switch in the east caverns which didnt seem to activate anything but you could hear a door opening somewhere i used beebem debugger to cycle through the items like the microuser cheat and there was a pill which when you picked up turned the pallete blue and let you walk through walls a short distance anyway

but the amiga game had "a large clam with special powers and a bad attitude" to quote the ui message! ( more powerfull than the others in the game) above the acid drips in the east caves in a dead end i am sure the idea was to collect the
"food not for you but for what" and give to clam = "it has given you special powers" also "here is a secret passage " "you have killed triax" obviously designed to deceive hackers but the f5 weapon triggered a "serendipity" (spawned in a using similar to the microuser cheat )message and fired homing type missiles with the "it has given you special powers" these would home in on enemys(triax) i do remember going through a teleporter under a red mushroom daze and coming somwhere different but i think i amagined that lol! in the game so some ideas maybe didnt have time to be included as wf reeve said ironically ran out of ram in the amiga version due to larger graphics/detail yes i have spent a long time on this great game and i thought the novella was brilliant in the bbc version as a 12 year old it really brought it alive


Return to “software: classic games”

Who is online

Users browsing this forum: No registered users and 5 guests