Category : Files from Magazines
Archive   : MAR91.ZIP
Filename : 2N03006B

 
Output of file : 2N03006B contained in archive : MAR91.ZIP
/*
* Listing 2: Print the screen to an Epson-compatible
* graphics printer. (Link this with Listing 1.)
*/
#include
#include

#define ESC 0x1b /* escape */
#define CR 0x0d /* carriage return */
#define LF 0x0a /* line feed */

/* global variables
*/
extern int x_max, y_max;
extern int print_fh;

/* prototypes
*/
void print_stripe( int y_start );


void print_screen( void )
{
static char line_sp[3] = {ESC, 'A', 0x08};
static char reset_prn[2] = {ESC, '@'};
int y;

/* Send ESC A 08 to set line spacing to 8 dot rows.
*/
write(print_fh, line_sp, 3);

/* Send the data in groups of 8 dots rows at a time,
* starting with row 0, then 8, 16...
*/
for (y = 0; y < y_max; y += 8)
print_stripe(y);

/* Send ESC @ to return the printer to defaults.
*/
write(print_fh, reset_prn, 2);
}


/*
* Send one "stripe" of pixels to the printer, beginning
* with the given Y-coordinate. A stripe is 8 dots high,
* and as wide as the screen.
*/
void print_stripe( int y_start )
{
int num_pix, x, y, bit_num;
unsigned char out_pixel;
static char graph_cmd[4] = {ESC, 'K', 0, 0};
static char cr_lf[2] = {CR, LF};

/* Send ESC K n1 n2, where (256 * n2) + n1 is the
* number of pixels across a line.
*/
num_pix = x_max + 1;
graph_cmd[2] = num_pix & 0xff;
graph_cmd[3] = num_pix >> 8;
write(print_fh, graph_cmd, 4);

for (x = 0; x < num_pix; ++x)
{
/* Accumulate 8 pixels, vertically, into out_pixel.
*/
out_pixel = 0;
y = y_start;
for (bit_num = 7; bit_num >= 0; --bit_num, ++y)
{
if (getpixel(x, y) > 0)
out_pixel |= (1 << bit_num);
}
write(print_fh, &out_pixel, 1);
}

/* Send carriage return, line feed.
*/
write(print_fh, cr_lf, 2);
}


  3 Responses to “Category : Files from Magazines
Archive   : MAR91.ZIP
Filename : 2N03006B

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/