NetBoot/ServerDA.a

632 lines
28 KiB
Plaintext

***************************************************************************
****
**** MEMORY DESK ACCESSORY - A sample DA written in MPW 68000 Assembly
****
**** Copyright Apple Computer, Inc. 1985-1987, 1993, 1998
**** All rights reserved.
****
***************************************************************************
; Desk accessories (drivers) cannot use global variables in the normal sense.
; Usually, a handle is allocated and stuffed into dCtlStorage and global
; variables are stored in this handle. However, in this example, the globals
; are allocated at the end of the desk accessory's window record. Since the
; window record is always nonrelocatable storage, the variables will never move.
; This record structure below defines the layout of our "global variables."
**************************** DESK ACCESSORY ENTRY **************************
DAEntry ; See Device Manager IM:2
DC.B $24 ; (1<<dCtlEnable) + (1<<dNeedTime) ; periodic,control flags set
DC.B 0 ; Lower byte is unused
DC.W 5*60 ; 5 sec periodic update
DC.W $40 ; (1<<updateEvt) ; Handle only update events
DC.W 0 ; No menu for this accessory
DC.W DAOpen-DAEntry ; Open routine
DC.W DADone-DAEntry ; Prime - unused
DC.W DACtl-DAEntry ; Control
DC.W DADone-DAEntry ; Status - unused
DC.W DAClose-DAEntry ; Close
DATitle
DC.B 17, 'Free Mem (#Bytes)' ; DA Name (& Window Title)
ALIGN 2 ; Word align
************************ DESK ACCESSORY OPEN ROUTINE ***********************
DAOpen
MOVEM.L A1-A4,-(SP) ; preserve A1-A4
MOVE.L A1,A4 ; MOVE DCE pointer to a reg
SUBQ.L #4,SP ; FUNCTION = GrafPtr
MOVE.L SP,-(SP) ; push a pointer to it
DC.W $A874 ; _GetPort ; push it on top of stack
TST.L $1E(A4) ; DCtlEntry.dCtlWindow do we have a window?
BNE.S StdReturn ; If so, return, Else
******************************* NEW WINDOW ROUTINE *************************
MOVE.L #156,D0 ; WindowRecord size
DC.W $A11E ; _NewPtr ; allocate space for record
SUBQ #4,SP ; FUNCTION = WindowRef
MOVE.L A0,-(SP) ; address of storage
PEA theWindow ; boundsRect
PEA DATitle ; title
CLR.W -(SP) ; visible flag FALSE
MOVE.W #16,-(SP) ; window proc = rDocProc, 16px rounding
MOVE.L #-1,-(SP) ; window in front
MOVE.B #1,-(SP) ; goAway box TRUE
CLR.L -(SP) ; refCon is 0
DC.W $A913 ; __NewWindow
MOVE.L (SP)+,A0
MOVE.L A0,$1E(A4) ; DCtlEntry.DCtlWindow save windowPtr
MOVE.W $18(A4),$6C(A0) ; DCtlEntry.DCtlRefNum system window
DC.W $A11D ; __MaxMem
StdReturn
DC.W $A873 ; __SetPort ; old port on stack
MOVEM.L (SP)+,A1-A4 ; restore regs
************************ DESK ACCESSORY DONE ROUTINE ***********************
DADone
MOVEQ #0,D0 ; return no error
RTS ; all done, exit
************************ DESK ACCESSORY CLOSE ROUTINE **********************
DAClose
MOVEM.L A1-A4,-(SP) ; preserve A1-A4
MOVE.L A1,A4 ; MOVE DCE ptr to A4
SUBQ.L #4,SP ; FUNCTION = GrafPtr
MOVE.L SP,-(SP) ; push a pointer to it
DC.W $A874 ; __GetPort ; get it, now it's on TOS
MOVE.L $1E(A4),-(SP) ; DCtlEntry.DCtlWindow push the window
DC.W $A914 ; __DisposeWindow ; dispose of the window
CLR.L $1E(A4) ; DCtlEntry.DCtlWindow mark DCE properly
BRA.S StdReturn ; all done with close, exit
********************** DESK ACCESSORY CONTROL ROUTINE **********************
DACtl
MOVE.L A4,-(SP) ; preserve reg
MOVE.L A1,A4 ; move DCE ptr to A4
MOVE.W $1A(A0),D0 ; get the control opCode
SUB.W #64,D0 ; = 64? (event)
BEQ.S DoCtlEvent
SUB.W #1,D0 ; = 65? (periodic)
BEQ.S DoPeriodic
CtlDone
MOVE.L A4,A1 ; put DCE ptr back in A1
MOVE.L (SP)+,A4 ; restore reg
MOVEQ #0,D0 ; return no error
MOVE.L $8FC,-(SP) ; jump to IODone
RTS
************************** EVENT HANDLING ROUTINE **************************
DoCtlEvent
MOVE.L A3,-(SP) ; save reg
MOVE.L $1C(A0),A3 ; CntrlParam.CSParamget the event pointer
MOVE.W 0(A3),D0 ; EventRecord.what get the event number
SUBQ #6,D0 ; updateEvt is it an update?
BNE.S CtlEvtDone ; If not, exit
MOVE.L 2(A3),-(SP) ; EventRecord.message push windowPtr
DC.W $A922 ; __BeginUpdate ; begin the update operation
MOVE.L 2(A3),-(SP) ; EventRecord.message push windowPtr again
DC.W $A873 ; __SetPort
BSR.S DrawWindow ; draw our items
MOVE.L 2(A3),-(SP) ; EventRecord.message one more time
DC.W $A923 ; __EndUpdate ; end of update
CtlEvtDone
MOVE.L (SP)+,A3 ; restore reg
BRA.S CtlDone ; exit
**************************** PERIODIC ROUTINE *****************************
DoPeriodic
MOVE.L $1E(A4),-(SP) ; DCtlEntry.DCtlWindow set the port
DC.W $A873 ; __SetPort
BSR.S DrawWindow ; draw our window every 5s
BRA.S CtlDone
****************************** FONT METRICS *******************************
DrawWindow
movem.l A0-A5/D0-D7,-(SP)
move.l #$00500050,D0
bsr Poof
movem.l (SP)+,A0-A5/D0-D7
Exit
RTS
***************************** SUBROUTINES ****************************
PrintNum
; Binary integer to be drawn at CurPenPos in D0 on entry
; number drawn in plain text, bolding restored afterwords
MOVE.L D0,D6 ; for safe keeping
CLR.W -(SP) ; plain text
DC.W $A888 ; __TextFace
MOVE.L D6,D0 ; and back again
MOVE.L $1A(A4),A0 ; DCtlEntry.DCtlWindow get window rec pointer
LEA aNumStr,A0 ; get buffer address
move.w #$0000,-(sp)
dc.w $A9EE ; __NumToString ; Binary-Decimal Package
MOVE.L A0,-(SP) ; push the pointer to the str
DC.W $A884 ; __DrawString
MOVE.W #1,-(SP) ; bold text restored
DC.W $A888 ; __TextFace
RTS
******************************* DATA AREA **********************************
s1 dc.b 9, 'AppHeap: '
s2 dc.b 11, ' SysHeap: '
s3 dc.b 8, ' Disk: ', 0
s4 dc.b 9, ' free on '
theWindow DC.W 322,10,338,500 ; window top,left,bottom,right
; Desk accessories (drivers) cannot use global variables in the normal sense.
; Usually, a handle is allocated and stuffed into dCtlStorage and global
; variables are stored in this handle. However, in this example, the globals
; are allocated at the end of the desk accessory's window record. Since the
; window record is always nonrelocatable storage, the variables will never move.
; This record structure below defines the layout of our "global variables."
;GlobalVars RECORD WindowRecord.sizeof ; Put variables at end of window rec
aString DCB.B 28 ; vol names must be < 28 char
aNumStr DCB.B 10 ; sufficient for 10 GB of space
;GlobalSize EQU *-GlobalVars ; size of my globals
; ENDR
Poof ; animation, takes D0
link A6,#-0
move.l D0,-(SP) ; D3 = screen rect
add.l #$00200020,(SP)
move.l D0,-(SP)
move.l SP,D3
move.l #$00200020,-(SP) ; D4 = bitmap rect (0,0,32,32)
clr.l -(SP)
move.l SP,D4
bsr PushBitmapToStack ; D5 = "save screen" bitmap
move.l SP,D5
bsr PushBitmapToStack ; D6 = "scratch" bitmap
move.l SP,D6
; A3 = "artwork" bitmap (changeable)
move.l #$00200020,-(SP) ; bounds.botRight
clr.l -(SP) ; bounds.topLeft
move.w #4,-(SP) ; rowBytes
subq #4,SP ; baseAddr!!!
move.l SP,A3
; A4 = screenBits bitmap
move.l (A5),A4 ; QD globals
lea -122(A4),A4
move.l A4,-(SP) ; srcBits = screenBits
move.l D5,-(SP) ; dstBits = "save screen" bitmap
move.l D3,-(SP) ; srcRect = screen rect
move.l D4,-(SP) ; dstRect = bitmap rect
clr.w -(SP) ; mode = srcCopy
clr.l -(SP) ; no maskRgn
dc.w $A8EC ; _CopyBits
; this is where the loop will start (very cutesy)
clr.l D7 ; loop counter!
.loop
tst.l D7
beq.s .dontwait
.dontwait
move.l D5,-(SP) ; srcBits = "save screen" bitmap
move.l D6,-(SP) ; dstBits = "scratch" bitmap
move.l D4,-(SP) ; srcRect = bitmap rect
move.l D4,-(SP) ; dstRect = bitmap rect
clr.w -(SP) ; mode = srcCopy
clr.l -(SP) ; no maskRgn
dc.w $A8EC ; _CopyBits
lea PoofData,A0
add.l #(PoofDataEnd-PoofData)/2,A0
move.l A0,(A3)
move.l A3,-(SP) ; srcBits = "artwork" bitmap
move.l D6,-(SP) ; dstBits = "scratch" bitmap
move.l D4,-(SP) ; srcRect = bitmap rect
move.l D4,-(SP) ; dstRect = bitmap rect
move.w #3,-(SP) ; mode = srcBic (erase)
clr.l -(SP) ; no maskRgn
dc.w $A8EC ; _CopyBits
lea PoofData,A0
move.l A0,(A3)
move.l A3,-(SP) ; srcBits = "artwork" bitmap
move.l D6,-(SP) ; dstBits = "scratch" bitmap
move.l D4,-(SP) ; srcRect = bitmap rect
move.l D4,-(SP) ; dstRect = bitmap rect
move.w #1,-(SP) ; mode = srcOr
clr.l -(SP) ; no maskRgn
dc.w $A8EC ; _CopyBits
move.l D6,-(SP) ; srcBits = "scratch" bitmap
move.l A4,-(SP) ; dstBits = screenBits
move.l D4,-(SP) ; srcRect = bitmap rect
move.l D3,-(SP) ; dstRect = screen rect
clr.w -(SP) ; mode = srcCopy
clr.l -(SP) ; no maskRgn
dc.w $A8EC ; _CopyBits
unlk A6
rts
PushBitmapToStack ; assumes 32x32, leaves bitmap structure on stack
move.l (SP)+,A0
sub #32*32/8,SP ; the actual data
move.l #$00200020,-(SP) ; bounds.botRight
clr.l -(SP) ; bounds.topLeft
move.w #32/8,-(SP) ; rowBytes
pea 10(SP) ; baseAddr
jmp (A0) ; return
PoofData
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000001111100000000000
dc.l %00000000000000110000011000000000
dc.l %00000000011110100000000100000000
dc.l %00001111100001101101011010000000
dc.l %00010000100000010010101001111000
dc.l %00100000000000100000000010001100
dc.l %00100000000000100000000010000010
dc.l %00100000000111001111100000000010
dc.l %00100000001000110000010000000001
dc.l %00100000000000100000010000000001
dc.l %01010000000000000000010000000010
dc.l %01010001100000000000010000000010
dc.l %10001110100000000000001000001100
dc.l %10000000100000000000001000000100
dc.l %01000000010000000000001000000010
dc.l %01000000001000000010010000000010
dc.l %01110000001000000010010000000010
dc.l %00010000000110000101100000000100
dc.l %00010010010001111100000001111000
dc.l %00001101100000000000001001000000
dc.l %00001000000000000000001101000000
dc.l %00001000000000000001000101000000
dc.l %00000100010000000110111001000000
dc.l %00000011110000001100000010000000
dc.l %00000001000000001011111100000000
dc.l %00000000111000110000000000000000
dc.l %00000000000111000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000110000011101111000000
dc.l %00000000011001100100010001000000
dc.l %00000000010000101000000001000000
dc.l %00001110100000010000000001100000
dc.l %00010001100000010000100000010000
dc.l %00010000000000101001000110100000
dc.l %00100000111100100110000010010000
dc.l %00010001000101010010000110010000
dc.l %00011000000010010100000001010000
dc.l %00001000100010001000010000100000
dc.l %00001000011100010100001000100000
dc.l %00001011100001100011111111000000
dc.l %00000100100010000000000000000000
dc.l %00001110111110000111100111011000
dc.l %00010001000001001000011000100100
dc.l %00100000000001010000000010001000
dc.l %00100000000000110000001101011000
dc.l %00100100111110010000000001000100
dc.l %00011101001010001000000000100010
dc.l %00100001000000010111000000010010
dc.l %00100001000000100100000000100010
dc.l %00010000100010100100000111001100
dc.l %00001101000100010100000000001000
dc.l %00001001001000010011110000111000
dc.l %00001001110011001000100000100000
dc.l %00001100000100110000010001000000
dc.l %00000011111000000000001110000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000001110000001100000000000
dc.l %00000000001010000010010000000000
dc.l %00000000000110111011010000000000
dc.l %00000000001001000101101100000000
dc.l %00000001110101000010010010000000
dc.l %00000010000110111110100110000000
dc.l %00000010000001000000100001000000
dc.l %00000011100010011110010001010000
dc.l %00000001000110100010010010101000
dc.l %00000001001001000001101101001000
dc.l %00001110110010000010010000110000
dc.l %00010010001110000000001000000000
dc.l %00011110010010001000000100110000
dc.l %00000000100001110000000101001000
dc.l %00001111000001001000000101000100
dc.l %00010010101110000100001001000010
dc.l %00100010010011000111110110111100
dc.l %00010011000001000100001001000000
dc.l %00001100110000111010010001000000
dc.l %00000001101111000001010110100000
dc.l %00000010010001001101010000010000
dc.l %00000100010001010000101000001000
dc.l %00000011100000110111100100001000
dc.l %00000000011100001010010010010000
dc.l %00000000010010000010001001100000
dc.l %00000000010010000001110000000000
dc.l %00000000001100000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000010000000000000000000000
dc.l %00000000011000000000000000000000
dc.l %00000000000001110001000000000000
dc.l %00000000000010001000010000000000
dc.l %00000000000010010000101000000000
dc.l %00000011100001100001001000000000
dc.l %00000100010000000000110010000000
dc.l %00000110001000000000000101000000
dc.l %00000100001001111000110010000000
dc.l %00000100001001000101001000000000
dc.l %00000011010001000010001000000000
dc.l %00000000100001000101110000000000
dc.l %00000010000001101000000000000000
dc.l %00000000000000011111000000000000
dc.l %00000011101110001000100001000000
dc.l %00000100010010001100100100000000
dc.l %00000010100001000111000000000000
dc.l %00000001010001000000111100000000
dc.l %00000000001110000100100010000000
dc.l %00000000000000001010100110000000
dc.l %00000000010010000101011101000000
dc.l %00000000001100001010001000100000
dc.l %00000000000000000100000100100000
dc.l %00000000000010000000000011000000
dc.l %00000000000000000001000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000110000000000000000
dc.l %00000000000001010000001100000000
dc.l %00000000000001100000000100000000
dc.l %00000000000000000000001000000000
dc.l %00000011000000000000000000000000
dc.l %00000000011000000001000000000000
dc.l %00000000100100000010100000000000
dc.l %00000000100101110100010000000000
dc.l %00000000011010001011100000000000
dc.l %00000000000001010000000000000000
dc.l %00000000000000110000000000000000
dc.l %00000000000000101100000000000000
dc.l %00000000000000011000000000000000
dc.l %00000001011100000000000000000000
dc.l %00000000100010000000000000000000
dc.l %00000000100010000000000000000000
dc.l %00000000011010000000000000000000
dc.l %00000000000100000000000010000000
dc.l %00000000010000001100000000000000
dc.l %00000000000000010010000000000000
dc.l %00000000000000001100000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000001111100000000000
dc.l %00000000000000111111111000000000
dc.l %00000000011110111111111100000000
dc.l %00001111111111111111111110000000
dc.l %00011111111111111111111111111000
dc.l %00111111111111111111111111111100
dc.l %00111111111111111111111111111110
dc.l %00111111111111111111111111111110
dc.l %00111111111111111111111111111111
dc.l %00111111111111111111111111111111
dc.l %01111111111111111111111111111110
dc.l %01111111111111111111111111111110
dc.l %11111111111111111111111111111100
dc.l %11111111111111111111111111111100
dc.l %01111111111111111111111111111110
dc.l %01111111111111111111111111111110
dc.l %01111111111111111111111111111110
dc.l %00011111111111111111111111111100
dc.l %00011111111111111111111111111000
dc.l %00001111111111111111111111000000
dc.l %00001111111111111111111111000000
dc.l %00001111111111111111111111000000
dc.l %00000111111111111111111111000000
dc.l %00000011111111111111111110000000
dc.l %00000001111111111011111100000000
dc.l %00000000111111110000000000000000
dc.l %00000000000111000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000110000011101111000000
dc.l %00000000011111100111111111000000
dc.l %00000000011111101111111111000000
dc.l %00001110111111111111111111100000
dc.l %00011111111111111111111111110000
dc.l %00011111111111101111111111100000
dc.l %00111111111111100111111111110000
dc.l %00011111111111110011111111110000
dc.l %00011111111111110111111111110000
dc.l %00001111111111111111111111100000
dc.l %00001111111111110111111111100000
dc.l %00001111111111100011111111000000
dc.l %00000100111110000000000000000000
dc.l %00001110111110000111100111011000
dc.l %00011111111111001111111111111100
dc.l %00111111111111011111111111111000
dc.l %00111111111111111111111111111000
dc.l %00111111111111111111111111111100
dc.l %00011111111111111111111111111110
dc.l %00111111111111110111111111111110
dc.l %00111111111111100111111111111110
dc.l %00011111111111100111111111111100
dc.l %00001111111111110111111111111000
dc.l %00001111111111110011111111111000
dc.l %00001111111111111000111111100000
dc.l %00001111111100110000011111000000
dc.l %00000011111000000000001110000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000001110000001100000000000
dc.l %00000000001110000011110000000000
dc.l %00000000000110111011110000000000
dc.l %00000000001001111101101100000000
dc.l %00000001111101111110011110000000
dc.l %00000011111110111110111110000000
dc.l %00000011111111000000111111000000
dc.l %00000011111110011110011111010000
dc.l %00000001111110111110011110111000
dc.l %00000001111001111111101101111000
dc.l %00001110110011111111110000110000
dc.l %00011110001111111111111000000000
dc.l %00011110011111111111111100110000
dc.l %00000000111111111111111101111000
dc.l %00001111111111001111111101111100
dc.l %00011111111110000111111001111110
dc.l %00111111111111000111110110111100
dc.l %00011111111111000100001111000000
dc.l %00001100111111111110011111000000
dc.l %00000001101111111111011111100000
dc.l %00000011110001111111011111110000
dc.l %00000111110001111111101111111000
dc.l %00000011100000111111100111111000
dc.l %00000000011100001011110011110000
dc.l %00000000011110000011111001100000
dc.l %00000000011110000001110000000000
dc.l %00000000001100000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000010000000000000000000000
dc.l %00000000011000000000000000000000
dc.l %00000000000001110001000000000000
dc.l %00000000000011111000010000000000
dc.l %00000000000011110000111000000000
dc.l %00000011100001100001111000000000
dc.l %00000111110000000000110010000000
dc.l %00000111111000000000000111000000
dc.l %00000111111001111000110010000000
dc.l %00000111111001111101111000000000
dc.l %00000011110001111111111000000000
dc.l %00000000100001111101110000000000
dc.l %00000010000001111000000000000000
dc.l %00000000000000011111000000000000
dc.l %00000011101110001111100001000000
dc.l %00000111111110001111100100000000
dc.l %00000011111111000111000000000000
dc.l %00000001011111000000111100000000
dc.l %00000000001110000100111110000000
dc.l %00000000000000001110111110000000
dc.l %00000000011110000111011111000000
dc.l %00000000001100001110001111100000
dc.l %00000000000000000100000111100000
dc.l %00000000000010000000000011000000
dc.l %00000000000000000001000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000110000000000000000
dc.l %00000000000001110000001100000000
dc.l %00000000000001100000001100000000
dc.l %00000000000000000000001000000000
dc.l %00000011000000000000000000000000
dc.l %00000000011000000001000000000000
dc.l %00000000111100000011100000000000
dc.l %00000000111101110111110000000000
dc.l %00000000011011111011100000000000
dc.l %00000000000001110000000000000000
dc.l %00000000000000110000000000000000
dc.l %00000000000000111100000000000000
dc.l %00000000000000011000000000000000
dc.l %00000001011100000000000000000000
dc.l %00000000111110000000000000000000
dc.l %00000000111110000000000000000000
dc.l %00000000011110000000000000000000
dc.l %00000000000100000000000010000000
dc.l %00000000010000001100000000000000
dc.l %00000000000000011110000000000000
dc.l %00000000000000001100000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
dc.l %00000000000000000000000000000000
PoofDataEnd