Esempio n. 1
0
    private void updateScreenByPalette(Palettes.Palette oldPal, Palettes.Palette pal)
    {
        var indexes   = screenTexture.GetPixels32().Select(c => Palettes.GetColorIx(c, oldPal));
        var newColors = indexes.ToList().Select(ix => Palettes.GetColor(ix, pal)).ToArray();

        screenTexture.SetPixels32(newColors);
    }
Esempio n. 2
0
    private void FixedUpdate()
    {
        if (!enabled || !isInited)
        {
            return;
        }

        if (tic80Config.Stats)
        {
            print("FPS:" + View.Instance.Stats.Fps, 205, 0, 6, true);
            print("Memory:" + View.Instance.Stats.UsedMemory, 187, 6, 6, true);
        }

        t = Time.time;
        Invoke("TIC", 0f);
        screenTexture.Apply();
        f++;

        oldPalette = tic80Config.Palette;
    }
Esempio n. 3
0
        public static Palette LoadAP(byte[] img)
        {
            Palette Pal = new Palette();
            for (int i = 0; i < img.Length / 4; i++)
            {
                byte B = img[4 * i];
                byte G = img[4 * i + 1];
                byte R = img[4 * i + 2];
                byte A = img[4 * i + 3];

                Colour C = new Colour(R, G, B, A);

                Pal.Colours.Add(C);
            }
            return Pal;
        }
Esempio n. 4
0
 public static byte[] Convert(Palette Pal)
 {
     byte[] res = new byte[Pal.Colours.Count * 4];
     for (int i = 0; i < Pal.Colours.Count; i++)
     {
         res[4 * i] = Pal.Colours[i].B;
         res[4 * i + 1] = Pal.Colours[i].G;
         res[4 * i + 2] = Pal.Colours[i].R;
         res[4 * i + 3] = Pal.Colours[i].A;
     }
     return res;
 }
Esempio n. 5
0
        public static Tuple<List<PalMap>, Palette> Convert(byte[][] Imgs, int W)
        {
            Palette Pal = new Palette();
            List<PalMap> PMs = new List<PalMap>();

            foreach (byte[] Img in Imgs)
            {
                PalMap PM = new PalMap();
                PMs.Add(PM);

                PM.Pixels = new int[Img.Length / W][];
                for (int i = 0; i < PM.Pixels.Length; i++)
                    PM.Pixels[i] = new int[W];

                for (int i = 0; i < Img.Length / 4; i++)
                {
                    byte B = Img[4 * i];
                    byte G = Img[4 * i + 1];
                    byte R = Img[4 * i + 2];
                    byte A = Img[4 * i + 3];

                    Colour C = new Colour(R, G, B, A);

                    if (Pal.Colours.Count == 0)
                    {
                        Pal.Colours.Add(C);
                        PM.Pixels[i / W][i % W] = 0;
                    }
                    else
                        for (int j = 0; j < Pal.Colours.Count; j++)
                            if (Pal.Colours[j].DecCode == C.DecCode)
                            {
                                PM.Pixels[i / W][i % W] = j;
                                break;
                            }
                            else if (j == Pal.Colours.Count - 1)
                            {
                                Pal.Colours.Add(C);
                                PM.Pixels[i / W][i % W] = j + 1;
                            }
                }

            }

            return new Tuple<List<PalMap>, Palette>(PMs, Pal);
        }
Esempio n. 6
0
        public static byte[] Convert(PalMap PM, Palette Pal)
        {
            byte[] res = new byte[PM.Width * PM.Height * 4];

            for (int i = 0; i < PM.Width * PM.Height; i++)
            {
                int w = W(i, PM.Width);
                int h = H(i, PM.Width);

                res[4 * i] = Pal.Colours[PM.Pixels[h][w]].B;
                res[4 * i + 1] = Pal.Colours[PM.Pixels[h][w]].G;
                res[4 * i + 2] = Pal.Colours[PM.Pixels[h][w]].R;
                res[4 * i + 3] = Pal.Colours[PM.Pixels[h][w]].A;
            }

            return res;
        }