DECLARE SUB proctext (text$)
DECLARE SUB gnpart (cmd$, otxt$, q!)
DECLARE SUB lpword (x!, y!, text$)
DECLARE SUB LPAC (x!, y!, CH$)
DECLARE SUB wcwait ()
DECLARE SUB wline (x!, y!, a!, b!, C!)
DECLARE SUB wcircp (aa!, bb!, s!, cc!)
DECLARE SUB wcirc (aa!, bb!, s!, cc!)

DIM SHARED PROGRAMARRY$(200)

REM
REM
REM

REM virtual qbasic object
REM screen saver
SCREEN 12
HSIZE = 640
VSIZE = 400
DO
KE$ = INKEY$

H = INT(RND(1) * HSIZE) + 1
V = INT(RND(1) * VSIZE) + 1
CIRCLE (H, V), 30, C
C = C + 1: IF C > 16 THEN C = 0


LOOP UNTIL KE$ = CHR$(27)


REM set os back to prompt

RUN "COCOROM.bas"

SUB gnpart (cmd$, otxt$, q)

ll = LEN(cmd$)
IF q <= (ll) THEN
IF q = 0 THEN q = 1

otxt$ = ""
CH$ = ""

DO

  CH$ = MID$(cmd$, q, 1)

IF CH$ <> "," AND CH$ <> ":" AND CH$ <> "(" AND CH$ <> ")" AND CH$ <> CHR$(32) AND CH$ <> CHR$(34) THEN
otxt$ = otxt$ + CH$
END IF

IF q <= (ll) THEN
  q = q + 1

END IF


LOOP UNTIL CH$ = CHR$(13) OR CH$ = ":" OR CH$ = "," OR CH$ = CHR$(34) OR CH$ = CHR$(32) OR q >= (ll)

END IF

END SUB

SUB LPAC (x, y, CH$)

  
IF x <= 79 THEN




PRINT #1, "LP" + STR$(x) + STR$(y) + " " + CH$ + CHR$(13)

 CALL wcwait
END IF

IF y < 1 THEN y = 1
IF y > 22 THEN y = 22

IF x > 79 THEN
z = x - 79
IF z > 79 THEN z = 79
LOCATE y, z
PRINT CH$;

'PRINT #1, "GO"; CHR$(13)

END IF
END SUB

SUB lpword (x, y, text$)

   L = LEN(text$)
    cl = 1
    FOR b = x TO (x + L)
   
    CH$ = MID$(text$, cl, 1)

    CALL LPAC(b, y, CH$)
     cl = cl + 1

    NEXT b

    CALL wcwait

END SUB

SUB proctext (text$)
 LOCATE 22, 1: PRINT text$

 IF text$ <> "" THEN

 text$ = UCASE$(text$)

 text$ = text$ + " "

 word$ = ""
 L = LEN(text$)
 x = 1
 CALL gnpart(text$, otxt$, q): word$ = otxt$
 CALL gnpart(text$, otxt$, q): P1$ = otxt$
 CALL gnpart(text$, otxt$, q): P2$ = otxt$
 CALL gnpart(text$, otxt$, q): P3$ = otxt$
 CALL gnpart(text$, otxt$, q): P4$ = otxt$
 CALL gnpart(text$, otxt$, q): P5$ = otxt$
 CALL gnpart(text$, otxt$, q): P6$ = otxt$
 CALL gnpart(text$, otxt$, q): P7$ = otxt$
 CALL gnpart(text$, otxt$, q): P8$ = otxt$


   V1 = VAL(P1$)
   V2 = VAL(P2$)
   V3 = VAL(P3$)
   V4 = VAL(P4$)
   V5 = VAL(P5$)
   V6 = VAL(P6$)
   V7 = VAL(P7$)
   V8 = VAL(P8$)

 
  LNV = VAL(word$)
  IF LNV > 0 OR word$ = "0" THEN
  PROGRAMARRY$(LNV) = P1$

  IF LNV > (PROGLENGTH) THEN PROGLENGTH = LNV

  END IF




' SLEEP

 SELECT CASE (word$)
 CASE IS = "LP"
  W = V1
  E = V2
  CH$ = P3$
 
 
   CALL LPAC(W, E, CH$)

 CASE IS = "SIZE"
 SIZE = V1
 CASE IS = "C", "CIRC"
 CIRCLE (V1, V2), V3, V4




 CASE IS = "LINE", "L"
   
 LINE (V1, V2)-(V3, V4), V5


 CALL wcwait
 '
 ' "GO"; CHR$(13)

 CASE IS = "HEB"

  HTEXT$ = P1$
 CASE IS = "CP"
    CIRCLE (V1, V2), V3, V4
    PAINT (V1, V2), V4




 CASE IS = "CIRCLE", "CIRC", "C"

    CIRCLE (V1, V2), V3, V4

 CASE IS = "CAD"
 CLOSE #1
 OPEN ROOT$ + "CADOBJ.DAT" FOR OUTPUT AS #1
 PRINT "BUILDING CAD DATA"

 PRINT #1, swth / 2
 PRINT #1, shht / 2
 PRINT #1, CHR$(34) + P1$ + CHR$(34)
 CLOSE #1
 CHAIN ROOT$ + "QBCAD.BAS"


 CASE IS = "BASIC"
 'CALL LEAVEOS9(word$)

 CASE IS = "GOTO"
  LNGOTO = VAL(P1$)



 CASE IS = "CLS"
 'CALL clprompt
 CASE IS = "RUN"

 ' CALL PROGRUN

 CASE IS = "SAVE"
  'CALL SVPROGRAM(P1$)


 CASE IS = "LOAD"
  'CALL LDPROGRAM(P1$)


 CASE IS = "SAY"
 'speaker (P1$)
   CLS
 CASE IS = "AUXOUT"
  IF auxsp > 0 THEN PRINT #12, P1$


 CASE IS = "EXIT", "REBOOT"

  CLS

  PRINT " REBOOT WILL TAKE YOU TO CoCoROM"
  INPUT " EXIT TO DOS OR MS WINDOWS "; choice$

   choice$ = UCASE$(choice$)

   SELECT CASE (choice$)
    CASE IS = "DOS"
    SYSTEM

    CASE IS = "REBOOT"
    CLS
    PRINT "GOING INTO COCO ROM"
    PRINT "PLEASE WAIT..."

    RUN "C:\QBASIC\COCOROM.BAS"

   END SELECT


 CASE IS = "QBASIC"
  CLS

  PRINT " EXITING TO QBASIC ... "
  END
 CASE IS = "SCREEN"
  SCREEN VAL(P1$)

 CASE IS = "LPRINT"

 IF prnbr = 0 THEN LPRINT P1$

 SELECT CASE (prnsd$)
 CASE IS = "S"
 prnouttext$ = P1$
 CASE IS = "P"
 LPRINT P1$


 CASE IS = "PRINT", "?"
  PRINT P1$


 CASE IS = "CLS"
 CLS

 CASE IS = "COPYOS"
 RUN "c:\qbasic\cocorom.bas"



 CASE IS = "SCREENSAVER"
  RUN "c:\qbasic\SCREENS.BAS"


 CASE IS = "VGA"
 'CALL VGA

 CASE IS = "REMOTE"
  'CALL REMOTE

 CASE IS = "LIST"

  'CALL lstprog
 ' IF P1$ <> "" THEN 'CALL FILELIST(P1$)
 CASE IS = "RS232", "MODEM"
   'CALL RS232



 END SELECT


 CASE IS = "CLOCK"
 CLS
 PRINT " getting clock ...."
 PRINT "       please wait"
 'CALL diskgr
 RUN "C:\QBASIC\clock1.bas"



 CASE IS = "BEEP"
 BEEP
 CASE IS = "FILES"
   CHDIR "C:\QBASIC"

   SHELL "DIR *.COB"
   SLEEP

 CASE IS = "DIR"
 CLS
 FILES
 SLEEP
 CLS
 CASE IS = "DISKCOPY"
 RUN "C:\QBASIC\DISKCOPY.BAS"

 CASE IS = "PLAY"
  PLAY P1$

 CASE IS = "DRAW"
  DRAW P1$
 CASE IS = "SHELL"
  SHELL P1$
  PRINT " ### DONE  ### "

  SLEEP
  CLS
  PRINT "PLEASE WAIT..."

  CASE IS = "WINDOWS", "GUI", "OS9"
  RUN "C:\QBASIC\QBWIN01.BAS"

 END SELECT




 text$ = ""
 ' 10, 1: PRINT STRING$(20, " ")

END IF
END SUB

SUB wcirc (aa, bb, s, cc)







 IF aa <= 640 THEN
 PRINT #1, "C" + STR$(aa) + STR$(bb) + STR$(s) + STR$(cc) + CHR$(13)

CALL wcwait

 END IF

 IF aa > 640 THEN


       y = bb
       x = aa - 640

       CIRCLE (x, y), s, cc





 END IF





END SUB

SUB wcircp (aa, bb, s, cc)









 IF aa <= 640 THEN
 PRINT #1, "Cp" + STR$(aa) + STR$(bb) + STR$(s) + STR$(cc) + CHR$(13)

CALL wcwait

 END IF


 IF aa > 640 THEN


       y = bb
       x = aa - 640

       CIRCLE (x, y), s, cc
       PAINT (x, y), cc




 END IF




END SUB

SUB wcwait


 tl = 0
 DO

 LOCATE 1, 1

IF DUAL = 1 THEN IF LOC(1) <> 0 THEN INPUT #1, a$: PRINT a$


 IF TIME$ <> (ltime$) THEN
  ltime$ = TIME$: tl = tl + 1
 END IF

 z$ = INKEY$

 LOOP UNTIL a$ = "GO" OR tl > 3 OR z$ = CHR$(32) OR a$ = "T"




 



END SUB

SUB wline (x, y, a, b, C)






  IF x >= 640 THEN

  LINE (x - 640, y)-(a, b), C
  END IF
  IF a >= 640 THEN
  LINE (x, y)-(640 - a, b), C

  END IF



  IF DUAL = 1 THEN PRINT #1, "l" + STR$(x) + STR$(y) + STR$(a) + STR$(b) + STR$(C) + CHR$(13)




CALL wcwait


END SUB

