[comp.sys.mac.programmer] Low level printer driver calls

meb4074@cec1.wustl.edu (Mark Edward Bradley) (12/08/89)

   If anyone is familiar with low-level printer driver calls, I would appreciate
some advice. I am using the access routines described in Inside Mac II, chapter
5. I am trying to output a bitmap to the printer, with dubious success. My code
follows: (I am programming in assembly language. Sorry, C gods, I'm a new boy)

          _PrDrvrOpen                   ; Open the driver
          move.w      #iPrDevCtl,-(SP)  ; Printer control code
          move.l      #lPrReset,-(SP)   ; Reset printer code
          move.l      #0,-(SP)          ; Unused
          move.l      #0,-(SP)
          _PrCtlCall                    ; Call the driver routine
          move.w      #iPrBitsCtl,-(SP) ; Bit map printing code
          move.l      MyWindPtr,-(SP)   ; Window pointer
          addq.l      #2,(SP)           ; Set pointer on stack to the portBits
          pea         MyRect            ; Enclosing rectangle
          move.l      #lPaintBits,-(SP) ; Use square pixels
          _PrCtlCall
          move.w      #iPrDevCtl,-(SP)
          move.l      #lPrPageEnd,-(SP) ; End page code
          move.l      #0,-(SP)
          move.l      #0,-(SP)
          _PrCtlCall
          _PrDrvrClose                  ; Close the driver

     The first time this routine executes, everything works. Any time after
that, the code executes (I checked w/ MacsBug), but the printer doesn't respond.
When I go to the Chooser, the printer is no longer selected. After re-selecting,
exiting, and re-entering, it still is not selected. When I exit my program, the
system crashes, but not always immediately. And when I reboot, the printer will
form feed without prompting at some point. (Seems to happen during window
operations?)
     Very little of the code above is my own. It's almost verbatim from IM.
I don't know what I'm missing. If you know what might be the problem or if I'm
leaving something out, please e-mail. I'm using a Mac SE with 2MB, no special
hardware, an AppleTalk Imagewriter and an AppleTalk ImageWriter LQ. I'm also
using the Consulair Development System.

Profuse thanks,
           Mark

-------------------------------------------------------------------------------
"Come to .test,    |        meb4074@cec1.wustl.edu        |  "I'm brave!
 the land without  |         Mark Edward Bradley          |   But I'm careful."
 flames!"          |             Markie B.!!              |     -- Goofy

ewing@tramp.Colorado.EDU (EWING DAVID JAMES) (12/09/89)

Don't use the low level printer driver!  It is about to disappear!  Currently
it calls the high level driver to get the work done (rolls reversed!).  Instead
do the equivalent of whats on page 155 of IM-II.  Use CopyBits to do the
drawing.  Be aware that you may have to band the image (do mulitple CopyBits
calls for the image) if the program is low on memory - otherwise you might
not get any output.

Dave Ewing
ewing@tramp.colorado.edu  (128.138.238.33)
..!hplabs!boulder!onecom!tyvax!iftech!dave (My Mac IIx running uupc & MacOS!)
AppleLink: D2408	  (D2408@applelink.apple.com)