frontend: input: pass default binds as argument
[pcsx_rearmed.git] / plugins / gpulib / vout_pl.c
CommitLineData
56f08d83 1/*
1f219c7b 2 * video output handling using plugin_lib
56f08d83 3 * (C) GraÅžvydas "notaz" Ignotas, 2011
4 *
5 * This work is licensed under the terms of any of these licenses
6 * (at your option):
7 * - GNU GPL, version 2 or later.
8 * - GNU LGPL, version 2.1 or later.
9 * See the COPYING file in the top-level directory.
10 */
11
12#include "gpu.h"
62d7fa95 13#include "cspace.h"
56f08d83 14#include "../../frontend/plugin_lib.h"
56f08d83 15
16static const struct rearmed_cbs *cbs;
17static void *screen_buf;
18
19int vout_init(void)
20{
21 return 0;
22}
23
24int vout_finish(void)
25{
26 return 0;
27}
28
7d993ee2 29static void check_mode_change(void)
56f08d83 30{
6f2ee2be 31 static uint32_t old_status;
32 static int old_h;
7d993ee2 33
34 // width|rgb24 change?
35 if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || gpu.screen.h != old_h)
36 {
37 old_status = gpu.status.reg;
38 old_h = gpu.screen.h;
39 screen_buf = cbs->pl_vout_set_mode(gpu.screen.hres,
40 gpu.screen.h, gpu.status.rgb24 ? 24 : 16);
41 }
42}
43
44static void blit(void)
45{
8dd855cd 46 int x = gpu.screen.x & ~1; // alignment needed by blitter
56f08d83 47 int y = gpu.screen.y;
48 int w = gpu.screen.w;
8dd855cd 49 int h = gpu.screen.h;
5f26e402 50 uint16_t *vram = gpu.vram;
8dd855cd 51 int stride = gpu.screen.hres;
5f26e402 52 int fb_offs, doffs;
53 uint8_t *dest;
56f08d83 54
5f26e402 55 fb_offs = y * 1024 + x;
6f2ee2be 56 dest = (uint8_t *)screen_buf;
56f08d83 57
8dd855cd 58 // only do centering, at least for now
59 doffs = (stride - w) / 2 & ~1;
60
56f08d83 61 if (gpu.status.rgb24)
62 {
63#ifndef MAEMO
8dd855cd 64 dest += (doffs / 8) * 24;
5f26e402 65 for (; h-- > 0; dest += stride * 3, fb_offs += 1024)
56f08d83 66 {
5f26e402 67 fb_offs &= 1024*512-1;
68 bgr888_to_rgb888(dest, vram + fb_offs, w * 3);
56f08d83 69 }
70#else
8dd855cd 71 dest += doffs * 2;
5f26e402 72 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
56f08d83 73 {
5f26e402 74 fb_offs &= 1024*512-1;
75 bgr888_to_rgb565(dest, vram + fb_offs, w * 3);
56f08d83 76 }
77#endif
78 }
79 else
80 {
8dd855cd 81 dest += doffs * 2;
5f26e402 82 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
56f08d83 83 {
5f26e402 84 fb_offs &= 1024*512-1;
85 bgr555_to_rgb565(dest, vram + fb_offs, w * 2);
56f08d83 86 }
87 }
88
9394ada5 89 screen_buf = cbs->pl_vout_flip();
56f08d83 90}
91
5440b88e 92void vout_update(void)
56f08d83 93{
7d993ee2 94 check_mode_change();
95 if (cbs->pl_vout_raw_flip)
96 cbs->pl_vout_raw_flip(gpu.screen.x, gpu.screen.y);
97 else
98 blit();
56f08d83 99}
100
096ec49b 101long GPUopen(void **unused)
56f08d83 102{
19e7cf87 103 gpu.frameskip.active = 0;
104 gpu.frameskip.frame_ready = 1;
fc84f618 105
9394ada5 106 cbs->pl_vout_open();
107 screen_buf = cbs->pl_vout_flip();
56f08d83 108 return 0;
109}
110
111long GPUclose(void)
112{
9394ada5 113 cbs->pl_vout_close();
56f08d83 114 return 0;
115}
116
5440b88e 117void vout_set_config(const struct rearmed_cbs *cbs_)
56f08d83 118{
119 cbs = cbs_;
120}
121
122// vim:shiftwidth=2:expandtab