diff --git a/Makefile b/Makefile index 3cdc012..277240d 100644 --- a/Makefile +++ b/Makefile @@ -21,9 +21,9 @@ all: loader $(PGM) $(PGM): - @PATH=$(PATH):/usr/local/bin; $(CL65) -t apple2enh --cpu 65816 --start-addr $(ADDR) -l$(PGM).lst $(PGM).s + @PATH=$(PATH):/usr/local/bin; $(CL65) -t apple2enh --cpu 65816 --start-addr 0000 -l$(PGM).lst $(PGM).s java -jar $(AC) -d $(PGM).2mg CODEBANK - java -jar $(AC) -p $(PGM).2mg CODEBANK BIN 0x$(ADDR) < $(PGM) + java -jar $(AC) -p $(PGM).2mg CODEBANK BIN 0x0000 < $(PGM) java -jar $(AC) -d $(PGM).2mg SPRITEBANK00 java -jar $(AC) -p $(PGM).2mg SPRITEBANK00 BIN 0x0000 < Art/spritebank00.bin rm -f $(PGM) diff --git a/gscats.2mg b/gscats.2mg index 276262f..28acd5b 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/gscats.s b/gscats.s index 2c9bee2..2f6cc71 100644 --- a/gscats.s +++ b/gscats.s @@ -8,7 +8,7 @@ .include "macros.s" .include "equates.s" -.org $800 +.org $0000 mainBank2: diff --git a/loader.s b/loader.s index b6df619..a292842 100644 --- a/loader.s +++ b/loader.s @@ -11,7 +11,7 @@ LOADBUFFER = $1000 ; Clear of this loader code BUFFERSIZE = $8200 ; About max size we can fit between buffer and this loader code -MAINENTRY = $020800 +MAINENTRY = $020000 .org $800 @@ -27,29 +27,46 @@ main: ; Load the code into bank 0 jsr PRODOS .byte $ca - .addr fileReadCode + .addr fileRead bne ioError ; Close the file jsr PRODOS .byte $cc - .addr fileCloseCode + .addr fileClose NATIVE ; Copy code into bank 2 -mainCopyStart: - ldx #0 + ldx fileReadLen + lda #2 + jsr copyBytes -mainCopyLoop: - lda LOADBUFFER,x + EMULATION -mainCopyDest: - sta MAINENTRY,x - inx - inx - cpx #LOADBUFFER+BUFFERSIZE - bne mainCopyLoop + ; Open the sprite bank file + jsr PRODOS + .byte $c8 + .addr fileOpenSprites + bne ioError + + ; Load the compiled sprites into bank 0 + jsr PRODOS + .byte $ca + .addr fileRead + bne ioError + + ; Close the file + jsr PRODOS + .byte $cc + .addr fileClose + + NATIVE + + ; Copy sprites into bank 3 + ldx fileReadLen + lda #3 + jsr copyBytes ; Set up a long jump into bank 2, and ; a way for game code to get back here to exit @@ -66,6 +83,37 @@ returnToProDOS: ioError: brk + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; copyBytes +; Copy data from read buffer in bank 0 to +; bottom of any other bank. Must be in native mode. +; +; X = Length of data in bytes +; A = Bank number of destination +; +copyBytes: + phx + BITS8 + sta copyBytesDest+3 + BITS16 + plx + dex + dex + +copyBytesLoop: + lda LOADBUFFER,x + +copyBytesDest: + sta $010000,x + dex + dex + bpl copyBytesLoop + rts + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + fileOpenCode: .byte 3 .addr codePath @@ -73,16 +121,26 @@ fileOpenCode: .byte 0 ; Result (file handle) .byte 0 ; Padding -fileReadCode: +fileRead: .byte 4 .byte 1 ; File handle (we know it's gonna be 1) .addr LOADBUFFER .word BUFFERSIZE +fileReadLen: .word 0 ; Result (bytes read) -fileCloseCode: +fileClose: .byte 1 .byte 1 ; File handle (we know it's gonna be 1) +fileOpenSprites: + .byte 3 + .addr spritePath + .addr $9200 ; 1k below BASIC.SYSTEM + .byte 0 ; Result (file handle) + .byte 0 ; Padding + codePath: pstring "/GSAPP/CODEBANK" +spritePath: + pstring "/GSAPP/SPRITEBANK00"