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