36 lines
708 B
C++
36 lines
708 B
C++
#include <lcd/palette.h>
|
|
|
|
const sf::Color Palette::colors[] = {
|
|
sf::Color(255,255,255),
|
|
sf::Color(170,170,170),
|
|
sf::Color(85,85,85),
|
|
sf::Color(0,0,0),
|
|
};
|
|
|
|
const sf::Color Palette::transparent(0,0,0,255);
|
|
|
|
Palette::Palette(bool transparent0)
|
|
: transparent0(transparent0)
|
|
{
|
|
setRegValue(0);
|
|
}
|
|
|
|
void Palette::setRegValue(u8 regval)
|
|
{
|
|
for(int i = 0; i < 4; i++, regval >>= 2)
|
|
idx_to_color[i] = regval & 0x3;
|
|
}
|
|
|
|
u8 Palette::getRegValue()
|
|
{
|
|
u8 regval = 0;
|
|
for(int i = 0; i < 4; i++, regval <<= 2)
|
|
regval |= idx_to_color[i] & 0x3;
|
|
return regval;
|
|
}
|
|
|
|
const sf::Color& Palette::getColorByIdx(u8 idx)
|
|
{
|
|
if(idx == 0 && transparent0) return transparent;
|
|
return colors[idx_to_color[idx]];
|
|
}
|