Exemplo n.º 1
0
        private static void RegionParse_cmd15(ROM rom, List <Region> regions)
        {
            int segment = rom.Read8(4);

            if (segment != 0x0e)
            {
                return;
            }

            int segmentedAddress = rom.Read32(4);
            int address          = (int)rom.GetROMAddress(segmentedAddress);

            DisplayList.PerformRegionParse(rom, regions, address, rom.Read8(1));
        }
Exemplo n.º 2
0
        private static void RegionParse_cmd21(ROM rom, List <Region> regions, RegionParseState state)
        {
            if (state.regionState != RegionState.ModelsLoader)
            {
                CutRegion(rom, regions, state, rom.offset, RegionState.ModelsLoader);
            }

            int segmentedAddress = rom.Read32(4);
            int segment          = rom.Read8(4);
            int model            = rom.Read8(3);

            // Only 0x19 or 0x0E commands are supported
            if (segment != 0x19 && segment != 0x0E)
            {
                return;
            }

            int displayListROMAddress = (int)rom.GetROMAddress(segmentedAddress);

            try
            {
                List <Region> modelRegions = new List <Region>();
                DisplayList.PerformRegionParse(rom, modelRegions, displayListROMAddress, rom.Read8(2));

                foreach (Region region in modelRegions)
                {
                    region.model = model;
                }

                regions.AddRange(modelRegions);
            }
            catch (NotSupportedException e)
            {
                MessageBox.Show(String.Format("Model {0} graphics parsing is not supported! Reason : '{1}'", model, e.Message), "Level Parser", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("Failed to parse model {0} graphics! Reason : '{1}'", model, e.Message), "Level Parser", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            List <Region> regions = new List <Region>();

            if (!Int32.TryParse(textBoxF3DPtr.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int offset))
            {
                MessageBox.Show("Custom DL", "Invalid ptr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Int32.TryParse(textBoxSegNum.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int segment))
            {
                MessageBox.Show("Custom DL", "Invalid segment", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Int32.TryParse(textBoxROMAddr.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int addr))
            {
                MessageBox.Show("Custom DL", "Invalid rom addr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            rom.SetSegment(segment, new SegmentDescriptor(addr, 0x00400000));
            DisplayList.FixConfig config = new DisplayList.FixConfig(checkBoxNerfFog.Checked, checkBoxOptimizeVertex.Checked, checkBoxTrimNops.Checked, checkBoxCombiners.Checked, checkBoxOtherMode.Checked, checkBoxNoFog.Checked);

            DisplayList.PerformRegionParse(rom, regions, offset, int.Parse(textBoxLayer.Text));
            foreach (Region region in regions)
            {
                if (region.state != RegionState.DisplayList)
                {
                    continue;
                }

                DisplayListRegion dlRegion = (DisplayListRegion)region;
                region.data = new byte[region.length];
                rom.ReadData(region.romStart, region.length, region.data);

                int maxDLLength = dlRegion.length;
                DisplayList.PerformRegionFix(rom, dlRegion, config);
                if (checkBoxOptimizeVertex.Checked)
                {
                    DisplayList.PerformRegionOptimize(rom, dlRegion, config);
                }

                if (checkBoxGroupByTexture.Checked)
                {
                    if (checkBoxRebuildVertices.Checked)
                    {
                        DisplayList.PerformTriangleMapRebuild(rom, dlRegion, maxDLLength, new List <ScrollObject>());
                    }
                    else
                    {
                        DisplayList.PerformVisualMapRebuild(rom, dlRegion, maxDLLength);
                    }
                }

                DisplayList.PerformRegionOptimize(rom, dlRegion, config);
            }

            File.WriteAllBytes(path, rom.rom);

            rom.SetSegment(segment, null);
            MessageBox.Show(String.Format("Ptr was fixed successfully"), "f3d fix", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }