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" |
72228559 |
19 | #include "pcnt.h" |
b60f2812 |
20 | |
21 | // misc globals |
22 | int iResX; |
23 | int iResY; |
24 | long lLowerpart; |
25 | BOOL bIsFirstFrame = TRUE; |
26 | BOOL bCheckMask = FALSE; |
27 | unsigned short sSetMask = 0; |
28 | unsigned long lSetMask = 0; |
29 | int iDesktopCol = 16; |
30 | int iShowFPS = 0; |
31 | int iWinSize; |
32 | int iMaintainAspect = 0; |
33 | int iUseNoStretchBlt = 0; |
34 | int iFastFwd = 0; |
35 | int iFVDisplay = 0; |
36 | PSXPoint_t ptCursorPoint[8]; |
37 | unsigned short usCursorActive = 0; |
38 | char * pCaptionText; |
39 | |
a327967e |
40 | #ifndef __arm__ |
41 | #define bgr555_to_rgb565 memcpy |
1972732a |
42 | #define bgr888_to_rgb888 memcpy |
a327967e |
43 | #endif |
b60f2812 |
44 | |
45 | static void blit(void) |
46 | { |
a327967e |
47 | extern void bgr555_to_rgb565(void *dst, void *src, int bytes); |
1972732a |
48 | extern void bgr888_to_rgb888(void *dst, void *src, int bytes); |
d352cde2 |
49 | int x = PSXDisplay.DisplayPosition.x & ~3; // XXX: align needed by bgr*_to_... |
b60f2812 |
50 | int y = PSXDisplay.DisplayPosition.y; |
51 | int w = PreviousPSXDisplay.Range.x1; |
52 | int h = PreviousPSXDisplay.DisplayMode.y; |
1972732a |
53 | int pitch = PreviousPSXDisplay.DisplayMode.x; |
54 | unsigned short *srcs = psxVuw + y * 1024 + x; |
b60f2812 |
55 | unsigned char *dest = pl_fbdev_buf; |
56 | |
a327967e |
57 | if (w <= 0) |
58 | return; |
59 | |
b60f2812 |
60 | // TODO: clear border if centering |
61 | |
1972732a |
62 | pitch *= PSXDisplay.RGB24 ? 3 : 2; |
63 | |
b60f2812 |
64 | // account for centering |
65 | h -= PreviousPSXDisplay.Range.y0; |
66 | dest += PreviousPSXDisplay.Range.y0 / 2 * pitch; |
67 | dest += PreviousPSXDisplay.Range.x0 * 2; // XXX |
68 | |
1972732a |
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 |
b60f2812 |
77 | { |
b60f2812 |
78 | for (; h-- > 0; dest += pitch, srcs += 1024) |
79 | { |
a327967e |
80 | bgr555_to_rgb565(dest, srcs, w * 2); |
b60f2812 |
81 | } |
82 | } |
83 | } |
84 | |
b60f2812 |
85 | void DoBufferSwap(void) |
86 | { |
f2019b6e |
87 | static int fbw, fbh, fb24bpp; |
72228559 |
88 | |
b60f2812 |
89 | if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0) |
90 | return; |
91 | |
d352cde2 |
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 */ |
f2019b6e |
94 | if (PSXDisplay.DisplayMode.x != fbw || PSXDisplay.DisplayMode.y != fbh |
95 | || PSXDisplay.RGB24 != fb24bpp) { |
b60f2812 |
96 | fbw = PSXDisplay.DisplayMode.x; |
f2019b6e |
97 | fbh = PSXDisplay.DisplayMode.y; |
b60f2812 |
98 | fb24bpp = PSXDisplay.RGB24; |
99 | pl_fbdev_set_mode(fbw, fbh, fb24bpp ? 24 : 16); |
100 | } |
101 | |
72228559 |
102 | pcnt_start(PCNT_BLIT); |
b60f2812 |
103 | blit(); |
72228559 |
104 | pcnt_end(PCNT_BLIT); |
14dffdb7 |
105 | |
72228559 |
106 | pl_fbdev_flip(); |
b60f2812 |
107 | } |
108 | |
109 | void DoClearScreenBuffer(void) // CLEAR DX BUFFER |
110 | { |
111 | } |
112 | |
113 | void DoClearFrontBuffer(void) // CLEAR DX BUFFER |
114 | { |
115 | } |
116 | |
117 | static int initialize(void) |
118 | { |
119 | iDesktopCol=32; |
120 | |
121 | bUsingTWin=FALSE; |
122 | bIsFirstFrame = FALSE; // done |
123 | |
124 | if(iShowFPS) |
125 | { |
126 | iShowFPS=0; |
127 | ulKeybits|=KEY_SHOWFPS; |
128 | szDispBuf[0]=0; |
129 | BuildDispMenu(0); |
130 | } |
131 | |
132 | return 0; |
133 | } |
134 | |
135 | unsigned long ulInitDisplay(void) |
136 | { |
137 | iShowFPS=1; |
138 | initialize(); |
139 | |
140 | if (pl_fbdev_init() != 0) |
141 | return 0; |
142 | |
143 | return 1; /* ok */ |
144 | } |
145 | |
146 | void CloseDisplay(void) |
147 | { |
148 | CloseMenu(); |
149 | pl_fbdev_finish(); |
14dffdb7 |
150 | //WriteConfig(); |
b60f2812 |
151 | } |
152 | |
153 | void CreatePic(unsigned char * pMem) |
154 | { |
155 | } |
156 | |
157 | void DestroyPic(void) |
158 | { |
159 | } |
160 | |
161 | void HandleKey(int keycode) |
162 | { |
163 | } |