home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
153.img
/
TELES.ZIP
/
COMMON.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-07-25
|
64KB
|
2,267 lines
{$I-} { I/O hecking OFF }
{$R-} { Range checking OFF }
{$S-} { Stack checking OFF }
{$V-} { Var-str checking OFF}
{$B+} {Boolean complete evaluation on}
{$N-} {No numeric coprocessor}
Unit Common;
Interface
Uses
Crt,
Dos,
Turbo3;
{ global declarations for Async}
type
astr = String[160]; { generic string type for parameters }
{ note the change from Waynes str => Astr }
const
buffer_max = 5120;
var
Async_OriginalVector : pointer;
buffer : Array[0..buffer_max] of char;
Async_Open_Flag : Boolean; { true if Open but no Close }
Async_Port : Integer; { current Open port number (1 or 2) }
base : Integer; { base for current open port }
Async_Irq : Integer; { irq for current open port }
Async_Buffer_Overflow : Boolean; { True if buffer overflow has happened }
Async_Buffer_Used : Integer;
Async_MaxBufferUsed : Integer;
{ buffer is empty if Head = Tail }
Buffer_head : Integer; { Locn in buffer to put next char }
Buffer_tail : Integer; { Locn in buffer to get next char }
Buffer_newtail : Integer;
{ End of Async declarations }
CONST strlen=160;
maxusers=500;
dsaves : Integer = 0;
TYPE restrictions=(rlogon,rchat,rvalidate,rbackspace,ramsg,rpostan,
rpost,remail,rvoting,rmsg);
acrq='@'..'G';
newtyp=(rp,lt,rm);
deflts=(spcsr,onekey,wordwrap,pause,mmnu,ansi,color,music);
pnr=record name:string[40]; number:string[14]; hs:byte; end;
anontyp=(no,yes,forced,dearabby);
ansttype=(postn,emailn,pana,sanm,cosysop,lcosysop);
opts=(alert,smw,nomail);
dlnscan=set of 0..39;
emary=array[1..20] of integer;
clrs=array[false..true,0..9] of byte;
slr=record
ttime:byte;
mallowed:integer;
emails,posts:byte;
anst:set of ansttype;
end;
messages=record
ltr:char;
number:integer;
ext:byte;
end;
smalrec=record
name:string[25];
number:integer;
end;
userrec=record
name:string[21];
realname:string[21];
deleted:boolean;
pw:string[20];
ph:string[12];
waiting:byte;
laston:string[10];
loggedon:integer;
msgpost:integer;
emailsent:integer;
feedback:integer;
linelen:byte;
pagelen:byte;
defaults:set of deflts;
ontoday:byte;
illegal:byte;
ttimeon:real;
dlnscn:dlnscan;
sl:byte;
ac:set of restrictions;
ar:set of acrq;
qscan:array[1..39] of messages;
qscn:array[1..39] of boolean;
macro:array[1..2] of string[79];
comptype:byte;
option:set of opts;
vote:array[1..20] of byte;
sbn:byte;
dsl:byte;
uploads,downloads:integer;
uk,dk:integer;
age:byte;
sex:char;
note:string[39];
forusr:integer;
res:array[1..70] of byte; (* Res[1] will be last msg base *)
filepoints:integer;
citystate:string[26];
street:string[21];
zipcode:string[10];
occupation:string[40];
wherebbs:string[40];
lockedout:boolean;
lockedfile:string[8];
computer:string[14];
cols:clrs;
end;
boardrec=record
name:string[30];
filename:string[12];
sl:byte;
maxmsgs:byte;
pw:string[10];
anonymous:anontyp;
ar:acrq;
key:char;
postsl:byte;
end;
msgstat=(validated,unvalidated,deleted);
messagerec=record
title:string[30];
messagestat:msgstat;
message:messages;
owner:integer;
date:integer;
mage:byte;
end;
systatrec=record
boardpw:string[20];
sysoppw:string[20];
hmsg:messages;
users:integer;
lastdate:string[8];
callernum:integer;
activetoday:integer;
callstoday:integer;
msgposttoday:integer;
emailtoday:integer;
fbacktoday:integer;
uptoday:integer;
closedsystem:boolean;
comport:byte;
maxbaud:integer;
msgpath:string[79];
gfiledate:string[8];
lowtime,hitime:integer;
res:array[1..185] of byte;
sysopcolor:byte;
usercolor:byte;
maxlines:byte;
special:boolean;
clearmsg:boolean;
bbspw:string[20];
matrix:boolean;
engage:string[79];
endchat:string[79];
alias:boolean;
echoc:char;
sysopin:string[79];
sysopout:string[79];
note:array[1..2] of string[79];
lprompt:string[40];
lansi:boolean;
init:string[40];
wait:string[79];
app:boolean;
fone:boolean;
sysopmacro:array[1..9] of string[72];
forcevoting:boolean;
multitask:boolean;
gfilepath:string[79];
pause:string[79];
hangup:string[40];
answer:string[40];
result300:integer;
result1200:integer;
result2400:integer;
nocarrier:integer;
tries:byte;
newsl:byte;
newdsl:byte;
newar:set of acrq;
newac:set of restrictions;
newfp:integer;
newuk:integer;
bwindow:boolean;
bsdelay:byte;
mcimsg:boolean;
b300lowtime,b300hitime:integer;
dllowtime,dlhitime:integer;
b300dllowtime,b300dlhitime:integer;
lock300:boolean;
result4800:integer;
result9600:integer;
SysopFirst:String[12];
SysopLast:String[16];
BBSName:String[40];
BBSPhone:String[12];
ANSIq:String[40];
WantQuote:Boolean;
Menupath:string[79];
autosl:byte;
autodsl:byte;
autoar:set of acrq;
autoac:set of restrictions;
end;
blk=array[1..255] of byte;
mailrec=record
title:string[30];
from,destin:integer;
msg:messages;
date:integer;
mage:byte;
end;
gft=record
num:integer;
title:string[40];
filen:string[12];
end;
smr=record
msg:astr;
destin:integer;
end;
vdatar=record
question:string[79];
numa:integer;
answ:array[0..9] of record
ans:string[25];
numres:integer;
end;
end;
ulrec=record
name:string[25];
filename:string[12];
password:string[10];
dsl:byte;
maxfiles:integer;
key:char;
ulpath:string[39];
dlpath:string[40];
agereq:byte;
ar:acrq;
end;
ulfrec=record
filename:string[12];
description:string[60];
filepoints:integer;
res:array[1..15] of byte;
nacc:integer;
ft:byte;
blocks:integer;
owner:integer;
date:string[8];
daten:integer;
end;
strptr=^strrec;
strrec=record
i:astr;
next,last:strptr;
end;
zlogt=record
date:string[8];
active,calls,post,email,fback,up:integer;
end;
{ eventrec=record
descr:string[25];
batch:string[12];
time:integer;
end;}
{ expro=record
descr:string[30];
rcmd:string[50];
scmd:string[50];
xferok:integer;
end;}
CONST dcols:clrs=((15,7,7,15,15,15,112,7,143,7),(15,3,1,11,9,14,31,4,140,10));
var sf:file of smalrec;
uf:file of userrec;
bf:file of boardrec;
{ xp:file of expro;}
mailfile:file of mailrec;
ulf:file of ulrec;
{ uevent:array [0..9] of eventrec;
eve:file of eventrec;
ev:eventrec;}
uboards:array[0..39] of ulrec;
{ protocals:array [0..4] of expro;}
maxulb:integer;
sysopf:text{[1024]};
slf:file of slr;
seclev:array[0..255] of slr;
systatf:file of systatrec;
systat:systatrec;
sr:smalrec;
thisline,chatr,buf,spd,irt,lastname,ll,i:astr;
thisuser,user:userrec;
boards:array[1..39] of boardrec;
fw,extramsgs,mread,board,numboards,t,usernum,numprotocals:integer;
pap,lil,realsl,realdsl,ftoday,ptoday,etoday:integer;
c,ID:char;
rep,hungup,useron,next,chatcall,doneday,echo,hangup,incom,outcom:boolean;
extratime,chattime,timeon:real;
mailread,smread,macok,lan,enddayf,ch,quit,beepend:boolean;
smf:file of smr;
srl:array[0..maxusers] of smalrec;
vqu:array[1..20] of boolean;
ldate:integer;
cmd:char;
bread:byte;
bchanged:boolean;
mary:array[0..200] of messagerec;
cf:text; cfo,okt:boolean;
elevel:byte;
curco:byte;
sll:astr;
andwith:byte;
checkit:boolean;
geek:astr;
lmain:boolean;
lmsg:boolean;
windowon,entry,wantfilename,nofile,nofeed:boolean;
nopfile:boolean;
reading_a_msg,write_msg:boolean;
wantout:boolean;
wcolor:boolean;
Filv:Text;
N:Astr;
cmdl : array [1..30] of string[14];
msl : array [1..30] of byte;
cmdtype: array [1..30] of byte;
optdata: array [1..30] of integer;
optstr : array [1..30] of string[40];
noc : integer;
found : boolean;
directive,menuprompt:astr;
FILEBOARD:integer;
first_time:boolean;
ulff:file of ulfrec;
crc:integer;
doit:boolean;
sortbd,doneft:boolean;
ldat:astr;
ix:array[1..9] of string[79];
ymodem,ucrc,bnp:boolean;
c1,c2,c3:integer;
chksum:byte;
lrn:integer;
lfn:astr;
all,readingmail:boolean;
ft:byte;
ymbtt:real;
ymodemfiles:integer;
ymbindx:integer;
ymbary:array[1..20] of record
fn:string[80];
tt:real;
end;
dta:string[44];
filenamef,s1,s2,s3:astr;
donedos,dld,d1,d2,done,abort:boolean;
cd,cmdlist,start_dir,ver:astr;
returna,quitafterdone,nightly:boolean;
answerbaud:integer;
dumb,dumb2:char;
lastcaller:astr;
tim:real;
procedure sprompt(i:astr);
procedure readin;
procedure tc(n:integer);
function cs:boolean;
function so:boolean;
function timer:real;
function freek(d:integer):integer; (* See disk space *)
function lcs:boolean;
function nma:integer;
function okansi:boolean;
function commpressed : boolean;
procedure dump;
procedure cline(dd:astr); (* input cmd line *)
function nsl:real;
procedure async_isr; INTERRUPT;
function capsnam(xx:integer):astr;
procedure remove_port;
procedure term_ready(s:Boolean);
procedure set_baud(r:integer);
procedure fix_window;
procedure iport;
procedure commandline(dd:astr); (* cmd line *)
function cinkey1:char;
procedure gameport;
function cinkey:char;
procedure o1(c:char);
procedure o(c:char);
function sysop1:boolean;
procedure cursoron;
procedure cursoroff;
function checkpw:boolean;
function sysop:boolean;
procedure sl1(i:astr);
procedure sysoplog(i:astr);
function tch(i:astr):astr;
function time:astr;
function date:astr;
function value(I:astr):integer;
function cstr(i:integer):astr;
function nam:astr;
procedure sysopshell;
function leapyear(yr:integer):boolean;
function days(mo,yr:integer):integer;
function daycount(mo,yr:integer):integer;
function daynum(dt:astr):integer;
function dat:astr;
function cdet:boolean;
procedure checkhangup;
procedure getkey(var c:char);
procedure pr1(i:astr);
procedure pr(i:astr);
procedure sdc;
procedure stsc;
function xclr(c:integer):astr;
procedure setc(cl:byte);
procedure cl(c:integer);
procedure prompt(i:astr);
procedure pausescr;
procedure print(i:astr);
procedure nl;
procedure prt(i:astr);
procedure ynq(i:astr);
procedure mpl(c:integer);
procedure tleft;
procedure prestrict(u:userrec);
procedure topscr;
procedure bigwindow;
procedure smallwindow;
function empty:boolean;
{procedure skey1(var c:char);}
function inkey:char;
procedure oc(c:char);
procedure outkey(c:char);
procedure outansi(i:char);
{procedure skey(var c:char);}
procedure dm(i:astr; var c:char); (* Throw macro to the input routine *)
{procedure getkey; } (* forward function to get a single key *)
procedure cls; (*guess*)
procedure wait(b:boolean); (* Displayed when sysop is working *)
procedure chsl; (* Change Security Level *)
procedure swac(var u:userrec;r:restrictions);
procedure acch(c:char; var u:userrec);
procedure sprint(i:astr);
procedure chac(var thisuser:userrec);
procedure chbac;
procedure chdsl;
procedure tfile; (* Open/Close chat.msg *)
procedure inli1(var i:astr); (* Input routine for chat *)
function yn:boolean; (* The "YES" or "NO" routine *)
procedure input1(var i:astr; ml:integer; tf:boolean);
procedure input(var i:astr; ml:integer); (* Input uppercase only *)
procedure inputl(var i:astr; ml:integer); (* Input lower & upper case *)
procedure onek(var c:char; ch:astr); (* 1 Key example: onkey(c,'1234'); *)
procedure centre(var i:astr); (* Center I String *)
procedure wkey(var abort,next:boolean); (* See if user aborts, pauses, etc*)
function ctim(rl:real):astr;
function tlef:astr;
Procedure Print_File (fn:astr); (* print ansi file *)
procedure printa1(i:astr; var abort,next:boolean); (* Print line of text *)
procedure printa(i:astr; var abort,next:boolean);
procedure printacr(i:astr; var abort,next:boolean);
function cstrr(rl:real; base:integer):astr;
procedure savesystat; (* save systat *)
procedure pfl(fn:astr; var abort:boolean; cr:boolean);
procedure printfile(fn:astr); (* Print normal text file *)
procedure printf(fn:astr); (* See if an *.ans file is available *)
procedure chat; (*Break into chat *)
procedure skey(c:char); (* Global user keys *)
procedure skey1(c:char); (* Global sysop keys *)
procedure Async_Init;
procedure Async_Close;
Procedure Async_Open(ComPort : Integer;
BaudRate : Integer;
Parity : Char;
WordSize : Integer;
StopBits : Integer);
Implementation
const
UART_THR = $00;
UART_RBR = $00;
UART_IER = $01;
UART_IIR = $02;
UART_LCR = $03;
UART_MCR = $04;
UART_LSR = $05;
UART_MSR = $06;
I8088_IMR = $21; { port address of the Interrupt Mask Register }
var
Async_BIOS_Port_Table : Array[1..2] of Integer absolute $40:0;
const
Async_Num_Bauds = 8;
Async_Baud_Table : array [1..Async_Num_Bauds] of record
Baud, Bits : integer
end
= ((Baud:110; Bits:$00),
(Baud:150; Bits:$20),
(Baud:300; Bits:$40),
(Baud:600; Bits:$60),
(Baud:1200; Bits:$80),
(Baud:2400; Bits:$A0),
(Baud:4800; Bits:$C0),
(Baud:9600; Bits:$E0));
PROCEDURE DisableInterrupts; inline($FA {cli} ); {MACROS}
PROCEDURE EnableInterrupts; inline($FB {sti} );
procedure BIOS_RS232_Init(ComPort, ComParm : Integer);
var
Regs : registers;
begin
with Regs do
begin
ax := ComParm and $00FF; { AH=0; AL=ComParm }
dx := ComPort;
Intr($14, Regs)
end
end;
function lenn(i:astr):integer;
var x:integer; z:integer;
begin
z:=0;
for x:=1 to length(i) do begin
if i[x]='^' then x:=x+2;
z:=z+1;
end;
lenn:=z;
end;
function checkpw:boolean;
var i:astr;
begin
prompt('Sysop PW? ');
echo:=false;
input(i,20);
echo:=true;
checkpw:=(i=systat.sysoppw);
end;
Procedure CursorOn;
Var
Reg:Registers;
Begin
with reg do
begin
ch:=07; cl:=08; ah:=1;
intr($10,reg);
end;
end;
Procedure CursorOff;
Var
Reg:Registers;
Begin
with reg do
begin
ch:=09; cl:=00; ah:=1;
intr($10,reg);
end;
end;
procedure sprompt(i:astr);
var x,z:Integer; y:astr; fr:astr; xx:boolean; dum:astr; zz:astr;
begin
dum:=nam;
for x:=1 to length(i) do begin
xx:=false;
if i[x]='^' then begin
z:=value(i[x+1]);
if z in [0..9] then cl(z);
x:=x+1; xx:=true;
end;
if i[x]='@' then begin
y:=upcase(i[x+1]);
if y='A' then prompt(cstr(board));
if y='B' then prompt(boards[board].name);
if y='C' then prompt(cstr(FILEBOARD));
if y='D' then prompt(uboards[FILEBOARD].name);
if y='E' then cls;
if y='P' then prompt(cstr(thisuser.filepoints));
if y='M' then nl;
if y='N' then prompt(dum);
if y='H' then prompt(copy(dum,1,(pos('#',dum)-1)));
if y='R' then prompt(thisuser.realname);
if y='Z' then prompt(chatr);
if y='F' then begin
zz:=(copy(dum,1,(pos(' ',dum)-1)));
if zz='The' then zz:=dum;
prompt(zz);
end;
if y='V' then prompt(cmdlist);
x:=x+1; xx:=true;
end;
if not xx then prompt(i[x]);
end;
end;
procedure sprint(i:astr);
begin
sprompt(i); nl;
end;
procedure readin;
var i:integer;
begin
cmdlist:='';
noc:=0;
if first_time=false then close(filv);
if first_time=true then first_time:=false;
assign(filv,n);
{$I-} reset(filv); {$I+}
if ioresult<>0 then begin sysoplog(n+' is MISSING.'); print(n+' is MISSING. Please inform SysOp.'); hangup:=true;
end else
BEGIN
readln(filv,directive);
readln(filv,menuprompt);
repeat
noc:=noc+1;
readln(filv,cmdl[noc]);
readln(filv,msl[noc]);
readln(filv,cmdtype[noc]);
readln(filv,optdata[noc]);
readln(filv,optstr[noc]);
until (eof(filv));
FILEBOARD:=thisuser.res[2];
for i:=1 to noc do begin
if (thisuser.sl>=msl[i]) and (i<>1) then cmdlist:=cmdlist+',';
if thisuser.sl>=msl[i] then cmdlist:=cmdlist+cmdl[i];
end;
END;
end;
procedure Async_Isr; {INTERRUPT;}
begin
Inline(
$FB/ { STI }
{ get the incomming character }
{ buffer[Buffer_head] := Chr(Port[UART_RBR + base]); }
$8B/$16/base/ { MOV DX,base }
$EC/ { IN AL,DX }
$8B/$1E/Buffer_head/ { MOV BX,Buffer_head }
$88/$87/buffer/ { MOV buffer[BX],AL }
{ Async_Buffer_NewHead := Buffer_head + 1; }
$43/ { INC BX }
{ if Async_Buffer_NewHead > buffer_max then
Async_Buffer_NewHead := 0; }
$81/$FB/buffer_max/ { CMP BX,buffer_max }
$7E/$02/ { JLE L001 }
$33/$DB/ { XOR BX,BX }
{ if Async_Buffer_NewHead = Buffer_tail then
Async_Buffer_Overflow := TRUE
else }
{L001:}
$3B/$1E/Buffer_tail/ { CMP BX,Buffer_tail }
$75/$08/ { JNE L002 }
$C6/$06/Async_Buffer_Overflow/$01/ { MOV Async_Buffer_Overflow,1 }
$90/ { NOP generated by assembler for some reason }
$EB/$16/ { JMP SHORT L003 }
{ begin
Buffer_head := Async_Buffer_NewHead;
Async_Buffer_Used := Async_Buffer_Used + 1;
if Async_Buffer_Used > Async_MaxBufferUsed then
Async_MaxBufferUsed := Async_Buffer_Used
end; }
{L002:}
$89/$1E/Buffer_head/ { MOV Buffer_head,BX }
$FF/$06/Async_Buffer_Used/ { INC Async_Buffer_Used }
$8B/$1E/Async_Buffer_Used/ { MOV BX,Async_Buffer_Used }
$3B/$1E/Async_MaxBufferUsed/ { CMP BX,Async_MaxBufferUsed }
$7E/$04/ { JLE L003 }
$89/$1E/Async_MaxBufferUsed/ { MOV Async_MaxBufferUsed,BX }
{L003:}
{ disable interrupts }
$FA/ { CLI }
{ Port[$20] := $20; } { use non-specific EOI }
$B0/$20/ { MOV AL,20h }
$E6/$20 { OUT 20h,AL }
)
end; { Async_Isr }
procedure Async_Init;
begin
Async_Open_Flag := FALSE;
Async_Buffer_Overflow := FALSE;
Async_Buffer_Used := 0;
Async_MaxBufferUsed := 0;
end; { Async_Init }
procedure Async_Close;
var
i, m : Integer;
begin
if Async_Open_Flag then
begin
{ disable the IRQ on the 8259 }
DisableInterrupts;
i := Port[I8088_IMR]; { get the interrupt mask register }
m := 1 shl Async_Irq; { set mask to turn off interrupt }
Port[I8088_IMR] := i or m;
{ disable the 8250 data ready interrupt }
Port[UART_IER + base] := 0;
{ disable OUT2 on the 8250 }
Port[UART_MCR + base] := 0;
EnableInterrupts;
SetIntVec(Async_Irq + 8,Async_OriginalVector);
{ re-initialize our data areas so we know the port is closed }
Async_Open_Flag := FALSE
end
end; { Async_Close }
Procedure Async_Open(ComPort : Integer;
BaudRate : Integer;
Parity : Char;
WordSize : Integer;
StopBits : Integer);
{ open a communications port }
var
ComParm : Integer;
i, m : Integer;
begin
if Async_Open_Flag then Async_Close;
if (ComPort = 2) and (Async_BIOS_Port_Table[2] <> 0) then
Async_Port := 2
else
Async_Port := 1; { default to COM1 }
base := Async_BIOS_Port_Table[Async_Port];
Async_Irq := Hi(base) + 1;
if (Port[UART_IIR + base] and $00F8)=0
then
begin
Buffer_head := 0;
Buffer_tail := 0;
Async_Buffer_Overflow := FALSE;
{ Build the ComParm for RS232_Init }
{ See Technical Reference Manual for description }
ComParm := $0000;
{ Set up the bits for the baud rate }
i := 0;
repeat
i := i + 1
until (Async_Baud_Table[i].Baud = BaudRate) or (i = Async_Num_Bauds);
ComParm := ComParm or Async_Baud_Table[i].Bits;
if Parity in ['E', 'e'] then ComParm := ComParm or $0018
else if Parity in ['O', 'o'] then ComParm := ComParm or $0008
else ComParm := ComParm or $0000; { default to No parity }
if WordSize = 7 then ComParm := ComParm or $0002
else ComParm := ComParm or $0003; { default to 8 data bits }
if StopBits = 2 then ComParm := ComParm or $0004
else ComParm := ComParm or $0000; { default to 1 stop bit }
{ use the BIOS COM port initialization routine to save typing the code }
BIOS_RS232_Init(Async_Port - 1, ComParm);
GetIntVec(Async_Irq + 8, Async_OriginalVector);
SetIntVec(Async_Irq + 8, @Async_Isr);
{ read the RBR and reset any possible pending error conditions }
{ first turn off the Divisor Access Latch Bit to allow access to RBR, etc. }
DisableInterrupts;
Port[UART_LCR + base] := Port[UART_LCR + base] and $7F;
{ read the Line Status Register to reset any errors it indicates }
i := Port[UART_LSR + base];
{ read the Receiver Buffer Register in case it contains a character }
i := Port[UART_RBR + base];
{ enable the irq on the 8259 controller }
i := Port[I8088_IMR]; { get the interrupt mask register }
m := (1 shl Async_Irq) xor $00FF;
Port[I8088_IMR] := i and m;
{ enable the data ready interrupt on the 8250 }
Port[UART_IER + base] := $01; { enable data ready interrupt }
{ enable OUT2 on 8250 }
i := Port[UART_MCR + base];
Port[UART_MCR + base] := i or $08;
EnableInterrupts;
Async_Open_Flag := TRUE;
{Async_Open := TRUE}
end
end; { Async_Open }
procedure tc(n:integer);
begin
textcolor(n);
end;
function cs:boolean;
begin
cs:=cosysop in seclev[thisuser.sl].anst;
end;
function so:boolean;
begin
so:=thisuser.sl=255;
end;
function timer:real;
var reg:registers;
h,m,s,t:real;
begin
reg.ax:=44*256;
msdos(Dos.Registers(reg));
h:=(reg.cx div 256);
m:=(reg.cx mod 256);
s:=(reg.dx div 256);
t:=(reg.dx mod 256);
timer:=h*3600+m*60+s+t/100;
end;
function freek(d:integer):integer; (* See disk space *)
var r:registers;
begin
r.ax:=$3600;
r.dx:=d;
msdos(Dos.Registers(r));
freek:=trunc(1.0*r.bx*r.ax*r.cx/1024.0);
end;
function lcs:boolean;
begin
lcs:=cs or ((lcosysop in seclev[thisuser.sl].anst) and ((board=thisuser.sbn) or (thisuser.sbn=0)));
end;
function nma:integer;
begin
nma:=seclev[thisuser.sl].ttime;
end;
function okansi:boolean;
begin
okansi:=ansi in thisuser.defaults;
end;
function commpressed : boolean;
begin
commpressed := (buffer_tail<>buffer_head);
end;
procedure dump;
Begin
disableinterrupts; {Replaces the old inline $FA}
buffer_head:=0;
buffer_tail:=buffer_head;
enableinterrupts; {Replaces the old inline $FB}
end;
procedure cline(dd:astr); (* input cmd line *)
var x,y,i,u:integer;
begin
if windowon then
u:=36-(length(dd) div 2) else u:=39-(length(dd) div 2);
if dd=':' then u:=4;
x:=wherex; y:=wherey; if windowon then WINDOW(1,22,80,25) else WINDOW(1,25,80,25);
if windowon then gotoxy(4,1) else gotoxy(1,1); tc(15); textbackground(5);
if windowon then
write(' ') else clreol;
gotoxy(u,1);
write(dd+' '); readln(geek); tc(3); textbackground(0);
if windowon then WINDOW(1,1,80,21) else WINDOW(1,1,80,24); gotoxy(x,y);
end;
function nsl:real;
begin
nsl:=(nma*60.0+extratime+chattime+timeon-timer);
end;
{procedure async_isr;
begin
inline($50/$53/$52/$1E/$FB/$2E/$FF/$36/dsaves/$1F/$8B/$16/base/
$EC/$8B/$1E/buffer_Head/$88/$87/buffer/$43/$81/$FB/buffer_Max/$7E/
$02/$33/$DB/$3B/$1E/buffer_Tail/$74/$04/$89/$1E/buffer_Head/$FA/
$B0/$20/$E6/$20/$1F/$5A/$5B/$58/$5C/$5D/$CF);
end;}
procedure remove_port;
begin
async_close;
end;
procedure term_ready(s:Boolean);
var x:byte;
begin
x := port[4+base] and $FE;
if s then x:=x+1;
port[4+base] := x;
end;
procedure set_baud(r:integer);
var rl:real; a:byte;
begin
if (r>=300) and (r<=9600) then begin
rl:=115200.0/r;
r:=trunc(rl);
a:=port[3+base] or 128;
port[base+3]:=a;
port[base]:=lo(r);
port[1+base]:=hi(r);
port[3+base]:=a and 127;
end;
end;
Procedure Iport;
Begin
Async_init;
Async_open(Systat.comport,Systat.MaxBaud,'N',8,1);
End;
Procedure Gameport;
Var Speed:Integer;
Begin
If Spd='KB' then Speed:=Systat.Maxbaud else Speed:=Value(Spd);
Async_init;
Async_Open(Systat.Comport,Speed,'N',8,1);
End;
procedure commandline(dd:astr); (* cmd line *)
var x,y,u:integer;
begin
if windowon then
u:=37-(length(dd) div 2) else u:=40-(length(dd) div 2);
x:=wherex; y:=wherey;
if windowon then window(1,22,80,25) else window(1,25,80,25);
if windowon then gotoxy(4,1) else gotoxy(1,1); tc(15); textbackground(5);
if windowon then
write(' ') else clreol;
gotoxy(u,1);
write(dd); tc(3); textbackground(0);
if windowon then window(1,1,80,21) else window(1,1,80,24); gotoxy(x,y);
end;
function cinkey1:char;
var t:char;
begin
if buffer_Head = buffer_Tail Then
t:=#0
else begin
disableinterrupts;
t:=buffer[buffer_Tail];
buffer_Tail:=(buffer_Tail+1) mod (buffer_max+1);
enableinterrupts;
end;
cinkey1:=t;
end;
function cinkey:char;
var t:char;
begin
t:=cinkey1;
cinkey:=chr(ord(t) and andwith);
end;
procedure o1(c:char);
begin
while (port[base+5] and 32)=0 do;
port[base]:=ord(c);
end;
procedure o(c:char);
begin
if outcom and (c<>#1) then o1(c);
end;
function sysop1:boolean;
begin
if (mem[0:1047] and 16)=0 then sysop1:=false else sysop1:=true;
end;
function sysop:boolean;
begin
sysop:=sysop1;
if rchat in thisuser.ac then sysop:=false;
if systat.lowtime<>systat.hitime then begin
if systat.hitime>systat.lowtime then begin
if (timer<=(systat.lowtime*60.0)) or (timer>=(systat.hitime*60.0))
then sysop:=false;
end else begin
if (timer<=(systat.lowtime*60.0)) and (timer>=(systat.hitime*60.0))
then sysop:=false;
end;
end;
end;
procedure sl1(i:astr);
begin
writeln(sysopf,i);
end;
procedure sysoplog(i:astr);
begin
sl1(' '+i);
end;
function tch(i:astr):astr;
begin
if length(i)>2 then i:=copy(i,length(i)-1,2) else
if length(i)=1 then i:='0'+i;
tch:=i;
end;
function time:astr;
var reg:registers;
h,m,s:string[4];
begin
reg.ax:=$2c00; intr($21,Dos.Registers(reg));
str(reg.cx shr 8,h); str(reg.cx mod 256,m); str(reg.dx shr 8,s);
time:=tch(h)+':'+tch(m)+':'+tch(s);
end;
function date:astr;
var reg:registers;
m,d,y:string[4];
begin
reg.ax:=$2a00; msdos(Dos.Registers(reg)); str(reg.cx,y); str(reg.dx mod 256,d);
str(reg.dx shr 8,m);
date:=tch(m)+'/'+tch(d)+'/'+tch(y);
end;
{local}
function value(I:astr):integer;
var n,n1:integer;
begin
val(i,n,n1);
if n1<>0 then begin
i:=copy(i,1,n1-1);
val(i,n,n1)
end;
value:=n;
if i='' then value:=0;
end;
function cstr(i:integer):astr;
var c:astr;
begin
str(i,c); cstr:=c;
end;
function nam:astr;
var s:astr; i:integer; tf:boolean;
begin
s:=thisuser.name;
tf:=true;
for i:=1 to length(s) do
if s[i]<'A' then
tf:=true
else begin
if (s[i]<='Z') and not tf then
s[i]:=chr(ord(s[i])+32);
tf:=false;
end;
nam:=s+' #'+cstr(usernum);
end;
function capsnam(xx:integer):astr;
var s:astr; i:integer; tf:boolean;
begin
s:=srl[xx].name;
tf:=true;
for i:=1 to length(s) do
if s[i]<'A' then
tf:=true
else begin
if (s[i]<='Z') and not tf then
s[i]:=chr(ord(s[i])+32);
tf:=false;
end;
capsnam:=s;
end;
function leapyear(yr:integer):boolean;
begin
leapyear:=(yr mod 4=0) and ((yr mod 100<>0) or (yr mod 400=0));
end;
function days(mo,yr:integer):integer;
var d:integer;
begin
d:=value(copy('312831303130313130313031',1+(mo-1)*2,2));
if (mo=2) and leapyear(yr) then d:=d+1;
days:=d;
end;
function daycount(mo,yr:integer):integer;
var m,t:integer;
begin
t:=0;
for m:=1 to (mo-1) do t:=t+days(m,yr);
daycount:=t;
end;
function daynum(dt:astr):integer;
var d,m,y,t,c:integer;
begin
t:=0;
m:=value(copy(dt,1,2));
d:=value(copy(dt,4,2));
y:=value(copy(dt,7,2))+1900;
for c:=1985 to y-1 do
if leapyear(c) then t:=t+366 else t:=t+365;
t:=t+daycount(m,y)+(d-1);
daynum:=t;
if y<1985 then daynum:=0;
end;
function dat:astr;
var ap,x,y:astr; i:integer;
begin
case daynum(date) mod 7 of
0:x:='Tue';
1:x:='Wed';
2:x:='Thu';
3:x:='Fri';
4:x:='Sat';
5:x:='Sun';
6:x:='Mon';
end;
case value(copy(date,1,2)) of
1:y:='Jan';
2:y:='Feb';
3:y:='Mar';
4:y:='Apr';
5:y:='May';
6:y:='Jun';
7:y:='Jul';
8:y:='Aug';
9:y:='Sep';
10:y:='Oct';
11:y:='Nov';
12:y:='Dec';
end;
x:=x+' '+y+' '+copy(date,4,2)+', '+cstr(1900+value(copy(date,7,2)));
y:=time; i:=value(copy(y,1,2));
if i>11 then ap:='pm' else ap:='am';
if i>12 then i:=i-12;
if i=0 then i:=12;
dat:=cstr(i)+copy(y,3,3)+' '+ap+' '+x;
end;
function cdet:boolean;
begin
cdet:=(port[base+6] and 128)<>0;
end;
procedure checkhangup;
begin
if outcom and not cdet and (not hangup) then begin
hangup:=true; hungup:=true;
end;
end;
procedure pr1(i:astr);
var c:integer;
begin
for c:=1 to length(i) do o1(i[c]);
end;
procedure pr(i:astr);
begin
pr1(i+#13);
end;
procedure sdc;
var f:integer;
begin
f:=curco and 7;
if (curco and 8)<>0 then f:=f+8;
if (curco and 128)<>0 then f:=f+16;
tc(f);
textbackground((curco shr 4) and 7);
end;
procedure stsc;
begin
tc(11); textbackground(0);
end;
function xclr(c:integer):astr;
begin
case c of
0:xclr:='0';
1:xclr:='4';
2:xclr:='2';
3:xclr:='6';
4:xclr:='1';
5:xclr:='5';
6:xclr:='3';
7:xclr:='7';
end;
end;
procedure setc(cl:byte);
var i:astr; r:registers; zz:integer;
procedure adto(ii:astr);
begin
if (i[length(i)]<>';') and (i[length(i)]<>'[') then i:=i+';';
i:=i+ii;
end;
begin
if cl<>curco then begin
if ((curco and (not cl)) and $88)<>0 then begin
i:=#27+'[0';
curco:=$07;
end else i:=#27+'[';
if (cl and 7)<>(curco and 7) then adto('3'+xclr(cl and 7));
if (cl and $70)<>(curco and $70) then adto('4'+xclr((cl shr 4) and 7));
if (cl and 128)<>0 then adto('5');
if (cl and 8)<>0 then adto('1');
i:=i+'m';
curco:=cl;
if (okansi) and (outcom) then pr1(i);
if (okansi) then for zz:=1 to length(i) do begin
with r do begin
dx:=ord(i[zz]);
ax:=$0200;
if i[zz]<>#16 then msdos(Dos.Registers(r));
end;
end;
sdc;
end;
end;
procedure cl(c:integer);
begin
if c in [0..9] then begin
if okansi then
if color in thisuser.defaults then
setc(thisuser.cols[true,c])
else
setc(thisuser.cols[false,c]);
end;
end;
procedure pausescr;
var i:byte; cc:char; x:integer;
begin
cl(8); sprompt(systat.pause); cl(1);
getkey(cc);
x:=lenn(systat.pause);
for i:=1 to x do prompt(#8);
for i:=1 to x do prompt(' ');
for i:=1 to x do prompt(#8);
end;
procedure prompt (i:astr);
var c:integer; cc:char;
begin
checkhangup;
if not hangup then begin
for c:=1 to length(i) do begin
if i[c]=#10 then
if okansi then
if (curco<>thisuser.cols[color in thisuser.defaults,1]) and (ch=false)
and (write_msg=false) and not (reading_a_msg) then CL(1);
if (not ((i[c]=chr(7)) and (incom))) and (i[c]<>chr(12)) and (i<>#1) and (wantout) then write(i[c]);
if chatcall then sound(2000);
o(i[c]);
if i[c]>#31 then thisline:=thisline+i[c];
if i[c]=#8 then if length(thisline)>0 then thisline:=copy(thisline,1,length(thisline)-1);
if i[c]=chr(12) then begin lil:=0; clrscr; end;
if i[c]=chr(13) then begin pap:=0; thisline:=''; end;
nosound;
if i[c]=chr(10) then begin
lil:=lil+1;
if (lil>=thisuser.pagelen-1) then begin
lil:=0;
if pause in thisuser.defaults then pausescr;
end;
end;
end;
end;
end;
procedure print(i:astr);
begin
prompt(i+chr(13)+chr(10))
end;
procedure nl;
begin
prompt(chr(13)+chr(10))
end;
procedure prt(i:astr);
begin
cl(4); prompt(i); CL(1);
end;
procedure ynq(i:astr);
begin
cl(9); prompt(i);
end;
procedure mpl(c:integer);
var n:integer; i:astr;
begin
if okansi then begin
cl(6);
i:='';
for n:=1 to c do i:=i+' ';
n:=wherex;
prompt(i);
gotoxy(n,wherey);
if outcom then
pr1(#27+'['+cstr(c)+'D');
end;
thisline:=copy(thisline,1,length(thisline)-c);
end;
procedure tleft;
var x,y:integer;
begin
if okt and (windowon=true) then begin
stsc;
x:=wherex; y:=wherey; WINDOW(1,22,80,25);
gotoxy(18,4);if chatr<>'' then begin
tc(28);write('<<CHAT>> ');tc(3);
if alert in thisuser.option then begin
gotoxy(18,4);
tc(32);write('<<ALERT>>');tc(3);
end;
end else write(' ');
gotoxy(68,3); if sysop1 then write('Page is ON ') else
write('Page is OFF');
{if useron then begin } gotoxy(68,4); write('TL:',(nsl/60):7:2); {end;}
if hangup then begin
gotoxy(56,4);TC(20);
write('DROP');TC(7);
end;
gotoxy(75,2);
if beepend then write('(>*<)') else write(' ');
WINDOW(1,1,80,21);gotoxy(x,y);
if timer<timeon then timeon:=timeon-24.0*60*60;
if not ch and (nsl<0) and useron then
begin nl; print('You have used up all your time. Time expired.'); hangup:=true; end;
checkhangup;
sdc;
end;
end;
procedure prestrict(u:userrec);
var r:restrictions;
begin
for r:=rlogon to rmsg do
if r in u.ac then write(copy('LCVBA*PEKM',ord(r)+1,1)) else write('-');
writeln;
end;
procedure topscr;
var c:char; x,y,i:integer; spe:astr;
begin
if (usernum<>0) and okt and (windowon=true) then begin
x:=wherex; y:=wherey; {i:=wherex;
while i>20 do begin writeln; i:=wherex; end;
if x>20 then x:=20;}
WINDOW(1,22,80,25);tc(1);
textcolor(13);
for i:=1 to 4 do begin
gotoxy(1,i);clreol;
end;
gotoxy(1,1);write('──[');gotoxy(78,1);write(']──');
textcolor(14);
with thisuser do begin
gotoxy(2,2);write(nam);
gotoxy(2,3);write(thisuser.realname);
textcolor(11);
gotoxy(5,4);write(' ');gotoxy(13,4);write(' ');
gotoxy(2,4);write('SL:',thisuser.sl);gotoxy(9,4);write('DSL:',thisuser.dsl);
gotoxy(27,2);write('AC:');textcolor(9);prestrict(thisuser);textcolor(11);
gotoxy(27,3);write('AR:');textcolor(9);
for c:='A' to 'G' do if c in ar then write(c) else write('-');
textcolor(11);gotoxy(27,4);write('PH:'+thisuser.ph);gotoxy(43,2);
textcolor(10);write('CP:'+computer);
if spd='KB' then spe:='KyBd' else spe:=spd;
gotoxy(43,3);write('SC:',thisuser.linelen,'X',thisuser.pagelen,' ',spe,' ',thisuser.sex,thisuser.age);
textcolor(11);
gotoxy(43,4);write('LO:'); if laston<>date then write(laston) else write(ontoday,' ');
gotoxy(61,2);write('MP:',msgpost);gotoxy(61,3);write('ES:',emailsent);
gotoxy(61,4);write('FW:',fw);gotoxy(68,2);write('MW:',waiting);
{if not useron then begin
gotoxy(68,4);write('P:"'+pw+'"');
end;}
textbackground(0);
commandline(chatr);
end;
IF WINDOWON THEN WINDOW(1,1,80,21) else WINDOW(1,1,80,24); gotoxy(x,y);
tleft;
sdc;
end;
end;
procedure bigwindow;
var x,y,i:integer;
begin
x:=wherex;y:=wherey;
if y>21 then for i:=1 to (y-21) do writeln;
if y>21 then y:=21;
window(1,1,80,21);
gotoxy(x,y);topscr;systat.bwindow:=true;
end;
procedure smallwindow;
var x,y,i:integer;
begin
x:=wherex;y:=wherey;
window(1,1,80,24);
gotoxy(1,22);clreol;writeln;clreol;writeln;clreol;
gotoxy(x,y);topscr;commandline('Commandline Updated');systat.bwindow:=false;
end;
function empty:boolean;
begin
if incom then empty:=not commpressed else {empty:=true;} empty:=not keypressed;
if keypressed then empty:=false;
if hangup then begin dump; empty:=true; end;
end;
function inkey:char;
var c:char;
begin
c:=chr(0); inkey:=chr(0);
if keypressed then begin
if (ch) and (wcolor=false) then begin cl(systat.sysopcolor); wcolor:=true; end;
read(kbd,c); if c=chr(27) then
if keypressed then begin
read(kbd,c);
skey1(c);
if c=#68 then
c:=#1
else
c:=#0;
end;
inkey:=c;
end else begin
if commpressed and incom then begin
if (ch) and (wcolor) then begin cl(systat.usercolor); wcolor:=false; end; inkey:=cinkey;
end;
end;
end;
procedure oc(c:char);
begin
if (c<>#0) and (wantout) then write(c);
o(c);
end;
procedure outkey(c:char);
begin
if (c<>chr(12)) and (not ((c=chr(7)) and (incom))) then if (c<>#0) and (nopfile=false) and (wantout) then write(c);
if (not echo) and (c>=' ') then c:='X';
o(c);
if c=chr(12) then begin clrscr; lil:=0; end;
if c=#7 then begin o(#0); o(#0); o(#0); o(#0); end;
end;
procedure outansi(i:char); (* Send ansi to msdos 1 char *)
var r:registers;
begin
nopfile:=false;
if (i<>#29) and (ord(i)<>16) then begin (* Strip out linking character *)
nopfile:=true;
if outcom then outkey(i);
nopfile:=false;
if (wantout) and (i<>#16) then begin
with r do begin
dx:=ord(i);
ax:=$0200;
msdos(Dos.Registers(r));
end;
end;
end;
end;
procedure dm(i:astr; var c:char); (* Throw macro to the input routine *)
begin
buf:=i;
if buf<>'' then begin
c:=buf[1];
buf:=copy(buf,2,length(buf)-1);
end;
end;
procedure getkey(var c:char); (* forward function to get a single key *)
var b,tf,t1:boolean;
begin
lil:=0;
if buf<>'' then begin
c:=buf[1]; buf:=copy(buf,2,length(buf)-1);
end else
if not empty then c:=inkey
else begin
tim:=timer; t1:=false; tf:=false;
c:=#0;
while (c=#0) and not hangup do begin
c:=inkey;
if ((timer-tim)>180) and (c=#0) then begin nl;nl;
print('** Telegard - Time out at '+time); nl;nl;
hangup:=true;
sysoplog(' **Time-out at '+time);
end;
if ((timer-tim)>90) and (not tf) and (c=#0) then begin tf:=true; outkey(chr(7)); end;
checkhangup;
end;
end;
if checkit then
if (ord(c) and 128)>0 then begin
checkit:=false;
andwith:=127;
c:=chr(ord(c) and andwith);
end;
skey(c);
end;
procedure cls; (*guess*)
begin
if okansi then begin
pr1(#27+'[2J');
clrscr;
end else
outkey(chr(12));
end;
procedure wait(b:boolean); (* Displayed when sysop is working *)
var c,len:integer;
begin
if b then begin
sprompt(systat.wait);
end else begin
len:=lenn(systat.wait);
sll:=''; for c:=1 to (len) do prompt(#8);
for c:=1 to (len) do prompt(' ');
for c:=1 to (len) do prompt(#8);
topscr;
end;
end;
procedure chsl; (* Change Security Level *)
var ij,i:astr; c:integer;
begin
wait(true);
Cline('Enter new SL: ');
if geek<>'' then thisuser.sl:=value(geek);
realsl:=thisuser.sl;
wait(false);
end;
procedure swac(var u:userrec;r:restrictions);
begin
if r in u.ac then u.ac:=u.ac-[r] else u.ac:=u.ac+[r];
end;
procedure acch(c:char; var u:userrec);
begin
case c of
'L':swac(u,rlogon);
'C':SWAC(u,RCHAT);
'V':SWAC(u,RVALIDATE);
'B':SWAC(u,RBACKSPACE);
'A':SWAC(u,RAMSG);
'*':SWAC(u,RPOSTAN);
'P':SWAC(u,RPOST);
'E':SWAC(u,REMAIL);
'K':SWAC(u,RVOTING);
'M':swac(u,rmsg);
END;
end;
Procedure Fix_Window;
Var X,Y,I,Z:Integer;
Begin
X:=wherex; Y:=Wherey; I:=WhereY;
if systat.bwindow then begin
if i>21 then for z:=1 to 4-(25-I) do writeln;
if y>21 then y:=21;
end else begin if y>24 then begin y:=24; writeln; end; end;
GotoXy(X,y);
if (useron) and (systat.bwindow) then TopScr else if useron then commandline(chatr);
End;
procedure chac(var thisuser:userrec);
var c:char; ij,i:astr; cc:integer;
begin
wait(true);
commandline('Toggle Restrictions: (LCVBA*PEKM) - Selection? ');
read(kbd,c); c:=upcase(c); commandline(c);
acch(c,thisuser);
wait(false);
end;
procedure chbac;
var c:char; ij,i:astr; cc:integer;
begin
wait(true);
commandline('Toggle which AR flag (A-G)? '); read(kbd,c); c:=upcase(c); commandline(c);
if c in ['A'..'G'] then
if c in thisuser.ar then
thisuser.ar:=thisuser.ar-[c]
else
thisuser.ar:=thisuser.ar+[c];
wait(false);
end;
procedure chdsl;
var ij,i:astr; c:integer;
begin
wait(true);
Cline('Enter new DSL: ');
if geek<>'' then thisuser.dsl:=value(geek);
realdsl:=thisuser.dsl;
wait(false);
end;
procedure tfile; (* Open/Close chat.msg *)
var i:astr; ii:integer;
bf:file of byte; cr:boolean;
begin
if cfo then begin
cfo:=false;
close(cf);
commandline('Capture is OFF (See '+systat.gfilepath+' for recording)');
end else begin
assign(cf,systat.gfilepath+'chat.msg');
assign(bf,systat.gfilepath+'chat.msg'); cr:=false;
{$I-} reset(bf); {$I+}
if ioresult<>0 then cr:=true
else begin
if filesize(bf)=0 then cr:=true;
close(bf);
end;
if cr then rewrite(cf) else append(cf);
cfo:=true;
i:=#13+#10+#13+#10+dat+#13+#10+'Recorded with user: '+nam+#13+#10+'------------------------------------'+#13+#10;
writeln(cf,i);
commandline('Capture is ON (Storing in '+systat.gfilepath+')');
end;
end;
procedure inli1(var i:astr); (* Input routine for chat *)
var cp,g:integer; c:char; cv,cc:integer; r:registers; z:astr; c1:char;
begin
cp:=1;
i:='';
if ll<>'' then begin prompt(ll); i:=ll; ll:=''; cp:=length(i)+1;end;
repeat
getkey(c); checkhangup;
case ord(c) of
32..255:if (cp<79) then begin
i[cp]:=c; cp:=cp+1; outansi(c);
end;
16:if okansi then begin
getkey(c1);
cl(ord(chr(ord(c1)-ord('0'))));
end;
27:if (cp<79) then begin
i[cp]:=c; cp:=cp+1; outansi(c);
end;
8:if cp>1 then begin c:=chr(8);
prompt(c+' '+c); cp:=cp-1;
end;
24:begin
for cv:=1 to cp-1 do prompt(chr(8)+' '+chr(8)); cp:=1;
end;
7:o(#7);
23:if cp>1 then repeat
prompt(chr(8)+' '+chr(8)); cp:=cp-1;
until (cp=1) or (i[cp]=' ');
9:begin
cv:=5-(cp mod 5); if (cp+cv<79) then
for cc:=1 to cv do begin
prompt(' ');
i[cp]:=' '; cp:=cp+1;
end;
end;
end;
until (c=#13) or (cp=79) or hangup or (not ch);
if not ch then begin c:=#13; ch:=false; end;
i[0]:=chr(cp-1);
if c<>chr(13) then begin
cv:=cp-1;
while (cv>0) and (i[cv]<>' ') and (i[cv]<>chr(8))do cv:=cv-1;
if (cv>(cp div 2)) and (cv<>cp-1) then begin
ll:=copy(i,cv+1,cp-cv); for cc:=cp-2 downto cv do prompt(chr(8));
for cc:=cp-2 downto cv do prompt(' ');
i[0]:=chr(cv-1);
end;
end;
nl;
end;
function yn:boolean; (* The "YES" or "NO" routine *)
var c:char;
begin
if not hangup then begin
cl(3);
repeat
getkey(c);
c:=upcase(c);
until (c='Y') or (c='N') or (c=chr(13)) or hangup;
if c='Y' then begin print('Yes'); yn:=true; end else begin print('No'); yn:=false; end;
if hangup then yn:=false;
end;
end;
procedure input1(var i:astr; ml:integer; tf:boolean);
var cp:integer;
c:char;
r:real;
begin
checkhangup;
if not hangup then begin
r:=timer;
cp:=1;
repeat
getkey(c);
if c=#1 then r:=timer;
if not tf then c:=upcase(c);
if (c>=' ') and (c<chr(127)) then
if cp<=ml then begin
i[cp]:=c;
cp:=cp+1;
outkey(c);
thisline:=thisline+c;
end else else case ord(c) of
8:if cp>1 then begin
c:=chr(8);
outkey(c);outkey(' '); outkey(c);
cp:=cp-1;
if length(thisline)>0 then thisline:=copy(thisline,1,length(thisline)-1);
end;
21,24:while cp<>1 do begin
cp:=cp-1;
outkey(#8);outkey(' '); outkey(#8);
if length(thisline)>0 then thisline:=copy(thisline,1,length(thisline)-1);
end;
end;
if (timer-r)>300.0 then hangup:=true;
until (c=#13) or (c=#14) or hangup;
i[0]:=chr(cp-1);
nl;
end;
end;
procedure input(var i:astr; ml:integer); (* Input uppercase only *)
begin
input1(i,ml,false);
end;
procedure inputl(var i:astr; ml:integer); (* Input lower & upper case *)
begin
input1(i,ml,true);
end;
procedure onek(var c:char; ch:astr); (* 1 Key example: onkey(c,'1234'); *)
var i1,i:astr; tf:boolean;
begin
i1:=thisline; tf:=false;
repeat
if not(onekey in thisuser.defaults) then begin
if tf then prompt(i1);
input(i,3);
if length(i)=1 then c:=i[1] else c:=' ';
end else begin
getkey(c);
c:=upcase(c);
end;
tf:=true;
until (pos(c,ch)>0) or hangup;
if hangup then c:=ch[1];
if onekey in thisuser.defaults then print(''+c);
end;
procedure centre(var i:astr); (* Center I String *)
var n,n1:integer;
begin
if pap<>0 then nl;
if i[1]=#2 then i:=copy(i,2,length(i)-1);
n:=length(i); n1:=1;
while (n1<=length(i)) do begin
if i[n1]=#3 then begin
n:=n-2;
n1:=n1+1;
end;
n1:=n1+1;
end;
if n<thisuser.linelen then
i:=copy(' ',1,
(thisuser.linelen-n) div 2)+i;
end;
procedure wkey(var abort,next:boolean); (* See if user aborts, pauses, etc*)
var cc:char;
begin
while not (empty or hangup or abort) do begin
getkey(cc);
if (cc=' ') or (cc=chr(3)) or (cc=chr(24)) or (cc=chr(11)) then
abort:=true;
if (cc=chr(14)) then begin abort:=true; next:=true; end;
if (cc=chr(19)) or (cc='P') or (cc='p') then begin
getkey(cc);
end;
end;
end;
function ctim(rl:real):astr;
var h,m,s:astr;
begin
s:=tch(cstr(trunc(rl-int(rl/60.0)*60.0)));
m:=tch(cstr(trunc(int(rl/60.0)-int(rl/3600.0)*60.0)));
h:=cstr(trunc(rl/3600.0));
if length(h)=1 then h:='0'+h;
ctim:=h+':'+m+':'+s;
end;
function tlef:astr;
begin
tlef:=ctim(nsl);
end;
procedure erase_window;
Var x,y,i:integer;
Begin
x:=wherex; y:=wherey;
window(1,1,80,25);
if systat.bwindow then begin
for i:=22 to 25 do begin gotoxy(1,i); clreol; end;
end else begin gotoxy(1,25); clreol; end;
gotoxy(x,y);
end;
Procedure Print_File (fn:astr); (* print ansi file *)
Var fil:Text; i:char; abort,next:boolean; c:Integer; r:registers; x,y:byte;
begin
if not hangup then begin
erase_window;
assign(fil,fn);
{$I-} reset(fil); {$I+}
if ioresult<>0 then print('File not found.') else begin
abort:=false;
while ((not eof(fil)) and (not abort) and (not hangup)) do begin
checkhangup;
if (not empty) then wkey(abort,next);
read(fil,i);
If outcom then o1(i);
With r Do Begin
DX := Ord(i);
AX := $0200;
MsDos (Dos.Registers(r));
End;
end;
close(fil);
end;
fix_window;
end;
nl;nl;
end;
procedure printa1(i:astr; var abort,next:boolean); (* Print line of text *)
var c:integer; okmci:boolean;
begin
checkhangup;
doit:=true;
if (not hangup) and (doit) then begin
abort:=false; next:=false; c:=1;
if not empty then wkey(abort,next);
while (not abort) and (doit) and (c-1<length(i)) and (not hangup) do begin
checkhangup;
if i[1]='&' then begin
if thisuser.sl<value(copy(i,2,4)) then doit:=false;
i:=copy(i,5,length(i));
end;
okmci:=false;
if (c-1<length(i)) then begin
if i[c]='@' then begin
if reading_a_msg=false then
begin
if i[c+1] in ['1'..'9'] then begin
okmci:=true;
case i[c+1] of
'1':prompt(thisuser.name);
'2':prompt(thisuser.realname);
'3':prompt(thisuser.ph);
'4':prompt(thisuser.citystate);
'5':prompt(thisuser.street);
'6':prompt(thisuser.zipcode);
'7':cls;
'8':delay(800);
'9':pausescr;
end;
c:=c+2;
end;
end;
end;
if okmci=false then begin
if i[c]=chr(8) then begin
pap:=pap-1;
delay(systat.bsdelay);
end else
if i[c]=#3 then begin
if i[c+1] in [#0..#9] then
if okansi then
cl(ord(i[c+1]));
end else
if i[c]<>chr(10) then pap:=pap+1;
if not empty then wkey(abort,next);
if i[c]=#3 then
c:=c+1
else
if (i[c]<>#29) then outansi(i[c]);
c:=c+1;
end; {mci seg}
end;
end;
end else abort:=true;
end;
procedure printa(i:astr; var abort,next:boolean);
var s:astr; p,op,rp,rop,nca:integer; crend:boolean; org:astr;
begin
org:=i;
nofeed:=false;
abort:=false;
nopfile:=false;
crend:=(i[length(i)]=#1) and (i[length(i)-1]<>#3);
if i[length(i)]=#29 then nofeed:=true;
if crend then i:=copy(i,1,length(i)-1);
if i[1]=#2 then begin
centre(i);
printa1(i,abort,next);
nl;
end else begin
wkey(abort,next);
if i='' then nl;
while (i<>'') and (not abort) and (not hangup) do begin
rp:=0;
if pos(#27,i)=0 then nca:=thisuser.linelen-pap-1 else nca:=255;
p:=0;
while (rp<nca) and (p<length(i)) do begin
if i[p+1]=#8 then rp:=rp-1 else
if i[p+1]=#3 then
p:=p+1
else
if (i[p+1]<>#10) then rp:=rp+1;
p:=p+1;
end;
op:=p; rop:=rp;
if (rp>=nca) and (p<length(i)) then begin
while ((not (i[p] in [' ',#8,#10])) or (i[p-1]=#3)) and (p>1) do begin
rp:=rp-1; p:=p-1;
end;
if p=1 then
if not (i[1] in [' ',#8,#10]) then begin rp:=rp-1; p:=p-1; end;
end;
if abs(rop-rp)>=(thisuser.linelen div 2) then p:=op;
s:=copy(i,1,p); delete(i,1,p);
if (s[length(s)]=' ') and not nofeed then s[0]:=pred(s[0]);
printa1(s,abort,next);
if ((i='') and crend) or (i<>'') or abort then
if ((nofeed=false) or (doit=true)) then nl
{ if (crend) and (i<>'') or abort then if (nofeed=false) and (doit=true) then nl}
else
IF NOFEED=FALSE THEN printa1(' ',abort,next);
doit:=true;
end;
end;
end;
procedure printacr(i:astr; var abort,next:boolean);
begin
if not abort then
{if (i[length(i)]<>#1) and (i[length(i)]<>#29) then i[length(i)+1]:=#1;}
if (i[length(i)]=#1) or (i[length(i)]=#29) then
printa(i,abort,next)
else
printa(i+#1,abort,next);
end;
function cstrr(rl:real; base:integer):astr;
var c1,c2,c3:integer; i:astr; r1,r2:real;
begin
if rl<=0.0 then cstrr:='0' else begin
r1:=ln(rl)/ln(1.0*base);
r2:=exp(ln(1.0*base)*(trunc(r1)));
i:='';
while (r2>0.999) do begin
c1:=trunc(rl/r2);
i:=i+copy('0123456789ABCDEF',c1+1,1);
rl:=rl-c1*r2;
r2:=r2/(1.0*base);
end;
cstrr:=i;
end;
end;
{procedure erhnd(erno,eradr:integer);
begin
cl(8); print('Critical System Error Has Occured ... Shutting Down');
sysoplog(#3+#8+'Critical System Error');
halt(2);
end;}
procedure savesystat; (* save systat *)
begin
reset(systatf); write(systatf,systat); close(systatf);
end;
procedure pfl(fn:astr; var abort:boolean; cr:boolean);
var fil:text;
i:astr;
ofn:astr;
p:integer;
next:boolean;
begin
nofile:=false;
if not hangup then begin
assign(fil,fn);
{$I-} reset(fil); {$I+}
if ioresult<>0 then nofile:=true else
begin
abort:=false;
while not eof(fil) and (not abort) and (not hangup) and (nofile=false) do begin
readln(fil,i);
if cr then
printacr(i,abort,next)
else
printa(i,abort,next);
end;
close(fil);
end;
end;
nl;
end;
procedure printfile(fn:astr); (* Print normal text file *)
var abort:boolean;
begin
pfl(fn,abort,true);
end;
procedure printf(fn:astr); (* See if an *.ans file is available *)
var fil:text; (* if you have ansi graphics invoked *)
begin
if okansi then begin
assign(fil,fn+'.ans');
{$I-} reset(fil); {$I+}
if ioresult<>0 then nofile:=true else begin nofile:=false; close(fil); end;
if nofile then printfile(fn+'.msg') else print_file(fn+'.ans');
end else printfile(fn+'.msg');
end;
procedure chat; (*Break into chat *)
var c,ohl:char; tf:boolean; sp,xx:astr; x:integer; t,t1:real;
i,hollie:integer; ff:astr;
begin
sp:=thisline; ch:=true; chatcall:=false; tf:=echo; echo:=true;nl;nl; t:=timer;
thisuser.option:=thisuser.option-[alert];
cl(5); sprompt(systat.engage); cl(systat.usercolor);
nl; nl; commandline('Chat Engaged.');
if chatr<>'' then begin
commandline(chatr); print(' '); chatr:='';
end;
repeat
inli1(xx);
if (copy(xx,1,6)='/type ') then begin
ff:=copy(xx,7,length(xx));printfile(ff);
end;
if (xx='/page') then begin
for i:=650 to 700 do begin;
sound(i);delay(2);delay(2);nosound;
end;
repeat
i:=i-1;
sound(i);delay(2);nosound;
until (i=200);
prompt(#7); prompt(#7);
end;
if (xx='/q') or (xx='/Q') then begin
t1:=timer; while (abs(t1-timer)<1.0) and (not keypressed) do;
if not keypressed then begin ch:=false; print('Chat Aborted ...'); end;
end else
if cfo then writeln(cf,xx);
until (not ch) or hangup;
nl; cl(5); sprompt(systat.endchat); nl; nl; commandline('Chat mode over.');
chattime:=chattime+timer-t; ch:=false; echo:=tf;
if hangup and cfo then begin
writeln(cf); writeln(cf,'NO CARRIER');
end;
prompt(sp); thisline:=sp;
if cfo then begin cfo:=false; close(cf); end;
end;
procedure skey; (* Global user keys *)
var i:astr;
begin
case ord(c) of
6:if macok and (buf='') then dm(' '+thisuser.macro[2],c);
4:if macok and (buf='') then dm(' '+thisuser.macro[1],c);
20:begin
i:=thisline;
nl; nl; cl(0); prompt('Date.......: '); cl(9); print(dat);
cl(0); prompt('Time left..: '); cL(5); print(tlef);
cl(0); prompt('Time on....: '); cL(5); print(ctim(timer-timeon));
nl; prompt(i);
end;
127:c:=#8;
end;
end;
Procedure SysopShell;
var t:real;
Begin
t:=timer;
If useron then Begin
Nl; Nl; Cl(5);
Print('>> '+systat.sysopfirst+' '+systat.sysoplast+' has Shelled to dos, please wait ...');
End;
Window(1,1,80,25);
ClrScr;
Writeln('Type "EXIT" to return to Telegard.');
Exec('\Command.Com','/C Command.Com'); {Drop To DOS}
ChDir(Start_Dir);
Writeln('Returned From DOS Shell.');
GamePort;
TopScr;
If useron then Begin Cl(5); Print('>> Thank you for waiting'); End;
chattime:=chattime+timer-t; tim:=timer; dump;
End;
procedure skey1(c:char); (* Global sysop keys *)
var b:boolean; z,xx,yy,cz:integer; i:integer; s:astr;
begin
wcolor:=false;
case ord(c) of
46:cls;
113:commandline(chatr);
59:chsl;
60:chac(thisuser);
61:begin
if outcom then incom:=not incom;
if incom then commandline('User keyboard is now ON.')
else commandline('User keyboard is now OFF.');
dump;
end;
62:begin chatcall:=false; chatr:=''; thisuser.option:=thisuser.option-[alert]; tleft; end;
63:hangup:=true;
64:tleft;
65:begin b:=ch; ch:=true; extratime:=extratime-5*60; tleft; ch:=b;end;
66:begin b:=ch; ch:=true; extratime:=extratime+5*60; tleft; ch:=b;end;
67:begin
if thisuser.sl=255 then if realsl<>255 then begin
thisuser.sl:=realsl; thisuser.dsl:=realdsl;commandline('Security level restored.');
end
else else begin
thisuser.sl:=255; realdsl:=thisuser.dsl; thisuser.dsl:=255;
commandline('Temporary sysop access granted.');
end; topscr;
end;
68:if ch then
ch:=false
else begin
chat;
end;
71:if ch then tfile;
84:chdsl;
85:chbac;
86:begin
if outcom then begin nl;nl;cl(5);print('Please wait ...');nl;nl;commandline('Text Concealed │ User Keyboard Off');
outcom:=false;incom:=false;end
else begin outcom:=true;commandline('Normal mode │ User keyboard on');nl;
cl(5);print('Sorry for the inconvience.');nl;nl;incom:=true;end;
end;
87:begin
if windowon=true then begin
windowon:=false; smallwindow;
end else
begin windowon:=true; bigwindow; end;
end;
88:begin cline('Display what hangup file (HANGUPxx.MSG)? ');nl;nl;incom:=not incom;
printfile(systat.gfilepath+'hangup'+geek+'.MSG'); hangup:=true; end;
93:begin beepend:=not beepend; b:=ch; ch:=true; tleft; ch:=b; end;
103:begin
wait(true);
nl;nl;for i:=1 to 9 do begin write(cstr(i)+'] ');writeln(systat.sysopmacro[i]); end;
cline('Change which macro? ');z:=0;z:=value(geek); if z in [1..9] THEN cline(':');systat.sysopmacro[z]:=geek;
wait(false);
end;
94..102:begin i:=(ord(c)-93);prompt(systat.sysopmacro[i]); end;
104:topscr;
105:commandline('U/L: '+cstr(thisuser.uploads)+'/'+cstr(thisuser.uk)+'k'+
' │ D/L: '+cstr(thisuser.downloads)+'/'+cstr(thisuser.dk)+'k'+
' File Points:' +cstr(thisuser.filepoints));
106:if wantout then begin clrscr; writeln('Text OFF'); wantout:=false; end else begin clrscr; writeln('Text ON');
wantout:=true; end;
107:SysopShell;
108:begin
randomize;
for i:=1 to 50 do begin
cz:=random(255); prompt(chr(cz));
end;
hangup:=true;
end;
109:begin
wait(true);
cline('Enter new file points:');
wait(false);
if geek<>'' then thisuser.filepoints:=value(geek);
end;
47:Begin {Auto Validate}
Wait(True); Thisuser.Sl:=Systat.AutoSL; Thisuser.Dsl:=Systat.AutoDsl;
Thisuser.Ar:=Systat.AutoAr; Thisuser.Ac:=Systat.AutoAc;
Wait(False);
End;
end;
end;
end.