示例#1
0
        /// <summary>
        /// Copies the current font from emulated memory into a buffer.
        /// </summary>
        /// <param name="memory">Current PhysicalMemory instance.</param>
        private void InitializeFont(PhysicalMemory memory)
        {
            uint offset;
            int  length;

            switch (this.FontHeight)
            {
            case 8:
                offset = PhysicalMemory.Font8x8Offset;
                length = 8 * 256;
                break;

            case 14:
                offset = PhysicalMemory.Font8x14Offset;
                length = 16 * 256;
                break;

            case 16:
                offset = PhysicalMemory.Font8x16Offset;
                length = 16 * 256;
                break;

            default:
                throw new InvalidOperationException("Unsupported font height.");
            }

            var ptr = memory.GetPointer(PhysicalMemory.FontSegment, offset);

            System.Runtime.InteropServices.Marshal.Copy(ptr, this.Font, 0, length);
        }