gr: plasma: work on effect

This commit is contained in:
Vince Weaver 2023-10-29 18:01:18 -04:00
parent 51ea424c74
commit c9afbb2443
9 changed files with 556 additions and 10 deletions

View File

@ -10,7 +10,7 @@ all: plasma.dsk
plasma.dsk: HELLO PLASMA PLASMA2 \
DIAMONDS STATIC STATIC_BOT \
PLASMA_128 PLASMA_TINY PLASMA_BOT WIRES WIRES_BOT \
SMALLCIRCS STAR OVAL OVAL_BOT
SMALLCIRCS STAR OVAL OVAL_BOT INTERFERENCE INTERFERENCE2
cp $(EMPTYDISK) plasma.dsk
$(DOS33) -y plasma.dsk SAVE A HELLO
$(DOS33) -y plasma.dsk BSAVE -a 0x70 PLASMA
@ -26,6 +26,8 @@ plasma.dsk: HELLO PLASMA PLASMA2 \
$(DOS33) -y plasma.dsk BSAVE -a 0xc00 SMALLCIRCS
$(DOS33) -y plasma.dsk BSAVE -a 0xc00 STAR
$(DOS33) -y plasma.dsk BSAVE -a 0xc00 OVAL
$(DOS33) -y plasma.dsk BSAVE -a 0xc00 INTERFERENCE
$(DOS33) -y plasma.dsk BSAVE -a 0xc00 INTERFERENCE2
$(DOS33) -y plasma.dsk BSAVE -a 0x375 OVAL_BOT
###
@ -76,6 +78,23 @@ oval.o: oval.s
###
INTERFERENCE: interference.o
ld65 -o INTERFERENCE interference.o -C $(LINKERSCRIPTS)/apple2_c00.inc
interference.o: interference.s
ca65 -o interference.o interference.s -l interference.lst
###
INTERFERENCE2: interference2.o
ld65 -o INTERFERENCE2 interference2.o -C $(LINKERSCRIPTS)/apple2_c00.inc
interference2.o: interference2.s
ca65 -o interference2.o interference2.s -l interference2.lst
###
OVAL_BOT: oval_bot.o
ld65 -o OVAL_BOT oval_bot.o -C $(LINKERSCRIPTS)/apple2_375.inc

View File

@ -0,0 +1,55 @@
;================================
; plot_setup
;================================
; sets up GBASL/GBASH and MASK
; Ycoord in A
; trashes Y/A
plot_setup:
lsr ; shift bottom bit into carry ; 2
bcc plot_even ; 2nt/3
plot_odd:
ldy #$f0 ; 2
bcs plot_c_done ; 2nt/3
plot_even:
ldy #$0f ; 2
plot_c_done:
sty MASK ; 3
asl ; shift back (now even) ; 2
tay ; 2
lda gr_offsets,Y ; lookup low-res memory address ; 4
; clc ; 2
; adc XPOS ; 3
sta GBASL ; 3
lda gr_offsets+1,Y ; 4
clc
adc DRAW_PAGE ; add in draw page offset ; 3
sta GBASH ; 3
rts
;================================
; plot1
;================================
; plots pixel of COLOR at GBASL/GBASH:Y
; Xcoord in Y
plot1:
lda MASK ; 3
eor #$ff ; 2
and (GBASL),Y ; 5+
sta COLOR_MASK ; 3
lda COLOR ; 3
and MASK ; 3
ora COLOR_MASK ; 3
sta (GBASL),Y ; 6
rts ; 6

View File

@ -16,8 +16,8 @@ SET_GR = $C050
SET_TEXT = $C051
FULLGR = $C052
TEXTGR = $C053
PAGE0 = $C054
PAGE1 = $C055
PAGE1 = $C054
PAGE2 = $C055
LORES = $C056 ; Enable LORES graphics
HIRES = $C057 ; Enable HIRES graphics
AN3 = $C05E ; Annunciator 3

View File

@ -0,0 +1,194 @@
; Interference Pattern
.include "hardware.inc"
; zero page
GBASL = $26
GBASH = $27
MASK = $2E
COLOR = $30
;CTEMP = $68
YY = $69
COLOR_MASK=$F8
XPOS = $F9
YPOS = $FA
DRAW_PAGE=$FB
FRAME = $FC
SUM = $FD
SAVEX = $FE
SAVEY = $FF
;================================
; Clear screen and setup graphics
;================================
oval:
bit SET_GR
bit LORES
bit FULLGR ; make it 40x48
bit PAGE1
lda #0
sta DRAW_PAGE
draw_oval_loop:
inc FRAME ; increment frame
ldx #47 ; YY from 47 downto zero
create_yloop:
txa
jsr plot_setup
; stx YPOS
; txa
; jsr PLOT ; (Y,A) sets GBASL/GBASH, Y
; txa
; lsr
; tay
; lda gr_offsets_l,Y
; sta GBASL
; lda gr_offsets_h,Y
; sta GBASH
ldy #39
create_xloop:
; lda #128
lda FRAME
sta SUM
tya ; XX
jsr calcsine_div2
txa ; YY
jsr calcsine
; X (YY) is in SAVEX
clc
; sty SAVEY ; XX
tya
adc SAVEX ; XX + YY
jsr calcsine_div2
; clc
; adc FRAME
lsr ; double colors
and #$7 ; mask
tax
lda colorlookup,X
; jsr SETCOL
sta COLOR
txa
pha
tya
pha
jsr plot1
pla
tay
pla
tax
; jsr PLOT1 ; PLOT (GBASL),Y
ldx SAVEX
dey
bpl create_xloop
dex
bpl create_yloop
; X and Y both $FF
bmi draw_oval_loop
calcsine_div2:
lsr
calcsine:
stx SAVEX
and #$3f
tax
rol
rol
rol
bcc sinadd
sinsub:
lda #0
lda SUM
sec
sbc sinetable-32,X
jmp sindone
sinadd:
lda SUM
clc
adc sinetable,X
sindone:
sta SUM
ldx SAVEX
rts
colorlookup:
; pink
.byte $55,$11,$33,$bb,$ff,$bb,$55
.byte $00
sinetable:
; this is actually (32*sin(x))
.byte $00,$03,$06,$09,$0C,$0F,$11,$14
.byte $16,$18,$1A,$1C,$1D,$1E,$1F,$1F
.byte $20,$1F,$1F,$1E,$1D,$1C,$1A,$18
.byte $16,$14,$11,$0F,$0C,$09,$06,$03
;.byte $00,$FD,$FA,$F7,$F4,$F1,$EF,$EC
;.byte $EA,$E8,$E6,$E4,$E3,$E2,$E1,$E1
;.byte $E0,$E1,$E1,$E2,$E3,$E4,$E6,$E8
;.byte $EA,$EC,$EF,$F1,$F4,$F7,$FA,$FD
.if 0
gr_offsets_l:
.byte <$400,<$480,<$500,<$580,<$600,<$680,<$700,<$780
.byte <$428,<$4a8,<$528,<$5a8,<$628,<$6a8,<$728,<$7a8
.byte <$450,<$4d0,<$550,<$5d0,<$650,<$6d0,<$750,<$7d0
gr_offsets_h:
.byte >$400,>$480,>$500,>$580,>$600,>$680,>$700,>$780
.byte >$428,>$4a8,>$528,>$5a8,>$628,>$6a8,>$728,>$7a8
.byte >$450,>$4d0,>$550,>$5d0,>$650,>$6d0,>$750,>$7d0
.endif
.include "gr_plot.s"
.include "/home/vince/research/dos33fsprogs.git/demos/second/gr_offsets.s"

View File

@ -0,0 +1,251 @@
; Interference Pattern
.include "hardware.inc"
; zero page
COLOR = $30
YY = $69
COLOR_MASK=$F8
XPOS = $F9
YPOS = $FA
DRAW_PAGE=$FB
FRAME = $FC
SUM = $FD
SAVEX = $FE
SAVEY = $FF
;================================
; Clear screen and setup graphics
;================================
oval:
bit SET_GR
bit LORES
bit FULLGR ; make it 40x48
bit PAGE1
lda #4
sta DRAW_PAGE
draw_oval_loop:
inc FRAME ; increment frame
ldx #47 ; YY from 47 downto zero
create_yloop:
txa
jsr plot_setup
ldy #39
create_xloop:
; lda #128
lda FRAME
sta SUM
tya ; XX
jsr calcsine_div2
txa ; YY
jsr calcsine
; X (YY) is in SAVEX
clc
; sty SAVEY ; XX
tya
adc SAVEX ; XX + YY
jsr calcsine_div2
; clc
; adc FRAME
lsr ; double colors
and #$7 ; mask
tax
lda colorlookup,X
; jsr SETCOL
sta COLOR
txa
pha
tya
pha
jsr plot1
pla
tay
pla
tax
; jsr PLOT1 ; PLOT (GBASL),Y
ldx SAVEX
dey
bpl create_xloop
dex
bpl create_yloop
lda DRAW_PAGE
beq flip_to_2
bit PAGE2
lda #0
beq done_flip
flip_to_2:
bit PAGE1
lda #4
done_flip:
sta DRAW_PAGE
; X and Y both $FF
jmp draw_oval_loop ; bra
calcsine_div2:
lsr
calcsine:
stx SAVEX
and #$3f
tax
rol
rol
rol
bcc sinadd
sinsub:
lda #0
lda SUM
sec
sbc sinetable-32,X
jmp sindone
sinadd:
lda SUM
clc
adc sinetable,X
sindone:
sta SUM
ldx SAVEX
rts
colorlookup:
; pink
.byte $55,$11,$33,$bb,$ff,$bb,$55
.byte $00
sinetable:
; this is actually (32*sin(x))
.byte $00,$03,$06,$09,$0C,$0F,$11,$14
.byte $16,$18,$1A,$1C,$1D,$1E,$1F,$1F
.byte $20,$1F,$1F,$1E,$1D,$1C,$1A,$18
.byte $16,$14,$11,$0F,$0C,$09,$06,$03
;.byte $00,$FD,$FA,$F7,$F4,$F1,$EF,$EC
;.byte $EA,$E8,$E6,$E4,$E3,$E2,$E1,$E1
;.byte $E0,$E1,$E1,$E2,$E3,$E4,$E6,$E8
;.byte $EA,$EC,$EF,$F1,$F4,$F7,$FA,$FD
;================================
; plot_setup
;================================
; sets up GBASL/GBASH and MASK
; Ycoord in A
; trashes Y/A
plot_setup:
lsr ; shift bottom bit into carry ; 2
tay
bcc plot_even ; 2nt/3
plot_odd:
lda #$f0 ; 2
bcs plot_c_done ; 2nt/3
plot_even:
lda #$0f ; 2
plot_c_done:
sta mask_smc1+1 ;
sta mask_smc2+1 ;
lda gr_offsets_l,Y ; lookup low-res memory address ; 4
sta gbasl_smc1+1
sta gbasl_smc2+1
lda gr_offsets_h,Y ; 4
clc
adc DRAW_PAGE ; add in draw page offset ; 3
sta gbasl_smc1+2
sta gbasl_smc2+2
rts
;================================
; plot1
;================================
; plots pixel of COLOR at GBASL/GBASH:Y
; Xcoord in Y
plot1:
mask_smc1:
lda #$ff ; 2
eor #$ff ; 2
gbasl_smc1:
and $400,Y ; 4+
sta COLOR_MASK ; 3
lda COLOR ; 3
mask_smc2:
and #$FF ; 2
ora COLOR_MASK ; 3
gbasl_smc2:
sta $400,Y ; 5
rts ; 6
gr_offsets_l:
.byte <$400,<$480,<$500,<$580,<$600,<$680,<$700,<$780
.byte <$428,<$4a8,<$528,<$5a8,<$628,<$6a8,<$728,<$7a8
.byte <$450,<$4d0,<$550,<$5d0,<$650,<$6d0,<$750,<$7d0
gr_offsets_h:
.byte >$400,>$480,>$500,>$580,>$600,>$680,>$700,>$780
.byte >$428,>$4a8,>$528,>$5a8,>$628,>$6a8,>$728,>$7a8
.byte >$450,>$4d0,>$550,>$5d0,>$650,>$6d0,>$750,>$7d0

View File

@ -102,7 +102,7 @@ flip_pages:
beq done_page
inx
done_page:
ldy PAGE0,X ; set display page to PAGE1 or PAGE2
ldy PAGE1,X ; set display page to PAGE1 or PAGE2
eor #$4 ; flip draw page between $400/$800
sta draw_page_smc+1 ; DRAW_PAGE

View File

@ -104,7 +104,7 @@ flip_pages:
beq done_page
inx
done_page:
ldy PAGE0,X ; set display page to PAGE1 or PAGE2
ldy PAGE1,X ; set display page to PAGE1 or PAGE2
eor #$4 ; flip draw page between $400/$800
sta draw_page_smc+1 ; DRAW_PAGE

View File

@ -129,7 +129,7 @@ flip_pages:
beq done_page
inx
done_page:
ldy PAGE0,X ; set display page to PAGE1 or PAGE2
ldy PAGE1,X ; set display page to PAGE1 or PAGE2
eor #$4 ; flip draw page between $400/$800
sta draw_page_smc+1 ; DRAW_PAGE

View File

@ -46,12 +46,15 @@ tunnel:
jsr HGR2
lda #10
tunnel_again:
lda #0
sta RR
draw_next:
ldx RR
lda star_z,X
tax
lda radii,X
sta R
@ -126,6 +129,11 @@ store_D:
sta D
do_plots:
lda XX
and #$3
bne done2
; setup constants
lda XX
@ -186,6 +194,7 @@ xnoc:
bpl pos_loop
done2:
; IFY>=XTHEN4
lda YY
cmp XX
@ -196,13 +205,23 @@ done:
clc
adc #1
sta RR
stop:
cmp #250
beq stop
cmp #19
beq done_frame
; GOTO1
jmp draw_next
done_frame:
jsr HGR2
ldx #19
move_circles:
dec star_z,X
dex
bpl move_circles
jmp tunnel_again
radii:
.byte <4000, <3200, <1600, <1066, <800, <640, <533, <457
@ -237,3 +256,11 @@ radii:
.byte 13, 13, 13, 13, 13, 13, 13, 13
.byte 13, 13, 13, 13, 13, 13, 13, 12
.byte 12, 12, 12, 12, 12, 12, 12, 12
; num-stars = 20
star_z:
.byte 15,26,38,50,63,75,78,100,112,125,137
.byte 150,162,175,187,200,212,224,237