vgi: update lines code

This commit is contained in:
Vince Weaver 2021-06-25 09:47:33 -04:00
parent 673a08f403
commit 598eb22da7
4 changed files with 65 additions and 9 deletions

View File

@ -12,6 +12,7 @@
#define VGI_VERT_TRIANGLE 7 #define VGI_VERT_TRIANGLE 7
#define VGI_HORIZ_TRIANGLE 8 #define VGI_HORIZ_TRIANGLE 8
#define VGI_VSTRIPE_RECTANGLE 9 #define VGI_VSTRIPE_RECTANGLE 9
#define VGI_LINE 10
#define VGI_END 15 #define VGI_END 15
/* non-encoded pseudo-values */ /* non-encoded pseudo-values */
@ -54,6 +55,9 @@ int main(int argc, char **argv) {
if (!strncmp(buffer,"LINETO",6)) { if (!strncmp(buffer,"LINETO",6)) {
type=VGI_LINETO; type=VGI_LINETO;
} }
else if (!strncmp(buffer,"LINE",4)) {
type=VGI_LINE;
}
if (!strncmp(buffer,"DRECT",5)) { if (!strncmp(buffer,"DRECT",5)) {
type=VGI_DITHER_RECTANGLE; type=VGI_DITHER_RECTANGLE;
} }
@ -215,6 +219,23 @@ int main(int argc, char **argv) {
size+=7; size+=7;
break; break;
case VGI_LINE: /* line */
sscanf(buffer,"%*s %i %i %i %i %i",
&color1,
&x1,&y1,&x2,&y2);
printf(".byte $%02X,",(type<<4)|6);
if (x1>255) {
x1=x1&0xff;
color1|=128;
}
printf("$%02X,",color1);
printf("$%02X,",x1);
printf("$%02X,",y1);
printf("$%02X,",x2);
printf("$%02X\n",y2);
size+=6;
break;
case VGI_END: /* end */ case VGI_END: /* end */
printf(".byte $FF\n"); printf(".byte $FF\n");
size+=1; size+=1;

View File

@ -206,7 +206,7 @@ vgi_rts_table:
.word vgi_vertical_triangle-1 ; 7 = vertical triangle .word vgi_vertical_triangle-1 ; 7 = vertical triangle
.word vgi_horizontal_triangle-1 ; 8 = horizontal triangle .word vgi_horizontal_triangle-1 ; 8 = horizontal triangle
.word vgi_vstripe_rectangle-1 ; 9 = vstripe rectangle .word vgi_vstripe_rectangle-1 ; 9 = vstripe rectangle
.word all_done-1 .word vgi_line-1 ;10 = line
.word all_done-1 .word all_done-1
.word all_done-1 .word all_done-1
.word all_done-1 .word all_done-1

View File

@ -3,16 +3,23 @@ CLS 255 ; white background
RECT 1 5 0 85 140 191 ; ground left RECT 1 5 0 85 140 191 ; ground left
RECT 1 5 140 85 279 191 ; ground right RECT 1 5 140 85 279 191 ; ground right
; tower ; tower
DRECT 0x4c 0x33 216 22 235 33 ; tower ;DRECT 0x4c 0x33 216 22 235 33 ; tower
DRECT 0x4c 216 216 22 235 33 ; tower
;RECT 6 6 216 22 235 33 ; tower
RECT 5 5 216 33 236 56 ; mountain RECT 5 5 216 33 236 56 ; mountain
VTRI 5 216 33 207 216 60 ; mountain VTRI 5 216 33 207 216 60 ; mountain
; temple ; temple
DRECT 0x4c 0x33 181 56 237 96 ; tower DRECT 0x4c 0x33 181 56 237 96 ; tower
VTRI 0 204 53 186 225 60 ; triangle VTRI 0 204 53 186 225 60 ; triangle
RECT 0 0 203 68 211 81 ; door RECT 0 0 203 68 211 81 ; door
POINT 7 189 68 LINE 7 189 68 189 82 ; columns
LINETO 189 82 LINE 7 197 67 197 84
POINT 7 197 67 LINE 7 214 80 214 66
LINETO 197 84 LINE 7 224 78 223 65
POINT 7 ; marker switch
RECT 5 5 209 76 217 86 ; marker switch
; trees
RECT 5 5 98 0 101 114 ; tree ?
VTRISK 1 97 0 88 110 87 4 ; leaves?
VTRISK 1 101 0 88 110 87 4 ; leaves?
END END

View File

@ -3,12 +3,20 @@
;======================== ;========================
; VGI point ; VGI point
;======================== ;========================
vgi_point:
jsr vgi_point_common
jmp vgi_loop
;========================
; VGI point common
;========================
VGI_PCOLOR = P0 ; if high bit set, then PX=PX+256 VGI_PCOLOR = P0 ; if high bit set, then PX=PX+256
VGI_PX = P1 VGI_PX = P1
VGI_PY = P2 VGI_PY = P2
vgi_point: vgi_point_common:
ldy #0 ldy #0
lda VGI_PCOLOR lda VGI_PCOLOR
@ -25,7 +33,7 @@ vgi_point_color:
jsr HPLOT0 ; plot at (Y,X), (A) jsr HPLOT0 ; plot at (Y,X), (A)
jmp vgi_loop rts
@ -44,3 +52,23 @@ vgi_lineto:
jsr HGLIN ; line to (X,A),(Y) jsr HGLIN ; line to (X,A),(Y)
jmp vgi_loop jmp vgi_loop
;========================
; VGI LINE
;========================
; VGI_LX = P0
; VGI_LY = P1
VGI_LX2 = P3
VGI_LY2 = P4
vgi_line:
jsr vgi_point_common
ldx #0
ldy VGI_LY2
lda VGI_LX2
jsr HGLIN ; line to (X,A),(Y)
jmp vgi_loop