From 6b6d6d021693744fe75948e74aed0e6b1a6fcaca Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 9 May 2012 13:06:08 -0400 Subject: [PATCH] Improve shape table program Now fully functional. Will also warn you if your shape table has zero fields that will be ignored. --- presenter_demo/num.table | 158 +++++++++++++++++++++++++++++++++++++++ shape_table.c | 132 +++++++++++++++++++++++++++++--- 2 files changed, 278 insertions(+), 12 deletions(-) create mode 100644 presenter_demo/num.table diff --git a/presenter_demo/num.table b/presenter_demo/num.table new file mode 100644 index 00000000..9a0829ba --- /dev/null +++ b/presenter_demo/num.table @@ -0,0 +1,158 @@ +# Number of shapes +13 +# Number "0" +START +NUP +RT +DN +DN +LT +LT +UP +UP +RT +STOP +# Number "1" +START +NUP +DN +DN +STOP +# Number "2" +START +NUP +NLT +RT +RT +DN +LT +LT +DN +RT +RT +STOP +# Number "3" +START +NUP +NLT +RT +RT +DN +LT +LT +NRT +NRT +DN +LT +LT +STOP +# Number "4" +START +NUP +NLT +DN +RT +RT +UP +NDN +DN +STOP +# Number "5" +START +NUP +NRT +LT +LT +DN +RT +RT +DN +LT +LT +STOP +# Number "6" +START +NUP +NRT +LT +LT +DN +RT +RT +DN +LT +LT +UP +STOP +# Number "7" +START +NUP +NLT +RT +RT +DN +DN +STOP +# Number "8" +START +LT +UP +# +RT +RT +# +DN +LT +NRT +# +DN +LT +# +LT +UP +STOP +# Number "9" +START +LT +UP +# +RT +RT +# +DN +LT +NRT +# +DN +STOP +# "." +START +NDN +UP +STOP +# "-" +START +LT +NRT +# +RT +STOP +# "W" +START +NUP +NLT +# +DN +DN +# +RT +UP +# +RT +DN +# +RT +UP +# +UP +STOP \ No newline at end of file diff --git a/shape_table.c b/shape_table.c index 7a6e1351..8a86711b 100644 --- a/shape_table.c +++ b/shape_table.c @@ -1,4 +1,7 @@ -/* http://www.atariarchives.org/cgp/Ch03_Sec05.php */ +/* Creates an AppleSoft BASIC shape table */ +/* See the AppleSoft manual for info on how this works */ +/* Other online info (I'm looking at you, atariarchives.org) */ +/* is inaccurate */ #include #include @@ -13,6 +16,25 @@ void set_offset(current_shape,current_offset) { table[2+(current_shape*2)+1]=(current_offset>>8)&0xff; } +#define LOC_A 0 +#define LOC_B 1 +#define LOC_C 2 + +static void warn_if_zero(unsigned char byte, int line) { + + /* Check to see if we're accidentally ignoring bytes */ + if (byte==0) { + fprintf(stderr,"Warning, all-0 byte will be ignored on line %d!\n", + line); + } + + if ((byte&0xf8)==0) { + fprintf(stderr,"Warning, ignoring C and B due to 0 on line %d!\n", + line); + } + +} + int main(int argc, char **argv) { char string[BUFSIZ]; @@ -20,21 +42,24 @@ int main(int argc, char **argv) { int table_size=0; int num_shapes=0; int current_offset=0,current_shape=0; - int i; + int i,line=1; + int command=0,sub_pointer; while(1) { result=fgets(string,BUFSIZ,stdin); if (result==NULL) break; + line++; /* skip comments and blank lines */ if ((string[0]=='#') || (string[0]=='\n')) continue; sscanf(string,"%d",&num_shapes); + break; } - printf("Num shapes: %d\n",num_shapes); + //fprintf(stderr,"Num shapes: %d\n",num_shapes); table[0]=num_shapes; table[1]=0; @@ -42,23 +67,106 @@ int main(int argc, char **argv) { current_shape=0; current_offset=2+2*(num_shapes); - set_offset(current_shape,current_offset); + for(current_shape=0;current_shape>8)&0xff); + printf("30 FOR L=%d TO %d: READ B:POKE L,B:NEXT L\n", + address,(address+table_size)-1); + printf("35 HGR:ROT=0:SCALE=2\n"); + printf("40 FOR I=1 TO %d: XDRAW I AT I*10,100:NEXT I\n", + num_shapes); + printf("90 END\n"); + for(i=0;i