2 * (C) GraÅžvydas "notaz" Ignotas, 2011
4 * This work is licensed under the terms of any of these licenses
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.
12 #include "../../frontend/plugin_lib.h"
13 #include "../../frontend/cspace.h"
15 static const struct rearmed_cbs *cbs;
16 static void *screen_buf;
28 static void blit(void)
30 static uint32_t old_status;
32 int x = gpu.screen.x & ~1; // alignment needed by blitter
36 uint16_t *vram = gpu.vram;
37 int stride = gpu.screen.hres;
41 fb_offs = y * 1024 + x;
43 if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) // width|rgb24 change?
45 old_status = gpu.status.reg;
47 screen_buf = cbs->pl_vout_set_mode(stride, h, gpu.status.rgb24 ? 24 : 16);
50 dest = (uint8_t *)screen_buf;
52 // only do centering, at least for now
53 doffs = (stride - w) / 2 & ~1;
58 dest += (doffs / 8) * 24;
59 for (; h-- > 0; dest += stride * 3, fb_offs += 1024)
61 fb_offs &= 1024*512-1;
62 bgr888_to_rgb888(dest, vram + fb_offs, w * 3);
66 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
68 fb_offs &= 1024*512-1;
69 bgr888_to_rgb565(dest, vram + fb_offs, w * 3);
76 for (; h-- > 0; dest += stride * 2, fb_offs += 1024)
78 fb_offs &= 1024*512-1;
79 bgr555_to_rgb565(dest, vram + fb_offs, w * 2);
83 screen_buf = cbs->pl_vout_flip();
86 void GPUupdateLace(void)
88 if (gpu.status.blanking || !gpu.state.fb_dirty)
91 if (gpu.frameskip.set) {
92 if (!gpu.frameskip.frame_ready) {
93 if (*gpu.state.frame_count - gpu.frameskip.last_flip_frame < 9)
96 gpu.frameskip.frame_ready = 0;
99 renderer_flush_queues();
101 gpu.state.fb_dirty = 0;
106 gpu.frameskip.active = 0;
107 gpu.frameskip.frame_ready = 1;
110 screen_buf = cbs->pl_vout_flip();
116 cbs->pl_vout_close();
120 void GPUrearmedCallbacks(const struct rearmed_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;
131 // vim:shiftwidth=2:expandtab