Beispiel #1
0
        static Palette CreatePalette(Color[] colors)
        {
            if (colors.Length != 16 && colors.Length != 17)
                throw new ArgumentException("16 or 17 colors was expected.");

            var palette = new Palette();
            Array.Copy(colors, palette.Colors, colors.Length);
            return palette;
        }
Beispiel #2
0
        protected override void PalManipulateInit(int resID, int start, int end, int time)
        {
            var newPal = roomData.Palettes[resID];

            _palManipStart = start;
            _palManipEnd = end;
            _palManipCounter = 0;

            if (_palManipPalette == null)
                _palManipPalette = new Palette();
            if (_palManipIntermediatePal == null)
                _palManipIntermediatePal = new Palette();

            for (int i = start; i < end; ++i)
            {
                _palManipPalette.Colors[i] = newPal.Colors[i];
                _palManipIntermediatePal.Colors[i] = Color.FromRgb(
                    CurrentPalette.Colors[i].R << 8,
                    CurrentPalette.Colors[i].G << 8,
                    CurrentPalette.Colors[i].B << 8);
            }

            _palManipCounter = time;
        }
Beispiel #3
0
 System.Drawing.Color ToColor(byte[] pixels, Palette palette, VirtScreen screen, int x, int y)
 {
     var index = pixels[y * screen.Width + x];
     var c = palette.Colors[index];
     return System.Drawing.Color.FromArgb(c.R, c.G, c.B);
 }
Beispiel #4
0
        protected virtual void PalManipulateInit(int resID, int start, int end, int time)
        {
            var string1 = _strings[resID];
            var string2 = _strings[resID + 1];
            var string3 = _strings[resID + 2];
            if (string1 == null || string2 == null || string3 == null)
            {
                throw new InvalidOperationException(string.Format(
                        "palManipulateInit({0},{1},{2},{3}): Cannot obtain string resources {4}, {5} and {6}",
                        resID, start, end, time, resID, resID + 1, resID + 2));
            }

            _palManipStart = start;
            _palManipEnd = end;
            _palManipCounter = 0;

            if (_palManipPalette == null)
                _palManipPalette = new Palette();

            if (_palManipIntermediatePal == null)
                _palManipIntermediatePal = new Palette();

            for (var i = start; i < end; ++i)
            {
                _palManipPalette.Colors[i] = Color.FromRgb(string1[i], string2[i], string3[i]);
                var pal = _currentPalette.Colors[i];
                _palManipIntermediatePal.Colors[i] = Color.FromRgb(pal.R << 8, pal.G << 8, pal.B << 8);
            }

            _palManipCounter = time;
        }
Beispiel #5
0
        /// <summary>
        /// Cycle the colors in the given palette in the interval [cycleStart, cycleEnd]
        /// either one step forward or backward.
        /// </summary>
        /// <param name="palette"></param>
        /// <param name="cycleStart"></param>
        /// <param name="cycleEnd"></param>
        /// <param name="forward"></param>
        static void DoCyclePalette(Palette palette, int cycleStart, int cycleEnd, bool forward)
        {
            int num = cycleEnd - cycleStart;

            if (forward)
            {
                var tmp = palette.Colors[cycleEnd];
                Array.Copy(palette.Colors, cycleStart, palette.Colors, cycleStart + 1, num);
                palette.Colors[cycleStart] = tmp;
            }
            else
            {
                var tmp = palette.Colors[cycleStart];
                Array.Copy(palette.Colors, cycleStart + 1, palette.Colors, cycleStart, num);
                palette.Colors[cycleEnd] = tmp;
            }
        }
Beispiel #6
0
 void SetCurrentPalette(Palette palette)
 {
     for (var i = 0; i < 256; i++)
     {
         var color = palette.Colors[i];
         if (Game.Version >= 5 && Game.Version <= 6)
         {
             if (i < 15 || i == 15 || color.R < 252 || color.G < 252 || color.B < 252)
             {
                 CurrentPalette.Colors[i] = color;
             }
         }
         else
         {
             CurrentPalette.Colors[i] = color;
         }
     }
     if (Game.Version == 8)
     {
         Array.Copy(_currentPalette.Colors, _darkenPalette.Colors, _darkenPalette.Colors.Length);
     }
     SetDirtyColors(0, 255);
 }
Beispiel #7
0
 void TownsSetTextPalette(Palette palette)
 {
     for (int i = 0; i < 16; i++)
     {
         _textPalette[i * 3] = (byte)palette.Colors[i].R;
         _textPalette[i * 3 + 1] = (byte)palette.Colors[i].G;
         _textPalette[i * 3 + 2] = (byte)palette.Colors[i].B;
     }
 }
Beispiel #8
0
        void TownsSetPalette(Palette palette)
        {
            SetCurrentPalette(palette);

            if (Game.Version == 5)
                TownsSetTextPalette(_currentPalette);

            TownsOverrideShadowColor = 1;
            int m = 48;
            for (int i = 1; i < 16; ++i)
            {
                int val = _currentPalette.Colors[i].R + _currentPalette.Colors[i].G + _currentPalette.Colors[i].B;
                if (m > val)
                {
                    TownsOverrideShadowColor = (byte)i;
                    m = val;
                }
            }
        }
Beispiel #9
0
 void SetPalette(Palette palette)
 {
     for (var i = 0; i < 256; i++)
     {
         SetPalColor(i, palette.Colors[i].R, palette.Colors[i].G, palette.Colors[i].B);
     }
 }