hgr: thick lines

This commit is contained in:
Vince Weaver 2021-11-23 23:52:19 -05:00
parent a25a133d6d
commit 21d3c1b289
3 changed files with 167 additions and 8 deletions

View File

@ -8,10 +8,11 @@ EMPTYDISK = ../../../empty_disk/empty.dsk
all: plasma_hgr.dsk
plasma_hgr.dsk: HELLO OVAL PURPLE_WAVES ZEBRA JAWS TWIST OVAL_FLIP MOVING \
MIRROR THICK_SINE
MIRROR THICK_SINE THICK_LINES
cp $(EMPTYDISK) plasma_hgr.dsk
$(DOS33) -y plasma_hgr.dsk SAVE A HELLO
$(DOS33) -y plasma_hgr.dsk BSAVE -a 0x3F5 THICK_SINE
$(DOS33) -y plasma_hgr.dsk BSAVE -a 0x3F5 THICK_LINES
$(DOS33) -y plasma_hgr.dsk BSAVE -a 0xc00 OVAL
$(DOS33) -y plasma_hgr.dsk BSAVE -a 0xc00 PURPLE_WAVES
$(DOS33) -y plasma_hgr.dsk BSAVE -a 0xc00 ZEBRA
@ -52,6 +53,14 @@ thick_sine.o: thick_sine.s
###
THICK_LINES: thick_lines.o
ld65 -o THICK_LINES thick_lines.o -C $(LINKERSCRIPTS)/apple2_3f5.inc
thick_lines.o: thick_lines.s
ca65 -o thick_lines.o thick_lines.s -l thick_lines.lst
###
MOVING: moving.o
ld65 -o MOVING moving.o -C $(LINKERSCRIPTS)/apple2_3f5.inc
@ -106,5 +115,5 @@ purple_waves.o: purple_waves.s
clean:
rm -f *~ *.o *.lst OVAL PURPLE_WAVES ZEBRA JAWS TWIST OVAL_FLIP \
THICK_SINE
THICK_SINE THICK_LINES

View File

@ -0,0 +1,138 @@
; thick lines
; zero page
GBASL = $26
GBASH = $27
YY = $69
ROW_SUM = $70
HGR_X = $E0
HGR_XH = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_PAGE = $E6
FRAME = $FC
SUM = $FD
SAVEX = $FE
SAVEY = $FF
; soft-switches
FULLGR = $C052
PAGE1 = $C054
; ROM routines
HGR2 = $F3D8
HPOSN = $F411 ; (Y,X),(A) (values stores in HGRX,XH,Y)
HPLOT0 = $F457 ; plot at (Y,X), (A)
;================================
; Clear screen and setup graphics
;================================
thick_sine:
jsr HGR2 ; set hi-res 140x192, page2, fullscreen
; A and Y both 0 at end
;==================
; create sinetable
;ldy #0 ; Y is 0
sinetable_loop:
tya ; 2
and #$3f ; wrap sine at 63 entries ; 2
cmp #$20
php ; save pos/negative for later
and #$1f
cmp #$10
bcc sin_left ; blt
sin_right:
; sec carry should be set here
eor #$FF
adc #$20 ; 32-X
sin_left:
tax
lda sinetable_base,X ; 4+
plp
bcc sin_done
sin_negate:
; carry set here
eor #$ff
adc #0 ; FIXME: this makes things off by 1
sin_done:
sta sinetable,Y
iny
bne sinetable_loop
; Y is 0 at this point?
;============================
; main loop
;============================
dey
sty HGR_COLOR ; required
; though in emulator it defaults to $FF
draw_circle:
ldy #0
sty SAVEY
blah_smc:
ldx #0
stx SAVEX
circle_loop:
ldx SAVEX
lda sinetable,X
; clc
asl
; $60 is midscreen
adc #$60
ldx SAVEY
ldy #0
jsr HPLOT0 ; plot at (Y,X), (A)
inc SAVEX
inc SAVEY
bne circle_loop
done:
inc blah_smc+1
lda SAVEX
and #$3f
cmp #$3f
bne blah
lda HGR_COLOR
eor #$ff
sta HGR_COLOR
blah:
jmp draw_circle
;sinetable_base:
; this is actually (32*sin(x))
; for bot
; 3F5 - 7d = 378
; jmp oval
sinetable=$6000
sinetable_base=$F5BA

View File

@ -1,5 +1,9 @@
; thick sine
; TODO: could we get this down to 64 bytes?
; put the sine table in the zero page?
; only generate 64 bytes of sine?
; zero page
GBASL = $26
@ -73,27 +77,33 @@ sin_done:
iny
bne sinetable_loop
; Y is 0 at this point?
;============================
; main loop
;============================
dey
sty HGR_COLOR ; required
; though in emulator it defaults to $FF
draw_circle:
ldy #0
sty SAVEY
blah_smc:
ldx #0
stx SAVEX
ldy #0
sty SAVEY
circle_loop:
ldx SAVEX
; ldy sinetable,X
; sty SAVEY
lda sinetable,X
clc
; clc
asl
; $60 is midscreen
adc #$60
ldx SAVEY
@ -102,6 +112,7 @@ circle_loop:
jsr HPLOT0 ; plot at (Y,X), (A)
inc SAVEX
inc SAVEY
bne circle_loop
@ -131,3 +142,4 @@ sinetable_base:
; jmp oval
sinetable=$6000
;sinetable_base=$F5BA