diff --git a/graphics/hgr/vgi/Makefile b/graphics/hgr/vgi/Makefile index 52ad1182..60709cc8 100644 --- a/graphics/hgr/vgi/Makefile +++ b/graphics/hgr/vgi/Makefile @@ -25,7 +25,8 @@ VGI: vgi.o ld65 -o VGI vgi.o -C $(LINKERSCRIPTS)/apple2_c00.inc vgi.o: clock.data rocket.data \ - vgi.s vgi_clearscreen.s vgi_rectangle.s vgi_circles.s vgi_lines.s + vgi.s vgi_clearscreen.s vgi_rectangle.s vgi_circles.s vgi_lines.s \ + vgi_triangles.s ca65 -o vgi.o vgi.s -l vgi.lst diff --git a/graphics/hgr/vgi/make_boxes_asm.c b/graphics/hgr/vgi/make_boxes_asm.c index cc20ee00..a52e116e 100644 --- a/graphics/hgr/vgi/make_boxes_asm.c +++ b/graphics/hgr/vgi/make_boxes_asm.c @@ -1,31 +1,79 @@ #include +#include +#include + +#define VGI_CLEARSCREEN 0 +#define VGI_RECTANGLE 1 +#define VGI_CIRCLE 2 +#define VGI_FILLED_CIRCLE 3 +#define VGI_POINT 4 +#define VGI_LINETO 5 +#define VGI_DITHER_RECTANGLE 6 +#define VGI_VERT_TRIANGLE 7 +#define VGI_HORIZ_TRIANGLE 8 +#define VGI_END 15 int main(int argc, char **argv) { char buffer[1024]; char *ptr; - int type,color1,color2,x1,x2,y1,y2,r; + int type,color1,color2,x1,x2,y1,y2,r,xl,xr,yt,yb; int line=1; while(1) { + type=0; + ptr=fgets(buffer,1024,stdin); if (ptr==NULL) break; if (buffer[0]==';') continue; - sscanf(buffer,"%i",&type); + if (isalpha(buffer[0])) { + if (!strncmp(buffer,"CLS",3)) { + type=VGI_CLEARSCREEN; + } + if (!strncmp(buffer,"RECT",4)) { + type=VGI_RECTANGLE; + } + if (!strncmp(buffer,"CIRC",4)) { + type=VGI_CIRCLE; + } + if (!strncmp(buffer,"FCIRC",5)) { + type=VGI_FILLED_CIRCLE; + } + if (!strncmp(buffer,"POINT",5)) { + type=VGI_POINT; + } + if (!strncmp(buffer,"LINETO",6)) { + type=VGI_LINETO; + } + if (!strncmp(buffer,"DRECT",5)) { + type=VGI_DITHER_RECTANGLE; + } + if (!strncmp(buffer,"VTRI",4)) { + type=VGI_VERT_TRIANGLE; + } + if (!strncmp(buffer,"HTRI",4)) { + type=VGI_HORIZ_TRIANGLE; + } + if (!strncmp(buffer,"END",3)) { + type=VGI_END; + } + } + else { + sscanf(buffer,"%i",&type); + } switch(type) { - case 0: /* clear screen */ - sscanf(buffer,"%i %i",&type,&color1); + case VGI_CLEARSCREEN: /* clear screen */ + sscanf(buffer,"%*s %i",&color1); printf(".byte $%02X,",(type<<4)|2); printf("$%02X\n",color1); break; - case 1: /* compact rectangle */ - sscanf(buffer,"%i %i %i %i %i %i %i", - &type, + case VGI_RECTANGLE: /* compact rectangle */ + sscanf(buffer,"%*s %i %i %i %i %i %i", &color1,&color2, &x1,&y1,&x2,&y2); printf(".byte $%02X,",(type<<4)|6); @@ -36,9 +84,8 @@ int main(int argc, char **argv) { printf("$%02X\n",y2-y1); break; - case 2: /* circle */ - sscanf(buffer,"%i %i %i %i %i", - &type, + case VGI_CIRCLE: /* circle */ + sscanf(buffer,"%*s %i %i %i %i", &color1, &x1,&y1,&r); printf(".byte $%02X,",(type<<4)|5); @@ -48,9 +95,8 @@ int main(int argc, char **argv) { printf("$%02X\n",r); break; - case 3: /* filled circle */ - sscanf(buffer,"%i %i %i %i %i", - &type, + case VGI_FILLED_CIRCLE: /* filled circle */ + sscanf(buffer,"%*s %i %i %i %i", &color1, &x1,&y1,&r); printf(".byte $%02X,",(type<<4)|5); @@ -60,9 +106,8 @@ int main(int argc, char **argv) { printf("$%02X\n",r); break; - case 4: /* point */ - sscanf(buffer,"%i %i %i %i", - &type, + case VGI_POINT: /* point */ + sscanf(buffer,"%*s %i %i %i", &color1, &x1,&y1); printf(".byte $%02X,",(type<<4)|4); @@ -71,18 +116,16 @@ int main(int argc, char **argv) { printf("$%02X\n",y1); break; - case 5: /* line to */ - sscanf(buffer,"%i %i %i", - &type, + case VGI_LINETO: /* line to */ + sscanf(buffer,"%*s %i %i", &x1,&y1); printf(".byte $%02X,",(type<<4)|3); printf("$%02X,",x1); printf("$%02X\n",y1); break; - case 6: /* dithered rectangle */ - sscanf(buffer,"%i %i %i %i %i %i %i", - &type, + case VGI_DITHER_RECTANGLE: /* dithered rectangle */ + sscanf(buffer,"%*s %i %i %i %i %i %i", &color1,&color2, &x1,&y1,&x2,&y2); printf(".byte $%02X,",(type<<4)|7); @@ -94,12 +137,39 @@ int main(int argc, char **argv) { printf("$%02X\n",color2); break; - case 15: /* end */ + case VGI_VERT_TRIANGLE: /* vertical triangle */ + sscanf(buffer,"%*s %i %i %i %i %i %i", + &color1, + &x1,&y1,&xl,&xr,&yb); + printf(".byte $%02X,",(type<<4)|7); + printf("$%02X,",color1); + printf("$%02X,",x1); + printf("$%02X,",y1); + printf("$%02X,",xl); + printf("$%02X,",xr); + printf("$%02X\n",yb); + break; + + case VGI_HORIZ_TRIANGLE: /* horizontal triangle */ + sscanf(buffer,"%*s %i %i %i %i %i %i", + &color1, + &x1,&y1,&yt,&yb,&xr); + printf(".byte $%02X,",(type<<4)|7); + printf("$%02X,",color1); + printf("$%02X,",x1); + printf("$%02X,",y1); + printf("$%02X,",yt); + printf("$%02X,",yb); + printf("$%02X\n",xr); + break; + + case VGI_END: /* end */ printf(".byte $FF\n"); break; default: - fprintf(stderr,"Unknown type %i\n",type); + fprintf(stderr,"Unknown type %i line %d\n", + type,line); break; } diff --git a/graphics/hgr/vgi/rocket.vgi b/graphics/hgr/vgi/rocket.vgi index 9d76b453..709fcc8b 100644 --- a/graphics/hgr/vgi/rocket.vgi +++ b/graphics/hgr/vgi/rocket.vgi @@ -1,22 +1,26 @@ ; 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 +CLS 255 ; white background +RECT 1 6 0 122 140 191 ; ocean left +RECT 1 6 140 122 279 191 ; ocean right ; base -6 0x8 0x22 86 124 193 191 ; green brick dock -3 7 99 121 4 ; left platform -3 7 180 121 4 ; right platform -1 7 7 99 119 175 125 ; platform -1 0 0 102 128 116 191 ; left shade -1 0 0 179 126 194 191 ; right shade -1 7 7 89 137 93 146 ; left light -1 7 7 186 139 190 147 ; right light +DRECT 0x8 0x22 86 124 193 191 ; green brick dock +FCIRC 7 99 121 4 ; left platform +FCIRC 7 180 121 4 ; right platform +RECT 7 7 99 119 175 125 ; platform +RECT 0 0 102 128 116 191 ; left shade +RECT 0 0 179 126 194 191 ; right shade +RECT 7 7 89 137 93 146 ; left light +RECT 7 7 186 139 190 147 ; right light +; walkway +VTRI 7 129 129 109 129 191 ; left path +RECT 7 7 129 129 151 191 ; center path +VTRI 7 151 129 151 170 191 ; right path ; wire -1 6 6 174 88 179 126 ; pole -1 6 6 174 73 179 80 ; insulator -4 6 177 90 ; thinner pole -5 177 74 ; to top -5 237 64 ; to top -;5 279 53 ; to top -5 255 60 ; to top -15 +RECT 6 6 174 88 179 126 ; pole +RECT 6 6 174 73 179 80 ; insulator +POINT 6 177 90 ; thinner pole +LINETO 177 74 ; to top +LINETO 237 64 ; to top +;LINETO 279 53 ; to top +LINETO 255 60 ; to top +END diff --git a/graphics/hgr/vgi/vgi.s b/graphics/hgr/vgi/vgi.s index 661edaa5..357b43e2 100644 --- a/graphics/hgr/vgi/vgi.s +++ b/graphics/hgr/vgi/vgi.s @@ -110,8 +110,8 @@ vgi_rts_table: .word vgi_point-1 ; 4 = dot .word vgi_lineto-1 ; 5 = line to .word vgi_dithered_rectangle-1 ; 6 = dithered rectangle - .word all_done-1 - .word all_done-1 + .word vgi_vertical_triangle-1 ; 7 = vertical triangle + .word vgi_horizontal_triangle-1 ; 8 = horizontal triangle .word all_done-1 .word all_done-1 .word all_done-1 @@ -128,6 +128,7 @@ all_done: .include "vgi_circles.s" .include "vgi_rectangle.s" .include "vgi_lines.s" +.include "vgi_triangles.s" .include "clock.data" .include "rocket.data" diff --git a/graphics/hgr/vgi/vgi_triangles.s b/graphics/hgr/vgi/vgi_triangles.s new file mode 100644 index 00000000..071572d0 --- /dev/null +++ b/graphics/hgr/vgi/vgi_triangles.s @@ -0,0 +1,39 @@ +; VGI Triangles + + ;======================== + ; VGI vertical triangle + ;======================== + + VGI_TCOLOR = P0 + VGI_VX = P1 + VGI_VY = P2 + VGI_TX1 = P3 + VGI_TX2 = P4 + +vgi_vertical_triangle: + + ldx VGI_TCOLOR + lda COLORTBL,X + sta HGR_COLOR + + ldy #0 + ldx VGI_VX + lda VGI_VY + + jsr HPLOT0 ; plot at (Y,X), (A) + + +; ldx #0 +; ldy VGI_LY +; lda VGI_LX + +; jsr HGLIN ; line to (X,A),(Y) + +; jmp vgi_loop + + + jmp vgi_loop + + +vgi_horizontal_triangle: + jmp vgi_loop