コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
    }