예제 #1
0
        private bool LoadArchiveFromDat(DatFileLoader dfl)
        {
            dfl.Gn();

            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after Archive, on line " + dfl.LineNumber);
                return(false);
            }

            dfl.Gn();
            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "name":
                    dfl.Gn();
                    break;

                default:
                    _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not know in Archive, on line " + dfl.LineNumber);
                    break;
                }
                dfl.Gn();
            }
            return(true);
        }
예제 #2
0
        public static bool ReadDat(string strFilename, ReportError errorReport, out DatHeader datHeader)
        {
            using (DatFileLoader dfl = new DatFileLoader())
            {
                datHeader = new DatHeader {
                    BaseDir = new DatDir(DatFileType.UnSet)
                };
                int errorCode = dfl.LoadDat(strFilename, DatRead.Enc);
                if (errorCode != 0)
                {
                    errorReport?.Invoke(strFilename, new Win32Exception(errorCode).Message);
                    return(false);
                }

                dfl.Gn();
                if (dfl.EndOfStream())
                {
                    return(false);
                }
                if (dfl.Next.ToLower() == "clrmamepro" || dfl.Next.ToLower() == "clrmame")
                {
                    if (!LoadHeaderFromDat(dfl, strFilename, datHeader, errorReport))
                    {
                        return(false);
                    }
                    dfl.Gn();
                }
                if (dfl.Next.ToLower() == "raine")
                {
                    while (dfl.Next.ToLower() != "emulator")
                    {
                        dfl.Gn();
                    }
                    if (!LoadHeaderFromDat(dfl, strFilename, datHeader, errorReport))
                    {
                        return(false);
                    }
                    dfl.Gn();
                }
                if (dfl.Next.ToLower() == "romvault")
                {
                    if (!LoadHeaderFromDat(dfl, strFilename, datHeader, errorReport))
                    {
                        return(false);
                    }
                    dfl.Gn();
                }

                while (!dfl.EndOfStream())
                {
                    bool res = ReadNextBlock(dfl, datHeader.BaseDir, errorReport);
                    if (!res)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #3
0
        private bool LoadDirFromDat(DatFileLoader dfl, DatDir parentDir)
        {
            dfl.Gn();
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after game, on line " + dfl.LineNumber);
                return(false);
            }

            dfl.Gn();
            if (dfl.Next.ToLower() != "name")
            {
                _errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }
            DatDir dir = new DatDir(DatFileType.UnSet)
            {
                Name = dfl.GnRest()
            };

            dfl.Gn();
            parentDir.ChildAdd(dir);

            while (dfl.Next != ")")
            {
                bool res = ReadNextBlock(dfl, dir);
                if (!res)
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #4
0
        private bool LoadEmulator(DatFileLoader dfl)
        {
            dfl.Gn();
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after emulator, on line " + dfl.LineNumber);
                return(false);
            }

            dfl.Gn();
            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "name":
                    dfl.GnRest();
                    break;

                case "version":
                    dfl.GnRest();
                    break;

                case "debug":
                    dfl.GnRest();
                    break;

                default:
                    _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in emulator, on line " + dfl.LineNumber);
                    break;
                }
                dfl.Gn();
            }
            return(true);
        }
예제 #5
0
        private bool LoadFileFromDat(DatFileLoader dfl, DatDir parentDir)
        {
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after file, on line " + dfl.LineNumber);
                return(false);
            }
            dfl.Gn();

            if (dfl.Next.ToLower() != "name")
            {
                _errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }

            DatFile dRom = new DatFile(DatFileType.UnSet)
            {
                Name = dfl.GnNameToSize()
            };

            dfl.Gn();


            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "size":
                    dRom.Size = VarFix.ULong(dfl.Gn());
                    dfl.Gn();
                    break;

                case "crc":
                    dRom.CRC = VarFix.CleanMD5SHA1(dfl.Gn(), 8);
                    dfl.Gn();
                    break;

                case "date":
                    dRom.Date = dfl.Gn() + " " + dfl.Gn();
                    dfl.Gn();
                    break;

                default:
                    _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in rom, on line " + dfl.LineNumber);
                    dfl.Gn();
                    break;
                }
            }

            parentDir.ChildAdd(dRom);

            return(true);
        }
예제 #6
0
        public bool ReadDat(string strFilename, out DatHeader datHeader)
        {
            _filename = strFilename;

            using (DatFileLoader dfl = new DatFileLoader())
            {
                datHeader = new DatHeader {
                    BaseDir = new DatDir(DatFileType.UnSet)
                };
                int errorCode = dfl.LoadDat(strFilename);
                if (errorCode != 0)
                {
                    _errorReport?.Invoke(strFilename, new Win32Exception(errorCode).Message);
                    return(false);
                }

                dfl.Gn();
                if (dfl.EndOfStream())
                {
                    return(false);
                }
                if (dfl.Next.ToLower() == "clrmamepro" || dfl.Next.ToLower() == "clrmame")
                {
                    dfl.Gn();
                    if (!LoadHeaderFromDat(dfl, datHeader))
                    {
                        return(false);
                    }
                    dfl.Gn();
                }
                if (dfl.Next.ToLower() == "romvault")
                {
                    dfl.Gn();
                    if (!LoadHeaderFromDat(dfl, datHeader))
                    {
                        return(false);
                    }
                    dfl.Gn();
                }

                while (!dfl.EndOfStream())
                {
                    bool res = ReadNextBlock(dfl, datHeader.BaseDir);
                    if (!res)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #7
0
        private static bool LoadCredits(DatFileLoader dfl, DatHeader datHeader, ReportError errorReport)
        {
            if (dfl.Next.ToLower() != "[credits]")
            {
                errorReport?.Invoke(dfl.Filename, "Looking for [CREDITS] but found " + dfl.Next + " , " + dfl.LineNumber);
                return(false);
            }

            while (!dfl.EndOfStream())
            {
                string line = dfl.Gn();
                if (line.Substring(0, 1) == "[")
                {
                    return(true);
                }

                string element;
                string value;
                if (!splitLine(line, out element, out value))
                {
                    return(false);
                }

                switch (element.ToLower())
                {
                case "author":
                    datHeader.Author = value;
                    break;

                case "email":
                    datHeader.Email = value;
                    break;

                case "homepage":
                    datHeader.URL = value;
                    break;

                case "url":
                    datHeader.URL = value;
                    break;

                case "version":
                    datHeader.Version = value;
                    break;

                case "date":
                    datHeader.Date = value;
                    break;

                case "comment":
                    datHeader.Comment = value;
                    break;

                default:
                    errorReport?.Invoke(dfl.Filename, "Unknown Line " + dfl.Next + " found in [CREDITS], " + dfl.LineNumber);
                    return(false);
                }
            }
            return(true);
        }
예제 #8
0
        private bool LoadGameFromDat(DatFileLoader dfl, DatDir parentDir)
        {
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after game, on line " + dfl.LineNumber);
                return(false);
            }
            dfl.Gn();

            string snext = dfl.Next.ToLower();

            if (snext != "name")
            {
                _errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }


            string name = dfl.GnRest();

            dfl.Gn();

            DatDir dDir = new DatDir(DatFileType.UnSet)
            {
                Name = name, DGame = new DatGame()
            };
            DatGame dGame = dDir.DGame;

            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "file":
                    dfl.Gn();
                    if (!LoadFileFromDat(dfl, dDir))
                    {
                        return(false);
                    }
                    dfl.Gn();
                    break;

                case "rom":
                    dfl.Gn();
                    if (!LoadFileFromDat(dfl, dDir))
                    {
                        return(false);
                    }
                    dfl.Gn();
                    break;

                default:
                    _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in game, on line " + dfl.LineNumber);
                    dfl.Gn();
                    break;
                }
            }
            parentDir.ChildAdd(dDir);
            return(true);
        }
예제 #9
0
        private bool ReadNextBlock(DatFileLoader dfl, DatDir parentDir)
        {
            switch (dfl.Next.ToLower())
            {
            case "dir":
                dfl.Gn();
                if (!LoadDirFromDat(dfl, parentDir))
                {
                    return(false);
                }
                dfl.Gn();
                break;

            case "game":
            case "machine":
                dfl.Gn();
                if (!LoadGameFromDat(dfl, parentDir))
                {
                    return(false);
                }
                dfl.Gn();
                break;

            case "resource":
                dfl.Gn();
                if (!LoadGameFromDat(dfl, parentDir))
                {
                    return(false);
                }
                dfl.Gn();
                break;

            case "emulator":
                dfl.Gn();
                if (!LoadEmulator(dfl))
                {
                    return(false);
                }
                dfl.Gn();
                break;

            default:
                _errorReport?.Invoke(dfl.Filename, "Error Keyword " + dfl.Next + " not know in dir, on line " + dfl.LineNumber);
                dfl.Gn();
                break;
            }
            return(true);
        }
예제 #10
0
        private static bool LoadEmulator(DatFileLoader dfl, DatHeader datHeader, ReportError errorReport)
        {
            if (dfl.Next.ToLower() != "[emulator]")
            {
                errorReport?.Invoke(dfl.Filename, "Looking for [EMULATOR] but found " + dfl.Next + " , " + dfl.LineNumber);
                return(false);
            }

            while (!dfl.EndOfStream())
            {
                string line = dfl.Gn();
                if (line.Substring(0, 1) == "[")
                {
                    return(true);
                }

                string element;
                string value;
                if (!splitLine(line, out element, out value))
                {
                    return(false);
                }

                switch (element.ToLower())
                {
                case "refname":
                    datHeader.Name = value;
                    break;

                case "version":
                    datHeader.Description = value;
                    break;

                case "category":
                    datHeader.Category = value;
                    break;

                case "exe":
                    break;

                case "runcmd":
                    break;

                case "romspaths":
                    break;

                default:
                    errorReport?.Invoke(dfl.Filename, "Unknown Line " + dfl.Next + " found in [EMULATOR], " + dfl.LineNumber);
                    return(false);
                }
            }
            return(true);
        }
예제 #11
0
        private static bool LoadDat(DatFileLoader dfl, DatHeader datHeader, ReportError errorReport)
        {
            if (dfl.Next.ToLower() != "[dat]")
            {
                errorReport?.Invoke(dfl.Filename, "Looking for [DAT] but found " + dfl.Next + " , " + dfl.LineNumber);
                return(false);
            }

            while (!dfl.EndOfStream())
            {
                string line = dfl.Gn();
                if (line.Substring(0, 1) == "[")
                {
                    return(true);
                }

                string element;
                string value;
                if (!splitLine(line, out element, out value))
                {
                    return(false);
                }

                switch (element.ToLower())
                {
                case "version":
                    //datVersion = value;
                    break;

                case "plugin":
                    //plugin = value;
                    break;

                case "split":
                    datHeader.Split = value;
                    break;

                case "merge":
                    datHeader.MergeType = value;
                    break;

                default:
                    errorReport?.Invoke(dfl.Filename, "Unknown Line " + dfl.Next + " found in [DAT], " + dfl.LineNumber);
                    return(false);
                }
            }
            return(true);
        }
예제 #12
0
        public bool ReadDat(string strFilename, out DatHeader datHeader)
        {
            _filename = strFilename;

            using (DatFileLoader dfl = new DatFileLoader())
            {
                datHeader = new DatHeader {
                    BaseDir = new DatDir(DatFileType.UnSet)
                };
                int errorCode = dfl.LoadDat(strFilename, System.Text.Encoding.UTF8);
                if (errorCode != 0)
                {
                    _errorReport?.Invoke(strFilename, new Win32Exception(errorCode).Message);
                    return(false);
                }

                dfl.Gn();
                if (dfl.EndOfStream())
                {
                    return(false);
                }
                if (dfl.Next.ToLower() == "doscenter")
                {
                    dfl.Gn();
                    if (!LoadHeaderFromDat(dfl, datHeader))
                    {
                        return(false);
                    }
                    dfl.Gn();
                }

                while (!dfl.EndOfStream())
                {
                    switch (dfl.Next.ToLower())
                    {
                    case "game":
                        dfl.Gn();
                        if (!LoadGameFromDat(dfl, datHeader.BaseDir))
                        {
                            return(false);
                        }
                        dfl.Gn();
                        break;

                    default:
                        _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known, on line " + dfl.LineNumber);
                        dfl.Gn();
                        break;
                    }
                }
            }

            return(true);
        }
예제 #13
0
        private static bool ReadNextBlock(DatFileLoader dfl, DatDir parentDir, ReportError errorReport)
        {
            switch (dfl.Next.ToLower())
            {
            case "dir":
                if (!LoadDirFromDat(dfl, parentDir, errorReport))
                {
                    return(false);
                }
                break;

            case "game":
            case "machine":
                if (!LoadGameFromDat(dfl, parentDir, errorReport))
                {
                    return(false);
                }
                break;

            case "resource":
                if (!LoadGameFromDat(dfl, parentDir, errorReport))
                {
                    return(false);
                }
                break;

            case "emulator":
                if (!LoadEmulator(dfl, errorReport))
                {
                    return(false);
                }
                break;

            case "#":     // comments

                dfl.GnRest();
                break;

            default:
                errorReport?.Invoke(dfl.Filename, "Error Keyword " + dfl.Next + " not know in dir, on line " + dfl.LineNumber);
                break;
            }
            dfl.Gn();
            return(true);
        }
예제 #14
0
        private bool LoadDiskFromDat(DatFileLoader dfl, DatDir parentDir)
        {
            dfl.Gn();
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after rom, on line " + dfl.LineNumber);
                return(false);
            }

            dfl.Gn();
            if (dfl.Next.ToLower() != "name")
            {
                _errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }


            DatFile dRom = new DatFile(DatFileType.UnSet)
            {
                Name   = VarFix.String(dfl.Gn()) + ".chd",
                isDisk = true
            };

            dfl.Gn();
            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "sha1":
                    dRom.SHA1 = VarFix.CleanMD5SHA1(dfl.Gn(), 40);
                    break;

                case "md5":
                    dRom.MD5 = VarFix.CleanMD5SHA1(dfl.Gn(), 32);
                    break;

                case "region":
                    dRom.Region = VarFix.String(dfl.Gn());
                    break;

                case "merge":
                    dRom.Merge = VarFix.String(dfl.Gn());
                    break;

                case "index":
                    dfl.Gn();
                    break;

                case "flags":
                    dRom.Status = VarFix.ToLower(dfl.Gn());
                    break;

                case "nodump":
                    dRom.Status = "nodump";
                    break;

                default:
                    _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in rom, on line " + dfl.LineNumber);
                    break;
                }
                dfl.Gn();
            }
            parentDir.ChildAdd(dRom);

            return(true);
        }
예제 #15
0
        private static bool LoadDisks(DatFileLoader dfl, DatDir parentDir, ReportError errorReport)
        {
            if (dfl.Next.ToLower() != "[disks]")
            {
                errorReport?.Invoke(dfl.Filename, "Looking for [DISKS] but found " + dfl.Next + " , " + dfl.LineNumber);
                return(false);
            }

            while (!dfl.EndOfStream())
            {
                string line = dfl.Gn();

                if (line.Substring(0, 1) == "[")
                {
                    return(true);
                }

                string[] parts = line.Split('¬');

                // 1 parent name         = clone of
                // 2 parent description  = description (from parent)
                // 3 game name           = name (game)
                // 4 game description    = description
                // 5 rom name            = name (rom)
                // 6 rom crc             = crc
                // 7 rom size            = size
                // 8 romof name          = romof
                // 9 merge name          = merge

                string ParentName        = parts[1];
                string ParentDescription = parts[2];
                string GameName          = parts[3];
                string GameDescription   = parts[4];
                string romName           = parts[5];
                string romCRC            = parts[6];
                string romSize           = parts[7];
                string romOf             = parts[8];
                string merge             = parts[9];

                int    index;
                DatDir dDir;
                DatDir searchDir = new DatDir(DatFileType.Dir)
                {
                    Name = GameName
                };
                if (parentDir.ChildNameSearch(searchDir, out index) != 0)
                {
                    dDir = new DatDir(DatFileType.UnSet)
                    {
                        Name = GameName, DGame = new DatGame()
                    };
                    DatGame dGame = dDir.DGame;
                    dGame.Description = GameDescription;
                    if (ParentName != GameName)
                    {
                        dGame.CloneOf = ParentName;
                    }
                    parentDir.ChildAdd(dDir);
                }
                else
                {
                    dDir = (DatDir)parentDir.Child(index);
                    // need to check everything matches
                }

                DatFile dRom = new DatFile(DatFileType.UnSet)
                {
                    isDisk = true,
                    Name   = VarFix.CleanCHD(romName),
                    SHA1   = VarFix.CleanMD5SHA1(romCRC, 40),
                    Merge  = merge
                };
                // dRom.Size = VarFix.ULong(romSize);
                // check romof=ParentName

                dDir.ChildAdd(dRom);
            }
            return(true);
        }
예제 #16
0
        private bool LoadGameFromDat(DatFileLoader dfl, DatDir parentDir)
        {
            dfl.Gn();
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after game, on line " + dfl.LineNumber);
                return(false);
            }

            dfl.Gn();
            string snext = dfl.Next.ToLower();

            string pathextra = "";

            if (snext == "rebuildto")
            {
                pathextra = dfl.Gn();
                dfl.Gn();
                snext = dfl.Next.ToLower();
            }

            if (snext != "name")
            {
                _errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }

            string name = dfl.GnRest();

            name = Path.Combine(pathextra, name);

            dfl.Gn();
            DatDir dDir = new DatDir(DatFileType.UnSet)
            {
                Name = name, DGame = new DatGame()
            };
            DatGame dGame = dDir.DGame;

            while (dfl.Next != ")" && !dfl.EndOfStream())
            {
                switch (dfl.Next.ToLower())
                {
                case "romof":
                    dGame.RomOf = dfl.GnRest();
                    break;

                case "description":
                    dGame.Description = dfl.GnRest();
                    break;

                case "sourcefile":
                    dGame.SourceFile = dfl.GnRest();
                    break;

                case "cloneof":
                    dGame.CloneOf = dfl.GnRest();
                    break;

                case "sampleof":
                    dGame.SampleOf = dfl.GnRest();
                    break;

                case "board":
                    dGame.Board = dfl.GnRest();
                    break;

                case "year":
                    dGame.Year = dfl.GnRest();
                    break;

                case "manufacturer":
                    dGame.Manufacturer = dfl.GnRest();
                    break;

                case "history":
                    dGame.History = dfl.GnRest();
                    break;

                case "serial":
                    dfl.GnRest();
                    break;

                case "rebuildto":
                    dfl.GnRest();
                    break;

                case "sample":
                    dfl.GnRest();
                    break;

                case "biosset":
                    dfl.GnRest();
                    break;

                case "chip":
                    dfl.GnRest();
                    break;

                case "video":
                    dfl.GnRest();
                    break;

                case "sound":
                    dfl.GnRest();
                    break;

                case "input":
                    dfl.GnRest();
                    break;

                case "dipswitch":
                    dfl.GnRest();
                    break;

                case "driver":
                    dfl.GnRest();
                    break;

                case "display":
                    dfl.GnRest();
                    break;

                case "comment":
                case "releaseyear":
                case "releasemonth":
                case "releaseday":
                case "genre":
                case "developer":
                case "publisher":
                case "homepage":
                case "users":
                case "version":
                case "license":
                    dfl.GnRest();
                    break;

                case "name":
                    string tmpName = dfl.GnRest();
                    _errorReport?.Invoke(dfl.Filename, "Error: multiple names found in one game '" + tmpName + "' will be ignored, on line " + dfl.LineNumber);
                    break;

                case "rom":
                    if (!LoadRomFromDat(dfl, dDir))
                    {
                        return(false);
                    }
                    break;

                case "disk":
                    if (!LoadDiskFromDat(dfl, dDir))
                    {
                        return(false);
                    }
                    break;

                case "archive":
                    if (!LoadArchiveFromDat(dfl))
                    {
                        return(false);
                    }
                    break;

                default:
                    _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in game, on line " + dfl.LineNumber);
                    break;
                }
                dfl.Gn();
            }
            parentDir.ChildAdd(dDir);
            return(true);
        }
예제 #17
0
        public static bool ReadDat(string strFilename, ReportError errorReport, out DatHeader datHeader)
        {
            datHeader = new DatHeader
            {
                BaseDir  = new DatDir(DatFileType.UnSet),
                Filename = strFilename
            };

            using (DatFileLoader dfl = new DatFileLoader())
            {
                dfl.LoadDat(strFilename);
                dfl.Gn();

                while (!dfl.EndOfStream())
                {
                    switch (dfl.Next.ToLower())
                    {
                    case "[credits]":
                        //getcredits
                        if (!LoadCredits(dfl, datHeader, errorReport))
                        {
                            return(false);
                        }
                        break;

                    case "[dat]":
                        //getdat
                        if (!LoadDat(dfl, datHeader, errorReport))
                        {
                            return(false);
                        }
                        break;

                    case "[emulator]":
                        //emulator
                        if (!LoadEmulator(dfl, datHeader, errorReport))
                        {
                            return(false);
                        }
                        break;

                    case "[games]":
                        //games
                        if (!LoadGame(dfl, datHeader.BaseDir, errorReport))
                        {
                            return(false);
                        }
                        break;

                    case "[resources]":
                        //resources
                        if (!LoadGame(dfl, datHeader.BaseDir, errorReport))
                        {
                            return(false);
                        }
                        break;

                    case "[disks]":
                        //games
                        if (!LoadDisks(dfl, datHeader.BaseDir, errorReport))
                        {
                            return(false);
                        }
                        break;

                    default:
                        errorReport?.Invoke(dfl.Filename, "Unknown Line " + dfl.Next + " , " + dfl.LineNumber);
                        return(false);
                    }
                }
            }

            return(true);
        }
예제 #18
0
        private bool LoadHeaderFromDat(DatFileLoader dfl, DatHeader datHeader)
        {
            dfl.Gn();
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after clrmamepro, on line " + dfl.LineNumber);
                return(false);
            }
            dfl.Gn();

            datHeader.Filename = _filename;

            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "name":
                    datHeader.Name = dfl.GnRest();
                    break;

                case "description":
                    datHeader.Description = dfl.GnRest();
                    break;

                case "category":
                    datHeader.Category = dfl.GnRest();
                    break;

                case "version":
                    datHeader.Version = dfl.GnRest();
                    break;

                case "date":
                    datHeader.Date = dfl.GnRest();
                    break;

                case "author":
                    datHeader.Author = dfl.GnRest();
                    break;

                case "email":
                    datHeader.Email = dfl.GnRest();
                    break;

                case "homepage":
                    datHeader.Homepage = dfl.GnRest();
                    break;

                case "url":
                    datHeader.URL = dfl.GnRest();
                    break;

                case "comment":
                    datHeader.Comment = dfl.GnRest();
                    break;

                case "header":
                    datHeader.Header = dfl.GnRest();
                    break;

                case "forcezipping":
                    datHeader.Compression = dfl.GnRest();
                    break;

                case "forcepacking":
                    datHeader.Compression = dfl.GnRest();
                    break;     // incorrect usage

                case "forcemerging":
                    datHeader.MergeType = dfl.GnRest();
                    break;

                case "forcenodump":
                    datHeader.NoDump = dfl.GnRest();
                    break;

                case "dir":
                    datHeader.Dir = dfl.GnRest();
                    break;

                default:
                    _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in clrmamepro, on line " + dfl.LineNumber);
                    break;
                }
                dfl.Gn();
            }

            return(true);
        }
예제 #19
0
        private static bool LoadGameFromDat(DatFileLoader dfl, DatDir parentDir, ReportError errorReport)
        {
            if (dfl.Next != "(")
            {
                errorReport?.Invoke(dfl.Filename, "( not found after game, on line " + dfl.LineNumber);
                return(false);
            }
            dfl.Gn();

            string sNext = dfl.Next.ToLower();

            if (sNext != "name")
            {
                errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }


            string name       = dfl.GnRest();
            int    nameLength = name.Length;

            if (nameLength > 4 && name.ToLower().Substring(nameLength - 4, 4) == ".zip")
            {
                name = name.Substring(0, nameLength - 4);
            }

            dfl.Gn();

            DatDir dDir = new DatDir(DatFileType.UnSet)
            {
                Name = name, DGame = new DatGame()
            };

            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "file":
                    dfl.Gn();
                    if (!LoadFileFromDat(dfl, dDir, errorReport))
                    {
                        return(false);
                    }
                    dfl.Gn();
                    break;

                case "rom":
                    dfl.Gn();
                    if (!LoadFileFromDat(dfl, dDir, errorReport))
                    {
                        return(false);
                    }
                    dfl.Gn();
                    break;

                default:
                    errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in game, on line " + dfl.LineNumber);
                    dfl.Gn();
                    break;
                }
            }
            parentDir.ChildAdd(dDir);
            return(true);
        }
예제 #20
0
        private static bool LoadRomFromDat(DatFileLoader dfl, DatDir parentDir, ReportError errorReport)
        {
            dfl.Gn();
            if (dfl.Next != "(")
            {
                errorReport?.Invoke(dfl.Filename, "( not found after rom, on line " + dfl.LineNumber);
                return(false);
            }

            dfl.Gn();
            if (dfl.Next.ToLower() != "name")
            {
                errorReport?.Invoke(dfl.Filename, "Name not found as first object in ( ), on line " + dfl.LineNumber);
                return(false);
            }


            DatFile dRom = new DatFile(DatFileType.UnSet)
            {
                Name = dfl.Gn()
            };

            dfl.Gn();


            while (dfl.Next != ")")
            {
                switch (dfl.Next.ToLower())
                {
                case "size":
                    dRom.Size = VarFix.ULong(dfl.Gn());
                    break;

                case "hash":
                    dfl.Gn();
                    break;

                case "crc":
                case "crc32":
                    dRom.CRC = VarFix.CleanMD5SHA1(dfl.Gn(), 8);
                    break;

                case "sha1":
                    dRom.SHA1 = VarFix.CleanMD5SHA1(dfl.Gn(), 40);
                    break;

                case "md5":
                    dRom.MD5 = VarFix.CleanMD5SHA1(dfl.Gn(), 32);
                    break;

                case "merge":
                    dRom.Merge = VarFix.String(dfl.Gn());
                    break;

                case "flags":
                    string flags = VarFix.ToLower(dfl.Gn());
                    if (string.IsNullOrWhiteSpace(dRom.Status))
                    {
                        dRom.Status = flags;
                    }
                    break;

                case "date":
                    dfl.Gn();
                    break;

                case "bios":
                    dfl.Gn();
                    break;

                case "region":
                    dfl.Gn();
                    break;

                case "regiona":
                case "regionb":
                    while (dfl.Next != ")")
                    {
                        dfl.Gn();
                    }
                    continue;

                case "offs":
                    dfl.Gn();
                    break;

                case "nodump":
                    dRom.Status = "nodump";
                    break;

                case "baddump":
                    dRom.Status = "baddump";
                    break;


                default:
                    errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in rom, on line " + dfl.LineNumber);
                    break;
                }
                dfl.Gn();
            }

            parentDir.ChildAdd(dRom);

            return(true);
        }
예제 #21
0
        private bool LoadHeaderFromDat(DatFileLoader dfl, DatHeader datHeader)
        {
            if (dfl.Next != "(")
            {
                _errorReport?.Invoke(dfl.Filename, "( not found after DOSCenter, on line " + dfl.LineNumber);
                return(false);
            }
            dfl.Gn();

            datHeader.Filename = _filename;

            while (dfl.Next != ")")
            {
                string nextstr = dfl.Next.ToLower();
                if ((nextstr.Length > 5) && (nextstr.Substring(0, 5) == "name:"))  // this is needed as there is no space after 'name:'
                {
                    datHeader.Name = (dfl.Next.Substring(5) + " " + dfl.GnRest()).Trim();
                    dfl.Gn();
                }
                else
                {
                    switch (nextstr)
                    {
                    case "name":
                    case "name:":
                        datHeader.Name = dfl.GnRest();
                        dfl.Gn();
                        break;

                    case "description":
                    case "description:":
                        datHeader.Description = dfl.GnRest();
                        dfl.Gn();
                        break;

                    case "version":
                    case "version:":
                        datHeader.Version = dfl.GnRest();
                        dfl.Gn();
                        break;

                    case "date":
                    case "date:":
                        datHeader.Date = dfl.GnRest();
                        dfl.Gn();
                        break;

                    case "author":
                    case "author:":
                        datHeader.Author = dfl.GnRest();
                        dfl.Gn();
                        break;

                    case "homepage":
                    case "homepage:":
                        datHeader.Homepage = dfl.GnRest();
                        dfl.Gn();
                        break;

                    case "comment":
                    case "comment:":
                        datHeader.Comment = dfl.GnRest();
                        dfl.Gn();
                        break;

                    default:
                        _errorReport?.Invoke(dfl.Filename, "Error: key word '" + dfl.Next + "' not known in DOSReader, on line " + dfl.LineNumber);
                        dfl.Gn();
                        break;
                    }
                }
            }
            return(true);
        }