Fixed an incompatibility with MSVC environments that caused the consoles to fail.
Fixed the missing-slash bug in emu_path.
This commit is contained in:
8
src/pc.c
8
src/pc.c
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Main emulator module where most things are controlled.
|
* Main emulator module where most things are controlled.
|
||||||
*
|
*
|
||||||
* Version: @(#)pc.c 1.0.18 2018/04/01
|
* Version: @(#)pc.c 1.0.19 2018/04/03
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -393,22 +393,22 @@ pc_init(int argc, wchar_t *argv[])
|
|||||||
* can test this by looking for the 'roms' folder.
|
* can test this by looking for the 'roms' folder.
|
||||||
*/
|
*/
|
||||||
wcscpy(path, emu_path);
|
wcscpy(path, emu_path);
|
||||||
p = plat_get_basename(path);
|
|
||||||
plat_append_slash(path);
|
plat_append_slash(path);
|
||||||
wcscat(path, ROMS_PATH);
|
wcscat(path, ROMS_PATH);
|
||||||
if (! plat_dir_check(path)) {
|
if (! plat_dir_check(path)) {
|
||||||
/* No 'roms' folder found, so go up one level. */
|
/* No 'roms' folder found, so go up one level. */
|
||||||
if (p != NULL)
|
wcscpy(path, emu_path);
|
||||||
|
if ((p = plat_get_basename(path)) != NULL)
|
||||||
*p = L'\0';
|
*p = L'\0';
|
||||||
plat_append_slash(path);
|
plat_append_slash(path);
|
||||||
wcscat(path, ROMS_PATH);
|
wcscat(path, ROMS_PATH);
|
||||||
if (plat_dir_check(path)) {
|
if (plat_dir_check(path)) {
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
*p = L'\0';
|
*p = L'\0';
|
||||||
plat_append_slash(path);
|
|
||||||
wcscpy(emu_path, path);
|
wcscpy(emu_path, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plat_append_slash(emu_path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the current working directory.
|
* Get the current working directory.
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Platform main support module for Windows.
|
* Platform main support module for Windows.
|
||||||
*
|
*
|
||||||
* Version: @(#)win.c 1.0.10 2018/03/31
|
* Version: @(#)win.c 1.0.11 2018/04/03
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
* USA.
|
* USA.
|
||||||
*/
|
*/
|
||||||
#define UNICODE
|
#define UNICODE
|
||||||
|
#define _WIN32_WINNT 0x0501
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -223,27 +224,26 @@ plat_get_string(int i)
|
|||||||
{
|
{
|
||||||
LPTSTR str;
|
LPTSTR str;
|
||||||
|
|
||||||
if ((i >= 2048) && (i <= 3071)) {
|
if ((i >= 2048) && (i <= 3071))
|
||||||
str = lpRCstr2048[i-2048].str;
|
str = lpRCstr2048[i-2048].str;
|
||||||
} else if ((i >= 4096) && (i <= 4351)) {
|
else if ((i >= 4096) && (i <= 4351))
|
||||||
str = lpRCstr4096[i-4096].str;
|
str = lpRCstr4096[i-4096].str;
|
||||||
} else if ((i >= 4352) && (i <= 4607)) {
|
else if ((i >= 4352) && (i <= 4607))
|
||||||
str = lpRCstr4352[i-4352].str;
|
str = lpRCstr4352[i-4352].str;
|
||||||
} else if ((i >= 4608) && (i <= 5119)) {
|
else if ((i >= 4608) && (i <= 5119))
|
||||||
str = lpRCstr4608[i-4608].str;
|
str = lpRCstr4608[i-4608].str;
|
||||||
} else if ((i >= 5120) && (i <= 5375)) {
|
else if ((i >= 5120) && (i <= 5375))
|
||||||
str = lpRCstr5120[i-5120].str;
|
str = lpRCstr5120[i-5120].str;
|
||||||
} else if ((i >= 5376) && (i <= 5631)) {
|
else if ((i >= 5376) && (i <= 5631))
|
||||||
str = lpRCstr5376[i-5376].str;
|
str = lpRCstr5376[i-5376].str;
|
||||||
} else if ((i >= 5632) && (i <= 5887)) {
|
else if ((i >= 5632) && (i <= 5887))
|
||||||
str = lpRCstr5632[i-5632].str;
|
str = lpRCstr5632[i-5632].str;
|
||||||
} else if ((i >= 5888) && (i <= 6143)) {
|
else if ((i >= 5888) && (i <= 6143))
|
||||||
str = lpRCstr5888[i-5888].str;
|
str = lpRCstr5888[i-5888].str;
|
||||||
} else if ((i >= 6144) && (i <= 7167)) {
|
else if ((i >= 6144) && (i <= 7167))
|
||||||
str = lpRCstr6144[i-6144].str;
|
str = lpRCstr6144[i-6144].str;
|
||||||
} else {
|
else
|
||||||
str = lpRCstr7168[i-7168].str;
|
str = lpRCstr7168[i-7168].str;
|
||||||
}
|
|
||||||
|
|
||||||
return((wchar_t *)str);
|
return((wchar_t *)str);
|
||||||
}
|
}
|
||||||
@@ -338,64 +338,24 @@ plat_console(int init)
|
|||||||
if (! AttachConsole(ATTACH_PARENT_PROCESS)) {
|
if (! AttachConsole(ATTACH_PARENT_PROCESS)) {
|
||||||
/* Parent has no console, create one. */
|
/* Parent has no console, create one. */
|
||||||
if (! AllocConsole()) {
|
if (! AllocConsole()) {
|
||||||
#ifdef _DEBUG
|
/* Cannot create console, just give up. */
|
||||||
fp = fopen("error.txt", "w");
|
|
||||||
fprintf(fp, "AllocConsole failed: %lu\n", GetLastError());
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((h = GetStdHandle(STD_OUTPUT_HANDLE)) == NULL) {
|
fp = NULL;
|
||||||
#ifdef _DEBUG
|
if ((h = GetStdHandle(STD_OUTPUT_HANDLE)) != NULL) {
|
||||||
fp = fopen("error.txt", "w");
|
/* We got the handle, now open a file descriptor. */
|
||||||
fprintf(fp, "GetStdHandle(OUT) failed: %lu\n", GetLastError());
|
if ((i = _open_osfhandle((intptr_t)h, _O_TEXT)) != -1) {
|
||||||
fclose(fp);
|
/* We got a file descriptor, now allocate a new stream. */
|
||||||
#endif
|
if ((fp = _fdopen(i, "w")) != NULL) {
|
||||||
return;
|
/* Got the stream, re-initialize stdout with it. */
|
||||||
}
|
(void)freopen("CONOUT$", "w", stdout);
|
||||||
i = _open_osfhandle((intptr_t)h, _O_TEXT);
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
if (i != -1) {
|
fflush(stdout);
|
||||||
fp = _fdopen(i, "w");
|
|
||||||
if (fp == NULL) {
|
|
||||||
#ifdef _DEBUG
|
|
||||||
fp = fopen("error.txt", "w");
|
|
||||||
fprintf(fp, "FdOpen(%i) failed: %lu\n", i, GetLastError());
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setvbuf(fp, NULL, _IONBF, 1);
|
|
||||||
*stdout = *fp;
|
|
||||||
} else {
|
|
||||||
#ifdef _DEBUG
|
|
||||||
fp = fopen("error.txt", "w");
|
|
||||||
fprintf(fp, "GetOSfHandle(%p) failed: %lu\n", h, GetLastError());
|
|
||||||
fclose(fp);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if NOTUSED
|
|
||||||
h = GetStdHandle(STD_ERROR_HANDLE);
|
|
||||||
if (h != NULL) {
|
|
||||||
i = _open_osfhandle((intptr_t)h, _O_TEXT);
|
|
||||||
if (i != -1) {
|
|
||||||
fp = _fdopen(i, "w");
|
|
||||||
if (fp != NULL) {
|
|
||||||
setvbuf(fp, NULL, _IONBF, 1);
|
|
||||||
*stderr = *fp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up stdin as well. */
|
|
||||||
h = GetStdHandle(STD_INPUT_HANDLE);
|
|
||||||
i = _open_osfhandle((intptr_t)h, _O_TEXT);
|
|
||||||
fp = _fdopen(i, "r");
|
|
||||||
setvbuf(fp, NULL, _IONBF, 128);
|
|
||||||
*stdin = *fp;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user