(FILECREATED "13-Dec-84 13:22:51" {ROSEBOWL}<BIRD>NEW>TMP>BACKGROUNDDEMO.;4 10068  

      changes to:  (FNS BACKGROUNDDEMOCLICK BACKGROUNDDEMO BACKGROUNDDEMODRAW BACKGROUNDDEMOPROCESS 
			BACKGROUNDDEMOERASE)
		   (VARS PONGCOMS BACKGROUNDDEMOCLICK BACKGROUNDDEMOCOMS)
		   (RECORDS BACKGROUNDDEMOOBJECT)

      previous date: "29-Oct-84 18:33:59" {ROSEBOWL}<BIRD>NEW>TMP>PONG.;3)


(* Copyright (c) 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT BACKGROUNDDEMOCOMS)

(RPAQQ BACKGROUNDDEMOCOMS ((RECORDS BACKGROUNDDEMOOBJECT)
			   (FNS BACKGROUNDDEMO BACKGROUNDDEMODRAW BACKGROUNDDEMOPROCESS 
				BACKGROUNDDEMOERASE BACKGROUNDDEMOCLICK)
			   (FILES BACKGROUND)
			   (VARS BACKGROUNDDEMOCLICK)))
[DECLARE: EVAL@COMPILE 

(DATATYPE BACKGROUNDDEMOOBJECT (X Y U V M R MASK TXTR))
]
(/DECLAREDATATYPE (QUOTE BACKGROUNDDEMOOBJECT)
		  (QUOTE (POINTER POINTER POINTER POINTER POINTER POINTER POINTER POINTER)))
(DEFINEQ

(BACKGROUNDDEMO
  [LAMBDA (N PONGWINDOW)                                     (* edited: "12-Dec-84 16:23")
    (DECLARE (LOCALVARS . T))
    (ADD.PROCESS (LIST (QUOTE BACKGROUNDDEMOPROCESS)
		       (KWOTE (for I from 1 to N bind SIZE MASS TEXTURE FILLING DIMENSION MASK
				 eachtime (SETQ SIZE (RAND 8 24))
					  (SETQ MASS (ITIMES SIZE SIZE))
					  (SETQ TEXTURE (COND
					      ((ZEROP (LOGAND I 1))
						30685)
					      (T 34850)))
					  (SETQ FILLING (COND
					      ((ZEROP (LOGAND I 2))
						42405)
					      (T 65535)))
					  (SETQ DIMENSION (IPLUS SIZE SIZE -1))
					  (SETQ MASK (BITMAPCREATE DIMENSION DIMENSION))
					  (for X from 0 to (SUB1 DIMENSION) bind XX Z
					     eachtime (SETQ XX (IDIFFERENCE X SIZE))
						      [SETQ Z (SQRT (IDIFFERENCE MASS
										 (ITIMES XX XX]
					     do (BITBLT NIL NIL NIL MASK X (IDIFFERENCE SIZE Z)
							1
							(ITIMES Z 2)
							(QUOTE TEXTURE)
							(QUOTE REPLACE)
							FILLING))
				 collect (create BACKGROUNDDEMOOBJECT
						 X ←(RAND 0 (IPLUS [COND
								     (PONGWINDOW (WINDOWPROP
										   PONGWINDOW
										   (QUOTE WIDTH)))
								     (T (fetch BITMAPWIDTH
									   of (SCREENBITMAP]
								   -1))
						 Y ←(RAND 0 (IPLUS [COND
								     (PONGWINDOW (WINDOWPROP
										   PONGWINDOW
										   (QUOTE HEIGHT)))
								     (T (fetch BITMAPHEIGHT
									   of (SCREENBITMAP]
								   -1))
						 U ←(ITIMES (SUB1 (ITIMES (RAND 0 1)
									  2))
							    (RAND 5 10))
						 V ←(ITIMES (SUB1 (ITIMES (RAND 0 1)
									  2))
							    (RAND 5 10))
						 M ←(ADD1 (IQUOTIENT MASS 100))
						 R ← SIZE
						 MASK ← MASK
						 TXTR ← TEXTURE)))
		       PONGWINDOW])

(BACKGROUNDDEMODRAW
  [LAMBDA (OB MAP)                                           (* edited: "12-Dec-84 16:19")
    (DECLARE (LOCALVARS . T))
    (PROG ((SOURCE (fetch (BACKGROUNDDEMOOBJECT MASK) of OB))
	   (LEFT (IDIFFERENCE (fetch (BACKGROUNDDEMOOBJECT X) of OB)
			      (fetch (BACKGROUNDDEMOOBJECT R) of OB)))
	   (BOTTOM (IDIFFERENCE (fetch (BACKGROUNDDEMOOBJECT Y) of OB)
				(fetch (BACKGROUNDDEMOOBJECT R) of OB)))
	   RIGHT TOP)
          (BITBLT SOURCE NIL NIL MAP LEFT BOTTOM NIL NIL (QUOTE MERGE)
		  (QUOTE INVERT)
		  (fetch (BACKGROUNDDEMOOBJECT TXTR) of OB))
          (SETQ RIGHT (IPLUS LEFT (fetch BITMAPWIDTH of SOURCE)))
          (SETQ TOP (IPLUS BOTTOM (fetch BITMAPHEIGHT of SOURCE)))
          (COND
	    ((ILESSP LEFT PONGLEFT)
	      (SETQ PONGLEFT LEFT)))
          (COND
	    ((ILESSP BOTTOM PONGBOTTOM)
	      (SETQ PONGBOTTOM BOTTOM)))
          (COND
	    ((IGREATERP RIGHT PONGRIGHT)
	      (SETQ PONGRIGHT RIGHT)))
          (COND
	    ((IGREATERP TOP PONGTOP)
	      (SETQ PONGTOP TOP])

(BACKGROUNDDEMOPROCESS
  [LAMBDA (PONGOBJECTS PONGWINDOW)                           (* edited: "12-Dec-84 16:21")
    (DECLARE (LOCALVARS . T)
	     (SPECVARS PONGLEFT PONGBOTTOM PONGRIGHT PONGTOP))
    (COND
      ((NLISTP PONGOBJECTS)
	(\ILLEGAL.ARG PONGOBJECTS))
      (T (bind [WIDTH ←(COND
			(PONGWINDOW (WINDOWPROP PONGWINDOW (QUOTE WIDTH)))
			(T (fetch BITMAPWIDTH of (SCREENBITMAP]
	       [HEIGHT ←(COND
			 (PONGWINDOW (WINDOWPROP PONGWINDOW (QUOTE HEIGHT)))
			 (T (fetch BITMAPHEIGHT of (SCREENBITMAP]
	       (PONGLEFT ← 0)
	       (PONGBOTTOM ← 0)
	       (PONGRIGHT ← 0)
	       (PONGTOP ← 0)
	       PONGMAP
	    first (SETQ PONGMAP (BITMAPCREATE WIDTH HEIGHT))
		  (BITBLT NIL NIL NIL PONGMAP NIL NIL NIL NIL (QUOTE TEXTURE)
			  (QUOTE REPLACE)
			  WINDOWBACKGROUNDSHADE)
		  (for OB in PONGOBJECTS
		     do (BACKGROUNDDEMODRAW OB PONGMAP)
			(replace (BACKGROUNDDEMOOBJECT V) of OB with 0))
		  (BITBLTTOBACKGROUND PONGMAP NIL NIL PONGWINDOW NIL NIL NIL NIL (QUOTE INPUT)
				      (QUOTE REPLACE))
	    do (BLOCK)
	       (for OB in PONGOBJECTS
		  bind PONGDEST U V X Y R BO XX YY RR MR UU VV F G first (SETQ PONGDEST (
									    BACKGROUNDDESTINATION
									     PONGWINDOW))
		  do (SETQ PONGLEFT WIDTH)
		     (SETQ PONGBOTTOM HEIGHT)
		     (SETQ PONGRIGHT 0)
		     (SETQ PONGTOP 0)
		     (BACKGROUNDDEMOERASE OB PONGMAP)
		     [replace (BACKGROUNDDEMOOBJECT X) of OB with (SETQ X
								    (IPLUS (fetch (
BACKGROUNDDEMOOBJECT X) of OB)
									   (SETQ U
									     (fetch (
BACKGROUNDDEMOOBJECT U) of OB]
		     [replace (BACKGROUNDDEMOOBJECT Y) of OB with (SETQ Y
								    (IPLUS (fetch (
BACKGROUNDDEMOOBJECT Y) of OB)
									   (SETQ V
									     (fetch (
BACKGROUNDDEMOOBJECT V) of OB]
		     (BACKGROUNDDEMODRAW OB PONGMAP)
		     (BITBLTTODESTINATION PONGMAP PONGLEFT PONGBOTTOM PONGDEST PONGLEFT PONGBOTTOM
					  (IDIFFERENCE PONGRIGHT PONGLEFT)
					  (IDIFFERENCE PONGTOP PONGBOTTOM)
					  (QUOTE INPUT)
					  (QUOTE REPLACE))
		     (SETQ R (fetch (BACKGROUNDDEMOOBJECT R) of OB))
		     [COND
		       ([OR (AND (MINUSP U)
				 (ILESSP X R))
			    (AND (NOT (MINUSP U))
				 (IGEQ X (IDIFFERENCE WIDTH R]
			 (BACKGROUNDDEMOCLICK)
			 (replace (BACKGROUNDDEMOOBJECT U) of OB with (SETQ U (IMINUS U]
		     [replace (BACKGROUNDDEMOOBJECT V) of OB
			with (SETQ V (COND
				 ([OR (AND (MINUSP V)
					   (ILESSP Y R))
				      (AND (NOT (MINUSP V))
					   (IGEQ Y (IDIFFERENCE HEIGHT R]
				   (BACKGROUNDDEMOCLICK)
				   (IMINUS V))
				 (T (SUB1 V]
		     [SETQ BO (for BO in PONGOBJECTS
				 thereis (AND (NEQ BO OB)
					      (ILEQ (SETQ XX (IDIFFERENCE X (fetch (
BACKGROUNDDEMOOBJECT X) of BO)))
						    48)
					      (IGEQ XX -48)
					      (ILEQ (SETQ YY (IDIFFERENCE Y (fetch (
BACKGROUNDDEMOOBJECT Y) of BO)))
						    48)
					      (IGEQ YY -48)
					      (PROGN (SETQ RR (IPLUS R (fetch (BACKGROUNDDEMOOBJECT
										R)
									  of BO)))
						     (AND (ILEQ XX RR)
							  (ILEQ YY RR)
							  (IGEQ XX (SETQ MR (IMINUS RR)))
							  (IGEQ YY MR)))
					      (PROGN (SETQ UU (IDIFFERENCE (fetch (
BACKGROUNDDEMOOBJECT U) of BO)
									   U))
						     (SETQ VV (IDIFFERENCE (fetch (
BACKGROUNDDEMOOBJECT V) of BO)
									   V))
						     (IGREATERP (SETQ F (IPLUS (ITIMES XX UU)
									       (ITIMES YY VV)))
								0))
					      (ILEQ (SETQ G (IPLUS (ITIMES XX XX)
								   (ITIMES YY YY)))
						    (ITIMES RR RR]
		     [COND
		       (BO (BLOCK)
			   (PROG ((AM (fetch (BACKGROUNDDEMOOBJECT M) of OB))
				  (BM (fetch (BACKGROUNDDEMOOBJECT M) of BO))
				  H HX HY)
			         (SETQ F (ITIMES F 2))
			         (SETQ G (ITIMES G (IPLUS AM BM)))
			         (SETQ H (IQUOTIENT G 2))
			         [SETQ HX (COND
				     ((IGEQ XX 0)
				       H)
				     (T (IMINUS H]
			         [SETQ HY (COND
				     ((IGEQ YY 0)
				       H)
				     (T (IMINUS H]
			         (add (fetch (BACKGROUNDDEMOOBJECT U) of OB)
				      (IQUOTIENT (IPLUS (ITIMES BM F XX)
							HX)
						 G))
			         (add (fetch (BACKGROUNDDEMOOBJECT V) of OB)
				      (IQUOTIENT (IPLUS (ITIMES BM F YY)
							HY)
						 G))
			         (add (fetch (BACKGROUNDDEMOOBJECT U) of BO)
				      (IMINUS (IQUOTIENT (IPLUS (ITIMES AM F XX)
								HX)
							 G)))
			         (add (fetch (BACKGROUNDDEMOOBJECT V) of BO)
				      (IMINUS (IQUOTIENT (IPLUS (ITIMES AM F YY)
								HY)
							 G)))
			         (BACKGROUNDDEMOCLICK]
		  finally (DESTINATION.RELEASE PONGDEST])

(BACKGROUNDDEMOERASE
  [LAMBDA (OB DST)                                           (* edited: "12-Dec-84 16:09")
    (DECLARE (LOCALVARS . T))
    (BACKGROUNDDEMODRAW OB DST])

(BACKGROUNDDEMOCLICK
  [LAMBDA NIL                                                (* mgb: "13-Dec-84 12:24")
    (AND BACKGROUNDDEMOCLICK (EQ (MACHINETYPE)
				 (QUOTE DANDELION))
	 (PLAYTUNE BACKGROUNDDEMOCLICK])
)
(FILESLOAD BACKGROUND)

(RPAQQ BACKGROUNDDEMOCLICK ((250 . 250)))
(PUTPROPS BACKGROUNDDEMO COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (942 9913 (BACKGROUNDDEMO 952 . 2953) (BACKGROUNDDEMODRAW 2955 . 4144) (
BACKGROUNDDEMOPROCESS 4146 . 9472) (BACKGROUNDDEMOERASE 9474 . 9668) (BACKGROUNDDEMOCLICK 9670 . 9911)
))))
STOP