info-mac@uw-beaver (12/22/84)
From: Walter.Smith@CMU-CS-K
[EDITOR: Please remove the data from the bottom of this message and
archive it (as SLEEP.HCX and SLEEP.SH, I suppose). Thanks.]
I have written a desk accessory reminiscent of the Xerox memory test
programs; it clears the screen completely and bounces an apple character
randomly about the screen. It doesn't actually test memory or anything,
but it keeps your display from being burned in. It lasts until you click
the mouse, then restores the screen.
So far it works with everything except MacTerminal. I don't know why
MacTerm doesnt like it. If anyone knows, please tell me.
Included in this message are two files: a Desk Accessory Mover 1.4 file
containing the accessory, and a shell archive containing the source (it
requires the traditional desk and device.h).
- Walter Smith (wrs@cmu-cs-k)
------------sleep.hcx----------------------
(This file must be converted with BinHex.Hex)
#DESKDAMV$0000
***COMPRESSED
***DATA FORK
( - )3 53;&5E<&5S:R!!8V-E<W-O<FEE<P!.5O_T
("\,2&[__*ER0J>I)"A?( QF"$AMOHBH46 .#&P 0!L
(&\&2&V^B*A1*%].7DYU3E8 $)G3KH$A! ?0JX #$Y>
("Z?3G5.5O[>3KK_LJFT0F<_//__2&W^<*EP'5___3 M
(/YP9P !W%- 9QQ50&< 9)50&< 8Q30&< <!50&<
( &T8 !SD)G+RW^>DAN_N*I+#U?__XP+O_^4T!G%%-
(&<:4T!G3E- 9R!50&<N8 !3D)G3KKYS& 41(;?YP
("\N_N*ILV 38O+O[B+RW^>DAM_I"I)6 20 0! R
( "0 #P 0 #( X #0 -@ R 8 4VQE97
( & L K@
(
( $CG__]#^O^:(@E#^O_()%G5P1X2 H< #_
($(2TY(,AP /]G$$J'9@8D6=7!8.+CG]7'8-P(.0
( 7MG##\\ &IR' !2H!F_"/- P 7#/Y @ !# 4
( (3-___R \! !$& >(#P$ %J8!8@/ 0 :!@#B \
( 0 ;1@!B \'0 !R$CG/_PO"2\(($!.D%"/3-\__ R
($ !F!$* 3G4O.0 "/Q.=0# !.5O_\2.X /_\
($IY!@ (=&8N2&[__$ZY! $(%B/+SP# B$3KD& 0
(%B/+R[__$ZY!0 $$%B/,_P 14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&5E<&5S:R!!8V-E<W-O<FEE<P!.5O_T
("\,2&[__*ER0J>I)"A?( QF"$AMOHBH46 .#&P 0!L
(&\&2&V^B*A1*%].7DYU3E8 $)G3KH$A! ?0JX #$Y>
("Z?3G5.5O[>3KK_LJFT0F<_//__2&W^<*EP'5___3 M
(/YP9P !W%- 9QQ50&< 9)50&< 8Q30&< <!50&<
( &T8 !SD)G+RW^>DAN_N*I+#U?__XP+O_^4T!G%%-
(&<:4T!G3E- 9R!50&<N8 !3D)G3KKYS& 41(;?YP
("\N_N*ILV 38O+O[B+RW^>DAM_I"I)6 20 0! R
!@
***END OF DATA
***CRC:3150
--------------cut-here---------------------
------------sleep.sh-----------------------
#
# type sh sleep.sh to unpack this archive.
#
echo extracting Makefile...
cat >Makefile <<'!E!O!F!'
.SUFFIXES: .rsrc .b .ln .s .c
BIN=/usr/apple/bin/
INCLUDE=/usr/apple/include
CFILES = desk.c sleep.c
HFILES = device.h
SFILES = crtsleep.s
.c.b:
$(BIN)cc68 -I$(INCLUDE) -c $<
.c.s:
$(BIN)cc68 -I$(INCLUDE) -S $<
.s.b:
$(BIN)cc68 -c $<
.c.ln:
$(BIN)lint -I$(INCLUDE) -lmac $< > $*.ln
sleep: sleep.b crtsleep.b
$(BIN)ld68 -X -r -d -e drvr -T 0 crtsleep.b sleep.b -lmac -lc68 -x -o sleep
desk: desk.b
$(BIN)cc68 -m desk.b -o desk
desk.rsrc: sleep desk desk.rc
$(BIN)rmaker desk.rc
all: desk.rsrc
put: desk.rsrc
$(BIN)macput -r desk
lint: sleep.ln desk.ln
desk.shar: $(CFILES) $(SFILES) $(HFILES)
csh shar desk.shar $(CFILES) $(SFILES) $(HFILES) desk.rc Makefile
clean:
rm -f *.b *.rsrc sleep desk
!E!O!F!
#
# type sh /usrk0/wrs/mac/cone/sleep to unpack this archive.
#
echo extracting crtsleep.s...
cat >crtsleep.s <<'!E!O!F!'
|
| crtcal.s - self relocating C runtime startoff for Mac desk accessory
|
| Copyright (C) 1984, Stanford Univ. SUMEX project
| May be used but not sold without permission.
|
| history
| 07/20/84 Croft Created.
| 10/24/84 Smith Customize for test
|
.data
.text
.globl _savea5
.globl drvr
.globl drvrOpen,drvrPrime,drvrCtl,drvrStatus,drvrClose
| driver header
drvr:
.word 0x2400 | enable control, need time
.word 60 | every second
.word 0x0001 | mouseDown events only
.word 0 | no menu
doffset:
.word reloc-drvr | replaced by "dopen-drvr" after initialization
.word dprime-drvr
.word dctl-drvr
.word dstatus-drvr
.word dclose-drvr
.byte 6
.ascii "\0Sleep"
.blkb 25 | 32 bytes total for name
reloc: jra .L21
.long 0,0,0,0,0,0,0,0,0,0 | longruns from rmaker
_savea5:.long 0
|
| a1 = next longrun address
| a2 = current reloc address
| d1 = relocation factor
|
.L21:
moveml #0xffff,sp@-
lea pc@([drvr-.-2]),a1 | reloc factor
movl a1,d1
lea pc@([reloc+2-.-2]),a1
movl a1@+,a2 | pickup 1st relocation
addl d1,a2
.L16:
| for(;;) {
| i = *a2;
| *a2 = 0;
| *(u_long *)a2 += (u_long)d1;
| if (i == 0377)
| goto start;
| if (i == 0) {
| a2 = *a1++;
| a2 += d1;
| continue;
| }
| a2 += (i << 1);
| }
movb a2@,d7
andl #255,d7
clrb a2@
addl d1,a2@
cmpl #255,d7
beqs .L18
tstl d7
bnes .L19
movl a1@+,a2
addl d1,a2
bras .L16
.L19:
roll #1,d7
addl d7,a2
bras .L16
|
| if shift button is pressed on entry, beep and hang around for an NMI.
|
.L18:
btst #0,0x17b
beqs .L31 | if not pressed
movw #1,sp@- | sysbeep, duration 1
.word /A9C8
moveq #1,d0
.L22:
tstl d0
bnes .L22 | hang, waiting for NMI
.L31:
movl a5,_savea5
movw doff2,doffset | above code is once-only
moveml sp@+,#0xffff
|
| driver entry points
|
dopen:
movl #drvrOpen,d0
bras call
dclose:
movl #drvrClose,d0
bras call
dctl:
movl #drvrCtl,d0
bras call
dstatus:
movl #drvrStatus,d0
bras call
dprime:
movl #drvrPrime,d0
call:
moveml #0x3ffc,sp@-
movl a1,sp@-
movl a0,sp@-
movl d0,a0
jsr a0@
addql #8,sp
moveml sp@+,#0x3ffc
cmpl #0x40000000,d0
bnes done
clrl d0
rts
jiodone = 0x8fc
done:
movl jiodone,sp@-
rts
doff2: .word dopen-drvr
!E!O!F!
#
# type sh /usrk0/wrs/mac/cone/sleep to unpack this archive.
#
echo extracting desk.rc...
cat >desk.rc <<'!E!O!F!'
desk.rsrc
Type ALRT
,256(32)
60 81 180 431
256
5555
Type DITL
,256(32)
3
BtnItem Enabled
90 10 110 80
OK
BtnItem Enabled
90 270 110 340
Cancel
StatText Disabled
10 60 70 350
Replace system resource ^0 type=^1 id=^2?
Type DRVR
sleep|Sleep,24(48)
Type CODE
desk,0
!E!O!F!
#
# type sh /usrk0/wrs/mac/cone/sleep to unpack this archive.
#
echo extracting sleep.c...
cat >sleep.c <<'!E!O!F!'
/*
* Sleep desk accessory
*
* Copyright (c) 1984 Walter Smith
* All rights reserved
*
*/
#include "quickdraw.h"
#include "osintf.h"
#include "toolintf.h"
#include "packintf.h"
#include "device.h"
#define NIL 0
#define FALSE 0
#define TRUE 1
/* Globals */
WindowPtr window; /* our window */
Rect windowRect; /* its size */
GrafPort bigport;
char title[] = {"Cone Pig"}; /* Alto DMT message */
short pigvisible = 0; /* flag to avoid leaving apples around */
short bpexists = 0; /* bigport created flag */
int coneh, conev; /* position of last apple */
/* Driver routines */
drvrOpen(pb, dce)
ControlParam *pb;
struct dce *dce;
{
GrafPtr temp;
/* Open a GrafPort for the whole screen */
if (!bpexists) {
GetPort(&temp);
OpenPort(&bigport);
SetPort(temp);
bpexists = 1;
}
if (!dce->dCtlWindow) createWindow(dce);
return(IOrts);
}
/* Unfortunately, this routine never gets called... */
drvrClose(pb, dce)
ControlParam *pb;
struct dce *dce;
{
DisposeWindow(window);
dce->dCtlWindow = NIL;
pigvisible = 0;
DrawMenuBar();
return(IOrts);
}
drvrCtl(pb, dce)
ControlParam *pb;
struct dce *dce;
{
return(IOrts);
}
drvrStatus(pb, dce)
ControlParam *pb;
struct dce *dce;
{
return(IOrts);
}
drvrPrime(pb, dce)
ControlParam *pb;
struct dce *dce;
{
return(IOrts);
}
/* Real routines */
/* Create our window and wait for a click. */
createWindow(dce)
struct dce *dce;
{
int nextTick;
SetRect(&windowRect, -2, -2, 514, 385); /* a very large window */
window = NewWindow((WindowPeek) NIL, &windowRect, title, TRUE,
2, (WindowPtr) -1, TRUE, 0);
dce->dCtlWindow = window;
SetPort(window);
InvertRect(&windowRect); /* Black out all but the menu bar */
PenMode(patXor);
TextMode(patXor);
TextFont(0);
((WindowPeek) window)->windowKind = dce->dCtlRefNum;
SetPort(&bigport);
PaintRect(&windowRect); /* Kill off the menu bar, too */
HideCursor();
nextTick = TickCount();
/* Move the apple every second, waiting for a click */
for (;!Button();) {
if (TickCount() >= nextTick) {
doSomething();
nextTick = TickCount() + 60;
}
}
FlushEvents(mDownMask, 0); /* Kill the mouseDown event from the click */
ShowCursor();
pigvisible = 0;
DisposeWindow(window); /* Destroy the window */
dce->dCtlWindow = NIL;
DrawMenuBar(); /* and put the menu bar back */
}
/* Make random apples wander around the screen */
doSomething()
{
SetPort(window);
if (pigvisible) {
MoveTo(coneh, conev);
DrawChar('\024');
}
else pigvisible = 1;
coneh = (((unsigned) Random() & 0x7fff) % 450) + 20;
conev = (((unsigned) Random() & 0x7fff) % 320) + 40;
MoveTo(coneh, conev);
DrawChar('\024');
}
!E!O!F!
--------------------cut-here-------------------------info-mac@uw-beaver (12/22/84)
From: Walter.Smith@CMU-CS-K I have written a desk accessory reminiscent of the Xerox memory test programs; it clears the screen completely and bounces an apple character randomly about the screen. It doesn't actually test memory or anything, but it keeps your display from being burned in. It lasts until you click the mouse, then restores the screen. So far it works with everything except MacTerminal. I don't know why MacTerm doesnt like it. If anyone knows, please tell me. Included in this message are two files: a Desk Accessory Mover 1.4 file containing the accessory, and a shell archive containing the source (it requires the traditional desk and device.h). - Walter Smith (wrs@cmu-cs-k) [stored on <info-mac>sleep.shar and sleep.hcx]