head     56.3;
access   paws bayes jws quist brad dew jwh;
symbols  ;
locks    ; strict;
comment  @# @;


56.3
date     93.01.27.13.37.32;  author jwh;  state Exp;
branches ;
next     56.2;

56.2
date     93.01.27.12.12.58;  author jwh;  state Exp;
branches ;
next     56.1;

56.1
date     91.11.05.09.43.09;  author jwh;  state Exp;
branches ;
next     55.1;

55.1
date     91.08.25.10.21.21;  author jwh;  state Exp;
branches ;
next     54.1;

54.1
date     91.03.18.15.25.34;  author jwh;  state Exp;
branches ;
next     53.1;

53.1
date     91.03.11.19.26.45;  author jwh;  state Exp;
branches ;
next     52.1;

52.1
date     91.02.19.09.10.43;  author jwh;  state Exp;
branches ;
next     51.1;

51.1
date     91.01.30.16.10.17;  author jwh;  state Exp;
branches ;
next     50.1;

50.1
date     90.10.29.16.25.07;  author jwh;  state Exp;
branches ;
next     49.1;

49.1
date     90.08.14.14.09.26;  author jwh;  state Exp;
branches ;
next     48.1;

48.1
date     90.07.26.11.15.28;  author jwh;  state Exp;
branches ;
next     47.1;

47.1
date     90.05.14.10.57.19;  author dew;  state Exp;
branches ;
next     46.1;

46.1
date     90.05.07.08.44.28;  author jwh;  state Exp;
branches ;
next     45.1;

45.1
date     90.04.19.15.52.09;  author jwh;  state Exp;
branches ;
next     44.1;

44.1
date     90.04.01.22.09.32;  author jwh;  state Exp;
branches ;
next     43.1;

43.1
date     90.03.20.14.00.53;  author jwh;  state Exp;
branches ;
next     42.1;

42.1
date     90.01.23.17.45.29;  author jwh;  state Exp;
branches ;
next     41.1;

41.1
date     89.12.22.11.28.20;  author jwh;  state Exp;
branches ;
next     40.1;

40.1
date     89.09.29.11.50.19;  author jwh;  state Exp;
branches ;
next     39.1;

39.1
date     89.09.26.16.34.42;  author dew;  state Exp;
branches ;
next     38.1;

38.1
date     89.08.29.11.26.20;  author jwh;  state Exp;
branches ;
next     37.1;

37.1
date     89.05.12.11.38.54;  author dew;  state Exp;
branches ;
next     36.1;

36.1
date     89.02.06.10.17.25;  author dew;  state Exp;
branches ;
next     35.1;

35.1
date     89.02.02.13.31.29;  author dew;  state Exp;
branches ;
next     34.1;

34.1
date     89.01.23.16.06.41;  author jwh;  state Exp;
branches ;
next     33.1;

33.1
date     89.01.16.11.39.23;  author dew;  state Exp;
branches ;
next     32.1;

32.1
date     89.01.10.11.47.09;  author bayes;  state Exp;
branches ;
next     31.1;

31.1
date     88.12.14.18.08.27;  author bayes;  state Exp;
branches ;
next     30.1;

30.1
date     88.12.09.13.45.42;  author dew;  state Exp;
branches ;
next     29.1;

29.1
date     88.10.31.15.30.23;  author bayes;  state Exp;
branches ;
next     28.1;

28.1
date     88.10.06.10.57.59;  author dew;  state Exp;
branches ;
next     27.1;

27.1
date     88.09.29.11.29.07;  author bayes;  state Exp;
branches ;
next     26.1;

26.1
date     88.09.28.13.10.23;  author bayes;  state Exp;
branches ;
next     25.1;

25.1
date     88.03.02.09.26.43;  author bayes;  state Exp;
branches ;
next     24.1;

24.1
date     87.08.31.09.45.52;  author jws;  state Exp;
branches ;
next     23.1;

23.1
date     87.08.26.10.22.54;  author bayes;  state Exp;
branches ;
next     22.1;

22.1
date     87.08.17.11.08.15;  author bayes;  state Exp;
branches ;
next     21.1;

21.1
date     87.08.12.13.51.26;  author bayes;  state Exp;
branches ;
next     20.1;

20.1
date     87.07.30.11.04.45;  author bayes;  state Exp;
branches ;
next     19.1;

19.1
date     87.06.01.08.20.31;  author jws;  state Exp;
branches ;
next     18.1;

18.1
date     87.05.20.15.16.47;  author bayes;  state Exp;
branches ;
next     17.1;

17.1
date     87.04.30.10.31.17;  author jws;  state Exp;
branches ;
next     16.1;

16.1
date     87.04.26.15.43.53;  author jws;  state Exp;
branches ;
next     15.1;

15.1
date     87.04.13.09.17.51;  author jws;  state Exp;
branches ;
next     14.1;

14.1
date     87.04.01.15.21.32;  author jws;  state Exp;
branches ;
next     13.1;

13.1
date     87.02.28.18.29.37;  author jws;  state Exp;
branches ;
next     12.1;

12.1
date     87.02.02.13.19.56;  author jws;  state Exp;
branches ;
next     11.1;

11.1
date     87.01.19.09.46.04;  author jws;  state Exp;
branches ;
next     10.1;

10.1
date     86.12.24.10.53.46;  author jws;  state Exp;
branches ;
next     9.1;

9.1
date     86.12.12.14.33.27;  author bayes;  state Exp;
branches ;
next     8.1;

8.1
date     86.11.27.11.51.29;  author jws;  state Exp;
branches ;
next     7.1;

7.1
date     86.11.20.13.41.23;  author hal;  state Exp;
branches ;
next     6.1;

6.1
date     86.11.04.17.53.00;  author paws;  state Exp;
branches ;
next     5.1;

5.1
date     86.10.28.16.40.57;  author hal;  state Exp;
branches ;
next     4.1;

4.1
date     86.09.30.19.42.44;  author hal;  state Exp;
branches ;
next     3.1;

3.1
date     86.09.01.11.53.40;  author hal;  state Exp;
branches ;
next     2.1;

2.1
date     86.07.30.14.39.32;  author hal;  state Exp;
branches ;
next     1.1;

1.1
date     86.06.30.14.49.49;  author danm;  state tmp;
branches ;
next     ;


desc
@Base file for PWS 3.2 release.

@


56.3
log
@
pws2rcs automatic delta on Wed Jan 27 13:14:25 MST 1993
@
text
@					       (*

 (c) Copyright Hewlett-Packard Company, 1984.
All rights are reserved.  Copying or other
reproduction of this program except for archival
purposes is prohibited without the prior
written consent of Hewlett-Packard Company.


	    RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government
is subject to restrictions as set forth in
paragraph (b) (3) (B) of the Rights in Technical
Data and Computer Software clause in
DAR 7-104.9(a).

HEWLETT-PACKARD COMPANY
Fort Collins, Colorado                         *)


$modcal$
$heap_dispose off$
$iocheck off$
$range off$ $ovflcheck off$
$stackcheck off$
$search  'INITLOAD','ASM','INIT','SYSDEVS'$
$ALLOW_PACKED ON$  { 4/10/85 JWS }

program initcrtb;


module crtb;
import sysglobals, asm, misc, sysdevs;
export

function gatorcrttype: boolean;

implement

const


  environc=environ[miscinfo:crtfrec[
				    nobreak:false,
				    stupid :false,
				    slowterm:false,
				    hasxycrt:true,
				    haslccrt:FALSE,  {INDICATES BITMAP}
				    hasclock:true,
				    canupscroll:true,
				    candownscroll:true],
		   crttype:0,
		   crtctrl:crtcrec[
				    rlf:chr(31),
				    ndfs:chr(28),
				    eraseeol:chr(9),
				    eraseeos:chr(11),
				    home:chr(1),
				    escape:chr(0),
				    backspace:chr(8),
				    fillcount:10,
				    clearscreen:chr(0),
				    clearline:chr(0),
				    prefixed:b9[9 of false]],
		   crtinfo:crtirec[
				    width :128,height:47,
				    crtmemaddr:0,
				    crtcontroladdr:0,
				    keybufferaddr: 0,
				    progstateinfoaddr: 0,
				    keybuffersize: 119,
				    crtcon: crtconsttype [ 0, 0, 0, 0, 0, 0, 0,
							   0,0, 0, 0,0],
				    right{FS}:chr(28),
				    left{BS}:chr(8),
				    down{LF}:chr(10),    up{US}:chr(31),
				    badch{?}:chr(63),
				    chardel{BS}:chr(8),stop{DC3} :chr(19),
				    break{DLE}:chr(16),
				    flush{ACK}:chr(6),  eof{ETX}:chr(3),
				    altmode{ESC}:chr(27),
				    linedel{DEL}:chr(127),
				    backspace{BS}:chr(8),
				    etx:chr(3),prefix:chr(0),
				    prefixed:b14[14 of false],
				    cursormask : 0,     spare : 0]];




type

scrtype = packed array[0..maxint] of crtword;
scrptr=^scrtype;


crtregtype = 0..15;
crtcmdwrd = packed record case integer of
		0: (topbyte, botbyte: byte);
		1: (longword: shortint);
		2: (p1,p2, textfield, softfield: boolean);
	      end;


var

cursoraddr: integer;
screenwidth: shortint;
screenheight:shortint;
maxx: shortint;
maxy: shortint;
screensize:shortint;
defaulthighlight: shortint;
highlight: shortint;


procedure  cchar(c,x,y:shortint);external;
procedure  changecursor; external;
procedure  cscrollup;external;
procedure  cscrolldown;external;
procedure  cclear(x,y,n:shortint);external;
procedure  cupdatecursor(x,y:shortint);external;
procedure  cbuildtable;external;
procedure  cshiftleft; external;
procedure  cshiftright; external;
procedure  cexchange( savearea: windowp; ymin, ymax, xmin, width: shortint);
	   external;
procedure  cscrollwindow( ymin, ymax, xmin, width: shortint); external;
procedure  cscrollwinddn( ymin, ymax, xmin, width: shortint); external;
procedure  cdbscrolll( ymin, ymax, xmin, width: shortint); external;
procedure  cdbscrollr( ymin, ymax, xmin, width: shortint); external;
procedure  cdbhighl( c, x, y: shortint); external;

procedure dumpg ;


label 1;

const
  gwidthb = 128;
  gmaxheight = 512;
  gbuffersize = gwidthb + 7;

type
  gbyte = 0..255;
  row_def = packed array [0..(1024*768)-1] of gbyte;

var
  row : ^row_def;

  gbuffer : packed array [1..gbuffersize] of char;
  i,j : integer;
  index : integer;
  bit_mask : integer;
  result : integer;

begin

  row := anyptr(frameaddr);

  write(gfiles[4]^,#27'*rA');   { initiate graphics sequence }

  gbuffer[1] := chr(27); { escape sequence for graphics }
  gbuffer[2] := '*';
  gbuffer[3] := 'b';
  gbuffer[4] := '1';
  gbuffer[5] := '2';
  gbuffer[6] := '8';
  gbuffer[7] := 'W';

  for j := 0 to 767 do
    begin
      for i := 0 to 127 do
	begin
	  result := 0;
	  index := j*1024+i*8;
	  bit_mask := 256;
	  for index := index to index+7 do
	    begin
	      bit_mask := bit_mask div 2;
	      if odd(row^[index])  then result := bit_mask+result;
	    end;
	  gbuffer[i+8] := chr(result);
	end;
	write(gfiles[4]^,gbuffer:gwidthb+7);
	if ioresult <> ord(inoerror) then goto 1;
    end;

  write(gfiles[4]^,#27'*rB');   { terminate graphics sequence }
1:
end;




procedure doupdatecursor;
var cursaddr: crtcmdwrd;
begin
  cupdatecursor(xpos,ypos);
end;

procedure getxy(var x,y: integer);
begin
x := xpos;      y := ypos;
end;

procedure setxy(x, y: shortint);
begin
  if x>=screenwidth then xpos:=maxx
  else if x<0 then xpos:=0
  else xpos := x;
  if y>=screenheight then ypos:=maxy
  else if y<0 then ypos:=0
  else ypos := y;
end;

procedure gotoxy(x,y: integer);
begin
  setxy(x,y);
  doupdatecursor;
end;


procedure clear(number: shortint);  { REVISED FOR 3.01 }
var x,y: shortint;
    clearchars: shortint;
begin
  x:=xpos; y:=ypos;
  while number>0 do begin
    if maxx-x+1<number then
      clearchars:=maxx-x+1
    else
      clearchars:=number;
    cclear(x,y,clearchars);
    number:=number-clearchars;
    x:=0; if y<maxy then y:=y+1;
  end;
end;

procedure scrollup;
begin
  cscrollup;
end;

procedure scrolldown;{new  4/30/81}
begin
  cscrolldown;
end;


function maptocrt(c:char):shortint;

{ Converts Katakana codes to their correct CRT font storage  codes.
  Note that the Yen symbol overlays the USASCII backslash (\). }
procedure mapkanatocrt ;
const
  yenromlocation = 188; { location of Yen symbol in font storage }
  yencode=92;
begin
    if ord(c) = yencode then maptocrt := yenromlocation
    else if ord(c)<128 then maptocrt:=ord(c)
	   else maptocrt:= ord(c)+128;
end; { mapkanatocrt }

begin
  if kbdlang = katakana_kbd then mapkanatocrt
  else maptocrt:=ord(c);
end;



procedure docrtio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
var c: char;
    s: string[1];
    buf: charptr;
begin
 ioresult := ord(inoerror);
 buf := addr(buffer);
 case request of
  {uwait: ;              }
  setcursor: gotoxy(fp^.fxpos, fp^.fypos);
  getcursor: getxy (fp^.fxpos, fp^.fypos);
  flush:  {do nothing};
  unitstatus:  kbdio(fp, request, buffer, length, position);
  clearunit: highlight := defaulthighlight;
  readtoeol:
    begin
    buf := addr(buf^, 1);
    buffer[0] := chr(0);
    while length>0 do
      begin
      kbdio(fp, readtoeol,  s, 1, 0);
      if      strlen(s)=0     then length := 0
    { else if s[1] = chr(etx) then length := 0 }
      else  begin
	    length := length - 1;
	    crtio(fp, writebytes, s[1], 1, 0);
	    buf := addr(buf^, 1);
	    buffer[0] := chr(ord(buffer[0])+1);
	    end;
      end;
    end;
  startread,
  readbytes:
    begin
    while length>0 do
      begin
      kbdio(fp, readbytes,  buf^, 1, 0);
      if buf^ = chr(etx) then length := 0
			 else length := length - 1;
      if buf^ = eol then crtio(fp, writeeol,   buf^, 1, 0)
		    else crtio(fp, writebytes, buf^, 1, 0);
      buf := addr(buf^, 1);
      end;
    if request = startread then call(fp^.feot, fp);
    end;
  writeeol:   begin
		if ypos=maxy then scrollup;
		gotoxy(0, ypos+1);

	      end;
  startwrite,
  writebytes:
    begin
    while length>0 do
     begin
       c:=buf^; buf:=addr(buf^,1); length:=length-1;

       case c of
       homechar:   setxy(0,0);
       leftchar:   if (xpos = 0) and (ypos>0) then setxy(maxx, ypos-1)
		   else setxy(xpos-1, ypos);
       rightchar:  if (xpos = maxx) and (ypos<maxy) then setxy(0, ypos+1)
		   else setxy(xpos+1, ypos);
       upchar:     begin if ypos <= 1  then scrolldown;
			 if ypos>0 then setxy(xpos, ypos-1);
		   end;
       downchar:   if ypos=maxy then scrollup
		   else setxy(xpos, ypos+1);
       bellchar:   beep;
       cteos:     clear(screensize-(ypos*screenwidth+xpos));
       cteol:     clear(screenwidth-xpos);
       clearscr:  begin setxy(0,0); clear(screensize); end;
       eol:       setxy(0, ypos);
       chr(etx):   length:=0;
       otherwise   if (ord(c)>=128) and (ord(c)<144) then
		     highlight:= (ord(c)-128)*256
		   else
		     begin
		      changecursor;
		      cchar(maptocrt(c),xpos,ypos);
		      changecursor;
		      if xpos = maxx then
			begin
			  if ypos = maxy then scrollup;
			  setxy(0, ypos+1);
			end
		      else setxy(xpos+1, ypos);
		     end;
       end;
     doupdatecursor;
     end; {while}
    if request = startwrite then call(fp^.feot, fp);
    end;
  otherwise ioresult := ord(ibadrequest);
 end; {case}
end;

procedure lineops(op: crtllops; anyvar position: integer; c: char);

var i,j: shortint;
    sptr: ^string255;

begin

j:=highlight; highlight:=defaulthighlight;

case op of

  cllput: cchar(maptocrt(c), position, screenheight);

  cllshiftl:
     begin
       cshiftleft;
       cchar(ord(' '), maxx-8, screenheight);
     end;

  cllshiftr:
     begin
       cshiftright;
       cchar(ord(' '), 0, screenheight);
     end;

  cllclear: cclear(0, screenheight, maxx-7);

  clldisplay:
     begin
       sptr:=addr(position);
       for i:=1 to strlen(sptr^) do
	 cchar(maptocrt(sptr^[i]), i-1, screenheight);
       for i:=strlen(sptr^) to (maxx-8) do
	 cchar(ord(' '), i, screenheight);
     end;

  putstatus:  cchar(ord(c), maxx-7+position, screenheight);

end; { of case }
highlight:=j;

end;

procedure crtdebug(op: dbcrtops; var dbrec: dbcinfo);

type
  iptr = ^iarray;
  iarray = array[0..maxint] of shortint;

var i: shortint;
    j: integer;
    tempaddr: integer;

begin
with dbrec do begin
  case op of

    dbinfo: savesize:=(xmax-xmin+1)*(ymax-ymin+1)*128; {assumes 8x14 char}

    dbgotoxy: cupdatecursor(cursx, cursy);

    dbscrollup: cscrollwindow( ymin, ymax, xmin, xmax-xmin+1);

    dbscrolldn: cscrollwinddn(ymin, ymax, xmin, xmax-xmin+1);

    dbscrolll: begin
		 cdbscrolll(ymin, ymax, xmin, xmax-xmin+1);
		 changecursor;
		 for i:=ymin to ymax do
		   cchar (ord(' '), xmax, i);
		 changecursor;
	       end;

    dbscrollr: begin
		 cdbscrollr(ymin, ymax, xmin, xmax-xmin+1);
		 changecursor;
		 for i:=ymin to ymax do
		   cchar (ord(' '), xmin, i);
		 changecursor;
	       end;

    dbhighl:  cdbhighl( ord(c), cursx, cursy);

    dbput: begin
	     changecursor;
	     i:=highlight; highlight:=debughighlight;
	     if charismapped then                  {3/25/85}
	       cchar( maptocrt(c), cursx, cursy)   {3/25/85}
	     else                                  {3/25/85}
	       cchar( ord(c), cursx, cursy);
	     highlight:=i;
	     changecursor;
	   end;


    dbclear:
      for i:=ymin to ymax do
	cclear( xmin, i, xmax-xmin+1);

    dbcline: cclear( cursx, cursy, xmax-cursx+1);

    dbinit:
      begin
	for j:= 0 to (savesize div 2)-1 do
	  iptr(savearea)^[j]:=0;
	cursx:=xmin; cursy:=ymin;
	dcursoraddr:=frameaddr;
	areaisdbcrt:=true;
	charismapped:=false;
	debughighlight:=0;
      end;

    dbexcg:
      begin
	changecursor;
	cexchange( savearea, ymin, ymax, xmin, (xmax-xmin+1)*8);
	tempaddr:=cursoraddr;
	cursoraddr:=dcursoraddr;
	dcursoraddr:=tempaddr;
	changecursor;
	areaisdbcrt:=not areaisdbcrt;
      end;


  end; { of case }
end; { of with }
end; { crtdebug procedure }

procedure dummy;
begin end;


procedure gatorcrtinit;
 var i: shortint;

 begin
 idle:=245;                          { set io char to roman8 value }
 with syscom^.crtinfo do begin
   screenwidth:=width;
   screenheight:=height;
   maxx:=screenwidth-1;
   maxy:=screenheight-1;
   screensize:=screenwidth*screenheight;
   cbuildtable;
   highlight:=0; defaulthighlight:=0;
   gotoxy(0,0);
   dumpalphahook := dumpg;
   dumpgraphicshook := dumpg;
   updatecursorhook:=doupdatecursor;
   dbcrthook:=crtdebug;
   crtllhook:=lineops;
   crtiohook:=docrtio;
   crtinithook:=gatorcrtinit;
   togglealphahook:=dummy;
   togglegraphicshook:=dummy;
   currentcrt:=bitmaptype;
   keybuffer^.maxsize:=maxx-8;
end;
end;



function gatorcrttype:boolean;
const gatorid=25;
var ptr: ^shortint;
    i: shortint;
    dummy: shortint;
    found: boolean;


begin

found:=false;
ptr:=anyptr(hex('560000'));

try
  dummy:=ptr^;
  if (dummy mod 128) = gatorid then begin
    found:=true; bitmapaddr:=integer(ptr);
  end;
recover
  if escapecode<>-12 then escape(escapecode);


gatorcrttype:=found;

if  found  then begin
  syscom^:=environc;
  gatorcrtinit;
end;

end;





end;  { of module -- I hope }

import crtb, loader;

begin
  if gatorcrttype then markuser;
end.

@


56.2
log
@
pws2rcs automatic delta on Wed Jan 27 11:57:27 MST 1993
@
text
@d1 575
@


56.1
log
@Automatic bump of revision number for PWS version 3.25
@
text
@a0 575
					       (*

 (c) Copyright Hewlett-Packard Company, 1984.
All rights are reserved.  Copying or other
reproduction of this program except for archival
purposes is prohibited without the prior
written consent of Hewlett-Packard Company.


	    RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the Government
is subject to restrictions as set forth in
paragraph (b) (3) (B) of the Rights in Technical
Data and Computer Software clause in
DAR 7-104.9(a).

HEWLETT-PACKARD COMPANY
Fort Collins, Colorado                         *)


$modcal$
$heap_dispose off$
$iocheck off$
$range off$ $ovflcheck off$
$stackcheck off$
$search  'INITLOAD','ASM','INIT','SYSDEVS'$
$ALLOW_PACKED ON$  { 4/10/85 JWS }

program initcrtb;


module crtb;
import sysglobals, asm, misc, sysdevs;
export

function gatorcrttype: boolean;

implement

const


  environc=environ[miscinfo:crtfrec[
				    nobreak:false,
				    stupid :false,
				    slowterm:false,
				    hasxycrt:true,
				    haslccrt:FALSE,  {INDICATES BITMAP}
				    hasclock:true,
				    canupscroll:true,
				    candownscroll:true],
		   crttype:0,
		   crtctrl:crtcrec[
				    rlf:chr(31),
				    ndfs:chr(28),
				    eraseeol:chr(9),
				    eraseeos:chr(11),
				    home:chr(1),
				    escape:chr(0),
				    backspace:chr(8),
				    fillcount:10,
				    clearscreen:chr(0),
				    clearline:chr(0),
				    prefixed:b9[9 of false]],
		   crtinfo:crtirec[
				    width :128,height:47,
				    crtmemaddr:0,
				    crtcontroladdr:0,
				    keybufferaddr: 0,
				    progstateinfoaddr: 0,
				    keybuffersize: 119,
				    crtcon: crtconsttype [ 0, 0, 0, 0, 0, 0, 0,
							   0,0, 0, 0,0],
				    right{FS}:chr(28),
				    left{BS}:chr(8),
				    down{LF}:chr(10),    up{US}:chr(31),
				    badch{?}:chr(63),
				    chardel{BS}:chr(8),stop{DC3} :chr(19),
				    break{DLE}:chr(16),
				    flush{ACK}:chr(6),  eof{ETX}:chr(3),
				    altmode{ESC}:chr(27),
				    linedel{DEL}:chr(127),
				    backspace{BS}:chr(8),
				    etx:chr(3),prefix:chr(0),
				    prefixed:b14[14 of false],
				    cursormask : 0,     spare : 0]];




type

scrtype = packed array[0..maxint] of crtword;
scrptr=^scrtype;


crtregtype = 0..15;
crtcmdwrd = packed record case integer of
		0: (topbyte, botbyte: byte);
		1: (longword: shortint);
		2: (p1,p2, textfield, softfield: boolean);
	      end;


var

cursoraddr: integer;
screenwidth: shortint;
screenheight:shortint;
maxx: shortint;
maxy: shortint;
screensize:shortint;
defaulthighlight: shortint;
highlight: shortint;


procedure  cchar(c,x,y:shortint);external;
procedure  changecursor; external;
procedure  cscrollup;external;
procedure  cscrolldown;external;
procedure  cclear(x,y,n:shortint);external;
procedure  cupdatecursor(x,y:shortint);external;
procedure  cbuildtable;external;
procedure  cshiftleft; external;
procedure  cshiftright; external;
procedure  cexchange( savearea: windowp; ymin, ymax, xmin, width: shortint);
	   external;
procedure  cscrollwindow( ymin, ymax, xmin, width: shortint); external;
procedure  cscrollwinddn( ymin, ymax, xmin, width: shortint); external;
procedure  cdbscrolll( ymin, ymax, xmin, width: shortint); external;
procedure  cdbscrollr( ymin, ymax, xmin, width: shortint); external;
procedure  cdbhighl( c, x, y: shortint); external;

procedure dumpg ;


label 1;

const
  gwidthb = 128;
  gmaxheight = 512;
  gbuffersize = gwidthb + 7;

type
  gbyte = 0..255;
  row_def = packed array [0..(1024*768)-1] of gbyte;

var
  row : ^row_def;

  gbuffer : packed array [1..gbuffersize] of char;
  i,j : integer;
  index : integer;
  bit_mask : integer;
  result : integer;

begin

  row := anyptr(frameaddr);

  write(gfiles[4]^,#27'*rA');   { initiate graphics sequence }

  gbuffer[1] := chr(27); { escape sequence for graphics }
  gbuffer[2] := '*';
  gbuffer[3] := 'b';
  gbuffer[4] := '1';
  gbuffer[5] := '2';
  gbuffer[6] := '8';
  gbuffer[7] := 'W';

  for j := 0 to 767 do
    begin
      for i := 0 to 127 do
	begin
	  result := 0;
	  index := j*1024+i*8;
	  bit_mask := 256;
	  for index := index to index+7 do
	    begin
	      bit_mask := bit_mask div 2;
	      if odd(row^[index])  then result := bit_mask+result;
	    end;
	  gbuffer[i+8] := chr(result);
	end;
	write(gfiles[4]^,gbuffer:gwidthb+7);
	if ioresult <> ord(inoerror) then goto 1;
    end;

  write(gfiles[4]^,#27'*rB');   { terminate graphics sequence }
1:
end;




procedure doupdatecursor;
var cursaddr: crtcmdwrd;
begin
  cupdatecursor(xpos,ypos);
end;

procedure getxy(var x,y: integer);
begin
x := xpos;      y := ypos;
end;

procedure setxy(x, y: shortint);
begin
  if x>=screenwidth then xpos:=maxx
  else if x<0 then xpos:=0
  else xpos := x;
  if y>=screenheight then ypos:=maxy
  else if y<0 then ypos:=0
  else ypos := y;
end;

procedure gotoxy(x,y: integer);
begin
  setxy(x,y);
  doupdatecursor;
end;


procedure clear(number: shortint);  { REVISED FOR 3.01 }
var x,y: shortint;
    clearchars: shortint;
begin
  x:=xpos; y:=ypos;
  while number>0 do begin
    if maxx-x+1<number then
      clearchars:=maxx-x+1
    else
      clearchars:=number;
    cclear(x,y,clearchars);
    number:=number-clearchars;
    x:=0; if y<maxy then y:=y+1;
  end;
end;

procedure scrollup;
begin
  cscrollup;
end;

procedure scrolldown;{new  4/30/81}
begin
  cscrolldown;
end;


function maptocrt(c:char):shortint;

{ Converts Katakana codes to their correct CRT font storage  codes.
  Note that the Yen symbol overlays the USASCII backslash (\). }
procedure mapkanatocrt ;
const
  yenromlocation = 188; { location of Yen symbol in font storage }
  yencode=92;
begin
    if ord(c) = yencode then maptocrt := yenromlocation
    else if ord(c)<128 then maptocrt:=ord(c)
	   else maptocrt:= ord(c)+128;
end; { mapkanatocrt }

begin
  if kbdlang = katakana_kbd then mapkanatocrt
  else maptocrt:=ord(c);
end;



procedure docrtio(fp: fibp; request: amrequesttype; anyvar buffer: window;
						   length, position: integer);
var c: char;
    s: string[1];
    buf: charptr;
begin
 ioresult := ord(inoerror);
 buf := addr(buffer);
 case request of
  {uwait: ;              }
  setcursor: gotoxy(fp^.fxpos, fp^.fypos);
  getcursor: getxy (fp^.fxpos, fp^.fypos);
  flush:  {do nothing};
  unitstatus:  kbdio(fp, request, buffer, length, position);
  clearunit: highlight := defaulthighlight;
  readtoeol:
    begin
    buf := addr(buf^, 1);
    buffer[0] := chr(0);
    while length>0 do
      begin
      kbdio(fp, readtoeol,  s, 1, 0);
      if      strlen(s)=0     then length := 0
    { else if s[1] = chr(etx) then length := 0 }
      else  begin
	    length := length - 1;
	    crtio(fp, writebytes, s[1], 1, 0);
	    buf := addr(buf^, 1);
	    buffer[0] := chr(ord(buffer[0])+1);
	    end;
      end;
    end;
  startread,
  readbytes:
    begin
    while length>0 do
      begin
      kbdio(fp, readbytes,  buf^, 1, 0);
      if buf^ = chr(etx) then length := 0
			 else length := length - 1;
      if buf^ = eol then crtio(fp, writeeol,   buf^, 1, 0)
		    else crtio(fp, writebytes, buf^, 1, 0);
      buf := addr(buf^, 1);
      end;
    if request = startread then call(fp^.feot, fp);
    end;
  writeeol:   begin
		if ypos=maxy then scrollup;
		gotoxy(0, ypos+1);

	      end;
  startwrite,
  writebytes:
    begin
    while length>0 do
     begin
       c:=buf^; buf:=addr(buf^,1); length:=length-1;

       case c of
       homechar:   setxy(0,0);
       leftchar:   if (xpos = 0) and (ypos>0) then setxy(maxx, ypos-1)
		   else setxy(xpos-1, ypos);
       rightchar:  if (xpos = maxx) and (ypos<maxy) then setxy(0, ypos+1)
		   else setxy(xpos+1, ypos);
       upchar:     begin if ypos <= 1  then scrolldown;
			 if ypos>0 then setxy(xpos, ypos-1);
		   end;
       downchar:   if ypos=maxy then scrollup
		   else setxy(xpos, ypos+1);
       bellchar:   beep;
       cteos:     clear(screensize-(ypos*screenwidth+xpos));
       cteol:     clear(screenwidth-xpos);
       clearscr:  begin setxy(0,0); clear(screensize); end;
       eol:       setxy(0, ypos);
       chr(etx):   length:=0;
       otherwise   if (ord(c)>=128) and (ord(c)<144) then
		     highlight:= (ord(c)-128)*256
		   else
		     begin
		      changecursor;
		      cchar(maptocrt(c),xpos,ypos);
		      changecursor;
		      if xpos = maxx then
			begin
			  if ypos = maxy then scrollup;
			  setxy(0, ypos+1);
			end
		      else setxy(xpos+1, ypos);
		     end;
       end;
     doupdatecursor;
     end; {while}
    if request = startwrite then call(fp^.feot, fp);
    end;
  otherwise ioresult := ord(ibadrequest);
 end; {case}
end;

procedure lineops(op: crtllops; anyvar position: integer; c: char);

var i,j: shortint;
    sptr: ^string255;

begin

j:=highlight; highlight:=defaulthighlight;

case op of

  cllput: cchar(maptocrt(c), position, screenheight);

  cllshiftl:
     begin
       cshiftleft;
       cchar(ord(' '), maxx-8, screenheight);
     end;

  cllshiftr:
     begin
       cshiftright;
       cchar(ord(' '), 0, screenheight);
     end;

  cllclear: cclear(0, screenheight, maxx-7);

  clldisplay:
     begin
       sptr:=addr(position);
       for i:=1 to strlen(sptr^) do
	 cchar(maptocrt(sptr^[i]), i-1, screenheight);
       for i:=strlen(sptr^) to (maxx-8) do
	 cchar(ord(' '), i, screenheight);
     end;

  putstatus:  cchar(ord(c), maxx-7+position, screenheight);

end; { of case }
highlight:=j;

end;

procedure crtdebug(op: dbcrtops; var dbrec: dbcinfo);

type
  iptr = ^iarray;
  iarray = array[0..maxint] of shortint;

var i: shortint;
    j: integer;
    tempaddr: integer;

begin
with dbrec do begin
  case op of

    dbinfo: savesize:=(xmax-xmin+1)*(ymax-ymin+1)*128; {assumes 8x14 char}

    dbgotoxy: cupdatecursor(cursx, cursy);

    dbscrollup: cscrollwindow( ymin, ymax, xmin, xmax-xmin+1);

    dbscrolldn: cscrollwinddn(ymin, ymax, xmin, xmax-xmin+1);

    dbscrolll: begin
		 cdbscrolll(ymin, ymax, xmin, xmax-xmin+1);
		 changecursor;
		 for i:=ymin to ymax do
		   cchar (ord(' '), xmax, i);
		 changecursor;
	       end;

    dbscrollr: begin
		 cdbscrollr(ymin, ymax, xmin, xmax-xmin+1);
		 changecursor;
		 for i:=ymin to ymax do
		   cchar (ord(' '), xmin, i);
		 changecursor;
	       end;

    dbhighl:  cdbhighl( ord(c), cursx, cursy);

    dbput: begin
	     changecursor;
	     i:=highlight; highlight:=debughighlight;
	     if charismapped then                  {3/25/85}
	       cchar( maptocrt(c), cursx, cursy)   {3/25/85}
	     else                                  {3/25/85}
	       cchar( ord(c), cursx, cursy);
	     highlight:=i;
	     changecursor;
	   end;


    dbclear:
      for i:=ymin to ymax do
	cclear( xmin, i, xmax-xmin+1);

    dbcline: cclear( cursx, cursy, xmax-cursx+1);

    dbinit:
      begin
	for j:= 0 to (savesize div 2)-1 do
	  iptr(savearea)^[j]:=0;
	cursx:=xmin; cursy:=ymin;
	dcursoraddr:=frameaddr;
	areaisdbcrt:=true;
	charismapped:=false;
	debughighlight:=0;
      end;

    dbexcg:
      begin
	changecursor;
	cexchange( savearea, ymin, ymax, xmin, (xmax-xmin+1)*8);
	tempaddr:=cursoraddr;
	cursoraddr:=dcursoraddr;
	dcursoraddr:=tempaddr;
	changecursor;
	areaisdbcrt:=not areaisdbcrt;
      end;


  end; { of case }
end; { of with }
end; { crtdebug procedure }

procedure dummy;
begin end;


procedure gatorcrtinit;
 var i: shortint;

 begin
 idle:=245;                          { set io char to roman8 value }
 with syscom^.crtinfo do begin
   screenwidth:=width;
   screenheight:=height;
   maxx:=screenwidth-1;
   maxy:=screenheight-1;
   screensize:=screenwidth*screenheight;
   cbuildtable;
   highlight:=0; defaulthighlight:=0;
   gotoxy(0,0);
   dumpalphahook := dumpg;
   dumpgraphicshook := dumpg;
   updatecursorhook:=doupdatecursor;
   dbcrthook:=crtdebug;
   crtllhook:=lineops;
   crtiohook:=docrtio;
   crtinithook:=gatorcrtinit;
   togglealphahook:=dummy;
   togglegraphicshook:=dummy;
   currentcrt:=bitmaptype;
   keybuffer^.maxsize:=maxx-8;
end;
end;



function gatorcrttype:boolean;
const gatorid=25;
var ptr: ^shortint;
    i: shortint;
    dummy: shortint;
    found: boolean;


begin

found:=false;
ptr:=anyptr(hex('560000'));

try
  dummy:=ptr^;
  if (dummy mod 128) = gatorid then begin
    found:=true; bitmapaddr:=integer(ptr);
  end;
recover
  if escapecode<>-12 then escape(escapecode);


gatorcrttype:=found;

if  found  then begin
  syscom^:=environc;
  gatorcrtinit;
end;

end;





end;  { of module -- I hope }

import crtb, loader;

begin
  if gatorcrttype then markuser;
end.

@


55.1
log
@Automatic bump of revision number for PWS version 3.25A
@
text
@@


54.1
log
@Automatic bump of revision number for PWS version 3.24
@
text
@@


53.1
log
@Automatic bump of revision number for PWS version 3.24B
@
text
@@


52.1
log
@Automatic bump of revision number for PWS version 3.24A
@
text
@@


51.1
log
@Automatic bump of revision number for PWS version 3.24d
@
text
@@


50.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


49.1
log
@Automatic bump of revision number for PWS version 3.24b
@
text
@@


48.1
log
@Automatic bump of revision number for PWS version 3.24a
@
text
@@


47.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


46.1
log
@Automatic bump of revision number for PWS version 3.23
@
text
@@


45.1
log
@Automatic bump of revision number for PWS version 3.23C
@
text
@@


44.1
log
@Automatic bump of revision number for PWS version 3.23B
@
text
@@


43.1
log
@Automatic bump of revision number for PWS version 3.23aA
@
text
@@


42.1
log
@Automatic bump of revision number for PWS version 3.23e
@
text
@@


41.1
log
@Automatic bump of revision number for PWS version 3.23d
@
text
@@


40.1
log
@Automatic bump of revision number for PWS version 3.23c
@
text
@@


39.1
log
@Automatic bump of revision number for PWS version 3.23b
@
text
@@


38.1
log
@Automatic bump of revision number for PWS version 3.23a
@
text
@@


37.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


36.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


35.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


34.1
log
@Automatic bump of revision number for PWS version 3.22
@
text
@@


33.1
log
@Automatic bump of revision number for PWS version 3.22D
@
text
@@


32.1
log
@Automatic bump of revision number for PWS version 3.22C
@
text
@@


31.1
log
@Automatic bump of revision number for PWS version 3.22B
@
text
@@


30.1
log
@Automatic bump of revision number for PWS version 3.22A
@
text
@@


29.1
log
@Automatic bump of revision number for PWS version 3.22b
@
text
@@


28.1
log
@Automatic bump of revision number for PWS version 3.3b
@
text
@@


27.1
log
@Automatic bump of revision number for PWS version 3.3a
@
text
@@


26.1
log
@Automatic bump of revision number for PWS version 3.3 Synch
@
text
@@


25.1
log
@Automatic bump of revision number for PWS version 3.2Y
@
text
@@


24.1
log
@Automatic bump of revision number for PWS version 3.2
@
text
@@


23.1
log
@Automatic bump of revision number for PWS version 3.2P
@
text
@@


22.1
log
@Automatic bump of revision number for PWS version 3.2N
@
text
@@


21.1
log
@Automatic bump of revision number for PWS version 3.2M
@
text
@@


20.1
log
@Automatic bump of revision number for PWS version 3.2L
@
text
@@


19.1
log
@Automatic bump of revision number for PWS version 3.2K
@
text
@@


18.1
log
@Automatic bump of revision number for PWS version 3.2J
@
text
@@


17.1
log
@Automatic bump of revision number for PWS version 3.2I+
@
text
@@


16.1
log
@Automatic bump of revision number for PWS version 3.2I
@
text
@@


15.1
log
@Automatic bump of revision number for PWS version 3.2H
@
text
@@


14.1
log
@Automatic bump of revision number for PWS version 3.2G
@
text
@@


13.1
log
@Automatic bump of revision number for PWS version 3.2F
@
text
@@


12.1
log
@Automatic bump of revision number for PWS version 3.2E
@
text
@@


11.1
log
@Automatic bump of revision number for PWS version 3.2D
@
text
@@


10.1
log
@Automatic bump of revision number for PWS version 3.2C
@
text
@@


9.1
log
@Automatic bump of revision number for PWS version 3.2B
@
text
@@


8.1
log
@Automatic bump of revision number for PWS version 3.2A
@
text
@@


7.1
log
@Automatic bump of revision number for PWS version 3.2l
@
text
@@


6.1
log
@Automatic bump of revision number for PWS version 3.2k
@
text
@@


5.1
log
@Automatic bump of revision number for PWS version 3.2j
@
text
@@


4.1
log
@Automatic bump of revision number for PWS version 3.2i
@
text
@@


3.1
log
@Automatic bump of revision number for PWS version 3.2h
@
text
@@


2.1
log
@Auto bump rev number to 2.1 for sys 3.2e.
@
text
@@


1.1
log
@Initial revision
@
text
@@
