home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1999 / MacHack 1999.toast / The Hacks / DotMatrixScript / dotMatrix.c next >
Encoding:
Text File  |  1999-06-25  |  1.1 KB  |  60 lines  |  [TEXT/CWIE]

  1. pascal void DotMatrix (TPPrPortRef printPort);
  2. asm void __Startup__ (void);
  3. void main (void);
  4.  
  5. asm void __Startup__ (void)
  6. {
  7.         bra.s    trueEntry
  8.         
  9. origFunc:
  10.         dc.l        0
  11.  
  12. trueEntry:
  13.         cmp.l        #0x1800040C,4(sp)            // is this a call to PrClosePage?
  14.         beq.s        DoSneak
  15.         bra.s        SkipSneak
  16.         
  17. DoSneak:
  18.         move.l        8(sp),-(sp)
  19.         jsr            DotMatrix
  20.         
  21. SkipSneak:
  22.         
  23.         move.l        origFunc, -(sp)                // fake out the rts to go to the original function
  24.         rts                                        // get outta here
  25. }
  26.  
  27.  
  28. pascal void DotMatrix (TPPrPortRef printPort)
  29. {
  30.     GrafPtr        origPort;
  31.     short        i;
  32.     
  33.     GetPort (&origPort);
  34.     
  35.     SetPort ((GrafPtr)printPort);
  36.     
  37.     ForeColor (whiteColor); // force white
  38.     
  39.     // horizontal lines
  40.     for (i = printPort->gPort.portRect.top; i += 2; i <= printPort->gPort.portRect.bottom)
  41.     {
  42.         MoveTo (printPort->gPort.portRect.left, i);
  43.         LineTo (printPort->gPort.portRect.right, i);
  44.     }
  45.     
  46.     // vertical lines
  47.     for (i = printPort->gPort.portRect.left; i += 2; i <= printPort->gPort.portRect.right)
  48.     {
  49.         MoveTo (i, printPort->gPort.portRect.top);
  50.         LineTo (i, printPort->gPort.portRect.bottom);
  51.     }
  52.     
  53.     SetPort (origPort);
  54. }
  55.  
  56.  
  57. void main (void) // to make the compiler happy
  58. {
  59. }
  60.