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 "plugin_lib.h"
17 BOOL bCheckMask = FALSE;
18 unsigned short sSetMask;
19 unsigned long lSetMask;
22 #define bgr555_to_rgb565 memcpy
23 #define bgr888_to_rgb888 memcpy
26 static void blit(void)
28 extern void bgr555_to_rgb565(void *dst, void *src, int bytes);
29 extern void bgr888_to_rgb888(void *dst, void *src, int bytes);
30 int px = PSXDisplay.DisplayPosition.x & ~3; // XXX: align needed by bgr*_to_...
31 int py = PSXDisplay.DisplayPosition.y;
32 int w = PreviousPSXDisplay.Range.x1;
33 int h = PreviousPSXDisplay.DisplayMode.y;
34 int pitch = PreviousPSXDisplay.DisplayMode.x;
35 unsigned short *srcs = psxVuw + py * 1024 + px;
36 unsigned char *dest = pl_fbdev_buf;
41 // TODO: clear border if centering?
43 pitch *= PSXDisplay.RGB24 ? 3 : 2;
45 // account for centering
46 h -= PreviousPSXDisplay.Range.y0;
47 dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
48 dest += (PreviousPSXDisplay.Range.x0 & ~3) * 2; // must align here too..
52 for (; h-- > 0; dest += pitch, srcs += 1024)
54 bgr888_to_rgb888(dest, srcs, w * 3);
59 for (; h-- > 0; dest += pitch, srcs += 1024)
61 bgr555_to_rgb565(dest, srcs, w * 2);
66 void DoBufferSwap(void)
68 static int fbw, fbh, fb24bpp;
70 if (PreviousPSXDisplay.DisplayMode.x == 0 || PreviousPSXDisplay.DisplayMode.y == 0)
73 /* careful if rearranging this code, we try to set mode and flip
74 * to get the hardware apply both changes at the same time */
75 if (PreviousPSXDisplay.DisplayMode.x != fbw || PreviousPSXDisplay.DisplayMode.y != fbh
76 || PSXDisplay.RGB24 != fb24bpp) {
77 fbw = PreviousPSXDisplay.DisplayMode.x;
78 fbh = PreviousPSXDisplay.DisplayMode.y;
79 fb24bpp = PSXDisplay.RGB24;
80 pl_fbdev_set_mode(fbw, fbh, fb24bpp ? 24 : 16);
83 pcnt_start(PCNT_BLIT);
90 void DoClearScreenBuffer(void)
94 unsigned long ulInitDisplay(void)
96 if (pl_fbdev_open() != 0)
102 void CloseDisplay(void)