示例#1
0
        /// <summary>
        ///
        /// </summary>
        private static void GetIconFromDOL(MEXDOLScrubber dol, MEX_Data data)
        {
            // generate menu table
            data.MenuTable            = new MEX_MenuTable();
            data.MenuTable.Parameters = new MEX_MenuParameters()
            {
                CSSHandScale            = 1,
                StageSelectCursorStartY = -13
            };
            dol.ExtractDataFromMap(data.MenuTable);


            // expand stage select node
            var sss        = data.MenuTable.SSSIconData._s;
            var stageIcons = new MEX_StageIconData[sss.Length / 0x1C];

            for (int i = 0; i < stageIcons.Length; i++)
            {
                stageIcons[i] = new MEX_StageIconData()
                {
                    _s = new HSDStruct(sss.GetSubData(i * 0x1C, 0x1C))
                };
                stageIcons[i]._s.Resize(0x20);
                stageIcons[i].ExternalID = sss.GetByte(i * 0x1C + 0x0B);
            }
            data.MenuTable.SSSIconData.Array = stageIcons;
        }
示例#2
0
        public static void InstallMisc(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            data.MiscData = new HSDRaw.MEX.Misc.MEX_Misc();

            data.MiscData.GawColors = new HSDArrayAccessor <HSDRaw.MEX.Misc.MEX_GawColor>()
            {
                Array = new HSDRaw.MEX.Misc.MEX_GawColor[]
                {
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x00, 0x00, 0x00), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x6E, 0x00, 0x00), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x00, 0x00, 0x6E), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                    new HSDRaw.MEX.Misc.MEX_GawColor()
                    {
                        FillColor = Color.FromArgb(0xFF, 0x00, 0x6E, 0x00), OutlineColor = Color.FromArgb(0x80, 0xFF, 0xFF, 0xFF)
                    },
                }
            };
        }
示例#3
0
        public static void InstallSounds(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            // generate ssm table
            data.SSMTable = new MEX_SSMTable();
            dol.ExtractDataFromMap(data.SSMTable);

            data.SSMTable.SSM_SSMFiles = new HSDNullPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(SSMStringOffset, data.MetaData.NumOfSSMs + 1)
            };
            data.SSMTable.SSM_Runtime = new HSDAccessor()
            {
                _s = new HSDStruct(0x18)
            };
            data.SSMTable.SSM_Runtime._s.SetReferenceStruct(0x00, new HSDStruct(0x180));
            data.SSMTable.SSM_Runtime._s.SetReferenceStruct(0x04, new HSDStruct(0xDC));
            data.SSMTable.SSM_Runtime._s.SetReferenceStruct(0x08, new HSDStruct(0xDC));
            data.SSMTable.SSM_Runtime._s.SetReferenceStruct(0x0C, new HSDStruct(0xDC));
            data.SSMTable.SSM_Runtime._s.SetReferenceStruct(0x10, new HSDStruct(0xDC));
            data.SSMTable.SSM_Runtime._s.SetReferenceStruct(0x14, new HSDStruct(0xDC));

            // add null entry
            data.SSMTable.SSM_SSMFiles.Add(new HSD_String("null.ssm"));

            // generate music table
            data.MusicTable = new MEX_BGMStruct();
            ExtractDataFromResource(resourceFile, data.MusicTable);
            data.MusicTable.BGMFileNames = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(MusicStringOffset, data.MetaData.NumOfMusic)
            };
            data.MusicTable.MenuPlaylist = new HSDArrayAccessor <MEX_PlaylistItem>()
            {
                Array = new MEX_PlaylistItem[] { new MEX_PlaylistItem()
                                                 {
                                                     ChanceToPlay = 100, HPSID = 52
                                                 } }
            };
            data.MusicTable.MenuPlayListCount = 1;
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="resource"></param>
        /// <returns></returns>
        public static bool InstallMEX(ImageResource resource)
        {
            // patch dol
            resource.SetDOL(MEXDolPatcher.ApplyPatch(resource.GetDOL(), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib/dol.patch")));

            /*using (var src = new MemoryStream(resource.GetDOL()))
             * using (System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider())
             * {
             *  byte[] vanillaFullHash = new byte[] { 39, 123, 108, 9, 132, 118, 2, 32, 152, 149, 208, 17, 197, 163, 163, 139 };
             *  byte[] vanillaDolHash = new byte[] { 135, 241, 17, 254, 252, 165, 45, 39, 50, 80, 104, 65, 216, 32, 142, 212 };
             *  byte[] patchedHash = new byte[] { 220, 216, 224, 150, 88, 53, 129, 175, 54, 201, 175, 176, 53, 71, 167, 40 };
             *
             *  var hash = md5.ComputeHash(src);
             *
             *  if (!hash.SequenceEqual(vanillaDolHash) && !hash.SequenceEqual(vanillaFullHash) && !hash.SequenceEqual(patchedHash))
             *      return false;
             *
             *  if (!hash.SequenceEqual(patchedHash))
             *      using (var dest = new MemoryStream())
             *      {
             *          src.Position = 0;
             *          GCILib.BZip2.BinaryPatchUtility.Apply(src, () => new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib/dol.patch"), FileMode.Open, FileAccess.Read, FileShare.Read), dest);
             *
             *          dest.Position = 0;
             *          hash = md5.ComputeHash(dest);
             *
             *          if (!hash.SequenceEqual(patchedHash))
             *              return false;
             *
             *          System.Diagnostics.Debug.WriteLine(string.Join(", ", patchedHash) + " " + hash.SequenceEqual(vanillaDolHash));
             *
             *          resource.SetDOL(dest.ToArray());
             *      }
             * }*/

            // generate mex files
            using (MEXDOLScrubber dol = new MEXDOLScrubber(resource.GetDOL()))
            {
                var resourceFile = new HSDRawFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib\\resource.dat"));

                // generate mxdt
                MEX_Data data = new MEX_Data();

                // generate meta data
                data.MetaData = new MEX_Meta()
                {
                    NumOfInternalIDs   = 33,
                    NumOfExternalIDs   = 33,
                    NumOfCSSIcons      = 26,
                    NumOfInternalStage = 0,
                    NumOfExternalStage = 285,
                    NumOfSSSIcons      = 30,
                    NumOfSSMs          = 55,
                    NumOfMusic         = 98,
                    NumOfEffects       = 51,
                    EnterScene         = 2,
                    LastMajor          = 45, //?
                    LastMinor          = 45,
                };
                // Version
                data.MetaData._s.SetInt16(0x00, 0x0100);


                // fighter table
                InstallFighters(dol, data, resourceFile);


                // kirby table
                InstallKirby(dol, data, resourceFile);


                // sound table
                InstallSounds(dol, data, resourceFile);


                // item table
                InstallItems(dol, data, resourceFile);



                // effect table
                data.EffectTable             = new MEX_EffectData();
                data.EffectTable.EffectFiles = new HSDArrayAccessor <MEX_EffectFiles>()
                {
                    _s = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
                    {
                        Array = dol.ReadStringTable(EffectStringOffset, data.MetaData.NumOfEffects * 3)
                    }._s
                };
                // note: this really isn't needed here because saving will regenerate anyway
                data.EffectTable.RuntimeUnk1 = new HSDAccessor()
                {
                    _s = new HSDStruct(0x60)
                };
                data.EffectTable.RuntimeUnk3 = new HSDAccessor()
                {
                    _s = new HSDStruct(0xCC)
                };
                data.EffectTable.RuntimeTexGrNum = new HSDAccessor()
                {
                    _s = new HSDStruct(0xCC)
                };
                data.EffectTable.RuntimeTexGrData = new HSDAccessor()
                {
                    _s = new HSDStruct(0xCC)
                };
                data.EffectTable.RuntimeUnk4 = new HSDAccessor()
                {
                    _s = new HSDStruct(0xCC)
                };
                data.EffectTable.RuntimePtclLast = new HSDAccessor()
                {
                    _s = new HSDStruct(0xCC)
                };
                data.EffectTable.RuntimePtclData = new HSDAccessor()
                {
                    _s = new HSDStruct(0xCC)
                };
                data.EffectTable.RuntimeLookup = new HSDAccessor()
                {
                    _s = new HSDStruct(0xCC)
                };

                // stage table
                InstallStages(dol, data, resourceFile);


                // scene table
                InstallScenes(dol, data, resourceFile);


                // misc table
                InstallMisc(dol, data, resourceFile);


                // generate sss and css symbols
                GetIconFromDOL(dol, data);
                var cssFile   = new HSDRawFile(resource.GetFile("MnSlChr.usd"));
                var sssFile   = new HSDRawFile(resource.GetFile("MnSlMap.usd"));
                var ifallFile = new HSDRawFile(resource.GetFile("IfAll.usd"));


                // mexSelectChr
                var mexMenuSymbol = GenerateMexSelectChrSymbol(cssFile.Roots[0].Data as SBM_SelectChrDataTable, data.MenuTable.CSSIconData.Icons);
                cssFile.Roots.RemoveAll(e => e.Name == "mexSelectChr");
                cssFile.Roots.Add(new HSDRootNode()
                {
                    Name = "mexSelectChr", Data = mexMenuSymbol
                });


                // mexMapData
                var mexMapSymbol = LoadIconDataFromVanilla(sssFile.Roots[0].Data as SBM_MnSelectStageDataTable);
                sssFile.Roots.RemoveAll(e => e.Name == "mexMapData");
                sssFile.Roots.Add(new HSDRootNode()
                {
                    Name = "mexMapData", Data = mexMapSymbol
                });


                // ifall data
                // load this from resources; don't generate
                if (ifallFile["bgm"] == null)
                {
                    ifallFile.Roots.Add(new HSDRootNode()
                    {
                        Name = "bgm",
                        Data = resourceFile["bgm"].Data
                    });
                }
                if (ifallFile["Eblm_matanim_joint"] == null)
                {
                    ifallFile.Roots.Add(new HSDRootNode()
                    {
                        Name = "Eblm_matanim_joint",
                        Data = resourceFile["Eblm_matanim_joint"].Data
                    });
                }
                if (ifallFile["Stc_icns"] == null)
                {
                    ifallFile.Roots.Add(new HSDRootNode()
                    {
                        Name = "Stc_icns",
                        Data = resourceFile["Stc_icns"].Data
                    });
                }



#if DEBUG
                /*var mexfile2 = new HSDRawFile();
                 * mexfile2.Roots.Add(new HSDRootNode() { Name = "mexData", Data = data });
                 * mexfile2.Save("test_Mxdt.dat");
                 * cssFile.Save("test_CSS.dat");
                 * sssFile.Save("test_SSS.dat");
                 * ifallFile.Save("test_IfAll.dat");
                 * return false;*/
#endif

                // add  files to resource
                resource.AddFile("codes.gct", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "lib\\codes.gct"));

                // null ssm file
                resource.AddFile("audio/us/null.ssm", resource.GetFile("audio/us/end.ssm"));

                using (MemoryStream dat = new MemoryStream())
                {
                    ifallFile.Save(dat);
                    resource.AddFile("IfAll.usd", dat.ToArray());
                }
                using (MemoryStream dat = new MemoryStream())
                {
                    cssFile.Save(dat);
                    resource.AddFile("MnSlChr.usd", dat.ToArray());
                }
                using (MemoryStream dat = new MemoryStream())
                {
                    sssFile.Save(dat);
                    resource.AddFile("MnSlMap.usd", dat.ToArray());
                }
                using (MemoryStream dat = new MemoryStream())
                {
                    var mexfile = new HSDRawFile();
                    mexfile.Roots.Add(new HSDRootNode()
                    {
                        Name = "mexData", Data = data
                    });
                    mexfile.Save(dat);
                    resource.AddFile("MxDt.dat", dat.ToArray());
                }
            }



            // success
            return(true);
        }
示例#5
0
        public static void InstallScenes(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            // Scenes
            data.SceneData = new HSDRaw.MEX.Scenes.MEX_SceneData();
            dol.ExtractDataFromMap(data.SceneData);

            {
                var majordata = data.SceneData.MajorScenes._s;

                var ar = new HSDRaw.MEX.Scenes.MEX_MajorScene[majordata.Length / 0x14];

                for (int i = 0; i < ar.Length; i++)
                {
                    ar[i] = new HSDRaw.MEX.Scenes.MEX_MajorScene()
                    {
                        _s = majordata.GetEmbeddedStruct(0x14 * i, 0x14)
                    };

                    ar[i]._s.Resize(0x18);

                    var ramOffset = (uint)ar[i]._s.GetInt32(0x10);

                    if (ramOffset > 0)
                    {
                        var offset = MEXDOLScrubber.RAMToDOL(ramOffset);
                        ar[i].MinorScene = new HSDArrayAccessor <HSDRaw.MEX.Scenes.MEX_MinorScene>();
                        ar[i].MinorScene._s.SetData(dol.GetSection(offset, 0x18 * MajorSceneMinorCounts[i]));
                    }
                }

                data.SceneData.MajorScenes.Array = ar;
            }

            for (int i = 0; i < data.SceneData.MajorScenes.Length; i++)
            {
                var scene = data.SceneData.MajorScenes[i];

                if (scene._s.GetInt32(0x10) == 0)
                {
                    continue;
                }

                var tableStart = MEXDOLScrubber.RAMToDOL((uint)scene._s.GetInt32(0x10));

                int size = 0;
                while (true)
                {
                    var val = dol.ReadValueAt((uint)(tableStart + 0x18 * size)) >> 24;
                    size++;
                    if (val == 0xFF)
                    {
                        break;
                    }
                }

                if (size > 0)
                {
                    scene.MinorScene = new HSDArrayAccessor <HSDRaw.MEX.Scenes.MEX_MinorScene>()
                    {
                        _s = new HSDStruct(dol.GetSection(tableStart, size * 0x18))
                    };
                    data.SceneData.MajorScenes[i] = scene;
                }
            }
        }
示例#6
0
        public static void InstallStages(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            // generate stage data
            data.StageData = new MEX_StageData();
            dol.ExtractDataFromMap(data.StageData);

            ExtractDataFromResource(resourceFile, data.StageData);

            var stageCount = data.StageData.CollisionTable.Length;

            data.StageData.StageItemLookup = new HSDArrayAccessor <MEX_ItemLookup>()
            {
                Array = new MEX_ItemLookup[stageCount]
            };
            data.StageData.StagePlaylists = new HSDArrayAccessor <MEX_Playlist>()
            {
                Array = new MEX_Playlist[stageCount]
            };

            // generate stage functions
            data.StageFunctions = new HSDFixedLengthPointerArrayAccessor <MEX_Stage>();

            for (int i = 0; i < 71; i++)
            {
                if (dol.ReadValueAt(StageFunctionOffset + (uint)i * 4) == 0)
                {
                    data.StageFunctions.Set(i, new MEX_Stage());
                    continue;
                }

                var off = MEXDOLScrubber.RAMToDOL(dol.ReadValueAt(StageFunctionOffset + (uint)i * 4));

                var stage = new MEX_Stage()
                {
                    _s = new HSDStruct(dol.GetSection(off, 0x34))
                };

                // gobj functions at 0x04 stride 0x14 unknown number of entries

                if (stage._s.GetInt32(0x08) != 0)
                {
                    stage.StageFileName = dol.ReadStringAt((uint)stage._s.GetInt32(0x08)).Value;
                }

                if (stage.MovingCollisionPointCount > 0 && stage._s.GetInt32(0x2C) != 0)
                {
                    var coloff = MEXDOLScrubber.RAMToDOL((uint)stage._s.GetInt32(0x2C));

                    stage._s.SetReferenceStruct(0x2C, new HSDStruct(dol.GetSection(coloff, 6 * stage.MovingCollisionPointCount)));
                }

                data.StageFunctions.Set(i, stage);
            }


            // Optional Map GOBJs
            //if (settings.IncludeMapGOBJs)
            {
                var mapGOBJStride = 20;
                var stages        = data.StageFunctions.Array;
                for (int i = 0; i < stages.Length; i++)
                {
                    var off = (uint)stages[i]._s.GetInt32(0x04);

                    if (off == 0)
                    {
                        continue;
                    }

                    off = MEXDOLScrubber.RAMToDOL(off);

                    stages[i]._s.SetReferenceStruct(0x04, new HSDStruct(dol.GetSection(off, MapGOBJEntries[i] * mapGOBJStride)));
                }
                data.StageFunctions.Array = stages;
            }
        }
示例#7
0
        public static void InstallFighters(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            // generate fighter table
            data.FighterData = new MEX_FighterData();
            dol.ExtractDataFromMap(data.FighterData);
            ExtractDataFromResource(resourceFile, data.FighterData);

            data.FighterData.DefineIDs.Add(new MEX_CharDefineIDs());
            data.FighterData.SSMFileIDs.Add(new MEX_CharSSMFileID());


            // convert fighter songs from bytes to shorts
            {
                var d = dol.GetSection((uint)MEXDOLScrubber.dolMap["FighterSongIDs"].Item1, MEXDOLScrubber.dolMap["FighterSongIDs"].Item2);
                data.FighterData.FighterSongIDs.Array = Enumerable.Range(0, d.Length / 2).Select(i => new MEX_FighterSongID()
                {
                    SongID1 = d[i * 2],
                    SongID2 = d[i * 2 + 1]
                }).ToArray();
            }


            // costume strings and runtime setup
            data.FighterData.CostumePointers = new HSDArrayAccessor <MEX_CostumeRuntimePointers>()
            {
                _s = dol.GetStruct(new Tuple <int, int>((int)CostumePointerOffset, 0x108))
            };
            data.FighterData.CostumeFileSymbols = new HSDArrayAccessor <MEX_CostumeFileSymbolTable>();
            for (int i = 0; i < data.FighterData.CostumePointers.Length; i++)
            {
                data.FighterData.CostumePointers._s.SetReferenceStruct(i * 8, new HSDStruct(0x18 * data.FighterData.CostumePointers[i].CostumeCount));

                if (data.FighterData.CostumePointers[i].CostumeCount > 0)
                {
                    var addr = MEXDOLScrubber.RAMToDOL(dol.ReadValueAt(CostumeStringOffset + (uint)i * 4));

                    MEX_CostumeFileSymbolTable costume = new MEX_CostumeFileSymbolTable();

                    var strings = dol.ReadStringTable(addr, data.FighterData.CostumePointers[i].CostumeCount * 3);

                    for (int j = 0; j < data.FighterData.CostumePointers[i].CostumeCount; j++)
                    {
                        costume.CostumeSymbols.Add(new MEX_CostumeFileSymbol()
                        {
                            FileName              = strings[j * 3]?.Value,
                            JointSymbol           = strings[j * 3 + 1]?.Value,
                            MatAnimSymbol         = strings[j * 3 + 2]?.Value,
                            VisibilityLookupIndex = j
                        });
                    }

                    data.FighterData.CostumeFileSymbols.Set(i, costume);
                }
            }
            data.FighterData.CostumeFileSymbols.Add(new MEX_CostumeFileSymbolTable());

            // anim file strings
            data.FighterData.AnimFiles = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(CharAnimStringOffset, data.MetaData.NumOfInternalIDs)
            };

            // vi files
            data.FighterData.VIFiles = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(VIFiles, 27)
            };

            // image files
            data.FighterData.EndClassicFiles = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(EndClassicStringOffset, 26)
            };
            data.FighterData.EndAdventureFiles = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(EndAdventureStringOffset, 26)
            };
            data.FighterData.EndAllStarFiles = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(EndAllStarStringOffset, 26)
            };
            data.FighterData.EndMovieFiles = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
            {
                Array = dol.ReadStringTable(EndMovieStringOffset, 26)
            };

            // ftDemo strings
            data.FighterData.FtDemo_SymbolNames = new HSDFixedLengthPointerArrayAccessor <MEX_FtDemoSymbolNames>();
            for (uint i = 0; i < 27; i++)
            {
                var addr = MEXDOLScrubber.RAMToDOL(dol.ReadValueAt(ftDemoStringOffset + i * 4));

                data.FighterData.FtDemo_SymbolNames.Add(
                    new MEX_FtDemoSymbolNames()
                {
                    _s = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
                    {
                        Array = dol.ReadStringTable(addr, 4)
                    }._s
                }
                    );
            }


            // character file strings
            data.FighterData._s.SetReferenceStruct(0x40, new HSDStruct(0x108));
            data.FighterData.CharFiles = new HSDArrayAccessor <MEX_CharFileStrings>()
            {
                _s = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
                {
                    Array = dol.ReadStringTable(CharStringOffset, data.MetaData.NumOfInternalIDs * 2)
                }._s
            };

            // blank mex data
            data.FighterData.FighterItemLookup = new HSDArrayAccessor <MEX_ItemLookup>()
            {
                Array = new MEX_ItemLookup[data.MetaData.NumOfInternalIDs]
            };


            // generate figther functions
            data.FighterFunctions = new MEX_FighterFunctionTable();
            dol.ExtractDataFromMap(data.FighterFunctions);

            data.FighterFunctions.enterFloat.Array             = new uint[33];
            data.FighterFunctions.enterSpecialDoubleJump.Array = new uint[33];
            data.FighterFunctions.enterTether.Array            = new uint[33];
            data.FighterFunctions.onLand.Array         = new uint[33];
            data.FighterFunctions.onSmashDown.Array    = new uint[33];
            data.FighterFunctions.onSmashForward.Array = new uint[33];
            data.FighterFunctions.onSmashUp.Array      = new uint[33];
            data.FighterFunctions.onThrowBk.Array      = new uint[33];
            data.FighterFunctions.onThrowFw.Array      = new uint[33];
            data.FighterFunctions.onThrowHi.Array      = new uint[33];
            data.FighterFunctions.onThrowLw.Array      = new uint[33];
            data.FighterFunctions.getTrailData.Array   = new uint[33];

            // special double jump code
            for (int i = 0; i < data.FighterFunctions.enterSpecialDoubleJump.Length; i++)
            {
                switch (i)
                {
                case 0x08:     // Ness
                    data.FighterFunctions.enterSpecialDoubleJump[i] = 0x800cbd18;
                    break;

                case 0x0E:     // Yoshi
                    data.FighterFunctions.enterSpecialDoubleJump[i] = 0x800cbe98;
                    break;

                case 0x09:     // Peach
                    data.FighterFunctions.enterSpecialDoubleJump[i] = 0x800cc0e8;
                    break;

                case 0x10:     // Mewtwo
                    data.FighterFunctions.enterSpecialDoubleJump[i] = 0x800cc238;
                    break;

                default:
                    data.FighterFunctions.enterSpecialDoubleJump[i] = 0x800cbbc0;
                    break;
                }
            }

            // Optional Move Logic
            //if (settings.IncludeMoveLogic)
            {
                var moveLogicStruct = data.FighterFunctions._s.GetReference <HSDAccessor>(0x0C);
                var movelogicStride = 0x20;
                for (int i = 0; i < data.MetaData.NumOfInternalIDs; i++)
                {
                    // get move logic pointer
                    var off = (uint)moveLogicStruct._s.GetInt32(i * 4);

                    // null pointer skips
                    if (off == 0 || MoveLogicEntries[i] == 0)
                    {
                        continue;
                    }

                    // convert ram offset to dol
                    off = MEXDOLScrubber.RAMToDOL(off);

                    // set the pointer to data
                    moveLogicStruct._s.SetReferenceStruct(i * 4, new HSDStruct(dol.GetSection(off, MoveLogicEntries[i] * movelogicStride)));
                }
            }
        }
示例#8
0
        public static void InstallKirby(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            // generate kirby data table
            data.KirbyData = new MEX_KirbyTable();
            dol.ExtractDataFromMap(data.KirbyData);
            data.KirbyData.CapFiles = new HSDArrayAccessor <MEX_KirbyCapFiles>()
            {
                _s = new HSDFixedLengthPointerArrayAccessor <HSD_String>()
                {
                    Array = dol.ReadStringTable(KirbyCapOffset, 33 * 2)
                }._s
            };
            data.KirbyData.KirbyCostumes = new HSDFixedLengthPointerArrayAccessor <MEX_KirbyCostume>();
            for (uint i = 0; i < 33; i++)
            {
                var ramaddr = MEXDOLScrubber.RAMToDOL(dol.ReadValueAt(KirbyCostumeOffset + i * 4));

                if (ramaddr != 0)
                {
                    var symbols = dol.ReadStringTable(ramaddr, 6 * 3);

                    var costumes = new MEX_CostumeFileSymbol[6];

                    for (int j = 0; j < costumes.Length; j++)
                    {
                        costumes[j] = new MEX_CostumeFileSymbol()
                        {
                            FileName              = symbols[j * 3 + 0].Value,
                            JointSymbol           = symbols[j * 3 + 1].Value,
                            MatAnimSymbol         = symbols[j * 3 + 2].Value,
                            VisibilityLookupIndex = j
                        };
                    }

                    data.KirbyData.KirbyCostumes.Add(new MEX_KirbyCostume()
                    {
                        Array = costumes
                    });
                }
                else
                {
                    data.KirbyData.KirbyCostumes.Add(null);
                }
            }

            // note: runtimes aren't really needed here
            data.KirbyData.CapFileRuntime = new HSDAccessor()
            {
                _s = new HSDStruct(0x100)
            };
            data.KirbyData.CapFtCmdRuntime = new HSDAccessor()
            {
                _s = new HSDStruct(0x100)
            };
            data.KirbyData.CostumeRuntime = new HSDAccessor()
            {
                _s = new HSDStruct(0xB8)
            };
            data.KirbyData.CostumeRuntime._s.SetReferenceStruct(0x0C, new HSDStruct(0x30));
            data.KirbyData.CostumeRuntime._s.SetReferenceStruct(0x3C, new HSDStruct(0x30));
            data.KirbyData.CostumeRuntime._s.SetReferenceStruct(0x40, new HSDStruct(0x30));
            data.KirbyData.CostumeRuntime._s.SetReferenceStruct(0x58, new HSDStruct(0x30));
            data.KirbyData.CostumeRuntime._s.SetReferenceStruct(0x60, new HSDStruct(0x30));


            // generate kirby function table
            data.KirbyFunctions = new MEX_KirbyFunctionTable();
            dol.ExtractDataFromMap(data.KirbyFunctions);
            var abtb = new HSDUIntArray()
            {
                _s = dol.GetStruct(MEXDOLScrubber.dolMap["KirbyAbility"])
            };

            data.KirbyFunctions.OnAbilityGain = new HSDUIntArray()
            {
                Array = abtb.Array.Where((e, i) => i % 2 == 0).ToArray()
            };
            data.KirbyFunctions.OnAbilityLose = new HSDUIntArray()
            {
                Array = abtb.Array.Where((e, i) => i % 2 == 1).ToArray()
            };
            data.KirbyFunctions.KirbyOnHit = new HSDUIntArray()
            {
                Array = new uint[data.MetaData.NumOfInternalIDs]
            };
            data.KirbyFunctions.KirbyOnItemInit = new HSDUIntArray()
            {
                Array = new uint[data.MetaData.NumOfInternalIDs]
            };
            data.KirbyFunctions.MoveLogicRuntime = new HSDAccessor()
            {
                _s = new HSDStruct(0x100)
            };
        }
示例#9
0
        public static void InstallItems(MEXDOLScrubber dol, MEX_Data data, HSDRawFile resourceFile)
        {
            // generate item table
            data.ItemTable = new MEX_ItemTables();
            dol.ExtractDataFromMap(data.ItemTable);
            data.ItemTable._s.SetReferenceStruct(0x14, new HSDStruct(4));

            // Optional Item States
            //if (settings.IncludeItemStates)
            {
                var itemStride = 0x10;
                for (int i = 0; i < data.ItemTable.CommonItems.Length; i++)
                {
                    var off = (uint)data.ItemTable.CommonItems._s.GetInt32(i * 0x3C);
                    //System.Diagnostics.Debug.WriteLine($"{GUI.MEX.DefaultItemNames.CommonItemNames[i],-40} \v0x{off.ToString("X8")} \v0x{DOLScrubber.RAMToDOL(off).ToString("X8")} \v{CommonItemStates[i]}");

                    if (off == 0 || CommonItemStates[i] == 0)
                    {
                        continue;
                    }
                    off = MEXDOLScrubber.RAMToDOL(off);
                    data.ItemTable.CommonItems._s.SetReferenceStruct(i * 0x3C, new HSDStruct(dol.GetSection(off, CommonItemStates[i] * itemStride)));
                }
                for (int i = 0; i < data.ItemTable.FighterItems.Length; i++)
                {
                    var off = (uint)data.ItemTable.FighterItems._s.GetInt32(i * 0x3C);
                    //System.Diagnostics.Debug.WriteLine($"{GUI.MEX.DefaultItemNames.FighterItemNames[i],-40} \v0x{off.ToString("X8")} \v0x{DOLScrubber.RAMToDOL(off).ToString("X8")} \v{FighterItemStates[i]}");

                    if (off == 0 || FighterItemStates[i] == 0)
                    {
                        continue;
                    }
                    off = MEXDOLScrubber.RAMToDOL(off);
                    data.ItemTable.FighterItems._s.SetReferenceStruct(i * 0x3C, new HSDStruct(dol.GetSection(off, FighterItemStates[i] * itemStride)));
                }
                for (int i = 0; i < data.ItemTable.Pokemon.Length; i++)
                {
                    var off = (uint)data.ItemTable.Pokemon._s.GetInt32(i * 0x3C);
                    //System.Diagnostics.Debug.WriteLine($"{GUI.MEX.DefaultItemNames.PokemonItemNames[i],-40} \v0x{off.ToString("X8")} \v0x{DOLScrubber.RAMToDOL(off).ToString("X8")} \v{PokemonItemStates[i]}");

                    if (off == 0 || PokemonItemStates[i] == 0)
                    {
                        continue;
                    }
                    off = MEXDOLScrubber.RAMToDOL(off);
                    data.ItemTable.Pokemon._s.SetReferenceStruct(i * 0x3C, new HSDStruct(dol.GetSection(off, PokemonItemStates[i] * itemStride)));
                }
                for (int i = 0; i < data.ItemTable.StageItems.Length; i++)
                {
                    var off = (uint)data.ItemTable.StageItems._s.GetInt32(i * 0x3C);
                    //System.Diagnostics.Debug.WriteLine($"{GUI.MEX.DefaultItemNames.StageItemNames[i],-40} \v0x{off.ToString("X8")} \v0x{DOLScrubber.RAMToDOL(off).ToString("X8")} \v{StageItemStates[i]}");

                    if (off == 0 || StageItemStates[i] == 0)
                    {
                        continue;
                    }
                    off = MEXDOLScrubber.RAMToDOL(off);
                    data.ItemTable.StageItems._s.SetReferenceStruct(i * 0x3C, new HSDStruct(dol.GetSection(off, StageItemStates[i] * itemStride)));
                }
            }
        }