4 ; This bootloader creates a signed binary so that the Lynx will accept it.
8 .import __BANK0BLOCKSIZE__
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 #$97 ; y = secondary loader size (151 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, $81, $ca, $33, $be, $80, $a2, $c4
53 .byte $6d, $98, $fe, $8d, $bc, $66, $c0, $7a
54 .byte $09, $50, $23, $28, $18, $c8, $06, $70
55 .byte $58, $4f, $1b, $e1, $c7, $90, $08, $cd
56 .byte $1a, $6e, $5a, $45, $32, $d7, $6d, $c6
57 .byte $8a, $e5, $d8, $5c, $a0, $e8, $4f, $7a
58 .byte $5f, $73, $8d, $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
79 lda _FileBlockOffset+1
87 ; 4. Read in the main exe to RAM
100 ; 5. Jump to start of the main exe code
103 ;**********************************
104 ; Skip bytes on bank 0
105 ; X:Y count (EOR $FFFF)
106 ;**********************************
115 ;**********************************
116 ; Read bytes from bank 0
117 ; X:Y count (EOR $ffff)
118 ;**********************************
131 ;**********************************
132 ; Read one byte from cartridge
133 ;**********************************
141 ;**********************************
143 ;**********************************
170 lda #<($100-(>__BANK0BLOCKSIZE__))