コード例 #1
0
        public void import(XmlDocument doc)
        {
            XmlNode blk = null;

            if (doc.DocumentElement.Name == "lure-strings")
            {
                blk = LureCommon.findNode(doc.DocumentElement, "block");
            }
            else if (doc.DocumentElement.Name == "lure-texts")
            {
                blk = LureCommon.findNode(LureCommon.findNode(doc.DocumentElement, "file", "id", resnum.ToString()), "block");
            }
            else
            {
                throw new Exception("bad strings xml");
            }
            ushort count  = BinaryHelper.readU16_LE(data, 0);
            int    curofs = 2;

            for (int i = 0; i < count; i++)
            {
                XmlNode nd  = LureCommon.findNode(blk, "text", "id", i.ToString());
                string  val = "";
                if (nd.ChildNodes.Count > 0)
                {
                    val = LureConfig.get().convert(nd.ChildNodes[0].Value);
                }
                data = LureCommon.checkArrLength(data, curofs + val.Length + 1);
                BinaryHelper.writeZString(data, ref curofs, val);
            }
            LureDisks.setResource(resnum, data);
        }
コード例 #2
0
        public Bitmap export(string pal)
        {
            byte[] tdata = new byte[xlen];
            int    iOfs  = xlen;

            Array.Copy(xdata, 0, tdata, 0, xlen);
            List <byte[]> imgs = new List <byte[]>();

            imgs.Add((byte[])tdata.Clone());
            int cOfs = 0;

            while (cOfs < cdata.Length && iOfs < xdata.Length)
            {
                int sOfs = 0;
                while (sOfs < xlen)
                {
                    UInt16 len = cdata[cOfs++];
                    if (len == 0)
                    {
                        len   = BinaryHelper.readU16_LE(cdata, cOfs);
                        cOfs += 2;
                    }
                    if (len > 0)
                    {
                        Array.Copy(xdata, iOfs, tdata, sOfs, len);
                        iOfs += len;
                        sOfs += len;
                    }
                    len = cdata[cOfs++];
                    if (len == 0)
                    {
                        len   = BinaryHelper.readU16_LE(cdata, cOfs);
                        cOfs += 2;
                    }
                    sOfs += len;
                }
                //next screen
                imgs.Add((byte[])tdata.Clone());
            }
            Bitmap       bmp    = new Bitmap(320, 200 * imgs.Count, System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
            ColorPalette tmppal = bmp.Palette;

            LureConfig.LurePalette p = LureConfig.get().getPalette(pal);
            for (int i = 0; i < 256; i++)
            {
                tmppal.Entries[i] = p.cols[i];
            }
            bmp.Palette = tmppal;
            BitmapData bd = bmp.LockBits(new Rectangle(0, 0, 320, 200 * imgs.Count),
                                         ImageLockMode.WriteOnly, bmp.PixelFormat);

            for (int i = 0; i < bd.Height; i++)
            {
                System.Runtime.InteropServices.Marshal.Copy(imgs[i / 200], (i % 200) * bd.Width, new IntPtr(bd.Scan0.ToInt64() + i * bd.Stride), bd.Width);
            }
            bmp.UnlockBits(bd);
            return(bmp);
        }
コード例 #3
0
 public FileEntry(byte[] data, int ofs)
 {
     id       = BinaryHelper.readU16_LE(data, ofs);
     unused   = data[ofs + 2];
     sizeEx   = data[ofs + 3];
     size     = BinaryHelper.readU16_LE(data, ofs + 4);
     offset   = BinaryHelper.readU16_LE(data, ofs + 6);
     realSize = size + (sizeEx != 0 ? 0x10000 : 0);
     realOfs  = offset * 0x20;
 }
コード例 #4
0
        public string processNames(string s)
        {
            string res = s;
            int    cnt = BinaryHelper.readU16_LE(data, 0) / 2;

            for (int i = 1; i < cnt; i++)
            {
                int    strt = BinaryHelper.readU16_LE(data, i * 2);
                string nm   = BinaryHelper.readZString(data, strt);
                char   code = (char)(i + 0xA0);
                res.Replace(nm, "" + code);
            }
            return(res);
        }
コード例 #5
0
        public XmlDocument export()
        {
            XmlDocument res   = LureCommon.makeXml("lure-strings");
            XmlNode     blk   = res.DocumentElement.AppendChild(res.CreateElement("block"));
            ushort      count = BinaryHelper.readU16_LE(data, 0);
            int         ofs   = 2;

            for (int i = 0; i < count; i++)
            {
                string str = BinaryHelper.readZString(data, ofs);
                ofs += str.Length + 1;
                XmlNode txt = blk.AppendChild(res.CreateElement("text"));
                txt.Attributes.Append(res.CreateAttribute("id")).Value = i.ToString();
                if (str != "")
                {
                    txt.AppendChild(res.CreateTextNode(str));
                }
            }
            return(res);
        }
コード例 #6
0
        public XmlDocument export(bool arts)
        {
            XmlDocument res        = LureCommon.makeXml("lure-text");
            ushort      skipTblOfs = BinaryHelper.readU16_LE(data, 0);
            ushort      textData   = BinaryHelper.readU16_LE(data, 2);
            int         ofs        = 4;
            int         bglob      = 0;
            int         blkid      = 0;

            while (ofs <= skipTblOfs)
            {
                XmlElement bNode = (XmlElement)res.DocumentElement.AppendChild(res.CreateElement("block"));
                bNode.Attributes.Append(res.CreateAttribute("id")).Value = blkid.ToString();
                int tid   = 0;
                int tofs  = skipTblOfs + 32 * blkid;
                int tglob = 0;
                while (tid < 32 && tofs < textData)
                {
                    XmlElement tNode = (XmlElement)bNode.AppendChild(res.CreateElement("text"));
                    tNode.Attributes.Append(res.CreateAttribute("id")).Value = tid.ToString();
                    int glob = bglob + tglob;
                    int bit  = glob & 3;
                    if ((bit & 3) != 0)
                    {
                        bit = 0x80 >> (bit * 2);
                    }
                    else
                    {
                        bit = 0x80;
                    }
                    glob >>= 2;
                    glob  += textData;
                    //final pos
                    while (getBit(ref glob, ref bit))
                    {
                        glob += 2;
                    }
                    //bool b1 = getBit(ref ofs, ref bit);
                    bool art = getBit(ref glob, ref bit);
                    if (arts)
                    {
                        tNode.Attributes.Append(res.CreateAttribute("art")).Value = art?"1":"0";
                    }
                    readString(tNode, glob, bit);
                    if ((data[tofs] & 0x80) == 0)
                    {
                        tglob += data[tofs];
                    }
                    else
                    {
                        tglob += (data[tofs] & 0x7f) << 3;
                    }
                    tofs++;
                    tid++;
                }
                blkid++;
                bglob += BinaryHelper.readU16_LE(data, ofs);
                ofs   += 2;
            }
            return(res);
        }
コード例 #7
0
        public string getName(int index)
        {
            int nmStart = BinaryHelper.readU16_LE(data, index * 2);

            return(BinaryHelper.readZString(data, nmStart));
        }