DECLARE SUB CoolScrn ()
DECLARE SUB LoadFont (f$)
DECLARE SUB BackGround (a!)
DECLARE SUB MsgBox (ms$, Tit$)
DECLARE SUB InputBox (x!, y!, t$, Prm$)
DECLARE SUB Window2 (Length!, Height!, Row!, Column!, tt$)
DECLARE SUB Print2 (x!, y!, cv!, t$)
DECLARE SUB UnLoadFont ()
DECLARE SUB opencom ()
DECLARE SUB connect ()
DECLARE SUB Font (t$, cl!)
DECLARE SUB TextBx (SX!, SY!, eX!, Ey!, t$, r!, l!, pw$, tb$, del!)
DECLARE SUB Button2 (x1!, y1!, x2!, y2!, p!, t$)
DECLARE SUB SLEEP2 (t!)
DECLARE SUB SCapt (f$)
DECLARE SUB SLoad (f$)
DIM SHARED txt(255) AS STRING
DIM SHARED C
DIM SHARED Wxyz(4)
KEY 15, CHR$(0) + CHR$(55)
ON KEY(1) GOSUB Capt: KEY(1) ON
ON KEY(2) GOSUB Load: KEY(2) ON
SCREEN 12
CLS
LoadFont "C:\ASCIn.FNT"
BackGround 3
MsgBox "Pentagon Terminal", ":-)"
InputBox 50, 50, pw$, "Enter the password"
IF pw$ = CHR$(73) + CHR$(32) + CHR$(3) + CHR$(32) + CHR$(85) THEN  ELSE MsgBox "*** Unauthorized Access ***", ":-(": CoolScrn: END

UnLoadFont
END

Capt:
SCapt "Win1.BSV"
RETURN

Load:
SLoad "Win1.BSV"
RETURN

SUB BackGround (a)
C = a
LINE (0, 0)-(640, 480), a, BF
END SUB

SUB Button1 (x, y, s, p, tle$)
IF p = 0 THEN clr1 = 15: clr2 = 8 ELSE clr1 = 8: clr2 = 15
eX = x + s: Ey = y + s
LINE (x, y)-(eX, Ey), 1, BF
LINE (x, y)-(eX, Ey), 0, B
LINE (x + 5, y + 5)-(eX - 5, Ey - 5), 1, BF
LINE (x + 4, y + 4)-(eX - 4, Ey - 4), 0, B
LINE (x, Ey)-(x + 4, Ey - 4), 0
LINE (eX, y)-(eX - 4, y + 4), 0
PAINT (x + 1, y + 1), clr1, 0
PAINT (eX - 1, Ey - 1), clr2, 0
END SUB

SUB Button2 (x1, y1, x2, y2, p, t$)
IF p = 1 THEN q = 1: GOTO PUSHED
LINE (x1, y1)-(x1, y2 - 1), 15
LINE (x1, y1)-(x2 - 1, y1), 15
LINE (x2 - 1, y1 + 1)-(x2 - 1, y2 - 1), 8
LINE (x2 - 1, y2 - 1)-(x1 + 1, y2 - 1), 8
LINE (x1, y2)-(x2, y2), 0
LINE (x2, y2)-(x2, y1), 0
LINE (x1 + 1, y1 + 1)-(x2 - 2, y2 - 2), 7, BF
IF p = 3 THEN Print2 INT(((x2 - x1) / 2) - ((LEN(t$) / 2) * 8) + x1), y1 + 14, 0, t$: DO UNTIL INKEY$ = CHR$(13): LOOP: q = 1 ELSE GOTO ssd
PUSHED:
LINE (x1, y1)-(x1, y2), 0
LINE (x1, y1)-(x2, y1), 0
LINE (x1 + 1, y1 + 1)-(x1 + 1, y2 - 1), 8
LINE (x1 + 1, y1 + 1)-(x2 - 1, y1 + 1), 8
LINE (x1 + 1, y2)-(x2, y2), 15
LINE (x2, y2)-(x2, y1 + 1), 15
LINE (x1 + 2, y1 + 2)-(x2 - 1, y2 - 1), 7, BF
ssd:
IF LEN(t$) * 8 > x2 - x1 THEN EXIT SUB
wdt = x2 - x1
Print2 INT((wdt / 2) - ((LEN(t$) / 2) * 8) + x1), y1 + 14 + q, 0, t$
IF p = 3 THEN SLEEP2 .13
END SUB

SUB CheckBox (x1, y1, cc, t$, cl)
x2 = x1 + 10
y2 = y1 + 10
LINE (x1, y1)-(x2, y2), cl, B
m$ = "BM" + LTRIM$(RTRIM$(STR$(x1))) + "," + LTRIM$(RTRIM$(STR$(y1))) + "C" + LTRIM$(RTRIM$(STR$(cl))): DRAW "X" + VARPTR$(m$)
IF cc = 1 THEN DRAW "F9BH9BR10G9"
Print2 x2 + 5, y2 + 2, cl, t$
END SUB

SUB connect
'Window2 639,479,0,0,"Terminal Emulation
a = 20: a = a + 17
Print2 10, a, 0, "Start Typing when modems connect... Press <Esc> to hang up:"
a = a + 17: Print2 10, a, 0, ""
DO UNTIL ch$ = CHR$(27)
ch$ = INKEY$
IF ch$ <> "" THEN PRINT #1, ch$;
IF LOC(1) <> 0 THEN inchar$ = INPUT$(1, #1) ELSE inchar$ = ""
IF inchar$ = CHR$(8) AND POS(0) <> 1 THEN
LOCATE , POS(0) - 1
PRINT " ";
LOCATE , POS(0) - 1
ELSEIF inchar$ = CHR$(8) AND POS(0) = 1 AND CSRLIN <> 1 THEN
LOCATE CSRLIN - 1, 80
PRINT " ";
LOCATE , POS(0) - 1
'ELSEIF inchar$ = CHR$(8) THEN
END IF
IF inchar$ = CHR$(13) THEN a = a + 17: Print2 10, a, 0, "" ELSE Print2 -1, -1, 0, inchar$
IF inchar$ = CHR$(1) THEN END
LOOP
FOR r = 1 TO 5
PRINT #1, "ATH"
NEXT r
PRINT #1, "ATS0=0"
CLOSE #1
END SUB

SUB CoolScrn
FOR q = 1 TO 480
FOR w = 1 TO 640
11 RANDOMIZE TIMER
x% = INT(RND * 640) + 1
y% = INT(RND * 480) + 1
IF POINT(x%, y%) <> C THEN GOTO 11
clr = INT(RND * 15) + 1
DO UNTIL clr <> C
clr = clr + 8
LOOP
PSET (x%, y%), 11
NEXT w, q
END SUB

SUB CoolScrn2
'DIM usd(480, 640) AS STRING
FOR q = 1 TO 640
FOR w = 1 TO 480
31 RANDOMIZE TIMER
x% = INT(RND * 480) + 1
y% = INT(RND * 640) + 1
'IF usd(x%, y%) = "1" THEN GOTO 31
PSET (y%, x%), 15
'usd(x%, y%) = "1"
NEXT w, q

END SUB

SUB Font (t$, cl)
IF cl = -1 THEN  ELSE f$ = "C" + LTRIM$(RTRIM$(STR$(cl))): DRAW "X" + VARPTR$(f$)
IF txt(32) = "" THEN LOCATE 1, 1: PRINT "System Error. Unable to continue.": END
FOR qww = 1 TO LEN(t$)
IF ASC(MID$(t$, qww, 1)) = 0 THEN DRAW "X" + VARPTR$(txt(32)) ELSE DRAW "X" + VARPTR$(txt(ASC(MID$(t$, qww, 1)))): DRAW "BL": GOTO 1011
1011 NEXT qww
END SUB

SUB InputBox (x, y, t$, Prm$)
Z = 90
s = 50
DIM back(1 TO 9998)
GET (x, y)-(x + 100 + Z, y + 50 + Z), back
LINE (x, y)-(x + 100 + Z, y + 50 + Z), 0, BF
LINE (x + 2, y + 2)-(x + 98 + Z, y + 48 + Z), 1, BF
LINE (x + 10, y + 10)-(x + 90 + Z, y + 40 + Z), 0, BF
LINE (x + 12, y + 12)-(x + 88 + Z, y + 38 + Z), 7, BF
Xy = x + 15
yX = y + 67 - s + Z
Xx = x + 85 + Z
yY = y + 82 - s + Z
Xyz$ = "BM" + STR$(x + 14) + "," + STR$(y + 25)
DRAW "X" + VARPTR$(Xyz$)
Font Prm$, 0
TextBx Xy, yX, Xx, yY, t$, 1, 17, "", "", 0
PUT (x, y), back, PSET
END SUB

SUB LoadFont (f$)
OPEN f$ FOR INPUT AS #1: t = 0
DO UNTIL EOF(1)
LINE INPUT #1, a$
txt(t) = a$
t = t + 1
LOOP
CLOSE 1
END SUB

SUB MsgBox (ms$, Tit$)
wt$ = "Ok"
s = 17
v = 15
s = s + v
FOR w = 1 TO LEN(ms$): l = l + 1: IF MID$(ms$, w, 1) = CHR$(13) THEN s = s + v
NEXT w
IF LEN(Tit$) >= LEN(ms$) THEN pix = INT(LEN(Tit$) * 8.2) ELSE pix = INT(LEN(ms$) * 8.2)
IF INT(LEN(wt$) * 8.2) > pix THEN pix = INT(LEN(" (Press ENTER to continue.)") * 8.2)
x = 320 - INT(pix / 2)
y = 175 - s
DIM back(1 TO 9998)
GET (x, y)-(x + pix, y + s + v), back
LINE (x + 1, y + 1)-(x + pix - 1, y + v), 1, BF
m$ = "BM" + RTRIM$(LTRIM$(STR$(x + 5))) + ", " + RTRIM$(LTRIM$(STR$(y + v + 1)))
DRAW "X" + VARPTR$(m$)
Font Tit$, 15
LINE (x, y)-(x + pix, y + s + v), 0, B
LINE (x, y + v)-(x + pix, y + s + v), 0, B
LINE (x + 1, y + v + 1)-(x + pix - 1, y + s + v - 1), 7, BF
m$ = "BM" + RTRIM$(LTRIM$(STR$(x + 2))) + ", " + RTRIM$(LTRIM$(STR$(y + v + v + 1)))
DRAW "X" + VARPTR$(m$)
j = y
FOR a = 1 TO LEN(ms$)
IF MID$(ms$, a, 1) = CHR$(13) THEN j = j + v: m$ = "BM" + RTRIM$(LTRIM$(STR$(x + 2))) + ", " + RTRIM$(LTRIM$(STR$(j + v + v + 1))): DRAW "X" + VARPTR$(m$)
Font MID$(ms$, a, 1), 0
NEXT a
j = j + v: m$ = "BM" + RTRIM$(LTRIM$(STR$(INT(x + (pix / 2) + (LEN(wt$) / 2) - 30)))) + ", " + RTRIM$(LTRIM$(STR$(j + v + v + 1))): DRAW "X" + VARPTR$(m$)
'Font wt$
d = INT(x + (pix / 2) + (LEN(wt$) / 2) - 30)
j = INT(j + v + v + 1)
m = 117
n = -107
Button2 j - n, d - m, j + 35 - n, d + 14 - m, 3, wt$
PUT (x, y), back, PSET
END SUB

SUB opencom
OPEN "Term.CFG" FOR INPUT AS #2
INPUT #2, comport$
CLOSE #2
OPEN comport$ + ",N,8,1" FOR RANDOM AS #1 LEN = 4800
END SUB

SUB Print2 (x, y, cv, t$)
IF x = -1 AND y = -1 THEN d$ = "C" + LTRIM$(RTRIM$(STR$(cv))): GOTO 3
IF x = -2 THEN x = (POS(0) * 8) - 7: g = -2
IF y = -2 THEN y = CSRLIN * 16: n = -2
IF x = -3 THEN x = Wxyz(2) + 7
IF y = -3 THEN y = Wxyz(1) + 35
d$ = "BM" + LTRIM$(RTRIM$(STR$(x))) + "," + LTRIM$(RTRIM$(STR$(y))) + " C" + LTRIM$(RTRIM$(STR$(cv)))
3 DRAW "X" + VARPTR$(d$)
Font t$, cv
IF g = -2 THEN LOCATE CSRLIN, POS(0) + LEN(t$)
IF n = -2 THEN LOCATE CSRLIN + 1, 1
END SUB

SUB SCapt (f$)
DEF SEG = &HA000
BSAVE f$, 0, 64000
END SUB

SUB setmodemoption
COLOR 2
InputBox 70, 70, portno$, "COM(1 or 2): "
InputBox 70, 70, speed$, "Modem Speed: "
comport$ = "COM" + portno$ + ":" + speed$
OPEN "BASTerm.CFG" FOR OUTPUT AS #2
PRINT #2, comport$
CLOSE #2
END SUB

SUB SLEEP2 (t)
a = TIMER
DO UNTIL TIMER >= a + t: LOOP
END SUB

SUB SLoad (f$)
DEF SEG = &HA000
BLOAD f$, 0
END SUB

SUB TextBx (SX, SY, eX, Ey, t$, r, l, pw$, tb$, del)
IF LEN(tb$) > l AND r = 1 THEN tb$ = MID$(tb$, 1, l)
t$ = tb$: w = LEN(tb$)
IF del = 1 THEN ds = 0 ELSE ds = LEN(tb$)
IF LEN(pw$) > 1 THEN pw$ = LEFT$(pw$, 1)
LINE (SX - 1, SY - 1)-(eX + 1, Ey + 1), 0, B
LINE (SX, SY)-(eX, Ey), 15, BF
MX$ = "M" + STR$(SX + 2) + "," + STR$(Ey - 0)
DRAW "BX" + VARPTR$(MX$)
IF pw$ = "" THEN Font tb$, 0 ELSE Font STRING$(LEN(tb$), pw$), 0
IF r = 1 THEN  ELSE EXIT SUB
12 a$ = INKEY$
IF a$ = "" GOTO 12
IF a$ = CHR$(8) THEN IF LEN(t$) - ds = 0 THEN GOTO 12 ELSE t$ = LEFT$(t$, LEN(t$) - 1): w = w - 1: LINE (SX - 1, SY - 1)-(eX + 1, Ey + 1), 0, B: LINE (SX, SY)-(eX, Ey), 15, BF: DRAW "BX" + VARPTR$(MX$): IF pw$ = "" THEN Font t$, 0: GOTO 12 ELSE Font STRING$(LEN(t$), pw$), 0: GOTO 12
IF a$ = CHR$(13) THEN EXIT SUB
IF w >= l THEN GOTO 12
t$ = t$ + a$: w = w + LEN(a$)
B$ = a$
IF pw$ = "" THEN Font B$, 0 ELSE Font pw$, 0
GOTO 12
END SUB

SUB UnLoadFont
FOR q = 0 TO 255
txt(q) = ""
NEXT q
END SUB

SUB waitforcall
CLS : BackGround C
Window2 630, 470, 0, 0, "Terminal Emulation"
COLOR 3
opencom
PRINT #1, "ATS0=1"
connect
END SUB

SUB Window2 (Length, Height, Row, Column, tt$)
Wxyz(1) = Row
Wxyz(2) = Column
Wxyz(3) = Row + Height
Wxyz(4) = Column + Length
LINE (Column, Row)-(Column + Length, Row + Height), 0, B
FOR i% = 1 TO 2
Row = Row + 1: Column = Column + 1: Height = Height - 1: Length = Length - 1
LINE (Column, Row)-(Column + Length, Row), 7
LINE (Column, Row)-(Column, Row + Height), 7
NEXT i%
Row = Row + 1: Column = Column + 1: Height = Height - 1: Length = Length - 1
LINE (Column, Row)-(Column + Length, Row), 0
LINE (Column, Row)-(Column, Row + Height), 0
LINE (Column, Row)-(Column + 18, Row + 18), 7, BF
LINE (Column, Row)-(Column + 18, Row + 18), 0, B
LINE (Column + 18, Row - 2)-(Column + 18, Row + 5), 0
LINE (Column - 2, Row + 18)-(Column + 5, Row + 18), 0
LINE (Column + 5, Row + 7)-(Column + 13, Row + 9), 15, BF: LINE (Column + 5, Row + 7)-(Column + 13, Row + 9), 0, B
LINE (Column + 14, Row + 7)-(Column + 14, Row + 9), 8
LINE (Column + 6, Row + 10)-(Column + 14, Row + 10), 8, B
LINE (Column + 18, Row)-(Column + Length, Row + 18), 9, BF
LINE (Column + 18, Row)-(Column + Length, Row + 18), 0, B
LINE (Column + Length, Row - 3)-(Column + Length + 2, Row + Height), 7, BF
LINE (Column + Length, Row - 3)-(Column + Length + 3, Row + Height), 0, B
LINE (Column + Length, Row - 2)-(Column + Length, Row - 1), 7
LINE (Column + Length - 18, Row - 2)-(Column + Length - 18, Row - 1), 0
LINE (Column + Length, Row + 18)-(Column + Length + 2, Row + 18), 0
LINE (Column, Row + Height - 3)-(Column + Length, Row + Height - 3), 0, B
LINE (Column, Row + Height - 2)-(Column + Length + 2, Row + Height), 7, BF
LINE (Column - 2, Row + Height)-(Column + Length + 2, Row + Height), 0, B
LINE (Column - 2, Row + Height - 18)-(Column, Row + Height - 18), 0
LINE (Column + Length - 2, Row + Height - 18)-(Column + Length + 2, Row + Height - 18), 0
LINE (Column + 18, Row + Height)-(Column + 18, Row + Height - 2), 0
LINE (Column + Length - 18, Row + Height)-(Column + Length - 18, Row + Height - 2), 0
LINE (Column + 1, Row + 19)-(Column + Length - 1, Row + Height - 4), 7, BF
mm$ = "BM" + RTRIM$(LTRIM$(STR$(Column + 20))) + "," + LTRIM$(RTRIM$(STR$(Row + 17)))
DRAW "X" + VARPTR$(mm$)
Font tt$, 0
END SUB

