Skip to navigation

Elite on the BBC Micro and NES

Loader: Elite loader (Part 2 of 5)

[Acorn Electron version, Loader]

Name: Elite loader (Part 2 of 5) [Show more] Type: Subroutine Category: Loader Summary: Perform a number of OS calls, set up sound, push routines on stack
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * David7 calls via Ian1

This part of the loader does a number of calls to OS routines, sets up the sound envelopes, and pushes 33 bytes onto the stack. A lot of the code in this routine has been removed or hobbled to remove the protection; for a full picture of the protection that's missing, see the source code for the BBC Micro cassette version, which contains almost exactly the same protection code as the original Electron version.
Other entry points: Ian1 Re-entry point following the wild goose chase obfuscation
.ENTRY NOP \ This part of the loader has been disabled by the NOP \ crackers, as this is an unprotected version NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP LDA #&60 \ This appears to be a lone instruction left over from STA &0088 \ the unprotected code, as this value is never used NOP \ This part of the loader has been disabled by the NOP \ crackers, as this is an unprotected version NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP LDA #&20 \ Set A to the op code for a JSR call with absolute \ addressing NOP \ This part of the loader has been disabled by the \ crackers, as this is an unprotected version .Ian1 NOP \ This part of the loader has been disabled by the NOP \ crackers, as this is an unprotected version NOP NOP NOP LSR A \ Set A = 16 LDX #3 \ Set the high bytes of BLPTR(1 0), BLN(1 0) and STX BLPTR+1 \ EXCN(1 0) to &3. We will fill in the high bytes in STX BLN+1 \ the PLL1 routine, and will then use these values in STX EXCN+1 \ the IRQ1 handler LDX #0 \ Call OSBYTE with A = 16 and X = 0 to set the joystick LDY #0 \ port to sample 0 channels (i.e. disable it) JSR OSBYTE LDX #255 \ Call doPROT1 to change an instruction in the PROT1 LDA #&95 \ routine and set up another couple of variables JSR doPROT1 LDA #144 \ Call OSBYTE with A = 144, X = 255 and Y = 0 to move JSR OSB \ the screen down one line and turn screen interlace on EQUB &2C \ Skip the next instruction by turning it into \ &2C &D0 &92, or BIT &92D0, which does nothing apart \ from affect the flags .FRED1 BNE David7 \ This instruction is skipped if we came from above, \ otherwise this is part of the multi-jump obfuscation \ in PROT1 LDA #247 \ Call OSBYTE with A = 247 and X = Y = 0 to disable the LDX #0 \ BREAK intercept code by poking 0 into the first value JSR OSB LDA #143 \ Call OSBYTE 143 to issue a paged ROM service call of LDX #&C \ type &C with argument &FF, which is the "NMI claim" LDY #&FF \ service call that asks the current user of the NMI JSR OSBYTE \ space to clear it out LDA #13 \ Set A = 13 for the next OSBYTE call .abrk LDX #0 \ Call OSBYTE with A = 13, X = 0 and Y = 0 to disable JSR OSB \ the "output buffer empty" event LDA #225 \ Call OSBYTE with A = 225, X = 128 and Y = 0 to set LDX #128 \ the function keys to return ASCII codes for SHIFT-fn JSR OSB \ keys (i.e. add 128) LDA #172 \ Call OSBYTE 172 to read the address of the MOS LDX #0 \ keyboard translation table into (Y X) LDY #255 JSR OSBYTE STX TRTB% \ Store the address of the keyboard translation table in STY TRTB%+1 \ TRTB%(1 0) NOP \ This part of the loader has been disabled by the NOP \ crackers, as this is an unprotected version NOP NOP NOP NOP NOP NOP NOP NOP NOP LDA #13 \ Call OSBYTE with A = 13, X = 2 and Y = 0 to disable LDX #2 \ the "character entering keyboard buffer" event JSR OSB .OS01 LDX #&FF \ Set the stack pointer to &01FF, which is the standard TXS \ location for the 6502 stack, so this instruction \ effectively resets the stack INX \ Set X = 0, to use as a counter in the following loop \ The following loop copies the crunchit routine into \ zero page, though this unprotected version of the \ loader doesn't call it there, so this has no effect LDY #0 \ Set a counter in Y for the copy .David3 LDA crunchit,Y \ Copy the Y-th byte of crunchit .PROT1 STA TRTB%+2,X \ And store it in the X-th byte of zero page after the \ TRTB%(1 0) variable INX \ Increment both byte counters INY CPY #33 \ Loop back to copy the next byte until we have copied BNE David3 \ all 33 bytes LDA #LO(B%) \ Set the low byte of ZP(1 0) to point to the VDU code STA ZP \ table at B% LDA #&95 \ This part of the loader has been disabled by the BIT PROT1 \ crackers, as this is an unprotected version (the BIT \ instruction is an STA instruction in the full version, \ but it has been hobbled here) LDA #HI(B%) \ Set the high byte of ZP(1 0) to point to the VDU code STA ZP+1 \ table at B% LDY #0 \ We are now going to send the N% VDU bytes in the table \ at B% to OSWRCH to set up the screen mode .LOOP LDA (ZP),Y \ Pass the Y-th byte of the B% table to OSWRCH JSR OSWRCH INY \ Increment the loop counter CPY #N% \ Loop back for the next byte until we have done them BNE LOOP \ all (the number of bytes was set in N% above) LDA #1 \ This part of the loader has been disabled by the TAX \ crackers, as this is an unprotected version (the CMP TAY \ instruction is an STA instruction in the full version, LDA abrk+1 \ but it has been hobbled here) CMP (V219),Y LDA #4 \ Call OSBYTE with A = 4, X = 1 and Y = 0 to disable JSR OSB \ cursor editing, so the cursor keys return ASCII values \ and can therefore be used in-game LDA #9 \ Call OSBYTE with A = 9, X = 0 and Y = 0 to disable LDX #0 \ flashing colours JSR OSB LDA #&6C \ This part of the loader has been disabled by the NOP \ crackers, as this is an unprotected version (the BIT NOP \ instruction is an STA instruction in the full version, NOP \ but it has been hobbled here) BIT &544F FNE 0 \ Set up sound envelopes 0-3 using the FNE macro FNE 1 FNE 2 FNE 3