1 /*
2 * PUAE - The Un*x Amiga Emulator
3 *
4 * A collection of ugly and random stuff brought in from Win32
5 * which desparately needs to be tidied up
6 *
7 * Copyright 2004 Richard Drummond
8 * Copyright 2010-2013 Mustafa TUFAN
9 */
10
11 #include "sysconfig.h"
12 #include "sysdeps.h"
13
14 #include "misc.h"
15 #include "cfgfile.h"
16 #include "memory_uae.h"
17 #include "custom.h"
18 #include "newcpu.h"
19 #include "events.h"
20 #include "uae.h"
21 #include "autoconf.h"
22 #include "traps.h"
23 #include "enforcer.h"
24 #include "picasso96.h"
25 #include "driveclick.h"
26 #include "inputdevice.h"
27 #include "keymap/keymap.h"
28 #include "keyboard.h"
29 #include <stdarg.h>
30 #include "clipboard.h"
31 #include "fsdb.h"
32 #include "debug.h"
33 #include "hrtimer.h"
34 #include "sleep.h"
35 #include "zfile.h"
36
37 // this is handled by the graphics drivers and set up in picasso96.c
38 #if defined(PICASSO96)
39 extern int screen_is_picasso;
40 #else
41 static int screen_is_picasso = 0;
42 #endif
43
44 uae_u32 redc[3 * 256], grec[3 * 256], bluc[3 * 256];
45
46 #define VBLANKTH_KILL 0
47 #define VBLANKTH_CALIBRATE 1
48 #define VBLANKTH_IDLE 2
49 #define VBLANKTH_ACTIVE_WAIT 3
50 #define VBLANKTH_ACTIVE 4
51 #define VBLANKTH_ACTIVE_START 5
52 #define VBLANKTH_ACTIVE_SKIPFRAME 6
53 #define VBLANKTH_ACTIVE_SKIPFRAME2 7
54
55 static volatile frame_time_t vblank_prev_time;
56
57 struct winuae_currentmode {
58 unsigned int flags;
59 int native_width, native_height, native_depth, pitch;
60 int current_width, current_height, current_depth;
61 int amiga_width, amiga_height;
62 int frequency;
63 int initdone;
64 int fullfill;
65 int vsync;
66 };
67
68 static struct winuae_currentmode currentmodestruct;
69 static struct winuae_currentmode *currentmode = ¤tmodestruct;
70 #ifndef _WIN32
71 typedef struct {
72 WORD dmSize;
73 WORD dmDriverExtra;
74 DWORD dmFields;
75 DWORD dmBitsPerPel;
76 DWORD dmPelsWidth;
77 DWORD dmPelsHeight;
78 DWORD dmDisplayFlags;
79 DWORD dmDisplayFrequency;
80 } DEVMODE;
81 #endif
82 /* internal prototypes */
83 void setmouseactivexy (int x, int y, int dir);
84 int get_guid_target (uae_u8 *out);
85 uae_u8 *save_log (int bootlog, int *len);
86 void refreshtitle (void);
87 int scan_roms (int show);
88 void setid (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt);
89 void setid_af (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt, int af);
90 void fetch_path (TCHAR *name, TCHAR *out, int size);
91 void fetch_screenshotpath (TCHAR *out, int size);
92 struct MultiDisplay *getdisplay (struct uae_prefs *p);
93 void addmode (struct MultiDisplay *md, DEVMODE *dm, int rawmode);
94 void updatedisplayarea (void);
95
96 /* external prototypes */
97 extern void setmaintitle(void);
98 extern int isvsync_chipset (void);
99 extern int isvsync_rtg (void);
100
101
getgfxoffset(int * dxp,int * dyp,int * mxp,int * myp)102 void getgfxoffset (int *dxp, int *dyp, int *mxp, int *myp)
103 {
104 *dxp = 0;
105 *dyp = 0;
106 *mxp = 0;
107 *myp = 0;
108 }
109
vsync_switchmode(int hz)110 int vsync_switchmode (int hz)
111 {
112 #ifndef __LIBRETRO__
113 static struct PicassoResolution *oldmode;
114 static int oldhz;
115 int w = currentmode->native_width;
116 int h = currentmode->native_height;
117 int d = currentmode->native_depth / 8;
118 struct MultiDisplay *md = getdisplay (&currprefs);
119 struct PicassoResolution *found;
120 int newh, i, cnt;
121
122 newh = h * (currprefs.ntscmode ? 60 : 50) / hz;
123
124 found = NULL;
125 for (cnt = 0; cnt <= abs (newh - h) + 1 && !found; cnt++) {
126 for (i = 0; md->DisplayModes[i].depth >= 0 && !found; i++) {
127 struct PicassoResolution *r = &md->DisplayModes[i];
128 if ( (r->res.width == (uae_u32)w)
129 && ( (r->res.height == (uae_u32)(newh + cnt))
130 || (r->res.height == (uae_u32)(newh - cnt)) )
131 && (r->depth == d) ) {
132 int j = 0;
133 for ( ; r->refresh[j] > 0; j++) {
134 if (r->refresh[j] == hz || r->refresh[j] == hz * 2) {
135 found = r;
136 hz = r->refresh[j];
137 break;
138 }
139 }
140 }
141 }
142 }
143 if (found == oldmode && hz == oldhz)
144 return true;
145 oldmode = found;
146 oldhz = hz;
147 if (!found) {
148 changed_prefs.gfx_apmode[0].gfx_vsync = 0;
149 if (currprefs.gfx_apmode[0].gfx_vsync != changed_prefs.gfx_apmode[0].gfx_vsync) {
150 config_changed = 1;
151 }
152 write_log (_T("refresh rate changed to %d but no matching screenmode found, vsync disabled\n"), hz);
153 return false;
154 } else {
155 newh = found->res.height;
156 changed_prefs.gfx_size_fs.height = newh;
157 changed_prefs.gfx_apmode[0].gfx_refreshrate = hz;
158 if (changed_prefs.gfx_size_fs.height != currprefs.gfx_size_fs.height ||
159 changed_prefs.gfx_apmode[0].gfx_refreshrate != currprefs.gfx_apmode[0].gfx_refreshrate) {
160 write_log (_T("refresh rate changed to %d, new screenmode %dx%d\n"), hz, w, newh);
161 config_changed = 1;
162 }
163 return true;
164 }
165 #else
166 return false;
167 #endif
168 }
169
170 //win32.cpp
171 int extraframewait = 0;
172
sleep_millis_main(int ms)173 void sleep_millis_main (int ms)
174 {
175 uae_msleep (ms);
176 }
177
target_restart(void)178 void target_restart (void)
179 {
180 }
181
driveclick_fdrawcmd_close(int drive)182 void driveclick_fdrawcmd_close(int drive){}
driveclick_fdrawcmd_detect(void)183 void driveclick_fdrawcmd_detect(void){}
driveclick_fdrawcmd_seek(int drive,int cyl)184 void driveclick_fdrawcmd_seek(int drive, int cyl){}
driveclick_fdrawcmd_motor(int drive,int running)185 void driveclick_fdrawcmd_motor (int drive, int running){}
driveclick_fdrawcmd_vsync(void)186 void driveclick_fdrawcmd_vsync(void){}
187
188 // win32
emulib_target_getcpurate(uae_u32 v,uae_u32 * low)189 uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low)
190 {
191 /*
192 static struct timeval _tstart, _tend;
193 static struct timezone tz;
194
195 *low = 0;
196 if (v == 1) {
197 gettimeofday (&_tstart, &tz);
198 } else if (v == 2) {
199 gettimeofday (&_tend, &tz);
200 }
201 double t1, t2;
202
203 t1 = (double)_tstart.tv_sec + (double)_tstart.tv_usec/(1000*1000);
204 t2 = (double)_tend.tv_sec + (double)_tend.tv_usec/(1000*1000);
205 return t2-t1;
206 */
207 return 0;
208 }
209
210
setmouseactivexy(int x,int y,int dir)211 void setmouseactivexy (int x, int y, int dir)
212 {
213 /* int diff = 8;
214
215 if (isfullscreen () > 0)
216 return;
217 x += amigawin_rect.left;
218 y += amigawin_rect.top;
219 if (dir & 1)
220 x = amigawin_rect.left - diff;
221 if (dir & 2)
222 x = amigawin_rect.right + diff;
223 if (dir & 4)
224 y = amigawin_rect.top - diff;
225 if (dir & 8)
226 y = amigawin_rect.bottom + diff;
227 if (!dir) {
228 x += (amigawin_rect.right - amigawin_rect.left) / 2;
229 y += (amigawin_rect.bottom - amigawin_rect.top) / 2;
230 }
231 if (mouseactive) {
232 disablecapture ();
233 SetCursorPos (x, y);
234 if (dir)
235 recapture = 1;
236 }*/
237 }
238
setmouseactive(int active)239 void setmouseactive (int active)
240 {
241 }
242
243 // unicode
au_fs_copy(char * dst,int maxlen,const char * src)244 char *au_fs_copy (char *dst, int maxlen, const char *src)
245 {
246 int i;
247
248 for (i = 0; src[i] && i < maxlen - 1; i++)
249 dst[i] = src[i];
250 dst[i] = 0;
251 return dst;
252 }
253
254 // clipboard
255 static uaecptr clipboard_data;
256 static int signaling, initialized;
257
amiga_clipboard_die(void)258 void amiga_clipboard_die (void)
259 {
260 signaling = 0;
261 write_log ("clipboard not initialized\n");
262 }
263
amiga_clipboard_init(void)264 void amiga_clipboard_init (void)
265 {
266 signaling = 0;
267 write_log ("clipboard initialized\n");
268 initialized = 1;
269 }
270
amiga_clipboard_task_start(uaecptr data)271 void amiga_clipboard_task_start (uaecptr data)
272 {
273 clipboard_data = data;
274 signaling = 1;
275 write_log ("clipboard task init: %08x\n", clipboard_data);
276 }
277
amiga_clipboard_proc_start(void)278 uaecptr amiga_clipboard_proc_start (void)
279 {
280 write_log ("clipboard process init: %08x\n", clipboard_data);
281 signaling = 1;
282 return clipboard_data;
283 }
284
amiga_clipboard_got_data(uaecptr data,uae_u32 size,uae_u32 actual)285 void amiga_clipboard_got_data (uaecptr data, uae_u32 size, uae_u32 actual)
286 {
287 //uae_u8 *addr;
288 if (!initialized) {
289 write_log ("clipboard: got_data() before initialized!?\n");
290 return;
291 }
292 }
293
294 // win32
get_guid_target(uae_u8 * out)295 int get_guid_target (uae_u8 *out)
296 {
297 unsigned Data1, Data2, Data3, Data4;
298
299 srand(time(NULL));
300 Data1 = rand();
301 Data2 = ((rand() & 0x0fff) | 0x4000);
302 Data3 = rand() % 0x3fff + 0x8000;
303 Data4 = rand();
304
305 out[0] = Data1 >> 24;
306 out[1] = Data1 >> 16;
307 out[2] = Data1 >> 8;
308 out[3] = Data1 >> 0;
309 out[4] = Data2 >> 8;
310 out[5] = Data2 >> 0;
311 out[6] = Data3 >> 8;
312 out[7] = Data3 >> 0;
313 memcpy (out + 8, (void*)(size_t)Data4, 8);
314 return 1;
315 }
316
machdep_free(void)317 void machdep_free (void)
318 {
319 }
320
target_run(void)321 void target_run (void)
322 {
323 //shellexecute (currprefs.win32_commandpathstart);
324 }
325
326 // dinput
input_get_default_keyboard(int i)327 int input_get_default_keyboard (int i)
328 {
329 if (i == 0)
330 return 1;
331 return 0;
332 }
333
334 // unicode
ua_fs(const char * s,int defchar)335 char *ua_fs (const char *s, int defchar)
336 {
337 return strdup(s);
338 }
339
ua_copy(char * dst,int maxlen,const char * src)340 char *ua_copy (char *dst, int maxlen, const char *src)
341 {
342 dst[0] = 0;
343 strncpy (dst, src, maxlen);
344 return dst;
345 }
346
347 // win32gui
348 static int qs_override;
349
target_cfgfile_load(struct uae_prefs * p,const TCHAR * filename,int type,int isdefault)350 int target_cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int type, int isdefault)
351 {
352 int v, i, type2;
353 int ct, ct2 = 0;//, size;
354 char tmp1[MAX_DPATH], tmp2[MAX_DPATH];
355 char fname[MAX_DPATH];
356
357 _tcscpy (fname, filename);
358 if (!zfile_exists (fname)) {
359 fetch_configurationpath (fname, sizeof (fname) / sizeof (TCHAR));
360 if (_tcsncmp (fname, filename, _tcslen (fname)))
361 _tcscat (fname, filename);
362 else
363 _tcscpy (fname, filename);
364 }
365
366 if (!isdefault)
367 qs_override = 1;
368 if (type < 0) {
369 type = 0;
370 cfgfile_get_description (fname, NULL, NULL, NULL, &type);
371 }
372 if (type == 0 || type == 1) {
373 discard_prefs (p, 0);
374 }
375 type2 = type;
376 if (type == 0) {
377 default_prefs (p, type);
378 }
379
380 //regqueryint (NULL, "ConfigFile_NoAuto", &ct2);
381 v = cfgfile_load (p, fname, &type2, ct2, isdefault ? 0 : 1);
382 if (!v)
383 return v;
384 if (type > 0)
385 return v;
386 for (i = 1; i <= 2; i++) {
387 if (type != i) {
388 // size = sizeof (ct);
389 ct = 0;
390 //regqueryint (NULL, configreg2[i], &ct);
391 if (ct && ((i == 1 && p->config_hardware_path[0] == 0) || (i == 2 && p->config_host_path[0] == 0) || ct2)) {
392 // size = sizeof (tmp1) / sizeof (TCHAR);
393 //regquerystr (NULL, configreg[i], tmp1, &size);
394 fetch_path ("ConfigurationPath", tmp2, sizeof (tmp2) / sizeof (TCHAR));
395 _tcscat (tmp2, tmp1);
396 v = i;
397 cfgfile_load (p, tmp2, &v, 1, 0);
398 }
399 }
400 }
401 v = 1;
402 return v;
403 }
404
stripslashes(TCHAR * p)405 void stripslashes (TCHAR *p)
406 {
407 while (_tcslen (p) > 0 && (p[_tcslen (p) - 1] == '\\' || p[_tcslen (p) - 1] == '/'))
408 p[_tcslen (p) - 1] = 0;
409 }
410
fixtrailing(TCHAR * p)411 void fixtrailing (TCHAR *p)
412 {
413 if (_tcslen(p) == 0)
414 return;
415 if (p[_tcslen(p) - 1] == '/' || p[_tcslen(p) - 1] == '\\')
416 return;
417 _tcscat(p, "\\");
418 }
419
getpathpart(TCHAR * outpath,int size,const TCHAR * inpath)420 void getpathpart (TCHAR *outpath, int size, const TCHAR *inpath)
421 {
422 _tcscpy (outpath, inpath);
423 TCHAR *p = _tcsrchr (outpath, '\\');
424 if (p)
425 p[0] = 0;
426 fixtrailing (outpath);
427 }
428
getfilepart(TCHAR * out,int size,const TCHAR * path)429 void getfilepart (TCHAR *out, int size, const TCHAR *path)
430 {
431 out[0] = 0;
432 const TCHAR *p = _tcsrchr (path, '\\');
433 if (p)
434 _tcscpy (out, p + 1);
435 else
436 _tcscpy (out, path);
437 }
438
refreshtitle(void)439 void refreshtitle (void)
440 {
441 if (isfullscreen () == 0)
442 setmaintitle ();
443 }
444
445 // win32gui
446 #define MAX_ROM_PATHS 10
scan_roms(int show)447 int scan_roms (int show)
448 {
449 /** FIXME: This function does nothing right now.
450 TCHAR path[MAX_DPATH];
451 static int recursive;
452 int id, i, ret, keys, cnt;
453 TCHAR *paths[MAX_ROM_PATHS];
454
455 if (recursive)
456 return 0;
457 recursive++;
458
459 //FIXME:
460 cnt = 0;
461 ret = 0;
462 for (i = 0; i < MAX_ROM_PATHS; i++)
463 paths[i] = NULL;
464
465 end:
466 recursive--;
467 return ret;
468 **/
469 return 0;
470 }
471
472 // dinput
input_get_default_lightpen(struct uae_input_device * uid,int num,int port,int af,bool gp)473 int input_get_default_lightpen (struct uae_input_device *uid, int num, int port, int af, bool gp)
474 {
475 /* struct didata *did;
476
477 if (num >= num_mouse)
478 return 0;
479 did = &di_mouse[i];
480 uid[num].eventid[ID_AXIS_OFFSET + 0][0] = INPUTEVENT_LIGHTPEN_HORIZ;
481 uid[num].eventid[ID_AXIS_OFFSET + 1][0] = INPUTEVENT_LIGHTPEN_VERT;
482 uid[num].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
483 if (num == 0)
484 return 1;*/
485 return 0;
486 }
487
input_get_default_joystick_analog(struct uae_input_device * uid,int num,int port,int af,bool gp)488 int input_get_default_joystick_analog (struct uae_input_device *uid, int num, int port, int af, bool gp)
489 {
490 /* int j;
491 struct didata *did;
492
493 if (num >= num_joystick)
494 return 0;
495 did = &di_joystick[i];
496 uid[num].eventid[ID_AXIS_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_HORIZ_POT : INPUTEVENT_JOY1_HORIZ_POT;
497 uid[num].eventid[ID_AXIS_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_VERT_POT : INPUTEVENT_JOY1_VERT_POT;
498 uid[num].eventid[ID_BUTTON_OFFSET + 0][0] = port ? INPUTEVENT_JOY2_LEFT : INPUTEVENT_JOY1_LEFT;
499 if (isrealbutton (did, 1))
500 uid[num].eventid[ID_BUTTON_OFFSET + 1][0] = port ? INPUTEVENT_JOY2_RIGHT : INPUTEVENT_JOY1_RIGHT;
501 if (isrealbutton (did, 2))
502 uid[num].eventid[ID_BUTTON_OFFSET + 2][0] = port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP;
503 if (isrealbutton (did, 3))
504 uid[num].eventid[ID_BUTTON_OFFSET + 3][0] = port ? INPUTEVENT_JOY2_DOWN : INPUTEVENT_JOY1_DOWN;
505 for (j = 2; j < MAX_MAPPINGS - 1; j++) {
506 int am = did->axismappings[j];
507 if (am == DIJOFS_POV(0) || am == DIJOFS_POV(1) || am == DIJOFS_POV(2) || am == DIJOFS_POV(3)) {
508 uid[num].eventid[ID_AXIS_OFFSET + j + 0][0] = port ? INPUTEVENT_JOY2_HORIZ_POT : INPUTEVENT_JOY1_HORIZ_POT;
509 uid[num].eventid[ID_AXIS_OFFSET + j + 1][0] = port ? INPUTEVENT_JOY2_VERT_POT : INPUTEVENT_JOY1_VERT_POT;
510 j++;
511 }
512 }
513 if (num == 0)
514 return 1;*/
515 return 0;
516 }
517
518 // writelog
buf_out(TCHAR * buffer,int * bufsize,const TCHAR * format,...)519 TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...)
520 {
521 /// REMOVEME: unused: int count;
522 va_list parms;
523 va_start (parms, format);
524
525 if (buffer == NULL)
526 return 0;
527 /** REMOVEME: unused: count = **/
528 vsnprintf (buffer, (*bufsize) - 1, format, parms);
529 va_end (parms);
530 *bufsize -= _tcslen (buffer);
531 return buffer + _tcslen (buffer);
532 }
533
534 // dinput
setid(struct uae_input_device * uid,int i,int slot,int sub,int port,int evt)535 void setid (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt)
536 {
537 // wrong place!
538 uid->eventid[slot][SPARE_SUB_EVENT] = uid->eventid[slot][sub];
539 uid->flags[slot][SPARE_SUB_EVENT] = uid->flags[slot][sub];
540 uid->port[slot][SPARE_SUB_EVENT] = MAX_JPORTS + 1;
541 xfree (uid->custom[slot][SPARE_SUB_EVENT]);
542 uid->custom[slot][SPARE_SUB_EVENT] = uid->custom[slot][sub];
543 uid->custom[slot][sub] = NULL;
544
545 uid[i].eventid[slot][sub] = evt;
546 uid[i].port[slot][sub] = port + 1;
547 }
548
setid_af(struct uae_input_device * uid,int i,int slot,int sub,int port,int evt,int af)549 void setid_af (struct uae_input_device *uid, int i, int slot, int sub, int port, int evt, int af)
550 {
551 setid (uid, i, slot, sub, port, evt);
552 uid[i].flags[slot][sub] &= ~(ID_FLAG_AUTOFIRE | ID_FLAG_TOGGLE);
553 if (af >= JPORT_AF_NORMAL)
554 uid[i].flags[slot][sub] |= ID_FLAG_AUTOFIRE;
555 if (af == JPORT_AF_TOGGLE)
556 uid[i].flags[slot][sub] |= ID_FLAG_TOGGLE;
557 }
558
559 // win32
target_quit(void)560 void target_quit (void)
561 {
562 //shellexecute (currprefs.win32_commandpathend);
563 }
564
target_fixup_options(struct uae_prefs * p)565 void target_fixup_options (struct uae_prefs *p)
566 {
567
568 }
569
570 TCHAR start_path_data[MAX_DPATH];
571
fetch_path(TCHAR * name,TCHAR * out,int size)572 void fetch_path (TCHAR *name, TCHAR *out, int size)
573 {
574 /// REMOVEME: unused: int size2 = size;
575
576 _tcscpy (start_path_data, "./");
577 _tcscpy (out, start_path_data);
578 if (!name)
579 return;
580 /* if (!_tcscmp (name, "FloppyPath"))
581 _tcscat (out, "../shared/adf/");
582 if (!_tcscmp (name, "CDPath"))
583 _tcscat (out, "../shared/cd/");
584 if (!_tcscmp (name, "hdfPath"))
585 _tcscat (out, "../shared/hdf/");
586 if (!_tcscmp (name, "KickstartPath"))
587 _tcscat (out, "../shared/rom/");
588 if (!_tcscmp (name, "ConfigurationPath"))
589 _tcscat (out, "Configurations/");
590 */
591 if (!_tcscmp (name, "FloppyPath"))
592 _tcscat (out, "./");
593 if (!_tcscmp (name, "CDPath"))
594 _tcscat (out, "./");
595 if (!_tcscmp (name, "hdfPath"))
596 _tcscat (out, "./");
597 if (!_tcscmp (name, "KickstartPath"))
598 _tcscat (out, "./");
599 if (!_tcscmp (name, "ConfigurationPath"))
600 _tcscat (out, "./");
601
602 }
603
fetch_saveimagepath(TCHAR * out,int size,int dir)604 void fetch_saveimagepath (TCHAR *out, int size, int dir)
605 {
606 /* assert (size > MAX_DPATH);
607 fetch_path ("SaveimagePath", out, size);
608 if (dir) {
609 out[_tcslen (out) - 1] = 0;
610 createdir (out);*/
611 fetch_path ("SaveimagePath", out, size);
612 // }
613 }
614
fetch_configurationpath(TCHAR * out,int size)615 void fetch_configurationpath (TCHAR *out, int size)
616 {
617 fetch_path ("ConfigurationPath", out, size);
618 }
619
fetch_screenshotpath(TCHAR * out,int size)620 void fetch_screenshotpath (TCHAR *out, int size)
621 {
622 fetch_path ("ScreenshotPath", out, size);
623 }
624
fetch_ripperpath(TCHAR * out,int size)625 void fetch_ripperpath (TCHAR *out, int size)
626 {
627 fetch_path ("RipperPath", out, size);
628 }
629
fetch_statefilepath(TCHAR * out,int size)630 void fetch_statefilepath (TCHAR *out, int size)
631 {
632 fetch_path ("StatefilePath", out, size);
633 }
634
fetch_inputfilepath(TCHAR * out,int size)635 void fetch_inputfilepath (TCHAR *out, int size)
636 {
637 fetch_path ("InputPath", out, size);
638 }
639
fetch_datapath(TCHAR * out,int size)640 void fetch_datapath (TCHAR *out, int size)
641 {
642 fetch_path (NULL, out, size);
643 }
644
645 // convert path to absolute or relative
fullpath(TCHAR * path,int size)646 void fullpath (TCHAR *path, int size)
647 {
648 if (path[0] == 0 || (path[0] == '\\' && path[1] == '\\') || path[0] == ':')
649 return;
650 /* <drive letter>: is supposed to mean same as <drive letter>:\ */
651 }
652
au(const char * s)653 TCHAR *au (const char *s)
654 {
655 return strdup(s);
656 }
657
658 //
au_copy(TCHAR * dst,int maxlen,const char * src)659 TCHAR *au_copy (TCHAR *dst, int maxlen, const char *src)
660 {
661 dst[0] = 0;
662 memcpy (dst, src, maxlen);
663 return dst;
664 }
665
666 // writelog
667 int consoleopen = 0;
668 static int realconsole = 1;
669
670 static int debugger_type = -1;
671
openconsole(void)672 static void openconsole (void)
673 {
674 if (realconsole) {
675 if (debugger_type == 2) {
676 //open_debug_window ();
677 consoleopen = 1;
678 } else {
679 //close_debug_window ();
680 consoleopen = -1;
681 }
682 return;
683 }
684 }
685
close_console(void)686 void close_console (void)
687 {
688 if (realconsole)
689 return;
690 }
691
console_isch(void)692 bool console_isch (void)
693 {
694 return false;
695 }
696
console_getch(void)697 TCHAR console_getch (void)
698 {
699 return 0;
700 }
701
debugger_change(int mode)702 void debugger_change (int mode)
703 {
704 if (mode < 0)
705 debugger_type = debugger_type == 2 ? 1 : 2;
706 else
707 debugger_type = mode;
708 if (debugger_type != 1 && debugger_type != 2)
709 debugger_type = 2;
710 // regsetint (NULL, "DebuggerType", debugger_type);
711 openconsole ();
712 }
713
714 // unicode
ua(const TCHAR * s)715 char *ua (const TCHAR *s)
716 {
717 return strdup(s);
718 }
719
uutf8(const char * s)720 char *uutf8 (const char *s)
721 {
722 return strdup(s);
723 }
724
utf8u(const char * s)725 char *utf8u (const char *s)
726 {
727 return strdup(s);
728 }
729
730 // debug_win32
update_debug_info(void)731 void update_debug_info(void)
732 {
733 }
734
735 #ifdef __LIBRETRO__
target_get_display_name(int num,bool friendlyname)736 const TCHAR *target_get_display_name (int num, bool friendlyname){return NULL;}
target_get_display(const TCHAR * name)737 int target_get_display (const TCHAR *name){return -1;}
target_checkcapslock(int scancode,int * state)738 int target_checkcapslock (int scancode, int *state){return 0;}
setmaintitle()739 void setmaintitle(){}
740 #endif
741
742 #if defined PICASSO96
743 ///////////////////////////////////////////////////
744 // win32gfx.cpp
745 ///////////////////////////////////////////////////
746 #define MAX_DISPLAYS 10
747 struct MultiDisplay Displays[MAX_DISPLAYS];
748
getdisplay2(struct uae_prefs * p,int index)749 static struct MultiDisplay *getdisplay2 (struct uae_prefs *p, int index)
750 {
751 write_log ("Multimonitor detection disabled\n");
752 Displays[0].primary = 1;
753 Displays[0].monitorname = "Display";
754
755 int max;
756 int display = index < 0 ? p->gfx_apmode[screen_is_picasso ? APMODE_RTG : APMODE_NATIVE].gfx_display - 1 : index;
757
758 max = 0;
759 while (Displays[max].monitorname)
760 max++;
761 if (max == 0) {
762 gui_message (_T("no display adapters! Exiting"));
763 exit (0);
764 }
765 if (index >= 0 && display >= max)
766 return NULL;
767 if (display >= max)
768 display = 0;
769 if (display < 0)
770 display = 0;
771 return &Displays[display];
772 }
773
getdisplay(struct uae_prefs * p)774 struct MultiDisplay *getdisplay (struct uae_prefs *p)
775 {
776 return getdisplay2 (p, -1);
777 }
778
target_get_display(const TCHAR * name)779 int target_get_display (const TCHAR *name)
780 {
781 int oldfound = -1;
782 int found = -1;
783 unsigned int i;
784 for (i = 0; Displays[i].monitorname; i++) {
785 struct MultiDisplay *md = &Displays[i];
786 if (!_tcscmp (md->adapterid, name))
787 found = i + 1;
788 if (!_tcscmp (md->adaptername, name))
789 found = i + 1;
790 if (!_tcscmp (md->monitorname, name))
791 found = i + 1;
792 if (!_tcscmp (md->monitorid, name))
793 found = i + 1;
794 if (found >= 0) {
795 if (oldfound != found)
796 return -1;
797 oldfound = found;
798 }
799 }
800 return -1;
801 }
target_get_display_name(int num,bool friendlyname)802 const TCHAR *target_get_display_name (int num, bool friendlyname)
803 {
804 if (num <= 0)
805 return NULL;
806 struct MultiDisplay *md = getdisplay2 (NULL, num - 1);
807 if (!md)
808 return NULL;
809 if (friendlyname)
810 return md->monitorname;
811 return md->monitorid;
812 }
813 #endif
isfullscreen_2(struct uae_prefs * p)814 static int isfullscreen_2 (struct uae_prefs *p)
815 {
816 int idx = screen_is_picasso ? 1 : 0;
817 return p->gfx_apmode[idx].gfx_fullscreen == GFX_FULLSCREEN ? 1 : (p->gfx_apmode[idx].gfx_fullscreen == GFX_FULLWINDOW ? -1 : 0);
818 }
819
isfullscreen(void)820 int isfullscreen (void)
821 {
822 return isfullscreen_2 (&currprefs);
823 }
824
825 #define SM_CXSCREEN 0
826 #define SM_CYSCREEN 1
827 #define SM_CXVIRTUALSCREEN 78
828 #define SM_CYVIRTUALSCREEN 79
829 #define REFRESH_RATE_RAW 1
830 #define REFRESH_RATE_LACE 2
831 #ifndef _WIN32
GetSystemMetrics(int nIndex)832 static int GetSystemMetrics (int nIndex) {
833 switch (nIndex) {
834 case SM_CXSCREEN: return 1024;
835 case SM_CYSCREEN: return 768;
836 case SM_CXVIRTUALSCREEN: return 1024;
837 case SM_CYVIRTUALSCREEN: return 768;
838 }
839 return 0;
840 }
841 #endif
resolution_compare(const void * a,const void * b)842 static int resolution_compare (const void *a, const void *b)
843 {
844 #ifndef __LIBRETRO__
845 struct PicassoResolution *ma = (struct PicassoResolution *)a;
846 struct PicassoResolution *mb = (struct PicassoResolution *)b;
847 if (ma->res.width < mb->res.width)
848 return -1;
849 if (ma->res.width > mb->res.width)
850 return 1;
851 if (ma->res.height < mb->res.height)
852 return -1;
853 if (ma->res.height > mb->res.height)
854 return 1;
855 return ma->depth - mb->depth;
856 #else
857 return 0;
858 #endif
859 }
860
861 #ifndef __LIBRETRO__
sortmodes(struct MultiDisplay * md)862 static void sortmodes (struct MultiDisplay *md)
863 {
864 int i, idx = -1;
865 int pw = -1, ph = -1;
866
867 i = 0;
868 while (md->DisplayModes[i].depth >= 0)
869 i++;
870 qsort (md->DisplayModes, i, sizeof (struct PicassoResolution), resolution_compare);
871 for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
872 int j, k;
873 for (j = 0; md->DisplayModes[i].refresh[j]; j++) {
874 for (k = j + 1; md->DisplayModes[i].refresh[k]; k++) {
875 if (md->DisplayModes[i].refresh[j] > md->DisplayModes[i].refresh[k]) {
876 int t = md->DisplayModes[i].refresh[j];
877 md->DisplayModes[i].refresh[j] = md->DisplayModes[i].refresh[k];
878 md->DisplayModes[i].refresh[k] = t;
879 t = md->DisplayModes[i].refreshtype[j];
880 md->DisplayModes[i].refreshtype[j] = md->DisplayModes[i].refreshtype[k];
881 md->DisplayModes[i].refreshtype[k] = t;
882 }
883 }
884 }
885 if ( (md->DisplayModes[i].res.height != (uae_u32)ph)
886 || (md->DisplayModes[i].res.width != (uae_u32)pw) ) {
887 ph = md->DisplayModes[i].res.height;
888 pw = md->DisplayModes[i].res.width;
889 idx++;
890 }
891 md->DisplayModes[i].residx = idx;
892 }
893 }
894
modesList(struct MultiDisplay * md)895 static void modesList (struct MultiDisplay *md)
896 {
897 int i, j;
898
899 i = 0;
900 while (md->DisplayModes[i].depth >= 0) {
901 write_log (_T("%d: %s%s ("), i, md->DisplayModes[i].rawmode ? _T("!") : _T(""), md->DisplayModes[i].name);
902 j = 0;
903 while (md->DisplayModes[i].refresh[j] > 0) {
904 if (j > 0)
905 write_log (_T(","));
906 if (md->DisplayModes[i].refreshtype[j] & REFRESH_RATE_RAW)
907 write_log (_T("!"));
908 write_log (_T("%d"), md->DisplayModes[i].refresh[j]);
909 if (md->DisplayModes[i].refreshtype[j] & REFRESH_RATE_LACE)
910 write_log (_T("i"));
911 j++;
912 }
913 write_log (_T(")\n"));
914 i++;
915 }
916 }
917
addmode(struct MultiDisplay * md,DEVMODE * dm,int rawmode)918 void addmode (struct MultiDisplay *md, DEVMODE *dm, int rawmode)
919 {
920 int ct;
921 int i, j;
922 int w = dm->dmPelsWidth;
923 int h = dm->dmPelsHeight;
924 int d = dm->dmBitsPerPel;
925 bool lace = false;
926
927 /* int freq = 0;
928 if (dm->dmFields & DM_DISPLAYFREQUENCY) {
929 freq = dm->dmDisplayFrequency;
930 if (freq < 10)
931 freq = 0;
932 }
933 if (dm->dmFields & DM_DISPLAYFLAGS) {
934 lace = (dm->dmDisplayFlags & DM_INTERLACED) != 0;
935 }*/
936 int freq = 75;
937
938 ct = 0;
939 if (d == 8)
940 ct = RGBMASK_8BIT;
941 if (d == 15)
942 ct = RGBMASK_15BIT;
943 if (d == 16)
944 ct = RGBMASK_16BIT;
945 if (d == 24)
946 ct = RGBMASK_24BIT;
947 if (d == 32)
948 ct = RGBMASK_32BIT;
949 if (ct == 0)
950 return;
951 d /= 8;
952 i = 0;
953
954 while (md->DisplayModes[i].depth >= 0) {
955 if ( (md->DisplayModes[i].depth == d)
956 && (md->DisplayModes[i].res.width == (uae_u32)w)
957 && (md->DisplayModes[i].res.height == (uae_u32)h) ) {
958 for (j = 0; j < MAX_REFRESH_RATES; j++) {
959 if (md->DisplayModes[i].refresh[j] == 0 || md->DisplayModes[i].refresh[j] == freq)
960 break;
961 }
962 if (j < MAX_REFRESH_RATES) {
963 md->DisplayModes[i].refresh[j] = freq;
964 md->DisplayModes[i].refreshtype[j] = rawmode;
965 md->DisplayModes[i].refresh[j + 1] = 0;
966 return;
967 }
968 }
969 i++;
970 }
971 i = 0;
972 while (md->DisplayModes[i].depth >= 0)
973 i++;
974 if (i >= MAX_PICASSO_MODES - 1)
975 return;
976 // md->DisplayModes[i].rawmode = rawmode;
977 // md->DisplayModes[i].lace = lace;
978 md->DisplayModes[i].res.width = w;
979 md->DisplayModes[i].res.height = h;
980 md->DisplayModes[i].depth = d;
981 md->DisplayModes[i].refresh[0] = freq;
982 md->DisplayModes[i].refreshtype[0] = rawmode;
983 md->DisplayModes[i].refresh[1] = 0;
984 md->DisplayModes[i].colormodes = ct;
985 md->DisplayModes[i + 1].depth = -1;
986 _stprintf (md->DisplayModes[i].name, _T("%dx%d%s, %d-bit"),
987 md->DisplayModes[i].res.width, md->DisplayModes[i].res.height,
988 lace ? _T("i") : _T(""),
989 md->DisplayModes[i].depth * 8);
990
991 // write_log ("Add Mode: %s\n", md->DisplayModes[i].name);
992 }
993
sortdisplays(void)994 void sortdisplays (void)
995 {
996 struct MultiDisplay *md;
997 int i, idx;
998
999 int w = GetSystemMetrics (SM_CXSCREEN);
1000 int h = GetSystemMetrics (SM_CYSCREEN);
1001 int b = 0;
1002 // HDC hdc = GetDC (NULL);
1003 // if (hdc) {
1004 // b = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
1005 // ReleaseDC (NULL, hdc);
1006 // }
1007 write_log (_T("Desktop: W=%d H=%d B=%d. CXVS=%d CYVS=%d\n"), w, h, b,
1008 GetSystemMetrics (SM_CXVIRTUALSCREEN), GetSystemMetrics (SM_CYVIRTUALSCREEN));
1009
1010 md = Displays;
1011 while (md->monitorname) {
1012 md->DisplayModes = xmalloc (struct PicassoResolution, MAX_PICASSO_MODES);
1013 md->DisplayModes[0].depth = -1;
1014
1015 write_log (_T("%s '%s' [%s]\n"), md->adaptername, md->adapterid, md->adapterkey);
1016 write_log (_T("-: %s [%s]\n"), md->fullname, md->monitorid);
1017 for (int mode = 0; mode < 2; mode++) {
1018 DEVMODE dm;
1019 dm.dmSize = sizeof dm;
1020 dm.dmDriverExtra = 0;
1021 idx = 0;
1022
1023 //let's hope for the best
1024 dm.dmPelsWidth = 1280;
1025 dm.dmPelsHeight = 1024;
1026 dm.dmBitsPerPel = 32;
1027 dm.dmDisplayFrequency = 50;
1028 //dm.dmDisplayFlags =
1029 //dm.dmPosition =
1030 //dm.dmDisplayOrientation =
1031 // while (EnumDisplaySettingsEx (md->adapterid, idx, &dm, mode ? EDS_RAWMODE : 0)) {
1032 int found = 0;
1033 int idx2 = 0;
1034 while (md->DisplayModes[idx2].depth >= 0 && !found) {
1035 struct PicassoResolution *pr = &md->DisplayModes[idx2];
1036 if ( (pr->res.width == (uae_u32)dm.dmPelsWidth)
1037 && (pr->res.height == (uae_u32)dm.dmPelsHeight)
1038 && (pr->depth == (int)(dm.dmBitsPerPel / 8)) ) {
1039 for (i = 0; pr->refresh[i]; i++) {
1040 if (pr->refresh[i] == (int)dm.dmDisplayFrequency) {
1041 found = 1;
1042 break;
1043 }
1044 }
1045 }
1046 idx2++;
1047 }
1048 if (!found && dm.dmBitsPerPel > 8) {
1049 /// REMOVEME: unused: int freq = 0;
1050 // if ((dm.dmFields & DM_PELSWIDTH) && (dm.dmFields & DM_PELSHEIGHT) && (dm.dmFields & DM_BITSPERPEL)) {
1051 addmode (md, &dm, mode);
1052 // }
1053 }
1054 idx++;
1055 // }
1056 }
1057 sortmodes (md);
1058 modesList (md);
1059 i = 0;
1060 while (md->DisplayModes[i].depth > 0)
1061 i++;
1062 write_log (_T("%d display modes.\n"), i);
1063 md++;
1064 }
1065 }
1066
enumeratedisplays(void)1067 void enumeratedisplays (void) {
1068 struct MultiDisplay *md = Displays;
1069
1070 md->adaptername = strdup ("DeviceString");
1071 md->adapterid = strdup ("DeviceName");
1072 md->adapterkey = strdup ("DeviceID");
1073 md->monitorname = strdup ("DeviceString");
1074 md->monitorid = strdup ("DeviceKey");
1075 md->fullname = strdup ("DeviceName");
1076 md->primary = true;
1077 }
1078 #endif
updatedisplayarea(void)1079 void updatedisplayarea (void)
1080 {
1081 /*
1082 if (!screen_is_initialized)
1083 return;
1084 if (dx_islost ())
1085 return;
1086 if (picasso_on)
1087 return;
1088 #if defined (GFXFILTER)
1089 if (currentmode->flags & DM_D3D) {
1090 #if defined (D3D)
1091 D3D_refresh ();
1092 #endif
1093 } else
1094 #endif
1095 if (currentmode->flags & DM_DDRAW) {
1096 #if defined (GFXFILTER)
1097 if (currentmode->flags & DM_SWSCALE)
1098 S2X_refresh ();
1099 #endif
1100 DirectDraw_Flip (0);
1101 }
1102 */
1103 }
1104
1105 static bool render_ok;
1106
1107 int vsync_busy_wait_mode;
1108
vsync_sleep(bool preferbusy)1109 static void vsync_sleep (bool preferbusy)
1110 {
1111 struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
1112 bool dowait;
1113
1114 if (vsync_busy_wait_mode == 0) {
1115 dowait = ap->gfx_vflip || !preferbusy;
1116 //dowait = !preferbusy;
1117 } else if (vsync_busy_wait_mode < 0) {
1118 dowait = true;
1119 } else {
1120 dowait = false;
1121 }
1122 if (dowait && (currprefs.m68k_speed >= 0 || currprefs.m68k_speed_throttle < 0))
1123 sleep_millis_main (1);
1124 }
1125
show_screen_maybe(bool show)1126 bool show_screen_maybe (bool show)
1127 {
1128 struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
1129 if (!ap->gfx_vflip || ap->gfx_vsyncmode == 0 || !ap->gfx_vsync) {
1130 if (show)
1131 show_screen (0);
1132 return false;
1133 }
1134 return false;
1135 }
1136
render_screen(bool immediate)1137 bool render_screen (bool immediate)
1138 {
1139 render_ok = false;
1140 return render_ok;
1141 }
1142
show_screen(int mode)1143 void show_screen (int mode)
1144 {
1145 render_ok = false;
1146 }
1147
1148 static int maxscanline, minscanline, prevvblankpos;
1149
getvblankpos(int * vp)1150 static bool getvblankpos (int *vp)
1151 {
1152 int sl = 0;
1153 *vp = -2;
1154 prevvblankpos = sl;
1155 if (sl > maxscanline)
1156 maxscanline = sl;
1157 if ( (sl > 0) && ( (sl < minscanline) || (minscanline < 0) ) ) {
1158 minscanline = sl;
1159 }
1160 *vp = sl;
1161 return true;
1162 }
1163
getvblankpos2(int * vp,int * flags)1164 static bool getvblankpos2 (int *vp, int *flags)
1165 {
1166 if (!getvblankpos (vp))
1167 return false;
1168 if (*vp > 100 && flags) {
1169 if ((*vp) & 1)
1170 *flags |= 2;
1171 else
1172 *flags |= 1;
1173 }
1174 return true;
1175 }
1176
waitvblankstate(bool state,int * maxvpos,int * flags)1177 static bool waitvblankstate (bool state, int *maxvpos, int *flags)
1178 {
1179 int vp;
1180 if (flags)
1181 *flags = 0;
1182 for (;;) {
1183 int omax = maxscanline;
1184 if (!getvblankpos2 (&vp, flags))
1185 return false;
1186 while (omax != maxscanline) {
1187 omax = maxscanline;
1188 if (!getvblankpos2 (&vp, flags))
1189 return false;
1190 }
1191 if (maxvpos)
1192 *maxvpos = maxscanline;
1193 if (vp < 0) {
1194 if (state)
1195 return true;
1196 } else {
1197 if (!state)
1198 return true;
1199 }
1200 }
1201 }
1202
vblank_wait(void)1203 static int vblank_wait (void)
1204 {
1205 int vp;
1206
1207 for (;;) {
1208 int opos = prevvblankpos;
1209 if (!getvblankpos (&vp))
1210 return -2;
1211 if (opos > (maxscanline + minscanline) / 2 && vp < (maxscanline + minscanline) / 3)
1212 return vp;
1213 if (vp <= 0)
1214 return vp;
1215 vsync_sleep (true);
1216 }
1217 }
1218
isthreadedvsync(void)1219 static bool isthreadedvsync (void)
1220 {
1221 return isvsync_chipset () <= -2 || isvsync_rtg () < 0;
1222 }
1223
vsync_busywait_do(int * freetime,bool lace,bool oddeven)1224 bool vsync_busywait_do (int *freetime, bool lace, bool oddeven)
1225 {
1226 bool v;
1227 static bool framelost;
1228 int ti;
1229 frame_time_t t;
1230 frame_time_t prevtime = vblank_prev_time;
1231 struct apmode *ap = picasso_on ? &currprefs.gfx_apmode[1] : &currprefs.gfx_apmode[0];
1232
1233 t = read_processor_time ();
1234 ti = t - prevtime;
1235 if (ti) {
1236 waitvblankstate (false, NULL, NULL);
1237 vblank_prev_time = t;
1238
1239 return true;
1240 }
1241
1242 if (freetime)
1243 *freetime = 0;
1244 v = 0;
1245
1246 if (isthreadedvsync ()) {
1247
1248 framelost = false;
1249 v = 1;
1250
1251 } else {
1252 int vp;
1253
1254 if (currprefs.turbo_emulation) {
1255 show_screen (0);
1256 vblank_prev_time = read_processor_time ();
1257 framelost = true;
1258 v = -1;
1259
1260 } else {
1261 while (!framelost && read_processor_time () - prevtime < 0) {
1262 vsync_sleep (false);
1263 }
1264 vp = vblank_wait ();
1265 if (vp >= -1) {
1266 vblank_prev_time = read_processor_time ();
1267 if (ap->gfx_vflip == 0) {
1268 show_screen (0);
1269 }
1270 for (;;) {
1271 if (!getvblankpos (&vp))
1272 break;
1273 if (vp > 0)
1274 break;
1275 sleep_millis (1);
1276 }
1277 if (ap->gfx_vflip != 0) {
1278 show_screen (0);
1279 }
1280 v = framelost ? -1 : 1;
1281 }
1282
1283 framelost = false;
1284 }
1285 getvblankpos (&vp);
1286 }
1287
1288 return v;
1289 }
1290
1291 ///////////////////////////////////////////////////
1292 // parser.c
1293 ///////////////////////////////////////////////////
1294
1295 unsigned int flashscreen;
1296
doflashscreen(void)1297 void doflashscreen (void)
1298 {
1299 /*
1300 flashscreen = 10;
1301 init_colors ();
1302 picasso_refresh ();
1303 reset_drawing ();
1304 flush_screen (gfxvidinfo.outbuffer, 0, 0);
1305 */
1306 }
1307
1308 // posix
getlocaltime(void)1309 uae_u32 getlocaltime (void)
1310 {
1311 /*
1312 SYSTEMTIME st;
1313 FILETIME ft;
1314 ULARGE_INTEGER t;
1315
1316 GetLocalTime (&st);
1317 SystemTimeToFileTime (&st, &ft);
1318 t.LowPart = ft.dwLowDateTime;
1319 t.HighPart = ft.dwHighDateTime;
1320 t.QuadPart -= 11644473600000 * 10000;
1321 return (uae_u32)(t.QuadPart / 10000000);
1322 */
1323 return 0;
1324 }
1325
1326 /*
1327 #ifndef HAVE_ISINF
1328 int isinf (double x)
1329 {
1330 const int nClass = _fpclass (x);
1331 int result;
1332 if (nClass == _FPCLASS_NINF || nClass == _FPCLASS_PINF)
1333 result = 1;
1334 else
1335 result = 0;
1336 return result;
1337 }
1338 #endif
1339 */
1340
1341 //fsdb_mywin
my_issamevolume(const TCHAR * path1,const TCHAR * path2,TCHAR * path)1342 bool my_issamevolume(const TCHAR *path1, const TCHAR *path2, TCHAR *path)
1343 {
1344 /*
1345 FIXME:
1346 TCHAR p1[MAX_DPATH];
1347 TCHAR p2[MAX_DPATH];
1348 TCHAR p1b[MAX_DPATH];
1349 TCHAR p2b[MAX_DPATH];
1350 int len;
1351
1352 if (!GetFullPathName(path1, sizeof p1 / sizeof (TCHAR), p1, NULL))
1353 return false;
1354 if (!GetFullPathName(path2, sizeof p2 / sizeof (TCHAR), p2, NULL))
1355 return false;
1356 PathCanonicalize(p1b, p1);
1357 PathCanonicalize(p2b, p2);
1358 len = _tcslen (p1b);
1359 if (len > _tcslen (p2b))
1360 len = _tcslen (p2b);
1361 if (_tcsnicmp (p1b, p2b, len))
1362 return false;
1363 _tcscpy (path, p2b + len);
1364 for (int i = 0; i < _tcslen (path); i++) {
1365 if (path[i] == '\\')
1366 path[i] = '/';
1367 }*/
1368 return true;
1369 }
1370
my_resolvesoftlink(TCHAR * linkfile,int size)1371 bool my_resolvesoftlink(TCHAR *linkfile, int size)
1372 {
1373 /*
1374 FIXME:
1375 if (my_resolvessymboliclink(linkfile, size))
1376 return true;
1377 if (my_resolveshortcut(linkfile,size))
1378 return true;*/
1379 return false;
1380 }
1381
1382