.ENTRY LDA $C054 ; Select page 1 display (i.e. main screen memory) by ; reading the PAGE20FF soft switch LDA $C052 ; Configure graphics on the whole screen by reading the ; MIXEDOFF soft switch LDA $C057 ; Select high-resolution graphics by reading the HIRESON ; soft switch LDA $C050 ; Select the graphics mode by reading the TEXTOFF soft ; switch LDA ZP1 ; Store the current contents of ZP1(1 0) and ZP2(1 0) on PHA ; the stack, so we can restore them later LDA ZP1+1 PHA LDA ZP2 PHA LDA ZP2+1 PHA LDA $C08B ; Set RAM bank 1 to read RAM and write RAM by reading ; the RDWRBSR1 soft switch, with bit 3 set (bank 1), ; bit 1 set (read RAM) and bit 0 set (write RAM) ; ; So this enables bank-switched RAM at $D000 ; We now want to copy all the data between $9000 and ; $C000 into the bank-switched RAM at $D000 LDA #LO(CODE2) ; Set ZP1(1 0) = CODE2 STA ZP1 LDA #HI(CODE2) STA ZP1+1 LDA #LO(STORE) ; Set ZP2(1 0) = STORE STA ZP2 LDA #HI(STORE) STA ZP2+1 LDY #0 ; Set Y = 0 to use as a byte counter LDX #HI($C000-$9000) ; We want to copy all the data between $9000 and $C000, ; so set X to the number of pages to copy .MVLP1 LDA (ZP1),Y ; Copy the Y-th byte of ZP1(1 0) to the Y-th byte of STA (ZP2),Y ; ZP2(1 0) INY ; Increment the byte counter BNE MVLP1 ; Loop back until we have copied a whole page of bytes INC ZP1+1 ; Increment the high bytes of ZP1(1 0) and ZP2(1 0) so INC ZP2+1 ; they point to the next page in memory DEX ; Decrement the page counter BNE MVLP1 ; Loop back until we have copied X pages LDA $C081 ; Set ROM bank 2 to read ROM and write RAM by reading ; the WRITEBSR2 soft switch, with bit 3 clear (bank 2), ; bit 1 clear (read ROM) and bit 0 set (write RAM) PLA ; Restore the contents of ZP1(1 0) and ZP2(1 0) from STA ZP2+1 ; the stack, so they are unchanged by the subroutine PLA STA ZP2 PLA STA ZP1+1 PLA STA ZP1 RTS ; Return from the subroutineName: ENTRY [Show more] Type: Subroutine Category: Utility routines Summary: Copy the second block of the game code, between CODE2 and STORE, into bank-switched RAM at $D000Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
This transfer program can be found on the source disk on Ian Bell's site. It packs the entire game binary into memory, ready to be transmitted to an Apple II computer connected to the BBC Micro's User Port. This code is run in the released variants of the game, but it doesn't have any effect (apart from slowing down the load process). In the source disk variant, it forms part of the development process. As part of the build process, the assembled game is split into two parts, CODE1 and CODE2 (in the original build process, the BASIC program S.SCODES creates these files, while in the modern build this split is done in the elite-checksum.py Python script). The split is as follows: * CODE1 contains the first $5000 bytes, from $4000 to $8FFF. * CODE2 contains the rest of the binary, from $9000 to $BFFF. The source you are reading now takes these two parts and produces two more binaries, ELA and ELB, which contain the two parts of the game binary, plus the following routine. ELA contains CODE2, while ELB contains CODE1 and the rest of the data. For the official Firebird variant of the game, the loading process is managed by a dedicated game loader. See the elite-loader.asm source for details. For the variant of the game on Ian Bell's website, the ELA and ELB files are not used, and instead CODE1 and CODE2 are loaded directly from disk and are moved to their correct addressses by a simple mover program. See the elite-mover.asm source for details. For the source disk variant, the process is different, as the game isn't run on an Apple II, but instead it's transmitted across a cable from the BBC Micro development machine to the test Apple II machine. The transfer process goes like this: * ELA is transmitted first, which loads the game data at $0B60, the loading screen at $2000 and CODE2 at $9000 to $BFFF. * The ENTRY routine in ELA (i.e. this routine) is called on the Apple II, which copies CODE2 into bank-switched RAM at $D000. * ELB is transmitted next, which loads CODE1 from $4000 to $8FFF. * The S% routine in ELB is called on the Apple II, which copies CODE2 out of bank-switched RAM back to $9000 to $BFFF. We don't have copies of the transfer software - there are some tantalising clues in the S.APMAKES BASIC program, which includes a *APPLE command that is presumably part of the transfer process - but I'm assumimg this memory-moving process ensures that CODE2 doesn't get corrupted by the second transfer process. Interestingly, this routine is run by all variants of the game when ELA is loaded, so the released game also copies CODE2 into bank-switched RAM when it loads. The only difference is that the copied code is ignored in the released game.
[X]
Configuration variable CODE2 = $4000
The address where the main game code file is loaded
[X]
Label MVLP1 is local to this routine
[X]
Configuration variable STORE = $D000
The address where the main game code file is run