1 #include "core/instance.hpp"
2 #include "core/moviedata.hpp"
3 #include "core/memorymanip.hpp"
4 #include "core/rom.hpp"
5 #include "interface/cover.hpp"
6 #include "library/minmax.hpp"
7 #include "library/utf8.hpp"
8 #include "fonts/wrapper.hpp"
13 template<size_t pstride
>
14 void cover_render_character(void* fb
, unsigned x
, unsigned y
, uint32_t ch
, uint32_t fg
, uint32_t bg
,
15 size_t w
, size_t h
, size_t istride
)
17 unsigned char* _fg
= reinterpret_cast<unsigned char*>(&fg
);
18 unsigned char* _bg
= reinterpret_cast<unsigned char*>(&bg
);
21 const framebuffer::font::glyph
& g
= main_font
.get_glyph(ch
);
22 unsigned maxw
= min((size_t)(g
.wide
? 16 : 8), (size_t)(w
- x
));
23 unsigned maxh
= min((size_t)16, (size_t)(h
- y
));
24 unsigned char* cellbase
= reinterpret_cast<unsigned char*>(fb
) + y
* istride
+ pstride
* x
;
27 for(size_t y2
= 0; y2
< maxh
; y2
++) {
28 uint32_t d
= g
.data
[y2
>> 1];
29 d
>>= 16 - ((y2
& 1) << 4);
30 for(size_t j
= 0; j
< maxw
; j
++) {
32 if(((d
>> b
) & 1) != 0) {
33 for(unsigned k
= 0; k
< pstride
; k
++)
34 cellbase
[pstride
* j
+ k
] = _fg
[k
];
36 for(unsigned k
= 0; k
< pstride
; k
++)
37 cellbase
[pstride
* j
+ k
] = _bg
[k
];
44 for(size_t y2
= 0; y2
< maxh
; y2
++) {
45 uint32_t d
= g
.data
[y2
>> 2];
46 d
>>= 24 - ((y2
& 3) << 3);
47 for(size_t j
= 0; j
< maxw
; j
++) {
49 if(((d
>> b
) & 1) != 0) {
50 for(unsigned k
= 0; k
< pstride
; k
++)
51 cellbase
[pstride
* j
+ k
] = _fg
[k
];
53 for(unsigned k
= 0; k
< pstride
; k
++)
54 cellbase
[pstride
* j
+ k
] = _bg
[k
];
63 void cover_render_character(void* fb
, unsigned x
, unsigned y
, uint32_t ch
, uint32_t fg
, uint32_t bg
, size_t w
,
64 size_t h
, size_t istride
, size_t pstride
)
67 cover_render_character
<2>(fb
, x
, y
, ch
, fg
, bg
, w
, h
, istride
);
69 cover_render_character
<3>(fb
, x
, y
, ch
, fg
, bg
, w
, h
, istride
);
71 cover_render_character
<4>(fb
, x
, y
, ch
, fg
, bg
, w
, h
, istride
);
74 void cover_render_string(void* fb
, unsigned x
, unsigned y
, const std::string
& str
, uint32_t fg
, uint32_t bg
,
75 size_t w
, size_t h
, size_t istride
, size_t pstride
)
77 utf8::to32i(str
.begin(), str
.end(), lambda_output_iterator
<int32_t>([fb
, &x
, &y
, fg
, bg
, w
, h
, istride
,
80 cover_render_character(fb
, x
, y
, u
, fg
, bg
, w
, h
, istride
, pstride
);
81 cover_next_position(u
, x
, y
);
85 void cover_next_position(uint32_t ch
, unsigned& x
, unsigned& y
)
88 x
= (x
+ 63) >> 6 << 6;
93 const framebuffer::font::glyph
& g
= main_font
.get_glyph(ch
);
94 x
= x
+ (g
.wide
? 16 : 8);
98 void cover_next_position(const std::string
& str
, unsigned& x
, unsigned& y
)
100 utf8::to32i(str
.begin(), str
.end(), lambda_output_iterator
<int32_t>([&x
, &y
](int32_t u
) {
101 cover_next_position(u
, x
, y
);
105 std::vector
<std::string
> cover_information()
108 std::vector
<std::string
> ret
;
109 ret
.push_back("System: " + core
.rom
->get_hname() + " (" + core
.rom
->region_get_hname() + ")");