(FILECREATED "23-Jul-85 00:04:28" {ERIS}<LISPCORE>SOURCES>DOVEDISPLAYHACK.;3 5483   

      changes to:  (FNS \STARTDISPLAY \CreateScreenBitMap \FixupDisplayForDove)

      previous date: "20-Jul-85 15:36:11" {ERIS}<LICHTENBERG>LISP>DOVEDISPLAYHACK.;9)


(* Copyright (c) 1985 by XEROX. All rights reserved.)

(PRETTYCOMPRINT DOVEDISPLAYHACKCOMS)

(RPAQQ DOVEDISPLAYHACKCOMS ((FNS \OPENW1 \STARTDISPLAY \CreateScreenBitMap)
			    (DECLARE: DONTEVAL@LOAD DOCOPY (P (\LOCKFN (FUNCTION 
								   \DoveDisplay.SetCursorPosition)))))
)
(DEFINEQ

(\OPENW1
  [LAMBDA (WINDOW)                                           (* mpl "19-Jul-85 13:10")
    (DECLARE (GLOBALVARS SCREENWIDTH))
    (UNINTERRUPTABLY
        (replace (WINDOW NEXTW) of WINDOW with TOPW)
	(SETQ TOPW WINDOW)
	(SETQ \TOPWDS (fetch (WINDOW DSP) of TOPW))
	(replace (PILOTBBT PBTDESTBPL) of (fetch (\DISPLAYDATA DDPILOTBBT) of (\GETDISPLAYDATA WINDOW)
						 )
	   with SCREENWIDTH)                                 (* changed from (SCREENBITMAP) to destination in 
							     preparation for multiple screens.)
                                                             (* Assume that the DSP of a window is guaranteed to be 
							     a display-stream)
	(\SW2BM (fetch DDDestination of (fetch IMAGEDATA of \TOPWDS))
		(fetch (WINDOW REG) of WINDOW)
		(fetch (WINDOW SAVE) of WINDOW)
		NIL))])

(\STARTDISPLAY
  (LAMBDA NIL                                                (* jwo: "23-Jul-85 00:04")
    (DECLARE (GLOBALVARS SCREENWIDTH SCREENHEIGHT))
    (COND
      ((NEQ \MACHINETYPE \DAYBREAK)
	(SETQ ScreenBitMap (\CreateScreenBitMap SCREENWIDTH SCREENHEIGHT))))
    (UNINTERRUPTABLY
        (SHOWDISPLAY (fetch BITMAPBASE of ScreenBitMap)
		     (fetch BITMAPRASTERWIDTH of ScreenBitMap))
	(CHANGETTYDEVICE (QUOTE LISPDISPLAY))
	(SETQ \DisplayStarted T))
    (COND
      ((AND (NEQ \KEYBOARD.BEFORETYPE \DAYBREAK)
	    (EQ \MACHINETYPE \DAYBREAK))
	(PROG (OLDWINDOWS)
	      (SETQ OLDWINDOWS (COPY (OPENWINDOWS)))
	      (for W in OLDWINDOWS do (PROG ((WREG (fetch (WINDOW REG) of W)))

          (* * This gook is designed to move open windows into reasonable positions on the Daybreak screen, from wherever they
	  were on the LOADUP machine. The LOADUP process needs to be fixed to just leave around functions that initialize the 
	  screen and related things in a machine dependent (intelligent) way.)


					    (MOVEW W (IQUOTIENT (ITIMES 4 (fetch (REGION LEFT)
									     of WREG))
								5)
						   (IQUOTIENT (ITIMES (fetch (REGION BOTTOM)
									 of WREG)
								      3)
							      4))
					    (\CLOSEW1 W)))
	      (SETQ ScreenBitMap (\CreateScreenBitMap (SETQ SCREENWIDTH (\DoveDisplay.ScreenWidth))
						      (SETQ SCREENHEIGHT (\DoveDisplay.ScreenHeight)))
		)
	      (CHANGEBACKGROUND)
	      (for I in OLDWINDOWS do (\OPENW1 I)))))
    (SETQ WHOLESCREEN (SETQ WHOLEDISPLAY
	(create REGION
		LEFT ← 0
		BOTTOM ← 0
		WIDTH ← SCREENWIDTH
		HEIGHT ← SCREENHEIGHT)))))

(\CreateScreenBitMap
  (LAMBDA (WIDTH HEIGHT)                                     (* jwo: "22-Jul-85 23:51")
    (DECLARE (GLOBALVARS \MaxScreenPage))

          (* creates and locks the pages for the display bit map. Returns a BITMAP descriptor for it. Uses the first words of 
	  the segment \DISPLAYREGION.)



          (* * ??? (COND ((OR (NEQ \MACHINETYPE \DAYBREAK) FLG) (FOLDHI (CEIL WIDTH (UNFOLD \DisplayWordAlign BITSPERWORD)) 
	  BITSPERWORD)) (T 52)))


    (PROG ((RASTERWIDTH (IQUOTIENT WIDTH BITSPERWORD))
	   MAXPAGE#)                                         (* the display microcode needs to have the display fall
							     on \DisplayWordAlign word boundaries.)
          (COND
	    ((IGREATERP (SETQ MAXPAGE# (SUB1 (FOLDHI (ITIMES RASTERWIDTH HEIGHT)
						     WORDSPERPAGE)))
			\MaxScreenPage)

          (* new screen size is larger, allocate more pages. All pages are locked. NOERROR is true in \NEWPAGE call in case 
	  pages are already there, e.g. DLBOOT allocated them.)


	      (for I from (ADD1 \MaxScreenPage) to MAXPAGE# do (\NEWPAGE (\ADDBASE \DISPLAYREGION
										   (UNFOLD I 
										     WORDSPERPAGE))
									 T T))
	      (SETQ \MaxScreenPage MAXPAGE#)))
          (RETURN (COND
		    ((BITMAPP ScreenBitMap)                  (* reuse the same BITMAP ptr so that it will stay EQ to
							     the one in user datastructures.)
		      (replace BITMAPBASE of ScreenBitMap with \DISPLAYREGION)
		      (replace BITMAPWIDTH of ScreenBitMap with WIDTH)
		      (replace BITMAPRASTERWIDTH of ScreenBitMap with RASTERWIDTH)
		      (replace BITMAPHEIGHT of ScreenBitMap with HEIGHT)
		      ScreenBitMap)
		    (T (create BITMAP
			       BITMAPBASE ← \DISPLAYREGION
			       BITMAPRASTERWIDTH ← RASTERWIDTH
			       BITMAPWIDTH ← WIDTH
			       BITMAPHEIGHT ← HEIGHT)))))))
)
(DECLARE: DONTEVAL@LOAD DOCOPY 
(\LOCKFN (FUNCTION \DoveDisplay.SetCursorPosition))
)
(PUTPROPS DOVEDISPLAYHACK COPYRIGHT ("XEROX" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (544 5323 (\OPENW1 554 . 1486) (\STARTDISPLAY 1488 . 3318) (\CreateScreenBitMap 3320 . 
5321)))))
STOP