public static void GetMaps() { for (int i = 0; i < RomData.SceneList.Count; i++) { int f = RomData.SceneList[i].File; RomUtils.CheckCompressed(f); int j = 0; while (true) { byte cmd = RomData.MMFileList[f].Data[j]; if (cmd == 0x04) { byte mapcount = RomData.MMFileList[f].Data[j + 1]; int mapsaddr = (int)ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, j + 4) & 0xFFFFFF; for (int k = 0; k < mapcount; k++) { Map m = new Map(); m.File = RomUtils.AddrToFile((int)ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, mapsaddr)); RomData.SceneList[i].Maps.Add(m); mapsaddr += 8; } break; } if (cmd == 0x14) { break; } j += 8; } } }
public static void GetActors() { for (int i = 0; i < RomData.SceneList.Count; i++) { for (int j = 0; j < RomData.SceneList[i].Maps.Count; j++) { int f = RomData.SceneList[i].Maps[j].File; RomUtils.CheckCompressed(f); int k = RomData.SceneList[i].Maps[j].Header; while (true) { byte cmd = RomData.MMFileList[f].Data[k]; if (cmd == 0x01) { byte ActorCount = RomData.MMFileList[f].Data[k + 1]; int ActorAddr = (int)ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, k + 4) & 0xFFFFFF; RomData.SceneList[i].Maps[j].ActorAddr = ActorAddr; RomData.SceneList[i].Maps[j].Actors = ReadMapActors(RomData.MMFileList[f].Data, ActorAddr, ActorCount); } if (cmd == 0x0B) { byte ObjectCount = RomData.MMFileList[f].Data[k + 1]; int ObjectAddr = (int)ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, k + 4) & 0xFFFFFF; RomData.SceneList[i].Maps[j].ObjAddr = ObjectAddr; RomData.SceneList[i].Maps[j].Objects = ReadMapObjects(RomData.MMFileList[f].Data, ObjectAddr, ObjectCount); } if (cmd == 0x14) { break; } k += 8; } } } }
public static void GetMapHeaders() { for (int i = 0; i < RomData.SceneList.Count; i++) { int maps = RomData.SceneList[i].Maps.Count; for (int j = 0; j < maps; j++) { int f = RomData.SceneList[i].Maps[j].File; RomUtils.CheckCompressed(f); int k = 0; int setupsaddr = -1; int nextlowest = -1; while (true) { byte cmd = RomData.MMFileList[f].Data[k]; if (cmd == 0x18) { setupsaddr = (int)ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, k + 4) & 0xFFFFFF; } else if (cmd == 0x14) { break; } else { if (RomData.MMFileList[f].Data[k + 4] == 0x03) { int p = (int)ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, k + 4) & 0xFFFFFF; if (((p < nextlowest) || (nextlowest == -1)) && ((p > setupsaddr) && (setupsaddr != -1))) { nextlowest = p; } } } k += 8; } if ((setupsaddr == -1) || (nextlowest == -1)) { continue; } for (k = setupsaddr; k < nextlowest; k += 4) { byte s = RomData.MMFileList[f].Data[k]; if (s != 0x03) { break; } int p = (int)ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[f].Data, k) & 0xFFFFFF; Map m = new Map(); m.File = f; m.Header = p; RomData.SceneList[i].Maps.Add(m); } } } }
public static byte[] GetObjectData(int objectIndex) { var objectTableFileIndex = RomUtils.GetFileIndexForWriting(Addresses.ObjTable); var baseAddress = Addresses.ObjTable - RomData.MMFileList[objectTableFileIndex].Addr; var objectAddress = ReadWriteUtils.Arr_ReadU32(RomData.MMFileList[objectTableFileIndex].Data, baseAddress + (objectIndex * 8)); var objectFileIndex = RomData.MMFileList.FindIndex(f => f.Addr == objectAddress); if (objectFileIndex == -1) { return(null); } RomUtils.CheckCompressed(objectFileIndex); return(RomData.MMFileList[objectFileIndex].Data); }