private static void HeaderParse_cmd17(ROM rom) { int segment = rom.Read8(3); int startAddress = rom.Read32(4); int endAddress = rom.Read32(8); SegmentDescriptor descriptor = new SegmentDescriptor(startAddress, endAddress - startAddress); rom.SetSegment(segment, descriptor); }
private static void RegionParse_cmd17(ROM rom, List <Region> regions, RegionParseState state) { int segment = rom.Read8(3); int startAddress = rom.Read32(4); int endAddress = rom.Read32(8); if ((uint)startAddress > 0x4000000) { return; } SegmentDescriptor descriptor = new SegmentDescriptor(startAddress, endAddress - startAddress); rom.SetSegment(segment, descriptor); }
private static void RegionParse_cmd00(ROM rom, List <Region> regions, RegionParseState state) { int segment = rom.Read8(3); if (segment != 0x19) { throw new MessageException("ROM does not use bank 0x19. Did you import a level?"); } int startAddress = rom.Read32(4); int endAddress = rom.Read32(8); SegmentDescriptor descriptor = new SegmentDescriptor(startAddress, endAddress - startAddress); rom.SetSegment(segment, descriptor); int segmentedAddress = rom.Read32(12); int levelscriptAddress = rom.GetROMAddress(segmentedAddress); rom.offset = levelscriptAddress - 0x10; // kostul for adding 0x10 state.start = levelscriptAddress; }
private static void HeaderParse_cmd00(ROM rom) { int segment = rom.Read8(3); if (segment != 0x19) { throw new MessageException("ROM does not use bank 0x19. Did you import a level?"); } int startAddress = rom.Read32(4); int endAddress = rom.Read32(8); SegmentDescriptor descriptor = new SegmentDescriptor(startAddress, endAddress - startAddress); rom.SetSegment(segment, descriptor); //rom.levelScriptEntryOffset = rom.offset + 12; int segmentedAddress = rom.Read32(12); int levelscriptAddress = rom.GetROMAddress(segmentedAddress); rom.offset = levelscriptAddress - 0x10; // kostul for adding 0x10 }
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); }