TweetFollow Us on Twitter

Printer Driver
Volume Number:3
Issue Number:11
Column Tag:Advanced Mac'ing

How to Write a Printer Driver

By Earle Horton, Hanover, NH

Writing a Simple Macintosh Printer Driver

Part 1: Overview

A Macintosh Printer Resource File is a file containing resources to emulate QuickDraw drawing commands on a printer or other remote device. This article describes how to write a Printer Resource File which implements text-drawing commands only on serial dot matrix and daisy wheel printers. The printer file is installed using the Chooser in the same manner as one would install the ImageWriter or LaserWriter file. The printers which are serviced by this printer driver are assumed to be capable of printing in only one font, which is mono-spaced. An ability is included in the printer driver to change serial port settings and printer control strings, so that a large number of different types of printers may be used with one driver. In addition, it is shown where more advanced drawing commands (graphics and proportional fonts) would fit into the structure of the Printer Resource File. This Printer Resource File was written, from scratch, by the author in two weeks. I am not a professional programmer, or even a registered Macintosh developer. I feel that the dearth of Printer Drivers for the Macintosh is due more to apparent, rather than real, difficulties in writing them.

I wrote my Printer Resource, which I christened Daisy, using LightspeedC for the code resources and RMaker for the data resources in the file. The table below summarizes all the resources in my Printer Resource. Most of these follow the standard types and IDs used by Apple, but some are particular to my implementation.

Printer File Resources and Function (Public)

Type ID Function

''DRVR’ -8192 Device driver: performs low-level printer calls and maintains storage

‘PREC’ -8192 Driver’s private storage

‘PREC’ 0 Default print record

‘PREC’ 1 Copy of last used print record

‘PDEF’ 0 Draft mode printing routine

‘PDEF’ 1 Spooling routine (not used)

‘PDEF’ 2&3 Printer specific printing code (not used)

‘PDEF’ 4 Code for handling printing dialogs

‘PDEF’ 5 Spool file printing routine (not used)

‘PACK’ -4096 Chooser interface code, used for device configuration

‘STR ‘ -8191 Default spool file name

‘STR ‘ -4096 Type name for AppleTalk devices (not used)

‘STR ‘ -4093 Title for Chooser left button (not used)

‘STR ‘ -4092 Title for Chooser right button

‘STR ‘ -4091 Chooser list label

‘STR ‘ -4090 Chooser reserved string (not used)

‘DLOG’ -8192 Paper Style dialog

‘DITL’ -8192 Paper Style dialog template

‘DLOG’ -8191 Paper Job dialog

‘DITL’ -8191 Paper Job dialog template (Private)

‘DLOG’ -4080 PACK resource installation dialog

‘DITL’ -4080 Installation dialog template

‘Stng’ -8192 Private type, printer settings

‘STR#’ -4080 Printer control string list

‘BNDL’ 128 For the file’s icon

‘DasY’ 0 File creator, resource is a ‘STR ‘

‘FREF’ 128 For the file’s icon

‘ICN#’ 128 Icon and mask

‘DLOG’ -8193 Sheet feed dialog

‘DITL’ -8193 Sheet feed dialog template

The Printer Resource file contains a fairly large number of resources, but each one has a well defined function. All of the “public” resources have type names and ID numbers rigidly defined by Apple, and also specific formats. The private resources should have ID numbers of “owned” resources, owned by either the driver, one of the ‘PREC’ resources, or the ‘PACK’ resource so as not to conflict with any application resources. The file must have a ‘BNDL’, ‘FREF’, ‘ICN#’, and creator resource in order to appear in the Chooser display. This printer file uses the Chooser interface code, ‘PACK’ -4096, so it therefore needs to be installed with the Chooser, and not Choose Printer.

This printer resource file is of type ‘PRER’, or ‘non-serial printer’, so that it can use the Chooser interface to query the user for application-independent installation parameters. These include the baud rate, what kind of flow control to use, and some printer control strings. If your printer resource does not need to use the Chooser interface, then you can make it of type ‘PRES’, or serial printer, and the Chooser will take care of all details of installation. If you do it this way, then the Chooser will put the user’s choice of serial port in parameter RAM, so that your printer driver can find it later.

The Printer Resource File contains a number of resources containing pure 68000 (or 68020) machine code. The ‘DRVR’ handles low-level Printing Manager calls, while the ‘PDEF’ resources handle high level printing. It is possible to define up to four different kinds of high level printing, but it is only necessary to provide one. The ‘PACK’ resource contains a single routine to handle the printer installation process. I wrote all of my code resources using LightspeedC, and used some InLine assembly to format the headers of the resources where required. There are some requirements which must be met by the development system used. The development system must be capable of producing stand alone code resources, and must allow you to specify the format of the code resource header. The development system must also be capable of producing functions that are called according to the Pascal conventions in Inside Macintosh. It appears then that most commonly available C and Pascal development systems are capable of producing working printer files, with perhaps a few dozen lines of assembler “glue” to make things fit together.

Fig. 1 Our Printer Driver is Chooser Compatible!

Of the non-code resources, most are standard, except for the ‘Stng’ type and the ‘PREC’ type. The ‘Stng’ type is just an array of integers I use to store configuration values, and is unique to my implementation. The ‘PREC’ type (0 and 1) is a disk copy of the Printing Record data structure, which the printing code uses to keep track of paper size and other parameters associated with each printing “job”. The printing record will be discussed in detail when I treat the style and job dialog code. The ‘PREC’ -8192 is merely a disk copy of whatever storage is needed by the driver and printing code. A good way to initialize variables used by the printer file is to keep their default values in a data structure in this resource. When LightspeedC creates a device driver, it uses a resource of type ‘DATA’ to do this, and creates initialization code to load it in when the driver is opened. Since the Chooser does not install the ‘DATA’ resource for me, I keep it in the printer resource file, and give it a type reserved for printer driver storage. When the driver is opened, I open the printer resource file, and load my storage resource before doing anything else.

When the printer is installed by the Chooser, the driver is added to the system resource file, and the ID is changed from -8192 to 2. The name is also changed from “.XPrint” to “.Print”. The structure of the printer resource file is admittedly fairly complicated. Taken a piece at a time, however, it is not a particularly difficult task to write one.

Part 2: The driver

The Printer Resource File code is written as a series of separate overlays, each of which has a specific function and a rigidly defined format. We will start with the driver. The driver has the same structure as any Macintosh device driver or desk accessory, and responds to Open, Close, Control, and Status calls. It does not appear to respond to Prime (read/write) calls. The driver’s private storage was originally contained, as a resource, in both the Printer Resource File and the System Resource File as a resource of type ‘PREC’ with the same resource ID as the driver. Apple appears to have discontinued this practice, but we will use it to store data structures used by various parts of the printing code. The driver shown here is written using the LightspeedC compiler, device driver option. When global variables are defined in a LightspeedC device driver project, they are stored in a resource of type ‘DATA’ and accessed via offsets from register A4. This is changed to type ‘PREC’, and code is provided to load this resource in at open time. The driver’s private storage is found in a Handle stored in the driver’s Device Control Entry, and is referenced through the dereferenced Handle.

The initialization code I have written for the device driver opens the Printer Resource File, loads the resource containing the driver’s private storage, and stores the Handle to it in the driver’s DCE. I have to provide code for opening the Printer Resource File, because it is possible to open the printer driver without the Printer Resource File being open at the time. The standard means of opening the printer driver is to call PrOpen, which opens the Printer Resource File. Assume the worst, however, and give the driver a means of opening the resource file. I use SysEnvirons to get the RefNum of the folder with the system resource file in it, and OpenRFPerm to open the printer resouce file. If the machine is older than 128k ROMs, I use OpenResFile, and hope that this routine looks on the volume containing the system (it probably does). I have not done verification tests on ANY parts of my printer driver for 64k ROMs or Mac XLs. Sorry.

The driver’s private storage is defined in a header file, so that it can be shared between the driver and other printing code overlays. Using conditional compilation, the same identifiers are used for static variables in the driver code, and data structure members in the other overlays.

The functions the driver open routine is expected to perform are as follows: It initializes a “permanent” storage area used by the printing code. It opens a channel to the serial driver used for printing. In my printer driver, it obtains settings to be used during printing from the printer resource file. The driver responds to several device manager control calls which are expected to perform useful printer functions. My driver loads a string list from the Printer Resource File which contains strings to perform these functions, so they can be changed without recompiling the code. In addition to hardware-oriented device control calls, the driver answers one control call and one status call from the Font Manager. These are for the purpose of determining which fonts and spacings the printer is capable of. Most applications appear to ignore this information, and attempt to print what is shown on the screen. We provide the font information anyway, since it can’t hurt.

LightspeedC provides a rather different programming shell for device drivers and desk accessories from that which is used by other development systems. The programmer writes one function, main(), which is called with the same parameters that are used to call the Open, Control, Status, Prime, and Close routines of the driver. A third parameter, an integer, indicates to main() which of the five driver routines was, in fact, intended. A switch statement in my driver code takes the place of the five device driver routines which you would have to write if using another development system. Note that this is certainly non-standard!

The first driver routine to be called is the open routine. This may be called several times during the course of an application session. We are called here, and everywhere, with three parameters: a parameter block, a device control entry pointer, and (particular to LightspeedC) an integer indicating which switch block to execute. The open routine checks the dCtlStorage field of our device control entry to make sure storage has been allocated, and allocates it if not. Since we read in our storage from the Printer Resource File, we have to find the “Blessed Folder” first. I use SysEnvirons to do this, then OpenRFPerm to open the resource file. (SysEnvirons is available as an OSTrap with system 4.1 and newer, and as glue for MPW and LightspeedC. It will return the correct VRefNum for the system folder on all Macs, I have been told.) Then we read in our storage from the resource file. Other tasks are to check to see if other required initializations have been performed, and to open and configure the serial port. It does not hurt anything to open the serial port more than once, so we open it every time the open routine is called. Also, the serial port parameters can be changed by the user in our Chooser interface, so the open routine sets the serial port parameters to whatever was “Chosen” last. The serial port is never closed, to maintain compatibility with 64k ROMs.

The driver control routine does most of the work of hardware-related printer functions, as well as part of the interface to the Font Manager. Since this driver is used for text-only functions, we perform only a subset of the low-level printer driver calls here. When the control routine is called, the csCode of the parameter block determines which driver function is required. I will discuss first the csCodes which I do not implement.

Printer driver parameter blocks have the usual driver control parameter block structure, but the fields following csCode are almost always three longs, lParam1, lParam2, and lParam3. A modified definition of the control parameter block, included in the master header file, is used to define these. When csCode is iPrBitsCtl or iPrEvtCtl, some sort of bitmap transfer to the printer is desired. With iPrBitsCtl, lParam1 is a pointer to the bitmap, lParam2 is a pointer to the rectangle to be printed, and lParam3 contains resolution information (defined for the ImageWriter). When csCode is iPrEvtCtl, this means that either (command-shift-4) or (command-shift-capslock-4) has been pressed, depending on lParam1. lParam1 is iPrEvtAll for printing the entire screen, and iPrEvtTop for printing the top window on the screen. If you have a printer capable of printing bitmaps in some fashion, then you can at this point translate the appropriate QuickDraw bitmap to one which your printer can handle, then simply send the graphics commands to your printer to do this. Doing so is the quickest way to get some sort of graphics capability for a non-Apple printer with the Macintosh. A few hours with Inside Macintosh and the manual for your printer should be enough to do this, but that is not the topic of this article...

When csCode is iPrIOCtl, then text streaming is being used. lParam1 is a pointer to an area of memory containing characters to be sent to the printer. lParam2 is a long integer which tells us how many characters to send. We simply use these values to fill in the ParamBlockRec we use to communicate with the serial driver, and issue a PBWrite call. Note here that I use inline assembly to issue the PBWrite and some other calls. I do this to suppress loading of libraries, and to save code size thereby. With LightspeedC if we wish to load PBWrite from a library, then we have to load in also all the PB... calls. LightspeedC compiles many of the Macintosh Toolbox calls into inline code, but not register based ones. This is partly a matter of taste, and partly a matter of how your development system handles things. I find that doing things this way helps in debugging too, since most all of the code I see when using MacsBug is code which I have written. Anyway, there is not much to handling iPrIOCtl.

When csCode is iPrDevCtl, we are being called upon to perform one of several printer control actions. lParam1 serves as an opcode to specify the desired function. All functions are performed here by sending Pascal strings to the printer, and the routine that services iPrDevCtl looks up the proper string, and issues a PBWrite to send it to the printer. Error checking could be added here, and in the iPrIOCtl code, to check for possible serial driver or printer errors. A status call to the serial driver might be appropriate, or a status call to the printer, if it accepts these. Errors usually do not occur here, and when they do the user can probably detect them, but it is a nice touch if the driver does so also. For instance, if you are writing a printer driver for a printer that can inform the computer when it has run out of paper, then your driver could put up a dialog with an “Out of Paper” message.

An important point should be made here concerning “Device Independence”. The philosophy of Apple is that there is a different printer driver for each printer, thereby providing device independence to applications. However, many of the printer functions, with the possible exception of the bitmap calls, can be specified to the driver in the format of resources, as I do here. Certainly there is no need to have a different printer driver for each baud rate. In my Chooser interface, I show one method of letting the user specify printer parameters with a dialog box. Another method might be to have one driver, and several user-selectable configuration files. For a simple text-only printer driver, the ability to handle many different kinds of printers is certainly desirable. The more functions you support, however, the less you will be able to do this, particularly if you decide to support graphics.

The printer driver answers to one Font Manager control/status call, when csCode is iFMgrCtl. The status call asks for the printer’s “Font Characterization Table”, and lParam1 points to where to put it. Frankly, since I only support mono-spaced fonts at this point, I just give it a copy of the ImageWriter Font Characterization Table, copied from the Font Manager Chapter of the Promotional Edition of Inside Macintosh. The Font Characterization Table gives information about how much space is taken up by different text styles, and how the fields are used is not well documented, so I have not attempted to do much with it. The Font Manager control call is to inform the printer driver which font has been selected for use, and to give the driver a chance to modify it. The original Inside Macintosh says lParam1 points to an FMOutput record in this case, but use of MacsBug shows that it is a pointer to an FMInput record. The device field of the FMInput contains an integer from one of my style dialogs, so I can use it to determine information which is specific to my driver. I use it here to determine character pitch, either 10, 12, or 15 cpi. At present, I tell the Font Manager I want Monaco 9, and modify the width according to character pitch. Much more experimentation is needed to make full use of these Font Manager calls, particularly if you want to support proportional fonts, or if you hope to work with applications which do fancy formatting. Justification does not work very well with my driver at this point, partly because I do not yet know how to respond to these calls in the best manner.

The driver close routine is simple. I purge the Handles to whatever storage I use, and set my copies of them to “nil”. If your printer driver will only work on 128k ROM machines or better, or if you plan to include the RAM serial driver, then perhaps you would want to do a RAMSDClose at this point. The correct thing to do here is unclear to me, especially remembering what happened when I had 64k ROMs and attempted to close the serial driver... (For those who never had 64k ROMs, the dreaded “mouse freeze” was the usual result.) There is usually not a problem here, unless the user plans to switch cables around with the Macintosh left on (not a good idea, anyway).

These are the functions performed by the driver, and how it is put together. Most development systems provide a “template” for writing desk accessories or device drivers, or a main unit which you link your driver service routines to. In this sense, the driver is the easiest part of all to write, since the code header is already taken care of for you. If you can write a desk accessory, then you can write this part of the printing code, no problem.

 * XPrint.c.  printer driver for daisy-wheel printers
 * for the Macintosh.
 * Earle R. Horton.  August 17, 1987
 * LightspeedC source.
 * Set the project type to Device Driver, ID #2.
 * Run RMaker to put resources in printer resource file.
 * Install with Chooser.
#include <WindowMgr.h>  /* inc. QuickDraw.h, MacTypes.h */
#include <EventMgr.h>
#include <DialogMgr.h>
#include <SerialDvr.h>  
#include <FontMgr.h>
#include <HFS.h>
#include <asm.h>
#include “prglobals.h” /* see end of this code for this */
 * LightspeedC doesn’t provide these as InLines.  To save space, I provide 
my own routines.  This way, I get around having to link in MacTraps.


/* Useful constants */
#define OPEN0
#define PRIME  1
#define CONTROL  2
#define STATUS 3
#define CLOSE  4

#define SERRESET 8
#define SERSHAKE 10

#define XONCR  ((char)17)
#define XOFFCR ((char)19)
#define RESFILEID(-8192)
#define PACKID   (-4080)  

main(p, d, n)
PrParam *p; /*  ==> parameter block  */
DCtlPtr d;/*  ==> device control entry  */
int n;  /*  entry point selector  */

/* Check to make sure our data area was allocated.  It may not have been 
if we were opened with a low-level open or even a device manager PBOpen() 
and our printer resource file was not opened.  Note that we cannot use 
any of LightspeedC’s “global” variables until after we get our storage 
from the resource file and lock it down, making A4 point to it.  This 
probably does the same thing that the prolog code attempts to do with 
the original ‘DATA’ resource created by LightspeedC.*/

Handle  storage;
 if(d->dCtlStorage == nil && n != CLOSE){
 if (openprinterfile(d) == -1){
              PrintErr = ResError();
 storage = d->dCtlStorage;
 movea.lstorage,a0 ;; LS C uses A4 as the base
 movea.l(a0),a4  ;; for driver globals.
 if (d->dCtlStorage != nil) switch (n){/*  dispatch  */

     case OPEN:  /*  open  */
 if((settings = (Pfg)(GetResource(‘Stng’,RESFILEID))) == nil ||
 GetResource(‘STR#’,PACKID) == nil){
 return(-1);/* Can’t run without these. */
      settings = nil;
 prpb.ioNamePtr = prname;

     case PRIME: /* For read/write calls, not  here. */

     case CONTROL: /*  control  */
 switch (p->csCode){ /* Device Control Call */
 /* p->csCode gives opcode, and we switch on */
 /* it to perform low-level Printing calls */
 case iPrBitsCtl:/* Send bitmap to printer (NA). */
 case iPrIOCtl:  /* Text streaming. */
     iopb.ioParam.ioBuffer = (Ptr)p->lParam1;
     iopb.ioParam.ioReqCount = p->lParam2;
      lea iopb,a0
 case iPrEvtCtl: /* Screen print (cmd-shift 4, NA.)*/
 case iPrDevCtl: /* CR, LF, FF, etc. */
 case iFMgrCtl:
/* Font manager font table modify request.  p->lParam1 is a pointer to 
an FMInput record.  (IM says we get an FMOutPtr here, but MacsBug says 
we get a pointer to an FMInput.  I go with MacsBug.)  In addition, the 
integer following p->lParam1 contains our driver reference number and 
a private byte we can use internally. The application first does something 
to determine the characteristics of fonts in our printing GrafPort.  
The Font Manager calls our status routine with csParam = 8 and we give 
it a “font characterization table”. The Font Manager selects a font, 
and calls our control routine to confirm the choice.  We change it to 
Monaco 9, horizontal scaling.  If you need to support proportional fonts, 
then you have to do something about it here and in the printing code, 
too.  Good luck.  */
     FMInput *fontset;
        fontset = (FMInput *)p->lParam1;
        fontset->family = monaco;
        fontset->face = 0;
        fontset->needBits = 0;
        fontset->numer = noscale;
        fontset->denom = noscale;
        if(fontset->device == IDEV10){
        fontset->size = 10;
        fontset->numer.h = 7;
        fontset->denom.h = 6;
        else if(fontset->device == IDEV15){
        fontset->size = 7;
        fontset->numer.h = 5;
        fontset->denom.h = 6;
        else fontset->size = 9;
     case STATUS:
 switch (p->csCode){ /* Device Status Call */
 /* p->csCode gives opcode, and we switch on */
 /* it to perform low-level Printing calls */
 case iFMgrCtl:

/* Font manager font table request.  Help out the Font Manager. p->lParam1 
is a pointer to an area in memory in which to put a copy of the information 
describing our font capabilities.  p->lParam2 has an integer in its high 
order word which contains the “resolution” to use, set in a style dialog 
with the user.  We say we have different horizontal resolutions, based 
on the number of characters per inch used.  I believe this gets called 
whenever the application does a GetFontInfo() or StringWidth() or whatever 
for the first time in one of our printing GrafPorts.  Possibly also when 
the application tries to change the font style.  */

     *((fontab *)p->lParam1) = myfonts;
     case CLOSE: /*  close  */
      if(storage != nil){
      d->dCtlStorage = nil;
 /*  done  */
SPopen()/* Open serial driver and configure it. */
 /* Use low-level ROM routines. */
 pb = &iopb;
 switch (pport){ /* get the correct port */
 case 0:/* modem port */
 if(!phone) {
 phone = TRUE;
 drivernum = AoutRefNum;
 case 1:/* printer port */
 if(!printer) {
 printer = TRUE;
 drivernum = BoutRefNum;
 /* set up the io parameter block for writing to the serial driver. A 
control call resets the baud rate */
 pb->ioParam.ioRefNum = drivernum;
 pb->ioParam.ioCompletion = nil;
 ((cntrlParam *)pb)->csCode = SERRESET;
 serconfig = data8 + noParity + stop20;
 serconfig += mybauds[pbaud].rate;
 ((cntrlParam*)pb)->csParam[0] = serconfig;
#define shake  ((SerShk*)&((cntrlParam*)pb)->csParam[0])
 shake->errs = FALSE;
 shake->evts = FALSE;
 shake->fDTR = FALSE;
 shake->fInX = FALSE;
 if(XonXoff && (theWorld.machineType >= envMachUnknown)){
      shake->fXOn = TRUE;
      shake->fCTS = FALSE;
      shake->xOn = XONCR;
      shake->xOff = XOFFCR;
 else {
      shake->fXOn = FALSE;
      shake->fCTS = TRUE;
 ((cntrlParam *)pb)->csCode = SERSHAKE;
#undef shake
 pb->ioParam.ioPosMode = 0;
 pb->ioParam.ioPosOffset = 0;

prinit(name) /* Open a driver by name. */
StringPtr name;  /* ROM, RAM serial driver? Who cares? */
 iopb.ioParam.ioNamePtr = name;
 iopb.ioParam.ioCompletion = nil;
 iopb.ioParam.ioPermssn = 0;
 lea  iopb,a0
 * Set printer control strings based on our STR# resource.
unsigned char  *strptr;
unsigned char  **mystrings;

mystrings = (unsigned char **)GetResource(‘STR#’,PACKID);
 if(mystrings != nil){
 copystr(  (strptr = (*mystrings)+2)  , prlfstr);
 copystr(  (strptr += (*strptr) + 1)  , prinitstr);
 copystr(  (strptr += (*strptr) + 1)  , prtopstr);
 copystr(  (strptr += (*strptr) + 1)  , preopstr);
 copystr(  (strptr += (*strptr) + 1)  , preofstr);
unsigned char *str;
register unsigned char i,count;
 count = 1;
 if (str[i] == ‘^’) str[count] = 31 & str[++i];
 else str[count] = str[i];
 str[0] = count - 1;
 * This is for copying PASCAL strings.  Simple.
unsigned char *src,*dst;
 clr.l  d0
 move.l src,a0
 move.l dst,a1
 move.b (a0),d0
 move.b (a0)+,(a1)+
 dbra d0,@loop
devicecontrol(code)/* printer device control calls. */
long  code;
 case lPrReset:
 case lPrPageEnd:
 case lPrLineFeed:
 case lPrLFSixth:
 case lPrLFEighth:
 default: /* Unknown parameter. */
printstring(string)/* printer control string to serial driver. */
unsigned char  *string;   
 iopb.ioParam.ioBuffer = (Ptr)(string+1);
 iopb.ioParam.ioReqCount = (long)(string[0]);
 lea  iopb,a0
/* Find the system folder, and open our printer resource file, if we 
can. Fill in a global SysEnvRec, which might be useful for other stuff. 
int openprinterfile(d)
DCtlPtr d;
SysEnvRec myWorld;
StringHandle   ourname;
Handle  storage;

 if(d->dCtlStorage != nil) 
 ourname = (StringHandle)GetResource(‘STR ‘,0xE000);
 HNoPurge(ourname);/* Get resource file name. */
 if(myWorld.machineType >= envMachUnknown)
 therefnum = OpenRFPerm(*ourname, myWorld.sysVRefNum, fsCurPerm);
 therefnum = OpenResFile(*ourname);
 if (therefnum != -1){
 d->dCtlStorage = (Handle)GetResource(‘PREC’,RESFILEID);
 if(d->dCtlStorage != nil){
 storage = d->dCtlStorage;
 movea.l storage,a0;; LightspeedC uses A4
 movea.l (a0),a4 ;; for driver globals.
 theWorld = myWorld;
 return (therefnum);
int HNoPurge(c)
char *c;
 move.l c,a0
int HPurge(c)
char *c;
 move.l c,a0
int HLock(c)
char *c;
 move.l c,a0
ParamBlockRec  closepb;
 lea  closepb,a0
 move.w refnum,24(a0)
 clr.l  12(a0)
 move.w 16(a0),d0

/* prglobals.h */
#define nil 0L
#include <PrintMgr.h>
#include <DeviceMgr.h>
#include <FileMgr.h>
#include <Environs.h>
#define DIRTY  0xFFFF
/* LightspeedC doesn’t do this exactly right for a Printer control call. 
typedef struct
 QElemPtr qLink;
 int    qType;
 int    ioTrap;
 Ptr    ioCmdAddr;
 OsErr  ioResult;
 int    ioVRefNum;
 int    ioRefNum;
 int    csCode;
 long   lParam1;
 long   lParam2;
 long   lParam3;
/* ^^^^ */
} PrParam;
#define WIDTH  164 /* la bombe if not a multiple of 4 */
#define NROWS  66/* 11 inches * lines per inch. */
typedef struct bauds{
 int  rate;
 char label[10];
typedef struct{
 int  dirty;
 unsigned char text[WIDTH];
typedef struct{
 int  dummy[5];
} pconfig,*Pcfg,**Pfg;
/* Be a real Mac cowboy, access data by the handle. */
#define pport    ((*settings)->dummy[0])
#define pbaud    ((*settings)->dummy[1])
#define XonXoff  ((*settings)->dummy[2])
/* Yeeeeee-Hah !! I don’t even lock it! */
typedef struct { /* Structure description of STR# */
 int  numstrings;/* resource. */
 unsigned char thestrings[];
#define RES1ID (-4080)
#define RES2ID (-8192)
#define ILLEGAL  0x4AFC
typedef unsigned char Str36[36];
#define HREZZ  72
#define HREZZ10  60/* For 10 cpi. */
#define HREZZ12  72/* For 12 cpi. */
#define HREZZ15  90/* For 15 cpi. */
#define VREZZ  66  /* 6 lines of printed text per inch. */
#define lines_per_inch  6
#define CHARWIDTH6
#define CHARHEIGHT 11

#define iPrPrivate 99

#define VERSION  3

#define _DEBUG 0
#define DEBUG  asm{\
#define DEBUG
#define IDEV10 0xFD01
#define IDEV12 0xFD02
#define IDEV15 0xFD03
/* HIgh order byte of IDEV is -3 for printer driver, low order byte is 
device specific.  I use it to determine character pitch for daisy wheel 
devices and dot matrix in draft mode. */
#define SETUP_CMD‘Setp’
#define PRINT_CMD‘Prnt’
#define CLOSE_CMD‘Clos’
#define OPEN_CMD ‘Open’

typedef struct{  /* Font characterization table  */
 int    vres;    /* for use by the Font Manager. */
 int    hres;
 SignedByte bold[3];
 SignedByte italic[3];
 SignedByte notused[3];
 SignedByte outline[3];
 SignedByte shadow[3];
 SignedByte condensed[3];
 SignedByte extended[3];
 SignedByte underline[3];

 * Shared storage, defined and initialized by the driver code, accessed 
elsewhere. */
typedef struct{
BAUDS mybauds[] = {/* Baud rate constant table. */
{ baud300,“\p300”},       /* Should use a string list. */
{ baud600,“\p600”},/* But these are numbers, so I */
{ baud1200, “\p1200”},  /* Think it’s OK. */
{ baud1800, “\p1800”},  /* This has to be the FIRST */
{ baud2400, “\p2400”}, /* driver global to be declared, */
{ baud3600, “\p3600”},  /* since it is also used by our */
{ baud4800, “\p4800”},  /* PACK -4096 resource, which  */
{ baud7200, “\p7200”},  /* needs to find it at the head */
{ baud9600, “\p9600”},  /* of PREC -8192. */
{ baud19200,“\p19200”}
Pfgsettings = nil;
static  PrParam prpb = {
 nil,   /* qLink */
 0,/* qType */
 0,/* ioTrap   */
 nil,   /* ioCmdAddr */
 nil,   /* ioCompletion */
 0,/* ioResult   */
 nil,   /* ioNamePtr */
 0,/* ioVRefNum  */
 iPrDrvrRef,/* ioRefNum   */
 0,/* csCode   */
 0L,0L,0L /* lParam[1-3]  */
Str36 prname = sPrDrvr;
 BAUDS  mybauds[10];
 Pfg  settings;
Str36 prname;
 ParamBlockRec   iopb;  /* For writing to serial driver. */
 static int phone   =     FALSE;
 static int printer =   FALSE;
 int phone;
 int printer;
 int  drivernum; /* RefNum of serial driver to use. */
 Str255 prinitstr;
 Str36  prlfstr;
 Str36  prtopstr;
 Str36  preopstr;
 Str36  preofstr;
static fontab  myfonts = { 
 { 0, 2,2},
 { 1, 8,2},
 { 0, 0,0},
 { 5, 1,2},
 { 5, 2,4},
 { 0, 0,-2},
 { 0, 0,2},
 { 1, 3,2}
static Point noscale = {0x0001,0x0001};
 fontab myfonts;
 int  MyRes[3];
 Point  noscale;
 Str255 stringbuf;
 int  topmargin,nlines;
 TPrint Print;
 int  pagenum;
 SysEnvRec theWorld;
#define SHEETDIALOG(-8193)
#define DONEITEM 1
#define STOPITEM 2

*Style and job dialogs for Daisy printer driver
*Chooser interface dialog
*Settings, strings, resource file BNDL, ICN#, and FREF


50 20 136 493
Invisible NoGoAway
1 ;; procID
1 ;; refCon


BtnItem ;; 1
8 321 28 381

BtnItem ;; 2
9 395 29 455

StatText Disabled;; 3
9 6 24 145

StatText Disabled;; 4
30 5 46 89
Page Range:

RadioItem ;; 5
30 93 45 138

RadioItem ;; 6
30 140 46 200

EditText Disabled;; 7
30 205 46 237

StatText Disabled;; 8
30 242 46 270

EditText Disabled;; 9
30 272 46 304

StatText Disabled;; 10
55 5 71 89

EditText Disabled;; 11
55 95 71 127

StatText Disabled;; 12
55 145 71 200

RadioItem ;; 13
55 205 70 303

RadioItem ;; 14
55 305 71 425
Sheet Feed

Printer Dialog Template,-4080

*   1
BtnItem Enabled
224 103 240 173

*   2
StatText Enabled
149 7 165 120
Bottom of page

*   3
StatText Disabled
6 91 23 219
Printer Port Setup

*   4
StatText Disabled
30 6 46 51

*   5
RadioItem Enabled
30 57 46 157
Modem Port

*   6
RadioItem Enabled
30 165 46 265
Printer Port

*   7
StatText Disabled
57 6 73 81
Baud Rate:

*   8
BtnItem Enabled
57 98 73 143

*   9
StatText Disabled
58 153 74 300
(Hit me for more )

*   10
StatText Disabled
83 5 99 122
Line Terminator

*   11
EditText Enabled
83 128 99 320

*   12
EditText Enabled
105 128 121 320

*   13
EditText Enabled
127 128 143 320

*   14
EditText Enabled
149 128 165 320

*   15
EditText Enabled
171 128 187 320

*   16
StatText Disabled
105 6 121 123

*   17
StatText Disabled
127 7 143 124
Top of page

*   18
StatText Enabled
171 8 187 121
End of file

*    19
RadioItem Enabled 
197 8 213 121

*   20
RadioItem Enabled
197 165 213 265

*   21
BtnItem Enabled
224 183 240 253

Printer Config Box,-4080
Serial Port Configuration
40 80 296 424
Invisible NoGoAway
1 ;; procID
0 ;; refCon

Type STR 
Right Button,-4092 ;; Chooser right button title

Type STR 
List label,-4091 ;; Chooser list label
Serial Printer Driver

Type Stng = GNRL
Printer Settings,-8192
0001 0002 0000 0000 ;; Printer port, 1200 baud, no Xon/Xoff

Type STR# ;; String list for EOL, EOP, BOP strings
Printer control strings,-4080 ;; Tandy DMP-110
^M ;; End of line
^[^W    ;; Initialize printer
 ;; beginning of page
^L ;; end of page
 ;; end of document

DasY 0
0 128
0 128

Type DasY = STR 
Version 0.000001


Type ICN# = GNRL
00000000 7FFFFFFE 40000002 40000002
40003802 40004582 4001C642 40024442
40042842 40021F82 4003FE42 40043D42
40025C82 40019442 40009242 40009382
40387202 403C4C02 401C8002 40038002
4001C002 4002F002 40047002 40087002
40080002 43FFC002 42004002 41FF8002
40810002 40420002 7FFFFFFE 00000000
* Printer style dialog template

BtnItem ;;1
10 319 30 379

BtnItem ;;2
10 390 30 450

StatText Disabled;;3
10 5 30 308
Daisy: 8.5" by 11"

RadioItem Enabled;;4
70 5 90 100
10 cpi

RadioItem Enabled;;5
70 120 90 180
12 cpi

RadioItem Enabled;;6
70 200 90 260
15 cpi

RadioItem Enabled;;7
40 5 60 150
Straight up

RadioItem Enabled;;8
40 155 60 300

* Style dialog box
31 20 120 488
Invisible NoGoAway
1 ;; procID
1 ;; refCon

Next Page Box,-8193
Next Page
48 51 100 300
Visible NoGoAway
1 ;; procID
0 ;; refCon

Next Page Template,-8193

*   1
BtnItem Enabled
30 60 46 140

*   2
BtnItem Enabled
30 160 46 240

*   3
8 8 24 292
Daisy: Insert Next Sheet

Community Search:
MacTech Search:

Software Updates via MacUpdate

BBEdit 11.6.1 - Powerful text and HTML e...
BBEdit is the leading professional HTML and text editor for the Mac. Specifically crafted in response to the needs of Web authors and software developers, this award-winning product provides a... Read more
OmniGraffle Pro 6.6.1 - Create diagrams,...
OmniGraffle Pro helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use... Read more
OmniGraffle 6.6.1 - Create diagrams, flo...
OmniGraffle helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use Graffle to... Read more
Dropbox 8.4.21 - Cloud backup and synchr...
Dropbox is an application that creates a special Finder folder that automatically syncs online and between your computers. It allows you to both backup files and keep them up-to-date between systems... Read more
BetterTouchTool 1.84 - Customize Multi-T...
BetterTouchTool adds many new, fully customizable gestures to the Magic Mouse, Multi-Touch MacBook trackpad, and Magic Trackpad. These gestures are customizable: Magic Mouse: Pinch in / out (zoom... Read more
ScreenFlow 6.1 - Create screen recording...
ScreenFlow is powerful, easy-to-use screencasting software for the Mac. With ScreenFlow you can record the contents of your entire monitor while also capturing your video camera, microphone and your... Read more
f.lux 37.7 - Adjusts the color of your d...
f.lux makes the color of your computer's display adapt to the time of day, warm at night and like sunlight during the day. Ever notice how people texting at night have that eerie blue glow? Or wake... Read more
BetterTouchTool 1.84 - Customize Multi-T...
BetterTouchTool adds many new, fully customizable gestures to the Magic Mouse, Multi-Touch MacBook trackpad, and Magic Trackpad. These gestures are customizable: Magic Mouse: Pinch in / out (zoom... Read more
Dropbox 8.4.21 - Cloud backup and synchr...
Dropbox is an application that creates a special Finder folder that automatically syncs online and between your computers. It allows you to both backup files and keep them up-to-date between systems... Read more
OmniGraffle Pro 6.6.1 - Create diagrams,...
OmniGraffle Pro helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use... Read more

3 best fantasy football apps to get you...
Last season didn't go the way you wanted it to in fantasy football. You were super happy following your drafts or auctions, convinced you had outsmarted everyone. You were all set to hustle on the waiver wire, work out some sweet trades, and make... | Read more »
Pokemon GO update: Take me to your leade...
The Team Leaders in Pokemon GO have had it pretty easy up until now. They show up when players reach level 5, make their cases for joining their respective teams, and that's pretty much it. Light work, as Floyd Mayweather might say. [Read more] | Read more »
Ruismaker FM (Music)
Ruismaker FM 1.0 Device: iOS Universal Category: Music Price: $4.99, Version: 1.0 (iTunes) Description: Following up on the success of Ruismaker, here's her crazy twin-sister, designed for people who want to design their own... | Read more »
Space Marshals 2 (Games)
Space Marshals 2 1.0.15 Device: iOS iPhone Category: Games Price: $5.99, Version: 1.0.15 (iTunes) Description: The sci-fi wild west adventure in outer space continues with Space Marshals 2. This tactical top-down shooter puts you in... | Read more »
Dungeon Warfare (Games)
Dungeon Warfare 1.0 Device: iOS Universal Category: Games Price: $3.99, Version: 1.0 (iTunes) Description: Dungeon Warfare is a challenging tower defense game where you become a dungeon lord to defend your dungeon against greedy... | Read more »
Solitairica (Games)
Solitairica 1.0.7 Device: iOS Universal Category: Games Price: $3.99, Version: 1.0.7 (iTunes) Description: Solitairica takes RPG combat and challenging rogue-like progression to a fresh new place—the world of solitaire! | Read more »
Bowmasters tips, tricks and hints
At least for this writer, archery was one of the more pleasant surprises of the 2016 Rio Olympics. As opposed to target shooting with guns, which was dreadfully boring, watching people shoot arrows at targets was pretty darn cool. [Read more] | Read more »
Best apps for watching live TV
The Olympics have come and gone, leaving nearly everyone in a temporary state of "What the heck am I going to watch on TV right now?" Besides old reruns of Golden Girls, but that goes without saying. [Read more] | Read more »
What is Flip Diving, and why has it take...
Move over Pokemon GO. There's a new king in town, and it's "the world's #1 cliff diving game." [Read more] | Read more »
5 places where Pokemon GO is still numbe...
In the U.S., the bloom is off the Pokemon Go rose ever so slightly. It's still doing great, sitting atop the top grossing chart as it has for some time, but it's no longer among the top 10 free apps in downloads, possibly because darn near... | Read more »

Price Scanner via

Apple refurbished 13-inch MacBook Airs availa...
Apple has Certified Refurbished 2016 and 2015 13″ MacBook Airs now available starting at $849. An Apple one-year warranty is included with each MacBook, and shipping is free: - 2016 13″ 1.6GHz/8GB/... Read more
Apple refurbished iPad mini 2s available for...
Apple is offering Certified Refurbished iPad mini 2s for up to $80 off the cost of new minis. An Apple one-year warranty is included with each model, and shipping is free: - 16GB iPad mini 2 WiFi: $... Read more
Save up to $600 with Apple refurbished Mac Pr...
Apple has Certified Refurbished Mac Pros available for up to $600 off the cost of new models. An Apple one-year warranty is included with each Mac Pro, and shipping is free. The following... Read more
Mac Pros on sale for $200 off MSRP
B&H Photo has Mac Pros on sale for $200 off MSRP. Shipping is free, and B&H charges sales tax in NY only: - 3.7GHz 4-core Mac Pro: $2799, $200 off MSRP - 3.5GHz 6-core Mac Pro: $3799, $200... Read more
Will We See A 10.5″ iPad Pro in 2017? – The ‘...
A MacRumors report, cites a research note from KGI Securities analyst Ming-Chi Kuo, saying a new size iPad model is in the works. According to the highly respected Cho, who has a strong track record... Read more
IOGEAR USB-C Docking Station Transforms Lapto...
IOGEAR has announced the launch of its innovative USB-C Docking Station with Power Delivery which turns USB-C enabled laptops into desktop workstations. The new IOGEAR USB-C Docking Station features... Read more
12-inch Retina MacBooks on sale for up to $10...
Amazon has 2016 12″ Apple Retina MacBooks on sale for $100 off MSRP. Shipping is free: - 12″ 1.1GHz Space Gray Retina MacBook: $1199 $100 off MSRP - 12″ 1.1GHz Silver Retina MacBook: $1224.99 $75 off... Read more
13-inch 2.5GHz MacBook Pro (Apple refurbished...
Apple has Certified Refurbished 13″ 2.5GHz MacBook Pros available for $829, or $270 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.5GHz MacBook Pros... Read more
21-inch iMacs on sale for up to $120 off MSRP
B&H Photo has 21″ iMacs on sale for up to $120 off MSRP including free shipping plus NY sales tax only: - 21″ 3.1GHz iMac 4K: $1379 $120 off MSRP - 21″ 2.8GHz iMac: $1199.99 $100 off MSRP - 21″ 1... Read more
Typinator 6.10 comes with 50 improvements – G...
Ergonis Software today announced release of Typinator 6.10, a new version of their text expander utility for macOS. Typinator 6.10 comes with 50 improvements, including new features, compatibility... Read more

Jobs Board

*Apple* Mobile Master - Best Buy (United Sta...
What does a Best Buy Apple Mobile Master do? At Best Buy, our mission is to leverage the unique talents and passions of our employees to inspire, delight, and enrich Read more
*Apple* Retail - Multiple Positions Akron, O...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Simply Mac *Apple* Specialist- Repair Techn...
…The Technician is a master at working with our customers to diagnose and repair Apple devices in a manner that exceeds the expectations set forth by Apple Read more
*Apple* Retail - Multiple Positions Germanto...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
*Apple* Professional Learning Specialist - A...
# Apple Professional Learning Specialist Job Number: 51234379 Portland, Maine, Maine, United States Posted: Aug. 18, 2016 Weekly Hours: 40.00 **Job Summary** The Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.