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