public byte[] GetBytes(bool jp) { List <byte> result = new List <byte>(); result.AddRange(jp ? Properties.Resources.garden_jp : Properties.Resources.garden_us); result.AddRange(BitConverter.GetBytes(0x8B7CA670A3B9AD8C)); result.AddRange(BitConverter.GetBytes((uint)0)); // Names for (int i = 0; i < 3; i++) { result.AddRange(VMS_Chao.GetChaoNameBytes(PearlCourseNames[i])); } for (int i = 0; i < 3; i++) { result.AddRange(VMS_Chao.GetChaoNameBytes(AmethystCourseNames[i])); } for (int i = 0; i < 3; i++) { result.AddRange(VMS_Chao.GetChaoNameBytes(SapphireCourseNames[i])); } for (int i = 0; i < 3; i++) { result.AddRange(VMS_Chao.GetChaoNameBytes(RubyCourseNames[i])); } for (int i = 0; i < 3; i++) { result.AddRange(VMS_Chao.GetChaoNameBytes(EmeraldCourseNames[i])); } // Time for (int i = 0; i < 9; i++) { result.Add(PearlCourseTimes[i]); } for (int i = 0; i < 9; i++) { result.Add(AmethystCourseTimes[i]); } for (int i = 0; i < 9; i++) { result.Add(SapphireCourseTimes[i]); } for (int i = 0; i < 9; i++) { result.Add(RubyCourseTimes[i]); } for (int i = 0; i < 9; i++) { result.Add(EmeraldCourseTimes[i]); } // Unknown data result.AddRange(UnknownBytes731x77F); result.Add(UnknownFlag0); result.Add(UnknownFlag1); result.Add(UnknownFlag2); result.Add(UnknownFlag3); result.Add(UnknownFlag4); result.Add(UnknownFlag5); result.Add(UnknownFlag6); result.Add(UnknownFlag7); result.Add(UnknownFlag8); result.AddRange(UnknownBytes789x7FF); // Chao for (int c = 0; c < 24; c++) { if (GardenChao.Count - 1 > c) { result.AddRange(GardenChao[c].GetBytes()); } else { result.AddRange(new VMS_Chao().GetBytes()); } } return(result.ToArray()); }
public VMS_ChaoGardenSave(byte[] file) { GardenChao = new List <VMS_Chao>(); PearlCourseNames = new string[3]; AmethystCourseNames = new string[3]; SapphireCourseNames = new string[3]; RubyCourseNames = new string[3]; EmeraldCourseNames = new string[3]; PearlCourseTimes = new byte[9]; AmethystCourseTimes = new byte[9]; SapphireCourseTimes = new byte[9]; RubyCourseTimes = new byte[9]; EmeraldCourseTimes = new byte[9]; UnknownBytes731x77F = new byte[79]; UnknownBytes789x7FF = new byte[119]; Array.Copy(file, 0x731, UnknownBytes731x77F, 0, 79); Array.Copy(file, 0x789, UnknownBytes789x7FF, 0, 119); StringBuilder sb = new StringBuilder(); // Check if the header is weird ulong headerid = BitConverter.ToUInt64(file, 0x680); if (headerid != 0x8B7CA670A3B9AD8C && headerid != 0) { System.Windows.Forms.MessageBox.Show("Default data ID is different: " + headerid.ToString("X"), "Chao Editor Message", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } // Check if any unknown data is set for (int i = 0; i < 79; i++) { if (UnknownBytes731x77F[i] != 0) { sb.Append("0x" + (0x731 + i).ToString("X") + " is " + UnknownBytes731x77F[i].ToString("X") + System.Environment.NewLine); } } for (int i = 0; i < 119; i++) { if (UnknownBytes789x7FF[i] != 0) { sb.Append("0x" + (0x731 + i).ToString("X") + " is " + UnknownBytes789x7FF[i].ToString("X") + System.Environment.NewLine); } } if (sb.Length > 0) { System.Windows.Forms.MessageBox.Show("Unknown data detected:\n" + sb.ToString(), "Chao Editor Message", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } // Names for (int i = 0; i < 3; i++) { PearlCourseNames[i] = VMS_Chao.ReadChaoName(file, 0x68C + i * 8); AmethystCourseNames[i] = VMS_Chao.ReadChaoName(file, 0x6A4 + i * 8); SapphireCourseNames[i] = VMS_Chao.ReadChaoName(file, 0x6BC + i * 8); RubyCourseNames[i] = VMS_Chao.ReadChaoName(file, 0x6D4 + i * 8); EmeraldCourseNames[i] = VMS_Chao.ReadChaoName(file, 0x6EC + i * 8); } // Time for (int t = 0; t < 9; t++) { PearlCourseTimes[t] = file[0x704 + t]; AmethystCourseTimes[t] = file[0x70D + t]; SapphireCourseTimes[t] = file[0x716 + t]; RubyCourseTimes[t] = file[0x71F + t]; EmeraldCourseTimes[t] = file[0x728 + t]; } // Flags UnknownFlag0 = file[0x780]; UnknownFlag1 = file[0x781]; UnknownFlag2 = file[0x782]; UnknownFlag3 = file[0x783]; UnknownFlag4 = file[0x784]; UnknownFlag5 = file[0x785]; UnknownFlag6 = file[0x786]; UnknownFlag7 = file[0x787]; UnknownFlag8 = file[0x788]; // Chao for (int c = 0; c < 24; c++) { GardenChao.Add(new VMS_Chao(file, 0x800 + c * 512)); } }