// XKBD.SR Initiallize keyboard handler for Bravo
// Last modified November 3, 1979 2:53 PM by Taft
get "BRAVO1.DF";
get "CHAR.DF";
get "DOC.DF";
get "SELECT.DF";
get "rn1.df"
get "com.df"
// Incoming Procedures
external [
DisableInterrupts
EnableInterrupts
CreateKeyboard
swat;
array;
movestack;
loadcore;
move;
hplay
puts;
gets;
flushfn;
confirm;
stnum;
stappend;
deleted;
inserta;
updatedisplay;
inserttx;
getint;
setsel;
SetRegionW
SetRegionA
SetRegionSys
ClearBuf
InsertBuf
augmentomseq;
deactivateomseq;
blinkscreen;
bravoFinish;
GetFromRB
RBempty
GetCharReplay;
ComReplay;
];
// Incoming Statics
external
[
vrlwsys
linkCursorToMouse
Saved335
begofopsys
diskBitTable
diskBTsize
lastSN
LASTSN1
LASTSN2
BITTABLE
stackroot
ozone
tsread
tscorrect
fnts
tstoflush
tsmacro
mpfnof
ccommand
tsbreak
tsstop
tsquick
sbstate
rgmaccp
sbtermesc
vcp
selaux;
vfhpsp;
OsBuffer;
]
// Outgoing Procedures
external [
initkbd
// boot
getchar
endofkeystream
bravochar;
tsflush;
resetts;
tsmode;
setreplay;
tsmakegood;
PutItem;
putsonts;
];
// Outgoing Statics
external [
SavedFinish
SavedKeyProcess
cominstream
SavedParityProcess
];
// Local Statics
static [
SavedFinish
SavedKeyProcess
cominstream
SavedParityProcess
];
manifest [
AdrAdrFinish=#353 //Holds address of finish code
bootCommand=#100000 // arg of StartIO to boot
KeyProcess=12
interruptVector = #500
keystreaml = 50;
ParityProcess = 1;
]
let initkbd() be
[
// cominstream = table [
// 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;
// ] ;
// SavedKeyProcess = @(interruptVector+KeyProcess)
// SavedFinish=@AdrAdrFinish //Save finish code
// SavedParityProcess = @(interruptVector+ParityProcess);
// @(interruptVector+ParityProcess) = PARTY;
// @AdrAdrFinish=bravoFinish //On finish, try recovery
let stackspace = table [
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;
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
]
CreateKeyboard(KeyProcess, stackspace,100)
linkCursorToMouse = true
]
//and boot() be
// [
// let StartIO = table [ #61004 ; #1401 ] ;
// StartIO(bootCommand)
// swat("boot failed, please push manual boot button. ")
// ]
and getchar() = GetFromRB()
and endofkeystream() = RBempty()
// B R A V O C H A R
//
and bravochar( ) = valof
[ let tchar = nil;
test tsread ifso
[ let tchar = GetCharReplay()
resultis tchar
]
ifnot
[
tchar = getchar( );
if tscorrect then
[ if (tchar eq chesc) then
[
tscorrect = false;
tsread = true;
]
resultis tchar;
]
puts(fnts,tchar);
if tchar eq chat then
puts(fnts,chat);
tsmakegood();
if tstoflush eq 0 then
tsflush( );
tstoflush = tstoflush-1;
resultis tchar;
]
]
// T S F L U S H
//
and tsflush( ) be
[ flushfn(fnts);
tstoflush = 20;
]
// R E S E T T S
//
and resetts( ) be
[
(mpfnof ! fnts) >> OF.pos = (mpfnof ! fnts) >> OF.pos-2;
]
// T S M O D E
//
and tsmode() be
[ ccommand = ccommand+1;
if ccommand eq tsbreak then tsstop = true;
if tsread & not tsmacro & (tsstop % not endofkeystream()) then
ComReplay();
]
// S E T R E P L A Y
//
and setreplay() be
[ tsread = true;
tsquick = true;
tsstop = false;
tsbreak = -1;
]
// T S M A K E G O O D
//
and tsmakegood() be
[ let tpage = ((mpfnof ! fnts) >> OF.pos) << PCD.p;
puts(fnts,chat);
puts(fnts,$E);
if ((mpfnof ! fnts) >> OF.pos) << PCD.p ne tpage then
tsflush();
(mpfnof ! fnts) >> OF.pos = (mpfnof ! fnts) >> OF.pos-2;
]
// P U T I T E M
//
// and PutItem(i) = valof
// [ let newIn = OsBuffer>>OsBUF.In+1;
// if newIn eq OsBuffer>> OsBUF.Last then newIn = OsBuffer>>OsBUF.First
// if newIn eq OsBuffer>> OsBUF.Out then resultis 0
// @(OsBuffer>>OsBUF.In) = i
// OsBuffer>>OsBUF.In = newIn
// resultis -1;
// ]
// P U T S O N T S
//
and putsonts(char) be
[ puts(fnts,char)
tsmakegood()
tsflush()
]