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;
35 pitch *= (PSXDisplay.RGB24 && !rcbs->only_16bpp) ? 3 : 2;
37 // account for centering
38 h -= PreviousPSXDisplay.Range.y0;
39 dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
40 dest += (PreviousPSXDisplay.Range.x0 & ~3) * 2; // must align here too..
44 if (!rcbs->only_16bpp)
46 for (; h-- > 0; dest += pitch, srcs += 1024)
48 bgr888_to_rgb888(dest, srcs, w * 3);
53 for (; h-- > 0; dest += pitch, srcs += 1024)
55 bgr888_to_rgb565(dest, srcs, w * 3);
61 for (; h-- > 0; dest += pitch, srcs += 1024)
63 bgr555_to_rgb565(dest, srcs, w * 2);
68 void DoBufferSwap(void)
70 static int fbw, fbh, fb24bpp;
71 static void *vout_buf;
73 if (PreviousPSXDisplay.DisplayMode.x == 0 || PreviousPSXDisplay.DisplayMode.y == 0)
76 /* careful if rearranging this code, we try to set mode and flip
77 * to get the hardware apply both changes at the same time */
78 if (PreviousPSXDisplay.DisplayMode.x != fbw || PreviousPSXDisplay.DisplayMode.y != fbh
79 || PSXDisplay.RGB24 != fb24bpp) {
80 fbw = PreviousPSXDisplay.DisplayMode.x;
81 fbh = PreviousPSXDisplay.DisplayMode.y;
82 fb24bpp = PSXDisplay.RGB24;
83 vout_buf = rcbs->pl_vout_set_mode(fbw, fbh, fb24bpp ? 24 : 16);
86 pcnt_start(PCNT_BLIT);
87 if (rcbs->pl_vout_raw_flip != NULL)
88 rcbs->pl_vout_raw_flip(PSXDisplay.DisplayPosition.x, PSXDisplay.DisplayPosition.y);
93 vout_buf = rcbs->pl_vout_flip();
96 void DoClearScreenBuffer(void)
100 unsigned long ulInitDisplay(void)
102 if (rcbs->pl_vout_open() != 0)
108 void CloseDisplay(void)
110 rcbs->pl_vout_close();