public static int GetLineByteLength(this ILogCreatorDataSource data, int offset, int romSizeMax, int countPerLine) { var flagType = data.GetFlag(offset); if (flagType == FlagType.Opcode) { return(data.GetInstructionLength(offset)); } GetLineByteLengthMaxAndStep(flagType, out var max, out var step, countPerLine); var bankSize = data.GetBankSize(); var myBank = offset / bankSize; var min = step; while ( min < max && offset + min < romSizeMax && data.GetFlag(offset + min) == flagType && data.Labels.GetLabelName(data.ConvertPCtoSnes(offset + min)) == "" && (offset + min) / bankSize == myBank ) { min += step; } return(min); }
public static string GetFormattedText(this ILogCreatorDataSource data, int offset, int bytes) { var text = "db \""; for (var i = 0; i < bytes; i++) { text += (char)data.GetRomByte(offset + i); } return(text + "\""); }
public static string GetFormattedBytes(this ILogCreatorDataSource data, int offset, int step, int bytes) { var res = step switch { 1 => "db ", 2 => "dw ", 3 => "dl ", 4 => "dd ", _ => "" }; for (var i = 0; i < bytes; i += step) { if (i > 0) { res += ","; } switch (step) { case 1: res += Util.NumberToBaseString(data.GetRomByteUnsafe(offset + i), Util.NumberBase.Hexadecimal, 2, true); break; case 2: res += Util.NumberToBaseString(data.GetRomWordUnsafe(offset + i), Util.NumberBase.Hexadecimal, 4, true); break; case 3: res += Util.NumberToBaseString(data.GetRomLongUnsafe(offset + i), Util.NumberBase.Hexadecimal, 6, true); break; case 4: res += Util.NumberToBaseString(data.GetRomDoubleWordUnsafe(offset + i), Util.NumberBase.Hexadecimal, 8, true); break; } } return(res); } }
public static string GeneratePointerStr(this ILogCreatorDataSource data, int offset, int bytes) { var ia = -1; string format = "", param = ""; switch (bytes) { case 2: ia = (data.GetDataBank(offset) << 16) | data.GetRomWordUnsafe(offset); format = "dw {0}"; param = Util.NumberToBaseString(data.GetRomWordUnsafe(offset), Util.NumberBase.Hexadecimal, 4, true); break; case 3: ia = data.GetRomLongUnsafe(offset); format = "dl {0}"; param = Util.NumberToBaseString(data.GetRomLongUnsafe(offset), Util.NumberBase.Hexadecimal, 6, true); break; case 4: ia = data.GetRomLongUnsafe(offset); format = "dl {0}" + $" : db {Util.NumberToBaseString(data.GetRomByteUnsafe(offset + 3), Util.NumberBase.Hexadecimal, 2, true)}"; param = Util.NumberToBaseString(data.GetRomLongUnsafe(offset), Util.NumberBase.Hexadecimal, 6, true); break; } if (data.ConvertSnesToPc(ia) >= 0) { var labelName = data.Labels.GetLabelName(ia); if (labelName != "") { param = labelName; } } return(string.Format(format, param)); }