public override void RenderPictureBuffer(PictureRectangle rect, bool picBuffRotate) { if (rect.X < 0 || rect.X > PictureResource.Width || rect.Y < 0 || rect.Y > PictureResource.Height || rect.Width < 0 || rect.Height < 0) { throw new ArgumentOutOfRangeException(nameof(rect)); } byte[] buffer; if (picBuffRotate) { buffer = this.PictureBuffer.Priority; } else { buffer = this.PictureBuffer.Visual; } for (int j = rect.Y; j > (rect.Y - rect.Height); j--) { for (int i = rect.X; i < (rect.X + rect.Width); i++) { byte color = (byte)(buffer[(PictureResource.Width * j) + i] & 0xf); this.RenderPixel(i, j, color); } } }
public override void RenderPictureBuffer(PictureRectangle rect, bool picBuffRotate) { if (rect.X < 0 || rect.X > PictureResource.Width || rect.Y < 0 || rect.Y > PictureResource.Height || rect.Width < 0 || rect.Height < 0) { throw new ArgumentOutOfRangeException(nameof(rect)); } byte[] buffer; if (picBuffRotate) { buffer = this.PictureBuffer.Priority; } else { buffer = this.PictureBuffer.Visual; } for (int j = rect.Y; j > (rect.Y - rect.Height); j--) { for (int i = rect.X; i < (rect.X + rect.Width); i++) { byte visual = buffer[(PictureResource.Width * j) + i]; byte pixel1 = (byte)((visual & 0xc) >> 2); byte pixel2 = (byte)(visual & 0x3); this.RenderBuffer.SetPixel(i * 2, j, pixel1); this.RenderBuffer.SetPixel((i * 2) + 1, j, pixel2); } } }
public void RenderPictureBuffer(PictureRectangle rect, bool picBuffRotate, bool fade) { if (!Clip(ref rect)) { this.renderDrivers[this.renderDriverIndex].RenderPictureBuffer(rect, picBuffRotate); this.Update(rect, fade); } }
public void RenderSolidRectangle(PictureRectangle rect, byte color) { if (!Clip(ref rect)) { this.renderDrivers[this.renderDriverIndex].RenderSolidRectangle(rect, color); this.Update(rect, false); } }
private void Update(PictureRectangle rect, bool fade) { int left = rect.X * 2 * this.RenderScaleX; int right = (rect.X + rect.Width) * 2 * this.RenderScaleX; int top = (rect.Y - rect.Height + 1) * this.RenderScaleY; int bottom = (rect.Y * this.RenderScaleY) + this.RenderScaleY; this.graphicsDriver.RenderToScreen(this.renderDrivers[this.renderDriverIndex].RenderBuffer, this.State.WindowRowMin * this.RenderFontHeight, new RenderPoint(left, top), new RenderPoint(right, bottom), fade); }
public void DisplayMessageBoxWindow(PictureRectangle rect, byte backgroundColor, byte lineColor) { // Draws the familiar white/red boxes in the picture buffer this.Interpreter.GraphicsRenderer.RenderSolidRectangle(new PictureRectangle(rect.X, rect.Y, rect.Width, rect.Height), backgroundColor); this.Interpreter.GraphicsRenderer.RenderSolidRectangle(new PictureRectangle(rect.X + 1, rect.Y - 1, rect.Width - 2, 1), lineColor); this.Interpreter.GraphicsRenderer.RenderSolidRectangle(new PictureRectangle(rect.X + rect.Width - 2, rect.Y - 2, 1, rect.Height - 4), lineColor); this.Interpreter.GraphicsRenderer.RenderSolidRectangle(new PictureRectangle(rect.X + 1, rect.Y - rect.Height + 2, rect.Width - 2, 1), lineColor); this.Interpreter.GraphicsRenderer.RenderSolidRectangle(new PictureRectangle(rect.X + 1, rect.Y - 2, 1, rect.Height - 4), lineColor); }
public override void RenderSolidRectangle(PictureRectangle rect, byte color) { if (rect.X < 0 || rect.X > PictureResource.Width || rect.Y < 0 || rect.Y > PictureResource.Height || rect.Width < 0 || rect.Height < 0) { throw new ArgumentOutOfRangeException(nameof(rect)); } for (int j = rect.Y; j > (rect.Y - rect.Height); j--) { for (int i = rect.X; i < (rect.X + rect.Width); i++) { this.RenderPixel(i, j, color); } } }
public override void RenderSolidRectangle(PictureRectangle rect, byte color) { if (rect.X < 0 || rect.X > PictureResource.Width || rect.Y < 0 || rect.Y > PictureResource.Height || rect.Width < 0 || rect.Height < 0) { throw new ArgumentOutOfRangeException(nameof(rect)); } DitheredColor dithered = this.DitherColor(color); if ((rect.Width & 1) != 0) { for (int j = rect.Y - rect.Height + 1; j <= rect.Y; j++) { int i = rect.X * 2; this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Odd & 0xc) >> 2)); this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Odd & 0x3)); for (int count = 0; count < ((rect.Width - 1) / 2); count++) { this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Even & 0xc) >> 2)); this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Even & 0x3)); this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Odd & 0xc) >> 2)); this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Odd & 0x3)); } } } else { for (int j = rect.Y - rect.Height + 1; j <= rect.Y; j++) { int i = rect.X * 2; for (int count = 0; count < (rect.Width / 2); count++) { this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Even & 0xc) >> 2)); this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Even & 0x3)); this.RenderBuffer.SetPixel(i++, j, (byte)((dithered.Odd & 0xc) >> 2)); this.RenderBuffer.SetPixel(i++, j, (byte)(dithered.Odd & 0x3)); } } } }
private static bool Clip(ref PictureRectangle rect) { int maxWidth = PictureResource.Width; int maxHeight = PictureResource.Height; // check if any of it is actually within window if (rect.X >= maxWidth || (rect.X + (rect.Width - 1)) < 0 || rect.Y < 0 || (rect.Y - (rect.Height - 1) >= maxHeight)) { return(true); } // top if ((rect.Y - rect.Height + 1) < 0) { rect.Height = rect.Y + 1; } // bottom if (rect.Y >= maxHeight) { rect.Height -= rect.Y - (maxHeight - 1); rect.Y = maxHeight - 1; } // left if (rect.X < 0) { rect.Width += rect.X; rect.X = 0; } // right if ((rect.X + rect.Width - 1) >= maxWidth) { rect.Width = maxWidth - rect.X; } return(false); }