// S L O T D E B U G
// Print page to the display -- for debugging on slot devices.
// Use the value for BandWidth from Press.bits (can be less than 16)
// GWilliams -- April 19, 1982 6:15 PM
get "PressInternals.df"
get "PressParams.df"

//outgoing procedures
external PSLOTDisplay

//incoming procedures
external
[
//WINDOW
WindowInit
WindowClose
WindowReadBlock
WindowGetPosition
WindowSetPosition
FileVDA

//PRESSML
DoubleAdd
Ugt
BitBLT

//OS
Zero
MoveBlock
Timer

//PRESS
PressError
DblShift
FSGet
FSGetX
FSPut
MulDiv

//CURSOR
CursorChar
CursorDigit
CursorToggle

//PRINT
PrintError
]

// incoming statics
external
[
BitsFile
]

manifest DISWID=36

let PSLOTDisplay(pg) be
[
let BandWidth = pg>>PageG.BandWidth
//believe what was written by producer program
let nbands=pg>>PageG.LastBand-pg>>PageG.FirstBand+1
let gbands=nbands
//Number of bands we have dis for
if gbands gr 800/BandWidth then gbands=800/BandWidth
let dsiz=nil
//Size of dis buffer
let dcore=nil
//Dis buffer
while gbands ge 1 do
[
dsiz=gbands*BandWidth*DISWID
//Size
dcore=FSGet(dsiz+1)
//Try for it
if dcore then break
//OK
gbands=gbands-1
]
if dcore eq 0 then [ PressError(1701); return ]
let dptr=(dcore+1)&(-2)
//Even address

Zero(dptr,dsiz)
//Zero it.
let display=vec 10
display=(display+1)&(-2)
//Even address
display!0=@#420
display!1=DISWID
display!2=dptr
display!3=gbands*BandWidth/2

let BitWc=pg>>PageG.BitWc
let pages=((BitWc*BandWidth+1023)/1024)
//1024 word hunks
let del=vec 1; del!0=0; del!1=BitWc
let rwin=WindowInit(BitsFile)
//Get a window.

let band=0
//Number of bands displayed.
while band ls nbands do
//Loop through all bands.
[
let b=nbands-band
if b gr gbands then b=gbands
// b= number of bands to show this time

let wid=0
//Number of words displayed
while wid ls BitWc do
[
let w=BitWc-wid
if w gr DISWID then w=DISWID// w= number of words to display

//When we get here, we are to display "b" bands starting at "band".
//In each band, we are to show "w" words starting at "wid"
// ***** Loop begins here *****
Zero(dptr,dsiz)

for db=0 to b-1 do
[
let pos=vec 1
pos!0=0; pos!1=(band+db)*pages+pg>>PageG.BitPage
DblShift(pos,-10)//1024 hunks to Words
let dw=vec 1
dw!0=0; dw!1=wid//Amount to pass up
DoubleAdd(dw,pos)//Where to start
WindowSetPosition(rwin,dw)

let dbase=dptr+DISWID*db*BandWidth

for sl=0 to BandWidth-1 do//For entire band
[
WindowReadBlock(rwin,dbase+sl*DISWID,w)
DoubleAdd(dw,del)//To next scan line
WindowSetPosition(rwin,dw)
]
]
// ***** Loop ends here *****

@#420=display//Now displaying!
CursorToggle(2); CursorToggle(3)//Let him know!
PrintError()//Wait for response
@#420=0
wid=wid+w
]

band=band+b
]

WindowClose(rwin)
@#420=display!0
FSPut(dcore)
]