diff --git a/graphics/hgr/tiny_triangles/Makefile b/graphics/hgr/sierpinski/Makefile similarity index 100% rename from graphics/hgr/tiny_triangles/Makefile rename to graphics/hgr/sierpinski/Makefile diff --git a/graphics/hgr/tiny_triangles/apple2_36f.inc b/graphics/hgr/sierpinski/apple2_36f.inc similarity index 100% rename from graphics/hgr/tiny_triangles/apple2_36f.inc rename to graphics/hgr/sierpinski/apple2_36f.inc diff --git a/graphics/hgr/tiny_triangles/apple2_70_zp.inc b/graphics/hgr/sierpinski/apple2_70_zp.inc similarity index 100% rename from graphics/hgr/tiny_triangles/apple2_70_zp.inc rename to graphics/hgr/sierpinski/apple2_70_zp.inc diff --git a/graphics/hgr/tiny_triangles/feathers.s b/graphics/hgr/sierpinski/feathers.s similarity index 100% rename from graphics/hgr/tiny_triangles/feathers.s rename to graphics/hgr/sierpinski/feathers.s diff --git a/graphics/hgr/tiny_triangles/hello.bas b/graphics/hgr/sierpinski/hello.bas similarity index 100% rename from graphics/hgr/tiny_triangles/hello.bas rename to graphics/hgr/sierpinski/hello.bas diff --git a/graphics/hgr/tiny_triangles/mod9.s b/graphics/hgr/sierpinski/mod9.s similarity index 100% rename from graphics/hgr/tiny_triangles/mod9.s rename to graphics/hgr/sierpinski/mod9.s diff --git a/graphics/hgr/tiny_triangles/mod9_64.s b/graphics/hgr/sierpinski/mod9_64.s similarity index 100% rename from graphics/hgr/tiny_triangles/mod9_64.s rename to graphics/hgr/sierpinski/mod9_64.s diff --git a/graphics/hgr/tiny_triangles/move_right.s b/graphics/hgr/sierpinski/move_right.s similarity index 100% rename from graphics/hgr/tiny_triangles/move_right.s rename to graphics/hgr/sierpinski/move_right.s diff --git a/graphics/hgr/tiny_triangles/rainbow_squares.s b/graphics/hgr/sierpinski/rainbow_squares.s similarity index 100% rename from graphics/hgr/tiny_triangles/rainbow_squares.s rename to graphics/hgr/sierpinski/rainbow_squares.s diff --git a/graphics/hgr/tiny_triangles/sier_hgr.s b/graphics/hgr/sierpinski/sier_hgr.s similarity index 100% rename from graphics/hgr/tiny_triangles/sier_hgr.s rename to graphics/hgr/sierpinski/sier_hgr.s diff --git a/graphics/hgr/tiny_triangles/sier_hplot.s b/graphics/hgr/sierpinski/sier_hplot.s similarity index 100% rename from graphics/hgr/tiny_triangles/sier_hplot.s rename to graphics/hgr/sierpinski/sier_hplot.s diff --git a/graphics/hgr/tiny_triangles/sier_inline.s b/graphics/hgr/sierpinski/sier_inline.s similarity index 100% rename from graphics/hgr/tiny_triangles/sier_inline.s rename to graphics/hgr/sierpinski/sier_inline.s diff --git a/graphics/hgr/tiny_triangles/sier_interlace.s b/graphics/hgr/sierpinski/sier_interlace.s similarity index 100% rename from graphics/hgr/tiny_triangles/sier_interlace.s rename to graphics/hgr/sierpinski/sier_interlace.s diff --git a/graphics/hgr/tiny_triangles/sier_moveright.s b/graphics/hgr/sierpinski/sier_moveright.s similarity index 100% rename from graphics/hgr/tiny_triangles/sier_moveright.s rename to graphics/hgr/sierpinski/sier_moveright.s diff --git a/graphics/hgr/tiny_triangles/tiny_triangles.s b/graphics/hgr/sierpinski/tiny_triangles.s similarity index 100% rename from graphics/hgr/tiny_triangles/tiny_triangles.s rename to graphics/hgr/sierpinski/tiny_triangles.s diff --git a/graphics/hgr/tiny_triangles/writing.s b/graphics/hgr/sierpinski/writing.s similarity index 100% rename from graphics/hgr/tiny_triangles/writing.s rename to graphics/hgr/sierpinski/writing.s diff --git a/graphics/hgr/tiny_triangles/xor.s b/graphics/hgr/sierpinski/xor.s similarity index 100% rename from graphics/hgr/tiny_triangles/xor.s rename to graphics/hgr/sierpinski/xor.s diff --git a/graphics/hgr/triangles/Makefile b/graphics/hgr/triangles/Makefile new file mode 100644 index 00000000..7716839e --- /dev/null +++ b/graphics/hgr/triangles/Makefile @@ -0,0 +1,39 @@ +include ../../../Makefile.inc + +DOS33 = ../../../utils/dos33fs-utils/dos33 +TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft +LINKER_SCRIPTS = ../../../linker_scripts +EMPTY_DISK = ../../../empty_disk + +all: triangles.dsk + +triangles.dsk: HELLO TRIANGLE.BAS LINES + cp $(EMPTY_DISK)/empty.dsk triangles.dsk + $(DOS33) -y triangles.dsk SAVE A HELLO + $(DOS33) -y triangles.dsk SAVE A TRIANGLE.BAS + $(DOS33) -y triangles.dsk BSAVE -a 0x0C00 LINES + +### + +HELLO: hello.bas + $(TOKENIZE) < hello.bas > HELLO + +### + +TRIANGLE.BAS: triangle.bas + $(TOKENIZE) < triangle.bas > TRIANGLE.BAS + + +### + +LINES: lines.o + ld65 -o LINES lines.o -C $(LINKER_SCRIPTS)/apple2_c00.inc + +lines.o: lines.s + ca65 -o lines.o lines.s -l lines.lst + +### + +clean: + rm -f *~ *.o *.lst HELLO LINES TRIANGLE.BAS + diff --git a/graphics/hgr/triangles/hello.bas b/graphics/hgr/triangles/hello.bas new file mode 100644 index 00000000..133a44bb --- /dev/null +++ b/graphics/hgr/triangles/hello.bas @@ -0,0 +1,2 @@ +5 HOME +10 PRINT CHR$(4);"CATALOG" diff --git a/graphics/hgr/triangles/lines.s b/graphics/hgr/triangles/lines.s new file mode 100644 index 00000000..c23722bf --- /dev/null +++ b/graphics/hgr/triangles/lines.s @@ -0,0 +1,251 @@ +; Hi-res Bresenham Lines + +; by Vince `deater` Weaver + +; based on pseudo-code from +; https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm + +; D0+ used by HGR routines + +HGR_COLOR = $E4 +HGR_PAGE = $E6 + + +B_X1 = $F0 +B_Y1 = $F1 +B_X2 = $F2 +B_Y2 = $F3 +B_DX = $F4 +B_DY = $F5 +B_SX = $F6 +B_SY = $F7 +B_ERR = $F8 +COUNT = $F9 +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 + + +lines: + + jsr HGR2 + +restart: + lda #0 + sta COUNT + +lines_loop: + lda FRAME + and #$7 +; lda #$7f +; sta HGR_COLOR + + + lda #0 + sta B_X1 + lda #36 + sta B_Y2 + + lda COUNT + cmp #10 +;end: + beq restart + + asl + asl + sta B_Y1 + sta B_X2 + + jsr draw_line + + inc COUNT + inc FRAME + + jmp lines_loop + + + + ;============================ + ; draw line + ; from x1,y1 to x2,y2 + ;============================ +draw_line: + + ; from wikipedia + + ; dx = abs(x2 - x1) + ; sx = x1 < x2 ? 1 : -1 + ; dy = -abs(y2 - y1) + ; sy = y1 < y2 ? 1 : -1 + ; err = dx+dy + +init_bresenham: + + ; dx = abs(x2-x1) + ; sx = x1= dy: + ; err = err + dy + ; x1 = x1 + sx + + + ; B_ERR already in A + cmp B_DY ; check equal first + beq do_x + + clc ; signed compare + sbc B_DY + bvc blah2 + eor #$80 +blah2: + bmi skip_x ; ble + +do_x: + lda B_DY + jsr common_inc +skip_x: + + + + inx ; setup common inc + + ; if err2 <= dx: + ; err = err + dx + ; y1 = y1 + sy + pla ; restore err2 + + clc ; signed compare + sbc B_DX + bvc blah + eor #$80 +blah: + bpl skip_y + +do_y: + lda B_DX + jsr common_inc + +skip_y: + + jmp line_loop + + + ;===================================== + ; common increment + ;===================================== +common_inc: + + clc + adc B_ERR + sta B_ERR + + lda B_X1,X + clc + adc B_SX,X + sta B_X1,X +done_line: + rts + + + ;===================================== + ; init, do the abs and sx calculations + ; x=0, for X + ; x=1, for Y + ;===================================== +do_abs: + ldy #$ff + sec + lda B_X1,X + sbc B_X2,X ; A = x1 - x2 + + bpl is_pos + + ldy #$1 +neg: + eor #$ff + clc + adc #1 +is_pos: + sty B_SX,X + sta B_DX,X + rts + + diff --git a/graphics/hgr/triangles/triangle.bas b/graphics/hgr/triangles/triangle.bas new file mode 100644 index 00000000..8146dfb3 --- /dev/null +++ b/graphics/hgr/triangles/triangle.bas @@ -0,0 +1,4 @@ +10 HGR2:HCOLOR=7 +15 FOR X=106 TO 130 +20 HPLOT 130,128 TO X,191:NEXT +30 FOR diff --git a/graphics/hgr/vgi/rocket.vgi b/graphics/hgr/vgi/rocket.vgi new file mode 100644 index 00000000..8400117c --- /dev/null +++ b/graphics/hgr/vgi/rocket.vgi @@ -0,0 +1,5 @@ +; Rocket from Myst +0 255 ; white background +1 1 6 0 122 140 191 ; ocean left +1 1 6 140 122 279 191 ; ocean right +15