-
Notifications
You must be signed in to change notification settings - Fork 2
/
Palettes.cs
50 lines (48 loc) · 1.35 KB
/
Palettes.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Threading.Tasks;
namespace sth1edwv
{
public static class Palettes
{
public static List<Color[]> palettes;
public static void ReadPallettes(byte[] mem)
{
palettes = new List<Color[]>();
int start = 0x627C;
for (int i = 0; i < 8; i++)
{
ushort address = BitConverter.ToUInt16(mem, start);
Color[] pal = new Color[32];
for (int j = 0; j < 32; j++)
{
byte col = mem[address + j];
byte r = scaleColor((byte)(col & 3));
byte g = scaleColor((byte)((col >> 2) & 3));
byte b = scaleColor((byte)((col >> 4) & 3));
pal[j] = Color.FromArgb(r, g, b);
}
palettes.Add(pal);
start += 2;
}
}
public static byte scaleColor(byte c)
{
switch (c)
{
case 0:
return 0;
case 1:
return 80;
case 2:
return 175;
case 3:
return 255;
}
return 0;
}
}
}