コード例 #1
0
ファイル: Dark Dawn.cs プロジェクト: adituv/gsmagic
        public void init(string aPath)
        {
            path   = aPath;
            header = Bits.openFilePart(path, 0, 0x200);
            fnt    = Bits.openFilePart(path, Bits.getInt32(header, 0x40), Bits.getInt32(header, 0x44));
            fat    = Bits.openFilePart(path, Bits.getInt32(header, 0x48), Bits.getInt32(header, 0x4C));
            ovr    = Bits.openFilePart(path, Bits.getInt32(header, 0x50), Bits.getInt32(header, 0x54));
            //Title check?
            loadARM9();
            loadFile(0x154);
            //Overlay File 0x151 / Battle Stuff
            //loadFile(0x181);//0x11AD+1+0x16E);// 0x1383);//0xFC7 + 8); //0x1134);// 0xD07 + 48*8);
            loadFile(0xD07);
            //doTextFile();
            doTextFiles();
            Form dd = new Form();

            dd.Text   = "Dark Dawn WIP - " + path;
            dd.Width  = 800;
            dd.Height = 600;
            dd.Show();
            dd.Activate();            //dd.Focus();
            //dd.TopMost = true;
            //dd.ShowDialog();

            TabControl a = new TabControl();

            a.Width  = dd.Width;
            a.Height = dd.Height;

            a.Controls.Add(new TabPage("Enemies"));
            //loadEnemies(a);

            TabPage d = new TabPage();

            d.Text = "Djinn";
            a.Controls.Add(d);

            dd.Controls.Add(a);
            loadEnemies(a);
            //File.WriteAllBytes(path + "ram.bin", ram);

            Button s = new Button();

            s.Left = a.Width;            // - 100;
            s.Top  = 0;
            dd.Controls.Add(s);
            s.MouseClick += new MouseEventHandler(saveClick);
        }
コード例 #2
0
ファイル: Dark Dawn.cs プロジェクト: adituv/gsmagic
        void loadFile(int fileID)
        {
            //if ((fileID < 0) || (fileID >= 0xF000))
            //	return;
            int ovrA = fileID << 5;
            int fatA = fileID << 3;             //One of Overlay ID or File ID in ovr should determine this? So update later?
            int fat1 = Bits.getInt32(fat, fatA);
            int fat2 = Bits.getInt32(fat, fatA + 4);
            int size = fat2 - fat1;

            byte[] src = Bits.openFilePart(path, fat1, size);             //new byte[size];

            //if (fileID == 0)
            //	Bits.saveFile(@"C:\Users\Tea\Desktop\original.bin", src);
            //Bits.saveFilePart(path, fat1, size, des);
            int srcPos = 0;

            byte[] des = ram;
            //int desPos = Bits.getInt32(ovr, ovrA + 4) & 0x1FFFFFF;
            //if (fileID > 0x16D) //Quick hack:  If not overlay file.... then I dunno where to put it yet, so...
            //	desPos = 0x220B80; //Update to base on slot list at 020840D4?
            int desPos = 0x220B80;

            if (fileID <= 0x16D)
            {
                desPos = Bits.getInt32(ovr, ovrA + 4) & 0x1FFFFFF;
            }
            //Sample/example - Some empty text files look like this:
            //40 04 00 00 A0 FF 13 00 00 00
            //In easier to read format: 40 000004 60 FF 001/3 000/0
            //(Note:  -A0 = 60)
            //which decompresses to FFFFFFFF.
            if (src[srcPos++] != 0x40)
            {
                return;
            }
            int decSize = src[srcPos++] | (src[srcPos++] << 8) | (src[srcPos++] << 16);

            if (decSize == 0)
            {
                decSize = Bits.getInt32(src, srcPos); srcPos += 4;
            }
            while (decSize-- > 0)
            {
                int flags = 0x800000 - (src[srcPos++] << 0x18);
                while ((flags << 1) != 0)
                {
                    if (flags > 0)
                    {
                        des[desPos++] = src[srcPos++];
                    }
                    else
                    {
                        int len  = src[srcPos] & 0xF;
                        int dist = (src[srcPos++] >> 4) | (src[srcPos++] << 4);
                        if (len == 0)
                        {
                            if (dist == 0)                             //Used by default.
                            {
                                return;
                            }
                            len = 0x10 + src[srcPos++];
                        }
                        else if (len == 1)
                        {
                            if (dist == 0)                             //May not ever be used, but here for functionality.
                            {
                                return;
                            }
                            len = 0x110 + src[srcPos++] + (src[srcPos++] << 8);
                        }
                        dist = desPos - dist;
                        while (len-- > 0)
                        {
                            des[desPos++] = des[dist++];
                        }
                    }
                    flags <<= 1;
                }
            }
        }