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