Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryControlBlock"/> class.
 /// </summary>
 /// <param name="memory">Emulated memory associated with the block.</param>
 /// <param name="segment">Segment of the memory control block to read.</param>
 public MemoryControlBlock(PhysicalMemory memory, ushort segment)
 {
     this.Segment    = segment;
     this.IsLast     = memory.GetByte(segment, 0) == 0x5A;
     this.PspSegment = memory.GetUInt16(segment, 1);
     this.Length     = memory.GetUInt16(segment, 3);
     this.ImageName  = memory.GetString(segment, 8, 8, 0);
 }
Пример #2
0
        public static byte ConvToConv(PhysicalMemory memory, uint sourceAddress, uint destAddress, int length)
        {
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }
            if (length == 0)
            {
                return(0);
            }

            if (sourceAddress + length > PhysicalMemory.ConvMemorySize || destAddress + length > PhysicalMemory.ConvMemorySize)
            {
                return(0xA2);
            }

            bool overlap = (sourceAddress + length - 1 >= destAddress || destAddress + length - 1 >= sourceAddress);
            bool reverse = overlap && sourceAddress > destAddress;

            if (!reverse)
            {
                for (uint offset = 0; offset < length; offset++)
                {
                    memory.SetByte(destAddress + offset, memory.GetByte(sourceAddress + offset));
                }
            }
            else
            {
                for (int offset = length - 1; offset >= 0; offset--)
                {
                    memory.SetByte(destAddress + (uint)offset, memory.GetByte(sourceAddress + (uint)offset));
                }
            }

            return(overlap ? (byte)0x92 : (byte)0);
        }
Пример #3
0
        public static byte ConvToEms(PhysicalMemory memory, uint sourceAddress, EmsHandle destHandle, int destPage, int destPageOffset, int length)
        {
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }
            if (length == 0)
            {
                return(0);
            }

            if (sourceAddress + length > PhysicalMemory.ConvMemorySize)
            {
                return(0xA2);
            }
            if (destPageOffset >= ExpandedMemoryManager.PageSize)
            {
                return(0x95);
            }

            int  offset      = destPageOffset;
            uint sourceCount = sourceAddress;
            int  pageIndex   = destPage;

            while (length > 0)
            {
                int    size   = Math.Min(length, ExpandedMemoryManager.PageSize - offset);
                byte[] target = destHandle.GetLogicalPage(pageIndex);
                if (target == null)
                {
                    return(0x8A);
                }

                for (int i = 0; i < size; i++)
                {
                    target[offset + i] = memory.GetByte(sourceCount++);
                }

                length -= size;
                pageIndex++;
                offset = 0;
            }

            return(0);
        }