public Importer(string tableFileName, string messageDataFileName, Dictionary <ControlCode, string> controlCodeDict) { m_messageList = new ObservableCollection <Message>(); List <TableRecord> tableRecordList = new List <TableRecord>(); //Read in message table records using (FileStream stream = new FileStream(tableFileName, FileMode.Open)) { EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); while (reader.PeekReadInt16() != -1) { TableRecord mesRecord = new TableRecord(reader); tableRecordList.Add(mesRecord); } } //Read in message data using (FileStream stream = new FileStream(messageDataFileName, FileMode.Open)) { EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); foreach (var mesgRecord in tableRecordList) { reader.BaseStream.Position = mesgRecord.Offset; Message mes = new Message(reader, mesgRecord, controlCodeDict); m_messageList.Add(mes); } } }
public Importer(string fileName, Dictionary <ControlCode, string> controlCodeDict, bool ZZRP, bool Debug) { List <TableRecord> tableRecordList = new List <TableRecord>(); string zzrpFolder = ""; string codeFilePath = ""; string msgDataPath = ""; if (ZZRP) { zzrpFolder = Path.GetDirectoryName(fileName); codeFilePath = Path.Combine(zzrpFolder, "system", "code"); msgDataPath = Path.Combine(zzrpFolder, "misc", "nes_message_data_static"); } long offset = ZZRP ? 0x0012E4C0 : Debug ? 0x00BC24C0 : 0x00B849EC; long msgOffset = ZZRP ? 0 : Debug ? 0x8C6000 : 0x92D000; try { using (FileStream stream = new FileStream(ZZRP ? codeFilePath : fileName, FileMode.Open, FileAccess.Read)) { m_inputFile = new MemoryStream(); stream.CopyTo(m_inputFile); EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); reader.BaseStream.Seek(offset, 0); //Read in message table records while (reader.PeekReadInt16() != -1) { TableRecord mesRecord = new TableRecord(reader); tableRecordList.Add(mesRecord); } } using (FileStream stream = new FileStream(ZZRP ? msgDataPath : fileName, FileMode.Open, FileAccess.Read)) { m_messageList = new ObservableCollection <Message>(); EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); foreach (var mesgRecord in tableRecordList) { reader.BaseStream.Position = msgOffset + mesgRecord.Offset; Message mes = new Message(reader, mesgRecord, controlCodeDict); m_messageList.Add(mes); } } } catch (IOException ex) { MessageBox.Show(ex.Message); return; } catch (Exception) { MessageBox.Show("Failed loading messages. Note: ROMs built by zzromtool are not supported directly!"); return; } }
public Message(EndianBinaryReader reader, TableRecord mesgTableRecord, Dictionary <ControlCode, string> controlCodeDict) { MessageID = mesgTableRecord.MessageID; BoxType = mesgTableRecord.BoxType; BoxPosition = mesgTableRecord.BoxPosition; GetStringData(reader, controlCodeDict); }
public Importer(string fileName, Dictionary <ControlCode, string> controlCodeDict) { List <TableRecord> tableRecordList = new List <TableRecord>(); try { using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { m_messageList = new ObservableCollection <Message>(); m_inputFile = new MemoryStream(); stream.CopyTo(m_inputFile); EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); reader.BaseStream.Seek(0x00BC24C0, 0); //Read in message table records while (reader.PeekReadInt16() != -1) { TableRecord mesRecord = new TableRecord(reader); tableRecordList.Add(mesRecord); } foreach (var mesgRecord in tableRecordList) { reader.BaseStream.Position = 0x8C6000 + mesgRecord.Offset; Message mes = new Message(reader, mesgRecord, controlCodeDict); m_messageList.Add(mes); } } } catch (IOException ex) { MessageBox.Show("The chosen ROM is open in another program. Please close that program and open the ROM again.", "ROM is Already In Use"); return; } }
public Importer(string fileName, Dictionary <ControlCode, string> controlCodeDict, EditMode Mode, bool Debug) { List <TableRecord> tableRecordList = new List <TableRecord>(); TableRecord f**k = null; if (Mode == EditMode.ZZRPL) { try { string zzrplFolder = Path.GetDirectoryName(fileName); string msgData = Path.Combine(zzrplFolder, "messages", "StringData.bin"); string table = Path.Combine(zzrplFolder, "messages", "MessageTable.tbl"); using (FileStream stream = new FileStream(table, FileMode.Open, FileAccess.Read)) { m_inputFile = new MemoryStream(); stream.CopyTo(m_inputFile); EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); reader.BaseStream.Seek(0, 0); //Read in message table records while (reader.BaseStream.Position != reader.BaseStream.Length && reader.PeekReadInt16() != -1) { TableRecord mesRecord = new TableRecord(reader); tableRecordList.Add(mesRecord); } } using (FileStream stream = new FileStream(msgData, FileMode.Open, FileAccess.Read)) { m_messageList = new ObservableCollection <Message>(); EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); foreach (var mesgRecord in tableRecordList) { f**k = mesgRecord; if (mesgRecord.Offset >= reader.BaseStream.Length) { continue; } reader.BaseStream.Position = mesgRecord.Offset; Message mes = new Message(reader, mesgRecord, controlCodeDict); m_messageList.Add(mes); } } } catch (IOException ex) { MessageBox.Show(ex.Message + " " + f**k.MessageID); return; } catch (Exception) { MessageBox.Show("Failed loading messages."); return; } } else { long offset = Mode == EditMode.ZZRT ? 0x0012E4C0 : Debug ? 0x00BC24C0 : 0x00B849EC; long msgOffset = Mode == EditMode.ZZRT ? 0 : Debug ? 0x8C6000 : 0x92D000; string zzrpFolder = Path.GetDirectoryName(fileName); string codeFilePath = Path.Combine(zzrpFolder, "system", "code"); string msgDataPath = Path.Combine(zzrpFolder, "misc", "nes_message_data_static"); try { using (FileStream stream = new FileStream(Mode == EditMode.ZZRT ? codeFilePath : fileName, FileMode.Open, FileAccess.Read)) { m_inputFile = new MemoryStream(); stream.CopyTo(m_inputFile); EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); reader.BaseStream.Seek(offset, 0); //Read in message table records while (reader.PeekReadInt16() != -1) { TableRecord mesRecord = new TableRecord(reader); tableRecordList.Add(mesRecord); } } using (FileStream stream = new FileStream(Mode == EditMode.ZZRT ? msgDataPath : fileName, FileMode.Open, FileAccess.Read)) { m_messageList = new ObservableCollection <Message>(); EndianBinaryReader reader = new EndianBinaryReader(stream, Endian.Big); foreach (var mesgRecord in tableRecordList) { reader.BaseStream.Position = msgOffset + mesgRecord.Offset; Message mes = new Message(reader, mesgRecord, controlCodeDict); m_messageList.Add(mes); } } } catch (IOException ex) { MessageBox.Show(ex.Message); return; } catch (Exception) { MessageBox.Show("Failed loading messages. Note: ROMs built by zzromtool are not supported directly!"); return; } } }