// GSWATRES.SR
// Swat's resident. See RSDNT and SWAPPER
// SWAT.16
 
get "LUSERSYMS.SR"
 
external [
// defined herein:
	InitSwatRes
	VCALL
// used:
// BMSG, OPENAFILE, CLOSEAFILE -- in USERSYMS
	SWAPINFILE	// pointers into RSDNT
	SWAPOUTFILE
	BREAKENTRY
	INTERRUPTENTRY
	LOCALSTORAGE
	]
 

let VCALL(cv) = valof [
  let cd = vec 7
  for i = 0 to 7 do cd!i = cv!i // quixotic attempt to make
  (table [ #61001		//	EIR;
	#1401		//	JMP+I3+1
	 ] )() // recursively interruptable
  resultis selecton cd!1 into
	[ case 0: (cd!0)()
	  case 1: (cd!0)(cd!2)
	  case 2: (cd!0)(cd!2,cd!3)
	  case 3: (cd!0)(cd!2,cd!3,cd!4)
	  case 4: (cd!0)(cd!2,cd!3,cd!4,cd!5)
	  case 5: (cd!0)(cd!2,cd!3,cd!4,cd!5,cd!6)
	  case 6: (cd!0)(cd!2,cd!3,cd!4,cd!5,cd!6,cd!7)
	]
]
 
let InitSwatRes() be [

// link up with OUTINLD (kludge, see ENTVEC)
// **??**

// set up swapping files
let brent = @#567;
let osswapinfile = brent-#31;
BMOVE(osswapinfile,SWAPINFILE,5);
let osswapoutfile = brent-#43;
BMOVE(osswapoutfile,SWAPOUTFILE,5);
 
// set up trap location for breaks
@567b = BREAKENTRY	// LAST ENTRY IN TRAP VECTOR (77400b)
 
// set up keyboard interrupt
@511b = INTERRUPTENTRY 	// entry in interrupt vector
@453b = @453b % 00400b    // active
@421b = @421b % 00400b   // timer from vert. dis.
 
// give RSDNT a storage area
@LOCALSTORAGE = table [ // storage for strings
	50;	// highest index
	0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;
	0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;
	]
 
]