home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
graf
/
macpnt1.zip
/
MACPAINT.C
< prev
next >
Wrap
Text File
|
1987-01-18
|
30KB
|
1,105 lines
/*
* Program to read and otherwise manipulate files produced by Macpaint
* on the Apple Macintosh, as well as RLE files.
*
* Written 1/2/87 by Joan Riff for Computerwise Consulting Services.
*
*
*
************************************************************************
*
* (c) Copyright 1987 by:
*
* Computerwise Consulting Services
* P.O. Box 813
* McLean, VA 22101
* (703) 280-2809
*
* All rights reserved.
*
* Permission is granted for personal use of this program, with the
* exception that the following potential users ARE EXPLICITLY DENIED
* PERMISSION TO RECEIVE, USE, OR TRANSFER THIS PROGRAM IN SOURCE OR
* OBJECT OR EXECUTABLE OR ANY OTHER FORM:
*
* 1) Lotus Development Corporation, and any employee thereof
* or consultant thereto;
*
* 2) ADAPSO, and any firm which is a member thereof, or any
* employee of such a firm.
*
* These two organizations have - in the opinion of CCS - acted as
* "software pirates" by continually and intentionally violating
* U.S. Copyright law, specifically by first "copy-protecting" software
* disks and then zealously prosecuting innocent users who exercised
* their rights under the law to make copies of their own property.
*
* Further, permission is granted to transfer this program only if
* it is transferred absolutely unmodified in any form.
*
************************************************************************
*
*
* This program:
*
* 1) Recognizes various versions of MACPAINT files (including
* improper "short" files)
* 2) Supports (and automatically detects) the CGA, EGA, and HERCULES
* 3) Allows printing of the pictures to various printers
* 4) What the heck! It supports RLE files too!
*
*
* HELP! I saw an EGA for the first time last night. The code that I have
* used to put the image to the EGA ** seems ** to work, but I would
* prefer to have some EGA heavy look it over and give me feedback.
* Call our answering machine at (703) 280-2809 with results.
*
* This program is written for Microsoft C version 3.0, and is compiled
* with the following batch file:
*
* CL -Ml -K /Zp /Ze /Fefoo macpaint.c
* exepack foo.exe macpaint.exe
* erase macpaint.obj
* erase foo.exe
*
*/
/*
*********************************************************************
* About MACPAINT files
*********************************************************************
*
* On the MAC, the picture was a grid of 720 lines, each holding 576
* pixels (72 bytes per line). This 720x576 image corresponded to an
* 8"x10" page image (72 dots per inch).
*
* There are exactly 72 bytes (576 pixels) encoded for each line, and
* exactly 720 lines represented. The encoding is as follows:
*
* <count> <data> [<data>...] <count> <data> [<data>...]
*
* <count> = number of MAC bytes accounted for by this sequence, minus 1
*
* Example: 71 = 72 bytes accounted for
* 18 = 19 bytes accounted for
*
* If this count has the high-order bit set (0x80), then negate
* it before adding 1 to it.
*
* Example: -2 (0xFE) = 3 bytes accounted for
* -71 (0xB9) = 72 bytes accounted for
*
* <data> = data byte(s), per count:
*
* If <count> was negative, then <data> is a single byte to
* be repeated <count> times.
*
* Example: -71 0 (0xB9 0x00) = 72 bytes of zero (a blank line)
*
* Otherwise, it is a single byte of output pixel data, and
* as many subsequent bytes are to be treated as such as
* <count> says.
*
* Now, all of this would be too simple. So in real life what we find are
* one or two special header records prepended to the file. They are explained
* in the _macpaint structure below. The first - the MacBinary header - is put
* there by MacBinary-compatible Mac communications programs, and serves to
* allow the resultant file to be properly created on the Mac. The second is
* put there by MacPaint itself, and defines brush/fill patterns etc.
*
* NOTE: There is another type of file that we have run across - one formatted
* as a "StartupScreen" file. This one seems to include the 128-byte
* MacBinary header, but has no 512-byte MacPaint header. In addition,
* the image data for such a file IS NOT encoded per the above, but
* seems to be a raw image organized as n 64-byte lines. This data can
* just be used as-is (properly centered within our 72-byte image, that is).
*
*/
/*
*********************************************************************
* About RLE files
*********************************************************************
*
* RLE stands for "Run Length Encoded". This is a crude method of
* encoding a graphics image as ASCII characters. It is used by CompuServe
* to present graphic data during an otherwise alphanumeric session.
*
* There are two types of RLE files:
*
* 1) "High resolution" data, which forms an image 256 pixels wide
* by 192 pixels high. OK, so that's not very high resolution.
* This is CompuServe's terminology, not mine.
*
* 2) "Medium Resolution" (How can you get any lower!!!???) data, which
* forms an image 128 pixels wide by 96 pixels high.
*
* Both of these are mono images, although there are rumors of support for
* color and higher resolution "Real Soon Now".
*
* Compared to MacPaint files, these are certainly primitive. RLE's saving grace
* is that there is a wealth of encoded RLE graphics images on CompuServe. For
* this reason - and since we have already done all of the video display and
* printer code for the MacPaint files anyway - we decided to throw in support
* for this RLE format too.
*
* An RLE file has the following format:
*
* 1) A "start graphics" escape code:
*
* a) "<ESC> G H" if this is a High Resolution file
* b) "<ESC> G M" if this is a Medium Resolution file
*
* 2) Data itself, as pairs of ASCII characters. Each is a count, with
* 32 decimal (ASCII blank) added to it. The first byte of each pair
* is the number of background (black) pixels to be set, and the
* second is the number of foreground (white) pixels to be set. Data
* wraps from the end of one line to the next.
*
* 3) An "end graphics" escape code: "<ESC> G N". This is actually an
* offshoot of the VIDTEX protocol, which means "return to normal
* mode" (hence the "N").
*
* NOTE: Not all files have the "<ESC> G N" at the end. The best test that we've
* found is as follows:
*
* 1) Physical end of file, or
* 2) Full picture has been received (256x192 or 128x96 pixels), or
* 3) "<ESC> G N" found in data
*
* whichever comes first.
*
* NOTE: There may be embedded control chars in the data. Besides checking for
* the terminating "<ESC> G N", these should be ignored.
*
* Because RLE images are so small, this program will load up to six RLE
* pictures into each screen image, and display all six at once. This makes
* for a nice "gallery" of these smaller images. They can they be saved
* as one MacPaint picture via the "Write" command.
*
*/
/*
*********************************************************************
* About Color and Sizing
*********************************************************************
*
* COLOR:
*
* In MacPaint files, a 0 bit corresponds to one pixel of the background
* color, and a 1 bit to one pixel of the foreground color. We can't tell
* from a given picture's data whether the 1 bits were the "on" color or
* the 0 bits were.
*
* With RLE files, the same applies. All we know is that the first data
* entry describes how many "background" pixels to plot, and from there
* on the data bytes alternately describe "foreground" and "background"
* pixels.
*
* What this means in short is that only the user looking at the screen can
* decide what looks right. We have included a command to invert the screen
* image, changing foreground to background and vice versa. This allows the
* user to produce whatever looks best.
*
* Note that printed images may need to be inverted in order to look nice.
* Again, there's no way that this program can figure it out. Some pictures
* have shading, others are simple white-on-black images. Caveat Practicum.
*
* SIZING:
*
* The aspect ration of the original artist's creation is lost to us. If we
* make the assumption that a MacPaint picture looked "about right" in terms
* of the vertical versus horizontal dimensions, then we can translate this
* into something close on the various video adapters that are supported. This
* program does this. In doing this, it must handle the CGA (boo!) by
* squishing the picture vertically. This loses a tremendous amount of
* clarity, ESPECIALLY WHEN VIEWING RLE FILES (which didn't have a lot of
* resolution to start with). Note, however, that the printed image will
* show full resolution.
*
*/
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <dos.h>
#include <io.h>
/*
* Local function definitions for any that don't return an int
*/
typedef unsigned char BYTE;
BYTE * wildcard();
BYTE * decode();
BYTE * adjust();
BYTE vslice();
long ticker();
unsigned write_pic();
/*
* Video adapter types
*/
#define TYPE_NONE 0 /* No video adapter (or printer) selected */
#define TYPE_HERC 1 /* Hercules Mono adapter (720x348) */
#define HERC_HORIZ 720
#define HERC_VERT 348
#define TYPE_CGA 2 /* IBM CGA (640x200) */
#define CGA_HORIZ 640
#define CGA_VERT 200
#define TYPE_EGA 3 /* IBM EGA (640x350) */
#define EGA_HORIZ 640
#define EGA_VERT 350
/*
* Macros to return line and column positions for RLE image number n (0-5)
*/
#define RLE_LINE(n) ( (((n/2) % 3) * (MAC_VERT/3)) + 36 )
#define RLE_COL(n) ( ((n&1) * ((MAC_HORIZ/8)/2)) + 2 )
/*
* Misc equates
*/
#define NEAR near /* 16-bit address here, please */
#define NASTY 1 /* Non-zero for -OK option enforcement */
#define DEBUG 0 /* Non-zero for our decode-timing stats, etc */
#define MAC_HORIZ (576) /* Pixels across a MACPAINT picture */
#define MAC_VERT (720) /* Lines in a MACPAINT picture */
#define GRAPHICS (-1) /* Request for GRAPHICS mode */
#define TEXT 0 /* Request for TEXT mode */
#define JUMP 40 /* Number of lines to jump with PgUp PgDn */
#define COLOR 11 /* Initial color to use on EGA and CGA (1-15) */
#define ENCODED 1 /* Data is encoded as we would expect */
#define RAW 2 /* Data is NOT encoded, but is raw image */
/*
* Structure of a MACPAINT file.
*
* NOTE: Because this comes off of a 68000 system, binary values ARE NOT
* byte-swapped as they are on the 8086. A 16-bit binary 5, for
* example, appears as "00 05" AND NOT as "05 00" as it would on
* the 8086.
*/
struct _macpaint
{
/*
* 128-byte header added by MACBINARY-compatible Macintosh
* communications programs. This is not present on all files
* that we've seen. It depends on who uploaded the file, and
* whether they knew what they were doing.
*/
struct _macbinary_header
{
BYTE version; /* Macbinary version number? Normally zero */
BYTE name_size; /* # bytes used in following filename */
BYTE filename[63]; /* Filename itself */
/*
* Info for use by the Mac Finder
*/
struct _finder_info
{
BYTE file_type[4]; /*
* Examples that we've seen:
*
* SCRN = StartupScreen
* PNTG = painting
*/
BYTE creator[4]; /*
* Examples that we've seen:
*
* NONE = StartupScreen
* PANT = Fullpaint
* MPNT = Macpaint
*/
BYTE flags; /*
* Bit 7 = locked
* Bit 6 = invisible
* Bit 5 = bundle
* Bit 4 = system
* Bit 3 = Bozo
* Bit 2 = busy
* Bit 1 = changed
* Bit 0 = Init'd
*/
BYTE zero; /* A zero byte */
unsigned vert_pos; /* File's vertical position within its window */
unsigned horiz_pos; /* File's horizontal position within its window */
unsigned ID; /* ID of file's window or folder */
}
finder_info;
BYTE flag; /* Bit 0 = "protected" */
BYTE zero; /* A zero byte */
unsigned long data_fork_length; /* Length of data fork (the picture data itself) */
unsigned long resource_fork_length; /* Length of resource fork (normally zero) */
BYTE create_date[4]; /* File's creation date */
BYTE modified_date[4]; /* File's "last modified" date */
BYTE reserved[27];
BYTE OS_ID[2]; /* Reserved for OS and computer ID */
}
macbinary_header;
/*
* 512-byte header put on file (and used) by Macpaint. StartupScreen
* files don't have this, but ALL OTHERS DO!!!
*/
struct _header
{
unsigned long version; /*
* Macpaint version number:
*
* 2 = Macpaint
* 3 = FullPaint
*/
BYTE patterns[38][8]; /* Brush/fill patterns */
BYTE filler[84]; /* Used by Macpaint? */
/*
* Area used by FullPaint, but presumably unused by Macpaint
*/
struct _fullpaint
{
unsigned selected_font_number;
unsigned selected_font_size;
unsigned user_font_size;
BYTE user_font_size_ON; /* Boolean value */
BYTE font_face;
unsigned alignment; /* 1=left, 2=middle, 3=right */
BYTE grid_ON; /* Boolean value */
BYTE rulers_ON; /* Boolean value */
BYTE mode; /* 0 = normal, 1 = FatBits */
BYTE ruler_units;
unsigned selected_pattern;
BYTE visible_rectangle[8];
BYTE FatBits_view_rectangle_point[4];
BYTE FatBits_point[4];
BYTE desk_rectangle[8];
BYTE filler[80];
}
fullpaint;
}
header;
/*
* Start of actual Macpaint picture data bytes
*/
BYTE picture_data[1]; /* First of many bytes */
};
/*
* Global data
*/
/*
* Flag to force exit from program
*/
static int time2quit = 0; /* Non-zero to exit */
/*
* Variables used to support RLE pictures
*/
static int rle_pic = 0; /* Number of RLE pictures on the screen */
static unsigned rle_horiz[6] = /* Horizontal sizes of 6 RLE images */
{ 0,0,0,0,0,0 };
static unsigned rle_vert[6] = /* Vertical sizes of 6 RLE images */
{ 0,0,0,0,0,0 };
/*
* Palette values for background and foreground. EGA uses both. CGA
* uses fg_color only, as value for the Color-Select Register.
* HERC uses neither.
*/
static int bg_color = 0;
static int fg_color = COLOR;
/*
* Current mode that we're in (TEXT or GRAPHICS)
*/
static int cur_mode = TEXT;
/*
* Flag indicating that -OK arg was present on command line
*/
static int ok_flag = 0;
/*
* Flag controlling print-only of all files.
*/
static int print_all = 0; /* Non-zero to just print all files */
/*
* Flag indicating the type of image data we have in this file
* (either ENCODED or RAW).
*/
static int data_type = ENCODED;
/*
* Fill value (1's or 0's) to be used to fill screen areas outside
* of actual image bounds.
*/
static BYTE fill_type = 0;
/*
* Number of lines in non-RLE image. This basically tells us
* how many true data lines we had in a short MacPaint file.
* The picture may have been short because it's a corrupted
* MacPaint file, or because it's a StartupScreen image.
*/
static int end_of_image = 0;
/*
* Flag controlling automatic invert() of next file
*/
static int auto_invert = 0; /* Non-zero to do auto invert of next file */
/*
* Flag controlling automatic invert() of all files
*/
static int all_invert = 0; /* Non-zero to do auto invert of all files */
#if DEBUG
/*
* Timings (in clock ticks) of decodes of each input file. These allow
* us to see what effect various speed improvement changes actually have
* on picture decode times. That RLE format is a killer!
*/
static long elapsed[50] = { 0L }; /* Elapsed ticks for each decode */
static int next_elapsed = 0; /* Next free entry in above table */
#endif
/*
* "Printer has hit an error, and we are to cancel current print" flag
*/
static int print_error = 0; /* Non-zero if cancelling current print */
/*
* What type of video adapter we have
*/
static int screen_type = TYPE_NONE;
/*
* What type of printer we have. This is an index into printers[],
* or -1 if we haven't specified one yet.
*/
static int print_type = -1;
/*
* Printer names, descriptions, and escape sequences
*/
static struct _printer
{
BYTE *name; /* Short name for this printer */
BYTE *desc; /* Description of it */
BYTE *crlf; /* String sent to move to next line */
BYTE *page_init; /* String sent at start of dump */
BYTE *line_init; /* String sent before data bytes ("enter graphics mode") */
BYTE *line_end; /* String sent after data bytes ("exit graphics mode") */
BYTE *wrapup; /* String sent after whole dump is done */
int buffered; /*
* How data bytes are sent:
*
* 0 = send 1 byte at a time, edited
* per 'special' below, after sending
* line_init and before line_end. Use this
* value if line_init has only "here comes
* some graphics data" without a count of
* how many bytes are coming, and some
* editing is required.
*
* 1 = send line_init, then 576 graphics bytes,
* and then line_end. Use this value
* if line_init has "here come 576 graphics
* bytes" coded into it. No editing can be done.
*/
int reversed; /* Passed to vslice() */
int delta; /* # wires fired per pass (7 or 8) */
int ignore; /* Ignore print request */
int special; /*
* Special editing needed. If non-zero,
* then buffered really ought to be set
* to zero.
*
* 0 = none
* 1 = DP8050 check for CHR$(3) etc
*/
}
printers[] =
{
{
/* name */ "IGNORE",
/* desc */ "Ignore print requests",
/* crlf */ NULL,
/* page_init */ NULL,
/* line_init */ NULL,
/* line_end */ NULL,
/* wrapup */ NULL,
0, /* buffered */
0, /* reversed */
0, /* delta */
-1, /* ignore */
0 /* special */
},
{
/* name */ "OKI192",
/* desc */ "Okidata Microline 192 (narrow carriage)",
/* crlf */ "\r\n",
/* page_init */ "\x1BA\007\x1B2\x1BU\x01\x12\r",
/* line_init */ " \x1BL\x40\x02",
/* line_end */ NULL,
/* wrapup */ "\r\x1BA\x55\x1B2\n\x1BA\x4d\x1B2\n\x1BA\x0c\x1B2\r",
1, /* buffered */
0, /* reversed */
8, /* delta */
0, /* ignore */
0 /* special */
},
{
/* name */ "OKI193",
/* desc */ "Okidata Microline 193 (wide carriage)",
/* crlf */ "\r\n",
/* page_init */ "\x1BA\007\x1B2\x1BU\x01\r\x12",
/* line_init */ " \x1BK\x40\x02",
/* line_end */ NULL,
/* wrapup */ "\r\x1BA\x55\x1B2\n\x1BA\x4d\x1B2\n\x1BA\x0c\x1B2\r",
1, /* buffered */
0, /* reversed */
8, /* delta */
0, /* ignore */
0 /* special */
},
{
/* name */ "OKI182",
/* desc */ "Okidata Microline 182 (narrow carriage)",
/* crlf */ "\r\n",
/* page_init */ "\x1BA\007\x1B2\x12\r",
/* line_init */ " \x1BL\x40\x02",
/* line_end */ NULL,
/* wrapup */ "\r\x1BA\x55\x1B2\n\x1BA\x4d\x1B2\n\x1BA\x0c\x1B2\r",
1, /* buffered */
0, /* reversed */
8, /* delta */
0, /* ignore */
0 /* special */
},
{
/* name */ "IBM",
/* desc */ "IBM Graphics printer (narrow carriage)",
/* crlf */ "\r\n",
/* page_init */ "\x1BA\007\x1B2\x1BU\x01\x12\r",
/* line_init */ " \x1BL\x40\x02",
/* line_end */ NULL,
/* wrapup */ "\r\x1BA\x55\x1B2\n\x1BA\x4d\x1B2\n\x1BA\x0c\x1B2\r",
1, /* buffered */
0, /* reversed */
8, /* delta */
0, /* ignore */
0 /* special */
},
{
/* name */ "MX",
/* desc */ "Epson MX-80, MX-100",
/* crlf */ "\r\n",
/* page_init */ "\x1BA\007\x1BU\x01\x12\r",
/* line_init */ " \x1BL\x40\x02",
/* line_end */ NULL,
/* wrapup */ "\r\x1BA\x55\n\x1BA\x4d\n\x1BA\x0c\r",
1, /* buffered */
0, /* reversed */
8, /* delta */
0, /* ignore */
0 /* special */
},
{
/* name */ "8510",
/* desc */ "C.ITOH Prowriter M-8510A",
/* crlf */ "\r\n",
/* page_init */ "\x1BT16\x1B[\x1BE\x1Bf\x1B\"\x1BY\x1BL000\x1B>\r",
/* line_init */ " \x1BS0576",
/* line_end */ NULL,
/* wrapup */ "\r\n\n\n\n\n\n\n\n\n\x1BA\x1B]\x1B<",
1, /* buffered */
-1, /* reversed */
8, /* delta */
0, /* ignore */
0 /* special */
},
{
/* name */ "DP8050",
/* desc */ "Data Products 8050 and 8070",
/* crlf */ "\n",
/* page_init */ "\x1Bx,0,$\x1Ba,0,$\x1Bj,1,$\x1BB,12,$\x1BQ,4,$\r",
/* line_init */ "\x03",
/* line_end */ "\x03\x02",
/* wrapup */ "\f\x18",
0, /* buffered */
-1, /* reversed */
7, /* delta */
0, /* ignore */
1 /* special */
}
};
#define NUMPRINT ( sizeof(printers) / sizeof(struct _printer) )
/*
* Misc scratch
*/
static union REGS inregs, outregs; /* For int86() use */
static BYTE scratch[60000]; /* Plenty big for max MACPAINT file */
/*
* Decoded MACPAINT picture as 720 576-pixel lines
*/
static BYTE mem_image[MAC_VERT][MAC_HORIZ/8];
/*
********************************************
* M A I N P R O G R A M *
********************************************
*/
main(argc, argv)
int argc;
BYTE *argv[];
{
BYTE *filepath;
int i;
fprintf(stderr, "\nJoan Riff's MACPAINT and RLE picture viewer for HERCULES, EGA, CGA boards.");
if ( argc < 2 )
{
use();
exit(-1);
}
/*
* Determine type of video display being used
*/
vtype();
#if NASTY
/*
* Pre-scan command line for -OK command-line arg
*/
for ( i = 1; i < argc; i++ )
{
if ( strcmpi(argv[i], "-OK") == 0 )
{
ok_flag = -1;
}
}
#else
fprintf(stderr, "\n(c) 1987 by Computerwise Consulting Services");
#endif
warning();
/*
* Handle all command-line args and filenames
*/
while( --argc && !time2quit )
{
argv++; /* Up to next filename */
/*
* If this arg starts with a "-", then process it as a
* command-line argument
*/
if ( **argv == '-' )
{
pswitch(*argv);
continue;
}
/*
* Continue, assuming that anything else we find is
* a filename. It may contain wildcards, so we must
* expand them into true paths. Note that in this way
* we apply command-line args like "-invert" etc to
* whole bunches of files even though they count as
* one filename on the command line. This is a feature,
* not a bug.
*/
if ( all_invert ) /* Inverting all files? */
{
/*
* We are inverting all files. In this case,
* a -INVERT flag for one file means to NOT
* invert this one. The absence of a -INVERT
* means that we set it for him.
*/
auto_invert = auto_invert ? 0 : -1;
}
wildcard(0, *argv, 0); /* Seed our wildcard pattern */
while ( (filepath = wildcard(1, NULL,0)) != NULL )
{
if ( time2quit )
{
break;
}
if ( readmac(filepath) ) /* Try to read it in and display/print it */
{
/*
* We encountered an error
*/
if ( cur_mode != TEXT )
{
mode(TEXT);
}
fprintf(stderr, "\nError reading file '%s'! Press RETURN...", *argv);
key();
cls();
}
}
auto_invert = 0; /* Clear for this "filename" */
}
/*
* We may have some dangling RLE images, which have been read in but not
* yet flushed. Now's the time!
*/
if ( rle_pic )
{
flush();
}
mode(TEXT); /* Restore screen */
#if DEBUG
/*
* Dump elapsed timings for all decodes
*/
fprintf(stderr, "\nDecode time ticks:\n");
for ( i = 0; i < next_elapsed; i++ )
{
fprintf( stderr, "%12ld ", elapsed[i] );
}
#endif
}
/*
* Issue various warnings
*/
warning()
{
#if NASTY
if ( ok_flag ) return; /* He wants them suppressed */
mode(TEXT);
fprintf(stderr, "(c) Copyright 1987 by Computerwise Consulting Services");
fprintf(stderr, "\n P.O. Box 813, McLean, VA 22101 (703) 280-2809");
fprintf(stderr, "\n");
fprintf(stderr, "\nThis program will not run unless you use the special command-line argument");
fprintf(stderr, "\n'-OK', meaning 'OK, I agree that Computerwise Consulting Services - as the");
fprintf(stderr, "\nowner of the copyright for this program - has every legal right to define");
fprintf(stderr, "\nwho may and may not use it, and I agree to be bound by this licensing");
fprintf(stderr, "\nagreement.'");
fprintf(stderr, "\n");
fprintf(stderr, "\n LICENSING AGREEMENT");
fprintf(stderr, "\nComputerwise Consulting Services hereby grants to any and all potential");
fprintf(stderr, "\nusers (EXCEPT FOR THOSE DEFINED BELOW) permission to receive, use, and");
fprintf(stderr, "\ntransfer this program 'as-is', with no warrantees etc etc.");
fprintf(stderr, "\n");
fprintf(stderr, "\nSpecifically DENIED all permissions are those who in the opinion of CCS have");
fprintf(stderr, "\nproven to be 'software pirates' by violating U.S. Copyright law, to wit:");
fprintf(stderr, "\n");
fprintf(stderr, "\n LOTUS DEVELOPMENT CORPORATION, and any employee thereof or");
fprintf(stderr, "\n consultant thereto.");
fprintf(stderr, "\n ADAPSO, and any firm which is a member thereof, and any employee");
fprintf(stderr, "\n of such a firm.");
fprintf(stderr, "\n");
fprintf(stderr, "\n(Press RETURN...)");
key();
#endif
/*
* Issue a mild warning if the poor guy has only a CGA
*/
if ( screen_type == TYPE_CGA )
{
mode(TEXT);
fprintf(stderr, "\nWarning: You are running this program on an IBM-compatible");
fprintf(stderr, "\nColor/Graphics Adapter.");
fprintf(stderr, "\n");
fprintf(stderr, "\nTo preserve a decent aspect ratio, this program must display every");
fprintf(stderr, "\nOTHER picture line on the screen. This results in some rough images,");
fprintf(stderr, "\nESPECIALLY WHEN DISPLAYING RLE FILES. But don't worry. Printed images");
fprintf(stderr, "\nwill contain the full resolution present in the picture file.");
fprintf(stderr, "\n");
fprintf(stderr, "\nYou should consider getting a HERCULES Monochrome board or an Enhanced");
fprintf(stderr, "\nGraphics Adapter and display, if you want to see some good graphics");
fprintf(stderr, "\nimages on the screen.");
fprintf(stderr, "\n");
fprintf(stderr, "\n(Just a friendly reminder) - Joan");
fprintf(stderr, "\n");
fprintf(stderr, "\n(Press RETURN...)");
key();
}
#if NASTY
exit(-1);
#endif
}
/*
* We have a screen image in mem_image. Flush it to the screen or the
* printer, cause it's about to be overwritten!!!
*/
flush()
{
if ( time2quit ) /* Are we aborting program? */
{
return; /* Yes, get back to mainline fast! */
}
if ( print_all ) /* Just printing? */
{
print(); /* Yes, send it to the printer */
}
else
{
browse(); /* No, show it */
}
}
/*
* Explain program use
*/
use()
{
int i;
fprintf(stderr, "\n\nUse: MACPAINT%s[-PRINT] [-INVALL] [-printer] {[-n] [-INVERT] filename}...\n",
#if NASTY
" -OK "
#else
" "
#endif
);
#if NASTY
fprintf(stderr, "\n-OK = 'OK, I agree to abide by your licensing agreement'");
#endif
fprintf(stderr, "\n-PRINT = automatically print all files, don't show 'em");
fprintf(stderr, "\n-INVALL = automatically invert all file images");
fprintf(stderr, "\n-n = set default fill to 0's ('-0') or 1's ('-1')");
fprintf(stderr, "\n-INVERT = automatically invert the next file's image");
fprintf(stderr, "\nfilename = name of a MACPAINT or RLE file (wildcards OK)");
fprintf(stderr, "\n-printer = the type of printer on your system:\n");
for ( i = 0; i < NUMPRINT; i++ )
{
fprintf(stderr, "\n -%-6s = %s", printers[i].name, printers[i].desc );
}
fprintf(stderr, "\n");
}
#if DEBUG
/*
* Return the number of clock ticks since midnight. This is only used for
* timing studies, to help us speed up the decode processing.
*/
long ticker()
{
inregs.h.ah = 0;
int86( 0x1a, &inregs, &outregs );
return( (outregs.x.cx << 16) | outregs.x.dx );
}
#endif
/*
* Process command-line switch s
*/
pswitch(s)
BYTE *s;
{
int i;
s++; /* Skip over "-" at front */
/*
* See if it's a printer name
*/
for( i = 0; i < NUMPRINT; i++ )
{
if ( strcmpi(s, printers[i].name) == 0 )
{
print_type = i;
return;
}
}
/*
* Try for a switch
*/
if ( strcmp(s, "1") == 0 )
{
fill_type = 0xff;
return;
}
if ( strcmp(s, "0") == 0 )
{
fill_type = 0x00;
return;
}
if ( strcmpi(s, "PRINT") == 0 )
{
print_all = -1;
return;
}
if ( strcmpi(s, "INVERT") == 0 )
{
auto_invert = -1;
return;
}
if ( strcmpi(s, "INVALL") == 0 )
{
all_invert = -1;
return;
}
/*
* It's not anything that we recognize
*/
}
#include "video.c"
#include "readmac.c"
#include "writemac.c"
#include "printer.c"
#include "wildcard.c"