Example #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public Exporter(DisasmProject project, LineListGen codeLineList, Formatter formatter,
                        ActiveColumnFlags leftFlags, int[] rightWidths)
        {
            mProject      = project;
            mCodeLineList = codeLineList;
            mFormatter    = formatter;
            mLeftFlags    = leftFlags;

            ConfigureColumns(leftFlags, rightWidths);
        }
Example #2
0
        /// <summary>
        /// Generates description of some parameters that we only have during construction.
        /// </summary>
        private static string GenerateParameterStringBase(ActiveColumnFlags leftFlags,
                                                          int[] rightWidths)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("cols=");
            for (int i = 0; i < rightWidths.Length; i++)
            {
                if (i != 0)
                {
                    sb.Append(',');
                }
                sb.Append(rightWidths[i]);
            }

            sb.Append(";extraCols=");
            bool first = true;

            foreach (ActiveColumnFlags flag in Enum.GetValues(typeof(ActiveColumnFlags)))
            {
                if (flag == ActiveColumnFlags.ALL)
                {
                    continue;
                }
                if ((leftFlags & flag) != 0)
                {
                    if (!first)
                    {
                        sb.Append(',');
                    }
                    sb.Append(flag);
                    first = false;
                }
            }

            return(sb.ToString());
        }
Example #3
0
        private void ConfigureColumns(ActiveColumnFlags leftFlags, int[] rightWidths)
        {
            mColStart = new int[(int)Col.COUNT];
            int total = 0;
            int width;

            // mColStart[(int)Col.Offset] = 0

            // offset "+123456"
            if ((leftFlags & ActiveColumnFlags.Offset) != 0)
            {
                total = mColStart[(int)Col.Offset + 1] = total + 7 + 1;
            }
            else
            {
                mColStart[(int)Col.Offset + 1] = total;
            }

            // address "1234:" or "12/4567:"
            if ((leftFlags & ActiveColumnFlags.Address) != 0)
            {
                width = mProject.CpuDef.HasAddr16 ? 5 : 8;
                total = mColStart[(int)Col.Address + 1] = total + width + 1;
            }
            else
            {
                mColStart[(int)Col.Address + 1] = total;
            }

            // bytes "12345678+" or "12 45 78 01+"
            if ((leftFlags & ActiveColumnFlags.Bytes) != 0)
            {
                // A limit of 8 gets us 4 bytes from dense display ("20edfd60") and 3 if spaces
                // are included ("20 ed fd") with no excess.  We want to increase it to 11 so
                // we can always show 4 bytes.  Add one for a trailing "+".
                width = mFormatter.Config.mSpacesBetweenBytes ? 12 : 9;
                total = mColStart[(int)Col.Bytes + 1] = total + width + 1;
            }
            else
            {
                mColStart[(int)Col.Bytes + 1] = total;
            }

            // flags "NVMXDIZC" or "NVMXDIZC E"
            if ((leftFlags & ActiveColumnFlags.Flags) != 0)
            {
                width = mProject.CpuDef.HasEmuFlag ? 10 : 8;
                total = mColStart[(int)Col.Flags + 1] = total + width + 1;
            }
            else
            {
                mColStart[(int)Col.Flags + 1] = total;
            }

            // attributes "@H!#>"
            if ((leftFlags & ActiveColumnFlags.Attr) != 0)
            {
                total = mColStart[(int)Col.Attr + 1] = total + 5 + 1;
            }
            else
            {
                mColStart[(int)Col.Attr + 1] = total;
            }

            total = mColStart[(int)Col.Label + 1] = total + rightWidths[0];
            total = mColStart[(int)Col.Opcode + 1] = total + rightWidths[1];
            total = mColStart[(int)Col.Operand + 1] = total + rightWidths[2];
            //total = mColStart[(int)Col.Comment + 1] = total + rightWidths[3];

            //Debug.WriteLine("Export col starts:");
            //for (int i = 0; i < (int)Col.COUNT; i++) {
            //    Debug.WriteLine("  " + i + "(" + ((Col)i) + ") " + mColStart[i]);
            //}
        }