
DIM col(3, 13)
DIM cname$(15)
DIM savcol(13)
DIM dir$(100)
DIM disc$(100)

GOSUB 800: REM read config files

REM read internal data
FOR a = 1 TO 3
FOR b = 13 TO 1 STEP -1
READ col(a, b)
NEXT b
NEXT a
FOR a = 1 TO 15
READ cname$(a)
NEXT a

REM command$
cmd = VAL(COMMAND$)
IF cmd = 0 GOTO 10
8 k2 = 0: k1 = cmd + 48
GOTO 21

10 CLS
IF cmd > 0 GOTO 1000
COLOR 14
PRINT "           Starmap Configuration"
COLOR 10
PRINT "   (for help contact: jimv@empirenet.com)"
PRINT
COLOR 11
PRINT "Current Setup"
COLOR 12
PRINT "------------------------------------------"
COLOR 11
FOR a = 1 TO 6
PRINT LTRIM$(RTRIM$(STR$(a)));
PRINT ") "; lin$(a);
PRINT
NEXT a
PRINT "7) colors:";
SELECT CASE VAL(RIGHT$(lin$(7), 1))
CASE 1
   PRINT "colors on black"
CASE 2
   PRINT "colors on white"
CASE 3
   PRINT "white on black"
CASE 4
   PRINT "black on white"
END SELECT
PRINT "8) Modify Color Chart"
COLOR 9
PRINT
PRINT "(Esc) to Quit or # of selection to modify: ";
COLOR 11

20 REM get input
GOSUB 60
IF k2 = 0 AND k1 = 27 GOTO 1000: REM esc
IF k2 = 0 AND (k1 = 81 OR k1 = 113) GOTO 1000: REM Q/q
21 IF k2 = 0 AND k1 = 49 GOTO 200: REM 1
IF k2 = 0 AND k1 = 50 GOTO 300: REM 2
IF k2 = 0 AND k1 = 51 GOTO 400: REM 3
IF k2 = 0 AND k1 > 51 AND k1 < 55 GOTO 500: REM 4,5,6
IF k2 = 0 AND k1 = 55 GOTO 100: REM 7
IF k2 = 0 AND k1 = 56 GOTO 600: REM 8
GOTO 20

60 REM read keyboard
k1 = 0: k2 = 0
62 k$ = INKEY$
IF k$ = "" THEN GOTO 62
SOUND 10000, .1
k1 = ASC(k$)
IF k1 <> 13 THEN GOTO 63
FOR note = 1 TO 10
SOUND note * 200, .1
NEXT note
63 IF k1 <> 0 THEN GOTO 64
k1 = ASC(RIGHT$(k$, 1))
k2 = 1
64 RETURN

100 REM colors
CLS
COLOR 11
PRINT "Starmap typically displays its maps with a black"
PRINT "background, however, since you may wish to take"
PRINT "screen snapshots from the printer, you might prefer"
PRINT "a white background instead. Please choose from"
PRINT "among the following options:"
PRINT
PRINT "(1) Colors on Black      (3) White on Black"
PRINT "(2) Colors on White      (4) Black on White"
PRINT
120 REM get input
GOSUB 60
IF k2 = 0 AND k1 = 27 GOTO 10: REM esc
IF k2 = 0 AND (k1 = 81 OR k1 = 113) GOTO 10: REM Q/q
IF k2 = 0 AND k1 >= 49 AND k1 <= 52 GOTO 130: REM 1-4
GOTO 120
130 REM the choice is made
lin$(7) = "colors:" + CHR$(k1)
GOTO 10

200 REM choose editor
CLS : COLOR 11
PRINT "When viewing quadrant maps, you have the option to edit"
PRINT "the quadrant data file ('<' key), or create text"
PRINT "attachments ('insert' key), or edit those attachments"
PRINT "descriptions if they already exist ('>' key). The only"
PRINT "question, of course, is which editor do you want to use?"
PRINT "An easy one called 'edit' is supplied with the most"
PRINT "recent versions of DOS, however, it's a glutton for"
PRINT "memory and may end up causing problems. One more"
PRINT "preferred by UNIX aficionados is called 'vi' and is"
PRINT "supplied with Starmap if you would prefer using that"
PRINT "instead. Yet another, called 'ted' is also suppied, and"
PRINT "ted has the advantage of being highly light-weight in"
PRINT "terms of memory usage. Alternately, you might have"
PRINT "another favorite editor. Enter the name of the editor"
PRINT "you want to use at the prompt or just hit <enter> to"
PRINT "choose 'ted'."
PRINT
COLOR 13
INPUT "Editor --->", t$
IF t$ = "" THEN t$ = "ted"
lin$(1) = "editor:" + t$
GOTO 10

300 REM reader
CLS : COLOR 11
PRINT "When viewing quadrant maps, you have the option to read"
PRINT "various world descriptions which you have previously"
PRINT "created ('enter' key used at a filled circle). When you do"
PRINT "this, what you are actually doing is accessing a text"
PRINT "file with some variety of text reading software. One"
PRINT "common text reader used in the UNIX environment is called"
PRINT "'less', and a DOS version of 'less' is supplied as part"
PRINT "of this software package. One problem with 'less',"
PRINT "however, is that it ignores tilde (~) characters. Hence,"
PRINT "WWW addresses tend to get screwed up. There is also a"
PRINT "text reader called 'browse' which is also available."
PRINT "However, you may have another text reader which you'd"
PRINT "prefer to use. If so, enter the name of that reader at"
PRINT "the prompt or just hit <enter> if you want to use 'less'."
PRINT
COLOR 13
INPUT "Reader --->", t$
IF t$ = "" THEN t$ = "less"
lin$(2) = "reader:" + t$
GOTO 10

400 REM choose galaxy
FOR a = 1 TO 100
   dir$(a) = ""
   disc$(a) = ""
NEXT a
REM read "lst" file
f$ = "galaxy.lst"
page = 1: i = 0
OPEN "i", 1, f$
LINE INPUT #1, cfg1$
LINE INPUT #1, cfg2$
DO UNTIL EOF(1)
   LINE INPUT #1, t$
   t$ = RTRIM$(t$)
   IF t$ <> "" THEN
      l = LEN(t$): i = i + 1
      dir$(i) = LCASE$(RTRIM$(LEFT$(t$, 8)))
      disc$(i) = RIGHT$(t$, l - 13)
   END IF
LOOP
numitems = i
CLOSE 1

405 REM show page of twenty
CLS : COLOR 10
PRINT cfg1$; SPACE$(26 + choice); "Page"; page
PRINT cfg2$
COLOR 11
FOR j = 1 TO 20
   i = (page - 1) * 20 + j
   PRINT CHR$(64 + j); ") ";
   PRINT dir$(i);
   PRINT SPACE$(14 - LEN(dir$(i)));
   PRINT disc$(i)
NEXT j

PRINT
COLOR 14: PRINT "Esc";
COLOR 12: PRINT " to Quit,";
COLOR 14: PRINT " Ins";
COLOR 12: PRINT " to Create a New Galaxy, ";
COLOR 14: PRINT "PgUp";
COLOR 12: PRINT "/";
COLOR 14: PRINT "PgDn";
COLOR 12: PRINT " to Switch Pages ";
410 GOSUB 60
IF k2 = 0 AND (k1 >= 97 AND k1 <= 122) THEN k1 = k1 - 32
IF k2 = 0 AND k1 = 27 THEN GOTO 10: REM esc
IF k2 = 0 AND (k1 >= 65 AND k1 <= 84) GOTO 420: REM A-T
IF k2 = 1 AND k1 = 82 GOTO 450: REM Ins
IF k2 = 1 AND (k1 = 73 OR k1 = 81) THEN GOTO 430: REM pgup/pgdn
GOTO 410

420 REM a-t
i = k1 - 64 + ((page - 1) * 20)
IF dir$(i) = "" GOTO 410
lin$(3) = "galaxy:" + dir$(i)
IF cmd > 0 THEN dontcord = 1
GOTO 10

430 REM pgup/pgdn
IF k1 = 73 THEN page = page - 1
IF k1 = 81 THEN page = page + 1
IF page = 0 THEN page = 5
IF page = 6 THEN page = 1
GOTO 405

450 REM insert
IF numitems < 100 GOTO 455
CLS
PRINT "No can do. You already have a hundred galaxies on file."
PRINT : PRINT "<Hit any key>"
GOSUB 60
GOTO 405
455 CLS : COLOR 11
PRINT "The program will automatically create a directory for"
PRINT "your new galaxy to be placed into (which you must name)."
PRINT

COLOR 10
PRINT "Are you sure you really want to create a new galaxy?";
460 GOSUB 60
IF k2 = 0 AND (k1 >= 97 AND k1 <= 122) THEN k1 = k1 - 32
IF k2 = 0 AND k1 = 89 GOTO 465: REM Y
IF k2 = 0 AND k1 = 78 GOTO 405: REM N
GOTO 460
465 COLOR 12
PRINT "   Yes"
PRINT

COLOR 11
PRINT "Enter the Name of the Galaxy (40 characters max)"
PRINT "   (For example: The Milky Way)";
470 LOCATE 9, 1: PRINT SPACE$(70);
LOCATE 9, 1
INPUT "--->", t$
IF t$ = "" GOTO 470
t$ = LTRIM$(RTRIM$(t$))
IF LEN(t$) > 40 GOTO 470
PRINT
galname$ = t$

PRINT "Please provide a directory name (8 characters or less)"
PRINT
480 LOCATE 13, 1
PRINT SPACE$(70)
LOCATE 13, 1: INPUT "--->", t$
t$ = LCASE$(LTRIM$(RTRIM$(t$)))
IF t$ = "" GOTO 480
l = LEN(t$)
IF RIGHT$(t$, 1) = "\" THEN
   l = l - 1
   t$ = LEFT$(t$, l)
END IF
ok = 1
FOR a = 1 TO numitems
IF t$ = dir$(a) THEN ok = 2
NEXT a
IF INSTR(t$, ".") > 0 THEN ok = 4
IF l > 8 THEN ok = 3
IF ok = 2 THEN PRINT "   <directory already exists, try again>"
IF ok = 3 THEN PRINT "   <8 characters maximum, try again>    "
IF ok = 4 THEN PRINT "   <no extension required, try again>   "
IF ok <> 1 GOTO 480
dirname$ = t$

REM new galaxy set-up
REM update galaxy.lst
l = LEN(dirname$)
t$ = dirname$ + SPACE$(13 - l) + galname$
OPEN "a", 1, "galaxy.lst"
PRINT #1, t$
CLOSE 1
REM create galaxy's directory
SHELL "mkdir " + dirname$
SHELL "mkdir " + dirname$ + "\gen"
SHELL "mkdir " + dirname$ + "\loc"
SHELL "mkdir " + dirname$ + "\map"
SHELL "mkdir " + dirname$ + "\dat"
REM create general info menu
OPEN "o", 1, dirname$ + "\gen\galaxy.mnu"
PRINT #1, "@dir="; dirname$; "\gen"
PRINT #1, "@Light Yellow"
PRINT #1, ""
PRINT #1, galname$; " / General Information"
PRINT #1, ""
PRINT #1, ""
PRINT #1, "@Light Cyan"
PRINT #1, "      Credits                @..\credits.txt"
PRINT #1, "      Topics & Methods       @ideas.txt"
CLOSE 1
SHELL "copy help\ideas.txt " + dirname$ + "\gen"
SHELL "copy data\start\credits.txt " + dirname$
SHELL "copy data\start\gov.dat " + dirname$ + "\dat"
SHELL "copy data\start\coords.dat " + dirname$ + "\dat"
lin$(3) = "galaxy:" + dirname$
lin$(4) = "x:0"
lin$(5) = "y:0"
lin$(6) = "z:0"

CLS : COLOR 11: LOCATE 5, 1
PRINT "Created:"
PRINT "   "; dirname$; ": credits.txt"
PRINT "   "; dirname$; "\dat: coords.dat, gov.dat"
PRINT "   "; dirname$; "\gen: galaxy.mnu"
PRINT "   "; dirname$; "\loc (this is where the map attachments go)"
PRINT "   "; dirname$; "\map (this is where the quadrant maps go)"
PRINT
COLOR 10
PRINT "Would you like to fill up the "; dirname$; "\map directory with"
PRINT "quadrant maps at this time?"
490 GOSUB 60
IF k2 = 0 AND (k1 >= 97 AND k1 <= 122) THEN k1 = k1 - 32
IF k2 = 0 AND k1 = 89 GOTO 492: REM Y
IF k2 = 0 AND k1 = 78 GOTO 10: REM N
GOTO 490
492 REM run fillgal.exe
SHELL "fillgal " + dirname$ + "\map"
GOTO 10

500 CLS
COLOR 11
PRINT "When you first enter Starmap, the program needs to know"
PRINT "your starting location, so it knows what portion of the"
PRINT "map to show you. Your location is represented by X,Y,Z"
PRINT "coordinates which designate your location relative to the"
PRINT "map's origin (0,0,0) (which in the Ragamuffin RPG is our"
PRINT "Solar System)."
PRINT
PRINT "You chose to modify the "; CHR$(k1 + 36); " coordinate,";
PRINT " so go ahead and"
PRINT "enter that coordinate at the prompt below. The coordinate"
PRINT "you enter must be an integer (a whole number) within some"
PRINT "reasonable range. Hit <enter> if you want to choose '0'"
PRINT "as the "; CHR$(k1 + 36); " coordinate."
PRINT
COLOR 13
PRINT CHR$(k1 + 36); " Coordinate --->";
INPUT "", t$
IF t$ = "" THEN t$ = "0"
t = INT(VAL(t$))
t$ = LTRIM$(RTRIM$(STR$(t)))
lin$(k1 - 48) = CHR$(k1 + 69) + ":" + t$
GOTO 10

600 REM color chart
CLS
COLOR 11
PRINT "Starmap uses colors to identify the relative depth of the"
PRINT "various starsystems it maps. There are three default"
PRINT "configurations you can choose from: Warm-first, Bright-"
PRINT "first, or Warm&Bright-first. Warm-first simply gives"
PRINT "warm colors to stars above the user and cold colors to"
PRINT "stars below the user. Bright-first gives bright colors"
PRINT "to stars above the user and dim colors to stars below,"
PRINT "and Warm&Bright-first tries to combine the two criteria."
PRINT "Alternately, you may want to devise your own color chart."
PRINT
COLOR 10
PRINT "1) Warm-first"
PRINT "2) Bright-first"
PRINT "3) Warm&Bright-first"
PRINT "4) Customize Color Chart"
PRINT
COLOR 14
PRINT "(Esc) or Select a Color Chart: ";
610 REM get input
GOSUB 60
IF k2 = 0 AND k1 = 27 GOTO 10: REM esc
IF k2 = 0 AND (k1 = 81 OR k1 = 113) GOTO 10: REM Q/q
IF k2 = 0 AND k1 > 48 AND k1 < 52 GOTO 620: REM 1-3
IF k2 = 0 AND k1 = 52 GOTO 630: REM 4
GOTO 610

620 CLS
IF k1 = 49 THEN PRINT "Warm-first Color Chart"
IF k1 = 50 THEN PRINT "Bright-first Color Chart"
IF k1 = 51 THEN PRINT "Warm&Bright-first Color Chart"
PRINT
FOR a = 6 TO -6 STEP -1
c$ = LTRIM$(RTRIM$(STR$(a)))
IF a > 0 THEN c$ = "+" + c$
IF a = 0 THEN c$ = " " + c$
COLOR col(k1 - 48, a + 7)
PRINT c$; "  "; cname$(col(k1 - 48, a + 7))
savcol(a + 7) = col(k1 - 48, a + 7)
NEXT a
GOSUB 60
GOTO 600

630 CLS
COLOR 14
PRINT "Modify Current Color Chart"
PRINT
FOR a = 15 TO 1 STEP -1
LOCATE 18 - a, 40
COLOR a
PRINT CHR$(80 - a); ": "; cname$(a)
NEXT a
FOR a = 6 TO -6 STEP -1
c$ = LTRIM$(RTRIM$(STR$(a)))
IF a > 0 THEN c$ = "+" + c$
IF a = 0 THEN c$ = " " + c$
COLOR 9
IF a = 0 THEN COLOR 11
LOCATE 10 - a, 5
PRINT c$; ": ";
COLOR savcol(a + 7)
PRINT cname$(savcol(a + 7))
LOCATE 19, 1
COLOR 5
PRINT "                (Arrow Keys, A-O, or Esc)"
NEXT a
row = 0
635 REM make arrow
LOCATE 10 - row, 2
COLOR 12
PRINT CHR$(196); CHR$(26);
GOSUB 60
IF k2 = 0 AND k1 = 27 GOTO 600: REM esc
IF k2 = 0 AND (k1 = 81 OR k1 = 113) GOTO 600: REM Q/q
IF k2 = 0 AND k1 > 64 AND k1 < 80 GOTO 660
IF k2 = 0 AND k1 > 96 AND k1 < 112 GOTO 660
IF k2 = 1 AND (k1 = 72 OR k1 = 75) THEN GOTO 640: REM up/left
IF k2 = 1 AND (k1 = 80 OR k1 = 77) THEN GOTO 650: REM down/right
GOTO 635

640 REM up
LOCATE 10 - row, 2
PRINT "  "
IF row < 6 THEN row = row + 1
GOTO 635

650 REM down
LOCATE 10 - row, 2
PRINT "  "
IF row > -6 THEN row = row - 1
GOTO 635

660 REM select
IF k1 > 96 THEN k1 = k1 - 32
COLOR 80 - k1
savcol(row + 7) = 80 - k1
LOCATE 10 - row, 9
PRINT SPC(30);
LOCATE 10 - row, 9
PRINT cname$(80 - k1)
GOTO 635

800 REM read config files
REM read starmap.cfg
OPEN "i", 1, "starmap.cfg"
FOR a = 1 TO 3
LINE INPUT #1, lin$(a)
NEXT a
LINE INPUT #1, lin$(7)
CLOSE 1
REM read coords.dat
cordfile$ = RIGHT$(lin$(3), LEN(lin$(3)) - 7) + "\dat\coords.dat"
OPEN "i", 1, cordfile$
FOR a = 4 TO 6
LINE INPUT #1, lin$(a)
NEXT a
CLOSE 1
REM read colors.dat
OPEN "i", 1, "data\colors.dat"
FOR a = 13 TO 1 STEP -1
INPUT #1, t$
savcol(a) = VAL(LEFT$(t$, 2))
NEXT a
CLOSE 1
RETURN

900 REM write config files
REM write starmap.cfg
OPEN "o", 1, "starmap.cfg"
FOR a = 1 TO 3
 PRINT #1, lin$(a)
NEXT a
PRINT #1, lin$(7)
CLOSE 1
REM write coords.dat
IF dontcord = 0 THEN
 cordfile$ = RIGHT$(lin$(3), LEN(lin$(3)) - 7) + "\dat\coords.dat"
 OPEN "o", 1, cordfile$
 FOR a = 4 TO 6
  PRINT #1, lin$(a)
 NEXT a
 CLOSE 1
END IF
REM write colors.dat
OPEN "o", 1, "data\colors.dat"
FOR a = 13 TO 1 STEP -1
 t$ = LTRIM$(RTRIM$(STR$(savcol(a))))
 IF LEN(t$) = 1 THEN t$ = "0" + t$
 t$ = t$ + " " + cname$(savcol(a))
 PRINT #1, t$
NEXT a
CLOSE 1
RETURN

DATA 4,4,12,12,14,14,15,11,11,3,3,9,9
DATA 15,14,11,10,12,13,3,2,4,5,9,8,1
DATA 15,14,12,4,13,5,11,3,10,2,9,1,8
DATA "Dark Blue","Dim Green","Dim Cyan"
DATA "Dim Red","Dim Magenta","Brown"
DATA "Dim White","Grey","Light Blue"
DATA "Light Green","Light Cyan","Light Red"
DATA "Light Magenta","Yellow","Bright White"

1000 REM
GOSUB 900
COLOR 7: CLS
PRINT
PRINT "For Assistance and/or Snide Remarks:"
PRINT
PRINT "     Email: jimv@empirenet.com"
PRINT "            JimVassila@aol.com"
PRINT
PRINT "  Homepage: http://members.aol.com/jimvassila"
PRINT
END

