Initial support for a program that builds shape tables

This commit is contained in:
Vince Weaver 2012-05-08 17:06:23 -04:00
parent fa23256a40
commit 2282929065
2 changed files with 79 additions and 2 deletions

View File

@ -4,7 +4,7 @@ LFLAGS =
all: dos33 asoft_detoken mkdos33fs make_b tokenize_asoft \
dos33_text2ascii integer_detoken char2hex pcx2hgr \
asoft_presenter
asoft_presenter shape_table
@ -26,6 +26,12 @@ integer_detoken: integer_detoken.o
integer_detoken.o: integer_detoken.c
$(CC) $(CFLAGS) -c integer_detoken.c
shape_table: shape_table.o
$(CC) $(LFLAGS) -o shape_table shape_table.o
shape_table.o: shape_table.c
$(CC) $(CFLAGS) -c shape_table.c
tokenize_asoft: tokenize_asoft.o
$(CC) $(LFLAGS) -o tokenize_asoft tokenize_asoft.o
@ -76,7 +82,7 @@ install:
clean:
rm -f *~ *.o asoft_detoken dos33 make_b mkdos33fs \
tokenize_asoft dos33_text2ascii integer_detoken \
char2hex pcx2hgr asoft_presenter
char2hex pcx2hgr asoft_presenter shape_table
cd tests && make clean
cd presenter_demo && make clean

71
shape_table.c Normal file
View File

@ -0,0 +1,71 @@
/* http://www.atariarchives.org/cgp/Ch03_Sec05.php */
#include <stdio.h>
#include <string.h>
#define MAX_SIZE 8192 /* not really, but anything larger would be crazy */
static unsigned char table[MAX_SIZE];
void set_offset(current_shape,current_offset) {
table[2+(current_shape*2)]=current_offset&0xff;
table[2+(current_shape*2)+1]=(current_offset>>8)&0xff;
}
int main(int argc, char **argv) {
char string[BUFSIZ];
char *result;
int table_size=0;
int num_shapes=0;
int current_offset=0,current_shape=0;
int i;
while(1) {
result=fgets(string,BUFSIZ,stdin);
if (result==NULL) break;
/* skip comments and blank lines */
if ((string[0]=='#') || (string[0]=='\n')) continue;
sscanf(string,"%d",&num_shapes);
}
printf("Num shapes: %d\n",num_shapes);
table[0]=num_shapes;
table[1]=0;
current_shape=0;
current_offset=2+2*(num_shapes);
set_offset(current_shape,current_offset);
/* Find START */
while(1) {
result=fgets(string,BUFSIZ,stdin);
if (result==NULL) break;
/* skip comments and blank lines */
if ((string[0]=='#') || (string[0]=='\n')) continue;
if (!strstr(string,"START")) continue;
}
table_size=current_offset;
for(i=0;i<current_offset;i++) {
if(i%10==0) printf("%d DATA ",100+i/10);
printf("%d",table[i]);
if ((i%10==9)||(i==current_offset-1)) printf("\n");
else printf(",");
}
return 0;
}