From 2222df9143368a2005507ff3c91ad478ee5bcb27 Mon Sep 17 00:00:00 2001 From: karri Date: Tue, 11 Sep 2012 13:01:39 +0000 Subject: [PATCH] Shring the bootloader by 20 bytes and remove restrictions on file size git-svn-id: svn://svn.cc65.org/cc65/trunk@5824 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- libsrc/lynx/bootldr.s | 51 ++++++++++++---------------------- libsrc/lynx/open.s | 16 +++-------- libsrc/lynx/read.s | 18 ++++-------- src/ld65/cfg/lynx-bll.cfg | 2 +- src/ld65/cfg/lynx-coll.cfg | 2 +- src/ld65/cfg/lynx-uploader.cfg | 2 +- src/ld65/cfg/lynx.cfg | 2 +- 7 files changed, 32 insertions(+), 61 deletions(-) diff --git a/libsrc/lynx/bootldr.s b/libsrc/lynx/bootldr.s index 4c437bc97..c5d051610 100644 --- a/libsrc/lynx/bootldr.s +++ b/libsrc/lynx/bootldr.s @@ -23,7 +23,7 @@ ; .org $0200 ; ; ; 1. force Mikey to be in memory -; stz MAPCTL +; stz MAPCTL ; ; ; 3. set ComLynx to open collector ; lda #4 ; a = 00000100 @@ -35,7 +35,7 @@ ; ; ; 5. read in secondary exe + 8 bytes from the cart and store it in $f000 ; ldx #0 ; x = 0 -; ldy #$AB ; y = secondary loader size (171 bytes) +; ldy #$97 ; y = secondary loader size (151 bytes) ;rloop1: lda RCART0 ; read a byte from the cart ; sta EXE,X ; EXE[X] = a ; inx ; x++ @@ -49,13 +49,13 @@ ;********************************** ; After compilation, encryption and obfuscation it turns into this. ;********************************** - .byte $ff, $dc, $e3, $bd, $bc, $7f, $f8, $94 - .byte $b7, $dd, $68, $bb, $da, $5b, $50, $5c - .byte $ea, $9f, $2b, $df, $96, $80, $3f, $7e - .byte $ef, $15, $81, $ae, $ad, $e4, $6e, $b3 - .byte $46, $d7, $72, $58, $f7, $76, $8a, $4a - .byte $c7, $99, $bd, $ff, $02, $3e, $5b, $3f - .byte $0c, $49, $1b, $22 + .byte $ff, $30, $73, $35, $4a, $a8, $54, $ef + .byte $54, $20, $f5, $38, $f4, $35, $7e, $31 + .byte $7a, $c3, $f6, $eb, $ee, $30, $e3, $e5 + .byte $81, $91, $85, $bf, $4b, $d9, $cf, $80 + .byte $5f, $54, $36, $b5, $8a, $b0, $50, $d6 + .byte $38, $22, $3e, $c1, $01, $a6, $dd, $f5 + .byte $4b, $5e, $6b, $21 ;********************************** ; Now we have the secondary loader @@ -76,20 +76,12 @@ rloop: lda RCART0 ; read a byte from the cart jsr seclynxblock ; 3. Skip over the block offset - lda _FileBlockOffset - ldx _FileBlockOffset+1 - phx ; The BLL kit uses negative offsets - plx ; while the basic Lynx uses positive - bmi @1 ; Make all offsets negative + lda _FileBlockOffset+1 eor #$FF - pha - txa + tay + lda _FileBlockOffset eor #$FF - bra @2 -@1: pha - txa -@2: tay - plx + tax jsr seclynxskip0 ; 4. Read in the main exe to RAM @@ -97,20 +89,12 @@ rloop: lda RCART0 ; read a byte from the cart ldx _FileDestAddr+1 sta _FileDestPtr stx _FileDestPtr+1 - lda _FileFileLen - ldx _FileFileLen+1 - phx ; The BLL kit uses negative counts - plx ; while the basic Lynx uses positive - bmi @3 ; make all counts negative + lda _FileFileLen+1 eor #$FF - pha - txa + tay + lda _FileFileLen eor #$FF - bra @4 -@3: pha - txa -@4: tay - plx + tax jsr seclynxread0 ; 5. Jump to start of the main exe code @@ -190,5 +174,6 @@ seclynxblock: pla exit: rts + .reloc diff --git a/libsrc/lynx/open.s b/libsrc/lynx/open.s index 88c8b8c8f..04ef2b68e 100644 --- a/libsrc/lynx/open.s +++ b/libsrc/lynx/open.s @@ -122,20 +122,12 @@ flagsok: lda _FileStartBlock sta _FileCurrBlock jsr lynxblock - lda _FileBlockOffset - ldx _FileBlockOffset+1 - phx ; The BLL kit uses negative offsets - plx ; while tha basic Lynx uses positive - bmi @1 ; Make all offsets negative + lda _FileBlockOffset+1 eor #$FF - pha - txa + tay + lda _FileBlockOffset eor #$FF - bra @2 -@1: pha - txa -@2: tay - plx + tax jsr lynxskip0 jsr stax0sp jmp incsp8 diff --git a/libsrc/lynx/read.s b/libsrc/lynx/read.s index c461e378f..43bb27cba 100644 --- a/libsrc/lynx/read.s +++ b/libsrc/lynx/read.s @@ -8,8 +8,7 @@ ; reads bytes from a raw cart and does not understand the concept of files. ; So if you read over the end of file you get data from the next file. ; -; The count-parameter can be positive (Atari style) or negative (BLL style). -; In any case the read routine will work correctly. +; The count-parameter is positive (Atari style). ; ; int __fastcall__ read(int fd,void *buf,int count) ; @@ -30,18 +29,13 @@ sta _FileDestPtr stx _FileDestPtr+1 jsr ldax0sp - phx ; The BLL kit uses negative counts - plx ; while the basic Lynx uses positive - bmi @1 ; make all counts negative - eor #$FF pha - txa + txa + eor #$FF + tay + pla eor #$FF - bra @2 -@1: pha - txa -@2: tay - plx + tax jsr lynxread0 jsr ldax0sp jmp incsp6 diff --git a/src/ld65/cfg/lynx-bll.cfg b/src/ld65/cfg/lynx-bll.cfg index 0cb677c9c..468ed5e21 100644 --- a/src/ld65/cfg/lynx-bll.cfg +++ b/src/ld65/cfg/lynx-bll.cfg @@ -1,6 +1,6 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack - __STARTOFDIRECTORY__: type = weak, value = $00DF; # start just after loader + __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader __BLOCKSIZE__: type = weak, value = 1024; # cart block size __BLLHDR__: type = import; } diff --git a/src/ld65/cfg/lynx-coll.cfg b/src/ld65/cfg/lynx-coll.cfg index f1f35dfe1..b189936f1 100644 --- a/src/ld65/cfg/lynx-coll.cfg +++ b/src/ld65/cfg/lynx-coll.cfg @@ -1,6 +1,6 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack - __STARTOFDIRECTORY__: type = weak, value = $00DF; # start just after loader + __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader __BLOCKSIZE__: type = weak, value = 1024; # cart block size __EXEHDR__: type = import; __BOOTLDR__: type = import; diff --git a/src/ld65/cfg/lynx-uploader.cfg b/src/ld65/cfg/lynx-uploader.cfg index 96f43db4e..6a4796443 100644 --- a/src/ld65/cfg/lynx-uploader.cfg +++ b/src/ld65/cfg/lynx-uploader.cfg @@ -1,6 +1,6 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack - __STARTOFDIRECTORY__: type = weak, value = $00DF; # start just after loader + __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader __BLOCKSIZE__: type = weak, value = 1024; # cart block size __EXEHDR__: type = import; __BOOTLDR__: type = import; diff --git a/src/ld65/cfg/lynx.cfg b/src/ld65/cfg/lynx.cfg index 0fea7eb85..520a291d5 100644 --- a/src/ld65/cfg/lynx.cfg +++ b/src/ld65/cfg/lynx.cfg @@ -1,6 +1,6 @@ SYMBOLS { __STACKSIZE__: type = weak, value = $0800; # 2k stack - __STARTOFDIRECTORY__: type = weak, value = $00DF; # start just after loader + __STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader __BLOCKSIZE__: type = weak, value = 1024; # cart block size __EXEHDR__: type = import; __BOOTLDR__: type = import; -- 2.39.5