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

Kodi 17.1. - Powerful media center tool...
Kodi (was XBMC) is an award-winning free and open-source (GPL) software media player and entertainment hub that can be installed on Linux, OS X, Windows, iOS, and Android, featuring a 10-foot user... Read more
Kodi 17.1. - Powerful media center tool...
Kodi (was XBMC) is an award-winning free and open-source (GPL) software media player and entertainment hub that can be installed on Linux, OS X, Windows, iOS, and Android, featuring a 10-foot user... Read more
Bookends 12.8 - Reference management and...
Bookends is a full-featured bibliography/reference and information-management system for students and professionals. Bookends uses the cloud to sync reference libraries on all the Macs you use.... Read more
Apple iTunes 12.6 - Play Apple Music and...
Apple iTunes lets you organize and stream Apple Music, download and watch video and listen to Podcasts. It can automatically download new music, app, and book purchases across all your devices and... Read more
Default Folder X 5.1.4 - Enhances Open a...
Default Folder X attaches a toolbar to the right side of the Open and Save dialogs in any OS X-native application. The toolbar gives you fast access to various folders and commands. You just click on... Read more
Amazon Chime 4.1.5587 - Amazon-based com...
Amazon Chime is a communications service that transforms online meetings with a secure, easy-to-use application that you can trust. Amazon Chime works seamlessly across your devices so that you can... Read more
CrossOver 16.2 - Run Windows apps on you...
CrossOver can get your Windows productivity applications and PC games up and running on your Mac quickly and easily. CrossOver runs the Windows software that you need on Mac at home, in the office,... Read more
Adobe Creative Cloud - Access...
Adobe Creative Cloud costs $19.99/month for a single app, or $49.99/month for the entire suite. Introducing Adobe Creative Cloud desktop applications, including Adobe Photoshop CC and Illustrator CC... Read more
MegaSeg 6.0.2 - Professional DJ and radi...
MegaSeg is a complete solution for pro audio/video DJ mixing, radio automation, and music scheduling with rock-solid performance and an easy-to-use design. Mix with visual waveforms and Magic... Read more
Bookends 12.8 - Reference management and...
Bookends is a full-featured bibliography/reference and information-management system for students and professionals. Bookends uses the cloud to sync reference libraries on all the Macs you use.... Read more

The best deals on the App Store this wee...
Deals, deals, deals. We're all about a good bargain here on 148Apps, and luckily this was another fine week in App Store discounts. There's a big board game sale happening right now, and a few fine indies are still discounted through the weekend.... | Read more »
The best new games we played this week
It's been quite the week, but now that all of that business is out of the way, it's time to hunker down with some of the excellent games that were released over the past few days. There's a fair few to help you relax in your down time or if you're... | Read more »
Orphan Black: The Game (Games)
Orphan Black: The Game 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: Dive into a dark and twisted puzzle-adventure that retells the pivotal events of Orphan Black. | Read more »
The Elder Scrolls: Legends is now availa...
| Read more »
Ticket to Earth beginner's guide: H...
Robot Circus launched Ticket to Earth as part of the App Store's indie games event last week. If you're not quite digging the space operatics Mass Effect: Andromeda is serving up, you'll be pleased to know that there's a surprising alternative on... | Read more »
Leap to victory in Nexx Studios new plat...
You’re always a hop, skip, and a jump away from a fiery death in Temple Jump, a new platformer-cum-endless runner from Nexx Studio. It’s out now on both iOS and Android if you’re an adventurer seeking treasure in a crumbling, pixel-laden temple. | Read more »
Failbetter Games details changes coming...
Sunless Sea, Failbetter Games' dark and gloomy sea explorer, sets sail for the iPad tomorrow. Ahead of the game's launch, Failbetter took to Twitter to discuss what will be different in the mobile version of the game. Many of the changes make... | Read more »
Splish, splash! The Pokémon GO Water Fes...
Niantic is back with a new festival for dedicated Pokémon GO collectors. The Water Festival officially kicks off today at 1 P.M. PDT and runs through March 29. Magikarp, Squirtle, Totodile, and their assorted evolved forms will be appearing at... | Read more »
Death Road to Canada (Games)
Death Road to Canada 1.0 Device: iOS Universal Category: Games Price: $7.99, Version: 1.0 (iTunes) Description: Get it now at the low launch price! Price will go up a dollar every major update. Update news at the bottom of this... | Read more »
Bean's Quest Beginner's Guide:...
Bean's Quest is a new take on both the classic platformer and the endless runner, and it's free on the App Store for the time being. Instead of running constantly, you can't stop jumping. That adds a surprising new level of challenge to the game... | Read more »

Price Scanner via

Updated iPad Price Trackers
Scan our Apple iPad (and iPod touch) Price Trackers for the latest information on sales, bundles, and availability on systems from Apple’s authorized internet/catalog resellers. We update the... Read more
12-inch 32GB Space Gray iPad Pro on sale for...
B&H Photo has 12″ Space Gray 32GB WiFi Apple iPad Pros on sale for $50 off MSRP including free shipping. B&H charges sales tax in NY only: - 12″ Space Gray 32GB WiFi iPad Pro: $749 $50 off... Read more
2.6GHz Mac mini on sale for $559, $140 off MS...
Guitar Center has the 2.6GHz Mac mini (MGEN2LL/A) on sale for $559 including free shipping. Their price is $140 off MSRP, and it’s the lowest price available for this model. Read more
SSD Speeder RAM Disk SSD Life Extender App Fo...
Fehraltorf, Switzerland based B-Eng has announced they are making their SSD Speeder app for macOS publicly available for purchase on their website. SSD Speeder is a RAM disk utility that prevents... Read more
iPhone Scores Highest Overall in Smartphone D...
Customer satisfaction is much higher among smartphone owners who use their device to operate other connected home services such as smart thermostats and smart appliances, according to the J.D. Power... Read more
Swipe CRM Free Photo-Centric CRM Sales DEal C...
Swipe CRM LLC has introduced Swipe CRM: Visual Sales 1.0 for iPad, an app for creating, managing, and sharing visually stunning sales deals. Swipe CRM is targeted to small-and-medium creative... Read more
13-inch 2.0GHz Apple MacBook Pros on sale for...
B&H has the non-Touch Bar 13″ 2.0GHz MacBook Pros in stock today and on sale for $150 off MSRP. Shipping is free, and B&H charges NY sales tax only: - 13″ 2.0GHz MacBook Pro Space Gray (... Read more
15-inch Touch Bar MacBook Pros on sale for up...
B&H Photo has the new 2016 15″ Apple Touch Bar MacBook Pros in stock today and on sale for up to $150 off MSRP. Shipping is free, and B&H charges NY sales tax only: - 15″ 2.7GHz Touch Bar... Read more
Apple’s iPhone 6s Tops Best-Selling Smartphon...
In terms of shipments, the iPhone 6s from Apple bested all competitors for sales in 2016, according to new analysis from IHS Markit, a world leader in critical information, analytics and solutions.... Read more
Logitech Rugged Combo Protective iPad Case an...
Logitech has announced its Logitech Rugged Combo, Logitech Rugged Case, and Logitech Add-on Keyboard for Rugged Case for Apple’s new, more affordable $329 9.7-inch iPad, a complete solution designed... Read more

Jobs Board

*Apple* Mobile Master - Best Buy (United Sta...
**492472BR** **Job Title:** Apple Mobile Master **Location Number:** 000470-Seattle-Store **Job Description:** **What does a Best Buy Apple Mobile Master do?** Read more
*Apple* Mobile Master - Best Buy (United Sta...
**492562BR** **Job Title:** Apple Mobile Master **Location Number:** 000853-Jackson-Store **Job Description:** **What does a Best Buy Apple Mobile Master do?** Read more
*Apple* Retail - Multiple Positions - Apple,...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Fulltime aan de slag als shopmanager in een h...
Ben jij helemaal gek van Apple -producten en vind je het helemaal super om fulltime shopmanager te zijn in een jonge en hippe elektronicazaak? Wil jij werken in Read more
*Apple* Retail - Multiple Positions - Apple,...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.