// DiExAddr.bcpl

get "DiEx.defs"

manifest new = 1

let DisplayAddr() be
	[
	Active = false
	DisplayParam(FirstDrive, 4, Tab0)
	DisplayParam(LastDrive, 4, Tab1)
	DisplayParam(DrType, 4, Tab2)
	DisplayParam(FirstCyl, 6, Tab0)
	DisplayParam(LastCyl, 6, Tab1)
	DisplayParam(CylInc, 6, Tab2)
	DisplayParam(FirstHd, 7, Tab0)
	DisplayParam(LastHd, 7, Tab1)
	DisplayParam(FirstSec, 8, Tab0)
	DisplayParam(LastSec, 8, Tab1)
	]

and DisplayAddrCont() be
	[
	Active = false
	DisplayParam(AllDisk, 5, Tab0)
	DisplayParam(OneSector, 5, Tab1)
	DisplayParam(Virtual, 5, Tab2)
	]

and DrType() be
	[ let flag,str = 0,nil
	if NewBoolian(0) then
		[ flag = new
		if T>>P.LastCyl eq nTracks-1 then T>>P.LastCyl = 1000
		]
	switchon nTracks + flag into
		[
		default:			nTracks = 203
		case 203:			str = "31"; endcase

		case 203+new:	nTracks = 406 
		case 406:			str = "44"; endcase

		]
	if flag then [ DisplayAddr() ]  //DisplayComm()
	PrintParam("Type: Mod-$S",str)
	]

and AllDisk() be
	[
	if NewBoolian("Will set Disk testing bounds to All of Disk") then
		[
		T>>P.FirstCyl = 0; T>>P.LastCyl = nTracks-1; T>>P.CylInc = 1
		T>>P.FirstHd = 0; T>>P.LastHd = nHeads-1
		T>>P.FirstSec = 0; T>>P.LastSec = nSectors-1
		DisplayAddr()
		]
	PrintParam("All Disk")
	]

and OneSector() be
	[
	if NewBoolian("Will set Disk testing to a single sector (you may trigger the scope on 'index' pulse)") then
		[
		T>>P.FirstCyl = 0; T>>P.LastCyl = 0; T>>P.CylInc = 1
		T>>P.FirstHd = 0; T>>P.LastHd = 0
		T>>P.FirstSec = 0; T>>P.LastSec = 0
		DisplayAddr()
		]
	PrintParam("1 Sector")
	]

and Virtual() be
	[ 
	let Str = "Will set Disk testing bounds to a single Virtual disk address you now type in"
	let vDA = NewNumber(Str,VirtualDA(lv T>>P.FirstCyl), "DA = ",10,5)
	if Active gr 0 then
		[
		if vDA ls 0 then vDA = #77777
		vDA = SetBounds(vDA, 0, nTracks*nHeads*nSectors - 1)
		//PrintParam("DA = $D",vDA)
		RealDA(vDA, lv T>>P.FirstCyl); RealDA(vDA, lv T>>P.LastCyl)
		DisplayAddr()
		]
	PrintParam("Virtual DA")
	]

and FirstDrive() be
	[ let str = "First Drive = "
	let HintStr = "Only applies in a 'multi-drive' system."
	FirstDr = NewNumber(HintStr, FirstDr, str)
	FirstDr = SetBounds(FirstDr, 0, 1); if Active gr 0 then DisplayAddr()
	PrintParam("$S$D",str,FirstDr)
	]

and LastDrive() be
	[ let str = "Last Drive = "
	let HintStr = "Only applies in a 'multi-drive' system."
	LastDr = NewNumber(HintStr, LastDr, str)
	LastDr = SetBounds(LastDr, FirstDr, 1)
	PrintParam("$S$D", str, LastDr)
	]

and FirstCyl() be
	[ let str = "First Cyl = "
	let num = NewNumber(0,T>>P.FirstCyl, str)
	T>>P.FirstCyl = SetBounds(num, 0, nTracks-1); if Active gr 0 then DisplayAddr()
	PrintParam("$S$D",str,T>>P.FirstCyl)
	]

and LastCyl() be
	[ let str = "Last Cyl = "
	let num = NewNumber(0,T>>P.LastCyl, str)
	T>>P.LastCyl = SetBounds(num, T>>P.FirstCyl, nTracks-1)
	PrintParam("$S$D", str, T>>P.LastCyl)
	]

and CylInc() be
	[ let str = "Cyl Inc = "
	let num = NewNumber(0,T>>P.CylInc, str)
	T>>P.CylInc=SetBounds(num,1,T>>P.LastCyl-T>>P.FirstCyl)//returns 0 if Max is 0
	if not T>>P.CylInc then T>>P.CylInc = 1
	PrintParam("$S$D", str, T>>P.CylInc)
	]

and FirstHd() be
	[ let str = "First Hd = "
	let num = NewNumber(0,T>>P.FirstHd, str)
	T>>P.FirstHd = SetBounds(num, 0, nHeads-1); if Active gr 0 then DisplayAddr()
	PrintParam("$S$D", str, T>>P.FirstHd)
	]

and LastHd() be
	[ let str = "Last Hd = "
	let num = NewNumber(0,T>>P.LastHd, str)
	T>>P.LastHd = SetBounds(num, T>>P.FirstHd, nHeads-1)
	PrintParam("$S$D",str,T>>P.LastHd)
	]

and FirstSec() be
	[ let str = "First Sec = "
	let num = NewNumber(0,T>>P.FirstSec, str)
	T>>P.FirstSec = SetBounds(num, 0, nSectors-1); if Active gr 0 then DisplayAddr()
	PrintParam("$S$D", str, T>>P.FirstSec)
	]

and LastSec() be
	[ let str = "Last Sec = "
	let num = NewNumber(0,T>>P.LastSec, str)
	T>>P.LastSec = SetBounds(num,T>>P.FirstSec,nSectors-1)
	PrintParam("$S$D", str, T>>P.LastSec)
	]