//вывод тайла void ShowTile(int x, int y) { Graphics g = Graphics.FromImage(Img); for (int j = y * 16; j < y * 16 + 16; j++) { for (int i = x * 16; i < x * 16 + 16; i++) { int bright = (AttrLayer[i / 8, j / 8] >> 3) & 0x08; Color ink = ZX.GetColor((AttrLayer[i / 8, j / 8] & 0x07) + bright); Color paper = ZX.GetColor(((AttrLayer[i / 8, j / 8] >> 3) & 0x07) + bright); Color c = PixelLayer[i, j] == 0 ? paper : ink; Brush b = new SolidBrush(c); g.FillRectangle(b, i * PixSize, j * PixSize, PixSize, PixSize); } } if (ShowGrid.Checked) { Pen p = new Pen(Color.Gray); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash; g.DrawLine(p, x * 16 * PixSize, y * 16 * PixSize, x * 16 * PixSize, (y + 1) * 16 * PixSize); g.DrawLine(p, x * 16 * PixSize, y * 16 * PixSize, (x + 1) * 16 * PixSize, y * 16 * PixSize); p = new Pen(Color.LightGray); p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; g.DrawLine(p, (x * 16 + 8) * PixSize, y * 16 * PixSize, (x * 16 + 8) * PixSize, (y + 1) * 16 * PixSize); g.DrawLine(p, x * 16 * PixSize, (y * 16 + 8) * PixSize, (x + 1) * 16 * PixSize, (y * 16 + 8) * PixSize); } }
//прорисовка спрайта 8x8 public void DrawChar(Graphics g, int x, int y, byte[] ch, int master_attr) { if (ch[0] == 0) { return; } Brush ColorInk; Brush ColorPaper; Brush ColorPix; if (master_attr == 0) { ColorInk = new SolidBrush(ZX.GetColor((ch[0] & 7) + ((ch[0] >> 3) & 8))); ColorPaper = new SolidBrush(ZX.GetColor(((ch[0] >> 3) & 15))); } else { ColorInk = new SolidBrush(ZX.GetColor((master_attr & 7) + ((master_attr >> 3) & 8))); ColorPaper = new SolidBrush(ZX.GetColor(((master_attr >> 3) & 15))); } if ((ch[0] & 0x80) == 0) { for (int j = 0; j < 8; j++) { for (int i = 0; i < 8; i++) { ColorPix = ((ch[j + 1] << i) & 128) == 0 ? ColorPaper : ColorInk; g.FillRectangle(ColorPix, x * 16 + i * 2, y * 16 + j * 2, 2, 2); } } } else { g.FillRectangle(ColorPaper, x * 16, y * 16, 16, 16); } }
//вывод палитры void ShowPalette() { int b = 0; if (BrightCheck.Checked) { b = 8; } for (int i = 0; i < 8; i++) { Color c = ZX.GetColor((byte)(i + b)); if (!ColorsCheck.Checked) { c = Color.LightGray; } var p = PalettePanel.Controls["I" + i.ToString()]; p.BackColor = c; if (i == Ink) { p.Text = "V"; } else { p.Text = ""; } if (i < 4 && ColorsCheck.Checked) { p.ForeColor = Color.White; } else { p.ForeColor = Color.Black; } p = PalettePanel.Controls["P" + i.ToString()]; p.BackColor = c; if (i == Paper) { p.Text = "V"; } else { p.Text = ""; } if (i < 4 && ColorsCheck.Checked) { p.ForeColor = Color.White; } else { p.ForeColor = Color.Black; } } if (!ColorsCheck.Checked) { AttrColor.BackColor = Color.LightGray; AttrColor.ForeColor = Color.Black; } else { AttrColor.BackColor = ZX.GetColor((byte)(Paper + b)); AttrColor.ForeColor = ZX.GetColor((byte)(Ink + b)); } }