(FILECREATED " 5-Sep-84 15:20:18" {ERIS}<LISPCORE>SOURCES>PCBUS.;26 45976  

      changes to:  (FNS PCCOLORINIT PCCOLORSCROLL PCCOLORSCROLLH PCROTATELUT PCWRITE PCWRITECOLOR 
			PCWRITELUT PCWRITEPIXEL)

      previous date: " 2-Aug-84 00:24:07" {ERIS}<SPEECH>WORK>PCBUS.;1)


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

(PRETTYCOMPRINT PCBUSCOMS)

(RPAQQ PCBUSCOMS ((FNS BR INTEST NEWREADCOLOR OLDPCWRITE OUTTEST PCBLINK PCBUS PCCOLORINIT 
		       PCCOLORSCROLL PCCOLORSCROLLH PCDACCLEAR PCDACCMD PCDACINPUT PCDACOUTPUT 
		       PCDACOUTPUT2 PCDACSTATUS PCDACSTOP PCDACVOUT PCDACWAIT PCDMAINIT PCDMASTOP 
		       PCDMATEST PCINITCOLORMAP PCINPUT PCLUTALL PCMEMTEST PCOUTPUT PCPEEK PCPOKE 
		       PCRAMPRINT PCRAMWRITE PCREAD PCREADTEST PCROTATELUT PCT PCTESTCOMMAND 
		       PCTESTLOOP PCTESTTIMER PCTESTTIMER2 PCWRITE PCWRITECOLOR PCWRITELUT 
		       PCWRITEPIXEL PCWRITETEST PCWRITEVIDEO PT RT TT)
	(CONSTANTS PCDMA PCTIMER)
	(VARS COLORMAPARRAY PCFNS)
	(RECORDS FOURPIX)
	(MACROS PCWRITE)
	(FNS PCDACBUFINIT PCDACCMD PCDACDMAINIT PCDACDMAOUT PCDACDMASETUP PCDACERROR PCDACFLAP 
	     PCDACINPUT PCDACINPUT2 PCDACOUTPUT2 PCDACSETCLOCK PCDACSETUP PCDACSTATUS PCDACSTOP 
	     PCDACVIN PCDACVOUT PCDACWAIT PCOUTPUT2 PCOUTPUTTEST PCRAMPRINT PCRAMPRINT2 PCREAD2 
	     PCWRITE2 PCWRITELOOP TEST TEST1 TEST1A-D TEST1D-A)
	(* PC bus interface functions used by speech demo)
	(FNS PCBUS PCINPUT PCOUTPUT PCREAD PCWRITE)
	(* PC bus dma dontroller%'s low level (command)
	   functions for speech demo)
	(FNS PCDMA.SETADDRESS PCDMA.SETCOUNTER PCDMA.READADDRESS PCDMA.READCOUNTER PCDMA.SETPAGE 
	     PCDMA.SETMODE PCDMA.MASK PCDMA.UNMASK PCDMA.CLEARBYTEFF)
	(* PC bus dma controller%'s higher level functions)
	(FNS PCDMA.INIT)
	(* PC DAC lowest-level stuff)
	(VARS PCDAC.BASE PCDAC.DMACHANNEL)
	(FNS PCDAC.DMASETUP PCDAC.READSTATUS PCDAC.WRITECOMMAND PCDAC.READDATABYTE PCDAC.READDATAWORD 
	     PCDAC.WRITEDATABYTE PCDAC.WRITEDATAWORD PCDAC.REPORTERROR PCDAC.ERRORMESSAGE PCDAC.STOP 
	     PCDAC.RESET PCDAC.CLEARERROR PCDAC.READERROR)
	(* PC DAC midlevel stuff)
	(FNS PCDAC.SETCLOCK PCDAC.SETA/DPARAMETERS PCDAC.READA/DWITHDMA PCDAC.SETD/APARAMETERS 
	     PCDAC.WRITED/AWITHDMA)
	(* testers building up to speech demo)
	(FNS TEST2 TEST2A/D TEST2D/A)))
(DEFINEQ

(BR
  [LAMBDA (N)                                                (* edited: "10-Jul-84 18:34")
    (for I from 0 to 15 sum (LLSH (LOGAND 1 (LRSH N (IDIFFERENCE 15 I)))
				  I])

(INTEST
  [LAMBDA (REG)                                              (* edited: "10-Jul-84 18:25")
    (do (\DEVICE.INPUT REG])

(NEWREADCOLOR
  [LAMBDA (BITMAP CMAP)                                      (* edited: "12-Jul-84 14:15")
    (PROG (BMBASE ADDR)
          (PCCOLORINIT)
          (OR CMAP (SETQ CMAP COLORMAPARRAY))
          [for X from 0 to 15 do (PCWRITELUT X (LOGXOR 255 (ELT CMAP X]
          (SETQ ADDR 0)
          (SETQ BMBASE (fetch BITMAPBASE of BITMAP))
          (for Y from 0 to 400 do (for X from 0 to 160
				     do (PCWRITEPIXEL ADDR (fetch (FOURPIX PIX0) of BMBASE))
					(SETQ ADDR (ADD1 ADDR))
					(PCWRITEPIXEL ADDR (fetch (FOURPIX PIX1) of BMBASE))
					(SETQ ADDR (ADD1 ADDR))
					(PCWRITEPIXEL ADDR (fetch (FOURPIX PIX2) of BMBASE))
					(SETQ ADDR (ADD1 ADDR))
					(PCWRITEPIXEL ADDR (fetch (FOURPIX PIX3) of BMBASE))
					(SETQ ADDR (ADD1 ADDR))
					(SETQ BMBASE (\ADDBASE BMBASE 1])

(OLDPCWRITE
  [LAMBDA (A D)                                              (* edited: "11-Jul-84 15:20")
    (PCBUS A D 2])

(OUTTEST
  [LAMBDA (DATA REG)                                         (* edited: "10-Jul-84 18:24")
    (do (\DEVICE.OUTPUT DATA REG])

(PCBLINK
  [LAMBDA NIL                                                (* edited: "10-Jul-84 22:14")
    (PROG NIL
      LP  (PCPOKE 917552 43690)
          (DISMISS 500)
          (PCPOKE 917552 21845)
          (DISMISS 500)
          (GO LP])

(PCBUS
  [LAMBDA (A D C)                                            (* edited: "12-Jul-84 17:05")
    ((OPCODES MISC2 2)
     (LRSH A 16)
     59)
    ((OPCODES MISC2 2)
     (LOGAND 65535 A)
     48)
    ((OPCODES MISC2 2)
     C 43)
    ((OPCODES MISC2 2)
     D 32)
    ((OPCODES MISC1 1)
     41])

(PCCOLORINIT
  [LAMBDA NIL                                                (* edited: "11-Jul-84 23:51")
    (PCWRITECOLOR 1 16)
    (PCWRITECOLOR 0 24)
    (PCWRITECOLOR 0 10)
    (PCWRITECOLOR 0 25)
    (PCWRITECOLOR 0 43)
    (PCWRITECOLOR 0 227)
    (PCWRITECOLOR 0 39)
    (PCWRITECOLOR 0 0)
    (PCWRITECOLOR 0 0)
    (PCWRITECOLOR 0 0)
    (PCWRITECOLOR 0 0)
    (PCWRITECOLOR 0 0)
    (PCWRITECOLOR 1 63)
    (PCWRITECOLOR 2 1)
    (PCWRITECOLOR 3 0)
    (PCWRITECOLOR 32 8)
    (PCWRITECOLOR 48 0)
    (PCWRITECOLOR 49 0])

(PCCOLORSCROLL
  [LAMBDA (N)                                                (* edited: "12-Jul-84 16:24")
    (OR N (SETQ N 50))
    (for I from 0 to 39
       do (DISMISS N)
	  (PCWRITECOLOR 2 (LOGAND 255 I])

(PCCOLORSCROLLH
  [LAMBDA (N)                                                (* edited: "12-Jul-84 16:26")
    (for I from 400 to 0 by -1
       do (DISMISS N)
	  (PCWRITECOLOR 2 (LOGAND 255 (ITIMES I 39)))
	  (PCWRITECOLOR 3 (LRSH (ITIMES I 39)
				8])

(PCDACCLEAR
  [LAMBDA NIL                                                (* edited: "19-Jul-84 10:56")
    (PCDACCMD 1])

(PCDACCMD
  [LAMBDA (CMD)                                              (* edited: "20-Jul-84 17:33")
    (PROG (X)
          (until [NOT (ZEROP (LOGAND 132 (SETQ X (PCDACSTATUS] do NIL)
          (if (NOT (ZEROP (LOGAND 128 X)))
	      then (PROGN (PRINT (LIST "dac status" X "error" (PCDACERROR)))
			  (HELP)))
          (PCOUTPUT 749 CMD])

(PCDACINPUT
  [LAMBDA NIL                                                (* edited: "20-Jul-84 17:38")
    (PROG (X)
          (until [NOT (ZEROP (LOGAND 129 (SETQ X (PCDACSTATUS] do NIL)
          (if (NOT (ZEROP (LOGAND 128 X)))
	      then (PROGN (PRINT (LIST "dac status" X "error" (PCDACERROR)))
			  (HELP)))
          (RETURN (PCINPUT 748])

(PCDACOUTPUT
  [LAMBDA (DAT)                                              (* edited: "20-Jul-84 18:00")
    (PROG (X)
          (until [PROGN (SETQ X (PCDACSTATUS))
			(OR (NOT (ZEROP (LOGAND 132 X)))
			    (ZEROP (LOGAND 2 X]
	     do NIL)
          (if (NOT (ZEROP (LOGAND 128 X)))
	      then (PROGN (PRINT (LIST "dac status" X "error" (PCDACERROR)))
			  (HELP)))
          (PCOUTPUT 748 DAT])

(PCDACOUTPUT2
  [LAMBDA (D16)                                              (* edited: "19-Jul-84 16:50")
    (PCDACOUTPUT (LOGAND D16 255))
    (PCDACOUTPUT (LRSH D16 8])

(PCDACSTATUS
  [LAMBDA NIL                                                (* edited: "20-Jul-84 19:08")

          (* read status of PC DAC -- in case of errors transmitting status back to host, require 5 or so consecutive reads 
	  of same status value -- called by PCDACERROR so can%'t itself call any PCDACxxx%'s -- N controls consecutive 
	  reads; M counts total reads; LAST reading; NEW reading)


    (PROG ((N 0)
	   (M 0)
	   (LAST 256)
	   NEW)
          [until (GREATERP N 4) do (PROGN (SETQ NEW (PCINPUT 749))
					  (if (EQ LAST NEW)
					      then (SETQ N (ADD1 N))
					    else             (* (OR (ZEROP M) (PRINT (LIST "status fail" N M NEW 
							     LAST))))
						 (SETQ N 0))
					  (SETQ LAST NEW)
					  (SETQ M (ADD1 M]
          (RETURN NEW])

(PCDACSTOP
  [LAMBDA NIL                                                (* edited: "19-Jul-84 14:31")
    (PCOUTPUT 749 15)                                        (* PCDACCMD 0)
    (PCINPUT 748])

(PCDACVOUT
  [LAMBDA (V DACN)                                           (* edited: "20-Jul-84 15:30")
    (OR DACN (SETQ DACN 1))
    (OR V (SETQ V 0))
    (PCDACSTOP)
    (PCDACCLEAR)
    (PCDACCMD 8)
    (PCDACOUTPUT DACN)
    (PCDACOUTPUT2 V)
    (PCDACWAIT)
    (ZEROP (LOGAND 128 (PCDACSTATUS])

(PCDACWAIT
  [LAMBDA (MASK VAL)                                         (* edited: "20-Jul-84 16:31")
    (OR MASK (SETQ MASK 4))
    (OR VAL (SETQ VAL 0))
    (while (EQ VAL (LOGAND (PCDACSTATUS)
			   MASK))
       do NIL])

(PCDMAINIT
  [LAMBDA NIL                                                (* edited: "12-Jul-84 13:46")
                                                             (* Initialize timer)
    (PCOUTPUT (IPLUS 3 PCTIMER)
	      84)
    (PCOUTPUT (IPLUS PCTIMER 1)
	      18)
    (PCOUTPUT (IPLUS PCDMA 13)
	      18)                                            (* Wrap DMA channels address and count registers)
                                                             (* Initialize DMA)
    (PCOUTPUT (IPLUS PCDMA 1)
	      255)
    (PCOUTPUT (IPLUS PCDMA 1)
	      255)                                           (* DMA mode, ch 0, read, autointerrupt)
    (PCOUTPUT (IPLUS PCDMA 11)
	      88)                                            (* enable controller and set up command reg)
    (PCOUTPUT (IPLUS PCDMA 8)
	      0)
    (PCOUTPUT (IPLUS PCDMA 10)
	      0)                                             (* Set modes for each channel)
    (PCOUTPUT (IPLUS PCDMA 11)
	      65)
    (PCOUTPUT (IPLUS PCDMA 11)
	      66)
    (PCOUTPUT (IPLUS PCDMA 11)
	      67])

(PCDMASTOP
  [LAMBDA NIL                                                (* edited: "12-Jul-84 17:36")
    (PCOUTPUT (IPLUS PCDMA 8)
	      4])

(PCDMATEST
  [LAMBDA NIL                                                (* mpl "17-Jul-84 21:42")
    (do (PROGN ((OPCODES MISC2 2)
		D 32])

(PCINITCOLORMAP
  [LAMBDA (COLORMAP)                                         (* edited: "12-Jul-84 17:35")
    (OR COLORMAP (SETQ COLORMAP COLORMAPARRAY))
    (for I from 0 to 15 do (PCWRITELUT I (LOGXOR 255 (ELT COLORMAP I])

(PCINPUT
  [LAMBDA (A)                                                (* edited: "10-Jul-84 22:23")
    (PCBUS A 0 4])

(PCLUTALL
  [LAMBDA (N)                                                (* edited: "11-Jul-84 18:37")
    (for I from 16 to 31 do (PCWRITECOLOR I N])

(PCMEMTEST
  [LAMBDA (D A)                                              (* edited: "11-Jul-84 17:18")
    (OR A (SETQ A 917520))
    (OR D (SETQ D 43690))
    (PCWRITE A D)
    (COND
      ((NEQ D (PRINT (PCREAD A)))
	(HELP])

(PCOUTPUT
  [LAMBDA (A D)                                              (* edited: "10-Jul-84 18:30")
    (PCBUS A D 8])

(PCPEEK
  [LAMBDA (A)                                                (* edited: "10-Jul-84 18:30")
    (PCBUS A 0 1])

(PCPOKE
  [LAMBDA (A D)                                              (* edited: "11-Jul-84 15:20")
    (PCBUS A D 2])

(PCRAMPRINT
  [LAMBDA (N)                                                (* edited: "20-Jul-84 01:52")
    (OR N (SETQ N 256))
    (for I from 0 to (SUB1 N) do (PRINT (LIST I (PCREAD (IPLUS 65536 I])

(PCRAMWRITE
  [LAMBDA NIL                                                (* mpl "17-Jul-84 23:53")
    (for I from 0 to 255 do (PCWRITE (IPLUS 65536 I)
				     I])

(PCREAD
  [LAMBDA (A)                                                (* mpl "17-Jul-84 19:07")
    (LOGAND 255 (PCBUS A 0 1])

(PCREADTEST
  [LAMBDA (A D)                                              (* edited: "11-Jul-84 16:31")
    (OR A (SETQ A 917520))
    (OR D (SETQ D 43690))
    (PCWRITE A D)
    (PRINT (PCREAD A))
    (do (\DEVICE.OUTPUT D 32)
	(\DEVICE.INPUT 41])

(PCROTATELUT
  [LAMBDA NIL                                                (* rrb " 2-Aug-84 10:26")
    (PROG (TEMP)
          (SETQ TEMP (PCREAD 917521))
          [for I from 1 to 14 do (PCWRITELUT I (PCREAD (IPLUS 917521 I]
          (PCWRITELUT 15 TEMP])

(PCT
  [LAMBDA NIL                                                (* edited: "11-Jul-84 18:01")
    (for I from 0 to 15 do (PCMEMTEST I])

(PCTESTCOMMAND
  [LAMBDA NIL                                                (* edited: "12-Jul-84 15:08")
    (do (PCWRITECOLOR 0 255])

(PCTESTLOOP
  [LAMBDA (D)                                                (* edited: "10-Jul-84 22:28")
    (do (\DEVICE.INPUT 41])

(PCTESTTIMER
  [LAMBDA NIL                                                (* edited: "12-Jul-84 11:01")
    (do (PCOUTPUT (IPLUS 3 PCTIMER)
		  84)
	(PCOUTPUT (IPLUS 1 PCTIMER)
		  18])

(PCTESTTIMER2
  [LAMBDA NIL                                                (* edited: "12-Jul-84 12:33")
    (do (PCOUTPUT (IPLUS 3 PCTIMER)
		  84])

(PCWRITE
  [LAMBDA (A D)                                              (* edited: "11-Jul-84 15:20")
    (PCBUS A D 2])

(PCWRITECOLOR
  [LAMBDA (A D)                                              (* edited: "11-Jul-84 18:24")
    (PCWRITE (IPLUS 917504 A)
	     D])

(PCWRITELUT
  [LAMBDA (A D)                                              (* edited: "11-Jul-84 23:20")
    (PCWRITE (IPLUS 917520 A)
	     D])

(PCWRITEPIXEL
  [LAMBDA (N D)                                              (* edited: "12-Jul-84 18:55")
    (PCWRITE 917553 (LRSH N 12))
    (PCWRITE (IPLUS 524288 (LOGAND 4095 N))
	     D])

(PCWRITETEST
  [LAMBDA (A D)                                              (* edited: "12-Jul-84 18:08")
    (OR A (SETQ A 917520))
    (OR D (SETQ D 43690))
    (PCWRITE A D)
    (PRINT (PCREAD A))
    (PCWRITE A D)
    (do (PROGN ((OPCODES MISC2 2)
		D 32])

(PCWRITEVIDEO
  [LAMBDA (N)                                                (* edited: "11-Jul-84 23:04")
    (for I from 0 to 65535 do (PCWRITE (IPLUS I 524288)
				       I])

(PT
  [LAMBDA NIL                                                (* edited: "10-Jul-84 21:53")
    (PCOUTPUT 532 43690)
    (PCTESTLOOP 43690])

(RT
  [LAMBDA NIL                                                (* edited: "10-Jul-84 22:29")
    (PCPOKE 524288 43690)
    (PRINT (PCPEEK 524288))
    (PCTESTLOOP 0])

(TT
  [LAMBDA NIL                                                (* edited: "19-Jul-84 13:25")
    (PCDACDMAOUT])
)
(DECLARE: EVAL@COMPILE 

(RPAQQ PCDMA 0)

(RPAQQ PCTIMER 64)

(CONSTANTS PCDMA PCTIMER)
)

(RPAQ COLORMAPARRAY (READARRAY 16 (QUOTE BYTE) 0))
(0 12 48 3 51 15 60 63 42 46 35 43 56 11 48 10 NIL
)

(RPAQQ PCFNS (BR INTEST NEWREADCOLOR OLDPCWRITE OUTTEST PCBLINK PCBUS PCCOLORINIT PCCOLORSCROLL 
		 PCCOLORSCROLLH PCDACCLEAR PCDACCMD PCDACINPUT PCDACOUTPUT PCDACOUTPUT2 PCDACSTATUS 
		 PCDACSTOP PCDACVOUT PCDACWAIT PCDMAINIT PCDMASTOP PCDMATEST PCINITCOLORMAP PCINPUT 
		 PCLUTALL PCMEMTEST PCOUTPUT PCPEEK PCPOKE PCRAMPRINT PCRAMWRITE PCREAD PCREADTEST 
		 PCROTATELUT PCT PCTESTCOMMAND PCTESTLOOP PCTESTTIMER PCTESTTIMER2 PCWRITE 
		 PCWRITECOLOR PCWRITELUT PCWRITEPIXEL PCWRITETEST PCWRITEVIDEO PT RT TT))
[DECLARE: EVAL@COMPILE 

(BLOCKRECORD FOURPIX ((PIX0 BITS 4)
		      (PIX1 BITS 4)
		      (PIX2 BITS 4)
		      (PIX3 BITS 4)))
]
(DECLARE: EVAL@COMPILE 

(PUTPROPS PCWRITE MACRO ((A D)
			 (PCBUS A D 2)))
)
(DEFINEQ

(PCDACBUFINIT
  [LAMBDA NIL                                                (* edited: "20-Jul-84 14:43")
    (for I from 0 to 255
       do (PCWRITE2 (IPLUS 65536 (ITIMES 2 I))
		    (IPLUS 16 (ITIMES 8 I)))                 (* PRINT (PCREAD2 (IPLUS 65536 65280 
							     (ITIMES 2 I))))
	  ])

(PCDACCMD
  [LAMBDA (CMD)                                              (* edited: "20-Jul-84 17:33")
    (PROG (X)
          (until [NOT (ZEROP (LOGAND 132 (SETQ X (PCDACSTATUS] do NIL)
          (if (NOT (ZEROP (LOGAND 128 X)))
	      then (PROGN (PRINT (LIST "dac status" X "error" (PCDACERROR)))
			  (HELP)))
          (PCOUTPUT 749 CMD])

(PCDACDMAINIT
  [LAMBDA NIL                                                (* edited: "20-Jul-84 14:43")
    (PCOUTPUT 11 89)                                         (* set dma mode and byte flipflop)
    (PCOUTPUT 12 0)                                          (* dmabasereg 0)
    (PCOUTPUT 2 0)
    (PCOUTPUT 2 0)                                           (* dmacount 256)
    (PCOUTPUT 3 255)
    (PCOUTPUT 3 1)                                           (* dmapagereg 1)
    (PCOUTPUT 131 1)                                         (* dma channel mask)
    (PCOUTPUT 10 1])

(PCDACDMAOUT
  [LAMBDA NIL                                                (* edited: "20-Jul-84 14:43")
    (PROG (X)                                                (* (PCRAMPRINT) (PCDACDMAOUT))
          (PCDACSTOP)
          (PCDACERROR)
          (PCDMAINIT)
          (PCDACBUFINIT)
          (PCDACDMAINIT)                                     (* set clock period to 80)
          (PCDACCMD 3)
          (PCDACOUTPUT2 80)                                  (* dac parameters: dac select, dummy no of conversions)
          (PCDACCMD 9)                                       (* ONE DAC CHANNEL)
          (PCDACOUTPUT 1)
          (PCDACOUTPUT2 5)
          (SETQ X (PCDACSTATUS))                             (* write dac continuous dma)
          (PCDACCMD (IPLUS 10 32 16))
          (PRINT (LIST X (PCDACSTATUS])

(PCDACDMASETUP
  [LAMBDA (TOMEM? BASEADDR NPOINTS)                          (* edited: "20-Jul-84 15:52")
    (PROG (X)
          (SETQ X (if TOMEM?
		      then 69
		    else 89))
          (OR BASEADDR (SETQ BASEADDR 0))
          (OR NPOINTS (SETQ NPOINTS 32767))
          (PCOUTPUT 11 X)                                    (* set dma mode and byte flipflop)
          (PCOUTPUT 12 0)                                    (* dmabasereg 0)
          (PCOUTPUT2 2 BASEADDR)                             (* dmacount in bytes)
          (PCOUTPUT2 3 (IPLUS NPOINTS NPOINTS -1))           (* dmapagereg 1)
          (PCOUTPUT 131 1)                                   (* dma channel mask)
          (PCOUTPUT 10 1])

(PCDACERROR
  [LAMBDA NIL                                                (* edited: "20-Jul-84 19:12")
                                                             (* return error code (word) -- called by all the 
							     PCDACxxx%'s except PCDACSTATUS, so can%'t use them)
    (PROG (ERR)
          (PCDACSTOP)                                        (* the STOP command does not have to be synchronized)
          (while (ZEROP (LOGAND 132 (PCDACSTATUS))) do NIL)
                                                             (* wait till DAC ready for command)
          (PCOUTPUT 749 2)                                   (* pcdaccmd 2 -- read error code)
          (while (ZEROP (LOGAND 1 (PCDACSTATUS))) do NIL)    (* wait till DAC has byte for us)
          (SETQ ERR (PCINPUT 748))                           (* err code lo byte)
          (while (ZEROP (LOGAND 1 (PCDACSTATUS))) do NIL)    (* wait till DAC has byte for us)
          (SETQ ERR (LOGOR ERR (LLSH (PCINPUT 748)
				     8)))                    (* err code hi byte)
          (while (ZEROP (LOGAND 4 (PCDACSTATUS))) do NIL)    (* wait till DAC ready for command)
          (PCOUTPUT 749 1)                                   (* pcdaccmd 1 -- clear error)
          (RETURN ERR])

(PCDACFLAP
  [LAMBDA NIL                                                (* edited: "19-Jul-84 14:23")
    (do (PROGN (PCDACVOUT 0)
	       (PRIN1 ".")
	       (PCDACVOUT 255)
	       (PRIN1 "."])

(PCDACINPUT
  [LAMBDA NIL                                                (* edited: "20-Jul-84 17:38")
    (PROG (X)
          (until [NOT (ZEROP (LOGAND 129 (SETQ X (PCDACSTATUS] do NIL)
          (if (NOT (ZEROP (LOGAND 128 X)))
	      then (PROGN (PRINT (LIST "dac status" X "error" (PCDACERROR)))
			  (HELP)))
          (RETURN (PCINPUT 748])

(PCDACINPUT2
  [LAMBDA NIL                                                (* edited: "19-Jul-84 14:47")
    (IPLUS (PCDACINPUT)
	   (LLSH (PCDACINPUT)
		 8])

(PCDACOUTPUT2
  [LAMBDA (D16)                                              (* edited: "19-Jul-84 16:50")
    (PCDACOUTPUT (LOGAND D16 255))
    (PCDACOUTPUT (LRSH D16 8])

(PCDACSETCLOCK
  [LAMBDA (NTICKS)                                           (* edited: "20-Jul-84 12:43")
                                                             (* set clock period in 1.25 usec ticks)
    (PCDACCMD 3)
    (PCDACOUTPUT2 NTICKS])

(PCDACSETUP
  [LAMBDA NIL                                                (* edited: "19-Jul-84 15:53")
                                                             (* dac parameters: dac select, dummy no of conversions)
                                                             (* edited: "19-Jul-84 15:04")
    (PCDACSTATUS)
    (PCDACSTOP)
    (PCDACCMD 9)
    (PCDACOUTPUT 2)
    (PCDACOUTPUT2 5)
    (PCDACERROR])

(PCDACSTATUS
  [LAMBDA NIL                                                (* edited: "20-Jul-84 19:08")

          (* read status of PC DAC -- in case of errors transmitting status back to host, require 5 or so consecutive reads 
	  of same status value -- called by PCDACERROR so can%'t itself call any PCDACxxx%'s -- N controls consecutive 
	  reads; M counts total reads; LAST reading; NEW reading)


    (PROG ((N 0)
	   (M 0)
	   (LAST 256)
	   NEW)
          [until (GREATERP N 4) do (PROGN (SETQ NEW (PCINPUT 749))
					  (if (EQ LAST NEW)
					      then (SETQ N (ADD1 N))
					    else             (* (OR (ZEROP M) (PRINT (LIST "status fail" N M NEW 
							     LAST))))
						 (SETQ N 0))
					  (SETQ LAST NEW)
					  (SETQ M (ADD1 M]
          (RETURN NEW])

(PCDACSTOP
  [LAMBDA NIL                                                (* edited: "19-Jul-84 14:31")
    (PCOUTPUT 749 15)                                        (* PCDACCMD 0)
    (PCINPUT 748])

(PCDACVIN
  [LAMBDA (DACN GAIN)                                        (* edited: "20-Jul-84 15:36")

          (* read one A-D input from A-D channed DACN (default 0), at gain 2**GAIN (default 1=2**0) -- print the value 
	  input; return= there was no error)


    (PROG (V)
          (OR DACN (SETQ DACN 0))
          (OR GAIN (SETQ GAIN 0))
          (PCDACSTOP)
          (PCDACCLEAR)
          (PCDACCMD 12)
          (PCDACOUTPUT GAIN)
          (PCDACOUTPUT DACN)
          (PCDACOUTPUT DACN)
          (PRINT (PCDACINPUT2))
          (PCDACWAIT)
          (ZEROP (LOGAND 128 (PCDACSTATUS])

(PCDACVOUT
  [LAMBDA (V DACN)                                           (* edited: "20-Jul-84 15:30")
    (OR DACN (SETQ DACN 1))
    (OR V (SETQ V 0))
    (PCDACSTOP)
    (PCDACCLEAR)
    (PCDACCMD 8)
    (PCDACOUTPUT DACN)
    (PCDACOUTPUT2 V)
    (PCDACWAIT)
    (ZEROP (LOGAND 128 (PCDACSTATUS])

(PCDACWAIT
  [LAMBDA (MASK VAL)                                         (* edited: "20-Jul-84 16:31")
    (OR MASK (SETQ MASK 4))
    (OR VAL (SETQ VAL 0))
    (while (EQ VAL (LOGAND (PCDACSTATUS)
			   MASK))
       do NIL])

(PCOUTPUT2
  [LAMBDA (PORT V)                                           (* edited: "19-Jul-84 23:57")
    (PCOUTPUT PORT (LOGAND 255 V))
    (PCOUTPUT PORT (LRSH V 8])

(PCOUTPUTTEST
  [LAMBDA (A D)                                              (* edited: "19-Jul-84 18:26")
    (OR A (SETQ A 131))
    (OR D (SETQ D 1))
    (PCOUTPUT A D)
    (PCOUTPUT A D)
    (do (PROGN ((OPCODES MISC2 2)
		D 32])

(PCRAMPRINT
  [LAMBDA (N)                                                (* edited: "20-Jul-84 01:52")
    (OR N (SETQ N 256))
    (for I from 0 to (SUB1 N) do (PRINT (LIST I (PCREAD (IPLUS 65536 I])

(PCRAMPRINT2
  [LAMBDA (N)                                                (* edited: "20-Jul-84 14:05")
    (OR N (SETQ N 256))
    (for I from 0 to (SUB1 N) by 2 do (PRINT (LIST I (PCREAD2 (IPLUS 65536 I])

(PCREAD2
  [LAMBDA (A D)                                              (* edited: "19-Jul-84 17:07")
    (IPLUS (PCREAD A)
	   (LLSH (PCREAD (ADD1 A))
		 8])

(PCWRITE2
  [LAMBDA (A D)                                              (* edited: "19-Jul-84 13:22")
    (PCWRITE A (LOGAND 255 D))
    (PCWRITE (ADD1 A)
	     (LRSH D 8])

(PCWRITELOOP
  [LAMBDA (A D)                                              (* edited: "19-Jul-84 17:29")
    (do (PCWRITE A D])

(TEST
  [LAMBDA (N DV V0 TESTFILE)                                 (* edited: "20-Jul-84 16:00")
    (PROG (X)                                                (* (Number of samples per loop;
							     delta-value; 0th value) (PCRAMPRINT) 
							     (PCDACDMAOUT) (TEST) (PCDMAINIT))
          (OR N (SETQ N 256))
          (OR TESTFILE (SETQ TESTFILE '{ERIS}<SPEECH>WAVE>AUSTIN1.WAVE))
          (OR DV (SETQ DV 2047))
          (OR V0 (SETQ V0 2048))
          (PCDMAINIT)
          (PCDACERROR)
          (PCDACSTOP)                                        (* PCBUFINIT)
          (SETQ TESTARRAY (ARRAY N 'BYTE 0 0))               (* READWAVE TESTARRAY 0 N TESTFILE 0)
          [for I from 0 to (SUB1 N)
	     do (PCWRITE2 (IPLUS 65536 (ITIMES 2 I))
			  (IPLUS V0 (FIX (FTIMES DV (if T
							then (SIN (FQUOTIENT (FTIMES I 360)
									     N))
						      else (CORRECT (ELT TESTARRAY (IPLUS I 400]
                                                             (* PCDACINIT (PCRAMPRINT))
          (PROGN (PCOUTPUT 11 89)                            (* set dma mode and byte flipflop)
		 (PCOUTPUT 12 0)                             (* dmabasereg 0)
		 (PCOUTPUT2 2 0)                             (* dmacount 256)
		 (PCOUTPUT2 3 (IPLUS N N -1))                (* dmapagereg 1)
		 (PCOUTPUT 131 1)                            (* dma channel mask)
		 (PCOUTPUT 10 1)                             (* set clock period to 80)
		 (PCDACCMD 3)
		 (PCDACOUTPUT2 80)                           (* dac parameters: dac select, dummy no of conversions)
		 (PCDACCMD 9)                                (* ONE DAC CHANNEL)
		 (PCDACOUTPUT 1)
		 (PCDACOUTPUT2 5)
		 (SETQ X (PCDACSTATUS))                      (* write dac continuous dma)
		 (PCDACCMD (IPLUS 10 32 16))
		 (PRINT (LIST X (PCDACSTATUS])

(TEST1
  [LAMBDA (NPOINTS)                                          (* edited: "24-Jul-84 20:54")
    (OR NPOINTS (SETQ NPOINTS 32768))
    (PCDACERROR)
    (PCDMAINIT)
    (PCDACSETCLOCK 80)
    (TEST1A-D NPOINTS)                                       (* (DISMISS 6000) (* pause a while -- necessary until we
							     fix status-read &/or find out why status won%'t become 
							     non-3))
    (TEST1D-A NPOINTS])

(TEST1A-D
  [LAMBDA (NPOINTS)                                          (* edited: "24-Jul-84 20:46")
    (PROG (X)                                                (* set up dma channel to read to memory)
          (PCDACDMASETUP T 0 NPOINTS)                        (* dac parameters:)
          (PCDACCMD 13)                                      (* gain, as log2 (actual gain))
          (PCDACOUTPUT 0)                                    (* scan channels 0:0)
          (PCDACOUTPUT 0)
          (PCDACOUTPUT 0)
          (PCDACOUTPUT2 NPOINTS)
          (SETQ X (PCDACSTATUS))                             (* write dac: dma but NOT continuous -- just one buffer 
							     load)
          (BEEPON 500)
          (BLOCK 100)
          (BEEPOFF)
          (PCDACCMD (IPLUS 14 16))
          (PRINT (LIST 'TEST1A-D X (PCDACSTATUS])

(TEST1D-A
  [LAMBDA (NPOINTS)                                          (* edited: "24-Jul-84 20:53")
    (PROG (X)                                                (* dac parameters: dac select, dummy no of conversions)
          (PCDACCMD 9)                                       (* ONE DAC CHANNEL)
          (PCDACOUTPUT 1)
          (PCDACOUTPUT2 5)                                   (* set up dma channel for read memory)
          (PCDACDMASETUP NIL 0 NPOINTS)
          (SETQ X (PCDACSTATUS))                             (* write dac continuous dma)
          (PCDACCMD (IPLUS 10 32 16))
          (PRINT (LIST 'test1d-a X (PCDACSTATUS])
)



(* PC bus interface functions used by speech demo)

(DEFINEQ

(PCBUS
  [LAMBDA (A D C)                                            (* edited: "12-Jul-84 17:05")
    ((OPCODES MISC2 2)
     (LRSH A 16)
     59)
    ((OPCODES MISC2 2)
     (LOGAND 65535 A)
     48)
    ((OPCODES MISC2 2)
     C 43)
    ((OPCODES MISC2 2)
     D 32)
    ((OPCODES MISC1 1)
     41])

(PCINPUT
  [LAMBDA (A)                                                (* edited: "10-Jul-84 22:23")
    (PCBUS A 0 4])

(PCOUTPUT
  [LAMBDA (A D)                                              (* edited: "10-Jul-84 18:30")
    (PCBUS A D 8])

(PCREAD
  [LAMBDA (A)                                                (* mpl "17-Jul-84 19:07")
    (LOGAND 255 (PCBUS A 0 1])

(PCWRITE
  [LAMBDA (A D)                                              (* edited: "11-Jul-84 15:20")
    (PCBUS A D 2])
)



(* PC bus dma dontroller%'s low level (command) functions for speech demo)

(DEFINEQ

(PCDMA.SETADDRESS
  [LAMBDA (CHAN ADDR)                                        (* scp "25-Jul-84 19:06")

          (* * write low-16-bit part of base address to a channel%'s base and current address registers)



          (* * presumes the high-byte-select flipflop is clear; presumes the channel is masked. Note that when a channel%'s 
	  current address register is inc/decremented, that does not affect its page register)


    (PROG ((CMD (LLSH CHAN 1)))
          (PCOUTPUT CMD ADDR)
          (PCOUTPUT CMD (LRSH ADDR 8])

(PCDMA.SETCOUNTER
  [LAMBDA (CHAN NBYTESLESS1)                                 (* scp "25-Jul-84 19:05")

          (* * write 16-bit base byte-count-less-1 for dma to a channel%'s base and current byte count registers)



          (* * presumes the high-byte-select flipflop is clear; presumes the channel is masked.)


    (PROG [(CMD (IPLUS 1 (LLSH CHAN 1]
          (PCOUTPUT CMD NBYTESLESS1)
          (PCOUTPUT CMD (LRSH NBYTESLESS1 8])

(PCDMA.READADDRESS
  [LAMBDA (CHAN)                                             (* scp "25-Jul-84 18:43")

          (* * read and return a channel%'s current address register (that is, the low-16-bit part))



          (* * presumes the high-byte-select flipflop is clear; presumes the channel is masked.)


    (PROG ((CMD (LLSH CHAN 1))
	   V)
          (SETQ V (PCINPUT CMD))
          (RETURN (LOGOR V (LLSH (PCINPUT CMD)
				 8])

(PCDMA.READCOUNTER
  [LAMBDA (CHAN)                                             (* scp "25-Jul-84 18:43")

          (* * read and return a channel%'s current byte-count-remaining-less-1 register)



          (* * presumes the high-byte-select flipflop is clear; presumes the channel is masked.)


    (PROG ((CMD (IPLUS 1 (LLSH CHAN 1)))
	   V)
          (SETQ V (PCINPUT CMD))
          (RETURN (LOGOR V (LLSH (PCINPUT CMD)
				 8])

(PCDMA.SETPAGE
  [LAMBDA (CHAN PAGE)                                        (* scp "25-Jul-84 16:40")

          (* * write the channel%'s page register. The low 4 bits are used as bits 20-17 for the current address register 
	  for this channel. Note that inc/decrementing the channel%'s current address register does NOT affect its page 
	  register. Note that the i/o command address for channel 2 is not known to me at this time, and that for channel 0 
	  (the memory refresh channel) is of no use.)


    (PCOUTPUT (SELECTQ CHAN
		       (1 131)
		       (3 130)
		       (HELP))
	      PAGE])

(PCDMA.SETMODE
  [LAMBDA (CHAN WRITEMEMORY? AUTOINIT?)                      (* scp "25-Jul-84 12:19")

          (* * set the channel%'s mode register. Assumes "single" mode -- this may eventually be the default value for 
	  another argument. Assumes the address register is to increment.)


    (PCOUTPUT 11 (LOGOR 64 (if AUTOINIT?
			       then 16
			     else 0)
			(if WRITEMEMORY?
			    then 4
			  else 8)
			CHAN])

(PCDMA.MASK
  [LAMBDA (CHAN)                                             (* scp "25-Jul-84 12:20")

          (* * prevent dma activity on a channel, by setting its bit in the controller%'s mask register)


    (PCOUTPUT 10 (IPLUS 4 CHAN])

(PCDMA.UNMASK
  [LAMBDA (CHAN)                                             (* scp "25-Jul-84 12:22")

          (* * allow dma activity on a channel, by clearing its bit in the controller%'s mask register)


    (PCOUTPUT 10 CHAN])

(PCDMA.CLEARBYTEFF
  [LAMBDA NIL                                                (* scp "25-Jul-84 12:25")

          (* * clear the dma controller%'s high-byte-select flipflop. This should be done before any sequence of reading 
	  and/or writing the 16-bit registers of the PC bus%'s dma chip ??)


    (PCOUTPUT 12 0])
)



(* PC bus dma controller%'s higher level functions)

(DEFINEQ

(PCDMA.INIT
  [LAMBDA NIL                                                (* scp "25-Jul-84 18:44")

          (* * initialize the PC bus%'s dma controller AND start memory refresh in the PC bus%'s memory, using channel 0 -- 
	  so it also has to initialize the timer used for memory refresh -- leaves channels 1-3 masked but uninitialized)



          (* * presumes PCTIMER contains the base i/o command address for the memory refresh timer -- knows the dma chip%'s 
	  "master clear" command address)



          (* * initialize timer --)


    (PCOUTPUT (IPLUS 3 PCTIMER)
	      84)
    (PCOUTPUT (IPLUS 1 PCTIMER)
	      18)

          (* * dma in general -- master clear, including in particular: clear command register (enable dma controller, no 
	  specials), set mask register (disable all channels), and clear high-byte-select flipflop)


    (PCOUTPUT 13 0)

          (* * memory refresh via channel 0 --)


    (PCDMA.SETCOUNTER 0 8191)                                (* max wordcount)
    (PCDMA.SETMODE 0 NIL T)                                  (* read, autoinit (and "single" mode))
    (PCDMA.UNMASK 0)                                         (* go)
    NIL])
)



(* PC DAC lowest-level stuff)


(RPAQQ PCDAC.BASE 748)

(RPAQQ PCDAC.DMACHANNEL 1)
(DEFINEQ

(PCDAC.DMASETUP
  [LAMBDA (PAGE ADDR NBYTES WRITEMEM? AUTOINIT?)             (* scp "25-Jul-84 12:59")

          (* * sets up dma channel 1 (the DAC%'s dma channel) on the assumption that, except for the arguments here, the 
	  registers and register-parts of the dma controller are to have their current/default values -- this function does 
	  not itself know what any of these default values are)


    (PCDMA.CLEARBYTEFF)
    (PCDMA.MASK PCDAC.DMACHANNEL)
    (PCDMA.SETMODE PCDAC.DMACHANNEL WRITEMEM? AUTOINIT?)
    (PCDMA.SETPAGE PCDAC.DMACHANNEL PAGE)
    (PCDMA.SETADDRESS PCDAC.DMACHANNEL ADDR)
    (PCDMA.SETCOUNTER PCDAC.DMACHANNEL (SUB1 NBYTES))
    (PCDMA.UNMASK PCDAC.DMACHANNEL])

(PCDAC.READSTATUS
  [LAMBDA NIL                                                (* edited: "30-Jul-84 02:27")

          (* * read and return status of PC DAC)



          (* * called by PCDACERROR so can%'t itself call any PCDACxxx%'s)


    (PCINPUT (IPLUS PCDAC.BASE 1])

(PCDAC.WRITECOMMAND
  [LAMBDA (COMMAND NOERROR? NOWAIT?)                         (* scp "26-Jul-84 22:00")

          (* * write command to command register of PC bus%'s DAC -- by default, first (1) wait until DAC%'s status register
	  shows "error" or "ready for new command", and (2) if error, report it -- if NOERROR?, ignore error status entirely
	  -- if NOWAIT?, do no waiting or checking at all)


    (PROG (STATUS)
          (if (NOT NOWAIT?)
	      then (while [AND [ZEROP (LOGAND 4 (SETQ STATUS (PCDAC.READSTATUS]
			       (OR NOERROR? (ZEROP (LOGAND 128 STATUS]
		      do NIL)
		   (if [AND (NOT NOERROR?)
			    (NOT (ZEROP (LOGAND 128 STATUS]
		       then (PCDAC.REPORTERROR STATUS)))
          (PCOUTPUT (IPLUS PCDAC.BASE 1)
		    COMMAND])

(PCDAC.READDATABYTE
  [LAMBDA (NOERROR? NOWAIT?)                                 (* scp "26-Jul-84 22:00")

          (* * read data byte from data register of PC bus%'s DAC -- by default, first (1) wait until DAC%'s status register
	  shows "error" or "ready for new command", and (2) if error, report it -- if NOERROR?, ignore error status entirely
	  -- if NOWAIT?, do no waiting or checking at all)


    (PROG (STATUS)
          (if (NOT NOWAIT?)
	      then (while [AND [ZEROP (LOGAND 1 (SETQ STATUS (PCDAC.READSTATUS]
			       (OR NOERROR? (ZEROP (LOGAND 128 STATUS]
		      do NIL)
		   (if [AND (NOT NOERROR?)
			    (NOT (ZEROP (LOGAND 128 STATUS]
		       then (PCDAC.REPORTERROR STATUS)))
          (RETURN (PCINPUT PCDAC.BASE])

(PCDAC.READDATAWORD
  [LAMBDA (NOERROR?)                                         (* scp "26-Jul-84 22:22")
    (PROG (X)
          (SETQ X (PCDAC.READDATABYTE NOERROR?))
          (RETURN (LOGOR X (LLSH (PCDAC.READDATABYTE NOERROR?)
				 8])

(PCDAC.WRITEDATABYTE
  [LAMBDA (DATA)                                             (* scp "25-Jul-84 16:44")

          (* * write byte of data to data register of PC bus%'s DAC -- first (1) wait until DAC%'s status register shows 
	  "error" or "DAC can accept data byte", and (2) if error, report it)


    (PROG (STATUS)
          (while [AND [ZEROP (LOGAND 128 (SETQ STATUS (PCDAC.READSTATUS]
		      (NOT (ZEROP (LOGAND 2 STATUS]
	     do NIL)
          (if (NULL (ZEROP (LOGAND 128 STATUS)))
	      then (PCDAC.REPORTERROR STATUS))
          (PCOUTPUT PCDAC.BASE DATA])

(PCDAC.WRITEDATAWORD
  [LAMBDA (DATA)                                             (* scp "25-Jul-84 19:02")
    (PCDAC.WRITEDATABYTE DATA)
    (PCDAC.WRITEDATABYTE (LRSH DATA 8])

(PCDAC.REPORTERROR
  [LAMBDA (STATUS)                                           (* edited: " 1-Aug-84 19:28")

          (* * report DAC error if status indicates there is one -- if STATUS arg is null, get status from DAC -- 
	  descriptive massages are printed as well as octal numbers)


    (PROG (ERROR BITNR)
          (OR STATUS (SETQ STATUS (PCDAC.READSTATUS)))
          (if (NOT (ZEROP (LOGAND 128 STATUS)))
	      then (SETQ ERROR (PCDAC.READERROR))
		   (PCDAC.CLEARERROR)
		   [RADIX (PROG1 (RADIX 8)
				 (PRINT (LIST "DAC error" ERROR "with status" STATUS "--"]
		   [for BITNR from 0 to 15 do (if [NOT (ZEROP (LOGAND ERROR (LLSH 1 BITNR]
						  then (PRINT (LIST "  " (PCDAC.ERRORMESSAGE BITNR]
		   (HELP])

(PCDAC.ERRORMESSAGE
  [LAMBDA (BITNR)                                            (* edited: " 1-Aug-84 19:30")

          (* * supply message explaining a given bit of the DAC error register)


    (SELECTQ BITNR
	     (0 "ERR0: reserved")
	     (1 "ERR1: command issued while (noncontinuous) command in progress")
	     (2 "ERR2: attempt to set clock period to illegal value 0 or 1")
	     (3 "ERR3: attempt to select digital port other than 0..2")
	     (4 "ERR4: attempt to read digital port set for output or v.v.")
	     (5 "ERR5: attempt to select DAC other than 0,1 or 2")
	     (6 "ERR6: clock signal occurred before DAC ready")
	     (7 "ERR7: attempt to set D-A #conversions to illegal values 0..2")
	     (8 "ERR8: attempt to select A-D channel other than 0..7 (s/e) or 0..15 (diff)")
	     (9 "ERR9: attempt to set A-D gain other than 0..3")
	     (10 "ERR10: clock signal occurred before A-D ready")
	     (11 "ERR11: A-D mux error -- clocking too fast")
	     (12 "ERR12: attempt to set A-D #conversions to illegal values 0..2")
	     (13 "ERR13: data written to data register when command was expected")
	     (14 "ERR14: reserved")
	     (15 "ERR15: reserved")
	     (HELP])

(PCDAC.STOP
  [LAMBDA NIL                                                (* scp "26-Jul-84 22:03")

          (* * issue an overriding Stop command without waiting for anything to finish -- then read the data byte, which may
	  contain garbage)


    (PCDAC.WRITECOMMAND 15 T T)
    (PCDAC.READDATABYTE T T)
    NIL])

(PCDAC.RESET
  [LAMBDA NIL                                                (* scp "26-Jul-84 22:06")
    (PCDAC.STOP)
    (PCDAC.WRITECOMMAND 0)
    (PCDAC.READDATABYTE T T)
    NIL])

(PCDAC.CLEARERROR
  [LAMBDA NIL                                                (* scp "26-Jul-84 22:07")
    (PCDAC.STOP)
    (PCDAC.WRITECOMMAND 1 T])

(PCDAC.READERROR
  [LAMBDA NIL                                                (* scp "26-Jul-84 22:02")

          (* * read and return the DAC%'s 16-bit error register)


    (PCDAC.STOP)
    (PCDAC.WRITECOMMAND 2 T)
    (PCDAC.READDATAWORD T])
)



(* PC DAC midlevel stuff)

(DEFINEQ

(PCDAC.SETCLOCK
  [LAMBDA (NR1.25USECTICKS)                                  (* scp "25-Jul-84 16:57")

          (* * set DAC board clock period in 1.25 usec ticks)


    (PCDAC.WRITECOMMAND 3)
    (PCDAC.WRITEDATAWORD NR1.25USECTICKS])

(PCDAC.SETA/DPARAMETERS
  [LAMBDA (GAIN STARTCHAN ENDCHAN NPOINTS)                   (* scp "25-Jul-84 17:00")

          (* * note NPOINTS defaults to 64K, and is ignored by the DAC for continuous-mode DMA -- note ENDCHAN defaults to 
	  STARTCHAN)


    (OR ENDCHAN (SETQ ENDCHAN STARTCHAN))
    (OR NPOINTS (SETQ NPOINTS 65536))
    (PCDAC.WRITECOMMAND 13)
    (PCDAC.WRITEDATABYTE GAIN)
    (PCDAC.WRITEDATABYTE STARTCHAN)
    (PCDAC.WRITEDATABYTE ENDCHAN)
    (PCDAC.WRITEDATAWORD NPOINTS])

(PCDAC.READA/DWITHDMA
  [LAMBDA (CONTINUOUS?)                                      (* scp "25-Jul-84 17:05")

          (* assumes no external trigger, no external clock -- note that PCDAC.SETA/DPARAMETERS%'s NPOINTS argument is 
	  ignored for continuous mode dma, tho must be >= 3)


    (PCDAC.WRITECOMMAND (LOGOR 30 (if CONTINUOUS?
				      then 32
				    else 0])

(PCDAC.SETD/APARAMETERS
  [LAMBDA (DAC0? DAC1? NPOINTS)                              (* scp "25-Jul-84 17:15")

          (* * note NPOINTS defaults to 64K, and is ignored by the DAC for continuous-mode DMA -- note at least one of 
	  DAC0?, DAC1? must be specified)


    (PROG [(CHANS (COND
		    ((AND DAC0? (NOT DAC1?))
		      0)
		    ((AND (NOT DAC0?)
			  DAC1?)
		      1)
		    ((AND DAC0? DAC1?)
		      2)
		    (T (HELP]
          (OR NPOINTS (SETQ NPOINTS 65536))
          (PCDAC.WRITECOMMAND 9)
          (PCDAC.WRITEDATABYTE CHANS)
          (PCDAC.WRITEDATAWORD NPOINTS])

(PCDAC.WRITED/AWITHDMA
  [LAMBDA (CONTINUOUS?)                                      (* scp "25-Jul-84 17:07")

          (* assumes no external trigger, no external clock -- note that PCDAC.SETD/APARAMETERS%'s NPOINTS argument is 
	  ignored for continuous mode dma, tho must be >= 3)


    (PCDAC.WRITECOMMAND (LOGOR 26 (if CONTINUOUS?
				      then 32
				    else 0])
)



(* testers building up to speech demo)

(DEFINEQ

(TEST2
  [LAMBDA (NPOINTS)                                          (* scp "25-Jul-84 17:21")
    (OR NPOINTS (SETQ NPOINTS 32768))
    (PCDAC.CLEARERROR)
    (PCDMA.INIT)
    (PCDAC.SETCLOCK 80)
    (TEST2A/D NPOINTS)
    (TEST2D/A NPOINTS)
    (PCDAC.REPORTERROR])

(TEST2A/D
  [LAMBDA (NPOINTS)                                          (* scp "25-Jul-84 19:02")
    (PCDAC.DMASETUP 1 0 (LLSH NPOINTS 1)
		    T NIL)
    (PCDAC.SETA/DPARAMETERS 0 0 0 NPOINTS)
    (BEEPON 500)
    (BLOCK 100)
    (BEEPOFF)
    (PCDAC.READA/DWITHDMA NIL])

(TEST2D/A
  [LAMBDA (NPOINTS)                                          (* scp "25-Jul-84 17:57")
    (PCDAC.SETD/APARAMETERS NIL T)
    (PCDAC.DMASETUP 1 0 NPOINTS NIL T)
    (PCDAC.WRITED/AWITHDMA T])
)
(PUTPROPS PCBUS COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (2288 14952 (BR 2298 . 2499) (INTEST 2501 . 2640) (NEWREADCOLOR 2642 . 3558) (OLDPCWRITE
 3560 . 3693) (OUTTEST 3695 . 3841) (PCBLINK 3843 . 4103) (PCBUS 4105 . 4414) (PCCOLORINIT 4416 . 5026
) (PCCOLORSCROLL 5028 . 5265) (PCCOLORSCROLLH 5267 . 5556) (PCDACCLEAR 5558 . 5690) (PCDACCMD 5692 . 
6070) (PCDACINPUT 6072 . 6455) (PCDACOUTPUT 6457 . 6891) (PCDACOUTPUT2 6893 . 7079) (PCDACSTATUS 7081
 . 7903) (PCDACSTOP 7905 . 8121) (PCDACVOUT 8123 . 8458) (PCDACWAIT 8460 . 8705) (PCDMAINIT 8707 . 
9846) (PCDMASTOP 9848 . 10002) (PCDMATEST 10004 . 10156) (PCINITCOLORMAP 10158 . 10411) (PCINPUT 10413
 . 10543) (PCLUTALL 10545 . 10721) (PCMEMTEST 10723 . 10964) (PCOUTPUT 10966 . 11097) (PCPEEK 11099 . 
11228) (PCPOKE 11230 . 11359) (PCRAMPRINT 11361 . 11588) (PCRAMWRITE 11590 . 11782) (PCREAD 11784 . 
11921) (PCREADTEST 11923 . 12190) (PCROTATELUT 12192 . 12490) (PCT 12492 . 12657) (PCTESTCOMMAND 12659
 . 12810) (PCTESTLOOP 12812 . 12954) (PCTESTTIMER 12956 . 13161) (PCTESTTIMER2 13163 . 13328) (PCWRITE
 13330 . 13460) (PCWRITECOLOR 13462 . 13618) (PCWRITELUT 13620 . 13774) (PCWRITEPIXEL 13776 . 13983) (
PCWRITETEST 13985 . 14267) (PCWRITEVIDEO 14269 . 14472) (PT 14474 . 14633) (RT 14635 . 14823) (TT 
14825 . 14950)) (15889 29707 (PCDACBUFINIT 15899 . 16230) (PCDACCMD 16232 . 16610) (PCDACDMAINIT 16612
 . 17249) (PCDACDMAOUT 17251 . 18148) (PCDACDMASETUP 18150 . 18924) (PCDACERROR 18926 . 20295) (
PCDACFLAP 20297 . 20512) (PCDACINPUT 20514 . 20897) (PCDACINPUT2 20899 . 21072) (PCDACOUTPUT2 21074 . 
21260) (PCDACSETCLOCK 21262 . 21532) (PCDACSETUP 21534 . 21994) (PCDACSTATUS 21996 . 22818) (PCDACSTOP
 22820 . 23036) (PCDACVIN 23038 . 23687) (PCDACVOUT 23689 . 24024) (PCDACWAIT 24026 . 24271) (
PCOUTPUT2 24273 . 24456) (PCOUTPUTTEST 24458 . 24709) (PCRAMPRINT 24711 . 24938) (PCRAMPRINT2 24940 . 
25178) (PCREAD2 25180 . 25352) (PCWRITE2 25354 . 25541) (PCWRITELOOP 25543 . 25685) (TEST 25687 . 
27646) (TEST1 27648 . 28109) (TEST1A-D 28111 . 29009) (TEST1D-A 29011 . 29705)) (29767 30624 (PCBUS 
29777 . 30086) (PCINPUT 30088 . 30218) (PCOUTPUT 30220 . 30351) (PCREAD 30353 . 30490) (PCWRITE 30492
 . 30622)) (30708 34616 (PCDMA.SETADDRESS 30718 . 31275) (PCDMA.SETCOUNTER 31277 . 31744) (
PCDMA.READADDRESS 31746 . 32206) (PCDMA.READCOUNTER 32208 . 32667) (PCDMA.SETPAGE 32669 . 33296) (
PCDMA.SETMODE 33298 . 33766) (PCDMA.MASK 33768 . 34023) (PCDMA.UNMASK 34025 . 34272) (
PCDMA.CLEARBYTEFF 34274 . 34614)) (34677 35941 (PCDMA.INIT 34687 . 35939)) (36040 42760 (
PCDAC.DMASETUP 36050 . 36793) (PCDAC.READSTATUS 36795 . 37088) (PCDAC.WRITECOMMAND 37090 . 37904) (
PCDAC.READDATABYTE 37906 . 38703) (PCDAC.READDATAWORD 38705 . 38962) (PCDAC.WRITEDATABYTE 38964 . 
39582) (PCDAC.WRITEDATAWORD 39584 . 39778) (PCDAC.REPORTERROR 39780 . 40567) (PCDAC.ERRORMESSAGE 40569
 . 41771) (PCDAC.STOP 41773 . 42114) (PCDAC.RESET 42116 . 42318) (PCDAC.CLEARERROR 42320 . 42487) (
PCDAC.READERROR 42489 . 42758)) (42795 45025 (PCDAC.SETCLOCK 42805 . 43062) (PCDAC.SETA/DPARAMETERS 
43064 . 43595) (PCDAC.READA/DWITHDMA 43597 . 43999) (PCDAC.SETD/APARAMETERS 44001 . 44618) (
PCDAC.WRITED/AWITHDMA 44620 . 45023)) (45073 45900 (TEST2 45083 . 45381) (TEST2A/D 45383 . 45675) (
TEST2D/A 45677 . 45898)))))
STOP