1 #include "core/moviedata.hpp"
2 #include "core/memorymanip.hpp"
3 #include "interface/cover.hpp"
4 #include "library/minmax.hpp"
5 #include "library/utf8.hpp"
6 #include "fonts/wrapper.hpp"
11 template<size_t pstride
>
12 void cover_render_character(void* fb
, unsigned x
, unsigned y
, uint32_t ch
, uint32_t fg
, uint32_t bg
,
13 size_t w
, size_t h
, size_t istride
)
15 unsigned char* _fg
= reinterpret_cast<unsigned char*>(&fg
);
16 unsigned char* _bg
= reinterpret_cast<unsigned char*>(&bg
);
19 const framebuffer::font::glyph
& g
= main_font
.get_glyph(ch
);
20 unsigned maxw
= min((size_t)(g
.wide
? 16 : 8), (size_t)(w
- x
));
21 unsigned maxh
= min((size_t)16, (size_t)(h
- y
));
22 unsigned char* cellbase
= reinterpret_cast<unsigned char*>(fb
) + y
* istride
+ pstride
* x
;
25 for(size_t y2
= 0; y2
< maxh
; y2
++) {
26 uint32_t d
= g
.data
[y2
>> 1];
27 d
>>= 16 - ((y2
& 1) << 4);
28 for(size_t j
= 0; j
< maxw
; j
++) {
30 if(((d
>> b
) & 1) != 0) {
31 for(unsigned k
= 0; k
< pstride
; k
++)
32 cellbase
[pstride
* j
+ k
] = _fg
[k
];
34 for(unsigned k
= 0; k
< pstride
; k
++)
35 cellbase
[pstride
* j
+ k
] = _bg
[k
];
42 for(size_t y2
= 0; y2
< maxh
; y2
++) {
43 uint32_t d
= g
.data
[y2
>> 2];
44 d
>>= 24 - ((y2
& 3) << 3);
45 for(size_t j
= 0; j
< maxw
; j
++) {
47 if(((d
>> b
) & 1) != 0) {
48 for(unsigned k
= 0; k
< pstride
; k
++)
49 cellbase
[pstride
* j
+ k
] = _fg
[k
];
51 for(unsigned k
= 0; k
< pstride
; k
++)
52 cellbase
[pstride
* j
+ k
] = _bg
[k
];
61 void cover_render_character(void* fb
, unsigned x
, unsigned y
, uint32_t ch
, uint32_t fg
, uint32_t bg
, size_t w
,
62 size_t h
, size_t istride
, size_t pstride
)
65 cover_render_character
<2>(fb
, x
, y
, ch
, fg
, bg
, w
, h
, istride
);
67 cover_render_character
<3>(fb
, x
, y
, ch
, fg
, bg
, w
, h
, istride
);
69 cover_render_character
<4>(fb
, x
, y
, ch
, fg
, bg
, w
, h
, istride
);
72 void cover_render_string(void* fb
, unsigned x
, unsigned y
, const std::string
& str
, uint32_t fg
, uint32_t bg
,
73 size_t w
, size_t h
, size_t istride
, size_t pstride
)
75 utf8::to32i(str
.begin(), str
.end(), lambda_output_iterator
<int32_t>([fb
, &x
, &y
, fg
, bg
, w
, h
, istride
,
78 cover_render_character(fb
, x
, y
, u
, fg
, bg
, w
, h
, istride
, pstride
);
79 cover_next_position(u
, x
, y
);
83 void cover_next_position(uint32_t ch
, unsigned& x
, unsigned& y
)
86 x
= (x
+ 63) >> 6 << 6;
91 const framebuffer::font::glyph
& g
= main_font
.get_glyph(ch
);
92 x
= x
+ (g
.wide
? 16 : 8);
96 void cover_next_position(const std::string
& str
, unsigned& x
, unsigned& y
)
98 utf8::to32i(str
.begin(), str
.end(), lambda_output_iterator
<int32_t>([&x
, &y
](int32_t u
) {
99 cover_next_position(u
, x
, y
);
103 std::vector
<std::string
> cover_information()
105 std::vector
<std::string
> ret
;
106 ret
.push_back("System: " + our_rom
.rtype
->get_hname() + " (" + our_rom
.region
->get_hname() + ")");