Replace Tmem_nasm.asm with C++ code. Patch by pyro.
[Glide64.git] / ToolTips.cpp
blobb7f273e2b4975ba247ab0368a11bd02242ee4c56
1 /*
2 * Glide64 - Glide video plugin for Nintendo 64 emulators.
3 * Copyright (c) 2002 Dave2001
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //****************************************************************
22 // Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64)
23 // Project started on December 29th, 2001
25 // To modify Glide64:
26 // * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
27 // * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
29 // Official Glide64 development channel: #Glide64 on EFnet
31 // Original author: Dave2001 (Dave2999@hotmail.com)
32 // Other authors: Gonetz, Gugaman
34 //****************************************************************
36 #include "Gfx1.3.h"
38 #ifdef GCC
39 #include <stdio.h>
40 #endif
42 HWND g_hwndDlg = NULL;
44 #ifdef USE_TOOLTIPS
46 #include "resource.h"
47 #include "ToolTips.h"
49 BOOL EnumChildProc(HWND hwndCtrl, LPARAM lParam);
50 LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam);
51 VOID OnWMNotify(LPARAM lParam);
53 HINSTANCE g_hinst = NULL;
54 HWND g_hwndTT = NULL;
55 HHOOK g_hhk = NULL;
57 typedef struct TOOLTIPMSG_t {
58 int id, id_alt;
59 char *title;
60 char *text;
61 } TOOLTIPMSG;
63 char gctitle[] = "Glide card #";
64 char gcmsg[] = "This option is only for users with multiple glide cards installed in one "
65 "machine. This selects the glide card number to use. If you only have one glide card "
66 "installed in your system, set this option to #1. Otherwise, select the number that "
67 "corresponds to the glide card you want to use.\n"
68 "[recommended: #1 if only one glide card present]";
70 #define NUM_MSG 39
71 TOOLTIPMSG ttmsg[NUM_MSG] = {
72 { IDC_AUTODETECT, 0,
73 "Autodetect Microcode",
74 "If this option is checked, the microcode of the game "
75 "will be detected automatically from the INI, and "
76 "therefore it will not need to be set in this "
77 "configuration dialog.\n"
78 "[recommended: on]" },
79 { IDC_UCODE, IDC_UCODE_T,
80 "Force Microcode",
81 "This option ONLY has an effect if Autodetect Microcode "
82 "is unchecked, the crc from the game could not be "
83 "found in the INI, OR after the game has already started "
84 "running. In any of those three cases, this will "
85 "select the microcode to use\n"
86 "[recommended: any, turn on Autodetect Microcode]" },
87 { IDC_RESOLUTION, IDC_RESOLUTION_T,
88 "Resolution",
89 "This option selects the resolution to set when switching to fullscreen mode "
90 "(note again that the plugin must be in fullscreen mode to see anything).\n"
91 "[recommended: 640x480, 800x600, 1024x768]" },
92 { IDC_WIREFRAME, 0,
93 "Wireframe",
94 "This option, when checked, makes it so that the plugin will draw only the "
95 "outlines of objects. The colors specified in the combo box to the right "
96 "determines the color that the wireframes show up as.\n"
97 "[recommended: off]" },
98 { IDC_WFMODE, 0,
99 "Wireframe Colors",
100 "This selects the colors to use for the wireframes (if wireframe mode is enabled). "
101 "There are 3 modes:\n"
102 "* Original colors - draw exactly as it would normally, textures and all, only "
103 "in wireframes.\n"
104 "* Vertex colors - use the colors specified in the vertices to draw the wireframes "
105 "with.\n"
106 "* Red only - use a constant red color to draw the wireframes.\n"
107 "[recommended: Vertex colors]" },
108 { IDC_LOD, 0,
109 "Per-pixel level-of-detail calculation",
110 "N64 uses special mechanism for mip-mapping, which nearly impossible to reproduce "
111 "correctly on PC hardware. This option enables approximate emulation of this feature. "
112 "For example, it is required for the Peach/Bowser portrait's transition in Super Mario 64. "
113 "There are 3 modes:\n"
114 "* off - LOD is not calculated\n"
115 "* fast - fast imprecise LOD calculation.\n"
116 "* precise - most precise LOD calculation possible, but more slow.\n"
117 "[recommended: your preference]" },
118 { IDC_FILTER, IDC_FILTER_T,
119 "Filtering mode",
120 "There are three filtering modes possible:\n\n"
121 "* Automatic filtering - filter exactly how the N64 specifies.\n"
122 "* Point-sampled filtering - causes texels to appear square and sharp.\n"
123 "* Bilinear filtering - interpolates the texture to make it appear more smooth.\n"
124 "[recommended: Force Bilinear]" },
125 { IDC_FOG, 0,
126 "Fog enabled",
127 "This option, when checked, will allow fog to be used.\n"
128 "[recommended: on]" },
129 { IDC_BUFFERCLEAR, 0,
130 "Buffer clear on every frame",
131 "If this option is checked, the buffer will be cleared (screen initialized to black) "
132 "at the beginning of each frame. If this option is disabled, the speed might increase "
133 "slightly, but some trails may appear.\n"
134 "[recommended: on]" },
135 { IDC_VSYNC, 0,
136 "Vertical Sync",
137 "This option will enable the vertical sync, which will prevent tearing. "
138 "Note: this option will ONLY have effect if vsync is set to \"Software Controlled\" "
139 "in the 3dfx Hub. (double-click the 3dfx icon in system tray).\n"
140 "[recommended: off]" },
141 { IDC_CRC, 0,
142 "Fast texture checksum calculation",
143 "This option will enable fast algorithm of checksum calculation. "
144 "Fast algorithm sometime returns the same checksum for different textures, which "
145 "causes various texture errors. Thus, use it only if you have performance problems.\n"
146 "[recommended: off]" },
147 { IDC_SWAP, IDC_SWAP_T,
148 "Buffer swapping method",
149 "There are 3 buffer swapping methods:\n\n"
150 "* old - swap buffers when vertical interrupt has occured.\n"
151 "* new - swap buffers when set of conditions is satisfied. \n"
152 " Prevents flicker on some games.\n"
153 "* hybrid - mix of first two methods.\n"
154 " Can prevent even more flickering then previous method,\n"
155 " but also can cause artefacts.\n"
156 "If you have flickering problems in a game (or graphics that don't show), "
157 "try to change swapping method.\n"
158 "[recommended: new (hybrid for Paper Mario)]" },
159 { IDC_LOGGING, 0,
160 "Log to RDP.txt",
161 "RECOMMENDED FOR DEBUGGING ONLY - this option, when checked, will log EVERY SINGLE "
162 "COMMAND the plugin processes to a file called RDP.txt in the current directory. "
163 "This is incredibly slow, so I recommend keeping it disabled.\n"
164 "[recommended: off]" },
165 { IDC_LOGCLEAR, 0,
166 "Log clear every frame",
167 "RECOMMENDED FOR DEBUGGING ONLY - this option has no effect unless 'Log to RDP.txt' "
168 "is checked. This will make it so that the log, RDP.txt, will be cleared at the "
169 "beginning of every frame.\n"
170 "[recommended: off]" },
171 { IDC_RUNINWINDOW, 0,
172 "Run and log in window",
173 "RECOMMENDED FOR DEBUGGING ONLY - this option will make it so that the plugin will "
174 "still process dlists in windowed mode. This allows for logging to occur while not "
175 "in fullscreen, possibly allowing you to debug a crash.\n"
176 "[recommended: off]" },
177 { IDC_CACHEFILTER, 0,
178 "Bilinear filter texture cache",
179 "RECOMMENDED FOR DEBUGGING ONLY - when checked, this option will make the graphical "
180 "debugger texture cache use bilinear filtering as opposed to point-sampled filtering, "
181 "which it will use otherwise. See 'Filtering mode' for descriptions of bilinear and "
182 "point-sampled filtering.\n"
183 "[recommended: off]" },
184 { IDC_UNKRED, 0,
185 "Unknown combiners as red",
186 "Objects that use an unimplemented combine mode will show up as red instead of "
187 "assuming texture with full alpha. Disable this option to remove the red stuff "
188 "and at least have a guess at the correct combine mode.\n"
189 "[recommended: off]" },
190 { IDC_LOGUNK, 0,
191 "Log unknown combiners",
192 "RECOMMENDED FOR DEBUGGING ONLY - when checked, this option will cause every "
193 "unimplemented combiner drawn to be logged to a file called Unimp.txt in the "
194 "current directory. This becomes slow when there are unimplemented combiners "
195 "on the screen, so I recommend keeping it disabled.\n"
196 "[recommended: off]" },
197 { IDC_UNKCLEAR, 0,
198 "Clear unknown combiner log every frame",
199 "RECOMMENDED FOR DEBUGGING ONLY - this option works much like 'Log clear every "
200 "frame' except it clears the combiner log (Unimp.txt) instead of RDP.txt at the "
201 "beginning of each frame. Again, this option has no effect if 'combiner logging' "
202 "is disabled.\n"
203 "[recommended: off]" },
204 { IDC_GID1, IDC_GID2,
205 gctitle, gcmsg },
206 { IDC_GID3, IDC_GID4,
207 gctitle, gcmsg },
209 { IDC_FPS, 0,
210 "FPS counter",
211 "When this option is checked, a FPS (frames per second) counter will be shown "
212 "in the lower left corner of the screen.\n"
213 "[recommended: your preference]" },
214 { IDC_FPS1, 0,
215 "VI/s counter",
216 "When this option is checked, a VI/s (vertical interrupts per second) counter "
217 "will be shown in the lower left corner of the screen. This is like the FPS "
218 "counter but will be consistent at 60 VI/s for full speed on NTSC (U) games and "
219 "50 VI/s for full speed on PAL (E) ones.\n"
220 "[recommended: your preference]" },
221 { IDC_FPS2, 0,
222 "% speed NTSC",
223 "This displays a percentage of the actual N64 speed in the lower "
224 "left corner of the screen.\n"
225 "[recommended: your preference]" },
226 { IDC_FPS3, 0,
227 "FPS transparent",
228 "If this is checked, the FPS counter will have a transparent background. Otherwise, "
229 "it will have a solid black background.\n"
230 "[reccomended: your preference]" },
231 { IDC_WRAP_BIG_TEX, 0,
232 "Wrap textures which are too big for tmem",
233 "This option can fix load of textures which can't fit their place in N64 texture memory. "
234 "Example: trees in Zelda MM intro.\n"
235 "[reccomended: mostly on]" },
236 { IDC_CUSTOM, 0,
237 "Use custom settings from the ini file",
238 "Most of settings, available on this page, can be set individually for each game. "
239 "If this option is on, custom settings will override common ones. "
240 "This is very useful since you won't have to change or even pick out the best settings for a game "
241 "because it is already done for you. However, if you want to run games with your own settings, set it off. "
242 "The following settings are set in custom part: filtering mode, depth buffer mode, fog, "
243 "buffer clear, buffer swapping mode, smart frame buffer read, "
244 "depth buffer clear and frame buffer read alpha.\n"
245 "[reccomended: on]" },
246 { IDC_HOTKEYS, 0,
247 "Enable hotkeys",
248 "Currently Glide64 uses 4 hotkeys which you can use during gameplay:\n"
249 "BACKSPACE - switch between filtering modes\n"
250 "ALT+V - frame buffer read always on/off\n"
251 "ALT+B - motion blur on/off\n"
252 "ALT+C - corona fix on/off\n"
253 "If you need to use these keys for other purposes, disable this option.\n"
254 "[reccomended: on]" },
255 { IDC_WRAPPER, 0,
256 "Glide wrapper configuration",
257 "If you are using Hacktarux's glide wrapper, press this button to configure it" },
258 { IDC_CORONA, 0,
259 "Fix for flame's corona in Zelda OOT and Zelda MM",
260 "By default corona will be drawn without depth compare, i.e. can be seen through the objects. "
261 "This option fixes it. However, it's better to use depth buffer render instead, "
262 "to correctly emulate this effect.\n"
263 "[reccomended: on for slow PC]" },
265 { IDC_RE2_VIDEO, 0,
266 "Show Resident Evil II videos in native resolution",
267 "Video in RE2 is not of good quality, and it's clearly visible when video is scaled up to PC resolution. "
268 "This option allows you to watch RE2 videos as is, i.e. without scaling and quality loss.\n"
269 "[reccomended: your preference]" },
271 { IDC_CLOCK, 0,
272 "Clock enabled",
273 "This option will put a clock in the lower right corner of the screen, showing the current "
274 "time.\n"
275 "[reccomended: your preference]" },
276 { IDC_FB_READ_ALWAYS, 0,
277 "Read every frame",
278 "In some games plugin can't detect frame buffer usage. "
279 "In such case you need to enable this option to see frame buffer effects. "
280 "Every drawn frame will be read from video card -> it works very slow.\n"
281 "[reccomended: mostly off (needed only for a few games)]" },
282 { IDC_FB_ALPHA, 0,
283 "Read with alpha information",
284 "N64 keeps alpha information in its frame buffer, Glide64 does not. "
285 "In rare cases this information is vital. Example: Pokemon Puzzle League. "
286 "When this option is on, all black pixels readed from frame buffer will have zero alpha.\n"
287 "[reccomended: off]" },
288 { IDC_FB_SMART, 0,
289 "Smart frame buffer reading",
290 "If on, plugin will try to detect frame buffer usage and read frame from video card only when it's needed.\n"
291 "[reccomended: on for games which uses frame buffer effects]" },
292 { IDC_ENABLEMB, 0,
293 "Enable motion blur effect",
294 "Some games use frame buffer for motion blur effect. "
295 "It looks very cool, but may work slow since every frame must be read during this effect.\n"
296 "[reccomended: your preference]" },
297 { IDC_HIRESFB, 0,
298 "Enable hardware frame buffer emulation",
299 "If this option is on, plugin will create auxilary frame buffers in video memory instead of copying "
300 "frame buffer content into main memory. This allows plugin to run frame buffer effects without slowdown "
301 "and without scaling image down to N64's native resolution. This feature is fully supported by "
302 "Voodoo 4/5 cards and partially by Voodoo3 and Banshee.\n"
303 "[reccomended: on, if supported by your hardware]" },
304 { IDC_FB_INFO, 0,
305 "Get information about frame buffers",
306 "This is compatibility option. It must be set on for Mupen64 and off for 1964\n" },
307 { IDC_DB_CLEAR, 0,
308 "Enable depth buffer clear",
309 "Some special effects work only if N64 depth buffer filled with correct values. "
310 "Example: Lens flare from the sun in Zelda. This option enables these effects."
311 "You may set it off to save a bit of CPU time.\n"
312 "[reccomended: on]" },
313 { IDC_DB_RENDER, 0,
314 "Enable depth buffer rendering",
315 "This option works in conjunction with depth buffer clear to fully emulate N64 depth buffer. "
316 "It is required for correct emulation of depth buffer based effects. "
317 "However, it requires fast CPU to work full speed.\n"
318 "[reccomended: on for fast PC]" },
321 // ** TOOLTIP CODE FROM MSDN LIBRARY SAMPLE WITH SEVERAL MODIFICATIONS **
323 // DoCreateDialogTooltip - creates a tooltip control for a dialog box,
324 // enumerates the child control windows, and installs a hook
325 // procedure to monitor the message stream for mouse messages posted
326 // to the control windows.
327 // Returns TRUE if successful, or FALSE otherwise.
329 // Global variables
330 // g_hinst - handle to the application instance.
331 // g_hwndTT - handle to the tooltip control.
332 // g_hwndDlg - handle to the dialog box.
333 // g_hhk - handle to the hook procedure.
335 BOOL DoCreateDialogTooltip(void)
337 // Ensure that the common control DLL is loaded, and create
338 // a tooltip control.
339 InitCommonControls();
340 g_hwndTT = CreateWindowEx(0, TOOLTIPS_CLASS, (LPSTR) NULL,
341 TTS_ALWAYSTIP|/*TTS_BALLOON*/0x40, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
342 CW_USEDEFAULT, g_hwndDlg, (HMENU) NULL, g_hinst, NULL);
344 if (g_hwndTT == NULL)
345 return FALSE;
347 // Enumerate the child windows to register them with the tooltip
348 // control.
349 if (!EnumChildWindows(g_hwndDlg, (WNDENUMPROC) EnumChildProc, 0))
350 return FALSE;
352 // Install a hook procedure to monitor the message stream for mouse
353 // messages intended for the controls in the dialog box.
354 g_hhk = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc,
355 (HINSTANCE) NULL, GetCurrentThreadId());
357 if (g_hhk == (HHOOK) NULL)
358 return FALSE;
360 return TRUE;
363 // EmumChildProc - registers control windows with a tooltip control by
364 // using the TTM_ADDTOOL message to pass the address of a
365 // TOOLINFO structure.
366 // Returns TRUE if successful, or FALSE otherwise.
367 // hwndCtrl - handle of a control window.
368 // lParam - application-defined value (not used).
369 BOOL EnumChildProc(HWND hwndCtrl, LPARAM lParam)
371 TOOLINFO ti;
373 ti.cbSize = sizeof(TOOLINFO);
374 ti.uFlags = TTF_IDISHWND;
375 ti.hwnd = g_hwndDlg;
376 ti.uId = (UINT) hwndCtrl;
377 ti.hinst = 0;
378 ti.lpszText = LPSTR_TEXTCALLBACK;
379 SendMessage(g_hwndTT, TTM_ADDTOOL, 0,
380 (LPARAM) (LPTOOLINFO) &ti);
381 return TRUE;
384 // GetMsgProc - monitors the message stream for mouse messages intended
385 // for a control window in the dialog box.
386 // Returns a message-dependent value.
387 // nCode - hook code.
388 // wParam - message flag (not used).
389 // lParam - address of an MSG structure.
390 LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
392 MSG *lpmsg;
394 lpmsg = (MSG *) lParam;
395 if (nCode < 0 || !(IsChild(g_hwndDlg, lpmsg->hwnd)))
396 return (CallNextHookEx(g_hhk, nCode, wParam, lParam));
398 switch (lpmsg->message) {
399 case WM_MOUSEMOVE:
400 case WM_LBUTTONDOWN:
401 case WM_LBUTTONUP:
402 case WM_RBUTTONDOWN:
403 case WM_RBUTTONUP:
404 if (g_hwndTT != NULL) {
405 MSG msg;
407 int idCtrl = GetDlgCtrlID((HWND)lpmsg->hwnd);
409 msg.lParam = lpmsg->lParam;
410 msg.wParam = lpmsg->wParam;
411 msg.message = lpmsg->message;
412 msg.hwnd = lpmsg->hwnd;
413 SendMessage(g_hwndTT, TTM_RELAYEVENT, 0,
414 (LPARAM) (LPMSG) &msg);
415 #ifdef TTM_SETMAXTIPWIDTH
416 SendMessage(g_hwndTT, TTM_SETMAXTIPWIDTH, 0, 300);
417 #endif
418 SendMessage(g_hwndTT, TTM_SETDELAYTIME, TTDT_INITIAL, (LPARAM)MAKELONG(500,0));
419 SendMessage(g_hwndTT, TTM_SETDELAYTIME, TTDT_AUTOPOP, (LPARAM)MAKELONG(32000,0));
421 for (int i=0; i<NUM_MSG; i++)
423 if (idCtrl == ttmsg[i].id ||
424 idCtrl == ttmsg[i].id_alt)
426 SendMessage(g_hwndTT, /*TTM_SETTITLE*/(WM_USER + 32), 1, (LPARAM)ttmsg[i].title);
427 break;
431 break;
432 default:
433 break;
435 return (CallNextHookEx(g_hhk, nCode, wParam, lParam));
439 // OnWMNotify - provides the tooltip control with the appropriate text
440 // to display for a control window. This function is called by
441 // the dialog box procedure in response to a WM_NOTIFY message.
442 // lParam - second message parameter of the WM_NOTIFY message.
443 VOID OnWMNotify(LPARAM lParam)
445 LPTOOLTIPTEXT lpttt;
446 int idCtrl;
448 if ((((LPNMHDR) lParam)->code) == TTN_NEEDTEXT) {
449 idCtrl = GetDlgCtrlID((HWND) ((LPNMHDR) lParam)->idFrom);
450 lpttt = (LPTOOLTIPTEXT) lParam;
452 for (int i=0; i<NUM_MSG; i++)
454 if (idCtrl == ttmsg[i].id ||
455 idCtrl == ttmsg[i].id_alt)
457 lpttt->lpszText = ttmsg[i].text;
458 return;
462 return;
466 #endif /* USE_TOOLTIPS */