diff --git a/src/86Box.rc b/src/86Box.rc index 997b7cf1b..c72678d63 100644 --- a/src/86Box.rc +++ b/src/86Box.rc @@ -751,8 +751,8 @@ BEGIN 2176 "Use CTRL + ALT + PAGE DOWN to return to windowed mode" 2177 "Microsoft InPort mouse" 2178 "Genius Bus mouse" - 2179 "Floppy %i (%s): %s" - 2180 "CD-ROM %i: %s" + 2179 "Floppy %i (%s): %ws" + 2180 "CD-ROM %i: %ws" 2181 "Removable disk %i: %s" 2182 "MFM hard disk" 2183 "IDE hard disk" @@ -766,7 +766,7 @@ BEGIN 2191 "ATAPI (PIO-only) (%01i:%01i)" 2192 "ATAPI (PIO and DMA) (%01i:%01i)" 2193 "Use CTRL + ALT + PAGE DOWN to return to windowed mode" - 2194 "" + 2194 "Unable to create bitmap file: %s" 2195 "English (United States)" END diff --git a/src/86box.h b/src/86box.h index 09f0a8a15..ef0a45e15 100644 --- a/src/86box.h +++ b/src/86box.h @@ -2,3 +2,4 @@ see COPYING for more details */ #define emulator_version "1.20" +#define emulator_version_w L"1.20" diff --git a/src/cdrom-iso.c b/src/cdrom-iso.c index 7fc01b246..2247baccb 100644 --- a/src/cdrom-iso.c +++ b/src/cdrom-iso.c @@ -13,7 +13,7 @@ #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE -#include +#include static CDROM iso_cdrom; @@ -48,7 +48,7 @@ void iso_audio_stop(uint8_t id) static int iso_ready(uint8_t id) { - if (strlen(cdrom_iso[id].iso_path) == 0) + if (wcslen(cdrom_iso[id].iso_path) == 0) { return 0; } @@ -68,7 +68,7 @@ static int iso_ready(uint8_t id) static int iso_medium_changed(uint8_t id) { - if (strlen(cdrom_iso[id].iso_path) == 0) + if (wcslen(cdrom_iso[id].iso_path) == 0) { return 0; } @@ -100,7 +100,7 @@ static uint8_t iso_getcurrentsubchannel(uint8_t id, uint8_t *b, int msf) { int pos=0; int32_t temp; - if (strlen(cdrom_iso[id].iso_path) == 0) + if (wcslen(cdrom_iso[id].iso_path) == 0) { return 0; } @@ -157,7 +157,7 @@ static void iso_readsector(uint8_t id, uint8_t *b, int sector) } file_pos <<= 11; memset(b, 0, 2856); - cdrom_iso[id].iso_image = fopen(cdrom_iso[id].iso_path, "rb"); + cdrom_iso[id].iso_image = _wfopen(cdrom_iso[id].iso_path, L"rb"); fseeko64(cdrom_iso[id].iso_image, file_pos, SEEK_SET); fread(b + 16, 2048, 1, cdrom_iso[id].iso_image); fclose(cdrom_iso[id].iso_image); @@ -527,7 +527,7 @@ static uint32_t iso_size(uint8_t id) { uint64_t iso_size; - cdrom_iso[id].iso_image = fopen(cdrom_iso[id].iso_path, "rb"); + cdrom_iso[id].iso_image = _wfopen(cdrom_iso[id].iso_path, L"rb"); fseeko64(cdrom_iso[id].iso_image, 0, SEEK_END); iso_size = ftello64(cdrom_iso[id].iso_image); iso_size >>= 11; @@ -547,11 +547,11 @@ void iso_reset(uint8_t id) { } -int iso_open(uint8_t id, char *fn) +int iso_open(uint8_t id, wchar_t *fn) { - struct stat64 st; + FILE *f; - if (strcmp(fn, cdrom_iso[id].iso_path) != 0) + if (wcscmp(fn, cdrom_iso[id].iso_path) != 0) { cdrom_iso[id].iso_changed = 1; } @@ -559,9 +559,9 @@ int iso_open(uint8_t id, char *fn) if (!cdrom_iso[id].iso_inited && (cdrom_drives[id].host_drive != 200)) cdrom_iso[id].iso_changed = 0; if (!cdrom_iso[id].iso_inited || cdrom_iso[id].iso_changed) { - sprintf(cdrom_iso[id].iso_path, "%s", fn); + _swprintf(cdrom_iso[id].iso_path, L"%ws", fn); } - cdrom_iso[id].iso_image = fopen(cdrom_iso[id].iso_path, "rb"); + cdrom_iso[id].iso_image = _wfopen(cdrom_iso[id].iso_path, L"rb"); cdrom_drives[id].handler = &iso_cdrom; if (!cdrom_iso[id].iso_inited || cdrom_iso[id].iso_changed) { @@ -569,8 +569,10 @@ int iso_open(uint8_t id, char *fn) fclose(cdrom_iso[id].iso_image); } - stat64(cdrom_iso[id].iso_path, &st); - cdrom_iso[id].image_size = st.st_size; + f = _wfopen(cdrom_iso[id].iso_path, L"rb"); + fseeko64(f, 0, SEEK_END); + cdrom_iso[id].image_size = ftello64(f); + fclose(f); return 0; } diff --git a/src/cdrom-iso.h b/src/cdrom-iso.h index c16ea0ebb..fa7b734fa 100644 --- a/src/cdrom-iso.h +++ b/src/cdrom-iso.h @@ -7,7 +7,7 @@ /* this header file lists the functions provided by various platform specific cdrom-ioctl files */ -extern int iso_open(uint8_t id, char *fn); +extern int iso_open(uint8_t id, wchar_t *fn); extern void iso_reset(uint8_t id); extern void iso_close(uint8_t id); diff --git a/src/cdrom.h b/src/cdrom.h index eb5e4066e..85f03a4b0 100644 --- a/src/cdrom.h +++ b/src/cdrom.h @@ -173,7 +173,7 @@ typedef struct uint32_t last_block; uint64_t image_size; int iso_inited; - char iso_path[1024]; + wchar_t iso_path[1024]; FILE* iso_image; int iso_changed; diff --git a/src/config.c b/src/config.c index 1e22f6415..20f40e197 100644 --- a/src/config.c +++ b/src/config.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "config.h" #include "ibm.h" @@ -33,6 +34,7 @@ typedef struct entry_t char name[256]; char data[256]; + wchar_t wdata[256]; } entry_t; #define list_add(new, head) \ @@ -100,7 +102,7 @@ void config_free() void config_load(char *fn) { - FILE *f = fopen(fn, "rt"); + FILE *f = fopen(fn, "rt, ccs=UNICODE"); section_t *current_section; memset(&config_head, 0, sizeof(list_t)); @@ -115,32 +117,34 @@ void config_load(char *fn) while (1) { int c; - char buffer[256]; + wchar_t buffer[1024]; + int org_pos; - fgets(buffer, 255, f); + memset(buffer, 0, 2048); + fgetws(buffer, 255, f); if (feof(f)) break; c = 0; - while (buffer[c] == ' ') + while (buffer[c] == L' ') c++; - if (!buffer[c]) continue; + if (buffer[c] == L'\0') continue; - if (buffer[c] == '#') /*Comment*/ + if (buffer[c] == L'#') /*Comment*/ continue; - if (buffer[c] == '[') /*Section*/ + if (buffer[c] == L'[') /*Section*/ { section_t *new_section; char name[256]; int d = 0; c++; - while (buffer[c] != ']' && buffer[c]) - name[d++] = buffer[c++]; + while (buffer[c] != L']' && buffer[c]) + wctomb(&(name[d++]), buffer[c++]); - if (buffer[c] != ']') + if (buffer[c] != L']') continue; name[d] = 0; @@ -157,13 +161,13 @@ void config_load(char *fn) char name[256]; int d = 0, data_pos; - while (buffer[c] != '=' && buffer[c] != ' ' && buffer[c]) - name[d++] = buffer[c++]; + while (buffer[c] != L'=' && buffer[c] != L' ' && buffer[c]) + wctomb(&(name[d++]), buffer[c++]); - if (!buffer[c]) continue; + if (buffer[c] == L'\0') continue; name[d] = 0; - while ((buffer[c] == '=' || buffer[c] == ' ') && buffer[c]) + while ((buffer[c] == L'=' || buffer[c] == L' ') && buffer[c]) c++; if (!buffer[c]) continue; @@ -171,15 +175,18 @@ void config_load(char *fn) data_pos = c; while (buffer[c]) { - if (buffer[c] == '\n') - buffer[c] = 0; + if (buffer[c] == L'\n') + buffer[c] = L'\0'; c++; } new_entry = malloc(sizeof(entry_t)); memset(new_entry, 0, sizeof(entry_t)); strncpy(new_entry->name, name, 256); - strncpy(new_entry->data, &buffer[data_pos], 256); + memcpy(new_entry->wdata, &buffer[data_pos], 512); + new_entry->wdata[255] = L'\0'; + wcstombs(new_entry->data, new_entry->wdata, 512); + new_entry->data[255] = '\0'; list_add(&new_entry->list, ¤t_section->entry_head); } } @@ -193,7 +200,7 @@ void config_load(char *fn) void config_new() { - FILE *f = fopen(config_file, "wt"); + FILE *f = fopen(config_file, "wt, ccs=UNICODE"); fclose(f); } @@ -292,6 +299,24 @@ char *config_get_string(char *head, char *name, char *def) return entry->data; } +wchar_t *config_get_wstring(char *head, char *name, wchar_t *def) +{ + section_t *section; + entry_t *entry; + + section = find_section(head); + + if (!section) + return def; + + entry = find_entry(section, name); + + if (!entry) + return def; + + return entry->wdata; +} + void config_set_int(char *head, char *name, int val) { section_t *section; @@ -308,6 +333,7 @@ void config_set_int(char *head, char *name, int val) entry = create_entry(section, name); sprintf(entry->data, "%i", val); + mbstowcs(entry->wdata, entry->data, 512); } void config_set_string(char *head, char *name, char *val) @@ -326,6 +352,25 @@ void config_set_string(char *head, char *name, char *val) entry = create_entry(section, name); strncpy(entry->data, val, 256); + mbstowcs(entry->wdata, entry->data, 256); +} + +void config_set_wstring(char *head, char *name, wchar_t *val) +{ + section_t *section; + entry_t *entry; + + section = find_section(head); + + if (!section) + section = create_section(head); + + entry = find_entry(section, name); + + if (!entry) + entry = create_entry(section, name); + + memcpy(entry->wdata, val, 512); } @@ -336,7 +381,7 @@ char *get_filename(char *s) { if (s[c] == '/' || s[c] == '\\') return &s[c+1]; - c--; + c--; } return s; } @@ -369,9 +414,27 @@ char *get_extension(char *s) return &s[c+1]; } +wchar_t *get_extension_w(wchar_t *s) +{ + int c = wcslen(s) - 1; + + if (c <= 0) + return s; + + while (c && s[c] != L'.') + c--; + + if (!c) + return &s[wcslen(s)]; + + return &s[c+1]; +} + +static wchar_t wname[512]; + void config_save(char *fn) { - FILE *f = fopen(fn, "wt"); + FILE *f = fopen(fn, "wt, ccs=UNICODE"); section_t *current_section; current_section = (section_t *)config_head.next; @@ -381,13 +444,24 @@ void config_save(char *fn) entry_t *current_entry; if (current_section->name[0]) - fprintf(f, "\n[%s]\n", current_section->name); + { + mbstowcs(wname, current_section->name, strlen(current_section->name) + 1); + _fwprintf_p(f, L"\n[%ws]\n", wname); + } current_entry = (entry_t *)current_section->entry_head.next; while (current_entry) { - fprintf(f, "%s = %s\n", current_entry->name, current_entry->data); + mbstowcs(wname, current_entry->name, strlen(current_entry->name) + 1); + if (current_entry->wdata[0] == L'\0') + { + _fwprintf_p(f, L"%ws = \n", wname); + } + else + { + _fwprintf_p(f, L"%ws = %ws\n", wname, current_entry->wdata); + } current_entry = (entry_t *)current_entry->list.next; } diff --git a/src/config.h b/src/config.h index 55e091e52..6fb3c8a2f 100644 --- a/src/config.h +++ b/src/config.h @@ -3,13 +3,16 @@ */ int config_get_int(char *head, char *name, int def); char *config_get_string(char *head, char *name, char *def); +wchar_t *config_get_wstring(char *head, char *name, wchar_t *def); void config_set_int(char *head, char *name, int val); void config_set_string(char *head, char *name, char *val); +void config_set_wstring(char *head, char *name, wchar_t *val); char *get_filename(char *s); void append_filename(char *dest, char *s1, char *s2, int size); void put_backslash(char *s); char *get_extension(char *s); +wchar_t *get_extension_w(wchar_t *s); void config_load(char *fn); void config_save(char *fn); diff --git a/src/disc.c b/src/disc.c index 70141de15..e858474ce 100644 --- a/src/disc.c +++ b/src/disc.c @@ -1,6 +1,9 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ +#define UNICODE +#include + #include "ibm.h" #include "config.h" @@ -56,68 +59,68 @@ void (*fdc_indexpulse)();*/ static struct { - char *ext; - void (*load)(int drive, char *fn); + wchar_t *ext; + void (*load)(int drive, wchar_t *fn); void (*close)(int drive); int size; } loaders[]= { - {"001", img_load, img_close, -1}, - {"002", img_load, img_close, -1}, - {"003", img_load, img_close, -1}, - {"004", img_load, img_close, -1}, - {"005", img_load, img_close, -1}, - {"006", img_load, img_close, -1}, - {"007", img_load, img_close, -1}, - {"008", img_load, img_close, -1}, - {"009", img_load, img_close, -1}, - {"010", img_load, img_close, -1}, - {"12", img_load, img_close, -1}, - {"144", img_load, img_close, -1}, - {"360", img_load, img_close, -1}, - {"720", img_load, img_close, -1}, - {"86F", d86f_load, d86f_close, -1}, - {"BIN", img_load, img_close, -1}, - {"CQ", img_load, img_close, -1}, - {"CQM", img_load, img_close, -1}, - {"DSK", img_load, img_close, -1}, - {"FDI", fdi_load, fdi_close, -1}, - {"FDF", img_load, img_close, -1}, - {"FLP", img_load, img_close, -1}, - {"HDM", img_load, img_close, -1}, - {"IMA", img_load, img_close, -1}, - {"IMD", imd_load, imd_close, -1}, - {"IMG", img_load, img_close, -1}, - {"TD0", td0_load, td0_close, -1}, - {"VFD", img_load, img_close, -1}, - {"XDF", img_load, img_close, -1}, + {L"001", img_load, img_close, -1}, + {L"002", img_load, img_close, -1}, + {L"003", img_load, img_close, -1}, + {L"004", img_load, img_close, -1}, + {L"005", img_load, img_close, -1}, + {L"006", img_load, img_close, -1}, + {L"007", img_load, img_close, -1}, + {L"008", img_load, img_close, -1}, + {L"009", img_load, img_close, -1}, + {L"010", img_load, img_close, -1}, + {L"12", img_load, img_close, -1}, + {L"144", img_load, img_close, -1}, + {L"360", img_load, img_close, -1}, + {L"720", img_load, img_close, -1}, + {L"86F", d86f_load, d86f_close, -1}, + {L"BIN", img_load, img_close, -1}, + {L"CQ", img_load, img_close, -1}, + {L"CQM", img_load, img_close, -1}, + {L"DSK", img_load, img_close, -1}, + {L"FDI", fdi_load, fdi_close, -1}, + {L"FDF", img_load, img_close, -1}, + {L"FLP", img_load, img_close, -1}, + {L"HDM", img_load, img_close, -1}, + {L"IMA", img_load, img_close, -1}, + {L"IMD", imd_load, imd_close, -1}, + {L"IMG", img_load, img_close, -1}, + {L"TD0", td0_load, td0_close, -1}, + {L"VFD", img_load, img_close, -1}, + {L"XDF", img_load, img_close, -1}, {0,0,0} }; static int driveloaders[4]; -void disc_load(int drive, char *fn) +void disc_load(int drive, wchar_t *fn) { int c = 0, size; - char *p; + wchar_t *p; FILE *f; if (!fn) return; - p = get_extension(fn); + p = get_extension_w(fn); if (!p) return; - f = fopen(fn, "rb"); + f = _wfopen(fn, L"rb"); if (!f) return; fseek(f, -1, SEEK_END); size = ftell(f) + 1; fclose(f); while (loaders[c].ext) { - if (!strcasecmp(p, loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1)) + if (!_wcsicmp(p, loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1)) { driveloaders[drive] = c; loaders[c].load(drive, fn); drive_empty[drive] = 0; - strcpy(discfns[drive], fn); + memcpy(discfns[drive], fn, (wcslen(fn) << 1) + 2); fdd_forced_seek(real_drive(drive), 0); disc_changed[drive] = 1; return; @@ -127,7 +130,8 @@ void disc_load(int drive, char *fn) pclog("Couldn't load %s %s\n",fn,p); drive_empty[drive] = 1; fdd_set_head(real_drive(drive), 0); - discfns[drive][0] = 0; + discfns[drive][0] = L'\0'; + update_status_bar_icon_state(drive, 1); } void disc_close(int drive) @@ -135,7 +139,7 @@ void disc_close(int drive) if (loaders[driveloaders[drive]].close) loaders[driveloaders[drive]].close(drive); drive_empty[drive] = 1; fdd_set_head(real_drive(drive), 0); - discfns[drive][0] = 0; + discfns[drive][0] = L'\0'; drives[drive].hole = NULL; drives[drive].poll = NULL; drives[drive].seek = NULL; @@ -146,6 +150,7 @@ void disc_close(int drive) drives[drive].format = NULL; drives[drive].byteperiod = NULL; drives[drive].stop = NULL; + update_status_bar_icon_state(drive, 1); } int disc_notfound=0; diff --git a/src/disc.h b/src/disc.h index 32bb601a0..4bf7a96cb 100644 --- a/src/disc.h +++ b/src/disc.h @@ -21,7 +21,7 @@ extern DRIVE drives[FDD_NUM]; extern int curdrive; -void disc_load(int drive, char *fn); +void disc_load(int drive, wchar_t *fn); void disc_new(int drive, char *fn); void disc_close(int drive); void disc_init(); diff --git a/src/disc_86f.c b/src/disc_86f.c index a939e9fe6..892696304 100644 --- a/src/disc_86f.c +++ b/src/disc_86f.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "lzf/lzf.h" @@ -229,7 +230,7 @@ struct __attribute__((__packed__)) uint32_t error_condition; int is_compressed; int id_found; - char original_file_name[2048]; + wchar_t original_file_name[2048]; uint8_t *filebuf; uint8_t *outbuf; uint32_t dma_over; @@ -2738,7 +2739,7 @@ void d86f_writeback(int drive) /* The image is compressed. */ /* Open the original, compressed file. */ - cf = fopen(d86f[drive].original_file_name, "wb"); + cf = _wfopen(d86f[drive].original_file_name, L"wb"); /* Write the header to the original file. */ fwrite(header, 1, header_size, cf); @@ -3018,11 +3019,11 @@ void d86f_common_handlers(int drive) drives[drive].stop = d86f_stop; } -void d86f_load(int drive, char *fn) +void d86f_load(int drive, wchar_t *fn) { uint32_t magic = 0; uint32_t len = 0; - char temp_file_name[2048]; + wchar_t temp_file_name[2048]; uint16_t temp = 0; int i = 0; FILE *tf; @@ -3030,12 +3031,15 @@ void d86f_load(int drive, char *fn) d86f_unregister(drive); writeprot[drive] = 0; - d86f[drive].f = fopen(fn, "rb+"); + d86f[drive].f = _wfopen(fn, L"rb+"); if (!d86f[drive].f) { - d86f[drive].f = fopen(fn, "rb"); + d86f[drive].f = _wfopen(fn, L"rb"); if (!d86f[drive].f) + { + update_status_bar_icon_state(drive, 1); return; + } writeprot[drive] = 1; } if (ui_writeprot[drive]) @@ -3054,6 +3058,7 @@ void d86f_load(int drive, char *fn) { /* File is WAY too small, abort. */ fclose(d86f[drive].f); + update_status_bar_icon_state(drive, 1); return; } @@ -3062,6 +3067,7 @@ void d86f_load(int drive, char *fn) /* File is not of the valid format, abort. */ d86f_log("86F: Unrecognized magic bytes: %08X\n", magic); fclose(d86f[drive].f); + update_status_bar_icon_state(drive, 1); return; } @@ -3083,6 +3089,7 @@ void d86f_load(int drive, char *fn) d86f_log("86F: Unrecognized file version: %i.%02i\n", d86f[drive].version >> 8, d86f[drive].version & 0xFF); } fclose(d86f[drive].f); + update_status_bar_icon_state(drive, 1); return; } else @@ -3098,6 +3105,7 @@ void d86f_load(int drive, char *fn) { /* File too small, abort. */ fclose(d86f[drive].f); + update_status_bar_icon_state(drive, 1); return; } @@ -3119,26 +3127,27 @@ void d86f_load(int drive, char *fn) { d86f_log("86F: CRC64 error\n"); fclose(d86f[drive].f); + update_status_bar_icon_state(drive, 1); return; } #endif if (d86f[drive].is_compressed) { - append_filename(temp_file_name, pcempath, drive ? "TEMP$$$1.$$$" : "TEMP$$$0.$$$", 511); - memcpy(temp_file_name, drive ? "TEMP$$$1.$$$" : "TEMP$$$0.$$$", 13); - memcpy(d86f[drive].original_file_name, fn, strlen(fn) + 1); + memcpy(temp_file_name, drive ? L"TEMP$$$1.$$$" : L"TEMP$$$0.$$$", 256); + memcpy(d86f[drive].original_file_name, fn, (wcslen(fn) << 1) + 2); fclose(d86f[drive].f); - d86f[drive].f = fopen(temp_file_name, "wb"); + d86f[drive].f = _wfopen(temp_file_name, L"wb"); if (!d86f[drive].f) { d86f_log("86F: Unable to create temporary decompressed file\n"); + update_status_bar_icon_state(drive, 1); return; } - tf = fopen(fn, "rb"); + tf = _wfopen(fn, L"rb"); for (i = 0; i < 8; i++) { @@ -3163,11 +3172,12 @@ void d86f_load(int drive, char *fn) if (!temp) { d86f_log("86F: Error decompressing file\n"); - remove(temp_file_name); + _wremove(temp_file_name); + update_status_bar_icon_state(drive, 1); return; } - d86f[drive].f = fopen(temp_file_name, "rb+"); + d86f[drive].f = _wfopen(temp_file_name, L"rb+"); } if (d86f[drive].disk_flags & 0x100) @@ -3177,8 +3187,9 @@ void d86f_load(int drive, char *fn) fclose(d86f[drive].f); if (d86f[drive].is_compressed) { - remove(temp_file_name); + _wremove(temp_file_name); } + update_status_bar_icon_state(drive, 1); return; } @@ -3189,8 +3200,9 @@ void d86f_load(int drive, char *fn) fclose(d86f[drive].f); if (d86f[drive].is_compressed) { - remove(temp_file_name); + _wremove(temp_file_name); } + update_status_bar_icon_state(drive, 1); return; } @@ -3206,11 +3218,11 @@ void d86f_load(int drive, char *fn) if (d86f[drive].is_compressed) { - d86f[drive].f = fopen(temp_file_name, "rb"); + d86f[drive].f = _wfopen(temp_file_name, L"rb"); } else { - d86f[drive].f = fopen(fn, "rb"); + d86f[drive].f = _wfopen(fn, L"rb"); } } @@ -3223,6 +3235,7 @@ void d86f_load(int drive, char *fn) /* File has no track 0 side 0, abort. */ d86f_log("86F: No Track 0 side 0\n"); fclose(d86f[drive].f); + update_status_bar_icon_state(drive, 1); return; } @@ -3231,6 +3244,7 @@ void d86f_load(int drive, char *fn) /* File is 2-sided but has no track 0 side 1, abort. */ d86f_log("86F: No Track 0 side 0\n"); fclose(d86f[drive].f); + update_status_bar_icon_state(drive, 1); return; } @@ -3306,14 +3320,13 @@ void d86f_init() void d86f_close(int drive) { - char temp_file_name[2048]; + wchar_t temp_file_name[2048]; - append_filename(temp_file_name, pcempath, drive ? "TEMP$$$1.$$$" : "TEMP$$$0.$$$", 511); - memcpy(temp_file_name, drive ? "TEMP$$$1.$$$" : "TEMP$$$0.$$$", 13); + memcpy(temp_file_name, drive ? "TEMP$$$1.$$$" : "TEMP$$$0.$$$", 26); if (d86f[drive].f) fclose(d86f[drive].f); if (d86f[drive].is_compressed) - remove(temp_file_name); + _wremove(temp_file_name); d86f[drive].f = NULL; } diff --git a/src/disc_86f.h b/src/disc_86f.h index 45c5838d2..7efc9b3f5 100644 --- a/src/disc_86f.h +++ b/src/disc_86f.h @@ -2,7 +2,7 @@ see COPYING for more details */ void d86f_init(); -void d86f_load(int drive, char *fn); +void d86f_load(int drive, wchar_t *fn); void d86f_close(int drive); void d86f_seek(int drive, int track); int d86f_hole(int drive); diff --git a/src/disc_fdi.c b/src/disc_fdi.c index 091524b20..b7aae9819 100644 --- a/src/disc_fdi.c +++ b/src/disc_fdi.c @@ -3,6 +3,7 @@ */ #include #include +#include #include "ibm.h" #include "disc.h" #include "disc_img.h" @@ -239,13 +240,17 @@ void d86f_register_fdi(int drive) d86f_handler[drive].check_crc = 1; } -void fdi_load(int drive, char *fn) +void fdi_load(int drive, wchar_t *fn) { char header[26]; writeprot[drive] = fwriteprot[drive] = 1; - fdi[drive].f = fopen(fn, "rb"); - if (!fdi[drive].f) return; + fdi[drive].f = _wfopen(fn, L"rb"); + if (!fdi[drive].f) + { + update_status_bar_icon_state(drive, 1); + return; + } d86f_unregister(drive); diff --git a/src/disc_fdi.h b/src/disc_fdi.h index d26340fd0..781efac23 100644 --- a/src/disc_fdi.h +++ b/src/disc_fdi.h @@ -2,7 +2,7 @@ see COPYING for more details */ void fdi_init(); -void fdi_load(int drive, char *fn); +void fdi_load(int drive, wchar_t *fn); void fdi_close(int drive); void fdi_seek(int drive, int track); void fdi_readsector(int drive, int sector, int track, int side, int density, int sector_size); diff --git a/src/disc_imd.c b/src/disc_imd.c index c69a0b674..e583335e0 100644 --- a/src/disc_imd.c +++ b/src/disc_imd.c @@ -8,6 +8,7 @@ #include "fdd.h" #include +#include typedef struct { @@ -49,7 +50,7 @@ void imd_init() void d86f_register_imd(int drive); -void imd_load(int drive, char *fn) +void imd_load(int drive, wchar_t *fn) { uint32_t magic = 0; uint32_t fsize = 0; @@ -73,12 +74,15 @@ void imd_load(int drive, char *fn) d86f_unregister(drive); writeprot[drive] = 0; - imd[drive].f = fopen(fn, "rb+"); + imd[drive].f = _wfopen(fn, L"rb+"); if (!imd[drive].f) { - imd[drive].f = fopen(fn, "rb"); + imd[drive].f = _wfopen(fn, L"rb"); if (!imd[drive].f) + { + update_status_bar_icon_state(drive, 1); return; + } writeprot[drive] = 1; } if (ui_writeprot[drive]) @@ -93,6 +97,7 @@ void imd_load(int drive, char *fn) { pclog("IMD: Not a valid ImageDisk image\n"); fclose(imd[drive].f); + update_status_bar_icon_state(drive, 1); return; } else @@ -113,6 +118,7 @@ void imd_load(int drive, char *fn) { pclog("IMD: No ASCII EOF character\n"); fclose(imd[drive].f); + update_status_bar_icon_state(drive, 1); return; } else @@ -125,6 +131,7 @@ void imd_load(int drive, char *fn) { pclog("IMD: File ends after ASCII EOF character\n"); fclose(imd[drive].f); + update_status_bar_icon_state(drive, 1); return; } else @@ -243,6 +250,7 @@ void imd_load(int drive, char *fn) /* If we can't fit the sectors with a reasonable minimum gap even at 2% slower RPM, abort. */ pclog("IMD: Unable to fit the %i sectors in a track\n", track_spt); fclose(imd[drive].f); + update_status_bar_icon_state(drive, 1); return; } } diff --git a/src/disc_imd.h b/src/disc_imd.h index 03628b031..a132605d9 100644 --- a/src/disc_imd.h +++ b/src/disc_imd.h @@ -2,6 +2,6 @@ see COPYING for more details */ void imd_init(); -void imd_load(int drive, char *fn); +void imd_load(int drive, wchar_t *fn); void imd_close(int drive); void imd_seek(int drive, int track); diff --git a/src/disc_img.c b/src/disc_img.c index a9e60c880..e5020353d 100644 --- a/src/disc_img.c +++ b/src/disc_img.c @@ -2,8 +2,10 @@ see COPYING for more details */ #include +#include #include "ibm.h" +#include "config.h" #include "disc.h" #include "disc_img.h" #include "fdc.h" @@ -296,14 +298,14 @@ int first_byte_is_valid(uint8_t first_byte) double bit_rate_300; -char ext[4]; +wchar_t *ext; uint8_t first_byte, second_byte, third_byte, fourth_byte; /* This is hard-coded to 0 - if you really need to read those NT 3.1 Beta floppy images, change this to 1 and recompile the emulator. */ uint8_t fdf_suppress_final_byte = 0; -void img_load(int drive, char *fn) +void img_load(int drive, wchar_t *fn) { int size; uint16_t bpb_bps; @@ -324,20 +326,20 @@ void img_load(int drive, char *fn) uint16_t track_bytes = 0; uint8_t *literal; - ext[0] = fn[strlen(fn) - 3] | 0x60; - ext[1] = fn[strlen(fn) - 2] | 0x60; - ext[2] = fn[strlen(fn) - 1] | 0x60; - ext[3] = 0; + ext = get_extension_w(fn); d86f_unregister(drive); writeprot[drive] = 0; - img[drive].f = fopen(fn, "rb+"); + img[drive].f = _wfopen(fn, L"rb+"); if (!img[drive].f) { - img[drive].f = fopen(fn, "rb"); + img[drive].f = _wfopen(fn, L"rb"); if (!img[drive].f) + { + update_status_bar_icon_state(drive, 1); return; + } writeprot[drive] = 1; } if (ui_writeprot[drive]) @@ -350,7 +352,7 @@ void img_load(int drive, char *fn) img[drive].interleave = img[drive].skew = 0; - if (strcmp(ext, "fdi") == 0) + if (_wcsicmp(ext, L"FDI") == 0) { /* This is a Japanese FDI image, so let's read the header */ pclog("img_load(): File is a Japanese FDI image...\n"); @@ -395,7 +397,7 @@ void img_load(int drive, char *fn) pclog("img_load(): File is a FDF image...\n"); fwriteprot[drive] = writeprot[drive] = 1; fclose(img[drive].f); - img[drive].f = fopen(fn, "rb"); + img[drive].f = _wfopen(fn, L"rb"); fdf = 1; @@ -580,7 +582,7 @@ void img_load(int drive, char *fn) pclog("img_load(): File is a CopyQM image...\n"); fwriteprot[drive] = writeprot[drive] = 1; fclose(img[drive].f); - img[drive].f = fopen(fn, "rb"); + img[drive].f = _wfopen(fn, L"rb"); fseek(img[drive].f, 0x03, SEEK_SET); fread(&bpb_bps, 1, 2, img[drive].f); @@ -734,6 +736,7 @@ jump_if_fdf: { pclog("Image is bigger than can fit on an ED floppy, ejecting...\n"); fclose(img[drive].f); + update_status_bar_icon_state(drive, 1); return; } } @@ -795,6 +798,7 @@ jump_if_fdf: { pclog("Image is bigger than can fit on an ED floppy, ejecting...\n"); fclose(img[drive].f); + update_status_bar_icon_state(drive, 1); return; } @@ -811,6 +815,7 @@ jump_if_fdf: { pclog("ERROR: Floppy image of unknown format was inserted into drive %c:!\n", drive + 0x41); fclose(img[drive].f); + update_status_bar_icon_state(drive, 1); return; } diff --git a/src/disc_img.h b/src/disc_img.h index a98ba1a98..4cb82ea1f 100644 --- a/src/disc_img.h +++ b/src/disc_img.h @@ -2,6 +2,6 @@ see COPYING for more details */ void img_init(); -void img_load(int drive, char *fn); +void img_load(int drive, wchar_t *fn); void img_close(int drive); void img_seek(int drive, int track); diff --git a/src/disc_td0.c b/src/disc_td0.c index 5905527b9..ab3511a32 100644 --- a/src/disc_td0.c +++ b/src/disc_td0.c @@ -14,6 +14,8 @@ * Edited and translated to English by Kenji RIKITAKE */ +#include + #include "ibm.h" #include "disc.h" #include "disc_td0.h" @@ -499,16 +501,17 @@ uint8_t imagebuf[4*1024*1024]; uint8_t processed_buf[5*1024*1024]; uint8_t header[12]; -void td0_load(int drive, char *fn) +void td0_load(int drive, wchar_t *fn) { int ret = 0; d86f_unregister(drive); writeprot[drive] = 1; - td0[drive].f = fopen(fn, "rb"); + td0[drive].f = _wfopen(fn, L"rb"); if (!td0[drive].f) { + update_status_bar_icon_state(drive, 1); return; } fwriteprot[drive] = writeprot[drive]; @@ -518,6 +521,7 @@ void td0_load(int drive, char *fn) { pclog("TD0: Not a valid Teledisk image\n"); fclose(td0[drive].f); + update_status_bar_icon_state(drive, 1); return; } else @@ -532,6 +536,7 @@ void td0_load(int drive, char *fn) { pclog("TD0: Failed to initialize\n"); fclose(td0[drive].f); + update_status_bar_icon_state(drive, 1); return; } else diff --git a/src/disc_td0.h b/src/disc_td0.h index 48226d77a..306c7be20 100644 --- a/src/disc_td0.h +++ b/src/disc_td0.h @@ -2,6 +2,6 @@ see COPYING for more details */ void td0_init(); -void td0_load(int drive, char *fn); +void td0_load(int drive, wchar_t *fn); void td0_close(int drive); void td0_seek(int drive, int track); diff --git a/src/hdd_esdi.c b/src/hdd_esdi.c index 4dfc0b4b6..5afe4ff10 100644 --- a/src/hdd_esdi.c +++ b/src/hdd_esdi.c @@ -796,14 +796,14 @@ static void esdi_mca_write(int port, uint8_t val, void *p) } } -static void loadhd(esdi_t *esdi, int d, const char *fn) +static void loadhd(esdi_t *esdi, int d, const wchar_t *fn) { esdi_drive_t *drive = &esdi->drives[d]; if (drive->hdfile == NULL) { /* Try to open existing hard disk image */ - drive->hdfile = fopen64(fn, "rb+"); + drive->hdfile = _wfopen(fn, L"rb+"); if (drive->hdfile == NULL) { /* Failed to open existing hard disk image */ @@ -811,7 +811,7 @@ static void loadhd(esdi_t *esdi, int d, const char *fn) { /* Failed because it does not exist, so try to create new file */ - drive->hdfile = fopen64(fn, "wb+"); + drive->hdfile = _wfopen(fn, L"wb+"); if (drive->hdfile == NULL) { pclog("Cannot create file '%s': %s", diff --git a/src/ibm.h b/src/ibm.h index ffbc18593..9d06e631b 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -4,6 +4,7 @@ #include #include #include +#include #define printf pclog /*Memory*/ @@ -350,7 +351,7 @@ extern int pic_intpending; int disctime; -char discfns[4][256]; +wchar_t discfns[4][256]; int driveempty[4]; #define MDA ((gfxcard==GFX_MDA || gfxcard==GFX_HERCULES || gfxcard==GFX_HERCULESPLUS || gfxcard==GFX_INCOLOR || gfxcard==GFX_GENIUS) && (romset=ROM_IBMAT)) @@ -637,10 +638,10 @@ FILE *shdf[HDC_NUM]; uint64_t hdt[128][3]; uint64_t hdt_mfm[128][3]; -extern char hdd_fn[HDC_NUM][512]; +extern wchar_t hdd_fn[HDC_NUM][512]; -int image_is_hdi(const char *s); -int image_is_hdx(const char *s, int check_signature); +int image_is_hdi(const wchar_t *s); +int image_is_hdx(const wchar_t *s, int check_signature); /*Keyboard*/ int keybsenddelay; @@ -779,6 +780,7 @@ void softresetx86(); void speedchanged(); void trc_reset(uint8_t val); void update_status_bar_icon(int tag, int active); +void update_status_bar_icon_state(int tag, int state); void x86_int_sw(int num); void x86gpf(char *s, uint16_t error); void x86np(char *s, uint16_t error); diff --git a/src/ide.c b/src/ide.c index 525534189..aa8855eba 100644 --- a/src/ide.c +++ b/src/ide.c @@ -13,6 +13,7 @@ #include #include +#include #include "86box.h" #include "cdrom.h" @@ -95,7 +96,7 @@ IDE ide_drives[IDE_NUM]; IDE *ext_ide; -char hdd_fn[HDC_NUM][512]; +wchar_t hdd_fn[HDC_NUM][512]; int (*ide_bus_master_read)(int channel, uint8_t *data, int transfer_length); int (*ide_bus_master_write)(int channel, uint8_t *data, int transfer_length); @@ -142,16 +143,19 @@ int ide_drive_is_cdrom(IDE *ide) } } -int image_is_hdi(const char *s) +static char as[512]; + +int image_is_hdi(const wchar_t *s) { int i, len; char ext[5] = { 0, 0, 0, 0, 0 }; - len = strlen(s); - if ((len < 4) || (s[0] == '.')) + wcstombs(as, s, (wcslen(s) << 1) + 2); + len = strlen(as); + if ((len < 4) || (as[0] == '.')) { return 0; } - memcpy(ext, s + len - 4, 4); + memcpy(ext, as + len - 4, 4); for (i = 0; i < 4; i++) { ext[i] = toupper(ext[i]); @@ -166,19 +170,20 @@ int image_is_hdi(const char *s) } } -int image_is_hdx(const char *s, int check_signature) +int image_is_hdx(const wchar_t *s, int check_signature) { int i, len; FILE *f; uint64_t filelen; uint64_t signature; char ext[5] = { 0, 0, 0, 0, 0 }; - len = strlen(s); - if ((len < 4) || (s[0] == '.')) + wcstombs(as, s, (wcslen(s) << 1) + 2); + len = strlen(as); + if ((len < 4) || (as[0] == '.')) { return 0; } - memcpy(ext, s + len - 4, 4); + memcpy(ext, as + len - 4, 4); for (i = 0; i < 4; i++) { ext[i] = toupper(ext[i]); @@ -187,7 +192,7 @@ int image_is_hdx(const char *s, int check_signature) { if (check_signature) { - f = fopen(s, "rb"); + f = _wfopen(s, L"rb"); if (!f) { return 0; @@ -392,6 +397,7 @@ static void ide_identify(IDE *ide) ide->buffer[50] = 0x4000; /* Capabilities */ ide->buffer[51] = 2 << 8; /*PIO timing mode*/ ide->buffer[52] = 2 << 8; /*DMA timing mode*/ +#if 0 ide->buffer[53] = 1; ide->buffer[55] = ide->hpc; ide->buffer[56] = ide->spt; @@ -406,6 +412,7 @@ static void ide_identify(IDE *ide) full_size = ((uint64_t) ide->hpc) * ((uint64_t) ide->spt) * ((uint64_t) ide->buffer[54]); ide->buffer[57] = full_size & 0xFFFF; /* Total addressable sectors (LBA) */ ide->buffer[58] = (full_size >> 16) & 0x0FFF; +#endif ide->buffer[59] = ide->blocksize ? (ide->blocksize | 0x100) : 0; if (ide->buffer[49] & (1 << 9)) { @@ -494,7 +501,7 @@ static void ide_next_sector(IDE *ide) } } -static void loadhd(IDE *ide, int d, const char *fn) +static void loadhd(IDE *ide, int d, const wchar_t *fn) { uint32_t sector_size = 512; uint32_t zero = 0; @@ -511,7 +518,7 @@ static void loadhd(IDE *ide, int d, const char *fn) ide->type = IDE_NONE; return; } - ide->hdfile = fopen64(fn, "rb+"); + ide->hdfile = _wfopen(fn, L"rb+"); if (ide->hdfile == NULL) { /* Failed to open existing hard disk image */ @@ -519,7 +526,7 @@ static void loadhd(IDE *ide, int d, const char *fn) { /* Failed because it does not exist, so try to create new file */ - ide->hdfile = fopen64(fn, "wb+"); + ide->hdfile = _wfopen(fn, L"wb+"); if (ide->hdfile == NULL) { ide->type = IDE_NONE; diff --git a/src/mfm_at.c b/src/mfm_at.c index ebbcde2a9..c4c1be484 100644 --- a/src/mfm_at.c +++ b/src/mfm_at.c @@ -8,6 +8,7 @@ #include #include +#include #include "ibm.h" #include "device.h" @@ -159,14 +160,14 @@ static void mfm_next_sector(mfm_t *mfm) } } -static void loadhd(mfm_t *mfm, int c, int d, const char *fn) +static void loadhd(mfm_t *mfm, int c, int d, const wchar_t *fn) { mfm_drive_t *drive = &mfm->drives[c]; if (drive->hdfile == NULL) { /* Try to open existing hard disk image */ - drive->hdfile = fopen64(fn, "rb+"); + drive->hdfile = _wfopen(fn, L"rb+"); if (drive->hdfile == NULL) { /* Failed to open existing hard disk image */ @@ -174,7 +175,7 @@ static void loadhd(mfm_t *mfm, int c, int d, const char *fn) { /* Failed because it does not exist, so try to create new file */ - drive->hdfile = fopen64(fn, "wb+"); + drive->hdfile = _wfopen(fn, L"wb+"); if (drive->hdfile == NULL) { pclog("Cannot create file '%s': %s", diff --git a/src/mfm_xebec.c b/src/mfm_xebec.c index eac421b0a..5459a75a7 100644 --- a/src/mfm_xebec.c +++ b/src/mfm_xebec.c @@ -763,14 +763,14 @@ static void xebec_callback(void *p) } } -static void loadhd(xebec_t *xebec, int d, const char *fn) +static void loadhd(xebec_t *xebec, int d, const wchar_t *fn) { mfm_drive_t *drive = &xebec->drives[d]; if (drive->hdfile == NULL) { /* Try to open existing hard disk image */ - drive->hdfile = fopen64(fn, "rb+"); + drive->hdfile = _wfopen(fn, L"rb+"); if (drive->hdfile == NULL) { /* Failed to open existing hard disk image */ @@ -778,7 +778,7 @@ static void loadhd(xebec_t *xebec, int d, const char *fn) { /* Failed because it does not exist, so try to create new file */ - drive->hdfile = fopen64(fn, "wb+"); + drive->hdfile = _wfopen(fn, L"wb+"); if (drive->hdfile == NULL) { pclog("Cannot create file '%s': %s", diff --git a/src/nethandler.c b/src/nethandler.c index c399964c6..ddf1677af 100644 --- a/src/nethandler.c +++ b/src/nethandler.c @@ -1,12 +1,9 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ -#include -#include #include #include #include -#include #include "nethandler.h" #include "ibm.h" @@ -83,6 +80,11 @@ void network_card_init() if (network_cards[network_card_current].device) device_add(network_cards[network_card_current].device); network_card_last = network_card_current; + + if (network_card_current != 0) + { + vlan_reset(); /* NETWORK */ + } } static struct diff --git a/src/pc.c b/src/pc.c index a3a09c04f..d13a402e7 100644 --- a/src/pc.c +++ b/src/pc.c @@ -10,6 +10,7 @@ #include "device.h" #ifndef __unix +#define UNICODE #define BITMAP WINDOWS_BITMAP #include #undef BITMAP @@ -357,7 +358,7 @@ void initpc(int argc, char *argv[]) { if (cdrom_drives[i].host_drive == 200) { - ff = fopen(cdrom_iso[i].iso_path, "rb"); + ff = _wfopen(cdrom_iso[i].iso_path, L"rb"); if (ff) { fclose(ff); @@ -486,12 +487,8 @@ void resetpchard() ide_qua_init(); } - if (network_card_current != 0) - { - vlan_reset(); /* NETWORK */ - } - network_card_init(network_card_current); - + network_card_init(); + for (i = 0; i < CDROM_NUM; i++) { if (cdrom_drives[i].bus_type) @@ -503,7 +500,7 @@ void resetpchard() resetide(); scsi_card_init(); - sound_card_init(sound_card_current); + sound_card_init(); if (GUS) device_add(&gus_device); if (GAMEBLASTER) @@ -559,9 +556,12 @@ int serial_fifo_read, serial_fifo_write; int emu_fps = 0; +static WCHAR wmodel[2048]; +static WCHAR wcpu[2048]; + void runpc() { - char s[200]; + wchar_t s[200]; int done=0; startblit(); @@ -637,7 +637,9 @@ void runpc() if (win_title_update) { win_title_update=0; - sprintf(s, "86Box v%s - %i%% - %s - %s - %s", emulator_version, fps, model_getname(), models[model].cpu[cpu_manufacturer].cpus[cpu].name, (!mousecapture) ? "Click to capture mouse" : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? "Press F12-F8 to release mouse" : "Press F12-F8 or middle button to release mouse")); + mbstowcs(wmodel, model_getname(), strlen(model_getname()) + 1); + mbstowcs(wcpu, models[model].cpu[cpu_manufacturer].cpus[cpu].name, strlen(models[model].cpu[cpu_manufacturer].cpus[cpu].name) + 1); + _swprintf(s, L"86Box v%s - %i%% - %s - %s - %s", emulator_version_w, fps, wmodel, wcpu, (!mousecapture) ? win_language_get_string_from_id(2077) : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? win_language_get_string_from_id(2078) : win_language_get_string_from_id(2079))); set_window_title(s); } done++; @@ -703,6 +705,7 @@ void loadconfig(char *fn) int c, d; char s[512]; char *p; + WCHAR *wp; char temps[512]; if (!fn) @@ -776,9 +779,13 @@ void loadconfig(char *fn) fdd_set_type(c, (c < 2) ? 2 : 0); sprintf(temps, "fdd_%02i_fn", c + 1); - p = (char *)config_get_string(NULL, temps, ""); - if (p) strcpy(discfns[c], p); - else strcpy(discfns[c], ""); + wp = (WCHAR *)config_get_wstring(NULL, temps, L""); + if (wp) memcpy(discfns[c], wp, 512); + else { + memcpy(discfns[c], L"", 2); + discfns[c][0] = L'\0'; + } + printf("Floppy: %ws\n", discfns[c]); sprintf(temps, "fdd_%02i_writeprot", c + 1); ui_writeprot[c] = config_get_int(NULL, temps, 0); } @@ -818,9 +825,12 @@ void loadconfig(char *fn) sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1); hdc[c].scsi_lun = config_get_int(NULL, temps, 0); sprintf(temps, "hdd_%02i_fn", c + 1); - p = (char *)config_get_string(NULL, temps, ""); - if (p) strcpy(hdd_fn[c], p); - else strcpy(hdd_fn[c], ""); + wp = (WCHAR *)config_get_wstring(NULL, temps, L""); + if (wp) memcpy(hdd_fn[c], wp, 512); + else { + memcpy(hdd_fn[c], L"", 2); + hdd_fn[c][0] = L'\0'; + } } memset(temps, 0, 512); @@ -845,9 +855,12 @@ void loadconfig(char *fn) cdrom_drives[c].scsi_device_lun = config_get_int(NULL, temps, 0); sprintf(temps, "cdrom_%02i_iso_path", c + 1); - p = (char *)config_get_string(NULL, temps, ""); - if (p) strcpy(cdrom_iso[c].iso_path, p); - else strcpy(cdrom_iso[c].iso_path, ""); + wp = (WCHAR *)config_get_wstring(NULL, temps, L""); + if (wp) memcpy(cdrom_iso[c].iso_path, wp, 512); + else { + memcpy(cdrom_iso[c].iso_path, L"", 2); + cdrom_iso[c].iso_path[0] = L'\0'; + } } vid_resize = config_get_int(NULL, "vid_resize", 0); @@ -972,7 +985,7 @@ void saveconfig() sprintf(temps, "fdd_%02i_type", c + 1); config_set_string(NULL, temps, fdd_get_internal_name(fdd_get_type(c))); sprintf(temps, "fdd_%02i_fn", c + 1); - config_set_string(NULL, temps, discfns[c]); + config_set_wstring(NULL, temps, discfns[c]); sprintf(temps, "fdd_%02i_writeprot", c + 1); config_set_int(NULL, temps, ui_writeprot[c]); } @@ -1008,7 +1021,7 @@ void saveconfig() sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1); config_set_int(NULL, temps, hdc[c].scsi_lun); sprintf(temps, "hdd_%02i_fn", c + 1); - config_set_string(NULL, temps, hdd_fn[c]); + config_set_wstring(NULL, temps, hdd_fn[c]); } memset(temps, 0, 512); @@ -1032,7 +1045,7 @@ void saveconfig() config_set_int(NULL, temps, cdrom_drives[c].scsi_device_lun); sprintf(temps, "cdrom_%02i_iso_path", c + 1); - config_set_string(NULL, temps, cdrom_iso[c].iso_path); + config_set_wstring(NULL, temps, cdrom_iso[c].iso_path); } config_set_int(NULL, "vid_resize", vid_resize); diff --git a/src/scsi.h b/src/scsi.h index ba0334f57..61c8f1bf5 100644 --- a/src/scsi.h +++ b/src/scsi.h @@ -12,6 +12,7 @@ #define GPCMD_TEST_UNIT_READY 0x00 #define GPCMD_REZERO_UNIT 0x01 #define GPCMD_REQUEST_SENSE 0x03 +#define GPCMD_FORMAT_UNIT 0x04 #define GPCMD_READ_6 0x08 #define GPCMD_WRITE_6 0x0a #define GPCMD_SEEK_6 0x0b diff --git a/src/scsi_hd.c b/src/scsi_hd.c index 1f2bd2788..e0b7f09a2 100644 --- a/src/scsi_hd.c +++ b/src/scsi_hd.c @@ -65,7 +65,8 @@ uint8_t scsi_hd_command_flags[0x100] = IMPLEMENTED | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x01 */ 0, IMPLEMENTED | ALLOW_UA, /* 0x03 */ - 0, 0, 0, 0, + IMPLEMENTED | CHECK_READY | ALLOW_UA | NONDATA | SCSI_ONLY, /* 0x04 */ + 0, 0, 0, IMPLEMENTED | CHECK_READY, /* 0x08 */ 0, IMPLEMENTED | CHECK_READY, /* 0x0A */ @@ -189,7 +190,7 @@ static void scsi_loadhd(int scsi_id, int scsi_lun, int id) uint64_t signature = 0xD778A82044445459ll; uint64_t full_size = 0; int c; - char *fn = hdd_fn[id]; + wchar_t *fn = hdd_fn[id]; shdc[id].base = 0; @@ -205,7 +206,7 @@ static void scsi_loadhd(int scsi_id, int scsi_lun, int id) scsi_hard_disks[scsi_id][scsi_lun] = 0xff; return; } - shdf[id] = fopen64(fn, "rb+"); + shdf[id] = _wfopen(fn, L"rb+"); if (shdf[id] == NULL) { /* Failed to open existing hard disk image */ @@ -213,7 +214,7 @@ static void scsi_loadhd(int scsi_id, int scsi_lun, int id) { /* Failed because it does not exist, so try to create new file */ - shdf[id] = fopen64(fn, "wb+"); + shdf[id] = _wfopen(fn, L"wb+"); if (shdf[id] == NULL) { scsi_hard_disks[scsi_id][scsi_lun] = 0xff; @@ -764,6 +765,7 @@ void scsi_hd_command(uint8_t id, uint8_t *cdb) switch (cdb[0]) { case GPCMD_TEST_UNIT_READY: + case GPCMD_FORMAT_UNIT: case GPCMD_VERIFY_6: case GPCMD_VERIFY_10: case GPCMD_VERIFY_12: diff --git a/src/win-d3d-fs.cc b/src/win-d3d-fs.cc index b3378e1e6..b44097898 100644 --- a/src/win-d3d-fs.cc +++ b/src/win-d3d-fs.cc @@ -3,6 +3,7 @@ */ #include #include +#define UNICODE #define BITMAP WINDOWS_BITMAP #include #undef BITMAP @@ -133,7 +134,7 @@ void cgapal_rebuild() int d3d_fs_init(HWND h) { HRESULT hr; - char emulator_title[200]; + WCHAR emulator_title[200]; d3d_fs_w = GetSystemMetrics(SM_CXSCREEN); d3d_fs_h = GetSystemMetrics(SM_CYSCREEN); @@ -142,7 +143,7 @@ int d3d_fs_init(HWND h) d3d_hwnd = h; - sprintf(emulator_title, "86Box v%s", emulator_version); + _swprintf(emulator_title, L"86Box v%s", emulator_version_w); d3d_device_window = CreateWindowEx ( 0, szSubClassName, @@ -572,12 +573,15 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) void d3d_fs_take_screenshot(char *fn) { + WCHAR wfn[512]; LPDIRECT3DSURFACE9 d3dSurface = NULL; if (!d3dTexture) return; + mbstowcs(wfn, fn, strlen(fn) + 1); + d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &d3dSurface); - D3DXSaveSurfaceToFile(fn, D3DXIFF_PNG, d3dSurface, NULL, NULL); + D3DXSaveSurfaceToFile(wfn, D3DXIFF_PNG, d3dSurface, NULL, NULL); d3dSurface->Release(); d3dSurface = NULL; diff --git a/src/win-d3d.cc b/src/win-d3d.cc index 561873c58..a30fe1795 100644 --- a/src/win-d3d.cc +++ b/src/win-d3d.cc @@ -2,6 +2,7 @@ see COPYING for more details */ #include +#define UNICODE #define BITMAP WINDOWS_BITMAP #include #undef BITMAP @@ -382,12 +383,15 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h) void d3d_take_screenshot(char *fn) { + WCHAR wfn[512]; LPDIRECT3DSURFACE9 d3dSurface = NULL; if (!d3dTexture) return; + mbstowcs(wfn, fn, strlen(fn) + 1); + d3ddev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &d3dSurface); - D3DXSaveSurfaceToFile(fn, D3DXIFF_PNG, d3dSurface, NULL, NULL); + D3DXSaveSurfaceToFile(wfn, D3DXIFF_PNG, d3dSurface, NULL, NULL); d3dSurface->Release(); d3dSurface = NULL; diff --git a/src/win-ddraw-fs.cc b/src/win-ddraw-fs.cc index 9c7bedbb0..811c69f37 100644 --- a/src/win-ddraw-fs.cc +++ b/src/win-ddraw-fs.cc @@ -2,6 +2,7 @@ see COPYING for more details */ #include +#define UNICODE #define BITMAP WINDOWS_BITMAP #include #undef BITMAP diff --git a/src/win-ddraw-screenshot.cc b/src/win-ddraw-screenshot.cc index 55c2ff730..c49c6170d 100644 --- a/src/win-ddraw-screenshot.cc +++ b/src/win-ddraw-screenshot.cc @@ -3,10 +3,13 @@ */ #include #include +#define UNICODE #define BITMAP WINDOWS_BITMAP #include #undef BITMAP +#include "win.h" #include "win-ddraw-screenshot.h" +#include "win-language.h" #include "video.h" extern "C" void fatal(const char *format, ...); @@ -64,6 +67,8 @@ void DoubleLines(uint8_t *dst, uint8_t *src) } } +static WCHAR szMessage[2048]; + void SaveBitmap(char *szFilename,HBITMAP hBitmap) { HDC hdc=NULL; @@ -73,8 +78,6 @@ void SaveBitmap(char *szFilename,HBITMAP hBitmap) BITMAPINFO bmpInfo; BITMAPFILEHEADER bmpFileHeader; - char szMessage[2048]; - do{ hdc=GetDC(NULL); @@ -105,8 +108,8 @@ void SaveBitmap(char *szFilename,HBITMAP hBitmap) if((fp = fopen(szFilename,"wb"))==NULL) { - sprintf(szMessage, "Unable to Create Bitmap File %s", szFilename); - MessageBox( NULL, szMessage, "Error", MB_OK|MB_ICONERROR); + _swprintf(szMessage, win_language_get_string_from_id(2194), szFilename); + msgbox_error_wstr(ghwnd, szMessage); break; } diff --git a/src/win-ddraw.cc b/src/win-ddraw.cc index 347c6a752..7842f16b6 100644 --- a/src/win-ddraw.cc +++ b/src/win-ddraw.cc @@ -3,6 +3,7 @@ */ #include #include +#define UNICODE #define BITMAP WINDOWS_BITMAP #include #undef BITMAP diff --git a/src/win-language.c b/src/win-language.c index 353fb1302..51f3e6c86 100644 --- a/src/win-language.c +++ b/src/win-language.c @@ -26,6 +26,7 @@ uint32_t dwLangID, dwSubLangID; WCHAR lpResourceString[STRINGS_NUM][512]; char openfilestring[260]; +WCHAR wopenfilestring[260]; void win_language_set() { @@ -94,11 +95,21 @@ void msgbox_info(HWND hwndParent, int i) MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[0], MB_OK | MB_ICONINFORMATION); } +void msgbox_info_wstr(HWND hwndParent, WCHAR *wstr) +{ + MessageBox(hwndParent, wstr, lpResourceString[0], MB_OK | MB_ICONINFORMATION); +} + void msgbox_error(HWND hwndParent, int i) { MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[1], MB_OK | MB_ICONWARNING); } +void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr) +{ + MessageBox(hwndParent, wstr, lpResourceString[1], MB_OK | MB_ICONWARNING); +} + void msgbox_critical(HWND hwndParent, int i) { MessageBox(hwndParent, win_language_get_string_from_id(i), lpResourceString[2], MB_OK | MB_ICONERROR); @@ -116,27 +127,22 @@ void msgbox_fatal(HWND hwndParent, char *string) free(lptsTemp); } -int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save) +int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save) { OPENFILENAME ofn; /* common dialog box structure */ BOOL r; DWORD err; - WCHAR ufn[260]; - WCHAR uofs[260]; - - /* Convert file name to Unicode */ - mbstowcs(ufn, fn, strlen(fn) + 1); /* Initialize OPENFILENAME */ ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwnd; - ofn.lpstrFile = uofs; + ofn.lpstrFile = wopenfilestring; /* Set lpstrFile[0] to '\0' so that GetOpenFileName does not use the contents of szFile to initialize itself. */ - memcpy(ofn.lpstrFile, ufn, (wcslen(ufn) << 1) + 2); + memcpy(ofn.lpstrFile, fn, (wcslen(fn) << 1) + 2); ofn.nMaxFile = 259; ofn.lpstrFilter = f; ofn.nFilterIndex = 1; @@ -163,7 +169,7 @@ int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save) } if (r) { - wcstombs(openfilestring, uofs, 520); + wcstombs(openfilestring, wopenfilestring, 520); pclog("File dialog return true\n"); return 0; } @@ -173,6 +179,18 @@ int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save) return 1; } +int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save) +{ + WCHAR ufn[512]; + mbstowcs(ufn, fn, strlen(fn) + 1); + return file_dlg_w(hwnd, f, ufn, save); +} + +int file_dlg_w_st(HWND hwnd, int i, WCHAR *fn, int save) +{ + file_dlg_w(hwnd, win_language_get_string_from_id(i), fn, save); +} + int file_dlg_st(HWND hwnd, int i, char *fn, int save) { file_dlg(hwnd, win_language_get_string_from_id(i), fn, save); diff --git a/src/win-language.h b/src/win-language.h index 47fde8df8..113c16f44 100644 --- a/src/win-language.h +++ b/src/win-language.h @@ -1,12 +1,20 @@ +#ifdef __cplusplus +extern "C" { +#endif + int msgbox_reset(HWND hwndParent); int msgbox_reset_yn(HWND hwndParent); int msgbox_question(HWND hwndParent, int i); void msgbox_info(HWND hwndParent, int i); +void msgbox_info_wstr(HWND hwndParent, WCHAR *wstr); void msgbox_error(HWND hwndParent, int i); +void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr); void msgbox_fatal(HWND hwndParent, char *string); void msgbox_critical(HWND hwndParent, int i); +int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save); int file_dlg(HWND hwnd, WCHAR *f, char *fn, int save); +int file_dlg_w_st(HWND hwnd, int i, WCHAR *fn, int save); int file_dlg_st(HWND hwnd, int i, char *fn, int save); void win_language_load_common_strings(); @@ -17,3 +25,7 @@ void win_language_check(); LPTSTR win_language_get_string_from_id(int i); LPTSTR win_language_get_string_from_string(char *str); + +#ifdef __cplusplus +} +#endif diff --git a/src/win-settings.c b/src/win-settings.c index ff3f87c7a..58229df82 100644 --- a/src/win-settings.c +++ b/src/win-settings.c @@ -57,7 +57,7 @@ char temp_hdc_name[16]; /* Hard disks category */ hard_disk_t temp_hdc[HDC_NUM]; -char temp_hdd_fn[HDC_NUM][512]; +wchar_t temp_hdd_fn[HDC_NUM][512]; /* Removable devices category */ int temp_fdd_types[FDD_NUM]; @@ -124,7 +124,7 @@ static void win_settings_init() memcpy(temp_hdc, hdc, HDC_NUM * sizeof(hard_disk_t)); for (i = 0; i < HDC_NUM; i++) { - memcpy(temp_hdd_fn[i], hdd_fn[i], 512); + memcpy(temp_hdd_fn[i], hdd_fn[i], 1024); } /* Removable devices category */ @@ -183,7 +183,7 @@ static int win_settings_changed() i = i || memcmp(hdc, temp_hdc, HDC_NUM * sizeof(hard_disk_t)); for (j = 0; j < HDC_NUM; j++) { - i = i || memcmp(hdd_fn[j], temp_hdd_fn[j], 512); + i = i || memcmp(hdd_fn[j], temp_hdd_fn[j], 1024); } /* Removable devices category */ @@ -274,7 +274,7 @@ static void win_settings_save() memcpy(hdc, temp_hdc, HDC_NUM * sizeof(hard_disk_t)); for (i = 0; i < HDC_NUM; i++) { - memcpy(hdd_fn[i], temp_hdd_fn[i], 512); + memcpy(hdd_fn[i], temp_hdd_fn[i], 1024); } /* Removable devices category */ @@ -1474,17 +1474,18 @@ static BOOL win_settings_hard_disks_image_list_init(HWND hwndList) int next_free_id = 0; +wchar_t ifn[HDC_NUM][512]; + static void normalize_hd_list() { hard_disk_t ihdc[HDC_NUM]; - char ifn[HDC_NUM][512]; int i, j; j = 0; memset(ihdc, 0, HDC_NUM * sizeof(hard_disk_t)); for (i = 0; i < HDC_NUM; i++) { - memset(ifn[i], 0, 512); + memset(ifn[i], 0, 1024); } for (i = 0; i < HDC_NUM; i++) { @@ -1496,7 +1497,7 @@ static void normalize_hd_list() if (temp_hdc[i].bus > 0) { memcpy(&(ihdc[j]), &(temp_hdc[i]), sizeof(hard_disk_t)); - memcpy(ifn[j], temp_hdd_fn[i], 512); + memcpy(ifn[j], temp_hdd_fn[i], 1024); j++; } } @@ -1504,7 +1505,7 @@ static void normalize_hd_list() memcpy(temp_hdc, ihdc, HDC_NUM * sizeof(hard_disk_t)); for (i = 0; i < HDC_NUM; i++) { - memcpy(temp_hdd_fn[i], ifn[i], 512); + memcpy(temp_hdd_fn[i], ifn[i], 1024); } } @@ -1786,8 +1787,7 @@ static void win_settings_hard_disks_update_item(HWND hwndList, int i, int column } else if (column == 1) { - mbstowcs(szText, temp_hdd_fn[i], strlen(temp_hdd_fn[i]) + 1); - lvI.pszText = szText; + lvI.pszText = temp_hdd_fn[i]; lvI.iImage = 0; } else if (column == 2) @@ -1864,8 +1864,7 @@ static BOOL win_settings_hard_disks_recalc_list(HWND hwndList) } lvI.iSubItem = 1; - mbstowcs(szText, temp_hdd_fn[i], strlen(temp_hdd_fn[i]) + 1); - lvI.pszText = szText; + lvI.pszText = temp_hdd_fn[i]; lvI.iItem = j; lvI.iImage = 0; @@ -2020,7 +2019,7 @@ int existing = 0; uint64_t selection = 127; uint64_t spt, hpc, tracks, size; -char hd_file_name[512]; +wchar_t hd_file_name[512]; static int hdconf_initialize_hdt_combo(HWND hdlg) { @@ -2134,7 +2133,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W switch (LOWORD(wParam)) { case IDOK: - if (strlen(hd_file_name) == 0) + if (wcslen(hd_file_name) == 0) { msgbox_error(hwndParentDialog, 2056); return TRUE; @@ -2153,14 +2152,14 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W temp_hdc[next_free_id].scsi_lun = SendMessage(h, CB_GETCURSEL, 0, 0); h = GetDlgItem(hdlg, IDC_COMBO_HD_CHANNEL_IDE); temp_hdc[next_free_id].ide_channel = SendMessage(h, CB_GETCURSEL, 0, 0); - memset(temp_hdd_fn[next_free_id], 0, 512); - memcpy(temp_hdd_fn[next_free_id], hd_file_name, strlen(hd_file_name) + 1); + memset(temp_hdd_fn[next_free_id], 0, 1024); + memcpy(temp_hdd_fn[next_free_id], hd_file_name, (wcslen(hd_file_name) << 1) + 2); sector_size = 512; - if (!existing && (strlen(hd_file_name) > 0)) + if (!existing && (wcslen(hd_file_name) > 0)) { - f = fopen(hd_file_name, "wb"); + f = _wfopen(hd_file_name, L"wb"); if (image_is_hdi(hd_file_name)) { @@ -2225,9 +2224,9 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W return TRUE; case IDC_CFILE: - if (!file_dlg(hdlg, win_language_get_string_from_id(2172), "", !existing)) + if (!file_dlg_w(hdlg, win_language_get_string_from_id(2172), L"", !existing)) { - f = fopen(openfilestring, existing ? "rb" : "wb"); + f = _wfopen(wopenfilestring, existing ? L"rb" : L"wb"); if (f == NULL) { msgbox_error(hwndParentDialog, existing ? 2060 : 2057); @@ -2235,7 +2234,7 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W } if (existing) { - if (image_is_hdi(openfilestring) || image_is_hdx(openfilestring, 1)) + if (image_is_hdi(wopenfilestring) || image_is_hdx(wopenfilestring, 1)) { fseeko64(f, 0x10, SEEK_SET); fread(§or_size, 1, 4, f); @@ -2312,9 +2311,8 @@ static BOOL CALLBACK win_settings_hard_disks_add_proc(HWND hdlg, UINT message, W } h = GetDlgItem(hdlg, IDC_EDIT_HD_FILE_NAME); - mbstowcs(szText, openfilestring, strlen(openfilestring) + 1); - SendMessage(h, WM_SETTEXT, 0, (LPARAM) szText); - memcpy(hd_file_name, openfilestring, strlen(openfilestring) + 1); + SendMessage(h, WM_SETTEXT, 0, (LPARAM) wopenfilestring); + memcpy(hd_file_name, wopenfilestring, (wcslen(wopenfilestring) << 1) + 2); return TRUE; @@ -2632,7 +2630,7 @@ static BOOL CALLBACK win_settings_hard_disks_proc(HWND hdlg, UINT message, WPARA return FALSE; case IDC_BUTTON_HDD_REMOVE: - strncpy(temp_hdd_fn[hdlv_current_sel], "", strlen("") + 1); + memcpy(temp_hdd_fn[hdlv_current_sel], L"", 4); temp_hdc[hdlv_current_sel].bus = 0; /* 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. */ ignore_change = 1; diff --git a/src/win.c b/src/win.c index 9c6695efa..75c798ded 100644 --- a/src/win.c +++ b/src/win.c @@ -1,6 +1,7 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ +#define UNICODE #define _WIN32_WINNT 0x0501 #define BITMAP WINDOWS_BITMAP #include @@ -397,7 +398,7 @@ static void initmenu(void) { int i, c; HMENU m; - char s[32]; + WCHAR s[64]; for (i = 0; i < CDROM_NUM; i++) { @@ -407,10 +408,10 @@ static void initmenu(void) it's a CDROM */ for (c='A';c<='Z';c++) { - sprintf(s,"%c:\\",c); + _swprintf(s,L"%c:\\",c); if (GetDriveType(s)==DRIVE_CDROM) { - sprintf(s, "Host CD/DVD Drive (%c:)", c); + _swprintf(s, win_language_get_string_from_id(2076), c); AppendMenu(m,MF_STRING,IDM_CDROM_1_REAL+(c << 2)+i,s); } } @@ -419,10 +420,12 @@ static void initmenu(void) void get_executable_name(char *s, int size) { - GetModuleFileName(hinstance, s, size); + WCHAR ws[512]; + GetModuleFileName(hinstance, ws, size); + wcstombs(s, ws, (wcslen(ws) << 1) + 2); } -void set_window_title(char *s) +void set_window_title(WCHAR *s) { if (video_fullscreen) return; @@ -478,8 +481,8 @@ UINT16 convert_scan_code(UINT16 scan_code) void get_registry_key_map() { - char *keyName = "SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout"; - char *valueName = "Scancode Map"; + WCHAR *keyName = L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout"; + WCHAR *valueName = L"Scancode Map"; unsigned char buf[32768]; DWORD bufSize; HKEY hKey; @@ -528,11 +531,13 @@ static char *argbuf; static void process_command_line() { - char *cmdline; + WCHAR *wcmdline; + char cmdline[2048]; int argc_max; int i, q; - cmdline = GetCommandLine(); + wcmdline = GetCommandLine(); + wcstombs(cmdline, wcmdline, (wcslen(wcmdline) << 1) + 2); i = strlen(cmdline) + 1; argbuf = malloc(i); memcpy(argbuf, cmdline, i); @@ -753,6 +758,20 @@ void update_status_bar_icon_state(int tag, int state) if (found != -1) { + if (state) + { + switch(tag & 0xf0) + { + case 0x00: + default: + discfns[tag & 0x0f][0] = L'\0'; + break; + case 0x10: + cdrom_iso[tag & 0x0f].iso_path[0] = L'\0'; + break; + } + } + sb_icon_flags[found] &= ~256; sb_icon_flags[found] |= state ? 256 : 0; @@ -765,59 +784,53 @@ void update_status_bar_icon_state(int tag, int state) } } -char sbTips[24][512]; +WCHAR sbTips[24][512]; void create_floppy_tip(int part) { WCHAR *szText; - char ansi_text[2][512]; + WCHAR wtext[512]; int drive = sb_part_meanings[part] & 0xf; - szText = (WCHAR *) win_language_get_string_from_id(2179); - wcstombs(ansi_text[0], szText, (wcslen(szText) << 1) + 2); - szText = (WCHAR *) win_language_get_string_from_id(2185); - wcstombs(ansi_text[1], szText, (wcslen(szText) << 1) + 2); - if (strlen(discfns[drive]) == 0) + + mbstowcs(wtext, fdd_getname(fdd_get_type(drive)), strlen(fdd_getname(fdd_get_type(drive))) + 1); + if (wcslen(discfns[drive]) == 0) { - sprintf(sbTips[part], ansi_text[0], drive + 1, fdd_getname(fdd_get_type(drive)), ansi_text[1]); + _swprintf(sbTips[part], win_language_get_string_from_id(2179), drive + 1, wtext, win_language_get_string_from_id(2185)); } else { - sprintf(sbTips[part], ansi_text[0], drive + 1, fdd_getname(fdd_get_type(drive)), discfns[drive]); + _swprintf(sbTips[part], win_language_get_string_from_id(2179), drive + 1, wtext, discfns[drive]); } } void create_cdrom_tip(int part) { WCHAR *szText; - char ansi_text[4][512]; + char ansi_text[3][512]; + WCHAR wtext[512]; int drive = sb_part_meanings[part] & 0xf; - szText = (WCHAR *) win_language_get_string_from_id(2180); - wcstombs(ansi_text[0], szText, (wcslen(szText) << 1) + 2); - szText = (WCHAR *) win_language_get_string_from_id(2185); - wcstombs(ansi_text[1], szText, (wcslen(szText) << 1) + 2); - szText = (WCHAR *) win_language_get_string_from_id(2186); - wcstombs(ansi_text[2], szText, (wcslen(szText) << 1) + 2); + if (cdrom_drives[drive].host_drive == 200) { - if (strlen(cdrom_iso[drive].iso_path) == 0) + if (wcslen(cdrom_iso[drive].iso_path) == 0) { - sprintf(sbTips[part], ansi_text[0], drive + 1, ansi_text[1]); + _swprintf(sbTips[part], win_language_get_string_from_id(2180), drive + 1, win_language_get_string_from_id(2185)); } else { - sprintf(sbTips[part], ansi_text[0], drive + 1, cdrom_iso[drive].iso_path); + _swprintf(sbTips[part], win_language_get_string_from_id(2180), drive + 1, cdrom_iso[drive].iso_path); } } else if (cdrom_drives[drive].host_drive < 0x41) { - sprintf(sbTips[part], ansi_text[0], drive + 1, ansi_text[1]); + _swprintf(sbTips[part], win_language_get_string_from_id(2180), drive + 1, win_language_get_string_from_id(2185)); } else { - sprintf(ansi_text[3], ansi_text[2], cdrom_drives[drive].host_drive & ~0x20); - sprintf(sbTips[part], ansi_text[0], drive + 1, ansi_text[3]); + _swprintf(wtext, win_language_get_string_from_id(2186), cdrom_drives[drive].host_drive & ~0x20); + _swprintf(sbTips[part], win_language_get_string_from_id(2180), drive + 1, wtext); } } @@ -827,7 +840,7 @@ void create_hd_tip(int part) int bus = sb_part_meanings[part] & 0xf; szText = (WCHAR *) win_language_get_string_from_id(2182 + bus); - wcstombs(sbTips[part], szText, (wcslen(szText) << 1) + 2); + memcpy(sbTips[part], szText, (wcslen(szText) << 1) + 2); } void update_tip(int meaning) @@ -866,7 +879,7 @@ void update_tip(int meaning) static int get_floppy_state(int id) { - return (strlen(discfns[id]) == 0) ? 1 : 0; + return (wcslen(discfns[id]) == 0) ? 1 : 0; } static int get_cd_state(int id) @@ -879,7 +892,7 @@ static int get_cd_state(int id) { if (cdrom_drives[id].host_drive == 0x200) { - return (strlen(cdrom_iso[id].iso_path) == 0) ? 1 : 0; + return (wcslen(cdrom_iso[id].iso_path) == 0) ? 1 : 0; } else { @@ -962,7 +975,7 @@ void update_status_bar_panes(HWND hwnds) { case 0x00: /* Floppy */ - sb_icon_flags[i] = (strlen(discfns[sb_part_meanings[i] & 0xf]) == 0) ? 256 : 0; + sb_icon_flags[i] = (wcslen(discfns[sb_part_meanings[i] & 0xf]) == 0) ? 256 : 0; sb_part_icons[i] = fdd_type_to_icon(fdd_get_type(sb_part_meanings[i] & 0xf)) | sb_icon_flags[i]; create_floppy_tip(i); break; @@ -977,7 +990,7 @@ void update_status_bar_panes(HWND hwnds) { if (cdrom_drives[id].host_drive == 0x200) { - sb_icon_flags[i] = (strlen(cdrom_iso[id].iso_path) == 0) ? 256 : 0; + sb_icon_flags[i] = (wcslen(cdrom_iso[id].iso_path) == 0) ? 256 : 0; } else { @@ -1002,7 +1015,7 @@ void update_status_bar_panes(HWND hwnds) break; case 0x30: /* Status text */ - SendMessage(hwnds, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) "Hello from 86Box UX lab! :p"); + SendMessage(hwnds, SB_SETTEXT, i | SBT_NOBORDERS, (LPARAM) L"Welcome to Unicode 86Box! :p"); sb_part_icons[i] = -1; break; } @@ -1088,7 +1101,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ int c, d, e, bRet; - char emulator_title[200]; + WCHAR emulator_title[200]; LARGE_INTEGER qpc_freq; HACCEL haccel; /* Handle to accelerator table */ @@ -1105,8 +1118,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance, wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ - wincl.hIcon = LoadIcon(hinstance, (LPCSTR) 100); - wincl.hIconSm = LoadIcon(hinstance, (LPCSTR) 100); + wincl.hIcon = LoadIcon(hinstance, (LPCTSTR) 100); + wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR) 100); wincl.hCursor = NULL; wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ @@ -1126,7 +1139,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, menu = LoadMenu(hThisInstance, TEXT("MainMenu")); - sprintf(emulator_title, "86Box v%s", emulator_version); + _swprintf(emulator_title, L"86Box v%s", emulator_version_w); /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( @@ -1148,7 +1161,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, ShowWindow (hwnd, nFunsterStil); /* Load the accelerator table */ - haccel = LoadAccelerators(hinstAcc, "MainAccel"); + haccel = LoadAccelerators(hinstAcc, L"MainAccel"); if (haccel == NULL) fatal("haccel is null\n"); @@ -1169,7 +1182,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, initpc(argc, argv); - hwndRender = CreateWindow("STATIC", NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, 0, 0, 1, 1, ghwnd, NULL, hinstance, NULL); + hwndRender = CreateWindow(L"STATIC", NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, 0, 0, 1, 1, ghwnd, NULL, hinstance, NULL); hwndStatus = EmulatorStatusBar(hwnd, IDC_STATUS, hThisInstance); @@ -1622,7 +1635,7 @@ static BOOL CALLBACK about_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARA void about_open(HWND hwnd) { - DialogBox(hinstance, (LPCSTR) ABOUTDLG, hwnd, about_dlgproc); + DialogBox(hinstance, (LPCTSTR) ABOUTDLG, hwnd, about_dlgproc); } LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -2127,7 +2140,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR RECT rc; POINT pt; - char temp_iso_path[1024]; + WCHAR temp_iso_path[1024]; int new_cdrom_drive; int cdrom_id = 0; int menu_sub_param = 0; @@ -2142,11 +2155,12 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR { case IDM_DISC_1: case IDM_DISC_1_WP: - if (!file_dlg_st(hwnd, 2173, discfns[0], 0)) + if (!file_dlg_w_st(hwnd, 2173, discfns[0], 0)) { disc_close(0); ui_writeprot[0] = (LOWORD(wParam) == IDM_DISC_1_WP) ? 1 : 0; - disc_load(0, openfilestring); + msgbox_info_wstr(ghwnd, wopenfilestring); + disc_load(0, wopenfilestring); update_status_bar_icon_state(0x00, 0); update_tip(0x00); saveconfig(); @@ -2154,11 +2168,11 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR break; case IDM_DISC_2: case IDM_DISC_2_WP: - if (!file_dlg_st(hwnd, 2173, discfns[0], 0)) + if (!file_dlg_w_st(hwnd, 2173, discfns[1], 0)) { disc_close(1); ui_writeprot[1] = (LOWORD(wParam) == IDM_DISC_2_WP) ? 1 : 0; - disc_load(1, openfilestring); + disc_load(1, wopenfilestring); update_status_bar_icon_state(0x01, 0); update_tip(0x01); saveconfig(); @@ -2166,11 +2180,11 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR break; case IDM_DISC_3: case IDM_DISC_3_WP: - if (!file_dlg_st(hwnd, 2173, discfns[0], 0)) + if (!file_dlg_w_st(hwnd, 2173, discfns[2], 0)) { disc_close(2); ui_writeprot[2] = (LOWORD(wParam) == IDM_DISC_3_WP) ? 1 : 0; - disc_load(2, openfilestring); + disc_load(2, wopenfilestring); update_status_bar_icon_state(0x02, 0); update_tip(0x02); saveconfig(); @@ -2178,11 +2192,11 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR break; case IDM_DISC_4: case IDM_DISC_4_WP: - if (!file_dlg_st(hwnd, 2173, discfns[0], 0)) + if (!file_dlg_w_st(hwnd, 2173, discfns[3], 0)) { disc_close(3); ui_writeprot[3] = (LOWORD(wParam) == IDM_DISC_4_WP) ? 1 : 0; - disc_load(3, openfilestring); + disc_load(3, wopenfilestring); update_status_bar_icon_state(0x03, 0); update_tip(0x03); saveconfig(); @@ -2250,11 +2264,11 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR case IDM_CDROM_4_ISO: cdrom_id = LOWORD(wParam) & 3; hmenu = GetSubMenu(smenu, cdrom_id + 4); - if (!file_dlg_st(hwnd, 2175, cdrom_iso[cdrom_id].iso_path, 0)) + if (!file_dlg_w_st(hwnd, 2175, cdrom_iso[cdrom_id].iso_path, 0)) { cdrom_drives[cdrom_id].prev_host_drive = cdrom_drives[cdrom_id].host_drive; - strcpy(temp_iso_path, openfilestring); - if ((strcmp(cdrom_iso[cdrom_id].iso_path, temp_iso_path) == 0) && (cdrom_drives[cdrom_id].host_drive == 200)) + wcscpy(temp_iso_path, wopenfilestring); + if ((wcscmp(cdrom_iso[cdrom_id].iso_path, temp_iso_path) == 0) && (cdrom_drives[cdrom_id].host_drive == 200)) { /* Switching from ISO to the same ISO. Do nothing. */ break; diff --git a/src/win.h b/src/win.h index 17316c27a..d49689a15 100644 --- a/src/win.h +++ b/src/win.h @@ -9,9 +9,9 @@ extern int mousecapture; extern "C" { #endif -#define szClassName "86BoxMainWnd" -#define szSubClassName "86BoxSubWnd" -#define szStatusBarClassName "86BoxStatusBar" +#define szClassName L"86BoxMainWnd" +#define szSubClassName L"86BoxSubWnd" +#define szStatusBarClassName L"86BoxStatusBar" void leave_fullscreen(); @@ -28,12 +28,13 @@ void deviceconfig_open(HWND hwnd, struct device_t *device); void joystickconfig_open(HWND hwnd, int joy_nr, int type); extern char openfilestring[260]; +extern WCHAR wopenfilestring[260]; int getfile(HWND hwnd, char *f, char *fn); int getsfile(HWND hwnd, char *f, char *fn); void get_executable_name(char *s, int size); -void set_window_title(char *s); +void set_window_title(WCHAR *s); void startblit(); void endblit();