public void PrintChar(SpeccyFontChar Char, SpeccyColor ForeColor, SpeccyColor BackColor, int X, int Y, SpeccyMode Mode) { if (X > width || Y > height) { return; } int baseY = Y * 8; var map = Char.Data; int row = 0; switch (Mode) { case SpeccyMode.AND: for (int y = baseY; y < baseY + 8; y++) { pixels[X, y] &= map[row++]; } break; case SpeccyMode.OR: for (int y = baseY; y < baseY + 8; y++) { pixels[X, y] |= map[row++]; } break; case SpeccyMode.XOR: for (int y = baseY; y < baseY + 8; y++) { pixels[X, y] ^= map[row++]; } break; default: for (int y = baseY; y < baseY + 8; y++) { pixels[X, y] = map[row++]; } break; } attributes[X, Y, 0] = BackColor; attributes[X, Y, 1] = ForeColor; }
public SpeccyFont(Font BaseFont) { if (BaseFont != null) { FillFromSystemFont(BaseFont); } else { for (int buc = 0; buc < 256; buc++) { chars[buc] = new SpeccyFontChar(); } } }
public void FillFromSystemFont(Font SystemFont) { Bitmap bmp = new Bitmap(8, 8); Graphics g = Graphics.FromImage(bmp); g.PageUnit = GraphicsUnit.Pixel; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; for (int buc = 0; buc < 256; buc++) { g.Clear(Color.Black); g.DrawString(new string((char)buc, 1), SystemFont, Brushes.White, new RectangleF(0, 0, 8, 8), StringFormat.GenericTypographic); g.Flush(); List <string> lines = new List <string>(); for (int y = 0; y < 8; y++) { string line = ""; for (int x = 0; x < 8; x++) { var value = bmp.GetPixel(x, y); if (value.ToArgb() != Color.Black.ToArgb()) { line += "@"; } else { line += " "; } } lines.Add(line); } chars[buc] = new SpeccyFontChar(lines.ToArray()); } g.Dispose(); bmp.Dispose(); }
public void PrintChar(SpeccyFontChar Char, int X, int Y, SpeccyMode Mode, int XShift, int YShift, bool ExpandAttributes) { if (X > width || Y > height) { return; } int baseY = Y * 8 + YShift; int maxY = Math.Min(height * 8, baseY + 8); var map = Char.Data; int row = 0; bool xFits = X + 1 < width || XShift == 0; bool yFits = Y < height - 1 || YShift == 0; switch (Mode) { case SpeccyMode.AND: if (XShift != 0) { if (xFits) { for (int y = baseY; y < maxY; y++) { pixels[X, y] &= (byte)(map[row] >> XShift); pixels[X + 1, y] &= (byte)(map[row++] << 8 - XShift); } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] &= (byte)(map[row++] >> XShift); } } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] &= map[row++]; } } break; case SpeccyMode.OR: if (XShift != 0) { if (xFits) { for (int y = baseY; y < maxY; y++) { pixels[X, y] |= (byte)(map[row] >> XShift); pixels[X + 1, y] |= (byte)(map[row++] << 8 - XShift); } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] |= (byte)(map[row++] >> XShift); } } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] |= map[row++]; } } break; case SpeccyMode.XOR: if (XShift != 0) { if (xFits) { for (int y = baseY; y < maxY; y++) { pixels[X, y] ^= (byte)(map[row] >> XShift); pixels[X + 1, y] ^= (byte)(map[row++] << 8 - XShift); } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] ^= (byte)(map[row++] >> XShift); } } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] ^= map[row++]; } } break; default: if (XShift != 0) { if (xFits) { for (int y = baseY; y < maxY; y++) { pixels[X, y] = (byte)(map[row] >> XShift); pixels[X + 1, y] = (byte)(map[row++] << 8 - XShift); } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] = (byte)(map[row++] >> XShift); } } } else { for (int y = baseY; y < maxY; y++) { pixels[X, y] = map[row++]; } } break; } }
public void SetChar(char Which, byte[] Data) { chars[(int)Which] = new SpeccyFontChar(Data); }