mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-06-20 17:29:28 +00:00
plasma: optimize
This commit is contained in:
parent
bb18191fd7
commit
2010c7b715
|
@ -6,10 +6,11 @@ LINKERSCRIPTS = ../../../linker_scripts
|
||||||
|
|
||||||
all: plasma.dsk
|
all: plasma.dsk
|
||||||
|
|
||||||
plasma.dsk: HELLO PLASMA
|
plasma.dsk: HELLO PLASMA PLASMA_TINY
|
||||||
cp empty.dsk plasma.dsk
|
cp empty.dsk plasma.dsk
|
||||||
$(DOS33) -y plasma.dsk SAVE A HELLO
|
$(DOS33) -y plasma.dsk SAVE A HELLO
|
||||||
$(DOS33) -y plasma.dsk BSAVE -a 0xC00 PLASMA
|
$(DOS33) -y plasma.dsk BSAVE -a 0xC00 PLASMA
|
||||||
|
$(DOS33) -y plasma.dsk BSAVE -a 0xC00 PLASMA_TINY
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
@ -26,5 +27,14 @@ plasma.o: plasma.s
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
PLASMA_TINY: plasma_tiny.o
|
||||||
|
ld65 -o PLASMA_TINY plasma_tiny.o -C $(LINKERSCRIPTS)/apple2_c00.inc
|
||||||
|
|
||||||
|
plasma_tiny.o: plasma_tiny.s
|
||||||
|
ca65 -o plasma_tiny.o plasma_tiny.s -l plasma_tiny.lst
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ *.o *.lst PLASMA
|
rm -f *~ *.o *.lst PLASMA
|
||||||
|
|
|
@ -40,10 +40,12 @@ NORMAL = $F273
|
||||||
;; MONITOR ROUTINES
|
;; MONITOR ROUTINES
|
||||||
|
|
||||||
PLOT = $F800 ;; PLOT AT Y,A
|
PLOT = $F800 ;; PLOT AT Y,A
|
||||||
|
PLOT1 = $F80E ;; PLOT at (GBASL),Y (need MASK to be $0f or $f0)
|
||||||
HLINE = $F819 ;; HLINE Y,$2C at A
|
HLINE = $F819 ;; HLINE Y,$2C at A
|
||||||
VLINE = $F828 ;; VLINE A,$2D at Y
|
VLINE = $F828 ;; VLINE A,$2D at Y
|
||||||
CLRSCR = $F832 ;; Clear low-res screen
|
CLRSCR = $F832 ;; Clear low-res screen
|
||||||
CLRTOP = $F836 ;; clear only top of low-res screen
|
CLRTOP = $F836 ;; clear only top of low-res screen
|
||||||
|
GBASCALC= $F847 ;; take Y coord in A, put address in GBASL/H ( a trashed, C clear)
|
||||||
SETCOL = $F864 ;; COLOR=A
|
SETCOL = $F864 ;; COLOR=A
|
||||||
ROM_TEXT2COPY = $F962 ;; iigs
|
ROM_TEXT2COPY = $F962 ;; iigs
|
||||||
SETTXT = $FB36
|
SETTXT = $FB36
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
; 129 -- run loop backwards
|
; 129 -- run loop backwards
|
||||||
; 128 -- set color ourselves
|
; 128 -- set color ourselves
|
||||||
; 127 -- overlap color lookup with sine table
|
; 127 -- overlap color lookup with sine table
|
||||||
|
; 119 -- forgot to comment out unused
|
||||||
|
|
||||||
|
; 149 -- add page flipping
|
||||||
|
; 144 -- optimize a bit
|
||||||
|
|
||||||
.include "zp.inc"
|
.include "zp.inc"
|
||||||
.include "hardware.inc"
|
.include "hardware.inc"
|
||||||
|
@ -24,11 +28,10 @@ SAVEY = $FF
|
||||||
;================================
|
;================================
|
||||||
|
|
||||||
jsr SETGR
|
jsr SETGR
|
||||||
|
bit FULLGR
|
||||||
|
|
||||||
lda #0
|
; lda #4
|
||||||
sta DISP_PAGE
|
; sta DRAW_PAGE
|
||||||
lda #4
|
|
||||||
sta DRAW_PAGE
|
|
||||||
|
|
||||||
;col = ( 8.0 + (sintable[xx&0xf])
|
;col = ( 8.0 + (sintable[xx&0xf])
|
||||||
; + 8.0 + (sintable[yy&0xf])
|
; + 8.0 + (sintable[yy&0xf])
|
||||||
|
@ -56,6 +59,7 @@ lookup_smc:
|
||||||
dey
|
dey
|
||||||
bpl create_yloop
|
bpl create_yloop
|
||||||
|
|
||||||
|
; X and Y both $FF
|
||||||
|
|
||||||
create_lookup_done:
|
create_lookup_done:
|
||||||
|
|
||||||
|
@ -64,7 +68,10 @@ forever_loop:
|
||||||
cycle_colors:
|
cycle_colors:
|
||||||
; cycle colors
|
; cycle colors
|
||||||
|
|
||||||
ldx #0
|
; X if $FF when arriving here
|
||||||
|
|
||||||
|
; ldx #0
|
||||||
|
inx ; make X 0
|
||||||
cycle_loop:
|
cycle_loop:
|
||||||
inc lookup,X
|
inc lookup,X
|
||||||
inx
|
inx
|
||||||
|
@ -73,19 +80,46 @@ cycle_loop:
|
||||||
|
|
||||||
plot_frame:
|
plot_frame:
|
||||||
|
|
||||||
|
; set which page
|
||||||
|
; flip page
|
||||||
|
|
||||||
|
; ldx #0 ; x already 0
|
||||||
|
lda DRAW_PAGE
|
||||||
|
beq done_page
|
||||||
|
inx
|
||||||
|
done_page:
|
||||||
|
ldy PAGE0,X
|
||||||
|
|
||||||
|
eor #$4
|
||||||
|
sta DRAW_PAGE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; plot frame
|
; plot frame
|
||||||
|
|
||||||
ldx #39 ; YY=0
|
ldx #47 ; YY=0
|
||||||
|
|
||||||
plot_yloop:
|
plot_yloop:
|
||||||
ldy #39 ; XX = 0
|
|
||||||
|
txa ; get (y&0xf)<<4
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
sta CTEMP
|
||||||
|
|
||||||
txa
|
txa
|
||||||
lsr
|
lsr
|
||||||
|
|
||||||
php
|
php
|
||||||
jsr GBASCALC ; point GBASL/H to address in A
|
jsr GBASCALC ; point GBASL/H to address in A
|
||||||
; after, A trashed, C is clear
|
; after, A is GBASL, C is clear
|
||||||
|
|
||||||
|
lda GBASH
|
||||||
|
adc DRAW_PAGE
|
||||||
|
sta GBASH
|
||||||
|
|
||||||
plp
|
plp
|
||||||
|
|
||||||
lda #$0f ; setup mask
|
lda #$0f ; setup mask
|
||||||
|
@ -95,21 +129,17 @@ plot_yloop:
|
||||||
plot_mask:
|
plot_mask:
|
||||||
sta MASK
|
sta MASK
|
||||||
|
|
||||||
|
;==========
|
||||||
|
|
||||||
|
ldy #39 ; XX = 39 (countdown)
|
||||||
|
|
||||||
plot_xloop:
|
plot_xloop:
|
||||||
|
|
||||||
stx SAVEX ; SAVE YY
|
stx SAVEX ; SAVE YY
|
||||||
|
|
||||||
tya ; get x&0xf
|
tya ; get x&0xf
|
||||||
and #$f
|
and #$f
|
||||||
sta CTEMP
|
ora CTEMP ; get ((y&0xf)*16)+x
|
||||||
|
|
||||||
txa ; get (y&0xf)<<4
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
asl
|
|
||||||
|
|
||||||
ora CTEMP ; get (y*15)+x
|
|
||||||
|
|
||||||
tax
|
tax
|
||||||
|
|
||||||
|
@ -140,7 +170,7 @@ plot_lookup_smc:
|
||||||
|
|
||||||
; iny
|
; iny
|
||||||
; cpy #40
|
; cpy #40
|
||||||
; bne plot_xloop
|
; bne plot_xlooph
|
||||||
|
|
||||||
; inx
|
; inx
|
||||||
; cpx #40
|
; cpx #40
|
||||||
|
|
176
graphics/gr/plasma/plasma_tiny.s
Normal file
176
graphics/gr/plasma/plasma_tiny.s
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
; do a (hopefully fast) plasma
|
||||||
|
|
||||||
|
; 151 -- original
|
||||||
|
; 137 -- optimize generation
|
||||||
|
; 136 -- align lookup table so we can index it easier
|
||||||
|
; 130 -- optimize indexing of lookup
|
||||||
|
; 126 -- run loops backaward
|
||||||
|
; 124 -- notice X already 0 before plot
|
||||||
|
; 131 -- use GBASCALC. much faster, but 7 bytes larger
|
||||||
|
; 129 -- run loop backwards
|
||||||
|
; 128 -- set color ourselves
|
||||||
|
; 127 -- overlap color lookup with sine table
|
||||||
|
; 119 -- forgot to comment out unused
|
||||||
|
; 121 -- make full screen
|
||||||
|
|
||||||
|
.include "zp.inc"
|
||||||
|
.include "hardware.inc"
|
||||||
|
|
||||||
|
CTEMP = $FC
|
||||||
|
SAVEOFF = $FD
|
||||||
|
SAVEX = $FE
|
||||||
|
SAVEY = $FF
|
||||||
|
|
||||||
|
;================================
|
||||||
|
; Clear screen and setup graphics
|
||||||
|
;================================
|
||||||
|
|
||||||
|
jsr SETGR
|
||||||
|
bit FULLGR ; full screen
|
||||||
|
|
||||||
|
; lda #0
|
||||||
|
; sta DISP_PAGE
|
||||||
|
; lda #4
|
||||||
|
; sta DRAW_PAGE
|
||||||
|
|
||||||
|
;col = ( 8.0 + (sintable[xx&0xf])
|
||||||
|
; + 8.0 + (sintable[yy&0xf])
|
||||||
|
; ) / 2;
|
||||||
|
|
||||||
|
create_lookup:
|
||||||
|
|
||||||
|
ldy #15
|
||||||
|
create_yloop:
|
||||||
|
ldx #15
|
||||||
|
create_xloop:
|
||||||
|
clc
|
||||||
|
lda #15
|
||||||
|
adc sinetable,X
|
||||||
|
adc sinetable,Y
|
||||||
|
lsr
|
||||||
|
lookup_smc:
|
||||||
|
sta lookup ; always starts at $d00
|
||||||
|
|
||||||
|
inc lookup_smc+1
|
||||||
|
|
||||||
|
dex
|
||||||
|
bpl create_xloop
|
||||||
|
|
||||||
|
dey
|
||||||
|
bpl create_yloop
|
||||||
|
|
||||||
|
|
||||||
|
create_lookup_done:
|
||||||
|
|
||||||
|
forever_loop:
|
||||||
|
|
||||||
|
cycle_colors:
|
||||||
|
; cycle colors
|
||||||
|
|
||||||
|
; X is $FF when arrive here
|
||||||
|
inx
|
||||||
|
|
||||||
|
; ldx #0
|
||||||
|
cycle_loop:
|
||||||
|
inc lookup,X
|
||||||
|
inx
|
||||||
|
bne cycle_loop
|
||||||
|
|
||||||
|
|
||||||
|
plot_frame:
|
||||||
|
|
||||||
|
; plot frame
|
||||||
|
|
||||||
|
ldx #47 ; YY=0
|
||||||
|
|
||||||
|
plot_yloop:
|
||||||
|
|
||||||
|
txa ; get (y&0xf)<<4
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
asl
|
||||||
|
sta CTEMP
|
||||||
|
|
||||||
|
txa
|
||||||
|
lsr
|
||||||
|
|
||||||
|
php
|
||||||
|
jsr GBASCALC ; point GBASL/H to address in A
|
||||||
|
; after, A trashed, C is clear
|
||||||
|
plp
|
||||||
|
|
||||||
|
lda #$0f ; setup mask
|
||||||
|
bcc plot_mask
|
||||||
|
adc #$e0
|
||||||
|
|
||||||
|
plot_mask:
|
||||||
|
sta MASK
|
||||||
|
|
||||||
|
;==========
|
||||||
|
|
||||||
|
ldy #39 ; XX = 39 (countdown)
|
||||||
|
|
||||||
|
plot_xloop:
|
||||||
|
|
||||||
|
stx SAVEX ; SAVE YY
|
||||||
|
|
||||||
|
tya ; get x&0xf
|
||||||
|
and #$f
|
||||||
|
ora CTEMP ; get ((y&0xf)*16)+x
|
||||||
|
|
||||||
|
tax
|
||||||
|
|
||||||
|
plot_lookup:
|
||||||
|
|
||||||
|
; sta plot_lookup_smc+1
|
||||||
|
|
||||||
|
plot_lookup_smc:
|
||||||
|
lda lookup,X ; load lookup, (y*16)+x
|
||||||
|
; lda lookup ; load lookup, (y*16)+x
|
||||||
|
|
||||||
|
and #$f
|
||||||
|
lsr
|
||||||
|
tax
|
||||||
|
lda colorlookup,X
|
||||||
|
sta COLOR
|
||||||
|
|
||||||
|
jsr PLOT1 ; plot at GBASL,Y (x co-ord in Y)
|
||||||
|
|
||||||
|
ldx SAVEX ; restore YY
|
||||||
|
|
||||||
|
dey
|
||||||
|
bpl plot_xloop
|
||||||
|
|
||||||
|
dex
|
||||||
|
bpl plot_yloop
|
||||||
|
bmi forever_loop
|
||||||
|
|
||||||
|
; iny
|
||||||
|
; cpy #40
|
||||||
|
; bne plot_xloop
|
||||||
|
|
||||||
|
; inx
|
||||||
|
; cpx #40
|
||||||
|
; bne plot_yloop
|
||||||
|
; beq forever_loop
|
||||||
|
|
||||||
|
|
||||||
|
colorlookup:
|
||||||
|
bw_color_lookup:
|
||||||
|
.byte $55,$22,$66,$77,$ff,$77,$55 ; ,$00 shared w sin table
|
||||||
|
|
||||||
|
sinetable:
|
||||||
|
.byte $00,$03,$05,$07,$08,$07,$05,$03
|
||||||
|
.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,$55,$77,$ff,$77,$66,$22,$55
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.org $d00
|
||||||
|
;.align $100
|
||||||
|
lookup:
|
Loading…
Reference in New Issue
Block a user