Пример #1
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;
                }
            }
        }
Пример #2
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)));
                }
            }
        }
Пример #3
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;
            }
        }
Пример #4
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)));
                }
            }
        }