From fbc5c1fdb0d7987509749d9e3c46da62728017c6 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 9 Jan 2021 11:58:12 -0500 Subject: [PATCH] plasma: optimizing --- graphics/gr/plasma/Makefile | 6 +++--- graphics/gr/plasma/plasma.s | 31 ++++++++++++++++++------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/graphics/gr/plasma/Makefile b/graphics/gr/plasma/Makefile index adc30550..213b7608 100644 --- a/graphics/gr/plasma/Makefile +++ b/graphics/gr/plasma/Makefile @@ -9,7 +9,7 @@ all: plasma.dsk plasma.dsk: HELLO PLASMA cp empty.dsk plasma.dsk $(DOS33) -y plasma.dsk SAVE A HELLO - $(DOS33) -y plasma.dsk BSAVE -a 0x1000 PLASMA + $(DOS33) -y plasma.dsk BSAVE -a 0xC00 PLASMA ### @@ -19,9 +19,9 @@ HELLO: hello.bas ### PLASMA: plasma.o - ld65 -o PLASMA plasma.o -C $(LINKERSCRIPTS)/apple2_1000.inc + ld65 -o PLASMA plasma.o -C $(LINKERSCRIPTS)/apple2_c00.inc -plasma.o: plasma.s gr_plot.s gr_scrn.s +plasma.o: plasma.s ca65 -o plasma.o plasma.s -l plasma.lst ### diff --git a/graphics/gr/plasma/plasma.s b/graphics/gr/plasma/plasma.s index dba49c98..c37ca273 100644 --- a/graphics/gr/plasma/plasma.s +++ b/graphics/gr/plasma/plasma.s @@ -1,6 +1,7 @@ ; do a (hopefully fast) plasma -; 151 +; 151 -- original +; 137 -- optimize generation .include "zp.inc" .include "hardware.inc" @@ -22,34 +23,36 @@ SAVEY = $FF sta DRAW_PAGE ;col = ( 8.0 + (sintable[xx&0xf]) - ; + 8.0 + (sintable[yy&0xf]) - ; ) / 2; +; + 8.0 + (sintable[yy&0xf]) +; ) / 2; + ldy #0 + sty SAVEOFF create_yloop: ldx #0 create_xloop: +; lda SAVEOFF +; and #$f +; tax + clc lda #15 adc sinetable,X adc sinetable,Y lsr lookup_smc: + stx SAVEX + ldx SAVEOFF sta lookup,X + ldx SAVEX + inc SAVEOFF inx cpx #16 bne create_xloop - clc - lda lookup_smc+1 - adc #16 - sta lookup_smc+1 - lda #0 - adc lookup_smc+2 - sta lookup_smc+2 - iny cpy #16 bne create_yloop @@ -89,6 +92,7 @@ plot_xloop: tax lda lookup,X and #$f + lsr tax lda colorlookup,X @@ -116,7 +120,8 @@ sinetable: .byte $00,$FD,$FB,$F9,$F8,$F9,$FB,$FD colorlookup: -.byte $00,$00,$05,$05,$07,$07,$0f,$0f -.byte $07,$07,$06,$06,$02,$02,$05,$05 +;.byte $00,$00,$05,$05,$07,$07,$0f,$0f +;.byte $07,$07,$06,$06,$02,$02,$05,$05 +.byte $00,$05,$07,$0f,$07,$06,$02,$05 lookup: