示例#1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            int num3;
            this.panel2.Width = (0x101 + this.panel2.Width) - this.panel2.ClientRectangle.Width;
            this.panel2.Height = ((this.panel2.Height - this.panel2.ClientRectangle.Height) + 15) + 2;
            FileStream input = new FileStream(romf, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            BinaryReader reader = new BinaryReader(input);
            ms = new MemoryStream(reader.ReadBytes((int)reader.BaseStream.Length));
            reader.BaseStream.Seek(4, SeekOrigin.Begin);
            pbanknum = reader.ReadByte();
            reader.BaseStream.Seek(0x2914c, SeekOrigin.Begin);
            enterspnum = reader.ReadByte();
            input.Close();
            cp = this.GetColorPalette(0x40);
            for (int i = 0; i < 0x40; i++)
            {
                cp.Entries[i] = commondata.nes_Palette[i];
            }
            for (int j = 0; j < 0x80; j++)
            {
                this.imageList1.Images.Add(j.ToString(), new Bitmap(1, 1));
            }
            this._commdata = new commondata();
            byte[] buffer = getfilecontents(0xbe12, 0x7e);
            for (num3 = 0; num3 < 0x7e; num3++)
            {
                singleMap item = new singleMap
                {
                    map_addr = (buffer[num3 + 1] * 0x100) + buffer[num3]
                };
                this.allmapdata.Add(item);
                num3++;
            }
            num3 = 0;
            buffer = getfilecontents(0x1deb0, 0x160);
            while (num3 < 0x160)
            {
                singleMap map2 = new singleMap
                {
                    map_addr = (buffer[num3 + 1] * 0x100) + buffer[num3]
                };
                this.allmapdata.Add(map2);
                num3++;
                num3++;
            }
            for (int k = 0; k < this.allmapdata.Count; k++)
            {
                int num5 = this.allmapdata[k].map_addr;
                byte num6 = getfilecontent((long)((0xe010 + num5) - 0x8000));
                int count = 0x18;
                if ((num6 & 1) != 0)
                {
                    count += 2;
                }
                if ((num6 & 4) != 0)
                {
                    count += 2;
                }
                this.allmapdata[k].map_store_data = new byte[count];
                getfilecontents((0xe010 + num5) - 0x8000, count).CopyTo(this.allmapdata[k].map_store_data, 0);
                this.allmapdata[k].maptitles = new byte[this.allmapdata[k].MapHeight * this.allmapdata[k].MapWidth];
                this.allmapdata[k].nametable = new byte[(this.allmapdata[k].MapHeight * this.allmapdata[k].MapWidth) * 4];
                this.allmapdata[k].uper2 = new byte[this.allmapdata[k].MapHeight * this.allmapdata[k].MapWidth];
                int mapTitleAddr = this.allmapdata[k].mapTitleAddr;
                if (mapTitleAddr >= 0xc000)
                {
                    int num9 = mapTitleAddr - 0xc000;
                    this.map_addr = (((pbanknum * 0x4000) + 0x10) + ((0xec + (((num9 >> 8) & 240) >> 2)) * 0x400)) + (num9 & 0xfff);
                }
                else
                {
                    int num10 = mapTitleAddr & 0x1fff;
                    int num11 = mapTitleAddr >> 13;
                    this.map_addr = ((num11 * 0x2000) + 0x10) + num10;
                }
                int off = this.map_addr;
                this.map_data_index = 0;
                this.maptitlestore_len = 0;
                int index = 0;
            Label_0465:
                while (index < this.allmapdata[k].maptitles.Length)
                {
                    byte mapTileData = this.GetMapTileData();
                    if (mapTileData == 0)
                    {
                        byte num15 = this.GetMapTileData();
                        int num16 = this.GetMapTileData();
                        for (int num17 = 0; num17 < num16; num17++)
                        {
                            if (index >= this.allmapdata[k].maptitles.Length)
                            {
                                goto Label_0465;
                            }
                            this.allmapdata[k].maptitles[index] = num15;
                            index++;
                        }
                    }
                    else
                    {
                        this.allmapdata[k].maptitles[index] = mapTileData;
                        index++;
                    }
                }
                this.allmapdata[k].maptitlestore = getfilecontents(off, this.maptitlestore_len);
                getfilecontents((((pbanknum * 0x4000) + 0x10) + ((0xd4 + ((this.allmapdata[k].map_store_data[9] & 240) >> 2)) * 0x400)) + ((this.allmapdata[k].map_store_data[9] & 15) * 0x100), 0x100).CopyTo(this.allmapdata[k].maptitles_1, 0);
                getfilecontents((((pbanknum * 0x4000) + 0x10) + ((0xd4 + ((this.allmapdata[k].map_store_data[10] & 240) >> 2)) * 0x400)) + ((this.allmapdata[k].map_store_data[10] & 15) * 0x100), 0x100).CopyTo(this.allmapdata[k].maptitles_1, 0x100);
                int num18 = ((this.allmapdata[k].map_store_data[9] * 0x100) >> 2) + 0x3700;
                getfilecontents((((pbanknum * 0x4000) + 0x10) + ((0xd4 + ((num18 & 0xf000) >> 10)) * 0x400)) + (num18 & 0xfff), 0x40).CopyTo(this.allmapdata[k].maptitles_1, 0x200);
                num18 = ((this.allmapdata[k].map_store_data[10] * 0x100) >> 2) + 0x3700;
                getfilecontents((((pbanknum * 0x4000) + 0x10) + ((0xd4 + ((num18 & 0xf000) >> 10)) * 0x400)) + (num18 & 0xfff), 0x40).CopyTo(this.allmapdata[k].maptitles_1, 0x240);
                byte[] buffer5 = getfilecontents((0x1c010 + this.allmapdata[k].palleteaddr) - 0x8000, 9);
                int num19 = 0;
                for (int num20 = 0; num20 < 13; num20++)
                {
                    if ((num20 % 4) == 0)
                    {
                        this.allmapdata[k].pallete[num20] = 15;
                    }
                    else
                    {
                        this.allmapdata[k].pallete[num20] = buffer5[num19++];
                    }
                }
                this.allmapdata[k].pallete[13] = 0x30;
                this.allmapdata[k].pallete[14] = 0x10;
                this.allmapdata[k].pallete[15] = 0;
                for (int num21 = 0; num21 < 4; num21++)
                {
                    int key = this.allmapdata[k].PattenTable[num21];
                    if (!this._commdata.chrimagedata.ContainsKey(key))
                    {
                        byte[] buffer6 = getfilecontents(((key * 0x400) + (pbanknum * 0x4000)) + 0x10, 0x400);
                        this._commdata.Add_CHR_index(key, buffer6);
                    }
                }
                if (!this._commdata.chrimagedata.ContainsKey(this.allmapdata[k].PattenTable1))
                {
                    int num23 = this.allmapdata[k].PattenTable1;
                    byte[] buffer7 = getfilecontents(((num23 * 0x400) + (pbanknum * 0x4000)) + 0x10, 0x400);
                    this._commdata.Add_CHR_index(num23, buffer7);
                    num23++;
                    buffer7 = getfilecontents(((num23 * 0x400) + (pbanknum * 0x4000)) + 0x10, 0x400);
                    this._commdata.Add_CHR_index(num23, buffer7);
                }
            }
            byte[] data = getfilecontents((0x1000 + (pbanknum * 0x4000)) + 0x10, 0x400);
            this._commdata.Add_CHR_index(4, data);
            data = getfilecontents((0x1400 + (pbanknum * 0x4000)) + 0x10, 0x400);
            this._commdata.Add_CHR_index(5, data);
            for (int m = 0; m < this.allmapdata.Count; m++)
            {
                int num45;
                singleMap map3 = this.allmapdata[m];
                int mapWidth = map3.MapWidth;
                int mapHeight = map3.MapHeight;
                byte[] nametable = map3.nametable;
                for (int num27 = 0; num27 < mapWidth; num27++)
                {
                    for (int num28 = 0; num28 < mapHeight; num28++)
                    {
                        nametable[((num28 * mapWidth) * 4) + (num27 * 2)] = map3.maptitles_1[map3.maptitles[(num28 * mapWidth) + num27] * 4];
                        nametable[(((num28 * mapWidth) * 4) + (num27 * 2)) + 1] = map3.maptitles_1[(map3.maptitles[(num28 * mapWidth) + num27] * 4) + 1];
                        nametable[((num28 * mapWidth) * 4) + ((mapWidth + num27) * 2)] = map3.maptitles_1[(map3.maptitles[(num28 * mapWidth) + num27] * 4) + 2];
                        nametable[(((num28 * mapWidth) * 4) + ((mapWidth + num27) * 2)) + 1] = map3.maptitles_1[(map3.maptitles[(num28 * mapWidth) + num27] * 4) + 3];
                        map3.uper2[(num28 * mapWidth) + num27] = (byte)(map3.maptitles_1[0x200 + map3.maptitles[(num28 * mapWidth) + num27]] & 3);
                    }
                }
                byte[] originalImageData = new byte[(((map3.MapHeight * map3.MapWidth) * 4) * 8) * 8];
                byte[] array = new byte[0x4000];
                this._commdata.chrimagedata[map3.PattenTable[0]].CopyTo(array, 0);
                this._commdata.chrimagedata[map3.PattenTable[1]].CopyTo(array, 0x1000);
                this._commdata.chrimagedata[map3.PattenTable[2]].CopyTo(array, 0x2000);
                this._commdata.chrimagedata[map3.PattenTable[3]].CopyTo(array, 0x3000);
                for (int num29 = 0; num29 < (map3.MapWidth * 2); num29++)
                {
                    for (int num30 = 0; num30 < (map3.MapHeight * 2); num30++)
                    {
                        int num31 = nametable[num29 + ((num30 * map3.MapWidth) * 2)];
                        int num32 = map3.uper2[((num30 / 2) * map3.MapWidth) + (num29 / 2)] * 4;
                        for (int num33 = 0; num33 < 8; num33++)
                        {
                            for (int num34 = 0; num34 < 8; num34++)
                            {
                                originalImageData[(((((num30 * 0x40) * map3.MapWidth) * 2) + (((num33 * 8) * map3.MapWidth) * 2)) + (num29 * 8)) + num34] = (byte)(array[((((num31 / 0x10) * 0x400) + (0x80 * num33)) + ((num31 % 0x10) * 8)) + num34] + num32);
                            }
                        }
                    }
                }
                for (int num35 = 0; num35 < originalImageData.Length; num35++)
                {
                    originalImageData[num35] = map3.pallete[originalImageData[num35]];
                }
                Bitmap original = bmp.CreateBitmap(originalImageData, (map3.MapWidth * 8) * 2, (map3.MapHeight * 8) * 2);
                original.Palette = cp;
                Bitmap bitmap2 = new Bitmap(original);
                original.Dispose();
                original = null;
                map3.cityBmp = bitmap2.Clone(new Rectangle(0, 0, map3.MapWidth * 0x10, map3.MapHeight * 0x10), PixelFormat.Format24bppRgb);
                for (int num36 = 0; num36 < 0x80; num36++)
                {
                    byte[] buffer12 = new byte[0x100];
                    for (int num37 = 0; num37 < 2; num37++)
                    {
                        for (int num38 = 0; num38 < 2; num38++)
                        {
                            int num39 = map3.maptitles_1[((num36 * 4) + (num37 * 2)) + num38];
                            for (int num40 = 0; num40 < 8; num40++)
                            {
                                for (int num41 = 0; num41 < 8; num41++)
                                {
                                    buffer12[(((((num37 * 8) * 8) * 2) + ((num40 * 8) * 2)) + (num38 * 8)) + num41] = (byte)(array[((((num39 / 0x10) * 0x400) + (0x80 * num40)) + ((num39 % 0x10) * 8)) + num41] + ((map3.maptitles_1[0x200 + num36] & 3) * 4));
                                }
                            }
                        }
                    }
                    for (int num42 = 0; num42 < buffer12.Length; num42++)
                    {
                        buffer12[num42] = map3.pallete[buffer12[num42]];
                    }
                    Bitmap bitmap3 = bmp.CreateBitmap(buffer12, 0x10, 0x10);
                    bitmap3.Palette = cp;
                    map3.map_item_image[num36] = new Bitmap(bitmap3);
                }
                int num43 = getfilecontent((long)((((enterspnum * 0x2000) + 0x10) + map3.enterAddr) - 0x8000));
                int num44 = 0;
                switch (num43)
                {
                    case 0xff:
                        num44 = getfilecontent((long)((((enterspnum * 0x2000) + 0x11) + map3.enterAddr) - 0x8000));
                        map3.enterdata = getfilecontents((((enterspnum * 0x2000) + 0x10) + map3.enterAddr) - 0x8000, 2 + (5 * num44));
                        num45 = 2;
                        break;

                    case 0xfe:
                        num44 = getfilecontent((long)((((enterspnum * 0x2000) + 20) + map3.enterAddr) - 0x8000));
                        map3.enterdata = getfilecontents((((enterspnum * 0x2000) + 0x10) + map3.enterAddr) - 0x8000, 5 + (5 * num44));
                        num45 = 5;
                        break;

                    default:
                        num44 = getfilecontent((long)((((enterspnum * 0x2000) + 0x1c) + map3.enterAddr) - 0x8000));
                        map3.enterdata = getfilecontents((((enterspnum * 0x2000) + 0x10) + map3.enterAddr) - 0x8000, 13 + (5 * num44));
                        num45 = 13;
                        break;
                }
                map3.enters = new List<enterPoint>();
                for (int num46 = 0; num46 < num44; num46++)
                {
                    enterPoint point = new enterPoint
                    {
                        X = map3.enterdata[num45 + (num46 * 2)],
                        Y = map3.enterdata[(num45 + (num46 * 2)) + 1],
                        switchmap = map3.enterdata[(num45 + (2 * num44)) + (num46 * 3)],
                        map_x = map3.enterdata[((num45 + (2 * num44)) + (num46 * 3)) + 1],
                        map_y = map3.enterdata[((num45 + (2 * num44)) + (num46 * 3)) + 2]
                    };
                    map3.enters.Add(point);
                }
                if (map3.dynamicMapaddr != 0)
                {
                    int dynamicMapaddr = map3.dynamicMapaddr;
                    List<byte> list = new List<byte>();
                    for (byte num48 = getfilecontent((long)((0x1c010 + dynamicMapaddr) - 0x8000)); num48 != 0; num48 = getfilecontent((long)((0x1c010 + dynamicMapaddr) - 0x8000)))
                    {
                        list.Add(num48);
                        dynamicMapaddr++;
                    }
                    map3.dynamicdata = list.ToArray();
                }
            }
            int num49 = getfilecontent(0x28ac3) + (getfilecontent(0x28ac7) * 0x100);
            List<byte> list2 = new List<byte>();
            for (byte n = getfilecontent((long)((0x1c010 + num49) - 0x8000)); n != 0; n = getfilecontent((long)((0x1c010 + num49) - 0x8000)))
            {
                list2.Add(n);
                num49++;
            }
            this.bigmapdynmicdata = list2.ToArray();
            byte[] buffer13 = getfilecontents(0x24012, 0x1de);
            for (int num51 = 0; num51 < buffer13.Length; num51++)
            {
                singleMap map4 = this.allmapdata[num51 / 2];
                map4.npc_addr = buffer13[num51] + (buffer13[num51 + 1] * 0x100);
                if (map4.npc_addr != 0)
                {
                    int num52 = getfilecontent((long)((0x24010 + map4.npc_addr) - 0x8000));
                    for (int num53 = 0; num53 < num52; num53++)
                    {
                        npc_data _data = new npc_data(getfilecontents(((0x24011 + map4.npc_addr) - 0x8000) + (num53 * 6), 6), map4.PattenTable1, ref this._commdata);
                        map4.npc_datas.Add(_data);
                    }
                }
                num51++;
            }
            byte[] buffer15 = getfilecontents(0x39c50, 0x182);
            for (int num54 = 0; num54 < 0x5b; num54++)
            {
                if (buffer15[num54] > 0)
                {
                    hideItemdata itemdata = new hideItemdata
                    {
                        x = buffer15[0x5b + num54],
                        y = buffer15[0xb6 + num54],
                        itemdata = buffer15[0x111 + num54]
                    };
                    this.allmapdata[buffer15[num54] - 1].hideItem.Add(itemdata);
                }
                else
                {
                    hideItemdata itemdata2 = new hideItemdata
                    {
                        x = buffer15[0x5b + num54],
                        y = buffer15[0xb6 + num54],
                        itemdata = buffer15[0x111 + num54]
                    };
                    this.bigmaphideItem.Add(itemdata2);
                }
            }
            byte[] buffer16 = getfilecontents(0x39343, 0x70);
            this.mondatas = new mondata(buffer16);
            byte[] buffer17 = getfilecontents(0x39dd2, 0x1ec);
            for (int num55 = 0; num55 < 0x7b; num55++)
            {
                if (buffer17[num55] > 0)
                {
                    specPosition position = new specPosition
                    {
                        mapid = buffer17[num55],
                        content = buffer17[0x7b + num55],
                        X = buffer17[0xf6 + num55],
                        Y = buffer17[0x171 + num55]
                    };
                    this.allmapdata[position.mapid - 1].specP.Add(position);
                }
            }
            for (int num56 = 0; num56 < this.allmapdata.Count; num56++)
            {
                int num58 = num56 + 1;
                this.listBox1.Items.Add(string.Format("{0}:\t{1}", num58.ToString("X"), this.allmapdata[num56].map_addr.ToString("X")));
            }
            IList<int> list3 = new List<int>();
            IList<int> list4 = new List<int>();
            IList<int> list5 = new List<int>();
            for (int num57 = 0; num57 < this.allmapdata.Count; num57++)
            {
                if (!list3.Contains(this.allmapdata[num57].mapTitleAddr))
                {
                    list3.Add(this.allmapdata[num57].mapTitleAddr);
                }
                else
                {
                    list3.Add(0);
                    this.allmapdata[num57].mapstoreshare = list3.IndexOf(this.allmapdata[num57].mapTitleAddr);
                }
                if (!list4.Contains(this.allmapdata[num57].enterAddr))
                {
                    list4.Add(this.allmapdata[num57].enterAddr);
                }
                else
                {
                    list4.Add(0);
                    this.allmapdata[num57].mapentershare = list4.IndexOf(this.allmapdata[num57].enterAddr);
                }
                if (!list5.Contains(this.allmapdata[num57].npc_addr))
                {
                    list5.Add(this.allmapdata[num57].npc_addr);
                }
                else
                {
                    list5.Add(0);
                    this.allmapdata[num57].mapnpcshare = list5.IndexOf(this.allmapdata[num57].npc_addr);
                }
            }
            this.loadItemFromfile();
        }
示例#2
0
 private void button18_Click(object sender, EventArgs e)
 {
     hideItemdata item = new hideItemdata
     {
         x = (int)this.numericUpDown21.Value,
         y = (int)this.numericUpDown20.Value,
         itemdata = (int)this.numericUpDown19.Value
     };
     this.comboBox4.Items.Add(this.comboBox4.Items.Count.ToString("d2"));
     this.map.hideItem.Add(item);
     MessageBox.Show("添加完成!");
 }