56f08d83 |
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" |
a80ae4a0 |
13 | #include "../../frontend/cspace.h" |
56f08d83 |
14 | |
15 | static const struct rearmed_cbs *cbs; |
16 | static void *screen_buf; |
17 | |
18 | int vout_init(void) |
19 | { |
20 | return 0; |
21 | } |
22 | |
23 | int vout_finish(void) |
24 | { |
25 | return 0; |
26 | } |
27 | |
28 | static void blit(void) |
29 | { |
30 | static uint32_t old_status, old_h; |
8dd855cd |
31 | int x = gpu.screen.x & ~1; // alignment needed by blitter |
56f08d83 |
32 | int y = gpu.screen.y; |
33 | int w = gpu.screen.w; |
8dd855cd |
34 | int h = gpu.screen.h; |
35 | int stride = gpu.screen.hres; |
36 | int doffs; |
56f08d83 |
37 | uint16_t *srcs; |
38 | uint8_t *dest; |
39 | |
40 | srcs = &gpu.vram[y * 1024 + x]; |
41 | |
56f08d83 |
42 | if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) // width|rgb24 change? |
43 | { |
44 | old_status = gpu.status.reg; |
45 | old_h = h; |
9394ada5 |
46 | screen_buf = cbs->pl_vout_set_mode(stride, h, gpu.status.rgb24 ? 24 : 16); |
56f08d83 |
47 | } |
8dd855cd |
48 | |
56f08d83 |
49 | dest = screen_buf; |
50 | |
8dd855cd |
51 | // only do centering, at least for now |
52 | doffs = (stride - w) / 2 & ~1; |
53 | |
56f08d83 |
54 | if (gpu.status.rgb24) |
55 | { |
56 | #ifndef MAEMO |
8dd855cd |
57 | dest += (doffs / 8) * 24; |
58 | for (; h-- > 0; dest += stride * 3, srcs += 1024) |
56f08d83 |
59 | { |
60 | bgr888_to_rgb888(dest, srcs, w * 3); |
61 | } |
62 | #else |
8dd855cd |
63 | dest += doffs * 2; |
64 | for (; h-- > 0; dest += stride * 2, srcs += 1024) |
56f08d83 |
65 | { |
66 | bgr888_to_rgb565(dest, srcs, w * 3); |
67 | } |
68 | #endif |
69 | } |
70 | else |
71 | { |
8dd855cd |
72 | dest += doffs * 2; |
73 | for (; h-- > 0; dest += stride * 2, srcs += 1024) |
56f08d83 |
74 | { |
75 | bgr555_to_rgb565(dest, srcs, w * 2); |
76 | } |
77 | } |
78 | |
9394ada5 |
79 | screen_buf = cbs->pl_vout_flip(); |
56f08d83 |
80 | } |
81 | |
82 | void GPUupdateLace(void) |
83 | { |
19e7cf87 |
84 | if (gpu.status.blanking || !gpu.state.fb_dirty) |
fc84f618 |
85 | return; |
86 | |
ea4a16e7 |
87 | if (gpu.frameskip.set) { |
5b745e5b |
88 | if (!gpu.frameskip.frame_ready && gpu.frameskip.skipped_blits < 9) { |
19e7cf87 |
89 | gpu.frameskip.skipped_blits++; |
90 | return; |
91 | } |
92 | gpu.frameskip.frame_ready = 0; |
93 | gpu.frameskip.skipped_blits = 0; |
fc84f618 |
94 | } |
19e7cf87 |
95 | |
96 | renderer_flush_queues(); |
97 | blit(); |
98 | gpu.state.fb_dirty = 0; |
56f08d83 |
99 | } |
100 | |
101 | long GPUopen(void) |
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 | |
111 | long GPUclose(void) |
112 | { |
9394ada5 |
113 | cbs->pl_vout_close(); |
56f08d83 |
114 | return 0; |
115 | } |
116 | |
117 | void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_) |
118 | { |
119 | cbs = cbs_; |
ea4a16e7 |
120 | gpu.frameskip.set = cbs->frameskip; |
121 | gpu.frameskip.advice = &cbs->fskip_advice; |
122 | gpu.frameskip.active = 0; |
123 | gpu.frameskip.frame_ready = 1; |
56f08d83 |
124 | } |
125 | |
126 | // vim:shiftwidth=2:expandtab |