b60f2812 |
1 | /* |
2 | * (C) notaz, 2010 |
3 | * |
4 | * This work is licensed under the terms of the GNU GPLv2 or later. |
5 | * See the COPYING file in the top-level directory. |
6 | */ |
7 | |
8 | #include <stdio.h> |
9 | #include <stdlib.h> |
69af03a2 |
10 | #include <string.h> |
11 | #include <stdarg.h> |
b60f2812 |
12 | |
13 | #include "linux/fbdev.h" |
69af03a2 |
14 | #include "common/fonts.h" |
15 | #include "common/input.h" |
16 | #include "omap.h" |
17 | #include "../libpcsxcore/new_dynarec/new_dynarec.h" |
b60f2812 |
18 | |
b60f2812 |
19 | void *pl_fbdev_buf; |
69af03a2 |
20 | int keystate; |
21 | static int pl_fbdev_w; |
b60f2812 |
22 | |
23 | int pl_fbdev_init(void) |
24 | { |
69af03a2 |
25 | pl_fbdev_buf = vout_fbdev_flip(layer_fb); |
26 | return 0; |
27 | } |
b60f2812 |
28 | |
69af03a2 |
29 | int pl_fbdev_set_mode(int w, int h, int bpp) |
30 | { |
d352cde2 |
31 | void *ret; |
b60f2812 |
32 | |
69af03a2 |
33 | pl_fbdev_w = w; |
d352cde2 |
34 | |
35 | vout_fbdev_clear(layer_fb); |
69af03a2 |
36 | ret = vout_fbdev_resize(layer_fb, w, h, bpp, 0, 0, 0, 0, 3); |
d352cde2 |
37 | if (ret == NULL) |
69af03a2 |
38 | fprintf(stderr, "failed to set mode\n"); |
d352cde2 |
39 | else |
40 | pl_fbdev_buf = ret; |
41 | |
42 | return (ret != NULL) ? 0 : -1; |
69af03a2 |
43 | } |
44 | |
45 | void *pl_fbdev_flip(void) |
46 | { |
47 | /* doing input here because the pad is polled |
48 | * thousands of times for some reason */ |
49 | int actions[IN_BINDTYPE_COUNT] = { 0, }; |
b60f2812 |
50 | |
69af03a2 |
51 | in_update(actions); |
52 | if (actions[IN_BINDTYPE_EMU] & PEV_MENU) |
53 | stop = 1; |
ccf51908 |
54 | keystate = actions[IN_BINDTYPE_PLAYER12]; |
b60f2812 |
55 | |
69af03a2 |
56 | // let's flip now |
57 | pl_fbdev_buf = vout_fbdev_flip(layer_fb); |
58 | return pl_fbdev_buf; |
b60f2812 |
59 | } |
60 | |
69af03a2 |
61 | void pl_fbdev_finish(void) |
b60f2812 |
62 | { |
b60f2812 |
63 | } |
64 | |
69af03a2 |
65 | static void pl_text_out16_(int x, int y, const char *text) |
b60f2812 |
66 | { |
69af03a2 |
67 | int i, l, len = strlen(text), w = pl_fbdev_w; |
68 | unsigned short *screen = (unsigned short *)pl_fbdev_buf + x + y * w; |
69 | unsigned short val = 0xffff; |
70 | |
71 | for (i = 0; i < len; i++, screen += 8) |
72 | { |
73 | for (l = 0; l < 8; l++) |
74 | { |
75 | unsigned char fd = fontdata8x8[text[i] * 8 + l]; |
76 | unsigned short *s = screen + l * w; |
77 | if (fd&0x80) s[0] = val; |
78 | if (fd&0x40) s[1] = val; |
79 | if (fd&0x20) s[2] = val; |
80 | if (fd&0x10) s[3] = val; |
81 | if (fd&0x08) s[4] = val; |
82 | if (fd&0x04) s[5] = val; |
83 | if (fd&0x02) s[6] = val; |
84 | if (fd&0x01) s[7] = val; |
85 | } |
86 | } |
b60f2812 |
87 | } |
88 | |
69af03a2 |
89 | void pl_text_out16(int x, int y, const char *texto, ...) |
b60f2812 |
90 | { |
69af03a2 |
91 | va_list args; |
92 | char buffer[256]; |
93 | |
94 | va_start(args, texto); |
95 | vsnprintf(buffer, sizeof(buffer), texto, args); |
96 | va_end(args); |
97 | |
98 | pl_text_out16_(x, y, buffer); |
b60f2812 |
99 | } |
100 | |