diff --git a/graphics/hgr/circles/Makefile b/graphics/hgr/circles/Makefile index 1db4b8c4..bfe0bcce 100644 --- a/graphics/hgr/circles/Makefile +++ b/graphics/hgr/circles/Makefile @@ -7,7 +7,7 @@ EMPTY_DISK = ../../../empty_disk all: circles.dsk -circles.dsk: HELLO CIRCLES ARCS WEB \ +circles.dsk: HELLO CIRCLES CIRCLES_FILL ARCS WEB PAC ROSE \ BRES.BAS BRESBOT.BAS BRESCOOL.BAS \ MID.BAS MIDBOT.BAS MIDCOOL.BAS BRESTEST.BAS cp $(EMPTY_DISK)/empty.dsk circles.dsk @@ -20,8 +20,11 @@ circles.dsk: HELLO CIRCLES ARCS WEB \ $(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 CIRCLES_FILL $(DOS33) -y circles.dsk BSAVE -a 0x0C00 ARCS $(DOS33) -y circles.dsk BSAVE -a 0x0C00 WEB + $(DOS33) -y circles.dsk BSAVE -a 0x0C00 PAC + $(DOS33) -y circles.dsk BSAVE -a 0x0C00 ROSE ### @@ -73,6 +76,15 @@ CIRCLES: circles.o circles.o: circles.s ca65 -o circles.o circles.s -l circles.lst +### + +CIRCLES_FILL: circles_fill.o + ld65 -o CIRCLES_FILL circles_fill.o -C $(LINKER_SCRIPTS)/apple2_c00.inc + +circles_fill.o: circles_fill.s + ca65 -o circles_fill.o circles_fill.s -l circles_fill.lst + + # ARCS: arcs.o @@ -89,11 +101,28 @@ WEB: web.o web.o: web.s ca65 -o web.o web.s -l web.lst +# + +PAC: pac.o + ld65 -o PAC pac.o -C $(LINKER_SCRIPTS)/apple2_c00.inc + +pac.o: pac.s + ca65 -o pac.o pac.s -l pac.lst + +# + +ROSE: rose.o + ld65 -o ROSE rose.o -C $(LINKER_SCRIPTS)/apple2_c00.inc + +rose.o: rose.s + ca65 -o rose.o rose.s -l rose.lst + + ### clean: - rm -f *~ *.o *.lst CIRCLES ARCS WEB \ + rm -f *~ *.o *.lst CIRCLES ARCS WEB CIRCLES_FILL PAC ROSE \ BRES.BAS BRESBOT.BAS BRESCOOL.BAS BRESTEST.BAS \ MID.BAS MIDBOT.BAS MIDCOOL.BAS diff --git a/graphics/hgr/circles/circles_fill.s b/graphics/hgr/circles/circles_fill.s new file mode 100644 index 00000000..09fcdc04 --- /dev/null +++ b/graphics/hgr/circles/circles_fill.s @@ -0,0 +1,258 @@ +; 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 + +COUNT = $F6 + + + +XX = $F7 +MINUSXX = $F8 +YY = $F9 +MINUSYY = $FA + +D = $FB +R = $FC +CX = $FD +CY = $FE +FRAME = $FF + +; soft-switches + +KEYPRESS = $C000 +KEYRESET = $C010 + +; ROM routines + +HGR2 = $F3D8 ; set hires page2 and clear $4000-$5fff +HGR = $F3E2 ; set hires page1 and clear $2000-$3fff +HPLOT0 = $F457 ; plot at (Y,X), (A) +HLINRL = $F530 ; line to (X,A), (Y) +HCOLOR1 = $F6F0 ; set HGR_COLOR to value in X +COLORTBL = $F6F6 +PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved) +NEXTCOL = $F85F ; COLOR=COLOR+3 +SETCOL = $F864 ; COLOR=A +SETGR = $FB40 ; set graphics and clear LO-RES screen +BELL2 = $FBE4 +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us + +circles: + + + + lda #0 + sta R + +draw_next: + + lda KEYPRESS + bpl draw_next + + bit KEYRESET + + jsr HGR2 + + + +;draw_next: +.if 0 + inc FRAME + ldy FRAME + + ; Random Color + ; HCOLOR=1+RND(1)*7 + lda $F000,Y + and #$7 ; mask to 0...7 + tax + lda COLORTBL,X + sta HGR_COLOR + + ; CX + lda $F100,Y + and #$7f + clc + adc #$40 + sta CX + + ; CY + lda $F200,Y + and #$7f + clc + adc #$20 + sta CY + + ; R + lda $F300,Y + and #$3f + sta R +.endif + + ; A=40+RND(1)*200:B=40+RND(1)*100:Y=RND(1)*40 + + lda #128 + sta CX + lda #96 + 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 + + lda #3 + sec + sbc R + sbc R + sta D + + jmp do_plots + +circle_loop: + ; X=X+1 + + inc XX + + ; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10 + lda D + bmi else + + dec YY + + lda XX + sec + sbc YY + asl + asl + clc + adc D + adc #10 + jmp store_D + +else: + ; ELSE D=D+4*X+6 + lda XX + asl + asl + clc + adc D + adc #6 +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 + ; HPLOT CX-X,CY+Y + ; HPLOT CX+X,CY-Y + ; HPLOT CX-X,CY-Y + ; HPLOT CX+Y,CY+X + ; HPLOT CX-Y,CY+X + ; HPLOT CX+Y,CY-X + ; HPLOT CX-Y,CY-X + + + + + lda #3 + sta COUNT +pos_loop: + + ; calc left side + + ; calc X co-ord + + lda COUNT + ora #$1 + eor #$2 + tay + lda CX + clc + adc XX,Y + tax + + ; calc y co-ord + + ldy COUNT + lda CY + clc + adc XX,Y + + ldy #0 + + pha ; save Y value for later + + jsr HPLOT0 ; plot at (Y,X), (A) + + + ; calc right side + lda COUNT + and #$2 + eor #$2 + tay + lda XX,Y + asl + + ldy #0 + ldx #0 + + jsr HLINRL ; plot relative (X,A), (Y) + ; so in our case (0,XX*2),0 + + + + dec COUNT + bpl pos_loop + + + ; IFY>=XTHEN4 + lda YY + cmp XX + bcs circle_loop + +done: + lda R + clc + adc #1 + sta R +stop: + cmp #90 + beq stop + + ; GOTO1 + jmp draw_next diff --git a/graphics/hgr/circles/pac.s b/graphics/hgr/circles/pac.s new file mode 100644 index 00000000..78a2889e --- /dev/null +++ b/graphics/hgr/circles/pac.s @@ -0,0 +1,251 @@ +; 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 + +COUNT = $F6 + + + +XX = $F7 +MINUSXX = $F8 +YY = $F9 +MINUSYY = $FA + +D = $FB +R = $FC +CX = $FD +CY = $FE +FRAME = $FF + +; soft-switches + +KEYPRESS = $C000 +KEYRESET = $C010 + +; ROM routines + +HGR2 = $F3D8 ; set hires page2 and clear $4000-$5fff +HGR = $F3E2 ; set hires page1 and clear $2000-$3fff +HPLOT0 = $F457 ; plot at (Y,X), (A) +HLINRL = $F530 ; line to (X,A), (Y) +HCOLOR1 = $F6F0 ; set HGR_COLOR to value in X +COLORTBL = $F6F6 +PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved) +NEXTCOL = $F85F ; COLOR=COLOR+3 +SETCOL = $F864 ; COLOR=A +SETGR = $FB40 ; set graphics and clear LO-RES screen +BELL2 = $FBE4 +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us + +circles: + + + + lda #1 + sta R + +draw_next: + + + jsr HGR2 + + + +;draw_next: +.if 0 + inc FRAME + ldy FRAME + + ; Random Color + ; HCOLOR=1+RND(1)*7 + lda $F000,Y + and #$7 ; mask to 0...7 + tax + lda COLORTBL,X + sta HGR_COLOR + + ; CX + lda $F100,Y + and #$7f + clc + adc #$40 + sta CX + + ; CY + lda $F200,Y + and #$7f + clc + adc #$20 + sta CY + + ; R + lda $F300,Y + and #$3f + sta R +.endif + + ; A=40+RND(1)*200:B=40+RND(1)*100:Y=RND(1)*40 + + lda #128 + sta CX + lda #96 + 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 + + lda #3 + sec + sbc R + sbc R + sta D + + jmp do_plots + +circle_loop: + ; X=X+1 + + inc XX + + ; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10 + lda D + bmi else + + dec YY + + lda XX + sec + sbc YY + asl + asl + clc + adc D + adc #10 + jmp store_D + +else: + ; ELSE D=D+4*X+6 + lda XX + asl + asl + clc + adc D + adc #6 +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 + ; HPLOT CX-X,CY+Y + ; HPLOT CX+X,CY-Y + ; HPLOT CX-X,CY-Y + ; HPLOT CX+Y,CY+X + ; HPLOT CX-Y,CY+X + ; HPLOT CX+Y,CY-X + ; HPLOT CX-Y,CY-X + + + + + lda #3 + sta COUNT +pos_loop: + + ; calc left side + + ; calc X co-ord + + lda COUNT + ora #$1 + eor #$2 + tay + lda CX + clc + adc XX,Y + tax + + ; calc y co-ord + + ldy COUNT + lda CY + clc + adc XX,Y + + ldy #0 + + pha ; save Y value for later + + jsr HPLOT0 ; plot at (Y,X), (A) + + + ; calc right side + + lda XX + asl + + ldy #0 + ldx #0 + + jsr HLINRL ; plot relative (X,A), (Y) + ; so in our case (0,XX*2),0 + + + + dec COUNT + bpl pos_loop + + + ; IFY>=XTHEN4 + lda YY + cmp XX + bcs circle_loop + +done: + + lda KEYPRESS + bpl done + + bit KEYRESET + + inc R + + ; GOTO1 + jmp draw_next diff --git a/graphics/hgr/circles/rose.s b/graphics/hgr/circles/rose.s new file mode 100644 index 00000000..f0309b98 --- /dev/null +++ b/graphics/hgr/circles/rose.s @@ -0,0 +1,256 @@ +; 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 + +COUNT = $F6 + + + +XX = $F7 +MINUSXX = $F8 +YY = $F9 +MINUSYY = $FA + +D = $FB +R = $FC +CX = $FD +CY = $FE +FRAME = $FF + +; soft-switches + +KEYPRESS = $C000 +KEYRESET = $C010 + +; ROM routines + +HGR2 = $F3D8 ; set hires page2 and clear $4000-$5fff +HGR = $F3E2 ; set hires page1 and clear $2000-$3fff +HPLOT0 = $F457 ; plot at (Y,X), (A) +HLINRL = $F530 ; line to (X,A), (Y) +HCOLOR1 = $F6F0 ; set HGR_COLOR to value in X +COLORTBL = $F6F6 +PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved) +NEXTCOL = $F85F ; COLOR=COLOR+3 +SETCOL = $F864 ; COLOR=A +SETGR = $FB40 ; set graphics and clear LO-RES screen +BELL2 = $FBE4 +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us + +circles: + + + + lda #0 + sta R + +draw_next: + + + jsr HGR2 + + + +;draw_next: +.if 0 + inc FRAME + ldy FRAME + + ; Random Color + ; HCOLOR=1+RND(1)*7 + lda $F000,Y + and #$7 ; mask to 0...7 + tax + lda COLORTBL,X + sta HGR_COLOR + + ; CX + lda $F100,Y + and #$7f + clc + adc #$40 + sta CX + + ; CY + lda $F200,Y + and #$7f + clc + adc #$20 + sta CY + + ; R + lda $F300,Y + and #$3f + sta R +.endif + + ; A=40+RND(1)*200:B=40+RND(1)*100:Y=RND(1)*40 + + lda #128 + sta CX + lda #96 + 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 + + lda #3 + sec + sbc R + sbc R + sta D + + jmp do_plots + +circle_loop: + ; X=X+1 + + inc XX + + ; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10 + lda D + bmi else + + dec YY + + lda XX + sec + sbc YY + asl + asl + clc + adc D + adc #10 + jmp store_D + +else: + ; ELSE D=D+4*X+6 + lda XX + asl + asl + clc + adc D + adc #6 +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 + ; HPLOT CX-X,CY+Y + ; HPLOT CX+X,CY-Y + ; HPLOT CX-X,CY-Y + ; HPLOT CX+Y,CY+X + ; HPLOT CX-Y,CY+X + ; HPLOT CX+Y,CY-X + ; HPLOT CX-Y,CY-X + + + + + lda #3 + sta COUNT +pos_loop: + + ; calc left side + + ; calc X co-ord + + lda COUNT + ora #$1 + eor #$2 + tay + lda CX + clc + adc XX,Y + tax + + ; calc y co-ord + + ldy COUNT + lda CY + clc + adc XX,Y + + ldy #0 + + pha ; save Y value for later + + jsr HPLOT0 ; plot at (Y,X), (A) + + + ; calc right side + lda COUNT + and #$2 + eor #$2 + tay + lda XX,Y + asl + + ldy #0 + ldx #0 + + jsr HLINRL ; plot relative (X,A), (Y) + ; so in our case (0,XX*2),0 + + + + dec COUNT + bpl pos_loop + + + ; IFY>=XTHEN4 + lda YY + cmp XX + bcs circle_loop + +done: + + + lda KEYPRESS + bpl done + + bit KEYRESET + + + inc R +stop: + ; GOTO1 + jmp draw_next diff --git a/graphics/hgr/vgi/vgi_circles.s b/graphics/hgr/vgi/vgi_circles.s new file mode 100644 index 00000000..b50d8596 --- /dev/null +++ b/graphics/hgr/vgi/vgi_circles.s @@ -0,0 +1,242 @@ +; 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 + +COUNT = $F6 + + + +XX = $F7 +MINUSXX = $F8 +YY = $F9 +MINUSYY = $FA + +D = $FB +R = $FC +CX = $FD +CY = $FE +FRAME = $FF + +; soft-switches + +KEYPRESS = $C000 +KEYRESET = $C010 + +; ROM routines + +HGR2 = $F3D8 ; set hires page2 and clear $4000-$5fff +HGR = $F3E2 ; set hires page1 and clear $2000-$3fff +HPLOT0 = $F457 ; plot at (Y,X), (A) +HCOLOR1 = $F6F0 ; set HGR_COLOR to value in X +COLORTBL = $F6F6 +PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved) +NEXTCOL = $F85F ; COLOR=COLOR+3 +SETCOL = $F864 ; COLOR=A +SETGR = $FB40 ; set graphics and clear LO-RES screen +BELL2 = $FBE4 +WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us + +circles: + + + + lda #0 + sta R + +draw_next: + + lda KEYPRESS + bpl draw_next + + bit KEYRESET + + jsr HGR2 + + + +;draw_next: +.if 0 + inc FRAME + ldy FRAME + + ; Random Color + ; HCOLOR=1+RND(1)*7 + lda $F000,Y + and #$7 ; mask to 0...7 + tax + lda COLORTBL,X + sta HGR_COLOR + + ; CX + lda $F100,Y + and #$7f + clc + adc #$40 + sta CX + + ; CY + lda $F200,Y + and #$7f + clc + adc #$20 + sta CY + + ; R + lda $F300,Y + and #$3f + sta R +.endif + + ; A=40+RND(1)*200:B=40+RND(1)*100:Y=RND(1)*40 + + lda #128 + sta CX + lda #96 + 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 + + lda #3 + sec + sbc R + sbc R + sta D + + jmp do_plots + +circle_loop: + ; X=X+1 + + inc XX + + ; IF D>0 THEN Y=Y-1:D=D+4*(X-Y)+10 + lda D + bmi else + + dec YY + + lda XX + sec + sbc YY + asl + asl + clc + adc D + adc #10 + jmp store_D + +else: + ; ELSE D=D+4*X+6 + lda XX + asl + asl + clc + adc D + adc #6 +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 + ; HPLOT CX-X,CY+Y + ; HPLOT CX+X,CY-Y + ; HPLOT CX-X,CY-Y + ; HPLOT CX+Y,CY+X + ; HPLOT CX-Y,CY+X + ; HPLOT CX+Y,CY-X + ; 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 + clc + adc XX,Y + tax + + ; calc y co-ord + + lda COUNT + lsr + eor #$2 + tay + + lda CY + 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 + +done: + lda R + clc + adc #1 + sta R +stop: + cmp #90 + beq stop + + ; GOTO1 + jmp draw_next