drc: don't remove unused i/o reads because of FIFOs
[pcsx_rearmed.git] / plugins / dfxvideo / draw_fb.c
CommitLineData
b60f2812 1/*
2 * (C) notaz, 2010
3 *
4 * This work is licensed under the terms of the GNU GPLv2 or later.
5 * See the COPYING file in the top-level directory.
6 */
7
8#define _IN_DRAW
9
10#include "externals.h"
11#include "gpu.h"
12#include "draw.h"
13#include "prim.h"
14#include "menu.h"
15#include "interp.h"
16#include "swap.h"
17
18#include "plugin_lib.h"
19
20// misc globals
21int iResX;
22int iResY;
23long lLowerpart;
24BOOL bIsFirstFrame = TRUE;
25BOOL bCheckMask = FALSE;
26unsigned short sSetMask = 0;
27unsigned long lSetMask = 0;
28int iDesktopCol = 16;
29int iShowFPS = 0;
30int iWinSize;
31int iMaintainAspect = 0;
32int iUseNoStretchBlt = 0;
33int iFastFwd = 0;
34int iFVDisplay = 0;
35PSXPoint_t ptCursorPoint[8];
36unsigned short usCursorActive = 0;
37char * pCaptionText;
38
69af03a2 39static int fbw, fbh, fb24bpp;
40static int flip_cnt, flips_per_sec;
41
a327967e 42#ifndef __arm__
43#define bgr555_to_rgb565 memcpy
1972732a 44#define bgr888_to_rgb888 memcpy
a327967e 45#endif
b60f2812 46
47static void blit(void)
48{
a327967e 49 extern void bgr555_to_rgb565(void *dst, void *src, int bytes);
1972732a 50 extern void bgr888_to_rgb888(void *dst, void *src, int bytes);
b60f2812 51 int x = PSXDisplay.DisplayPosition.x;
52 int y = PSXDisplay.DisplayPosition.y;
53 int w = PreviousPSXDisplay.Range.x1;
54 int h = PreviousPSXDisplay.DisplayMode.y;
1972732a 55 int pitch = PreviousPSXDisplay.DisplayMode.x;
56 unsigned short *srcs = psxVuw + y * 1024 + x;
b60f2812 57 unsigned char *dest = pl_fbdev_buf;
58
a327967e 59 if (w <= 0)
60 return;
61
b60f2812 62 // TODO: clear border if centering
63
1972732a 64 pitch *= PSXDisplay.RGB24 ? 3 : 2;
65
b60f2812 66 // account for centering
67 h -= PreviousPSXDisplay.Range.y0;
68 dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
69 dest += PreviousPSXDisplay.Range.x0 * 2; // XXX
70
1972732a 71 if (PSXDisplay.RGB24)
72 {
73 for (; h-- > 0; dest += pitch, srcs += 1024)
74 {
75 bgr888_to_rgb888(dest, srcs, w * 3);
76 }
77 }
78 else
b60f2812 79 {
b60f2812 80 for (; h-- > 0; dest += pitch, srcs += 1024)
81 {
a327967e 82 bgr555_to_rgb565(dest, srcs, w * 2);
b60f2812 83 }
69af03a2 84 pl_text_out16(2, fbh - 10, "%2d %2.1f", flips_per_sec, fps_cur);
b60f2812 85 }
86}
87
14dffdb7 88#include "pcnt.h"
89
b60f2812 90void DoBufferSwap(void)
91{
14dffdb7 92 static int fps_counter;
b60f2812 93 if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0)
94 return;
95
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);
102 }
103
b60f2812 104 blit();
105 pl_fbdev_flip();
14dffdb7 106
107 pcnt_end(PCNT_ALL);
108
69af03a2 109 {
110 static int oldsec;
111 struct timeval tv;
112 flip_cnt++;
113 gettimeofday(&tv, 0);
114 if (tv.tv_sec != oldsec) {
115 flips_per_sec = flip_cnt;
116 flip_cnt = 0;
117 oldsec = tv.tv_sec;
118 }
119 }
14dffdb7 120 if (++fps_counter == 60/6) {
14dffdb7 121 pcnt_print(fps_cur);
122 fps_counter = 0;
123 }
124
125 pcnt_start(PCNT_ALL);
b60f2812 126}
127
128void DoClearScreenBuffer(void) // CLEAR DX BUFFER
129{
130}
131
132void DoClearFrontBuffer(void) // CLEAR DX BUFFER
133{
134}
135
136static int initialize(void)
137{
138 iDesktopCol=32;
139
140 bUsingTWin=FALSE;
141 bIsFirstFrame = FALSE; // done
142
143 if(iShowFPS)
144 {
145 iShowFPS=0;
146 ulKeybits|=KEY_SHOWFPS;
147 szDispBuf[0]=0;
148 BuildDispMenu(0);
149 }
150
151 return 0;
152}
153
154unsigned long ulInitDisplay(void)
155{
156 iShowFPS=1;
157 initialize();
158
159 if (pl_fbdev_init() != 0)
160 return 0;
161
162 return 1; /* ok */
163}
164
165void CloseDisplay(void)
166{
167 CloseMenu();
168 pl_fbdev_finish();
14dffdb7 169 //WriteConfig();
b60f2812 170}
171
172void CreatePic(unsigned char * pMem)
173{
174}
175
176void DestroyPic(void)
177{
178}
179
180void HandleKey(int keycode)
181{
182}