rewrite the emulator to use UTF-8 internally

This commit is contained in:
David Hrdlička
2021-03-14 20:35:01 +01:00
parent 56d62de4fe
commit dfbbe08a07
146 changed files with 1507 additions and 1457 deletions

View File

@@ -29,6 +29,7 @@
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2</dpiAwareness>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
</windowsSettings>
</application>
</assembly>

View File

@@ -31,6 +31,7 @@
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <direct.h>
#include <wchar.h>
#include <io.h>
#define HAVE_STDARG_H
@@ -66,6 +67,7 @@ HINSTANCE hinstance; /* application instance */
HANDLE ghMutex;
LCID lang_id; /* current language ID used */
DWORD dwSubLangID;
int acp_utf8; /* Windows supports UTF-8 codepage */
/* Local data. */
@@ -81,7 +83,7 @@ static rc_str_t *lpRCstr2048,
*lpRCstr6144,
*lpRCstr7168;
static int vid_api_inited = 0;
static wchar_t *argbuf;
static char *argbuf;
static int first_use = 1;
static LARGE_INTEGER StartingTime;
static LARGE_INTEGER Frequency;
@@ -181,6 +183,36 @@ LoadCommonStrings(void)
}
size_t mbstoc16s(uint16_t dst[], const char src[], int len)
{
if (src == NULL) return 0;
if (len < 0) return 0;
size_t ret = MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, dst == NULL ? 0 : len);
if (!ret) {
return -1;
}
return ret;
}
size_t c16stombs(char dst[], const uint16_t src[], int len)
{
if (src == NULL) return 0;
if (len < 0) return 0;
size_t ret = WideCharToMultiByte(CP_UTF8, 0, src, -1, dst, dst == NULL ? 0 : len, NULL, NULL);
if (!ret) {
return -1;
}
return ret;
}
/* Set (or re-set) the language for the application. */
void
set_language(int id)
@@ -302,21 +334,25 @@ CloseConsole(void)
/* Process the commandline, and create standard argc/argv array. */
static int
ProcessCommandLine(wchar_t ***argw)
ProcessCommandLine(char ***argv)
{
WCHAR *cmdline;
wchar_t **args;
char **args;
int argc_max;
int i, q, argc;
cmdline = GetCommandLine();
i = wcslen(cmdline) + 1;
argbuf = (wchar_t *)malloc(sizeof(wchar_t)*i);
wcscpy(argbuf, cmdline);
if (acp_utf8) {
i = strlen(GetCommandLineA()) + 1;
argbuf = (char *)malloc(i);
strcpy(argbuf, GetCommandLineA());
} else {
i = c16stombs(NULL, GetCommandLineW(), 0) + 1;
argbuf = (char *)malloc(i);
c16stombs(argbuf, GetCommandLineW(), i);
}
argc = 0;
argc_max = 64;
args = (wchar_t **)malloc(sizeof(wchar_t *) * argc_max);
args = (char **)malloc(sizeof(char *) * argc_max);
if (args == NULL) {
free(argbuf);
return(0);
@@ -325,11 +361,11 @@ ProcessCommandLine(wchar_t ***argw)
/* parse commandline into argc/argv format */
i = 0;
while (argbuf[i]) {
while (argbuf[i] == L' ')
while (argbuf[i] == ' ')
i++;
if (argbuf[i]) {
if ((argbuf[i] == L'\'') || (argbuf[i] == L'"')) {
if ((argbuf[i] == '\'') || (argbuf[i] == '"')) {
q = argbuf[i++];
if (!argbuf[i])
break;
@@ -340,7 +376,7 @@ ProcessCommandLine(wchar_t ***argw)
if (argc >= argc_max) {
argc_max += 64;
args = realloc(args, sizeof(wchar_t *)*argc_max);
args = realloc(args, sizeof(char *)*argc_max);
if (args == NULL) {
free(argbuf);
return(0);
@@ -348,7 +384,7 @@ ProcessCommandLine(wchar_t ***argw)
}
while ((argbuf[i]) && ((q)
? (argbuf[i]!=q) : (argbuf[i]!=L' '))) i++;
? (argbuf[i]!=q) : (argbuf[i]!=' '))) i++;
if (argbuf[i]) {
argbuf[i] = 0;
@@ -358,7 +394,7 @@ ProcessCommandLine(wchar_t ***argw)
}
args[argc] = NULL;
*argw = args;
*argv = args;
return(argc);
}
@@ -368,12 +404,18 @@ ProcessCommandLine(wchar_t ***argw)
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
{
wchar_t **argw = NULL;
char **argv = NULL;
int argc, i;
wchar_t * AppID = L"86Box.86Box\0";
SetCurrentProcessExplicitAppUserModelID(AppID);
/* Check if Windows supports UTF-8 */
if (GetACP() == CP_UTF8)
acp_utf8 = 1;
else
acp_utf8 = 0;
/* Set this to the default value (windowed mode). */
video_fullscreen = 0;
@@ -387,10 +429,10 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
set_language(0x0409);
/* Process the command line for options. */
argc = ProcessCommandLine(&argw);
argc = ProcessCommandLine(&argv);
/* Pre-initialize the system, this loads the config file. */
if (! pc_init(argc, argw)) {
if (! pc_init(argc, argv)) {
/* Detach from console. */
if (force_debug)
CreateConsole(0);
@@ -399,7 +441,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
PostMessage((HWND) (uintptr_t) source_hwnd, WM_HAS_SHUTDOWN, (WPARAM) 0, (LPARAM) hwndMain);
free(argbuf);
free(argw);
free(argv);
return(1);
}
@@ -417,7 +459,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow)
i = ui_init(nCmdShow);
free(argbuf);
free(argw);
free(argv);
return(i);
}
@@ -507,87 +549,152 @@ do_stop(void)
void
plat_get_exe_name(wchar_t *s, int size)
plat_get_exe_name(char *s, int size)
{
GetModuleFileName(hinstance, s, size);
wchar_t *temp;
if (acp_utf8)
GetModuleFileNameA(hinstance, s, size);
else {
temp = malloc(size * sizeof(wchar_t));
GetModuleFileNameW(hinstance, temp, size);
c16stombs(s, temp, size);
free(temp);
}
}
void
plat_tempfile(wchar_t *bufp, wchar_t *prefix, wchar_t *suffix)
plat_tempfile(char *bufp, char *prefix, char *suffix)
{
SYSTEMTIME SystemTime;
char temp[1024];
if (prefix != NULL)
sprintf(temp, "%ls-", prefix);
sprintf(bufp, "%s-", prefix);
else
strcpy(temp, "");
strcpy(bufp, "");
GetSystemTime(&SystemTime);
sprintf(&temp[strlen(temp)], "%d%02d%02d-%02d%02d%02d-%03d%ls",
sprintf(&bufp[strlen(bufp)], "%d%02d%02d-%02d%02d%02d-%03d%s",
SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay,
SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond,
SystemTime.wMilliseconds,
suffix);
mbstowcs(bufp, temp, strlen(temp)+1);
}
int
plat_getcwd(wchar_t *bufp, int max)
plat_getcwd(char *bufp, int max)
{
(void)_wgetcwd(bufp, max);
wchar_t *temp;
if (acp_utf8)
(void)_getcwd(bufp, max);
else {
temp = malloc(max * sizeof(wchar_t));
(void)_wgetcwd(temp, max);
c16stombs(bufp, temp, max);
free(temp);
}
return(0);
}
int
plat_chdir(wchar_t *path)
plat_chdir(char *path)
{
return(_wchdir(path));
wchar_t *temp;
int len, ret;
if (acp_utf8)
return(_chdir(path));
else {
len = mbstoc16s(NULL, path, 0) + 1;
temp = malloc(len * sizeof(wchar_t));
mbstoc16s(temp, path, len);
ret = _wchdir(temp);
free(temp);
return ret;
}
}
FILE *
plat_fopen(wchar_t *path, wchar_t *mode)
plat_fopen(const char *path, const char *mode)
{
return(_wfopen(path, mode));
wchar_t *pathw, *modew;
int len;
FILE *fp;
if (acp_utf8)
return fopen(path, mode);
else {
len = mbstoc16s(NULL, path, 0) + 1;
pathw = malloc(sizeof(wchar_t) * len);
mbstoc16s(pathw, path, len);
len = mbstoc16s(NULL, mode, 0) + 1;
modew = malloc(sizeof(wchar_t) * len);
mbstoc16s(modew, mode, len);
fp = _wfopen(pathw, modew);
free(pathw);
free(modew);
return fp;
}
}
/* Open a file, using Unicode pathname, with 64bit pointers. */
FILE *
plat_fopen64(const wchar_t *path, const wchar_t *mode)
plat_fopen64(const char *path, const char *mode)
{
return(_wfopen(path, mode));
return plat_fopen(path, mode);
}
void
plat_remove(wchar_t *path)
plat_remove(char *path)
{
_wremove(path);
wchar_t *temp;
int len;
if (acp_utf8)
remove(path);
else {
len = mbstoc16s(NULL, path, 0) + 1;
temp = malloc(len * sizeof(wchar_t));
mbstoc16s(temp, path, len);
_wremove(temp);
free(temp);
}
}
/* Make sure a path ends with a trailing (back)slash. */
void
plat_path_slash(wchar_t *path)
plat_path_slash(char *path)
{
if ((path[wcslen(path)-1] != L'\\') &&
(path[wcslen(path)-1] != L'/')) {
wcscat(path, L"\\");
if ((path[strlen(path)-1] != '\\') &&
(path[strlen(path)-1] != '/')) {
strcat(path, "\\");
}
}
/* Check if the given path is absolute or not. */
int
plat_path_abs(wchar_t *path)
plat_path_abs(char *path)
{
if ((path[1] == L':') || (path[0] == L'\\') || (path[0] == L'/'))
if ((path[1] == ':') || (path[0] == '\\') || (path[0] == '/'))
return(1);
return(0);
@@ -595,33 +702,33 @@ plat_path_abs(wchar_t *path)
/* Return the last element of a pathname. */
wchar_t *
plat_get_basename(const wchar_t *path)
char *
plat_get_basename(const char *path)
{
int c = (int)wcslen(path);
int c = (int)strlen(path);
while (c > 0) {
if (path[c] == L'/' || path[c] == L'\\')
return((wchar_t *)&path[c]);
if (path[c] == '/' || path[c] == '\\')
return((char *)&path[c]);
c--;
}
return((wchar_t *)path);
return((char *)path);
}
/* Return the 'directory' element of a pathname. */
void
plat_get_dirname(wchar_t *dest, const wchar_t *path)
plat_get_dirname(char *dest, const char *path)
{
int c = (int)wcslen(path);
wchar_t *ptr;
int c = (int)strlen(path);
char *ptr;
ptr = (wchar_t *)path;
ptr = (char *)path;
while (c > 0) {
if (path[c] == L'/' || path[c] == L'\\') {
ptr = (wchar_t *)&path[c];
if (path[c] == '/' || path[c] == '\\') {
ptr = (char *)&path[c];
break;
}
c--;
@@ -630,17 +737,17 @@ plat_get_dirname(wchar_t *dest, const wchar_t *path)
/* Copy to destination. */
while (path < ptr)
*dest++ = *path++;
*dest = L'\0';
*dest = '\0';
}
wchar_t *
plat_get_filename(wchar_t *s)
char *
plat_get_filename(char *s)
{
int c = wcslen(s) - 1;
int c = strlen(s) - 1;
while (c > 0) {
if (s[c] == L'/' || s[c] == L'\\')
if (s[c] == '/' || s[c] == '\\')
return(&s[c+1]);
c--;
}
@@ -649,47 +756,61 @@ plat_get_filename(wchar_t *s)
}
wchar_t *
plat_get_extension(wchar_t *s)
char *
plat_get_extension(char *s)
{
int c = wcslen(s) - 1;
int c = strlen(s) - 1;
if (c <= 0)
return(s);
while (c && s[c] != L'.')
while (c && s[c] != '.')
c--;
if (!c)
return(&s[wcslen(s)]);
return(&s[strlen(s)]);
return(&s[c+1]);
}
void
plat_append_filename(wchar_t *dest, wchar_t *s1, wchar_t *s2)
plat_append_filename(char *dest, char *s1, char *s2)
{
wcscat(dest, s1);
strcpy(dest, s1);
plat_path_slash(dest);
wcscat(dest, s2);
strcat(dest, s2);
}
void
plat_put_backslash(wchar_t *s)
plat_put_backslash(char *s)
{
int c = wcslen(s) - 1;
int c = strlen(s) - 1;
if (s[c] != L'/' && s[c] != L'\\')
s[c] = L'/';
if (s[c] != '/' && s[c] != '\\')
s[c] = '/';
}
int
plat_dir_check(wchar_t *path)
plat_dir_check(char *path)
{
DWORD dwAttrib = GetFileAttributes(path);
DWORD dwAttrib;
int len;
wchar_t *temp;
if (acp_utf8)
dwAttrib = GetFileAttributesA(path);
else {
len = mbstoc16s(NULL, path, 0) + 1;
temp = malloc(len * sizeof(wchar_t));
mbstoc16s(temp, path, len);
dwAttrib = GetFileAttributesW(temp);
free(temp);
}
return(((dwAttrib != INVALID_FILE_ATTRIBUTES &&
(dwAttrib & FILE_ATTRIBUTE_DIRECTORY))) ? 1 : 0);
@@ -697,9 +818,24 @@ plat_dir_check(wchar_t *path)
int
plat_dir_create(wchar_t *path)
plat_dir_create(char *path)
{
return((int)SHCreateDirectory(hwndMain, path));
int ret, len;
wchar_t *temp;
if (acp_utf8)
return (int)SHCreateDirectoryExA(NULL, path, NULL);
else {
len = mbstoc16s(NULL, path, 0) + 1;
temp = malloc(len * sizeof(wchar_t));
mbstoc16s(temp, path, len);
ret = (int)SHCreateDirectoryExW(NULL, temp, NULL);
free(temp);
return ret;
}
}

View File

@@ -42,12 +42,12 @@
void
floppy_mount(uint8_t id, wchar_t *fn, uint8_t wp)
floppy_mount(uint8_t id, char *fn, uint8_t wp)
{
fdd_close(id);
ui_writeprot[id] = wp;
fdd_load(id, fn);
ui_sb_update_icon_state(SB_FLOPPY | id, wcslen(floppyfns[id]) ? 0 : 1);
ui_sb_update_icon_state(SB_FLOPPY | id, strlen(floppyfns[id]) ? 0 : 1);
media_menu_update_floppy(id);
ui_sb_update_tip(SB_FLOPPY | id);
config_save();
@@ -80,10 +80,10 @@ plat_cdrom_ui_update(uint8_t id, uint8_t reload)
}
void
cdrom_mount(uint8_t id, wchar_t *fn)
cdrom_mount(uint8_t id, char *fn)
{
cdrom[id].prev_host_drive = cdrom[id].host_drive;
wcscpy(cdrom[id].prev_image_path, cdrom[id].image_path);
strcpy(cdrom[id].prev_image_path, cdrom[id].image_path);
if (cdrom[id].ops && cdrom[id].ops->exit)
cdrom[id].ops->exit(&(cdrom[id]));
cdrom[id].ops = NULL;
@@ -92,7 +92,7 @@ cdrom_mount(uint8_t id, wchar_t *fn)
/* Signal media change to the emulated machine. */
if (cdrom[id].insert)
cdrom[id].insert(cdrom[id].priv);
cdrom[id].host_drive = (wcslen(cdrom[id].image_path) == 0) ? 0 : 200;
cdrom[id].host_drive = (strlen(cdrom[id].image_path) == 0) ? 0 : 200;
if (cdrom[id].host_drive == 200) {
ui_sb_update_icon_state(SB_CDROM | id, 0);
} else {
@@ -122,7 +122,7 @@ mo_eject(uint8_t id)
void
mo_mount(uint8_t id, wchar_t *fn, uint8_t wp)
mo_mount(uint8_t id, char *fn, uint8_t wp)
{
mo_t *dev = (mo_t *) mo_drives[id].priv;
@@ -131,7 +131,7 @@ mo_mount(uint8_t id, wchar_t *fn, uint8_t wp)
mo_load(dev, fn);
mo_insert(dev);
ui_sb_update_icon_state(SB_MO | id, wcslen(mo_drives[id].image_path) ? 0 : 1);
ui_sb_update_icon_state(SB_MO | id, strlen(mo_drives[id].image_path) ? 0 : 1);
media_menu_update_mo(id);
ui_sb_update_tip(SB_MO | id);
@@ -145,7 +145,7 @@ mo_reload(uint8_t id)
mo_t *dev = (mo_t *) mo_drives[id].priv;
mo_disk_reload(dev);
if (wcslen(mo_drives[id].image_path) == 0) {
if (strlen(mo_drives[id].image_path) == 0) {
ui_sb_update_icon_state(SB_MO|id, 1);
} else {
ui_sb_update_icon_state(SB_MO|id, 0);
@@ -176,7 +176,7 @@ zip_eject(uint8_t id)
void
zip_mount(uint8_t id, wchar_t *fn, uint8_t wp)
zip_mount(uint8_t id, char *fn, uint8_t wp)
{
zip_t *dev = (zip_t *) zip_drives[id].priv;
@@ -185,7 +185,7 @@ zip_mount(uint8_t id, wchar_t *fn, uint8_t wp)
zip_load(dev, fn);
zip_insert(dev);
ui_sb_update_icon_state(SB_ZIP | id, wcslen(zip_drives[id].image_path) ? 0 : 1);
ui_sb_update_icon_state(SB_ZIP | id, strlen(zip_drives[id].image_path) ? 0 : 1);
media_menu_update_zip(id);
ui_sb_update_tip(SB_ZIP | id);
@@ -199,7 +199,7 @@ zip_reload(uint8_t id)
zip_t *dev = (zip_t *) zip_drives[id].priv;
zip_disk_reload(dev);
if (wcslen(zip_drives[id].image_path) == 0) {
if (strlen(zip_drives[id].image_path) == 0) {
ui_sb_update_icon_state(SB_ZIP|id, 1);
} else {
ui_sb_update_icon_state(SB_ZIP|id, 0);

View File

@@ -124,7 +124,7 @@ ui_msgbox_ex(int flags, void *header, void *message, void *btn1, void *btn2, voi
/* If the message is an ANSI string, convert it. */
tdconfig.pszContent = (WCHAR *) STRING_OR_RESOURCE(message);
if (flags & MBX_ANSI) {
mbstowcs(temp, (char *)message, strlen((char *)message)+1);
mbstoc16s(temp, (char *)message, strlen((char *)message)+1);
tdconfig.pszContent = temp;
}
@@ -194,7 +194,7 @@ file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, WCHAR *title, int save)
plat_chdir(usr_path);
if (r) {
wcstombs(openfilestring, wopenfilestring, sizeof(openfilestring));
c16stombs(openfilestring, wopenfilestring, sizeof(openfilestring));
filterindex = ofn.nFilterIndex;
return(0);
@@ -209,9 +209,9 @@ file_dlg(HWND hwnd, WCHAR *f, char *fn, char *title, int save)
{
WCHAR ufn[512], title_buf[512];
mbstowcs(ufn, fn, strlen(fn) + 1);
mbstoc16s(ufn, fn, strlen(fn) + 1);
if (title)
mbstowcs(title_buf, title, sizeof title_buf);
mbstoc16s(title_buf, title, sizeof title_buf);
return(file_dlg_w(hwnd, f, ufn, title ? title_buf : NULL, save));
}
@@ -222,10 +222,10 @@ file_dlg_mb(HWND hwnd, char *f, char *fn, char *title, int save)
{
WCHAR uf[512], ufn[512], title_buf[512];
mbstowcs(uf, f, strlen(fn) + 1);
mbstowcs(ufn, fn, strlen(fn) + 1);
mbstoc16s(uf, f, strlen(fn) + 1);
mbstoc16s(ufn, fn, strlen(fn) + 1);
if (title)
mbstowcs(title_buf, title, sizeof title_buf);
mbstoc16s(title_buf, title, sizeof title_buf);
return(file_dlg_w(hwnd, uf, ufn, title ? title_buf : NULL, save));
}
@@ -236,7 +236,7 @@ file_dlg_w_st(HWND hwnd, int id, WCHAR *fn, char *title, int save)
{
WCHAR title_buf[512];
if (title)
mbstowcs(title_buf, title, sizeof title_buf);
mbstoc16s(title_buf, title, sizeof title_buf);
return(file_dlg_w(hwnd, plat_get_string(id), fn, title ? title_buf : NULL, save));
}

View File

@@ -68,9 +68,7 @@ void
discord_update_activity(int paused)
{
struct DiscordActivity activity;
wchar_t config_name_w[1024];
char config_name[128];
char *temp;
char config_name[1024];
if(discord_activities == NULL)
return;
@@ -79,17 +77,16 @@ discord_update_activity(int paused)
memset(&activity, 0x00, sizeof(activity));
plat_get_dirname(config_name_w, usr_path);
if (WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, plat_get_filename(config_name_w), -1, config_name, 128, NULL, NULL) > 0)
plat_get_dirname(config_name, usr_path);
if (strlen(plat_get_filename(config_name)) < 100)
{
sprintf_s(activity.details, 128, "Running \"%s\"", config_name);
sprintf_s(activity.state, 128, "%s (%s)", strchr(machine_getname(), ']') + 2, cpu_s->name);
sprintf_s(activity.details, sizeof(activity.details), "Running \"%s\"", plat_get_filename(config_name));
sprintf_s(activity.state, sizeof(activity.state), "%s (%s)", strchr(machine_getname(), ']') + 2, cpu_s->name);
}
else
{
temp = strchr(machine_getname(), ']') + 2;
strncpy(activity.details, temp, 127);
strncpy(activity.state, cpu_s->name, 127);
strncpy(activity.details, strchr(machine_getname(), ']') + 2, sizeof(activity.details) - 1);
strncpy(activity.state, cpu_s->name, sizeof(activity.state) - 1);
}
activity.timestamps.start = time(NULL);

View File

@@ -69,17 +69,18 @@ media_menu_load_resource(wchar_t *lpName)
static void
media_menu_set_name_floppy(int drive)
{
wchar_t name[512], temp[512];
wchar_t name[512], temp[512], fn[512];
MENUITEMINFO mii = { 0 };
mbstowcs(temp, fdd_getname(fdd_get_type(drive)),
mbstoc16s(temp, fdd_getname(fdd_get_type(drive)),
strlen(fdd_getname(fdd_get_type(drive))) + 1);
if (wcslen(floppyfns[drive]) == 0) {
if (strlen(floppyfns[drive]) == 0) {
_swprintf(name, plat_get_string(IDS_2108),
drive + 1, temp, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, floppyfns[drive], sizeof_w(fn));
_swprintf(name, plat_get_string(IDS_2108),
drive + 1, temp, floppyfns[drive]);
drive + 1, temp, fn);
}
mii.cbSize = sizeof(mii);
@@ -92,7 +93,7 @@ media_menu_set_name_floppy(int drive)
static void
media_menu_set_name_cdrom(int drive)
{
wchar_t name[512], *temp;
wchar_t name[512], *temp, fn[512];
MENUITEMINFO mii = { 0 };
int bus = cdrom[drive].bus_type;
@@ -101,10 +102,14 @@ media_menu_set_name_cdrom(int drive)
temp = plat_get_string(id);
if (cdrom[drive].host_drive == 200) {
if (wcslen(cdrom[drive].image_path) == 0)
_swprintf(name, plat_get_string(IDS_5120), drive+1, temp, plat_get_string(IDS_2057));
else
_swprintf(name, plat_get_string(IDS_5120), drive+1, temp, cdrom[drive].image_path);
if (strlen(cdrom[drive].image_path) == 0) {
_swprintf(name, plat_get_string(IDS_5120),
drive+1, temp, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, cdrom[drive].image_path, sizeof_w(fn));
_swprintf(name, plat_get_string(IDS_5120),
drive+1, temp, fn);
}
} else
_swprintf(name, plat_get_string(IDS_5120), drive+1, temp, plat_get_string(IDS_2057));
@@ -118,7 +123,7 @@ media_menu_set_name_cdrom(int drive)
static void
media_menu_set_name_zip(int drive)
{
wchar_t name[512], *temp;
wchar_t name[512], *temp, fn[512];
MENUITEMINFO mii = { 0 };
int bus = zip_drives[drive].bus_type;
@@ -128,10 +133,11 @@ media_menu_set_name_zip(int drive)
int type = zip_drives[drive].is_250 ? 250 : 100;
if (wcslen(zip_drives[drive].image_path) == 0) {
if (strlen(zip_drives[drive].image_path) == 0) {
_swprintf(name, plat_get_string(IDS_2054),
type, drive+1, temp, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, zip_drives[drive].image_path, sizeof_w(fn));
_swprintf(name, plat_get_string(IDS_2054),
type, drive+1, temp, zip_drives[drive].image_path);
}
@@ -146,7 +152,7 @@ media_menu_set_name_zip(int drive)
static void
media_menu_set_name_mo(int drive)
{
wchar_t name[512], *temp;
wchar_t name[512], *temp, fn[512];
MENUITEMINFO mii = { 0 };
int bus = mo_drives[drive].bus_type;
@@ -154,12 +160,13 @@ media_menu_set_name_mo(int drive)
temp = plat_get_string(id);
if (wcslen(mo_drives[drive].image_path) == 0) {
if (strlen(mo_drives[drive].image_path) == 0) {
_swprintf(name, plat_get_string(IDS_2115),
drive+1, temp, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, mo_drives[drive].image_path, sizeof_w(fn));
_swprintf(name, plat_get_string(IDS_2115),
drive+1, temp, mo_drives[drive].image_path);
drive+1, temp, fn);
}
mii.cbSize = sizeof(mii);
@@ -174,7 +181,7 @@ media_menu_update_floppy(int id)
{
int i = FDD_FIRST + id;
if (floppyfns[id][0] == 0x0000) {
if (strlen(floppyfns[id]) == 0) {
EnableMenuItem(menus[i], IDM_FLOPPY_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(menus[i], IDM_FLOPPY_EXPORT_TO_86F | id, MF_BYCOMMAND | MF_GRAYED);
} else {
@@ -217,12 +224,12 @@ media_menu_update_zip(int id)
{
int i = ZIP_FIRST + id;
if (zip_drives[id].image_path[0] == 0x0000)
if (strlen(zip_drives[id].image_path) == 0)
EnableMenuItem(menus[i], IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
else
EnableMenuItem(menus[i], IDM_ZIP_EJECT | id, MF_BYCOMMAND | MF_ENABLED);
if(zip_drives[id].prev_image_path[0] == 0x0000)
if(strlen(zip_drives[id].prev_image_path) == 0)
EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
else
EnableMenuItem(menus[i], IDM_ZIP_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
@@ -235,12 +242,12 @@ media_menu_update_mo(int id)
{
int i = MO_FIRST + id;
if (mo_drives[id].image_path[0] == 0x0000)
if (strlen(mo_drives[id].image_path) == 0)
EnableMenuItem(menus[i], IDM_MO_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
else
EnableMenuItem(menus[i], IDM_MO_EJECT | id, MF_BYCOMMAND | MF_ENABLED);
if(mo_drives[id].prev_image_path[0] == 0x0000)
if(strlen(mo_drives[id].prev_image_path) == 0)
EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
else
EnableMenuItem(menus[i], IDM_MO_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
@@ -413,9 +420,9 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
wp = 1;
/* FALLTHROUGH */
case IDM_FLOPPY_IMAGE_EXISTING:
ret = file_dlg_w_st(hwnd, IDS_2109, floppyfns[id], NULL, 0);
ret = file_dlg_st(hwnd, IDS_2109, floppyfns[id], NULL, 0);
if (! ret) {
floppy_mount(id, wopenfilestring, wp);
floppy_mount(id, openfilestring, wp);
}
break;
@@ -424,10 +431,10 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case IDM_FLOPPY_EXPORT_TO_86F:
ret = file_dlg_w_st(hwnd, IDS_2076, floppyfns[id], NULL, 1);
ret = file_dlg_st(hwnd, IDS_2076, floppyfns[id], NULL, 1);
if (! ret) {
plat_pause(1);
ret = d86f_export(id, wopenfilestring);
ret = d86f_export(id, openfilestring);
if (!ret)
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_4108, (wchar_t *) IDS_4115);
plat_pause(0);
@@ -450,8 +457,8 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case IDM_CDROM_IMAGE:
if (!file_dlg_w_st(hwnd, IDS_2140, cdrom[id].image_path, NULL, 0)) {
cdrom_mount(id, wopenfilestring);
if (!file_dlg_st(hwnd, IDS_2140, cdrom[id].image_path, NULL, 0)) {
cdrom_mount(id, openfilestring);
}
break;
@@ -463,9 +470,9 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
wp = 1;
/* FALLTHROUGH */
case IDM_ZIP_IMAGE_EXISTING:
ret = file_dlg_w_st(hwnd, IDS_2058, zip_drives[id].image_path, NULL, 0);
ret = file_dlg_st(hwnd, IDS_2058, zip_drives[id].image_path, NULL, 0);
if (! ret)
zip_mount(id, wopenfilestring, wp);
zip_mount(id, openfilestring, wp);
break;
case IDM_ZIP_EJECT:
@@ -484,9 +491,9 @@ media_menu_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
wp = 1;
/* FALLTHROUGH */
case IDM_MO_IMAGE_EXISTING:
ret = file_dlg_w_st(hwnd, IDS_2116, mo_drives[id].image_path, NULL, 0);
ret = file_dlg_st(hwnd, IDS_2116, mo_drives[id].image_path, NULL, 0);
if (! ret)
mo_mount(id, wopenfilestring, wp);
mo_mount(id, openfilestring, wp);
break;
case IDM_MO_EJECT:

View File

@@ -71,7 +71,7 @@ static unsigned char *empty;
static int
create_86f(WCHAR *file_name, disk_size_t disk_size, uint8_t rpm_mode)
create_86f(char *file_name, disk_size_t disk_size, uint8_t rpm_mode)
{
FILE *f;
@@ -139,7 +139,7 @@ create_86f(WCHAR *file_name, disk_size_t disk_size, uint8_t rpm_mode)
memset(tarray, 0, 2048);
memset(empty, 0, array_size);
f = plat_fopen(file_name, L"wb");
f = plat_fopen(file_name, "wb");
if (!f)
return 0;
@@ -178,7 +178,7 @@ static int is_mo;
static int
create_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_fdi)
create_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_fdi)
{
FILE *f;
uint32_t total_size = 0;
@@ -191,7 +191,7 @@ create_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_fdi)
uint32_t zero_bytes = 0;
uint16_t base = 0x1000;
f = plat_fopen(file_name, L"wb");
f = plat_fopen(file_name, "wb");
if (!f)
return 0;
@@ -284,7 +284,7 @@ create_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_fdi)
static int
create_zip_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_zdi, HWND hwnd)
create_zip_sector_image(char *file_name, disk_size_t disk_size, uint8_t is_zdi, HWND hwnd)
{
HWND h;
FILE *f;
@@ -301,7 +301,7 @@ create_zip_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_zdi,
uint32_t i;
MSG msg;
f = plat_fopen(file_name, L"wb");
f = plat_fopen(file_name, "wb");
if (!f)
return 0;
@@ -521,7 +521,7 @@ create_zip_sector_image(WCHAR *file_name, disk_size_t disk_size, uint8_t is_zdi,
static int
create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND hwnd)
create_mo_sector_image(char *file_name, int8_t disk_size, uint8_t is_mdi, HWND hwnd)
{
HWND h;
FILE *f;
@@ -535,7 +535,7 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
uint32_t i, j;
MSG msg;
f = plat_fopen(file_name, L"wb");
f = plat_fopen(file_name, "wb");
if (!f)
return 0;
@@ -646,7 +646,7 @@ create_mo_sector_image(WCHAR *file_name, int8_t disk_size, uint8_t is_mdi, HWND
static int fdd_id, sb_part;
static int file_type = 0; /* 0 = IMG, 1 = Japanese FDI, 2 = 86F */
static wchar_t fd_file_name[1024];
static char fd_file_name[1024];
/* Show a MessageBox dialog. This is nasty, I know. --FvK */
@@ -704,7 +704,7 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
switch (message) {
case WM_INITDIALOG:
plat_pause(1);
memset(fd_file_name, 0, 1024 * sizeof(wchar_t));
memset(fd_file_name, 0, 1024);
h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE);
if (is_zip) {
zip_types = zip_drives[fdd_id].is_250 ? 2 : 1;
@@ -802,7 +802,7 @@ NewFloppyDialogProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
}
SendMessage(h, WM_SETTEXT, 0, (LPARAM) wopenfilestring);
memset(fd_file_name, 0, sizeof(fd_file_name));
wcscpy(fd_file_name, wopenfilestring);
c16stombs(fd_file_name, wopenfilestring, sizeof(fd_file_name));
h = GetDlgItem(hdlg, IDC_COMBO_DISK_SIZE);
if (!is_zip || zip_drives[fdd_id].is_250)
EnableWindow(h, TRUE);

View File

@@ -2100,7 +2100,7 @@ win_settings_hard_disks_update_item(HWND hdlg, int i, int column)
{
HWND hwndList = GetDlgItem(hdlg, IDC_LIST_HARD_DISKS);
LVITEM lvI;
WCHAR szText[256];
WCHAR szText[256], usr_path_w[1024];
lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvI.stateMask = lvI.iSubItem = lvI.state = 0;
@@ -2132,10 +2132,11 @@ win_settings_hard_disks_update_item(HWND hdlg, int i, int column)
lvI.pszText = szText;
lvI.iImage = 0;
} else if (column == 1) {
if (!wcsnicmp(temp_hdd[i].fn, usr_path, wcslen(usr_path)))
lvI.pszText = temp_hdd[i].fn + wcslen(usr_path);
if (!strnicmp(temp_hdd[i].fn, usr_path, strlen(usr_path)))
mbstoc16s(szText, temp_hdd[i].fn + strlen(usr_path), sizeof_w(szText));
else
lvI.pszText = temp_hdd[i].fn;
mbstoc16s(szText, temp_hdd[i].fn, sizeof_w(szText));
lvI.pszText = szText;
lvI.iImage = 0;
} else if (column == 2) {
wsprintf(szText, plat_get_string(IDS_4098), temp_hdd[i].tracks);
@@ -2165,9 +2166,11 @@ win_settings_hard_disks_recalc_list(HWND hdlg)
{
LVITEM lvI;
int i, j = 0;
WCHAR szText[256];
WCHAR szText[256], usr_path_w[1024];
HWND hwndList = GetDlgItem(hdlg, IDC_LIST_HARD_DISKS);
mbstoc16s(usr_path_w, usr_path, sizeof_w(usr_path_w));
hd_listview_items = 0;
lv1_current_sel = -1;
@@ -2208,10 +2211,11 @@ win_settings_hard_disks_recalc_list(HWND hdlg)
return FALSE;
lvI.iSubItem = 1;
if (!wcsnicmp(temp_hdd[i].fn, usr_path, wcslen(usr_path)))
lvI.pszText = temp_hdd[i].fn + wcslen(usr_path);
if (!strnicmp(temp_hdd[i].fn, usr_path, strlen(usr_path)))
mbstoc16s(szText, temp_hdd[i].fn + strlen(usr_path), sizeof_w(szText));
else
lvI.pszText = temp_hdd[i].fn;
mbstoc16s(szText, temp_hdd[i].fn, sizeof_w(szText));
lvI.pszText = szText;
if (ListView_SetItem(hwndList, &lvI) == -1)
return FALSE;
@@ -2706,8 +2710,8 @@ win_settings_hard_disks_add_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM
}
memset(hdd_ptr->fn, 0, sizeof(hdd_ptr->fn));
wcscpy(hdd_ptr->fn, hd_file_name);
wcstombs(hd_file_name_multibyte, hd_file_name, sizeof hd_file_name_multibyte);
c16stombs(hdd_ptr->fn, hd_file_name, sizeof(hdd_ptr->fn));
strcpy(hd_file_name_multibyte, hdd_ptr->fn);
sector_size = 512;
@@ -2867,7 +2871,7 @@ hdd_add_file_open_error:
return TRUE;
}
if (existing & 1) {
if (image_is_hdi(wopenfilestring) || image_is_hdx(wopenfilestring, 1)) {
if (image_is_hdi(openfilestring) || image_is_hdx(openfilestring, 1)) {
fseeko64(f, 0x10, SEEK_SET);
fread(&sector_size, 1, 4, f);
if (sector_size != 512) {
@@ -2879,10 +2883,9 @@ hdd_add_file_open_error:
fread(&spt, 1, 4, f);
fread(&hpc, 1, 4, f);
fread(&tracks, 1, 4, f);
} else if (image_is_vhd(wopenfilestring, 1)) {
} else if (image_is_vhd(openfilestring, 1)) {
fclose(f);
wcstombs(hd_file_name_multibyte, wopenfilestring, sizeof hd_file_name_multibyte);
MVHDMeta* vhd = mvhd_open(hd_file_name_multibyte, 0, &vhd_error);
MVHDMeta* vhd = mvhd_open(openfilestring, 0, &vhd_error);
if (vhd == NULL) {
settings_msgbox_header(MBX_ERROR, (existing & 1) ? (wchar_t *) IDS_4114 : (wchar_t *) IDS_4115, (existing & 1) ? (wchar_t *) IDS_4107 : (wchar_t *) IDS_4108);
return TRUE;
@@ -3453,7 +3456,7 @@ win_settings_hard_disks_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPar
return FALSE;
case IDC_BUTTON_HDD_REMOVE:
memcpy(temp_hdd[lv1_current_sel].fn, L"", sizeof(L""));
temp_hdd[lv1_current_sel].fn[0] = '\0';
hard_disk_untrack(lv1_current_sel);
temp_hdd[lv1_current_sel].bus = HDD_BUS_DISABLED; /* Only set the bus to zero, the list normalize code below will take care of turning this entire entry to a complete zero. */
normalize_hd_list(); /* Normalize the hard disks so that non-disabled hard disks start from index 0, and so they are contiguous. */
@@ -3513,10 +3516,7 @@ win_settings_floppy_drives_recalc_list(HWND hdlg)
lvI.iSubItem = 0;
if (temp_fdd_types[i] > 0) {
t = fdd_getname(temp_fdd_types[i]);
if (strlen(t) <= 256)
strcpy(s, t);
else
strncpy(s, t, 256);
strncpy(s, t, sizeof(s) - 1);
mbstowcs(szText, s, strlen(s) + 1);
lvI.pszText = szText;
} else
@@ -3950,10 +3950,7 @@ win_settings_floppy_drives_update_item(HWND hdlg, int i)
if (temp_fdd_types[i] > 0) {
t = fdd_getname(temp_fdd_types[i]);
if (strlen(t) <= 256)
strcpy(s, t);
else
strncpy(s, t, 256);
strncpy(s, t, sizeof(s) - 1);
mbstowcs(szText, s, strlen(s) + 1);
lvI.pszText = szText;
} else

View File

@@ -180,17 +180,19 @@ StatusBarCreateFloppyTip(int part)
{
WCHAR wtext[512];
WCHAR tempTip[512];
WCHAR fn[512];
int drive = sb_part_meanings[part] & 0xf;
mbstowcs(wtext, fdd_getname(fdd_get_type(drive)),
mbstoc16s(wtext, fdd_getname(fdd_get_type(drive)),
strlen(fdd_getname(fdd_get_type(drive))) + 1);
if (wcslen(floppyfns[drive]) == 0) {
if (strlen(floppyfns[drive]) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2108),
drive+1, wtext, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, floppyfns[drive], sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_2108),
drive+1, wtext, floppyfns[drive]);
drive+1, wtext, fn);
}
if (sbTips[part] != NULL) {
@@ -207,6 +209,7 @@ StatusBarCreateCdromTip(int part)
{
WCHAR tempTip[512];
WCHAR *szText;
WCHAR fn[512];
int id;
int drive = sb_part_meanings[part] & 0xf;
int bus = cdrom[drive].bus_type;
@@ -215,10 +218,14 @@ StatusBarCreateCdromTip(int part)
szText = plat_get_string(id);
if (cdrom[drive].host_drive == 200) {
if (wcslen(cdrom[drive].image_path) == 0)
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057));
else
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, cdrom[drive].image_path);
if (strlen(cdrom[drive].image_path) == 0) {
_swprintf(tempTip, plat_get_string(IDS_5120),
drive+1, szText, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, cdrom[drive].image_path, sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_5120),
drive+1, szText, fn);
}
} else
_swprintf(tempTip, plat_get_string(IDS_5120), drive+1, szText, plat_get_string(IDS_2057));
@@ -236,6 +243,7 @@ StatusBarCreateZIPTip(int part)
{
WCHAR tempTip[512];
WCHAR *szText;
WCHAR fn[512];
int id;
int drive = sb_part_meanings[part] & 0xf;
int bus = zip_drives[drive].bus_type;
@@ -245,12 +253,13 @@ StatusBarCreateZIPTip(int part)
int type = zip_drives[drive].is_250 ? 250 : 100;
if (wcslen(zip_drives[drive].image_path) == 0) {
if (strlen(zip_drives[drive].image_path) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2054),
type, drive+1, szText, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, zip_drives[drive].image_path, sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_2054),
type, drive+1, szText, zip_drives[drive].image_path);
type, drive+1, szText, fn);
}
if (sbTips[part] != NULL) {
@@ -267,6 +276,7 @@ StatusBarCreateMOTip(int part)
{
WCHAR tempTip[512];
WCHAR *szText;
WCHAR fn[512];
int id;
int drive = sb_part_meanings[part] & 0xf;
int bus = mo_drives[drive].bus_type;
@@ -274,10 +284,11 @@ StatusBarCreateMOTip(int part)
id = IDS_5377 + (bus - 1);
szText = plat_get_string(id);
if (wcslen(mo_drives[drive].image_path) == 0) {
if (strlen(mo_drives[drive].image_path) == 0) {
_swprintf(tempTip, plat_get_string(IDS_2115),
drive+1, szText, plat_get_string(IDS_2057));
} else {
mbstoc16s(fn, mo_drives[drive].image_path, sizeof_w(fn));
_swprintf(tempTip, plat_get_string(IDS_2115),
drive+1, szText, mo_drives[drive].image_path);
}
@@ -652,7 +663,7 @@ ui_sb_update_panes(void)
for (i=0; i<sb_parts; i++) {
switch (sb_part_meanings[i] & 0xf0) {
case SB_FLOPPY: /* Floppy */
sb_part_icons[i] = (wcslen(floppyfns[sb_part_meanings[i] & 0xf]) == 0) ? 128 : 0;
sb_part_icons[i] = (strlen(floppyfns[sb_part_meanings[i] & 0xf]) == 0) ? 128 : 0;
sb_part_icons[i] |= fdd_type_to_icon(fdd_get_type(sb_part_meanings[i] & 0xf));
StatusBarCreateFloppyTip(i);
break;
@@ -660,7 +671,7 @@ ui_sb_update_panes(void)
case SB_CDROM: /* CD-ROM */
id = sb_part_meanings[i] & 0xf;
if (cdrom[id].host_drive == 200)
sb_part_icons[i] = (wcslen(cdrom[id].image_path) == 0) ? 128 : 0;
sb_part_icons[i] = (strlen(cdrom[id].image_path) == 0) ? 128 : 0;
else
sb_part_icons[i] = 128;
sb_part_icons[i] |= 32;
@@ -668,13 +679,13 @@ ui_sb_update_panes(void)
break;
case SB_ZIP: /* Iomega ZIP */
sb_part_icons[i] = (wcslen(zip_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 128 : 0;
sb_part_icons[i] = (strlen(zip_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 128 : 0;
sb_part_icons[i] |= 48;
StatusBarCreateZIPTip(i);
break;
case SB_MO: /* Magneto-Optical disk */
sb_part_icons[i] = (wcslen(mo_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 128 : 0;
sb_part_icons[i] = (strlen(mo_drives[sb_part_meanings[i] & 0xf].image_path) == 0) ? 128 : 0;
sb_part_icons[i] |= 56;
StatusBarCreateMOTip(i);
break;

View File

@@ -1399,10 +1399,7 @@ ui_window_title(wchar_t *s)
{
if (! video_fullscreen) {
if (s != NULL) {
if (wcslen(s) <= 512)
wcscpy(wTitle, s);
else
wcsncpy(wTitle, s, 512);
wcsncpy(wTitle, s, sizeof_w(wTitle) - 1);
} else
s = wTitle;
@@ -1438,10 +1435,7 @@ plat_pause(int p)
if (p) {
t = ui_window_title(NULL);
if (wcslen(t) <= 511)
wcscpy(oldtitle, ui_window_title(NULL));
else
wcsncpy(oldtitle, ui_window_title(NULL), 511);
wcsncpy(oldtitle, ui_window_title(NULL), sizeof_w(oldtitle) - 1);
wcscpy(title, oldtitle);
wcscat(title, L" - PAUSED -");
ui_window_title(title);