iOS Source Code

This is Version 1.19, July 24, 2006. This version will run in QBasic v1.0 and v1.1. For a compilable version, see the iOS ZIP file.


' iOS! The Innovative Technologies Interactive Operating System
' (C) 2006 i-TECH and Kristopher Windsor

DECLARE SUB bounce2 ()
DECLARE SUB boxblaster ()
DECLARE SUB calendar ()
DECLARE FUNCTION daysinmonth (month AS INTEGER, year AS INTEGER)
DECLARE SUB display (code)
DECLARE SUB displayappwindow (text$)
DECLARE FUNCTION driveready (drive$)
DECLARE SUB duetoday ()
DECLARE SUB getpic (x, y, maxx, maxy)
DECLARE SUB help ()
DECLARE SUB hiddenmission ()
DECLARE SUB incoming ()
DECLARE SUB icons (text$, itype$, x, y, bg)
DECLARE SUB intro ()
DECLARE SUB jotit (filename$)
DECLARE SUB leftclick (name$, extension$, path$, x, y)
DECLARE FUNCTION menu (title$, item1$, item2$, item3$, item4$, item5$, item6$, item7$, x, y)
DECLARE SUB minitext (text$, x, y, bg, fg)
DECLARE SUB messagewindow (text$, x, y, delay)
DECLARE SUB options ()
DECLARE SUB readbrowserfiles ()
DECLARE SUB readdicons ()
DECLARE SUB resettimer ()
DECLARE SUB savetemp ()
DECLARE FUNCTION selectfile$ ()
DECLARE SUB screensaver ()
DECLARE SUB sleeep (time)
DECLARE FUNCTION typein$ (info$, max, x, y)
DECLARE SUB MouseDriver (ax AS INTEGER, bx AS INTEGER, cx AS INTEGER, dx AS INTEGER)
DECLARE FUNCTION MouseExists% ()
DECLARE SUB MouseShow ()
DECLARE SUB MouseHide ()
DECLARE SUB MouseStatus (mouseX, mouseY, leftB, rightB, middleB)
DECLARE SUB MousePosition (newX, newY)
DECLARE SUB MouseSetArea (x1, y1, x2, y2)
DECLARE SUB MouseLastPress (button, x, y)

COMMON SHARED bc, dc, fc, tc, bicount, browser, dicount, startmenu, started
COMMON SHARED pi, nextspeed, drive$, time, hmission
COMMON SHARED bacross, drows, mt, mtime, ttime, bpath$, saverdelay, shellcmd
COMMON SHARED whichscreensaver, path$, inappcount, mappc

CONST true = -1, false = 0, left = 0, RIGHT = 1, CENTER = 2
ON KEY(31) GOSUB quickexit: KEY(31) ON

SCREEN 13: WIDTH 40, 25: CLS
COLOR 9: GOSUB displaylogo: SLEEP 1

SHELL "CD >path.tmp"
OPEN "path.tmp" FOR INPUT AS #1: INPUT #1, drive$: CLOSE #1
drive$ = LEFT$(drive$, 3)

path$ = drive$ + "ITECH\MISC\IOS": GOSUB loadinapps: GOSUB loadfiles: ON ERROR GOTO handling

bicount = 0
CONST brows = 15
copy = 1
copy$ = ""
CONST email$ = "kristopherwindsor@yahoo.com"
pi = ATN(1) * 4
DIM SHARED pic%(1 TO 9000)
spinningcircle = 0
started = false
startmenu = 0
CONST version = 1.192

DIM SHARED ac$(1 TO 16, 1 TO 3), bi$(256, 1 TO 2), di$(1 TO 128, 1 TO 3): readbrowserfiles

ntime = TIMER: FOR a = 1 TO 200000: NEXT a
nextspeed = 200000 / (TIMER - ntime)
FOR a = 26 TO 16 STEP -1: COLOR a: GOSUB displaylogo: sleeep 1 / a: NEXT a

SCREEN 12: MouseSetArea 2, 2, 637, 477: x = 320: y = 240: MousePosition x, y: MouseShow
RANDOMIZE TIMER: key$ = "": framecount = 0: quit = false: time = TIMER: resettimer

IF newbie THEN intro ELSE GOSUB autoclicks

started = true: display 1
IF upgrade THEN messagewindow "You have upgraded from Version" + STR$(lastversion) + " to Version" + STR$(version) + ". The old data has been erased.", 128, 150, 1
leftclick "Welcome", " px OR y <> py OR lb <> prb OR rb <> prb OR lb OR rb OR key$ <> "" THEN mtime = ptime

SELECT CASE LCASE$(key$)
CASE " ": bpath$ = "Programs": readbrowserfiles
CASE "b": browser = 1 - browser: display (2 + browser)
CASE "c", "t": display 5: messagewindow "The time is " + TIME$, 256, 150, 1
CASE "f": messagewindow "The program has looped" + STR$(framecount) + " times.", x, y, 1: spinningcircle = 1
CASE "h", CHR$(0) + CHR$(59): help
CASE "k": hiddenmission
CASE "o": options
CASE "r": IF browser = 1 THEN display 6: readbrowserfiles ELSE display 1
CASE "s", "z": startmenu = 1 - startmenu: display (2 + startmenu * 2)
END SELECT

IF startmenu = 1 AND x < 68 AND y > 341 AND y < 361 + mappc * 10 AND psmy <> y THEN
 MouseHide
 IF psmy > 0 THEN LINE (1, 369 + INT((psmy - 361) / 10) * 10)-(67, 369 + INT((psmy - 361) / 10) * 10), bc
 psmy = y: LINE (1, 369 + INT((y - 361) / 10) * 10)-(67, 369 + INT((y - 361) / 10) * 10), fc
 MouseShow
END IF

IF ((plb = false AND lb) OR (prb = false AND rb)) AND x < 400 AND y < 460 AND (x > 69 OR y < 330) AND startmenu = 1 THEN startmenu = 0: display 2

IF plb = false AND lb THEN
 z = INT(x / 40) * drows + INT((y - 10) / 30)
 IF x < 400 AND z = 0 THEN browser = 1: leftclick "My Computer", " 0 AND z <= dicount AND y > 9 AND y - 10 < drows * 30 AND (startmenu = 0 OR (y < 330 AND x > 68)) THEN leftclick (di$(z, 1)), (di$(z, 2)), (di$(z, 3)), x, y
 IF browser = 1 AND x > 400 THEN
 IF x > 400 AND x < 603 AND y >= 2 AND y <= 7 THEN newpath$ = typein$("Goto Directory: (8-character names only)", 38, 403, 12): IF newpath$ <> "" THEN IF INSTR(newpath$, ":\") = 0 AND newpath$ <> "My Computer" AND newpath$ <> "Programs" THEN bpath$ = drive$ + newpath$: readbrowserfiles ELSE bpath$ = newpath$: readbrowserfiles
 IF x > 603 AND x < 615 AND y >= 2 AND y <= 7 AND bacross > 0 THEN bacross = bacross - 1: display 3
 IF x > 619 AND x < 631 AND y >= 2 AND y <= 7 AND (bacross + 4) * brows < bicount THEN bacross = bacross + 1: display 3
 'z is icon number. if z=0 then on the UP button
 z = INT((x - 400) / 40) * brows + INT((y - 10) / 30) + bacross * brows
 SELECT CASE bpath$
 CASE "My Computer": z = z + 1: IF z <= bicount AND y > 9 AND y < 460 THEN leftclick (bi$(z, 1)), (bi$(z, 2)), RIGHT$(bi$(z, 1), 1) + ":\", x - 20, y - 12
 CASE ELSE: IF z - bacross * brows = 0 THEN GOSUB moveup: readbrowserfiles ELSE IF z <= bicount AND z >= 0 AND y > 9 AND y < 460 THEN leftclick (bi$(z, 1)), (bi$(z, 2)), bpath$, x - 20, y - 12
 END SELECT
 END IF
 IF startmenu = 1 AND x < 68 AND y > 341 THEN
  IF y > 341 AND y < 351 THEN bpath$ = "Programs": readbrowserfiles
  IF y > 351 AND y < 351 + mappc * 10 THEN leftclick STR$(INT((y - 351) / 10) + 1), " 351 + mappc * 10 AND y < 361 + mappc * 10 THEN choice = menu("Exit iOS?", "Yes", "No", "", "", "", "", "", 12, 402): IF choice = 1 THEN quit = true
  resettimer
 END IF
 IF x > 69 AND x < 119 AND y > 462 AND y < 477 THEN browser = 1 - browser: display (2 + browser)
 IF x > 9 AND x < 59 AND y > 462 AND y < 477 THEN startmenu = 1 - startmenu: display (2 + startmenu * 2)
 IF x > 576 AND x < 626 AND y > 462 AND y < 477 THEN display 5: messagewindow "It is " + TIME$ + " on " + DATE$ + ".", 256, 150, 1
END IF

IF prb = false AND rb THEN
 z = INT(x / 40) * drows + INT((y - 10) / 30)
 IF x < 400 AND z <= dicount AND y - 10 < drows * 30 THEN IF z > 0 THEN GOSUB desktoprightclick ELSE IF hmission = 3 THEN hmission = 4: hiddenmission
 z = INT((x - 400) / 40) * brows + INT((y - 10) / 30) + bacross * brows
 IF bpath$ = "My Computer" THEN z = z + 1
 IF browser = 1 AND x > 400 AND z > 0 AND z <= bicount AND y > 9 AND y < 460 THEN
  SELECT CASE bpath$
  CASE "My Computer", "Programs"
  GOSUB newshortcut
  CASE ELSE
  GOSUB browserrightclick
  END SELECT
 END IF
 IF x > 576 AND x < 626 AND y > 462 AND y < 477 THEN
  display 5: choice = menu("Clock", "Change the Time", "Change the Date", "", "", "", "", "", 576, 434)
  ON ERROR GOTO invalidtime
  SELECT CASE choice
  CASE 1
   TIME$ = typein$("Enter the new time in the form HH:MM:SS:", 8, 256, 150)
   IF hmission = 1 THEN hmission = 2: hiddenmission
  CASE 2: DATE$ = typein$("Enter the new date in the form MM-DD-YYYY:", 10, 256, 150)
  END SELECT
  ON ERROR GOTO handling: display 5
 END IF
END IF

'timed events
ttime = INT(TIMER - time)
IF ttime > ptime THEN
 IF ttime / 60 = INT(ttime / 60) THEN display 5
 IF ttime - mtime > saverdelay THEN screensaver: display 1: resettimer
END IF
ptime = ttime

IF spinningcircle = 1 THEN
 LINE (320, 240)-(320 + COS((framecount - 1) / 50) * 20, 240 + SIN((framecount - 1) / 50) * 20), dc
 CIRCLE (320, 240), 20, tc
 LINE (320, 240)-(320 + COS(framecount / 50) * 20, 240 + SIN(framecount / 50) * 20), tc
END IF

key$ = INKEY$
framecount = framecount + 1: WEND: savetemp

dc = 0: bc = 0: fc = 8: tc = 8: display 7
fc = 0: tc = 0: display 5
bc = 9: fc = 6: tc = 0: messagewindow "Goodbye!", 256, 150, 0
OPEN "log.txt" FOR APPEND AS #1: PRINT #1, "iOS properly closed by user at " + TIME$ + " on " + DATE$ + ".": CLOSE #1
COLOR 0: sleeep 1.5: SYSTEM

autoclicks:
ON ERROR GOTO missingautoclicks: OPEN "auto.txt" FOR INPUT AS #7: ON ERROR GOTO handling
LINE INPUT #7, ac1$: ac = 0
WHILE NOT EOF(7): ac = ac + 1: INPUT #7, ac$(ac, 1), ac$(ac, 2), ac$(ac, 3): WEND
CLOSE #7
FOR a = 1 TO ac: leftclick (ac$(a, 1)), (ac$(a, 2)), (ac$(a, 3)), 256, 150: NEXT a
ERASE ac$: RETURN

browserrightclick:
lb = true: plb = lb
IF LEN(bpath$) = 3 THEN fix$ = "" ELSE fix$ = "\"
IF bi$(z, 2) = " 600), y + 37 * (y > 422))
SELECT CASE choice
CASE 1'new folder
newname$ = typein$("Enter the new folder name:", 8, 405, y + (y > 422) * 37)
valid = 1: ON ERROR GOTO foldererror: MKDIR bpath$ + fix$ + newname$
ON ERROR GOTO handling
readbrowserfiles
CASE 2'cut
 copy$ = bpath$ + fix$ + name$: copyname$ = name$: copytype$ = bi$(z, 2): copy = 1
CASE 3'copy
 copy$ = bpath$ + fix$ + name$: copyname$ = name$: copytype$ = bi$(z, 2): copy = 2
CASE 4'paste
 IF LEN(copy$) = 0 THEN
  messagewindow "There is nothing to paste.", 405, y + (y > 422) * 37, 1
 ELSE
  SCREEN 0: CLS : LOCATE 1, 1
  IF copy = 1 THEN 'for cut
   MouseHide
   IF shellcmd = 1 THEN SHELL "CMD /C MOVE /Y " + copy$ + " " + bpath$ + fix$ + copyname$ + " >info.tmp" ELSE SHELL "COMMAND /C MOVE /Y " + copy$ + " " + bpath$ + fix$ + copyname$ + " >info.tmp"
   copy$ = ""
  ELSE 'for copy
   IF copytype$ = "info.tmp" ELSE SHELL "ECHO D | COMMAND /C XCOPY " + copy$ + " " + bpath$ + fix$ + copyname$ + " /E >info.tmp"
   ELSE
    SHELL "ECHO F | XCOPY " + copy$ + " " + bpath$ + fix$ + copyname$ + " >info.tmp"
   END IF
  END IF
  SCREEN 12: MouseShow: display 6
  readbrowserfiles
 END IF
CASE 5: GOSUB newshortcut
CASE 6'delete
 IF menu("Delete " + bpath$ + fix$ + name$ + "?", "Yes", "No", "", "", "", "", "", x + 40 * (x > 600), y + 37 * (y > 422)) = 1 THEN
  IF bi$(z, 2) = "info.tmp" ELSE SHELL "ECHO Y | DEL " + bpath$ + fix$ + name$ + "\*.* >info.tmp": SHELL "RMDIR " + bpath$ + fix$ + name$ + " >info.tmp"
   SCREEN 12: MouseShow: display 6
  ELSE
   KILL bpath$ + fix$ + name$
  END IF
  readbrowserfiles
 END IF
CASE 7'rename
 newname$ = typein$("Enter a new file name for " + name$ + ":", 8, x - 32, y)
 valid = true
 FOR a = 1 TO 11
  IF INSTR(newname$, MID$(" ,.;:<>/?*" + CHR$(34), a, 1)) > 0 THEN valid = false
 NEXT a
 IF valid THEN
  IF bi$(z, 2) = "info.tmp" ELSE SHELL "COMMAND /C MOVE /Y " + bpath$ + fix$ + name$ + " " + bpath$ + fix$ + newname$ + " >info.tmp"
   SCREEN 12: MouseShow: display 6
  ELSE
   SHELL "REN " + bpath$ + fix$ + name$ + " " + newname$ + "." + bi$(z, 2) + " >info.tmp"
  END IF
  readbrowserfiles
 ELSE
  messagewindow "Invalid filename!", x - 32, y, 1
 END IF
END SELECT
RETURN

builtinprogramdata:
DATA 9
DATA "Blaster
DATA "Bounce 2"
DATA "Calendar"
DATA "DueToday"
DATA "Help"
DATA "Incoming"
DATA "Jotit
DATA "Options"
DATA "Welcome"

desktoprightclick:
lb = true: plb = lb
IF LEN(di$(z, 3)) = 3 THEN fix$ = "" ELSE fix$ = "\"
IF di$(z, 2) = " 2 THEN resumenext = 1
END SELECT
IF resumenext = 0 THEN RESUME ELSE RESUME NEXT

invalidtime:
messagewindow "Your time or date entry is invalid!", 256, 150, 1
RESUME NEXT

jsaveerrors:
mt = menu("The file cannot be saved!", "Auto-name file", "Cancel", "", "", "", "", "", 69, 0)
RESUME NEXT

loadfiles:
ON ERROR GOTO resumenext: CHDIR drive$: MKDIR "ITECH": MKDIR "ITECH\MISC": MKDIR path$ + "\My_Docs"
newbie = false: ON ERROR GOTO missingpath: CHDIR path$
ON ERROR GOTO missingversion: OPEN "version.txt" FOR INPUT AS #1: INPUT #1, lastversion: CLOSE #1
ON ERROR GOTO resumenext: upgrade = false
IF version < lastversion THEN LOCATE 12, 6: PRINT "This is an old version of iOS": LOCATE 13, 7: PRINT "Please use the latest version": SLEEP: SYSTEM
IF version > lastversion THEN
 upgrade = true: KILL "b2data.txt": KILL "dicons.txt": OPEN "version.txt" FOR OUTPUT AS #1: WRITE #1, version: CLOSE #1
 IF lastversion < 1.16 THEN KILL "inscores.txt": KILL "options.txt": KILL "temp.txt"
END IF
ON ERROR GOTO missingoptions: OPEN "options.txt" FOR INPUT AS #1: INPUT #1, dc, fc, tc, bc: INPUT #1, whichscreensaver, saverdelay: INPUT #1, shellcmd: CLOSE #1
ON ERROR GOTO missingtemp: OPEN "temp.txt" FOR INPUT AS #1: INPUT #1, bpath$, browser, hmission: CLOSE #1: hmission = INT(SQR(hmission * 5 + 4) - 2.98)
ON ERROR GOTO resumenext: OPEN "log.txt" FOR APPEND AS #1: PRINT #1, "iOS Version" + STR$(version) + " started at " + TIME$ + " on " + DATE$: CLOSE #1
OPEN "autoexec.bat" FOR APPEND AS #1: CLOSE #1
readdicons
RETURN

loadinapps:
RESTORE builtinprogramdata: READ inappcount: DIM SHARED inapp$(1 TO inappcount)
FOR a = 1 TO inappcount: READ inapp$(a): NEXT a
IF inappcount > 9 THEN mappc = 9 ELSE mappc = inappcount
RETURN

missingautoclicks:
z = FREEFILE
OPEN "auto.txt" FOR OUTPUT AS #z
PRINT #z, "This is a list of commands for iOS to run after starting. You can add to the end of this list."
WRITE #z, "AUTOEXEC", "BAT", path$
WRITE #z, "DRIVE " + LEFT$(drive$, 1), " 125 THEN
 messagewindow "The Desktop is full!", 405, y + (y > 422) * 37, 1
ELSE
 dicount = dicount + 1: di$(dicount, 1) = bi$(z, 1): di$(dicount, 2) = bi$(z, 2)
 IF bi$(z, 2) = " tt(level) THEN
    IF tt(level) THEN MouseShow: messagewindow "You got a new record time! (Time left:" + STR$(gtime - framecount) + ")", 75, 20, 1: MouseHide
    tt(level) = gtime - framecount
   END IF
   level = level + 1
  END IF
  IF level > 10 THEN GOSUB victory
 ELSE
  MouseShow
  MousePosition 182, 140
  IF menu("Game Over", "Continue", "Quit", "", "", "", "", "", 175, 128) = 2 THEN quit = 1
  MouseHide
 END IF
WEND

display 1
MouseShow
OPEN "b2data.txt" FOR OUTPUT AS #1: WRITE #1, level, unlocked, delay: FOR a = 1 TO 10: WRITE #1, tt(a): NEXT a: CLOSE #1
resettimer
EXIT SUB

displaybounceinfo:
IF mission = 1 THEN minitext "Mission Level" + STR$(level) + " | Time Left:" + STR$(gtime - framecount) + " | Lives:" + STR$(lives) + " Points Left:" + STR$(goal - score) + " ", minx + 1, miny + 1, bg, 15 ELSE minitext "Bonus Mode | Score:" + STR$(score) + " | Time:" + STR$(framecount) + " | Lives:" + STR$(lives), minx + 1, miny + 1, bg, 15
RETURN

game:
GOSUB displaybounceinfo
death = -dtime - 1: framecount = 0: score = 0: win = 0: xv = 0: yv = 0: key$ = ""
WHILE framecount < gtime AND win = 0
IF INT(framecount / 100) = framecount / 100 THEN GOSUB displaybounceinfo
IF key$ = CHR$(0) + CHR$(75) THEN xv = -8
IF key$ = CHR$(0) + CHR$(77) THEN xv = 8
IF key$ = " " THEN xv = 0
IF key$ = CHR$(0) + CHR$(72) AND delay > 0 THEN delay = delay - .005
IF key$ = CHR$(0) + CHR$(80) AND delay < .6 THEN delay = delay + .005
IF key$ = "k" AND mission = 0 THEN esize = esize - guysize: guysize = INT((RND * 15) ^ 2) + 1: esize = esize + guysize
IF framecount > death + dtime AND gtime > framecount + 60 THEN die = 0: yv = yv + .6: y = y + yv ELSE die = 1
IF y + guysize > maxy AND death + dtime < framecount THEN death = framecount: lives = lives - 1: GOSUB displaybounceinfo
IF death + dtime = framecount AND gtime > framecount + 60 THEN x = minx + guysize: y = miny + guysize + 27: xv = 0: yv = 0
IF weather > 0 THEN GOSUB weather: sleeep delay / 2 ELSE sleeep delay'slows game :-8
IF framecount > death + dtime THEN GOSUB points: GOSUB mound
GOSUB guy
IF enemy THEN GOSUB enemy
IF score >= goal THEN win = 1
IF lives = 0 AND gtime > framecount + 60 THEN gtime = framecount + 60
IF key$ = CHR$(13) THEN SLEEP
IF key$ = CHR$(27) AND gtime > framecount + 60 THEN gtime = framecount + 60
key$ = INKEY$
framecount = framecount + 1: WEND
minitext "Bounce 2: Game Over!" + SPACE$(50), minx + 1, miny + 1, bg, 15
RETURN

guy:
IF die = 0 THEN x = x + wind + xv
IF x + guysize > maxx THEN x = maxx - guysize
IF x - guysize < minx THEN x = minx + guysize
IF py + pguysize < maxy THEN
 CIRCLE (px, py), pguysize, bg
 CIRCLE (px - pguysize / 3, py - pguysize / 4), pguysize / 5, bg
 CIRCLE (px + pguysize / 3, py - pguysize / 4), pguysize / 5, bg
 PSET (px - pguysize / 3, py - pguysize / 4), bg
 PSET (px + pguysize / 3, py - pguysize / 4), bg
 CIRCLE (px, py + pguysize / 6), pguysize / 10, bg 'nose
 CIRCLE (px, py + pguysize / 1.8), pguysize / 2, bg, pi, 0, 1 / 3
END IF
px = x: py = y: pguysize = guysize
IF y + guysize < maxy THEN
 CIRCLE (x, y), guysize, 15
 CIRCLE (x - guysize / 3, y - guysize / 4), guysize / 5, 15
 CIRCLE (x + guysize / 3, y - guysize / 4), guysize / 5, 15
 PSET (x - guysize / 3, y - guysize / 4), 15
 PSET (x + guysize / 3, y - guysize / 4), 15
 CIRCLE (x, y + guysize / 6), guysize / 10, 15 'nose
 CIRCLE (x, y + guysize / 1.8), guysize / 2, 15, pi, 0, 1 / 3
END IF
IF gtime < framecount + 60 THEN
 pdistance = ((framecount - gtime + 59) * .6) ^ 2 + 16
 distance = ((framecount - gtime + 60) * .6) ^ 2 + 16
 FOR a = 0 TO pi * 2 STEP pi / 64
  CIRCLE (x + COS(a) * pdistance, y + SIN(a) * pdistance), 2, bg
  CIRCLE (x + COS(a) * distance, y + SIN(a) * distance), 2, 4
 NEXT a
END IF
RETURN

enemy:
IF framecount = 0 THEN MouseShow: messagewindow "Your Arch Nemesis demands a dual!", 400, 200, 1: MouseHide
IF ABS(ex - p(1, 1)) > esize THEN IF ex > p(1, 1) THEN ex = ex - 2 ELSE ex = ex + 2
ey = COS(framecount / 20) * 230 + 230

CIRCLE (pex, pey), pesize, bg
CIRCLE (pex - pesize / 2, pey - pesize / 4), pesize / 5, bg, 0, pi / 2
CIRCLE (pex + pesize / 2, pey - pesize / 4), pesize / 5, bg, pi / 2, pi
PSET (pex - pesize / 2, pey - pesize / 4), bg
PSET (pex + pesize / 2, pey - pesize / 4), bg
CIRCLE (pex, pey + pesize / 5), pesize / 10, bg 'nose
CIRCLE (pex, pey + pesize / 1.8), pesize / 2, bg, pi, 0, 1 / 5
 pex = ex: pey = ey: pesize = esize
CIRCLE (ex, ey), esize, 8
CIRCLE (ex - esize / 2, ey - esize / 4), esize / 5, 8, 0, pi / 2
CIRCLE (ex + esize / 2, ey - esize / 4), esize / 5, 8, pi / 2, pi
PSET (ex - esize / 2, ey - esize / 4), 8
PSET (ex + esize / 2, ey - esize / 4), 8
CIRCLE (ex, ey + esize / 5), esize / 10, 8 'nose
CIRCLE (ex, ey + esize / 1.8), esize / 2, 8, pi, 0, 1 / 5

IF SQR((x - ex) * (x - ex) + (y - ey) * (y - ey)) < guysize + esize AND guysize > 8 THEN guysize = guysize - .1

IF SQR((ex - p(1, 1)) * (ex - p(1, 1)) + (ey - p(1, 2)) * (ey - p(1, 2))) < 8 + esize THEN
 CIRCLE (p(1, 1), p(1, 2)), 8, bg: CIRCLE (p(1, 1), p(1, 2)), 8, bg, , , 1 / 2: CIRCLE (p(1, 1), p(1, 2)), 8, bg, , , 2
 p(1, 1) = INT(RND * (maxx - minx - 17)) + minx + 8: p(1, 2) = INT(RND * (maxy - miny - 104)) + miny + 15
 score = score - 1: GOSUB displaybounceinfo
END IF
RETURN

loadlevel:
FOR a = 1 TO weathercount: weather(a, 1) = 0: weather(a, 2) = 0: weather(a, 3) = 0: weather(a, 4) = 0: NEXT a
MouseShow
MousePosition 182, 140
IF unlocked = 1 THEN choice = menu("Bounce 2", "Continue Mission", "Bonus Mode", "", "", "", "", "", 175, 128) ELSE choice = 0
IF choice < 2 THEN
 'weather, screen size, etc.
 SELECT CASE level
 CASE IS <= 4: bg = 9: minx = 70: maxx = 398: miny = 9: maxy = 458: weather = 1 + (level <= 2): weatherc = 7
 CASE IS <= 6: bg = 8: minx = 0: maxx = 398: miny = 0: maxy = 459: weather = level - 4
 CASE IS <= 8: bg = 8 + (level = 8) * 8: minx = 0: maxx = 398: miny = 0: maxy = 479: weather = 2: weatherc = 7 - (level = 8)
 CASE IS <= 10: bg = 0: minx = 0: maxx = 639: miny = 0: maxy = 479: weather = 11 - level: weatherc = 8
 END SELECT
 enemy = (level = 10)

 SELECT CASE level 'specific settings
 CASE 1
  ln$ = "Sunny Days"
  bouncepower = 10: goal = 2: gtime = 5000: guysize = 24: lives = 5: mcount = 4: newpoints = 0: pcount = 2: wind = 0
  m(1, 1) = 152: m(1, 2) = 458: m(1, 3) = 80: m(1, 4) = 0: m(1, 5) = 0
  m(2, 1) = 152: m(2, 2) = 458: m(2, 3) = 80: m(2, 4) = 1: m(2, 5) = 0
  m(3, 1) = 382: m(3, 2) = 168: m(3, 3) = 12: m(3, 4) = 0: m(3, 5) = 0
  m(4, 1) = 382: m(4, 2) = 268: m(4, 3) = 12: m(4, 4) = 0: m(4, 5) = 0
  p(1, 1) = 380: p(1, 2) = 30: p(2, 1) = 380: p(2, 2) = 80
 CASE 2
  ln$ = "A Midget's Life"
  bouncepower = 13: goal = 30: gtime = 5000: guysize = 12: lives = 4: mcount = 5: newpoints = 1: pcount = 4: wind = 0
  m(1, 1) = 152: m(1, 2) = 458: m(1, 3) = 80: m(1, 4) = 0: m(1, 5) = 0
  m(2, 1) = 152: m(2, 2) = 458: m(2, 3) = 80: m(2, 4) = 1: m(2, 5) = 0
  m(3, 1) = 152: m(3, 2) = 458: m(3, 3) = 80: m(3, 4) = 2: m(3, 5) = 0
  m(4, 1) = 152: m(4, 2) = 458: m(4, 3) = 80: m(4, 4) = 3: m(4, 5) = 0
  m(5, 1) = 234: m(5, 2) = 230: m(5, 3) = 40: m(5, 4) = 0: m(5, 5) = 0
  FOR a = 1 TO 4: p(a, 1) = 82: p(a, 2) = 400: NEXT a
 CASE 3
  ln$ = "Rainy Days"
  bouncepower = 5: goal = 4: gtime = 3000: guysize = 24: lives = 4: mcount = 6: newpoints = 1: pcount = 1: wind = 2
  m(1, 1) = 151: m(1, 2) = 458: m(1, 3) = 80: m(1, 4) = 0: m(1, 5) = 0
  m(2, 1) = 317: m(2, 2) = 458: m(2, 3) = 80: m(2, 4) = 0: m(2, 5) = 0
  m(3, 1) = 234: m(3, 2) = 320: m(3, 3) = 20: m(3, 4) = 0: m(3, 5) = 0
  m(4, 1) = 234: m(4, 2) = 240: m(4, 3) = 20: m(4, 4) = 0: m(4, 5) = 0
  m(5, 1) = 234: m(5, 2) = 180: m(5, 3) = 20: m(5, 4) = 0: m(5, 5) = 0
  m(6, 1) = 234: m(6, 2) = 140: m(6, 3) = 20: m(6, 4) = 0: m(6, 5) = 1
  p(1, 1) = 380: p(1, 2) = 30
 CASE 4
  ln$ = "Mad Mad Dash"
  bouncepower = 20: goal = 200: gtime = 2500: guysize = 28: lives = 4: mcount = 2: newpoints = 1: pcount = 8: wind = 1
  m(1, 1) = 151: m(1, 2) = 458: m(1, 3) = 80: m(1, 4) = 0: m(1, 5) = 0
  m(2, 1) = 317: m(2, 2) = 458: m(2, 3) = 80: m(2, 4) = 0: m(2, 5) = 0
  FOR a = 1 TO 8: p(a, 1) = 234: p(a, 2) = 50: NEXT a
 CASE 5
  ln$ = "Daytime no More"
  bouncepower = 9: goal = 30: gtime = 6000: guysize = 24: lives = 2: mcount = 3: newpoints = 1: pcount = 5: wind = 1
  FOR a = 1 TO 3: m(a, 1) = 50: m(a, 2) = 30 + a * 140: m(a, 3) = 40: m(a, 4) = a: m(a, 5) = 0: NEXT a
  FOR a = 1 TO 5: p(a, 1) = 234: p(a, 2) = 50: NEXT a
 CASE 6
  ln$ = "Snow Bounced"
  bouncepower = 10: goal = 30: gtime = 2000: guysize = 20: lives = 4: mcount = 5: newpoints = 1: pcount = 5: wind = 3
  FOR a = 1 TO 3: m(a, 1) = 50: m(a, 2) = 30 + a * 140: m(a, 3) = 40: m(a, 4) = 0: m(a, 5) = 0: NEXT a
  m(4, 1) = 50: m(4, 2) = 170: m(4, 3) = 60: m(4, 4) = 3: m(4, 5) = 0
  m(5, 1) = 300: m(5, 2) = 410: m(5, 3) = 60: m(5, 4) = 0: m(5, 5) = 1
  FOR a = 1 TO 5: p(a, 1) = 234: p(a, 2) = 50: NEXT a
 CASE 7
  ln$ = "Wind Freeze Factor"
  bouncepower = 15: goal = 24: gtime = 2000: guysize = 28: lives = 4: mcount = 1: newpoints = 1: pcount = 8: wind = 6
  m(1, 1) = 90: m(1, 2) = 410: m(1, 3) = 80: m(1, 4) = 3: m(1, 5) = 3
  FOR a = 1 TO 8: p(a, 1) = 234: p(a, 2) = 350: NEXT a
 CASE 8
  ln$ = "Night Giant"
  bouncepower = 22: goal = 1000: gtime = 4500: guysize = 72: lives = 1: mcount = 2: newpoints = 1: pcount = 16: wind = 4
  m(1, 1) = 234: m(1, 2) = 458: m(1, 3) = 80: m(1, 4) = -4: m(1, 5) = 0
  m(2, 1) = 234: m(2, 2) = 458: m(2, 3) = 80: m(2, 4) = 4: m(2, 5) = 0
  FOR a = 1 TO 16: p(a, 1) = 320: p(a, 2) = 220: NEXT a
 CASE 9
  ln$ = "Bounce Extreme"
  bouncepower = 30: goal = 50: gtime = 8000: guysize = 32: lives = 4: mcount = 6: newpoints = 1: pcount = 12: wind = 1
  m(1, 1) = 320: m(1, 2) = 470: m(1, 3) = 50: m(1, 4) = -1: m(1, 5) = 0
  m(2, 1) = 320: m(2, 2) = 470: m(2, 3) = 50: m(2, 4) = 1: m(2, 5) = 0
  m(3, 1) = 320: m(3, 2) = 470: m(3, 3) = 50: m(3, 4) = -2: m(3, 5) = 0
  m(4, 1) = 320: m(4, 2) = 470: m(4, 3) = 50: m(4, 4) = 2: m(4, 5) = 0
  m(5, 1) = 320: m(5, 2) = 470: m(5, 3) = 50: m(5, 4) = -3: m(5, 5) = 0
  m(6, 1) = 320: m(6, 2) = 470: m(6, 3) = 50: m(6, 4) = 3: m(6, 5) = 0
  FOR a = 1 TO 12: p(a, 1) = a * 53 + 2: p(a, 2) = -80: NEXT a
 CASE 10
  ln$ = "The Final Hour": delay = 0
  bouncepower = 10: goal = 25: gtime = 8000: guysize = 28: lives = 4: mcount = 11: newpoints = 1: pcount = 8: wind = 2
  FOR a = 1 TO 3: m(a, 1) = a * 60 - 30: m(a, 2) = 460: m(a, 3) = 20: m(a, 4) = 0: m(a, 5) = 0: NEXT a
  FOR a = 4 TO 8: m(a, 1) = a * 60 + 60: m(a, 2) = 120: m(a, 3) = 20: m(a, 4) = 0: m(a, 5) = 0: NEXT a
  m(9, 1) = 540: m(9, 2) = 230: m(9, 3) = 20: m(9, 4) = 0: m(9, 5) = 0
  m(10, 1) = 540: m(10, 2) = 340: m(10, 3) = 20: m(10, 4) = 2: m(10, 5) = 0
  m(11, 1) = 620: m(11, 2) = 500: m(11, 3) = 0: m(11, 4) = 0: m(11, 5) = 3
  esize = 32: ex = 320: ey = 300
  FOR a = 1 TO 8: p(a, 1) = a * 10 + 520: p(a, 2) = 80: NEXT a
 END SELECT
 messagewindow "Level" + STR$(level) + ": " + ln$, 175, 128, 1
 mission = 1
ELSE
 bouncepower = 18: goal = 10000: gtime = 999999: guysize = 24: lives = 99: newpoints = 1
 weather = 1: bg = 0: rc = 8: minx = 0: maxx = 639: miny = 0: maxy = 479

 mcount = VAL(typein("Number of Mounds: (1 to 16)", 2, 175, 128))
 IF mcount = 0 THEN mcount = 4 ELSE IF mcount > 16 THEN mcount = 16
 FOR a = 1 TO mcount
  m(a, 1) = INT(RND * 480) + 81: m(a, 2) = 400 + INT(RND * 80): m(a, 3) = INT(RND * 48) + 17: m(a, 4) = 3 - INT(RND * 7): m(a, 5) = INT(RND * 3)
 NEXT a

 pcount = VAL(typein("Number of Points: (1 to 16)", 2, 175, 128))
 IF pcount = 0 THEN pcount = 4 ELSE IF pcount > 16 THEN pcount = 16
 FOR a = 1 TO pcount
  p(a, 1) = INT(RND * 640): p(a, 2) = INT(RND * 360) + 40
 NEXT a

 wind = VAL(typein("Wind Speed: (-6 to 6)", 2, 175, 128))
 IF wind < -6 THEN wind = -6 ELSE IF wind > 6 THEN wind = 6

 weather = INT(VAL(typein("Weather: (1-Rain | 2-Snow)", 1, 175, 128)))
 IF weather < 0 THEN weather = 0 ELSE IF weather > 2 THEN wetaher = 2

 enemy = (INT(VAL(typein("Enemy: (0-Off | 1-On)", 1, 175, 128))) = 1)
 IF enemy THEN esize = 32: ex = 320: ey = 300

 messagewindow "Press [K] to change the bouncer's size.", 160, 150, 1
 mission = 0
END IF
MouseHide
LINE (minx, miny)-(maxx, maxy), bg, BF
x = minx + guysize: y = miny + guysize + 27: px = x: py = y: pguysize = 1
RETURN

mound:
FOR a = 1 TO mcount
IF SQR((x - m(a, 1)) * (x - m(a, 1)) + (y - m(a, 2)) * (y - m(a, 2))) < m(a, 3) + guysize AND y < m(a, 2) + guysize THEN yv = -bouncepower
IF m(a, 4) OR m(a, 5) THEN CIRCLE (m(a, 1), m(a, 2)), m(a, 3), bg, 0, pi
m(a, 1) = m(a, 1) + m(a, 4)
IF m(a, 1) + m(a, 3) > maxx THEN m(a, 4) = -ABS(m(a, 4)): m(a, 1) = maxx - m(a, 3)
IF m(a, 1) - m(a, 3) < minx THEN m(a, 4) = ABS(m(a, 4)): m(a, 1) = minx + m(a, 3)
m(a, 3) = m(a, 3) + m(a, 5)
IF m(a, 3) > 64 THEN m(a, 5) = -ABS(m(a, 5)) ELSE IF m(a, 3) < 16 THEN m(a, 5) = ABS(m(a, 5))
CIRCLE (m(a, 1), m(a, 2)), m(a, 3), mc, 0, pi
NEXT a
RETURN

points:
FOR a = 1 TO pcount
 IF p(a, 1) > 0 THEN
  IF SQR((x - p(a, 1)) * (x - p(a, 1)) + (y - p(a, 2)) * (y - p(a, 2))) < 8 + guysize THEN
   CIRCLE (p(a, 1), p(a, 2)), 8, bg: CIRCLE (p(a, 1), p(a, 2)), 8, bg, , , 1 / 2: CIRCLE (p(a, 1), p(a, 2)), 8, bg, , , 2
   IF newpoints = 1 THEN p(a, 1) = INT(RND * (maxx - minx - 17)) + minx + 8: p(a, 2) = INT(RND * (maxy - miny - 104)) + miny + 15 ELSE p(a, 1) = 0
   score = score + 1: GOSUB displaybounceinfo
  ELSE
   CIRCLE (p(a, 1), p(a, 2)), 8, 14: CIRCLE (p(a, 1), p(a, 2)), 8, 14, , , 1 / 2: CIRCLE (p(a, 1), p(a, 2)), 8, 14, , , 2
  END IF
 END IF
NEXT a
RETURN

victory:
MouseShow
messagewindow "You Win! Your Arch Nemesis has been defeated!", 150, 128, 1
IF unlocked = 0 THEN sleeep 1: messagewindow "You unlocked the bonus mode! " + CHR$(1), 175, 128, 1: unlocked = 1
IF menu("Play Again?", "Yes", "No", "", "", "", "", "", 175, 128) = 2 THEN quit = 1
MouseHide
level = 1
RETURN

weather:
a = INT(RND * weathercount) + 1: IF weather(a, 4) = 0 THEN weather(a, 1) = INT(RND * (maxx - minx)) + minx + 1: weather(a, 2) = miny + 12: weather(a, 3) = INT(RND * weathersize) + 5: weather(a, 4) = INT(RND * 6) + 6
FOR a = 1 TO weathercount

IF weather(a, 4) > 0 THEN
SELECT CASE weather
CASE 1
 LINE (weather(a, 1), weather(a, 2))-(weather(a, 1), weather(a, 2) + weather(a, 3)), bg
CASE 2
 LINE (weather(a, 1) - 1, weather(a, 2) - 1)-(weather(a, 1) + 1, weather(a, 2) + 1), bg
 LINE (weather(a, 1) + 1, weather(a, 2) - 1)-(weather(a, 1) - 1, weather(a, 2) + 1), bg
END SELECT
END IF

weather(a, 2) = weather(a, 2) + weather(a, 4)
weather(a, 1) = weather(a, 1) + wind
IF weather(a, 2) + weather(a, 3) > maxy OR weather(a, 1) - 4 < minx OR weather(a, 1) + 4 > maxx THEN weather(a, 4) = 0

IF weather(a, 4) > 0 THEN
 SELECT CASE weather
 CASE 1
  LINE (weather(a, 1), weather(a, 2))-(weather(a, 1), weather(a, 2) + weather(a, 3)), weatherc
 CASE 2
  LINE (weather(a, 1) - 1, weather(a, 2) - 1)-(weather(a, 1) + 1, weather(a, 2) + 1), weatherc
  LINE (weather(a, 1) + 1, weather(a, 2) - 1)-(weather(a, 1) - 1, weather(a, 2) + 1), weatherc
 END SELECT
END IF

NEXT a
RETURN
END SUB

SUB boxblaster

messagewindow "Loading...", 100, 21, 0
ON ERROR GOTO missingblasterdata: OPEN "blstdata.txt" FOR INPUT AS #1: ON ERROR GOTO handling: INPUT #1, highscore: CLOSE #1
messagewindow "High Score:" + STR$(highscore), 100, 21, 0: sleeep .8

MouseSetArea 70, 2, 398, 477
WHILE quit > true: GOSUB playblaster: WEND
MouseSetArea 2, 2, 637, 477
display 1: EXIT SUB

playblaster:
displayappwindow "Box Blaster!"
REDIM B%(9, 24)
i = 500: k = 70: l = 140: lives = 6: s = 25: score = 0: x = 98: xv = 1: y = 98: yv = 1: MouseHide: GOSUB bdisplay

quit = 0: WHILE quit = 0
a = INT(RND * 10): B = INT(RND * 25): IF B%(a, B) = 0 AND INT(RND * 30) = 0 THEN B%(a, B) = 1: LINE (84 + a * 30, 90 + B * 10)-(113 + a * 30, 99 + B * 10), fc, BF

pk = k: pl = l: px = x: py = y: x = x + xv: y = y + yv
IF x - s < 70 THEN xv = -xv: x = 70 + s
IF x + s > 398 THEN xv = -xv: x = 398 - s
IF y - s < 20 THEN yv = -yv: y = 20 + s: IF k > x + s OR k + l < x - s THEN GOSUB bdeath
IF y + s > 448 THEN yv = -yv: y = 448 - s: IF k > x + s OR k + l < x - s THEN GOSUB bdeath

IF mx <> pmx THEN SELECT CASE mx: CASE IS < 70: k = 70: CASE IS < 398 - l: k = mx: CASE ELSE: k = 398 - l: END SELECT
IF key$ = CHR$(0) + CHR$(75) THEN IF k > 79 THEN k = k - 10 ELSE k = 70
IF key$ = CHR$(0) + CHR$(77) THEN IF k < 388 - l THEN k = k + 10 ELSE k = 398 - l

FOR a = INT((x - 84 - s) / 30) TO INT((x - 84 + s) / 30)
FOR B = INT((y - 90 - s) / 10) TO INT((y - 90 + s) / 10)
IF a >= 0 AND a < 10 AND B >= 0 AND B < 25 THEN
IF B%(a, B) > 0 THEN
SELECT CASE INT(RND * 8)
CASE 0: IF s > 6 THEN CIRCLE (px, py), s, bc: s = s - .2
CASE 1: IF l < 200 THEN l = l + 10: IF k + l > 398 THEN k = 398 - l
CASE 2: IF l > 100 THEN l = l - 10
CASE 3: i = 200
CASE 4: xv = (xv / ABS(xv)) * INT(RND * 2 + 1)
CASE 5: yv = (yv / ABS(yv)) * INT(RND * 2 + 1)
END SELECT
IF i = 0 THEN
IF INT(RND * 2) = 0 THEN IF yv > 0 THEN IF INT(RND * 6) = 0 THEN yv = -yv ELSE  ELSE IF INT(RND * 2) = 0 THEN yv = -yv
IF INT(RND * 2) = 0 THEN xv = -xv
END IF
LINE (84 + a * 30, 90 + B * 10)-(113 + a * 30, 99 + B * 10), bc, BF: B%(a, B) = 0: score = score + 1: IF score MOD 10 = 0 THEN GOSUB bdisplay
END IF
END IF
NEXT B, a

IF k <> pk OR l <> pl THEN LINE (pk, 10)-(pk + pl, 20), bc, BF: LINE (pk, 448)-(pk + pl, 458), bc, BF
LINE (k, 10)-(k + l, 20), fc, BF: LINE (k, 448)-(k + l, 458), fc, BF
FOR a = 1 TO s: CIRCLE (px, py), a, bc: CIRCLE (x, y), a, fc: NEXT a

IF i > 0 THEN i = i - 1
IF (rb AND NOT rlb) OR (lb AND NOT plb) OR key$ = CHR$(13) OR key$ = CHR$(27) OR key$ = " " THEN GOSUB bblastermenu
pmx = mx: pmy = my: plb = lb: prb = rb: MouseStatus mx, my, lb, rb, 0: key$ = INKEY$
IF lives = 0 THEN quit = 1
WEND
MouseShow

IF score > highscore THEN
messagewindow "You Got the New High Score! (" + LTRIM$(STR$(score)) + ")", 220, 150, 1
OPEN "blstdata.txt" FOR OUTPUT AS #1: WRITE #1, score: CLOSE #1: highscore = score
ELSE
IF score > 10 THEN messagewindow "Game Over (Score" + STR$(score) + ")", 220, 150, 1
END IF
IF score >= 500 AND hmission = 7 THEN hmission = 8: hiddenmission
RETURN

bblastermenu:
MouseShow
SELECT CASE menu("Box Blaster!", "Continue Game", "Restart Game", "Quit Box Blaster", "", "", "", "", mx, my)
CASE 2: quit = 1
CASE 3: quit = true
END SELECT
MouseHide
RETURN

bdeath:
lives = lives - 1: i = 200: x = 98: y = 98: xv = 1: yv = 1
GOSUB bdisplay
sleeep .8
RETURN

bdisplay:
messagewindow "Score:" + STR$(score) + " | Lives left:" + STR$(lives), 420, 64, 0
RETURN
END SUB

SUB calendar
messagewindow "Loading...", 100, 21, 0: sleeep .2
CONST wo = 6
DIM d AS LONG, ds AS STRING, d1 AS INTEGER, d2 AS INTEGER, d3 AS INTEGER
DIM ct%(1 TO 20), t$(1 TO 150), t%(1 TO 150, 1 TO 3)

ON ERROR GOTO missingcalendar: OPEN "calendar.txt" FOR INPUT AS #1: ON ERROR GOTO handling
WHILE NOT EOF(1): tcount = tcount + 1
INPUT #1, t%(tcount, 1), t%(tcount, 2), t%(tcount, 3)
LINE INPUT #1, t$(tcount): WEND: CLOSE #1

MouseHide
displayappwindow "Calendar"
FOR a = 95 TO 375 STEP 40: LINE (a, 30)-(a, 270), fc: NEXT a
FOR a = 30 TO 270 STEP 40: LINE (95, a)-(375, a), fc: NEXT a
LINE (95, 280)-(375, 295), fc, B
LINE (165, 280)-(165, 295), fc
LINE (235, 280)-(235, 295), fc
LINE (305, 280)-(305, 295), fc
minitext "Last Month", 110, 284, bc, tc
minitext "Next Month", 180, 284, bc, tc
minitext "Options", 251, 284, bc, tc
minitext "Exit", 332, 284, bc, tc
GOSUB currentdate: GOSUB displaymonth
GOSUB currentdate: MousePosition 115 + ((d2 + offset - 1) MOD 7) * 40, 50 + INT((d2 + offset - 1) / 7) * 40
MouseShow

oldhover = true
WHILE key$ <> CHR$(27) AND quit = 0

IF key$ = CHR$(0) + CHR$(75) THEN GOSUB backamonth ELSE IF key$ = CHR$(0) + CHR$(77) THEN GOSUB upamonth

IF x > 95 AND x < 375 AND y > 30 AND y < 270 THEN
IF plb = false AND lb THEN
 IF tcount = 150 OR ctcount = 20 THEN
  messagewindow "The Calendar is full (max total-150 | max per day-20)!", 95, y, 1
 ELSE
  newtask$ = typein$("New Task:", 64, x, y)
  IF newtask$ <> "" THEN
   IF d1 = 12 AND d2 = 25 AND hmission = 6 THEN hmission = 7: hiddenmission: quit = 1
   tcount = tcount + 1: drawhover = true
   t%(tcount, 1) = d1: t%(tcount, 2) = d2: t%(tcount, 3) = d3
   t$(tcount) = newtask$: drawnotes = true
  END IF
 END IF
END IF

IF prb = false AND rb AND ctcount > 0 THEN MousePosition 95, 308
END IF

IF (plb = false AND lb) OR (prb = false AND rb) THEN
IF x > 95 AND x < 165 AND y > 280 AND y < 295 THEN GOSUB backamonth
IF x > 165 AND x < 235 AND y > 280 AND y < 295 THEN GOSUB upamonth
IF x > 235 AND x < 305 AND y > 280 AND y < 295 THEN
 SELECT CASE menu("Options:", "Go to Today", "Remove All Tasks", "Cancel", "", "", "", "", x, y)
 CASE 1: GOSUB currentdate: GOSUB displaymonth: GOSUB currentdate
  MousePosition 115 + ((d2 + offset - 1) MOD 7) * 40, 50 + INT((d2 + offset - 1) / 7) * 40
 CASE 2: IF tcount > 0 THEN IF menu("Remove All Tasks?", "Yes", "No", "", "", "", "", "", x, y) = 1 THEN tcount = 0: drawhover = true: drawnotes = true
 END SELECT
END IF
IF x > 305 AND x < 375 AND y > 280 AND y < 295 THEN quit = 1
IF x > 95 AND x < 375 AND y > 300 AND y < 300 + ctcount * 8 THEN
 a = ct%(INT((y - 300) / 8) + 1)
 IF menu(t$(a), "Remove task", "Cancel", "", "", "", "", "", x, y) = 1 THEN
  SWAP t%(a, 1), t%(tcount, 1): SWAP t%(a, 2), t%(tcount, 2)
  SWAP t%(a, 3), t%(tcount, 3): SWAP t$(a), t$(tcount)
  tcount = tcount - 1: drawhover = true: drawnotes = true
 END IF
END IF
END IF

IF x > 95 AND x < 375 AND y > 30 AND y < 270 THEN oldhover = hover: hover = INT((x - 95) / 40) + INT((y - 30) / 40) * 7: IF hover - offset < 0 OR hover - offset >= daysinmonth(d1, d3) THEN hover = oldhover ELSE d2 = hover - offset + 1

IF key$ = "" AND drawnotes THEN
FOR a = 1 TO 42
 day = a - offset
 colr = bc
 IF day <= daysinmonth(d1, d3) THEN
  FOR B = 1 TO tcount
   IF (t%(B, 1) = d1 AND t%(B, 2) = day AND t%(B, 3) = d3) THEN colr = fc
  NEXT B
 END IF
 LINE (96 + ((a + 6) MOD 7) * 40, INT((a - 1) / 7) * 40 + 32)-(124 + ((a + 6) MOD 7) * 40, INT((a - 1) / 7) * 40 + 37), colr, BF
NEXT a
drawnotes = false
END IF

IF drawhover OR (hover <> oldhover AND x > 95 AND x < 375 AND y > 30 AND y < 270) THEN
 MouseHide
 FOR a = 1 TO 10 STEP .1
  LINE (115 + 40 * (oldhover MOD 7) - a, 50 + INT(oldhover / 7) * 40 - a)-(115 + 40 * (oldhover MOD 7) + a, 50 + INT(oldhover / 7) * 40 + a), bc, BF
  LINE (115 + 40 * (hover MOD 7) - a, 50 + INT(hover / 7) * 40 - a)-(115 + 40 * (hover MOD 7) + a, 50 + INT(hover / 7) * 40 + a), fc, BF
 NEXT a
 GOSUB storedatestring: minitext ds + SPACE$(8), 94, 22, bc, tc
 LINE (95, 300)-(375, 300 + ctcount * 8 - 3), bc, BF: ctcount = 0
 FOR a = 1 TO tcount
  IF t%(a, 1) = d1 AND t%(a, 2) = d2 AND t%(a, 3) = d3 THEN
   minitext t$(a), 95, 300 + ctcount * 8, bc, tc
   ctcount = ctcount + 1: ct%(ctcount) = a
  END IF
 NEXT a
 MouseShow
 drawhover = false
END IF

plb = lb: prb = rb: MouseStatus x, y, lb, rb, 0
key$ = INKEY$
WEND

messagewindow "Saving...", 100, 21, 0
OPEN "calendar.txt" FOR OUTPUT AS #1
FOR a = 1 TO tcount
WRITE #1, t%(a, 1), t%(a, 2), t%(a, 3)
PRINT #1, t$(a)
NEXT a
CLOSE #1
display 2
EXIT SUB

backamonth:
IF d3 >= 1000 THEN
LINE (105 + 40 * (hover MOD 7), 40 + INT(hover / 7) * 40)-(125 + 40 * (hover MOD 7), 60 + INT(hover / 7) * 40), bc, BF
d2 = 1: GOSUB longdate: d = d - 1 - 1: GOSUB complexdate
GOSUB displaymonth: drawhover = true
IF hover - offset < 0 OR hover - offset >= daysinmonth(d1, d3) THEN oldhover = offset: hover = oldhover
d2 = hover - offset + 1
END IF
RETURN

upamonth:
IF d3 <= 3000 THEN
LINE (105 + 40 * (hover MOD 7), 40 + INT(hover / 7) * 40)-(125 + 40 * (hover MOD 7), 60 + INT(hover / 7) * 40), bc, BF
d2 = 1: GOSUB longdate: d = d + daysinmonth(d1, d3): GOSUB complexdate
GOSUB displaymonth: drawhover = true
IF hover - offset < 0 OR hover - offset >= daysinmonth(d1, d3) THEN oldhover = offset: hover = oldhover
d2 = hover - offset + 1
END IF
RETURN

displaymonth:
GOSUB storedatestring: weeks = 0: drawnotes = true
d2 = 1: GOSUB longdate: offset = (d + wo) MOD 7
MouseHide
FOR a = 1 TO offset: minitext SPACE$(2), 85 + a * 40, 32, bc, 0: NEXT a
FOR d2 = 1 TO daysinmonth(d1, d3): GOSUB longdate
 IF (d + wo) MOD 7 = 0 AND d2 > 1 THEN weeks = weeks + 1
 minitext LEFT$(LTRIM$(STR$(d2)) + " ", 2), 125 + ((d + wo) MOD 7) * 40, weeks * 40 + 32, bc, tc
NEXT d2
a = weeks
FOR d2 = daysinmonth(d1, d3) + 1 TO 42 - offset
 GOSUB longdate
 IF ((d + wo) MOD 7) = 0 THEN a = a + 1
 minitext SPACE$(2), 125 + ((d + wo) MOD 7) * 40, a * 40 + 32, bc, 0
NEXT d2
MouseShow
RETURN

currentdate:
thedate$ = DATE$
d1 = VAL(LEFT$(thedate$, 2))
d2 = VAL(MID$(thedate$, 4, 2))
d3 = VAL(RIGHT$(thedate$, 4))
RETURN

complexdate:
d3 = INT((d - (d - 59) / 1461 + INT((d - 53) / 36525) - INT((d - 56) / 146097)) / 365)
d2 = INT(d - d3 * 365& - INT((d3 - 1) / 4) + INT((d3 - 1) / 100) - INT((d3 - 1) / 400))
ly = -(((d3 MOD 4) = 0) AND ((d3 MOD 100) > 0 OR (d3 MOD 400) = 0))

SELECT CASE d2
CASE IS <= 31: d1 = 1
CASE IS <= 59 + ly: d1 = 2: d2 = d2 - 31
CASE IS <= 90 + ly: d1 = 3: d2 = d2 - 59 - ly
CASE IS <= 120 + ly: d1 = 4: d2 = d2 - 90 - ly
CASE IS <= 151 + ly: d1 = 5: d2 = d2 - 120 - ly
CASE IS <= 181 + ly: d1 = 6: d2 = d2 - 151 - ly
CASE IS <= 212 + ly: d1 = 7: d2 = d2 - 181 - ly
CASE IS <= 243 + ly: d1 = 8: d2 = d2 - 212 - ly
CASE IS <= 273 + ly: d1 = 9: d2 = d2 - 243 - ly
CASE IS <= 304 + ly: d1 = 10: d2 = d2 - 273 - ly
CASE IS <= 334 + ly: d1 = 11: d2 = d2 - 304 - ly
CASE IS <= 365 + ly: d1 = 12: d2 = d2 - 334 - ly
END SELECT
RETURN

storedatestring:
SELECT CASE d1
CASE 1: ds = "January"
CASE 2: ds = "February"
CASE 3: ds = "March"
CASE 4: ds = "April"
CASE 5: ds = "May"
CASE 6: ds = "June"
CASE 7: ds = "July"
CASE 8: ds = "August"
CASE 9: ds = "September"
CASE 10: ds = "October"
CASE 11: ds = "November"
CASE 12: ds = "December"
END SELECT
ds = ds + STR$(d2) + "," + STR$(d3)
RETURN

longdate:
SELECT CASE d1
CASE 1: d = 0
CASE 2: d = 31
CASE 3: d = 59
CASE 4: d = 90
CASE 5: d = 120
CASE 6: d = 151
CASE 7: d = 181
CASE 8: d = 212
CASE 9: d = 243
CASE 10: d = 273
CASE 11: d = 304
CASE 12: d = 334
END SELECT
IF d1 > 2 AND (d3 MOD 4) = 0 AND ((d3 MOD 100) > 0 OR (d3 MOD 400) = 0) THEN d = d + 1
d = INT(d + d2 + 365& * d3 + INT((d3 - 1) / 4) - INT((d3 - 1) / 100) + INT((d3 - 1) / 400))
RETURN
END SUB

FUNCTION daysinmonth (month AS INTEGER, year AS INTEGER)
IF month = 0 THEN month = 12: year = year - 1
SELECT CASE month
CASE 1, 3, 5, 7, 8, 10, 12: daysinmonth = 31
CASE 2: daysinmonth = 28 - ((year MOD 4) = 0 AND ((year MOD 100) > 0 OR (year MOD 400) = 0))
CASE 4, 6, 9, 11: daysinmonth = 30
END SELECT
END FUNCTION

SUB display (code)
IF started = false THEN EXIT SUB
IF dicount > 100 THEN drows = 15 ELSE drows = 10

MouseHide
SELECT CASE code
CASE 1: GOSUB displaydesktop: GOSUB displaystartmenu: GOSUB displaybrowser: GOSUB displaytaskbar
CASE 2: GOSUB displaydesktop: GOSUB displaystartmenu
CASE 3: GOSUB displaybrowser
CASE 4: GOSUB displaystartmenu
CASE 5: GOSUB displaytaskbar
CASE 6: GOSUB displaydesktop: GOSUB displaystartmenu: GOSUB displaytaskbar
CASE 7: GOSUB displaydesktop: GOSUB displaystartmenu: GOSUB displaybrowser
CASE 8: GOSUB displaylasticon
CASE 9: GOSUB displaytaskbar: GOSUB displaybrowser
END SELECT
MouseShow
EXIT SUB

displaybrowser:
IF browser = 1 THEN
LINE (400, 0)-(639, 459), tc, B
LINE (401, 1)-(638, 8), fc, BF
LINE (401, 9)-(638, 458), bc, BF
minitext bpath$, 402, 1, fc, tc
SELECT CASE bpath$
CASE "My Computer"
FOR a = 1 TO bicount
icons bi$(a, 1), bi$(a, 2), 403 + 40 * INT((a - 1) / brows), 10 + 30 * ((a - 1) - brows * INT((a - 1) / brows)), bc
NEXT a
CASE ELSE
minitext "[<] [>]", 603, 1, fc, tc
icons "Up", "UP", 403, 10, bc
FOR a = 1 TO bicount
IF a < 90 AND a + bacross * brows <= bicount THEN icons bi$(a + bacross * brows, 1), bi$(a + bacross * brows, 2), 403 + 40 * INT(a / brows), 10 + 30 * (a - brows * INT(a / brows)), bc
NEXT a
END SELECT
END IF
RETURN

displaydesktop:
IF startmenu = 1 THEN LINE (0, 0)-(639 - 240 * browser, 329), dc, BF: LINE (69, 330)-(639 - 240 * browser, 459), dc, BF ELSE LINE (0, 0)-(639 - 240 * browser, 459), dc, BF
icons "Computer", " 12: thetime$ = LTRIM$(STR$(VAL(LEFT$(thetime$, 2)) - 12)) + RIGHT$(thetime$, 3) + " PM"
END SELECT
LINE (576, 462)-(626, 477), tc, B
minitext thetime$, 586 - LEN(text$) * 2, 466, fc, tc
LINE (0, 471)-(8, 471), tc
LINE (60, 471)-(68, 471), tc
LINE (120, 471)-(575, 471), tc
LINE (627, 471)-(639, 471), tc
RETURN
END SUB

SUB displayappwindow (text$)
IF started = false THEN EXIT SUB
MouseHide
LINE (69, 0)-(399, 459), tc, B
LINE (70, 1)-(398, 8), fc, BF
LINE (70, 9)-(398, 458), bc, BF
minitext text$, 71, 1, fc, tc
MouseShow
END SUB

FUNCTION driveready (d$)
SHARED driveerr%
ON ERROR GOTO drivehandling: d$ = d$ + ":": f% = FREEFILE
OPEN d$ + "\track01.cda" FOR INPUT AS f%: IF driveerr% = 0 THEN CLOSE f%
IF driveerr% = 64 OR driveerr% = 68 OR driveerr% = 76 THEN driveready = false ELSE driveready = true
driveerr% = 0: ON ERROR GOTO handling
END FUNCTION

SUB duetoday
thedate$ = DATE$: d1 = VAL(LEFT$(thedate$, 2))
d2 = VAL(MID$(thedate$, 4, 2)): d3 = VAL(RIGHT$(thedate$, 4))

OPEN "calendar.txt" FOR INPUT AS #1
WHILE NOT EOF(1)
 INPUT #1, t1, t2, t3
 LINE INPUT #1, t$
 IF t1 = d1 AND t2 = d2 AND t3 = d3 THEN messagewindow t$, 200, 150, 1: tcount = tcount + 1
WEND
CLOSE #1

IF tcount = 0 THEN messagewindow "Nothing is due today. You can add tasks with the Calendar program.", 160, 150, 1
END SUB

SUB getpic (x, y, maxx, maxy)
IF maxx < 640 AND maxy < 480 THEN GET (x, y)-(maxx, maxy), pic%
IF maxx >= 640 AND maxy < 480 THEN GET (x, y)-(639, maxy), pic%
IF maxx < 640 AND maxy >= 480 THEN GET (x, y)-(maxx, 479), pic%
IF maxx >= 640 AND maxy >= 480 THEN GET (x, y)-(639, 479), pic%
END SUB

SUB help
displayappwindow "Help"
choice3 = 0

WHILE choice3 <= 1
choice = menu("Select a Topic", "Introduction", "Desktop and Taskbar", "Start Menu", "File Browser", "Built-in Programs", "Handling Errors", "About iOS", 75, 20)
SELECT CASE choice
CASE 1: intro: displayappwindow "Help"
CASE 2
 choice2 = menu("Desktop and Taskbar", "Adding Desktop Icons", "Removing Desktop Icons", "Refreshing the Display", "Using the Taskbar", "Changing the Time or Date", "", "", 75, 20)
 SELECT CASE choice2
 CASE 1: minitext "You can add shortcuts by right-clicking on files in the file browser.", 72, 99, bc, tb
 CASE 2: minitext "You can remove shortcuts from the Desktop by right-clicking on them.", 72, 99, bc, tc
 CASE 3: minitext "You can refresh the screen, including the file browser, by pressing [R].", 72, 99, bc, tc
 CASE 4: minitext "Left-click on the Taskbar to open the Start Menu or File Browser, or to view", 72, 99, bc, tc: minitext "the current time and date. Right-click on the clock to change the time or date.", 72, 108, bc, tc
 CASE 5: minitext "Right-click on the clock in the Taskbar to change the time or date.", 72, 99, bc, tc
 END SELECT
CASE 3
 choice2 = menu("Start Menu", "How to Open", "Contents", "", "", "", "", "", 75, 20)
 SELECT CASE choice2
 CASE 1: minitext "You can open the Start Menu through the icon in the Taskbar, or by pressing [Z].", 72, 99, bc, tc
 CASE 2: minitext "The Start Menu lets you lauch built-in programs, run Help, and exit iOS.", 72, 99, bc, tc
 END SELECT
CASE 4
 choice2 = menu("File Browser", "How to Open", "Using Icons", "Navigating", "Creating Shortcuts", "", "", "", 75, 20)
 SELECT CASE choice2
 CASE 1: minitext "You can open the file browser through the icon in the Taskbar,", 72, 99, tc, bc: minitext "or by pressing [B].", 72, 108, bc, tc
 CASE 2: minitext "Click on an icon to open that folder or file. Right-click it for more options.", 72, 99, bc, tc
 CASE 3: minitext "Click on the path (such as C:\) at the top of the Browser window to manually", 72, 99, bc, tc: minitext "type a directory name, or click on the 'Up' icon and folders to browse through", 72, 108, bc, tc
  minitext "the files. Click on the [<] and [>] icons at the top-right of the window to", 72, 117, bc, tc: minitext "scroll though the files in the current directory.", 72, 126, bc, tc
 CASE 4: minitext "Right-click on a file and select 'Create Shortcut' to add a Desktop icon.", 72, 99, bc, tc
 END SELECT
CASE 5
 choice2 = menu("Built-in Programs", "How to Open", "For More Info", "About", "", "", "", "", 75, 20)
 SELECT CASE choice2
 CASE 1: minitext "You can view a list of the built-in programs in the file browser by pressing", 72, 99, bc, tc: minitext "[Space], through the Start Menu, or through the Desktop shortcuts.", 72, 108, bc, tc
 CASE 2: minitext "Read the README file for additional information.", 72, 99, bc, tc
 CASE 3: minitext "These applications are (C) 2006 i-TECH, and written by Kristopher Windsor.", 72, 99, bc, tc
 END SELECT
CASE 6
 minitext "Certain errors may cause iOS to freeze or display incorrectly. If this happens,", 72, 99, bc, tc
 minitext "try pressing [Esc] to continue, [R] to refresh the display, or [F12] to quit.", 72, 108, bc, tc
 minitext "Please report errors to " + email$ + ".", 72, 116, bc, tc
CASE 7
 minitext "The i-TECH Operating System, written by Kristopher Windsor, is (C) 2006 i-TECH.", 72, 99, bc, tc
 minitext "Please send feedback and suggestions to " + email$ + ".", 72, 108, bc, tc
END SELECT

choice3 = menu("Help", "Back", "Close", "", "", "", "", "", 75, 20)
LINE (72, 99)-(398, 131), bc, BF: WEND
display 2
resettimer
END SUB

SUB hiddenmission
displayappwindow "Hidden Mission"
hmission = INT(hmission + .001): IF hmission = 0 THEN hmission = 1
MouseHide
minitext "You found the hidden mission! Your mission is currently" + STR$(INT(hmission * 10)) + "% complete.", 72, 21, bc, tc
SELECT CASE hmission
CASE 1: minitext "For your first task, set the clock.", 72, 30, bc, tc
CASE 2: minitext "You finished your first task! Now try to get 80 points in Incoming!", 72, 30, bc, tc
CASE 3: minitext "Good work! Next, right-click something that is almost always on the screen.", 72, 30, bc, tc
CASE 4: minitext "Keep going! Use the file browser to find the iOS data files.", 72, 30, bc, tc
CASE 5: minitext "Now try to beat Level 8 in Bounce 2.", 72, 30, bc, tc
CASE 6: minitext "The Secret to iOS is near. Add a task for Christmas to the Calendar.", 72, 30, bc, tc
CASE 7: minitext "Box Blaster demands 500 points of you.", 72, 30, bc, tc
CASE 8: minitext "Your next task is to preview the screen saver.", 72, 30, bc, tc
CASE 9: minitext "Task #9: Save a web page in Jotit.", 72, 30, bc, tc
CASE 10: minitext "You have won for now, but the secret to iOS will be safe until Version 1.22.", 72, 30, bc, tc
END SELECT
MouseShow
messagewindow "Close.", 72, 57, 1
display 6
END SUB

SUB icons (text$, itype$, x, y, bg)
MouseHide
LINE (x, y)-(x + 34, y + 27), bg, BF
minitext LEFT$(text$ + SPACE$(8), 8), x + 1, y + 21, bg, tc
SELECT CASE itype$
CASE " 0 THEN messagewindow "Try to beat " + topplayer$ + "'s score of" + STR$(highscore) + " points (" + tdate$ + ").", 156, 150, 1 ELSE messagewindow "Move your space ship up and down to avoid the incoming missiles!", 156, 150, 1
MouseHide
CLS : starttime = TIMER
WHILE key$ <> CHR$(27) AND lives > 0
IF key$ = CHR$(0) + CHR$(72) OR key$ = CHR$(0) + CHR$(80) OR framecount = 0 OR invinc = 1 OR invinc = itime - 1 OR mouse <> pmouse THEN
CIRCLE (21, w + 5), 14, 0, , , .5
CIRCLE (21, w - 5), 14, 0, , , .5
LINE (15, w - 15)-(45, w - 15), 0
LINE (15, w + 15)-(45, w + 15), 0
CIRCLE (30, w), 10, 0, , , .5
CIRCLE (25, w), 20, 0, , , 2
IF key$ = CHR$(0) + CHR$(72) AND w > 0 THEN w = w - shipspeed
IF key$ = CHR$(0) + CHR$(80) AND w < 479 THEN w = w + shipspeed
IF mouse <> pmouse THEN w = mouse
END IF
CIRCLE (21, w + 5), 14, 4 + ABS(20 * (invinc > 1)), , , .5
CIRCLE (21, w - 5), 14, 4 + ABS(20 * (invinc > 1)), , , .5
LINE (15, w - 15)-(45, w - 15), 8 + ABS(20 * (invinc > 1))
LINE (15, w + 15)-(45, w + 15), 8 + ABS(20 * (invinc > 1))
CIRCLE (30, w), 10, 2 + ABS(20 * (invinc > 1)), , , .5
CIRCLE (25, w), 20, 2 + ABS(20 * (invinc > 1)), , , 2
whichmoon = INT(RND * mooncount + 1)
IF moon(whichmoon, 3) = 0 THEN moon(whichmoon, 1) = INT(RND * planetcount) + 1: moon(whichmoon, 2) = INT(RND * 15) + 1: moon(whichmoon, 3) = .1: moon(whichmoon, 4) = 1: moon(whichmoon, 5) = RND * moonspeed * 2
whichi = INT(RND * icount) + 1
IF moon(whichmoon, 3) > 0 AND i(whichi, 4) = 0 AND framecount > 500 THEN
i(whichi, 1) = COS(moon(whichmoon, 3) * 3.14) * planet(moon(whichmoon, 1), 3) + planet(moon(whichmoon, 1), 1) + COS(moon(whichmoon, 4) * 3.14) * (moonsize + gunsize)
i(whichi, 2) = SIN(moon(whichmoon, 3) * 3.14) * planet(moon(whichmoon, 1), 3) + planet(moon(whichmoon, 1), 2) + SIN(moon(whichmoon, 4) * 3.14) * moonsize
i(whichi, 3) = moon(whichmoon, 2): i(whichi, 4) = ispeed * RND * 2 + 1
END IF
IF key$ = " " OR autoshoot = 1 THEN
whicho = INT(RND * ocount) + 1: IF o(whicho, 3) = 0 THEN o(whicho, 1) = 45 + otrail: o(whicho, 2) = w - 15: o(whicho, 3) = ospeed * RND * 2 + 1
whicho = INT(RND * ocount) + 1: IF o(whicho, 3) = 0 THEN o(whicho, 1) = 45 + otrail: o(whicho, 2) = w + 15: o(whicho, 3) = ospeed * RND * 2 + 1
END IF
FOR a = 1 TO mooncount
IF moon(a, 3) > 0 THEN
x = COS(moon(a, 3) * 3.14) * planet(moon(a, 1), 3) + planet(moon(a, 1), 1)
y = SIN(moon(a, 3) * 3.14) * planet(moon(a, 1), 3) + planet(moon(a, 1), 2)
CIRCLE (x, y), moonsize, 0
CIRCLE (x + COS(moon(a, 4) * 3.14) * (moonsize + gunsize), y + SIN(moon(a, 4) * 3.14) * moonsize), gunsize, 0
CIRCLE (x + COS((moon(a, 4) + .5) * 3.14) * (moonsize + gunsize), y + SIN((moon(a, 4) + .5) * 3.14) * moonsize), gunsize, 0
moon(a, 3) = moon(a, 3) + moon(a, 5)
moon(a, 4) = moon(a, 4) + gunspeed
dead = 0: FOR B = 1 TO ocount
IF SQR((o(B, 1) - x) * (o(B, 1) - x) + (o(B, 2) - y) * (o(B, 2) - y)) < moonsize AND o(B, 3) > 0 AND dead = 0 THEN
moon(a, 3) = 0: dead = 1: points = points + 1: LOCATE 1, 2: PRINT "Score:"; points, "Lives:"; lives
FOR ba = 0 TO 2 STEP 2 / pd: CIRCLE (p(whichp, 1) + COS(ba * 3.14) * p(whichp, 3), p(whichp, 2) + SIN(ba * 3.14) * p(whichp, 3)), psize, 0: NEXT ba 'erase all particles for one explosion
p(whichp, 1) = x: p(whichp, 2) = y: p(whichp, 3) = moonsize: p(whichp, 4) = moon(a, 2): p(whichp, 5) = pspeed + INT(RND * 5) - 2
whichp = whichp + 1: IF whichp > pcount THEN whichp = 1
END IF
NEXT B
IF moon(a, 3) > 0 THEN
x = COS(moon(a, 3) * 3.14) * planet(moon(a, 1), 3) + planet(moon(a, 1), 1)
y = SIN(moon(a, 3) * 3.14) * planet(moon(a, 1), 3) + planet(moon(a, 1), 2)
CIRCLE (x, y), moonsize, moon(a, 2)
CIRCLE (x + COS(moon(a, 4) * 3.14) * (moonsize + gunsize), y + SIN(moon(a, 4) * 3.14) * moonsize), gunsize, moon(a, 2)
CIRCLE (x + COS((moon(a, 4) + .5) * 3.14) * (moonsize + gunsize), y + SIN((moon(a, 4) + .5) * 3.14) * moonsize), gunsize, moon(a, 2)
END IF
END IF
NEXT a
FOR a = 1 TO icount
LINE (i(a, 1), i(a, 2))-(i(a, 1) + itrail, i(a, 2)), 0
i(a, 1) = i(a, 1) - i(a, 4)
IF SQR((i(a, 1) - 25) * (i(a, 1) - 25) + (i(a, 2) - w) * (i(a, 2) - w)) < 20 AND invinc = 0 THEN invinc = itime: lives = lives - 1: LOCATE 1, 2: PRINT "Score:"; points, "Lives:"; lives
IF i(a, 1) < -itrail THEN i(a, 4) = 0 ELSE LINE (i(a, 1), i(a, 2))-(i(a, 1) + itrail, i(a, 2)), i(a, 3)
NEXT a
FOR a = 1 TO ocount
LINE (o(a, 1), o(a, 2))-(o(a, 1) - otrail, o(a, 2)), 0
o(a, 1) = o(a, 1) + o(a, 3)
IF o(a, 1) - otrail > 640 THEN o(a, 3) = 0 ELSE LINE (o(a, 1), o(a, 2))-(o(a, 1) - otrail, o(a, 2))
NEXT a
FOR a = 1 TO pcount
IF p(a, 5) > 0 THEN
FOR ba = 0 TO 2 STEP 2 / pd: CIRCLE (p(a, 1) + COS(ba * 3.14) * p(a, 3), p(a, 2) + SIN(ba * 3.14) * p(a, 3)), psize, 0
NEXT ba 'erase all particles for one explosion
p(a, 3) = p(a, 3) + p(a, 5)
FOR ba = 0 TO 2 STEP 2 / pd: CIRCLE (p(a, 1) + COS(ba * 3.14) * p(a, 3), p(a, 2) + SIN(ba * 3.14) * p(a, 3)), psize, p(a, 4):
NEXT ba
END IF
NEXT a
framecount = framecount + 1: IF invinc > 0 THEN invinc = invinc - 1
pmouse = mouse: MouseStatus 0, mouse, 0, 0, 0
key$ = INKEY$: IF key$ = CHR$(13) THEN SLEEP
WEND: GOSUB gameover: WEND: display 1: MouseShow: resettimer: EXIT SUB
gameover:
LOCATE 28, 2: PRINT "Frames per Second:"; INT(framecount / (TIMER - starttime))
MouseShow
IF points > highscore THEN
messagewindow "You beat the High Score!", 200, 150, 1
highscore = points: topplayer$ = typein$("Enter your name:", 16, 200, 150)
OPEN "inscores.txt" FOR OUTPUT AS #1: PRINT #1, topplayer$: WRITE #1, highscore, DATE$: CLOSE #1
END IF
MouseShow
IF points >= 80 AND hmission = 2 THEN hmission = 3: hiddenmission
IF menu("Game Over (Score:" + STR$(points) + ")", "Play Again", "Quit", "", "", "", "", "", 200, 150) = 2 THEN quit = 1
MouseHide
RETURN
END SUB

SUB intro
displayappwindow "Introduction to iOS"
MouseHide
minitext "The i-TECH Operating System is (C) 2006 i-TECH and Kristopher Windsor", 72, 19, bc, tc
minitext "Special thanks to those at Network54.com who made this possible.", 72, 27, bc, tc
minitext "To get started, press [Z] or [B] to open the Start Menu or File Browser.", 72, 43, bc, tc
minitext "You can launch programs through those or the Desktop icons.", 72, 51, bc, tc
minitext "Keyboard shortcuts include [H]-Help, [T]-Time, [O]-Options, and [R]-Refresh.", 72, 59, bc, tc
minitext "Press [F12] to quick-exit, or select the Exit option from the Start Menu.", 72, 76, bc, tc
minitext "To minimize the iOS program, press [Alt]-[Enter].", 72, 84, bc, tc
minitext "Note: Certain features may not work with your computer", 72, 100, bc, tc
minitext "Until you have configured it in the Options program.", 72, 108, bc, tc
minitext "Please send feedback to " + email$ + ",", 72, 124, bc, tc
minitext "Or goto network54.com/Forum/13959 for instant support.", 72, 132, bc, tc
MouseShow
messagewindow "Close", 292, 87, 1
display 2
END SUB

SUB jotit (filename$)
DIM j%(1 TO 384): z = FREEFILE
ON ERROR GOTO resumenext: MKDIR "Jotit"
ON ERROR GOTO missingjdata: OPEN "jotit.txt" FOR INPUT AS #z
ON ERROR GOTO handling: INPUT #z, jfcount: CLOSE #z

GOSUB openjfile: GOSUB editjfile
OPEN "jotit.txt" FOR OUTPUT AS #z: WRITE #z, jfcount: CLOSE #z
CALL readdicons: display 2: readbrowserfiles
EXIT SUB

displayjall:
displayall = false: displaypart = false: down = 11 + offset: l = INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80)
MouseHide
IF down > 11 THEN LINE (71, 11)-(391, down - 1), bc, BF
FOR a = 1 TO jcount
j%(a) = down
FOR B = 0 TO INT(LEN(di$(INT((a + 2) / 3), a MOD 3 + 1)) / 80)
IF down >= 11 AND down <= 452 THEN minitext LEFT$(MID$(di$(INT((a + 2) / 3), a MOD 3 + 1), B * 80 + 1, 80) + SPACE$(80), 80), 71, down, bc, tc
down = down + 7
NEXT B
NEXT a
IF down < 452 THEN LINE (71, 457)-(391, down - 1), bc, BF
MouseShow
RETURN

displayjpart:
displaypart = false: l = INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80)
MouseHide
FOR B = INT(c2 / 80) TO INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80)
IF j%(c1) + B * 7 >= 11 AND j%(c1) + B * 7 <= 452 THEN minitext LEFT$(MID$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), B * 80 + 1, 80) + SPACE$(80), 80), 71, j%(c1) + B * 7, bc, tc
NEXT B
MouseShow
RETURN

jcursor:
MouseHide
IF j%(c1) + INT(c2 / 80) * 7 >= 11 AND j%(c1) + INT(c2 / 80) * 7 <= 452 THEN LINE (71 + (c2 MOD 80) * 4, j%(c1) + INT(c2 / 80) * 7)-(71 + (c2 MOD 80) * 4, j%(c1) + INT(c2 / 80) * 7 + 5), cc
MouseShow
RETURN

editjfile:
quit = 0: key$ = ""
WHILE quit = 0: t = INT(TIMER * 5)

IF (x > 70 AND x < 400 AND y < 11 AND plb = false AND lb) OR key$ = CHR$(27) THEN GOSUB jotitmenu

IF x > 70 AND x < 392 AND y >= 11 AND lb THEN
B = 1: WHILE j%(B) <= y AND B <= jcount: B = B + 1: WEND
cc = bc: GOSUB jcursor: c1 = B - 1: l = INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80)
c2 = INT((x - 69) / 4) + INT((y - j%(B - 1)) / 7) * 80: IF c2 > LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1))
END IF

IF LEN(key$) = 1 AND key$ <> CHR$(7) AND key$ <> CHR$(8) AND key$ <> CHR$(13) AND key$ <> CHR$(27) THEN
 di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) = LEFT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), c2) + key$ + RIGHT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) - c2)
 cc = bc: GOSUB jcursor: c2 = c2 + 1: displaypart = true: nts = true
END IF
SELECT CASE key$
CASE CHR$(0) + CHR$(71)
 cc = bc: GOSUB jcursor
 c2 = INT(c2 / 80) * 80
CASE CHR$(0) + CHR$(72)
 IF (c1 > 1 OR c2 >= 80) THEN
 cc = bc: GOSUB jcursor
 IF INT(c2 / 80) > 0 THEN c2 = c2 - 80 ELSE c1 = c1 - 1: c2 = c2 + INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80) * 80: IF c2 > LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1))
 l = INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80)
 END IF
CASE CHR$(0) + CHR$(75)
 cc = bc: GOSUB jcursor
 IF c2 > 0 THEN c2 = c2 - 1 ELSE IF c1 > 1 THEN c1 = c1 - 1: c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1))
CASE CHR$(0) + CHR$(77)
 cc = bc: GOSUB jcursor
 IF c2 < LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN c2 = c2 + 1 ELSE IF c1 < jcount THEN c1 = c1 + 1: c2 = 0
CASE CHR$(0) + CHR$(79)
 cc = bc: GOSUB jcursor
 c2 = INT(c2 / 80 + 1) * 80: IF c2 > LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1))
CASE CHR$(0) + CHR$(80)
 IF c1 < jcount OR c2 + 80 <= LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN
 cc = bc: GOSUB jcursor
 IF INT(c2 / 80) = INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80) THEN
 c1 = c1 + 1: c2 = c2 - l * 80: IF c2 > LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1))
 ELSE
 c2 = c2 + 80: IF c2 > LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1))
 END IF
 l = INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80)
 END IF
CASE CHR$(0) + CHR$(83): nts = true
 IF c1 < jcount OR c2 < LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN
 IF c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) THEN
 jcount = jcount - 1: di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) = di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) + di$(INT((c1 + 3) / 3), (c1 + 1) MOD 3 + 1)
 FOR a = c1 + 1 TO jcount: SWAP di$(INT((a + 2) / 3), a MOD 3 + 1), di$(INT((a + 3) / 3), (a + 1) MOD 3 + 1): NEXT a
 displayall = true
 ELSE
 cc = bc: GOSUB jcursor: displaypart = true
 di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) = LEFT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), c2) + RIGHT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) - c2 - 1)
 END IF
 END IF
CASE CHR$(8): nts = true
 IF c1 > 1 OR c2 > 0 THEN
 IF c2 = 0 THEN
  c1 = c1 - 1: c2 = LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)): jcount = jcount - 1
  di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) = di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) + di$(INT((c1 + 3) / 3), (c1 + 1) MOD 3 + 1)
  FOR a = c1 + 1 TO jcount: SWAP di$(INT((a + 2) / 3), a MOD 3 + 1), di$(INT((a + 3) / 3), (a + 1) MOD 3 + 1): NEXT a
  displayall = true
 ELSE
  cc = bc: GOSUB jcursor: c2 = c2 - 1: displaypart = true
  di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) = LEFT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), c2) + RIGHT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) - c2 - 1)
 END IF
 END IF
CASE CHR$(13): nts = true
 IF jcount < 384 THEN
 FOR a = jcount TO c1 + 1 STEP -1: SWAP di$(INT((a + 2) / 3), a MOD 3 + 1), di$(INT((a + 3) / 3), (a + 1) MOD 3 + 1): NEXT a
 di$(INT((c1 + 3) / 3), (c1 + 1) MOD 3 + 1) = RIGHT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) - c2)
 di$(INT((c1 + 2) / 3), c1 MOD 3 + 1) = LEFT$(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1), c2)
 displayall = true: jcount = jcount + 1: c1 = c1 + 1: c2 = 0
 END IF
END SELECT
WHILE j%(c1) + INT(c2 / 80) * 7 < 11 AND displayall = false: offset = offset + 7: GOSUB nojdisplay: WEND
WHILE j%(c1) + INT(c2 / 80) * 7 > 452 AND displayall = false: offset = offset - 7: GOSUB nojdisplay: WEND
IF poffset <> offset OR l <> INT(LEN(di$(INT((c1 + 2) / 3), c1 MOD 3 + 1)) / 80) THEN displayall = true
cc = tc + (tc - bc) * (t / 5 = INT(t / 5)): GOSUB jcursor

IF displayall THEN displaypart = false: IF key$ = "" THEN GOSUB displayjall ELSE GOSUB nojdisplay
IF displaypart AND key$ = "" THEN GOSUB displayjpart

pkey$ = key$: poffset = offset: plb = lb: sleeep .03
key$ = INKEY$: MouseStatus x, y, lb, 0, 0
WEND
RETURN

jotitmenu:
SELECT CASE menu("Jotit", "New", "New Web Page", "Open", "Save", "Save As", "Exit", "", 69, 0)
CASE 1: GOSUB savejfileask: filename$ = "": GOSUB openjfile
CASE 2: GOSUB savejfileask: di$(1, 2) = "": di$(1, 3) = "" + typein$("Page Name:", 64, x, y) + "": di$(1, 1) = "": di$(2, 2) = "

": di$(2, 3) = "": nts = false jcount = 5: c1 = 4: c2 = 3: nts = true: ex$ = ".htm": filename$ = "Jotit/Jot_" + LTRIM$(STR$(jfcount)) + ex$: displayappwindow "Jotit: " + filename$: GOSUB displayjall CASE 3: GOSUB savejfileask: GOSUB openjfileas CASE 4: GOSUB savejfile CASE 5: GOSUB savejfileas CASE 6: GOSUB savejfileask: quit = 1 END SELECT RETURN nojdisplay: down = 11 + offset: FOR a = 1 TO jcount: j%(a) = down FOR B = 0 TO INT(LEN(di$(INT((a + 2) / 3), a MOD 3 + 1)) / 80): down = down + 7: NEXT B, a RETURN openjfile: c1 = 1: c2 = 0: jcount = 0: mt = false: offset = 0: ex$ = ".txt" IF LEN(filename$) > 4 THEN IF MID$(filename$, LEN(filename$) - 3, 1) = "." THEN ex$ = RIGHT$(filename$, 4) ON ERROR GOTO missingtext: OPEN filename$ FOR INPUT AS #z: ON ERROR GOTO handling IF mt THEN filename$ = "Jotit/Jot_" + LTRIM$(STR$(jfcount)) + ex$ ELSE ON ERROR GOTO handlejloading WHILE NOT EOF(z) AND jcount < 384 jcount = jcount + 1: mt = false: LINE INPUT #z, di$(INT((jcount + 2) / 3), jcount MOD 3 + 1) IF mt THEN ON ERROR GOTO handling: CLOSE #z: EXIT SUB WEND ON ERROR GOTO handling: CLOSE #z END IF IF jcount = 0 THEN jcount = 1: di$(1, 2) = "" displayappwindow "Jotit: " + filename$: GOSUB displayjall: nts = false RETURN openjfileas: filename$ = typein$("Open file:", 64, 69, 0) IF INSTR(filename$, "\") = 0 THEN filename$ = "Jotit\" + filename$ GOSUB openjfile RETURN savejfile: mt = true: ON ERROR GOTO jsaveerrors: OPEN filename$ FOR OUTPUT AS #z ON ERROR GOTO handling SELECT CASE mt CASE -1 IF filename$ = "Jotit/Jot_" + LTRIM$(STR$(jfcount)) + ex$ THEN jfcount = jfcount + 1 FOR a = 1 TO jcount: PRINT #z, di$(INT((a + 2) / 3), a MOD 3 + 1): NEXT a: CLOSE #z CASE 0, 1 filename$ = "Jotit/Jot_" + LTRIM$(STR$(jfcount)) + ex$ displayappwindow "Jotit: " + filename$: GOSUB displayjall OPEN filename$ FOR OUTPUT AS #z FOR a = 1 TO jcount: PRINT #z, di$(INT((a + 2) / 3), a MOD 3 + 1): NEXT a CLOSE #z: jfcount = jfcount + 1 END SELECT: nts = false IF hmission = 9 AND ex$ = ".htm" THEN hmission = 10: hiddenmission: displayappwindow "Jotit: " + filename$: displayall = true RETURN savejfileas: filename$ = typein$("Save file as:", 38, 69, 0) IF INSTR(filename$, "\") = 0 THEN filename$ = "Jotit\" + filename$ displayappwindow "Jotit: " + filename$: GOSUB displayjall GOSUB savejfile RETURN savejfileask: IF nts THEN IF menu("Save current file?", "Yes", "No", "", "", "", "", "", 69, 0) = 1 THEN GOSUB savejfile RETURN END SUB SUB leftclick (name$, extension$, lpath$, x, y) IF LEN(lpath$) = 3 THEN fix$ = "" ELSE fix$ = "\" IF extension$ = " 8 THEN size = LEN(title$) + 2 ELSE size = 10 IF LEN(item1$) > size THEN size = LEN(item1$) IF LEN(item2$) > size THEN size = LEN(item2$) IF LEN(item3$) > size THEN size = LEN(item3$) IF LEN(item4$) > size THEN size = LEN(item4$) IF LEN(item5$) > size THEN size = LEN(item5$) IF LEN(item6$) > size THEN size = LEN(item6$) IF LEN(item7$) > size THEN size = LEN(item7$) IF item7$ <> "" THEN icount = 7 ELSE IF item6$ <> "" THEN icount = 6 ELSE IF item5$ <> "" THEN icount = 5 ELSE IF item4$ <> "" THEN icount = 4 ELSE IF item3$ <> "" THEN icount = 3 ELSE icount = 2 maxx = x + 2 + 4 * size: maxy = y + 9 + icount * 8 GOSUB displaymenu key$ = "": lb = true: plb = lb: hover = 1 WHILE key$ <> CHR$(27) AND (VAL(key$) = 0 OR VAL(key$) > icount) AND ((lb = false OR plb) OR ((mx < x OR mx > maxx OR my < y + 7 OR my > maxy) AND (mx < maxx - 5 OR mx > maxx OR my < y OR my > y + 7))) IF lb AND plb = false AND mx > x AND mx < maxx - 5 AND my > y AND my < y + 7 THEN GOSUB movemenu phover = hover: IF mx > x AND mx < maxx AND my > y + 7 AND my < maxy - 2 THEN hover = INT((my - y) / 8) + 1 IF hover <> phover THEN MouseHide: LINE (x + 1, y + phover * 8)-(maxx - 1, y + phover * 8), bc: LINE (x + 1, y + hover * 8)-(maxx - 1, y + hover * 8), fc: MouseShow key$ = INKEY$: plb = lb: MouseStatus mx, my, lb, 0, 0 WEND GOSUB erasemenu IF key$ = CHR$(27) THEN menu = 0 ELSE IF VAL(key$) > 0 AND VAL(key$) <= icount THEN menu = VAL(key$) ELSE menu = INT((my - y) / 8) resettimer EXIT FUNCTION displaymenu: MouseHide getpic x, y, maxx, maxy LINE (x, y)-(maxx, maxy), tc, B LINE (x + 1, y + 1)-(maxx - 1, y + 7), fc, BF LINE (x + 1, y + 8)-(maxx - 1, maxy - 1), bc, BF minitext title$, x + 1, y + 1, fc, tc minitext "X", maxx - 5, y + 1, fc, tc minitext item1$, x + 1, y + 9, bc, tc minitext item2$, x + 1, y + 17, bc, tc IF icount >= 3 THEN minitext item3$, x + 1, y + 25, bc, tc IF icount >= 4 THEN minitext item4$, x + 1, y + 33, bc, tc IF icount >= 5 THEN minitext item5$, x + 1, y + 41, bc, tc IF icount >= 6 THEN minitext item6$, x + 1, y + 49, bc, tc IF icount >= 7 THEN minitext item7$, x + 1, y + 57, bc, tc MouseShow RETURN erasemenu: MouseHide PUT (x, y), pic%, PSET MouseShow RETURN movemenu: WHILE lb px = mx: py = my: MouseStatus mx, my, lb, 0, 0 IF mx <> px OR my <> py THEN GOSUB erasemenu xmove = mx - px: IF x + xmove < 0 THEN xmove = -x ymove = my - py: IF y + ymove < 0 THEN ymove = -y x = x + xmove: maxx = maxx + xmove: y = y + ymove: maxy = maxy + ymove GOSUB displaymenu sleeep .5 END IF WEND RETURN END FUNCTION SUB messagewindow (text$, x, y, delay) IF started = false THEN EXIT SUB GOSUB displaymessagewindow IF delay = 1 THEN key$ = "": lb = true: plb = lb: WHILE key$ <> CHR$(27) AND key$ <> CHR$(13) AND (lb = false OR plb OR mx < x OR mx > maxx OR my < y + 7 OR my > y + 50) IF lb AND plb = false AND mx > x AND mx < maxx AND my > y AND my < y + 7 THEN GOSUB movemessagewindow px = mx: py = my: plb = lb: MouseStatus mx, my, lb, 0, 0: key$ = INKEY$: WEND END IF IF delay = 1 THEN GOSUB erasemessagewindow resettimer EXIT SUB displaymessagewindow: maxx = x + 4 * LEN(text$) + 80: maxy = y + 50 MouseHide IF delay = 1 THEN getpic x, y, maxx, maxy LINE (x, y)-(maxx, maxy), tc, B LINE (x + 1, y + 1)-(maxx - 1, y + 7), fc, BF LINE (x + 1, y + 8)-(maxx - 1, y + 49), bc, BF minitext text$, x + 40, y + 16, bc, tc LINE (x + 39, y + 15)-(maxx - 39, y + 23), tc, B IF delay = 1 THEN minitext "Okay", x + 4, y + 40, bc, tc: LINE (x + 3, y + 39)-(x + 21, y + 47), tc, B MouseShow RETURN erasemessagewindow: MouseHide PUT (x, y), pic%, PSET MouseShow RETURN movemessagewindow: WHILE lb px = mx: py = my: MouseStatus mx, my, lb, 0, 0 IF mx <> px OR my <> py THEN GOSUB erasemessagewindow x = x + mx - px: IF x < 0 THEN x = 0 y = y + my - py: IF y < 0 THEN y = 0 GOSUB displaymessagewindow sleeep .5 END IF WEND RETURN END SUB SUB minitext (text$, x, y, bg, fg) LINE (x, y)-(x + 4 * LEN(text$), y + 6), bg, BF FOR a = 1 TO LEN(text$) DRAW "C" + LTRIM$(STR$(fg)) + " BM" + LTRIM$(STR$(x + 4 * a - 3)) + "," + LTRIM$(STR$(y + 1)) SELECT CASE ASC(MID$(text$, a, 1)) CASE 1, 2, 3, 4, 5, 6, 14: DRAW "D0 BR1 BD2 D0 BU2 BR1 R0 BD4 L2" CASE 9, 27: DRAW "F2 G2 U3 F1" CASE 13, 20: DRAW "BD1 NF1 E1 R1 D4" CASE 15, 35, 38, 42: DRAW "BD1 D0 BD2 D0 BD1 BR1 U4 BR1 BD1 D0 BD2 D0" CASE 16, 62, 242: DRAW "BD2 BR2 NH2 G2" CASE 17, 60, 243: DRAW "BD2 NE2 F2" CASE 19, 33: DRAW "D2 BD2 D0" CASE 32 CASE 34: DRAW "D1 BR2 U1" CASE 36, 155, 156, 157, 158, 159: DRAW "BD2 D0 BD2 D0 BR1 U4 BR1 BD1 D0 BD2 D0" CASE 37, 246: DRAW "D0 BR2 D1 G2 D1 BR2 D0" CASE 39, 96: DRAW "BR1 D2" CASE 40: DRAW "BR1 G1 D2 F1" CASE 41: DRAW "F1 D2 G1" CASE 43: DRAW "BF1 NF1 NG1 D2" CASE 44: DRAW "BF2 D1 G1" CASE 45: DRAW "BD2 R2" CASE 46: DRAW "BD4 BR1 R0" CASE 47: DRAW "BR2 D1 G2 D1" CASE 48: DRAW "BD1 D2 BD1 BR1 R0 BR1 BU1 U2 BU1 BL1 L0" CASE 49: DRAW "BD1 D0 BD3 R2 BL1 U4 BD1 L1" CASE 50: DRAW "R1 BR1 BD1 D0 BD1 BL1 L0 BD1 BL1 L0 BD1 R2" CASE 51: DRAW "R1 BR1 BD1 D0 BD1 BL1 L0 BD1 BR1 R0 BD1 BL1 L1" CASE 52: DRAW "D2 R2 BU1 D3" CASE 53: DRAW "NR2 D2 R1 BR1 BD1 D0 BD1 BL1 L1" CASE 54: DRAW "BR1 R1 BL2 BD1 D3 R2 U2 L1" CASE 55: DRAW "R2 D1 BD1 BL1 L0 BD1 BL1 D1" CASE 56: DRAW "D4 R2 U4 NL1 BD2 L1" CASE 57: DRAW "D2 R2 BD1 U3 L1 BD4 L1" CASE 58: DRAW "BF1 D0 BD2 D0" CASE 59: DRAW "BD4 D0 BR1 BU1 U0 BU2 U0" CASE 61: DRAW "BD1 R2 BD2 L2" CASE 63, 168: DRAW "R1 BR1 BD1 D0 BD1 BL1 D0 BD2 D0" CASE 64: DRAW "R2 D2 BD2 L2 U3" CASE 65: DRAW "BD1 D3 BU2 R2 D2 U3 BU1 BL1 L0" CASE 66: DRAW "D4 R1 BU2 U0 BU2 U0 BR1 BD1 D0 BD2 D0" CASE 67: DRAW "BR1 NR1 BL1 BD1 D2 BD1 BR1 R1" CASE 68: DRAW "NR1 D4 R1 BR1 BU1 U2" CASE 69: DRAW "NR2 D2 NR1 D2 R2" CASE 70: DRAW "NR2 D2 NR1 D2" CASE 71: DRAW "BR1 NR1 BL1 BD1 D2 BD1 BR1 R1 U2" CASE 72: DRAW "D2 ND2 R2 NU2 D2" CASE 73: DRAW "R1 NR1 D4 NL1 R1" CASE 74: DRAW "BD3 D1 R2 U4" CASE 75: DRAW "D2 NR1 D2 BR2 U1 BU2 U1" CASE 76: DRAW "D4 R2" CASE 77: DRAW "D2 ND2 R2 ND2 U1 NU1 L1" CASE 78: DRAW "ND4 R1 BR1 BD1 D3" CASE 79: DRAW "D4 R2 U4 L1" CASE 80: DRAW "ND4 R1 F1 G1" CASE 81: DRAW "ND3 R2 D4 L1 U1" CASE 82: DRAW "R1 F1 BL2 D1 NR1 D2 BR2 U1" CASE 83: DRAW "BR1 NR1 G1 F2 G1 L1" CASE 84: DRAW "R1 NR1 D4" CASE 85: DRAW "D4 R2 U4" CASE 86: DRAW "D2 F1 ND1 E1 U2" CASE 87: DRAW "D4 E1 F1 U4" CASE 88: DRAW "D1 F2 D1 BL2 U1 E2 U1" CASE 89: DRAW "D1 F1 ND2 E1 U1" CASE 90, 122: DRAW "R2 D1 G2 D1 R2" CASE 91: DRAW "BR1 NR1 D4 R1" CASE 92: DRAW "D1 F2 D1" CASE 93: DRAW "R1 D4 L1" CASE 94: DRAW "BR1 NG1 F1" CASE 95: DRAW "BD4 R2" CASE 97: DRAW "BF1 R1 D3 L1 H1 U1" CASE 98: DRAW "D4 R1 E1 U1 H1" CASE 99: DRAW "BF1 NR1 G1 D1 F1 R1" CASE 100: DRAW "BF1 E1 D4 L1 H1 U1" CASE 101: DRAW "BF1 NF1 G1 D1 R1 D1 R1" CASE 102: DRAW "BR1 G1 ND3 F1" CASE 103: DRAW "BD1 NF1 E1 R1 D3 G1 L1" CASE 104: DRAW "ND4 F2 D2" CASE 105: DRAW "BR1 D0 BD2 D2" CASE 106: DRAW "BD3 F1 E1 U1 BU2 U0" CASE 107: DRAW "D4 E1 NF1 E1" CASE 108: DRAW "BR1 R1 D4" CASE 109: DRAW "BD1 D2 ND1 R2 ND1 U1 NU1 L1" CASE 110: DRAW "BD1 ND3 R1 F1 D2" CASE 111: DRAW "BF1 G1 D1 F1 E1 U1" CASE 112: DRAW "BD1 ND3 R1 F1 G1" CASE 113: DRAW "BF1 G1 F2 U3" CASE 114: DRAW "BD1 D1 ND2 R1 E1" CASE 115: DRAW "BF1 NR1 D1 F1 D1 L1" CASE 116: DRAW "BR1 NF1 D3 F1" CASE 117: DRAW "BD1 D3 R2 U3" CASE 118: DRAW "BD1 D1 F1 ND1 E1 U1" CASE 119: DRAW "BD1 D3 E1 F1 U3" CASE 120: DRAW "BD1 F1 NE1 BD1 NF1 G1" CASE 121: DRAW "BD1 D1 F1 NG1 E1 U1" CASE 123: DRAW "BR1 R1 G2 F2 L1" CASE 124: DRAW "BR1 D4" CASE 125: DRAW "NR1 F2 G2 R1" CASE 126: DRAW "BD1 E1 R1" CASE 173: DRAW "D0 BD2 D2 R1 E1" CASE 251: DRAW "BR1 NR1 D4 BU1 L1" CASE ELSE: DRAW "D4 R1 U4 R1 D4" END SELECT NEXT a END SUB SUB MouseDriver (ax AS INTEGER, bx AS INTEGER, cx AS INTEGER, dx AS INTEGER) STATIC called AS INTEGER, mouseDrv AS STRING DIM mcount AS INTEGER, mData AS STRING IF NOT called THEN called = true RESTORE MouseData FOR mcount = 1 TO 51 READ mData mouseDrv = mouseDrv + CHR$(VAL("&H" + mData)) NEXT mcount IF NOT MouseExists THEN LOCATE 12, 6: PRINT "The mouse driver was not found": SLEEP: SYSTEM END IF DEF SEG = VARSEG(mouseDrv) CALL ABSOLUTE(ax, bx, cx, dx, SADD(mouseDrv)) DEF SEG END SUB FUNCTION MouseExists% DIM ax AS INTEGER ax = 0 MouseDriver ax, 0, 0, 0 MouseExists% = ax END FUNCTION SUB MouseHide MouseDriver 2, 0, 0, 0 END SUB SUB MouseLastPress (button, x, y) DIM bx AS INTEGER, cx AS INTEGER, dx AS INTEGER IF button <> left AND button <> RIGHT AND button <> MIDDLE THEN x = -1 y = -1 EXIT SUB END IF bx = button MouseDriver 5, bx, cx, dx IF bx = 0 THEN x = -1: y = -1 ELSE x = cx: y = dx END SUB SUB MousePosition (newX, newY) DIM cx AS INTEGER, dx AS INTEGER cx = newX dx = newY MouseDriver 4, 0, cx, dx END SUB SUB MouseSetArea (x1, y1, x2, y2) DIM cx AS INTEGER, dx AS INTEGER cx = x1 dx = x2 MouseDriver 7, 0, cx, dx cx = y1 dx = y2 MouseDriver 8, 0, cx, dx END SUB SUB MouseShow MouseDriver 1, 0, 0, 0 END SUB SUB MouseStatus (mouseX, mouseY, leftB, rightB, middleB) DIM bx AS INTEGER, cx AS INTEGER, dx AS INTEGER MouseDriver 3, bx, cx, dx IF (bx AND 1) THEN leftB = true ELSE leftB = false IF (bx AND 2) THEN rightB = true ELSE rightB = false IF (bx AND 4) THEN middleB = true ELSE middleB = false mouseX = cx mouseY = dx END SUB SUB options displayappwindow "Options" obc = bc: ofc = fc: odc = dc: otc = tc: oshellcmd = shellcmd: osaverdelay = saverdelay: owhichscreensaver = whichscreensaver DO SELECT CASE menu("Options", "Compatibility", "Color Scheme", "Screen Saver", "Reset", "Close", "", "", 75, 20) CASE 1 SELECT CASE menu("Compatibility for", LEFT$("-> ", -3 * (shellcmd = 1)) + "Windows NT, 2000 and Xp", LEFT$("-> ", -3 * (shellcmd <> 1)) + "DOS and Windows 95, 98, and ME", "", "", "", "", "", 75, 20) CASE 1: shellcmd = 1 CASE 2: shellcmd = 2 END SELECT CASE 2 done = false: DO SELECT CASE menu("Color Scheme", "Desktop", "Foreground", "Background", "Text and Border", "Preview", "Done", "", 75, 20) CASE 1: dc = dc + 1: IF dc > 15 THEN dc = 0 GOSUB displaynewcolors CASE 2: fc = fc + 1: IF fc > 15 THEN fc = 0 CASE 3: bc = bc + 1: IF bc > 15 THEN bc = 0 CASE 4: tc = tc + 1: IF tc > 15 THEN tc = 0 CASE 5: GOSUB displaynewcolors CASE 6: done = true END SELECT LOOP UNTIL done IF (bc = fc OR bc = tc OR dc = fc OR dc = tc OR fc = tc) THEN bc = obc: fc = ofc: dc = odc: tc = otc: messagewindow "The foreground and text colors must be unique!", 75, 21, 1 obc = bc: ofc = fc: odc = dc: otc = tc CASE 3 done = false: DO choice = menu("Screen Saver", LEFT$("-> ", -3 * (whichscreensaver = 1)) + "Swirled", LEFT$("-> ", -3 * (whichscreensaver = 2)) + "The Ring", LEFT$("-> ", -3 * (whichscreensaver = 3)) + "Exit iOS", "Preview", "Delay", "Done", "", 75, 20) SELECT CASE choice CASE 0 CASE IS <= 3: whichscreensaver = choice CASE 4: sleeep .5: screensaver: IF hmission = 8 THEN hmission = 9: hiddenmission: GOSUB displaynewcolors ELSE displayappwindow "Options" CASE 5 DO SELECT CASE menu("Screen Saver Delay", LEFT$("-> ", -3 * (saverdelay = 10)) + "10 Seconds", LEFT$("-> ", -3 * (saverdelay = 30)) + "30 Seconds", LEFT$("-> ", -3 * (saverdelay = 60)) + "1 Minute", LEFT$("-> ", -3 * (saverdelay = 300)) + "5 Minutes", LEFT$("-> ", -3 * (saverdelay = 600)) + "10 Minutes", "Done", "", 75, 20) CASE 1: saverdelay = 10 CASE 2: saverdelay = 30 CASE 3: saverdelay = 60 CASE 4: saverdelay = 300 CASE 5: saverdelay = 600 CASE 6: done = true END SELECT LOOP UNTIL done done = false CASE 6: done = true END SELECT LOOP UNTIL done CASE 4 SELECT CASE menu("Reset", "Previous Settings", "Default", "Cancel", "", "", "", "", 75, 20) CASE 1: bc = obc: fc = ofc: dc = odc: tc = otc: shellcmd = oshellcmd: saverdelay = osaverdelay: whichscreensaver = owhichscreensaver: GOSUB displaynewcolors CASE 2: bc = 9: fc = 6: dc = 9: tc = 0: saverdelay = 60: shellcmd = 1: whichscreensaver = 1: GOSUB displaynewcolors END SELECT CASE 5: quit = true END SELECT LOOP UNTIL quit IF obc <> bc OR ofc <> fc OR odc <> dc OR otc <> tc OR oshellcmd <> shellcmd OR osaverdelay <> saverdelay THEN z = FREEFILE: OPEN "options.txt" FOR OUTPUT AS #z: WRITE #z, dc, fc, tc, bc WRITE #z, whichscreensaver, saverdelay: WRITE #z, shellcmd: CLOSE #z END IF display 1 EXIT SUB displaynewcolors: display 2: displayappwindow "Options": display 9 RETURN END SUB SUB readbrowserfiles IF started THEN browser = 1 messagewindow "Please Wait...", 405, 20, 0 SELECT CASE bpath$ CASE "My Computer" bicount = 0 FOR a = 65 TO 90 IF a <> 66 THEN IF driveready(CHR$(a)) THEN bicount = bicount + 1: bi$(bicount, 1) = "Drive " + CHR$(a): bi$(bicount, 2) = " files.tmp" bacross = 0: bicount = 0: OPEN "files.tmp" FOR INPUT AS #1 FOR a = 1 TO 4: LINE INPUT #1, data$: NEXT a WHILE NOT EOF(1) AND bicount < 256: bicount = bicount + 1 LINE INPUT #1, data$: a = INSTR(data$, " ") IF a > 0 THEN IF a = 1 OR LEFT$(data$, a - 1) = "." OR LEFT$(data$, a - 1) = ".." THEN bicount = bicount - 1 ELSE GOSUB assign ELSE bicount = bicount - 1 WEND CLOSE #1 IF bicount = 0 THEN bicount = 1: bi$(1, 1) = "iOS": bi$(1, 2) = "DAT" IF UCASE$(bpath$) = UCASE$(path$) THEN messagewindow "Warning! These files are used by iOS and should not be modified!", 280, 20, 1: IF hmission = 4 THEN hmission = 5: hiddenmission END SELECT display 3 ON ERROR GOTO handling EXIT SUB assign: bi$(bicount, 1) = LEFT$(data$, a - 1) WHILE MID$(data$, a, 1) = " " AND a < LEN(data$) - 3: a = a + 1: WEND IF a = LEN(data$) - 3 THEN bi$(bicount, 2) = "" ELSE bi$(bicount, 2) = MID$(data$, a, 3) RETURN END SUB SUB readdicons ON ERROR GOTO missingdicons dicount = 0: OPEN "dicons.txt" FOR INPUT AS #1: WHILE NOT EOF(1): dicount = dicount + 1: INPUT #1, di$(dicount, 1), di$(dicount, 2), di$(dicount, 3): WEND: CLOSE #1 ON ERROR GOTO handling END SUB SUB resettimer ttime = INT(TIMER - time): ptime = ttime: mtime = ptime END SUB SUB savetemp z = FREEFILE OPEN "temp.txt" FOR OUTPUT AS #z: WRITE #z, bpath$, browser, ((hmission + 3) ^ 2 - 4) / 5: CLOSE #z END SUB SUB screensaver MouseHide LINE (0, 0)-(639, 479), bc, BF MouseStatus x, y, 0, 0, 0: px = x: py = y: quit = 0: key$ = "" SELECT CASE whichscreensaver CASE 1 angle = 0: inc = .305: parts = 16: c = tc WHILE quit = 0 FOR a = 1 TO 240 STEP 1 FOR B = 0 TO 16 PSET (320 + a * COS((angle - inc) + B * pi * 2 / parts + SIN(a / 50 * pi)), 240 + a * SIN((angle - inc) + B * pi * 2 / parts + SIN(a / 50 * pi))), bc PSET (320 + a * COS(angle + B * pi * 2 / parts + SIN(a / 50 * pi)), 240 + a * SIN(angle + B * pi * 2 / parts + SIN(a / 50 * pi))), c NEXT B px = x: py = y: MouseStatus x, y, lb, rb, 0: IF px <> x OR py <> y OR lb OR rb THEN a = 240: quit = 1 key$ = INKEY$: IF key$ = CHR$(27) THEN a = 240: quit = 1 ELSE IF key$ = " " THEN c = INT(RND * 9) + 7 NEXT a angle = angle + inc WEND CASE 2 B = 300: c = tc: e = 8: d = 0: g = 2: h = .05: i = 240: j = 4 WHILE quit = 0 FOR f = 1 TO 5: FOR a = 0 TO pi * 2 STEP .01 PSET (320 + B * COS(a) + e * COS(d - 1572.5), 240 + B * SIN(a) / (g - h) + e * SIN(d - 1572.5)), bc PSET (320 + B * COS(a) + e * COS(d), 240 + B * SIN(a) / g + e * SIN(d)), c d = d + .5 NEXT a px = x: py = y: MouseStatus x, y, lb, rb, 0: IF px <> x OR py <> y OR lb OR rb THEN a = 2 * pi: quit = 1 key$ = INKEY$: IF key$ = CHR$(27) THEN a = pi * 2: quit = 1 ELSE IF key$ = " " THEN c = INT(RND * 9) + 7 NEXT f g = g + h WEND CASE 3 MouseStatus px, py, 0, 0, 0 FOR a = 1 TO 320 LINE (320 - a, 240 - a)-(320 + a, 240 + a), tc, BF NEXT a MouseStatus x, y, lb, rb, 0 IF INKEY$ = "" AND px = x AND py = y AND lb = false AND rb = false THEN savetemp messagewindow "Goodbye!", 256, 150, 0 OPEN "log.txt" FOR APPEND AS #1: PRINT #1, "iOS terminated by screensaver at " + TIME$ + " on " + DATE$ + ".": CLOSE #1 COLOR 0: sleeep 1.5 SYSTEM ELSE display 1 END IF END SELECT MouseShow END SUB FUNCTION selectfile$ 'This will not be implemented until Version 1.2x selectfile$ = "test.dat" END FUNCTION SUB sleeep (time) FOR a = 1 TO nextspeed * time: NEXT a END SUB FUNCTION typein$ (info$, max, x, y) IF started = false THEN EXIT FUNCTION maxx = x + 4 * max + 80: IF maxx < x + 4 * LEN(info$) + 40 THEN maxx = x + 4 * LEN(info$) + 40 GOSUB displaytypein lb = true: plb = lb: quit = false: key$ = "": text$ = "" WHILE quit = false IF lb AND plb = false AND mx > x AND mx < maxx AND my > y AND my < y + 7 THEN GOSUB movetypein IF LEN(key$) = 1 AND key$ <> CHR$(8) AND key$ <> CHR$(9) AND LEN(text$) < max THEN text$ = text$ + key$ IF key$ = CHR$(8) AND LEN(text$) > 0 THEN text$ = LEFT$(text$, LEN(text$) - 1) IF LEN(key$) > 0 THEN GOSUB displaytypeintext key$ = INKEY$: IF key$ = CHR$(13) OR key$ = CHR$(27) THEN quit = true plb = lb: MouseStatus mx, my, lb, 0, 0 IF plb = false AND lb AND mx > x + 3 AND mx < x + 21 AND my > y + 39 AND my < y + 47 THEN quit = true WEND: typein$ = text$ GOSUB erasetypein resettimer EXIT FUNCTION displaytypein: MouseHide getpic x, y, maxx, y + 50 LINE (x, y)-(maxx, y + 50), tc, B LINE (x + 1, y + 1)-(maxx - 1, y + 7), fc, BF LINE (x + 1, y + 8)-(maxx - 1, y + 49), bc, BF minitext info$, x + 1, y + 1, fc, tc minitext "Okay", x + 4, y + 40, bc, tc: LINE (x + 3, y + 39)-(x + 21, y + 47), tc, B GOSUB displaytypeintext MouseShow RETURN displaytypeintext: MouseHide minitext LEFT$(text$ + SPACE$(max), max), x + 40, y + 16, bc, tc LINE (x + 39, y + 15)-(x + 4 * max + 41, y + 23), tc, B MouseShow RETURN erasetypein: MouseHide PUT (x, y), pic%, PSET MouseShow RETURN movetypein: WHILE lb px = mx: py = my: MouseStatus mx, my, lb, 0, 0 IF mx <> px OR my <> py THEN GOSUB erasetypein xmove = mx - px: IF x + xmove < 0 THEN xmove = -x ymove = my - py: IF y + ymove < 0 THEN ymove = -y x = x + xmove: maxx = maxx + xmove: y = y + ymove: maxy = maxy + ymove GOSUB displaytypein sleeep .5 END IF WEND RETURN END FUNCTION

(C) 2006 i-TECH