diff --git a/Makefile b/Makefile index e20f1ae..2262520 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CPSPRITES = apple-sprite9x11.png moldy_burger.png TOHGR = tohgr A2 = build-apple2/ -all: build-apple2 working.dsk demo.dsk +all: working.dsk demo.dsk build-apple2: mkdir build-apple2 @@ -30,32 +30,41 @@ $(A2)title.hgr: title.png asmgen.py -i bw $(A2)title-bot.png asmgen.py --merge 136 167 -o $(A2)title $(A2)title-top.hgr $(A2)title-bot.hgr +$(A2)title.s: $(A2)title.hgr + # use legacy block format + lz4 -9lf $(A2)title.hgr $(A2)title.lz4 + # strip first 8 bytes (start at byte 9 when counting from 1) + tail -c +9 $(A2)title.lz4 > $(A2)title.lz4-payload + asmgen.py -a mac65 --src $(A2)title.lz4-payload -n title > $(A2)title.s + $(A2)working-sprite-driver.s: $(SPRITES) fatfont128.dat asmgen.py -a mac65 -p 6502 -s hgrbw --scroll 4 -m -k -d -g -f fatfont128.dat -o $(A2)working $(SPRITES) -$(A2)working.xex: wipes-null.s main.s constants.s rand.s maze.s $(A2)working-sprite-driver.s vars.s debug.s actors.s background.s logic.s platform-apple2.s +$(A2)working.xex: wipes-null.s main.s constants.s rand.s maze.s $(A2)working-sprite-driver.s $(A2)title.s vars.s debug.s actors.s background.s logic.s platform-apple2.s lz4.s rm -f $(A2)working.xex echo '.include "main.s"' > $(A2)working.s echo '.include "wipes-null.s"' >> $(A2)working.s echo '.include "platform-apple2.s"' >> $(A2)working.s echo '.include "$(A2)working-sprite-driver.s"' >> $(A2)working.s + echo '.include "$(A2)title.s"' >> $(A2)working.s atasm -mae -o$(A2)working.xex $(A2)working.s -L$(A2)working.var -g$(A2)working.lst -working.dsk: $(A2)working.xex +working.dsk: build-apple2 $(A2)working.xex rm -f working.dsk atrcopy working.dsk boot -b $(A2)working.xex --brun 6000 -f #cp $(A2)working.var /home/rob/.wine/drive_c/applewin/APPLE2E.SYM -$(A2)demo.xex: wipes-demo.s main.s constants.s rand.s maze.s $(A2)working-sprite-driver.s vars.s debug.s actors.s background.s logic.s platform-apple2.s +$(A2)demo.xex: wipes-demo.s main.s constants.s rand.s maze.s $(A2)working-sprite-driver.s vars.s debug.s actors.s background.s logic.s platform-apple2.s lz4.s rm -f $(A2)demo.xex echo '.include "main.s"' > $(A2)demo.s echo '.include "wipes-demo.s"' >> $(A2)demo.s echo '.include "platform-apple2.s"' >> $(A2)demo.s echo '.include "$(A2)working-sprite-driver.s"' >> $(A2)demo.s + echo '.include "$(A2)title.s"' >> $(A2)demo.s atasm -mae -o$(A2)demo.xex $(A2)demo.s -L$(A2)demo.var -g$(A2)demo.lst -demo.dsk: $(A2)demo.xex $(A2)player-missile.hgr $(A2)player-missile-2.hgr $(A2)kansasfest-hackfest.hgr $(A2)title.hgr - atrcopy demo.dsk boot -d $(A2)player-missile.hgr@2000 $(A2)player-missile-2.hgr@4000 $(A2)kansasfest-hackfest.hgr@2000 $(A2)title.hgr@4001 -b $(A2)demo.xex --brun 6000 -f +demo.dsk: build-apple2 $(A2)demo.xex $(A2)player-missile.hgr $(A2)player-missile-2.hgr $(A2)kansasfest-hackfest.hgr $(A2)title.hgr + atrcopy demo.dsk boot -d $(A2)player-missile.hgr@2000 $(A2)player-missile-2.hgr@4000 $(A2)kansasfest-hackfest.hgr@2000 -b $(A2)demo.xex --brun 6000 -f clean: rm -rf $(A2) diff --git a/lz4.s b/lz4.s new file mode 100644 index 0000000..035b4d6 --- /dev/null +++ b/lz4.s @@ -0,0 +1,109 @@ +;LZ4 data decompressor for Apple II +;Peter Ferrie (peter.ferrie@gmail.com) +; +;from http://pferrie.host22.com/misc/appleii.htm +;Converted to ATasm by Rob McMullen + +;unpacker variables, set in main.s +; src = $0 ; source packed data +; dst = $2 ; destination unpacked data +; end = $4 ; end of source packed data +; count = $6 ; temporary variable +; delta = $8 ; temporary variable + +unpack_lz4 ldy #0 + +parsetoken + jsr getsrc + pha + lsr + lsr + lsr + lsr + beq copymatches + jsr buildcount + tax + jsr docopy + lda src + cmp end + lda src+1 + sbc end+1 + bcs done + +copymatches + jsr getsrc + sta delta + jsr getsrc + sta delta+1 + pla + and #$0f + jsr buildcount + clc + adc #4 + tax + bcc ?1 + inc count+1 +?1 lda src+1 + pha + lda src + pha + sec + lda dst + sbc delta + sta src + lda dst+1 + sbc delta+1 + sta src+1 + jsr docopy + pla + sta src + pla + sta src+1 + jmp parsetoken + +done + pla + rts + +docopy + jsr getput + dex + bne docopy + dec count+1 + bne docopy + rts + +buildcount + ldx #1 + stx count+1 + cmp #$0f + bne ?3 +?1 sta count + jsr getsrc + tax + clc + adc count + bcc ?2 + inc count+1 +?2 inx + beq ?1 +?3 rts + +getput + jsr getsrc + +putdst + sta (dst), y + inc dst + beq ?1 + rts +?1 inc dst+1 + rts + +getsrc + lda (src), y + inc src + beq ?1 + rts +?1 inc src+1 + rts diff --git a/main.s b/main.s index a28f35f..7f890e5 100644 --- a/main.s +++ b/main.s @@ -45,6 +45,11 @@ tdamageindex .ds 1 tdamageindex1 .ds 1 tdamageindex2 .ds 1 damagestart .ds 1 +src .ds 2 ; decompression usage +dst .ds 2 +end .ds 2 +count .ds 2 +delta .ds 2 *= $0040 ; global variables for this program @@ -111,6 +116,20 @@ frame_count .ds 2 start jsr set_hires ; start with HGR page 1, full screen + lda #TITLE_START + sta src+1 + lda #TITLE_END + sta end+1 + lda #0 + sta dst + lda #$40 + sta dst+1 + jsr unpack_lz4 + ;jsr clrscr jsr init_once @@ -290,3 +309,4 @@ handle_player nop .include "logic.s" .include "background.s" .include "debug.s" +.include "lz4.s"