From a04cc7824ffeee0175f3d53b8aff34d5cbebbe63 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 8 Jun 2021 13:43:01 -0400 Subject: [PATCH] gr: tunnel: managed to get it to fit had to RLE compress the division lookup table --- basic/appleiibot/Makefile | 14 +++- basic/appleiibot/{weird.bas => stargate.bas} | 0 basic/appleiibot/tunnel.bas | 2 + graphics/gr/tunnel/Makefile | 4 +- graphics/gr/tunnel/t.s | 77 +++++++++++++++----- linker_scripts/apple2_36b.inc | 12 +++ 6 files changed, 86 insertions(+), 23 deletions(-) rename basic/appleiibot/{weird.bas => stargate.bas} (100%) create mode 100644 basic/appleiibot/tunnel.bas create mode 100644 linker_scripts/apple2_36b.inc diff --git a/basic/appleiibot/Makefile b/basic/appleiibot/Makefile index 57a1272b..85ebdad2 100644 --- a/basic/appleiibot/Makefile +++ b/basic/appleiibot/Makefile @@ -16,7 +16,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ C64.BAS SIERPINSKI.BAS FAKES.BAS SIER.BAS DROPS.BAS RR.BAS RR_HGR.BAS \ COMBO.BAS WIRES.BAS PATTERN.BAS BALL.BAS LINES.BAS MOD9.BAS \ XOR_ZOOM.BAS MOD9_HGR.BAS SIER_HGR.BAS MOVE.BAS SINE.BAS XDRAW128.BAS \ - GATOR.BAS CURSOR.BAS WEIRD.BAS + GATOR.BAS CURSOR.BAS STARGATE.BAS TUNNEL.BAS # cp $(EMPTY_DISK)/empty.dsk appleiibot.dsk cp empty.dsk appleiibot.dsk @@ -83,7 +83,8 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ $(DOS33) -y appleiibot.dsk SAVE A XDRAW128.BAS $(DOS33) -y appleiibot.dsk SAVE A GATOR.BAS $(DOS33) -y appleiibot.dsk SAVE A CURSOR.BAS - $(DOS33) -y appleiibot.dsk SAVE A WEIRD.BAS + $(DOS33) -y appleiibot.dsk SAVE A STARGATE.BAS + $(DOS33) -y appleiibot.dsk SAVE A TUNNEL.BAS #### @@ -259,8 +260,13 @@ CURSOR.BAS: cursor.bas #### -WEIRD.BAS: weird.bas - $(TOKENIZE) < weird.bas > WEIRD.BAS +STARGATE.BAS: stargate.bas + $(TOKENIZE) < stargate.bas > STARGATE.BAS + +#### + +TUNNEL.BAS: tunnel.bas + $(TOKENIZE) < tunnel.bas > TUNNEL.BAS diff --git a/basic/appleiibot/weird.bas b/basic/appleiibot/stargate.bas similarity index 100% rename from basic/appleiibot/weird.bas rename to basic/appleiibot/stargate.bas diff --git a/basic/appleiibot/tunnel.bas b/basic/appleiibot/tunnel.bas new file mode 100644 index 00000000..3aff199e --- /dev/null +++ b/basic/appleiibot/tunnel.bas @@ -0,0 +1,2 @@ +1FORI=0TO140:POKE875+I,4*PEEK(2125+I)-192+(PEEK(2266+I/3)-35)/4^(I-INT(I/3)*3):NEXT +2&",=nQYh$i4571RHBF4fP0\6hnC3QoZRQ;Q-NnbmYaFo8InNlR76nRmYk76lRZVn8:nYbVn8:n^e4Z[aj3[7XXQSRKML@FFDCA0:;8904G0SIVWC=#K/[<)HH=E04#=@##\AX#O'?3+0#W#SK5788M&a0_ diff --git a/graphics/gr/tunnel/Makefile b/graphics/gr/tunnel/Makefile index 868c3bd7..733028b6 100644 --- a/graphics/gr/tunnel/Makefile +++ b/graphics/gr/tunnel/Makefile @@ -17,7 +17,7 @@ tunnel.dsk: $(DOS33) HELLO TUNNEL.BAS TUNNEL TUNNEL2 STARGATE T.BAS T $(DOS33) -y tunnel.dsk SAVE A HELLO $(DOS33) -y tunnel.dsk SAVE A TUNNEL.BAS $(DOS33) -y tunnel.dsk SAVE A T.BAS - $(DOS33) -y tunnel.dsk BSAVE -a 0xc00 T + $(DOS33) -y tunnel.dsk BSAVE -a 0x36B T $(DOS33) -y tunnel.dsk BSAVE -a 0xc00 TUNNEL $(DOS33) -y tunnel.dsk BSAVE -a 0xc00 TUNNEL2 $(DOS33) -y tunnel.dsk BSAVE -a 0x37c STARGATE @@ -50,7 +50,7 @@ tunnel.o: tunnel.s ### T: t.o - ld65 -o T t.o -C $(LINKERSCRIPTS)/apple2_c00.inc + ld65 -o T t.o -C $(LINKERSCRIPTS)/apple2_36b.inc t.o: t.s ca65 -o t.o t.s -l t.lst diff --git a/graphics/gr/tunnel/t.s b/graphics/gr/tunnel/t.s index d4751e72..e94bec12 100644 --- a/graphics/gr/tunnel/t.s +++ b/graphics/gr/tunnel/t.s @@ -5,6 +5,9 @@ ; 167 bytes -- unnecessary clc ; 163 bytes -- no need to init color at beginning ; 154 bytes -- optimize some calculations +; 144 bytes -- compress lookup table +; 142 bytes -- convert jmp to bne/bmi +; 141 bytes -- start X at $D0 H2 = $2C V2 = $2D @@ -29,11 +32,41 @@ SETCOL = $F864 ; COLOR=A SETGR = $FB40 WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us +lookup = $80 + tunnel: ; 1 GR:N=23 jsr SETGR + ; A is now $D0 + +uncompress_table: + + tax + +; ldx #0 +uncompress_loop: + lda lookup_compressed + beq uncompress_done + pha + and #$7 + tay + pla + lsr + lsr + lsr +store_loop: + sta <(lookup-$D0),X ; horrible hack to save a byte + inx + dey + bne store_loop + inc uncompress_loop+1 ; assume doesn't cross page boundary + bne uncompress_loop ; assume it was never 0 + + +uncompress_done: + .if 0 make_table: lda #$2 @@ -77,6 +110,10 @@ qqloop: forq: + ; wrapping 255 to 0 is OK + inc NEWCOLOR ; moved from end to improve looping + + lda #6 sta Q @@ -91,11 +128,11 @@ fori: tax ; X is 0 iloop: - lda Q + lda P asl asl asl - ora P + ora Q tay txa @@ -168,28 +205,30 @@ blah: dec Q bpl qloop - inc NEWCOLOR - - ; wrapping 255 to 0 is OK - end: ; 8 GOTO 2 - jmp forq + bmi forq + + + + +lookup_compressed: +.byte 20<<3+1,19<<3+1,18<<3+1,17<<3+1,16<<3+1,15<<3+1,14<<3+1 +.byte 13<<3+2,12<<3+2,11<<3+2,10<<3+3, 9<<3+4, 8<<3+4, 7<<3+6 +.byte 6<<3+7, 5<<3+7, 5<<3+5, 4<<3+7, 0 ; 0 DIM A(9,9):FOR I=0 TO 8:FOR J=0 TO 8:A(I,J)=40/(2+I+J/7):NEXTJ,I -lookup: +;lookup: - - -.byte 20,13,10,8,7,6,5,4 ; 2.0 3.0 4,0 5,0 6.0 7.0 8.0 9.0 -.byte 19,13,10,8,7,6,5,4 ; 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 -.byte 18,12,9,8,6,5,5,4 -.byte 17,12,9,7,6,5,5,4 -.byte 16,11,9,7,6,5,5,4 -.byte 15,11,9,7,6,5,5,4 -.byte 14,10,8,7,6,5,5,4 +;.byte 20,13,10,8,7,6,5,4 ; 2.0 3.0 4,0 5,0 6.0 7.0 8.0 9.0 +;.byte 19,13,10,8,7,6,5,4 ; 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 +;.byte 18,12,9,8,6,5,5,4 +;.byte 17,12,9,7,6,5,5,4 +;.byte 16,11,9,7,6,5,5,4 +;.byte 15,11,9,7,6,5,5,4 +;.byte 14,10,8,7,6,5,5,4 @@ -214,4 +253,8 @@ lookup: ; need for bot + ; want this to live at $3F5 + ; originally at 38A, so load at $36B + jmp tunnel + diff --git a/linker_scripts/apple2_36b.inc b/linker_scripts/apple2_36b.inc new file mode 100644 index 00000000..2032069c --- /dev/null +++ b/linker_scripts/apple2_36b.inc @@ -0,0 +1,12 @@ +MEMORY { + ZP: start = $00, size = $1A, type = rw; + RAM: start = $36b, size = $8E00, file = %O; +} + +SEGMENTS { +CODE: load = RAM, type = ro; +RODATA: load = RAM, type = ro; +DATA: load = RAM, type = rw; +BSS: load = RAM, type = bss, define = yes; +ZEROPAGE: load = ZP, type = zp; +}