Esempio n. 1
0
        public static void DisplayChar(Formats.CharsetProject Charset, int CharIndex, GR.Image.IImage TargetImage, int X, int Y, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4, Types.CharsetMode AlternativeMode)
        {
            Formats.CharData Char = Charset.Characters[CharIndex];

            if (AlternativeMode == C64Studio.Types.CharsetMode.ECM)
            {
                // ECM
                Formats.CharData origChar = Charset.Characters[CharIndex % 64];

                int bgColor = AltBGColor;
                switch (CharIndex / 64)
                {
                case 1:
                    bgColor = AltMColor1;
                    break;

                case 2:
                    bgColor = AltMColor2;
                    break;

                case 3:
                    bgColor = AltBGColor4;
                    break;
                }
                Displayer.CharacterDisplayer.DisplayHiResChar(origChar.Data, bgColor, AlternativeColor, TargetImage, X, Y);
            }
            else if (AlternativeMode == C64Studio.Types.CharsetMode.MULTICOLOR)
            {
                Displayer.CharacterDisplayer.DisplayMultiColorChar(Char.Data, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, TargetImage, X, Y);
            }
            else if (AlternativeMode == C64Studio.Types.CharsetMode.HIRES)
            {
                Displayer.CharacterDisplayer.DisplayHiResChar(Char.Data, AltBGColor, AlternativeColor, TargetImage, X, Y);
            }
        }
Esempio n. 2
0
        public static void DisplayChar(Formats.CharsetProject Charset, Palette Palette, int CharIndex, GR.Image.IImage TargetImage, int X, int Y, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4)
        {
            if (CharIndex >= Charset.Characters.Count)
            {
                return;
            }

            Formats.CharData Char = Charset.Characters[CharIndex];

            DisplayChar(Charset, Palette, CharIndex, TargetImage, X, Y, AlternativeColor, AltBGColor, AltMColor1, AltMColor2, AltBGColor4, Charset.Mode);
        }
Esempio n. 3
0
        public static void DisplayChar(Formats.CharsetProject Charset, Palette Palette, int CharIndex, GR.Image.IImage TargetImage, int X, int Y, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4, TextCharMode AlternativeMode)
        {
            Formats.CharData Char = Charset.Characters[CharIndex];

            if ((AlternativeMode == TextCharMode.COMMODORE_ECM) ||
                (AlternativeMode == TextCharMode.MEGA65_ECM))
            {
                // ECM
                Formats.CharData origChar = Charset.Characters[CharIndex % 64];

                int bgColor = AltBGColor;
                switch (CharIndex / 64)
                {
                case 1:
                    bgColor = AltMColor1;
                    break;

                case 2:
                    bgColor = AltMColor2;
                    break;

                case 3:
                    bgColor = AltBGColor4;
                    break;
                }
                DisplayHiResChar(origChar.Tile.Data, Palette, bgColor, AlternativeColor, TargetImage, X, Y);
            }
            else if (AlternativeMode == TextCharMode.COMMODORE_MULTICOLOR)
            {
                DisplayMultiColorChar(Char.Tile.Data, Palette, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, TargetImage, X, Y);
            }
            else if ((AlternativeMode == TextCharMode.COMMODORE_HIRES) ||
                     (AlternativeMode == TextCharMode.MEGA65_HIRES))
            {
                DisplayHiResChar(Char.Tile.Data, Palette, AltBGColor, AlternativeColor, TargetImage, X, Y);
            }
            else if ((AlternativeMode == TextCharMode.MEGA65_FCM) ||
                     (AlternativeMode == TextCharMode.MEGA65_FCM_16BIT))
            {
                DisplayMega65FCMChar(Char.Tile.Data, Palette, AltBGColor, AlternativeColor, TargetImage, X, Y);
            }
            else if (AlternativeMode == TextCharMode.MEGA65_NCM)
            {
                DisplayMega65NCMChar(Char.Tile.Data, Palette, AltBGColor, AlternativeColor, TargetImage, X, Y);
            }
            else if (AlternativeMode == TextCharMode.VIC20)
            {
                DisplayVIC20Char(Char.Tile.Data, Palette, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, TargetImage, X, Y);
            }
            else
            {
                Debug.Log("DisplayChar #2 unsupported mode " + AlternativeMode);
            }
        }
Esempio n. 4
0
        public static void DisplayChar(Formats.CharsetProject Charset, int CharIndex, CustomDrawControlContext Context, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4, TextCharMode AlternativeMode)
        {
            Formats.CharData Char = Charset.Characters[CharIndex];

            if (AlternativeMode == TextCharMode.COMMODORE_ECM)
            {
                // ECM
                Formats.CharData origChar = Charset.Characters[CharIndex % 64];

                int bgColor = AltBGColor;
                switch (CharIndex / 64)
                {
                case 1:
                    bgColor = AltMColor1;
                    break;

                case 2:
                    bgColor = AltMColor2;
                    break;

                case 3:
                    bgColor = AltBGColor4;
                    break;
                }
                DisplayHiResChar(origChar.Tile.Data, bgColor, AlternativeColor, Context);
            }
            else if (AlternativeMode == TextCharMode.COMMODORE_MULTICOLOR)
            {
                DisplayMultiColorChar(Char.Tile.Data, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, Context);
            }
            else if (AlternativeMode == TextCharMode.COMMODORE_HIRES)
            {
                DisplayHiResChar(Char.Tile.Data, AltBGColor, AlternativeColor, Context);
            }
            else if ((AlternativeMode == TextCharMode.MEGA65_FCM) ||
                     (AlternativeMode == TextCharMode.MEGA65_FCM_16BIT))
            {
                DisplayMega65FCMChar(Char.Tile.Data, AltBGColor, AlternativeColor, Context);
            }
            else if (AlternativeMode == TextCharMode.VIC20)
            {
                DisplayVIC20Char(Char.Tile.Data, AltBGColor, AltMColor1, AltMColor2, AlternativeColor, Context);
            }
            else
            {
                Debug.Log("DisplayChar unsupported mode " + AlternativeMode);
            }
        }
Esempio n. 5
0
        public static void DisplayChar(Formats.CharsetProject Charset, int CharIndex, GR.Image.IImage TargetImage, int X, int Y, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4)
        {
            Formats.CharData Char = Charset.Characters[CharIndex];

            DisplayChar(Charset, CharIndex, TargetImage, X, Y, AlternativeColor, AltBGColor, AltMColor1, AltMColor2, AltBGColor4, Char.Mode);
        }
Esempio n. 6
0
        public static void DisplayChar(Formats.CharsetProject Charset, int CharIndex, GR.Image.IImage TargetImage, int X, int Y)
        {
            Formats.CharData Char = Charset.Characters[CharIndex];

            DisplayChar(Charset, CharIndex, TargetImage, X, Y, Char.Color);
        }
Esempio n. 7
0
        public static void DisplayChar(Formats.CharsetProject Charset, int CharIndex, CustomDrawControlContext Context, int AlternativeColor, int AltBGColor, int AltMColor1, int AltMColor2, int AltBGColor4)
        {
            Formats.CharData Char = Charset.Characters[CharIndex];

            DisplayChar(Charset, CharIndex, Context, AlternativeColor, AltBGColor, AltMColor1, AltMColor2, AltBGColor4, Char.Mode);
        }
Esempio n. 8
0
        public static void DisplayChar(Formats.CharsetProject Charset, int CharIndex, CustomDrawControlContext Context)
        {
            Formats.CharData Char = Charset.Characters[CharIndex];

            DisplayChar(Charset, CharIndex, Context, Char.Color);
        }
        private bool CheckCharBox(Formats.GraphicScreenProject Project, Formats.CharData cd, int X, int Y, bool CheckForMC)
        {
            // Match image data
            int chosenCharColor = -1;

            cd.Replacement = null;
            cd.Index       = 0;

            // clear data
            for (int i = 0; i < cd.Tile.Data.Length; ++i)
            {
                cd.Tile.Data.SetU8At(i, 0);
            }

            bool isMultiColor = false;

            {
                // determine single/multi color
                bool[] usedColor           = new bool[16];
                int    numColors           = 0;
                bool   hasSinglePixel      = false;
                bool   usedBackgroundColor = false;

                for (int y = 0; y < 8; ++y)
                {
                    for (int x = 0; x < 8; ++x)
                    {
                        int colorIndex = (int)Project.Image.GetPixel(X + x, Y + y) % 16;
                        if (colorIndex >= 16)
                        {
                            cd.Error = "Color index >= 16";
                            return(false);
                        }
                        if ((x % 2) == 0)
                        {
                            if (colorIndex != (int)Project.Image.GetPixel(X + x + 1, Y + y) % 16)
                            {
                                // not a double pixel, must be single color then
                                hasSinglePixel = true;
                            }
                        }

                        if (!usedColor[colorIndex])
                        {
                            if (colorIndex == Project.Colors.BackgroundColor)
                            {
                                usedBackgroundColor = true;
                            }
                            usedColor[colorIndex] = true;
                            numColors++;
                        }
                    }
                }
                if ((hasSinglePixel) &&
                    (numColors > 2))
                {
                    cd.Error = "Has single pixel, but more than 2 colors";
                    return(false);
                }
                if (numColors > 2)
                {
                    isMultiColor = true;
                }
                if ((!CheckForMC) &&
                    (numColors > 2))
                {
                    cd.Error = "Has too many colors";
                    return(false);
                }
                if ((!CheckForMC) &&
                    (numColors == 2) &&
                    (!usedBackgroundColor))
                {
                    cd.Error = "Uses two colors different from background color";
                    return(false);
                }
                if ((hasSinglePixel) &&
                    (numColors == 2) &&
                    (!usedBackgroundColor))
                {
                    cd.Error = "Has single pixel, but more than 2 colors different from background color";
                    return(false);
                }
                if ((CheckForMC) &&
                    (!hasSinglePixel) &&
                    (numColors > 4))
                {
                    cd.Error = "Has more than 4 colors";
                    return(false);
                }
                if ((!hasSinglePixel) &&
                    (numColors == 4) &&
                    (!usedBackgroundColor))
                {
                    cd.Error = "Has more than 4 colors different from background color";
                    return(false);
                }
                int otherColorIndex = 16;
                if ((!hasSinglePixel) &&
                    (numColors == 2) &&
                    (usedBackgroundColor))
                {
                    for (int i = 0; i < 16; ++i)
                    {
                        if ((usedColor[i]) &&
                            (i != Project.Colors.BackgroundColor))
                        {
                            otherColorIndex = i;
                            break;
                        }
                    }
                }
                if ((hasSinglePixel) ||
                    (!CheckForMC) ||
                    ((numColors == 2) &&
                     (usedBackgroundColor) &&
                     (otherColorIndex < 8)))
                //||   ( numColors == 2 ) )
                {
                    // eligible for single color
                    isMultiColor = false;
                    int usedFreeColor = -1;
                    for (int i = 0; i < 16; ++i)
                    {
                        if (usedColor[i])
                        {
                            if (i != Project.Colors.BackgroundColor)
                            {
                                if (usedFreeColor != -1)
                                {
                                    cd.Error = "More than 1 free color";
                                    return(false);
                                }
                                usedFreeColor = i;
                            }
                        }
                    }

                    if ((hasSinglePixel) &&
                        (CheckForMC) &&
                        (numColors == 2) &&
                        (usedFreeColor >= 8))
                    {
                        cd.Error = "Hires char cannot use free color with index " + usedFreeColor;
                        return(false);
                    }

                    for (int y = 0; y < 8; ++y)
                    {
                        for (int x = 0; x < 8; ++x)
                        {
                            int ColorIndex = (int)Project.Image.GetPixel(X + x, Y + y) % 16;

                            int BitPattern = 0;

                            if (ColorIndex != Project.Colors.BackgroundColor)
                            {
                                BitPattern = 1;
                            }

                            // noch nicht verwendete Farbe
                            if (BitPattern == 1)
                            {
                                chosenCharColor = ColorIndex;
                            }
                            cd.Tile.Data.SetU8At(y + x / 8, (byte)(cd.Tile.Data.ByteAt(y + x / 8) | (BitPattern << ((7 - (x % 8))))));
                        }
                    }
                }
                else
                {
                    // multi color
                    isMultiColor = true;
                    int usedMultiColors = 0;
                    int usedFreeColor   = -1;
                    for (int i = 0; i < 16; ++i)
                    {
                        if (usedColor[i])
                        {
                            if ((i == Project.Colors.MultiColor1) ||
                                (i == Project.Colors.MultiColor2) ||
                                (i == Project.Colors.BackgroundColor))
                            {
                                ++usedMultiColors;
                            }
                            else
                            {
                                usedFreeColor = i;
                            }
                        }
                    }
                    if (numColors - usedMultiColors > 1)
                    {
                        // only one free color allowed
                        cd.Error = "More than 1 free color";
                        return(false);
                    }
                    if (usedFreeColor >= 8)
                    {
                        cd.Error = "Free color must be of index < 8";
                        return(false);
                    }
                    for (int y = 0; y < 8; ++y)
                    {
                        for (int x = 0; x < 4; ++x)
                        {
                            int ColorIndex = (int)Project.Image.GetPixel(X + 2 * x, Y + y) % 16;

                            byte BitPattern = 0;

                            if (ColorIndex == Project.Colors.BackgroundColor)
                            {
                                BitPattern = 0x00;
                            }
                            else if (ColorIndex == Project.Colors.MultiColor1)
                            {
                                BitPattern = 0x01;
                            }
                            else if (ColorIndex == Project.Colors.MultiColor2)
                            {
                                BitPattern = 0x02;
                            }
                            else
                            {
                                // noch nicht verwendete Farbe
                                chosenCharColor = usedFreeColor;
                                BitPattern      = 0x03;
                            }
                            cd.Tile.Data.SetU8At(y + x / 4, (byte)(cd.Tile.Data.ByteAt(y + x / 4) | (BitPattern << ((3 - (x % 4)) * 2))));
                        }
                    }
                    if (usedFreeColor == -1)
                    {
                        // only the two multi colors were used, we need to force multi color index though
                        chosenCharColor = 8;
                    }
                }
            }
            if (chosenCharColor == -1)
            {
                chosenCharColor = 0;
            }
            cd.Tile.CustomColor = chosenCharColor;
            if ((isMultiColor) &&
                (chosenCharColor < 8))
            {
                cd.Tile.CustomColor = chosenCharColor + 8;
            }
            return(true);
        }