dirkjan@zuring.UUCP (11/26/85)
Hi Folks,
What about a little man pushing your screen away? How impertinent of him!!
This is, for now, the last DA in my little series (Crabs, Flow and Push)
of screen molesting DA's. Hope you enjoy them.
(Source included, so you can happily hack the DA the way you want)
Fons Rademakers
Nikhef-H (Nat. Inst. for High Energy Physics)
Amsterdam
the Netherlands
(Come on folks, post also sources to n.SOURCES.m)
*************** mailed by Dirk Jan for Fons Rademakers *************
Please mail any reactions or questions on this posting to:
{ ...|decvax|seismo|philabs}mcvax!dirkjan
# This is a shell archive. Remove anything before this line, then
# unpack it by saving it in a file and typing "sh file". (Files
# unpacked will be owned by you and have default permissions.)
#
# This archive contains:
# push.hqx mkpush push.c
echo x - push.hqx
cat > "push.hqx" << '//E*O*F push.hqx//'
(This file must be converted with BinHex 4.0)
:"("eFfJ!4%C*6%406eB!N!J5+Kl`!*!%!3#3!a(b!!!3mJ#3!cJ!N2)3lQ3!N!3
"!*!$,!l`$[S1m!l#"&"eFfJ!5IS3e#P)rrBT5Irk6R8JE2rf6R919[rq51F-%'(
L+#crqL4%5US!(QB!"F!N4#m+,c`!!!5i6VS3F&K2*&mP3!!8,`"1ZK"%@%mNE2r
k)QS!&#S4*%3[#N+R3UG)E2rZ5(VrQ%*R2c`!!Lmmrj!%3QG#TkN6)"mQ3#4I*8!
!(L4%0fS!'!"X*%8Q"GDm!*!$0L5$*%8[%UK[3QlrrJaZ!!2rrQaq0LlrrXIm!!i
N3pA&3QS!#MBZrrl(r!!1*%29a8*U!!`f,[rqar`!$L4$eF8eI!!k!!if,[rqar`
!$L4$eF8eI!!`!"!f,[rqar`!$L4$eF8eI!!'!!Jf,[rqar`!$L4$eF8f,[rqar`
"A0D&eV`!N!1L*8-!"&*ZrrjJ!2pm*%8[+J!%5(S%c+KQ*%8LDJ!%dr`!N!-5,`P
)HJ6HU'BN45*U!!66r!#3!b3[#8Kk"2#SCL4&)QS!"02m!*!$0Lm*5(S&!UKQ*%8
LDJ!%dr`!N!0),`P)HJ88U'BN45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!"`!%cI#""1ANje)'m!"+!T6[S
!+L"[!!5J+Nlk!#!JE`!%S#01qJ!@)#m!"+%L6[S!!N2YrribJ#!)6R9$lIrq-S"
1G3#3+a`!-J!!4&*@8J#3!`S!(`!!)!#3"`8!8(9cD#!A!:
//E*O*F push.hqx//
echo x - mkpush
cat > "mkpush" << '//E*O*F mkpush//'
set -x
cp -f $1.c ram:$1.c
cc -bu -z2250 ram:$1.c
ln -an $2 ram:$1.o -lc
cprsrc DRVR 31 ram:$1 2:flow/term
//E*O*F mkpush//
echo x - push.c
cat > "push.c" << '//E*O*F push.c//'
/* ----------------- push -----------------
*
* A little guy will push away your screen.
* What a brutality!!
* Written in Aztec C.
*
* Author: Fons Rademakers
* Nikhef-h (Nat. Inst. for High Energy Physics)
* the Netherlands
* Version: 21-nov-1985
* Revision:
*
*/
#asm
main
dc.w $6400 ;ctl-enable, need time and locked in mem.
dc.w 0 ;update as often as possible
dc.w $0001 ;don't react on any specific event
dc.w 0 ;no menu
dc.w open_-main ;open routine
dc.w nop_-main ;prime routine
dc.w control_-main ;control routine
dc.w nop_-main ;status routine
dc.w close_-main ;close routine
title_
dc.b 4
dc.b "Push"
ds 0 ;for alignment
public _Uend_,_Dorg_,_Cend_
save_
lea main+(_Uend_-_Dorg_)+(_Cend_-main),a4 ;set up globals
move.l a0,Pbp_ ;save pb pointer
move.l a1,Dp_ ;save DCE pointer
rts
restore_
move.l Pbp_,a0
rts
#endasm
#define _DRIVER
#define SMALL_MEM
#include <quickdraw.h>
#include <memory.h>
#undef SMALL_MEM
#include <event.h>
#include <pb.h>
#include <desk.h>
#define notSrcCopy 4 /* Not in QD with SMALL_MEM flag set */
#define NULL (0L)
#define BASE1 512 /* Mac screen size in x direction */
#define BASE2 342 /* Mac screen size in y direction */
#define SP (*(struct storage **)Dp->dCtlStorage)
DCEPtr Dp;
ParmBlkPtr Pbp;
Rect wind_rect = {0, 0, 0, 0};
struct storage {
GrafPtr pushport; /* the push grafport */
BitMap manmap[3]; /* the 3 amn bitmaps */
Pattern black;
short portspace[54]; /* space for the flowport */
char manspace[3][348]; /* space for the 3 man bitmaps */
short x;
};
open()
{
register WindowPtr wp;
register struct DCE *dp;
register struct storage *sp;
extern char title[];
struct windowpeek {
GrafPort port;
int windowKind;
};
short i;
save();
dp = Dp;
if (dp->dCtlWindow == NULL) {
HLock(dp->dCtlStorage = NewHandle((long) sizeof(struct storage)));
sp = SP;
/* create an invisible window */
dp->dCtlWindow =
wp = NewWindow(NULL, &wind_rect, title, FALSE, plainDBox, -1L, FALSE,
NULL);
((struct windowpeek *)wp)->windowKind = dp->dCtlRefNum;
/* allocate space for new pushport */
&sp->pushport->device = sp->portspace;
OpenPort(sp->pushport);
/* set the 3 man bitmaps */
for (i = 0; i < 3 ; i++) {
sp->manmap[i].bounds.top = 0;
sp->manmap[i].bounds.left = 0;
sp->manmap[i].bounds.bottom = 58;
sp->manmap[i].bounds.right = 48;
sp->manmap[i].rowBytes = 6;
sp->manmap[i].baseAddr = &sp->manspace[i][0];
}
/* first man map */
StuffHex(sp->manmap[0].baseAddr, "\P00000000001000000000001800000000001C");
StuffHex(sp->manmap[0].baseAddr+18, "\P000000000020000000000040000000000080");
StuffHex(sp->manmap[0].baseAddr+36, "\P000000000100000000000200000000000400");
StuffHex(sp->manmap[0].baseAddr+54, "\P000000000800000000001000000000002000");
StuffHex(sp->manmap[0].baseAddr+72, "\P003F00004000007F80008000007C80010000");
StuffHex(sp->manmap[0].baseAddr+90, "\P007900220000007080740000002100E80000");
StuffHex(sp->manmap[0].baseAddr+108,"\P001083240000001F0CDE0000002173240000");
StuffHex(sp->manmap[0].baseAddr+126,"\P004784C800000041CB10000000403C200000");
StuffHex(sp->manmap[0].baseAddr+144,"\P004000C0000000438300000000407C000000");
StuffHex(sp->manmap[0].baseAddr+162,"\P004080000000004080000000004080000000");
StuffHex(sp->manmap[0].baseAddr+180,"\P004080000000002080000000003F80000000");
StuffHex(sp->manmap[0].baseAddr+198,"\P002080000000002080000000001080000000");
StuffHex(sp->manmap[0].baseAddr+216,"\P001100000000001100000000001100000000");
StuffHex(sp->manmap[0].baseAddr+234,"\P001100000000001100000000001100000000");
StuffHex(sp->manmap[0].baseAddr+252,"\P001100000000001200000000001200000000");
StuffHex(sp->manmap[0].baseAddr+270,"\P001200000000001200000000001200000000");
StuffHex(sp->manmap[0].baseAddr+288,"\P001200000000003F00000000003F00000000");
StuffHex(sp->manmap[0].baseAddr+306,"\P003F00000000001200000000001200000000");
StuffHex(sp->manmap[0].baseAddr+324,"\P0012000000000013C0000000001420000000");
StuffHex(sp->manmap[0].baseAddr+342,"\P001BE0000000");
/* second man map */
StuffHex(sp->manmap[1].baseAddr, "\P00000000001000000000001800000000001C");
StuffHex(sp->manmap[1].baseAddr+18, "\P000000000020000000000040000000000080");
StuffHex(sp->manmap[1].baseAddr+36, "\P000000000100000000000200000000000400");
StuffHex(sp->manmap[1].baseAddr+54, "\P000000000800000000001000000000002000");
StuffHex(sp->manmap[1].baseAddr+72, "\P003F00004000007F80008000007C80010000");
StuffHex(sp->manmap[1].baseAddr+90, "\P007900220000007080740000002100E80000");
StuffHex(sp->manmap[1].baseAddr+108,"\P001083240000001F0CDE0000002173240000");
StuffHex(sp->manmap[1].baseAddr+126,"\P004784C800000041CB10000000403C200000");
StuffHex(sp->manmap[1].baseAddr+144,"\P004000C0000000438300000000407C000000");
StuffHex(sp->manmap[1].baseAddr+162,"\P004080000000004080000000004080000000");
StuffHex(sp->manmap[1].baseAddr+180,"\P004080000000002080000000003F80000000");
StuffHex(sp->manmap[1].baseAddr+198,"\P002080000000002080000000001080000000");
StuffHex(sp->manmap[1].baseAddr+216,"\P001080000000001080000000001240000000");
StuffHex(sp->manmap[1].baseAddr+234,"\P001240000000001220000000001320000000");
StuffHex(sp->manmap[1].baseAddr+252,"\P002310000000002690000000004488000000");
StuffHex(sp->manmap[1].baseAddr+270,"\P00484800000000884C000000009024000000");
StuffHex(sp->manmap[1].baseAddr+288,"\P01102400000003F07E00000003F07E000000");
StuffHex(sp->manmap[1].baseAddr+306,"\P03F07E000000012024000000012024000000");
StuffHex(sp->manmap[1].baseAddr+324,"\P012024000000013C27800000014228400000");
StuffHex(sp->manmap[1].baseAddr+342,"\P01BE37C00000");
/* third man map */
StuffHex(sp->manmap[2].baseAddr, "\P00000000001000000000001800000000001C");
StuffHex(sp->manmap[2].baseAddr+18, "\P000000000020000000000040000000000080");
StuffHex(sp->manmap[2].baseAddr+36, "\P000000000100000000000200000000000400");
StuffHex(sp->manmap[2].baseAddr+54, "\P000000000800000000001000000000002000");
StuffHex(sp->manmap[2].baseAddr+72, "\P003F00004000007F80008000007C80010000");
StuffHex(sp->manmap[2].baseAddr+90, "\P007900220000007080740000002100E80000");
StuffHex(sp->manmap[2].baseAddr+108,"\P001083240000001F0CDE0000002173240000");
StuffHex(sp->manmap[2].baseAddr+126,"\P004784C800000041CB10000000403C200000");
StuffHex(sp->manmap[2].baseAddr+144,"\P004000C0000000438300000000407C000000");
StuffHex(sp->manmap[2].baseAddr+162,"\P004080000000004080000000004080000000");
StuffHex(sp->manmap[2].baseAddr+180,"\P004080000000002080000000003F80000000");
StuffHex(sp->manmap[2].baseAddr+198,"\P002080000000002080000000001080000000");
StuffHex(sp->manmap[2].baseAddr+216,"\P001080000000001080000000001240000000");
StuffHex(sp->manmap[2].baseAddr+234,"\P001240000000001220000000001320000000");
StuffHex(sp->manmap[2].baseAddr+252,"\P002310000000004490000000008888000000");
StuffHex(sp->manmap[2].baseAddr+270,"\P01104800000006204C0000000F4024000000");
StuffHex(sp->manmap[2].baseAddr+288,"\P0F802400000017807E00000023007E000000");
StuffHex(sp->manmap[2].baseAddr+306,"\P44007E000000880024000000D00024000000");
StuffHex(sp->manmap[2].baseAddr+324,"\P480024000000240027800000120028400000");
StuffHex(sp->manmap[2].baseAddr+342,"\P0E0037C00000");
/* set start x value */
sp->x = 0;
/* black pattern */
StuffHex(sp->black, "\PFFFFFFFFFFFFFFFF");
/* set the background pattern to black */
BackPat(sp->black);
HUnlock(dp->dCtlStorage);
}
restore();
return(0);
}
close()
{
register struct DCE *dp;
save();
dp = Dp;
/* get rid of the allocated space for the window */
DisposeWindow(dp->dCtlWindow);
dp->dCtlWindow = NULL;
DisposHandle(dp->dCtlStorage);
restore();
return(0);
}
nop()
{
return(0);
}
control()
{
register struct DCE *dp;
register struct storage *sp;
short i, j;
short xdest, ydest;
short xvel, slowdown;
Rect destrect;
RgnHandle dummyrgn;
save();
dp = Dp;
HLock(dp->dCtlStorage);
sp = SP;
switch (Pbp->u.cp.csCode) {
case accRun: /* time to push the screen */
SetPort(sp->pushport);
xvel = 2; /* speed with which the screen is being pushed by the man
*/
/* to prevent man from walking too fast at end of screen, slow him down
*/
if (sp->x < 128) /* 1/4*BASE1 */
slowdown = 0;
else if (sp->x < 256) /* 1/2*BASE1 */
slowdown = 1000;
else if (sp->x < 384) /* 3/4*BASE1 */
slowdown = 5000;
else
slowdown = 10000;
for (i = 0; i < 3; i++) {
for (j = 0; j <= slowdown; j++)
;
if (sp->x <= BASE1 + 48) {
dummyrgn = NewRgn();
SetRect(&destrect, sp->x, 0, BASE1, BASE2);
xdest = xvel;
ydest = 0;
ScrollRect(&destrect, xdest, ydest, dummyrgn);
sp->x += xvel;
/* kind of dirty fix: erase heel of third man map.
* I should have defined the man maps 1 word bigger on the left side
* to prevent this EraseRect call */
if (!i) {
SetRect(&destrect, sp->x - 56, BASE2 - 13, sp->x - 48, BASE2);
EraseRect(&destrect);
}
SetRect(&destrect, sp->x - 48, BASE2 - 58, sp->x, BASE2);
CopyBits(&sp->manmap[i], &sp->pushport->portBits,
&sp->manmap[i].bounds, &destrect,
notSrcCopy, NULL);
DisposeRgn(dummyrgn);
} else
sp->x = 0;
}
break; /* end case */
}
HUnlock(dp->dCtlStorage);
restore();
return(0);
}
//E*O*F push.c//
exit 0