BBC Elite source, now fully documented and explained

reminisce about classic bbc micro and acorn electron games here
Related forum: adventures


cjpinder
Posts: 18
Joined: Fri Jul 03, 2020 6:00 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by cjpinder » Fri Sep 04, 2020 9:31 pm

Kroc wrote:
Fri Sep 04, 2020 1:21 pm
I'm not sure what the intention (or outcome) of the EOR is; given that it's only checked when "C" is held, so it can't be for the purposes of breaking docking computer control because that wouldn't make sense only for one direction (any direction should cancel, if this is the intention). It may be that the order of keys in the key-table is implying something else from the BBC's perspective, and they didn't correct it; `joy_down` is the "X" key, and this happens to appear 3 bytes before "C" in the key table on the C64.
This is curious as to what the C64 is trying to do!
Luckily this is one place in the source code where there is actually a comment and it says "kill phantom Cs". So I'm pretty sure the code is there because of the C64 keyboard ghosting issue where if you hold down certain key combinations it thinks another key is being held down when it isn't. Probably using A,S and X was causing C to appear to be held down when it wasn't.

Thanks,
Christian.

User avatar
Dave Footitt
Posts: 916
Joined: Thu Jun 22, 2006 10:31 am
Location: Abandoned Uranium Workings
Contact:

Re: BBC Elite source, now fully documented and explained

Post by Dave Footitt » Fri Sep 04, 2020 10:11 pm

Like many others have said, proper amazing work =D> =D>

MarkMoxon
Posts: 67
Joined: Thu Jul 18, 2019 4:38 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by MarkMoxon » Fri Sep 04, 2020 11:22 pm

melchett wrote:
Fri Sep 04, 2020 6:27 pm
MarkMoxon wrote:
Thu Sep 03, 2020 11:34 am
Ha! That is absolutely epic! =D>
I updated this so you could destroy it with lasers too not just an energy bomb Mark...
This is great. :D I’m genuinely surprised how amenable to change this part seems to be!
melchett wrote:
Fri Sep 04, 2020 6:27 pm
interesting that the code auto re-spawns a space station after the explosions complete
Well, every 32 iterations round the main loop, the code checks for your relative position to the planet, and if you're in the right spot, it spawns a space station, so I guess that's what's going on - it sees you are in the right place and there’s no station, so it just spawns another. See part 14 of the main flight loop, which does the test and calls NWSPS to spawn the station.

Mark

User avatar
Diminished
Posts: 492
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by Diminished » Fri Sep 04, 2020 11:26 pm

And yet they're still stupid enough to sell you more missiles.

User avatar
Snuggsy187
Posts: 120
Joined: Wed Apr 03, 2019 9:53 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by Snuggsy187 » Fri Sep 04, 2020 11:47 pm

Hmmmm.....
I did exactly the same thing..... mod the code so lasers can destroy the station..... (stop the police coming out before it explodes).

I was interested to see if the station re-spawned or not !

Destroying the station is the best thing I've ever seen...... Having a bad day at work ? Just load the Elite mod and blow up the space station.

:lol:
PUSH PARCHMENT > POKE LOCK > PULL PARCHMENT

Kroc
Posts: 12
Joined: Sun Feb 17, 2013 12:24 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by Kroc » Sat Sep 05, 2020 1:35 pm

The routine used to copy the ship instance to the zero-page (and to copy it back later) could do with some slight optimisation:
This is the code in the BBC version;

Code: Select all

 LDY #NI%-1             \ There are NI% bytes in the INWK workspace, so set a
                        \ counter in Y so we can loop through them

.MAL2

 LDA (INF),Y            \ Load the Y-th byte of INF and store it in the Y-th
 STA INWK,Y             \ byte of INWK

 DEY                    \ Decrement the loop counter

 BPL MAL2               \ Loop back for the next byte, ending when we have
                        \ copied the last byte from INF to INWK
Here's the same [unoptimised] code in the C64 disassembly to use as reference for the optimised version;

Code: Select all

        ;                                       ; bytes/tally   cycles/tally
        ;---------------------------------------;-------------------------------
        ldy # .sizeof(PolyObject)-1             ; +2    2       +2      2
:       lda [ZP_POLYOBJ_ADDR], y                ; +2    .       +5      .      
        sta ZP_POLYOBJ, y                       ; +2    .       +5      .      
        dey                                     ; +1    .       +2      .      
        bpl :-                                  ; +2    7       +3     (15)
        ;                                 loop: ;               -1  *37=555
        ;---------------------------------------;-------------------------------
        ;                                total: ;       9               556
Here's a slightly optimised version:

Code: Select all

        ;                                       ; bytes/tally   cycles/tally
        ;---------------------------------------;-------------------------------
        lda ZP_POLYOBJ_ADDR_LO                  ; +2    .       +3      .
        sta @copy+1                             ; +3    .       +4      .
        lda ZP_POLYOBJ_ADDR_HI                  ; +2    .       +3      .
        sta @copy+2                             ; +3    10      +4      14
        ldx # .sizeof(PolyObject)-1             ; +2    2       +2      2
        ;---------------------------------------;-------------------------------
@copy:  lda $8888, x                            ; +3    .       +4      .
        sta ZP_POLYOBJ, x                       ; +2    .       +4      .
        dex                                     ; +1    .       +2      .
        bpl @copy                               ; +2    8       +3     (13)
        ;                                 loop: ;               -1  *37=481
        ;---------------------------------------;-------------------------------
        ;                                total: ;       20              496
This saves just 60 cycles, but we can double that for the same optimisation applied to the routine to copy the zero-page back to the ship instance, equals 120 cycles. This saving applies for each ship in play, so for a busy screen with 10 ships floating about that would be 1'200 cycles saved!

(You could also completely unroll the loop and that takes just 370 cycles, one way -- at a cost of 186 bytes!)

EDIT: Note that the C64 has 37 bytes in an instance, not 36 like the BBC!

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

Re: BBC Elite source, now fully documented and explained

Post by jms2 » Sat Sep 05, 2020 5:47 pm

One of the aspects of Elite that always intrigued me was the potential to get trapped in Witchspace and attacked by the Thargoids. On the Electron version, which I had at the time, it was never clear whether this was possible, and there were various rumours suggesting how to make it happen (I seem to recall diving steeply when hyperspacing or something like that ... which never worked for me). Anyway, Mark's disassembly explains very clearly how to make it happen and I can confirm that it works in the Master version. However, I have a couple of Master-specific comments to add:

1) The Thargoids are plotted in stripy red-and-cyan.
2) Using the Escape capsule is not fatal - it just doesn't do anything at all. [EDIT - I thought that "Escape" launched the capsule but I have since discovered that it's actually "Q", so it probably is fatal after all]

I found myself left with not enough fuel to reach any other planets and so Witchspace was unescapable for me. I take it there is no other way out?

MarkMoxon
Posts: 67
Joined: Thu Jul 18, 2019 4:38 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by MarkMoxon » Sat Sep 05, 2020 9:41 pm

jms2 wrote:
Sat Sep 05, 2020 5:47 pm
One of the aspects of Elite that always intrigued me was the potential to get trapped in Witchspace and attacked by the Thargoids. On the Electron version, which I had at the time, it was never clear whether this was possible, and there were various rumours suggesting how to make it happen (I seem to recall diving steeply when hyperspacing or something like that ... which never worked for me).
I fell for this one, too! When I was trying to work out the code, I wanted to know how to trigger witchspace, and I found the following in Ian Bell's FAQ:
How do I force a mis-jump/entry to "witch space"?

On 6502 versions, this is achieved by engaging maximum "climb" as the hyperspace countdown times out. On the BBC version, you may have to pause the game, press CTRL_X, and then resume to enable this.
Like you, I couldn't get that to work... and after tracking down the relevant code, I found that pitching is nothing to do with it, at least not on the BBC, and that CTRL and X are involved, but not together. I wonder if some of the other versions do need to be at full pitch to trigger the onslaught?
jms2 wrote:
Sat Sep 05, 2020 5:47 pm
I found myself left with not enough fuel to reach any other planets and so Witchspace was unescapable for me. I take it there is no other way out?
No, if you get stranded too far from the nearest system, you're stuck. I guess it's all part of the witchspace experience... :cry:

Mark

User avatar
Diminished
Posts: 492
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by Diminished » Sun Sep 06, 2020 3:02 pm

MarkMoxon wrote:
Sat Sep 05, 2020 9:41 pm
I wonder if some of the other versions do need to be at full pitch to trigger the onslaught?
I believe the original DOS version worked this way (which is the one that I played through BITD), but it's been a long time.

Kroc
Posts: 12
Joined: Sun Feb 17, 2013 12:24 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by Kroc » Tue Sep 15, 2020 9:39 am

Just to get a second opinion on this, is this a bug here?

When the player destroys a ship, it goes through a set of checks to see if it can put a message on the screen, but the paying of bounties is tied to this check, meaning that should a message already be on screen (e.g. "incoming missile") the player will NOT get the bounty for the kill!

Code: Select all

.q2

 LDA DLY                \ If we already have an in-flight message on-screen (in
 ORA MJ                 \ which case DLY > 0), or we are in witchspace (in
 BNE KS1S               \ which case MJ > 0), jump to KS1S to skip showing an
                        \ on-screen bounty for this kill

 LDY #10                \ Fetch byte #10 of the ship's blueprint, which is the
 LDA (XX0),Y            \ low byte of the bounty awarded when this ship is
 BEQ KS1S               \ killed (in Cr * 10), and if it's zero jump to KS1S as
                        \ there is no on-screen bounty to display

 TAX                    \ Put the low byte of the bounty into X

 INY                    \ Fetch byte #11 of the ship's blueprint, which is the
 LDA (XX0),Y            \ high byte of the bounty awarded (in Cr * 10), and put
 TAY                    \ it into Y

 JSR MCASH              \ Call MCASH to add (Y X) to the cash pot

 LDA #0                 \ Print control code 0 (current cash, right-aligned to
 JSR MESS               \ width 9, then " CR", newline) as an in-flight message

.KS1S

 JMP KS1                \ Process the killing of this ship (which removes this
                        \ ship from its slot and shuffles all the other ships
                        \ down to close up the gap)

MarkMoxon
Posts: 67
Joined: Thu Jul 18, 2019 4:38 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by MarkMoxon » Tue Sep 15, 2020 9:54 am

Kroc wrote:
Tue Sep 15, 2020 9:39 am
Just to get a second opinion on this, is this a bug here?

When the player destroys a ship, it goes through a set of checks to see if it can put a message on the screen, but the paying of bounties is tied to this check, meaning that should a message already be on screen (e.g. "incoming missile") the player will NOT get the bounty for the kill!

Code: Select all

.q2

 LDA DLY                \ If we already have an in-flight message on-screen (in
 ORA MJ                 \ which case DLY > 0), or we are in witchspace (in
 BNE KS1S               \ which case MJ > 0), jump to KS1S to skip showing an
                        \ on-screen bounty for this kill

 LDY #10                \ Fetch byte #10 of the ship's blueprint, which is the
 LDA (XX0),Y            \ low byte of the bounty awarded when this ship is
 BEQ KS1S               \ killed (in Cr * 10), and if it's zero jump to KS1S as
                        \ there is no on-screen bounty to display

 TAX                    \ Put the low byte of the bounty into X

 INY                    \ Fetch byte #11 of the ship's blueprint, which is the
 LDA (XX0),Y            \ high byte of the bounty awarded (in Cr * 10), and put
 TAY                    \ it into Y

 JSR MCASH              \ Call MCASH to add (Y X) to the cash pot

 LDA #0                 \ Print control code 0 (current cash, right-aligned to
 JSR MESS               \ width 9, then " CR", newline) as an in-flight message

.KS1S

 JMP KS1                \ Process the killing of this ship (which removes this
                        \ ship from its slot and shuffles all the other ships
                        \ down to close up the gap)
Good catch, Kroc! That does indeed look like in-flight messages prevent you from earning a bounty.

Perhaps your Cobra's messaging service is single-tasking and can't transmit details of the kill to GalCop if it's busy displaying messages about missiles and stuff? Then again, it does register a kill for the rank progression, so yeah, perhaps it's a bug. :-)

Is it the same in the C64 version?

Mark

Kroc
Posts: 12
Joined: Sun Feb 17, 2013 12:24 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by Kroc » Tue Sep 15, 2020 10:06 am

MarkMoxon wrote:
Tue Sep 15, 2020 9:54 am
Is it the same in the C64 version?
Yeah, I'm working through the C64 code and documenting it, using your BBC code as reference. I noticed the bug in the C64 code but wanted to double-check if the BBC was exhibiting the same behaviour

dominicbeesley
Posts: 1113
Joined: Tue Apr 30, 2013 12:16 pm
Contact:

Re: BBC Elite source, now fully documented and explained

Post by dominicbeesley » Tue Sep 15, 2020 11:20 am

I seem to recall that when playing BITD... most disappointing

User avatar
CHRISJJ
Posts: 47
Joined: Sun Feb 02, 2014 1:34 am
Contact:

Re: BBC Elite source, now fully documented and explained

Post by CHRISJJ » Wed Sep 16, 2020 12:52 am

cjpinder wrote:
Wed Sep 02, 2020 11:35 pm
But even when I did Elite-TNK 20 years ago I had "modern" systems to help me. Angus was working on a BBC Model B, just a few years after Elite was released.
Hmm. Angus told me he used a BBC Micro with 6502 second processor.

So I think it very unlikely he was stuck with only a Model B.

Not that that changes the fact his Elite-III was a great achievement. Almost as great has another one of his. With none of our dev tools or dev system docs, going only by end-user code, he created a brilliant code module for the Hybrid Music System. In that (unlike Elite adaptations), he's unique - to my knowledge.

Post Reply

Return to “8-bit acorn software: classic games”