public BMCParser(EndianBinaryReader reader) { colorList = new List<ByteColorAlpha>(); short numColors = reader.ReadInt16At(40); reader.BaseStream.Position += 44; //int numColors = Helpers.Read16(data, 40); for (int i = 0; i < numColors; i++) { ByteColorAlpha tempCol = new ByteColorAlpha(); tempCol.R = reader.ReadByte(); tempCol.G = reader.ReadByte(); tempCol.B = reader.ReadByte(); tempCol.A = reader.ReadByte(); colorList.Add(tempCol); } }
public BMG_New(EndianBinaryReader stream) { //Loads a BMG file from a file stream messageList = new List<Message>(); //There are two headers at the start of the BMG file. One is //the main file header, which begins with the string "MESGbmg1." //It contains the file size and two other variables with unknown //purposes. The other is the INF1 header, which begins with "INF1" //and contains the INF1's size, the number of messages, and the //size of the message entries. For TWW, the message entry size is 0x18. //We only need the number of message entries to parse the file, so we'll //pull that from INF1 and disregard everything else. windWakerCheck = (ushort)stream.ReadInt16At(0x2A); if (windWakerCheck != 0x18) { IsWindWaker = false; return; } numEntries = (ushort)stream.ReadInt16At(0x28); stream.BaseStream.Position = 0x30; for (int i = 0; i < numEntries; i++) { Message mes = new Message(stream); //There are many null entries in the file as it is. //This will filter them out. Why do they exist? //Nintendo. That's why. if (mes.charOffset == 0) { continue; } messageList.Add(mes); } dat1Size = (uint)stream.ReadInt32At((stream.BaseStream.Position + 0xC)); stream.BaseStream.Position += 0x11; uint charDataSize = 0; for (int j = 0; j < messageList.Count; j++) { if (j == (messageList.Count - 1)) { charDataSize = (uint)(dat1Size - messageList[j].charOffset); } else { charDataSize = (uint)(messageList[j + 1].charOffset - messageList[j].charOffset); } messageList[j].GetCharData(stream, charDataSize); } //ExportBMGFromPath(messageList); }