Ejemplo n.º 1
0
        /// <summary>
        /// Loads the program from file image
        /// </summary>
        /// <param name="file"></param>
        public void Load(byte[] file)
        {
            StartPtr = Convert.ToUInt16(file[0] + 256 * file[1]);
            for (int j = 1; j < file.Length;)
            {
                // gets pointer to next line: if 0 exit
                UInt16 ptr = Convert.ToUInt16(file[++j] + 256 * file[++j]);
                if (0 == ptr)
                {
                    break;
                }

                // gets line number
                UInt16 linenum = Convert.ToUInt16(file[++j] + 256 * file[++j]);

                // scan for EOL
                int start = j + 1;
                while (file[++j] != 0)
                {
                }
                byte[] data = new byte[j - start];
                Array.Copy(file, start, data, 0, j - start);
                BasicRow row = new BasicRow(ptr, linenum, data);
                Lines.Add(row);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a new row of code (or replaces existing)
        /// </summary>
        /// <param name="LineNum"></param>
        /// <param name="rawdata"></param>
        public void AddLine(UInt16 LineNum, byte[] rawdata)
        {
            BasicRow r = GetLine(LineNum);

            if (r != null)
            {
                Lines.Remove(r);
            }

            r = new BasicRow(0, LineNum, rawdata);
            Lines.Add(r);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deletes line by number
        /// </summary>
        /// <param name="LineNum"></param>
        /// <returns>true if line deleted, false if not found</returns>
        public bool DeleteLine(UInt16 LineNum)
        {
            BasicRow r = GetLine(LineNum);

            if (r != null)
            {
                Lines.Remove(r);
                return(true);
            }
            else
            {
                return(false);
            }
        }