home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel
/
CAROUSEL.cdr
/
mactosh
/
init
/
rwatcher.sit
/
ShowInit.a
< prev
next >
Wrap
Text File
|
1988-10-27
|
5KB
|
234 lines
title 'ShowInit'
;__________________________________________________________________
;
; ShowInit - Show INIT icon at boot time.
;
; Version 1.0. October, 1988.
;
; John Norstad
; Academic Computing and Network Services
; Northwestern University
; 2129 Sheridan Road
; Evanston, IL 60208
;
; Bitnet: jln@nuacc
; Internet: jln@nuacc.acns.nwu.edu
;
; Adapted from a version by Paul Mercer, Darin Adler, and
; Paul Snively, as posted to comp.sys.mac.programmer by William
; Bumgarner.
;
; PROCEDURE ShowInit (iconID: Integer)
;
; iconID = resource ID of ICN# resource.
;__________________________________________________________________
;__________________________________________________________________
;
; ShowInit is written in MPW assembler. Use the following MPW
; command to assemble it:
;
; asm -wb -l -pagesize 73,105 ShowInit.a
;__________________________________________________________________
; Include Files.
print off
include 'Traps.a'
include 'QuickEqu.a'
include 'SysEqu.a'
include 'ToolEqu.a'
print on
;__________________________________________________________________
;
; Constants and Assembly Options.
;__________________________________________________________________
; New ShowInit low core globals.
;
; newH = left coordinate of next INIT icon to be displayed. [word]
; newCheck = newH shifted left 1, xor'd with the constant $1021.
; [word]
newH equ CurApName+32-4
newCheck equ newH+2
; Old ShowInit low core globals.
;
; oldH = left coordinate of next INIT icon to be displayed. [word]
; oldCheck = constant 'Paul'. [long]
oldH equ ApplScratch+4+2
oldCheck equ ApplScratch
; Miscellany.
eorMask equ $1021 ; mask for forming newCheck
hOffset equ 40 ; horizontal offset between icons
oldKey equ 'Paul' ; oldCheck constant
eject
;__________________________________________________________________
;
; The Procedure.
;__________________________________________________________________
ShowInit proc export
StackFrame record {oldA6},decrement
iconID ds.w 1 ; resource id of icon
retAddr ds.l 1 ; return address
oldA6 ds.l 1 ; old A6
destRect ds.w 4 ; icon destination rect
myBitMap ds bitMapRec ; icon source bitmap
myPort ds portRec ; grafport
thePort ds.l 1 ; QuickDraw globals
ds grafSize-4
localA5 ds.l 1 ; A5 world for QuickDraw
size equ *
endr
with StackFrame
; Entry. Create stack frame and save registers.
link a6,#size
movem.l a2-a5,-(sp)
; Load and lock the ICN# resource.
clr.l -(sp)
move.l #'ICN#',-(sp)
move.w iconID(a6),-(sp)
_GetResource
move.l (sp)+,d0
beq Exit ; if error
move.l d0,a0
_HLock
move.l a0,a3 ; (a3) = handle to ICN#
; Initialize QuickDraw and open a port.
lea localA5(a6),a5
pea thePort(a6)
_InitGraf
pea myPort(a6)
_OpenPort
; Get (newH) = coordinate of left side of icon. The previous INIT
; (if any) may or may not have left this value in newH for us.
; In any case the following magic makes sure it's correct.
move.w newH,d0
rol.w #1,d0
eor.w #eorMask,d0
cmp.w newCheck,d0
beq.s NewHOK ; if new ShowInit
cmp.l #oldKey,oldCheck
beq.s OldHOK ; if old ShowInit
move.w #8,newH ; if we're the first
bra.s NewHOK
OldHOK:
move.w oldH,newH
NewHOK:
; Get (d0) = coordinates of top left corner of icon.
lea myPort(a6),a4 ; (a4) = ptr to myPort
move.w portBounds+bottom(a4),d0
sub.w #8+32,d0
swap d0
move.w newH,d0
; Set destRect = destination rectangle of icon.
move.l d0,destRect(a6)
move.l d0,destRect+botRight(a6)
add.l #$00200020,destRect+botRight(a6)
; Set myBitMap = bitmap for icon mask.
move.l (a3),a0 ; (a0) = ptr to ICN#
lea myBitMap(a6),a2 ; (a2) = ptr to myBitMap
move.l a0,baseAddr(a2) ; baseAddr =
add.l #128,baseAddr(a2) ; ptr to mask
move.w #4,rowBytes(a2) ; rowbytes = 32/8 bytes
move.l #0,bounds(a2) ; bounds.topleft = 0,0
move.l #$00200020,bounds+botRight(a2)
; bounds.botright = 32,32
; Call CopyBits to erase mask (punch hole).
move.l a2,-(sp) ; srcBits
pea portBits(a4) ; dstBits
pea srcRect ; srcRect = 0,0,32,32
pea destRect(a6) ; dstRect
move.w #srcBic,-(sp) ; mode
clr.l -(sp) ; maskRgn
_CopyBits
; Set myBitMap = bitmap for icon proper.
sub.l #128,baseAddr(a2) ; baseAddr = ptr to icon
; Call CopyBits to draw icon over mask.
move.l a2,-(sp) ; srcBits
pea portBits(a4) ; dstBits
pea srcRect ; srcRect = 0,0,32,32
pea destRect(a6) ; dstRect
move.w #srcOr,-(sp) ; mode
clr.l -(sp) ; maskRgn
_CopyBits
; Update newH and newCheck for next icon.
move.w newH,d0
add.w #hOffset,d0
move.w d0,newH
rol.w #1,d0
eor.w #eorMask,d0
move.w d0,newCheck
; Close the grafport.
pea myPort(a6)
_ClosePort
; Release the ICN# resource.
move.l a3,-(sp)
_ReleaseResource
; Exit.
Exit:
movem.l (sp)+,a2-a5 ; restore registers
unlk a6 ; unlink
move.l (sp)+,a0 ; return address
add.l #2,sp ; get rid of param
jmp (a0) ; return
srcRect dc.w 0,0,32,32
endwith
endproc
end