From a6aa19c8b90a3f99d17f56fb0f9a709b2e58ce08 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 9 May 2012 16:09:47 -0400 Subject: [PATCH] Add preliminary support for plotting graphs --- asoft_presenter.c | 123 +++++++++++++++++++++++++++--- presenter_demo/Makefile | 6 +- presenter_demo/info | 3 +- presenter_demo/slide_wattsup_plot | 49 ++++++++++++ shape_table.c | 81 ++++++++++++++++---- 5 files changed, 233 insertions(+), 29 deletions(-) create mode 100644 presenter_demo/slide_wattsup_plot diff --git a/asoft_presenter.c b/asoft_presenter.c index d541fe1d..6c383161 100644 --- a/asoft_presenter.c +++ b/asoft_presenter.c @@ -77,6 +77,8 @@ static void print_line(unsigned char c, int num) { } + + static void center_comment(unsigned char c, int max_len, char *string) { int half_len; @@ -131,19 +133,20 @@ struct footer_info { char *center; }; -#define SLIDE_40COL 0 -#define SLIDE_80COL 1 -#define SLIDE_HGR 2 -#define SLIDE_HGR2 3 +#define SLIDE_40COL 0 +#define SLIDE_80COL 1 +#define SLIDE_HGR 2 +#define SLIDE_HGR2 3 +#define SLIDE_HGR_PLOT 4 -#define MAX_SLIDES 100 +#define MAX_SLIDES 89 struct slide_info { int type; char *filename; }; -#define LINES_PER_SLIDE 30 +#define LINES_PER_SLIDE 100 static void generate_slide(int num, int max, char*filename) { @@ -173,23 +176,118 @@ static void generate_slide(int num, int max, char*filename) { fprintf(stderr,"Couldn't open %s!\n",filename); } else { + int address=0x6000; + int num_plots=0,plot,color; + double maxx,maxy,x,y; + int applex,appley,hplot_num,first=1; + +#define HPLOTS_ON_LINE 5 result=fgets(type,BUFSIZ,fff); - if (strstr(type,"HGR2")) { + if (strstr(type,"HGR_PLOT")) { + printf("%d IF ST%%=1 GOTO %d\n",line_num,line_num+3); line_num++; + printf("%d PRINT CHR$(4);\"BLOAD NUM.SHAPE\"\n",line_num); line_num++; + printf("%d POKE 232,%d: POKE 233,%d : ROT=0: SCALE=3: ST%%=1\n", + line_num,address&0xff,(address>>8)&0xff); line_num++; + + printf("%d HGR\n",line_num); line_num++; + + /* get the size */ + while(1) { + result=fgets(string,BUFSIZ,fff); + if (result==NULL) break; + if ((string[0]=='#') || (string[0]=='\n')) continue; + sscanf(string,"%lf %lf",&maxx,&maxy); + break; + } + + /* get number of plots */ + while(1) { + result=fgets(string,BUFSIZ,fff); + if (result==NULL) break; + if ((string[0]=='#') || (string[0]=='\n')) continue; + sscanf(string,"%d",&num_plots); + break; + } + + for(plot=0;plot NUM.SHAPE + TITLE.IMG: title.pcx ../pcx2hgr ../pcx2hgr title.pcx > TITLE.IMG diff --git a/presenter_demo/info b/presenter_demo/info index 5029399d..0f398ef0 100644 --- a/presenter_demo/info +++ b/presenter_demo/info @@ -8,9 +8,10 @@ EMAIL vweaver1@eecs.utk.edu SLIDES +slide_wattsup_plot slide_rapl_intro slide_rapl_continued slide_rapl_more slide_rapl_finish slide_title -END_SLIDES \ No newline at end of file +END_SLIDES diff --git a/presenter_demo/slide_wattsup_plot b/presenter_demo/slide_wattsup_plot new file mode 100644 index 00000000..6ded5de0 --- /dev/null +++ b/presenter_demo/slide_wattsup_plot @@ -0,0 +1,49 @@ +HGR_PLOT +40 70 +1 +START +1 +0 32.4 +1 32.3 +2 52.8 +3 42.3 +4 65.3 +5 66.2 +6 66.3 +7 63.7 +8 66.3 +9 66.7 +10 66.5 +11 67.6 +12 67.4 +13 67.6 +14 67.9 +15 63.8 +16 67.3 +17 65.2 +18 68.6 +19 68.5 +20 65.0 +21 68.7 +22 67.3 +23 67.2 +24 69.2 +25 63.6 +26 68.1 +27 63.7 +28 63.3 +29 65.8 +30 64.0 +31 69.4 +32 68.1 +33 64.5 +34 64.1 +35 66.9 +36 68.4 +37 57.7 +38 35.4 +39 35.1 +STOP +WATTS TIME(seconds) + +Blah Blah Blah Measured diff --git a/shape_table.c b/shape_table.c index 8a86711b..5fc6506b 100644 --- a/shape_table.c +++ b/shape_table.c @@ -5,6 +5,7 @@ #include #include +#include #define MAX_SIZE 8192 /* not really, but anything larger would be crazy */ @@ -35,6 +36,15 @@ static void warn_if_zero(unsigned char byte, int line) { } +void print_usage(char *exe) { + printf("Usage:\t%s [-h] [-a] [-b]\n\n",exe); + printf("\t-h\tprint this help message\n"); + printf("\t-a\toutput shape table in applesoft BASIC format\n"); + printf("\t-b\toutput shape table in binary format for BLOADing\n"); + printf("\n"); + exit(1); +} + int main(int argc, char **argv) { char string[BUFSIZ]; @@ -46,6 +56,28 @@ int main(int argc, char **argv) { int command=0,sub_pointer; + int output_binary=0; + + if (argc<2) { + output_binary=0; + } + + else { + if (argv[1][0]=='-') { + + switch(argv[1][1]) { + + case 'h': print_usage(argv[0]); + case 'b': output_binary=1; + break; + case 'a': output_binary=0; + break; + default: printf("Unknown options %s\n",argv[1]); + print_usage(argv[0]); + } + } + } + while(1) { result=fgets(string,BUFSIZ,stdin); if (result==NULL) break; @@ -155,24 +187,43 @@ int main(int argc, char **argv) { table_size=current_offset; - /* put near highmem */ - int address=0x1ff0-table_size; + if (output_binary) { + unsigned char header[4]; + int offset=0x6000; + + header[0]=offset&0xff; + header[1]=(offset>>8)&0xff; + header[2]=table_size&0xff; + header[3]=(table_size>>8)&0xff; - printf("10 HIMEM:%d\n",address); - printf("20 POKE 232,%d:POKE 233,%d\n",(address&0xff),(address>>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"); + fprintf(stderr,"Be sure to POKE 232,%d : POKE 233,%d\n" + "\tto let applesoft know the location of the table\n", + offset&0xff,(offset>>8)&0xff); - for(i=0;i>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