From cf0f503a4cf1eabf018fedc40daa1b9947b8bf6b Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 15 Oct 2021 18:57:06 -0400 Subject: [PATCH] static: ready for the bot --- basic/appleiibot/Makefile | 8 +- basic/appleiibot/static.bas | 2 + basic/fractals/Makefile | 7 +- basic/fractals/restrict.bas | 12 ++ graphics/gr/plasma/Makefile | 11 +- graphics/gr/plasma/static_bot.s | 251 ++++++++++++++++++++++++++++++++ linker_scripts/apple2_384.inc | 12 ++ 7 files changed, 300 insertions(+), 3 deletions(-) create mode 100644 basic/appleiibot/static.bas create mode 100644 basic/fractals/restrict.bas create mode 100644 graphics/gr/plasma/static_bot.s create mode 100644 linker_scripts/apple2_384.inc diff --git a/basic/appleiibot/Makefile b/basic/appleiibot/Makefile index 3a40840a..32e2f953 100644 --- a/basic/appleiibot/Makefile +++ b/basic/appleiibot/Makefile @@ -18,7 +18,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ XOR_ZOOM.BAS MOD9_HGR.BAS SIER_HGR.BAS MOVE.BAS SINE.BAS XDRAW128.BAS \ GATOR.BAS CURSOR.BAS STARGATE.BAS TUNNEL.BAS STARFIELD.BAS \ STAROOPS.BAS HGRSTARFIELD.BAS COOL_BOT.BAS WEB.BAS ORB.BAS \ - FIREWORKS.BAS THINKING.BAS ARCS.BAS WIRE_HGR.BAS + FIREWORKS.BAS THINKING.BAS ARCS.BAS WIRE_HGR.BAS STATIC.BAS # cp $(EMPTY_DISK)/empty.dsk appleiibot.dsk cp empty.dsk appleiibot.dsk @@ -97,6 +97,7 @@ appleiibot.dsk: E2.BAS FLAME.BAS FLAME2.BAS HELLO \ $(DOS33) -y appleiibot.dsk SAVE A THINKING.BAS $(DOS33) -y appleiibot.dsk SAVE A ARCS.BAS $(DOS33) -y appleiibot.dsk SAVE A WIRE_HGR.BAS + $(DOS33) -y appleiibot.dsk SAVE A STATIC.BAS #### @@ -480,6 +481,11 @@ WIRE_HGR.BAS: wire_hgr.bas #### +STATIC.BAS: static.bas + $(TOKENIZE) < static.bas > STATIC.BAS + +#### + RR.BAS: rr.bas $(TOKENIZE) < rr.bas > RR.BAS diff --git a/basic/appleiibot/static.bas b/basic/appleiibot/static.bas new file mode 100644 index 00000000..376f7807 --- /dev/null +++ b/basic/appleiibot/static.bas @@ -0,0 +1,2 @@ +1FORI=0TO115:POKE900+I,4*PEEK(2125+I)-204+(PEEK(2241+I/3)-35)/4^(I-INT(I/3)*3):NEXT +2&"/@q DRAGON_SMALL.BAS +#### + +RESTRICT.BAS: restrict.bas + $(TOKENIZE) < restrict.bas > RESTRICT.BAS #### diff --git a/basic/fractals/restrict.bas b/basic/fractals/restrict.bas new file mode 100644 index 00000000..3ce82e2c --- /dev/null +++ b/basic/fractals/restrict.bas @@ -0,0 +1,12 @@ +10 HGR2 +20 X=192*RND(1):Y=192*RND(1) +30 L=0:LL=0 +40 V=INT(4*RND(1)) +50 IF V=LL THEN 40 +60 X=X/2:Y=Y/2 +70 IF V<2 THEN X=X+96 +80 IF V=1 OR V=2 THEN Y=Y+96 +90 HPLOT 43+X,Y +100 LL=L:L=V+1 +110 IF L=4 THEN L=0 +120 GOTO 40 diff --git a/graphics/gr/plasma/Makefile b/graphics/gr/plasma/Makefile index db3e36f7..db33ab41 100644 --- a/graphics/gr/plasma/Makefile +++ b/graphics/gr/plasma/Makefile @@ -8,7 +8,7 @@ EMPTYDISK = ../../../empty_disk/empty.dsk all: plasma.dsk plasma.dsk: HELLO PLASMA PLASMA2 \ - DIAMONDS STATIC \ + DIAMONDS STATIC STATIC_BOT \ PLASMA_128 PLASMA_TINY PLASMA_BOT WIRES WIRES_BOT cp $(EMPTYDISK) plasma.dsk $(DOS33) -y plasma.dsk SAVE A HELLO @@ -21,6 +21,7 @@ plasma.dsk: HELLO PLASMA PLASMA2 \ $(DOS33) -y plasma.dsk BSAVE -a 0xc00 PLASMA2 $(DOS33) -y plasma.dsk BSAVE -a 0xc00 DIAMONDS $(DOS33) -y plasma.dsk BSAVE -a 0xc00 STATIC + $(DOS33) -y plasma.dsk BSAVE -a 0x384 STATIC_BOT ### @@ -60,6 +61,14 @@ STATIC: static.o static.o: static.s ca65 -o static.o static.s -l static.lst +### + +STATIC_BOT: static_bot.o + ld65 -o STATIC_BOT static_bot.o -C $(LINKERSCRIPTS)/apple2_384.inc + +static_bot.o: static_bot.s + ca65 -o static_bot.o static_bot.s -l static_bot.lst + ### diff --git a/graphics/gr/plasma/static_bot.s b/graphics/gr/plasma/static_bot.s new file mode 100644 index 00000000..1c568c4f --- /dev/null +++ b/graphics/gr/plasma/static_bot.s @@ -0,0 +1,251 @@ +; static + +; bring blue pages + +; by Vince `deater` Weaver (vince@deater.net) / dSr +; with some help from qkumba + +; zero page +GBASL = $26 +GBASH = $27 +MASK = $2E +COLOR = $30 +;CTEMP = $68 +YY = $69 + +FRAME = $FC +SUM = $FD +SAVEX = $FE +SAVEY = $FF + +; soft-switches +FULLGR = $C052 +PAGE1 = $C054 + +; ROM routines +PLOT = $F800 ;; PLOT AT Y,A +PLOT1 = $F80E ;; PLOT at (GBASL),Y (need MASK to be $0f or $f0) +GBASCALC= $F847 ;; take Y-coord/2 in A, put address in GBASL/H ( a trashed, C clear) +SETCOL = $F864 ;; COLOR=A*17 +SETGR = $FB40 + + + + ;================================ + ; Clear screen and setup graphics + ;================================ +static: + + jsr SETGR ; set lo-res 40x40 mode + bit FULLGR ; make it 40x48 + + + +draw_plasma: + ldx #39 +create_yloop: + ldy #47 +create_xloop: + lda #128 + sta SUM + txa + adc FRAME + jsr calcsine + + tya +; adc FRAME + jsr calcsine_div_2 + + clc + stx SAVEX + tya + adc SAVEX + jsr calcsine + + stx SAVEX + sty SAVEY + +; clc + adc FRAME + + and #$7 + tax + lda colorlookup,X + + jsr SETCOL + + + ldy SAVEX + lda SAVEY + + jsr PLOT ; PLOT Y,A + + ldx SAVEX + ldy SAVEY + + + dey + bpl create_xloop + + dex + bpl create_yloop + + ; X and Y both $FF + +create_lookup_done: + +forever_loop: + inc FRAME + + jmp draw_plasma +; jmp forever_loop + +.if 0 +cycle_colors: + + ; cycle colors + ; instead of advancing entire frame, do slightly slower route + ; instead now and just incrememnting the frame and doing the + ; adjustment at plot time. + + ; increment frame + + inc frame_smc+1 + + ; set/flip pages + ; we want to flip pages and then draw to the offscreen one + +flip_pages: + +; ldy #0 + +; iny ; y is $FF, make it 0 + + lda draw_page_smc+1 ; DRAW_PAGE + bne done_page + dey +done_page: +; ldx PAGE1,Y ; set display page to PAGE1 or PAGE2 + + ldx $BF56,Y ; PAGE1 - $FF + + eor #$4 ; flip draw page between $400/$800 + sta draw_page_smc+1 ; DRAW_PAGE + + + ; plot current frame + ; scan whole 40x48 screen and plot each point based on + ; lookup table colors +plot_frame: + + ldx #47 ; YY=47 (count backwards) +plot_yloop: + + txa ; get YY into A + pha ; save X for later + lsr ; call actually wants Ycoord/2 + + php ; save C flag for mask handling + + ; ugh can't use PLOT trick as it always will draw something + ; to PAGE1 even if we don't want to + + jsr GBASCALC ; point GBASL/H to address in (A is ycoord/2) + ; after, A is GBASL, C is clear + + lda GBASH ; adjust to be PAGE1/PAGE2 ($400 or $800) +draw_page_smc: + adc #0 + sta GBASH + + ; increment YY in top nibble of lookup for (yy<<16)+xx + ; clc from above, C always 0 + lda plot_lookup_smc+1 + adc #$10 ; no need to mask as it will oflo and be ignored + sta plot_lookup_smc+1 + + ;========== + + ldy #39 ; XX = 39 (countdown) + + ; sets MASK by calling into middle of PLOT routine + ; by Y being 39 draw in a spot that gets over-written + + plp + jsr $f806 + +plot_xloop: + + tya ; get XX & 0x0f + and #$f + tax + +plot_lookup_smc: + lda lookup,X ; load lookup, (YY*16)+XX + + clc +frame_smc: + adc #$00 ; add in frame + + and #$f + lsr ; we actually only have 8 colors + + tax + + lda colorlookup,X ; lookup color + + + sta COLOR ; each nibble should be same + + jsr PLOT1 ; plot at GBASL,Y (x co-ord goes in Y) + + dey + bpl plot_xloop + + pla ; restore YY + tax + dex + bpl plot_yloop + bmi forever_loop +.endif + + +calcsine_div_8: + lsr +calcsine_div_4: + lsr +calcsine_div_2: + lsr +calcsine: + stx SAVEX + and #$f + tax + lda sinetable,X + clc + adc SUM + sta SUM + ldx SAVEX + rts + + +colorlookup: + +; blue +.byte $55,$22,$66,$77,$ff,$77,$55,$00 + + + +sinetable: +; this is actually (32*sin(x)) +.byte $00,$0C,$16,$1D +.byte $20,$1D,$16,$0C +.byte $00,$F4,$EA,$E3 +.byte $E0,$E3,$EA,$F4 + +entry: + jmp static + + ; want this to be at 3f5 + ; Length is 116 so start at 384 + + diff --git a/linker_scripts/apple2_384.inc b/linker_scripts/apple2_384.inc new file mode 100644 index 00000000..e9b3fce5 --- /dev/null +++ b/linker_scripts/apple2_384.inc @@ -0,0 +1,12 @@ +MEMORY { + ZP: start = $00, size = $1A, type = rw; + RAM: start = $384, 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; +}