home *** CD-ROM | disk | FTP | other *** search
/ Carousel / CAROUSEL.cdr / mactosh / init / rwatcher.sit / ShowInit.a < prev    next >
Text File  |  1988-10-27  |  5KB  |  234 lines

  1.     title    'ShowInit'
  2. ;__________________________________________________________________
  3. ;
  4. ; ShowInit - Show INIT icon at boot time.
  5. ;
  6. ; Version 1.0.  October, 1988.
  7. ;
  8. ; John Norstad
  9. ; Academic Computing and Network Services
  10. ; Northwestern University
  11. ; 2129 Sheridan Road
  12. ; Evanston, IL 60208
  13. ;
  14. ; Bitnet: jln@nuacc
  15. ; Internet: jln@nuacc.acns.nwu.edu
  16. ;
  17. ; Adapted from a version by Paul Mercer, Darin Adler, and
  18. ; Paul Snively, as posted to comp.sys.mac.programmer by William
  19. ; Bumgarner.
  20. ;
  21. ; PROCEDURE ShowInit (iconID: Integer)
  22. ;
  23. ; iconID = resource ID of ICN# resource.
  24. ;__________________________________________________________________
  25.  
  26.  
  27. ;__________________________________________________________________
  28. ;
  29. ; ShowInit is written in MPW assembler.  Use the following MPW
  30. ; command to assemble it:
  31. ;
  32. ; asm -wb -l -pagesize 73,105 ShowInit.a
  33. ;__________________________________________________________________
  34.  
  35.  
  36. ; Include Files.
  37.  
  38.     print   off
  39.     include    'Traps.a'
  40.     include 'QuickEqu.a'
  41.     include 'SysEqu.a'
  42.     include 'ToolEqu.a'
  43.     print   on
  44.     
  45.     
  46. ;__________________________________________________________________
  47. ;
  48. ; Constants and Assembly Options.
  49. ;__________________________________________________________________
  50.  
  51.  
  52. ; New ShowInit low core globals.
  53. ;
  54. ; newH = left coordinate of next INIT icon to be displayed.  [word]
  55. ; newCheck = newH shifted left 1, xor'd with the constant $1021. 
  56. ;    [word]
  57.  
  58. newH        equ    CurApName+32-4
  59. newCheck    equ    newH+2        
  60.  
  61.  
  62. ; Old ShowInit low core globals.
  63. ;
  64. ; oldH = left coordinate of next INIT icon to be displayed.  [word]
  65. ; oldCheck = constant 'Paul'.  [long]
  66.  
  67. oldH        equ    ApplScratch+4+2
  68. oldCheck    equ    ApplScratch
  69.  
  70.  
  71. ; Miscellany.
  72.  
  73. eorMask    equ    $1021        ; mask for forming newCheck
  74. hOffset    equ    40        ; horizontal offset between icons
  75. oldKey    equ    'Paul'        ; oldCheck constant
  76.     eject
  77. ;__________________________________________________________________
  78. ;
  79. ; The Procedure.
  80. ;__________________________________________________________________
  81.  
  82.  
  83. ShowInit    proc    export
  84.  
  85. StackFrame    record    {oldA6},decrement
  86. iconID        ds.w    1        ; resource id of icon
  87. retAddr        ds.l    1        ; return address
  88. oldA6        ds.l    1        ; old A6
  89. destRect    ds.w    4        ; icon destination rect
  90. myBitMap    ds    bitMapRec    ; icon source bitmap
  91. myPort        ds    portRec        ; grafport
  92. thePort        ds.l    1        ; QuickDraw globals
  93.         ds    grafSize-4
  94. localA5        ds.l    1        ; A5 world for QuickDraw
  95. size        equ    *
  96.         endr
  97.         
  98.     with    StackFrame
  99.         
  100. ; Entry.  Create stack frame and save registers.
  101.         
  102.     link    a6,#size
  103.     movem.l    a2-a5,-(sp)
  104.         
  105. ; Load and lock the ICN# resource.
  106.  
  107.     clr.l    -(sp)
  108.     move.l    #'ICN#',-(sp)
  109.     move.w    iconID(a6),-(sp)
  110.     _GetResource
  111.     move.l    (sp)+,d0
  112.     beq    Exit            ; if error
  113.     move.l    d0,a0
  114.     _HLock
  115.     move.l    a0,a3            ; (a3) = handle to ICN#
  116.         
  117. ; Initialize QuickDraw and open a port.
  118.  
  119.     lea    localA5(a6),a5
  120.     pea    thePort(a6)
  121.     _InitGraf
  122.     pea    myPort(a6)
  123.     _OpenPort
  124.     
  125. ; Get (newH) = coordinate of left side of icon.  The previous INIT
  126. ; (if any) may or may not have left this value in newH for us.
  127. ; In any case the following magic makes sure it's correct.
  128.  
  129.     move.w    newH,d0
  130.     rol.w    #1,d0
  131.     eor.w    #eorMask,d0
  132.     cmp.w    newCheck,d0
  133.     beq.s    NewHOK        ; if new ShowInit
  134.     cmp.l    #oldKey,oldCheck
  135.     beq.s    OldHOK        ; if old ShowInit
  136.     move.w    #8,newH        ; if we're the first
  137.     bra.s    NewHOK
  138.     
  139. OldHOK:
  140.  
  141.     move.w    oldH,newH
  142.     
  143. NewHOK:
  144.  
  145. ; Get (d0) = coordinates of top left corner of icon.
  146.  
  147.     lea    myPort(a6),a4        ; (a4) = ptr to myPort
  148.     move.w    portBounds+bottom(a4),d0
  149.     sub.w    #8+32,d0
  150.     swap    d0
  151.     move.w    newH,d0
  152.  
  153. ; Set destRect = destination rectangle of icon.
  154.  
  155.     move.l    d0,destRect(a6)
  156.     move.l    d0,destRect+botRight(a6)
  157.     add.l    #$00200020,destRect+botRight(a6)
  158.     
  159. ; Set myBitMap = bitmap for icon mask.
  160.  
  161.     move.l    (a3),a0            ; (a0) = ptr to ICN#
  162.     lea    myBitMap(a6),a2        ; (a2) = ptr to myBitMap
  163.     move.l    a0,baseAddr(a2)        ; baseAddr = 
  164.     add.l    #128,baseAddr(a2)    ;    ptr to mask
  165.     move.w    #4,rowBytes(a2)        ; rowbytes = 32/8 bytes
  166.     move.l    #0,bounds(a2)        ; bounds.topleft = 0,0
  167.     move.l    #$00200020,bounds+botRight(a2)
  168.                     ; bounds.botright = 32,32
  169.                     
  170. ; Call CopyBits to erase mask (punch hole).
  171.  
  172.     move.l    a2,-(sp)        ; srcBits
  173.     pea    portBits(a4)        ; dstBits
  174.     pea    srcRect            ; srcRect = 0,0,32,32
  175.     pea    destRect(a6)        ; dstRect
  176.     move.w    #srcBic,-(sp)        ; mode
  177.     clr.l    -(sp)            ; maskRgn
  178.     _CopyBits
  179.  
  180. ; Set myBitMap = bitmap for icon proper.
  181.  
  182.     sub.l    #128,baseAddr(a2)    ; baseAddr = ptr to icon
  183.     
  184. ; Call CopyBits to draw icon over mask.
  185.  
  186.     move.l    a2,-(sp)        ; srcBits
  187.     pea    portBits(a4)        ; dstBits
  188.     pea    srcRect            ; srcRect = 0,0,32,32
  189.     pea    destRect(a6)        ; dstRect
  190.     move.w    #srcOr,-(sp)        ; mode
  191.     clr.l    -(sp)            ; maskRgn
  192.     _CopyBits
  193.     
  194. ; Update newH and newCheck for next icon.
  195.  
  196.     move.w    newH,d0
  197.     add.w    #hOffset,d0
  198.     move.w    d0,newH
  199.     rol.w    #1,d0
  200.     eor.w    #eorMask,d0
  201.     move.w    d0,newCheck
  202.     
  203. ; Close the grafport.
  204.  
  205.     pea    myPort(a6)
  206.     _ClosePort
  207.     
  208. ; Release the ICN# resource.
  209.  
  210.     move.l    a3,-(sp)
  211.     _ReleaseResource
  212.     
  213. ; Exit.
  214.  
  215. Exit:
  216.     
  217.     movem.l    (sp)+,a2-a5        ; restore registers
  218.     unlk    a6            ; unlink
  219.     move.l    (sp)+,a0        ; return address
  220.     add.l    #2,sp            ; get rid of param
  221.     jmp    (a0)            ; return
  222.     
  223. srcRect    dc.w    0,0,32,32
  224.  
  225.     endwith
  226.     
  227.     endproc
  228.     
  229.     end
  230.  
  231.     
  232.         
  233.     
  234.