Пример #1
0
 // prevent copying
 private p00(ref p00 p)
 {
 }
Пример #2
0
 private p00 opeEquel(ref p00 p)
 {
     return(null);
 }
Пример #3
0
        public static SidTuneBase load(string fileName, byte[] dataBuf)
        {
            string ext = SidTuneTools.fileExtOfPath(fileName);

            // Combined extension & magic field identification
            if (ext.Length != 4)
            {
                return(null);
            }

            //if (!isdigit(ext[2]) || !isdigit(ext[3]))
            //return null;
            if ("0123456789".IndexOf(ext[2]) < 0 || "0123456789".IndexOf(ext[3]) < 0)
            {
                return(null);
            }

            string    format = null;
            X00Format type;

            switch (ext[1].ToString().ToUpper()[0])
            {
            case 'D':
                type   = X00Format.X00_DEL;
                format = TXT_FORMAT_DEL;
                break;

            case 'S':
                type   = X00Format.X00_SEQ;
                format = TXT_FORMAT_SEQ;
                break;

            case 'P':
                type   = X00Format.X00_PRG;
                format = TXT_FORMAT_PRG;
                break;

            case 'U':
                type   = X00Format.X00_USR;
                format = TXT_FORMAT_USR;
                break;

            case 'R':
                type   = X00Format.X00_REL;
                format = TXT_FORMAT_REL;
                break;

            default:
                return(null);
            }

            // Verify the file is what we think it is
            Int32 bufLen = dataBuf.Length;

            if (bufLen < X00_ID_LEN)
            {
                return(null);
            }

            X00Header pHeader = new X00Header();

            mem.memcpy(ref pHeader.id, dataBuf, X00_ID_LEN);
            Ptr <byte> p = new Ptr <byte>(pHeader.name, 0);

            mem.memcpy(ref p, new Ptr <byte>(dataBuf, X00_ID_LEN), X00_NAME_LEN);
            pHeader.length = dataBuf[X00_ID_LEN + X00_NAME_LEN];

            if (Encoding.ASCII.GetString(pHeader.id) == P00_ID)
            {
                return(null);
            }

            // File types current supported
            if (type != X00Format.X00_PRG)
            {
                throw new loadError("Not a PRG inside X00");
            }

            if (bufLen < 26 + 2)//sizeof(X00Header) + 2)
            {
                throw new loadError(ERR_TRUNCATED);
            }

            p00 tune = new p00();

            tune.load(Encoding.ASCII.GetBytes(format), pHeader);

            return(tune);
        }