示例#1
0
        private SidTuneBase getFromBuffer(byte[] buffer, UInt32 bufferLen)
        {
            if (buffer == null || bufferLen == 0)
            {
                throw new loadError(ERR_EMPTY);
            }

            if (bufferLen > MAX_FILELEN)
            {
                throw new loadError(ERR_FILE_TOO_LONG);
            }

            byte[] buf1 = buffer;//, buffer +bufferLen);

            // Here test for the possible single file formats.
            SidTuneBase s = PSID.load(ref buf1);

            if (s == null)
            {
                s = (new MUS()).load(buf1.ToArray(), true);
            }
            if (s == null)
            {
                throw new loadError(ERR_UNRECOGNIZED_FORMAT);
            }

            List <byte> lstBuf1 = new List <byte>(buf1);

            s.acceptSidTune("-", "-", ref lstBuf1, false);
            return(s);
        }
示例#2
0
        // Initializing the object based upon what we find in the specified file.

        private SidTuneBase getFromFiles(string fileName, string[] fileNameExtensions, bool separatorIsSlash)
        {
            List <byte> fileBuf1 = new List <byte>();

            loadFile(fileName, ref fileBuf1);

            // File loaded. Now check if it is in a valid single-file-format.
            byte[]      aryFileBuf1 = fileBuf1.ToArray();
            SidTuneBase s           = PSID.load(ref aryFileBuf1);

            fileBuf1 = new List <byte>(aryFileBuf1);
            if (s == null)
            {
                // Try some native C64 file formats
                s = (new MUS()).load(fileBuf1.ToArray(), true);
                if (s != null)
                {
                    // Try to find second file.
                    string fileName2;
                    int    n = 0;
                    while (fileNameExtensions[n] != null)
                    {
                        createNewFileName(out fileName2, Encoding.ASCII.GetBytes(fileName), Encoding.ASCII.GetBytes(fileNameExtensions[n]));
                        // 1st data file was loaded into "fileBuf1",
                        // so we load the 2nd one into "fileBuf2".
                        // Do not load the first file again if names are equal.
                        if (fileName.Substring(0, fileName2.Length) != fileName2.Substring(0, fileName2.Length))
                        {
                            try
                            {
                                List <byte> fileBuf2 = new List <byte>();

                                loadFile(fileName2, ref fileBuf2);
                                // Check if tunes in wrong order and therefore swap them here
                                if (fileNameExtensions[n] == ".mus")
                                {
                                    SidTuneBase s2 = (new MUS()).load(fileBuf2.ToArray(), fileBuf1.ToArray(), 0, true);
                                    if (s2 != null)
                                    {
                                        s2.acceptSidTune(fileName2, fileName, ref fileBuf2, separatorIsSlash);
                                        return(s2);
                                    }
                                }
                                else
                                {
                                    SidTuneBase s2 = (new MUS()).load(fileBuf1.ToArray(), true);
                                    if (s2 != null)
                                    {
                                        s2.acceptSidTune(fileName, fileName2, ref fileBuf1, separatorIsSlash);
                                        return(s2);
                                    }
                                }
                                // The first tune loaded ok, so ignore errors on the
                                // second tune, may find an ok one later
                            }
                            catch (loadError)
                            {
                            }
                        }
                        n++;
                    }
                }
            }
            if (s == null)
            {
                s = p00.load(fileName, aryFileBuf1);
            }
            if (s == null)
            {
                s = prg.load(fileName, aryFileBuf1);
            }
            if (s == null)
            {
                throw new loadError(ERR_UNRECOGNIZED_FORMAT);
            }

            s.acceptSidTune(fileName, null, ref fileBuf1, separatorIsSlash);
            return(s);
        }
示例#3
0
 private SidTuneBase opeEquel(ref SidTuneBase a)
 {
     return(null);
 }
示例#4
0
        //protected SidTuneBase() { }

        /**
         * Does not affect status of object, and therefore can be used
         * to load files. Error string is put into info.statusString, though.
         *
         * @param fileName
         * @param bufferRef
         * @throw loadError
         */
        //protected void loadFile(string fileName, ref List<byte> bufferRef) { }

        /**
         * Convert 32-bit PSID-style speed word to internal tables.
         *
         * @param speed
         * @param clock
         */
        //protected void convertOldStyleSpeedToTables(UInt32 speed, Int64 clock = CLOCK_PAL) { }

        /**
         * Check if compatibility constraints are fulfilled.
         */
        //protected bool checkCompatibility() { return false; }

        /**
         * Check for valid relocation information.
         */
        //protected bool checkRelocInfo() { return false; }

        /**
         * Common address resolution procedure.
         *
         * @param c64data
         */
        //protected void resolveAddrs(byte[] c64data) { }

        /**
         * Cache the data of a single-file or two-file sidtune and its
         * corresponding file names.
         *
         * @param dataFileName
         * @param infoFileName
         * @param buf
         * @param isSlashedFileName If your opendir() and readdir()->d_name return path names
         * that contain the forward slash (/) as file separator, but
         * your operating system uses a different character, there are
         * extra functions that can deal with this special case. Set
         * separatorIsSlash to true if you like path names to be split
         * correctly.
         * You do not need these extra functions if your systems file
         * separator is the forward slash.
         * @throw loadError
         */
        //protected virtual void acceptSidTune(string dataFileName, string infoFileName, ref List<byte> buf, bool isSlashedFileName) { }

        /**
         * Petscii to Ascii converter.
         */
        //protected string petsciiToAscii(ref SmartPtr_sidtt<byte> spPet) { return null; }

        // ---------------------------------------------------------------

        //#if !defined(SIDTUNE_NO_STDIN_LOADER)
        //private SidTuneBase getFromStdIn() { return null; }
        //#endif
        //private SidTuneBase getFromFiles(string name, string[] fileNameExtensions, bool separatorIsSlash) { return null; }

        /**
         * Try to retrieve single-file sidtune from specified buffer.
         */
        //private SidTuneBase getFromBuffer(byte[] buffer, UInt32 bufferLen) { return null; }

        /**
         * Get new file name with specified extension.
         *
         * @param destString destinaton string
         * @param sourceName original file name
         * @param sourceExt new extension
         */
        //private void createNewFileName(ref string destString, byte[] sourceName, byte[] sourceExt) { }

        // prevent copying
        public SidTuneBase(SidTuneBase a)
        {
        }