4 ; This bootloader creates a signed binary so that the Lynx will accept it.
9 .export __BOOTLDR__: absolute = 1
12 ; ------------------------------------------------------------------------
16 ;**********************************
17 ; Here is the bootloader in plaintext
18 ; The idea is to make the smalles possible encrypted loader as decryption
19 ; is very slow. The minimum size is 49 bytes plus a zero byte.
20 ;**********************************
25 ; ; 1. force Mikey to be in memory
28 ; ; 3. set ComLynx to open collector
29 ; lda #4 ; a = 00000100
30 ; sta SERCTL ; set the ComLynx to open collector
32 ; ; 4. make sure the ROM is powered on
33 ; lda #8 ; a = 00001000
34 ; sta IODAT ; set the ROM power to on
36 ; ; 5. read in secondary exe + 8 bytes from the cart and store it in $f000
38 ; ldy #$AB ; y = secondary loader size (171 bytes)
39 ;rloop1: lda RCART0 ; read a byte from the cart
40 ; sta EXE,X ; EXE[X] = a
43 ; bne rloop1 ; loops until y wraps
45 ; ; 6. jump to secondary loader
46 ; jmp EXE ; run the secondary loader
49 ;**********************************
50 ; After compilation, encryption and obfuscation it turns into this.
51 ;**********************************
52 .byte $ff, $dc, $e3, $bd, $bc, $7f, $f8, $94
53 .byte $b7, $dd, $68, $bb, $da, $5b, $50, $5c
54 .byte $ea, $9f, $2b, $df, $96, $80, $3f, $7e
55 .byte $ef, $15, $81, $ae, $ad, $e4, $6e, $b3
56 .byte $46, $d7, $72, $58, $f7, $76, $8a, $4a
57 .byte $c7, $99, $bd, $ff, $02, $3e, $5b, $3f
58 .byte $0c, $49, $1b, $22
60 ;**********************************
61 ; Now we have the secondary loader
62 ;**********************************
64 ; 1. Read in the 1st File-entry (main exe) in FileEntry
67 rloop: lda RCART0 ; read a byte from the cart
68 sta _FileEntry,X ; EXE[X] = a
73 ; 2. Set the block hardware to the main exe start
78 ; 3. Skip over the block offset
80 ldx _FileBlockOffset+1
81 phx ; The BLL kit uses negative offsets
82 plx ; while the basic Lynx uses positive
83 bmi @1 ; Make all offsets negative
95 ; 4. Read in the main exe to RAM
102 phx ; The BLL kit uses negative counts
103 plx ; while the basic Lynx uses positive
104 bmi @3 ; make all counts negative
116 ; 5. Jump to start of the main exe code
119 ;**********************************
120 ; Skip bytes on bank 0
121 ; X:Y count (EOR $FFFF)
122 ;**********************************
131 ;**********************************
132 ; Read bytes from bank 0
133 ; X:Y count (EOR $ffff)
134 ;**********************************
147 ;**********************************
148 ; Read one byte from cartridge
149 ;**********************************
157 ;**********************************
159 ;**********************************
186 lda #<($100-(>__BLOCKSIZE__))