4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
10 #include "externals.h"
18 #include "plugin_lib.h"
25 BOOL bIsFirstFrame = TRUE;
26 BOOL bCheckMask = FALSE;
27 unsigned short sSetMask = 0;
28 unsigned long lSetMask = 0;
32 int iMaintainAspect = 0;
33 int iUseNoStretchBlt = 0;
36 PSXPoint_t ptCursorPoint[8];
37 unsigned short usCursorActive = 0;
41 #define bgr555_to_rgb565 memcpy
42 #define bgr888_to_rgb888 memcpy
45 static void blit(void)
47 extern void bgr555_to_rgb565(void *dst, void *src, int bytes);
48 extern void bgr888_to_rgb888(void *dst, void *src, int bytes);
49 int x = PSXDisplay.DisplayPosition.x & ~3; // XXX: align needed by bgr*_to_...
50 int y = PSXDisplay.DisplayPosition.y;
51 int w = PreviousPSXDisplay.Range.x1;
52 int h = PreviousPSXDisplay.DisplayMode.y;
53 int pitch = PreviousPSXDisplay.DisplayMode.x;
54 unsigned short *srcs = psxVuw + y * 1024 + x;
55 unsigned char *dest = pl_fbdev_buf;
60 // TODO: clear border if centering
62 pitch *= PSXDisplay.RGB24 ? 3 : 2;
64 // account for centering
65 h -= PreviousPSXDisplay.Range.y0;
66 dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
67 dest += PreviousPSXDisplay.Range.x0 * 2; // XXX
71 for (; h-- > 0; dest += pitch, srcs += 1024)
73 bgr888_to_rgb888(dest, srcs, w * 3);
78 for (; h-- > 0; dest += pitch, srcs += 1024)
80 bgr555_to_rgb565(dest, srcs, w * 2);
85 void DoBufferSwap(void)
87 static int fbw, fb24bpp;
89 if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0)
92 /* careful if rearranging this code, we try to set mode and flip
93 * to get the hardware apply both changes at the same time */
94 if (PSXDisplay.DisplayMode.x != fbw || PSXDisplay.RGB24 != fb24bpp) {
95 int fbh = PSXDisplay.DisplayMode.y;
96 fbw = PSXDisplay.DisplayMode.x;
97 fb24bpp = PSXDisplay.RGB24;
98 pl_fbdev_set_mode(fbw, fbh, fb24bpp ? 24 : 16);
101 pcnt_start(PCNT_BLIT);
108 void DoClearScreenBuffer(void) // CLEAR DX BUFFER
112 void DoClearFrontBuffer(void) // CLEAR DX BUFFER
116 static int initialize(void)
121 bIsFirstFrame = FALSE; // done
126 ulKeybits|=KEY_SHOWFPS;
134 unsigned long ulInitDisplay(void)
139 if (pl_fbdev_init() != 0)
145 void CloseDisplay(void)
152 void CreatePic(unsigned char * pMem)
156 void DestroyPic(void)
160 void HandleKey(int keycode)