/* strypt -- encrypts/decrypts an Artworx "Strip Poker II" image file for Apple IIGS Last edit: 08-Jul-1990 Douglas A. Gwyn Usage: strypt [-z] old new This program copies an Apple IIGS Strip Poker Data Disk image file, decoding the pixel data in scan lines 0 through 146. If the -z option is used, it will also set all scan-line control bytes and the pixels in scan lines 147 through 199 to 0 in the output file; this is useful when decrypting a file preparatory to translating it to some other image file format such as GIF. The encryption scheme is self-inverse; i.e., the same program can be used (without the -z option) for either encryption or decryption of Artworx image files; presumably Artworx uses a similar program to encrypt their files before putting them on their Data Disks. These files contain uncompressed SHR images, normally assigned Apple File Type $C1, Auxiliary Type $0000; however, for maximum portability this program does not set the file type of its output file, which (depending on the C implementation) will probably be created with file type "BIN". Hence, you may need to use a file- type changing utility in order to make these output files acceptable as input to Apple IIGS display utilities that depend too much on Apple's File Type scheme. (SHRConvert 2.1 and ShowPic 4.6 do not require this.) Please note that Artworx images are NOT in the public domain and should therefore NOT be posted to public bulletin boards or information services. I am providing this program (which itself IS in the public domain) as a service to Apple IIGS owners, for their personal use only! There aren't many software publishers currently supporting the Apple IIGS; for our own self interest, we MUST respect the property rights of those who do support our machines. If somebody asks for a copy of Artworx images, give him this program instead and tell him to buy the Artworx Data Disks; they're cheap. As of this writing, the following Program and Data Disks have been released for the Apple IIGS: Strip Poker II: Suzi & Melissa Data Disk #1: Morgan & Kathy Data Disk #2: Samantha & Jack Data Disk #3: Gina & Holly Artworx Strip Poker II and Strip Poker Data Disks are available from enlightened software distributors; if you cannot find one, try writing to: Artworx Software Company, Inc. 1844 Penfield Road Penfield, New York 14526 Be sure to commend them for supporting the Apple IIGS! */ #ifdef __STDC__ #include /* for EXIT_*, exit() */ #define RB_MODE "rb" #define WB_MODE "wb" #else extern void exit(); #define RB_MODE "r" #define WB_MODE "w" #endif #include #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE #define EXIT_FAILURE (-1) /* Suitable for APW C */ #endif /* The following parameters specify IIGS Super Hi-Res addresses; a $C1/$0000 file is simply an exact copy of SHR address space. */ #define PIXELS ((unsigned)0x2000) /* start of pixel data (and file) */ #define TRAILER ((unsigned)0x7BE0) /* end of Artworx encipherment */ #define PALETS ((unsigned)0x9E00) /* start of color palettes */ main( argc, argv ) int argc; char *argv[]; { register unsigned short w; /* word being *crypted */ register int c; /* input character */ register unsigned short key = 0x1F2B; /* *cryption key */ register FILE *ifp; /* input stream */ register FILE *ofp; /* output stream */ unsigned p = PIXELS; /* -> next image byte */ int zero; /* set iff -z option */ if ( (zero = argc > 1 && argv[1][0] == '-' && argv[1][1] == 'z') ) ++argv, --argc; if ( argc != 3 ) { (void)fprintf( stderr, "Usage: strypt [-z] old new\n" ); exit( EXIT_FAILURE ); } if ( (ifp = fopen( argv[1], "rb" )) == NULL ) { (void)fprintf( stderr, "strypt: can't open input\n" ); exit( EXIT_FAILURE ); } if ( (ofp = fopen( argv[2], "wb" )) == NULL ) { (void)fprintf( stderr, "strypt: can't open output\n" ); exit( EXIT_FAILURE ); } while ( (c = getc( ifp )) != EOF ) { w = c; /* low byte */ w |= getc( ifp ) << 8; /* high byte */ if ( (p += 2) <= TRAILER ) w ^= key++; else if ( zero && p <= PALETS ) w = 0; if ( putc( (int)w & 0xFF, ofp ) == EOF || putc( (int)w >> 8, ofp ) == EOF ) { (void)fprintf( stderr, "strypt: write error\n" ); exit( EXIT_FAILURE ); } } (void)fflush( ofp ); /* just in case */ return EXIT_SUCCESS; }