def rominfo(arg, dirauto=1): if arg == None: sys.exit("ERROR: no file specified.") filearg = arg.split("^")[0] fname = iofuncts.findtrom(filearg, dirauto=dirauto, exitonfail=0) if fname != None and "^" not in arg: if fname.lower().endswith(".trom"): fobj = open(fname, "r") print("----FileType: TROM: SBTCVM Ternary ROM.") print("path: " + filearg) g2com.standardsizeprint(g2com.gettromsize(fobj)) print("--------") fname2 = iofuncts.findtrom(filearg, dirauto=dirauto, exitonfail=0, ext=".tdsk1") if fname2 != None: if "^" in arg: diskfilename = arg.split("^")[1] dsk = td1.loaddisk(filearg, readonly=1) if diskfilename in dsk.files: filedat = diskfilename if diskfilename.lower().endswith(".txe"): print( "----VDI FileType: TXE: Ternary Executable. [RAW G2-9 format]" ) else: print("----VDI FileType: (?): Unknown extention.") print("File Size: " + g2com.nonetformatted_smart(len(dsk.files[diskfilename]))) print("--------") else: if fname2.lower().endswith(".tdsk1"): dsk = td1.loaddisk(filearg, readonly=1) print("----FileType: TDSK1: Format 1 SBTVDI disk image.") print("path: " + filearg) disksize = 0 print("Label: " + dsk.label) print("files:") for filex in dsk.files: print(" " + filex.ljust(20) + " " + g2com.nonetformatted_smart(len(dsk.files[filex]))) disksize += len(dsk.files[filex]) print("Disk size (virtual): " + g2com.nonetformatted_smart(disksize)) print("--------") else: if fname == None: sys.exit("ERROR: Cant find TDSK1/TROM image.")
def InputFileLoader(arg, dirauto=1): if arg == None: sys.exit("ERROR: no file specified.") filearg = arg.split("^")[0] fname = iofuncts.findtrom(filearg, dirauto=dirauto, exitonfail=0) if fname != None and "^" not in arg: if fname.lower().endswith(".trom"): fobj = open(fname, "r") return TromLoad(fobj) elif fname.lower().endswith(".tdsk1"): sys.exit("please specify file via [diskimage^filename].") else: fname = iofuncts.findtrom(filearg, dirauto=dirauto, exitonfail=0, ext=".tdsk1") if fname != None: if fname.lower().endswith(".tdsk1"): return DiskLoader(arg, filearg) sys.exit("Unable to locate TDSK1/TROM.")
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SBTCVM Gen2-9 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SBTCVM Gen2-9. If not, see <http://www.gnu.org/licenses/> ''') elif cmd == None: print("Tip: Try stnpcom.py -h for help.") elif cmd.startswith("-") and cmd not in ['-m', '--module', '-c', '--compile']: print("Unknown option: '" + cmd + "' try stnpcom.py -h for help.") else: if cmd in ['-m', '--module']: argx=arg pathx=iofuncts.findtrom(argx, ext=".stnp", exitonfail=1, exitmsg="stnp file was not found. STOP", dirauto=1) stnplib.modcomp(pathx) else: if cmd in ['-c', '--compile']: argx=arg else: argx=cmd pathx=iofuncts.findtrom(argx, ext=".stnp", exitonfail=1, exitmsg="stnp file was not found. STOP", dirauto=1) stnplib.compwrap(pathx)
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SBTCVM Gen2-9. If not, see <http://www.gnu.org/licenses/> ''') elif cmd in ["-i"]: xaslib.xasshell() elif cmd == None: xaslib.xasshell() elif cmd.startswith("-"): print("Unknown option: '" + cmd + "' try xas.py -h for help.") else: if cmd in ['-b', '--build', '-s', '--syntax']: argx = arg else: argx = cmd if cmd in ['-s', '--syntax']: syntaxonly = 1 else: syntaxonly = 0 pathx = iofuncts.findtrom(argx, ext=".xas", exitonfail=1, exitmsg="xas file was not found. STOP", dirauto=1) if xaslib.xasparse(pathx, syntaxonly): sys.exit("The script was not run successfully.")
SBTCVM Gen2-9 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SBTCVM Gen2-9. If not, see <http://www.gnu.org/licenses/> ''') elif cmd == None: print("Tip: Try g2-asm.py -h for help.") elif cmd.startswith("-") and cmd not in [ '-b', '--build', '-s', '--syntax' ]: print("Unknown option: '" + cmd + "' try g2-asm.py -h for help.") else: if cmd in ['-b', '--build', '-s', '--syntax']: argx = arg else: argx = cmd if cmd in ['-s', '--syntax']: syntaxonly = 1 else: syntaxonly = 0 pathx = iofuncts.findtrom(argx, ext=".tasm", exitonfail=1, exitmsg="source file was not found. STOP", dirauto=1) g2asmlib.assemble(pathx, syntaxonly)
sys.exit() else: romfile = cmd if slow == 1: targtime = slowspeed else: #targspeed is in khz. acuracy may vary. targspeed = 6.5 #approx. speed should be close. #calculate approx speed. targtime = 1 / (targspeed * 1000.0) print("SBTCVM Generation 2 9-trit VM, v2.1.0.alpha\n") windowprefix = romfile diska = None diskfile = iofuncts.findtrom(romfile, ext=".tdsk1", exitonfail=0, dirauto=1) if diskfile != None: retval = td1.loaddisk(diskfile, readonly=0) windowprefix = retval.label if not isinstance(retval, str): diska = retval romfile = 'VDIBOOT' #initialize memory subsystem memsys = vmsystem.MEM_G2x_9.memory(romfile) #initialize IO subsystem iosys = vmsystem.IO_G2x_9.io() cpusys = vmsystem.CPU_G2x_9.cpu(memsys, iosys) devcommon.factorydevs(iosys)
def from_diskmap(diskmap, disk_append=False): diskmapfile = open(diskmap, "r") diskpath = (diskmap.rsplit('.', 1)[0]) + ".tdsk1" print("Checking to see if all files exist...") lineno = 0 for ent in diskmapfile: ent = ent.replace("\n", "") ent = ent.rsplit("#", 1)[0] lineno += 1 if lineno == 1: label = ent elif ent != "": try: enttype, entsource, entdest = ent.split(";") except ValueError: sys.exit("Malformed entry in diskmap: \n '" + ent + "'") if enttype not in validenttypes: sys.exit("Invalid entry type feild value: \n '" + enttype + "'") sourcereturn = iofuncts.findtrom( entsource, exitonfail=1, exitmsg="ERROR: Entry Source file: '" + entsource + "' Not found.", dirauto=1) if sourcereturn == None: sys.exit( "Source Entry does not exist, is misspelled, or has the wrong path: \n '" + entsource + "'") diskmapfile.seek(0) if disk_append == False: diskdict = {} print("Done. Constructing Disk file dictionary...") else: diskclass = td1.loaddisk(opt) if isinstance(diskclass, str): sys.exit("TDSK1 image: '" + opt + "' not found.") diskdict = diskclass.files print("Done. Appending to Disk file dictionary...") lineno = 0 for ent in diskmapfile: ent = ent.replace("\n", "") ent = ent.rsplit("#", 1)[0] lineno += 1 if lineno == 1: label = ent elif ent != "": enttype, entsource, entdest = ent.split(";") ###trom enttype's get their data stored away verbatim. if enttype == "trom": filelist = [] sourcefile = iofuncts.loadtrom( entsource, exitonfail=1, exitmsg="ERROR: Entry Source file: '" + entsource + "' Not found.", dirauto=1) #for line in sourcefile: # i,o=line.replace("\n", "").split(",") # filelist.append([btint(int(i)), btint(int(o))]) filelist = trom_to_diskfilelist(sourcefile, entsource) diskdict[entdest] = filelist sourcefile.close() print("Saving disk...") if disk_append == False: diskclass = td1.disk(label, diskdict, diskpath) diskmapfile.close() td1.savedisk(diskclass) print(diskpath)
opt3 = sys.argv[5] except IndexError: opt3 = None if cmd in ["-h", "--help"]: print('''SBTVDI Disk Image Edit Utility v1.0''') print('''Help: --new [*.diskmap] - Build a new disk from a diskmap file. --append [*.diskmap] [*.tdsk1] - append/update files in an EXISTING disk from a diskmap file. --appendfile [*.tdsk1] [sourcefile] [targetname] [type] - append/update a single file in an EXISTING disk.''' ) elif cmd == "--new": if arg == None: sys.exit("Please specify a diskmap to construct disk image with.") diskmappath = iofuncts.findtrom(arg, ext=".diskmap", exitonfail=1, exitmsg="diskmap file was not found.", dirauto=1) print("Found diskmap: '" + diskmappath + "'") from_diskmap(diskmappath) elif cmd == "--append": if arg == None or opt == None: sys.exit( "Please specify '--append [*.diskmap] [existing *.tdsk1]'") diskmappath = iofuncts.findtrom(arg, ext=".diskmap", exitonfail=1, exitmsg="diskmap file was not found.", dirauto=1) print("Found diskmap: '" + diskmappath + "'") from_diskmap(diskmappath, disk_append=opt)
SBTCVM Gen2-9 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SBTCVM Gen2-9. If not, see <http://www.gnu.org/licenses/> ''') elif cmd in ["-p"]: print("Ternary-Packed art encoder.") packart_maker( iofuncts.findtrom(arg, ext=".png", exitonfail=1, exitmsg="image file was not found. STOP", dirauto=1)) elif cmd in ["-cp"]: print("Color Ternary-Packed art encoder.") colart_maker( iofuncts.findtrom(arg, ext=".png", exitonfail=1, exitmsg="image file was not found. STOP", dirauto=1)) elif cmd in ["-pn"]: print("Ternary-Packed art encoder.") packart_maker( iofuncts.findtrom(arg,