private string GetStringSJIS(uint offset) { using (var text = new ImprovedBinaryReader(new MemoryStream(t4_data.ToArray()))) { text.BaseStream.Position = offset; var str = text.ReadCStringSJIS(); return(str); } }
public List <string> dumpStrings() { var strings = new List <string>(); using (var reader = new ImprovedBinaryReader(new MemoryStream(t4_data.ToArray()))) { while (reader.BaseStream.Position < reader.BaseStream.Length) { using (var text = new ImprovedBinaryReader(reader.BaseStream, true)) { text.BaseStream.Position = reader.BaseStream.Position; var str = text.ReadCStringSJIS(); strings.Add(str); Console.Out.WriteLine(reader.BaseStream.Position); reader.BaseStream.Position = text.BaseStream.Position; } } } return(strings); }
public List <string> GetDebugData() { var debug = new List <string>(); var debug_2 = new List <string>(); var debug_3 = new List <string>(); debug.Add("T0"); foreach (var item in t0_list) { debug.Add( $"nameOffset: {item.nameOffset:X8}, nameCRC32: {item.nameCRC32:X8}, T1From: {item.T1From:X4}, T1Count: {item.T1Count:X4}, T2From: {item.T2From:X4}, T2To: {item.T2To:X4}, Unk5: {item.Unk5:X8}, Unk6: {item.Unk6:X8}"); } debug.Add("T1"); foreach (var item in t1_list) { debug.Add( $"nameOffset: {item.nameOffset:X8}, nameCRC32: {item.nameCRC32:X8}, T2Entry: {item.T2EntryId:X8}"); } debug.Add("T2"); var cur = 0; foreach (var item in t2_list) { debug.Add( $"ID: {cur++:X}, T3Off: {item.T3EntryId:X}, ArgCount: {item.T3ArgCount:X}, Unk1: {item.Unk1:X}, FuncId: {item.FuncId:X}, Unk3: {item.Unk3:X}"); } debug.Add("T3"); cur = 0; foreach (var item in t3_list) { debug.Add( $"ID: {cur++:X}, Cmd: {item.Cmd:X}, Val: {item.Value:X}"); } using (var reader = new ImprovedBinaryReader(new MemoryStream(t4_data.ToArray()))) { // print names in table 0 debug.Add("T0 Names"); foreach (var entry in t0_list) { using (var text = new ImprovedBinaryReader(reader.BaseStream, true)) { text.BaseStream.Position = entry.nameOffset; var str = text.ReadCStringSJIS(); debug.Add("Name: " + str); } } // print names in table 1 debug.Add("T1 Names"); foreach (var entry in t1_list) { using (var text = new ImprovedBinaryReader(reader.BaseStream, true)) { text.BaseStream.Position = entry.nameOffset; var str = text.ReadCStringSJIS(); debug.Add("Name: " + str); } } // parse commands in table 2 debug.Add("Commands"); var cnt = 0; foreach (var t2Entry in t2_list) { //if (t2Entry.FuncId != 0x1B59) // continue; debug.Add($"[{cnt++}] New Command: {t2Entry.FuncId:X}"); for (var i = 0; i < t2Entry.T3ArgCount; ++i) { var cmdArgEntry = t3_list[t2Entry.T3EntryId + i]; if (t2Entry.FuncId == 0x14 && i == 0) { string opcode; opcode = XqOpcodes.OpCodes.TryGetValue((uint)cmdArgEntry.Value, out opcode) ? opcode : "N/A"; /* * if (opcode != "Event3DCharaInit" && opcode != "EvenCrtBuildChara" && * opcode != "Event3DCharaPlace_Crt") * break; * else * { * var chara = t3_list[t2Entry.T3EntryId + 1]; * using (var text = new ImprovedBinaryReader(reader.BaseStream, true)) * { * text.BaseStream.Position = chara.Value; * var str = text.ReadCStringSJIS(); * * debug_2.Add($"opcode: {opcode}, string: {str}"); * } * }*/// todo comment was here debug.Add($"ArgCmd: {cmdArgEntry.Cmd:X}, ArgValue: {cmdArgEntry.Value:X} [{opcode}]"); } else if (cmdArgEntry.Cmd == 0x18) { using (var text = new ImprovedBinaryReader(reader.BaseStream, true)) { text.BaseStream.Position = cmdArgEntry.Value; var str = text.ReadCStringSJIS(); debug.Add( $"ArgCmd: {cmdArgEntry.Cmd:X}, StrOffset: {cmdArgEntry.Value:X}, ArgString: {str}"); } } else { debug.Add($"ArgCmd: {cmdArgEntry.Cmd:X}, ArgValue: {cmdArgEntry.Value:X}"); } } } } // print emotes var curStr = ""; foreach (var t2Entry in t2_list) { if (t2Entry.FuncId != 0x1B59 && t2Entry.FuncId != 0x14) { continue; } for (var i = 0; i < t2Entry.T3ArgCount; ++i) { var cmdArgEntry = t3_list[t2Entry.T3EntryId + i]; if (t2Entry.FuncId == 0x14) { if (i == 0) { { string opcode; opcode = XqOpcodes.OpCodes.TryGetValue((uint)cmdArgEntry.Value, out opcode) ? opcode : "N/A"; if (opcode != "EventSetMtnByMtnSet") { break; } } } else if (i == 1) { debug_3.Add($"{GetStringSJIS(cmdArgEntry.Value)}"); } else if (i == 2) { debug_3.Add($"{GetStringSJIS(cmdArgEntry.Value)}"); } } else if (t2Entry.FuncId == 0x1B59) { if (i % 2 == 0) { curStr = GetStringSJIS(cmdArgEntry.Value); } else if (i % 2 == 1) { if (cmdArgEntry.Cmd != 0x18) { continue; } debug_3.Add($"{curStr}"); debug_3.Add($"{GetStringSJIS(cmdArgEntry.Value)}"); } } } } /* * // print bytes in last table * var hex = new StringBuilder(); * foreach (var b in t4_data) hex.AppendFormat("{0:X2} ", b); * debug.Add(hex.ToString()); */ return(debug); }