From 228292906536168ffdb56ecb3812d2b3a88f2a70 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 8 May 2012 17:06:23 -0400 Subject: [PATCH] Initial support for a program that builds shape tables --- Makefile | 10 ++++++-- shape_table.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 shape_table.c diff --git a/Makefile b/Makefile index ceb43f6f..2cc498fd 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/shape_table.c b/shape_table.c new file mode 100644 index 00000000..7a6e1351 --- /dev/null +++ b/shape_table.c @@ -0,0 +1,71 @@ +/* http://www.atariarchives.org/cgp/Ch03_Sec05.php */ + +#include +#include + +#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