From 093e15268dd622368ef2d0905146e5965e05ca96 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 18 Jun 2021 12:51:40 -0400 Subject: [PATCH] hgr: circles: made it a bit smaller --- graphics/hgr/circles/Makefile | 10 +- graphics/hgr/circles/brestest.bas | 19 +++ graphics/hgr/circles/circles.s | 189 ++++++++++++++---------------- 3 files changed, 114 insertions(+), 104 deletions(-) create mode 100644 graphics/hgr/circles/brestest.bas diff --git a/graphics/hgr/circles/Makefile b/graphics/hgr/circles/Makefile index 63337061..1db4b8c4 100644 --- a/graphics/hgr/circles/Makefile +++ b/graphics/hgr/circles/Makefile @@ -9,7 +9,7 @@ all: circles.dsk circles.dsk: HELLO CIRCLES ARCS WEB \ BRES.BAS BRESBOT.BAS BRESCOOL.BAS \ - MID.BAS MIDBOT.BAS MIDCOOL.BAS + MID.BAS MIDBOT.BAS MIDCOOL.BAS BRESTEST.BAS cp $(EMPTY_DISK)/empty.dsk circles.dsk $(DOS33) -y circles.dsk SAVE A HELLO $(DOS33) -y circles.dsk SAVE A BRES.BAS @@ -18,6 +18,7 @@ circles.dsk: HELLO CIRCLES ARCS WEB \ $(DOS33) -y circles.dsk SAVE A MID.BAS $(DOS33) -y circles.dsk SAVE A MIDBOT.BAS $(DOS33) -y circles.dsk SAVE A MIDCOOL.BAS + $(DOS33) -y circles.dsk SAVE A BRESTEST.BAS $(DOS33) -y circles.dsk BSAVE -a 0x0C00 CIRCLES $(DOS33) -y circles.dsk BSAVE -a 0x0C00 ARCS $(DOS33) -y circles.dsk BSAVE -a 0x0C00 WEB @@ -58,6 +59,11 @@ BRESBOT.BAS: bresbot.bas BRESCOOL.BAS: brescool.bas $(TOKENIZE) < brescool.bas > BRESCOOL.BAS +### + +BRESTEST.BAS: brestest.bas + $(TOKENIZE) < brestest.bas > BRESTEST.BAS + ### @@ -89,5 +95,5 @@ web.o: web.s clean: rm -f *~ *.o *.lst CIRCLES ARCS WEB \ - BRES.BAS BRESBOT.BAS BRESCOOL.BAS \ + BRES.BAS BRESBOT.BAS BRESCOOL.BAS BRESTEST.BAS \ MID.BAS MIDBOT.BAS MIDCOOL.BAS diff --git a/graphics/hgr/circles/brestest.bas b/graphics/hgr/circles/brestest.bas new file mode 100644 index 00000000..89373a32 --- /dev/null +++ b/graphics/hgr/circles/brestest.bas @@ -0,0 +1,19 @@ +10 HCOLOR=3:R=0:XC=128:YC=96 +20 GET A$:HGR +30 X=0:Y=R:D=3-2*R:GOSUB 100 +40 X=X+1 +50 IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10:GOTO 70 +60 D=D+4*X+6 +70 GOSUB 100 +80 IF Y>=X THEN 40 +90 R=R+1:GOTO 20 +99 END +100 HPLOT XC+X,YC+Y +110 HPLOT XC-X,YC+Y +120 HPLOT XC+X,YC-Y +130 HPLOT XC-X,YC-Y +140 HPLOT XC+Y,YC+X +150 HPLOT XC-Y,YC+X +160 HPLOT XC+Y,YC-X +170 HPLOT XC-Y,YC-X +180 RETURN diff --git a/graphics/hgr/circles/circles.s b/graphics/hgr/circles/circles.s index 60441b61..b50d8596 100644 --- a/graphics/hgr/circles/circles.s +++ b/graphics/hgr/circles/circles.s @@ -1,14 +1,28 @@ ; circles tiny -- Apple II Hires +; 229 -- first +; 228 -- remove shift +; 190 -- move hplots into two loops +; 169 -- move hplots into one loop +; 166 -- small enough we can use bcs again +; 157 -- some more math + ; D0+ used by HGR routines HGR_COLOR = $E4 HGR_PAGE = $E6 -D = $F9 -XX = $FA -YY = $FB +COUNT = $F6 + + + +XX = $F7 +MINUSXX = $F8 +YY = $F9 +MINUSYY = $FA + +D = $FB R = $FC CX = $FD CY = $FE @@ -16,6 +30,9 @@ FRAME = $FF ; soft-switches +KEYPRESS = $C000 +KEYRESET = $C010 + ; ROM routines HGR2 = $F3D8 ; set hires page2 and clear $4000-$5fff @@ -32,12 +49,23 @@ WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us circles: - jsr HGR2 + lda #0 sta R draw_next: + + lda KEYPRESS + bpl draw_next + + bit KEYRESET + + jsr HGR2 + + + +;draw_next: .if 0 inc FRAME ldy FRAME @@ -78,21 +106,27 @@ draw_next: sta CY + ;=============================== + ; draw circle + ;=============================== + ; draw circle at (CX,CY) of radius R + ; signed 8-bit math so problems if R > 64? + ; XX=0 YY=R ; D=3-2*R ; GOTO6 + lda #0 sta XX lda R sta YY - asl - sta D lda #3 sec - sbc D + sbc R + sbc R sta D jmp do_plots @@ -130,124 +164,75 @@ store_D: sta D do_plots: + ; setup constants + + lda XX + eor #$FF + sta MINUSXX + inc MINUSXX + + lda YY + eor #$FF + sta MINUSYY + inc MINUSYY + ; HPLOT CX+X,CY+Y - - lda CX - clc - adc XX - tax - ldy #0 - lda CY - clc - adc YY - - jsr HPLOT0 ; plot at (Y,X), (A) - ; HPLOT CX-X,CY+Y - - lda CX - sec - sbc XX - tax - ldy #0 - lda CY - clc - adc YY - - jsr HPLOT0 ; plot at (Y,X), (A) - ; HPLOT CX+X,CY-Y - - lda CX - clc - adc XX - tax - ldy #0 - lda CY - sec - sbc YY - - jsr HPLOT0 ; plot at (Y,X), (A) - - ; HPLOT CX-X,CY-Y - - lda CX - sec - sbc XX - tax - ldy #0 - lda CY - sec - sbc YY - - jsr HPLOT0 ; plot at (Y,X), (A) - ; HPLOT CX+Y,CY+X - - lda CX - clc - adc YY - tax - ldy #0 - lda CY - clc - adc XX - - jsr HPLOT0 ; plot at (Y,X), (A) - - ; HPLOT CX-Y,CY+X - - lda CX - sec - sbc YY - tax - ldy #0 - lda CY - clc - adc XX - - jsr HPLOT0 ; plot at (Y,X), (A) - ; HPLOT CX+Y,CY-X - - lda CX - clc - adc YY - tax - ldy #0 - lda CY - sec - sbc XX - - jsr HPLOT0 ; plot at (Y,X), (A) - ; HPLOT CX-Y,CY-X + ; calc X co-ord + + lda #7 + sta COUNT +pos_loop: + lda COUNT + and #$4 + lsr + tay + + lda COUNT + lsr + bcc xnoc + iny +xnoc: lda CX - sec - sbc YY + clc + adc XX,Y tax - ldy #0 + + ; calc y co-ord + + lda COUNT + lsr + eor #$2 + tay + lda CY - sec - sbc XX + clc + adc XX,Y + + ldy #0 jsr HPLOT0 ; plot at (Y,X), (A) + dec COUNT + bpl pos_loop + ; IFY>=XTHEN4 lda YY cmp XX -; bcs circle_loop - bcc done + bcs circle_loop - jmp circle_loop done: lda R clc - adc #3 + adc #1 sta R stop: cmp #90