Made the emulator even more Unicode then before - configuration files are now Unicode, and floppy images, CD/DVD .ISO images, and hard disk images can now be in paths with non-Latin characters;

Fixed a few minor UI bugs;
Brought IDE IDENTIFY command behavior back in line with Mainline PCEM, in hopes to reduce bugs.
This commit is contained in:
OBattler
2017-05-05 22:36:10 +02:00
parent b024f174a3
commit cee82642ef
38 changed files with 487 additions and 282 deletions

View File

@@ -13,6 +13,7 @@
#include <string.h>
#include <sys/types.h>
#include <wchar.h>
#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;