// G J U N T A

get "BRAVO.DF";
get "HEAP.DF";
get "DISPLAY.DF";
get "CHAR.DF";

// Incoming Procedures

external [
	ult;
	errhlt;
	bravocom;
	oinit;
	updatedisplay;
	move;
	ActOnPages;
	WritePages;
	trims;
	recover;
	array
	movestack
	hpinit
	addbp
	opens
	creates
	dumpcore
	ugt
	movec
	InitSwatRes
	stcopy
	stappend
	stsize
	EtherReport
	];

// Incoming Statics

external [
	freet;
	KEYS;
	freee;
	rgsbcom;
	rgsbopand;
	mpfunsb;
	rgdllast;
	rgmaxdl;
	rgcdlblank;
	rgmaccp;
	rgupdate;
	macww;
	vpzone;
	rgcplast;
	rgdoc;
	BITTABLE;
	mpfnof;
	fillInDA;
	eofDA;
	DCread;
	dnbp;
	cominstream
	pzone
	stackroot
	LASTSN1
	LASTSN2
	tsmacro
	vmtb
	rgbp
	rgvpa
	rglastused
	rgbs
	macbp
	lrutime
	dnfn
	macfn
	cvmfree
	cof
	rgnchlast
	vdeltafp
	begofopsys;
	USERNAME;
	mpfnsb
	];

// Outgoing Procedures

external [
	junta;
	];

// Outgoing Statics

external [
	diskBitTable;
	diskBTsize;
	lastSN;
	]; 

// Local Statics

static [
	diskBitTable;
	diskBTsize;
	lastSN;
	];

let junta() be
[
InitSwatRes();
// ** let report = vec 20;
// ** report ! 0 = 1;
// ** report ! 1 = 0;
// ** stcopy(lv(report ! 1),"Bravo started by ");
// ** stappend(lv(report ! 1),USERNAME);
// ** EtherReport(((stsize(lv(report ! 1))+4) rshift 1),report);
move(osmachinecode, begofopsys, osmachinecodel);
freet = osmachinecode;
freee = osmachinecode+osmachinecodel-1;

lastSN = array(2);
lastSN ! 0 = rv LASTSN1;
lastSN ! 1 = rv LASTSN2;
diskBTsize = (nTracks*nHeads*nSectors)/16+1;
diskBitTable = array(diskBTsize);
move(BITTABLE, diskBitTable, diskBTsize);

pzone = array(zonel); // a heap just for fndir and fnopsys

initvm(array);
while (freee-freet) gr (chperpage rshift 1) do
	addbp(array);
]

// I N I T V M 
// catalogue no = SPE-84
and initvm(alloc) be
[ vmtb = alloc(vmtbmask+1);
movec(vmtb,vmtb+vmtbmask,0);
rgbp = alloc(vmtbmask+1);
dnbp = alloc(maxbp);
rgvpa = alloc(maxbp);
movec(rgvpa,rgvpa+maxbp-1,-1);
rglastused = alloc(maxbp);
rgbs = alloc(maxbp);
macbp = 0;
lrutime = 1;
dnfn = alloc(maxfn);
macfn = 0;
cvmfree = vmtbmask+1;
 
cof = 0;
movec(dnfn,dnfn+maxfn-1,-1);
mpfnof = alloc(maxfn);
movec(mpfnof,mpfnof+maxfn-1,-1);
rgnchlast = alloc(maxbp);
movec(rgnchlast,rgnchlast+maxbp-1,#1000);
vdeltafp = 0;
mpfnsb = alloc(maxfn);
movec(mpfnsb,mpfnsb+maxfn-1,0);
]