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 | |
67 | void DoBufferSwap(void) |
68 | { |
69 | static float fps_old; |
70 | if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0) |
71 | return; |
72 | |
73 | if (PSXDisplay.DisplayMode.x != fbw || PSXDisplay.DisplayMode.y != fbh |
74 | || PSXDisplay.RGB24 != fb24bpp) { |
75 | fbw = PSXDisplay.DisplayMode.x; |
76 | fbh = PSXDisplay.DisplayMode.y; |
77 | fb24bpp = PSXDisplay.RGB24; |
78 | pl_fbdev_set_mode(fbw, fbh, fb24bpp ? 24 : 16); |
79 | } |
80 | |
81 | if (fps_cur != fps_old) { |
82 | printf("%2.1f\n", fps_cur); |
83 | fps_old = fps_cur; |
84 | } |
85 | |
86 | blit(); |
87 | pl_fbdev_flip(); |
88 | } |
89 | |
90 | void DoClearScreenBuffer(void) // CLEAR DX BUFFER |
91 | { |
92 | } |
93 | |
94 | void DoClearFrontBuffer(void) // CLEAR DX BUFFER |
95 | { |
96 | } |
97 | |
98 | static int initialize(void) |
99 | { |
100 | iDesktopCol=32; |
101 | |
102 | bUsingTWin=FALSE; |
103 | bIsFirstFrame = FALSE; // done |
104 | |
105 | if(iShowFPS) |
106 | { |
107 | iShowFPS=0; |
108 | ulKeybits|=KEY_SHOWFPS; |
109 | szDispBuf[0]=0; |
110 | BuildDispMenu(0); |
111 | } |
112 | |
113 | return 0; |
114 | } |
115 | |
116 | unsigned long ulInitDisplay(void) |
117 | { |
118 | iShowFPS=1; |
119 | initialize(); |
120 | |
121 | if (pl_fbdev_init() != 0) |
122 | return 0; |
123 | |
124 | return 1; /* ok */ |
125 | } |
126 | |
127 | void CloseDisplay(void) |
128 | { |
129 | CloseMenu(); |
130 | pl_fbdev_finish(); |
131 | } |
132 | |
133 | void CreatePic(unsigned char * pMem) |
134 | { |
135 | } |
136 | |
137 | void DestroyPic(void) |
138 | { |
139 | } |
140 | |
141 | void HandleKey(int keycode) |
142 | { |
143 | } |