psxbios: make noisy bios prints optional
[pcsx_rearmed.git] / plugins / dfxvideo / draw_fb.c
... / ...
CommitLineData
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#include "pcnt.h"
20
21// misc globals
22int iResX;
23int iResY;
24long lLowerpart;
25BOOL bIsFirstFrame = TRUE;
26BOOL bCheckMask = FALSE;
27unsigned short sSetMask = 0;
28unsigned long lSetMask = 0;
29int iDesktopCol = 16;
30int iShowFPS = 0;
31int iWinSize;
32int iMaintainAspect = 0;
33int iUseNoStretchBlt = 0;
34int iFastFwd = 0;
35int iFVDisplay = 0;
36PSXPoint_t ptCursorPoint[8];
37unsigned short usCursorActive = 0;
38char * pCaptionText;
39
40#ifndef __arm__
41#define bgr555_to_rgb565 memcpy
42#define bgr888_to_rgb888 memcpy
43#endif
44
45static void blit(void)
46{
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;
56
57 if (w <= 0)
58 return;
59
60 // TODO: clear border if centering
61
62 pitch *= PSXDisplay.RGB24 ? 3 : 2;
63
64 // account for centering
65 h -= PreviousPSXDisplay.Range.y0;
66 dest += PreviousPSXDisplay.Range.y0 / 2 * pitch;
67 dest += PreviousPSXDisplay.Range.x0 * 2; // XXX
68
69 if (PSXDisplay.RGB24)
70 {
71 for (; h-- > 0; dest += pitch, srcs += 1024)
72 {
73 bgr888_to_rgb888(dest, srcs, w * 3);
74 }
75 }
76 else
77 {
78 for (; h-- > 0; dest += pitch, srcs += 1024)
79 {
80 bgr555_to_rgb565(dest, srcs, w * 2);
81 }
82 }
83}
84
85void DoBufferSwap(void)
86{
87 static int fbw, fb24bpp;
88
89 if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0)
90 return;
91
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);
99 }
100
101 pcnt_start(PCNT_BLIT);
102 blit();
103 pcnt_end(PCNT_BLIT);
104
105 pl_fbdev_flip();
106}
107
108void DoClearScreenBuffer(void) // CLEAR DX BUFFER
109{
110}
111
112void DoClearFrontBuffer(void) // CLEAR DX BUFFER
113{
114}
115
116static int initialize(void)
117{
118 iDesktopCol=32;
119
120 bUsingTWin=FALSE;
121 bIsFirstFrame = FALSE; // done
122
123 if(iShowFPS)
124 {
125 iShowFPS=0;
126 ulKeybits|=KEY_SHOWFPS;
127 szDispBuf[0]=0;
128 BuildDispMenu(0);
129 }
130
131 return 0;
132}
133
134unsigned long ulInitDisplay(void)
135{
136 iShowFPS=1;
137 initialize();
138
139 if (pl_fbdev_init() != 0)
140 return 0;
141
142 return 1; /* ok */
143}
144
145void CloseDisplay(void)
146{
147 CloseMenu();
148 pl_fbdev_finish();
149 //WriteConfig();
150}
151
152void CreatePic(unsigned char * pMem)
153{
154}
155
156void DestroyPic(void)
157{
158}
159
160void HandleKey(int keycode)
161{
162}