dos33fsprogs/graphics/gr/boxes/make_boxes.c

72 lines
1.1 KiB
C
Raw Normal View History

2021-01-21 06:32:06 +00:00
#include <stdio.h>
int main(int argc, char **argv) {
char buffer[1024];
char *ptr;
int color,x1,x2,y1,y2;
char output[1024];
int out_ptr=0;
int old_color=0xff;
2021-01-21 15:43:38 +00:00
#if 0
2021-01-21 06:32:06 +00:00
while(1) {
ptr=fgets(buffer,1024,stdin);
if (ptr==NULL) break;
sscanf(buffer,"%d %d %d %d %d",
&color,&x1,&x2,&y1,&y2);
// printf("\t.byte $%02X,$%02X,$%02X,$%02X,$%02X\n",
// color,x1,x2,y1,y2);
if (color==old_color) {
printf("\t.byte $%02X,$%02X,$%02X,$%02X\n",
y1|0x80,y2,x1,x2);
}
else {
printf("\t.byte $%02X,$%02X,$%02X,$%02X,$%02X\n",
color,y1,y2,x1,x2);
}
old_color=color;
// output[out_ptr]=color+32;
// output[out_ptr+1]=x1+32;
// output[out_ptr+2]=x2+32;
// output[out_ptr+3]=y1+32;
// output[out_ptr+4]=y2+32;
// out_ptr+=5;
}
// output[out_ptr]=0;
// printf("%s\n",output);
printf("\t.byte $FF\n");
2021-01-21 15:43:38 +00:00
#endif
while(1) {
ptr=fgets(buffer,1024,stdin);
if (ptr==NULL) break;
sscanf(buffer,"%d %d %d %d %d",
&color,&x1,&x2,&y1,&y2);
printf("\t.byte $%02X,$%02X,$%02X,$%02X\n",
y1,y2,
((color&0x03)<<6)|x1,
((color&0x0c)<<4)|x2);
}
printf("\t.byte $FF\n");
2021-01-21 06:32:06 +00:00
return 0;
}