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"
24 BOOL bIsFirstFrame = TRUE;
25 BOOL bCheckMask = FALSE;
26 unsigned short sSetMask = 0;
27 unsigned long lSetMask = 0;
31 int iMaintainAspect = 0;
32 int iUseNoStretchBlt = 0;
35 PSXPoint_t ptCursorPoint[8];
36 unsigned short usCursorActive = 0;
39 static int fbw, fbh, fb24bpp;
40 static int flip_cnt, flips_per_sec;
43 #define bgr555_to_rgb565 memcpy
44 #define bgr888_to_rgb888 memcpy
47 static void blit(void)
49 extern void bgr555_to_rgb565(void *dst, void *src, int bytes);
50 extern void bgr888_to_rgb888(void *dst, void *src, int bytes);
51 int x = PSXDisplay.DisplayPosition.x;
52 int y = PSXDisplay.DisplayPosition.y;
53 int w = PreviousPSXDisplay.Range.x1;
54 int h = PreviousPSXDisplay.DisplayMode.y;
55 int pitch = PreviousPSXDisplay.DisplayMode.x;
56 unsigned short *srcs = psxVuw + y * 1024 + x;
57 unsigned char *dest = pl_fbdev_buf;
62 // TODO: clear border if centering
64 pitch *= PSXDisplay.RGB24 ? 3 : 2;
66 // account for centering
67 h -= PreviousPSXDisplay.Range.y0;
68 dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
69 dest += PreviousPSXDisplay.Range.x0 * 2; // XXX
73 for (; h-- > 0; dest += pitch, srcs += 1024)
75 bgr888_to_rgb888(dest, srcs, w * 3);
80 for (; h-- > 0; dest += pitch, srcs += 1024)
82 bgr555_to_rgb565(dest, srcs, w * 2);
84 pl_text_out16(2, fbh - 10, "%2d %2.1f", flips_per_sec, fps_cur);
90 void DoBufferSwap(void)
92 static int fps_counter;
93 if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0)
96 if (PSXDisplay.DisplayMode.x != fbw || PSXDisplay.DisplayMode.y != fbh
97 || PSXDisplay.RGB24 != fb24bpp) {
98 fbw = PSXDisplay.DisplayMode.x;
99 fbh = PSXDisplay.DisplayMode.y;
100 fb24bpp = PSXDisplay.RGB24;
101 pl_fbdev_set_mode(fbw, fbh, fb24bpp ? 24 : 16);
113 gettimeofday(&tv, 0);
114 if (tv.tv_sec != oldsec) {
115 flips_per_sec = flip_cnt;
120 if (++fps_counter == 60/6) {
125 pcnt_start(PCNT_ALL);
128 void DoClearScreenBuffer(void) // CLEAR DX BUFFER
132 void DoClearFrontBuffer(void) // CLEAR DX BUFFER
136 static int initialize(void)
141 bIsFirstFrame = FALSE; // done
146 ulKeybits|=KEY_SHOWFPS;
154 unsigned long ulInitDisplay(void)
159 if (pl_fbdev_init() != 0)
165 void CloseDisplay(void)
172 void CreatePic(unsigned char * pMem)
176 void DestroyPic(void)
180 void HandleKey(int keycode)