disk and tape loader

the loader is a small program with liblzg only, which loads data from
the snake.pack.lz (from either disk or tape), inflates the ram, and
starts the game
This commit is contained in:
giomba 2021-04-12 22:00:04 +02:00
parent 2f6a4e6735
commit a82c9e94fe
6 changed files with 85 additions and 13 deletions

View File

@ -3,17 +3,20 @@
ASM=$(wildcard src/*.asm) ASM=$(wildcard src/*.asm)
RES=res.bin/amour.sid res.bin/levels.bin res.bin/unlzg.bin RES=res.bin/amour.sid res.bin/levels.bin res.bin/unlzg.bin
.PHONY: debug env clean .PHONY: debug env clean all
bin/snake.bin: bin/snake.pack.lz all: bin/snake6502.bin bin/snake6502.d64
dasm src/cart.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f3 -sbuild/cart.symbols.txt -obin/snake.bin
#bin/tape.prg: bin/snake.pack.lz.file bin/snake6502.bin: bin/snake.pack.lz
# dasm src/tape.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -sbuild/tape.sybols.txt -obin/tape.prg dasm src/cart.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f3 -sbuild/cart.symbols.txt -obin/snake6502.bin
#bin/snake.pack.lz.file: bin/snake.pack.lz bin/snake6502.d64: bin/loader.prg
# echo -e "\x00\x80" > bin/snake.pack.lz.file c1541 -format "snake6502,01" d64 bin/snake6502.d64
# cat bin/snake.pack.lz >> bin/snake.pack.lz.file c1541 -attach bin/snake6502.d64 -write bin/loader.prg loader
c1541 -attach bin/snake6502.d64 -write bin/snake.pack.lz.prg packlz
bin/loader.prg: bin/snake.pack.lz.prg
dasm src/loader.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -sbuild/loader.sybols.txt -obin/loader.prg
bin/snake.prg: bin/snake.pack bin/snake.prg: bin/snake.pack
dasm src/prg.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -sbuild/prg.symbols.txt -obin/snake.prg dasm src/prg.asm -Isrc/ -DVERBOSE=$(VERBOSE) -f1 -sbuild/prg.symbols.txt -obin/snake.prg
@ -24,6 +27,10 @@ bin/snake.pack: env $(ASM) $(RES) bin/explodefont
bin/snake.pack.lz: bin/snake.pack liblzg/src/tools/lzg bin/snake.pack.lz: bin/snake.pack liblzg/src/tools/lzg
liblzg/src/tools/lzg bin/snake.pack > bin/snake.pack.lz liblzg/src/tools/lzg bin/snake.pack > bin/snake.pack.lz
bin/snake.pack.lz.prg: bin/snake.pack.lz
echo -n -e "\x00\x80" > bin/snake.pack.lz.prg
cat bin/snake.pack.lz >> bin/snake.pack.lz.prg
liblzg/src/tools/lzg: liblzg/src/tools/lzg:
cd liblzg/src && make cd liblzg/src && make

View File

@ -7,19 +7,20 @@
Current development status [here](https://git.giomba.it/giomba/snake6502). Current development status [here](https://git.giomba.it/giomba/snake6502).
## Download ## Download
* [.prg](dist/snake.prg) for tapes and disks (size not optimized, yet) * [.d64](dist/snake6502.d64) for floppy disks
* [.bin](dist/snake.bin) for 8KiB cartridges * [.bin](dist/snake6502.bin) for 8KiB cartridges
## Compile ## Compile
You need the GNU compiler collection and the [dasm](https://dasm-assembler.github.io/) macro assembler, then: You need the GNU compiler collection and the [dasm](https://dasm-assembler.github.io/) macro assembler, then:
``` ```
$ git submodule init
$ git submodule update
$ make $ make
``` ```
Interesting targets: Interesting targets:
* ```make bin/snake.bin``` produces .bin, ready to be burnt on an 8K EEPROM for making a cartridge (default) * ```make bin/snake6502.bin``` produces .bin, ready to be burnt on an 8K EEPROM for making a cartridge
* ```make bin/snake.prg``` produces .prg for the emulator, ready to be used on tape/disk * ```make bin/snake6502.d64``` produces .d64, ready to be used for floppy disks
* ```make tape/disk``` (fastloader, to be done)
You can also define the following environment variables: You can also define the following environment variables:
@ -27,6 +28,10 @@ You can also define the following environment variables:
```$ VERBOSE=1 make``` output useful info during compilation ```$ VERBOSE=1 make``` output useful info during compilation
## Tape
Copy ```loader.prg``` and ```packlz``` from disk to tape.
On a physical machine, you can use [disk2tape](https://git.giomba.it/giomba/cbmutil).
## Developer docs ## Developer docs
### Package ### Package
The whole program is assembled into a ```snake.pack``` binary blob with the following structure. The whole program is assembled into a ```snake.pack``` binary blob with the following structure.

BIN
dist/snake.prg vendored

Binary file not shown.

BIN
dist/snake6502.d64 vendored Normal file

Binary file not shown.

60
src/loader.asm Normal file
View File

@ -0,0 +1,60 @@
processor 6502
SEG.U
org $02
INCLUDE "zeropage.asm"
SEG autostart
org $801
autostartRoutine SUBROUTINE
; this is at $801
; and it MUST be exactly at this location in order to autostart
; 10 SYS2060 ($80c) BASIC autostart
BYTE #$0b,#$08,#$0a,#$00,#$9e,#$32,#$30,#$36,#$31,#$00,#$00,#$00
; this is at (2061 dec)=($80d)
; and it MUST be exactly after the above BASIC statement
. = $80d
; load pack from tape
lda #(packFileNameEnd - packFileName) ; filename length
ldx #<packFileName ; filename string address
ldy #>packFileName
jsr $ffbd ; setnam
lda #$01 ; file nr
ldx $ba ; last used device nr
ldy #$01 ; load to address stored in file
jsr $ffba ; setlfs
lda #$0 ; load to memory
jsr $ffd5 ; load
; address of input compressed data
lda #$00
sta srcPointer
lda #$80
sta srcPointer + 1
; address of output decompressed data
lda #$00
sta dstPointer
lda #$10
sta dstPointer + 1
jsr inflate
jmp $2800
; decompression util
INCLUDE "lzgmini.asm"
; DATA
; -------------------------------------
packFileName:
BYTE "PACKLZ"
packFileNameEnd:
#if VERBOSE = 1
ECHO "PRG SIZE:",(. - $801),"=",[(. - $801)d]
#endif