diff -c w2000a-screenshot-0.3/w2000a-screenshot.cpp w2000a-screenshot-0.3-dl3daz/w2000a-screenshot.cpp *** w2000a-screenshot-0.3/w2000a-screenshot.cpp 2009-07-02 17:55:07.000000000 +0200 --- w2000a-screenshot-0.3-dl3daz/w2000a-screenshot.cpp 2009-07-04 22:08:42.000000000 +0200 *************** *** 133,142 **** char fnam[256]; int r, pnum, rd, total, ppos; unsigned char c, l, b; ! int i; #ifdef WIN32 ! if (!ComOpen(0, 115200, P_NONE, S_1BIT, D_8BIT)) err(1, "Unable to open COM port"); #endif (void)fprintf(stderr, "* Waiting for Screenshot...\n"); --- 133,148 ---- char fnam[256]; int r, pnum, rd, total, ppos; unsigned char c, l, b; ! unsigned int i,j; ! ! unsigned char *buffer,*bufptr,*bufend; ! unsigned int llength=0; ! unsigned char cout,lastbyte=0,esc=0; ! int out,outcnt=0,incnt=0; ! #ifdef WIN32 ! if (!ComOpen(com, 115200, P_NONE, S_1BIT, D_8BIT)) err(1, "Unable to open COM port"); #endif (void)fprintf(stderr, "* Waiting for Screenshot...\n"); *************** *** 152,157 **** --- 158,209 ---- exit(1); (void)fprintf(stderr, "* Found Screenshot Start Marker\n"); + /********************************************************************* + * Allocate enough space for all planes + *********************************************************************/ + buffer=(unsigned char *)malloc(640*480*MAXPLANES/8); + if (!buffer) + err(1, "malloc %d failed", 640*480*MAXPLANES/8); + bufptr=buffer; + /********************************************************************* + * Read all from stdin/COMx, decompress and fill buffer + *********************************************************************/ + while (((r = rdchar()) >= 0) && (bufptr 0) { ! c = (unsigned char)r; rd++; ! if (rd % 100 == 0) ! (void)fprintf(stderr, "\r %d bytes...", rd); ! if (c == 255) ! break; ! b = 0x00; ! if (c & (1 << 7)) ! b = 0xff; ! c &= ~(1 << 7); ! ! for (i = 0; i < c; i++) { ! pixmaps[pnum][ppos++] = b; ! if (all) ! (void)fputc(b, fp); } } total += rd; rdplanes++; --- 221,239 ---- rd = 0; ppos = 0; ! /********************************************************************* ! * get data from buffers ! *********************************************************************/ ! while (bufptr 0) { ! c = (unsigned char)r; if (c == 'E') { (void)fprintf(stderr, "* End of Transmission\n"); break; --- 243,250 ---- if (all && fclose(fp) != 0) err(1, "fclose(%s) failed", fnam); ! if (bufptr<=bufend) { ! c=*bufptr++; if (c == 'E') { (void)fprintf(stderr, "* End of Transmission\n"); break; *************** *** 285,291 **** int ch, bflag; #ifdef WIN32 ! int com = 0; #endif bflag = 0; (void)snprintf(fnamprefix, sizeof(fnamprefix), "screenshot"); --- 333,339 ---- int ch, bflag; #ifdef WIN32 ! com = 0; #endif bflag = 0; (void)snprintf(fnamprefix, sizeof(fnamprefix), "screenshot"); *************** *** 298,304 **** #ifdef WIN32 case 'c': com = atoi(optarg) - 1; ! if (com < 0 || com > 9) err(1, "invalid COM port given, use -c n, where 0 < n < 10"); break; #endif --- 346,352 ---- #ifdef WIN32 case 'c': com = atoi(optarg) - 1; ! if (com < 0 || com > 8) err(1, "invalid COM port given, use -c n, where 0 < n < 10"); break; #endif