示例#1
0
        public SpeccyFrame(int Width, int Height, string[] InitialContent = null, SpeccyColor ForeColor = SpeccyColor.Black, SpeccyColor BackColor = SpeccyColor.White)
        {
            width  = Width;
            height = Height;

            chars = new SpeccyScreenChar[Width, Height];

            if (InitialContent != null)
            {
                for (int y = 0; y < Height; y++)
                {
                    string line = InitialContent[y];

                    for (int x = 0; x < Width; x++)
                    {
                        chars[x, y] = new SpeccyScreenChar {
                            CurrentChar = line[x], ForeColor = ForeColor, BackColor = BackColor
                        };
                    }
                }
            }
            else
            {
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        chars[x, y] = new SpeccyScreenChar {
                            CurrentChar = ' ', ForeColor = ForeColor, BackColor = BackColor
                        }
                    }
                }
                ;
            }
        }
示例#2
0
 public SpeccyLabel(int Width, SpeccyColor ForegroundColor, SpeccyColor BackgroundColor, SpeccyFont Font) : base(Width, 1, Font)
 {
     this.ForeColor       = ForegroundColor;
     this.BackColor       = BackgroundColor;
     this.TranspatentChar = '\0';
     this.Text            = "";
 }
示例#3
0
        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;
        }
示例#4
0
        public void Plot(int X, int Y, SpeccyColor ForeColor)
        {
            if (X >= bufferWidth || Y >= bufferHeight || X < 0 || Y < 0)
            {
                return;
            }

            int byteX = X / 8;
            int attrY = Y / 8;
            int bit   = X % 8;

            pixels[byteX, Y]           |= (byte)(128 >> bit);
            attributes[byteX, attrY, 1] = ForeColor;
        }
示例#5
0
        protected void PrintAt(SpeccyColor Ink, SpeccyColor Paper, int X, int Y, string Value)
        {
            int len = Value.Length;

            cursorX = X;
            cursorY = Y;
            bool lastInc = false;

            for (int buc = 0; buc < len; buc++)
            {
                if (Value[buc] == '\r')
                {
                    continue;
                }

                lastInc = false;

                if (Value[buc] != '\n')
                {
                    if (cursorY >= Screen.Height)
                    {
                        cursorY--;
                        Screen.ShiftChars(1, Ink, Paper);
                    }

                    Screen.PrintChar(currentFont[Value[buc]], Ink, Paper, cursorX, cursorY, Over ? SpeccyMode.OR : SpeccyMode.COPY);
                    cursorX++;

                    if (cursorX >= Screen.Width)
                    {
                        cursorX = 0;
                        cursorY++;
                        lastInc = true;
                    }
                }
                else
                {
                    cursorX = 0;
                    cursorY++;
                    lastInc = true;
                }
            }

            cursorX = 0;
            if (!lastInc)
            {
                cursorY++;
            }
        }
示例#6
0
        public void Circle(int X, int Y, int Radius, SpeccyColor ForeColor, SpeccyColor BackColor)
        {
            var f     = 1 - Radius;
            var ddF_x = 1;
            var ddF_y = -2 * Radius;
            var x     = 0;
            var y     = Radius;

            //Bottom middle
            Plot(X, Y + Radius, ForeColor, BackColor);

            //Top Middle
            Plot(X, Y - Radius, ForeColor, BackColor);

            //Right Middle
            Plot(X + Radius, Y, ForeColor, BackColor);

            //Left Middle
            Plot(X - Radius, Y, ForeColor, BackColor);

            while (x < y)
            {
                if (f >= 0)
                {
                    y--;
                    ddF_y += 2;
                    f     += ddF_y;
                }
                x++;
                ddF_x += 2;
                f     += ddF_x;

                //Lower Right
                Plot(X + x, Y + y, ForeColor, BackColor);
                Plot(X + y, Y + x, ForeColor, BackColor);

                //Lower Left
                Plot(X - x, Y + y, ForeColor, BackColor);
                Plot(X - y, Y + x, ForeColor, BackColor);

                //Top Right
                Plot(X + x, Y - y, ForeColor, BackColor);
                Plot(X + y, Y - x, ForeColor, BackColor);

                //Top Left
                Plot(X - x, Y - y, ForeColor, BackColor);
                Plot(X - y, Y - x, ForeColor, BackColor);
            }
        }
示例#7
0
        public void Clear(SpeccyColor Foreground, SpeccyColor Background)
        {
            Array.Clear(pixels, 0, width * height * 8);

            fixed(SpeccyColor *attrPtr = &attributes[0, 0, 0])
            {
                int max = width * height * 2;

                for (int buc = 0; buc < max; buc++)
                {
                    if (buc % 2 == 0)
                    {
                        attrPtr[buc] = Background;
                    }
                    else
                    {
                        attrPtr[buc] = Foreground;
                    }
                }
            }
        }
示例#8
0
        public void ShiftChars(int Chars, SpeccyColor ForeColor, SpeccyColor BackColor)
        {
            int h      = height * 8;
            int Pixels = Chars * 8;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int fromCopy = y + Pixels;

                    if (fromCopy >= h)
                    {
                        pixels[x, y] = 0;
                    }
                    else
                    {
                        pixels[x, fromCopy] = 0;
                    }
                }
            }

            h = height - 1;

            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    attributes[x, y, 0] = attributes[x, y + 1, 0];
                    attributes[x, y, 1] = attributes[x, y + 1, 1];
                }
            }

            for (int x = 0; x < width; x++)
            {
                attributes[x, h, 0] = BackColor;
                attributes[x, h, 1] = ForeColor;
            }
        }
示例#9
0
        public void PrintChar(SpeccyFontChar Char, SpeccyColor ForeColor, 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;
            }

            attributes[X, Y, 1] = ForeColor;

            if (ExpandAttributes)
            {
                if (XShift != 0 && xFits)
                {
                    attributes[X + 1, Y, 1] = ForeColor;
                }

                if (YShift != 0 && yFits)
                {
                    attributes[X, Y + 1, 1] = ForeColor;
                }

                if (XShift != 0 && YShift != 0 && xFits && yFits)
                {
                    attributes[X + 1, Y + 1, 1] = ForeColor;
                }
            }
        }
示例#10
0
        public void Line(int StartX, int StartY, int EndX, int EndY, SpeccyColor ForeColor, SpeccyColor BackColor)
        {
            int w = EndX - StartX;
            int h = EndY - StartY;
            int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0;

            if (w < 0)
            {
                dx1 = -1;
            }
            else if (w > 0)
            {
                dx1 = 1;
            }
            if (h < 0)
            {
                dy1 = -1;
            }
            else if (h > 0)
            {
                dy1 = 1;
            }
            if (w < 0)
            {
                dx2 = -1;
            }
            else if (w > 0)
            {
                dx2 = 1;
            }
            int longest  = Math.Abs(w);
            int shortest = Math.Abs(h);

            if (!(longest > shortest))
            {
                longest  = Math.Abs(h);
                shortest = Math.Abs(w);
                if (h < 0)
                {
                    dy2 = -1;
                }
                else if (h > 0)
                {
                    dy2 = 1;
                }
                dx2 = 0;
            }
            int numerator = longest >> 1;

            for (int i = 0; i <= longest; i++)
            {
                Plot(StartX, StartY, ForeColor, BackColor);
                numerator += shortest;
                if (!(numerator < longest))
                {
                    numerator -= longest;
                    StartX    += dx1;
                    StartY    += dy1;
                }
                else
                {
                    StartX += dx2;
                    StartY += dy2;
                }
            }
        }
示例#11
0
 protected void Print(SpeccyColor Ink, SpeccyColor Paper, string Value)
 {
     PrintAt(Ink, Paper, cursorX, cursorY, Value);
 }
示例#12
0
 protected void Circle(SpeccyColor Ink, SpeccyColor Paper, int X, int Y, int Radius)
 {
     Screen.Circle(X, Y, Radius, Ink, Paper);
     plotX = X;
     plotY = Y;
 }
示例#13
0
 protected void Draw(SpeccyColor Ink, SpeccyColor Paper, int X, int Y)
 {
     Screen.Line(plotX, plotY, X, Y, Ink, Paper);
     plotX = X;
     plotY = Y;
 }
示例#14
0
 protected void Plot(SpeccyColor Ink, SpeccyColor Paper, int X, int Y)
 {
     plotX = X;
     plotY = Y;
     Screen.Plot(X, Y, Ink, Paper);
 }