PicoGraphics: RGB332 use 332->565 flash LUT.

experimental/8bitfb
jon 2022-06-17 10:37:54 +01:00 zatwierdzone przez Phil Howard
rodzic 077159adeb
commit b0a386f240
2 zmienionych plików z 18 dodań i 261 usunięć

Wyświetl plik

@ -126,255 +126,22 @@ namespace pimoroni {
};
static const RGB565 rgb332_to_rgb565_lut[256] = {
0x0000, 0x0800, 0x1000, 0x1800, 0x0001, 0x0801, 0x1001, 0x1801,
0x0002,
0x0802,
0x1002,
0x1802,
0x0003,
0x0803,
0x1003,
0x1803,
0x0004,
0x0804,
0x1004,
0x1804,
0x0005,
0x0805,
0x1005,
0x1805,
0x0006,
0x0806,
0x1006,
0x1806,
0x0007,
0x0807,
0x1007,
0x1807,
0x0020,
0x0820,
0x1020,
0x1820,
0x0021,
0x0821,
0x1021,
0x1821,
0x0022,
0x0822,
0x1022,
0x1822,
0x0023,
0x0823,
0x1023,
0x1823,
0x0024,
0x0824,
0x1024,
0x1824,
0x0025,
0x0825,
0x1025,
0x1825,
0x0026,
0x0826,
0x1026,
0x1826,
0x0027,
0x0827,
0x1027,
0x1827,
0x0040,
0x0840,
0x1040,
0x1840,
0x0041,
0x0841,
0x1041,
0x1841,
0x0042,
0x0842,
0x1042,
0x1842,
0x0043,
0x0843,
0x1043,
0x1843,
0x0044,
0x0844,
0x1044,
0x1844,
0x0045,
0x0845,
0x1045,
0x1845,
0x0046,
0x0846,
0x1046,
0x1846,
0x0047,
0x0847,
0x1047,
0x1847,
0x0060,
0x0860,
0x1060,
0x1860,
0x0061,
0x0861,
0x1061,
0x1861,
0x0062,
0x0862,
0x1062,
0x1862,
0x0063,
0x0863,
0x1063,
0x1863,
0x0064,
0x0864,
0x1064,
0x1864,
0x0065,
0x0865,
0x1065,
0x1865,
0x0066,
0x0866,
0x1066,
0x1866,
0x0067,
0x0867,
0x1067,
0x1867,
0x0080,
0x0880,
0x1080,
0x1880,
0x0081,
0x0881,
0x1081,
0x1881,
0x0082,
0x0882,
0x1082,
0x1882,
0x0083,
0x0883,
0x1083,
0x1883,
0x0084,
0x0884,
0x1084,
0x1884,
0x0085,
0x0885,
0x1085,
0x1885,
0x0086,
0x0886,
0x1086,
0x1886,
0x0087,
0x0887,
0x1087,
0x1887,
0x00a0,
0x08a0,
0x10a0,
0x18a0,
0x00a1,
0x08a1,
0x10a1,
0x18a1,
0x00a2,
0x08a2,
0x10a2,
0x18a2,
0x00a3,
0x08a3,
0x10a3,
0x18a3,
0x00a4,
0x08a4,
0x10a4,
0x18a4,
0x00a5,
0x08a5,
0x10a5,
0x18a5,
0x00a6,
0x08a6,
0x10a6,
0x18a6,
0x00a7,
0x08a7,
0x10a7,
0x18a7,
0x00c0,
0x08c0,
0x10c0,
0x18c0,
0x00c1,
0x08c1,
0x10c1,
0x18c1,
0x00c2,
0x08c2,
0x10c2,
0x18c2,
0x00c3,
0x08c3,
0x10c3,
0x18c3,
0x00c4,
0x08c4,
0x10c4,
0x18c4,
0x00c5,
0x08c5,
0x10c5,
0x18c5,
0x00c6,
0x08c6,
0x10c6,
0x18c6,
0x00c7,
0x08c7,
0x10c7,
0x18c7,
0x00e0,
0x08e0,
0x10e0,
0x18e0,
0x00e1,
0x08e1,
0x10e1,
0x18e1,
0x00e2,
0x08e2,
0x10e2,
0x18e2,
0x00e3,
0x08e3,
0x10e3,
0x18e3,
0x00e4,
0x08e4,
0x10e4,
0x18e4,
0x00e5,
0x08e5,
0x10e5,
0x18e5,
0x00e6,
0x08e6,
0x10e6,
0x18e6,
0x00e7,
0x08e7,
0x10e7,
0x18e7,
0x0000, 0x0800, 0x1000, 0x1800, 0x0001, 0x0801, 0x1001, 0x1801, 0x0002, 0x0802, 0x1002, 0x1802, 0x0003, 0x0803, 0x1003, 0x1803,
0x0004, 0x0804, 0x1004, 0x1804, 0x0005, 0x0805, 0x1005, 0x1805, 0x0006, 0x0806, 0x1006, 0x1806, 0x0007, 0x0807, 0x1007, 0x1807,
0x0020, 0x0820, 0x1020, 0x1820, 0x0021, 0x0821, 0x1021, 0x1821, 0x0022, 0x0822, 0x1022, 0x1822, 0x0023, 0x0823, 0x1023, 0x1823,
0x0024, 0x0824, 0x1024, 0x1824, 0x0025, 0x0825, 0x1025, 0x1825, 0x0026, 0x0826, 0x1026, 0x1826, 0x0027, 0x0827, 0x1027, 0x1827,
0x0040, 0x0840, 0x1040, 0x1840, 0x0041, 0x0841, 0x1041, 0x1841, 0x0042, 0x0842, 0x1042, 0x1842, 0x0043, 0x0843, 0x1043, 0x1843,
0x0044, 0x0844, 0x1044, 0x1844, 0x0045, 0x0845, 0x1045, 0x1845, 0x0046, 0x0846, 0x1046, 0x1846, 0x0047, 0x0847, 0x1047, 0x1847,
0x0060, 0x0860, 0x1060, 0x1860, 0x0061, 0x0861, 0x1061, 0x1861, 0x0062, 0x0862, 0x1062, 0x1862, 0x0063, 0x0863, 0x1063, 0x1863,
0x0064, 0x0864, 0x1064, 0x1864, 0x0065, 0x0865, 0x1065, 0x1865, 0x0066, 0x0866, 0x1066, 0x1866, 0x0067, 0x0867, 0x1067, 0x1867,
0x0080, 0x0880, 0x1080, 0x1880, 0x0081, 0x0881, 0x1081, 0x1881, 0x0082, 0x0882, 0x1082, 0x1882, 0x0083, 0x0883, 0x1083, 0x1883,
0x0084, 0x0884, 0x1084, 0x1884, 0x0085, 0x0885, 0x1085, 0x1885, 0x0086, 0x0886, 0x1086, 0x1886, 0x0087, 0x0887, 0x1087, 0x1887,
0x00a0, 0x08a0, 0x10a0, 0x18a0, 0x00a1, 0x08a1, 0x10a1, 0x18a1, 0x00a2, 0x08a2, 0x10a2, 0x18a2, 0x00a3, 0x08a3, 0x10a3, 0x18a3,
0x00a4, 0x08a4, 0x10a4, 0x18a4, 0x00a5, 0x08a5, 0x10a5, 0x18a5, 0x00a6, 0x08a6, 0x10a6, 0x18a6, 0x00a7, 0x08a7, 0x10a7, 0x18a7,
0x00c0, 0x08c0, 0x10c0, 0x18c0, 0x00c1, 0x08c1, 0x10c1, 0x18c1, 0x00c2, 0x08c2, 0x10c2, 0x18c2, 0x00c3, 0x08c3, 0x10c3, 0x18c3,
0x00c4, 0x08c4, 0x10c4, 0x18c4, 0x00c5, 0x08c5, 0x10c5, 0x18c5, 0x00c6, 0x08c6, 0x10c6, 0x18c6, 0x00c7, 0x08c7, 0x10c7, 0x18c7,
0x00e0, 0x08e0, 0x10e0, 0x18e0, 0x00e1, 0x08e1, 0x10e1, 0x18e1, 0x00e2, 0x08e2, 0x10e2, 0x18e2, 0x00e3, 0x08e3, 0x10e3, 0x18e3,
0x00e4, 0x08e4, 0x10e4, 0x18e4, 0x00e5, 0x08e5, 0x10e5, 0x18e5, 0x00e6, 0x08e6, 0x10e6, 0x18e6, 0x00e7, 0x08e7, 0x10e7, 0x18e7,
};
class PicoGraphics {

Wyświetl plik

@ -94,17 +94,6 @@ namespace pimoroni {
void PicoGraphics_PenRGB332::scanline_convert(PenType type, conversion_callback_func callback) {
if(type == PEN_RGB565) {
static RGB565 cache[256];
for(auto i = 0u; i < 256; i++) {
cache[i] = rgb332_to_rgb565_lut[i]; // defined in pico_graphics.hpp
}
// 2ms slower, I swear!
/*
static RGB565 cache[256];
memcpy(cache, rgb332_to_rgb565_lut, 256 * sizeof(RGB565));
*/
// Treat our void* frame_buffer as uint8_t
uint8_t *src = (uint8_t *)frame_buffer;
@ -112,7 +101,8 @@ namespace pimoroni {
uint16_t row_buf[bounds.w];
for(auto y = 0; y < bounds.h; y++) {
for(auto x = 0; x < bounds.w; x++) {
row_buf[x] = cache[*src];
row_buf[x] = rgb332_to_rgb565_lut[*src];
src++;
}
// Callback to the driver with the row data