Some tweaks to Lua docs
[lsnes.git] / src / library / framebuffer-pixfmt-lrgb.cpp
blob5b861bad2f029899dc43d8f04c7bcf96ae44d5f6
1 #include "framebuffer-pixfmt-lrgb.hpp"
3 namespace framebuffer
5 _pixfmt_lrgb::~_pixfmt_lrgb() throw()
9 void _pixfmt_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width)
10 throw()
12 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
13 for(size_t i = 0; i < width; i++) {
14 uint32_t word = _src[i];
15 uint32_t l = 1 + ((word >> 15) & 0xF);
16 uint32_t r = l * ((word >> 0) & 0x1F);
17 uint32_t g = l * ((word >> 5) & 0x1F);
18 uint32_t b = l * ((word >> 10) & 0x1F);
19 uint32_t x = (((r << 8) - r + 248) / 496) << 16;
20 x |= (((g << 8) - g + 248) / 496) << 8;
21 x |= ((b << 8) - b + 248) / 496;
22 target[i] = x;
26 void _pixfmt_lrgb::decode(uint32_t* target, const uint8_t* src, size_t width,
27 const auxpalette<false>& auxp) throw()
29 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
30 for(size_t i = 0; i < width; i++)
31 target[i] = auxp.pcache[_src[i] & 0x7FFFF];
34 void _pixfmt_lrgb::decode(uint64_t* target, const uint8_t* src, size_t width,
35 const auxpalette<true>& auxp) throw()
37 const uint32_t* _src = reinterpret_cast<const uint32_t*>(src);
38 for(size_t i = 0; i < width; i++)
39 target[i] = auxp.pcache[_src[i] & 0x7FFFF];
42 void _pixfmt_lrgb::set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
43 uint8_t bshift) throw(std::bad_alloc)
45 auxp.pcache.resize(0x80000);
46 for(size_t i = 0; i < 0x80000; i++) {
47 uint32_t l = 1 + ((i >> 15) & 0xF);
48 uint32_t r = l * ((i >> 0) & 0x1F);
49 uint32_t g = l * ((i >> 5) & 0x1F);
50 uint32_t b = l * ((i >> 10) & 0x1F);
51 auxp.pcache[i] = (((r << 8) - r + 248) / 496) << rshift;
52 auxp.pcache[i] += (((g << 8) - g + 248) / 496) << gshift;
53 auxp.pcache[i] += (((b << 8) - b + 248) / 496) << bshift;
55 auxp.rshift = rshift;
56 auxp.gshift = gshift;
57 auxp.bshift = bshift;
60 void _pixfmt_lrgb::set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
61 uint8_t bshift) throw(std::bad_alloc)
63 auxp.pcache.resize(0x80000);
64 for(size_t i = 0; i < 0x80000; i++) {
65 uint64_t l = 1 + ((i >> 15) & 0xF);
66 uint64_t r = l * ((i >> 0) & 0x1F);
67 uint64_t g = l * ((i >> 5) & 0x1F);
68 uint64_t b = l * ((i >> 10) & 0x1F);
69 auxp.pcache[i] = (((r << 16) - r + 248) / 496) << rshift;
70 auxp.pcache[i] += (((g << 16) - g + 248) / 496) << gshift;
71 auxp.pcache[i] += (((b << 16) - b + 248) / 496) << bshift;
73 auxp.rshift = rshift;
74 auxp.gshift = gshift;
75 auxp.bshift = bshift;
78 uint8_t _pixfmt_lrgb::get_bpp() throw()
80 return 4;
83 uint8_t _pixfmt_lrgb::get_ss_bpp() throw()
85 return 3;
88 uint32_t _pixfmt_lrgb::get_magic() throw()
90 return 0;
93 _pixfmt_lrgb pixfmt_lrgb;