DIM lin$(3)
DIM dir$(100)
DIM disc$(100)

REM Mapper Configuration v1.0
REM Public Domain 1997 Jim Vassilakos

REM read configuration
OPEN "i", 1, "mapper.cfg"
FOR a = 1 TO 3
   LINE INPUT #1, lin$(a)
NEXT a
CLOSE 1

REM command$
cmd = VAL(COMMAND$)
IF cmd = 0 GOTO 10
8 k2 = 0: k1 = cmd + 48
GOTO 21

10 REM main menu
IF cmd <> 0 GOTO 10000
CLS : COLOR 13
PRINT "           Mapper Configuration"
COLOR 9
PRINT "  (for help contact: jimv@empirenet.com)"
PRINT
COLOR 11
PRINT "Current Setup"
COLOR 12
PRINT "------------------------------------------"
COLOR 11

FOR a = 1 TO 3
PRINT LTRIM$(RTRIM$(STR$(a)));
PRINT ") "; lin$(a);
PRINT
NEXT a

PRINT
COLOR 14: PRINT "Esc";
COLOR 12: PRINT " to Quit or ";
COLOR 14: PRINT "# of selection";
COLOR 12: PRINT " to modify: ";
COLOR 11

20 REM get input
GOSUB 60
IF k2 = 0 AND k1 = 27 GOTO 10000: REM esc
IF k2 = 0 AND (k1 = 81 OR k1 = 113) GOTO 10000: REM Q/q
21 IF k2 = 0 AND k1 = 49 GOTO 100: REM 1
IF k2 = 0 AND k1 = 50 GOTO 200: REM 2
IF k2 = 0 AND k1 = 51 GOTO 400: REM 3
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 editor
CLS
COLOR 11
PRINT "When viewing subsector maps, you have the option to edit"
PRINT "the subsector data file ('<' key), or create world"
PRINT "description files ('enter' key), or edit those world"
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 Galactic 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

200 REM reader
CLS
COLOR 11
PRINT "When viewing subsector maps, you have the option to read"
PRINT "various world descriptions which you have previously"
PRINT "created ('enter' key used at a red hex). 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/sector
FOR a = 1 TO 100
   dir$(a) = ""
   disc$(a) = ""
NEXT a
choice = k1 - 48
REM read "lst" file
IF choice = 3 THEN f$ = "mapper.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 World, ";
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) = "world:" + dir$(i)
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 THEN
   CLS
   PRINT "No can do. You already have a hundred worlds on file."
   PRINT : PRINT "<Hit any key>"
   GOSUB 60
   GOTO 405
END IF
CLS : COLOR 11
PRINT "The program will automatically create a directory for"
PRINT "your new world to be placed into (which you must name)."
PRINT

COLOR 10
PRINT "Are you sure you really want to create a new world?";
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 ";
IF choice = 3 THEN PRINT "World (40 characters max)"
PRINT "   (For example: Earth)"
locline = 13
470 LOCATE locline, 1: PRINT SPACE$(70);
LOCATE locline, 1
INPUT "--->", t$
IF t$ = "" GOTO 470
t$ = LTRIM$(RTRIM$(t$))
IF LEN(t$) > 40 GOTO 470
PRINT
secname$ = t$

locline = locline + 4
PRINT "Please provide a directory name (8 characters or less)"
PRINT
480 LOCATE locline, 1
PRINT SPACE$(70)
LOCATE locline, 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 world set-up
REM update gal.lst
l = LEN(dirname$)
t$ = dirname$ + SPACE$(13 - l) + secname$
OPEN "a", 1, "mapper.lst"
PRINT #1, t$
CLOSE 1
REM create world's directory
SHELL "mkdir " + dirname$
SHELL "mkdir " + dirname$ + "\gen"
SHELL "mkdir " + dirname$ + "\loc"
SHELL "mkdir " + dirname$ + "\map"
REM create general info menu
OPEN "o", 1, dirname$ + "\gen\world.mnu"
PRINT #1, "@dir="; dirname$; "\gen"
PRINT #1, "@Light Yellow"
PRINT #1, ""
PRINT #1, secname$; " / General Information"
PRINT #1, ""
PRINT #1, ""
PRINT #1, "@Light Cyan"
PRINT #1, "      Credits       @credits.txt"
CLOSE 1
SHELL "copy data\start\credits.txt " + dirname$ + "\gen"
SHELL "copy data\start\objects.dat " + dirname$ + "\map"
SHELL "copy data\start\n000e000.map " + dirname$ + "\map"
SHELL "copy data\start\colorkey.dat " + dirname$ + "\map"
GOTO 8

9000 REM y/n
yn$ = ""
GOSUB 60
IF k2 = 0 AND (k1 >= 97 AND k1 <= 122) THEN k1 = k1 - 32
IF k2 = 0 AND k1 = 78 THEN yn$ = "n": REM N
IF k2 = 0 AND k1 = 89 THEN yn$ = "y": REM Y
IF yn$ = "" GOTO 9000
RETURN

10000 REM
OPEN "o", 1, "mapper.cfg"
FOR a = 1 TO 3
PRINT #1, lin$(a)
NEXT a
CLOSE 1
COLOR 7: CLS
PRINT "Been fun..."
END

