/// <summary> /// Initializes a new instance of the TextConsole class. /// </summary> /// <param name="video">Current VideoHandler instance.</param> /// <param name="bios">Current Bios instance.</param> public TextConsole(VideoHandler video, Bios bios) { unsafe { displayData = (ushort *)video.VideoRam.ToPointer(); } this.video = video; this.bios = bios; this.AnsiEnabled = true; Width = 80; Height = 25; ForegroundColor = 7; }
/// <summary> /// Performs any necessary initialization upon entering the video mode. /// </summary> /// <param name="video">The video device.</param> internal virtual void InitializeMode(VideoHandler video) { video.VirtualMachine.PhysicalMemory.Bios.CharacterPointHeight = (ushort)this.FontHeight; unsafe { byte *ptr = (byte *)VideoRam.ToPointer(); for (int i = 0; i < VideoHandler.TotalVramBytes; i++) { ptr[i] = 0; } } int stride; if (this.VideoModeType == VideoModeType.Text) { video.TextConsole.Width = this.Width; video.TextConsole.Height = this.Height; stride = this.Width * 2; } else { video.TextConsole.Width = this.Width / 8; video.TextConsole.Height = this.Height / this.FontHeight; if (this.BitsPerPixel < 8) { stride = this.Width / 8; } else { stride = this.Width; } } crtController.Overflow = (1 << 4); crtController.MaximumScanLine = (1 << 6); crtController.LineCompare = 0xFF; crtController.Offset = (byte)(stride / 2u); crtController.StartAddress = 0; video.Graphics.BitMask = 0xFF; }
/// <summary> /// Returns a pointer to video RAM for the display mode. /// </summary> /// <param name="video">Current VideoHandler instance.</param> /// <returns>Pointer to the mode's video RAM.</returns> internal virtual IntPtr GetVideoRamPointer(VideoHandler video) => video.VideoRam;
private protected VideoMode(int width, int height, int bpp, bool planar, int fontHeight, VideoModeType modeType, VideoHandler video) { this.Width = width; this.Height = height; this.OriginalHeight = height; this.BitsPerPixel = bpp; this.IsPlanar = planar; this.FontHeight = fontHeight; this.VideoModeType = modeType; this.dac = video.Dac; this.crtController = video.CrtController; this.attributeController = video.AttributeController; this.VideoRam = GetVideoRamPointer(video); InitializeFont(video.VirtualMachine.PhysicalMemory); }