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