4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
12 #include "../gpulib/cspace.h"
13 #include "../../frontend/plugin_lib.h"
14 #include "../../frontend/pcnt.h"
18 BOOL bCheckMask = FALSE;
19 unsigned short sSetMask;
20 unsigned long lSetMask;
22 static void blit(void *vout_buf)
24 int px = PSXDisplay.DisplayPosition.x & ~1; // XXX: align needed by bgr*_to_...
25 int py = PSXDisplay.DisplayPosition.y;
26 int w = PreviousPSXDisplay.Range.x1;
27 int h = PreviousPSXDisplay.DisplayMode.y;
28 int pitch = PreviousPSXDisplay.DisplayMode.x;
29 unsigned short *srcs = psxVuw + py * 1024 + px;
30 unsigned char *dest = vout_buf;
36 pitch *= PSXDisplay.RGB24 ? 3 : 2;
38 // n900 doesn't do rgb24 for some reason
40 #define bgr888_to_rgb888 bgr888_to_rgb565
43 // account for centering
44 h -= PreviousPSXDisplay.Range.y0;
45 dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
46 dest += (PreviousPSXDisplay.Range.x0 & ~3) * 2; // must align here too..
50 for (; h-- > 0; dest += pitch, srcs += 1024)
52 bgr888_to_rgb888(dest, srcs, w * 3);
57 for (; h-- > 0; dest += pitch, srcs += 1024)
59 bgr555_to_rgb565(dest, srcs, w * 2);
64 void DoBufferSwap(void)
66 static int fbw, fbh, fb24bpp;
67 static void *vout_buf;
69 if (PreviousPSXDisplay.DisplayMode.x == 0 || PreviousPSXDisplay.DisplayMode.y == 0)
72 /* careful if rearranging this code, we try to set mode and flip
73 * to get the hardware apply both changes at the same time */
74 if (PreviousPSXDisplay.DisplayMode.x != fbw || PreviousPSXDisplay.DisplayMode.y != fbh
75 || PSXDisplay.RGB24 != fb24bpp) {
76 fbw = PreviousPSXDisplay.DisplayMode.x;
77 fbh = PreviousPSXDisplay.DisplayMode.y;
78 fb24bpp = PSXDisplay.RGB24;
79 vout_buf = rcbs->pl_vout_set_mode(fbw, fbh, fb24bpp ? 24 : 16);
82 pcnt_start(PCNT_BLIT);
83 if (rcbs->pl_vout_raw_flip != NULL)
84 rcbs->pl_vout_raw_flip(PSXDisplay.DisplayPosition.x, PSXDisplay.DisplayPosition.y);
89 vout_buf = rcbs->pl_vout_flip();
92 void DoClearScreenBuffer(void)
96 unsigned long ulInitDisplay(void)
98 if (rcbs->pl_vout_open() != 0)
104 void CloseDisplay(void)
106 rcbs->pl_vout_close();