bsnes: redump sprite/palette functions
[lsnes.git] / src / library / framebuffer-pixfmt-rgb24.cpp
blobc788f33b25b739d9129f539fb02b177ed15e79b8
1 #include "framebuffer-pixfmt-rgb24.hpp"
2 #include <cstring>
4 namespace framebuffer
6 template<bool uvswap>
7 _pixfmt_rgb24<uvswap>::~_pixfmt_rgb24() throw() {}
9 template<bool uvswap>
10 void _pixfmt_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width) throw()
12 if(uvswap) {
13 for(size_t i = 0; i < width; i++) {
14 target[i] = (uint32_t)src[3 * i + 2] << 16;
15 target[i] |= (uint32_t)src[3 * i + 1] << 8;
16 target[i] |= src[3 * i + 0];
18 } else {
19 for(size_t i = 0; i < width; i++) {
20 target[i] = (uint32_t)src[3 * i + 0] << 16;
21 target[i] |= (uint32_t)src[3 * i + 1] << 8;
22 target[i] |= src[3 * i + 2];
27 template<bool uvswap>
28 void _pixfmt_rgb24<uvswap>::decode(uint32_t* target, const uint8_t* src, size_t width,
29 const auxpalette<false>& auxp) throw()
31 for(size_t i = 0; i < width; i++) {
32 target[i] = static_cast<uint32_t>(src[3 * i + (uvswap ? 2 : 0)]) << auxp.rshift;
33 target[i] |= static_cast<uint32_t>(src[3 * i + 1]) << auxp.gshift;
34 target[i] |= static_cast<uint32_t>(src[3 * i + (uvswap ? 0 : 2)]) << auxp.bshift;
38 template<bool uvswap>
39 void _pixfmt_rgb24<uvswap>::decode(uint64_t* target, const uint8_t* src, size_t width,
40 const auxpalette<true>& auxp) throw()
42 for(size_t i = 0; i < width; i++) {
43 target[i] = static_cast<uint64_t>(src[3 * i + (uvswap ? 2 : 0)]) << auxp.rshift;
44 target[i] |= static_cast<uint64_t>(src[3 * i + 1]) << auxp.gshift;
45 target[i] |= static_cast<uint64_t>(src[3 * i + (uvswap ? 0 : 2)]) << auxp.bshift;
46 target[i] += (target[i] << 8);
50 template<bool uvswap>
51 void _pixfmt_rgb24<uvswap>::set_palette(auxpalette<false>& auxp, uint8_t rshift, uint8_t gshift,
52 uint8_t bshift) throw(std::bad_alloc)
54 auxp.rshift = rshift;
55 auxp.gshift = gshift;
56 auxp.bshift = bshift;
57 auxp.pcache.clear();
60 template<bool uvswap>
61 void _pixfmt_rgb24<uvswap>::set_palette(auxpalette<true>& auxp, uint8_t rshift, uint8_t gshift,
62 uint8_t bshift) throw(std::bad_alloc)
64 auxp.rshift = rshift;
65 auxp.gshift = gshift;
66 auxp.bshift = bshift;
67 auxp.pcache.clear();
70 template<bool uvswap>
71 uint8_t _pixfmt_rgb24<uvswap>::get_bpp() throw()
73 return 3;
76 template<bool uvswap>
77 uint8_t _pixfmt_rgb24<uvswap>::get_ss_bpp() throw()
79 return 3;
82 template<bool uvswap>
83 uint32_t _pixfmt_rgb24<uvswap>::get_magic() throw()
85 if(uvswap)
86 return 0x25642332U;
87 else
88 return 0x85433684U;
91 _pixfmt_rgb24<false> pixfmt_rgb24;
92 _pixfmt_rgb24<true> pixfmt_bgr24;