REM Convert warriors to RedMixer format 5/10/09 REM Prompts for input warrior then can generate a single REM converted warrior or copy to all soup locations PRINT "Convert to RedMixer format..." ON ERROR GOTO errortrap GOTO getinfo errortrap: PRINT "An error occured." CLOSE SYSTEM getinfo: PRINT "Select coresize 1) 80 2) 800 3) 8000 "; coresize = 0 WHILE coresize = 0 a$ = INKEY$ IF a$ = "1" THEN coresize = 80: warlen = 5 IF a$ = "2" THEN coresize = 800: warlen = 20 IF a$ = "3" THEN coresize = 8000: warlen = 100 WEND PRINT coresize PRINT "Select 1) single output or 2) clone to all soup positions "; outputmode = 0 WHILE outputmode = 0 a$ = INKEY$ IF a$ = "1" THEN outputmode = 1 IF a$ = "2" THEN outputmode = 2 WEND IF outputmode = 1 THEN PRINT "Single." ELSE PRINT "Clone to soup." INPUT "Soup X Size"; xsize INPUT "Soup Y Size"; ysize PRINT "Soup directory (must exist): "; : LINE INPUT soupdir$ END IF promptforfile: PRINT "Input warrior filename (enter to exit): "; LINE INPUT inputfile$ inputfile$ = LTRIM$(RTRIM$(inputfile$)) IF inputfile$ = "" THEN GOTO done OPEN inputfile$ FOR INPUT AS #1 CLOSE #1 PRINT "Tag string (i.e. 77_77): "; : LINE INPUT tag$ PRINT "Output filename: "; : LINE INPUT outputfile$ outputfile$ = LTRIM$(RTRIM$(outputfile$)) IF outputfile$ = "" THEN GOTO done 'convert file to load format... pmars$ = "pmars -s " + STR$(coresize) + " -l " + STR$(warlen) + " -r 0 " + inputfile$ SHELL pmars$ + " > rmxconv_.tmp" 'pmars "load" format looks like... 'Program "name" (length #) by "author" ' ' ORG START 'START SPL.B $ 2, * -699 ' SPL.B $ 1, { -2543 '(one empty line) 'need to convert to... ';redcode ';name tag ';author converted by rmxconv.bas ';strategy unknown ';origin tag Program "name" (length #) by "author" ';parents none ';generation 0 ';assert 1 'spl.b $ 2 , * 7301 'spl.b $ 1 , { 5457 'end 0 ';species tag PRINT "Converting..." OPEN "rmxconv_.tmp" FOR INPUT AS #1 OPEN outputfile$ FOR OUTPUT AS #2 endofwarrior = 0 endnumber = 0 lineaddress = 0 LINE INPUT #1, title$ LINE INPUT #1, dummy$ LINE INPUT #1, dummy$ PRINT #2, ";redcode" PRINT #2, ";name "; tag$ PRINT #2, ";author converted by rmxconv.bas" PRINT #2, ";strategy unknown" PRINT #2, ";origin "; tag$; " "; title$ PRINT #2, ";parents none" PRINT #2, ";generation 0" PRINT #2, ";assert 1" WHILE NOT EOF(1) AND NOT endofwarrior LINE INPUT #1, warline$ IF warline$ = "" THEN endofwarrior = 1 ELSE IF LEFT$(warline$, 5) = "START" THEN endnumber = lineaddress instrmod$ = LCASE$(MID$(warline$, 8, 6)) amode$ = MID$(warline$, 15, 1) adata = VAL(MID$(warline$, 17, 5)) bmode$ = MID$(warline$, 24, 1) bdata = VAL(MID$(warline$, 26, 5)) IF adata < -(warlen) THEN adata = adata + coresize IF bdata < -(warlen) THEN bdata = bdata + coresize adata$ = RIGHT$(" " + RTRIM$(STR$(adata)), 5) bdata$ = RIGHT$(" " + RTRIM$(STR$(bdata)), 5) PRINT #2, instrmod$; " "; amode$; adata$; " , "; bmode$; bdata$ lineaddress = lineaddress + 1 END IF WEND PRINT #2, "end"; endnumber PRINT #2, ";species "; tag$ CLOSE #2 CLOSE #1 IF outputmode = 2 THEN PRINT "Cloning..." FOR x = 1 TO xsize FOR y = 1 TO ysize yname$ = RIGHT$("0" + LTRIM$(RTRIM$(STR$(y))), 2) xname$ = RIGHT$("0" + LTRIM$(RTRIM$(STR$(x))), 2) dest$ = soup$ + "\" + yname$ + "_" + xname$ + ".red" SHELL "copy " + outputfile$ + " " + dest$ + " > nul" NEXT y NEXT x ELSE GOTO promptforfile END IF done: SYSTEM