]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc1600b15.zip
authorToni Wilen <twilen@winuae.net>
Sat, 7 Mar 2009 14:31:07 +0000 (16:31 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 19:45:00 +0000 (21:45 +0200)
156 files changed:
a2091.c
akiko.c
amax.c
ar.c
arcadia.c
archivers/dms/pfile.c
archivers/lha/header.c
archivers/lha/lhamaketbl.c
archivers/lha/lharc.c
archivers/lha/uae_lha.c
archivers/lzx/unlzx.c
archivers/wrp/warp.c
audio.c
autoconf.c
blitter.c
blkdev.c
bsdsocket.c
build68k.c
catweasel.c
cd32_fmv.c
cdtv.c
cfgfile.c
cia.c
cpummu.c
crc32.c
custom.c
debug.c
disk.c
drawing.c
driveclick.c
enforcer.c
ersatz.c
expansion.c
fdi2raw.c
filesys.c
fpp.c
fsdb.c
fsusage.c
gayle.c
gfxlib.c
gfxutil.c
hardfile.c
identify.c
include/a2091.h
include/arcadia.h
include/autoconf.h
include/blkdev.h
include/bsdsocket.h
include/cdtv.h
include/cpummu.h
include/crc32.h
include/debug.h
include/disk.h
include/driveclick.h
include/filesys.h
include/fsdb.h
include/gayle.h
include/gfxfilter.h
include/gui.h
include/identify.h
include/inputdevice.h
include/memory.h
include/newcpu.h
include/options.h
include/readcpu.h
include/savestate.h
include/sysdeps.h
include/traps.h
include/uae.h
include/uaeexe.h
include/uaeipc.h
include/zarchive.h
include/zfile.h
inputdevice.c
inputevents.def
jit/compemu_fpp.c
jit/compemu_raw_x86.c
jit/compemu_support.c
keybuf.c
main.c
memory.c
missing.c
moduleripper.c
ncr_scsi.c
newcpu.c
od-win32/ahidsound.c
od-win32/ahidsound.h
od-win32/ahidsound_new.c
od-win32/avioutput.c
od-win32/avioutput.h
od-win32/blkdev_win32_aspi.c
od-win32/blkdev_win32_ioctl.c
od-win32/blkdev_win32_spti.c
od-win32/bsdsock.c
od-win32/caps/caps_win32.c
od-win32/clipboard_win32.c
od-win32/debug_win32.c
od-win32/debug_win32.h
od-win32/dinput.c
od-win32/direct3d.c
od-win32/direct3d.h
od-win32/driveclick_win32.c
od-win32/dxwrap.c
od-win32/dxwrap.h
od-win32/fsdb_win32.c
od-win32/hardfile_win32.c
od-win32/ioport.c
od-win32/ioport.h
od-win32/keyboard_win32.c
od-win32/lcd.c
od-win32/lcd.h
od-win32/midi.c
od-win32/mman.c
od-win32/opengl.c
od-win32/opengl.h
od-win32/parser.c
od-win32/parser.h
od-win32/picasso96_win.c
od-win32/posixemu.c
od-win32/registry.c
od-win32/registry.h
od-win32/rp.c
od-win32/rp.h
od-win32/screenshot.c
od-win32/serial_win32.c
od-win32/sounddep/sound.c
od-win32/sys/mman.h
od-win32/target.h
od-win32/threaddep/thread.h
od-win32/unicode.c [new file with mode: 0644]
od-win32/win32.c
od-win32/win32.h
od-win32/win32_filesys.c
od-win32/win32_scale2x.c
od-win32/win32_uaenet.c
od-win32/win32_uaenet.h
od-win32/win32gfx.c
od-win32/win32gui.c
od-win32/win32gui.h
od-win32/win32gui_extra.c
od-win32/winuae_msvc/winuae_msvc.vcproj
od-win32/winuaechangelog.txt
od-win32/writelog.c
readcpu.c
sana2.c
savestate.c
scsi.c
scsiemul.c
traps.c
uaeexe.c
uaeipc.c
uaelib.c
uaeresource.c
uaeserial.c
zfile.c
zfile_archive.c

diff --git a/a2091.c b/a2091.c
index eed6ad5922f03815af1ce68c1c5117147fbc89b9..7011fb302c3e60fccba6e068d30f4398882b64be 100644 (file)
--- a/a2091.c
+++ b/a2091.c
@@ -162,7 +162,7 @@ struct scsi_data *scsis[8];
 
 uae_u8 wdregs[32];
 
-static int isirq(void)
+static int isirq (void)
 {
     if (superdmac) {
        if ((dmac_cntr & SCNTR_INTEN) && (dmac_istr & (ISTR_INTS | ISTR_E_INT)))
@@ -174,21 +174,21 @@ static int isirq(void)
     return 0;
 }
 
-void rethink_a2091(void)
+void rethink_a2091 (void)
 {
     if (currprefs.cs_cdtvscsi)
        return;
     if (isirq()) {
        uae_int_requested |= 2;
 #if A2091_DEBUG > 2 || A3000_DEBUG > 2
-       write_log ("Interrupt_RETHINK\n");
+       write_log (L"Interrupt_RETHINK\n");
 #endif
     } else {
        uae_int_requested &= ~2;
     }
 }
 
-static void INT2(void)
+static void INT2 (void)
 {
     int irq = 0;
 
@@ -197,34 +197,34 @@ static void INT2(void)
     if (!(auxstatus & 0x80))
        return;
     dmac_istr |= ISTR_INTS;
-    if (isirq())
+    if (isirq ())
        uae_int_requested |= 2;
 }
 
-static void dmac_start_dma(void)
+static void dmac_start_dma (void)
 {
 #if A3000_DEBUG > 0 || A2091_DEBUG > 0
-    write_log ("DMAC DMA started, ADDR=%08X, LEN=%08X words\n", dmac_acr, dmac_wtc);
+    write_log (L"DMAC DMA started, ADDR=%08X, LEN=%08X words\n", dmac_acr, dmac_wtc);
 #endif
     dmac_dma = 1;
 }
-static void dmac_stop_dma(void)
+static void dmac_stop_dma (void)
 {
     dmac_dma = 0;
     dmac_istr &= ~ISTR_E_INT;
 }
 
-static void dmac_reset(void)
+static void dmac_reset (void)
 {
 #if WD33C93_DEBUG > 0
     if (superdmac)
-       write_log ("A3000 %s SCSI reset\n", WD33C93);
+       write_log (L"A3000 %s SCSI reset\n", WD33C93);
     else
-       write_log ("A2091 %s SCSI reset\n", WD33C93);
+       write_log (L"A2091 %s SCSI reset\n", WD33C93);
 #endif
 }
 
-static void incsasr(int w)
+static void incsasr (int w)
 {
     if (sasr == WD_AUXILIARY_STATUS || sasr == WD_DATA || sasr == WD_COMMAND)
        return;
@@ -234,18 +234,18 @@ static void incsasr(int w)
     sasr &= 0x1f;
 }
 
-static void dmac_cint(void)
+static void dmac_cint (void)
 {
     dmac_istr = 0;
     rethink_a2091();
 }
 
-static void doscsistatus(void)
+static void doscsistatus (void)
 {
     wdregs[WD_SCSI_STATUS] = scsidelay_status;
     auxstatus |= 0x80;
 #if WD33C93_DEBUG > 0
-    write_log ("%s STATUS=%02X\n", WD33C93, scsidelay_status);
+    write_log (L"%s STATUS=%02X\n", WD33C93, scsidelay_status);
 #endif
     if (currprefs.cs_cdtvscsi) {
        cdtv_scsi_int ();
@@ -255,11 +255,11 @@ static void doscsistatus(void)
        return;
     INT2();
 #if A2091_DEBUG > 2 || A3000_DEBUG > 2
-    write_log ("Interrupt\n");
+    write_log (L"Interrupt\n");
 #endif
 }
 
-void scsi_hsync(void)
+void scsi_hsync (void)
 {
     if (scsidelay_irq == 1) {
        scsidelay_irq = 0;
@@ -270,36 +270,36 @@ void scsi_hsync(void)
        scsidelay_irq--;
 }
 
-static void set_status(uae_u8 status, int quick)
+static void set_status (uae_u8 status, int quick)
 {
     scsidelay_irq = quick <= 2 ? 2 : quick;
     scsidelay_status = status;
 }
 
-static char *scsitostring(void)
+static TCHAR *scsitostring (void)
 {
-    static char buf[200];
-    char *p;
+    static TCHAR buf[200];
+    TCHAR *p;
     int i;
 
     p = buf;
     p[0] = 0;
     for (i = 0; i < wd_tc && i < sizeof wd_data; i++) {
        if (i > 0) {
-           strcat(p, ".");
+           _tcscat (p, L".");
            p++;
        }
-       sprintf(p, "%02X", wd_data[i]);
-       p += strlen(p);
+       _stprintf (p, L"%02X", wd_data[i]);
+       p += _tcslen (p);
     }
     return buf;
 }
 
-static void wd_cmd_sel_xfer(void)
+static void wd_cmd_sel_xfer (void)
 {
     int phase = wdregs[WD_COMMAND_PHASE];
 #if WD33C93_DEBUG > 0
-    write_log ("* %s select and transfer, ID=%d phase=%02X\n", WD33C93, wdregs[WD_DESTINATION_ID] & 0x7, phase);
+    write_log (L"* %s select and transfer, ID=%d phase=%02X\n", WD33C93, wdregs[WD_DESTINATION_ID] & 0x7, phase);
 #endif
     if (!SCSIID) {
        set_status (CSR_TIMEOUT, 0);
@@ -316,12 +316,12 @@ static void wd_cmd_sel_xfer(void)
     set_status (wd_phase, 1);
 }
 
-static void do_dma(void)
+static void do_dma (void)
 {
     if (currprefs.cs_cdtvscsi)
        cdtv_getdmadata (&dmac_acr);
     if (SCSIID->direction == 0) {
-       write_log ("%s DMA but no data!?\n", WD33C93);
+       write_log (L"%s DMA but no data!?\n", WD33C93);
     } else if (SCSIID->direction < 0) {
        for (;;) {
            uae_u8 v;
@@ -347,10 +347,10 @@ static void do_dma(void)
     }
 }
 
-static void wd_do_transfer_out(void)
+static void wd_do_transfer_out (void)
 {
 #if WD33C93_DEBUG > 0
-    write_log ("%s SCSI O [%02X] %d/%d %s\n", WD33C93, wdregs[WD_COMMAND_PHASE], wd_dataoffset, wd_tc, scsitostring());
+    write_log (L"%s SCSI O [%02X] %d/%d %s\n", WD33C93, wdregs[WD_COMMAND_PHASE], wd_dataoffset, wd_tc, scsitostring());
 #endif
     if (wdregs[WD_COMMAND_PHASE] == 0x11) {
        wdregs[WD_COMMAND_PHASE] = 0x20;
@@ -385,10 +385,10 @@ static void wd_do_transfer_out(void)
     wd_busy = 0;
 }
 
-static void wd_do_transfer_in(void)
+static void wd_do_transfer_in (void)
 {
 #if WD33C93_DEBUG > 0
-    write_log ("%s SCSI I [%02X] %d/%d %s\n", WD33C93, wdregs[WD_COMMAND_PHASE], wd_dataoffset, wd_tc, scsitostring());
+    write_log (L"%s SCSI I [%02X] %d/%d %s\n", WD33C93, wdregs[WD_COMMAND_PHASE], wd_dataoffset, wd_tc, scsitostring());
 #endif
     wd_dataoffset = 0;
     if (wdregs[WD_COMMAND_PHASE] >= 0x36 && wdregs[WD_COMMAND_PHASE] < 0x47) {
@@ -406,13 +406,13 @@ static void wd_do_transfer_in(void)
     SCSIID->direction = 0;
 }
 
-static void wd_cmd_sel_xfer_atn(void)
+static void wd_cmd_sel_xfer_atn (void)
 {
     int i, tmp_tc;
 
     tmp_tc = wdregs[WD_TRANSFER_COUNT_LSB] | (wdregs[WD_TRANSFER_COUNT] << 8) | (wdregs[WD_TRANSFER_COUNT_MSB] << 16);
 #if WD33C93_DEBUG > 0
-    write_log ("* %s select and transfer with atn, ID=%d PHASE=%02X TC=%d\n",
+    write_log (L"* %s select and transfer with atn, ID=%d PHASE=%02X TC=%d\n",
        WD33C93, wdregs[WD_DESTINATION_ID] & 0x7, wdregs[WD_COMMAND_PHASE], tmp_tc);
 #endif
     if (wdregs[WD_COMMAND] & 0x80)
@@ -470,7 +470,7 @@ static void wd_cmd_sel_xfer_atn(void)
 }
 
 
-static void wd_cmd_trans_info(void)
+static void wd_cmd_trans_info (void)
 {
     if (wdregs[WD_COMMAND_PHASE] == 0x47)
        SCSIID->buffer[0] = SCSIID->status;
@@ -482,7 +482,7 @@ static void wd_cmd_trans_info(void)
        wd_tc = 1;
     wd_dataoffset = 0;
 #if WD33C93_DEBUG > 0
-    write_log ("* %s transfer info phase=%02x len=%d dma=%d\n", WD33C93, wdregs[WD_COMMAND_PHASE], wd_tc, wdregs[WD_CONTROL] >> 5);
+    write_log (L"* %s transfer info phase=%02x len=%d dma=%d\n", WD33C93, wdregs[WD_COMMAND_PHASE], wd_tc, wdregs[WD_CONTROL] >> 5);
 #endif
     scsi_start_transfer (SCSIID, wd_tc);
     if (wdregs[WD_COMMAND_PHASE] >= 0x36 && wdregs[WD_COMMAND_PHASE] <= 0x3f)
@@ -501,7 +501,7 @@ static void wd_cmd_trans_info(void)
 static void wd_cmd_sel_atn (void)
 {
 #if WD33C93_DEBUG > 0
-    write_log ("* %s select with atn, ID=%d\n", WD33C93, wdregs[WD_DESTINATION_ID] & 0x7);
+    write_log (L"* %s select with atn, ID=%d\n", WD33C93, wdregs[WD_DESTINATION_ID] & 0x7);
 #endif
     wd_phase = 0;
     wdregs[WD_COMMAND_PHASE] = 0;
@@ -519,7 +519,7 @@ static void wd_cmd_reset (void)
     int i;
 
 #if WD33C93_DEBUG > 0
-    write_log ("%s reset\n", WD33C93);
+    write_log (L"%s reset\n", WD33C93);
 #endif
     for (i = 1; i < 0x16; i++)
        wdregs[i] = 0;
@@ -532,7 +532,7 @@ static void wd_cmd_reset (void)
 static void wd_cmd_abort (void)
 {
 #if WD33C93_DEBUG > 0
-    write_log ("%s abort\n", WD33C93);
+    write_log (L"%s abort\n", WD33C93);
 #endif
     set_status (CSR_SEL_ABORT, 0);
 }
@@ -548,17 +548,17 @@ void wdscsi_put (uae_u8 d)
 {
 #if WD33C93_DEBUG > 1
     if (WD33C93_DEBUG > 3 || sasr != WD_DATA)
-       write_log ("W %s REG %02X (%d) = %02X (%d) PC=%08X\n", WD33C93, sasr, sasr, d, d, M68K_GETPC);
+       write_log (L"W %s REG %02X (%d) = %02X (%d) PC=%08X\n", WD33C93, sasr, sasr, d, d, M68K_GETPC);
 #endif
     if (!writeonlyreg (sasr))
        wdregs[sasr] = d;
     if (!wd_used) {
        wd_used = 1;
-       write_log ("%s in use\n", WD33C93);
+       write_log (L"%s in use\n", WD33C93);
     }
     if (sasr == WD_COMMAND_PHASE) {
 #if WD33C93_DEBUG > 0
-       write_log ("%s PHASE=%02X\n", WD33C93, d);
+       write_log (L"%s PHASE=%02X\n", WD33C93, d);
 #endif
     } else if (sasr == WD_DATA) {
        if (wd_dataoffset < sizeof wd_data)
@@ -586,7 +586,7 @@ void wdscsi_put (uae_u8 d)
                wd_cmd_trans_info ();
            break;
            default:
-               write_log ("%s unimplemented/unknown command %02X\n", WD33C93, d);
+               write_log (L"%s unimplemented/unknown command %02X\n", WD33C93, d);
            break;
        }
     }
@@ -602,7 +602,7 @@ uae_u8 wdscsi_getauxstatus (void)
     return (auxstatus & 0x80) | (wd_busy ? 0x20 : 0) | (wd_busy ? 0x01 : 0);
 }
 
-uae_u8 wdscsi_get(void)
+uae_u8 wdscsi_get (void)
 {
     uae_u8 v, osasr = sasr;
 
@@ -629,7 +629,7 @@ uae_u8 wdscsi_get(void)
     incsasr (0);
 #if WD33C93_DEBUG > 1
     if (WD33C93_DEBUG > 3 || osasr != WD_DATA)
-       write_log ("R %s REG %02X (%d) = %02X (%d) PC=%08X\n", WD33C93, osasr, osasr, v, v, M68K_GETPC);
+       write_log (L"R %s REG %02X (%d) = %02X (%d) PC=%08X\n", WD33C93, osasr, osasr, v, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -701,7 +701,7 @@ static uae_u32 dmac_bget2 (uaecptr addr)
        break;
     }
 #if A2091_DEBUG > 0
-    write_log ("dmac_bget %04X=%02X PC=%08X\n", addr, v, M68K_GETPC);
+    write_log (L"dmac_bget %04X=%02X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -786,7 +786,7 @@ static void dmac_bput2 (uaecptr addr, uae_u32 b)
        break;
     }
 #if A2091_DEBUG > 0
-    write_log ("dmac_bput %04X=%02X PC=%08X\n", addr, b & 255, M68K_GETPC);
+    write_log (L"dmac_bput %04X=%02X PC=%08X\n", addr, b & 255, M68K_GETPC);
 #endif
 }
 
@@ -805,7 +805,7 @@ static uae_u32 REGPARAM2 dmac_lget (uaecptr addr)
     v |= dmac_bget2 (addr + 3);
 #ifdef A2091_DEBUG
     if (addr >= 0x40 && addr < ROM_OFFSET)
-       write_log ("dmac_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
+       write_log (L"dmac_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -821,7 +821,7 @@ static uae_u32 REGPARAM2 dmac_wget (uaecptr addr)
     v |= dmac_bget2 (addr + 1);
 #if A2091_DEBUG > 0
     if (addr >= 0x40 && addr < ROM_OFFSET)
-       write_log ("dmac_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
+       write_log (L"dmac_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -847,7 +847,7 @@ static void REGPARAM2 dmac_lput (uaecptr addr, uae_u32 l)
     addr &= 65535;
 #if A2091_DEBUG > 0
     if (addr >= 0x40 && addr < ROM_OFFSET)
-       write_log ("dmac_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
+       write_log (L"dmac_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
 #endif
     dmac_bput2 (addr, l >> 24);
     dmac_bput2 (addr + 1, l >> 16);
@@ -863,7 +863,7 @@ static void REGPARAM2 dmac_wput (uaecptr addr, uae_u32 w)
     addr &= 65535;
 #if A2091_DEBUG > 0
     if (addr >= 0x40 && addr < ROM_OFFSET)
-       write_log ("dmac_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
+       write_log (L"dmac_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
 #endif
     dmac_bput2 (addr, w >> 8);
     dmac_bput2 (addr + 1, w);
@@ -878,13 +878,13 @@ static void REGPARAM2 dmac_bput (uaecptr addr, uae_u32 b)
     addr &= 65535;
     if (addr == 0x48 && !configured) {
        map_banks (&dmaca2091_bank, b, 0x10000 >> 16, 0x10000);
-       write_log ("A590/A2091 Z2 autoconfigured at %02X0000\n", b);
+       write_log (L"A590/A2091 Z2 autoconfigured at %02X0000\n", b);
        configured = 1;
        expamem_next ();
        return;
     }
     if (addr == 0x4c && !configured) {
-       write_log ("A590/A2091 DMAC AUTOCONFIG SHUT-UP!\n");
+       write_log (L"A590/A2091 DMAC AUTOCONFIG SHUT-UP!\n");
        configured = 1;
        expamem_next ();
        return;
@@ -919,17 +919,17 @@ static uae_u32 REGPARAM2 dmac_lgeti (uaecptr addr)
 addrbank dmaca2091_bank = {
     dmac_lget, dmac_wget, dmac_bget,
     dmac_lput, dmac_wput, dmac_bput,
-    default_xlate, default_check, NULL, "A2091/A590",
+    default_xlate, default_check, NULL, L"A2091/A590",
     dmac_lgeti, dmac_wgeti, ABFLAG_IO
 };
 
-static void dmacreg_write(uae_u32 *reg, int addr, uae_u32 val, int size)
+static void dmacreg_write (uae_u32 *reg, int addr, uae_u32 val, int size)
 {
     addr = (size - 1) - addr;
     (*reg) &= ~(0xff << (addr * 8));
     (*reg) |= (val & 0xff) << (addr * 8);
 }
-static uae_u32 dmacreg_read(uae_u32 val, int addr, int size)
+static uae_u32 dmacreg_read (uae_u32 val, int addr, int size)
 {
     addr = (size - 1) - addr;
     return (val >> (addr * 8)) & 0xff;
@@ -940,7 +940,7 @@ static void mbdmac_write (uae_u32 addr, uae_u32 val, int mode)
     if (currprefs.cs_mbdmac > 1)
        return;
 #if A3000_DEBUG > 1
-    write_log ("DMAC_WRITE %08X=%02X PC=%08X\n", addr, val & 0xff, M68K_GETPC);
+    write_log (L"DMAC_WRITE %08X=%02X PC=%08X\n", addr, val & 0xff, M68K_GETPC);
 #endif
     addr &= 0xffff;
     switch (addr)
@@ -1068,7 +1068,7 @@ static uae_u32 mbdmac_read (uae_u32 addr, int mode)
        break;
     }
 #if A3000_DEBUG > 1
-    write_log ("DMAC_READ %08X=%02X PC=%X\n", vaddr, v & 0xff, M68K_GETPC);
+    write_log (L"DMAC_READ %08X=%02X PC=%X\n", vaddr, v & 0xff, M68K_GETPC);
 #endif
     return v;
 }
@@ -1139,7 +1139,7 @@ static void REGPARAM2 mbdmac_bput (uaecptr addr, uae_u32 b)
 addrbank mbdmac_a3000_bank = {
     mbdmac_lget, mbdmac_wget, mbdmac_bget,
     mbdmac_lput, mbdmac_wput, mbdmac_bput,
-    default_xlate, default_check, NULL, "A3000 DMAC",
+    default_xlate, default_check, NULL, L"A3000 DMAC",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -1155,7 +1155,7 @@ static void ew (int addr, uae_u32 value)
     }
 }
 
-static void freescsi(struct scsi_data *sd)
+static void freescsi (struct scsi_data *sd)
 {
     if (!sd)
        return;
@@ -1163,9 +1163,9 @@ static void freescsi(struct scsi_data *sd)
     scsi_free (sd);
 }
 
-int addscsi(int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys, int scsi_level)
+int addscsi (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys, int scsi_level)
 {
     struct hd_hardfiledata *hfd;
 
@@ -1179,7 +1179,7 @@ int addscsi(int ch, char *path, int blocksize, int readonly,
     return scsis[ch] ? 1 : 0;
 }
 
-static void freenativescsi(void)
+static void freenativescsi (void)
 {
     int i;
     for (i = 0; i < 7; i++) {
@@ -1188,7 +1188,7 @@ static void freenativescsi(void)
     }
 }
 
-static void addnativescsi(void)
+static void addnativescsi (void)
 {
     int i, j;
     int devices[MAX_TOTAL_DEVICES];
@@ -1228,16 +1228,16 @@ static void addnativescsi(void)
     while (devices[i] >= 0 && j < 7) {
        if (scsis[j] == NULL) {
            scsis[j] = scsi_alloc_native(j, devices[i]);
-           write_log ("SCSI: %d:'%s'\n", j, dis[i].label);
+           write_log (L"SCSI: %d:'%s'\n", j, dis[i].label);
            i++;
        }
        j++;
     }
 }
 
-int a3000_add_scsi_unit (int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys)
+int a3000_add_scsi_unit (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys)
 {
     return addscsi (ch, path, blocksize, readonly, devname, sectors, surfaces, reserved, bootpri, filesys, 2);
 }
@@ -1252,9 +1252,9 @@ void a3000scsi_free (void)
     freenativescsi ();
 }
 
-int a2091_add_scsi_unit (int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys)
+int a2091_add_scsi_unit (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys)
 {
     return addscsi (ch, path, blocksize, readonly, devname, sectors, surfaces, reserved, bootpri, filesys, 1);
 }
@@ -1315,7 +1315,7 @@ void a2091_init (void)
        rd = rl->rd; 
        z = read_rom (&rd);
        if (z) {
-           write_log ("A590/A2091 BOOT ROM %d.%d ", rd->ver, rd->rev);
+           write_log (L"A590/A2091 BOOT ROM %d.%d ", rd->ver, rd->rev);
            rom_size = rd->size;
            rom = xmalloc (rom_size);
            if (rl->rd->id == 56)
diff --git a/akiko.c b/akiko.c
index 63220eddcdb7cd64b6306e3cecdab0fca2d2eca1..135e61336e94269893406338c9580ababf117742 100644 (file)
--- a/akiko.c
+++ b/akiko.c
@@ -38,7 +38,7 @@
 static void irq (void)
 {
 #if AKIKO_DEBUG_IO > 1
-    write_log ("Akiko Interrupt\n");
+    write_log (L"Akiko Interrupt\n");
 #endif
     if (!(intreq & 8)) {
        INTREQ_0 (0x8000 | 0x0008);
@@ -82,9 +82,9 @@ static void nvram_write (int offset, int len)
 
     if (!currprefs.cs_cd32nvram)
        return;
-    f = zfile_fopen (currprefs.flashfile, "rb+");
+    f = zfile_fopen (currprefs.flashfile, L"rb+");
     if (!f) {
-       f = zfile_fopen (currprefs.flashfile, "wb");
+       f = zfile_fopen (currprefs.flashfile, L"wb");
        if (!f) return;
        zfile_fwrite (cd32_nvram, NVRAM_SIZE, 1, f);
     }
@@ -99,7 +99,7 @@ static void nvram_read (void)
 
     if (!currprefs.cs_cd32nvram)
        return;
-    f = zfile_fopen (currprefs.flashfile, "rb");
+    f = zfile_fopen (currprefs.flashfile, L"rb");
     memset (cd32_nvram, 0, NVRAM_SIZE);
     if (!f) return;
     zfile_fread (cd32_nvram, NVRAM_SIZE, 1, f);
@@ -118,24 +118,24 @@ static void i2c_do (void)
            bitcounter = 0;
            direction = -1;
 #if AKIKO_DEBUG_NVRAM
-           write_log ("START\n");
+           write_log (L"START\n");
 #endif
            return;
        } else if(sda_out && !osda) { /* STOP-condition? */
            state = I2C_WAIT;
            bitcounter = -1;
 #if AKIKO_DEBUG_NVRAM
-           write_log ("STOP\n");
+           write_log (L"STOP\n");
 #endif
            if (direction > 0) {
                memcpy (cd32_nvram + (nvram_address & ~(NVRAM_PAGE_SIZE - 1)), nvram_writetmp, NVRAM_PAGE_SIZE);
                nvram_write (nvram_address & ~(NVRAM_PAGE_SIZE - 1), NVRAM_PAGE_SIZE);
                direction = -1;
 #if AKIKO_DEBUG_NVRAM
-               write_log ("NVRAM write address %04X:", nvram_address & ~(NVRAM_PAGE_SIZE - 1));
+               write_log (L"NVRAM write address %04X:", nvram_address & ~(NVRAM_PAGE_SIZE - 1));
                for (i = 0; i < NVRAM_PAGE_SIZE; i++)
-                   write_log ("%02X", nvram_writetmp[i]);
-               write_log ("\n");
+                   write_log (L"%02X", nvram_writetmp[i]);
+               write_log (L"\n");
 
 #endif
            }
@@ -148,7 +148,7 @@ static void i2c_do (void)
            if (scl_out && !oscl) {
                if (bitcounter == 8) {
 #if AKIKO_DEBUG_NVRAM
-                   write_log ("RB %02X ", nvram_byte, M68K_GETPC);
+                   write_log (L"RB %02X ", nvram_byte, M68K_GETPC);
 #endif
                    sda_in = 0; /* ACK */
                    if (direction > 0) {
@@ -159,7 +159,7 @@ static void i2c_do (void)
                        bitcounter = -1;
                    }
                } else {
-                   //write_log ("NVRAM received bit %d, offset %d\n", sda_out, bitcounter);
+                   //write_log (L"NVRAM received bit %d, offset %d\n", sda_out, bitcounter);
                    nvram_byte <<= 1;
                    nvram_byte |= sda_out;
                    bitcounter++;
@@ -172,12 +172,12 @@ static void i2c_do (void)
                    nvram_byte = cd32_nvram[nvram_address];
                sda_dir_nvram = 1;
                sda_in = (nvram_byte & 0x80) ? 1 : 0;
-               //write_log ("NVRAM sent bit %d, offset %d\n", sda_in, bitcounter);
+               //write_log (L"NVRAM sent bit %d, offset %d\n", sda_in, bitcounter);
                nvram_byte <<= 1;
                bitcounter++;
                if (bitcounter == 8) {
 #if AKIKO_DEBUG_NVRAM
-                   write_log ("NVRAM sent byte %02X address %04X PC=%08X\n", cd32_nvram[nvram_address], nvram_address, M68K_GETPC);
+                   write_log (L"NVRAM sent byte %02X address %04X PC=%08X\n", cd32_nvram[nvram_address], nvram_address, M68K_GETPC);
 #endif
                    nvram_address++;
                    nvram_address &= NVRAM_SIZE - 1;
@@ -193,7 +193,7 @@ static void i2c_do (void)
     {
        case I2C_DEVICEADDR:
        if ((nvram_byte & 0xf0) != 0xa0) {
-           write_log ("WARNING: I2C_DEVICEADDR: device address != 0xA0\n");
+           write_log (L"WARNING: I2C_DEVICEADDR: device address != 0xA0\n");
            state = I2C_WAIT;
            return;
        }
@@ -211,14 +211,14 @@ static void i2c_do (void)
        }
        bitcounter = 0;
 #if AKIKO_DEBUG_NVRAM
-       write_log ("I2C_DEVICEADDR: rw %d, address %02Xxx PC=%08X\n", nvram_rw, nvram_address >> 8, M68K_GETPC);
+       write_log (L"I2C_DEVICEADDR: rw %d, address %02Xxx PC=%08X\n", nvram_rw, nvram_address >> 8, M68K_GETPC);
 #endif
        break;
        case I2C_WORDADDR:
        nvram_address &= 0x300;
        nvram_address |= nvram_byte;
 #if AKIKO_DEBUG_NVRAM
-       write_log ("I2C_WORDADDR: address %04X PC=%08X\n", nvram_address, M68K_GETPC);
+       write_log (L"I2C_WORDADDR: address %04X PC=%08X\n", nvram_address, M68K_GETPC);
 #endif
        if (direction < 0) {
            memcpy (nvram_writetmp, cd32_nvram + (nvram_address & ~(NVRAM_PAGE_SIZE - 1)), NVRAM_PAGE_SIZE);
@@ -488,7 +488,7 @@ static int cd_play_audio (uae_u32 startmsf, uae_u32 endmsf, int scan)
            break;
     }
     if ((s[1] & 0x0c) == 0x04) {
-       write_log ("tried to play data track %d!\n", s[3]);
+       write_log (L"tried to play data track %d!\n", s[3]);
        s += 11;
        startmsf = (s[8] << 16) | (s[9] << 8) | (s[10] << 0);
        s += 11;
@@ -613,7 +613,7 @@ static int sys_cddev_open (void)
        if (sys_command_open (DF_IOCTL, unitnum)) {
            di2 = sys_command_info (DF_IOCTL, unitnum, &di1);
            if (di2 && di2->type == INQ_ROMD) {
-               write_log ("%s: ", di2->label);
+               write_log (L"%s: ", di2->label);
                if (first < 0)
                    first = unitnum;
                if (!cdrom_toc ()) {
@@ -622,27 +622,27 @@ static int sys_cddev_open (void)
                        if (p) {
                            if (!memcmp (p + 8, "CDTV", 4) || !memcmp (p + 8, "CD32", 4)) {
                                uae_u32 crc;
-                               write_log ("CD32 or CDTV");
+                               write_log (L"CD32 or CDTV");
                                if (cd32unit < 0)
                                    cd32unit = unitnum;
                                p = sys_command_cd_read (DF_IOCTL, unitnum, 21);
                                crc = get_crc32 (p, 2048);
                                if (crc == 0xe56c340f)
-                                   write_log (" [CD32.TM]");
-                               write_log ("\n");
+                                   write_log (L" [CD32.TM]");
+                               write_log (L"\n");
                            } else {
-                               write_log ("non CD32/CDTV data CD\n");
+                               write_log (L"non CD32/CDTV data CD\n");
                            }
                        } else {
-                           write_log ("read error\n");
+                           write_log (L"read error\n");
                        }
                    } else {
-                       write_log ("Audio CD\n");
+                       write_log (L"Audio CD\n");
                        if (audiounit < 0)
                            audiounit = unitnum;
                    }
                } else {
-                   write_log ("can't read TOC\n");
+                   write_log (L"can't read TOC\n");
                }
            }
            sys_command_close (DF_IOCTL, unitnum);
@@ -656,16 +656,16 @@ static int sys_cddev_open (void)
     if (unitnum < 0)
        return 1;
     if (!sys_command_open (DF_IOCTL, unitnum))
-       write_log ("re-opening unit %d failed!\n", unitnum);
+       write_log (L"re-opening unit %d failed!\n", unitnum);
     di2 = sys_command_info (DF_IOCTL, unitnum, &di1);
     if (!di2) {
-       write_log ("unit %d info failed\n", unitnum);
+       write_log (L"unit %d info failed\n", unitnum);
        sys_command_close (DF_IOCTL, unitnum);
        return 1;
     }
     if (!sys_command_ismedia(DF_IOCTL, unitnum, 0))
        cd_hunt = 1;
-    write_log ("using drive %s (unit %d, media %d)\n", di2->label, unitnum, di2->media_inserted);
+    write_log (L"using drive %s (unit %d, media %d)\n", di2->label, unitnum, di2->media_inserted);
     /* make sure CD audio is not playing */
     cdaudiostop ();
     return 0;
@@ -689,19 +689,19 @@ static void cdrom_return_data (int len)
     if (len <= 0)
        return;
 #if AKIKO_DEBUG_IO_CMD
-    write_log ("OUT:");
+    write_log (L"OUT:");
 #endif
     checksum = 0xff;
     for (i = 0; i < len; i++) {
        checksum -= cdrom_result_buffer[i];
        put_byte (cmd_buf + ((cdrom_result_complete + i) & 0xff), cdrom_result_buffer[i]);
 #if AKIKO_DEBUG_IO_CMD
-       write_log ("%02X ", cdrom_result_buffer[i]);
+       write_log (L"%02X ", cdrom_result_buffer[i]);
 #endif
     }
     put_byte (cmd_buf + ((cdrom_result_complete + len) & 0xff), checksum);
 #if AKIKO_DEBUG_IO_CMD
-    write_log ("%02X\n", checksum);
+    write_log (L"%02X\n", checksum);
 #endif
     cdrom_result_complete += len + 1;
     set_status (CDSTATUS_DATA_AVAILABLE);
@@ -820,7 +820,7 @@ static int cdrom_command_multi (void)
        int cdrom_data_offset_end = msf2lsn (endpos);
        cdrom_data_offset = msf2lsn (seekpos);
 #if AKIKO_DEBUG_IO_CMD
-       write_log ("READ DATA %06X (%d) - %06X (%d) SPD=%dx PC=%08X\n",
+       write_log (L"READ DATA %06X (%d) - %06X (%d) SPD=%dx PC=%08X\n",
            seekpos, cdrom_data_offset, endpos, cdrom_data_offset_end, cdrom_speed, M68K_GETPC);
 #endif
        cdrom_result_buffer[1] |= 0x02;
@@ -831,7 +831,7 @@ static int cdrom_command_multi (void)
        else if (cdrom_command_buffer[7] & 0x08)
            scan = -1;
 #if AKIKO_DEBUG_IO_CMD
-       write_log ("PLAY FROM %06X (%d) to %06X (%d) SCAN=%d\n",
+       write_log (L"PLAY FROM %06X (%d) to %06X (%d) SCAN=%d\n",
            seekpos, msf2lsn (seekpos), endpos, msf2lsn (endpos), scan);
 #endif
        if (!cd_play_audio (seekpos, endpos, 0)) {
@@ -842,7 +842,7 @@ static int cdrom_command_multi (void)
        }
     } else {
 #if AKIKO_DEBUG_IO_CMD
-       write_log ("SEEKTO %06X\n",seekpos);
+       write_log (L"SEEKTO %06X\n",seekpos);
 #endif
        if (seekpos < 150)
            cdrom_toc_counter = 0;
@@ -880,29 +880,29 @@ static void cdrom_run_command (void)
        cmd_len = command_lengths[cdrom_command & 0x0f];
        if (cmd_len < 0) {
 #if AKIKO_DEBUG_IO_CMD
-           write_log ("unknown command\n");
+           write_log (L"unknown command\n");
 #endif
            cmd_len = 1;
        }
 #if AKIKO_DEBUG_IO_CMD
-       write_log ("IN:");
+       write_log (L"IN:");
 #endif
        checksum = 0;
        for (i = 0; i < cmd_len + 1; i++) {
            cdrom_command_buffer[i] = get_byte (cmd_buf + ((cdrom_command_offset_complete + i) & 0xff));
            checksum += cdrom_command_buffer[i];
 #if AKIKO_DEBUG_IO_CMD
-           write_log ("%02X ", cdrom_command_buffer[i]);
+           write_log (L"%02X ", cdrom_command_buffer[i]);
 #endif
        }
        if (checksum!=0xff) {
 #if AKIKO_DEBUG_IO_CMD
-           write_log (" checksum error");
+           write_log (L" checksum error");
 #endif
            cdrom_checksum_error = 1;
        }
 #if AKIKO_DEBUG_IO_CMD
-       write_log ("\n");
+       write_log (L"\n");
 #endif
        cdrom_command_active = 1;
        cdrom_command_length = cmd_len;
@@ -985,7 +985,7 @@ static void cdrom_run_read (void)
            return;
        }
 #if AKIKO_DEBUG_IO_CMD
-       write_log ("read sector=%d, scnt=%d -> %d. %08X\n",
+       write_log (L"read sector=%d, scnt=%d -> %d. %08X\n",
            cdrom_data_offset, cdrom_sector_counter, sector, cdrom_address1 + j * 4096);
 #endif
        cdrom_readmask_w &= ~(1 << j);
@@ -1017,7 +1017,7 @@ static void akiko_handler (void)
        int media = sys_command_ismedia (DF_IOCTL, unitnum, 0);
        mediacheckcnt = 312 * 50 * 2;
        if (media != lastmediastate) {
-           write_log ("media changed = %d\n", media);
+           write_log (L"media changed = %d\n", media);
            lastmediastate = cdrom_disk = media;
            cdrom_return_data (cdrom_command_media_status ());
            if (!media)
@@ -1064,7 +1064,7 @@ static void do_hunt(void)
     if (sys_command_open(DF_IOCTL, i) > 0) {
        unitnum = i;
        cd_hunt = 0;
-       write_log ("CD32: autodetected unit %d\n", unitnum);
+       write_log (L"CD32: autodetected unit %d\n", unitnum);
     }
 }
 
@@ -1151,7 +1151,7 @@ static void *akiko_thread (void *null)
                (sector_buffer_sector_1 < 0 || sector < sector_buffer_sector_1 || sector >= sector_buffer_sector_1 + SECTOR_BUFFER_SIZE * 2 / 3 || i != SECTOR_BUFFER_SIZE)) {
            memset (sector_buffer_info_2, 0, SECTOR_BUFFER_SIZE);
 #if AKIKO_DEBUG_IO_CMD
-           write_log ("filling buffer sector=%d (max=%d)\n", sector, cdrom_data_end);
+           write_log (L"filling buffer sector=%d (max=%d)\n", sector, cdrom_data_end);
 #endif
            sector_buffer_sector_2 = sector;
            offset = 0;
@@ -1292,14 +1292,14 @@ static uae_u32 akiko_bget2 (uaecptr addr, int msg)
        }
 
        default:
-       write_log ("akiko_bget: unknown address %08X\n", addr);
+       write_log (L"akiko_bget: unknown address %08X\n", addr);
        v = 0;
        break;
     }
     akiko_internal ();
     uae_sem_post (&akiko_sem);
     if (msg && addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log ("akiko_bget %08X: %08X %02X\n", M68K_GETPC, addr, v & 0xff);
+       write_log (L"akiko_bget %08X: %08X %02X\n", M68K_GETPC, addr, v & 0xff);
     return v;
 }
 
@@ -1321,7 +1321,7 @@ static uae_u32 REGPARAM2 akiko_wget (uaecptr addr)
     v = akiko_bget2 (addr + 1, 0);
     v |= akiko_bget2 (addr + 0, 0) << 8;
     if (addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log ("akiko_wget %08X: %08X %04X\n", M68K_GETPC, addr, v & 0xffff);
+       write_log (L"akiko_wget %08X: %08X %04X\n", M68K_GETPC, addr, v & 0xffff);
     return v;
 }
 
@@ -1338,7 +1338,7 @@ static uae_u32 REGPARAM2 akiko_lget (uaecptr addr)
     v |= akiko_bget2 (addr + 1, 0) << 16;
     v |= akiko_bget2 (addr + 0, 0) << 24;
     if (addr < 0x30 && (addr != 4 && addr != 8) && AKIKO_DEBUG_IO)
-       write_log ("akiko_lget %08: %08X %08X\n", M68K_GETPC, addr, v);
+       write_log (L"akiko_lget %08: %08X %08X\n", M68K_GETPC, addr, v);
     return v;
 }
 
@@ -1364,7 +1364,7 @@ static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
     v &= 0xff;
 
     if(msg && addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log ("akiko_bput %08X: %08X=%02X\n", M68K_GETPC, addr, v & 0xff);
+       write_log (L"akiko_bput %08X: %08X=%02X\n", M68K_GETPC, addr, v & 0xff);
 
     switch (addr)
     {
@@ -1455,7 +1455,7 @@ static void akiko_bput2 (uaecptr addr, uae_u32 v, int msg)
        }
 
        default:
-       write_log ("akiko_bput: unknown address %08X\n", addr);
+       write_log (L"akiko_bput: unknown address %08X\n", addr);
        break;
     }
     akiko_internal ();
@@ -1477,7 +1477,7 @@ static void REGPARAM2 akiko_wput (uaecptr addr, uae_u32 v)
 #endif
     addr &= 0xfff;
     if((addr < 0x30 && AKIKO_DEBUG_IO))
-       write_log ("akiko_wput %08X: %08X=%04X\n", M68K_GETPC, addr, v & 0xffff);
+       write_log (L"akiko_wput %08X: %08X=%04X\n", M68K_GETPC, addr, v & 0xffff);
     akiko_bput2 (addr + 1, v & 0xff, 0);
     akiko_bput2 (addr + 0, v >> 8, 0);
 }
@@ -1489,7 +1489,7 @@ static void REGPARAM2 akiko_lput (uaecptr addr, uae_u32 v)
 #endif
     addr &= 0xffff;
     if(addr < 0x30 && AKIKO_DEBUG_IO)
-       write_log ("akiko_lput %08X: %08X=%08X\n", M68K_GETPC, addr, v);
+       write_log (L"akiko_lput %08X: %08X=%08X\n", M68K_GETPC, addr, v);
     akiko_bput2 (addr + 3, (v >> 0) & 0xff, 0);
     akiko_bput2 (addr + 2, (v >> 8) & 0xff, 0);
     akiko_bput2 (addr + 1, (v >> 16) & 0xff, 0);
@@ -1499,7 +1499,7 @@ static void REGPARAM2 akiko_lput (uaecptr addr, uae_u32 v)
 addrbank akiko_bank = {
     akiko_lget, akiko_wget, akiko_bget,
     akiko_lput, akiko_wput, akiko_bput,
-    default_xlate, default_check, NULL, "Akiko",
+    default_xlate, default_check, NULL, L"Akiko",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -1559,13 +1559,13 @@ static void patchrom (void)
            p[i + 7] = 0x71;
            p[i + 8] = 0x4e;
            p[i + 9] = 0x71;
-           write_log ("extended rom delay loop patched at 0x%08x\n", i + 6 + 0xe00000);
+           write_log (L"extended rom delay loop patched at 0x%08x\n", i + 6 + 0xe00000);
            return;
        }
        if (!memcmp (p + i, patchdata2, sizeof(patchdata2)))
            return;
     }
-    write_log ("couldn't patch extended rom\n");
+    write_log (L"couldn't patch extended rom\n");
 }
 
 void akiko_free (void)
@@ -1579,7 +1579,7 @@ int akiko_init (void)
     if (currprefs.cs_cd32cd && cdromok == 0) {
        unitnum = -1;
        if (!device_func_init (DEVICE_TYPE_ANY)) {
-           write_log ("no CDROM support\n");
+           write_log (L"no CDROM support\n");
            return 0;
        }
        if (!sys_cddev_open ()) {
@@ -1600,7 +1600,7 @@ int akiko_init (void)
     }
     if (cdromok && !akiko_thread_running) {
        akiko_thread_running = 1;
-       uae_start_thread ("akiko", akiko_thread, 0, NULL);
+       uae_start_thread (L"akiko", akiko_thread, 0, NULL);
     }
     return 1;
 }
@@ -1615,7 +1615,7 @@ uae_u8 *save_akiko(int *len)
     if (!currprefs.cs_cd32cd)
        return NULL;
 
-    dstbak = dst = (uae_u8*)malloc (1000);
+    dstbak = dst = malloc (1000);
     save_u16 (0);
     save_u16 (0xCAFE);
     save_u32 (cdrom_status1);
diff --git a/amax.c b/amax.c
index b477e854fc2da6ad961c74f9f05672327ff3ae49..a60e54ab93e02ead57890aa2ab783f048b9babbd 100644 (file)
--- a/amax.c
+++ b/amax.c
@@ -44,7 +44,7 @@ static void load_byte (void)
     }
     data = val;
     if (AMAX_LOG > 0)
-       write_log ("AMAX: load byte, rom=%d addr=%06x (%06x) data=%02x (%02x) PC=%08X\n", rom_oddeven, romptr, addr, v, val, M68K_GETPC);
+       write_log (L"AMAX: load byte, rom=%d addr=%06x (%06x) data=%02x (%02x) PC=%08X\n", rom_oddeven, romptr, addr, v, val, M68K_GETPC);
 }
 
 static void amax_check (void)
@@ -52,7 +52,7 @@ static void amax_check (void)
     /* DIR low = reset address counter */
     if ((bfd100 & 2)) {
        if (romptr && AMAX_LOG > 0)
-           write_log ("AMAX: counter reset PC=%08X\n", M68K_GETPC);
+           write_log (L"AMAX: counter reset PC=%08X\n", M68K_GETPC);
         romptr = 0;
     }
 }
@@ -68,7 +68,7 @@ void amax_diskwrite (uae_u16 w)
        if (dwlastbit && !(w & 0x8000)) {
            romptr++;
            if (AMAX_LOG > 0)
-               write_log ("AMAX: counter increase %d PC=%08X\n", romptr, M68K_GETPC);
+               write_log (L"AMAX: counter increase %d PC=%08X\n", romptr, M68K_GETPC);
        }
        dwlastbit = (w & 0x8000) ? 1 : 0;
        w <<= 1;
@@ -89,7 +89,7 @@ void amax_bfe001_write (uae_u8 pra, uae_u8 dra)
        data <<= 1;
        data |= 1;
        if (AMAX_LOG > 0)
-           write_log ("AMAX: data shifted\n");
+           write_log (L"AMAX: data shifted\n");
     }
     /* TK0 = even, WPRO = odd */
     rom_oddeven = -1;
@@ -139,9 +139,9 @@ void amax_init (void)
     if (!currprefs.amaxromfile[0])
        return;
     amax_reset ();
-    z = zfile_fopen (currprefs.amaxromfile, "rb");
+    z = zfile_fopen (currprefs.amaxromfile, L"rb");
     if (!z) {
-       write_log ("AMAX: failed to load rom '%s'\n", currprefs.amaxromfile);
+       write_log (L"AMAX: failed to load rom '%s'\n", currprefs.amaxromfile);
        return;
     }
     zfile_fseek (z, 0, SEEK_END);
@@ -150,7 +150,7 @@ void amax_init (void)
     rom = xmalloc (rom_size);
     zfile_fread (rom, rom_size, 1, z);
     zfile_fclose (z);
-    write_log ("AMAX: '%s' loaded, %d bytes\n", currprefs.amaxromfile, rom_size);
+    write_log (L"AMAX: '%s' loaded, %d bytes\n", currprefs.amaxromfile, rom_size);
     dselect = 0x20;
 }
 
diff --git a/ar.c b/ar.c
index b471289da83003efd7d604b6298e9e52e3b062fc..cec5746b8adfc6571b16170e1091e100227affef 100644 (file)
--- a/ar.c
+++ b/ar.c
 #define write_log_debug
 #endif
 
-static char *cart_memnames[] = { NULL, "hrtmon", "arhrtmon", "superiv" };
+static TCHAR *cart_memnames[] = { NULL, L"hrtmon", L"arhrtmon", L"superiv" };
 
 #define ARMODE_FREEZE 0 /* AR2/3 The action replay 'freeze' button has been pressed.  */
 #define ARMODE_BREAKPOINT_AR2 2 /* AR2: The action replay is activated via a breakpoint. */
@@ -457,19 +457,19 @@ static uae_u8 *REGPARAM2 hrtmem_xlate (uaecptr addr)
 static addrbank hrtmem_bank = {
     hrtmem_lget, hrtmem_wget, hrtmem_bget,
     hrtmem_lput, hrtmem_wput, hrtmem_bput,
-    hrtmem_xlate, hrtmem_check, NULL, "Cartridge Bank",
+    hrtmem_xlate, hrtmem_check, NULL, L"Cartridge Bank",
     hrtmem_lget, hrtmem_wget, ABFLAG_RAM
 };
 static addrbank hrtmem2_bank = {
     hrtmem2_lget, hrtmem2_wget, hrtmem2_bget,
     hrtmem2_lput, hrtmem2_wput, hrtmem2_bput,
-    hrtmem2_xlate, hrtmem2_check, NULL, "Cartridge Bank 2",
+    hrtmem2_xlate, hrtmem2_check, NULL, L"Cartridge Bank 2",
     hrtmem2_lget, hrtmem2_wget, ABFLAG_RAM
 };
 static addrbank hrtmem3_bank = {
     hrtmem3_lget, hrtmem3_wget, hrtmem3_bget,
     hrtmem3_lput, hrtmem3_wput, hrtmem3_bput,
-    hrtmem3_xlate, hrtmem3_check, NULL, "Cartridge Bank 3",
+    hrtmem3_xlate, hrtmem3_check, NULL, L"Cartridge Bank 3",
     hrtmem3_lget, hrtmem3_wget, ABFLAG_RAM
 };
 
@@ -584,19 +584,19 @@ STATIC_INLINE int ar3a (uaecptr addr, uae_u8 b, int writing)
        armode = b;
        if (armode >= 2) {
            if (armode == ARMODE_BREAKPOINT_AR2) {
-               write_log ("AR2: exit with breakpoint(s) active\n"); /* Correct for AR2 */
+               write_log (L"AR2: exit with breakpoint(s) active\n"); /* Correct for AR2 */
            } else if (armode == ARMODE_BREAKPOINT_AR3_RESET_AR2 )
-               write_log ("AR3: exit waiting for breakpoint.\n"); /* Correct for AR3 (waiting for breakpoint)*/
+               write_log (L"AR3: exit waiting for breakpoint.\n"); /* Correct for AR3 (waiting for breakpoint)*/
            else
-               write_log ("AR2/3: mode(%d) > 3 this shouldn't happen.\n", armode);
+               write_log (L"AR2/3: mode(%d) > 3 this shouldn't happen.\n", armode);
        } else
-           write_log ("AR: exit with armode(%d)\n", armode);
+           write_log (L"AR: exit with armode(%d)\n", armode);
 
        set_special (&regs, SPCFLAG_ACTION_REPLAY);
        action_replay_flag = ACTION_REPLAY_HIDE;
     } else if (addr == 6) {
        copytoamiga (regs.vbr + 0x7c, artemp, 4);
-       write_log ("AR: chipmem returned\n");
+       write_log (L"AR: chipmem returned\n");
     }
     return 0;
 }
@@ -686,19 +686,19 @@ static uae_u32 REGPARAM2 arram_lget (uaecptr addr)
     addr &= arram_mask;
     m = (uae_u32 *)(armemory_ram + addr);
     if (strncmp ("T8", (char*)m, 2) == 0)
-       write_log_debug ("Reading T8 from addr %088x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Reading T8 from addr %088x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("LAME", (char*)m, 4) == 0)
-       write_log_debug ("Reading LAME from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Reading LAME from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("RES1", (char*)m, 4) == 0)
-       write_log_debug ("Reading RES1 from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Reading RES1 from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("ARON", (char*)m, 4) == 0)
-       write_log_debug ("Reading ARON from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Reading ARON from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("KILL", (char*)m, 4) == 0)
-       write_log_debug ("Reading KILL from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Reading KILL from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("BRON", (char*)m, 4) == 0)
-       write_log_debug ("Reading BRON from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Reading BRON from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("PRIN", (char*)m, 4) == 0)
-       write_log_debug ("Reading PRIN from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Reading PRIN from addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     return do_get_mem_long (m);
 }
 
@@ -735,19 +735,19 @@ void REGPARAM2 arram_lput (uaecptr addr, uae_u32 l)
     addr &= arram_mask;
     m = (uae_u32 *)(armemory_ram + addr);
     if (strncmp ("T8", (char*)m, 2) == 0)
-       write_log_debug ("Writing T8 to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Writing T8 to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("LAME", (char*)m, 4) == 0)
-       write_log_debug ("Writing LAME to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Writing LAME to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("RES1", (char*)m, 4) == 0)
-       write_log_debug ("Writing RES1 to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Writing RES1 to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("ARON", (char*)m, 4) == 0)
-       write_log_debug ("Writing ARON to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Writing ARON to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("KILL", (char*)m, 4) == 0)
-       write_log_debug ("Writing KILL to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Writing KILL to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("BRON", (char*)m, 4) == 0)
-       write_log_debug ("Writing BRON to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Writing BRON to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     if (strncmp ("PRIN", (char*)m, 4) == 0)
-       write_log_debug ("Writing PRIN to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
+       write_log_debug (L"Writing PRIN to addr %08x PC=%p\n", addr, m68k_getpc (&regs));
     do_put_mem_long (m, l);
 }
 
@@ -869,13 +869,13 @@ static uae_u8 *REGPARAM2 arrom_xlate (uaecptr addr)
 static addrbank arrom_bank = {
     arrom_lget, arrom_wget, arrom_bget,
     arrom_lput, arrom_wput, arrom_bput,
-    arrom_xlate, arrom_check, NULL, "Action Replay ROM",
+    arrom_xlate, arrom_check, NULL, L"Action Replay ROM",
     arrom_lget, arrom_wget, ABFLAG_ROM
 };
 static addrbank arram_bank = {
     arram_lget, arram_wget, arram_bget,
     arram_lput, arram_wput, arram_bput,
-    arram_xlate, arram_check, NULL, "Action Replay RAM",
+    arram_xlate, arram_check, NULL, L"Action Replay RAM",
     arram_lget, arram_wget, ABFLAG_RAM
 };
 
@@ -1025,7 +1025,7 @@ void hrtmon_enter (void)
     if (!hrtmemory)
        return;
     hrtmon_map_banks ();
-    write_log ("%s: freeze\n", cart_memnames[cart_type]);
+    write_log (L"%s: freeze\n", cart_memnames[cart_type]);
     hrtmon_go();
 }
 
@@ -1035,23 +1035,23 @@ void action_replay_enter(void)
        return;
     triggered_once = 1;
     if (armodel == 1) {
-       write_log ("AR1: Enter PC:%p\n", m68k_getpc (&regs));
+       write_log (L"AR1: Enter PC:%p\n", m68k_getpc (&regs));
        action_replay_go1 (7);
        unset_special (&regs, SPCFLAG_ACTION_REPLAY);
        return;
     }
     if (action_replay_flag == ACTION_REPLAY_DORESET) {
-       write_log ("AR2/3: reset\n");
+       write_log (L"AR2/3: reset\n");
        armode = ARMODE_BREAKPOINT_AR3_RESET_AR2;
     } else if (armode == ARMODE_FREEZE) {
-       write_log ("AR2/3: activated (freeze)\n");
+       write_log (L"AR2/3: activated (freeze)\n");
     } else if (armode >= 2) {
        if (armode == ARMODE_BREAKPOINT_AR2)
-           write_log ("AR2: activated (breakpoint)\n");
+           write_log (L"AR2: activated (breakpoint)\n");
        else if (armode == ARMODE_BREAKPOINT_AR3_RESET_AR2)
-           write_log ("AR3: activated (breakpoint)\n");
+           write_log (L"AR3: activated (breakpoint)\n");
        else
-           write_log ("AR2/3: mode(%d) > 3 this shouldn't happen.\n", armode);
+           write_log (L"AR2/3: mode(%d) > 3 this shouldn't happen.\n", armode);
        armode = ARMODE_BREAKPOINT_ACTIVATED;
     }
     action_replay_go();
@@ -1061,8 +1061,8 @@ void check_prefs_changed_carts(int in_memory_reset)
 {
     if (currprefs.cart_internal != changed_prefs.cart_internal)
        currprefs.cart_internal = changed_prefs.cart_internal;
-    if (strcmp (currprefs.cartfile, changed_prefs.cartfile) != 0) {
-       write_log ("Cartridge ROM Prefs changed.\n");
+    if (_tcscmp (currprefs.cartfile, changed_prefs.cartfile) != 0) {
+       write_log (L"Cartridge ROM Prefs changed.\n");
        if (action_replay_unload (in_memory_reset)) {
            memcpy (currprefs.cartfile, changed_prefs.cartfile, sizeof currprefs.cartfile);
            #ifdef ACTION_REPLAY
@@ -1104,8 +1104,8 @@ void action_replay_reset(void)
            action_replay_flag = ACTION_REPLAY_ACTIVE;
            hide_cart (0);
        } else {
-           write_log_debug ("Setting flag to ACTION_REPLAY_WAITRESET\n");
-           write_log_debug ("armode == %d\n", armode);
+           write_log_debug (L"Setting flag to ACTION_REPLAY_WAITRESET\n");
+           write_log_debug (L"armode == %d\n", armode);
            action_replay_flag = ACTION_REPLAY_WAITRESET;
            hide_cart (0);
        }
@@ -1179,7 +1179,7 @@ void hrtmon_hide(void)
     cartridge_exit();
     hrtmon_flag = ACTION_REPLAY_IDLE;
     unset_special (&regs, SPCFLAG_ACTION_REPLAY);
-    //write_log ("HRTMON: Exit\n");
+    //write_log (L"HRTMON: Exit\n");
 }
 
 void hrtmon_breakenter(void)
@@ -1225,7 +1225,7 @@ static void action_replay_patch(void)
     armemory_rom[off2 + 1] = (uae_u8)((off1 + kickmem_start + 2) >> 16);
     armemory_rom[off2 + 2] = (uae_u8)((off1 + kickmem_start + 2) >> 8);
     armemory_rom[off2 + 3] = (uae_u8)((off1 + kickmem_start + 2) >> 0);
-    write_log ("AR ROM patched for KS2.0+\n");
+    write_log (L"AR ROM patched for KS2.0+\n");
 }
 
 /* Returns 0 if the checksum is OK.
@@ -1325,7 +1325,7 @@ static void action_replay_fixup_checksum(uae_u32 new_checksum)
     if (checksum)
        do_put_mem_long (checksum, new_checksum);
     else
-       write_log ("Unable to locate Checksum in ROM.\n");
+       write_log (L"Unable to locate Checksum in ROM.\n");
     return;
 }
 
@@ -1400,7 +1400,7 @@ static void disable_rom_test(void)
            if (do_get_mem_word((uae_u16*)(addr-6)) == 0x6100 && /* bsr.w */
                do_get_mem_word((uae_u16*)(addr-2)) == 0x41fa)  /* lea relative */
            {
-               write_log ("Patching to disable ROM TEST.\n");
+               write_log (L"Patching to disable ROM TEST.\n");
                do_put_mem_word((uae_u16*)(addr-6), 0x4e75); /* rts */
            }
        }
@@ -1412,7 +1412,7 @@ static void disable_rom_test(void)
            if (do_get_mem_word((uae_u16*)(addr-6)) == 0x6100 && /* bsr.w */
                do_get_mem_word((uae_u16*)(addr-2)) == 0x41f9)  /* lea absolute */
            {
-               write_log ("Patching to disable ROM TEST.\n");
+               write_log (L"Patching to disable ROM TEST.\n");
                do_put_mem_word((uae_u16*)(addr-6), 0x4e75); /* rts */
            }
        }
@@ -1430,9 +1430,9 @@ static void action_replay_checksum_info(void)
     if (!armemory_rom)
        return;
     if (action_replay_calculate_checksum() == 0)
-       write_log ("Action Replay Checksum is OK.\n");
+       write_log (L"Action Replay Checksum is OK.\n");
     else
-       write_log ("Action Replay Checksum is INVALID.\n");
+       write_log (L"Action Replay Checksum is INVALID.\n");
     disable_rom_test();
 }
 
@@ -1467,32 +1467,32 @@ static void action_replay_unsetbanks (void)
 /* param to allow us to unload the cart. Currently we know it is safe if we are doing a reset to unload it.*/
 int action_replay_unload (int in_memory_reset)
 {
-    static const char *state[] = {
-       "ACTION_REPLAY_WAIT_PC",
-       "ACTION_REPLAY_INACTIVE",
-       "ACTION_REPLAY_WAITRESET",
-       "0",
-       "ACTION_REPLAY_IDLE",
-       "ACTION_REPLAY_ACTIVATE",
-       "ACTION_REPLAY_ACTIVE",
-       "ACTION_REPLAY_DORESET",
-       "ACTION_REPLAY_HIDE",
+    static const TCHAR *state[] = {
+       L"ACTION_REPLAY_WAIT_PC",
+       L"ACTION_REPLAY_INACTIVE",
+       L"ACTION_REPLAY_WAITRESET",
+       L"0",
+       L"ACTION_REPLAY_IDLE",
+       L"ACTION_REPLAY_ACTIVATE",
+       L"ACTION_REPLAY_ACTIVE",
+       L"ACTION_REPLAY_DORESET",
+       L"ACTION_REPLAY_HIDE",
     };
 
-    write_log_debug("Action Replay State:(%s)\nHrtmon State:(%s)\n", state[action_replay_flag+3],state[hrtmon_flag+3]);
+    write_log_debug (L"Action Replay State:(%s)\nHrtmon State:(%s)\n", state[action_replay_flag+3],state[hrtmon_flag+3]);
 
     if (armemory_rom && armodel == 1) {
        if (is_ar_pc_in_ram() || is_ar_pc_in_rom() || action_replay_flag == ACTION_REPLAY_WAIT_PC) {
-           write_log ("Can't Unload Action Replay 1. It is Active.\n");
+           write_log (L"Can't Unload Action Replay 1. It is Active.\n");
            return 0;
        }
     } else {
        if (action_replay_flag != ACTION_REPLAY_IDLE && action_replay_flag != ACTION_REPLAY_INACTIVE) {
-           write_log ("Can't Unload Action Replay. It is Active.\n");
+           write_log (L"Can't Unload Action Replay. It is Active.\n");
            return 0; /* Don't unload it whilst it's active, or it will crash the amiga if not the emulator */
        }
        if (hrtmon_flag != ACTION_REPLAY_IDLE && hrtmon_flag != ACTION_REPLAY_INACTIVE) {
-           write_log ("Can't Unload Hrtmon. It is Active.\n");
+           write_log (L"Can't Unload Hrtmon. It is Active.\n");
            return 0; /* Don't unload it whilst it's active, or it will crash the amiga if not the emulator */
        }
     }
@@ -1513,7 +1513,7 @@ static int superiv_init (struct romdata *rd, struct zfile *f)
     uae_u32 chip = currprefs.chipmem_size - 0x10000;
     int subtype = rd->id;
     int flags = rd->type;
-    char *memname1, *memname2, *memname3;
+    TCHAR *memname1, *memname2, *memname3;
 
     memname1 = memname2 = memname3 = NULL;
 
@@ -1529,8 +1529,8 @@ static int superiv_init (struct romdata *rd, struct zfile *f)
        hrtmem2_start = 0xf20000;
        hrtmem2_size =  0x10000;
        hrtmem_rom = 1;
-       memname1 = "xpower_e2";
-       memname2 = "xpower_f2";
+       memname1 = L"xpower_e2";
+       memname2 = L"xpower_f2";
     } else if (flags & ROMTYPE_NORDIC) { /* nordic */
        hrtmem_start = 0xf00000;
        hrtmem_size = 0x10000;
@@ -1539,12 +1539,12 @@ static int superiv_init (struct romdata *rd, struct zfile *f)
        hrtmem2_end = 0xf60000;
        hrtmem2_size =  0x10000;
        hrtmem_rom = 1;
-       memname1 = "nordic_f0";
-       memname2 = "nordic_f4";
+       memname1 = L"nordic_f0";
+       memname2 = L"nordic_f4";
        if (subtype == 70) {
            hrtmem_start += 0x60000;
            hrtmem_end += 0x60000;
-           memname1 = "nordic_f6";
+           memname1 = L"nordic_f6";
        }
     } else { /* super4 */
        hrtmem_start = 0xd00000;
@@ -1554,9 +1554,9 @@ static int superiv_init (struct romdata *rd, struct zfile *f)
        hrtmem2_size2 = 0x0c0000;
        hrtmem3_start = 0xe00000;
        hrtmem3_size = 0x80000;
-       memname1 = "superiv_d0";
-       memname2 = "superiv_b0";
-       memname3 = "superiv_e0";
+       memname1 = L"superiv_d0";
+       memname2 = L"superiv_b0";
+       memname3 = L"superiv_e0";
     }
     if (hrtmem2_size && !hrtmem2_size2)
        hrtmem2_size2 = hrtmem2_size;
@@ -1612,7 +1612,7 @@ static int superiv_init (struct romdata *rd, struct zfile *f)
     }
 
     hrtmon_flag = ACTION_REPLAY_IDLE;
-    write_log ("%s installed at %08X\n", cart_memnames[cart_type], hrtmem_start);
+    write_log (L"%s installed at %08X\n", cart_memnames[cart_type], hrtmem_start);
     return 1;
 }
 
@@ -1624,14 +1624,14 @@ int action_replay_load (void)
 
     armodel = 0;
     action_replay_flag = ACTION_REPLAY_INACTIVE;
-    write_log_debug("Entered action_replay_load ()\n");
+    write_log_debug (L"Entered action_replay_load ()\n");
     /* Don't load a rom if one is already loaded. Use action_replay_unload () first. */
     if (armemory_rom || hrtmemory) {
-       write_log ("action_replay_load () ROM already loaded.\n");
+       write_log (L"action_replay_load () ROM already loaded.\n");
        return 0;
     }
 
-    if (strlen(currprefs.cartfile) == 0)
+    if (_tcslen (currprefs.cartfile) == 0)
        return 0;
     rd = getromdatabypath (currprefs.cartfile);
     if (rd) {
@@ -1642,12 +1642,12 @@ int action_replay_load (void)
     }
     f = read_rom_name (currprefs.cartfile);
     if (!f) {
-       write_log ("failed to load '%s' cartridge ROM\n", currprefs.cartfile);
+       write_log (L"failed to load '%s' cartridge ROM\n", currprefs.cartfile);
        return 0;
     }
     rd = getromdatabyzfile(f);
     if (!rd) {
-       write_log ("Unknown cartridge ROM\n");
+       write_log (L"Unknown cartridge ROM\n");
     } else {
        if (rd->type & (ROMTYPE_SUPERIV | ROMTYPE_NORDIC | ROMTYPE_XPOWER)) {
            return superiv_init (rd, f);
@@ -1663,7 +1663,7 @@ int action_replay_load (void)
        return 0;
     }
     if (ar_rom_file_size != 65536 && ar_rom_file_size != 131072 && ar_rom_file_size != 262144) {
-       write_log ("rom size must be 64KB (AR1), 128KB (AR2) or 256KB (AR3)\n");
+       write_log (L"rom size must be 64KB (AR1), 128KB (AR2) or 256KB (AR3)\n");
        zfile_fclose(f);
        return 0;
     }
@@ -1688,7 +1688,7 @@ int action_replay_load (void)
     arram_mask = arram_size - 1;
     arrom_mask = arrom_size - 1;
     armemory_ram = (uae_u8*)xcalloc (arram_size, 1);
-    write_log ("Action Replay %d installed at %08X, size %08X\n", armodel, arrom_start, arrom_size);
+    write_log (L"Action Replay %d installed at %08X, size %08X\n", armodel, arrom_start, arrom_size);
     action_replay_version();
     return armodel;
 }
@@ -1796,11 +1796,11 @@ int hrtmon_load (void)
     }
 
     if (!isinternal) {
-       if (strlen(currprefs.cartfile) == 0)
+       if (_tcslen (currprefs.cartfile) == 0)
            return 0;
        f = read_rom_name (currprefs.cartfile);
        if(!f) {
-           write_log ("failed to load '%s' cartridge ROM\n", currprefs.cartfile);
+           write_log (L"failed to load '%s' cartridge ROM\n", currprefs.cartfile);
            return 0;
        }
        zfile_fread(header, sizeof header, 1, f);
@@ -1819,14 +1819,14 @@ int hrtmon_load (void)
     hrtmem_mask = hrtmem_size - 1;
     if (isinternal) {
        #ifdef ACTION_REPLAY_HRTMON
-       struct zfile *zf = zfile_fopen_data ("hrtrom.gz", hrtrom_len, hrtrom);
+       struct zfile *zf = zfile_fopen_data (L"hrtrom.gz", hrtrom_len, hrtrom);
        f = zfile_gunzip (zf);
        #else
        return 0;
        #endif
        cart_type = CART_HRTMON;
     }
-    hrtmemory = mapped_malloc (hrtmem_size, "hrtmem");
+    hrtmemory = mapped_malloc (hrtmem_size, L"hrtmem");
     memset (hrtmemory, 0xff, 0x80000);
     zfile_fseek (f, 0, SEEK_SET);
     zfile_fread (hrtmemory, 1, 524288, f);
@@ -1845,7 +1845,7 @@ int hrtmon_load (void)
 #endif
     hrtmem_bank.baseaddr = hrtmemory;
     hrtmon_flag = ACTION_REPLAY_IDLE;
-    write_log ("%s installed at %08X\n", cart_memnames[cart_type], hrtmem_start);
+    write_log (L"%s installed at %08X\n", cart_memnames[cart_type], hrtmem_start);
     return 1;
 }
 
@@ -1906,7 +1906,7 @@ static void hrtmon_unmap_banks ()
 #define AR_VER_STR_OFFSET 0x4 /* offset in the rom where the version string begins. */
 #define AR_VER_STR_END 0x7c   /* offset in the rom where the version string ends. */
 #define AR_VER_STR_LEN (AR_VER_STR_END - AR_VER_STR_OFFSET)
-char arVersionString[AR_VER_STR_LEN+1];
+static uae_char arVersionString[AR_VER_STR_LEN+1];
 
 /* This function extracts the version info for AR2 and AR3. */
 
@@ -1916,7 +1916,7 @@ void action_replay_version(void)
     int iArVersionMajor = -1 ;
     int iArVersionMinor = -1;
     char* pNext;
-    char sArDate[11];
+    uae_char sArDate[11];
     *sArDate = '\0';
 
     if (!armemory_rom)
@@ -1960,7 +1960,7 @@ void action_replay_version(void)
     }
 
     if (iArVersionMajor > 0) {
-       write_log ("Version of cart is '%d.%.02d', date is '%s'\n", iArVersionMajor, iArVersionMinor, sArDate);
+       write_log (L"Version of cart is '%d.%.02d', date is '%s'\n", iArVersionMajor, iArVersionMinor, sArDate);
     }
 }
 
@@ -2001,8 +2001,7 @@ uae_u8 *save_hrtmon (int *len, uae_u8 *dstptr)
     save_u8 (cart_type);
     save_u8 (0);
     save_u32 (0);
-    strcpy (dst, currprefs.cartfile);
-    dst += strlen (dst) + 1;
+    save_string (currprefs.cartfile);
     save_u32 (0);
     if (!hrtmem_rom) {
        save_u32 (hrtmem_size);
@@ -2031,14 +2030,16 @@ uae_u8 *save_hrtmon (int *len, uae_u8 *dstptr)
 uae_u8 *restore_hrtmon (uae_u8 *src)
 {
     uae_u32 size;
+    TCHAR *s;
 
     action_replay_unload (1);
     restore_u8 ();
     restore_u8 ();
     restore_u32 ();
-    strncpy (changed_prefs.cartfile, src, 255);
-    strcpy (currprefs.cartfile, changed_prefs.cartfile);
-    src += strlen (src) + 1;
+    s = restore_string ();
+    _tcsncpy (changed_prefs.cartfile, s, 255);
+    xfree (s);
+    _tcscpy (currprefs.cartfile, changed_prefs.cartfile);
     hrtmon_load ();
     action_replay_load ();
     if (restore_u32 () != 0)
@@ -2077,8 +2078,7 @@ uae_u8 *save_action_replay (int *len, uae_u8 *dstptr)
     save_u8 (0);
     save_u8 (armodel);
     save_u32 (get_crc32 (armemory_rom + 4, arrom_size - 4));
-    strcpy (dst, currprefs.cartfile);
-    dst += strlen (dst) + 1;
+    save_string (currprefs.cartfile);
     save_u32 (arrom_size);
     save_u32 (arram_size);
     memcpy (dst, armemory_ram, arram_size);
@@ -2099,6 +2099,7 @@ uae_u8 *save_action_replay (int *len, uae_u8 *dstptr)
 uae_u8 *restore_action_replay (uae_u8 *src)
 {
     uae_u32 crc32;
+    TCHAR *s;
 
     action_replay_unload (1);
     restore_u8 ();
@@ -2106,9 +2107,10 @@ uae_u8 *restore_action_replay (uae_u8 *src)
     if (!armodel)
        return src;
     crc32 = restore_u32 ();
-    strncpy (changed_prefs.cartfile, src, 255);
-    strcpy (currprefs.cartfile, changed_prefs.cartfile);
-    src += strlen (src) + 1;
+    s = restore_string ();
+    _tcsncpy (changed_prefs.cartfile, s, 255);
+    _tcscpy (currprefs.cartfile, changed_prefs.cartfile);
+    xfree (s);
     action_replay_load ();
     if (restore_u32 () != arrom_size)
        return src;
@@ -2130,9 +2132,9 @@ uae_u8 *restore_action_replay (uae_u8 *src)
 
 #define NPSIZE 65536
 
-static unsigned char bswap (unsigned char v,int b7,int b6,int b5,int b4,int b3,int b2,int b1,int b0)
+static uae_u8 bswap (uae_u8 v,int b7,int b6,int b5,int b4,int b3,int b2,int b1,int b0)
 {
-    unsigned char b = 0;
+    uae_u8 b = 0;
 
     b |= ((v >> b7) & 1) << 7;
     b |= ((v >> b6) & 1) << 6;
@@ -2145,9 +2147,9 @@ static unsigned char bswap (unsigned char v,int b7,int b6,int b5,int b4,int b3,i
     return b;
 }
 
-static unsigned short wswap (unsigned short v,int b15,int b14,int b13,int b12, int b11, int b10, int b9, int b8, int b7,int b6,int b5,int b4,int b3,int b2,int b1,int b0)
+static uae_u16 wswap (uae_u16 v,int b15,int b14,int b13,int b12, int b11, int b10, int b9, int b8, int b7,int b6,int b5,int b4,int b3,int b2,int b1,int b0)
 {
-    unsigned short b = 0;
+    uae_u16 b = 0;
 
     b |= ((v >> b15) & 1) << 15;
     b |= ((v >> b14) & 1) << 14;
@@ -2171,41 +2173,41 @@ static unsigned short wswap (unsigned short v,int b15,int b14,int b13,int b12, i
 #define AXOR 0x817f
 
 // middle (even)
-static void descramble1(unsigned char *buf, int size)
+static void descramble1 (uae_u8 *buf, int size)
 {
     int i;
 
     for (i = 0; i < size; i++)
-       buf[i] = bswap(buf[i], 4, 1, 5, 3, 0, 7, 6, 2);
+       buf[i] = bswap (buf[i], 4, 1, 5, 3, 0, 7, 6, 2);
 }
-static void descramble1a(unsigned char *buf, int size)
+static void descramble1a (uae_u8 *buf, int size)
 {
     int i;
-    unsigned char tbuf[NPSIZE];
+    uae_u8 tbuf[NPSIZE];
 
-    memcpy(tbuf, buf, size);
+    memcpy (tbuf, buf, size);
     for (i = 0; i < size; i++) {
        int a = (i ^ AXOR) & (size - 1);
-       buf[i] = tbuf[wswap(a, 15, 9, 10, 4, 6, 5, 3, 8, 14, 13, 0, 12, 11, 2, 1, 7)];
+       buf[i] = tbuf[wswap (a, 15, 9, 10, 4, 6, 5, 3, 8, 14, 13, 0, 12, 11, 2, 1, 7)];
     }
 }
 // corner (odd)
-static void descramble2(unsigned char *buf, int size)
+static void descramble2 (uae_u8 *buf, int size)
 {
     int i;
 
     for (i = 0; i < size; i++)
-       buf[i] = bswap(buf[i], 5, 4, 3, 2, 1, 0, 7, 6);
+       buf[i] = bswap (buf[i], 5, 4, 3, 2, 1, 0, 7, 6);
 }
-static void descramble2a(unsigned char *buf, int size)
+static void descramble2a (uae_u8 *buf, int size)
 {
     int i;
-    unsigned char tbuf[NPSIZE];
+    uae_u8 tbuf[NPSIZE];
 
-    memcpy(tbuf, buf, size);
+    memcpy (tbuf, buf, size);
     for (i = 0; i < size; i++) {
        int a = (i ^ AXOR) & (size - 1);
-       buf[i] = tbuf[wswap(a, 15, 2, 4, 0, 1, 10, 11, 8, 13, 14, 12, 9, 7, 5, 6, 3)];
+       buf[i] = tbuf[wswap (a, 15, 2, 4, 0, 1, 10, 11, 8, 13, 14, 12, 9, 7, 5, 6, 3)];
     }
 }
 void descramble_nordicpro (uae_u8 *buf, int size, int odd)
index 23d17e3347c64a8e9728c247312736f157bc03d1..c359e8ab46d7b554087c35597280edf164015f40 100644 (file)
--- a/arcadia.c
+++ b/arcadia.c
@@ -47,23 +47,23 @@ struct arcadiarom *arcadia_bios, *arcadia_game;
 
 static struct arcadiarom roms[]        = {
 
-    { 49, "ar_bios.zip", "scpa21",         ARCADIA_BIOS, 0, 6, 1, 0, 2, 3, 4, 5, 7 },
-    { 50, "ar_bios.zip", "gcp-",           ARCADIA_BIOS, 3, 7, 6, 5, 4, 3, 2, 1, 0 },
-    { 51, "ar_bios.zip", "scpav3_0.",      ARCADIA_BIOS, 0, 6, 1, 0, 2, 3, 4, 5, 7 },
-
-    { 33, "ar_airh.zip", "airh_",          ARCADIA_GAME, 1, 5, 0, 2, 4, 7, 6, 1, 3 },
-    { 34, "ar_bowl.zip", "bowl_",          ARCADIA_GAME, 1, 7, 6, 0, 1, 2, 3, 4, 5 },
-    { 35, "ar_dart.zip", "dart_",          ARCADIA_GAME, 1, 4, 0, 7, 6, 3, 1, 2, 5 },
-    { 36, "ar_fast.zip", "fastv28.",       ARCADIA_GAME, 0, 7, 6, 5, 4, 3, 2, 1, 0 },
-    { 37, "ar_ldrb.zip", "lbg240",         ARCADIA_GAME, 0, 7, 6, 5, 4, 3, 2, 1, 0 },
-    { 38, "ar_ldrba.zip","ldrb_",          ARCADIA_GAME, 1, 2, 3, 4, 1, 0, 7, 5, 6 },
-    { 39, "ar_ninj.zip", "ninj_",          ARCADIA_GAME, 1, 1, 6, 5, 7, 4, 2, 0, 3 },
-    { 40, "ar_rdwr.zip", "rdwr_",          ARCADIA_GAME, 1, 3, 1, 6, 4, 0, 5, 2, 7 },
-    { 41, "ar_sdwr.zip", "sdwr_",          ARCADIA_GAME, 1, 6, 3, 4, 5, 2, 1, 0, 7 },
-    { 42, "ar_spot.zip", "spotv2.",        ARCADIA_GAME, 0, 7, 6, 5, 4, 3, 2, 1, 0 },
-    { 43, "ar_sprg.zip", "sprg_",          ARCADIA_GAME, 1, 4, 7, 3, 0, 6, 5, 2, 1 },
-    { 44, "ar_xeon.zip", "xeon_",          ARCADIA_GAME, 1, 3, 1, 2, 4, 0, 5, 6, 7 },
-    { 45, "ar_socc.zip", "socc30.",        ARCADIA_GAME, 2, 0, 7, 1, 6, 5, 4, 3, 2 },
+    { 49, L"ar_bios.zip", L"scpa21",       ARCADIA_BIOS, 0, 6, 1, 0, 2, 3, 4, 5, 7 },
+    { 50, L"ar_bios.zip", L"gcp-",         ARCADIA_BIOS, 3, 7, 6, 5, 4, 3, 2, 1, 0 },
+    { 51, L"ar_bios.zip", L"scpav3_0.",            ARCADIA_BIOS, 0, 6, 1, 0, 2, 3, 4, 5, 7 },
+
+    { 33, L"ar_airh.zip", L"airh_",        ARCADIA_GAME, 1, 5, 0, 2, 4, 7, 6, 1, 3 },
+    { 34, L"ar_bowl.zip", L"bowl_",        ARCADIA_GAME, 1, 7, 6, 0, 1, 2, 3, 4, 5 },
+    { 35, L"ar_dart.zip", L"dart_",        ARCADIA_GAME, 1, 4, 0, 7, 6, 3, 1, 2, 5 },
+    { 36, L"ar_fast.zip", L"fastv28.",     ARCADIA_GAME, 0, 7, 6, 5, 4, 3, 2, 1, 0 },
+    { 37, L"ar_ldrb.zip", L"lbg240",       ARCADIA_GAME, 0, 7, 6, 5, 4, 3, 2, 1, 0 },
+    { 38, L"ar_ldrba.zip",L"ldrb_",        ARCADIA_GAME, 1, 2, 3, 4, 1, 0, 7, 5, 6 },
+    { 39, L"ar_ninj.zip", L"ninj_",        ARCADIA_GAME, 1, 1, 6, 5, 7, 4, 2, 0, 3 },
+    { 40, L"ar_rdwr.zip", L"rdwr_",        ARCADIA_GAME, 1, 3, 1, 6, 4, 0, 5, 2, 7 },
+    { 41, L"ar_sdwr.zip", L"sdwr_",        ARCADIA_GAME, 1, 6, 3, 4, 5, 2, 1, 0, 7 },
+    { 42, L"ar_spot.zip", L"spotv2.",      ARCADIA_GAME, 0, 7, 6, 5, 4, 3, 2, 1, 0 },
+    { 43, L"ar_sprg.zip", L"sprg_",        ARCADIA_GAME, 1, 4, 7, 3, 0, 6, 5, 2, 1 },
+    { 44, L"ar_xeon.zip", L"xeon_",        ARCADIA_GAME, 1, 3, 1, 2, 4, 0, 5, 6, 7 },
+    { 45, L"ar_socc.zip", L"socc30.",      ARCADIA_GAME, 2, 0, 7, 1, 6, 5, 4, 3, 2 },
 
     { -1 }
 };
@@ -85,24 +85,24 @@ static int boot_read;
 
 static int nvwrite;
 
-static int load_rom8 (char *xpath, uae_u8 *mem,        int extra)
+static int load_rom8 (TCHAR *xpath, uae_u8 *mem,       int extra)
 {
     struct zfile *zf;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
     int i;
-    uae_u8 *tmp = (uae_u8*)xmalloc (131072);
-    char *bin = extra == 1 ? ".bin" : "";
+    uae_u8 *tmp = xmalloc (131072);
+    TCHAR *bin = extra == 1 ? L".bin" : L"";
 
     memset (tmp, 0, 131072);
-    sprintf (path, "%s%s%s", xpath, extra == 3 ? "-hi" : (extra == 2 ? "hi" : "h"), bin);
-    zf = zfile_fopen (path, "rb");
+    _stprintf (path, L"%s%s%s", xpath, extra == 3 ? L"-hi" : (extra == 2 ? L"hi" : L"h"), bin);
+    zf = zfile_fopen (path, L"rb");
     if (!zf)
        goto end;
     if (zfile_fread (tmp, 65536, 1, zf) == 0)
        goto end;
     zfile_fclose (zf);
-    sprintf (path, "%s%s%s", xpath, extra == 3 ? "-lo" : (extra == 2 ? "lo" : "l"), bin);
-    zf = zfile_fopen (path, "rb");
+    _stprintf (path, L"%s%s%s", xpath, extra == 3 ? L"-lo" : (extra == 2 ? L"lo" : L"l"), bin);
+    zf = zfile_fopen (path, L"rb");
     if (!zf)
        goto end;
     if (zfile_fread (tmp + 65536, 65536, 1, zf) == 0)
@@ -119,15 +119,15 @@ static int load_rom8 (char *xpath, uae_u8 *mem,   int extra)
     return 0;
 }
 
-static struct arcadiarom *is_arcadia (char *xpath, int cnt)
+static struct arcadiarom *is_arcadia (const TCHAR *xpath, int cnt)
 {
-    char path[MAX_DPATH], *p;
+    TCHAR path[MAX_DPATH], *p;
     struct arcadiarom *rom = NULL;
     int i;
 
-    strcpy (path, xpath);
+    _tcscpy (path, xpath);
     p = path;
-    for (i = strlen (xpath) - 1; i > 0; i--) {
+    for (i = _tcslen (xpath) - 1; i > 0; i--) {
        if (path[i] == '\\' || path[i] == '/') {
            path[i++] = 0;
            p = path + i;
@@ -135,7 +135,7 @@ static struct arcadiarom *is_arcadia (char *xpath, int cnt)
        }
     }
     for (i = 0; roms[i].romid > 0; i++) {
-       if (!strcmpi (p, roms[i].name) || !strcmpi (p, roms[i].rom)) {
+       if (!_tcsicmp (p, roms[i].name) || !_tcsicmp (p, roms[i].rom)) {
            if (cnt > 0) {
                cnt--;
                continue;
@@ -151,17 +151,17 @@ static struct arcadiarom *is_arcadia (char *xpath, int cnt)
 
 static int load_roms (struct arcadiarom *rom)
 {
-    char path[MAX_DPATH], path2[MAX_DPATH], path3[MAX_DPATH], *p;
+    TCHAR path[MAX_DPATH], path2[MAX_DPATH], path3[MAX_DPATH], *p;
     int i, offset;
-    char *xpath;
+    TCHAR *xpath;
 
     if (rom->type == ARCADIA_BIOS)
        xpath = currprefs.romextfile;
     else
        xpath = currprefs.cartfile;
 
-    strcpy (path3, xpath);
-    p = path3 + strlen (path3) - 1;
+    _tcscpy (path3, xpath);
+    p = path3 + _tcslen (path3) - 1;
     while (p > path3) {
        if (p[0] == '\\' || p[0] == '/') {
            *p = 0;
@@ -171,24 +171,24 @@ static int load_roms (struct arcadiarom *rom)
     }
     if (p == path3)
        *p = 0;
-    strcpy (path2, xpath);
+    _tcscpy (path2, xpath);
 
     offset = 0;
     if (rom->type == ARCADIA_BIOS)
        offset = bios_offset;
     i = 0;
     for (;;) {
-       sprintf (path, "%s%d", xpath, i + 1);
+       _stprintf (path, L"%s%d", xpath, i + 1);
        if (!load_rom8 (path, arbmemory + 2 * 65536 * i + offset, rom->extra)) {
            if (i == 0)
-               write_log ("Arcadia: %s rom load failed ('%s')\n", rom->type == ARCADIA_BIOS ? "bios" : "game", path);
+               write_log (L"Arcadia: %s rom load failed ('%s')\n", rom->type == ARCADIA_BIOS ? "bios" : "game", path);
            break;
        }
        i++;
     }
     if (i == 0)
        return 0;
-    write_log ("Arcadia: %s rom %s loaded\n", rom->type == ARCADIA_BIOS ? "bios" : "game", xpath);
+    write_log (L"Arcadia: %s rom %s loaded\n", rom->type == ARCADIA_BIOS ? "bios" : "game", xpath);
     return 1;
 }
 
@@ -263,7 +263,7 @@ static void REGPARAM2 arbb_bput (uaecptr addr, uae_u32 b)
 static addrbank arcadia_boot_bank = {
     arbb_lget, arbb_wget, arbb_bget,
     arbb_lput, arbb_wput, arbb_bput,
-    default_xlate, default_check, NULL, "Arcadia BIOS",
+    default_xlate, default_check, NULL, L"Arcadia BIOS",
     arbb_lget, arbb_wget, ABFLAG_ROM
 };
 
@@ -330,7 +330,7 @@ static void REGPARAM2 arb_bput (uaecptr addr, uae_u32 b)
 static addrbank arcadia_rom_bank = {
     arb_lget, arb_wget, arb_bget,
     arb_lput, arb_wput, arb_bput,
-    default_xlate, default_check, NULL, "Arcadia Game ROM",
+    default_xlate, default_check, NULL, L"Arcadia Game ROM",
     arb_lget, arb_wget, ABFLAG_ROM
 };
 
@@ -345,7 +345,7 @@ static void multigame(int v)
            allocated_arbmemory >> 16, 0);
 }
 
-int is_arcadia_rom (char *path)
+int is_arcadia_rom (const TCHAR *path)
 {
     struct arcadiarom *rom;
 
@@ -362,9 +362,9 @@ int is_arcadia_rom (char *path)
 
 static void nvram_write (void)
 {
-    struct zfile *f = zfile_fopen (currprefs.flashfile, "rb+");
+    struct zfile *f = zfile_fopen (currprefs.flashfile, L"rb+");
     if (!f) {
-       f = zfile_fopen (currprefs.flashfile, "wb");
+       f = zfile_fopen (currprefs.flashfile, L"wb");
        if (!f)
            return;
     }
@@ -376,7 +376,7 @@ static void nvram_read (void)
 {
     struct zfile *f;
 
-    f = zfile_fopen (currprefs.flashfile, "rb");
+    f = zfile_fopen (currprefs.flashfile, L"rb");
     memset (arbmemory + nvram_offset, 0, NVRAM_SIZE);
     if (!f)
        return;
@@ -448,25 +448,25 @@ uae_u8 arcadia_parport (int port, uae_u8 pra, uae_u8 dra)
     return v;
 }
 
-struct romdata *scan_arcadia_rom (char *path, int cnt)
+struct romdata *scan_arcadia_rom (TCHAR *path, int cnt)
 {
     struct romdata *rd = 0;
     struct romlist **arc_rl;
     struct arcadiarom *arcadia_rom;
     int i;
 
-    arcadia_rom = is_arcadia(path, cnt);
+    arcadia_rom = is_arcadia (path, cnt);
     if (arcadia_rom) {
        arc_rl = getarcadiaroms();
        for (i = 0; arc_rl[i]; i++) {
            if (arc_rl[i]->rd->id == arcadia_rom->romid) {
                rd = arc_rl[i]->rd;
-               strcat(path, "/");
-               strcat(path, arcadia_rom->rom);
+               _tcscat (path, L"/");
+               _tcscat (path, arcadia_rom->rom);
                break;
            }
        }
-       xfree(arc_rl);
+       xfree (arc_rl);
     }
     return rd;
 }
index f8e7d1113e832bdef1e2df3dcb7ac6d30b251e4d..c2f4ef757e7e66f55f9e12de16e84463b880b743 100644 (file)
@@ -48,7 +48,7 @@ UCHAR *text;
 
 static void log_error(int track)
 {
-    write_log ("DMS: Ignored error on track %d!\n", track);
+    write_log (L"DMS: Ignored error on track %d!\n", track);
 }
 
 USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT opt, USHORT PCRC, USHORT pwd){
@@ -118,18 +118,18 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
        if ( (cmd == CMD_VIEW) || (cmd == CMD_VIEWFULL) ) {
 
                pv = (USHORT)(c_version/100);
-               write_log (" Created with DMS version %d.%02d ",pv,c_version-pv*100);
+               write_log (L" Created with DMS version %d.%02d ",pv,c_version-pv*100);
                if (geninfo & 0x80)
-                       write_log ("Registered\n");
+                       write_log (L"Registered\n");
                else
-                       write_log ("Evaluation\n");
+                       write_log (L"Evaluation\n");
 
-               write_log (" Creation date : %s",ctime(&date));
-               write_log (" Lowest track in archive : %d\n",from);
-               write_log (" Highest track in archive : %d\n",to);
-               write_log (" Packed data size : %lu\n",pkfsize);
-               write_log (" Unpacked data size : %lu\n",unpkfsize);
-               write_log (" Disk type of archive : ");
+               write_log (L" Creation date : %s",ctime(&date));
+               write_log (L" Lowest track in archive : %d\n",from);
+               write_log (L" Highest track in archive : %d\n",to);
+               write_log (L" Packed data size : %lu\n",pkfsize);
+               write_log (L" Unpacked data size : %lu\n",unpkfsize);
+               write_log (L" Disk type of archive : ");
 
                /*  The original DMS from SDS software (DMS up to 1.11) used other values    */
                /*  in disk type to indicate formats as MS-DOS, AMax and Mac, but it was     */
@@ -140,49 +140,49 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
                        case 0:
                        case 1:
                                /* Can also be a non-dos disk */
-                               write_log ("AmigaOS 1.0 OFS\n");
+                               write_log (L"AmigaOS 1.0 OFS\n");
                                break;
                        case 2:
-                               write_log ("AmigaOS 2.0 FFS\n");
+                               write_log (L"AmigaOS 2.0 FFS\n");
                                break;
                        case 3:
-                               write_log ("AmigaOS 3.0 OFS / International\n");
+                               write_log (L"AmigaOS 3.0 OFS / International\n");
                                break;
                        case 4:
-                               write_log ("AmigaOS 3.0 FFS / International\n");
+                               write_log (L"AmigaOS 3.0 FFS / International\n");
                                break;
                        case 5:
-                               write_log ("AmigaOS 3.0 OFS / Dir Cache\n");
+                               write_log (L"AmigaOS 3.0 OFS / Dir Cache\n");
                                break;
                        case 6:
-                               write_log ("AmigaOS 3.0 FFS / Dir Cache\n");
+                               write_log (L"AmigaOS 3.0 FFS / Dir Cache\n");
                                break;
                        case 7:
-                               write_log ("FMS Amiga System File\n");
+                               write_log (L"FMS Amiga System File\n");
                                break;
                        default:
-                               write_log ("Unknown\n");
+                               write_log (L"Unknown\n");
                }
 
-               write_log (" Compression mode used : ");
+               write_log (L" Compression mode used : ");
                if (cmode>6)
-                       write_log ("Unknown !\n");
+                       write_log (L"Unknown !\n");
                else
-                       write_log ("%s\n",modes[cmode]);
-
-               write_log (" General info : ");
-               if ((geninfo==0)||(geninfo==0x80)) write_log ("None");
-               if (geninfo & 1) write_log ("NoZero ");
-               if (geninfo & 2) write_log ("Encrypted ");
-               if (geninfo & 4) write_log ("Appends ");
-               if (geninfo & 8) write_log ("Banner ");
-               if (geninfo & 16) write_log ("HD ");
-               if (geninfo & 32) write_log ("MS-DOS ");
-               if (geninfo & 64) write_log ("DMS_DEV_Fixed ");
-               if (geninfo & 256) write_log ("FILEID.DIZ");
-               write_log ("\n");
-
-               write_log (" Info Header CRC : %04X\n\n",hcrc);
+                       write_log (L"%s\n",modes[cmode]);
+
+               write_log (L" General info : ");
+               if ((geninfo==0)||(geninfo==0x80)) write_log (L"None");
+               if (geninfo & 1) write_log (L"NoZero ");
+               if (geninfo & 2) write_log (L"Encrypted ");
+               if (geninfo & 4) write_log (L"Appends ");
+               if (geninfo & 8) write_log (L"Banner ");
+               if (geninfo & 16) write_log (L"HD ");
+               if (geninfo & 32) write_log (L"MS-DOS ");
+               if (geninfo & 64) write_log (L"DMS_DEV_Fixed ");
+               if (geninfo & 256) write_log (L"FILEID.DIZ");
+               write_log (L"\n");
+
+               write_log (L" Info Header CRC : %04X\n\n",hcrc);
 
        }
 
@@ -196,8 +196,8 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
 
 
        if (cmd == CMD_VIEWFULL)        {
-               write_log (" Track   Plength  Ulength  Cmode   USUM  HCRC  DCRC Cflag\n");
-               write_log (" ------  -------  -------  ------  ----  ----  ---- -----\n");
+               write_log (L" Track   Plength  Ulength  Cmode   USUM  HCRC  DCRC Cflag\n");
+               write_log (L" ------  -------  -------  ------  ----  ----  ---- -----\n");
        }
 
 //     if (((cmd==CMD_UNPACK) || (cmd==CMD_SHOWBANNER)) && (geninfo & 2) && (!pwd))
@@ -215,7 +215,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
                }
        }
 
-       if ((cmd == CMD_VIEWFULL) || (cmd == CMD_SHOWDIZ) || (cmd == CMD_SHOWBANNER)) write_log ("\n");
+       if ((cmd == CMD_VIEWFULL) || (cmd == CMD_SHOWDIZ) || (cmd == CMD_SHOWBANNER)) write_log (L"\n");
 
        if (ret == DMS_FILE_END) ret = NO_PROBLEM;
 
@@ -270,15 +270,15 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR
 
        if (cmd == CMD_VIEWFULL) {
                if (number==80)
-                       write_log (" FileID   ");
+                       write_log (L" FileID   ");
                else if (number==0xffff)
-                       write_log (" Banner   ");
+                       write_log (L" Banner   ");
                else if ((number==0) && (unpklen==1024))
-                       write_log (" FakeBB   ");
+                       write_log (L" FakeBB   ");
                else
-                       write_log ("   %2d     ",(short)number);
+                       write_log (L"   %2d     ",(short)number);
 
-           write_log ("%5d    %5d   %s  %04X  %04X  %04X    %0d\n", pklen1, unpklen, modes[cmode], usum, hcrc, dcrc, flags);
+           write_log (L"%5d    %5d   %s  %04X  %04X  %04X    %0d\n", pklen1, unpklen, modes[cmode], usum, hcrc, dcrc, flags);
        }
 
        if ((pklen1 > TRACK_BUFFER_LEN) || (pklen2 >TRACK_BUFFER_LEN) || (unpklen > TRACK_BUFFER_LEN)) return ERR_BIGTRACK;
@@ -420,7 +420,7 @@ static USHORT Unpack_Track(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen,
            if (usum1 == Calc_CheckSum(b2,(ULONG)unpklen)) {
                passfound = maybeencrypted;
                if (passfound)
-                   write_log ("DMS: decryption key = 0x%04X\n", prevpass);
+                   write_log (L"DMS: decryption key = 0x%04X\n", prevpass);
                err = NO_PROBLEM;
                pass = prevpass;
                break;
@@ -454,7 +454,7 @@ static void printbandiz(UCHAR *m, USHORT len){
        while (i<m+len) {
                if (*i == 10) {
                        *i=0;
-                       write_log ("%s\n",j);
+                       write_log (L"%s\n",j);
                        j=i+1;
                }
                i++;
index da1ec994a11df2dbbd6d9e1c7f59e0d81525eb7f..dbe72861494641a391e4e1ab0abb2b59903977d8 100644 (file)
@@ -418,19 +418,19 @@ get_header(fp, hdr)
 
        if (zfile_fread(data + I_HEADER_CHECKSUM,
                  sizeof(char), header_size - 1, fp) < header_size - 1) {
-               fatal_error("Invalid header (LHarc file ?)");
+               fatal_error(L"Invalid header (LHarc file ?)");
                return FALSE;   /* finish */
        }
        setup_get(data + I_HEADER_LEVEL);
        hdr->header_level = get_byte ();
        if (hdr->header_level != 2 &&
            zfile_fread(data + header_size, sizeof(char), 2, fp) < 2) {
-               fatal_error("Invalid header (LHarc file ?)");
+               fatal_error(L"Invalid header (LHarc file ?)");
                return FALSE;   /* finish */
        }
 
        if (hdr->header_level >= 3) {
-               fatal_error("Unknown level header");
+               fatal_error(L"Unknown level header");
                return FALSE;
        }
 
@@ -451,7 +451,7 @@ get_header(fp, hdr)
 
        if ((hdr->header_level = get_byte ()) != 2) {
                if (calc_sum(data + I_METHOD, header_size) != checksum)
-                       warning("Checksum error (LHarc file?)", "");
+                       warning(L"Checksum error (LHarc file?)", L"");
                name_length = get_byte ();
                for (i = 0; i < name_length; i++)
                        hdr->name[i] = (char) get_byte ();
@@ -474,7 +474,7 @@ get_header(fp, hdr)
                                hdr->extend_type = EXTEND_GENERIC;
                                hdr->has_crc = FALSE;
                        } else {
-                               fatal_error("Unkonwn header (lha file?)");
+                               fatal_error(L"Unkonwn header (lha file?)");
                                return FALSE;
                        }
                } else {
@@ -524,7 +524,7 @@ get_header(fp, hdr)
                        if (hdr->header_level != 2 &&
                        ((data + LZHEADER_STRAGE - get_ptr < header_size) ||
                         zfile_fread(get_ptr, sizeof(char), header_size, fp) < header_size)) {
-                               fatal_error("Invalid header (LHa file ?)");
+                               fatal_error(L"Invalid header (LHa file ?)");
                                return FALSE;
                        }
                        switch (get_byte ()) {
index 95e53d4784abba147f5448225de8a5d1f3857deb..00bf544fb3e3849006ed035cc8748400bbc5618a 100644 (file)
@@ -42,7 +42,7 @@ lha_make_table(nchar, bitlen, tablebits, table)
                total += weight[i] * count[i];
        }
        if ((total & 0xffff) != 0)
-               error("make_table()", "Bad table (5)\n");
+               error(L"make_table()", L"Bad table (5)\n");
 
        /* shift data for make table. */
        m = 16 - tablebits;
index 9d01e458fb80d577d74970b9b2cc2b8886c81601..6c23f0e421f2b69eb89200a6f0ddf24ee8c24e85 100644 (file)
@@ -166,7 +166,7 @@ xrealloc(old, size)
 {
        char           *p = (char *) realloc(old, size);
        if (!p)
-               fatal_error("Not enough memory");
+               fatal_error(L"Not enough memory");
        return p;
 }
 
index af9497e3c941751e77658aec81fedfe30703d630..3299733734b2089215b7f871714072021540db21 100644 (file)
@@ -37,12 +37,12 @@ struct zvolume *archive_directory_lha(struct zfile *zf)
                method = i;
        }
        memset(&zai, 0, sizeof zai);
-       zai.name = hdr.name;
+       zai.name = au (hdr.name);
        zai.size = hdr.original_size;
        zai.flags = hdr.attribute;
        zai.t = hdr.unix_last_modified_stamp -= _timezone;
        if (hdr.name[strlen(hdr.name) + 1] != 0)
-           zai.comment = &hdr.name[strlen(hdr.name) + 1];
+           zai.comment = au (&hdr.name[strlen(hdr.name) + 1]);
        if (method == LZHDIRS_METHOD_NUM) {
            zvolume_adddir_abs(zv, &zai);
        } else {
@@ -51,6 +51,8 @@ struct zvolume *archive_directory_lha(struct zfile *zf)
            zn->packedsize = hdr.packed_size;
            zn->method = method;
        }
+       xfree (zai.name);
+       xfree (zai.comment);
        zfile_fseek(zf, hdr.packed_size, SEEK_CUR);
 
     }
index a55b4c10af5b79297658c363f0223a9f7b33b130..a4e6086d6cc7c0694e64e908404bdb4de315452f 100644 (file)
@@ -667,7 +667,7 @@ struct zfile *archive_access_lzx (struct znode *zn)
                unpsize -= decrunch_length;
                crc_calc (pdest, decrunch_length);
            } else {
-               write_log ("LZX corrupt compressed data %s\n", zn->name);
+               write_log (L"LZX corrupt compressed data %s\n", zn->name);
                goto end;
            }
        }
@@ -768,9 +768,9 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file)
          second = temp & 63;
 
          memset(&zai, 0, sizeof zai);
-         zai.name = header_filename;
+         zai.name = au (header_filename);
          if (header_comment[0])
-          zai.comment = header_comment;
+          zai.comment = au (header_comment);
          zai.flags |= (attributes & 32) ? 0x80 : 0;
          zai.flags |= (attributes & 64) ? 0x40 : 0;
          zai.flags |= (attributes & 128) ? 0x20 : 0;
@@ -791,6 +791,8 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file)
          zai.size = unpack_size;
          zn = zvolume_addfile_abs(zv, &zai);
          zn->offset2 = merge_size;
+         xfree (zai.name);
+         xfree (zai.comment);
 
          total_pack += pack_size;
          total_unpack += unpack_size;
@@ -810,7 +812,7 @@ struct zvolume *archive_directory_lzx (struct zfile *in_file)
          else
           abort = 0; /* continue */
 
-         //write_log ("unp=%6d mrg=%6d pack=%6d off=%6d %s\n", unpack_size, merge_size, pack_size, zn->offset, zai.name);
+         //write_log (L"unp=%6d mrg=%6d pack=%6d off=%6d %s\n", unpack_size, merge_size, pack_size, zn->offset, zai.name);
 
 
         }
index 2c593a2d6df0810b6b65fc7fc89fcf07941c7cb6..4408a335a2f2116799736669367e860512b86387 100644 (file)
@@ -403,8 +403,8 @@ struct zfile *unwarp(struct zfile *zf)
        if (!iswrp (buf))
            break;
        if (!nf) {
-           nf = zfile_fopen_empty ("zipped.wrp", 1760 * 512);
-           tmpf = zfile_fopen_empty ("tmp", outsize2);
+           nf = zfile_fopen_empty (L"zipped.wrp", 1760 * 512);
+           tmpf = zfile_fopen_empty (L"tmp", outsize2);
        }
        track = (buf[10] << 8) | buf[11];
         algo = buf[19];
@@ -447,19 +447,19 @@ struct zfile *unwarp(struct zfile *zf)
            }
            break;
            default:
-               write_log ("WRP unknown compression method %d, track=%d,size=%d\n", algo, track, side);
+               write_log (L"WRP unknown compression method %d, track=%d,size=%d\n", algo, track, side);
                goto end;
            break;
        }
        if (err) {
-           write_log ("WRP corrupt data, track=%d,side=%d,err=%d\n", track, side, err);
+           write_log (L"WRP corrupt data, track=%d,side=%d,err=%d\n", track, side, err);
        } else {
            uae_u16 crc2;
            int os = zfile_ftell (tmpf);
            data = zfile_getdata (tmpf, 0, os);
            crc2 = wrpcrc16 (wrpcrc16table, data, os);
            if (crc != crc2)
-               write_log ("WRP crc error %04x<>%04x, track=%d,side=%d\n", crc, crc2, track, side);
+               write_log (L"WRP crc error %04x<>%04x, track=%d,side=%d\n", crc, crc2, track, side);
            xfree (data);
        }
        if (dstpos >= 0) {
diff --git a/audio.c b/audio.c
index a20ea0062a984f60334e01c585d414e4ae1d36ca..2bc8f731ac0baa18eed098b9f68fdea97999126a 100644 (file)
--- a/audio.c
+++ b/audio.c
@@ -143,11 +143,11 @@ static void convertsample(uae_u8 *sample, int len)
        sample[i] += 0x80;
 }
 
-static void namesplit (char *s)
+static void namesplit (TCHAR *s)
 {
     int l;
 
-    l = strlen (s) - 1;
+    l = _tcslen (s) - 1;
     while (l >= 0) {
        if (s[l] == '.')
            s[l] = 0;
@@ -158,16 +158,16 @@ static void namesplit (char *s)
        l--;
     }
     if (l > 0)
-       memmove (s, s + l, strlen (s + l) + 1);
+       memmove (s, s + l, (_tcslen (s + l) + 1) * sizeof (TCHAR));
 }
 
 void audio_sampleripper (int mode)
 {
     struct ripped_sample *rs = ripped_samples;
     int cnt = 1;
-    char path[MAX_DPATH], name[MAX_DPATH], filename[MAX_DPATH];
-    char underline[] = "_";
-    char extension[4];
+    TCHAR path[MAX_DPATH], name[MAX_DPATH], filename[MAX_DPATH];
+    TCHAR underline[] = L"_";
+    TCHAR extension[4];
     struct zfile *wavfile;
 
     if (mode < 0) {
@@ -186,13 +186,13 @@ void audio_sampleripper (int mode)
            fetch_ripperpath (path, sizeof (path));
            name[0] = 0;
            if (currprefs.dfxtype[0] >= 0)
-               strcpy (name, currprefs.df[0]);
+               _tcscpy (name, currprefs.df[0]);
            if (!name[0])
                underline[0] = 0;
            namesplit (name);
-           strcpy (extension, "wav");
-           sprintf (filename, "%s%s%s%03.3d.%s", path, name, underline, cnt, extension);
-           wavfile = zfile_fopen(filename, "wb");
+           _tcscpy (extension, L"wav");
+           _stprintf (filename, L"%s%s%s%03.3d.%s", path, name, underline, cnt, extension);
+           wavfile = zfile_fopen (filename, L"wb");
            if (wavfile) {
                int freq = rs->per > 0 ? (currprefs.ntscmode ? 3579545 : 3546895 / rs->per) : 8000;
                write_wavheader (wavfile, 0, 0);
@@ -201,9 +201,9 @@ void audio_sampleripper (int mode)
                convertsample (rs->sample, rs->len);
                write_wavheader (wavfile, zfile_ftell(wavfile), freq);
                zfile_fclose (wavfile);
-               write_log ("SAMPLERIPPER: %d: %dHz %d bytes\n", cnt, freq, rs->len);
+               write_log (L"SAMPLERIPPER: %d: %dHz %d bytes\n", cnt, freq, rs->len);
            } else {
-               write_log ("SAMPLERIPPER: failed to open '%s'\n", filename);
+               write_log (L"SAMPLERIPPER: failed to open '%s'\n", filename);
            }
        }
        cnt++;
@@ -236,7 +236,7 @@ static void do_samplerip (struct audio_channel_data *adp)
                xfree (rs->sample);
                rs->sample = xmalloc (len);
                memcpy (rs->sample, smp, len);
-               write_log ("SAMPLERIPPER: replaced sample %d (%d -> %d)\n", cnt, rs->len, len);
+               write_log (L"SAMPLERIPPER: replaced sample %d (%d -> %d)\n", cnt, rs->len, len);
                rs->len = len;
                rs->per = adp->per / CYCLE_UNIT;
                rs->changed = 1;
@@ -261,7 +261,7 @@ static void do_samplerip (struct audio_channel_data *adp)
     memcpy(rs->sample, smp, len);
     rs->next = NULL;
     rs->changed = 1;
-    write_log ("SAMPLERIPPER: sample added (%06X, %d bytes), total %d samples\n", adp->pt, len, ++cnt);
+    write_log (L"SAMPLERIPPER: sample added (%06X, %d bytes), total %d samples\n", adp->pt, len, ++cnt);
     audio_sampleripper (0);
 }
 
@@ -512,7 +512,7 @@ static void sinc_prehandler (unsigned long best_evtime)
         * write data into sinc queue for mixing in the BLEP */
        if (acd->sinc_output_state != output) {
            if (acd->sinc_queue_length > SINC_QUEUE_LENGTH - 1) {
-               //write_log ("warning: sinc queue truncated. Last age: %d.\n", acd->sinc_queue[SINC_QUEUE_LENGTH-1].age);
+               //write_log (L"warning: sinc queue truncated. Last age: %d.\n", acd->sinc_queue[SINC_QUEUE_LENGTH-1].age);
                acd->sinc_queue_length = SINC_QUEUE_LENGTH - 1;
            }
            /* make room for new and add the new value */
@@ -1087,7 +1087,7 @@ static void setirq (int nr)
 {
 #ifdef DEBUG_AUDIO
     if (debugchannel (nr))
-       write_log ("SETIRQ %d %08X\n", nr, M68K_GETPC);
+       write_log (L"SETIRQ %d %08X\n", nr, M68K_GETPC);
 #endif
     INTREQ (0x8000 | (0x80 << nr));
 }
@@ -1119,7 +1119,7 @@ static void state23 (struct audio_channel_data *cdp)
            do_samplerip (cdp);
 #ifdef DEBUG_AUDIO
        if (debugchannel (cdp - audio_channel))
-           write_log ("Channel %d looped, LC=%08X LEN=%d\n", cdp - audio_channel, cdp->pt, cdp->wlen);
+           write_log (L"Channel %d looped, LC=%08X LEN=%d\n", cdp - audio_channel, cdp->pt, cdp->wlen);
 #endif
     } else {
        cdp->wlen = (cdp->wlen - 1) & 0xFFFF;
@@ -1150,7 +1150,7 @@ static void audio_handler (int nr)
                    cdp->pt = cdp->lc;
 #ifdef DEBUG_AUDIO
                if (debugchannel (nr))
-                   write_log ("%d:0>1: LEN=%d\n", nr, cdp->wlen);
+                   write_log (L"%d:0>1: LEN=%d\n", nr, cdp->wlen);
 #endif
                cdp->request_word = 0;
                cdp->request_word_skip = 0;
@@ -1398,9 +1398,9 @@ void set_audio (void)
        if (currprefs.produce_sound >= 2) {
            if (!init_audio ()) {
                if (! sound_available) {
-                   write_log ("Sound is not supported.\n");
+                   write_log (L"Sound is not supported.\n");
                } else {
-                   write_log ("Sorry, can't initialize sound.\n");
+                   write_log (L"Sorry, can't initialize sound.\n");
                    currprefs.produce_sound = 0;
                    /* So we don't do this every frame */
                    changed_prefs.produce_sound = 0;
@@ -1606,7 +1606,7 @@ void audio_hsync (int dmaaction)
                    do_samplerip (cdp);
 #ifdef DEBUG_AUDIO
                if (debugchannel (nr))
-                   write_log ("%d:>5: LEN=%d PT=%08X\n", nr, cdp->wlen, cdp->pt);
+                   write_log (L"%d:>5: LEN=%d PT=%08X\n", nr, cdp->wlen, cdp->pt);
 #endif
            }
            cdp->dat2 = chipmem_agnus_wget (cdp->pt);
@@ -1624,7 +1624,7 @@ void audio_hsync (int dmaaction)
        if (cdp->dmaen != chan_ena) {
 #ifdef DEBUG_AUDIO
            if (debugchannel (nr))
-               write_log ("AUD%dDMA %d->%d (%d) LEN=%d/%d %08X\n", nr, cdp->dmaen, chan_ena,
+               write_log (L"AUD%dDMA %d->%d (%d) LEN=%d/%d %08X\n", nr, cdp->dmaen, chan_ena,
                    cdp->state, cdp->wlen, cdp->len, M68K_GETPC);
 #endif
            cdp->dmaen = chan_ena;
@@ -1647,7 +1647,7 @@ void AUDxDAT (int nr, uae_u16 v)
 
 #ifdef DEBUG_AUDIO
     if (debugchannel (nr))
-       write_log ("AUD%dDAT: %04X STATE=%d IRQ=%d %08X\n", nr,
+       write_log (L"AUD%dDAT: %04X STATE=%d IRQ=%d %08X\n", nr,
            v, cdp->state, isirq(nr) ? 1 : 0, M68K_GETPC);
 #endif
     audio_activate();
@@ -1677,7 +1677,7 @@ void AUDxLCH (int nr, uae_u16 v)
     audio_channel[nr].lc = (audio_channel[nr].lc & 0xffff) | ((uae_u32)v << 16);
 #ifdef DEBUG_AUDIO
     if (debugchannel (nr))
-       write_log ("AUD%dLCH: %04X %08X\n", nr, v, M68K_GETPC);
+       write_log (L"AUD%dLCH: %04X %08X\n", nr, v, M68K_GETPC);
 #endif
 }
 
@@ -1688,7 +1688,7 @@ void AUDxLCL (int nr, uae_u16 v)
     audio_channel[nr].lc = (audio_channel[nr].lc & ~0xffff) | (v & 0xFFFE);
 #ifdef DEBUG_AUDIO
     if (debugchannel (nr))
-       write_log ("AUD%dLCL: %04X %08X\n", nr, v, M68K_GETPC);
+       write_log (L"AUD%dLCL: %04X %08X\n", nr, v, M68K_GETPC);
 #endif
 }
 
@@ -1718,7 +1718,7 @@ void AUDxPER (int nr, uae_u16 v)
     audio_channel[nr].per = per;
 #ifdef DEBUG_AUDIO
     if (debugchannel (nr))
-       write_log ("AUD%dPER: %d %08X\n", nr, v, M68K_GETPC);
+       write_log (L"AUD%dPER: %d %08X\n", nr, v, M68K_GETPC);
 #endif
 }
 
@@ -1729,7 +1729,7 @@ void AUDxLEN (int nr, uae_u16 v)
     audio_channel[nr].len = v;
 #ifdef DEBUG_AUDIO
     if (debugchannel (nr))
-       write_log ("AUD%dLEN: %d %08X\n", nr, v, M68K_GETPC);
+       write_log (L"AUD%dLEN: %d %08X\n", nr, v, M68K_GETPC);
 #endif
 }
 
@@ -1745,7 +1745,7 @@ void AUDxVOL (int nr, uae_u16 v)
 #endif
 #ifdef DEBUG_AUDIO
     if (debugchannel (nr))
-       write_log ("AUD%dVOL: %d %08X\n", nr, v2, M68K_GETPC);
+       write_log (L"AUD%dVOL: %d %08X\n", nr, v2, M68K_GETPC);
 #endif
 }
 
@@ -1764,7 +1764,7 @@ void audio_update_irq (uae_u16 v)
        if ((1 << i) & DEBUG_CHANNEL_MASK) {
            uae_u16 mask = 0x80 << i;
            if ((v2 & mask) != (v3 & mask))
-               write_log ("AUD%dINTREQ %d->%d %08X\n", i, !!(v3 & mask), !!(v2 & mask), M68K_GETPC);
+               write_log (L"AUD%dINTREQ %d->%d %08X\n", i, !!(v3 & mask), !!(v2 & mask), M68K_GETPC);
        }
     }
 #endif
@@ -1782,7 +1782,7 @@ void audio_update_adkmasks (void)
     if ((prevcon & 0xff) != (adkcon & 0xff)) {
        audio_activate();
 #ifdef DEBUG_AUDIO
-       write_log ("ADKCON=%02x %08X\n", adkcon & 0xff, M68K_GETPC);
+       write_log (L"ADKCON=%02x %08X\n", adkcon & 0xff, M68K_GETPC);
 #endif
        prevcon = adkcon;
     }
index 76b288a9219edbfe943c854d2dc81c4bf35debae..7abd6ecd972b3a3c6cd93f8755413e7ad9f9d244 100644 (file)
@@ -42,7 +42,7 @@ static int REGPARAM3 rtarea_check (uaecptr addr, uae_u32 size) REGPARAM;
 addrbank rtarea_bank = {
     rtarea_lget, rtarea_wget, rtarea_bget,
     rtarea_lput, rtarea_wput, rtarea_bput,
-    rtarea_xlate, rtarea_check, NULL, "UAE Boot ROM",
+    rtarea_xlate, rtarea_check, NULL, L"UAE Boot ROM",
     rtarea_lget, rtarea_wget, ABFLAG_ROMIN
 };
 
@@ -141,7 +141,7 @@ void dl (uae_u32 data)
  * backward.  store pointer at current address
  */
 
-uae_u32 ds (const char *str)
+uae_u32 ds_ansi (const uae_char *str)
 {
     int len;
 
@@ -149,10 +149,18 @@ uae_u32 ds (const char *str)
        return addr (rt_straddr);
     len = strlen (str) + 1;
     rt_straddr -= len;
-    strcpy ((char *)rtarea + rt_straddr, str);
+    strcpy ((uae_char*)rtarea + rt_straddr, str);
     return addr (rt_straddr);
 }
 
+uae_u32 ds (const TCHAR *str)
+{
+    char *s = ua (str);
+    uae_u32 v = ds_ansi (s);
+    xfree (s);
+    return v;
+}
+
 void calltrap (uae_u32 n)
 {
     dw (0xA000 + n);
@@ -161,7 +169,7 @@ void calltrap (uae_u32 n)
 void org (uae_u32 a)
 {
     if ( ((a & 0xffff0000) != 0x00f00000) && ((a & 0xffff0000) != rtarea_base) )
-       write_log ("ORG: corrupt address! %08X", a);
+       write_log (L"ORG: corrupt address! %08X", a);
     rt_addr = a & 0xffff;
 }
 
@@ -177,7 +185,7 @@ void align (int b)
 
 static uae_u32 REGPARAM2 nullfunc (TrapContext *context)
 {
-    write_log ("Null function called\n");
+    write_log (L"Null function called\n");
     return 0;
 }
 
@@ -188,15 +196,15 @@ static uae_u32 REGPARAM2 getchipmemsize (TrapContext *context)
 
 static uae_u32 REGPARAM2 uae_puts (TrapContext *context)
 {
-    puts ((char *)get_real_address (m68k_areg (&context->regs, 0)));
+    puts ((uae_u8*)get_real_address (m68k_areg (&context->regs, 0)));
     return 0;
 }
 
 void rtarea_init_mem (void)
 {
-    rtarea = mapped_malloc (0x10000, "rtarea");
+    rtarea = mapped_malloc (0x10000, L"rtarea");
     if (!rtarea) {
-       write_log ("virtual memory exhausted (rtarea)!\n");
+       write_log (L"virtual memory exhausted (rtarea)!\n");
        abort ();
     }
     rtarea_bank.baseaddr = rtarea;
@@ -205,7 +213,7 @@ void rtarea_init_mem (void)
 void rtarea_init (void)
 {
     uae_u32 a;
-    char uaever[100];
+    TCHAR uaever[100];
 
     rt_straddr = 0xFF00 - 2;
     rt_addr = 0;
@@ -215,12 +223,12 @@ void rtarea_init (void)
     rtarea_init_mem ();
     memset (rtarea, 0, 0x10000);
 
-    sprintf (uaever, "uae-%d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
+    _stprintf (uaever, L"uae-%d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
 
     EXPANSION_uaeversion = ds (uaever);
-    EXPANSION_explibname = ds ("expansion.library");
-    EXPANSION_doslibname = ds ("dos.library");
-    EXPANSION_uaedevname = ds ("uae.device");
+    EXPANSION_explibname = ds (L"expansion.library");
+    EXPANSION_doslibname = ds (L"dos.library");
+    EXPANSION_uaedevname = ds (L"uae.device");
 
     deftrap (NULL); /* Generic emulator trap */
 
@@ -231,13 +239,13 @@ void rtarea_init (void)
     a = here();
     /* Dummy trap - removing this breaks the filesys emulation. */
     org (rtarea_base + 0xFF00);
-    calltrap (deftrap2 (nullfunc, TRAPFLAG_NO_RETVAL, ""));
+    calltrap (deftrap2 (nullfunc, TRAPFLAG_NO_RETVAL, L""));
 
     org (rtarea_base + 0xFF80);
-    calltrap (deftrapres (getchipmemsize, TRAPFLAG_DORET, "getchipmemsize"));
+    calltrap (deftrapres (getchipmemsize, TRAPFLAG_DORET, L"getchipmemsize"));
 
     org (rtarea_base + 0xFF10);
-    calltrap (deftrapres (uae_puts, TRAPFLAG_NO_RETVAL, "uae_puts"));
+    calltrap (deftrapres (uae_puts, TRAPFLAG_NO_RETVAL, L"uae_puts"));
     dw (RTS);
 
     org (a);
@@ -264,7 +272,7 @@ void rtarea_setup (void)
 {
     uaecptr base = need_uae_boot_rom ();
     if (base) {
-       write_log ("RTAREA located at %08X\n", base);
+       write_log (L"RTAREA located at %08X\n", base);
        rtarea_base = base;
     }
 }
index 10d290953d41c93c22b0fc4cf67d623643596bb9..721285e206a6b7dabc68d99274b6249cc2e43fca 100644 (file)
--- a/blitter.c
+++ b/blitter.c
@@ -222,10 +222,10 @@ void build_blitfilltable (void)
 
 static void blitter_dump (void)
 {
-    write_log ("APT=%08X BPT=%08X CPT=%08X DPT=%08X\n", bltapt, bltbpt, bltcpt, bltdpt);
-    write_log ("CON0=%04X CON1=%04X ADAT=%04X BDAT=%04X CDAT=%04X\n",
+    write_log (L"APT=%08X BPT=%08X CPT=%08X DPT=%08X\n", bltapt, bltbpt, bltcpt, bltdpt);
+    write_log (L"CON0=%04X CON1=%04X ADAT=%04X BDAT=%04X CDAT=%04X\n",
               bltcon0, bltcon1, blt_info.bltadat, blt_info.bltbdat, blt_info.bltcdat);
-    write_log ("AFWM=%04X ALWM=%04X AMOD=%04X BMOD=%04X CMOD=%04X DMOD=%04X\n",
+    write_log (L"AFWM=%04X ALWM=%04X AMOD=%04X BMOD=%04X CMOD=%04X DMOD=%04X\n",
               blt_info.bltafwm, blt_info.bltalwm,
               blt_info.bltamod & 0xffff, blt_info.bltbmod & 0xffff, blt_info.bltcmod & 0xffff, blt_info.bltdmod & 0xffff);
 }
@@ -260,7 +260,7 @@ static void blitter_done (void)
     event2_remevent (ev2_blitter);
     unset_special (&regs, SPCFLAG_BLTNASTY);
 #ifdef BLITTER_DEBUG
-    write_log ("vpos=%d, cycles %d, missed %d, total %d\n",
+    write_log (L"vpos=%d, cycles %d, missed %d, total %d\n",
        vpos, blit_cyclecounter, blit_misscyclecounter, blit_cyclecounter + blit_misscyclecounter);
 #endif
 }
@@ -309,7 +309,7 @@ static void blitter_dofast (void)
        uaecptr dstp = 0;
        int dodst = 0;
 
-       /*if (!blitfill) write_log ("minterm %x not present\n",mt); */
+       /*if (!blitfill) write_log (L"minterm %x not present\n",mt); */
        for (j = 0; j < blt_info.vblitsize; j++) {
            blitfc = !!(bltcon1 & 0x4);
            for (i = 0; i < blt_info.hblitsize; i++) {
@@ -673,7 +673,7 @@ void blitter_handler (uae_u32 data)
        /* "free" blitter in immediate mode if it has been "stuck" ~3 frames
         * fixes some JIT game incompatibilities
         */
-       debugtest (DEBUGTEST_BLITTER, "force-unstuck!\n");
+       debugtest (DEBUGTEST_BLITTER, L"force-unstuck!\n");
     }
     blitter_stuck = 0;
     if (blit_slowdown > 0 && !currprefs.immediate_blits) {
@@ -933,7 +933,7 @@ static void blitter_force_finish (void)
          */
        odmacon = dmacon;
        dmacon |= DMA_MASTER | DMA_BLITTER;
-       write_log ("forcing blitter finish\n");
+       write_log (L"forcing blitter finish\n");
        if (blitter_cycle_exact) {
            int rounds = 10000;
            while (bltstate != BLT_done && rounds > 0) {
@@ -942,7 +942,7 @@ static void blitter_force_finish (void)
                rounds--;
            }
            if (rounds == 0)
-               write_log ("blitter froze!?\n");
+               write_log (L"blitter froze!?\n");
        } else {
            actually_do_blit ();
        }
@@ -971,7 +971,7 @@ static void blit_bltset (int con)
 
     if (blitline) {
        if (blt_info.hblitsize != 2)
-           debugtest (DEBUGTEST_BLITTER, "weird hblitsize in linemode: %d vsize=%d\n",
+           debugtest (DEBUGTEST_BLITTER, L"weird hblitsize in linemode: %d vsize=%d\n",
                blt_info.hblitsize, blt_info.vblitsize);
        blit_diag = blit_cycle_diagram_line;
     } else {
@@ -979,16 +979,16 @@ static void blit_bltset (int con)
            blitfc = !!(bltcon1 & 0x4);
            blitife = bltcon1 & 0x8;
            if ((bltcon1 & 0x18) == 0x18) {
-               debugtest (DEBUGTEST_BLITTER, "weird fill mode\n");
+               debugtest (DEBUGTEST_BLITTER, L"weird fill mode\n");
                blitife = 0;
            }
        }
        if (blitfill && !blitdesc)
-           debugtest (DEBUGTEST_BLITTER, "fill without desc\n");
+           debugtest (DEBUGTEST_BLITTER, L"fill without desc\n");
        blit_diag = blitfill ? blit_cycle_diagram_fill[blit_ch] : blit_cycle_diagram[blit_ch];
     }
     if ((bltcon1 & 0x80) && (currprefs.chipset_mask & CSMASK_ECS_AGNUS))
-       debugtest (DEBUGTEST_BLITTER, "ECS BLTCON1 DOFF-bit set\n");
+       debugtest (DEBUGTEST_BLITTER, L"ECS BLTCON1 DOFF-bit set\n");
 
     blit_dmacount = blit_dmacount2 = 0;
     blit_nod = 1;
@@ -1069,7 +1069,7 @@ void do_blitter (int hpos)
     if (1) {
        int ch = 0;
        if (oldstate != BLT_done)
-           write_log ("blitter was already active!\n");
+           write_log (L"blitter was already active!\n");
        if (blit_ch & 1)
            ch++;
        if (blit_ch & 2)
@@ -1078,7 +1078,7 @@ void do_blitter (int hpos)
            ch++;
        if (blit_ch & 8)
            ch++;
-       write_log ("blitstart: v=%03d h=%03d %dx%d ch=%d %d*%d=%d d=%d f=%02X n=%d pc=%p l=%d dma=%04X\n",
+       write_log (L"blitstart: v=%03d h=%03d %dx%d ch=%d %d*%d=%d d=%d f=%02X n=%d pc=%p l=%d dma=%04X\n",
            vpos, hpos, blt_info.hblitsize, blt_info.vblitsize, ch, blit_diag[1], cycles, blit_diag[1] * cycles,
            blitdesc ? 1 : 0, blitfill, dmaen (DMA_BLITPRI) ? 1 : 0, M68K_GETPC, blitline, dmacon);
        blitter_dump ();
@@ -1142,7 +1142,7 @@ void maybe_blit (int hpos, int hack)
 #ifndef BLITTER_DEBUG
        warned = 1;
 #endif
-        debugtest (DEBUGTEST_BLITTER, "program does not wait for blitter vpos=%d tc=%d\n",
+        debugtest (DEBUGTEST_BLITTER, L"program does not wait for blitter vpos=%d tc=%d\n",
            vpos, blit_cyclecounter);
     }
 
@@ -1214,8 +1214,8 @@ uae_u8 *restore_blitter (uae_u8 *src)
 
     bltstate = (flags & 1) ? BLT_init : BLT_done;
     if (flags & 2) {
-       write_log ("blitter was force-finished when this statefile was saved\n");
-       write_log ("contact the author if restored program freezes\n");
+       write_log (L"blitter was force-finished when this statefile was saved\n");
+       write_log (L"contact the author if restored program freezes\n");
     }
     return src;
 }
@@ -1223,7 +1223,7 @@ uae_u8 *restore_blitter (uae_u8 *src)
 void restore_blitter_finish (void)
 {
     if (bltstate == BLT_init) {
-       write_log ("blitter was started but DMA was inactive during save\n");
+       write_log (L"blitter was started but DMA was inactive during save\n");
        do_blitter (0);
     }
 }
@@ -1235,7 +1235,7 @@ uae_u8 *save_blitter (int *len, uae_u8 *dstptr)
 
     forced = 0;
     if (bltstate != BLT_done && bltstate != BLT_init) {
-       write_log ("blitter is active, forcing immediate finish\n");
+       write_log (L"blitter is active, forcing immediate finish\n");
         /* blitter is active just now but we don't have blitter state support yet */
        blitter_force_finish ();
        forced = 2;
index bc0b1b86839acdcf9096c075102e4012f43d4f5e..264d8214d4f9f90f962502a189cb5a89505bcdea 100644 (file)
--- a/blkdev.c
+++ b/blkdev.c
@@ -84,7 +84,7 @@ int device_func_init (int flags)
     if (have_ioctl)
        support_ioctl = device_func[DF_IOCTL]->openbus (1 << INQ_ROMD) ? 1 : 0;
     initialized = 1;
-    write_log ("support_scsi = %d support_ioctl = %d\n", support_scsi, support_ioctl);
+    write_log (L"support_scsi = %d support_ioctl = %d\n", support_scsi, support_ioctl);
     return (support_scsi ? (1 << DF_SCSI) : 0) | (support_ioctl ? (1 << DF_IOCTL) : 0);
 }
 
@@ -397,31 +397,31 @@ void scsi_log_before (uae_u8 *cdb, int cdblen, uae_u8 *data, int datalen)
 {
     int i;
     for (i = 0; i < cdblen; i++) {
-       write_log ("%s%02X", i > 0 ? "." : "", cdb[i]);
+       write_log (L"%s%02X", i > 0 ? "." : "", cdb[i]);
     }
-    write_log ("\n");
+    write_log (L"\n");
     if (data) {
-       write_log ("DATAOUT: %d\n", datalen);
+       write_log (L"DATAOUT: %d\n", datalen);
        for (i = 0; i < datalen && i < 100; i++)
-           write_log ("%s%02X", i > 0 ? "." : "", data[i]);
+           write_log (L"%s%02X", i > 0 ? "." : "", data[i]);
        if (datalen > 0)
-           write_log ("\n");
+           write_log (L"\n");
     }
 }
 
 void scsi_log_after (uae_u8 *data, int datalen, uae_u8 *sense, int senselen)
 {
     int i;
-    write_log ("DATAIN: %d\n", datalen);
+    write_log (L"DATAIN: %d\n", datalen);
     for (i = 0; i < datalen && i < 100 && data; i++)
-       write_log ("%s%02X", i > 0 ? "." : "", data[i]);
+       write_log (L"%s%02X", i > 0 ? "." : "", data[i]);
     if (data && datalen > 0)
-       write_log ("\n");
+       write_log (L"\n");
     if (senselen > 0) {
-       write_log ("SENSE: %d,", senselen);
+       write_log (L"SENSE: %d,", senselen);
        for (i = 0; i < senselen && i < 32; i++) {
-           write_log ("%s%02X", i > 0 ? "." : "", sense[i]);
+           write_log (L"%s%02X", i > 0 ? "." : "", sense[i]);
        }
-       write_log ("\n");
+       write_log (L"\n");
     }
 }
index 1fba6c213d3d2c7afd91b22772c03895fb2f7b1d..f2e7f8346530f133edc7327f0f9d73b32ef33620 100644 (file)
@@ -41,10 +41,10 @@ struct sockd {
 static long curruniqid = 65536;
 static struct sockd *sockdata;
 
-uae_u32 strncpyha (uae_u32 dst, const char *src, int size)
+uae_u32 strncpyha (uae_u32 dst, const uae_char *src, int size)
 {
     uae_u32 res = dst;
-    if (!addr_valid("strncpyha", dst, size))
+    if (!addr_valid (L"strncpyha", dst, size))
        return res;
     while (size--) {
        put_byte (dst++, *src);
@@ -54,20 +54,28 @@ uae_u32 strncpyha (uae_u32 dst, const char *src, int size)
     return res;
 }
 
-uae_u32 addstr (uae_u32 * dst, const char *src)
+uae_u32 addstr (uae_u32 * dst, const TCHAR *src)
+{
+    uae_u32 res = *dst;
+    int len;
+    char *s = ua (src);
+    len = strlen (s) + 1;
+    strcpyha_safe (*dst, s);
+    (*dst) += len;
+    xfree (s);
+    return res;
+}
+uae_u32 addstr_ansi (uae_u32 * dst, const uae_char *src)
 {
     uae_u32 res = *dst;
     int len;
-
     len = strlen (src) + 1;
-
     strcpyha_safe (*dst, src);
     (*dst) += len;
-
     return res;
 }
 
-uae_u32 addmem (uae_u32 * dst, const char *src, int len)
+uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len)
 {
     uae_u32 res = *dst;
 
@@ -90,7 +98,7 @@ static uae_u32 gettask (TrapContext *context)
 
     m68k_areg (&context->regs, 1) = a1;
 
-    TRACE (("[%s] ", get_real_address (get_long (currtask + 10))));
+    BSDTRACE ((L"[%s] ", get_real_address (get_long (currtask + 10))));
     return currtask;
 }
 
@@ -152,7 +160,7 @@ BOOL checksd(SB, int sd)
                return TRUE;
        }
     }
-    TRACE(("checksd FALSE s 0x%x sd %d\n",s,sd));
+    BSDTRACE(("checksd FALSE s 0x%x sd %d\n",s,sd));
     return FALSE;
 }
 
@@ -188,25 +196,25 @@ int getsd (SB, SOCKET_TYPE s)
 SOCKET_TYPE getsock (SB, int sd)
 {
     if ((unsigned int) (sd - 1) >= (unsigned int) sb->dtablesize) {
-       TRACE (("Invalid Socket Descriptor (%d)\n", sd));
+       BSDTRACE ((L"Invalid Socket Descriptor (%d)\n", sd));
        bsdsocklib_seterrno (sb, 38); /* ENOTSOCK */
        return -1;
     }
     if (sb->dtable[sd - 1] == INVALID_SOCKET) {
        struct socketbase *sb1, *nsb;
        uaecptr ot;
-       if (!addr_valid("getsock1", sb->ownertask + 10, 4))
+       if (!addr_valid (L"getsock1", sb->ownertask + 10, 4))
            return -1;
        ot = get_long (sb->ownertask + 10);
-       if (!addr_valid("getsock2", ot, 1))
+       if (!addr_valid (L"getsock2", ot, 1))
            return -1;
        // Fix for Newsrog (All Tasks of Newsrog using the same dtable)
        for (sb1 = socketbases; sb1; sb1 = nsb) {
            uaecptr ot1;
-           if (!addr_valid("getsock3", sb1->ownertask + 10, 4))
+           if (!addr_valid (L"getsock3", sb1->ownertask + 10, 4))
                break;
            ot1 = get_long (sb1->ownertask + 10);
-           if (!addr_valid("getsock4", ot1, 1))
+           if (!addr_valid (L"getsock4", ot1, 1))
                break;
            if (strcmp(get_real_address (ot1), get_real_address (ot)) == 0) {
                // Task with same name already exists -> use same dtable
@@ -371,7 +379,7 @@ static struct socketbase *alloc_socketbase (TrapContext *context)
        sb->signal = CallLib (context, get_long (4), -0x14A); /* AllocSignal */
 
        if (sb->signal == -1) {
-           write_log ("bsdsocket: ERROR: Couldn't allocate signal for task 0x%lx.\n", sb->ownertask);
+           write_log (L"bsdsocket: ERROR: Couldn't allocate signal for task 0x%lx.\n", sb->ownertask);
            free (sb);
            return NULL;
        }
@@ -475,7 +483,7 @@ static void free_socketbase (TrapContext *context)
 
 static uae_u32 REGPARAM2 bsdsocklib_Expunge (TrapContext *context)
 {
-    TRACE (("Expunge() -> [ignored]\n"));
+    BSDTRACE ((L"Expunge() -> [ignored]\n"));
     return 0;
 }
 
@@ -487,7 +495,7 @@ static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *context)
     int opencount;
     SB;
 
-    TRACE (("OpenLibrary() -> "));
+    BSDTRACE ((L"OpenLibrary() -> "));
 
     if ((sb = alloc_socketbase (context)) != NULL) {
        put_word (SockLibBase + 32, opencount = get_word (SockLibBase + 32) + 1);
@@ -501,9 +509,9 @@ static uae_u32 REGPARAM2 bsdsocklib_Open (TrapContext *context)
 
        put_pointer (result + offsetof (struct UAEBSDBase, sb), sb);
 
-       TRACE (("%0lx [%d]\n", result, opencount));
+       BSDTRACE ((L"%0lx [%d]\n", result, opencount));
     } else
-       TRACE (("failed (out of memory)\n"));
+       BSDTRACE ((L"failed (out of memory)\n"));
 
     return result;
 }
@@ -523,7 +531,7 @@ static uae_u32 REGPARAM2 bsdsocklib_Close (TrapContext *context)
     m68k_dreg (&context->regs, 0) = negsize + get_word (base + 18);
     CallLib (context, get_long (4), -0xD2); /* FreeMem */
 
-    TRACE (("CloseLibrary() -> [%d]\n", opencount));
+    BSDTRACE ((L"CloseLibrary() -> [%d]\n", opencount));
 
     return 0;
 }
@@ -671,7 +679,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SetSocketSignals (TrapContext *context)
 {
     struct socketbase *sb = get_socketbase (context);
 
-    TRACE (("SetSocketSignals(0x%08lx,0x%08lx,0x%08lx) -> ", m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2)));
+    BSDTRACE ((L"SetSocketSignals(0x%08lx,0x%08lx,0x%08lx) -> ", m68k_dreg (&context->regs, 0), m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2)));
     sb->eintrsigs = m68k_dreg (&context->regs, 0);
     sb->eventsigs = m68k_dreg (&context->regs, 1);
 
@@ -735,19 +743,19 @@ static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *context)
 
     id = m68k_dreg (&context->regs, 0);
 
-    TRACE (("ObtainSocket(%d,%d,%d,%d) -> ", id, m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2), m68k_dreg (&context->regs, 3)));
+    BSDTRACE ((L"ObtainSocket(%d,%d,%d,%d) -> ", id, m68k_dreg (&context->regs, 1), m68k_dreg (&context->regs, 2), m68k_dreg (&context->regs, 3)));
 
     i = sockpoolindex (id);
 
     if (i == -1) {
-       TRACE (("[invalid key]\n"));
+       BSDTRACE ((L"[invalid key]\n"));
        return -1;
     }
     s = sockdata->sockpoolsocks[i];
 
     sd = getsd (sb, s);
 
-    TRACE (("%d\n", sd));
+    BSDTRACE ((L"%d\n", sd));
 
     if (sd != -1) {
        sb->ftable[sd - 1] = sockdata->sockpoolflags[i];
@@ -772,7 +780,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context)
     id = m68k_dreg (&context->regs, 1);
 
     sd++;
-    TRACE (("ReleaseSocket(%d,%d) -> ", sd, id));
+    BSDTRACE ((L"ReleaseSocket(%d,%d) -> ", sd, id));
 
     s = getsock (sb, sd);
 
@@ -780,7 +788,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context)
        flags = sb->ftable[sd - 1];
 
        if (flags & REP_ALL) {
-           write_log ("bsdsocket: ERROR: ReleaseSocket() is not supported for sockets with async event notification enabled!\n");
+           write_log (L"bsdsocket: ERROR: ReleaseSocket() is not supported for sockets with async event notification enabled!\n");
            return -1;
        }
        releasesock (sb, sd);
@@ -797,24 +805,24 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context)
            id = curruniqid;
        } else if (id < 0 && id > 65535) {
            if (sockpoolindex (id) != -1) {
-               TRACE (("[unique ID already exists]\n"));
+               BSDTRACE ((L"[unique ID already exists]\n"));
                return -1;
            }
        }
        i = sockpoolindex (-1);
 
        if (i == -1) {
-           TRACE (("-1\n"));
-           write_log (("bsdsocket: ERROR: Global socket pool overflow\n"));
+           BSDTRACE ((L"-1\n"));
+           write_log (L"bsdsocket: ERROR: Global socket pool overflow\n");
            return -1;
        }
        sockdata->sockpoolids[i] = id;
        sockdata->sockpoolsocks[i] = s;
        sockdata->sockpoolflags[i] = flags;
 
-       TRACE (("id %d s 0x%x\n", id,s));
+       BSDTRACE ((L"id %d s 0x%x\n", id,s));
     } else {
-       TRACE (("[invalid socket descriptor]\n"));
+       BSDTRACE ((L"[invalid socket descriptor]\n"));
        return -1;
     }
 
@@ -835,7 +843,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *context)
    id = m68k_dreg (&context->regs, 1);
 
    sd++;
-   TRACE (("ReleaseSocket(%d,%d) -> ", sd, id));
+   BSDTRACE ((L"ReleaseSocket(%d,%d) -> ", sd, id));
 
    s = getsock (sb, sd);
 
@@ -843,7 +851,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *context)
        flags = sb->ftable[sd - 1];
 
        if (flags & REP_ALL) {
-           write_log ("bsdsocket: ERROR: ReleaseCopyOfSocket() is not supported for sockets with async event notification enabled!\n");
+           write_log (L"bsdsocket: ERROR: ReleaseCopyOfSocket() is not supported for sockets with async event notification enabled!\n");
            return -1;
        }
        if (id == UNIQUE_ID) {
@@ -857,26 +865,26 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *context)
            id = curruniqid;
        } else if (id < 0 && id > 65535) {
            if (sockpoolindex (id) != -1) {
-               TRACE (("[unique ID already exists]\n"));
+               BSDTRACE ((L"[unique ID already exists]\n"));
                return -1;
            }
        }
        i = sockpoolindex (-1);
 
        if (i == -1) {
-           TRACE (("-1\n"));
-           write_log (("bsdsocket: ERROR: Global socket pool overflow\n"));
+           BSDTRACE ((L"-1\n"));
+           write_log (L"bsdsocket: ERROR: Global socket pool overflow\n");
            return -1;
        }
        sockdata->sockpoolids[i] = id;
        sockdata->sockpoolsocks[i] = s;
        sockdata->sockpoolflags[i] = flags;
 
-       TRACE (("id %d s 0x%x\n", id,s));
+       BSDTRACE ((L"id %d s 0x%x\n", id,s));
 
     } else {
 
-       TRACE (("[invalid socket descriptor]\n"));
+       BSDTRACE ((L"[invalid socket descriptor]\n"));
        return -1;
     }
 
@@ -887,7 +895,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseCopyOfSocket (TrapContext *context)
 static uae_u32 REGPARAM2 bsdsocklib_Errno (TrapContext *context)
 {
     struct socketbase *sb = get_socketbase (context);
-    TRACE (("Errno() -> %d\n", sb->sb_errno));
+    BSDTRACE ((L"Errno() -> %d\n", sb->sb_errno));
     return sb->sb_errno;
 }
 
@@ -897,12 +905,12 @@ static uae_u32 REGPARAM2 bsdsocklib_SetErrnoPtr (TrapContext *context)
     struct socketbase *sb = get_socketbase (context);
     uae_u32 errnoptr = m68k_areg (&context->regs, 0), size = m68k_dreg (&context->regs, 0);
 
-    TRACE (("SetErrnoPtr(0x%lx,%d) -> ", errnoptr, size));
+    BSDTRACE ((L"SetErrnoPtr(0x%lx,%d) -> ", errnoptr, size));
 
     if (size == 1 || size == 2 || size == 4) {
        sb->errnoptr = errnoptr;
        sb->errnosize = size;
-       TRACE (("OK\n"));
+       BSDTRACE ((L"OK\n"));
        return 0;
     }
     bsdsocklib_seterrno (sb, 22); /* EINVAL */
@@ -927,21 +935,21 @@ static uae_u32 REGPARAM2 bsdsocklib_inet_addr (TrapContext *context)
 /* Inet_LnaOf(in)(d0) */
 static uae_u32 REGPARAM2 bsdsocklib_Inet_LnaOf (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: Inet_LnaOf()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: Inet_LnaOf()\n");
     return 0;
 }
 
 /* Inet_NetOf(in)(d0) */
 static uae_u32 REGPARAM2 bsdsocklib_Inet_NetOf (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: Inet_NetOf()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: Inet_NetOf()\n");
     return 0;
 }
 
 /* Inet_MakeAddr(net, host)(d0/d1) */
 static uae_u32 REGPARAM2 bsdsocklib_Inet_MakeAddr (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: Inet_MakeAddr()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: Inet_MakeAddr()\n");
     return 0;
 }
 
@@ -971,14 +979,14 @@ static uae_u32 REGPARAM2 bsdsocklib_gethostbyaddr (TrapContext *context)
 /* getnetbyname(name)(a0) */
 static uae_u32 REGPARAM2 bsdsocklib_getnetbyname (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: getnetbyname()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: getnetbyname()\n");
     return 0;
 }
 
 /* getnetbyaddr(net, type)(d0/d1) */
 static uae_u32 REGPARAM2 bsdsocklib_getnetbyaddr (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: getnetbyaddr()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: getnetbyaddr()\n");
     return 0;
 }
 
@@ -1018,7 +1026,7 @@ static uae_u32 REGPARAM2 bsdsocklib_getprotobynumber (TrapContext *context)
 /* Syslog(level, format, ap)(d0/a0/a1) */
 static uae_u32 REGPARAM2 bsdsocklib_vsyslog (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: vsyslog()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: vsyslog()\n");
     return 0;
 }
 
@@ -1032,13 +1040,13 @@ static uae_u32 REGPARAM2 bsdsocklib_Dup2Socket (TrapContext *context)
 
 static uae_u32 REGPARAM2 bsdsocklib_sendmsg (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: sendmsg()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: sendmsg()\n");
     return 0;
 }
 
 static uae_u32 REGPARAM2 bsdsocklib_recvmsg (TrapContext *context)
 {
-    write_log ("bsdsocket: UNSUPPORTED: recvmsg()\n");
+    write_log (L"bsdsocket: UNSUPPORTED: recvmsg()\n");
     return 0;
 }
 
@@ -1049,49 +1057,49 @@ static uae_u32 REGPARAM2 bsdsocklib_gethostname (TrapContext *context)
 
 static uae_u32 REGPARAM2 bsdsocklib_gethostid (TrapContext *context)
 {
-    write_log ("bsdsocket: WARNING: Process '%s' calls deprecated function gethostid() - returning 127.0.0.1\n",
+    write_log (L"bsdsocket: WARNING: Process '%s' calls deprecated function gethostid() - returning 127.0.0.1\n",
        get_real_address (get_long (gettask (context) + 10)));
     return 0x7f000001;
 }
 
-static const char *errortexts[] =
-{"No error", "Operation not permitted", "No such file or directory",
"No such process", "Interrupted system call", "Input/output error", "Device not configured",
"Argument list too long", "Exec format error", "Bad file descriptor", "No child processes",
"Resource deadlock avoided", "Cannot allocate memory", "Permission denied", "Bad address",
"Block device required", "Device busy", "Object exists", "Cross-device link",
"Operation not supported by device", "Not a directory", "Is a directory", "Invalid argument",
"Too many open files in system", "Too many open files", "Inappropriate ioctl for device",
"Text file busy", "File too large", "No space left on device", "Illegal seek",
"Read-only file system", "Too many links", "Broken pipe", "Numerical argument out of domain",
"Result too large", "Resource temporarily unavailable", "Operation now in progress",
"Operation already in progress", "Socket operation on non-socket", "Destination address required",
"Message too long", "Protocol wrong type for socket", "Protocol not available",
"Protocol not supported", "Socket type not supported", "Operation not supported",
"Protocol family not supported", "Address family not supported by protocol family",
"Address already in use", "Can't assign requested address", "Network is down",
"Network is unreachable", "Network dropped connection on reset", "Software caused connection abort",
"Connection reset by peer", "No buffer space available", "Socket is already connected",
"Socket is not connected", "Can't send after socket shutdown", "Too many references: can't splice",
"Connection timed out", "Connection refused", "Too many levels of symbolic links",
"File name too long", "Host is down", "No route to host", "Directory not empty",
"Too many processes", "Too many users", "Disc quota exceeded", "Stale NFS file handle",
"Too many levels of remote in path", "RPC struct is bad", "RPC version wrong",
"RPC prog. not avail", "Program version wrong", "Bad procedure for program", "No locks available",
"Function not implemented", "Inappropriate file type or format", "PError 0"};
+static const TCHAR *errortexts[] =
+{L"No error", L"Operation not permitted", L"No such file or directory",
L"No such process", L"Interrupted system call", L"Input/output error", L"Device not configured",
L"Argument list too long", L"Exec format error", L"Bad file descriptor", L"No child processes",
L"Resource deadlock avoided", L"Cannot allocate memory", L"Permission denied", L"Bad address",
L"Block device required", L"Device busy", L"Object exists", L"Cross-device link",
L"Operation not supported by device", L"Not a directory", L"Is a directory", L"Invalid argument",
L"Too many open files in system", L"Too many open files", L"Inappropriate ioctl for device",
L"Text file busy", L"File too large", L"No space left on device", L"Illegal seek",
L"Read-only file system", L"Too many links", L"Broken pipe", L"Numerical argument out of domain",
L"Result too large", L"Resource temporarily unavailable", L"Operation now in progress",
L"Operation already in progress", L"Socket operation on non-socket", L"Destination address required",
L"Message too long", L"Protocol wrong type for socket", L"Protocol not available",
L"Protocol not supported", L"Socket type not supported", L"Operation not supported",
L"Protocol family not supported", L"Address family not supported by protocol family",
L"Address already in use", L"Can't assign requested address", L"Network is down",
L"Network is unreachable", L"Network dropped connection on reset", L"Software caused connection abort",
L"Connection reset by peer", L"No buffer space available", L"Socket is already connected",
L"Socket is not connected", L"Can't send after socket shutdown", L"Too many references: can't splice",
L"Connection timed out", L"Connection refused", L"Too many levels of symbolic links",
L"File name too long", L"Host is down", L"No route to host", L"Directory not empty",
L"Too many processes", L"Too many users", L"Disc quota exceeded", L"Stale NFS file handle",
L"Too many levels of remote in path", L"RPC struct is bad", L"RPC version wrong",
L"RPC prog. not avail", L"Program version wrong", L"Bad procedure for program", L"No locks available",
L"Function not implemented", L"Inappropriate file type or format", L"PError 0"};
 
 static uae_u32 errnotextptrs[sizeof (errortexts) / sizeof (*errortexts)];
 static const uae_u32 number_sys_error = sizeof (errortexts) / sizeof (*errortexts);
 
 
-static const char *herrortexts[] =
{"No error", "Unknown host", "Host name lookup failure", "Unknown server error",
- "No address associated with name"};
+static const TCHAR *herrortexts[] =
   {L"No error", L"Unknown host", L"Host name lookup failure", L"Unknown server error",
      L"No address associated with name"};
 
 static uae_u32 herrnotextptrs[sizeof (herrortexts) / sizeof (*herrortexts)];
 static const uae_u32 number_host_error = sizeof (herrortexts) / sizeof (*herrortexts);
 
-static const char * const strErr = "Errlist lookup error";
+static const TCHAR * const strErr = L"Errlist lookup error";
 static uae_u32 strErrptr;
 
 
@@ -1167,7 +1175,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
     uae_u32 currtag;
     uae_u32 currval;
 
-    TRACE (("SocketBaseTagList("));
+    BSDTRACE ((L"SocketBaseTagList("));
 
     for (;;) {
        currtag = get_long (tagptr);
@@ -1176,50 +1184,50 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
 
        switch (currtag) {
         case TAG_DONE:
-           TRACE (("TAG_DONE"));
+           BSDTRACE ((L"TAG_DONE"));
            tagsprocessed = 0;
            goto done;
         case TAG_IGNORE:
-           TRACE (("TAG_IGNORE"));
+           BSDTRACE ((L"TAG_IGNORE"));
            break;
         case TAG_MORE:
-           TRACE (("TAG_MORE(0x%lx)", currval));
+           BSDTRACE ((L"TAG_MORE(0x%lx)", currval));
            tagptr = currval;
            break;
         case TAG_SKIP:
-           TRACE (("TAG_SKIP(%d)", currval));
+           BSDTRACE ((L"TAG_SKIP(%d)", currval));
            tagptr += currval * 8;
            break;
 
         default:
            if (currtag & TAG_USER) {
-               TRACE (("SBTM_"));
-               TRACE ((currtag & 0x0001 ? "SET" : "GET"));
-               TRACE ((currtag & 0x8000 ? "REF(" : "VAL("));
+               BSDTRACE ((L"SBTM_"));
+               BSDTRACE ((currtag & 0x0001 ? "SET" : "GET"));
+               BSDTRACE ((currtag & 0x8000 ? "REF(" : "VAL("));
 
                switch ((currtag >> 1) & SBTS_CODE) {
                 case SBTC_BREAKMASK:
-                   TRACE (("SBTC_BREAKMASK),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_BREAKMASK),0x%lx", currval));
                    tagcopy (currtag, currval, tagptr, &sb->eintrsigs);
                    break;
                 case SBTC_SIGEVENTMASK:
-                   TRACE (("SBTC_SIGEVENTMASK),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_SIGEVENTMASK),0x%lx", currval));
                    tagcopy (currtag, currval, tagptr, &sb->eventsigs);
                    break;
                 case SBTC_SIGIOMASK:
-                   TRACE (("SBTC_SIGEVENTMASK),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_SIGEVENTMASK),0x%lx", currval));
                    tagcopy (currtag, currval, tagptr, &sb->eventsigs);
                    break;
                 case SBTC_ERRNO:
-                   TRACE (("SBTC_ERRNO),%d", currval));
+                   BSDTRACE ((L"SBTC_ERRNO),%d", currval));
                    tagcopy (currtag, currval, tagptr, &sb->sb_errno);
                    break;
                 case SBTC_HERRNO:
-                   TRACE (("SBTC_HERRNO),%d", currval));
+                   BSDTRACE ((L"SBTC_HERRNO),%d", currval));
                    tagcopy (currtag, currval, tagptr, &sb->sb_herrno);
                    break;
                 case SBTC_DTABLESIZE:
-                   TRACE (("SBTC_DTABLESIZE),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_DTABLESIZE),0x%lx", currval));
                    if (currtag & 1) {
                        bsdsocklib_SetDTableSize(sb, currval);
                    } else {
@@ -1228,7 +1236,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
                    break;
                 case SBTC_ERRNOSTRPTR:
                    if (currtag & 1) {
-                       TRACE (("ERRNOSTRPTR),invalid"));
+                       BSDTRACE ((L"ERRNOSTRPTR),invalid"));
                    } else {
                        unsigned long ulTmp;
                        if (currtag & 0x8000) { /* SBTM_GETREF */
@@ -1236,7 +1244,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
                        } else { /* SBTM_GETVAL */
                            ulTmp = currval;
                        }
-                       TRACE (("ERRNOSTRPTR),%d", ulTmp));
+                       BSDTRACE ((L"ERRNOSTRPTR),%d", ulTmp));
                        if (ulTmp < number_sys_error) {
                            tagcopy (currtag, currval, tagptr, &errnotextptrs[ulTmp]);
                        } else {
@@ -1246,7 +1254,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
                    break;
                 case SBTC_HERRNOSTRPTR:
                    if (currtag & 1) {
-                       TRACE (("HERRNOSTRPTR),invalid"));
+                       BSDTRACE ((L"HERRNOSTRPTR),invalid"));
                    } else {
                        unsigned long ulTmp;
                        if (currtag & 0x8000) { /* SBTM_GETREF */
@@ -1254,7 +1262,7 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
                        } else { /* SBTM_GETVAL */
                            ulTmp = currval;
                        }
-                       TRACE (("HERRNOSTRPTR),%d", ulTmp));
+                       BSDTRACE ((L"HERRNOSTRPTR),%d", ulTmp));
                        if (ulTmp < number_host_error) {
                            tagcopy (currtag, currval, tagptr, &herrnotextptrs[ulTmp]);
                        } else {
@@ -1263,47 +1271,47 @@ static uae_u32 REGPARAM2 bsdsocklib_SocketBaseTagList (TrapContext *context)
                    }
                    break;
                 case SBTC_ERRNOBYTEPTR:
-                   TRACE (("SBTC_ERRNOBYTEPTR),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_ERRNOBYTEPTR),0x%lx", currval));
                    tagcopy (currtag, currval, tagptr, &sb->errnoptr);
                    sb->errnosize = 1;
                    break;
                 case SBTC_ERRNOWORDPTR:
-                   TRACE (("SBTC_ERRNOWORDPTR),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_ERRNOWORDPTR),0x%lx", currval));
                    tagcopy (currtag, currval, tagptr, &sb->errnoptr);
                    sb->errnosize = 2;
                    break;
                 case SBTC_ERRNOLONGPTR:
-                   TRACE (("SBTC_ERRNOLONGPTR),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_ERRNOLONGPTR),0x%lx", currval));
                    tagcopy (currtag, currval, tagptr, &sb->errnoptr);
                    sb->errnosize = 4;
                    break;
                 case SBTC_HERRNOLONGPTR:
-                   TRACE (("SBTC_HERRNOLONGPTR),0x%lx", currval));
+                   BSDTRACE ((L"SBTC_HERRNOLONGPTR),0x%lx", currval));
                    tagcopy (currtag, currval, tagptr, &sb->herrnoptr);
                    sb->herrnosize = 4;
                    break;
                 default:
-                   write_log ("bsdsocket: WARNING: Unsupported tag type (%08x) in SocketBaseTagList(%x)\n",
+                   write_log (L"bsdsocket: WARNING: Unsupported tag type (%08x) in SocketBaseTagList(%x)\n",
                        currtag, m68k_areg (&context->regs, 0));
                    break;
                }
            } else {
-               TRACE (("TAG_UNKNOWN(0x%x)", currtag));
+               BSDTRACE ((L"TAG_UNKNOWN(0x%x)", currtag));
                /* Aminetradio uses 0x00004e55 as an ending tag */
                if ((currtag & 0xffff8000) == 0) {
-                   write_log ("bsdsocket: WARNING: Corrupted SocketBaseTagList(%x) tag detected (%08x)\n",
+                   write_log (L"bsdsocket: WARNING: Corrupted SocketBaseTagList(%x) tag detected (%08x)\n",
                        m68k_areg (&context->regs, 0), currtag);
                    goto done;
                }
            }
        }
 
-       TRACE ((","));
+       BSDTRACE ((L","));
        tagptr += 8;
     }
 
   done:
-    TRACE ((") -> %d\n", tagsprocessed));
+    BSDTRACE ((L") -> %d\n", tagsprocessed));
 
     return tagsprocessed;
 }
@@ -1316,7 +1324,7 @@ static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents (TrapContext *context)
     int flags;
     uae_u32 ptr = m68k_areg (&context->regs, 0);
 
-    TRACE (("GetSocketEvents(0x%x) -> ", ptr));
+    BSDTRACE ((L"GetSocketEvents(0x%x) -> ", ptr));
 
     for (i = sb->dtablesize; i--; sb->eventindex++) {
        if (sb->eventindex >= sb->dtablesize)
@@ -1327,13 +1335,13 @@ static uae_u32 REGPARAM2 bsdsocklib_GetSocketEvents (TrapContext *context)
            if (flags) {
                sb->ftable[sb->eventindex] &= ~SET_ALL;
                put_long (m68k_areg (&context->regs, 0), flags >> 8);
-               TRACE (("%d (0x%x)\n", sb->eventindex + 1, flags >> 8));
+               BSDTRACE ((L"%d (0x%x)\n", sb->eventindex + 1, flags >> 8));
                return sb->eventindex; // xxx
            }
        }
     }
 #endif
-    TRACE (("-1\n"));
+    BSDTRACE ((L"-1\n"));
     return -1;
 }
 
@@ -1352,7 +1360,7 @@ static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context)
     uae_u32 tmp1;
     int i;
 
-    write_log ("Creating UAE bsdsocket.library 4.1\n");
+    write_log (L"Creating UAE bsdsocket.library 4.1\n");
     if (SockLibBase)
        bsdlib_reset ();
 
@@ -1364,7 +1372,7 @@ static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context)
     tmp1 = CallLib (context, m68k_areg (&context->regs, 6), -0x54); /* MakeLibrary */
 
     if (!tmp1) {
-       write_log ("bsdoscket: FATAL: Cannot create bsdsocket.library!\n");
+       write_log (L"bsdoscket: FATAL: Cannot create bsdsocket.library!\n");
        return 0;
     }
     m68k_areg (&context->regs, 1) = tmp1;
@@ -1374,27 +1382,25 @@ static uae_u32 REGPARAM2 bsdsocklib_init (TrapContext *context)
     /* Install error strings in Amiga memory */
     tmp1 = 0;
     for (i = number_sys_error; i--;)
-       tmp1 += strlen (errortexts[i])+1;
+       tmp1 += _tcslen (errortexts[i]) + 1;
 
     for (i = number_host_error; i--;)
-       tmp1 += strlen (herrortexts[i])+1;
+       tmp1 += _tcslen (herrortexts[i]) + 1;
 
-    tmp1 += strlen(strErr)+1;
+    tmp1 += _tcslen (strErr) + 1;
 
     m68k_dreg (&context->regs, 0) = tmp1;
     m68k_dreg (&context->regs, 1) = 0;
     tmp1 = CallLib (context, get_long (4), -0xC6); /* AllocMem */
 
     if (!tmp1) {
-       write_log ("bsdsocket: FATAL: Ran out of memory while creating bsdsocket.library!\n");
+       write_log (L"bsdsocket: FATAL: Ran out of memory while creating bsdsocket.library!\n");
        return 0;
     }
     for (i = 0; i < (int) (number_sys_error); i++)
        errnotextptrs[i] = addstr (&tmp1, errortexts[i]);
-
     for (i = 0; i < (int) (number_host_error); i++)
        herrnotextptrs[i] = addstr (&tmp1, herrortexts[i]);
-
     strErrptr = addstr (&tmp1, strErr);
 
 #if 0
@@ -1420,12 +1426,12 @@ void bsdlib_reset (void)
 
     SockLibBase = 0;
 
-    write_log("BSDSOCK: cleanup start..\n");
+    write_log (L"BSDSOCK: cleanup start..\n");
     host_sbcleanup (NULL);
     for (sb = socketbases; sb; sb = nsb) {
        nsb = sb->next;
 
-       write_log("BSDSOCK: cleanup start socket %x\n", sb);
+       write_log (L"BSDSOCK: cleanup start socket %x\n", sb);
        host_sbcleanup (sb);
 
        free (sb->dtable);
@@ -1433,7 +1439,7 @@ void bsdlib_reset (void)
 
        free (sb);
     }
-    write_log("BSDSOCK: cleanup end\n");
+    write_log (L"BSDSOCK: cleanup end\n");
 
     socketbases = NULL;
 #if 1
@@ -1448,7 +1454,7 @@ void bsdlib_reset (void)
     }
 
     host_sbreset ();
-    write_log("BSDSOCK: cleanup finished\n");
+    write_log (L"BSDSOCK: cleanup finished\n");
 }
 
 static const TrapHandler sockfuncs[] = {
@@ -1467,20 +1473,20 @@ static const TrapHandler sockfuncs[] = {
     bsdsocklib_GetSocketEvents
 };
 
-static const char * const funcnames[] = {
-    "bsdsocklib_init", "bsdsocklib_Open", "bsdsocklib_Close", "bsdsocklib_Expunge",
-    "bsdsocklib_socket", "bsdsocklib_bind", "bsdsocklib_listen", "bsdsocklib_accept",
-    "bsdsocklib_connect", "bsdsocklib_sendto", "bsdsocklib_send", "bsdsocklib_recvfrom", "bsdsocklib_recv",
-    "bsdsocklib_shutdown", "bsdsocklib_setsockopt", "bsdsocklib_getsockopt", "bsdsocklib_getsockname",
-    "bsdsocklib_getpeername", "bsdsocklib_IoctlSocket", "bsdsocklib_CloseSocket", "bsdsocklib_WaitSelect",
-    "bsdsocklib_SetSocketSignals", "bsdsocklib_getdtablesize", "bsdsocklib_ObtainSocket", "bsdsocklib_ReleaseSocket",
-    "bsdsocklib_ReleaseCopyOfSocket", "bsdsocklib_Errno", "bsdsocklib_SetErrnoPtr", "bsdsocklib_Inet_NtoA",
-    "bsdsocklib_inet_addr", "bsdsocklib_Inet_LnaOf", "bsdsocklib_Inet_NetOf", "bsdsocklib_Inet_MakeAddr",
-    "bsdsocklib_inet_network", "bsdsocklib_gethostbyname", "bsdsocklib_gethostbyaddr", "bsdsocklib_getnetbyname",
-    "bsdsocklib_getnetbyaddr", "bsdsocklib_getservbyname", "bsdsocklib_getservbyport", "bsdsocklib_getprotobyname",
-    "bsdsocklib_getprotobynumber", "bsdsocklib_vsyslog", "bsdsocklib_Dup2Socket", "bsdsocklib_sendmsg",
-    "bsdsocklib_recvmsg", "bsdsocklib_gethostname", "bsdsocklib_gethostid", "bsdsocklib_SocketBaseTagList",
-    "bsdsocklib_GetSocketEvents"
+static const TCHAR * const funcnames[] = {
+    L"bsdsocklib_init", L"bsdsocklib_Open", L"bsdsocklib_Close", L"bsdsocklib_Expunge",
+    L"bsdsocklib_socket", L"bsdsocklib_bind", L"bsdsocklib_listen", L"bsdsocklib_accept",
+    L"bsdsocklib_connect", L"bsdsocklib_sendto", L"bsdsocklib_send", L"bsdsocklib_recvfrom", L"bsdsocklib_recv",
+    L"bsdsocklib_shutdown", L"bsdsocklib_setsockopt", L"bsdsocklib_getsockopt", L"bsdsocklib_getsockname",
+    L"bsdsocklib_getpeername", L"bsdsocklib_IoctlSocket", L"bsdsocklib_CloseSocket", L"bsdsocklib_WaitSelect",
+    L"bsdsocklib_SetSocketSignals", L"bsdsocklib_getdtablesize", L"bsdsocklib_ObtainSocket", L"bsdsocklib_ReleaseSocket",
+    L"bsdsocklib_ReleaseCopyOfSocket", L"bsdsocklib_Errno", L"bsdsocklib_SetErrnoPtr", L"bsdsocklib_Inet_NtoA",
+    L"bsdsocklib_inet_addr", L"bsdsocklib_Inet_LnaOf", L"bsdsocklib_Inet_NetOf", L"bsdsocklib_Inet_MakeAddr",
+    L"bsdsocklib_inet_network", L"bsdsocklib_gethostbyname", L"bsdsocklib_gethostbyaddr", L"bsdsocklib_getnetbyname",
+    L"bsdsocklib_getnetbyaddr", L"bsdsocklib_getservbyname", L"bsdsocklib_getservbyport", L"bsdsocklib_getprotobyname",
+    L"bsdsocklib_getprotobynumber", L"bsdsocklib_vsyslog", L"bsdsocklib_Dup2Socket", L"bsdsocklib_sendmsg",
+    L"bsdsocklib_recvmsg", L"bsdsocklib_gethostname", L"bsdsocklib_gethostid", L"bsdsocklib_SocketBaseTagList",
+    L"bsdsocklib_GetSocketEvents"
 };
 
 static uae_u32 sockfuncvecs[sizeof (sockfuncs) / sizeof (*sockfuncs)];
@@ -1516,8 +1522,8 @@ void bsdlib_install (void)
     if (!init_socket_layer ())
        return;
 
-    res_name = ds ("bsdsocket.library");
-    res_id = ds ("UAE bsdsocket.library 4.1");
+    res_name = ds (L"bsdsocket.library");
+    res_id = ds (L"UAE bsdsocket.library 4.1");
 
     for (i = 0; i < (int) (sizeof (sockfuncs) / sizeof (sockfuncs[0])); i++) {
        sockfuncvecs[i] = here ();
@@ -1565,7 +1571,7 @@ void bsdlib_install (void)
     dl (datatable);
     dl (*sockfuncvecs);
 
-    write_log ("bsdsocked.library installed\n");
+    write_log (L"bsdsocked.library installed\n");
 }
 
 #endif /* ! BSDSOCKET */
index a3d4a5a2ecdcee5aa5376075e5ca08e782436fef..f39d2ebe61c739c3353f0430ec17f462ab019846 100644 (file)
@@ -6,11 +6,16 @@
  * Copyright 1995,1996 Bernd Schmidt
  */
 
+#include <stdlib.h>
+#include <tchar.h>
+#include <assert.h>
+#include <ctype.h>
+
+#define TCHAR char
+
 #include "sysconfig.h"
 #include "sysdeps.h"
 
-#include <assert.h>
-#include <ctype.h>
 
 #include "readcpu.h"
 
@@ -246,7 +251,7 @@ int main(int argc, char **argv)
            for(i = 0; i < 5; i++) {
                printf("{%d,%d}%s", flaguse[i], flagset[i], i == 4 ? "" : ",");
            }
-           printf("},%2d,\"%s\"}", sduse, opstrp);
+           printf("},%2d,L\"%s\"}", sduse, opstrp);
        }
     }
     printf("};\nint n_defs68k = %d;\n", no_insns);
index a39c47e81422fc6bdc75845006849c8fc72d8b91..d3ffef0cb8d705a351965b97c3a0aca6d46a8459 100644 (file)
@@ -285,11 +285,11 @@ uae_u32   catweasel_do_bget (uaecptr addr)
     buf1[0] = (uae_u8)addr;
     if (handle != INVALID_HANDLE_VALUE) {
        if (!DeviceIoControl (handle, CW_PEEKREG_FULL, buf1, 1, buf2, 1, &did_read, 0))
-           write_log ("catweasel_do_bget %02x fail err=%d\n", buf1[0], GetLastError ());
+           write_log (L"catweasel_do_bget %02x fail err=%d\n", buf1[0], GetLastError ());
     } else {
        buf2[0] = ioport_read (cwc.iobase + addr);
     }
-    //write_log ("G %02X %02X %d\n", buf1[0], buf2[0], did_read);
+    //write_log (L"G %02X %02X %d\n", buf1[0], buf2[0], did_read);
     return buf2[0];
 }
 
@@ -304,11 +304,11 @@ void catweasel_do_bput (uaecptr   addr, uae_u32 b)
     buf[1] = b;
     if (handle != INVALID_HANDLE_VALUE) {
        if (!DeviceIoControl (handle, CW_POKEREG_FULL, buf, 2, 0, 0, &did_read, 0))
-           write_log ("catweasel_do_bput %02x=%02x fail err=%d\n", buf[0], buf[1], GetLastError ());
+           write_log (L"catweasel_do_bput %02x=%02x fail err=%d\n", buf[0], buf[1], GetLastError ());
     } else {
        ioport_write (cwc.iobase + addr, b);
     }
-    //write_log ("P %02X %02X %d\n", (uae_u8)addr, (uae_u8)b, did_read);
+    //write_log (L"P %02X %02X %d\n", (uae_u8)addr, (uae_u8)b, did_read);
 }
 
 #include "core.cw4.c"
@@ -357,21 +357,21 @@ static int catweasel4_configure (void)
     sleep_millis(10);
 
     if (cw_config_done()) {
-       write_log ("CW: FPGA already configured, skipping core upload\n");
+       write_log (L"CW: FPGA already configured, skipping core upload\n");
        return 1;
     }
     cw_resetFPGA();
     sleep_millis(10);
     if (cw_config_done()) {
-       write_log ("CW: FPGA failed to reset!\n");
+       write_log (L"CW: FPGA failed to reset!\n");
        return 0;
     }
-    f = zfile_fopen("core.cw4", "rb");
+    f = zfile_fopen(L"core.cw4", L"rb");
     if (!f) {
-       f = zfile_fopen_data ("core.cw4.gz", core_len, core);
+       f = zfile_fopen_data (L"core.cw4.gz", core_len, core);
        f = zfile_gunzip (f);
     }
-    write_log ("CW: starting core upload, this will take few seconds\n");
+    write_log (L"CW: starting core upload, this will take few seconds\n");
     t = time(NULL) + 10; // give up if upload takes more than 10s
     for (;;) {
        uae_u8 b;
@@ -380,7 +380,7 @@ static int catweasel4_configure (void)
        ioport_write (cwc.iobase + 3, (b & 1) ? 67 : 65);
        while (!cw_fpga_ready()) {
            if (time(NULL) >= t) {
-               write_log ("CW: FPGA core upload got stuck!?\n");
+               write_log (L"CW: FPGA core upload got stuck!?\n");
                cw_resetFPGA();
                return 0;
            }
@@ -388,12 +388,12 @@ static int catweasel4_configure (void)
        ioport_write (cwc.iobase + 192, b);
     }
     if (!cw_config_done()) {
-       write_log ("CW: FPGA didn't accept the core!\n");
+       write_log (L"CW: FPGA didn't accept the core!\n");
        cw_resetFPGA();
        return 0;
     }
     sleep_millis(10);
-    write_log ("CW: core uploaded successfully\n");
+    write_log (L"CW: core uploaded successfully\n");
     return 1;
 }
 
@@ -495,7 +495,7 @@ static int direct_detect(void)
                    if (resId == ResType_IO) {
                        PIO_RESOURCE pIoData = (PIO_RESOURCE)resDesData;
                        if(pIoData->IO_Header.IOD_Alloc_End-pIoData->IO_Header.IOD_Alloc_Base+1) {
-                           write_log ("CW: PCI SCAN: CWMK%d @%I64X - %I64X\n", cw,
+                           write_log (L"CW: PCI SCAN: CWMK%d @%I64X - %I64X\n", cw,
                                pIoData->IO_Header.IOD_Alloc_Base,pIoData->IO_Header.IOD_Alloc_End);
                            cwc.iobase = (int)pIoData->IO_Header.IOD_Alloc_Base;
                            cwc.direct_type = cw;
@@ -521,7 +521,7 @@ static int detected;
 
 int catweasel_init(void)
 {
-    char name[32], tmp[1000];
+    TCHAR name[32], tmp[1000];
     int i, len;
     uae_u8 buffer[10000];
     uae_u32 model, base;
@@ -547,7 +547,7 @@ int catweasel_init(void)
                i = currprefs.catweasel;
            if (currprefs.catweasel < 0)
                i = -currprefs.catweasel + 1;
-           sprintf (name, "\\\\.\\CAT%d_F0", i);
+           _stprintf (name, L"\\\\.\\CAT%d_F0", i);
            handle = CreateFile (name, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_WRITE|FILE_SHARE_READ, 0,
                OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
            if (handle != INVALID_HANDLE_VALUE || currprefs.catweasel > 0)
@@ -561,7 +561,7 @@ int catweasel_init(void)
     }
 
     if (handle == INVALID_HANDLE_VALUE) {
-       strcpy(name, "[DIRECT]");
+       _tcscpy (name, L"[DIRECT]");
        if (cwc.direct_type && ioport_init()) {
            cwc.direct_access = 1;
            if (cwc.direct_type == 4 && catweasel4_configure()) {
@@ -579,22 +579,22 @@ int catweasel_init(void)
            }
        }
        if (cwc.type == 0) {
-           write_log ("CW: No Catweasel detected\n");
+           write_log (L"CW: No Catweasel detected\n");
            goto fail;
        }
     }
 
     if (!cwc.direct_type) {
        if (!DeviceIoControl (handle, CW_GET_VERSION, 0, 0, buffer, sizeof (buffer), &len, 0)) {
-           write_log ("CW: CW_GET_VERSION failed %d\n", GetLastError());
+           write_log (L"CW: CW_GET_VERSION failed %d\n", GetLastError());
            goto fail;
        }
-       write_log ("CW driver version string '%s'\n", buffer);
+       write_log (L"CW driver version string '%s'\n", buffer);
        if (!DeviceIoControl (handle, CW_GET_HWVERSION, 0, 0, buffer, sizeof (buffer), &len, 0)) {
-           write_log ("CW: CW_GET_HWVERSION failed %d\n", GetLastError());
+           write_log (L"CW: CW_GET_HWVERSION failed %d\n", GetLastError());
            goto fail;
        }
-       write_log ("CW: v=%d 14=%d 28=%d 56=%d joy=%d dpm=%d sid=%d kb=%d sidfifo=%d\n",
+       write_log (L"CW: v=%d 14=%d 28=%d 56=%d joy=%d dpm=%d sid=%d kb=%d sidfifo=%d\n",
            buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5],
            buffer[6], buffer[7], ((uae_u32*)(buffer + 8))[0]);
        cwc.can_joy = (buffer[4] & 1) ? 2 : 0;
@@ -602,7 +602,7 @@ int catweasel_init(void)
        cwc.can_kb = buffer[7] & 1;
        cwc.can_mouse = (buffer[4] & 2) ? 2 : 0;
         if (!DeviceIoControl (handle, CW_LOCK_EXCLUSIVE, 0, 0, buffer, sizeof (buffer), &len, 0)) {
-           write_log ("CW: CW_LOCK_EXCLUSIVE failed %d\n", GetLastError ());
+           write_log (L"CW: CW_LOCK_EXCLUSIVE failed %d\n", GetLastError ());
            goto fail;
        }
        model = *((uae_u32*)(buffer + 4));
@@ -611,7 +611,7 @@ int catweasel_init(void)
        cwc.iobase = base;
        if (!cwc.direct_access) {
            if (!DeviceIoControl (handle, CW_UNLOCK_EXCLUSIVE, 0, 0, 0, 0, &len, 0)) {
-               write_log ("CW: CW_UNLOCK_EXCLUSIVE failed %d\n", GetLastError ());
+               write_log (L"CW: CW_UNLOCK_EXCLUSIVE failed %d\n", GetLastError ());
            }
        }
        if (cwc.type == CATWEASEL_TYPE_MK4 && cwc.can_sid)
@@ -637,20 +637,20 @@ int catweasel_init(void)
     }
 
     //catweasel_init_controller(&cwc);
-    sprintf(tmp, "CW: Catweasel MK%d @%p (%s) enabled. %s.",
+    _stprintf (tmp, L"CW: Catweasel MK%d @%p (%s) enabled. %s.",
        cwc.type, (uae_u8*)cwc.iobase, name, cwc.direct_access ? "DIRECTIO": "API");
     if (cwc.direct_access) {
        if (cwc.can_sid) {
-           char *p = tmp + strlen(tmp);
+           TCHAR *p = tmp + _tcslen (tmp);
            catweasel_detect_sid ();
-           sprintf(p, " SID0=%d", cwc.sid[0]);
+           _stprintf (p, L" SID0=%d", cwc.sid[0]);
            if (cwc.can_sid > 1) {
-               p += strlen(p);
-               sprintf(p, " SID1=%d", cwc.sid[1]);
+               p += _tcslen (p);
+               _stprintf (p, L" SID1=%d", cwc.sid[1]);
            }
        }
     }
-    write_log ("%s\n", tmp);
+    write_log (L"%s\n", tmp);
     detected = 1;
 
     return 1;
@@ -679,7 +679,7 @@ void catweasel_free (void)
 
 int catweasel_detect (void)
 {
-    char name[32];
+    TCHAR name[32];
     int i;
     HANDLE h;
 
@@ -688,12 +688,12 @@ int catweasel_detect (void)
 
     detected = -1;
     for (i = 0; i < 4; i++) {
-       sprintf (name, "\\\\.\\CAT%u_F0", i);
+       _stprintf (name, L"\\\\.\\CAT%u_F0", i);
        h = CreateFile (name, GENERIC_READ, FILE_SHARE_WRITE|FILE_SHARE_READ, 0,
            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
        if (h != INVALID_HANDLE_VALUE) {
            CloseHandle (h);
-           write_log ("CW: Windows driver device detected '%s'\n", name);
+           write_log (L"CW: Windows driver device detected '%s'\n", name);
            detected = 1;
            return TRUE;
        }
index a22e92f913de82fdf005b8e8f9b7701ae17fdf39..6714ba00ed097f415d674645d370e6b34b08736f 100644 (file)
@@ -29,10 +29,10 @@ static int fmv_size = 1048576;
 static uae_u8 fmv_bget2 (uaecptr addr)
 {
 #ifdef FMV_DEBUG
-    write_log ("fmv_bget2 %08X PC=%8X\n", addr, M68K_GETPC);
+    write_log (L"fmv_bget2 %08X PC=%8X\n", addr, M68K_GETPC);
 #endif
     if (addr >= rom_size) {
-       write_log ("fmv_bget2 %08X PC=%8X\n", addr, M68K_GETPC);
+       write_log (L"fmv_bget2 %08X PC=%8X\n", addr, M68K_GETPC);
        return 0;
     }
     return rom[addr];
@@ -40,7 +40,7 @@ static uae_u8 fmv_bget2 (uaecptr addr)
 static void fmv_bput2 (uaecptr addr, uae_u8 v)
 {
     if (addr >= rom_size && addr < 0xf0000) {
-       ;//write_log ("fmv_bput2 %08X=%02X PC=%8X\n", addr, v & 0xff, M68K_GETPC);
+       ;//write_log (L"fmv_bput2 %08X=%02X PC=%8X\n", addr, v & 0xff, M68K_GETPC);
     }
 }
 
@@ -55,7 +55,7 @@ static uae_u32 REGPARAM2 fmv_lget (uaecptr addr)
     v = (fmv_bget2 (addr) << 24) | (fmv_bget2 (addr + 1) << 16) |
        (fmv_bget2 (addr + 2) << 8) | (fmv_bget2 (addr + 3));
 #ifdef FMV_DEBUG
-    write_log ("fmv_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
+    write_log (L"fmv_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -70,7 +70,7 @@ static uae_u32 REGPARAM2 fmv_wget (uaecptr addr)
     addr &= fmv_mask;
     v = (fmv_bget2 (addr) << 8) | fmv_bget2 (addr + 1);
 #ifdef FMV_DEBUG
-    write_log ("fmv_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
+    write_log (L"fmv_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -95,7 +95,7 @@ static void REGPARAM2 fmv_lput (uaecptr addr, uae_u32 l)
     addr -= fmv_start & fmv_mask;
     addr &= fmv_mask;
 #ifdef FMV_DEBUG
-    write_log ("fmv_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
+    write_log (L"fmv_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
 #endif
     fmv_bput2 (addr, l >> 24);
     fmv_bput2 (addr + 1, l >> 16);
@@ -111,7 +111,7 @@ static void REGPARAM2 fmv_wput (uaecptr addr, uae_u32 w)
     addr -= fmv_start & fmv_mask;
     addr &= fmv_mask;
 #ifdef FMV_DEBUG
-    write_log ("fmv_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
+    write_log (L"fmv_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
 #endif
     fmv_bput2 (addr, w >> 8);
     fmv_bput2 (addr + 1, w);
@@ -142,7 +142,7 @@ static uae_u32 REGPARAM2 fmv_wgeti (uaecptr addr)
     if (addr < rom_size)
        return do_get_mem_word ((uae_u16 *)m);
 #ifdef FMV_DEBUG
-    write_log ("fmv_wgeti %08X %08X PC=%08X\n", addr, v, M68K_GETPC);
+    write_log (L"fmv_wgeti %08X %08X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -160,7 +160,7 @@ static uae_u32 REGPARAM2 fmv_lgeti (uaecptr addr)
     if (addr < rom_size)
        return do_get_mem_long ((uae_u32 *)m);
 #ifdef FMV_DEBUG
-    write_log ("fmv_lgeti %08X %08X PC=%08X\n", addr, v, M68K_GETPC);
+    write_log (L"fmv_lgeti %08X %08X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -182,7 +182,7 @@ static uae_u8 *REGPARAM2 fmv_xlate (uaecptr addr)
 static addrbank fmv_bank = {
     fmv_lget, fmv_wget, fmv_bget,
     fmv_lput, fmv_wput, fmv_bput,
-    fmv_xlate, fmv_check, NULL, "CD32 FMV module",
+    fmv_xlate, fmv_check, NULL, L"CD32 FMV module",
     fmv_lgeti, fmv_wgeti, ABFLAG_ROM | ABFLAG_IO
 };
 
@@ -195,7 +195,7 @@ void cd32_fmv_init (uaecptr start)
     struct romdata *rd;
     struct zfile *z;
 
-    write_log ("CD32 FMV mapped @$%lx\n", start);
+    write_log (L"CD32 FMV mapped @$%lx\n", start);
     if (start != fmv_start)
        return;
     if (!rl)
@@ -203,8 +203,8 @@ void cd32_fmv_init (uaecptr start)
     rd = rl->rd;
     z = read_rom (&rd);
     if (z) {
-       write_log ("CD32 FMV ROM %d.%d\n", rd->ver, rd->rev);
-       rom = mapped_malloc (fmv_size, "fast");
+       write_log (L"CD32 FMV ROM %d.%d\n", rd->ver, rd->rev);
+       rom = mapped_malloc (fmv_size, L"fast");
        if (rom)
            zfile_fread (rom, rd->size, 1, z);
        zfile_fclose (z);
diff --git a/cdtv.c b/cdtv.c
index 2eb665312733b5b8d2597b6327fdf873bf6df38d..b0bc194040e59f7e90a2cb5685757cfd630aed8a 100644 (file)
--- a/cdtv.c
+++ b/cdtv.c
@@ -210,7 +210,7 @@ static int pause_audio (int pause)
 
 static int read_sectors(int start, int length)
 {
-    write_log ("READ DATA sector %d, %d sectors (blocksize=%d)\n", start, length, cdtv_sectorsize);
+    write_log (L"READ DATA sector %d, %d sectors (blocksize=%d)\n", start, length, cdtv_sectorsize);
     cdrom_sector = start;
     cdrom_sectors = length;
     cdrom_offset = start * cdtv_sectorsize;
@@ -264,7 +264,7 @@ static int play_cdtrack (uae_u8 *p)
     }
     play_end = msf2lsn (end);
     play_start = msf2lsn (start);
-    write_log ("PLAY CD AUDIO from %d-%d, %06X (%d) to %06X (%d)\n",
+    write_log (L"PLAY CD AUDIO from %d-%d, %06X (%d) to %06X (%d)\n",
        track_start, track_end, start, msf2lsn (start), end, msf2lsn (end));
     play_state = 1;
     play_state_cmd = 1;
@@ -303,7 +303,7 @@ static int play_cd (uae_u8 *p)
        end = last_cd_position;
     play_end = msf2lsn (end);
     play_start = msf2lsn (start);
-    write_log ("PLAY CD AUDIO from %06X (%d) to %06X (%d)\n",
+    write_log (L"PLAY CD AUDIO from %06X (%d) to %06X (%d)\n",
        start, msf2lsn (start), end, msf2lsn (end));
     play_state = 1;
     play_state_cmd = 1;
@@ -400,7 +400,7 @@ static int cdrom_modeset (uae_u8 *cmd)
 {
     cdtv_sectorsize = (cmd[2] << 8) | cmd[3];
     if (cdtv_sectorsize != 2048 && cdtv_sectorsize != 2336) {
-       write_log ("CDTV: tried to set unknown sector size %d\n", cdtv_sectorsize);
+       write_log (L"CDTV: tried to set unknown sector size %d\n", cdtv_sectorsize);
        cdtv_sectorsize = 2048;
     }
     return 0;
@@ -409,7 +409,7 @@ static int cdrom_modeset (uae_u8 *cmd)
 static void cdrom_command_accepted (int size, uae_u8 *cdrom_command_input, int *cdrom_command_cnt_in)
 {
 #ifdef CDTV_DEBUG_CMD
-    char tmp[200];
+    TCHAR tmp[200];
     int i;
 #endif
     cdrom_command_size_out = size;
@@ -417,12 +417,12 @@ static void cdrom_command_accepted (int size, uae_u8 *cdrom_command_input, int *
     tmp[0] = 0;
     for (i = 0; i < *cdrom_command_cnt_in; i++)
        sprintf(tmp + i * 3, "%02X%c", cdrom_command_input[i], i < *cdrom_command_cnt_in - 1 ? '.' : ' ');
-    write_log ("CD<-: %s\n", tmp);
+    write_log (L"CD<-: %s\n", tmp);
     if (size > 0) {
        tmp[0] = 0;
        for (i = 0; i < size; i++)
            sprintf(tmp + i * 3, "%02X%c", cdrom_command_output[i], i < size - 1 ? '.' : ' ');
-       write_log ("CD->: %s\n", tmp);
+       write_log (L"CD->: %s\n", tmp);
     }
 #endif
     *cdrom_command_cnt_in = 0;
@@ -552,7 +552,7 @@ static void cdrom_command_thread (uae_u8 b)
        }
        break;
        default:
-       write_log ("unknown CDROM command %02X!\n", s[0]);
+       write_log (L"unknown CDROM command %02X!\n", s[0]);
        cd_error = 1;
        cdrom_command_accepted (0, s, &cdrom_command_cnt_in);
        break;
@@ -565,7 +565,7 @@ static uae_u8 *read_raw (int sector, int size)
     static struct zfile *f;
     static int track;
     int trackcnt;
-    char fname[MAX_DPATH];
+    TCHAR fname[MAX_DPATH];
     static uae_u8 buf[4096];
     uae_u32 prevlsn = 0;
     uae_u8 *s = cdrom_toc + 4;
@@ -587,17 +587,17 @@ static uae_u8 *read_raw (int sector, int size)
        s += 11;
     }
     if (track != trackcnt) {
-       sprintf (fname, "track%d.bin", trackcnt);
+       _stprintf (fname, L"track%d.bin", trackcnt);
        zfile_fclose (f);
-       f = zfile_fopen (fname, "rb");
+       f = zfile_fopen (fname, L"rb");
        if (!f)
-           write_log ("failed to open '%s'\n", fname);
+           write_log (L"failed to open '%s'\n", fname);
        else
-           write_log ("opened '%s'\n", fname);
+           write_log (L"opened '%s'\n", fname);
        track = trackcnt;
     }
     if (f) {
-       write_log ("CDTV fakeraw: %dx%d=%d\n", sector, size, sector * size);
+       write_log (L"CDTV fakeraw: %dx%d=%d\n", sector, size, sector * size);
        zfile_fseek (f, sector * size, SEEK_SET);
        zfile_fread (buf, size, 1, f);
        return buf;
@@ -617,7 +617,7 @@ static void dma_do_thread(void)
     if (!cdtv_sectorsize)
        return;
     cnt = dmac_wtc;
-    write_log ("DMAC DMA: sector=%d, addr=%08X, words=%d (of %d)\n",
+    write_log (L"DMAC DMA: sector=%d, addr=%08X, words=%d (of %d)\n",
        cdrom_offset / cdtv_sectorsize, dmac_acr, cnt, cdrom_length / 2);
     dma_wait += cnt * (uae_u64)312 * 50 / 75 + 1;
     while (cnt > 0 && dmac_dma) {
@@ -630,7 +630,7 @@ static void dma_do_thread(void)
            if (!p) {
                cd_error = 1;
                activate_stch = 1;
-               write_log ("CDTV: CD read error!\n");
+               write_log (L"CDTV: CD read error!\n");
                break;
            }
 
@@ -650,7 +650,7 @@ static void dma_do_thread(void)
 
 static void *dev_thread (void *p)
 {
-    write_log ("CDTV: CD thread started\n");
+    write_log (L"CDTV: CD thread started\n");
     thread_alive = 1;
     for (;;) {
 
@@ -728,7 +728,7 @@ static void tp_bput (int addr, uae_u8 v)
 {
     static int volstrobe1, volstrobe2;
 #ifdef CDTV_DEBUG_6525
-    write_log ("6525 write %x=%02X PC=%x\n", addr, v, M68K_GETPC);
+    write_log (L"6525 write %x=%02X PC=%x\n", addr, v, M68K_GETPC);
 #endif
     switch (addr)
     {
@@ -772,7 +772,7 @@ static void tp_bput (int addr, uae_u8 v)
     }
     if (!volstrobe2 && ((tp_b >> 7) & 1)) {
 #ifdef CDTV_DEBUG_CMD
-       write_log ("CDTV CD volume = %d\n", cd_volume);
+       write_log (L"CDTV CD volume = %d\n", cd_volume);
 #endif
        cd_volume = 0;
        volstrobe2 = 1;
@@ -788,7 +788,7 @@ static uae_u8 tp_bget(int addr)
     {
        case 0:
        v = tp_a;
-       write_log ("TPA read!\n");
+       write_log (L"TPA read!\n");
        break;
        case 1:
        v = tp_b;
@@ -824,7 +824,7 @@ static uae_u8 tp_bget(int addr)
 
 #ifdef CDTV_DEBUG_6525
     if (addr < 7)
-       write_log ("6525 read %x=%02X PC=%x\n", addr, v, M68K_GETPC);
+       write_log (L"6525 read %x=%02X PC=%x\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -864,7 +864,7 @@ static void do_hunt (void)
     if (sys_command_open (DF_IOCTL, i) > 0) {
        unitnum = i;
        cd_hunt = 0;
-       write_log ("CDTV: autodetected unit %d\n", unitnum);
+       write_log (L"CDTV: autodetected unit %d\n", unitnum);
     } else {
        unitnum = -1;
     }
@@ -916,7 +916,7 @@ void CDTV_hsync_handler (void)
        if ((dmac_cntr & (CNTR_INTEN | CNTR_TCEN)) == (CNTR_INTEN | CNTR_TCEN)) {
            dmac_istr |= ISTR_INT_P | ISTR_E_INT;
 #ifdef CDTV_DEBUG
-           write_log ("DMA finished\n");
+           write_log (L"DMA finished\n");
 #endif
        }
        dma_finished = 0;
@@ -983,7 +983,7 @@ static void do_stch (void)
        activate_stch = 0;
        tp_air |= 1 << 2;
        INT2();
-       write_log ("STCH %d\n", stch_cnt++);
+       write_log (L"STCH %d\n", stch_cnt++);
     }
 }
 
@@ -999,7 +999,7 @@ void bleh (void)
 
 static void cdtv_reset (void)
 {
-    write_log ("CDTV: reset\n");
+    write_log (L"CDTV: reset\n");
     cdaudiostop();
     cd_playing = cd_paused = 0;
     cd_motor = 0;
@@ -1080,7 +1080,7 @@ static uae_u32 dmac_bget2 (uaecptr addr)
 
 #ifdef CDTV_DEBUG
     if (addr != 0x41)
-       write_log ("dmac_bget %04X=%02X PC=%08X\n", addr, v, M68K_GETPC);
+       write_log (L"dmac_bget %04X=%02X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
 
     return v;
@@ -1094,7 +1094,7 @@ static void dmac_bput2 (uaecptr addr, uae_u32 b)
     }
 
 #ifdef CDTV_DEBUG
-    write_log ("dmac_bput %04X=%02X PC=%08X\n", addr, b & 255, M68K_GETPC);
+    write_log (L"dmac_bput %04X=%02X PC=%08X\n", addr, b & 255, M68K_GETPC);
 #endif
 
     switch (addr)
@@ -1195,7 +1195,7 @@ static uae_u32 REGPARAM2 dmac_lget (uaecptr addr)
     v = (dmac_bget2 (addr) << 24) | (dmac_bget2 (addr + 1) << 16) |
        (dmac_bget2 (addr + 2) << 8) | (dmac_bget2 (addr + 3));
 #ifdef CDTV_DEBUG
-    write_log ("dmac_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
+    write_log (L"dmac_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -1209,7 +1209,7 @@ static uae_u32 REGPARAM2 dmac_wget (uaecptr addr)
     addr &= 65535;
     v = (dmac_bget2 (addr) << 8) | dmac_bget2 (addr + 1);
 #ifdef CDTV_DEBUG
-    write_log ("dmac_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
+    write_log (L"dmac_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -1234,7 +1234,7 @@ static void REGPARAM2 dmac_lput (uaecptr addr, uae_u32 l)
 #endif
     addr &= 65535;
 #ifdef CDTV_DEBUG
-    write_log ("dmac_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
+    write_log (L"dmac_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
 #endif
     dmac_bput2 (addr, l >> 24);
     dmac_bput2 (addr + 1, l >> 16);
@@ -1249,7 +1249,7 @@ static void REGPARAM2 dmac_wput (uaecptr addr, uae_u32 w)
 #endif
     addr &= 65535;
 #ifdef CDTV_DEBUG
-    write_log ("dmac_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
+    write_log (L"dmac_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
 #endif
     dmac_bput2 (addr, w >> 8);
     dmac_bput2 (addr + 1, w);
@@ -1264,13 +1264,13 @@ static void REGPARAM2 dmac_bput (uaecptr addr, uae_u32 b)
     b &= 0xff;
     if (addr == 0x48) {
        map_banks (&dmac_bank, b, 0x10000 >> 16, 0x10000);
-       write_log ("CDTV DMAC autoconfigured at %02X0000\n", b);
+       write_log (L"CDTV DMAC autoconfigured at %02X0000\n", b);
        configured = 1;
        expamem_next();
        return;
     }
     if (addr == 0x4c) {
-       write_log ("CDTV DMAC AUTOCONFIG SHUT-UP!\n");
+       write_log (L"CDTV DMAC AUTOCONFIG SHUT-UP!\n");
        configured = 1;
        expamem_next();
        return;
@@ -1291,14 +1291,14 @@ static void open_unit(void)
     unitnum = -1;
     cdtv_reset ();
     if (!device_func_init (DEVICE_TYPE_ANY)) {
-       write_log ("no CDROM support\n");
+       write_log (L"no CDROM support\n");
        return;
     }
     for (unitnum = 0; unitnum < MAX_TOTAL_DEVICES; unitnum++) {
        if (sys_command_open (DF_IOCTL, unitnum)) {
            di2 = sys_command_info (DF_IOCTL, unitnum, &di1);
            if (di2 && di2->type == INQ_ROMD) {
-               write_log ("%s: ", di2->label);
+               write_log (L"%s: ", di2->label);
                if (first < 0)
                    first = unitnum;
                if (get_toc () > 0) {
@@ -1306,18 +1306,18 @@ static void open_unit(void)
                        uae_u8 *p = sys_command_cd_read (DF_IOCTL, unitnum, 16);
                        if (p) {
                            if (!memcmp (p + 8, "CDTV", 4)) {
-                               write_log ("CDTV\n");
+                               write_log (L"CDTV\n");
                                if (cdtvunit < 0)
                                    cdtvunit = unitnum;
                            }
                        }
                    } else {
-                       write_log ("Audio CD\n");
+                       write_log (L"Audio CD\n");
                        if (audiounit < 0)
                            audiounit = unitnum;
                    }
                } else {
-                   write_log ("TOC read failed\n");
+                   write_log (L"TOC read failed\n");
                }
            }
            sys_command_close (DF_IOCTL, unitnum);
@@ -1382,7 +1382,7 @@ static uae_u32 REGPARAM2 dmac_lgeti (uaecptr addr)
 addrbank dmac_bank = {
     dmac_lget, dmac_wget, dmac_bget,
     dmac_lput, dmac_wput, dmac_bput,
-    default_xlate, default_check, NULL, "CDTV DMAC/CD Controller",
+    default_xlate, default_check, NULL, L"CDTV DMAC/CD Controller",
     dmac_lgeti, dmac_wgeti, ABFLAG_IO
 };
 
@@ -1409,7 +1409,7 @@ void cdtv_loadcardmem(uae_u8 *p, int size)
     struct zfile *f;
 
     memset (p, 0, size);
-    f = zfile_fopen (currprefs.flashfile, "rb");
+    f = zfile_fopen (currprefs.flashfile, L"rb");
     if (!f)
        return;
     zfile_fseek (f, CDTV_NVRAM_SIZE, SEEK_SET);
@@ -1421,7 +1421,7 @@ void cdtv_savecardmem(uae_u8 *p, int size)
 {
     struct zfile *f;
 
-    f = zfile_fopen (currprefs.flashfile, "rb+");
+    f = zfile_fopen (currprefs.flashfile, L"rb+");
     if (!f)
        return;
     zfile_fseek (f, CDTV_NVRAM_SIZE, SEEK_SET);
@@ -1435,9 +1435,9 @@ static void cdtv_battram_reset (void)
     int v;
 
     memset (cdtv_battram, 0, CDTV_NVRAM_SIZE);
-    f = zfile_fopen (currprefs.flashfile, "rb+");
+    f = zfile_fopen (currprefs.flashfile, L"rb+");
     if (!f) {
-       f = zfile_fopen (currprefs.flashfile, "wb");
+       f = zfile_fopen (currprefs.flashfile, L"wb");
        if (f) {
            zfile_fwrite (cdtv_battram, CDTV_NVRAM_SIZE, 1, f);
            zfile_fclose (f);
@@ -1460,7 +1460,7 @@ void cdtv_battram_write (int addr, int v)
     if (cdtv_battram[offset] == v)
        return;
     cdtv_battram[offset] = v;
-    f = zfile_fopen (currprefs.flashfile, "rb+");
+    f = zfile_fopen (currprefs.flashfile, L"rb+");
     if (!f)
        return;
     zfile_fseek (f, offset, SEEK_SET);
@@ -1479,11 +1479,11 @@ uae_u8 cdtv_battram_read (int addr)
     return v;
 }
 
-int cdtv_add_scsi_unit(int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys)
+int cdtv_add_scsi_unit(int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys)
 {
-    return addscsi(ch, path, blocksize, readonly, devname, sectors, surfaces, reserved, bootpri, filesys, 1);
+    return addscsi (ch, path, blocksize, readonly, devname, sectors, surfaces, reserved, bootpri, filesys, 1);
 }
 
 void cdtv_free (void)
@@ -1523,7 +1523,7 @@ static void romhack (void)
 
     rl = getromlistbyids(roms);
     if (rl) {
-       write_log ("A590/A2091 BOOT ROM '%s' %d.%d\n", rl->path, rl->rd->ver, rl->rd->rev);
+       write_log (L"A590/A2091 BOOT ROM '%s' %d.%d\n", rl->path, rl->rd->ver, rl->rd->rev);
        z = zfile_fopen(rl->path, "rb");
        if (z) {
            rom_size = 16384;
@@ -1549,7 +1549,7 @@ void cdtv_init (void)
 {
     if (!thread_alive) {
        init_comm_pipe (&requests, 100, 1);
-       uae_start_thread ("cdtv", dev_thread, NULL, NULL);
+       uae_start_thread (L"cdtv", dev_thread, NULL, NULL);
        while (!thread_alive)
            sleep_millis(10);
     }
index 7f0e5334b8dbc1823975822eae1052bf049172fb..93817df5d2bba02a5df8873ff49d5d7853c25fac 100644 (file)
--- a/cfgfile.c
+++ b/cfgfile.c
@@ -34,158 +34,159 @@ static int config_newfilesystem;
 static struct strlist *temp_lines;
 static struct zfile *default_file;
 static int uaeconfig;
+static int unicode_config = 0;
 
 /* @@@ need to get rid of this... just cut part of the manual and print that
  * as a help text.  */
 struct cfg_lines
 {
-    const char *config_label, *config_help;
+    const TCHAR *config_label, *config_help;
 };
 
 static const struct cfg_lines opttable[] =
 {
-    {"help", "Prints this help" },
-    {"config_description", "" },
-    {"config_info", "" },
-    {"use_gui", "Enable the GUI?  If no, then goes straight to emulator" },
-    {"use_debugger", "Enable the debugger?" },
-    {"cpu_speed", "can be max, real, or a number between 1 and 20" },
-    {"cpu_model", "Can be 68000, 68010, 68020, 68030, 68040, 68060" },
-    {"fpu_model", "Can be 68881, 68882, 68040, 68060" },
-    {"cpu_compatible", "yes enables compatibility-mode" },
-    {"cpu_24bit_addressing", "must be set to 'no' in order for Z3mem or P96mem to work" },
-    {"autoconfig", "yes = add filesystems and extra ram" },
-    {"log_illegal_mem", "print illegal memory access by Amiga software?" },
-    {"fastmem_size", "Size in megabytes of fast-memory" },
-    {"chipmem_size", "Size in megabytes of chip-memory" },
-    {"bogomem_size", "Size in megabytes of bogo-memory at 0xC00000" },
-    {"a3000mem_size", "Size in megabytes of A3000 memory" },
-    {"gfxcard_size", "Size in megabytes of Picasso96 graphics-card memory" },
-    {"z3mem_size", "Size in megabytes of Zorro-III expansion memory" },
-    {"gfx_test_speed", "Test graphics speed?" },
-    {"gfx_framerate", "Print every nth frame" },
-    {"gfx_width", "Screen width" },
-    {"gfx_height", "Screen height" },
-    {"gfx_refreshrate", "Fullscreen refresh rate" },
-    {"gfx_vsync", "Sync screen refresh to refresh rate" },
-    {"gfx_lores", "Treat display as lo-res?" },
-    {"gfx_linemode", "Can be none, double, or scanlines" },
-    {"gfx_fullscreen_amiga", "Amiga screens are fullscreen?" },
-    {"gfx_fullscreen_picasso", "Picasso screens are fullscreen?" },
-    {"gfx_center_horizontal", "Center display horizontally?" },
-    {"gfx_center_vertical", "Center display vertically?" },
-    {"gfx_colour_mode", "" },
-    {"32bit_blits", "Enable 32 bit blitter emulation" },
-    {"immediate_blits", "Perform blits immediately" },
-    {"show_leds", "LED display" },
-    {"keyboard_leds", "Keyboard LEDs" },
-    {"gfxlib_replacement", "Use graphics.library replacement?" },
-    {"sound_output", "" },
-    {"sound_frequency", "" },
-    {"sound_bits", "" },
-    {"sound_channels", "" },
-    {"sound_max_buff", "" },
-    {"comp_trustbyte", "How to access bytes in compiler (direct/indirect/indirectKS/afterPic" },
-    {"comp_trustword", "How to access words in compiler (direct/indirect/indirectKS/afterPic" },
-    {"comp_trustlong", "How to access longs in compiler (direct/indirect/indirectKS/afterPic" },
-    {"comp_nf", "Whether to optimize away flag generation where possible" },
-    {"comp_fpu", "Whether to provide JIT FPU emulation" },
-    {"compforcesettings", "Whether to force the JIT compiler settings" },
-    {"cachesize", "How many MB to use to buffer translated instructions"},
-    {"override_dga_address","Address from which to map the frame buffer (upper 16 bits) (DANGEROUS!)"},
-    {"avoid_cmov", "Set to yes on machines that lack the CMOV instruction" },
-    {"avoid_dga", "Set to yes if the use of DGA extension creates problems" },
-    {"avoid_vid", "Set to yes if the use of the Vidmode extension creates problems" },
-    {"parallel_on_demand", "" },
-    {"serial_on_demand", "" },
-    {"scsi", "scsi.device emulation" },
-    {"joyport0", "" },
-    {"joyport1", "" },
-    {"pci_devices", "List of PCI devices to make visible to the emulated Amiga" },
-    {"kickstart_rom_file", "Kickstart ROM image, (C) Copyright Amiga, Inc." },
-    {"kickstart_ext_rom_file", "Extended Kickstart ROM image, (C) Copyright Amiga, Inc." },
-    {"kickstart_key_file", "Key-file for encrypted ROM images (from Cloanto's Amiga Forever)" },
-    {"flash_ram_file", "Flash/battery backed RAM image file." },
-    {"cart_file", "Freezer cartridge ROM image file." },
-    {"floppy0", "Diskfile for drive 0" },
-    {"floppy1", "Diskfile for drive 1" },
-    {"floppy2", "Diskfile for drive 2" },
-    {"floppy3", "Diskfile for drive 3" },
-    {"hardfile", "access,sectors, surfaces, reserved, blocksize, path format" },
-    {"filesystem", "access,'Amiga volume-name':'host directory path' - where 'access' can be 'read-only' or 'read-write'" },
-    {"catweasel", "Catweasel board io base address" }
+    {L"help", L"Prints this help" },
+    {L"config_description", L"" },
+    {L"config_info", L"" },
+    {L"use_gui", L"Enable the GUI?  If no, then goes straight to emulator" },
+    {L"use_debugger", L"Enable the debugger?" },
+    {L"cpu_speed", L"can be max, real, or a number between 1 and 20" },
+    {L"cpu_model", L"Can be 68000, 68010, 68020, 68030, 68040, 68060" },
+    {L"fpu_model", L"Can be 68881, 68882, 68040, 68060" },
+    {L"cpu_compatible", L"yes enables compatibility-mode" },
+    {L"cpu_24bit_addressing", L"must be set to 'no' in order for Z3mem or P96mem to work" },
+    {L"autoconfig", L"yes = add filesystems and extra ram" },
+    {L"log_illegal_mem", L"print illegal memory access by Amiga software?" },
+    {L"fastmem_size", L"Size in megabytes of fast-memory" },
+    {L"chipmem_size", L"Size in megabytes of chip-memory" },
+    {L"bogomem_size", L"Size in megabytes of bogo-memory at 0xC00000" },
+    {L"a3000mem_size", L"Size in megabytes of A3000 memory" },
+    {L"gfxcard_size", L"Size in megabytes of Picasso96 graphics-card memory" },
+    {L"z3mem_size", L"Size in megabytes of Zorro-III expansion memory" },
+    {L"gfx_test_speed", L"Test graphics speed?" },
+    {L"gfx_framerate", L"Print every nth frame" },
+    {L"gfx_width", L"Screen width" },
+    {L"gfx_height", L"Screen height" },
+    {L"gfx_refreshrate", L"Fullscreen refresh rate" },
+    {L"gfx_vsync", L"Sync screen refresh to refresh rate" },
+    {L"gfx_lores", L"Treat display as lo-res?" },
+    {L"gfx_linemode", L"Can be none, double, or scanlines" },
+    {L"gfx_fullscreen_amiga", L"Amiga screens are fullscreen?" },
+    {L"gfx_fullscreen_picasso", L"Picasso screens are fullscreen?" },
+    {L"gfx_center_horizontal", L"Center display horizontally?" },
+    {L"gfx_center_vertical", L"Center display vertically?" },
+    {L"gfx_colour_mode", L"" },
+    {L"32bit_blits", L"Enable 32 bit blitter emulation" },
+    {L"immediate_blits", L"Perform blits immediately" },
+    {L"show_leds", L"LED display" },
+    {L"keyboard_leds", L"Keyboard LEDs" },
+    {L"gfxlib_replacement", L"Use graphics.library replacement?" },
+    {L"sound_output", L"" },
+    {L"sound_frequency", L"" },
+    {L"sound_bits", L"" },
+    {L"sound_channels", L"" },
+    {L"sound_max_buff", L"" },
+    {L"comp_trustbyte", L"How to access bytes in compiler (direct/indirect/indirectKS/afterPic" },
+    {L"comp_trustword", L"How to access words in compiler (direct/indirect/indirectKS/afterPic" },
+    {L"comp_trustlong", L"How to access longs in compiler (direct/indirect/indirectKS/afterPic" },
+    {L"comp_nf", L"Whether to optimize away flag generation where possible" },
+    {L"comp_fpu", L"Whether to provide JIT FPU emulation" },
+    {L"compforcesettings", L"Whether to force the JIT compiler settings" },
+    {L"cachesize", L"How many MB to use to buffer translated instructions"},
+    {L"override_dga_address",L"Address from which to map the frame buffer (upper 16 bits) (DANGEROUS!)"},
+    {L"avoid_cmov", L"Set to yes on machines that lack the CMOV instruction" },
+    {L"avoid_dga", L"Set to yes if the use of DGA extension creates problems" },
+    {L"avoid_vid", L"Set to yes if the use of the Vidmode extension creates problems" },
+    {L"parallel_on_demand", L"" },
+    {L"serial_on_demand", L"" },
+    {L"scsi", L"scsi.device emulation" },
+    {L"joyport0", L"" },
+    {L"joyport1", L"" },
+    {L"pci_devices", L"List of PCI devices to make visible to the emulated Amiga" },
+    {L"kickstart_rom_file", L"Kickstart ROM image, (C) Copyright Amiga, Inc." },
+    {L"kickstart_ext_rom_file", L"Extended Kickstart ROM image, (C) Copyright Amiga, Inc." },
+    {L"kickstart_key_file", L"Key-file for encrypted ROM images (from Cloanto's Amiga Forever)" },
+    {L"flash_ram_file", L"Flash/battery backed RAM image file." },
+    {L"cart_file", L"Freezer cartridge ROM image file." },
+    {L"floppy0", L"Diskfile for drive 0" },
+    {L"floppy1", L"Diskfile for drive 1" },
+    {L"floppy2", L"Diskfile for drive 2" },
+    {L"floppy3", L"Diskfile for drive 3" },
+    {L"hardfile", L"access,sectors, surfaces, reserved, blocksize, path format" },
+    {L"filesystem", L"access,'Amiga volume-name':'host directory path' - where 'access' can be 'read-only' or 'read-write'" },
+    {L"catweasel", L"Catweasel board io base address" }
 };
 
-static const char *guimode1[] = { "no", "yes", "nowait", 0 };
-static const char *guimode2[] = { "false", "true", "nowait", 0 };
-static const char *guimode3[] = { "0", "1", "nowait", 0 };
-static const char *csmode[] = { "ocs", "ecs_agnus", "ecs_denise", "ecs", "aga", 0 };
-static const char *linemode1[] = { "none", "double", "scanlines", 0 };
-static const char *linemode2[] = { "n", "d", "s", 0 };
-static const char *speedmode[] = { "max", "real", 0 };
-static const char *colormode1[] = { "8bit", "15bit", "16bit", "8bit_dither", "4bit_dither", "32bit", 0 };
-static const char *colormode2[] = { "8", "15", "16", "8d", "4d", "32", 0 };
-static const char *soundmode1[] = { "none", "interrupts", "normal", "exact", 0 };
-static const char *soundmode2[] = { "none", "interrupts", "good", "best", 0 };
-static const char *centermode1[] = { "none", "simple", "smart", 0 };
-static const char *centermode2[] = { "false", "true", "smart", 0 };
-static const char *stereomode[] = { "mono", "stereo", "clonedstereo", "4ch", "clonedstereo6ch", "6ch", "mixed", 0 };
-static const char *interpolmode[] = { "none", "anti", "sinc", "rh", "crux", 0 };
-static const char *collmode[] = { "none", "sprites", "playfields", "full", 0 };
-static const char *compmode[] = { "direct", "indirect", "indirectKS", "afterPic", 0 };
-static const char *flushmode[] = { "soft", "hard", 0 };
-static const char *kbleds[] = { "none", "POWER", "DF0", "DF1", "DF2", "DF3", "HD", "CD", 0 };
-static const char *onscreenleds[] = { "false", "true", "rtg", "both", 0 };
-static const char *soundfiltermode1[] = { "off", "emulated", "on", 0 };
-static const char *soundfiltermode2[] = { "standard", "enhanced", 0 };
-static const char *lorestype1[] = { "lores", "hires", "superhires" };
-static const char *lorestype2[] = { "true", "false" };
-static const char *loresmode[] = { "normal", "filtered", 0 };
+static const TCHAR *guimode1[] = { L"no", L"yes", L"nowait", 0 };
+static const TCHAR *guimode2[] = { L"false", L"true", L"nowait", 0 };
+static const TCHAR *guimode3[] = { L"0", L"1", L"nowait", 0 };
+static const TCHAR *csmode[] = { L"ocs", L"ecs_agnus", L"ecs_denise", L"ecs", L"aga", 0 };
+static const TCHAR *linemode1[] = { L"none", L"double", L"scanlines", 0 };
+static const TCHAR *linemode2[] = { L"n", L"d", L"s", 0 };
+static const TCHAR *speedmode[] = { L"max", L"real", 0 };
+static const TCHAR *colormode1[] = { L"8bit", L"15bit", L"16bit", L"8bit_dither", L"4bit_dither", L"32bit", 0 };
+static const TCHAR *colormode2[] = { L"8", L"15", L"16", L"8d", L"4d", L"32", 0 };
+static const TCHAR *soundmode1[] = { L"none", L"interrupts", L"normal", L"exact", 0 };
+static const TCHAR *soundmode2[] = { L"none", L"interrupts", L"good", L"best", 0 };
+static const TCHAR *centermode1[] = { L"none", L"simple", L"smart", 0 };
+static const TCHAR *centermode2[] = { L"false", L"true", L"smart", 0 };
+static const TCHAR *stereomode[] = { L"mono", L"stereo", L"clonedstereo", L"4ch", L"clonedstereo6ch", L"6ch", L"mixed", 0 };
+static const TCHAR *interpolmode[] = { L"none", L"anti", L"sinc", L"rh", L"crux", 0 };
+static const TCHAR *collmode[] = { L"none", L"sprites", L"playfields", L"full", 0 };
+static const TCHAR *compmode[] = { L"direct", L"indirect", L"indirectKS", L"afterPic", 0 };
+static const TCHAR *flushmode[] = { L"soft", L"hard", 0 };
+static const TCHAR *kbleds[] = { L"none", L"POWER", L"DF0", L"DF1", L"DF2", L"DF3", L"HD", L"CD", 0 };
+static const TCHAR *onscreenleds[] = { L"false", L"true", L"rtg", L"both", 0 };
+static const TCHAR *soundfiltermode1[] = { L"off", L"emulated", L"on", 0 };
+static const TCHAR *soundfiltermode2[] = { L"standard", L"enhanced", 0 };
+static const TCHAR *lorestype1[] = { L"lores", L"hires", L"superhires" };
+static const TCHAR *lorestype2[] = { L"true", L"false" };
+static const TCHAR *loresmode[] = { L"normal", L"filtered", 0 };
 #ifdef GFXFILTER
-static const char *filtermode1[] = { "no_16", "bilinear_16", "no_32", "bilinear_32", 0 };
-static const char *filtermode2[] = { "0x", "1x", "2x", "3x", "4x", 0 };
+static const TCHAR *filtermode1[] = { L"no_16", L"bilinear_16", L"no_32", L"bilinear_32", 0 };
+static const TCHAR *filtermode2[] = { L"0x", L"1x", L"2x", L"3x", L"4x", 0 };
 #endif
-static const char *cartsmode[] = { "none", "hrtmon", 0 };
-static const char *idemode[] = { "none", "a600/a1200", "a4000", 0 };
-static const char *rtctype[] = { "none", "MSM6242B", "RP5C01A", 0 };
-static const char *ciaatodmode[] = { "vblank", "50hz", "60hz", 0 };
-static const char *ksmirrortype[] = { "none", "e0", "a8+e0", 0 };
-static const char *cscompa[] = {
-    "-", "Generic", "CDTV", "CD32", "A500", "A500+", "A600",
-    "A1000", "A1200", "A2000", "A3000", "A3000T", "A4000", "A4000T", 0
+static const TCHAR *cartsmode[] = { L"none", L"hrtmon", 0 };
+static const TCHAR *idemode[] = { L"none", L"a600/a1200", L"a4000", 0 };
+static const TCHAR *rtctype[] = { L"none", L"MSM6242B", L"RP5C01A", 0 };
+static const TCHAR *ciaatodmode[] = { L"vblank", L"50hz", L"60hz", 0 };
+static const TCHAR *ksmirrortype[] = { L"none", L"e0", L"a8+e0", 0 };
+static const TCHAR *cscompa[] = {
+    L"-", L"Generic", L"CDTV", L"CD32", L"A500", L"A500+", L"A600",
+    L"A1000", L"A1200", L"A2000", L"A3000", L"A3000T", L"A4000", L"A4000T", 0
 };
 /* 3-state boolean! */
-static const char *fullmodes[] = { "false", "true", /* "FILE_NOT_FOUND", */ "fullwindow", 0 };
+static const TCHAR *fullmodes[] = { L"false", L"true", /* "FILE_NOT_FOUND", */ L"fullwindow", 0 };
 /* bleh for compatibility */
-static const char *scsimode[] = { "false", "true", "scsi", 0 };
-static const char *maxhoriz[] = { "lores", "hires", "superhires", 0 };
-static const char *maxvert[] = { "nointerlace", "interlace", 0 };
-static const char *abspointers[] = { "none", "mousehack", "tablet", 0 };
-static const char *magiccursors[] = { "both", "native", "host", 0 };
-static const char *autoscale[] = { "none", "scale", "resize", 0 };
-
-static const char *obsolete[] = {
-    "accuracy", "gfx_opengl", "gfx_32bit_blits", "32bit_blits",
-    "gfx_immediate_blits", "gfx_ntsc", "win32", "gfx_filter_bits",
-    "sound_pri_cutoff", "sound_pri_time", "sound_min_buff", "sound_bits",
-    "gfx_test_speed", "gfxlib_replacement", "enforcer", "catweasel_io",
-    "kickstart_key_file", "fast_copper", "sound_adjust",
-    "serial_hardware_dtrdsr", "gfx_filter_upscale",
-    "gfx_correct_aspect",
+static const TCHAR *scsimode[] = { L"false", L"true", L"scsi", 0 };
+static const TCHAR *maxhoriz[] = { L"lores", L"hires", L"superhires", 0 };
+static const TCHAR *maxvert[] = { L"nointerlace", L"interlace", 0 };
+static const TCHAR *abspointers[] = { L"none", L"mousehack", L"tablet", 0 };
+static const TCHAR *magiccursors[] = { L"both", L"native", L"host", 0 };
+static const TCHAR *autoscale[] = { L"none", L"scale", L"resize", 0 };
+
+static const TCHAR *obsolete[] = {
+    L"accuracy", L"gfx_opengl", L"gfx_32bit_blits", L"32bit_blits",
+    L"gfx_immediate_blits", L"gfx_ntsc", L"win32", L"gfx_filter_bits",
+    L"sound_pri_cutoff", L"sound_pri_time", L"sound_min_buff", L"sound_bits",
+    L"gfx_test_speed", L"gfxlib_replacement", L"enforcer", L"catweasel_io",
+    L"kickstart_key_file", L"fast_copper", L"sound_adjust",
+    L"serial_hardware_dtrdsr", L"gfx_filter_upscale",
+    L"gfx_correct_aspect",
     NULL
 };
 
-#define UNEXPANDED "$(FILE_PATH)"
+#define UNEXPANDED L"$(FILE_PATH)"
 
-static void trimws (char *s)
+static void trimws (TCHAR *s)
 {
     /* Delete trailing whitespace.  */
-    int len = strlen (s);
-    while (len > 0 && strcspn (s + len - 1, "\t \r\n") == 0)
+    int len = _tcslen (s);
+    while (len > 0 && _tcscspn (s + len - 1, L"\t \r\n") == 0)
         s[--len] = '\0';
 }
 
-static int match_string (const char *table[], const char *str)
+static int match_string (const TCHAR *table[], const TCHAR *str)
 {
     int i;
     for (i = 0; table[i] != 0; i++)
@@ -194,101 +195,115 @@ static int match_string (const char *table[], const char *str)
     return -1;
 }
 
-char *cfgfile_subst_path (const char *path, const char *subst, const char *file)
+TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *file)
 {
     /* @@@ use strcasecmp for some targets.  */
-    if (strlen (path) > 0 && strncmp (file, path, strlen (path)) == 0) {
+    if (_tcslen (path) > 0 && _tcsncmp (file, path, _tcslen (path)) == 0) {
        int l;
-       char *p = xmalloc (strlen (file) + strlen (subst) + 2);
-       strcpy (p, subst);
-       l = strlen (p);
+       TCHAR *p = xmalloc ((_tcslen (file) + _tcslen (subst) + 2) * sizeof (TCHAR));
+       _tcscpy (p, subst);
+       l = _tcslen (p);
        while (l > 0 && p[l - 1] == '/')
            p[--l] = '\0';
-       l = strlen (path);
+       l = _tcslen (path);
        while (file[l] == '/')
            l++;
-       strcat (p, "/"); strcat (p, file + l);
+       _tcscat (p, L"/"); _tcscat (p, file + l);
        return p;
     }
     return my_strdup (file);
 }
 
-static int isdefault (const char *s)
+static int isdefault (const TCHAR *s)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     if (!default_file || uaeconfig)
        return 0;
     zfile_fseek (default_file, 0, SEEK_SET);
-    while (zfile_fgets (tmp, sizeof tmp, default_file)) {
-       if (!strcmp (tmp, s))
+    while (zfile_fgets (tmp, sizeof tmp / sizeof (TCHAR), default_file)) {
+       if (!_tcscmp (tmp, s))
            return 1;
     }
     return 0;
 }
 
-void cfgfile_write (struct zfile *f, char *format,...)
+static size_t cfg_write (void *b, struct zfile *z)
+{
+    size_t v;
+    if (unicode_config) {
+       v = zfile_fwrite (b, _tcslen (b), sizeof (TCHAR), z);
+    } else {
+       char *s = ua (b);
+       v = zfile_fwrite (s, strlen(s), 1, z);
+       xfree (s);
+    }
+    return v;
+}
+
+
+void cfgfile_write (struct zfile *f, TCHAR *format,...)
 {
     va_list parms;
-    char tmp[CONFIG_BLEN];
+    TCHAR tmp[CONFIG_BLEN];
 
     va_start (parms, format);
-    vsprintf (tmp, format, parms);
-    zfile_fwrite (tmp, 1, strlen (tmp), f);
+    _vstprintf (tmp, format, parms);
+    cfg_write (tmp, f);
     va_end (parms);
 }
 
-void cfgfile_dwrite (struct zfile *f, char *format,...)
+void cfgfile_dwrite (struct zfile *f, TCHAR *format,...)
 {
     va_list parms;
-    char tmp[CONFIG_BLEN];
+    TCHAR tmp[CONFIG_BLEN];
 
     va_start (parms, format);
-    vsprintf (tmp, format, parms);
+    _vstprintf (tmp, format, parms);
     if (!isdefault (tmp))
-       zfile_fwrite (tmp, 1, strlen (tmp), f);
+       cfg_write (tmp, f);
     va_end (parms);
 }
 
-void cfgfile_target_write (struct zfile *f, char *format,...)
+void cfgfile_target_write (struct zfile *f, TCHAR *format,...)
 {
     va_list parms;
-    char tmp[CONFIG_BLEN];
+    TCHAR tmp[CONFIG_BLEN];
 
     va_start (parms, format);
-    vsprintf (tmp + strlen (TARGET_NAME) + 1, format, parms);
-    memcpy (tmp, TARGET_NAME, strlen (TARGET_NAME));
-    tmp[strlen (TARGET_NAME)] = '.';
-    zfile_fwrite (tmp, 1, strlen (tmp), f);
+    _vstprintf (tmp + _tcslen (TARGET_NAME) + 1, format, parms);
+    memcpy (tmp, TARGET_NAME, _tcslen (TARGET_NAME) * sizeof (TCHAR));
+    tmp[_tcslen (TARGET_NAME)] = '.';
+    cfg_write (tmp, f);
     va_end (parms);
 }
 
-void cfgfile_target_dwrite (struct zfile *f, char *format,...)
+void cfgfile_target_dwrite (struct zfile *f, TCHAR *format,...)
 {
     va_list parms;
-    char tmp[CONFIG_BLEN];
+    TCHAR tmp[CONFIG_BLEN];
 
     va_start (parms, format);
-    vsprintf (tmp + strlen (TARGET_NAME) + 1, format, parms);
-    memcpy (tmp, TARGET_NAME, strlen (TARGET_NAME));
-    tmp[strlen (TARGET_NAME)] = '.';
+    _vstprintf (tmp + _tcslen (TARGET_NAME) + 1, format, parms);
+    memcpy (tmp, TARGET_NAME, _tcslen (TARGET_NAME) * sizeof (TCHAR));
+    tmp[_tcslen (TARGET_NAME)] = '.';
     if (!isdefault (tmp))
-       zfile_fwrite (tmp, 1, strlen (tmp), f);
+       cfg_write (tmp, f);
     va_end (parms);
 }
 
-static void write_filesys_config (struct uae_prefs *p, const char *unexpanded,
-                                 const char *default_path, struct zfile *f)
+static void write_filesys_config (struct uae_prefs *p, const TCHAR *unexpanded,
+                                 const TCHAR *default_path, struct zfile *f)
 {
     int i;
-    char tmp[MAX_DPATH], tmp2[MAX_DPATH];
-    char *hdcontrollers[] = { "uae",
-       "ide0", "ide1", "ide2", "ide3",
-       "scsi0", "scsi1", "scsi2", "scsi3", "scsi4", "scsi5", "scsi6",
-       "scsram", "scside" }; /* scsram = smart card sram = pcmcia sram card */
+    TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR *hdcontrollers[] = { L"uae",
+       L"ide0", L"ide1", L"ide2", L"ide3",
+       L"scsi0", L"scsi1", L"scsi2", L"scsi3", L"scsi4", L"scsi5", L"scsi6",
+       L"scsram", L"scside" }; /* scsram = smart card sram = pcmcia sram card */
 
     for (i = 0; i < p->mountitems; i++) {
        struct uaedev_config_info *uci = &p->mountconfig[i];
-       char *str;
+       TCHAR *str;
         int bp = uci->bootpri;
 
        if (!uci->autoboot)
@@ -297,31 +312,31 @@ static void write_filesys_config (struct uae_prefs *p, const char *unexpanded,
            bp = -129;
        str = cfgfile_subst_path (default_path, unexpanded, uci->rootdir);
        if (!uci->ishdf) {
-           sprintf (tmp, "%s,%s:%s:%s,%d\n", uci->readonly ? "ro" : "rw",
-               uci->devname ? uci->devname : "", uci->volname, str, bp);
-           sprintf (tmp2, "filesystem2=%s", tmp);
+           _stprintf (tmp, L"%s,%s:%s:%s,%d\n", uci->readonly ? L"ro" : L"rw",
+               uci->devname ? uci->devname : L"", uci->volname, str, bp);
+           _stprintf (tmp2, L"filesystem2=%s", tmp);
            zfile_fputs (f, tmp2);
 #if 0
-           sprintf (tmp2, "filesystem=%s,%s:%s\n", uci->readonly ? "ro" : "rw",
+           _stprintf (tmp2, L"filesystem=%s,%s:%s\n", uci->readonly ? L"ro" : L"rw",
                uci->volname, str);
            zfile_fputs (f, tmp2);
 #endif
        } else {
-           sprintf (tmp, "%s,%s:%s,%d,%d,%d,%d,%d,%s,%s\n",
-                    uci->readonly ? "ro" : "rw",
-                    uci->devname ? uci->devname : "", str,
+           _stprintf (tmp, L"%s,%s:%s,%d,%d,%d,%d,%d,%s,%s\n",
+                    uci->readonly ? L"ro" : L"rw",
+                    uci->devname ? uci->devname : L"", str,
                     uci->sectors, uci->surfaces, uci->reserved, uci->blocksize,
-                    bp, uci->filesys ? uci->filesys : "", hdcontrollers[uci->controller]);
-           sprintf (tmp2, "hardfile2=%s", tmp);
+                    bp, uci->filesys ? uci->filesys : L"", hdcontrollers[uci->controller]);
+           _stprintf (tmp2, L"hardfile2=%s", tmp);
            zfile_fputs (f, tmp2);
 #if 0
-           sprintf (tmp2, "hardfile=%s,%d,%d,%d,%d,%s\n",
+           _stprintf (tmp2, L"hardfile=%s,%d,%d,%d,%d,%s\n",
                     uci->readonly ? "ro" : "rw", uci->sectors,
                     uci->surfaces, uci->reserved, uci->blocksize, str);
            zfile_fputs (f, tmp2);
 #endif
        }
-       sprintf (tmp2, "uaehf%d=%s,%s", i, uci->ishdf ? "hdf" : "dir", tmp);
+       _stprintf (tmp2, L"uaehf%d=%s,%s", i, uci->ishdf ? L"hdf" : L"dir", tmp);
        zfile_fputs (f, tmp2);
        xfree (str);
     }
@@ -329,7 +344,7 @@ static void write_filesys_config (struct uae_prefs *p, const char *unexpanded,
 
 static void write_compatibility_cpu (struct zfile *f, struct uae_prefs *p)
 {
-    char tmp[100];
+    TCHAR tmp[100];
     int model;
 
     model = p->cpu_model;
@@ -338,202 +353,202 @@ static void write_compatibility_cpu (struct zfile *f, struct uae_prefs *p)
     if (model == 68060)
        model = 68040;
     if (p->address_space_24 && model == 68020)
-       strcpy (tmp, "68ec020");
+       _tcscpy (tmp, L"68ec020");
     else
-       sprintf(tmp, "%d", model);
+       _stprintf (tmp, L"%d", model);
     if (model == 68020 && (p->fpu_model == 68881 || p->fpu_model == 68882))
-       strcat(tmp,"/68881");
-    cfgfile_write (f, "cpu_type=%s\n", tmp);
+       _tcscat (tmp, L"/68881");
+    cfgfile_write (f, L"cpu_type=%s\n", tmp);
 }
 
 void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
 {
     struct strlist *sl;
-    char *str;
+    TCHAR *str;
     int i;
 
-    cfgfile_write (f, "config_description=%s\n", p->description);
-    cfgfile_write (f, "config_hardware=%s\n", (type & CONFIG_TYPE_HARDWARE) ? "true" : "false");
-    cfgfile_write (f, "config_host=%s\n", (type & CONFIG_TYPE_HOST) ? "true" : "false");
+    cfgfile_write (f, L"config_description=%s\n", p->description);
+    cfgfile_write (f, L"config_hardware=%s\n", (type & CONFIG_TYPE_HARDWARE) ? L"true" : L"false");
+    cfgfile_write (f, L"config_host=%s\n", (type & CONFIG_TYPE_HOST) ? L"true" : L"false");
     if (p->info[0])
-       cfgfile_write (f, "config_info=%s\n", p->info);
-    cfgfile_write (f, "config_version=%d.%d.%d\n", UAEMAJOR, UAEMINOR, UAESUBREV);
-    cfgfile_write (f, "config_hardware_path=%s\n", p->config_hardware_path);
-    cfgfile_write (f, "config_host_path=%s\n", p->config_host_path);
+       cfgfile_write (f, L"config_info=%s\n", p->info);
+    cfgfile_write (f, L"config_version=%d.%d.%d\n", UAEMAJOR, UAEMINOR, UAESUBREV);
+    cfgfile_write (f, L"config_hardware_path=%s\n", p->config_hardware_path);
+    cfgfile_write (f, L"config_host_path=%s\n", p->config_host_path);
 
     for (sl = p->all_lines; sl; sl = sl->next) {
        if (sl->unknown)
-           cfgfile_write (f, "%s=%s\n", sl->option, sl->value);
+           cfgfile_write (f, L"%s=%s\n", sl->option, sl->value);
     }
 
-    cfgfile_write (f, "%s.rom_path=%s\n", TARGET_NAME, p->path_rom);
-    cfgfile_write (f, "%s.floppy_path=%s\n", TARGET_NAME, p->path_floppy);
-    cfgfile_write (f, "%s.hardfile_path=%s\n", TARGET_NAME, p->path_hardfile);
+    cfgfile_write (f, L"%s.rom_path=%s\n", TARGET_NAME, p->path_rom);
+    cfgfile_write (f, L"%s.floppy_path=%s\n", TARGET_NAME, p->path_floppy);
+    cfgfile_write (f, L"%s.hardfile_path=%s\n", TARGET_NAME, p->path_hardfile);
 
-    cfgfile_write (f, "; host-specific\n");
+    cfgfile_write (f, L"; host-specific\n");
 
     target_save_options (f, p);
 
-    cfgfile_write (f, "; common\n");
+    cfgfile_write (f, L"; common\n");
 
-    cfgfile_write (f, "use_gui=%s\n", guimode1[p->start_gui]);
-    cfgfile_write (f, "use_debugger=%s\n", p->start_debugger ? "true" : "false");
+    cfgfile_write (f, L"use_gui=%s\n", guimode1[p->start_gui]);
+    cfgfile_write (f, L"use_debugger=%s\n", p->start_debugger ? L"true" : L"false");
     str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romfile);
-    cfgfile_write (f, "kickstart_rom_file=%s\n", str);
+    cfgfile_write (f, L"kickstart_rom_file=%s\n", str);
     free (str);
     if (p->romident[0])
-       cfgfile_dwrite (f, "kickstart_rom=%s\n", p->romident);
+       cfgfile_dwrite (f, L"kickstart_rom=%s\n", p->romident);
     str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->romextfile);
-    cfgfile_write (f, "kickstart_ext_rom_file=%s\n", str);
+    cfgfile_write (f, L"kickstart_ext_rom_file=%s\n", str);
     free (str);
     if (p->romextident[0])
-       cfgfile_write (f, "kickstart_ext_rom=%s\n", p->romextident);
+       cfgfile_write (f, L"kickstart_ext_rom=%s\n", p->romextident);
     str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->flashfile);
-    cfgfile_write (f, "flash_file=%s\n", str);
+    cfgfile_write (f, L"flash_file=%s\n", str);
     free (str);
     str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->cartfile);
-    cfgfile_write (f, "cart_file=%s\n", str);
+    cfgfile_write (f, L"cart_file=%s\n", str);
     free (str);
     if (p->cartident[0])
-       cfgfile_write (f, "cart=%s\n", p->cartident);
-    //cfgfile_write (f, "cart_internal=%s\n", cartsmode[p->cart_internal]);
+       cfgfile_write (f, L"cart=%s\n", p->cartident);
+    //cfgfile_write (f, L"cart_internal=%s\n", cartsmode[p->cart_internal]);
     if (p->amaxromfile[0]) {
        str = cfgfile_subst_path (p->path_rom, UNEXPANDED, p->amaxromfile);
-       cfgfile_write (f, "amax_rom_file=%s\n", str);
+       cfgfile_write (f, L"amax_rom_file=%s\n", str);
        free (str);
     }
 
-    cfgfile_write (f, "kickshifter=%s\n", p->kickshifter ? "true" : "false");
+    cfgfile_write (f, L"kickshifter=%s\n", p->kickshifter ? L"true" : L"false");
 
     p->nr_floppies = 4;
     for (i = 0; i < 4; i++) {
        str = cfgfile_subst_path (p->path_floppy, UNEXPANDED, p->df[i]);
-       cfgfile_write (f, "floppy%d=%s\n", i, str);
+       cfgfile_write (f, L"floppy%d=%s\n", i, str);
        free (str);
-       cfgfile_dwrite (f, "floppy%dtype=%d\n", i, p->dfxtype[i]);
-       cfgfile_dwrite (f, "floppy%dsound=%d\n", i, p->dfxclick[i]);
+       cfgfile_dwrite (f, L"floppy%dtype=%d\n", i, p->dfxtype[i]);
+       cfgfile_dwrite (f, L"floppy%dsound=%d\n", i, p->dfxclick[i]);
        if (p->dfxclick[i] < 0 && p->dfxclickexternal[i][0])
-           cfgfile_dwrite (f, "floppy%dsoundext=%s\n", i, p->dfxclickexternal[i]);
+           cfgfile_dwrite (f, L"floppy%dsoundext=%s\n", i, p->dfxclickexternal[i]);
        if (p->dfxtype[i] < 0 && p->nr_floppies > i)
            p->nr_floppies = i;
     }
     for (i = 0; i < MAX_SPARE_DRIVES; i++) {
        if (p->dfxlist[i][0])
-           cfgfile_dwrite (f, "diskimage%d=%s\n", i, p->dfxlist[i]);
-    }
-
-    cfgfile_write (f, "nr_floppies=%d\n", p->nr_floppies);
-    cfgfile_write (f, "floppy_speed=%d\n", p->floppy_speed);
-    cfgfile_write (f, "floppy_volume=%d\n", p->dfxclickvolume);
-    cfgfile_write (f, "parallel_on_demand=%s\n", p->parallel_demand ? "true" : "false");
-    cfgfile_write (f, "serial_on_demand=%s\n", p->serial_demand ? "true" : "false");
-    cfgfile_write (f, "serial_hardware_ctsrts=%s\n", p->serial_hwctsrts ? "true" : "false");
-    cfgfile_write (f, "serial_direct=%s\n", p->serial_direct ? "true" : "false");
-    cfgfile_write (f, "scsi=%s\n", scsimode[p->scsi]);
-    cfgfile_write (f, "uaeserial=%s\n", p->uaeserial ? "true" : "false");
-    cfgfile_write (f, "sana2=%s\n", p->sana2 ? "true" : "false");
-
-    cfgfile_write (f, "sound_output=%s\n", soundmode1[p->produce_sound]);
-    cfgfile_write (f, "sound_channels=%s\n", stereomode[p->sound_stereo]);
-    cfgfile_write (f, "sound_stereo_separation=%d\n", p->sound_stereo_separation);
-    cfgfile_write (f, "sound_stereo_mixing_delay=%d\n", p->sound_mixed_stereo_delay >= 0 ? p->sound_mixed_stereo_delay : 0);
-    cfgfile_write (f, "sound_max_buff=%d\n", p->sound_maxbsiz);
-    cfgfile_write (f, "sound_frequency=%d\n", p->sound_freq);
-    cfgfile_write (f, "sound_latency=%d\n", p->sound_latency);
-    cfgfile_write (f, "sound_interpol=%s\n", interpolmode[p->sound_interpol]);
-    cfgfile_write (f, "sound_filter=%s\n", soundfiltermode1[p->sound_filter]);
-    cfgfile_write (f, "sound_filter_type=%s\n", soundfiltermode2[p->sound_filter_type]);
-    cfgfile_write (f, "sound_volume=%d\n", p->sound_volume);
-    cfgfile_write (f, "sound_auto=%s\n", p->sound_auto ? "yes" : "no");
-    cfgfile_write (f, "sound_stereo_swap_paula=%s\n", p->sound_stereo_swap_paula ? "yes" : "no");
-    cfgfile_write (f, "sound_stereo_swap_ahi=%s\n", p->sound_stereo_swap_ahi ? "yes" : "no");
-
-    cfgfile_write (f, "comp_trustbyte=%s\n", compmode[p->comptrustbyte]);
-    cfgfile_write (f, "comp_trustword=%s\n", compmode[p->comptrustword]);
-    cfgfile_write (f, "comp_trustlong=%s\n", compmode[p->comptrustlong]);
-    cfgfile_write (f, "comp_trustnaddr=%s\n", compmode[p->comptrustnaddr]);
-    cfgfile_write (f, "comp_nf=%s\n", p->compnf ? "true" : "false");
-    cfgfile_write (f, "comp_constjump=%s\n", p->comp_constjump ? "true" : "false");
-    cfgfile_write (f, "comp_oldsegv=%s\n", p->comp_oldsegv ? "true" : "false");
-
-    cfgfile_write (f, "comp_flushmode=%s\n", flushmode[p->comp_hardflush]);
-    cfgfile_write (f, "compfpu=%s\n", p->compfpu ? "true" : "false");
-    cfgfile_write (f, "fpu_strict=%s\n", p->fpu_strict ? "true" : "false");
-    cfgfile_write (f, "comp_midopt=%s\n", p->comp_midopt ? "true" : "false");
-    cfgfile_write (f, "comp_lowopt=%s\n", p->comp_lowopt ? "true" : "false");
-    cfgfile_write (f, "avoid_cmov=%s\n", p->avoid_cmov ? "true" : "false" );
-    cfgfile_write (f, "avoid_dga=%s\n", p->avoid_dga ? "true" : "false" );
-    cfgfile_write (f, "avoid_vid=%s\n", p->avoid_vid ? "true" : "false" );
-    cfgfile_write (f, "cachesize=%d\n", p->cachesize);
+           cfgfile_dwrite (f, L"diskimage%d=%s\n", i, p->dfxlist[i]);
+    }
+
+    cfgfile_write (f, L"nr_floppies=%d\n", p->nr_floppies);
+    cfgfile_write (f, L"floppy_speed=%d\n", p->floppy_speed);
+    cfgfile_write (f, L"floppy_volume=%d\n", p->dfxclickvolume);
+    cfgfile_write (f, L"parallel_on_demand=%s\n", p->parallel_demand ? L"true" : L"false");
+    cfgfile_write (f, L"serial_on_demand=%s\n", p->serial_demand ? L"true" : L"false");
+    cfgfile_write (f, L"serial_hardware_ctsrts=%s\n", p->serial_hwctsrts ? L"true" : L"false");
+    cfgfile_write (f, L"serial_direct=%s\n", p->serial_direct ? L"true" : L"false");
+    cfgfile_write (f, L"scsi=%s\n", scsimode[p->scsi]);
+    cfgfile_write (f, L"uaeserial=%s\n", p->uaeserial ? L"true" : L"false");
+    cfgfile_write (f, L"sana2=%s\n", p->sana2 ? L"true" : L"false");
+
+    cfgfile_write (f, L"sound_output=%s\n", soundmode1[p->produce_sound]);
+    cfgfile_write (f, L"sound_channels=%s\n", stereomode[p->sound_stereo]);
+    cfgfile_write (f, L"sound_stereo_separation=%d\n", p->sound_stereo_separation);
+    cfgfile_write (f, L"sound_stereo_mixing_delay=%d\n", p->sound_mixed_stereo_delay >= 0 ? p->sound_mixed_stereo_delay : 0);
+    cfgfile_write (f, L"sound_max_buff=%d\n", p->sound_maxbsiz);
+    cfgfile_write (f, L"sound_frequency=%d\n", p->sound_freq);
+    cfgfile_write (f, L"sound_latency=%d\n", p->sound_latency);
+    cfgfile_write (f, L"sound_interpol=%s\n", interpolmode[p->sound_interpol]);
+    cfgfile_write (f, L"sound_filter=%s\n", soundfiltermode1[p->sound_filter]);
+    cfgfile_write (f, L"sound_filter_type=%s\n", soundfiltermode2[p->sound_filter_type]);
+    cfgfile_write (f, L"sound_volume=%d\n", p->sound_volume);
+    cfgfile_write (f, L"sound_auto=%s\n", p->sound_auto ? L"yes" : L"no");
+    cfgfile_write (f, L"sound_stereo_swap_paula=%s\n", p->sound_stereo_swap_paula ? L"yes" : L"no");
+    cfgfile_write (f, L"sound_stereo_swap_ahi=%s\n", p->sound_stereo_swap_ahi ? L"yes" : L"no");
+
+    cfgfile_write (f, L"comp_trustbyte=%s\n", compmode[p->comptrustbyte]);
+    cfgfile_write (f, L"comp_trustword=%s\n", compmode[p->comptrustword]);
+    cfgfile_write (f, L"comp_trustlong=%s\n", compmode[p->comptrustlong]);
+    cfgfile_write (f, L"comp_trustnaddr=%s\n", compmode[p->comptrustnaddr]);
+    cfgfile_write (f, L"comp_nf=%s\n", p->compnf ? L"true" : L"false");
+    cfgfile_write (f, L"comp_constjump=%s\n", p->comp_constjump ? L"true" : L"false");
+    cfgfile_write (f, L"comp_oldsegv=%s\n", p->comp_oldsegv ? L"true" : L"false");
+
+    cfgfile_write (f, L"comp_flushmode=%s\n", flushmode[p->comp_hardflush]);
+    cfgfile_write (f, L"compfpu=%s\n", p->compfpu ? L"true" : L"false");
+    cfgfile_write (f, L"fpu_strict=%s\n", p->fpu_strict ? L"true" : L"false");
+    cfgfile_write (f, L"comp_midopt=%s\n", p->comp_midopt ? L"true" : L"false");
+    cfgfile_write (f, L"comp_lowopt=%s\n", p->comp_lowopt ? L"true" : L"false");
+    cfgfile_write (f, L"avoid_cmov=%s\n", p->avoid_cmov ? L"true" : L"false" );
+    cfgfile_write (f, L"avoid_dga=%s\n", p->avoid_dga ? L"true" : L"false" );
+    cfgfile_write (f, L"avoid_vid=%s\n", p->avoid_vid ? L"true" : L"false" );
+    cfgfile_write (f, L"cachesize=%d\n", p->cachesize);
     if (p->override_dga_address)
-       cfgfile_write (f, "override_dga_address=0x%08x\n", p->override_dga_address);
+       cfgfile_write (f, L"override_dga_address=0x%08x\n", p->override_dga_address);
 
     for (i = 0; i < 2; i++) {
        struct jport *jp = &p->jports[i];
        int v = jp->id;
-       char tmp1[MAX_DPATH], tmp2[MAX_DPATH];
+       TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
        if (v < 0) {
-           strcpy (tmp2, "none");
+           _tcscpy (tmp2, L"none");
        } else if (v < JSEM_JOYS) {
-           sprintf (tmp2, "kbd%d", v + 1);
+           _stprintf (tmp2, L"kbd%d", v + 1);
        } else if (v < JSEM_MICE) {
-           sprintf (tmp2, "joy%d", v - JSEM_JOYS);
+           _stprintf (tmp2, L"joy%d", v - JSEM_JOYS);
        } else {
-           strcpy (tmp2, "mouse");
+           _tcscpy (tmp2, L"mouse");
            if (v - JSEM_MICE > 0)
-               sprintf (tmp2, "mouse%d", v - JSEM_MICE);
+               _stprintf (tmp2, L"mouse%d", v - JSEM_MICE);
        }
-       sprintf (tmp1, "joyport%d=%s\n", i, tmp2);
+       _stprintf (tmp1, L"joyport%d=%s\n", i, tmp2);
        cfgfile_write (f, tmp1);
        if (jp->name) {
-           sprintf (tmp1, "joyportfriendlyname%d=%s\n", i, jp->name);
+           _stprintf (tmp1, L"joyportfriendlyname%d=%s\n", i, jp->name);
            cfgfile_write (f, tmp1);
        }
        if (jp->configname) {
-           sprintf (tmp1, "joyportname%d=%s\n", i, jp->configname);
+           _stprintf (tmp1, L"joyportname%d=%s\n", i, jp->configname);
            cfgfile_write (f, tmp1);
        }
     }
 
-    cfgfile_write (f, "bsdsocket_emu=%s\n", p->socket_emu ? "true" : "false");
-
-    cfgfile_write (f, "synchronize_clock=%s\n", p->tod_hack ? "yes" : "no");
-    cfgfile_write (f, "maprom=0x%x\n", p->maprom);
-    cfgfile_write (f, "parallel_postscript_emulation=%s\n", p->parallel_postscript_emulation ? "yes" : "no");
-    cfgfile_write (f, "parallel_postscript_detection=%s\n", p->parallel_postscript_detection ? "yes" : "no");
-    cfgfile_write (f, "ghostscript_parameters=%s\n", p->ghostscript_parameters);
-    cfgfile_write (f, "parallel_autoflush=%d\n", p->parallel_autoflush_time);
-    cfgfile_dwrite (f, "uae_hide=%d\n", p->uae_hide);
-    cfgfile_dwrite (f, "magic_mouse=%s\n", p->input_magic_mouse ? "true" : "false");
-    cfgfile_dwrite (f, "magic_mousecursor=%s\n", magiccursors[p->input_magic_mouse_cursor]);
-    cfgfile_dwrite (f, "absolute_mouse=%s\n", abspointers[p->input_tablet]);
-
-    cfgfile_write (f, "gfx_display=%d\n", p->gfx_display);
-    cfgfile_write (f, "gfx_display_name=%s\n", p->gfx_display_name);
-    cfgfile_write (f, "gfx_framerate=%d\n", p->gfx_framerate);
-    cfgfile_write (f, "gfx_width=%d\n", p->gfx_size_win.width); /* compatibility with old versions */
-    cfgfile_write (f, "gfx_height=%d\n", p->gfx_size_win.height); /* compatibility with old versions */
-    cfgfile_write (f, "gfx_top_windowed=%d\n", p->gfx_size_win.x);
-    cfgfile_write (f, "gfx_left_windowed=%d\n", p->gfx_size_win.y);
-    cfgfile_write (f, "gfx_width_windowed=%d\n", p->gfx_size_win.width);
-    cfgfile_write (f, "gfx_height_windowed=%d\n", p->gfx_size_win.height);
-    cfgfile_write (f, "gfx_width_fullscreen=%d\n", p->gfx_size_fs.width);
-    cfgfile_write (f, "gfx_height_fullscreen=%d\n", p->gfx_size_fs.height);
-    cfgfile_write (f, "gfx_refreshrate=%d\n", p->gfx_refreshrate);
-    cfgfile_write (f, "gfx_autoresolution=%d\n", p->gfx_autoresolution);
-    cfgfile_write (f, "gfx_vsync=%s\n", p->gfx_avsync ? "true" : "false");
-    cfgfile_write (f, "gfx_vsync_picasso=%s\n", p->gfx_pvsync ? "true" : "false");
-    cfgfile_write (f, "gfx_lores=%s\n", p->gfx_resolution == 0 ? "true" : "false");
-    cfgfile_write (f, "gfx_resolution=%s\n", lorestype1[p->gfx_resolution]);
-    cfgfile_write (f, "gfx_lores_mode=%s\n", loresmode[p->gfx_lores_mode]);
-    cfgfile_write (f, "gfx_flickerfixer=%s\n", p->gfx_scandoubler ? "true" : "false");
-    cfgfile_write (f, "gfx_linemode=%s\n", linemode1[p->gfx_linedbl]);
-    cfgfile_write (f, "gfx_fullscreen_amiga=%s\n", fullmodes[p->gfx_afullscreen]);
-    cfgfile_write (f, "gfx_fullscreen_picasso=%s\n", fullmodes[p->gfx_pfullscreen]);
-    cfgfile_write (f, "gfx_center_horizontal=%s\n", centermode1[p->gfx_xcenter]);
-    cfgfile_write (f, "gfx_center_vertical=%s\n", centermode1[p->gfx_ycenter]);
-    cfgfile_write (f, "gfx_colour_mode=%s\n", colormode1[p->color_mode]);
-    cfgfile_write (f, "gfx_blacker_than_black=%s\n", p->gfx_blackerthanblack ? "true" : "false");
+    cfgfile_write (f, L"bsdsocket_emu=%s\n", p->socket_emu ? L"true" : L"false");
+
+    cfgfile_write (f, L"synchronize_clock=%s\n", p->tod_hack ? L"yes" : L"no");
+    cfgfile_write (f, L"maprom=0x%x\n", p->maprom);
+    cfgfile_write (f, L"parallel_postscript_emulation=%s\n", p->parallel_postscript_emulation ? L"yes" : L"no");
+    cfgfile_write (f, L"parallel_postscript_detection=%s\n", p->parallel_postscript_detection ? L"yes" : L"no");
+    cfgfile_write (f, L"ghostscript_parameters=%s\n", p->ghostscript_parameters);
+    cfgfile_write (f, L"parallel_autoflush=%d\n", p->parallel_autoflush_time);
+    cfgfile_dwrite (f, L"uae_hide=%d\n", p->uae_hide);
+    cfgfile_dwrite (f, L"magic_mouse=%s\n", p->input_magic_mouse ? L"true" : L"false");
+    cfgfile_dwrite (f, L"magic_mousecursor=%s\n", magiccursors[p->input_magic_mouse_cursor]);
+    cfgfile_dwrite (f, L"absolute_mouse=%s\n", abspointers[p->input_tablet]);
+
+    cfgfile_write (f, L"gfx_display=%d\n", p->gfx_display);
+    cfgfile_write (f, L"gfx_display_name=%s\n", p->gfx_display_name);
+    cfgfile_write (f, L"gfx_framerate=%d\n", p->gfx_framerate);
+    cfgfile_write (f, L"gfx_width=%d\n", p->gfx_size_win.width); /* compatibility with old versions */
+    cfgfile_write (f, L"gfx_height=%d\n", p->gfx_size_win.height); /* compatibility with old versions */
+    cfgfile_write (f, L"gfx_top_windowed=%d\n", p->gfx_size_win.x);
+    cfgfile_write (f, L"gfx_left_windowed=%d\n", p->gfx_size_win.y);
+    cfgfile_write (f, L"gfx_width_windowed=%d\n", p->gfx_size_win.width);
+    cfgfile_write (f, L"gfx_height_windowed=%d\n", p->gfx_size_win.height);
+    cfgfile_write (f, L"gfx_width_fullscreen=%d\n", p->gfx_size_fs.width);
+    cfgfile_write (f, L"gfx_height_fullscreen=%d\n", p->gfx_size_fs.height);
+    cfgfile_write (f, L"gfx_refreshrate=%d\n", p->gfx_refreshrate);
+    cfgfile_write (f, L"gfx_autoresolution=%d\n", p->gfx_autoresolution);
+    cfgfile_write (f, L"gfx_vsync=%s\n", p->gfx_avsync ? L"true" : L"false");
+    cfgfile_write (f, L"gfx_vsync_picasso=%s\n", p->gfx_pvsync ? L"true" : L"false");
+    cfgfile_write (f, L"gfx_lores=%s\n", p->gfx_resolution == 0 ? L"true" : L"false");
+    cfgfile_write (f, L"gfx_resolution=%s\n", lorestype1[p->gfx_resolution]);
+    cfgfile_write (f, L"gfx_lores_mode=%s\n", loresmode[p->gfx_lores_mode]);
+    cfgfile_write (f, L"gfx_flickerfixer=%s\n", p->gfx_scandoubler ? L"true" : L"false");
+    cfgfile_write (f, L"gfx_linemode=%s\n", linemode1[p->gfx_linedbl]);
+    cfgfile_write (f, L"gfx_fullscreen_amiga=%s\n", fullmodes[p->gfx_afullscreen]);
+    cfgfile_write (f, L"gfx_fullscreen_picasso=%s\n", fullmodes[p->gfx_pfullscreen]);
+    cfgfile_write (f, L"gfx_center_horizontal=%s\n", centermode1[p->gfx_xcenter]);
+    cfgfile_write (f, L"gfx_center_vertical=%s\n", centermode1[p->gfx_ycenter]);
+    cfgfile_write (f, L"gfx_colour_mode=%s\n", colormode1[p->color_mode]);
+    cfgfile_write (f, L"gfx_blacker_than_black=%s\n", p->gfx_blackerthanblack ? L"true" : L"false");
 
 #ifdef GFXFILTER
     if (p->gfx_filter > 0) {
@@ -543,12 +558,12 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
            uf = &uaefilters[i];
            if (uf->type == p->gfx_filter) {
                if (p->gfx_filtershader[0])
-                   cfgfile_dwrite (f, "gfx_filter=%s:%s\n", uf->cfgname, p->gfx_filtershader);
+                   cfgfile_dwrite (f, L"gfx_filter=%s:%s\n", uf->cfgname, p->gfx_filtershader);
                else
-                   cfgfile_dwrite (f, "gfx_filter=%s\n", uf->cfgname);
+                   cfgfile_dwrite (f, L"gfx_filter=%s\n", uf->cfgname);
                if (uf->type == p->gfx_filter) {
                    if (uf->x[0]) {
-                       cfgfile_dwrite (f, "gfx_filter_mode=%s\n", filtermode1[p->gfx_filter_filtermode]);
+                       cfgfile_dwrite (f, L"gfx_filter_mode=%s\n", filtermode1[p->gfx_filter_filtermode]);
                    } else {
                        int mt[4], i = 0;
                        if (uf->x[1])
@@ -559,220 +574,220 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
                            mt[i++] = 3;
                        if (uf->x[4])
                            mt[i++] = 4;
-                       cfgfile_dwrite (f, "gfx_filter_mode=%dx\n", mt[p->gfx_filter_filtermode]);
+                       cfgfile_dwrite (f, L"gfx_filter_mode=%dx\n", mt[p->gfx_filter_filtermode]);
                    }
                }
            }
            i++;
        }
     } else {
-       cfgfile_dwrite (f, "gfx_filter=no\n");
-    }
-
-    cfgfile_dwrite (f, "gfx_filter_vert_zoom=%d\n", p->gfx_filter_vert_zoom);
-    cfgfile_dwrite (f, "gfx_filter_horiz_zoom=%d\n", p->gfx_filter_horiz_zoom);
-    cfgfile_dwrite (f, "gfx_filter_vert_zoom_mult=%d\n", p->gfx_filter_vert_zoom_mult);
-    cfgfile_dwrite (f, "gfx_filter_horiz_zoom_mult=%d\n", p->gfx_filter_horiz_zoom_mult);
-    cfgfile_dwrite (f, "gfx_filter_vert_offset=%d\n", p->gfx_filter_vert_offset);
-    cfgfile_dwrite (f, "gfx_filter_horiz_offset=%d\n", p->gfx_filter_horiz_offset);
-    cfgfile_dwrite (f, "gfx_filter_scanlines=%d\n", p->gfx_filter_scanlines);
-    cfgfile_dwrite (f, "gfx_filter_scanlinelevel=%d\n", p->gfx_filter_scanlinelevel);
-    cfgfile_dwrite (f, "gfx_filter_scanlineratio=%d\n", p->gfx_filter_scanlineratio);
-    cfgfile_dwrite (f, "gfx_filter_luminance=%d\n", p->gfx_filter_luminance);
-    cfgfile_dwrite (f, "gfx_filter_contrast=%d\n", p->gfx_filter_contrast);
-    cfgfile_dwrite (f, "gfx_filter_saturation=%d\n", p->gfx_filter_saturation);
-    cfgfile_dwrite (f, "gfx_filter_gamma=%d\n", p->gfx_filter_gamma);
-    cfgfile_dwrite (f, "gfx_filter_blur=%d\n", p->gfx_filter_blur);
-    cfgfile_dwrite (f, "gfx_filter_noise=%d\n", p->gfx_filter_noise);
-    cfgfile_dwrite (f, "gfx_filter_keep_aspect=%s\n", p->gfx_filter_keep_aspect ? "true" : "false");
-    cfgfile_dwrite (f, "gfx_filter_autoscale=%s\n", autoscale[p->gfx_filter_autoscale]);
-    cfgfile_dwrite (f, "gfx_filter_aspect_ratio=%d:%d\n",
+       cfgfile_dwrite (f, L"gfx_filter=no\n");
+    }
+
+    cfgfile_dwrite (f, L"gfx_filter_vert_zoom=%d\n", p->gfx_filter_vert_zoom);
+    cfgfile_dwrite (f, L"gfx_filter_horiz_zoom=%d\n", p->gfx_filter_horiz_zoom);
+    cfgfile_dwrite (f, L"gfx_filter_vert_zoom_mult=%d\n", p->gfx_filter_vert_zoom_mult);
+    cfgfile_dwrite (f, L"gfx_filter_horiz_zoom_mult=%d\n", p->gfx_filter_horiz_zoom_mult);
+    cfgfile_dwrite (f, L"gfx_filter_vert_offset=%d\n", p->gfx_filter_vert_offset);
+    cfgfile_dwrite (f, L"gfx_filter_horiz_offset=%d\n", p->gfx_filter_horiz_offset);
+    cfgfile_dwrite (f, L"gfx_filter_scanlines=%d\n", p->gfx_filter_scanlines);
+    cfgfile_dwrite (f, L"gfx_filter_scanlinelevel=%d\n", p->gfx_filter_scanlinelevel);
+    cfgfile_dwrite (f, L"gfx_filter_scanlineratio=%d\n", p->gfx_filter_scanlineratio);
+    cfgfile_dwrite (f, L"gfx_filter_luminance=%d\n", p->gfx_filter_luminance);
+    cfgfile_dwrite (f, L"gfx_filter_contrast=%d\n", p->gfx_filter_contrast);
+    cfgfile_dwrite (f, L"gfx_filter_saturation=%d\n", p->gfx_filter_saturation);
+    cfgfile_dwrite (f, L"gfx_filter_gamma=%d\n", p->gfx_filter_gamma);
+    cfgfile_dwrite (f, L"gfx_filter_blur=%d\n", p->gfx_filter_blur);
+    cfgfile_dwrite (f, L"gfx_filter_noise=%d\n", p->gfx_filter_noise);
+    cfgfile_dwrite (f, L"gfx_filter_keep_aspect=%s\n", p->gfx_filter_keep_aspect ? L"true" : L"false");
+    cfgfile_dwrite (f, L"gfx_filter_autoscale=%s\n", autoscale[p->gfx_filter_autoscale]);
+    cfgfile_dwrite (f, L"gfx_filter_aspect_ratio=%d:%d\n",
        p->gfx_filter_aspect >= 0 ? (p->gfx_filter_aspect >> 8) : -1,
        p->gfx_filter_aspect >= 0 ? (p->gfx_filter_aspect & 0xff) : -1);
-    cfgfile_dwrite (f, "gfx_luminance=%d\n", p->gfx_luminance);
-    cfgfile_dwrite (f, "gfx_contrast=%d\n", p->gfx_contrast);
-    cfgfile_dwrite (f, "gfx_gamma=%d\n", p->gfx_gamma);
+    cfgfile_dwrite (f, L"gfx_luminance=%d\n", p->gfx_luminance);
+    cfgfile_dwrite (f, L"gfx_contrast=%d\n", p->gfx_contrast);
+    cfgfile_dwrite (f, L"gfx_gamma=%d\n", p->gfx_gamma);
 #endif
 
-    cfgfile_write (f, "immediate_blits=%s\n", p->immediate_blits ? "true" : "false");
-    cfgfile_write (f, "ntsc=%s\n", p->ntscmode ? "true" : "false");
-    cfgfile_write (f, "genlock=%s\n", p->genlock ? "true" : "false");
-    cfgfile_dwrite (f, "show_leds=%s\n", (p->leds_on_screen & STATUSLINE_CHIPSET) ? "true" : "false");
-    cfgfile_dwrite (f, "keyboard_leds=numlock:%s,capslock:%s,scrolllock:%s\n",
+    cfgfile_write (f, L"immediate_blits=%s\n", p->immediate_blits ? L"true" : L"false");
+    cfgfile_write (f, L"ntsc=%s\n", p->ntscmode ? L"true" : L"false");
+    cfgfile_write (f, L"genlock=%s\n", p->genlock ? L"true" : L"false");
+    cfgfile_dwrite (f, L"show_leds=%s\n", (p->leds_on_screen & STATUSLINE_CHIPSET) ? L"true" : L"false");
+    cfgfile_dwrite (f, L"keyboard_leds=numlock:%s,capslock:%s,scrolllock:%s\n",
        kbleds[p->keyboard_leds[0]], kbleds[p->keyboard_leds[1]], kbleds[p->keyboard_leds[2]]);
     if (p->chipset_mask & CSMASK_AGA)
-       cfgfile_dwrite (f, "chipset=aga\n");
+       cfgfile_dwrite (f, L"chipset=aga\n");
     else if ((p->chipset_mask & CSMASK_ECS_AGNUS) && (p->chipset_mask & CSMASK_ECS_DENISE))
-       cfgfile_dwrite (f, "chipset=ecs\n");
+       cfgfile_dwrite (f, L"chipset=ecs\n");
     else if (p->chipset_mask & CSMASK_ECS_AGNUS)
-       cfgfile_dwrite (f, "chipset=ecs_agnus\n");
+       cfgfile_dwrite (f, L"chipset=ecs_agnus\n");
     else if (p->chipset_mask & CSMASK_ECS_DENISE)
-       cfgfile_dwrite (f, "chipset=ecs_denise\n");
+       cfgfile_dwrite (f, L"chipset=ecs_denise\n");
     else
-       cfgfile_dwrite (f, "chipset=ocs\n");
-    cfgfile_write (f, "chipset_refreshrate=%d\n", p->chipset_refreshrate);
-    cfgfile_write (f, "collision_level=%s\n", collmode[p->collision_level]);
-
-    cfgfile_write (f, "chipset_compatible=%s\n", cscompa[p->cs_compatible]);
-    cfgfile_dwrite (f, "ciaatod=%s\n", ciaatodmode[p->cs_ciaatod]);
-    cfgfile_dwrite (f, "rtc=%s\n", rtctype[p->cs_rtc]);
-    //cfgfile_dwrite (f, "chipset_rtc_adjust=%d\n", p->cs_rtc_adjust);
-    cfgfile_dwrite (f, "ksmirror_e0=%s\n", p->cs_ksmirror_e0 ? "true" : "false");
-    cfgfile_dwrite (f, "ksmirror_a8=%s\n", p->cs_ksmirror_a8 ? "true" : "false");
-    cfgfile_dwrite (f, "cd32cd=%s\n", p->cs_cd32cd ? "true" : "false");
-    cfgfile_dwrite (f, "cd32c2p=%s\n", p->cs_cd32c2p ? "true" : "false");
-    cfgfile_dwrite (f, "cd32nvram=%s\n", p->cs_cd32nvram ? "true" : "false");
-    cfgfile_dwrite (f, "cdtvcd=%s\n", p->cs_cdtvcd ? "true" : "false");
-    cfgfile_dwrite (f, "cdtvram=%s\n", p->cs_cdtvram ? "true" : "false");
-    cfgfile_dwrite (f, "cdtvramcard=%d\n", p->cs_cdtvcard);
-    cfgfile_dwrite (f, "ide=%s\n", p->cs_ide == 1 ? "a600/a1200" : (p->cs_ide == 2 ? "a4000" : "none"));
-    cfgfile_dwrite (f, "a1000ram=%s\n", p->cs_a1000ram ? "true" : "false");
-    cfgfile_dwrite (f, "fatgary=%d\n", p->cs_fatgaryrev);
-    cfgfile_dwrite (f, "ramsey=%d\n", p->cs_ramseyrev);
-    cfgfile_dwrite (f, "pcmcia=%s\n", p->cs_pcmcia ? "true" :"false");
-    cfgfile_dwrite (f, "scsi_cdtv=%s\n", p->cs_cdtvscsi ? "true" : "false");
-    cfgfile_dwrite (f, "scsi_a2091=%s\n", p->cs_a2091 ? "true" : "false");
-    cfgfile_dwrite (f, "scsi_a4091=%s\n", p->cs_a4091 ? "true" : "false");
-    cfgfile_dwrite (f, "scsi_a3000=%s\n", p->cs_mbdmac == 1 ? "true" : "false");
-    cfgfile_dwrite (f, "scsi_a4000t=%s\n", p->cs_mbdmac == 2 ? "true" : "false");
-    cfgfile_dwrite (f, "bogomem_fast=%s\n", p->cs_slowmemisfast ? "true" : "false");
-    cfgfile_dwrite (f, "resetwarning=%s\n", p->cs_resetwarning ? "true" : "false");
-    cfgfile_dwrite (f, "denise_noehb=%s\n", p->cs_denisenoehb ? "true" : "false");
-    cfgfile_dwrite (f, "agnus_bltbusybug=%s\n", p->cs_agnusbltbusybug ? "true" : "false");
-
-    cfgfile_write (f, "fastmem_size=%d\n", p->fastmem_size / 0x100000);
-    cfgfile_write (f, "a3000mem_size=%d\n", p->mbresmem_low_size / 0x100000);
-    cfgfile_write (f, "mbresmem_size=%d\n", p->mbresmem_high_size / 0x100000);
-    cfgfile_write (f, "z3mem_size=%d\n", p->z3fastmem_size / 0x100000);
-    cfgfile_write (f, "z3mem2_size=%d\n", p->z3fastmem2_size / 0x100000);
-    cfgfile_write (f, "z3mem_start=0x%x\n", p->z3fastmem_start);
-    cfgfile_write (f, "bogomem_size=%d\n", p->bogomem_size / 0x40000);
-    cfgfile_write (f, "gfxcard_size=%d\n", p->gfxmem_size / 0x100000);
-    cfgfile_write (f, "chipmem_size=%d\n", p->chipmem_size == 0x20000 ? -1 : (p->chipmem_size == 0x40000 ? 0 : p->chipmem_size / 0x80000));
+       cfgfile_dwrite (f, L"chipset=ocs\n");
+    cfgfile_write (f, L"chipset_refreshrate=%d\n", p->chipset_refreshrate);
+    cfgfile_write (f, L"collision_level=%s\n", collmode[p->collision_level]);
+
+    cfgfile_write (f, L"chipset_compatible=%s\n", cscompa[p->cs_compatible]);
+    cfgfile_dwrite (f, L"ciaatod=%s\n", ciaatodmode[p->cs_ciaatod]);
+    cfgfile_dwrite (f, L"rtc=%s\n", rtctype[p->cs_rtc]);
+    //cfgfile_dwrite (f, L"chipset_rtc_adjust=%d\n", p->cs_rtc_adjust);
+    cfgfile_dwrite (f, L"ksmirror_e0=%s\n", p->cs_ksmirror_e0 ? L"true" : L"false");
+    cfgfile_dwrite (f, L"ksmirror_a8=%s\n", p->cs_ksmirror_a8 ? L"true" : L"false");
+    cfgfile_dwrite (f, L"cd32cd=%s\n", p->cs_cd32cd ? L"true" : L"false");
+    cfgfile_dwrite (f, L"cd32c2p=%s\n", p->cs_cd32c2p ? L"true" : L"false");
+    cfgfile_dwrite (f, L"cd32nvram=%s\n", p->cs_cd32nvram ? L"true" : L"false");
+    cfgfile_dwrite (f, L"cdtvcd=%s\n", p->cs_cdtvcd ? L"true" : L"false");
+    cfgfile_dwrite (f, L"cdtvram=%s\n", p->cs_cdtvram ? L"true" : L"false");
+    cfgfile_dwrite (f, L"cdtvramcard=%d\n", p->cs_cdtvcard);
+    cfgfile_dwrite (f, L"ide=%s\n", p->cs_ide == 1 ? L"a600/a1200" : (p->cs_ide == 2 ? L"a4000" : L"none"));
+    cfgfile_dwrite (f, L"a1000ram=%s\n", p->cs_a1000ram ? L"true" : L"false");
+    cfgfile_dwrite (f, L"fatgary=%d\n", p->cs_fatgaryrev);
+    cfgfile_dwrite (f, L"ramsey=%d\n", p->cs_ramseyrev);
+    cfgfile_dwrite (f, L"pcmcia=%s\n", p->cs_pcmcia ? L"true" : L"false");
+    cfgfile_dwrite (f, L"scsi_cdtv=%s\n", p->cs_cdtvscsi ? L"true" : L"false");
+    cfgfile_dwrite (f, L"scsi_a2091=%s\n", p->cs_a2091 ? L"true" : L"false");
+    cfgfile_dwrite (f, L"scsi_a4091=%s\n", p->cs_a4091 ? L"true" : L"false");
+    cfgfile_dwrite (f, L"scsi_a3000=%s\n", p->cs_mbdmac == 1 ? L"true" : L"false");
+    cfgfile_dwrite (f, L"scsi_a4000t=%s\n", p->cs_mbdmac == 2 ? L"true" : L"false");
+    cfgfile_dwrite (f, L"bogomem_fast=%s\n", p->cs_slowmemisfast ? L"true" : L"false");
+    cfgfile_dwrite (f, L"resetwarning=%s\n", p->cs_resetwarning ? L"true" : L"false");
+    cfgfile_dwrite (f, L"denise_noehb=%s\n", p->cs_denisenoehb ? L"true" : L"false");
+    cfgfile_dwrite (f, L"agnus_bltbusybug=%s\n", p->cs_agnusbltbusybug ? L"true" : L"false");
+
+    cfgfile_write (f, L"fastmem_size=%d\n", p->fastmem_size / 0x100000);
+    cfgfile_write (f, L"a3000mem_size=%d\n", p->mbresmem_low_size / 0x100000);
+    cfgfile_write (f, L"mbresmem_size=%d\n", p->mbresmem_high_size / 0x100000);
+    cfgfile_write (f, L"z3mem_size=%d\n", p->z3fastmem_size / 0x100000);
+    cfgfile_write (f, L"z3mem2_size=%d\n", p->z3fastmem2_size / 0x100000);
+    cfgfile_write (f, L"z3mem_start=0x%x\n", p->z3fastmem_start);
+    cfgfile_write (f, L"bogomem_size=%d\n", p->bogomem_size / 0x40000);
+    cfgfile_write (f, L"gfxcard_size=%d\n", p->gfxmem_size / 0x100000);
+    cfgfile_write (f, L"chipmem_size=%d\n", p->chipmem_size == 0x20000 ? -1 : (p->chipmem_size == 0x40000 ? 0 : p->chipmem_size / 0x80000));
 
     if (p->m68k_speed > 0)
-       cfgfile_write (f, "finegrain_cpu_speed=%d\n", p->m68k_speed);
+       cfgfile_write (f, L"finegrain_cpu_speed=%d\n", p->m68k_speed);
     else
-       cfgfile_write (f, "cpu_speed=%s\n", p->m68k_speed == -1 ? "max" : "real");
+       cfgfile_write (f, L"cpu_speed=%s\n", p->m68k_speed == -1 ? L"max" : L"real");
 
     /* do not reorder start */
     write_compatibility_cpu(f, p);
-    cfgfile_write (f, "cpu_model=%d\n", p->cpu_model);
+    cfgfile_write (f, L"cpu_model=%d\n", p->cpu_model);
     if (p->fpu_model)
-       cfgfile_write (f, "fpu_model=%d\n", p->fpu_model);
-    cfgfile_write (f, "cpu_compatible=%s\n", p->cpu_compatible ? "true" : "false");
-    cfgfile_write (f, "cpu_24bit_addressing=%s\n", p->address_space_24 ? "true" : "false");
+       cfgfile_write (f, L"fpu_model=%d\n", p->fpu_model);
+    cfgfile_write (f, L"cpu_compatible=%s\n", p->cpu_compatible ? L"true" : L"false");
+    cfgfile_write (f, L"cpu_24bit_addressing=%s\n", p->address_space_24 ? L"true" : L"false");
     /* do not reorder end */
-    cfgfile_write (f, "cpu_cycle_exact=%s\n", p->cpu_cycle_exact ? "true" : "false");
-    cfgfile_write (f, "blitter_cycle_exact=%s\n", p->blitter_cycle_exact ? "true" : "false");
-    cfgfile_write (f, "rtg_nocustom=%s\n", p->picasso96_nocustom ? "true" : "false");
-    cfgfile_write (f, "rtg_modes=0x%x\n", p->picasso96_modeflags);
+    cfgfile_write (f, L"cpu_cycle_exact=%s\n", p->cpu_cycle_exact ? L"true" : L"false");
+    cfgfile_write (f, L"blitter_cycle_exact=%s\n", p->blitter_cycle_exact ? L"true" : L"false");
+    cfgfile_write (f, L"rtg_nocustom=%s\n", p->picasso96_nocustom ? L"true" : L"false");
+    cfgfile_write (f, L"rtg_modes=0x%x\n", p->picasso96_modeflags);
 
-    cfgfile_write (f, "log_illegal_mem=%s\n", p->illegal_mem ? "true" : "false");
+    cfgfile_write (f, L"log_illegal_mem=%s\n", p->illegal_mem ? L"true" : L"false");
     if (p->catweasel >= 100)
-       cfgfile_dwrite (f, "catweasel=0x%x\n", p->catweasel);
+       cfgfile_dwrite (f, L"catweasel=0x%x\n", p->catweasel);
     else
-       cfgfile_dwrite (f, "catweasel=%d\n", p->catweasel);
+       cfgfile_dwrite (f, L"catweasel=%d\n", p->catweasel);
 
-    cfgfile_write (f, "kbd_lang=%s\n", (p->keyboard_lang == KBD_LANG_DE ? "de"
-                                       : p->keyboard_lang == KBD_LANG_DK ? "dk"
-                                       : p->keyboard_lang == KBD_LANG_ES ? "es"
-                                       : p->keyboard_lang == KBD_LANG_US ? "us"
-                                       : p->keyboard_lang == KBD_LANG_SE ? "se"
-                                       : p->keyboard_lang == KBD_LANG_FR ? "fr"
-                                       : p->keyboard_lang == KBD_LANG_IT ? "it"
-                                       : "FOO"));
+    cfgfile_write (f, L"kbd_lang=%s\n", (p->keyboard_lang == KBD_LANG_DE ? L"de"
+                                       : p->keyboard_lang == KBD_LANG_DK ? L"dk"
+                                       : p->keyboard_lang == KBD_LANG_ES ? L"es"
+                                       : p->keyboard_lang == KBD_LANG_US ? L"us"
+                                       : p->keyboard_lang == KBD_LANG_SE ? L"se"
+                                       : p->keyboard_lang == KBD_LANG_FR ? L"fr"
+                                       : p->keyboard_lang == KBD_LANG_IT ? L"it"
+                                       : L"FOO"));
 
-    cfgfile_dwrite (f, "state_replay=%s\n", p->statecapture ? "yes" : "no");
-    cfgfile_dwrite (f, "state_replay_rate=%d\n", p->statecapturerate);
-    cfgfile_dwrite (f, "state_replay_buffer=%d\n", p->statecapturebuffersize);
+    cfgfile_dwrite (f, L"state_replay=%s\n", p->statecapture ? L"yes" : L"no");
+    cfgfile_dwrite (f, L"state_replay_rate=%d\n", p->statecapturerate);
+    cfgfile_dwrite (f, L"state_replay_buffer=%d\n", p->statecapturebuffersize);
 
 #ifdef FILESYS
     write_filesys_config (p, UNEXPANDED, p->path_hardfile, f);
     if (p->filesys_no_uaefsdb)
-       cfgfile_write (f, "filesys_no_fsdb=%s\n", p->filesys_no_uaefsdb ? "true" : "false");
+       cfgfile_write (f, L"filesys_no_fsdb=%s\n", p->filesys_no_uaefsdb ? L"true" : L"false");
 #endif
     write_inputdevice_config (p, f);
 
     /* Don't write gfxlib/gfx_test_speed options.  */
 }
 
-int cfgfile_yesno (const char *option, const char *value, const char *name, int *location)
+int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location)
 {
-    if (strcmp (option, name) != 0)
+    if (_tcscmp (option, name) != 0)
        return 0;
-    if (strcasecmp (value, "yes") == 0 || strcasecmp (value, "y") == 0
-       || strcasecmp (value, "true") == 0 || strcasecmp (value, "t") == 0)
+    if (strcasecmp (value, L"yes") == 0 || strcasecmp (value, L"y") == 0
+       || strcasecmp (value, L"true") == 0 || strcasecmp (value, L"t") == 0)
        *location = 1;
-    else if (strcasecmp (value, "no") == 0 || strcasecmp (value, "n") == 0
-       || strcasecmp (value, "false") == 0 || strcasecmp (value, "f") == 0)
+    else if (strcasecmp (value, L"no") == 0 || strcasecmp (value, L"n") == 0
+       || strcasecmp (value, L"false") == 0 || strcasecmp (value, L"f") == 0)
        *location = 0;
     else {
-       write_log ("Option `%s' requires a value of either `yes' or `no'.\n", option);
+       write_log (L"Option `%s' requires a value of either `yes' or `no'.\n", option);
        return -1;
     }
     return 1;
 }
 
-int cfgfile_intval (const char *option, const char *value, const char *name, int *location, int scale)
+int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale)
 {
     int base = 10;
-    char *endptr;
-    if (strcmp (option, name) != 0)
+    TCHAR *endptr;
+    if (_tcscmp (option, name) != 0)
        return 0;
     /* I guess octal isn't popular enough to worry about here...  */
     if (value[0] == '0' && value[1] == 'x')
        value += 2, base = 16;
-    *location = strtol (value, &endptr, base) * scale;
+    *location = _tcstol (value, &endptr, base) * scale;
 
     if (*endptr != '\0' || *value == '\0') {
-       write_log ("Option `%s' requires a numeric argument.\n", option);
+       write_log (L"Option `%s' requires a numeric argument.\n", option);
        return -1;
     }
     return 1;
 }
 
-int cfgfile_strval (const char *option, const char *value, const char *name, int *location, const char *table[], int more)
+int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more)
 {
     int val;
-    if (strcmp (option, name) != 0)
+    if (_tcscmp (option, name) != 0)
        return 0;
     val = match_string (table, value);
     if (val == -1) {
        if (more)
            return 0;
 
-       write_log ("Unknown value for option `%s'.\n", option);
+       write_log (L"Unknown value for option `%s'.\n", option);
        return -1;
     }
     *location = val;
     return 1;
 }
 
-int cfgfile_string (const char *option, const char *value, const char *name, char *location, int maxsz)
+int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz)
 {
-    if (strcmp (option, name) != 0)
+    if (_tcscmp (option, name) != 0)
        return 0;
-    strncpy (location, value, maxsz - 1);
+    _tcsncpy (location, value, maxsz - 1);
     location[maxsz - 1] = '\0';
     return 1;
 }
 
-static int getintval (char **p, int *result, int delim)
+static int getintval (TCHAR **p, int *result, int delim)
 {
-    char *value = *p;
+    TCHAR *value = *p;
     int base = 10;
-    char *endptr;
-    char *p2 = strchr (*p, delim);
+    TCHAR *endptr;
+    TCHAR *p2 = _tcschr (*p, delim);
 
     if (p2 == 0)
        return 0;
 
     *p2++ = '\0';
 
-    if (value[0] == '0' && toupper (value[1]) == 'X')
+    if (value[0] == '0' && _totupper (value[1]) == 'X')
        value += 2, base = 16;
-    *result = strtol (value, &endptr, base);
+    *result = _tcstol (value, &endptr, base);
     *p = p2;
 
     if (*endptr != '\0' || *value == '\0')
@@ -781,15 +796,15 @@ static int getintval (char **p, int *result, int delim)
     return 1;
 }
 
-static int getintval2 (char **p, int *result, int delim)
+static int getintval2 (TCHAR **p, int *result, int delim)
 {
-    char *value = *p;
+    TCHAR *value = *p;
     int base = 10;
-    char *endptr;
-    char *p2 = strchr (*p, delim);
+    TCHAR *endptr;
+    TCHAR *p2 = _tcschr (*p, delim);
 
     if (p2 == 0) {
-       p2 = strchr (*p, 0);
+       p2 = _tcschr (*p, 0);
        if (p2 == 0) {
            *p = 0;
            return 0;
@@ -798,9 +813,9 @@ static int getintval2 (char **p, int *result, int delim)
     if (*p2 != 0)
        *p2++ = '\0';
 
-    if (value[0] == '0' && toupper (value[1]) == 'X')
+    if (value[0] == '0' && _totupper (value[1]) == 'X')
        value += 2, base = 16;
-    *result = strtol (value, &endptr, base);
+    *result = _tcstol (value, &endptr, base);
     *p = p2;
 
     if (*endptr != '\0' || *value == '\0') {
@@ -820,187 +835,187 @@ static void set_chipset_mask (struct uae_prefs *p, int val)
                       : CSMASK_AGA | CSMASK_ECS_DENISE | CSMASK_ECS_AGNUS);
 }
 
-static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
+static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
 {
     int i;
-    char *section = 0;
-    char *tmpp;
-    char tmpbuf[CONFIG_BLEN];
+    TCHAR *section = 0;
+    TCHAR *tmpp;
+    TCHAR tmpbuf[CONFIG_BLEN];
 
-    if (memcmp (option, "input.", 6) == 0) {
+    if (_tcsncmp (option, L"input.", 6) == 0) {
        read_inputdevice_config (p, option, value);
        return 1;
     }
 
     for (tmpp = option; *tmpp != '\0'; tmpp++)
-       if (isupper (*tmpp))
-           *tmpp = tolower (*tmpp);
-    tmpp = strchr (option, '.');
+       if (_istupper (*tmpp))
+           *tmpp = _totlower (*tmpp);
+    tmpp = _tcschr (option, '.');
     if (tmpp) {
        section = option;
        option = tmpp + 1;
        *tmpp = '\0';
-       if (strcmp (section, TARGET_NAME) == 0) {
+       if (_tcscmp (section, TARGET_NAME) == 0) {
            /* We special case the various path options here.  */
-           if (cfgfile_string (option, value, "rom_path", p->path_rom, sizeof p->path_rom)
-               || cfgfile_string (option, value, "floppy_path", p->path_floppy, sizeof p->path_floppy)
-               || cfgfile_string (option, value, "hardfile_path", p->path_hardfile, sizeof p->path_hardfile))
+           if (cfgfile_string (option, value, L"rom_path", p->path_rom, sizeof p->path_rom / sizeof (TCHAR))
+               || cfgfile_string (option, value, L"floppy_path", p->path_floppy, sizeof p->path_floppy / sizeof (TCHAR))
+               || cfgfile_string (option, value, L"hardfile_path", p->path_hardfile, sizeof p->path_hardfile / sizeof (TCHAR)))
                return 1;
            return target_parse_option (p, option, value);
        }
        return 0;
     }
     for (i = 0; i < MAX_SPARE_DRIVES; i++) {
-       sprintf (tmpbuf, "diskimage%d", i);
-       if (cfgfile_string (option, value, tmpbuf, p->dfxlist[i], sizeof p->dfxlist[i])) {
+       _stprintf (tmpbuf, L"diskimage%d", i);
+       if (cfgfile_string (option, value, tmpbuf, p->dfxlist[i], sizeof p->dfxlist[i] / sizeof (TCHAR))) {
 #if 0
            if (i < 4 && !p->df[i][0])
-               strcpy (p->df[i], p->dfxlist[i]);
+               _tcscpy (p->df[i], p->dfxlist[i]);
 #endif
            return 1;
        }
     }
 
-    if (cfgfile_intval (option, value, "sound_frequency", &p->sound_freq, 1)) {
+    if (cfgfile_intval (option, value, L"sound_frequency", &p->sound_freq, 1)) {
        /* backwards compatibility */
        p->sound_latency = 1000 * (p->sound_maxbsiz >> 1) / p->sound_freq;
        return 1;
     }
 
-    if (cfgfile_intval (option, value, "sound_latency", &p->sound_latency, 1)
-       || cfgfile_intval (option, value, "sound_max_buff", &p->sound_maxbsiz, 1)
-       || cfgfile_intval (option, value, "state_replay_rate", &p->statecapturerate, 1)
-       || cfgfile_intval (option, value, "state_replay_buffer", &p->statecapturebuffersize, 1)
-       || cfgfile_intval (option, value, "sound_frequency", &p->sound_freq, 1)
-       || cfgfile_intval (option, value, "sound_volume", &p->sound_volume, 1)
-       || cfgfile_intval (option, value, "sound_stereo_separation", &p->sound_stereo_separation, 1)
-       || cfgfile_intval (option, value, "sound_stereo_mixing_delay", &p->sound_mixed_stereo_delay, 1)
-
-       || cfgfile_intval (option, value, "gfx_display", &p->gfx_display, 1)
-       || cfgfile_intval (option, value, "gfx_framerate", &p->gfx_framerate, 1)
-       || cfgfile_intval (option, value, "gfx_width_windowed", &p->gfx_size_win.width, 1)
-       || cfgfile_intval (option, value, "gfx_height_windowed", &p->gfx_size_win.height, 1)
-       || cfgfile_intval (option, value, "gfx_top_windowed", &p->gfx_size_win.x, 1)
-       || cfgfile_intval (option, value, "gfx_left_windowed", &p->gfx_size_win.y, 1)
-       || cfgfile_intval (option, value, "gfx_width_fullscreen", &p->gfx_size_fs.width, 1)
-       || cfgfile_intval (option, value, "gfx_height_fullscreen", &p->gfx_size_fs.height, 1)
-       || cfgfile_intval (option, value, "gfx_refreshrate", &p->gfx_refreshrate, 1)
-       || cfgfile_intval (option, value, "gfx_autoresolution", &p->gfx_autoresolution, 1)
-
-       || cfgfile_intval (option, value, "gfx_center_horizontal_position", &p->gfx_xcenter_pos, 1)
-       || cfgfile_intval (option, value, "gfx_center_vertical_position", &p->gfx_ycenter_pos, 1)
-       || cfgfile_intval (option, value, "gfx_center_horizontal_size", &p->gfx_xcenter_size, 1)
-       || cfgfile_intval (option, value, "gfx_center_vertical_size", &p->gfx_ycenter_size, 1)
+    if (cfgfile_intval (option, value, L"sound_latency", &p->sound_latency, 1)
+       || cfgfile_intval (option, value, L"sound_max_buff", &p->sound_maxbsiz, 1)
+       || cfgfile_intval (option, value, L"state_replay_rate", &p->statecapturerate, 1)
+       || cfgfile_intval (option, value, L"state_replay_buffer", &p->statecapturebuffersize, 1)
+       || cfgfile_intval (option, value, L"sound_frequency", &p->sound_freq, 1)
+       || cfgfile_intval (option, value, L"sound_volume", &p->sound_volume, 1)
+       || cfgfile_intval (option, value, L"sound_stereo_separation", &p->sound_stereo_separation, 1)
+       || cfgfile_intval (option, value, L"sound_stereo_mixing_delay", &p->sound_mixed_stereo_delay, 1)
+
+       || cfgfile_intval (option, value, L"gfx_display", &p->gfx_display, 1)
+       || cfgfile_intval (option, value, L"gfx_framerate", &p->gfx_framerate, 1)
+       || cfgfile_intval (option, value, L"gfx_width_windowed", &p->gfx_size_win.width, 1)
+       || cfgfile_intval (option, value, L"gfx_height_windowed", &p->gfx_size_win.height, 1)
+       || cfgfile_intval (option, value, L"gfx_top_windowed", &p->gfx_size_win.x, 1)
+       || cfgfile_intval (option, value, L"gfx_left_windowed", &p->gfx_size_win.y, 1)
+       || cfgfile_intval (option, value, L"gfx_width_fullscreen", &p->gfx_size_fs.width, 1)
+       || cfgfile_intval (option, value, L"gfx_height_fullscreen", &p->gfx_size_fs.height, 1)
+       || cfgfile_intval (option, value, L"gfx_refreshrate", &p->gfx_refreshrate, 1)
+       || cfgfile_intval (option, value, L"gfx_autoresolution", &p->gfx_autoresolution, 1)
+
+       || cfgfile_intval (option, value, L"gfx_center_horizontal_position", &p->gfx_xcenter_pos, 1)
+       || cfgfile_intval (option, value, L"gfx_center_vertical_position", &p->gfx_ycenter_pos, 1)
+       || cfgfile_intval (option, value, L"gfx_center_horizontal_size", &p->gfx_xcenter_size, 1)
+       || cfgfile_intval (option, value, L"gfx_center_vertical_size", &p->gfx_ycenter_size, 1)
 
 #ifdef GFXFILTER
-       || cfgfile_intval (option, value, "gfx_filter_vert_zoom", &p->gfx_filter_vert_zoom, 1)
-       || cfgfile_intval (option, value, "gfx_filter_horiz_zoom", &p->gfx_filter_horiz_zoom, 1)
-       || cfgfile_intval (option, value, "gfx_filter_vert_zoom_mult", &p->gfx_filter_vert_zoom_mult, 1)
-       || cfgfile_intval (option, value, "gfx_filter_horiz_zoom_mult", &p->gfx_filter_horiz_zoom_mult, 1)
-       || cfgfile_intval (option, value, "gfx_filter_vert_offset", &p->gfx_filter_vert_offset, 1)
-       || cfgfile_intval (option, value, "gfx_filter_horiz_offset", &p->gfx_filter_horiz_offset, 1)
-       || cfgfile_intval (option, value, "gfx_filter_scanlines", &p->gfx_filter_scanlines, 1)
-       || cfgfile_intval (option, value, "gfx_filter_scanlinelevel", &p->gfx_filter_scanlinelevel, 1)
-       || cfgfile_intval (option, value, "gfx_filter_scanlineratio", &p->gfx_filter_scanlineratio, 1)
-       || cfgfile_intval (option, value, "gfx_filter_luminance", &p->gfx_filter_luminance, 1)
-       || cfgfile_intval (option, value, "gfx_filter_contrast", &p->gfx_filter_contrast, 1)
-       || cfgfile_intval (option, value, "gfx_filter_saturation", &p->gfx_filter_saturation, 1)
-       || cfgfile_intval (option, value, "gfx_filter_gamma", &p->gfx_filter_gamma, 1)
-       || cfgfile_intval (option, value, "gfx_filter_blur", &p->gfx_filter_blur, 1)
-       || cfgfile_intval (option, value, "gfx_filter_noise", &p->gfx_filter_noise, 1)
-       || cfgfile_yesno  (option, value, "gfx_filter_keep_aspect", &p->gfx_filter_keep_aspect)
-       || cfgfile_intval (option, value, "gfx_luminance", &p->gfx_luminance, 1)
-       || cfgfile_intval (option, value, "gfx_contrast", &p->gfx_contrast, 1)
-       || cfgfile_intval (option, value, "gfx_gamma", &p->gfx_gamma, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_vert_zoom", &p->gfx_filter_vert_zoom, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_horiz_zoom", &p->gfx_filter_horiz_zoom, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_vert_zoom_mult", &p->gfx_filter_vert_zoom_mult, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_horiz_zoom_mult", &p->gfx_filter_horiz_zoom_mult, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_vert_offset", &p->gfx_filter_vert_offset, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_horiz_offset", &p->gfx_filter_horiz_offset, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_scanlines", &p->gfx_filter_scanlines, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_scanlinelevel", &p->gfx_filter_scanlinelevel, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_scanlineratio", &p->gfx_filter_scanlineratio, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_luminance", &p->gfx_filter_luminance, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_contrast", &p->gfx_filter_contrast, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_saturation", &p->gfx_filter_saturation, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_gamma", &p->gfx_filter_gamma, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_blur", &p->gfx_filter_blur, 1)
+       || cfgfile_intval (option, value, L"gfx_filter_noise", &p->gfx_filter_noise, 1)
+       || cfgfile_yesno  (option, value, L"gfx_filter_keep_aspect", &p->gfx_filter_keep_aspect)
+       || cfgfile_intval (option, value, L"gfx_luminance", &p->gfx_luminance, 1)
+       || cfgfile_intval (option, value, L"gfx_contrast", &p->gfx_contrast, 1)
+       || cfgfile_intval (option, value, L"gfx_gamma", &p->gfx_gamma, 1)
 #endif
-       || cfgfile_intval (option, value, "floppy0sound", &p->dfxclick[0], 1)
-       || cfgfile_intval (option, value, "floppy1sound", &p->dfxclick[1], 1)
-       || cfgfile_intval (option, value, "floppy2sound", &p->dfxclick[2], 1)
-       || cfgfile_intval (option, value, "floppy3sound", &p->dfxclick[3], 1)
-       || cfgfile_intval (option, value, "floppy_volume", &p->dfxclickvolume, 1)
-       || cfgfile_intval (option, value, "override_dga_address", &p->override_dga_address, 1))
+       || cfgfile_intval (option, value, L"floppy0sound", &p->dfxclick[0], 1)
+       || cfgfile_intval (option, value, L"floppy1sound", &p->dfxclick[1], 1)
+       || cfgfile_intval (option, value, L"floppy2sound", &p->dfxclick[2], 1)
+       || cfgfile_intval (option, value, L"floppy3sound", &p->dfxclick[3], 1)
+       || cfgfile_intval (option, value, L"floppy_volume", &p->dfxclickvolume, 1)
+       || cfgfile_intval (option, value, L"override_dga_address", &p->override_dga_address, 1))
            return 1;
 
-    if (cfgfile_string (option, value, "floppy0soundext", p->dfxclickexternal[0], sizeof p->dfxclickexternal[0])
-       || cfgfile_string (option, value, "floppy1soundext", p->dfxclickexternal[1], sizeof p->dfxclickexternal[1])
-       || cfgfile_string (option, value, "floppy2soundext", p->dfxclickexternal[2], sizeof p->dfxclickexternal[2])
-       || cfgfile_string (option, value, "floppy3soundext", p->dfxclickexternal[3], sizeof p->dfxclickexternal[3])
-       || cfgfile_string (option, value, "gfx_display_name", p->gfx_display_name, sizeof p->gfx_display_name)
-       || cfgfile_string (option, value, "config_info", p->info, sizeof p->info)
-       || cfgfile_string (option, value, "config_description", p->description, sizeof p->description))
+    if (cfgfile_string (option, value, L"floppy0soundext", p->dfxclickexternal[0], sizeof p->dfxclickexternal[0] / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"floppy1soundext", p->dfxclickexternal[1], sizeof p->dfxclickexternal[1] / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"floppy2soundext", p->dfxclickexternal[2], sizeof p->dfxclickexternal[2] / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"floppy3soundext", p->dfxclickexternal[3], sizeof p->dfxclickexternal[3] / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"gfx_display_name", p->gfx_display_name, sizeof p->gfx_display_name / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"config_info", p->info, sizeof p->info / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"config_description", p->description, sizeof p->description / sizeof (TCHAR)))
            return 1;
 
-    if (cfgfile_yesno (option, value, "use_debugger", &p->start_debugger)
-       || cfgfile_yesno (option, value, "sound_auto", &p->sound_auto)
-       || cfgfile_yesno (option, value, "sound_stereo_swap_paula", &p->sound_stereo_swap_paula)
-       || cfgfile_yesno (option, value, "sound_stereo_swap_ahi", &p->sound_stereo_swap_ahi)
-       || cfgfile_yesno (option, value, "state_replay", &p->statecapture)
-       || cfgfile_yesno (option, value, "avoid_cmov", &p->avoid_cmov)
-       || cfgfile_yesno (option, value, "avoid_dga", &p->avoid_dga)
-       || cfgfile_yesno (option, value, "avoid_vid", &p->avoid_vid)
-       || cfgfile_yesno (option, value, "log_illegal_mem", &p->illegal_mem)
-       || cfgfile_yesno (option, value, "filesys_no_fsdb", &p->filesys_no_uaefsdb)
-       || cfgfile_yesno (option, value, "gfx_vsync", &p->gfx_avsync)
-       || cfgfile_yesno (option, value, "gfx_vsync_picasso", &p->gfx_pvsync)
-       || cfgfile_yesno (option, value, "gfx_blacker_than_black", &p->gfx_blackerthanblack)
-       || cfgfile_yesno (option, value, "gfx_flickerfixer", &p->gfx_scandoubler)
-       || cfgfile_yesno (option, value, "show_leds", &p->leds_on_screen)
-       || cfgfile_yesno (option, value, "synchronize_clock", &p->tod_hack)
-       || cfgfile_yesno (option, value, "magic_mouse", &p->input_magic_mouse)
-       || cfgfile_yesno (option, value, "bsdsocket_emu", &p->socket_emu))
+    if (cfgfile_yesno (option, value, L"use_debugger", &p->start_debugger)
+       || cfgfile_yesno (option, value, L"sound_auto", &p->sound_auto)
+       || cfgfile_yesno (option, value, L"sound_stereo_swap_paula", &p->sound_stereo_swap_paula)
+       || cfgfile_yesno (option, value, L"sound_stereo_swap_ahi", &p->sound_stereo_swap_ahi)
+       || cfgfile_yesno (option, value, L"state_replay", &p->statecapture)
+       || cfgfile_yesno (option, value, L"avoid_cmov", &p->avoid_cmov)
+       || cfgfile_yesno (option, value, L"avoid_dga", &p->avoid_dga)
+       || cfgfile_yesno (option, value, L"avoid_vid", &p->avoid_vid)
+       || cfgfile_yesno (option, value, L"log_illegal_mem", &p->illegal_mem)
+       || cfgfile_yesno (option, value, L"filesys_no_fsdb", &p->filesys_no_uaefsdb)
+       || cfgfile_yesno (option, value, L"gfx_vsync", &p->gfx_avsync)
+       || cfgfile_yesno (option, value, L"gfx_vsync_picasso", &p->gfx_pvsync)
+       || cfgfile_yesno (option, value, L"gfx_blacker_than_black", &p->gfx_blackerthanblack)
+       || cfgfile_yesno (option, value, L"gfx_flickerfixer", &p->gfx_scandoubler)
+       || cfgfile_yesno (option, value, L"show_leds", &p->leds_on_screen)
+       || cfgfile_yesno (option, value, L"synchronize_clock", &p->tod_hack)
+       || cfgfile_yesno (option, value, L"magic_mouse", &p->input_magic_mouse)
+       || cfgfile_yesno (option, value, L"bsdsocket_emu", &p->socket_emu))
            return 1;
 
-    if (cfgfile_strval (option, value, "sound_output", &p->produce_sound, soundmode1, 1)
-       || cfgfile_strval (option, value, "sound_output", &p->produce_sound, soundmode2, 0)
-       || cfgfile_strval (option, value, "sound_interpol", &p->sound_interpol, interpolmode, 0)
-       || cfgfile_strval (option, value, "sound_filter", &p->sound_filter, soundfiltermode1, 0)
-       || cfgfile_strval (option, value, "sound_filter_type", &p->sound_filter_type, soundfiltermode2, 0)
-       || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode1, 1)
-       || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode2, 1)
-       || cfgfile_strval (option, value, "use_gui", &p->start_gui, guimode3, 0)
-       || cfgfile_strval (option, value, "gfx_resolution", &p->gfx_resolution, lorestype1, 0)
-       || cfgfile_strval (option, value, "gfx_lores", &p->gfx_resolution, lorestype2, 0)
-       || cfgfile_strval (option, value, "gfx_lores_mode", &p->gfx_lores_mode, loresmode, 0)
-       || cfgfile_strval (option, value, "gfx_fullscreen_amiga", &p->gfx_afullscreen, fullmodes, 0)
-       || cfgfile_strval (option, value, "gfx_fullscreen_picasso", &p->gfx_pfullscreen, fullmodes, 0)
-       || cfgfile_strval (option, value, "gfx_linemode", &p->gfx_linedbl, linemode1, 1)
-       || cfgfile_strval (option, value, "gfx_linemode", &p->gfx_linedbl, linemode2, 0)
-       || cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_xcenter, centermode1, 1)
-       || cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_ycenter, centermode1, 1)
-       || cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_xcenter, centermode2, 0)
-       || cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_ycenter, centermode2, 0)
-       || cfgfile_strval (option, value, "gfx_colour_mode", &p->color_mode, colormode1, 1)
-       || cfgfile_strval (option, value, "gfx_colour_mode", &p->color_mode, colormode2, 0)
-       || cfgfile_strval (option, value, "gfx_color_mode", &p->color_mode, colormode1, 1)
-       || cfgfile_strval (option, value, "gfx_color_mode", &p->color_mode, colormode2, 0)
-       || cfgfile_strval (option, value, "gfx_max_horizontal", &p->gfx_max_horizontal, maxhoriz, 0)
-       || cfgfile_strval (option, value, "gfx_max_vertical", &p->gfx_max_vertical, maxvert, 0)
-       || cfgfile_strval (option, value, "gfx_filter_autoscale", &p->gfx_filter_autoscale, autoscale, 0)
-       || cfgfile_strval (option, value, "magic_mousecursor", &p->input_magic_mouse_cursor, magiccursors, 0)
-       || cfgfile_strval (option, value, "absolute_mouse", &p->input_tablet, abspointers, 0))
+    if (cfgfile_strval (option, value, L"sound_output", &p->produce_sound, soundmode1, 1)
+       || cfgfile_strval (option, value, L"sound_output", &p->produce_sound, soundmode2, 0)
+       || cfgfile_strval (option, value, L"sound_interpol", &p->sound_interpol, interpolmode, 0)
+       || cfgfile_strval (option, value, L"sound_filter", &p->sound_filter, soundfiltermode1, 0)
+       || cfgfile_strval (option, value, L"sound_filter_type", &p->sound_filter_type, soundfiltermode2, 0)
+       || cfgfile_strval (option, value, L"use_gui", &p->start_gui, guimode1, 1)
+       || cfgfile_strval (option, value, L"use_gui", &p->start_gui, guimode2, 1)
+       || cfgfile_strval (option, value, L"use_gui", &p->start_gui, guimode3, 0)
+       || cfgfile_strval (option, value, L"gfx_resolution", &p->gfx_resolution, lorestype1, 0)
+       || cfgfile_strval (option, value, L"gfx_lores", &p->gfx_resolution, lorestype2, 0)
+       || cfgfile_strval (option, value, L"gfx_lores_mode", &p->gfx_lores_mode, loresmode, 0)
+       || cfgfile_strval (option, value, L"gfx_fullscreen_amiga", &p->gfx_afullscreen, fullmodes, 0)
+       || cfgfile_strval (option, value, L"gfx_fullscreen_picasso", &p->gfx_pfullscreen, fullmodes, 0)
+       || cfgfile_strval (option, value, L"gfx_linemode", &p->gfx_linedbl, linemode1, 1)
+       || cfgfile_strval (option, value, L"gfx_linemode", &p->gfx_linedbl, linemode2, 0)
+       || cfgfile_strval (option, value, L"gfx_center_horizontal", &p->gfx_xcenter, centermode1, 1)
+       || cfgfile_strval (option, value, L"gfx_center_vertical", &p->gfx_ycenter, centermode1, 1)
+       || cfgfile_strval (option, value, L"gfx_center_horizontal", &p->gfx_xcenter, centermode2, 0)
+       || cfgfile_strval (option, value, L"gfx_center_vertical", &p->gfx_ycenter, centermode2, 0)
+       || cfgfile_strval (option, value, L"gfx_colour_mode", &p->color_mode, colormode1, 1)
+       || cfgfile_strval (option, value, L"gfx_colour_mode", &p->color_mode, colormode2, 0)
+       || cfgfile_strval (option, value, L"gfx_color_mode", &p->color_mode, colormode1, 1)
+       || cfgfile_strval (option, value, L"gfx_color_mode", &p->color_mode, colormode2, 0)
+       || cfgfile_strval (option, value, L"gfx_max_horizontal", &p->gfx_max_horizontal, maxhoriz, 0)
+       || cfgfile_strval (option, value, L"gfx_max_vertical", &p->gfx_max_vertical, maxvert, 0)
+       || cfgfile_strval (option, value, L"gfx_filter_autoscale", &p->gfx_filter_autoscale, autoscale, 0)
+       || cfgfile_strval (option, value, L"magic_mousecursor", &p->input_magic_mouse_cursor, magiccursors, 0)
+       || cfgfile_strval (option, value, L"absolute_mouse", &p->input_tablet, abspointers, 0))
            return 1;
 
 
 #ifdef GFXFILTER
-    if (strcmp (option,"gfx_filter") == 0) {
+    if (_tcscmp (option, L"gfx_filter") == 0) {
        int i = 0;
-       char *s = strchr (value, ':');
+       TCHAR *s = _tcschr (value, ':');
        if (s)
            *s++ = 0;
        p->gfx_filtershader[0] = 0;
        p->gfx_filter = 0;
        while(uaefilters[i].name) {
-           if (!strcmp (uaefilters[i].cfgname, value)) {
+           if (!_tcscmp (uaefilters[i].cfgname, value)) {
                p->gfx_filter = uaefilters[i].type;
                if (s)
-                   strcpy (p->gfx_filtershader, s);
+                   _tcscpy (p->gfx_filtershader, s);
                break;
            }
            i++;
        }
        return 1;
     }
-    if (strcmp (option,"gfx_filter_mode") == 0) {
+    if (_tcscmp (option, L"gfx_filter_mode") == 0) {
        p->gfx_filter_filtermode = 0;
        if (p->gfx_filter > 0) {
            struct uae_filter *uf;
@@ -1009,7 +1024,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
                uf = &uaefilters[i];
                if (uf->type == p->gfx_filter) {
                    if (uf->x[0]) {
-                       cfgfile_strval (option, value, "gfx_filter_mode", &p->gfx_filter_filtermode, filtermode1, 0);
+                       cfgfile_strval (option, value, L"gfx_filter_mode", &p->gfx_filter_filtermode, filtermode1, 0);
                    } else {
                        int mt[4], j;
                        i = 0;
@@ -1021,7 +1036,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
                            mt[i++] = 3;
                        if (uf->x[4])
                            mt[i++] = 4;
-                       cfgfile_strval (option, value, "gfx_filter_mode", &i, filtermode2, 0);
+                       cfgfile_strval (option, value, L"gfx_filter_mode", &i, filtermode2, 0);
                        for (j = 0; j < i; j++) {
                            if (mt[j] == i)
                                p->gfx_filter_filtermode = j;
@@ -1034,15 +1049,15 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
        }
        return 1;
     }
-    if (cfgfile_string (option, value, "gfx_filter_aspect_ratio", tmpbuf, sizeof tmpbuf)) {
+    if (cfgfile_string (option, value, L"gfx_filter_aspect_ratio", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
        int v1, v2;
-       char *s;
+       TCHAR *s;
        
        p->gfx_filter_aspect = -1;
-       v1 = atol (tmpbuf);
-       s = strchr (tmpbuf, ':');
+       v1 = _tstol (tmpbuf);
+       s = _tcschr (tmpbuf, ':');
        if (s) {
-           v2 = atol (s + 1);
+           v2 = _tstol (s + 1);
            if (v1 < 0 || v2 < 0)
                p->gfx_filter_aspect = -1;
            else if (v1 == 0 || v2 == 0)
@@ -1054,63 +1069,63 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
     }
 #endif
 
-    if (strcmp (option, "gfx_width") == 0 || strcmp (option, "gfx_height") == 0) {
-       cfgfile_intval (option, value, "gfx_width", &p->gfx_size_win.width, 1);
-       cfgfile_intval (option, value, "gfx_height", &p->gfx_size_win.height, 1);
+    if (_tcscmp (option, L"gfx_width") == 0 || _tcscmp (option, L"gfx_height") == 0) {
+       cfgfile_intval (option, value, L"gfx_width", &p->gfx_size_win.width, 1);
+       cfgfile_intval (option, value, L"gfx_height", &p->gfx_size_win.height, 1);
        p->gfx_size_fs.width = p->gfx_size_win.width;
        p->gfx_size_fs.height = p->gfx_size_win.height;
        return 1;
     }
 
-    if (strcmp (option, "gfx_fullscreen_multi") == 0 || strcmp (option, "gfx_windowed_multi") == 0) {
-       char tmp[256], *tmpp, *tmpp2;
+    if (_tcscmp (option, L"gfx_fullscreen_multi") == 0 || _tcscmp (option, L"gfx_windowed_multi") == 0) {
+       TCHAR tmp[256], *tmpp, *tmpp2;
        struct wh *wh = p->gfx_size_win_xtra;
-       if (strcmp (option, "gfx_fullscreen_multi") == 0)
+       if (_tcscmp (option, L"gfx_fullscreen_multi") == 0)
            wh = p->gfx_size_fs_xtra;
-       sprintf (tmp, ",%s,", value);
+       _stprintf (tmp, L",%s,", value);
        tmpp2 = tmp;
        for (i = 0; i < 4; i++) {
-           tmpp = strchr (tmpp2, ',');
+           tmpp = _tcschr (tmpp2, ',');
            tmpp++;
-           wh[i].width = atol (tmpp);
+           wh[i].width = _tstol (tmpp);
            while (*tmpp != ',' && *tmpp != 'x')
                tmpp++;
-           wh[i].height = atol (tmpp + 1);
+           wh[i].height = _tstol (tmpp + 1);
            tmpp2 = tmpp;
        }
        return 1;
     }
 
-    if (strcmp (option, "joyportfriendlyname0") == 0 || strcmp (option, "joyportfriendlyname1") == 0) {
-       inputdevice_joyport_config (p, value, strcmp (option, "joyportfriendlyname0") == 0 ? 0 : 1, 2);
+    if (_tcscmp (option, L"joyportfriendlyname0") == 0 || _tcscmp (option, L"joyportfriendlyname1") == 0) {
+       inputdevice_joyport_config (p, value, _tcscmp (option, L"joyportfriendlyname0") == 0 ? 0 : 1, 2);
        return 1;
     }
-    if (strcmp (option, "joyportname0") == 0 || strcmp (option, "joyportname1") == 0) {
-       inputdevice_joyport_config (p, value, strcmp (option, "joyportname0") == 0 ? 0 : 1, 1);
+    if (_tcscmp (option, L"joyportname0") == 0 || _tcscmp (option, L"joyportname1") == 0) {
+       inputdevice_joyport_config (p, value, _tcscmp (option, L"joyportname0") == 0 ? 0 : 1, 1);
        return 1;
     }
 
-    if (strcmp (option, "joyport0") == 0 || strcmp (option, "joyport1") == 0) {
-       inputdevice_joyport_config (p, value, strcmp (option, "joyport0") == 0 ? 0 : 1, 0);
+    if (_tcscmp (option, L"joyport0") == 0 || _tcscmp (option, L"joyport1") == 0) {
+       inputdevice_joyport_config (p, value, _tcscmp (option, L"joyport0") == 0 ? 0 : 1, 0);
        return 1;
     }
 
-    if (cfgfile_string (option, value, "statefile", tmpbuf, sizeof (tmpbuf))) {
-       strcpy (savestate_fname, tmpbuf);
+    if (cfgfile_string (option, value, L"statefile", tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) {
+       _tcscpy (savestate_fname, tmpbuf);
        if (zfile_exists (savestate_fname)) {
            savestate_state = STATE_DORESTORE;
        } else {
            int ok = 0;
            if (savestate_fname[0]) {
                for (;;) {
-                   char *p;
+                   TCHAR *p;
                    if (my_existsdir (savestate_fname)) {
                        ok = 1;
                        break;
                    }
-                   p = strrchr (savestate_fname, '\\');
+                   p = _tcsrchr (savestate_fname, '\\');
                    if (!p)
-                       p = strrchr (savestate_fname, '/');
+                       p = _tcsrchr (savestate_fname, '/');
                    if (!p)
                        break;
                    *p = 0;
@@ -1122,7 +1137,7 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
        return 1;
     }
 
-    if (cfgfile_strval (option, value, "sound_channels", &p->sound_stereo, stereomode, 1)) {
+    if (cfgfile_strval (option, value, L"sound_channels", &p->sound_stereo, stereomode, 1)) {
        if (p->sound_stereo == SND_NONE) { /* "mixed stereo" compatibility hack */
            p->sound_stereo = SND_STEREO;
            p->sound_mixed_stereo_delay = 5;
@@ -1131,58 +1146,58 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
        return 1;
     }
 
-    if (strcmp (option, "kbd_lang") == 0) {
+    if (_tcscmp (option, L"kbd_lang") == 0) {
        KbdLang l;
-       if ((l = KBD_LANG_DE, strcasecmp (value, "de") == 0)
-           || (l = KBD_LANG_DK, strcasecmp (value, "dk") == 0)
-           || (l = KBD_LANG_SE, strcasecmp (value, "se") == 0)
-           || (l = KBD_LANG_US, strcasecmp (value, "us") == 0)
-           || (l = KBD_LANG_FR, strcasecmp (value, "fr") == 0)
-           || (l = KBD_LANG_IT, strcasecmp (value, "it") == 0)
-           || (l = KBD_LANG_ES, strcasecmp (value, "es") == 0))
+       if ((l = KBD_LANG_DE, strcasecmp (value, L"de") == 0)
+           || (l = KBD_LANG_DK, strcasecmp (value, L"dk") == 0)
+           || (l = KBD_LANG_SE, strcasecmp (value, L"se") == 0)
+           || (l = KBD_LANG_US, strcasecmp (value, L"us") == 0)
+           || (l = KBD_LANG_FR, strcasecmp (value, L"fr") == 0)
+           || (l = KBD_LANG_IT, strcasecmp (value, L"it") == 0)
+           || (l = KBD_LANG_ES, strcasecmp (value, L"es") == 0))
            p->keyboard_lang = l;
        else
-           write_log ("Unknown keyboard language\n");
+           write_log (L"Unknown keyboard language\n");
        return 1;
     }
 
-    if (cfgfile_string (option, value, "config_version", tmpbuf, sizeof (tmpbuf))) {
-       char *tmpp2;
-       tmpp = strchr (value, '.');
+    if (cfgfile_string (option, value, L"config_version", tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) {
+       TCHAR *tmpp2;
+       tmpp = _tcschr (value, '.');
        if (tmpp) {
            *tmpp++ = 0;
            tmpp2 = tmpp;
-           p->config_version = atol (tmpbuf) << 16;
-           tmpp = strchr (tmpp, '.');
+           p->config_version = _tstol (tmpbuf) << 16;
+           tmpp = _tcschr (tmpp, '.');
            if (tmpp) {
                *tmpp++ = 0;
-               p->config_version |= atol (tmpp2) << 8;
-               p->config_version |= atol (tmpp);
+               p->config_version |= _tstol (tmpp2) << 8;
+               p->config_version |= _tstol (tmpp);
            }
        }
        return 1;
     }
 
-    if (cfgfile_string (option, value, "keyboard_leds", tmpbuf, sizeof (tmpbuf))) {
-       char *tmpp2 = tmpbuf;
+    if (cfgfile_string (option, value, L"keyboard_leds", tmpbuf, sizeof (tmpbuf) / sizeof (TCHAR))) {
+       TCHAR *tmpp2 = tmpbuf;
        int i, num;
        p->keyboard_leds[0] = p->keyboard_leds[1] = p->keyboard_leds[2] = 0;
        p->keyboard_leds_in_use = 0;
-       strcat (tmpbuf, ",");
+       _tcscat (tmpbuf, L",");
        for (i = 0; i < 3; i++) {
-           tmpp = strchr (tmpp2, ':');
+           tmpp = _tcschr (tmpp2, ':');
            if (!tmpp)
                break;
            *tmpp++= 0;
            num = -1;
-           if (!strcasecmp (tmpp2, "numlock"))
+           if (!strcasecmp (tmpp2, L"numlock"))
                num = 0;
-           if (!strcasecmp (tmpp2, "capslock"))
+           if (!strcasecmp (tmpp2, L"capslock"))
                num = 1;
-           if (!strcasecmp (tmpp2, "scrolllock"))
+           if (!strcasecmp (tmpp2, L"scrolllock"))
                num = 2;
            tmpp2 = tmpp;
-           tmpp = strchr (tmpp2, ',');
+           tmpp = _tcschr (tmpp2, ',');
            if (!tmpp)
                break;
            *tmpp++= 0;
@@ -1198,17 +1213,17 @@ static int cfgfile_parse_host (struct uae_prefs *p, char *option, char *value)
     return 0;
 }
 
-static void decode_rom_ident (char *romfile, int maxlen, char *ident)
+static void decode_rom_ident (TCHAR *romfile, int maxlen, TCHAR *ident)
 {
-    char *p;
+    TCHAR *p;
     int ver, rev, subver, subrev, round, i;
-    char model[64], *modelp;
+    TCHAR model[64], *modelp;
     struct romlist **rl;
-    char *romtxt;
+    TCHAR *romtxt;
 
     if (!ident[0])
        return;
-    romtxt = (char*)malloc (10000);
+    romtxt = malloc (10000 * sizeof (TCHAR));
     romtxt[0] = 0;
     for (round = 0; round < 2; round++) {
        ver = rev = subver = subrev = -1;
@@ -1216,40 +1231,40 @@ static void decode_rom_ident (char *romfile, int maxlen, char *ident)
        memset (model, 0, sizeof model);
        p = ident;
        while (*p) {
-           char c = *p++;
+           TCHAR c = *p++;
            int *pp1 = NULL, *pp2 = NULL;
-           if (toupper(c) == 'V' && isdigit(*p)) {
+           if (_totupper(c) == 'V' && _istdigit(*p)) {
                pp1 = &ver;
                pp2 = &rev;
-           } else if (toupper(c) == 'R' && isdigit(*p)) {
+           } else if (_totupper(c) == 'R' && _istdigit(*p)) {
                pp1 = &subver;
                pp2 = &subrev;
-           } else if (!isdigit(c) && c != ' ') {
-               strncpy (model, p - 1, (sizeof model) - 1);
-               p += strlen(model);
+           } else if (!_istdigit(c) && c != ' ') {
+               _tcsncpy (model, p - 1, (sizeof model) - 1);
+               p += _tcslen (model);
                modelp = model;
            }
            if (pp1) {
-               *pp1 = atol(p);
+               *pp1 = _tstol(p);
                while (*p != 0 && *p != '.' && *p != ' ')
                p++;
                if (*p == '.') {
                p++;
                if (pp2)
-                       *pp2 = atol(p);
+                       *pp2 = _tstol(p);
                }
            }
            if (*p == 0 || *p == ';') {
-               rl = getromlistbyident(ver, rev, subver, subrev, modelp, round);
+               rl = getromlistbyident (ver, rev, subver, subrev, modelp, round);
                if (rl) {
                    for (i = 0; rl[i]; i++) {
                        if (round) {
-                           char romname[MAX_DPATH];
+                           TCHAR romname[MAX_DPATH];
                            getromname(rl[i]->rd, romname);
-                           strcat (romtxt, romname);
-                           strcat (romtxt, "\n");
+                           _tcscat (romtxt, romname);
+                           _tcscat (romtxt, L"\n");
                        } else {
-                           strncpy (romfile, rl[i]->path, maxlen);
+                           _tcsncpy (romfile, rl[i]->path, maxlen);
                            goto end;
                        }
                    }
@@ -1262,7 +1277,7 @@ end:
     if (round && romtxt[0]) {
        notify_user_parms (NUMSG_ROMNEED, romtxt, romtxt);
     }
-    xfree(romtxt);
+    xfree (romtxt);
 }
 
 static struct uaedev_config_info *getuci(struct uae_prefs *p)
@@ -1273,13 +1288,13 @@ static struct uaedev_config_info *getuci(struct uae_prefs *p)
 }
 
 struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
-                       char *devname, char *volname, char *rootdir, int readonly,
+                       TCHAR *devname, TCHAR *volname, TCHAR *rootdir, int readonly,
                        int secspertrack, int surfaces, int reserved,
                        int blocksize, int bootpri,
-                       char *filesysdir, int hdc, int flags) {
+                       TCHAR *filesysdir, int hdc, int flags) {
     struct uaedev_config_info *uci;
     int i;
-    char *s;
+    TCHAR *s;
 
     if (index < 0) {
        uci = getuci(p);
@@ -1290,9 +1305,9 @@ struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
     if (!uci)
        return 0;
     uci->ishdf = volname == NULL ? 1 : 0;
-    strcpy (uci->devname, devname ? devname : "");
-    strcpy (uci->volname, volname ? volname : "");
-    strcpy (uci->rootdir, rootdir ? rootdir : "");
+    _tcscpy (uci->devname, devname ? devname : L"");
+    _tcscpy (uci->volname, volname ? volname : L"");
+    _tcscpy (uci->rootdir, rootdir ? rootdir : L"");
     uci->readonly = readonly;
     uci->sectors = secspertrack;
     uci->surfaces = surfaces;
@@ -1306,33 +1321,33 @@ struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
     else if (bootpri >= -127)
        uci->autoboot = 1;
     uci->controller = hdc;
-    strcpy (uci->filesys, filesysdir ? filesysdir : "");
+    _tcscpy (uci->filesys, filesysdir ? filesysdir : L"");
     if (!uci->devname[0]) {
-       char base[32];
-       char base2[32];
+       TCHAR base[32];
+       TCHAR base2[32];
        int num = 0;
        if (uci->rootdir[0] == 0 && !uci->ishdf)
-           strcpy (base, "RDH");
+           _tcscpy (base, L"RDH");
        else
-           strcpy (base, "DH");
-       strcpy (base2, base);
+           _tcscpy (base, L"DH");
+       _tcscpy (base2, base);
        for (i = 0; i < p->mountitems; i++) {
-           sprintf(base2, "%s%d", base, num);
-           if (!strcmp(base2, p->mountconfig[i].devname)) {
+           _stprintf (base2, L"%s%d", base, num);
+           if (!_tcscmp(base2, p->mountconfig[i].devname)) {
                num++;
                i = -1;
                continue;
            }
        }
-       strcpy (uci->devname, base2);
+       _tcscpy (uci->devname, base2);
     }
-    s = filesys_createvolname (volname, rootdir, "Harddrive");
-    strcpy (uci->volname, s);
+    s = filesys_createvolname (volname, rootdir, L"Harddrive");
+    _tcscpy (uci->volname, s);
     xfree (s);
     return uci;
 }
 
-static void parse_addmem (struct uae_prefs *p, char *buf, int num)
+static void parse_addmem (struct uae_prefs *p, TCHAR *buf, int num)
 {
     uae_u32 size = 0, addr = 0;
 
@@ -1348,153 +1363,153 @@ static void parse_addmem (struct uae_prefs *p, char *buf, int num)
     p->custom_memory_sizes[num] = size;
 }
 
-static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *value)
+static int cfgfile_parse_hardware (struct uae_prefs *p, TCHAR *option, TCHAR *value)
 {
     int tmpval, dummyint, i;
-    char *section = 0;
-    char tmpbuf[CONFIG_BLEN];
+    TCHAR *section = 0;
+    TCHAR tmpbuf[CONFIG_BLEN];
 
-    if (cfgfile_yesno (option, value, "cpu_cycle_exact", &p->cpu_cycle_exact)
-       || cfgfile_yesno (option, value, "blitter_cycle_exact", &p->blitter_cycle_exact)) {
+    if (cfgfile_yesno (option, value, L"cpu_cycle_exact", &p->cpu_cycle_exact)
+       || cfgfile_yesno (option, value, L"blitter_cycle_exact", &p->blitter_cycle_exact)) {
        if (p->cpu_model >= 68020 && p->cachesize > 0)
            p->cpu_cycle_exact = p->blitter_cycle_exact = 0;
        /* we don't want cycle-exact in 68020/40+JIT modes */
        return 1;
     }
 
-    if (cfgfile_yesno (option, value, "scsi_a3000", &dummyint)) {
+    if (cfgfile_yesno (option, value, L"scsi_a3000", &dummyint)) {
        if (dummyint)
            p->cs_mbdmac = 1;
        return 1;
     }
-    if (cfgfile_yesno (option, value, "scsi_a4000t", &dummyint)) {
+    if (cfgfile_yesno (option, value, L"scsi_a4000t", &dummyint)) {
        if (dummyint)
            p->cs_mbdmac = 2;
        return 1;
     }
-    if (cfgfile_yesno (option, value, "immediate_blits", &p->immediate_blits)
-       || cfgfile_yesno (option, value, "cd32cd", &p->cs_cd32cd)
-       || cfgfile_yesno (option, value, "cd32c2p", &p->cs_cd32c2p)
-       || cfgfile_yesno (option, value, "cd32nvram", &p->cs_cd32nvram)
-       || cfgfile_yesno (option, value, "cdtvcd", &p->cs_cdtvcd)
-       || cfgfile_yesno (option, value, "cdtvram", &p->cs_cdtvram)
-       || cfgfile_yesno (option, value, "a1000ram", &p->cs_a1000ram)
-       || cfgfile_yesno (option, value, "pcmcia", &p->cs_pcmcia)
-       || cfgfile_yesno (option, value, "scsi_cdtv", &p->cs_cdtvscsi)
-       || cfgfile_yesno (option, value, "scsi_a4091", &p->cs_a4091)
-       || cfgfile_yesno (option, value, "scsi_a2091", &p->cs_a2091)
-       || cfgfile_yesno (option, value, "cia_overlay", &p->cs_ciaoverlay)
-       || cfgfile_yesno (option, value, "bogomem_fast", &p->cs_slowmemisfast)
-       || cfgfile_yesno (option, value, "ksmirror_e0", &p->cs_ksmirror_e0)
-       || cfgfile_yesno (option, value, "ksmirror_a8", &p->cs_ksmirror_a8)
-       || cfgfile_yesno (option, value, "resetwarning", &p->cs_resetwarning)
-       || cfgfile_yesno (option, value, "denise_noehb", &p->cs_denisenoehb)
-       || cfgfile_yesno (option, value, "agnus_bltbusybug", &p->cs_agnusbltbusybug)
-
-       || cfgfile_yesno (option, value, "kickshifter", &p->kickshifter)
-       || cfgfile_yesno (option, value, "ntsc", &p->ntscmode)
-       || cfgfile_yesno (option, value, "sana2", &p->sana2)
-       || cfgfile_yesno (option, value, "genlock", &p->genlock)
-       || cfgfile_yesno (option, value, "cpu_compatible", &p->cpu_compatible)
-       || cfgfile_yesno (option, value, "cpu_24bit_addressing", &p->address_space_24)
-       || cfgfile_yesno (option, value, "parallel_on_demand", &p->parallel_demand)
-       || cfgfile_yesno (option, value, "parallel_postscript_emulation", &p->parallel_postscript_emulation)
-       || cfgfile_yesno (option, value, "parallel_postscript_detection", &p->parallel_postscript_detection)
-       || cfgfile_yesno (option, value, "serial_on_demand", &p->serial_demand)
-       || cfgfile_yesno (option, value, "serial_hardware_ctsrts", &p->serial_hwctsrts)
-       || cfgfile_yesno (option, value, "serial_direct", &p->serial_direct)
-       || cfgfile_yesno (option, value, "comp_nf", &p->compnf)
-       || cfgfile_yesno (option, value, "comp_constjump", &p->comp_constjump)
-       || cfgfile_yesno (option, value, "comp_oldsegv", &p->comp_oldsegv)
-       || cfgfile_yesno (option, value, "compforcesettings", &dummyint)
-       || cfgfile_yesno (option, value, "compfpu", &p->compfpu)
-       || cfgfile_yesno (option, value, "fpu_strict", &p->fpu_strict)
-       || cfgfile_yesno (option, value, "comp_midopt", &p->comp_midopt)
-       || cfgfile_yesno (option, value, "comp_lowopt", &p->comp_lowopt)
-       || cfgfile_yesno (option, value, "rtg_nocustom", &p->picasso96_nocustom)
-       || cfgfile_yesno (option, value, "uaeserial", &p->uaeserial))
+    if (cfgfile_yesno (option, value, L"immediate_blits", &p->immediate_blits)
+       || cfgfile_yesno (option, value, L"cd32cd", &p->cs_cd32cd)
+       || cfgfile_yesno (option, value, L"cd32c2p", &p->cs_cd32c2p)
+       || cfgfile_yesno (option, value, L"cd32nvram", &p->cs_cd32nvram)
+       || cfgfile_yesno (option, value, L"cdtvcd", &p->cs_cdtvcd)
+       || cfgfile_yesno (option, value, L"cdtvram", &p->cs_cdtvram)
+       || cfgfile_yesno (option, value, L"a1000ram", &p->cs_a1000ram)
+       || cfgfile_yesno (option, value, L"pcmcia", &p->cs_pcmcia)
+       || cfgfile_yesno (option, value, L"scsi_cdtv", &p->cs_cdtvscsi)
+       || cfgfile_yesno (option, value, L"scsi_a4091", &p->cs_a4091)
+       || cfgfile_yesno (option, value, L"scsi_a2091", &p->cs_a2091)
+       || cfgfile_yesno (option, value, L"cia_overlay", &p->cs_ciaoverlay)
+       || cfgfile_yesno (option, value, L"bogomem_fast", &p->cs_slowmemisfast)
+       || cfgfile_yesno (option, value, L"ksmirror_e0", &p->cs_ksmirror_e0)
+       || cfgfile_yesno (option, value, L"ksmirror_a8", &p->cs_ksmirror_a8)
+       || cfgfile_yesno (option, value, L"resetwarning", &p->cs_resetwarning)
+       || cfgfile_yesno (option, value, L"denise_noehb", &p->cs_denisenoehb)
+       || cfgfile_yesno (option, value, L"agnus_bltbusybug", &p->cs_agnusbltbusybug)
+
+       || cfgfile_yesno (option, value, L"kickshifter", &p->kickshifter)
+       || cfgfile_yesno (option, value, L"ntsc", &p->ntscmode)
+       || cfgfile_yesno (option, value, L"sana2", &p->sana2)
+       || cfgfile_yesno (option, value, L"genlock", &p->genlock)
+       || cfgfile_yesno (option, value, L"cpu_compatible", &p->cpu_compatible)
+       || cfgfile_yesno (option, value, L"cpu_24bit_addressing", &p->address_space_24)
+       || cfgfile_yesno (option, value, L"parallel_on_demand", &p->parallel_demand)
+       || cfgfile_yesno (option, value, L"parallel_postscript_emulation", &p->parallel_postscript_emulation)
+       || cfgfile_yesno (option, value, L"parallel_postscript_detection", &p->parallel_postscript_detection)
+       || cfgfile_yesno (option, value, L"serial_on_demand", &p->serial_demand)
+       || cfgfile_yesno (option, value, L"serial_hardware_ctsrts", &p->serial_hwctsrts)
+       || cfgfile_yesno (option, value, L"serial_direct", &p->serial_direct)
+       || cfgfile_yesno (option, value, L"comp_nf", &p->compnf)
+       || cfgfile_yesno (option, value, L"comp_constjump", &p->comp_constjump)
+       || cfgfile_yesno (option, value, L"comp_oldsegv", &p->comp_oldsegv)
+       || cfgfile_yesno (option, value, L"compforcesettings", &dummyint)
+       || cfgfile_yesno (option, value, L"compfpu", &p->compfpu)
+       || cfgfile_yesno (option, value, L"fpu_strict", &p->fpu_strict)
+       || cfgfile_yesno (option, value, L"comp_midopt", &p->comp_midopt)
+       || cfgfile_yesno (option, value, L"comp_lowopt", &p->comp_lowopt)
+       || cfgfile_yesno (option, value, L"rtg_nocustom", &p->picasso96_nocustom)
+       || cfgfile_yesno (option, value, L"uaeserial", &p->uaeserial))
        return 1;
 
-    if (cfgfile_intval (option, value, "cachesize", &p->cachesize, 1)
-       || cfgfile_intval (option, value, "cpu060_revision", &p->cpu060_revision, 1)
-       || cfgfile_intval (option, value, "fpu_revision", &p->fpu_revision, 1)
-       || cfgfile_intval (option, value, "cdtvramcard", &p->cs_cdtvcard, 1)
-       || cfgfile_intval (option, value, "fatgary", &p->cs_fatgaryrev, 1)
-       || cfgfile_intval (option, value, "ramsey", &p->cs_ramseyrev, 1)
-       || cfgfile_intval (option, value, "chipset_refreshrate", &p->chipset_refreshrate, 1)
-       || cfgfile_intval (option, value, "fastmem_size", &p->fastmem_size, 0x100000)
-       || cfgfile_intval (option, value, "a3000mem_size", &p->mbresmem_low_size, 0x100000)
-       || cfgfile_intval (option, value, "mbresmem_size", &p->mbresmem_high_size, 0x100000)
-       || cfgfile_intval (option, value, "z3mem_size", &p->z3fastmem_size, 0x100000)
-       || cfgfile_intval (option, value, "z3mem2_size", &p->z3fastmem2_size, 0x100000)
-       || cfgfile_intval (option, value, "z3mem_start", &p->z3fastmem_start, 1)
-       || cfgfile_intval (option, value, "bogomem_size", &p->bogomem_size, 0x40000)
-       || cfgfile_intval (option, value, "gfxcard_size", &p->gfxmem_size, 0x100000)
-       || cfgfile_intval (option, value, "rtg_modes", &p->picasso96_modeflags, 1)
-       || cfgfile_intval (option, value, "floppy_speed", &p->floppy_speed, 1)
-       || cfgfile_intval (option, value, "floppy_write_length", &p->floppy_write_length, 1)
-       || cfgfile_intval (option, value, "nr_floppies", &p->nr_floppies, 1)
-       || cfgfile_intval (option, value, "floppy0type", &p->dfxtype[0], 1)
-       || cfgfile_intval (option, value, "floppy1type", &p->dfxtype[1], 1)
-       || cfgfile_intval (option, value, "floppy2type", &p->dfxtype[2], 1)
-       || cfgfile_intval (option, value, "floppy3type", &p->dfxtype[3], 1)
-       || cfgfile_intval (option, value, "maprom", &p->maprom, 1)
-       || cfgfile_intval (option, value, "parallel_autoflush", &p->parallel_autoflush_time, 1)
-       || cfgfile_intval (option, value, "uae_hide", &p->uae_hide, 1)
-       || cfgfile_intval (option, value, "catweasel", &p->catweasel, 1))
+    if (cfgfile_intval (option, value, L"cachesize", &p->cachesize, 1)
+       || cfgfile_intval (option, value, L"cpu060_revision", &p->cpu060_revision, 1)
+       || cfgfile_intval (option, value, L"fpu_revision", &p->fpu_revision, 1)
+       || cfgfile_intval (option, value, L"cdtvramcard", &p->cs_cdtvcard, 1)
+       || cfgfile_intval (option, value, L"fatgary", &p->cs_fatgaryrev, 1)
+       || cfgfile_intval (option, value, L"ramsey", &p->cs_ramseyrev, 1)
+       || cfgfile_intval (option, value, L"chipset_refreshrate", &p->chipset_refreshrate, 1)
+       || cfgfile_intval (option, value, L"fastmem_size", &p->fastmem_size, 0x100000)
+       || cfgfile_intval (option, value, L"a3000mem_size", &p->mbresmem_low_size, 0x100000)
+       || cfgfile_intval (option, value, L"mbresmem_size", &p->mbresmem_high_size, 0x100000)
+       || cfgfile_intval (option, value, L"z3mem_size", &p->z3fastmem_size, 0x100000)
+       || cfgfile_intval (option, value, L"z3mem2_size", &p->z3fastmem2_size, 0x100000)
+       || cfgfile_intval (option, value, L"z3mem_start", &p->z3fastmem_start, 1)
+       || cfgfile_intval (option, value, L"bogomem_size", &p->bogomem_size, 0x40000)
+       || cfgfile_intval (option, value, L"gfxcard_size", &p->gfxmem_size, 0x100000)
+       || cfgfile_intval (option, value, L"rtg_modes", &p->picasso96_modeflags, 1)
+       || cfgfile_intval (option, value, L"floppy_speed", &p->floppy_speed, 1)
+       || cfgfile_intval (option, value, L"floppy_write_length", &p->floppy_write_length, 1)
+       || cfgfile_intval (option, value, L"nr_floppies", &p->nr_floppies, 1)
+       || cfgfile_intval (option, value, L"floppy0type", &p->dfxtype[0], 1)
+       || cfgfile_intval (option, value, L"floppy1type", &p->dfxtype[1], 1)
+       || cfgfile_intval (option, value, L"floppy2type", &p->dfxtype[2], 1)
+       || cfgfile_intval (option, value, L"floppy3type", &p->dfxtype[3], 1)
+       || cfgfile_intval (option, value, L"maprom", &p->maprom, 1)
+       || cfgfile_intval (option, value, L"parallel_autoflush", &p->parallel_autoflush_time, 1)
+       || cfgfile_intval (option, value, L"uae_hide", &p->uae_hide, 1)
+       || cfgfile_intval (option, value, L"catweasel", &p->catweasel, 1))
        return 1;
 
-    if (cfgfile_strval (option, value, "comp_trustbyte", &p->comptrustbyte, compmode, 0)
-       || cfgfile_strval (option, value, "chipset_compatible", &p->cs_compatible, cscompa, 0)
-       || cfgfile_strval (option, value, "rtc", &p->cs_rtc, rtctype, 0)
-       || cfgfile_strval (option, value, "ksmirror", &p->cs_ksmirror_e0, ksmirrortype, 0)
-       || cfgfile_strval (option, value, "ciaatod", &p->cs_ciaatod, ciaatodmode, 0)
-       || cfgfile_strval (option, value, "ide", &p->cs_ide, idemode, 0)
-       || cfgfile_strval (option, value, "scsi", &p->scsi, scsimode, 0)
-       || cfgfile_strval (option, value, "comp_trustword", &p->comptrustword, compmode, 0)
-       || cfgfile_strval (option, value, "comp_trustlong", &p->comptrustlong, compmode, 0)
-       || cfgfile_strval (option, value, "comp_trustnaddr", &p->comptrustnaddr, compmode, 0)
-       || cfgfile_strval (option, value, "collision_level", &p->collision_level, collmode, 0)
-       || cfgfile_strval (option, value, "comp_flushmode", &p->comp_hardflush, flushmode, 0))
+    if (cfgfile_strval (option, value, L"comp_trustbyte", &p->comptrustbyte, compmode, 0)
+       || cfgfile_strval (option, value, L"chipset_compatible", &p->cs_compatible, cscompa, 0)
+       || cfgfile_strval (option, value, L"rtc", &p->cs_rtc, rtctype, 0)
+       || cfgfile_strval (option, value, L"ksmirror", &p->cs_ksmirror_e0, ksmirrortype, 0)
+       || cfgfile_strval (option, value, L"ciaatod", &p->cs_ciaatod, ciaatodmode, 0)
+       || cfgfile_strval (option, value, L"ide", &p->cs_ide, idemode, 0)
+       || cfgfile_strval (option, value, L"scsi", &p->scsi, scsimode, 0)
+       || cfgfile_strval (option, value, L"comp_trustword", &p->comptrustword, compmode, 0)
+       || cfgfile_strval (option, value, L"comp_trustlong", &p->comptrustlong, compmode, 0)
+       || cfgfile_strval (option, value, L"comp_trustnaddr", &p->comptrustnaddr, compmode, 0)
+       || cfgfile_strval (option, value, L"collision_level", &p->collision_level, collmode, 0)
+       || cfgfile_strval (option, value, L"comp_flushmode", &p->comp_hardflush, flushmode, 0))
        return 1;
 
-    if (cfgfile_string (option, value, "kickstart_rom_file", p->romfile, sizeof p->romfile)
-       || cfgfile_string (option, value, "kickstart_ext_rom_file", p->romextfile, sizeof p->romextfile)
-       || cfgfile_string (option, value, "amax_rom_file", p->amaxromfile, sizeof p->amaxromfile)
-       || cfgfile_string (option, value, "flash_file", p->flashfile, sizeof p->flashfile)
-       || cfgfile_string (option, value, "cart_file", p->cartfile, sizeof p->cartfile)
-       || cfgfile_string (option, value, "pci_devices", p->pci_devices, sizeof p->pci_devices)
-       || cfgfile_string (option, value, "ghostscript_parameters", p->ghostscript_parameters, sizeof p->ghostscript_parameters))
+    if (cfgfile_string (option, value, L"kickstart_rom_file", p->romfile, sizeof p->romfile / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"kickstart_ext_rom_file", p->romextfile, sizeof p->romextfile / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"amax_rom_file", p->amaxromfile, sizeof p->amaxromfile / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"flash_file", p->flashfile, sizeof p->flashfile / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"cart_file", p->cartfile, sizeof p->cartfile / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"pci_devices", p->pci_devices, sizeof p->pci_devices / sizeof (TCHAR))
+       || cfgfile_string (option, value, L"ghostscript_parameters", p->ghostscript_parameters, sizeof p->ghostscript_parameters / sizeof (TCHAR)))
        return 1;
 
-    if (cfgfile_strval (option, value, "cart_internal", &p->cart_internal, cartsmode, 0)) {
+    if (cfgfile_strval (option, value, L"cart_internal", &p->cart_internal, cartsmode, 0)) {
        if (p->cart_internal) {
-           struct romdata *rd = getromdatabyid(63);
+           struct romdata *rd = getromdatabyid (63);
            if (rd)
-               sprintf(p->cartfile, ":%s", rd->configname);
+               _stprintf (p->cartfile, L":%s", rd->configname);
        }
        return 1;
     }
-    if (cfgfile_string (option, value, "kickstart_rom", p->romident, sizeof p->romident)) {
-       decode_rom_ident (p->romfile, sizeof p->romfile, p->romident);
+    if (cfgfile_string (option, value, L"kickstart_rom", p->romident, sizeof p->romident / sizeof (TCHAR))) {
+       decode_rom_ident (p->romfile, sizeof p->romfile / sizeof (TCHAR), p->romident);
        return 1;
     }
-    if (cfgfile_string (option, value, "kickstart_ext_rom", p->romextident, sizeof p->romextident)) {
-       decode_rom_ident (p->romextfile, sizeof p->romextfile, p->romextident);
+    if (cfgfile_string (option, value, L"kickstart_ext_rom", p->romextident, sizeof p->romextident / sizeof (TCHAR))) {
+       decode_rom_ident (p->romextfile, sizeof p->romextfile / sizeof (TCHAR), p->romextident);
        return 1;
     }
-    if (cfgfile_string (option, value, "cart", p->cartident, sizeof p->cartident)) {
-       decode_rom_ident (p->cartfile, sizeof p->cartfile, p->cartident);
+    if (cfgfile_string (option, value, L"cart", p->cartident, sizeof p->cartident / sizeof (TCHAR))) {
+       decode_rom_ident (p->cartfile, sizeof p->cartfile / sizeof (TCHAR), p->cartident);
        return 1;
     }
 
     for (i = 0; i < 4; i++) {
-       sprintf (tmpbuf, "floppy%d", i);
-       if (cfgfile_string (option, value, tmpbuf, p->df[i], sizeof p->df[i]))
+       _stprintf (tmpbuf, L"floppy%d", i);
+       if (cfgfile_string (option, value, tmpbuf, p->df[i], sizeof p->df[i] / sizeof (TCHAR)))
            return 1;
     }
 
-    if (cfgfile_intval (option, value, "chipmem_size", &dummyint, 1)) {
+    if (cfgfile_intval (option, value, L"chipmem_size", &dummyint, 1)) {
        if (dummyint < 0)
            p->chipmem_size = 0x20000; /* 128k, prototype support */
        else if (dummyint == 0)
@@ -1504,56 +1519,56 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
        return 1;
     }
 
-    if (cfgfile_string (option, value, "addmem1", tmpbuf, sizeof tmpbuf)) {
+    if (cfgfile_string (option, value, L"addmem1", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
        parse_addmem (p, tmpbuf, 0);
        return 1;
     }
-    if (cfgfile_string (option, value, "addmem2", tmpbuf, sizeof tmpbuf)) {
+    if (cfgfile_string (option, value, L"addmem2", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
        parse_addmem (p, tmpbuf, 1);
        return 1;
     }
 
-    if (cfgfile_strval (option, value, "chipset", &tmpval, csmode, 0)) {
+    if (cfgfile_strval (option, value, L"chipset", &tmpval, csmode, 0)) {
        set_chipset_mask (p, tmpval);
        return 1;
     }
 
-    if (cfgfile_string (option, value, "fpu_model", tmpbuf, sizeof tmpbuf)) {
-       p->fpu_model = atol(tmpbuf);
+    if (cfgfile_string (option, value, L"fpu_model", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
+       p->fpu_model = _tstol(tmpbuf);
        return 1;
     }
 
-    if (cfgfile_string (option, value, "cpu_model", tmpbuf, sizeof tmpbuf)) {
-       p->cpu_model = atol(tmpbuf);
+    if (cfgfile_string (option, value, L"cpu_model", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
+       p->cpu_model = _tstol(tmpbuf);
        p->fpu_model = 0;
        return 1;
     }
 
     /* old-style CPU configuration */
-    if (cfgfile_string (option, value, "cpu_type", tmpbuf, sizeof tmpbuf)) {
+    if (cfgfile_string (option, value, L"cpu_type", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
        p->fpu_model = 0;
        p->address_space_24 = 0;
        p->cpu_model = 680000;
-       if (!strcmp(tmpbuf, "68000")) {
+       if (!_tcscmp (tmpbuf, L"68000")) {
            p->cpu_model = 68000;
-       } else if (!strcmp(tmpbuf, "68010")) {
+       } else if (!_tcscmp (tmpbuf, L"68010")) {
            p->cpu_model = 68010;
-       } else if (!strcmp(tmpbuf, "68ec020")) {
+       } else if (!_tcscmp (tmpbuf, L"68ec020")) {
            p->cpu_model = 68020;
            p->address_space_24 = 1;
-       } else if (!strcmp(tmpbuf, "68020")) {
+       } else if (!_tcscmp (tmpbuf, L"68020")) {
            p->cpu_model = 68020;
-       } else if (!strcmp(tmpbuf, "68ec020/68881")) {
+       } else if (!_tcscmp (tmpbuf, L"68ec020/68881")) {
            p->cpu_model = 68020;
            p->fpu_model = 68881;
            p->address_space_24 = 1;
-       } else if (!strcmp(tmpbuf, "68020/68881")) {
+       } else if (!_tcscmp (tmpbuf, L"68020/68881")) {
            p->cpu_model = 68020;
            p->fpu_model = 68881;
-       } else if (!strcmp(tmpbuf, "68040")) {
+       } else if (!_tcscmp (tmpbuf, L"68040")) {
            p->cpu_model = 68040;
            p->fpu_model = 68040;
-       } else if (!strcmp(tmpbuf, "68060")) {
+       } else if (!_tcscmp (tmpbuf, L"68060")) {
            p->cpu_model = 68060;
            p->fpu_model = 68060;
        }
@@ -1561,44 +1576,44 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
     }
 
     if (p->config_version < (21 << 16)) {
-       if (cfgfile_strval (option, value, "cpu_speed", &p->m68k_speed, speedmode, 1)
+       if (cfgfile_strval (option, value, L"cpu_speed", &p->m68k_speed, speedmode, 1)
            /* Broken earlier versions used to write this out as a string.  */
-           || cfgfile_strval (option, value, "finegraincpu_speed", &p->m68k_speed, speedmode, 1))
+           || cfgfile_strval (option, value, L"finegraincpu_speed", &p->m68k_speed, speedmode, 1))
        {
            p->m68k_speed--;
            return 1;
        }
     }
 
-    if (cfgfile_intval (option, value, "cpu_speed", &p->m68k_speed, 1)) {
+    if (cfgfile_intval (option, value, L"cpu_speed", &p->m68k_speed, 1)) {
        p->m68k_speed *= CYCLE_UNIT;
        return 1;
     }
 
-    if (cfgfile_intval (option, value, "finegrain_cpu_speed", &p->m68k_speed, 1)) {
+    if (cfgfile_intval (option, value, L"finegrain_cpu_speed", &p->m68k_speed, 1)) {
        if (OFFICIAL_CYCLE_UNIT > CYCLE_UNIT) {
            int factor = OFFICIAL_CYCLE_UNIT / CYCLE_UNIT;
            p->m68k_speed = (p->m68k_speed + factor - 1) / factor;
        }
-       if (strcasecmp (value, "max") == 0)
+       if (strcasecmp (value, L"max") == 0)
            p->m68k_speed = -1;
        return 1;
     }
 
     for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
-       char tmp[100];
-       sprintf (tmp, "uaehf%d", i);
-       if (strcmp (option, tmp) == 0)
+       TCHAR tmp[100];
+       _stprintf (tmp, L"uaehf%d", i);
+       if (_tcscmp (option, tmp) == 0)
            return 1;
     }
  
-    if (strcmp (option, "filesystem") == 0
-       || strcmp (option, "hardfile") == 0)
+    if (_tcscmp (option, L"filesystem") == 0
+       || _tcscmp (option, L"hardfile") == 0)
     {
        int secs, heads, reserved, bs, ro;
-       char *aname, *root;
-       char *tmpp = strchr (value, ',');
-       char *str;
+       TCHAR *aname, *root;
+       TCHAR *tmpp = _tcschr (value, ',');
+       TCHAR *str;
 
        if (config_newfilesystem)
            return 1;
@@ -1607,21 +1622,21 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
            goto invalid_fs;
 
        *tmpp++ = '\0';
-       if (strcmp (value, "1") == 0 || strcasecmp (value, "ro") == 0
-           || strcasecmp (value, "readonly") == 0
-           || strcasecmp (value, "read-only") == 0)
+       if (_tcscmp (value, L"1") == 0 || strcasecmp (value, L"ro") == 0
+           || strcasecmp (value, L"readonly") == 0
+           || strcasecmp (value, L"read-only") == 0)
            ro = 1;
-       else if (strcmp (value, "0") == 0 || strcasecmp (value, "rw") == 0
-                || strcasecmp (value, "readwrite") == 0
-                || strcasecmp (value, "read-write") == 0)
+       else if (_tcscmp (value, L"0") == 0 || strcasecmp (value, L"rw") == 0
+                || strcasecmp (value, L"readwrite") == 0
+                || strcasecmp (value, L"read-write") == 0)
            ro = 0;
        else
            goto invalid_fs;
        secs = 0; heads = 0; reserved = 0; bs = 0;
 
        value = tmpp;
-       if (strcmp (option, "filesystem") == 0) {
-           tmpp = strchr (value, ':');
+       if (_tcscmp (option, L"filesystem") == 0) {
+           tmpp = _tcschr (value, ':');
            if (tmpp == 0)
                goto invalid_fs;
            *tmpp++ = '\0';
@@ -1645,22 +1660,22 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
 
     }
 
-    if (strcmp (option, "filesystem2") == 0
-       || strcmp (option, "hardfile2") == 0)
+    if (_tcscmp (option, L"filesystem2") == 0
+       || _tcscmp (option, L"hardfile2") == 0)
     {
        int secs, heads, reserved, bs, ro, bp, hdcv;
-       char *dname = NULL, *aname = "", *root = NULL, *fs = NULL, *hdc;
-       char *tmpp = strchr (value, ',');
-       char *str = NULL;
+       TCHAR *dname = NULL, *aname = L"", *root = NULL, *fs = NULL, *hdc;
+       TCHAR *tmpp = _tcschr (value, ',');
+       TCHAR *str = NULL;
 
        config_newfilesystem = 1;
        if (tmpp == 0)
            goto invalid_fs;
 
        *tmpp++ = '\0';
-       if (strcasecmp (value, "ro") == 0)
+       if (strcasecmp (value, L"ro") == 0)
            ro = 1;
-       else if (strcasecmp (value, "rw") == 0)
+       else if (strcasecmp (value, L"rw") == 0)
            ro = 0;
        else
            goto invalid_fs;
@@ -1668,32 +1683,32 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
        fs = 0; hdc = 0; hdcv = 0;
 
        value = tmpp;
-       if (strcmp (option, "filesystem2") == 0) {
-           tmpp = strchr (value, ':');
+       if (_tcscmp (option, L"filesystem2") == 0) {
+           tmpp = _tcschr (value, ':');
            if (tmpp == 0)
                goto empty_fs;
            *tmpp++ = 0;
            dname = value;
            aname = tmpp;
-           tmpp = strchr (tmpp, ':');
+           tmpp = _tcschr (tmpp, ':');
            if (tmpp == 0)
                goto empty_fs;
            *tmpp++ = 0;
            root = tmpp;
-           tmpp = strchr (tmpp, ',');
+           tmpp = _tcschr (tmpp, ',');
            if (tmpp == 0)
                goto empty_fs;
            *tmpp++ = 0;
            if (! getintval (&tmpp, &bp, 0))
                goto empty_fs;
        } else {
-           tmpp = strchr (value, ':');
+           tmpp = _tcschr (value, ':');
            if (tmpp == 0)
                goto invalid_fs;
            *tmpp++ = '\0';
            dname = value;
            root = tmpp;
-           tmpp = strchr (tmpp, ',');
+           tmpp = _tcschr (tmpp, ',');
            if (tmpp == 0)
                goto invalid_fs;
            *tmpp++ = 0;
@@ -1705,21 +1720,21 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
                goto invalid_fs;
            if (getintval2 (&tmpp, &bp, ',')) {
                fs = tmpp;
-               tmpp = strchr (tmpp, ',');
+               tmpp = _tcschr (tmpp, ',');
                if (tmpp != 0) {
                    *tmpp++ = 0;
                    hdc = tmpp;
-                   if(strlen (hdc) >= 4 && !memcmp( hdc, "ide", 3)) {
+                   if(_tcslen (hdc) >= 4 && !_tcsncmp (hdc, L"ide", 3)) {
                        hdcv = hdc[3] - '0' + HD_CONTROLLER_IDE0;
                        if (hdcv < HD_CONTROLLER_IDE0 || hdcv > HD_CONTROLLER_IDE3)
                            hdcv = 0;
                    }
-                   if(strlen (hdc) >= 5 && !memcmp (hdc, "scsi", 4)) {
+                   if(_tcslen (hdc) >= 5 && !_tcsncmp (hdc, L"scsi", 4)) {
                        hdcv = hdc[4] - '0' + HD_CONTROLLER_SCSI0;
                        if (hdcv < HD_CONTROLLER_SCSI0 || hdcv > HD_CONTROLLER_SCSI6)
                            hdcv = 0;
                    }
-                   if (strlen (hdc) >= 6 && !memcmp (hdc, "scsram", 6))
+                   if (_tcslen (hdc) >= 6 && !_tcsncmp (hdc, L"scsram", 6))
                        hdcv = HD_CONTROLLER_PCMCIA_SRAM;
                }
            }
@@ -1734,22 +1749,22 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, char *option, char *valu
        return 1;
 
       invalid_fs:
-       write_log ("Invalid filesystem/hardfile specification.\n");
+       write_log (L"Invalid filesystem/hardfile specification.\n");
        return 1;
     }
 
     return 0;
 }
 
-int cfgfile_parse_option (struct uae_prefs *p, char *option, char *value, int type)
+int cfgfile_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value, int type)
 {
-    if (!strcmp (option, "config_hardware"))
+    if (!_tcscmp (option, L"config_hardware"))
        return 1;
-    if (!strcmp (option, "config_host"))
+    if (!_tcscmp (option, L"config_host"))
        return 1;
-    if (cfgfile_string (option, value, "config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path))
+    if (cfgfile_string (option, value, L"config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path / sizeof (TCHAR)))
        return 1;
-    if (cfgfile_string (option, value, "config_host_path", p->config_host_path, sizeof p->config_host_path))
+    if (cfgfile_string (option, value, L"config_host_path", p->config_host_path, sizeof p->config_host_path / sizeof (TCHAR)))
        return 1;
     if (type == 0 || (type & CONFIG_TYPE_HARDWARE)) {
        if (cfgfile_parse_hardware (p, option, value))
@@ -1764,66 +1779,66 @@ int cfgfile_parse_option (struct uae_prefs *p, char *option, char *value, int ty
     return 0;
 }
 
-static int cfgfile_separate_line (char *line, char *line1b, char *line2b)
+static int cfgfile_separate_line (TCHAR *line, TCHAR *line1b, TCHAR *line2b)
 {
-    char *line1, *line2;
+    TCHAR *line1, *line2;
     int i;
 
     line1 = line;
-    line2 = strchr (line, '=');
+    line2 = _tcschr (line, '=');
     if (! line2) {
-       write_log ("CFGFILE: line was incomplete with only %s\n", line1);
+       write_log (L"CFGFILE: line was incomplete with only %s\n", line1);
        return 0;
     }
     *line2++ = '\0';
-    strcpy (line1b, line1);
-    strcpy (line2b, line2);
+    _tcscpy (line1b, line1);
+    _tcscpy (line2b, line2);
 
     /* Get rid of whitespace.  */
-    i = strlen (line2);
+    i = _tcslen (line2);
     while (i > 0 && (line2[i - 1] == '\t' || line2[i - 1] == ' '
                     || line2[i - 1] == '\r' || line2[i - 1] == '\n'))
        line2[--i] = '\0';
-    line2 += strspn (line2, "\t \r\n");
-    strcpy (line2b, line2);
-    i = strlen (line);
+    line2 += _tcsspn (line2, L"\t \r\n");
+    _tcscpy (line2b, line2);
+    i = _tcslen (line);
     while (i > 0 && (line[i - 1] == '\t' || line[i - 1] == ' '
                     || line[i - 1] == '\r' || line[i - 1] == '\n'))
        line[--i] = '\0';
-    line += strspn (line, "\t \r\n");
-    strcpy (line1b, line);
+    line += _tcsspn (line, L"\t \r\n");
+    _tcscpy (line1b, line);
     return 1;
 }
 
-static int isobsolete (char *s)
+static int isobsolete (TCHAR *s)
 {
     int i = 0;
     while (obsolete[i]) {
        if (!strcasecmp (s, obsolete[i])) {
-           write_log ("obsolete config entry '%s'\n", s);
+           write_log (L"obsolete config entry '%s'\n", s);
            return 1;
        }
        i++;
     }
-    if (strlen (s) >= 10 && !memcmp (s, "gfx_opengl", 10)) {
-       write_log ("obsolete config entry '%s\n", s);
+    if (_tcslen (s) >= 10 && !_tcsncmp (s, L"gfx_opengl", 10)) {
+       write_log (L"obsolete config entry '%s\n", s);
        return 1;
     }
-    if (strlen (s) >= 6 && !memcmp (s, "gfx_3d", 6)) {
-       write_log ("obsolete config entry '%s\n", s);
+    if (_tcslen (s) >= 6 && !_tcsncmp (s, L"gfx_3d", 6)) {
+       write_log (L"obsolete config entry '%s\n", s);
        return 1;
     }
     return 0;
 }
 
-static void cfgfile_parse_separated_line (struct uae_prefs *p, char *line1b, char *line2b, int type)
+static void cfgfile_parse_separated_line (struct uae_prefs *p, TCHAR *line1b, TCHAR *line2b, int type)
 {
-    char line3b[CONFIG_BLEN], line4b[CONFIG_BLEN];
+    TCHAR line3b[CONFIG_BLEN], line4b[CONFIG_BLEN];
     struct strlist *sl;
     int ret;
 
-    strcpy (line3b, line1b);
-    strcpy (line4b, line2b);
+    _tcscpy (line3b, line1b);
+    _tcscpy (line4b, line2b);
     ret = cfgfile_parse_option (p, line1b, line2b, type);
     if (!isobsolete (line3b)) {
        for (sl = p->all_lines; sl; sl = sl->next) {
@@ -1831,41 +1846,41 @@ static void cfgfile_parse_separated_line (struct uae_prefs *p, char *line1b, cha
        }
        if (!sl) {
            struct strlist *u = xcalloc (sizeof (struct strlist), 1);
-           u->option = my_strdup(line3b);
-           u->value = my_strdup(line4b);
+           u->option = my_strdup (line3b);
+           u->value = my_strdup (line4b);
            u->next = p->all_lines;
            p->all_lines = u;
            if (!ret) {
                u->unknown = 1;
-               write_log ("unknown config entry: '%s=%s'\n", u->option, u->value);
+               write_log (L"unknown config entry: '%s=%s'\n", u->option, u->value);
            }
        }
     }
 }
 
-void cfgfile_parse_line (struct uae_prefs *p, char *line, int type)
+void cfgfile_parse_line (struct uae_prefs *p, TCHAR *line, int type)
 {
-    char line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
+    TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
 
     if (!cfgfile_separate_line (line, line1b, line2b))
        return;
     cfgfile_parse_separated_line (p, line1b, line2b, type);
 }
 
-static void subst (char *p, char *f, int n)
+static void subst (TCHAR *p, TCHAR *f, int n)
 {
-    char *str = cfgfile_subst_path (UNEXPANDED, p, f);
-    strncpy (f, str, n - 1);
+    TCHAR *str = cfgfile_subst_path (UNEXPANDED, p, f);
+    _tcsncpy (f, str, n - 1);
     f[n - 1] = '\0';
     free (str);
 }
 
-static char *cfg_fgets (char *line, int max, struct zfile *fh)
+static TCHAR *cfg_fgets (TCHAR *line, int max, struct zfile *fh)
 {
 #ifdef SINGLEFILE
-    extern char singlefile_config[];
-    static char *sfile_ptr;
-    char *p;
+    extern TCHAR singlefile_config[];
+    static TCHAR *sfile_ptr;
+    TCHAR *p;
 #endif
 
     if (fh)
@@ -1874,7 +1889,7 @@ static char *cfg_fgets (char *line, int max, struct zfile *fh)
     if (sfile_ptr == 0) {
        sfile_ptr = singlefile_config;
        if (*sfile_ptr) {
-           write_log ("singlefile config found\n");
+           write_log (L"singlefile config found\n");
            while (*sfile_ptr++);
        }
     }
@@ -1885,7 +1900,7 @@ static char *cfg_fgets (char *line, int max, struct zfile *fh)
     p = sfile_ptr;
     while (*p != 13 && *p != 10 && *p != 0) p++;
     memset (line, 0, max);
-    memcpy (line, sfile_ptr, p - sfile_ptr);
+    memcpy (line, sfile_ptr, (p - sfile_ptr) * sizeof (TCHAR));
     sfile_ptr = p + 1;
     if (*sfile_ptr == 13)
        sfile_ptr++;
@@ -1896,11 +1911,11 @@ static char *cfg_fgets (char *line, int max, struct zfile *fh)
     return 0;
 }
 
-static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real, int *type)
+static int cfgfile_load_2 (struct uae_prefs *p, const TCHAR *filename, int real, int *type)
 {
     int i;
     struct zfile *fh;
-    char line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
+    TCHAR line[CONFIG_BLEN], line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
     struct strlist *sl;
     int type1 = 0, type2 = 0, askedtype = 0;
 
@@ -1914,22 +1929,22 @@ static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real,
        reset_inputdevice_config (p);
     }
 
-    fh = zfile_fopen (filename, "r");
+    fh = zfile_fopen (filename, L"r");
 #ifndef        SINGLEFILE
     if (! fh)
        return 0;
 #endif
 
-    while (cfg_fgets (line, sizeof (line), fh) != 0) {
+    while (cfg_fgets (line, sizeof (line) / sizeof (TCHAR), fh) != 0) {
        trimws (line);
-       if (strlen (line) > 0) {
+       if (_tcslen (line) > 0) {
            if (line[0] == '#' || line[0] == ';')
                continue;
            if (!cfgfile_separate_line (line, line1b, line2b))
                continue;
            type1 = type2 = 0;
-           if (cfgfile_yesno (line1b, line2b, "config_hardware", &type1) ||
-               cfgfile_yesno (line1b, line2b, "config_host", &type2)) {
+           if (cfgfile_yesno (line1b, line2b, L"config_hardware", &type1) ||
+               cfgfile_yesno (line1b, line2b, L"config_host", &type2)) {
                if (type1 && type)
                    *type |= CONFIG_TYPE_HARDWARE;
                if (type2 && type)
@@ -1939,9 +1954,9 @@ static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real,
            if (real) {
                cfgfile_parse_separated_line (p, line1b, line2b, askedtype);
            } else {
-               cfgfile_string (line1b, line2b, "config_description", p->description, sizeof p->description);
-               cfgfile_string (line1b, line2b, "config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path);
-               cfgfile_string (line1b, line2b, "config_host_path", p->config_host_path, sizeof p->config_host_path);
+               cfgfile_string (line1b, line2b, L"config_description", p->description, sizeof p->description / sizeof (TCHAR));
+               cfgfile_string (line1b, line2b, L"config_hardware_path", p->config_hardware_path, sizeof p->config_hardware_path / sizeof (TCHAR));
+               cfgfile_string (line1b, line2b, L"config_host_path", p->config_host_path, sizeof p->config_host_path / sizeof (TCHAR));
            }
        }
     }
@@ -1954,44 +1969,44 @@ static int cfgfile_load_2 (struct uae_prefs *p, const char *filename, int real,
        return 1;
 
     for (sl = temp_lines; sl; sl = sl->next) {
-       sprintf (line, "%s=%s", sl->option, sl->value);
+       _stprintf (line, L"%s=%s", sl->option, sl->value);
        cfgfile_parse_line (p, line, 0);
     }
 
     for (i = 0; i < 4; i++)
        subst (p->path_floppy, p->df[i], sizeof p->df[i]);
-    subst (p->path_rom, p->romfile, sizeof p->romfile);
-    subst (p->path_rom, p->romextfile, sizeof p->romextfile);
+    subst (p->path_rom, p->romfile, sizeof p->romfile / sizeof (TCHAR));
+    subst (p->path_rom, p->romextfile, sizeof p->romextfile / sizeof (TCHAR));
 
     return 1;
 }
 
-int cfgfile_load (struct uae_prefs *p, const char *filename, int *type, int ignorelink)
+int cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink)
 {
     int v;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     int type2;
     static int recursive;
 
     if (recursive > 1)
        return 0;
     recursive++;
-    write_log ("load config '%s':%d\n", filename, type ? *type : -1);
+    write_log (L"load config '%s':%d\n", filename, type ? *type : -1);
     v = cfgfile_load_2 (p, filename, 1, type);
     if (!v) {
-       write_log ("load failed\n");
+       write_log (L"load failed\n");
        goto end;
     }
     if (!ignorelink) {
        if (p->config_hardware_path[0]) {
-           fetch_configurationpath (tmp, sizeof (tmp));
-           strncat (tmp, p->config_hardware_path, sizeof (tmp));
+           fetch_configurationpath (tmp, sizeof (tmp) / sizeof (TCHAR));
+           _tcsncat (tmp, p->config_hardware_path, sizeof (tmp) / sizeof (TCHAR));
            type2 = CONFIG_TYPE_HARDWARE;
            cfgfile_load (p, tmp, &type2, 1);
        }
        if (p->config_host_path[0]) {
-           fetch_configurationpath (tmp, sizeof (tmp));
-           strncat (tmp, p->config_host_path, sizeof (tmp));
+           fetch_configurationpath (tmp, sizeof (tmp) / sizeof (TCHAR));
+           _tcsncat (tmp, p->config_host_path, sizeof (tmp) / sizeof (TCHAR));
            type2 = CONFIG_TYPE_HOST;
            cfgfile_load (p, tmp, &type2, 1);
        }
@@ -2002,23 +2017,22 @@ end:
     return v;
 }
 
-void cfgfile_backup (const char        *path)
+void cfgfile_backup (const TCHAR *path)
 {
-    char dpath[MAX_DPATH];
+    TCHAR dpath[MAX_DPATH];
 
-    fetch_configurationpath (dpath, sizeof (dpath));
-    strcat (dpath, "configuration.backup");
+    fetch_configurationpath (dpath, sizeof (dpath) / sizeof (TCHAR));
+    _tcscat (dpath, L"configuration.backup");
     my_unlink (dpath);
     my_rename (path, dpath);
 }
 
-int cfgfile_save (struct uae_prefs *p, const char *filename, int type)
+int cfgfile_save (struct uae_prefs *p, const TCHAR *filename, int type)
 {
     struct zfile *fh;
 
     cfgfile_backup (filename);
-    fh = zfile_fopen (filename, "w");
-    write_log ("save config '%s'\n", filename);
+    fh = zfile_fopen (filename, unicode_config ? L"w, ccs=UTF-8" : L"w");
     if (! fh)
        return 0;
 
@@ -2029,7 +2043,7 @@ int cfgfile_save (struct uae_prefs *p, const char *filename, int type)
     return 1;
 }
 
-int cfgfile_get_description (const char *filename, char *description, char *hostlink, char *hardwarelink, int *type)
+int cfgfile_get_description (const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type)
 {
     int result = 0;
     struct uae_prefs *p = xmalloc (sizeof (struct uae_prefs));
@@ -2040,11 +2054,11 @@ int cfgfile_get_description (const char *filename, char *description, char *host
     if (cfgfile_load_2 (p, filename, 0, type)) {
        result = 1;
        if (description)
-           strcpy (description, p->description);
+           _tcscpy (description, p->description);
        if (hostlink)
-           strcpy (hostlink, p->config_host_path);
+           _tcscpy (hostlink, p->config_host_path);
        if (hardwarelink)
-           strcpy (hardwarelink, p->config_hardware_path);
+           _tcscpy (hardwarelink, p->config_hardware_path);
     }
     xfree (p);
     return result;
@@ -2061,76 +2075,76 @@ int cfgfile_configuration_change (int v)
 void cfgfile_show_usage (void)
 {
     int i;
-    write_log ("UAE Configuration Help:\n" \
-              "=======================\n");
+    write_log (L"UAE Configuration Help:\n" \
+              L"=======================\n");
     for (i = 0; i < sizeof opttable / sizeof *opttable; i++)
-       write_log ("%s: %s\n", opttable[i].config_label, opttable[i].config_help);
+       write_log (L"%s: %s\n", opttable[i].config_label, opttable[i].config_help);
 }
 
 /* This implements the old commandline option parsing. I've re-added this
    because the new way of doing things is painful for me (it requires me
    to type a couple hundred characters when invoking UAE).  The following
    is far less annoying to use.  */
-static void parse_gfx_specs (struct uae_prefs *p, char *spec)
+static void parse_gfx_specs (struct uae_prefs *p, const TCHAR *spec)
 {
-    char *x0 = my_strdup (spec);
-    char *x1, *x2;
+    TCHAR *x0 = my_strdup (spec);
+    TCHAR *x1, *x2;
 
-    x1 = strchr (x0, ':');
+    x1 = _tcschr (x0, ':');
     if (x1 == 0)
        goto argh;
-    x2 = strchr (x1+1, ':');
+    x2 = _tcschr (x1+1, ':');
     if (x2 == 0)
        goto argh;
     *x1++ = 0; *x2++ = 0;
 
-    p->gfx_size_win.width = p->gfx_size_fs.width = atoi (x0);
-    p->gfx_size_win.height = p->gfx_size_fs.height = atoi (x1);
-    p->gfx_resolution = strchr (x2, 'l') != 0 ? 1 : 0;
-    p->gfx_xcenter = strchr (x2, 'x') != 0 ? 1 : strchr (x2, 'X') != 0 ? 2 : 0;
-    p->gfx_ycenter = strchr (x2, 'y') != 0 ? 1 : strchr (x2, 'Y') != 0 ? 2 : 0;
-    p->gfx_linedbl = strchr (x2, 'd') != 0;
-    p->gfx_linedbl += 2 * (strchr (x2, 'D') != 0);
-    p->gfx_afullscreen = strchr (x2, 'a') != 0;
-    p->gfx_pfullscreen = strchr (x2, 'p') != 0;
+    p->gfx_size_win.width = p->gfx_size_fs.width = _tstoi (x0);
+    p->gfx_size_win.height = p->gfx_size_fs.height = _tstoi (x1);
+    p->gfx_resolution = _tcschr (x2, 'l') != 0 ? 1 : 0;
+    p->gfx_xcenter = _tcschr (x2, 'x') != 0 ? 1 : _tcschr (x2, 'X') != 0 ? 2 : 0;
+    p->gfx_ycenter = _tcschr (x2, 'y') != 0 ? 1 : _tcschr (x2, 'Y') != 0 ? 2 : 0;
+    p->gfx_linedbl = _tcschr (x2, 'd') != 0;
+    p->gfx_linedbl += 2 * (_tcschr (x2, 'D') != 0);
+    p->gfx_afullscreen = _tcschr (x2, 'a') != 0;
+    p->gfx_pfullscreen = _tcschr (x2, 'p') != 0;
 
     if (p->gfx_linedbl == 3) {
-       write_log ("You can't use both 'd' and 'D' modifiers in the display mode specification.\n");
+       write_log (L"You can't use both 'd' and 'D' modifiers in the display mode specification.\n");
     }
 
     free (x0);
     return;
 
     argh:
-    write_log ("Bad display mode specification.\n");
-    write_log ("The format to use is: \"width:height:modifiers\"\n");
-    write_log ("Type \"uae -h\" for detailed help.\n");
+    write_log (L"Bad display mode specification.\n");
+    write_log (L"The format to use is: \"width:height:modifiers\"\n");
+    write_log (L"Type \"uae -h\" for detailed help.\n");
     free (x0);
 }
 
-static void parse_sound_spec (struct uae_prefs *p, char *spec)
+static void parse_sound_spec (struct uae_prefs *p, const TCHAR *spec)
 {
-    char *x0 = my_strdup (spec);
-    char *x1, *x2 = NULL, *x3 = NULL, *x4 = NULL, *x5 = NULL;
+    TCHAR *x0 = my_strdup (spec);
+    TCHAR *x1, *x2 = NULL, *x3 = NULL, *x4 = NULL, *x5 = NULL;
 
-    x1 = strchr (x0, ':');
+    x1 = _tcschr (x0, ':');
     if (x1 != NULL) {
        *x1++ = '\0';
-       x2 = strchr (x1 + 1, ':');
+       x2 = _tcschr (x1 + 1, ':');
        if (x2 != NULL) {
            *x2++ = '\0';
-           x3 = strchr (x2 + 1, ':');
+           x3 = _tcschr (x2 + 1, ':');
            if (x3 != NULL) {
                *x3++ = '\0';
-               x4 = strchr (x3 + 1, ':');
+               x4 = _tcschr (x3 + 1, ':');
                if (x4 != NULL) {
                    *x4++ = '\0';
-                   x5 = strchr (x4 + 1, ':');
+                   x5 = _tcschr (x4 + 1, ':');
                }
            }
        }
     }
-    p->produce_sound = atoi (x0);
+    p->produce_sound = _tstoi (x0);
     if (x1) {
        p->sound_stereo_separation = 0;
        if (*x1 == 'S') {
@@ -2142,17 +2156,17 @@ static void parse_sound_spec (struct uae_prefs *p, char *spec)
            p->sound_stereo = SND_MONO;
     }
     if (x3)
-       p->sound_freq = atoi (x3);
+       p->sound_freq = _tstoi (x3);
     if (x4)
-       p->sound_maxbsiz = atoi (x4);
+       p->sound_maxbsiz = _tstoi (x4);
     free (x0);
 }
 
 
-static void parse_joy_spec (struct uae_prefs *p, char *spec)
+static void parse_joy_spec (struct uae_prefs *p, const TCHAR *spec)
 {
     int v0 = 2, v1 = 0;
-    if (strlen(spec) != 2)
+    if (_tcslen(spec) != 2)
        goto bad;
 
     switch (spec[0]) {
@@ -2179,28 +2193,28 @@ static void parse_joy_spec (struct uae_prefs *p, char *spec)
     /* Let's scare Pascal programmers */
     if (0)
 bad:
-    write_log ("Bad joystick mode specification. Use -J xy, where x and y\n"
-            "can be 0 for joystick 0, 1 for joystick 1, M for mouse, and\n"
-            "a, b or c for different keyboard settings.\n");
+    write_log (L"Bad joystick mode specification. Use -J xy, where x and y\n"
+            L"can be 0 for joystick 0, 1 for joystick 1, M for mouse, and\n"
+            L"a, b or c for different keyboard settings.\n");
 
     p->jports[0].id = v0;
     p->jports[1].id = v1;
 }
 
-static void parse_filesys_spec (struct uae_prefs *p, int readonly, char *spec)
+static void parse_filesys_spec (struct uae_prefs *p, int readonly, const TCHAR *spec)
 {
-    char buf[256];
-    char *s2;
+    TCHAR buf[256];
+    TCHAR *s2;
 
-    strncpy (buf, spec, 255); buf[255] = 0;
-    s2 = strchr (buf, ':');
+    _tcsncpy (buf, spec, 255); buf[255] = 0;
+    s2 = _tcschr (buf, ':');
     if (s2) {
        *s2++ = '\0';
 #ifdef __DOS__
        {
-           char *tmp;
+           TCHAR *tmp;
 
-           while ((tmp = strchr (s2, '\\')))
+           while ((tmp = _tcschr (s2, '\\')))
                *tmp = '/';
        }
 #endif
@@ -2208,47 +2222,47 @@ static void parse_filesys_spec (struct uae_prefs *p, int readonly, char *spec)
        add_filesys_config (p, -1, NULL, buf, s2, readonly, 0, 0, 0, 0, 0, 0, 0, 0);
 #endif
     } else {
-       write_log ("Usage: [-m | -M] VOLNAME:mount_point\n");
+       write_log (L"Usage: [-m | -M] VOLNAME:mount_point\n");
     }
 }
 
-static void parse_hardfile_spec (struct uae_prefs *p, char *spec)
+static void parse_hardfile_spec (struct uae_prefs *p, const TCHAR *spec)
 {
-    char *x0 = my_strdup (spec);
-    char *x1, *x2, *x3, *x4;
+    TCHAR *x0 = my_strdup (spec);
+    TCHAR *x1, *x2, *x3, *x4;
 
-    x1 = strchr (x0, ':');
+    x1 = _tcschr (x0, ':');
     if (x1 == NULL)
        goto argh;
     *x1++ = '\0';
-    x2 = strchr (x1 + 1, ':');
+    x2 = _tcschr (x1 + 1, ':');
     if (x2 == NULL)
        goto argh;
     *x2++ = '\0';
-    x3 = strchr (x2 + 1, ':');
+    x3 = _tcschr (x2 + 1, ':');
     if (x3 == NULL)
        goto argh;
     *x3++ = '\0';
-    x4 = strchr (x3 + 1, ':');
+    x4 = _tcschr (x3 + 1, ':');
     if (x4 == NULL)
        goto argh;
     *x4++ = '\0';
 #ifdef FILESYS
-    add_filesys_config (p, -1, NULL, NULL, x4, 0, atoi (x0), atoi (x1), atoi (x2), atoi (x3), 0, 0, 0, 0);
+    add_filesys_config (p, -1, NULL, NULL, x4, 0, _tstoi (x0), _tstoi (x1), _tstoi (x2), _tstoi (x3), 0, 0, 0, 0);
 #endif
     free (x0);
     return;
 
  argh:
     free (x0);
-    write_log ("Bad hardfile parameter specified - type \"uae -h\" for help.\n");
+    write_log (L"Bad hardfile parameter specified - type \"uae -h\" for help.\n");
     return;
 }
 
-static void parse_cpu_specs (struct uae_prefs *p, char *spec)
+static void parse_cpu_specs (struct uae_prefs *p, const TCHAR *spec)
 {
     if (*spec < '0' || *spec > '4') {
-       write_log ("CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n");
+       write_log (L"CPU parameter string must begin with '0', '1', '2', '3' or '4'.\n");
        return;
     }
 
@@ -2259,21 +2273,21 @@ static void parse_cpu_specs (struct uae_prefs *p, char *spec)
        switch (*spec) {
         case 'a':
            if (p->cpu_model < 68020)
-               write_log ("In 68000/68010 emulation, the address space is always 24 bit.\n");
+               write_log (L"In 68000/68010 emulation, the address space is always 24 bit.\n");
            else if (p->cpu_model >= 68040)
-               write_log ("In 68040/060 emulation, the address space is always 32 bit.\n");
+               write_log (L"In 68040/060 emulation, the address space is always 32 bit.\n");
            else
                p->address_space_24 = 1;
            break;
         case 'c':
            if (p->cpu_model != 68000)
-               write_log  ("The more compatible CPU emulation is only available for 68000\n"
-                        "emulation, not for 68010 upwards.\n");
+               write_log (L"The more compatible CPU emulation is only available for 68000\n"
+                        L"emulation, not for 68010 upwards.\n");
            else
                p->cpu_compatible = 1;
            break;
         default:
-           write_log  ("Bad CPU parameter specified - type \"uae -h\" for help.\n");
+           write_log (L"Bad CPU parameter specified - type \"uae -h\" for help.\n");
            break;
        }
        spec++;
@@ -2281,38 +2295,38 @@ static void parse_cpu_specs (struct uae_prefs *p, char *spec)
 }
 
 /* Returns the number of args used up (0 or 1).  */
-int parse_cmdline_option (struct uae_prefs *p, char c, char *arg)
+int parse_cmdline_option (struct uae_prefs *p, TCHAR c, const TCHAR *arg)
 {
-    struct strlist *u = (struct strlist*)xcalloc (sizeof (struct strlist), 1);
-    const char arg_required[] = "0123rKpImWSAJwNCZUFcblOdHRv";
+    struct strlist *u = xcalloc (sizeof (struct strlist), 1);
+    const TCHAR arg_required[] = L"0123rKpImWSAJwNCZUFcblOdHRv";
 
-    if (strchr (arg_required, c) && ! arg) {
-       write_log ("Missing argument for option `-%c'!\n", c);
+    if (_tcschr (arg_required, c) && ! arg) {
+       write_log (L"Missing argument for option `-%c'!\n", c);
        return 0;
     }
 
-    u->option = (char*)malloc (2);
+    u->option = malloc (2 * sizeof (TCHAR));
     u->option[0] = c;
     u->option[1] = 0;
-    u->value = my_strdup(arg);
+    u->value = my_strdup (arg);
     u->next = p->all_lines;
     p->all_lines = u;
 
     switch (c) {
     case 'h': usage (); exit (0);
 
-    case '0': strncpy (p->df[0], arg, 255); p->df[0][255] = 0; break;
-    case '1': strncpy (p->df[1], arg, 255); p->df[1][255] = 0; break;
-    case '2': strncpy (p->df[2], arg, 255); p->df[2][255] = 0; break;
-    case '3': strncpy (p->df[3], arg, 255); p->df[3][255] = 0; break;
-    case 'r': strncpy (p->romfile, arg, 255); p->romfile[255] = 0; break;
-    case 'K': strncpy (p->romextfile, arg, 255); p->romextfile[255] = 0; break;
-    case 'p': strncpy (p->prtname, arg, 255); p->prtname[255] = 0; break;
-       /*     case 'I': strncpy (p->sername, arg, 255); p->sername[255] = 0; currprefs.use_serial = 1; break; */
+    case '0': _tcsncpy (p->df[0], arg, 255); p->df[0][255] = 0; break;
+    case '1': _tcsncpy (p->df[1], arg, 255); p->df[1][255] = 0; break;
+    case '2': _tcsncpy (p->df[2], arg, 255); p->df[2][255] = 0; break;
+    case '3': _tcsncpy (p->df[3], arg, 255); p->df[3][255] = 0; break;
+    case 'r': _tcsncpy (p->romfile, arg, 255); p->romfile[255] = 0; break;
+    case 'K': _tcsncpy (p->romextfile, arg, 255); p->romextfile[255] = 0; break;
+    case 'p': _tcsncpy (p->prtname, arg, 255); p->prtname[255] = 0; break;
+       /*     case 'I': _tcsncpy (p->sername, arg, 255); p->sername[255] = 0; currprefs.use_serial = 1; break; */
     case 'm': case 'M': parse_filesys_spec (p, c == 'M', arg); break;
     case 'W': parse_hardfile_spec (p, arg); break;
     case 'S': parse_sound_spec (p, arg); break;
-    case 'R': p->gfx_framerate = atoi (arg); break;
+    case 'R': p->gfx_framerate = _tstoi (arg); break;
     case 'x': p->no_xhair = 1; break;
     case 'i': p->illegal_mem = 1; break;
     case 'J': parse_joy_spec (p, arg); break;
@@ -2322,19 +2336,19 @@ int parse_cmdline_option (struct uae_prefs *p, char c, char *arg)
     case 'L': p->x11_use_low_bandwidth = 1; break;
     case 'T': p->x11_use_mitshm = 1; break;
 #endif
-    case 'w': p->m68k_speed = atoi (arg); break;
+    case 'w': p->m68k_speed = _tstoi (arg); break;
 
        /* case 'g': p->use_gfxlib = 1; break; */
     case 'G': p->start_gui = 0; break;
     case 'D': p->start_debugger = 1; break;
 
     case 'n':
-       if (strchr (arg, 'i') != 0)
+       if (_tcschr (arg, 'i') != 0)
            p->immediate_blits = 1;
        break;
 
     case 'v':
-       set_chipset_mask (p, atoi (arg));
+       set_chipset_mask (p, _tstoi (arg));
        break;
 
     case 'C':
@@ -2342,82 +2356,82 @@ int parse_cmdline_option (struct uae_prefs *p, char c, char *arg)
        break;
 
     case 'Z':
-       p->z3fastmem_size = atoi (arg) * 0x100000;
+       p->z3fastmem_size = _tstoi (arg) * 0x100000;
        break;
 
     case 'U':
-       p->gfxmem_size = atoi (arg) * 0x100000;
+       p->gfxmem_size = _tstoi (arg) * 0x100000;
        break;
 
     case 'F':
-       p->fastmem_size = atoi (arg) * 0x100000;
+       p->fastmem_size = _tstoi (arg) * 0x100000;
        break;
 
     case 'b':
-       p->bogomem_size = atoi (arg) * 0x40000;
+       p->bogomem_size = _tstoi (arg) * 0x40000;
        break;
 
     case 'c':
-       p->chipmem_size = atoi (arg) * 0x80000;
+       p->chipmem_size = _tstoi (arg) * 0x80000;
        break;
 
     case 'l':
-       if (0 == strcasecmp(arg, "de"))
+       if (0 == strcasecmp(arg, L"de"))
            p->keyboard_lang = KBD_LANG_DE;
-       else if (0 == strcasecmp(arg, "dk"))
+       else if (0 == strcasecmp(arg, L"dk"))
            p->keyboard_lang = KBD_LANG_DK;
-       else if (0 == strcasecmp(arg, "us"))
+       else if (0 == strcasecmp(arg, L"us"))
            p->keyboard_lang = KBD_LANG_US;
-       else if (0 == strcasecmp(arg, "se"))
+       else if (0 == strcasecmp(arg, L"se"))
            p->keyboard_lang = KBD_LANG_SE;
-       else if (0 == strcasecmp(arg, "fr"))
+       else if (0 == strcasecmp(arg, L"fr"))
            p->keyboard_lang = KBD_LANG_FR;
-       else if (0 == strcasecmp(arg, "it"))
+       else if (0 == strcasecmp(arg, L"it"))
            p->keyboard_lang = KBD_LANG_IT;
-       else if (0 == strcasecmp(arg, "es"))
+       else if (0 == strcasecmp(arg, L"es"))
            p->keyboard_lang = KBD_LANG_ES;
        break;
 
     case 'O': parse_gfx_specs (p, arg); break;
     case 'd':
-       if (strchr (arg, 'S') != NULL || strchr (arg, 's')) {
-           write_log ("  Serial on demand.\n");
+       if (_tcschr (arg, 'S') != NULL || _tcschr (arg, 's')) {
+           write_log (L"  Serial on demand.\n");
            p->serial_demand = 1;
        }
-       if (strchr (arg, 'P') != NULL || strchr (arg, 'p')) {
-           write_log ("  Parallel on demand.\n");
+       if (_tcschr (arg, 'P') != NULL || _tcschr (arg, 'p')) {
+           write_log (L"  Parallel on demand.\n");
            p->parallel_demand = 1;
        }
 
        break;
 
     case 'H':
-       p->color_mode = atoi (arg);
+       p->color_mode = _tstoi (arg);
        if (p->color_mode < 0) {
-           write_log ("Bad color mode selected. Using default.\n");
+           write_log (L"Bad color mode selected. Using default.\n");
            p->color_mode = 0;
        }
        break;
     default:
-       write_log ("Unknown option `-%c'!\n", c);
+       write_log (L"Unknown option `-%c'!\n", c);
        break;
     }
-    return !! strchr (arg_required, c);
+    return !! _tcschr (arg_required, c);
 }
 
-void cfgfile_addcfgparam (char *line)
+void cfgfile_addcfgparam (TCHAR *line)
 {
     struct strlist *u;
-    char line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
+    TCHAR line1b[CONFIG_BLEN], line2b[CONFIG_BLEN];
 
     if (!line) {
        struct strlist **ps = &temp_lines;
        while (*ps) {
            struct strlist *s = *ps;
            *ps = s->next;
-           free (s->value);
-           free (s->option);
-           free (s);
+           xfree (s->value);
+           xfree (s->option);
+           xfree (s);
        }
        temp_lines = 0;
        return;
@@ -2425,20 +2439,20 @@ void cfgfile_addcfgparam (char *line)
     if (!cfgfile_separate_line (line, line1b, line2b))
        return;
     u = xcalloc (sizeof (struct strlist), 1);
-    u->option = my_strdup(line1b);
-    u->value = my_strdup(line2b);
+    u->option = my_strdup (line1b);
+    u->value = my_strdup (line2b);
     u->next = temp_lines;
     temp_lines = u;
 }
 
-static int getconfigstoreline (struct zfile *z, char *option, char *value)
+static int getconfigstoreline (struct zfile *z, TCHAR *option, TCHAR *value)
 {
-    char tmp[CONFIG_BLEN * 2];
+    TCHAR tmp[CONFIG_BLEN * 2];
     int idx = 0;
 
     for (;;) {
-       uae_u8 b = 0;
-       if (zfile_fread (&b, 1, 1, z) != 1)
+       TCHAR b = 0;
+       if (zfile_fread (&b, 1, sizeof (TCHAR), z) != 1)
            return 0;
        tmp[idx++] = b;
        tmp[idx] = 0;
@@ -2449,11 +2463,11 @@ static int getconfigstoreline (struct zfile *z, char *option, char *value)
 }
 
 #if 0
-static int cfgfile_handle_custom_event (char *custom, int mode)
+static int cfgfile_handle_custom_event (TCHAR *custom, int mode)
 {
-    char option[CONFIG_BLEN], value[CONFIG_BLEN];
-    char option2[CONFIG_BLEN], value2[CONFIG_BLEN];
-    char *tmp, *p, *nextp;
+    TCHAR option[CONFIG_BLEN], value[CONFIG_BLEN];
+    TCHAR option2[CONFIG_BLEN], value2[CONFIG_BLEN];
+    TCHAR *tmp, *p, *nextp;
     struct zfile *configstore = NULL;
     int cnt = 0, cnt_ok = 0;
 
@@ -2461,15 +2475,15 @@ static int cfgfile_handle_custom_event (char *custom, int mode)
        uae_u8 zero = 0;
        configstore = zfile_fopen_empty ("configstore", 50000);
        cfgfile_save_options (configstore, &currprefs, 0);
-       zfile_fwrite (&zero, 1, 1, configstore);
+       cfg_write (&zero, configstore);
     }
 
     nextp = NULL;
-    tmp = p = xcalloc (strlen (custom) + 2, 1);
-    strcpy (tmp, custom);
+    tmp = p = xcalloc (_tcslen (custom) + 2, 1);
+    _tcscpy (tmp, custom);
     while (p && *p) {
        if (*p == '\"') {
-           char *p2;
+           TCHAR *p2;
            p++;
            p2 = p;
            while (*p2 != '\"' && *p2 != 0)
@@ -2490,7 +2504,7 @@ static int cfgfile_handle_custom_event (char *custom, int mode)
                for (;;) {
                    if (!getconfigstoreline (configstore, option2, value2))
                        break;
-                   if (!strcmpi (option, option2) && !strcmpi (value, value2)) {
+                   if (!_tcscmpi (option, option2) && !_tcscmpi (value, value2)) {
                        cnt_ok++;
                        break;
                    }
@@ -2507,20 +2521,20 @@ static int cfgfile_handle_custom_event (char *custom, int mode)
 }
 #endif
 
-int cmdlineparser (char *s, char *outp[], int max)
+int cmdlineparser (TCHAR *s, TCHAR *outp[], int max)
 {
     int j, cnt = 0;
     int slash = 0;
     int quote = 0;
-    char tmp1[MAX_DPATH];
-    char *prev;
+    TCHAR tmp1[MAX_DPATH];
+    TCHAR *prev;
     int doout;
 
     doout = 0;
     prev = s;
     j = 0;
     while (cnt < max) {
-       char c = *s++;
+       TCHAR c = *s++;
        if (!c)
            break;
        if (c < 32)
@@ -2560,15 +2574,15 @@ int cmdlineparser (char *s, char *outp[], int max)
 
 #define UAELIB_MAX_PARSE 100
 
-uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae_u32 outsize)
+uae_u32 cfgfile_modify (uae_u32 index, TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize)
 {
-    char *p;
-    char *argc[UAELIB_MAX_PARSE];
+    TCHAR *p;
+    TCHAR *argc[UAELIB_MAX_PARSE];
     int argv, i;
     uae_u32 err;
-    uae_u8 zero = 0;
+    TCHAR zero = 0;
     static struct zfile *configstore;
-    static char *configsearch;
+    static TCHAR *configsearch;
     static int configsearchfound;
 
     err = 0;
@@ -2580,10 +2594,10 @@ uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae
            goto end;
        }
        if (configsearch) {
-           char tmp[CONFIG_BLEN];
+           TCHAR tmp[CONFIG_BLEN];
            int j = 0;
-           char *in = configsearch;
-           int inlen = strlen (configsearch);
+           TCHAR *in = configsearch;
+           int inlen = _tcslen (configsearch);
            int joker = 0;
 
            if (in[inlen - 1] == '*') {
@@ -2602,8 +2616,8 @@ uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae
                        err = 0;
                    goto end;
                }
-               if (j >= sizeof (tmp) - 1)
-                   j = sizeof (tmp) - 1;
+               if (j >= sizeof (tmp) / sizeof (TCHAR) - 1)
+                   j = sizeof (tmp) / sizeof (TCHAR) - 1;
                if (b == 0) {
                    err = 10;
                    if (configsearch)
@@ -2613,16 +2627,16 @@ uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae
                    goto end;
                }
                if (b == '\n') {
-                   if (configsearch && !strncmp (tmp, in, inlen) &&
-                       ((inlen > 0 && strlen (tmp) > inlen && tmp[inlen] == '=') || (joker))) {
-                       char *p;
+                   if (configsearch && !_tcsncmp (tmp, in, inlen) &&
+                       ((inlen > 0 && _tcslen (tmp) > inlen && tmp[inlen] == '=') || (joker))) {
+                       TCHAR *p;
                        if (joker)
                            p = tmp - 1;
                        else
-                           p = strchr (tmp, '=');
+                           p = _tcschr (tmp, '=');
                        if (p) {
                            for (i = 0; i < outsize - 1; i++) {
-                               uae_u8 b = *++p;
+                               TCHAR b = *++p;
                                out[i] = b;
                                out[i + 1] = 0;
                                if (!b)
@@ -2665,9 +2679,9 @@ uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae
     if (argv <= 1 && index == 0xffffffff) {
        zfile_fclose (configstore);
        xfree (configsearch);
-       configstore = zfile_fopen_empty ("configstore", 50000);
+       configstore = zfile_fopen_empty (L"configstore", 50000);
        configsearch = NULL;
-       if (argv > 0 && strlen (argc[0]) > 0)
+       if (argv > 0 && _tcslen (argc[0]) > 0)
            configsearch = my_strdup (argc[0]);
        if (!configstore) {
            err = 20;
@@ -2677,7 +2691,7 @@ uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae
        uaeconfig++;
        cfgfile_save_options (configstore, &currprefs, 0);
        uaeconfig--;
-       zfile_fwrite (&zero, 1, 1, configstore);
+       cfg_write (&zero, configstore);
        zfile_fseek (configstore, 0, SEEK_SET);
        err = 0xffffffff;
        configsearchfound = 0;
@@ -2705,8 +2719,9 @@ end:
 
 uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize)
 {
-    char *p, *parms_p = NULL, *out_p = NULL;
+    uae_char *p, *parms_p = NULL, *parms_out = NULL;
     int i, ret;
+    TCHAR *out_p = NULL, *parms_in = NULL;
 
     put_byte (out, 0);
     parms_p = xmalloc (size + 1);
@@ -2714,7 +2729,7 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u
        ret = 10;
        goto end;
     }
-    out_p = xmalloc (outsize + 1);
+    out_p = xmalloc ((outsize + 1) * sizeof (TCHAR));
     if (!out_p) {
        ret = 10;
        goto end;
@@ -2727,8 +2742,11 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u
     }
     p[i] = 0;
     out_p[0] = 0;
-    ret = cfgfile_modify (index, parms_p, size, out_p, outsize);
-    p = out_p;
+    parms_in = au (parms_p);
+    ret = cfgfile_modify (index, parms_in, size, out_p, outsize);
+    xfree (parms_in);
+    parms_out = ua (out_p);
+    p = parms_out;
     for (i = 0; i < outsize - 1; i++) {
        uae_u8 b = *p++;
        put_byte (out + i, b);
@@ -2736,6 +2754,7 @@ uae_u32 cfgfile_uaelib_modify (uae_u32 index, uae_u32 parms, uae_u32 size, uae_u
        if (!b)
            break;
     }
+    xfree (parms_out);
 end:
     xfree (out_p);
     xfree (parms_p);
@@ -2744,19 +2763,19 @@ end:
 
 uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen)
 {
-    char tmp[CONFIG_BLEN];
+    TCHAR tmp[CONFIG_BLEN];
     int i;
     struct strlist *sl;
 
     if (mode)
        return 0;
 
-    for (i = 0; i < sizeof(tmp); i++) {
+    for (i = 0; i < sizeof (tmp) / sizeof (TCHAR); i++) {
        tmp[i] = get_byte (name + i);
        if (tmp[i] == 0)
            break;
     }
-    tmp[sizeof(tmp) - 1] = 0;
+    tmp[sizeof(tmp) / sizeof (TCHAR) - 1] = 0;
     if (tmp[0] == 0)
        return 0;
     for (sl = currprefs.all_lines; sl; sl = sl->next) {
@@ -2765,11 +2784,13 @@ uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen)
     }
 
     if (sl) {
+       char *s = ua (sl->value);
        for (i = 0; i < maxlen; i++) {
-           put_byte (dst + i, sl->value[i]);
-           if (sl->value[i] == 0)
+           put_byte (dst + i, s[i]);
+           if (s[i] == 0)
                break;
        }
+       xfree (s);
        return dst;
     }
     return 0;
@@ -2777,30 +2798,34 @@ uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen)
 
 uae_u8 *restore_configuration (uae_u8 *src)
 {
-    write_log (src);
-    src += strlen(src) + 1;
+    TCHAR *s = au (src);
+    write_log (s);
+    xfree (s);
+    src += strlen (src) + 1;
     return src;
 }
 
 uae_u8 *save_configuration (int *len)
 {
     int tmpsize = 30000;
-    uae_u8 *dstbak, *dst;
-    char *p;
+    uae_u8 *dstbak, *dst, *p;
     int index = -1;
 
-    dstbak = dst = (uae_u8*)malloc (tmpsize);
+    dstbak = dst = malloc (tmpsize * sizeof (TCHAR));
     p = dst;
     for (;;) {
-       char tmpout[256];
+       TCHAR tmpout[256];
        int ret;
        tmpout[0] = 0;
-       ret = cfgfile_modify (index, "*", 1, tmpout, sizeof (tmpout));
+       ret = cfgfile_modify (index, L"*", 1, tmpout, sizeof (tmpout) / sizeof (TCHAR));
        index++;
-       if (strlen(tmpout) > 0) {
-           if (!memcmp (tmpout, "input.", 6))
+       if (_tcslen (tmpout) > 0) {
+           char *out;
+           if (!_tcsncmp (tmpout, L"input.", 6))
                continue;
-           strcpy (p, tmpout);
+           out = ua (tmpout);
+           strcpy (p, out);
+           xfree (out);
            strcat (p, "\n");
            p += strlen (p);
            if (p - dstbak >= tmpsize - sizeof (tmpout))
@@ -2817,7 +2842,7 @@ uae_u8 *save_configuration (int *len)
 static int configure_rom (struct uae_prefs *p, int *rom, int msg)
 {
     struct romdata *rd;
-    char *path = 0;
+    TCHAR *path = 0;
     int i;
 
     i = 0;
@@ -2838,17 +2863,17 @@ static int configure_rom (struct uae_prefs *p, int *rom, int msg)
        return 0;
     }
     if (rd->type & (ROMTYPE_KICK | ROMTYPE_KICKCD32))
-       strcpy (p->romfile, path);
+       _tcscpy (p->romfile, path);
     if (rd->type & (ROMTYPE_EXTCD32 | ROMTYPE_EXTCDTV | ROMTYPE_ARCADIABIOS))
-       strcpy (p->romextfile, path);
+       _tcscpy (p->romextfile, path);
     if (rd->type & (ROMTYPE_CD32CART | ROMTYPE_ARCADIAGAME | ROMTYPE_HRTMON | ROMTYPE_XPOWER | ROMTYPE_NORDIC | ROMTYPE_AR | ROMTYPE_SUPERIV))
-       strcpy (p->cartfile, path);
+       _tcscpy (p->cartfile, path);
     return 1;
 }
 
 static void default_prefs_mini (struct uae_prefs *p, int type)
 {
-    strcpy (p->description, "UAE default A500 configuration");
+    _tcscpy (p->description, L"UAE default A500 configuration");
 
     p->nr_floppies = 1;
     p->dfxtype[0] = DRV_35_DD;
@@ -2869,7 +2894,7 @@ void default_prefs (struct uae_prefs *p, int type)
     struct zfile *f;
 
     memset (p, 0, sizeof (*p));
-    strcpy (p->description, "UAE default configuration");
+    _tcscpy (p->description, L"UAE default configuration");
     p->config_hardware_path[0] = 0;
     p->config_host_path[0] = 0;
 
@@ -3020,19 +3045,19 @@ void default_prefs (struct uae_prefs *p, int type)
     p->gfx_filter_keep_aspect = 0;
     p->gfx_filter_autoscale = 0;
 
-    strcpy (p->df[0], "df0.adf");
-    strcpy (p->df[1], "df1.adf");
-    strcpy (p->df[2], "df2.adf");
-    strcpy (p->df[3], "df3.adf");
+    _tcscpy (p->df[0], L"df0.adf");
+    _tcscpy (p->df[1], L"df1.adf");
+    _tcscpy (p->df[2], L"df2.adf");
+    _tcscpy (p->df[3], L"df3.adf");
 
     configure_rom (p, roms, 0);
-    strcpy (p->romextfile, "");
-    strcpy (p->flashfile, "");
-    strcpy (p->cartfile, "");
+    _tcscpy (p->romextfile, L"");
+    _tcscpy (p->flashfile, L"");
+    _tcscpy (p->cartfile, L"");
 
-    strcpy (p->path_rom, "./");
-    strcpy (p->path_floppy, "./");
-    strcpy (p->path_hardfile, "./");
+    _tcscpy (p->path_rom, L"./");
+    _tcscpy (p->path_floppy, L"./");
+    _tcscpy (p->path_hardfile, L"./");
 
     p->prtname[0] = 0;
     p->sername[0] = 0;
@@ -3090,12 +3115,12 @@ void default_prefs (struct uae_prefs *p, int type)
 
     zfile_fclose (default_file);
     default_file = NULL;
-    f = zfile_fopen_empty ("configstore", 100000);
+    f = zfile_fopen_empty (L"configstore", 100000);
     if (f) {
        uaeconfig++;
        cfgfile_save_options (f, p, 0);
        uaeconfig--;
-       zfile_fwrite (&zero, 1, 1, f);
+       cfg_write (&zero, f);
        default_file = f;
     }
 }
@@ -3184,11 +3209,11 @@ static void buildin_default_prefs (struct uae_prefs *p)
     p->cs_df0idhw = 1;
     p->cs_resetwarning = 0;
 
-    strcpy (p->romfile, "");
-    strcpy (p->romextfile, "");
-    strcpy (p->flashfile, "");
-    strcpy (p->cartfile, "");
-    strcpy (p->amaxromfile, "");
+    _tcscpy (p->romfile, L"");
+    _tcscpy (p->romextfile, L"");
+    _tcscpy (p->flashfile, L"");
+    _tcscpy (p->cartfile, L"");
+    _tcscpy (p->amaxromfile, L"");
     p->prtname[0] = 0;
     p->sername[0] = 0;
 
@@ -3386,8 +3411,8 @@ static int bip_cdtv (struct uae_prefs *p, int config, int compa, int romcheck)
     set_68000_compa (p, compa);
     p->cs_compatible = CP_CDTV;
     built_in_chipset_prefs (p);
-    fetch_datapath (p->flashfile, sizeof (p->flashfile));
-    strcat(p->flashfile, "cdtv.nvr");
+    fetch_datapath (p->flashfile, sizeof (p->flashfile) / sizeof (TCHAR));
+    _tcscat (p->flashfile, L"cdtv.nvr");
     return 1;
 }
 
@@ -3419,8 +3444,8 @@ static int bip_cd32 (struct uae_prefs *p, int config, int compa, int romcheck)
     set_68020_compa (p, compa);
     p->cs_compatible = CP_CD32;
     built_in_chipset_prefs (p);
-    fetch_datapath (p->flashfile, sizeof (p->flashfile));
-    strcat(p->flashfile, "cd32.nvr");
+    fetch_datapath (p->flashfile, sizeof (p->flashfile) / sizeof (TCHAR));
+    _tcscat (p->flashfile, L"cd32.nvr");
     return 1;
 }
 
@@ -3576,7 +3601,7 @@ static int bip_super (struct uae_prefs *p, int config, int compa, int romcheck)
     built_in_chipset_prefs (p);
     p->cs_ide = -1;
     p->cs_ciaatod = p->ntscmode ? 2 : 1;
-    //strcat(p->flashfile, "battclock.nvr");
+    //_tcscat(p->flashfile, L"battclock.nvr");
     return configure_rom (p, roms, romcheck);
 }
 
@@ -3593,8 +3618,8 @@ static int bip_super (struct uae_prefs *p, int config, int compa, int romcheck)
     set_68000_compa (p, compa);
     p->cs_compatible = CP_A500;
     built_in_chipset_prefs (p);
-    fetch_datapath (p->flashfile, sizeof (p->flashfile));
-    strcat(p->flashfile, "arcadia.nvr");
+    fetch_datapath (p->flashfile, sizeof (p->flashfile) / sizeof (TCHAR));
+    _tcscat (p->flashfile, L"arcadia.nvr");
     roms[0] = 5;
     roms[1] = 4;
     roms[2] = -1;
@@ -3774,4 +3799,3 @@ int built_in_chipset_prefs (struct uae_prefs *p)
     }
     return 1;
 }
-
diff --git a/cia.c b/cia.c
index 1704a68b2b847bb04e58b7c1b7b707b169354256..1e529556c5adefede96a1541a0805209a0885d37 100644 (file)
--- a/cia.c
+++ b/cia.c
@@ -359,7 +359,7 @@ static void do_tod_hack (int dotod)
     if (tod_hack_enabled > 1) {
        tod_hack_enabled--;
        if (tod_hack_enabled == 1) {
-           write_log ("TOD HACK enabled\n");
+           write_log (L"TOD HACK enabled\n");
            tod_hack_reset ();
        }
        return;
@@ -375,7 +375,7 @@ static void do_tod_hack (int dotod)
        return;
     if (rate != oldrate || ciaatod != tod_hack_tod_last) {
        if (ciaatod != 0)
-           write_log ("TOD HACK reset %d,%d %d,%d\n",
+           write_log (L"TOD HACK reset %d,%d %d,%d\n",
                rate, oldrate, ciaatod, tod_hack_tod_last);
         tod_hack_reset ();
         oldrate = rate;
@@ -410,7 +410,7 @@ static void sendrw (void)
     ciaasdr_unread = 1;
     ciaaicr |= 8;
     RethinkICRA ();
-    write_log ("KB: sent reset warning code (phase=%d)\n", resetwarning_phase);
+    write_log (L"KB: sent reset warning code (phase=%d)\n", resetwarning_phase);
 }
 
 int resetwarning_do (int canreset)
@@ -425,7 +425,7 @@ int resetwarning_do (int canreset)
     }
     resetwarning_phase = 1;
     resetwarning_timer = maxvpos * 5;
-    write_log ("KB: reset warning triggered\n");
+    write_log (L"KB: reset warning triggered\n");
     sendrw ();
     return 1;
 }
@@ -435,14 +435,14 @@ static void resetwarning_check (void)
     if (resetwarning_timer > 0) {
        resetwarning_timer--;
        if (resetwarning_timer <= 0) {
-           write_log ("KB: reset warning forced reset. Phase=%d\n", resetwarning_phase);
+           write_log (L"KB: reset warning forced reset. Phase=%d\n", resetwarning_phase);
            resetwarning_phase = -1;
            uae_reset (0);
        }
     }
     if (resetwarning_phase == 1) {
        if (kback && !(ciaacra & 0x40) && ciaasdr_unread == 2) {
-           write_log ("KB: reset warning second phase..\n");
+           write_log (L"KB: reset warning second phase..\n");
            resetwarning_phase = 2;
            resetwarning_timer = maxvpos * 5;
            sendrw ();
@@ -450,12 +450,12 @@ static void resetwarning_check (void)
     } else if (resetwarning_phase == 2) {
        if (ciaacra & 0x40) {
            resetwarning_phase = 3;
-           write_log ("KB: reset warning SP = output\n");
+           write_log (L"KB: reset warning SP = output\n");
            resetwarning_timer = 10 * maxvpos * vblank_hz; /* wait max 10s */
        }
     } else if (resetwarning_phase == 3) {
        if (!(ciaacra & 0x40)) {
-           write_log ("KB: reset warning end by software. reset.\n");
+           write_log (L"KB: reset warning end by software. reset.\n");
            resetwarning_phase = -1;
            uae_reset (0);
        }
@@ -604,7 +604,7 @@ static uae_u8 ReadCIAA (unsigned int addr)
     compute_passed_time ();
 
 #ifdef CIAA_DEBUG_R
-    write_log ("R_CIAA: bfe%x01 %08X\n", addr, M68K_GETPC);
+    write_log (L"R_CIAA: bfe%x01 %08X\n", addr, M68K_GETPC);
 #endif
 
     switch (addr & 0xf) {
@@ -621,7 +621,7 @@ static uae_u8 ReadCIAA (unsigned int addr)
            tmp = (tmp & ~0x80) | (ciaapra & 0x80);
 #ifdef DONGLE_DEBUG
        if (notinrom())
-           write_log ("BFE001 R %02X %s\n", tmp, debuginfo(0));
+           write_log (L"BFE001 R %02X %s\n", tmp, debuginfo(0));
 #endif
        return tmp;
     case 1:
@@ -642,7 +642,7 @@ static uae_u8 ReadCIAA (unsigned int addr)
            tmp = handle_parport_joystick (0, ciaaprb, ciaadrb);
 #ifdef DONGLE_DEBUG
            if (notinrom())
-               write_log ("BFE101 R %02X %s\n", tmp, debuginfo(0));
+               write_log (L"BFE101 R %02X %s\n", tmp, debuginfo(0));
 #endif
        }
        if (ciaacrb & 2) {
@@ -663,13 +663,13 @@ static uae_u8 ReadCIAA (unsigned int addr)
     case 2:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFE201 R %02X %s\n", ciaadra, debuginfo(0));
+           write_log (L"BFE201 R %02X %s\n", ciaadra, debuginfo(0));
 #endif
        return ciaadra;
     case 3:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFE301 R %02X %s\n", ciaadrb, debuginfo(0));
+           write_log (L"BFE301 R %02X %s\n", ciaadrb, debuginfo(0));
 #endif
        return ciaadrb;
     case 4:
@@ -720,7 +720,7 @@ static uae_u8 ReadCIAB (unsigned int addr)
 
 #ifdef CIAB_DEBUG_R
     if (addr >= 8 && addr <= 10)
-       write_log ("R_CIAB: bfd%x00 %08X\n", addr, M68K_GETPC);
+       write_log (L"R_CIAB: bfd%x00 %08X\n", addr, M68K_GETPC);
 #endif
 
     compute_passed_time ();
@@ -745,13 +745,13 @@ static uae_u8 ReadCIAB (unsigned int addr)
 #endif
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFD000 R %02X %s\n", tmp, debuginfo(0));
+           write_log (L"BFD000 R %02X %s\n", tmp, debuginfo(0));
 #endif
        return tmp;
     case 1:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFD100 R %02X %s\n", ciabprb, debuginfo(0));
+           write_log (L"BFD100 R %02X %s\n", ciabprb, debuginfo(0));
 #endif
        tmp = ciabprb;
        if (ciabcrb & 2) {
@@ -816,7 +816,7 @@ static uae_u8 ReadCIAB (unsigned int addr)
 static void WriteCIAA (uae_u16 addr,uae_u8 val)
 {
 #ifdef CIAA_DEBUG_W
-    write_log ("W_CIAA: bfe%x01 %02X %08X\n", addr, val, M68K_GETPC);
+    write_log (L"W_CIAA: bfe%x01 %02X %08X\n", addr, val, M68K_GETPC);
 #endif
 #ifdef ACTION_REPLAY
     ar_ciaa[addr & 0xf] = val;
@@ -829,7 +829,7 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val)
     case 0:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFE001 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFE001 W %02X %s\n", val, debuginfo(0));
 #endif
        ciaapra = (ciaapra & ~0xc3) | (val & 0xc3);
        bfe001_change ();
@@ -842,7 +842,7 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val)
     case 1:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFE101 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFE101 W %02X %s\n", val, debuginfo(0));
 #endif
        ciaaprb = val;
 #ifdef PARALLEL_PORT
@@ -862,14 +862,14 @@ static void WriteCIAA (uae_u16 addr,uae_u8 val)
     case 2:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFE201 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFE201 W %02X %s\n", val, debuginfo(0));
 #endif
        ciaadra = val; bfe001_change (); break;
     case 3:
        ciaadrb = val;
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFE301 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFE301 W %02X %s\n", val, debuginfo(0));
 #endif
 #ifdef ARCADIA
        if (arcadia_bios)
@@ -975,7 +975,7 @@ static void WriteCIAB (uae_u16 addr,uae_u8 val)
 {
 #ifdef CIAB_DEBUG_W
     if (addr >= 8 && addr <= 10)
-       write_log ("W_CIAB: bfd%x00 %02X %08X\n", addr, val, M68K_GETPC);
+       write_log (L"W_CIAB: bfd%x00 %02X %08X\n", addr, val, M68K_GETPC);
 #endif
 #ifdef ACTION_REPLAY
     ar_ciab[addr & 0xf] = val;
@@ -984,7 +984,7 @@ static void WriteCIAB (uae_u16 addr,uae_u8 val)
     case 0:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFD000 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFD000 W %02X %s\n", val, debuginfo(0));
 #endif
        ciabpra = val;
 #ifdef SERIAL_PORT
@@ -999,13 +999,13 @@ static void WriteCIAB (uae_u16 addr,uae_u8 val)
     case 1:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFD100 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFD100 W %02X %s\n", val, debuginfo(0));
 #endif
        ciabprb = val; DISK_select(val); break;
     case 2:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFD200 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFD200 W %02X %s\n", val, debuginfo(0));
 #endif
        ciabdra = val;
 #ifdef SERIAL_PORT
@@ -1016,7 +1016,7 @@ static void WriteCIAB (uae_u16 addr,uae_u8 val)
     case 3:
 #ifdef DONGLE_DEBUG
        if (notinrom ())
-           write_log ("BFD300 W %02X %s\n", val, debuginfo(0));
+           write_log (L"BFD300 W %02X %s\n", val, debuginfo(0));
 #endif
        ciabdrb = val; break;
     case 4:
@@ -1172,13 +1172,13 @@ void CIA_reset (void)
 
 void dumpcia (void)
 {
-    console_out_f ("A: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n",
+    console_out_f (L"A: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n",
                 ciaacra, ciaacrb, ciaaicr, ciaaimask, ciaata, ciaala, ciaatb, ciaalb);
-    console_out_f ("TOD %06x (%06x) ALARM %06x %c%c\n",
+    console_out_f (L"TOD %06x (%06x) ALARM %06x %c%c\n",
                 ciaatod, ciaatol, ciaaalarm, ciaatlatch ? 'L' : ' ', ciaatodon ? ' ' : 'S');
-    console_out_f ("B: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n",
+    console_out_f (L"B: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)\n",
                 ciabcra, ciabcrb, ciaaicr, ciabimask, ciabta, ciabla, ciabtb, ciablb);
-    console_out_f ("TOD %06x (%06x) ALARM %06x %c%c\n",
+    console_out_f (L"TOD %06x (%06x) ALARM %06x %c%c\n",
                 ciabtod, ciabtol, ciabalarm, ciabtlatch ? 'L' : ' ', ciabtodon ? ' ' : 'S');
 }
 
@@ -1196,7 +1196,7 @@ static void REGPARAM3 cia_bput (uaecptr, uae_u32) REGPARAM;
 addrbank cia_bank = {
     cia_lget, cia_wget, cia_bget,
     cia_lput, cia_wput, cia_bput,
-    default_xlate, default_check, NULL, "CIA",
+    default_xlate, default_check, NULL, L"CIA",
     cia_lgeti, cia_wgeti, ABFLAG_IO
 };
 
@@ -1258,7 +1258,7 @@ static uae_u32 REGPARAM2 cia_bget (uaecptr addr)
            if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible)
                v = (addr & 1) ? regs.irc : regs.irc >> 8;
            if (warned > 0) {
-               write_log ("cia_bget: unknown CIA address %x PC=%x\n", addr, M68K_GETPC);
+               write_log (L"cia_bget: unknown CIA address %x PC=%x\n", addr, M68K_GETPC);
                warned--;
            }
        break;
@@ -1293,7 +1293,7 @@ static uae_u32 REGPARAM2 cia_wget (uaecptr addr)
            if (currprefs.cpu_model == 68000 && currprefs.cpu_compatible)
                v = regs.irc;
            if (warned > 0) {
-               write_log ("cia_wget: unknown CIA address %x PC=%x\n", addr, M68K_GETPC);
+               write_log (L"cia_wget: unknown CIA address %x PC=%x\n", addr, M68K_GETPC);
                warned--;
            }
        break;
@@ -1340,7 +1340,7 @@ static void REGPARAM2 cia_bput (uaecptr addr, uae_u32 value)
        if ((addr & 0x1000) == 0)
            WriteCIAA (r, value);
        if (((addr & 0x3000) == 0x3000) && warned > 0) {
-           write_log ("cia_bput: unknown CIA address %x %x\n", addr, value);
+           write_log (L"cia_bput: unknown CIA address %x %x\n", addr, value);
            warned--;
        }
     }
@@ -1361,7 +1361,7 @@ static void REGPARAM2 cia_wput (uaecptr addr, uae_u32 value)
        if ((addr & 0x1000) == 0)
            WriteCIAA (r, value & 0xff);
        if (((addr & 0x3000) == 0x3000) && warned > 0) {
-           write_log ("cia_wput: unknown CIA address %x %x\n", addr, value);
+           write_log (L"cia_wput: unknown CIA address %x %x\n", addr, value);
            warned--;
        }
     }
@@ -1389,7 +1389,7 @@ static void REGPARAM3 clock_bput (uaecptr, uae_u32) REGPARAM;
 addrbank clock_bank = {
     clock_lget, clock_wget, clock_bget,
     clock_lput, clock_wput, clock_bput,
-    default_xlate, default_check, NULL, "Battery backed up clock (none)",
+    default_xlate, default_check, NULL, L"Battery backed up clock (none)",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -1402,9 +1402,9 @@ static uae_u8 rtc_memory[RF5C01A_RAM_SIZE], rtc_alarm[RF5C01A_RAM_SIZE];
 
 static void write_battclock (void)
 {
-    struct zfile *f = zfile_fopen (currprefs.flashfile, "rb+");
+    struct zfile *f = zfile_fopen (currprefs.flashfile, L"rb+");
     if (!f) {
-        f = zfile_fopen (currprefs.flashfile, "wb");
+        f = zfile_fopen (currprefs.flashfile, L"wb");
         if (f) {
            zfile_fwrite (rtc_memory, RF5C01A_RAM_SIZE, 1, f);
            zfile_fwrite (rtc_alarm, RF5C01A_RAM_SIZE, 1, f);
@@ -1424,12 +1424,12 @@ static void write_battclock (void)
 void rtc_hardreset (void)
 {
     if (currprefs.cs_rtc == 1) { /* MSM6242B */
-       clock_bank.name = "Battery backed up clock (MSM6242B)";
+       clock_bank.name = L"Battery backed up clock (MSM6242B)";
        clock_control_d = 0x1;
        clock_control_e = 0;
        clock_control_f = 0x4; /* 24/12 */
     } else if (currprefs.cs_rtc == 2) { /* RF5C01A */
-       clock_bank.name = "Battery backed up clock (RF5C01A)";
+       clock_bank.name = L"Battery backed up clock (RF5C01A)";
        clock_control_d = 0x4; /* Timer EN */
        clock_control_e = 0;
        clock_control_f = 0;
index fae0dc21ac018c0df577127a1db7e2e29a36f39c..10b71d973ca311de2e7f54a00b47a1a1d16e74a8 100644 (file)
--- a/cpummu.c
+++ b/cpummu.c
@@ -48,14 +48,14 @@ static unsigned int mmu_atc_hits[ATC_L2_SIZE];
 #endif
 
 
-static void mmu_dump_ttr(const char * label, uae_u32 ttr)
+static void mmu_dump_ttr(const TCHAR * label, uae_u32 ttr)
 {
        uae_u32 from_addr, to_addr;
 
        from_addr = ttr & MMU_TTR_LOGICAL_BASE;
        to_addr = (ttr & MMU_TTR_LOGICAL_MASK) << 8;
 
-       D(bug("%s: [%08lx] %08lx - %08lx enabled=%d supervisor=%d wp=%d cm=%02d\n",
+       D(bug(L"%s: [%08lx] %08lx - %08lx enabled=%d supervisor=%d wp=%d cm=%02d\n",
                        label, ttr,
                        from_addr, to_addr,
                        ttr & MMU_TTR_BIT_ENABLED ? 1 : 0,
@@ -82,7 +82,7 @@ void mmu_make_transparent_region(uaecptr baseaddr, uae_u32 size, int datamode)
        *ttr |= ((baseaddr + size - 1) & MMU_TTR_LOGICAL_BASE) >> 8;
        *ttr |= MMU_TTR_BIT_ENABLED;
 
-       D(bug("MMU: map transparent mapping of %08x\n", *ttr));
+       D(bug(L"MMU: map transparent mapping of %08x\n", *ttr));
 }
 
 /* check if an address matches a ttr */
@@ -131,7 +131,7 @@ STATIC_INLINE int mmu_match_ttr(uaecptr addr, int super, int data)
 #define        ROOT_INDEX_SHIFT 25
 #define        PTR_INDEX_SHIFT 18
 /* {{{ mmu_dump_table */
-static void mmu_dump_table(const char * label, uaecptr root_ptr)
+static void mmu_dump_table(const TCHAR * label, uaecptr root_ptr)
 {
 //     DUNUSED(label);
        // const int PAGE_INDEX_SHIFT = 12;
@@ -140,7 +140,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr)
        uaecptr ptr_des_addr, page_addr,
                root_log, ptr_log, page_log;
 
-       D(bug("%s: root=%lx", label, root_ptr));
+       D(bug(L"%s: root=%lx", label, root_ptr));
 
        for (root_idx = 0; root_idx < ROOT_TABLE_SIZE; root_idx++) {
                root_des = phys_get_long(root_ptr + root_idx);
@@ -148,7 +148,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr)
                if ((root_des & 2) == 0)
                        continue;       /* invalid */
 
-               D(bug("ROOT: %03d U=%d W=%d UDT=%02d", root_idx,
+               D(bug(L"ROOT: %03d U=%d W=%d UDT=%02d", root_idx,
                                root_des & 8 ? 1 : 0,
                                root_des & 4 ? 1 : 0,
                                root_des & 3
@@ -203,7 +203,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr)
                        if (n_pages_used == -1)
                                continue;
 
-                       D(bug(" PTR: %03d U=%d W=%d UDT=%02d", ptr_idx,
+                       D(bug(L" PTR: %03d U=%d W=%d UDT=%02d", ptr_idx,
                                ptr_des & 8 ? 1 : 0,
                                ptr_des & 4 ? 1 : 0,
                                ptr_des & 3
@@ -214,7 +214,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr)
                                page_des = page_info[page_idx].match;
 
                                if ((page_des & MMU_PDT_MASK) == 2) {
-                                       D(bug("  PAGE: %03d-%03d log=%08lx INDIRECT --> addr=%08lx",
+                                       D(bug(L"  PAGE: %03d-%03d log=%08lx INDIRECT --> addr=%08lx",
                                                        page_info[page_idx].start_idx,
                                                        page_info[page_idx].start_idx + page_info[page_idx].n_pages - 1,
                                                        page_info[page_idx].log,
@@ -222,7 +222,7 @@ static void mmu_dump_table(const char * label, uaecptr root_ptr)
                                                  ));
 
                                } else {
-                                       D(bug("  PAGE: %03d-%03d log=%08lx addr=%08lx UR=%02d G=%d U1/0=%d S=%d CM=%d M=%d U=%d W=%d",
+                                       D(bug(L"  PAGE: %03d-%03d log=%08lx addr=%08lx UR=%02d G=%d U1/0=%d S=%d CM=%d M=%d U=%d W=%d",
                                                        page_info[page_idx].start_idx,
                                                        page_info[page_idx].start_idx + page_info[page_idx].n_pages - 1,
                                                        page_info[page_idx].log,
@@ -253,7 +253,7 @@ void mmu_dump_atc(void)
                for (j = 0; j < ATC_L2_SIZE; j++) {
                        if (atc_l2[i][j].tag == 0x8000)
                                continue;
-                       D(bug("ATC[%02d] G=%d TT=%d M=%d WP=%d VD=%d VI=%d tag=%08x --> phys=%08x",
+                       D(bug(L"ATC[%02d] G=%d TT=%d M=%d WP=%d VD=%d VI=%d tag=%08x --> phys=%08x",
                                j, atc_l2[i][j].global, atc_l2[i][j].tt, atc_l2[i][j].modified,
                                atc_l2[i][j].write_protect, atc_l2[i][j].valid_data, atc_l2[i][j].valid_inst,
                                atc_l2[i][j].tag, atc_l2[i][j].phys));
@@ -265,11 +265,11 @@ void mmu_dump_atc(void)
 /* {{{ mmu_dump_tables */
 void mmu_dump_tables(void)
 {
-       D(bug("URP: %08x   SRP: %08x  MMUSR: %x  TC: %x\n", regs.urp, regs.srp, regs.mmusr, regs.tcr));
-       mmu_dump_ttr("DTT0", regs.dtt0);
-       mmu_dump_ttr("DTT1", regs.dtt1);
-       mmu_dump_ttr("ITT0", regs.itt0);
-       mmu_dump_ttr("ITT1", regs.itt1);
+       D(bug(L"URP: %08x   SRP: %08x  MMUSR: %x  TC: %x\n", regs.urp, regs.srp, regs.mmusr, regs.tcr));
+       mmu_dump_ttr(L"DTT0", regs.dtt0);
+       mmu_dump_ttr(L"DTT1", regs.dtt1);
+       mmu_dump_ttr(L"ITT0", regs.itt0);
+       mmu_dump_ttr(L"ITT1", regs.itt1);
        mmu_dump_atc();
        //mmu_dump_table("SRP", regs.srp);
 }
@@ -306,7 +306,7 @@ static void mmu_bus_error(uaecptr addr, int fc, int write, int size)
        regs.mmu_fault_addr = addr;
        regs.mmu_ssw = ssw | MMU_SSW_ATC;
 
-       D(bug("BUS ERROR: fc=%d w=%d log=%08x ssw=%04x", fc, write, addr, ssw));
+       D(bug(L"BUS ERROR: fc=%d w=%d log=%08x ssw=%04x", fc, write, addr, ssw));
 
        THROW(2);
 }
@@ -355,7 +355,7 @@ static uaecptr mmu_fill_atc_l2(uaecptr addr, int super, int data, int write,
        SAVE_EXCEPTION;
        TRY(prb) {
                desc = mmu_lookup_pagetable(addr, super, write);
-               D(bug("translate: %x,%u,%u,%u -> %x", addr, super, write, data, desc));
+               D(bug(L"translate: %x,%u,%u,%u -> %x", addr, super, write, data, desc));
                RESTORE_EXCEPTION;
        }
        CATCH(prb) {
@@ -397,12 +397,12 @@ mmu_fill_atc_l1(uaecptr addr, int super, int data, int write,
                mmu_fill_atc_l2(addr, super, data, write, l);
        }
        if (!(data ? l->valid_data : l->valid_inst)) {
-               D(bug("MMU: non-resident page (%x,%x,%x)!", addr, regs.pc, regs.fault_pc));
+               D(bug(L"MMU: non-resident page (%x,%x,%x)!", addr, regs.pc, regs.fault_pc));
                goto fail;
        }
        if (write) {
                if (l->write_protect) {
-                       D(bug("MMU: write protected (via %s) %lx", l->tt ? "ttr" : "atc", addr));
+                       D(bug(L"MMU: write protected (via %s) %lx", l->tt ? "ttr" : "atc", addr));
                        goto fail;
                }
                if (!l->modified)
@@ -464,7 +464,7 @@ static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, int super, int write
        desc_addr = (desc & MMU_ROOT_PTR_ADDR_MASK) | i;
        desc = phys_get_long(desc_addr);
        if ((desc & 2) == 0) {
-               D(bug("MMU: invalid root descriptor for %lx", addr));
+               D(bug(L"MMU: invalid root descriptor for %lx", addr));
                return 0;
        }
 
@@ -477,7 +477,7 @@ static uaecptr REGPARAM2 mmu_lookup_pagetable(uaecptr addr, int super, int write
        desc_addr = (desc & MMU_ROOT_PTR_ADDR_MASK) | i;
        desc = phys_get_long(desc_addr);
        if ((desc & 2) == 0) {
-               D(bug("MMU: invalid ptr descriptor for %lx", addr));
+               D(bug(L"MMU: invalid ptr descriptor for %lx", addr));
                return 0;
        }
        wp |= desc;
@@ -497,12 +497,12 @@ get_page_descriptor:
        desc = phys_get_long(desc_addr);
        if ((desc & 1) == 0) {
                if ((desc & 2) == 0) {
-                       D(bug("MMU: invalid page descriptor log=%08lx desc=%08lx @%08lx", addr, desc, desc_addr));
+                       D(bug(L"MMU: invalid page descriptor log=%08lx desc=%08lx @%08lx", addr, desc, desc_addr));
                        return desc;
                }
                /* indirect */
                if (indirect) {
-                       D(bug("MMU: double indirect descriptor log=%lx descriptor @ %lx", addr, desc_addr));
+                       D(bug(L"MMU: double indirect descriptor log=%lx descriptor @ %lx", addr, desc_addr));
                        return desc;
                }
                wp |= desc;
@@ -917,11 +917,11 @@ void REGPARAM2 mmu_op_real(uae_u32 opcode, uae_u16 extra)
                glob = (opcode & 8) != 0;
 
                if (opcode & 16) {
-                       D(bug("pflusha(%u,%u)\n", glob, regs.dfc));
+                       D(bug(L"pflusha(%u,%u)\n", glob, regs.dfc));
                        mmu_flush_atc_all(glob);
                } else {
                        addr = m68k_areg(&regs, regno);
-                       D(bug("pflush(%u,%u,%x)\n", glob, regs.dfc, addr));
+                       D(bug(L"pflush(%u,%u,%x)\n", glob, regs.dfc, addr));
                        mmu_flush_atc(addr, super, glob);
                }
                flush_internals();
@@ -933,7 +933,7 @@ void REGPARAM2 mmu_op_real(uae_u32 opcode, uae_u16 extra)
                write = (opcode & 32) == 0;
                addr = m68k_areg(&regs, regno);
                //bug("ptest(%u,%u,%x)", write, regs.dfc, addr);
-               D(bug("PTEST%c (A%d) %08x DFC=%d\n", write ? 'W' : 'R', regno, addr, regs.dfc));
+               D(bug(L"PTEST%c (A%d) %08x DFC=%d\n", write ? 'W' : 'R', regno, addr, regs.dfc));
                mmu_flush_atc(addr, super, true);
                SAVE_EXCEPTION;
                TRY(prb) {
@@ -957,7 +957,7 @@ void REGPARAM2 mmu_op_real(uae_u32 opcode, uae_u16 extra)
                        regs.mmusr = MMU_MMUSR_B;
                }
                RESTORE_EXCEPTION;
-               D(bug("PTEST result: mmusr %08x\n", regs.mmusr));
+               D(bug(L"PTEST result: mmusr %08x\n", regs.mmusr));
        } else
                op_illg (opcode, &regs);
 }
@@ -1032,7 +1032,7 @@ void REGPARAM2 mmu_set_tc(uae_u16 tc)
        regs.mmu_pagesize_8k = tc & 0x4000 ? 1 : 0;
        mmu_flush_atc_all(true);
 
-       D(bug("MMU: enabled=%d page8k=%d\n", regs.mmu_enabled, regs.mmu_pagesize_8k));
+       D(bug(L"MMU: enabled=%d page8k=%d\n", regs.mmu_enabled, regs.mmu_pagesize_8k));
 }
 
 void REGPARAM2 mmu_set_super(bool super)
diff --git a/crc32.c b/crc32.c
index 9b645afba0a1cc09dea365a9fe631df027684692..d9b5d603ef7f848ab608e2212d00488699296a79 100644 (file)
--- a/crc32.c
+++ b/crc32.c
@@ -335,17 +335,17 @@ void get_sha1 (uae_u8 *input, int len, uae_u8 *out)
     sha1_update( &ctx, input, len );
     sha1_finish( &ctx, out );
 }
-char *get_sha1_txt (uae_u8 *input, int len)
+const TCHAR *get_sha1_txt (uae_u8 *input, int len)
 {
-    static char outtxt[SHA1_SIZE * 2 + 1];
+    static TCHAR outtxt[SHA1_SIZE * 2 + 1];
     uae_u8 out[SHA1_SIZE];
     int i;
-    char *p;
+    TCHAR *p;
 
     p = outtxt;
-    get_sha1(input, len, out);
+    get_sha1 (input, len, out);
     for (i = 0; i < SHA1_SIZE; i++) {
-       sprintf(p, "%02X", out[i]);
+       _stprintf (p, L"%02X", out[i]);
        p += 2;
     }
     *p = 0;
index 2c69053288af38c4e6e2c08307121d30a32fc492..95cce1e2da1d85fb6a49b093254a39464214628e 100644 (file)
--- a/custom.c
+++ b/custom.c
@@ -75,17 +75,17 @@ STATIC_INLINE int nocustom(void)
     return 0;
 }
 
-void uae_abort (const char *format,...)
+void uae_abort (const TCHAR *format,...)
 {
     static int nomore;
     va_list parms;
-    char buffer[1000];
+    TCHAR buffer[1000];
 
     va_start (parms, format);
-    _vsnprintf(buffer, sizeof (buffer) - 1, format, parms );
+    _vsntprintf (buffer, sizeof (buffer) - 1, format, parms );
     va_end (parms);
     if (nomore) {
-       write_log ("%s\n", buffer);
+       write_log (L"%s\n", buffer);
        return;
     }
     gui_message (buffer);
@@ -425,7 +425,7 @@ void reset_frame_rate_hack (void)
     rpt_did_reset = 1;
     is_lastline = 0;
     vsyncmintime = read_processor_time () + vsynctime;
-    write_log ("Resetting frame rate hack\n");
+    write_log (L"Resetting frame rate hack\n");
 }
 
 STATIC_INLINE void setclr (uae_u16 *p, uae_u16 val)
@@ -441,11 +441,11 @@ STATIC_INLINE alloc_cycle (int hpos, int type)
 #ifdef CPUEMU_12
 #if 0
     if (cycle_line[hpos])
-       write_log ("hpos=%d, old=%d, new=%d\n", hpos, cycle_line[hpos], type);
+       write_log (L"hpos=%d, old=%d, new=%d\n", hpos, cycle_line[hpos], type);
     if ((type == CYCLE_CPU || type == CYCLE_COPPER) && (hpos & 1))
-       write_log ("odd %d cycle %d\n", hpos);
+       write_log (L"odd %d cycle %d\n", hpos);
     if (!(hpos & 1) && (type == CYCLE_SPRITE || type == CYCLE_REFRESH || type == CYCLE_MISC))
-       write_log ("even %d cycle %d\n", type, hpos);
+       write_log (L"even %d cycle %d\n", type, hpos);
 #endif
     cycle_line[hpos] = type;
 #endif
@@ -482,7 +482,7 @@ STATIC_INLINE uae_u8 *pfield_xlateptr (uaecptr plpt, int bytecount)
     if (!chipmem_bank.check (plpt, bytecount)) {
        static int count = 0;
        if (!count)
-           count++, write_log ("Warning: Bad playfield pointer\n");
+           count++, write_log (L"Warning: Bad playfield pointer\n");
        return NULL;
     }
     return chipmem_bank.xlateaddr (plpt);
@@ -694,22 +694,22 @@ static const int cycle_sequences[3 * 8] = { 2,1,2,1,2,1,2,1, 4,2,3,1,4,2,3,1, 8,
 static void debug_cycle_diagram (void)
 {
     int fm, res, planes, cycle, v;
-    char aa;
+    TCHAR aa;
 
     for (fm = 0; fm <= 2; fm++) {
-       write_log ("FMODE %d\n=======\n", fm);
+       write_log (L"FMODE %d\n=======\n", fm);
        for (res = 0; res <= 2; res++) {
            for (planes = 0; planes <= 8; planes++) {
-               write_log ("%d: ",planes);
+               write_log (L"%d: ",planes);
                for (cycle = 0; cycle < 32; cycle++) {
                    v=cycle_diagram_table[fm][res][planes][cycle];
                    if (v==0) aa='-'; else if(v>0) aa='1'; else aa='X';
-                   write_log ("%c",aa);
+                   write_log (L"%c",aa);
                }
-               write_log (" %d:%d\n",
+               write_log (L" %d:%d\n",
                    cycle_diagram_free_cycles[fm][res][planes], cycle_diagram_total_cycles[fm][res][planes]);
            }
-           write_log ("\n");
+           write_log (L"\n");
        }
     }
     fm=0;
@@ -833,7 +833,7 @@ STATIC_INLINE void compute_delay_offset (void)
        delayoffset = 16;
     else /* what about 40 and 56? */
        delayoffset = 0;
-    //write_log ("%d:%d ", vpos, delayoffset);
+    //write_log (L"%d:%d ", vpos, delayoffset);
 #endif
 }
 
@@ -1534,7 +1534,7 @@ STATIC_INLINE int one_fetch_cycle_0 (int pos, int ddfstop_to_test, int dma, int
     toscr_nbits += 2 << toscr_res;
 
     if (toscr_nbits > 16) {
-       uae_abort ("toscr_nbits > 16 (%d)", toscr_nbits);
+       uae_abort (L"toscr_nbits > 16 (%d)", toscr_nbits);
        toscr_nbits = 0;
     }
     if (toscr_nbits == 16)
@@ -1555,7 +1555,7 @@ STATIC_INLINE int one_fetch_cycle (int pos, int ddfstop_to_test, int dma, int fm
     case 1: return one_fetch_cycle_fm1 (pos, ddfstop_to_test, dma);
     case 2: return one_fetch_cycle_fm2 (pos, ddfstop_to_test, dma);
 #endif
-    default: uae_abort ("fm corrupt"); return 0;
+    default: uae_abort (L"fm corrupt"); return 0;
     }
 }
 
@@ -1686,7 +1686,7 @@ STATIC_INLINE void decide_fetch (int hpos)
        case 1: update_fetch_1 (hpos); break;
        case 2: update_fetch_2 (hpos); break;
 #endif
-       default: uae_abort ("fetchmode corrupt");
+       default: uae_abort (L"fetchmode corrupt");
        }
     }
     last_fetch_hpos = hpos;
@@ -2052,7 +2052,7 @@ static void do_sprite_collisions (void)
     {
        static int olx;
        if (clxdat != olx)
-           write_log ("%d: %04X\n", vpos, clxdat);
+           write_log (L"%d: %04X\n", vpos, clxdat);
        olx = clxdat;
     }
 #endif
@@ -2150,7 +2150,7 @@ static void record_sprite (int line, int num, int sprxp, uae_u16 *data, uae_u16
     }
 
     if (sprxp < e->pos)
-       uae_abort ("sprxp < e->pos");
+       uae_abort (L"sprxp < e->pos");
 
     e->max = sprxp + width;
     e[1].first_pixel = e->first_pixel + ((e->max - e->pos + 3) & ~3);
@@ -2390,10 +2390,10 @@ static void finish_decisions (int hpos)
 
     if (thisline_decision.plfleft != -1 && thisline_decision.plflinelen == -1) {
        if (fetch_state != fetch_not_started) {
-           write_log ("fetch_state=%d plfleft=%d,len=%d,vpos=%d,hpos=%d\n",
+           write_log (L"fetch_state=%d plfleft=%d,len=%d,vpos=%d,hpos=%d\n",
                fetch_state, thisline_decision.plfleft, thisline_decision.plflinelen,
                vpos, hpos);
-           uae_abort ("fetch_state != fetch_not_started");
+           uae_abort (L"fetch_state != fetch_not_started");
        }
        thisline_decision.plfright = thisline_decision.plfleft;
        thisline_decision.plflinelen = 0;
@@ -2564,10 +2564,10 @@ static void dumpsync (void)
     if (cnt < 0)
        return;
     cnt--;
-    write_log ("BEAMCON0=%04X VTOTAL=%04X HTOTAL=%04X\n", new_beamcon0, vtotal, htotal);
-    write_log ("HSSTOP=%04X HBSTRT=%04X HBSTOP=%04X\n", hsstop, hbstrt, hbstop);
-    write_log ("VSSTOP=%04X VBSTRT=%04X VBSTOP=%04X\n", vsstop, vbstrt, vbstop);
-    write_log ("HSSTRT=%04X VSSTRT=%04X HCENTER=%04X\n", hsstrt, vsstrt, hcenter);
+    write_log (L"BEAMCON0=%04X VTOTAL=%04X HTOTAL=%04X\n", new_beamcon0, vtotal, htotal);
+    write_log (L"HSSTOP=%04X HBSTRT=%04X HBSTOP=%04X\n", hsstop, hbstrt, hbstop);
+    write_log (L"VSSTOP=%04X VBSTRT=%04X VBSTOP=%04X\n", vsstop, vbstrt, vbstop);
+    write_log (L"HSSTRT=%04X VSSTRT=%04X HCENTER=%04X\n", hsstrt, vsstrt, hcenter);
 }
 
 /* set PAL/NTSC or custom timing variables */
@@ -2590,7 +2590,7 @@ void init_hz (void)
        hzc = 1;
     if (beamcon0 != new_beamcon0) {
        hack_vpos = 0;
-       write_log ("BEAMCON0 %04x -> %04x\n", beamcon0, new_beamcon0);
+       write_log (L"BEAMCON0 %04x -> %04x\n", beamcon0, new_beamcon0);
     }
     if (beamcon0 & 0x80)
        hack_vpos = -1;
@@ -2666,10 +2666,10 @@ void init_hz (void)
     init_hz_p96 ();
 #endif
     inputdevice_tablet_strobe ();
-    write_log ("%s mode%s%s V=%dHz H=%dHz (%dx%d)\n",
-       isntsc ? "NTSC" : "PAL",
-       (bplcon0 & 4) ? " interlaced" : "",
-       doublescan > 0 ? " dblscan" : "",
+    write_log (L"%s mode%s%s V=%dHz H=%dHz (%dx%d)\n",
+       isntsc ? L"NTSC" : L"PAL",
+       (bplcon0 & 4) ? L" interlaced" : L"",
+       doublescan > 0 ? L" dblscan" : L"",
        vblank_hz, vblank_hz * maxvpos,
        maxhpos, maxvpos);
 }
@@ -2823,7 +2823,7 @@ STATIC_INLINE uae_u16 VPOSR (void)
        vp &= 1;
     vp = vp | (lof ? 0x8000 : 0) | csbit;
 #if 0
-    write_log ("VPOSR %04x at %08x\n", vp, M68K_GETPC);
+    write_log (L"VPOSR %04x at %08x\n", vp, M68K_GETPC);
 #endif
     if (currprefs.cpu_model >= 68020)
        hsyncdelay ();
@@ -2832,7 +2832,7 @@ STATIC_INLINE uae_u16 VPOSR (void)
 static void VPOSW (uae_u16 v)
 {
 #if 0
-    write_log ("VPOSW %d PC=%08x\n", v, M68K_GETPC);
+    write_log (L"VPOSW %d PC=%08x\n", v, M68K_GETPC);
 #endif
     if (lof != ((v & 0x8000) ? 1 : 0))
        lof_changed = 1;
@@ -2860,7 +2860,7 @@ STATIC_INLINE uae_u16 VHPOSR (void)
     if (currprefs.cpu_model >= 68020)
        hsyncdelay ();
 #if 0
-    write_log ("VPOS %04x %04x at %08x\n", VPOSR(), vp, M68K_GETPC);
+    write_log (L"VPOS %04x %04x at %08x\n", VPOSR(), vp, M68K_GETPC);
     if (M68K_GETPC == 0x40e6) {
         activate_debugger();
     }
@@ -3057,7 +3057,7 @@ STATIC_INLINE void INTENA (uae_u16 v)
     setclr (&intena,v);
 #if 0
     if (v & 0x40)
-       write_log ("INTENA %04X (%04X) %p\n", intena, v, M68K_GETPC);
+       write_log (L"INTENA %04X (%04X) %p\n", intena, v, M68K_GETPC);
 #endif
     if (v & 0x8000) {
        if (!use_eventmode ())
@@ -3132,7 +3132,7 @@ static void BEAMCON0 (uae_u16 v)
        if (v != new_beamcon0) {
            new_beamcon0 = v;
            if (v & ~0x20)
-               write_log ("warning: %04X written to BEAMCON0 PC=%08X\n", v, M68K_GETPC);
+               write_log (L"warning: %04X written to BEAMCON0 PC=%08X\n", v, M68K_GETPC);
        }
     }
 }
@@ -3196,7 +3196,7 @@ static void BPLxPTH (int hpos, uae_u16 v, int num)
     decide_fetch (hpos);
     bplpt[num] = (bplpt[num] & 0x0000ffff) | ((uae_u32)v << 16);
     bplptx[num] = (bplptx[num] & 0x0000ffff) | ((uae_u32)v << 16);
-    //write_log ("%d:%d:BPL%dPTH %08X COP=%08x\n", hpos, vpos, num, bplpt[num], cop_state.ip);
+    //write_log (L"%d:%d:BPL%dPTH %08X COP=%08x\n", hpos, vpos, num, bplpt[num], cop_state.ip);
 }
 static void BPLxPTL (int hpos, uae_u16 v, int num)
 {
@@ -3210,7 +3210,7 @@ static void BPLxPTL (int hpos, uae_u16 v, int num)
     }
     bplpt[num] = (bplpt[num] & 0xffff0000) | ((v + delta) & 0x0000fffe);
     bplptx[num] = (bplptx[num] & 0xffff0000) | ((v + delta) & 0x0000fffe);
-    //write_log ("%d:%d:BPL%dPTL %08X COP=%08x\n", hpos, vpos, num, bplpt[num], cop_state.ip);
+    //write_log (L"%d:%d:BPL%dPTL %08X COP=%08x\n", hpos, vpos, num, bplpt[num], cop_state.ip);
 }
 
 static int isehb (uae_u16 bplcon0, uae_u16 bplcon2)
@@ -3442,7 +3442,7 @@ static void DDFSTRT (int hpos, uae_u16 v)
        static int last_warned;
        last_warned = (last_warned + 1) & 4095;
        if (last_warned == 0)
-           write_log ("WARNING! Very strange DDF values (%x %x).\n", ddfstrt, ddfstop);
+           write_log (L"WARNING! Very strange DDF values (%x %x).\n", ddfstrt, ddfstop);
     }
 }
 
@@ -3463,7 +3463,7 @@ static void DDFSTOP (int hpos, uae_u16 v)
     if (ddfstop > 0xD4 && (ddfstrt & 4) == 4) {
        static int last_warned;
        if (last_warned == 0)
-           write_log ("WARNING! Very strange DDF values (%x).\n", ddfstop);
+           write_log (L"WARNING! Very strange DDF values (%x).\n", ddfstop);
        last_warned = (last_warned + 1) & 4095;
     }
 }
@@ -3644,7 +3644,7 @@ STATIC_INLINE void SPRxCTL_1 (uae_u16 v, int num, int hpos)
     SPRxCTLPOS (num);
 #if SPRITE_DEBUG > 0
     if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-       write_log ("%d:%d:SPR%dCTL %04X P=%06X VSTRT=%d VSTOP=%d HSTRT=%d D=%d A=%d CP=%x PC=%x\n",
+       write_log (L"%d:%d:SPR%dCTL %04X P=%06X VSTRT=%d VSTOP=%d HSTRT=%d D=%d A=%d CP=%x PC=%x\n",
            vpos, hpos, num, v, s->pt, s->vstart, s->vstop, s->xpos, spr[num].dmastate, spr[num].armed, cop_state.ip, M68K_GETPC);
     }
 #endif
@@ -3657,7 +3657,7 @@ STATIC_INLINE void SPRxPOS_1 (uae_u16 v, int num, int hpos)
     SPRxCTLPOS (num);
 #if SPRITE_DEBUG > 0
     if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-       write_log ("%d:%d:SPR%dPOS %04X P=%06X VSTRT=%d VSTOP=%d HSTRT=%d D=%d A=%d CP=%x PC=%x\n",
+       write_log (L"%d:%d:SPR%dPOS %04X P=%06X VSTRT=%d VSTOP=%d HSTRT=%d D=%d A=%d CP=%x PC=%x\n",
            vpos, hpos, num, v, s->pt, s->vstart, s->vstop, s->xpos, spr[num].dmastate, spr[num].armed, cop_state.ip, M68K_GETPC);
     }
 #endif
@@ -3673,7 +3673,7 @@ STATIC_INLINE void SPRxDATA_1 (uae_u16 v, int num, int hpos)
     spr_arm (num, 1);
 #if SPRITE_DEBUG > 1
     if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-       write_log ("%d:%d:SPR%dDATA %04X P=%06X D=%d A=%d PC=%x\n",
+       write_log (L"%d:%d:SPR%dDATA %04X P=%06X D=%d A=%d PC=%x\n",
            vpos, hpos, num, v, spr[num].pt, spr[num].dmastate, spr[num].armed, M68K_GETPC);
     }
 #endif
@@ -3688,7 +3688,7 @@ STATIC_INLINE void SPRxDATB_1 (uae_u16 v, int num, int hpos)
 #endif
 #if SPRITE_DEBUG > 1
     if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-       write_log ("%d:%d:SPR%dDATB %04X P=%06X D=%d A=%d PC=%x\n",
+       write_log (L"%d:%d:SPR%dDATB %04X P=%06X D=%d A=%d PC=%x\n",
            vpos, hpos, num, v, spr[num].pt, spr[num].dmastate, spr[num].armed, M68K_GETPC);
     }
 #endif
@@ -3704,7 +3704,7 @@ static void SPRxPTH (int hpos, uae_u16 v, int num)
     spr[num].pt |= (uae_u32)v << 16;
 #if SPRITE_DEBUG > 0
     if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-       write_log ("%d:%d:SPR%dPTH %06X\n", vpos, hpos, num, spr[num].pt);
+       write_log (L"%d:%d:SPR%dPTH %06X\n", vpos, hpos, num, spr[num].pt);
     }
 #endif
 }
@@ -3715,7 +3715,7 @@ static void SPRxPTL (int hpos, uae_u16 v, int num)
     spr[num].pt |= v;
 #if SPRITE_DEBUG > 0
      if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-       write_log ("%d:%d:SPR%dPTL %06X\n", vpos, hpos, num, spr[num].pt);
+       write_log (L"%d:%d:SPR%dPTL %06X\n", vpos, hpos, num, spr[num].pt);
      }
 #endif
 }
@@ -3758,7 +3758,7 @@ void dump_aga_custom (void)
        rgb2 = current_colors.color_regs_aga[c2] | (color_regs_aga_genlock[c2] << 31);
        rgb3 = current_colors.color_regs_aga[c3] | (color_regs_aga_genlock[c3] << 31);
        rgb4 = current_colors.color_regs_aga[c4] | (color_regs_aga_genlock[c4] << 31);
-       console_out_f ("%3d %08X %3d %08X %3d %08X %3d %08X\n",
+       console_out_f (L"%3d %08X %3d %08X %3d %08X %3d %08X\n",
            c1, rgb1, c2, rgb2, c3, rgb3, c4, rgb4);
     }
 }
@@ -3930,7 +3930,7 @@ static void perform_copper_write (int old_hpos, int address, int data)
        cop_state.last_write_hpos = old_hpos;
        old_hpos++;
        if (!nocustom () && address >= 0x140 && address < 0x180 && old_hpos >= SPR0_HPOS && old_hpos < SPR0_HPOS + 4 * MAX_SPRITES) {
-           //write_log ("%d:%d %04X:%04X\n", vpos, old_hpos, cop_state.saved_i1, cop_state.saved_i2);
+           //write_log (L"%d:%d %04X:%04X\n", vpos, old_hpos, cop_state.saved_i1, cop_state.saved_i2);
            do_sprites (old_hpos);
        }
     }
@@ -3956,13 +3956,13 @@ static int isagnus[]= {
     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 };
 
-static void dump_copper (char *error, int until_hpos)
+static void dump_copper (TCHAR *error, int until_hpos)
 {
-    write_log ("%s: vpos=%d until_hpos=%d\n",
+    write_log (L"%s: vpos=%d until_hpos=%d\n",
        error, vpos, until_hpos);
-    write_log ("cvcmp=%d chcmp=%d chpos=%d cvpos=%d ci1=%04X ci2=%04X\n",
+    write_log (L"cvcmp=%d chcmp=%d chpos=%d cvpos=%d ci1=%04X ci2=%04X\n",
        cop_state.vcmp,cop_state.hcmp,cop_state.hpos,cop_state.vpos,cop_state.saved_i1,cop_state.saved_i2);
-    write_log ("cstate=%d ip=%x SPCFLAGS=%x\n",
+    write_log (L"cstate=%d ip=%x SPCFLAGS=%x\n",
        cop_state.state, cop_state.ip, regs.spcflags);
 }
 
@@ -3975,7 +3975,7 @@ static void update_copper (int until_hpos)
        return;
 
     if (cop_state.state == COP_wait && vp < cop_state.vcmp) {
-       dump_copper ("error2", until_hpos);
+       dump_copper (L"error2", until_hpos);
        copper_enabled_thisline = 0;
        cop_state.state = COP_stop;
        unset_special (&regs, SPCFLAG_COPPER);
@@ -4294,12 +4294,12 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos)
 #endif
 #if SPRITE_DEBUG > 3
     if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY)
-       write_log ("%d:%d:slot%d:%d\n", vpos, hpos, num, cycle);
+       write_log (L"%d:%d:slot%d:%d\n", vpos, hpos, num, cycle);
 #endif
     if (vpos == s->vstart) {
 #if SPRITE_DEBUG > 0
        if (!s->dmastate && vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY)
-           write_log ("%d:%d:SPR%d START\n", vpos, hpos, num);
+           write_log (L"%d:%d:SPR%d START\n", vpos, hpos, num);
 #endif
        s->dmastate = 1;
        if (num == 0 && cycle == 0)
@@ -4308,7 +4308,7 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos)
     if (vpos == s->vstop || vpos == sprite_vblank_endline) {
 #if SPRITE_DEBUG > 0
        if (s->dmastate && vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY)
-           write_log ("%d:%d:SPR%d STOP\n", vpos, hpos, num);
+           write_log (L"%d:%d:SPR%d STOP\n", vpos, hpos, num);
 #endif
        s->dmastate = 0;
 #if 1
@@ -4343,10 +4343,10 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos)
        }
 #if SPRITE_DEBUG > 1
        if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-           write_log ("%d:%d:dma:P=%06X ", vpos, hpos, s->pt);
+           write_log (L"%d:%d:dma:P=%06X ", vpos, hpos, s->pt);
        }
 #endif
-       //write_log ("%d:%d: %04X=%04X\n", vpos, hpos, 0x140 + cycle * 2 + num * 8, data);
+       //write_log (L"%d:%d: %04X=%04X\n", vpos, hpos, 0x140 + cycle * 2 + num * 8, data);
        if (cycle == 0) {
            SPRxPOS_1 (data, num, hpos);
            s->dmacycle = 1;
@@ -4362,7 +4362,7 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos)
        data = sprite_fetch (s, dma, hpos, cycle, 1);
 #if SPRITE_DEBUG > 1
        if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
-           write_log ("%d:%d:dma:P=%06X ", vpos, hpos, s->pt);
+           write_log (L"%d:%d:dma:P=%06X ", vpos, hpos, s->pt);
        }
 #endif
        if (cycle == 0) {
@@ -4490,11 +4490,11 @@ static void adjust_array_sizes (void)
            memset (&sprite_entries[0][max_sprite_entry], (mcc - max_sprite_entry) * sizeof(struct sprite_entry), 0);
            memset (&sprite_entries[1][max_sprite_entry], (mcc - max_sprite_entry) * sizeof(struct sprite_entry), 0);
 
-           write_log ("New max_sprite_entry=%d\n", mcc);
+           write_log (L"New max_sprite_entry=%d\n", mcc);
 
            max_sprite_entry = mcc;
        } else
-           write_log ("WARNING: Failed to enlarge sprite_entries table\n");
+           write_log (L"WARNING: Failed to enlarge sprite_entries table\n");
     }
     if (delta_color_change) {
        void *p1;
@@ -4510,11 +4510,11 @@ static void adjust_array_sizes (void)
            color_changes[0] = p1;
            color_changes[1] = p2;
 
-           write_log ("New max_color_change=%d\n", mcc);
+           write_log (L"New max_color_change=%d\n", mcc);
 
            max_color_change = mcc;
        } else
-           write_log ("WARNING: Failed to enlarge color_changes table\n");
+           write_log (L"WARNING: Failed to enlarge color_changes table\n");
     }
 #endif
 }
@@ -4782,7 +4782,7 @@ static void copper_check (int n)
        int vp = vpos & (((cop_state.saved_i2 >> 8) & 0x7F) | 0x80);
        if (vp < cop_state.vcmp) {
            if (copper_enabled_thisline)
-               write_log ("COPPER BUG %d: vp=%d vpos=%d vcmp=%d act=%d thisline=%d\n", n, vp, vpos, cop_state.vcmp, copper_enabled_thisline);
+               write_log (L"COPPER BUG %d: vp=%d vpos=%d vcmp=%d act=%d thisline=%d\n", n, vp, vpos, cop_state.vcmp, copper_enabled_thisline);
        }
     }
 }
@@ -4802,7 +4802,7 @@ static void CIA_vsync_prehandler (int dotod)
            inprec_pend();
        }
        if (v != ciavsync_counter)
-           write_log ("INPREC: ciavsync sync error %d <> %d\n", v, ciavsync_counter);
+           write_log (L"INPREC: ciavsync sync error %d <> %d\n", v, ciavsync_counter);
     }
 #endif
     ciavsync_counter++;
@@ -5004,7 +5004,7 @@ static void hsync_handler (void)
                inprec_pend();
            }
            if (v != vsync_counter)
-               write_log ("INPREC: vsync sync error %d <> %d\n", v, vsync_counter);
+               write_log (L"INPREC: vsync sync error %d <> %d\n", v, vsync_counter);
        }
 #endif
        vsync_counter++;
@@ -5096,7 +5096,7 @@ static void hsync_handler (void)
     while (input_recording < 0 && inprec_pstart (INPREC_DISKINSERT)) {
        int drv = inprec_pu8 ();
        inprec_pstr (currprefs.df[drv]);
-       strcpy (changed_prefs.df[drv], currprefs.df[drv]);
+       _tcscpy (changed_prefs.df[drv], currprefs.df[drv]);
        disk_insert_force (drv, currprefs.df[drv]);
        inprec_pend ();
     }
@@ -5203,7 +5203,7 @@ STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func)
            }
        }
        if (no == ev2_max) {
-           write_log ("out of event2's! PC=%x\n", M68K_GETPC);
+           write_log (L"out of event2's! PC=%x\n", M68K_GETPC);
            return;
        }
     }
@@ -5260,7 +5260,7 @@ void customreset (int hardreset)
     int zero = 0;
 
     reset_all_systems ();
-    write_log ("Reset at %08X\n", m68k_getpc (&regs));
+    write_log (L"Reset at %08X\n", m68k_getpc (&regs));
     memory_map_dump();
 
     hsync_counter = 0;
@@ -5404,7 +5404,7 @@ void customreset (int hardreset)
        CLXCON (clxcon);
        CLXCON2 (clxcon2);
        calcdiw ();
-       write_log ("State restored\n");
+       write_log (L"State restored\n");
        for (i = 0; i < 8; i++)
            nr_armed += spr[i].armed != 0;
        if (! currprefs.produce_sound) {
@@ -5431,17 +5431,17 @@ void customreset (int hardreset)
 
 void dumpcustom (void)
 {
-    console_out_f ("DMACON: %x INTENA: %x INTREQ: %x VPOS: %x HPOS: %x\n", DMACONR(),
+    console_out_f (L"DMACON: %x INTENA: %x INTREQ: %x VPOS: %x HPOS: %x\n", DMACONR(),
            (unsigned int)intena, (unsigned int)intreq, (unsigned int)vpos, (unsigned int)current_hpos());
-    console_out_f ("COP1LC: %08lx, COP2LC: %08lx COPPTR: %08lx\n", (unsigned long)cop1lc, (unsigned long)cop2lc, cop_state.ip);
-    console_out_f ("DIWSTRT: %04x DIWSTOP: %04x DDFSTRT: %04x DDFSTOP: %04x\n",
+    console_out_f (L"COP1LC: %08lx, COP2LC: %08lx COPPTR: %08lx\n", (unsigned long)cop1lc, (unsigned long)cop2lc, cop_state.ip);
+    console_out_f (L"DIWSTRT: %04x DIWSTOP: %04x DDFSTRT: %04x DDFSTOP: %04x\n",
            (unsigned int)diwstrt, (unsigned int)diwstop, (unsigned int)ddfstrt, (unsigned int)ddfstop);
-    console_out_f ("BPLCON 0: %04x 1: %04x 2: %04x 3: %04x 4: %04x\n", bplcon0, bplcon1, bplcon2, bplcon3, bplcon4);
+    console_out_f (L"BPLCON 0: %04x 1: %04x 2: %04x 3: %04x 4: %04x\n", bplcon0, bplcon1, bplcon2, bplcon3, bplcon4);
     if (timeframes) {
-       console_out_f ("Average frame time: %.2f ms [frames: %d time: %d]\n",
+       console_out_f (L"Average frame time: %.2f ms [frames: %d time: %d]\n",
                    (double)frametime / timeframes, timeframes, frametime);
        if (total_skipped)
-           console_out_f ("Skipped frames: %d\n", total_skipped);
+           console_out_f (L"Skipped frames: %d\n", total_skipped);
     }
 }
 
@@ -5561,7 +5561,7 @@ static void REGPARAM3 custom_bput (uaecptr, uae_u32) REGPARAM;
 addrbank custom_bank = {
     custom_lget, custom_wget, custom_bget,
     custom_lput, custom_wput, custom_bput,
-    default_xlate, default_check, NULL, "Custom chipset",
+    default_xlate, default_check, NULL, L"Custom chipset",
     custom_lgeti, custom_wgeti, ABFLAG_IO
 };
 
@@ -5586,7 +5586,7 @@ STATIC_INLINE uae_u32 REGPARAM2 custom_wget_1 (uaecptr addr, int noput)
 #endif
     addr &= 0xfff;
 #ifdef CUSTOM_DEBUG
-    write_log ("%d:%d:wget: %04X=%04X pc=%p\n", current_hpos(), vpos, addr, addr & 0x1fe, m68k_getpc ());
+    write_log (L"%d:%d:wget: %04X=%04X pc=%p\n", current_hpos(), vpos, addr, addr & 0x1fe, m68k_getpc ());
 #endif
     switch (addr & 0x1fe) {
      case 0x002: v = DMACONR (); break;
@@ -5906,7 +5906,7 @@ static void REGPARAM2 custom_wput (uaecptr addr, uae_u32 value)
     special_mem |= S_WRITE;
 #endif
 #ifdef CUSTOM_DEBUG
-    write_log ("%d:%d:wput: %04X %04X pc=%p\n", hpos, vpos, addr & 0x01fe, value & 0xffff, m68k_getpc ());
+    write_log (L"%d:%d:wput: %04X %04X pc=%p\n", hpos, vpos, addr & 0x01fe, value & 0xffff, m68k_getpc ());
 #endif
     sync_copper_with_cpu (hpos, 1);
     if (addr & 1) {
@@ -5936,7 +5936,7 @@ static void REGPARAM2 custom_bput (uaecptr addr, uae_u32 value)
     }
     if (warned < 10) {
        if (M68K_GETPC < 0xe00000 || M68K_GETPC >= 0x10000000) {
-           write_log ("Byte put to custom register %04X PC=%08X\n", addr, M68K_GETPC);
+           write_log (L"Byte put to custom register %04X PC=%08X\n", addr, M68K_GETPC);
            warned++;
        }
     }
diff --git a/debug.c b/debug.c
index 48e2833dc5aea02afa19f8534d50ec0900b240a2..a0bfde5e6497170bede2bdcbdc7b9c9a770e525d 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -47,7 +47,7 @@ int debug_copper;
 int debug_sprite_mask = 0xff;
 
 static uaecptr processptr;
-static char *processname;
+static uae_char *processname;
 
 static uaecptr debug_copper_pc;
 
@@ -60,7 +60,7 @@ void deactivate_debugger (void)
     debugging = 0;
     exception_debugging = 0;
     processptr = 0;
-    xfree(processname);
+    xfree (processname);
     processname = NULL;
 }
 
@@ -79,67 +79,67 @@ int firsthist = 0;
 int lasthist = 0;
 static struct regstruct history[MAX_HIST];
 
-static char help[] = {
-    "          HELP for UAE Debugger\n"
-    "         -----------------------\n\n"
-    "  g [<address>]         Start execution at the current address or <address>\n"
-    "  c                     Dump state of the CIA, disk drives and custom registers\n"
-    "  r                     Dump state of the CPU\n"
-    "  r <reg> <value>       Modify CPU registers (Dx,Ax,USP,ISP,VBR,...)\n"
-    "  m <address> [<lines>] Memory dump starting at <address>\n"
-    "  m r<register>         Memory dump starting at <register>\n"
-    "  d <address> [<lines>] Disassembly starting at <address>\n"
-    "  t [instructions]      Step one or more instructions\n"
-    "  z                     Step through one instruction - useful for JSR, DBRA etc\n"
-    "  f                     Step forward until PC in RAM (\"boot block finder\")\n"
-    "  f <address>           Add/remove breakpoint\n"
-    "  fa <address> [<start>] [<end>]\n"
-    "                        Find effective address <address>\n"
-    "  fi                    Step forward until PC points to RTS/RTD or RTE\n"
-    "  fi <opcode>           Step forward until PC points to <opcode>\n"
-    "  fp \"<name>\"/<addr>    Step forward until process <name> or <addr> is active\n"
-    "  fl                    List breakpoints\n"
-    "  fd                    Remove all breakpoints\n"
-    "  fs <val> <mask>       Break when (SR & mask) = val\n"                   
-    "  f <addr1> <addr2>     Step forward until <addr1> <= PC <= <addr2>\n"
-    "  e                     Dump contents of all custom registers, ea = AGA colors\n"
-    "  i [<addr>]            Dump contents of interrupt and trap vectors\n"
-    "  o <0-2|addr> [<lines>]View memory as Copper instructions\n"
-    "  od                    Enable/disable Copper vpos/hpos tracing\n"
-    "  ot                    Copper single step trace\n"
-    "  ob <addr>             Copper breakpoint\n"
-    "  O                     Display bitplane offsets\n"
-    "  O <plane> <offset>    Offset a bitplane\n"
-    "  H[H] <cnt>            Show PC history (HH=full CPU info) <cnt> instructions\n"
-    "  C <value>             Search for values like energy or lifes in games\n"
-    "  Cl                    List currently found trainer addresses\n"
-    "  D[idxzs <[max diff]>] Deep trainer. i=new value must be larger, d=smaller,\n"
-    "                        x = must be same, z = must be different, s = restart.\n"
-    "  W <address> <value>   Write into Amiga memory\n"
-    "  w <num> <address> <length> <R/W/I/F> [<value>] (read/write/opcode/freeze)\n"
-    "                        Add/remove memory watchpoints\n"
-    "  wd [<0-1>]            Enable illegal access logger. 1 = enable break.\n"
-    "  S <file> <addr> <n>   Save a block of Amiga memory\n"
-    "  s \"<string>\"/<values> [<addr>] [<length>]\n"
-    "                        Search for string/bytes\n"
-    "  T                     Show exec tasks and their PCs\n"
-    "  b                     Step to previous state capture position\n"
-    "  M<a/b/s> <val>        Enable or disable audio channels, bitplanes or sprites\n"
-    "  sp <addr> [<addr2][<size>] Dump sprite information\n"
-    "  di <mode> [<track>]   Break on disk access. R=DMA read,W=write,RW=both,P=PIO\n"
-    "                        Also enables level 1 disk logging\n"
-    "  did <log level>       Enable disk logging\n"
-    "  dj [<level bitmask>]  Enable joystick/mouse input debugging\n"
-    "  smc [<0-1>]           Enable self-modifying code detector. 1 = enable break.\n"
-    "  dm                    Dump current address space map\n"
-    "  ?<value>              Hex/Bin/Dec converter\n"
+static TCHAR help[] = {
+    L"          HELP for UAE Debugger\n"
+    L"         -----------------------\n\n"
+    L"  g [<address>]         Start execution at the current address or <address>\n"
+    L"  c                     Dump state of the CIA, disk drives and custom registers\n"
+    L"  r                     Dump state of the CPU\n"
+    L"  r <reg> <value>       Modify CPU registers (Dx,Ax,USP,ISP,VBR,...)\n"
+    L"  m <address> [<lines>] Memory dump starting at <address>\n"
+    L"  m r<register>         Memory dump starting at <register>\n"
+    L"  d <address> [<lines>] Disassembly starting at <address>\n"
+    L"  t [instructions]      Step one or more instructions\n"
+    L"  z                     Step through one instruction - useful for JSR, DBRA etc\n"
+    L"  f                     Step forward until PC in RAM (\"boot block finder\")\n"
+    L"  f <address>           Add/remove breakpoint\n"
+    L"  fa <address> [<start>] [<end>]\n"
+    L"                        Find effective address <address>\n"
+    L"  fi                    Step forward until PC points to RTS/RTD or RTE\n"
+    L"  fi <opcode>           Step forward until PC points to <opcode>\n"
+    L"  fp \"<name>\"/<addr>    Step forward until process <name> or <addr> is active\n"
+    L"  fl                    List breakpoints\n"
+    L"  fd                    Remove all breakpoints\n"
+    L"  fs <val> <mask>       Break when (SR & mask) = val\n"                   
+    L"  f <addr1> <addr2>     Step forward until <addr1> <= PC <= <addr2>\n"
+    L"  e                     Dump contents of all custom registers, ea = AGA colors\n"
+    L"  i [<addr>]            Dump contents of interrupt and trap vectors\n"
+    L"  o <0-2|addr> [<lines>]View memory as Copper instructions\n"
+    L"  od                    Enable/disable Copper vpos/hpos tracing\n"
+    L"  ot                    Copper single step trace\n"
+    L"  ob <addr>             Copper breakpoint\n"
+    L"  O                     Display bitplane offsets\n"
+    L"  O <plane> <offset>    Offset a bitplane\n"
+    L"  H[H] <cnt>            Show PC history (HH=full CPU info) <cnt> instructions\n"
+    L"  C <value>             Search for values like energy or lifes in games\n"
+    L"  Cl                    List currently found trainer addresses\n"
+    L"  D[idxzs <[max diff]>] Deep trainer. i=new value must be larger, d=smaller,\n"
+    L"                        x = must be same, z = must be different, s = restart.\n"
+    L"  W <address> <value>   Write into Amiga memory\n"
+    L"  w <num> <address> <length> <R/W/I/F> [<value>] (read/write/opcode/freeze)\n"
+    L"                        Add/remove memory watchpoints\n"
+    L"  wd [<0-1>]            Enable illegal access logger. 1 = enable break.\n"
+    L"  S <file> <addr> <n>   Save a block of Amiga memory\n"
+    L"  s \"<string>\"/<values> [<addr>] [<length>]\n"
+    L"                        Search for string/bytes\n"
+    L"  T                     Show exec tasks and their PCs\n"
+    L"  b                     Step to previous state capture position\n"
+    L"  M<a/b/s> <val>        Enable or disable audio channels, bitplanes or sprites\n"
+    L"  sp <addr> [<addr2][<size>] Dump sprite information\n"
+    L"  di <mode> [<track>]   Break on disk access. R=DMA read,W=write,RW=both,P=PIO\n"
+    L"                        Also enables level 1 disk logging\n"
+    L"  did <log level>       Enable disk logging\n"
+    L"  dj [<level bitmask>]  Enable joystick/mouse input debugging\n"
+    L"  smc [<0-1>]           Enable self-modifying code detector. 1 = enable break.\n"
+    L"  dm                    Dump current address space map\n"
+    L"  ?<value>              Hex/Bin/Dec converter\n"
 #ifdef _WIN32
-    "  x                     Close debugger.\n"
-    "  xx                    Switch between console and GUI debugger.\n"
-    "  mg <address>          Memory dump starting at <address> in GUI\n"
-    "  dg <address>          Disassembly starting at <address> in GUI\n"
+    L"  x                     Close debugger.\n"
+    L"  xx                    Switch between console and GUI debugger.\n"
+    L"  mg <address>          Memory dump starting at <address> in GUI\n"
+    L"  dg <address>          Disassembly starting at <address> in GUI\n"
 #endif
-    "  q                     Quit the emulator. You don't want to use this command.\n\n"
+    L"  q                     Quit the emulator. You don't want to use this command.\n\n"
 };
 
 void debug_help (void)
@@ -150,13 +150,13 @@ void debug_help (void)
 static int debug_linecounter;
 #define MAX_LINECOUNTER 1000
 
-static int debug_out (const char *format, ...)
+static int debug_out (const TCHAR *format, ...)
 {
     va_list parms;
-    char buffer[4000];
+    TCHAR buffer[4000];
 
     va_start (parms, format);
-    _vsnprintf (buffer, 4000 - 1, format, parms);
+    _vsntprintf (buffer, 4000 - 1, format, parms);
     va_end (parms);
 
     console_out (buffer);
@@ -167,50 +167,50 @@ static int debug_out (const char *format, ...)
     return 1;
 }
 
-static void ignore_ws (char **c)
+static void ignore_ws (TCHAR **c)
 {
-    while (**c && isspace(**c))
+    while (**c && _istspace(**c))
        (*c)++;
 }
 
-static uae_u32 readint (char **c);
-static uae_u32 readbin (char **c);
-static uae_u32 readhex (char **c);
+static uae_u32 readint (TCHAR **c);
+static uae_u32 readbin (TCHAR **c);
+static uae_u32 readhex (TCHAR **c);
 
-static int readregx (char **c, uae_u32 *valp)
+static int readregx (TCHAR **c, uae_u32 *valp)
 {
     int i;
     uae_u32 addr;
-    char *p = *c;
-    char tmp[10];
+    TCHAR *p = *c;
+    TCHAR tmp[10];
     int extra = 0;
 
     addr = 0;
     i = 0;
     while (p[i]) {
-       tmp[i] = toupper(p[i]);
+       tmp[i] = _totupper(p[i]);
        if (i >= sizeof (tmp) - 1)
            break;
        i++;
     }
     tmp[i] = 0;
-    if (toupper (tmp[0]) == 'R') {
+    if (_totupper (tmp[0]) == 'R') {
        memmove (tmp, tmp + 1, sizeof (tmp) - 1);
        extra = 1;
     }
-    if (!strcmp(tmp, "USP")) {
+    if (!_tcscmp (tmp, L"USP")) {
        addr = regs.usp;
        (*c) += 3;
-    } else if (!strcmp(tmp, "VBR")) {
+    } else if (!_tcscmp (tmp, L"VBR")) {
        addr = regs.vbr;
        (*c) += 3;
-    } else if (!strcmp(tmp, "MSP")) {
+    } else if (!_tcscmp (tmp, L"MSP")) {
        addr = regs.msp;
        (*c) += 3;
-    } else if (!strcmp(tmp, "ISP")) {
+    } else if (!_tcscmp (tmp, L"ISP")) {
        addr = regs.isp;
        (*c) += 3;
-    } else if (!strcmp(tmp, "PC")) {
+    } else if (!_tcscmp (tmp, L"PC")) {
        addr = regs.pc;
        (*c) += 2;
     } else if (tmp[0] == 'A' || tmp[0] == 'D') {
@@ -230,13 +230,13 @@ static int readregx (char **c, uae_u32 *valp)
     return 1;
 }
 
-static uae_u32 readbinx (char **c)
+static uae_u32 readbinx (TCHAR **c)
 {
     uae_u32 val = 0;
 
     ignore_ws (c);
     for (;;) {
-       char nc = **c;
+       TCHAR nc = **c;
        if (nc != '1' && nc != '0')
            break;
        (*c)++;
@@ -247,16 +247,16 @@ static uae_u32 readbinx (char **c)
     return val;
 }
 
-static uae_u32 readhexx (char **c)
+static uae_u32 readhexx (TCHAR **c)
 {
     uae_u32 val = 0;
-    char nc;
+    TCHAR nc;
 
     ignore_ws (c);
     while (isxdigit (nc = **c)) {
        (*c)++;
        val *= 16;
-       nc = toupper (nc);
+       nc = _totupper (nc);
        if (isdigit (nc)) {
            val += nc - '0';
        } else {
@@ -266,10 +266,10 @@ static uae_u32 readhexx (char **c)
     return val;
 }
 
-static uae_u32 readintx (char **c)
+static uae_u32 readintx (TCHAR **c)
 {
     uae_u32 val = 0;
-    char nc;
+    TCHAR nc;
     int negative = 0;
 
     ignore_ws (c);
@@ -284,12 +284,12 @@ static uae_u32 readintx (char **c)
 }
 
 
-static int checkvaltype (char **c, uae_u32 *val)
+static int checkvaltype (TCHAR **c, uae_u32 *val)
 {
-    char nc;
+    TCHAR nc;
 
     ignore_ws (c);
-    nc = toupper (**c);
+    nc = _totupper (**c);
     if (nc == '!') {
        (*c)++;
        *val = readintx (c);
@@ -300,7 +300,7 @@ static int checkvaltype (char **c, uae_u32 *val)
        *val = readhexx (c);
        return 1;
     }
-    if (nc == '0' && toupper ((*c)[1]) == 'X') {
+    if (nc == '0' && _totupper ((*c)[1]) == 'X') {
        (*c)+= 2;
        *val = readhexx (c);
        return 1;
@@ -317,21 +317,21 @@ static int checkvaltype (char **c, uae_u32 *val)
     return 0;
 }
 
-static uae_u32 readint (char **c)
+static uae_u32 readint (TCHAR **c)
 {
     uae_u32 val;
     if (checkvaltype (c, &val))
        return val;
     return readintx (c);
 }
-static uae_u32 readhex (char **c)
+static uae_u32 readhex (TCHAR **c)
 {
     uae_u32 val;
     if (checkvaltype (c, &val))
        return val;
     return readhexx (c);
 }
-static uae_u32 readbin (char **c)
+static uae_u32 readbin (TCHAR **c)
 {
     uae_u32 val;
     if (checkvaltype (c, &val))
@@ -339,27 +339,27 @@ static uae_u32 readbin (char **c)
     return readbinx (c);
 }
 
-static char next_char(char **c)
+static TCHAR next_char(TCHAR **c)
 {
     ignore_ws (c);
     return *(*c)++;
 }
 
-static char peek_next_char(char **c)
+static TCHAR peek_next_char(TCHAR **c)
 {
-    char *pc = *c;
+    TCHAR *pc = *c;
     return pc[1];
 }
 
-static int more_params (char **c)
+static int more_params (TCHAR **c)
 {
     ignore_ws (c);
     return (**c) != 0;
 }
 
-static int next_string (char **c, char *out, int max, int forceupper)
+static int next_string (TCHAR **c, TCHAR *out, int max, int forceupper)
 {
-    char *p = out;
+    TCHAR *p = out;
     int startmarker = 0;
 
     if (**c == '\"') {
@@ -376,26 +376,26 @@ static int next_string (char **c, char *out, int max, int forceupper)
        }
        *p = next_char (c);
        if (forceupper)
-           *p = toupper(*p);
+           *p = _totupper(*p);
        *++p = 0;
        max--;
        if (max <= 1)
            break;
     }
-    return strlen (out);
+    return _tcslen (out);
 }
 
-static void converter (char **c)
+static void converter (TCHAR **c)
 {
     uae_u32 v = readint (c);
-    char s[100];
-    char *p = s;
+    TCHAR s[100];
+    TCHAR *p = s;
     int i;
 
     for (i = 0; i < 32; i++)
        s[i] = (v & (1 << (31 - i))) ? '1' : '0';
     s[i] = 0;
-    console_out_f ("0x%08X = %%%s = %u = %d\n", v, s, v, (uae_s32)v);
+    console_out_f (L"0x%08X = %%%s = %u = %d\n", v, s, v, (uae_s32)v);
 }
 
 int notinrom (void)
@@ -524,26 +524,26 @@ int safe_addr(uaecptr addr, int size)
     return 0;
 }
 
-uaecptr dumpmem2 (uaecptr addr, char *out, int osize)
+uaecptr dumpmem2 (uaecptr addr, TCHAR *out, int osize)
 {
     int i, cols = 8;
     int nonsafe = 0;
 
     if (osize <= (9 + cols * 5 + 1 + 2 * cols))
        return addr;
-    sprintf (out, "%08lX ", addr);
+    _stprintf (out, L"%08lX ", addr);
     for (i = 0; i < cols; i++) {
        uae_u8 b1, b2;
        b1 = b2 = 0;
        if (safe_addr(addr, 2)) {
            b1 = get_byte (addr + 0);
            b2 = get_byte (addr + 1);
-           sprintf (out + 9 + i * 5, "%02X%02X ", b1, b2);
+           _stprintf (out + 9 + i * 5, L"%02X%02X ", b1, b2);
            out[9 + cols * 5 + 1 + i * 2 + 0] = b1 >= 32 && b1 < 127 ? b1 : '.';
            out[9 + cols * 5 + 1 + i * 2 + 1] = b2 >= 32 && b2 < 127 ? b2 : '.';
        } else {
            nonsafe++;
-           strcpy (out + 9 + i * 5, "**** ");
+           _tcscpy (out + 9 + i * 5, L"**** ");
            out[9 + cols * 5 + 1 + i * 2 + 0] = '*';
            out[9 + cols * 5 + 1 + i * 2 + 1] = '*';
        }
@@ -554,18 +554,18 @@ uaecptr dumpmem2 (uaecptr addr, char *out, int osize)
     if (nonsafe == cols) {
        addrbank *ab = &get_mem_bank (addr);
        if (ab->name)
-           memcpy (out + 9 + 4 + 1, ab->name, strlen (ab->name));
+           memcpy (out + 9 + 4 + 1, ab->name, _tcslen (ab->name));
     }
     return addr;
 }
 
 static void dumpmem (uaecptr addr, uaecptr *nxmem, int lines)
 {
-    char line[MAX_LINEWIDTH + 1];
+    TCHAR line[MAX_LINEWIDTH + 1];
     for (;lines--;) {
        addr = dumpmem2 (addr, line, sizeof(line));
-       debug_out ("%s", line);
-       if (!debug_out ("\n"))
+       debug_out (L"%s", line);
+       if (!debug_out (L"\n"))
            break;
     }
     *nxmem = addr;
@@ -613,7 +613,7 @@ static void dump_custom_regs (int aga)
        addr2 = custd[j].adr & 0x1ff;
        v1 = (p1[addr1 + 0] << 8) | p1[addr1 + 1];
        v2 = (p1[addr2 + 0] << 8) | p1[addr2 + 1];
-       console_out_f ("%03X %s\t%04X\t%03X %s\t%04X\n",
+       console_out_f (L"%03X %s\t%04X\t%03X %s\t%04X\n",
            addr1, custd[i].name, v1,
            addr2, custd[j].name, v2);
     }
@@ -629,24 +629,25 @@ static void dump_vectors (uaecptr addr)
 
     while (int_labels[i].name || trap_labels[j].name) {
        if (int_labels[i].name) {
-           console_out_f ("$%08X: %s  \t $%08X\t", int_labels[i].adr + addr,
+           console_out_f (L"$%08X: %s  \t $%08X\t", int_labels[i].adr + addr,
                int_labels[i].name, get_long (int_labels[i].adr + addr));
            i++;
        } else {
-           console_out ("\t\t\t\t");
+           console_out (L"\t\t\t\t");
        }
        if (trap_labels[j].name) {
-           console_out_f ("$%08X: %s  \t $%08X", trap_labels[j].adr + addr,
+           console_out_f (L"$%08X: %s  \t $%08X", trap_labels[j].adr + addr,
               trap_labels[j].name, get_long (trap_labels[j].adr + addr));
            j++;
        }
-       console_out ("\n");
+       console_out (L"\n");
     }
 }
 
 static void disassemble_wait (FILE *file, unsigned long insn)
 {
     int vp, hp, ve, he, bfd, v_mask, h_mask;
+    int doout = 0;
 
     vp = (insn & 0xff000000) >> 24;
     hp = (insn & 0x00fe0000) >> 16;
@@ -658,26 +659,29 @@ static void disassemble_wait (FILE *file, unsigned long insn)
     v_mask = vp & (ve | 0x80);
     h_mask = hp & he;
     if (v_mask > 0) {
-       console_out ("vpos ");
+       doout = 1;
+       console_out (L"vpos ");
        if (ve != 0x7f) {
-           console_out_f ("& 0x%02x ", ve);
+           console_out_f (L"& 0x%02x ", ve);
        }
-       console_out_f (">= 0x%02x", v_mask);
+       console_out_f (L">= 0x%02x", v_mask);
     }
     if (he > 0) {
        if (v_mask > 0) {
-           console_out (" and");
+           console_out (L" and");
        }
-       console_out (" hpos ");
+       console_out (L" hpos ");
        if (he != 0xfe) {
-           console_out_f ("& 0x%02x ", he);
+           console_out_f (L"& 0x%02x ", he);
        }
-       console_out_f (">= 0x%02x", h_mask);
+       console_out_f (L">= 0x%02x", h_mask);
     } else {
-       console_out (", ignore horizontal");
+       if (doout)
+           console_out (L", ");
+       console_out (L", ignore horizontal");
     }
 
-    console_out_f (".\n                        \t; VP %02x, VE %02x; HP %02x, HE %02x; BFD %d\n",
+    console_out_f (L".\n                        \t; VP %02x, VE %02x; HP %02x, HE %02x; BFD %d\n",
             vp, ve, hp, he, bfd);
 }
 
@@ -741,29 +745,29 @@ static void decode_copper_insn (FILE* file, unsigned long insn, unsigned long ad
 {
     uae_u32 insn_type = insn & 0x00010001;
     int hpos, vpos;
-    char here = ' ';
-    char record[] = "          ";
+    TCHAR here = ' ';
+    TCHAR record[] = L"          L";
     if (find_copper_record (addr, &hpos, &vpos)) {
-       sprintf (record, " [%03x %03x]", vpos, hpos);
+       _stprintf (record, L" [%03x %03x]", vpos, hpos);
     }
 
-    if (get_copper_address(-1) >= addr && get_copper_address(-1) <= addr + 3)
+    if (get_copper_address (-1) >= addr && get_copper_address(-1) <= addr + 3)
        here = '*';
 
-    console_out_f ("%c%08lx: %04lx %04lx%s\t; ", here, addr, insn >> 16, insn & 0xFFFF, record);
+    console_out_f (L"%c%08lx: %04lx %04lx%s\t; ", here, addr, insn >> 16, insn & 0xFFFF, record);
 
     switch (insn_type) {
     case 0x00010000: /* WAIT insn */
-       console_out ("Wait for ");
+       console_out (L"Wait for ");
        disassemble_wait (file, insn);
 
        if (insn == 0xfffffffe)
-           console_out ("                           \t; End of Copperlist\n");
+           console_out (L"                           \t; End of Copperlist\n");
 
        break;
 
     case 0x00010001: /* SKIP insn */
-       console_out ("Skip if ");
+       console_out (L"Skip if ");
        disassemble_wait (file, insn);
        break;
 
@@ -778,9 +782,9 @@ static void decode_copper_insn (FILE* file, unsigned long insn, unsigned long ad
                i++;
            }
            if (custd[i].name)
-               console_out_f ("%s := 0x%04lx\n", custd[i].name, insn & 0xffff);
+               console_out_f (L"%s := 0x%04lx\n", custd[i].name, insn & 0xffff);
            else
-               console_out_f ("%04x := 0x%04lx\n", addr, insn & 0xffff);
+               console_out_f (L"%04x := 0x%04lx\n", addr, insn & 0xffff);
        }
        break;
 
@@ -804,7 +808,7 @@ static uaecptr decode_copperlist (FILE* file, uaecptr address, int nolines)
      * values that mean the end of the copperlist */
 }
 
-static int copper_debugger (char **c)
+static int copper_debugger (TCHAR **c)
 {
     static uaecptr nxcopper;
     uae_u32 maddr;
@@ -816,7 +820,7 @@ static int copper_debugger (char **c)
            debug_copper = 0;
        else
            debug_copper = 1;
-       console_out_f ("Copper debugger %s.\n", debug_copper ? "enabled" : "disabled");
+       console_out_f (L"Copper debugger %s.\n", debug_copper ? L"enabled" : L"disabled");
     } else if(**c == 't') {
        debug_copper = 1|2;
        return 1;
@@ -825,7 +829,7 @@ static int copper_debugger (char **c)
        debug_copper = 1|4;
        if (more_params(c)) {
            debug_copper_pc = readhex(c);
-           console_out_f ("Copper breakpoint @0x%08x\n", debug_copper_pc);
+           console_out_f (L"Copper breakpoint @0x%08x\n", debug_copper_pc);
        } else {
            debug_copper &= ~4;
        }
@@ -894,15 +898,15 @@ static void listcheater(int mode, int size)
            b = get_word (ts->addr);
        }
        if (mode)
-           console_out_f ("%08X=%04X ", ts->addr, b);
+           console_out_f (L"%08X=%04X ", ts->addr, b);
        else
-           console_out_f ("%08X ", ts->addr);
+           console_out_f (L"%08X ", ts->addr);
        if ((i % skip) == skip)
-           console_out ("\n");
+           console_out (L"\n");
     }
 }
 
-static void deepcheatsearch (char **c)
+static void deepcheatsearch (TCHAR **c)
 {
     static int first = 1;
     static uae_u8 *memtmp;
@@ -913,9 +917,9 @@ static void deepcheatsearch (char **c)
     static int size;
     static int inconly, deconly, maxdiff;
     int addrcnt, cnt;
-    char v;
+    TCHAR v;
 
-    v = toupper (**c);
+    v = _totupper (**c);
 
     if(!memtmp || v == 'S') {
        maxdiff = 0x10000;
@@ -955,7 +959,7 @@ static void deepcheatsearch (char **c)
                *p1++ = get_byte (i);
            addr = end - 1;
        }
-       console_out ("Deep trainer first pass complete.\n");
+       console_out (L"Deep trainer first pass complete.\n");
        return;
     }
     inconly = deconly = 0;
@@ -1020,7 +1024,7 @@ static void deepcheatsearch (char **c)
        }
     }
 
-    console_out_f ("%d addresses found\n", cnt);
+    console_out_f (L"%d addresses found\n", cnt);
     if (cnt <= MAX_CHEAT_VIEW) {
        clearcheater ();
        cnt = 0;
@@ -1035,15 +1039,15 @@ static void deepcheatsearch (char **c)
            cnt++;
        }
        if (cnt > 0)
-           console_out ("\n");
+           console_out (L"\n");
        listcheater (1, size);
     } else {
-       console_out ("Now continue with 'g' and use 'D' again after you have lost another life\n");
+       console_out (L"Now continue with 'g' and use 'D' again after you have lost another life\n");
     }
 }
 
 /* cheat-search by Toni Wilen (originally by Holger Jakob) */
-static void cheatsearch (char **c)
+static void cheatsearch (TCHAR **c)
 {
     static uae_u8 *vlist;
     static int listsize;
@@ -1060,14 +1064,14 @@ static void cheatsearch (char **c)
        addr = end - 1;
     }
 
-    if (toupper (**c) == 'L') {
+    if (_totupper (**c) == 'L') {
        listcheater (1, size);
        return;
     }
     ignore_ws (c);
     if (!more_params (c)) {
        first = 1;
-       console_out ("search reset\n");
+       console_out (L"Search reset\n");
        xfree (vlist);
        listsize = memsize;
        vlist = xcalloc (listsize >> 3, 1);
@@ -1138,9 +1142,9 @@ static void cheatsearch (char **c)
        }
        listcheater (0, size);
     }
-    console_out_f ("Found %d possible addresses with 0x%X (%u) (%d bytes)\n", count, val, val, size);
+    console_out_f (L"Found %d possible addresses with 0x%X (%u) (%d bytes)\n", count, val, val, size);
     if (count > 0)
-       console_out ("Now continue with 'g' and use 'C' with a different value\n");
+       console_out (L"Now continue with 'g' and use 'C' with a different value\n");
     first = 0;
 }
 
@@ -1251,17 +1255,17 @@ static void illg_debug_do (uaecptr addr, int rwi, int size, uae_u32 val)
            illg_debug_check (ad, rwi, size, val);
        } else if ((mask & 3) == 0) {
            if (rwi & 2)
-               console_out_f ("W: %08X=%02X PC=%08X\n", ad, v, pc);
+               console_out_f (L"W: %08X=%02X PC=%08X\n", ad, v, pc);
            else if (rwi & 1)
-               console_out_f ("R: %08X    PC=%08X\n", ad, pc);
+               console_out_f (L"R: %08X    PC=%08X\n", ad, pc);
            if (illgdebug_break)
                activate_debugger ();
        } else if (!(mask & 1) && (rwi & 1)) {
-           console_out_f ("RO: %08X=%02X PC=%08X\n", ad, v, pc);
+           console_out_f (L"RO: %08X=%02X PC=%08X\n", ad, v, pc);
            if (illgdebug_break)
                activate_debugger ();
        } else if (!(mask & 2) && (rwi & 2)) {
-           console_out_f ("WO: %08X    PC=%08X\n", ad, pc);
+           console_out_f (L"WO: %08X    PC=%08X\n", ad, pc);
            if (illgdebug_break)
                activate_debugger ();
        }
@@ -1284,14 +1288,14 @@ static struct smc_item *smc_table;
 static void smc_free (void)
 {
     if (smc_table)
-       console_out ("SMCD disabled\n");
+       console_out (L"SMCD disabled\n");
     xfree(smc_table);
     smc_mode = 0;
     smc_table = NULL;
 }
 
 static void initialize_memwatch (int mode);
-static void smc_detect_init (char **c)
+static void smc_detect_init (TCHAR **c)
 {
     int v, i;
     
@@ -1313,7 +1317,7 @@ static void smc_detect_init (char **c)
        initialize_memwatch (0);
     if (v)
        smc_mode = 1;
-    console_out_f ("SMCD enabled. Break=%d\n", smc_mode);
+    console_out_f (L"SMCD enabled. Break=%d\n", smc_mode);
 }
 
 #define SMC_MAXHITS 8
@@ -1355,12 +1359,12 @@ static void smc_detector (uaecptr addr, int rwi, int size, uae_u32 *valp)
     }
     if (hitcnt < 100) {
        smc_table[hitaddr].cnt++;
-       console_out_f ("SMC at %08X - %08X (%d) from %08X\n",
+       console_out_f (L"SMC at %08X - %08X (%d) from %08X\n",
            hitaddr, hitaddr + hitcnt, hitcnt, hitpc);
        if (smc_mode)
            activate_debugger ();
        if (smc_table[hitaddr].cnt >= SMC_MAXHITS)
-           console_out_f ("* hit count >= %d, future hits ignored\n", SMC_MAXHITS);
+           console_out_f (L"* hit count >= %d, future hits ignored\n", SMC_MAXHITS);
     }
 }
 
@@ -1716,7 +1720,7 @@ int debug_bankchange (int mode)
     return -1;
 }
 
-void memwatch_dump2 (char *buf, int bufsize, int num)
+void memwatch_dump2 (TCHAR *buf, int bufsize, int num)
 {
     int i;
     struct memwatch_node *mwn;
@@ -1728,42 +1732,42 @@ void memwatch_dump2 (char *buf, int bufsize, int num)
            mwn = &mwnodes[i];
            if (mwn->size == 0)
                continue;
-           buf = buf_out (buf, &bufsize, "%d: %08X - %08X (%d) %c%c%c",
+           buf = buf_out (buf, &bufsize, L"%d: %08X - %08X (%d) %c%c%c",
                i, mwn->addr, mwn->addr + (mwn->size - 1), mwn->size,
                (mwn->rwi & 1) ? 'R' : ' ', (mwn->rwi & 2) ? 'W' : ' ', (mwn->rwi & 4) ? 'I' : ' ');
            if (mwn->frozen)
-               buf = buf_out (buf, &bufsize, "F");
+               buf = buf_out (buf, &bufsize, L"F");
            if (mwn->val_enabled)
-               buf = buf_out (buf, &bufsize, " =%X", mwn->val);
+               buf = buf_out (buf, &bufsize, L" =%X", mwn->val);
            if (mwn->modval_written)
-               buf = buf_out (buf, &bufsize, " =M");
-           buf = buf_out (buf, &bufsize, "\n");
+               buf = buf_out (buf, &bufsize, L" =M");
+           buf = buf_out (buf, &bufsize, L"\n");
        }
     }
 }
 
 static void memwatch_dump (int num)
 {
-    char *buf;
+    TCHAR *buf;
     int multiplier = num < 0 ? MEMWATCH_TOTAL : 1;
 
     buf = malloc (50 * multiplier);
     if (!buf)
        return;
     memwatch_dump2 (buf, 50 * multiplier, num);
-    f_out (stdout, "%s", buf);
+    f_out (stdout, L"%s", buf);
     xfree (buf);
 }
 
-static void memwatch (char **c)
+static void memwatch (TCHAR **c)
 {
     int num;
     struct memwatch_node *mwn;
-    char nc;
+    TCHAR nc;
 
     if (!memwatch_enabled) {
        initialize_memwatch (0);
-       console_out ("Memwatch breakpoints enabled\n");
+       console_out (L"Memwatch breakpoints enabled\n");
     }
 
     ignore_ws (c);
@@ -1774,7 +1778,7 @@ static void memwatch (char **c)
     nc = next_char (c);
     if (nc == '-') {
        deinitialize_memwatch ();
-       console_out ("Memwatch breakpoints disabled\n");
+       console_out (L"Memwatch breakpoints disabled\n");
        return;
     }
     if (nc == 'd') {
@@ -1785,7 +1789,7 @@ static void memwatch (char **c)
                uae_u32 len = 1;
                if (more_params (c))
                    len = readhex (c);
-               console_out_f ("cleared logging addresses %08X - %08X\n", addr, addr + len);
+               console_out_f (L"Cleared logging addresses %08X - %08X\n", addr, addr + len);
                while (len > 0) {
                    addr &= 0xffffff;
                    illgdebug[addr] = 7;
@@ -1794,7 +1798,7 @@ static void memwatch (char **c)
                }
            } else {
                illg_free();
-               console_out ("Illegal memory access logging disabled\n");
+               console_out (L"Illegal memory access logging disabled\n");
            }
        } else {
            illg_init ();
@@ -1802,7 +1806,7 @@ static void memwatch (char **c)
            illgdebug_break = 0;
            if (more_params (c))
                illgdebug_break = 1;
-           console_out_f ("Illegal memory access logging enabled. Break=%d\n", illgdebug_break);
+           console_out_f (L"Illegal memory access logging enabled. Break=%d\n", illgdebug_break);
        }
        return;
     }
@@ -1813,7 +1817,7 @@ static void memwatch (char **c)
     mwn->size = 0;
     ignore_ws (c);
     if (!more_params (c)) {
-       console_out_f ("Memwatch %d removed\n", num);
+       console_out_f (L"Memwatch %d removed\n", num);
        return;
     }
     mwn->addr = readhex (c);
@@ -1829,8 +1833,8 @@ static void memwatch (char **c)
        ignore_ws (c);
        if (more_params (c)) {
            for (;;) {
-               char ncc = peek_next_char(c);
-               char nc = toupper (next_char (c));
+               TCHAR ncc = peek_next_char(c);
+               TCHAR nc = _totupper (next_char (c));
                if (mwn->rwi == 7)
                    mwn->rwi = 0;
                if (nc == 'F')
@@ -1848,7 +1852,7 @@ static void memwatch (char **c)
            }
            ignore_ws (c);
            if (more_params (c)) {
-               if (toupper(**c) == 'M') {
+               if (_totupper(**c) == 'M') {
                    mwn->modval_written = 1;
                } else {
                    mwn->val = readhex (c);
@@ -1862,11 +1866,11 @@ static void memwatch (char **c)
     memwatch_dump (num);
 }
 
-static void writeintomem (char **c)
+static void writeintomem (TCHAR **c)
 {
     uae_u32 addr = 0;
     uae_u32 val = 0;
-    char cc;
+    TCHAR cc;
     int len = 1;
 
     ignore_ws(c);
@@ -1893,7 +1897,7 @@ static void writeintomem (char **c)
        put_byte (addr, val);
        cc = 'B';
     }
-    console_out_f ("Wrote %X (%u) at %08X.%c\n", val, val, addr, cc);
+    console_out_f (L"Wrote %X (%u) at %08X.%c\n", val, val, addr, cc);
 }
 
 static uae_u8 *dump_xlate (uae_u32 addr)
@@ -1907,7 +1911,7 @@ static void memory_map_dump_2 (int log)
 {
     int i, j, max, im;
     addrbank *a1 = mem_banks[0];
-    char txt[256];
+    TCHAR txt[256];
 
     im = currprefs.illegal_mem;
     currprefs.illegal_mem = 0;
@@ -1919,14 +1923,14 @@ static void memory_map_dump_2 (int log)
            a2 = mem_banks[i];
        if (a1 != a2) {
            int k, mirrored, size, size_out;
-           char size_ext;
+           TCHAR size_ext;
            uae_u8 *caddr;
-           char *name;
-           char tmp[MAX_DPATH];
+           TCHAR *name;
+           TCHAR tmp[MAX_DPATH];
 
            name = a1->name;
            if (name == NULL)
-               name = "<none>";
+               name = L"<none>";
 
            k = j;
            caddr = dump_xlate (k << 16);
@@ -1944,22 +1948,22 @@ static void memory_map_dump_2 (int log)
                size_out /= 1024;
                size_ext = 'M';
            }
-           sprintf (txt, "%08X %7d%c/%d = %7d%c %s", j << 16, size_out, size_ext,
+           _stprintf (txt, L"%08X %7d%c/%d = %7d%c %s", j << 16, size_out, size_ext,
                mirrored, mirrored ? size_out / mirrored : size_out, size_ext, name);
 
            tmp[0] = 0;
            if (a1->flags == ABFLAG_ROM && mirrored) {
-               char *p = txt + strlen (txt);
+               TCHAR *p = txt + _tcslen (txt);
                uae_u32 crc = get_crc32 (a1->xlateaddr(j << 16), (size * 1024) / mirrored);
                struct romdata *rd = getromdatabycrc (crc);
-               sprintf(p, " (%08X)", crc);
+               _stprintf (p, L" (%08X)", crc);
                if (rd) {
                    tmp[0] = '=';
                    getromname (rd, tmp + 1);
-                   strcat (tmp,"\n");
+                   _tcscat (tmp, L"\n");
                }
            }
-           strcat (txt,"\n");
+           _tcscat (txt, L"\n");
            if (log)
                write_log (txt);
            else
@@ -1985,31 +1989,34 @@ STATIC_INLINE uaecptr BPTR2APTR (uaecptr addr)
 {
     return addr << 2;
 }
-static char* BSTR2CSTR (uae_u8 *bstr)
+static TCHAR *BSTR2CSTR (uae_u8 *bstr)
 {
+    WCHAR *s;
     char *cstr = xmalloc (bstr[0] + 1);
     if (cstr) {
        memcpy (cstr, bstr + 1, bstr[0]);
        cstr[bstr[0]] = 0;
     }
-    return cstr;
+    s = au (cstr);
+    xfree (cstr);
+    return s;
 }
 
 static void print_task_info (uaecptr node)
 {
     int process = get_byte (node + 8) == 13 ? 1 : 0;
-    console_out_f ("%08X: %08X", node, 0);
-    console_out_f (process ? " PROCESS '%s'" : " TASK    '%s'\n", get_real_address (get_long (node + 10)));
+    console_out_f (L"%08X: %08X", node, 0);
+    console_out_f (process ? L" PROCESS '%s'" : L" TASK    '%s'\n", get_real_address (get_long (node + 10)));
     if (process) {
        uaecptr cli = BPTR2APTR (get_long (node + 172));
        int tasknum = get_long (node + 140);
        if (cli && tasknum) {
            uae_u8 *command_bstr = get_real_address (BPTR2APTR (get_long (cli + 16)));
-           char *command = BSTR2CSTR (command_bstr);
-           console_out_f (" [%d, '%s']\n", tasknum, command);
+           TCHAR *command = BSTR2CSTR (command_bstr);
+           console_out_f (L" [%d, '%s']\n", tasknum, command);
            xfree (command);
        } else {
-           console_out ("\n");
+           console_out (L"\n");
        }
     }
 }
@@ -2020,18 +2027,18 @@ static void show_exec_tasks (void)
     uaecptr taskready = get_long (execbase + 406);
     uaecptr taskwait = get_long (execbase + 420);
     uaecptr node, end;
-    console_out_f ("execbase at 0x%08X\n", (unsigned long) execbase);
-    console_out ("Current:\n");
+    console_out_f (L"Execbase at 0x%08X\n", (unsigned long) execbase);
+    console_out (L"Current:\n");
     node = get_long (execbase + 276);
     print_task_info (node);
-    console_out_f ("Ready:\n");
+    console_out_f (L"Ready:\n");
     node = get_long (taskready);
     end = get_long (taskready + 4);
     while (node) {
        print_task_info (node);
        node = get_long (node);
     }
-    console_out ("Waiting:\n");
+    console_out (L"Waiting:\n");
     node = get_long (taskwait);
     end = get_long (taskwait + 4);
     while (node) {
@@ -2047,13 +2054,13 @@ static struct regstruct trace_prev_regs;
 #endif
 static uaecptr nextpc;
 
-int instruction_breakpoint (char **c)
+int instruction_breakpoint (TCHAR **c)
 {
     struct breakpoint_node *bpn;
     int i;
 
     if (more_params (c)) {
-       char nc = toupper ((*c)[0]);
+       TCHAR nc = _totupper ((*c)[0]);
        if (nc == 'S') {
            next_char (c);
            sr_bpvalue = sr_bpmask = 0;
@@ -2063,7 +2070,7 @@ int instruction_breakpoint (char **c)
                if (more_params (c))
                    sr_bpmask = readhex (c);
            }
-           console_out_f ("SR breakpoint, value=%04X, mask=%04X\n", sr_bpvalue, sr_bpmask);
+           console_out_f (L"SR breakpoint, value=%04X, mask=%04X\n", sr_bpvalue, sr_bpmask);
            return 0;
        } else if (nc == 'I') {
            next_char (c);
@@ -2077,7 +2084,7 @@ int instruction_breakpoint (char **c)
        } else if (nc == 'D' && (*c)[1] == 0) {
            for (i = 0; i < BREAKPOINT_TOTAL; i++)
                bpnodes[i].enabled = 0;
-           console_out ("All breakpoints removed\n");
+           console_out (L"All breakpoints removed\n");
            return 0;
        } else if (nc == 'L') {
            int got = 0;
@@ -2085,13 +2092,13 @@ int instruction_breakpoint (char **c)
                bpn = &bpnodes[i];
                if (!bpn->enabled)
                    continue;
-               console_out_f ("%8X ", bpn->addr);
+               console_out_f (L"%8X ", bpn->addr);
                got = 1;
            }
            if (!got)
-               console_out ("No breakpoints\n");
+               console_out (L"No breakpoints\n");
            else
-               console_out ("\n");
+               console_out (L"\n");
            return 0;
        }
        skipaddr_doskip = 1;
@@ -2103,7 +2110,7 @@ int instruction_breakpoint (char **c)
                bpn = &bpnodes[i];
                if (bpn->enabled && bpn->addr == skipaddr_start) {
                    bpn->enabled = 0;
-                   console_out ("Breakpoint removed\n");
+                   console_out (L"Breakpoint removed\n");
                    skipaddr_start = 0xffffffff;
                    skipaddr_doskip = 0;
                    return 0;
@@ -2115,7 +2122,7 @@ int instruction_breakpoint (char **c)
                    continue;
                bpn->addr = skipaddr_start;
                bpn->enabled = 1;
-               console_out ("Breakpoint added\n");
+               console_out (L"Breakpoint added\n");
                skipaddr_start = 0xffffffff;
                skipaddr_doskip = 0;
                break;
@@ -2136,7 +2143,7 @@ int instruction_breakpoint (char **c)
     return 1;
 }
 
-static int process_breakpoint(char **c)
+static int process_breakpoint(TCHAR **c)
 {
     processptr = 0;
     xfree (processname);
@@ -2144,8 +2151,9 @@ static int process_breakpoint(char **c)
     if (!more_params (c))
        return 0;
     if (**c == '\"') {
-       processname = xmalloc (200);
-       next_string (c, processname, 200, 0);
+       TCHAR pn[200];
+       next_string (c, pn, 200, 0);
+       processname = ua (pn);
     } else {
        processptr = readhex (c);
     }
@@ -2155,11 +2163,11 @@ static int process_breakpoint(char **c)
     return 1;
 }
 
-static void savemem (char **cc)
+static void savemem (TCHAR **cc)
 {
     uae_u8 b;
     uae_u32 src, src2, len, len2;
-    char *name;
+    TCHAR *name;
     FILE *fp;
 
     if (!more_params (cc))
@@ -2179,9 +2187,9 @@ static void savemem (char **cc)
     if (!more_params (cc))
        goto S_argh;
     len2 = len = readhex (cc);
-    fp = fopen (name, "wb");
+    fp = _tfopen (name, L"wb");
     if (fp == NULL) {
-       console_out_f ("Couldn't open file '%s'\n", name);
+       console_out_f (L"Couldn't open file '%s'\n", name);
        return;
     }
     while (len > 0) {
@@ -2189,25 +2197,25 @@ static void savemem (char **cc)
        src++;
        len--;
        if (fwrite (&b, 1, 1, fp) != 1) {
-           console_out ("Error writing file\n");
+           console_out (L"Error writing file\n");
            break;
        }
     }
     fclose (fp);
     if (len == 0)
-       console_out_f ("Wrote %08X - %08X (%d bytes) to '%s'\n",
+       console_out_f (L"Wrote %08X - %08X (%d bytes) to '%s'\n",
            src2, src2 + len2, len2, name);
     return;
 S_argh:
-    console_out ("S-command needs more arguments!\n");
+    console_out (L"S-command needs more arguments!\n");
 }
 
-static void searchmem (char **cc)
+static void searchmem (TCHAR **cc)
 {
     int i, sslen, got, val, stringmode;
     uae_u8 ss[256];
     uae_u32 addr, endaddr;
-    char nc;
+    TCHAR nc;
 
     got = 0;
     sslen = 0;
@@ -2226,7 +2234,7 @@ static void searchmem (char **cc)
        for (;;) {
            if (**cc == 32 || **cc == 0)
                break;
-           nc = toupper (next_char (cc));
+           nc = _totupper (next_char (cc));
            if (isspace (nc))
                break;
            if (isdigit(nc))
@@ -2238,7 +2246,7 @@ static void searchmem (char **cc)
            val *= 16;
            if (**cc == 32 || **cc == 0)
                break;
-           nc = toupper (next_char (cc));
+           nc = _totupper (next_char (cc));
            if (isspace (nc))
                break;
            if (isdigit(nc))
@@ -2260,7 +2268,7 @@ static void searchmem (char **cc)
        if (more_params (cc))
            endaddr = readhex (cc);
     }
-    console_out_f ("Searching from %08X to %08X..\n", addr, endaddr);
+    console_out_f (L"Searching from %08X to %08X..\n", addr, endaddr);
     while ((addr = nextaddr (addr, NULL)) != 0xffffffff) {
        if (addr == endaddr)
            break;
@@ -2276,21 +2284,21 @@ static void searchmem (char **cc)
        }
        if (i == sslen) {
            got++;
-           console_out_f (" %08X", addr);
+           console_out_f (L" %08X", addr);
            if (got > 100) {
-               console_out ("\nMore than 100 results, aborting..");
+               console_out (L"\nMore than 100 results, aborting..");
                break;
            }
        }
     }
     if (!got)
-       console_out ("nothing found");
-    console_out ("\n");
+       console_out (L"nothing found");
+    console_out (L"\n");
 }
 
-static int staterecorder (char **cc)
+static int staterecorder (TCHAR **cc)
 {
-    char nc;
+    TCHAR nc;
 
     if (!more_params (cc)) {
        if (savestate_dorewind (1)) {
@@ -2308,26 +2316,26 @@ static int staterecorder (char **cc)
 }
 
 static int debugtest_modes[DEBUGTEST_MAX];
-static const char *debugtest_names[] = {
-    "Blitter", "Keyboard", "Floppy"
+static const TCHAR *debugtest_names[] = {
+    L"Blitter", L"Keyboard", L"Floppy"
 };
 
-void debugtest (enum debugtest_item di, const char *format, ...)
+void debugtest (enum debugtest_item di, const TCHAR *format, ...)
 {
     va_list parms;
-    char buffer[1000];
+    TCHAR buffer[1000];
 
     if (!debugtest_modes[di])
        return;
     va_start (parms, format);
-    _vsnprintf (buffer, 1000 - 1, format, parms);
+    _vsntprintf (buffer, 1000 - 1, format, parms);
     va_end (parms);
-    write_log ("%s PC=%08X: %s\n", debugtest_names[di], M68K_GETPC, buffer);
+    write_log (L"%s PC=%08X: %s\n", debugtest_names[di], M68K_GETPC, buffer);
     if (debugtest_modes[di] == 2)
        activate_debugger ();
 }
 
-static void debugtest_set (char **inptr)
+static void debugtest_set (TCHAR **inptr)
 {
     int i, val, val2;
     ignore_ws (inptr);
@@ -2336,7 +2344,7 @@ static void debugtest_set (char **inptr)
     if (!more_params (inptr)) {
        for (i = 0; i < DEBUGTEST_MAX; i++)
            debugtest_modes[i] = 0;
-       console_out ("all debugtests disabled\n");
+       console_out (L"All debugtests disabled\n");
        return;
     }
     val = readint (inptr);
@@ -2348,7 +2356,7 @@ static void debugtest_set (char **inptr)
     if (val < 0) {
        for (i = 0; i < DEBUGTEST_MAX; i++)
            debugtest_modes[i] = val2;
-       console_out ("all debugtests enabled\n");
+       console_out (L"All debugtests enabled\n");
        return;
     }
     if (val >= 0 && val < DEBUGTEST_MAX) {
@@ -2356,12 +2364,12 @@ static void debugtest_set (char **inptr)
            debugtest_modes[val] = 0;
        else
            debugtest_modes[val] = val2;
-       console_out_f ("debugtest '%s': %s. break = %s\n",
-           debugtest_names[val], debugtest_modes[val] ? "on" :"off", val2 == 2 ? "on" : "off");
+       console_out_f (L"Debugtest '%s': %s. break = %s\n",
+           debugtest_names[val], debugtest_modes[val] ? L"on" :L"off", val2 == 2 ? L"on" : L"off");
     }
 }
 
-static void debug_sprite (char **inptr)
+static void debug_sprite (TCHAR **inptr)
 {
     uaecptr saddr, addr, addr2;
     int xpos, xpos_ecs;
@@ -2372,7 +2380,7 @@ static void debug_sprite (char **inptr)
     int size = 1, width;
     int ecs, sh10;
     int y, i;
-    char tmp[80];
+    TCHAR tmp[80];
     int max = 2;
 
     addr2 = 0;
@@ -2396,10 +2404,10 @@ static void debug_sprite (char **inptr)
        width = size * 16;
        w1 = get_word (addr);
        w2 = get_word (addr + size * 2);
-       console_out_f ("    %06X ", addr);
+       console_out_f (L"    %06X ", addr);
        for (i = 0; i < size * 2; i++)
-           console_out_f ("%04X ", get_word (addr + i * 2));
-       console_out_f ("\n");
+           console_out_f (L"%04X ", get_word (addr + i * 2));
+       console_out_f (L"\n");
 
        ypos = w1 >> 8;
        xpos = w1 & 255;
@@ -2482,13 +2490,13 @@ static void debug_sprite (char **inptr)
                }
            }
            tmp[width] = 0;
-           console_out_f ("%3d %06X %s\n", y, addr, tmp);
+           console_out_f (L"%3d %06X %s\n", y, addr, tmp);
        }
 
-       console_out_f ("Sprite address %08X, width = %d\n", saddr, size * 16);
-       console_out_f ("OCS: StartX=%d StartY=%d EndY=%d\n", xpos, ypos, ypose);
-       console_out_f ("ECS: StartX=%d (%d.%d) StartY=%d EndY=%d%s\n", xpos_ecs, xpos_ecs / 4, xpos_ecs & 3, ypos_ecs, ypose_ecs, ecs ? " (*)" : "");
-       console_out_f ("Attach: %d. AGA SSCAN/SH10 bit: %d\n", attach, sh10);
+       console_out_f (L"Sprite address %08X, width = %d\n", saddr, size * 16);
+       console_out_f (L"OCS: StartX=%d StartY=%d EndY=%d\n", xpos, ypos, ypose);
+       console_out_f (L"ECS: StartX=%d (%d.%d) StartY=%d EndY=%d%s\n", xpos_ecs, xpos_ecs / 4, xpos_ecs & 3, ypos_ecs, ypose_ecs, ecs ? " (*)" : "");
+       console_out_f (L"Attach: %d. AGA SSCAN/SH10 bit: %d\n", attach, sh10);
 
         addr += size * 4;
        if (get_word (addr) == 0 && get_word (addr + size * 4) == 0)
@@ -2500,16 +2508,16 @@ static void debug_sprite (char **inptr)
 
 }
 
-static void disk_debug (char **inptr)
+static void disk_debug (TCHAR **inptr)
 {
-    char parm[10];
+    TCHAR parm[10];
     int i;
 
     if (**inptr == 'd') {
        (*inptr)++;
        ignore_ws (inptr);
        disk_debug_logging = readint (inptr);
-       console_out_f ("disk logging level %d\n", disk_debug_logging);
+       console_out_f (L"Disk logging level %d\n", disk_debug_logging);
        return;
     }
     disk_debug_mode = 0;
@@ -2517,7 +2525,7 @@ static void disk_debug (char **inptr)
     ignore_ws (inptr);
     if (!next_string (inptr, parm, sizeof (parm), 1))
        goto end;
-    for (i = 0; i < strlen(parm); i++) {
+    for (i = 0; i < _tcslen(parm); i++) {
        if (parm[i] == 'R')
            disk_debug_mode |= DISK_DEBUG_DMA_READ;
        if (parm[i] == 'W')
@@ -2532,14 +2540,14 @@ static void disk_debug (char **inptr)
     if (disk_debug_logging == 0)
        disk_debug_logging = 1;
 end:
-    console_out_f ("disk breakpoint mode %c%c%c track %d\n",
+    console_out_f (L"Disk breakpoint mode %c%c%c track %d\n",
        disk_debug_mode & DISK_DEBUG_DMA_READ ? 'R' : '-',
        disk_debug_mode & DISK_DEBUG_DMA_WRITE ? 'W' : '-',
        disk_debug_mode & DISK_DEBUG_PIO ? 'P' : '-',
        disk_debug_track);
 }
 
-static void find_ea (char **inptr)
+static void find_ea (TCHAR **inptr)
 {
     uae_u32 ea, sea, dea;
     uaecptr addr, end;
@@ -2553,7 +2561,7 @@ static void find_ea (char **inptr)
        if (more_params(inptr))
            end = readhex (inptr);
     }
-    console_out_f ("Searching from %08X to %08X\n", addr, end);
+    console_out_f (L"Searching from %08X to %08X\n", addr, end);
     while((addr = nextaddr(addr, &end)) != 0xffffffff) {
        if ((addr & 1) == 0 && addr + 6 <= end) {
            sea = 0xffffffff;
@@ -2563,7 +2571,7 @@ static void find_ea (char **inptr)
                m68k_disasm (stdout, addr, NULL, 1);
                hits++;
                if (hits > 100) {
-                   write_log ("Too many hits. End addr = %08X\n", addr);
+                   write_log (L"Too many hits. End addr = %08X\n", addr);
                    break;
                }
            }
@@ -2571,19 +2579,19 @@ static void find_ea (char **inptr)
     }
 }
 
-static void m68k_modify (char **inptr)
+static void m68k_modify (TCHAR **inptr)
 {
     uae_u32 v;
-    char parm[10];
-    char c1, c2;
+    TCHAR parm[10];
+    TCHAR c1, c2;
     int i;
 
     if (!next_string (inptr, parm, sizeof (parm), 1))
        return;
-    c1 = toupper (parm[0]);
+    c1 = _totupper (parm[0]);
     c2 = 99;
     if (c1 == 'A' || c1 == 'D' || c1 == 'P') {
-       c2 = toupper (parm[1]);
+       c2 = _totupper (parm[1]);
        if (isdigit (c2))
            c2 -= '0';
        else
@@ -2598,22 +2606,22 @@ static void m68k_modify (char **inptr)
        regs.irc = v;
     else if (c1 == 'P' && c2 == 1)
        regs.ir = v;
-    else if (!strcmp (parm, "SR")) {
+    else if (!_tcscmp (parm, L"SR")) {
        regs.sr = v;
        MakeFromSR (&regs);
-    } else if (!strcmp (parm, "CCR")) {
+    } else if (!_tcscmp (parm, L"CCR")) {
        regs.sr = (regs.sr & ~31) | (v & 31);
        MakeFromSR (&regs);
-    } else if (!strcmp(parm, "USP")) {
+    } else if (!_tcscmp (parm, L"USP")) {
        regs.usp = v;
-    } else if (!strcmp(parm, "ISP")) {
+    } else if (!_tcscmp (parm, L"ISP")) {
        regs.isp = v;
-    } else if (!strcmp (parm, "PC")) {
+    } else if (!_tcscmp (parm, L"PC")) {
        m68k_setpc (&regs, v);
        fill_prefetch_slow (&regs);
     } else {
        for (i = 0; m2cregs[i].regname; i++) {
-           if (!strcmp (parm, m2cregs[i].regname))
+           if (!_tcscmp (parm, m2cregs[i].regname))
                val_move2c2 (m2cregs[i].regno, v);
        }
     }
@@ -2621,7 +2629,7 @@ static void m68k_modify (char **inptr)
 
 static void debug_1 (void)
 {
-    char input[MAX_LINEWIDTH];
+    TCHAR input[MAX_LINEWIDTH];
     uaecptr nxdis, nxmem, addr;
 
     m68k_dumpstate (stdout, &nextpc);
@@ -2629,13 +2637,13 @@ static void debug_1 (void)
     debugger_active = 1;
 
     for (;;) {
-       char cmd, *inptr;
+       TCHAR cmd, *inptr;
        int v;
 
        if (!debugger_active)
            return;
        update_debug_info ();
-       console_out (">");
+       console_out (L">");
        console_flush ();
        debug_linecounter = 0;
        v = console_get (input, MAX_LINEWIDTH);
@@ -2698,7 +2706,7 @@ static void debug_1 (void)
                inputdevice_logging = 1 | 2;
                if (more_params (&inptr))
                    inputdevice_logging = readint(&inptr);
-               console_out_f ("input logging level %d\n", inputdevice_logging);
+               console_out_f (L"Input logging level %d\n", inputdevice_logging);
            } else if (*inptr == 'm') {
                memory_map_dump_2 (0);
            } else if (*inptr == 't') {
@@ -2770,7 +2778,7 @@ static void debug_1 (void)
            return;
 
        case 'x':
-           if (toupper(inptr[0]) == 'X') {
+           if (_totupper(inptr[0]) == 'X') {
                debugger_change(-1);
            } else {
                deactivate_debugger();
@@ -2831,12 +2839,12 @@ static void debug_1 (void)
                    case 'a':
                    if (more_params (&inptr))
                        audio_channel_mask = readhex (&inptr);
-                   console_out_f ("Audio mask = %02X\n", audio_channel_mask);
+                   console_out_f (L"Audio mask = %02X\n", audio_channel_mask);
                    break;
                    case 's':
                    if (more_params (&inptr))
                        debug_sprite_mask = readhex (&inptr);
-                   console_out_f ("sprite mask: %02X\n", debug_sprite_mask);
+                   console_out_f (L"Sprite mask: %02X\n", debug_sprite_mask);
                    break;
                    case 'b':
                    if (more_params (&inptr)) {
@@ -2845,7 +2853,7 @@ static void debug_1 (void)
                            debug_bpl_mask_one = readhex (&inptr) & 0xff;
                        notice_screen_contents_lost ();
                    }
-                   console_out_f ("bitplane mask: %02X (%02X)\n", debug_bpl_mask, debug_bpl_mask_one);
+                   console_out_f (L"Bitplane mask: %02X (%02X)\n", debug_bpl_mask, debug_bpl_mask_one);
                    break;
                }
            }
@@ -2893,7 +2901,7 @@ static void debug_1 (void)
            } else {
                int i;
                for (i = 0; i < 8; i++)
-                   console_out_f ("Plane %d offset %d\n", i, bpl_off[i]);
+                   console_out_f (L"Plane %d offset %d\n", i, bpl_off[i]);
            }
            break;
        case 'b':
@@ -2968,7 +2976,7 @@ void debug (void)
                    continue;
                if (bpnodes[i].addr == pc) {
                    bp = 1;
-                   console_out_f ("Breakpoint at %08X\n", pc);
+                   console_out_f (L"Breakpoint at %08X\n", pc);
                    break;
                }
            }
@@ -2985,7 +2993,7 @@ void debug (void)
                        uaecptr cli = BPTR2APTR(get_long (activetask + 172));
                        uaecptr seglist = 0;
 
-                       uae_u8 *command = NULL;
+                       uae_char *command = NULL;
                        if (cli) {
                            if (processname)
                                command = get_real_address (BPTR2APTR(get_long (cli + 16)));
@@ -3024,7 +3032,7 @@ void debug (void)
            if (sr_bpmask || sr_bpvalue) {
                MakeSR (&regs);
                if ((regs.sr & sr_bpmask) == sr_bpvalue) {
-                   console_out ("SR breakpoint\n");
+                   console_out (L"SR breakpoint\n");
                    bp = 1;
                }
            }
@@ -3034,7 +3042,7 @@ void debug (void)
            }
        }
     } else {
-       console_out_f ("Memwatch %d: break at %08X.%c %c%c%c %08X PC=%08X\n", memwatch_triggered - 1, mwhit.addr,
+       console_out_f (L"Memwatch %d: break at %08X.%c %c%c%c %08X PC=%08X\n", memwatch_triggered - 1, mwhit.addr,
            mwhit.size == 1 ? 'B' : (mwhit.size == 2 ? 'W' : 'L'),
            (mwhit.rwi & 1) ? 'R' : ' ', (mwhit.rwi & 2) ? 'W' : ' ', (mwhit.rwi & 4) ? 'I' : ' ',
            mwhit.val, mwhit.pc);
@@ -3087,11 +3095,11 @@ void debug (void)
     inputdevice_acquire (TRUE);
 }
 
-const char *debuginfo (int mode)
+const TCHAR *debuginfo (int mode)
 {
-    static char txt[100];
+    static TCHAR txt[100];
     uae_u32 pc = M68K_GETPC;
-    sprintf (txt, "PC=%08X INS=%04X %04X %04X",
+    _stprintf (txt, L"PC=%08X INS=%04X %04X %04X",
        pc, get_word (pc), get_word (pc + 2), get_word (pc + 4));
     return txt;
 }
@@ -3197,7 +3205,7 @@ static void mmu_do_hit_pre (struct mmudata *md, uaecptr addr, int size, int rwi,
     mmur = regs;
     pc = m68k_getpc (&regs);
     if (mmu_logging)
-       console_out_f ("MMU: hit %08X SZ=%d RW=%d V=%08X PC=%08X\n", addr, size, rwi, v, pc);
+       console_out_f (L"MMU: hit %08X SZ=%d RW=%d V=%08X PC=%08X\n", addr, size, rwi, v, pc);
 
     p = mmu_regs;
     put_long (p, 0); p += 4;
@@ -3260,7 +3268,7 @@ static int mmu_hit (uaecptr addr, int size, int rwi, uae_u32 *v)
                    if (maddr == addr) /* infinite mmu hit loop? no thanks.. */
                        return 1;
                    if (mmu_logging)
-                       console_out_f ("MMU: remap %08X -> %08X SZ=%d RW=%d\n", addr, maddr, size, rwi);
+                       console_out_f (L"MMU: remap %08X -> %08X SZ=%d RW=%d\n", addr, maddr, size, rwi);
                    if ((rwi & 2)) {
                        switch (size)
                        {
@@ -3362,7 +3370,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
     if (currprefs.cachesize) {
        wasjit = currprefs.cachesize;
        changed_prefs.cachesize = 0;
-       console_out ("MMU: JIT disabled\n");
+       console_out (L"MMU: JIT disabled\n");
        check_prefs_changed_comp ();
     }
 
@@ -3370,7 +3378,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
        if (mmu_enabled) {
            mmu_free ();
            deinitialize_memwatch ();
-           console_out ("MMU: disabled\n");
+           console_out (L"MMU: disabled\n");
            changed_prefs.cachesize = wasjit;
        }
        mmu_logging = 0;
@@ -3386,7 +3394,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
     p = parm;
     mmu_struct = p;
     if (get_long (p) != 1) {
-       console_out_f ("MMU: version mismatch %d <> %d\n", get_long (p), 1);
+       console_out_f (L"MMU: version mismatch %d <> %d\n", get_long (p), 1);
        return 0;
     }
     p += 4;
@@ -3408,7 +3416,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
            if (mn->mmubank->p_addr == parm2) {
                getmmubank(mn->mmubank, parm2);
                if (mmu_logging)
-                   console_out_f ("MMU: bank update %08X: %08X - %08X %08X\n",
+                   console_out_f (L"MMU: bank update %08X: %08X - %08X %08X\n",
                        mn->mmubank->flags, mn->mmubank->addr, mn->mmubank->len + mn->mmubank->addr,
                        mn->mmubank->remap);
            }
@@ -3446,7 +3454,7 @@ int mmu_init(int mode, uaecptr parm, uaecptr parm2)
     }
 
     initialize_memwatch (1);
-    console_out_f ("MMU: enabled, %d banks, CB=%08X S=%08X BNK=%08X SF=%08X, %d*%d\n",
+    console_out_f (L"MMU: enabled, %d banks, CB=%08X S=%08X BNK=%08X SF=%08X, %d*%d\n",
        size - 1, mmu_callback, parm, banks, mmu_regs, mmu_slots, 1 << MMU_PAGE_SHIFT);
     set_special (&regs, SPCFLAG_BRK);
     return 1;
diff --git a/disk.c b/disk.c
index a43670294b8957f79ecb8ec9d1dc2e362e0c2b30..7a3c5ccdc4dd0d9e012136b38d6f2288fafbb52b 100644 (file)
--- a/disk.c
+++ b/disk.c
@@ -171,7 +171,7 @@ typedef struct {
     int drive_id_scnt; /* drive id shift counter */
     int idbit;
     unsigned long drive_id; /* drive id to be reported */
-    char newname[256]; /* storage space for new filename during eject delay */
+    TCHAR newname[256]; /* storage space for new filename during eject delay */
     uae_u32 crc32;
 #ifdef FDI2RAW
     FDI *fdi;
@@ -194,7 +194,7 @@ int disk_debug_track = -1;
 
 static uae_u16 bigmfmbufw[0x4000 * DDHDMULT];
 static drive floppy[MAX_FLOPPY_DRIVES];
-static char dfxhistory[MAX_PREVIOUS_FLOPPIES][MAX_DPATH];
+static TCHAR dfxhistory[MAX_PREVIOUS_FLOPPIES][MAX_DPATH];
 
 static uae_u8 exeheader[]={0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00};
 static uae_u8 bootblock[]={
@@ -246,19 +246,20 @@ static void disk_date (uae_u8 *p)
     time_t t;
     struct tm *today;
     int year, days, minutes, ticks;
-    char tmp[10];
+    TCHAR tmp[10];
+
     time (&t);
     today = localtime( &t );
-    strftime (tmp, sizeof (tmp), "%Y", today);
-    year = atol (tmp);
-    strftime (tmp, sizeof (tmp), "%j", today);
-    days = atol (tmp) - 1;
-    strftime (tmp, sizeof (tmp), "%H", today);
-    minutes = atol (tmp) * 60;
-    strftime (tmp, sizeof (tmp), "%M", today);
-    minutes += atol (tmp);
-    strftime (tmp, sizeof (tmp), "%S", today);
-    ticks = atol (tmp) * 50;
+    _tcsftime (tmp, sizeof (tmp), L"%Y", today);
+    year = _tstoi (tmp);
+    _tcsftime (tmp, sizeof (tmp), L"%j", today);
+    days = _tstoi (tmp) - 1;
+    _tcsftime (tmp, sizeof (tmp), L"%H", today);
+    minutes = _tstoi (tmp) * 60;
+    _tcsftime (tmp, sizeof (tmp), L"%M", today);
+    minutes += _tstoi (tmp);
+    _tcsftime (tmp, sizeof (tmp), L"%S", today);
+    ticks = _tstoi (tmp) * 50;
     while (year > 1978) {
        if ( !(year % 100) ? !(year % 400) : !(year % 4) ) days++;
        days += 365;
@@ -313,7 +314,7 @@ static void pl (uae_u8 *sector, int offset, uae_u32 v)
     sector[offset + 3] = v >> 0;
 }
 
-static int createdirheaderblock (uae_u8 *sector, int parent, char *filename, uae_u8 *bitmap)
+static int createdirheaderblock (uae_u8 *sector, int parent, const char *filename, uae_u8 *bitmap)
 {
     int block = getblock (bitmap);
 
@@ -328,7 +329,7 @@ static int createdirheaderblock (uae_u8 *sector, int parent, char *filename, uae
     return block;
 }
 
-static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, char *filename, struct zfile *src, uae_u8 *bitmap)
+static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, const char *filename, struct zfile *src, uae_u8 *bitmap)
 {
     uae_u8 sector2[FS_FLOPPY_BLOCKSIZE];
     uae_u8 sector3[FS_FLOPPY_BLOCKSIZE];
@@ -431,6 +432,7 @@ static int createimagefromexe (struct zfile *src, struct zfile *dst)
     int totalblocks;
     int fblock1, dblock1;
     char *fname1 = "runme.exe";
+    TCHAR *fname1b = L"runme.adf";
     char *fname2 = "startup-sequence";
     char *dirname1 = "s";
     struct zfile *ss;
@@ -451,7 +453,7 @@ static int createimagefromexe (struct zfile *src, struct zfile *dst)
     bitmap[1] = 1;
 
     dblock1 = createdirheaderblock (sector2, 880, dirname1, bitmap);
-    ss = zfile_fopen_empty (fname1, strlen(fname1));
+    ss = zfile_fopen_empty (fname1b, strlen (fname1));
     zfile_fwrite (fname1, strlen(fname1), 1, ss);
     fblock1 = createfileheaderblock (dst, sector1,  dblock1, fname2, ss, bitmap);
     zfile_fclose (ss);
@@ -493,16 +495,16 @@ static int get_floppy_speed2 (drive *drv)
     return m;
 }
 
-static char *drive_id_name(drive *drv)
+static TCHAR *drive_id_name(drive *drv)
 {
     switch(drv->drive_id)
     {
-    case DRIVE_ID_35HD : return "3.5HD";
-    case DRIVE_ID_525SD: return "5.25SD";
-    case DRIVE_ID_35DD : return "3.5DD";
-    case DRIVE_ID_NONE : return "NONE";
+    case DRIVE_ID_35HD : return L"3.5HD";
+    case DRIVE_ID_525SD: return L"5.25SD";
+    case DRIVE_ID_35DD : return L"3.5DD";
+    case DRIVE_ID_NONE : return L"NONE";
     }
-    return "UNKNOWN";
+    return L"UNKNOWN";
 }
 
 /* Simulate exact behaviour of an A3000T 3.5 HD disk drive.
@@ -539,7 +541,7 @@ static void drive_settype_id (drive *drv)
        break;
     }
 #ifdef DEBUG_DRIVE_ID
-    write_log ("drive_settype_id: DF%d: set to %s\n", drv-floppy, drive_id_name(drv));
+    write_log (L"drive_settype_id: DF%d: set to %s\n", drv-floppy, drive_id_name(drv));
 #endif
 }
 
@@ -566,7 +568,7 @@ static void drive_image_free (drive *drv)
     drv->writediskfile = 0;
 }
 
-static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char *fname);
+static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR *fname);
 
 static void reset_drive_gui(int i)
 {
@@ -589,7 +591,7 @@ static void setamax(void)
        for (j = 0; j < MAX_FLOPPY_DRIVES; j++) {
            if ((1 << j) & disabled) {
                floppy[j].amax = 1;
-               write_log ("AMAX: drive %d\n", j);
+               write_log (L"AMAX: drive %d\n", j);
                return;
            }
        }
@@ -620,7 +622,7 @@ static void reset_drive(int i)
     drv->buffered_side = -1;
     gui_led (i + 1, 0);
     drive_settype_id (drv);
-    strcpy (currprefs.df[i], changed_prefs.df[i]);
+    _tcscpy (currprefs.df[i], changed_prefs.df[i]);
     drv->newname[0] = 0;
     if (!drive_insert (drv, &currprefs, i, currprefs.df[i]))
        disk_eject (i);
@@ -638,7 +640,7 @@ static void update_drive_gui (int num)
        && drv->crc32 == gui_data.crc32[num]
        && writ == gui_data.drive_writing[num])
        return;
-    strcpy (gui_data.df[num], currprefs.df[num]);
+    _tcscpy (gui_data.df[num], currprefs.df[num]);
     gui_data.crc32[num] = drv->crc32;
     gui_data.drive_motor[num] = drv->state;
     gui_data.drive_track[num] = drv->cyl;
@@ -649,19 +651,19 @@ static void update_drive_gui (int num)
 
 static void drive_fill_bigbuf (drive * drv,int);
 
-struct zfile *DISK_validate_filename (const char *fname, int leave_open, int *wrprot, uae_u32 *crc32)
+struct zfile *DISK_validate_filename (const TCHAR *fname, int leave_open, int *wrprot, uae_u32 *crc32)
 {
     if (crc32)
        *crc32 = 0;
     if (leave_open) {
-       struct zfile *f = zfile_fopen (fname, "r+b");
+       struct zfile *f = zfile_fopen (fname, L"r+b");
        if (f) {
            if (wrprot)
                *wrprot = 0;
        } else {
            if (wrprot)
                *wrprot = 1;
-           f = zfile_fopen (fname, "rb");
+           f = zfile_fopen (fname, L"rb");
        }
        if (f && crc32)
            *crc32 = zfile_crc32 (f);
@@ -671,7 +673,7 @@ struct zfile *DISK_validate_filename (const char *fname, int leave_open, int *wr
            if (wrprot)
                *wrprot = 0;
            if (crc32) {
-               struct zfile *f = zfile_fopen (fname, "rb");
+               struct zfile *f = zfile_fopen (fname, L"rb");
                if (f)
                    *crc32 = zfile_crc32 (f);
                zfile_fclose (f);
@@ -734,15 +736,15 @@ static int read_header_ext2 (struct zfile *diskfile, trackid *trackdata, int *nu
     return 1;
 }
 
-char *DISK_get_saveimagepath (const char *name)
+TCHAR *DISK_get_saveimagepath (const TCHAR *name)
 {
-    static char name1[MAX_DPATH];
-    char name2[MAX_DPATH];
-    char path[MAX_DPATH];
+    static TCHAR name1[MAX_DPATH];
+    TCHAR name2[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
     int i;
 
-    strcpy (name2, name);
-    i = strlen (name2) - 1;
+    _tcscpy (name2, name);
+    i = _tcslen (name2) - 1;
     while (i > 0) {
        if (name2[i] == '.') {
            name2[i] = 0;
@@ -758,27 +760,27 @@ char *DISK_get_saveimagepath (const char *name)
        i--;
     }
     fetch_saveimagepath (path, sizeof (path), 1);
-    sprintf (name1, "%s%s_save.adf", path, name2 + i);
+    _stprintf (name1, L"%s%s_save.adf", path, name2 + i);
     return name1;
 }
 
-static struct zfile *getwritefile (const char *name, int *wrprot)
+static struct zfile *getwritefile (const TCHAR *name, int *wrprot)
 {
     return DISK_validate_filename (DISK_get_saveimagepath (name), 1, wrprot, NULL);
 }
 
-static int iswritefileempty (const char *name)
+static int iswritefileempty (const TCHAR *name)
 {
     struct zfile *zf;
     int wrprot;
-    uae_u8 buffer[8];
+    uae_char buffer[8];
     trackid td[MAX_TRACKS];
     int tracks, ddhd, i, ret;
 
     zf = getwritefile (name, &wrprot);
     if (!zf) return 1;
     zfile_fread (buffer, sizeof (char), 8, zf);
-    if (strncmp ((char *) buffer, "UAE-1ADF", 8))
+    if (strncmp ((uae_char*)buffer, "UAE-1ADF", 8))
        return 0;
     ret = read_header_ext2 (zf, td, &tracks, &ddhd);
     zfile_fclose (zf);
@@ -811,11 +813,11 @@ static int openwritefile (drive *drv, int create)
     return drv->writediskfile ? 1 : 0;
 }
 
-static int diskfile_iswriteprotect (const char *fname, int *needwritefile, drive_type *drvtype)
+static int diskfile_iswriteprotect (const TCHAR *fname, int *needwritefile, drive_type *drvtype)
 {
     struct zfile *zf1, *zf2;
     int wrprot1 = 0, wrprot2 = 1;
-    unsigned char buffer[25];
+    uae_char buffer[25];
 
     *needwritefile = 0;
     *drvtype = DRV_35_DD;
@@ -830,20 +832,20 @@ static int diskfile_iswriteprotect (const char *fname, int *needwritefile, drive
     zfile_fclose (zf2);
     zfile_fread (buffer, sizeof (char), 25, zf1);
     zfile_fclose (zf1);
-    if (strncmp ((char *) buffer, "CAPS", 4) == 0) {
+    if (strncmp ((uae_char*) buffer, "CAPS", 4) == 0) {
        *needwritefile = 1;
        return wrprot2;
     }
-    if (strncmp ((char *) buffer, "Formatted Disk Image file", 25) == 0) {
+    if (strncmp ((uae_char*) buffer, "Formatted Disk Image file", 25) == 0) {
        *needwritefile = 1;
        return wrprot2;
     }
-    if (strncmp ((char *) buffer, "UAE-1ADF", 8) == 0) {
+    if (strncmp ((uae_char*) buffer, "UAE-1ADF", 8) == 0) {
        if (wrprot1)
            return wrprot2;
        return wrprot1;
     }
-    if (strncmp ((char *) buffer, "UAE--ADF", 8) == 0) {
+    if (strncmp ((uae_char*) buffer, "UAE--ADF", 8) == 0) {
        *needwritefile = 1;
        return wrprot2;
     }
@@ -854,9 +856,9 @@ static int diskfile_iswriteprotect (const char *fname, int *needwritefile, drive
     return wrprot1;
 }
 
-static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char *fname)
+static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR *fname)
 {
-    unsigned char buffer[2 + 2 + 4 + 4];
+    uae_char buffer[2 + 2 + 4 + 4];
     trackid *tid;
     int num_tracks, size;
 
@@ -887,11 +889,11 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
        inprec_rend ();
     }
 
-    strncpy (currprefs.df[dnum], fname, 255);
+    _tcsncpy (currprefs.df[dnum], fname, 255);
     currprefs.df[dnum][255] = 0;
-    strncpy (changed_prefs.df[dnum], fname, 255);
+    _tcsncpy (changed_prefs.df[dnum], fname, 255);
     changed_prefs.df[dnum][255] = 0;
-    strcpy (drv->newname, fname);
+    _tcscpy (drv->newname, fname);
     gui_filename (dnum, fname);
 
     memset (buffer, 0, sizeof (buffer));
@@ -912,7 +914,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
        drv->ddhd = 1;
 
 #ifdef CAPS
-    } else if (strncmp ((char *) buffer, "CAPS", 4) == 0) {
+    } else if (strncmp ((uae_char*)buffer, "CAPS", 4) == 0) {
 
        drv->wrprot = 1;
        if (!caps_loadimage (drv->diskfile, drv - floppy, &num_tracks)) {
@@ -931,7 +933,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
        drv->num_secs = fdi2raw_get_num_sector (drv->fdi);
        drv->filetype = ADF_FDI;
 #endif
-    } else if (strncmp ((char *) buffer, "UAE-1ADF", 8) == 0) {
+    } else if (strncmp ((uae_char*)buffer, "UAE-1ADF", 8) == 0) {
 
        read_header_ext2 (drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd);
        drv->filetype = ADF_EXT2;
@@ -939,7 +941,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
        if (drv->ddhd > 1)
            drv->num_secs = 22;
 
-    } else if (strncmp ((char *) buffer, "UAE--ADF", 8) == 0) {
+    } else if (strncmp ((uae_char*)buffer, "UAE--ADF", 8) == 0) {
        int offs = 160 * 4 + 8;
        int i;
 
@@ -967,7 +969,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
 
     } else if (memcmp (exeheader, buffer, sizeof (exeheader)) == 0) {
        int i;
-       struct zfile *z = zfile_fopen_empty ("", 512 * 1760);
+       struct zfile *z = zfile_fopen_empty (L"", 512 * 1760);
        createimagefromexe (drv->diskfile, z);
        drv->filetype = ADF_NORMAL;
        zfile_fclose (drv->diskfile);
@@ -1026,7 +1028,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
            drv->num_tracks = size / (512 * (drv->num_secs = 11));
 
        if (drv->num_tracks > MAX_TRACKS)
-           write_log ("Your diskfile is too big, %d bytes!\n", size);
+           write_log (L"Your diskfile is too big, %d bytes!\n", size);
        for (i = 0; i < drv->num_tracks; i++) {
            tid = &drv->trackdata[i];
            tid->type = TRACK_AMIGADOS;
@@ -1083,13 +1085,13 @@ static void drive_step (drive * drv)
        drv->cyl += dir;
        if (drv->cyl < 0)
            drv->cyl = 0;
-       write_log ("%d -> %d\n", dir, drv->cyl);
+       write_log (L"%d -> %d\n", dir, drv->cyl);
        return;
     }
 #endif
     if (drv->steplimit && get_cycles() - drv->steplimitcycle < MIN_STEPLIMIT_CYCLE) {
        if (disk_debug_logging > 1)
-           write_log (" step ignored drive %d, %d",
+           write_log (L" step ignored drive %d, %d",
                drv - floppy, (get_cycles() - drv->steplimitcycle) / CYCLE_UNIT);
        return;
     }
@@ -1108,7 +1110,7 @@ static void drive_step (drive * drv)
 #endif
        }
 /*     else
-           write_log ("program tried to step beyond track zero\n");
+           write_log (L"program tried to step beyond track zero\n");
            "no-click" programs does that
 */
   } else {
@@ -1121,14 +1123,14 @@ static void drive_step (drive * drv)
 #endif
        }
        if (drv->cyl >= maxtrack)
-           write_log ("program tried to step over track %d\n", maxtrack);
+           write_log (L"program tried to step over track %d\n", maxtrack);
 #ifdef DRIVESOUND
        driveclick_click (drv - floppy, drv->cyl);
 #endif
     }
     rand_shifter (drv);
     if (disk_debug_logging > 1)
-       write_log (" ->step %d", drv->cyl);
+       write_log (L" ->step %d", drv->cyl);
 }
 
 static int drive_track0 (drive * drv)
@@ -1168,7 +1170,7 @@ static void drive_motor (drive * drv, int off)
        driveclick_motor (drv - floppy, drv->dskready_down_time == 0 ? 2 : 1);
 #endif
        if (disk_debug_logging > 1)
-           write_log (" ->motor on");
+           write_log (L" ->motor on");
     }
     if (!drv->motoroff && off) {
        drv->drive_id_scnt = 0; /* Reset id shift reg counter */
@@ -1177,10 +1179,10 @@ static void drive_motor (drive * drv, int off)
        driveclick_motor (drv - floppy, 0);
 #endif
 #ifdef DEBUG_DRIVE_ID
-       write_log ("drive_motor: Selected DF%d: reset id shift reg.\n",drv-floppy);
+       write_log (L"drive_motor: Selected DF%d: reset id shift reg.\n",drv-floppy);
 #endif
        if (disk_debug_logging > 1)
-           write_log (" ->motor off");
+           write_log (L" ->motor off");
        if (currprefs.cpu_model <= 68010 && currprefs.m68k_speed == 0) {
            drv->motordelay = 1;
            event2_newevent2 (30, drv - floppy, motordelay_func);
@@ -1197,7 +1199,7 @@ static void drive_motor (drive * drv, int off)
 #endif
 }
 
-static void read_floppy_data (struct zfile *diskfile, trackid *tid, int offset, unsigned char *dst, int len)
+static void read_floppy_data (struct zfile *diskfile, trackid *tid, int offset, uae_u8 *dst, int len)
 {
     if (len == 0)
        return;
@@ -1310,7 +1312,7 @@ static void decode_pcdos (drive *drv)
     drv->skipoffset = 0;
     drv->tracklen = (dstmfmbuf - drv->bigmfmbuf) * 16;
     if (disk_debug_logging > 0)
-       write_log ("pcdos read track %d\n", tr);
+       write_log (L"pcdos read track %d\n", tr);
 }
 
 static void decode_amigados (drive *drv)
@@ -1403,7 +1405,7 @@ static void decode_amigados (drive *drv)
      }
 
     if (disk_debug_logging > 0)
-       write_log ("amigados read track %d\n", tr);
+       write_log (L"amigados read track %d\n", tr);
 }
 
 static void drive_fill_bigbuf (drive * drv, int force)
@@ -1432,14 +1434,14 @@ static void drive_fill_bigbuf (drive * drv, int force)
        int i;
        trackid *wti = &drv->writetrackdata[tr];
        drv->tracklen = wti->bitlen;
-       read_floppy_data (drv->writediskfile, wti, 0, (char *) drv->bigmfmbuf, (wti->bitlen + 7) / 8);
+       read_floppy_data (drv->writediskfile, wti, 0, (uae_u8*)drv->bigmfmbuf, (wti->bitlen + 7) / 8);
        for (i = 0; i < (drv->tracklen + 15) / 16; i++) {
            uae_u16 *mfm = drv->bigmfmbuf + i;
            uae_u8 *data = (uae_u8 *) mfm;
            *mfm = 256 * *data + *(data + 1);
        }
        if (disk_debug_logging > 0)
-           write_log ("track %d, length %d read from \"saveimage\"\n", tr, drv->tracklen);
+           write_log (L"track %d, length %d read from \"saveimage\"\n", tr, drv->tracklen);
     } else if (drv->filetype == ADF_CATWEASEL) {
 #ifdef CATWEASEL
        drv->tracklen = 0;
@@ -1478,14 +1480,14 @@ static void drive_fill_bigbuf (drive * drv, int force)
        int base_offset = ti->type == TRACK_RAW ? 0 : 1;
        drv->tracklen = ti->bitlen + 16 * base_offset;
        drv->bigmfmbuf[0] = ti->sync;
-       read_floppy_data (drv->diskfile, ti, 0, (char *) (drv->bigmfmbuf + base_offset), (ti->bitlen + 7) / 8);
+       read_floppy_data (drv->diskfile, ti, 0, (uae_u8*)(drv->bigmfmbuf + base_offset), (ti->bitlen + 7) / 8);
        for (i = base_offset; i < (drv->tracklen + 15) / 16; i++) {
            uae_u16 *mfm = drv->bigmfmbuf + i;
            uae_u8 *data = (uae_u8 *) mfm;
            *mfm = 256 * *data + *(data + 1);
        }
        if (disk_debug_logging > 1)
-           write_log ("rawtrack %d image offset=%x\n", tr, ti->offs);
+           write_log (L"rawtrack %d image offset=%x\n", tr, ti->offs);
     }
     drv->buffered_side = side;
     drv->buffered_cyl = drv->cyl;
@@ -1519,7 +1521,7 @@ static void diskfile_update (struct zfile *diskfile, trackid *ti, int len, uae_u
        free (zerobuf);
     }
     if (disk_debug_logging > 0)
-       write_log ("track %d, raw track length %d written (total size %d)\n", ti->track, (ti->bitlen + 7) / 8, ti->len);
+       write_log (L"track %d, raw track length %d written (total size %d)\n", ti->track, (ti->bitlen + 7) / 8, ti->len);
 }
 
 #define MFMMASK 0x55555555
@@ -1572,7 +1574,7 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file
 
        trackoffs = (id & 0xff00) >> 8;
        if (trackoffs + 1 > drvsec) {
-           write_log ("Disk decode: weird sector number %d\n", trackoffs);
+           write_log (L"Disk decode: weird sector number %d\n", trackoffs);
            if (filetype == ADF_EXT2)
                return 2;
            continue;
@@ -1596,7 +1598,7 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file
        even = getmfmlong (mbuf + 2, shift);
        mbuf += 4;
        if (((odd << 1) | even) != chksum || ((id & 0x00ff0000) >> 16) != cyl * 2 + side) {
-           write_log ("Disk decode: checksum error on sector %d header\n", trackoffs);
+           write_log (L"Disk decode: checksum error on sector %d header\n", trackoffs);
            if (filetype == ADF_EXT2)
                return 3;
            continue;
@@ -1618,7 +1620,7 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file
            chksum ^= odd ^ even;
        }
        if (chksum) {
-           write_log ("Disk decode: sector %d, data checksum error\n", trackoffs);
+           write_log (L"Disk decode: sector %d, data checksum error\n", trackoffs);
            if (filetype == ADF_EXT2)
                return 4;
            continue;
@@ -1631,9 +1633,9 @@ static int decode_buffer (uae_u16 *mbuf, int cyl, int drvsec, int ddhd, int file
     if (filetype == ADF_EXT2 && (secwritten == 0 || secwritten < 0))
        return 5;
     if (secwritten == 0)
-       write_log ("Disk decode: unsupported format\n");
+       write_log (L"Disk decode: unsupported format\n");
     if (secwritten < 0)
-       write_log ("Disk decode: sector labels ignored\n");
+       write_log (L"Disk decode: sector labels ignored\n");
     *drvsecp = drvsec;
     return 0;
 }
@@ -1704,14 +1706,14 @@ static int drive_write_pcdos (drive *drv)
            tmp[0] = 0xa1; tmp[1] = 0xa1; tmp[2] = 0xa1; tmp[3] = mark;
            tmp[4] = cyl; tmp[5] = head; tmp[6] = sector; tmp[7] = size;
            if (get_crc16(tmp, 8) != crc || cyl != drv->cyl || head != side || size != 2 || sector < 1 || sector > drv->num_secs) {
-               write_log ("PCDOS: track %d, corrupted sector header\n", drv->cyl * 2 + side);
+               write_log (L"PCDOS: track %d, corrupted sector header\n", drv->cyl * 2 + side);
                return 1;
            }
            sector--;
            continue;
        }
        if (mark != 0xfb) {
-           write_log ("PCDOS: track %d: unknown address mark %02X\n", drv->cyl * 2 + side, mark);
+           write_log (L"PCDOS: track %d: unknown address mark %02X\n", drv->cyl * 2 + side, mark);
            continue;
        }
        if (sector < 0)
@@ -1720,7 +1722,7 @@ static int drive_write_pcdos (drive *drv)
            secbuf[i + 4] = mfmdecode(&mbuf, shift);
        crc = (mfmdecode(&mbuf, shift) << 8) | mfmdecode(&mbuf, shift);
        if (get_crc16(secbuf, 3 + 1 + 512) != crc) {
-           write_log ("PCDOS: track %d, sector %d data checksum error\n",
+           write_log (L"PCDOS: track %d, sector %d data checksum error\n",
                drv->cyl * 2 + side, sector + 1);
            continue;
        }
@@ -1728,11 +1730,11 @@ static int drive_write_pcdos (drive *drv)
        secwritten++;
        zfile_fseek (drv->diskfile, drv->trackdata[drv->cyl * 2 + side].offs + sector * 512, SEEK_SET);
        zfile_fwrite (secbuf + 4, sizeof (uae_u8), 512, drv->diskfile);
-       write_log ("PCDOS: track %d sector %d written\n", drv->cyl * 2 + side, sector + 1);
+       write_log (L"PCDOS: track %d sector %d written\n", drv->cyl * 2 + side, sector + 1);
        sector = -1;
     }
     if (secwritten != drv->num_secs)
-       write_log ("PCDOS: track %d, %d corrupted sectors ignored\n",
+       write_log (L"PCDOS: track %d, %d corrupted sectors ignored\n",
            drv->cyl * 2 + side, drv->num_secs - secwritten);
     return 0;
 }
@@ -1764,7 +1766,7 @@ static int drive_write_ext2 (uae_u16 *bigmfmbuf, struct zfile *diskfile, trackid
 
     len = (tracklen + 7) / 8;
     if (len > ti->len) {
-       write_log ("disk raw write: image file's track %d is too small (%d < %d)!\n", ti->track, ti->len, len);
+       write_log (L"disk raw write: image file's track %d is too small (%d < %d)!\n", ti->track, ti->len, len);
        len = ti->len;
     }
     diskfile_update (diskfile, ti, tracklen, TRACK_RAW);
@@ -1807,7 +1809,7 @@ static void drive_write_data (drive * drv)
        if (!longwritemode)
            ret = drive_write_adf_amigados (drv);
        if (ret) {
-           write_log ("not an amigados track %d (error %d), writing as raw track\n", drv->cyl * 2 + side, ret);
+           write_log (L"not an amigados track %d (error %d), writing as raw track\n", drv->cyl * 2 + side, ret);
            drive_write_ext2 (drv->bigmfmbuf, drv->diskfile, &drv->trackdata[drv->cyl * 2 + side],
                longwritemode ? dsklength2 * 8 : drv->tracklen);
        }
@@ -1817,7 +1819,7 @@ static void drive_write_data (drive * drv)
     case ADF_PCDOS:
        ret = drive_write_pcdos (drv);
        if (ret)
-           write_log ("not a PC formatted track %d (error %d)\n", drv->cyl * 2 + side, ret);
+           write_log (L"not a PC formatted track %d (error %d)\n", drv->cyl * 2 + side, ret);
        break;
     }
     drv->tracktiming[0] = 0;
@@ -1839,7 +1841,7 @@ static void drive_eject (drive * drv)
     drv->crc32 = 0;
     drive_settype_id (drv); /* Back to 35 DD */
     if (disk_debug_logging > 0)
-       write_log ("eject drive %d\n", drv - &floppy[0]);
+       write_log (L"eject drive %d\n", drv - &floppy[0]);
     if (input_recording > 0) {
        inprec_rstart (INPREC_DISKREMOVE);
        inprec_ru8 (drv - floppy);
@@ -1858,15 +1860,16 @@ void DISK_ersatz_read (int tr, int sec, uaecptr dest)
 
 /* type: 0=regular, 1=ext2adf */
 /* adftype: 0=DD,1=HD,2=525SD */
-void disk_creatediskfile (char *name, int type, drive_type adftype, char *disk_name)
+void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk_name)
 {
     struct zfile *f;
     int i, l, file_size, tracks, track_len;
-    char *chunk = NULL;
+    uae_u8 *chunk = NULL;
     uae_u8 tmp[3*4];
+    uae_char *s;
 
-    if (disk_name == NULL || strlen(disk_name) == 0)
-       disk_name = "empty";
+    if (disk_name == NULL || _tcslen (disk_name) == 0)
+       disk_name = L"empty";
 
     if (type == 1)
        tracks = 2 * 83;
@@ -1882,8 +1885,8 @@ void disk_creatediskfile (char *name, int type, drive_type adftype, char *disk_n
        tracks /= 2;
     }
 
-    f = zfile_fopen (name, "wb");
-    chunk = (uae_u8*)xmalloc (16384);
+    f = zfile_fopen (name, L"wb");
+    chunk = xmalloc (16384);
     if (f && chunk) {
        memset(chunk,0,16384);
        if (type == 0 && adftype < 2) {
@@ -1899,8 +1902,10 @@ void disk_creatediskfile (char *name, int type, drive_type adftype, char *disk_n
                    chunk[12+3] = 0x48;
                    chunk[312] = chunk[313] = chunk[314] = chunk[315] = (uae_u8)0xff;
                    chunk[316+2] = (block + 1) >> 8; chunk[316+3] = (block + 1) & 255;
-                   chunk[432] = strlen (disk_name);
-                   strcpy (chunk + 433, disk_name);
+                   s = ua (disk_name);
+                   chunk[432] = strlen (s);
+                   strcpy (chunk + 433, s);
+                   xfree (s);
                    chunk[508 + 3] = 1;
                    disk_date (chunk + 420);
                    memcpy (chunk + 472, chunk + 420, 3 * 4);
@@ -1935,14 +1940,14 @@ void disk_creatediskfile (char *name, int type, drive_type adftype, char *disk_n
     zfile_fclose (f);
 }
 
-int disk_getwriteprotect (const char *name)
+int disk_getwriteprotect (const TCHAR *name)
 {
     int needwritefile;
     drive_type drvtype;
     return diskfile_iswriteprotect (name, &needwritefile, &drvtype);
 }
 
-static void diskfile_readonly (const char *name, int readonly)
+static void diskfile_readonly (const TCHAR *name, int readonly)
 {
     struct stat st;
     int mode, oldmode;
@@ -1969,7 +1974,7 @@ static void setdskchangetime(drive *drv, int dsktime)
     }
     drv->dskchange_time = dsktime;
     if (disk_debug_logging > 0)
-       write_log ("delayed insert enable %d\n", dsktime);
+       write_log (L"delayed insert enable %d\n", dsktime);
 }
 
 void DISK_reinsert (int num)
@@ -1978,12 +1983,12 @@ void DISK_reinsert (int num)
     setdskchangetime (&floppy[num], 20);
 }
 
-int disk_setwriteprotect (int num, const char *name, int protect)
+int disk_setwriteprotect (int num, const TCHAR *name, int protect)
 {
     int needwritefile, oldprotect;
     struct zfile *zf1, *zf2;
     int wrprot1, wrprot2, i;
-    char *name2;
+    TCHAR *name2;
     drive_type drvtype;
 
     oldprotect = diskfile_iswriteprotect (name, &needwritefile, &drvtype);
@@ -2001,10 +2006,10 @@ int disk_setwriteprotect (int num, const char *name, int protect)
     zfile_fclose (zf2);
     if (protect && iswritefileempty (name)) {
        for (i = 0; i < MAX_FLOPPY_DRIVES; i++) {
-           if (!strcmp (name, floppy[i].newname))
+           if (!_tcscmp (name, floppy[i].newname))
                drive_eject (&floppy[i]);
        }
-       unlink (name2);
+       _wunlink (name2);
     }
 
     if (!needwritefile)
@@ -2016,14 +2021,14 @@ int disk_setwriteprotect (int num, const char *name, int protect)
 
 void disk_eject (int num)
 {
-    gui_filename (num, "");
+    gui_filename (num, L"");
     drive_eject (floppy + num);
     *currprefs.df[num] = *changed_prefs.df[num] = 0;
     floppy[num].newname[0] = 0;
     update_drive_gui (num);
 }
 
-int DISK_history_add (const char *name, int idx)
+int DISK_history_add (const TCHAR *name, int idx)
 {
     int i;
 
@@ -2042,16 +2047,16 @@ int DISK_history_add (const char *name, int idx)
            return 0;
        dfxhistory[idx][0] = 0;
        for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) {
-           if (!strcmp (dfxhistory[i], name))
+           if (!_tcscmp (dfxhistory[i], name))
                return 0;
        }
-       strcpy (dfxhistory[idx], name);
+       _tcscpy (dfxhistory[idx], name);
        return 1;
     }
     for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) {
-       if (!strcmp (dfxhistory[i], name)) {
+       if (!_tcscmp (dfxhistory[i], name)) {
            while (i < MAX_PREVIOUS_FLOPPIES - 1) {
-               strcpy (dfxhistory[i], dfxhistory[i + 1]);
+               _tcscpy (dfxhistory[i], dfxhistory[i + 1]);
                i++;
            }
            dfxhistory[MAX_PREVIOUS_FLOPPIES - 1][0] = 0;
@@ -2059,19 +2064,19 @@ int DISK_history_add (const char *name, int idx)
        }
     }
     for (i = MAX_PREVIOUS_FLOPPIES - 2; i >= 0; i--)
-       strcpy (dfxhistory[i + 1], dfxhistory[i]);
-    strcpy (dfxhistory[0], name);
+       _tcscpy (dfxhistory[i + 1], dfxhistory[i]);
+    _tcscpy (dfxhistory[0], name);
     return 1;
 }
 
-char *DISK_history_get (int idx)
+TCHAR *DISK_history_get (int idx)
 {
     if (idx >= MAX_PREVIOUS_FLOPPIES)
        return 0;
     return dfxhistory[idx];
 }
 
-static void disk_insert_2 (int num, const char *name, int forced)
+static void disk_insert_2 (int num, const TCHAR *name, int forced)
 {
     drive *drv = floppy + num;
 
@@ -2079,10 +2084,10 @@ static void disk_insert_2 (int num, const char *name, int forced)
        drive_insert (drv, &currprefs, num, name);
        return;
     }
-    if (!strcmp (currprefs.df[num], name))
+    if (!_tcscmp (currprefs.df[num], name))
        return;
-    strcpy (drv->newname, name);
-    strcpy (currprefs.df[num], name);
+    _tcscpy (drv->newname, name);
+    _tcscpy (currprefs.df[num], name);
     DISK_history_add (name, -1);
     if (name[0] == 0) {
        disk_eject (num);
@@ -2098,11 +2103,11 @@ static void disk_insert_2 (int num, const char *name, int forced)
     }
 }
 
-void disk_insert (int num, const char *name)
+void disk_insert (int num, const TCHAR *name)
 {
     disk_insert_2 (num, name, 0);
 }
-void disk_insert_force (int num, const char *name)
+void disk_insert_force (int num, const TCHAR *name)
 {
     disk_insert_2 (num, name, 1);
 }
@@ -2123,7 +2128,7 @@ void DISK_check_change (void)
            rp_floppydrive_change (i, currprefs.dfxtype[i] >= 0 ? 1 : 0);
 #endif
        }
-       if (drv->dskchange_time == 0 && strcmp (currprefs.df[i], changed_prefs.df[i]))
+       if (drv->dskchange_time == 0 && _tcscmp (currprefs.df[i], changed_prefs.df[i]))
            disk_insert (i, changed_prefs.df[i]);
        gui_unlock ();
        if (drv->dskready_down_time > 0)
@@ -2140,7 +2145,7 @@ void DISK_check_change (void)
            if (drv->dskchange_time == 0) {
                drive_insert (drv, &currprefs, i, drv->newname);
                if (disk_debug_logging > 0)
-                   write_log ("delayed insert, drive %d, image '%s'\n", i, drv->newname);
+                   write_log (L"delayed insert, drive %d, image '%s'\n", i, drv->newname);
                update_drive_gui (i);
 
            }
@@ -2153,10 +2158,10 @@ int disk_empty (int num)
     return drive_empty (floppy + num);
 }
 
-static char *tobin(uae_u8 v)
+static TCHAR *tobin(uae_u8 v)
 {
     int i;
-    static char buf[10];
+    static TCHAR buf[10];
     for( i = 7; i >= 0; i--)
        buf[7 - i] = v & (1 << i) ? '1' : '0';
     buf[i] = 0;
@@ -2176,7 +2181,7 @@ void DISK_select (uae_u8 data)
     step_pulse = data & 1;
 
     if (disk_debug_logging > 1)
-       write_log ("%08X %02X %s drvmask=%x", M68K_GETPC, data, tobin(data), selected ^ 15);
+       write_log (L"%08X %02X %s drvmask=%x", M68K_GETPC, data, tobin(data), selected ^ 15);
 
 #ifdef AMAX
     if (currprefs.amaxromfile[0])
@@ -2188,24 +2193,24 @@ void DISK_select (uae_u8 data)
            if (floppy[dr].indexhackmode > 1 && !(selected & (1 << dr))) {
                floppy[dr].indexhack = 1;
                if (disk_debug_logging > 1)
-                   write_log (" indexhack!");
+                   write_log (L" indexhack!");
            }
        }
     }
 
     if (disk_debug_logging > 1) {
-       write_log (" %d%d%d%d% ", (selected & 1) ? 0 : 1, (selected & 2) ? 0 : 1, (selected & 4) ? 0 : 1, (selected & 8) ? 0 : 1);
+       write_log (L" %d%d%d%d% ", (selected & 1) ? 0 : 1, (selected & 2) ? 0 : 1, (selected & 4) ? 0 : 1, (selected & 8) ? 0 : 1);
        if ((prevdata & 0x80) != (data & 0x80))
-           write_log (" dskmotor %d ", (data & 0x80) ? 1 : 0);
+           write_log (L" dskmotor %d ", (data & 0x80) ? 1 : 0);
        if ((prevdata & 0x02) != (data & 0x02))
-           write_log (" direct %d ", (data & 0x02) ? 1 : 0);
+           write_log (L" direct %d ", (data & 0x02) ? 1 : 0);
        if ((prevdata & 0x04) != (data & 0x04))
-           write_log (" side %d ", (data & 0x04) ? 1 : 0);
+           write_log (L" side %d ", (data & 0x04) ? 1 : 0);
     }
 
     if (step != step_pulse) {
        if (disk_debug_logging > 1)
-           write_log (" dskstep %d ", step_pulse);
+           write_log (L" dskstep %d ", step_pulse);
        step = step_pulse;
        if (step && !savestate_state) {
            for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
@@ -2239,7 +2244,7 @@ void DISK_select (uae_u8 data)
                if (!currprefs.cs_df0idhw && dr == 0)
                    drv->idbit = 0;
 #ifdef DEBUG_DRIVE_ID
-               write_log ("DISK_status: sel %d id %s (%08X) [0x%08lx, bit #%02d: %d]\n",
+               write_log (L"DISK_status: sel %d id %s (%08X) [0x%08lx, bit #%02d: %d]\n",
                    dr, drive_id_name(drv), drv->drive_id, drv->drive_id << drv->drive_id_scnt, 31 - drv->drive_id_scnt, drv->idbit);
 #endif
            }
@@ -2252,7 +2257,7 @@ void DISK_select (uae_u8 data)
     }
     prevdata = data;
     if (disk_debug_logging > 1)
-       write_log ("\n");
+       write_log (L"\n");
 }
 
 uae_u8 DISK_status (void)
@@ -2336,21 +2341,21 @@ void dumpdisk (void)
     for (i = 0; i < MAX_FLOPPY_DRIVES; i++) {
        drive *drv = &floppy[i];
        if (!(disabled & (1 << i))) {
-           console_out_f ("Drive %d: motor %s cylinder %2d sel %s %s mfmpos %d/%d\n",
+           console_out_f (L"Drive %d: motor %s cylinder %2d sel %s %s mfmpos %d/%d\n",
                i, drv->motoroff ? "off" : " on", drv->cyl, (selected & (1 << i)) ? "no" : "yes",
                drive_writeprotected(drv) ? "ro" : "rw", drv->mfmpos, drv->tracklen);
            w = word;
            for (j = 0; j < 15; j++) {
-               console_out_f ("%04X ", w);
+               console_out_f (L"%04X ", w);
                for (k = 0; k < 16; k++) {
                    w <<= 1;
                    w |= getonebit (drv->bigmfmbuf, drv->mfmpos + j * 16 + k);
                }
            }
-           console_out ("\n");
+           console_out (L"\n");
        }
     }
-    console_out_f ("side %d, dma %d, bitoffset %d, word %04X, dskbytr %04X adkcon %04X dsksync %04X\n", side, dskdmaen, bitoffset, word, dskbytr_val, adkcon, dsksync);
+    console_out_f (L"side %d, dma %d, bitoffset %d, word %04X, dskbytr %04X adkcon %04X dsksync %04X\n", side, dskdmaen, bitoffset, word, dskbytr_val, adkcon, dsksync);
 }
 
 static void disk_dmafinished (void)
@@ -2360,10 +2365,10 @@ static void disk_dmafinished (void)
     dskdmaen = 0;
     if (disk_debug_logging > 0) {
        int dr, mfmpos = -1;
-       write_log ("disk dma finished %08X MFMpos=", dskpt);
+       write_log (L"disk dma finished %08X MFMpos=", dskpt);
        for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++)
-           write_log ("%d%s", floppy[dr].mfmpos, dr < MAX_FLOPPY_DRIVES - 1 ? "," : "");
-       write_log ("\n");
+           write_log (L"%d%s", floppy[dr].mfmpos, dr < MAX_FLOPPY_DRIVES - 1 ? "," : "");
+       write_log (L"\n");
     }
 }
 
@@ -2415,7 +2420,7 @@ void DISK_handler (uae_u32 data)
                if (drv->dskready_time == 0) {
                    drv->dskready = 1;
                    if (disk_debug_logging > 0)
-                        write_log ("%d: %d\n", i, drv->mfmpos);
+                        write_log (L"%d: %d\n", i, drv->mfmpos);
                }
            }
        }
@@ -2492,7 +2497,7 @@ static void updatetrackspeed (drive *drv, int mfmpos)
            static int warned;
            warned++;
            if (warned < 50)
-               write_log ("corrupted trackspeed value %d\n", drv->trackspeed);
+               write_log (L"corrupted trackspeed value %d\n", drv->trackspeed);
            drv->trackspeed = 1000;
        }
     }
@@ -2614,12 +2619,12 @@ static void disk_doupdate_read (drive * drv, int floppybits)
            else
                word |= getonebit (drv->bigmfmbuf, drv->mfmpos);
        }
-       //write_log ("%08X bo=%d so=%d mfmpos=%d dma=%d\n", (word & 0xffffff), bitoffset, syncoffset, drv->mfmpos,dma_enable);
+       //write_log (L"%08X bo=%d so=%d mfmpos=%d dma=%d\n", (word & 0xffffff), bitoffset, syncoffset, drv->mfmpos,dma_enable);
        drv->mfmpos++;
        drv->mfmpos %= drv->tracklen;
        if (drv->mfmpos == drv->indexoffset) {
            if (disk_debug_logging > 1 && drv->indexhack)
-               write_log ("indexhack cleared\n");
+               write_log (L"indexhack cleared\n");
            drv->indexhack = 0;
        }
        if (drv->mfmpos == drv->skipoffset) {
@@ -2638,7 +2643,7 @@ static void disk_doupdate_read (drive * drv, int floppybits)
 #if 0
            dma_tab[j++] = word;
            if (j == MAX_DISK_WORDS_PER_LINE - 1) {
-               write_log ("Bug: Disk DMA buffer overflow!\n");
+               write_log (L"Bug: Disk DMA buffer overflow!\n");
                j--;
            }
 #endif
@@ -2655,7 +2660,7 @@ static void disk_doupdate_read (drive * drv, int floppybits)
                bitoffset = 15;
            if (dskdmaen) {
                if (disk_debug_logging && dma_enable == 0)
-                   write_log ("Sync match, DMA started at %d\n", drv->mfmpos);
+                   write_log (L"Sync match, DMA started at %d\n", drv->mfmpos);
                dma_enable = 1;
            }
        }
@@ -2670,7 +2675,7 @@ static void disk_doupdate_read (drive * drv, int floppybits)
 
 static void disk_dma_debugmsg (void)
 {
-    write_log ("LEN=%04X (%d) SYNC=%04X PT=%08X ADKCON=%04X PC=%08X\n",
+    write_log (L"LEN=%04X (%d) SYNC=%04X PT=%08X ADKCON=%04X PC=%08X\n",
        dsklength, dsklength, (adkcon & 0x400) ? dsksync : 0xffff, dskpt, adkcon, M68K_GETPC);
 }
 
@@ -2708,7 +2713,7 @@ uae_u16 DSKBYTR (int hpos)
     if (dsklen & 0x4000)
        v |= 0x2000;
     if (disk_debug_logging > 1)
-       write_log ("DSKBYTR=%04X hpos=%d\n", v, hpos);
+       write_log (L"DSKBYTR=%04X hpos=%d\n", v, hpos);
     if (disk_debug_mode & DISK_DEBUG_PIO) {
        int dr;
        for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
@@ -2718,7 +2723,7 @@ uae_u16 DSKBYTR (int hpos)
            if (!(selected & (1 << dr))) {
                if (disk_debug_track < 0 || disk_debug_track == 2 * drv->cyl + side) {
                    disk_dma_debugmsg ();
-                   write_log ("DSKBYTR=%04X\n", v);
+                   write_log (L"DSKBYTR=%04X\n", v);
                    activate_debugger ();
                    break;
                }
@@ -2851,9 +2856,9 @@ void DSKLEN (uae_u16 v, int hpos)
        if (dskdmaen) {
            /* Megalomania and Knightmare does this */
            if (disk_debug_logging > 0 && dskdmaen == 2)
-               write_log ("warning: Disk read DMA aborted, %d words left PC=%x\n", dsklength, M68K_GETPC);
+               write_log (L"warning: Disk read DMA aborted, %d words left PC=%x\n", dsklength, M68K_GETPC);
            if (dskdmaen == 3) {
-               write_log ("warning: Disk write DMA aborted, %d words left PC=%x\n", dsklength, M68K_GETPC);
+               write_log (L"warning: Disk write DMA aborted, %d words left PC=%x\n", dsklength, M68K_GETPC);
                // did program write something that needs to be stored to file?
                for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
                    drive *drv2 = &floppy[dr];
@@ -2913,12 +2918,12 @@ void DSKLEN (uae_u16 v, int hpos)
            break;
     }
     if (dr == 4) {
-        write_log ("disk %s DMA started, drvmask=%x motormask=%x\n",
+        write_log (L"disk %s DMA started, drvmask=%x motormask=%x\n",
            dskdmaen == 3 ? "write" : "read", selected ^ 15, motormask);
        noselected = 1;
     } else {
        if (disk_debug_logging > 0) {
-           write_log ("disk %s DMA started, drvmask=%x track %d mfmpos %d dmaen=%d\n",
+           write_log (L"disk %s DMA started, drvmask=%x track %d mfmpos %d dmaen=%d\n",
                dskdmaen == 3 ? "write" : "read", selected ^ 15,
                floppy[dr].cyl * 2 + side, floppy[dr].mfmpos, dma_enable);
            disk_dma_debugmsg ();
@@ -3043,11 +3048,11 @@ void DSKDAT (uae_u16 v)
 #endif
     if (count < 5) {
        count++;
-       write_log ("%04X written to DSKDAT. Not good. PC=%08X", v, M68K_GETPC);
+       write_log (L"%04X written to DSKDAT. Not good. PC=%08X", v, M68K_GETPC);
        if (count == 5)
-           write_log ("(further messages suppressed)");
+           write_log (L"(further messages suppressed)");
 
-       write_log ("\n");
+       write_log (L"\n");
     }
 }
 void DSKPTH (uae_u16 v)
@@ -3084,7 +3089,7 @@ void DISK_init (void)
            disk_eject (dr);
     }
     if (disk_empty (0))
-       write_log ("No disk in drive 0.\n");
+       write_log (L"No disk in drive 0.\n");
     amax_init ();
 }
 
@@ -3197,11 +3202,12 @@ void restore_disk_finish (void)
     setamax();
 }
 
-uae_u8 *restore_disk(int num,uae_u8 *src)
+uae_u8 *restore_disk (int num,uae_u8 *src)
 {
     drive *drv;
     int state, dfxtype;
-    char old[MAX_DPATH];
+    TCHAR old[MAX_DPATH];
+    TCHAR *s;
     int newis;
 
     drv = &floppy[num];
@@ -3246,10 +3252,11 @@ uae_u8 *restore_disk(int num,uae_u8 *src)
     drv->dskchange = 0;
     drv->dskchange_time = 0;
     restore_u32 ();
-    strcpy (old, currprefs.df[num]);
-    strncpy (changed_prefs.df[num], src, 255);
+    s = restore_string ();
+    _tcscpy (old, currprefs.df[num]);
+    _tcsncpy (changed_prefs.df[num], s, 255);
+    xfree (s);
     newis = changed_prefs.df[num][0] ? 1 : 0;
-    src += strlen(src) + 1;
     if (!(disabled & (1 << num))) {
        if (!newis) {
            drv->dskchange = 1;
@@ -3257,7 +3264,7 @@ uae_u8 *restore_disk(int num,uae_u8 *src)
            drive_insert (floppy + num, &currprefs, num, changed_prefs.df[num]);
            if (drive_empty (floppy + num)) {
                if (newis && old[0]) {
-                   strcpy (changed_prefs.df[num], old);
+                   _tcscpy (changed_prefs.df[num], old);
                    drive_insert (floppy + num, &currprefs, num, changed_prefs.df[num]);
                    if (drive_empty (floppy + num))
                        drv->dskchange = 1;
@@ -3306,8 +3313,7 @@ uae_u8 *save_disk(int num, int *len, uae_u8 *dstptr)
     save_u8 (drv->drive_id_scnt);   /* id mode position */
     save_u32 (drv->mfmpos);        /* disk position */
     save_u32 (getadfcrc (drv));            /* CRC of disk image */
-    strcpy (dst, currprefs.df[num]);/* image name */
-    dst += strlen(dst) + 1;
+    save_string (currprefs.df[num]);/* image name */
 
     *len = dst - dstbak;
     return dstbak;
index 28547545a2462be267cd11d63da0d844e5e8127f..0a0927c3e2beb1081521173a4824e0114f7bafbd 100644 (file)
--- a/drawing.c
+++ b/drawing.c
@@ -182,7 +182,7 @@ typedef void (*line_draw_func)(int, int);
 #define LINE_DONE_AS_PREVIOUS 8
 #define LINE_REMEMBERED_AS_PREVIOUS 9
 
-static char linestate[(MAXVPOS + 1) * 2 + 1];
+static uae_u8 linestate[(MAXVPOS + 1) * 2 + 1];
 
 uae_u8 line_data[(MAXVPOS + 1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
 
@@ -255,7 +255,7 @@ static void xlinecheck (unsigned int start, unsigned int end)
        ok = 0;
 
     if (!ok) {
-           write_log ("*** %d-%d (%dx%dx%d %d) %p\n",
+           write_log (L"*** %d-%d (%dx%dx%d %d) %p\n",
                start - min, end - min, gfxvidinfo.width, gfxvidinfo.height,
                gfxvidinfo.pixbytes, gfxvidinfo.rowbytes,
                xlinebuffer);
@@ -430,8 +430,8 @@ int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy)
     *pdx = dx;
     *pdy = dy;
 
-    write_log ("Display Size: %dx%d Offset: %dx%d\n", w, h, dx, dy);
-    write_log ("first: %d last: %d minv: %d maxv: %d min: %d\n",
+    write_log (L"Display Size: %dx%d Offset: %dx%d\n", w, h, dx, dy);
+    write_log (L"first: %d last: %d minv: %d maxv: %d min: %d\n",
        plffirstline_total, plflastline_total,
        first_planes_vpos, last_planes_vpos, minfirstline);
     return 1;
@@ -729,7 +729,7 @@ STATIC_INLINE void fill_line (void)
     nints = gfxvidinfo.width >> (2 - shift);
     nrem = nints & 7;
     nints &= ~7;
-    start = (int *)(((char *)xlinebuffer) + (visible_left_border << shift));
+    start = (int *)(((uae_u8*)xlinebuffer) + (visible_left_border << shift));
 #ifdef ECS_DENISE
     val = brdblank ? 0 : colors_for_drawing.acolors[0];
 #else
@@ -1666,7 +1666,7 @@ void init_row_map (void)
 {
     int i, j;
     if (gfxvidinfo.height > MAX_VIDHEIGHT) {
-       write_log ("Resolution too high, aborting\n");
+       write_log (L"Resolution too high, aborting\n");
        abort ();
     }
     j = 0;
@@ -1957,7 +1957,7 @@ static void pfield_draw_line (int lineno, int gfx_ypos, int follow_ypos)
     {
     case LINE_REMEMBERED_AS_PREVIOUS:
        if (!warned)
-           write_log ("Shouldn't get here... this is a bug.\n"), warned++;
+           write_log (L"Shouldn't get here... this is a bug.\n"), warned++;
        return;
 
     case LINE_BLACK:
@@ -2167,7 +2167,7 @@ static void center_image (void)
 #if 0
        if (currprefs.gfx_xcenter_size > 0) {
            int diff = ((gfxvidinfo.width << (RES_MAX - currprefs.gfx_resolution)) - currprefs.gfx_xcenter_size) / 1;
-           write_log ("%d %d\n", currprefs.gfx_xcenter_size, gfxvidinfo.width);
+           write_log (L"%d %d\n", currprefs.gfx_xcenter_size, gfxvidinfo.width);
            val -= diff >> RES_MAX;
        }
 #endif
@@ -2836,7 +2836,7 @@ void vsync_handle_redraw (int long_frame, int lof_changed)
 
 void hsync_record_line_state (int lineno, enum nln_how how, int changed)
 {
-    char *state;
+    uae_u8 *state;
 
     if (framecnt != 0)
        return;
index 40f5e27c582f18b5f681b3552befdb001bd19ec3..aa022ae2c2a14f63f817ce144fc124fa642d08bf 100644 (file)
@@ -59,20 +59,20 @@ uae_s16 *decodewav (uae_u8 *s, int *lenp)
     return 0;
 }
 
-static int loadsample (char *path, struct drvsample *ds)
+static int loadsample (TCHAR *path, struct drvsample *ds)
 {
     struct zfile *f;
     uae_u8 *buf;
     int size;
-    char name[MAX_DPATH];
+    TCHAR name[MAX_DPATH];
 
-    f = zfile_fopen (path, "rb");
+    f = zfile_fopen (path, L"rb");
     if (!f) {
-       strcpy (name, path);
-       strcat (name, ".wav");
-       f = zfile_fopen (name, "rb");
+       _tcscpy (name, path);
+       _tcscat (name, L".wav");
+       f = zfile_fopen (name, L"rb");
        if (!f) {
-           write_log ("driveclick: can't open '%s' (or '%s')\n", path, name);
+           write_log (L"driveclick: can't open '%s' (or '%s')\n", path, name);
            return 0;
        }
     }
@@ -135,7 +135,7 @@ static void processclicks(struct drvsample *ds)
 void driveclick_init (void)
 {
     int v, vv, i, j;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     driveclick_fdrawcmd_detect ();
     driveclick_free ();
@@ -163,30 +163,30 @@ void driveclick_init (void)
                    break;
                }
            } else if (currprefs.dfxclick[i] == -1) {
-               char path2[MAX_DPATH];
+               TCHAR path2[MAX_DPATH];
                wave_initialized = 1;
                for (j = 0; j < CLICK_TRACKS; j++)
                    drvs[i][DS_CLICK].lengths[j] = drvs[i][DS_CLICK].len;
-               sprintf (tmp, "%splugins%cfloppysounds%c", start_path_data, FSDB_DIR_SEPARATOR, FSDB_DIR_SEPARATOR, FSDB_DIR_SEPARATOR);
+               _stprintf (tmp, L"%splugins%cfloppysounds%c", start_path_data, FSDB_DIR_SEPARATOR, FSDB_DIR_SEPARATOR, FSDB_DIR_SEPARATOR);
                if (my_existsdir (tmp))
-                   strcpy (path2, tmp);
+                   _tcscpy (path2, tmp);
                else
-                   sprintf (path2, "%suae_data%c", start_path_data, FSDB_DIR_SEPARATOR);
-               sprintf (tmp, "%sdrive_click_%s",
+                   _stprintf (path2, L"%suae_data%c", start_path_data, FSDB_DIR_SEPARATOR);
+               _stprintf (tmp, L"%sdrive_click_%s",
                    path2, currprefs.dfxclickexternal[i]);
                v = loadsample (tmp, &drvs[i][DS_CLICK]);
                if (v)
                    processclicks (&drvs[i][DS_CLICK]);
-               sprintf (tmp, "%sdrive_spin_%s",
+               _stprintf (tmp, L"%sdrive_spin_%s",
                    path2, currprefs.dfxclickexternal[i]);
                v += loadsample (tmp, &drvs[i][DS_SPIN]);
-               sprintf (tmp, "%sdrive_spinnd_%s",
+               _stprintf (tmp, L"%sdrive_spinnd_%s",
                    path2, currprefs.dfxclickexternal[i]);
                v += loadsample (tmp, &drvs[i][DS_SPINND]);
-               sprintf (tmp, "%sdrive_startup_%s",
+               _stprintf (tmp, L"%sdrive_startup_%s",
                    path2, currprefs.dfxclickexternal[i]);
                v += loadsample (tmp, &drvs[i][DS_START]);
-               sprintf (tmp, "%sdrive_snatch_%s",
+               _stprintf (tmp, L"%sdrive_snatch_%s",
                    path2, currprefs.dfxclickexternal[i]);
                v += loadsample (tmp, &drvs[i][DS_SNATCH]);
            }
@@ -458,15 +458,15 @@ void driveclick_check_prefs (void)
        currprefs.dfxclick[1] != changed_prefs.dfxclick[1] ||
        currprefs.dfxclick[2] != changed_prefs.dfxclick[2] ||
        currprefs.dfxclick[3] != changed_prefs.dfxclick[3] ||
-       strcmp (currprefs.dfxclickexternal[0], changed_prefs.dfxclickexternal[0]) ||
-       strcmp (currprefs.dfxclickexternal[1], changed_prefs.dfxclickexternal[1]) ||
-       strcmp (currprefs.dfxclickexternal[2], changed_prefs.dfxclickexternal[2]) ||
-       strcmp (currprefs.dfxclickexternal[3], changed_prefs.dfxclickexternal[3]))
+       _tcscmp (currprefs.dfxclickexternal[0], changed_prefs.dfxclickexternal[0]) ||
+       _tcscmp (currprefs.dfxclickexternal[1], changed_prefs.dfxclickexternal[1]) ||
+       _tcscmp (currprefs.dfxclickexternal[2], changed_prefs.dfxclickexternal[2]) ||
+       _tcscmp (currprefs.dfxclickexternal[3], changed_prefs.dfxclickexternal[3]))
     {
        currprefs.dfxclickvolume = changed_prefs.dfxclickvolume;
        for (i = 0; i < 4; i++) {
            currprefs.dfxclick[i] = changed_prefs.dfxclick[i];
-           strcpy (currprefs.dfxclickexternal[i], changed_prefs.dfxclickexternal[i]);
+           _tcscpy (currprefs.dfxclickexternal[i], changed_prefs.dfxclickexternal[i]);
        }
        driveclick_init ();
     }
index 1c118a0a84458b16de4341cedf21affab2fa6db1..6d0d5a4edde2e44e393b9a949571d2ba37544b63 100644 (file)
@@ -46,7 +46,7 @@ int enforcermode = 0;
 static int enforcer_hit = 0; /* set to 1 if displaying the hit */
 
 #define ENFORCER_BUF_SIZE 8192
-static char enforcer_buf[ENFORCER_BUF_SIZE];
+static TCHAR enforcer_buf[ENFORCER_BUF_SIZE];
 
 uae_u32 (REGPARAM3 *saved_chipmem_lget) (uaecptr addr);
 uae_u32 (REGPARAM3 *saved_chipmem_wget) (uaecptr addr);
@@ -111,7 +111,7 @@ static uae_u8 *amiga2native (uae_u32 aptr, int size)
 /*************************************************************
  Writes the Hunk and Offset of the given Address into buf
 *************************************************************/
-static int enforcer_decode_hunk_and_offset (char *buf, uae_u32 pc)
+static int enforcer_decode_hunk_and_offset (TCHAR *buf, uae_u32 pc)
 {
     uae_u32 sysbase = get_long (4);
     uae_u32 semaphore_list = sysbase + 532;
@@ -154,16 +154,19 @@ static int enforcer_decode_hunk_and_offset (char *buf, uae_u32 pc)
 
                if (pc > address && pc < address + size) {
                    uae_u32 name, offset;
-                   uae_u8 *native_name;
+                   TCHAR *native_name;
 
                    offset = pc - address - 4;
                    name = get_long (node + 8); /* ln_Name */
                    if (name) {
-                       native_name = amiga2native(name,100);
-                       if (!native_name) native_name = "Unknown";
-                   } else native_name = "Unknown";
-
-                   sprintf (buf, "----> %08lx - \"%s\" Hunk %04lx Offset %08lx\n", pc, native_name, hunk, offset);
+                       native_name = au (amiga2native(name,100));
+                       if (!native_name)
+                           native_name = my_strdup (L"Unknown");
+                   } else {
+                       native_name = my_strdup (L"Unknown");
+                   }
+                   _stprintf (buf, L"----> %08lx - \"%s\" Hunk %04lx Offset %08lx\n", pc, native_name, hunk, offset);
+                   xfree (native_name);
                    return 1;
                }
 
@@ -179,19 +182,19 @@ static int enforcer_decode_hunk_and_offset (char *buf, uae_u32 pc)
 /*************************************************************
  Display the enforcer hit
 *************************************************************/
-static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr addr)
+static void enforcer_display_hit (const TCHAR *addressmode, uae_u32 pc, uaecptr addr)
 {
     uae_u32 a7;
     uae_u32 sysbase;
     uae_u32 this_task;
     uae_u32 task_name;
-    uae_u8 *native_task_name;
+    TCHAR *native_task_name = NULL;
     int i, j;
-    static char buf[256],instrcode[256];
-    static char lines[INSTRUCTIONLINES/2][256];
+    static TCHAR buf[256],instrcode[256];
+    static TCHAR lines[INSTRUCTIONLINES/2][256];
     static uaecptr bestpc_array[INSTRUCTIONLINES/2][5];
     static int bestpc_idxs[INSTRUCTIONLINES/2];
-    char *enforcer_buf_ptr = enforcer_buf;
+    TCHAR *enforcer_buf_ptr = enforcer_buf;
     uaecptr bestpc, pospc, nextpc, temppc;
 
     if (enforcer_hit)
@@ -207,40 +210,40 @@ static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr a
        goto end;
 
     task_name = get_long (this_task + 10); /* ln_Name */
-    native_task_name = amiga2native (task_name, 100);
+    native_task_name = au (amiga2native (task_name, 100));
     /*if (strcmp(native_task_name,"c:MCP")!=0)
       {
       Exception (0x2d,0);
       }*/
-    strcpy (enforcer_buf_ptr, "Enforcer Hit! Bad program\n");
-    enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+    _tcscpy (enforcer_buf_ptr, L"Enforcer Hit! Bad program\n");
+    enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
 
-    sprintf (buf, "Illegal %s: %08lx", addressmode, addr);
-    sprintf (enforcer_buf_ptr, "%-48sPC: %0lx\n", buf, pc);
-    enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+    _stprintf (buf, L"Illegal %s: %08lx", addressmode, addr);
+    _stprintf (enforcer_buf_ptr, L"%-48sPC: %0lx\n", buf, pc);
+    enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
 
     /* Data registers */
-    sprintf (enforcer_buf_ptr, "Data: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
+    _stprintf (enforcer_buf_ptr, L"Data: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
             m68k_dreg (&regs, 0), m68k_dreg (&regs, 1), m68k_dreg (&regs, 2), m68k_dreg (&regs, 3),
             m68k_dreg (&regs, 4), m68k_dreg (&regs, 5), m68k_dreg (&regs, 6), m68k_dreg (&regs, 7));
-    enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+    enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
 
     /* Address registers */
-    sprintf(enforcer_buf_ptr, "Addr: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
+    _stprintf (enforcer_buf_ptr, L"Addr: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
            m68k_areg (&regs, 0), m68k_areg (&regs, 1), m68k_areg (&regs, 2), m68k_areg (&regs, 3),
            m68k_areg (&regs, 4), m68k_areg (&regs, 5), m68k_areg (&regs, 6), m68k_areg (&regs, 7));
-    enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+    enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
 
     /* Stack */
     a7 = m68k_areg (&regs, 7);
     for (i = 0; i < 8 * STACKLINES; i++) {
        a7 += 4;
        if (!(i % 8)) {
-           strcpy (enforcer_buf_ptr, "Stck:");
-           enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+           _tcscpy (enforcer_buf_ptr, L"Stck:");
+           enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
        }
-       sprintf (enforcer_buf_ptr, " %08lx",get_long (a7));
-       enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+       _stprintf (enforcer_buf_ptr, L" %08lx",get_long (a7));
+       enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
 
        if (i%8 == 7)
            *enforcer_buf_ptr++ = '\n';
@@ -250,18 +253,18 @@ static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr a
     a7 = m68k_areg (&regs, 7);
     if (get_long (a7 - 4) != pc) {
        if (enforcer_decode_hunk_and_offset (buf, pc)) {
-           strcpy (enforcer_buf_ptr, buf);
-           enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+           _tcscpy (enforcer_buf_ptr, buf);
+           enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
        }
     }
 
     for (i = 0; i < BACKTRACELONGS; i++) {
        a7 += 4;
        if (enforcer_decode_hunk_and_offset (buf, get_long (a7))) {
-           int l = strlen (buf);
+           int l = _tcslen (buf);
 
            if (ENFORCER_BUF_SIZE - (enforcer_buf_ptr - enforcer_buf) > l + 256) {
-               strcpy (enforcer_buf_ptr, buf);
+               _tcscpy (enforcer_buf_ptr, buf);
                enforcer_buf_ptr += l;
            }
        }
@@ -332,30 +335,30 @@ static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr a
        }
 
        sm68k_disasm (buf, instrcode, bestpc, NULL);
-       sprintf (lines[i], "%08lx :   %-20s %s\n", bestpc, instrcode, buf);
+       _stprintf (lines[i], L"%08lx :   %-20s %s\n", bestpc, instrcode, buf);
        temppc = bestpc;
     }
 
     i--;
     for (; i >= 0; i--) {
-       strcpy (enforcer_buf_ptr, lines[i]);
-       enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+       _tcscpy (enforcer_buf_ptr, lines[i]);
+       enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
     }
 
     /* Now the instruction after the pc including the pc */
     temppc = pc;
     for (i = 0; i < (INSTRUCTIONLINES + 1) / 2; i++) {
        sm68k_disasm (buf, instrcode, temppc, &nextpc);
-       sprintf (enforcer_buf_ptr, "%08lx : %s %-20s %s\n", temppc,
-                (i == 0 ? "*" : " "), instrcode, buf);
-       enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+       _stprintf (enforcer_buf_ptr, L"%08lx : %s %-20s %s\n", temppc,
+                (i == 0 ? L"*" : L" "), instrcode, buf);
+       enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
        temppc = nextpc;
     }
 
     if (!native_task_name)
-       native_task_name = "Unknown";
-    sprintf (enforcer_buf_ptr, "Name: \"%s\"\n\n", native_task_name);
-    enforcer_buf_ptr += strlen (enforcer_buf_ptr);
+       native_task_name = L"Unknown";
+    _stprintf (enforcer_buf_ptr, L"Name: \"%s\"\n\n", native_task_name);
+    enforcer_buf_ptr += _tcslen (enforcer_buf_ptr);
 
     console_out (enforcer_buf);
     write_log (enforcer_buf);
@@ -363,6 +366,7 @@ static void enforcer_display_hit (const char *addressmode, uae_u32 pc, uaecptr a
     flashscreen = 30;
 
   end:
+    xfree (native_task_name);
     enforcer_hit = 0;
 }
 
@@ -376,7 +380,7 @@ uae_u32 REGPARAM2 chipmem_lget2 (uaecptr addr)
 
     if (ISILLEGAL (addr))
     {
-       enforcer_display_hit ("LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+       enforcer_display_hit (L"LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
        if (enforcermode & 1)
            set_special (&regs, SPCFLAG_TRAP);
     }
@@ -393,7 +397,7 @@ uae_u32 REGPARAM2 chipmem_wget2(uaecptr addr)
 
     if (ISILLEGAL (addr))
     {
-       enforcer_display_hit ("WORD READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+       enforcer_display_hit (L"WORD READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
        if (enforcermode & 1)
            set_special (&regs, SPCFLAG_TRAP);
     }
@@ -407,7 +411,7 @@ uae_u32 REGPARAM2 chipmem_bget2 (uaecptr addr)
 
     if (ISILLEGAL (addr))
     {
-       enforcer_display_hit ("BYTE READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+       enforcer_display_hit (L"BYTE READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
        if (enforcermode & 1)
            set_special (&regs, SPCFLAG_TRAP);
     }
@@ -425,7 +429,7 @@ void REGPARAM2 chipmem_lput2 (uaecptr addr, uae_u32 l)
 
     if (ISILLEGAL (addr))
     {
-       enforcer_display_hit ("LONG WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+       enforcer_display_hit (L"LONG WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
        if (enforcermode & 1)
            if (addr != 0x100)
                set_special (&regs, SPCFLAG_TRAP);
@@ -443,7 +447,7 @@ void REGPARAM2 chipmem_wput2 (uaecptr addr, uae_u32 w)
 
     if (ISILLEGAL (addr))
     {
-       enforcer_display_hit ("WORD WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+       enforcer_display_hit (L"WORD WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
        if (enforcermode & 1)
            set_special (&regs, SPCFLAG_TRAP);
     }
@@ -457,7 +461,7 @@ void REGPARAM2 chipmem_bput2 (uaecptr addr, uae_u32 b)
 
     if (ISILLEGAL (addr))
     {
-       enforcer_display_hit ("BYTE WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+       enforcer_display_hit (L"BYTE WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
        if (enforcermode & 1)
            set_special (&regs, SPCFLAG_TRAP);
     }
@@ -481,7 +485,7 @@ uae_u8 * REGPARAM2 chipmem_xlate2 (uaecptr addr)
 uae_u32 REGPARAM2 dummy_lget2 (uaecptr addr)
 {
     special_mem_r;
-    enforcer_display_hit ("LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET), addr);
+    enforcer_display_hit (L"LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET), addr);
     if (enforcermode & 1) {
        set_special (&regs, SPCFLAG_TRAP);
        return 0;
@@ -501,12 +505,12 @@ uae_u32 REGPARAM2 dummy_wget2 (uaecptr addr)
     if (addr >= 0x00F10000 && addr <= 0x00F7FFFF) {
        if (!warned_JIT_0xF10000) {
            warned_JIT_0xF10000 = 1;
-           enforcer_display_hit ("LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+           enforcer_display_hit (L"LONG READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
        }
        return 0;
     }
 #endif
-    enforcer_display_hit ("WORD READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+    enforcer_display_hit (L"WORD READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
     if (enforcermode & 1) {
        set_special (&regs, SPCFLAG_TRAP);
        return 0;
@@ -517,7 +521,7 @@ uae_u32 REGPARAM2 dummy_wget2 (uaecptr addr)
 uae_u32        REGPARAM2 dummy_bget2 (uaecptr addr)
 {
     special_mem_r;
-    enforcer_display_hit ("BYTE READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+    enforcer_display_hit (L"BYTE READ from",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
     if (enforcermode & 1) {
        set_special (&regs, SPCFLAG_TRAP);
        return 0;
@@ -528,7 +532,7 @@ uae_u32     REGPARAM2 dummy_bget2 (uaecptr addr)
 void REGPARAM2 dummy_lput2 (uaecptr addr, uae_u32 l)
 {
     special_mem_w;
-    enforcer_display_hit ("LONG WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+    enforcer_display_hit (L"LONG WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
     if (enforcermode & 1) {
        set_special (&regs, SPCFLAG_TRAP);
        return;
@@ -538,7 +542,7 @@ void REGPARAM2 dummy_lput2 (uaecptr addr, uae_u32 l)
 void REGPARAM2 dummy_wput2 (uaecptr addr, uae_u32 w)
 {
     special_mem_w;
-    enforcer_display_hit ("WORD WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+    enforcer_display_hit (L"WORD WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
     if (enforcermode & 1) {
        set_special (&regs, SPCFLAG_TRAP);
        return;
@@ -548,7 +552,7 @@ void REGPARAM2 dummy_wput2 (uaecptr addr, uae_u32 w)
 void REGPARAM2 dummy_bput2 (uaecptr addr, uae_u32 b)
 {
     special_mem_w;
-    enforcer_display_hit ("BYTE WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+    enforcer_display_hit (L"BYTE WRITE to",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
     if (enforcermode & 1) {
        set_special (&regs, SPCFLAG_TRAP);
        return;
@@ -558,7 +562,7 @@ void REGPARAM2 dummy_bput2 (uaecptr addr, uae_u32 b)
 int REGPARAM2 dummy_check2 (uaecptr addr, uae_u32 size)
 {
     special_mem_r;
-    enforcer_display_hit ("CHECK from ",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
+    enforcer_display_hit (L"CHECK from ",(uae_u32)(regs.pc_p - NMEM_OFFSET),addr);
     return 0;
 }
 
index 29e7e7350572326dcc673ed73532df4a483b3958..d74d43a62bd0d92cb013ea6647a9a1effa502dfd 100644 (file)
--- a/ersatz.c
+++ b/ersatz.c
@@ -104,7 +104,7 @@ static void ersatz_doio (void)
        break;
 
      default:
-       write_log ("Only CMD_READ supported in DoIO()\n");
+       write_log (L"Only CMD_READ supported in DoIO()\n");
        ersatz_failed ();
     }
     {
@@ -129,7 +129,7 @@ static void ersatz_init (void)
     uaecptr a;
 
     already_failed = 0;
-    write_log ("initializing kickstart replacement\n");
+    write_log (L"initializing kickstart replacement\n");
     if (disk_empty (0)) {
        already_failed = 1;
        notify_user (NUMSG_KICKREP);
@@ -171,9 +171,9 @@ static void ersatz_init (void)
     /* kickstart disk loader */
     if (get_long (0x4000) == 0x4b49434b) {
        /* a kickstart disk was found in drive 0! */
-       write_log ("Loading Kickstart rom image from Kickstart disk\n");
+       write_log (L"Loading Kickstart rom image from Kickstart disk\n");
        /* print some notes... */
-       write_log ("NOTE: if UAE crashes set CPU to 68000 and/or chipmem size to 512KB!\n");
+       write_log (L"NOTE: if UAE crashes set CPU to 68000 and/or chipmem size to 512KB!\n");
 
        /* read rom image from kickstart disk */
        put_word (request + 0x1C, 2);
@@ -255,7 +255,7 @@ void ersatz_perform (uae_u16 what)
        break;
 
      case EOP_NIMP:
-       write_log ("Unimplemented Kickstart function called\n");
+       write_log (L"Unimplemented Kickstart function called\n");
        ersatz_failed ();
 
        /* fall through */
@@ -265,7 +265,7 @@ void ersatz_perform (uae_u16 what)
 
      case EOP_OPENLIB:
      default:
-       write_log ("Internal error. Giving up.\n");
+       write_log (L"Internal error. Giving up.\n");
        ersatz_failed ();
     }
 }
index 9fe9ac5f3afa249a3aac90d5a072cda8e41984d9..6d321775a40aff5b0862e1c2b2f703917a8f413e 100644 (file)
@@ -176,13 +176,13 @@ static void REGPARAM3 expamem_bput (uaecptr, uae_u32) REGPARAM;
 addrbank expamem_bank = {
     expamem_lget, expamem_wget, expamem_bget,
     expamem_lput, expamem_wput, expamem_bput,
-    default_xlate, default_check, NULL, "Autoconfig",
+    default_xlate, default_check, NULL, L"Autoconfig",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
 };
 
 static void expamem_map_clear (void)
 {
-    write_log ("expamem_map_clear() got called. Shouldn't happen.\n");
+    write_log (L"expamem_map_clear() got called. Shouldn't happen.\n");
 }
 
 static void expamem_init_clear (void)
@@ -204,21 +204,21 @@ static void expamem_init_clear2 (void)
 static void expamem_init_last (void)
 {
     expamem_init_clear2 ();
-    write_log ("Memory map after autoconfig:\n");
+    write_log (L"Memory map after autoconfig:\n");
     memory_map_dump();
 }
 
 
 static uae_u32 REGPARAM2 expamem_lget (uaecptr addr)
 {
-    write_log ("warning: READ.L from address $%lx PC=%x\n", addr, M68K_GETPC);
+    write_log (L"warning: READ.L from address $%lx PC=%x\n", addr, M68K_GETPC);
     return (expamem_wget (addr) << 16) | expamem_wget (addr + 2);
 }
 
 static uae_u32 REGPARAM2 expamem_wget (uaecptr addr)
 {
     uae_u32 v = (expamem_bget (addr) << 8) | expamem_bget (addr + 1);
-    write_log ("warning: READ.W from address $%lx=%04x PC=%x\n", addr, v & 0xffff, M68K_GETPC);
+    write_log (L"warning: READ.W from address $%lx=%04x PC=%x\n", addr, v & 0xffff, M68K_GETPC);
     return v;
 }
 
@@ -230,7 +230,7 @@ static uae_u32 REGPARAM2 expamem_bget (uaecptr addr)
 #endif
     addr &= 0xFFFF;
     b = expamem[addr];
-    //write_log ("%08x=%02X\n", addr, b);
+    //write_log (L"%08x=%02X\n", addr, b);
     return b;
 }
 
@@ -259,7 +259,7 @@ static void REGPARAM2 expamem_lput (uaecptr addr, uae_u32 value)
 #ifdef JIT
     special_mem |= S_WRITE;
 #endif
-    write_log ("warning: WRITE.L to address $%lx : value $%lx\n", addr, value);
+    write_log (L"warning: WRITE.L to address $%lx : value $%lx\n", addr, value);
 }
 
 static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
@@ -271,7 +271,7 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
     if (ecard >= cardno)
        return;
     if (expamem_type() != zorroIII)
-       write_log ("warning: WRITE.W to address $%lx : value $%x\n", addr, value);
+       write_log (L"warning: WRITE.W to address $%lx : value $%x\n", addr, value);
     else {
        switch (addr & 0xff) {
         case 0x44:
@@ -297,8 +297,8 @@ static void REGPARAM2 expamem_wput (uaecptr addr, uae_u32 value)
                (*card_map[ecard]) ();
                ecard++;
                if (p1 != p2)
-                   write_log ("   Card %d remapped %04x0000 -> %04x0000\n", ecard, p1, p2);
-               write_log ("   Card %d (Zorro%s) done.\n", ecard, expamem_type () == 0xc0 ? "II" : "III");
+                   write_log (L"   Card %d remapped %04x0000 -> %04x0000\n", ecard, p1, p2);
+               write_log (L"   Card %d (Zorro%s) done.\n", ecard, expamem_type () == 0xc0 ? L"II" : L"III");
                if (ecard < cardno)
                    (*card_init[ecard]) ();
                else
@@ -329,7 +329,7 @@ static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
        if (expamem_type () == zorroII) {
            expamem_hi = value;
            (*card_map[ecard]) ();
-           write_log ("   Card %d (Zorro%s) done.\n", ecard + 1, expamem_type () == 0xc0 ? "II" : "III");
+           write_log (L"   Card %d (Zorro%s) done.\n", ecard + 1, expamem_type () == 0xc0 ? "II" : "III");
            ++ecard;
            if (ecard < cardno)
                (*card_init[ecard]) ();
@@ -345,7 +345,7 @@ static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value)
        break;
 
      case 0x4c:
-       write_log ("   Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type () == 0xc0 ? "II" : "III");
+       write_log (L"   Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type () == 0xc0 ? "II" : "III");
        ++ecard;
        if (ecard < cardno)
            (*card_init[ecard]) ();
@@ -373,7 +373,7 @@ static void expamem_init_cd32fmv (void)
     expamem_init_clear ();
     if (!rl)
        return;
-    write_log ("CD32 FMV ROM '%s' %d.%d\n", rl->path, rl->rd->ver, rl->rd->rev);
+    write_log (L"CD32 FMV ROM '%s' %d.%d\n", rl->path, rl->rd->ver, rl->rd->rev);
     rd = rl->rd;
     z = read_rom (&rd);
     if (z) {
@@ -471,7 +471,7 @@ static uae_u8 *REGPARAM2 fastmem_xlate (uaecptr addr)
 addrbank fastmem_bank = {
     fastmem_lget, fastmem_wget, fastmem_bget,
     fastmem_lput, fastmem_wput, fastmem_bput,
-    fastmem_xlate, fastmem_check, NULL, "Fast memory",
+    fastmem_xlate, fastmem_check, NULL, L"Fast memory",
     fastmem_lget, fastmem_wget, ABFLAG_RAM
 };
 
@@ -499,7 +499,7 @@ static uae_u32 REGPARAM2 catweasel_lget (uaecptr addr)
 #ifdef JIT
     special_mem |= S_READ;
 #endif
-    write_log ("catweasel_lget @%08X!\n",addr);
+    write_log (L"catweasel_lget @%08X!\n",addr);
     return 0;
 }
 
@@ -508,7 +508,7 @@ static uae_u32 REGPARAM2 catweasel_wget (uaecptr addr)
 #ifdef JIT
     special_mem |= S_READ;
 #endif
-    write_log ("catweasel_wget @%08X!\n",addr);
+    write_log (L"catweasel_wget @%08X!\n",addr);
     return 0;
 }
 
@@ -527,7 +527,7 @@ static void REGPARAM2 catweasel_lput (uaecptr addr, uae_u32 l)
 #ifdef JIT
     special_mem |= S_WRITE;
 #endif
-    write_log ("catweasel_lput @%08X=%08X!\n",addr,l);
+    write_log (L"catweasel_lput @%08X=%08X!\n",addr,l);
 }
 
 static void REGPARAM2 catweasel_wput (uaecptr addr, uae_u32 w)
@@ -535,7 +535,7 @@ static void REGPARAM2 catweasel_wput (uaecptr addr, uae_u32 w)
 #ifdef JIT
     special_mem |= S_WRITE;
 #endif
-    write_log ("catweasel_wput @%08X=%04X!\n",addr,w);
+    write_log (L"catweasel_wput @%08X=%04X!\n",addr,w);
 }
 
 static void REGPARAM2 catweasel_bput (uaecptr addr, uae_u32 b)
@@ -555,14 +555,14 @@ static int REGPARAM2 catweasel_check (uaecptr addr, uae_u32 size)
 
 static uae_u8 *REGPARAM2 catweasel_xlate (uaecptr addr)
 {
-    write_log ("catweasel_xlate @%08X size %08X\n", addr);
+    write_log (L"catweasel_xlate @%08X size %08X\n", addr);
     return 0;
 }
 
 static addrbank catweasel_bank = {
     catweasel_lget, catweasel_wget, catweasel_bget,
     catweasel_lput, catweasel_wput, catweasel_bput,
-    catweasel_xlate, catweasel_check, NULL, "Catweasel",
+    catweasel_xlate, catweasel_check, NULL, L"Catweasel",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -570,7 +570,7 @@ static void expamem_map_catweasel (void)
 {
     catweasel_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
     map_banks (&catweasel_bank, catweasel_start >> 16, 1, 0);
-    write_log ("Catweasel MK%d: mapped @$%lx\n", cwc.type, catweasel_start);
+    write_log (L"Catweasel MK%d: mapped @$%lx\n", cwc.type, catweasel_start);
 }
 
 static void expamem_init_catweasel (void)
@@ -660,7 +660,7 @@ static void REGPARAM2 filesys_lput (uaecptr addr, uae_u32 l)
 #ifdef JIT
     special_mem |= S_WRITE;
 #endif
-    write_log ("filesys_lput called PC=%p\n", M68K_GETPC);
+    write_log (L"filesys_lput called PC=%p\n", M68K_GETPC);
 }
 
 static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
@@ -668,7 +668,7 @@ static void REGPARAM2 filesys_wput (uaecptr addr, uae_u32 w)
 #ifdef JIT
     special_mem |= S_WRITE;
 #endif
-    write_log ("filesys_wput called PC=%p\n", M68K_GETPC);
+    write_log (L"filesys_wput called PC=%p\n", M68K_GETPC);
 }
 
 static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
@@ -681,7 +681,7 @@ static void REGPARAM2 filesys_bput (uaecptr addr, uae_u32 b)
 static addrbank filesys_bank = {
     filesys_lget, filesys_wget, filesys_bget,
     filesys_lput, filesys_wput, filesys_bput,
-    default_xlate, default_check, NULL, "Filesystem Autoconfig Area",
+    default_xlate, default_check, NULL, L"Filesystem Autoconfig Area",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
 };
 
@@ -812,13 +812,13 @@ static uae_u8 *REGPARAM2 z3fastmem2_xlate (uaecptr addr)
 addrbank z3fastmem_bank = {
     z3fastmem_lget, z3fastmem_wget, z3fastmem_bget,
     z3fastmem_lput, z3fastmem_wput, z3fastmem_bput,
-    z3fastmem_xlate, z3fastmem_check, NULL, "ZorroIII Fast RAM",
+    z3fastmem_xlate, z3fastmem_check, NULL, L"ZorroIII Fast RAM",
     z3fastmem_lget, z3fastmem_wget, ABFLAG_RAM
 };
 addrbank z3fastmem2_bank = {
     z3fastmem2_lget, z3fastmem2_wget, z3fastmem2_bget,
     z3fastmem2_lput, z3fastmem2_wput, z3fastmem2_bput,
-    z3fastmem2_xlate, z3fastmem2_check, NULL, "ZorroIII Fast RAM #2",
+    z3fastmem2_xlate, z3fastmem2_check, NULL, L"ZorroIII Fast RAM #2",
     z3fastmem2_lget, z3fastmem2_wget, ABFLAG_RAM
 };
 
@@ -837,7 +837,7 @@ static void expamem_map_fastcard (void)
 {
     fastmem_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
     map_banks (&fastmem_bank, fastmem_start >> 16, allocated_fastmem >> 16, 0);
-    write_log ("Fastcard: mapped @$%lx: %dMB fast memory\n", fastmem_start, allocated_fastmem >> 20);
+    write_log (L"Fastcard: mapped @$%lx: %dMB fast memory\n", fastmem_start, allocated_fastmem >> 20);
 }
 
 static void expamem_init_fastcard (void)
@@ -887,7 +887,7 @@ static void expamem_map_filesys (void)
 
     filesys_start = ((expamem_hi | (expamem_lo >> 4)) << 16);
     map_banks (&filesys_bank, filesys_start >> 16, 1, 0);
-    write_log ("Filesystem: mapped memory @$%lx.\n", filesys_start);
+    write_log (L"Filesystem: mapped memory @$%lx.\n", filesys_start);
     /* 68k code needs to know this. */
     a = here ();
     org (rtarea_base + 0xFFFC);
@@ -950,14 +950,14 @@ static void expamem_map_z3fastmem_2 (addrbank *bank, int *startp, uae_u32 size,
     int start = *startp;
 
     if (start != z3fs) {
-       write_log ("WARNING: Z3FAST mapping changed from $%08x to $%08x\n", start, z3fs);
+       write_log (L"WARNING: Z3FAST mapping changed from $%08x to $%08x\n", start, z3fs);
        map_banks (&dummy_bank, start >> 16, size >> 16,
                   allocated);
        *startp = z3fs;
        map_banks (bank, start >> 16, size >> 16,
                   allocated);
     }
-    write_log ("Fastmem (32bit): mapped @$%08x: %d MB Zorro III fast memory \n",
+    write_log (L"Fastmem (32bit): mapped @$%08x: %d MB Zorro III fast memory \n",
               start, allocated / 0x100000);
 }
 
@@ -1027,7 +1027,7 @@ static void expamem_map_gfxcard (void)
 {
     gfxmem_start = (expamem_hi | (expamem_lo >> 4)) << 16;
     map_banks (&gfxmem_bankx, gfxmem_start >> 16, allocated_gfxmem >> 16, allocated_gfxmem);
-    write_log ("UAEGFX-card: mapped @$%lx, %d MB RTG RAM\n", gfxmem_start, allocated_gfxmem / 0x100000);
+    write_log (L"UAEGFX-card: mapped @$%lx, %d MB RTG RAM\n", gfxmem_start, allocated_gfxmem / 0x100000);
 }
 
 static void expamem_init_gfxcard (void)
@@ -1095,9 +1095,9 @@ static void allocate_expamem (void)
        fastmem_mask = allocated_fastmem - 1;
 
        if (allocated_fastmem) {
-           fastmemory = mapped_malloc (allocated_fastmem, "fast");
+           fastmemory = mapped_malloc (allocated_fastmem, L"fast");
            if (fastmemory == 0) {
-               write_log ("Out of memory for fastmem card.\n");
+               write_log (L"Out of memory for fastmem card.\n");
                allocated_fastmem = 0;
            }
        }
@@ -1112,9 +1112,9 @@ static void allocate_expamem (void)
        z3fastmem_mask = allocated_z3fastmem - 1;
 
        if (allocated_z3fastmem) {
-           z3fastmem = mapped_malloc (allocated_z3fastmem, "z3");
+           z3fastmem = mapped_malloc (allocated_z3fastmem, L"z3");
            if (z3fastmem == 0) {
-               write_log ("Out of memory for 32 bit fast memory.\n");
+               write_log (L"Out of memory for 32 bit fast memory.\n");
                allocated_z3fastmem = 0;
            }
        }
@@ -1129,9 +1129,9 @@ static void allocate_expamem (void)
        z3fastmem2_mask = allocated_z3fastmem2 - 1;
 
        if (allocated_z3fastmem2) {
-           z3fastmem2 = mapped_malloc (allocated_z3fastmem2, "z3_2");
+           z3fastmem2 = mapped_malloc (allocated_z3fastmem2, L"z3_2");
            if (z3fastmem2 == 0) {
-               write_log ("Out of memory for 32 bit fast memory #2.\n");
+               write_log (L"Out of memory for 32 bit fast memory #2.\n");
                allocated_z3fastmem2 = 0;
            }
        }
@@ -1147,9 +1147,9 @@ static void allocate_expamem (void)
        gfxmem_mask = allocated_gfxmem - 1;
 
        if (allocated_gfxmem) {
-           gfxmemory = mapped_malloc (allocated_gfxmem, "gfx");
+           gfxmemory = mapped_malloc (allocated_gfxmem, L"gfx");
            if (gfxmemory == 0) {
-               write_log ("Out of memory for graphics card memory\n");
+               write_log (L"Out of memory for graphics card memory\n");
                allocated_gfxmem = 0;
            }
        }
@@ -1297,7 +1297,7 @@ void expamem_reset (void)
            || kickstart_version < 34))
     {
        /* warn user */
-       write_log ("Kickstart version is below 1.3!  Disabling autoconfig devices.\n");
+       write_log (L"Kickstart version is below 1.3!  Disabling autoconfig devices.\n");
        do_mount = 0;
     }
     if (need_uae_boot_rom() == 0)
@@ -1330,7 +1330,7 @@ void expamem_reset (void)
     if (currprefs.cs_cd32cd && currprefs.fastmem_size == 0 && currprefs.chipmem_size <= 0x200000) {
        int ids[] = { 23, -1 };
        struct romlist *rl = getromlistbyids (ids);
-       if (rl && !strcmp (rl->path, currprefs.cartfile)) {
+       if (rl && !_tcscmp (rl->path, currprefs.cartfile)) {
            card_init[cardno] = expamem_init_cd32fmv;
            card_map[cardno++] = expamem_map_cd32fmv;
        }
@@ -1409,9 +1409,9 @@ void expansion_init (void)
     allocate_expamem ();
 
 #ifdef FILESYS
-    filesysory = mapped_malloc (0x10000, "filesys");
+    filesysory = mapped_malloc (0x10000, L"filesys");
     if (!filesysory) {
-       write_log ("virtual memory exhausted (filesysory)!\n");
+       write_log (L"virtual memory exhausted (filesysory)!\n");
        exit (0);
     }
     filesys_bank.baseaddr = filesysory;
index f7b28570e53295d28c23f6b8f0b098d5dea5a430..5579fd56419b5193d21ba7a8fb3304f1dd6bbe73 100644 (file)
--- a/fdi2raw.c
+++ b/fdi2raw.c
 #include <assert.h>
 
 #ifdef DEBUG
-static char *datalog (uae_u8 *src, int len)
+static TCHAR *datalog (uae_u8 *src, int len)
 {
-       static char buf[1000];
+       static TCHAR buf[1000];
        static int offset;
        int i = 0, offset2;
 
        offset2 = offset;
        buf[offset++]='\'';
        while (len--) {
-               sprintf (buf + offset, "%02X", src[i]);
+               _stprintf (buf + offset, "%02X", src[i]);
                offset += 2;
                i++;
                if (i > 10) break;
@@ -70,7 +70,7 @@ static char *datalog (uae_u8 *src, int len)
        return buf + offset2;
 }
 #else
-static char *datalog (uae_u8 *src, int len) { return ""; }
+static TCHAR *datalog (uae_u8 *src, int len) { return L""; }
 #endif
 
 #ifdef DEBUG
@@ -93,7 +93,7 @@ static void fdi_free (void *p)
                return;
        size = ((int*)p)[-1];
        fdi_allocated -= size;
-       write_log ("%d freed (%d)\n", size, fdi_allocated);
+       write_log (L"%d freed (%d)\n", size, fdi_allocated);
        free ((int*)p - 1);
 }
 static void *fdi_malloc (int size)
@@ -101,7 +101,7 @@ static void *fdi_malloc (int size)
        void *p = xmalloc (size + sizeof (int));
        ((int*)p)[0] = size;
        fdi_allocated += size;
-       write_log ("%d allocated (%d)\n", size, fdi_allocated);
+       write_log (L"%d allocated (%d)\n", size, fdi_allocated);
        return (int*)p + 1;
 }
 #else
@@ -329,13 +329,13 @@ static int decode_raw_track (FDI *fdi)
 /* unknown track */
 static void zxx (FDI *fdi)
 {
-       outlog ("track %d: unknown track type 0x%02X\n", fdi->current_track, fdi->track_type);
+       outlog (L"track %d: unknown track type 0x%02X\n", fdi->current_track, fdi->track_type);
 //     return -1;
 }
 /* unsupported track */
 static void zyy (FDI *fdi)
 {
-       outlog ("track %d: unsupported track type 0x%02X\n", fdi->current_track, fdi->track_type);
+       outlog (L"track %d: unsupported track type 0x%02X\n", fdi->current_track, fdi->track_type);
 //     return -1;
 }
 /* empty track */
@@ -347,13 +347,13 @@ static void track_empty (FDI *fdi)
 /* unknown sector described type */
 static void dxx (FDI *fdi)
 {
-       outlog ("\ntrack %d: unknown sector described type 0x%02X\n", fdi->current_track, fdi->track_type);
+       outlog (L"\ntrack %d: unknown sector described type 0x%02X\n", fdi->current_track, fdi->track_type);
        fdi->err = 1;
 }
 /* unsupported sector described type */
 static void dyy (FDI *fdi)
 {
-       outlog ("\ntrack %d: unsupported sector described 0x%02X\n", fdi->current_track, fdi->track_type);
+       outlog (L"\ntrack %d: unsupported sector described 0x%02X\n", fdi->current_track, fdi->track_type);
        fdi->err = 1;
 }
 /* add position of mfm sync bit */
@@ -365,12 +365,12 @@ static void add_mfm_sync_bit (FDI *fdi)
        }
        fdi->mfmsync_buffer[fdi->mfmsync_offset++] = fdi->out;
        if (fdi->out == 0) {
-               outlog ("illegal position for mfm sync bit, offset=%d\n",fdi->out);
+               outlog (L"illegal position for mfm sync bit, offset=%d\n",fdi->out);
                fdi->err = 1;
        }
        if (fdi->mfmsync_offset >= MAX_MFM_SYNC_BUFFER) {
                fdi->mfmsync_offset = 0;
-               outlog ("mfmsync buffer overflow\n");
+               outlog (L"mfmsync buffer overflow\n");
                fdi->err = 1;
        }
        fdi->out++;
@@ -391,7 +391,7 @@ static void bit_add (FDI *fdi, int bit)
                fdi->track_dst[BIT_BYTEOFFSET] |= (1 << BIT_BITOFFSET);
        fdi->out++;
        if (fdi->out >= MAX_DST_BUFFER * 8) {
-               outlog ("destination buffer overflow\n");
+               outlog (L"destination buffer overflow\n");
                fdi->err = 1;
                fdi->out = 1;
        }
@@ -406,7 +406,7 @@ static void bit_mfm_add (FDI *fdi, int bit)
 static void bit_drop_next (FDI *fdi)
 {
        if (fdi->nextdrop > 0) {
-               outlog ("multiple bit_drop_next() called");
+               outlog (L"multiple bit_drop_next() called");
        } else if (fdi->nextdrop < 0) {
                fdi->nextdrop = 0;
                debuglog (":DNN:");
@@ -420,7 +420,7 @@ static void bit_drop_next (FDI *fdi)
 static void bit_dedrop (FDI *fdi)
 {
        if (fdi->nextdrop) {
-               outlog ("bit_drop_next called before bit_dedrop");
+               outlog (L"bit_drop_next called before bit_dedrop");
        }
        fdi->nextdrop = -1;
        debuglog (":BDD:");
@@ -620,7 +620,7 @@ static int amiga_check_track (FDI *fdi)
        uae_u8 secbuf[544];
        uae_u8 bigmfmbuf[60000];
        uae_u8 *mbuf, *mbuf2, *mend;
-       char sectable[22];
+       TCHAR sectable[22];
        uae_u8 *raw = fdi->track_dst_buffer;
        int slabel, off;
        int ok = 1;
@@ -688,13 +688,13 @@ static int amiga_check_track (FDI *fdi)
 
                trackoffs = (id & 0xff00) >> 8;
                if (trackoffs + 1 > drvsec) {
-                       outlog ("illegal sector offset %d\n",trackoffs);
+                       outlog (L"illegal sector offset %d\n",trackoffs);
                        ok = 0;
                        mbuf = mbuf2;
                        continue;
                }
                if ((id >> 24) != 0xff) {
-                       outlog ("sector %d format type %02X?\n", trackoffs, id >> 24);
+                       outlog (L"sector %d format type %02X?\n", trackoffs, id >> 24);
                        ok = 0;
                }
                chksum = odd ^ even;
@@ -713,14 +713,14 @@ static int amiga_check_track (FDI *fdi)
                even = getmfmlong (mbuf + 2 * 2);
                mbuf += 4 * 2;
                if (((odd << 1) | even) != chksum) {
-                       outlog ("sector %d header crc error\n", trackoffs);
+                       outlog (L"sector %d header crc error\n", trackoffs);
                        ok = 0;
                        mbuf = mbuf2;
                        continue;
                }
-               outlog ("sector %d header crc ok\n", trackoffs);
+               outlog (L"sector %d header crc ok\n", trackoffs);
                if (((id & 0x00ff0000) >> 16) != (uae_u32)fdi->current_track) {
-                       outlog ("illegal track number %d <> %d\n",fdi->current_track,(id & 0x00ff0000) >> 16);
+                       outlog (L"illegal track number %d <> %d\n",fdi->current_track,(id & 0x00ff0000) >> 16);
                        ok++;
                        mbuf = mbuf2;
                        continue;
@@ -743,14 +743,14 @@ static int amiga_check_track (FDI *fdi)
                }
                mbuf += 256 * 2;
                if (chksum) {
-                       outlog ("sector %d data checksum error\n",trackoffs);
+                       outlog (L"sector %d data checksum error\n",trackoffs);
                        ok = 0;
                } else if (sectable[trackoffs]) {
-                       outlog ("sector %d already found?\n", trackoffs);
+                       outlog (L"sector %d already found?\n", trackoffs);
                        mbuf = mbuf2;
                } else {
-                       outlog ("sector %d ok\n",trackoffs);
-                       if (slabel) outlog ("(non-empty sector header)\n");
+                       outlog (L"sector %d ok\n",trackoffs);
+                       if (slabel) outlog (L"(non-empty sector header)\n");
                        sectable[trackoffs] = 1;
                        secwritten++;
                        if (trackoffs == 9)
@@ -759,7 +759,7 @@ static int amiga_check_track (FDI *fdi)
        }
        for (i = 0; i < drvsec; i++) {
                if (!sectable[i]) {
-                       outlog ("sector %d missing\n", i);
+                       outlog (L"sector %d missing\n", i);
                        ok = 0;
                }
        }
@@ -1316,25 +1316,25 @@ static int handle_sectors_described_track (FDI *fdi)
        fdi->index_offset = get_u32(fdi->track_src);
        fdi->index_offset >>= 8;
        fdi->track_src += 3;
-       outlog ("sectors_described, index offset: %d\n",fdi->index_offset);
+       outlog (L"sectors_described, index offset: %d\n",fdi->index_offset);
 
        do {
                fdi->track_type = *fdi->track_src++;
-               outlog ("%06X %06X %02X:",fdi->track_src - start_src + 0x200, fdi->out/8, fdi->track_type);
+               outlog (L"%06X %06X %02X:",fdi->track_src - start_src + 0x200, fdi->out/8, fdi->track_type);
                oldout = fdi->out;
                decode_sectors_described_track[fdi->track_type](fdi);
-               outlog (" %d\n", fdi->out - oldout);
+               outlog (L" %d\n", fdi->out - oldout);
                oldout = fdi->out;
                if (fdi->out < 0 || fdi->err) {
-                       outlog ("\nin %d bytes, out %d bits\n", fdi->track_src - fdi->track_src_buffer, fdi->out);
+                       outlog (L"\nin %d bytes, out %d bits\n", fdi->track_src - fdi->track_src_buffer, fdi->out);
                        return -1;
                }
                if (fdi->track_src - fdi->track_src_buffer >= fdi->track_src_len) {
-                       outlog ("source buffer overrun, previous type: %02X\n", fdi->track_type);
+                       outlog (L"source buffer overrun, previous type: %02X\n", fdi->track_type);
                        return -1;
                }
        } while (fdi->track_type != 0xff);
-       outlog ("\n");
+       outlog (L"\n");
        fix_mfm_sync (fdi);
        return fdi->out;
 }
@@ -1370,10 +1370,10 @@ static uae_u8 *fdi_decompress (int pulses, uae_u8 *sizep, uae_u8 *src, int *dofr
 static void dumpstream(int track, uae_u8 *stream, int len)
 {
 #if 0
-    char name[100];
+    TCHAR name[100];
     FILE *f;
 
-    sprintf (name, "track_%d.raw", track);
+    _stprintf (name, "track_%d.raw", track);
     f = fopen(name, "wb");
     fwrite (stream, 1, len * 4, f);
     fclose (f);
@@ -1438,7 +1438,7 @@ static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u3
                || (avgp[i] < (standard_MFM_2_bit_cell_size - (standard_MFM_2_bit_cell_size / 4))) ) )
                        i++;
        if (i == pulses)  {
-               outlog ("No stable and long-enough pulse in track.\n");
+               outlog (L"No stable and long-enough pulse in track.\n");
                return;
        }
        i--;
@@ -1566,7 +1566,7 @@ static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u3
                || (minp[i] < (standard_MFM_2_bit_cell_size - (standard_MFM_2_bit_cell_size / 4))) ) )
                        i++;
        if (i == pulses)  {
-               outlog ("FDI: No stable and long-enough pulse in track.\n");
+               outlog (L"FDI: No stable and long-enough pulse in track.\n");
                return;
        }
        nexti = i;
@@ -1644,12 +1644,12 @@ static void fdi2_decode (FDI *fdi, unsigned long totalavg, uae_u32 *avgp, uae_u3
                                }
                                avg_pulse += jitter;
                                if ((avg_pulse < min_pulse) || (avg_pulse > max_pulse)) {
-                                       outlog ("FDI: avg_pulse outside bounds! avg=%u min=%u max=%u\n", avg_pulse, min_pulse, max_pulse);
-                                       outlog ("FDI: avgp=%u (%u) minp=%u (%u) maxp=%u (%u) jitter=%d i=%d ni=%d\n",
+                                       outlog (L"FDI: avg_pulse outside bounds! avg=%u min=%u max=%u\n", avg_pulse, min_pulse, max_pulse);
+                                       outlog (L"FDI: avgp=%u (%u) minp=%u (%u) maxp=%u (%u) jitter=%d i=%d ni=%d\n",
                                                avgp[i], avgp[nexti], minp[i], minp[nexti], maxp[i], maxp[nexti], jitter, i, nexti);
                                }
                                if (avg_pulse < ref_pulse)
-                                       outlog ("FDI: avg_pulse < ref_pulse! (%u < %u)\n", avg_pulse, ref_pulse);
+                                       outlog (L"FDI: avg_pulse < ref_pulse! (%u < %u)\n", avg_pulse, ref_pulse);
                                pulse += avg_pulse - ref_pulse;
                                ref_pulse = 0;
                                if (i == eodat)
@@ -1943,7 +1943,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache)
        return 1;
 }
 
-static unsigned char fdiid[]={"Formatted Disk Image file"};
+static uae_char fdiid[] = {"Formatted Disk Image file"};
 static int bit_rate_table[16] = { 125,150,250,300,500,1000 };
 
 void fdi2raw_header_free (FDI *fdi)
@@ -2033,7 +2033,7 @@ FDI *fdi2raw_header(struct zfile *f)
                uae_u32 crc = get_crc32(fdi->header, 508);
                uae_u32 crc2 = (fdi->header[508] << 24) | (fdi->header[509] << 16) | (fdi->header[510] << 8) | fdi->header[511];
                if (crc != crc2) {
-                       outlog ("FDI: header checksum error\n");
+                       outlog (L"FDI: header checksum error\n");
                        fdi_free(fdi);
                        return NULL;
                }
@@ -2047,7 +2047,7 @@ FDI *fdi2raw_header(struct zfile *f)
        fdi->last_track = ((fdi->header[142] << 8) + fdi->header[143]) + 1;
        fdi->last_track *= fdi->header[144] + 1;
        if (fdi->last_track >= MAX_TRACKS) {
-               write_log ("FDI: last_track >= MAX_TRACKS (%d >= %d)\n", fdi->last_track, MAX_TRACKS);
+               write_log (L"FDI: last_track >= MAX_TRACKS (%d >= %d)\n", fdi->last_track, MAX_TRACKS);
                fdi->last_track = MAX_TRACKS - 1;
        }
        fdi->last_head = fdi->header[144];
@@ -2055,8 +2055,8 @@ FDI *fdi2raw_header(struct zfile *f)
        fdi->rotation_speed = fdi->header[146] + 128;
        fdi->write_protect = fdi->header[147] & 1;
        fdi->reversed_side = (fdi->header[147] & 4) ? 1 : 0;
-       outlog ("FDI version %d.%d\n", fdi->header[140], fdi->header[141]);
-       outlog ("last_track=%d rotation_speed=%d\n", fdi->last_track, fdi->rotation_speed);
+       outlog (L"FDI version %d.%d\n", fdi->header[140], fdi->header[141]);
+       outlog (L"last_track=%d rotation_speed=%d\n", fdi->last_track, fdi->rotation_speed);
 
        offset = 512;
        i = fdi->last_track;
index 23ebe03c669e473dd1a4c75ea8f5739da93d5887..06883177cffb454361789e251b4974884cd2e112 100644 (file)
--- a/filesys.c
+++ b/filesys.c
 
 static uae_sem_t test_sem;
 
+static char *ua_fs (const TCHAR *src)
+{
+    return uacp (src, currprefs.win32_fscodepage);
+}
+static TCHAR *au_fs (const char *src)
+{
+    return aucp (src, currprefs.win32_fscodepage);
+}
+static TCHAR *au_fs_copy (TCHAR *dst, int maxlen, const char *src)
+{
+    return aucp_copy (dst, maxlen, src, currprefs.win32_fscodepage);
+}
+static char *ua_fs_copy (char *dst, int maxlen, const TCHAR *src)
+{
+    return uacp_copy (dst, maxlen, src, currprefs.win32_fscodepage);
+}
+
 static void aino_test (a_inode *aino)
 {
 #ifdef AINO_DEBUG
@@ -71,12 +88,12 @@ static void aino_test (a_inode *aino)
        if (!aino || !aino->next)
            return;
        if ((aino->checksum1 ^ aino->checksum2) != 0xaaaa5555) {
-           write_log ("PANIC: corrupted or freed but used aino detected!", aino);
+           write_log (L"PANIC: corrupted or freed but used aino detected!", aino);
        }
        aino3 = aino;
        aino = aino->next;
        if (aino->prev != aino3) {
-           write_log ("PANIC: corrupted aino linking!\n");
+           write_log (L"PANIC: corrupted aino linking!\n");
            break;
        }
        if (aino == aino2) break;
@@ -106,14 +123,14 @@ static int automountunit = -1;
 
 typedef struct {
     int open;
-    char *devname; /* device name, e.g. UAE0: */
+    TCHAR *devname; /* device name, e.g. UAE0: */
     uaecptr devname_amiga;
     uaecptr startup;
-    char *volname; /* volume name, e.g. CDROM, WORK, etc. */
+    TCHAR *volname; /* volume name, e.g. CDROM, WORK, etc. */
     int volflags; /* volume flags, readonly, stream uaefsdb support */
-    char *rootdir; /* root native directory/hdf. empty drive if invalid path */
+    TCHAR *rootdir; /* root native directory/hdf. empty drive if invalid path */
     struct zvolume *zarchive;
-    char *rootdirdiff; /* "diff" file/directory */
+    TCHAR *rootdirdiff; /* "diff" file/directory */
     int readonly; /* disallow write access? */
     int bootpri; /* boot priority. -128 = no autoboot, -129 = no mount */
     int devno;
@@ -139,7 +156,7 @@ typedef struct {
     int rdb_cylblocks;
     uae_u8 *rdb_filesysstore;
     int rdb_filesyssize;
-    char *filesysdir;
+    TCHAR *filesysdir;
 
 } UnitInfo;
 
@@ -237,7 +254,7 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *
        ui = &uitmp;
        if (!uci->ishdf) {
            mi->ismounted = 1;
-           if (uci->rootdir && strlen(uci->rootdir) == 0)
+           if (uci->rootdir && _tcslen(uci->rootdir) == 0)
                return FILESYS_VIRTUAL;
            if (my_existsfile (uci->rootdir)) {
                mi->ismedia = 1;
@@ -286,19 +303,19 @@ int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo *
     return FILESYS_HARDFILE;
 }
 
-static void stripsemicolon(char *s)
+static void stripsemicolon (TCHAR *s)
 {
     if (!s)
        return;
-    while(strlen(s) > 0 && s[strlen(s) - 1] == ':')
-       s[strlen(s) - 1] = 0;
+    while(_tcslen(s) > 0 && s[_tcslen(s) - 1] == ':')
+       s[_tcslen(s) - 1] = 0;
 }
 
-char *filesys_createvolname (const char *volname, const char *rootdir, const char *def)
+TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const TCHAR *def)
 {
-    char *nvol = NULL;
+    TCHAR *nvol = NULL;
     int i, archivehd;
-    char *p = NULL;
+    TCHAR *p = NULL;
 
     archivehd = -1;
     if (my_existsfile (rootdir))
@@ -306,16 +323,16 @@ char *filesys_createvolname (const char *volname, const char *rootdir, const cha
     else if (my_existsdir (rootdir))
         archivehd = 0;
 
-    if ((!volname || strlen (volname) == 0) && rootdir && archivehd >= 0) {
+    if ((!volname || _tcslen (volname) == 0) && rootdir && archivehd >= 0) {
        p = my_strdup (rootdir);
-       for (i = strlen (p) - 1; i >= 0; i--) {
-           char c = p[i];
+       for (i = _tcslen (p) - 1; i >= 0; i--) {
+           TCHAR c = p[i];
            if (c == ':' || c == '/' || c == '\\') {
-               if (i == strlen (p) - 1)
+               if (i == _tcslen (p) - 1)
                    continue;
-               if (!strcmp (p + i, ":\\")) {
+               if (!_tcscmp (p + i, L":\\")) {
                    xfree (p);
-                   p = xmalloc (10);
+                   p = xmalloc (10 * sizeof (TCHAR));
                    p[0] = rootdir[0];
                    p[1] = 0;
                    i = 0;
@@ -329,31 +346,31 @@ char *filesys_createvolname (const char *volname, const char *rootdir, const cha
            nvol = my_strdup (p + i);
     }
     if (!nvol && archivehd >= 0) {
-       char *s = NULL;
-       if (volname && strlen(volname) > 0)
+       TCHAR *s = NULL;
+       if (volname && _tcslen (volname) > 0)
            nvol = my_strdup (volname);
        else
            nvol = my_strdup (def);
     }
     if (!nvol) {
-       if (volname && strlen (volname))
+       if (volname && _tcslen (volname))
            nvol = my_strdup (volname);
        else
-           nvol = my_strdup ("");
+           nvol = my_strdup (L"");
     }
     stripsemicolon (nvol);
     xfree (p);
     return nvol;
 }
 
-static int set_filesys_volume(const char *rootdir, int *flags, int *readonly, int *emptydrive, struct zvolume **zvp)
+static int set_filesys_volume (const TCHAR *rootdir, int *flags, int *readonly, int *emptydrive, struct zvolume **zvp)
 {
     *emptydrive = 0;
     if (my_existsfile(rootdir)) {
        struct zvolume *zv;
        zv = zfile_fopen_archive(rootdir);
        if (!zv) {
-           write_log ("'%s' is not a supported archive file\n", rootdir);
+           write_log (L"'%s' is not a supported archive file\n", rootdir);
            return -1;
        }
        *zvp = zv;
@@ -363,11 +380,11 @@ static int set_filesys_volume(const char *rootdir, int *flags, int *readonly, in
        *flags = my_getvolumeinfo (rootdir);
        if (*flags < 0) {
            if (rootdir && rootdir[0])
-               write_log ("directory '%s' not found, mounting as empty drive\n", rootdir);
+               write_log (L"directory '%s' not found, mounting as empty drive\n", rootdir);
            *emptydrive = 1;
            *flags = 0;
        } else if ((*flags) & MYVOLUMEINFO_READONLY) {
-           write_log ("'%s' set to read-only\n", rootdir);
+           write_log (L"'%s' set to read-only\n", rootdir);
            *readonly = 1;
        }
     }
@@ -375,10 +392,10 @@ static int set_filesys_volume(const char *rootdir, int *flags, int *readonly, in
 }
 
 static int set_filesys_unit_1 (int nr,
-                                char *devname, char *volname, const char *rootdir, int readonly,
+                                TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, int readonly,
                                 int secspertrack, int surfaces, int reserved,
                                 int blocksize, int bootpri, int donotmount, int autoboot,
-                                char *filesysdir, int hdc, int flags)
+                                TCHAR *filesysdir, int hdc, int flags)
 {
     UnitInfo *ui;
     int i;
@@ -392,7 +409,7 @@ static int set_filesys_unit_1 (int nr,
                break;
        }
        if (nr == MAX_FILESYSTEM_UNITS) {
-           write_log ("No slot allocated for this unit\n");
+           write_log (L"No slot allocated for this unit\n");
            return -1;
        }
     }
@@ -400,8 +417,8 @@ static int set_filesys_unit_1 (int nr,
     for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
        if (nr == i || !mountinfo.ui[i].open)
            continue;
-       if (rootdir && strlen(rootdir) > 0 && !strcmpi (mountinfo.ui[i].rootdir, rootdir)) {
-           write_log ("directory/hardfile '%s' already added\n", rootdir);
+       if (rootdir && _tcslen (rootdir) > 0 && !_tcsicmp (mountinfo.ui[i].rootdir, rootdir)) {
+           write_log (L"directory/hardfile '%s' already added\n", rootdir);
            return -1;
        }
     }
@@ -416,7 +433,7 @@ static int set_filesys_unit_1 (int nr,
            if (set_filesys_volume (rootdir, &flags, &readonly, &emptydrive, &ui->zarchive) < 0)
                return -1;
        }
-        ui->volname = filesys_createvolname (volname, rootdir, "harddrive");
+        ui->volname = filesys_createvolname (volname, rootdir, L"harddrive");
        ui->volflags = flags;
     } else {
        ui->hf.secspertrack = secspertrack;
@@ -433,21 +450,21 @@ static int set_filesys_unit_1 (int nr,
        ui->hf.readonly = readonly;
        if (!ui->hf.drive_empty) {
            if (ui->hf.handle_valid == 0) {
-               write_log ("Hardfile %s not found\n", ui->hf.device_name);
+               write_log (L"Hardfile %s not found\n", ui->hf.device_name);
                goto err;
            }
            if ((ui->hf.blocksize & (ui->hf.blocksize - 1)) != 0 || ui->hf.blocksize == 0) {
-               write_log ("Hardfile %s bad blocksize\n", ui->hf.device_name);
+               write_log (L"Hardfile %s bad blocksize\n", ui->hf.device_name);
                goto err;
            }
            if ((ui->hf.secspertrack || ui->hf.surfaces || ui->hf.reservedblocks) &&
                (ui->hf.secspertrack < 1 || ui->hf.surfaces < 1 || ui->hf.surfaces > 1023 ||
                ui->hf.reservedblocks < 0 || ui->hf.reservedblocks > 1023) != 0) {
-                   write_log ("Hardfile %s bad hardfile geometry\n", ui->hf.device_name);
+                   write_log (L"Hardfile %s bad hardfile geometry\n", ui->hf.device_name);
                    goto err;
            }
            if (ui->hf.blocksize > ui->hf.virtsize || ui->hf.virtsize == 0) {
-               write_log ("Hardfile %s too small\n", ui->hf.device_name);
+               write_log (L"Hardfile %s too small\n", ui->hf.device_name);
                goto err;
            }
            ui->hf.nrcyls = (int)(ui->hf.secspertrack * ui->hf.surfaces ? (ui->hf.virtsize / ui->hf.blocksize) / (ui->hf.secspertrack * ui->hf.surfaces) : 0);
@@ -480,10 +497,10 @@ err:
 }
 
 static int set_filesys_unit (int nr,
-                       char *devname, char *volname, const char *rootdir, int readonly,
+                       TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, int readonly,
                        int secspertrack, int surfaces, int reserved,
                        int blocksize, int bootpri, int donotmount, int autoboot,
-                       char *filesysdir, int hdc, int flags)
+                       TCHAR *filesysdir, int hdc, int flags)
 {
     int ret;
 
@@ -493,10 +510,10 @@ static int set_filesys_unit (int nr,
     return ret;
 }
 
-static int add_filesys_unit (char *devname, char *volname, const char *rootdir, int readonly,
+static int add_filesys_unit (TCHAR *devname, TCHAR *volname, const TCHAR *rootdir, int readonly,
                        int secspertrack, int surfaces, int reserved,
                        int blocksize, int bootpri, int donotmount, int autoboot,
-                       char *filesysdir, int hdc, int flags)
+                       TCHAR *filesysdir, int hdc, int flags)
 {
     int ret;
 
@@ -586,19 +603,19 @@ static void initialize_mountinfo(void)
            gayle_add_pcmcia_sram_unit (uci->rootdir, uci->readonly);
        }
     }
-    filesys_addexternals();
+    filesys_addexternals ();
 }
 
 
-int sprintf_filesys_unit (char *buffer, int num)
+int sprintf_filesys_unit (TCHAR *buffer, int num)
 {
     UnitInfo *uip = mountinfo.ui;
 
     if (uip[num].volname != 0)
-       sprintf (buffer, "(DH%d:) Filesystem, %s: %s %s", num, uip[num].volname,
+       _stprintf (buffer, L"(DH%d:) Filesystem, %s: %s %s", num, uip[num].volname,
                 uip[num].rootdir, uip[num].readonly ? "ro" : "");
     else
-       sprintf (buffer, "(DH%d:) Hardfile, \"%s\", size %d Mbytes", num,
+       _stprintf (buffer, L"(DH%d:) Hardfile, \"%s\", size %d Mbytes", num,
        uip[num].rootdir, uip[num].hf.virtsize / (1024 * 1024));
     return 0;
 }
@@ -631,10 +648,24 @@ struct hardfiledata *get_hardfile_data (int nr)
 #define dp_Arg4 32
 #define dp_Arg5 36
 
+#define DP64_INIT       -3L
+
+#define dp64_Type 8
+#define dp64_Res0 12
+#define dp64_Res2 16
+#define dp64_Res1 24
+#define dp64_Arg1 32
+#define dp64_Arg2 40
+#define dp64_Arg3 48
+#define dp64_Arg4 52
+#define dp64_Arg5 56
+
 /* result codes */
 #define DOS_TRUE ((unsigned long)-1L)
 #define DOS_FALSE (0L)
 
+#define MAXFILESIZE32 (0x7fffffff)
+
 /* Passed as type to Lock() */
 #define SHARED_LOCK    -2  /* File is readable by others */
 #define ACCESS_READ    -2  /* Synonym */
@@ -692,6 +723,11 @@ struct hardfiledata *get_hardfile_data (int nr)
 #define ACTION_ADD_NOTIFY      4097
 #define ACTION_REMOVE_NOTIFY   4098
 
+#define ACTION_CHANGE_FILE_POSITION64  8001
+#define ACTION_GET_FILE_POSITION64     8002
+#define ACTION_CHANGE_FILE_SIZE64      8003
+#define ACTION_GET_FILE_SIZE64         8004
+
 #define DISK_TYPE              0x444f5301 /* DOS\1 */
 
 typedef struct {
@@ -707,7 +743,7 @@ typedef struct key {
     a_inode *aino;
     uae_u32 uniq;
     void *fd;
-    off_t file_pos;
+    uae_u64 file_pos;
     int dosmode;
     int createmode;
     int notifyactive;
@@ -716,14 +752,14 @@ typedef struct key {
 typedef struct notify {
     struct notify *next;
     uaecptr notifyrequest;
-    char *fullname;
-    char *partname;
+    TCHAR *fullname;
+    TCHAR *partname;
 } Notify;
 
 typedef struct exallkey {
     uae_u32 id;
     void *dirhandle;
-    char *fn;
+    TCHAR *fn;
     uaecptr control;
 } ExAllKey;
 
@@ -750,7 +786,7 @@ typedef struct _unit {
     /* Native stuff */
     uae_s32 unit;      /* unit number */
     UnitInfo ui;       /* unit startup info */
-    char tmpbuf3[256];
+    TCHAR tmpbuf3[256];
 
     /* Dummy message processing */
     uaecptr dummy_message;
@@ -786,8 +822,8 @@ typedef struct _unit {
     struct zvolume *zarchive;
 
     int reinsertdelay;
-    char *newvolume;
-    char *newrootdir;
+    TCHAR *newvolume;
+    TCHAR *newrootdir;
     int newreadonly;
     int newflags;
 
@@ -807,22 +843,37 @@ typedef uae_u8 *dpacket;
 #define GET_PCK_ARG4(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg4))))
 #define GET_PCK_ARG5(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp_Arg5))))
 
-static int flush_cache(Unit *unit, int num);
+#define PUT_PCK64_RES0(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp64_Res0), (v)); } while (0)
+#define PUT_PCK64_RES1(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp64_Res1), ((v) >> 32)); do_put_mem_long ((uae_u32 *)((p) + dp64_Res1 + 4), ((uae_u32)v)); } while (0)
+#define PUT_PCK64_RES2(p,v) do { do_put_mem_long ((uae_u32 *)((p) + dp64_Res2), (v)); } while (0)
 
-static char *char1 (uaecptr addr)
+#define GET_PCK64_TYPE(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Type))))
+#define GET_PCK64_RES0(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Res0))))
+#define GET_PCK64_RES1(p) ( (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Res1)))) << 32) | (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Res1 + 4)))) << 0) )
+#define GET_PCK64_ARG1(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg1))))
+#define GET_PCK64_ARG2(p) ( (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg2)))) << 32) | (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg2 + 4)))) << 0) )
+#define GET_PCK64_ARG3(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg3))))
+#define GET_PCK64_ARG4(p) ((uae_s32)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg4))))
+#define GET_PCK64_ARG5(p) ( (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg5)))) << 32) | (((uae_s64)(do_get_mem_long ((uae_u32 *)((p) + dp64_Arg5 + 4)))) << 0) )
+
+static int flush_cache (Unit *unit, int num);
+
+static TCHAR *char1 (uaecptr addr)
 {
-    static char buf[1024];
+    static uae_char buf[1024];
+    static TCHAR bufx[1024];
     unsigned int i = 0;
     do {
        buf[i] = get_byte (addr);
        addr++;
-    } while (buf[i++] && i < sizeof(buf));
-    return buf;
+    } while (buf[i++] && i < sizeof (buf));
+    return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf);
 }
 
-static char *bstr1 (uaecptr addr)
+static TCHAR *bstr1 (uaecptr addr)
 {
-    static char buf[256];
+    static TCHAR bufx[256];
+    static uae_char buf[256];
     int i;
     int n = get_byte (addr);
     addr++;
@@ -830,24 +881,26 @@ static char *bstr1 (uaecptr addr)
     for (i = 0; i < n; i++, addr++)
        buf[i] = get_byte (addr);
     buf[i] = 0;
-    return buf;
+    return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf);
 }
 
-static char *bstr (Unit *unit, uaecptr addr)
+static TCHAR *bstr (Unit *unit, uaecptr addr)
 {
     int i;
     int n = get_byte (addr);
+    uae_char buf[256];
 
     addr++;
     for (i = 0; i < n; i++, addr++)
-       unit->tmpbuf3[i] = get_byte (addr);
-    unit->tmpbuf3[i] = 0;
+       buf[i] = get_byte (addr);
+    buf[i] = 0;
+    au_fs_copy (unit->tmpbuf3, sizeof (unit->tmpbuf3) / sizeof (TCHAR), buf);
     return unit->tmpbuf3;
 }
 
-static char *bstr_cut (Unit *unit, uaecptr addr)
+static TCHAR *bstr_cut (Unit *unit, uaecptr addr)
 {
-    char *p = unit->tmpbuf3;
+    TCHAR *p = unit->tmpbuf3;
     int i, colon_seen = 0;
     int n = get_byte (addr);
 
@@ -876,7 +929,7 @@ find_unit (uaecptr port)
 }
 
 
-static void *fs_opendir (Unit *u, const char *nname)
+static void *fs_opendir (Unit *u, const TCHAR *nname)
 {
     if (u->volflags & MYVOLUMEINFO_ARCHIVE)
        return zfile_opendir_archive (nname);
@@ -890,7 +943,7 @@ static void fs_closedir (Unit *u, void *d)
     else
        my_closedir (d);
 }
-static void *fs_open (Unit *unit, const char *name, int flags)
+static void *fs_open (Unit *unit, const TCHAR *name, int flags)
 {
     int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
     if (isarch)
@@ -914,7 +967,7 @@ static unsigned int fs_read (Unit *unit, void *d, void *b, unsigned int size)
     else
        return my_read (d, b, size);
 }
-static unsigned int fs_lseek (Unit *unit, void *d, unsigned int offset, int whence)
+static uae_u64 fs_lseek64 (Unit *unit, void *d, uae_s64 offset, int whence)
 {
     int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
     if (isarch)
@@ -922,17 +975,27 @@ static unsigned int fs_lseek (Unit *unit, void *d, unsigned int offset, int when
     else
        return my_lseek (d, offset, whence);
 }
-
+static uae_u32 fs_lseek (Unit *unit, void *d, uae_s32 offset, int whence)
+{
+    int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
+    if (isarch)
+       return (uae_u32)zfile_lseek_archive (d, (uae_s32)offset, whence);
+    else
+       return (uae_u32)my_lseek (d, (uae_s32)offset, whence);
+}
 static void set_volume_name (Unit *unit)
 {
     int namelen;
     int i;
+    char *s;
 
-    namelen = strlen (unit->ui.volname);
+    s = ua_fs (unit->ui.volname);
+    namelen = strlen (s);
     put_byte (unit->volume + 44, namelen);
     for (i = 0; i < namelen; i++)
-       put_byte (unit->volume + 45 + i, unit->ui.volname[i]);
+       put_byte (unit->volume + 45 + i, s[i]);
     put_byte (unit->volume + 45 + namelen, 0);
+    xfree (s);
     unit->rootnode.aname = unit->ui.volname;
     unit->rootnode.nname = unit->ui.rootdir;
     unit->rootnode.mountcount = unit->mountcount;
@@ -990,10 +1053,10 @@ int filesys_eject (int nr)
     zfile_fclose_archive (u->zarchive);
     u->zarchive = NULL;
     u->mountcount++;
-    write_log ("FILESYS: removed volume '%s'\n", u->ui.volname);
+    write_log (L"FILESYS: removed volume '%s'\n", u->ui.volname);
     flush_cache (u, -1);
     put_byte (u->volume + 172 - 32, -2);
-    uae_Signal (get_long(u->volume + 176 - 32), 1 << 13);
+    uae_Signal (get_long (u->volume + 176 - 32), 1 << 13);
     return 1;
 }
 
@@ -1014,7 +1077,7 @@ void filesys_vsync (void)
        }
     }
 }
-static void filesys_delayed_change (Unit *u, int frames, const char *rootdir, const char *volume, int readonly, int flags)
+static void filesys_delayed_change (Unit *u, int frames, const TCHAR *rootdir, const TCHAR *volume, int readonly, int flags)
 {
     u->reinsertdelay = 50;
     u->newflags = flags;
@@ -1023,19 +1086,19 @@ static void filesys_delayed_change (Unit *u, int frames, const char *rootdir, co
     if (volume)
         u->newvolume = my_strdup (volume);
     filesys_eject(u->unit);
-    if (!rootdir || strlen (rootdir) == 0)
+    if (!rootdir || _tcslen (rootdir) == 0)
         u->reinsertdelay = 0;
     if (u->reinsertdelay > 0)
-       write_log ("FILESYS: delayed insert %d: '%s' ('%s')\n", u->unit, volume ? volume : "<none>", rootdir);
+       write_log (L"FILESYS: delayed insert %d: '%s' ('%s')\n", u->unit, volume ? volume : L"<none>", rootdir);
 }
 
-int filesys_media_change (const char *rootdir, int inserted, struct uaedev_config_info *uci)
+int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_info *uci)
 {
     Unit *u;
     UnitInfo *ui;
     int nr = -1;
-    char volname[MAX_DPATH], *volptr;
-    char devname[MAX_DPATH];
+    TCHAR volname[MAX_DPATH], *volptr;
+    TCHAR devname[MAX_DPATH];
 
     if (!mountertask)
        return 0;
@@ -1045,7 +1108,7 @@ int filesys_media_change (const char *rootdir, int inserted, struct uaedev_confi
     for (u = units; u; u = u->next) {
         if (is_hardfile (u->unit) == FILESYS_VIRTUAL) {
            ui = &mountinfo.ui[u->unit];
-           if (ui->rootdir && !memcmp (ui->rootdir, rootdir, strlen (rootdir)) && strlen (rootdir) + 3 >= strlen (ui->rootdir)) {
+           if (ui->rootdir && !memcmp (ui->rootdir, rootdir, _tcslen (rootdir)) && _tcslen (rootdir) + 3 >= _tcslen (ui->rootdir)) {
                if (filesys_isvolume (u) && inserted) {
                    if (uci)
                        filesys_delayed_change (u, 50, rootdir, uci->volname, uci->readonly, 0);
@@ -1078,12 +1141,12 @@ int filesys_media_change (const char *rootdir, int inserted, struct uaedev_confi
                volptr = NULL;
            if (ui && ui->configureddrive && ui->volname) {
                volptr = volname;
-               strcpy (volptr, ui->volname);
+               _tcscpy (volptr, ui->volname);
            }
        }
        if (!volptr) {
-           volptr = filesys_createvolname (NULL, rootdir, "removable");
-           strcpy (volname, volptr);
+           volptr = filesys_createvolname (NULL, rootdir, L"removable");
+           _tcscpy (volname, volptr);
            xfree (volptr);
            volptr = volname;
        }
@@ -1106,9 +1169,9 @@ int filesys_media_change (const char *rootdir, int inserted, struct uaedev_confi
        }
        /* nope, uh, need black magic now.. */
        if (uci)
-           strcpy (devname, uci->devname);
+           _tcscpy (devname, uci->devname);
        else
-           sprintf (devname, "RDH%d", nr_units());
+           _stprintf (devname, L"RDH%d", nr_units());
        nr = add_filesys_unit (devname, volptr, rootdir, 0, 0, 0, 0, 0, 0, 0, 1, NULL, 0, MYVOLUMEINFO_REUSABLE);
        if (nr < 0)
            return 0;
@@ -1136,7 +1199,7 @@ int hardfile_remount (int nr)
     return 1;
 }
 
-int filesys_insert (int nr, char *volume, const char *rootdir, int readonly, int flags)
+int filesys_insert (int nr, TCHAR *volume, const TCHAR *rootdir, int readonly, int flags)
 {
     struct uaedev_config_info *uci;
     int emptydrive = 0;
@@ -1190,13 +1253,13 @@ int filesys_insert (int nr, char *volume, const char *rootdir, int readonly, int
     if (emptydrive)
        return 0;
     xfree (u->ui.volname);
-    ui->volname = u->ui.volname = filesys_createvolname (volume, rootdir, "removable");
+    ui->volname = u->ui.volname = filesys_createvolname (volume, rootdir, L"removable");
     set_volume_name (u);
-    write_log ("FILESYS: inserted volume NR=%d RO=%d '%s' ('%s')\n", nr, readonly, ui->volname, rootdir);
+    write_log (L"FILESYS: inserted volume NR=%d RO=%d '%s' ('%s')\n", nr, readonly, ui->volname, rootdir);
     if (flags >= 0)
        ui->volflags = u->volflags = u->ui.volflags = flags;
-    strcpy (uci->volname, ui->volname);
-    strcpy (uci->rootdir, rootdir);
+    _tcscpy (uci->volname, ui->volname);
+    _tcscpy (uci->rootdir, rootdir);
     if (readonly >= 0)
        uci->readonly = ui->readonly = u->ui.readonly = readonly;
     put_byte (u->volume + 44, 0);
@@ -1217,7 +1280,7 @@ static int fsdb_cando (Unit *unit)
     return 0;
 }
 
-static void prepare_for_open (char *name)
+static void prepare_for_open (TCHAR *name)
 {
 #if 0
     struct stat statbuf;
@@ -1270,12 +1333,12 @@ static void free_all_ainos (Unit *u, a_inode *parent)
     }
 }
 
-static int flush_cache(Unit *unit, int num)
+static int flush_cache (Unit *unit, int num)
 {
     int i = 0;
     int cnt = 100;
 
-    write_log ("FILESYS: flushing cache unit %d (max %d items)\n", unit->unit, num);
+    write_log (L"FILESYS: flushing cache unit %d (max %d items)\n", unit->unit, num);
     if (num == 0)
        num = -1;
     while (i < num || num < 0) {
@@ -1298,7 +1361,7 @@ static int flush_cache(Unit *unit, int num)
                    aip = &aino->sibling;
                } else {
                    if (aino->shlock > 0 || aino->elock)
-                       write_log ("panic: freeing locked a_inode!\n");
+                       write_log (L"panic: freeing locked a_inode!\n");
                    de_recycle_aino (unit, aino);
                    dispose_aino (unit, aip, aino);
                    i++;
@@ -1336,15 +1399,15 @@ static void recycle_aino (Unit *unit, a_inode *new_aino)
        /* Still in use */
        return;
 
-    TRACE (("Recycling; cache size %d, total_locked %d\n",
+    TRACE ((L"Recycling; cache size %d, total_locked %d\n",
            unit->aino_cache_size, unit->total_locked_ainos));
     if (unit->aino_cache_size > 5000 + unit->total_locked_ainos) {
        /* Reap a few. */
        flush_cache (unit, 50);
 #if 0
        {
-           char buffer[40];
-           sprintf (buffer, "%d ainos reaped.\n", i);
+           TCHAR buffer[40];
+           _stprintf (buffer, "%d ainos reaped.\n", i);
            TRACE ((buffer));
        }
 #endif
@@ -1368,23 +1431,23 @@ void filesys_flush_cache (void)
 
 static void update_child_names (Unit *unit, a_inode *a, a_inode *parent)
 {
-    int l0 = strlen (parent->nname) + 2;
+    int l0 = _tcslen (parent->nname) + 2;
 
     while (a != 0) {
-       char *name_start;
-       char *new_name;
-       char dirsep[2] = { FSDB_DIR_SEPARATOR, '\0' };
+       TCHAR *name_start;
+       TCHAR *new_name;
+       TCHAR dirsep[2] = { FSDB_DIR_SEPARATOR, '\0' };
 
        a->parent = parent;
-       name_start = strrchr (a->nname, FSDB_DIR_SEPARATOR);
+       name_start = _tcsrchr (a->nname, FSDB_DIR_SEPARATOR);
        if (name_start == 0) {
-           write_log ("malformed file name");
+           write_log (L"malformed file name");
        }
        name_start++;
-       new_name = (char *)xmalloc (strlen (name_start) + l0);
-       strcpy (new_name, parent->nname);
-       strcat (new_name, dirsep);
-       strcat (new_name, name_start);
+       new_name = xmalloc ((_tcslen (name_start) + l0) * sizeof (TCHAR));
+       _tcscpy (new_name, parent->nname);
+       _tcscat (new_name, dirsep);
+       _tcscat (new_name, name_start);
        xfree (a->nname);
        a->nname = new_name;
        if (a->child)
@@ -1406,7 +1469,7 @@ static void delete_aino (Unit *unit, a_inode *aino)
 {
     a_inode **aip;
 
-    TRACE(("deleting aino %x\n", aino->uniq));
+    TRACE((L"deleting aino %x\n", aino->uniq));
 
     aino_test (aino);
     aino->dirty = 1;
@@ -1416,16 +1479,16 @@ static void delete_aino (Unit *unit, a_inode *aino)
     /* If any ExKeys are currently pointing at us, advance them.  */
     if (aino->parent->exnext_count > 0) {
        int i;
-       TRACE(("entering exkey validation\n"));
+       TRACE((L"entering exkey validation\n"));
        for (i = 0; i < EXKEYS; i++) {
            ExamineKey *k = unit->examine_keys + i;
            if (k->uniq == 0)
                continue;
            if (k->aino == aino->parent) {
-               TRACE(("Same parent found for %d\n", i));
+               TRACE((L"Same parent found for %d\n", i));
                if (k->curr_file == aino) {
                    k->curr_file = aino->sibling;
-                   TRACE(("Advancing curr_file\n"));
+                   TRACE((L"Advancing curr_file\n"));
                }
            }
        }
@@ -1435,7 +1498,7 @@ static void delete_aino (Unit *unit, a_inode *aino)
     while (*aip != aino && *aip != 0)
        aip = &(*aip)->sibling;
     if (*aip != aino) {
-       write_log ("Couldn't delete aino.\n");
+       write_log (L"Couldn't delete aino.\n");
        return;
     }
     dispose_aino (unit, aip, aino);
@@ -1493,32 +1556,32 @@ static a_inode *lookup_aino (Unit *unit, uae_u32 uniq)
     return a;
 }
 
-char *build_nname (const char *d, const char *n)
+TCHAR *build_nname (const TCHAR *d, const TCHAR *n)
 {
-    char dsep[2] = { FSDB_DIR_SEPARATOR, '\0' };
-    char *p = (char *) xmalloc (strlen (d) + strlen (n) + 2);
-    strcpy (p, d);
-    strcat (p, dsep);
-    strcat (p, n);
+    TCHAR dsep[2] = { FSDB_DIR_SEPARATOR, '\0' };
+    TCHAR *p = xmalloc ((_tcslen (d) + _tcslen (n) + 2) * sizeof (TCHAR));
+    _tcscpy (p, d);
+    _tcscat (p, dsep);
+    _tcscat (p, n);
     return p;
 }
 
-char *build_aname (const char *d, const char *n)
+TCHAR *build_aname (const TCHAR *d, const TCHAR *n)
 {
-    char *p = (char *) xmalloc (strlen (d) + strlen (n) + 2);
-    strcpy (p, d);
-    strcat (p, "/");
-    strcat (p, n);
+    TCHAR *p = xmalloc ((_tcslen (d) + _tcslen (n) + 2) * sizeof (TCHAR));
+    _tcscpy (p, d);
+    _tcscat (p, L"/");
+    _tcscat (p, n);
     return p;
 }
 
 /* This gets called to translate an Amiga name that some program used to
  * a name that we can use on the native filesystem.  */
-static char *get_nname (Unit *unit, a_inode *base, char *rel,
-                       char **modified_rel)
+static TCHAR *get_nname (Unit *unit, a_inode *base, TCHAR *rel,
+                       TCHAR **modified_rel)
 {
-    char *found;
-    char *p = 0;
+    TCHAR *found;
+    TCHAR *p = 0;
 
     *modified_rel = 0;
 
@@ -1557,9 +1620,9 @@ static char *get_nname (Unit *unit, a_inode *base, char *rel,
     return build_nname (base->nname, found);
 }
 
-static char *create_nname (Unit *unit, a_inode *base, char *rel)
+static TCHAR *create_nname (Unit *unit, a_inode *base, TCHAR *rel)
 {
-    char *p;
+    TCHAR *p;
 
     aino_test (base);
     /* We are trying to create a file called REL.  */
@@ -1571,7 +1634,7 @@ static char *create_nname (Unit *unit, a_inode *base, char *rel)
        oh_dear:
 #endif
        if (currprefs.filesys_no_uaefsdb && !(base->volflags & MYVOLUMEINFO_STREAMS)) {
-           write_log ("illegal filename '%s', no stream supporting filesystem and uaefsdb disabled\n", rel);
+           write_log (L"illegal filename '%s', no stream supporting filesystem and uaefsdb disabled\n", rel);
            return 0;
        }
        p = fsdb_create_unique_nname (base, rel);
@@ -1581,7 +1644,7 @@ static char *create_nname (Unit *unit, a_inode *base, char *rel)
 #if 0
     /* Delete this code once we know everything works.  */
     if (access (p, R_OK) >= 0 || errno != ENOENT) {
-       write_log ("Filesystem in trouble... please report.\n");
+       write_log (L"Filesystem in trouble... please report.\n");
        xfree (p);
        goto oh_dear;
     }
@@ -1589,12 +1652,12 @@ static char *create_nname (Unit *unit, a_inode *base, char *rel)
     return p;
 }
 
-static int fill_file_attrs(Unit *u, a_inode *base, a_inode *c)
+static int fill_file_attrs (Unit *u, a_inode *base, a_inode *c)
 {
     if (u->volflags & MYVOLUMEINFO_ARCHIVE) {
        int isdir, flags;
-       char *comment;
-       zfile_fill_file_attrs_archive(c->nname, &isdir, &flags, &comment);
+       TCHAR *comment;
+       zfile_fill_file_attrs_archive (c->nname, &isdir, &flags, &comment);
        c->dir = isdir;
        c->amigaos_mode = flags;
        c->comment = comment;
@@ -1616,7 +1679,7 @@ static int fill_file_attrs(Unit *u, a_inode *base, a_inode *c)
  * figure out that this is supposed to be the file "foobar.inf".
  * DOS sucks...
  */
-static char *get_aname (Unit *unit, a_inode *base, char *rel)
+static TCHAR *get_aname (Unit *unit, a_inode *base, TCHAR *rel)
 {
     return my_strdup (rel);
 }
@@ -1636,7 +1699,7 @@ static void init_child_aino (Unit *unit, a_inode *base, a_inode *aino)
 {
     aino->uniq = ++a_uniq;
     if (a_uniq == 0xFFFFFFFF) {
-       write_log ("Running out of a_inodes (prepare for big trouble)!\n");
+       write_log (L"Running out of a_inodes (prepare for big trouble)!\n");
     }
     aino->shlock = 0;
     aino->elock = 0;
@@ -1653,20 +1716,20 @@ static void init_child_aino (Unit *unit, a_inode *base, a_inode *aino)
        unit->total_locked_ainos++;
        base->locked_children++;
     }
-    init_child_aino_tree(unit, base, aino);
+    init_child_aino_tree (unit, base, aino);
 
     aino_test_init (aino);
     aino_test (aino);
 }
 
-static a_inode *new_child_aino (Unit *unit, a_inode *base, char *rel)
+static a_inode *new_child_aino (Unit *unit, a_inode *base, TCHAR *rel)
 {
-    char *modified_rel;
-    char *nn;
+    TCHAR *modified_rel;
+    TCHAR *nn;
     a_inode *aino = NULL;
     int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
 
-    TRACE(("new_child_aino %s, %s\n", base->aname, rel));
+    TRACE((L"new_child_aino %s, %s\n", base->aname, rel));
 
     if (!isarch)
        aino = fsdb_lookup_aino_aname (base, rel);
@@ -1675,7 +1738,7 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, char *rel)
        if (nn == 0)
            return 0;
 
-       aino = (a_inode *) xcalloc (sizeof (a_inode), 1);
+       aino = xcalloc (sizeof (a_inode), 1);
        if (aino == 0)
            return 0;
        aino->aname = modified_rel ? modified_rel : my_strdup (rel);
@@ -1694,13 +1757,13 @@ static a_inode *new_child_aino (Unit *unit, a_inode *base, char *rel)
     init_child_aino (unit, base, aino);
 
     recycle_aino (unit, aino);
-    TRACE(("created aino %x, lookup, amigaos_mode %d\n", aino->uniq, aino->amigaos_mode));
+    TRACE((L"created aino %x, lookup, amigaos_mode %d\n", aino->uniq, aino->amigaos_mode));
     return aino;
 }
 
-static a_inode *create_child_aino (Unit *unit, a_inode *base, char *rel, int isdir)
+static a_inode *create_child_aino (Unit *unit, a_inode *base, TCHAR *rel, int isdir)
 {
-    a_inode *aino = (a_inode *) xcalloc (sizeof (a_inode), 1);
+    a_inode *aino = xcalloc (sizeof (a_inode), 1);
     if (aino == 0)
        return 0;
 
@@ -1720,14 +1783,14 @@ static a_inode *create_child_aino (Unit *unit, a_inode *base, char *rel, int isd
     aino->dirty = 1;
 
     recycle_aino (unit, aino);
-    TRACE(("created aino %x, create\n", aino->uniq));
+    TRACE((L"created aino %x, create\n", aino->uniq));
     return aino;
 }
 
-static a_inode *lookup_child_aino (Unit *unit, a_inode *base, char *rel, uae_u32 *err)
+static a_inode *lookup_child_aino (Unit *unit, a_inode *base, TCHAR *rel, uae_u32 *err)
 {
     a_inode *c = base->child;
-    int l0 = strlen (rel);
+    int l0 = _tcslen (rel);
 
     aino_test (base);
     aino_test (c);
@@ -1738,7 +1801,7 @@ static a_inode *lookup_child_aino (Unit *unit, a_inode *base, char *rel, uae_u32
     }
 
     while (c != 0) {
-       int l1 = strlen (c->aname);
+       int l1 = _tcslen (c->aname);
        if (l0 <= l1 && same_aname (rel, c->aname + l1 - l0)
            && (l0 == l1 || c->aname[l1-l0-1] == '/') && c->mountcount == unit->mountcount)
            break;
@@ -1753,10 +1816,10 @@ static a_inode *lookup_child_aino (Unit *unit, a_inode *base, char *rel, uae_u32
 }
 
 /* Different version because for this one, REL is an nname.  */
-static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, char *rel, uae_u32 *err)
+static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, TCHAR *rel, uae_u32 *err)
 {
     a_inode *c = base->child;
-    int l0 = strlen (rel);
+    int l0 = _tcslen (rel);
     int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
 
     aino_test (base);
@@ -1764,9 +1827,9 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, char *r
 
     *err = 0;
     while (c != 0) {
-       int l1 = strlen (c->nname);
-       /* Note: using strcmp here.  */
-       if (l0 <= l1 && strcmp (rel, c->nname + l1 - l0) == 0
+       int l1 = _tcslen (c->nname);
+       /* Note: using _tcscmp here.  */
+       if (l0 <= l1 && _tcscmp (rel, c->nname + l1 - l0) == 0
            && (l0 == l1 || c->nname[l1-l0-1] == FSDB_DIR_SEPARATOR) && c->mountcount == unit->mountcount)
            break;
        c = c->sibling;
@@ -1776,7 +1839,7 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, char *r
     if (!isarch)
        c = fsdb_lookup_aino_nname (base, rel);
     if (c == 0) {
-       c = (a_inode*)xcalloc (sizeof (a_inode), 1);
+       c = xcalloc (sizeof (a_inode), 1);
        if (c == 0) {
            *err = ERROR_NO_FREE_STORE;
            return 0;
@@ -1786,7 +1849,7 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, char *r
        c->aname = get_aname (unit, base, rel);
        c->comment = 0;
        c->has_dbentry = 0;
-       if (!fill_file_attrs(unit, base, c)) {
+       if (!fill_file_attrs (unit, base, c)) {
            xfree (c);
            *err = ERROR_NO_FREE_STORE;
            return 0;
@@ -1797,22 +1860,22 @@ static a_inode *lookup_child_aino_for_exnext (Unit *unit, a_inode *base, char *r
     init_child_aino (unit, base, c);
 
     recycle_aino (unit, c);
-    TRACE(("created aino %x, exnext\n", c->uniq));
+    TRACE((L"created aino %x, exnext\n", c->uniq));
 
     return c;
 }
 
-static a_inode *get_aino (Unit *unit, a_inode *base, const char *rel, uae_u32 *err)
+static a_inode *get_aino (Unit *unit, a_inode *base, const TCHAR *rel, uae_u32 *err)
 {
-    char *tmp;
-    char *p;
+    TCHAR *tmp;
+    TCHAR *p;
     a_inode *curr;
     int i;
 
     aino_test (base);
 
     *err = 0;
-    TRACE(("get_path(%s,%s)\n", base->aname, rel));
+    TRACE((L"get_path(%s,%s)\n", base->aname, rel));
 
     /* root-relative path? */
     for (i = 0; rel[i] && rel[i] != '/' && rel[i] != ':'; i++)
@@ -1833,8 +1896,8 @@ static a_inode *get_aino (Unit *unit, a_inode *base, const char *rel, uae_u32 *e
        } else {
            a_inode *next;
 
-           char *component_end;
-           component_end = strchr (p, '/');
+           TCHAR *component_end;
+           component_end = _tcschr (p, '/');
            if (component_end != 0)
                *component_end = '\0';
            next = lookup_child_aino (unit, curr, p, err);
@@ -1858,7 +1921,7 @@ static a_inode *get_aino (Unit *unit, a_inode *base, const char *rel, uae_u32 *e
 }
 
 
-static uae_u32 notifyhash (char *s)
+static uae_u32 notifyhash (TCHAR *s)
 {
     uae_u32 hash = 0;
     while (*s)
@@ -1866,9 +1929,9 @@ static uae_u32 notifyhash (char *s)
     return hash % NOTIFY_HASH_SIZE;
 }
 
-static Notify *new_notify (Unit *unit, char *name)
+static Notify *new_notify (Unit *unit, TCHAR *name)
 {
-    Notify *n = (Notify*)xmalloc (sizeof(Notify));
+    Notify *n = xmalloc (sizeof (Notify));
     uae_u32 hash = notifyhash (name);
     n->next = unit->notifyhash[hash];
     unit->notifyhash[hash] = n;
@@ -1989,11 +2052,11 @@ static void filesys_start_thread (UnitInfo *ui, int nr)
     }
 #ifdef UAE_FILESYS_THREADS
     if (is_hardfile (nr) == FILESYS_VIRTUAL) {
-        ui->unit_pipe = (smp_comm_pipe *)xmalloc (sizeof (smp_comm_pipe));
-        ui->back_pipe = (smp_comm_pipe *)xmalloc (sizeof (smp_comm_pipe));
+        ui->unit_pipe = xmalloc (sizeof (smp_comm_pipe));
+        ui->back_pipe = xmalloc (sizeof (smp_comm_pipe));
         init_comm_pipe (ui->unit_pipe, 100, 3);
         init_comm_pipe (ui->back_pipe, 100, 1);
-        uae_start_thread ("filesys", filesys_thread, (void *)ui, &ui->tid);
+        uae_start_thread (L"filesys", filesys_thread, (void *)ui, &ui->tid);
     }
 #endif
     if (savestate_state == STATE_RESTORE)
@@ -2011,14 +2074,14 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context)
     uaecptr arg2 = get_long (pkt + dp_Arg2);
     uaecptr devnode;
     int i;
-    char* devname = bstr1 (get_long (pkt + dp_Arg1) << 2);
-    char* s;
+    TCHAR *devname = bstr1 (get_long (pkt + dp_Arg1) << 2);
+    TCHAR *s;
     Unit *unit;
     UnitInfo *uinfo;
     int late = 0;
 
     /* find UnitInfo with correct device name */
-    s = strchr (devname, ':');
+    s = _tcschr (devname, ':');
     if (s)
        *s = '\0';
 
@@ -2033,7 +2096,7 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context)
     }
 
     if (i == MAX_FILESYSTEM_UNITS) {
-       write_log ("Failed attempt to mount device '%s'\n", devname);
+       write_log (L"Failed attempt to mount device '%s'\n", devname);
        put_long (pkt + dp_Res1, DOS_FALSE);
        put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED);
        return 0;
@@ -2041,7 +2104,7 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context)
 
     if (!mountinfo.ui[i].wasisempty && !my_existsdir (mountinfo.ui[i].rootdir) && !my_existsfile (mountinfo.ui[i].rootdir))
     {
-       write_log ("Failed attempt to mount device '%s'\n", devname);
+       write_log (L"Failed attempt to mount device '%s'\n", devname);
        put_long (pkt + dp_Res1, DOS_FALSE);
        put_long (pkt + dp_Res2, ERROR_DEVICE_NOT_MOUNTED);
        return 0;
@@ -2057,7 +2120,7 @@ static uae_u32 REGPARAM2 startup_handler (TrapContext *context)
 
 /*    write_comm_pipe_int (unit->ui.unit_pipe, -1, 1);*/
 
-    write_log ("FS: %s (flags=%08X) starting..\n", unit->ui.volname, unit->volflags);
+    write_log (L"FS: %s (flags=%08X) starting..\n", unit->ui.volname, unit->volflags);
 
     /* fill in our process in the device node */
     devnode = get_long (pkt + dp_Arg3) << 2;
@@ -2128,15 +2191,15 @@ do_info (Unit *unit, dpacket packet, uaecptr info)
 static void
 action_disk_info (Unit *unit, dpacket packet)
 {
-    TRACE(("ACTION_DISK_INFO\n"));
-    do_info(unit, packet, GET_PCK_ARG1 (packet) << 2);
+    TRACE((L"ACTION_DISK_INFO\n"));
+    do_info (unit, packet, GET_PCK_ARG1 (packet) << 2);
 }
 
 static void
 action_info (Unit *unit, dpacket packet)
 {
-    TRACE(("ACTION_INFO\n"));
-    do_info(unit, packet, GET_PCK_ARG2 (packet) << 2);
+    TRACE((L"ACTION_INFO\n"));
+    do_info (unit, packet, GET_PCK_ARG2 (packet) << 2);
 }
 
 static void free_key (Unit *unit, Key *k)
@@ -2171,13 +2234,13 @@ static Key *lookup_key (Unit *unit, uae_u32 uniq)
        if (uniq == k->uniq)
            return k;
     }
-    write_log ("Error: couldn't find key %u / %u!\n", uniq, total);
+    write_log (L"Error: couldn't find key %u / %u!\n", uniq, total);
     return 0;
 }
 
 static Key *new_key (Unit *unit)
 {
-    Key *k = xmalloc (sizeof(Key));
+    Key *k = xmalloc (sizeof (Key));
     k->uniq = ++key_uniq;
     k->fd = NULL;
     k->file_pos = 0;
@@ -2191,25 +2254,25 @@ static void
 dumplock (Unit *unit, uaecptr lock)
 {
     a_inode *a;
-    TRACE(("LOCK: 0x%lx", lock));
+    TRACE((L"LOCK: 0x%lx", lock));
     if (!lock) {
-       TRACE(("\n"));
+       TRACE((L"\n"));
        return;
     }
-    TRACE(("{ next=0x%lx, mode=%ld, handler=0x%lx, volume=0x%lx, aino %lx ",
+    TRACE((L"{ next=0x%lx, mode=%ld, handler=0x%lx, volume=0x%lx, aino %lx ",
           get_long (lock) << 2, get_long (lock+8),
           get_long (lock+12), get_long (lock+16),
           get_long (lock + 4)));
     a = lookup_aino (unit, get_long (lock + 4));
     if (a == 0) {
-       TRACE(("not found!"));
+       TRACE((L"not found!"));
     } else {
-       TRACE(("%s", a->nname));
+       TRACE((L"%s", a->nname));
     }
-    TRACE((" }\n"));
+    TRACE((L" }\n"));
 }
 
-static a_inode *find_aino (Unit *unit, uaecptr lock, const char *name, uae_u32 *err)
+static a_inode *find_aino (Unit *unit, uaecptr lock, const TCHAR *name, uae_u32 *err)
 {
     a_inode *a;
 
@@ -2219,15 +2282,15 @@ static a_inode *find_aino (Unit *unit, uaecptr lock, const char *name, uae_u32 *
            /* That's the best we can hope to do. */
            a = get_aino (unit, &unit->rootnode, name, err);
        } else {
-           TRACE(("aino: 0x%08lx", (unsigned long int)olda->uniq));
-           TRACE((" \"%s\"\n", olda->nname));
+           TRACE((L"aino: 0x%08lx", (unsigned long int)olda->uniq));
+           TRACE((L" \"%s\"\n", olda->nname));
            a = get_aino (unit, olda, name, err);
        }
     } else {
        a = get_aino (unit, &unit->rootnode, name, err);
     }
     if (a) {
-       TRACE(("aino=\"%s\"\n", a->nname));
+       TRACE((L"aino=\"%s\"\n", a->nname));
     }
     aino_test (a);
     return a;
@@ -2313,9 +2376,9 @@ action_add_notify (Unit *unit, dpacket packet)
     uaecptr nr = GET_PCK_ARG1 (packet);
     int flags;
     Notify *n;
-    char *name, *p, *partname;
+    TCHAR *name, *p, *partname;
 
-    TRACE(("ACTION_ADD_NOTIFY\n"));
+    TRACE((L"ACTION_ADD_NOTIFY\n"));
 
     name = my_strdup (char1 (get_long (nr + 4)));
     flags = get_long (nr + 12);
@@ -2327,21 +2390,21 @@ action_add_notify (Unit *unit, dpacket packet)
     }
 
 #if 0
-    write_log ("Notify:\n");
-    write_log ("nr_Name '%s'\n", char1 (get_long (nr + 0)));
-    write_log ("nr_FullName '%s'\n", name);
-    write_log ("nr_UserData %08X\n", get_long (nr + 8));
-    write_log ("nr_Flags %08X\n", flags);
+    write_log (L"Notify:\n");
+    write_log (L"nr_Name '%s'\n", char1 (get_long (nr + 0)));
+    write_log (L"nr_FullName '%s'\n", name);
+    write_log (L"nr_UserData %08X\n", get_long (nr + 8));
+    write_log (L"nr_Flags %08X\n", flags);
     if (flags & NRF_SEND_MESSAGE) {
-       write_log ("Message NotifyRequest, port = %08X\n", get_long (nr + 16));
+       write_log (L"Message NotifyRequest, port = %08X\n", get_long (nr + 16));
     } else if (flags & NRF_SEND_SIGNAL) {
-       write_log ("Signal NotifyRequest, Task = %08X signal = %d\n", get_long (nr + 16), get_long (nr + 20));
+       write_log (L"Signal NotifyRequest, Task = %08X signal = %d\n", get_long (nr + 16), get_long (nr + 20));
     } else {
-       write_log ("corrupt NotifyRequest\n");
+       write_log (L"corrupt NotifyRequest\n");
     }
 #endif
 
-    p = name + strlen (name) - 1;
+    p = name + _tcslen (name) - 1;
     if (p[0] == ':')
        p--;
     while (p > name && p[0] != ':' && p[0] != '/')
@@ -2367,11 +2430,11 @@ action_remove_notify (Unit *unit, dpacket packet)
     Notify *n;
     int hash;
 
-    TRACE(("ACTION_REMOVE_NOTIFY\n"));
+    TRACE((L"ACTION_REMOVE_NOTIFY\n"));
     for (hash = 0; hash < NOTIFY_HASH_SIZE; hash++) {
        for (n = unit->notifyhash[hash]; n; n = n->next) {
            if (n->notifyrequest == nr) {
-               //write_log ("NotifyRequest %08X freed\n", n->notifyrequest);
+               //write_log (L"NotifyRequest %08X freed\n", n->notifyrequest);
                xfree (n->fullname);
                xfree (n->partname);
                free_notify (unit, hash, n);
@@ -2380,7 +2443,7 @@ action_remove_notify (Unit *unit, dpacket packet)
            }
        }
     }
-    //write_log ("Tried to free non-existing NotifyRequest %08X\n", nr);
+    //write_log (L"Tried to free non-existing NotifyRequest %08X\n", nr);
     PUT_PCK_RES1 (packet, DOS_TRUE);
 }
 
@@ -2401,7 +2464,7 @@ static void free_lock (Unit *unit, uaecptr lock)
            current = next;
        }
        if (!current) {
-           write_log ("tried to unlock non-existing lock %x\n", lock);
+           write_log (L"tried to unlock non-existing lock %x\n", lock);
            return;
        }
        put_long (current << 2, get_long (lock));
@@ -2421,11 +2484,11 @@ action_lock (Unit *unit, dpacket packet)
     uae_u32 err;
 
     if (mode != SHARED_LOCK && mode != EXCLUSIVE_LOCK) {
-       TRACE(("Bad mode %d (should be %d or %d).\n", mode, SHARED_LOCK, EXCLUSIVE_LOCK));
+       TRACE((L"Bad mode %d (should be %d or %d).\n", mode, SHARED_LOCK, EXCLUSIVE_LOCK));
        mode = SHARED_LOCK;
     }
 
-    TRACE(("ACTION_LOCK(0x%lx, \"%s\", %d)\n", lock, bstr (unit, name), mode));
+    TRACE((L"ACTION_LOCK(0x%lx, \"%s\", %d)\n", lock, bstr (unit, name), mode));
     DUMPLOCK(unit, lock);
 
     a = find_aino (unit, lock, bstr (unit, name), &err);
@@ -2450,7 +2513,7 @@ static void action_free_lock (Unit *unit, dpacket packet)
 {
     uaecptr lock = GET_PCK_ARG1 (packet) << 2;
     a_inode *a;
-    TRACE(("ACTION_FREE_LOCK(0x%lx)\n", lock));
+    TRACE((L"ACTION_FREE_LOCK(0x%lx)\n", lock));
     DUMPLOCK(unit, lock);
 
     a = lookup_aino (unit, get_long (lock + 4));
@@ -2500,7 +2563,7 @@ static void
 action_dup_lock (Unit *unit, dpacket packet)
 {
     uaecptr lock = GET_PCK_ARG1 (packet) << 2;
-    TRACE(("ACTION_DUP_LOCK(0x%lx)\n", lock));
+    TRACE((L"ACTION_DUP_LOCK(0x%lx)\n", lock));
     if (!lock) {
        PUT_PCK_RES1 (packet, 0);
        return;
@@ -2513,7 +2576,7 @@ static void
 action_lock_from_fh (Unit *unit, dpacket packet)
 {
     Key *k = lookup_key (unit, GET_PCK_ARG1 (packet));
-    TRACE(("ACTION_COPY_DIR_FH(0x%lx)\n", GET_PCK_ARG1 (packet)));
+    TRACE((L"ACTION_COPY_DIR_FH(0x%lx)\n", GET_PCK_ARG1 (packet)));
     if (k == 0) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
        return;
@@ -2556,7 +2619,7 @@ put_time (long days, long mins, long ticks)
 static void free_exkey (Unit *unit, ExamineKey *ek)
 {
     if (--ek->aino->exnext_count == 0) {
-       TRACE (("Freeing ExKey and reducing total_locked from %d by %d\n",
+       TRACE ((L"Freeing ExKey and reducing total_locked from %d by %d\n",
                unit->total_locked_ainos, ek->aino->locked_children));
        unit->total_locked_ainos -= ek->aino->locked_children;
        ek->aino->locked_children = 0;
@@ -2576,7 +2639,7 @@ static ExamineKey *lookup_exkey (Unit *unit, uae_u32 uniq)
        if (ek->uniq == uniq)
            return ek;
     }
-    write_log ("Houston, we have a BIG problem.\n");
+    write_log (L"Houston, we have a BIG problem.\n");
     return 0;
 }
 
@@ -2603,7 +2666,7 @@ static ExamineKey *new_exkey (Unit *unit, a_inode *aino)
            goto found;
     }
     /* This message should usually be harmless. */
-    write_log ("Houston, we have a problem (%s).\n", aino->nname);
+    write_log (L"Houston, we have a problem (%s).\n", aino->nname);
     free_exkey (unit, oldest_ek);
     ek = oldest_ek;
     found:
@@ -2635,7 +2698,7 @@ static void move_exkeys (Unit *unit, a_inode *from, a_inode *to)
        }
     }
     if (tmp != from->exnext_count)
-       write_log ("filesys.c: Bug in ExNext bookkeeping.  BAD.\n");
+       write_log (L"filesys.c: Bug in ExNext bookkeeping.  BAD.\n");
     to->exnext_count = from->exnext_count;
     to->locked_children = from->locked_children;
     from->exnext_count = 0;
@@ -2645,33 +2708,36 @@ static void move_exkeys (Unit *unit, a_inode *from, a_inode *to)
 static void
 get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino)
 {
-    struct stat statbuf;
+    struct _stat64 statbuf;
     long days, mins, ticks;
     int i, n, entrytype;
     int fsdb_can = fsdb_cando (unit);
-    char *x;
+    TCHAR *xs;
+    char *x, *x2;
 
-    memset(&statbuf, 0, sizeof statbuf);
+    memset (&statbuf, 0, sizeof statbuf);
     /* No error checks - this had better work. */
     if (unit->volflags & MYVOLUMEINFO_ARCHIVE)
        zfile_stat_archive (aino->nname, &statbuf);
     else
-       stat (aino->nname, &statbuf);
+       _wstat64 (aino->nname, &statbuf);
 
     if (aino->parent == 0) {
        /* Guru book says ST_ROOT = 1 (root directory, not currently used)
         * but some programs really expect 2 from root dir..
         */
        entrytype = 2;
-       x = unit->ui.volname;
+       xs = unit->ui.volname;
     } else {
        entrytype = aino->dir ? 2 : -3;
-       x = aino->aname;
+       xs = aino->aname;
     }
     put_long (info + 4, entrytype);
     /* AmigaOS docs say these have to contain the same value. */
     put_long (info + 120, entrytype);
-    TRACE(("name=\"%s\"\n", x));
+
+    TRACE((L"name=\"%s\"\n", xs));
+    x2 = x = ua_fs (xs);
     n = strlen (x);
     if (n > 106)
        n = 106;
@@ -2681,13 +2747,14 @@ get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino)
        put_byte (info + i, *x), i++, x++;
     while (i < 108)
        put_byte (info + i, 0), i++;
+    xfree (x2);
 
     put_long (info + 116, fsdb_can ? aino->amigaos_mode : fsdb_mode_supported(aino));
-    put_long (info + 124, statbuf.st_size);
+    put_long (info + 124, statbuf.st_size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.st_size);
 #ifdef HAVE_ST_BLOCKS
     put_long (info + 128, statbuf.st_blocks);
 #else
-    put_long (info + 128, statbuf.st_size / 512 + 1);
+    put_long (info + 128, (statbuf.st_size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.st_size) / 512 + 1);
 #endif
     get_time (statbuf.st_mtime, &days, &mins, &ticks);
     put_long (info + 132, days);
@@ -2696,11 +2763,12 @@ get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino)
     if (aino->comment == 0 || !fsdb_can)
        put_long (info + 144, 0);
     else {
-       TRACE(("comment=\"%s\"\n", aino->comment));
+       TRACE((L"comment=\"%s\"\n", aino->comment));
        i = 144;
-       x = aino->comment;
-       if (! x)
-           x = "";
+       xs = aino->comment;
+       if (!xs)
+           xs= L"";
+       x2 = x = ua_fs (xs);
        n = strlen (x);
        if (n > 78)
            n = 78;
@@ -2709,18 +2777,19 @@ get_fileinfo (Unit *unit, dpacket packet, uaecptr info, a_inode *aino)
            put_byte (info + i, *x), i++, x++;
        while (i < 224)
            put_byte (info + i, 0), i++;
+       xfree (x2);
     }
     PUT_PCK_RES1 (packet, DOS_TRUE);
 }
 
-int get_native_path (uae_u32 lock, char *out)
+int get_native_path (uae_u32 lock, TCHAR *out)
 {
     int i = 0;
     for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
        if (mountinfo.ui[i].self) {
            a_inode *a = lookup_aino (mountinfo.ui[i].self, get_long ((lock << 2) + 4));
            if (a) {
-               strcpy (out, a->nname);
+               _tcscpy (out, a->nname);
                return 0;
            }
        }
@@ -2760,55 +2829,59 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec
     int i;
     int size, size2;
     int entrytype;
-    char *x = NULL, *comment = NULL;
+    TCHAR *xs = NULL, *commentx = NULL;
     uae_u32 flags = 15, days, mins, ticks;
-    struct stat statbuf;
+    struct _stat64 statbuf;
     int fsdb_can = fsdb_cando (unit);
     uae_u16 uid = 0, gid = 0;
+    char *x = NULL, *comment = NULL;
+    int ret = 0;
 
     memset(&statbuf, 0, sizeof statbuf);
     if (unit->volflags & MYVOLUMEINFO_ARCHIVE)
        zfile_stat_archive (aino->nname, &statbuf);
     else
-       stat (aino->nname, &statbuf);
+       _wstat64 (aino->nname, &statbuf);
 
     if (aino->parent == 0) {
        entrytype = 2;
-       x = unit->ui.volname;
+       xs = unit->ui.volname;
     } else {
        entrytype = aino->dir ? 2 : -3;
-       x = aino->aname;
+       xs = aino->aname;
     }
+    x = ua_fs (xs);
 
     size = 0;
     size2 = 4;
-    if (control >= 1) {
+    if (type >= 1) {
        size2 += 4;
        size += strlen (x) + 1;
        size = (size + 3) & ~3;
     }
-    if (control >= 2)
+    if (type >= 2)
        size2 += 4;
-    if (control >= 3)
+    if (type >= 3)
        size2 += 4;
-    if (control >= 4) {
-       flags = fsdb_can ? aino->amigaos_mode : fsdb_mode_supported(aino);
+    if (type >= 4) {
+       flags = fsdb_can ? aino->amigaos_mode : fsdb_mode_supported (aino);
        size2 += 4;
     }
-    if (control >= 5) {
+    if (type >= 5) {
         get_time (statbuf.st_mtime, &days, &mins, &ticks);
        size2 += 12;
     }
-    if (control >= 6) {
+    if (type >= 6) {
        size2 += 4;
         if (aino->comment == 0 || !fsdb_can)
-           comment = "";
+           commentx = L"";
        else
-           comment = aino->comment;
+           commentx = aino->comment;
+       comment = ua_fs (commentx);
        size += strlen (comment) + 1;
        size = (size + 3) & ~3;
     }
-    if (control >= 7) {
+    if (type >= 7) {
        size2 += 4;
        uid = 0;
        gid = 0;
@@ -2821,33 +2894,33 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec
     }
 
     if (exalldata + exalldatasize - exp < size + size2)
-       return 0; /* not enough space */
+       goto end; /* not enough space */
 
 #if EXALL_DEBUG > 0
-   write_log("ID=%d, %d, %08x: '%s'%s\n",
-       get_long (control + 4), get_long (control + 0), exp, x, aino->dir ? " [DIR]" : "");
+   write_log (L"ID=%d, %d, %08x: '%s'%s\n",
+       get_long (control + 4), get_long (control + 0), exp, xs, aino->dir ? L" [DIR]" : L"");
 #endif
 
     put_long (exp, exp + size + size2); /* ed_Next */
-    if (control >= 1) {
+    if (type >= 1) {
        put_long (exp + 4, exp + size2);
        for (i = 0; i <= strlen (x); i++) {
            put_byte (exp + size2, x[i]);
            size2++;
        }
     }
-    if (control >= 2)
+    if (type >= 2)
        put_long (exp + 8, entrytype);
-    if (control >= 3)
-       put_long (exp + 12, statbuf.st_size);
-    if (control >= 4)
+    if (type >= 3)
+       put_long (exp + 12, statbuf.st_size > MAXFILESIZE32 ? MAXFILESIZE32 : statbuf.st_size);
+    if (type >= 4)
        put_long (exp + 16, flags);
-    if (control >= 5) {
+    if (type >= 5) {
        put_long (exp + 20, days);
        put_long (exp + 24, mins);
        put_long (exp + 28, ticks);
     }
-    if (control >= 6) {
+    if (type >= 6) {
        put_long (exp + 32, exp + size2);
        put_byte (exp + size2, strlen (comment));
        for (i = 0; i <= strlen (comment); i++) {
@@ -2855,12 +2928,16 @@ static int exalldo (uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaec
            size2++;
        }
     }
-    if (control >= 7) {
+    if (type >= 7) {
        put_word (exp + 36, uid);
        put_word (exp + 38, gid);
     }
     put_long (control + 0, get_long (control + 0) + 1);
-    return 1;
+    ret = 1;
+end:
+    xfree (x);
+    xfree (comment);
+    return ret;
 }
 
 static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecptr exalldata, uae_u32 exalldatasize, uae_u32 type, uaecptr control)
@@ -2870,7 +2947,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp
     uae_u32 err;
     int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
     void *d;
-    char fn[MAX_DPATH];
+    TCHAR fn[MAX_DPATH];
 
     if (lock != 0)
         base = lookup_aino (unit, get_long (lock + 4));
@@ -2888,7 +2965,7 @@ static int action_examine_all_do (Unit *unit, uaecptr lock, ExAllKey *eak, uaecp
            if (!ok)
                return 0;
        } else {
-           strcpy (fn, eak->fn);
+           _tcscpy (fn, eak->fn);
            xfree (eak->fn);
            eak->fn = NULL;
        }
@@ -2917,10 +2994,10 @@ static int action_examine_all_end (Unit *unit, dpacket packet)
     id = get_long (control + 4);
     eak = getexall (unit, control, id);
 #if EXALL_DEBUG > 0
-    write_log ("EXALL_END ID=%d %x\n", id, eak);
+    write_log (L"EXALL_END ID=%d %x\n", id, eak);
 #endif
     if (!eak) {
-        write_log ("FILESYS: EXALL_END non-existing ID %d\n", id);
+        write_log (L"FILESYS: EXALL_END non-existing ID %d\n", id);
         doserr = ERROR_OBJECT_WRONG_TYPE;
     } else {
         eak->id = 0;
@@ -2957,9 +3034,9 @@ static int action_examine_all (Unit *unit, dpacket packet)
     ok = 0;
 
 #if EXALL_DEBUG > 0
-    write_log ("exall: %08x %08x-%08x %d %d %08x\n",
+    write_log (L"exall: %08x %08x-%08x %d %d %08x\n",
        lock, exalldata, exalldata + exalldatasize, exalldatasize, type, control);
-    write_log ("exall: MatchString %08x, MatchFunc %08x\n",
+    write_log (L"exall: MatchString %08x, MatchFunc %08x\n",
        get_long (control + 8), get_long (control + 12));
 #endif
 
@@ -2977,13 +3054,13 @@ static int action_examine_all (Unit *unit, dpacket packet)
     PUT_PCK_RES1 (packet, DOS_TRUE);
     id = get_long (control + 4);
     if (id == EXALL_END) {
-       write_log ("FILESYS: EXALL called twice with ERROR_NO_MORE_ENTRIES\n");
+       write_log (L"FILESYS: EXALL called twice with ERROR_NO_MORE_ENTRIES\n");
        goto fail; /* already ended exall() */
     }
     if (id) {
        eak = getexall (unit, control, id);
        if (!eak) {
-           write_log ("FILESYS: EXALL non-existing ID %d\n", id);
+           write_log (L"FILESYS: EXALL non-existing ID %d\n", id);
            doserr = ERROR_OBJECT_WRONG_TYPE;
            goto fail;
        }
@@ -3065,7 +3142,7 @@ static uae_u32 REGPARAM2 exall_helper (TrapContext *context)
     uae_u32 id = get_long (control + 4);
 
 #if EXALL_DEBUG > 0
-    write_log ("FILESYS: EXALL extra round ID=%d\n", id);
+    write_log (L"FILESYS: EXALL extra round ID=%d\n", id);
 #endif
     if (id == EXALL_END)
        return 1;
@@ -3085,7 +3162,7 @@ static void action_examine_object (Unit *unit, dpacket packet)
     uaecptr info = GET_PCK_ARG2 (packet) << 2;
     a_inode *aino = 0;
 
-    TRACE(("ACTION_EXAMINE_OBJECT(0x%lx,0x%lx)\n", lock, info));
+    TRACE((L"ACTION_EXAMINE_OBJECT(0x%lx,0x%lx)\n", lock, info));
     DUMPLOCK(unit, lock);
 
     if (lock != 0)
@@ -3120,10 +3197,10 @@ static void populate_directory (Unit *unit, a_inode *base)
        base->locked_children++;
        unit->total_locked_ainos++;
     }
-    TRACE(("Populating directory, child %p, locked_children %d\n",
+    TRACE((L"Populating directory, child %p, locked_children %d\n",
           base->child, base->locked_children));
     for (;;) {
-       char fn[MAX_DPATH];
+       TCHAR fn[MAX_DPATH];
        int ok;
        uae_u32 err;
 
@@ -3147,21 +3224,21 @@ static void populate_directory (Unit *unit, a_inode *base)
 static void do_examine (Unit *unit, dpacket packet, ExamineKey *ek, uaecptr info)
 {
     for (;;) {
-       char *name;
+       TCHAR *name;
        if (ek->curr_file == 0)
            break;
        name = ek->curr_file->nname;
        get_fileinfo (unit, packet, info, ek->curr_file);
        ek->curr_file = ek->curr_file->sibling;
        if (!(unit->volflags & MYVOLUMEINFO_ARCHIVE) && !fsdb_exists(name)) {
-           TRACE (("%s orphaned", name));
+           TRACE ((L"%s orphaned", name));
            continue;
        }
-       TRACE (("curr_file set to %p %s\n", ek->curr_file,
-           ek->curr_file ? ek->curr_file->aname : "NULL"));
+       TRACE ((L"curr_file set to %p %s\n", ek->curr_file,
+           ek->curr_file ? ek->curr_file->aname : L"NULL"));
        return;
     }
-    TRACE(("no more entries\n"));
+    TRACE((L"no more entries\n"));
     free_exkey (unit, ek);
     PUT_PCK_RES1 (packet, DOS_FALSE);
     PUT_PCK_RES2 (packet, ERROR_NO_MORE_ENTRIES);
@@ -3175,7 +3252,7 @@ static void action_examine_next (Unit *unit, dpacket packet)
     ExamineKey *ek;
     uae_u32 uniq;
 
-    TRACE(("ACTION_EXAMINE_NEXT(0x%lx,0x%lx)\n", lock, info));
+    TRACE((L"ACTION_EXAMINE_NEXT(0x%lx,0x%lx)\n", lock, info));
     gui_hd_led (unit->unit, 1);
     DUMPLOCK(unit, lock);
 
@@ -3186,26 +3263,26 @@ static void action_examine_next (Unit *unit, dpacket packet)
 for(;;) {
     uniq = get_long (info);
     if (uniq == 0) {
-       write_log ("ExNext called for a file! (Houston?)\n");
+       write_log (L"ExNext called for a file! (Houston?)\n");
        goto no_more_entries;
     } else if (uniq == 0xFFFFFFFE)
        goto no_more_entries;
     else if (uniq == 0xFFFFFFFF) {
-       TRACE(("Creating new ExKey\n"));
+       TRACE((L"Creating new ExKey\n"));
        ek = new_exkey (unit, aino);
        if (ek) {
            if (aino->exnext_count++ == 0)
                populate_directory (unit, aino);
            ek->curr_file = aino->child;
-           TRACE(("Initial curr_file: %p %s\n", ek->curr_file,
-              ek->curr_file ? ek->curr_file->aname : "NULL"));
+           TRACE((L"Initial curr_file: %p %s\n", ek->curr_file,
+              ek->curr_file ? ek->curr_file->aname : L"NULL"));
        }
     } else {
-       TRACE(("Looking up ExKey\n"));
+       TRACE((L"Looking up ExKey\n"));
        ek = lookup_exkey (unit, get_long (info));
     }
     if (ek == 0) {
-       write_log ("Couldn't find a matching ExKey. Prepare for trouble.\n");
+       write_log (L"Couldn't find a matching ExKey. Prepare for trouble.\n");
        goto no_more_entries;
     }
     put_long (info, ek->uniq);
@@ -3236,7 +3313,7 @@ static void do_find (Unit *unit, dpacket packet, int mode, int create, int fallb
     int aino_created = 0;
     int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
 
-    TRACE(("ACTION_FIND_*(0x%lx,0x%lx,\"%s\",%d,%d)\n", fh, lock, bstr (unit, name), mode, create));
+    TRACE((L"ACTION_FIND_*(0x%lx,0x%lx,\"%s\",%d,%d)\n", fh, lock, bstr (unit, name), mode, create));
     DUMPLOCK(unit, lock);
 
     aino = find_aino (unit, lock, bstr (unit, name), &err);
@@ -3361,7 +3438,7 @@ action_fh_from_lock (Unit *unit, dpacket packet)
     int mode;
     int isarch = unit->volflags & MYVOLUMEINFO_ARCHIVE;
 
-    TRACE(("ACTION_FH_FROM_LOCK(0x%lx,0x%lx)\n", fh, lock));
+    TRACE((L"ACTION_FH_FROM_LOCK(0x%lx,0x%lx)\n", fh, lock));
     DUMPLOCK(unit,lock);
 
     if (!lock) {
@@ -3377,7 +3454,7 @@ action_fh_from_lock (Unit *unit, dpacket packet)
 
     prepare_for_open (aino->nname);
 
-    TRACE (("  mode is %d\n", mode));
+    TRACE ((L"  mode is %d\n", mode));
     openmode = (((mode & A_FIBF_READ) ? O_WRONLY
                 : (mode & A_FIBF_WRITE) ? O_RDONLY
                 : O_RDWR));
@@ -3459,7 +3536,7 @@ static void
 action_end (Unit *unit, dpacket packet)
 {
     Key *k;
-    TRACE(("ACTION_END(0x%lx)\n", GET_PCK_ARG1 (packet)));
+    TRACE((L"ACTION_END(0x%lx)\n", GET_PCK_ARG1 (packet)));
 
     k = lookup_key (unit, GET_PCK_ARG1 (packet));
     if (k != 0) {
@@ -3491,13 +3568,13 @@ action_read (Unit *unit, dpacket packet)
        /* PUT_PCK_RES2 (packet, EINVAL); */
        return;
     }
-    TRACE(("ACTION_READ(%s,0x%lx,%ld)\n", k->aino->nname, addr, size));
+    TRACE((L"ACTION_READ(%s,0x%lx,%ld)\n", k->aino->nname, addr, size));
     gui_hd_led (unit->unit, 1);
 #ifdef RELY_ON_LOADSEG_DETECTION
     /* HACK HACK HACK HACK
      * Try to detect a LoadSeg() */
     if (k->file_pos == 0 && size >= 4) {
-       unsigned char buf[4];
+       unsigned TCHAR buf[4];
        off_t currpos = fs_lseek (unit, k->fd, 0, SEEK_CUR);
        my_read (k->fd, buf, 4);
        fs_lseek (unit, k->fd, currpos, SEEK_SET);
@@ -3521,10 +3598,10 @@ action_read (Unit *unit, dpacket packet)
            k->file_pos += actual;
        }
     } else {
-       char *buf;
+       TCHAR *buf;
        off_t old, filesize;
 
-       write_log ("unixfs warning: Bad pointer passed for read: %08x, size %d\n", addr, size);
+       write_log (L"unixfs warning: Bad pointer passed for read: %08x, size %d\n", addr, size);
        /* ugh this is inefficient but easy */
 
        old = fs_lseek (unit, k->fd, 0, SEEK_CUR);
@@ -3553,7 +3630,7 @@ action_read (Unit *unit, dpacket packet)
        }
        xfree (buf);
     }
-    TRACE(("=%d\n", actual));
+    TRACE((L"=%d\n", actual));
 }
 
 static void
@@ -3563,7 +3640,7 @@ action_write (Unit *unit, dpacket packet)
     uaecptr addr = GET_PCK_ARG2 (packet);
     long size = GET_PCK_ARG3 (packet);
     long actual;
-    char *buf;
+    TCHAR *buf;
     int i;
 
     if (k == 0) {
@@ -3573,7 +3650,7 @@ action_write (Unit *unit, dpacket packet)
     }
 
     gui_hd_led (unit->unit, 2);
-    TRACE(("ACTION_WRITE(%s,0x%lx,%ld)\n", k->aino->nname, addr, size));
+    TRACE((L"ACTION_WRITE(%s,0x%lx,%ld)\n", k->aino->nname, addr, size));
 
     if (unit->ui.readonly) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -3587,9 +3664,9 @@ action_write (Unit *unit, dpacket packet)
 
     } else {
 
-       write_log ("unixfs warning: Bad pointer passed for write: %08x, size %d\n", addr, size);
+       write_log (L"unixfs warning: Bad pointer passed for write: %08x, size %d\n", addr, size);
        /* ugh this is inefficient but easy */
-       buf = (char *)malloc(size);
+       buf = (TCHAR *)malloc(size);
        if (!buf) {
            PUT_PCK_RES1 (packet, -1);
            PUT_PCK_RES2 (packet, ERROR_NO_FREE_STORE);
@@ -3603,7 +3680,7 @@ action_write (Unit *unit, dpacket packet)
        xfree (buf);
     }
 
-    TRACE(("=%d\n", actual));
+    TRACE((L"=%d\n", actual));
     PUT_PCK_RES1 (packet, actual);
     if (actual != size)
        PUT_PCK_RES2 (packet, dos_errno ());
@@ -3629,10 +3706,12 @@ action_seek (Unit *unit, dpacket packet)
        return;
     }
 
-    if (mode > 0) whence = SEEK_END;
-    if (mode < 0) whence = SEEK_SET;
+    if (mode > 0)
+       whence = SEEK_END;
+    if (mode < 0)
+       whence = SEEK_SET;
 
-    TRACE(("ACTION_SEEK(%s,%d,%d)\n", k->aino->nname, pos, mode));
+    TRACE((L"ACTION_SEEK(%s,%d,%d)\n", k->aino->nname, pos, mode));
     gui_hd_led (unit->unit, 1);
 
     old = fs_lseek (unit, k->fd, 0, SEEK_CUR);
@@ -3673,7 +3752,7 @@ action_set_protect (Unit *unit, dpacket packet)
     a_inode *a;
     uae_u32 err;
 
-    TRACE(("ACTION_SET_PROTECT(0x%lx,\"%s\",0x%lx)\n", lock, bstr (unit, name), mask));
+    TRACE((L"ACTION_SET_PROTECT(0x%lx,\"%s\",0x%lx)\n", lock, bstr (unit, name), mask));
 
     if (unit->ui.readonly) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -3707,7 +3786,7 @@ static void action_set_comment (Unit * unit, dpacket packet)
     uaecptr lock = GET_PCK_ARG2 (packet) << 2;
     uaecptr name = GET_PCK_ARG3 (packet) << 2;
     uaecptr comment = GET_PCK_ARG4 (packet) << 2;
-    char *commented = NULL;
+    TCHAR *commented = NULL;
     a_inode *a;
     uae_u32 err;
 
@@ -3719,16 +3798,16 @@ static void action_set_comment (Unit * unit, dpacket packet)
 
     if (fsdb_cando (unit)) {
        commented = bstr (unit, comment);
-       if (strlen (commented) > 0) {
-           char *p = commented;
-           commented = (char*)xmalloc (81);
-           strncpy (commented, p, 80);
+       if (_tcslen (commented) > 0) {
+           TCHAR *p = commented;
+           commented = xmalloc (81 * sizeof (TCHAR));
+           _tcsncpy (commented, p, 80);
            commented[80] = 0;
        } else {
            commented = NULL;
        }
     }
-    TRACE (("ACTION_SET_COMMENT(0x%lx,\"%s\")\n", lock, commented));
+    TRACE ((L"ACTION_SET_COMMENT(0x%lx,\"%s\")\n", lock, commented));
 
     a = find_aino (unit, lock, bstr (unit, name), &err);
     if (err != 0) {
@@ -3744,7 +3823,7 @@ static void action_set_comment (Unit * unit, dpacket packet)
     PUT_PCK_RES2 (packet, 0);
     if (a->comment == 0 && commented == 0)
        goto maybe_free_and_out;
-    if (a->comment != 0 && commented != 0 && strcmp (a->comment, commented) == 0)
+    if (a->comment != 0 && commented != 0 && _tcscmp (a->comment, commented) == 0)
        goto maybe_free_and_out;
     if (a->comment)
        xfree (a->comment);
@@ -3760,7 +3839,7 @@ action_same_lock (Unit *unit, dpacket packet)
     uaecptr lock1 = GET_PCK_ARG1 (packet) << 2;
     uaecptr lock2 = GET_PCK_ARG2 (packet) << 2;
 
-    TRACE(("ACTION_SAME_LOCK(0x%lx,0x%lx)\n", lock1, lock2));
+    TRACE((L"ACTION_SAME_LOCK(0x%lx,0x%lx)\n", lock1, lock2));
     DUMPLOCK(unit, lock1); DUMPLOCK(unit, lock2);
 
     if (!lock1 || !lock2) {
@@ -3786,7 +3865,7 @@ action_change_mode (Unit *unit, dpacket packet)
     unsigned long uniq;
     a_inode *a = NULL, *olda = NULL;
     uae_u32 err = 0;
-    TRACE(("ACTION_CHANGE_MODE(0x%lx,%d,%d)\n", object, type, mode));
+    TRACE((L"ACTION_CHANGE_MODE(0x%lx,%d,%d)\n", object, type, mode));
 
     if (! object || (type != CHANGE_FH && type != CHANGE_LOCK)) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -3875,7 +3954,7 @@ action_parent (Unit *unit, dpacket packet)
 {
     uaecptr lock = GET_PCK_ARG1 (packet) << 2;
 
-    TRACE(("ACTION_PARENT(0x%lx)\n",lock));
+    TRACE((L"ACTION_PARENT(0x%lx)\n",lock));
 
     if (!lock) {
        PUT_PCK_RES1 (packet, 0);
@@ -3883,7 +3962,7 @@ action_parent (Unit *unit, dpacket packet)
     } else {
        action_parent_common (unit, packet, get_long (lock + 4));
     }
-    TRACE(("=%x %d\n", GET_PCK_RES1 (packet), GET_PCK_RES2 (packet)));
+    TRACE((L"=%x %d\n", GET_PCK_RES1 (packet), GET_PCK_RES2 (packet)));
 }
 
 static void
@@ -3894,7 +3973,7 @@ action_create_dir (Unit *unit, dpacket packet)
     a_inode *aino;
     uae_u32 err;
 
-    TRACE(("ACTION_CREATE_DIR(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
+    TRACE((L"ACTION_CREATE_DIR(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
 
     if (unit->ui.readonly) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -3943,7 +4022,7 @@ action_examine_fh (Unit *unit, dpacket packet)
     a_inode *aino = 0;
     uaecptr info = GET_PCK_ARG2 (packet) << 2;
 
-    TRACE(("ACTION_EXAMINE_FH(0x%lx,0x%lx)\n",
+    TRACE((L"ACTION_EXAMINE_FH(0x%lx,0x%lx)\n",
           GET_PCK_ARG1 (packet), GET_PCK_ARG2 (packet) ));
 
     k = lookup_key (unit, GET_PCK_ARG1 (packet));
@@ -3971,10 +4050,12 @@ action_set_file_size (Unit *unit, dpacket packet)
     long mode = (uae_s32)GET_PCK_ARG3 (packet);
     int whence = SEEK_CUR;
 
-    if (mode > 0) whence = SEEK_END;
-    if (mode < 0) whence = SEEK_SET;
+    if (mode > 0)
+       whence = SEEK_END;
+    if (mode < 0)
+       whence = SEEK_SET;
 
-    TRACE(("ACTION_SET_FILE_SIZE(0x%lx, %d, 0x%x)\n", GET_PCK_ARG1 (packet), offset, mode));
+    TRACE((L"ACTION_SET_FILE_SIZE(0x%lx, %d, 0x%x)\n", GET_PCK_ARG1 (packet), offset, mode));
 
     k = lookup_key (unit, GET_PCK_ARG1 (packet));
     if (k == 0) {
@@ -3990,16 +4071,16 @@ action_set_file_size (Unit *unit, dpacket packet)
     for (k1 = unit->keys; k1; k1 = k1->next) {
        if (k != k1 && k->aino == k1->aino) {
            if (k1->file_pos > offset)
-               offset = k1->file_pos;
+               offset = (off_t)k1->file_pos;
        }
     }
 
     /* Write one then truncate: that should give the right size in all cases.  */
     offset = fs_lseek (unit, k->fd, offset, whence);
-    my_write (k->fd, /* whatever */(char *)&k1, 1);
+    my_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
     if (k->file_pos > offset)
        k->file_pos = offset;
-    fs_lseek (unit, k->fd, k->file_pos, SEEK_SET);
+    fs_lseek (unit, k->fd, (off_t)k->file_pos, SEEK_SET);
 
     /* Brian: no bug here; the file _must_ be one byte too large after writing
        The write is supposed to guarantee that the file can't be smaller than
@@ -4025,7 +4106,7 @@ static int relock_do(Unit *unit, a_inode *a1)
        if (k1->aino == a1 && k1->fd) {
            wehavekeys++;
            fs_close (unit, k1->fd);
-           write_log ("handle %p freed\n", k1->fd);
+           write_log (L"handle %p freed\n", k1->fd);
        }
     }
     return wehavekeys;
@@ -4043,22 +4124,22 @@ static void relock_re(Unit *unit, a_inode *a1, a_inode *a2, int failed)
            if (failed) {
                /* rename still failed, restore fd */
                k1->fd = fs_open (unit, a1->nname, mode);
-               write_log ("restoring old handle '%s' %d\n", a1->nname, k1->dosmode);
+               write_log (L"restoring old handle '%s' %d\n", a1->nname, k1->dosmode);
            } else {
                /* transfer fd to new name */
                if (a2) {
                    k1->aino = a2;
                    k1->fd = fs_open (unit, a2->nname, mode);
-                   write_log ("restoring new handle '%s' %d\n", a2->nname, k1->dosmode);
+                   write_log (L"restoring new handle '%s' %d\n", a2->nname, k1->dosmode);
                } else {
-                   write_log ("no new handle, deleting old lock(s).\n");
+                   write_log (L"no new handle, deleting old lock(s).\n");
                }
            }
            if (k1->fd == NULL) {
-               write_log ("relocking failed '%s' -> '%s'\n", a1->nname, a2->nname);
+               write_log (L"relocking failed '%s' -> '%s'\n", a1->nname, a2->nname);
                free_key (unit, k1);
            } else {
-               fs_lseek (unit, k1->fd, k1->file_pos, SEEK_SET);
+               fs_lseek64 (unit, k1->fd, k1->file_pos, SEEK_SET);
            }
        }
     }
@@ -4072,7 +4153,7 @@ action_delete_object (Unit *unit, dpacket packet)
     a_inode *a;
     uae_u32 err;
 
-    TRACE(("ACTION_DELETE_OBJECT(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
+    TRACE((L"ACTION_DELETE_OBJECT(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
 
     if (unit->ui.readonly) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -4115,7 +4196,7 @@ action_delete_object (Unit *unit, dpacket packet)
     notify_check (unit, a);
     updatedirtime (a, 1);
     if (a->child != 0) {
-       write_log ("Serious error in action_delete_object.\n");
+       write_log (L"Serious error in action_delete_object.\n");
        a->deleted = 1;
     } else {
        delete_aino (unit, a);
@@ -4134,7 +4215,7 @@ action_set_date (Unit *unit, dpacket packet)
     struct utimbuf ut;
     uae_u32 err;
 
-    TRACE(("ACTION_SET_DATE(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
+    TRACE((L"ACTION_SET_DATE(0x%lx,\"%s\")\n", lock, bstr (unit, name)));
 
     if (unit->ui.readonly) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -4169,8 +4250,8 @@ action_rename_object (Unit *unit, dpacket packet)
     Key *k1, *knext;
     int wehavekeys = 0;
 
-    TRACE(("ACTION_RENAME_OBJECT(0x%lx,\"%s\",", lock1, bstr (unit, name1)));
-    TRACE(("0x%lx,\"%s\")\n", lock2, bstr (unit, name2)));
+    TRACE((L"ACTION_RENAME_OBJECT(0x%lx,\"%s\",", lock1, bstr (unit, name1)));
+    TRACE((L"0x%lx,\"%s\")\n", lock2, bstr (unit, name2)));
 
     if (unit->ui.readonly) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -4200,7 +4281,7 @@ action_rename_object (Unit *unit, dpacket packet)
 
     if (a2 == a1) {
        /* Renaming to the same name, but possibly different case.  */
-       if (strcmp (a1->aname, bstr_cut (unit, name2)) == 0) {
+       if (_tcscmp (a1->aname, bstr_cut (unit, name2)) == 0) {
            /* Exact match -> do nothing.  */
            notify_check (unit, a1);
            updatedirtime (a1, 1);
@@ -4224,7 +4305,7 @@ action_rename_object (Unit *unit, dpacket packet)
     if (-1 == my_rename (a1->nname, a2->nname)) {
        int ret = -1;
        /* maybe we have open file handles that caused failure? */
-       write_log ("rename '%s' -> '%s' failed, trying relocking..\n", a1->nname, a2->nname);
+       write_log (L"rename '%s' -> '%s' failed, trying relocking..\n", a1->nname, a2->nname);
        wehavekeys = relock_do(unit, a1);
        /* try again... */
        ret = my_rename (a1->nname, a2->nname);
@@ -4276,10 +4357,8 @@ static void
 action_rename_disk (Unit *unit, dpacket packet)
 {
     uaecptr name = GET_PCK_ARG1 (packet) << 2;
-    int i;
-    int namelen;
 
-    TRACE(("ACTION_RENAME_DISK(\"%s\")\n", bstr (unit, name)));
+    TRACE((L"ACTION_RENAME_DISK(\"%s\")\n", bstr (unit, name)));
 
     if (unit->ui.readonly) {
        PUT_PCK_RES1 (packet, DOS_FALSE);
@@ -4288,12 +4367,8 @@ action_rename_disk (Unit *unit, dpacket packet)
     }
 
     /* get volume name */
-    namelen = get_byte (name); name++;
     xfree (unit->ui.volname);
-    unit->ui.volname = (char *) xmalloc (namelen + 1);
-    for (i = 0; i < namelen; i++, name++)
-       unit->ui.volname[i] = get_byte (name);
-    unit->ui.volname[i] = 0;
+    unit->ui.volname = bstr1 (name);
     set_volume_name (unit);
 
     PUT_PCK_RES1 (packet, DOS_TRUE);
@@ -4302,14 +4377,14 @@ action_rename_disk (Unit *unit, dpacket packet)
 static void
 action_is_filesystem (Unit *unit, dpacket packet)
 {
-    TRACE(("ACTION_IS_FILESYSTEM()\n"));
+    TRACE((L"ACTION_IS_FILESYSTEM()\n"));
     PUT_PCK_RES1 (packet, DOS_TRUE);
 }
 
 static void
 action_flush (Unit *unit, dpacket packet)
 {
-    TRACE(("ACTION_FLUSH()\n"));
+    TRACE((L"ACTION_FLUSH()\n"));
     PUT_PCK_RES1 (packet, DOS_TRUE);
     flush_cache(unit, 0);
 }
@@ -4317,7 +4392,7 @@ action_flush (Unit *unit, dpacket packet)
 static void
 action_more_cache (Unit *unit, dpacket packet)
 {
-    TRACE(("ACTION_MORE_CACHE()\n"));
+    TRACE((L"ACTION_MORE_CACHE()\n"));
     PUT_PCK_RES1 (packet, 50); /* bug but AmigaOS expects it */
     if (GET_PCK_ARG1 (packet) != 0)
        flush_cache(unit, 0);
@@ -4329,13 +4404,13 @@ action_inhibit (Unit *unit, dpacket packet)
     PUT_PCK_RES1 (packet, DOS_TRUE);
     flush_cache(unit, 0);
     unit->inhibited = GET_PCK_ARG1 (packet);
-    TRACE(("ACTION_INHIBIT(%d:%d)\n", unit->unit, unit->inhibited));
+    TRACE((L"ACTION_INHIBIT(%d:%d)\n", unit->unit, unit->inhibited));
 }
 
 static void
 action_write_protect (Unit *unit, dpacket packet)
 {
-    TRACE(("ACTION_WRITE_PROTECT()\n"));
+    TRACE((L"ACTION_WRITE_PROTECT()\n"));
     PUT_PCK_RES1 (packet, DOS_TRUE);
     if (GET_PCK_ARG1 (packet)) {
        if (!(unit->ui.readonly & 2)) {
@@ -4354,6 +4429,157 @@ action_write_protect (Unit *unit, dpacket packet)
     }
 }
 
+static void action_change_file_position64 (Unit *unit, dpacket packet)
+{
+    Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet));
+    uae_s64 pos = GET_PCK64_ARG2 (packet);
+    long mode = GET_PCK64_ARG3 (packet);
+    long whence = SEEK_CUR;
+    uae_s64 res, old;
+
+    PUT_PCK64_RES0 (packet, DP64_INIT);
+
+    if (k == 0) {
+       PUT_PCK64_RES1 (packet, (uae_s64)-1);
+       PUT_PCK64_RES2 (packet, ERROR_INVALID_LOCK);
+       return;
+    }
+
+    if (mode > 0)
+       whence = SEEK_END;
+    if (mode < 0)
+       whence = SEEK_SET;
+
+    TRACE((L"ACTION_CHANGE_FILE_POSITION64(%s,%I64d,%d)\n", k->aino->nname, pos, mode));
+    gui_hd_led (unit->unit, 1);
+
+    old = fs_lseek64 (unit, k->fd, 0, SEEK_CUR);
+    {
+       uae_s64 temppos;
+       uae_s64 filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END);
+       fs_lseek64 (unit, k->fd, old, SEEK_SET);
+
+       if (whence == SEEK_CUR)
+           temppos = old + pos;
+       if (whence == SEEK_SET)
+           temppos = pos;
+       if (whence == SEEK_END)
+           temppos = filesize + pos;
+       if (filesize < temppos) {
+           res = -1;
+           PUT_PCK64_RES1 (packet, res);
+           PUT_PCK64_RES2 (packet, ERROR_SEEK_ERROR);
+           return;
+       }
+    }
+    res = fs_lseek64 (unit, k->fd, pos, whence);
+
+    if (-1 == res) {
+       PUT_PCK64_RES1 (packet, res);
+       PUT_PCK64_RES2 (packet, ERROR_SEEK_ERROR);
+    } else {
+       PUT_PCK64_RES1 (packet, TRUE);
+        PUT_PCK64_RES2 (packet, DOS_TRUE);
+    }
+    k->file_pos = res;
+
+}
+
+static void action_get_file_position64 (Unit *unit, dpacket packet)
+{
+    Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet));
+
+    PUT_PCK64_RES0 (packet, DP64_INIT);
+
+    if (k == 0) {
+       PUT_PCK64_RES1 (packet, (uae_s64)-1);
+       PUT_PCK64_RES2 (packet, ERROR_INVALID_LOCK);
+       return;
+    }
+    TRACE((L"ACTION_GET_FILE_POSITION64(%s)\n", k->aino->nname));
+    PUT_PCK64_RES1 (packet, k->file_pos);
+    PUT_PCK64_RES2 (packet, DOS_TRUE);
+}
+
+static void action_change_file_size64 (Unit *unit, dpacket packet)
+{
+    Key *k, *k1;
+    uae_s64 offset = GET_PCK64_ARG2 (packet);
+    long mode = (uae_s32)GET_PCK64_ARG3 (packet);
+    int whence = SEEK_CUR;
+
+    PUT_PCK64_RES0 (packet, DP64_INIT);
+
+    if (mode > 0)
+       whence = SEEK_END;
+    if (mode < 0)
+       whence = SEEK_SET;
+
+    TRACE((L"ACTION_CHANGE_FILE_SIZE64(0x%lx, %I64d, 0x%x)\n", GET_PCK64_ARG1 (packet), offset, mode));
+
+    k = lookup_key (unit, GET_PCK64_ARG1 (packet));
+    if (k == 0) {
+       PUT_PCK64_RES1 (packet, DOS_TRUE);
+       PUT_PCK64_RES2 (packet, ERROR_OBJECT_NOT_AROUND);
+       return;
+    }
+
+    gui_hd_led (unit->unit, 1);
+    k->notifyactive = 1;
+    /* If any open files have file pointers beyond this size, truncate only
+     * so far that these pointers do not become invalid.  */
+    for (k1 = unit->keys; k1; k1 = k1->next) {
+       if (k != k1 && k->aino == k1->aino) {
+           if (k1->file_pos > offset)
+               offset = k1->file_pos;
+       }
+    }
+
+    /* Write one then truncate: that should give the right size in all cases.  */
+    offset = fs_lseek (unit, k->fd, offset, whence);
+    my_write (k->fd, /* whatever */(uae_u8*)&k1, 1);
+    if (k->file_pos > offset)
+       k->file_pos = offset;
+    fs_lseek (unit, k->fd, k->file_pos, SEEK_SET);
+
+    if (my_truncate (k->aino->nname, offset) == -1) {
+       PUT_PCK64_RES1 (packet, DOS_FALSE);
+       PUT_PCK64_RES2 (packet, dos_errno ());
+       return;
+    }
+
+    PUT_PCK64_RES1 (packet, DOS_TRUE);
+    PUT_PCK64_RES2 (packet, TRUE);
+}
+
+
+static void action_get_file_size64 (Unit *unit, dpacket packet)
+{
+    Key *k = lookup_key (unit, GET_PCK64_ARG1 (packet));
+    uae_s64 old, filesize;
+
+    PUT_PCK64_RES0 (packet, DP64_INIT);
+
+    if (k == 0) {
+       PUT_PCK64_RES1 (packet, (uae_s64)-1);
+       PUT_PCK64_RES2 (packet, ERROR_INVALID_LOCK);
+       return;
+    }
+    TRACE((L"ACTION_GET_FILE_SIZE64(%s)\n", k->aino->nname));
+    old = fs_lseek64 (unit, k->fd, 0, SEEK_CUR);
+    if (old >= 0) {
+       filesize = fs_lseek64 (unit, k->fd, 0, SEEK_END);
+       if (filesize >= 0) {
+           fs_lseek64 (unit, k->fd, old, SEEK_SET);
+           PUT_PCK64_RES1 (packet, filesize);
+           PUT_PCK64_RES2 (packet, DOS_TRUE);
+           return;
+       }
+    }
+    PUT_PCK64_RES1 (packet, (uae_s64)-1);
+    PUT_PCK64_RES2 (packet, ERROR_SEEK_ERROR);
+}
+
 /* We don't want multiple interrupts to be active at the same time. I don't
  * know whether AmigaOS takes care of that, but this does. */
 static uae_sem_t singlethread_int_sem;
@@ -4401,19 +4627,19 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context)
                lockend = locks;
                while (get_long (lockend) != 0) {
                    if (get_long (lockend) == lockend) {
-                       write_log ("filesystem lock queue corrupted!\n");
+                       write_log (L"filesystem lock queue corrupted!\n");
                        break;
                    }
                    lockend = get_long (lockend);
                    cnt++;
                }
-               TRACE(("%d %x %x %x\n", cnt, locks, lockend, m68k_areg (&context->regs, 3)));
+               TRACE((L"%d %x %x %x\n", cnt, locks, lockend, m68k_areg (&context->regs, 3)));
                put_long (lockend, get_long (m68k_areg (&context->regs, 3)));
                put_long (m68k_areg (&context->regs, 3), locks);
            }
        }
 #else
-       write_log ("exter_int_helper should not be called with arg 1!\n");
+       write_log (L"exter_int_helper should not be called with arg 1!\n");
 #endif
        break;
      case 2:
@@ -4455,7 +4681,7 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context)
                return 5;
 
             default:
-               write_log ("exter_int_helper: unknown native action %X\n", cmd);
+               write_log (L"exter_int_helper: unknown native action %X\n", cmd);
                break;
            }
        }
@@ -4494,7 +4720,7 @@ static uae_u32 REGPARAM2 exter_int_helper (TrapContext *context)
        break;
 
      default:
-       write_log ("Shouldn't happen in exter_int_helper.\n");
+       write_log (L"Shouldn't happen in exter_int_helper.\n");
        break;
     }
     return 0;
@@ -4564,7 +4790,13 @@ static int handle_packet (Unit *unit, dpacket pck)
      case ACTION_EXAMINE_ALL: return action_examine_all (unit, pck);
      case ACTION_EXAMINE_ALL_END: return action_examine_all_end (unit, pck);
 
-        /* unsupported packets */
+     /* OS4+ packet types */
+     case ACTION_CHANGE_FILE_POSITION64: action_change_file_position64 (unit, pck); break;
+     case ACTION_GET_FILE_POSITION64: action_get_file_position64 (unit, pck); break;
+     case ACTION_CHANGE_FILE_SIZE64: action_change_file_size64 (unit, pck); break;
+     case ACTION_GET_FILE_SIZE64: action_get_file_size64 (unit, pck); break;
+
+     /* unsupported packets */
      case ACTION_LOCK_RECORD:
      case ACTION_FREE_RECORD:
      case ACTION_MAKE_LINK:
@@ -4572,7 +4804,7 @@ static int handle_packet (Unit *unit, dpacket pck)
      case ACTION_FORMAT:
        return 0;
      default:
-       write_log ("FILESYS: UNKNOWN PACKET %x\n", type);
+       write_log (L"FILESYS: UNKNOWN PACKET %x\n", type);
        return 0;
     }
     return 1;
@@ -4635,7 +4867,7 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *context)
     uae_u8 *pck;
     uae_u8 *msg;
     if (! valid_address (packet_addr, 36) || ! valid_address (message_addr, 14)) {
-       write_log ("FILESYS: Bad address %x/%x passed for packet.\n", packet_addr, message_addr);
+       write_log (L"FILESYS: Bad address %x/%x passed for packet.\n", packet_addr, message_addr);
        goto error2;
     }
     pck = get_real_address (packet_addr);
@@ -4643,7 +4875,7 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *context)
 
     do_put_mem_long ((uae_u32 *)(msg + 4), -1);
     if (!unit || !unit->volume) {
-       write_log ("FILESYS: was not initialized.\n");
+       write_log (L"FILESYS: was not initialized.\n");
        goto error;
     }
 #ifdef UAE_FILESYS_THREADS
@@ -4671,7 +4903,7 @@ static uae_u32 REGPARAM2 filesys_handler (TrapContext *context)
        PUT_PCK_RES1 (pck, DOS_FALSE);
        PUT_PCK_RES2 (pck, ERROR_ACTION_NOT_KNOWN);
     }
-    TRACE(("reply: %8lx, %ld\n", GET_PCK_RES1 (pck), GET_PCK_RES2 (pck)));
+    TRACE((L"reply: %8lx, %ld\n", GET_PCK_RES1 (pck), GET_PCK_RES2 (pck)));
 
     error2:
 
@@ -4794,7 +5026,7 @@ static uae_u32 REGPARAM2 filesys_diagentry (TrapContext *context)
     uaecptr start = resaddr;
     uaecptr residents, tmp;
 
-    TRACE (("filesystem: diagentry called\n"));
+    TRACE ((L"filesystem: diagentry called\n"));
 
     filesys_configdev = m68k_areg (&context->regs, 3);
     init_filesys_diagentry ();
@@ -4960,7 +5192,7 @@ static int rl (uae_u8 *p)
     return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]);
 }
 
-int rdb_checksum (char *id, uae_u8 *p, int block)
+int rdb_checksum (TCHAR *id, uae_u8 *p, int block)
 {
     uae_u32 sum = 0;
     int i, blocksize;
@@ -4974,17 +5206,17 @@ int rdb_checksum (char *id, uae_u8 *p, int block)
        sum += rl (p + i * 4);
     sum = -sum;
     if (sum) {
-       write_log ("RDB: block %d ('%s') checksum error\n", block, id);
+       write_log (L"RDB: block %d ('%s') checksum error\n", block, id);
        return 0;
     }
     return 1;
 }
 
-static int device_isdup (uaecptr expbase, char *devname)
+static int device_isdup (uaecptr expbase, TCHAR *devname)
 {
     uaecptr bnode, dnode, name;
     int len, i;
-    char dname[256];
+    TCHAR dname[256];
 
     bnode = get_long (expbase + 74); /* expansion.library bootnode list */
     while (get_long (bnode)) {
@@ -4994,27 +5226,27 @@ static int device_isdup (uaecptr expbase, char *devname)
        for (i = 0; i < len; i++)
            dname[i] = get_byte (name + 1 + i);
        dname[len] = 0;
-       if (!strcmpi (devname, dname))
+       if (!_tcsicmp (devname, dname))
            return 1;
         bnode = get_long (bnode);
     }
     return 0;
 }
 
-static char *device_dupfix (uaecptr expbase, char *devname)
+static TCHAR *device_dupfix (uaecptr expbase, TCHAR *devname)
 {
     int modified;
-    char newname[256];
+    TCHAR newname[256];
 
-    strcpy (newname, devname);
+    _tcscpy (newname, devname);
     modified = 1;
     while (modified) {
        modified = 0;
        if (device_isdup (expbase, newname)) {
-           if (strlen (newname) > 2 && newname[strlen (newname) - 2] == '_') {
-               newname[strlen (newname) - 1]++;
+           if (_tcslen (newname) > 2 && newname[_tcslen (newname) - 2] == '_') {
+               newname[_tcslen (newname) - 1]++;
            } else {
-               strcat (newname, "_0");
+               _tcscat (newname, L"_0");
            }
            modified = 1;
        }
@@ -5022,19 +5254,21 @@ static char *device_dupfix (uaecptr expbase, char *devname)
     return my_strdup (newname);
 }
 
-static void dump_partinfo (char *name, int num, uaecptr pp, int partblock)
+static void dump_partinfo (uae_char *name, int num, uaecptr pp, int partblock)
 {
+    TCHAR *s = au (name);
     uae_u32 dostype = get_long (pp + 80);
-    write_log ("RDB: '%s' dostype=%08X. PartBlock=%d\n", name, dostype, partblock);
-    write_log ("BlockSize: %d, Surfaces: %d, SectorsPerBlock %d\n",
+    write_log (L"RDB: '%s' dostype=%08X. PartBlock=%d\n", s, dostype, partblock);
+    write_log (L"BlockSize: %d, Surfaces: %d, SectorsPerBlock %d\n",
               get_long (pp + 20) * 4, get_long (pp + 28), get_long (pp + 32));
-    write_log ("SectorsPerTrack: %d, Reserved: %d, LowCyl %d, HighCyl %d\n",
+    write_log (L"SectorsPerTrack: %d, Reserved: %d, LowCyl %d, HighCyl %d\n",
               get_long (pp + 36), get_long (pp + 40), get_long (pp + 52), get_long (pp + 56));
-    write_log ("Buffers: %d, BufMemType: %08x, MaxTransfer: %08x, BootPri: %d\n",
+    write_log (L"Buffers: %d, BufMemType: %08x, MaxTransfer: %08x, BootPri: %d\n",
               get_long (pp + 60), get_long (pp + 64), get_long (pp + 68), get_long (pp + 76));
+    xfree (s);
 }
 
-#define rdbmnt write_log ("Mounting uaehf.device %d (%d) (size=%I64u):\n", unit_no, partnum, hfd->virtsize);
+#define rdbmnt write_log (L"Mounting uaehf.device %d (%d) (size=%I64u):\n", unit_no, partnum, hfd->virtsize);
 
 static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacket)
 {
@@ -5049,35 +5283,36 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     int err = 0;
     int oldversion, oldrevision;
     int newversion, newrevision;
+    TCHAR *s;
 
-    write_log ("%s:\n", uip->rootdir);
+    write_log (L"%s:\n", uip->rootdir);
     if (hfd->drive_empty) {
        rdbmnt
-       write_log ("ignored, drive is empty\n");
+       write_log (L"ignored, drive is empty\n");
        return -2;
     }
     if (hfd->blocksize == 0) {
        rdbmnt
-       write_log ("failed, blocksize == 0\n");
+       write_log (L"failed, blocksize == 0\n");
        return -1;
     }
     if (lastblock * hfd->blocksize > hfd->virtsize) {
        rdbmnt
-       write_log ("failed, too small (%d*%d > %I64u)\n", lastblock, hfd->blocksize, hfd->virtsize);
+       write_log (L"failed, too small (%d*%d > %I64u)\n", lastblock, hfd->blocksize, hfd->virtsize);
        return -2;
     }
     for (rdblock = 0; rdblock < lastblock; rdblock++) {
        hdf_read (hfd, bufrdb, rdblock * hfd->blocksize, hfd->blocksize);
-       if (rdb_checksum ("RDSK", bufrdb, rdblock))
+       if (rdb_checksum (L"RDSK", bufrdb, rdblock))
            break;
        hdf_read (hfd, bufrdb, rdblock * hfd->blocksize, hfd->blocksize);
-       if (!memcmp ("RDSK", bufrdb, 4)) {
+       if (!memcmp (L"RDSK", bufrdb, 4)) {
            bufrdb[0xdc] = 0;
            bufrdb[0xdd] = 0;
            bufrdb[0xde] = 0;
            bufrdb[0xdf] = 0;
-           if (rdb_checksum ("RDSK", bufrdb, rdblock)) {
-               write_log ("Windows 95/98/ME trashed RDB detected, fixing..\n");
+           if (rdb_checksum (L"RDSK", bufrdb, rdblock)) {
+               write_log (L"Windows 95/98/ME trashed RDB detected, fixing..\n");
                hdf_write (hfd, bufrdb, rdblock * hfd->blocksize, hfd->blocksize);
                break;
            }
@@ -5085,7 +5320,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     }
     if (rdblock == lastblock) {
        rdbmnt
-       write_log ("failed, no RDB detected\n");
+       write_log (L"failed, no RDB detected\n");
        return -2;
     }
     blocksize = rl (bufrdb + 16);
@@ -5093,13 +5328,13 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     badblock = rl (bufrdb + 24);
     if (badblock != -1) {
        rdbmnt
-       write_log ("RDB: badblock list is not yet supported. Contact the author.\n");
+       write_log (L"RDB: badblock list is not yet supported. Contact the author.\n");
        return -2;
     }
     driveinitblock = rl (bufrdb + 36);
     if (driveinitblock != -1) {
        rdbmnt
-       write_log ("RDB: driveinit is not yet supported. Contact the author.\n");
+       write_log (L"RDB: driveinit is not yet supported. Contact the author.\n");
        return -2;
     }
     hfd->cylinders = rl (bufrdb + 64);
@@ -5108,11 +5343,11 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     fileblock = rl (bufrdb + 32);
 
     if (partnum == 0) {
-       write_log ("RDB: RDSK detected at %d, FSHD=%d, C=%d S=%d H=%d\n",
+       write_log (L"RDB: RDSK detected at %d, FSHD=%d, C=%d S=%d H=%d\n",
            rdblock, fileblock, hfd->cylinders, hfd->sectors, hfd->heads);
     }
 
-    buf = (uae_u8*)xmalloc (readblocksize);
+    buf = xmalloc (readblocksize);
     for (i = 0; i <= partnum; i++) {
        if (i == 0)
            partblock = rl (bufrdb + 28);
@@ -5124,7 +5359,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
        }
        memset (buf, 0, readblocksize);
        hdf_read (hfd, buf, partblock * hfd->blocksize, readblocksize);
-       if (!rdb_checksum ("PART", buf, partblock)) {
+       if (!rdb_checksum (L"PART", buf, partblock)) {
            err = -2;
            goto error;
        }
@@ -5134,7 +5369,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     flags = rl (buf + 20);
     if (flags & 2) { /* do not mount */
        err = -1;
-       write_log ("RDB: Automount disabled, not mounting\n");
+       write_log (L"RDB: Automount disabled, not mounting\n");
        goto error;
     }
 
@@ -5142,7 +5377,9 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
        m68k_dreg (&regs, 7) = m68k_dreg (&regs, 7) & ~1;
 
     buf[37 + buf[36]] = 0; /* zero terminate BSTR */
-    uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), buf + 37));
+    s = au (buf + 37);
+    uip->rdb_devname_amiga[partnum] = ds (device_dupfix (get_long (parmpacket + PP_EXPLIB), s));
+    xfree (s);
     put_long (parmpacket, uip->rdb_devname_amiga[partnum]); /* name */
     put_long (parmpacket + 4, ROM_hardfile_resname);
     put_long (parmpacket + 8, uip->devno);
@@ -5153,13 +5390,13 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     dostype = get_long (parmpacket + 80);
 
     if (dostype == 0) {
-       write_log ("RDB: mount failed, dostype=0\n");
+       write_log (L"RDB: mount failed, dostype=0\n");
        err = -1;
        goto error;
     }
 
     if (hfd->cylinders * hfd->sectors * hfd->heads * blocksize > hfd->virtsize)
-       write_log ("RDB: WARNING: end of partition > size of disk!\n");
+       write_log (L"RDB: WARNING: end of partition > size of disk!\n");
 
     err = 2;
 
@@ -5169,7 +5406,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
 
     fsres = get_long (parmpacket + PP_FSRES);
     if (!fsres) {
-       write_log ("RDB: FileSystem.resource not found, this shouldn't happen!\n");
+       write_log (L"RDB: FileSystem.resource not found, this shouldn't happen!\n");
        goto error;
     }
     fsnode = get_long (fsres + 18);
@@ -5189,17 +5426,17 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     for (;;) {
        if (fileblock == -1) {
            if (!fsnode)
-               write_log ("RDB: required FS %08X not in FileSystem.resource or in RDB\n", dostype);
+               write_log (L"RDB: required FS %08X not in FileSystem.resource or in RDB\n", dostype);
            goto error;
        }
        if (!legalrdbblock (uip, fileblock)) {
-           write_log ("RDB: corrupt FSHD pointer %d\n", fileblock);
+           write_log (L"RDB: corrupt FSHD pointer %d\n", fileblock);
            goto error;
        }
        memset (buf, 0, readblocksize);
        hdf_read (hfd, buf, fileblock * hfd->blocksize, readblocksize);
-       if (!rdb_checksum ("FSHD", buf, fileblock)) {
-           write_log ("RDB: checksum error in FSHD block %d\n", fileblock);
+       if (!rdb_checksum (L"FSHD", buf, fileblock)) {
+           write_log (L"RDB: checksum error in FSHD block %d\n", fileblock);
            goto error;
        }
        fileblock = rl (buf + 16);
@@ -5209,12 +5446,12 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
     newversion = (buf[36] << 8) | buf[37];
     newrevision = (buf[38] << 8) | buf[39];
 
-    write_log ("RDB: RDB filesystem %08X version %d.%d\n", dostype, newversion, newrevision);
+    write_log (L"RDB: RDB filesystem %08X version %d.%d\n", dostype, newversion, newrevision);
     if (fsnode) {
-       write_log ("RDB: %08X in FileSystem.resouce version %d.%d\n", dostype, oldversion, oldrevision);
+       write_log (L"RDB: %08X in FileSystem.resouce version %d.%d\n", dostype, oldversion, oldrevision);
     }
     if (newversion * 65536 + newrevision <= oldversion * 65536 + oldrevision && oldversion >= 0) {
-       write_log ("RDB: FS in FileSystem.resource is newer or same, ignoring RDB filesystem\n");
+       write_log (L"RDB: FS in FileSystem.resource is newer or same, ignoring RDB filesystem\n");
        goto error;
     }
 
@@ -5222,7 +5459,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
        put_byte (parmpacket + PP_FSHDSTART + i, buf[32 + i]);
     put_long (parmpacket + PP_FSHDSTART, dostype);
     /* we found required FSHD block */
-    fsmem = (uae_u8*)xmalloc (262144);
+    fsmem = xmalloc (262144);
     lsegblock = rl (buf + 72);
     i = 0;
     for (;;) {
@@ -5231,7 +5468,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
            goto error;
        memset (buf, 0, readblocksize);
        hdf_read (hfd, buf, lsegblock * hfd->blocksize, readblocksize);
-       if (!rdb_checksum ("LSEG", buf, lsegblock))
+       if (!rdb_checksum (L"LSEG", buf, lsegblock))
            goto error;
        lsegblock = rl (buf + 16);
        if (lsegblock == pb)
@@ -5241,7 +5478,7 @@ static int rdb_mount (UnitInfo *uip, int unit_no, int partnum, uaecptr parmpacke
        if (lsegblock == -1)
            break;
     }
-    write_log ("RDB: Filesystem loaded, %d bytes\n", i * (blocksize - 20));
+    write_log (L"RDB: Filesystem loaded, %d bytes\n", i * (blocksize - 20));
     put_long (parmpacket + PP_FSSIZE, i * (blocksize - 20)); /* RDB filesystem size hack */
     uip->rdb_filesysstore = fsmem;
     uip->rdb_filesyssize = i * (blocksize - 20);
@@ -5268,7 +5505,7 @@ static void addfakefilesys (uaecptr parmpacket, uae_u32 dostype)
 static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket)
 {
     int i, size;
-    char tmp[1024];
+    TCHAR tmp[1024];
     struct zfile *zf;
     uae_u32 dostype, fsres, fsnode;
 
@@ -5292,25 +5529,25 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket)
     }
 
     tmp[0] = 0;
-    if (uip->filesysdir && strlen(uip->filesysdir) > 0) {
-       strcpy (tmp, uip->filesysdir);
+    if (uip->filesysdir && _tcslen(uip->filesysdir) > 0) {
+       _tcscpy (tmp, uip->filesysdir);
     } else if ((dostype & 0xffffff00) == 0x444f5300) {
-       strcpy (tmp, currprefs.romfile);
-       i = strlen (tmp);
+       _tcscpy (tmp, currprefs.romfile);
+       i = _tcslen (tmp);
        while (i > 0 && tmp[i - 1] != '/' && tmp[i - 1] != '\\')
            i--;
-       strcpy (tmp + i, "FastFileSystem");
+       _tcscpy (tmp + i, L"FastFileSystem");
     }
     if (tmp[0] == 0) {
-       write_log ("RDB: no filesystem for dostype 0x%08X\n", dostype);
+       write_log (L"RDB: no filesystem for dostype 0x%08X\n", dostype);
        if ((dostype & 0xffffff00) == 0x444f5300)
            return FILESYS_HARDFILE;
        return -1;
     }
-    write_log ("RDB: fakefilesys, trying to load '%s', dostype 0x%08X\n", tmp, dostype);
-    zf = zfile_fopen (tmp, "rb");
+    write_log (L"RDB: fakefilesys, trying to load '%s', dostype 0x%08X\n", tmp, dostype);
+    zf = zfile_fopen (tmp, L"rb");
     if (!zf) {
-       write_log ("RDB: filesys not found\n");
+       write_log (L"RDB: filesys not found\n");
        if ((dostype & 0xffffff00) == 0x444f5300)
            return FILESYS_HARDFILE;
        return -1;
@@ -5320,37 +5557,37 @@ static int dofakefilesys (UnitInfo *uip, uaecptr parmpacket)
     size = zfile_ftell (zf);
     if (size > 0) {
        zfile_fseek (zf, 0, SEEK_SET);
-       uip->rdb_filesysstore = (uae_u8*)xmalloc (size);
+       uip->rdb_filesysstore = xmalloc (size);
        zfile_fread (uip->rdb_filesysstore, size, 1, zf);
     }
     zfile_fclose (zf);
     uip->rdb_filesyssize = size;
     put_long (parmpacket + PP_FSSIZE, uip->rdb_filesyssize);
     addfakefilesys (parmpacket, dostype);
-    write_log ("HDF: faked RDB filesystem %08X loaded\n", dostype);
+    write_log (L"HDF: faked RDB filesystem %08X loaded\n", dostype);
     return FILESYS_HARDFILE;
 }
 
-static void get_new_device (int type, uaecptr parmpacket, char **devname, uaecptr *devname_amiga, int unit_no)
+static void get_new_device (int type, uaecptr parmpacket, TCHAR **devname, uaecptr *devname_amiga, int unit_no)
 {
-    char buffer[80];
+    TCHAR buffer[80];
     uaecptr expbase = get_long (parmpacket + PP_EXPLIB);
 
-    if (*devname == 0 || strlen(*devname) == 0) {
+    if (*devname == 0 || _tcslen (*devname) == 0) {
        int un = unit_no;
        for (;;) {
-           sprintf (buffer, "DH%d", un++);
+           _stprintf (buffer, L"DH%d", un++);
            if (!device_isdup (expbase, buffer))
                break;
        }
     } else {
-       strcpy (buffer, *devname);
+       _tcscpy (buffer, *devname);
     }
     *devname_amiga = ds (device_dupfix (expbase, buffer));
     if (type == FILESYS_VIRTUAL)
-       write_log ("FS: mounted virtual unit %s (%s)\n", buffer, mountinfo.ui[unit_no].rootdir);
+       write_log (L"FS: mounted virtual unit %s (%s)\n", buffer, mountinfo.ui[unit_no].rootdir);
     else
-       write_log ("FS: mounted HDF unit %s (%04x-%08x, %s)\n", buffer,
+       write_log (L"FS: mounted HDF unit %s (%04x-%08x, %s)\n", buffer,
            (uae_u32)(mountinfo.ui[unit_no].hf.virtsize >> 32),
            (uae_u32)(mountinfo.ui[unit_no].hf.virtsize),
            mountinfo.ui[unit_no].rootdir);
@@ -5373,7 +5610,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context)
     }
     if (sub_no)
        return -2;
-    write_log ("Mounting uaehf.device %d (%d):\n", unit_no, sub_no);
+    write_log (L"Mounting uaehf.device %d (%d):\n", unit_no, sub_no);
     get_new_device (type, parmpacket, &uip[unit_no].devname, &uip[unit_no].devname_amiga, unit_no);
     uip[unit_no].devno = unit_no;
     put_long (parmpacket, uip[unit_no].devname_amiga);
@@ -5437,57 +5674,57 @@ void filesys_install (void)
 {
     uaecptr loop;
 
-    TRACE (("Installing filesystem\n"));
+    TRACE ((L"Installing filesystem\n"));
 
     uae_sem_init (&singlethread_int_sem, 0, 1);
     uae_sem_init (&test_sem, 0, 1);
 
-    ROM_filesys_resname = ds("UAEunixfs.resource");
-    ROM_filesys_resid = ds("UAE unixfs 0.4");
+    ROM_filesys_resname = ds(L"UAEunixfs.resource");
+    ROM_filesys_resid = ds(L"UAE unixfs 0.4");
 
-    fsdevname = ds ("uae.device"); /* does not really exist */
+    fsdevname = ds (L"uae.device"); /* does not really exist */
 
     ROM_filesys_diagentry = here();
-    calltrap (deftrap2(filesys_diagentry, 0, "filesys_diagentry"));
+    calltrap (deftrap2(filesys_diagentry, 0, L"filesys_diagentry"));
     dw(0x4ED0); /* JMP (a0) - jump to code that inits Residents */
 
     loop = here ();
 
     org (rtarea_base + 0xFF18);
-    calltrap (deftrap2 (filesys_dev_bootfilesys, 0, "filesys_dev_bootfilesys"));
+    calltrap (deftrap2 (filesys_dev_bootfilesys, 0, L"filesys_dev_bootfilesys"));
     dw (RTS);
 
     /* Special trap for the assembly make_dev routine */
     org (rtarea_base + 0xFF20);
-    calltrap (deftrap2 (filesys_dev_remember, 0, "filesys_dev_remember"));
+    calltrap (deftrap2 (filesys_dev_remember, 0, L"filesys_dev_remember"));
     dw (RTS);
 
     org (rtarea_base + 0xFF28);
-    calltrap (deftrap2 (filesys_dev_storeinfo, 0, "filesys_dev_storeinfo"));
+    calltrap (deftrap2 (filesys_dev_storeinfo, 0, L"filesys_dev_storeinfo"));
     dw (RTS);
 
     org (rtarea_base + 0xFF30);
-    calltrap (deftrap2 (filesys_handler, 0, "filesys_handler"));
+    calltrap (deftrap2 (filesys_handler, 0, L"filesys_handler"));
     dw (RTS);
 
     org (rtarea_base + 0xFF38);
-    calltrap (deftrap2 (mousehack_done, 0, "mousehack_done"));
+    calltrap (deftrap2 (mousehack_done, 0, L"mousehack_done"));
     dw (RTS);
 
     org (rtarea_base + 0xFF40);
-    calltrap (deftrap2 (startup_handler, 0, "startup_handler"));
+    calltrap (deftrap2 (startup_handler, 0, L"startup_handler"));
     dw (RTS);
 
     org (rtarea_base + 0xFF48);
-    calltrap (deftrap2 (filesys_init_storeinfo, TRAPFLAG_EXTRA_STACK, "filesys_init_storeinfo"));
+    calltrap (deftrap2 (filesys_init_storeinfo, TRAPFLAG_EXTRA_STACK, L"filesys_init_storeinfo"));
     dw (RTS);
 
     org (rtarea_base + 0xFF50);
-    calltrap (deftrap2 (exter_int_helper, 0, "exter_int_helper"));
+    calltrap (deftrap2 (exter_int_helper, 0, L"exter_int_helper"));
     dw (RTS);
 
     org (rtarea_base + 0xFF58);
-    calltrap (deftrap2 (exall_helper, 0, "exall_helper"));
+    calltrap (deftrap2 (exall_helper, 0, L"exall_helper"));
     dw (RTS);
 
     org (loop);
@@ -5510,7 +5747,7 @@ void filesys_install_code (void)
 static uae_u8 *restore_filesys_hardfile (UnitInfo *ui, uae_u8 *src)
 {
     struct hardfiledata *hfd = &ui->hf;
-    char *s;
+    TCHAR *s;
 
     hfd->virtsize = restore_u64();
     hfd->offset = restore_u64();
@@ -5525,16 +5762,16 @@ static uae_u8 *restore_filesys_hardfile (UnitInfo *ui, uae_u8 *src)
     hfd->sectors = restore_u32();
     hfd->heads = restore_u32();
     s = restore_string();
-    strcpy (hfd->vendor_id, s);
+    _tcscpy (hfd->vendor_id, s);
     xfree(s);
     s = restore_string();
-    strcpy (hfd->product_id, s);
+    _tcscpy (hfd->product_id, s);
     xfree(s);
     s = restore_string();
-    strcpy (hfd->product_rev, s);
+    _tcscpy (hfd->product_rev, s);
     xfree(s);
     s = restore_string();
-    strcpy (hfd->device_name, s);
+    _tcscpy (hfd->device_name, s);
     xfree(s);
     return src;
 }
@@ -5562,24 +5799,24 @@ static uae_u8 *save_filesys_hardfile (UnitInfo *ui, uae_u8 *dst)
     return dst;
 }
 
-static a_inode *restore_filesys_get_base(Unit *u, char *npath)
+static a_inode *restore_filesys_get_base (Unit *u, TCHAR *npath)
 {
-    char *path, *p, *p2;
+    TCHAR *path, *p, *p2;
     a_inode *a;
     int cnt, err, i;
 
     /* no '/' = parent is root */
-    if (!strchr(npath, '/'))
+    if (!_tcschr (npath, '/'))
        return &u->rootnode;
 
     /* iterate from root to last to previous path part,
      * create ainos if not already created.
      */
-    path = (char*)xcalloc(strlen(npath) + 2, 1);
+    path = xcalloc((_tcslen(npath) + 2) * sizeof (TCHAR), 1);
     cnt = 1;
     for (;;) {
-       strcpy (path, npath);
-       strcat (path, "/");
+       _tcscpy (path, npath);
+       _tcscat (path, L"/");
        p = path;
        for (i = 0; i < cnt ;i++) {
            if (i > 0)
@@ -5592,7 +5829,7 @@ static a_inode *restore_filesys_get_base(Unit *u, char *npath)
            err = 0;
            get_aino (u, &u->rootnode, path, &err);
            if (err) {
-               write_log ("*** FS: missing path '%s'!\n", path);
+               write_log (L"*** FS: missing path '%s'!\n", path);
                return NULL;
            }
            cnt++;
@@ -5602,12 +5839,12 @@ static a_inode *restore_filesys_get_base(Unit *u, char *npath)
     }
 
     /* find base (parent) of last path part */
-    strcpy (path, npath);
+    _tcscpy (path, npath);
     p = path;
     a = u->rootnode.child;
     for (;;) {
        if (*p == 0) {
-           write_log ("*** FS: base aino NOT found '%s' ('%s')\n", a->nname, npath);
+           write_log (L"*** FS: base aino NOT found '%s' ('%s')\n", a->nname, npath);
            xfree (path);
            return NULL;
        }
@@ -5622,7 +5859,7 @@ static a_inode *restore_filesys_get_base(Unit *u, char *npath)
            }
            p = p2 + 1;
            if (*p == 0) {
-               write_log ("FS: base aino found '%s' ('%s')\n", a->nname, npath);
+               write_log (L"FS: base aino found '%s' ('%s')\n", a->nname, npath);
                xfree (path);
                return a;
            }
@@ -5630,22 +5867,22 @@ static a_inode *restore_filesys_get_base(Unit *u, char *npath)
            break;
        }
        if (!a) {
-           write_log ("*** FS: path part '%s' not found ('%s')\n", p, npath);
+           write_log (L"*** FS: path part '%s' not found ('%s')\n", p, npath);
            xfree (path);
            return NULL;
        }
     }
 }
 
-static char *makenativepath(UnitInfo *ui, char *apath)
+static TCHAR *makenativepath (UnitInfo *ui, TCHAR *apath)
 {
     int i;
-    char *pn;
+    TCHAR *pn;
     /* create native path. FIXME: handle 'illegal' characters */
-    pn = xcalloc (strlen (apath) + 1 + strlen (ui->rootdir) + 1, 1);
-    sprintf (pn, "%s/%s", ui->rootdir, apath);
+    pn = xcalloc ((_tcslen (apath) + 1 + _tcslen (ui->rootdir) + 1) * sizeof (TCHAR), 1);
+    _stprintf (pn, L"%s/%s", ui->rootdir, apath);
     if (FSDB_DIR_SEPARATOR != '/') {
-       for (i = 0; i < strlen (pn); i++) {
+       for (i = 0; i < _tcslen (pn); i++) {
            if (pn[i] == '/')
                pn[i] = FSDB_DIR_SEPARATOR;
        }
@@ -5653,15 +5890,15 @@ static char *makenativepath(UnitInfo *ui, char *apath)
     return pn;
 }
 
-static uae_u8 *restore_aino(UnitInfo *ui, Unit *u, uae_u8 *src)
+static uae_u8 *restore_aino (UnitInfo *ui, Unit *u, uae_u8 *src)
 {
-    char *p, *p2, *pn;
+    TCHAR *p, *p2, *pn;
     uae_u32 flags;
     int missing;
     a_inode *base, *a;
 
     missing = 0;
-    a = (a_inode*)xcalloc (sizeof (a_inode), 1);
+    a = xcalloc (sizeof (a_inode), 1);
     a->uniq = restore_u64 ();
     a->locked_children = restore_u32 ();
     a->exnext_count = restore_u32 ();
@@ -5673,64 +5910,64 @@ static uae_u8 *restore_aino(UnitInfo *ui, Unit *u, uae_u8 *src)
     p = restore_string ();
     /* root (p = volume label) */
     if (a->uniq == 0) {
-       a->nname = my_strdup(ui->rootdir);
+       a->nname = my_strdup (ui->rootdir);
        a->aname = p;
        a->dir = 1;
        if (ui->volflags < 0) {
-           write_log ("FS: Volume '%s' ('%s') missing!\n", a->aname, a->nname);
+           write_log (L"FS: Volume '%s' ('%s') missing!\n", a->aname, a->nname);
        } else {
            a->volflags = ui->volflags;
            recycle_aino (u, a);
-           write_log ("FS: Lock (root) '%s' ('%s')\n", a->aname, a->nname);
+           write_log (L"FS: Lock (root) '%s' ('%s')\n", a->aname, a->nname);
        }
        return src;
     }
-    p2 = strrchr(p, '/');
+    p2 = _tcsrchr(p, '/');
     if (p2)
        p2++;
     else
        p2 = p;
-    pn = makenativepath(ui, p);
+    pn = makenativepath (ui, p);
     a->nname = pn;
-    a->aname = my_strdup(p2);
+    a->aname = my_strdup (p2);
     /* find parent of a->aname (Already restored previously. I hope..) */
     if (p2 != p)
        p2[-1] = 0;
-    base = restore_filesys_get_base(u, p);
+    base = restore_filesys_get_base (u, p);
     xfree(p);
     if (flags & 2) {
        a->dir = 1;
        if (!my_existsdir(a->nname))
-           write_log ("*** FS: Directory '%s' missing!\n", a->nname);
+           write_log (L"*** FS: Directory '%s' missing!\n", a->nname);
        else
            fsdb_clean_dir (a);
     } else {
        if (!my_existsfile(a->nname))
-           write_log ("*** FS: File '%s' missing!\n", a->nname);
+           write_log (L"*** FS: File '%s' missing!\n", a->nname);
     }
     if (base) {
        fill_file_attrs (u, base, a);
        init_child_aino_tree (u, base, a);
     } else {
-       write_log ("*** FS: parent directory missing '%s' ('%s')\n", a->aname, a->nname);
+       write_log (L"*** FS: parent directory missing '%s' ('%s')\n", a->aname, a->nname);
        missing = 1;
     }
     if (missing) {
-       write_log ("*** FS: Lock restore failed '%s' ('%s')\n", a->aname, a->nname);
+       write_log (L"*** FS: Lock restore failed '%s' ('%s')\n", a->aname, a->nname);
        xfree (a->nname);
        xfree (a->aname);
        xfree (a);
     } else {
-       write_log ("FS: Lock '%s' ('%s')\n", a->aname, a->nname);
+       write_log (L"FS: Lock '%s' ('%s')\n", a->aname, a->nname);
        recycle_aino (u, a);
     }
     return src;
 }
 
-static uae_u8 *restore_key(UnitInfo *ui, Unit *u, uae_u8 *src)
+static uae_u8 *restore_key (UnitInfo *ui, Unit *u, uae_u8 *src)
 {
     int savedsize, uniq;
-    char *p, *pn;
+    TCHAR *p, *pn;
     mode_t openmode;
     DWORD err;
     int missing;
@@ -5738,33 +5975,35 @@ static uae_u8 *restore_key(UnitInfo *ui, Unit *u, uae_u8 *src)
     Key *k;
 
     missing = 0;
-    k = (Key*)xcalloc(sizeof(Key), 1);
-    k->uniq = restore_u64();
-    k->file_pos = restore_u32();
-    k->createmode = restore_u32();
-    k->dosmode = restore_u32();
-    savedsize = restore_u32();
-    uniq = restore_u64();
-    p = restore_string();
+    k = xcalloc (sizeof(Key), 1);
+    k->uniq = restore_u64 ();
+    k->file_pos = restore_u32 ();
+    k->createmode = restore_u32 ();
+    k->dosmode = restore_u32 ();
+    savedsize = restore_u32 ();
+    uniq = restore_u64 ();
+    p = restore_string ();
+    restore_u64 ();
+    restore_u64 ();
     pn = makenativepath (ui, p);
     openmode = ((k->dosmode & A_FIBF_READ) == 0 ? O_WRONLY
         : (k->dosmode & A_FIBF_WRITE) == 0 ? O_RDONLY
         : O_RDWR);
-    write_log ("FS: open file '%s' ('%s'), pos=%d\n", p, pn, k->file_pos);
+    write_log (L"FS: open file '%s' ('%s'), pos=%d\n", p, pn, k->file_pos);
     a = get_aino (u, &u->rootnode, p, &err);
     if (!a)
-       write_log ("*** FS: Open file aino creation failed '%s'\n", p);
+       write_log (L"*** FS: Open file aino creation failed '%s'\n", p);
     missing = 1;
     if (a) {
        missing = 0;
        k->aino = a;
        if (a->uniq != uniq)
-           write_log ("*** FS: Open file '%s' aino id %d != %d\n", p, uniq, a->uniq);
+           write_log (L"*** FS: Open file '%s' aino id %d != %d\n", p, uniq, a->uniq);
        if (!my_existsfile(pn)) {
-           write_log ("*** FS: Open file '%s' is missing, creating dummy file!\n", p);
+           write_log (L"*** FS: Open file '%s' is missing, creating dummy file!\n", p);
            k->fd = fs_open (u, pn, openmode | O_CREAT |O_BINARY);
            if (k->fd) {
-               uae_u8 *buf = (uae_u8*)xcalloc (10000, 1);
+               uae_u8 *buf = xcalloc (10000, 1);
                int sp = savedsize;
                while (sp) {
                    int s = sp >= 10000 ? 10000 : sp;
@@ -5772,26 +6011,26 @@ static uae_u8 *restore_key(UnitInfo *ui, Unit *u, uae_u8 *src)
                    sp -= s;
                }
                xfree(buf);
-               write_log ("*** FS: dummy file created\n");
+               write_log (L"*** FS: dummy file created\n");
            } else {
-               write_log ("*** FS: Open file '%s', couldn't create dummy file!\n", p);
+               write_log (L"*** FS: Open file '%s', couldn't create dummy file!\n", p);
            }
        } else {
            k->fd = fs_open (u, pn, openmode | O_BINARY);
        }
        if (!k->fd) {
-           write_log ("*** FS: Open file '%s' failed to open!\n", p);
+           write_log (L"*** FS: Open file '%s' failed to open!\n", p);
            missing = 1;
        } else {
-           size_t s;
-           s = fs_lseek (u, k->fd, 0, SEEK_END);
+           uae_s64 s;
+           s = fs_lseek64 (u, k->fd, 0, SEEK_END);
            if (s != savedsize)
-               write_log ("FS: restored file '%s' size changed! orig=%d, now=%d!!\n", p, savedsize, s);
+               write_log (L"FS: restored file '%s' size changed! orig=%d, now=%d!!\n", p, savedsize, s);
            if (k->file_pos > s) {
-               write_log ("FS: restored filepos larger than size of file '%s'!! %d > %d\n", p, k->file_pos, s);
+               write_log (L"FS: restored filepos larger than size of file '%s'!! %d > %d\n", p, k->file_pos, s);
                k->file_pos = s;
            }
-           fs_lseek (u,k->fd, k->file_pos, SEEK_SET);
+           fs_lseek64 (u,k->fd, k->file_pos, SEEK_SET);
        }
     }
     xfree (p);
@@ -5808,14 +6047,14 @@ static uae_u8 *restore_notify (UnitInfo *ui, Unit *u, uae_u8 *src)
 {
     Notify *n = xcalloc (sizeof (Notify), 1);
     uae_u32 hash;
-    char *s;
+    TCHAR *s;
 
     n->notifyrequest = restore_u32 ();
     s = restore_string ();
-    n->fullname = xmalloc (strlen (ui->volname) + 2 + strlen (s) + 1);
-    sprintf (n->fullname, "%s:%s", ui->volname, s);
+    n->fullname = xmalloc ((_tcslen (ui->volname) + 2 + _tcslen (s) + 1) * sizeof (TCHAR));
+    _stprintf (n->fullname, L"%s:%s", ui->volname, s);
     xfree(s);
-    s = strrchr (n->fullname, '/');
+    s = _tcsrchr (n->fullname, '/');
     if (s)
        s++;
     else
@@ -5824,7 +6063,7 @@ static uae_u8 *restore_notify (UnitInfo *ui, Unit *u, uae_u8 *src)
     hash = notifyhash (n->fullname);
     n->next = u->notifyhash[hash];
     u->notifyhash[hash] = n;
-    write_log ("FS: notify %08X '%s' '%s'\n", n->notifyrequest, n->fullname, n->partname);
+    write_log (L"FS: notify %08X '%s' '%s'\n", n->notifyrequest, n->fullname, n->partname);
     return src;
 }
 
@@ -5854,38 +6093,38 @@ static uae_u8 *restore_filesys_virtual (UnitInfo *ui, uae_u8 *src, int num)
     u->volflags = ui->volflags;
 
     cnt = restore_u32 ();
-    write_log ("FS: restoring %d locks\n", cnt);
+    write_log (L"FS: restoring %d locks\n", cnt);
     while (cnt-- > 0)
        src = restore_aino(ui, u, src);
 
     cnt = restore_u32 ();
-    write_log ("FS: restoring %d open files\n", cnt);
+    write_log (L"FS: restoring %d open files\n", cnt);
     while (cnt-- > 0)
        src = restore_key(ui, u, src);
 
     cnt = restore_u32 ();
-    write_log ("FS: restoring %d notifications\n", cnt);
+    write_log (L"FS: restoring %d notifications\n", cnt);
     while (cnt-- > 0)
        src = restore_notify (ui, u, src);
 
     cnt = restore_u32 ();
-    write_log ("FS: restoring %d exkeys\n", cnt);
+    write_log (L"FS: restoring %d exkeys\n", cnt);
     while (cnt-- > 0)
        src = restore_exkey (ui, u, src);
 
     return src;
 }
 
-static char *getfullaname(a_inode *a)
+static TCHAR *getfullaname(a_inode *a)
 {
-    char *p;
+    TCHAR *p;
     int first = 1;
 
-    p = (char*)xcalloc (2000, 1);
+    p = xcalloc (2000 * sizeof (TCHAR), 1);
     while (a) {
-       int len = strlen (a->aname);
-       memmove (p + len + 1, p, strlen (p) + 1);
-       memcpy (p, a->aname, strlen (a->aname));
+       int len = _tcslen (a->aname);
+       memmove (p + len + 1, p, (_tcslen (p) + 1) * sizeof (TCHAR));
+       memcpy (p, a->aname, _tcslen (a->aname) * sizeof (TCHAR));
        if (!first)
            p[len] = '/';
        first = 0;
@@ -5909,10 +6148,10 @@ static int recurse_aino (UnitInfo *ui, a_inode *a, int cnt, uae_u8 **dstp)
        //write_log("recurse '%s' '%s' %d %08x\n", a->aname, a->nname, a->uniq, a->parent);
        if (a->elock || a->shlock || a->uniq == 0) {
            if (dst) {
-               char *fn;
-               write_log ("%04x s=%d e=%d d=%d '%s' '%s'\n", a->uniq, a->shlock, a->elock, a->dir, a->aname, a->nname);
+               TCHAR *fn;
+               write_log (L"%04x s=%d e=%d d=%d '%s' '%s'\n", a->uniq, a->shlock, a->elock, a->dir, a->aname, a->nname);
                fn = getfullaname(a);
-               write_log ("->'%s'\n", fn);
+               write_log (L"->'%s'\n", fn);
                save_u64 (a->uniq);
                save_u32 (a->locked_children);
                save_u32 (a->exnext_count);
@@ -5936,20 +6175,22 @@ static int recurse_aino (UnitInfo *ui, a_inode *a, int cnt, uae_u8 **dstp)
     return cnt;
 }
 
-static uae_u8 *save_key(uae_u8 *dst, Key *k)
+static uae_u8 *save_key (uae_u8 *dst, Key *k)
 {
-    char *fn = getfullaname(k->aino);
-    int size;
+    TCHAR *fn = getfullaname (k->aino);
+    uae_u64 size;
     save_u64 (k->uniq);
-    save_u32 (k->file_pos);
+    save_u32 ((uae_u32)k->file_pos);
     save_u32 (k->createmode);
     save_u32 (k->dosmode);
     size = my_lseek (k->fd, 0, SEEK_END);
-    save_u32 (size);
+    save_u32 ((uae_u32)size);
     save_u64 (k->aino->uniq);
     my_lseek (k->fd, k->file_pos, SEEK_SET);
     save_string (fn);
-    write_log ("'%s' uniq=%d size=%d seekpos=%d mode=%d dosmode=%d\n",
+    save_u64 (k->file_pos);
+    save_u64 (size);
+    write_log (L"'%s' uniq=%d size=%d seekpos=%d mode=%d dosmode=%d\n",
        fn, k->uniq, size, k->file_pos, k->createmode, k->dosmode);
     xfree (fn);
     return dst;
@@ -5957,13 +6198,13 @@ static uae_u8 *save_key(uae_u8 *dst, Key *k)
 
 static uae_u8 *save_notify (UnitInfo *ui, uae_u8 *dst, Notify *n)
 {
-    char *s;
-    save_u32(n->notifyrequest);
+    TCHAR *s;
+    save_u32 (n->notifyrequest);
     s = n->fullname;
-    if (strlen (s) >= strlen (ui->volname) && !memcmp (n->fullname, ui->volname, strlen (ui->volname)))
-       s = n->fullname + strlen (ui->volname) + 1;
+    if (_tcslen (s) >= _tcslen (ui->volname) && !_tcsncmp (n->fullname, ui->volname, _tcslen (ui->volname)))
+       s = n->fullname + _tcslen (ui->volname) + 1;
     save_string (s);
-    write_log ("FS: notify %08X '%s'\n", n->notifyrequest, n->fullname);
+    write_log (L"FS: notify %08X '%s'\n", n->notifyrequest, n->fullname);
     return dst;
 }
 
@@ -5981,7 +6222,7 @@ static uae_u8 *save_filesys_virtual (UnitInfo *ui, uae_u8 *dst)
     Key *k;
     int cnt, i, j;
 
-    write_log ("FSSAVE: '%s'\n", ui->devname);
+    write_log (L"FSSAVE: '%s'\n", ui->devname);
     save_u32 (u->dosbase);
     save_u32 (u->volume);
     save_u32 (u->port);
@@ -5994,13 +6235,13 @@ static uae_u8 *save_filesys_virtual (UnitInfo *ui, uae_u8 *dst)
     save_u32 (u->total_locked_ainos);
     cnt = recurse_aino (ui, &u->rootnode, 0, NULL);
     save_u32 (cnt);
-    write_log ("%d open locks\n", cnt);
+    write_log (L"%d open locks\n", cnt);
     cnt = recurse_aino (ui, &u->rootnode, 0, &dst);
     cnt = 0;
     for (k = u->keys; k; k = k->next)
        cnt++;
     save_u32 (cnt);
-    write_log ("%d open files\n", cnt);
+    write_log (L"%d open files\n", cnt);
     for (k = u->keys; k; k = k->next)
        dst = save_key (dst, k);
     for (j = 0; j < 2; j++) {
@@ -6016,7 +6257,7 @@ static uae_u8 *save_filesys_virtual (UnitInfo *ui, uae_u8 *dst)
        }
        if (j == 0) {
            save_u32 (cnt);
-           write_log ("%d notify requests\n", cnt);
+           write_log (L"%d notify requests\n", cnt);
        }
     }
     for (j = 0; j < 2; j++) {
@@ -6031,10 +6272,10 @@ static uae_u8 *save_filesys_virtual (UnitInfo *ui, uae_u8 *dst)
        }
        if (j == 0) {
            save_u32 (cnt);
-           write_log ("%d exkeys\n", cnt);
+           write_log (L"%d exkeys\n", cnt);
        }
     }
-    write_log ("END\n");
+    write_log (L"END\n");
     return dst;
 }
 
@@ -6074,7 +6315,7 @@ uae_u8 *save_filesys (int num, int *len)
     /* not initialized yet, do not save */
     if (type == FILESYS_VIRTUAL && (ui->self == NULL || ui->volname == NULL))
        return NULL;
-    write_log ("FS_FILESYS: '%s' '%s'\n", ui->devname, ui->volname);
+    write_log (L"FS_FILESYS: '%s' '%s'\n", ui->devname, ui->volname);
     dstbak = dst = xmalloc (100000);
     save_u32 (2); /* version */
     save_u32 (ui->devno);
@@ -6099,7 +6340,7 @@ uae_u8 *restore_filesys (uae_u8 *src)
 {
     int type, devno;
     UnitInfo *ui;
-    char *devname = 0, *volname = 0, *rootdir = 0, *filesysdir = 0;
+    TCHAR *devname = 0, *volname = 0, *rootdir = 0, *filesysdir = 0;
     int bootpri, readonly;
 
     if (restore_u32 () != 2)
@@ -6123,12 +6364,12 @@ uae_u8 *restore_filesys (uae_u8 *src)
     if (set_filesys_unit (devno, devname, volname, rootdir, readonly,
        ui->hf.secspertrack, ui->hf.surfaces, ui->hf.reservedblocks, ui->hf.blocksize,
        bootpri, 0, 1, filesysdir[0] ? filesysdir : NULL, 0, 0) < 0) {
-       write_log ("filesys '%s' failed to restore\n", rootdir);
+       write_log (L"filesys '%s' failed to restore\n", rootdir);
        goto end;
     }
     if (type == FILESYS_VIRTUAL)
        src = restore_filesys_virtual (ui, src, devno);
-    write_log ("'%s' restored\n", rootdir);
+    write_log (L"'%s' restored\n", rootdir);
 end:
     xfree (rootdir);
     xfree (devname);
diff --git a/fpp.c b/fpp.c
index 72c4a98c681b0abe6a4feabcdc83718b7e16336a..e46d50c498cbd23ad1518de8153c03ccd9098edf 100644 (file)
--- a/fpp.c
+++ b/fpp.c
@@ -163,7 +163,7 @@ static void fpu_op_illg (uae_u32 opcode, struct regstruct *regs, int pcoffset)
        put_long (m68k_areg (regs, 7), newpc);
        m68k_areg (regs, 7) -= 2;
        put_word (m68k_areg (regs, 7), regs->sr);
-       write_log("68040/060 FPU disabled exception PC=%x\n", newpc);
+       write_log (L"68040/060 FPU disabled exception PC=%x\n", newpc);
        newpc = get_long (regs->vbr + 11 * 4);
        m68k_setpc (regs, newpc);
        set_special (regs, SPCFLAG_END_COMPILE);
@@ -513,7 +513,7 @@ STATIC_INLINE int put_fp_value (struct regstruct *regs, fptype value, uae_u32 op
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("PUTFP: %f %04X %04X\n", value, opcode, extra);
+       write_log (L"PUTFP: %f %04X %04X\n", value, opcode, extra);
 #endif
     if (!(extra & 0x4000)) {
        regs->fp[(extra >> 10) & 7] = value;
@@ -779,7 +779,7 @@ void fpuop_dbcc (uae_u32 opcode, struct regstruct *regs, uae_u16 extra)
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("fdbcc_opp at %08lx\n", m68k_getpc (regs));
+       write_log (L"fdbcc_opp at %08lx\n", m68k_getpc (regs));
 #endif
     if (fault_if_no_fpu (opcode, regs, 4))
        return;
@@ -805,7 +805,7 @@ void fpuop_scc (uae_u32 opcode, struct regstruct *regs, uae_u16 extra)
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("fscc_opp at %08lx\n", m68k_getpc (regs));
+       write_log (L"fscc_opp at %08lx\n", m68k_getpc (regs));
 #endif
     if (fault_if_no_fpu (opcode, regs, 4))
        return;
@@ -830,7 +830,7 @@ void fpuop_trapcc (uae_u32 opcode, struct regstruct *regs, uaecptr oldpc)
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("ftrapcc_opp at %08lx\n", m68k_getpc (regs));
+       write_log (L"ftrapcc_opp at %08lx\n", m68k_getpc (regs));
 #endif
     if (fault_if_no_fpu (opcode, regs, m68k_getpc(regs) - oldpc))
        return;
@@ -849,7 +849,7 @@ void fpuop_bcc (uae_u32 opcode, struct regstruct *regs, uaecptr pc, uae_u32 extr
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("fbcc_opp at %08lx\n", m68k_getpc (regs));
+       write_log (L"fbcc_opp at %08lx\n", m68k_getpc (regs));
 #endif
     if (fault_if_no_fpu (opcode, regs, m68k_getpc(regs) - pc))
        return;
@@ -873,7 +873,7 @@ void fpuop_save (uae_u32 opcode, struct regstruct *regs)
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("fsave_opp at %08lx\n", m68k_getpc (regs));
+       write_log (L"fsave_opp at %08lx\n", m68k_getpc (regs));
 #endif
     if (fault_if_no_fpu (opcode, regs, 2))
        return;
@@ -945,7 +945,7 @@ void fpuop_restore (uae_u32 opcode, struct regstruct *regs)
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("frestore_opp at %08lx\n", m68k_getpc (regs));
+       write_log (L"frestore_opp at %08lx\n", m68k_getpc (regs));
 #endif
     if (fault_if_no_fpu (opcode, regs, 2))
        return;
@@ -1036,7 +1036,7 @@ void fpuop_arithmetic (uae_u32 opcode, struct regstruct *regs, uae_u16 extra)
 
 #if DEBUG_FPP
     if (!isinrom ())
-       write_log ("FPP %04lx %04x at %08lx\n", opcode & 0xffff, extra, m68k_getpc (regs) - 4);
+       write_log (L"FPP %04lx %04x at %08lx\n", opcode & 0xffff, extra, m68k_getpc (regs) - 4);
 #endif
     if (fault_if_no_fpu (opcode, regs, 4))
        return;
@@ -1642,7 +1642,7 @@ uae_u8 *restore_fpu (uae_u8 *src)
        restore_u32();
        restore_u32();
     }
-    write_log ("FPU=%d\n", currprefs.fpu_model);
+    write_log (L"FPU=%d\n", currprefs.fpu_model);
     return src;
 }
 
diff --git a/fsdb.c b/fsdb.c
index 3552b92ead9b63b67a11038c1e29263fe67ccdcb..6129ab4f131ffcabc4a279591127ae481be03b55 100644 (file)
--- a/fsdb.c
+++ b/fsdb.c
@@ -36,9 +36,9 @@
 #define TRACE(x)
 #endif
 
-char *nname_begin (char *nname)
+TCHAR *nname_begin (TCHAR *nname)
 {
-    char *p = strrchr (nname, FSDB_DIR_SEPARATOR);
+    TCHAR *p = _tcsrchr (nname, FSDB_DIR_SEPARATOR);
     if (p)
        return p + 1;
     return nname;
@@ -50,12 +50,12 @@ char *nname_begin (char *nname)
  * has the same name when compared case-insensitively, return a
  * malloced string that contains the name we found.  If no file
  * exists that compares equal to REL, return 0.  */
-char *fsdb_search_dir (const char *dirname, char *rel)
+TCHAR *fsdb_search_dir (const TCHAR *dirname, TCHAR *rel)
 {
-    char *p = 0;
+    TCHAR *p = 0;
     int de;
     void *dir;
-    char fn[MAX_DPATH];
+    TCHAR fn[MAX_DPATH];
 
     dir = my_opendir (dirname);
     /* This really shouldn't happen...  */
@@ -73,27 +73,27 @@ char *fsdb_search_dir (const char *dirname, char *rel)
 }
 #endif
 
-static FILE *get_fsdb (a_inode *dir, const char *mode)
+static FILE *get_fsdb (a_inode *dir, const TCHAR *mode)
 {
-    char *n;
+    TCHAR *n;
     FILE *f;
 
     n = build_nname (dir->nname, FSDB_FILE);
-    f = fopen (n, mode);
+    f = _tfopen (n, mode);
     free (n);
     return f;
 }
 
 static void kill_fsdb (a_inode *dir)
 {
-    char *n = build_nname (dir->nname, FSDB_FILE);
-    unlink (n);
-    free (n);
+    TCHAR *n = build_nname (dir->nname, FSDB_FILE);
+    _wunlink (n);
+    xfree (n);
 }
 
-static void fsdb_fixup (FILE *f, char *buf, int size, a_inode *base)
+static void fsdb_fixup (FILE *f, TCHAR *buf, int size, a_inode *base)
 {
-    char *nname;
+    TCHAR *nname;
     int ret;
 
     if (buf[0] == 0)
@@ -104,7 +104,7 @@ static void fsdb_fixup (FILE *f, char *buf, int size, a_inode *base)
        free (nname);
        return;
     }
-    TRACE (("uaefsdb '%s' deleted\n", nname));
+    TRACE ((L"uaefsdb '%s' deleted\n", nname));
     /* someone deleted this file/dir outside of emulation.. */
     buf[0] = 0;
     free (nname);
@@ -113,13 +113,13 @@ static void fsdb_fixup (FILE *f, char *buf, int size, a_inode *base)
 /* Prune the db file the first time this directory is opened in a session.  */
 void fsdb_clean_dir (a_inode *dir)
 {
-    char buf[1 + 4 + 257 + 257 + 81];
-    char *n;
+    TCHAR buf[1 + 4 + 257 + 257 + 81];
+    TCHAR *n;
     FILE *f;
     off_t pos1 = 0, pos2;
 
     n = build_nname (dir->nname, FSDB_FILE);
-    f = fopen (n, "r+b");
+    f = _tfopen (n, L"r+b");
     if (f == 0) {
        free (n);
        return;
@@ -143,18 +143,21 @@ void fsdb_clean_dir (a_inode *dir)
     free (n);
 }
 
-static a_inode *aino_from_buf (a_inode *base, char *buf, long off)
+static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, long off)
 {
     uae_u32 mode;
     a_inode *aino = (a_inode *) xcalloc (sizeof (a_inode), 1);
+    TCHAR *s;
 
     mode = do_get_mem_long ((uae_u32 *)(buf + 1));
     buf += 5;
-    aino->aname = my_strdup (buf);
+    aino->aname = au (buf);
     buf += 257;
-    aino->nname = build_nname (base->nname, buf);
+    s = au (buf);
+    aino->nname = build_nname (base->nname, s);
+    xfree (s);
     buf += 257;
-    aino->comment = *buf != '\0' ? my_strdup (buf) : 0;
+    aino->comment = *buf != '\0' ? au (buf) : 0;
     fsdb_fill_file_attrs (base, aino);
     aino->amigaos_mode = mode;
     aino->has_dbentry = 1;
@@ -163,74 +166,86 @@ static a_inode *aino_from_buf (a_inode *base, char *buf, long off)
     return aino;
 }
 
-a_inode *fsdb_lookup_aino_aname (a_inode *base, const char *aname)
+a_inode *fsdb_lookup_aino_aname (a_inode *base, const TCHAR *aname)
 {
     FILE *f;
 
-    f = get_fsdb (base, "r+b");
+    f = get_fsdb (base, L"r+b");
     if (f == 0) {
        if (currprefs.filesys_custom_uaefsdb && (base->volflags & MYVOLUMEINFO_STREAMS))
            return custom_fsdb_lookup_aino_aname (base, aname);
        return 0;
     }
     for (;;) {
-       char buf[1 + 4 + 257 + 257 + 81];
+       uae_u8 buf[1 + 4 + 257 + 257 + 81];
+       TCHAR *s;
        if (fread (buf, 1, sizeof buf, f) < sizeof buf)
            break;
-       if (buf[0] != 0 && same_aname (buf + 5, aname)) {
+       s = au (buf + 5);
+       if (buf[0] != 0 && same_aname (s, aname)) {
            long pos = ftell (f) - sizeof buf;
            fclose (f);
+           xfree (s);
            return aino_from_buf (base, buf, pos);
        }
+       xfree (s);
     }
     fclose (f);
     return 0;
 }
 
-a_inode *fsdb_lookup_aino_nname (a_inode *base, const char *nname)
+a_inode *fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname)
 {
     FILE *f;
+    char *s;
 
-    f = get_fsdb (base, "r+b");
+    f = get_fsdb (base, L"r+b");
     if (f == 0) {
        if (currprefs.filesys_custom_uaefsdb && (base->volflags & MYVOLUMEINFO_STREAMS))
            return custom_fsdb_lookup_aino_nname (base, nname);
        return 0;
     }
+    s = ua (nname);
     for (;;) {
-       char buf[1 + 4 + 257 + 257 + 81];
+       uae_u8 buf[1 + 4 + 257 + 257 + 81];
        if (fread (buf, 1, sizeof buf, f) < sizeof buf)
            break;
-       if (buf[0] != 0 && strcmp (buf + 5 + 257, nname) == 0) {
+       if (buf[0] != 0 && strcmp (buf + 5 + 257, s) == 0) {
            long pos = ftell (f) - sizeof buf;
            fclose (f);
+           xfree (s);
            return aino_from_buf (base, buf, pos);
        }
     }
+    xfree (s);
     fclose (f);
     return 0;
 }
 
-int fsdb_used_as_nname (a_inode *base, const char *nname)
+int fsdb_used_as_nname (a_inode *base, const TCHAR *nname)
 {
     FILE *f;
-    char buf[1 + 4 + 257 + 257 + 81];
+    uae_u8 buf[1 + 4 + 257 + 257 + 81];
 
-    f = get_fsdb (base, "r+b");
+    f = get_fsdb (base, L"r+b");
     if (f == 0) {
        if (currprefs.filesys_custom_uaefsdb && (base->volflags & MYVOLUMEINFO_STREAMS))
            return custom_fsdb_used_as_nname (base, nname);
        return 0;
     }
     for (;;) {
+       TCHAR *s;
        if (fread (buf, 1, sizeof buf, f) < sizeof buf)
            break;
        if (buf[0] == 0)
            continue;
-       if (strcmp (buf + 5 + 257, nname) == 0) {
+       s = au (buf + 5 + 257);
+       if (_tcscmp (s, nname) == 0) {
+           xfree (s);
            fclose (f);
            return 1;
        }
+       xfree (s);
     }
     fclose (f);
     return 0;
@@ -238,7 +253,7 @@ int fsdb_used_as_nname (a_inode *base, const char *nname)
 
 static int needs_dbentry (a_inode *aino)
 {
-    const char *nn_begin;
+    const TCHAR *nn_begin;
 
     if (aino->deleted)
        return 0;
@@ -247,24 +262,25 @@ static int needs_dbentry (a_inode *aino)
        return 1;
 
     nn_begin = nname_begin (aino->nname);
-    return strcmp (nn_begin, aino->aname) != 0;
+    return _tcscmp (nn_begin, aino->aname) != 0;
 }
 
 static void write_aino (FILE *f, a_inode *aino)
 {
-    char buf[1 + 4 + 257 + 257 + 81];
+    uae_u8 buf[1 + 4 + 257 + 257 + 81];
+
     buf[0] = aino->needs_dbentry;
     do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode);
-    strncpy (buf + 5, aino->aname, 256);
+    ua_copy (buf + 5, 256, aino->aname);
     buf[5 + 256] = '\0';
-    strncpy (buf + 5 + 257, nname_begin (aino->nname), 256);
+    ua_copy (buf + 5 + 257, 256, nname_begin (aino->nname));
     buf[5 + 257 + 256] = '\0';
-    strncpy (buf + 5 + 2 * 257, aino->comment ? aino->comment : "", 80);
+    ua_copy (buf + 5 + 2 * 257, 80, aino->comment ? aino->comment : L"");
     buf[5 + 2 * 257 + 80] = '\0';
     aino->db_offset = ftell (f);
     fwrite (buf, 1, sizeof buf, f);
     aino->has_dbentry = aino->needs_dbentry;
-    TRACE (("%d '%s' '%s' written\n", aino->db_offset, aino->aname, aino->nname));
+    TRACE ((L"%d '%s' '%s' written\n", aino->db_offset, aino->aname, aino->nname));
 }
 
 /* Write back the db file for a directory.  */
@@ -278,7 +294,7 @@ void fsdb_dir_writeback (a_inode *dir)
     uae_u8 *tmpbuf;
     int size, i;
 
-    TRACE (("fsdb writeback %s\n", dir->aname));
+    TRACE ((L"fsdb writeback %s\n", dir->aname));
     /* First pass: clear dirty bits where unnecessary, and see if any work
      * needs to be done.  */
     for (aino = dir->child; aino; aino = aino->sibling) {
@@ -300,16 +316,16 @@ void fsdb_dir_writeback (a_inode *dir)
     }
     if (! entries_needed) {
        kill_fsdb (dir);
-       TRACE (("fsdb removed\n"));
+       TRACE ((L"fsdb removed\n"));
        return;
     }
 
     if (! changes_needed) {
-       TRACE (("not modified\n"));
+       TRACE ((L"not modified\n"));
        return;
     }
 
-    f = get_fsdb (dir, "r+b");
+    f = get_fsdb (dir, L"r+b");
     if (f == 0) {
        if ((currprefs.filesys_custom_uaefsdb  && (dir->volflags & MYVOLUMEINFO_STREAMS)) || currprefs.filesys_no_uaefsdb) {
            for (aino = dir->child; aino; aino = aino->sibling) {
@@ -319,9 +335,9 @@ void fsdb_dir_writeback (a_inode *dir)
            }
            return;
        }
-       f = get_fsdb (dir, "w+b");
+       f = get_fsdb (dir, L"w+b");
        if (f == 0) {
-           TRACE (("failed\n"));
+           TRACE ((L"failed\n"));
            /* This shouldn't happen... */
            return;
        }
@@ -334,7 +350,7 @@ void fsdb_dir_writeback (a_inode *dir)
        tmpbuf = (uae_u8*)malloc (size);
        fread (tmpbuf, 1, size, f);
     }
-    TRACE (("**** updating '%s' %d\n", dir->aname, size));
+    TRACE ((L"**** updating '%s' %d\n", dir->aname, size));
 
     for (aino = dir->child; aino; aino = aino->sibling) {
        if (! aino->dirty)
@@ -343,10 +359,12 @@ void fsdb_dir_writeback (a_inode *dir)
 
        i = 0;
        while (!aino->has_dbentry && i < size) {
-           if (!strcmp (tmpbuf + i + 5, aino->aname)) {
+           TCHAR *s = au (tmpbuf + i +  5);
+           if (!_tcscmp (s, aino->aname)) {
                aino->has_dbentry = 1;
                aino->db_offset = i;
            }
+           xfree (s);
            i += 1 + 4 + 257 + 257 + 81;
        }
 
@@ -358,7 +376,7 @@ void fsdb_dir_writeback (a_inode *dir)
        }
        write_aino (f, aino);
     }
-    TRACE (("end\n"));
+    TRACE ((L"end\n"));
     fclose (f);
     free (tmpbuf);
 }
index 2259911acb826d187aa222a8e81acb8b346a3e8f..7515653bc3032a0897e5ce22804a9342a6d17ca7 100644 (file)
--- a/fsusage.c
+++ b/fsusage.c
@@ -49,23 +49,23 @@ static long adjust_blocks (long blocks, int fromsize, int tosize)
 #include "sysdeps.h"
 #include "od-win32/posixemu.h"
 #include <windows.h>
-int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
+int get_fs_usage (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp)
 {
-    char buf2[MAX_DPATH];
+    TCHAR buf2[MAX_DPATH];
     ULARGE_INTEGER FreeBytesAvailable, TotalNumberOfBytes, TotalNumberOfFreeBytes;
 
-    if (!GetFullPathName (path, sizeof buf2, buf2, NULL)) {
-       write_log ("GetFullPathName() failed err=%d\n", GetLastError());
+    if (!GetFullPathName (path, sizeof buf2 / sizeof (TCHAR), buf2, NULL)) {
+       write_log (L"GetFullPathName() failed err=%d\n", GetLastError());
        return -1;
     }
 
-    if (!memcmp (buf2, "\\\\", 2)) {
-       char *p;
-       strcat(buf2, "\\");
-       p = strchr(buf2 + 2, '\\');
+    if (!_tcsncmp (buf2, L"\\\\", 2)) {
+       TCHAR *p;
+       _tcscat (buf2, L"\\");
+       p = _tcschr (buf2 + 2, '\\');
        if (!p)
            return -1;
-       p = strchr(p + 1, '\\');
+       p = _tcschr (p + 1, '\\');
        if (!p)
            return -1;
        p[1] = 0;
@@ -74,7 +74,7 @@ int get_fs_usage (const char *path, const char *disk, struct fs_usage *fsp)
     }
 
     if (!GetDiskFreeSpaceEx (buf2, &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)) {
-       write_log ("GetDiskFreeSpaceEx() failed err=%d\n", GetLastError());
+       write_log (L"GetDiskFreeSpaceEx() failed err=%d\n", GetLastError());
        return -1;
     }
 
@@ -139,7 +139,7 @@ int statvfs ();
 int
 safe_read (desc, ptr, len)
      int desc;
-     char *ptr;
+     TCHAR *ptr;
      int len;
 {
   int n_chars;
@@ -169,8 +169,8 @@ safe_read (desc, ptr, len)
    on a system that requires a non-NULL value.  */
 int
 get_fs_usage (path, disk, fsp)
-     const char *path;
-     const char *disk;
+     const TCHAR *path;
+     const TCHAR *disk;
      struct fs_usage *fsp;
 {
 #ifdef STAT_STATFS3_OSF1
@@ -218,7 +218,7 @@ get_fs_usage (path, disk, fsp)
   if (fd < 0)
     return -1;
   lseek (fd, (long) SUPERBOFF, 0);
-  if (safe_read (fd, (char *) &fsd, sizeof fsd) != sizeof fsd)
+  if (safe_read (fd, (TCHAR *) &fsd, sizeof fsd) != sizeof fsd)
     {
       close (fd);
       return -1;
@@ -323,7 +323,7 @@ get_fs_usage (path, disk, fsp)
 
 int
 statfs (path, fsb)
-     char *path;
+     TCHAR *path;
      struct statfs *fsb;
 {
   struct stat stats;
diff --git a/gayle.c b/gayle.c
index 1be9ba5a819244e02ad1325492781b515ef49708..bc51f11e77ef7df5e93449a6f1b336e44512edd6 100644 (file)
--- a/gayle.c
+++ b/gayle.c
@@ -188,11 +188,13 @@ STATIC_INLINE void pw (int offset, uae_u16 w)
     ide->secbuf[offset * 2 + 0] = (uae_u8)w;
     ide->secbuf[offset * 2 + 1] = w >> 8;
 }
-static void ps (int offset, char *s, int max)
+static void ps (int offset, TCHAR *src, int max)
 {
     int i, len;
+    char *s;
 
     offset *= 2;
+    s = ua (src);
     len = strlen (s);
     for (i = 0; i < max; i++) {
        char c = ' ';
@@ -338,7 +340,7 @@ static void write_gayle_cs (uae_u8 val)
        /* PCMCIA disable -> enable */
         card_trigger (!(gayle_cs & GAYLE_CS_DIS) ? 1 : 0);
        if (PCMCIA_LOG)
-           write_log ("PCMCIA slot: %s PC=%08X\n", !(gayle_cs & 1) ? "enabled" : "disabled", M68K_GETPC);
+           write_log (L"PCMCIA slot: %s PC=%08X\n", !(gayle_cs & 1) ? "enabled" : "disabled", M68K_GETPC);
     }
 }
 static uae_u8 read_gayle_cs (void)
@@ -392,7 +394,7 @@ static void ide_data_ready (int blocks)
 
 static void ide_recalibrate (void)
 {
-    write_log ("IDE%d recalibrate\n", ide->num);
+    write_log (L"IDE%d recalibrate\n", ide->num);
     ide_sector = 0;
     ide_lcyl = ide_hcyl = 0;
     ide_interrupt ();
@@ -402,7 +404,7 @@ static void ide_identify_drive (void)
     uae_u64 totalsecs;
     int v;
     uae_u8 *buf = ide->secbuf;
-    char tmp[100];
+    TCHAR tmp[100];
 
     if (ide->hdhfd.size == 0) {
        ide_fail ();
@@ -410,7 +412,7 @@ static void ide_identify_drive (void)
     }
     memset (buf, 0, 512);
     if (IDE_LOG > 0)
-       write_log ("IDE%d identify drive\n", ide->num);
+       write_log (L"IDE%d identify drive\n", ide->num);
     ide_data_ready (1);
     pw (0, 1 << 6);
     pw (1, ide->hdhfd.cyls_def);
@@ -419,12 +421,12 @@ static void ide_identify_drive (void)
     pw (4, 512 * ide->hdhfd.secspertrack_def);
     pw (5, 512);
     pw (6, ide->hdhfd.secspertrack_def);
-    ps (10, "68000", 20); /* serial */
+    ps (10, L"68000", 20); /* serial */
     pw (20, 3);
     pw (21, 512);
     pw (22, 4);
-    ps (23, "0.3", 8); /* firmware revision */
-    sprintf (tmp, "UAE-IDE %s", ide->hdhfd.hfd.product_id);
+    ps (23, L"0.3", 8); /* firmware revision */
+    _stprintf (tmp, L"UAE-IDE %s", ide->hdhfd.hfd.product_id);
     ps (27, tmp, 40); /* model */
     pw (47, MAX_MULTIPLE_SECTORS); /* max sectors in multiple mode */
     pw (48, 1);
@@ -486,13 +488,13 @@ static void ide_initialize_drive_parameters (void)
        ide_error |= IDE_ERR_ABRT;
        ide->status |= IDE_STATUS_ERR;
     }
-    write_log ("IDE%d initialize drive parameters, CYL=%d,SPT=%d,HEAD=%d\n",
+    write_log (L"IDE%d initialize drive parameters, CYL=%d,SPT=%d,HEAD=%d\n",
        ide->num, ide->hdhfd.cyls, ide->hdhfd.secspertrack, ide->hdhfd.heads);
     ide_interrupt ();
 }
 static void ide_set_multiple_mode (void)
 {
-    write_log ("IDE%d drive multiple mode = %d\n", ide->num, ide_nsector);
+    write_log (L"IDE%d drive multiple mode = %d\n", ide->num, ide_nsector);
     ide->multiple_mode = ide_nsector;
     ide_interrupt ();
 }
@@ -501,7 +503,7 @@ static void ide_set_features (void)
     int type = ide_nsector >> 3;
     int mode = ide_nsector & 7;
 
-    write_log ("IDE%d set features %02X (%02X)\n", ide->num, ide_feat, ide_nsector);
+    write_log (L"IDE%d set features %02X (%02X)\n", ide->num, ide_feat, ide_nsector);
     ide_fail ();
 }
 
@@ -586,7 +588,7 @@ static void ide_read_sectors (int flags)
     nsec = get_nsec (lba48);
     get_lbachs (ide, &lba, &cyl, &head, &sec, lba48);
     if (IDE_LOG > 0)
-       write_log ("IDE%d read off=%d, sec=%d (%d) lba%d\n", ide->num, (uae_u32)lba, nsec, ide->multiple_mode, lba48 ? 48 : 28);
+       write_log (L"IDE%d read off=%d, sec=%d (%d) lba%d\n", ide->num, (uae_u32)lba, nsec, ide->multiple_mode, lba48 ? 48 : 28);
     if (multi && ide->multiple_mode > nsec)
        nsec = ide->multiple_mode;
     if (lba * 512 >= ide->hdhfd.size) {
@@ -626,7 +628,7 @@ static void ide_write_sectors (int flags)
        return;
     }
     if (IDE_LOG > 0)
-       write_log ("IDE%d write off=%d, sec=%d (%d) lba%d\n", ide->num, (uae_u32)lba, nsec, ide->multiple_mode, lba48 ? 48 : 28);
+       write_log (L"IDE%d write off=%d, sec=%d (%d) lba%d\n", ide->num, (uae_u32)lba, nsec, ide->multiple_mode, lba48 ? 48 : 28);
     if (nsec * 512 > ide->hdhfd.size - lba * 512)
        nsec = (ide->hdhfd.size - lba * 512) / 512;
     if (nsec <= 0) {
@@ -643,7 +645,7 @@ static void ide_do_command (uae_u8 cmd)
     int lba48 = ide->lba48;
 
     if (IDE_LOG > 1)
-       write_log ("**** IDE%d command %02X\n", ide->num, cmd);
+       write_log (L"**** IDE%d command %02X\n", ide->num, cmd);
     ide->status &= ~ (IDE_STATUS_DRDY | IDE_STATUS_DRQ | IDE_STATUS_ERR);
     ide_error = 0;
 
@@ -686,7 +688,7 @@ static void ide_do_command (uae_u8 cmd)
        ide_interrupt ();
     } else {
        ide_fail ();
-       write_log ("IDE%d: unknown command %x\n", ide->num, cmd);
+       write_log (L"IDE%d: unknown command %x\n", ide->num, cmd);
     }
 }
 
@@ -697,7 +699,7 @@ static uae_u16 ide_get_data (void)
 
     if (ide->data_size == 0) {
        if (IDE_LOG > 0)
-           write_log ("IDE%d DATA read without DRQ!?\n", ide->num);
+           write_log (L"IDE%d DATA read without DRQ!?\n", ide->num);
        if (ide->hdhfd.size == 0)
            return 0xffff;
        return 0;
@@ -721,7 +723,7 @@ static void ide_put_data (uae_u16 v)
 
     if (ide->data_size == 0) {
        if (IDE_LOG > 0)
-           write_log ("IDE%d DATA write without DRQ!?\n", ide->num);
+           write_log (L"IDE%d DATA write without DRQ!?\n", ide->num);
        return;
     }
     ide->secbuf[ide->data_offset + 1] = v & 0xff;
@@ -730,7 +732,7 @@ static void ide_put_data (uae_u16 v)
     ide->data_size -= 2;
     if (((ide->data_offset % 512) == 0) && ((ide->data_offset / 512) % ide->data_multi) == 0) {
        if (IDE_LOG > 0)
-           write_log ("IDE%d write interrupt, %d total bytes transferred so far\n", ide->num, ide->data_offset);
+           write_log (L"IDE%d write interrupt, %d total bytes transferred so far\n", ide->num, ide->data_offset);
        irq = 1;
     }
     if (ide->data_size == 0) {
@@ -741,7 +743,7 @@ static void ide_put_data (uae_u16 v)
        nsec = ide->data_offset / 512;
        get_lbachs (ide, &lba, &cyl, &head, &sec, ide->lba48);
        if (IDE_LOG > 0)
-           write_log ("IDE%d write finished, %d bytes (%d) written\n", ide->num, ide->data_offset, ide->data_offset / 512);
+           write_log (L"IDE%d write finished, %d bytes (%d) written\n", ide->num, ide->data_offset, ide->data_offset / 512);
        hdf_write (&ide->hdhfd.hfd, ide->secbuf, lba * 512, ide->data_offset);
        put_lbachs (ide, lba, cyl, head, sec, nsec, ide->lba48);
        irq = 1;
@@ -776,7 +778,7 @@ static uae_u32 ide_read (uaecptr addr)
 
     addr &= 0xffff;
     if (IDE_LOG > 2 && addr != 0x2000 && addr != 0x2001 && addr != 0x2020 && addr != 0x2021 && addr != GAYLE_IRQ_1200)
-       write_log ("IDE_READ %08X PC=%X\n", addr, M68K_GETPC);
+       write_log (L"IDE_READ %08X PC=%X\n", addr, M68K_GETPC);
     if (currprefs.cs_ide <= 0) {
        if (addr == 0x201c) // AR1200 IDE detection hack
            return 0x7f;
@@ -857,7 +859,7 @@ static uae_u32 ide_read (uaecptr addr)
        break;
     }
     if (IDE_LOG > 2 && ide_reg > 0)
-       write_log ("IDE%d register %d->%02X\n", ide->num, ide_reg, (uae_u32)v & 0xff);
+       write_log (L"IDE%d register %d->%02X\n", ide->num, ide_reg, (uae_u32)v & 0xff);
     return v;
 }
 
@@ -866,7 +868,7 @@ static void ide_write (uaecptr addr, uae_u32 val)
     int ide_reg;
 
     if (IDE_LOG > 2 && addr != 0x2000 && addr != 0x2001 && addr != 0x2020 && addr != 0x2021 && addr != GAYLE_IRQ_1200)
-       write_log ("IDE_WRITE %08X=%02X PC=%X\n", addr, (uae_u32)val & 0xff, M68K_GETPC);
+       write_log (L"IDE_WRITE %08X=%02X PC=%X\n", addr, (uae_u32)val & 0xff, M68K_GETPC);
     if (currprefs.cs_ide <= 0)
        return;
     if (currprefs.cs_ide == 1) {
@@ -884,7 +886,7 @@ static void ide_write (uaecptr addr, uae_u32 val)
     ide_devcon &= ~0x80; /* clear HOB */
     ide_reg = get_ide_reg (addr);
     if (IDE_LOG > 2 && ide_reg > 0)
-       write_log ("IDE%d register %d=%02X\n", ide->num, ide_reg, (uae_u32)val & 0xff);
+       write_log (L"IDE%d register %d=%02X\n", ide->num, ide_reg, (uae_u32)val & 0xff);
     switch (ide_reg)
     {
        case IDE_DRVADDR:
@@ -948,18 +950,18 @@ static int gayle_read (uaecptr addr)
            v = read_gayle_cs ();
            got = 1;
            if (PCMCIA_LOG)
-               write_log ("PCMCIA STATUS READ %08X=%02X PC=%08X\n", oaddr, (uae_u32)v & 0xff, M68K_GETPC);
+               write_log (L"PCMCIA STATUS READ %08X=%02X PC=%08X\n", oaddr, (uae_u32)v & 0xff, M68K_GETPC);
        } else if (addr == GAYLE_CFG_1200) {
            v = read_gayle_cfg ();
            got = 1;
            if (PCMCIA_LOG)
-               write_log ("PCMCIA CONFIG READ %08X=%02X PC=%08X\n", oaddr, (uae_u32)v & 0xff, M68K_GETPC);
+               write_log (L"PCMCIA CONFIG READ %08X=%02X PC=%08X\n", oaddr, (uae_u32)v & 0xff, M68K_GETPC);
        }
     }
     if (!got)
        v = ide_read (addr);
     if (GAYLE_LOG)
-       write_log ("GAYLE_READ %08X=%02X PC=%08X\n", oaddr, (uae_u32)v & 0xff, M68K_GETPC);
+       write_log (L"GAYLE_READ %08X=%02X PC=%08X\n", oaddr, (uae_u32)v & 0xff, M68K_GETPC);
     return v;
 }
 static void gayle_write (uaecptr addr, int val)
@@ -984,17 +986,17 @@ static void gayle_write (uaecptr addr, int val)
            write_gayle_cs (val);
            got = 1;
            if (PCMCIA_LOG > 1)
-               write_log ("PCMCIA STATUS WRITE %08X=%02X PC=%08X\n", oaddr, (uae_u32)val & 0xff, M68K_GETPC);
+               write_log (L"PCMCIA STATUS WRITE %08X=%02X PC=%08X\n", oaddr, (uae_u32)val & 0xff, M68K_GETPC);
        } else if (addr == GAYLE_CFG_1200) {
            write_gayle_cfg (val);
            got = 1;
            if (PCMCIA_LOG > 1)
-               write_log ("PCMCIA CONFIG WRITE %08X=%02X PC=%08X\n", oaddr, (uae_u32)val & 0xff, M68K_GETPC);
+               write_log (L"PCMCIA CONFIG WRITE %08X=%02X PC=%08X\n", oaddr, (uae_u32)val & 0xff, M68K_GETPC);
        }
     }
 
     if (GAYLE_LOG)
-       write_log ("GAYLE_WRITE %08X=%02X PC=%08X\n", addr, (uae_u32)val & 0xff, M68K_GETPC);
+       write_log (L"GAYLE_WRITE %08X=%02X PC=%08X\n", addr, (uae_u32)val & 0xff, M68K_GETPC);
     if (!got)
        ide_write (addr, val);
 }
@@ -1009,7 +1011,7 @@ static void REGPARAM3 gayle_bput (uaecptr, uae_u32) REGPARAM;
 addrbank gayle_bank = {
     gayle_lget, gayle_wget, gayle_bget,
     gayle_lput, gayle_wput, gayle_bput,
-    default_xlate, default_check, NULL, "Gayle (low)",
+    default_xlate, default_check, NULL, L"Gayle (low)",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -1134,7 +1136,7 @@ static void REGPARAM3 gayle2_bput (uaecptr, uae_u32) REGPARAM;
 addrbank gayle2_bank = {
     gayle2_lget, gayle2_wget, gayle2_bget,
     gayle2_lput, gayle2_wput, gayle2_bput,
-    default_xlate, default_check, NULL, "Gayle (high)",
+    default_xlate, default_check, NULL, L"Gayle (high)",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -1201,7 +1203,7 @@ static void mbres_write (uaecptr addr, uae_u32 val, int size)
     addr &= 0xffff;
 
     if (MBRES_LOG > 0)
-       write_log ("MBRES_WRITE %08X=%08X (%d) PC=%08X S=%d\n", addr, val, size, M68K_GETPC, regs.s);
+       write_log (L"MBRES_WRITE %08X=%08X (%d) PC=%08X S=%d\n", addr, val, size, M68K_GETPC, regs.s);
     if (regs.s) { /* CPU FC = supervisor only */
        if (addr == 0x1002)
            garyidoffset = -1;
@@ -1254,7 +1256,7 @@ static uae_u32 mbres_read (uaecptr addr, int size)
        v = custom_bank.wget (addr);
     }
     if (MBRES_LOG > 0)
-       write_log ("MBRES_READ %08X=%08X (%d) PC=%08X S=%d\n", addr, v, size, M68K_GETPC, regs.s);
+       write_log (L"MBRES_READ %08X=%08X (%d) PC=%08X S=%d\n", addr, v, size, M68K_GETPC, regs.s);
     return v;
 }
 
@@ -1318,7 +1320,7 @@ static void REGPARAM2 mbres_bput (uaecptr addr, uae_u32 value)
 addrbank mbres_bank = {
     mbres_lget, mbres_wget, mbres_bget,
     mbres_lput, mbres_wput, mbres_bput,
-    default_xlate, default_check, NULL, "Motherboard Resources",
+    default_xlate, default_check, NULL, L"Motherboard Resources",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -1347,11 +1349,11 @@ static uae_u32 gayle_attr_read (uaecptr addr)
     uae_u8 v = 0;
 
     if (PCMCIA_LOG > 1)
-       write_log ("PCMCIA ATTR R: %x %x\n", addr, M68K_GETPC);
+       write_log (L"PCMCIA ATTR R: %x %x\n", addr, M68K_GETPC);
     addr &= 0x80000 - 1;
     if (addr >= 0x40000) {
        if (PCMCIA_LOG > 0)
-           write_log ("GAYLE: Reset disabled\n");
+           write_log (L"GAYLE: Reset disabled\n");
        return v;
     }
     if (addr >= pcmcia_attrs_size)
@@ -1362,11 +1364,11 @@ static uae_u32 gayle_attr_read (uaecptr addr)
 static void gayle_attr_write (uaecptr addr, uae_u32 v)
 {
     if (PCMCIA_LOG > 1)
-       write_log ("PCMCIA ATTR W: %x=%x %x\n", addr, v, M68K_GETPC);
+       write_log (L"PCMCIA ATTR W: %x=%x %x\n", addr, v, M68K_GETPC);
     addr &= 0x80000 - 1;
     if (addr >= 0x40000) {
        if (PCMCIA_LOG > 0)
-           write_log ("GAYLE: Reset active\n");
+           write_log (L"GAYLE: Reset active\n");
     } else if (addr < pcmcia_attrs_size) {
        ;
     }
@@ -1414,9 +1416,9 @@ static void initsramattr (int size, int readonly)
     *p++= 4; /* PCMCIA 2.1 */
     *p++= 1;
     if (real) {
-       strcpy (p, hfd->product_id);
+       ua_copy (p, -1, hfd->product_id);
        p += strlen (p) + 1;
-       strcpy (p, hfd->product_rev);
+       ua_copy(p, -1, hfd->product_rev);
     } else {
        strcpy (p, "UAE");
        p += strlen (p) + 1;
@@ -1505,7 +1507,7 @@ static int freepcmcia (int reset)
     return 1;
 }
 
-static int initpcmcia (const char *path, int readonly, int reset)
+static int initpcmcia (const TCHAR *path, int readonly, int reset)
 {
     if (currprefs.cs_pcmcia == 0)
        return 0;
@@ -1529,11 +1531,11 @@ static int initpcmcia (const char *path, int readonly, int reset)
     if (!pcmcia_sram->hfd.drive_empty) {
        pcmcia_common_size = pcmcia_sram->hfd.virtsize;
        if (pcmcia_sram->hfd.virtsize > 4 * 1024 * 1024) {
-           write_log ("PCMCIA SRAM: too large device, %d bytes\n", pcmcia_sram->hfd.virtsize);
+           write_log (L"PCMCIA SRAM: too large device, %d bytes\n", pcmcia_sram->hfd.virtsize);
            pcmcia_common_size = 4 * 1024 * 1024;
        }
        pcmcia_common = xcalloc (pcmcia_common_size, 1);
-       write_log ("PCMCIA SRAM: '%s' open, size=%d\n", path, pcmcia_common_size);
+       write_log (L"PCMCIA SRAM: '%s' open, size=%d\n", path, pcmcia_common_size);
        hdf_read (&pcmcia_sram->hfd, pcmcia_common, 0, pcmcia_common_size);
        pcmcia_card = 1;
        initsramattr (pcmcia_common_size, readonly);
@@ -1551,7 +1553,7 @@ static uae_u32 gayle_common_read (uaecptr addr)
 {
     uae_u8 v = 0;
     if (PCMCIA_LOG > 2)
-       write_log ("PCMCIA COMMON R: %x %x\n", addr, M68K_GETPC);
+       write_log (L"PCMCIA COMMON R: %x %x\n", addr, M68K_GETPC);
     if (!pcmcia_common_size)
        return 0;
     addr -= PCMCIA_COMMON_START & (PCMCIA_COMMON_SIZE - 1);
@@ -1563,7 +1565,7 @@ static uae_u32 gayle_common_read (uaecptr addr)
 static void gayle_common_write (uaecptr addr, uae_u32 v)
 {
     if (PCMCIA_LOG > 2)
-       write_log ("PCMCIA COMMON W: %x=%x %x\n", addr, v, M68K_GETPC);
+       write_log (L"PCMCIA COMMON W: %x=%x %x\n", addr, v, M68K_GETPC);
     if (!pcmcia_common_size)
        return;
     if (pcmcia_readonly)
@@ -1604,7 +1606,7 @@ static uae_u8 *REGPARAM2 gayle_common_xlate (uaecptr addr)
 static addrbank gayle_common_bank = {
     gayle_common_lget, gayle_common_wget, gayle_common_bget,
     gayle_common_lput, gayle_common_wput, gayle_common_bput,
-    gayle_common_xlate, gayle_common_check, NULL, "Gayle PCMCIA Common",
+    gayle_common_xlate, gayle_common_check, NULL, L"Gayle PCMCIA Common",
     gayle_common_lget, gayle_common_wget, ABFLAG_RAM | ABFLAG_SAFE
 };
 
@@ -1619,7 +1621,7 @@ static void REGPARAM3 gayle_attr_bput (uaecptr, uae_u32) REGPARAM;
 addrbank gayle_attr_bank = {
     gayle_attr_lget, gayle_attr_wget, gayle_attr_bget,
     gayle_attr_lput, gayle_attr_wput, gayle_attr_bput,
-    default_xlate, default_check, NULL, "Gayle PCMCIA Attribute/Misc",
+    default_xlate, default_check, NULL, L"Gayle PCMCIA Attribute/Misc",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO | ABFLAG_SAFE
 };
 
@@ -1790,9 +1792,9 @@ static void dumphdf (struct hardfiledata *hfd)
 }
 #endif
 
-int gayle_add_ide_unit (int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys)
+int gayle_add_ide_unit (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys)
 {
     struct ide_hdf *ide;
 
@@ -1803,7 +1805,7 @@ int gayle_add_ide_unit (int ch, char *path, int blocksize, int readonly,
     if (!hdf_hd_open (&ide->hdhfd, path, blocksize, readonly, devname, sectors, surfaces, reserved, bootpri, filesys))
        return -1;
     ide->lba48 = ide->hdhfd.size >= 128 * (uae_u64)0x40000000 ? 1 : 0;
-    write_log ("IDE%d '%s', CHS=%d,%d,%d. %uM. LBA48=%d\n",
+    write_log (L"IDE%d '%s', CHS=%d,%d,%d. %uM. LBA48=%d\n",
        ch, path, ide->hdhfd.cyls, ide->hdhfd.heads, ide->hdhfd.secspertrack, (int)(ide->hdhfd.size / (1024 * 1024)), ide->lba48);
     ide->status = 0;
     ide->data_offset = 0;
@@ -1812,12 +1814,12 @@ int gayle_add_ide_unit (int ch, char *path, int blocksize, int readonly,
     return 1;
 }
 
-int gayle_add_pcmcia_sram_unit (const char *path, int readonly)
+int gayle_add_pcmcia_sram_unit (const TCHAR *path, int readonly)
 {
     return initpcmcia (path, readonly, 1);
 }
 
-int gayle_modify_pcmcia_sram_unit (const char *path, int readonly, int insert)
+int gayle_modify_pcmcia_sram_unit (const TCHAR *path, int readonly, int insert)
 {
     if (insert)
        return initpcmcia (path, readonly, pcmcia_sram ? 0 : 1);
@@ -1840,7 +1842,7 @@ static void initide (void)
     ide_splitter = 0;
     if (idedrive[2]->hdhfd.size) {
        ide_splitter = 1;
-       write_log ("IDE splitter enabled\n");
+       write_log (L"IDE splitter enabled\n");
     }
     for (i = 0; i < 4; i++)
        idedrive[i]->num = i;
@@ -1849,7 +1851,7 @@ static void initide (void)
 
 void gayle_reset (int hardreset)
 {
-    static char bankname[100];
+    static TCHAR bankname[100];
 
     initide ();
     if (hardreset) {
@@ -1858,11 +1860,11 @@ void gayle_reset (int hardreset)
        gary_timeout = 0;
        gary_toenb = 0;
     }
-    strcpy (bankname, "Gayle (low)");
+    _tcscpy (bankname, L"Gayle (low)");
     if (currprefs.cs_ide == 2)
-       strcpy (bankname, "A4000 IDE");
+       _tcscpy (bankname, L"A4000 IDE");
     if (currprefs.cs_mbdmac == 2) {
-       strcat (bankname," + NCR53C710 SCSI");
+       _tcscat (bankname, L" + NCR53C710 SCSI");
        ncr_reset ();
     }
     gayle_bank.name = bankname;
@@ -1945,7 +1947,7 @@ uae_u8 *restore_ide (uae_u8 *src)
 {
     int num, readonly, blocksize;
     uae_u64 size;
-    char *path;
+    TCHAR *path;
     struct ide_hdf *ide;
 
     alloc_ide_mem ();
index 73e13a0fc015e0a0dfbf4797a90375fd5835311d..29a229c3f1ecfc311edd446cff0bc3c239bcded3 100644 (file)
--- a/gfxlib.c
+++ b/gfxlib.c
@@ -65,7 +65,7 @@ static struct uniq_head *find_uniq (uniq_list *a, uae_u32 uniq)
     while (b && b->uniq != uniq)
        b = b->next;
     if (!b)
-       write_log ("Couldn't find structure. Bad\n");
+       write_log (L"Couldn't find structure. Bad\n");
     return b;
 }
 
@@ -76,7 +76,7 @@ static struct uniq_head *find_and_rem_uniq (uniq_list *a, uae_u32 uniq)
        b = &(*b)->next;
     c = *b;
     if (!c)
-       write_log ("Couldn't find structure. Bad\n");
+       write_log (L"Couldn't find structure. Bad\n");
     else
        *b = c->next;
     return c;
@@ -202,7 +202,7 @@ int GFX_WritePixel(uaecptr rp, int x, int y)
     int x2, y2;
 
     if (bitmap == 0) {
-       write_log ("bogus RastPort in WritePixel\n");
+       write_log (L"bogus RastPort in WritePixel\n");
        return -1;
     }
 
@@ -234,7 +234,7 @@ int GFX_WritePixel(uaecptr rp, int x, int y)
         * suppose if we can't find a ClipRect, we aren't supposed to draw
         * the dot.
         */
-       /*write_log ("Weirdness in WritePixel\n");*/
+       /*write_log (L"Weirdness in WritePixel\n");*/
        v = -1;
     } else if (get_long (cliprect + 8) == 0) {
        v = GFX_Bitmap_WritePixel(bitmap, x2, y2, rp);
@@ -268,7 +268,7 @@ static uae_u32 gfxl_BltClear(void)
     }
 
     if ((mem & 1) != 0 || (count & 1) != 0)
-       write_log ("gfx: BltClear called with odd parameters\n");
+       write_log (L"gfx: BltClear called with odd parameters\n");
 
     /* Bit 2 set means use pattern (V36+ only, but we might as well emulate
      * it always) */
@@ -566,7 +566,7 @@ static void region_splitrects_band(struct RectList *rl, struct BandList *bl)
                rl->rects[i].MaxY = bl->maxy[j];
                break;
            }
-           write_log ("Foo..\n");
+           write_log (L"Foo..\n");
        }
     }
     qsort(rl->rects, rl->count, sizeof (struct Rectangle), regionrect_cmpfn);
@@ -1070,7 +1070,7 @@ static uae_u32 gfxl_perform_regionop(regionop op, int with_rect)
            rpp = rr;
        }
        if (get_long (rpp) != 0)
-           write_log ("BUG\n");
+           write_log (L"BUG\n");
     }
     put_word (reg2+0, rl3.bounds.MinX);
     put_word (reg2+2, rl3.bounds.MinY);
@@ -1644,7 +1644,7 @@ void gfxlib_install(void)
     if (! currprefs.use_gfxlib)
        return;
 
-    write_log ("Warning: you enabled the graphics.library replacement with -g\n"
+    write_log (L"Warning: you enabled the graphics.library replacement with -g\n"
             "This may be buggy right now, and will not speed things up much.\n");
 
     resname = ds ("UAEgfxlib.resource");
index 40303b06c4d2b50ad0d21b136d21035281b6f134..8911d5c680a644f6e31c7ef3e5809af166b088a4 100644 (file)
--- a/gfxutil.c
+++ b/gfxutil.c
@@ -444,7 +444,7 @@ void alloc_colors256 (allocfunc_type allocfunc)
 
     map = (xcolnr *)malloc (sizeof(xcolnr) * maxcol);
     if (!map) {
-       write_log ("Not enough mem for colormap!\n");
+       write_log (L"Not enough mem for colormap!\n");
        abort ();
     }
 
@@ -575,7 +575,7 @@ void setup_greydither_maxcol (int maxcol, allocfunc_type allocfunc)
 
     map = (xcolnr *)malloc (sizeof(xcolnr) * maxcol);
     if (!map) {
-       write_log ("Not enough mem for colormap!\n");
+       write_log (L"Not enough mem for colormap!\n");
        abort();
     }
 
@@ -639,7 +639,7 @@ void setup_dither (int bits, allocfunc_type allocfunc)
 
     map = (xcolnr *)malloc (sizeof(xcolnr) * maxcol);
     if (!map) {
-       write_log ("Not enough mem for colormap!\n");
+       write_log (L"Not enough mem for colormap!\n");
        abort();
     }
 
@@ -685,7 +685,7 @@ void setup_dither (int bits, allocfunc_type allocfunc)
            }
        }
     }
-/*    write_log ("%d color(s) lost\n",maxcol - l);*/
+/*    write_log (L"%d color(s) lost\n",maxcol - l);*/
 
     /*
      * for each component compute the mapping
index f455f022b5a2b14de379a7cd80cfe7ff70c9bf19..774edc109a2487803aae9d60041e4fb49d0ea206 100644 (file)
@@ -201,7 +201,7 @@ static void rdb_crc(uae_u8 *p)
     pl (p, 2, sum);
 }
 
-static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int bootpri, const char *filesys)
+static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int bootpri, const TCHAR *filesys)
 {
     uae_u8 *rdb, *part, *denv;
     int cyl = hfd->heads * hfd->secspertrack;
@@ -252,10 +252,10 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
     pl(rdb, 37, 0); // autopark
     pl(rdb, 38, 2); // highrdskblock
     pl(rdb, 39, -1); // res
-    strcpy (rdb + 40 * 4, hfd->vendor_id);
-    strcpy (rdb + 42 * 4, hfd->product_id);
-    strcpy (rdb + 46 * 4, "UAE");
-    rdb_crc(rdb);
+    ua_copy (rdb + 40 * 4, -1, hfd->vendor_id);
+    ua_copy (rdb + 42 * 4, -1, hfd->product_id);
+    ua_copy (rdb + 46 * 4, -1, L"UAE");
+    rdb_crc (rdb);
 
     pl(part, 0, 0x50415254);
     pl(part, 1, 64);
@@ -266,8 +266,8 @@ static void create_virtual_rdb (struct hardfiledata *hfd, uae_u32 dostype, int b
     pl(part, 6, -1);
     pl(part, 7, -1);
     pl(part, 8, 0); // devflags
-    part[9 * 4] = strlen(hfd->device_name);
-    strcpy (part + 9 * 4 + 1, hfd->device_name);
+    part[9 * 4] = _tcslen (hfd->device_name);
+    ua_copy (part + 9 * 4 + 1, -1, hfd->device_name);
 
     denv = part + 128;
     pl(denv, 0, 80);
@@ -301,9 +301,9 @@ void hdf_hd_close (struct hd_hardfiledata *hfd)
     xfree (hfd->path);
 }
 
-int hdf_hd_open (struct hd_hardfiledata *hfd, const char *path, int blocksize, int readonly,
-                      const char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, const char *filesys)
+int hdf_hd_open (struct hd_hardfiledata *hfd, const TCHAR *path, int blocksize, int readonly,
+                      const TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, const TCHAR *filesys)
 {
     memset (hfd, 0, sizeof (struct hd_hardfiledata));
     hfd->bootpri = bootpri;
@@ -315,7 +315,7 @@ int hdf_hd_open (struct hd_hardfiledata *hfd, const char *path, int blocksize, i
     hfd->hfd.reservedblocks = reserved;
     hfd->hfd.secspertrack = sectors;
     if (devname)
-       strcpy (hfd->hfd.device_name, devname);
+       _tcscpy (hfd->hfd.device_name, devname);
     getchshd (&hfd->hfd, &hfd->cyls, &hfd->heads, &hfd->secspertrack);
     hfd->cyls_def = hfd->cyls;
     hfd->secspertrack_def = hfd->secspertrack;
@@ -323,7 +323,7 @@ int hdf_hd_open (struct hd_hardfiledata *hfd, const char *path, int blocksize, i
     if (hfd->hfd.heads && hfd->hfd.secspertrack) {
        uae_u8 buf[512] = { 0 };
        hdf_read (&hfd->hfd, buf, 0, 512);
-       if (buf[0] != 0 && memcmp (buf, "RDSK", 4)) {
+       if (buf[0] != 0 && memcmp (buf, L"RDSK", 4)) {
            hfd->hfd.nrcyls = (hfd->hfd.virtsize / blocksize) / (sectors * surfaces);
            create_virtual_rdb (&hfd->hfd, rl (buf), hfd->bootpri, filesys);
            while (hfd->hfd.nrcyls * surfaces * sectors > hfd->cyls_def * hfd->secspertrack_def * hfd->heads_def) {
@@ -349,7 +349,7 @@ static uae_u32 vhd_checksum (uae_u8 *p, int offset)
     return ~sum;
 }
 
-int hdf_open (struct hardfiledata *hfd, const char *pname)
+int hdf_open (struct hardfiledata *hfd, const TCHAR *pname)
 {
     uae_u8 tmp[512], tmp2[512];
     uae_u32 v;
@@ -403,7 +403,7 @@ int hdf_open (struct hardfiledata *hfd, const char *pname)
        hfd->vhd_sectormapblock = -1;
        hfd->vhd_bitmapsize = ((hfd->vhd_blocksize / (8 * 512)) + 511) & ~511;
     }
-    write_log ("HDF is VHD %s image, virtual size=%dK\n",
+    write_log (L"HDF is VHD %s image, virtual size=%dK\n",
        hfd->vhd_type == 2 ? "fixed" : "dynamic",
        hfd->virtsize / 1024);
     return 1;
@@ -432,7 +432,7 @@ int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd)
 
 extern int get_guid_target (uae_u8 *out);
 
-int vhd_create (const char *name, uae_u64 size)
+int vhd_create (const TCHAR *name, uae_u64 size)
 {
     struct hardfiledata hfd;
     struct zfile *zf;
@@ -453,7 +453,7 @@ int vhd_create (const char *name, uae_u64 size)
     batsize &= ~511;
     ret = 0;
     b = NULL;
-    zf = zfile_fopen (name, "wb");
+    zf = zfile_fopen (name, L"wb");
     if (!zf)
        goto end;
     b = xcalloc (512 + 1024 + batsize + 512, 1);
@@ -559,7 +559,7 @@ static uae_u64 vhd_read (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offs
     uae_u32 sectoroffset;
     uae_u64 read;
 
-    //write_log ("%08x %08x\n", (uae_u32)offset, (uae_u32)len);
+    //write_log (L"%08x %08x\n", (uae_u32)offset, (uae_u32)len);
     read = 0;
     if (offset & 511)
        return read;
@@ -581,7 +581,7 @@ static uae_u64 vhd_read (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offs
            sectormapblock = sectoroffset * 512 + (bitmapoffsetbytes & ~511);
            if (hfd->vhd_sectormapblock != sectormapblock) {
                // read sector bitmap
-               //write_log ("BM %08x\n", sectormapblock);
+               //write_log (L"BM %08x\n", sectormapblock);
                if (hdf_read_target (hfd, hfd->vhd_sectormap, sectormapblock, 512) != 512)
                    return read;
                hfd->vhd_sectormapblock = sectormapblock;
@@ -590,7 +590,7 @@ static uae_u64 vhd_read (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offs
            if (hfd->vhd_sectormap[bitmapoffsetbytes & 511] & (1 << (7 - (bitmapoffsetbits & 7)))) {
                // read data block
                int block = sectoroffset * 512 + hfd->vhd_bitmapsize + bitmapoffsetbits * 512;
-               //write_log ("DB %08x\n", block);
+               //write_log (L"DB %08x\n", block);
                if (hdf_read_target (hfd, dataptr, block, 512) != 512)
                    return read;
            } else {
@@ -641,7 +641,7 @@ static uae_u64 vhd_write (struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 off
     uae_u32 sectoroffset;
     uae_u64 written;
 
-    //write_log ("%08x %08x\n", (uae_u32)offset, (uae_u32)len);
+    //write_log (L"%08x %08x\n", (uae_u32)offset, (uae_u32)len);
     written = 0;
     if (offset & 511)
        return written;
@@ -768,6 +768,7 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
     int scsi_len = -1;
     int status = 0;
     int i;
+    char *ss;
 
     *reply_len = *sense_len = 0;
     memset(r, 0, 256);
@@ -817,33 +818,39 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
            r[2] = hdhfd->ansi_version;
            r[3] = hdhfd->ansi_version >= 2 ? 2 : 0;
        }
+       ss = ua (hfd->vendor_id);
        i = 0; /* vendor id */
-       while (i < 8 && hfd->vendor_id[i]) {
-           r[8 + i] = hfd->vendor_id[i];
+       while (i < 8 && ss[i]) {
+           r[8 + i] = ss[i];
            i++;
        }
        while (i < 8) {
            r[8 + i] = 32;
            i++;
        }
+       xfree (ss);
+       ss = ua (hfd->product_id);
        i = 0; /* product id */
-       while (i < 16 && hfd->product_id[i]) {
-           r[16 + i] = hfd->product_id[i];
+       while (i < 16 && ss[i]) {
+           r[16 + i] = ss[i];
            i++;
        }
        while (i < 16) {
            r[16 + i] = 32;
            i++;
        }
+       xfree (ss);
+       ss = ua (hfd->product_rev);
        i = 0; /* product revision */
-       while (i < 4 && hfd->product_rev[i]) {
-           r[32 + i] = hfd->product_rev[i];
+       while (i < 4 && ss[i]) {
+           r[32 + i] = ss[i];
            i++;
        }
        while (i < 4) {
            r[32 + i] = 32;
            i++;
        }
+       xfree (ss);
        break;
        case 0x1a: /* MODE SENSE(6) */
        {
@@ -862,7 +869,7 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
            } else {
                getchs (hfd, &cyl, &cylsec, &head, &tracksec);
            }
-           //write_log ("MODE SENSE PC=%d CODE=%d DBD=%d\n", pc, pcode, dbd);
+           //write_log (L"MODE SENSE PC=%d CODE=%d DBD=%d\n", pc, pcode, dbd);
            p = r;
            p[0] = 4 - 1;
            p[1] = 0;
@@ -1014,7 +1021,7 @@ int scsi_emulate (struct hardfiledata *hfd, struct hd_hardfiledata *hdhfd, uae_u
        case 0x37: /* READ DEFECT DATA */
        if (nodisk (hfd))
            goto nodisk;
-       write_log ("UAEHF: READ DEFECT DATA\n");
+       write_log (L"UAEHF: READ DEFECT DATA\n");
        status = 2; /* CHECK CONDITION */
        s[0] = 0x70;
        s[2] = 0; /* NO SENSE */
@@ -1032,7 +1039,7 @@ nodisk:
        default:
 err:
        lr = -1;
-       write_log ("UAEHF: unsupported scsi command 0x%02X\n", cmdbuf[0]);
+       write_log (L"UAEHF: unsupported scsi command 0x%02X\n", cmdbuf[0]);
        status = 2; /* CHECK CONDITION */
        s[0] = 0x70;
        s[2] = 5; /* ILLEGAL REQUEST */
@@ -1140,7 +1147,7 @@ void hardfile_do_disk_change (struct uaedev_config_info *uci, int insert)
        return;
     uae_sem_wait (&change_sem);
     hardfpd[fsid].changenum++;
-    write_log("uaehf.device:%d media status=%d changenum=%d\n", fsid, insert, hardfpd[fsid].changenum);
+    write_log (L"uaehf.device:%d media status=%d changenum=%d\n", fsid, insert, hardfpd[fsid].changenum);
     hfd->drive_empty = newstate;
     j = 0;
     while (j < MAX_ASYNC_REQUESTS) {
@@ -1230,7 +1237,7 @@ static int start_thread (TrapContext *context, int unit)
     hfpd->base = m68k_areg (&context->regs, 6);
     init_comm_pipe (&hfpd->requests, 100, 1);
     uae_sem_init (&hfpd->sync_sem, 0, 0);
-    uae_start_thread ("hardfile", hardfile_thread, hfpd, NULL);
+    uae_start_thread (L"hardfile", hardfile_thread, hfpd, NULL);
     uae_sem_wait (&hfpd->sync_sem);
     return hfpd->thread_running;
 }
@@ -1264,7 +1271,7 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *context)
                put_long (ioreq + 24, unit); /* io_Unit */
                put_byte (ioreq + 31, 0); /* io_Error */
                put_byte (ioreq + 8, 7); /* ln_type = NT_REPLYMSG */
-               hf_log ("hardfile_open, unit %d (%d), OK\n", unit, m68k_dreg (&context->regs, 0));
+               hf_log (L"hardfile_open, unit %d (%d), OK\n", unit, m68k_dreg (&context->regs, 0));
                return 0;
            }
        }
@@ -1273,7 +1280,7 @@ static uae_u32 REGPARAM2 hardfile_open (TrapContext *context)
     } else {
        err = IOERR_BADLENGTH;
     }
-    hf_log ("hardfile_open, unit %d (%d), ERR=%d\n", unit, m68k_dreg (&context->regs, 0), err);
+    hf_log (L"hardfile_open, unit %d (%d), ERR=%d\n", unit, m68k_dreg (&context->regs, 0), err);
     put_long (ioreq + 20, (uae_u32)err);
     put_byte (ioreq + 31, (uae_u8)err);
     return (uae_u32)err;
@@ -1300,13 +1307,13 @@ static uae_u32 REGPARAM2 hardfile_expunge (TrapContext *context)
 
 static void outofbounds (int cmd, uae_u64 offset, uae_u64 len, uae_u64 max)
 {
-    write_log ("UAEHF: cmd %d: out of bounds, %08X-%08X + %08X-%08X > %08X-%08X\n", cmd,
+    write_log (L"UAEHF: cmd %d: out of bounds, %08X-%08X + %08X-%08X > %08X-%08X\n", cmd,
        (uae_u32)(offset >> 32),(uae_u32)offset,(uae_u32)(len >> 32),(uae_u32)len,
        (uae_u32)(max >> 32),(uae_u32)max);
 }
 static void unaligned (int cmd, uae_u64 offset, uae_u64 len, int blocksize)
 {
-    write_log ("UAEHF: cmd %d: unaligned access, %08X-%08X, %08X-%08X, %08X\n", cmd,
+    write_log (L"UAEHF: cmd %d: unaligned access, %08X-%08X, %08X-%08X, %08X\n", cmd,
        (uae_u32)(offset >> 32),(uae_u32)offset,(uae_u32)(len >> 32),(uae_u32)len,
        blocksize);
 }
@@ -1508,7 +1515,7 @@ static uae_u32 hardfile_do_io (struct hardfiledata *hfd, struct hardfileprivdata
                error = handle_scsi (request, hfd);
            } else { /* we don't want users trashing their "partition" hardfiles with hdtoolbox */
                error = IOERR_NOCMD;
-               write_log ("UAEHF: HD_SCSICMD tried on regular HDF, unit %d\n", unit);
+               write_log (L"UAEHF: HD_SCSICMD tried on regular HDF, unit %d\n", unit);
            }
        break;
 
@@ -1653,8 +1660,8 @@ void hardfile_install (void)
 
     uae_sem_init (&change_sem, 0, 1);
 
-    ROM_hardfile_resname = ds ("uaehf.device");
-    ROM_hardfile_resid = ds ("UAE hardfile.device 0.2");
+    ROM_hardfile_resname = ds (L"uaehf.device");
+    ROM_hardfile_resid = ds (L"UAE hardfile.device 0.2");
 
     nscmd_cmd = here ();
     dw (NSCMD_DEVICEQUERY);
index b9404dea7bc92bbecafd8ea79037b506df3260e2..48f6431b2df7f3bd20cd16f59e464734952eecd9 100644 (file)
 
 const struct mem_labels int_labels[] =
 {
-    { "Reset:SSP",  0x0000 },
-    { "EXECBASE",   0x0004 },
-    { "BUS ERROR",  0x0008 },
-    { "ADR ERROR",  0x000C },
-    { "ILLEG OPC",  0x0010 },
-    { "DIV BY 0",   0x0014 },
-    { "CHK",        0x0018 },
-    { "TRAPV",      0x001C },
-    { "PRIVIL VIO", 0x0020 },
-    { "TRACE",      0x0024 },
-    { "LINEA EMU",  0x0028 },
-    { "LINEF EMU",  0x002C },
-    { "INT Uninit", 0x003C },
-    { "INT Unjust", 0x0060 },
-    { "Lvl 1 Int",  0x0064 },
-    { "Lvl 2 Int",  0x0068 },
-    { "Lvl 3 Int",  0x006C },
-    { "Lvl 4 Int",  0x0070 },
-    { "Lvl 5 Int",  0x0074 },
-    { "Lvl 6 Int",  0x0078 },
-    { "NMI",        0x007C },
+    { L"Reset:SSP",  0x0000 },
+    { L"EXECBASE",   0x0004 },
+    { L"BUS ERROR",  0x0008 },
+    { L"ADR ERROR",  0x000C },
+    { L"ILLEG OPC",  0x0010 },
+    { L"DIV BY 0",   0x0014 },
+    { L"CHK",        0x0018 },
+    { L"TRAPV",      0x001C },
+    { L"PRIVIL VIO", 0x0020 },
+    { L"TRACE",      0x0024 },
+    { L"LINEA EMU",  0x0028 },
+    { L"LINEF EMU",  0x002C },
+    { L"INT Uninit", 0x003C },
+    { L"INT Unjust", 0x0060 },
+    { L"Lvl 1 Int",  0x0064 },
+    { L"Lvl 2 Int",  0x0068 },
+    { L"Lvl 3 Int",  0x006C },
+    { L"Lvl 4 Int",  0x0070 },
+    { L"Lvl 5 Int",  0x0074 },
+    { L"Lvl 6 Int",  0x0078 },
+    { L"NMI",        0x007C },
     { 0, 0 }
 };
 
 const struct mem_labels trap_labels[] =
 {
-    { "TRAP 00",    0x0080 },
-    { "TRAP 01",    0x0084 },
-    { "TRAP 02",    0x0088 },
-    { "TRAP 03",    0x008C },
-    { "TRAP 04",    0x0090 },
-    { "TRAP 05",    0x0094 },
-    { "TRAP 06",    0x0098 },
-    { "TRAP 07",    0x009C },
-    { "TRAP 08",    0x00A0 },
-    { "TRAP 09",    0x00A4 },
-    { "TRAP 10",    0x00A8 },
-    { "TRAP 11",    0x00AC },
-    { "TRAP 12",    0x00B0 },
-    { "TRAP 13",    0x00B4 },
-    { "TRAP 14",    0x00B8 },
-    { "TRAP 15",    0x00BC },
+    { L"TRAP 00",    0x0080 },
+    { L"TRAP 01",    0x0084 },
+    { L"TRAP 02",    0x0088 },
+    { L"TRAP 03",    0x008C },
+    { L"TRAP 04",    0x0090 },
+    { L"TRAP 05",    0x0094 },
+    { L"TRAP 06",    0x0098 },
+    { L"TRAP 07",    0x009C },
+    { L"TRAP 08",    0x00A0 },
+    { L"TRAP 09",    0x00A4 },
+    { L"TRAP 10",    0x00A8 },
+    { L"TRAP 11",    0x00AC },
+    { L"TRAP 12",    0x00B0 },
+    { L"TRAP 13",    0x00B4 },
+    { L"TRAP 14",    0x00B8 },
+    { L"TRAP 15",    0x00BC },
     { 0, 0 }
 };
 
 const struct mem_labels mem_labels[] =
 {
-    { "CIAB PRA",   0xBFD000 },
-    { "CIAB PRB",   0xBFD100 },
-    { "CIAB DDRA",  0xBFD200 },
-    { "CIAB DDRB",  0xBFD300 },
-    { "CIAB TALO",  0xBFD400 },
-    { "CIAB TAHI",  0xBFD500 },
-    { "CIAB TBLO",  0xBFD600 },
-    { "CIAB TBHI",  0xBFD700 },
-    { "CIAB TDLO",  0xBFD800 },
-    { "CIAB TDMD",  0xBFD900 },
-    { "CIAB TDHI",  0xBFDA00 },
-    { "CIAB SDR",   0xBFDC00 },
-    { "CIAB ICR",   0xBFDD00 },
-    { "CIAB CRA",   0xBFDE00 },
-    { "CIAB CRB",   0xBFDF00 },
-    { "CIAA PRA",   0xBFE001 },
-    { "CIAA PRB",   0xBFE101 },
-    { "CIAA DDRA",  0xBFE201 },
-    { "CIAA DDRB",  0xBFE301 },
-    { "CIAA TALO",  0xBFE401 },
-    { "CIAA TAHI",  0xBFE501 },
-    { "CIAA TBLO",  0xBFE601 },
-    { "CIAA TBHI",  0xBFE701 },
-    { "CIAA TDLO",  0xBFE801 },
-    { "CIAA TDMD",  0xBFE901 },
-    { "CIAA TDHI",  0xBFEA01 },
-    { "CIAA SDR",   0xBFEC01 },
-    { "CIAA ICR",   0xBFED01 },
-    { "CIAA CRA",   0xBFEE01 },
-    { "CIAA CRB",   0xBFEF01 },
-    { "CLK S1",     0xDC0000 },
-    { "CLK S10",    0xDC0004 },
-    { "CLK MI1",    0xDC0008 },
-    { "CLK MI10",   0xDC000C },
-    { "CLK H1",     0xDC0010 },
-    { "CLK H10",    0xDC0014 },
-    { "CLK D1",     0xDC0018 },
-    { "CLK D10",    0xDC001C },
-    { "CLK MO1",    0xDC0020 },
-    { "CLK MO10",   0xDC0024 },
-    { "CLK Y1",     0xDC0028 },
-    { "CLK Y10",    0xDC002E },
-    { "CLK WEEK",   0xDC0030 },
-    { "CLK CD",     0xDC0034 },
-    { "CLK CE",     0xDC0038 },
-    { "CLK CF",     0xDC003C },
+    { L"CIAB PRA",   0xBFD000 },
+    { L"CIAB PRB",   0xBFD100 },
+    { L"CIAB DDRA",  0xBFD200 },
+    { L"CIAB DDRB",  0xBFD300 },
+    { L"CIAB TALO",  0xBFD400 },
+    { L"CIAB TAHI",  0xBFD500 },
+    { L"CIAB TBLO",  0xBFD600 },
+    { L"CIAB TBHI",  0xBFD700 },
+    { L"CIAB TDLO",  0xBFD800 },
+    { L"CIAB TDMD",  0xBFD900 },
+    { L"CIAB TDHI",  0xBFDA00 },
+    { L"CIAB SDR",   0xBFDC00 },
+    { L"CIAB ICR",   0xBFDD00 },
+    { L"CIAB CRA",   0xBFDE00 },
+    { L"CIAB CRB",   0xBFDF00 },
+    { L"CIAA PRA",   0xBFE001 },
+    { L"CIAA PRB",   0xBFE101 },
+    { L"CIAA DDRA",  0xBFE201 },
+    { L"CIAA DDRB",  0xBFE301 },
+    { L"CIAA TALO",  0xBFE401 },
+    { L"CIAA TAHI",  0xBFE501 },
+    { L"CIAA TBLO",  0xBFE601 },
+    { L"CIAA TBHI",  0xBFE701 },
+    { L"CIAA TDLO",  0xBFE801 },
+    { L"CIAA TDMD",  0xBFE901 },
+    { L"CIAA TDHI",  0xBFEA01 },
+    { L"CIAA SDR",   0xBFEC01 },
+    { L"CIAA ICR",   0xBFED01 },
+    { L"CIAA CRA",   0xBFEE01 },
+    { L"CIAA CRB",   0xBFEF01 },
+    { L"CLK S1",     0xDC0000 },
+    { L"CLK S10",    0xDC0004 },
+    { L"CLK MI1",    0xDC0008 },
+    { L"CLK MI10",   0xDC000C },
+    { L"CLK H1",     0xDC0010 },
+    { L"CLK H10",    0xDC0014 },
+    { L"CLK D1",     0xDC0018 },
+    { L"CLK D10",    0xDC001C },
+    { L"CLK MO1",    0xDC0020 },
+    { L"CLK MO10",   0xDC0024 },
+    { L"CLK Y1",     0xDC0028 },
+    { L"CLK Y10",    0xDC002E },
+    { L"CLK WEEK",   0xDC0030 },
+    { L"CLK CD",     0xDC0034 },
+    { L"CLK CE",     0xDC0038 },
+    { L"CLK CF",     0xDC003C },
     { NULL, 0 }
 };
 
@@ -117,285 +117,285 @@ const struct mem_labels mem_labels[] =
 const struct customData custd[] =
 {
 #if 0
-    { "BLTDDAT",  0xdff000 }, /* Blitter dest. early read (dummy address) */
+    { L"BLTDDAT",  0xdff000 }, /* Blitter dest. early read (dummy address) */
 #endif
-    { "DMACONR",  0xdff002, 1 }, /* Dma control (and blitter status) read */
-    { "VPOSR",    0xdff004, 1 }, /* Read vert most sig. bits (and frame flop */
-    { "VHPOSR",   0xdff006, 1 }, /* Read vert and horiz position of beam */
+    { L"DMACONR",  0xdff002, 1 }, /* Dma control (and blitter status) read */
+    { L"VPOSR",    0xdff004, 1 }, /* Read vert most sig. bits (and frame flop */
+    { L"VHPOSR",   0xdff006, 1 }, /* Read vert and horiz position of beam */
 #if 0
-    { "DSKDATR",  0xdff008 }, /* Disk data early read (dummy address) */
+    { L"DSKDATR",  0xdff008 }, /* Disk data early read (dummy address) */
 #endif
-    { "JOY0DAT",  0xdff00A, 1 }, /* Joystick-mouse 0 data (vert,horiz) */
-    { "JOT1DAT",  0xdff00C, 1 }, /* Joystick-mouse 1 data (vert,horiz) */
-    { "CLXDAT",   0xdff00E, 1 }, /* Collision data reg. (read and clear) */
-    { "ADKCONR",  0xdff010, 1 }, /* Audio,disk control register read */
-    { "POT0DAT",  0xdff012, 1 }, /* Pot counter pair 0 data (vert,horiz) */
-    { "POT1DAT",  0xdff014, 1 }, /* Pot counter pair 1 data (vert,horiz) */
-    { "POTGOR",   0xdff016, 1 }, /* Pot pin data read */
-    { "SERDATR",  0xdff018, 1 }, /* Serial port data and status read */
-    { "DSKBYTR",  0xdff01A, 1 }, /* Disk data byte and status read */
-    { "INTENAR",  0xdff01C, 1 }, /* Interrupt enable bits read */
-    { "INTREQR",  0xdff01E, 1 }, /* Interrupt request bits read */
-    { "DSKPTH",   0xdff020, 2, 1 }, /* Disk pointer (high 5 bits) */
-    { "DSKPTL",   0xdff022, 2, 2 }, /* Disk pointer (low 15 bits) */
-    { "DSKLEN",   0xdff024, 2, 0 }, /* Disk lentgh */
+    { L"JOY0DAT",  0xdff00A, 1 }, /* Joystick-mouse 0 data (vert,horiz) */
+    { L"JOT1DAT",  0xdff00C, 1 }, /* Joystick-mouse 1 data (vert,horiz) */
+    { L"CLXDAT",   0xdff00E, 1 }, /* Collision data reg. (read and clear) */
+    { L"ADKCONR",  0xdff010, 1 }, /* Audio,disk control register read */
+    { L"POT0DAT",  0xdff012, 1 }, /* Pot counter pair 0 data (vert,horiz) */
+    { L"POT1DAT",  0xdff014, 1 }, /* Pot counter pair 1 data (vert,horiz) */
+    { L"POTGOR",   0xdff016, 1 }, /* Pot pin data read */
+    { L"SERDATR",  0xdff018, 1 }, /* Serial port data and status read */
+    { L"DSKBYTR",  0xdff01A, 1 }, /* Disk data byte and status read */
+    { L"INTENAR",  0xdff01C, 1 }, /* Interrupt enable bits read */
+    { L"INTREQR",  0xdff01E, 1 }, /* Interrupt request bits read */
+    { L"DSKPTH",   0xdff020, 2, 1 }, /* Disk pointer (high 5 bits) */
+    { L"DSKPTL",   0xdff022, 2, 2 }, /* Disk pointer (low 15 bits) */
+    { L"DSKLEN",   0xdff024, 2, 0 }, /* Disk lentgh */
 #if 0
-    { "DSKDAT",   0xdff026 }, /* Disk DMA data write */
-    { "REFPTR",   0xdff028 }, /* Refresh pointer */
+    { L"DSKDAT",   0xdff026 }, /* Disk DMA data write */
+    { L"REFPTR",   0xdff028 }, /* Refresh pointer */
 #endif
-    { "VPOSW",    0xdff02A, 2, 0 }, /* Write vert most sig. bits(and frame flop) */
-    { "VHPOSW",   0xdff02C, 2, 0 }, /* Write vert and horiz pos of beam */
-    { "COPCON",   0xdff02e, 2, 0 }, /* Coprocessor control reg (CDANG) */
-    { "SERDAT",   0xdff030, 2, 0 }, /* Serial port data and stop bits write */
-    { "SERPER",   0xdff032, 2, 0 }, /* Serial port period and control */
-    { "POTGO",    0xdff034, 2, 0 }, /* Pot count start,pot pin drive enable data */
-    { "JOYTEST",  0xdff036, 2, 0 }, /* Write to all 4 joystick-mouse counters at once */
-    { "STREQU",   0xdff038, 2, 0 }, /* Strobe for horiz sync with VB and EQU */
-    { "STRVBL",   0xdff03A, 2, 0 }, /* Strobe for horiz sync with VB (vert blank) */
-    { "STRHOR",   0xdff03C, 2, 0 }, /* Strobe for horiz sync */
-    { "STRLONG",  0xdff03E, 2, 0 }, /* Strobe for identification of long horiz line */
-    { "BLTCON0",  0xdff040, 2, 0 }, /* Blitter control reg 0 */
-    { "BLTCON1",  0xdff042, 2, 0 }, /* Blitter control reg 1 */
-    { "BLTAFWM",  0xdff044, 2, 0 }, /* Blitter first word mask for source A */
-    { "BLTALWM",  0xdff046, 2, 0 }, /* Blitter last word mask for source A */
-    { "BLTCPTH",  0xdff048, 2, 1 }, /* Blitter pointer to source C (high 5 bits) */
-    { "BLTCPTL",  0xdff04A, 2, 2 }, /* Blitter pointer to source C (low 15 bits) */
-    { "BLTBPTH",  0xdff04C, 2, 1 }, /* Blitter pointer to source B (high 5 bits) */
-    { "BLTBPTL",  0xdff04E, 2, 2 }, /* Blitter pointer to source B (low 15 bits) */
-    { "BLTAPTH",  0xdff050, 2, 1 }, /* Blitter pointer to source A (high 5 bits) */
-    { "BLTAPTL",  0xdff052, 2, 2 }, /* Blitter pointer to source A (low 15 bits) */
-    { "BPTDPTH",  0xdff054, 2, 1 }, /* Blitter pointer to destn  D (high 5 bits) */
-    { "BLTDPTL",  0xdff056, 2, 2 }, /* Blitter pointer to destn  D (low 15 bits) */
-    { "BLTSIZE",  0xdff058, 2, 0 }, /* Blitter start and size (win/width,height) */
-    { "BLTCON0L", 0xdff05A, 2, 4 }, /* Blitter control 0 lower 8 bits (minterms) */
-    { "BLTSIZV",  0xdff05C, 2, 4 }, /* Blitter V size (for 15 bit vert size) */
-    { "BLTSIZH",  0xdff05E, 2, 4 }, /* Blitter H size & start (for 11 bit H size) */
-    { "BLTCMOD",  0xdff060, 2, 0 }, /* Blitter modulo for source C */
-    { "BLTBMOD",  0xdff062, 2, 0 }, /* Blitter modulo for source B */
-    { "BLTAMOD",  0xdff064, 2, 0 }, /* Blitter modulo for source A */
-    { "BLTDMOD",  0xdff066, 2, 0 }, /* Blitter modulo for destn  D */
+    { L"VPOSW",    0xdff02A, 2, 0 }, /* Write vert most sig. bits(and frame flop) */
+    { L"VHPOSW",   0xdff02C, 2, 0 }, /* Write vert and horiz pos of beam */
+    { L"COPCON",   0xdff02e, 2, 0 }, /* Coprocessor control reg (CDANG) */
+    { L"SERDAT",   0xdff030, 2, 0 }, /* Serial port data and stop bits write */
+    { L"SERPER",   0xdff032, 2, 0 }, /* Serial port period and control */
+    { L"POTGO",    0xdff034, 2, 0 }, /* Pot count start,pot pin drive enable data */
+    { L"JOYTEST",  0xdff036, 2, 0 }, /* Write to all 4 joystick-mouse counters at once */
+    { L"STREQU",   0xdff038, 2, 0 }, /* Strobe for horiz sync with VB and EQU */
+    { L"STRVBL",   0xdff03A, 2, 0 }, /* Strobe for horiz sync with VB (vert blank) */
+    { L"STRHOR",   0xdff03C, 2, 0 }, /* Strobe for horiz sync */
+    { L"STRLONG",  0xdff03E, 2, 0 }, /* Strobe for identification of long horiz line */
+    { L"BLTCON0",  0xdff040, 2, 0 }, /* Blitter control reg 0 */
+    { L"BLTCON1",  0xdff042, 2, 0 }, /* Blitter control reg 1 */
+    { L"BLTAFWM",  0xdff044, 2, 0 }, /* Blitter first word mask for source A */
+    { L"BLTALWM",  0xdff046, 2, 0 }, /* Blitter last word mask for source A */
+    { L"BLTCPTH",  0xdff048, 2, 1 }, /* Blitter pointer to source C (high 5 bits) */
+    { L"BLTCPTL",  0xdff04A, 2, 2 }, /* Blitter pointer to source C (low 15 bits) */
+    { L"BLTBPTH",  0xdff04C, 2, 1 }, /* Blitter pointer to source B (high 5 bits) */
+    { L"BLTBPTL",  0xdff04E, 2, 2 }, /* Blitter pointer to source B (low 15 bits) */
+    { L"BLTAPTH",  0xdff050, 2, 1 }, /* Blitter pointer to source A (high 5 bits) */
+    { L"BLTAPTL",  0xdff052, 2, 2 }, /* Blitter pointer to source A (low 15 bits) */
+    { L"BPTDPTH",  0xdff054, 2, 1 }, /* Blitter pointer to destn  D (high 5 bits) */
+    { L"BLTDPTL",  0xdff056, 2, 2 }, /* Blitter pointer to destn  D (low 15 bits) */
+    { L"BLTSIZE",  0xdff058, 2, 0 }, /* Blitter start and size (win/width,height) */
+    { L"BLTCON0L", 0xdff05A, 2, 4 }, /* Blitter control 0 lower 8 bits (minterms) */
+    { L"BLTSIZV",  0xdff05C, 2, 4 }, /* Blitter V size (for 15 bit vert size) */
+    { L"BLTSIZH",  0xdff05E, 2, 4 }, /* Blitter H size & start (for 11 bit H size) */
+    { L"BLTCMOD",  0xdff060, 2, 0 }, /* Blitter modulo for source C */
+    { L"BLTBMOD",  0xdff062, 2, 0 }, /* Blitter modulo for source B */
+    { L"BLTAMOD",  0xdff064, 2, 0 }, /* Blitter modulo for source A */
+    { L"BLTDMOD",  0xdff066, 2, 0 }, /* Blitter modulo for destn  D */
 #if 0
-    { "Unknown",  0xdff068 }, /* Unknown or Unused */
-    { "Unknown",  0xdff06a }, /* Unknown or Unused */
-    { "Unknown",  0xdff06c }, /* Unknown or Unused */
-    { "Unknown",  0xdff06e }, /* Unknown or Unused */
+    { L"Unknown",  0xdff068 }, /* Unknown or Unused */
+    { L"Unknown",  0xdff06a }, /* Unknown or Unused */
+    { L"Unknown",  0xdff06c }, /* Unknown or Unused */
+    { L"Unknown",  0xdff06e }, /* Unknown or Unused */
 #endif
-    { "BLTCDAT",  0xdff070, 2, 0 }, /* Blitter source C data reg */
-    { "BLTBDAT",  0xdff072, 2, 0 }, /* Blitter source B data reg */
-    { "BLTADAT",  0xdff074, 2, 0 }, /* Blitter source A data reg */
-    { "BLTDDAT",  0xdff076, 2, 0 }, /* Blitter destination reg */
+    { L"BLTCDAT",  0xdff070, 2, 0 }, /* Blitter source C data reg */
+    { L"BLTBDAT",  0xdff072, 2, 0 }, /* Blitter source B data reg */
+    { L"BLTADAT",  0xdff074, 2, 0 }, /* Blitter source A data reg */
+    { L"BLTDDAT",  0xdff076, 2, 0 }, /* Blitter destination reg */
 #if 0
-    { "SPRHDAT",  0xdff078 }, /* Ext logic UHRES sprite pointer and data identifier */
-    { "BPLHDAT",  0xdff07A }, /* Ext logic UHRES bit plane identifier */
+    { L"SPRHDAT",  0xdff078 }, /* Ext logic UHRES sprite pointer and data identifier */
+    { L"BPLHDAT",  0xdff07A }, /* Ext logic UHRES bit plane identifier */
 #endif
-    { "LISAID",   0xdff07C, 1, 8 }, /* Chip revision level for Denise/Lisa */
-    { "DSKSYNC",  0xdff07E, 2 }, /* Disk sync pattern reg for disk read */
-    { "COP1LCH",  0xdff080, 2, 1 }, /* Coprocessor first location reg (high 5 bits) */
-    { "COP1LCL",  0xdff082, 2, 2 }, /* Coprocessor first location reg (low 15 bits) */
-    { "COP2LCH",  0xdff084, 2, 1 }, /* Coprocessor second reg (high 5 bits) */
-    { "COP2LCL",  0xdff086, 2, 2 }, /* Coprocessor second reg (low 15 bits) */
-    { "COPJMP1",  0xdff088, 2 }, /* Coprocessor restart at first location */
-    { "COPJMP2",  0xdff08A, 2 }, /* Coprocessor restart at second location */
+    { L"LISAID",   0xdff07C, 1, 8 }, /* Chip revision level for Denise/Lisa */
+    { L"DSKSYNC",  0xdff07E, 2 }, /* Disk sync pattern reg for disk read */
+    { L"COP1LCH",  0xdff080, 2, 1 }, /* Coprocessor first location reg (high 5 bits) */
+    { L"COP1LCL",  0xdff082, 2, 2 }, /* Coprocessor first location reg (low 15 bits) */
+    { L"COP2LCH",  0xdff084, 2, 1 }, /* Coprocessor second reg (high 5 bits) */
+    { L"COP2LCL",  0xdff086, 2, 2 }, /* Coprocessor second reg (low 15 bits) */
+    { L"COPJMP1",  0xdff088, 2 }, /* Coprocessor restart at first location */
+    { L"COPJMP2",  0xdff08A, 2 }, /* Coprocessor restart at second location */
 #if 0
-    { "COPINS",   0xdff08C }, /* Coprocessor inst fetch identify */
+    { L"COPINS",   0xdff08C }, /* Coprocessor inst fetch identify */
 #endif
-    { "DIWSTRT",  0xdff08E, 2 }, /* Display window start (upper left vert-hor pos) */
-    { "DIWSTOP",  0xdff090, 2 }, /* Display window stop (lower right vert-hor pos) */
-    { "DDFSTRT",  0xdff092, 2 }, /* Display bit plane data fetch start.hor pos */
-    { "DDFSTOP",  0xdff094, 2 }, /* Display bit plane data fetch stop.hor pos */
-    { "DMACON",   0xdff096, 2 }, /* DMA control write (clear or set) */
-    { "CLXCON",   0xdff098, 2 }, /* Collision control */
-    { "INTENA",   0xdff09A, 2 }, /* Interrupt enable bits (clear or set bits) */
-    { "INTREQ",   0xdff09C, 2 }, /* Interrupt request bits (clear or set bits) */
-    { "ADKCON",   0xdff09E, 2 }, /* Audio,disk,UART,control */
-    { "AUD0LCH",  0xdff0A0, 2, 1 }, /* Audio channel 0 location (high 5 bits) */
-    { "AUD0LCL",  0xdff0A2, 2, 2 }, /* Audio channel 0 location (low 15 bits) */
-    { "AUD0LEN",  0xdff0A4, 2 }, /* Audio channel 0 lentgh */
-    { "AUD0PER",  0xdff0A6, 2 }, /* Audio channel 0 period */
-    { "AUD0VOL",  0xdff0A8, 2 }, /* Audio channel 0 volume */
-    { "AUD0DAT",  0xdff0AA, 2 }, /* Audio channel 0 data */
+    { L"DIWSTRT",  0xdff08E, 2 }, /* Display window start (upper left vert-hor pos) */
+    { L"DIWSTOP",  0xdff090, 2 }, /* Display window stop (lower right vert-hor pos) */
+    { L"DDFSTRT",  0xdff092, 2 }, /* Display bit plane data fetch start.hor pos */
+    { L"DDFSTOP",  0xdff094, 2 }, /* Display bit plane data fetch stop.hor pos */
+    { L"DMACON",   0xdff096, 2 }, /* DMA control write (clear or set) */
+    { L"CLXCON",   0xdff098, 2 }, /* Collision control */
+    { L"INTENA",   0xdff09A, 2 }, /* Interrupt enable bits (clear or set bits) */
+    { L"INTREQ",   0xdff09C, 2 }, /* Interrupt request bits (clear or set bits) */
+    { L"ADKCON",   0xdff09E, 2 }, /* Audio,disk,UART,control */
+    { L"AUD0LCH",  0xdff0A0, 2, 1 }, /* Audio channel 0 location (high 5 bits) */
+    { L"AUD0LCL",  0xdff0A2, 2, 2 }, /* Audio channel 0 location (low 15 bits) */
+    { L"AUD0LEN",  0xdff0A4, 2 }, /* Audio channel 0 lentgh */
+    { L"AUD0PER",  0xdff0A6, 2 }, /* Audio channel 0 period */
+    { L"AUD0VOL",  0xdff0A8, 2 }, /* Audio channel 0 volume */
+    { L"AUD0DAT",  0xdff0AA, 2 }, /* Audio channel 0 data */
 #if 0
-    { "Unknown",  0xdff0AC }, /* Unknown or Unused */
-    { "Unknown",  0xdff0AE }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0AC }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0AE }, /* Unknown or Unused */
 #endif
-    { "AUD1LCH",  0xdff0B0, 2, 1 }, /* Audio channel 1 location (high 5 bits) */
-    { "AUD1LCL",  0xdff0B2, 2, 2 }, /* Audio channel 1 location (low 15 bits) */
-    { "AUD1LEN",  0xdff0B4, 2 }, /* Audio channel 1 lentgh */
-    { "AUD1PER",  0xdff0B6, 2 }, /* Audio channel 1 period */
-    { "AUD1VOL",  0xdff0B8, 2 }, /* Audio channel 1 volume */
-    { "AUD1DAT",  0xdff0BA, 2 }, /* Audio channel 1 data */
+    { L"AUD1LCH",  0xdff0B0, 2, 1 }, /* Audio channel 1 location (high 5 bits) */
+    { L"AUD1LCL",  0xdff0B2, 2, 2 }, /* Audio channel 1 location (low 15 bits) */
+    { L"AUD1LEN",  0xdff0B4, 2 }, /* Audio channel 1 lentgh */
+    { L"AUD1PER",  0xdff0B6, 2 }, /* Audio channel 1 period */
+    { L"AUD1VOL",  0xdff0B8, 2 }, /* Audio channel 1 volume */
+    { L"AUD1DAT",  0xdff0BA, 2 }, /* Audio channel 1 data */
 #if 0
-    { "Unknown",  0xdff0BC }, /* Unknown or Unused */
-    { "Unknown",  0xdff0BE }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0BC }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0BE }, /* Unknown or Unused */
 #endif
-    { "AUD2LCH",  0xdff0C0, 2, 1 }, /* Audio channel 2 location (high 5 bits) */
-    { "AUD2LCL",  0xdff0C2, 2, 2 }, /* Audio channel 2 location (low 15 bits) */
-    { "AUD2LEN",  0xdff0C4, 2 }, /* Audio channel 2 lentgh */
-    { "AUD2PER",  0xdff0C6, 2 }, /* Audio channel 2 period */
-    { "AUD2VOL",  0xdff0C8, 2 }, /* Audio channel 2 volume */
-    { "AUD2DAT",  0xdff0CA, 2 }, /* Audio channel 2 data */
+    { L"AUD2LCH",  0xdff0C0, 2, 1 }, /* Audio channel 2 location (high 5 bits) */
+    { L"AUD2LCL",  0xdff0C2, 2, 2 }, /* Audio channel 2 location (low 15 bits) */
+    { L"AUD2LEN",  0xdff0C4, 2 }, /* Audio channel 2 lentgh */
+    { L"AUD2PER",  0xdff0C6, 2 }, /* Audio channel 2 period */
+    { L"AUD2VOL",  0xdff0C8, 2 }, /* Audio channel 2 volume */
+    { L"AUD2DAT",  0xdff0CA, 2 }, /* Audio channel 2 data */
 #if 0
-    { "Unknown",  0xdff0CC }, /* Unknown or Unused */
-    { "Unknown",  0xdff0CE }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0CC }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0CE }, /* Unknown or Unused */
 #endif
-    { "AUD3LCH",  0xdff0D0, 2, 1 }, /* Audio channel 3 location (high 5 bits) */
-    { "AUD3LCL",  0xdff0D2, 2, 2 }, /* Audio channel 3 location (low 15 bits) */
-    { "AUD3LEN",  0xdff0D4, 2 }, /* Audio channel 3 lentgh */
-    { "AUD3PER",  0xdff0D6, 2 }, /* Audio channel 3 period */
-    { "AUD3VOL",  0xdff0D8, 2 }, /* Audio channel 3 volume */
-    { "AUD3DAT",  0xdff0DA, 2 }, /* Audio channel 3 data */
+    { L"AUD3LCH",  0xdff0D0, 2, 1 }, /* Audio channel 3 location (high 5 bits) */
+    { L"AUD3LCL",  0xdff0D2, 2, 2 }, /* Audio channel 3 location (low 15 bits) */
+    { L"AUD3LEN",  0xdff0D4, 2 }, /* Audio channel 3 lentgh */
+    { L"AUD3PER",  0xdff0D6, 2 }, /* Audio channel 3 period */
+    { L"AUD3VOL",  0xdff0D8, 2 }, /* Audio channel 3 volume */
+    { L"AUD3DAT",  0xdff0DA, 2 }, /* Audio channel 3 data */
 #if 0
-    { "Unknown",  0xdff0DC }, /* Unknown or Unused */
-    { "Unknown",  0xdff0DE }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0DC }, /* Unknown or Unused */
+    { L"Unknown",  0xdff0DE }, /* Unknown or Unused */
 #endif
-    { "BPL1PTH",  0xdff0E0, 2, 1 }, /* Bit plane pointer 1 (high 5 bits) */
-    { "BPL1PTL",  0xdff0E2, 2, 2 }, /* Bit plane pointer 1 (low 15 bits) */
-    { "BPL2PTH",  0xdff0E4, 2, 1 }, /* Bit plane pointer 2 (high 5 bits) */
-    { "BPL2PTL",  0xdff0E6, 2, 2 }, /* Bit plane pointer 2 (low 15 bits) */
-    { "BPL3PTH",  0xdff0E8, 2, 1 }, /* Bit plane pointer 3 (high 5 bits) */
-    { "BPL3PTL",  0xdff0EA, 2, 2 }, /* Bit plane pointer 3 (low 15 bits) */
-    { "BPL4PTH",  0xdff0EC, 2, 1 }, /* Bit plane pointer 4 (high 5 bits) */
-    { "BPL4PTL",  0xdff0EE, 2, 2 }, /* Bit plane pointer 4 (low 15 bits) */
-    { "BPL5PTH",  0xdff0F0, 2, 1 }, /* Bit plane pointer 5 (high 5 bits) */
-    { "BPL5PTL",  0xdff0F2, 2, 2 }, /* Bit plane pointer 5 (low 15 bits) */
-    { "BPL6PTH",  0xdff0F4, 2, 1|8 }, /* Bit plane pointer 6 (high 5 bits) */
-    { "BPL6PTL",  0xdff0F6, 2, 2|8 }, /* Bit plane pointer 6 (low 15 bits) */
-    { "BPL7PTH",  0xdff0F8, 2, 1|8 }, /* Bit plane pointer 7 (high 5 bits) */
-    { "BPL7PTL",  0xdff0FA, 2, 2|8 }, /* Bit plane pointer 7 (low 15 bits) */
-    { "BPL8PTH",  0xdff0FC, 2, 1|8 }, /* Bit plane pointer 8 (high 5 bits) */
-    { "BPL8PTL",  0xdff0FE, 2, 2|8 }, /* Bit plane pointer 8 (low 15 bits) */
-    { "BPLCON0",  0xdff100, 2 }, /* Bit plane control reg (misc control bits) */
-    { "BPLCON1",  0xdff102, 2 }, /* Bit plane control reg (scroll val PF1,PF2) */
-    { "BPLCON2",  0xdff104, 2 }, /* Bit plane control reg (priority control) */
-    { "BPLCON3",  0xdff106, 2|8 }, /* Bit plane control reg (enhanced features) */
-    { "BPL1MOD",  0xdff108, 2 }, /* Bit plane modulo (odd planes,or active- fetch lines if bitplane scan-doubling is enabled */
-    { "BPL2MOD",  0xdff10A, 2 }, /* Bit plane modulo (even planes or inactive- fetch lines if bitplane scan-doubling is enabled */
-    { "BPLCON4",  0xdff10C, 2|8 }, /* Bit plane control reg (bitplane and sprite masks) */
-    { "CLXCON2",  0xdff10e, 2|8 }, /* Extended collision control reg */
-    { "BPL1DAT",  0xdff110, 2 }, /* Bit plane 1 data (parallel to serial con- vert) */
-    { "BPL2DAT",  0xdff112, 2 }, /* Bit plane 2 data (parallel to serial con- vert) */
-    { "BPL3DAT",  0xdff114, 2 }, /* Bit plane 3 data (parallel to serial con- vert) */
-    { "BPL4DAT",  0xdff116, 2 }, /* Bit plane 4 data (parallel to serial con- vert) */
-    { "BPL5DAT",  0xdff118, 2 }, /* Bit plane 5 data (parallel to serial con- vert) */
-    { "BPL6DAT",  0xdff11a, 2 }, /* Bit plane 6 data (parallel to serial con- vert) */
-    { "BPL7DAT",  0xdff11c, 2|8 }, /* Bit plane 7 data (parallel to serial con- vert) */
-    { "BPL8DAT",  0xdff11e, 2|8 }, /* Bit plane 8 data (parallel to serial con- vert) */
-    { "SPR0PTH",  0xdff120, 2, 1 }, /* Sprite 0 pointer (high 5 bits) */
-    { "SPR0PTL",  0xdff122, 2, 2 }, /* Sprite 0 pointer (low 15 bits) */
-    { "SPR1PTH",  0xdff124, 2, 1 }, /* Sprite 1 pointer (high 5 bits) */
-    { "SPR1PTL",  0xdff126, 2, 2 }, /* Sprite 1 pointer (low 15 bits) */
-    { "SPR2PTH",  0xdff128, 2, 1 }, /* Sprite 2 pointer (high 5 bits) */
-    { "SPR2PTL",  0xdff12A, 2, 2 }, /* Sprite 2 pointer (low 15 bits) */
-    { "SPR3PTH",  0xdff12C, 2, 1 }, /* Sprite 3 pointer (high 5 bits) */
-    { "SPR3PTL",  0xdff12E, 2, 2 }, /* Sprite 3 pointer (low 15 bits) */
-    { "SPR4PTH",  0xdff130, 2, 1 }, /* Sprite 4 pointer (high 5 bits) */
-    { "SPR4PTL",  0xdff132, 2, 2 }, /* Sprite 4 pointer (low 15 bits) */
-    { "SPR5PTH",  0xdff134, 2, 1 }, /* Sprite 5 pointer (high 5 bits) */
-    { "SPR5PTL",  0xdff136, 2, 2 }, /* Sprite 5 pointer (low 15 bits) */
-    { "SPR6PTH",  0xdff138, 2, 1 }, /* Sprite 6 pointer (high 5 bits) */
-    { "SPR6PTL",  0xdff13A, 2, 2 }, /* Sprite 6 pointer (low 15 bits) */
-    { "SPR7PTH",  0xdff13C, 2, 1 }, /* Sprite 7 pointer (high 5 bits) */
-    { "SPR7PTL",  0xdff13E, 2, 2 }, /* Sprite 7 pointer (low 15 bits) */
-    { "SPR0POS",  0xdff140, 2 }, /* Sprite 0 vert-horiz start pos data */
-    { "SPR0CTL",  0xdff142, 2 }, /* Sprite 0 position and control data */
-    { "SPR0DATA", 0xdff144, 2 }, /* Sprite 0 image data register A */
-    { "SPR0DATB", 0xdff146, 2 }, /* Sprite 0 image data register B */
-    { "SPR1POS",  0xdff148, 2 }, /* Sprite 1 vert-horiz start pos data */
-    { "SPR1CTL",  0xdff14A, 2 }, /* Sprite 1 position and control data */
-    { "SPR1DATA", 0xdff14C, 2 }, /* Sprite 1 image data register A */
-    { "SPR1DATB", 0xdff14E, 2 }, /* Sprite 1 image data register B */
-    { "SPR2POS",  0xdff150, 2 }, /* Sprite 2 vert-horiz start pos data */
-    { "SPR2CTL",  0xdff152, 2 }, /* Sprite 2 position and control data */
-    { "SPR2DATA", 0xdff154, 2 }, /* Sprite 2 image data register A */
-    { "SPR2DATB", 0xdff156, 2 }, /* Sprite 2 image data register B */
-    { "SPR3POS",  0xdff158, 2 }, /* Sprite 3 vert-horiz start pos data */
-    { "SPR3CTL",  0xdff15A, 2 }, /* Sprite 3 position and control data */
-    { "SPR3DATA", 0xdff15C, 2 }, /* Sprite 3 image data register A */
-    { "SPR3DATB", 0xdff15E, 2 }, /* Sprite 3 image data register B */
-    { "SPR4POS",  0xdff160, 2 }, /* Sprite 4 vert-horiz start pos data */
-    { "SPR4CTL",  0xdff162, 2 }, /* Sprite 4 position and control data */
-    { "SPR4DATA", 0xdff164, 2 }, /* Sprite 4 image data register A */
-    { "SPR4DATB", 0xdff166, 2 }, /* Sprite 4 image data register B */
-    { "SPR5POS",  0xdff168, 2 }, /* Sprite 5 vert-horiz start pos data */
-    { "SPR5CTL",  0xdff16A, 2 }, /* Sprite 5 position and control data */
-    { "SPR5DATA", 0xdff16C, 2 }, /* Sprite 5 image data register A */
-    { "SPR5DATB", 0xdff16E, 2 }, /* Sprite 5 image data register B */
-    { "SPR6POS",  0xdff170, 2 }, /* Sprite 6 vert-horiz start pos data */
-    { "SPR6CTL",  0xdff172, 2 }, /* Sprite 6 position and control data */
-    { "SPR6DATA", 0xdff174, 2 }, /* Sprite 6 image data register A */
-    { "SPR6DATB", 0xdff176, 2 }, /* Sprite 6 image data register B */
-    { "SPR7POS",  0xdff178, 2 }, /* Sprite 7 vert-horiz start pos data */
-    { "SPR7CTL",  0xdff17A, 2 }, /* Sprite 7 position and control data */
-    { "SPR7DATA", 0xdff17C, 2 }, /* Sprite 7 image data register A */
-    { "SPR7DATB", 0xdff17E, 2 }, /* Sprite 7 image data register B */
-    { "COLOR00",  0xdff180, 2 }, /* Color table 00 */
-    { "COLOR01",  0xdff182, 2 }, /* Color table 01 */
-    { "COLOR02",  0xdff184, 2 }, /* Color table 02 */
-    { "COLOR03",  0xdff186, 2 }, /* Color table 03 */
-    { "COLOR04",  0xdff188, 2 }, /* Color table 04 */
-    { "COLOR05",  0xdff18A, 2 }, /* Color table 05 */
-    { "COLOR06",  0xdff18C, 2 }, /* Color table 06 */
-    { "COLOR07",  0xdff18E, 2 }, /* Color table 07 */
-    { "COLOR08",  0xdff190, 2 }, /* Color table 08 */
-    { "COLOR09",  0xdff192, 2 }, /* Color table 09 */
-    { "COLOR10",  0xdff194, 2 }, /* Color table 10 */
-    { "COLOR11",  0xdff196, 2 }, /* Color table 11 */
-    { "COLOR12",  0xdff198, 2 }, /* Color table 12 */
-    { "COLOR13",  0xdff19A, 2 }, /* Color table 13 */
-    { "COLOR14",  0xdff19C, 2 }, /* Color table 14 */
-    { "COLOR15",  0xdff19E, 2 }, /* Color table 15 */
-    { "COLOR16",  0xdff1A0, 2 }, /* Color table 16 */
-    { "COLOR17",  0xdff1A2, 2 }, /* Color table 17 */
-    { "COLOR18",  0xdff1A4, 2 }, /* Color table 18 */
-    { "COLOR19",  0xdff1A6, 2 }, /* Color table 19 */
-    { "COLOR20",  0xdff1A8, 2 }, /* Color table 20 */
-    { "COLOR21",  0xdff1AA, 2 }, /* Color table 21 */
-    { "COLOR22",  0xdff1AC, 2 }, /* Color table 22 */
-    { "COLOR23",  0xdff1AE, 2 }, /* Color table 23 */
-    { "COLOR24",  0xdff1B0, 2 }, /* Color table 24 */
-    { "COLOR25",  0xdff1B2, 2 }, /* Color table 25 */
-    { "COLOR26",  0xdff1B4, 2 }, /* Color table 26 */
-    { "COLOR27",  0xdff1B6, 2 }, /* Color table 27 */
-    { "COLOR28",  0xdff1B8, 2 }, /* Color table 28 */
-    { "COLOR29",  0xdff1BA, 2 }, /* Color table 29 */
-    { "COLOR30",  0xdff1BC, 2 }, /* Color table 30 */
-    { "COLOR31",  0xdff1BE, 2 }, /* Color table 31 */
-    { "HTOTAL",   0xdff1C0, 2|4 }, /* Highest number count in horiz line (VARBEAMEN = 1) */
-    { "HSSTOP",   0xdff1C2, 2|4 }, /* Horiz line pos for HSYNC stop */
-    { "HBSTRT",   0xdff1C4, 2|4 }, /* Horiz line pos for HBLANK start */
-    { "HBSTOP",   0xdff1C6, 2|4 }, /* Horiz line pos for HBLANK stop */
-    { "VTOTAL",   0xdff1C8, 2|4 }, /* Highest numbered vertical line (VARBEAMEN = 1) */
-    { "VSSTOP",   0xdff1CA, 2|4 }, /* Vert line for VBLANK start */
-    { "VBSTRT",   0xdff1CC, 2|4 }, /* Vert line for VBLANK start */
-    { "VBSTOP",   0xdff1CE, 2|4 }, /* Vert line for VBLANK stop */
+    { L"BPL1PTH",  0xdff0E0, 2, 1 }, /* Bit plane pointer 1 (high 5 bits) */
+    { L"BPL1PTL",  0xdff0E2, 2, 2 }, /* Bit plane pointer 1 (low 15 bits) */
+    { L"BPL2PTH",  0xdff0E4, 2, 1 }, /* Bit plane pointer 2 (high 5 bits) */
+    { L"BPL2PTL",  0xdff0E6, 2, 2 }, /* Bit plane pointer 2 (low 15 bits) */
+    { L"BPL3PTH",  0xdff0E8, 2, 1 }, /* Bit plane pointer 3 (high 5 bits) */
+    { L"BPL3PTL",  0xdff0EA, 2, 2 }, /* Bit plane pointer 3 (low 15 bits) */
+    { L"BPL4PTH",  0xdff0EC, 2, 1 }, /* Bit plane pointer 4 (high 5 bits) */
+    { L"BPL4PTL",  0xdff0EE, 2, 2 }, /* Bit plane pointer 4 (low 15 bits) */
+    { L"BPL5PTH",  0xdff0F0, 2, 1 }, /* Bit plane pointer 5 (high 5 bits) */
+    { L"BPL5PTL",  0xdff0F2, 2, 2 }, /* Bit plane pointer 5 (low 15 bits) */
+    { L"BPL6PTH",  0xdff0F4, 2, 1|8 }, /* Bit plane pointer 6 (high 5 bits) */
+    { L"BPL6PTL",  0xdff0F6, 2, 2|8 }, /* Bit plane pointer 6 (low 15 bits) */
+    { L"BPL7PTH",  0xdff0F8, 2, 1|8 }, /* Bit plane pointer 7 (high 5 bits) */
+    { L"BPL7PTL",  0xdff0FA, 2, 2|8 }, /* Bit plane pointer 7 (low 15 bits) */
+    { L"BPL8PTH",  0xdff0FC, 2, 1|8 }, /* Bit plane pointer 8 (high 5 bits) */
+    { L"BPL8PTL",  0xdff0FE, 2, 2|8 }, /* Bit plane pointer 8 (low 15 bits) */
+    { L"BPLCON0",  0xdff100, 2 }, /* Bit plane control reg (misc control bits) */
+    { L"BPLCON1",  0xdff102, 2 }, /* Bit plane control reg (scroll val PF1,PF2) */
+    { L"BPLCON2",  0xdff104, 2 }, /* Bit plane control reg (priority control) */
+    { L"BPLCON3",  0xdff106, 2|8 }, /* Bit plane control reg (enhanced features) */
+    { L"BPL1MOD",  0xdff108, 2 }, /* Bit plane modulo (odd planes,or active- fetch lines if bitplane scan-doubling is enabled */
+    { L"BPL2MOD",  0xdff10A, 2 }, /* Bit plane modulo (even planes or inactive- fetch lines if bitplane scan-doubling is enabled */
+    { L"BPLCON4",  0xdff10C, 2|8 }, /* Bit plane control reg (bitplane and sprite masks) */
+    { L"CLXCON2",  0xdff10e, 2|8 }, /* Extended collision control reg */
+    { L"BPL1DAT",  0xdff110, 2 }, /* Bit plane 1 data (parallel to serial con- vert) */
+    { L"BPL2DAT",  0xdff112, 2 }, /* Bit plane 2 data (parallel to serial con- vert) */
+    { L"BPL3DAT",  0xdff114, 2 }, /* Bit plane 3 data (parallel to serial con- vert) */
+    { L"BPL4DAT",  0xdff116, 2 }, /* Bit plane 4 data (parallel to serial con- vert) */
+    { L"BPL5DAT",  0xdff118, 2 }, /* Bit plane 5 data (parallel to serial con- vert) */
+    { L"BPL6DAT",  0xdff11a, 2 }, /* Bit plane 6 data (parallel to serial con- vert) */
+    { L"BPL7DAT",  0xdff11c, 2|8 }, /* Bit plane 7 data (parallel to serial con- vert) */
+    { L"BPL8DAT",  0xdff11e, 2|8 }, /* Bit plane 8 data (parallel to serial con- vert) */
+    { L"SPR0PTH",  0xdff120, 2, 1 }, /* Sprite 0 pointer (high 5 bits) */
+    { L"SPR0PTL",  0xdff122, 2, 2 }, /* Sprite 0 pointer (low 15 bits) */
+    { L"SPR1PTH",  0xdff124, 2, 1 }, /* Sprite 1 pointer (high 5 bits) */
+    { L"SPR1PTL",  0xdff126, 2, 2 }, /* Sprite 1 pointer (low 15 bits) */
+    { L"SPR2PTH",  0xdff128, 2, 1 }, /* Sprite 2 pointer (high 5 bits) */
+    { L"SPR2PTL",  0xdff12A, 2, 2 }, /* Sprite 2 pointer (low 15 bits) */
+    { L"SPR3PTH",  0xdff12C, 2, 1 }, /* Sprite 3 pointer (high 5 bits) */
+    { L"SPR3PTL",  0xdff12E, 2, 2 }, /* Sprite 3 pointer (low 15 bits) */
+    { L"SPR4PTH",  0xdff130, 2, 1 }, /* Sprite 4 pointer (high 5 bits) */
+    { L"SPR4PTL",  0xdff132, 2, 2 }, /* Sprite 4 pointer (low 15 bits) */
+    { L"SPR5PTH",  0xdff134, 2, 1 }, /* Sprite 5 pointer (high 5 bits) */
+    { L"SPR5PTL",  0xdff136, 2, 2 }, /* Sprite 5 pointer (low 15 bits) */
+    { L"SPR6PTH",  0xdff138, 2, 1 }, /* Sprite 6 pointer (high 5 bits) */
+    { L"SPR6PTL",  0xdff13A, 2, 2 }, /* Sprite 6 pointer (low 15 bits) */
+    { L"SPR7PTH",  0xdff13C, 2, 1 }, /* Sprite 7 pointer (high 5 bits) */
+    { L"SPR7PTL",  0xdff13E, 2, 2 }, /* Sprite 7 pointer (low 15 bits) */
+    { L"SPR0POS",  0xdff140, 2 }, /* Sprite 0 vert-horiz start pos data */
+    { L"SPR0CTL",  0xdff142, 2 }, /* Sprite 0 position and control data */
+    { L"SPR0DATA", 0xdff144, 2 }, /* Sprite 0 image data register A */
+    { L"SPR0DATB", 0xdff146, 2 }, /* Sprite 0 image data register B */
+    { L"SPR1POS",  0xdff148, 2 }, /* Sprite 1 vert-horiz start pos data */
+    { L"SPR1CTL",  0xdff14A, 2 }, /* Sprite 1 position and control data */
+    { L"SPR1DATA", 0xdff14C, 2 }, /* Sprite 1 image data register A */
+    { L"SPR1DATB", 0xdff14E, 2 }, /* Sprite 1 image data register B */
+    { L"SPR2POS",  0xdff150, 2 }, /* Sprite 2 vert-horiz start pos data */
+    { L"SPR2CTL",  0xdff152, 2 }, /* Sprite 2 position and control data */
+    { L"SPR2DATA", 0xdff154, 2 }, /* Sprite 2 image data register A */
+    { L"SPR2DATB", 0xdff156, 2 }, /* Sprite 2 image data register B */
+    { L"SPR3POS",  0xdff158, 2 }, /* Sprite 3 vert-horiz start pos data */
+    { L"SPR3CTL",  0xdff15A, 2 }, /* Sprite 3 position and control data */
+    { L"SPR3DATA", 0xdff15C, 2 }, /* Sprite 3 image data register A */
+    { L"SPR3DATB", 0xdff15E, 2 }, /* Sprite 3 image data register B */
+    { L"SPR4POS",  0xdff160, 2 }, /* Sprite 4 vert-horiz start pos data */
+    { L"SPR4CTL",  0xdff162, 2 }, /* Sprite 4 position and control data */
+    { L"SPR4DATA", 0xdff164, 2 }, /* Sprite 4 image data register A */
+    { L"SPR4DATB", 0xdff166, 2 }, /* Sprite 4 image data register B */
+    { L"SPR5POS",  0xdff168, 2 }, /* Sprite 5 vert-horiz start pos data */
+    { L"SPR5CTL",  0xdff16A, 2 }, /* Sprite 5 position and control data */
+    { L"SPR5DATA", 0xdff16C, 2 }, /* Sprite 5 image data register A */
+    { L"SPR5DATB", 0xdff16E, 2 }, /* Sprite 5 image data register B */
+    { L"SPR6POS",  0xdff170, 2 }, /* Sprite 6 vert-horiz start pos data */
+    { L"SPR6CTL",  0xdff172, 2 }, /* Sprite 6 position and control data */
+    { L"SPR6DATA", 0xdff174, 2 }, /* Sprite 6 image data register A */
+    { L"SPR6DATB", 0xdff176, 2 }, /* Sprite 6 image data register B */
+    { L"SPR7POS",  0xdff178, 2 }, /* Sprite 7 vert-horiz start pos data */
+    { L"SPR7CTL",  0xdff17A, 2 }, /* Sprite 7 position and control data */
+    { L"SPR7DATA", 0xdff17C, 2 }, /* Sprite 7 image data register A */
+    { L"SPR7DATB", 0xdff17E, 2 }, /* Sprite 7 image data register B */
+    { L"COLOR00",  0xdff180, 2 }, /* Color table 00 */
+    { L"COLOR01",  0xdff182, 2 }, /* Color table 01 */
+    { L"COLOR02",  0xdff184, 2 }, /* Color table 02 */
+    { L"COLOR03",  0xdff186, 2 }, /* Color table 03 */
+    { L"COLOR04",  0xdff188, 2 }, /* Color table 04 */
+    { L"COLOR05",  0xdff18A, 2 }, /* Color table 05 */
+    { L"COLOR06",  0xdff18C, 2 }, /* Color table 06 */
+    { L"COLOR07",  0xdff18E, 2 }, /* Color table 07 */
+    { L"COLOR08",  0xdff190, 2 }, /* Color table 08 */
+    { L"COLOR09",  0xdff192, 2 }, /* Color table 09 */
+    { L"COLOR10",  0xdff194, 2 }, /* Color table 10 */
+    { L"COLOR11",  0xdff196, 2 }, /* Color table 11 */
+    { L"COLOR12",  0xdff198, 2 }, /* Color table 12 */
+    { L"COLOR13",  0xdff19A, 2 }, /* Color table 13 */
+    { L"COLOR14",  0xdff19C, 2 }, /* Color table 14 */
+    { L"COLOR15",  0xdff19E, 2 }, /* Color table 15 */
+    { L"COLOR16",  0xdff1A0, 2 }, /* Color table 16 */
+    { L"COLOR17",  0xdff1A2, 2 }, /* Color table 17 */
+    { L"COLOR18",  0xdff1A4, 2 }, /* Color table 18 */
+    { L"COLOR19",  0xdff1A6, 2 }, /* Color table 19 */
+    { L"COLOR20",  0xdff1A8, 2 }, /* Color table 20 */
+    { L"COLOR21",  0xdff1AA, 2 }, /* Color table 21 */
+    { L"COLOR22",  0xdff1AC, 2 }, /* Color table 22 */
+    { L"COLOR23",  0xdff1AE, 2 }, /* Color table 23 */
+    { L"COLOR24",  0xdff1B0, 2 }, /* Color table 24 */
+    { L"COLOR25",  0xdff1B2, 2 }, /* Color table 25 */
+    { L"COLOR26",  0xdff1B4, 2 }, /* Color table 26 */
+    { L"COLOR27",  0xdff1B6, 2 }, /* Color table 27 */
+    { L"COLOR28",  0xdff1B8, 2 }, /* Color table 28 */
+    { L"COLOR29",  0xdff1BA, 2 }, /* Color table 29 */
+    { L"COLOR30",  0xdff1BC, 2 }, /* Color table 30 */
+    { L"COLOR31",  0xdff1BE, 2 }, /* Color table 31 */
+    { L"HTOTAL",   0xdff1C0, 2|4 }, /* Highest number count in horiz line (VARBEAMEN = 1) */
+    { L"HSSTOP",   0xdff1C2, 2|4 }, /* Horiz line pos for HSYNC stop */
+    { L"HBSTRT",   0xdff1C4, 2|4 }, /* Horiz line pos for HBLANK start */
+    { L"HBSTOP",   0xdff1C6, 2|4 }, /* Horiz line pos for HBLANK stop */
+    { L"VTOTAL",   0xdff1C8, 2|4 }, /* Highest numbered vertical line (VARBEAMEN = 1) */
+    { L"VSSTOP",   0xdff1CA, 2|4 }, /* Vert line for VBLANK start */
+    { L"VBSTRT",   0xdff1CC, 2|4 }, /* Vert line for VBLANK start */
+    { L"VBSTOP",   0xdff1CE, 2|4 }, /* Vert line for VBLANK stop */
 #if 0
-    { "SPRHSTRT", 0xdff1D0 }, /* UHRES sprite vertical start */
-    { "SPRHSTOP", 0xdff1D2 }, /* UHRES sprite vertical stop */
-    { "BPLHSTRT", 0xdff1D4 }, /* UHRES bit plane vertical stop */
-    { "BPLHSTOP", 0xdff1D6 }, /* UHRES bit plane vertical stop */
-    { "HHPOSW",   0xdff1D8 }, /* DUAL mode hires H beam counter write */
-    { "HHPOSR",   0xdff1DA }, /* DUAL mode hires H beam counter read */
+    { L"SPRHSTRT", 0xdff1D0 }, /* UHRES sprite vertical start */
+    { L"SPRHSTOP", 0xdff1D2 }, /* UHRES sprite vertical stop */
+    { L"BPLHSTRT", 0xdff1D4 }, /* UHRES bit plane vertical stop */
+    { L"BPLHSTOP", 0xdff1D6 }, /* UHRES bit plane vertical stop */
+    { L"HHPOSW",   0xdff1D8 }, /* DUAL mode hires H beam counter write */
+    { L"HHPOSR",   0xdff1DA }, /* DUAL mode hires H beam counter read */
 #endif
-    { "BEAMCON0", 0xdff1DC, 2|4 }, /* Beam counter control register (SHRES,UHRES,PAL) */
-    { "HSSTRT",   0xdff1DE, 2|4 }, /* Horizontal sync start (VARHSY) */
-    { "VSSTRT",   0xdff1E0, 2|4 }, /* Vertical sync start (VARVSY) */
-    { "HCENTER",  0xdff1E2, 2|4 }, /* Horizontal pos for vsync on interlace */
-    { "DIWHIGH",  0xdff1E4, 2|4 }, /* Display window upper bits for start/stop */
+    { L"BEAMCON0", 0xdff1DC, 2|4 }, /* Beam counter control register (SHRES,UHRES,PAL) */
+    { L"HSSTRT",   0xdff1DE, 2|4 }, /* Horizontal sync start (VARHSY) */
+    { L"VSSTRT",   0xdff1E0, 2|4 }, /* Vertical sync start (VARVSY) */
+    { L"HCENTER",  0xdff1E2, 2|4 }, /* Horizontal pos for vsync on interlace */
+    { L"DIWHIGH",  0xdff1E4, 2|4 }, /* Display window upper bits for start/stop */
 #if 0
-    { "BPLHMOD",  0xdff1E6 }, /* UHRES bit plane modulo */
-    { "SPRHPTH",  0xdff1E8 }, /* UHRES sprite pointer (high 5 bits) */
-    { "SPRHPTL",  0xdff1EA }, /* UHRES sprite pointer (low 15 bits) */
-    { "BPLHPTH",  0xdff1EC }, /* VRam (UHRES) bitplane pointer (hi 5 bits) */
-    { "BPLHPTL",  0xdff1EE }, /* VRam (UHRES) bitplane pointer (lo 15 bits) */
-    { "RESERVED", 0xdff1F0 }, /* Reserved (forever i guess!) */
-    { "RESERVED", 0xdff1F2 }, /* Reserved (forever i guess!) */
-    { "RESERVED", 0xdff1F4 }, /* Reserved (forever i guess!) */
-    { "RESERVED", 0xdff1F6 }, /* Reserved (forever i guess!) */
-    { "RESERVED", 0xdff1F8 }, /* Reserved (forever i guess!) */
-    { "RESERVED", 0xdff1Fa }, /* Reserved (forever i guess!) */
+    { L"BPLHMOD",  0xdff1E6 }, /* UHRES bit plane modulo */
+    { L"SPRHPTH",  0xdff1E8 }, /* UHRES sprite pointer (high 5 bits) */
+    { L"SPRHPTL",  0xdff1EA }, /* UHRES sprite pointer (low 15 bits) */
+    { L"BPLHPTH",  0xdff1EC }, /* VRam (UHRES) bitplane pointer (hi 5 bits) */
+    { L"BPLHPTL",  0xdff1EE }, /* VRam (UHRES) bitplane pointer (lo 15 bits) */
+    { L"RESERVED", 0xdff1F0 }, /* Reserved (forever i guess!) */
+    { L"RESERVED", 0xdff1F2 }, /* Reserved (forever i guess!) */
+    { L"RESERVED", 0xdff1F4 }, /* Reserved (forever i guess!) */
+    { L"RESERVED", 0xdff1F6 }, /* Reserved (forever i guess!) */
+    { L"RESERVED", 0xdff1F8 }, /* Reserved (forever i guess!) */
+    { L"RESERVED", 0xdff1Fa }, /* Reserved (forever i guess!) */
 #endif
-    { "FMODE",    0xdff1FC, 2|8 }, /* Fetch mode register */
-    { "NO-OP(NULL)", 0xdff1FE },   /*   Can also indicate last 2 or 3 refresh
+    { L"FMODE",    0xdff1FC, 2|8 }, /* Fetch mode register */
+    { L"NO-OP(NULL)", 0xdff1FE },   /*   Can also indicate last 2 or 3 refresh
                                            cycles or the restart of the COPPER after lockup.*/
     { NULL }
 };
index 718ec2fdefd9e59f6d6f7f4c4a8f303564e8f9da..ae59636665278707a8de88baa6990e82a191843c 100644 (file)
@@ -11,28 +11,28 @@ extern void a3000scsi_free (void);
 extern void a3000scsi_reset (void);
 extern void rethink_a2091 (void);
 
-extern void wdscsi_put(uae_u8);
-extern uae_u8 wdscsi_get(void);
-extern uae_u8 wdscsi_getauxstatus(void);
-extern void wdscsi_sasr(uae_u8);
+extern void wdscsi_put (uae_u8);
+extern uae_u8 wdscsi_get (void);
+extern uae_u8 wdscsi_getauxstatus (void);
+extern void wdscsi_sasr (uae_u8);
 
-extern void scsi_hsync(void);
+extern void scsi_hsync (void);
 
 extern uae_u8 wdregs[32];
 extern struct scsi_data *scsis[8];
 
-#define WD33C93 "WD33C93"
+#define WD33C93 L"WD33C93"
 #define SCSIID (scsis[wdregs[WD_DESTINATION_ID] & 7])
 
-extern int a2091_add_scsi_unit(int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys);
-extern int a3000_add_scsi_unit(int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys);
+extern int a2091_add_scsi_unit (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys);
+extern int a3000_add_scsi_unit (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys);
 
-extern int addscsi(int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys, int scsi_level);
+extern int addscsi (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys, int scsi_level);
 
 #endif
index 73697f3312156903258d710f36ca3b3d1b55b3d3..732a73489d62173f818b70a25973ef222594e8ad 100644 (file)
@@ -2,17 +2,17 @@
 #ifdef ARCADIA
 
 extern void arcadia_init (void);
-extern int is_arcadia_rom (char *path);
+extern int is_arcadia_rom (const TCHAR *path);
 extern int arcadia_map_banks (void);
 extern void arcadia_unmap (void);
 extern void arcadia_vsync (void);
 extern void arcadia_reset (void);
 extern uae_u8 arcadia_parport (int port, uae_u8 pra, uae_u8 dra);
-extern struct romdata *scan_arcadia_rom (char*, int);
+extern struct romdata *scan_arcadia_rom (TCHAR*, int);
 
 struct arcadiarom {
     int romid;
-    char *name, *rom;
+    TCHAR *name, *rom;
     int type, extra;
     int b7, b6, b5, b4, b3, b2, b1, b0;
 };
index df32f408e320496cb016a4e90a1a60363d752dd4..ffc8043212c50f9fd20d65186542755d4d63c97b 100644 (file)
@@ -13,13 +13,14 @@ extern uae_u32 addr (int);
 extern void db (uae_u8);
 extern void dw (uae_u16);
 extern void dl (uae_u32);
-extern uae_u32 ds (const char *);
+extern uae_u32 ds_ansi (const uae_char*);
+extern uae_u32 ds (const TCHAR*);
 extern void calltrap (uae_u32);
 extern void org (uae_u32);
 extern uae_u32 here (void);
 extern uaecptr makedatatable (uaecptr resid, uaecptr resname, uae_u8 type, uae_s8 priority, uae_u16 ver, uae_u16 rev);
 
-#define deftrap(f) define_trap((f), 0, "")
+#define deftrap(f) define_trap((f), 0, L"")
 #define deftrap2(f, mode, str) define_trap((f), (mode), (str))
 #define deftrapres(f, mode, str) define_trap((f), (mode | TRAPFLAG_UAERES), (str))
 
@@ -54,19 +55,19 @@ struct mountedinfo
     int nrcyls;
 };
 
-extern int add_filesys_unitconfig (struct uae_prefs *p, int index, char *error);
+extern int add_filesys_unitconfig (struct uae_prefs *p, int index, TCHAR *error);
 extern int get_filesys_unitconfig (struct uae_prefs *p, int index, struct mountedinfo*);
 extern int kill_filesys_unitconfig (struct uae_prefs *p, int nr);
 extern int move_filesys_unitconfig (struct uae_prefs *p, int nr, int to);
 
-int filesys_insert(int nr, char *volume, const char *rootdir, int readonly, int flags);
+int filesys_insert(int nr, TCHAR *volume, const TCHAR *rootdir, int readonly, int flags);
 int filesys_eject(int nr);
-int filesys_media_change (const char *rootdir, int inserted, struct uaedev_config_info *uci);
+int filesys_media_change (const TCHAR *rootdir, int inserted, struct uaedev_config_info *uci);
 
-extern char *filesys_createvolname (const char *volname, const char *rootdir, const char *def);
-extern int target_get_volume_name(struct uaedev_mount_info *mtinf, const char *volumepath, char *volumename, int size, int inserted, int fullcheck);
+extern TCHAR *filesys_createvolname (const TCHAR *volname, const TCHAR *rootdir, const TCHAR *def);
+extern int target_get_volume_name(struct uaedev_mount_info *mtinf, const TCHAR *volumepath, TCHAR *volumename, int size, int inserted, int fullcheck);
 
-extern int sprintf_filesys_unit (char *buffer, int num);
+extern int sprintf_filesys_unit (TCHAR *buffer, int num);
 
 extern void filesys_reset (void);
 extern void filesys_cleanup (void);
index 994ca54f75543c4db8883d4fdeb71e5bf2c58469..0c9c05fa429debb8cd1137ab94a1698b1cc61bbd 100644 (file)
@@ -40,7 +40,7 @@ struct device_info {
     int bytespersector;
     int bus, target, lun;
     int id;
-    char label[MAX_DPATH];
+    TCHAR label[MAX_DPATH];
 };
 
 struct device_scsi_info {
index f02145f65fab266bf7f035c4f3673cbe98056abe..6a223fe5aead5376ded724f9a28bc393ee216d98 100644 (file)
@@ -10,9 +10,9 @@
 //#define TRACING_ENABLED
 
 #ifdef TRACING_ENABLED
-#define TRACE(x) do { write_log x; } while(0)
+#define BSDTRACE(x) do { write_log x; } while(0)
 #else
-#define TRACE(x)
+#define BSDTRACE(x)
 #endif
 
 extern int init_socket_layer (void);
@@ -92,9 +92,9 @@ struct socketbase {
 #define LIBRARY_SIZEOF 36
 
 struct UAEBSDBase {
-    char dummy[LIBRARY_SIZEOF];
+    uae_u8 dummy[LIBRARY_SIZEOF];
     struct socketbase *sb;
-    char scratchbuf[SCRATCHBUFSIZE];
+    uae_u8 scratchbuf[SCRATCHBUFSIZE];
 };
 
 /* socket flags */
@@ -120,11 +120,10 @@ struct UAEBSDBase {
 #define SF_BLOCKING 0x80000000
 #define SF_BLOCKINGINPROGRESS 0x40000000
 
-extern uae_u32 addstr (uae_u32 *, const char *);
-extern uae_u32 addmem (uae_u32 *, const char *, int len);
-
-extern char *strncpyah (char *, uae_u32, int);
-extern uae_u32 strncpyha (uae_u32, const char *, int);
+uae_u32 addstr (uae_u32 * dst, const TCHAR *src);
+uae_u32 addstr_ansi (uae_u32 * dst, const uae_char *src);
+uae_u32 strncpyha (uae_u32 dst, const uae_char *src, int size);
+uae_u32 addmem (uae_u32 * dst, const uae_char *src, int len);
 
 #define SB struct socketbase *sb
 
index 694c0e1b5db1eba0cc6af981a1588dbb34e15140..b632d94a5c34f676f83137713d8e805eae326e2a 100644 (file)
@@ -13,14 +13,14 @@ extern void cdtv_exitgui (void);
 void cdtv_battram_write (int addr, int v);
 uae_u8 cdtv_battram_read (int addr);
 
-extern void cdtv_loadcardmem(uae_u8*, int);
-extern void cdtv_savecardmem(uae_u8*, int);
+extern void cdtv_loadcardmem (uae_u8*, int);
+extern void cdtv_savecardmem (uae_u8*, int);
 
-int cdtv_add_scsi_unit(int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys);
+int cdtv_add_scsi_unit (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys);
 
-extern void cdtv_getdmadata(uae_u32*);
+extern void cdtv_getdmadata (uae_u32*);
 
 extern void rethink_cdtv (void);
 extern void cdtv_scsi_int (void);
index 1216f869fbe524625606505acc066fe540e68852..6faca8eb58cf82986eaab7cbd7c3ac192fe758c7 100644 (file)
@@ -49,7 +49,7 @@
 static ALWAYS_INLINE bool test_ram_boundary (uaecptr addr, int size, bool super, bool write) { return false; }
 static ALWAYS_INLINE void flush_internals (void) { }
 
-typedef char flagtype;
+typedef uae_u8 flagtype;
 
 struct xttrx {
     uae_u32 log_addr_base : 8;
index f0576b6a888453016bf90e2f619ea1f2970a610f..0c8fbf7e585e1000f2a1000776fc0f63db01d609 100644 (file)
@@ -1,6 +1,6 @@
-extern uae_u32 get_crc32 (uae_u8 *p, int size);
-extern uae_u16 get_crc16 (uae_u8 *p, int size);
+extern uae_u32 get_crc32 (void *p, int size);
+extern uae_u16 get_crc16 (void *p, int size);
 extern uae_u32 get_crc32_val (uae_u8 v, uae_u32 crc);
-extern void get_sha1 (uae_u8 *p, int size, uae_u8 *out);
-extern char *get_sha1_txt (uae_u8 *p, int size);
+extern void get_sha1 (void *p, int size, void *out);
+extern const TCHAR *get_sha1_txt (void *p, int size);
 #define SHA1_SIZE 20
index 3479a964b689e9c45bd338255c5ea6dd99e21f05..6bcb36c726f5f262e9c18af0df75e77f8176a9ea 100644 (file)
@@ -24,7 +24,7 @@ extern void debugger_change(int mode);
 extern void activate_debugger(void);
 extern void deactivate_debugger (void);
 extern int notinrom (void);
-extern const char *debuginfo(int);
+extern const TCHAR *debuginfo (int);
 extern void record_copper (uaecptr addr, int hpos, int vpos);
 extern void record_copper_reset(void);
 extern int mmu_init(int,uaecptr,uaecptr);
@@ -32,9 +32,9 @@ extern void mmu_do_hit(void);
 extern void dump_aga_custom (void);
 extern void memory_map_dump (void);
 extern void debug_help (void);
-extern uaecptr dumpmem2 (uaecptr addr, char *out, int osize);
+extern uaecptr dumpmem2 (uaecptr addr, TCHAR *out, int osize);
 extern void update_debug_info (void);
-extern int instruction_breakpoint (char **c);
+extern int instruction_breakpoint (TCHAR **c);
 extern int debug_bankchange (int);
 
 #define BREAKPOINT_TOTAL 8
@@ -58,7 +58,7 @@ struct memwatch_node {
 };
 extern struct memwatch_node mwnodes[MEMWATCH_TOTAL];
 
-extern void memwatch_dump2 (char *buf, int bufsize, int num);
+extern void memwatch_dump2 (TCHAR *buf, int bufsize, int num);
 
 void debug_lgetpeek (uaecptr addr, uae_u32 v);
 void debug_wgetpeek (uaecptr addr, uae_u32 v);
@@ -68,7 +68,7 @@ void debug_wputpeek(uaecptr addr, uae_u32 v);
 void debug_lputpeek(uaecptr addr, uae_u32 v);
 
 enum debugtest_item { DEBUGTEST_BLITTER, DEBUGTEST_KEYBOARD, DEBUGTEST_FLOPPY, DEBUGTEST_MAX };
-void debugtest (enum debugtest_item, const char *, ...);
+void debugtest (enum debugtest_item, const TCHAR *, ...);
 
 #else
 
index 23fa2e4d0fb3c3d4717db823b12e0567427667f8..33cd61fd41b2f21166fa116bca63c262ddd28189 100644 (file)
@@ -14,22 +14,22 @@ extern void DISK_select (uae_u8 data);
 extern uae_u8 DISK_status (void);
 extern void disk_eject (int num);
 extern int disk_empty (int num);
-extern void disk_insert (int num, const char *name);
-extern void disk_insert_force (int num, const char *name);
+extern void disk_insert (int num, const TCHAR *name);
+extern void disk_insert_force (int num, const TCHAR *name);
 extern void DISK_check_change (void);
-extern struct zfile *DISK_validate_filename (const char *, int, int *, uae_u32 *);
+extern struct zfile *DISK_validate_filename (const TCHAR *, int, int *, uae_u32 *);
 extern void DISK_handler (uae_u32);
 extern void DISK_update (int hpos);
 extern void DISK_hsync (int hpos);
 extern void DISK_reset (void);
-extern int disk_getwriteprotect (const char *name);
-extern int disk_setwriteprotect (int num, const char *name, int protect);
-extern void disk_creatediskfile (char *name, int type, drive_type adftype, char *disk_name);
+extern int disk_getwriteprotect (const TCHAR *name);
+extern int disk_setwriteprotect (int num, const TCHAR *name, int protect);
+extern void disk_creatediskfile (TCHAR *name, int type, drive_type adftype, TCHAR *disk_name);
 extern void dumpdisk (void);
-extern int DISK_history_add (const char *name, int idx);
-extern char *DISK_history_get (int idx);
+extern int DISK_history_add (const TCHAR *name, int idx);
+extern TCHAR *DISK_history_get (int idx);
 int DISK_examine_image (struct uae_prefs *p, int num, uae_u32 *crc32);
-extern char *DISK_get_saveimagepath (const char *name);
+extern TCHAR *DISK_get_saveimagepath (const TCHAR *name);
 extern void DISK_reinsert (int num);
 
 extern void DSKLEN (uae_u16 v, int hpos);
index bfa4a2cae117c1ca2eb315890a62d04a24559b04..54f348c7d0504d2c5378113b6de904b220ea4842 100644 (file)
@@ -24,28 +24,28 @@ struct drvsample {
 #define DS_SNATCH 4
 #define DS_END 5
 
-extern void driveclick_click(int drive, int startOffset);
-extern void driveclick_motor(int drive, int running);
-extern void driveclick_insert(int drive, int eject);
-extern void driveclick_init(void);
-extern void driveclick_free(void);
-extern void driveclick_reset(void);
-extern void driveclick_mix(uae_s16*, int);
-extern int driveclick_loadresource(struct drvsample*, int);
+extern void driveclick_click (int drive, int startOffset);
+extern void driveclick_motor (int drive, int running);
+extern void driveclick_insert (int drive, int eject);
+extern void driveclick_init (void);
+extern void driveclick_free (void);
+extern void driveclick_reset (void);
+extern void driveclick_mix (uae_s16*, int);
+extern int driveclick_loadresource (struct drvsample*, int);
 extern void driveclick_check_prefs (void);
 extern uae_s16 *decodewav (uae_u8 *s, int *len);
 
 #define DS_BUILD_IN_SOUNDS 1
-#define DS_NAME_CLICK "drive_click_"
-#define DS_NAME_SPIN "drive_spin_"
-#define DS_NAME_SPIN_ND "drive_spinnd_"
-#define DS_NAME_START "drive_start_"
-#define DS_NAME_SNATCH "drive_snatch_"
+#define DS_NAME_CLICK L"drive_click_"
+#define DS_NAME_SPIN L"drive_spin_"
+#define DS_NAME_SPIN_ND L"drive_spinnd_"
+#define DS_NAME_START L"drive_start_"
+#define DS_NAME_SNATCH L"drive_snatch_"
 
-extern int driveclick_fdrawcmd_open(int);
-extern void driveclick_fdrawcmd_close(int);
-extern void driveclick_fdrawcmd_detect(void);
-extern void driveclick_fdrawcmd_seek(int, int);
-extern void driveclick_fdrawcmd_motor(int, int);
-extern void driveclick_fdrawcmd_vsync(void);
+extern int driveclick_fdrawcmd_open (int);
+extern void driveclick_fdrawcmd_close (int);
+extern void driveclick_fdrawcmd_detect (void);
+extern void driveclick_fdrawcmd_seek (int, int);
+extern void driveclick_fdrawcmd_motor (int, int);
+extern void driveclick_fdrawcmd_vsync (void);
 extern int driveclick_pcdrivemask, driveclick_pcdrivenum;
\ No newline at end of file
index 8c5ea5b777818172b225ab060784049abf0676ca..6734d585fec9eb5863df47c3a78ddf5f8add9bd2 100644 (file)
@@ -22,10 +22,10 @@ struct hardfiledata {
     uae_u8 *cache;
     int cache_valid;
     uae_u64 cache_offset;
-    char vendor_id[8 + 1];
-    char product_id[16 + 1];
-    char product_rev[4 + 1];
-    char device_name[256];
+    TCHAR vendor_id[8 + 1];
+    TCHAR product_id[16 + 1];
+    TCHAR product_rev[4 + 1];
+    TCHAR device_name[256];
     /* geometry from possible RDSK block */
     unsigned int cylinders;
     unsigned int sectors;
@@ -46,7 +46,7 @@ struct hardfiledata {
     uae_u64 vhd_footerblock;
 
     int drive_empty;
-    char *emptyname;
+    TCHAR *emptyname;
 };
 
 #define HFD_FLAGS_REALDRIVE 1
@@ -61,7 +61,7 @@ struct hd_hardfiledata {
     unsigned int cyls_def;
     unsigned int secspertrack_def;
     unsigned int heads_def;
-    char *path;
+    TCHAR *path;
     int ansi_version;
 };
 
@@ -92,27 +92,27 @@ extern struct uaedev_mount_info options_mountinfo;
 
 extern struct hardfiledata *get_hardfile_data (int nr);
 #define FILESYS_MAX_BLOCKSIZE 2048
-extern int hdf_open (struct hardfiledata *hfd, const char *name);
+extern int hdf_open (struct hardfiledata *hfd, const TCHAR *name);
 extern int hdf_dup (struct hardfiledata *dhfd, const struct hardfiledata *shfd);
 extern void hdf_close (struct hardfiledata *hfd);
 extern int hdf_read (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
 extern int hdf_write (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
 extern int hdf_getnumharddrives (void);
-extern char *hdf_getnameharddrive (int index, int flags, int *sectorsize);
-extern int isspecialdrive(const char *name);
-extern int get_native_path(uae_u32 lock, char *out);
+extern TCHAR *hdf_getnameharddrive (int index, int flags, int *sectorsize);
+extern int isspecialdrive(const TCHAR *name);
+extern int get_native_path(uae_u32 lock, TCHAR *out);
 extern void hardfile_do_disk_change (struct uaedev_config_info *uci, int insert);
 
 void hdf_hd_close(struct hd_hardfiledata *hfd);
-int hdf_hd_open(struct hd_hardfiledata *hfd, const char *path, int blocksize, int readonly,
-                      const char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, const char *filesys);
+int hdf_hd_open(struct hd_hardfiledata *hfd, const TCHAR *path, int blocksize, int readonly,
+                      const TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, const TCHAR *filesys);
 
 
-extern int vhd_create (const char *name, uae_u64 size);
+extern int vhd_create (const TCHAR *name, uae_u64 size);
 
 extern int hdf_init_target (void);
-extern int hdf_open_target (struct hardfiledata *hfd, const char *name);
+extern int hdf_open_target (struct hardfiledata *hfd, const TCHAR *name);
 extern int hdf_dup_target (struct hardfiledata *dhfd, const struct hardfiledata *shfd);
 extern void hdf_close_target (struct hardfiledata *hfd);
 extern int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len);
index aad08558c1257eb30f2ec7578f72f01fa00814b7..766ad23c373440edbbe7a049f84e6564ed6072d3 100644 (file)
@@ -8,7 +8,7 @@
   */
 
 #ifndef FSDB_FILE
-#define FSDB_FILE "_UAEFSDB.___"
+#define FSDB_FILE L"_UAEFSDB.___"
 #endif
 
 #ifndef FSDB_DIR_SEPARATOR
@@ -59,10 +59,10 @@ typedef struct a_inode_struct {
     struct a_inode_struct *child, *sibling;
     /* AmigaOS name, and host OS name.  The host OS name is a full path, the
      * AmigaOS name is relative to the parent.  */
-    char *aname;
-    char *nname;
+    TCHAR *aname;
+    TCHAR *nname;
     /* AmigaOS file comment, or NULL if file has none.  */
-    char *comment;
+    TCHAR *comment;
     /* AmigaOS protection bits.  */
     int amigaos_mode;
     /* Unique number for identification.  */
@@ -95,60 +95,60 @@ typedef struct a_inode_struct {
 #endif
 } a_inode;
 
-extern char *nname_begin (char *);
+extern TCHAR *nname_begin (TCHAR *);
 
-extern char *build_nname (const char *d, const char *n);
-extern char *build_aname (const char *d, const char *n);
+extern TCHAR *build_nname (const TCHAR *d, const TCHAR *n);
+extern TCHAR *build_aname (const TCHAR *d, const TCHAR *n);
 
 /* Filesystem-independent functions.  */
 extern void fsdb_clean_dir (a_inode *);
-extern char *fsdb_search_dir (const char *dirname, char *rel);
+extern TCHAR *fsdb_search_dir (const TCHAR *dirname, TCHAR *rel);
 extern void fsdb_dir_writeback (a_inode *);
-extern int fsdb_used_as_nname (a_inode *base, const char *);
-extern a_inode *fsdb_lookup_aino_aname (a_inode *base, const char *);
-extern a_inode *fsdb_lookup_aino_nname (a_inode *base, const char *);
-extern int fsdb_exists (char *nname);
+extern int fsdb_used_as_nname (a_inode *base, const TCHAR *);
+extern a_inode *fsdb_lookup_aino_aname (a_inode *base, const TCHAR *);
+extern a_inode *fsdb_lookup_aino_nname (a_inode *base, const TCHAR *);
+extern int fsdb_exists (TCHAR *nname);
 
-STATIC_INLINE int same_aname (const char *an1, const char *an2)
+STATIC_INLINE int same_aname (const TCHAR *an1, const TCHAR *an2)
 {
     return strcasecmp (an1, an2) == 0;
 }
 
 /* Filesystem-dependent functions.  */
-extern int fsdb_name_invalid (const char *n);
+extern int fsdb_name_invalid (const TCHAR *n);
 extern int fsdb_fill_file_attrs (a_inode *, a_inode *);
 extern int fsdb_set_file_attrs (a_inode *);
 extern int fsdb_mode_representable_p (const a_inode *, int);
 extern int fsdb_mode_supported (const a_inode *);
-extern char *fsdb_create_unique_nname (a_inode *base, const char *);
+extern TCHAR *fsdb_create_unique_nname (a_inode *base, const TCHAR *);
 
-extern void *my_opendir (const char*);
+extern void *my_opendir (const TCHAR*);
 extern void my_closedir (void*);
-extern int my_readdir (void*, char*);
+extern int my_readdir (void*, TCHAR*);
 
-extern int my_rmdir (const char*);
-extern int my_mkdir (const char*);
-extern int my_unlink (const char*);
-extern int my_rename (const char*, const char*);
+extern int my_rmdir (const TCHAR*);
+extern int my_mkdir (const TCHAR*);
+extern int my_unlink (const TCHAR*);
+extern int my_rename (const TCHAR*, const TCHAR*);
 
-extern void *my_open (const char*, int);
+extern void *my_open (const TCHAR*, int);
 extern void my_close (void*);
-extern unsigned int my_lseek (void*, unsigned int, int);
+extern uae_s64 my_lseek (void*, uae_s64, int);
 extern unsigned int my_read (void*, void*, unsigned int);
 extern unsigned int my_write (void*, void*, unsigned int);
-extern int my_truncate (const char *name, long int len);
+extern int my_truncate (const TCHAR *name, uae_u64 len);
 extern int dos_errno (void);
-extern int my_existsfile (const char *name);
-extern int my_existsdir (const char *name);
+extern int my_existsfile (const TCHAR *name);
+extern int my_existsdir (const TCHAR *name);
 
-extern char *custom_fsdb_search_dir (const char *dirname, char *rel);
-extern a_inode *custom_fsdb_lookup_aino_aname (a_inode *base, const char *aname);
-extern a_inode *custom_fsdb_lookup_aino_nname (a_inode *base, const char *nname);
-extern int custom_fsdb_used_as_nname (a_inode *base, const char *nname);
+extern char *custom_fsdb_search_dir (const char *dirname, TCHAR *rel);
+extern a_inode *custom_fsdb_lookup_aino_aname (a_inode *base, const TCHAR *aname);
+extern a_inode *custom_fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname);
+extern int custom_fsdb_used_as_nname (a_inode *base, const TCHAR *nname);
 
 #define MYVOLUMEINFO_READONLY 1
 #define MYVOLUMEINFO_STREAMS 2
 #define MYVOLUMEINFO_ARCHIVE 4
 #define MYVOLUMEINFO_REUSABLE 8
 
-extern int my_getvolumeinfo (const char *root);
+extern int my_getvolumeinfo (const TCHAR *root);
index fafbb58332da08ed1068e02dc60a757fad5ecb78..695aeb8c74a7bbd6967080ba3a3da44b720180e2 100644 (file)
@@ -1,12 +1,12 @@
 
-extern void gayle_reset(int);
-extern void gayle_hsync(void);
-extern int gayle_add_ide_unit(int ch, char *path, int blocksize, int readonly,
-                      char *devname, int sectors, int surfaces, int reserved,
-                      int bootpri, char *filesys);
-extern int gayle_modify_pcmcia_sram_unit(const char *path, int readonly, int insert);
-extern int gayle_add_pcmcia_sram_unit(const char *path, int readonly);
-extern void gayle_free_units(void);
+extern void gayle_reset (int);
+extern void gayle_hsync (void);
+extern int gayle_add_ide_unit (int ch, TCHAR *path, int blocksize, int readonly,
+                      TCHAR *devname, int sectors, int surfaces, int reserved,
+                      int bootpri, TCHAR *filesys);
+extern int gayle_modify_pcmcia_sram_unit (const TCHAR *path, int readonly, int insert);
+extern int gayle_add_pcmcia_sram_unit (const TCHAR *path, int readonly);
+extern void gayle_free_units (void);
 extern void rethink_gayle (void);
 extern void gayle_map_pcmcia (void);
 
index c49930c063f25e8225838638b7f78539caa60220..b2a541bd54f90a3363cf48b0932e76e1f1507539 100644 (file)
@@ -63,7 +63,7 @@ extern void hq4x_32(unsigned char*, unsigned char*, DWORD, DWORD, DWORD);
 struct uae_filter
 {
     int type, yuv, intmul;
-    char *name, *cfgname;
+    TCHAR *name, *cfgname;
     int x[6];
 };
 
index 512960f1075a03505f6d424ce50ebed7e82c68d8..bf9c454d42ff2cde3b125f2bf140a99c0035cc56 100644 (file)
@@ -11,14 +11,14 @@ extern int gui_update (void);
 extern void gui_exit (void);
 extern void gui_led (int, int);
 extern void gui_handle_events (void);
-extern void gui_filename (int, const char *);
+extern void gui_filename (int, const TCHAR *);
 extern void gui_fps (int fps, int idle);
 extern void gui_changesettings (void);
 extern void gui_lock (void);
 extern void gui_unlock (void);
 extern void gui_hd_led (int, int);
 extern void gui_cd_led (int, int);
-extern void gui_disk_image_change (int, const char *);
+extern void gui_disk_image_change (int, const TCHAR *);
 extern unsigned int gui_ledstate;
 extern void gui_display (int shortcut);
 
@@ -37,7 +37,7 @@ struct gui_info
     uae_u8 cd;                     /* CD */
     int fps, idle;
     int sndbuf, sndbuf_status;
-    char df[4][256];               /* inserted image */
+    TCHAR df[4][256];              /* inserted image */
     uae_u32 crc32[4];              /* crc32 of image */
 };
 #define NUM_LEDS (1 + 1 + 1 + 1 + 1 + 1 + 4)
@@ -48,8 +48,8 @@ extern struct gui_info gui_data;
 extern void gui_update_gfx (void);
 
 void notify_user (int msg);
-void notify_user_parms (int msg, const char *parms, ...);
-int translate_message (int msg, char *out);
+void notify_user_parms (int msg, const TCHAR *parms, ...);
+int translate_message (int msg, TCHAR *out);
 typedef enum {
     NUMSG_NEEDEXT2, NUMSG_NOROM, NUMSG_NOROMKEY,
     NUMSG_KSROMCRCERROR, NUMSG_KSROMREADERROR, NUMSG_NOEXTROM,
index 43d7369658625dae1b55248fb344dd0ae8667a60..27103a5e9506457db15f294acb4f8fd950d43ebb 100644 (file)
@@ -7,13 +7,13 @@
 
 struct mem_labels
 {
-    const char *name;
+    const TCHAR *name;
     uae_u32 adr;
 };
 
 struct customData
 {
-    const char *name;
+    const TCHAR *name;
     uae_u32 adr;
     uae_u8 rw, special;
 };
index 355904b03737b4e0935eb794cffbdf9634e02301..dd52e48e0a3e6aea9b9a8b392026cecc323ce5c2 100644 (file)
@@ -19,10 +19,10 @@ struct inputdevice_functions {
     void (*unacquire)(int);
     void (*read)(void);
     int (*get_num)(void);
-    char* (*get_friendlyname)(int);
-    char* (*get_uniquename)(int);
+    TCHAR* (*get_friendlyname)(int);
+    TCHAR* (*get_uniquename)(int);
     int (*get_widget_num)(int);
-    int (*get_widget_type)(int,int,char*,uae_u32*);
+    int (*get_widget_type)(int,int,TCHAR*,uae_u32*);
     int (*get_widget_first)(int,int);
     int (*get_flags)(int);
 };
@@ -50,22 +50,22 @@ struct uae_input_device_kbr_default {
 #define ID_AXIS_OFFSET 32
 #define ID_AXIS_TOTAL 32
 
-extern int inputdevice_iterate (int devnum, int num, char *name, int *af);
-extern int inputdevice_set_mapping (int devnum, int num, char *name, char *custom, int af, int sub);
-extern int inputdevice_get_mapped_name (int devnum, int num, int *pflags, char *name, char *custom, int sub);
+extern int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af);
+extern int inputdevice_set_mapping (int devnum, int num, TCHAR *name, TCHAR *custom, int af, int sub);
+extern int inputdevice_get_mapped_name (int devnum, int num, int *pflags, TCHAR *name, TCHAR *custom, int sub);
 extern void inputdevice_copyconfig (const struct uae_prefs *src, struct uae_prefs *dst);
 extern void inputdevice_copy_single_config (struct uae_prefs *p, int src, int dst, int devnum);
 extern void inputdevice_swap_ports (struct uae_prefs *p, int devnum);
 extern void inputdevice_config_change (void);
 extern int inputdevice_config_change_test (void);
 extern int inputdevice_get_device_index (int devnum);
-extern char *inputdevice_get_device_name (int type, int devnum);
-extern char *inputdevice_get_device_unique_name (int type, int devnum);
+extern TCHAR *inputdevice_get_device_name (int type, int devnum);
+extern TCHAR *inputdevice_get_device_unique_name (int type, int devnum);
 extern int inputdevice_get_device_status (int devnum);
 extern void inputdevice_set_device_status (int devnum, int enabled);
 extern int inputdevice_get_device_total (int type);
 extern int inputdevice_get_widget_num (int devnum);
-extern int inputdevice_get_widget_type (int devnum, int num, char *name);
+extern int inputdevice_get_widget_type (int devnum, int num, TCHAR *name);
 
 extern int input_get_default_mouse (struct uae_input_device *uid, int num, int port);
 extern int input_get_default_joystick (struct uae_input_device *uid, int num, int port);
@@ -126,9 +126,9 @@ extern void inputdevice_hsync (void);
 extern void inputdevice_reset (void);
 
 extern void write_inputdevice_config (struct uae_prefs *p, struct zfile *f);
-extern void read_inputdevice_config (struct uae_prefs *p, char *option, char *value);
+extern void read_inputdevice_config (struct uae_prefs *p, TCHAR *option, TCHAR *value);
 extern void reset_inputdevice_config (struct uae_prefs *pr);
-extern int inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, int type);
+extern int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum, int type);
 extern int inputdevice_getjoyportdevice (int jport);
 
 extern void inputdevice_init (void);
@@ -173,7 +173,7 @@ extern int jsem_ismouse (int port, const struct uae_prefs *p);
 extern int jsem_iskbdjoy (int port, const struct uae_prefs *p);
 extern void do_fake_joystick (int nr, int *fake);
 
-extern int inputdevice_uaelib (char *, char *);
+extern int inputdevice_uaelib (TCHAR *, TCHAR *);
 
 #define INPREC_JOYPORT 1
 #define INPREC_JOYBUTTON 2
@@ -185,20 +185,20 @@ extern int inputdevice_uaelib (char *, char *);
 #define INPREC_END 0xff
 
 extern int input_recording;
-extern void inprec_close(void);
-extern int inprec_open(char*, int);
-extern void inprec_rend(void);
-extern void inprec_rstart(uae_u8);
-extern void inprec_ru8(uae_u8);
-extern void inprec_ru16(uae_u16);
-extern void inprec_ru32(uae_u32);
-extern void inprec_rstr(const char*);
-extern int inprec_pstart(uae_u8);
-extern void inprec_pend(void);
-extern uae_u8 inprec_pu8(void);
-extern uae_u16 inprec_pu16(void);
-extern uae_u32 inprec_pu32(void);
-extern int inprec_pstr(char*);
-
-extern int inputdevice_testread (char *name);
+extern void inprec_close (void);
+extern int inprec_open (TCHAR*, int);
+extern void inprec_rend (void);
+extern void inprec_rstart (uae_u8);
+extern void inprec_ru8 (uae_u8);
+extern void inprec_ru16 (uae_u16);
+extern void inprec_ru32 (uae_u32);
+extern void inprec_rstr (const TCHAR*);
+extern int inprec_pstart (uae_u8);
+extern void inprec_pend (void);
+extern uae_u8 inprec_pu8 (void);
+extern uae_u16 inprec_pu16 (void);
+extern uae_u32 inprec_pu32 (void);
+extern int inprec_pstr (TCHAR*);
+
+extern int inputdevice_testread (TCHAR *name);
 extern int inputdevice_istest (void);
index 6ce5bc648671a64f69ef4b560ec40ae8b5b00d30..46cb79b08392788dd37f80b023857473e9f65f94 100644 (file)
@@ -35,7 +35,7 @@ typedef void (REGPARAM3 *mem_put_func)(uaecptr, uae_u32) REGPARAM;
 typedef uae_u8 *(REGPARAM3 *xlate_func)(uaecptr) REGPARAM;
 typedef int (REGPARAM3 *check_func)(uaecptr, uae_u32) REGPARAM;
 
-extern char *address_space, *good_address_map;
+extern uae_u8 *address_space, *good_address_map;
 extern uae_u8 *chipmemory;
 
 extern uae_u32 allocated_chipmem;
@@ -90,7 +90,7 @@ typedef struct {
        ourselves. This holds the memory address where the start of memory is
        for this particular bank. */
     uae_u8 *baseaddr;
-    char *name;
+    TCHAR *name;
     /* for instruction opcode/operand fetches */
     mem_get_func lgeti, wgeti;
     int flags;
@@ -275,15 +275,15 @@ STATIC_INLINE void put_pointer (uaecptr addr, void *v)
 
 STATIC_INLINE uae_u8 *get_real_address (uaecptr addr)
 {
-    return get_mem_bank(addr).xlateaddr(addr);
+    return get_mem_bank (addr).xlateaddr(addr);
 }
 
-STATIC_INLINE int valid_address(uaecptr addr, uae_u32 size)
+STATIC_INLINE int valid_address (uaecptr addr, uae_u32 size)
 {
-    return get_mem_bank(addr).check(addr, size);
+    return get_mem_bank (addr).check(addr, size);
 }
 
-extern int addr_valid(char*,uaecptr,uae_u32);
+extern int addr_valid (TCHAR*, uaecptr,uae_u32);
 
 /* For faster access in custom chip emulation.  */
 extern uae_u32 REGPARAM3 chipmem_lget (uaecptr) REGPARAM;
@@ -327,12 +327,12 @@ extern shmpiece *shm_start;
 
 #endif
 
-extern uae_u8 *mapped_malloc (size_t, const char *);
+extern uae_u8 *mapped_malloc (size_t, const TCHAR*);
 extern void mapped_free (uae_u8 *);
 extern void clearexec (void);
 extern void mapkick (void);
 extern int decode_cloanto_rom_do (uae_u8 *mem, int size, int real_size);
-extern void a3000_fakekick(int);
+extern void a3000_fakekick (int);
 
 #define ROMTYPE_KICK       0x000001
 #define ROMTYPE_KICKCD32    0x000002
@@ -359,15 +359,15 @@ extern void a3000_fakekick(int);
 #define ROMTYPE_SCRAMBLED   0x400000
 
 struct romheader {
-    char *name;
+    TCHAR *name;
     int id;
 };
 
 struct romdata {
-    char *name;
+    TCHAR *name;
     int ver, rev;
     int subver, subrev;
-    char *model;
+    TCHAR *model;
     uae_u32 size;
     int id;
     int cpu;
@@ -375,46 +375,46 @@ struct romdata {
     int type;
     int group;
     int title;
-    char *partnumber;
+    TCHAR *partnumber;
     uae_u32 crc32;
     uae_u32 sha1[5];
-    char *configname;
+    TCHAR *configname;
 };
 
 struct romlist {
-    char *path;
+    TCHAR *path;
     struct romdata *rd;
 };
 
-extern struct romdata *getromdatabypath(char *path);
+extern struct romdata *getromdatabypath (TCHAR *path);
 extern struct romdata *getromdatabycrc (uae_u32 crc32);
 extern struct romdata *getromdatabydata (uae_u8 *rom, int size);
 extern struct romdata *getromdatabyid (int id);
 extern struct romdata *getromdatabyidgroup (int id, int group, int subitem);
 extern struct romdata *getromdatabyzfile (struct zfile *f);
 extern struct romlist **getarcadiaroms (void);
-extern struct romdata *getarcadiarombyname (char *name);
-extern struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, char *model, int all);
-extern void getromname (struct romdata*, char*);
-extern struct romdata *getromdatabyname (char*);
-extern struct romlist *getromlistbyids(int *ids);
+extern struct romdata *getarcadiarombyname (TCHAR *name);
+extern struct romlist **getromlistbyident (int ver, int rev, int subver, int subrev, TCHAR *model, int all);
+extern void getromname (struct romdata*, TCHAR*);
+extern struct romdata *getromdatabyname (TCHAR*);
+extern struct romlist *getromlistbyids (int *ids);
 extern void romwarning(int *ids);
-extern struct romlist *getromlistbyromdata(struct romdata *rd);
-extern void romlist_add (char *path, struct romdata *rd);
-extern char *romlist_get (struct romdata *rd);
+extern struct romlist *getromlistbyromdata (struct romdata *rd);
+extern void romlist_add (TCHAR *path, struct romdata *rd);
+extern TCHAR *romlist_get (struct romdata *rd);
 extern void romlist_clear (void);
 extern struct zfile *read_rom (struct romdata **rd);
-extern struct zfile *read_rom_name (const char *filename);
+extern struct zfile *read_rom_name (const TCHAR *filename);
 
-extern int load_keyring (struct uae_prefs *p, char *path);
-extern uae_u8 *target_load_keyfile (struct uae_prefs *p, char *path, int *size, char *name);
+extern int load_keyring (struct uae_prefs *p, TCHAR *path);
+extern uae_u8 *target_load_keyfile (struct uae_prefs *p, TCHAR *path, int *size, TCHAR *name);
 extern void free_keyring (void);
 extern int get_keyring (void);
 
-uaecptr strcpyha_safe (uaecptr dst, const char *src);
-extern char *strcpyah_safe (char *dst, uaecptr src, int maxsize);
-void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size);
-void memcpyha (uaecptr dst, const uae_u8 *src, int size);
-void memcpyah_safe (uae_u8 *dst, uaecptr src, int size);
-void memcpyah (uae_u8 *dst, uaecptr src, int size);
+extern uaecptr strcpyha_safe (uaecptr dst, const uae_char *src);
+extern uae_char *strcpyah_safe (uae_u8 *dst, uaecptr src, int maxsize);
+extern void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size);
+extern void memcpyha (uaecptr dst, const uae_u8 *src, int size);
+extern void memcpyah_safe (uae_u8 *dst, uaecptr src, int size);
+extern void memcpyah (uae_u8 *dst, uaecptr src, int size);
 
index ce42ad1c2e5cac4998980db10cd77b7e262e1f59..e9429e09b697acf6be89e11722b736368e1830c9 100644 (file)
@@ -69,7 +69,7 @@ struct comptbl {
 
 extern unsigned long REGPARAM3 op_illg (uae_u32, struct regstruct *regs) REGPARAM;
 
-typedef char flagtype;
+typedef uae_u8 flagtype;
 
 #ifdef FPUEMU
 /* You can set this to long double to be more accurate. However, the
@@ -170,13 +170,13 @@ STATIC_INLINE void m68k_setpc (struct regstruct *regs, uaecptr newpc)
 
 STATIC_INLINE uaecptr m68k_getpc (struct regstruct *regs)
 {
-    return (uaecptr)(regs->pc + ((char *)regs->pc_p - (char *)regs->pc_oldp));
+    return (uaecptr)(regs->pc + ((uae_u8*)regs->pc_p - (uae_u8*)regs->pc_oldp));
 }
 #define M68K_GETPC m68k_getpc(&regs)
 
 STATIC_INLINE uaecptr m68k_getpc_p (struct regstruct *regs, uae_u8 *p)
 {
-    return (uaecptr)(regs->pc + ((char *)p - (char *)regs->pc_oldp));
+    return (uaecptr)(regs->pc + ((uae_u8*)p - (uae_u8*)regs->pc_oldp));
 }
 
 #define m68k_incpc(regs, o) ((regs)->pc_p += (o))
@@ -281,7 +281,7 @@ extern uae_u32 REGPARAM3 get_disp_ea_020i (struct regstruct *regs, uae_u32 base,
 extern uae_u32 REGPARAM3 get_disp_ea_000 (struct regstruct *regs, uae_u32 base, uae_u32 dp) REGPARAM;
 extern void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr);
 extern void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt);
-extern void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode);
+extern void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode);
 extern int get_cpu_model(void);
 
 extern void REGPARAM3 MakeSR (struct regstruct *regs) REGPARAM;
@@ -300,7 +300,7 @@ extern void init_m68k_full (void);
 extern void m68k_go (int);
 extern void m68k_dumpstate (void *, uaecptr *);
 extern void m68k_disasm (void *, uaecptr, uaecptr *, int);
-extern void sm68k_disasm(char *, char *, uaecptr addr, uaecptr *nextpc);
+extern void sm68k_disasm (TCHAR*, TCHAR*, uaecptr addr, uaecptr *nextpc);
 extern void m68k_reset (int);
 extern int getDivu68kCycles(uae_u32 dividend, uae_u16 divisor);
 extern int getDivs68kCycles(uae_s32 dividend, uae_s16 divisor);
@@ -360,6 +360,6 @@ extern uae_u32 val_move2c (int regno);
 extern void val_move2c2 (int regno, uae_u32 val);
 struct cpum2c {
     int regno;
-    char *regname;
+    TCHAR *regname;
 };
 extern struct cpum2c m2cregs[];
index 0ad43f09c7362029836c918d09d9003f073c19f3..4c99af7e0819f250e5894af9c188f99091916070 100644 (file)
@@ -17,7 +17,7 @@ extern long int version;
 
 struct strlist {
     struct strlist *next;
-    char *option, *value;
+    TCHAR *option, *value;
     int unknown;
 };
 
@@ -31,10 +31,10 @@ struct strlist {
 #define MAX_INPUT_SIMULTANEOUS_KEYS 4
 
 struct uae_input_device {
-    char *name;
-    char *configname;
+    TCHAR *name;
+    TCHAR *configname;
     uae_s16 eventid[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT];
-    char *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT];
+    TCHAR *custom[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT];
     uae_u16 flags[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SUB_EVENT];
     uae_s16 extra[MAX_INPUT_DEVICE_EVENTS][MAX_INPUT_SIMULTANEOUS_KEYS];
     uae_u8 enabled;
@@ -43,8 +43,8 @@ struct uae_input_device {
 #define MAX_JPORTNAME 128
 struct jport {
     int id;
-    char name[MAX_JPORTNAME];
-    char configname[MAX_JPORTNAME];
+    TCHAR name[MAX_JPORTNAME];
+    TCHAR configname[MAX_JPORTNAME];
 };
 
 #define MAX_SPARE_DRIVES 20
@@ -65,15 +65,15 @@ struct wh {
 
 #define MOUNT_CONFIG_SIZE 30
 struct uaedev_config_info {
-    char devname[MAX_DPATH];
-    char volname[MAX_DPATH];
-    char rootdir[MAX_DPATH];
+    TCHAR devname[MAX_DPATH];
+    TCHAR volname[MAX_DPATH];
+    TCHAR rootdir[MAX_DPATH];
     int ishdf;
     int readonly;
     int bootpri;
     int autoboot;
     int donotmount;
-    char filesys[MAX_DPATH];
+    TCHAR filesys[MAX_DPATH];
     int surfaces;
     int sectors;
     int reserved;
@@ -89,11 +89,11 @@ struct uae_prefs {
 
     struct strlist *all_lines;
 
-    char description[256];
-    char info[256];
+    TCHAR description[256];
+    TCHAR info[256];
     int config_version;
-    char config_hardware_path[MAX_DPATH];
-    char config_host_path[MAX_DPATH];
+    TCHAR config_hardware_path[MAX_DPATH];
+    TCHAR config_host_path[MAX_DPATH];
 
     int illegal_mem;
     int no_xhair;
@@ -105,7 +105,7 @@ struct uae_prefs {
     int parallel_postscript_emulation;
     int parallel_postscript_detection;
     int parallel_autoflush_time;
-    char ghostscript_parameters[256];
+    TCHAR ghostscript_parameters[256];
     int use_gfxlib;
     int socket_emu;
 
@@ -153,7 +153,7 @@ struct uae_prefs {
     uae_u32 override_dga_address;
 
     int gfx_display;
-    char gfx_display_name[256];
+    TCHAR gfx_display_name[256];
     int gfx_framerate, gfx_autoframerate;
     struct wh gfx_size_win;
     struct wh gfx_size_fs;
@@ -177,7 +177,7 @@ struct uae_prefs {
     int color_mode;
 
     int gfx_filter;
-    char gfx_filtershader[MAX_DPATH];
+    TCHAR gfx_filtershader[MAX_DPATH];
     int gfx_filter_scanlines;
     int gfx_filter_scanlineratio;
     int gfx_filter_scanlinelevel;
@@ -241,24 +241,24 @@ struct uae_prefs {
     int cs_denisenoehb;
     int cs_agnusbltbusybug;
 
-    char df[4][MAX_DPATH];
-    char dfxlist[MAX_SPARE_DRIVES][MAX_DPATH];
-    char romfile[MAX_DPATH];
-    char romident[256];
-    char romextfile[MAX_DPATH];
-    char romextident[256];
-    char flashfile[MAX_DPATH];
-    char cartfile[MAX_DPATH];
-    char cartident[256];
+    TCHAR df[4][MAX_DPATH];
+    TCHAR dfxlist[MAX_SPARE_DRIVES][MAX_DPATH];
+    TCHAR romfile[MAX_DPATH];
+    TCHAR romident[256];
+    TCHAR romextfile[MAX_DPATH];
+    TCHAR romextident[256];
+    TCHAR flashfile[MAX_DPATH];
+    TCHAR cartfile[MAX_DPATH];
+    TCHAR cartident[256];
     int cart_internal;
-    char pci_devices[256];
-    char prtname[256];
-    char sername[256];
-    char amaxromfile[MAX_DPATH];
+    TCHAR pci_devices[256];
+    TCHAR prtname[256];
+    TCHAR sername[256];
+    TCHAR amaxromfile[MAX_DPATH];
 
-    char path_floppy[256];
-    char path_hardfile[256];
-    char path_rom[256];
+    TCHAR path_floppy[256];
+    TCHAR path_hardfile[256];
+    TCHAR path_rom[256];
 
     int m68k_speed;
     int cpu_model;
@@ -294,7 +294,7 @@ struct uae_prefs {
     int nr_floppies;
     int dfxtype[4];
     int dfxclick[4];
-    char dfxclickexternal[4][256];
+    TCHAR dfxclickexternal[4][256];
     int dfxclickvolume;
 
     /* Target specific options */
@@ -338,6 +338,7 @@ struct uae_prefs {
     int win32_specialkey;
     int win32_guikey;
     int win32_kbledmode;
+    int win32_fscodepage;
 
     int curses_reverse_video;
 
@@ -346,7 +347,7 @@ struct uae_prefs {
 
     /* input */
 
-    char inputname[256];
+    TCHAR inputname[256];
     struct jport jports[2];
     int input_selected_setting;
     int input_joymouse_multiplier;
@@ -366,50 +367,50 @@ struct uae_prefs {
 };
 
 /* Contains the filename of .uaerc */
-extern char optionsfile[];
+extern TCHAR optionsfile[];
 extern void save_options (struct zfile *, struct uae_prefs *, int);
-extern void cfgfile_write (struct zfile *, char *format,...);
-extern void cfgfile_dwrite (struct zfile *, char *format,...);
-extern void cfgfile_target_write (struct zfile *, char *format,...);
-extern void cfgfile_target_dwrite (struct zfile *, char *format,...);
-extern void cfgfile_backup (const char *path);
+extern void cfgfile_write (struct zfile *, TCHAR *format,...);
+extern void cfgfile_dwrite (struct zfile *, TCHAR *format,...);
+extern void cfgfile_target_write (struct zfile *, TCHAR *format,...);
+extern void cfgfile_target_dwrite (struct zfile *, TCHAR *format,...);
+extern void cfgfile_backup (const TCHAR *path);
 extern struct uaedev_config_info *add_filesys_config (struct uae_prefs *p, int index,
-                       char *devname, char *volname, char *rootdir, int readonly,
+                       TCHAR *devname, TCHAR *volname, TCHAR *rootdir, int readonly,
                        int secspertrack, int surfaces, int reserved,
-                       int blocksize, int bootpri, char *filesysdir, int hdc, int flags);
+                       int blocksize, int bootpri, TCHAR *filesysdir, int hdc, int flags);
 
 extern void default_prefs (struct uae_prefs *, int);
 extern void discard_prefs (struct uae_prefs *, int);
 
-int parse_cmdline_option (struct uae_prefs *, char, char *);
+int parse_cmdline_option (struct uae_prefs *, TCHAR, const TCHAR *);
 
-extern int cfgfile_yesno (const char *option, const char *value, const char *name, int *location);
-extern int cfgfile_intval (const char *option, const char *value, const char *name, int *location, int scale);
-extern int cfgfile_strval (const char *option, const char *value, const char *name, int *location, const char *table[], int more);
-extern int cfgfile_string (const char *option, const char *value, const char *name, char *location, int maxsz);
-extern char *cfgfile_subst_path (const char *path, const char *subst, const char *file);
+extern int cfgfile_yesno (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location);
+extern int cfgfile_intval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, int scale);
+extern int cfgfile_strval (const TCHAR *option, const TCHAR *value, const TCHAR *name, int *location, const TCHAR *table[], int more);
+extern int cfgfile_string (const TCHAR *option, const TCHAR *value, const TCHAR *name, TCHAR *location, int maxsz);
+extern TCHAR *cfgfile_subst_path (const TCHAR *path, const TCHAR *subst, const TCHAR *file);
 
-extern int target_parse_option (struct uae_prefs *, char *option, char *value);
+extern int target_parse_option (struct uae_prefs *, TCHAR *option, TCHAR *value);
 extern void target_save_options (struct zfile*, struct uae_prefs *);
 extern void target_default_options (struct uae_prefs *, int type);
 extern void target_fixup_options (struct uae_prefs *);
-extern int target_cfgfile_load (struct uae_prefs *, char *filename, int type, int isdefault);
+extern int target_cfgfile_load (struct uae_prefs *, TCHAR *filename, int type, int isdefault);
 extern void target_quit (void);
 extern void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type);
 
-extern int cfgfile_load (struct uae_prefs *p, const char *filename, int *type, int ignorelink);
-extern int cfgfile_save (struct uae_prefs *p, const char *filename, int);
-extern void cfgfile_parse_line (struct uae_prefs *p, char *, int);
-extern int cfgfile_parse_option (struct uae_prefs *p, char *option, char *value, int);
-extern int cfgfile_get_description (const char *filename, char *description, char *hostlink, char *hardwarelink, int *type);
+extern int cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int *type, int ignorelink);
+extern int cfgfile_save (struct uae_prefs *p, const TCHAR *filename, int);
+extern void cfgfile_parse_line (struct uae_prefs *p, TCHAR *, int);
+extern int cfgfile_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value, int);
+extern int cfgfile_get_description (const TCHAR *filename, TCHAR *description, TCHAR *hostlink, TCHAR *hardwarelink, int *type);
 extern void cfgfile_show_usage (void);
 extern uae_u32 cfgfile_uaelib (int mode, uae_u32 name, uae_u32 dst, uae_u32 maxlen);
 extern uae_u32 cfgfile_uaelib_modify (uae_u32 mode, uae_u32 parms, uae_u32 size, uae_u32 out, uae_u32 outsize);
-extern uae_u32 cfgfile_modify (uae_u32 index, char *parms, uae_u32 size, char *out, uae_u32 outsize);
-extern void cfgfile_addcfgparam (char *);
+extern uae_u32 cfgfile_modify (uae_u32 index, TCHAR *parms, uae_u32 size, TCHAR *out, uae_u32 outsize);
+extern void cfgfile_addcfgparam (TCHAR *);
 extern int built_in_prefs (struct uae_prefs *p, int model, int config, int compa, int romcheck);
 extern int built_in_chipset_prefs (struct uae_prefs *p);
-extern int cmdlineparser (char *s, char *outp[], int max);
+extern int cmdlineparser (TCHAR *s, TCHAR *outp[], int max);
 extern int cfgfile_configuration_change(int);
 extern void fixup_prefs_dimensions (struct uae_prefs *prefs);
 extern void fixup_prefs (struct uae_prefs *prefs);
@@ -450,7 +451,7 @@ extern void machdep_free (void);
 #define fuzzy_memset(p, c, o, l) fuzzy_memset_1 ((p), QUADRUPLIFY (c), (o) & ~3, ((l) + 4) >> 2)
 STATIC_INLINE void fuzzy_memset_1 (void *p, uae_u32 c, int offset, int len)
 {
-    uae_u32 *p2 = (uae_u32 *)((char *)p + offset);
+    uae_u32 *p2 = (uae_u32 *)((TCHAR *)p + offset);
     int a = len & 7;
     len >>= 3;
     switch (a) {
@@ -493,7 +494,7 @@ STATIC_INLINE void fuzzy_memset_1 (void *p, uae_u32 c, int offset, int len)
 #define fuzzy_memset_le32(p, c, o, l) fuzzy_memset_le32_1 ((p), QUADRUPLIFY (c), (o) & ~3, ((l) + 7) >> 2)
 STATIC_INLINE void fuzzy_memset_le32_1 (void *p, uae_u32 c, int offset, int len)
 {
-    uae_u32 *p2 = (uae_u32 *)((char *)p + offset);
+    uae_u32 *p2 = (uae_u32 *)((TCHAR *)p + offset);
 
     switch (len) {
      case 9: p2[0] = c; p2[1] = c; p2[2] = c; p2[3] = c; p2[4] = c; p2[5] = c; p2[6] = c; p2[7] = c; p2[8] = c; break;
index 07be5dcb3bc6472b643b2d5935840f03c0964f8b..47b50782570037126fb0d664d96ad09fec427378 100644 (file)
@@ -35,8 +35,8 @@ ENUMDECL {
 
 extern struct mnemolookup {
     instrmnem mnemo;
-    const char *name;
-    const char *friendlyname;
+    const TCHAR *name;
+    const TCHAR *friendlyname;
 } lookuptab[];
 
 ENUMDECL {
@@ -60,7 +60,7 @@ ENUMDECL {
 struct instr_def {
     unsigned int bits;
     int n_variable;
-    char bitpos[16];
+    uae_u8 bitpos[16];
     unsigned int mask;
     int cpulevel;
     int plevel;
@@ -68,8 +68,8 @@ struct instr_def {
        unsigned int flaguse:3;
        unsigned int flagset:3;
     } flaginfo[5];
-    unsigned char sduse;
-    const char *opcstr;
+    uae_u8 sduse;
+    const TCHAR *opcstr;
 };
 
 extern struct instr_def defs68k[];
index b7b42944ce96000715201d3dc66ebf71d8115aa4..6190f6126b70bb5cdaf35974396054012e2a3994 100644 (file)
@@ -20,8 +20,8 @@ extern uae_u32 restore_u32_func (uae_u8 **);
 extern uae_u16 restore_u16_func (uae_u8 **);
 extern uae_u8 restore_u8_func (uae_u8 **);
 
-extern void save_string_func (uae_u8 **, const char*);
-extern char *restore_string_func (uae_u8 **);
+extern void save_string_func (uae_u8 **, const TCHAR*);
+extern TCHAR *restore_string_func (uae_u8 **);
 
 #define save_u64(x) save_u64_func (&dst, (x))
 #define save_u32(x) save_u32_func (&dst, (x))
@@ -130,9 +130,9 @@ extern uae_u8 *save_action_replay (int *, uae_u8 *);
 extern uae_u8 *restore_hrtmon (uae_u8 *);
 extern uae_u8 *save_hrtmon (int *, uae_u8 *);
 
-extern void savestate_initsave (const char *filename, int docompress, int nodialogs);
-extern int save_state (const char *filename, const char *description);
-extern void restore_state (const char *filename);
+extern void savestate_initsave (const TCHAR *filename, int docompress, int nodialogs);
+extern int save_state (const TCHAR *filename, const TCHAR *description);
+extern void restore_state (const TCHAR *filename);
 extern void savestate_restore_finish (void);
 
 extern void custom_save_state (void);
@@ -146,7 +146,7 @@ extern void custom_prepare_savestate (void);
 #define STATE_DOREWIND 32
 
 extern int savestate_state;
-extern char savestate_fname[MAX_DPATH];
+extern TCHAR savestate_fname[MAX_DPATH];
 extern struct zfile *savestate_file;
 
 extern void savestate_quick (int slot, int save);
index 5ccf2a37601303255219b338a50f16eda14d925e..8f2aef0644e794dbc986c0f29eeee424baadf395 100644 (file)
@@ -20,6 +20,7 @@
 #include <errno.h>
 #include <assert.h>
 #include <limits.h>
+#include <tchar.h>
 
 #ifndef __STDC__
 #ifndef _MSC_VER
@@ -177,6 +178,7 @@ extern void* q_memcpy(void*,const void*,size_t);
 /* If char has more then 8 bits, good night. */
 typedef unsigned char uae_u8;
 typedef signed char uae_s8;
+typedef unsigned char uae_char;
 
 typedef struct { uae_u8 RGB[3]; } RGB;
 
@@ -223,14 +225,23 @@ typedef uae_u32 uaecptr;
 #endif
 
 #ifdef HAVE_STRDUP
-#define my_strdup strdup
+#define my_strdup _tcsdup
 #else
-extern char *my_strdup (const char*s);
-#endif
-
-extern void *xmalloc(size_t);
-extern void *xcalloc(size_t, size_t);
-extern void xfree(const void*);
+extern TCHAR *my_strdup (const TCHAR*s);
+#endif
+extern TCHAR *my_strdup_ansi (const char*);
+extern TCHAR *au (const char*);
+extern char *ua (const TCHAR*);
+extern TCHAR *aucp (const char*, unsigned int cp);
+extern char *uacp (const TCHAR*, unsigned int cp);
+extern char *ua_copy (char *dst, int maxlen, const TCHAR *src);
+extern TCHAR *au_copy (TCHAR *dst, int maxlen, const char *src);
+extern char *uacp_copy (char *dst, int maxlen, const TCHAR *src, unsigned int cp);
+extern TCHAR *aucp_copy (TCHAR *dst, int maxlen, const char *src, unsigned int cp);
+
+extern void *xmalloc (size_t);
+extern void *xcalloc (size_t, size_t);
+extern void xfree (const void*);
 
 /* We can only rely on GNU C getting enums right. Mickeysoft VSC++ is known
  * to have problems, and it's likely that other compilers choke too. */
@@ -312,15 +323,15 @@ extern void gettimeofday( struct timeval *tv, void *blah );
 #define O_RDWR   _O_RDWR
 #define O_CREAT  _O_CREAT
 #define O_TRUNC  _O_TRUNC
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
+#define strcasecmp _tcsicmp 
+#define strncasecmp _tcsncicmp 
 #define W_OK 0x2
 #define R_OK 0x4
 #define STAT struct stat
 #define DIR struct DIR
 struct direct
 {
-    char d_name[1];
+    TCHAR d_name[1];
 };
 #include <sys/utime.h>
 #define utimbuf _utimbuf
@@ -337,22 +348,22 @@ struct direct
 #define S_IXUSR FILEFLAG_EXECUTE
 
 /* These are prototypes for functions from the Win32 posixemu file */
-extern void get_time(time_t t, long* days, long* mins, long* ticks);
+extern void get_time (time_t t, long* days, long* mins, long* ticks);
 extern time_t put_time (long days, long mins, long ticks);
-extern DWORD getattr(const char *name, LPFILETIME lpft, size_t *size);
+extern DWORD getattr (const TCHAR *name, LPFILETIME lpft, size_t *size);
 
 /* #define DONT_HAVE_POSIX - don't need all of Mathias' posixemu_functions, just a subset (below) */
 #define chmod(a,b) posixemu_chmod ((a), (b))
-extern int posixemu_chmod (const char *, int);
+extern int posixemu_chmod (const TCHAR *, int);
 #define stat(a,b) posixemu_stat ((a), (b))
-extern int posixemu_stat (const char *, struct stat *);
+extern int posixemu_stat (const TCHAR *, struct stat *);
 #define mkdir(x,y) mkdir(x)
 #define truncate posixemu_truncate
-extern int posixemu_truncate (const char *, long int);
+extern int posixemu_truncate (const TCHAR *, long int);
 #define utime posixemu_utime
-extern int posixemu_utime (const char *, struct utimbuf *);
+extern int posixemu_utime (const TCHAR *, struct utimbuf *);
 #define opendir posixemu_opendir
-extern DIR * posixemu_opendir (const char *);
+extern DIR * posixemu_opendir (const TCHAR *);
 #define readdir posixemu_readdir
 extern struct dirent* posixemu_readdir (DIR *);
 #define closedir posixemu_closedir
@@ -365,38 +376,38 @@ extern void posixemu_closedir (DIR *);
 #ifdef DONT_HAVE_POSIX
 
 #define access posixemu_access
-extern int posixemu_access (const char *, int);
+extern int posixemu_access (const TCHAR *, int);
 #define open posixemu_open
-extern int posixemu_open (const char *, int, int);
+extern int posixemu_open (const TCHAR *, int, int);
 #define close posixemu_close
 extern void posixemu_close (int);
 #define read posixemu_read
-extern int posixemu_read (int, char *, int);
+extern int posixemu_read (int, TCHAR *, int);
 #define write posixemu_write
-extern int posixemu_write (int, const char *, int);
+extern int posixemu_write (int, const TCHAR *, int);
 #undef lseek
 #define lseek posixemu_seek
 extern int posixemu_seek (int, int, int);
 #define stat(a,b) posixemu_stat ((a), (b))
-extern int posixemu_stat (const char *, STAT *);
+extern int posixemu_stat (const TCHAR *, STAT *);
 #define mkdir posixemu_mkdir
-extern int mkdir (const char *, int);
+extern int mkdir (const TCHAR *, int);
 #define rmdir posixemu_rmdir
-extern int posixemu_rmdir (const char *);
+extern int posixemu_rmdir (const TCHAR *);
 #define unlink posixemu_unlink
-extern int posixemu_unlink (const char *);
+extern int posixemu_unlink (const TCHAR *);
 #define truncate posixemu_truncate
-extern int posixemu_truncate (const char *, long int);
+extern int posixemu_truncate (const TCHAR *, long int);
 #define rename posixemu_rename
-extern int posixemu_rename (const char *, const char *);
+extern int posixemu_rename (const TCHAR *, const TCHAR *);
 #define chmod posixemu_chmod
-extern int posixemu_chmod (const char *, int);
+extern int posixemu_chmod (const TCHAR *, int);
 #define tmpnam posixemu_tmpnam
-extern void posixemu_tmpnam (char *);
+extern void posixemu_tmpnam (TCHAR *);
 #define utime posixemu_utime
-extern int posixemu_utime (const char *, struct utimbuf *);
+extern int posixemu_utime (const TCHAR *, struct utimbuf *);
 #define opendir posixemu_opendir
-extern DIR * posixemu_opendir (const char *);
+extern DIR * posixemu_opendir (const TCHAR *);
 #define readdir posixemu_readdir
 extern struct dirent* readdir (DIR *);
 #define closedir posixemu_closedir
@@ -411,13 +422,13 @@ extern long dos_errno (void);
 
 #ifdef DONT_HAVE_STDIO
 
-extern FILE *stdioemu_fopen (const char *, const char *);
+extern FILE *stdioemu_fopen (const TCHAR *, const TCHAR *);
 #define fopen(a,b) stdioemu_fopen(a, b)
 extern int stdioemu_fseek (FILE *, int, int);
 #define fseek(a,b,c) stdioemu_fseek(a, b, c)
-extern int stdioemu_fread (char *, int, int, FILE *);
+extern int stdioemu_fread (TCHAR *, int, int, FILE *);
 #define fread(a,b,c,d) stdioemu_fread(a, b, c, d)
-extern int stdioemu_fwrite (const char *, int, int, FILE *);
+extern int stdioemu_fwrite (const TCHAR *, int, int, FILE *);
 #define fwrite(a,b,c,d) stdioemu_fwrite(a, b, c, d)
 extern int stdioemu_ftell (FILE *);
 #define ftell(a) stdioemu_ftell(a)
@@ -449,27 +460,27 @@ extern void mallocemu_free (void *ptr);
 #endif
 
 #if __GNUC__ - 1 > 1 || __GNUC_MINOR__ - 1 > 6
-extern void write_log (const char *, ...) __attribute__ ((format (printf, 1, 2)));
+extern void write_log (const TCHAR *, ...) __attribute__ ((format (printf, 1, 2)));
 #else
-extern void write_log (const char *, ...);
+extern void write_log (const TCHAR *, ...);
 #endif
-extern void write_dlog (const char *, ...);
+extern void write_dlog (const TCHAR *, ...);
 
 extern void flush_log (void);
 extern void close_console (void);
 extern void reopen_console (void);
-extern void console_out (const char *);
-extern void console_out_f (const char *, ...);
+extern void console_out (const TCHAR *);
+extern void console_out_f (const TCHAR *, ...);
 extern void console_flush (void);
-extern int console_get (char *, int);
-extern void f_out (void *, const char *, ...);
-extern char* buf_out (char *buffer, int *bufsize, const char *format, ...);
-extern void gui_message (const char *,...);
-extern int gui_message_multibutton (int flags, const char *format,...);
+extern int console_get (TCHAR *, int);
+extern void f_out (void *, const TCHAR *, ...);
+extern TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...);
+extern void gui_message (const TCHAR *,...);
+extern int gui_message_multibutton (int flags, const TCHAR *format,...);
 #define write_log_err write_log
-extern void logging_init(void);
-extern void *log_open(const char *name, int append, int bootlog);
-extern void log_close(void *f);
+extern void logging_init (void);
+extern void *log_open (const TCHAR *name, int append, int bootlog);
+extern void log_close (void *f);
 
 
 #ifndef O_BINARY
index d9923648368fe1efb981aa6fa7134dba4fdfe695..3a8a2cc531a4a971c28adfba198533fe587be1ef 100644 (file)
@@ -39,8 +39,8 @@ typedef uae_u32 (REGPARAM3 *TrapHandler) (TrapContext *) REGPARAM;
  */
 extern void REGPARAM3 m68k_handle_trap (unsigned int trap_num, struct regstruct *) REGPARAM;
 
-unsigned int define_trap (TrapHandler handler_func, int flags, const char *name);
-uaecptr find_trap (const char *name);
+unsigned int define_trap (TrapHandler handler_func, int flags, const TCHAR *name);
+uaecptr find_trap (const TCHAR *name);
 
 /*
  * Call a 68k Library function from an extended trap
index 8fa460a3e3a6d9d3fefc137c5820e91b3093d547..128ebf095a9dde30e1b6d8d1149cd9a0a613229f 100644 (file)
@@ -10,24 +10,24 @@ extern void do_start_program (void);
 extern void do_leave_program (void);
 extern void start_program (void);
 extern void leave_program (void);
-extern void real_main (int, char **);
+extern void real_main (int, TCHAR **);
 extern void usage (void);
-extern void parse_cmdline (int argc, char **argv);
+extern void parse_cmdline (int argc, TCHAR **argv);
 extern void sleep_millis (int ms);
 extern void sleep_millis_busy (int ms);
 extern int sleep_resolution;
 
 extern void uae_reset (int);
 extern void uae_quit (void);
-extern void uae_restart (int, char*);
+extern void uae_restart (int, TCHAR*);
 extern void reset_all_systems (void);
 extern void target_reset (void);
 
 extern int quit_program;
 
-extern char warning_buffer[256];
-extern char start_path_data[];
-extern char start_path_data_exe[];
+extern TCHAR warning_buffer[256];
+extern TCHAR start_path_data[];
+extern TCHAR start_path_data_exe[];
 
 /* This structure is used to define menus. The val field can hold key
  * shortcuts, or one of these special codes:
@@ -39,14 +39,14 @@ extern char start_path_data_exe[];
  *    0: Menu title
  */
 struct bstring {
-    const char *data;
+    const TCHAR *data;
     int val;
 };
 
-extern char *colormodes[];
-extern void fetch_saveimagepath (char*, int, int);
-extern void fetch_configurationpath (char *out, int size);
-extern void fetch_screenshotpath (char *out, int size);
-extern void fetch_ripperpath (char *out, int size);
-extern void fetch_datapath (char *out, int size);
+extern TCHAR *colormodes[];
+extern void fetch_saveimagepath (TCHAR*, int, int);
+extern void fetch_configurationpath (TCHAR *out, int size);
+extern void fetch_screenshotpath (TCHAR *out, int size);
+extern void fetch_ripperpath (TCHAR *out, int size);
+extern void fetch_datapath (TCHAR *out, int size);
 extern int uaerand(void);
\ No newline at end of file
index 49c9616805c9437441c3570c9b49d7c22d1146db..c215b3b0dffe8ebf4666ebeae1c2fe53f017b9b9 100644 (file)
@@ -6,7 +6,7 @@
 
 struct uae_xcmd {
     struct uae_xcmd *prev, *next;
-    char *cmd;
+    TCHAR *cmd;
 };
 
 #define UAEEXE_ORG         0xF0FF90 /* sam: I hope this slot is free */
@@ -16,6 +16,6 @@ struct uae_xcmd {
 #define UAEEXE_NOMEM       2
 
 extern void uaeexe_install (void);
-extern int uaeexe (const char *cmd);
+extern int uaeexe (const TCHAR *cmd);
 
 
index 5a26b48c3cb55f579c4697eede6c5cd804117d47..97ac270df2d52bf42f4447190624b3c0daf990f2 100644 (file)
@@ -1,10 +1,10 @@
 
-#define COMPIPENAME "WinUAE_COM"
+#define COMPIPENAME L"WinUAE_COM"
 
-extern void *createIPC(const char *name, int);
-extern void closeIPC(void*);
-extern int checkIPC(void*,struct uae_prefs*);
-extern void *geteventhandleIPC(void*);
-extern int sendBinIPC(void*, uae_u8 *msg, int len);
-extern int sendIPC(void*, char *msg);
-extern int isIPC (const char *pipename);
+extern void *createIPC (const TCHAR *name, int);
+extern void closeIPC (void*);
+extern int checkIPC (void*,struct uae_prefs*);
+extern void *geteventhandleIPC (void*);
+extern int sendBinIPC (void*, uae_u8 *msg, int len);
+extern int sendIPC (void*, TCHAR *msg);
+extern int isIPC (const TCHAR *pipename);
index d56e32d051fa4dc06ba2d111554d862de04f05be..240c1cba9ca7ee456d3f832db43451238a220c85 100644 (file)
@@ -1,11 +1,11 @@
 
 struct zfile {
-    char *name;
-    char *zipname;
+    TCHAR *name;
+    TCHAR *zipname;
     FILE *f;
     uae_u8 *data;
-    int size;
-    int seek;
+    uae_u64 size;
+    uae_u64 seek;
     int deleteafterclose;
     struct zfile *next;
 };
@@ -20,11 +20,11 @@ struct znode {
     struct znode *next;
     struct znode *prev;
     struct znode *vfile; // points to real file when this node is virtual directory
-    char *name;
-    char *fullname;
-    unsigned int size;
+    TCHAR *name;
+    TCHAR *fullname;
+    uae_u64 size;
     struct zfile *f;
-    char *comment;
+    TCHAR *comment;
     int flags;
     time_t mtime;
     /* decompressor specific */
@@ -42,19 +42,19 @@ struct zvolume
     struct zvolume *next;
     struct znode *last;
     struct zvolume *parent;
-    unsigned int size;
+    uae_u64 size;
     unsigned int blocks;
     unsigned int id;
-    unsigned int archivesize;
+    uae_u64 archivesize;
     unsigned int method;
 };
 
 struct zarchive_info
 {
-    const char *name;
-    unsigned int size;
+    const TCHAR *name;
+    uae_u64 size;
     int flags;
-    char *comment;
+    TCHAR *comment;
     time_t t;
 };
 
@@ -66,14 +66,14 @@ struct zarchive_info
 #define ArchiveFormatPLAIN '----'
 #define ArchiveFormatAA 'aa  ' // method only
 
-extern int zfile_is_ignore_ext(const char *name);
+extern int zfile_is_ignore_ext(const TCHAR *name);
 
 extern struct zvolume *zvolume_alloc(struct zfile *z, unsigned int id, void *handle);
-extern struct zvolume *zvolume_alloc_empty(const char *name);
+extern struct zvolume *zvolume_alloc_empty(const TCHAR *name);
 
 extern struct znode *zvolume_addfile_abs(struct zvolume *zv, struct zarchive_info*);
 extern struct znode *zvolume_adddir_abs(struct zvolume *zv, struct zarchive_info *zai);
-extern struct znode *znode_adddir(struct znode *parent, const char *name, struct zarchive_info*);
+extern struct znode *znode_adddir(struct znode *parent, const TCHAR *name, struct zarchive_info*);
 
 extern struct zvolume *archive_directory_plain(struct zfile *zf);
 extern struct zfile *archive_access_plain (struct znode *zn);
index 3a2ea7292b383d5b8a98def72810dbf2d711988f..7aeca076658c09f0ae5bdd50e7d1189d797a7c3f 100644 (file)
@@ -11,34 +11,34 @@ struct zvolume;
 
 typedef int (*zfile_callback)(struct zfile*, void*);
 
-extern struct zfile *zfile_fopen (const char *, const char *);
-extern struct zfile *zfile_fopen_nozip (const char *, const char *);
-extern struct zfile *zfile_fopen_empty (const char *name, int size);
-extern struct zfile *zfile_fopen_data (const char *name, int size, uae_u8 *data);
-extern int zfile_exists (const char *name);
+extern struct zfile *zfile_fopen (const TCHAR *, const TCHAR *);
+extern struct zfile *zfile_fopen_nozip (const TCHAR *, const TCHAR *);
+extern struct zfile *zfile_fopen_empty (const TCHAR *name, uae_u64 size);
+extern struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, uae_u8 *data);
+extern int zfile_exists (const TCHAR *name);
 extern void zfile_fclose (struct zfile *);
-extern int zfile_fseek (struct zfile *z, long offset, int mode);
-extern long zfile_ftell (struct zfile *z);
+extern uae_s64 zfile_fseek (struct zfile *z, uae_s64 offset, int mode);
+extern uae_s64 zfile_ftell (struct zfile *z);
 extern size_t zfile_fread  (void *b, size_t l1, size_t l2, struct zfile *z);
 extern size_t zfile_fwrite  (void *b, size_t l1, size_t l2, struct zfile *z);
-extern char *zfile_fgets(char *s, int size, struct zfile *z);
-extern size_t zfile_fputs (struct zfile *z, char *s);
+extern TCHAR *zfile_fgets(TCHAR *s, int size, struct zfile *z);
+extern size_t zfile_fputs (struct zfile *z, TCHAR *s);
 extern int zfile_getc (struct zfile *z);
 extern int zfile_putc (int c, struct zfile *z);
 extern int zfile_ferror (struct zfile *z);
-extern char *zfile_getdata (struct zfile *z, int offset, int len);
+extern uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len);
 extern void zfile_exit (void);
-extern int execute_command (char *);
+extern int execute_command (TCHAR *);
 extern int zfile_iscompressed (struct zfile *z);
 extern int zfile_zcompress (struct zfile *dst, void *src, int size);
 extern int zfile_zuncompress (void *dst, int dstsize, struct zfile *src, int srcsize);
 extern int zfile_gettype (struct zfile *z);
-extern int zfile_zopen (const char *name, zfile_callback zc, void *user);
-extern char *zfile_getname (struct zfile *f);
+extern int zfile_zopen (const TCHAR *name, zfile_callback zc, void *user);
+extern TCHAR *zfile_getname (struct zfile *f);
 extern uae_u32 zfile_crc32 (struct zfile *f);
 extern struct zfile *zfile_dup (struct zfile *f);
 extern struct zfile *zfile_gunzip (struct zfile *z);
-extern int zfile_isdiskimage (const char *name);
+extern int zfile_isdiskimage (const TCHAR *name);
 extern int iszip (struct zfile *z);
 
 #define ZFILE_UNKNOWN 0
@@ -51,20 +51,20 @@ extern int iszip (struct zfile *z);
 #define ZFILE_NVR 7
 #define ZFILE_HDFRDB 8
 
-extern const char *uae_archive_extensions[];
-extern const char *uae_ignoreextensions[];
-extern const char *uae_diskimageextensions[];
+extern const TCHAR *uae_archive_extensions[];
+extern const TCHAR *uae_ignoreextensions[];
+extern const TCHAR *uae_diskimageextensions[];
 
-extern struct zvolume *zfile_fopen_archive(const char *filename);
+extern struct zvolume *zfile_fopen_archive(const TCHAR *filename);
 extern void zfile_fclose_archive(struct zvolume *zv);
-extern int zfile_fs_usage_archive(const char *path, const char *disk, struct fs_usage *fsp);
-extern int zfile_stat_archive(const char *path, struct stat *statbuf);
-extern void *zfile_opendir_archive(const char *path);
+extern int zfile_fs_usage_archive(const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp);
+extern int zfile_stat_archive(const TCHAR *path, struct _stat64 *statbuf);
+extern void *zfile_opendir_archive(const TCHAR *path);
 extern void zfile_closedir_archive(void*);
-extern int zfile_readdir_archive(void*, char*);
-extern zfile_fill_file_attrs_archive(const char *path, int *isdir, int *flags, char **comment);
-extern unsigned int zfile_lseek_archive (void *d, unsigned int offset, int whence);
+extern int zfile_readdir_archive(void*, TCHAR*);
+extern zfile_fill_file_attrs_archive(const TCHAR *path, int *isdir, int *flags, TCHAR **comment);
+extern uae_s64 zfile_lseek_archive (void *d, uae_s64 offset, int whence);
 extern unsigned int zfile_read_archive (void *d, void *b, unsigned int size);
 extern void zfile_close_archive (void *d);
-extern void *zfile_open_archive (const char *path, int flags);
-extern int zfile_exists_archive(const char *path, const char *rel);
+extern void *zfile_open_archive (const TCHAR *path, int flags);
+extern int zfile_exists_archive(const TCHAR *path, const TCHAR *rel);
index ec177a7dd8d1b51ff351d4f830c96a8c7f346c97..50c6a5f7017eb00a3eebf723ec2c648331dc7a3b 100644 (file)
@@ -61,8 +61,8 @@ int inputdevice_logging = 0;
 #define DIR_DOWN 8
 
 struct inputevent {
-    const char *confname;
-    const char *name;
+    const TCHAR *confname;
+    const TCHAR *name;
     int allow_mask;
     int type;
     int unit;
@@ -102,7 +102,7 @@ struct inputevent {
 /* event flags */
 #define ID_FLAG_AUTOFIRE 1
 
-#define DEFEVENT(A, B, C, D, E, F) {#A, B, C, D, E, F },
+#define DEFEVENT(A, B, C, D, E, F) {L#A, B, C, D, E, F },
 struct inputevent events[] = {
 {0, 0, AM_K,0,0,0},
 #include "inputevents.def"
@@ -133,13 +133,13 @@ static int inprec_div;
 static uae_u32 oldbuttons[4];
 static uae_u16 oldjoy[2];
 
-int inprec_open(char *fname, int record)
+int inprec_open (TCHAR *fname, int record)
 {
     uae_u32 t = (uae_u32)time(0);
     int i;
 
     inprec_close();
-    inprec_zf = zfile_fopen(fname, record > 0 ? "wb" : "rb");
+    inprec_zf = zfile_fopen (fname, record > 0 ? L"wb" : L"rb");
     if (inprec_zf == NULL)
        return 0;
     inprec_size = 10000;
@@ -154,35 +154,35 @@ int inprec_open(char *fname, int record)
        inprec_plastptr = inprec_buffer;
        id = inprec_pu32();
        if (id != 'UAE\0') {
-           inprec_close();
+           inprec_close ();
            return 0;
        }
        inprec_pu32();
-       t = inprec_pu32();
-       i = inprec_pu32();
+       t = inprec_pu32 ();
+       i = inprec_pu32 ();
        while (i-- > 0)
-           inprec_pu8();
+           inprec_pu8 ();
        inprec_p = inprec_plastptr;
        oldbuttons[0] = oldbuttons[1] = oldbuttons[2] = oldbuttons[3] = 0;
        oldjoy[0] = oldjoy[1] = 0;
        if (record < -1)
            inprec_div = maxvpos;
     } else if (record > 0) {
-       inprec_buffer = inprec_p = (uae_u8*)xmalloc (inprec_size);
-       inprec_ru32('UAE\0');
-       inprec_ru8(1);
-       inprec_ru8(UAEMAJOR);
-       inprec_ru8(UAEMINOR);
-       inprec_ru8(UAESUBREV);
-       inprec_ru32(t);
-       inprec_ru32(0); // extra header size
+       inprec_buffer = inprec_p = xmalloc (inprec_size);
+       inprec_ru32 ('UAE\0');
+       inprec_ru8 (1);
+       inprec_ru8 (UAEMAJOR);
+       inprec_ru8 (UAEMINOR);
+       inprec_ru8 (UAESUBREV);
+       inprec_ru32 (t);
+       inprec_ru32 (0); // extra header size
     } else {
        return 0;
     }
     input_recording = record;
     srand(t);
-    CIA_inprec_prepare();
-    write_log ("inprec initialized '%s', mode=%d\n", fname, input_recording);
+    CIA_inprec_prepare ();
+    write_log (L"inprec initialized '%s', mode=%d\n", fname, input_recording);
     return 1;
 }
 
@@ -203,41 +203,43 @@ void inprec_close(void)
     xfree (inprec_buffer);
     inprec_buffer = NULL;
     input_recording = 0;
-    write_log ("inprec finished\n");
+    write_log (L"inprec finished\n");
 }
 
 void inprec_ru8(uae_u8 v)
 {
     *inprec_p++= v;
 }
-void inprec_ru16(uae_u16 v)
+void inprec_ru16 (uae_u16 v)
 {
-    inprec_ru8((uae_u8)(v >> 8));
-    inprec_ru8((uae_u8)v);
+    inprec_ru8 ((uae_u8)(v >> 8));
+    inprec_ru8 ((uae_u8)v);
 }
-void inprec_ru32(uae_u32 v)
+void inprec_ru32 (uae_u32 v)
 {
-    inprec_ru16((uae_u16)(v >> 16));
-    inprec_ru16((uae_u16)v);
+    inprec_ru16 ((uae_u16)(v >> 16));
+    inprec_ru16 ((uae_u16)v);
 }
-void inprec_rstr(const char *s)
+void inprec_rstr (const TCHAR *src)
 {
+    char *s = ua (src);
     while(*s) {
-       inprec_ru8(*s);
+       inprec_ru8 (*s);
        s++;
     }
-    inprec_ru8(0);
+    inprec_ru8 (0);
+    xfree (s);
 }
-void inprec_rstart(uae_u8 type)
+void inprec_rstart (uae_u8 type)
 {
-    write_log ("INPREC: %08X: %d\n", hsync_counter, type);
-    inprec_ru32(hsync_counter);
-    inprec_ru8(0);
+    write_log (L"INPREC: %08X: %d\n", hsync_counter, type);
+    inprec_ru32 (hsync_counter);
+    inprec_ru8 (0);
     inprec_plast = inprec_p;
-    inprec_ru8(0xff);
-    inprec_ru8(type);
+    inprec_ru8 (0xff);
+    inprec_ru8 (type);
 }
-void inprec_rend(void)
+void inprec_rend (void)
 {
     *inprec_plast = inprec_p - (inprec_plast + 2);
     if (inprec_p >= inprec_buffer + inprec_size - 256) {
@@ -246,7 +248,7 @@ void inprec_rend(void)
     }
 }
 
-int inprec_pstart(uae_u8 type)
+int inprec_pstart (uae_u8 type)
 {
     uae_u8 *p = inprec_p;
     uae_u32 hc = hsync_counter;
@@ -256,7 +258,7 @@ int inprec_pstart(uae_u8 type)
     if (savestate_state)
        return 0;
     if (p[5 + 1] == INPREC_END) {
-       inprec_close();
+       inprec_close ();
        return 0;
     }
     hc_orig = hc;
@@ -265,15 +267,15 @@ int inprec_pstart(uae_u8 type)
     for (;;) {
        uae_u32 hc2 = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
        if (p > lastp) {
-           write_log ("INPREC: Next %08x (%08x=%d): %d (%d)\n", hc2, hc, hc2 - hc, p[5 + 1], p[5]);
+           write_log (L"INPREC: Next %08x (%08x=%d): %d (%d)\n", hc2, hc, hc2 - hc, p[5 + 1], p[5]);
            lastp = p;
        }
        hc2_orig = hc2;
        hc2 /= inprec_div;
        hc2 *= inprec_div;
        if (hc > hc2) {
-           write_log ("INPREC: %08x > %08x: %d (%d) missed!\n", hc, hc2, p[5 + 1], p[5]);
-           inprec_close();
+           write_log (L"INPREC: %08x > %08x: %d (%d) missed!\n", hc, hc2, p[5 + 1], p[5]);
+           inprec_close ();
            return 0;
        }
        if (hc2 != hc) {
@@ -281,7 +283,7 @@ int inprec_pstart(uae_u8 type)
            break;
        }
        if (p[5 + 1] == type) {
-           write_log ("INPREC: %08x: %d (%d) (%+d)\n", hc, type, p[5], hc_orig - hc2_orig);
+           write_log (L"INPREC: %08x: %d (%d) (%+d)\n", hc, type, p[5], hc_orig - hc2_orig);
            inprec_plast = p;
            inprec_plastptr = p + 5 + 2;
            return 1;
@@ -291,7 +293,7 @@ int inprec_pstart(uae_u8 type)
     inprec_plast = NULL;
     return 0;
 }
-void inprec_pend(void)
+void inprec_pend (void)
 {
     uae_u8 *p = inprec_p;
     uae_u32 hc = hsync_counter;
@@ -315,35 +317,40 @@ void inprec_pend(void)
     }
     inprec_p = p;
     if (p[5 + 1] == INPREC_END)
-       inprec_close();
+       inprec_close ();
 }
 
-uae_u8 inprec_pu8(void)
+uae_u8 inprec_pu8 (void)
 {
     return *inprec_plastptr++;
 }
-uae_u16 inprec_pu16(void)
+uae_u16 inprec_pu16 (void)
 {
-    uae_u16 v = inprec_pu8() << 8;
-    v |= inprec_pu8();
+    uae_u16 v = inprec_pu8 () << 8;
+    v |= inprec_pu8 ();
     return v;
 }
-uae_u32 inprec_pu32(void)
+uae_u32 inprec_pu32 (void)
 {
-    uae_u32 v = inprec_pu16() << 16;
-    v |= inprec_pu16();
+    uae_u32 v = inprec_pu16 () << 16;
+    v |= inprec_pu16 ();
     return v;
 }
-int inprec_pstr(char *s)
+int inprec_pstr (TCHAR *dst)
 {
+    char tmp[MAX_DPATH];
+    char *s;
     int len = 0;
+
+    s = tmp;
     for(;;) {
-       uae_u8 v = inprec_pu8();
+       uae_u8 v = inprec_pu8 ();
        *s++ = v;
        if (!v)
            break;
        len++;
     }
+    au_copy (dst, MAX_DPATH, tmp);
     return len;
 }
 
@@ -359,13 +366,13 @@ static int isdevice (struct uae_input_device *id)
     return 0;
 }
 
-int inputdevice_uaelib (char *s, char *parm)
+int inputdevice_uaelib (TCHAR *s, TCHAR *parm)
 {
     int i;
 
     for (i = 1; events[i].name; i++) {
-       if (!strcmp (s, events[i].confname)) {
-           handle_input_event (i, atol (parm), 1, 0);
+       if (!_tcscmp (s, events[i].confname)) {
+           handle_input_event (i, _tstol (parm), 1, 0);
            return 1;
        }
     }
@@ -422,21 +429,21 @@ static void freejport (struct uae_prefs *dst, int num)
 static void copyjport (const struct uae_prefs *src, struct uae_prefs *dst, int num)
 {
     freejport (dst, num);
-    strcpy (dst->jports[num].configname, src->jports[num].configname);
-    strcpy (dst->jports[num].name, src->jports[num].name);
+    _tcscpy (dst->jports[num].configname, src->jports[num].configname);
+    _tcscpy (dst->jports[num].name, src->jports[num].name);
     dst->jports[num].id = src->jports[num].id;
 }
 
-static void out_config (struct zfile *f, int id, int num, char *s1, char *s2)
+static void out_config (struct zfile *f, int id, int num, TCHAR *s1, TCHAR *s2)
 {
-    cfgfile_write (f, "input.%d.%s%d=%s\n", id, s1, num, s2);
+    cfgfile_write (f, L"input.%d.%s%d=%s\n", id, s1, num, s2);
 }
 
-static void write_config2 (struct zfile *f, int idnum, int i, int offset, char *tmp1, struct uae_input_device *id)
+static void write_config2 (struct zfile *f, int idnum, int i, int offset, TCHAR *tmp1, struct uae_input_device *id)
 {
-    char tmp2[200], *p;
+    TCHAR tmp2[200], *p;
     int evt, got, j, k;
-    char *custom;
+    TCHAR *custom;
 
     p = tmp2;
     got = 0;
@@ -456,32 +463,32 @@ static void write_config2 (struct zfile *f, int idnum, int i, int offset, char *
            *p = 0;
        }
        if (custom)
-           sprintf (p, "'%s'.%d", custom, id->flags[i + offset][j] & 0xff);
+           _stprintf (p, L"'%s'.%d", custom, id->flags[i + offset][j] & 0xff);
        else if (evt <= 0)
-           sprintf (p, "NULL");
+           _stprintf (p, L"NULL");
        else
-           sprintf (p, "%s.%d", events[evt].confname, id->flags[i + offset][j]);
-       p += strlen (p);
+           _stprintf (p, L"%s.%d", events[evt].confname, id->flags[i + offset][j]);
+       p += _tcslen (p);
     }
     if (p > tmp2)
-       cfgfile_write (f, "input.%d.%s%d=%s\n", idnum, tmp1, i, tmp2);
+       cfgfile_write (f, L"input.%d.%s%d=%s\n", idnum, tmp1, i, tmp2);
 }
 
 static struct inputdevice_functions *getidf (int devnum);
 
-static void write_config (struct zfile *f, int idnum, int devnum, char *name, struct uae_input_device *id, struct uae_input_device2 *id2, struct inputdevice_functions *idf)
+static void write_config (struct zfile *f, int idnum, int devnum, TCHAR *name, struct uae_input_device *id, struct uae_input_device2 *id2, struct inputdevice_functions *idf)
 {
-    char tmp1[MAX_DPATH], *s;
+    TCHAR tmp1[MAX_DPATH], *s;
     int i;
 
     if (!isdevice (id)) {
-       cfgfile_write (f, "input.%d.%s.%d.empty=true\n", idnum, name, devnum);
+       cfgfile_write (f, L"input.%d.%s.%d.empty=true\n", idnum, name, devnum);
        if (id->enabled)
-           cfgfile_write (f, "input.%d.%s.%d.disabled=%d\n", idnum, name, devnum, id->enabled ? 0 : 1);
+           cfgfile_write (f, L"input.%d.%s.%d.disabled=%d\n", idnum, name, devnum, id->enabled ? 0 : 1);
        return;
     }
-    cfgfile_write (f, "input.%d.%s.%d.empty=false\n", idnum, name, devnum);
-    cfgfile_write (f, "input.%d.%s.%d.disabled=%d\n", idnum, name, devnum, id->enabled ? 0 : 1);
+    cfgfile_write (f, L"input.%d.%s.%d.empty=false\n", idnum, name, devnum);
+    cfgfile_write (f, L"input.%d.%s.%d.disabled=%d\n", idnum, name, devnum, id->enabled ? 0 : 1);
 
     s = NULL;
     if (id->name)
@@ -489,7 +496,7 @@ static void write_config (struct zfile *f, int idnum, int devnum, char *name, st
     else if (devnum < idf->get_num ())
        s = idf->get_friendlyname (devnum);
     if (s)
-        cfgfile_write (f, "input.%d.%s.%d.friendlyname=%s\n", idnum, name, devnum, s);
+        cfgfile_write (f, L"input.%d.%s.%d.friendlyname=%s\n", idnum, name, devnum, s);
 
     s = NULL;
     if (id->configname)
@@ -497,17 +504,17 @@ static void write_config (struct zfile *f, int idnum, int devnum, char *name, st
     else if (devnum < idf->get_num ())
        s = idf->get_uniquename (devnum);
     if (s)
-        cfgfile_write (f, "input.%d.%s.%d.name=%s\n", idnum, name, devnum, s);
+        cfgfile_write (f, L"input.%d.%s.%d.name=%s\n", idnum, name, devnum, s);
 
-    sprintf (tmp1, "%s.%d.axis.", name, devnum);
+    _stprintf (tmp1, L"%s.%d.axis.", name, devnum);
     for (i = 0; i < ID_AXIS_TOTAL; i++)
        write_config2 (f, idnum, i, ID_AXIS_OFFSET, tmp1, id);
-    sprintf (tmp1, "%s.%d.button." ,name, devnum);
+    _stprintf (tmp1, L"%s.%d.button." ,name, devnum);
     for (i = 0; i < ID_BUTTON_TOTAL; i++)
        write_config2 (f, idnum, i, ID_BUTTON_OFFSET, tmp1, id);
 }
 
-static void kbrlabel (char *s)
+static void kbrlabel (TCHAR *s)
 {
     while (*s) {
        *s = toupper(*s);
@@ -518,7 +525,7 @@ static void kbrlabel (char *s)
 
 static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae_input_device *kbr, struct inputdevice_functions *idf)
 {
-    char tmp1[200], tmp2[200], tmp3[200], *p;
+    TCHAR tmp1[200], tmp2[200], tmp3[200], *p;
     int i, j, k, evt, skip;
 
     if (!keyboard_default)
@@ -549,7 +556,7 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae
        p = tmp2;
        p[0] = 0;
        for (j = 0; j < MAX_INPUT_SUB_EVENT; j++) {
-           char *custom = kbr->custom[i][j];
+           TCHAR *custom = kbr->custom[i][j];
            evt = kbr->eventid[i][j];
            if (custom == NULL && evt <= 0) {
                for (k = j + 1; k < MAX_INPUT_SUB_EVENT; k++) {
@@ -563,17 +570,17 @@ static void write_kbr_config (struct zfile *f, int idnum, int devnum, struct uae
                *p = 0;
            }
            if (custom)
-               sprintf (p, "'%s'.%d", custom, kbr->flags[i][j] & 0xff);
+               _stprintf (p, L"'%s'.%d", custom, kbr->flags[i][j] & 0xff);
            else if (evt > 0)
-               sprintf (p, "%s.%d", events[evt].confname, kbr->flags[i][j]);
+               _stprintf (p, L"%s.%d", events[evt].confname, kbr->flags[i][j]);
            else
-               strcat (p, "NULL");
-           p += strlen(p);
+               _tcscat (p, L"NULL");
+           p += _tcslen(p);
        }
-       sprintf (tmp3, "%d", kbr->extra[i][0]);
+       _stprintf (tmp3, L"%d", kbr->extra[i][0]);
        kbrlabel (tmp3);
-       sprintf (tmp1, "keyboard.%d.button.%s", devnum, tmp3);
-       cfgfile_write (f, "input.%d.%s=%s\n", idnum, tmp1, tmp2[0] ? tmp2 : "NULL");
+       _stprintf (tmp1, L"keyboard.%d.button.%s", devnum, tmp3);
+       cfgfile_write (f, L"input.%d.%s=%s\n", idnum, tmp1, tmp2[0] ? tmp2 : L"NULL");
        i++;
     }
 }
@@ -582,40 +589,40 @@ void write_inputdevice_config (struct uae_prefs *p, struct zfile *f)
 {
     int i, id;
 
-    cfgfile_write (f, "input.config=%d\n", p->input_selected_setting);
-    cfgfile_write (f, "input.joymouse_speed_analog=%d\n", p->input_joymouse_multiplier);
-    cfgfile_write (f, "input.joymouse_speed_digital=%d\n", p->input_joymouse_speed);
-    cfgfile_write (f, "input.joymouse_deadzone=%d\n", p->input_joymouse_deadzone);
-    cfgfile_write (f, "input.joystick_deadzone=%d\n", p->input_joystick_deadzone);
-    cfgfile_write (f, "input.analog_joystick_multiplier=%d\n", p->input_analog_joystick_mult);
-    cfgfile_write (f, "input.analog_joystick_offset=%d\n", p->input_analog_joystick_offset);
-    cfgfile_write (f, "input.mouse_speed=%d\n", p->input_mouse_speed);
-    cfgfile_write (f, "input.autofire=%d\n", p->input_autofire_framecnt);
+    cfgfile_write (f, L"input.config=%d\n", p->input_selected_setting);
+    cfgfile_write (f, L"input.joymouse_speed_analog=%d\n", p->input_joymouse_multiplier);
+    cfgfile_write (f, L"input.joymouse_speed_digital=%d\n", p->input_joymouse_speed);
+    cfgfile_write (f, L"input.joymouse_deadzone=%d\n", p->input_joymouse_deadzone);
+    cfgfile_write (f, L"input.joystick_deadzone=%d\n", p->input_joystick_deadzone);
+    cfgfile_write (f, L"input.analog_joystick_multiplier=%d\n", p->input_analog_joystick_mult);
+    cfgfile_write (f, L"input.analog_joystick_offset=%d\n", p->input_analog_joystick_offset);
+    cfgfile_write (f, L"input.mouse_speed=%d\n", p->input_mouse_speed);
+    cfgfile_write (f, L"input.autofire=%d\n", p->input_autofire_framecnt);
     for (id = 1; id <= MAX_INPUT_SETTINGS; id++) {
        for (i = 0; i < MAX_INPUT_DEVICES; i++)
-           write_config (f, id, i, "joystick", &p->joystick_settings[id][i], &joysticks2[i], &idev[IDTYPE_JOYSTICK]);
+           write_config (f, id, i, L"joystick", &p->joystick_settings[id][i], &joysticks2[i], &idev[IDTYPE_JOYSTICK]);
        for (i = 0; i < MAX_INPUT_DEVICES; i++)
-           write_config (f, id, i, "mouse", &p->mouse_settings[id][i], &mice2[i], &idev[IDTYPE_MOUSE]);
+           write_config (f, id, i, L"mouse", &p->mouse_settings[id][i], &mice2[i], &idev[IDTYPE_MOUSE]);
        for (i = 0; i < MAX_INPUT_DEVICES; i++)
            write_kbr_config (f, id, i, &p->keyboard_settings[id][i], &idev[IDTYPE_KEYBOARD]);
     }
 }
 
-static int getnum (const char **pp)
+static int getnum (const TCHAR **pp)
 {
-    const char *p = *pp;
-    int v = atol (p);
+    const TCHAR *p = *pp;
+    int v = _tstol (p);
 
     while (*p != 0 && *p !='.' && *p != ',') p++;
     if (*p == '.' || *p == ',') p++;
     *pp = p;
     return v;
 }
-static char *getstring (const char **pp)
+static TCHAR *getstring (const TCHAR **pp)
 {
     int i;
-    static char str[1000];
-    const char *p = *pp;
+    static TCHAR str[1000];
+    const TCHAR *p = *pp;
 
     if (*p == 0)
        return 0;
@@ -647,44 +654,44 @@ static void clear_id (struct uae_input_device *id)
     memset (id, 0, sizeof (struct uae_input_device));
 }
 
-void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value)
+void read_inputdevice_config (struct uae_prefs *pr, TCHAR *option, TCHAR *value)
 {
     struct uae_input_device *id = 0;
     struct inputevent *ie;
     int devnum, num, button, joystick, flags, i, subnum, idnum, keynum;
     int mask;
-    char *p, *p2, *custom;
+    TCHAR *p, *p2, *custom;
 
     option += 6; /* "input." */
     p = getstring (&option);
-    if (!strcasecmp (p, "config"))
-       pr->input_selected_setting = atol (value);
-    if (!strcasecmp (p, "joymouse_speed_analog"))
-       pr->input_joymouse_multiplier = atol (value);
-    if (!strcasecmp (p, "joymouse_speed_digital"))
-       pr->input_joymouse_speed = atol (value);
-    if (!strcasecmp (p, "joystick_deadzone"))
-       pr->input_joystick_deadzone = atol (value);
-    if (!strcasecmp (p, "joymouse_deadzone"))
-       pr->input_joymouse_deadzone = atol (value);
-    if (!strcasecmp (p, "mouse_speed"))
-       pr->input_mouse_speed = atol (value);
-    if (!strcasecmp (p, "autofire"))
-       pr->input_autofire_framecnt = atol (value);
-    if (!strcasecmp (p, "analog_joystick_multiplier"))
-       pr->input_analog_joystick_mult = atol (value);
-    if (!strcasecmp (p, "analog_joystick_offset"))
-       pr->input_analog_joystick_offset = atol (value);
-
-    idnum = atol (p);
+    if (!strcasecmp (p, L"config"))
+       pr->input_selected_setting = _tstol (value);
+    if (!strcasecmp (p, L"joymouse_speed_analog"))
+       pr->input_joymouse_multiplier = _tstol (value);
+    if (!strcasecmp (p, L"joymouse_speed_digital"))
+       pr->input_joymouse_speed = _tstol (value);
+    if (!strcasecmp (p, L"joystick_deadzone"))
+       pr->input_joystick_deadzone = _tstol (value);
+    if (!strcasecmp (p, L"joymouse_deadzone"))
+       pr->input_joymouse_deadzone = _tstol (value);
+    if (!strcasecmp (p, L"mouse_speed"))
+       pr->input_mouse_speed = _tstol (value);
+    if (!strcasecmp (p, L"autofire"))
+       pr->input_autofire_framecnt = _tstol (value);
+    if (!strcasecmp (p, L"analog_joystick_multiplier"))
+       pr->input_analog_joystick_mult = _tstol (value);
+    if (!strcasecmp (p, L"analog_joystick_offset"))
+       pr->input_analog_joystick_offset = _tstol (value);
+
+    idnum = _tstol (p);
     if (idnum <= 0 || idnum > MAX_INPUT_SETTINGS)
        return;
 
-    if (memcmp (option, "mouse.", 6) == 0) {
+    if (_tcsncmp (option, L"mouse.", 6) == 0) {
        p = option + 6;
-    } else if (memcmp (option, "joystick.", 9) == 0) {
+    } else if (_tcsncmp (option, L"joystick.", 9) == 0) {
        p = option + 9;
-    } else if (memcmp (option, "keyboard.", 9) == 0) {
+    } else if (_tcsncmp (option, L"keyboard.", 9) == 0) {
        p = option + 9;
     } else
        return;
@@ -697,37 +704,37 @@ void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value)
     if (!p2)
        return;
 
-    if (memcmp (option, "mouse.", 6) == 0) {
+    if (_tcsncmp (option, L"mouse.", 6) == 0) {
        id = &pr->mouse_settings[idnum][devnum];
        joystick = 0;
-    } else if (memcmp (option, "joystick.", 9) == 0) {
+    } else if (_tcsncmp (option, L"joystick.", 9) == 0) {
        id = &pr->joystick_settings[idnum][devnum];
        joystick = 1;
-    } else if (memcmp (option, "keyboard.", 9) == 0) {
+    } else if (_tcsncmp (option, L"keyboard.", 9) == 0) {
        id = &pr->keyboard_settings[idnum][devnum];
        joystick = -1;
     }
     if (!id)
        return;
 
-    if (!strcmp (p2, "name")) {
+    if (!_tcscmp (p2, L"name")) {
        xfree (id->configname);
        id->configname = my_strdup (value);
        return;
     }
-    if (!strcmp (p2, "friendlyname")) {
+    if (!_tcscmp (p2, L"friendlyname")) {
        xfree (id->name);
        id->name = my_strdup (value);
        return;
     }
 
-    if (!strcmp (p2, "empty")) {
+    if (!_tcscmp (p2, L"empty")) {
        clear_id (id);
        id->enabled = 1;
        return;
     }
 
-    if (!strcmp (p2, "disabled")) {
+    if (!_tcscmp (p2, L"disabled")) {
        int disabled;
        p = value;
        disabled = getnum (&p);
@@ -747,9 +754,9 @@ void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value)
            return;
     } else {
        button = -1;
-       if (!strcmp (p2, "axis"))
+       if (!_tcscmp (p2, L"axis"))
            button = 0;
-       else if(!strcmp (p2, "button"))
+       else if(!_tcscmp (p2, L"button"))
            button = 1;
        if (button < 0)
            return;
@@ -766,23 +773,23 @@ void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value)
            break;
        i = 1;
        while (events[i].name) {
-           if (!strcmp (events[i].confname, p2))
+           if (!_tcscmp (events[i].confname, p2))
                break;
            i++;
        }
        ie = &events[i];
        if (!ie->name) {
            ie = &events[0];
-           if (strlen (p2) > 2 && p2[0] == '\'' && p2[strlen (p2) - 1] == '\'') {
+           if (_tcslen (p2) > 2 && p2[0] == '\'' && p2[_tcslen (p2) - 1] == '\'') {
                custom = my_strdup (p2 + 1);
-               custom[strlen (custom) - 1] = 0;
+               custom[_tcslen (custom) - 1] = 0;
            }
        }
        flags = 0;
        if (p[-1] == '.')
            flags = getnum (&p);
        if (custom == NULL && ie->name == NULL) {
-           if (!strcmp(p2, "NULL")) {
+           if (!_tcscmp(p2, L"NULL")) {
                if (joystick < 0) {
                    id->eventid[keynum][subnum] = 0;
                    id->flags[keynum][subnum] = 0;
@@ -843,7 +850,7 @@ int mousehack_alive (void)
     return mousehack_alive_cnt > 0 ? mousehack_alive_cnt : 0;
 }
 
-static uaecptr get_base (const char *name)
+static uaecptr get_base (const TCHAR *name)
 {
     uaecptr v = get_long (4);
     addrbank *b = &get_mem_bank(v);
@@ -864,7 +871,7 @@ static uaecptr get_base (const char *name)
        if (b->flags != ABFLAG_ROM && b->flags != ABFLAG_RAM)
            return 0;
        p = b->xlateaddr(v2);
-       if (!memcmp(p, name, strlen(name) + 1))
+       if (!memcmp (p, name, _tcslen (name) + 1))
            return v;
     }
     return 0;
@@ -876,7 +883,7 @@ static uaecptr get_intuitionbase (void)
        return 0;
     if (magicmouse_ibase)
        return magicmouse_ibase;
-    magicmouse_ibase = get_base ("intuition.library");
+    magicmouse_ibase = get_base (L"intuition.library");
     return magicmouse_ibase;
 }
 static uaecptr get_gfxbase (void)
@@ -885,7 +892,7 @@ static uaecptr get_gfxbase (void)
        return 0;
     if (magicmouse_gfxbase)
        return magicmouse_gfxbase;
-    magicmouse_gfxbase = get_base ("graphics.library");
+    magicmouse_gfxbase = get_base (L"graphics.library");
     return magicmouse_gfxbase;
 }
 
@@ -961,7 +968,7 @@ static void mousehack_enable (void)
        mode |= 1;
     if (inputdevice_is_tablet () > 0)
        mode |= 2;
-    write_log ("Tablet driver enabled (%s)\n", ((mode & 3) == 3 ? "tablet+mousehack" : ((mode & 3) == 2) ? "tablet" : "mousehack"));
+    write_log (L"Tablet driver enabled (%s)\n", ((mode & 3) == 3 ? "tablet+mousehack" : ((mode & 3) == 2) ? "tablet" : "mousehack"));
     rtarea[off + MH_E] = 0x80;
 }
 
@@ -969,7 +976,6 @@ void input_mousehack_mouseoffset (uaecptr pointerprefs)
 {
     mouseoffset_x = (uae_s16)get_word (pointerprefs + 28);
     mouseoffset_y = (uae_s16)get_word (pointerprefs + 30);
-    write_log ("MO: %dx%d\n", mouseoffset_x, mouseoffset_y);
 }
 
 void input_mousehack_status (int mode, uaecptr diminfo, uaecptr dispinfo, uaecptr vp, uae_u32 moffset)
@@ -978,7 +984,7 @@ void input_mousehack_status (int mode, uaecptr diminfo, uaecptr dispinfo, uaecpt
        uae_u8 v = rtarea[12 + get_long (rtarea_base + 36)];
        v |= 0x40;
        rtarea[12 + get_long (rtarea_base + 36)] = v;
-       write_log ("Tablet driver running (%02x)\n", v);
+       write_log (L"Tablet driver running (%02x)\n", v);
     } else if (mode == 1) {
         int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
        uae_u32 props = 0;
@@ -1001,7 +1007,7 @@ void input_mousehack_status (int mode, uaecptr diminfo, uaecptr dispinfo, uaecpt
        if (dispinfo)
            props = get_long (dispinfo + 18);
        dimensioninfo_dbl = (props & 0x00020000) ? 1 : 0;
-       write_log ("%08x %08x %08x (%dx%d)-(%dx%d) d=%dx%d %s\n",
+       write_log (L"%08x %08x %08x (%dx%d)-(%dx%d) d=%dx%d %s\n",
            diminfo, props, vp, x1, y1, x2, y2, vp_xoffset, vp_yoffset,
            (props & 0x00020000) ? "dbl" : "");
     } else if (mode == 2) {
@@ -1038,7 +1044,7 @@ void inputdevice_tablet (int x, int y, int z, int pressure, uae_u32 buttonbits,
     mousehack_enable ();
     if (inputdevice_is_tablet () <= 0)
        return;
-    //write_log ("%d %d %d %d %08X %d %d %d %d\n", x, y, z, pressure, buttonbits, inproximity, ax, ay, az);
+    //write_log (L"%d %d %d %d %08X %d %d %d %d\n", x, y, z, pressure, buttonbits, inproximity, ax, ay, az);
     off = 12 + get_long (rtarea_base + 36);
     p = rtarea + off;
 
@@ -1228,7 +1234,7 @@ static void inputdevice_mh_abs_v36 (int x, int y)
        uaecptr gb = get_intuitionbase ();
        maxy = get_word (gb + 1344 + 2);
        maxx = get_word (gb + 1348 + 2);
-       write_log ("%d %d\n", maxx, maxy);
+       write_log (L"%d %d\n", maxx, maxy);
     }
 #endif
 #if 1
@@ -1243,7 +1249,7 @@ static void inputdevice_mh_abs_v36 (int x, int y)
                h = get_word (vp + 26) * 2;
                dw = get_word (vp + 28);
                dh = get_word (vp + 30);
-               //write_log ("%d %d %d %d\n", w, h, dw, dh);
+               //write_log (L"%d %d %d %d\n", w, h, dw, dh);
                if (w < maxx)
                    maxx = w;
                if (h < maxy)
@@ -1252,9 +1258,9 @@ static void inputdevice_mh_abs_v36 (int x, int y)
                y -= dh;
            }
        }
-       //write_log ("* %d %d\n", get_word (gb + 218), get_word (gb + 216));
+       //write_log (L"* %d %d\n", get_word (gb + 218), get_word (gb + 216));
     }
-    //write_log ("%d %d\n", maxx, maxy);
+    //write_log (L"%d %d\n", maxx, maxy);
 #endif
 
     maxx = maxx * 1000 / fmx;
@@ -1277,7 +1283,7 @@ static void inputdevice_mh_abs_v36 (int x, int y)
     if (y >= maxy)
        y = maxy - 1;
 
-    //write_log ("%d %d %d %d\n", x, y, maxx, maxy);
+    //write_log (L"%d %d %d %d\n", x, y, maxx, maxy);
 
     p[MH_X] = x >> 8;
     p[MH_X + 1] = x;
@@ -1585,7 +1591,7 @@ int getjoystate (int joy)
     uae_u16 v = 0;
 
     if (inputdevice_logging & 2)
-       write_log ("JOY%dDAT %08x\n", joy, M68K_GETPC);
+       write_log (L"JOY%dDAT %08x\n", joy, M68K_GETPC);
     readinput ();
     if (joydir[joy] & DIR_LEFT)
        left = 1;
@@ -1608,7 +1614,7 @@ int getjoystate (int joy)
     }
 #ifdef DONGLE_DEBUG
     if (notinrom ())
-       write_log ("JOY%dDAT %04X %s\n", joy, v, debuginfo (0));
+       write_log (L"JOY%dDAT %04X %s\n", joy, v, debuginfo (0));
 #endif
     if (input_recording > 0 && oldjoy[joy] != v) {
        oldjoy[joy] = v;
@@ -1650,7 +1656,7 @@ void JOYTEST (uae_u16 v)
     mouse_frame_x[1] = mouse_x[1];
     mouse_frame_y[1] = mouse_y[1];
     if (inputdevice_logging & 2)
-       write_log ("JOYTEST: %04X PC=%x\n", v , M68K_GETPC);
+       write_log (L"JOYTEST: %04X PC=%x\n", v , M68K_GETPC);
 }
 
 static uae_u8 parconvert (uae_u8 v, int jd, int shift)
@@ -1791,7 +1797,7 @@ uae_u8 handle_joystick_buttons (uae_u8 dra)
        }
     }
     if (inputdevice_logging & 4)
-       write_log ("BFE001: %02X:%02X %x\n", dra, but, M68K_GETPC);
+       write_log (L"BFE001: %02X:%02X %x\n", dra, but, M68K_GETPC);
     return but;
 }
 
@@ -1886,7 +1892,7 @@ static uae_u16 POTDAT (int joy)
 {
     uae_u16 v = (pot_dat[joy][1] << 8) | pot_dat[joy][0];
     if (inputdevice_logging & 16)
-       write_log ("POTDAT%d: %04X %08X\n", joy, v, M68K_GETPC);
+       write_log (L"POTDAT%d: %04X %08X\n", joy, v, M68K_GETPC);
     return v;
 }
 
@@ -1911,10 +1917,10 @@ void POTGO (uae_u16 v)
     int i, j;
 
     if (inputdevice_logging & 16)
-       write_log ("POTGO_W: %04X %08X\n", v, M68K_GETPC);
+       write_log (L"POTGO_W: %04X %08X\n", v, M68K_GETPC);
 #ifdef DONGLE_DEBUG
     if (notinrom ())
-       write_log ("POTGO %04X %s\n", v, debuginfo(0));
+       write_log (L"POTGO %04X %s\n", v, debuginfo(0));
 #endif
     potgo_value = potgo_value & 0x5500; /* keep state of data bits */
     potgo_value |= v & 0xaa00; /* get new direction bits */
@@ -1949,10 +1955,10 @@ uae_u16 POTGOR (void)
     uae_u16 v = handle_joystick_potgor (potgo_value) & 0x5500;
 #ifdef DONGLE_DEBUG
     if (notinrom ())
-       write_log ("POTGOR %04X %s\n", v, debuginfo(0));
+       write_log (L"POTGOR %04X %s\n", v, debuginfo(0));
 #endif
     if (inputdevice_logging & 16)
-       write_log ("POTGO_R: %04X %08X %d\n", v, M68K_GETPC, cd32_shifter[1]);
+       write_log (L"POTGO_R: %04X %08X %d\n", v, M68K_GETPC, cd32_shifter[1]);
     return v;
 }
 
@@ -1987,7 +1993,7 @@ static void queue_input_event (int event, int state, int max, int framecnt, int
            if (iq->framecnt < 0) break;
        }
        if (i == INPUT_QUEUE_SIZE) {
-           write_log ("input queue overflow\n");
+           write_log (L"input queue overflow\n");
            return;
        }
        iq->event = event;
@@ -2037,7 +2043,7 @@ void inputdevice_do_keyboard (int code, int state)
        }
        record_key ((uae_u8)((key << 1) | (key >> 7)));
        if (inputdevice_logging & 1)
-           write_log ("Amiga key %02X %d\n", key & 0x7f, key >> 7);
+           write_log (L"Amiga key %02X %d\n", key & 0x7f, key >> 7);
        return;
     }
     inputdevice_add_inputcode (code, state);
@@ -2053,7 +2059,7 @@ void inputdevice_handle_inputcode (void)
     if (code == 0)
        return;
     if (vpos != 0)
-       write_log ("inputcode=%d but vpos = %d", code, vpos);
+       write_log (L"inputcode=%d but vpos = %d", code, vpos);
 
 #ifdef ARCADIA
     switch (code)
@@ -2233,7 +2239,7 @@ void inputdevice_handle_inputcode (void)
     case AKS_DISKSWAPPER_INSERT1:
     case AKS_DISKSWAPPER_INSERT2:
     case AKS_DISKSWAPPER_INSERT3:
-       strcpy (changed_prefs.df[code - AKS_DISKSWAPPER_INSERT0], currprefs.dfxlist[swapperslot]);
+       _tcscpy (changed_prefs.df[code - AKS_DISKSWAPPER_INSERT0], currprefs.dfxlist[swapperslot]);
     break;
 
     break;
@@ -2247,15 +2253,15 @@ void inputdevice_handle_inputcode (void)
     }
 }
 
-int handle_custom_event (char *custom)
+int handle_custom_event (TCHAR *custom)
 {
-    char *p, *buf, *nextp;
+    TCHAR *p, *buf, *nextp;
 
     if (custom == NULL)
        return 0;
     p = buf = my_strdup (custom);
     while (p && *p) {
-       char *p2;
+       TCHAR *p2;
        if (*p != '\"')
            break;
        p++;
@@ -2284,7 +2290,7 @@ int handle_input_event (int nr, int state, int max, int autofire)
        return 0;
     ie = &events[nr];
     if (inputdevice_logging & 1)
-       write_log ("'%s' %d %d\n", ie->name, state, max);
+       write_log (L"'%s' %d %d\n", ie->name, state, max);
     if (autofire) {
        if (state)
            queue_input_event (nr, state, max, currprefs.input_autofire_framecnt, 1);
@@ -2451,7 +2457,7 @@ void inputdevice_vsync (void)
     int i;
 
     if (inputdevice_logging & 32)
-       write_log ("*\n");
+       write_log (L"*\n");
 
     for (i = 0; i < INPUT_QUEUE_SIZE; i++) {
        iq = &input_queue[i];
@@ -2530,7 +2536,7 @@ static int switchdevice (struct uae_input_device *id, int num, int button)
     int ismouse = 0;
     int newport = 0;
     int flags = 0;
-    char *name = NULL;
+    TCHAR *name = NULL;
     int otherbuttonpressed = 0;
 
     if (num >= 4)
@@ -2571,7 +2577,7 @@ static int switchdevice (struct uae_input_device *id, int num, int button)
            if (flags)
                return 0;
            if (name) {
-               write_log ("inputdevice change '%s':%d->%d\n", name, num, newport);
+               write_log (L"inputdevice change '%s':%d->%d\n", name, num, newport);
                inputdevice_joyport_config (&changed_prefs, name, newport, 2);
                inputdevice_copyconfig (&changed_prefs, &currprefs);
                return 1;
@@ -2631,7 +2637,7 @@ static int switchdevice (struct uae_input_device *id, int num, int button)
                }
            }
        }
-        write_log ("inputdevice change '%s':%d->%d\n", name, num, newport);
+        write_log (L"inputdevice change '%s':%d->%d\n", name, num, newport);
        inputdevice_copyconfig (&currprefs, &changed_prefs);
        inputdevice_copyconfig (&changed_prefs, &currprefs);
        return 1;
@@ -2643,7 +2649,7 @@ static void process_custom_event (struct uae_input_device *id, int offset, int s
 {
     int idx = -1;
     int custompos = (id->flags[offset][0] >> 15) & 1;
-    char *custom;
+    TCHAR *custom;
 
     if (state < 0) {
        idx = 0;
@@ -2915,14 +2921,14 @@ static void compatibility_mode (struct uae_prefs *prefs)
     if ((joy = jsem_ismouse (0, prefs)) >= 0) {
        input_get_default_mouse (mice, joy, 0);
        mice[joy].enabled = 1;
-       strncpy (prefs->jports[0].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       strncpy (prefs->jports[0].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[0].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[0].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
     }
     if ((joy = jsem_ismouse (1, prefs)) >= 0) {
        input_get_default_mouse (mice, joy, 1);
        mice[joy].enabled = 1;
-       strncpy (prefs->jports[1].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       strncpy (prefs->jports[1].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[1].name, idev[IDTYPE_MOUSE].get_friendlyname (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[1].configname, idev[IDTYPE_MOUSE].get_uniquename (joy), MAX_JPORTNAME - 1);
     }
 
     joy = jsem_isjoy (1, prefs);
@@ -2930,8 +2936,8 @@ static void compatibility_mode (struct uae_prefs *prefs)
        used[joy] = 1;
        input_get_default_joystick (joysticks, joy, 1);
        joysticks[joy].enabled = 1;
-       strncpy (prefs->jports[1].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       strncpy (prefs->jports[1].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[1].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[1].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
     }
 
     joy = jsem_isjoy (0, prefs);
@@ -2939,8 +2945,8 @@ static void compatibility_mode (struct uae_prefs *prefs)
        used[joy] = 1;
        input_get_default_joystick (joysticks, joy, 0);
        joysticks[joy].enabled = 1;
-       strncpy (prefs->jports[0].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
-       strncpy (prefs->jports[0].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[0].name, idev[IDTYPE_JOYSTICK].get_friendlyname (joy), MAX_JPORTNAME - 1);
+       _tcsncpy (prefs->jports[0].configname, idev[IDTYPE_JOYSTICK].get_uniquename (joy), MAX_JPORTNAME - 1);
    }
 
     for (joy = 0; used[joy]; joy++);
@@ -2976,22 +2982,22 @@ static void matchdevices (struct inputdevice_functions *inf, struct uae_input_de
     int i, j;
 
     for (i = 0; i < inf->get_num (); i++) {
-       char *aname1 = inf->get_friendlyname (i);
-       char *aname2 = inf->get_uniquename (i);
+       TCHAR *aname1 = inf->get_friendlyname (i);
+       TCHAR *aname2 = inf->get_uniquename (i);
         int match = -1;
        for (j = 0; j < MAX_INPUT_DEVICES; j++) {
            if (aname2 && uid[j].configname) {
-               char bname[MAX_DPATH];
-               char bname2[MAX_DPATH];
-               char *p1 ,*p2;
-               strcpy (bname, uid[j].configname);
-               strcpy (bname2, aname2);
-               p1 = strchr (bname, ' ');
-               p2 = strchr (bname2, ' ');
+               TCHAR bname[MAX_DPATH];
+               TCHAR bname2[MAX_DPATH];
+               TCHAR *p1 ,*p2;
+               _tcscpy (bname, uid[j].configname);
+               _tcscpy (bname2, aname2);
+               p1 = _tcschr (bname, ' ');
+               p2 = _tcschr (bname2, ' ');
                if (p1 && p2 && p1 - bname == p2 - bname2) {
                    *p1 = 0;
                    *p2 = 0;
-                   if (bname && !strcmp (bname2, bname)) {
+                   if (bname && !_tcscmp (bname2, bname)) {
                        if (match >= 0)
                            match = -2;
                        else
@@ -3005,15 +3011,15 @@ static void matchdevices (struct inputdevice_functions *inf, struct uae_input_de
        // multiple matches -> use complete local-only id string for comparisons
        if (match == -2) {
            for (j = 0; j < MAX_INPUT_DEVICES; j++) {
-               char *bname = uid[j].configname;
-               if (aname2 && bname && !strcmp (aname2, bname))
+               TCHAR *bname = uid[j].configname;
+               if (aname2 && bname && !_tcscmp (aname2, bname))
                    match = j;
            }
        }
        if (match < 0) {
            for (j = 0; j < MAX_INPUT_DEVICES; j++) {
-               char *bname = uid[j].name;
-               if (aname2 && bname && !strcmp (aname2, bname))
+               TCHAR *bname = uid[j].name;
+               if (aname2 && bname && !_tcscmp (aname2, bname))
                    match = j;
            }
        }
@@ -3115,7 +3121,7 @@ void inputdevice_devicechange (struct uae_prefs *prefs)
 {
     int acc = input_acquired;
     int i, idx;
-    char *jports[2];
+    TCHAR *jports[2];
 
     for (i = 0; i < 2; i++) {
        jports[i] = 0;
@@ -3180,7 +3186,7 @@ static void set_kbr_default (struct uae_prefs *p, int index, int num)
                            if (kbr->eventid[i][k] == 0) break;
                        }
                        if (k == MAX_INPUT_SUB_EVENT) {
-                           write_log ("corrupt default keyboard mappings\n");
+                           write_log (L"corrupt default keyboard mappings\n");
                            return;
                        }
                        kbr->eventid[i][k] = trans[l].event;
@@ -3315,7 +3321,7 @@ static struct uae_input_device *get_uid (const struct inputdevice_functions *id,
     return uid;
 }
 
-static int get_event_data (const struct inputdevice_functions *id, int devnum, int num, int *eventid, char **custom, int *flags, int sub)
+static int get_event_data (const struct inputdevice_functions *id, int devnum, int num, int *eventid, TCHAR **custom, int *flags, int sub)
 {
     const struct uae_input_device *uid = get_uid (id, devnum);
     int type = id->get_widget_type (devnum, num, 0, 0);
@@ -3342,7 +3348,7 @@ static int get_event_data (const struct inputdevice_functions *id, int devnum, i
     return -1;
 }
 
-static int put_event_data (const struct inputdevice_functions *id, int devnum, int num, int eventid, char *custom, int flags, int sub)
+static int put_event_data (const struct inputdevice_functions *id, int devnum, int num, int eventid, TCHAR *custom, int flags, int sub)
 {
     struct uae_input_device *uid = get_uid (id, devnum);
     int type = id->get_widget_type (devnum, num, 0, 0);
@@ -3376,7 +3382,7 @@ static int is_event_used (const struct inputdevice_functions *id, int devnum, in
 {
     struct uae_input_device *uid = get_uid (id, devnum);
     int num, evt, flag, sub;
-    char *custom;
+    TCHAR *custom;
 
     for (num = 0; num < id->get_widget_num (devnum); num++) {
        for (sub = 0; sub < MAX_INPUT_SUB_EVENT; sub++) {
@@ -3428,12 +3434,12 @@ int inputdevice_get_device_total (int type)
     return idev[type].get_num ();
 }
 /* returns the name of device */
-char *inputdevice_get_device_name (int type, int devnum)
+TCHAR *inputdevice_get_device_name (int type, int devnum)
 {
     return idev[type].get_friendlyname (devnum);
 }
 /* returns machine readable name of device */
-char *inputdevice_get_device_unique_name (int type, int devnum)
+TCHAR *inputdevice_get_device_unique_name (int type, int devnum)
 {
     return idev[type].get_uniquename (devnum);
 }
@@ -3460,24 +3466,24 @@ int inputdevice_get_widget_num (int devnum)
     return idf->get_widget_num (inputdevice_get_device_index (devnum));
 }
 
-static void get_ename (const struct inputevent *ie, char *out)
+static void get_ename (const struct inputevent *ie, TCHAR *out)
 {
     if (!out)
        return;
     if (ie->allow_mask == AM_K)
-       sprintf (out, "%s (0x%02X)", ie->name, ie->data);
+       _stprintf (out, L"%s (0x%02X)", ie->name, ie->data);
     else
-       strcpy (out, ie->name);
+       _tcscpy (out, ie->name);
 }
 
-int inputdevice_iterate (int devnum, int num, char *name, int *af)
+int inputdevice_iterate (int devnum, int num, TCHAR *name, int *af)
 {
     const struct inputdevice_functions *idf = getidf (devnum);
     static int id_iterator;
     struct inputevent *ie;
     int mask, data, flags, type;
     int devindex = inputdevice_get_device_index (devnum);
-    char *custom;
+    TCHAR *custom;
 
     *af = 0;
     *name = 0;
@@ -3527,16 +3533,16 @@ int inputdevice_iterate (int devnum, int num, char *name, int *af)
     }
 }
 
-int inputdevice_get_mapped_name (int devnum, int num, int *pflags, char *name, char *custom, int sub)
+int inputdevice_get_mapped_name (int devnum, int num, int *pflags, TCHAR *name, TCHAR *custom, int sub)
 {
     const struct inputdevice_functions *idf = getidf (devnum);
     const struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum));
     int flags = 0, flag, data;
     int devindex = inputdevice_get_device_index (devnum);
-    char *customp = NULL;
+    TCHAR *customp = NULL;
 
     if (name)
-       strcpy (name, "<none>");
+       _tcscpy (name, L"<none>");
     if (custom)
        custom[0] = 0;
     if (pflags)
@@ -3546,7 +3552,7 @@ int inputdevice_get_mapped_name (int devnum, int num, int *pflags, char *name, c
     if (get_event_data (idf, devindex, num, &data, &customp, &flag, sub) < 0)
        return 0;
     if (customp && custom)
-       strcpy (custom, customp);
+       _tcscpy (custom, customp);
     if (flag & ID_FLAG_AUTOFIRE)
        flags |= IDEV_MAPPED_AUTOFIRE_SET;
     if (!data)
@@ -3559,14 +3565,14 @@ int inputdevice_get_mapped_name (int devnum, int num, int *pflags, char *name, c
     return data;
 }
 
-int inputdevice_set_mapping (int devnum, int num, char *name, char *custom, int af, int sub)
+int inputdevice_set_mapping (int devnum, int num, TCHAR *name, TCHAR *custom, int af, int sub)
 {
     const struct inputdevice_functions *idf = getidf (devnum);
     const struct uae_input_device *uid = get_uid (idf, inputdevice_get_device_index (devnum));
     int eid, data, flag, amask;
-    char ename[256];
+    TCHAR ename[256];
     int devindex = inputdevice_get_device_index (devnum);
-    char *customp = NULL;
+    TCHAR *customp = NULL;
 
     if (uid == 0 || num < 0)
        return 0;
@@ -3574,7 +3580,7 @@ int inputdevice_set_mapping (int devnum, int num, char *name, char *custom, int
        eid = 1;
        while (events[eid].name) {
            get_ename (&events[eid], ename);
-           if (!strcmp(ename, name)) break;
+           if (!_tcscmp(ename, name)) break;
            eid++;
        }
        if (!events[eid].name)
@@ -3597,7 +3603,7 @@ int inputdevice_set_mapping (int devnum, int num, char *name, char *custom, int
     return 0;
 }
 
-int inputdevice_get_widget_type (int devnum, int num, char *name)
+int inputdevice_get_widget_type (int devnum, int num, TCHAR *name)
 {
     const struct inputdevice_functions *idf = getidf (devnum);
     return idf->get_widget_type (inputdevice_get_device_index (devnum), num, name, 0);
@@ -3701,7 +3707,7 @@ void inputdevice_acquire (int allmode)
            idev[IDTYPE_KEYBOARD].acquire (i, 0);
     }
 //    if (!input_acquired)
-//     write_log ("input devices acquired (%s)\n", allmode ? "all" : "selected only");
+//     write_log (L"input devices acquired (%s)\n", allmode ? "all" : "selected only");
     input_acquired = 1;
 }
 
@@ -3710,7 +3716,7 @@ void inputdevice_unacquire (void)
     int i;
 
 //    if (input_acquired)
-//     write_log ("input devices unacquired\n");
+//     write_log (L"input devices unacquired\n");
     input_acquired = 0;
     for (i = 0; i < MAX_INPUT_DEVICES; i++)
        idev[IDTYPE_JOYSTICK].unacquire (i);
@@ -3722,11 +3728,11 @@ void inputdevice_unacquire (void)
 
 static void testrecord (int type, int num, int wtype, int wnum, int state)
 {
-    char tmp[2000];
+    TCHAR tmp[2000];
     tmp[0] = 0;
     wnum += idev[type].get_widget_first (num, wtype);
     idev[type].get_widget_type (num, wnum, tmp, NULL);
-    write_log ("%s: %s %d\n", idev[type].get_friendlyname (num), tmp, state);
+    write_log (L"%s: %s %d\n", idev[type].get_friendlyname (num), tmp, state);
 }
 
 int inputdevice_istest (void)
@@ -3734,7 +3740,7 @@ int inputdevice_istest (void)
     return testmode;
 }
 
-int inputdevice_testread (char *name)
+int inputdevice_testread (TCHAR *name)
 {
     testmode = 1;
     idev[IDTYPE_KEYBOARD].read ();
@@ -3946,7 +3952,7 @@ void warpmode (int mode)
 {
     int fr, fr2;
     
-    write_log ("%d %d %d\n", currprefs.gfx_framerate, turbo_emulation, mode);
+    write_log (L"%d %d %d\n", currprefs.gfx_framerate, turbo_emulation, mode);
 
     fr = currprefs.gfx_framerate;
     if (fr == 0)
@@ -4023,7 +4029,7 @@ int jsem_iskbdjoy (int port, const struct uae_prefs *p)
     return v;
 }
 
-int inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, int type)
+int inputdevice_joyport_config (struct uae_prefs *p, TCHAR *value, int portnum, int type)
 {
     switch (type)
     {
@@ -4041,9 +4047,9 @@ int inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, i
                }
                idf = &idev[type];
                for (i = 0; i < idf->get_num (); i++) {
-                   char *name1 = idf->get_friendlyname (i);
-                   char *name2 = idf->get_uniquename (i);
-                   if ((name1 && !strcmp (name1, value)) || (name2 && !strcmp (name2, value))) {
+                   TCHAR *name1 = idf->get_friendlyname (i);
+                   TCHAR *name2 = idf->get_uniquename (i);
+                   if ((name1 && !_tcscmp (name1, value)) || (name2 && !_tcscmp (name2, value))) {
                        p->jports[portnum].id = idnum + i;
                        return 1;
                    }
@@ -4054,25 +4060,25 @@ int inputdevice_joyport_config (struct uae_prefs *p, char *value, int portnum, i
        case 0:
        {
            int start = -1, got = 0;
-           char *pp = 0;
-           if (strncmp (value, "kbd", 3) == 0) {
+           TCHAR *pp = 0;
+           if (_tcsncmp (value, L"kbd", 3) == 0) {
                start = JSEM_KBDLAYOUT;
                pp = value + 3;
                got = 1;
-           } else if (strncmp (value, "joy", 3) == 0) {
+           } else if (_tcsncmp (value, L"joy", 3) == 0) {
                start = JSEM_JOYS;
                pp = value + 3;
                got = 1;
-           } else if (strncmp (value, "mouse", 5) == 0) {
+           } else if (_tcsncmp (value, L"mouse", 5) == 0) {
                start = JSEM_MICE;
                pp = value + 5;
                got = 1;
-           } else if (strcmp (value, "none") == 0) {
+           } else if (_tcscmp (value, L"none") == 0) {
                got = 2;
            }
            if (got) {
                if (pp) {
-                   int v = atol (pp);
+                   int v = _tstol (pp);
                    if (start >= 0) {
                        if (start == JSEM_KBDLAYOUT && v > 0)
                            v--;
index f94c901ba42d9c740344a84922c14d3cb880fa56..cd47279f53778dc58e18d96f98a73801854bf0c9 100644 (file)
 /* joystick/mouse port 1 */
 
-DEFEVENT(JOYPORT1_START,"Joystick port 1", AM_INFO, 0,1,0)
-
-DEFEVENT(MOUSE1_FIRST, "", AM_DUMMY, 0,0,0)
-
-DEFEVENT(MOUSE1_HORIZ,"Mouse1 Horizontal",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,0)
-DEFEVENT(MOUSE1_VERT,"Mouse1 Vertical",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,1)
-DEFEVENT(MOUSE1_HORIZ_INV,"Mouse1 Horizontal (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,0|IE_INVERT)
-DEFEVENT(MOUSE1_VERT_INV,"Mouse1 Vertical (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,1|IE_INVERT)
-
-DEFEVENT(MOUSE1_LAST, "", AM_DUMMY, 0,0,0)
-
-DEFEVENT(MOUSE1_UP,"Mouse1 Up",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,1,DIR_UP)
-DEFEVENT(MOUSE1_DOWN,"Mouse1 Down",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,1,DIR_DOWN)
-DEFEVENT(MOUSE1_LEFT,"Mouse1 Left",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,1,DIR_LEFT)
-DEFEVENT(MOUSE1_RIGHT,"Mouse1 Right",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,1,DIR_RIGHT)
-
-DEFEVENT(MOUSE1_WHEEL,"Mouse1 Wheel",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,2)
-
-DEFEVENT(JOY1_HORIZ,"Joy1 Horizontal",AM_JOY_AXIS,0,1,DIR_LEFT|DIR_RIGHT)
-DEFEVENT(JOY1_VERT,"Joy1 Vertical",AM_JOY_AXIS,0,1,DIR_UP|DIR_DOWN)
-DEFEVENT(JOY1_HORIZ_POT,"Joy1 Horizontal (Analog)",AM_JOY_AXIS,128,1,1)
-DEFEVENT(JOY1_VERT_POT,"Joy1 Vertical (Analog)",AM_JOY_AXIS,128,1,0)
-DEFEVENT(JOY1_HORIZ_POT_INV,"Joy1 Horizontal (Analog, inverted)",AM_JOY_AXIS,128,1,1|IE_INVERT)
-DEFEVENT(JOY1_VERT_POT_INV,"Joy1 Vertical (Analog, inverted)",AM_JOY_AXIS,128,1,0|IE_INVERT)
-
-DEFEVENT(JOY1_LEFT,"Joy1 Left",AM_K,16,1,DIR_LEFT)
-DEFEVENT(JOY1_RIGHT,"Joy1 Right",AM_K,16,1,DIR_RIGHT)
-DEFEVENT(JOY1_UP,"Joy1 Up",AM_K,16,1,DIR_UP)
-DEFEVENT(JOY1_DOWN,"Joy1 Down",AM_K,16,1,DIR_DOWN)
-DEFEVENT(JOY1_LEFT_UP,"Joy1 Left+Up",AM_K,16,1,DIR_LEFT|DIR_UP)
-DEFEVENT(JOY1_LEFT_DOWN,"Joy1 Left+Down",AM_K,16,1,DIR_LEFT|DIR_DOWN)
-DEFEVENT(JOY1_RIGHT_UP,"Joy1 Right+Up",AM_K,16,1,DIR_RIGHT|DIR_UP)
-DEFEVENT(JOY1_RIGHT_DOWN,"Joy1 Right+Down",AM_K,16,1,DIR_RIGHT|DIR_DOWN)
-
-DEFEVENT(JOY1_FIRE_BUTTON,"Joy1 Fire/Mouse1 Left Button",AM_K,4,1,JOYBUTTON_1)
-DEFEVENT(JOY1_2ND_BUTTON,"Joy1 2nd Button/Mouse1 Right Button",AM_K,4,1,JOYBUTTON_2)
-DEFEVENT(JOY1_3RD_BUTTON,"Joy1 3rd Button/Mouse1 Middle Button",AM_K,4,1,JOYBUTTON_3)
-DEFEVENT(JOY1_CD32_PLAY,"Joy1 CD32 Play",AM_K,4,1,JOYBUTTON_CD32_PLAY)
-DEFEVENT(JOY1_CD32_RWD,"Joy1 CD32 RWD",AM_K,4,1,JOYBUTTON_CD32_RWD)
-DEFEVENT(JOY1_CD32_FFW,"Joy1 CD32 FFW",AM_K,4,1,JOYBUTTON_CD32_FFW)
-DEFEVENT(JOY1_CD32_GREEN,"Joy1 CD32 Green",AM_K,4,1,JOYBUTTON_CD32_GREEN)
-DEFEVENT(JOY1_CD32_YELLOW,"Joy1 CD32 Yellow",AM_K,4,1,JOYBUTTON_CD32_YELLOW)
-DEFEVENT(JOY1_CD32_RED,"Joy1 CD32 Red",AM_K,4,1,JOYBUTTON_CD32_RED)
-DEFEVENT(JOY1_CD32_BLUE,"Joy1 CD32 Blue",AM_K,4,1,JOYBUTTON_CD32_BLUE)
+DEFEVENT(JOYPORT1_START,L"Joystick port 1", AM_INFO, 0,1,0)
+
+DEFEVENT(MOUSE1_FIRST, L"", AM_DUMMY, 0,0,0)
+
+DEFEVENT(MOUSE1_HORIZ,L"Mouse1 Horizontal",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,0)
+DEFEVENT(MOUSE1_VERT,L"Mouse1 Vertical",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,1)
+DEFEVENT(MOUSE1_HORIZ_INV,L"Mouse1 Horizontal (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,0|IE_INVERT)
+DEFEVENT(MOUSE1_VERT_INV,L"Mouse1 Vertical (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,1|IE_INVERT)
+
+DEFEVENT(MOUSE1_LAST, L"", AM_DUMMY, 0,0,0)
+
+DEFEVENT(MOUSE1_UP,L"Mouse1 Up",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,1,DIR_UP)
+DEFEVENT(MOUSE1_DOWN,L"Mouse1 Down",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,1,DIR_DOWN)
+DEFEVENT(MOUSE1_LEFT,L"Mouse1 Left",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,1,DIR_LEFT)
+DEFEVENT(MOUSE1_RIGHT,L"Mouse1 Right",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,1,DIR_RIGHT)
+
+DEFEVENT(MOUSE1_WHEEL,L"Mouse1 Wheel",AM_MOUSE_AXIS|AM_JOY_AXIS,8,1,2)
+
+DEFEVENT(JOY1_HORIZ,L"Joy1 Horizontal",AM_JOY_AXIS,0,1,DIR_LEFT|DIR_RIGHT)
+DEFEVENT(JOY1_VERT,L"Joy1 Vertical",AM_JOY_AXIS,0,1,DIR_UP|DIR_DOWN)
+DEFEVENT(JOY1_HORIZ_POT,L"Joy1 Horizontal (Analog)",AM_JOY_AXIS,128,1,1)
+DEFEVENT(JOY1_VERT_POT,L"Joy1 Vertical (Analog)",AM_JOY_AXIS,128,1,0)
+DEFEVENT(JOY1_HORIZ_POT_INV,L"Joy1 Horizontal (Analog, inverted)",AM_JOY_AXIS,128,1,1|IE_INVERT)
+DEFEVENT(JOY1_VERT_POT_INV,L"Joy1 Vertical (Analog, inverted)",AM_JOY_AXIS,128,1,0|IE_INVERT)
+
+DEFEVENT(JOY1_LEFT,L"Joy1 Left",AM_K,16,1,DIR_LEFT)
+DEFEVENT(JOY1_RIGHT,L"Joy1 Right",AM_K,16,1,DIR_RIGHT)
+DEFEVENT(JOY1_UP,L"Joy1 Up",AM_K,16,1,DIR_UP)
+DEFEVENT(JOY1_DOWN,L"Joy1 Down",AM_K,16,1,DIR_DOWN)
+DEFEVENT(JOY1_LEFT_UP,L"Joy1 Left+Up",AM_K,16,1,DIR_LEFT|DIR_UP)
+DEFEVENT(JOY1_LEFT_DOWN,L"Joy1 Left+Down",AM_K,16,1,DIR_LEFT|DIR_DOWN)
+DEFEVENT(JOY1_RIGHT_UP,L"Joy1 Right+Up",AM_K,16,1,DIR_RIGHT|DIR_UP)
+DEFEVENT(JOY1_RIGHT_DOWN,L"Joy1 Right+Down",AM_K,16,1,DIR_RIGHT|DIR_DOWN)
+
+DEFEVENT(JOY1_FIRE_BUTTON,L"Joy1 Fire/Mouse1 Left Button",AM_K,4,1,JOYBUTTON_1)
+DEFEVENT(JOY1_2ND_BUTTON,L"Joy1 2nd Button/Mouse1 Right Button",AM_K,4,1,JOYBUTTON_2)
+DEFEVENT(JOY1_3RD_BUTTON,L"Joy1 3rd Button/Mouse1 Middle Button",AM_K,4,1,JOYBUTTON_3)
+DEFEVENT(JOY1_CD32_PLAY,L"Joy1 CD32 Play",AM_K,4,1,JOYBUTTON_CD32_PLAY)
+DEFEVENT(JOY1_CD32_RWD,L"Joy1 CD32 RWD",AM_K,4,1,JOYBUTTON_CD32_RWD)
+DEFEVENT(JOY1_CD32_FFW,L"Joy1 CD32 FFW",AM_K,4,1,JOYBUTTON_CD32_FFW)
+DEFEVENT(JOY1_CD32_GREEN,L"Joy1 CD32 Green",AM_K,4,1,JOYBUTTON_CD32_GREEN)
+DEFEVENT(JOY1_CD32_YELLOW,L"Joy1 CD32 Yellow",AM_K,4,1,JOYBUTTON_CD32_YELLOW)
+DEFEVENT(JOY1_CD32_RED,L"Joy1 CD32 Red",AM_K,4,1,JOYBUTTON_CD32_RED)
+DEFEVENT(JOY1_CD32_BLUE,L"Joy1 CD32 Blue",AM_K,4,1,JOYBUTTON_CD32_BLUE)
 
 /* joystick/mouse port 2 */
 
-DEFEVENT(JOYPORT2_START,"Joystick port 2", AM_INFO, 0,2,0)
-
-DEFEVENT(MOUSE2_FIRST, "", AM_DUMMY, 0,0,0)
-
-DEFEVENT(MOUSE2_HORIZ,"Mouse2 Horizontal",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,0)
-DEFEVENT(MOUSE2_VERT,"Mouse2 Vertical",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,1)
-DEFEVENT(MOUSE2_HORIZ_INV,"Mouse2 Horizontal (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,0|IE_INVERT)
-DEFEVENT(MOUSE2_VERT_INV,"Mouse2 Vertical (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,1|IE_INVERT)
-
-DEFEVENT(MOUSE2_LAST, "", AM_DUMMY, 0,0,0)
-
-DEFEVENT(MOUSE2_UP,"Mouse2 Up",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,2,DIR_UP)
-DEFEVENT(MOUSE2_DOWN,"Mouse2 Down",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,2,DIR_DOWN)
-DEFEVENT(MOUSE2_LEFT,"Mouse2 Left",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,2,DIR_LEFT)
-DEFEVENT(MOUSE2_RIGHT,"Mouse2 Right",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,2,DIR_RIGHT)
-
-DEFEVENT(JOY2_HORIZ,"Joy2 Horizontal",AM_JOY_AXIS,0,2,DIR_LEFT|DIR_RIGHT)
-DEFEVENT(JOY2_VERT,"Joy2 Vertical",AM_JOY_AXIS,0,2,DIR_UP|DIR_DOWN)
-DEFEVENT(JOY2_HORIZ_POT,"Joy2 Horizontal (Analog)",AM_JOY_AXIS,128,2,1)
-DEFEVENT(JOY2_VERT_POT,"Joy2 Vertical (Analog)",AM_JOY_AXIS,128,2,0)
-DEFEVENT(JOY2_HORIZ_POT_INV,"Joy2 Horizontal (Analog, inverted)",AM_JOY_AXIS,128,2,1|IE_INVERT)
-DEFEVENT(JOY2_VERT_POT_INV,"Joy2 Vertical (Analog, inverted)",AM_JOY_AXIS,128,2,0|IE_INVERT)
-
-DEFEVENT(JOY2_LEFT,"Joy2 Left",AM_K,16,2,DIR_LEFT)
-DEFEVENT(JOY2_RIGHT,"Joy2 Right",AM_K,16,2,DIR_RIGHT)
-DEFEVENT(JOY2_UP,"Joy2 Up",AM_K,16,2,DIR_UP)
-DEFEVENT(JOY2_DOWN,"Joy2 Down",AM_K,16,2,DIR_DOWN)
-DEFEVENT(JOY2_LEFT_UP,"Joy2 Left+Up",AM_K,16,2,DIR_LEFT|DIR_UP)
-DEFEVENT(JOY2_LEFT_DOWN,"Joy2 Left+Down",AM_K,16,2,DIR_LEFT|DIR_DOWN)
-DEFEVENT(JOY2_RIGHT_UP,"Joy2 Right+Up",AM_K,16,2,DIR_RIGHT|DIR_UP)
-DEFEVENT(JOY2_RIGHT_DOWN,"Joy2 Right+Down",AM_K,16,2,DIR_RIGHT|DIR_DOWN)
-
-DEFEVENT(JOY2_FIRE_BUTTON,"Joy2 Fire/Mouse2 Left Button",AM_K,4,2,JOYBUTTON_1)
-DEFEVENT(JOY2_2ND_BUTTON,"Joy2 2nd Button/Mouse2 Right Button",AM_K,4,2,JOYBUTTON_2)
-DEFEVENT(JOY2_3RD_BUTTON,"Joy2 3rd Button/Mouse2 Middle Button",AM_K,4,2,JOYBUTTON_3)
-DEFEVENT(JOY2_CD32_PLAY,"Joy2 CD32 Play",AM_K,4,2,JOYBUTTON_CD32_PLAY)
-DEFEVENT(JOY2_CD32_RWD,"Joy2 CD32 RWD",AM_K,4,2,JOYBUTTON_CD32_RWD)
-DEFEVENT(JOY2_CD32_FFW,"Joy2 CD32 FFW",AM_K,4,2,JOYBUTTON_CD32_FFW)
-DEFEVENT(JOY2_CD32_GREEN,"Joy2 CD32 Green",AM_K,4,2,JOYBUTTON_CD32_GREEN)
-DEFEVENT(JOY2_CD32_YELLOW,"Joy2 CD32 Yellow",AM_K,4,2,JOYBUTTON_CD32_YELLOW)
-DEFEVENT(JOY2_CD32_RED,"Joy2 CD32 Red",AM_K,4,2,JOYBUTTON_CD32_RED)
-DEFEVENT(JOY2_CD32_BLUE,"Joy2 CD32 Blue",AM_K,4,2,JOYBUTTON_CD32_BLUE)
-
-DEFEVENT(LIGHTPEN_HORIZ,"Lightpen Horizontal",AM_MOUSE_AXIS,0,5,0)
-DEFEVENT(LIGHTPEN_VERT,"Lightpen Vertical",AM_MOUSE_AXIS,0,5,1)
+DEFEVENT(JOYPORT2_START,L"Joystick port 2", AM_INFO, 0,2,0)
+
+DEFEVENT(MOUSE2_FIRST, L"", AM_DUMMY, 0,0,0)
+
+DEFEVENT(MOUSE2_HORIZ,L"Mouse2 Horizontal",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,0)
+DEFEVENT(MOUSE2_VERT,L"Mouse2 Vertical",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,1)
+DEFEVENT(MOUSE2_HORIZ_INV,L"Mouse2 Horizontal (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,0|IE_INVERT)
+DEFEVENT(MOUSE2_VERT_INV,L"Mouse2 Vertical (inverted)",AM_MOUSE_AXIS|AM_JOY_AXIS,8,2,1|IE_INVERT)
+
+DEFEVENT(MOUSE2_LAST, L"", AM_DUMMY, 0,0,0)
+
+DEFEVENT(MOUSE2_UP,L"Mouse2 Up",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,2,DIR_UP)
+DEFEVENT(MOUSE2_DOWN,L"Mouse2 Down",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,32,2,DIR_DOWN)
+DEFEVENT(MOUSE2_LEFT,L"Mouse2 Left",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,2,DIR_LEFT)
+DEFEVENT(MOUSE2_RIGHT,L"Mouse2 Right",AM_KEY|AM_JOY_BUT|AM_MOUSE_BUT,64,2,DIR_RIGHT)
+
+DEFEVENT(JOY2_HORIZ,L"Joy2 Horizontal",AM_JOY_AXIS,0,2,DIR_LEFT|DIR_RIGHT)
+DEFEVENT(JOY2_VERT,L"Joy2 Vertical",AM_JOY_AXIS,0,2,DIR_UP|DIR_DOWN)
+DEFEVENT(JOY2_HORIZ_POT,L"Joy2 Horizontal (Analog)",AM_JOY_AXIS,128,2,1)
+DEFEVENT(JOY2_VERT_POT,L"Joy2 Vertical (Analog)",AM_JOY_AXIS,128,2,0)
+DEFEVENT(JOY2_HORIZ_POT_INV,L"Joy2 Horizontal (Analog, inverted)",AM_JOY_AXIS,128,2,1|IE_INVERT)
+DEFEVENT(JOY2_VERT_POT_INV,L"Joy2 Vertical (Analog, inverted)",AM_JOY_AXIS,128,2,0|IE_INVERT)
+
+DEFEVENT(JOY2_LEFT,L"Joy2 Left",AM_K,16,2,DIR_LEFT)
+DEFEVENT(JOY2_RIGHT,L"Joy2 Right",AM_K,16,2,DIR_RIGHT)
+DEFEVENT(JOY2_UP,L"Joy2 Up",AM_K,16,2,DIR_UP)
+DEFEVENT(JOY2_DOWN,L"Joy2 Down",AM_K,16,2,DIR_DOWN)
+DEFEVENT(JOY2_LEFT_UP,L"Joy2 Left+Up",AM_K,16,2,DIR_LEFT|DIR_UP)
+DEFEVENT(JOY2_LEFT_DOWN,L"Joy2 Left+Down",AM_K,16,2,DIR_LEFT|DIR_DOWN)
+DEFEVENT(JOY2_RIGHT_UP,L"Joy2 Right+Up",AM_K,16,2,DIR_RIGHT|DIR_UP)
+DEFEVENT(JOY2_RIGHT_DOWN,L"Joy2 Right+Down",AM_K,16,2,DIR_RIGHT|DIR_DOWN)
+
+DEFEVENT(JOY2_FIRE_BUTTON,L"Joy2 Fire/Mouse2 Left Button",AM_K,4,2,JOYBUTTON_1)
+DEFEVENT(JOY2_2ND_BUTTON,L"Joy2 2nd Button/Mouse2 Right Button",AM_K,4,2,JOYBUTTON_2)
+DEFEVENT(JOY2_3RD_BUTTON,L"Joy2 3rd Button/Mouse2 Middle Button",AM_K,4,2,JOYBUTTON_3)
+DEFEVENT(JOY2_CD32_PLAY,L"Joy2 CD32 Play",AM_K,4,2,JOYBUTTON_CD32_PLAY)
+DEFEVENT(JOY2_CD32_RWD,L"Joy2 CD32 RWD",AM_K,4,2,JOYBUTTON_CD32_RWD)
+DEFEVENT(JOY2_CD32_FFW,L"Joy2 CD32 FFW",AM_K,4,2,JOYBUTTON_CD32_FFW)
+DEFEVENT(JOY2_CD32_GREEN,L"Joy2 CD32 Green",AM_K,4,2,JOYBUTTON_CD32_GREEN)
+DEFEVENT(JOY2_CD32_YELLOW,L"Joy2 CD32 Yellow",AM_K,4,2,JOYBUTTON_CD32_YELLOW)
+DEFEVENT(JOY2_CD32_RED,L"Joy2 CD32 Red",AM_K,4,2,JOYBUTTON_CD32_RED)
+DEFEVENT(JOY2_CD32_BLUE,L"Joy2 CD32 Blue",AM_K,4,2,JOYBUTTON_CD32_BLUE)
+
+DEFEVENT(LIGHTPEN_HORIZ,L"Lightpen Horizontal",AM_MOUSE_AXIS,0,5,0)
+DEFEVENT(LIGHTPEN_VERT,L"Lightpen Vertical",AM_MOUSE_AXIS,0,5,1)
 
 /* parallel port joystick adapter */
 
-DEFEVENT(PAR_JOY1_START, "Parallel port joystick adapter", AM_INFO, 0,3,0)
-
-DEFEVENT(PAR_JOY1_HORIZ,"Parallel Joy1 Horizontal",AM_JOY_AXIS,0,3,DIR_LEFT|DIR_RIGHT)
-DEFEVENT(PAR_JOY1_VERT,"Parallel Joy1 Vertical",AM_JOY_AXIS,0,3,DIR_UP|DIR_DOWN)
-DEFEVENT(PAR_JOY1_LEFT,"Parallel Joy1 Left",AM_K,16,3,DIR_LEFT)
-DEFEVENT(PAR_JOY1_RIGHT,"Parallel Joy1 Right",AM_K,16,3,DIR_RIGHT)
-DEFEVENT(PAR_JOY1_UP,"Parallel Joy1 Up",AM_K,16,3,DIR_UP)
-DEFEVENT(PAR_JOY1_DOWN,"Parallel Joy1 Down",AM_K,16,3,DIR_DOWN)
-DEFEVENT(PAR_JOY1_LEFT_UP,"Parallel Joy1 Left+Up",AM_K,16,3,DIR_LEFT|DIR_UP)
-DEFEVENT(PAR_JOY1_LEFT_DOWN,"Parallel Joy1 Left+Down",AM_K,16,3,DIR_LEFT|DIR_DOWN)
-DEFEVENT(PAR_JOY1_RIGHT_UP,"Parallel Joy1 Right+Up",AM_K,16,3,DIR_RIGHT|DIR_UP)
-DEFEVENT(PAR_JOY1_RIGHT_DOWN,"Parallel Joy1 Right+Down",AM_K,16,3,DIR_RIGHT|DIR_DOWN)
-DEFEVENT(PAR_JOY1_FIRE_BUTTON,"Parallel Joy1 Fire Button",AM_K,4,3,JOYBUTTON_1)
-
-DEFEVENT(PAR_JOY2_START, "", AM_DUMMY, 0,4,0)
-
-DEFEVENT(PAR_JOY2_HORIZ,"Parallel Joy2 Horizontal",AM_JOY_AXIS,0,4,DIR_LEFT|DIR_RIGHT)
-DEFEVENT(PAR_JOY2_VERT,"Parallel Joy2 Vertical",AM_JOY_AXIS,0,4,DIR_UP|DIR_DOWN)
-DEFEVENT(PAR_JOY2_LEFT,"Parallel Joy2 Left",AM_K,16,4,DIR_LEFT)
-DEFEVENT(PAR_JOY2_RIGHT,"Parallel Joy2 Right",AM_K,16,4,DIR_RIGHT)
-DEFEVENT(PAR_JOY2_UP,"Parallel Joy2 Up",AM_K,16,4,DIR_UP)
-DEFEVENT(PAR_JOY2_DOWN,"Parallel Joy2 Down",AM_K,16,4,DIR_DOWN)
-DEFEVENT(PAR_JOY2_LEFT_UP,"Parallel Joy2 Left+Up",AM_K,16,4,DIR_LEFT|DIR_UP)
-DEFEVENT(PAR_JOY2_LEFT_DOWN,"Parallel Joy2 Left+Down",AM_K,16,4,DIR_LEFT|DIR_DOWN)
-DEFEVENT(PAR_JOY2_RIGHT_UP,"Parallel Joy2 Right+Up",AM_K,16,4,DIR_RIGHT|DIR_UP)
-DEFEVENT(PAR_JOY2_RIGHT_DOWN,"Parallel Joy2 Right+Down",AM_K,16,4,DIR_RIGHT|DIR_DOWN)
-DEFEVENT(PAR_JOY2_FIRE_BUTTON,"Parallel Joy2 Fire Button",AM_K,4,4,JOYBUTTON_1)
-
-DEFEVENT(PAR_JOY_END, "", AM_DUMMY, 0,0,0)
+DEFEVENT(PAR_JOY1_START, L"Parallel port joystick adapter", AM_INFO, 0,3,0)
+
+DEFEVENT(PAR_JOY1_HORIZ,L"Parallel Joy1 Horizontal",AM_JOY_AXIS,0,3,DIR_LEFT|DIR_RIGHT)
+DEFEVENT(PAR_JOY1_VERT,L"Parallel Joy1 Vertical",AM_JOY_AXIS,0,3,DIR_UP|DIR_DOWN)
+DEFEVENT(PAR_JOY1_LEFT,L"Parallel Joy1 Left",AM_K,16,3,DIR_LEFT)
+DEFEVENT(PAR_JOY1_RIGHT,L"Parallel Joy1 Right",AM_K,16,3,DIR_RIGHT)
+DEFEVENT(PAR_JOY1_UP,L"Parallel Joy1 Up",AM_K,16,3,DIR_UP)
+DEFEVENT(PAR_JOY1_DOWN,L"Parallel Joy1 Down",AM_K,16,3,DIR_DOWN)
+DEFEVENT(PAR_JOY1_LEFT_UP,L"Parallel Joy1 Left+Up",AM_K,16,3,DIR_LEFT|DIR_UP)
+DEFEVENT(PAR_JOY1_LEFT_DOWN,L"Parallel Joy1 Left+Down",AM_K,16,3,DIR_LEFT|DIR_DOWN)
+DEFEVENT(PAR_JOY1_RIGHT_UP,L"Parallel Joy1 Right+Up",AM_K,16,3,DIR_RIGHT|DIR_UP)
+DEFEVENT(PAR_JOY1_RIGHT_DOWN,L"Parallel Joy1 Right+Down",AM_K,16,3,DIR_RIGHT|DIR_DOWN)
+DEFEVENT(PAR_JOY1_FIRE_BUTTON,L"Parallel Joy1 Fire Button",AM_K,4,3,JOYBUTTON_1)
+
+DEFEVENT(PAR_JOY2_START, L"", AM_DUMMY, 0,4,0)
+
+DEFEVENT(PAR_JOY2_HORIZ,L"Parallel Joy2 Horizontal",AM_JOY_AXIS,0,4,DIR_LEFT|DIR_RIGHT)
+DEFEVENT(PAR_JOY2_VERT,L"Parallel Joy2 Vertical",AM_JOY_AXIS,0,4,DIR_UP|DIR_DOWN)
+DEFEVENT(PAR_JOY2_LEFT,L"Parallel Joy2 Left",AM_K,16,4,DIR_LEFT)
+DEFEVENT(PAR_JOY2_RIGHT,L"Parallel Joy2 Right",AM_K,16,4,DIR_RIGHT)
+DEFEVENT(PAR_JOY2_UP,L"Parallel Joy2 Up",AM_K,16,4,DIR_UP)
+DEFEVENT(PAR_JOY2_DOWN,L"Parallel Joy2 Down",AM_K,16,4,DIR_DOWN)
+DEFEVENT(PAR_JOY2_LEFT_UP,L"Parallel Joy2 Left+Up",AM_K,16,4,DIR_LEFT|DIR_UP)
+DEFEVENT(PAR_JOY2_LEFT_DOWN,L"Parallel Joy2 Left+Down",AM_K,16,4,DIR_LEFT|DIR_DOWN)
+DEFEVENT(PAR_JOY2_RIGHT_UP,L"Parallel Joy2 Right+Up",AM_K,16,4,DIR_RIGHT|DIR_UP)
+DEFEVENT(PAR_JOY2_RIGHT_DOWN,L"Parallel Joy2 Right+Down",AM_K,16,4,DIR_RIGHT|DIR_DOWN)
+DEFEVENT(PAR_JOY2_FIRE_BUTTON,L"Parallel Joy2 Fire Button",AM_K,4,4,JOYBUTTON_1)
+
+DEFEVENT(PAR_JOY_END, L"", AM_DUMMY, 0,0,0)
 
 /* keys */
 
-DEFEVENT(KEY_START,"Keyboard",AM_INFO, 0,0,0)
+DEFEVENT(KEY_START,L"Keyboard",AM_INFO, 0,0,0)
 
-DEFEVENT(KEY_F1,"F1",AM_K,0,0,AK_F1)
-DEFEVENT(KEY_F2,"F2",AM_K,0,0,AK_F2)
-DEFEVENT(KEY_F3,"F3",AM_K,0,0,AK_F3)
-DEFEVENT(KEY_F4,"F4",AM_K,0,0,AK_F4)
-DEFEVENT(KEY_F5,"F5",AM_K,0,0,AK_F5)
-DEFEVENT(KEY_F6,"F6",AM_K,0,0,AK_F6)
-DEFEVENT(KEY_F7,"F7",AM_K,0,0,AK_F7)
-DEFEVENT(KEY_F8,"F8",AM_K,0,0,AK_F8)
-DEFEVENT(KEY_F9,"F9",AM_K,0,0,AK_F9)
-DEFEVENT(KEY_F10,"F10",AM_K,0,0,AK_F10)
+DEFEVENT(KEY_F1,L"F1",AM_K,0,0,AK_F1)
+DEFEVENT(KEY_F2,L"F2",AM_K,0,0,AK_F2)
+DEFEVENT(KEY_F3,L"F3",AM_K,0,0,AK_F3)
+DEFEVENT(KEY_F4,L"F4",AM_K,0,0,AK_F4)
+DEFEVENT(KEY_F5,L"F5",AM_K,0,0,AK_F5)
+DEFEVENT(KEY_F6,L"F6",AM_K,0,0,AK_F6)
+DEFEVENT(KEY_F7,L"F7",AM_K,0,0,AK_F7)
+DEFEVENT(KEY_F8,L"F8",AM_K,0,0,AK_F8)
+DEFEVENT(KEY_F9,L"F9",AM_K,0,0,AK_F9)
+DEFEVENT(KEY_F10,L"F10",AM_K,0,0,AK_F10)
 
 /* "special" keys */
 
-DEFEVENT(KEY_ESC,"ESC",AM_K,0,0,AK_ESC)
-DEFEVENT(KEY_TAB,"Tab",AM_K,0,0,AK_TAB)
-DEFEVENT(KEY_CTRL,"CTRL",AM_K,0,0,AK_CTRL)
-DEFEVENT(KEY_CTRL_RIGHT,"Right CTRL",AM_K,0,0,AK_RCTRL)
-DEFEVENT(KEY_CAPS_LOCK,"Caps Lock",AM_K,0,0,AK_CAPSLOCK)
-DEFEVENT(KEY_SHIFT_LEFT,"Left Shift",AM_K,0,0,AK_LSH)
-DEFEVENT(KEY_ALT_LEFT,"Left Alt",AM_K,0,0,AK_LALT)
-DEFEVENT(KEY_AMIGA_LEFT,"Left Amiga",AM_K,0,0,AK_LAMI)
-DEFEVENT(KEY_AMIGA_RIGHT,"Right Amiga",AM_K,0,0,AK_RAMI)
-DEFEVENT(KEY_ALT_RIGHT,"Right Alt",AM_K,0,0,AK_RALT)
-DEFEVENT(KEY_SHIFT_RIGHT,"Right Shift",AM_K,0,0,AK_RSH)
-DEFEVENT(KEY_SPACE,"Space",AM_K,0,0,AK_SPC)
-DEFEVENT(KEY_CURSOR_UP,"Cursor Up",AM_K,0,0,AK_UP)
-DEFEVENT(KEY_CURSOR_DOWN,"Cursor Down",AM_K,0,0,AK_DN)
-DEFEVENT(KEY_CURSOR_LEFT,"Cursor Left",AM_K,0,0,AK_LF)
-DEFEVENT(KEY_CURSOR_RIGHT,"Cursor Right",AM_K,0,0,AK_RT)
-DEFEVENT(KEY_HELP,"Help",AM_K,0,0,AK_HELP)
-DEFEVENT(KEY_DEL,"Del",AM_K,0,0,AK_DEL)
-DEFEVENT(KEY_BACKSPACE,"Backspace",AM_K,0,0,AK_BS)
-DEFEVENT(KEY_RETURN,"Return",AM_K,0,0,AK_RET)
+DEFEVENT(KEY_ESC,L"ESC",AM_K,0,0,AK_ESC)
+DEFEVENT(KEY_TAB,L"Tab",AM_K,0,0,AK_TAB)
+DEFEVENT(KEY_CTRL,L"CTRL",AM_K,0,0,AK_CTRL)
+DEFEVENT(KEY_CTRL_RIGHT,L"Right CTRL",AM_K,0,0,AK_RCTRL)
+DEFEVENT(KEY_CAPS_LOCK,L"Caps Lock",AM_K,0,0,AK_CAPSLOCK)
+DEFEVENT(KEY_SHIFT_LEFT,L"Left Shift",AM_K,0,0,AK_LSH)
+DEFEVENT(KEY_ALT_LEFT,L"Left Alt",AM_K,0,0,AK_LALT)
+DEFEVENT(KEY_AMIGA_LEFT,L"Left Amiga",AM_K,0,0,AK_LAMI)
+DEFEVENT(KEY_AMIGA_RIGHT,L"Right Amiga",AM_K,0,0,AK_RAMI)
+DEFEVENT(KEY_ALT_RIGHT,L"Right Alt",AM_K,0,0,AK_RALT)
+DEFEVENT(KEY_SHIFT_RIGHT,L"Right Shift",AM_K,0,0,AK_RSH)
+DEFEVENT(KEY_SPACE,L"Space",AM_K,0,0,AK_SPC)
+DEFEVENT(KEY_CURSOR_UP,L"Cursor Up",AM_K,0,0,AK_UP)
+DEFEVENT(KEY_CURSOR_DOWN,L"Cursor Down",AM_K,0,0,AK_DN)
+DEFEVENT(KEY_CURSOR_LEFT,L"Cursor Left",AM_K,0,0,AK_LF)
+DEFEVENT(KEY_CURSOR_RIGHT,L"Cursor Right",AM_K,0,0,AK_RT)
+DEFEVENT(KEY_HELP,L"Help",AM_K,0,0,AK_HELP)
+DEFEVENT(KEY_DEL,L"Del",AM_K,0,0,AK_DEL)
+DEFEVENT(KEY_BACKSPACE,L"Backspace",AM_K,0,0,AK_BS)
+DEFEVENT(KEY_RETURN,L"Return",AM_K,0,0,AK_RET)
 
 /* numpad */
 
-DEFEVENT(KEY_A,"A",AM_K,0,0,AK_A)
-DEFEVENT(KEY_B,"B",AM_K,0,0,AK_B)
-DEFEVENT(KEY_C,"C",AM_K,0,0,AK_C)
-DEFEVENT(KEY_D,"D",AM_K,0,0,AK_D)
-DEFEVENT(KEY_E,"E",AM_K,0,0,AK_E)
-DEFEVENT(KEY_F,"F",AM_K,0,0,AK_F)
-DEFEVENT(KEY_G,"G",AM_K,0,0,AK_G)
-DEFEVENT(KEY_H,"H",AM_K,0,0,AK_H)
-DEFEVENT(KEY_I,"I",AM_K,0,0,AK_I)
-DEFEVENT(KEY_J,"J",AM_K,0,0,AK_J)
-DEFEVENT(KEY_K,"K",AM_K,0,0,AK_K)
-DEFEVENT(KEY_L,"L",AM_K,0,0,AK_L)
-DEFEVENT(KEY_M,"M",AM_K,0,0,AK_M)
-DEFEVENT(KEY_N,"N",AM_K,0,0,AK_N)
-DEFEVENT(KEY_O,"O",AM_K,0,0,AK_O)
-DEFEVENT(KEY_P,"P",AM_K,0,0,AK_P)
-DEFEVENT(KEY_Q,"Q",AM_K,0,0,AK_Q)
-DEFEVENT(KEY_R,"R",AM_K,0,0,AK_R)
-DEFEVENT(KEY_S,"S",AM_K,0,0,AK_S)
-DEFEVENT(KEY_T,"T",AM_K,0,0,AK_T)
-DEFEVENT(KEY_U,"U",AM_K,0,0,AK_U)
-DEFEVENT(KEY_V,"V",AM_K,0,0,AK_V)
-DEFEVENT(KEY_W,"W",AM_K,0,0,AK_W)
-DEFEVENT(KEY_X,"X",AM_K,0,0,AK_X)
-DEFEVENT(KEY_Y,"Y",AM_K,0,0,AK_Y)
-DEFEVENT(KEY_Z,"Z",AM_K,0,0,AK_Z)
-
-DEFEVENT(KEY_ENTER,"Numpad Enter",AM_K,0,0,AK_ENT)
-DEFEVENT(KEY_NP_0,"Numpad 0",AM_K,0,0,AK_NP0)
-DEFEVENT(KEY_NP_1,"Numpad 1",AM_K,0,0,AK_NP1)
-DEFEVENT(KEY_NP_2,"Numpad 2",AM_K,0,0,AK_NP2)
-DEFEVENT(KEY_NP_3,"Numpad 3",AM_K,0,0,AK_NP3)
-DEFEVENT(KEY_NP_4,"Numpad 4",AM_K,0,0,AK_NP4)
-DEFEVENT(KEY_NP_5,"Numpad 5",AM_K,0,0,AK_NP5)
-DEFEVENT(KEY_NP_6,"Numpad 6",AM_K,0,0,AK_NP6)
-DEFEVENT(KEY_NP_7,"Numpad 7",AM_K,0,0,AK_NP7)
-DEFEVENT(KEY_NP_8,"Numpad 8",AM_K,0,0,AK_NP8)
-DEFEVENT(KEY_NP_9,"Numpad 9",AM_K,0,0,AK_NP9)
-DEFEVENT(KEY_NP_PERIOD,"Numpad Period",AM_K,0,0,AK_NPDEL)
-DEFEVENT(KEY_NP_ADD,"Numpad Plus",AM_K,0,0,AK_NPADD)
-DEFEVENT(KEY_NP_SUB,"Numpad Minus",AM_K,0,0,AK_NPSUB)
-DEFEVENT(KEY_NP_MUL,"Numpad Multiply",AM_K,0,0,AK_NPMUL)
-DEFEVENT(KEY_NP_DIV,"Numpad Divide",AM_K,0,0,AK_NPDIV)
-DEFEVENT(KEY_NP_LPAREN,"Numpad Left Parenthesis",AM_K,0,0,AK_NPLPAREN)
-DEFEVENT(KEY_NP_RPAREN,"Numpad Right Parenthesis",AM_K,0,0,AK_NPRPAREN)
-DEFEVENT(KEY_2B,"Keycode 0x2b",AM_K,0,0,0x2b)
-DEFEVENT(KEY_30,"Keycode 0x30",AM_K,0,0,0x30)
-
-DEFEVENT(KEY_BACKQUOTE,"Back Quote",AM_K,0,0,AK_BACKQUOTE)
-DEFEVENT(KEY_1,"1",AM_K,0,0,AK_1)
-DEFEVENT(KEY_2,"2",AM_K,0,0,AK_2)
-DEFEVENT(KEY_3,"3",AM_K,0,0,AK_3)
-DEFEVENT(KEY_4,"4",AM_K,0,0,AK_4)
-DEFEVENT(KEY_5,"5",AM_K,0,0,AK_5)
-DEFEVENT(KEY_6,"6",AM_K,0,0,AK_6)
-DEFEVENT(KEY_7,"7",AM_K,0,0,AK_7)
-DEFEVENT(KEY_8,"8",AM_K,0,0,AK_8)
-DEFEVENT(KEY_9,"9",AM_K,0,0,AK_9)
-DEFEVENT(KEY_0,"0",AM_K,0,0,AK_0)
-DEFEVENT(KEY_SUB,"Minus",AM_K,0,0,AK_MINUS)
-DEFEVENT(KEY_EQUALS,"Equals",AM_K,0,0,AK_EQUAL)
-DEFEVENT(KEY_BACKSLASH,"Backslash",AM_K,0,0,AK_BACKSLASH)
-
-DEFEVENT(KEY_LEFTBRACKET,"Left Bracket",AM_K,0,0,AK_LBRACKET)
-DEFEVENT(KEY_RIGHTBRACKET,"Right Bracket",AM_K,0,0,AK_RBRACKET)
-DEFEVENT(KEY_SEMICOLON,"Semicolon",AM_K,0,0,AK_SEMICOLON)
-DEFEVENT(KEY_SINGLEQUOTE,"Single Quote",AM_K,0,0,AK_QUOTE)
-DEFEVENT(KEY_COMMA,"Comma",AM_K,0,0,AK_COMMA)
-DEFEVENT(KEY_PERIOD,"Period",AM_K,0,0,AK_PERIOD)
-DEFEVENT(KEY_DIV,"Slash",AM_K,0,0,AK_SLASH)
-
-// DEFEVENT(KEY_,"",AM_K,0,0,0x)
+DEFEVENT(KEY_A,L"A",AM_K,0,0,AK_A)
+DEFEVENT(KEY_B,L"B",AM_K,0,0,AK_B)
+DEFEVENT(KEY_C,L"C",AM_K,0,0,AK_C)
+DEFEVENT(KEY_D,L"D",AM_K,0,0,AK_D)
+DEFEVENT(KEY_E,L"E",AM_K,0,0,AK_E)
+DEFEVENT(KEY_F,L"F",AM_K,0,0,AK_F)
+DEFEVENT(KEY_G,L"G",AM_K,0,0,AK_G)
+DEFEVENT(KEY_H,L"H",AM_K,0,0,AK_H)
+DEFEVENT(KEY_I,L"I",AM_K,0,0,AK_I)
+DEFEVENT(KEY_J,L"J",AM_K,0,0,AK_J)
+DEFEVENT(KEY_K,L"K",AM_K,0,0,AK_K)
+DEFEVENT(KEY_L,L"L",AM_K,0,0,AK_L)
+DEFEVENT(KEY_M,L"M",AM_K,0,0,AK_M)
+DEFEVENT(KEY_N,L"N",AM_K,0,0,AK_N)
+DEFEVENT(KEY_O,L"O",AM_K,0,0,AK_O)
+DEFEVENT(KEY_P,L"P",AM_K,0,0,AK_P)
+DEFEVENT(KEY_Q,L"Q",AM_K,0,0,AK_Q)
+DEFEVENT(KEY_R,L"R",AM_K,0,0,AK_R)
+DEFEVENT(KEY_S,L"S",AM_K,0,0,AK_S)
+DEFEVENT(KEY_T,L"T",AM_K,0,0,AK_T)
+DEFEVENT(KEY_U,L"U",AM_K,0,0,AK_U)
+DEFEVENT(KEY_V,L"V",AM_K,0,0,AK_V)
+DEFEVENT(KEY_W,L"W",AM_K,0,0,AK_W)
+DEFEVENT(KEY_X,L"X",AM_K,0,0,AK_X)
+DEFEVENT(KEY_Y,L"Y",AM_K,0,0,AK_Y)
+DEFEVENT(KEY_Z,L"Z",AM_K,0,0,AK_Z)
+
+DEFEVENT(KEY_ENTER,L"Numpad Enter",AM_K,0,0,AK_ENT)
+DEFEVENT(KEY_NP_0,L"Numpad 0",AM_K,0,0,AK_NP0)
+DEFEVENT(KEY_NP_1,L"Numpad 1",AM_K,0,0,AK_NP1)
+DEFEVENT(KEY_NP_2,L"Numpad 2",AM_K,0,0,AK_NP2)
+DEFEVENT(KEY_NP_3,L"Numpad 3",AM_K,0,0,AK_NP3)
+DEFEVENT(KEY_NP_4,L"Numpad 4",AM_K,0,0,AK_NP4)
+DEFEVENT(KEY_NP_5,L"Numpad 5",AM_K,0,0,AK_NP5)
+DEFEVENT(KEY_NP_6,L"Numpad 6",AM_K,0,0,AK_NP6)
+DEFEVENT(KEY_NP_7,L"Numpad 7",AM_K,0,0,AK_NP7)
+DEFEVENT(KEY_NP_8,L"Numpad 8",AM_K,0,0,AK_NP8)
+DEFEVENT(KEY_NP_9,L"Numpad 9",AM_K,0,0,AK_NP9)
+DEFEVENT(KEY_NP_PERIOD,L"Numpad Period",AM_K,0,0,AK_NPDEL)
+DEFEVENT(KEY_NP_ADD,L"Numpad Plus",AM_K,0,0,AK_NPADD)
+DEFEVENT(KEY_NP_SUB,L"Numpad Minus",AM_K,0,0,AK_NPSUB)
+DEFEVENT(KEY_NP_MUL,L"Numpad Multiply",AM_K,0,0,AK_NPMUL)
+DEFEVENT(KEY_NP_DIV,L"Numpad Divide",AM_K,0,0,AK_NPDIV)
+DEFEVENT(KEY_NP_LPAREN,L"Numpad Left Parenthesis",AM_K,0,0,AK_NPLPAREN)
+DEFEVENT(KEY_NP_RPAREN,L"Numpad Right Parenthesis",AM_K,0,0,AK_NPRPAREN)
+DEFEVENT(KEY_2B,L"Keycode 0x2b",AM_K,0,0,0x2b)
+DEFEVENT(KEY_30,L"Keycode 0x30",AM_K,0,0,0x30)
+
+DEFEVENT(KEY_BACKQUOTE,L"Back Quote",AM_K,0,0,AK_BACKQUOTE)
+DEFEVENT(KEY_1,L"1",AM_K,0,0,AK_1)
+DEFEVENT(KEY_2,L"2",AM_K,0,0,AK_2)
+DEFEVENT(KEY_3,L"3",AM_K,0,0,AK_3)
+DEFEVENT(KEY_4,L"4",AM_K,0,0,AK_4)
+DEFEVENT(KEY_5,L"5",AM_K,0,0,AK_5)
+DEFEVENT(KEY_6,L"6",AM_K,0,0,AK_6)
+DEFEVENT(KEY_7,L"7",AM_K,0,0,AK_7)
+DEFEVENT(KEY_8,L"8",AM_K,0,0,AK_8)
+DEFEVENT(KEY_9,L"9",AM_K,0,0,AK_9)
+DEFEVENT(KEY_0,L"0",AM_K,0,0,AK_0)
+DEFEVENT(KEY_SUB,L"Minus",AM_K,0,0,AK_MINUS)
+DEFEVENT(KEY_EQUALS,L"Equals",AM_K,0,0,AK_EQUAL)
+DEFEVENT(KEY_BACKSLASH,L"Backslash",AM_K,0,0,AK_BACKSLASH)
+
+DEFEVENT(KEY_LEFTBRACKET,L"Left Bracket",AM_K,0,0,AK_LBRACKET)
+DEFEVENT(KEY_RIGHTBRACKET,L"Right Bracket",AM_K,0,0,AK_RBRACKET)
+DEFEVENT(KEY_SEMICOLON,L"Semicolon",AM_K,0,0,AK_SEMICOLON)
+DEFEVENT(KEY_SINGLEQUOTE,L"Single Quote",AM_K,0,0,AK_QUOTE)
+DEFEVENT(KEY_COMMA,L"Comma",AM_K,0,0,AK_COMMA)
+DEFEVENT(KEY_PERIOD,L"Period",AM_K,0,0,AK_PERIOD)
+DEFEVENT(KEY_DIV,L"Slash",AM_K,0,0,AK_SLASH)
+
+// DEFEVENT(KEY_,L"",AM_K,0,0,0x)
 
 /* mouse wheel "keys" */
 
-DEFEVENT(MOUSEWHEEL_DOWN,"Mouse Wheel Down",AM_K,0,0,0x7a)
-DEFEVENT(MOUSEWHEEL_UP,"Mouse Wheel Up",AM_K,0,0,0x7b)
+DEFEVENT(MOUSEWHEEL_DOWN,L"Mouse Wheel Down",AM_K,0,0,0x7a)
+DEFEVENT(MOUSEWHEEL_UP,L"Mouse Wheel Up",AM_K,0,0,0x7b)
 
 /* misc */
 
-DEFEVENT(KEY_CDTV_STOP,"CDTV Stop",AM_K,0,0,0x72)
-DEFEVENT(KEY_CDTV_PLAYPAUSE,"CDTV Play/Pause",AM_K,0,0,0x73)
-DEFEVENT(KEY_CDTV_PREV,"CDTV Previous",AM_K,0,0,0x74)
-DEFEVENT(KEY_CDTV_NEXT,"CDTV Next",AM_K,0,0,0x75)
-DEFEVENT(KEY_CDTV_REW,"CDTV Rewind",AM_K,0,0,0x76)
-DEFEVENT(KEY_CDTV_FF,"CDTV Fast Forward",AM_K,0,0,0x77)
-
-DEFEVENT(KEY_0E,"Keycode 0x0E",AM_K,0,0,0x0e)
-
-DEFEVENT(KEY_1C,"Keycode 0x1C",AM_K,0,0,0x1c)
-
-DEFEVENT(KEY_2C,"Keycode 0x2C",AM_K,0,0,0x2C)
-
-DEFEVENT(KEY_3B,"Keycode 0x3B",AM_K,0,0,0x3b)
-DEFEVENT(KEY_47,"Keycode 0x47",AM_K,0,0,0x47)
-
-DEFEVENT(KEY_48,"Keycode 0x48",AM_K,0,0,0x48)
-DEFEVENT(KEY_49,"Keycode 0x49",AM_K,0,0,0x49)
-DEFEVENT(KEY_4B,"Keycode 0x4B",AM_K,0,0,0x4b)
-
-DEFEVENT(KEY_68,"Keycode 0x68",AM_K,0,0,0x68)
-DEFEVENT(KEY_69,"Keycode 0x69",AM_K,0,0,0x69)
-DEFEVENT(KEY_6A,"Keycode 0x6A",AM_K,0,0,0x6a)
-DEFEVENT(KEY_6B,"Keycode 0x6B",AM_K,0,0,0x6b)
-DEFEVENT(KEY_6C,"Keycode 0x6C",AM_K,0,0,0x6c)
-DEFEVENT(KEY_6D,"Keycode 0x6D",AM_K,0,0,0x6d)
-DEFEVENT(KEY_6E,"Keycode 0x6E",AM_K,0,0,0x6e)
-DEFEVENT(KEY_6F,"Keycode 0x6F",AM_K,0,0,0x6f)
-
-DEFEVENT(KEY_70,"Keycode 0x70",AM_K,0,0,0x70)
-DEFEVENT(KEY_71,"Keycode 0x71",AM_K,0,0,0x71)
-DEFEVENT(KEY_78,"Keycode 0x78 (Reset Warning)",AM_K,0,0,0x78)
-DEFEVENT(KEY_79,"Keycode 0x79",AM_K,0,0,0x79)
-DEFEVENT(KEY_7A,"Keycode 0x7A",AM_K,0,0,0x7a)
-DEFEVENT(KEY_7B,"Keycode 0x7B",AM_K,0,0,0x7b)
-DEFEVENT(KEY_7C,"Keycode 0x7C",AM_K,0,0,0x7c)
-DEFEVENT(KEY_7D,"Keycode 0x7D",AM_K,0,0,0x7d)
-DEFEVENT(KEY_7E,"Keycode 0x7E",AM_K,0,0,0x7e)
-DEFEVENT(KEY_7F,"Keycode 0x7F",AM_K,0,0,0x7f)
+DEFEVENT(KEY_CDTV_STOP,L"CDTV Stop",AM_K,0,0,0x72)
+DEFEVENT(KEY_CDTV_PLAYPAUSE,L"CDTV Play/Pause",AM_K,0,0,0x73)
+DEFEVENT(KEY_CDTV_PREV,L"CDTV Previous",AM_K,0,0,0x74)
+DEFEVENT(KEY_CDTV_NEXT,L"CDTV Next",AM_K,0,0,0x75)
+DEFEVENT(KEY_CDTV_REW,L"CDTV Rewind",AM_K,0,0,0x76)
+DEFEVENT(KEY_CDTV_FF,L"CDTV Fast Forward",AM_K,0,0,0x77)
+
+DEFEVENT(KEY_0E,L"Keycode 0x0E",AM_K,0,0,0x0e)
+
+DEFEVENT(KEY_1C,L"Keycode 0x1C",AM_K,0,0,0x1c)
+
+DEFEVENT(KEY_2C,L"Keycode 0x2C",AM_K,0,0,0x2C)
+
+DEFEVENT(KEY_3B,L"Keycode 0x3B",AM_K,0,0,0x3b)
+DEFEVENT(KEY_47,L"Keycode 0x47",AM_K,0,0,0x47)
+
+DEFEVENT(KEY_48,L"Keycode 0x48",AM_K,0,0,0x48)
+DEFEVENT(KEY_49,L"Keycode 0x49",AM_K,0,0,0x49)
+DEFEVENT(KEY_4B,L"Keycode 0x4B",AM_K,0,0,0x4b)
+
+DEFEVENT(KEY_68,L"Keycode 0x68",AM_K,0,0,0x68)
+DEFEVENT(KEY_69,L"Keycode 0x69",AM_K,0,0,0x69)
+DEFEVENT(KEY_6A,L"Keycode 0x6A",AM_K,0,0,0x6a)
+DEFEVENT(KEY_6B,L"Keycode 0x6B",AM_K,0,0,0x6b)
+DEFEVENT(KEY_6C,L"Keycode 0x6C",AM_K,0,0,0x6c)
+DEFEVENT(KEY_6D,L"Keycode 0x6D",AM_K,0,0,0x6d)
+DEFEVENT(KEY_6E,L"Keycode 0x6E",AM_K,0,0,0x6e)
+DEFEVENT(KEY_6F,L"Keycode 0x6F",AM_K,0,0,0x6f)
+
+DEFEVENT(KEY_70,L"Keycode 0x70",AM_K,0,0,0x70)
+DEFEVENT(KEY_71,L"Keycode 0x71",AM_K,0,0,0x71)
+DEFEVENT(KEY_78,L"Keycode 0x78 (Reset Warning)",AM_K,0,0,0x78)
+DEFEVENT(KEY_79,L"Keycode 0x79",AM_K,0,0,0x79)
+DEFEVENT(KEY_7A,L"Keycode 0x7A",AM_K,0,0,0x7a)
+DEFEVENT(KEY_7B,L"Keycode 0x7B",AM_K,0,0,0x7b)
+DEFEVENT(KEY_7C,L"Keycode 0x7C",AM_K,0,0,0x7c)
+DEFEVENT(KEY_7D,L"Keycode 0x7D",AM_K,0,0,0x7d)
+DEFEVENT(KEY_7E,L"Keycode 0x7E",AM_K,0,0,0x7e)
+DEFEVENT(KEY_7F,L"Keycode 0x7F",AM_K,0,0,0x7f)
 
 /* special */
 
-DEFEVENT(SPC_ENTERGUI,"Enter GUI",AM_K,0,0,AKS_ENTERGUI)
-DEFEVENT(SPC_SCREENSHOT,"Screenshot",AM_K,0,0,AKS_SCREENSHOT)
-DEFEVENT(SPC_FREEZEBUTTON,"Activate Cartridge",AM_K,0,0,AKS_FREEZEBUTTON)
-DEFEVENT(SPC_FLOPPY0,"Change disk in DF0:",AM_K,0,0,AKS_FLOPPY0)
-DEFEVENT(SPC_FLOPPY1,"Change disk in DF1:",AM_K,0,0,AKS_FLOPPY1)
-DEFEVENT(SPC_FLOPPY2,"Change disk in DF2:",AM_K,0,0,AKS_FLOPPY2)
-DEFEVENT(SPC_FLOPPY3,"Change disk in DF3:",AM_K,0,0,AKS_FLOPPY3)
-DEFEVENT(SPC_EFLOPPY0,"Eject disk in DF0:",AM_K,0,0,AKS_EFLOPPY0)
-DEFEVENT(SPC_EFLOPPY1,"Eject disk in DF1:",AM_K,0,0,AKS_EFLOPPY1)
-DEFEVENT(SPC_EFLOPPY2,"Eject disk in DF2:",AM_K,0,0,AKS_EFLOPPY2)
-DEFEVENT(SPC_EFLOPPY3,"Eject disk in DF3:",AM_K,0,0,AKS_EFLOPPY3)
-DEFEVENT(SPC_PAUSE,"Pause emulation",AM_K,0,0,AKS_PAUSE)
-DEFEVENT(SPC_WARP,"Warp mode",AM_K,0,0,AKS_WARP)
-DEFEVENT(SPC_INHIBITSCREEN,"Toggle screen updates",AM_K,0,0,AKS_INHIBITSCREEN)
-DEFEVENT(SPC_IRQ7,"Level 7 interrupt",AM_K,0,0,AKS_IRQ7)
-DEFEVENT(SPC_STATEREWIND,"Load previous state capture",AM_K,0,0,AKS_STATEREWIND)
-DEFEVENT(SPC_VOLUME_DOWN,"Decrease volume level",AM_K,0,0,AKS_VOLDOWN)
-DEFEVENT(SPC_VOLUME_UP,"Increase volume level",AM_K,0,0,AKS_VOLUP)
-DEFEVENT(SPC_VOLUME_MUTE,"Mute/unmute volume",AM_K,0,0,AKS_VOLMUTE)
-DEFEVENT(SPC_MASTER_VOLUME_DOWN,"Decrease master volume level",AM_K,0,0,AKS_MVOLDOWN)
-DEFEVENT(SPC_MASTER_VOLUME_UP,"Increase master volume level",AM_K,0,0,AKS_MVOLUP)
-DEFEVENT(SPC_MASTER_VOLUME_MUTE,"Mute/unmute master volume",AM_K,0,0,AKS_MVOLMUTE)
-DEFEVENT(SPC_QUIT,"Quit emulator",AM_K,0,0,AKS_QUIT)
-DEFEVENT(SPC_SOFTRESET,"Reset emulation",AM_K,0,0,AKS_SOFTRESET)
-DEFEVENT(SPC_HARDRESET,"Hard reset emulation",AM_K,0,0,AKS_HARDRESET)
-DEFEVENT(SPC_ENTERDEBUGGER,"Activate the built-in debugger",AM_K,0,0,AKS_ENTERDEBUGGER)
-DEFEVENT(SPC_STATESAVE,"Quick save state",AM_K,0,0,AKS_STATESAVEQUICK)
-DEFEVENT(SPC_STATERESTORE,"Quick restore state",AM_K,0,0,AKS_STATERESTOREQUICK)
-DEFEVENT(SPC_STATESAVEDIALOG,"Save state",AM_K,0,0,AKS_STATESAVEDIALOG)
-DEFEVENT(SPC_STATERESTOREDIALOG,"Restore state",AM_K,0,0,AKS_STATERESTOREDIALOG)
-DEFEVENT(SPC_TOGGLEFULLSCREEN,"Toggle windowed/fullscreen",AM_K,0,0,AKS_TOGGLEFULLSCREEN)
-DEFEVENT(SPC_TOGGLEMOUSEGRAB,"Toggle between mouse grabbed and un-grabbed",AM_K,0,0,AKS_TOGGLEMOUSEGRAB)
-DEFEVENT(SPC_DECREASE_REFRESHRATE,"Decrease emulation speed",AM_K,0,0,AKS_DECREASEREFRESHRATE)
-DEFEVENT(SPC_INCREASE_REFRESHRATE,"Increase emulation speed",AM_K,0,0,AKS_INCREASEREFRESHRATE)
-DEFEVENT(SPC_SWITCHINTERPOL,"Switch between audio interpolation methods",AM_K,0,0,AKS_SWITCHINTERPOL)
-
-DEFEVENT(SPC_DISKSWAPPER_NEXT,"Next slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_NEXT)
-DEFEVENT(SPC_DISKSWAPPER_PREV,"Previous slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_PREV)
-DEFEVENT(SPC_DISKSWAPPER_INSERT0,"Insert disk in current Disk Swapper slot in DF0:",AM_K,0,0,AKS_DISKSWAPPER_INSERT0)
-DEFEVENT(SPC_DISKSWAPPER_INSERT1,"Insert disk in current Disk Swapper slot in DF1:",AM_K,0,0,AKS_DISKSWAPPER_INSERT1)
-DEFEVENT(SPC_DISKSWAPPER_INSERT2,"Insert disk in current Disk Swapper slot in DF2:",AM_K,0,0,AKS_DISKSWAPPER_INSERT2)
-DEFEVENT(SPC_DISKSWAPPER_INSERT3,"Insert disk in current Disk Swapper slot in DF3:",AM_K,0,0,AKS_DISKSWAPPER_INSERT3)
-
-DEFEVENT(SPC_INPUT_CONFIG1,"Select Input Configuration #1",AM_K,0,0,AKS_INPUT_CONFIG_1)
-DEFEVENT(SPC_INPUT_CONFIG2,"Select Input Configuration #2",AM_K,0,0,AKS_INPUT_CONFIG_2)
-DEFEVENT(SPC_INPUT_CONFIG3,"Select Input Configuration #3",AM_K,0,0,AKS_INPUT_CONFIG_3)
-DEFEVENT(SPC_INPUT_CONFIG4,"Select Input Configuration #4",AM_K,0,0,AKS_INPUT_CONFIG_4)
-
-DEFEVENT(SPC_ARCADIA_DIAGNOSTICS,"Arcadia diagnostics dip switch",AM_K,0,0,AKS_ARCADIADIAGNOSTICS)
-DEFEVENT(SPC_ARCADIA_PLAYER1,"Arcadia player 1",AM_K,0,0,AKS_ARCADIAPLY1)
-DEFEVENT(SPC_ARCADIA_PLAYER2,"Arcadia player 2",AM_K,0,0,AKS_ARCADIAPLY2)
-DEFEVENT(SPC_ARCADIA_COIN1,"Arcadia coin player 1",AM_K,0,0,AKS_ARCADIACOIN1)
-DEFEVENT(SPC_ARCADIA_COIN2,"Arcadia coin player 2",AM_K,0,0,AKS_ARCADIACOIN2)
+DEFEVENT(SPC_ENTERGUI,L"Enter GUI",AM_K,0,0,AKS_ENTERGUI)
+DEFEVENT(SPC_SCREENSHOT,L"Screenshot",AM_K,0,0,AKS_SCREENSHOT)
+DEFEVENT(SPC_FREEZEBUTTON,L"Activate Cartridge",AM_K,0,0,AKS_FREEZEBUTTON)
+DEFEVENT(SPC_FLOPPY0,L"Change disk in DF0:",AM_K,0,0,AKS_FLOPPY0)
+DEFEVENT(SPC_FLOPPY1,L"Change disk in DF1:",AM_K,0,0,AKS_FLOPPY1)
+DEFEVENT(SPC_FLOPPY2,L"Change disk in DF2:",AM_K,0,0,AKS_FLOPPY2)
+DEFEVENT(SPC_FLOPPY3,L"Change disk in DF3:",AM_K,0,0,AKS_FLOPPY3)
+DEFEVENT(SPC_EFLOPPY0,L"Eject disk in DF0:",AM_K,0,0,AKS_EFLOPPY0)
+DEFEVENT(SPC_EFLOPPY1,L"Eject disk in DF1:",AM_K,0,0,AKS_EFLOPPY1)
+DEFEVENT(SPC_EFLOPPY2,L"Eject disk in DF2:",AM_K,0,0,AKS_EFLOPPY2)
+DEFEVENT(SPC_EFLOPPY3,L"Eject disk in DF3:",AM_K,0,0,AKS_EFLOPPY3)
+DEFEVENT(SPC_PAUSE,L"Pause emulation",AM_K,0,0,AKS_PAUSE)
+DEFEVENT(SPC_WARP,L"Warp mode",AM_K,0,0,AKS_WARP)
+DEFEVENT(SPC_INHIBITSCREEN,L"Toggle screen updates",AM_K,0,0,AKS_INHIBITSCREEN)
+DEFEVENT(SPC_IRQ7,L"Level 7 interrupt",AM_K,0,0,AKS_IRQ7)
+DEFEVENT(SPC_STATEREWIND,L"Load previous state capture",AM_K,0,0,AKS_STATEREWIND)
+DEFEVENT(SPC_VOLUME_DOWN,L"Decrease volume level",AM_K,0,0,AKS_VOLDOWN)
+DEFEVENT(SPC_VOLUME_UP,L"Increase volume level",AM_K,0,0,AKS_VOLUP)
+DEFEVENT(SPC_VOLUME_MUTE,L"Mute/unmute volume",AM_K,0,0,AKS_VOLMUTE)
+DEFEVENT(SPC_MASTER_VOLUME_DOWN,L"Decrease master volume level",AM_K,0,0,AKS_MVOLDOWN)
+DEFEVENT(SPC_MASTER_VOLUME_UP,L"Increase master volume level",AM_K,0,0,AKS_MVOLUP)
+DEFEVENT(SPC_MASTER_VOLUME_MUTE,L"Mute/unmute master volume",AM_K,0,0,AKS_MVOLMUTE)
+DEFEVENT(SPC_QUIT,L"Quit emulator",AM_K,0,0,AKS_QUIT)
+DEFEVENT(SPC_SOFTRESET,L"Reset emulation",AM_K,0,0,AKS_SOFTRESET)
+DEFEVENT(SPC_HARDRESET,L"Hard reset emulation",AM_K,0,0,AKS_HARDRESET)
+DEFEVENT(SPC_ENTERDEBUGGER,L"Activate the built-in debugger",AM_K,0,0,AKS_ENTERDEBUGGER)
+DEFEVENT(SPC_STATESAVE,L"Quick save state",AM_K,0,0,AKS_STATESAVEQUICK)
+DEFEVENT(SPC_STATERESTORE,L"Quick restore state",AM_K,0,0,AKS_STATERESTOREQUICK)
+DEFEVENT(SPC_STATESAVEDIALOG,L"Save state",AM_K,0,0,AKS_STATESAVEDIALOG)
+DEFEVENT(SPC_STATERESTOREDIALOG,L"Restore state",AM_K,0,0,AKS_STATERESTOREDIALOG)
+DEFEVENT(SPC_TOGGLEFULLSCREEN,L"Toggle windowed/fullscreen",AM_K,0,0,AKS_TOGGLEFULLSCREEN)
+DEFEVENT(SPC_TOGGLEMOUSEGRAB,L"Toggle between mouse grabbed and un-grabbed",AM_K,0,0,AKS_TOGGLEMOUSEGRAB)
+DEFEVENT(SPC_DECREASE_REFRESHRATE,L"Decrease emulation speed",AM_K,0,0,AKS_DECREASEREFRESHRATE)
+DEFEVENT(SPC_INCREASE_REFRESHRATE,L"Increase emulation speed",AM_K,0,0,AKS_INCREASEREFRESHRATE)
+DEFEVENT(SPC_SWITCHINTERPOL,L"Switch between audio interpolation methods",AM_K,0,0,AKS_SWITCHINTERPOL)
+
+DEFEVENT(SPC_DISKSWAPPER_NEXT,L"Next slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_NEXT)
+DEFEVENT(SPC_DISKSWAPPER_PREV,L"Previous slot in Disk Swapper",AM_K,0,0,AKS_DISKSWAPPER_PREV)
+DEFEVENT(SPC_DISKSWAPPER_INSERT0,L"Insert disk in current Disk Swapper slot in DF0:",AM_K,0,0,AKS_DISKSWAPPER_INSERT0)
+DEFEVENT(SPC_DISKSWAPPER_INSERT1,L"Insert disk in current Disk Swapper slot in DF1:",AM_K,0,0,AKS_DISKSWAPPER_INSERT1)
+DEFEVENT(SPC_DISKSWAPPER_INSERT2,L"Insert disk in current Disk Swapper slot in DF2:",AM_K,0,0,AKS_DISKSWAPPER_INSERT2)
+DEFEVENT(SPC_DISKSWAPPER_INSERT3,L"Insert disk in current Disk Swapper slot in DF3:",AM_K,0,0,AKS_DISKSWAPPER_INSERT3)
+
+DEFEVENT(SPC_INPUT_CONFIG1,L"Select Input Configuration #1",AM_K,0,0,AKS_INPUT_CONFIG_1)
+DEFEVENT(SPC_INPUT_CONFIG2,L"Select Input Configuration #2",AM_K,0,0,AKS_INPUT_CONFIG_2)
+DEFEVENT(SPC_INPUT_CONFIG3,L"Select Input Configuration #3",AM_K,0,0,AKS_INPUT_CONFIG_3)
+DEFEVENT(SPC_INPUT_CONFIG4,L"Select Input Configuration #4",AM_K,0,0,AKS_INPUT_CONFIG_4)
+
+DEFEVENT(SPC_ARCADIA_DIAGNOSTICS,L"Arcadia diagnostics dip switch",AM_K,0,0,AKS_ARCADIADIAGNOSTICS)
+DEFEVENT(SPC_ARCADIA_PLAYER1,L"Arcadia player 1",AM_K,0,0,AKS_ARCADIAPLY1)
+DEFEVENT(SPC_ARCADIA_PLAYER2,L"Arcadia player 2",AM_K,0,0,AKS_ARCADIAPLY2)
+DEFEVENT(SPC_ARCADIA_COIN1,L"Arcadia coin player 1",AM_K,0,0,AKS_ARCADIACOIN1)
+DEFEVENT(SPC_ARCADIA_COIN2,L"Arcadia coin player 2",AM_K,0,0,AKS_ARCADIACOIN2)
index f3b28af78f05da92ac5ba59dbc591f1425ce95aa..df842a26be8d08f68585e8e47aa18f7e24a8f1ce 100644 (file)
@@ -134,7 +134,7 @@ STATIC_INLINE int comp_fp_get (uae_u32 opcode, uae_u16 extra, int treg)
          }
         case 2: /* (d16,PC) */
          {
-            uae_u32 address=start_pc+((char *)comp_pc_p-(char *)start_pc_p)+
+            uae_u32 address=start_pc+((TCHAR *)comp_pc_p-(TCHAR *)start_pc_p)+
                        m68k_pc_offset;
             uae_s32 PC16off =(uae_s32)(uae_s16)comp_get_iword((m68k_pc_offset+=2)-2);
             mov_l_ri(S1,address+PC16off);
@@ -151,20 +151,20 @@ STATIC_INLINE int comp_fp_get (uae_u32 opcode, uae_u16 extra, int treg)
                    float si = (float) li;
 
                    if (li == (int) si) {
-                       //write_log ("converted immediate LONG constant to SINGLE\n");
+                       //write_log (L"converted immediate LONG constant to SINGLE\n");
                        fmovs_ri(treg,*(uae_u32 *)&si);
                        return 1;
                    }
-                   //write_log ("immediate LONG constant\n");
+                   //write_log (L"immediate LONG constant\n");
                    fmovl_ri(treg,li);
                    return 2;
                  }
                case 1:
-                   //write_log ("immediate SINGLE constant\n");
+                   //write_log (L"immediate SINGLE constant\n");
                    fmovs_ri(treg,comp_get_ilong(m68k_pc_offset-4));
                    return 1;
                case 2:
-                   //write_log ("immediate LONG DOUBLE constant\n");
+                   //write_log (L"immediate LONG DOUBLE constant\n");
                    fmov_ext_ri(treg,comp_get_ilong(m68k_pc_offset-4),
                                  comp_get_ilong(m68k_pc_offset-8),
                                (comp_get_ilong(m68k_pc_offset-12)>>16)&0xffff);
@@ -173,7 +173,7 @@ STATIC_INLINE int comp_fp_get (uae_u32 opcode, uae_u16 extra, int treg)
                  {
                    float si = (float)(uae_s16)comp_get_iword(m68k_pc_offset-2);
 
-                   //write_log ("converted immediate WORD constant to SINGLE\n");
+                   //write_log (L"converted immediate WORD constant to SINGLE\n");
                    fmovs_ri(treg,*(uae_u32 *)&si);
                    return 1;
                  }
@@ -184,11 +184,11 @@ STATIC_INLINE int comp_fp_get (uae_u32 opcode, uae_u16 extra, int treg)
                    float si = (float)*(double *)longarray;
 
                    if (*(double *)longarray == (double)si) {
-                       //write_log ("SPEED GAIN: converted a DOUBLE constant to SINGLE\n");
+                       //write_log (L"SPEED GAIN: converted a DOUBLE constant to SINGLE\n");
                        fmovs_ri(treg,*(uae_u32 *)&si);
                        return 1;
                    }
-                   //write_log ("immediate DOUBLE constant\n");
+                   //write_log (L"immediate DOUBLE constant\n");
                    fmov_ri(treg,longarray[0],longarray[1]);
                    return 2;
                 }
@@ -196,7 +196,7 @@ STATIC_INLINE int comp_fp_get (uae_u32 opcode, uae_u16 extra, int treg)
                  {
                    float si = (float)(uae_s8)comp_get_ibyte(m68k_pc_offset-2);
 
-                   //write_log ("immediate BYTE constant converted to SINGLE\n");
+                   //write_log (L"immediate BYTE constant converted to SINGLE\n");
                    fmovs_ri(treg,*(uae_u32 *)&si);
                    return 1;
                  }
@@ -365,7 +365,7 @@ STATIC_INLINE int comp_fp_put (uae_u32 opcode, uae_u16 extra)
             break;
          }
         default: /* All other modes are not allowed for FPx to <EA> */
-           write_log ("JIT FMOVE FPx,<EA> Mode is not allowed %04x %04x\n",opcode,extra);
+           write_log (L"JIT FMOVE FPx,<EA> Mode is not allowed %04x %04x\n",opcode,extra);
            return -1;
        }
     }
@@ -467,7 +467,7 @@ void comp_fscc_opp (uae_u32 opcode, uae_u16 extra)
     }
 
 #if DEBUG_FPP
-    write_log ("JIT: fscc_opp at %08lx\n", M68K_GETPC);
+    write_log (L"JIT: fscc_opp at %08lx\n", M68K_GETPC);
 #endif
 
     if (extra&0x20) {  /* only cc from 00 to 1f are defined */
@@ -990,14 +990,14 @@ void comp_fpp_opp (uae_u32 opcode, uae_u16 extra)
                mov_l_rr((opcode & 7)+8,ad);
            return;
        } /* no break */
-       write_log ("fallback from JIT FMOVEM dynamic register list\n");
+       write_log (L"fallback from JIT FMOVEM dynamic register list\n");
        FAIL(1);
        return;
 #endif
      case 2: /* from <EA> to FPx */
        dont_care_fflags();
        if ((extra & 0xfc00) == 0x5c00) { /* FMOVECR */
-           //write_log ("JIT FMOVECR %x\n", opmode);
+           //write_log (L"JIT FMOVECR %x\n", opmode);
            switch (opmode) {
                case 0x00:
                    fmov_pi(dreg);
@@ -1448,7 +1448,7 @@ void comp_fpp_opp (uae_u32 opcode, uae_u16 extra)
        fmov_rr(FP_RESULT,dreg);
        return;
      default:
-       write_log ("Unsupported JIT-FPU instruction: 0x%04x %04x\n",opcode,extra);
+       write_log (L"Unsupported JIT-FPU instruction: 0x%04x %04x\n",opcode,extra);
        FAIL(1);
        return;
     }
index e86cea6fb43703ec87f29398f187d75dc240e784..1555b2860089fe790129999fb3cea60cb03816d6 100644 (file)
@@ -641,7 +641,7 @@ LOWFUNC(NONE,NONE,2,raw_imul_64_32,(RW4 d, RW4 s))
 {
 #ifdef JIT_DEBUG
     if (d!=MUL_NREG1 || s!=MUL_NREG2) {
-       write_log ("JIT: Bad register in IMUL: d=%d, s=%d\n",d,s);
+       write_log (L"JIT: Bad register in IMUL: d=%d, s=%d\n",d,s);
        abort();
     }
 #endif
@@ -654,7 +654,7 @@ LOWFUNC(NONE,NONE,2,raw_mul_64_32,(RW4 d, RW4 s))
 {
 #ifdef JIT_DEBUG
     if (d!=MUL_NREG1 || s!=MUL_NREG2) {
-       write_log ("JIT: Bad register in MUL: d=%d, s=%d\n",d,s);
+       write_log (L"JIT: Bad register in MUL: d=%d, s=%d\n",d,s);
        abort();
     }
 #endif
@@ -1723,13 +1723,13 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
     if (pExceptRecord)
        addr = (uae_u32)(pExceptRecord->ExceptionInformation[1]);
 #ifdef JIT_DEBUG
-    write_log ("JIT: fault address is 0x%x at 0x%x\n",addr,i);
+    write_log (L"JIT: fault address is 0x%x at 0x%x\n",addr,i);
 #endif
     if (!canbang || !currprefs.cachesize)
        return EXCEPTION_CONTINUE_SEARCH;
 
     if (in_handler)
-       write_log ("JIT: Argh --- Am already in a handler. Shouldn't happen!\n");
+       write_log (L"JIT: Argh --- Am already in a handler. Shouldn't happen!\n");
 
     if (canbang && i>=compiled_code && i<=current_compile_p) {
        if (*i==0x66) {
@@ -1803,7 +1803,7 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
     if (r!=-1) {
        void* pr=NULL;
 #ifdef JIT_DEBUG
-       write_log ("JIT: register was %d, direction was %d, size was %d\n",r,dir,size);
+       write_log (L"JIT: register was %d, direction was %d, size was %d\n",r,dir,size);
 #endif
 
        switch(r) {
@@ -1849,7 +1849,7 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
 #ifdef JIT_DEBUG
                if ((addr>=0x10000000 && addr<0x40000000) ||
                    (addr>=0x50000000)) {
-                       write_log ("JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
+                       write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
                }
 #endif
                if (dir==SIG_READ) {
@@ -1869,7 +1869,7 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
                    }
                }
 #ifdef JIT_DEBUG
-               write_log ("JIT: Handled one access!\n");
+               write_log (L"JIT: Handled one access!\n");
 #endif
                fflush(stdout);
                segvcount++;
@@ -1885,7 +1885,7 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
 #ifdef JIT_DEBUG
                if ((addr>=0x10000000 && addr<0x40000000) ||
                    (addr>=0x50000000)) {
-                   write_log ("JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
+                   write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
                }
 #endif
 
@@ -1896,8 +1896,8 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
                emit_long((uae_u32)veccode-(uae_u32)target-4);
 #ifdef JIT_DEBUG
 
-               write_log ("JIT: Create jump to %p\n",veccode);
-               write_log ("JIT: Handled one access!\n");
+               write_log (L"JIT: Create jump to %p\n",veccode);
+               write_log (L"JIT: Handled one access!\n");
 #endif
                segvcount++;
 
@@ -1933,7 +1933,7 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
                    (uae_u8*)bi->direct_handler<=i &&
                    (uae_u8*)bi->nexthandler>i) {
 #ifdef JIT_DEBUG
-                   write_log ("JIT: deleted trigger (%p<%p<%p) %p\n",
+                   write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n",
                        bi->handler,
                        i,
                        bi->nexthandler,
@@ -1954,7 +1954,7 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
                    (uae_u8*)bi->direct_handler<=i &&
                    (uae_u8*)bi->nexthandler>i) {
 #ifdef JIT_DEBUG
-                   write_log ("JIT: deleted trigger (%p<%p<%p) %p\n",
+                   write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n",
                        bi->handler,
                        i,
                        bi->nexthandler,
@@ -1968,24 +1968,24 @@ int EvalException (LPEXCEPTION_POINTERS blah, int n_except)
                bi=bi->next;
            }
 #ifdef JIT_DEBUG
-           write_log ("JIT: Huh? Could not find trigger!\n");
+           write_log (L"JIT: Huh? Could not find trigger!\n");
 #endif
            return EXCEPTION_CONTINUE_EXECUTION;
        }
     }
-    write_log ("JIT: Can't handle access %08X!\n", i);
+    write_log (L"JIT: Can't handle access %08X!\n", i);
 #if 0
     if (i)
     {
        int j;
 
        for (j=0;j<10;j++) {
-           write_log ("JIT: instruction byte %2d is 0x%02x\n",j,i[j]);
+           write_log (L"JIT: instruction byte %2d is 0x%02x\n",j,i[j]);
        }
     }
-    write_log ("Please send the above info (starting at \"fault address\") to\n"
-          "bmeyer@csse.monash.edu.au\n"
-          "This shouldn't happen ;-)\n");
+    write_log (L"Please send the above info (starting at \"fault address\") to\n"
+          L"bmeyer@csse.monash.edu.au\n"
+          L"This shouldn't happen ;-)\n");
 #endif
     return EXCEPTION_CONTINUE_SEARCH;
 }
@@ -2000,11 +2000,11 @@ static void vec(int x, struct sigcontext sc)
     int len=0;
     int j;
 
-    write_log ("JIT: fault address is %08x at %08x\n",sc.cr2,sc.eip);
+    write_log (L"JIT: fault address is %08x at %08x\n",sc.cr2,sc.eip);
     if (!canbang)
-       write_log ("JIT: Not happy! Canbang is 0 in SIGSEGV handler!\n");
+       write_log (L"JIT: Not happy! Canbang is 0 in SIGSEGV handler!\n");
     if (in_handler)
-       write_log ("JIT: Argh --- Am already in a handler. Shouldn't happen!\n");
+       write_log (L"JIT: Argh --- Am already in a handler. Shouldn't happen!\n");
 
     if (canbang && i>=compiled_code && i<=current_compile_p) {
        if (*i==0x66) {
@@ -2079,7 +2079,7 @@ static void vec(int x, struct sigcontext sc)
 
     if (r!=-1) {
        void* pr=NULL;
-       write_log ("JIT: register was %d, direction was %d, size was %d\n",r,dir,size);
+       write_log (L"JIT: register was %d, direction was %d, size was %d\n",r,dir,size);
 
        switch(r) {
         case 0: pr=&(sc.eax); break;
@@ -2106,7 +2106,7 @@ static void vec(int x, struct sigcontext sc)
 
            if ((addr>=0x10000000 && addr<0x40000000) ||
                (addr>=0x50000000)) {
-               write_log ("JIT: Suspicious address in %x SEGV handler.\n",addr);
+               write_log (L"JIT: Suspicious address in %x SEGV handler.\n",addr);
            }
            if (dir==SIG_READ) {
                switch(size) {
@@ -2124,7 +2124,7 @@ static void vec(int x, struct sigcontext sc)
                 default: abort();
                }
            }
-           write_log ("JIT: Handled one access!\n");
+           write_log (L"JIT: Handled one access!\n");
            fflush(stdout);
            segvcount++;
            sc.eip+=len;
@@ -2138,7 +2138,7 @@ static void vec(int x, struct sigcontext sc)
 
                if ((addr>=0x10000000 && addr<0x40000000) ||
                    (addr>=0x50000000)) {
-                   write_log ("JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
+                   write_log (L"JIT: Suspicious address 0x%x in SEGV handler.\n",addr);
                }
 
                target=(uae_u8*)sc.eip;
@@ -2146,9 +2146,9 @@ static void vec(int x, struct sigcontext sc)
                    vecbuf[i]=target[i];
                emit_byte(0xe9);
                emit_long((uae_u32)veccode-(uae_u32)target-4);
-               write_log ("JIT: Create jump to %p\n",veccode);
+               write_log (L"JIT: Create jump to %p\n",veccode);
 
-               write_log ("JIT: Handled one access!\n");
+               write_log (L"JIT: Handled one access!\n");
                segvcount++;
 
                target=veccode;
@@ -2182,7 +2182,7 @@ static void vec(int x, struct sigcontext sc)
                if (bi->handler &&
                    (uae_u8*)bi->direct_handler<=i &&
                    (uae_u8*)bi->nexthandler>i) {
-                   write_log ("JIT: deleted trigger (%p<%p<%p) %p\n",
+                   write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n",
                              bi->handler,
                              i,
                              bi->nexthandler,
@@ -2201,7 +2201,7 @@ static void vec(int x, struct sigcontext sc)
                if (bi->handler &&
                    (uae_u8*)bi->direct_handler<=i &&
                    (uae_u8*)bi->nexthandler>i) {
-                   write_log ("JIT: deleted trigger (%p<%p<%p) %p\n",
+                   write_log (L"JIT: deleted trigger (%p<%p<%p) %p\n",
                              bi->handler,
                              i,
                              bi->nexthandler,
@@ -2213,16 +2213,16 @@ static void vec(int x, struct sigcontext sc)
                }
                bi=bi->next;
            }
-           write_log ("JIT: Huh? Could not find trigger!\n");
+           write_log (L"JIT: Huh? Could not find trigger!\n");
            return;
        }
     }
-    write_log ("JIT: Can't handle access!\n");
+    write_log (L"JIT: Can't handle access!\n");
     for (j=0;j<10;j++) {
-       write_log ("JIT: instruction byte %2d is %02x\n",j,i[j]);
+       write_log (L"JIT: instruction byte %2d is %02x\n",j,i[j]);
     }
 #if 0
-    write_log ("Please send the above info (starting at \"fault address\") to\n"
+    write_log (L"Please send the above info (starting at \"fault address\") to\n"
           "bmeyer@csse.monash.edu.au\n"
           "This shouldn't happen ;-)\n");
     fflush(stdout);
@@ -2465,9 +2465,12 @@ static void raw_init_cpu(void)
        align_loops = x86_alignments[c->x86_processor].align_loop;
        align_jumps = x86_alignments[c->x86_processor].align_jump;
   }
-
-    write_log ("CPUID level=%d, Family=%d, Model=%d, Mask=%d, Vendor=%s [%d]\n",
-       c->cpuid_level, c->x86, c->x86_model, c->x86_mask, c->x86_vendor_id, c->x86_vendor);
+  { 
+      TCHAR *s = au (c->x86_vendor_id);
+       write_log (L"CPUID level=%d, Family=%d, Model=%d, Mask=%d, Vendor=%s [%d]\n",
+           c->cpuid_level, c->x86, c->x86_model, c->x86_mask, s, c->x86_vendor);
+       xfree (s);
+  }
 }
 
 #if 0
@@ -2493,7 +2496,7 @@ static int target_check_bsf(void)
                }
        }}}}
        if (mismatch)
-               write_log ("Target CPU defines all flags on BSF instruction\n");
+               write_log (L"Target CPU defines all flags on BSF instruction\n");
        return !mismatch;
 }
 #endif
@@ -2561,7 +2564,7 @@ static void raw_init_cpu(void)
 
     x=cpuid(0);
     maxlev=x.eax;
-    write_log ("Max CPUID level=%d Processor is %c%c%c%c%c%c%c%c%c%c%c%c\n",
+    write_log (L"Max CPUID level=%d Processor is %c%c%c%c%c%c%c%c%c%c%c%c\n",
              maxlev,
              x.ebx,
              x.ebx>>8,
@@ -2589,16 +2592,16 @@ static void raw_init_cpu(void)
        have_rat_stall=0;
 #endif
 #if 0
-    write_log ("have_cmov=%d, avoid_cmov=%d, have_rat_stall=%d\n",
+    write_log (L"have_cmov=%d, avoid_cmov=%d, have_rat_stall=%d\n",
               have_cmov,currprefs.avoid_cmov,have_rat_stall);
     if (currprefs.avoid_cmov) {
-       write_log ("Disabling cmov use despite processor claiming to support it!\n");
+       write_log (L"Disabling cmov use despite processor claiming to support it!\n");
        have_cmov=0;
     }
 #else
     /* Dear Bernie, I don't want to keep around options which are useless, and not
        represented in the GUI anymore... Is this okay? */
-    write_log ("have_cmov=%d, have_rat_stall=%d\n", have_cmov, have_rat_stall);
+    write_log (L"have_cmov=%d, have_rat_stall=%d\n", have_cmov, have_rat_stall);
 #endif
 #if 0   /* For testing of non-cmov code! */
     have_cmov=0;
@@ -2683,7 +2686,7 @@ STATIC_INLINE int stackpos(int r)
     if (live.spos[r]<0)
        abort();
     if (live.tos<live.spos[r]) {
-       write_log ("JIT: Looking for spos for fnreg %d\n",r);
+       write_log (L"JIT: Looking for spos for fnreg %d\n",r);
        abort();
     }
     return live.tos-live.spos[r];
@@ -2697,7 +2700,7 @@ STATIC_INLINE void usereg(int r)
 {
 
     if (live.spos[r]<0) {
-       // write_log ("usereg wants to push reg %d onto the x87 stack calling make_tos\n", r);
+       // write_log (L"usereg wants to push reg %d onto the x87 stack calling make_tos\n", r);
        make_tos(r);
     }
 }
@@ -3207,7 +3210,7 @@ LOWFUNC(NONE,NONE,3,raw_fsincos_rr,(FW d, FW c, FR s))
     int ds;
 
     if (s==d) {
-       //write_log ("FSINCOS src = dest\n");
+       //write_log (L"FSINCOS src = dest\n");
        make_tos(s);
        emit_byte(0xd9);
        emit_byte(0xfb); /* fsincos sin(x) push cos(x) */
@@ -3254,7 +3257,7 @@ LOWFUNC(NONE,NONE,2,raw_fscale_rr,(FRW d, FR s))
     int ds;
 
     if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) {
-       //write_log ("fscale found x in TOS-1 and y in TOS\n");
+       //write_log (L"fscale found x in TOS-1 and y in TOS\n");
        emit_byte(0xd9);
        emit_byte(0xfd);    /* fscale y*(2^x) */
     }
@@ -3997,7 +4000,7 @@ LOWFUNC(NONE,NONE,2,raw_frem_rr,(FRW d, FR s))
     int ds;
 
     if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) {
-       //write_log ("frem found x in TOS-1 and y in TOS\n");
+       //write_log (L"frem found x in TOS-1 and y in TOS\n");
        emit_byte(0xd9);
        emit_byte(0xf8);    /* fprem rem(y/x) */
     }
@@ -4018,7 +4021,7 @@ LOWFUNC(NONE,NONE,2,raw_frem1_rr,(FRW d, FR s))
     int ds;
 
     if (live.spos[d]==live.tos && live.spos[s]==live.tos-1) {
-       //write_log ("frem1 found x in TOS-1 and y in TOS\n");
+       //write_log (L"frem1 found x in TOS-1 and y in TOS\n");
        emit_byte(0xd9);
        emit_byte(0xf5);    /* fprem1 rem1(y/x) */
     }
index 73277d874191e9d64c40278e3d64a5bed37f6cfc..d44bf2875210e819dd70701b1cd0e4d62181e254 100644 (file)
@@ -276,14 +276,14 @@ STATIC_INLINE void adjust_jmpdep(dependency* d, void* a)
 
 STATIC_INLINE void set_dhtu(blockinfo* bi, void* dh)
 {
-    //write_log ("JIT: bi is %p\n",bi);
+    //write_log (L"JIT: bi is %p\n",bi);
     if (dh!=bi->direct_handler_to_use) {
        dependency* x=bi->deplist;
-       //write_log ("JIT: bi->deplist=%p\n",bi->deplist);
+       //write_log (L"JIT: bi->deplist=%p\n",bi->deplist);
        while (x) {
-           //write_log ("JIT: x is %p\n",x);
-           //write_log ("JIT: x->next is %p\n",x->next);
-           //write_log ("JIT: x->prev_p is %p\n",x->prev_p);
+           //write_log (L"JIT: x is %p\n",x);
+           //write_log (L"JIT: x->next is %p\n",x->next);
+           //write_log (L"JIT: x->prev_p is %p\n",x->prev_p);
 
            if (x->jmp_off) {
                adjust_jmpdep(x,dh);
@@ -346,7 +346,7 @@ STATIC_INLINE void big_to_small_state(bigstate* b, smallstate* s)
            count++;
        }
     }
-    write_log ("JIT: count=%d\n",count);
+    write_log (L"JIT: count=%d\n",count);
     for (i=0;i<N_REGS;i++) {  // FIXME --- don't do dirty yet
        s->nat[i].dirtysize=0;
     }
@@ -480,11 +480,11 @@ int check_prefs_changed_comp (void)
        changed = 1;
 
        if (currprefs.cachesize)
-           write_log ( "JIT: Reverting to \"indirect\" access, because canbang is zero!\n" );
+           write_log (L"JIT: Reverting to \"indirect\" access, because canbang is zero!\n");
     }
 
     if (changed)
-       write_log ("JIT: cache=%d. b=%d w=%d l=%d fpu=%d nf=%d const=%d hard=%d\n",
+       write_log (L"JIT: cache=%d. b=%d w=%d l=%d fpu=%d nf=%d const=%d hard=%d\n",
            currprefs.cachesize,
            currprefs.comptrustbyte, currprefs.comptrustword, currprefs.comptrustlong, 
            currprefs.compfpu, currprefs.compnf, currprefs.comp_constjump, currprefs.comp_hardflush);
@@ -493,21 +493,21 @@ int check_prefs_changed_comp (void)
     if (!currprefs.compforcesettings) {
        int stop=0;
        if (currprefs.comptrustbyte!=0 && currprefs.comptrustbyte!=3)
-           stop = 1, write_log ("JIT: comptrustbyte is not 'direct' or 'afterpic'\n");
+           stop = 1, write_log (L"JIT: comptrustbyte is not 'direct' or 'afterpic'\n");
        if (currprefs.comptrustword!=0 && currprefs.comptrustword!=3)
-           stop = 1, write_log ("JIT: comptrustword is not 'direct' or 'afterpic'\n");
+           stop = 1, write_log (L"JIT: comptrustword is not 'direct' or 'afterpic'\n");
        if (currprefs.comptrustlong!=0 && currprefs.comptrustlong!=3)
-           stop = 1, write_log ("JIT: comptrustlong is not 'direct' or 'afterpic'\n");
+           stop = 1, write_log (L"JIT: comptrustlong is not 'direct' or 'afterpic'\n");
        if (currprefs.comptrustnaddr!=0 && currprefs.comptrustnaddr!=3)
-           stop = 1, write_log ("JIT: comptrustnaddr is not 'direct' or 'afterpic'\n");
+           stop = 1, write_log (L"JIT: comptrustnaddr is not 'direct' or 'afterpic'\n");
        if (currprefs.compnf!=1)
-           stop = 1, write_log ("JIT: compnf is not 'yes'\n");
+           stop = 1, write_log (L"JIT: compnf is not 'yes'\n");
        if (currprefs.cachesize<1024)
-           stop = 1, write_log ("JIT: cachesize is less than 1024\n");
+           stop = 1, write_log (L"JIT: cachesize is less than 1024\n");
        if (currprefs.comp_hardflush)
-           stop = 1, write_log ("JIT: comp_flushmode is 'hard'\n");
+           stop = 1, write_log (L"JIT: comp_flushmode is 'hard'\n");
        if (!canbang)
-           stop = 1, write_log ("JIT: Cannot use most direct memory access,\n"
+           stop = 1, write_log (L"JIT: Cannot use most direct memory access,\n"
                                "     and unable to recover from failed guess!\n");
        if (stop) {
            gui_message("JIT: Configuration problems were detected!\n"
@@ -711,17 +711,17 @@ STATIC_INLINE void log_dump(void)
 
     return;
 
-    write_log ("----------------------\n");
+    write_log (L"----------------------\n");
     for (i=0;i<N_REGS;i++) {
        switch(nstate[i]) {
-        case L_UNKNOWN: write_log ("Nat %d : UNKNOWN\n",i); break;
-        case L_UNAVAIL: write_log ("Nat %d : UNAVAIL\n",i); break;
-        default:        write_log ("Nat %d : %d\n",i,nstate[i]); break;
+        case L_UNKNOWN: write_log (L"Nat %d : UNKNOWN\n",i); break;
+        case L_UNAVAIL: write_log (L"Nat %d : UNAVAIL\n",i); break;
+        default:        write_log (L"Nat %d : %d\n",i,nstate[i]); break;
        }
     }
     for (i=0;i<VREGS;i++) {
        if (vstate[i]==L_UNNEEDED)
-           write_log ("Virt %d: UNNEEDED\n",i);
+           write_log (L"Virt %d: UNNEEDED\n",i);
     }
 }
 
@@ -757,7 +757,7 @@ static  void tomem(int r)
        if (live.state[r].val &&
            live.nat[rr].nholds==1 &&
            !live.nat[rr].locked) {
-           // write_log ("JIT: RemovingA offset %x from reg %d (%d) at %p\n",
+           // write_log (L"JIT: RemovingA offset %x from reg %d (%d) at %p\n",
            //   live.state[r].val,r,rr,target);
            adjust_nreg(rr,live.state[r].val);
            live.state[r].val=0;
@@ -1147,7 +1147,7 @@ STATIC_INLINE void remove_offset(int r, int spec)
     rr=live.state[r].realreg;
 
     if (live.nat[rr].nholds==1) {
-       //write_log ("JIT: RemovingB offset %x from reg %d (%d) at %p\n",
+       //write_log (L"JIT: RemovingB offset %x from reg %d (%d) at %p\n",
        //       live.state[r].val,r,rr,target);
        adjust_nreg(rr,live.state[r].val);
        live.state[r].dirtysize=4;
@@ -1172,7 +1172,7 @@ STATIC_INLINE int readreg_general(int r, int size, int spec, int can_offset)
     int answer=-1;
 
     if (live.state[r].status==UNDEF) {
-       write_log ("JIT: WARNING: Unexpected read of undefined register %d\n",r);
+       write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
     }
     if (!can_offset)
        remove_offset(r,spec);
@@ -1318,7 +1318,7 @@ STATIC_INLINE int rmw_general(int r, int wsize, int rsize, int spec)
     int answer=-1;
 
     if (live.state[r].status==UNDEF) {
-       write_log ("JIT: WARNING: Unexpected read of undefined register %d\n",r);
+       write_log (L"JIT: WARNING: Unexpected read of undefined register %d\n",r);
     }
     remove_offset(r,spec);
     make_exclusive(r,0,spec);
@@ -1604,13 +1604,13 @@ STATIC_INLINE void f_make_exclusive(int r, int clobber)
            }
        }
        Dif (live.fat[rr].nholds!=1) {
-           write_log ("JIT: realreg %d holds %d (",rr,live.fat[rr].nholds);
+           write_log (L"JIT: realreg %d holds %d (",rr,live.fat[rr].nholds);
            for (i=0;i<live.fat[rr].nholds;i++) {
-               write_log ("JIT: %d(%d,%d)",live.fat[rr].holds[i],
+               write_log (L"JIT: %d(%d,%d)",live.fat[rr].holds[i],
                       live.fate[live.fat[rr].holds[i]].realreg,
                       live.fate[live.fat[rr].holds[i]].realind);
            }
-           write_log ("\n");
+           write_log (L"\n");
            jit_abort("x");
        }
        return;
@@ -3151,7 +3151,7 @@ MIDFUNC(2,mov_l_rr,(W4 d, R4 s))
     live.nat[s].nholds++;
     log_clobberreg(d);
 
-    /* write_log ("JIT: Added %d to nreg %d(%d), now holds %d regs\n",
+    /* write_log (L"JIT: Added %d to nreg %d(%d), now holds %d regs\n",
        d,s,live.state[d].realind,live.nat[s].nholds); */
     unlock(s);
 #else
@@ -4639,7 +4639,7 @@ STATIC_INLINE void match_states(smallstate* s)
         case UNDEF:
            break;
         default:
-           write_log ("JIT: Weird status: %d\n",live.state[i].status);
+           write_log (L"JIT: Weird status: %d\n",live.state[i].status);
            abort();
        }
     }
@@ -4650,12 +4650,12 @@ STATIC_INLINE void match_states(smallstate* s)
            int n=live.state[i].realreg;
 
            if (live.nat[n].nholds!=1) {
-               write_log ("JIT: Register %d isn't alone in nreg %d\n",
+               write_log (L"JIT: Register %d isn't alone in nreg %d\n",
                       i,n);
                abort();
            }
            if (vton[i]==-1) {
-               write_log ("JIT: Register %d is still in register, shouldn't be\n",
+               write_log (L"JIT: Register %d is still in register, shouldn't be\n",
                       i);
                abort();
            }
@@ -4674,7 +4674,7 @@ STATIC_INLINE void match_states(smallstate* s)
        int n=vton[i];
        if (n==-1) {
            Dif (isinreg(i)) {
-               write_log ("JIT: Register %d unexpectedly in nreg %d\n",
+               write_log (L"JIT: Register %d unexpectedly in nreg %d\n",
                       i,live.state[i].realreg);
                abort();
            }
@@ -4688,7 +4688,7 @@ STATIC_INLINE void match_states(smallstate* s)
                break;
             case INMEM:
                Dif (live.nat[n].nholds) {
-                   write_log ("JIT: natreg %d holds %d vregs, should be empty\n",
+                   write_log (L"JIT: natreg %d holds %d vregs, should be empty\n",
                           n,live.nat[n].nholds);
                }
                raw_mov_l_rm(n,(uae_u32)live.state[i].mem);
@@ -4705,7 +4705,7 @@ STATIC_INLINE void match_states(smallstate* s)
                break;
             case ISCONST:
                if (i!=PC_P) {
-                   write_log ("JIT: Got constant in matchstate for reg %d. Bad!\n",i);
+                   write_log (L"JIT: Got constant in matchstate for reg %d. Bad!\n",i);
                    abort();
                }
                break;
@@ -4790,7 +4790,7 @@ void flush(int save_regs)
                 default: break;
                }
                Dif (live.state[i].val && i!=PC_P) {
-                   write_log ("JIT: Register %d still has val %x\n",
+                   write_log (L"JIT: Register %d still has val %x\n",
                           i,live.state[i].val);
                }
            }
@@ -4804,7 +4804,7 @@ void flush(int save_regs)
        raw_fp_cleanup_drop();
     }
     if (needflags) {
-       write_log ("JIT: Warning! flush with needflags=1!\n");
+       write_log (L"JIT: Warning! flush with needflags=1!\n");
     }
 
     lopt_emit_all();
@@ -4852,7 +4852,7 @@ void freescratch(void)
     int i;
     for (i=0;i<N_REGS;i++)
        if (live.nat[i].locked && i!=4)
-           write_log ("JIT: Warning! %d is locked\n",i);
+           write_log (L"JIT: Warning! %d is locked\n",i);
 
     for (i=0;i<VREGS;i++)
        if (live.state[i].needflush==NF_SCRATCH) {
@@ -5433,11 +5433,11 @@ static void show_checksum(blockinfo* bi)
     }
     else {
        while (len>0) {
-           write_log ("%08x ",*pos);
+           write_log (L"%08x ",*pos);
            pos++;
            len-=4;
        }
-       write_log (" bla\n");
+       write_log (L" bla\n");
     }
 }
 
@@ -5522,7 +5522,7 @@ static void check_checksum(void)
        bi->handler_to_use=bi->handler;
        set_dhtu(bi,bi->direct_handler);
 
-       /*      write_log ("JIT: reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+       /*      write_log (L"JIT: reactivate %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
                c1,c2,bi->c1,bi->c2);*/
        remove_from_list(bi);
        add_to_active(bi);
@@ -5531,7 +5531,7 @@ static void check_checksum(void)
     else {
        /* This block actually changed. We need to invalidate it,
           and set it up to be recompiled */
-       /* write_log ("JIT: discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
+       /* write_log (L"JIT: discard %p/%p (%x %x/%x %x)\n",bi,bi->pc_p,
           c1,c2,bi->c1,bi->c2); */
        invalidate_block(bi);
        raise_in_cl_list(bi);
@@ -5688,12 +5688,12 @@ void build_comp(void)
 #endif
     raw_init_cpu();
 #ifdef NATMEM_OFFSET
-    write_log ("JIT: Setting signal handler\n");
+    write_log (L"JIT: Setting signal handler\n");
 #ifndef _WIN32
     signal(SIGSEGV,vec);
 #endif
 #endif
-    write_log ("JIT: Building Compiler function table\n");
+    write_log (L"JIT: Building Compiler function table\n");
     for (opcode = 0; opcode < 65536; opcode++) {
 #ifdef NOFLAGS_SUPPORT
        nfcpufunctbl[opcode] = op_illg;
@@ -5782,7 +5782,7 @@ void build_comp(void)
        if (compfunctbl[opcode])
            count++;
     }
-    write_log ("JIT: Supposedly %d compileable opcodes!\n",count);
+    write_log (L"JIT: Supposedly %d compileable opcodes!\n",count);
 
     /* Initialise state */
     alloc_cache();
@@ -5816,7 +5816,7 @@ static void flush_icache_hard(uae_u32 ptr, int n)
 
     hard_flush_count++;
 #if 0
-    write_log ("JIT: Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
+    write_log (L"JIT: Flush Icache_hard(%d/%x/%p), %u instruction bytes\n",
           n,regs.pc,regs.pc_p,current_compile_p-compiled_code);
 #endif
     bi=active;
index 223fa9e69d0400d8dc54f534332e240f48cdb592..f705fa12c742848a5b2c53f408887bb072f75c35 100644 (file)
--- a/keybuf.c
+++ b/keybuf.c
@@ -73,11 +73,11 @@ void record_key_direct (int kc)
     int k = kc >> 1;
     int b = !(kc & 1);
 
-    //write_log ("got kc %02X\n", ((kc << 7) | (kc >> 1)) & 0xff);
+    //write_log (L"got kc %02X\n", ((kc << 7) | (kc >> 1)) & 0xff);
     if (kpb_next == 256)
        kpb_next = 0;
     if (kpb_next == kpb_last) {
-       write_log ("Keyboard buffer overrun. Congratulations.\n");
+       write_log (L"Keyboard buffer overrun. Congratulations.\n");
        return;
     }
 
diff --git a/main.c b/main.c
index 0041e358167ec69a46632f5d08da1dc81535736b..0d68a8d5e3f5d6d61bf34dfd774e67d55f1ff8a3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -65,33 +65,14 @@ int kickstart_rom = 1;
 
 struct gui_info gui_data;
 
-char warning_buffer[256];
+TCHAR warning_buffer[256];
 
-char optionsfile[256];
+TCHAR optionsfile[256];
 
 int uaerand (void)
 {
     return rand ();
 }
-/* If you want to pipe printer output to a file, put something like
- * "cat >>printerfile.tmp" above.
- * The printer support was only tested with the driver "PostScript" on
- * Amiga side, using apsfilter for linux to print ps-data.
- *
- * Under DOS it ought to be -p LPT1: or -p PRN: but you'll need a
- * PostScript printer or ghostscript -=SR=-
- */
-
-/* Slightly stupid place for this... */
-/* ncurses.c might use quite a few of those. */
-char *colormodes[] = { "256 colors", "32768 colors", "65536 colors",
-    "256 colors dithered", "16 colors dithered", "16 million colors",
-    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
-    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
-    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
-    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
-    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
-};
 
 void discard_prefs (struct uae_prefs *p, int type)
 {
@@ -178,20 +159,20 @@ void fixup_prefs (struct uae_prefs *p)
        || p->chipmem_size < 0x20000
        || p->chipmem_size > 0x800000)
     {
-       write_log ("Unsupported chipmem size %x!\n", p->chipmem_size);
+       write_log (L"Unsupported chipmem size %x!\n", p->chipmem_size);
        p->chipmem_size = 0x200000;
        err = 1;
     }
     if ((p->fastmem_size & (p->fastmem_size - 1)) != 0
        || (p->fastmem_size != 0 && (p->fastmem_size < 0x100000 || p->fastmem_size > 0x800000)))
     {
-       write_log ("Unsupported fastmem size %x!\n", p->fastmem_size);
+       write_log (L"Unsupported fastmem size %x!\n", p->fastmem_size);
        err = 1;
     }
     if ((p->gfxmem_size & (p->gfxmem_size - 1)) != 0
        || (p->gfxmem_size != 0 && (p->gfxmem_size < 0x100000 || p->gfxmem_size > max_z3fastmem / 2)))
     {
-       write_log ("Unsupported graphics card memory size %x (%x)!\n", p->gfxmem_size, max_z3fastmem / 2);
+       write_log (L"Unsupported graphics card memory size %x (%x)!\n", p->gfxmem_size, max_z3fastmem / 2);
        if (p->gfxmem_size > max_z3fastmem / 2)
            p->gfxmem_size = max_z3fastmem / 2;
        else
@@ -201,7 +182,7 @@ void fixup_prefs (struct uae_prefs *p)
     if ((p->z3fastmem_size & (p->z3fastmem_size - 1)) != 0
        || (p->z3fastmem_size != 0 && (p->z3fastmem_size < 0x100000 || p->z3fastmem_size > max_z3fastmem)))
     {
-       write_log ("Unsupported Zorro III fastmem size %x (%x)!\n", p->z3fastmem_size, max_z3fastmem);
+       write_log (L"Unsupported Zorro III fastmem size %x (%x)!\n", p->z3fastmem_size, max_z3fastmem);
        if (p->z3fastmem_size > max_z3fastmem)
            p->z3fastmem_size = max_z3fastmem;
        else
@@ -211,7 +192,7 @@ void fixup_prefs (struct uae_prefs *p)
     if ((p->z3fastmem2_size & (p->z3fastmem2_size - 1)) != 0
        || (p->z3fastmem2_size != 0 && (p->z3fastmem2_size < 0x100000 || p->z3fastmem2_size > max_z3fastmem)))
     {
-       write_log ("Unsupported Zorro III fastmem size %x (%x)!\n", p->z3fastmem2_size, max_z3fastmem);
+       write_log (L"Unsupported Zorro III fastmem size %x (%x)!\n", p->z3fastmem2_size, max_z3fastmem);
        if (p->z3fastmem2_size > max_z3fastmem)
            p->z3fastmem2_size = max_z3fastmem;
        else
@@ -224,112 +205,112 @@ void fixup_prefs (struct uae_prefs *p)
 
     if (p->address_space_24 && (p->gfxmem_size != 0 || p->z3fastmem_size != 0)) {
        p->z3fastmem_size = p->gfxmem_size = 0;
-       write_log ("Can't use a graphics card or Zorro III fastmem when using a 24 bit\n"
-                "address space - sorry.\n");
+       write_log (L"Can't use a graphics card or Zorro III fastmem when using a 24 bit\n"
+                L"address space - sorry.\n");
     }
     if (p->bogomem_size != 0 && p->bogomem_size != 0x80000 && p->bogomem_size != 0x100000 && p->bogomem_size != 0x180000 && p->bogomem_size != 0x1c0000) {
        p->bogomem_size = 0;
-       write_log ("Unsupported bogomem size!\n");
+       write_log (L"Unsupported bogomem size!\n");
        err = 1;
     }
     if (p->bogomem_size > 0x100000 && (p->cs_fatgaryrev >= 0 || p->cs_ide || p->cs_ramseyrev >= 0)) {
        p->bogomem_size = 0x100000;
-       write_log ("Possible Gayle bogomem conflict fixed\n");
+       write_log (L"Possible Gayle bogomem conflict fixed\n");
     }
     if (p->chipmem_size > 0x200000 && p->fastmem_size != 0) {
-       write_log ("You can't use fastmem and more than 2MB chip at the same time!\n");
+       write_log (L"You can't use fastmem and more than 2MB chip at the same time!\n");
        p->fastmem_size = 0;
        err = 1;
     }
     if (p->mbresmem_low_size > 0x04000000 || (p->mbresmem_low_size & 0xfffff)) {
        p->mbresmem_low_size = 0;
-       write_log ("Unsupported A3000 MB RAM size\n");
+       write_log (L"Unsupported A3000 MB RAM size\n");
     }
     if (p->mbresmem_high_size > 0x04000000 || (p->mbresmem_high_size & 0xfffff)) {
        p->mbresmem_high_size = 0;
-       write_log ("Unsupported Motherboard RAM size\n");
+       write_log (L"Unsupported Motherboard RAM size\n");
     }
 
 #if 0
     if (p->m68k_speed < -1 || p->m68k_speed > 20) {
-       write_log ("Bad value for -w parameter: must be -1, 0, or within 1..20.\n");
+       write_log (L"Bad value for -w parameter: must be -1, 0, or within 1..20.\n");
        p->m68k_speed = 4;
        err = 1;
     }
 #endif
 
     if (p->produce_sound < 0 || p->produce_sound > 3) {
-       write_log ("Bad value for -S parameter: enable value must be within 0..3\n");
+       write_log (L"Bad value for -S parameter: enable value must be within 0..3\n");
        p->produce_sound = 0;
        err = 1;
     }
     if (p->comptrustbyte < 0 || p->comptrustbyte > 3) {
-       write_log ("Bad value for comptrustbyte parameter: value must be within 0..2\n");
+       write_log (L"Bad value for comptrustbyte parameter: value must be within 0..2\n");
        p->comptrustbyte = 1;
        err = 1;
     }
     if (p->comptrustword < 0 || p->comptrustword > 3) {
-       write_log ("Bad value for comptrustword parameter: value must be within 0..2\n");
+       write_log (L"Bad value for comptrustword parameter: value must be within 0..2\n");
        p->comptrustword = 1;
        err = 1;
     }
     if (p->comptrustlong < 0 || p->comptrustlong > 3) {
-       write_log ("Bad value for comptrustlong parameter: value must be within 0..2\n");
+       write_log (L"Bad value for comptrustlong parameter: value must be within 0..2\n");
        p->comptrustlong = 1;
        err = 1;
     }
     if (p->comptrustnaddr < 0 || p->comptrustnaddr > 3) {
-       write_log ("Bad value for comptrustnaddr parameter: value must be within 0..2\n");
+       write_log (L"Bad value for comptrustnaddr parameter: value must be within 0..2\n");
        p->comptrustnaddr = 1;
        err = 1;
     }
     if (p->compnf < 0 || p->compnf > 1) {
-       write_log ("Bad value for compnf parameter: value must be within 0..1\n");
+       write_log (L"Bad value for compnf parameter: value must be within 0..1\n");
        p->compnf = 1;
        err = 1;
     }
     if (p->comp_hardflush < 0 || p->comp_hardflush > 1) {
-       write_log ("Bad value for comp_hardflush parameter: value must be within 0..1\n");
+       write_log (L"Bad value for comp_hardflush parameter: value must be within 0..1\n");
        p->comp_hardflush = 1;
        err = 1;
     }
     if (p->comp_constjump < 0 || p->comp_constjump > 1) {
-       write_log ("Bad value for comp_constjump parameter: value must be within 0..1\n");
+       write_log (L"Bad value for comp_constjump parameter: value must be within 0..1\n");
        p->comp_constjump = 1;
        err = 1;
     }
     if (p->comp_oldsegv < 0 || p->comp_oldsegv > 1) {
-       write_log ("Bad value for comp_oldsegv parameter: value must be within 0..1\n");
+       write_log (L"Bad value for comp_oldsegv parameter: value must be within 0..1\n");
        p->comp_oldsegv = 1;
        err = 1;
     }
     if (p->cachesize < 0 || p->cachesize > 16384) {
-       write_log ("Bad value for cachesize parameter: value must be within 0..16384\n");
+       write_log (L"Bad value for cachesize parameter: value must be within 0..16384\n");
        p->cachesize = 0;
        err = 1;
     }
     if (p->z3fastmem_size > 0 && (p->address_space_24 || p->cpu_model < 68020)) {
-       write_log ("Z3 fast memory can't be used with a 68000/68010 emulation. It\n"
-                "requires a 68020 emulation. Turning off Z3 fast memory.\n");
+       write_log (L"Z3 fast memory can't be used with a 68000/68010 emulation. It\n"
+                L"requires a 68020 emulation. Turning off Z3 fast memory.\n");
        p->z3fastmem_size = 0;
        err = 1;
     }
     if (p->gfxmem_size > 0 && (p->cpu_model < 68020 || p->address_space_24)) {
-       write_log ("Picasso96 can't be used with a 68000/68010 or 68EC020 emulation. It\n"
-                "requires a 68020 emulation. Turning off Picasso96.\n");
+       write_log (L"Picasso96 can't be used with a 68000/68010 or 68EC020 emulation. It\n"
+                L"requires a 68020 emulation. Turning off Picasso96.\n");
        p->gfxmem_size = 0;
        err = 1;
     }
 #if !defined (BSDSOCKET)
     if (p->socket_emu) {
-       write_log ("Compile-time option of BSDSOCKET_SUPPORTED was not enabled.  You can't use bsd-socket emulation.\n");
+       write_log (L"Compile-time option of BSDSOCKET_SUPPORTED was not enabled.  You can't use bsd-socket emulation.\n");
        p->socket_emu = 0;
        err = 1;
     }
 #endif
 
     if (p->nr_floppies < 0 || p->nr_floppies > 4) {
-       write_log ("Invalid number of floppies.  Using 4.\n");
+       write_log (L"Invalid number of floppies.  Using 4.\n");
        p->nr_floppies = 4;
        p->dfxtype[0] = 0;
        p->dfxtype[1] = 0;
@@ -344,7 +325,7 @@ void fixup_prefs (struct uae_prefs *p)
        p->input_mouse_speed = 100;
     }
     if (p->collision_level < 0 || p->collision_level > 3) {
-       write_log ("Invalid collision support level.  Using 1.\n");
+       write_log (L"Invalid collision support level.  Using 1.\n");
        p->collision_level = 1;
        err = 1;
     }
@@ -411,7 +392,7 @@ void fixup_prefs (struct uae_prefs *p)
 
 int quit_program = 0;
 static int restart_program;
-static char restart_config[256];
+static TCHAR restart_config[256];
 
 void uae_reset (int hardreset)
 {
@@ -432,13 +413,13 @@ void uae_quit (void)
 }
 
 /* 0 = normal, 1 = nogui, -1 = disable nogui */
-void uae_restart (int opengui, char *cfgfile)
+void uae_restart (int opengui, TCHAR *cfgfile)
 {
     uae_quit ();
     restart_program = opengui > 0 ? 1 : (opengui == 0 ? 2 : 3);
     restart_config[0] = 0;
     if (cfgfile)
-       strcpy (restart_config, cfgfile);
+       _tcscpy (restart_config, cfgfile);
 }
 
 #ifndef DONT_PARSE_CMDLINE
@@ -446,81 +427,81 @@ void uae_restart (int opengui, char *cfgfile)
 void usage (void)
 {
 }
-static void parse_cmdline_2 (int argc, char **argv)
+static void parse_cmdline_2 (int argc, TCHAR **argv)
 {
     int i;
 
     cfgfile_addcfgparam (0);
     for (i = 1; i < argc; i++) {
-       if (strcmp (argv[i], "-cfgparam") == 0) {
+       if (_tcscmp (argv[i], L"-cfgparam") == 0) {
            if (i + 1 == argc)
-               write_log ("Missing argument for '-cfgparam' option.\n");
+               write_log (L"Missing argument for '-cfgparam' option.\n");
            else
                cfgfile_addcfgparam (argv[++i]);
        }
     }
 }
 
-static void parse_diskswapper (char *s)
+static void parse_diskswapper (TCHAR *s)
 {
-    char *tmp = my_strdup (s);
-    char *delim = ",";
-    char *p1, *p2;
+    TCHAR *tmp = my_strdup (s);
+    TCHAR *delim = L",";
+    TCHAR *p1, *p2;
     int num = 0;
 
     p1 = tmp;
     for (;;) {
-       p2 = strtok (p1, delim);
+       p2 = _tcstok (p1, delim);
        if (!p2)
            break;
        p1 = NULL;
        if (num >= MAX_SPARE_DRIVES)
            break;
-       strncpy (currprefs.dfxlist[num], p2, 255);
+       _tcsncpy (currprefs.dfxlist[num], p2, 255);
        num++;
     }
     free (tmp);
 }
 
-static void parse_cmdline (int argc, char **argv)
+static void parse_cmdline (int argc, TCHAR **argv)
 {
     int i;
 
     for (i = 1; i < argc; i++) {
-       if (!strncmp (argv[i], "-diskswapper=", 13)) {
+       if (!_tcsncmp (argv[i], L"-diskswapper=", 13)) {
            parse_diskswapper (argv[i] + 13);
-       } else if (strcmp (argv[i], "-cfgparam") == 0) {
+       } else if (_tcscmp (argv[i], L"-cfgparam") == 0) {
            if (i + 1 < argc)
                i++;
-       } else if (strncmp (argv[i], "-config=", 8) == 0) {
+       } else if (_tcsncmp (argv[i], L"-config=", 8) == 0) {
            currprefs.mountitems = 0;
            target_cfgfile_load (&currprefs, argv[i] + 8, -1, 1);
-       } else if (strncmp (argv[i], "-statefile=", 11) == 0) {
+       } else if (_tcsncmp (argv[i], L"-statefile=", 11) == 0) {
            savestate_state = STATE_DORESTORE;
-           strcpy (savestate_fname, argv[i] + 11);
-       } else if (strcmp (argv[i], "-f") == 0) {
+           _tcscpy (savestate_fname, argv[i] + 11);
+       } else if (_tcscmp (argv[i], L"-f") == 0) {
            /* Check for new-style "-f xxx" argument, where xxx is config-file */
            if (i + 1 == argc) {
-               write_log ("Missing argument for '-f' option.\n");
+               write_log (L"Missing argument for '-f' option.\n");
            } else {
                currprefs.mountitems = 0;
                target_cfgfile_load (&currprefs, argv[++i], -1, 1);
            }
-       } else if (strcmp (argv[i], "-s") == 0) {
+       } else if (_tcscmp (argv[i], L"-s") == 0) {
            if (i + 1 == argc)
-               write_log ("Missing argument for '-s' option.\n");
+               write_log (L"Missing argument for '-s' option.\n");
            else
                cfgfile_parse_line (&currprefs, argv[++i], 0);
-       } else if (strcmp (argv[i], "-h") == 0 || strcmp (argv[i], "-help") == 0) {
+       } else if (_tcscmp (argv[i], L"-h") == 0 || _tcscmp (argv[i], L"-help") == 0) {
            usage ();
            exit (0);
        } else {
            if (argv[i][0] == '-' && argv[i][1] != '\0') {
-               const char *arg = argv[i] + 2;
+               const TCHAR *arg = argv[i] + 2;
                int extra_arg = *arg == '\0';
                if (extra_arg)
                    arg = i + 1 < argc ? argv[i + 1] : 0;
-               if (parse_cmdline_option (&currprefs, argv[i][1], (char*)arg) && extra_arg)
+               if (parse_cmdline_option (&currprefs, argv[i][1], arg) && extra_arg)
                    i++;
            }
        }
@@ -528,31 +509,31 @@ static void parse_cmdline (int argc, char **argv)
 }
 #endif
 
-static void parse_cmdline_and_init_file (int argc, char **argv)
+static void parse_cmdline_and_init_file (int argc, TCHAR **argv)
 {
 
-    strcpy (optionsfile, "");
+    _tcscpy (optionsfile, L"");
 
 #ifdef OPTIONS_IN_HOME
     {
-       char *home = getenv ("HOME");
+       TCHAR *home = getenv ("HOME");
        if (home != NULL && strlen (home) < 240)
        {
-           strcpy (optionsfile, home);
-           strcat (optionsfile, "/");
+           _tcscpy (optionsfile, home);
+           _tcscat (optionsfile, L"/");
        }
     }
 #endif
 
     parse_cmdline_2 (argc, argv);
 
-    strcat (optionsfile, restart_config);
+    _tcscat (optionsfile, restart_config);
 
     if (! target_cfgfile_load (&currprefs, optionsfile, 0, 0)) {
-       write_log ("failed to load config '%s'\n", optionsfile);
+       write_log (L"failed to load config '%s'\n", optionsfile);
 #ifdef OPTIONS_IN_HOME
        /* sam: if not found in $HOME then look in current directory */
-       strcpy (optionsfile, restart_config);
+       _tcscpy (optionsfile, restart_config);
        target_cfgfile_load (&currprefs, optionsfile, 0);
 #endif
     }
@@ -676,7 +657,7 @@ void leave_program (void)
     do_leave_program ();
 }
 
-static void real_main2 (int argc, char **argv)
+static void real_main2 (int argc, TCHAR **argv)
 {
 #if defined (JIT) && (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
     extern int EvalException (LPEXCEPTION_POINTERS blah, int n_except);
@@ -712,7 +693,7 @@ static void real_main2 (int argc, char **argv)
     }
 
     if (! setup_sound ()) {
-       write_log ("Sound driver unavailable: Sound output disabled\n");
+       write_log (L"Sound driver unavailable: Sound output disabled\n");
        currprefs.produce_sound = 0;
     }
     inputdevice_init ();
@@ -728,7 +709,7 @@ static void real_main2 (int argc, char **argv)
        int err = gui_init ();
        currprefs = changed_prefs;
        if (err == -1) {
-           write_log ("Failed to initialize the GUI\n");
+           write_log (L"Failed to initialize the GUI\n");
        } else if (err == -2) {
            return;
        }
@@ -742,7 +723,7 @@ static void real_main2 (int argc, char **argv)
 #endif
 
 #ifdef JIT
-    if (!((currprefs.cpu_model >= 68020) && (currprefs.address_space_24 == 0) && (currprefs.cachesize)))
+    if (!(currprefs.cpu_model >= 68020 && currprefs.address_space_24 == 0 && currprefs.cachesize))
        canbang = 0;
 #endif
 
@@ -809,7 +790,7 @@ static void real_main2 (int argc, char **argv)
 
        if (!init_audio ()) {
            if (sound_available && currprefs.produce_sound > 1) {
-               write_log ("Sound driver unavailable: Sound output disabled\n");
+               write_log (L"Sound driver unavailable: Sound output disabled\n");
            }
            currprefs.produce_sound = 0;
        }
@@ -818,7 +799,7 @@ static void real_main2 (int argc, char **argv)
     }
 
     }
-#if defined (JIT) && (defined ( _WIN32 ) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
+#if defined (JIT) && (defined (_WIN32) || defined (_WIN64)) && !defined (NO_WIN32_EXCEPTION_HANDLER)
     __except (EvalException (GetExceptionInformation (), GetExceptionCode ()))
     {
        // EvalException does the good stuff...
@@ -826,11 +807,11 @@ static void real_main2 (int argc, char **argv)
 #endif
 }
 
-void real_main (int argc, char **argv)
+void real_main (int argc, TCHAR **argv)
 {
     restart_program = 1;
-    fetch_configurationpath (restart_config, sizeof (restart_config));
-    strcat (restart_config, OPTIONSFILENAME);
+    fetch_configurationpath (restart_config, sizeof (restart_config) / sizeof (TCHAR));
+    _tcscat (restart_config, OPTIONSFILENAME);
     while (restart_program) {
        changed_prefs = currprefs;
        real_main2 (argc, argv);
@@ -841,7 +822,7 @@ void real_main (int argc, char **argv)
 }
 
 #ifndef NO_MAIN_IN_MAIN_C
-int main (int argc, char **argv)
+int main (int argc, TCHAR **argv)
 {
     real_main (argc, argv);
     return 0;
index d2bc8c3fe07497a13eaf84700ad55e8104ddb755..91e25143b42f5b4f65e0968f3a00735e37c35598 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -86,7 +86,7 @@ static int last_address_space_24;
 static struct romlist *rl;
 static int romlist_cnt;
 
-char *romlist_get (struct romdata *rd)
+TCHAR *romlist_get (struct romdata *rd)
 {
     int i;
 
@@ -113,7 +113,7 @@ static struct romlist *romlist_getrl (struct romdata *rd)
 }
 
 static void romlist_cleanup (void);
-void romlist_add (char *path, struct romdata *rd)
+void romlist_add (TCHAR *path, struct romdata *rd)
 {
     struct romlist *rl2;
 
@@ -129,16 +129,16 @@ void romlist_add (char *path, struct romdata *rd)
 }
 
 
-struct romdata *getromdatabypath(char *path)
+struct romdata *getromdatabypath(TCHAR *path)
 {
     int i;
     for (i = 0; i < romlist_cnt; i++) {
        struct romdata *rd = rl[i].rd;
        if (rd->configname && path[0] == ':') {
-           if (!strcmp(path + 1, rd->configname))
+           if (!_tcscmp(path + 1, rd->configname))
                return rd;
        }
-       if (!strcmp(rl[i].path, path))
+       if (!_tcscmp(rl[i].path, path))
            return rl[i].rd;
     }
     return NULL;
@@ -147,210 +147,210 @@ struct romdata *getromdatabypath(char *path)
 #define NEXT_ROM_ID 73
 
 static struct romheader romheaders[] = {
-    { "Freezer Cartridges", 1 },
-    { "Arcadia Games", 2 },
+    { L"Freezer Cartridges", 1 },
+    { L"Arcadia Games", 2 },
     { NULL, 0 }
 };
 
 #define ALTROM(id,grp,num,size,flags,crc32,a,b,c,d,e) \
-    { "X", 0, 0, 0, 0, 0, size, id, 0, 0, flags, (grp << 16) | num, 0, NULL, crc32, a, b, c, d, e },
+    { L"X", 0, 0, 0, 0, 0, size, id, 0, 0, flags, (grp << 16) | num, 0, NULL, crc32, a, b, c, d, e },
 #define ALTROMPN(id,grp,num,size,flags,pn,crc32,a,b,c,d,e) \
-    { "X", 0, 0, 0, 0, 0, size, id, 0, 0, flags, (grp << 16) | num, 0, pn, crc32, a, b, c, d, e },
+    { L"X", 0, 0, 0, 0, 0, size, id, 0, 0, flags, (grp << 16) | num, 0, pn, crc32, a, b, c, d, e },
 
 static struct romdata roms[] = {
-    { "Cloanto Amiga Forever ROM key", 0, 0, 0, 0, 0, 2069, 0, 0, 1, ROMTYPE_KEY, 0, 0, NULL,
+    { L"Cloanto Amiga Forever ROM key", 0, 0, 0, 0, 0, 2069, 0, 0, 1, ROMTYPE_KEY, 0, 0, NULL,
        0x869ae1b1, 0x801bbab3,0x2e3d3738,0x6dd1636d,0x4f1d6fa7,0xe21d5874 },
-    { "Cloanto Amiga Forever 2006 ROM key", 0, 0, 0, 0, 0, 750, 48, 0, 1, ROMTYPE_KEY, 0, 0, NULL,
+    { L"Cloanto Amiga Forever 2006 ROM key", 0, 0, 0, 0, 0, 750, 48, 0, 1, ROMTYPE_KEY, 0, 0, NULL,
        0xb01c4b56, 0xbba8e5cd,0x118b8d92,0xafed5693,0x5eeb9770,0x2a662d8f },
 
-    { "KS ROM v1.0 (A1000)(NTSC)", 1, 0, 1, 0, "A1000\0", 262144, 1, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v1.0 (A1000)(NTSC)", 1, 0, 1, 0, L"A1000\0", 262144, 1, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x299790ff, 0x00C15406,0xBEB4B8AB,0x1A16AA66,0xC05860E1,0xA7C1AD79 },
-    { "KS ROM v1.1 (A1000)(NTSC)", 1, 1, 31, 34, "A1000\0", 262144, 2, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v1.1 (A1000)(NTSC)", 1, 1, 31, 34, L"A1000\0", 262144, 2, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0xd060572a, 0x4192C505,0xD130F446,0xB2ADA6BD,0xC91DAE73,0x0ACAFB4C},
-    { "KS ROM v1.1 (A1000)(PAL)", 1, 1, 31, 34, "A1000\0", 262144, 3, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v1.1 (A1000)(PAL)", 1, 1, 31, 34, L"A1000\0", 262144, 3, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0xec86dae2, 0x16DF8B5F,0xD524C5A1,0xC7584B24,0x57AC15AF,0xF9E3AD6D },
-    { "KS ROM v1.2 (A1000)", 1, 2, 33, 166, "A1000\0", 262144, 4, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v1.2 (A1000)", 1, 2, 33, 166, L"A1000\0", 262144, 4, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x9ed783d0, 0x6A7BFB5D,0xBD6B8F17,0x9F03DA84,0xD8D95282,0x67B6273B },
-    { "KS ROM v1.2 (A500,A1000,A2000)", 1, 2, 33, 180, "A500\0A1000\0A2000\0", 262144, 5, 0, 0, ROMTYPE_KICK, 0, 0, "315093-01",
+    { L"KS ROM v1.2 (A500,A1000,A2000)", 1, 2, 33, 180, L"A500\0A1000\0A2000\0", 262144, 5, 0, 0, ROMTYPE_KICK, 0, 0, L"315093-01",
        0xa6ce1636, 0x11F9E62C,0xF299F721,0x84835B7B,0x2A70A163,0x33FC0D88 },
-    { "KS ROM v1.3 (A500,A1000,A2000)", 1, 3, 34, 5, "A500\0A1000\0A2000\0", 262144, 6, 0, 0, ROMTYPE_KICK, 0, 0, "315093-02",
+    { L"KS ROM v1.3 (A500,A1000,A2000)", 1, 3, 34, 5, L"A500\0A1000\0A2000\0", 262144, 6, 0, 0, ROMTYPE_KICK, 0, 0, L"315093-02",
        0xc4f0f55f, 0x891E9A54,0x7772FE0C,0x6C19B610,0xBAF8BC4E,0xA7FCB785 },
-    { "KS ROM v1.3 (A3000)(SK)", 1, 3, 34, 5, "A3000\0", 262144, 32, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v1.3 (A3000)(SK)", 1, 3, 34, 5, L"A3000\0", 262144, 32, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0xe0f37258, 0xC39BD909,0x4D4E5F4E,0x28C1411F,0x30869504,0x06062E87 },
-    { "KS ROM v1.4 (A3000)", 1, 4, 36, 16, "A3000\0", 524288, 59, 3, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v1.4 (A3000)", 1, 4, 36, 16, L"A3000\0", 524288, 59, 3, 0, ROMTYPE_KICK, 0, 0, NULL,
        0xbc0ec13f, 0xF76316BF,0x36DFF14B,0x20FA349E,0xD02E4B11,0xDD932B07 },
-    ALTROMPN(59, 1, 1, 262144, ROMTYPE_EVEN, "390629-02", 0x58327536,0xd1713d7f,0x31474a59,0x48e6d488,0xe3368606,0x1cf3d1e2)
-    ALTROMPN(59, 1, 2, 262144, ROMTYPE_ODD , "390630-02", 0xfe2f7fb9,0xc05c9c52,0xd014c66f,0x9019152b,0x3f2a2adc,0x2c678794)
-    { "KS ROM v2.04 (A500+)", 2, 4, 37, 175, "A500+\0", 524288, 7, 0, 0, ROMTYPE_KICK, 0, 0, "390979-01",
+    ALTROMPN(59, 1, 1, 262144, ROMTYPE_EVEN, L"390629-02", 0x58327536,0xd1713d7f,0x31474a59,0x48e6d488,0xe3368606,0x1cf3d1e2)
+    ALTROMPN(59, 1, 2, 262144, ROMTYPE_ODD , L"390630-02", 0xfe2f7fb9,0xc05c9c52,0xd014c66f,0x9019152b,0x3f2a2adc,0x2c678794)
+    { L"KS ROM v2.04 (A500+)", 2, 4, 37, 175, L"A500+\0", 524288, 7, 0, 0, ROMTYPE_KICK, 0, 0, L"390979-01",
        0xc3bdb240, 0xC5839F5C,0xB98A7A89,0x47065C3E,0xD2F14F5F,0x42E334A1 },
-    { "KS ROM v2.05 (A600)", 2, 5, 37, 299, "A600\0", 524288, 8, 0, 0, ROMTYPE_KICK, 0, 0, "391388-01",
+    { L"KS ROM v2.05 (A600)", 2, 5, 37, 299, L"A600\0", 524288, 8, 0, 0, ROMTYPE_KICK, 0, 0, L"391388-01",
        0x83028fb5, 0x87508DE8,0x34DC7EB4,0x7359CEDE,0x72D2E3C8,0xA2E5D8DB },
-    { "KS ROM v2.05 (A600HD)", 2, 5, 37, 300, "A600HD\0A600\0", 524288, 9, 0, 0, ROMTYPE_KICK, 0, 0, "391304-01",
+    { L"KS ROM v2.05 (A600HD)", 2, 5, 37, 300, L"A600HD\0A600\0", 524288, 9, 0, 0, ROMTYPE_KICK, 0, 0, L"391304-01",
        0x64466c2a, 0xF72D8914,0x8DAC39C6,0x96E30B10,0x859EBC85,0x9226637B },
-    { "KS ROM v2.05 (A600HD)", 2, 5, 37, 350, "A600HD\0A600\0", 524288, 10, 0, 0, ROMTYPE_KICK, 0, 0, "391304-02",
+    { L"KS ROM v2.05 (A600HD)", 2, 5, 37, 350, L"A600HD\0A600\0", 524288, 10, 0, 0, ROMTYPE_KICK, 0, 0, L"391304-02",
        0x43b0df7b, 0x02843C42,0x53BBD29A,0xBA535B0A,0xA3BD9A85,0x034ECDE4 },
-    { "KS ROM v2.04 (A3000)", 2, 4, 37, 175, "A3000\0", 524288, 71, 3, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v2.04 (A3000)", 2, 4, 37, 175, L"A3000\0", 524288, 71, 3, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x234a7233, 0xd82ebb59,0xafc53540,0xddf2d718,0x7ecf239b,0x7ea91590 },
-    ALTROMPN(71, 1, 1, 262144, ROMTYPE_EVEN, "390629-03", 0x7db1332b,0x48f14b31,0x279da675,0x7848df6f,0xeb531881,0x8f8f576c)
-    ALTROMPN(71, 1, 2, 262144, ROMTYPE_ODD , "390630-03", 0xa245dbdf,0x83bab8e9,0x5d378b55,0xb0c6ae65,0x61385a96,0xf638598f)
+    ALTROMPN(71, 1, 1, 262144, ROMTYPE_EVEN, L"390629-03", 0x7db1332b,0x48f14b31,0x279da675,0x7848df6f,0xeb531881,0x8f8f576c)
+    ALTROMPN(71, 1, 2, 262144, ROMTYPE_ODD , L"390630-03", 0xa245dbdf,0x83bab8e9,0x5d378b55,0xb0c6ae65,0x61385a96,0xf638598f)
 
-    { "KS ROM v3.0 (A1200)", 3, 0, 39, 106, "A1200\0", 524288, 11, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v3.0 (A1200)", 3, 0, 39, 106, L"A1200\0", 524288, 11, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x6c9b07d2, 0x70033828,0x182FFFC7,0xED106E53,0x73A8B89D,0xDA76FAA5 },
-    ALTROMPN(11, 1, 1, 262144, ROMTYPE_EVEN, "391523-01", 0xc742a412,0x999eb81c,0x65dfd07a,0x71ee1931,0x5d99c7eb,0x858ab186)
-    ALTROMPN(11, 1, 2, 262144, ROMTYPE_ODD , "391524-01", 0xd55c6ec6,0x3341108d,0x3a402882,0xb5ef9d3b,0x242cbf3c,0x8ab1a3e9)
-    { "KS ROM v3.0 (A4000)", 3, 0, 39, 106, "A4000\0", 524288, 12, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
+    ALTROMPN(11, 1, 1, 262144, ROMTYPE_EVEN, L"391523-01", 0xc742a412,0x999eb81c,0x65dfd07a,0x71ee1931,0x5d99c7eb,0x858ab186)
+    ALTROMPN(11, 1, 2, 262144, ROMTYPE_ODD , L"391524-01", 0xd55c6ec6,0x3341108d,0x3a402882,0xb5ef9d3b,0x242cbf3c,0x8ab1a3e9)
+    { L"KS ROM v3.0 (A4000)", 3, 0, 39, 106, L"A4000\0", 524288, 12, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x9e6ac152, 0xF0B4E9E2,0x9E12218C,0x2D5BD702,0x0E4E7852,0x97D91FD7 },
-    ALTROMPN(12, 1, 1, 262144, ROMTYPE_EVEN, "391513-02", 0x36f64dd0,0x196e9f3f,0x9cad934e,0x181c07da,0x33083b1f,0x0a3c702f)
-    ALTROMPN(12, 1, 2, 262144, ROMTYPE_ODD , "391514-02", 0x17266a55,0x42fbed34,0x53d1f11c,0xcbde89a9,0x826f2d11,0x75cca5cc)
-    { "KS ROM v3.1 (A4000)", 3, 1, 40, 70, "A4000\0", 524288, 13, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
+    ALTROMPN(12, 1, 1, 262144, ROMTYPE_EVEN, L"391513-02", 0x36f64dd0,0x196e9f3f,0x9cad934e,0x181c07da,0x33083b1f,0x0a3c702f)
+    ALTROMPN(12, 1, 2, 262144, ROMTYPE_ODD , L"391514-02", 0x17266a55,0x42fbed34,0x53d1f11c,0xcbde89a9,0x826f2d11,0x75cca5cc)
+    { L"KS ROM v3.1 (A4000)", 3, 1, 40, 70, L"A4000\0", 524288, 13, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x2b4566f1, 0x81c631dd,0x096bbb31,0xd2af9029,0x9c76b774,0xdb74076c },
     ALTROM(13, 1, 1, 262144, ROMTYPE_EVEN, 0xf9cbecc9,0x138d8cb4,0x3b8312fe,0x16d69070,0xde607469,0xb3d4078e)
     ALTROM(13, 1, 2, 262144, ROMTYPE_ODD , 0xf8248355,0xc2379547,0x9fae3910,0xc185512c,0xa268b82f,0x1ae4fe05)
-    { "KS ROM v3.1 (A500,A600,A2000)", 3, 1, 40, 63, "A500\0A600\0A2000\0", 524288, 14, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v3.1 (A500,A600,A2000)", 3, 1, 40, 63, L"A500\0A600\0A2000\0", 524288, 14, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0xfc24ae0d, 0x3B7F1493,0xB27E2128,0x30F989F2,0x6CA76C02,0x049F09CA },
-    { "KS ROM v3.1 (A1200)", 3, 1, 40, 68, "A1200\0", 524288, 15, 1, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v3.1 (A1200)", 3, 1, 40, 68, L"A1200\0", 524288, 15, 1, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x1483a091, 0xE2154572,0x3FE8374E,0x91342617,0x604F1B3D,0x703094F1 },
-    ALTROMPN(15, 1, 1, 262144, ROMTYPE_EVEN, "391773-01", 0x08dbf275,0xb8800f5f,0x90929810,0x9ea69690,0xb1b8523f,0xa22ddb37)
-    ALTROMPN(15, 1, 2, 262144, ROMTYPE_ODD , "391774-01", 0x16c07bf8,0x90e331be,0x1970b0e5,0x3f53a9b0,0x390b51b5,0x9b3869c2)
-    { "KS ROM v3.1 (A3000)", 3, 1, 40, 68, "A3000\0", 524288, 61, 2, 0, ROMTYPE_KICK, 0, 0, NULL,
+    ALTROMPN(15, 1, 1, 262144, ROMTYPE_EVEN, L"391773-01", 0x08dbf275,0xb8800f5f,0x90929810,0x9ea69690,0xb1b8523f,0xa22ddb37)
+    ALTROMPN(15, 1, 2, 262144, ROMTYPE_ODD , L"391774-01", 0x16c07bf8,0x90e331be,0x1970b0e5,0x3f53a9b0,0x390b51b5,0x9b3869c2)
+    { L"KS ROM v3.1 (A3000)", 3, 1, 40, 68, L"A3000\0", 524288, 61, 2, 0, ROMTYPE_KICK, 0, 0, NULL,
        0xefb239cc, 0xF8E210D7,0x2B4C4853,0xE0C9B85D,0x223BA20E,0x3D1B36EE },
     ALTROM(61, 1, 1, 262144, ROMTYPE_EVEN, 0x286b9a0d,0x6763a225,0x8ec493f7,0x408cf663,0x110dae9a,0x17803ad1)
     ALTROM(61, 1, 2, 262144, ROMTYPE_ODD , 0x0b8cde6a,0x5f02e97b,0x48ebbba8,0x7d516a56,0xb0400c6f,0xc3434d8d)
-    { "KS ROM v3.1 (A4000)(Cloanto)", 3, 1, 40, 68, "A4000\0", 524288, 31, 2 | 4, 1, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v3.1 (A4000)(Cloanto)", 3, 1, 40, 68, L"A4000\0", 524288, 31, 2 | 4, 1, ROMTYPE_KICK, 0, 0, NULL,
        0x43b6dd22, 0xC3C48116,0x0866E60D,0x085E436A,0x24DB3617,0xFF60B5F9 },
-    { "KS ROM v3.1 (A4000)", 3, 1, 40, 68, "A4000\0", 524288, 16, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v3.1 (A4000)", 3, 1, 40, 68, L"A4000\0", 524288, 16, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
        0xd6bae334, 0x5FE04842,0xD04A4897,0x20F0F4BB,0x0E469481,0x99406F49 },
     ALTROM(16, 1, 1, 262144, ROMTYPE_EVEN, 0xb2af34f8,0x24e52b5e,0xfc020495,0x17387ab7,0xb1a1475f,0xc540350e)
     ALTROM(16, 1, 2, 262144, ROMTYPE_ODD , 0xe65636a3,0x313c7cbd,0xa5779e56,0xf19a41d3,0x4e760f51,0x7626d882)
-    { "KS ROM v3.1 (A4000T)", 3, 1, 40, 70, "A4000T\0", 524288, 17, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"KS ROM v3.1 (A4000T)", 3, 1, 40, 70, L"A4000T\0", 524288, 17, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x75932c3a, 0xB0EC8B84,0xD6768321,0xE01209F1,0x1E6248F2,0xF5281A21 },
-    ALTROMPN(17, 1, 1, 262144, ROMTYPE_EVEN, "391657-01", 0x0ca94f70,0xb3806eda,0xcb3362fc,0x16a154ce,0x1eeec5bf,0x5bc24789)
-    ALTROMPN(17, 1, 2, 262144, ROMTYPE_ODD , "391658-01", 0xdfe03120,0xcd7a706c,0x431b04d8,0x7814d3a2,0xd8b39710,0x0cf44c0c)
-    { "KS ROM v3.X (A4000)(Cloanto)", 3, 10, 45, 57, "A4000\0", 524288, 46, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
+    ALTROMPN(17, 1, 1, 262144, ROMTYPE_EVEN, L"391657-01", 0x0ca94f70,0xb3806eda,0xcb3362fc,0x16a154ce,0x1eeec5bf,0x5bc24789)
+    ALTROMPN(17, 1, 2, 262144, ROMTYPE_ODD , L"391658-01", 0xdfe03120,0xcd7a706c,0x431b04d8,0x7814d3a2,0xd8b39710,0x0cf44c0c)
+    { L"KS ROM v3.X (A4000)(Cloanto)", 3, 10, 45, 57, L"A4000\0", 524288, 46, 2 | 4, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x3ac99edc, 0x3cbfc9e1,0xfe396360,0x157bd161,0xde74fc90,0x1abee7ec },
 
-    { "CD32 KS ROM v3.1", 3, 1, 40, 60, "CD32\0", 524288, 18, 1, 0, ROMTYPE_KICKCD32, 0, 0, NULL,
+    { L"CD32 KS ROM v3.1", 3, 1, 40, 60, L"CD32\0", 524288, 18, 1, 0, ROMTYPE_KICKCD32, 0, 0, NULL,
        0x1e62d4a5, 0x3525BE88,0x87F79B59,0x29E017B4,0x2380A79E,0xDFEE542D },
-    { "CD32 extended ROM", 3, 1, 40, 60, "CD32\0", 524288, 19, 1, 0, ROMTYPE_EXTCD32, 0, 0, NULL,
+    { L"CD32 extended ROM", 3, 1, 40, 60, L"CD32\0", 524288, 19, 1, 0, ROMTYPE_EXTCD32, 0, 0, NULL,
        0x87746be2, 0x5BEF3D62,0x8CE59CC0,0x2A66E6E4,0xAE0DA48F,0x60E78F7F },
 
     /* plain CD32 rom */
-    { "CD32 ROM (KS + extended)", 3, 1, 40, 60, "CD32\0", 2 * 524288, 64, 1, 0, ROMTYPE_KICKCD32 | ROMTYPE_EXTCD32 | ROMTYPE_CD32, 0, 0, NULL,
+    { L"CD32 ROM (KS + extended)", 3, 1, 40, 60, L"CD32\0", 2 * 524288, 64, 1, 0, ROMTYPE_KICKCD32 | ROMTYPE_EXTCD32 | ROMTYPE_CD32, 0, 0, NULL,
        0xf5d4f3c8, 0x9fa14825,0xc40a2475,0xa2eba5cf,0x325bd483,0xc447e7c1 },
     /* real CD32 rom dump 391640-03 */
-    ALTROMPN(64, 1, 1, 2 * 524288, ROMTYPE_CD32, "391640-03", 0xa4fbc94a, 0x816ce6c5,0x07787585,0x0c7d4345,0x2230a9ba,0x3a2902db )
+    ALTROMPN(64, 1, 1, 2 * 524288, ROMTYPE_CD32, L"391640-03", 0xa4fbc94a, 0x816ce6c5,0x07787585,0x0c7d4345,0x2230a9ba,0x3a2902db )
    
-    { "CD32 MPEG Cartridge ROM", 3, 1, 40, 30, "CD32FMV\0", 262144, 23, 1, 0, ROMTYPE_CD32CART, 0, 0, NULL,
+    { L"CD32 MPEG Cartridge ROM", 3, 1, 40, 30, L"CD32FMV\0", 262144, 23, 1, 0, ROMTYPE_CD32CART, 0, 0, NULL,
        0xc35c37bf, 0x03ca81c7,0xa7b259cf,0x64bc9582,0x863eca0f,0x6529f435 },
 
-    { "CDTV extended ROM v1.00", 1, 0, 1, 0, "CDTV\0", 262144, 20, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL,
+    { L"CDTV extended ROM v1.00", 1, 0, 1, 0, L"CDTV\0", 262144, 20, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL,
        0x42baa124, 0x7BA40FFA,0x17E500ED,0x9FED041F,0x3424BD81,0xD9C907BE },
-    ALTROMPN(20, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, "252606-01", 0x791cb14b,0x277a1778,0x92449635,0x3ffe56be,0x68063d2a,0x334360e4)
-    ALTROMPN(20, 1, 2, 131072, ROMTYPE_ODD  | ROMTYPE_8BIT, "252607-01", 0xaccbbc2e,0x41b06d16,0x79c6e693,0x3c3378b7,0x626025f7,0x641ebc5c)
-    { "CDTV extended ROM v2.07", 2, 7, 2, 7, "CDTV\0", 262144, 22, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL,
+    ALTROMPN(20, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, L"252606-01", 0x791cb14b,0x277a1778,0x92449635,0x3ffe56be,0x68063d2a,0x334360e4)
+    ALTROMPN(20, 1, 2, 131072, ROMTYPE_ODD  | ROMTYPE_8BIT, L"252607-01", 0xaccbbc2e,0x41b06d16,0x79c6e693,0x3c3378b7,0x626025f7,0x641ebc5c)
+    { L"CDTV extended ROM v2.07", 2, 7, 2, 7, L"CDTV\0", 262144, 22, 0, 0, ROMTYPE_EXTCDTV, 0, 0, NULL,
        0xceae68d2, 0x5BC114BB,0xA29F60A6,0x14A31174,0x5B3E2464,0xBFA06846 },
     ALTROM(22, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x36d73cb8,0x9574e546,0x4b390697,0xf28f9a43,0x4e604e5e,0xf5e5490a)
     ALTROM(22, 1, 2, 131072, ROMTYPE_ODD  | ROMTYPE_8BIT, 0x6e84dce7,0x01a0679e,0x895a1a0f,0x559c7253,0xf539606b,0xd447b54f)
-    { "CDTV/A570 extended ROM v2.30", 2, 30, 2, 30, "CDTV\0", 262144, 21, 0, 0, ROMTYPE_EXTCDTV, 0, 0, "391298-01",
+    { L"CDTV/A570 extended ROM v2.30", 2, 30, 2, 30, L"CDTV\0", 262144, 21, 0, 0, ROMTYPE_EXTCDTV, 0, 0, L"391298-01",
        0x30b54232, 0xED7E461D,0x1FFF3CDA,0x321631AE,0x42B80E3C,0xD4FA5EBB },
     ALTROM(21, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x48e4d74f,0x54946054,0x2269e410,0x36018402,0xe1f6b855,0xfd89092b)
     ALTROM(21, 1, 2, 131072, ROMTYPE_ODD  | ROMTYPE_8BIT, 0x8a54f362,0x03df800f,0x032046fd,0x892f6e7e,0xec08b76d,0x33981e8c)
 
-    { "A1000 bootstrap ROM", 0, 0, 0, 0, "A1000\0", 65536, 24, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
+    { L"A1000 bootstrap ROM", 0, 0, 0, 0, L"A1000\0", 65536, 24, 0, 0, ROMTYPE_KICK, 0, 0, NULL,
        0x0b1ad2d0, 0xBA93B8B8,0x5CA0D83A,0x68225CC3,0x3B95050D,0x72D2FDD7 },
     ALTROM(24, 1, 1, 8192,           0, 0x62f11c04, 0xC87F9FAD,0xA4EE4E69,0xF3CCA0C3,0x6193BE82,0x2B9F5FE6)
-    ALTROMPN(24, 2, 1, 4096, ROMTYPE_EVEN | ROMTYPE_8BIT, "252179-01", 0x42553bc4,0x8855a97f,0x7a44e3f6,0x2d1c88d9,0x38fee1f4,0xc606af5b)
-    ALTROMPN(24, 2, 2, 4096, ROMTYPE_ODD  | ROMTYPE_8BIT, "252180-01", 0x8e5b9a37,0xd10f1564,0xb99f5ffe,0x108fa042,0x362e877f,0x569de2c3)
+    ALTROMPN(24, 2, 1, 4096, ROMTYPE_EVEN | ROMTYPE_8BIT, L"252179-01", 0x42553bc4,0x8855a97f,0x7a44e3f6,0x2d1c88d9,0x38fee1f4,0xc606af5b)
+    ALTROMPN(24, 2, 2, 4096, ROMTYPE_ODD  | ROMTYPE_8BIT, L"252180-01", 0x8e5b9a37,0xd10f1564,0xb99f5ffe,0x108fa042,0x362e877f,0x569de2c3)
 
-    { "The Diagnostic 2.0 (Logica)", 2, 0, 2, 0, "LOGICA\0", 524288, 72, 0, 0, ROMTYPE_KICK | ROMTYPE_SPECIALKICK, 0, 0, NULL,
+    { L"The Diagnostic 2.0 (Logica)", 2, 0, 2, 0, L"LOGICA\0", 524288, 72, 0, 0, ROMTYPE_KICK | ROMTYPE_SPECIALKICK, 0, 0, NULL,
        0x8484f426, 0xba10d161,0x66b2e2d6,0x177c979c,0x99edf846,0x2b21651e },
 
-    { "Freezer: Action Replay Mk I v1.00", 1, 0, 1, 0, "AR\0", 65536, 52, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay Mk I v1.00", 1, 0, 1, 0, L"AR\0", 65536, 52, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0x2d921771, 0x1EAD9DDA,0x2DAD2914,0x6441F5EF,0x72183750,0x22E01248 },
     ALTROM(52, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x82d6eb87, 0x7c9bac11,0x28666017,0xeee6f019,0x63fb3890,0x7fbea355)
     ALTROM(52, 1, 2, 32768, ROMTYPE_ODD  | ROMTYPE_8BIT, 0x40ae490c, 0x81d8e432,0x01b73fd9,0x2e204ebd,0x68af8602,0xb62ce397)
-    { "Freezer: Action Replay Mk I v1.50", 1, 50, 1, 50, "AR\0", 65536, 25, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay Mk I v1.50", 1, 50, 1, 50, L"AR\0", 65536, 25, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0xd4ce0675, 0x843B433B,0x2C56640E,0x045D5FDC,0x854DC6B1,0xA4964E7C },
     ALTROM(25, 1, 1, 32768, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x7fbd6de2, 0xb5f71a5c,0x09d65ecc,0xa8a3bc93,0x93558461,0xca190228)
     ALTROM(25, 1, 2, 32768, ROMTYPE_ODD  | ROMTYPE_8BIT, 0x43018069, 0xad8ff242,0xb2cbf125,0x1fc53a73,0x581cf57a,0xb69cee00)
-    { "Freezer: Action Replay Mk II v2.05", 2, 5, 2, 5, "AR\0", 131072, 26, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay Mk II v2.05", 2, 5, 2, 5, L"AR\0", 131072, 26, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0x1287301f, 0xF6601DE8,0x888F0050,0x72BF562B,0x9F533BBC,0xAF1B0074 },
-    { "Freezer: Action Replay Mk II v2.12", 2, 12, 2, 12, "AR\0", 131072, 27, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay Mk II v2.12", 2, 12, 2, 12, L"AR\0", 131072, 27, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0x804d0361, 0x3194A07A,0x0A82D8B5,0xF2B6AEFA,0x3CA581D6,0x8BA8762B },
-    { "Freezer: Action Replay Mk II v2.14", 2, 14, 2, 14, "AR\0", 131072, 28, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay Mk II v2.14", 2, 14, 2, 14, L"AR\0", 131072, 28, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0x49650e4f, 0x255D6DF6,0x3A4EAB0A,0x838EB1A1,0x6A267B09,0x59DFF634 },
-    { "Freezer: Action Replay Mk III v3.09", 3, 9, 3, 9, "AR\0", 262144, 29, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay Mk III v3.09", 3, 9, 3, 9, L"AR\0", 262144, 29, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0x0ed9b5aa, 0x0FF3170A,0xBBF0CA64,0xC9DD93D6,0xEC0C7A01,0xB5436824 },
     ALTROM(29, 1, 1, 131072, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x2b84519f, 0x7841873b,0xf009d834,0x1dfa2794,0xb3751bac,0xf86adcc8)
     ALTROM(29, 1, 2, 131072, ROMTYPE_ODD  | ROMTYPE_8BIT, 0x1d35bd56, 0x6464be16,0x26b51949,0x9e76e4e3,0x409e8016,0x515d48b6)
-    { "Freezer: Action Replay Mk III v3.17", 3, 17, 3, 17, "AR\0", 262144, 30, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay Mk III v3.17", 3, 17, 3, 17, L"AR\0", 262144, 30, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0xc8a16406, 0x5D4987C2,0xE3FFEA8B,0x1B02E314,0x30EF190F,0x2DB76542 },
-    { "Freezer: Action Replay 1200", 0, 0, 0, 0, "AR\0", 262144, 47, 0, 0, ROMTYPE_AR, 0, 1, NULL,
+    { L"Freezer: Action Replay 1200", 0, 0, 0, 0, L"AR\0", 262144, 47, 0, 0, ROMTYPE_AR, 0, 1, NULL,
        0x8d760101, 0x0F6AB834,0x2810094A,0xC0642F62,0xBA42F78B,0xC0B07E6A },
 
-    { "Freezer: Action Cartridge Super IV Professional", 0, 0, 0, 0, "SUPERIV\0", 0, 62, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL,
-       0xffffffff, 0, 0, 0, 0, 0, "SuperIV" },
-    { "Freezer: Action Cart. Super IV Pro (+ROM v4.3)", 4, 3, 4, 3, "SUPERIV\0", 170368, 60, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL,
+    { L"Freezer: Action Cartridge Super IV Professional", 0, 0, 0, 0, L"SUPERIV\0", 0, 62, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL,
+       0xffffffff, 0, 0, 0, 0, 0, L"SuperIV" },
+    { L"Freezer: Action Cart. Super IV Pro (+ROM v4.3)", 4, 3, 4, 3, L"SUPERIV\0", 170368, 60, 0, 0, ROMTYPE_SUPERIV, 0, 1, NULL,
        0xe668a0be, 0x633A6E65,0xA93580B8,0xDDB0BE9C,0x9A64D4A1,0x7D4B4801 },
-    { "Freezer: X-Power Professional 500 v1.2", 1, 2, 1, 2, "XPOWER\0", 131072, 65, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL,
+    { L"Freezer: X-Power Professional 500 v1.2", 1, 2, 1, 2, L"XPOWER\0", 131072, 65, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL,
        0x9e70c231, 0xa2977a1c,0x41a8ca7d,0x4af4a168,0x726da542,0x179d5963 },
     ALTROM(65, 1, 1, 65536, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xf98742e4,0xe8e683ba,0xd8b38d1f,0x79f3ad83,0xa9e67c6f,0xa91dc96c)
     ALTROM(65, 1, 2, 65536, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xdfb9984b,0x8d6bdd49,0x469ec8e2,0x0143fbb3,0x72e92500,0x99f07910)
-    { "Freezer: X-Power Professional 500 v1.3", 1, 2, 1, 2, "XPOWER\0", 131072, 68, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL,
+    { L"Freezer: X-Power Professional 500 v1.3", 1, 2, 1, 2, L"XPOWER\0", 131072, 68, 0, 0, ROMTYPE_XPOWER, 0, 1, NULL,
        0x31e057f0, 0x84650266,0x465d1859,0x7fd71dee,0x00775930,0xb7e450ee },
     ALTROM(68, 1, 1, 65536, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x0b2ce0c7,0x45ad5456,0x89192404,0x956f47ce,0xf66a5274,0x57ace33b)
     ALTROM(68, 1, 2, 65536, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x34580c35,0x8ad42566,0x7364f238,0x978f4381,0x08f8d5ec,0x470e72ea)
-    { "Freezer: Nordic Power v1.5", 1, 5, 1, 5, "NPOWER\0", 65536, 69, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL,
+    { L"Freezer: Nordic Power v1.5", 1, 5, 1, 5, L"NPOWER\0", 65536, 69, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL,
        0x83b4b21c, 0xc56ced25,0x506a5aab,0x3fa13813,0x4fc9e5ae,0x0f9d3709 },
     ALTROM(69, 1, 1, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xdd207174,0xae67652d,0x64f5db20,0x0f4b2110,0xee59567f,0xfbd90a1b)
     ALTROM(69, 1, 2, 32768, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x8f93d85d,0x73c62d21,0x40c0c092,0x6315b702,0xdd5d0f05,0x3dad7fab)
-    { "Freezer: Nordic Power v2.0", 2, 0, 2, 0, "NPOWER\0", 65536, 67, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL,
+    { L"Freezer: Nordic Power v2.0", 2, 0, 2, 0, L"NPOWER\0", 65536, 67, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL,
        0xa4db2906, 0x0aec68f7,0x25470c89,0x6b699ff4,0x6623dec5,0xc777466e },
     ALTROM(67, 1, 1, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xb21be46c,0x50dc607c,0xce976bbd,0x3841eaf0,0x591ddc7e,0xa1939ad2)
     ALTROM(67, 1, 2, 32768, ROMTYPE_ODD |ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0x96057aed,0xdd9209e2,0x1d5edfc1,0xcdb52abe,0x93de0f35,0xc43da696)
-    { "Freezer: Nordic Power v3.0", 3, 0, 3, 0, "NPOWER\0", 65536, 70, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL,
+    { L"Freezer: Nordic Power v3.0", 3, 0, 3, 0, L"NPOWER\0", 65536, 70, 0, 0, ROMTYPE_NORDIC, 0, 1, NULL,
        0x72850aef, 0x59c91d1f,0xa8f118f9,0x0bdba05a,0x9ae788d7,0x7a6cc7c9 },
     ALTROM(70, 1, 1, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xf3330e1f,0x3a597db2,0xb7d11b6c,0xb8e13496,0xc215f223,0x88c4ca3c)
     ALTROM(70, 1, 2, 32768, ROMTYPE_EVEN|ROMTYPE_SCRAMBLED|ROMTYPE_8BIT, 0xee58e0f9,0x4148f4cb,0xb42cec33,0x8ca144de,0xd4f54118,0xe0f185dd)
-    { "Freezer: HRTMon v2.30 (built-in)", 0, 0, 0, 0, "HRTMON\0", 0, 63, 0, 0, ROMTYPE_HRTMON, 0, 1, NULL,
-       0xffffffff, 0, 0, 0, 0, 0, "HRTMon" },
+    { L"Freezer: HRTMon v2.30 (built-in)", 0, 0, 0, 0, L"HRTMON\0", 0, 63, 0, 0, ROMTYPE_HRTMON, 0, 1, NULL,
+       0xffffffff, 0, 0, 0, 0, 0, L"HRTMon" },
 
-    { "A590/A2091 SCSI boot ROM", 6, 0, 6, 0, "A590\0A2091\0", 16384, 53, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
+    { L"A590/A2091 SCSI boot ROM", 6, 0, 6, 0, L"A590\0A2091\0", 16384, 53, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
        0x8396cf4e, 0x5E03BC61,0x8C862ABE,0x7BF79723,0xB4EEF4D2,0x1859A0F2 },
     ALTROM(53, 1, 1, 8192, ROMTYPE_ODD  | ROMTYPE_8BIT, 0xb0b8cf24,0xfcf40175,0x05f4d441,0x814b45d5,0x59c19eab,0x43816b30)
     ALTROM(53, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x2e77bbff,0x8a098845,0x068f32cf,0xa4d34a27,0x8cd290f6,0x1d35a52c)
-    { "A590/A2091 SCSI boot ROM", 6, 6, 6, 6, "A590\0A2091\0", 16384, 54, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
+    { L"A590/A2091 SCSI boot ROM", 6, 6, 6, 6, L"A590\0A2091\0", 16384, 54, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
        0x33e00a7a, 0x739BB828,0xE874F064,0x9360F59D,0x26B5ED3F,0xBC99BB66 },
     ALTROM(54, 1, 1, 8192, ROMTYPE_ODD  | ROMTYPE_8BIT, 0xe536bbb2,0xfd7f8a6d,0xa18c1b02,0xd07eb990,0xc2467a24,0x183ede12)
     ALTROM(54, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, 0xc0871d25,0xe155f18a,0xbb90cf82,0x0589c15e,0x70559d3b,0x6b391af8)
-    { "A590/A2091 SCSI boot ROM", 7, 0, 7, 0, "A590\0A2091\0", 16384, 55, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
+    { L"A590/A2091 SCSI boot ROM", 7, 0, 7, 0, L"A590\0A2091\0", 16384, 55, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
        0x714a97a2, 0xE50F01BA,0xF2899892,0x85547863,0x72A82C33,0x3C91276E },
     ALTROM(55, 1, 1, 8192, ROMTYPE_ODD  | ROMTYPE_8BIT, 0xa9ccffed,0x149f5bd5,0x2e2d2990,0x4e3de483,0xb9ad7724,0x48e9278e)
     ALTROM(55, 1, 2, 8192, ROMTYPE_EVEN | ROMTYPE_8BIT, 0x2942747a,0xdbd7648e,0x79c75333,0x7ff3e4f4,0x91de224b,0xf05e6bb6)
-    { "A590/A2091 SCSI Guru boot ROM", 6, 14, 6, 14, "A590\0A2091\0", 32768, 56, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
+    { L"A590/A2091 SCSI Guru boot ROM", 6, 14, 6, 14, L"A590\0A2091\0", 32768, 56, 0, 0, ROMTYPE_A2091BOOT, 0, 0, NULL,
        0x04e52f93, 0x6DA21B6F,0x5E8F8837,0xD64507CD,0x8A4D5CDC,0xAC4F426B },
-    { "A4091 SCSI boot ROM", 40, 9, 40, 9, "A4091\0", 32768, 57, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL,
+    { L"A4091 SCSI boot ROM", 40, 9, 40, 9, L"A4091\0", 32768, 57, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL,
        0x00000000, 0, 0, 0, 0, 0 },
-    { "A4091 SCSI boot ROM", 40, 13, 40, 13, "A4091\0", 32768, 58, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL,
+    { L"A4091 SCSI boot ROM", 40, 13, 40, 13, L"A4091\0", 32768, 58, 0, 0, ROMTYPE_A4091BOOT, 0, 0, NULL,
        0x54cb9e85, 0x3CE66919,0xF6FD6797,0x4923A12D,0x91B730F1,0xFFB4A7BA },
 
-    { "Arcadia OnePlay 2.11", 0, 0, 0, 0, "ARCADIA\0", 0, 49, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 },
-    { "Arcadia TenPlay 2.11", 0, 0, 0, 0, "ARCADIA\0", 0, 50, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 },
-    { "Arcadia OnePlay 3.00", 0, 0, 0, 0, "ARCADIA\0", 0, 51, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 },
-
-    { "Arcadia SportTime Table Hockey", 0, 0, 0, 0, "ARCADIA\0", 0, 33, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia SportTime Bowling", 0, 0, 0, 0, "ARCADIA\0", 0, 34, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia World Darts", 0, 0, 0, 0, "ARCADIA\0", 0, 35, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Magic Johnson's Fast Break", 0, 0, 0, 0, "ARCADIA\0", 0, 36, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Leader Board Golf", 0, 0, 0, 0, "ARCADIA\0", 0, 37, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Leader Board Golf (alt)", 0, 0, 0, 0, "ARCADIA\0", 0, 38, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Ninja Mission", 0, 0, 0, 0, "ARCADIA\0", 0, 39, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Road Wars", 0, 0, 0, 0, "ARCADIA\0", 0, 40, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Sidewinder", 0, 0, 0, 0, "ARCADIA\0", 0, 41, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Spot", 0, 0, 0, 0, "ARCADIA\0", 0, 42, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Space Ranger", 0, 0, 0, 0, "ARCADIA\0", 0, 43, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia Xenon", 0, 0, 0, 0, "ARCADIA\0", 0, 44, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
-    { "Arcadia World Trophy Soccer", 0, 0, 0, 0, "ARCADIA\0", 0, 45, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia OnePlay 2.11", 0, 0, 0, 0, L"ARCADIA\0", 0, 49, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 },
+    { L"Arcadia TenPlay 2.11", 0, 0, 0, 0, L"ARCADIA\0", 0, 50, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 },
+    { L"Arcadia OnePlay 3.00", 0, 0, 0, 0, L"ARCADIA\0", 0, 51, 0, 0, ROMTYPE_ARCADIABIOS, 0, 0 },
+
+    { L"Arcadia SportTime Table Hockey", 0, 0, 0, 0, L"ARCADIA\0", 0, 33, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia SportTime Bowling", 0, 0, 0, 0, L"ARCADIA\0", 0, 34, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia World Darts", 0, 0, 0, 0, L"ARCADIA\0", 0, 35, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Magic Johnson's Fast Break", 0, 0, 0, 0, L"ARCADIA\0", 0, 36, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Leader Board Golf", 0, 0, 0, 0, L"ARCADIA\0", 0, 37, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Leader Board Golf (alt)", 0, 0, 0, 0, L"ARCADIA\0", 0, 38, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Ninja Mission", 0, 0, 0, 0, L"ARCADIA\0", 0, 39, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Road Wars", 0, 0, 0, 0, L"ARCADIA\0", 0, 40, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Sidewinder", 0, 0, 0, 0, L"ARCADIA\0", 0, 41, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Spot", 0, 0, 0, 0, L"ARCADIA\0", 0, 42, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Space Ranger", 0, 0, 0, 0, L"ARCADIA\0", 0, 43, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia Xenon", 0, 0, 0, 0, L"ARCADIA\0", 0, 44, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
+    { L"Arcadia World Trophy Soccer", 0, 0, 0, 0, L"ARCADIA\0", 0, 45, 0, 0, ROMTYPE_ARCADIAGAME, 0, 2 },
 
     { NULL }
 
@@ -361,7 +361,7 @@ void romlist_clear (void)
     int i;
     int mask = 0;
     struct romdata *parent;
-    char *pn;
+    TCHAR *pn;
 
     xfree (rl);
     rl = 0;
@@ -378,15 +378,15 @@ void romlist_clear (void)
            rd->type &= ~ROMTYPE_MASK;
            rd->type |= mask & ROMTYPE_MASK;
            if (rd->partnumber && !pn) {
-               char *newpn;
+               TCHAR *newpn;
                if (parent->partnumber == NULL)
-                   parent->partnumber = my_strdup ("");
-               newpn = xcalloc (strlen (parent->partnumber) + 1 + strlen (rd->partnumber) + 1, 1);
-               if (strlen (parent->partnumber) > 0) {
-                   strcpy (newpn, parent->partnumber);
-                   strcat (newpn, "/");
+                   parent->partnumber = my_strdup (L"");
+               newpn = xcalloc ((_tcslen (parent->partnumber) + 1 + _tcslen (rd->partnumber) + 1) * sizeof (TCHAR), 1);
+               if (_tcslen (parent->partnumber) > 0) {
+                   _tcscpy (newpn, parent->partnumber);
+                   _tcscat (newpn, L"/");
                }
-               strcat (newpn, rd->partnumber);
+               _tcscat (newpn, rd->partnumber);
                xfree (parent->partnumber);
                parent->partnumber = newpn;
            }
@@ -416,7 +416,7 @@ static void romlist_cleanup (void)
                struct romlist *rl = romlist_getrl (&roms[i]);
                if (rl) {
                    int cnt = romlist_cnt - i - 1;
-                   write_log ("%d '%s' removed from romlist\n", roms[k].name, rl->path);
+                   write_log (L"%d '%s' removed from romlist\n", roms[k].name, rl->path);
                    xfree (rl->path);
                    if (cnt > 0)
                        memmove (rl, rl + 1, cnt * sizeof (struct romlist));
@@ -429,11 +429,11 @@ static void romlist_cleanup (void)
     }
     for (i = 0; i < romlist_cnt; i++) {
        struct romlist *rll = &rl[i];
-       //write_log ("%s (%s)\n", rll->rd->name, rll->path);
+       //write_log (L"%s (%s)\n", rll->rd->name, rll->path);
     }
 }
 
-struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, char *model, int all)
+struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, TCHAR *model, int all)
 {
     int i, j, ok, out, max;
     struct romdata *rd;
@@ -458,7 +458,7 @@ struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, cha
            rd = &roms[i];
        if (rd->group)
            continue;
-       if (model && !strcmpi(model, rd->name))
+       if (model && !_tcsicmp (model, rd->name))
            ok = 2;
        if (rd->ver == ver && (rev < 0 || rd->rev == rev)) {
            if (subver >= 0) {
@@ -471,14 +471,14 @@ struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, cha
        if (!ok)
            continue;
        if (model && ok < 2) {
-           char *p = rd->model;
+           TCHAR *p = rd->model;
            ok = 0;
            while (*p) {
-               if (!strcmp(rd->model, model)) {
+               if (!_tcscmp(rd->model, model)) {
                    ok = 1;
                    break;
                }
-               p = p + strlen(p) + 1;
+               p = p + _tcslen(p) + 1;
            }
        }
        if (!model && rd->type != ROMTYPE_KICK)
@@ -513,16 +513,16 @@ struct romlist **getromlistbyident(int ver, int rev, int subver, int subrev, cha
     return rdout;
 }
 
-struct romdata *getarcadiarombyname (char *name)
+struct romdata *getarcadiarombyname (TCHAR *name)
 {
     int i;
     for (i = 0; roms[i].name; i++) {
        if (roms[i].group == 0 && (roms[i].type == ROMTYPE_ARCADIAGAME || roms[i].type == ROMTYPE_ARCADIAGAME)) {
-           char *p = roms[i].name;
-           p = p + strlen (p) + 1;
-           if (strlen (name) >= strlen (p) + 4) {
-               char *p2 = name + strlen (name) - strlen (p) - 4;
-               if (!memcmp (p, p2, strlen (p)) && !memcmp (p2 + strlen (p2) - 4, ".zip", 4))
+           TCHAR *p = roms[i].name;
+           p = p + _tcslen (p) + 1;
+           if (_tcslen (name) >= _tcslen (p) + 4) {
+               TCHAR *p2 = name + _tcslen (name) - _tcslen (p) - 4;
+               if (!memcmp (p, p2, _tcslen (p)) && !memcmp (p2 + _tcslen (p2) - 4, ".zip", 4))
                    return &roms[i];
            }
        }
@@ -580,7 +580,7 @@ struct rom_key {
 
 static struct rom_key keyring[ROM_KEY_NUM];
 
-static void addkey (uae_u8 *key, int size, const char *name)
+static void addkey (uae_u8 *key, int size, const TCHAR *name)
 {
     int i;
 
@@ -604,16 +604,16 @@ static void addkey (uae_u8 *key, int size, const char *name)
     }
     keyring[i].key = key;
     keyring[i].size = size;
-    write_log ("ROM KEY '%s' %d bytes loaded\n", name, size);
+    write_log (L"ROM KEY '%s' %d bytes loaded\n", name, size);
 }
 
-static void addkeyfile (const char *path)
+static void addkeyfile (const TCHAR *path)
 {
     struct zfile *f;
     int keysize;
     uae_u8 *keybuf;
 
-    f = zfile_fopen (path, "rb");
+    f = zfile_fopen (path, L"rb");
     if (!f)
        return;
     zfile_fseek (f, 0, SEEK_END);
@@ -627,21 +627,21 @@ static void addkeyfile (const char *path)
     zfile_fclose (f);
 }
 
-static void addkeydir (const char *path)
+static void addkeydir (const TCHAR *path)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
-    strcpy (tmp, path);
+    _tcscpy (tmp, path);
     if (zfile_exists (tmp)) {
         int i;
-        for (i = strlen (tmp) - 1; i > 0; i--) {
+        for (i = _tcslen (tmp) - 1; i > 0; i--) {
            if (tmp[i] == '\\' || tmp[i] == '/')
                break;
        }
        tmp[i] = 0;
     }
-    strcat (tmp, "/");
-    strcat (tmp, "rom.key");
+    _tcscat (tmp, L"/");
+    _tcscat (tmp, L"rom.key");
     addkeyfile (tmp);
 }
 
@@ -655,11 +655,11 @@ int get_keyring (void)
     return num;
 }
 
-int load_keyring (struct uae_prefs *p, char *path)
+int load_keyring (struct uae_prefs *p, TCHAR *path)
 {
     uae_u8 *keybuf;
     int keysize;
-    char tmp[MAX_PATH], *d;
+    TCHAR tmp[MAX_PATH], *d;
     int keyids[] = { 0, 48, -1 };
     int cnt, i;
 
@@ -668,7 +668,7 @@ int load_keyring (struct uae_prefs *p, char *path)
     addkey (keybuf, keysize, tmp);
     for (i = 0; keyids[i] >= 0; i++) {
        struct romdata *rd = getromdatabyid (keyids[i]);
-       char *s;
+       TCHAR *s;
        if (rd) {
            s = romlist_get (rd);
            if (s)
@@ -685,40 +685,40 @@ int load_keyring (struct uae_prefs *p, char *path)
        {
        case 0:
        if (path)
-           strcpy (tmp, path);
+           _tcscpy (tmp, path);
        break;
        case 1:
-           strcat (tmp, "rom.key");
+           _tcscat (tmp, L"rom.key");
        break;
        case 2:
            if (p) {
-               strcpy (tmp, p->path_rom);
-               strcat (tmp, "rom.key");
+               _tcscpy (tmp, p->path_rom);
+               _tcscat (tmp, L"rom.key");
            }
        break;
        case 3:
-           strcpy (tmp, "roms/rom.key");
+           _tcscpy (tmp, L"roms/rom.key");
        break;
        case 4:
-           strcpy (tmp, start_path_data);
-           strcat (tmp, "rom.key");
+           _tcscpy (tmp, start_path_data);
+           _tcscat (tmp, L"rom.key");
        break;
        case 5:
-           sprintf (tmp, "%s../shared/rom/rom.key", start_path_data);
+           _stprintf (tmp, L"%s../shared/rom/rom.key", start_path_data);
        break;
        case 6:
            if (p) {
                for (i = 0; uae_archive_extensions[i]; i++) {
-                   if (strstr(p->romfile, uae_archive_extensions[i]))
+                   if (_tcsstr (p->romfile, uae_archive_extensions[i]))
                        break;
                }
                if (!uae_archive_extensions[i]) {
-                   strcpy (tmp, p->romfile);
-                   d = strrchr(tmp, '/');
+                   _tcscpy (tmp, p->romfile);
+                   d = _tcsrchr (tmp, '/');
                    if (!d)
-                       d = strrchr(tmp, '\\');
+                       d = _tcsrchr (tmp, '\\');
                    if (d)
-                       strcpy (d + 1, "rom.key");
+                       _tcscpy (d + 1, L"rom.key");
                }
            }
        break;
@@ -739,14 +739,14 @@ void free_keyring (void)
     memset(keyring, 0, sizeof (struct rom_key) * ROM_KEY_NUM);
 }
 
-struct romdata *getromdatabyname (char *name)
+struct romdata *getromdatabyname (TCHAR *name)
 {
-    char tmp[MAX_PATH];
+    TCHAR tmp[MAX_PATH];
     int i = 0;
     while (roms[i].name) {
        if (!roms[i].group) {
            getromname (&roms[i], tmp);
-           if (!strcmp (tmp, name) || !strcmp (roms[i].name, name))
+           if (!_tcscmp (tmp, name) || !_tcscmp (roms[i].name, name))
                return &roms[i];
        }
        i++;
@@ -965,20 +965,20 @@ struct romdata *getromdatabyzfile (struct zfile *f)
     return rd;
 }
 
-void getromname        (struct romdata *rd, char *name)
+void getromname        (struct romdata *rd, TCHAR *name)
 {
     name[0] = 0;
     if (!rd)
        return;
     while (rd->group)
        rd--;
-    strcat (name, rd->name);
+    _tcscat (name, rd->name);
     if ((rd->subrev || rd->subver) && rd->subver != rd->ver)
-       sprintf (name + strlen (name), " rev %d.%d", rd->subver, rd->subrev);
+       _stprintf (name + _tcslen (name), L" rev %d.%d", rd->subver, rd->subrev);
     if (rd->size > 0)
-       sprintf (name + strlen (name), " (%dk)", (rd->size + 1023) / 1024);
-    if (rd->partnumber && strlen (rd->partnumber) > 0)
-       sprintf (name + strlen (name), " [%s]", rd->partnumber);
+       _stprintf (name + _tcslen (name), L" (%dk)", (rd->size + 1023) / 1024);
+    if (rd->partnumber && _tcslen (rd->partnumber) > 0)
+       _stprintf (name + _tcslen (name), L" [%s]", rd->partnumber);
 }
 
 struct romlist *getromlistbyromdata (struct romdata *rd)
@@ -1012,8 +1012,8 @@ struct romlist *getromlistbyids (int *ids)
 void romwarning (int *ids)
 {
     int i, exp;
-    char tmp1[MAX_DPATH], tmp2[MAX_DPATH];
-    char tmp3[MAX_DPATH];
+    TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR tmp3[MAX_DPATH];
 
     exp = 0;
     tmp2[0] = 0;
@@ -1021,9 +1021,9 @@ void romwarning (int *ids)
     while (ids[i] >= 0) {
        struct romdata *rd = getromdatabyid (ids[i]);
        getromname (rd, tmp1);
-       strcat (tmp2, "- ");
-       strcat (tmp2, tmp1);
-       strcat (tmp2, "\n");
+       _tcscat (tmp2, L"- ");
+       _tcscat (tmp2, tmp1);
+       _tcscat (tmp2, L"\n");
        if (rd->type & (ROMTYPE_A2091BOOT | ROMTYPE_A4091BOOT))
            exp++;
        i++;
@@ -1069,11 +1069,11 @@ __inline__ void byteput (uaecptr addr, uae_u32 b)
 }
 #endif
 
-int addr_valid (char *txt, uaecptr addr, uae_u32 len)
+int addr_valid (TCHAR *txt, uaecptr addr, uae_u32 len)
 {
     addrbank *ab = &get_mem_bank(addr);
     if (ab == 0 || !(ab->flags & ABFLAG_RAM) || addr < 0x100 || len < 0 || len > 16777215 || !valid_address (addr, len)) {
-       write_log ("corrupt %s pointer %x (%d) detected!\n", txt, addr, len);
+       write_log (L"corrupt %s pointer %x (%d) detected!\n", txt, addr, len);
        return 0;
     }
     return 1;
@@ -1118,13 +1118,13 @@ static void dummylog (int rw, uaecptr addr, int size, uae_u32 val, int ins)
     if (MAX_ILG >= 0)
        illegal_count++;
     if (ins) {
-       write_log ("WARNING: Illegal opcode %cget at %08lx PC=%x\n",
+       write_log (L"WARNING: Illegal opcode %cget at %08lx PC=%x\n",
            size == 2 ? 'w' : 'l', addr, M68K_GETPC);
     } else if (rw) {
-       write_log ("Illegal %cput at %08lx=%08lx PC=%x\n",
+       write_log (L"Illegal %cput at %08lx=%08lx PC=%x\n",
            size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, val, M68K_GETPC);
     } else {
-       write_log ("Illegal %cget at %08lx PC=%x\n",
+       write_log (L"Illegal %cget at %08lx PC=%x\n",
            size == 1 ? 'b' : size == 2 ? 'w' : 'l', addr, M68K_GETPC);
     }
 }
@@ -1839,7 +1839,7 @@ static void REGPARAM2 kickmem_lput (uaecptr addr, uae_u32 b)
        } else
            a1000_handle_kickstart (0);
     } else if (currprefs.illegal_mem)
-       write_log ("Illegal kickmem lput at %08lx\n", addr);
+       write_log (L"Illegal kickmem lput at %08lx\n", addr);
 }
 
 static void REGPARAM2 kickmem_wput (uaecptr addr, uae_u32 b)
@@ -1857,7 +1857,7 @@ static void REGPARAM2 kickmem_wput (uaecptr addr, uae_u32 b)
        } else
            a1000_handle_kickstart (0);
     } else if (currprefs.illegal_mem)
-       write_log ("Illegal kickmem wput at %08lx\n", addr);
+       write_log (L"Illegal kickmem wput at %08lx\n", addr);
 }
 
 static void REGPARAM2 kickmem_bput (uaecptr addr, uae_u32 b)
@@ -1873,7 +1873,7 @@ static void REGPARAM2 kickmem_bput (uaecptr addr, uae_u32 b)
        } else
            a1000_handle_kickstart (0);
     } else if (currprefs.illegal_mem)
-       write_log ("Illegal kickmem lput at %08lx\n", addr);
+       write_log (L"Illegal kickmem lput at %08lx\n", addr);
 }
 
 static void REGPARAM2 kickmem2_lput (uaecptr addr, uae_u32 l)
@@ -1967,7 +1967,7 @@ static void REGPARAM2 extendedkickmem_lput (uaecptr addr, uae_u32 b)
     special_mem |= S_WRITE;
 #endif
     if (currprefs.illegal_mem)
-       write_log ("Illegal extendedkickmem lput at %08lx\n", addr);
+       write_log (L"Illegal extendedkickmem lput at %08lx\n", addr);
 }
 static void REGPARAM2 extendedkickmem_wput (uaecptr addr, uae_u32 b)
 {
@@ -1975,7 +1975,7 @@ static void REGPARAM2 extendedkickmem_wput (uaecptr addr, uae_u32 b)
     special_mem |= S_WRITE;
 #endif
     if (currprefs.illegal_mem)
-       write_log ("Illegal extendedkickmem wput at %08lx\n", addr);
+       write_log (L"Illegal extendedkickmem wput at %08lx\n", addr);
 }
 static void REGPARAM2 extendedkickmem_bput (uaecptr addr, uae_u32 b)
 {
@@ -1983,7 +1983,7 @@ static void REGPARAM2 extendedkickmem_bput (uaecptr addr, uae_u32 b)
     special_mem |= S_WRITE;
 #endif
     if (currprefs.illegal_mem)
-       write_log ("Illegal extendedkickmem lput at %08lx\n", addr);
+       write_log (L"Illegal extendedkickmem lput at %08lx\n", addr);
 }
 static int REGPARAM2 extendedkickmem_check (uaecptr addr, uae_u32 size)
 {
@@ -2034,7 +2034,7 @@ static void REGPARAM2 extendedkickmem2_lput (uaecptr addr, uae_u32 b)
     special_mem |= S_WRITE;
 #endif
     if (currprefs.illegal_mem)
-       write_log ("Illegal extendedkickmem2 lput at %08lx\n", addr);
+       write_log (L"Illegal extendedkickmem2 lput at %08lx\n", addr);
 }
 static void REGPARAM2 extendedkickmem2_wput (uaecptr addr, uae_u32 b)
 {
@@ -2042,7 +2042,7 @@ static void REGPARAM2 extendedkickmem2_wput (uaecptr addr, uae_u32 b)
     special_mem |= S_WRITE;
 #endif
     if (currprefs.illegal_mem)
-       write_log ("Illegal extendedkickmem2 wput at %08lx\n", addr);
+       write_log (L"Illegal extendedkickmem2 wput at %08lx\n", addr);
 }
 static void REGPARAM2 extendedkickmem2_bput (uaecptr addr, uae_u32 b)
 {
@@ -2050,7 +2050,7 @@ static void REGPARAM2 extendedkickmem2_bput (uaecptr addr, uae_u32 b)
     special_mem |= S_WRITE;
 #endif
     if (currprefs.illegal_mem)
-       write_log ("Illegal extendedkickmem2 lput at %08lx\n", addr);
+       write_log (L"Illegal extendedkickmem2 lput at %08lx\n", addr);
 }
 static int REGPARAM2 extendedkickmem2_check (uaecptr addr, uae_u32 size)
 {
@@ -2088,15 +2088,15 @@ uae_u8 *REGPARAM2 default_xlate (uaecptr a)
                int i, j;
                uaecptr a2 = a - 32;
                uaecptr a3 = m68k_getpc (&regs) - 32;
-               write_log ("Your Amiga program just did something terribly stupid %08X PC=%08X\n", a, M68K_GETPC);
+               write_log (L"Your Amiga program just did something terribly stupid %08X PC=%08X\n", a, M68K_GETPC);
                m68k_dumpstate (0, 0);
                for (i = 0; i < 10; i++) {
-                   write_log ("%08X ", i >= 5 ? a3 : a2);
+                   write_log (L"%08X ", i >= 5 ? a3 : a2);
                    for (j = 0; j < 16; j += 2) {
-                       write_log (" %04X", get_word (i >= 5 ? a3 : a2));
+                       write_log (L" %04X", get_word (i >= 5 ? a3 : a2));
                        if (i >= 5) a3 += 2; else a2 += 2;
                    }
-                   write_log ("\n");
+                   write_log (L"\n");
                }
                memory_map_dump ();
            }
@@ -2127,14 +2127,14 @@ addrbank dummy_bank = {
 addrbank chipmem_bank = {
     chipmem_lget, chipmem_wget, chipmem_bget,
     chipmem_lput, chipmem_wput, chipmem_bput,
-    chipmem_xlate, chipmem_check, NULL, "Chip memory",
+    chipmem_xlate, chipmem_check, NULL, L"Chip memory",
     chipmem_lget, chipmem_wget, ABFLAG_RAM
 };
 
 addrbank chipmem_dummy_bank = {
     chipmem_dummy_lget, chipmem_dummy_wget, chipmem_dummy_bget,
     chipmem_dummy_lput, chipmem_dummy_wput, chipmem_dummy_bput,
-    default_xlate, dummy_check, NULL, "Dummy Chip memory",
+    default_xlate, dummy_check, NULL, L"Dummy Chip memory",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -2143,7 +2143,7 @@ addrbank chipmem_dummy_bank = {
 addrbank chipmem_bank_ce2 = {
     chipmem_lget_ce2, chipmem_wget_ce2, chipmem_bget_ce2,
     chipmem_lput_ce2, chipmem_wput_ce2, chipmem_bput_ce2,
-    chipmem_xlate, chipmem_check, NULL, "Chip memory (68020 'ce')",
+    chipmem_xlate, chipmem_check, NULL, L"Chip memory (68020 'ce')",
     chipmem_lget_ce2, chipmem_wget_ce2, ABFLAG_RAM
 };
 #endif
@@ -2151,55 +2151,55 @@ addrbank chipmem_bank_ce2 = {
 addrbank bogomem_bank = {
     bogomem_lget, bogomem_wget, bogomem_bget,
     bogomem_lput, bogomem_wput, bogomem_bput,
-    bogomem_xlate, bogomem_check, NULL, "Slow memory",
+    bogomem_xlate, bogomem_check, NULL, L"Slow memory",
     bogomem_lget, bogomem_wget, ABFLAG_RAM
 };
 
 addrbank cardmem_bank = {
     cardmem_lget, cardmem_wget, cardmem_bget,
     cardmem_lput, cardmem_wput, cardmem_bput,
-    cardmem_xlate, cardmem_check, NULL, "CDTV memory card",
+    cardmem_xlate, cardmem_check, NULL, L"CDTV memory card",
     cardmem_lget, cardmem_wget, ABFLAG_RAM
 };
 
 addrbank a3000lmem_bank = {
     a3000lmem_lget, a3000lmem_wget, a3000lmem_bget,
     a3000lmem_lput, a3000lmem_wput, a3000lmem_bput,
-    a3000lmem_xlate, a3000lmem_check, NULL, "RAMSEY memory (low)",
+    a3000lmem_xlate, a3000lmem_check, NULL, L"RAMSEY memory (low)",
     a3000lmem_lget, a3000lmem_wget, ABFLAG_RAM
 };
 
 addrbank a3000hmem_bank = {
     a3000hmem_lget, a3000hmem_wget, a3000hmem_bget,
     a3000hmem_lput, a3000hmem_wput, a3000hmem_bput,
-    a3000hmem_xlate, a3000hmem_check, NULL, "RAMSEY memory (high)",
+    a3000hmem_xlate, a3000hmem_check, NULL, L"RAMSEY memory (high)",
     a3000hmem_lget, a3000hmem_wget, ABFLAG_RAM
 };
 
 addrbank kickmem_bank = {
     kickmem_lget, kickmem_wget, kickmem_bget,
     kickmem_lput, kickmem_wput, kickmem_bput,
-    kickmem_xlate, kickmem_check, NULL, "Kickstart ROM",
+    kickmem_xlate, kickmem_check, NULL, L"Kickstart ROM",
     kickmem_lget, kickmem_wget, ABFLAG_ROM
 };
 
 addrbank kickram_bank = {
     kickmem_lget, kickmem_wget, kickmem_bget,
     kickmem2_lput, kickmem2_wput, kickmem2_bput,
-    kickmem_xlate, kickmem_check, NULL, "Kickstart Shadow RAM",
+    kickmem_xlate, kickmem_check, NULL, L"Kickstart Shadow RAM",
     kickmem_lget, kickmem_wget, ABFLAG_UNK | ABFLAG_SAFE
 };
 
 addrbank extendedkickmem_bank = {
     extendedkickmem_lget, extendedkickmem_wget, extendedkickmem_bget,
     extendedkickmem_lput, extendedkickmem_wput, extendedkickmem_bput,
-    extendedkickmem_xlate, extendedkickmem_check, NULL, "Extended Kickstart ROM",
+    extendedkickmem_xlate, extendedkickmem_check, NULL, L"Extended Kickstart ROM",
     extendedkickmem_lget, extendedkickmem_wget, ABFLAG_ROM
 };
 addrbank extendedkickmem2_bank = {
     extendedkickmem2_lget, extendedkickmem2_wget, extendedkickmem2_bget,
     extendedkickmem2_lput, extendedkickmem2_wput, extendedkickmem2_bput,
-    extendedkickmem2_xlate, extendedkickmem2_check, NULL, "Extended 2nd Kickstart ROM",
+    extendedkickmem2_xlate, extendedkickmem2_check, NULL, L"Extended 2nd Kickstart ROM",
     extendedkickmem2_lget, extendedkickmem2_wget, ABFLAG_ROM
 };
 
@@ -2343,13 +2343,13 @@ static uae_u8 *REGPARAM2 custmem2_xlate (uaecptr addr)
 addrbank custmem1_bank = {
     custmem1_lget, custmem1_wget, custmem1_bget,
     custmem1_lput, custmem1_wput, custmem1_bput,
-    custmem1_xlate, custmem1_check, NULL, "Non-autoconfig RAM #1",
+    custmem1_xlate, custmem1_check, NULL, L"Non-autoconfig RAM #1",
     custmem1_lget, custmem1_wget, ABFLAG_RAM
 };
 addrbank custmem2_bank = {
     custmem1_lget, custmem1_wget, custmem1_bget,
     custmem1_lput, custmem1_wput, custmem1_bput,
-    custmem1_xlate, custmem1_check, NULL, "Non-autoconfig RAM #2",
+    custmem1_xlate, custmem1_check, NULL, L"Non-autoconfig RAM #2",
     custmem1_lget, custmem1_wget, ABFLAG_RAM
 };
 
@@ -2370,7 +2370,7 @@ void a3000_fakekick (int map)
                memcpy (kickmemory + fkickmem_size / 2, fkickmemory, fkickmem_size / 2);
                extendedkickmem_size = 65536;
                extendedkickmem_mask = extendedkickmem_size - 1;
-               extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_f0");
+               extendedkickmemory = mapped_malloc (extendedkickmem_size, L"rom_f0");
                extendedkickmem_bank.baseaddr = extendedkickmemory;
                memcpy (extendedkickmemory, fkickmemory + fkickmem_size / 2, 65536);
                map_banks (&extendedkickmem_bank, 0xf0, 1, 1);
@@ -2408,11 +2408,11 @@ static int read_rom_file (uae_u8 *buf, struct romdata *rd)
 {
     struct zfile *zf;
     struct romlist *rl = romlist_getrl (rd);
-    char tmp[11];
+    uae_char tmp[11];
 
-    if (!rl || strlen (rl->path) == 0)
+    if (!rl || _tcslen (rl->path) == 0)
        return 0;
-    zf = zfile_fopen (rl->path, "rb");
+    zf = zfile_fopen (rl->path, L"rb");
     if (!zf)
        return 0;
     addkeydir (rl->path);
@@ -2485,7 +2485,7 @@ struct zfile *read_rom (struct romdata **prd)
 {
     struct romdata *rd2 = *prd;
     struct romdata *rd = *prd;
-    char *name;
+    TCHAR *name;
     int id = rd->id;
     uae_u32 crc32;
     int size;
@@ -2591,20 +2591,20 @@ struct zfile *read_rom (struct romdata **prd)
     return NULL;
 }
 
-struct zfile *read_rom_name (const char *filename)
+struct zfile *read_rom_name (const TCHAR *filename)
 {
     int i;
     struct zfile *f;
 
     for (i = 0; i < romlist_cnt; i++) {
-       if (!strcmpi (filename, rl[i].path)) {
+       if (!_tcsicmp (filename, rl[i].path)) {
            struct romdata *rd = rl[i].rd;
            f = read_rom (&rd);
            if (f)
                return f;
        }
     }
-    f = zfile_fopen (filename, "rb");
+    f = zfile_fopen (filename, L"rb");
     if (f) {
        uae_u8 tmp[11];
        zfile_fread (tmp, sizeof tmp, 1, f);
@@ -2618,7 +2618,7 @@ struct zfile *read_rom_name (const char *filename)
            zfile_fseek (f, sizeof tmp, SEEK_SET);
            buf = xmalloc (size);
            zfile_fread (buf, size, 1, f);
-           df = zfile_fopen_empty ("tmp.rom", size);
+           df = zfile_fopen_empty (L"tmp.rom", size);
            decode_cloanto_rom_do (buf, size, size);
            zfile_fwrite (buf, size, 1, df);
            zfile_fclose (f);
@@ -2632,10 +2632,10 @@ struct zfile *read_rom_name (const char *filename)
     return f;
 }
 
-static char *kickstring = "exec.library";
+static uae_char *kickstring = "exec.library";
 static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksum, int noalias)
 {
-    unsigned char buffer[20];
+    uae_char buffer[20];
     int i, j, oldpos;
     int cr = 0, kickdisk = 0;
 
@@ -2655,7 +2655,7 @@ static int read_kickstart (struct zfile *f, uae_u8 *mem, int size, int dochecksu
        zfile_fseek (f, oldpos + 0x6c, SEEK_SET);
        cr = 2;
 #endif
-    } else if (strncmp ((char *)buffer, "AMIROMTYPE1", 11) != 0) {
+    } else if (memcmp ((uae_char*)buffer, "AMIROMTYPE1", 11) != 0) {
        zfile_fseek (f, oldpos, SEEK_SET);
     } else {
        cloanto_rom = 1;
@@ -2707,7 +2707,7 @@ static int load_extendedkickstart (void)
     struct zfile *f;
     int size, off;
 
-    if (strlen (currprefs.romextfile) == 0)
+    if (_tcslen (currprefs.romextfile) == 0)
        return 0;
     if (is_arcadia_rom (currprefs.romextfile) == ARCADIA_BIOS) {
        extendedkickmem_type = EXTENDED_ROM_ARCADIA;
@@ -2735,11 +2735,11 @@ static int load_extendedkickstart (void)
     zfile_fseek (f, off, SEEK_SET);
     switch (extendedkickmem_type) {
     case EXTENDED_ROM_CDTV:
-       extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_f0");
+       extendedkickmemory = mapped_malloc (extendedkickmem_size, L"rom_f0");
        extendedkickmem_bank.baseaddr = extendedkickmemory;
        break;
     case EXTENDED_ROM_CD32:
-       extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_e0");
+       extendedkickmemory = mapped_malloc (extendedkickmem_size, L"rom_e0");
        extendedkickmem_bank.baseaddr = extendedkickmemory;
        break;
     }
@@ -2788,7 +2788,7 @@ static int patch_shapeshifter (uae_u8 *kickmemory)
        !memcmp (kickmemory + i, kickshift2, sizeof (kickshift2)) ||
        !memcmp (kickmemory + i, kickshift3, sizeof (kickshift3))) {
            kickmemory[i + 2] = 0x30;
-           write_log ("Kickstart KickShifted @%04X\n", i);
+           write_log (L"Kickstart KickShifted @%04X\n", i);
            patched++;
        }
     }
@@ -2799,7 +2799,7 @@ static int patch_shapeshifter (uae_u8 *kickmemory)
 static int patch_residents (uae_u8 *kickmemory, int size)
 {
     int i, j, patched = 0;
-    char *residents[] = { "NCR scsi.device", 0 };
+    uae_char *residents[] = { "NCR scsi.device", 0 };
     // "scsi.device", "carddisk.device", "card.resource" };
     uaecptr base = size == 524288 ? 0xf80000 : 0xfc0000;
 
@@ -2816,7 +2816,7 @@ static int patch_residents (uae_u8 *kickmemory, int size)
                j = 0;
                while (residents[j]) {
                    if (!memcmp (residents[j], kickmemory + addr - base, strlen (residents[j]) + 1)) {
-                       write_log ("KSPatcher: '%s' at %08X disabled\n", residents[j], i + base);
+                       write_log (L"KSPatcher: '%s' at %08X disabled\n", residents[j], i + base);
                        kickmemory[i] = 0x4b; /* destroy RTC_MATCHWORD */
                        patched++;
                        break;
@@ -2847,32 +2847,32 @@ static void patch_kick (void)
 static int load_kickstart (void)
 {
     struct zfile *f;
-    char tmprom[MAX_DPATH], tmprom2[MAX_DPATH];
+    TCHAR tmprom[MAX_DPATH], tmprom2[MAX_DPATH];
     int patched = 0;
 
     cloanto_rom = 0;
     f = read_rom_name (currprefs.romfile);
-    strcpy (tmprom, currprefs.romfile);
+    _tcscpy (tmprom, currprefs.romfile);
     if (f == NULL) {
-       sprintf (tmprom2, "%s%s", start_path_data, currprefs.romfile);
-       f = zfile_fopen (tmprom2, "rb");
+       _stprintf (tmprom2, L"%s%s", start_path_data, currprefs.romfile);
+       f = zfile_fopen (tmprom2, L"rb");
        if (f == NULL) {
-           sprintf (currprefs.romfile, "%sroms/kick.rom", start_path_data);
-           f = zfile_fopen (currprefs.romfile, "rb");
+           _stprintf (currprefs.romfile, L"%sroms/kick.rom", start_path_data);
+           f = zfile_fopen (currprefs.romfile, L"rb");
            if (f == NULL) {
-               sprintf (currprefs.romfile, "%skick.rom", start_path_data);
-               f = zfile_fopen (currprefs.romfile, "rb");
+               _stprintf (currprefs.romfile, L"%skick.rom", start_path_data);
+               f = zfile_fopen (currprefs.romfile, L"rb");
                if (f == NULL) {
-                   sprintf (currprefs.romfile, "%s../shared/rom/kick.rom", start_path_data);
-                   f = zfile_fopen (currprefs.romfile, "rb");
+                   _stprintf (currprefs.romfile, L"%s../shared/rom/kick.rom", start_path_data);
+                   f = zfile_fopen (currprefs.romfile, L"rb");
                    if (f == NULL) {
-                       sprintf (currprefs.romfile, "%s../System/rom/kick.rom", start_path_data);
-                       f = zfile_fopen (currprefs.romfile, "rb");
+                       _stprintf (currprefs.romfile, L"%s../System/rom/kick.rom", start_path_data);
+                       f = zfile_fopen (currprefs.romfile, L"rb");
                    }
                }
            }
        } else {
-           strcpy (currprefs.romfile, tmprom2);
+           _tcscpy (currprefs.romfile, tmprom2);
        }
     }
     addkeydir (currprefs.romfile);
@@ -2881,7 +2881,7 @@ static int load_kickstart (void)
 #define USE_UAE_ERSATZ "USE_UAE_ERSATZ"
        if( !getenv(USE_UAE_ERSATZ))
        {
-           write_log ("Using current ROM. (create ENV:%s to "
+           write_log (L"Using current ROM. (create ENV:%s to "
                "use uae's ROM replacement)\n",USE_UAE_ERSATZ);
            memcpy(kickmemory,(char*)0x1000000-kickmem_size,kickmem_size);
            kickstart_checksum (kickmemory, kickmem_size);
@@ -2928,10 +2928,10 @@ static int load_kickstart (void)
            if (currprefs.cs_cdtvcd || currprefs.cs_cdtvram) {
                extendedkickmem_type = EXTENDED_ROM_CDTV;
                extendedkickmem_size *= 2;
-               extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_f0");
+               extendedkickmemory = mapped_malloc (extendedkickmem_size, L"rom_f0");
            } else {
                extendedkickmem_type = EXTENDED_ROM_KS;
-               extendedkickmemory = mapped_malloc (extendedkickmem_size, "rom_e0");
+               extendedkickmemory = mapped_malloc (extendedkickmem_size, L"rom_e0");
            }
            extendedkickmem_bank.baseaddr = extendedkickmemory;
            zfile_fseek (f, extpos, SEEK_SET);
@@ -2940,7 +2940,7 @@ static int load_kickstart (void)
        }
        if (filesize > 524288 * 2) {
            extendedkickmem2_size = 524288 * 2;
-           extendedkickmemory2 = mapped_malloc (extendedkickmem2_size, "rom_a8");
+           extendedkickmemory2 = mapped_malloc (extendedkickmem2_size, L"rom_a8");
            extendedkickmem2_bank.baseaddr = extendedkickmemory2;
            zfile_fseek (f, extpos + 524288, SEEK_SET);
            read_kickstart (f, extendedkickmemory2, 524288, 0, 1);
@@ -2960,14 +2960,14 @@ static int load_kickstart (void)
     zfile_fclose (f);
     return 1;
 err:
-    strcpy (currprefs.romfile, tmprom);
+    _tcscpy (currprefs.romfile, tmprom);
     zfile_fclose (f);
     return 0;
 }
 
 #ifndef NATMEM_OFFSET
 
-uae_u8 *mapped_malloc (size_t s, char *file)
+uae_u8 *mapped_malloc (size_t s, TCHAR *file)
 {
     return xmalloc (s);
 }
@@ -2989,13 +2989,13 @@ shmpiece *shm_start;
 static void dumplist (void)
 {
     shmpiece *x = shm_start;
-    write_log ("Start Dump:\n");
+    write_log (L"Start Dump:\n");
     while (x) {
-       write_log ("this=%p,Native %p,id %d,prev=%p,next=%p,size=0x%08x\n",
+       write_log (L"this=%p,Native %p,id %d,prev=%p,next=%p,size=0x%08x\n",
                x, x->native_address, x->id, x->prev, x->next, x->size);
        x = x->next;
     }
-    write_log ("End Dump:\n");
+    write_log (L"End Dump:\n");
 }
 
 static shmpiece *find_shmpiece (uae_u8 *base)
@@ -3005,7 +3005,7 @@ static shmpiece *find_shmpiece (uae_u8 *base)
     while (x && x->native_address != base)
        x = x->next;
     if (!x) {
-       write_log ("NATMEM: Failure to find mapping at %08X, %p\n", base - NATMEM_OFFSET, base);
+       write_log (L"NATMEM: Failure to find mapping at %08X, %p\n", base - NATMEM_OFFSET, base);
        nocanbang ();
        return 0;
     }
@@ -3029,7 +3029,7 @@ static void delete_shmmaps (uae_u32 start, uae_u32 size)
 
            if (x->size > size) {
                if (isdirectjit ())
-                   write_log ("NATMEM WARNING: size mismatch mapping at %08x (size %08x, delsize %08x)\n",start,x->size,size);
+                   write_log (L"NATMEM WARNING: size mismatch mapping at %08x (size %08x, delsize %08x)\n",start,x->size,size);
                size = x->size;
            }
 #if 0
@@ -3074,7 +3074,7 @@ static void add_shmmaps (uae_u32 start, addrbank *what)
     base = ((uae_u8 *) NATMEM_OFFSET) + start;
     y->native_address = shmat (y->id, base, 0);
     if (y->native_address == (void *) -1) {
-       write_log ("NATMEM: Failure to map existing at %08x(%p)\n", start, base);
+       write_log (L"NATMEM: Failure to map existing at %08x(%p)\n", start, base);
        dumplist ();
        nocanbang ();
        return;
@@ -3086,7 +3086,7 @@ static void add_shmmaps (uae_u32 start, addrbank *what)
     shm_start = y;
 }
 
-uae_u8 *mapped_malloc (size_t s, const char *file)
+uae_u8 *mapped_malloc (size_t s, const TCHAR *file)
 {
     int id;
     void *answer;
@@ -3112,7 +3112,7 @@ uae_u8 *mapped_malloc (size_t s, const char *file)
     answer = shmat (id, 0, 0);
     shmctl (id, IPC_RMID, NULL);
     if (answer != (void *) -1) {
-       x = (shmpiece*)xmalloc (sizeof (shmpiece));
+       x = xmalloc (sizeof (shmpiece));
        x->native_address = (uae_u8*)answer;
        x->id = id;
        x->size = s;
@@ -3159,11 +3159,11 @@ static void allocate_memory (void)
        chipmem_mask = allocated_chipmem - 1;
        chipmem_full_mask = allocated_chipmem * 2 - 1;
        chipmem_full_size = 0x80000 * 2;
-       chipmemory = mapped_malloc (memsize1 + memsize2, "chip");
+       chipmemory = mapped_malloc (memsize1 + memsize2, L"chip");
        bogomemory = chipmemory + memsize1;
        bogomem_mask = allocated_bogomem - 1;
        if (chipmemory == 0) {
-           write_log ("Fatal error: out of memory for chipmem.\n");
+           write_log (L"Fatal error: out of memory for chipmem.\n");
            allocated_chipmem = 0;
        } else {
            need_hardreset = 1;
@@ -3184,9 +3184,9 @@ static void allocate_memory (void)
            memsize = 0x100000;
        if (memsize > 0x100000 && memsize < 0x200000)
            memsize = 0x200000;
-       chipmemory = mapped_malloc (memsize, "chip");
+       chipmemory = mapped_malloc (memsize, L"chip");
        if (chipmemory == 0) {
-           write_log ("Fatal error: out of memory for chipmem.\n");
+           write_log (L"Fatal error: out of memory for chipmem.\n");
            allocated_chipmem = 0;
        } else {
            need_hardreset = 1;
@@ -3213,9 +3213,9 @@ static void allocate_memory (void)
        bogomem_mask = allocated_bogomem - 1;
 
        if (allocated_bogomem) {
-           bogomemory = mapped_malloc (allocated_bogomem, "bogo");
+           bogomemory = mapped_malloc (allocated_bogomem, L"bogo");
            if (bogomemory == 0) {
-               write_log ("Out of memory for bogomem.\n");
+               write_log (L"Out of memory for bogomem.\n");
                allocated_bogomem = 0;
            }
        }
@@ -3230,9 +3230,9 @@ static void allocate_memory (void)
        a3000lmem_mask = allocated_a3000lmem - 1;
        a3000lmem_start = 0x08000000 - allocated_a3000lmem;
        if (allocated_a3000lmem) {
-           a3000lmemory = mapped_malloc (allocated_a3000lmem, "ramsey_low");
+           a3000lmemory = mapped_malloc (allocated_a3000lmem, L"ramsey_low");
            if (a3000lmemory == 0) {
-               write_log ("Out of memory for a3000lowmem.\n");
+               write_log (L"Out of memory for a3000lowmem.\n");
                allocated_a3000lmem = 0;
            }
        }
@@ -3247,9 +3247,9 @@ static void allocate_memory (void)
        a3000hmem_mask = allocated_a3000hmem - 1;
        a3000hmem_start = 0x08000000;
        if (allocated_a3000hmem) {
-           a3000hmemory = mapped_malloc (allocated_a3000hmem, "ramsey_high");
+           a3000hmemory = mapped_malloc (allocated_a3000hmem, L"ramsey_high");
            if (a3000hmemory == 0) {
-               write_log ("Out of memory for a3000highmem.\n");
+               write_log (L"Out of memory for a3000highmem.\n");
                allocated_a3000hmem = 0;
            }
        }
@@ -3263,9 +3263,9 @@ static void allocate_memory (void)
        allocated_cardmem = currprefs.cs_cdtvcard * 1024;
        cardmem_mask = allocated_cardmem - 1;
        if (allocated_cardmem) {
-           cardmemory = mapped_malloc (allocated_cardmem, "rom_e0");
+           cardmemory = mapped_malloc (allocated_cardmem, L"rom_e0");
            if (cardmemory == 0) {
-               write_log ("Out of memory for cardmem.\n");
+               write_log (L"Out of memory for cardmem.\n");
                allocated_cardmem = 0;
            }
        }
@@ -3278,7 +3278,7 @@ static void allocate_memory (void)
        allocated_custmem1 = currprefs.custom_memory_sizes[0];
        custmem1_mask = allocated_custmem1 - 1;
        if (allocated_custmem1) {
-           custmem1 = mapped_malloc (allocated_custmem1, "custmem1");
+           custmem1 = mapped_malloc (allocated_custmem1, L"custmem1");
            if (!custmem1)
                allocated_custmem1 = 0;
        }
@@ -3290,7 +3290,7 @@ static void allocate_memory (void)
        allocated_custmem2 = currprefs.custom_memory_sizes[1];
        custmem2_mask = allocated_custmem2 - 1;
        if (allocated_custmem2) {
-           custmem2 = mapped_malloc (allocated_custmem2, "custmem2");
+           custmem2 = mapped_malloc (allocated_custmem2, L"custmem2");
            if (!custmem2)
                allocated_custmem2 = 0;
        }
@@ -3402,8 +3402,8 @@ void memory_reset (void)
     init_mem_banks ();
     allocate_memory ();
 
-    if (strcmp (currprefs.romfile, changed_prefs.romfile) != 0
-       || strcmp (currprefs.romextfile, changed_prefs.romextfile) != 0)
+    if (_tcscmp (currprefs.romfile, changed_prefs.romfile) != 0
+       || _tcscmp (currprefs.romextfile, changed_prefs.romextfile) != 0)
     {
         kickstart_rom = 1;
        ersatzkickfile = 0;
@@ -3424,8 +3424,8 @@ void memory_reset (void)
        load_extendedkickstart ();
        kickmem_mask = 524288 - 1;
        if (!load_kickstart ()) {
-           if (strlen (currprefs.romfile) > 0) {
-               write_log ("Failed to open '%s'\n", currprefs.romfile);
+           if (_tcslen (currprefs.romfile) > 0) {
+               write_log (L"Failed to open '%s'\n", currprefs.romfile);
                notify_user (NUMSG_NOROM);
            }
 #ifdef AUTOCONFIG
@@ -3604,9 +3604,9 @@ void memory_reset (void)
 
 #ifdef ARCADIA
     if (is_arcadia_rom (currprefs.romextfile) == ARCADIA_BIOS) {
-       if (strcmp (currprefs.romextfile, changed_prefs.romextfile) != 0)
+       if (_tcscmp (currprefs.romextfile, changed_prefs.romextfile) != 0)
            memcpy (currprefs.romextfile, changed_prefs.romextfile, sizeof currprefs.romextfile);
-       if (strcmp (currprefs.cartfile, changed_prefs.cartfile) != 0)
+       if (_tcscmp (currprefs.cartfile, changed_prefs.cartfile) != 0)
            memcpy (currprefs.cartfile, changed_prefs.cartfile, sizeof currprefs.cartfile);
        arcadia_unmap ();
        is_arcadia_rom (currprefs.romextfile);
@@ -3646,10 +3646,10 @@ void memory_init (void)
 
     init_mem_banks ();
 
-    kickmemory = mapped_malloc (0x80000, "kick");
+    kickmemory = mapped_malloc (0x80000, L"kick");
     memset (kickmemory, 0, 0x80000);
     kickmem_bank.baseaddr = kickmemory;
-    strcpy (currprefs.romfile, "<none>");
+    _tcscpy (currprefs.romfile, L"<none>");
     currprefs.romextfile[0] = 0;
 
 #ifdef ACTION_REPLAY
@@ -3746,7 +3746,7 @@ void map_banks (addrbank *bank, int start, int size, int realsize)
     addrbank *orgbank = bank;
     uae_u32 realstart = start;
 
-    //write_log ("MAP_BANK %04X0000 %d %s\n", start, size, bank->name);
+    //write_log (L"MAP_BANK %04X0000 %d %s\n", start, size, bank->name);
 
     old = debug_bankchange (-1);
     flush_icache (0, 3); /* Sure don't want to keep any old mappings around! */
@@ -3758,7 +3758,7 @@ void map_banks (addrbank *bank, int start, int size, int realsize)
        realsize = size << 16;
 
     if ((size << 16) < realsize) {
-       write_log ("Broken mapping, size=%x, realsize=%x\nStart is %x\n",
+       write_log (L"Broken mapping, size=%x, realsize=%x\nStart is %x\n",
            size, realsize, start);
     }
 
@@ -3871,6 +3871,7 @@ void restore_a3000hram (int len, size_t filepos)
 uae_u8 *restore_rom (uae_u8 *src)
 {
     uae_u32 crc32, mem_start, mem_size, mem_type, version;
+    TCHAR *s;
     int i;
 
     mem_start = restore_u32 ();
@@ -3878,33 +3879,35 @@ uae_u8 *restore_rom (uae_u8 *src)
     mem_type = restore_u32 ();
     version = restore_u32 ();
     crc32 = restore_u32 ();
+    s = restore_string ();
     for (i = 0; i < romlist_cnt; i++) {
        if (rl[i].rd->crc32 == crc32 && crc32) {
            switch (mem_type)
            {
                case 0:
-               strncpy (changed_prefs.romfile, rl[i].path, 255);
+               _tcsncmp (changed_prefs.romfile, rl[i].path, 255);
                break;
                case 1:
-               strncpy (changed_prefs.romextfile, rl[i].path, 255);
+               _tcsncmp (changed_prefs.romextfile, rl[i].path, 255);
                break;
            }
            break;
        }
     }
-    src += strlen (src) + 1;
-    if (zfile_exists(src)) {
+    xfree (s);
+    s = restore_string ();
+    if (zfile_exists (s)) {
        switch (mem_type)
        {
            case 0:
-           strncpy (changed_prefs.romfile, src, 255);
+           _tcsncmp (changed_prefs.romfile, s, 255);
            break;
            case 1:
-           strncpy (changed_prefs.romextfile, src, 255);
+           _tcsncmp (changed_prefs.romextfile, s, 255);
            break;
        }
     }
-    src += strlen (src) + 1;
+    xfree (s);
     return src;
 }
 
@@ -3914,10 +3917,10 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
     uae_u8 *dst, *dstbak;
     uae_u8 *mem_real_start;
     uae_u32 version;
-    char *path;
+    TCHAR *path;
     int mem_start, mem_size, mem_type, saverom;
     int i;
-    char tmpname[1000];
+    TCHAR tmpname[1000];
 
     version = 0;
     saverom = 0;
@@ -3942,7 +3945,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
                mem_start += 262144;
            }
            version = longget (mem_start + 12); /* version+revision */
-           sprintf (tmpname, "Kickstart %d.%d", wordget (mem_start + 12), wordget (mem_start + 14));
+           _stprintf (tmpname, L"Kickstart %d.%d", wordget (mem_start + 12), wordget (mem_start + 14));
            break;
        case 1: /* Extended ROM */
            if (!extendedkickmem_type)
@@ -3951,7 +3954,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
            mem_real_start = extendedkickmemory;
            mem_size = extendedkickmem_size;
            path = currprefs.romextfile;
-           sprintf (tmpname, "Extended");
+           _stprintf (tmpname, L"Extended");
            break;
        default:
            return 0;
@@ -3969,10 +3972,8 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
     save_u32 (mem_type);
     save_u32 (version);
     save_u32 (get_crc32 (mem_real_start, mem_size));
-    strcpy (dst, tmpname);
-    dst += strlen (dst) + 1;
-    strcpy (dst, path);/* rom image name */
-    dst += strlen (dst) + 1;
+    save_string (tmpname);
+    save_string (path);
     if (saverom) {
        for (i = 0; i < mem_size; i++)
            *dst++ = byteget (mem_start + i);
@@ -3987,7 +3988,7 @@ uae_u8 *save_rom (int first, int *len, uae_u8 *dstptr)
 
 void memcpyha_safe (uaecptr dst, const uae_u8 *src, int size)
 {
-    if (!addr_valid ("memcpyha", dst, size))
+    if (!addr_valid (L"memcpyha", dst, size))
        return;
     while (size--)
        put_byte (dst++, *src++);
@@ -3999,7 +4000,7 @@ void memcpyha (uaecptr dst, const uae_u8 *src, int size)
 }
 void memcpyah_safe (uae_u8 *dst, uaecptr src, int size)
 {
-    if (!addr_valid ("memcpyah", src, size))
+    if (!addr_valid (L"memcpyah", src, size))
        return;
     while (size--)
        *dst++ = get_byte (src++);
@@ -4009,12 +4010,12 @@ void memcpyah (uae_u8 *dst, uaecptr src, int size)
     while (size--)
        *dst++ = get_byte (src++);
 }
-char *strcpyah_safe (char *dst, uaecptr src, int maxsize)
+uae_char *strcpyah_safe (uae_char *dst, uaecptr src, int maxsize)
 {
-    char *res = dst;
+    uae_char *res = dst;
     uae_u8 b;
     do {
-       if (!addr_valid ("strcpyah", src, 1))
+       if (!addr_valid (L"_tcscpyah", src, 1))
            return res;
        b = get_byte (src++);
        *dst++ = b;
@@ -4026,12 +4027,12 @@ char *strcpyah_safe (char *dst, uaecptr src, int maxsize)
     } while (b);
     return res;
 }
-uaecptr strcpyha_safe (uaecptr dst, const char *src)
+uaecptr strcpyha_safe (uaecptr dst, const uae_char *src)
 {
     uaecptr res = dst;
     uae_u8 b;
     do {
-       if (!addr_valid ("strcpyha", dst, 1))
+       if (!addr_valid (L"_tcscpyha", dst, 1))
            return res;
        b = *src++;
        put_byte (dst++, b);
index 0b6453464e2560aab957ace19468116f246a7e13..a16c490beab40428a8b534a147f706f44211fc47 100644 (file)
--- a/missing.c
+++ b/missing.c
 
 #ifndef HAVE_STRDUP
 
-char *my_strdup (const char *s)
+TCHAR *my_strdup (const TCHAR *s)
 {
-    /* The casts to char * are there to shut up the compiler on HPUX */
-    char *x = (char*)xmalloc(strlen((char *)s) + 1);
-    strcpy(x, (char *)s);
+    TCHAR *x = (char*)xmalloc(strlen((TCHAR *)s) + 1);
+    strcpy(x, (TCHAR *)s);
     return x;
 }
 
index 141a6b8a67401de2aa0343488e5fbccc39bc26c7..aa87ac1d2817f79629d61a6ed5bc1328bc20e892 100644 (file)
@@ -72,7 +72,7 @@ void moduleripper (void)
        prowizard_search (buf, size);
 #ifdef _WIN32
     } __except(ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
-       write_log ("prowizard scan crashed\n");
+       write_log (L"prowizard scan crashed\n");
     }
 #endif
     if (!got)
@@ -84,22 +84,31 @@ void moduleripper (void)
 
 FILE *moduleripper_fopen (const char *name, const char *mode)
 {
-    char tmp[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR tmp2[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
+    TCHAR *ufn, *umode;
+    FILE *f;
+
     fetch_ripperpath (tmp, sizeof tmp);
-    sprintf (tmp2, "%s%s", tmp, name);
-    return fopen (tmp2, mode);
+    ufn = au (name);
+    umode = au (mode);
+    _stprintf (tmp2, L"%s%s", tmp, ufn);
+    f = _tfopen (tmp2, umode);
+    xfree (umode);
+    xfree (ufn);
+    return f;
 }
 
 FILE *moduleripper2_fopen (const char *name, const char *mode, const char *id, int addr, int size)
 {
-    char msg[MAX_DPATH], msg2[MAX_DPATH];
+    TCHAR msg[MAX_DPATH], msg2[MAX_DPATH];
     int ret;
 
     if (canceled)
        return NULL;
     got++;
     translate_message (NUMSG_MODRIP_SAVE, msg);
-    sprintf (msg2, msg, id, addr, size);
+    _stprintf (msg2, msg, id, addr, size);
     ret = gui_message_multibutton (2, msg2);
     if (ret < 0)
        canceled = 1;
index d570bf4e8bb76b600f8af293eb7a44a148545d44..1afdbd291a49638a339688c0629ee1a462676e56 100644 (file)
@@ -20,7 +20,7 @@
 #include "ncr_scsi.h"
 #include "zfile.h"
 
-#define NCRNAME "NCR53C710"
+#define NCRNAME L"NCR53C710"
 #define NCR_REGS 0x40
 
 #define ROM_VECTOR 0x0200
@@ -37,80 +37,80 @@ static uae_u8 acmemory[100];
 static uae_u8 ncrregs[NCR_REGS];
 
 struct ncrscsi {
-    char *name;
+    TCHAR *name;
     int be, le;
 };
 
 static struct ncrscsi regsinfo[] =
 {
-    "SCNTL0",   0,  3,
-    "SCNTL1",   1,  2,
-    "SDID",     2,  1,
-    "SIEN",     3,  0,
-    "SCID",     4,  7,
-    "SXFER",    5,  6,
-    "SODL",     6,  5,
-    "SOCL",     7,  4,
-    "SFBR",     8, 11,
-    "SIDL",     9, 10,
-    "SBDL",    10, -1,
-    "SBCL",    11,  8,
-    "DSTAT",   12, 15,
-    "SSTAT0",  13, 14,
-    "SSTAT1",  14, 13,
-    "SSTAT2",  15, 12,
-    "DSA0",    16, 19,
-    "DSA1",    17, 18,
-    "DSA2",    18, 17,
-    "DSA3",    19, 16,
-    "CTEST0",  20, 23,
-    "CTEST1",  21, 22,
-    "CTEST2",  22, 21,
-    "CTEST3",  23, 20,
-    "CTEST4",  24, 27,
-    "CTEST5",  25, 26,
-    "CTEST6",  26, 25,
-    "CTEST7",  27, 24,
-    "TEMP0",   28, 31,
-    "TEMP1",   29, 30,
-    "TEMP2",   30, 29,
-    "TEMP3",   31, 28,
-    "DFIFO",   32, 35,
-    "ISTAT",   33, 34,
-    "CTEST8",  34, 33,
-    "LCRC",    35, 32,
-    "DBC0",    36, 39,
-    "DBC1",    37, 38,
-    "DBC2",    38, 37,
-    "DCMD",    39, 36,
-    "DNAD0",   40, 43,
-    "DNAD1",   41, 42,
-    "DNAD2",   42, 41,
-    "DNAD3",   43, 40,
-    "DSP0",    44, 47,
-    "DSP1",    45, 46,
-    "DSP2",    46, 45,
-    "DSP3",    47, 44,
-    "DSPS0",   48, 51,
-    "DSPS1",   49, 50,
-    "DSPS2",   50, 49,
-    "DSPS3",   51, 48,
-    "SCRATCH0",        52, 55,
-    "SCRATCH1",        53, 54,
-    "SCRATCH2",        54, 53,
-    "SCRATCH3",        55, 52,
-    "DMODE",   56, 59,
-    "DIEN",    57, 58,
-    "DWT",     58, 57,
-    "DCNTL",   59, 56,
-    "ADDER0",  60, 63,
-    "ADDER1",  61, 62,
-    "ADDER2",  62, 61,
-    "ADDER3",  63, 60,
+    L"SCNTL0",  0,  3,
+    L"SCNTL1",  1,  2,
+    L"SDID",    2,  1,
+    L"SIEN",    3,  0,
+    L"SCID",    4,  7,
+    L"SXFER",   5,  6,
+    L"SODL",    6,  5,
+    L"SOCL",    7,  4,
+    L"SFBR",    8, 11,
+    L"SIDL",    9, 10,
+    L"SBDL",   10, -1,
+    L"SBCL",   11,  8,
+    L"DSTAT",  12, 15,
+    L"SSTAT0", 13, 14,
+    L"SSTAT1", 14, 13,
+    L"SSTAT2", 15, 12,
+    L"DSA0",   16, 19,
+    L"DSA1",   17, 18,
+    L"DSA2",   18, 17,
+    L"DSA3",   19, 16,
+    L"CTEST0", 20, 23,
+    L"CTEST1", 21, 22,
+    L"CTEST2", 22, 21,
+    L"CTEST3", 23, 20,
+    L"CTEST4", 24, 27,
+    L"CTEST5", 25, 26,
+    L"CTEST6", 26, 25,
+    L"CTEST7", 27, 24,
+    L"TEMP0",  28, 31,
+    L"TEMP1",  29, 30,
+    L"TEMP2",  30, 29,
+    L"TEMP3",  31, 28,
+    L"DFIFO",  32, 35,
+    L"ISTAT",  33, 34,
+    L"CTEST8", 34, 33,
+    L"LCRC",   35, 32,
+    L"DBC0",   36, 39,
+    L"DBC1",   37, 38,
+    L"DBC2",   38, 37,
+    L"DCMD",   39, 36,
+    L"DNAD0",  40, 43,
+    L"DNAD1",  41, 42,
+    L"DNAD2",  42, 41,
+    L"DNAD3",  43, 40,
+    L"DSP0",   44, 47,
+    L"DSP1",   45, 46,
+    L"DSP2",   46, 45,
+    L"DSP3",   47, 44,
+    L"DSPS0",  48, 51,
+    L"DSPS1",  49, 50,
+    L"DSPS2",  50, 49,
+    L"DSPS3",  51, 48,
+    L"SCRATCH0",       52, 55,
+    L"SCRATCH1",       53, 54,
+    L"SCRATCH2",       54, 53,
+    L"SCRATCH3",       55, 52,
+    L"DMODE",  56, 59,
+    L"DIEN",   57, 58,
+    L"DWT",    58, 57,
+    L"DCNTL",  59, 56,
+    L"ADDER0", 60, 63,
+    L"ADDER1", 61, 62,
+    L"ADDER2", 62, 61,
+    L"ADDER3", 63, 60,
     NULL
 };
 
-static char *regname(uaecptr addr)
+static TCHAR *regname (uaecptr addr)
 {
     int i;
 
@@ -118,7 +118,7 @@ static char *regname(uaecptr addr)
        if (regsinfo[i].le == addr)
            return regsinfo[i].name;
     }
-    return "?";
+    return L"?";
 }
 
 #define SCNTL0_REG                      0x03
@@ -252,14 +252,14 @@ static void INT2(void)
     if (ncrregs[SIEN_REG] == 0)
        return;
     INTREQ_f(0x8000 | 0x0008);
-    write_log ("IRQ\n");
+    write_log (L"IRQ\n");
 }
 
 
 static uae_u8 read_rombyte (uaecptr addr)
 {
     uae_u8 v = rom[addr];
-    //write_log ("%08X = %02X PC=%08X\n", addr, v, M68K_GETPC);
+    //write_log (L"%08X = %02X PC=%08X\n", addr, v, M68K_GETPC);
     return v;
 }
 
@@ -278,7 +278,7 @@ void ncr_bput2 (uaecptr addr, uae_u32 val)
        INT2();
        break;
     }
-    write_log ("%s write %04X (%s) = %02X PC=%08X\n", NCRNAME, addr, regname(addr), v & 0xff, M68K_GETPC);
+    write_log (L"%s write %04X (%s) = %02X PC=%08X\n", NCRNAME, addr, regname(addr), v & 0xff, M68K_GETPC);
     ncrregs[addr] = val;
 }
 
@@ -305,7 +305,7 @@ uae_u32 ncr_bget2 (uaecptr addr)
        v &= 0x0f; // revision 0
        break;
     }
-    write_log ("%s read  %04X (%s) = %02X PC=%08X\n", NCRNAME, addr, regname(addr), v, M68K_GETPC);
+    write_log (L"%s read  %04X (%s) = %02X PC=%08X\n", NCRNAME, addr, regname(addr), v, M68K_GETPC);
     if (v2 != v)
        ncrregs[addr] = v2;
     return v;
@@ -324,7 +324,7 @@ static uae_u32 REGPARAM2 ncr_lget (uaecptr addr)
        (ncr_bget2 (addr + 2) << 8) | (ncr_bget2 (addr + 3));
 #if NCR_DEBUG > 0
     if (addr < ROM_VECTOR)
-       write_log ("ncr_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
+       write_log (L"ncr_lget %08X=%08X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -339,7 +339,7 @@ static uae_u32 REGPARAM2 ncr_wget (uaecptr addr)
     v = (ncr_bget2 (addr) << 8) | ncr_bget2 (addr + 1);
 #if NCR_DEBUG > 0
     if (addr < ROM_VECTOR)
-       write_log ("ncr_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
+       write_log (L"ncr_wget %08X=%04X PC=%08X\n", addr, v, M68K_GETPC);
 #endif
     return v;
 }
@@ -368,7 +368,7 @@ static void REGPARAM2 ncr_lput (uaecptr addr, uae_u32 l)
     addr &= board_mask;
 #if NCR_DEBUG > 0
     if (addr < ROM_VECTOR)
-       write_log ("ncr_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
+       write_log (L"ncr_lput %08X=%08X PC=%08X\n", addr, l, M68K_GETPC);
 #endif
     ncr_bput2 (addr, l >> 24);
     ncr_bput2 (addr + 1, l >> 16);
@@ -385,14 +385,14 @@ static void REGPARAM2 ncr_wput (uaecptr addr, uae_u32 w)
     addr &= board_mask;
 #if NCR_DEBUG > 0
     if (addr < ROM_VECTOR)
-       write_log ("ncr_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
+       write_log (L"ncr_wput %04X=%04X PC=%08X\n", addr, w & 65535, M68K_GETPC);
 #endif
     if (addr == 0x44 && !configured) {
        uae_u32 value = (p96ram_start + ((currprefs.gfxmem_size + 0xffffff) & ~0xffffff)) >> 16;
        chipmem_wput (regs.regs[11] + 0x20, value);
        chipmem_wput (regs.regs[11] + 0x28, value);
        map_banks (&ncr_bank, value, BOARD_SIZE >> 16, 0);
-       write_log ("A4091 Z3 autoconfigured at %04X0000\n", value);
+       write_log (L"A4091 Z3 autoconfigured at %04X0000\n", value);
        configured = 1;
        expamem_next();
        return;
@@ -409,7 +409,7 @@ static void REGPARAM2 ncr_bput (uaecptr addr, uae_u32 b)
     b &= 0xff;
     addr &= board_mask;
     if (addr == 0x4c && !configured) {
-       write_log ("A4091 AUTOCONFIG SHUT-UP!\n");
+       write_log (L"A4091 AUTOCONFIG SHUT-UP!\n");
        configured = 1;
        expamem_next();
        return;
@@ -422,7 +422,7 @@ static void REGPARAM2 ncr_bput (uaecptr addr, uae_u32 b)
 static addrbank ncr_bank = {
     ncr_lget, ncr_wget, ncr_bget,
     ncr_lput, ncr_wput, ncr_bput,
-    default_xlate, default_check, NULL, "A4091",
+    default_xlate, default_check, NULL, L"A4091",
     dummy_lgeti, dummy_wgeti, ABFLAG_IO
 };
 
@@ -486,7 +486,7 @@ void ncr_init (void)
        struct romdata *rd = rl->rd;
        z = read_rom (&rd);
        if (z) {
-           write_log ("A4091 BOOT ROM %d.%d\n", rd->ver, rd->rev);
+           write_log (L"A4091 BOOT ROM %d.%d\n", rd->ver, rd->rev);
            rom = (uae_u8*)xmalloc (ROM_SIZE * 4);
            for (i = 0; i < ROM_SIZE; i++) {
                uae_u8 b;
index 8b72f16a34e800032b05fca6cfe5a949d6ba95eb..0e44ac6472765ee44af9444883e882f2000eb0ae 100644 (file)
--- a/newcpu.c
+++ b/newcpu.c
@@ -86,9 +86,9 @@ static int compfn (const void *el1, const void *el2)
     return instrcount[*(const uae_u16 *)el1] < instrcount[*(const uae_u16 *)el2];
 }
 
-static char *icountfilename (void)
+static TCHAR *icountfilename (void)
 {
-    char *name = getenv ("INSNCOUNT");
+    TCHAR *name = getenv ("INSNCOUNT");
     if (name)
        return name;
     return COUNT_INSTRS == 2 ? "frequent.68k" : "insncount";
@@ -100,7 +100,7 @@ void dump_counts (void)
     unsigned long int total;
     int i;
 
-    write_log ("Writing instruction count file...\n");
+    write_log (L"Writing instruction count file...\n");
     for (i = 0; i < 65536; i++) {
        opcodenums[i] = i;
        total += instrcount[i];
@@ -202,7 +202,7 @@ static void build_cpufunctbl (void)
     }
 
     if (tbl == 0) {
-       write_log ("no CPU emulation cores available!");
+       write_log (L"no CPU emulation cores available!");
        abort ();
     }
 
@@ -241,12 +241,12 @@ static void build_cpufunctbl (void)
            opcnt++;
        }
     }
-    write_log ("Building CPU, %d opcodes (%d %d %d)\n",
+    write_log (L"Building CPU, %d opcodes (%d %d %d)\n",
        opcnt, lvl,
        currprefs.cpu_cycle_exact ? -1 : currprefs.cpu_compatible ? 1 : 0, currprefs.address_space_24);
-    write_log ("CPU=%d, FPU=%d, JIT%s=%d.\n",
+    write_log (L"CPU=%d, FPU=%d, JIT%s=%d.\n",
        currprefs.cpu_model, currprefs.fpu_model,
-       currprefs.cachesize ? (currprefs.compfpu ? "=CPU/FPU" : "=CPU") : "",
+       currprefs.cachesize ? (currprefs.compfpu ? L"=CPU/FPU" : L"=CPU") : L"",
        currprefs.cachesize);
 #ifdef JIT
     build_comp ();
@@ -346,8 +346,8 @@ void init_m68k (void)
        memset (instrcount, 0, sizeof instrcount);
        if (f) {
            uae_u32 opcode, count, total;
-           char name[20];
-           write_log ("Reading instruction count file...\n");
+           TCHAR name[20];
+           write_log (L"Reading instruction count file...\n");
            fscanf (f, "Total: %lu\n", &total);
            while (fscanf (f, "%lx: %lu %s\n", &opcode, &count, name) == 3) {
                instrcount[opcode] = count;
@@ -356,31 +356,31 @@ void init_m68k (void)
        }
     }
 #endif
-    write_log ("Building CPU table for configuration: %d", currprefs.cpu_model);
+    write_log (L"Building CPU table for configuration: %d", currprefs.cpu_model);
     regs.address_space_mask = 0xffffffff;
     if (currprefs.cpu_compatible > 0) {
        if (currprefs.address_space_24 && currprefs.cpu_model >= 68030)
            currprefs.address_space_24 = 0;
     }
     if (currprefs.fpu_model > 0)
-       write_log ("/%d", currprefs.fpu_model);
+       write_log (L"/%d", currprefs.fpu_model);
     if (currprefs.cpu_cycle_exact) {
        if (currprefs.cpu_model == 68000)
-           write_log (" prefetch and cycle-exact");
+           write_log (L" prefetch and cycle-exact");
        else
-           write_log (" ~cycle-exact");
+           write_log (L" ~cycle-exact");
     } else if (currprefs.cpu_compatible)
-       write_log (" prefetch");
+       write_log (L" prefetch");
     if (currprefs.address_space_24) {
        regs.address_space_mask = 0x00ffffff;
-       write_log (" 24-bit");
+       write_log (L" 24-bit");
     }
-    write_log ("\n");
+    write_log (L"\n");
 
     read_table68k ();
     do_merges ();
 
-    write_log ("%d CPU functions\n", nr_cpuop_funcs);
+    write_log (L"%d CPU functions\n", nr_cpuop_funcs);
 
     build_cpufunctbl ();
 
@@ -400,7 +400,7 @@ static long int m68kpc_offset;
 #define get_iword_1(o) get_word (regs.pc + (regs.pc_p - regs.pc_oldp) + (o))
 #define get_ilong_1(o) get_long (regs.pc + (regs.pc_p - regs.pc_oldp) + (o))
 
-static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes size, char *buf, uae_u32 *eaddr, int safemode)
+static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes size, TCHAR *buf, uae_u32 *eaddr, int safemode)
 {
     uae_u16 dp;
     uae_s8 disp8;
@@ -409,37 +409,37 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes
     uae_u32 dispreg;
     uaecptr addr = 0;
     uae_s32 offset = 0;
-    char buffer[80];
+    TCHAR buffer[80];
 
     switch (mode){
      case Dreg:
-       sprintf (buffer, "D%d", reg);
+       _stprintf (buffer, L"D%d", reg);
        break;
      case Areg:
-       sprintf (buffer, "A%d", reg);
+       _stprintf (buffer, L"A%d", reg);
        break;
      case Aind:
-       sprintf (buffer, "(A%d)", reg);
+       _stprintf (buffer, L"(A%d)", reg);
        addr = regs.regs[reg + 8];
        break;
      case Aipi:
-       sprintf (buffer, "(A%d)+", reg);
+       _stprintf (buffer, L"(A%d)+", reg);
        addr = regs.regs[reg + 8];
        break;
      case Apdi:
-       sprintf (buffer, "-(A%d)", reg);
+       _stprintf (buffer, L"-(A%d)", reg);
        addr = regs.regs[reg + 8];
        break;
      case Ad16:
        {
-           char offtxt[80];
+           TCHAR offtxt[80];
            disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
            if (disp16 < 0)
-               sprintf (offtxt, "-$%04x", -disp16);
+               _stprintf (offtxt, L"-$%04x", -disp16);
            else
-               sprintf (offtxt, "$%04x", disp16);
+               _stprintf (offtxt, L"$%04x", disp16);
            addr = m68k_areg (&regs, reg) + disp16;
-           sprintf (buffer, "(A%d, %s) == $%08lx", reg, offtxt, (unsigned long)addr);
+           _stprintf (buffer, L"(A%d, %s) == $%08lx", reg, offtxt, (unsigned long)addr);
        }
        break;
      case Ad8r:
@@ -453,8 +453,8 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes
        if (dp & 0x100) {
            uae_s32 outer = 0, disp = 0;
            uae_s32 base = m68k_areg (&regs, reg);
-           char name[10];
-           sprintf (name, "A%d, ", reg);
+           TCHAR name[10];
+           _stprintf (name, L"A%d, ", reg);
            if (dp & 0x80) { base = 0; name[0] = 0; }
            if (dp & 0x40) dispreg = 0;
            if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; }
@@ -469,14 +469,14 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes
            if (dp & 4) base += dispreg;
 
            addr = base + outer;
-           sprintf (buffer, "(%s%c%d.%c*%d+%ld)+%ld == $%08lx", name,
+           _stprintf (buffer, L"(%s%c%d.%c*%d+%ld)+%ld == $%08lx", name,
                    dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W',
                    1 << ((dp >> 9) & 3),
                    disp, outer,
                    (unsigned long)addr);
        } else {
          addr = m68k_areg (&regs, reg) + (uae_s32)((uae_s8)disp8) + dispreg;
-         sprintf (buffer, "(A%d, %c%d.%c*%d, $%02x) == $%08lx", reg,
+         _stprintf (buffer, L"(A%d, %c%d.%c*%d, $%02x) == $%08lx", reg,
               dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W',
               1 << ((dp >> 9) & 3), disp8,
               (unsigned long)addr);
@@ -486,7 +486,7 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes
        addr = m68k_getpc (&regs) + m68kpc_offset;
        disp16 = get_iword_1 (m68kpc_offset); m68kpc_offset += 2;
        addr += (uae_s16)disp16;
-       sprintf (buffer, "(PC,$%04x) == $%08lx", disp16 & 0xffff, (unsigned long)addr);
+       _stprintf (buffer, L"(PC,$%04x) == $%08lx", disp16 & 0xffff, (unsigned long)addr);
        break;
      case PC8r:
        addr = m68k_getpc (&regs) + m68kpc_offset;
@@ -500,8 +500,8 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes
        if (dp & 0x100) {
            uae_s32 outer = 0, disp = 0;
            uae_s32 base = addr;
-           char name[10];
-           sprintf (name, "PC, ");
+           TCHAR name[10];
+           _stprintf (name, L"PC, ");
            if (dp & 0x80) { base = 0; name[0] = 0; }
            if (dp & 0x40) dispreg = 0;
            if ((dp & 0x30) == 0x20) { disp = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset); m68kpc_offset += 2; }
@@ -516,40 +516,40 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes
            if (dp & 4) base += dispreg;
 
            addr = base + outer;
-           sprintf (buffer, "(%s%c%d.%c*%d+%ld)+%ld == $%08lx", name,
+           _stprintf (buffer, L"(%s%c%d.%c*%d+%ld)+%ld == $%08lx", name,
                    dp & 0x8000 ? 'A' : 'D', (int)r, dp & 0x800 ? 'L' : 'W',
                    1 << ((dp >> 9) & 3),
                    disp, outer,
                    (unsigned long)addr);
        } else {
          addr += (uae_s32)((uae_s8)disp8) + dispreg;
-         sprintf (buffer, "(PC, %c%d.%c*%d, $%02x) == $%08lx", dp & 0x8000 ? 'A' : 'D',
+         _stprintf (buffer, L"(PC, %c%d.%c*%d, $%02x) == $%08lx", dp & 0x8000 ? 'A' : 'D',
                (int)r, dp & 0x800 ? 'L' : 'W',  1 << ((dp >> 9) & 3),
                disp8, (unsigned long)addr);
        }
        break;
      case absw:
        addr = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset);
-       sprintf (buffer, "$%08lx", (unsigned long)addr);
+       _stprintf (buffer, L"$%08lx", (unsigned long)addr);
        m68kpc_offset += 2;
        break;
      case absl:
        addr = get_ilong_1 (m68kpc_offset);
-       sprintf (buffer, "$%08lx", (unsigned long)addr);
+       _stprintf (buffer, L"$%08lx", (unsigned long)addr);
        m68kpc_offset += 4;
        break;
      case imm:
        switch (size){
         case sz_byte:
-           sprintf (buffer, "#$%02x", (unsigned int)(get_iword_1 (m68kpc_offset) & 0xff));
+           _stprintf (buffer, L"#$%02x", (unsigned int)(get_iword_1 (m68kpc_offset) & 0xff));
            m68kpc_offset += 2;
            break;
         case sz_word:
-           sprintf (buffer, "#$%04x", (unsigned int)(get_iword_1 (m68kpc_offset) & 0xffff));
+           _stprintf (buffer, L"#$%04x", (unsigned int)(get_iword_1 (m68kpc_offset) & 0xffff));
            m68kpc_offset += 2;
            break;
         case sz_long:
-           sprintf (buffer, "#$%08lx", (unsigned long)(get_ilong_1 (m68kpc_offset)));
+           _stprintf (buffer, L"#$%08lx", (unsigned long)(get_ilong_1 (m68kpc_offset)));
            m68kpc_offset += 4;
            break;
         default:
@@ -559,30 +559,30 @@ static uae_s32 ShowEA (void *f, uae_u16 opcode, int reg, amodes mode, wordsizes
      case imm0:
        offset = (uae_s32)(uae_s8)get_iword_1 (m68kpc_offset);
        m68kpc_offset += 2;
-       sprintf (buffer, "#$%02x", (unsigned int)(offset & 0xff));
+       _stprintf (buffer, L"#$%02x", (unsigned int)(offset & 0xff));
        break;
      case imm1:
        offset = (uae_s32)(uae_s16)get_iword_1 (m68kpc_offset);
        m68kpc_offset += 2;
        buffer[0] = 0;
-       sprintf (buffer, "#$%04x", (unsigned int)(offset & 0xffff));
+       _stprintf (buffer, L"#$%04x", (unsigned int)(offset & 0xffff));
        break;
      case imm2:
        offset = (uae_s32)get_ilong_1 (m68kpc_offset);
        m68kpc_offset += 4;
-       sprintf (buffer, "#$%08lx", (unsigned long)offset);
+       _stprintf (buffer, L"#$%08lx", (unsigned long)offset);
        break;
      case immi:
        offset = (uae_s32)(uae_s8)(reg & 0xff);
-       sprintf (buffer, "#$%08lx", (unsigned long)offset);
+       _stprintf (buffer, L"#$%08lx", (unsigned long)offset);
        break;
      default:
        break;
     }
     if (buf == 0)
-       f_out (f, "%s", buffer);
+       f_out (f, L"%s", buffer);
     else
-       strcat (buf, buffer);
+       _tcscat (buf, buffer);
     if (eaddr)
        *eaddr = addr;
     return offset;
@@ -882,7 +882,7 @@ static void exception_debug (int nr)
 #ifdef DEBUGGER
     if (!exception_debugging)
        return;
-    console_out_f ("Exception %d, PC=%08X\n", nr, m68k_getpc (&regs));
+    console_out_f (L"Exception %d, PC=%08X\n", nr, M68K_GETPC);
 #endif
 }
 
@@ -973,7 +973,7 @@ static void Exception_ce (int nr, struct regstruct *regs, uaecptr oldpc)
        put_word_ce (m68k_areg (regs, 7) + 4, last_fault_for_exception_3);
        put_word_ce (m68k_areg (regs, 7) + 0, mode);
        put_word_ce (m68k_areg (regs, 7) + 2, last_fault_for_exception_3 >> 16);
-       write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (4 * nr));
+       write_log (L"Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (4 * nr));
        goto kludge_me_do;
     }
     m68k_areg (regs, 7) -= 6;
@@ -1065,7 +1065,7 @@ static void Exception_normal (int nr, struct regstruct *regs, uaecptr oldpc)
                m68k_areg (regs, 7) -= 2;
                put_word (m68k_areg (regs, 7), 0xb000 + nr * 4);
            }
-           write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs->vbr + 4*nr));
+           write_log (L"Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs->vbr + 4*nr));
        } else if (nr ==5 || nr == 6 || nr == 7 || nr == 9) {
            m68k_areg (regs, 7) -= 4;
            put_long (m68k_areg (regs, 7), oldpc);
@@ -1097,7 +1097,7 @@ static void Exception_normal (int nr, struct regstruct *regs, uaecptr oldpc)
        put_word (m68k_areg (regs, 7) + 6, last_op_for_exception_3);
        put_word (m68k_areg (regs, 7) + 8, regs->sr);
        put_long (m68k_areg (regs, 7) + 10, last_addr_for_exception_3);
-       write_log ("Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs->vbr + 4*nr));
+       write_log (L"Exception %d (%x) at %x -> %x!\n", nr, oldpc, currpc, get_long (regs->vbr + 4*nr));
        goto kludge_me_do;
     }
     m68k_areg (regs, 7) -= 4;
@@ -1124,7 +1124,7 @@ void REGPARAM2 Exception (int nr, struct regstruct *regs, uaecptr oldpc)
 #if 0
     //if (nr < 24)
     if (nr == 24 + 3)
-       write_log ("exception %d %08X %08X (%04X %04X)\n",
+       write_log (L"exception %d %08X %08X (%04X %04X)\n",
            nr, oldpc, m68k_getpc (regs), intena, intreq);
 #endif
 #ifdef CPUEMU_12
@@ -1140,8 +1140,8 @@ STATIC_INLINE void do_interrupt (int nr, struct regstruct *regs)
     int vector;
 #if 0
     if (nr == 2)
-       write_log (".");
-       //write_log ("irq %d at %x (%04X) ", nr, m68k_getpc (regs), intena & intreq);
+       write_log (L".");
+       //write_log (L"irq %d at %x (%04X) ", nr, m68k_getpc (regs), intena & intreq);
 #endif
     regs->stopped = 0;
     unset_special (regs, SPCFLAG_STOP);
@@ -1204,7 +1204,7 @@ int movec_illg (int regno)
 int m68k_move2c (int regno, uae_u32 *regp)
 {
 #if MOVEC_DEBUG > 0
-    write_log ("move2c %04X <- %08X PC=%x\n", regno, *regp, M68K_GETPC);
+    write_log (L"move2c %04X <- %08X PC=%x\n", regno, *regp, M68K_GETPC);
 #endif
     if (movec_illg (regno)) {
        op_illg (0x4E7B, &regs);
@@ -1260,7 +1260,7 @@ int m68k_move2c (int regno, uae_u32 *regp)
            regs.pcr &= ~(0x40 | 2 | 1);
            regs.pcr |= (*regp) & (0x40 | 2 | 1);
            if (((opcr ^ regs.pcr) & 2) == 2) {
-               write_log ("68060 FPU state: %s\n", regs.pcr & 2 ? "disabled" : "enabled");
+               write_log (L"68060 FPU state: %s\n", regs.pcr & 2 ? "disabled" : "enabled");
                /* flush possible already translated FPU instructions */
                flush_icache (0, 3);
            }
@@ -1277,7 +1277,7 @@ int m68k_move2c (int regno, uae_u32 *regp)
 int m68k_movec2 (int regno, uae_u32 *regp)
 {
 #if MOVEC_DEBUG > 0
-    write_log ("movec2 %04X PC=%x\n", regno, M68K_GETPC);
+    write_log (L"movec2 %04X PC=%x\n", regno, M68K_GETPC);
 #endif
     if (movec_illg (regno)) {
        op_illg (0x4E7A, &regs);
@@ -1324,7 +1324,7 @@ int m68k_movec2 (int regno, uae_u32 *regp)
        }
     }
 #if MOVEC_DEBUG > 0
-    write_log ("-> %08X\n", *regp);
+    write_log (L"-> %08X\n", *regp);
 #endif
     return 1;
 }
@@ -1706,7 +1706,7 @@ unsigned long REGPARAM2 op_illg (uae_u32 opcode, struct regstruct *regs)
 
     if ((opcode & 0xF000) == 0xF000) {
        if (warned < 20) {
-           write_log ("B-Trap %x at %x (%p)\n", opcode, pc, regs->pc_p);
+           write_log (L"B-Trap %x at %x (%p)\n", opcode, pc, regs->pc_p);
            warned++;
        }
        Exception (0xB, regs, 0);
@@ -1714,14 +1714,14 @@ unsigned long REGPARAM2 op_illg (uae_u32 opcode, struct regstruct *regs)
     }
     if ((opcode & 0xF000) == 0xA000) {
        if (warned < 20) {
-           write_log ("A-Trap %x at %x (%p)\n", opcode, pc, regs->pc_p);
+           write_log (L"A-Trap %x at %x (%p)\n", opcode, pc, regs->pc_p);
            warned++;
        }
        Exception (0xA, regs, 0);
        return 4;
     }
     if (warned < 20) {
-       write_log ("Illegal instruction: %04x at %08X -> %08X\n", opcode, pc, get_long (regs->vbr + 0x10));
+       write_log (L"Illegal instruction: %04x at %08X -> %08X\n", opcode, pc, get_long (regs->vbr + 0x10));
        warned++;
     }
 
@@ -1731,21 +1731,21 @@ unsigned long REGPARAM2 op_illg (uae_u32 opcode, struct regstruct *regs)
 
 #ifdef CPUEMU_0
 
-static char *mmu30regs[] = { "TCR", "", "SRP", "CRP", "", "", "", "" };
+static TCHAR *mmu30regs[] = { L"TCR", L"", L"SRP", L"CRP", L"", L"", L"", L"" };
 
 static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
 {
     int preg = (next >> 10) & 31;
     int rw = (next >> 9) & 1;
     int fd = (next >> 8) & 1;
-    char *reg = NULL;
+    TCHAR *reg = NULL;
     uae_u32 otc = tc_030;
     int siz;
 
     switch (preg)
     {
     case 0x10: // TC
-       reg = "TC";
+       reg = L"TC";
        siz = 4;
        if (rw)
            put_long (extra, tc_030);
@@ -1753,7 +1753,7 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
            tc_030 = get_long (extra);
     break;
     case 0x12: // SRP
-       reg = "SRP";
+       reg = L"SRP";
        siz = 8;
        if (rw) {
            put_long (extra, srp_030 >> 32);
@@ -1764,7 +1764,7 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
        }
     break;
     case 0x13: // CRP
-       reg = "CRP";
+       reg = L"CRP";
        siz = 8;
        if (rw) {
            put_long (extra, crp_030 >> 32);
@@ -1775,7 +1775,7 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
        }
     break;
     case 0x18: // MMUSR
-       reg = "MMUSR";
+       reg = L"MMUSR";
        siz = 2;
        if (rw)
            put_word (extra, mmusr_030);
@@ -1783,7 +1783,7 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
            mmusr_030 = get_word (extra);
     break;
     case 0x02: // TT0
-       reg = "TT0";
+       reg = L"TT0";
        siz = 4;
        if (rw)
            put_long (extra, tt0_030);
@@ -1791,7 +1791,7 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
            tt0_030 = get_long (extra);
     break;
     case 0x03: // TT1
-       reg = "TT1";
+       reg = L"TT1";
        siz = 4;
        if (rw)
            put_long (extra, tt1_030);
@@ -1811,20 +1811,20 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
            uae_u32 val2 = get_long (extra);
            val = get_long (extra + 4);
            if (rw)
-               write_log ("PMOVE %s,%08X%08X", reg, val2, val);
+               write_log (L"PMOVE %s,%08X%08X", reg, val2, val);
            else
-               write_log ("PMOVE %08X%08X,%s", val2, val, reg);
+               write_log (L"PMOVE %08X%08X,%s", val2, val, reg);
        } else {
            if (siz == 4)
                val = get_long (extra);
            else
                val = get_word (extra);
            if (rw)
-               write_log ("PMOVE %s,%08X", reg, val);
+               write_log (L"PMOVE %s,%08X", reg, val);
            else
-               write_log ("PMOVE %08X,%s", val, reg);
+               write_log (L"PMOVE %08X,%s", val, reg);
        }
-       write_log (" PC=%08X\n", pc);
+       write_log (L" PC=%08X\n", pc);
     }
 #endif
     if (currprefs.cs_mbdmac == 1 && currprefs.mbresmem_low_size > 0) {
@@ -1837,12 +1837,12 @@ static void mmu_op30_pmove (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
 static void mmu_op30_ptest (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
 {
 #if MMUOP_DEBUG > 0
-    char tmp[10];
+    TCHAR tmp[10];
 
     tmp[0] = 0;
     if ((next >> 8) & 1)
-       sprintf (tmp, ",A%d", (next >> 4) & 15);
-    write_log ("PTEST%c %02X,%08X,#%X%s PC=%08X\n",
+       _stprintf (tmp, L",A%d", (next >> 4) & 15);
+    write_log (L"PTEST%c %02X,%08X,#%X%s PC=%08X\n",
               ((next >> 9) & 1) ? 'W' : 'R', (next & 15), extra, (next >> 10) & 7, tmp, pc);
 #endif
     mmusr_030 = 0;
@@ -1851,7 +1851,7 @@ static void mmu_op30_ptest (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr ex
 static void mmu_op30_pflush (uaecptr pc, uae_u32 opcode, uae_u16 next, uaecptr extra)
 {
 #if MMUOP_DEBUG > 0
-    write_log ("PFLUSH PC=%08X\n", pc);
+    write_log (L"PFLUSH PC=%08X\n", pc);
 #endif
 }
 
@@ -1873,7 +1873,7 @@ void mmu_op30 (uaecptr pc, uae_u32 opcode, struct regstruct *regs, int isnext, u
        m68k_setpc (regs, m68k_getpc (regs) + 2);
     } else {
 #if MMUOP_DEBUG > 0
-       write_log ("MMU030: %04x PC=%08x\n", opcode, m68k_getpc (regs));
+       write_log (L"MMU030: %04x PC=%08x\n", opcode, m68k_getpc (regs));
 #endif
     }
     return;
@@ -1882,7 +1882,7 @@ void mmu_op30 (uaecptr pc, uae_u32 opcode, struct regstruct *regs, int isnext, u
 void mmu_op (uae_u32 opcode, struct regstruct *regs, uae_u32 extra)
 {
 #if MMUOP_DEBUG > 1
-    write_log ("mmu_op %04X PC=%08X\n", opcode, m68k_getpc (regs));
+    write_log (L"mmu_op %04X PC=%08X\n", opcode, m68k_getpc (regs));
 #endif
     if (currprefs.cpu_model) {
        mmu_op_real (opcode, extra);
@@ -1892,14 +1892,14 @@ void mmu_op (uae_u32 opcode, struct regstruct *regs, uae_u32 extra)
        /* PFLUSH */
        regs->mmusr = 0;
 #if MMUOP_DEBUG > 0
-       write_log ("PFLUSH\n");
+       write_log (L"PFLUSH\n");
 #endif
        return;
     } else if ((opcode & 0x0FD8) == 0x548) {
        if (currprefs.cpu_model < 68060) { /* PTEST not in 68060 */
            /* PTEST */
 #if MMUOP_DEBUG > 0
-           write_log ("PTEST\n");
+           write_log (L"PTEST\n");
 #endif
            return;
        }
@@ -1907,13 +1907,13 @@ void mmu_op (uae_u32 opcode, struct regstruct *regs, uae_u32 extra)
        /* PLPA */
        if (currprefs.cpu_model == 68060) {
 #if MMUOP_DEBUG > 0
-           write_log ("PLPA\n");
+           write_log (L"PLPA\n");
 #endif
            return;
        }
     }
 #if MMUOP_DEBUG > 0
-    write_log ("Unknown MMU OP %04X\n", opcode);
+    write_log (L"Unknown MMU OP %04X\n", opcode);
 #endif
     m68k_setpc (regs, m68k_getpc (regs) - 2);
     op_illg (opcode, regs);
@@ -1980,7 +1980,7 @@ STATIC_INLINE int do_specialties (int cycles, struct regstruct *regs)
     #endif
     if ((regs->spcflags & SPCFLAG_ACTION_REPLAY) && action_replay_flag != ACTION_REPLAY_INACTIVE) {
        /*if (action_replay_flag == ACTION_REPLAY_ACTIVE && !is_ar_pc_in_rom ())*/
-       /*      write_log ("PC:%p\n", m68k_getpc ());*/
+       /*      write_log (L"PC:%p\n", m68k_getpc ());*/
 
        if (action_replay_flag == ACTION_REPLAY_ACTIVATE || action_replay_flag == ACTION_REPLAY_DORESET)
            action_replay_enter ();
@@ -1989,7 +1989,7 @@ STATIC_INLINE int do_specialties (int cycles, struct regstruct *regs)
            unset_special (regs, SPCFLAG_ACTION_REPLAY);
        }
        if (action_replay_flag == ACTION_REPLAY_WAIT_PC) {
-           /*write_log ("Waiting for PC: %p, current PC= %p\n", wait_for_pc, m68k_getpc ());*/
+           /*write_log (L"Waiting for PC: %p, current PC= %p\n", wait_for_pc, m68k_getpc ());*/
            if (m68k_getpc (regs) == wait_for_pc) {
                action_replay_flag = ACTION_REPLAY_ACTIVATE; /* Activate after next instruction. */
            }
@@ -2101,15 +2101,15 @@ static uae_u32 cd32nextpc, cd32request;
 static void out_cd32io2 (void)
 {
     uae_u32 request = cd32request;
-    write_log ("%08x returned\n", request);
-    //write_log ("ACTUAL=%d ERROR=%d\n", get_long (request + 32), get_byte (request + 31));
+    write_log (L"%08x returned\n", request);
+    //write_log (L"ACTUAL=%d ERROR=%d\n", get_long (request + 32), get_byte (request + 31));
     cd32nextpc = 0;
     cd32request = 0;
 }
 
 static void out_cd32io (uae_u32 pc)
 {
-    char out[100];
+    TCHAR out[100];
     int ioreq = 0;
     uae_u32 request = m68k_areg (&regs, 1);
 
@@ -2122,30 +2122,30 @@ static void out_cd32io (uae_u32 pc)
     {
        case 0xe57cc0:
        case 0xf04c34:
-       sprintf (out, "opendevice");
+       _stprintf (out, "opendevice");
        break;
        case 0xe57ce6:
        case 0xf04c56:
-       sprintf (out, "closedevice");
+       _stprintf (out, "closedevice");
        break;
        case 0xe57e44:
        case 0xf04f2c:
-       sprintf (out, "beginio");
+       _stprintf (out, "beginio");
        ioreq = 1;
        break;
        case 0xe57ef2:
        case 0xf0500e:
-       sprintf (out, "abortio");
+       _stprintf (out, "abortio");
        ioreq = -1;
        break;
     }
     if (out[0] == 0)
        return;
     if (cd32request)
-       write_log ("old request still not returned!\n");
+       write_log (L"old request still not returned!\n");
     cd32request = request;
     cd32nextpc = get_long (m68k_areg (&regs, 7));
-    write_log ("%s A1=%08X\n", out, request);
+    write_log (L"%s A1=%08X\n", out, request);
     if (ioreq) {
        static int cnt = 0;
        int cmd = get_word (request + 28);
@@ -2156,7 +2156,7 @@ static void out_cd32io (uae_u32 pc)
                activate_debugger ();
        }
 #endif
-       write_log ("CMD=%d DATA=%08X LEN=%d %OFF=%d PC=%x\n",
+       write_log (L"CMD=%d DATA=%08X LEN=%d %OFF=%d PC=%x\n",
            cmd, get_long (request + 40),
            get_long (request + 36), get_long (request + 44), M68K_GETPC);
     }
@@ -2194,11 +2194,11 @@ static void m68k_run_1 (void)
 #if 0
        int pc = m68k_getpc ();
        if (pc == 0xdff002)
-           write_log ("hip\n");
+           write_log (L"hip\n");
        if (pc != pcs[0] && (pc < 0xd00000 || pc > 0x1000000)) {
            memmove (pcs + 1, pcs, 998 * 4);
            pcs[0] = pc;
-           //write_log ("%08X-%04X ", pc, opcode);
+           //write_log (L"%08X-%04X ", pc, opcode);
        }
 #endif
        do_cycles (cpu_cycles);
@@ -2440,7 +2440,7 @@ void m68k_go (int may_quit)
     int hardboot = 1;
 
     if (in_m68k_go || !may_quit) {
-       write_log ("Bug! m68k_go is not reentrant.\n");
+       write_log (L"Bug! m68k_go is not reentrant.\n");
        abort ();
     }
 
@@ -2467,7 +2467,7 @@ void m68k_go (int may_quit)
            m68k_reset (hardreset);
            if (hardreset) {
                memory_hardreset ();
-               write_log ("hardreset, memory cleared\n");
+               write_log (L"hardreset, memory cleared\n");
            }
 #ifdef SAVESTATE
            /* We may have been restoring state, but we're done now.  */
@@ -2501,7 +2501,7 @@ void m68k_go (int may_quit)
                exception2_handle (regs.panic_pc, regs.panic_addr);
            if (regs.panic) {
                /* system is very badly confused */
-               write_log ("double bus error or corrupted stack, forcing reboot..\n");
+               write_log (L"double bus error or corrupted stack, forcing reboot..\n");
                regs.panic = 0;
                uae_reset (1);
            }
@@ -2564,25 +2564,25 @@ static void m68k_verify (uaecptr addr, uaecptr *nextpc)
 }
 #endif
 
-static const char* ccnames[] =
-{ "T ","F ","HI","LS","CC","CS","NE","EQ",
-  "VC","VS","PL","MI","GE","LT","GT","LE" };
+static const TCHAR *ccnames[] =
+{ L"T ",L"F ",L"HI",L"LS",L"CC",L"CS",L"NE",L"EQ",
+  L"VC",L"VS",L"PL",L"MI",L"GE",L"LT",L"GT",L"LE" };
 
-static void addmovemreg (char *out, int *prevreg, int *lastreg, int *first, int reg)
+static void addmovemreg (TCHAR *out, int *prevreg, int *lastreg, int *first, int reg)
 {
-    char *p = out + strlen (out);
+    TCHAR *p = out + _tcslen (out);
     if (*prevreg < 0) {
        *prevreg = reg;
        *lastreg = reg;
        return;
     }
     if ((*prevreg) + 1 != reg || (reg & 8) != ((*prevreg & 8))) {
-       sprintf (p, "%s%c%d", (*first) ? "" : "/", (*lastreg) < 8 ? 'D' : 'A', (*lastreg) & 7);
-       p = p + strlen (p);
+       _stprintf (p, L"%s%c%d", (*first) ? L"" : L"/", (*lastreg) < 8 ? 'D' : 'A', (*lastreg) & 7);
+       p = p + _tcslen (p);
        if ((*lastreg) + 2 == reg) {
-           sprintf (p, "/%c%d", (*prevreg) < 8 ? 'D' : 'A', (*prevreg) & 7);
+           _stprintf (p, L"/%c%d", (*prevreg) < 8 ? 'D' : 'A', (*prevreg) & 7);
        } else if ((*lastreg) != (*prevreg)) {
-           sprintf (p, "-%c%d", (*prevreg) < 8 ? 'D' : 'A', (*prevreg) & 7);
+           _stprintf (p, L"-%c%d", (*prevreg) < 8 ? 'D' : 'A', (*prevreg) & 7);
        }
        *lastreg = reg;
        *first = 0;
@@ -2590,7 +2590,7 @@ static void addmovemreg (char *out, int *prevreg, int *lastreg, int *first, int
     *prevreg = reg;
 }
 
-static void movemout (char *out, uae_u16 mask, int mode)
+static void movemout (TCHAR *out, uae_u16 mask, int mode)
 {
     unsigned int dmask, amask;
     int prevreg = -1, lastreg = -1, first = 1;
@@ -2615,7 +2615,7 @@ static void movemout (char *out, uae_u16 mask, int mode)
     addmovemreg (out, &prevreg, &lastreg, &first, -1);
 }
 
-static void disasm_size (char *instrname, struct instr *dp)
+static void disasm_size (TCHAR *instrname, struct instr *dp)
 {
 #if 0
     int i, size;
@@ -2635,21 +2635,21 @@ static void disasm_size (char *instrname, struct instr *dp)
     switch (dp->size)
     {
        case sz_byte:
-           strcat (instrname, ".B ");
+           _tcscat (instrname, L".B ");
        break;
        case sz_word:
-           strcat (instrname, ".W ");
+           _tcscat (instrname, L".W ");
        break;
        case sz_long:
-           strcat (instrname, ".L ");
+           _tcscat (instrname, L".L ");
        break;
        default:
-           strcat (instrname, "   ");
+           _tcscat (instrname, L"   ");
        break;
     }
 }
 
-void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode)
+void m68k_disasm_2 (TCHAR *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr, int safemode)
 {
     uaecptr newpc = 0;
     m68kpc_offset = addr - m68k_getpc (&regs);
@@ -2659,7 +2659,7 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
     if (!table68k)
        return;
     while (cnt-- > 0) {
-       char instrname[100], *ccpt;
+       TCHAR instrname[100], *ccpt;
        int i;
        uae_u32 opcode;
        struct mnemolookup *lookup;
@@ -2675,17 +2675,17 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
        for (lookup = lookuptab;lookup->mnemo != dp->mnemo; lookup++)
            ;
 
-       buf = buf_out (buf, &bufsize, "%08lX ", m68k_getpc (&regs) + m68kpc_offset);
+       buf = buf_out (buf, &bufsize, L"%08lX ", m68k_getpc (&regs) + m68kpc_offset);
 
        m68kpc_offset += 2;
 
        if (lookup->friendlyname)
-           strcpy (instrname, lookup->friendlyname);
+           _tcscpy (instrname, lookup->friendlyname);
        else
-           strcpy (instrname, lookup->name);
-       ccpt = strstr (instrname, "cc");
+           _tcscpy (instrname, lookup->name);
+       ccpt = _tcsstr (instrname, L"cc");
        if (ccpt != 0) {
-           strncpy (ccpt, ccnames[dp->cc], 2);
+           _tcsncpy (ccpt, ccnames[dp->cc], 2);
        }
        disasm_size (instrname, dp);
 
@@ -2693,35 +2693,35 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
            uae_u16 imm = get_iword_1 (m68kpc_offset);
            uae_u16 creg = imm & 0x0fff;
            uae_u16 r = imm >> 12;
-           char regs[16], *cname = "?";
+           TCHAR regs[16], *cname = L"?";
            int i;
            for (i = 0; m2cregs[i].regname; i++) {
                if (m2cregs[i].regno == creg)
                    break;
            }
-           sprintf (regs, "%c%d", r >= 8 ? 'A' : 'D', r >= 8 ? r - 8 : r);
+           _stprintf (regs, L"%c%d", r >= 8 ? 'A' : 'D', r >= 8 ? r - 8 : r);
            if (m2cregs[i].regname)
                cname = m2cregs[i].regname;
            if (lookup->mnemo == i_MOVE2C) {
-               strcat (instrname, regs);
-               strcat (instrname, ",");
-               strcat (instrname, cname);
+               _tcscat (instrname, regs);
+               _tcscat (instrname, L",");
+               _tcscat (instrname, cname);
            } else {
-               strcat (instrname, cname);
-               strcat (instrname, ",");
-               strcat (instrname, regs);
+               _tcscat (instrname, cname);
+               _tcscat (instrname, L",");
+               _tcscat (instrname, regs);
            }
            m68kpc_offset += 2;
        } else if (lookup->mnemo == i_MVMEL) {
            newpc = m68k_getpc (&regs) + m68kpc_offset;
            m68kpc_offset += 2;
            newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode);
-           strcat (instrname, ",");
+           _tcscat (instrname, L",");
            movemout (instrname, get_iword_1 (m68kpc_offset - 2), dp->dmode);
        } else if (lookup->mnemo == i_MVMLE) {
            m68kpc_offset += 2;
            movemout (instrname, get_iword_1 (m68kpc_offset - 2), dp->dmode);
-           strcat (instrname, ",");
+           _tcscat (instrname, L",");
            newpc = m68k_getpc (&regs) + m68kpc_offset;
            newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode);
        } else {
@@ -2730,7 +2730,7 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
                newpc += ShowEA (0, opcode, dp->sreg, dp->smode, dp->size, instrname, seaddr, safemode);
            }
            if (dp->suse && dp->duse)
-               strcat (instrname, ",");
+               _tcscat (instrname, L",");
            if (dp->duse) {
                newpc = m68k_getpc (&regs) + m68kpc_offset;
                newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, deaddr, safemode);
@@ -2738,10 +2738,10 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
        }
 
        for (i = 0; i < (m68kpc_offset - oldpc) / 2; i++) {
-           buf = buf_out (buf, &bufsize, "%04x ", get_iword_1 (oldpc + i * 2));
+           buf = buf_out (buf, &bufsize, L"%04x ", get_iword_1 (oldpc + i * 2));
        }
        while (i++ < 5)
-           buf = buf_out (buf, &bufsize, "     ");
+           buf = buf_out (buf, &bufsize, L"     ");
 
        buf = buf_out (buf, &bufsize, instrname);
 
@@ -2749,15 +2749,15 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
            if (deaddr)
                *deaddr = newpc;
            if (cctrue (&regs.ccrflags, dp->cc))
-               buf = buf_out (buf, &bufsize, " == $%08lX (T)", newpc);
+               buf = buf_out (buf, &bufsize, L" == $%08lX (T)", newpc);
            else
-               buf = buf_out (buf, &bufsize, " == $%08lX (F)", newpc);
+               buf = buf_out (buf, &bufsize, L" == $%08lX (F)", newpc);
        } else if ((opcode & 0xff00) == 0x6100) { /* BSR */
            if (deaddr)
                *deaddr = newpc;
-           buf = buf_out (buf, &bufsize, " == $%08lX", newpc);
+           buf = buf_out (buf, &bufsize, L" == $%08lX", newpc);
        }
-       buf = buf_out (buf, &bufsize, "\n");
+       buf = buf_out (buf, &bufsize, L"\n");
     }
     if (nextpc)
        *nextpc = m68k_getpc (&regs) + m68kpc_offset;
@@ -2765,34 +2765,34 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
 
 void m68k_disasm_ea (void *f, uaecptr addr, uaecptr *nextpc, int cnt, uae_u32 *seaddr, uae_u32 *deaddr)
 {
-    char *buf;
+    TCHAR *buf;
 
-    buf = malloc ((MAX_LINEWIDTH + 1) * cnt);
+    buf = malloc ((MAX_LINEWIDTH + 1) * cnt * sizeof (TCHAR));
     if (!buf)
        return;
     m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, seaddr, deaddr, 1);
-    f_out (f, "%s", buf);
-    free (buf);
+    f_out (f, L"%s", buf);
+    xfree (buf);
 }
 void m68k_disasm (void *f, uaecptr addr, uaecptr *nextpc, int cnt)
 {
-    char *buf;
+    TCHAR *buf;
 
-    buf = malloc ((MAX_LINEWIDTH + 1) * cnt);
+    buf = malloc ((MAX_LINEWIDTH + 1) * cnt * sizeof (TCHAR));
     if (!buf)
        return;
     m68k_disasm_2 (buf, (MAX_LINEWIDTH + 1) * cnt, addr, nextpc, cnt, NULL, NULL, 0);
-    f_out (f, "%s", buf);
-    free (buf);
+    f_out (f, L"%s", buf);
+    xfree (buf);
 }
 
 /*************************************************************
  Disasm the m68kcode at the given address into instrname
  and instrcode
 *************************************************************/
-void sm68k_disasm (char *instrname, char *instrcode, uaecptr addr, uaecptr *nextpc)
+void sm68k_disasm (TCHAR *instrname, TCHAR *instrcode, uaecptr addr, uaecptr *nextpc)
 {
-    char *ccpt;
+    TCHAR *ccpt;
     uae_u32 opcode;
     struct mnemolookup *lookup;
     struct instr *dp;
@@ -2812,16 +2812,16 @@ void sm68k_disasm (char *instrname, char *instrcode, uaecptr addr, uaecptr *next
 
     m68kpc_offset += 2;
 
-    strcpy (instrname, lookup->name);
-    ccpt = strstr (instrname, "cc");
+    _tcscpy (instrname, lookup->name);
+    ccpt = _tcsstr (instrname, L"cc");
     if (ccpt != 0) {
-       strncpy (ccpt, ccnames[dp->cc], 2);
+       _tcsncpy (ccpt, ccnames[dp->cc], 2);
     }
     switch (dp->size){
-       case sz_byte: strcat (instrname, ".B "); break;
-       case sz_word: strcat (instrname, ".W "); break;
-       case sz_long: strcat (instrname, ".L "); break;
-       default: strcat (instrname, "   "); break;
+       case sz_byte: _tcscat (instrname, L".B "); break;
+       case sz_word: _tcscat (instrname, L".W "); break;
+       case sz_long: _tcscat (instrname, L".L "); break;
+       default: _tcscat (instrname, L"   "); break;
     }
 
     if (dp->suse) {
@@ -2829,7 +2829,7 @@ void sm68k_disasm (char *instrname, char *instrcode, uaecptr addr, uaecptr *next
        newpc += ShowEA (0, opcode, dp->sreg, dp->smode, dp->size, instrname, NULL, 0);
     }
     if (dp->suse && dp->duse)
-       strcat (instrname, ",");
+       _tcscat (instrname, L",");
     if (dp->duse) {
        newpc = m68k_getpc (&regs) + m68kpc_offset;
        newpc += ShowEA (0, opcode, dp->dreg, dp->dmode, dp->size, instrname, NULL, 0);
@@ -2840,8 +2840,8 @@ void sm68k_disasm (char *instrname, char *instrcode, uaecptr addr, uaecptr *next
        int i;
        for (i = 0; i < (m68kpc_offset - oldpc) / 2; i++)
        {
-           sprintf (instrcode, "%04x ", get_iword_1 (oldpc + i * 2));
-           instrcode += strlen (instrcode);
+           _stprintf (instrcode, L"%04x ", get_iword_1 (oldpc + i * 2));
+           instrcode += _tcslen (instrcode);
        }
     }
 
@@ -2850,24 +2850,24 @@ void sm68k_disasm (char *instrname, char *instrcode, uaecptr addr, uaecptr *next
 }
 
 struct cpum2c m2cregs[] = {
-    0, "SFC",
-    1, "DFC",
-    2, "CACR",
-    3, "TC",
-    4, "ITT0",
-    5, "ITT1",
-    6, "DTT0",
-    7, "DTT1",
-    8, "BUSC",
-    0x800, "USP",
-    0x801, "VBR",
-    0x802, "CAAR",
-    0x803, "MSP",
-    0x804, "ISP",
-    0x805, "MMUS",
-    0x806, "URP",
-    0x807, "SRP",
-    0x808, "PCR",
+    0, L"SFC",
+    1, L"DFC",
+    2, L"CACR",
+    3, L"TC",
+    4, L"ITT0",
+    5, L"ITT1",
+    6, L"DTT0",
+    7, L"DTT1",
+    8, L"BUSC",
+    0x800, L"USP",
+    0x801, L"VBR",
+    0x802, L"CAAR",
+    0x803, L"MSP",
+    0x804, L"ISP",
+    0x805, L"MMUS",
+    0x806, L"URP",
+    0x807, L"SRP",
+    0x808, L"PCR",
     -1, NULL
 };
 
@@ -2925,31 +2925,31 @@ void m68k_dumpstate (void *f, uaecptr *nextpc)
     int i, j;
 
     for (i = 0; i < 8; i++){
-       f_out (f, "  D%d %08lX ", i, m68k_dreg (&regs, i));
-       if ((i & 3) == 3) f_out (f, "\n");
+       f_out (f, L"  LD%d %08lX ", i, m68k_dreg (&regs, i));
+       if ((i & 3) == 3) f_out (f, L"\n");
     }
     for (i = 0; i < 8; i++){
-       f_out (f, "  A%d %08lX ", i, m68k_areg (&regs, i));
-       if ((i & 3) == 3) f_out (f, "\n");
+       f_out (f, L"  LA%d %08lX ", i, m68k_areg (&regs, i));
+       if ((i & 3) == 3) f_out (f, L"\n");
     }
     if (regs.s == 0) regs.usp = m68k_areg (&regs, 7);
     if (regs.s && regs.m) regs.msp = m68k_areg (&regs, 7);
     if (regs.s && regs.m == 0) regs.isp = m68k_areg (&regs, 7);
     j = 2;
-    f_out (f, "USP  %08X ISP  %08X ", regs.usp, regs.isp);
+    f_out (f, L"USP  %08X ISP  %08X ", regs.usp, regs.isp);
     for (i = 0; m2cregs[i].regno>= 0; i++) {
        if (!movec_illg (m2cregs[i].regno)) {
-           if (!strcmp (m2cregs[i].regname, "USP") || !strcmp (m2cregs[i].regname, "ISP"))
+           if (!_tcscmp (m2cregs[i].regname, L"USP") || !_tcscmp (m2cregs[i].regname, L"ISP"))
                continue;
            if (j > 0 && (j % 4) == 0)
-               f_out (f, "\n");
-           f_out (f, "%-4s %08X ", m2cregs[i].regname, val_move2c (m2cregs[i].regno));
+               f_out (f, L"\n");
+           f_out (f, L"%-4s %08X ", m2cregs[i].regname, val_move2c (m2cregs[i].regno));
            j++;
        }
     }
     if (j > 0)
-       f_out (f, "\n");
-    f_out (f, "T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d STP=%d\n",
+       f_out (f, L"\n");
+    f_out (f, L"T=%d%d S=%d M=%d X=%d N=%d Z=%d V=%d C=%d IMASK=%d STP=%d\n",
        regs.t1, regs.t0, regs.s, regs.m,
        GET_XFLG (&regs.ccrflags), GET_NFLG (&regs.ccrflags), GET_ZFLG (&regs.ccrflags),
        GET_VFLG (&regs.ccrflags), GET_CFLG (&regs.ccrflags),
@@ -2958,11 +2958,12 @@ void m68k_dumpstate (void *f, uaecptr *nextpc)
     if (currprefs.fpu_model) {
        uae_u32 fpsr;
        for (i = 0; i < 8; i++){
-           f_out (f, "FP%d: %g ", i, regs.fp[i]);
-           if ((i & 3) == 3) f_out (f, "\n");
+           f_out (f, L"FP%d: %g ", i, regs.fp[i]);
+           if ((i & 3) == 3)
+               f_out (f, L"\n");
        }
        fpsr = get_fpsr ();
-       f_out (f, "N=%d Z=%d I=%d NAN=%d\n",
+       f_out (f, L"N=%d Z=%d I=%d NAN=%d\n",
                (fpsr & 0x8000000) != 0,
                (fpsr & 0x4000000) != 0,
                (fpsr & 0x2000000) != 0,
@@ -2976,12 +2977,12 @@ void m68k_dumpstate (void *f, uaecptr *nextpc)
        for (lookup1 = lookuptab; lookup1->mnemo != dp->mnemo; lookup1++);
        dp = table68k + regs.ir;
        for (lookup2 = lookuptab; lookup2->mnemo != dp->mnemo; lookup2++);
-       f_out (f, "Prefetch %04x (%s) %04x (%s)\n", regs.irc, lookup1->name, regs.ir, lookup2->name);
+       f_out (f, L"Prefetch %04x (%s) %04x (%s)\n", regs.irc, lookup1->name, regs.ir, lookup2->name);
     }
 
     m68k_disasm (f, m68k_getpc (&regs), nextpc, 1);
     if (nextpc)
-       f_out (f, "Next PC: %08lx\n", *nextpc);
+       f_out (f, L"Next PC: %08lx\n", *nextpc);
 }
 
 #ifdef SAVESTATE
@@ -3061,7 +3062,7 @@ uae_u8 *restore_cpu (uae_u8 *src)
        if (khz > 0 && khz < 800000)
            currprefs.m68k_speed = changed_prefs.m68k_speed = 0;
     }
-    write_log ("CPU %d%s%03d, PC=%08X\n",
+    write_log (L"CPU %d%s%03d, PC=%08X\n",
        model / 1000, flags & 1 ? "EC" : "", model % 1000, regs.pc);
 
     return src;
@@ -3163,7 +3164,7 @@ void exception3i (uae_u32 opcode, uaecptr addr, uaecptr fault)
 
 void exception2 (uaecptr addr, uaecptr fault)
 {
-    write_log ("delayed exception2!\n");
+    write_log (L"delayed exception2!\n");
     regs.panic_pc = m68k_getpc (&regs);
     regs.panic_addr = addr;
     regs.panic = 2;
@@ -3193,7 +3194,7 @@ void cpureset (void)
            customreset (0);
            return;
        }
-       write_log ("M68K RESET PC=%x, rebooting..\n", pc);
+       write_log (L"M68K RESET PC=%x, rebooting..\n", pc);
        customreset (0);
        m68k_setpc (&regs, ksboot);
        return;
@@ -3203,14 +3204,14 @@ void cpureset (void)
     if ((ins & ~7) == 0x4ed0) {
        int reg = ins & 7;
        uae_u32 addr = m68k_areg (&regs, reg);
-       write_log ("reset/jmp (ax) combination emulated -> %x\n", addr);
+       write_log (L"reset/jmp (ax) combination emulated -> %x\n", addr);
        customreset (0);
        if (addr < 0x80000)
            addr += 0xf80000;
        m68k_setpc (&regs, addr - 2);
        return;
     }
-    write_log ("M68K RESET PC=%x, rebooting..\n", pc);
+    write_log (L"M68K RESET PC=%x, rebooting..\n", pc);
     customreset (0);
     m68k_setpc (&regs, ksboot);
 }
@@ -3295,7 +3296,7 @@ STATIC_INLINE int getDivu68kCycles_2 (uae_u32 dividend, uae_u16 divisor)
 int getDivu68kCycles (uae_u32 dividend, uae_u16 divisor)
 {
     int v = getDivu68kCycles_2 (dividend, divisor) - 4;
-//    write_log ("U%d ", v);
+//    write_log (L"U%d ", v);
     return v;
 }
 
@@ -3347,6 +3348,6 @@ STATIC_INLINE int getDivs68kCycles_2 (uae_s32 dividend, uae_s16 divisor)
 int getDivs68kCycles (uae_s32 dividend, uae_s16 divisor)
 {
     int v = getDivs68kCycles_2 (dividend, divisor) - 4;
-//    write_log ("S%d ", v);
+//    write_log (L"S%d ", v);
     return v;
 }
index 090c973074e94dc1eaae17ab2ffd9046d9e98560..0127f3962acefc759d3c0cdb6241fe2e7da5ec69 100644 (file)
 static long samples, playchannel, intcount;
 static int record_enabled;
 int ahi_on;
-static char *sndptrmax, soundneutral, sndptr;
+static TCHAR *sndptrmax, soundneutral, sndptr;
 
 static LPSTR lpData,sndptrout;
 extern uae_u32 chipmem_mask;
 unsigned int *sndbufrecpt;
-static char *ahisndbuffer, *sndrecbuffer;
+static TCHAR *ahisndbuffer, *sndrecbuffer;
 static int ahisndbufsize, *ahisndbufpt, ahitweak;;
 int ahi_pollrate = 40;
 
@@ -153,9 +153,9 @@ void ahi_close_sound (void)
     if (lpDSB2) {
        hr = IDirectSoundBuffer_Stop (lpDSB2);
        if(FAILED (hr))
-           write_log ("AHI: SoundStop() failure: %s\n", DXError (hr));
+           write_log (L"AHI: SoundStop() failure: %s\n", DXError (hr));
     } else {
-       write_log ("AHI: Sound Stopped...\n");
+       write_log (L"AHI: Sound Stopped...\n");
     }
 
     if (lpDSB2)
@@ -219,7 +219,7 @@ void ahi_updatesound(int force)
 
     hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0);
     if(hr == DSERR_BUFFERLOST) {
-       write_log ("AHI: lostbuf %d %x\n", pos, amigablksize);
+       write_log (L"AHI: lostbuf %d %x\n", pos, amigablksize);
        IDirectSoundBuffer_Restore (lpDSB2);
        hr = IDirectSoundBuffer_Lock (lpDSB2, oldpos, amigablksize * 4, &dwData1, &dwBytes1, &dwData2, &dwBytes2, 0);
     }
@@ -271,7 +271,7 @@ static int ahi_init_record_win32 (void)
     // Record begin
     hr = DirectSoundCaptureCreate (NULL, &lpDS2r, NULL);
     if (FAILED (hr)) {
-       write_log ( "AHI: DirectSoundCaptureCreate() failure: %s\n", DXError (hr));
+       write_log (L"AHI: DirectSoundCaptureCreate() failure: %s\n", DXError (hr));
        record_enabled = -1;
        return 0;
     }
@@ -283,19 +283,19 @@ static int ahi_init_record_win32 (void)
 
     hr = IDirectSoundCapture_CreateCaptureBuffer (lpDS2r, &sound_buffer_rec, &lpDSB2r, NULL);
     if (FAILED (hr)) {
-       write_log ("AHI: CreateCaptureSoundBuffer() failure: %s\n", DXError(hr));
+       write_log (L"AHI: CreateCaptureSoundBuffer() failure: %s\n", DXError(hr));
        record_enabled = -1;
        return 0;
     }
 
     hr = IDirectSoundCaptureBuffer_Start (lpDSB2r, DSCBSTART_LOOPING);
     if (FAILED (hr)) {
-       write_log ("AHI: DirectSoundCaptureBuffer_Start failed: %s\n", DXError (hr));
+       write_log (L"AHI: DirectSoundCaptureBuffer_Start failed: %s\n", DXError (hr));
        record_enabled = -1;
        return 0;
     }
     record_enabled = 1;
-    write_log ("AHI: Init AHI Audio Recording \n");
+    write_log (L"AHI: Init AHI Audio Recording \n");
     return 1;
 }
 
@@ -306,7 +306,7 @@ void setvolume_ahi (LONG vol)
        return;
     hr = IDirectSoundBuffer_SetVolume (lpDSB2, vol);
     if (FAILED (hr))
-       write_log ("AHI: SetVolume(%d) failed: %s\n", vol, DXError (hr));
+       write_log (L"AHI: SetVolume(%d) failed: %s\n", vol, DXError (hr));
 }
 
 static int ahi_init_sound_win32 (void)
@@ -327,7 +327,7 @@ static int ahi_init_sound_win32 (void)
     wavfmt.nAvgBytesPerSec = wavfmt.nBlockAlign * sound_freq_ahi;
     wavfmt.cbSize = 0;
 
-    write_log ("AHI: Init AHI Sound Rate %d, Channels %d, Bits %d, Buffsize %d\n",
+    write_log (L"AHI: Init AHI Sound Rate %d, Channels %d, Bits %d, Buffsize %d\n",
        sound_freq_ahi, sound_channels_ahi, sound_bits_ahi, amigablksize);
 
     if (!amigablksize)
@@ -342,7 +342,7 @@ static int ahi_init_sound_win32 (void)
     else
        hr = DirectSoundCreate (&sound_devices[currprefs.win32_soundcard].guid, &lpDS2, NULL);
     if (FAILED (hr)) {
-       write_log ("AHI: DirectSoundCreate() failure: %s\n", DXError (hr));
+       write_log (L"AHI: DirectSoundCreate() failure: %s\n", DXError (hr));
        return 0;
     }
     memset (&sound_buffer, 0, sizeof (DSBUFFERDESC));
@@ -355,18 +355,18 @@ static int ahi_init_sound_win32 (void)
     hr = IDirectSound_GetCaps (lpDS2, &DSCaps);
     if (SUCCEEDED (hr)) {
        if (DSCaps.dwFlags & DSCAPS_EMULDRIVER)
-           write_log ( "AHI: Your DirectSound Driver is emulated via WaveOut - yuck!\n");
+           write_log (L"AHI: Your DirectSound Driver is emulated via WaveOut - yuck!\n");
     }
     if (FAILED (IDirectSound_SetCooperativeLevel (lpDS2, hMainWnd, DSSCL_PRIORITY)))
        return 0;
     hr = IDirectSound_CreateSoundBuffer (lpDS2, &sound_buffer, &lpDSBprimary2, NULL);
     if (FAILED (hr)) {
-       write_log ("AHI: CreateSoundBuffer() failure: %s\n", DXError(hr));
+       write_log (L"AHI: CreateSoundBuffer() failure: %s\n", DXError(hr));
        return 0;
     }
     hr = IDirectSoundBuffer_SetFormat (lpDSBprimary2, &wavfmt);
     if (FAILED (hr)) {
-       write_log ("AHI: SetFormat() failure: %s\n", DXError (hr));
+       write_log (L"AHI: SetFormat() failure: %s\n", DXError (hr));
        return 0;
     }
     sound_buffer.dwBufferBytes = ahisndbufsize;
@@ -376,7 +376,7 @@ static int ahi_init_sound_win32 (void)
     sound_buffer.guid3DAlgorithm = GUID_NULL;
     hr = IDirectSound_CreateSoundBuffer (lpDS2, &sound_buffer, &lpDSB2, NULL);
     if (FAILED (hr)) {
-       write_log ("AHI: CreateSoundBuffer() failure: %s\n", DXError (hr));
+       write_log (L"AHI: CreateSoundBuffer() failure: %s\n", DXError (hr));
        return 0;
     }
 
@@ -384,7 +384,7 @@ static int ahi_init_sound_win32 (void)
 
     hr = IDirectSoundBuffer_GetFormat (lpDSBprimary2,&wavfmt,500,0);
     if (FAILED (hr)) {
-       write_log ("AHI: GetFormat() failure: %s\n", DXError (hr));
+       write_log (L"AHI: GetFormat() failure: %s\n", DXError (hr));
        return 0;
     }
 
@@ -456,7 +456,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
     {
        uae_u32 src, num_vars;
        static int cap_pos, clipsize;
-       static char *clipdat;
+       static TCHAR *clipdat;
 
        case 0:
            cap_pos = 0;
@@ -556,7 +556,7 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
            if (OpenClipboard (0)) {
                clipdat = GetClipboardData (CF_TEXT);
                if (clipdat) {
-                   clipsize = strlen (clipdat);
+                   clipsize = _tcslen (clipdat);
                    clipsize++;
                    return clipsize;
                }
@@ -578,28 +578,27 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
        case 12:
        {
 #if 1
-           uae_u8 *addr = get_real_address (m68k_areg (&regs, 0));
+           TCHAR *s = au (get_real_address (m68k_areg (&regs, 0)));
            static LPTSTR p;
            int slen;
-           LPTSTR p2;
 
            if (OpenClipboard (0)) {
                EmptyClipboard();
-               slen = strlen(addr);
+               slen = _tcslen (s);
                if (p)
                    GlobalFree (p);
-               p = GlobalAlloc (GMEM_MOVEABLE,slen+2);
+               p = GlobalAlloc (GMEM_MOVEABLE, (slen + 1) * sizeof (TCHAR));
                if (p) {
-                   p2 = GlobalLock (p);
+                   TCHAR *p2 = GlobalLock (p);
                    if (p2) {
-                       memcpy (p2, addr, slen);
-                       p2[slen] = 0;
+                       _tcscpy (p2, s);
                        GlobalUnlock (p);
-                       SetClipboardData (CF_TEXT,p2);
+                       SetClipboardData (CF_TEXT, p);
                    }
                }
                CloseClipboard ();
            }
+           xfree (s);
 #endif
        }
        return 0;
@@ -633,46 +632,46 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
 
        case 100: // open dll
        {
-           char *dlldir = TEXT ("winuae_dll");
-           char *dllname;
+           TCHAR *dlldir = TEXT ("winuae_dll");
+           TCHAR *dllname;
            uaecptr dllptr;
            HMODULE h = NULL;
-           char dpath[MAX_DPATH];
-           char newdllpath[MAX_DPATH];
+           TCHAR dpath[MAX_DPATH];
+           TCHAR newdllpath[MAX_DPATH];
            int ok = 0;
-           char *filepart;
+           TCHAR *filepart;
 
            dllptr = m68k_areg (&context->regs, 0);
-           dllname = (char *)get_real_address (dllptr);
+           dllname = (TCHAR *)get_real_address (dllptr);
            dpath[0] = 0;
-           GetFullPathName (dllname, sizeof dpath, dpath, &filepart);
-           if (strlen (dpath) > strlen (start_path_data) && !strnicmp (dpath, start_path_data, strlen (start_path_data))) {
+           GetFullPathName (dllname, sizeof dpath / sizeof (TCHAR), dpath, &filepart);
+           if (_tcslen (dpath) > _tcslen (start_path_data) && !_tcsncmp (dpath, start_path_data, _tcslen (start_path_data))) {
                /* path really is relative to winuae directory */
                ok = 1;
-               strcpy (newdllpath, dpath + strlen (start_path_data));
-               if (!strnicmp (newdllpath, dlldir, strlen (dlldir))) /* remove "winuae_dll" */
-                   strcpy (newdllpath, dpath + strlen (start_path_data) + 1 + strlen (dlldir));
-               sprintf (dpath, "%s%s%s", start_path_data, WIN32_PLUGINDIR, newdllpath);
+               _tcscpy (newdllpath, dpath + _tcslen (start_path_data));
+               if (!_tcsncmp (newdllpath, dlldir, _tcslen (dlldir))) /* remove "winuae_dll" */
+                   _tcscpy (newdllpath, dpath + _tcslen (start_path_data) + 1 + _tcslen (dlldir));
+               _stprintf (dpath, L"%s%s%s", start_path_data, WIN32_PLUGINDIR, newdllpath);
                h = LoadLibrary (dpath);
                if (h == NULL)
-                   write_log ("native open: '%s' = %d\n", dpath, GetLastError ());
+                   write_log (L"native open: '%s' = %d\n", dpath, GetLastError ());
                if (h == NULL) {
-                   sprintf (dpath, "%s%s\\%s", start_path_data, dlldir, newdllpath);
+                   _stprintf (dpath, L"%s%s\\%s", start_path_data, dlldir, newdllpath);
                    h = LoadLibrary (dllname);
                    if (h == NULL)
-                       write_log ("fallback native open: '%s' = %d\n", dpath, GetLastError ());
+                       write_log (L"fallback native open: '%s' = %d\n", dpath, GetLastError ());
                }
            } else {
-               write_log ("native open outside of installation dir '%s'!\n", dpath);
+               write_log (L"native open outside of installation dir '%s'!\n", dpath);
            }
 #if 0
            if (h == NULL) {
                h = LoadLibrary (filepart);
-               write_log ("native file open: '%s' = %p\n", filepart, h);
+               write_log (L"native file open: '%s' = %p\n", filepart, h);
                if (h == NULL) {
-                   sprintf (dpath, "%s%s%s", start_path_data, WIN32_PLUGINDIR, filepart);
+                   _stprintf (dpath, "%s%s%s", start_path_data, WIN32_PLUGINDIR, filepart);
                    h = LoadLibrary (dpath);
-                   write_log ("native path open: '%s' = %p\n", dpath, h);
+                   write_log (L"native path open: '%s' = %p\n", dpath, h);
                }
            }
 #endif
@@ -683,10 +682,11 @@ uae_u32 REGPARAM2 ahi_demux (TrapContext *context)
        case 101:       //get dll label
        {
            HMODULE m;
+           uaecptr funcaddr;
            char *funcname;
            m = (HMODULE) m68k_dreg (&context->regs, 1);
-           funcname = (char *)m68k_areg (&context->regs, 0);
-           funcname = (char *)get_real_address ((uae_u32)funcname);
+           funcaddr = m68k_areg (&context->regs, 0);
+           funcname = get_real_address (funcaddr);
            return (uae_u32) GetProcAddress (m, funcname);
        }
 
index f1da32bc0c801e6edc0637c02d1145164f6f56d9..931b8e943a1ecbc5a1c448c31cb24b6687866526 100644 (file)
@@ -1,8 +1,8 @@
 extern void ahi_updatesound(int force);
-extern uae_u32 REGPARAM2 ahi_demux(TrapContext*);
+extern uae_u32 REGPARAM2 ahi_demux (TrapContext*);
 extern int ahi_open_sound (void);
 extern void ahi_close_sound (void);
-extern void ahi_finish_sound_buffer( void );
+extern void ahi_finish_sound_buffer (void);
 
 extern int ahi_on;
 extern int ahi_pollrate;
\ No newline at end of file
index 3a0cc98f170a6b204374ee22a79709fa2b14f9b7..d9921e70f50017314697f4a5d7d9aa81a0e298c8 100644 (file)
@@ -532,7 +532,7 @@ static void setevent (struct DSAHI *dsahip)
     t = (evt)(cycles / f);
     if (dsahip->evttime == t)
        return;
-    write_log ("AHI: playerfunc freq = %.2fHz\n", f);
+    write_log (L"AHI: playerfunc freq = %.2fHz\n", f);
     dsahip->evttime = t;
     if (t < 10)
        return;
@@ -543,9 +543,9 @@ static void alClear (void)
 {
     alGetError ();
 }
-static int alError (const char *format,...)
+static int alError (const TCHAR *format,...)
 {
-    char buffer[1000];
+    TCHAR buffer[1000];
     va_list parms;
     int err;
 
@@ -553,9 +553,9 @@ static int alError (const char *format,...)
     if (err == AL_NO_ERROR)
        return 0;
     va_start (parms, format);
-    _vsnprintf (buffer, sizeof buffer -1, format, parms);
-    sprintf (buffer + strlen (buffer), ": ERR=%x\n", err);
-    write_log ("%s", buffer);
+    _vsntprintf (buffer, sizeof buffer -1, format, parms);
+    _stprintf (buffer + _tcslen (buffer), L": ERR=%x\n", err);
+    write_log (L"%s", buffer);
     return err;
 }
 
@@ -598,7 +598,7 @@ static void ds_free (struct DSAHI *dsahip)
     alcCloseDevice (dsahip->al_dev);
     dsahip->al_dev = 0;
     if (ahi_debug && ahi_active)
-       write_log ("AHI: OpenAL freed\n");
+       write_log (L"AHI: OpenAL freed\n");
     ahi_active = 0;
 }
 
@@ -615,6 +615,7 @@ static int ds_init_record (struct DSAHI *dsahip)
     int freq = get_long (dsahip->audioctrl + ahiac_MixFreq);
     struct sound_device *sd;
     int device;
+    char *s;
 
     if (!freq)
        return 0;
@@ -634,13 +635,15 @@ static int ds_init_record (struct DSAHI *dsahip)
     dsahip->record_ch = 2;
     dsahip->record_bytespersample = 2;
     alClear ();
-    dsahip->al_recorddev = alcCaptureOpenDevice (sd->alname, freq, AL_FORMAT_STEREO16, dsahip->record_samples);
+    s = ua (sd->alname);
+    dsahip->al_recorddev = alcCaptureOpenDevice (s, freq, AL_FORMAT_STEREO16, dsahip->record_samples);
+    xfree (s);
     if (dsahip->al_recorddev == NULL)
        goto error;
     return 1;
 error:
     if (ahi_debug)
-       write_log ("AHI: OPENAL recording initialization failed\n");
+       write_log (L"AHI: OPENAL recording initialization failed\n");
     return 0;
 }
 
@@ -650,6 +653,7 @@ static int ds_init (struct DSAHI *dsahip)
     int v;
     struct sound_device *sd;
     int device;
+    char *s;
 
     device = dsahip->output;
     sd = sound_devices;
@@ -663,7 +667,9 @@ static int ds_init (struct DSAHI *dsahip)
        if (sd->name == NULL)
            return 0;
     }
-    dsahip->al_dev = alcOpenDevice (sd->alname);
+    s = ua (sd->alname);
+    dsahip->al_dev = alcOpenDevice (s);
+    xfree (s);
     if (!dsahip->al_dev)
        goto error;
     dsahip->al_ctx = alcCreateContext (dsahip->al_dev, NULL);
@@ -690,18 +696,18 @@ static int ds_init (struct DSAHI *dsahip)
     dsahip->bytespersampleout = dsahip->bitspersampleout / 8;
     dsahip->channellength = 65536 * dsahip->chout * dsahip->bytespersampleout;
     if (ahi_debug)
-       write_log("AHI: CH=%d BLEN=%d\n",
+       write_log (L"AHI: CH=%d BLEN=%d\n",
            dsahip->chout, dsahip->channellength);
 
     dsahip->tmpbuffer_size = 1000000;
     dsahip->tmpbuffer = xmalloc (dsahip->tmpbuffer_size);
     if (ahi_debug)
-       write_log ("AHI: OpenAL initialized: %s\n", sound_devices[dsahip->output].name);
+       write_log (L"AHI: OpenAL initialized: %s\n", sound_devices[dsahip->output].name);
 
     return 1;
 error:
     if (ahi_debug)
-       write_log ("AHI: OpenAL initialization failed\n");
+       write_log (L"AHI: OpenAL initialization failed\n");
     ds_free (dsahip);
     return 0;
 }
@@ -719,7 +725,7 @@ static void ds_setvolume (struct DSAHI *dsahip, struct dschannel *dc)
            float vol = ((float)(abs (dc->csnext.volume))) / 65536.0;
            alClear ();
            alSourcef (dc->al_source, AL_GAIN, vol);
-           alError ("AHI: SetVolume(%d,%d)", dc->num, vol);
+           alError (L"AHI: SetVolume(%d,%d)", dc->num, vol);
        }
        if (abs (dc->cs.panning) != abs (dc->csnext.panning)) {
 ;//        pan = (abs (dc->csnext.panning) - 0x8000) * DSBPAN_RIGHT / 32768;
@@ -734,7 +740,7 @@ static void ds_setfreq (struct DSAHI *dsahip, struct dschannel *dc)
     if (dc->dsplaying && dc->cs.frequency != dc->csnext.frequency && dc->csnext.frequency > 0 && dc->al_source != -1) {
        //alClear ();
        //alSourcei (dc->al_source, AL_FREQUENCY, dc->csnext.frequency);
-       //alError ("AHI: SetFrequency(%d,%d)", dc->num, dc->csnext.frequency);
+       //alError (L"AHI: SetFrequency(%d,%d)", dc->num, dc->csnext.frequency);
     }
     dc->cs.frequency = dc->csnext.frequency;
 }
@@ -745,7 +751,7 @@ static int ds_allocchannel (struct DSAHI *dsahip, struct dschannel *dc)
        return 1;
     alClear ();
     alGenSources (1, &dc->al_source);
-    if (alError ("alGenSources()"))
+    if (alError (L"alGenSources()"))
        goto error;
     dc->cs.frequency = -1;
     dc->cs.volume = -1;
@@ -753,7 +759,7 @@ static int ds_allocchannel (struct DSAHI *dsahip, struct dschannel *dc)
     ds_setvolume (dsahip, dc);
     ds_setfreq (dsahip, dc);
     if (ahi_debug)
-       write_log ("AHI: allocated OpenAL source for channel %d. vol=%d pan=%d freq=%d\n",
+       write_log (L"AHI: allocated OpenAL source for channel %d. vol=%d pan=%d freq=%d\n",
            dc->num, dc->cs.volume, dc->cs.panning, dc->cs.frequency);
     return 1;
 error:
@@ -985,14 +991,14 @@ static void al_setloop (struct dschannel *dc, int state)
 {
     alClear ();
     alSourcei (dc->al_source, AL_LOOPING, state ? AL_TRUE : AL_FALSE);
-    alError ("AHI: ds_play() alSourcei(AL_LOOPING)");
+    alError (L"AHI: ds_play() alSourcei(AL_LOOPING)");
 }
 
 static void al_startplay (struct dschannel *dc)
 {
     alClear ();
     alSourcePlay (dc->al_source);
-    alError ("AHI: ds_play() alSourcePlay");
+    alError (L"AHI: ds_play() alSourcePlay");
 }
 
 static void preparesample_single (struct DSAHI *dsahip, struct dschannel *dc)
@@ -1013,12 +1019,12 @@ static void preparesample_single (struct DSAHI *dsahip, struct dschannel *dc)
     dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
     alClear ();
     alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
-    alError ("AHI: preparesample_single:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
+    alError (L"AHI: preparesample_single:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
     alClear ();
     alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
-    alError ("AHI: al_initsample_single:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
+    alError (L"AHI: al_initsample_single:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
     if (ahi_debug > 2)
-       write_log ("AHI: sample queued %d: %d/%d\n",
+       write_log (L"AHI: sample queued %d: %d/%d\n",
            dc->num, dc->samplecounter, dc->totalsamples);
 }
 
@@ -1041,12 +1047,12 @@ static void preparesample_multi (struct DSAHI *dsahip, struct dschannel *dc)
     dlen = copysampledata (dsahip, dc, ds, &p, pe, ps, dsahip->tmpbuffer, slen);
     alClear ();
     alBufferData (ds->al_buffer[dc->buffertoggle], dsahip->al_bufferformat, dsahip->tmpbuffer, dlen, dc->cs.frequency);
-    alError ("AHI: preparesample:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
+    alError (L"AHI: preparesample:alBufferData(len=%d,freq=%d)", dlen, dc->cs.frequency);
     alClear ();
     alSourceQueueBuffers (dc->al_source, 1, &ds->al_buffer[dc->buffertoggle]);
-    alError ("AHI: al_initsample:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
+    alError (L"AHI: al_initsample:alSourceQueueBuffers(freq=%d)", dc->cs.frequency);
     if (ahi_debug > 2)
-       write_log ("AHI: sample queued %d: %d/%d\n",
+       write_log (L"AHI: sample queued %d: %d/%d\n",
            dc->num, dc->samplecounter, dc->totalsamples);
     dc->samplecounter++;
     dc->buffertoggle ^= 1;
@@ -1062,7 +1068,7 @@ static void al_initsample (struct DSAHI *dsahip, struct dschannel *dc)
     alSourceStop (dc->al_source);
     alClear ();
     alSourcei (dc->al_source, AL_BUFFER, AL_NONE);
-    alError ("AHI: al_initsample:AL_BUFFER=AL_NONE");
+    alError (L"AHI: al_initsample:AL_BUFFER=AL_NONE");
 
     memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
     dc->csnext.ds = NULL;
@@ -1118,14 +1124,14 @@ static void al_queuesample (struct DSAHI *dsahip, struct dschannel *dc)
     if (dc->dsplaying) {
        alClear ();
        alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
-       alError ("AHI: queuesample AL_SOURCE_STATE");
+       alError (L"AHI: queuesample AL_SOURCE_STATE");
        if (v != AL_PLAYING) {
            alClear ();
            alSourceRewind (dc->al_source);
-           alError ("AHI: queuesample:restart");
+           alError (L"AHI: queuesample:restart");
            restart = 1;
            if (ahi_debug > 2)
-               write_log ("AHI: queuesample, play restart\n");
+               write_log (L"AHI: queuesample, play restart\n");
            preparesample_multi (dsahip, dc);
        }
     }
@@ -1135,7 +1141,7 @@ static void al_queuesample (struct DSAHI *dsahip, struct dschannel *dc)
     if (restart)
        al_startplay (dc);
     if (ahi_debug > 2)
-       write_log ("AHI: sample %d queued to channel %d\n", dc->cs.ds->num, dc->num);
+       write_log (L"AHI: sample %d queued to channel %d\n", dc->cs.ds->num, dc->num);
 }
 
 static int unqueuebuffers (struct dschannel *dc)
@@ -1145,7 +1151,7 @@ static int unqueuebuffers (struct dschannel *dc)
        ALuint tmp;
        alClear ();
        alGetSourcei (dc->al_source, AL_BUFFERS_PROCESSED, &v);
-       if (alError ("AHI: hsync AL_BUFFERS_PROCESSED %d", dc->num))
+       if (alError (L"AHI: hsync AL_BUFFERS_PROCESSED %d", dc->num))
            return cnt;
        if (v == 0)
            return cnt;
@@ -1187,12 +1193,12 @@ void ahi_hsync (void)
        v = 0;
         alClear ();
        alGetSourcei (dc->al_source, AL_SOURCE_STATE, &v);
-       alError ("AHI: hsync AL_SOURCE_STATE");
+       alError (L"AHI: hsync AL_SOURCE_STATE");
        if (v != AL_PLAYING) {
            if (dc->cs.ds) {
                setchannelevent (dsahip, dc);
                if (ahi_debug)
-                   write_log ("AHI: ********* channel %d stopped state=%d!\n", dc->num, v);
+                   write_log (L"AHI: ********* channel %d stopped state=%d!\n", dc->num, v);
                removed = 1;
                dc->dsplaying = 2;
                dc->waitforack = 0;
@@ -1201,11 +1207,11 @@ void ahi_hsync (void)
        if (!dc->waitforack && dc->samplecounter >= 0 && removed) {
            int evt = 0;
            if (ahi_debug > 2)
-               write_log ("sample end channel %d: %d/%d\n", dc->num, dc->samplecounter, dc->totalsamples);
+               write_log (L"sample end channel %d: %d/%d\n", dc->num, dc->samplecounter, dc->totalsamples);
            if (dc->samplecounter >= dc->totalsamples) {
                evt = 1;
                if (ahi_debug > 2)
-                   write_log ("sample finished channel %d: %d\n", dc->num, dc->totalsamples);
+                   write_log (L"sample finished channel %d: %d\n", dc->num, dc->totalsamples);
                dc->samplecounter = 0;
                if (dc->csnext.ds) {
                    memcpy (&dc->cs, &dc->csnext, sizeof (struct chsample));
@@ -1240,7 +1246,7 @@ static void ds_record (struct DSAHI *dsahip, int start)
        alcCaptureStop (dsahip->al_recorddev);
        dsahip->dsrecording = 0;
     }
-    alError ("AHI: alcCapture%s failed", start ? "Start" : "Stop");
+    alError (L"AHI: alcCapture%s failed", start ? "Start" : "Stop");
 }
 
 static void ds_stop (struct DSAHI *dsahip, struct dschannel *dc)
@@ -1249,10 +1255,10 @@ static void ds_stop (struct DSAHI *dsahip, struct dschannel *dc)
     if (dc->al_source == -1)
        return;
     if (ahi_debug)
-       write_log ("AHI: ds_stop(%d)\n", dc->num);
+       write_log (L"AHI: ds_stop(%d)\n", dc->num);
     alClear ();
     alSourceStop (dc->al_source);
-    alError ("AHI: alSourceStop");
+    alError (L"AHI: alSourceStop");
     unqueuebuffers (dc);
 }
 
@@ -1268,7 +1274,7 @@ static void ds_play (struct DSAHI *dsahip, struct dschannel *dc)
     if (dc->al_source == -1)
        return;
     if (ahi_debug)
-       write_log ("AHI: ds_play(%d)\n", dc->num);
+       write_log (L"AHI: ds_play(%d)\n", dc->num);
     al_startplay (dc);
 }
 
@@ -1298,9 +1304,9 @@ static uae_u32 init (TrapContext *ctx)
     int i, j;
     
     enumerate_sound_devices ();
-    xahi_author = ds ("Toni Wilen");
-    xahi_copyright = ds ("GPL");
-    xahi_version = ds ("uae2 0.2 (xx.xx.2008)\r\n");
+    xahi_author = ds (L"Toni Wilen");
+    xahi_copyright = ds (L"GPL");
+    xahi_version = ds (L"uae2 0.2 (xx.xx.2008)\r\n");
     j = 0;
     for (i = 0; sound_devices[i].name; i++) {
        if (sound_devices[i].type == SOUND_DEVICE_AL)
@@ -1327,22 +1333,22 @@ static uae_u32 AHIsub_AllocAudio (TrapContext *ctx)
     struct DSAHI *dsahip = &dsahi[0];
 
     if (ahi_debug)
-       write_log ("AHI: AllocAudio(%08x,%08x)\n", tags, audioctrl);
+       write_log (L"AHI: AllocAudio(%08x,%08x)\n", tags, audioctrl);
 
     ver = get_long (pbase + pub_Version);
     size = get_long (pbase + pub_SizeOf);
     if (ver != AHI_STRUCT_VERSION) {
-       gui_message ("AHI: Incompatible DEVS:AHI/uae2.audio\nVersion mismatch %d<>%d.", ver, AHI_STRUCT_VERSION);
+       gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio\nVersion mismatch %d<>%d.", ver, AHI_STRUCT_VERSION);
        return AHISF_ERROR;
     }
     if (size < pub_End) {
-       gui_message ("AHI: Incompatible DEVS:AHI/uae2.audio.\nInternal structure size %d<>%d.", size, pub_End);
+       gui_message (L"AHI: Incompatible DEVS:AHI/uae2.audio.\nInternal structure size %d<>%d.", size, pub_End);
        return AHISF_ERROR;
     }
 
     v = get_long (pbase + pub_Index);
     if (v != -1) {
-       write_log ("AHI: corrupted memory\n");
+       write_log (L"AHI: corrupted memory\n");
        return AHISF_ERROR;
     }
     put_long (pbase + pub_Index, dsahip - dsahi);
@@ -1355,7 +1361,7 @@ static uae_u32 AHIsub_AllocAudio (TrapContext *ctx)
     dsahip->audioid = 0x003b0001;
     while ((tag = gettag (&tags, &data))) {
        if (ahi_debug)
-           write_log ("- TAG %08x=%d: %08x=%u\n", tag, tag & 0x7fff, data, data);
+           write_log (L"- TAG %08x=%d: %08x=%u\n", tag, tag & 0x7fff, data, data);
        switch (tag)
        {
            case AHIA_AudioID:
@@ -1400,7 +1406,7 @@ static void AHIsub_Disable (TrapContext *ctx)
     uae_u32 audioctrl = m68k_areg (&ctx->regs, 2);
     struct DSAHI *dsahip = GETAHI;
     if (ahi_debug > 1)
-       write_log ("AHI: Disable(%08x)\n", audioctrl);
+       write_log (L"AHI: Disable(%08x)\n", audioctrl);
     dsahip->enabledisable++;
 }
 
@@ -1409,7 +1415,7 @@ static void AHIsub_Enable (TrapContext *ctx)
     uae_u32 audioctrl = m68k_areg (&ctx->regs, 2);
     struct DSAHI *dsahip = GETAHI;
     if (ahi_debug > 1)
-       write_log ("AHI: Enable(%08x)\n", audioctrl);
+       write_log (L"AHI: Enable(%08x)\n", audioctrl);
     dsahip->enabledisable--;
     if (dsahip->enabledisable == 0 && dsahip->playing)
        setevent (dsahip);
@@ -1421,7 +1427,7 @@ static void AHIsub_FreeAudio (TrapContext *ctx)
     uae_u32 pbase = get_long (audioctrl + ahiac_DriverData);
     struct DSAHI *dsahip = GETAHI;
     if (ahi_debug)
-       write_log ("AHI: FreeAudio(%08x)\n", audioctrl);
+       write_log (L"AHI: FreeAudio(%08x)\n", audioctrl);
     if (ahi_active == 0)
        return;
     ahi_active = 0;
@@ -1527,7 +1533,7 @@ static uae_u32 AHIsub_GetAttr (TrapContext *ctx)
 
     v = getattr2 (dsahip, attribute, argument, def);
     if (ahi_debug)
-       write_log ("AHI: GetAttr(%08x=%d,%08x,%08x)=%08x\n", attribute, attribute & 0x7fff, argument, def, v);
+       write_log (L"AHI: GetAttr(%08x=%d,%08x,%08x)=%08x\n", attribute, attribute & 0x7fff, argument, def, v);
 
     return v;
 }
@@ -1539,7 +1545,7 @@ static uae_u32 AHIsub_HardwareControl (TrapContext *ctx)
     uae_u32 audioctrl = m68k_areg (&ctx->regs, 2);
     struct DSAHI *dsahip = GETAHI;
     if (ahi_debug)
-       write_log ("AHI: HardwareControl(%08x=%d,%08x,%08x)\n", attribute, attribute & 0x7fff, argument, audioctrl);
+       write_log (L"AHI: HardwareControl(%08x=%d,%08x,%08x)\n", attribute, attribute & 0x7fff, argument, audioctrl);
     switch (attribute)
     {
        case AHIC_Input:
@@ -1576,7 +1582,7 @@ static uae_u32 AHIsub_Start (TrapContext *ctx)
     int i;
 
     if (ahi_debug)
-       write_log ("AHI: Play(%08x,%08x)\n",
+       write_log (L"AHI: Play(%08x,%08x)\n",
            flags, audioctrl);
     if ((flags & AHISF_PLAY) && !dsahip->playing) {
        dsahip->playing = 1;
@@ -1602,7 +1608,7 @@ static uae_u32 AHIsub_Stop (TrapContext *ctx)
     int i;
 
     if (ahi_debug)
-       write_log ("AHI: Stop(%08x,%08x)\n",
+       write_log (L"AHI: Stop(%08x,%08x)\n",
            flags, audioctrl);
     if ((flags & AHISF_PLAY) && dsahip->playing) {
        dsahip->playing = 0;
@@ -1625,7 +1631,7 @@ static uae_u32 AHIsub_Update (TrapContext *ctx)
     uae_u32 audioctrl = m68k_areg (&ctx->regs, 2);
     struct DSAHI *dsahip = GETAHI;
     if (ahi_debug)
-       write_log ("AHI: Update(%08x,%08x)\n", flags, audioctrl);
+       write_log (L"AHI: Update(%08x,%08x)\n", flags, audioctrl);
     setevent (dsahip);
     return 0;
 }
@@ -1641,7 +1647,7 @@ static uae_u32 AHIsub_SetVol (TrapContext *ctx)
     struct dschannel *dc = GETCHANNEL;
 
     if (ahi_debug > 1)
-       write_log ("AHI: SetVol(%d,%d,%d,%08x,%08x)\n",
+       write_log (L"AHI: SetVol(%d,%d,%d,%08x,%08x)\n",
            channel, volume, pan, audioctrl, flags);
     if (dc) {
        if (volume < -65535)
@@ -1671,7 +1677,7 @@ static uae_u32 AHIsub_SetFreq (TrapContext *ctx)
     struct dschannel *dc = GETCHANNEL;
 
     if (ahi_debug > 1)
-       write_log ("AHI: SetFreq(%d,%d,%08x,%08x)\n",
+       write_log (L"AHI: SetFreq(%d,%d,%08x,%08x)\n",
            channel, frequency, audioctrl, flags);
     if (dc) {
        dc->csnext.frequency = frequency;
@@ -1696,7 +1702,7 @@ static uae_u32 AHIsub_SetSound (TrapContext *ctx)
     struct dschannel *dc = GETCHANNEL;
 
     if (ahi_debug > 1)
-       write_log ("AHI: SetSound(%d,%d,%08x,%d,%08x,%08x)\n",
+       write_log (L"AHI: SetSound(%d,%d,%08x,%d,%08x,%08x)\n",
            channel, sound, offset, length, audioctrl, flags);
     if (dc == NULL)
        return AHIE_UNKNOWN;
@@ -1737,7 +1743,7 @@ static uae_u32 AHIsub_SetEffect (TrapContext *ctx)
     struct DSAHI *dsahip = GETAHI;
 
     if (ahi_debug)
-       write_log ("AHI: SetEffect(%08x (%08x),%08x)\n", effect, effectype, audioctrl);
+       write_log (L"AHI: SetEffect(%08x (%08x),%08x)\n", effect, effectype, audioctrl);
     switch (effectype)
     {
        case AHIET_CHANNELINFO:
@@ -1747,7 +1753,7 @@ static uae_u32 AHIsub_SetEffect (TrapContext *ctx)
        put_long (puaebase + pub_ChannelInfo, 0);
        break;
        case AHIET_MASTERVOLUME:
-           write_log ("AHI: SetEffect(MasterVolume=%08x)\n", get_long (effect + 4));
+           write_log (L"AHI: SetEffect(MasterVolume=%08x)\n", get_long (effect + 4));
        case AHIET_MASTERVOLUME | AHIET_CANCEL:
        break;
        default:
@@ -1772,7 +1778,7 @@ static uae_u32 AHIsub_LoadSound (TrapContext *ctx)
     int bps;
 
     if (ahi_debug > 1)
-       write_log ("AHI: LoadSound(%d,%d,%08x,%08x,SMP=%d,ADDR=%08x,LEN=%d)\n",
+       write_log (L"AHI: LoadSound(%d,%d,%08x,%08x,SMP=%d,ADDR=%08x,LEN=%d)\n",
            sound, type, info, audioctrl, sampletype, addr, len);
 
     if (!ds)
@@ -1829,10 +1835,10 @@ static uae_u32 AHIsub_LoadSound (TrapContext *ctx)
     if (ds->al_buffer[0] == -1) {
        alClear ();
        alGenBuffers (2, ds->al_buffer);
-       if (alError ("AHI: alGenBuffers"))
+       if (alError (L"AHI: alGenBuffers"))
            return AHIE_NOMEM;
        if (ahi_debug > 1)
-           write_log ("AHI:LoadSound:allocated OpenAL buffer\n");
+           write_log (L"AHI:LoadSound:allocated OpenAL buffer\n");
     }
     return AHIE_OK;
 }
@@ -1845,7 +1851,7 @@ static uae_u32 AHIsub_UnloadSound (TrapContext *ctx)
     struct dssample *ds = GETSAMPLE;
 
     if (ahi_debug > 1)
-       write_log ("AHI: UnloadSound(%d,%08x)\n",
+       write_log (L"AHI: UnloadSound(%d,%08x)\n",
            sound, audioctrl);
     ds->num = -1;
     return AHIE_OK;
@@ -1858,7 +1864,7 @@ static uae_u32 REGPARAM2 ahi_demux (TrapContext *ctx)
     uae_u32 offset = get_long (sp + 4);
 
     if (0 && ahi_debug)
-       write_log ("AHI: %d\n", offset);
+       write_log (L"AHI: %d\n", offset);
 
     switch (offset)
     {
@@ -1918,7 +1924,7 @@ void init_ahi_v2 (void)
 {
     uaecptr a = here ();
     org (rtarea_base + 0xFFC8);
-    calltrap (deftrapres (ahi_demux, 0, "ahi_v2"));
+    calltrap (deftrapres (ahi_demux, 0, L"ahi_v2"));
     dw (RTS);
     org (a);
 }
index 96b7317a98fde763d1155bc3b85ed62cbd694a05..61209bb5f0fdcdf172ef6747e297996441caadea 100644 (file)
@@ -66,11 +66,11 @@ int avioutput_width, avioutput_height, avioutput_bits;
 int avioutput_fps = VBLANK_HZ_PAL;
 DWORD avioutput_framelimiter = 0, avioutput_nosoundoutput = 0;
 
-char avioutput_filename[MAX_DPATH];
-static char avioutput_filename_tmp[MAX_DPATH];
+TCHAR avioutput_filename[MAX_DPATH];
+static TCHAR avioutput_filename_tmp[MAX_DPATH];
 
 extern struct uae_prefs workprefs;
-extern char config_filename[256];
+extern TCHAR config_filename[256];
 
 static CRITICAL_SECTION AVIOutput_CriticalSection;
 static int cs_allocated;
@@ -188,25 +188,25 @@ static void waitqueuefull (void)
 
 static UAEREG *openavikey (void)
 {
-    return regcreatetree (NULL, "AVConfiguration");
+    return regcreatetree (NULL, L"AVConfiguration");
 }
 
 static void storesettings (UAEREG *avikey)
 {
-    regsetint (avikey, "FrameLimiter", avioutput_framelimiter);
-    regsetint (avikey, "NoSoundOutput", avioutput_nosoundoutput);
-    regsetint (avikey, "FPS", avioutput_fps);
+    regsetint (avikey, L"FrameLimiter", avioutput_framelimiter);
+    regsetint (avikey, L"NoSoundOutput", avioutput_nosoundoutput);
+    regsetint (avikey, L"FPS", avioutput_fps);
 }
 static void getsettings (UAEREG *avikey)
 {
     DWORD val;
-    if (regqueryint (avikey, "NoSoundOutput", &val))
+    if (regqueryint (avikey, L"NoSoundOutput", &val))
        avioutput_nosoundoutput = val;
-    if (regqueryint (avikey, "FrameLimiter", &val))
+    if (regqueryint (avikey, L"FrameLimiter", &val))
        avioutput_framelimiter = val;
     if (!avioutput_framelimiter)
        avioutput_nosoundoutput = 1;
-    if (regqueryint (avikey, "FPS", &val))
+    if (regqueryint (avikey, L"FPS", &val))
        avioutput_fps = val;
 }
 
@@ -248,7 +248,7 @@ static int AVIOutput_AllocateAudio (void)
     AVIOutput_ReleaseAudio ();
 
     if ((err = acmMetrics (NULL, ACM_METRIC_MAX_SIZE_FORMAT, &wfxMaxFmtSize))) {
-       gui_message("acmMetrics() FAILED (%X)\n", err);
+       gui_message (L"acmMetrics() FAILED (%X)\n", err);
        return 0;
     }
 
@@ -293,7 +293,7 @@ static int AVIOutput_AllocateAudio (void)
     acmopt.fdwStyle = ACMFORMATCHOOSE_STYLEF_INITTOWFXSTRUCT;
     acmopt.pwfx = pwfxDst;
     acmopt.cbwfx = wfxMaxFmtSize;
-    acmopt.pszTitle  = "Choose Audio Codec";
+    acmopt.pszTitle  = L"Choose Audio Codec";
 
     //acmopt.szFormatTag =; // not valid until the format is chosen
     //acmopt.szFormat =; // not valid until the format is chosen
@@ -311,7 +311,7 @@ static int AVIOutput_AllocateAudio (void)
     return 1;
 }
 
-static int AVIOutput_ValidateAudio (WAVEFORMATEX *wft, char *name, int len)
+static int AVIOutput_ValidateAudio (WAVEFORMATEX *wft, TCHAR *name, int len)
 {
     DWORD ret;
     ACMFORMATTAGDETAILS aftd;
@@ -334,7 +334,7 @@ static int AVIOutput_ValidateAudio (WAVEFORMATEX *wft, char *name, int len)
        return 0;
 
     if (name)
-       sprintf (name, "%s %s", aftd.szFormatTag, afd.szFormat);
+       _stprintf (name, L"%s %s", aftd.szFormatTag, afd.szFormat);
     return 1;
 }
 
@@ -350,25 +350,25 @@ static int AVIOutput_GetAudioFromRegistry (WAVEFORMATEX *wft)
     getsettings (avikey);
     if (wft) {
        ss = wfxMaxFmtSize;
-       if (regquerydata (avikey, "AudioConfigurationVars", wft, &ss)) {
+       if (regquerydata (avikey, L"AudioConfigurationVars", wft, &ss)) {
            if (AVIOutput_ValidateAudio (wft, NULL, 0))
                ok = 1;
        }
     }
     if (!ok)
-       regdelete (avikey, "AudioConfigurationVars");
+       regdelete (avikey, L"AudioConfigurationVars");
     regclosetree (avikey);
     return ok;
 }
 
 
 
-static int AVIOutput_GetAudioCodecName (WAVEFORMATEX *wft, char *name, int len)
+static int AVIOutput_GetAudioCodecName (WAVEFORMATEX *wft, TCHAR *name, int len)
 {
     return AVIOutput_ValidateAudio (wft, name, len);
 }
 
-int AVIOutput_GetAudioCodec (char *name, int len)
+int AVIOutput_GetAudioCodec (TCHAR *name, int len)
 {
     if (AVIOutput_AudioAllocated ())
        return AVIOutput_GetAudioCodecName (pwfxDst, name, len);
@@ -382,7 +382,7 @@ int AVIOutput_GetAudioCodec (char *name, int len)
     return 0;
 }
 
-int AVIOutput_ChooseAudioCodec (HWND hwnd, char *s, int len)
+int AVIOutput_ChooseAudioCodec (HWND hwnd, TCHAR *s, int len)
 {
     AVIOutput_End();
     if (!AVIOutput_AllocateAudio ())
@@ -395,10 +395,10 @@ int AVIOutput_ChooseAudioCodec (HWND hwnd, char *s, int len)
        case MMSYSERR_NOERROR:
        {
            UAEREG *avikey;
-           strcpy (s, acmopt.szFormatTag);
+           _tcscpy (s, acmopt.szFormatTag);
            avikey = openavikey ();
            if (avikey) {
-               regsetdata (avikey, "AudioConfigurationVars", pwfxDst, pwfxDst->cbSize + sizeof (WAVEFORMATEX));
+               regsetdata (avikey, L"AudioConfigurationVars", pwfxDst, pwfxDst->cbSize + sizeof (WAVEFORMATEX));
                storesettings (avikey);
                regclosetree (avikey);
            }
@@ -411,27 +411,27 @@ int AVIOutput_ChooseAudioCodec (HWND hwnd, char *s, int len)
            break;
 
        case ACMERR_NOTPOSSIBLE:
-           MessageBox (hwnd, "The buffer identified by the pwfx member of the ACMFORMATCHOOSE structure is too small to contain the selected format.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
+           MessageBox (hwnd, L"The buffer identified by the pwfx member of the ACMFORMATCHOOSE structure is too small to contain the selected format.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
            break;
 
        case MMSYSERR_INVALFLAG:
-           MessageBox (hwnd, "At least one flag is invalid.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
+           MessageBox (hwnd, L"At least one flag is invalid.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
            break;
 
        case MMSYSERR_INVALHANDLE:
-           MessageBox (hwnd, "The specified handle is invalid.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
+           MessageBox (hwnd, L"The specified handle is invalid.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
            break;
 
        case MMSYSERR_INVALPARAM:
-           MessageBox (hwnd, "At least one parameter is invalid.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
+           MessageBox (hwnd, L"At least one parameter is invalid.", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
            break;
 
        case MMSYSERR_NODRIVER:
-           MessageBox (hwnd, "A suitable driver is not available to provide valid format selections.\n(Unsupported channel-mode selected in Sound-panel?)", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
+           MessageBox (hwnd, L"A suitable driver is not available to provide valid format selections.\n(Unsupported channel-mode selected in Sound-panel?)", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
            break;
 
        default:
-           MessageBox (hwnd, "acmFormatChoose() FAILED", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
+           MessageBox (hwnd, L"acmFormatChoose() FAILED", VersionStr, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
            break;
     }
     return 0;
@@ -502,14 +502,14 @@ static int AVIOutput_GetCOMPVARSFromRegistry (COMPVARS *pcv)
     if (pcv) {
        ss = pcv->cbSize;
        pcv->hic = 0;
-       if (regquerydata (avikey, "VideoConfigurationVars", pcv, &ss)) {
+       if (regquerydata (avikey, L"VideoConfigurationVars", pcv, &ss)) {
            pcv->hic = 0;
            pcv->lpbiIn = pcv->lpbiOut = 0;
            pcv->cbState = 0;
-           if (regquerydatasize (avikey, "VideoConfigurationState", &ss)) {
+           if (regquerydatasize (avikey, L"VideoConfigurationState", &ss)) {
                if (ss > 0) {
                    LPBYTE state = xmalloc (ss);
-                   if (regquerydata (avikey, "VideoConfigurationState", state, &ss)) {
+                   if (regquerydata (avikey, L"VideoConfigurationState", state, &ss)) {
                        pcv->hic = ICOpen (pcv->fccType, pcv->fccHandler, ICMODE_COMPRESS);
                        if (pcv->hic) {
                            ok = 1;
@@ -524,30 +524,30 @@ static int AVIOutput_GetCOMPVARSFromRegistry (COMPVARS *pcv)
        }
     }
     if (!ok) {
-       regdelete (avikey, "VideoConfigurationVars");
-       regdelete (avikey, "VideoConfigurationState");
+       regdelete (avikey, L"VideoConfigurationVars");
+       regdelete (avikey, L"VideoConfigurationState");
     }
     regclosetree (avikey);
     return ok;
 }
 
-static int AVIOutput_GetVideoCodecName (COMPVARS *pcv, char *name, int len)
+static int AVIOutput_GetVideoCodecName (COMPVARS *pcv, TCHAR *name, int len)
 {
     ICINFO icinfo = { 0 };
 
     name[0] = 0;
     if (pcv->fccHandler == mmioFOURCC ('D','I','B',' ')) {
-       strcpy (name, "Full Frames (Uncompressed)");
+       _tcscpy (name, L"Full Frames (Uncompressed)");
        return 1;
     }
     if (ICGetInfo (pcv->hic, &icinfo, sizeof (ICINFO)) != 0) {
-       if (WideCharToMultiByte (CP_ACP, 0, icinfo.szDescription, -1, name, len, NULL, NULL) != 0)
-           return 1;
+       _tcsncpy (name, icinfo.szDescription, len);
+       return 1;
     }
     return 0;
 }
 
-int AVIOutput_GetVideoCodec (char *name, int len)
+int AVIOutput_GetVideoCodec (TCHAR *name, int len)
 {
     if (AVIOutput_VideoAllocated ())
        return AVIOutput_GetVideoCodecName (pcompvars, name, len);
@@ -562,7 +562,7 @@ int AVIOutput_GetVideoCodec (char *name, int len)
     return 0;
 }
 
-int AVIOutput_ChooseVideoCodec (HWND hwnd, char *s, int len)
+int AVIOutput_ChooseVideoCodec (HWND hwnd, TCHAR *s, int len)
 {
     AVIOutput_End ();
     if (!AVIOutput_AllocateVideo ())
@@ -602,8 +602,8 @@ int AVIOutput_ChooseVideoCodec (HWND hwnd, char *s, int len)
            state = xmalloc (1);
        avikey = openavikey ();
        if (avikey) {
-           regsetdata (avikey, "VideoConfigurationState", state, ss);
-           regsetdata (avikey, "VideoConfigurationVars", pcompvars, pcompvars->cbSize);
+           regsetdata (avikey, L"VideoConfigurationState", state, ss);
+           regsetdata (avikey, L"VideoConfigurationVars", pcompvars, pcompvars->cbSize);
            storesettings (avikey);
            regclosetree (avikey);
        }
@@ -621,15 +621,15 @@ static void checkAVIsize (int force)
     int tmp_partcnt = partcnt + 1;
     int tmp_avioutput_video = avioutput_video;
     int tmp_avioutput_audio = avioutput_audio;
-    char fn[MAX_DPATH];
+    TCHAR fn[MAX_DPATH];
 
     if (!force && total_avi_size < MAX_AVI_SIZE)
        return;
     if (total_avi_size == 0)
        return;
-    strcpy (fn, avioutput_filename_tmp);
-    sprintf (avioutput_filename, "%s_%d.avi", fn, tmp_partcnt);
-    write_log ("AVI split %d at %d bytes, %d frames\n",
+    _tcscpy (fn, avioutput_filename_tmp);
+    _stprintf (avioutput_filename, L"%s_%d.avi", fn, tmp_partcnt);
+    write_log (L"AVI split %d at %d bytes, %d frames\n",
        tmp_partcnt, total_avi_size, frame_count);
     AVIOutput_End ();
     first_frame = 0;
@@ -637,13 +637,13 @@ static void checkAVIsize (int force)
     avioutput_video = tmp_avioutput_video;
     avioutput_audio = tmp_avioutput_audio;
     AVIOutput_Begin ();
-    strcpy (avioutput_filename_tmp, fn);
+    _tcscpy (avioutput_filename_tmp, fn);
     partcnt = tmp_partcnt;
 }
 
 static void dorestart (void)
 {
-    write_log ("AVIOutput: parameters changed, restarting..\n");
+    write_log (L"AVIOutput: parameters changed, restarting..\n");
     avioutput_needs_restart = 0;
     checkAVIsize (1);
 }
@@ -675,7 +675,7 @@ static int AVIOutput_AVIWriteAudio_Thread (struct avientry *ae)
            goto error;
 
        if ((err = acmStreamSize (has, ae->sndsize, &dwOutputBytes, ACM_STREAMSIZEF_SOURCE) != 0)) {
-           gui_message ("acmStreamSize() FAILED (%X)\n", err);
+           gui_message (L"acmStreamSize() FAILED (%X)\n", err);
            goto error;
        }
 
@@ -703,17 +703,17 @@ static int AVIOutput_AVIWriteAudio_Thread (struct avientry *ae)
        ash.dwDstUser = 0;
 
        if ((err = acmStreamPrepareHeader (has, &ash, 0))) {
-           gui_message ("acmStreamPrepareHeader() FAILED (%X)\n", err);
+           gui_message (L"acmStreamPrepareHeader() FAILED (%X)\n", err);
            goto error;
        }
 
        if ((err = acmStreamConvert (has, &ash, ACM_STREAMCONVERTF_BLOCKALIGN))) {
-           gui_message ("acmStreamConvert() FAILED (%X)\n", err);
+           gui_message (L"acmStreamConvert() FAILED (%X)\n", err);
            goto error;
        }
 
        if ((err = AVIStreamWrite (AVIAudioStream, StreamSizeAudio, ash.cbDstLengthUsed / pwfxDst->nBlockAlign, lpAudio, ash.cbDstLengthUsed, 0, &swritten, &written)) != 0) {
-           gui_message ("AVIStreamWrite() FAILED (%X)\n", err);
+           gui_message (L"AVIStreamWrite() FAILED (%X)\n", err);
            goto error;
        }
 
@@ -777,7 +777,7 @@ static int getFromDC (struct avientry *avie)
     BitBlt (hdcMem, (avioutput_width / 2) - (actual_width / 2), (avioutput_height / 2) - (actual_height / 2), actual_width, actual_height, hdc, 0, 0, SRCCOPY);
     SelectObject (hdcMem, hbitmapOld);
     if (GetDIBits (hdc, hbitmap, 0, avioutput_height, avie->lpVideo, (LPBITMAPINFO)lpbi, DIB_RGB_COLORS) == 0) {
-       gui_message ("GetDIBits() FAILED (%X)\n", GetLastError());
+       gui_message (L"GetDIBits() FAILED (%X)\n", GetLastError());
        ok = 0;
     }
     DeleteObject (hbitmap);
@@ -892,13 +892,13 @@ static int AVIOutput_AVIWriteVideo_Thread (struct avientry *ae)
 
        if (!frame_count) {
            if ((err = AVIStreamSetFormat (AVIVideoStream, frame_count, ae->lpbi, ae->lpbi->biSize + (ae->lpbi->biClrUsed * sizeof (RGBQUAD)))) != 0) {
-               gui_message ("AVIStreamSetFormat() FAILED (%X)\n", err);
+               gui_message (L"AVIStreamSetFormat() FAILED (%X)\n", err);
                goto error;
            }
        }
 
        if ((err = AVIStreamWrite (AVIVideoStream, frame_count, 1, ae->lpVideo, ae->lpbi->biSizeImage, 0, NULL, &written)) != 0) {
-           gui_message ("AVIStreamWrite() FAILED (%X)\n", err);
+           gui_message (L"AVIStreamWrite() FAILED (%X)\n", err);
            goto error;
        }
 
@@ -907,13 +907,13 @@ static int AVIOutput_AVIWriteVideo_Thread (struct avientry *ae)
 
     } else {
 
-       gui_message ("DirectDraw_GetDC() FAILED\n");
+       gui_message (L"DirectDraw_GetDC() FAILED\n");
        goto error;
 
     }
 
     if ((frame_count % (avioutput_fps * 10)) == 0)
-       write_log ("AVIOutput: %d frames, (%d fps)\n", frame_count, avioutput_fps);
+       write_log (L"AVIOutput: %d frames, (%d fps)\n", frame_count, avioutput_fps);
     return 1;
 
 error:
@@ -967,7 +967,7 @@ void AVIOutput_End (void)
     avioutput_enabled = 0;
 
     if (alive) {
-       write_log ("killing worker thread\n");
+       write_log (L"killing worker thread\n");
        write_comm_pipe_u32 (&workindex, 0xfffffffe, 1);
        while (alive) {
            while (comm_pipe_has_data (&queuefull))
@@ -1021,7 +1021,7 @@ void AVIOutput_Begin (void)
 {
     AVISTREAMINFO avistreaminfo; // Structure containing information about the stream, including the stream type and its sample rate
     int i, err;
-    char *ext1, *ext2;
+    TCHAR *ext1, *ext2;
     struct avientry *ae = NULL;
 
     avientryindex = -1;
@@ -1037,16 +1037,16 @@ void AVIOutput_Begin (void)
     reset_sound ();
 
     if (avioutput_audio == AVIAUDIO_WAV) {
-       ext1 = ".wav"; ext2 = ".avi";
+       ext1 = L".wav"; ext2 = L".avi";
     } else {
-       ext1 = ".avi"; ext2 = ".wav";
+       ext1 = L".avi"; ext2 = L".wav";
     }
-    if (strlen (avioutput_filename) >= 4 && !strcmpi (avioutput_filename + strlen (avioutput_filename) - 4, ext2))
-       avioutput_filename[strlen (avioutput_filename) - 4] = 0;
-    if (strlen (avioutput_filename) >= 4 && strcmpi (avioutput_filename + strlen (avioutput_filename) - 4, ext1))
-       strcat (avioutput_filename, ext1);
-    strcpy (avioutput_filename_tmp, avioutput_filename);
-    i = strlen (avioutput_filename_tmp) - 1;
+    if (_tcslen (avioutput_filename) >= 4 && !_tcsicmp (avioutput_filename + _tcslen (avioutput_filename) - 4, ext2))
+       avioutput_filename[_tcslen (avioutput_filename) - 4] = 0;
+    if (_tcslen (avioutput_filename) >= 4 && _tcsicmp (avioutput_filename + _tcslen (avioutput_filename) - 4, ext1))
+       _tcscat (avioutput_filename, ext1);
+    _tcscpy (avioutput_filename_tmp, avioutput_filename);
+    i = _tcslen (avioutput_filename_tmp) - 1;
     while (i > 0 && avioutput_filename_tmp[i] != '.') i--;
     if (i > 0)
        avioutput_filename_tmp[i] = 0;
@@ -1061,18 +1061,18 @@ void AVIOutput_Begin (void)
     DeleteFile (avioutput_filename);
 
     if (avioutput_audio == AVIAUDIO_WAV) {
-       wavfile = fopen (avioutput_filename, "wb");
+       wavfile = _tfopen (avioutput_filename, L"wb");
        if (!wavfile) {
-           gui_message ("Failed to open wave-file\n\nThis can happen if the path and or file name was entered incorrectly.\n");
+           gui_message (L"Failed to open wave-file\n\nThis can happen if the path and or file name was entered incorrectly.\n");
            goto error;
        }
        writewavheader (0);
-       write_log ("wave-output to '%s' started\n", avioutput_filename);
+       write_log (L"wave-output to '%s' started\n", avioutput_filename);
        return;
     }
 
     if (((err = AVIFileOpen (&pfile, avioutput_filename, OF_CREATE | OF_WRITE, NULL)) != 0)) {
-       gui_message ("AVIFileOpen() FAILED (Error %X)\n\nThis can happen if the path and or file name was entered incorrectly.\nRequired *.avi extension.\n", err);
+       gui_message (L"AVIFileOpen() FAILED (Error %X)\n\nThis can happen if the path and or file name was entered incorrectly.\nRequired *.avi extension.\n", err);
        goto error;
     }
 
@@ -1097,21 +1097,21 @@ void AVIOutput_Begin (void)
        //avistreaminfo.rcFrame; // doesn't apply to audio
        //avistreaminfo.dwEditCount =; // Number of times the stream has been edited. The stream handler maintains this count.
        //avistreaminfo.dwFormatChangeCount =; // Number of times the stream format has changed. The stream handler maintains this count.
-       strcpy (avistreaminfo.szName, "Audiostream"); // description of the stream.
+       _tcscpy (avistreaminfo.szName, L"Audiostream"); // description of the stream.
 
        // create the audio stream
        if ((err = AVIFileCreateStream (pfile, &AVIAudioStream, &avistreaminfo)) != 0) {
-           gui_message ("AVIFileCreateStream() FAILED (%X)\n", err);
+           gui_message (L"AVIFileCreateStream() FAILED (%X)\n", err);
            goto error;
        }
 
        if ((err = AVIStreamSetFormat (AVIAudioStream, 0, pwfxDst, sizeof (WAVEFORMATEX) + pwfxDst->cbSize)) != 0) {
-           gui_message ("AVIStreamSetFormat() FAILED (%X)\n", err);
+           gui_message (L"AVIStreamSetFormat() FAILED (%X)\n", err);
            goto error;
        }
 
        if ((err = acmStreamOpen(&has, NULL, &wfxSrc.Format, pwfxDst, NULL, 0, 0, ACM_STREAMOPENF_NONREALTIME)) != 0) {
-           gui_message ("acmStreamOpen() FAILED (%X)\n", err);
+           gui_message (L"acmStreamOpen() FAILED (%X)\n", err);
            goto error;
        }
     }
@@ -1147,11 +1147,11 @@ void AVIOutput_Begin (void)
 
        //avistreaminfo.dwEditCount =; // Number of times the stream has been edited. The stream handler maintains this count.
        //avistreaminfo.dwFormatChangeCount =; // Number of times the stream format has changed. The stream handler maintains this count.
-       strcpy (avistreaminfo.szName, "Videostream"); // description of the stream.
+       _tcscpy (avistreaminfo.szName, L"Videostream"); // description of the stream.
 
        // create the stream
        if ((err = AVIFileCreateStream (pfile, &AVIStreamInterface, &avistreaminfo)) != 0) {
-           gui_message ("AVIFileCreateStream() FAILED (%X)\n", err);
+           gui_message (L"AVIFileCreateStream() FAILED (%X)\n", err);
            goto error;
        }
 
@@ -1173,7 +1173,7 @@ void AVIOutput_Begin (void)
 
        // create a compressed stream from our uncompressed stream and a compression filter
        if ((err = AVIMakeCompressedStream (&AVIVideoStream, AVIStreamInterface, &videoOptions, NULL)) != AVIERR_OK) {
-           gui_message("AVIMakeCompressedStream() FAILED (%X)\n", err);
+           gui_message (L"AVIMakeCompressedStream() FAILED (%X)\n", err);
            goto error;
        }
     }
@@ -1181,8 +1181,8 @@ void AVIOutput_Begin (void)
     init_comm_pipe (&workindex, 20, 1);
     init_comm_pipe (&queuefull, 20, 1);
     alive = -1;
-    uae_start_thread ("aviworker", AVIOutput_worker, NULL, NULL);
-    write_log ("AVIOutput enabled: video=%d audio=%d\n", avioutput_video, avioutput_audio);
+    uae_start_thread (L"aviworker", AVIOutput_worker, NULL, NULL);
+    write_log (L"AVIOutput enabled: video=%d audio=%d\n", avioutput_video, avioutput_audio);
     return;
 
 error:
@@ -1233,7 +1233,7 @@ void AVIOutput_Initialize (void)
 
 static void *AVIOutput_worker (void *arg)
 {
-    write_log ("AVIOutput worker thread started\n");
+    write_log (L"AVIOutput worker thread started\n");
     alive = 1;
     for (;;) {
         uae_u32 idx = read_comm_pipe_u32_blocking (&workindex);
@@ -1262,7 +1262,7 @@ static void *AVIOutput_worker (void *arg)
         if (idx == 0xfffffffe || idx == 0xffffffff)
            break;
     }
-    write_log ("AVIOutput worker thread killed\n");
+    write_log (L"AVIOutput worker thread killed\n");
     alive = 0;
     return 0;
 }
@@ -1303,7 +1303,7 @@ void frame_drawn(void)
     sound_setadjust (0.0);
 
 #if 0
-    write_log ("%d ", idiff);
+    write_log (L"%d ", idiff);
     diff = idiff / 20.0;
     skipmode = pow (diff < 0 ? -diff : diff, EXP);
     if (idiff < 0)
@@ -1312,12 +1312,12 @@ void frame_drawn(void)
        skipmode = -ADJUST_SIZE;
     if (skipmode > ADJUST_SIZE)
        skipmode = ADJUST_SIZE;
-    write_log ("%d/%.2f\n", idiff, skipmode);
+    write_log (L"%d/%.2f\n", idiff, skipmode);
 
     sound_setadjust (skipmode);
 
     if (0 && !(frame_count % avioutput_fps))
-       write_log ("AVIOutput: diff=%.2f skip=%.2f (%d-%d=%d)\n", diff, skipmode,
+       write_log (L"AVIOutput: diff=%.2f skip=%.2f (%d-%d=%d)\n", diff, skipmode,
            StreamSizeAudio, StreamSizeAudioExpected, idiff);
 #endif
 }
index d764d54e2cad194585714e98a31992a8bbea76c0..29cdcdb51e57d39a1e5e579e0af139539e379bac 100644 (file)
@@ -12,52 +12,22 @@ extern int avioutput_width, avioutput_height, avioutput_bits;
 extern int avioutput_fps;
 extern DWORD avioutput_framelimiter, avioutput_nosoundoutput;
 
-extern char avioutput_filename[MAX_DPATH];
-
-extern void AVIOutput_WriteAudio(uae_u8 *sndbuffer, int sndbufsize);
-extern void AVIOutput_WriteVideo(void);
-extern int AVIOutput_ChooseAudioCodec(HWND hwnd,char*,int);
-extern int AVIOutput_GetAudioCodec(char*,int);
-extern int AVIOutput_ChooseVideoCodec(HWND hwnd,char*,int);
-extern int AVIOutput_GetVideoCodec(char*,int);
-extern void AVIOutput_Restart(void);
-extern void AVIOutput_End(void);
-extern void AVIOutput_Begin(void);
-extern void AVIOutput_Release(void);
-extern void AVIOutput_Initialize(void);
-extern void AVIOutput_RGBinfo(int,int,int,int,int,int);
-extern void AVIOutput_GetSettings(void);
-extern void AVIOutput_SetSettings(void);
+extern TCHAR avioutput_filename[MAX_DPATH];
+
+extern void AVIOutput_WriteAudio (uae_u8 *sndbuffer, int sndbufsize);
+extern void AVIOutput_WriteVideo (void);
+extern int AVIOutput_ChooseAudioCodec (HWND hwnd,TCHAR*,int);
+extern int AVIOutput_GetAudioCodec (TCHAR*,int);
+extern int AVIOutput_ChooseVideoCodec (HWND hwnd,TCHAR*,int);
+extern int AVIOutput_GetVideoCodec (TCHAR*,int);
+extern void AVIOutput_Restart (void);
+extern void AVIOutput_End (void);
+extern void AVIOutput_Begin (void);
+extern void AVIOutput_Release (void);
+extern void AVIOutput_Initialize (void);
+extern void AVIOutput_RGBinfo (int,int,int,int,int,int);
+extern void AVIOutput_GetSettings (void);
+extern void AVIOutput_SetSettings (void);
 
 #define AVIAUDIO_AVI 1
 #define AVIAUDIO_WAV 2
-
-/*
-extern int avioutput_pause;
-
-extern int avioutput_bits;
-
-extern int avioutput_fps;
-
-extern int avioutput_width, avioutput_height;
-
-extern int avioutput_video, avioutput_audio;
-
-extern int avioutput_init;
-
-extern int frame_count;
-
-extern char avioutput_filename[MAX_DPATH];
-
-extern void AviOutputClearAudioCodec(HWND hwnd);
-extern void AviOutputClearVideoCodec(HWND hwnd);
-
-extern void avioutput_screenshot(void);
-
-extern void AVIWriteAudio(uae_u16* sndbuffer, int sndbufsize);
-extern void AVIWriteVideo(void);
-extern LPSTR AVIChooseAudioCodec(HWND hwnd);
-extern LPSTR AVIChooseVideoCodec(HWND hwnd);
-extern void AVIUninitialize(void);
-extern void AVIInitialize(void);
-*/
\ No newline at end of file
index 42c0fe9d0677812f476565be61b84acdb2287197..07176536864de8179f3b4eb46e00026db2a23997 100644 (file)
@@ -39,7 +39,7 @@ struct scsi_info {
     int type;
     int mediainserted;
     uae_u8 *buf;
-    char label[100];
+    TCHAR label[100];
     SCSI *handle;
     int isatapi;
     int removable;
@@ -47,7 +47,7 @@ struct scsi_info {
 static struct scsi_info si[MAX_TOTAL_DEVICES];
 static int unitcnt;
 
-static int getversion(const char *name, VS_FIXEDFILEINFO *ver)
+static int getversion(const TCHAR *name, VS_FIXEDFILEINFO *ver)
 {
     int ok = FALSE;
     DWORD  dwVersionHandle, dwFileVersionInfoSize;
@@ -63,7 +63,7 @@ static int getversion(const char *name, VS_FIXEDFILEINFO *ver)
                    if(vsFileInfo) {
                        memcpy (ver, vsFileInfo, sizeof (*ver));
                        ok = TRUE;
-                       write_log ("%s version %d.%d.%d.%d\n", name,
+                       write_log (L"%s version %d.%d.%d.%d\n", name,
                            vsFileInfo->dwFileVersionMS >> 16,
                            vsFileInfo->dwFileVersionMS & 0xffff,
                            vsFileInfo->dwFileVersionLS >> 16,
@@ -77,12 +77,12 @@ static int getversion(const char *name, VS_FIXEDFILEINFO *ver)
     return ok;
 }
 
-const char *get_aspi_path(int aspitype)
+const TCHAR *get_aspi_path(int aspitype)
 {
     static int nero, adaptec, frog;
-    static char path_nero[MAX_DPATH];
-    static char path_adaptec[MAX_DPATH];
-    static const char *path_frog = "FrogAspi.dll";
+    static TCHAR path_nero[MAX_DPATH];
+    static TCHAR path_adaptec[MAX_DPATH];
+    static const TCHAR *path_frog = L"FrogAspi.dll";
     VS_FIXEDFILEINFO ver;
 
     switch (aspitype)
@@ -107,11 +107,11 @@ const char *get_aspi_path(int aspitype)
            if (nero < 0)
                return NULL;
            nero = -1;
-           if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\Ahead\\shared", 0, KEY_READ, &key) == ERROR_SUCCESS) {
-               if (RegQueryValueEx (key, "NeroAPI", 0, &type, (LPBYTE)path_nero, &size) == ERROR_SUCCESS) {
-                   if (path_nero[strlen(path_nero) - 1] != '\\')
-                       strcat (path_nero, "\\");
-                   strcat (path_nero, "wnaspi32.dll");
+           if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Ahead\\shared", 0, KEY_READ, &key) == ERROR_SUCCESS) {
+               if (RegQueryValueEx (key, L"NeroAPI", 0, &type, (LPBYTE)path_nero, &size) == ERROR_SUCCESS) {
+                   if (path_nero[_tcslen (path_nero) - 1] != '\\')
+                       _tcscat (path_nero, L"\\");
+                   _tcscat (path_nero, L"wnaspi32.dll");
                    RegCloseKey (key);
                    if (getversion(path_nero, &ver)) {
                        if (ver.dwFileVersionMS >= 0x20000) {
@@ -133,7 +133,7 @@ const char *get_aspi_path(int aspitype)
            if (adaptec < 0)
                return NULL;
            adaptec = -1;
-           strcpy (path_adaptec, "wnaspi32.dll");
+           _tcscpy (path_adaptec, L"wnaspi32.dll");
            if (getversion(path_adaptec, &ver)) {
                if (ver.dwFileVersionMS >= 0x40000 || ver.dwFileVersionMS < 0x10000) {
                    adaptec = 1;
@@ -157,7 +157,7 @@ static int ha_inquiry (SCSI *scgp, int id, SRB_HAInquiry *ip)
 
     Status = pfnSendASPI32Command((LPSRB)ip);
     if (log_scsi)
-       write_log ("ASPI: S=%d ha=%d, ID=%d, M='%s', Id='%s'\n",
+       write_log (L"ASPI: S=%d ha=%d, ID=%d, M='%s', Id='%s'\n",
            Status, ip->HA_Count, ip->HA_SCSI_ID, ip->HA_ManagerId, ip->HA_Identifier);
     if (ip->SRB_Status != SS_COMP)
        return -1;
@@ -166,7 +166,7 @@ static int ha_inquiry (SCSI *scgp, int id, SRB_HAInquiry *ip)
 
 static int open_driver (SCSI *scgp)
 {
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
     DWORD astatus;
     BYTE HACount;
     BYTE ASPIStatus;
@@ -180,35 +180,35 @@ static int open_driver (SCSI *scgp)
        return TRUE;
 
     nero = frog = 0;
-    strcpy (path, "WNASPI32");
+    _tcscpy (path, L"WNASPI32");
     if (currprefs.win32_uaescsimode == UAESCSI_NEROASPI) {
-       const char *p = get_aspi_path(1);
+       const TCHAR *p = get_aspi_path(1);
        if (p) {
-           strcpy (path, p);
+           _tcscpy (path, p);
            nero = 1;
        }
     } else if (currprefs.win32_uaescsimode == UAESCSI_FROGASPI) {
-       const char *p = get_aspi_path(2);
+       const TCHAR *p = get_aspi_path(2);
        if (p) {
-           strcpy (path, p);
+           _tcscpy (path, p);
            frog = 1;
        }
     }
     /*
      * Load the ASPI library
      */
-    write_log ("ASPI: driver location '%s'\n", path);
-    hAspiLib = LoadLibrary(path);
+    write_log (L"ASPI: driver location '%s'\n", path);
+    hAspiLib = LoadLibrary (path);
     if (hAspiLib == NULL && (nero || frog)) {
-       write_log ("ASPI: NERO/FROG ASPI failed to load, falling back to default\n");
-       hAspiLib = LoadLibrary("WNASPI32");
+       write_log (L"ASPI: NERO/FROG ASPI failed to load, falling back to default\n");
+       hAspiLib = LoadLibrary (L"WNASPI32");
     }
 
     /*
      * Check if ASPI library is loaded correctly
      */
     if (hAspiLib == NULL) {
-       write_log ("ASPI: failed to load wnaspi32.dll\n");
+       write_log (L"ASPI: failed to load wnaspi32.dll\n");
        return FALSE;
     }
     /*
@@ -219,7 +219,7 @@ static int open_driver (SCSI *scgp)
     pfnSendASPI32Command = (DWORD(*)(LPSRB))GetProcAddress(hAspiLib, "SendASPI32Command");
 
     if (pfnGetASPI32SupportInfo == NULL || pfnSendASPI32Command == NULL) {
-       write_log ("ASPI: obsolete wnaspi32.dll found\n");
+       write_log (L"ASPI: obsolete wnaspi32.dll found\n");
        return FALSE;
     }
 
@@ -237,15 +237,15 @@ static int open_driver (SCSI *scgp)
     ASPIStatus = HIBYTE(LOWORD(astatus));
     HACount    = LOBYTE(LOWORD(astatus));
 
-    write_log ("ASPI: open_driver %X HostASPIStatus=0x%x HACount=0x%x\n", astatus, ASPIStatus, HACount);
+    write_log (L"ASPI: open_driver %X HostASPIStatus=0x%x HACount=0x%x\n", astatus, ASPIStatus, HACount);
 
     if (ASPIStatus != SS_COMP && ASPIStatus != SS_NO_ADAPTERS) {
-       write_log ("ASPI: Could not find any host adapters, ASPIStatus == 0x%02X\n", ASPIStatus);
+       write_log (L"ASPI: Could not find any host adapters, ASPIStatus == 0x%02X\n", ASPIStatus);
        return FALSE;
     }
     busses = HACount;
 
-    write_log ("ASPI: open_driver HostASPIStatus=0x%x HACount=0x%x\n", ASPIStatus, HACount);
+    write_log (L"ASPI: open_driver HostASPIStatus=0x%x HACount=0x%x\n", ASPIStatus, HACount);
 
     for (i=0; i < busses; i++) {
        SRB_HAInquiry s;
@@ -361,7 +361,7 @@ static SCSI *openscsi (int busno, int tgt, int tlun)
     if (busno >= MAX_SCG || tgt >= MAX_TGT || tlun >= MAX_LUN) {
        errno = EINVAL;
        if (log_scsi)
-           write_log ("ASPI: Illegal value for busno, target or lun '%d,%d,%d'\n", busno, tgt, tlun);
+           write_log (L"ASPI: Illegal value for busno, target or lun '%d,%d,%d'\n", busno, tgt, tlun);
        return 0;
     }
     /*
@@ -407,7 +407,7 @@ static void scsi_debug (SCSI *scgp, SRB_ExecSCSICmd *s)
        return;
     if (scanphase)
        return;
-    write_log ("ASPI EXEC_SCSI: bus=%d,target=%d,lun=%d\n",
+    write_log (L"ASPI EXEC_SCSI: bus=%d,target=%d,lun=%d\n",
        s->SRB_HaId, s->SRB_Target, s->SRB_Lun);
     scsi_log_before (scgp->scmd->cdb.cmd_cdb, scgp->scmd->cdb_len,
        (s->SRB_Flags & SRB_DIR_OUT) ? s->SRB_BufPointer : 0, s->SRB_BufLen);
@@ -493,7 +493,7 @@ static int scsiabort(SCSI *scgp, SRB_ExecSCSICmd *sp)
     SRB_Abort s;
 
     if (log_scsi)
-       write_log ("ASPI: Attempting to abort SCSI command\n");
+       write_log (L"ASPI: Attempting to abort SCSI command\n");
     /*
      * Set structure variables
      */
@@ -510,11 +510,11 @@ static int scsiabort(SCSI *scgp, SRB_ExecSCSICmd *sp)
      */
     if (s.SRB_Status != SS_COMP) {
        if (log_scsi)
-           write_log ("ASPI: Abort ERROR! 0x%08X\n", s.SRB_Status);
+           write_log (L"ASPI: Abort ERROR! 0x%08X\n", s.SRB_Status);
        return FALSE;
     }
     if (log_scsi)
-       write_log ("ASPI: Abort SCSI command completed\n");
+       write_log (L"ASPI: Abort SCSI command completed\n");
     /*
      * Everything went OK
      */
@@ -546,7 +546,7 @@ static int scsicmd(SCSI *scgp)
        sp->error = SCG_FATAL;
        sp->ux_errno = EINVAL;
        if (log_scsi)
-           write_log ("ASPI: sp->cdb_len > sizeof(SRB_ExecSCSICmd.CDBByte). Fatal error in scgo_send, exiting...\n");
+           write_log (L"ASPI: sp->cdb_len > sizeof(SRB_ExecSCSICmd.CDBByte). Fatal error in scgo_send, exiting...\n");
        return -1;
     }
     /*
@@ -619,11 +619,11 @@ static int scsicmd(SCSI *scgp)
 
     if (s.SRB_Status != SS_COMP) {
        if (log_scsi && s.SRB_Status != 0x82)
-           write_log ("ASPI: Error in scgo_send: s.SRB_Status is 0x%x\n", s.SRB_Status);
+           write_log (L"ASPI: Error in scgo_send: s.SRB_Status is 0x%x\n", s.SRB_Status);
        set_error(&s, sp); /* Set error flags */
        copy_sensedata(&s, sp); /* Copy sense and status */
        if (log_scsi && s.SRB_Status != 0x82)
-           write_log ("ASPI: Mapped to: error %d errno: %d\n", sp->error, sp->ux_errno);
+           write_log (L"ASPI: Mapped to: error %d errno: %d\n", sp->error, sp->ux_errno);
        return 1;
     }
     /*
@@ -658,7 +658,7 @@ static int scsierr(SCSI *scgp)
     register struct scg_cmd *cp = scgp->scmd;
 
     if(cp->error != SCG_NO_ERROR ||
-       cp->ux_errno != 0 || *(u_char *)&cp->scb != 0)
+       cp->ux_errno != 0 || *(u_char*)&cp->scb != 0)
        return -1;
     return 0;
 }
@@ -666,7 +666,7 @@ static int scsierr(SCSI *scgp)
 static void scan_scsi_bus (SCSI *scgp, int flags)
 {
     /* add all units we find */
-    write_log ("ASPI: SCSI scan starting..\n");
+    write_log (L"ASPI: SCSI scan starting..\n");
     scanphase = 1;
     for (scgp->addr.scsibus=0; scgp->addr.scsibus < 8; scgp->addr.scsibus++) {
        if (!scsi_havebus(scgp, scgp->addr.scsibus))
@@ -678,29 +678,29 @@ static void scan_scsi_bus (SCSI *scgp, int flags)
                continue;
            for (scgp->addr.lun=0; scgp->addr.lun < 8; scgp->addr.lun++) {
                if (!inquiry (scgp, &inq, sizeof(inq))) {
-                   write_log ("ASPI: %d:%d:%d ", scgp->addr.scsibus,scgp->addr.target,scgp->addr.lun);
-                   write_log ("'%.8s' ", inq.vendor_info);
-                   write_log ("'%.16s' ", inq.prod_ident);
-                   write_log ("'%.4s' ", inq.prod_revision);
+                   write_log (L"ASPI: %d:%d:%d ", scgp->addr.scsibus,scgp->addr.target,scgp->addr.lun);
+                   write_log (L"'%.8s' ", inq.vendor_info);
+                   write_log (L"'%.16s' ", inq.prod_ident);
+                   write_log (L"'%.4s' ", inq.prod_revision);
                    if (unitcnt < MAX_TOTAL_DEVICES) {
                        struct scsi_info *cis = &si[unitcnt];
                        int use = 0;
-                       write_log ("[");
+                       write_log (L"[");
                        if (inq.type == INQ_ROMD) {
-                           write_log ("CDROM");
+                           write_log (L"CDROM");
                            use = 1;
                        } else if ((inq.type >= INQ_SEQD && inq.type < INQ_COMM && aspi_allow_misc) || aspi_allow_all) {
-                           write_log ("%d", inq.type);
+                           write_log (L"%d", inq.type);
                            use = 1;
                        } else {
-                           write_log ("<%d>", inq.type);
+                           write_log (L"<%d>", inq.type);
                        }
                        if (inq.ansi_version == 0) {
-                           write_log (",ATAPI");
+                           write_log (L",ATAPI");
                            cis->isatapi = 1;
                        } else
-                           write_log (",SCSI");
-                       write_log ("]");
+                           write_log (L",SCSI");
+                       write_log (L"]");
                        if (use) {
                            unitcnt++;
                            cis->buf = malloc (DEVICE_SCSI_BUFSIZE);
@@ -709,15 +709,15 @@ static void scan_scsi_bus (SCSI *scgp, int flags)
                            cis->lun = scgp->addr.lun;
                            cis->type = inq.type;
                            cis->removable = inq.removable;
-                           sprintf (cis->label, "%.8s %.16s %.4s", inq.vendor_info, inq.prod_ident, inq.prod_revision);
+                           _stprintf (cis->label, L"%.8s %.16s %.4s", inq.vendor_info, inq.prod_ident, inq.prod_revision);
                        }
                    }
-                   write_log ("\n");
+                   write_log (L"\n");
                }
            }
        }
     }
-    write_log ("ASPI: SCSI scan ended\n");
+    write_log (L"ASPI: SCSI scan ended\n");
     scanphase = 0;
 }
 
@@ -843,12 +843,12 @@ static int open_scsi_device (int unitnum)
     if (unitnum >= unitcnt)
        return 0;
     if (log_scsi)
-       write_log ("ASPI: opening %d:%d:%d (%d)\n", si[unitnum].scsibus, si[unitnum].target, si[unitnum].lun, unitnum);
+       write_log (L"ASPI: opening %d:%d:%d (%d)\n", si[unitnum].scsibus, si[unitnum].target, si[unitnum].lun, unitnum);
     si[unitnum].handle = openscsi (si[unitnum].scsibus, si[unitnum].target, si[unitnum].lun);
     if (si[unitnum].handle)
        si[unitnum].mediainserted = mediacheck (unitnum);
     if (log_scsi)
-       write_log ("unit %d: %s\n", unitnum, si[unitnum].mediainserted ? "CD inserted" : "Drive empty");
+       write_log (L"unit %d: %s\n", unitnum, si[unitnum].mediainserted ? "CD inserted" : "Drive empty");
     return si[unitnum].handle ? 1 : 0;
 }
 
@@ -949,15 +949,15 @@ static struct device_info *info_device (int unitnum, struct device_info *di)
     mediacheck_full (unitnum, di);
     di->id = unitnum + 1;
     di->removable = sif->removable;
-    strcpy (di->label, sif->label);
+    _tcscpy (di->label, sif->label);
     if (log_scsi) {
-       write_log ("MI=%d TP=%d WP=%d CY=%d BK=%d '%s'\n",
+       write_log (L"MI=%d TP=%d WP=%d CY=%d BK=%d '%s'\n",
            di->media_inserted, di->type, di->write_protected, di->cylinders, di->bytespersector, di->label);
     }
     return di;
 }
 
-void win32_aspi_media_change (char driveletter, int insert)
+void win32_aspi_media_change (TCHAR driveletter, int insert)
 {
     int i, now;
 
@@ -965,7 +965,7 @@ void win32_aspi_media_change (char driveletter, int insert)
        if (si[i].type == INQ_ROMD) {
            now = mediacheck (i);
            if (now != si[i].mediainserted) {
-               write_log ("ASPI: media change %c %d\n", driveletter, insert);
+               write_log (L"ASPI: media change %c %d\n", driveletter, insert);
                si[i].mediainserted = now;
                scsi_do_disk_change (i + 1, insert);
            }
index 32cff49329dc515bdaf4e5a27dde67edb3403605..1b0446ef8bc0cf80b068aa2d6757987fc385e258 100644 (file)
@@ -32,8 +32,8 @@
 struct dev_info_ioctl {
     HANDLE h;
     uae_u8 *tempbuffer;
-    char drvletter;
-    char devname[30];
+    TCHAR drvletter;
+    TCHAR devname[30];
     int mediainserted;
     int type;
     int blocksize;
@@ -62,58 +62,58 @@ static void reseterrormode (int unitnum)
 static void close_device (int unitnum);
 static int open_device (int unitnum);
 
-static void mcierr(char *str, DWORD err)
+static void mcierr(TCHAR *str, DWORD err)
 {
-    char es[1000];
+    TCHAR es[1000];
     if (err == MMSYSERR_NOERROR)
        return;
-    if (mciGetErrorString(err, es, sizeof es))
-       write_log ("MCIErr: %s: %d = '%s'\n", str, err, es);
+    if (mciGetErrorString (err, es, sizeof es))
+       write_log (L"MCIErr: %s: %d = '%s'\n", str, err, es);
 }
 
-static int win32_error (int unitnum, const char *format,...)
+static int win32_error (int unitnum, const TCHAR *format,...)
 {
     LPVOID lpMsgBuf;
     va_list arglist;
-    char buf[1000];
-    DWORD err = GetLastError();
+    TCHAR buf[1000];
+    DWORD err = GetLastError ();
 
     if (err == ERROR_WRONG_DISK) {
-       write_log ("IOCTL: media change, re-opening device\n");
+       write_log (L"IOCTL: media change, re-opening device\n");
        close_device (unitnum);
        if (!open_device (unitnum))
-           write_log ("IOCTL: re-opening failed!\n");
+           write_log (L"IOCTL: re-opening failed!\n");
        return -1;
     }
     va_start (arglist, format );
-    vsprintf (buf, format, arglist);
-    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
+    _vstprintf (buf, format, arglist);
+    FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR)&lpMsgBuf, 0, NULL);
     if (log_scsi)
-       write_log ("IOCTL: unit=%d %s,%d: %s\n", unitnum, buf, err, (char*)lpMsgBuf);
-    va_end(arglist);
+       write_log (L"IOCTL: unit=%d %s,%d: %s\n", unitnum, buf, err, (TCHAR*)lpMsgBuf);
+    va_end (arglist);
     return err;
 }
 
-static int close_createfile(int unitnum)
+static int close_createfile (int unitnum)
 {
     struct dev_info_ioctl *ciw = &ciw32[unitnum];
 
     ciw->fullaccess = 0;
     if (ciw->h != INVALID_HANDLE_VALUE) {
        if (log_scsi)
-           write_log ("IOCTL: IOCTL close\n");
-       CloseHandle(ciw->h);
+           write_log (L"IOCTL: IOCTL close\n");
+       CloseHandle (ciw->h);
        if (log_scsi)
-           write_log ("IOCTL: IOCTL close completed\n");
+           write_log (L"IOCTL: IOCTL close completed\n");
        ciw->h = INVALID_HANDLE_VALUE;
        return 1;
     }
     return 0;
 }
 
-static int close_mci(int unitnum)
+static int close_mci (int unitnum)
 {
     struct dev_info_ioctl *ciw = &ciw32[unitnum];
     MCI_GENERIC_PARMS gp = { 0 };
@@ -121,18 +121,18 @@ static int close_mci(int unitnum)
     ciw->playend = -1;
     if (ciw->mciid > 0) {
        if (log_scsi)
-           write_log ("IOCTL: MCI close\n");
-       mcierr("MCI_STOP", mciSendCommand(ciw->mciid, MCI_STOP, MCI_WAIT, (DWORD_PTR)&gp));
-       mcierr("MCI_CLOSE", mciSendCommand(ciw->mciid, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&gp));
+           write_log (L"IOCTL: MCI close\n");
+       mcierr (L"MCI_STOP", mciSendCommand (ciw->mciid, MCI_STOP, MCI_WAIT, (DWORD_PTR)&gp));
+       mcierr (L"MCI_CLOSE", mciSendCommand (ciw->mciid, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&gp));
        if (log_scsi)
-           write_log ("IOCTL: MCI close completed\n");
+           write_log (L"IOCTL: MCI close completed\n");
        ciw->mciid = 0;
        return 1;
     }
     return 0;
 }
 
-static int open_createfile(int unitnum, int fullaccess)
+static int open_createfile (int unitnum, int fullaccess)
 {
     struct dev_info_ioctl *ciw = &ciw32[unitnum];
     int closed = 0;
@@ -146,52 +146,52 @@ static int open_createfile(int unitnum, int fullaccess)
            return 1;
        }
     }
-    closed = close_mci(unitnum);
+    closed = close_mci (unitnum);
     if (log_scsi)
-       write_log ("IOCTL: opening IOCTL %s\n", ciw->devname);
+       write_log (L"IOCTL: opening IOCTL %s\n", ciw->devname);
     for (;;) {
        if (fullaccess) {
-           ciw->h = CreateFile(ciw->devname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+           ciw->h = CreateFile (ciw->devname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
            if (ciw->h != INVALID_HANDLE_VALUE)
                ciw->fullaccess = 1;
        } else {
            DWORD flags = GENERIC_READ;
-           ciw->h = CreateFile(ciw->devname, flags, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+           ciw->h = CreateFile (ciw->devname, flags, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
            if (ciw->h == INVALID_HANDLE_VALUE) {
-               ciw->h = CreateFile(ciw->devname, flags, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+               ciw->h = CreateFile (ciw->devname, flags, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                if (ciw->h == INVALID_HANDLE_VALUE) {
                    flags |= GENERIC_WRITE;
-                   ciw->h = CreateFile(ciw->devname, flags, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+                   ciw->h = CreateFile (ciw->devname, flags, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
                }
            }
        }
         if (ciw->h == INVALID_HANDLE_VALUE) {
-           DWORD err = GetLastError();
+           DWORD err = GetLastError ();
            if (err == ERROR_SHARING_VIOLATION) {
                if (closed && cnt > 0) {
                    cnt--;
-                   Sleep(10);
+                   Sleep (10);
                    continue;
                }
            }
            if (closed)
-               write_log ("IOCTL: failed to re-open '%s', err=%d\n", ciw->devname, GetLastError());
+               write_log (L"IOCTL: failed to re-open '%s', err=%d\n", ciw->devname, GetLastError());
            return 0;
        }
        break;
     }
-    if (!DeviceIoControl(ciw->h, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &len, NULL))
-       write_log ("IOCTL: FSCTL_ALLOW_EXTENDED_DASD_IO returned %d\n", GetLastError());
+    if (!DeviceIoControl (ciw->h, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &len, NULL))
+       write_log (L"IOCTL: FSCTL_ALLOW_EXTENDED_DASD_IO returned %d\n", GetLastError());
     if (log_scsi)
-       write_log ("IOCTL: IOCTL open completed\n");
+       write_log (L"IOCTL: IOCTL open completed\n");
     return 1;
 }
 
-static int open_mci(int unitnum)
+static int open_mci (int unitnum)
 {
     struct dev_info_ioctl *ciw = &ciw32[unitnum];
-    char elname[10];
-    char alname[100];
+    TCHAR elname[10];
+    TCHAR alname[100];
     MCI_OPEN_PARMS mciOpen;
     DWORD err, flags;
     int closed = 0;
@@ -199,25 +199,25 @@ static int open_mci(int unitnum)
     if (ciw->mciid > 0 || MCICDA == 0)
        return 1;
     ciw->playend = -1;
-    closed = close_createfile(unitnum);
+    closed = close_createfile (unitnum);
     if (log_scsi)
-       write_log ("IOCTL: MCI opening %c:\n", ciw->drvletter);
-    memset (&mciOpen, 0, sizeof(mciOpen));
-    mciOpen.lpstrDeviceType = (LPSTR)MCI_DEVTYPE_CD_AUDIO;
-    sprintf(elname,"%c:", ciw->drvletter);
-    sprintf(alname,"CD%u:", GetCurrentTime());
+       write_log (L"IOCTL: MCI opening %c:\n", ciw->drvletter);
+    memset (&mciOpen, 0, sizeof (mciOpen));
+    mciOpen.lpstrDeviceType = (LPWSTR)MCI_DEVTYPE_CD_AUDIO;
+    _stprintf (elname, L"%c:", ciw->drvletter);
+    _stprintf (alname, L"CD%u:", GetCurrentTime ());
     mciOpen.lpstrElementName = elname;
     mciOpen.lpstrAlias = alname;
     flags = MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE | MCI_OPEN_ALIAS | MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | MCI_WAIT;
-    err = mciSendCommand(0, MCI_OPEN, flags, (DWORD)(LPVOID)&mciOpen);
+    err = mciSendCommand (0, MCI_OPEN, flags, (DWORD)(LPVOID)&mciOpen);
     ciw->mciid = mciOpen.wDeviceID;
     if (err != MMSYSERR_NOERROR) {
        if (closed)
-           mcierr("MCI_OPEN", err);
+           mcierr (L"MCI_OPEN", err);
        return 0;
     }
     if (log_scsi)
-       write_log ("IOCTL: MCI open completed\n");
+       write_log (L"IOCTL: MCI open completed\n");
     return 1;
 }
 
@@ -230,9 +230,9 @@ static int ioctl_command_pause (int unitnum, int paused)
 
        MCI_GENERIC_PARMS gp = { 0 };
        if (paused)
-           mcierr("MCI_PAUSE", mciSendCommand(ciw->mciid, MCI_PAUSE, MCI_WAIT, (DWORD_PTR)&gp));
+           mcierr(L"MCI_PAUSE", mciSendCommand (ciw->mciid, MCI_PAUSE, MCI_WAIT, (DWORD_PTR)&gp));
        else
-           mcierr("MCI_RESUME", mciSendCommand(ciw->mciid, MCI_RESUME, MCI_WAIT, (DWORD_PTR)&gp));
+           mcierr(L"MCI_RESUME", mciSendCommand (ciw->mciid, MCI_RESUME, MCI_WAIT, (DWORD_PTR)&gp));
 
     } else {
 
@@ -244,7 +244,7 @@ static int ioctl_command_pause (int unitnum, int paused)
            seterrormode (unitnum);
            if (!DeviceIoControl(ciw32[unitnum].h, command, NULL, 0, NULL, 0, &len, NULL)) {
                reseterrormode (unitnum);
-               if (win32_error (unitnum, paused ? "IOCTL_CDROM_PAUSE_AUDIO" : "IOCTL_CDROM_RESUME_AUDIO") < 0)
+               if (win32_error (unitnum, paused ? L"IOCTL_CDROM_PAUSE_AUDIO" : L"IOCTL_CDROM_RESUME_AUDIO") < 0)
                    continue;
                return 0;
            }
@@ -263,7 +263,7 @@ static int ioctl_command_stop (int unitnum)
     if (ciw->mciid > 0) {
 
        MCI_GENERIC_PARMS gp = { 0 };
-       mcierr("MCI_STOP", mciSendCommand(ciw->mciid, MCI_STOP, MCI_WAIT, (DWORD_PTR)&gp));
+       mcierr (L"MCI_STOP", mciSendCommand (ciw->mciid, MCI_STOP, MCI_WAIT, (DWORD_PTR)&gp));
        ciw->playend = -1;
 
     } else {
@@ -273,9 +273,9 @@ static int ioctl_command_stop (int unitnum)
 
        while (cnt-- > 0) {
            seterrormode (unitnum);
-           if(!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &len, NULL)) {
+           if(!DeviceIoControl (ciw32[unitnum].h, IOCTL_CDROM_STOP_AUDIO, NULL, 0, NULL, 0, &len, NULL)) {
                reseterrormode (unitnum);
-               if (win32_error (unitnum, "IOCTL_CDROM_STOP_AUDIO") < 0)
+               if (win32_error (unitnum, L"IOCTL_CDROM_STOP_AUDIO") < 0)
                    continue;
                return 0;
            }
@@ -299,10 +299,10 @@ static int ioctl_command_play (int unitnum, uae_u32 start, uae_u32 end, int scan
        MCI_PLAY_PARMS playParms = {0};
 
        setParms.dwTimeFormat = MCI_FORMAT_MSF;
-       mcierr("MCI_SET", mciSendCommand(ciw->mciid, MCI_SET, MCI_SET_TIME_FORMAT | MCI_WAIT, (DWORD_PTR)&setParms));
+       mcierr (L"MCI_SET", mciSendCommand (ciw->mciid, MCI_SET, MCI_SET_TIME_FORMAT | MCI_WAIT, (DWORD_PTR)&setParms));
        playParms.dwFrom = MCI_MAKE_MSF((start >> 16) & 0xff, (start >> 8) & 0xff, start & 0xff);
        playParms.dwTo = MCI_MAKE_MSF((end >> 16) & 0xff, (end >> 8) & 0xff, end & 0xff);
-       mcierr("MCI_PLAY", mciSendCommand(ciw->mciid, MCI_PLAY, MCI_FROM | MCI_TO, (DWORD_PTR)&playParms));
+       mcierr (L"MCI_PLAY", mciSendCommand (ciw->mciid, MCI_PLAY, MCI_FROM | MCI_TO, (DWORD_PTR)&playParms));
        ciw->playend = end;
 
     } else {
@@ -315,13 +315,13 @@ static int ioctl_command_play (int unitnum, uae_u32 start, uae_u32 end, int scan
        {
        VOLUME_CONTROL vc;
        if (!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_GET_VOLUME, NULL, 0, &vc, sizeof(vc), &len, NULL))
-           write_log ("IOCTL_CDROM_GET_VOLUME %d\n", GetLastError());
+           write_log (L"IOCTL_CDROM_GET_VOLUME %d\n", GetLastError());
        vc.PortVolume[0] = 0xff;
        vc.PortVolume[1] = 0xff;
        vc.PortVolume[2] = 0xff;
        vc.PortVolume[3] = 0xff;
        if (!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_SET_VOLUME, &vc, sizeof(vc), NULL, 0, &len, NULL))
-           write_log ("IOCTL_CDROM_SET_VOLUME %d\n", GetLastError());
+           write_log (L"IOCTL_CDROM_SET_VOLUME %d\n", GetLastError());
        }
 #endif
 
@@ -333,9 +333,9 @@ static int ioctl_command_play (int unitnum, uae_u32 start, uae_u32 end, int scan
            pa.EndingS = end >> 8;
            pa.EndingF = end >> 0;
            seterrormode (unitnum);
-           if (!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_PLAY_AUDIO_MSF, &pa, sizeof(pa), NULL, 0, &len, NULL)) {
+           if (!DeviceIoControl (ciw32[unitnum].h, IOCTL_CDROM_PLAY_AUDIO_MSF, &pa, sizeof(pa), NULL, 0, &len, NULL)) {
                reseterrormode (unitnum);
-               if (win32_error (unitnum, "IOCTL_CDROM_PLAY_AUDIO_MSF %02.%02.%02-%02.%02.%02",
+               if (win32_error (unitnum, L"IOCTL_CDROM_PLAY_AUDIO_MSF %02.%02.%02-%02.%02.%02",
                    pa.StartingM, pa.StartingS, pa.StartingF, pa.EndingM, pa.EndingS, pa.EndingF ) < 0) continue;
                return 0;
            }
@@ -378,22 +378,22 @@ static uae_u8 *ioctl_command_qcode (int unitnum)
        uae_u32 pos, pos2;
        int trk;
 
-       memset(buf, 0, sizeof buf);
-       memset(&mciStatusParms, 0, sizeof mciStatusParms);
+       memset (buf, 0, sizeof buf);
+       memset (&mciStatusParms, 0, sizeof mciStatusParms);
        mciStatusParms.dwItem = MCI_STATUS_MODE;
-       err = mciSendCommand(ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
+       err = mciSendCommand (ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
        if (err != MMSYSERR_NOERROR)
            return 0;
        mode = mciStatusParms.dwReturn;
        mciStatusParms.dwItem = MCI_STATUS_CURRENT_TRACK;
-       err = mciSendCommand(ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
+       err = mciSendCommand (ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
        if (err != MMSYSERR_NOERROR)
            return 0;
        trk = mciStatusParms.dwReturn - 1;
        if (trk < 0)
            trk = 0;
        mciStatusParms.dwItem = MCI_STATUS_POSITION;
-       err = mciSendCommand(ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
+       err = mciSendCommand (ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
        if (err != MMSYSERR_NOERROR)
            return 0;
        pos = (((mciStatusParms.dwReturn >> 16) & 0xff) << 0) | (((mciStatusParms.dwReturn >> 8) & 0xff) << 8) | (((mciStatusParms.dwReturn >> 0) & 0xff) << 16);
@@ -415,12 +415,12 @@ static uae_u8 *ioctl_command_qcode (int unitnum)
        p[6] = (pos >> 8) & 0xff;
        p[7] = (pos >> 0) & 0xff;
 
-       pos = msf2lsn(pos);
+       pos = msf2lsn (pos);
        pos2 = (ciw->toc.TrackData[trk].Address[1] << 16) | (ciw->toc.TrackData[trk].Address[2] << 8) | (ciw->toc.TrackData[trk].Address[3] << 0);
-       pos -= msf2lsn(pos2);
+       pos -= msf2lsn (pos2);
        if (pos < 0)
            pos = 0;
-       pos = lsn2msf(pos);
+       pos = lsn2msf (pos);
 
        p[9] = (pos >> 16) & 0xff;
        p[10] = (pos >> 8) & 0xff;
@@ -441,9 +441,9 @@ static uae_u8 *ioctl_command_qcode (int unitnum)
        p[3] = 12;
        while (cnt-- > 0) {
            reseterrormode (unitnum);
-           if(!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_READ_Q_CHANNEL, &in, sizeof(in), &qcd, sizeof (qcd), &len, NULL)) {
+           if(!DeviceIoControl (ciw32[unitnum].h, IOCTL_CDROM_READ_Q_CHANNEL, &in, sizeof(in), &qcd, sizeof (qcd), &len, NULL)) {
                reseterrormode (unitnum);
-               if (win32_error (unitnum, "IOCTL_CDROM_READ_Q_CHANNEL") < 0)
+               if (win32_error (unitnum, L"IOCTL_CDROM_READ_Q_CHANNEL") < 0)
                    continue;
                return 0;
            }
@@ -486,7 +486,7 @@ static uae_u8 *spti_read (int unitnum, int sector, int sectorsize)
     uae_u8 cmd[12] = { 0xbe, 0, 0, 0, 0, 0, 0, 0, 1, 0x10, 0, 0 };
     int len = sizeof cmd;
 
-    if (!open_createfile(unitnum, 1))
+    if (!open_createfile (unitnum, 1))
        return 0;
     cmd[3] = (uae_u8)(sector >> 16);
     cmd[4] = (uae_u8)(sector >> 8);
@@ -511,8 +511,8 @@ static uae_u8 *spti_read (int unitnum, int sector, int sectorsize)
        &returned, NULL);
     reseterrormode (unitnum);
     if (!status) {
-       DWORD err = GetLastError();
-       write_log ("IOCTL_RAW_SCSI unit %d, ERR=%d ", unitnum, err);
+       DWORD err = GetLastError ();
+       write_log (L"IOCTL_RAW_SCSI unit %d, ERR=%d ", unitnum, err);
        return 0;
     }
     return p;
@@ -526,10 +526,10 @@ uae_u8 *ioctl_command_rawread (int unitnum, int sector, int sectorsize)
     uae_u8 *p = ciw32[unitnum].tempbuffer;
 
     if (log_scsi)
-       write_log ("IOCTL rawread unit=%d sector=%d blocksize=%d\n", unitnum, sector, sectorsize);
+       write_log (L"IOCTL rawread unit=%d sector=%d blocksize=%d\n", unitnum, sector, sectorsize);
     if (!os_vista)
        return spti_read (unitnum, sector, sectorsize);
-    if (!open_createfile(unitnum, 1))
+    if (!open_createfile (unitnum, 1))
        return 0;
     if (sectorsize != 2336 && sectorsize != 2352 && sectorsize != 2048)
        return 0;
@@ -541,7 +541,7 @@ uae_u8 *ioctl_command_rawread (int unitnum, int sector, int sectorsize)
        rri.TrackMode = RawWithSubCode;
        len = sectorsize;
        memset (p, 0, sectorsize);
-       if (!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_RAW_READ, &rri, sizeof rri,
+       if (!DeviceIoControl (ciw32[unitnum].h, IOCTL_CDROM_RAW_READ, &rri, sizeof rri,
            p, IOCTL_DATA_BUFFER, &len, NULL)) {
            DWORD err = GetLastError ();
        }
@@ -560,14 +560,14 @@ static int ioctl_command_readwrite (int unitnum, int sector, int write, int bloc
     uae_u8 *p = ciw32[unitnum].tempbuffer;
 
     *ptr = NULL;
-    if (!open_createfile(unitnum, 0))
+    if (!open_createfile (unitnum, 0))
        return 0;
     while (cnt-- > 0) {
        gui_cd_led (unitnum, 1);
        seterrormode (unitnum);
        if (SetFilePointer (ciw32[unitnum].h, sector * ciw32[unitnum].blocksize, 0, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
            reseterrormode (unitnum);
-           if (win32_error (unitnum, "SetFilePointer") < 0)
+           if (win32_error (unitnum, L"SetFilePointer") < 0)
                continue;
            return 0;
        }
@@ -582,7 +582,7 @@ static int ioctl_command_readwrite (int unitnum, int sector, int write, int bloc
            if (!WriteFile (ciw32[unitnum].h, p, blocksize, &dtotal, 0)) {
                int err;
                reseterrormode (unitnum);
-               err = win32_error (unitnum, "WriteFile");
+               err = win32_error (unitnum, L"WriteFile");
                if (err < 0)
                    continue;
                if (err == ERROR_WRITE_PROTECT)
@@ -593,7 +593,7 @@ static int ioctl_command_readwrite (int unitnum, int sector, int write, int bloc
            dtotal = 0;
            if (!ReadFile (ciw32[unitnum].h, p, blocksize, &dtotal, 0)) {
                reseterrormode (unitnum);
-               if (win32_error (unitnum, "ReadFile") < 0)
+               if (win32_error (unitnum, L"ReadFile") < 0)
                    continue;
                return 0;
            }
@@ -601,7 +601,7 @@ static int ioctl_command_readwrite (int unitnum, int sector, int write, int bloc
                /* ESS Mega (CDTV) "fake" data area returns zero bytes and no error.. */
                *ptr = spti_read (unitnum, sector, 2048);
                if (log_scsi)
-                   write_log ("IOCTL unit %d, sector %d: ReadFile()==0. SPTI=%d\n", unitnum, sector, *ptr == 0 ? GetLastError() : 0);
+                   write_log (L"IOCTL unit %d, sector %d: ReadFile()==0. SPTI=%d\n", unitnum, sector, *ptr == 0 ? GetLastError () : 0);
                return 1;
 #if 0
                DWORD len = CD_RAW_SECTOR_WITH_SUBCODE_SIZE, err = -1;
@@ -615,7 +615,7 @@ static int ioctl_command_readwrite (int unitnum, int sector, int write, int bloc
                    err = GetLastError (); /* returns ERROR_IO_DEVICE and still succeeds?! */
                }
                p += 16; /* skip raw header */
-               write_log ("ioctl_command_read(%d,%d)==0, IOCTL_CDROM_RAW_READ = d\n",
+               write_log (L"ioctl_command_read(%d,%d)==0, IOCTL_CDROM_RAW_READ = d\n",
                    sector, blocksize, err);
 #endif
            }
@@ -648,13 +648,13 @@ static int fetch_geometry (int unitnum, struct device_info *di)
     DWORD len;
     int cnt = 3;
 
-    if (!open_createfile(unitnum, 0))
+    if (!open_createfile (unitnum, 0))
        return 0;
     while (cnt-- > 0) {
        seterrormode (unitnum);
-       if (!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_GET_DRIVE_GEOMETRY, NULL, 0, &geom, sizeof(geom), &len, NULL)) {
+       if (!DeviceIoControl (ciw32[unitnum].h, IOCTL_CDROM_GET_DRIVE_GEOMETRY, NULL, 0, &geom, sizeof(geom), &len, NULL)) {
            reseterrormode (unitnum);
-           if (win32_error (unitnum, "IOCTL_CDROM_GET_DRIVE_GEOMETRY") < 0)
+           if (win32_error (unitnum, L"IOCTL_CDROM_GET_DRIVE_GEOMETRY") < 0)
                continue;
            return 0;
        }
@@ -680,7 +680,7 @@ static int ismedia (int unitnum)
        MCI_STATUS_PARMS mciStatusParms;
 
        mciStatusParms.dwItem = MCI_STATUS_MEDIA_PRESENT;
-       err = mciSendCommand(ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
+       err = mciSendCommand (ciw->mciid, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatusParms);
        if (err != MMSYSERR_NOERROR)
            return 0;
        if (mciStatusParms.dwReturn)
@@ -689,7 +689,7 @@ static int ismedia (int unitnum)
 
     } else {
        struct device_info di;
-       memset(&di, 0, sizeof di);
+       memset (&di, 0, sizeof di);
        return fetch_geometry (unitnum, &di);
     }
 }
@@ -703,14 +703,14 @@ static uae_u8 *ioctl_command_toc (int unitnum)
     int cnt = 3;
     CDROM_TOC *toc = &ciw32[unitnum].toc;
 
-    if (!open_createfile(unitnum, 0))
+    if (!open_createfile (unitnum, 0))
        return 0;
     gui_cd_led (unitnum, 1);
     while (cnt-- > 0) {
        seterrormode (unitnum);
-       if (!DeviceIoControl(ciw32[unitnum].h, IOCTL_CDROM_READ_TOC, NULL, 0, toc, sizeof(CDROM_TOC), &len, NULL)) {
+       if (!DeviceIoControl (ciw32[unitnum].h, IOCTL_CDROM_READ_TOC, NULL, 0, toc, sizeof(CDROM_TOC), &len, NULL)) {
            reseterrormode (unitnum);
-           if (win32_error (unitnum, "IOCTL_CDROM_READ_TOC") < 0)
+           if (win32_error (unitnum, L"IOCTL_CDROM_READ_TOC") < 0)
                continue;
            return 0;
        }
@@ -766,19 +766,19 @@ static int sys_cddev_open (int unitnum)
     /* buffer must be page aligned for device access */
     ciw->tempbuffer = VirtualAlloc (NULL, IOCTL_DATA_BUFFER, MEM_COMMIT, PAGE_READWRITE);
     if (!ciw->tempbuffer) {
-       write_log ("IOCTL: failed to allocate buffer");
+       write_log (L"IOCTL: failed to allocate buffer");
        return 1;
     }
-    if (!open_createfile(unitnum, 0)) {
-       write_log ("IOCTL: failed to open '%s', err=%d\n", ciw->devname, GetLastError());
+    if (!open_createfile (unitnum, 0)) {
+       write_log (L"IOCTL: failed to open '%s', err=%d\n", ciw->devname, GetLastError ());
        goto error;
     }
     ciw->mediainserted = ioctl_command_toc (unitnum) ? 1 : 0;
-    write_log ("IOCTL: device '%s' opened succesfully (unit number=%d,media=%d)\n", ciw->devname, unitnum, ciw->mediainserted);
+    write_log (L"IOCTL: device '%s' opened succesfully (unit number=%d,media=%d)\n", ciw->devname, unitnum, ciw->mediainserted);
     ioctl_command_stop (unitnum);
     return 0;
 error:
-    win32_error (unitnum, "CreateFile");
+    win32_error (unitnum, L"CreateFile");
     VirtualFree (ciw->tempbuffer, 0, MEM_RELEASE);
     ciw->tempbuffer = NULL;
     CloseHandle (ciw->h);
@@ -805,8 +805,8 @@ void sys_cddev_close (int unitnum)
 
     if (!unitcheck (unitnum))
        return;
-    close_createfile(unitnum);
-    close_mci(unitnum);
+    close_createfile (unitnum);
+    close_mci (unitnum);
     VirtualFree (ciw->tempbuffer, 0, MEM_RELEASE);
     ciw->tempbuffer = NULL;
 }
@@ -834,7 +834,7 @@ static int open_bus (int flags)
 {
     int dwDriveMask;
     int drive, i;
-    char tmp[10];
+    TCHAR tmp[10];
 
     for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
        memset (&ciw32[i], 0, sizeof (struct dev_info_ioctl));
@@ -842,24 +842,24 @@ static int open_bus (int flags)
     }
     MCICDA = 1;//os_vista ? 1 : 0;
     total_devices = 0;
-    dwDriveMask = GetLogicalDrives();
+    dwDriveMask = GetLogicalDrives ();
     if (log_scsi)
-       write_log ("IOCTL: drive mask = %08X\n", dwDriveMask);
+       write_log (L"IOCTL: drive mask = %08X\n", dwDriveMask);
     dwDriveMask >>= 2; // Skip A and B drives...
     for( drive = 'C'; drive <= 'Z'; drive++) {
        if (dwDriveMask & 1) {
            int dt;
-           sprintf(tmp, "%c:\\", drive);
+           _stprintf (tmp, L"%c:\\", drive);
            dt = GetDriveType (tmp);
            if (log_scsi)
-               write_log ("IOCTL: drive %c type %d\n", drive, dt);
+               write_log (L"IOCTL: drive %c type %d\n", drive, dt);
            if (((flags & (1 << INQ_ROMD)) && dt == DRIVE_CDROM) || ((flags & (1 << INQ_DASD)) && dt == DRIVE_FIXED)) {
                if (log_scsi)
-                   write_log ("IOCTL: drive %c: = unit %d\n", drive, total_devices);
+                   write_log (L"IOCTL: drive %c: = unit %d\n", drive, total_devices);
                ciw32[total_devices].drvletter = drive;
                ciw32[total_devices].type = dt;
                ciw32[total_devices].blocksize = 2048;
-               sprintf (ciw32[total_devices].devname,"\\\\.\\%c:", drive);
+               _stprintf (ciw32[total_devices].devname, L"\\\\.\\%c:", drive);
                total_devices++;
            }
        }
@@ -876,7 +876,7 @@ static int ioctl_ismedia (int unitnum, int quick)
        struct dev_info_ioctl *ciw = &ciw32[unitnum];
        return ciw->mediainserted;
     }
-    return ismedia(unitnum);
+    return ismedia (unitnum);
 }
 
 static struct device_info *info_device (int unitnum, struct device_info *di)
@@ -895,17 +895,17 @@ static struct device_info *info_device (int unitnum, struct device_info *di)
     di->write_protected = ciw32[unitnum].type == DRIVE_CDROM ? 1 : 0;
     di->type = ciw32[unitnum].type == DRIVE_CDROM ? INQ_ROMD : INQ_DASD;
     di->id = ciw32[unitnum].drvletter;
-    sprintf (di->label, "Drive %c:", ciw32[unitnum].drvletter);
+    _stprintf (di->label, L"Drive %c:", ciw32[unitnum].drvletter);
     return di;
 }
 
-void win32_ioctl_media_change (char driveletter, int insert)
+void win32_ioctl_media_change (TCHAR driveletter, int insert)
 {
     int i;
 
     for (i = 0; i < MAX_TOTAL_DEVICES; i++) {
        if (ciw32[i].drvletter == driveletter && ciw32[i].mediainserted != insert) {
-           write_log ("IOCTL: media change %c %d\n", driveletter, insert);
+           write_log (L"IOCTL: media change %c %d\n", driveletter, insert);
            ciw32[i].mediainserted = insert;
            scsi_do_disk_change (driveletter, insert);
        }
index caae6164e95cadf9ea927cbe4d78bfdbe6a8dccf..7a16acd9f17b2cf1898789ab01b5bcb8d8cf7ec3 100644 (file)
@@ -45,9 +45,9 @@ typedef struct _SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER {
 static int unitcnt = 0;
 
 struct dev_info_spti {
-    char *drvpath;
-    char *name;
-    char *inquirydata;
+    TCHAR *drvpath;
+    TCHAR *name;
+    TCHAR *inquirydata;
     int mediainserted;
     HANDLE handle;
     int isatapi;
@@ -68,7 +68,7 @@ static int doscsi (int unitnum, SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER *swb, int *
 
     *err = 0;
     if (log_scsi) {
-       write_log ("SCSI, H=%X:%d:%d:%d:%d: ", di->handle, di->bus, di->path, di->target, di->lun);
+       write_log (L"SCSI, H=%X:%d:%d:%d:%d: ", di->handle, di->bus, di->path, di->target, di->lun);
        scsi_log_before (swb->spt.Cdb, swb->spt.CdbLength,
            swb->spt.DataIn == SCSI_IOCTL_DATA_OUT ? swb->spt.DataBuffer : 0,swb->spt.DataTransferLength);
     }
@@ -86,8 +86,8 @@ static int doscsi (int unitnum, SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER *swb, int *
     if (!status) {
        int lasterror = GetLastError();
        *err = lasterror;
-       write_log ("SCSI ERROR, H=%X:%d:%d:%d:%d: ", di->handle, di->bus, di->path, di->target, di->lun);
-       write_log ("Status = %d, Error code = %d, LastError=%d\n", status, swb->spt.ScsiStatus, lasterror);
+       write_log (L"SCSI ERROR, H=%X:%d:%d:%d:%d: ", di->handle, di->bus, di->path, di->target, di->lun);
+       write_log (L"Status = %d, Error code = %d, LastError=%d\n", status, swb->spt.ScsiStatus, lasterror);
        scsi_log_before (swb->spt.Cdb, swb->spt.CdbLength,
            swb->spt.DataIn == SCSI_IOCTL_DATA_OUT ? swb->spt.DataBuffer : 0,swb->spt.DataTransferLength);
     }
@@ -231,7 +231,7 @@ static int total_devices;
 static void close_scsi_device (int unitnum)
 {
     if (dev_info[unitnum].handle != INVALID_HANDLE_VALUE) {
-       write_log ("SPTI: unit %d closed\n", unitnum);
+       write_log (L"SPTI: unit %d closed\n", unitnum);
        CloseHandle (dev_info[unitnum].handle);
     }
     dev_info[unitnum].handle = INVALID_HANDLE_VALUE;
@@ -270,7 +270,7 @@ static void close_scsi_bus (void)
 {
     int i;
     for (i = 0; i < total_devices; i++)
-       free_scsi_device(i);
+       free_scsi_device (i);
 }
 
 static void checkcapabilities (int unitnum)
@@ -286,7 +286,7 @@ static void checkcapabilities (int unitnum)
        &query, sizeof query, &desc, sizeof desc, &ret, NULL);
     if (status) {
        if (desc.Version > offsetof (STORAGE_ADAPTER_DESCRIPTOR, BusType))
-           write_log ("SCSI CAPS: BusType=%d, MaxTransfer=0x%08X, Mask=0x%08X\n",
+           write_log (L"SCSI CAPS: BusType=%d, MaxTransfer=0x%08X, Mask=0x%08X\n",
                desc.BusType, desc.MaximumTransferLength, desc.AlignmentMask);
     }
 }
@@ -304,7 +304,7 @@ static int inquiry (int unitnum, struct dev_info_spti *di, uae_u8 *inquirydata)
     di->type = 0x1f;
     if (!p) {
        if (log_scsi)
-           write_log ("SPTI: INQUIRY failed\n");
+           write_log (L"SPTI: INQUIRY failed\n");
        return 0;
     }
     inqlen = outlen > INQUIRY_SIZE ? INQUIRY_SIZE : outlen;
@@ -317,7 +317,7 @@ static int inquiry (int unitnum, struct dev_info_spti *di, uae_u8 *inquirydata)
     memcpy (inquirydata, p, inqlen);
     if (log_scsi) {
        if (outlen >= INQUIRY_SIZE)
-           write_log ("SPTI: INQUIRY: %02X%02X%02X %d '%-8s' '%-16s'\n",
+           write_log (L"SPTI: INQUIRY: %02X%02X%02X %d '%-8s' '%-16s'\n",
            p[0], p[1], p[2], di->isatapi, p + 8, p + 16);
     }
     return inqlen;
@@ -362,7 +362,7 @@ static int mediacheck_full (int unitnum, struct device_info *di)
            di->write_protected = (p[3] & 0x80) ? 1 : 0;
        }
     }
-//    write_log ("mediacheck_full(%d,%d,%d,%d,%d)\n",
+//    write_log (L"mediacheck_full(%d,%d,%d,%d,%d)\n",
 //     di->bytespersector, di->sectorspertrack, di->trackspercylinder, di->cylinders, di->write_protected);
     return 1;
 }
@@ -370,7 +370,7 @@ static int mediacheck_full (int unitnum, struct device_info *di)
 int open_scsi_device (int unitnum)
 {
     HANDLE h;
-    char *dev;
+    TCHAR *dev;
     struct dev_info_spti *di;
 
     di = &dev_info[unitnum];
@@ -380,37 +380,38 @@ int open_scsi_device (int unitnum)
        return 0;
     if (di->bus >= 0) {
        dev = xmalloc (100);
-       sprintf (dev, "\\\\.\\Scsi%d:", di->bus);
+       _stprintf (dev, L"\\\\.\\Scsi%d:", di->bus);
     } else {
-       dev = my_strdup(di->drvpath);
+       dev = my_strdup (di->drvpath);
     }
     if (!di->scsibuf)
        di->scsibuf = VirtualAlloc (NULL, DEVICE_SCSI_BUFSIZE, MEM_COMMIT, PAGE_READWRITE);
     h = CreateFile(dev,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL);
     di->handle = h;
     if (h == INVALID_HANDLE_VALUE) {
-       write_log ("SPTI: failed to open unit %d err=%d ('%s')\n", unitnum, GetLastError(), dev);
+       write_log (L"SPTI: failed to open unit %d err=%d ('%s')\n", unitnum, GetLastError(), dev);
     } else {
        uae_u8 inqdata[INQUIRY_SIZE + 1] = { 0 };
        checkcapabilities (unitnum);
        if (!inquiry (unitnum, di, inqdata)) {
-           write_log ("SPTI: inquiry failed unit %d ('%s':%d:%d:%d:%d)\n", unitnum, dev,
+           write_log (L"SPTI: inquiry failed unit %d ('%s':%d:%d:%d:%d)\n", unitnum, dev,
                di->bus, di->path, di->target, di->lun);
            close_scsi_device (unitnum);
            xfree (dev);
            return 0;
        }
        inqdata[INQUIRY_SIZE] = 0;
+       di->name = my_strdup_ansi (inqdata + 8);
        if (di->type == INQ_ROMD) {
            dev_info[unitnum].mediainserted = mediacheck (unitnum);
-           write_log ("SPTI: unit %d opened [%s], %s, '%s'\n", unitnum,
-               di->isatapi ? "ATAPI" : "SCSI",
-               di->mediainserted ? "media inserted" : "drive empty", inqdata + 8);
+           write_log (L"SPTI: unit %d opened [%s], %s, '%s'\n", unitnum,
+               di->isatapi ? L"ATAPI" : L"SCSI",
+               di->mediainserted ? L"media inserted" : L"drive empty",
+               di->name);
        } else {
-           write_log ("SPTI: unit %d, type %d, '%s'\n",
-               unitnum, di->type, inqdata + 8);
+           write_log (L"SPTI: unit %d, type %d, '%s'\n",
+               unitnum, di->type, di->name);
        }
-       di->name = my_strdup (inqdata + 8);
        di->inquirydata = xmalloc (INQUIRY_SIZE);
        memcpy (di->inquirydata, inqdata, INQUIRY_SIZE);
        xfree (dev);
@@ -420,7 +421,7 @@ int open_scsi_device (int unitnum)
     return 0;
 }
 
-static int adddrive (char *drvpath, int bus, int pathid, int targetid, int lunid, int scanmode)
+static int adddrive (TCHAR *drvpath, int bus, int pathid, int targetid, int lunid, int scanmode)
 {
     struct dev_info_spti *di;
     int cnt = total_devices, i;
@@ -430,10 +431,10 @@ static int adddrive (char *drvpath, int bus, int pathid, int targetid, int lunid
        return 0;
     for (i = 0; i < total_devices; i++) {
        di = &dev_info[i];
-       if (!strcmp (drvpath, di->drvpath))
+       if (!_tcscmp (drvpath, di->drvpath))
            return 0;
     }
-    write_log ("SPTI: unit %d '%s' added\n", total_devices, drvpath);
+    write_log (L"SPTI: unit %d '%s' added\n", total_devices, drvpath);
     di = &dev_info[total_devices];
     di->drvpath = my_strdup (drvpath);
     di->type = 0;
@@ -446,7 +447,7 @@ static int adddrive (char *drvpath, int bus, int pathid, int targetid, int lunid
     if (open_scsi_device (cnt)) {
        for (i = 0; i < cnt; i++) {
            if (!memcmp (di->inquirydata, dev_info[i].inquirydata, INQUIRY_SIZE) && di->scanmode != dev_info[i].scanmode) {
-               write_log ("duplicate device, skipped..\n");
+               write_log (L"duplicate device, skipped..\n");
                break;
            }
        }
@@ -468,7 +469,7 @@ static struct device_info *info_device (int unitnum, struct device_info *di)
     if (unitnum >= MAX_TOTAL_DEVICES || dev_info[unitnum].handle == INVALID_HANDLE_VALUE)
        return 0;
     dispti = &dev_info[unitnum];
-    strcpy (di->label, dispti->name);
+    _tcscpy (di->label, dispti->name);
     di->bus = 0;
     di->target = unitnum;
     di->lun = 0;
@@ -478,13 +479,13 @@ static struct device_info *info_device (int unitnum, struct device_info *di)
     di->type = dispti->type;
     di->id = unitnum + 1;
     if (log_scsi) {
-       write_log ("MI=%d TP=%d WP=%d CY=%d BK=%d RMB=%d '%s'\n",
+       write_log (L"MI=%d TP=%d WP=%d CY=%d BK=%d RMB=%d '%s'\n",
            di->media_inserted, di->type, di->write_protected, di->cylinders, di->bytespersector, di->removable, di->label);
     }
     return di;
 }
 
-void win32_spti_media_change (char driveletter, int insert)
+void win32_spti_media_change (TCHAR driveletter, int insert)
 {
     int i, now;
 
@@ -492,7 +493,7 @@ void win32_spti_media_change (char driveletter, int insert)
        if (dev_info[i].type == INQ_ROMD) {
            now = mediacheck (i);
            if (now != dev_info[i].mediainserted) {
-               write_log ("SPTI: media change %c %d\n", driveletter, insert);
+               write_log (L"SPTI: media change %c %d\n", driveletter, insert);
                dev_info[i].mediainserted = now;
                scsi_do_disk_change (i + 1, insert);
            }
@@ -518,7 +519,7 @@ struct device_functions devicefunc_win32_spti = {
     0, 0, 0, 0, 0, 0, 0, 0, check_isatapi, scsi_info, 0
 };
 
-static int getCDROMProperty(int idx, HDEVINFO DevInfo, const GUID *guid)
+static int getCDROMProperty (int idx, HDEVINFO DevInfo, const GUID *guid)
 {
     SP_DEVICE_INTERFACE_DATA interfaceData;
     PSP_DEVICE_INTERFACE_DETAIL_DATA interfaceDetailData = NULL;
@@ -576,7 +577,7 @@ static int getCDROMProperty(int idx, HDEVINFO DevInfo, const GUID *guid)
 }
 
 #define        SCSI_INFO_BUFFER_SIZE 0x5000
-static void scanscsi(void)
+static void scanscsi (void)
 {
     PSCSI_BUS_DATA BusData;
     PSCSI_INQUIRY_DATA InquiryData;
@@ -588,15 +589,15 @@ static void scanscsi(void)
     SHORT Bus, Luns;
     DWORD bytesTransferred;
     int idx;
-    char DeviceName[256];
+    TCHAR DeviceName[256];
 
-    AdapterInfo = (PSCSI_ADAPTER_BUS_INFO)xmalloc(SCSI_INFO_BUFFER_SIZE) ;
+    AdapterInfo = xmalloc (SCSI_INFO_BUFFER_SIZE) ;
     if (AdapterInfo == NULL)
        return;
 
     idx = 0;
     for (;;) {
-       sprintf(DeviceName, "\\\\.\\Scsi%d:", idx++);
+       _stprintf (DeviceName, L"\\\\.\\Scsi%d:", idx++);
        h = CreateFile (DeviceName,
            GENERIC_READ | GENERIC_WRITE,
            0,
@@ -607,7 +608,7 @@ static void scanscsi(void)
        if (h == INVALID_HANDLE_VALUE)
            return;
 
-       if(!DeviceIoControl(h,
+       if(!DeviceIoControl (h,
            IOCTL_SCSI_RESCAN_BUS,
            NULL,
            0,
@@ -615,13 +616,13 @@ static void scanscsi(void)
            0,
            &bytesTransferred,
            NULL)) {
-           write_log ( "Rescan SCSI port %d failed [Error %d]\n", idx - 1, GetLastError());
-           CloseHandle(h);
+           write_log (L"Rescan SCSI port %d failed [Error %d]\n", idx - 1, GetLastError());
+           CloseHandle (h);
            continue;
        }
 
        // Get the SCSI inquiry data for all devices for the given SCSI bus
-       status = DeviceIoControl(
+       status = DeviceIoControl (
            h,
            IOCTL_SCSI_GET_INQUIRY_DATA,
            NULL,
@@ -632,7 +633,7 @@ static void scanscsi(void)
            NULL);
 
        if (!status) {
-           write_log ("Error in IOCTL_SCSI_GET_INQUIRY_DATA\n" );
+           write_log (L"Error in IOCTL_SCSI_GET_INQUIRY_DATA\n" );
            CloseHandle (h);
            continue;
        }
@@ -640,22 +641,22 @@ static void scanscsi(void)
        for (Bus = 0; Bus < AdapterInfo->NumberOfBuses; Bus++) {
            int luncheck = 0;
            BusData = &AdapterInfo->BusData[Bus];
-           InquiryData = (PSCSI_INQUIRY_DATA) ( (PUCHAR) AdapterInfo + BusData->InquiryDataOffset );
+           InquiryData = (PSCSI_INQUIRY_DATA) ((PUCHAR)AdapterInfo + BusData->InquiryDataOffset);
            for (Luns = 0; Luns < BusData->NumberOfLogicalUnits; Luns++) {
-               char label[100];
+               TCHAR label[100];
                int type = InquiryData->InquiryData[0] & 0x1f;
                Claimed = InquiryData->DeviceClaimed;
-               write_log ("SCSI=%d Initiator=%d Path=%d Target=%d LUN=%d Claimed=%s Type=%d\n",
+               write_log (L"SCSI=%d Initiator=%d Path=%d Target=%d LUN=%d Claimed=%s Type=%d\n",
                    idx - 1,
                    BusData->InitiatorBusId, InquiryData->PathId, InquiryData->TargetId,
-                   InquiryData->Lun, Claimed ? "Yes" : "No ", type);
+                   InquiryData->Lun, Claimed ? L"Yes" : L"No ", type);
                if (Claimed == 0 && !luncheck) {
                    luncheck = 1;
-                   sprintf (label, "SCSI(%d):%d:%d:%d:%d", idx - 1, BusData->InitiatorBusId,
+                   _stprintf (label, L"SCSI(%d):%d:%d:%d:%d", idx - 1, BusData->InitiatorBusId,
                        InquiryData->PathId, InquiryData->TargetId, InquiryData->Lun);
                    adddrive (label, idx - 1, InquiryData->PathId, InquiryData->TargetId, InquiryData->Lun, 3);
                }
-               InquiryData = (PSCSI_INQUIRY_DATA) ( (PUCHAR) AdapterInfo + InquiryData->NextInquiryDataOffset );
+               InquiryData = (PSCSI_INQUIRY_DATA) ((PUCHAR)AdapterInfo + InquiryData->NextInquiryDataOffset);
            }   // for Luns
        }       // for Bus
        CloseHandle(h);
@@ -667,9 +668,9 @@ static const GUID *guids[] = {
     &GUID_DEVCLASS_IMAGE,
     &GUID_DEVCLASS_TAPEDRIVE,
     NULL };
-static const char *scsinames[] = { "Tape", "Scanner", "Changer", NULL };
+static const TCHAR *scsinames[] = { L"Tape", L"Scanner", L"Changer", NULL };
 
-static int rescan(void)
+static int rescan (void)
 {
     int idx, idx2;
 
@@ -679,34 +680,34 @@ static int rescan(void)
            NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
        if (hDevInfo != INVALID_HANDLE_VALUE) {
            for (idx = 0; ; idx++) {
-               if (!getCDROMProperty(idx, hDevInfo, guids[idx2]))
+               if (!getCDROMProperty (idx, hDevInfo, guids[idx2]))
                    break;
            }
-           SetupDiDestroyDeviceInfoList(hDevInfo);
+           SetupDiDestroyDeviceInfoList (hDevInfo);
        }
     }
 
     for (idx2 = 0; scsinames[idx2]; idx2++) {
        int max = 10;
        for (idx = 0; idx < max; idx++) {
-           char tmp[100];
+           TCHAR tmp[100];
            HANDLE h;
-           sprintf (tmp, "\\\\.\\%s%d", scsinames[idx2], idx);
-           h = CreateFile(tmp, GENERIC_READ | GENERIC_WRITE,
+           _stprintf (tmp, L"\\\\.\\%s%d", scsinames[idx2], idx);
+           h = CreateFile (tmp, GENERIC_READ | GENERIC_WRITE,
                FILE_SHARE_READ | FILE_SHARE_WRITE,
                NULL, OPEN_EXISTING, 0, NULL);
            if (h != INVALID_HANDLE_VALUE) {
-               adddrive(tmp, -1, -1, -1, -1, 2);
-               CloseHandle(h);
+               adddrive (tmp, -1, -1, -1, -1, 2);
+               CloseHandle (h);
                if (idx == max - 1)
                    max++;
            }
        }
     }
     if (currprefs.win32_uaescsimode == UAESCSI_SPTISCAN) {
-       write_log ("SCSI adapter enumeration..\n");
-       scanscsi();
-       write_log ("SCSI adapter enumeration ends\n");
+       write_log (L"SCSI adapter enumeration..\n");
+       scanscsi ();
+       write_log (L"SCSI adapter enumeration ends\n");
     }
     return 1;
 }
index 0b1681a1577a830b7d1c80733d9ecc29622d4b51..c6895e0fe31cad76eca63d0dd74619d63d1b1c06 100644 (file)
@@ -45,7 +45,7 @@ struct threadargs {
     uae_u32 args2;
     int args3;
     long args4;
-       char buf[MAXGETHOSTSTRUCT];
+       uae_char buf[MAXGETHOSTSTRUCT];
 };
 
 struct threadargsw {
@@ -143,41 +143,36 @@ static int mySockStartup(void)
        int result = 0, i;
        SOCKET dummy;
        DWORD lasterror;
+       TCHAR *ss;
 
        if (!bsd) {
                bsd = calloc (sizeof (struct bsdsockdata), 1);
                for (i = 0; i < MAX_GET_THREADS; i++)
                    threadindextable[i] = i;
        }
-       if (WSAStartup(MAKEWORD(SOCKVER_MAJOR, SOCKVER_MINOR), &bsd->wsbData)) {
+       if (WSAStartup (MAKEWORD (SOCKVER_MAJOR, SOCKVER_MINOR), &bsd->wsbData)) {
            lasterror = WSAGetLastError();
            if(lasterror == WSAVERNOTSUPPORTED) {
-                       char szMessage[MAX_DPATH];
+                       TCHAR szMessage[MAX_DPATH];
                        WIN32GUI_LoadUIString(IDS_WSOCK2NEEDED, szMessage, MAX_DPATH);
                                        gui_message(szMessage);
            } else
-                       write_log ("BSDSOCK: ERROR - Unable to initialize Windows socket layer! Error code: %d\n", lasterror);
+                       write_log (L"BSDSOCK: ERROR - Unable to initialize Windows socket layer! Error code: %d\n", lasterror);
            return 0;
        }
 
-       if (LOBYTE (bsd->wsbData.wVersion) != SOCKVER_MAJOR || HIBYTE (bsd->wsbData.wVersion) != SOCKVER_MINOR) {
-               char szMessage[MAX_DPATH];
-               WIN32GUI_LoadUIString(IDS_WSOCK2NEEDED, szMessage, MAX_DPATH);
-               gui_message(szMessage);
-
-               return 0;
+       ss = au (bsd->wsbData.szDescription);
+       write_log (L"BSDSOCK: using %s\n", ss);
+       xfree (ss);
+       // make sure WSP/NSPStartup gets called from within the regular stack
+       // (Windows 95/98 need this)
+       if((dummy = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) != INVALID_SOCKET)  {
+               closesocket(dummy);
+               result = 1;
        } else {
-               write_log ("BSDSOCK: using %s\n", bsd->wsbData.szDescription);
-               // make sure WSP/NSPStartup gets called from within the regular stack
-               // (Windows 95/98 need this)
-               if((dummy = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) != INVALID_SOCKET)  {
-                       closesocket(dummy);
-                       result = 1;
-               } else {
-                       write_log ("BSDSOCK: ERROR - WSPStartup/NSPStartup failed! Error code: %d\n",
-                               WSAGetLastError());
-                       result = 0;
-               }
+               write_log (L"BSDSOCK: ERROR - WSPStartup/NSPStartup failed! Error code: %d\n",
+                       WSAGetLastError());
+               result = 0;
        }
 
        return result;
@@ -207,17 +202,17 @@ int init_socket_layer (void)
                                wc.hCursor = LoadCursor (NULL, IDC_ARROW);
                                wc.hbrBackground = GetStockObject (BLACK_BRUSH);
                                wc.lpszMenuName = 0;
-                               wc.lpszClassName = "SocketFun";
+                               wc.lpszClassName = L"SocketFun";
                                RegisterClass(&wc);
                                bsd->hSockWnd = CreateWindowEx (0,
-                                       "SocketFun", "WinUAE Socket Window",
+                                       L"SocketFun", L"WinUAE Socket Window",
                                        WS_POPUP,
                                        0, 0,
                                        1, 1,
                                        NULL, NULL, 0, NULL);
                                bsd->hSockThread = THREAD(sock_thread, NULL);
                                if (!bsd->hSockWnd) {
-                                   write_log ("bsdsocket initialization failed\n");
+                                   write_log (L"bsdsocket initialization failed\n");
                                    deinit_socket_layer();
                                    return 0;
                                }
@@ -277,7 +272,7 @@ void deinit_socket_layer(void)
                bsd->hSockReqHandled = NULL;
                DestroyWindow (bsd->hSockWnd);
                bsd->hSockWnd = NULL;
-               UnregisterClass ("SocketFun", hInst);
+               UnregisterClass (L"SocketFun", hInst);
        }
        close_selectget_threads ();
        WSACleanup();
@@ -329,7 +324,7 @@ void host_closesocketquick(SOCKET s)
        BOOL b = 1;
 
        if(s) {
-           setsockopt(s, SOL_SOCKET, SO_DONTLINGER, (char *)&b, sizeof(b));
+           setsockopt(s, SOL_SOCKET, SO_DONTLINGER, (uae_char*)&b, sizeof(b));
            shutdown(s, 1);
            closesocket(s);
        }
@@ -436,7 +431,7 @@ static void sockmsg(unsigned int msg, WPARAM wParam, LPARAM lParam)
                        if (sb->sb_errno >= 1001 && sb->sb_errno <= 1005) {
                                bsdsocklib_setherrno(sb, sb->sb_errno - 1000);
                        } else if (sb->sb_errno == 55) { // ENOBUFS
-                               write_log ("BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n",
+                               write_log (L"BSDSOCK: ERROR - Buffer overflow - %d bytes requested\n",
                                        WSAGETASYNCBUFLEN(lParam));
                        }
                } else {
@@ -474,7 +469,7 @@ static unsigned     int allocasyncmsg(SB,uae_u32 sd,SOCKET s)
        unlocksigqueue();
 
        bsdsocklib_seterrno(sb, 12); // ENOMEM
-       write_log ("BSDSOCK: ERROR - Async operation completion table overflow\n");
+       write_log (L"BSDSOCK: ERROR - Async operation completion table overflow\n");
 
        return 0;
 }
@@ -543,10 +538,10 @@ static void prephostaddr(SOCKADDR_IN *addr)
 static void prepamigaaddr(struct sockaddr *realpt, int len)
 {
     // little endian address family value to the byte sin_family member
-    ((char *)realpt)[1] = *((char *)realpt);
+    ((TCHAR *)realpt)[1] = *((TCHAR *)realpt);
 
     // set size of address
-    *((char *)realpt) = len;
+    *((TCHAR *)realpt) = len;
 }
 
 
@@ -554,14 +549,14 @@ int host_dup2socket(SB, int fd1, int fd2)
 {
     SOCKET s1,s2;
 
-    TRACE(("dup2socket(%d,%d) -> ",fd1,fd2));
+    BSDTRACE((L"dup2socket(%d,%d) -> ",fd1,fd2));
        fd1++;
 
     s1 = getsock(sb, fd1);
     if (s1 != INVALID_SOCKET) {
                if (fd2 != -1) {
                    if ((unsigned int) (fd2) >= (unsigned int) sb->dtablesize)  {
-                               TRACE (("Bad file descriptor (%d)\n", fd2));
+                               BSDTRACE (("Bad file descriptor (%d)\n", fd2));
                                bsdsocklib_seterrno (sb, 9); /* EBADF */
                        }
                        fd2++;
@@ -571,16 +566,16 @@ int host_dup2socket(SB, int fd1, int fd2)
                            closesocket(s2);
                        }
                        setsd(sb,fd2,s1);
-                   TRACE(("0\n"));
+                   BSDTRACE((L"0\n"));
                        return 0;
                } else {
                        fd2 = getsd(sb, 1);
                        setsd(sb,fd2,s1);
-                   TRACE(("%d\n",fd2));
+                   BSDTRACE((L"%d\n",fd2));
                        return (fd2 - 1);
                }
        }
-    TRACE(("-1\n"));
+    BSDTRACE((L"-1\n"));
     return -1;
 }
 
@@ -590,18 +585,18 @@ int host_socket(SB, int af, int type, int protocol)
     SOCKET s;
     unsigned long nonblocking = 1;
 
-    TRACE(("socket(%s,%s,%d) -> ",af == AF_INET ? "AF_INET" : "AF_other",type == SOCK_STREAM ? "SOCK_STREAM" : type == SOCK_DGRAM ? "SOCK_DGRAM " : "SOCK_RAW",protocol));
+    BSDTRACE((L"socket(%s,%s,%d) -> ",af == AF_INET ? "AF_INET" : "AF_other",type == SOCK_STREAM ? "SOCK_STREAM" : type == SOCK_DGRAM ? "SOCK_DGRAM " : "SOCK_RAW",protocol));
 
     if ((s = socket(af,type,protocol)) == INVALID_SOCKET) {
                SETERRNO;
-               TRACE(("failed (%d)\n",sb->sb_errno));
+               BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                return -1;
     } else
                sd = getsd(sb,(int)s);
 
        sb->ftable[sd-1] = SF_BLOCKING;
     ioctlsocket(s,FIONBIO,&nonblocking);
-    TRACE(("%d\n",sd));
+    BSDTRACE((L"%d\n",sd));
 
        if (type == SOCK_RAW) {
                if (protocol==IPPROTO_UDP) {
@@ -623,17 +618,17 @@ int host_socket(SB, int af, int type, int protocol)
 
 uae_u32 host_bind(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
 {
-    char buf[MAXADDRLEN];
+    TCHAR buf[MAXADDRLEN];
     uae_u32 success = 0;
     SOCKET s;
 
        sd++;
-    TRACE(("bind(%d,0x%lx,%d) -> ",sd, name, namelen));
+    BSDTRACE((L"bind(%d,0x%lx,%d) -> ",sd, name, namelen));
     s = getsock(sb, sd);
 
     if (s != INVALID_SOCKET) {
                if (namelen <= sizeof buf) {
-                       if (!addr_valid("host_bind", name, namelen))
+                       if (!addr_valid (L"host_bind", name, namelen))
                                return 0;
                    memcpy(buf, get_real_address (name), namelen);
 
@@ -642,11 +637,11 @@ uae_u32 host_bind(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
 
                        if ((success = bind(s,(struct sockaddr *)buf, namelen)) != 0) {
                                SETERRNO;
-                               TRACE(("failed (%d)\n",sb->sb_errno));
+                               BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                        } else
-                               TRACE(("OK\n"));
+                               BSDTRACE((L"OK\n"));
                } else
-                       write_log ("BSDSOCK: ERROR - Excessive namelen (%d) in bind()!\n", namelen);
+                       write_log (L"BSDSOCK: ERROR - Excessive namelen (%d) in bind()!\n", namelen);
     }
 
     return success;
@@ -658,15 +653,15 @@ uae_u32 host_listen(SB, uae_u32 sd, uae_u32 backlog)
     uae_u32 success = -1;
 
        sd++;
-    TRACE(("listen(%d,%d) -> ", sd, backlog));
+    BSDTRACE((L"listen(%d,%d) -> ", sd, backlog));
     s = getsock(sb, sd);
 
     if (s != INVALID_SOCKET) {
                if ((success = listen(s,backlog)) != 0) {
                        SETERRNO;
-                       TRACE(("failed (%d)\n",sb->sb_errno));
+                       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                } else
-                       TRACE(("OK\n"));
+                       BSDTRACE((L"OK\n"));
     }
     return success;
 }
@@ -682,7 +677,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam
 
     sd++;
        if (name != 0) {
-               if (!addr_valid("host_accept1", name, sizeof(struct sockaddr)) || !addr_valid("host_accept2", namelen, 4))
+               if (!addr_valid (L"host_accept1", name, sizeof(struct sockaddr)) || !addr_valid (L"host_accept2", namelen, 4))
                        return;
                rp_nameuae = rp_name = (struct sockaddr *)get_real_address (name);
            hlenuae = hlen = get_long (namelen);
@@ -695,7 +690,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam
                rp_name = &sockaddr;
                hlen = sizeof(sockaddr);
        }
-    TRACE(("accept(%d,%d,%d) -> ",sd,name,hlenuae));
+    BSDTRACE((L"accept(%d,%d,%d) -> ",sd,name,hlenuae));
 
     s = getsock(sb, (int)sd);
 
@@ -724,7 +719,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam
                                        }
 
                                        if (sb->eintr) {
-                                               TRACE(("[interrupted]\n"));
+                                               BSDTRACE((L"[interrupted]\n"));
                                                ENDBLOCKING;
                                                return;
                                        }
@@ -735,7 +730,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam
                                                SETERRNO;
 
                                                if (sb->sb_errno == WSAEWOULDBLOCK - WSABASEERR)
-                                                       write_log ("BSDSOCK: ERRRO - accept() would block despite FD_ACCEPT message\n");
+                                                       write_log (L"BSDSOCK: ERRRO - accept() would block despite FD_ACCEPT message\n");
                                        }
                                }
                        }
@@ -743,7 +738,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam
 
                if (s2 == INVALID_SOCKET) {
                        sb->resultval = -1;
-                       TRACE(("failed (%d)\n",sb->sb_errno));
+                       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                } else {
                        sb->resultval = getsd(sb, s2);
                        sb->ftable[sb->resultval - 1] = sb->ftable[sd - 1]; // new socket inherits the old socket's properties
@@ -762,7 +757,7 @@ void host_accept(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 nam
                                        }
                                }
                        }
-                       TRACE(("%d/%d\n", sb->resultval, hlen));
+                       BSDTRACE((L"%d/%d\n", sb->resultval, hlen));
                }
 
                ENDBLOCKING;
@@ -786,8 +781,8 @@ struct threadsock_packet
     {
        struct sendto_params
        {
-           char *buf;
-           char *realpt;
+           uae_char *buf;
+           uae_char *realpt;
            uae_u32 sd;
            uae_u32 msg;
            uae_u32 len;
@@ -797,7 +792,7 @@ struct threadsock_packet
        } sendto_s;
        struct recvfrom_params
        {
-           char *realpt;
+           uae_char *realpt;
            uae_u32 addr;
            uae_u32 len;
            uae_u32 flags;
@@ -806,7 +801,7 @@ struct threadsock_packet
        } recvfrom_s;
        struct connect_params
        {
-           char *buf;
+           uae_char *buf;
            uae_u32 namelen;
        } connect_s;
        struct abort_params
@@ -863,7 +858,7 @@ static BOOL HandleStuff(void)
                                break;
                                case last_req:
                                default:
-                                       write_log ( "BSDSOCK: Invalid sock-thread request!\n" );
+                                       write_log (L"BSDSOCK: Invalid sock-thread request!\n");
                                        handled = FALSE;
                                break;
                        }
@@ -926,7 +921,7 @@ static unsigned int sock_thread2(void *blah)
                        }
            }
        }
-       write_log ( "BSDSOCK: We have exited our sock_thread()\n" );
+       write_log (L"BSDSOCK: We have exited our sock_thread()\n");
        THREADEND(result);
        return result;
 }
@@ -945,12 +940,12 @@ void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na
     SOCKET s;
     int success = 0;
     unsigned int wMsg;
-    char buf[MAXADDRLEN];
+    uae_char buf[MAXADDRLEN];
 
        sd++;
-    TRACE(("connect(%d,0x%lx,%d) -> ", sd, name, namelen));
+    BSDTRACE((L"connect(%d,0x%lx,%d) -> ", sd, name, namelen));
 
-       if (!addr_valid("host_connect", name, namelen))
+       if (!addr_valid (L"host_connect", name, namelen))
                return;
 
     s = getsock(sb,(int)sd);
@@ -1008,38 +1003,38 @@ void host_connect(TrapContext *context, SB, uae_u32 sd, uae_u32 name, uae_u32 na
                                }
                        }
                } else
-                       write_log ("BSDSOCK: WARNING - Excessive namelen (%d) in connect()!\n", namelen);
+                       write_log (L"BSDSOCK: WARNING - Excessive namelen (%d) in connect()!\n", namelen);
     }
-    TRACE(("%d\n",sb->sb_errno));
+    BSDTRACE((L"%d\n",sb->sb_errno));
 }
 
-void host_sendto(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen)
+void host_sendto (TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 to, uae_u32 tolen)
 {
     SOCKET s;
-    char *realpt;
+    uae_char *realpt;
     unsigned int wMsg;
-    char buf[MAXADDRLEN];
+    uae_char buf[MAXADDRLEN];
     int iCut;
 
 #ifdef TRACING_ENABLED
     if (to)
-               TRACE(("sendto(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,to,tolen));
+               BSDTRACE((L"sendto(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,to,tolen));
     else
-               TRACE(("send(%d,0x%lx,%d,%d) -> ",sd,msg,len,flags));
+               BSDTRACE((L"send(%d,0x%lx,%d,%d) -> ",sd,msg,len,flags));
 #endif
        sd++;
     s = getsock(sb,sd);
 
     if (s != INVALID_SOCKET) {
-               if (!addr_valid("host_sendto1", msg, 4))
+               if (!addr_valid (L"host_sendto1", msg, 4))
                        return;
                realpt = get_real_address (msg);
 
                if (to) {
                        if (tolen > sizeof buf) {
-                               write_log ("BSDSOCK: WARNING - Target address in sendto() too large (%d)!\n", tolen);
+                               write_log (L"BSDSOCK: WARNING - Target address in sendto() too large (%d)!\n", tolen);
                        } else {
-                               if (!addr_valid("host_sendto2", to, tolen))
+                               if (!addr_valid (L"host_sendto2", to, tolen))
                                        return;
                                memcpy(buf, get_real_address (to), tolen);
                                // some Amiga software sets this field to bogus values
@@ -1157,7 +1152,7 @@ void host_sendto(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len,
                                }
 
                                if (sb->eintr) {
-                                       TRACE(("[interrupted]\n"));
+                                       BSDTRACE((L"[interrupted]\n"));
                                        return;
                                }
                        } else
@@ -1171,9 +1166,9 @@ void host_sendto(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len,
 
 #ifdef TRACING_ENABLED
     if (sb->resultval == -1)
-       TRACE(("failed (%d)\n",sb->sb_errno));
+       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
     else
-       TRACE(("%d\n",sb->resultval));
+       BSDTRACE((L"%d\n",sb->resultval));
 #endif
 
 }
@@ -1181,30 +1176,30 @@ void host_sendto(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len,
 void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 len, uae_u32 flags, uae_u32 addr, uae_u32 addrlen)
 {
     SOCKET s;
-    char *realpt;
+    uae_char *realpt;
     struct sockaddr *rp_addr = NULL;
     int hlen;
     unsigned int wMsg;
 
 #ifdef TRACING_ENABLED
     if (addr)
-               TRACE(("recvfrom(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,addr,get_long (addrlen)));
+               BSDTRACE((L"recvfrom(%d,0x%lx,%d,0x%lx,0x%lx,%d) -> ",sd,msg,len,flags,addr,get_long (addrlen)));
        else
-               TRACE(("recv(%d,0x%lx,%d,0x%lx) -> ",sd,msg,len,flags));
+               BSDTRACE((L"recv(%d,0x%lx,%d,0x%lx) -> ",sd,msg,len,flags));
 #endif
     sd++;
     s = getsock(sb,sd);
 
     if (s != INVALID_SOCKET) {
-               if (!addr_valid("host_recvfrom1", msg, 4))
+               if (!addr_valid (L"host_recvfrom1", msg, 4))
                        return;
                realpt = get_real_address (msg);
 
                if (addr) {
-                       if (!addr_valid("host_recvfrom1", addrlen, 4))
+                       if (!addr_valid (L"host_recvfrom1", addrlen, 4))
                                return;
                        hlen = get_long (addrlen);
-                       if (!addr_valid("host_recvfrom2", addr, hlen))
+                       if (!addr_valid (L"host_recvfrom2", addr, hlen))
                                return;
                        rp_addr = (struct sockaddr *)get_real_address (addr);
                }
@@ -1245,7 +1240,7 @@ void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 le
                                }
 
                                if (sb->eintr) {
-                                       TRACE(("[interrupted]\n"));
+                                       BSDTRACE((L"[interrupted]\n"));
                                        return;
                                }
                    } else
@@ -1267,9 +1262,9 @@ void host_recvfrom(TrapContext *context, SB, uae_u32 sd, uae_u32 msg, uae_u32 le
 
 #ifdef TRACING_ENABLED
     if (sb->resultval == -1)
-               TRACE(("failed (%d)\n",sb->sb_errno));
+               BSDTRACE((L"failed (%d)\n",sb->sb_errno));
     else
-               TRACE(("%d\n",sb->resultval));
+               BSDTRACE((L"%d\n",sb->resultval));
 #endif
 
 }
@@ -1278,16 +1273,16 @@ uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how)
 {
     SOCKET s;
 
-    TRACE(("shutdown(%d,%d) -> ",sd,how));
+    BSDTRACE((L"shutdown(%d,%d) -> ",sd,how));
     sd++;
     s = getsock(sb,sd);
 
     if (s != INVALID_SOCKET) {
                if (shutdown(s,how)) {
                        SETERRNO;
-                       TRACE(("failed (%d)\n",sb->sb_errno));
+                       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                } else {
-                       TRACE(("OK\n"));
+                       BSDTRACE((L"OK\n"));
                        return 0;
                }
     }
@@ -1298,15 +1293,15 @@ uae_u32 host_shutdown(SB, uae_u32 sd, uae_u32 how)
 void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 len)
 {
     SOCKET s;
-    char buf[MAXADDRLEN];
+    uae_char buf[MAXADDRLEN];
 
-    TRACE(("setsockopt(%d,%d,0x%lx,0x%lx,%d) -> ",sd,(short)level,optname,optval,len));
+    BSDTRACE((L"setsockopt(%d,%d,0x%lx,0x%lx,%d) -> ",sd,(short)level,optname,optval,len));
     sd++;
     s = getsock(sb,sd);
 
     if (s != INVALID_SOCKET) {
                if (len > sizeof buf) {
-                       write_log ("BSDSOCK: WARNING - Excessive optlen in setsockopt() (%d)\n", len);
+                       write_log (L"BSDSOCK: WARNING - Excessive optlen in setsockopt() (%d)\n", len);
                        len = sizeof buf;
                }
                if (level == IPPROTO_IP && optname == 2) { // IP_HDRINCL emulated by icmp.dll
@@ -1322,7 +1317,7 @@ void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 opt
                        else if (len == 2)
                                *(short *)buf = get_word (optval);
                        else
-                               write_log ("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n", len, level, optname);
+                               write_log (L"BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n", len, level, optname);
                }
 
                // handle SO_EVENTMASK
@@ -1354,22 +1349,22 @@ void host_setsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 opt
                        sb->resultval = setsockopt(s,level,optname,buf,len);
 
                if (!sb->resultval) {
-                       TRACE(("OK\n"));
+                       BSDTRACE((L"OK\n"));
                        return;
                } else
                        SETERRNO;
 
-               TRACE(("failed (%d)\n",sb->sb_errno));
+               BSDTRACE((L"failed (%d)\n",sb->sb_errno));
     }
 }
 
 uae_u32 host_getsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32 optval, uae_u32 optlen)
 {
        SOCKET s;
-       char buf[MAXADDRLEN];
+       uae_char buf[MAXADDRLEN];
        int len = sizeof(buf);
 
-       TRACE(("getsockopt(%d,%d,0x%lx,0x%lx,0x%lx) -> ",sd,(short)level,optname,optval,optlen));
+       BSDTRACE((L"getsockopt(%d,%d,0x%lx,0x%lx,0x%lx) -> ",sd,(short)level,optname,optval,optlen));
        sd++;
        s = getsock(sb,sd);
 
@@ -1384,15 +1379,15 @@ uae_u32 host_getsockopt(SB, uae_u32 sd, uae_u32 level, uae_u32 optname, uae_u32
                                else if (len == 2)
                                        put_word (optval,*(short *)buf);
                                else
-                                       write_log ("BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n", len, level, optname);
+                                       write_log (L"BSDSOCK: ERROR - Unknown optlen (%d) in setsockopt(%d,%d)\n", len, level, optname);
                        }
 
 //                     put_long (optlen,len); // some programs pass the        actual length instead of a pointer to the length, so...
-                       TRACE(("OK (%d,%d)\n",len,*(long *)buf));
+                       BSDTRACE((L"OK (%d,%d)\n",len,*(long *)buf));
                        return 0;
                } else {
                        SETERRNO;
-                       TRACE(("failed (%d)\n",sb->sb_errno));
+                       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                }
        }
 
@@ -1406,24 +1401,24 @@ uae_u32 host_getsockname(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
        struct sockaddr *rp_name;
 
        sd++;
-       if (!addr_valid("host_getsockname1", namelen, 4))
+       if (!addr_valid (L"host_getsockname1", namelen, 4))
                return -1;
        len = get_long (namelen);
 
-       TRACE(("getsockname(%d,0x%lx,%d) -> ",sd,name,len));
+       BSDTRACE((L"getsockname(%d,0x%lx,%d) -> ",sd,name,len));
 
        s = getsock(sb,sd);
 
        if (s != INVALID_SOCKET) {
-               if (!addr_valid("host_getsockname2", name, len))
+               if (!addr_valid (L"host_getsockname2", name, len))
                        return -1;
                rp_name = (struct sockaddr *)get_real_address (name);
 
                if (getsockname(s,rp_name,&len)) {
                        SETERRNO;
-                       TRACE(("failed (%d)\n",sb->sb_errno));
+                       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                } else {
-                       TRACE(("%d\n",len));
+                       BSDTRACE((L"%d\n",len));
                        prepamigaaddr(rp_name,len);
                        put_long (namelen,len);
                        return 0;
@@ -1440,24 +1435,24 @@ uae_u32 host_getpeername(SB, uae_u32 sd, uae_u32 name, uae_u32 namelen)
        struct sockaddr *rp_name;
 
        sd++;
-       if (!addr_valid("host_getpeername1", namelen, 4))
+       if (!addr_valid (L"host_getpeername1", namelen, 4))
                return -1;
        len = get_long (namelen);
 
-       TRACE(("getpeername(%d,0x%lx,%d) -> ",sd,name,len));
+       BSDTRACE((L"getpeername(%d,0x%lx,%d) -> ",sd,name,len));
 
        s = getsock(sb,sd);
 
        if (s != INVALID_SOCKET) {
-               if (!addr_valid("host_getpeername2", name, len))
+               if (!addr_valid (L"host_getpeername2", name, len))
                        return -1;
                rp_name = (struct sockaddr *)get_real_address (name);
 
                if (getpeername(s,rp_name,&len)) {
                        SETERRNO;
-                       TRACE(("failed (%d)\n",sb->sb_errno));
+                       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
                } else {
-                       TRACE(("%d\n",len));
+                       BSDTRACE((L"%d\n",len));
                        prepamigaaddr(rp_name,len);
                        put_long (namelen,len);
                        return 0;
@@ -1473,7 +1468,7 @@ uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request,
        uae_u32 data;
        int success = SOCKET_ERROR;
 
-       TRACE(("IoctlSocket(%d,0x%lx,0x%lx) ",sd,request,arg));
+       BSDTRACE((L"IoctlSocket(%d,0x%lx,0x%lx) ",sd,request,arg));
        sd++;
        s = getsock(sb,sd);
 
@@ -1489,19 +1484,19 @@ uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request,
                            success = 0;
                        break;
                        case FIONBIO:
-                               TRACE(("[FIONBIO] -> "));
+                               BSDTRACE((L"[FIONBIO] -> "));
                                if (get_long (arg)) {
-                                       TRACE(("nonblocking\n"));
+                                       BSDTRACE((L"nonblocking\n"));
                                        sb->ftable[sd-1] &= ~SF_BLOCKING;
                                } else {
-                                       TRACE(("blocking\n"));
+                                       BSDTRACE((L"blocking\n"));
                                        sb->ftable[sd-1] |= SF_BLOCKING;
                                }
                                success = 0;
                                break;
                        case FIONREAD:
                                ioctlsocket(s,request,(u_long *)&data);
-                               TRACE(("[FIONREAD] -> %d\n",data));
+                               BSDTRACE((L"[FIONREAD] -> %d\n",data));
                                put_long (arg,data);
                                success = 0;
                                break;
@@ -1509,7 +1504,7 @@ uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request,
                                if (get_long (arg)) {
                                        sb->ftable[sd-1] |= REP_ALL;
 
-                                       TRACE(("[FIOASYNC] -> enabled\n"));
+                                       BSDTRACE((L"[FIOASYNC] -> enabled\n"));
                                        if (sb->mtable[sd-1] || (sb->mtable[sd-1] = allocasyncmsg(sb,sd,s))) {
                                                WSAAsyncSelect(s,hWndSelector ? hAmigaWnd : bsd-> hSockWnd, sb->mtable[sd-1],
                                                        FD_ACCEPT | FD_CONNECT | FD_OOB | FD_READ | FD_WRITE | FD_CLOSE);
@@ -1518,12 +1513,12 @@ uae_u32 host_IoctlSocket(TrapContext *context, SB, uae_u32 sd, uae_u32 request,
                                        }
                                }
                                else
-                                       write_log (("BSDSOCK: WARNING - FIOASYNC disabling unsupported.\n"));
+                                       write_log (L"BSDSOCK: WARNING - FIOASYNC disabling unsupported.\n");
 
                                success = -1;
                                break;
                        default:
-                               write_log ("BSDSOCK: WARNING - Unknown IoctlSocket request: 0x%08lx\n", request);
+                               write_log (L"BSDSOCK: WARNING - Unknown IoctlSocket request: 0x%08lx\n", request);
                                bsdsocklib_seterrno(sb, 22); // EINVAL
                                break;
                }
@@ -1537,7 +1532,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd)
     unsigned int wMsg;
     SOCKET s;
 
-    TRACE(("CloseSocket(%d) -> ",sd));
+    BSDTRACE((L"CloseSocket(%d) -> ",sd));
        sd++;
 
     s = getsock(sb,sd);
@@ -1558,7 +1553,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd)
                        shutdown(s,1);
                        if (!closesocket(s)) {
                                releasesock(sb,sd);
-                               TRACE(("OK\n"));
+                               BSDTRACE((L"OK\n"));
                                return 0;
                        }
 
@@ -1575,7 +1570,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd)
                                cancelasyncmsg(context, wMsg);
 
                                if (sb->eintr) {
-                                       TRACE(("[interrupted]\n"));
+                                       BSDTRACE((L"[interrupted]\n"));
                                        break;
                                }
                        } else
@@ -1585,7 +1580,7 @@ int host_CloseSocket(TrapContext *context, SB, int sd)
                ENDBLOCKING;
     }
 
-    TRACE(("failed (%d)\n",sb->sb_errno));
+    BSDTRACE((L"failed (%d)\n",sb->sb_errno));
 
     return -1;
 }
@@ -1610,7 +1605,7 @@ static void makesocktable(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, i
        }
 
        if (nfds > sb->dtablesize) {
-               write_log ("BSDSOCK: ERROR - select()ing more sockets (%d) than socket descriptors available (%d)!\n", nfds, sb->dtablesize);
+               write_log (L"BSDSOCK: ERROR - select()ing more sockets (%d) than socket descriptors available (%d)!\n", nfds, sb->dtablesize);
                nfds = sb->dtablesize;
        }
 
@@ -1632,7 +1627,7 @@ static void makesocktable(SB, uae_u32 fd_set_amiga, struct fd_set *fd_set_win, i
                                        fd_set_win->fd_array[fd_set_win->fd_count++] = s;
 
                                        if (fd_set_win->fd_count >= FD_SETSIZE) {
-                                               write_log ("BSDSOCK: ERROR - select()ing more sockets (%d) than the hard-coded fd_set limit (%d) - please report\n", nfds, FD_SETSIZE);
+                                               write_log (L"BSDSOCK: ERROR - select()ing more sockets (%d) than the hard-coded fd_set limit (%d) - please report\n", nfds, FD_SETSIZE);
                                                return;
                                        }
                                }
@@ -1713,10 +1708,10 @@ static unsigned int thread_WaitSelect2(void *indexp)
                    if (timeout) {
                            tv.tv_sec = get_long (timeout);
                            tv.tv_usec = get_long (timeout+4);
-                           TRACE(("(timeout: %d.%06d) ",tv.tv_sec,tv.tv_usec));
+                           BSDTRACE((L"(timeout: %d.%06d) ",tv.tv_sec,tv.tv_usec));
                    }
 
-                   TRACE(("-> "));
+                   BSDTRACE((L"-> "));
 
                    resultval = select(nfds+1, &readsocks, writefds ? &writesocks : NULL,
                                        exceptfds ? &exceptsocks : NULL, timeout ? &tv : 0);
@@ -1751,7 +1746,7 @@ static unsigned int thread_WaitSelect2(void *indexp)
                        }
                    if (sb->resultval == SOCKET_ERROR) {
                            SETERRNO;
-                           TRACE(("failed (%d) - ",sb->sb_errno));
+                           BSDTRACE((L"failed (%d) - ",sb->sb_errno));
                            if (readfds)
                                        fd_zero(readfds,nfds);
                            if (writefds)
@@ -1773,7 +1768,7 @@ static unsigned int thread_WaitSelect2(void *indexp)
                    SetEvent(sb->hEvent);
            }
     }
-       write_log ("BSDSOCK: thread_WaitSelect2 terminated\n");
+       write_log (L"BSDSOCK: thread_WaitSelect2 terminated\n");
     THREADEND(result);
     return result;
 }
@@ -1795,12 +1790,12 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua
 
        wssigs = sigmp ? get_long (sigmp) : 0;
 
-       TRACE(("WaitSelect(%d,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx) ",
+       BSDTRACE((L"WaitSelect(%d,0x%lx,0x%lx,0x%lx,0x%lx,0x%lx) ",
                nfds, readfds, writefds, exceptfds, timeout, wssigs));
 
        if (!readfds && !writefds && !exceptfds && !timeout && !wssigs) {
                sb->resultval = 0;
-               TRACE(("-> [ignored]\n"));
+               BSDTRACE((L"-> [ignored]\n"));
                return;
        }
        if (wssigs) {
@@ -1809,7 +1804,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua
                sigs = CallLib (context, get_long (4),-0x132) & wssigs; // SetSignal()
 
                if (sigs) {
-                       TRACE(("-> [preempted by signals 0x%08lx]\n",sigs & wssigs));
+                       BSDTRACE((L"-> [preempted by signals 0x%08lx]\n",sigs & wssigs));
                        put_long (sigmp,sigs & wssigs);
                        // Check for zero address -> otherwise WinUAE crashes
                        if (readfds)
@@ -1857,7 +1852,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua
                                bsd->hThreads[i] = THREAD(thread_WaitSelect, &threadindextable[i]);
                                if (bsd->hEvents[i] == NULL || bsd->hThreads[i] == NULL) {
                                        bsd->hThreads[i] = 0;
-                                       write_log ("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",
+                                       write_log (L"BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",
                                                GetLastError());
                                        bsdsocklib_seterrno(sb,12); // ENOMEM
                                        sb->resultval = -1;
@@ -1871,7 +1866,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua
        }
 
        if (i >= MAX_SELECT_THREADS)
-               write_log ("BSDSOCK: ERROR - Too many select()s\n");
+               write_log (L"BSDSOCK: ERROR - Too many select()s\n");
        else {
                SOCKET newsock = INVALID_SOCKET;
 
@@ -1896,7 +1891,7 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua
 */
                if (sb->needAbort) {
                        if ((newsock = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)) == INVALID_SOCKET)
-                               write_log ("BSDSOCK: ERROR - Cannot create socket: %d\n", WSAGetLastError());
+                               write_log (L"BSDSOCK: ERROR - Cannot create socket: %d\n", WSAGetLastError());
                        shutdown(sb->sockAbort,1);
                        if (newsock != sb->sockAbort) {
                                shutdown(sb->sockAbort, 1);
@@ -1915,11 +1910,11 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua
                    put_long (sigmp,sigs & wssigs);
 
                    if (sigs & sb->eintrsigs) {
-                           TRACE(("[interrupted]\n"));
+                           BSDTRACE((L"[interrupted]\n"));
                            sb->resultval = -1;
                            bsdsocklib_seterrno(sb,4); // EINTR
                    } else if (sigs & wssigs) {
-                           TRACE(("[interrupted by signals 0x%08lx]\n",sigs & wssigs));
+                           BSDTRACE((L"[interrupted by signals 0x%08lx]\n",sigs & wssigs));
                                if (readfds) fd_zero(readfds,nfds);
                                if (writefds) fd_zero(writefds,nfds);
                                if (exceptfds) fd_zero(exceptfds,nfds);
@@ -1927,34 +1922,34 @@ void host_WaitSelect(TrapContext *context, SB, uae_u32 nfds, uae_u32 readfds, ua
                            sb->resultval = 0;
                    }
                        if (sb->resultval >= 0) {
-                               TRACE(("%d\n",sb->resultval));
+                               BSDTRACE((L"%d\n",sb->resultval));
                        } else {
-                               TRACE(("%d errno %d\n",sb->resultval,sb->sb_errno));
+                               BSDTRACE((L"%d errno %d\n",sb->resultval,sb->sb_errno));
                        }
                } else
-                       TRACE(("%d\n",sb->resultval));
+                       BSDTRACE((L"%d\n",sb->resultval));
        }
 }
 
 uae_u32 host_Inet_NtoA(TrapContext *context, SB, uae_u32 in)
 {
-       char *addr;
+       uae_char *addr;
        struct in_addr ina;
        uae_u32 scratchbuf;
 
        *(uae_u32 *)&ina = htonl(in);
 
-       TRACE(("Inet_NtoA(%lx) -> ",in));
+       BSDTRACE((L"Inet_NtoA(%lx) -> ",in));
 
        if ((addr = inet_ntoa(ina)) != NULL) {
                scratchbuf = m68k_areg (&context->regs,6) + offsetof(struct UAEBSDBase,scratchbuf);
                strncpyha(scratchbuf,addr,SCRATCHBUFSIZE);
-               TRACE(("%s\n",addr));
+               BSDTRACE((L"%s\n",addr));
                return scratchbuf;
        } else
                SETERRNO;
 
-       TRACE(("failed (%d)\n",sb->sb_errno));
+       BSDTRACE((L"failed (%d)\n",sb->sb_errno));
 
        return 0;
 }
@@ -1962,15 +1957,15 @@ uae_u32 host_Inet_NtoA(TrapContext *context, SB, uae_u32 in)
 uae_u32 host_inet_addr(uae_u32 cp)
 {
        uae_u32 addr;
-       char *cp_rp;
+       uae_char *cp_rp;
 
-       if (!addr_valid("host_inet_addr", cp, 4))
+       if (!addr_valid (L"host_inet_addr", cp, 4))
                return 0;
        cp_rp = get_real_address (cp);
 
        addr = htonl(inet_addr(cp_rp));
 
-       TRACE(("inet_addr(%s) -> 0x%08lx\n",cp_rp,addr));
+       BSDTRACE((L"inet_addr(%s) -> 0x%08lx\n",cp_rp,addr));
 
        return addr;
 }
@@ -1996,7 +1991,7 @@ static BOOL CheckOnline(SB)
        return bReturn;
 }
 
-static unsigned int thread_get2(void *indexp)
+static unsigned int thread_get2 (void *indexp)
 {
        int index = *((int*)indexp);
        unsigned int result = 0;
@@ -2004,7 +1999,7 @@ static unsigned int thread_get2(void *indexp)
        uae_u32 name;
        uae_u32 namelen;
        long addrtype;
-       char *name_rp;
+       uae_char *name_rp;
        SB;
 
        while (bsd->hGetEvents[index]) {
@@ -2028,23 +2023,24 @@ static unsigned int thread_get2(void *indexp)
                                name = args->args2;
                                namelen = args->args3;
                                addrtype = args->args4;
-                               name_rp = "";
-                               if (addr_valid("thread_get1", name, 1))
+                               if (addr_valid (L"thread_get1", name, 1))
                                        name_rp = get_real_address (name);
+                               else
+                                       name_rp = "";
 
-                               if (strchr(name_rp, '.') == 0 || CheckOnline(sb) == TRUE) {
+                               if (strchr (name_rp, '.') == 0 || CheckOnline(sb) == TRUE) {
                                        // Local Address or Internet Online ?
                                        if (addrtype == -1) {
-                                               host = gethostbyname(name_rp);
+                                               host = gethostbyname (name_rp);
                                        } else {
-                                               host = gethostbyaddr(name_rp, namelen, addrtype);
+                                               host = gethostbyaddr (name_rp, namelen, addrtype);
                                        }
                                        if (bsd->threadGetargs_inuse[index] != -1) {
                                                // No CTRL-C Signal
                                                if (host == 0) {
                                                        // Error occured
                                                        SETERRNO;
-                                                       TRACE(("failed (%d) - ", sb->sb_errno));
+                                                       BSDTRACE((L"failed (%d) - ", sb->sb_errno));
                                                } else {
                                                        bsdsocklib_seterrno(sb, 0);
                                                        memcpy(args->buf, host, sizeof(HOSTENT));
@@ -2058,15 +2054,16 @@ static unsigned int thread_get2(void *indexp)
                                struct protoent  *proto;
 
                                name = args->args2;
-                               name_rp = "";
-                               if (addr_valid("thread_get2", name, 1))
+                               if (addr_valid (L"thread_get2", name, 1))
                                        name_rp = get_real_address (name);
+                               else
+                                       name_rp = "";
                                proto = getprotobyname (name_rp);
                                if (bsd->threadGetargs_inuse[index] != -1) { // No CTRL-C Signal
                                        if (proto == 0) {
                                                // Error occured
                                                SETERRNO;
-                                               TRACE(("failed (%d) - ", sb->sb_errno));
+                                               BSDTRACE((L"failed (%d) - ", sb->sb_errno));
                                        } else {
                                                bsdsocklib_seterrno(sb, 0);
                                                memcpy(args->buf, proto, sizeof(struct protoent));
@@ -2079,7 +2076,7 @@ static unsigned int thread_get2(void *indexp)
                                uae_u32 nameport;
                                uae_u32 proto;
                                uae_u32 type;
-                               char *proto_rp = 0;
+                               uae_char *proto_rp = 0;
                                struct servent *serv;
 
                                nameport = args->args2;
@@ -2087,14 +2084,14 @@ static unsigned int thread_get2(void *indexp)
                                type = args->args4;
 
                                if (proto) {
-                                       if (addr_valid("thread_get3", proto, 1))
+                                       if (addr_valid (L"thread_get3", proto, 1))
                                                proto_rp = get_real_address (proto);
                                }
 
                                if (type) {
                                        serv = getservbyport(nameport, proto_rp);
                                } else {
-                                       if (addr_valid("thread_get4", nameport, 1))
+                                       if (addr_valid (L"thread_get4", nameport, 1))
                                                name_rp = get_real_address (nameport);
                                        serv = getservbyname(name_rp, proto_rp);
                                }
@@ -2103,7 +2100,7 @@ static unsigned int thread_get2(void *indexp)
                                        if (serv == 0) {
                                                // Error occured
                                                SETERRNO;
-                                               TRACE(("failed (%d) - ", sb->sb_errno));
+                                               BSDTRACE((L"failed (%d) - ", sb->sb_errno));
                                        } else {
                                                bsdsocklib_seterrno(sb, 0);
                                                memcpy(args->buf, serv, sizeof(struct servent));
@@ -2111,7 +2108,7 @@ static unsigned int thread_get2(void *indexp)
                                }
                        }
 
-                   TRACE(("-> "));
+                   BSDTRACE((L"-> "));
 
                        if (bsd->threadGetargs_inuse[index] != -1)
                                SETSIGNAL;
@@ -2120,7 +2117,7 @@ static unsigned int thread_get2(void *indexp)
 
                }
     }
-       write_log ("BSDSOCK: thread_get2 terminated\n");
+       write_log (L"BSDSOCK: thread_get2 terminated\n");
        THREADEND(result);
     return result;
 }
@@ -2153,7 +2150,7 @@ static volatile struct threadargs *run_get_thread(TrapContext *context, SB, stru
                                bsd->hGetThreads[i] = THREAD(thread_get, &threadindextable[i]);
                                if (bsd->hGetEvents[i] == NULL || bsd->hGetThreads[i] == NULL) {
                                        bsd->hGetThreads[i] = NULL;
-                                       write_log ("BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",
+                                       write_log (L"BSDSOCK: ERROR - Thread/Event creation failed - error code: %d\n",
                                                GetLastError());
                                        bsdsocklib_seterrno(sb, 12); // ENOMEM
                                        sb->resultval = -1;
@@ -2165,7 +2162,7 @@ static volatile struct threadargs *run_get_thread(TrapContext *context, SB, stru
        }
 
        if (i >= MAX_GET_THREADS) {
-               write_log ("BSDSOCK: ERROR - Too many gethostbyname()s\n");
+               write_log (L"BSDSOCK: ERROR - Too many gethostbyname()s\n");
                bsdsocklib_seterrno(sb, 12); // ENOMEM
                sb->resultval = -1;
                return 0;
@@ -2187,21 +2184,21 @@ static volatile struct threadargs *run_get_thread(TrapContext *context, SB, stru
        return &bsd->threadGetargs[i];
 }
 
-void host_gethostbynameaddr(TrapContext *context, SB, uae_u32 name, uae_u32 namelen, long addrtype)
+void host_gethostbynameaddr (TrapContext *context, SB, uae_u32 name, uae_u32 namelen, long addrtype)
 {
        HOSTENT *h;
        int size, numaliases = 0, numaddr = 0;
        uae_u32 aptr;
-       char *name_rp;
+       uae_char *name_rp;
        int i;
        struct threadargs args;
        volatile struct threadargs *argsp;
        uae_u32 addr;
        uae_u32 *addr_list[2];
-       volatile char *buf;
+       volatile uae_char *buf;
        unsigned int wMsg = 0;
 
-//     char on = 1;
+//     TCHAR on        = 1;
 //     InternetSetOption(0,INTERNET_OPTION_SETTINGS_CHANGED,&on,strlen(&on));
 //  Do not use:        Causes locks with some machines
 
@@ -2210,11 +2207,11 @@ void host_gethostbynameaddr(TrapContext *context, SB, uae_u32 name, uae_u32 name
        buf = argsp->buf;
        name_rp = "";
 
-       if (addr_valid("host_gethostbynameaddr", name, 1))
+       if (addr_valid (L"host_gethostbynameaddr", name, 1))
                name_rp = get_real_address (name);
 
        if (addrtype == -1) {
-               TRACE(("gethostbyname(%s) -> ",name_rp));
+               BSDTRACE((L"gethostbyname(%s) -> ",name_rp));
 
                // workaround for numeric host "names"
                if ((addr = inet_addr(name_rp)) != INADDR_NONE) {
@@ -2223,14 +2220,14 @@ void host_gethostbynameaddr(TrapContext *context, SB, uae_u32 name, uae_u32 name
                        ((HOSTENT *)buf)->h_aliases = NULL;
                        ((HOSTENT *)buf)->h_addrtype = AF_INET;
                        ((HOSTENT *)buf)->h_length = 4;
-                       ((HOSTENT *)buf)->h_addr_list = (char **)&addr_list;
+                       ((HOSTENT *)buf)->h_addr_list = (uae_char**)&addr_list;
                        addr_list[0] = &addr;
                        addr_list[1] = NULL;
 
                        goto kludge;
                }
        } else {
-               TRACE(("gethostbyaddr(0x%lx,0x%lx,%ld) -> ",name,namelen,addrtype));
+               BSDTRACE((L"gethostbyaddr(0x%lx,0x%lx,%ld) -> ",name,namelen,addrtype));
        }
 
        argsp->sb = sb;
@@ -2269,8 +2266,8 @@ kludge:
                sb->hostent = uae_AllocMem(context, size, 0);
 
                if (!sb->hostent) {
-                       write_log ("BSDSOCK: WARNING - gethostby%s() ran out of Amiga memory "
-                               "(couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",
+                       write_log (L"BSDSOCK: WARNING - gethostby%s() ran out of Amiga memory "
+                               L"(couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",
                                addrtype == -1 ? "name" : "addr", size, name_rp);
                        bsdsocklib_seterrno(sb, 12); // ENOMEM
                        return;
@@ -2287,19 +2284,19 @@ kludge:
                put_long (sb->hostent + 16, sb->hostent + 24 + numaliases * 4);
 
                for (i = 0; i < numaliases; i++)
-                       put_long (sb->hostent + 20 + i * 4, addstr(&aptr, h->h_aliases[i]));
+                       put_long (sb->hostent + 20 + i * 4, addstr_ansi (&aptr, h->h_aliases[i]));
                put_long (sb->hostent + 20 + numaliases * 4, 0);
                for (i = 0; i < numaddr; i++)
-                       put_long (sb->hostent + 24 + (numaliases + i) * 4, addmem(&aptr, h->h_addr_list[i], h->h_length));
+                       put_long (sb->hostent + 24 + (numaliases + i) * 4, addmem (&aptr, h->h_addr_list[i], h->h_length));
                put_long (sb->hostent + 24 + numaliases * 4 + numaddr * 4, 0);
                put_long (sb->hostent, aptr);
-               addstr(&aptr, h->h_name);
+               addstr_ansi (&aptr, h->h_name);
 
-               TRACE(("OK (%s)\n", h->h_name));
+               BSDTRACE((L"OK (%s)\n", h->h_name));
                bsdsocklib_seterrno(sb, 0);
 
        } else {
-               TRACE(("failed (%d/%d)\n", sb->sb_errno, sb->sb_herrno));
+               BSDTRACE((L"failed (%d/%d)\n", sb->sb_errno, sb->sb_herrno));
        }
 
 }
@@ -2309,16 +2306,16 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name)
        PROTOENT *p;
        int size, numaliases = 0;
        uae_u32 aptr;
-       char *name_rp;
+       uae_char *name_rp;
        int i;
        struct threadargs args;
        volatile struct threadargs *argsp;
 
        name_rp = "";
-       if (addr_valid("host_gethostbynameaddr", name, 1))
+       if (addr_valid (L"host_gethostbynameaddr", name, 1))
                name_rp = get_real_address (name);
 
-       TRACE(("getprotobyname(%s) -> ",name_rp));
+       BSDTRACE((L"getprotobyname(%s) -> ",name_rp));
 
        memset(&args, 0, sizeof (args));
        argsp = &args;
@@ -2348,8 +2345,8 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name)
                sb->protoent = uae_AllocMem(context, size, 0);
 
                if (!sb->protoent) {
-                       write_log ("BSDSOCK: WARNING - getprotobyname() ran out of Amiga memory "
-                               "(couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",
+                       write_log (L"BSDSOCK: WARNING - getprotobyname() ran out of Amiga memory "
+                               L"(couldn't allocate %ld bytes) while returning result of lookup for '%s'\n",
                                size, name_rp);
                        bsdsocklib_seterrno(sb,12); // ENOMEM
                        return;
@@ -2364,15 +2361,15 @@ void host_getprotobyname(TrapContext *context, SB, uae_u32 name)
                put_long (sb->protoent+8,p->p_proto);
 
                for (i = 0; i < numaliases; i++)
-                       put_long (sb->protoent + 12 + i * 4, addstr(&aptr, p->p_aliases[i]));
+                       put_long (sb->protoent + 12 + i * 4, addstr_ansi (&aptr, p->p_aliases[i]));
                put_long (sb->protoent + 12 + numaliases * 4,0);
                put_long (sb->protoent, aptr);
-               addstr(&aptr, p->p_name);
-               TRACE(("OK (%s, %d)\n", p->p_name, p->p_proto));
-               bsdsocklib_seterrno(sb,0);
+               addstr_ansi (&aptr, p->p_name);
+               BSDTRACE((L"OK (%s, %d)\n", p->p_name, p->p_proto));
+               bsdsocklib_seterrno (sb,0);
 
        } else {
-               TRACE(("failed (%d)\n", sb->sb_errno));
+               BSDTRACE((L"failed (%d)\n", sb->sb_errno));
        }
 
 }
@@ -2387,22 +2384,22 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32
        SERVENT *s;
        int size, numaliases = 0;
        uae_u32 aptr;
-       char *name_rp = NULL, *proto_rp = NULL;
+       TCHAR *name_rp = NULL, *proto_rp = NULL;
        int i;
        struct threadargs args;
        volatile struct threadargs *argsp;
 
        if (proto) {
-               if (addr_valid("host_getservbynameport1", proto, 1))
-                       proto_rp = get_real_address (proto);
+               if (addr_valid (L"host_getservbynameport1", proto, 1))
+                       proto_rp = au (get_real_address (proto));
        }
 
        if (type) {
-               TRACE(("getservbyport(%d,%s) -> ",nameport,proto_rp ? proto_rp : "NULL"));
+               BSDTRACE((L"getservbyport(%d,%s) -> ",nameport, proto_rp ? proto_rp : L"NULL"));
        } else {
-               if (addr_valid("host_getservbynameport2", nameport, 1))
-                       name_rp = get_real_address (nameport);
-               TRACE(("getservbyname(%s,%s) -> ",name_rp,proto_rp ? proto_rp : "NULL"));
+               if (addr_valid (L"host_getservbynameport2", nameport, 1))
+                       name_rp = au (get_real_address (nameport));
+               BSDTRACE((L"getservbyname(%s,%s) -> ",name_rp, proto_rp ? proto_rp : L"NULL"));
        }
 
        memset(&args, 0, sizeof (args));
@@ -2413,7 +2410,7 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32
        argsp->args3 = proto;
        argsp->args4 = type;
 
-       argsp = run_get_thread(context, sb, &args);
+       argsp = run_get_thread (context, sb, &args);
        if (!argsp)
                return;
 
@@ -2438,7 +2435,7 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32
                sb->servent = uae_AllocMem(context, size, 0);
 
                if (!sb->servent) {
-                       write_log ("BSDSOCK: WARNING - getservby%s() ran out of Amiga memory (couldn't allocate %ld bytes)\n", type ? "port" : "name", size);
+                       write_log (L"BSDSOCK: WARNING - getservby%s() ran out of Amiga memory (couldn't allocate %ld bytes)\n", type ? "port" : "name", size);
                        bsdsocklib_seterrno(sb, 12); // ENOMEM
                        return;
                }
@@ -2452,25 +2449,25 @@ void host_getservbynameport(TrapContext *context, SB, uae_u32 nameport, uae_u32
                put_long (sb->servent + 8, (unsigned short)htons(s->s_port));
 
                for (i = 0; i < numaliases; i++)
-                       put_long (sb->servent + 16 + i * 4,addstr(&aptr,s->s_aliases[i]));
+                       put_long (sb->servent + 16 + i * 4,addstr_ansi (&aptr,s->s_aliases[i]));
                put_long (sb->servent + 16 + numaliases * 4,0);
                put_long (sb->servent, aptr);
-               addstr(&aptr, s->s_name);
+               addstr_ansi (&aptr, s->s_name);
                put_long (sb->servent + 12, aptr);
-               addstr(&aptr, s->s_proto);
+               addstr_ansi (&aptr, s->s_proto);
 
-               TRACE(("OK (%s, %d)\n", s->s_name, (unsigned short)htons(s->s_port)));
+               BSDTRACE((L"OK (%s, %d)\n", s->s_name, (unsigned short)htons(s->s_port)));
                bsdsocklib_seterrno(sb, 0);
 
        } else {
-               TRACE(("failed (%d)\n",sb->sb_errno));
+               BSDTRACE((L"failed (%d)\n",sb->sb_errno));
        }
 
 }
 
 uae_u32 host_gethostname(uae_u32 name, uae_u32 namelen)
 {
-       if (!addr_valid("host_gethostname", name, namelen))
+       if (!addr_valid (L"host_gethostname", name, namelen))
                return -1;
        return gethostname(get_real_address (name),namelen);
 }
index 6ef65b025505d6aa8c5c731c666c3d97d85a3fa9..5df11c63075ede758acf743847c0c22a0d955066 100644 (file)
@@ -45,16 +45,16 @@ int caps_init (void)
     int i;
     HMODULE h;
     struct CapsVersionInfo cvi;
-    char *dllname = "CAPSImg.dll";
+    TCHAR *dllname = L"CAPSImg.dll";
 
     if (init)
        return 1;
     h = WIN32_LoadLibrary (dllname);
     if (!h) {
-       char tmp[MAX_DPATH];
+       TCHAR tmp[MAX_DPATH];
        if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, tmp))) {
-           strcat (tmp, "\\Software Preservation Society\\");
-           strcat (tmp, dllname);
+           _tcscat (tmp, L"\\Software Preservation Society\\");
+           _tcscat (tmp, dllname);
            h = LoadLibrary (tmp);
            if (!h) {
                if (noticed)
@@ -85,7 +85,7 @@ int caps_init (void)
     init = 1;
     cvi.type = LIB_TYPE;
     pCAPSGetVersionInfo (&cvi, 0);
-    write_log ("CAPS: library version %d.%d\n", cvi.release, cvi.revision);
+    write_log (L"CAPS: library version %d.%d\n", cvi.release, cvi.revision);
     for (i = 0; i < 4; i++)
        caps_cont[i] = pCAPSAddImage ();
     return 1;
@@ -105,7 +105,7 @@ int caps_loadimage (struct zfile *zf, int drv, int *num_tracks)
     struct CapsImageInfo ci;
     int len, ret;
     uae_u8 *buf;
-    char s1[100];
+    TCHAR s1[100];
     struct CapsDateTimeExt *cdt;
 
     if (!caps_init ())
@@ -128,8 +128,8 @@ int caps_loadimage (struct zfile *zf, int drv, int *num_tracks)
     *num_tracks = (ci.maxcylinder - ci.mincylinder + 1) * (ci.maxhead - ci.minhead + 1);
     pCAPSLoadImage(caps_cont[drv], caps_flags);
     cdt = &ci.crdt;
-    sprintf (s1, "%d.%d.%d %d:%d:%d", cdt->day, cdt->month, cdt->year, cdt->hour, cdt->min, cdt->sec);
-    write_log ("caps: type:%d date:%s rel:%d rev:%d\n",
+    _stprintf (s1, L"%d.%d.%d %d:%d:%d", cdt->day, cdt->month, cdt->year, cdt->hour, cdt->min, cdt->sec);
+    write_log (L"caps: type:%d date:%s rel:%d rev:%d\n",
        ci.type, s1, ci.release, ci.revision);
     return 1;
 }
@@ -206,7 +206,7 @@ int caps_loadtrack (uae_u16 *mfmbuf, uae_u16 *tracktiming, int drv, int track, i
            tracktiming[i] = (uae_u16)ci.timebuf[i];
     }
 #if 0
-    write_log ("caps: drive:%d track:%d len:%d multi:%d timing:%d type:%d overlap:%d\n",
+    write_log (L"caps: drive:%d track:%d len:%d multi:%d timing:%d type:%d overlap:%d\n",
        drv, track, len, *multirev, ci.timelen, type, ci.overlap);
 #endif
     return 1;
index 12018858432fa179042ed0c5b9f718396f16d92c..7af7f98db91657dcf3f4299455235e631001468e 100644 (file)
@@ -28,7 +28,7 @@ static int clipboard_change;
 static void *clipboard_delayed_data;
 static int clipboard_delayed_size;
 
-static void debugwrite (const char *name, uae_u8 *p, int size)
+static void debugwrite (const TCHAR *name, uae_u8 *p, int size)
 {
     FILE *f;
     int cnt;
@@ -37,15 +37,15 @@ static void debugwrite (const char *name, uae_u8 *p, int size)
        return;
     cnt = 0;
     for (;;) {
-       char tmp[MAX_DPATH];
-       sprintf (tmp, "%s.%03d.dat", name, cnt);
-       f = fopen (tmp, "rb");
+       TCHAR tmp[MAX_DPATH];
+       _stprintf (tmp, L"%s.%03d.dat", name, cnt);
+       f = _tfopen (tmp, L"rb");
        if (f) {
            fclose (f);
            cnt++;
            continue;
        }
-        f = fopen (tmp, "wb");
+        f = _tfopen (tmp, L"wb");
        if (f) {
            fwrite (p, size, 1, f);
            fclose (f);
@@ -59,23 +59,23 @@ static void to_amiga_start (void)
     if (!clipboard_data)
        return;
     if (clipboard_debug) {
-       debugwrite ("clipboard_p2a", to_amiga, to_amiga_size);
+       debugwrite (L"clipboard_p2a", to_amiga, to_amiga_size);
     }
     put_long (clipboard_data, to_amiga_size);
     uae_Signal (get_long (clipboard_data + 8), 1 << 13);
 }
 
-static char *pctoamiga (const char *txt)
+static TCHAR *pctoamiga (const TCHAR *txt)
 {
     int len;
-    char *txt2;
+    TCHAR *txt2;
     int i, j;
 
-    len = strlen (txt) + 1;
-    txt2 = xmalloc (len);
+    len = _tcslen (txt) + 1;
+    txt2 = xmalloc (len * sizeof (TCHAR));
     j = 0;
     for (i = 0; i < len; i++) {
-       char c = txt[i];
+       TCHAR c = txt[i];
        if (c == 13)
            continue;
        txt2[j++] = c;
@@ -83,7 +83,7 @@ static char *pctoamiga (const char *txt)
     return txt2;
 }
 
-static int parsecsi (const char *txt, int off, int len)
+static int parsecsi (const uae_u8 *txt, int off, int len)
 {
     while (off < len) {
        if (txt[off] >= 0x40)
@@ -93,28 +93,29 @@ static int parsecsi (const char *txt, int off, int len)
     return off;
 }
 
-static char *amigatopc (const char *txt)
+static TCHAR *amigatopc (const uae_u8 *txt)
 {
     int i, j, cnt;
     int len, pc;
     char *txt2;
+    TCHAR *s;
 
     pc = 0;
     cnt = 0;
     len = strlen (txt) + 1;
     for (i = 0; i < len; i++) {
-       char c = txt[i];
+       TCHAR c = txt[i];
        if (c == 13)
            pc = 1;
        if (c == 10)
            cnt++;
     }
     if (pc)
-        return my_strdup (txt);
+        return my_strdup_ansi (txt);
     txt2 = xcalloc (len + cnt, 1);
     j = 0;
     for (i = 0; i < len; i++) {
-       char c = txt[i];
+       uae_u8 c = txt[i];
        if (c == 0 && i + 1 < len)
            continue;
        if (c == 10)
@@ -128,19 +129,23 @@ static char *amigatopc (const char *txt)
        }
        txt2[j++] = c;
     }
-    return txt2;
+    s = my_strdup_ansi (txt2);
+    xfree (txt2);
+    return s;
 }
 
 
-static void to_iff_text (char *pctxt)
+static void to_iff_text (TCHAR *pctxt)
 {
     uae_u8 b[] = { 'F','O','R','M',0,0,0,0,'F','T','X','T','C','H','R','S',0,0,0,0 };
     uae_u32 size;
     int txtlen;
-    char *txt;
-    
+    TCHAR *txt;
+    char *s;
+
     txt = pctoamiga (pctxt);
-    txtlen = strlen (txt);
+    s = ua (txt);
+    txtlen = strlen (s);
     xfree (to_amiga);
     size = txtlen + sizeof b + (txtlen & 1) - 8;
     b[4] = size >> 24;
@@ -155,18 +160,18 @@ static void to_iff_text (char *pctxt)
     to_amiga_size = sizeof b + txtlen + (txtlen & 1);
     to_amiga = xcalloc (to_amiga_size, 1);
     memcpy (to_amiga, b, sizeof b);
-    memcpy (to_amiga + sizeof b, txt, strlen (txt));
+    memcpy (to_amiga + sizeof b, s, txtlen);
     to_amiga_start ();
     xfree (txt);
+    xfree (s);
 }
 
-static int clipboard_put_text (const char *txt);
+static int clipboard_put_text (const TCHAR *txt);
 static void from_iff_text (uaecptr ftxt, uae_u32 len)
 {
     uae_u8 *addr = NULL, *eaddr;
     char *txt = NULL;
     int txtsize = 0;
-    char *pctxt;
 
 #if 0
     {
@@ -201,11 +206,13 @@ static void from_iff_text (uaecptr ftxt, uae_u32 len)
        else if (csize >= 1 && addr[-1] == 0x0d && addr[0] == 0x0a)
            addr++;
     }
-    if (txt == NULL)
-       txt = my_strdup ("");
-    pctxt = amigatopc (txt);
-    clipboard_put_text (pctxt);
-    xfree (pctxt);
+    if (txt == NULL) {
+        clipboard_put_text (L"");
+    } else {
+       TCHAR *pctxt = amigatopc (txt);
+       clipboard_put_text (pctxt);
+       xfree (pctxt);
+    }
     xfree (txt);
 }
 
@@ -239,7 +246,7 @@ static void to_iff_ilbm (HBITMAP hbmp)
        return;
     }
 
-    write_log ("BMP2IFF: W=%d H=%d bpp=%d\n", w, h, bpp);
+    write_log (L"BMP2IFF: W=%d H=%d bpp=%d\n", w, h, bpp);
 
     iffbpp = bpp > 8 ? 24 : bpp;
     cnt = 0;
@@ -264,7 +271,7 @@ static void to_iff_ilbm (HBITMAP hbmp)
            i >>= 1;
            iffbpp++;
        }
-       write_log ("BMP2IFF: Colors=%d BPP=%d\n", cnt, iffbpp);
+       write_log (L"BMP2IFF: Colors=%d BPP=%d\n", cnt, iffbpp);
     }
 
     bodysize = (((w + 15) & ~15) / 8) * h * iffbpp;
@@ -491,7 +498,7 @@ static void from_iff_ilbm (uaecptr ilbm, uae_u32 len)
            uae_u8 *caddr = NULL, *dptr;
            body = 1;
 
-           write_log ("W=%d H=%d planes=%d mask=%d comp=%d CAMG=%08x\n", w, h, planes, masking, compr, camg);
+           write_log (L"W=%d H=%d planes=%d mask=%d comp=%d CAMG=%08x\n", w, h, planes, masking, compr, camg);
 
            ham = 0; ehb = 0;
            if ((camg & 0x0800) && planes > 4)
@@ -648,7 +655,7 @@ static void from_iff (uaecptr data, uae_u32 len)
        return;
     addr = get_real_address (data);
     if (clipboard_debug)
-       debugwrite ("clipboard_a2p", addr, len);
+       debugwrite (L"clipboard_a2p", addr, len);
     if (memcmp ("FORM", addr, 4))
        return;
     if (!memcmp ("FTXT", addr + 8, 4))
@@ -666,19 +673,19 @@ static void clipboard_read (HWND hwnd)
     if (!OpenClipboard (hwnd))
        return;
     f = 0;
-    write_log ("clipboard: windows clipboard: ");
+    write_log (L"clipboard: windows clipboard: ");
     while (f = EnumClipboardFormats (f)) {
-       write_log ("%d ", f);
+       write_log (L"%d ", f);
        if (f == CF_TEXT)
            text = TRUE;
        if (f == CF_BITMAP)
            bmp = TRUE;
     }
-    write_log ("\n");
+    write_log (L"\n");
     if (text) {
        hglb = GetClipboardData (CF_TEXT); 
        if (hglb != NULL) { 
-           char *lptstr = GlobalLock (hglb); 
+           TCHAR *lptstr = GlobalLock (hglb); 
            if (lptstr != NULL) {
                to_iff_text (lptstr);
                GlobalUnlock (hglb);
@@ -730,11 +737,11 @@ static int clipboard_put_bmp_real (HBITMAP hbmp)
     ret = TRUE;
     CloseClipboard ();
     clipopen--;
-    write_log ("clipboard: BMP written to windows clipboard\n");
+    write_log (L"clipboard: BMP written to windows clipboard\n");
     return ret;
 }
 
-static int clipboard_put_text_real (const char *txt)
+static int clipboard_put_text_real (const TCHAR *txt)
 {
     HGLOBAL hglb;
     int ret = FALSE;
@@ -743,21 +750,21 @@ static int clipboard_put_text_real (const char *txt)
        return ret;
     clipopen++;
     EmptyClipboard (); 
-    hglb = GlobalAlloc (GMEM_MOVEABLE, strlen (txt) + 1);
+    hglb = GlobalAlloc (GMEM_MOVEABLE, (_tcslen (txt) + 1) * sizeof (TCHAR));
     if (hglb) {
-       char *lptstr = GlobalLock (hglb);
-       strcpy (lptstr, txt);
+       TCHAR *lptstr = GlobalLock (hglb);
+       _tcscpy (lptstr, txt);
        GlobalUnlock (hglb);
        SetClipboardData (CF_TEXT, hglb); 
        ret = TRUE;
     }
     CloseClipboard ();
     clipopen--;
-    write_log ("clipboard: text written to windows clipboard\n");
+    write_log (L"clipboard: text written to windows clipboard\n");
     return ret;
 }
 
-static int clipboard_put_text (const char *txt)
+static int clipboard_put_text (const TCHAR *txt)
 {
     if (!clipactive)
        return clipboard_put_text_real (txt);
@@ -779,25 +786,25 @@ static int clipboard_put_bmp (HBITMAP hbmp)
 void amiga_clipboard_die (void)
 {
     signaling = 0;
-    write_log ("clipboard not initialized\n");
+    write_log (L"clipboard not initialized\n");
 }
 
 void amiga_clipboard_init (void)
 {
     signaling = 0;
-    write_log ("clipboard initialized\n");
+    write_log (L"clipboard initialized\n");
 }
 
 void amiga_clipboard_task_start (uaecptr data)
 {
     clipboard_data = data;
     signaling = 1;
-    write_log ("clipboard task init: %08x\n", data);
+    write_log (L"clipboard task init: %08x\n", data);
 }
 
 uae_u32 amiga_clipboard_proc_start (void)
 {
-    write_log ("clipboard process init\n");
+    write_log (L"clipboard process init\n");
     signaling = 1;
     return clipboard_data;
 }
@@ -805,7 +812,7 @@ uae_u32 amiga_clipboard_proc_start (void)
 void amiga_clipboard_got_data (uaecptr data, uae_u32 size, uae_u32 actual)
 {
     uae_u8 *addr = get_real_address (data);
-    write_log ("clipboard: <-amiga, %08x %d %d\n", data, size, actual);
+    write_log (L"clipboard: <-amiga, %08x %d %d\n", data, size, actual);
     from_iff (data, actual);
 }
 
@@ -820,7 +827,7 @@ void amiga_clipboard_want_data (void)
        memcpy (raddr, to_amiga, size);
     }
     xfree (to_amiga);
-    write_log ("clipboard: ->amiga, %08x %d bytes\n", addr, size);
+    write_log (L"clipboard: ->amiga, %08x %d bytes\n", addr, size);
     to_amiga = NULL;
     to_amiga_size = 0;
 }
index e56e5ffa14dea079dd7200fe1c800ea44fccb103..7c4e0b4345957656466450aaa64d3c402c0acc4f 100644 (file)
@@ -45,7 +45,7 @@ BOOL debuggerinitializing = FALSE;
 extern uae_u32 get_fpsr();
 extern void set_fpsr(uae_u32 x);
 
-static char linebreak[] = {'\r', '\n', '\0'};
+static TCHAR linebreak[] = {'\r', '\n', '\0'};
 
 #define MAXLINES 250
 #define MAXINPUTHIST 50
@@ -59,7 +59,7 @@ static WORD* dlgtmpl;
 static int reopen;
 
 struct histnode {
-    char *command;
+    TCHAR *command;
        struct histnode *prev;
        struct histnode *next;
 };
@@ -71,7 +71,7 @@ struct debuggerpage {
     HWND ctrl[MAXPAGECONTROLS];
     uae_u32 memaddr;
        uae_u32 dasmaddr;
-    char addrinput[9];
+    TCHAR addrinput[9];
        int selection;
     int init;
        int autoset;
@@ -80,32 +80,32 @@ static struct debuggerpage dbgpage[MAXPAGES];
 static int currpage, pages;
 static int pagetype;
 
-char *pname[] = { "OUT1", "OUT2", "MEM1", "MEM2", "DASM1", "DASM2", "BRKPTS", "MISC", "CUSTOM" };
+TCHAR *pname[] = { L"OUT1", L"OUT2", L"MEM1", L"MEM2", L"DASM1", L"DASM2", L"BRKPTS", L"MISC", L"CUSTOM" };
 static int pstatuscolor[MAXPAGES];
 
 static int dbgwnd_minx = 800, dbgwnd_miny = 600;
 
 static BOOL useinternalcmd = FALSE;
-static char internalcmd[MAX_LINEWIDTH + 1];
+static TCHAR internalcmd[MAX_LINEWIDTH + 1];
 
-static const char *markinstr[] = { "JMP", "BT ", "RTS", "RTD", "RTE", "RTR", 0 };
-static const char *ucbranch[] = { "BSR", "JMP", "JSR", 0 };
-static const char *cbranch[] = { "B", "DB", "FB", "FDB", 0 };
-static const char *ccode[] = { "T ", "F ", "HI", "LS", "CC", "CS", "NE", "EQ",
-                                                               "VC", "VS", "PL", "MI", "GE", "LT", "GT", "LE", 0 };
+static const TCHAR *markinstr[] = { L"JMP", L"BT L", L"RTS", L"RTD", L"RTE", L"RTR", 0 };
+static const TCHAR *ucbranch[] = { L"BSR", L"JMP", L"JSR", 0 };
+static const TCHAR *cbranch[] = { L"B", L"DB", L"FB", L"FDB", 0 };
+static const TCHAR *ccode[] = { L"T ", L"F  ", L"HI", L"LS", L"CC", L"CS", L"NE", L"EQ",
+                               L"VC", L"VS", L"PL", L"MI", L"GE", L"LT", L"GT", L"LE", 0 };
 
 static void OutputCurrHistNode(HWND hWnd)
 {
     int txtlen;
-    char *buf;
+    TCHAR *buf;
 
     if (currhist->command) {
        txtlen = GetWindowTextLength(hWnd);
        buf = malloc(txtlen + 1);
        GetWindowText(hWnd, buf, txtlen + 1);
-       if (strcmp(buf, currhist->command)) {
+       if (_tcscmp(buf, currhist->command)) {
            SetWindowText(hWnd, currhist->command);
-           txtlen = strlen(currhist->command);
+           txtlen = _tcslen(currhist->command);
            SendMessage(hWnd, EM_SETSEL, (WPARAM)txtlen, (LPARAM)txtlen);
            SendMessage(hWnd, EM_SETSEL, -1, -1);
        }
@@ -155,12 +155,12 @@ static void DeleteFromHistory(int count)
     }
 }
 
-static void AddToHistory(const char *command)
+static void AddToHistory(const TCHAR *command)
 {
     struct histnode *tmp;
 
     currhist = NULL;
-    if (histcount > 0 && !strcmp(command, lasthist->command))
+    if (histcount > 0 && !_tcscmp(command, lasthist->command))
        return;
     else if (histcount == MAXINPUTHIST)
        DeleteFromHistory(1);
@@ -168,7 +168,7 @@ static void AddToHistory(const char *command)
     lasthist = malloc(sizeof(struct histnode));
     if (histcount == 0)
        firsthist = lasthist;
-    lasthist->command = strdup(command);
+    lasthist->command = my_strdup(command);
     lasthist->next = NULL;
     lasthist->prev = tmp;
     if (tmp)
@@ -176,33 +176,33 @@ static void AddToHistory(const char *command)
     histcount++;
 }
 
-int GetInput (char *out, int maxlen)
+int GetInput (TCHAR *out, int maxlen)
 {
     HWND hInput;
-    int chars;
+    int TCHARs;
 
     if (!hDbgWnd)
        return 0;
     hInput = GetDlgItem(hDbgWnd, IDC_DBG_INPUT);
-    chars = GetWindowText(hInput, out, maxlen);
-    if (chars == 0)
+    TCHARs = GetWindowText(hInput, out, maxlen);
+    if (TCHARs == 0)
        return 0;
     WriteOutput(linebreak + 1, 2);
-    WriteOutput(out, strlen(out));
+    WriteOutput(out, _tcslen(out));
     WriteOutput(linebreak + 1, 2);
     AddToHistory(out);
-    SetWindowText(hInput, "");
-    return chars;
+    SetWindowText(hInput, L"");
+    return TCHARs;
 }
 
-static int CheckLineLimit(HWND hWnd, const char *out)
+static int CheckLineLimit(HWND hWnd, const TCHAR *out)
 {
-    char *tmp, *p;
+    TCHAR *tmp, *p;
     int lines_have, lines_new = 0, lastchr, txtlen, visible;
 
-    tmp = (char *)out;
+    tmp = (TCHAR *)out;
     lines_have = SendMessage(hWnd, EM_GETLINECOUNT, 0, 0);
-    while (strlen(tmp) > 0 && (p = strchr(tmp, '\n')) > 0) {
+    while (_tcslen(tmp) > 0 && (p = _tcschr(tmp, '\n')) > 0) {
        lines_new++;
        tmp = p + 1;
     }
@@ -225,37 +225,37 @@ static int CheckLineLimit(HWND hWnd, const char *out)
     return 1;
 }
 
-void WriteOutput(const char *out, int len)
+void WriteOutput(const TCHAR *out, int len)
 {
     int txtlen, pos = 0, count, index, leave = 0;
-    char *buf = 0, *p, *tmp;
+    TCHAR *buf = 0, *p, *tmp;
 
-    if (!hOutput || !strcmp(out, ">") || len == 0)
+    if (!hOutput || !_tcscmp(out, L">") || len == 0)
        return;
     if (!CheckLineLimit(hOutput, out))
        return;
-    tmp = (char *)out;
+    tmp = (TCHAR *)out;
     for(;;) {
-       p = strchr(tmp, '\n');
+       p = _tcschr(tmp, '\n');
        if (p) {
            pos = p - tmp + 1;
            if (pos > (MAX_LINEWIDTH + 1))
                pos = MAX_LINEWIDTH + 1;
            buf = xmalloc(pos + 2);
            memset(buf, 0, pos + 2);
-           strncpy(buf, tmp, pos - 1);
-           strcat(buf, linebreak);
-       } else if (strlen(tmp) == 0) {
+           _tcsncmp(buf, tmp, pos - 1);
+           _tcscat(buf, linebreak);
+       } else if (_tcslen(tmp) == 0) {
            leave = 1;
        } else {
            count = SendMessage(hOutput, EM_GETLINECOUNT, 0, 0);
            index = SendMessage(hOutput, EM_LINEINDEX, count - 1, 0);
            txtlen = SendMessage(hOutput, EM_LINELENGTH, index, 0);
-           if (strlen(tmp) + txtlen > MAX_LINEWIDTH) {
+           if (_tcslen(tmp) + txtlen > MAX_LINEWIDTH) {
                buf = xmalloc(MAX_LINEWIDTH + 3 - txtlen);
                memset(buf, 0, MAX_LINEWIDTH + 3 - txtlen);
-               strncpy(buf, tmp, MAX_LINEWIDTH - txtlen);
-               strcat(buf, linebreak);
+               _tcsncmp(buf, tmp, MAX_LINEWIDTH - txtlen);
+               _tcscat(buf, linebreak);
            }
            leave = 1;
        }
@@ -274,20 +274,20 @@ void WriteOutput(const char *out, int len)
 
 static HWND ulbs_hwnd;
 static int ulbs_pos;
-static void UpdateListboxString(HWND hWnd, int pos, char *out, int mark)
+static void UpdateListboxString(HWND hWnd, int pos, TCHAR *out, int mark)
 {
     int count;
-    char text[MAX_LINEWIDTH + 1], *p;
+    TCHAR text[MAX_LINEWIDTH + 1], *p;
     COLORREF cr;
 
     if (!IsWindowEnabled(hWnd)) {
-       p = strchr(out, ':');
+       p = _tcschr(out, ':');
        if (p)
            *(p + 1) = '\0';
     }
-    if (strlen(out) > MAX_LINEWIDTH)
+    if (_tcslen(out) > MAX_LINEWIDTH)
        out[MAX_LINEWIDTH] = '\0';
-    p = strchr(out, '\n');
+    p = _tcschr(out, '\n');
     if (p)
        *p = '\0';
     cr = GetSysColor(COLOR_WINDOWTEXT);
@@ -295,7 +295,7 @@ static void UpdateListboxString(HWND hWnd, int pos, char *out, int mark)
     if (pos < count) {
        memset(text, 0, MAX_LINEWIDTH + 1);
        SendMessage(hWnd, LB_GETTEXT, pos, (LPARAM)((LPTSTR)text));
-       if (strcmp(out, text) != 0 && mark)
+       if (_tcscmp(out, text) != 0 && mark)
            cr = GetSysColor(COLOR_HIGHLIGHT);
        SendMessage(hWnd, LB_DELETESTRING, pos, 0);
     }
@@ -307,20 +307,20 @@ static void ULBSINIT(HWND hwnd)
     ulbs_hwnd = hwnd;
     ulbs_pos = 0;
 }
-static void ULBS(const char *format, ...)
+static void ULBS(const TCHAR *format, ...)
 {
-    char buffer[MAX_LINEWIDTH + 1];
+    TCHAR buffer[MAX_LINEWIDTH + 1];
     va_list parms;
     va_start(parms, format);
-    _vsnprintf(buffer, MAX_LINEWIDTH, format, parms);
+    _vsntprintf(buffer, MAX_LINEWIDTH, format, parms);
     UpdateListboxString(ulbs_hwnd, ulbs_pos++, buffer, FALSE);
 }
-static void ULBST(const char *format, ...)
+static void ULBST(const TCHAR *format, ...)
 {
-    char buffer[MAX_LINEWIDTH + 1];
+    TCHAR buffer[MAX_LINEWIDTH + 1];
     va_list parms;
     va_start(parms, format);
-    _vsnprintf(buffer, MAX_LINEWIDTH, format, parms);
+    _vsntprintf(buffer, MAX_LINEWIDTH, format, parms);
     UpdateListboxString(ulbs_hwnd, ulbs_pos++, buffer, TRUE);
 }
 
@@ -342,12 +342,12 @@ static int GetLBOutputLines(HWND hWnd)
 static void ShowMiscCPU(HWND hwnd)
 {
     int line = 0;
-    char out[MAX_LINEWIDTH + 1];
+    TCHAR out[MAX_LINEWIDTH + 1];
     int i;
 
     for (i = 0; m2cregs[i].regno>= 0; i++) {
        if (!movec_illg(m2cregs[i].regno)) {
-           sprintf(out, "%-4s %08X", m2cregs[i].regname, val_move2c(m2cregs[i].regno));
+           _stprintf(out, L"%-4s %08X", m2cregs[i].regname, val_move2c(m2cregs[i].regno));
            UpdateListboxString(hwnd, line++, out, TRUE);
        }
     }
@@ -365,7 +365,7 @@ static void ShowCustomSmall(HWND hwnd)
 {
     int len, i, j, cnt;
     uae_u8 *p1, *p2, *p3, *p4;
-    char out[MAX_LINEWIDTH + 1];
+    TCHAR out[MAX_LINEWIDTH + 1];
 
     p1 = p2 = save_custom (&len, 0, 1);
     p1 += 4; // skip chipset type
@@ -388,20 +388,20 @@ static void ShowCustomSmall(HWND hwnd)
     }
     ULBSINIT(hwnd);
     cnt = 0;
-    sprintf(out, "CPU %d", currprefs.cpu_model);
+    _stprintf(out, L"CPU %d", currprefs.cpu_model);
     if (currprefs.fpu_model)
-       sprintf (out + strlen(out), "/%d", currprefs.fpu_model);
-    sprintf(out + strlen(out), " %s", (currprefs.chipset_mask & CSMASK_AGA) ? "AGA" : ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? "ECS" : "OCS"));
+       _stprintf (out + _tcslen(out), L"/%d", currprefs.fpu_model);
+    _stprintf(out + _tcslen(out), L" %s", (currprefs.chipset_mask & CSMASK_AGA) ? L"AGA" : ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? L"ECS" : L"OCS"));
     ULBST(out);
-    ULBST("VPOS     %04X (%d)", vpos, vpos);
-    ULBST("HPOS     %04X (%d)", current_hpos(), current_hpos());
+    ULBST(L"VPOS     %04X (%d)", vpos, vpos);
+    ULBST(L"HPOS     %04X (%d)", current_hpos(), current_hpos());
     for (i = 0; dcustom[i]; i++) {
        for (j = 0; custd[j].name; j++) {
            if (custd[j].adr == (dcustom[i] & 0x1fe) + 0xdff000) {
                if (dcustom[i] & 0x8000)
-                   ULBST("%-8s %08X", custd[j].name, (gw(p1, dcustom[i] & 0x1fe) << 16) | gw(p1, (dcustom[i] & 0x1fe) + 2));
+                   ULBST(L"%-8s %08X", custd[j].name, (gw(p1, dcustom[i] & 0x1fe) << 16) | gw(p1, (dcustom[i] & 0x1fe) + 2));
                else
-                   ULBST("%-8s %04X", custd[j].name, gw(p1, dcustom[i] & 0x1fe));
+                   ULBST(L"%-8s %04X", custd[j].name, gw(p1, dcustom[i] & 0x1fe));
                break;
            }
        }
@@ -420,17 +420,17 @@ static void ShowMisc(void)
     ULBSINIT(hMisc);
     for (i = 0; i < 2; i++) {
        p = p2 = save_cia (i, &len, NULL);
-       ULBS("");
-       ULBS("CIA %c:", i == 1 ? 'B' : 'A');
-       ULBS("");
-       ULBS("PRA %02X   PRB %02X", p[0], p[1]);
-       ULBS("DRA %02X   DRB %02X", p[2], p[3]);
-       ULBS("CRA %02X   CRB %02X   ICR %02X   IM %02X",
+       ULBS(L"");
+       ULBS(L"CIA %c:", i == 1 ? 'B' : 'A');
+       ULBS(L"");
+       ULBS(L"PRA %02X   PRB %02X", p[0], p[1]);
+       ULBS(L"DRA %02X   DRB %02X", p[2], p[3]);
+       ULBS(L"CRA %02X   CRB %02X   ICR %02X   IM %02X",
            p[14], p[15], p[13], p[16]);
-       ULBS("TA  %04X (%04X)   TB %04X (%04X)",
+       ULBS(L"TA  %04X (%04X)   TB %04X (%04X)",
            (p[5] << 8) | p[4], (p[18] << 8) | p[17],
            (p[7] << 8) | p[6], (p[20] << 8) | p[19]);
-       ULBS("TOD %06X (%06X) ALARM %06X %c%c",
+       ULBS(L"TOD %06X (%06X) ALARM %06X %c%c",
            (p[10] << 16) | (p[ 9] << 8) | p[ 8],
            (p[23] << 16) | (p[22] << 8) | p[21],
            (p[26] << 16) | (p[25] << 8) | p[24],
@@ -439,23 +439,23 @@ static void ShowMisc(void)
     }
     for (i = 0; i < 4; i++) {
        p = p2 = save_disk (i, &len, NULL);
-       ULBS("");
-       ULBS("Drive DF%d: (%s)", i, (p[4] & 2) ? "disabled" : "enabled");
-       ULBS("ID %08X  Motor %s  Cylinder %2d  MFMPOS %d",
+       ULBS(L"");
+       ULBS(L"Drive DF%d: (%s)", i, (p[4] & 2) ? "disabled" : "enabled");
+       ULBS(L"ID %08X  Motor %s  Cylinder %2d  MFMPOS %d",
            (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3],
-           (p[4] & 1) ? "On" : "Off",
+           (p[4] & 1) ? L"On" : L"Off",
            p[5], (p[8] << 24) | (p[9] << 16) | (p[10] << 8) | p[11]);
        if (p[16])
-           ULBS("'%s'", p + 16);
+           ULBS(L"'%s'", p + 16);
        else
-           ULBS("Drive is empty");
+           ULBS(L"Drive is empty");
        free(p2);
     }
     p = p2 = save_floppy (&len, NULL);
-    ULBS("");
-    ULBS("Disk controller:");
-    ULBS("");
-    ULBS("Shift register: Data=%04X Shift=%d. DMA=%d,%d", (p[0] << 8) | p[1], p[2], p[3], p[5]);
+    ULBS(L"");
+    ULBS(L"Disk controller:");
+    ULBS(L"");
+    ULBS(L"Shift register: Data=%04X Shift=%d. DMA=%d,%d", (p[0] << 8) | p[1], p[2], p[3], p[5]);
     free (p2);
 }
 
@@ -497,7 +497,7 @@ static void ShowCustom(void)
        addr2 = custd[j].adr & 0x1ff;
        v1 = (p1[addr1 + 0] << 8) | p1[addr1 + 1];
        v2 = (p1[addr2 + 0] << 8) | p1[addr2 + 1];
-       ULBS("%03.3X %-15s %04X    %03X %-15s %04X",
+       ULBS(L"%03.3X %-15s %04X    %03X %-15s %04X",
            addr1, custd[i].name, v1,
            addr2, custd[j].name, v2);
     }
@@ -508,14 +508,14 @@ static void ShowBreakpoints(void)
 {
     HWND hBrkpts;
     int i, lines_old, got;
-    char outbp[MAX_LINEWIDTH + 1], outw[50];
+    TCHAR outbp[MAX_LINEWIDTH + 1], outw[50];
 
     hBrkpts = GetDlgItem(hDbgWnd, IDC_DBG_BRKPTS);
     ULBSINIT(hBrkpts);
     lines_old = SendMessage(hBrkpts, LB_GETCOUNT, 0, 0);
-    ULBS("");
-    ULBS("Breakpoints:");
-    ULBS("");
+    ULBS(L"");
+    ULBS(L"Breakpoints:");
+    ULBS(L"");
     got = 0;
     for (i = 0; i < BREAKPOINT_TOTAL; i++) {
        if (!bpnodes[i].enabled)
@@ -525,10 +525,10 @@ static void ShowBreakpoints(void)
        got = 1;
     }
     if (!got)
-       ULBS("none");
-    ULBS("");
-    ULBS("Memwatch breakpoints:");
-    ULBS("");
+       ULBS(L"none");
+    ULBS(L"");
+    ULBS(L"Memwatch breakpoints:");
+    ULBS(L"");
     got = 0;
     for (i = 0; i < MEMWATCH_TOTAL; i++) {
        if (mwnodes[i].size == 0)
@@ -538,7 +538,7 @@ static void ShowBreakpoints(void)
        got = 1;
     }
     if (!got)
-       ULBS("none");
+       ULBS(L"none");
     for (i = ulbs_pos; i < lines_old; i++)
        SendMessage(hBrkpts, LB_DELETESTRING, ulbs_pos, 0);
 }
@@ -547,7 +547,7 @@ static void ShowMem(int offset)
 {
     uae_u32 addr;
     int i, lines_old, lines_new;
-    char out[MAX_LINEWIDTH + 1];
+    TCHAR out[MAX_LINEWIDTH + 1];
     HWND hMemory;
 
     dbgpage[currpage].memaddr += offset;
@@ -590,7 +590,7 @@ static void ShowDasm(int direction)
 {
     uae_u32 addr = 0, prev;
     int i, lines_old, lines_new;
-    char out[MAX_LINEWIDTH + 1];
+    TCHAR out[MAX_LINEWIDTH + 1];
     HWND hDasm;
 
        if (currpage == 0)
@@ -626,7 +626,7 @@ static void ShowDasm(int direction)
        if (addr > dbgpage[currpage].dasmaddr)
            UpdateListboxString(hDasm, i, out, FALSE);
        else
-           UpdateListboxString(hDasm, i, "", FALSE);
+           UpdateListboxString(hDasm, i, L"", FALSE);
     }
     for (i = lines_new; i < lines_old; i++) {
        SendMessage(hDasm, LB_DELETESTRING, lines_new, 0);
@@ -639,7 +639,7 @@ static void SetMemToPC(void)
     int i, id;
 
     dbgpage[currpage].dasmaddr = m68k_getpc (&regs);
-    sprintf(dbgpage[currpage].addrinput, "%08lX", dbgpage[currpage].dasmaddr);
+    _stprintf(dbgpage[currpage].addrinput, L"%08lX", dbgpage[currpage].dasmaddr);
     for (i = 0; i < MAXPAGECONTROLS; i++) {
        id = GetDlgCtrlID(dbgpage[currpage].ctrl[i]);
        if (id == IDC_DBG_MEMINPUT)
@@ -722,7 +722,7 @@ static void AddPage(int *iddata)
     pages++;
 }
 
-static int GetTextSize(HWND hWnd, char *text, int width)
+static int GetTextSize(HWND hWnd, TCHAR *text, int width)
 {
     HDC hdc;
     TEXTMETRIC tm;
@@ -736,7 +736,7 @@ static int GetTextSize(HWND hWnd, char *text, int width)
     if (!width)
        return tm.tmHeight + tm.tmExternalLeading;
     else if (text)
-       return tm.tmMaxCharWidth * strlen(text);
+       return tm.tmMaxCharWidth * _tcslen(text);
     return 0;
 }
 
@@ -761,7 +761,7 @@ static void InitPages(void)
     for (i = 0; i < (sizeof(dpage) / sizeof(dpage[0])); i++)
        AddPage(dpage[i]);
     memset(parts, 0, MAXPAGES * sizeof(int));
-    width = GetTextSize(hDbgWnd, "12345678", TRUE); // longest pagename + 2
+    width = GetTextSize(hDbgWnd, L"12345678", TRUE); // longest pagename + 2
     for (i = 0; i < pages; i++) {
        pwidth += width;
        parts[i] = pwidth;
@@ -807,9 +807,9 @@ static LRESULT CALLBACK MemInputProc (HWND hWnd, UINT message, WPARAM wParam, LP
 {
     HANDLE hdata;
     LPTSTR lptstr;
-    char allowed[] = "1234567890abcdefABCDEF";
+    TCHAR allowed[] = L"1234567890abcdefABCDEF";
     int ok = 1;
-    char addrstr[11];
+    TCHAR addrstr[11];
     uae_u32 addr;
     WNDPROC oldproc;
 
@@ -822,7 +822,7 @@ static LRESULT CALLBACK MemInputProc (HWND hWnd, UINT message, WPARAM wParam, LP
                        case 0x16:              //ctrl+v
                                break;
                        default:
-                               if (!debugger_active || !strchr(allowed, wParam))
+                               if (!debugger_active || !_tcschr(allowed, wParam))
                                        return 0;
                                break;
                }
@@ -834,7 +834,7 @@ static LRESULT CALLBACK MemInputProc (HWND hWnd, UINT message, WPARAM wParam, LP
            if (hdata) {
                lptstr = GlobalLock(hdata);
                if (lptstr) {
-                   if (strspn(lptstr, allowed) != strlen(lptstr))
+                   if (_tcsspn(lptstr, allowed) != _tcslen(lptstr))
                        ok = 0;
                    GlobalUnlock(hdata);
                }
@@ -848,10 +848,10 @@ static LRESULT CALLBACK MemInputProc (HWND hWnd, UINT message, WPARAM wParam, LP
                        return 0;
             switch (wParam) {
                case VK_RETURN:
-                   sprintf(addrstr, "0x");
+                   _stprintf(addrstr, L"0x");
                    GetWindowText(hWnd, addrstr + 2, 9);
                        if (addrstr[2] != 0) {
-                               addr = strtoul(addrstr, NULL, 0);
+                               addr = _tcstoul(addrstr, NULL, 0);
                                if (pagetype == IDC_DBG_MEM || pagetype == IDC_DBG_MEM2) {
                                        dbgpage[currpage].memaddr = addr;
                                        ShowMem(0);
@@ -904,11 +904,11 @@ static INT_PTR CALLBACK AddrInputDialogProc(HWND hDlg, UINT msg, WPARAM wParam,
            switch (LOWORD(wParam)) {
                        case IDOK:
                        {
-                               char addrstr[11] = { '0', 'x', '\0' };
+                               TCHAR addrstr[11] = { '0', 'x', '\0' };
 
                                SendMessage(GetDlgItem(hDlg, IDC_DBG_MEMINPUT2), WM_GETTEXT, 9, (LPARAM)addrstr + 2);
                                if (addrstr[2] != 0) {
-                                       uae_u32 addr = strtoul(addrstr, NULL, 0);
+                                       uae_u32 addr = _tcstoul(addrstr, NULL, 0);
                                        if (dbgpage[currpage].selection == IDC_DBG_MEM || dbgpage[currpage].selection == IDC_DBG_MEM2) {
                                                dbgpage[currpage].memaddr = addr;
                                                ShowMem(0);
@@ -975,34 +975,34 @@ static void CopyListboxText(HWND hwnd, BOOL all)
 
 static void ToggleBreakpoint(HWND hwnd)
 {
-       char addrstr[MAX_LINEWIDTH + 1], *ptr;
+       TCHAR addrstr[MAX_LINEWIDTH + 1], *ptr;
        int index = dbgpage[currpage].selection;
        SendMessage(hwnd, LB_GETTEXT, index, (LPARAM)addrstr);
        addrstr[8] = '\0';
        ptr = addrstr;
-       console_out_f ("\nf %s\n", addrstr);
+       console_out_f (L"\nf %s\n", addrstr);
        instruction_breakpoint(&ptr);
        RedrawWindow(hwnd, 0, 0, RDW_INVALIDATE);
 }
 
 static void DeleteBreakpoints(HWND hwnd)
 {
-       char *cmd = "d";
-       console_out("\nfd\n");
+       TCHAR *cmd = L"d";
+       console_out(L"\nfd\n");
        instruction_breakpoint(&cmd);
        RedrawWindow(hwnd, 0, 0, RDW_INVALIDATE);
 }
 
-static void ignore_ws (char **c)
+static void ignore_ws (TCHAR **c)
 {
-    while (**c && isspace(**c))
+    while (**c && _istspace(**c))
        (*c)++;
 }
 
 static void ListboxEndEdit(HWND hwnd, BOOL acceptinput)
 {
        MSG msg;
-       char *p, *p2, txt[MAX_LINEWIDTH + 1], tmp[MAX_LINEWIDTH + 1], hexstr[11] = { '0', 'x', '\0' };
+       TCHAR *p, *p2, txt[MAX_LINEWIDTH + 1], tmp[MAX_LINEWIDTH + 1], hexstr[11] = { '0', 'x', '\0' };
 
        if (!hedit)
                return;
@@ -1011,7 +1011,7 @@ static void ListboxEndEdit(HWND hwnd, BOOL acceptinput)
        GetWindowText(hedit, txt, MAX_LINEWIDTH + 1);
        p = txt;
        ignore_ws(&p);
-       if ((GetWindowTextLength(hedit) == 0) || (strlen(p) == 0))
+       if ((GetWindowTextLength(hedit) == 0) || (_tcslen(p) == 0))
                acceptinput = FALSE;
        while (PeekMessage(&msg, hedit, 0, 0, PM_REMOVE))
                ;
@@ -1020,22 +1020,22 @@ static void ListboxEndEdit(HWND hwnd, BOOL acceptinput)
        if (acceptinput) {
                int index = dbgpage[currpage].selection, id = GetDlgCtrlID(hwnd);
                if (id == IDC_DBG_DREG) {
-                       strncpy(hexstr + 2, txt, 8);
+                       _tcsncmp(hexstr + 2, txt, 8);
                        hexstr[10] = '\0';
-                       m68k_dreg(&regs, index) = strtoul(hexstr, NULL, 0);
+                       m68k_dreg(&regs, index) = _tcstoul(hexstr, NULL, 0);
                }
                else if (id == IDC_DBG_AREG) {
-                       strncpy(hexstr + 2, txt, 8);
+                       _tcsncmp(hexstr + 2, txt, 8);
                        hexstr[10] = '\0';
-                       m68k_areg(&regs, index) = strtoul(hexstr, NULL, 0);
+                       m68k_areg(&regs, index) = _tcstoul(hexstr, NULL, 0);
                }
                else if (id == IDC_DBG_FPREG) {
-                       char *stopstr;
+                       TCHAR *stopstr;
                        double value;
                        errno = 0;
-                       value = strtod(txt, &stopstr);
-                       if (strlen(stopstr) == 0 && errno == 0)
-                               regs.fp[index] = strtod(txt, &stopstr);
+                       value = _tcstod(txt, &stopstr);
+                       if (_tcslen(stopstr) == 0 && errno == 0)
+                               regs.fp[index] = _tcstod(txt, &stopstr);
                }
                else {
                        int bytes, i, offset = -1;
@@ -1048,44 +1048,44 @@ static void ListboxEndEdit(HWND hwnd, BOOL acceptinput)
                                bytes = 16;
                        }
                        else if (id == IDC_DBG_MEM || id == IDC_DBG_MEM2) {
-                               strncpy(hexstr + 2, tmp, 8);
+                               _tcsncmp(hexstr + 2, tmp, 8);
                                hexstr[10] = '\0';
-                               addr = strtoul(hexstr, NULL, 0);
+                               addr = _tcstoul(hexstr, NULL, 0);
                                offset = 9;
                                bytes = 16;
                        }
                        else if (id == IDC_DBG_DASM || id == IDC_DBG_DASM2) {
-                               strncpy(hexstr + 2, tmp, 8);
+                               _tcsncmp(hexstr + 2, tmp, 8);
                                hexstr[10] = '\0';
-                               addr = strtoul(hexstr, NULL, 0);
+                               addr = _tcstoul(hexstr, NULL, 0);
                                bytes = 0;
                                p = tmp + 9;
-                               while (isxdigit(p[0]) && p[4] == ' ') {
+                               while (_istxdigit(p[0]) && p[4] == ' ') {
                                        bytes += 2;
                                        p += 5;
                                }
                        }
-                       if (offset >= 0 && !isxdigit(tmp[offset])) {
+                       if (offset >= 0 && !_istxdigit(tmp[offset])) {
                                int t = 0;
                                do {
                                        t += 5;
                                        addr += 2;
                                        bytes -= 2;
-                               } while (!isxdigit(tmp[offset + t]) && !isxdigit(tmp[offset + t + 1]) && isspace(tmp[offset + t + 4]));
+                               } while (!_istxdigit(tmp[offset + t]) && !_istxdigit(tmp[offset + t + 1]) && _istspace(tmp[offset + t + 4]));
                        }
                        p = txt;
                        for (i = 0; i < bytes; i++) {
                                ignore_ws(&p);
-                               if (!isxdigit(p[0]))
+                               if (!_istxdigit(p[0]))
                                        break;
                                p2 = p + 1;
                                ignore_ws(&p2);
-                               if (!isxdigit(p2[0]))
+                               if (!_istxdigit(p2[0]))
                                        break;
                                hexstr[2] = p[0];
                                hexstr[3] = p2[0];
                                hexstr[4] = '\0';
-                               value = (uae_u8)strtoul(hexstr, NULL, 0);
+                               value = (uae_u8)_tcstoul(hexstr, NULL, 0);
                                put_byte(addr, value);
                                p = p2 + 1;
                                addr++;
@@ -1101,15 +1101,15 @@ static LRESULT CALLBACK ListboxEditProc(HWND hWnd, UINT message, WPARAM wParam,
 {
     HANDLE hdata;
     LPTSTR lptstr;
-    char allowed[] = "1234567890abcdefABCDEF ";
+    TCHAR allowed[] = L"1234567890abcdefABCDEF ";
     int ok = 1, id;
     WNDPROC oldproc;
        HWND hparent = GetParent(hWnd);
        id = GetDlgCtrlID(hparent);
        if (id == IDC_DBG_DREG || id == IDC_DBG_AREG)
-               allowed[strlen(allowed) - 1] = '\0'; // no space
+               allowed[_tcslen(allowed) - 1] = '\0'; // no space
        else if (id == IDC_DBG_FPREG)
-               sprintf(allowed, "1234567890deDE.+-");
+               _stprintf(allowed, L"1234567890deDE.+-");
     switch (message) {
        case WM_GETDLGCODE:
                return DLGC_WANTALLKEYS;
@@ -1141,7 +1141,7 @@ static LRESULT CALLBACK ListboxEditProc(HWND hWnd, UINT message, WPARAM wParam,
                                ListboxEndEdit(hparent, FALSE);
                                return 0;
                        default:
-                               if (!strchr(allowed, wParam))
+                               if (!_tcschr(allowed, wParam))
                                        return 0;
                                break;
                }
@@ -1153,7 +1153,7 @@ static LRESULT CALLBACK ListboxEditProc(HWND hWnd, UINT message, WPARAM wParam,
            if (hdata) {
                lptstr = GlobalLock(hdata);
                if (lptstr) {
-                   if (strspn(lptstr, allowed) != strlen(lptstr))
+                   if (_tcsspn(lptstr, allowed) != _tcslen(lptstr))
                        ok = 0;
                    GlobalUnlock(hdata);
                }
@@ -1177,7 +1177,7 @@ static void ListboxEdit(HWND hwnd, int x, int y)
        RECT rc, ri;
        HFONT hfont;
        WNDPROC oldproc;
-       char txt[MAX_LINEWIDTH + 1], tmp[MAX_LINEWIDTH + 1];
+       TCHAR txt[MAX_LINEWIDTH + 1], tmp[MAX_LINEWIDTH + 1];
        if (!debugger_active || hedit)
                return;
        if (!hwnd)
@@ -1205,7 +1205,7 @@ static void ListboxEdit(HWND hwnd, int x, int y)
        }
        else
                return;
-       hedit = CreateWindow("Edit", "Listbox Edit", WS_BORDER | WS_CHILD, 0, 0, 1, 1, hwnd, NULL, hInst, NULL);
+       hedit = CreateWindow(L"Edit", L"Listbox Edit", WS_BORDER | WS_CHILD, 0, 0, 1, 1, hwnd, NULL, hInst, NULL);
        if (!hedit)
                return;
        size = GetTextSize(hwnd, NULL, 0);
@@ -1214,20 +1214,20 @@ static void ListboxEdit(HWND hwnd, int x, int y)
        SendMessage(hwnd, LB_GETITEMRECT, (WPARAM)index, (LPARAM)&ri);
        SendMessage(hwnd, LB_GETTEXT, (WPARAM)index, (LPARAM)(LPTSTR)txt);
        if (id == IDC_DBG_DASM || id == IDC_DBG_DASM2) {
-               while (isxdigit(txt[offset + length]) && isspace(txt[offset + length + 4]))
+               while (_istxdigit(txt[offset + length]) && _istspace(txt[offset + length + 4]))
                        length += 5;
                length--;
        }
        if (length > 0) {
                int t = 0;
-               if (!isxdigit(txt[offset])) {
-                       while (isxdigit(txt[offset + length - t - 1]) && isspace(txt[offset + length - t - 5]))
+               if (!_istxdigit(txt[offset])) {
+                       while (_istxdigit(txt[offset + length - t - 1]) && _istspace(txt[offset + length - t - 5]))
                                t += 5;
                        offset += length - t + 1;
                        length = t - 1;
                }
-               else if (!isxdigit(txt[offset + length - 1])) {
-                       while (isxdigit(txt[offset + t]) && isspace(txt[offset + t + 4]))
+               else if (!_istxdigit(txt[offset + length - 1])) {
+                       while (_istxdigit(txt[offset + t]) && _istspace(txt[offset + t + 4]))
                                t += 5;
                        length = t - 1;
                }
@@ -1235,15 +1235,15 @@ static void ListboxEdit(HWND hwnd, int x, int y)
                        ListboxEndEdit(hwnd, FALSE);
                        return;
                }
-               strncpy(tmp, txt + offset, length);
+               _tcsncmp(tmp, txt + offset, length);
                tmp[length] = '\0';
                radjust = GetTextSize(hwnd, tmp, TRUE);
        }
        else if (id == IDC_DBG_FPREG)
                length = 20;
        else
-               length = strlen(txt + offset);
-       strncpy(tmp, txt, offset);
+               length = _tcslen(txt + offset);
+       _tcsncmp(tmp, txt, offset);
        tmp[offset] = '\0';
        ri.left += GetTextSize(hwnd, tmp, TRUE);
        if (radjust)
@@ -1278,7 +1278,7 @@ static void ToggleCCRFlag(HWND hwnd, int x, int y)
 {
        int size = GetTextSize(hwnd, NULL, 0);
        int index = y / size;
-       char txt[MAX_LINEWIDTH + 1];
+       TCHAR txt[MAX_LINEWIDTH + 1];
 
        memset(txt, 0, MAX_LINEWIDTH + 1);
        SendMessage(hwnd, LB_GETTEXT, (WPARAM)index, (LPARAM)(LPTSTR)txt);
@@ -1600,7 +1600,7 @@ static BOOL CALLBACK InitChildWindows(HWND hWnd, LPARAM lParam)
 {
     int i, id, enable = TRUE, items = 0;
     WNDPROC newproc = NULL, oldproc;
-    char classname[CLASSNAMELENGTH];
+    TCHAR classname[CLASSNAMELENGTH];
     WINDOWINFO pwi;
     RECT *r;
 
@@ -1644,9 +1644,9 @@ static BOOL CALLBACK InitChildWindows(HWND hWnd, LPARAM lParam)
            break;
        default:
            if (GetClassName(hWnd, classname, CLASSNAMELENGTH)) {
-               if (!strcmp(classname, "ListBox"))
+               if (!_tcscmp(classname, L"ListBox"))
                    newproc = ListboxProc;
-               else if (!strcmp(classname, "Edit"))
+               else if (!_tcscmp(classname, L"Edit"))
                    newproc = EditProc;
            }
            break;
@@ -1662,9 +1662,9 @@ static BOOL CALLBACK InitChildWindows(HWND hWnd, LPARAM lParam)
 static void step(BOOL over)
 {
        if (over)
-               strcpy(internalcmd, "z");
+               _tcscpy(internalcmd, L"z");
        else
-               strcpy(internalcmd, "t");
+               _tcscpy(internalcmd, L"t");
        useinternalcmd = TRUE;
        inputfinished = 1;
 }
@@ -1727,13 +1727,13 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
            dbgwnd_miny = rw.bottom - rw.top;
            GetClientRect(hDlg, &dlgRect);
            newpos = 1;
-           if (!regqueryint (NULL, "DebuggerPosX", &x))
+           if (!regqueryint (NULL, L"DebuggerPosX", &x))
                newpos = 0;
-           if (!regqueryint (NULL, "DebuggerPosY", &y))
+           if (!regqueryint (NULL, L"DebuggerPosY", &y))
                newpos = 0;
-           if (!regqueryint (NULL, "DebuggerPosW", &w))
+           if (!regqueryint (NULL, L"DebuggerPosW", &w))
                newpos = 0;
-           if (!regqueryint (NULL, "DebuggerPosH", &h))
+           if (!regqueryint (NULL, L"DebuggerPosH", &h))
                newpos = 0;
            if (newpos) {
                RECT rc;
@@ -1778,11 +1778,11 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                r->bottom -= r->top;
                r->left += xoffset;
                r->top += yoffset;
-               regsetint (NULL, "DebuggerPosX", r->left);
-               regsetint (NULL, "DebuggerPosY", r->top);
-               regsetint (NULL, "DebuggerPosW", r->right);
-               regsetint (NULL, "DebuggerPosH", r->bottom);
-               regsetint (NULL, "DebuggerMaximized", (IsZoomed(hDlg) || (wp.flags & WPF_RESTORETOMAXIMIZED)) ? 1 : 0);
+               regsetint (NULL, L"DebuggerPosX", r->left);
+               regsetint (NULL, L"DebuggerPosY", r->top);
+               regsetint (NULL, L"DebuggerPosW", r->right);
+               regsetint (NULL, L"DebuggerPosH", r->bottom);
+               regsetint (NULL, L"DebuggerMaximized", (IsZoomed(hDlg) || (wp.flags & WPF_RESTORETOMAXIMIZED)) ? 1 : 0);
            }
            hDbgWnd = 0;
            PostQuitMessage(0);
@@ -1921,12 +1921,12 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
                HDC hdc = pdis->hDC;
                RECT rc = pdis->rcItem;
-               char text[MAX_LINEWIDTH + 1];
+               TCHAR text[MAX_LINEWIDTH + 1];
                uae_u32 addr;
            SetBkMode(hdc, TRANSPARENT);
            if (wParam == IDC_DBG_STATUS) {
                SetTextColor(hdc, GetSysColor(pstatuscolor[pdis->itemID]));
-               DrawText(hdc, pname[pdis->itemID], lstrlen(pname[pdis->itemID]), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
+               DrawText(hdc, pname[pdis->itemID], _tcslen(pname[pdis->itemID]), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
                return TRUE;
            }
            else {
@@ -1945,11 +1945,11 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                }
                SetTextColor(hdc, pdis->itemData);
                if (wParam == IDC_DBG_DASM || wParam == IDC_DBG_DASM2) {
-                       char addrstr[11] = { '0', 'x', '\0'}, *btemp;
+                       TCHAR addrstr[11] = { '0', 'x', '\0'}, *btemp;
                        int i, j, size = rc.bottom - rc.top;
-                       strncpy(addrstr + 2, text, 8);
+                       _tcsncmp(addrstr + 2, text, 8);
                        addrstr[10] = 0;
-                       addr = strtoul(addrstr, NULL, 0);
+                       addr = _tcstoul(addrstr, NULL, 0);
                        for (i = 0; i < BREAKPOINT_TOTAL; i++) {
                                if (addr == bpnodes[i].addr && bpnodes[i].enabled) {
                                        int offset = 0;
@@ -1964,18 +1964,18 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                        btemp = NULL;
                        addrstr[2] = '\0';
                        while (ucbranch[i])  {
-                               if (!strncmp(text + 34, ucbranch[i], strlen(ucbranch[i]))) {
-                                       btemp = strchr(text + 34, '=');
+                               if (!_tcsncmp(text + 34, ucbranch[i], _tcslen(ucbranch[i]))) {
+                                       btemp = _tcschr(text + 34, '=');
                                        if (btemp)
-                                               strncpy(addrstr + 2, btemp + 4, 8);
+                                               _tcsncmp(addrstr + 2, btemp + 4, 8);
                                        else {
-                                               int pos = 34 + strlen(ucbranch[i]) + 3;
+                                               int pos = 34 + _tcslen(ucbranch[i]) + 3;
                                                if (text[pos] == '$')   //absolute addressing
-                                                       strncpy(addrstr + 2, text + pos + 1, 8);
-                                               else if (text[pos] == '(' && isdigit(text[pos + 2])) { //address register indirect
-                                                       int reg = atoi(text + pos + 2);
+                                                       _tcsncmp(addrstr + 2, text + pos + 1, 8);
+                                               else if (text[pos] == '(' && _istdigit(text[pos + 2])) { //address register indirect
+                                                       int reg = _tstoi(text + pos + 2);
                                                        uae_u32 loc = m68k_areg (&regs, reg);
-                                                       sprintf(addrstr + 2, "%08lx", loc);
+                                                       _stprintf(addrstr + 2, L"%08lx", loc);
                                                }
                                        }
                                        break;
@@ -1984,13 +1984,13 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                        }
                        i = 0;
                        while (addrstr[2] == '\0' && cbranch[i]) {
-                               if (!strncmp(text + 34, cbranch[i], strlen(cbranch[i]))) {
+                               if (!_tcsncmp(text + 34, cbranch[i], _tcslen(cbranch[i]))) {
                                        j = 0;
                                        while (ccode[j]) {
-                                               if (!strncmp(text + 34 + strlen(cbranch[i]), ccode[j], strlen(ccode[j]))) {
-                                                       btemp = strchr(text + 34, '=');
+                                               if (!_tcsncmp(text + 34 + _tcslen(cbranch[i]), ccode[j], _tcslen(ccode[j]))) {
+                                                       btemp = _tcschr(text + 34, '=');
                                                        if (btemp)
-                                                               strncpy(addrstr + 2, btemp + 4, 8);
+                                                               _tcsncmp(addrstr + 2, btemp + 4, 8);
                                                        break;
                                                }
                                                j++;
@@ -1999,17 +1999,17 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                                i++;
                        }
                        if (addrstr[2] != '\0') {
-                               uae_u32 branchaddr = strtoul(addrstr, NULL, 0);
+                               uae_u32 branchaddr = _tcstoul(addrstr, NULL, 0);
                                if (branchaddr < addr)
-                                       TextOut(hdc, rc.left, rc.top, "^", 1);
+                                       TextOut(hdc, rc.left, rc.top, L"^", 1);
                                else if (branchaddr > addr) {
                                        HFONT hfontold = (HFONT)SelectObject(hdc, udfont);
-                                       int width = GetTextSize(hDlg, "^", TRUE);
-                                       TextOut(hdc, rc.left + width, rc.bottom, "^", 1);
+                                       int width = GetTextSize(hDlg, L"^", TRUE);
+                                       TextOut(hdc, rc.left + width, rc.bottom, L"^", 1);
                                        SelectObject(hdc, hfontold);
                                }
                                else
-                                       TextOut(hdc, rc.left, rc.top, "=", 1);
+                                       TextOut(hdc, rc.left, rc.top, L"=", 1);
                        }
                        rc.left += size;
                        if (addr == m68k_getpc(&regs)) {
@@ -2017,10 +2017,10 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                                SetBkColor(hdc, GetSysColor(COLOR_HIGHLIGHT));
                                SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT));
                        }
-                       TextOut(hdc, rc.left, rc.top, text, strlen(text));
+                       TextOut(hdc, rc.left, rc.top, text, _tcslen(text));
                        i = 0;
                        while (markinstr[i])  {
-                               if (!strncmp(text + 34, markinstr[i], strlen(markinstr[i]))) {
+                               if (!_tcsncmp(text + 34, markinstr[i], _tcslen(markinstr[i]))) {
                                        MoveToEx(hdc, rc.left, rc.bottom - 1, NULL);
                                        LineTo(hdc, rc.right, rc.bottom - 1);
                                        break;
@@ -2031,12 +2031,12 @@ static LRESULT CALLBACK DebuggerProc (HWND hDlg, UINT message, WPARAM wParam, LP
                                DrawFocusRect(hdc, &rc);
                }
                else if (wParam == IDC_DBG_MEM || wParam == IDC_DBG_MEM2) {
-                       TextOut(hdc, rc.left, rc.top, text, strlen(text));
+                       TextOut(hdc, rc.left, rc.top, text, _tcslen(text));
                        if ((pdis->itemState) & (ODS_SELECTED))
                                DrawFocusRect(hdc, &rc);
                }
                else
-                       TextOut(hdc, rc.left, rc.top, text, strlen(text));
+                       TextOut(hdc, rc.left, rc.top, text, _tcslen(text));
                return TRUE;
            }
            break;
@@ -2066,7 +2066,7 @@ int open_debug_window(void)
        return 0;
     InitPages();
     ShowPage(0, TRUE);
-       if (!regqueryint (NULL, "DebuggerMaximized", &maximized))
+       if (!regqueryint (NULL, L"DebuggerMaximized", &maximized))
                maximized = 0;
        ShowWindow(hDbgWnd, maximized ? SW_SHOWMAXIMIZED : SW_SHOW);
     UpdateWindow(hDbgWnd);
@@ -2079,7 +2079,7 @@ void close_debug_window(void)
     DestroyWindow(hDbgWnd);
  }
 
-int console_get_gui (char *out, int maxlen)
+int console_get_gui (TCHAR *out, int maxlen)
 {
     MSG msg;
     int ret;
@@ -2099,11 +2099,11 @@ int console_get_gui (char *out, int maxlen)
                inputfinished = 0;
                if (useinternalcmd) {
                        useinternalcmd = FALSE;
-                       console_out("\n");
+                       console_out(L"\n");
                        console_out(internalcmd);
-                       console_out("\n");
-                       strncpy(out, internalcmd, maxlen);
-                       return strlen(out);
+                       console_out(L"\n");
+                       _tcsncmp(out, internalcmd, maxlen);
+                       return _tcslen(out);
                }
                else
                        return GetInput(out, maxlen);
@@ -2115,25 +2115,25 @@ int console_get_gui (char *out, int maxlen)
 void update_debug_info(void)
 {
     int i;
-    char out[MAX_LINEWIDTH + 1];
+    TCHAR out[MAX_LINEWIDTH + 1];
     HWND hwnd;
     struct instr *dp;
     struct mnemolookup *lookup1, *lookup2;
     uae_u32 fpsr;
-    char *fpsrflag[] = { "N:   ", "Z:   ", "I:   ", "NAN: " };
+    TCHAR *fpsrflag[] = { L"N:   ", L"Z:   ", L"I:   ", L"NAN: " };
 
     if (!hDbgWnd)
        return;
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_DREG);
     for (i = 0; i < 8; i++) {
-       sprintf(out, "D%d: %08lX", i, m68k_dreg (&regs, i));
+       _stprintf(out, L"D%d: %08lX", i, m68k_dreg (&regs, i));
        UpdateListboxString(hwnd, i, out, TRUE);
     }
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_AREG);
     for (i = 0; i < 8; i++) {
        hwnd = GetDlgItem(hDbgWnd, IDC_DBG_AREG);
-       sprintf(out, "A%d: %08lX", i, m68k_areg (&regs, i));
+       _stprintf(out, L"A%d: %08lX", i, m68k_areg (&regs, i));
        UpdateListboxString(hwnd, i, out, TRUE);
        hwnd = GetDlgItem(hDbgWnd, IDC_DBG_AMEM);
        dumpmem2(m68k_areg (&regs, i), out, sizeof(out));
@@ -2141,34 +2141,34 @@ void update_debug_info(void)
     }
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_CCR);
-    UpdateListboxString(hwnd, 0, GET_XFLG(&regs.ccrflags) ? "X: 1" : "X: 0", TRUE);
-    UpdateListboxString(hwnd, 1, GET_NFLG(&regs.ccrflags) ? "N: 1" : "N: 0", TRUE);
-    UpdateListboxString(hwnd, 2, GET_ZFLG(&regs.ccrflags) ? "Z: 1" : "Z: 0", TRUE);
-    UpdateListboxString(hwnd, 3, GET_VFLG(&regs.ccrflags) ? "V: 1" : "V: 0", TRUE);
-    UpdateListboxString(hwnd, 4, GET_CFLG(&regs.ccrflags) ? "C: 1" : "C: 0", TRUE);
+    UpdateListboxString(hwnd, 0, GET_XFLG(&regs.ccrflags) ? L"X: 1" : L"X: 0", TRUE);
+    UpdateListboxString(hwnd, 1, GET_NFLG(&regs.ccrflags) ? L"N: 1" : L"N: 0", TRUE);
+    UpdateListboxString(hwnd, 2, GET_ZFLG(&regs.ccrflags) ? L"Z: 1" : L"Z: 0", TRUE);
+    UpdateListboxString(hwnd, 3, GET_VFLG(&regs.ccrflags) ? L"V: 1" : L"V: 0", TRUE);
+    UpdateListboxString(hwnd, 4, GET_CFLG(&regs.ccrflags) ? L"C: 1" : L"C: 0", TRUE);
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_SP_VBR);
-    sprintf(out, "USP: %08lX", regs.usp);
+    _stprintf(out, L"USP: %08lX", regs.usp);
     UpdateListboxString(hwnd, 0, out, TRUE);
-    sprintf(out, "ISP: %08lX", regs.isp);
+    _stprintf(out, L"ISP: %08lX", regs.isp);
     UpdateListboxString(hwnd, 1, out, TRUE);
 
     ShowMiscCPU(GetDlgItem(hDbgWnd, IDC_DBG_MISCCPU));
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_MMISC);
-    sprintf(out, "T:     %d%d", regs.t1, regs.t0);
+    _stprintf(out, L"T:     %d%d", regs.t1, regs.t0);
     UpdateListboxString(hwnd, 0, out, TRUE);
-    sprintf(out, "S:     %d", regs.s);
+    _stprintf(out, L"S:     %d", regs.s);
     UpdateListboxString(hwnd, 1, out, TRUE);
-    sprintf(out, "M:     %d", regs.m);
+    _stprintf(out, L"M:     %d", regs.m);
     UpdateListboxString(hwnd, 2, out, TRUE);
-    sprintf(out, "IMASK: %d", regs.intmask);
+    _stprintf(out, L"IMASK: %d", regs.intmask);
     UpdateListboxString(hwnd, 3, out, TRUE);
-    sprintf(out, "STP:   %d", regs.stopped);
+    _stprintf(out, L"STP:   %d", regs.stopped);
     UpdateListboxString(hwnd, 4, out, TRUE);
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_PC);
-    sprintf(out, "PC: %08lX", m68k_getpc (&regs));
+    _stprintf(out, L"PC: %08lX", m68k_getpc (&regs));
     UpdateListboxString(hwnd, 0, out, TRUE);
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_PREFETCH);
@@ -2176,21 +2176,21 @@ void update_debug_info(void)
     for (lookup1 = lookuptab; lookup1->mnemo != dp->mnemo; lookup1++);
     dp = table68k + regs.ir;
     for (lookup2 = lookuptab; lookup2->mnemo != dp->mnemo; lookup2++);
-    sprintf(out, "Prefetch: %04X (%s) %04X (%s)", regs.irc, lookup1->name, regs.ir, lookup2->name);
+    _stprintf(out, L"Prefetch: %04X (%s) %04X (%s)", regs.irc, lookup1->name, regs.ir, lookup2->name);
     UpdateListboxString(hwnd, 0, out, TRUE);
 
     ShowCustomSmall(GetDlgItem(hDbgWnd, IDC_DBG_MCUSTOM));
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_FPREG);
     for (i = 0; i < 8; i++) {
-       sprintf(out, "FP%d: %g", i, regs.fp[i]);
+       _stprintf(out, L"FP%d: %g", i, regs.fp[i]);
        UpdateListboxString(hwnd, i, out, TRUE);
     }
 
     hwnd = GetDlgItem(hDbgWnd, IDC_DBG_FPSR);
     fpsr = get_fpsr();
     for (i = 0; i < 4; i++) {
-       sprintf(out, "%s%d", fpsrflag[i], (fpsr & (0x8000000 >> i)) != 0 ? 1 : 0);
+       _stprintf(out, L"%s%d", fpsrflag[i], (fpsr & (0x8000000 >> i)) != 0 ? 1 : 0);
        UpdateListboxString(hwnd, i, out, TRUE);
     }
     ShowPage(currpage, TRUE);
index 5c747a359a013fc0a98a6a394545764af255d15d..516d2f5928c19d324e2030f9d1a4e31c70eb19f4 100644 (file)
@@ -3,8 +3,8 @@
 
 extern int open_debug_window(void);
 extern void close_debug_window(void);
-extern void WriteOutput(const char *out, int len);
-extern int GetInput (char *out, int maxlen);
-extern int console_get_gui (char *out, int maxlen);
+extern void WriteOutput(const TCHAR *out, int len);
+extern int GetInput (TCHAR *out, int maxlen);
+extern int console_get_gui (TCHAR *out, int maxlen);
 
 #endif
index f7fbe0e96ec61ce35e4de4a487f049a3f5319d0c..754979e57fe2b5cfce2030c490266c7044f5b329 100644 (file)
@@ -65,9 +65,9 @@ struct didata {
     int superdevice;
     GUID iguid;
     GUID pguid;
-    char *name;
-    char *sortname;
-    char *configname;
+    TCHAR *name;
+    TCHAR *sortname;
+    TCHAR *configname;
 
     int connection;
     LPDIRECTINPUTDEVICE8 lpdi;
@@ -79,11 +79,11 @@ struct didata {
     int axles;
     int buttons, buttons_real;
     int axismappings[MAX_MAPPINGS];
-    char *axisname[MAX_MAPPINGS];
+    TCHAR *axisname[MAX_MAPPINGS];
     int axissort[MAX_MAPPINGS];
     int axistype[MAX_MAPPINGS];
     int buttonmappings[MAX_MAPPINGS];
-    char *buttonname[MAX_MAPPINGS];
+    TCHAR *buttonname[MAX_MAPPINGS];
     int buttonsort[MAX_MAPPINGS];
 
     int axisparent[MAX_MAPPINGS];
@@ -138,22 +138,22 @@ static void fixbuttons (struct didata *did)
 {
     if (did->buttons > 0)
        return;
-    write_log ("'%s' has no buttons, adding single default button\n", did->name);
-    did->buttonmappings[0] = DIJOFS_BUTTON(0);
+    write_log (L"'%s' has no buttons, adding single default button\n", did->name);
+    did->buttonmappings[0] = DIJOFS_BUTTON (0);
     did->buttonsort[0] = 0;
-    did->buttonname[0] = my_strdup("Button");
+    did->buttonname[0] = my_strdup (L"Button");
     did->buttons++;
 }
 
 static void addplusminus (struct didata *did, int i)
 {
-    char tmp[256];
+    TCHAR tmp[256];
     int j;
 
     if (did->buttons + 1 >= MAX_MAPPINGS)
        return;
     for (j = 0; j < 2; j++) {
-        sprintf (tmp, "%s [%c]", did->axisname[i], j ? '+' : '-');
+        _stprintf (tmp, L"%s [%c]", did->axisname[i], j ? '+' : '-');
         did->buttonname[did->buttons] = my_strdup (tmp);
         did->buttonmappings[did->buttons] = did->axismappings[i];
         did->buttonsort[did->buttons] = 1000 + (did->axismappings[i] + did->axistype[i]) * 2 + j;
@@ -238,7 +238,7 @@ static int register_rawinput (void)
     if (num == 0)
        return 1;
     if (pRegisterRawInputDevices (rid, num, sizeof (RAWINPUTDEVICE)) == FALSE) {
-       write_log ("RAWINPUT registration failed %d (%d,%d->%d,%d->%d)\n",
+       write_log (L"RAWINPUT registration failed %d (%d,%d->%d,%d->%d)\n",
            GetLastError (), num,
            rawinput_registered_mouse, rm,
            rawinput_registered_kb, rkb);
@@ -367,7 +367,7 @@ static int axmax, aymax, azmax;
 static int xmax, ymax, zmax;
 static int xres, yres;
 static int maxpres;
-static char *tabletname;
+static TCHAR *tabletname;
 static int tablet_x, tablet_y, tablet_z, tablet_pressure, tablet_buttons, tablet_proximity;
 static int tablet_ax, tablet_ay, tablet_az, tablet_flags;
 
@@ -401,7 +401,7 @@ void send_tablet_proximity (int inproxi)
 
 void send_tablet (int x, int y, int z, int pres, uae_u32 buttons, int flags, int ax, int ay, int az, int rx, int ry, int rz, RECT *r)
 {
-    //write_log ("%d %d %d (%d,%d,%d), %08X %d\n", x, y, pres, ax, ay, az, buttons, proxi);
+    //write_log (L"%d %d %d (%d,%d,%d), %08X %d\n", x, y, pres, ax, ay, az, buttons, proxi);
     if (axmax > 0)
        ax = ax * 255 / axmax;
     else
@@ -471,12 +471,12 @@ void *open_tablet (HWND hwnd)
     lc.lcInExtY = ty.axMax;
     if (zmax > 0)
        lc.lcInExtZ = tz.axMax;
-    write_log ("Tablet '%s' parameters\n", tabletname);
-    write_log ("Xmax=%d,Ymax=%d,Zmax=%d\n", xmax, ymax, zmax);
-    write_log ("Xres=%.1f:%d,Yres=%.1f:%d,Zres=%.1f:%d\n",
+    write_log (L"Tablet '%s' parameters\n", tabletname);
+    write_log (L"Xmax=%d,Ymax=%d,Zmax=%d\n", xmax, ymax, zmax);
+    write_log (L"Xres=%.1f:%d,Yres=%.1f:%d,Zres=%.1f:%d\n",
        tx.axResolution / 65536.0, tx.axUnits, ty.axResolution / 65536.0, ty.axUnits, tz.axResolution / 65536.0, tz.axUnits);
-    write_log ("Xrotmax=%d,Yrotmax=%d,Zrotmax=%d\n", axmax, aymax, azmax);
-    write_log ("PressureMin=%d,PressureMax=%d\n", pres.axMin, pres.axMax);
+    write_log (L"Xrotmax=%d,Yrotmax=%d,Zrotmax=%d\n", axmax, aymax, azmax);
+    write_log (L"PressureMin=%d,PressureMax=%d\n", pres.axMin, pres.axMax);
     maxpres = pres.axMax;
     xres = gettabletres (&tx);
     yres = gettabletres (&ty);
@@ -504,18 +504,18 @@ int is_tablet (void)
 static int initialize_tablet (void)
 {
     HANDLE h;
-    char name[MAX_DPATH];
+    TCHAR name[MAX_DPATH];
     struct tagAXIS ori[3];
     int tilt = 0;
 
-    h = LoadLibrary ("wintab32.dll");
+    h = LoadLibrary (L"wintab32.dll");
     if (h == NULL) {
-       write_log ("Tablet: no wintab32.dll\n");
+       write_log (L"Tablet: no wintab32.dll\n");
        return 0;
     }
     FreeLibrary (h);
     if (!WTInfo (0, 0, NULL)) {
-       write_log ("Tablet: WTInfo() returned failure\n");
+       write_log (L"Tablet: WTInfo() returned failure\n");
        return 0;
     }
     WTInfo (WTI_DEVICES, DVC_NAME, name);
@@ -529,7 +529,7 @@ static int initialize_tablet (void)
        if (ori[2].axMax > 0)
            azmax = ori[2].axMax;
     }
-    write_log ("Tablet '%s' detected\n", name);
+    write_log (L"Tablet '%s' detected\n", name);
     tabletname = my_strdup (name);
     tablet = TRUE;
     return 1;
@@ -538,7 +538,7 @@ static int initialize_tablet (void)
 static int initialize_catweasel (void)
 {
     int j, i;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     struct didata *did;
 
     if (catweasel_ismouse ()) {
@@ -548,20 +548,20 @@ static int initialize_catweasel (void)
            cleardid(did);
            did->connection = DIDC_CAT;
            did->catweasel = i;
-           sprintf (tmp, "Catweasel mouse");
+           _stprintf (tmp, L"Catweasel mouse");
            did->name = my_strdup (tmp);
            did->sortname = my_strdup (tmp);
-           sprintf (tmp, "CWMOUSE%d", i);
+           _stprintf (tmp, L"CWMOUSE%d", i);
            did->configname = my_strdup (tmp);
            did->buttons = did->buttons_real = 3;
            did->axles = 2;
            did->axissort[0] = 0;
-           did->axisname[0] = my_strdup ("X-Axis");
+           did->axisname[0] = my_strdup (L"X-Axis");
            did->axissort[1] = 1;
-           did->axisname[1] = my_strdup ("Y-Axis");
+           did->axisname[1] = my_strdup (L"Y-Axis");
            for (j = 0; j < did->buttons; j++) {
                did->buttonsort[j] = j;
-               sprintf (tmp, "Button %d", j + 1);
+               _stprintf (tmp, L"Button %d", j + 1);
                did->buttonname[j] = my_strdup (tmp);
            }
            did->priority = -1;
@@ -575,20 +575,20 @@ static int initialize_catweasel (void)
            cleardid(did);
            did->connection = DIDC_CAT;
            did->catweasel = i;
-           sprintf (tmp, "Catweasel joystick");
+           _stprintf (tmp, L"Catweasel joystick");
            did->name = my_strdup (tmp);
            did->sortname = my_strdup (tmp);
-           sprintf (tmp, "CWJOY%d", i);
+           _stprintf (tmp, L"CWJOY%d", i);
            did->configname = my_strdup (tmp);
            did->buttons = did->buttons_real =(catweasel_isjoystick() & 0x80) ? 3 : 1;
            did->axles = 2;
            did->axissort[0] = 0;
-           did->axisname[0] = my_strdup ("X-Axis");
+           did->axisname[0] = my_strdup (L"X-Axis");
            did->axissort[1] = 1;
-           did->axisname[1] = my_strdup ("Y-Axis");
+           did->axisname[1] = my_strdup (L"Y-Axis");
            for (j = 0; j < did->buttons; j++) {
                did->buttonsort[j] = j;
-               sprintf (tmp, "Button %d", j + 1);
+               _stprintf (tmp, L"Button %d", j + 1);
                did->buttonname[j] = my_strdup (tmp);
            }
            did->priority = -1;
@@ -601,44 +601,44 @@ static int initialize_catweasel (void)
 }
 
 
-#define RDP_DEVICE1 "\\??\\Root#RDP_"
-#define RDP_DEVICE2 "\\\\?\\Root#RDP_"
+#define RDP_DEVICE1 L"\\??\\Root#RDP_"
+#define RDP_DEVICE2 L"\\\\?\\Root#RDP_"
 
-static int rdpdevice(char *buf)
+static int rdpdevice(TCHAR *buf)
 {
-    if (!memcmp (RDP_DEVICE1, buf, strlen (RDP_DEVICE1)))
+    if (!_tcsncmp (RDP_DEVICE1, buf, _tcslen (RDP_DEVICE1)))
        return 1;
-    if (!memcmp (RDP_DEVICE2, buf, strlen (RDP_DEVICE2)))
+    if (!_tcsncmp (RDP_DEVICE2, buf, _tcslen (RDP_DEVICE2)))
        return 1;
     return 0;
 }
 
-static void rawinputfixname (const char *name, const char *friendlyname)
+static void rawinputfixname (const TCHAR *name, const TCHAR *friendlyname)
 {
     int i, ii, j;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
-    sprintf (tmp, "\\\\?\\%s", name);
-    for (i = 4; i < strlen (tmp); i++) {
+    _stprintf (tmp, L"\\\\?\\%s", name);
+    for (i = 4; i < _tcslen (tmp); i++) {
        if (tmp[i] == '\\')
            tmp[i] = '#';
-       tmp[i] = toupper (tmp[i]);
+       tmp[i] = _totupper (tmp[i]);
     }
     for (ii = 0; ii < 2; ii++) {
        for (i = 0; i < (ii == 0 ? num_mouse : num_keyboard); i++) {
            struct didata *did = ii == 0 ? &di_mouse[i] : &di_keyboard[i];
-           char tmp2[MAX_DPATH];
+           TCHAR tmp2[MAX_DPATH];
            if (!did->rawinput)
                continue;
-           for (j = 0; j < strlen (did->configname); j++)
-               tmp2[j] = toupper (did->configname[j]);
+           for (j = 0; j < _tcslen (did->configname); j++)
+               tmp2[j] = _totupper (did->configname[j]);
            tmp2[j] = 0;
-           if (strlen (tmp2) >= strlen (tmp) && !memcmp (tmp2, tmp, strlen (tmp))) {
+           if (_tcslen (tmp2) >= _tcslen (tmp) && !_tcsncmp (tmp2, tmp, _tcslen (tmp))) {
                xfree (did->name);
                xfree (did->sortname);
                did->name = my_strdup (friendlyname);
                did->sortname = my_strdup (friendlyname);
-               write_log ("'%s' ('%s')\n", did->name, did->configname);
+               write_log (L"'%s' ('%s')\n", did->name, did->configname);
            }
        }
     }
@@ -655,10 +655,10 @@ static void rawinputfriendlynames (void)
            SP_DEVINFO_DATA dd;
            dd.cbSize = sizeof dd;
            for (i = 0; SetupDiEnumDeviceInfo (di, i, &dd); i++) {
-               char buf[MAX_DPATH];
+               TCHAR buf[MAX_DPATH];
                DWORD size = 0;
                if (SetupDiGetDeviceInstanceId (di, &dd, buf, sizeof buf , &size)) {
-                   char fname[MAX_DPATH];
+                   TCHAR fname[MAX_DPATH];
                    DWORD dt;
                    fname[0] = 0;
                    size = 0;
@@ -677,43 +677,43 @@ static void rawinputfriendlynames (void)
     }
 }
 
-static char *rawkeyboardlabels[] =
+static TCHAR *rawkeyboardlabels[] =
 {
-    "ESCAPE",
-    "1","2","3","4","5","6","7","8","9","0",
-    "MINUS","EQUALS","BACK","TAB",
-    "Q","W","E","R","T","Y","U","I","O","P",
-    "LBRACKET","RBRACKET","RETURN","LCONTROL",
-    "A","S","D","F","G","H","J","K","L",
-    "SEMICOLON","APOSTROPHE","GRAVE","LSHIFT","BACKSLASH",
-    "Z","X","C","V","B","N","M",
-    "COMMA","PERIOD","SLASH","RSHIFT","MULTIPLY","LMENU","SPACE","CAPITAL",
-    "F1","F2","F3","F4","F5","F6","F7","F8","F9","F10",
-    "NULOCK","SCROLL","NUMPAD7","NUMPAD8","NUMPAD9","SUBTRACT",
-    "NUMPAD4","NUMPAD5","NUMPAD6","ADD","NUMPAD1","NUMPAD2","NUMPAD3","NUMPAD0",
-    "DECIMAL",NULL,NULL,"OEM_102","F11","F12",
+    L"ESCAPE",
+    L"1",L"2",L"3",L"4",L"5",L"6",L"7",L"8",L"9",L"0",
+    L"MINUS",L"EQUALS",L"BACK",L"TAB",
+    L"Q",L"W",L"E",L"R",L"T",L"Y",L"U",L"I",L"O",L"P",
+    L"LBRACKET",L"RBRACKET",L"RETURN",L"LCONTROL",
+    L"A",L"S",L"D",L"F",L"G",L"H",L"J",L"K",L"L",
+    L"SEMICOLON",L"APOSTROPHE",L"GRAVE",L"LSHIFT",L"BACKSLASH",
+    L"Z",L"X",L"C",L"V",L"B",L"N",L"M",
+    L"COMMA",L"PERIOD",L"SLASH",L"RSHIFT",L"MULTIPLY",L"LMENU",L"SPACE",L"CAPITAL",
+    L"F1",L"F2",L"F3",L"F4",L"F5",L"F6",L"F7",L"F8",L"F9",L"F10",
+    L"NULOCK",L"SCROLL",L"NUMPAD7",L"NUMPAD8",L"NUMPAD9",L"SUBTRACT",
+    L"NUMPAD4",L"NUMPAD5",L"NUMPAD6",L"ADD",L"NUMPAD1",L"NUMPAD2",L"NUMPAD3",L"NUMPAD0",
+    L"DECIMAL",NULL,NULL,L"OEM_102",L"F11",L"F12",
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
     NULL,NULL,
-    "NUMPADEQUALS",NULL,NULL,
-    "PREVTRACK",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-    "NEXTTRACK",NULL,NULL,"NUMPADENTER","RCONTROL",NULL,NULL,
-    "MUTE","CALCULATOR","PLAYPAUSE",NULL,"MEDIASTOP",
+    L"NUMPADEQUALS",NULL,NULL,
+    L"PREVTRACK",NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
+    L"NEXTTRACK",NULL,NULL,L"NUMPADENTER",L"RCONTROL",NULL,NULL,
+    L"MUTE",L"CALCULATOR",L"PLAYPAUSE",NULL,L"MEDIASTOP",
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-    "VOLUMEDOWN",NULL,"VOLUMEUP",NULL,"WEBHOME","NUMPADCOMMA",NULL,
-    "DIVIDE",NULL,"SYSRQ","RMENU",
+    L"VOLUMEDOWN",NULL,L"VOLUMEUP",NULL,L"WEBHOME",L"NUMPADCOMMA",NULL,
+    L"DIVIDE",NULL,L"SYSRQ",L"RMENU",
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-    "PAUSE",NULL,"HOME","UP","PRIOR",NULL,"LEFT",NULL,"RIGHT",NULL,"END",
-    "DOWN","NEXT","INSERT","DELETE",
+    L"PAUSE",NULL,L"HOME",L"UP",L"PRIOR",NULL,L"LEFT",NULL,L"RIGHT",NULL,L"END",
+    L"DOWN",L"NEXT",L"INSERT",L"DELETE",
     NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-    "LWIN","RWIN","APPS","POWER","SLEEP",
+    L"LWIN",L"RWIN",L"APPS",L"POWER",L"SLEEP",
     NULL,NULL,NULL,
-    "WAKE",NULL,"WEBSEARCH","WEBFAVORITES","WEBREFRESH","WEBSTOP",
-    "WEBFORWARD","WEBBACK","MYCOMPUTER","MAIL","MEDIASELECT",
-    ""
+    L"WAKE",NULL,L"WEBSEARCH",L"WEBFAVORITES",L"WEBREFRESH",L"WEBSTOP",
+    L"WEBFORWARD",L"WEBBACK",L"MYCOMPUTER",L"MAIL",L"MEDIASELECT",
+    L""
 };
 
 static int initialize_rawinput (void)
@@ -721,44 +721,44 @@ static int initialize_rawinput (void)
     RAWINPUTDEVICELIST *ridl = 0;
     int num = 500, gotnum, i, bufsize, vtmp;
     int rnum_mouse, rnum_kb, rnum_raw;
-    uae_u8 *buf = 0;
+    TCHAR *buf = NULL;
     int rmouse = 0, rkb = 0;
-    char tmp[100];
+    TCHAR tmp[100];
 
     if (no_rawinput)
        goto error;
     pRegisterRawInputDevices = (REGISTERRAWINPUTDEVICES)GetProcAddress (
-       GetModuleHandle ("user32.dll"), "RegisterRawInputDevices");
+       GetModuleHandle (L"user32.dll"), "RegisterRawInputDevices");
     pGetRawInputData = (GETRAWINPUTDATA)GetProcAddress (
-       GetModuleHandle ("user32.dll"), "GetRawInputData");
+       GetModuleHandle (L"user32.dll"), "GetRawInputData");
     pGetRawInputDeviceList = (GETRAWINPUTDEVICELIST)GetProcAddress (
-       GetModuleHandle ("user32.dll"), "GetRawInputDeviceList");
+       GetModuleHandle (L"user32.dll"), "GetRawInputDeviceList");
     pGetRawInputDeviceInfo = (GETRAWINPUTDEVICEINFO)GetProcAddress (
-       GetModuleHandle ("user32.dll"), "GetRawInputDeviceInfoA");
+       GetModuleHandle (L"user32.dll"), "GetRawInputDeviceInfoW");
     pGetRawInputBuffer = (GETRAWINPUTBUFFER)GetProcAddress (
-       GetModuleHandle ("user32.dll"), "GetRawInputBuffer");
+       GetModuleHandle (L"user32.dll"), "GetRawInputBuffer");
     pDefRawInputProc = (DEFRAWINPUTPROC)GetProcAddress (
-       GetModuleHandle ("user32.dll"), "DefRawInputProc");
+       GetModuleHandle (L"user32.dll"), "DefRawInputProc");
 
     if (!pRegisterRawInputDevices || !pGetRawInputData || !pGetRawInputDeviceList ||
        !pGetRawInputDeviceInfo || !pGetRawInputBuffer || !pDefRawInputProc)
        goto error;
 
-    bufsize = 10000;
+    bufsize = 10000 * sizeof (TCHAR);
     buf = xmalloc (bufsize);
 
     register_rawinput ();
     if (pGetRawInputDeviceList (NULL, &num, sizeof (RAWINPUTDEVICELIST)) != 0) {
-       write_log ("RAWINPUT error %08X\n", GetLastError());
+       write_log (L"RAWINPUT error %08X\n", GetLastError());
        goto error2;
     }
-    write_log ("RAWINPUT: found %d devices\n", num);
+    write_log (L"RAWINPUT: found %d devices\n", num);
     if (num <= 0)
        goto error2;
-    ridl = xcalloc (sizeof(RAWINPUTDEVICELIST), num);
+    ridl = xcalloc (sizeof (RAWINPUTDEVICELIST), num);
     gotnum = pGetRawInputDeviceList (ridl, &num, sizeof (RAWINPUTDEVICELIST));
     if (gotnum <= 0) {
-       write_log ("RAWINPUT didn't find any devices\n");
+       write_log (L"RAWINPUT didn't find any devices\n");
        goto error2;
     }
     rnum_raw = rnum_mouse = rnum_kb = 0;
@@ -823,14 +823,14 @@ static int initialize_rawinput (void)
 
            rnum_raw++;
            cleardid (did);
-           sprintf (tmp, "%s", type == RIM_TYPEMOUSE ? "RAW Mouse" : "RAW Keyboard");
+           _stprintf (tmp, L"%s", type == RIM_TYPEMOUSE ? L"RAW Mouse" : L"RAW Keyboard");
            did->name = my_strdup (tmp);
            did->rawinput = h;
            did->connection = DIDC_RAW;
 
-           write_log ("%p %s: ", h, type == RIM_TYPEMOUSE ? "mouse" : "keyboard");
+           write_log (L"%p %s: ", h, type == RIM_TYPEMOUSE ? L"mouse" : L"keyboard");
            did->sortname = my_strdup (buf);
-           write_log ("'%s'\n", buf);
+           write_log (L"'%s'\n", buf);
            did->configname = my_strdup (buf);
            rdi = (PRID_DEVICE_INFO)buf;
            memset (rdi, 0, sizeof (RID_DEVICE_INFO));
@@ -844,29 +844,29 @@ static int initialize_rawinput (void)
 
            if (type == RIM_TYPEMOUSE) {
                PRID_DEVICE_INFO_MOUSE rdim = &rdi->mouse;
-               write_log ("id=%d buttons=%d hw=%d rate=%d\n",
+               write_log (L"id=%d buttons=%d hw=%d rate=%d\n",
                    rdim->dwId, rdim->dwNumberOfButtons, rdim->fHasHorizontalWheel, rdim->dwSampleRate);
                if (rdim->dwNumberOfButtons >= MAX_MAPPINGS) {
-                   write_log ("bogus number of buttons, ignored\n");
+                   write_log (L"bogus number of buttons, ignored\n");
                    continue;
                }
                did->buttons_real = did->buttons = rdim->dwNumberOfButtons;
                for (j = 0; j < did->buttons; j++) {
                    did->buttonsort[j] = j;
-                   sprintf (tmp, "Button %d", j + 1);
+                   _stprintf (tmp, L"Button %d", j + 1);
                    did->buttonname[j] = my_strdup (tmp);
                }
                did->axles = 3;
                did->axissort[0] = 0;
-               did->axisname[0] = my_strdup ("X-Axis");
+               did->axisname[0] = my_strdup (L"X-Axis");
                did->axissort[1] = 1;
-               did->axisname[1] = my_strdup ("Y-Axis");
+               did->axisname[1] = my_strdup (L"Y-Axis");
                did->axissort[2] = 2;
-               did->axisname[2] = my_strdup ("Wheel");
+               did->axisname[2] = my_strdup (L"Wheel");
                addplusminus (did, 2);
                if (rdim->fHasHorizontalWheel) {
                    did->axissort[3] = 3;
-                   did->axisname[3] = my_strdup ("HWheel");
+                   did->axisname[3] = my_strdup (L"HWheel");
                    did->axles++;
                    addplusminus (did, 3);
                }
@@ -874,23 +874,23 @@ static int initialize_rawinput (void)
            } else {
                int j;
                PRID_DEVICE_INFO_KEYBOARD rdik = &rdi->keyboard;
-               write_log ("type=%d sub=%d mode=%d fkeys=%d indicators=%d tkeys=%d",
+               write_log (L"type=%d sub=%d mode=%d fkeys=%d indicators=%d tkeys=%d",
                    rdik->dwType, rdik->dwSubType, rdik->dwKeyboardMode,
                    rdik->dwNumberOfFunctionKeys, rdik->dwNumberOfIndicators, rdik->dwNumberOfKeysTotal);
                j = 0;
                for (i = 0; i < 254; i++) {
-                   char tmp[100];
+                   TCHAR tmp[100];
                    tmp[0] = 0;
                    if (rawkeyboardlabels[j] != NULL) {
                        if (rawkeyboardlabels[j][0]) {
-                           strcpy (tmp, rawkeyboardlabels[j]);
+                           _tcscpy (tmp, rawkeyboardlabels[j]);
                            j++;
                        }
                    } else {
                        j++;
                    }
                    if (!tmp[0])
-                       sprintf (tmp, "Key %02X", i + 1);
+                       _stprintf (tmp, L"Key %02X", i + 1);
                    did->buttonname[i] = my_strdup (tmp);
                    did->buttonmappings[i] = i + 1;
                    did->buttonsort[i] = i + 1;
@@ -909,7 +909,7 @@ static int initialize_rawinput (void)
     return 1;
 
 error:
-    write_log ("RAWINPUT not available or failed to initialize\n");
+    write_log (L"RAWINPUT not available or failed to initialize\n");
 error2:
     xfree (ridl);
     xfree (buf);
@@ -919,7 +919,7 @@ error2:
 static void initialize_windowsmouse (void)
 {
     struct didata *did = di_mouse;
-    char tmp[100], *name;
+    TCHAR tmp[100], *name;
     int i, j;
 
     did += num_mouse;
@@ -927,11 +927,11 @@ static void initialize_windowsmouse (void)
        if (num_mouse >= MAX_INPUT_DEVICES)
            return;
        num_mouse++;
-       name = (i == 0) ? "Windows mouse" : "Mousehack mouse";
+       name = (i == 0) ? L"Windows mouse" : L"Mousehack mouse";
        did->connection = DIDC_WIN;
-       did->name = my_strdup (i ? "Mousehack mouse (Required for tablets)" : "Windows mouse");
-       did->sortname = my_strdup (i ? "Windowsmouse2" : "Windowsmouse1");
-       did->configname = my_strdup (i ? "WINMOUSE2" : "WINMOUSE1");
+       did->name = my_strdup (i ? L"Mousehack mouse (Required for tablets)" : L"Windows mouse");
+       did->sortname = my_strdup (i ? L"Windowsmouse2" : L"Windowsmouse1");
+       did->configname = my_strdup (i ? L"WINMOUSE2" : L"WINMOUSE1");
        did->buttons = GetSystemMetrics (SM_CMOUSEBUTTONS);
        if (did->buttons < 3)
            did->buttons = 3;
@@ -940,23 +940,23 @@ static void initialize_windowsmouse (void)
        did->buttons_real = did->buttons;
        for (j = 0; j < did->buttons; j++) {
            did->buttonsort[j] = j;
-           sprintf (tmp, "Button %d", j + 1);
+           _stprintf (tmp, L"Button %d", j + 1);
            did->buttonname[j] = my_strdup (tmp);
        }
        winmousewheelbuttonstart = did->buttons;
        did->axles = os_vista ? 4 : 3;
        did->axissort[0] = 0;
-       did->axisname[0] = my_strdup ("X-Axis");
+       did->axisname[0] = my_strdup (L"X-Axis");
        did->axissort[1] = 1;
-       did->axisname[1] = my_strdup ("Y-Axis");
+       did->axisname[1] = my_strdup (L"Y-Axis");
        if (did->axles > 2) {
            did->axissort[2] = 2;
-           did->axisname[2] = my_strdup ("Wheel");
+           did->axisname[2] = my_strdup (L"Wheel");
            addplusminus (did, 2);
        }
        if (did->axles > 3) {
            did->axissort[3] = 3;
-           did->axisname[3] = my_strdup ("HWheel");
+           did->axisname[3] = my_strdup (L"HWheel");
            addplusminus (did, 3);
        }
        did->priority = 2;
@@ -980,7 +980,7 @@ static void handle_rawinput_2 (RAWINPUT *raw)
                break;
        }
 #ifdef DI_DEBUG_RAWINPUT
-       write_log ("HANDLE=%08x %04x %04x %04x %08x %3d %3d %08x M=%d\n",
+       write_log (L"HANDLE=%08x %04x %04x %04x %08x %3d %3d %08x M=%d\n",
            raw->header.hDevice,
            rm->usFlags,
            rm->usButtonFlags,
@@ -993,24 +993,14 @@ static void handle_rawinput_2 (RAWINPUT *raw)
        if (num == num_mouse)
            return;
 
-       if (focus) {
-           if (mouseactive || isfullscreen () > 0) {
-               for (i = 0; i < (5 > did->buttons ? did->buttons : 5); i++) {
-                   if (rm->usButtonFlags & (3 << (i * 2)))
-                       setmousebuttonstate (num, i, (rm->usButtonFlags & (1 << (i * 2))) ? 1 : 0);
-               }
-               if (did->buttons > 5) {
-                   for (i = 5; i < did->buttons; i++)
-                       setmousebuttonstate (num, i, (rm->ulRawButtons & (1 << i)) ? 1 : 0);
-               }
-               if (did->buttons >= 3 && (rm->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN)) {
-                   if (currprefs.win32_middle_mouse) {
-                       if (isfullscreen () > 0)
-                           minimizewindow ();
-                       if (mouseactive)
-                           setmouseactive(0);
-                   }
-               }
+       if (isfocus () > 0) {
+           for (i = 0; i < (5 > did->buttons ? did->buttons : 5); i++) {
+               if (rm->usButtonFlags & (3 << (i * 2)))
+                   setmousebuttonstate (num, i, (rm->usButtonFlags & (1 << (i * 2))) ? 1 : 0);
+           }
+           if (did->buttons > 5) {
+               for (i = 5; i < did->buttons; i++)
+                   setmousebuttonstate (num, i, (rm->ulRawButtons & (1 << i)) ? 1 : 0);
            }
            if (rm->usButtonFlags & RI_MOUSE_WHEEL) {
                int val = (short)rm->usButtonData;
@@ -1024,6 +1014,16 @@ static void handle_rawinput_2 (RAWINPUT *raw)
            setmousestate (num, 0, rm->lLastX, (rm->usFlags & MOUSE_MOVE_ABSOLUTE) ? 1 : 0);
            setmousestate (num, 1, rm->lLastY, (rm->usFlags & MOUSE_MOVE_ABSOLUTE) ? 1 : 0);
        }
+       if (isfocus ()) {
+           if (did->buttons >= 3 && (rm->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN)) {
+               if (currprefs.win32_middle_mouse) {
+                   if (isfullscreen () > 0)
+                       minimizewindow ();
+                   if (mouseactive)
+                       setmouseactive(0);
+               }
+           }
+       }
 
     } else if (raw->header.dwType == RIM_TYPEKEYBOARD) {
        int istest = inputdevice_istest ();
@@ -1032,7 +1032,7 @@ static void handle_rawinput_2 (RAWINPUT *raw)
        int pressed = (rk->Flags & RI_KEY_BREAK) ? 0 : 1;
 
 #ifdef DI_DEBUG_RAWINPUT
-       write_log ("HANDLE=%x CODE=%x Flags=%x VK=%x MSG=%x EXTRA=%x\n",
+       write_log (L"HANDLE=%x CODE=%x Flags=%x VK=%x MSG=%x EXTRA=%x\n",
            raw->header.hDevice,
            raw->data.keyboard.MakeCode,
            raw->data.keyboard.Flags,
@@ -1067,7 +1067,7 @@ static void handle_rawinput_2 (RAWINPUT *raw)
            inputdevice_do_keyboard (scancode, pressed);
        } else {
            scancode = keyhack (scancode, pressed, num);
-           if (scancode < 0)
+           if (scancode < 0 || isfocus () <= 0)
                return;
            di_keycodes[num][scancode] = pressed;
            if (stopoutput == 0)
@@ -1110,27 +1110,27 @@ void handle_rawinput (LPARAM lParam)
     }
 }
 
-static void unacquire (LPDIRECTINPUTDEVICE8 lpdi, char *txt)
+static void unacquire (LPDIRECTINPUTDEVICE8 lpdi, TCHAR *txt)
 {
     if (lpdi) {
        HRESULT hr = IDirectInputDevice8_Unacquire (lpdi);
        if (FAILED (hr) && hr != DI_NOEFFECT)
-           write_log ("unacquire %s failed, %s\n", txt, DXError (hr));
+           write_log (L"unacquire %s failed, %s\n", txt, DXError (hr));
     }
 }
-static int acquire (LPDIRECTINPUTDEVICE8 lpdi, char *txt)
+static int acquire (LPDIRECTINPUTDEVICE8 lpdi, TCHAR *txt)
 {
     HRESULT hr = DI_OK;
     if (lpdi) {
        hr = IDirectInputDevice8_Acquire (lpdi);
        if (FAILED (hr) && hr != 0x80070005) {
-           write_log ("acquire %s failed, %s\n", txt, DXError (hr));
+           write_log (L"acquire %s failed, %s\n", txt, DXError (hr));
        }
     }
     return SUCCEEDED (hr) ? 1 : 0;
 }
 
-static int setcoop (struct didata *did, DWORD mode, char *txt)
+static int setcoop (struct didata *did, DWORD mode, TCHAR *txt)
 {
     HRESULT hr = DI_OK;
     if (did->lpdi) {
@@ -1138,10 +1138,10 @@ static int setcoop (struct didata *did, DWORD mode, char *txt)
        if (!did->coop && hMainWnd) {
            hr = IDirectInputDevice8_SetCooperativeLevel (did->lpdi, hMainWnd, mode);
            if (FAILED (hr) && hr != E_NOTIMPL) {
-               write_log ("setcooperativelevel %s failed, %s\n", txt, DXError (hr));
+               write_log (L"setcooperativelevel %s failed, %s\n", txt, DXError (hr));
            } else {
                did->coop = 1;
-               //write_log ("cooperativelevel %s set\n", txt);
+               //write_log (L"cooperativelevel %s set\n", txt);
            }
        }
     }
@@ -1157,7 +1157,7 @@ static void sortdd (struct didata *dd, int num, int type)
        dd[i].type = type;
        for (j = i + 1; j < num; j++) {
            dd[j].type = type;
-           if (dd[i].priority < dd[j].priority || (dd[i].priority == dd[j].priority && strcmp (dd[i].sortname, dd[j].sortname) > 0)) {
+           if (dd[i].priority < dd[j].priority || (dd[i].priority == dd[j].priority && _tcscmp (dd[i].sortname, dd[j].sortname) > 0)) {
                memcpy (&ddtmp, &dd[i], sizeof (ddtmp));
                memcpy (&dd[i], &dd[j], sizeof (ddtmp));
                memcpy (&dd[j], &ddtmp, sizeof (ddtmp));
@@ -1168,13 +1168,13 @@ static void sortdd (struct didata *dd, int num, int type)
     /* rename duplicate names */
     for (i = 0; i < num; i++) {
        for (j = i + 1; j < num; j++) {
-           if (!strcmp (dd[i].name, dd[j].name)) {
+           if (!_tcscmp (dd[i].name, dd[j].name)) {
                int cnt = 1;
-               char tmp[MAX_DPATH], tmp2[MAX_DPATH];
-               strcpy (tmp2, dd[i].name);
+               TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH];
+               _tcscpy (tmp2, dd[i].name);
                for (j = i; j < num; j++) {
-                   if (!strcmp (tmp2, dd[j].name)) {
-                       sprintf (tmp, "%s [%d]", dd[j].name, cnt++);
+                   if (!_tcscmp (tmp2, dd[j].name)) {
+                       _stprintf (tmp, L"%s [%d]", dd[j].name, cnt++);
                        xfree (dd[j].name);
                        dd[j].name = my_strdup (tmp);
                    }
@@ -1186,10 +1186,10 @@ static void sortdd (struct didata *dd, int num, int type)
 
 }
 
-static void sortobjects (struct didata *did, int *mappings, int *sort, char **names, int *types, int num)
+static void sortobjects (struct didata *did, int *mappings, int *sort, TCHAR **names, int *types, int num)
 {
     int i, j, tmpi;
-    char *tmpc;
+    TCHAR *tmpc;
 
     for (i = 0; i < num; i++) {
        for (j = i + 1; j < num; j++) {
@@ -1205,9 +1205,9 @@ static void sortobjects (struct didata *did, int *mappings, int *sort, char **na
     }
 #ifdef DI_DEBUG
     if (num > 0) {
-       write_log ("%s (PGUID=%s):\n", did->name, outGUID (&did->pguid));
+       write_log (L"%s (PGUID=%s):\n", did->name, outGUID (&did->pguid));
        for (i = 0; i < num; i++)
-           write_log ("%02X %03d '%s' (%d,%d)\n", mappings[i], mappings[i], names[i], sort[i], types ? types[i] : -1);
+           write_log (L"%02X %03d '%s' (%d,%d)\n", mappings[i], mappings[i], names[i], sort[i], types ? types[i] : -1);
     }
 #endif
 }
@@ -1251,11 +1251,11 @@ static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi,
 {
     struct didata *did = pContext;
     int i;
-    char tmp[100];
+    TCHAR tmp[100];
 
 #if 0
     if (pdidoi->dwOfs != DIDFT_GETINSTANCE (pdidoi->dwType))
-       write_log ("%x-%s: %x <> %x\n", pdidoi->dwType & 0xff, pdidoi->tszName,
+       write_log (L"%x-%s: %x <> %x\n", pdidoi->dwType & 0xff, pdidoi->tszName,
            pdidoi->dwOfs, DIDFT_GETINSTANCE (pdidoi->dwType));
 #endif
     if (pdidoi->dwType & DIDFT_AXIS) {
@@ -1271,7 +1271,7 @@ static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi,
        if (sort < 0) {
            for (i = 0; i < did->axles; i++) {
                if (did->axissort[i] == sort) {
-                   write_log ("ignored duplicate '%s'\n", pdidoi->tszName);
+                   write_log (L"ignored duplicate '%s'\n", pdidoi->tszName);
                    return DIENUM_CONTINUE;
                }
            }
@@ -1295,7 +1295,7 @@ static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi,
            did->axissort[did->axles] = makesort_mouse (&pdidoi->guidType, &did->axismappings[did->axles]);
        for (i = 0; i < 2; i++) {
            did->axismappings[did->axles + i] = DIJOFS_POV(numpov);
-           sprintf (tmp, "%s (%d)", pdidoi->tszName, i + 1);
+           _stprintf (tmp, L"%s (%d)", pdidoi->tszName, i + 1);
            did->axisname[did->axles + i] = my_strdup (tmp);
            did->axissort[did->axles + i] = did->axissort[did->axles];
            did->axistype[did->axles + i] = i + 1;
@@ -1325,11 +1325,11 @@ static BOOL CALLBACK EnumObjectsCallback (const DIDEVICEOBJECTINSTANCE* pdidoi,
     return DIENUM_CONTINUE;
 }
 
-static void trimws (char *s)
+static void trimws (TCHAR *s)
 {
     /* Delete trailing whitespace.  */
-    int len = strlen (s);
-    while (len > 0 && strcspn (s + len - 1, "\t \r\n") == 0)
+    int len = _tcslen (s);
+    while (len > 0 && _tcscspn (s + len - 1, L"\t \r\n") == 0)
         s[--len] = '\0';
 }
 
@@ -1337,29 +1337,29 @@ static BOOL CALLBACK di_enumcallback (LPCDIDEVICEINSTANCE lpddi, LPVOID *dd)
 {
     struct didata *did;
     int len, type;
-    char *typetxt;
-    char tmp[100];
+    TCHAR *typetxt;
+    TCHAR tmp[100];
 
     type = lpddi->dwDevType & 0xff;
     if (type == DI8DEVTYPE_MOUSE || type == DI8DEVTYPE_SCREENPOINTER) {
        did = di_mouse;
-       typetxt = "Mouse";
+       typetxt = L"Mouse";
     } else if (type == DI8DEVTYPE_GAMEPAD  || type == DI8DEVTYPE_JOYSTICK ||
        type == DI8DEVTYPE_FLIGHT || type == DI8DEVTYPE_DRIVING || type == DI8DEVTYPE_1STPERSON) {
        did = di_joystick;
-       typetxt = "Game controller";
+       typetxt = L"Game controller";
     } else if (type == DI8DEVTYPE_KEYBOARD) {
        did = di_keyboard;
-       typetxt = "Keyboard";
+       typetxt = L"Keyboard";
     } else {
        did = NULL;
-       typetxt = "Unknown";
+       typetxt = L"Unknown";
     }
 
 #ifdef DI_DEBUG
-    write_log ("I=%s ", outGUID (&lpddi->guidInstance));
-    write_log ("P=%s\n", outGUID (&lpddi->guidProduct));
-    write_log ("'%s' '%s' %08X [%s]\n", lpddi->tszProductName, lpddi->tszInstanceName, lpddi->dwDevType, typetxt);
+    write_log (L"I=%s ", outGUID (&lpddi->guidInstance));
+    write_log (L"P=%s\n", outGUID (&lpddi->guidProduct));
+    write_log (L"'%s' '%s' %08X [%s]\n", lpddi->tszProductName, lpddi->tszInstanceName, lpddi->dwDevType, typetxt);
 #endif
 
     if (did == di_mouse) {
@@ -1382,15 +1382,15 @@ static BOOL CALLBACK di_enumcallback (LPCDIDEVICEINSTANCE lpddi, LPVOID *dd)
 
     cleardid (did);
     if (lpddi->tszInstanceName) {
-       len = strlen (lpddi->tszInstanceName) + 5 + 1;
-       did->name = malloc (len);
-       strcpy (did->name, lpddi->tszInstanceName);
+       len = _tcslen (lpddi->tszInstanceName) + 5 + 1;
+       did->name = malloc (len * sizeof (TCHAR));
+       _tcscpy (did->name, lpddi->tszInstanceName);
     } else {
        did->name = malloc (100);
-       sprintf(did->name, "[no name]");
+       _stprintf (did->name, L"[no name]");
     }
     trimws (did->name);
-    sprintf (tmp, "%08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X %08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X",
+    _stprintf (tmp, L"%08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X %08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X",
        lpddi->guidProduct.Data1, lpddi->guidProduct.Data2, lpddi->guidProduct.Data3,
        lpddi->guidProduct.Data4[0], lpddi->guidProduct.Data4[1], lpddi->guidProduct.Data4[2], lpddi->guidProduct.Data4[3],
        lpddi->guidProduct.Data4[4], lpddi->guidProduct.Data4[5], lpddi->guidProduct.Data4[6], lpddi->guidProduct.Data4[7],
@@ -1407,7 +1407,7 @@ static BOOL CALLBACK di_enumcallback (LPCDIDEVICEINSTANCE lpddi, LPVOID *dd)
     if (!memcmp (&did->iguid, &GUID_SysKeyboard, sizeof (GUID)) || !memcmp (&did->iguid, &GUID_SysMouse, sizeof (GUID))) {
        did->priority = 2;
        did->superdevice = 1;
-       strcat (did->name, " *");
+       _tcscat (did->name, L" *");
     }
     return DIENUM_CONTINUE;
 }
@@ -1438,34 +1438,34 @@ static int di_do_init (void)
        di_dev_free (&di_mouse[i]);
        di_dev_free (&di_keyboard[i]);
     }
-    hr = DirectInput8Create (hInst, DIRECTINPUT_VERSION, &IID_IDirectInput8A, (LPVOID *)&g_lpdi, NULL);
+    hr = DirectInput8Create (hInst, DIRECTINPUT_VERSION, &IID_IDirectInput8, (LPVOID *)&g_lpdi, NULL);
     if (FAILED(hr)) {
-       write_log ("DirectInput8Create failed, %s\n", DXError (hr));
-       gui_message ("Failed to initialize DirectInput!");
+       write_log (L"DirectInput8Create failed, %s\n", DXError (hr));
+       gui_message (L"Failed to initialize DirectInput!");
        return 0;
     }
     if (dinput_enum_all) {
-       write_log ("DirectInput enumeration..\n");
+       write_log (L"DirectInput enumeration..\n");
        IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_ALL, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
     } else {
        if (rawkeyboard <= 0) {
-           write_log ("DirectInput enumeration.. Keyboards..\n");
+           write_log (L"DirectInput enumeration.. Keyboards..\n");
            IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_KEYBOARD, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
        }
-       write_log ("DirectInput enumeration.. Pointing devices..\n");
+       write_log (L"DirectInput enumeration.. Pointing devices..\n");
        IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_POINTER, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
-       write_log ("DirectInput enumeration.. Game controllers..\n");
+       write_log (L"DirectInput enumeration.. Game controllers..\n");
        IDirectInput8_EnumDevices (g_lpdi, DI8DEVCLASS_GAMECTRL, di_enumcallback, 0, DIEDFL_ATTACHEDONLY);
     }
-    write_log ("RawInput enumeration..\n");
+    write_log (L"RawInput enumeration..\n");
     initialize_rawinput ();
-    write_log ("Windowsmouse initialization..\n");
+    write_log (L"Windowsmouse initialization..\n");
     initialize_windowsmouse ();
-    write_log ("Catweasel joymouse initialization..\n");
+    write_log (L"Catweasel joymouse initialization..\n");
     initialize_catweasel ();
-    write_log ("wintab tablet initialization..\n");
+    write_log (L"wintab tablet initialization..\n");
     initialize_tablet ();
-    write_log ("end\n");
+    write_log (L"end\n");
 
     sortdd (di_joystick, num_joystick, DID_JOYSTICK);
     sortdd (di_mouse, num_mouse, DID_MOUSE);
@@ -1506,12 +1506,12 @@ static int get_mouse_num (void)
     return num_mouse;
 }
 
-static char *get_mouse_friendlyname (int mouse)
+static TCHAR *get_mouse_friendlyname (int mouse)
 {
     return di_mouse[mouse].name;
 }
 
-static char *get_mouse_uniquename (int mouse)
+static TCHAR *get_mouse_uniquename (int mouse)
 {
     return di_mouse[mouse].configname;
 }
@@ -1533,7 +1533,7 @@ static int get_mouse_widget_first (int mouse, int type)
     return -1;
 }
 
-static int get_mouse_widget_type (int mouse, int num, char *name, uae_u32 *code)
+static int get_mouse_widget_type (int mouse, int num, TCHAR *name, uae_u32 *code)
 {
     struct didata *did = &di_mouse[mouse];
 
@@ -1541,11 +1541,11 @@ static int get_mouse_widget_type (int mouse, int num, char *name, uae_u32 *code)
     int buttons = did->buttons;
     if (num >= axles && num < axles + buttons) {
        if (name)
-           strcpy (name, did->buttonname[num - did->axles]);
+           _tcscpy (name, did->buttonname[num - did->axles]);
        return IDEV_WIDGET_BUTTON;
     } else if (num < axles) {
        if (name)
-           strcpy (name, did->axisname[num]);
+           _tcscpy (name, did->axisname[num]);
        return IDEV_WIDGET_AXIS;
     }
     return IDEV_WIDGET_NONE;
@@ -1575,7 +1575,7 @@ static int init_mouse (void)
                sortobjects (did, did->buttonmappings, did->buttonsort, did->buttonname, 0, did->buttons);
                did->lpdi = lpdi;
            } else {
-               write_log ("mouse %d CreateDevice failed, %s\n", i, DXError (hr));
+               write_log (L"mouse %d CreateDevice failed, %s\n", i, DXError (hr));
            }
        }
     }
@@ -1602,9 +1602,9 @@ static int acquire_mouse (int num, int flags)
     DIPROPDWORD dipdw;
     HRESULT hr;
 
-    unacquire (lpdi, "mouse");
+    unacquire (lpdi, L"mouse");
     if (did->connection == DIDC_DX && lpdi) {
-       setcoop (&di_mouse[num], flags ? (DISCL_FOREGROUND | DISCL_EXCLUSIVE) : (DISCL_BACKGROUND | DISCL_NONEXCLUSIVE), "mouse");
+       setcoop (&di_mouse[num], flags ? (DISCL_FOREGROUND | DISCL_EXCLUSIVE) : (DISCL_BACKGROUND | DISCL_NONEXCLUSIVE), L"mouse");
        dipdw.diph.dwSize = sizeof(DIPROPDWORD);
        dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
        dipdw.diph.dwObj = 0;
@@ -1612,8 +1612,8 @@ static int acquire_mouse (int num, int flags)
        dipdw.dwData = DI_BUFFER;
        hr = IDirectInputDevice8_SetProperty (lpdi, DIPROP_BUFFERSIZE, &dipdw.diph);
        if (FAILED (hr))
-           write_log ("mouse setpropertry failed, %s\n", DXError (hr));
-       di_mouse[num].acquired = acquire (lpdi, "mouse") ? 1 : -1;
+           write_log (L"mouse setpropertry failed, %s\n", DXError (hr));
+       di_mouse[num].acquired = acquire (lpdi, L"mouse") ? 1 : -1;
     } else {
        di_mouse[num].acquired = 1;
     }
@@ -1635,7 +1635,7 @@ static int acquire_mouse (int num, int flags)
 
 static void unacquire_mouse (int num)
 {
-    unacquire (di_mouse[num].lpdi, "mouse");
+    unacquire (di_mouse[num].lpdi, L"mouse");
     if (di_mouse[num].acquired > 0) {
        if (di_mouse[num].rawinput)
            rawmouse--;
@@ -1693,48 +1693,46 @@ static void read_mouse (void)
                int data = didod[j].dwData;
                int state = (data & 0x80) ? 1 : 0;
 #ifdef DI_DEBUG2
-               write_log ("MOUSE: %d OFF=%d DATA=%d STATE=%d\n", i, dimofs, data, state);
+               write_log (L"MOUSE: %d OFF=%d DATA=%d STATE=%d\n", i, dimofs, data, state);
 #endif
-               if (istest || focus) {
-                   if (istest || mouseactive || fs) {
-                       for (k = 0; k < did->axles; k++) {
-                           if (did->axismappings[k] == dimofs)
-                               setmousestate (i, k, data, 0);
-                       }
-                       for (k = 0; k < did->buttons; k++) {
-                           if (did->buttonmappings[k] == dimofs) {
-                               if (did->axisparent[k] >= 0) {
-                                   int dir = did->axisparentdir[k];
-                                   int bstate = 0;
-                                   if (dir)
-                                       bstate = data > 0 ? 1 : 0;
-                                   else
-                                       bstate = data < 0 ? 1 : 0;
-                                   if (bstate)
-                                       setmousebuttonstate (i, k, -1);
-                               } else {
+               if (istest || isfocus () > 0) {
+                   for (k = 0; k < did->axles; k++) {
+                       if (did->axismappings[k] == dimofs)
+                           setmousestate (i, k, data, 0);
+                   }
+                   for (k = 0; k < did->buttons; k++) {
+                       if (did->buttonmappings[k] == dimofs) {
+                           if (did->axisparent[k] >= 0) {
+                               int dir = did->axisparentdir[k];
+                               int bstate = 0;
+                               if (dir)
+                                   bstate = data > 0 ? 1 : 0;
+                               else
+                                   bstate = data < 0 ? 1 : 0;
+                               if (bstate)
+                                   setmousebuttonstate (i, k, -1);
+                           } else {
 #ifdef SINGLEFILE
-                                   if (k == 0)
-                                       uae_quit ();
+                               if (k == 0)
+                                   uae_quit ();
 #endif
-                                   if ((currprefs.win32_middle_mouse && k != 2) || !(currprefs.win32_middle_mouse))
-                                       setmousebuttonstate (i, k, state);
-                               }
+                               if ((currprefs.win32_middle_mouse && k != 2) || !(currprefs.win32_middle_mouse))
+                                   setmousebuttonstate (i, k, state);
                            }
                        }
                    }
-                   if (!istest && currprefs.win32_middle_mouse && dimofs == DIMOFS_BUTTON2 && state) {
-                       if (isfullscreen () > 0)
-                           minimizewindow ();
-                       if (mouseactive)
-                           setmouseactive (0);
-                   }
+               }
+               if (!istest && isfocus () && currprefs.win32_middle_mouse && dimofs == DIMOFS_BUTTON2 && state) {
+                   if (isfullscreen () > 0)
+                       minimizewindow ();
+                   if (mouseactive)
+                       setmouseactive (0);
                }
            }
        } else if (hr == DIERR_INPUTLOST) {
-           acquire (lpdi, "mouse");
+           acquire (lpdi, L"mouse");
        } else if (did->acquired &&  hr == DIERR_NOTACQUIRED) {
-           acquire (lpdi, "mouse");
+           acquire (lpdi, L"mouse");
        }
        IDirectInputDevice8_Poll (lpdi);
     }
@@ -1764,12 +1762,12 @@ static int get_kb_num (void)
     return num_keyboard;
 }
 
-static char *get_kb_friendlyname (int kb)
+static TCHAR *get_kb_friendlyname (int kb)
 {
     return di_keyboard[kb].name;
 }
 
-static char *get_kb_uniquename (int kb)
+static TCHAR *get_kb_uniquename (int kb)
 {
     return di_keyboard[kb].configname;
 }
@@ -1784,10 +1782,10 @@ static int get_kb_widget_first (int kb, int type)
     return 0;
 }
 
-static int get_kb_widget_type (int kb, int num, char *name, uae_u32 *code)
+static int get_kb_widget_type (int kb, int num, TCHAR *name, uae_u32 *code)
 {
     if (name)
-       sprintf (name, "[%02X] %s", di_keyboard[kb].buttonmappings[num], di_keyboard[kb].buttonname[num]);
+       _stprintf (name, L"[%02X] %s", di_keyboard[kb].buttonmappings[num], di_keyboard[kb].buttonname[num]);
     if (code)
        *code = di_keyboard[kb].buttonmappings[num];
     return IDEV_WIDGET_KEY;
@@ -1877,7 +1875,7 @@ static void set_leds (uae_u32 led)
            InputBuffer.LedFlags |= KEYBOARD_SCROLL_LOCK_ON;
        if (!DeviceIoControl (kbhandle, IOCTL_KEYBOARD_SET_INDICATORS,
            &InputBuffer, DataLength, NULL, 0, &ReturnedLength, NULL))
-               write_log ("kbleds: DeviceIoControl() failed %d\n", GetLastError());
+               write_log (L"kbleds: DeviceIoControl() failed %d\n", GetLastError());
 #endif
     }
 }
@@ -1926,7 +1924,7 @@ static int init_kb (void)
            if (SUCCEEDED (hr)) {
                hr = IDirectInputDevice8_SetDataFormat (lpdi, &c_dfDIKeyboard);
                if (FAILED (hr))
-                   write_log ("keyboard setdataformat failed, %s\n", DXError (hr));
+                   write_log (L"keyboard setdataformat failed, %s\n", DXError (hr));
                memset (&dipdw, 0, sizeof (dipdw));
                dipdw.diph.dwSize = sizeof (DIPROPDWORD);
                dipdw.diph.dwHeaderSize = sizeof (DIPROPHEADER);
@@ -1935,13 +1933,13 @@ static int init_kb (void)
                dipdw.dwData = DI_KBBUFFER;
                hr = IDirectInputDevice8_SetProperty (lpdi, DIPROP_BUFFERSIZE, &dipdw.diph);
                if (FAILED (hr))
-                   write_log ("keyboard setpropertry failed, %s\n", DXError (hr));
+                   write_log (L"keyboard setpropertry failed, %s\n", DXError (hr));
                IDirectInputDevice8_EnumObjects (lpdi, EnumObjectsCallback, did, DIDFT_ALL);
                sortobjects (did, did->axismappings, did->axissort, did->axisname, did->axistype, did->axles);
                sortobjects (did, did->buttonmappings, did->buttonsort, did->buttonname, 0, did->buttons);
                did->lpdi = lpdi;
            } else
-               write_log ("keyboard CreateDevice failed, %s\n", DXError (hr));
+               write_log (L"keyboard CreateDevice failed, %s\n", DXError (hr));
        }
     }
     keyboard_german = 0;
@@ -2006,13 +2004,13 @@ static int refresh_kb (LPDIRECTINPUTDEVICE8 lpdi, int num)
            else
                kc[i] = 0;
            if (kc[i] != di_keycodes[num][i]) {
-               write_log ("%02X -> %d\n", i, kc[i]);
+               write_log (L"%02X -> %d\n", i, kc[i]);
                di_keycodes[num][i] = kc[i];
                my_kbd_handler (num, i, kc[i]);
            }
        }
     } else if (hr == DIERR_INPUTLOST) {
-       acquire (lpdi, "keyboard");
+       acquire (lpdi, L"keyboard");
        IDirectInputDevice8_Poll (lpdi);
        return 0;
     }
@@ -2048,13 +2046,13 @@ static void read_kb (void)
        }
        elements = DI_KBBUFFER;
        hr = IDirectInputDevice8_GetDeviceData (lpdi, sizeof(DIDEVICEOBJECTDATA), didod, &elements, 0);
-       if (SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) {
+       if ((SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) && isfocus () > 0) {
            if (did->superdevice && (normalkb || rawkb))
                continue;
            for (j = 0; j < elements; j++) {
                int scancode = didod[j].dwOfs;
                int pressed = (didod[j].dwData & 0x80) ? 1 : 0;
-               //write_log ("%d: %02X %d\n", j, scancode, pressed);
+               //write_log (L"%d: %02X %d\n", j, scancode, pressed);
                if (!istest)
                    scancode = keyhack (scancode, pressed, i);
                if (scancode < 0)
@@ -2068,16 +2066,16 @@ static void read_kb (void)
                }
            }
        } else if (hr == DIERR_INPUTLOST) {
-           acquire (lpdi, "keyboard");
+           acquire (lpdi, L"keyboard");
            kb_do_refresh |= 1 << i;
        } else if (did->acquired &&  hr == DIERR_NOTACQUIRED) {
-           acquire (lpdi, "keyboard");
+           acquire (lpdi, L"keyboard");
        }
        IDirectInputDevice8_Poll (lpdi);
     }
 #ifdef CATWEASEL
     {
-       char kc;
+       uae_u8 kc;
        if (stopoutput == 0 && catweasel_read_keyboard (&kc))
            inputdevice_do_keyboard (kc & 0x7f, kc & 0x80);
     }
@@ -2139,19 +2137,19 @@ static int acquire_kb (int num, int flags)
 {
     LPDIRECTINPUTDEVICE8 lpdi = di_keyboard[num].lpdi;
 
-    unacquire (lpdi, "keyboard");
+    unacquire (lpdi, L"keyboard");
     if (currprefs.keyboard_leds_in_use) {
 #ifdef WINDDK
        if (!currprefs.win32_kbledmode) {
-           if (DefineDosDevice (DDD_RAW_TARGET_PATH, "Kbd","\\Device\\KeyboardClass0")) {
-               kbhandle = CreateFile ("\\\\.\\Kbd", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+           if (DefineDosDevice (DDD_RAW_TARGET_PATH, L"Kbd", L"\\Device\\KeyboardClass0")) {
+               kbhandle = CreateFile (L"\\\\.\\Kbd", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
                if (kbhandle == INVALID_HANDLE_VALUE) {
-                   write_log ("kbled: CreateFile failed, error %d\n", GetLastError());
+                   write_log (L"kbled: CreateFile failed, error %d\n", GetLastError());
                    currprefs.win32_kbledmode = 1;
                }
            } else {
                currprefs.win32_kbledmode = 1;
-               write_log ("kbled: DefineDosDevice failed, error %d\n", GetLastError());
+               write_log (L"kbled: DefineDosDevice failed, error %d\n", GetLastError());
            }
        }
 #else
@@ -2163,10 +2161,10 @@ static int acquire_kb (int num, int flags)
        set_leds (oldusedleds);
     }
 
-    setcoop (&di_keyboard[num], DISCL_NOWINKEY | DISCL_FOREGROUND | DISCL_EXCLUSIVE, "keyboard");
+    setcoop (&di_keyboard[num], DISCL_NOWINKEY | DISCL_FOREGROUND | DISCL_EXCLUSIVE, L"keyboard");
     kb_do_refresh = ~0;
     di_keyboard[num].acquired = -1;
-    if (acquire (lpdi, "keyboard")) {
+    if (acquire (lpdi, L"keyboard")) {
        if (di_keyboard[num].rawinput)
            rawkb++;
        else if (di_keyboard[num].superdevice)
@@ -2183,7 +2181,7 @@ static void unacquire_kb (int num)
 {
     LPDIRECTINPUTDEVICE8 lpdi = di_keyboard[num].lpdi;
 
-    unacquire (lpdi, "keyboard");
+    unacquire (lpdi, L"keyboard");
     if (di_keyboard[num].acquired > 0) {
        if (di_keyboard[num].rawinput)
            rawkb--;
@@ -2203,7 +2201,7 @@ static void unacquire_kb (int num)
 #ifdef WINDDK
        if (kbhandle != INVALID_HANDLE_VALUE) {
            CloseHandle (kbhandle);
-           DefineDosDevice (DDD_REMOVE_DEFINITION, "Kbd", NULL);
+           DefineDosDevice (DDD_REMOVE_DEFINITION, L"Kbd", NULL);
            kbhandle = INVALID_HANDLE_VALUE;
        }
 #endif
@@ -2234,16 +2232,16 @@ static int get_joystick_widget_num (int joy)
     return di_joystick[joy].axles + di_joystick[joy].buttons;
 }
 
-static int get_joystick_widget_type (int joy, int num, char *name, uae_u32 *code)
+static int get_joystick_widget_type (int joy, int num, TCHAR *name, uae_u32 *code)
 {
     struct didata *did = &di_joystick[joy];
     if (num >= did->axles && num < did->axles + did->buttons) {
        if (name)
-           strcpy (name, did->buttonname[num - did->axles]);
+           _tcscpy (name, did->buttonname[num - did->axles]);
        return IDEV_WIDGET_BUTTON;
     } else if (num < di_joystick[joy].axles) {
        if (name)
-           strcpy (name, did->axisname[num]);
+           _tcscpy (name, did->axisname[num]);
        return IDEV_WIDGET_AXIS;
     }
     return IDEV_WIDGET_NONE;
@@ -2261,13 +2259,13 @@ static int get_joystick_widget_first (int joy, int type)
     return -1;
 }
 
-static char *get_joystick_friendlyname (int joy)
+static TCHAR *get_joystick_friendlyname (int joy)
 {
     return di_joystick[joy].name;
 }
 
 
-static char *get_joystick_uniquename (int joy)
+static TCHAR *get_joystick_uniquename (int joy)
 {
     return di_joystick[joy].configname;
 }
@@ -2288,7 +2286,7 @@ static void read_joystick (void)
        if (!did->acquired)
            continue;
        if (did->connection == DIDC_CAT) {
-           if (getjoystickstate (i)) {
+           if (getjoystickstate (i) && isfocus () > 0) {
                /* only read CW state if it is really needed */
                uae_u8 cdir, cbuttons;
                if (catweasel_read_joystick (&cdir, &cbuttons)) {
@@ -2308,7 +2306,7 @@ static void read_joystick (void)
            continue;
        elements = DI_BUFFER;
        hr = IDirectInputDevice8_GetDeviceData (lpdi, sizeof (DIDEVICEOBJECTDATA), didod, &elements, 0);
-       if (SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) {
+       if ((SUCCEEDED (hr) || hr == DI_BUFFEROVERFLOW) && isfocus () > 0) {
            for (j = 0; j < elements; j++) {
                int dimofs = didod[j].dwOfs;
                int data = didod[j].dwData;
@@ -2343,13 +2341,13 @@ static void read_joystick (void)
                        if (bstate >= 0)
                            setjoybuttonstate (i, k, bstate);
 #ifdef DI_DEBUG2
-                       write_log ("AB:NUM=%d OFF=%d AXIS=%d DIR=%d NAME=%s VAL=%d STATE=%d\n",
+                       write_log (L"AB:NUM=%d OFF=%d AXIS=%d DIR=%d NAME=%s VAL=%d STATE=%d\n",
                            k, dimofs, axis, dir, did->buttonname[k], data, state);
 #endif
 
                    } else if (did->axisparent[k] < 0 && did->buttonmappings[k] == dimofs) {
 #ifdef DI_DEBUG2
-                       write_log ("B:NUM=%d OFF=%d NAME=%s VAL=%d STATE=%d\n",
+                       write_log (L"B:NUM=%d OFF=%d NAME=%s VAL=%d STATE=%d\n",
                            k, dimofs, did->buttonname[k], data, state);
 #endif
                        setjoybuttonstate (i, k, state);
@@ -2363,12 +2361,12 @@ static void read_joystick (void)
                        } else if (did->axistype[k] == 2) {
                            setjoystickstate (i, k, ((data2 >= 29250 && data2 <= 33750) || (data2 >= 0 && data2 <= 6750)) ? -1 : (data2 >= 11250 && data2 <= 24750) ? 1 : 0, 1);
 #ifdef DI_DEBUG2
-                           write_log ("P:NUM=%d OFF=%d NAME=%s VAL=%d\n", k, dimofs, did->axisname[k], data2);
+                           write_log (L"P:NUM=%d OFF=%d NAME=%s VAL=%d\n", k, dimofs, did->axisname[k], data2);
 #endif
                        } else if (did->axistype[k] == 0) {
 #ifdef DI_DEBUG2
                            if (data < -20000 || data > 20000)
-                               write_log ("A:NUM=%d OFF=%d NAME=%s VAL=%d\n", k, dimofs, did->axisname[k], data);
+                               write_log (L"A:NUM=%d OFF=%d NAME=%s VAL=%d\n", k, dimofs, did->axisname[k], data);
 #endif
                            setjoystickstate (i, k, data, 32768);
                        }
@@ -2378,9 +2376,9 @@ static void read_joystick (void)
            }
 
        } else if (hr == DIERR_INPUTLOST) {
-           acquire (lpdi, "joystick");
+           acquire (lpdi, L"joystick");
        } else if (did->acquired &&  hr == DIERR_NOTACQUIRED) {
-           acquire (lpdi, "joystick");
+           acquire (lpdi, L"joystick");
        }
        IDirectInputDevice8_Poll (lpdi);
     }
@@ -2412,7 +2410,7 @@ static int init_joystick (void)
                    sortobjects (did, did->buttonmappings, did->buttonsort, did->buttonname, 0, did->buttons);
                }
            } else {
-               write_log ("joystick createdevice failed, %s\n", DXError (hr));
+               write_log (L"joystick createdevice failed, %s\n", DXError (hr));
            }
        }
     }
@@ -2448,9 +2446,9 @@ static int acquire_joystick (int num, int flags)
     DIPROPDWORD dipdw;
     HRESULT hr;
 
-    unacquire (lpdi, "joystick");
+    unacquire (lpdi, L"joystick");
     if (di_joystick[num].connection == DIDC_DX && lpdi) {
-       setcoop (&di_joystick[num], flags ? (DISCL_FOREGROUND | DISCL_EXCLUSIVE) : (DISCL_BACKGROUND | DISCL_NONEXCLUSIVE), "joystick");
+       setcoop (&di_joystick[num], flags ? (DISCL_FOREGROUND | DISCL_EXCLUSIVE) : (DISCL_BACKGROUND | DISCL_NONEXCLUSIVE), L"joystick");
        memset (&dipdw, 0, sizeof (dipdw));
        dipdw.diph.dwSize = sizeof (DIPROPDWORD);
        dipdw.diph.dwHeaderSize = sizeof (DIPROPHEADER);
@@ -2459,8 +2457,8 @@ static int acquire_joystick (int num, int flags)
        dipdw.dwData = DI_BUFFER;
        hr = IDirectInputDevice8_SetProperty (lpdi, DIPROP_BUFFERSIZE, &dipdw.diph);
        if (FAILED (hr))
-           write_log ("joystick setproperty failed, %s\n", DXError (hr));
-       di_joystick[num].acquired = acquire (lpdi, "joystick") ? 1 : -1;
+           write_log (L"joystick setproperty failed, %s\n", DXError (hr));
+       di_joystick[num].acquired = acquire (lpdi, L"joystick") ? 1 : -1;
     } else {
        di_joystick[num].acquired = 1;
     }
@@ -2469,7 +2467,7 @@ static int acquire_joystick (int num, int flags)
 
 static void unacquire_joystick (int num)
 {
-    unacquire (di_joystick[num].lpdi, "joystick");
+    unacquire (di_joystick[num].lpdi, L"joystick");
     di_joystick[num].acquired = 0;
 }
 
index f134c869644db0498b32580a5afaeb04b106d384..46abd7d6ec07315506a2637f9108a8651515becd 100644 (file)
@@ -59,14 +59,14 @@ struct TLVERTEX {
     D3DXVECTOR2 texcoord;       // texture coords
 };
 
-static char *D3D_ErrorText (HRESULT error)
+static TCHAR *D3D_ErrorText (HRESULT error)
 {
-    return "";
+    return L"";
 }
-static char *D3D_ErrorString (HRESULT dival)
+static TCHAR *D3D_ErrorString (HRESULT dival)
 {
-    static char dierr[200];
-    sprintf(dierr, "%08X S=%d F=%04X C=%04X (%d) (%s)",
+    static TCHAR dierr[200];
+    _stprintf (dierr, L"%08X S=%d F=%04X C=%04X (%d) (%s)",
        dival, (dival & 0x80000000) ? 1 : 0,
        HRESULT_FACILITY(dival),
        HRESULT_CODE(dival),
@@ -102,17 +102,17 @@ static D3DXMATRIX* MatrixTranslation (D3DXMATRIX *pOut, float tx, float ty, floa
     return pOut;
 }
 
-static char *D3DX_ErrorString (HRESULT hr, LPD3DXBUFFER Errors)
+static TCHAR *D3DX_ErrorString (HRESULT hr, LPD3DXBUFFER Errors)
 {
-    static char buffer[1000];
-    char *s = NULL;
+    static TCHAR buffer[1000];
+    TCHAR *s = NULL;
 
     if (Errors)
        s = Errors->lpVtbl->GetBufferPointer (Errors);
-    strcpy (buffer, D3D_ErrorString (hr));
+    _tcscpy (buffer, D3D_ErrorString (hr));
     if (s) {
-       strcat (buffer, " ");
-       strcat (buffer, s);
+       _tcscat (buffer, L" ");
+       _tcscat (buffer, s);
     }
     return buffer;
 }
@@ -294,7 +294,7 @@ static int psEffect_ParseParameters (LPD3DXEFFECTCOMPILER EffectCompiler)
                if (ppTextureShader)
                    ppTextureShader->lpVtbl->Release (ppTextureShader);
            } else {
-               write_log ("D3D: Could not compile texture shader: %s\n", D3DX_ErrorString (hr, lpErrors));
+               write_log (L"D3D: Could not compile texture shader: %s\n", D3DX_ErrorString (hr, lpErrors));
                if (lpErrors)
                    lpErrors->lpVtbl->Release (lpErrors);
                return 0;
@@ -319,14 +319,14 @@ int D3D_canshaders (void)
     if (yesno > 0)
        return 1;
     yesno = -1;
-    h = LoadLibrary ("d3dx9_40.dll");
+    h = LoadLibrary (L"d3dx9_40.dll");
     if (h != NULL) {
        FreeLibrary (h);
        d3dx = Direct3DCreate9 (D3D_SDK_VERSION);
        if (d3dx != NULL) {
            if (SUCCEEDED (IDirect3D9_GetDeviceCaps (d3dx, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps))) {
                if(d3dCaps.PixelShaderVersion >= D3DPS_VERSION(2,0)) {
-                   write_log ("D3D: Pixel shader 2.0+ support detected, shader filters enabled.\n");
+                   write_log (L"D3D: Pixel shader 2.0+ support detected, shader filters enabled.\n");
                    yesno = 1;
                }
            }
@@ -336,31 +336,31 @@ int D3D_canshaders (void)
     return yesno > 0 ? 1 : 0;
 }
 
-static int psEffect_LoadEffect (const char *shaderfile)
+static int psEffect_LoadEffect (const TCHAR *shaderfile)
 {
     int ret = 0;
     LPD3DXEFFECTCOMPILER EffectCompiler = NULL;
     LPD3DXBUFFER Errors = NULL;
     LPD3DXBUFFER BufferEffect = NULL;
     HRESULT hr;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     static int first;
 
     if (!D3D_canshaders ()) {
        if (!first)
-           gui_message ("Installed DirectX is too old\nD3D shaders disabled.");
+           gui_message (L"Installed DirectX is too old\nD3D shaders disabled.");
        first = 1;
        return 0;
     }
-    sprintf (tmp, "%s%sfiltershaders\\direct3d\\%s", start_path_exe, WIN32_PLUGINDIR, shaderfile);
+    _stprintf (tmp, L"%s%sfiltershaders\\direct3d\\%s", start_path_exe, WIN32_PLUGINDIR, shaderfile);
     hr = D3DXCreateEffectCompilerFromFile (tmp, NULL, NULL, 0, &EffectCompiler, &Errors);
     if (FAILED (hr)) {
-       write_log ("D3D: D3DXCreateEffectCompilerFromFile failed: %s\n", D3DX_ErrorString (hr, Errors));
+       write_log (L"D3D: D3DXCreateEffectCompilerFromFile failed: %s\n", D3DX_ErrorString (hr, Errors));
        goto end;
     }
     hr = EffectCompiler->lpVtbl->CompileEffect (EffectCompiler, 0, &BufferEffect, &Errors);
     if (FAILED (hr)) {
-       write_log ("D3D: CompileEffect failed: %s\n", D3DX_ErrorString (hr, Errors));
+       write_log (L"D3D: CompileEffect failed: %s\n", D3DX_ErrorString (hr, Errors));
        goto end;
     }
     hr = D3DXCreateEffect (d3ddev,
@@ -370,7 +370,7 @@ static int psEffect_LoadEffect (const char *shaderfile)
        0,
        NULL, &pEffect, &Errors);
     if (FAILED (hr)) {
-       write_log ("D3D: D3DXCreateEffect failed: %s\n", D3DX_ErrorString (hr, Errors));
+       write_log (L"D3D: D3DXCreateEffect failed: %s\n", D3DX_ErrorString (hr, Errors));
        goto end;
     }
     pEffect->lpVtbl->GetDesc (pEffect, &EffectDesc);
@@ -391,9 +391,9 @@ end:
        psActive = TRUE;
        if (psEffect_hasPreProcess ())
            psPreProcess = TRUE;
-       write_log ("D3D: pixelshader filter '%s' enabled, preproc=%d\n", tmp, psPreProcess);
+       write_log (L"D3D: pixelshader filter '%s' enabled, preproc=%d\n", tmp, psPreProcess);
     } else {
-       write_log ("D3D: pixelshader filter '%s' failed to initialize\n", tmp);
+       write_log (L"D3D: pixelshader filter '%s' failed to initialize\n", tmp);
     }
     return ret;
 }
@@ -405,21 +405,21 @@ static int psEffect_SetMatrices (D3DXMATRIX *matProj, D3DXMATRIX *matView, D3DXM
     if (m_MatWorldEffectHandle) {
        hr = pEffect->lpVtbl->SetMatrix (pEffect, m_MatWorldEffectHandle, matWorld);
        if (FAILED (hr)) {
-           write_log ("D3D:Create:SetMatrix:matWorld %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:Create:SetMatrix:matWorld %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
     if (m_MatViewEffectHandle) {
        hr = pEffect->lpVtbl->SetMatrix (pEffect, m_MatViewEffectHandle, matView);
        if (FAILED (hr)) {
-           write_log ("D3D:Create:SetMatrix:matView %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:Create:SetMatrix:matView %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
     if (m_MatProjEffectHandle) {
        hr = pEffect->lpVtbl->SetMatrix (pEffect, m_MatProjEffectHandle, matProj);
        if (FAILED (hr)) {
-           write_log ("D3D:Create:SetMatrix:matProj %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:Create:SetMatrix:matProj %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
@@ -428,7 +428,7 @@ static int psEffect_SetMatrices (D3DXMATRIX *matProj, D3DXMATRIX *matView, D3DXM
        D3DXMatrixMultiply (&matWorldView, matWorld, matView);
        hr = pEffect->lpVtbl->SetMatrix (pEffect, m_MatWorldViewEffectHandle, &matWorldView);
        if (FAILED (hr)) {
-           write_log ("D3D:Create:SetMatrix:matWorldView %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:Create:SetMatrix:matWorldView %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
@@ -437,7 +437,7 @@ static int psEffect_SetMatrices (D3DXMATRIX *matProj, D3DXMATRIX *matView, D3DXM
        D3DXMatrixMultiply (&matViewProj, matView, matProj);
        hr = pEffect->lpVtbl->SetMatrix (pEffect, m_MatViewProjEffectHandle, &matViewProj);
        if (FAILED (hr)) {
-           write_log ("D3D:Create:SetMatrix:matViewProj %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:Create:SetMatrix:matViewProj %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
@@ -447,7 +447,7 @@ static int psEffect_SetMatrices (D3DXMATRIX *matProj, D3DXMATRIX *matView, D3DXM
        D3DXMatrixMultiply (&matWorldViewProj, &tmp, matProj);
        hr = pEffect->lpVtbl->SetMatrix (pEffect, m_MatWorldViewProjEffectHandle, &matWorldViewProj);
        if (FAILED (hr)) {
-           write_log ("D3D:Create:SetMatrix:matWorldViewProj %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:Create:SetMatrix:matWorldViewProj %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
@@ -460,32 +460,32 @@ static int psEffect_SetTextures (LPDIRECT3DTEXTURE9 lpSource, LPDIRECT3DTEXTURE9
     D3DXVECTOR4 fDims, fTexelSize;
 
     if (!m_SourceTextureEffectHandle) {
-       write_log ("D3D: Texture with SOURCETEXTURE semantic not found\n");
+       write_log (L"D3D: Texture with SOURCETEXTURE semantic not found\n");
        return 0;
     }
     hr = pEffect->lpVtbl->SetTexture (pEffect, m_SourceTextureEffectHandle, (LPDIRECT3DBASETEXTURE9)lpSource);
     if (FAILED (hr)) {
-       write_log ("D3D:SetTextures:lpSource %s\n", D3D_ErrorString (hr));
+       write_log (L"D3D:SetTextures:lpSource %s\n", D3D_ErrorString (hr));
        return 0;
     }
     if(m_WorkingTexture1EffectHandle) {
        hr = pEffect->lpVtbl->SetTexture (pEffect, m_WorkingTexture1EffectHandle, (LPDIRECT3DBASETEXTURE9)lpWorking1);
        if (FAILED (hr)) {
-           write_log ("D3D:SetTextures:lpWorking1 %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:SetTextures:lpWorking1 %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
     if(m_WorkingTexture2EffectHandle) {
        hr = pEffect->lpVtbl->SetTexture (pEffect, m_WorkingTexture2EffectHandle, (LPDIRECT3DBASETEXTURE9)lpWorking2);
        if (FAILED (hr)) {
-           write_log ("D3D:SetTextures:lpWorking2 %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:SetTextures:lpWorking2 %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
     if(m_Hq2xLookupTextureHandle) {
        hr = pEffect->lpVtbl->SetTexture (pEffect, m_Hq2xLookupTextureHandle, (LPDIRECT3DBASETEXTURE9)lpHq2xLookupTexture);
        if (FAILED (hr)) {
-           write_log ("D3D:SetTextures:lpHq2xLookupTexture %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:SetTextures:lpHq2xLookupTexture %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
@@ -502,14 +502,14 @@ static int psEffect_SetTextures (LPDIRECT3DTEXTURE9 lpSource, LPDIRECT3DTEXTURE9
     if (m_SourceDimsEffectHandle) {
        hr = pEffect->lpVtbl->SetVector (pEffect, m_SourceDimsEffectHandle, &fDims);
        if (FAILED (hr)) {
-           write_log ("D3D:SetTextures:SetVector:Source %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:SetTextures:SetVector:Source %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
     if (m_TexelSizeEffectHandle) {
        hr = pEffect->lpVtbl->SetVector (pEffect, m_TexelSizeEffectHandle, &fTexelSize);
        if (FAILED (hr)) {
-           write_log ("D3D:SetTextures:SetVector:Texel %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D:SetTextures:SetVector:Texel %s\n", D3D_ErrorString (hr));
            return 0;
        }
     }
@@ -531,12 +531,12 @@ static int psEffect_Begin (enum psEffect_Pass pass, UINT *pPasses)
            break;
     }
     if(FAILED(hr)) {
-       write_log ("D3D: SetTechnique: %s\n", D3D_ErrorString (hr));
+       write_log (L"D3D: SetTechnique: %s\n", D3D_ErrorString (hr));
        return 0;
     }
     hr = pEffect->lpVtbl->Begin (pEffect, pPasses, D3DXFX_DONOTSAVESTATE|D3DXFX_DONOTSAVESHADERSTATE);
     if(FAILED(hr)) {
-       write_log ("D3D: Begin: %s\n", D3D_ErrorString (hr));
+       write_log (L"D3D: Begin: %s\n", D3D_ErrorString (hr));
        return 0;
     }
     return 1;
@@ -547,7 +547,7 @@ static int psEffect_BeginPass (UINT Pass)
 
     hr = pEffect->lpVtbl->BeginPass (pEffect, Pass);
     if (FAILED (hr)) {
-       write_log ("D3D: BeginPass: %s\n", D3D_ErrorString (hr));
+       write_log (L"D3D: BeginPass: %s\n", D3D_ErrorString (hr));
        return 0;
     }
     return 1;
@@ -558,7 +558,7 @@ static int psEffect_EndPass (void)
 
     hr = pEffect->lpVtbl->EndPass (pEffect);
     if (FAILED (hr)) {
-       write_log ("D3D: EndPass: %s\n", D3D_ErrorString (hr));
+       write_log (L"D3D: EndPass: %s\n", D3D_ErrorString (hr));
        return 0;
     }
     return 1;
@@ -569,7 +569,7 @@ static int psEffect_End (void)
 
     hr = pEffect->lpVtbl->End (pEffect);
     if (FAILED (hr)) {
-       write_log ("D3D: End: %s\n", D3D_ErrorString (hr));
+       write_log (L"D3D: End: %s\n", D3D_ErrorString (hr));
        return 0;
     }
     return 1;
@@ -618,7 +618,7 @@ static LPDIRECT3DTEXTURE9 createtext (int *ww, int *hh, D3DFORMAT format)
            D3DPOOL_MANAGED, &t, NULL);
     }
     if (FAILED (hr)) {
-        write_log ("IDirect3DDevice9_CreateTexture failed: %s\n", D3D_ErrorString (hr));
+        write_log (L"IDirect3DDevice9_CreateTexture failed: %s\n", D3D_ErrorString (hr));
        return 0;
     }
 
@@ -639,26 +639,26 @@ static int createtexture (int w, int h)
        return 0;
     twidth = ww;
     theight = hh;
-    write_log ("D3D: %d*%d texture allocated, bits per pixel %d\n", ww, hh, t_depth);
+    write_log (L"D3D: %d*%d texture allocated, bits per pixel %d\n", ww, hh, t_depth);
     if (psActive) {
        D3DLOCKED_BOX lockedBox;
        if (FAILED (hr = IDirect3DDevice9_CreateTexture (d3ddev, ww, hh, 1,
            D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpWorkTexture1, NULL))) {
-               write_log ("D3D:Failed to create working texture1: %s\n", D3D_ErrorString (hr));
+               write_log (L"D3D:Failed to create working texture1: %s\n", D3D_ErrorString (hr));
                return 0;
        }
        if (FAILED (hr = IDirect3DDevice9_CreateTexture (d3ddev, ww, hh, 1,
            D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &lpWorkTexture2, NULL))) {
-               write_log ("D3D:Failed to create working texture2: %s\n", D3D_ErrorString (hr));
+               write_log (L"D3D:Failed to create working texture2: %s\n", D3D_ErrorString (hr));
                return 0;
        }
        if (FAILED (hr = IDirect3DDevice9_CreateVolumeTexture (d3ddev, 256, 16, 256, 1, 0,
            D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &lpHq2xLookupTexture, NULL))) {
-               write_log ("D3D:Failed to create volume texture: %s\n", D3D_ErrorString (hr));
+               write_log (L"D3D:Failed to create volume texture: %s\n", D3D_ErrorString (hr));
                return 0;
        }
        if (FAILED (hr = IDirect3DVolumeTexture9_LockBox (lpHq2xLookupTexture, 0, &lockedBox, NULL, 0))) {
-           write_log ("D3D: Failed to lock box of volume texture: %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D: Failed to lock box of volume texture: %s\n", D3D_ErrorString (hr));
            return 0;
        }
        //BuildHq2xLookupTexture(tin_w, tin_w, window_w, window_h, (unsigned char*)lockedBox.pBits);
@@ -679,7 +679,7 @@ static int createsltexture (void)
        return 0;
     required_sl_texture_w = ww;
     required_sl_texture_h = hh;
-    write_log ("D3D: SL %d*%d texture allocated\n", ww, hh);
+    write_log (L"D3D: SL %d*%d texture allocated\n", ww, hh);
 
     scanlines_ok = 1;
     return 1;
@@ -718,17 +718,17 @@ static void setupscenecoords (void)
     float w, h;
     float dw, dh;
 
-//    write_log ("%dx%d %dx%d %dx%d\n", twidth, theight, tin_w, tin_h, window_w, window_h);
+//    write_log (L"%dx%d %dx%d %dx%d\n", twidth, theight, tin_w, tin_h, window_w, window_h);
 
     getfilterrect2 (&dr, &sr, &zr, window_w, window_h, tin_w, tin_h, 1, tin_w, tin_h);
-//    write_log ("(%d %d %d %d) - (%d %d %d %d) (%d %d)\n",
+//    write_log (L"(%d %d %d %d) - (%d %d %d %d) (%d %d)\n",
 //     dr.left, dr.top, dr.right, dr.bottom, sr.left, sr.top, sr.right, sr.bottom, zr.left, zr.top);
 
     dw = dr.right - dr.left;
     dh = dr.bottom - dr.top;
     w = sr.right - sr.left;
     h = sr.bottom - sr.top;
-//    write_log ("%.1fx%.1f %.1fx%.1f\n", dw, dh, w, h);
+//    write_log (L"%.1fx%.1f %.1fx%.1f\n", dw, dh, w, h);
 
     MatrixOrthoOffCenterLH (&m_matProj, 0, w, 0, h, 0.0f, 1.0f);
 
@@ -841,7 +841,7 @@ static void createscanlines (int force)
 
     hr = IDirect3DTexture9_LockRect (sltexture, 0, &locked, NULL, D3DLOCK_DISCARD);
     if (FAILED (hr)) {
-       write_log ("SL IDirect3DTexture9_LockRect failed: %s\n", D3D_ErrorString (hr));
+       write_log (L"SL IDirect3DTexture9_LockRect failed: %s\n", D3D_ErrorString (hr));
        return;
     }
     sld = (uae_u8*)locked.pBits;
@@ -940,7 +940,7 @@ static int restoredeviceobjects (void)
     hr = IDirect3DDevice9_SetFVF (d3ddev, D3DFVF_TLVERTEX);
     if (FAILED (IDirect3DDevice9_CreateVertexBuffer (d3ddev, vbsize, D3DUSAGE_WRITEONLY,
        D3DFVF_TLVERTEX, D3DPOOL_MANAGED, &vertexBuffer, NULL))) {
-           write_log ("D3D: failed to create vertex buffer: %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D: failed to create vertex buffer: %s\n", D3D_ErrorString (hr));
            return 0;
     }
     createvertex ();
@@ -976,10 +976,10 @@ void D3D_free (void)
     psActive = 0;
 }
 
-const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
+const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
 {
     HRESULT ret, hr;
-    static char errmsg[100] = { 0 };
+    static TCHAR errmsg[100] = { 0 };
     D3DDISPLAYMODE mode;
     D3DDISPLAYMODEEX modeex;
     D3DCAPS9 d3dCaps;
@@ -992,14 +992,14 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     d3d_enabled = 0;
     scanlines_ok = 0;
     if (currprefs.gfx_filter != UAE_FILTER_DIRECT3D) {
-       strcpy (errmsg, "D3D: not enabled");
+       _tcscpy (errmsg, L"D3D: not enabled");
        return errmsg;
     }
 
     d3d_ex = FALSE;
-    d3dDLL = LoadLibrary ("D3D9.DLL");
+    d3dDLL = LoadLibrary (L"D3D9.DLL");
     if (d3dDLL == NULL) {
-       strcpy (errmsg, "Direct3D: DirectX 9 or newer required");
+       _tcscpy (errmsg, L"Direct3D: DirectX 9 or newer required");
        return errmsg;
     } else {
        typedef HRESULT (WINAPI *LPDIRECT3DCREATE9EX)(UINT, IDirect3D9Ex**);
@@ -1011,7 +1011,7 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     hr = -1;
     if (d3d_ex && D3DEX) {
         hr = Direct3DCreate9Ex (D3D_SDK_VERSION, &d3dex);
-       write_log ("Direct3D: failed to create D3DEx object: %s\n", D3D_ErrorString (hr));
+       write_log (L"Direct3D: failed to create D3DEx object: %s\n", D3D_ErrorString (hr));
         d3d = (IDirect3D9*)d3dex;
     }
     if (FAILED (hr)) {
@@ -1019,7 +1019,7 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
        d3d = Direct3DCreate9 (D3D_SDK_VERSION);
        if (d3d == NULL) {
            D3D_free ();
-           strcpy (errmsg, "Direct3D: failed to create D3D object");
+           _tcscpy (errmsg, L"Direct3D: failed to create D3D object");
            return errmsg;
         }
     }
@@ -1034,9 +1034,9 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     if (d3dex && D3DEX)
        IDirect3D9Ex_GetAdapterDisplayModeEx (d3dex, adapter, &modeex, NULL);
     if (FAILED (hr = IDirect3D9_GetAdapterDisplayMode (d3d, adapter, &mode)))
-        write_log ("D3D: IDirect3D9_GetAdapterDisplayMode failed %s\n", D3D_ErrorString (hr));
+        write_log (L"D3D: IDirect3D9_GetAdapterDisplayMode failed %s\n", D3D_ErrorString (hr));
     if (FAILED (hr = IDirect3D9_GetDeviceCaps (d3d, adapter, D3DDEVTYPE_HAL, &d3dCaps)))
-        write_log ("D3D: IDirect3D9_GetDeviceCaps failed %s\n", D3D_ErrorString (hr));
+        write_log (L"D3D: IDirect3D9_GetDeviceCaps failed %s\n", D3D_ErrorString (hr));
 
     memset (&dpp, 0, sizeof (dpp));
     dpp.Windowed = isfullscreen() <= 0;
@@ -1085,7 +1085,7 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
        ret = IDirect3D9_CreateDevice (d3d, adapter, D3DDEVTYPE_HAL, d3dhwnd, flags, &dpp, &d3ddev);
     }
     if (FAILED (ret)) {
-       sprintf (errmsg, "%s failed, %s\n", d3d_ex && D3DEX ? "CreateDeviceEx" : "CreateDevice", D3D_ErrorString (ret));
+       _stprintf (errmsg, L"%s failed, %s\n", d3d_ex && D3DEX ? L"CreateDeviceEx" : L"CreateDevice", D3D_ErrorString (ret));
        D3D_free ();
        return errmsg;
     }
@@ -1118,14 +1118,14 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     max_texture_w = d3dCaps.MaxTextureWidth;
     max_texture_h = d3dCaps.MaxTextureHeight;
 
-    write_log ("D3D: PS=%d.%d VS=%d.%d Square=%d, Pow2=%d, Tex Size=%d*%d\n",
+    write_log (L"D3D: PS=%d.%d VS=%d.%d Square=%d, Pow2=%d, Tex Size=%d*%d\n",
        (d3dCaps.PixelShaderVersion >> 8) & 0xff, d3dCaps.PixelShaderVersion & 0xff,
        (d3dCaps.VertexShaderVersion >> 8) & 0xff, d3dCaps.VertexShaderVersion & 0xff,
        tex_square, tex_pow2,
        max_texture_w, max_texture_h);
 
     if (max_texture_w < t_w || max_texture_h < t_h) {
-       sprintf (errmsg, "Direct3D: %d * %d or bigger texture support required\nYour card's maximum texture size is only %d * %d",
+       _stprintf (errmsg, L"Direct3D: %d * %d or bigger texture support required\nYour card's maximum texture size is only %d * %d",
            t_w, t_h, max_texture_w, max_texture_h);
        return errmsg;
     }
@@ -1133,8 +1133,8 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     required_sl_texture_w = w_w;
     required_sl_texture_h = w_h;
     if (currprefs.gfx_filter_scanlines > 0 && (max_texture_w < w_w || max_texture_h < w_h)) {
-       gui_message ("Direct3D: %d * %d or bigger texture support required for scanlines (max is only %d * %d)\n"
-           "Scanlines disabled.",
+       gui_message (L"Direct3D: %d * %d or bigger texture support required for scanlines (max is only %d * %d)\n"
+           L"Scanlines disabled.",
            required_sl_texture_w, required_sl_texture_h, max_texture_w, max_texture_h);
        changed_prefs.gfx_filter_scanlines = currprefs.gfx_filter_scanlines = 0;
     }
@@ -1162,7 +1162,7 @@ const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     tin_h = t_h;
     if (!restoredeviceobjects ()) {
        D3D_free ();
-       sprintf (errmsg, "Direct3D: texture creation failed");
+       _stprintf (errmsg, L"Direct3D: texture creation failed");
        return errmsg;
     }
 
@@ -1177,7 +1177,7 @@ int D3D_needreset (void)
     if (hr == D3DERR_DEVICENOTRESET) {
        hr = IDirect3DDevice9_Reset (d3ddev, &dpp);
        if (FAILED (hr)) {
-           write_log ("D3D: Reset failed %s\n", D3D_ErrorString (hr));
+           write_log (L"D3D: Reset failed %s\n", D3D_ErrorString (hr));
            return 1;
        }
     }
@@ -1229,7 +1229,7 @@ static void D3D_render2 (int clear)
            pass2:
            IDirect3DTexture9_GetSurfaceLevel (lpWorkTexture, 0, &lpNewRenderTarget);
            if (FAILED (hr = IDirect3DDevice9_SetRenderTarget (d3ddev, 0, lpNewRenderTarget))) {
-               write_log ("D3D: IDirect3DDevice9_SetRenderTarget: %s\n", D3D_ErrorString (hr));
+               write_log (L"D3D: IDirect3DDevice9_SetRenderTarget: %s\n", D3D_ErrorString (hr));
                return;
            }
            if (lpRenderTarget)
@@ -1312,7 +1312,7 @@ int D3D_locktexture (void)
     if (FAILED (hr)) {
        if (hr == D3DERR_DEVICELOST) {
            if (!dpp.Windowed && IsWindow (d3dhwnd) && !IsIconic (d3dhwnd)) {
-               write_log ("D3D: minimize\n");
+               write_log (L"D3D: minimize\n");
                ShowWindow (d3dhwnd, SW_MINIMIZE);
            }
        }
@@ -1324,13 +1324,13 @@ int D3D_locktexture (void)
     hr = IDirect3DTexture9_LockRect (texture, 0, &locked, NULL, D3DLOCK_NO_DIRTY_UPDATE);
     if (FAILED (hr)) {
        if (hr != D3DERR_DRIVERINTERNALERROR) {
-           write_log ("IDirect3DTexture9_LockRect failed: %s\n", D3D_ErrorString (hr));
+           write_log (L"IDirect3DTexture9_LockRect failed: %s\n", D3D_ErrorString (hr));
            D3D_unlocktexture ();
            return 0;
        }
     }
     if (locked.pBits == NULL || locked.Pitch == 0) {
-       write_log ("IDirect3DTexture9_LockRect return NULL texture\n");
+       write_log (L"IDirect3DTexture9_LockRect return NULL texture\n");
         D3D_unlocktexture ();
        return 0;
     }
@@ -1385,7 +1385,7 @@ void D3D_guimode (int guion)
        return;
     hr = IDirect3DDevice9_SetDialogBoxMode (d3ddev, guion);
     if (FAILED (hr))
-       write_log ("D3D: SetDialogBoxMode %s\n", D3D_ErrorString (hr));
+       write_log (L"D3D: SetDialogBoxMode %s\n", D3D_ErrorString (hr));
     guimode = guion;
 }
 
@@ -1399,13 +1399,13 @@ HDC D3D_getDC (HDC hdc)
     if (!hdc) {
        hr = IDirect3DDevice9_GetBackBuffer (d3ddev, 0, 0, D3DBACKBUFFER_TYPE_MONO, &bb);
        if (FAILED (hr)) {
-           write_log ("IDirect3DDevice9_GetBackBuffer() failed: %s\n", D3D_ErrorString (hr));
+           write_log (L"IDirect3DDevice9_GetBackBuffer() failed: %s\n", D3D_ErrorString (hr));
            return 0;
        }
        hr = IDirect3DSurface9_GetDC (bb, &hdc);
        if (SUCCEEDED (hr))
            return hdc;
-        write_log ("IDirect3DSurface9_GetDC() failed: %s\n", D3D_ErrorString (hr));
+        write_log (L"IDirect3DSurface9_GetDC() failed: %s\n", D3D_ErrorString (hr));
        return 0;
     }
     IDirect3DSurface9_ReleaseDC (bb, hdc);
index d8233307dbc921e56bef2e6484271dbf54364fda..9601cd92a384e2e5b06565f55c6ebed5cb339e53 100644 (file)
@@ -1,7 +1,7 @@
 
 extern void D3D_resize (int width, int height);
-extern void D3D_free ();
-extern const char *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth);
+extern void D3D_free (void);
+extern const TCHAR *D3D_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth);
 extern void D3D_render (void);
 extern void D3D_getpixelformat (int depth,int *rb, int *bb, int *gb, int *rs, int *bs, int *gs, int *ab, int *ar, int *a);
 extern void D3D_refresh (void);
index 71d5af35d056168abe2f8c3a79832c3bfb423b87..d78b09a2cb8d6039ae19ce0fd785be1e64dec2e8 100644 (file)
@@ -127,7 +127,7 @@ static int driveclick_fdrawcmd_init(int drive)
        return 1;
     thread_ok = 1;
     init_comm_pipe (dc_pipe, DC_PIPE_SIZE, 3);
-    uae_start_thread("fdrawcmd_win32", driveclick_thread, NULL, NULL);
+    uae_start_thread (L"fdrawcmd_win32", driveclick_thread, NULL, NULL);
     return 1;
 }
 
@@ -141,10 +141,10 @@ void driveclick_fdrawcmd_close(int drive)
 
 static int driveclick_fdrawcmd_open_2(int drive)
 {
-    char s[32];
+    TCHAR s[32];
 
     driveclick_fdrawcmd_close(drive);
-    sprintf (s, "\\\\.\\fdraw%d", drive);
+    _stprintf (s, L"\\\\.\\fdraw%d", drive);
     h[drive] = CreateFile(s, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
     if (h[drive] == INVALID_HANDLE_VALUE)
        return 0;
index 207a02ee413786dfcc670535568d8ff27296807f..032597d6398485835a39443eebe092abbd5ae2fb 100644 (file)
@@ -25,7 +25,7 @@ HRESULT DirectDraw_GetDisplayMode (void)
     dxdata.native.dwSize = sizeof (DDSURFACEDESC2);
     ddrval = IDirectDraw7_GetDisplayMode (dxdata.maindd, &dxdata.native);
     if (FAILED (ddrval))
-       write_log ("IDirectDraw7_GetDisplayMode: %s\n", DXError (ddrval));
+       write_log (L"IDirectDraw7_GetDisplayMode: %s\n", DXError (ddrval));
     return ddrval;
 }
 
@@ -85,7 +85,7 @@ HRESULT restoresurface (LPDIRECTDRAWSURFACE7 surf)
        return ddrval;
     ddrval = IDirectDrawSurface7_Restore (surf);
     if (FAILED (ddrval)) {
-       write_log ("IDirectDrawSurface7_Restore: %s\n", DXError (ddrval));
+       write_log (L"IDirectDrawSurface7_Restore: %s\n", DXError (ddrval));
     } else {
        if (surf == dxdata.primary && dxdata.palette)
            IDirectDrawSurface7_SetPalette (dxdata.primary, dxdata.palette);
@@ -144,7 +144,7 @@ int locksurface (LPDIRECTDRAWSURFACE7 surf, LPDDSURFACEDESC2 desc)
            if (FAILED (ddrval))
                return 0;
        } else if (ddrval != DDERR_SURFACEBUSY) {
-           write_log ("locksurface: %s\n", DXError (ddrval));
+           write_log (L"locksurface: %s\n", DXError (ddrval));
            return 0;
        }
     }
@@ -156,7 +156,7 @@ void unlocksurface (LPDIRECTDRAWSURFACE7 surf)
 
     ddrval = IDirectDrawSurface7_Unlock (surf, NULL);
     if (FAILED (ddrval))
-       write_log ("IDirectDrawSurface7_Unlock: %s\n", DXError (ddrval));
+       write_log (L"IDirectDrawSurface7_Unlock: %s\n", DXError (ddrval));
 }
 
 static void setsurfacecap (DDSURFACEDESC2 *desc, int w, int h, int mode)
@@ -177,7 +177,7 @@ STATIC_INLINE uae_u16 rgb32torgb16pc (uae_u32 rgb)
     return (((rgb >> (16 + 3)) & 0x1f) << 11) | (((rgb >> (8 + 2)) & 0x3f) << 5) | (((rgb >> (0 + 3)) & 0x1f) << 0);
 }
 
-static char *alloctexts[] = { "NonLocalVRAM", "DefaultRAM", "VRAM", "RAM" };
+static TCHAR *alloctexts[] = { L"NonLocalVRAM", L"DefaultRAM", L"VRAM", L"RAM" };
 static LPDIRECTDRAWSURFACE7 allocsurface_3 (int width, int height, uae_u8 *ptr, int pitch, int ck, int forcemode)
 {
     HRESULT ddrval;
@@ -211,10 +211,10 @@ static LPDIRECTDRAWSURFACE7 allocsurface_3 (int width, int height, uae_u8 *ptr,
     }
     ddrval = IDirectDraw7_CreateSurface (dxdata.maindd, &desc, &surf, NULL);
     if (FAILED (ddrval)) {
-       write_log ("IDirectDraw7_CreateSurface (%dx%d,%s): %s\n", width, height, alloctexts[forcemode], DXError (ddrval));
+       write_log (L"IDirectDraw7_CreateSurface (%dx%d,%s): %s\n", width, height, alloctexts[forcemode], DXError (ddrval));
     } else {
-       write_log ("Created %dx%dx%d (%p) surface in %s (%d)%s\n", width, height, desc.ddpfPixelFormat.dwRGBBitCount, surf,
-           alloctexts[forcemode], forcemode, ck ? (dxcaps.cancolorkey ? " hardware colorkey" : " software colorkey") : "");
+       write_log (L"Created %dx%dx%d (%p) surface in %s (%d)%s\n", width, height, desc.ddpfPixelFormat.dwRGBBitCount, surf,
+           alloctexts[forcemode], forcemode, ck ? (dxcaps.cancolorkey ? L" hardware colorkey" : L" software colorkey") : L"");
     }
     return surf;
 }
@@ -318,7 +318,7 @@ int dx_testck (void)
     clearsurface (cksurf);
     clearsurface (tmp);
     if (failed) {
-       write_log ("Color key test failure, display driver bug, falling back to software emulation.\n");
+       write_log (L"Color key test failure, display driver bug, falling back to software emulation.\n");
        dxcaps.cancolorkey = 0;
        releaser (dxdata.cursorsurface1, IDirectDrawSurface7_Release);
        dxdata.cursorsurface1 = allocsurface_2 (dxcaps.cursorwidth, dxcaps.cursorheight, TRUE);
@@ -371,7 +371,7 @@ HRESULT DirectDraw_CreateMainSurface (int width, int height)
                ddrval = IDirectDrawSurface7_GetAttachedSurface (dxdata.flipping[0], &ddscaps, &dxdata.flipping[1]);
            }
            if (FAILED (ddrval))
-               write_log ("IDirectDrawSurface7_GetAttachedSurface: %s\n", DXError (ddrval));
+               write_log (L"IDirectDrawSurface7_GetAttachedSurface: %s\n", DXError (ddrval));
        } else {
            desc.dwBackBufferCount = 0;
            desc.ddsCaps.dwCaps = oldcaps;
@@ -401,13 +401,13 @@ HRESULT DirectDraw_CreateMainSurface (int width, int height)
        }
     }
     if (FAILED (ddrval)) {
-        write_log ("IDirectDraw7_CreateSurface: %s\n", DXError (ddrval));
+        write_log (L"IDirectDraw7_CreateSurface: %s\n", DXError (ddrval));
         return ddrval;
     }
     dxdata.native.dwSize = sizeof (DDSURFACEDESC2);
     ddrval = IDirectDrawSurface7_GetSurfaceDesc (dxdata.primary, &dxdata.native);
     if (FAILED (ddrval))
-       write_log ("IDirectDrawSurface7_GetSurfaceDesc: %s\n", DXError (ddrval));
+       write_log (L"IDirectDrawSurface7_GetSurfaceDesc: %s\n", DXError (ddrval));
     if (dxdata.fsmodeset) {
         clearsurf (dxdata.primary, 0);
        dxdata.fsmodeset = 1;
@@ -425,13 +425,13 @@ HRESULT DirectDraw_CreateMainSurface (int width, int height)
            dxdata.pitch = desc.lPitch;
            unlocksurface (surf);
        } else {
-           write_log ("Couldn't get surface pitch!\n");
+           write_log (L"Couldn't get surface pitch!\n");
        }
        createcursorsurface ();
     } else {
        ddrval = DD_FALSE;
     }
-    write_log ("DDRAW: primary surface %p, secondary %p (%dx%dx%d)\n",
+    write_log (L"DDRAW: primary surface %p, secondary %p (%dx%dx%d)\n",
        dxdata.primary, surf, width, height, dxdata.native.ddpfPixelFormat.dwRGBBitCount);
     return ddrval;
 }
@@ -445,7 +445,7 @@ HRESULT DirectDraw_SetDisplayMode (int width, int height, int bits, int freq)
        return DD_OK;
     ddrval = IDirectDraw7_SetDisplayMode (dxdata.maindd, width, height, bits, freq, 0);
     if (FAILED (ddrval)) {
-       write_log ("IDirectDraw7_SetDisplayMode: %s\n", DXError (ddrval));
+       write_log (L"IDirectDraw7_SetDisplayMode: %s\n", DXError (ddrval));
        IDirectDraw7_RestoreDisplayMode (dxdata.maindd);
        dxdata.fsmodeset = 0;
     } else {
@@ -467,11 +467,11 @@ HRESULT DirectDraw_SetCooperativeLevel (HWND window, int fullscreen, int doset)
        ddrval = IDirectDraw7_SetCooperativeLevel (dxdata.maindd, window, fullscreen ?
            DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN : DDSCL_NORMAL);
        if (FAILED (ddrval))
-           write_log ("IDirectDraw7_SetCooperativeLevel: SET %s\n", DXError (ddrval));
+           write_log (L"IDirectDraw7_SetCooperativeLevel: SET %s\n", DXError (ddrval));
     } else {
         ddrval = IDirectDraw7_SetCooperativeLevel (dxdata.maindd, dxdata.hwnd, DDSCL_NORMAL);
        if (FAILED (ddrval))
-           write_log ("IDirectDraw7_SetCooperativeLevel: RESET %s\n", DXError (ddrval));
+           write_log (L"IDirectDraw7_SetCooperativeLevel: RESET %s\n", DXError (ddrval));
     }
     return ddrval;
 }
@@ -482,7 +482,7 @@ HRESULT DirectDraw_CreateClipper (void)
 
     ddrval = IDirectDraw7_CreateClipper (dxdata.maindd, 0, &dxdata.dclip, NULL);
     if (FAILED (ddrval))
-       write_log ("IDirectDraw7_CreateClipper: %s\n", DXError (ddrval));
+       write_log (L"IDirectDraw7_CreateClipper: %s\n", DXError (ddrval));
     return ddrval;
 }
 
@@ -494,32 +494,32 @@ HRESULT DirectDraw_SetClipper (HWND hWnd)
        return DD_FALSE;
     ddrval = IDirectDrawSurface7_SetClipper (dxdata.primary, hWnd ? dxdata.dclip : NULL);
     if (FAILED (ddrval))
-       write_log ("IDirectDrawSurface7_SetClipper: %s\n", DXError (ddrval));
+       write_log (L"IDirectDrawSurface7_SetClipper: %s\n", DXError (ddrval));
     if(hWnd && SUCCEEDED (ddrval)) {
        ddrval = IDirectDrawClipper_SetHWnd (dxdata.dclip, 0, hWnd);
        if (FAILED (ddrval))
-           write_log ("IDirectDrawClipper_SetHWnd: %s\n", DXError (ddrval));
+           write_log (L"IDirectDrawClipper_SetHWnd: %s\n", DXError (ddrval));
     }
     return ddrval;
 }
 
 
-char *outGUID (const GUID *guid)
+TCHAR *outGUID (const GUID *guid)
 {
-    static char gb[64];
+    static TCHAR gb[64];
     if (guid == NULL)
-       return "NULL";
-    sprintf (gb, "%08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X",
+       return L"NULL";
+    _stprintf (gb, L"%08X-%04X-%04X-%02X%02X%02X%02X%02X%02X%02X%02X",
        guid->Data1, guid->Data2, guid->Data3,
        guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
        guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
     return gb;
 }
 
-const char *DXError (HRESULT ddrval)
+const TCHAR *DXError (HRESULT ddrval)
 {
-    static char dderr[1000];
-    sprintf (dderr, "%08X S=%d F=%04X C=%04X (%d) (%s)",
+    static TCHAR dderr[1000];
+    _stprintf (dderr, L"%08X S=%d F=%04X C=%04X (%d) (%s)",
        ddrval, (ddrval & 0x80000000) ? 1 : 0,
        HRESULT_FACILITY(ddrval),
        HRESULT_CODE(ddrval),
@@ -586,7 +586,7 @@ RGBFTYPE DirectDraw_GetSurfacePixelFormat (LPDDSURFACEDESC2 surface)
        break;
 
      default:
-       write_log ("Unknown %d bit format %d %d %d\n", pfp->dwRGBBitCount, r, g, b);
+       write_log (L"Unknown %d bit format %d %d %d\n", pfp->dwRGBBitCount, r, g, b);
        break;
     }
     return RGBFB_NONE;
@@ -599,10 +599,10 @@ HRESULT DirectDraw_EnumDisplayModes (DWORD flags, LPDDENUMMODESCALLBACK2 callbac
     return result;
 }
 
-HRESULT DirectDraw_EnumDisplays (LPDDENUMCALLBACKEX callback)
+HRESULT DirectDraw_EnumDisplays (LPDDENUMCALLBACKEXA callback)
 {
     HRESULT result;
-    result = DirectDrawEnumerateEx (callback, 0, DDENUM_DETACHEDSECONDARYDEVICES | DDENUM_ATTACHEDSECONDARYDEVICES);
+    result = DirectDrawEnumerateExA (callback, 0, DDENUM_DETACHEDSECONDARYDEVICES | DDENUM_ATTACHEDSECONDARYDEVICES);
     return result;
 }
 
@@ -639,7 +639,7 @@ int DirectDraw_SurfaceLock (void)
 void DirectDraw_SurfaceUnlock (void)
 {
     if (dxdata.lockcnt < 0)
-       write_log ("DirectDraw_SurfaceUnlock negative lock count %d!\n", dxdata.lockcnt);
+       write_log (L"DirectDraw_SurfaceUnlock negative lock count %d!\n", dxdata.lockcnt);
     if (dxdata.lockcnt == 0)
        return;
     dxdata.lockcnt--;
@@ -741,7 +741,7 @@ int DirectDraw_BlitToPrimaryScale (RECT *dstrect, RECT *srcrect)
            if (FAILED (ddrval))
                return 0;
        } else if (ddrval != DDERR_SURFACEBUSY) {
-           write_log ("DirectDraw_BlitToPrimary: %s\n", DXError (ddrval));
+           write_log (L"DirectDraw_BlitToPrimary: %s\n", DXError (ddrval));
            break;
        }
     }
@@ -781,7 +781,7 @@ static int DirectDraw_BlitToPrimary2 (RECT *rect, int dooffset)
            if (FAILED (ddrval))
                return 0;
        } else if (ddrval != DDERR_SURFACEBUSY) {
-           write_log ("DirectDraw_BlitToPrimary: %s\n", DXError (ddrval));
+           write_log (L"DirectDraw_BlitToPrimary: %s\n", DXError (ddrval));
            break;
        }
     }
@@ -865,7 +865,7 @@ static int DirectDraw_Blt (LPDIRECTDRAWSURFACE7 dst, RECT *dstrect, LPDIRECTDRAW
            if (FAILED (ddrval))
                return 0;
        } else if (ddrval != DDERR_SURFACEBUSY) {
-           write_log ("DirectDraw_Blit: %s\n", DXError (ddrval));
+           write_log (L"DirectDraw_Blit: %s\n", DXError (ddrval));
            return 0;
        }
     }
@@ -900,7 +900,7 @@ void DirectDraw_FillSurface (LPDIRECTDRAWSURFACE7 dst, RECT *rect, uae_u32 color
            if (FAILED (ddrval))
                break;
        } else if (ddrval != DDERR_SURFACEBUSY) {
-           write_log ("DirectDraw_Fill: %s\n", DXError (ddrval));
+           write_log (L"DirectDraw_Fill: %s\n", DXError (ddrval));
            break;
        }
     }
@@ -958,7 +958,7 @@ static void flip (void)
            recurse--;
        }
     } else if(FAILED (ddrval)) {
-       write_log ("IDirectDrawSurface7_Flip: %s\n", DXError (ddrval));
+       write_log (L"IDirectDrawSurface7_Flip: %s\n", DXError (ddrval));
     }
 }
 
@@ -993,7 +993,7 @@ HRESULT DirectDraw_SetPalette (int remove)
        return DD_FALSE;
     ddrval = IDirectDrawSurface7_SetPalette (dxdata.primary, remove ? NULL : dxdata.palette);
     if (FAILED (ddrval))
-       write_log ("IDirectDrawSurface7_SetPalette: %s\n", DXError (ddrval));
+       write_log (L"IDirectDrawSurface7_SetPalette: %s\n", DXError (ddrval));
     return ddrval;
 }
 HRESULT DirectDraw_CreatePalette (LPPALETTEENTRY pal)
@@ -1001,7 +1001,7 @@ HRESULT DirectDraw_CreatePalette (LPPALETTEENTRY pal)
     HRESULT ddrval;
     ddrval = IDirectDraw_CreatePalette (dxdata.maindd, DDPCAPS_8BIT | DDPCAPS_ALLOW256, pal, &dxdata.palette, NULL);
     if (FAILED (ddrval))
-       write_log ("IDirectDraw_CreatePalette: %s\n", DXError (ddrval));
+       write_log (L"IDirectDraw_CreatePalette: %s\n", DXError (ddrval));
     return ddrval;
 }
 
@@ -1024,50 +1024,50 @@ void DirectDraw_Release (void)
 
 struct dxcap {
     int num;
-    char *name;
+    TCHAR *name;
     DWORD mask;
 };
 static struct dxcap dxcapsinfo[] = 
 {
-    { 1, "DDCAPS_BLT", DDCAPS_BLT },
-    { 1, "DDCAPS_BLTQUEUE", DDCAPS_BLTQUEUE },
-    { 1, "DDCAPS_BLTFOURCC", DDCAPS_BLTFOURCC },
-    { 1, "DDCAPS_BLTCOLORFILL", DDCAPS_BLTSTRETCH },
-    { 1, "DDCAPS_BLTSTRETCH", DDCAPS_BLTSTRETCH },
-    { 1, "DDCAPS_CANBLTSYSMEM", DDCAPS_CANBLTSYSMEM },
-    { 1, "DDCAPS_CANCLIP", DDCAPS_CANCLIP },
-    { 1, "DDCAPS_CANCLIPSTRETCHED", DDCAPS_CANCLIPSTRETCHED },
-    { 1, "DDCAPS_COLORKEY", DDCAPS_COLORKEY },
-    { 1, "DDCAPS_COLORKEYHWASSIST", DDCAPS_COLORKEYHWASSIST },
-    { 1, "DDCAPS_GDI", DDCAPS_GDI },
-    { 1, "DDCAPS_NOHARDWARE", DDCAPS_NOHARDWARE },
-    { 1, "DDCAPS_OVERLAY", DDCAPS_OVERLAY },
-    { 1, "DDCAPS_VBI", DDCAPS_VBI },
-    { 1, "DDCAPS_3D", DDCAPS_3D },
-    { 1, "DDCAPS_BANKSWITCHED", DDCAPS_BANKSWITCHED },
-    { 1, "DDCAPS_PALETTE", DDCAPS_PALETTE },
-    { 1, "DDCAPS_PALETTEVSYNC", DDCAPS_PALETTEVSYNC },
-    { 1, "DDCAPS_READSCANLINE", DDCAPS_READSCANLINE },
-    { 2, "DDCAPS2_CERTIFIED", DDCAPS2_CERTIFIED },
-    { 2, "DDCAPS2_CANRENDERWINDOWED", DDCAPS2_CANRENDERWINDOWED },
-    { 2, "DDCAPS2_NOPAGELOCKREQUIRED", DDCAPS2_NOPAGELOCKREQUIRED },
-    { 2, "DDCAPS2_FLIPNOVSYNC", DDCAPS2_FLIPNOVSYNC },
-    { 2, "DDCAPS2_FLIPINTERVAL", DDCAPS2_FLIPINTERVAL },
-    { 2, "DDCAPS2_NO2DDURING3DSCENE", DDCAPS2_NO2DDURING3DSCENE },
-    { 2, "DDCAPS2_NONLOCALVIDMEM", DDCAPS2_NONLOCALVIDMEM },
-    { 2, "DDCAPS2_NONLOCALVIDMEMCAPS", DDCAPS2_NONLOCALVIDMEMCAPS },
-    { 2, "DDCAPS2_WIDESURFACES", DDCAPS2_WIDESURFACES },
-    { 3, "DDCKEYCAPS_DESTBLT", DDCKEYCAPS_DESTBLT },
-    { 3, "DDCKEYCAPS_DESTBLTCLRSPACE", DDCKEYCAPS_DESTBLTCLRSPACE },
-    { 3, "DDCKEYCAPS_SRCBLT", DDCKEYCAPS_SRCBLT },
-    { 3, "DDCKEYCAPS_SRCBLTCLRSPACE", DDCKEYCAPS_SRCBLTCLRSPACE },
+    { 1, L"DDCAPS_BLT", DDCAPS_BLT },
+    { 1, L"DDCAPS_BLTQUEUE", DDCAPS_BLTQUEUE },
+    { 1, L"DDCAPS_BLTFOURCC", DDCAPS_BLTFOURCC },
+    { 1, L"DDCAPS_BLTCOLORFILL", DDCAPS_BLTSTRETCH },
+    { 1, L"DDCAPS_BLTSTRETCH", DDCAPS_BLTSTRETCH },
+    { 1, L"DDCAPS_CANBLTSYSMEM", DDCAPS_CANBLTSYSMEM },
+    { 1, L"DDCAPS_CANCLIP", DDCAPS_CANCLIP },
+    { 1, L"DDCAPS_CANCLIPSTRETCHED", DDCAPS_CANCLIPSTRETCHED },
+    { 1, L"DDCAPS_COLORKEY", DDCAPS_COLORKEY },
+    { 1, L"DDCAPS_COLORKEYHWASSIST", DDCAPS_COLORKEYHWASSIST },
+    { 1, L"DDCAPS_GDI", DDCAPS_GDI },
+    { 1, L"DDCAPS_NOHARDWARE", DDCAPS_NOHARDWARE },
+    { 1, L"DDCAPS_OVERLAY", DDCAPS_OVERLAY },
+    { 1, L"DDCAPS_VBI", DDCAPS_VBI },
+    { 1, L"DDCAPS_3D", DDCAPS_3D },
+    { 1, L"DDCAPS_BANKSWITCHED", DDCAPS_BANKSWITCHED },
+    { 1, L"DDCAPS_PALETTE", DDCAPS_PALETTE },
+    { 1, L"DDCAPS_PALETTEVSYNC", DDCAPS_PALETTEVSYNC },
+    { 1, L"DDCAPS_READSCANLINE", DDCAPS_READSCANLINE },
+    { 2, L"DDCAPS2_CERTIFIED", DDCAPS2_CERTIFIED },
+    { 2, L"DDCAPS2_CANRENDERWINDOWED", DDCAPS2_CANRENDERWINDOWED },
+    { 2, L"DDCAPS2_NOPAGELOCKREQUIRED", DDCAPS2_NOPAGELOCKREQUIRED },
+    { 2, L"DDCAPS2_FLIPNOVSYNC", DDCAPS2_FLIPNOVSYNC },
+    { 2, L"DDCAPS2_FLIPINTERVAL", DDCAPS2_FLIPINTERVAL },
+    { 2, L"DDCAPS2_NO2DDURING3DSCENE", DDCAPS2_NO2DDURING3DSCENE },
+    { 2, L"DDCAPS2_NONLOCALVIDMEM", DDCAPS2_NONLOCALVIDMEM },
+    { 2, L"DDCAPS2_NONLOCALVIDMEMCAPS", DDCAPS2_NONLOCALVIDMEMCAPS },
+    { 2, L"DDCAPS2_WIDESURFACES", DDCAPS2_WIDESURFACES },
+    { 3, L"DDCKEYCAPS_DESTBLT", DDCKEYCAPS_DESTBLT },
+    { 3, L"DDCKEYCAPS_DESTBLTCLRSPACE", DDCKEYCAPS_DESTBLTCLRSPACE },
+    { 3, L"DDCKEYCAPS_SRCBLT", DDCKEYCAPS_SRCBLT },
+    { 3, L"DDCKEYCAPS_SRCBLTCLRSPACE", DDCKEYCAPS_SRCBLTCLRSPACE },
     { 0, NULL }
 };
 
 static void showcaps (DDCAPS_DX7 *dc)
 {
     int i, out;
-    write_log ("%08x %08x %08x %08x %08x %08x\n",
+    write_log (L"%08x %08x %08x %08x %08x %08x\n",
        dc->dwCaps, dc->dwCaps2, dc->dwCKeyCaps, dc->dwFXCaps, dc->dwFXAlphaCaps, dc->dwPalCaps, dc->ddsCaps);
     out = 0;
     for (i = 0;  dxcapsinfo[i].name; i++) {
@@ -1086,13 +1086,13 @@ static void showcaps (DDCAPS_DX7 *dc)
        }
        if (caps & dxcapsinfo[i].mask) {
            if (out > 0)
-               write_log (",");
-           write_log ("%s", dxcapsinfo[i].name);
+               write_log (L",");
+           write_log (L"%s", dxcapsinfo[i].name);
            out++;
        }
     }
     if (out > 0)
-       write_log ("\n");
+       write_log (L"\n");
     if ((dc->dwCaps & DDCAPS_COLORKEY) && (dc->dwCKeyCaps & DDCKEYCAPS_SRCBLT))
        dxcaps.cancolorkey = TRUE;
     if (dc->dwCaps2 & DDCAPS2_NONLOCALVIDMEM)
@@ -1113,12 +1113,12 @@ static void getcaps (void)
     hc.dwSize = sizeof hc;
     hr = IDirectDraw7_GetCaps (dxdata.maindd, &dc, &hc);
     if (FAILED (hr)) {
-       write_log ("IDirectDraw7_GetCaps() failed %s\n", DXError (hr));
+       write_log (L"IDirectDraw7_GetCaps() failed %s\n", DXError (hr));
        return;
     }
-    write_log ("DriverCaps: ");
+    write_log (L"DriverCaps: ");
     showcaps (&dc);
-    write_log ("HELCaps   : ");
+    write_log (L"HELCaps   : ");
     showcaps (&hc);
 }
 
@@ -1143,7 +1143,7 @@ int DirectDraw_Start (GUID *guid)
     LPDIRECTDRAW dd;
     ddrval = DirectDrawCreate (guid, &dd, NULL);
     if (FAILED (ddrval)) {
-       write_log ("DirectDrawCreate() failed, %s\n", DXError (ddrval));
+       write_log (L"DirectDrawCreate() failed, %s\n", DXError (ddrval));
        if (guid != NULL)
            return 0;
        goto oops;
@@ -1151,13 +1151,13 @@ int DirectDraw_Start (GUID *guid)
     ddrval = IDirectDraw_QueryInterface (dd, &IID_IDirectDraw7, &dxdata.maindd);
     IDirectDraw_Release (dd);
     if (FAILED (ddrval)) {
-       write_log ("IDirectDraw_QueryInterface() failed, %s\n", DXError (ddrval));
+       write_log (L"IDirectDraw_QueryInterface() failed, %s\n", DXError (ddrval));
        goto oops;
     }
 #else
     ddrval = DirectDrawCreateEx (guid, &dxdata.maindd, &IID_IDirectDraw7, NULL);
     if (FAILED (ddrval)) {
-       write_log ("DirectDrawCreateEx() failed, %s\n", DXError (ddrval));
+       write_log (L"DirectDrawCreateEx() failed, %s\n", DXError (ddrval));
        if (guid != NULL)
            return 0;
        goto oops;
@@ -1169,14 +1169,14 @@ int DirectDraw_Start (GUID *guid)
     dxcaps.cursorwidth = 48;
     dxcaps.cursorheight = 48;
     if (!d3ddone) {
-       d3dDLL = LoadLibrary ("D3D9.DLL");
+       d3dDLL = LoadLibrary (L"D3D9.DLL");
        if (d3dDLL) {
            d3d = Direct3DCreate9 (D3D9b_SDK_VERSION);
            if (d3d) {
                if (SUCCEEDED (IDirect3D9_GetDeviceCaps (d3d, 0, D3DDEVTYPE_HAL, &d3dCaps))) {
                    dxcaps.maxwidth = d3dCaps.MaxTextureWidth;
                    dxcaps.maxheight = d3dCaps.MaxTextureHeight;
-                   write_log ("Max hardware surface size: %dx%d\n", dxcaps.maxwidth, dxcaps.maxheight);
+                   write_log (L"Max hardware surface size: %dx%d\n", dxcaps.maxwidth, dxcaps.maxheight);
                }
                IDirect3D9_Release (d3d);
            }
@@ -1204,7 +1204,7 @@ int DirectDraw_Start (GUID *guid)
        return 1;
     }
   oops:
-    write_log ("DirectDraw_Start: %s\n", DXError (ddrval));
+    write_log (L"DirectDraw_Start: %s\n", DXError (ddrval));
     DirectDraw_Release ();
     return 0;
 }
index 0ebe161400779fd1cd7995fda2715279ed289b9d..6ae88172b8a229db2045aa89a1b768be10deeca3 100644 (file)
@@ -59,7 +59,7 @@ struct PicassoResolution
     int depth;   /* depth in bytes-per-pixel */
     int residx;
     int refresh[MAX_REFRESH_RATES]; /* refresh-rates in Hz */
-    char name[25];
+    TCHAR name[25];
     /* Bit mask of RGBFF_xxx values.  */
     uae_u32 colormodes;
 };
@@ -69,8 +69,8 @@ extern GUID *displayGUID;
 struct MultiDisplay {
     int primary, disabled, gdi;
     GUID guid;
-    char *name;
-    char *name2;
+    TCHAR *name;
+    TCHAR *name2;
     struct PicassoResolution *DisplayModes;
     RECT rect;
 };
@@ -83,8 +83,8 @@ typedef enum
     blue_mask
 } DirectDraw_Mask_e;
 
-extern const char *DXError (HRESULT hr);
-extern char *outGUID (const GUID *guid);
+extern const TCHAR *DXError (HRESULT hr);
+extern TCHAR *outGUID (const GUID *guid);
 
 HRESULT DirectDraw_GetDisplayMode (void);
 void DirectDraw_Release(void);
@@ -105,7 +105,7 @@ HRESULT DirectDraw_CreateClipper (void);
 HRESULT DirectDraw_SetClipper(HWND hWnd);
 RGBFTYPE DirectDraw_GetSurfacePixelFormat(LPDDSURFACEDESC2 surface);
 HRESULT DirectDraw_EnumDisplayModes(DWORD flags, LPDDENUMMODESCALLBACK2 callback, void *context);
-HRESULT DirectDraw_EnumDisplays(LPDDENUMCALLBACKEX callback);
+HRESULT DirectDraw_EnumDisplays(LPDDENUMCALLBACKEXA callback);
 DWORD DirectDraw_CurrentWidth (void);
 DWORD DirectDraw_CurrentHeight (void);
 DWORD DirectDraw_GetCurrentDepth (void);
index 893424df01804c763c3e510090f0a16df1529b4d..debde65c1782e81eed69641d3fb6ca85f88e4eb8 100644 (file)
@@ -29,11 +29,12 @@ static int fsdb_debug = 0;
 
 /* these are deadly (but I think allowed on the Amiga): */
 #define NUM_EVILCHARS 7
-static char evilchars[NUM_EVILCHARS] = { '\\', '*', '?', '\"', '<', '>', '|' };
+static TCHAR evilchars[NUM_EVILCHARS] = { '\\', '*', '?', '\"', '<', '>', '|' };
 
-#define UAEFSDB_BEGINS "__uae___"
-#define UAEFSDB_BEGINSX "__uae___*"
+#define UAEFSDB_BEGINS L"__uae___"
+#define UAEFSDB_BEGINSX L"__uae___*"
 #define UAEFSDB_LEN 604
+#define UAEFSDB2_LEN 1632
 
 /* The on-disk format is as follows:
  * Offset 0, 1 byte, valid
@@ -42,30 +43,36 @@ static char evilchars[NUM_EVILCHARS] = { '\\', '*', '?', '\"', '<', '>', '|' };
  * Offset 262, 257 bytes, nname
  * Offset 519, 81 bytes, comment
  * Offset 600, 4 bytes, Windows-side mode
+ *
+ * 1.6.0+ Unicode data
+ * 
+ * Offset  604, 257 * 2 bytes, aname
+ * Offset 1118, 257 * 2 bytes, nname
+ *        1632
  */
 
-static char *make_uaefsdbpath (const char *dir, const char *name)
+static TCHAR *make_uaefsdbpath (const TCHAR *dir, const TCHAR *name)
 {
     int len;
-    char *p;
+    TCHAR *p;
 
-    len = strlen (dir) + 1 + 1;
+    len = _tcslen (dir) + 1 + 1;
     if (name)
-       len += 1 + strlen (name);
-    len += 1 + strlen (FSDB_FILE);
-    p = xmalloc (len);
+       len += 1 + _tcslen (name);
+    len += 1 + _tcslen (FSDB_FILE);
+    p = xmalloc (len * sizeof (TCHAR));
     if (!p)
        return NULL;
     if (name)
-       sprintf (p, "%s\\%s:%s", dir, name, FSDB_FILE);
+       _stprintf (p, L"%s\\%s:%s", dir, name, FSDB_FILE);
     else
-       sprintf (p, "%s:%s", dir, FSDB_FILE);
+       _stprintf (p, L"%s:%s", dir, FSDB_FILE);
     return p;
 }
 
-static int read_uaefsdb (const char *dir, const char *name, uae_u8 *fsdb)
+static int read_uaefsdb (const TCHAR *dir, const TCHAR *name, uae_u8 *fsdb)
 {
-    char *p;
+    TCHAR *p;
     HANDLE h;
     DWORD read;
 
@@ -74,41 +81,50 @@ static int read_uaefsdb (const char *dir, const char *name, uae_u8 *fsdb)
     h = CreateFile (p, GENERIC_READ, 0,
        NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
     if (fsdb_debug)
-       write_log ("read_uaefsdb '%s' = %x\n", p, h);
+       write_log (L"read_uaefsdb '%s' = %x\n", p, h);
     xfree (p);
     if (h != INVALID_HANDLE_VALUE) {
-       ReadFile (h, fsdb, UAEFSDB_LEN, &read, NULL);
+       memset (fsdb, 0, UAEFSDB2_LEN);
+       ReadFile (h, fsdb, UAEFSDB2_LEN, &read, NULL);
        CloseHandle (h);
-       if (read == UAEFSDB_LEN) {
+       if (read == UAEFSDB_LEN || read == UAEFSDB2_LEN) {
            if (fsdb_debug) {
-               write_log ("->ok\n");
-               write_log ("v=%02x flags=%08x an='%s' nn='%s' c='%s'\n", fsdb[0], ((uae_u32*)(fsdb+1))[0], fsdb + 5, fsdb + 262, fsdb + 519);
+               TCHAR *an, *nn, *co;
+               write_log (L"->ok\n");
+               an = aucp (fsdb + 5, currprefs.win32_fscodepage);
+               nn = aucp (fsdb + 262, currprefs.win32_fscodepage);
+               co = aucp (fsdb + 519, currprefs.win32_fscodepage);
+               write_log (L"v=%02x flags=%08x an='%s' nn='%s' c='%s'\n",
+                   fsdb[0], ((uae_u32*)(fsdb+1))[0], an, nn, co);
+               xfree (co);
+               xfree (nn);
+               xfree (an);
            }
            return 1;
        }
     }
     if (fsdb_debug)
-       write_log ("->fail %d, %d\n", read, GetLastError ());
-    memset (fsdb, 0, UAEFSDB_LEN);
+       write_log (L"->fail %d, %d\n", read, GetLastError ());
+    memset (fsdb, 0, UAEFSDB2_LEN);
     return 0;
 }
 
-static int delete_uaefsdb (const char *dir)
+static int delete_uaefsdb (const TCHAR *dir)
 {
-    char *p;
+    TCHAR *p;
     int ret;
 
     p = make_uaefsdbpath (dir, NULL);
-    ret = DeleteFile(p);
+    ret = DeleteFile (p);
     if (fsdb_debug)
-       write_log ("delete_uaefsdb '%s' = %d\n", p, ret);
+       write_log (L"delete_uaefsdb '%s' = %d\n", p, ret);
     xfree (p);
     return ret;
 }
 
-static int write_uaefsdb (const char *dir, uae_u8 *fsdb)
+static int write_uaefsdb (const TCHAR *dir, uae_u8 *fsdb)
 {
-    char *p;
+    TCHAR *p;
     HANDLE h;
     DWORD written = 0, dirflag, dirattr;
     DWORD attr = INVALID_FILE_ATTRIBUTES;
@@ -131,8 +147,16 @@ static int write_uaefsdb (const char *dir, uae_u8 *fsdb)
     h = CreateFile (p, GENERIC_WRITE, 0,
        NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
     if (fsdb_debug) {
-       write_log ("write_uaefsdb '%s' = %x\n", p, h);
-       write_log ("v=%02x flags=%08x an='%s' nn='%s' c='%s'\n", fsdb[0], ((uae_u32*)(fsdb+1))[0], fsdb + 5, fsdb + 262, fsdb + 519);
+       TCHAR *an, *nn, *co;
+       an = aucp (fsdb + 5, currprefs.win32_fscodepage);
+       nn = aucp (fsdb + 262, currprefs.win32_fscodepage);
+       co = aucp (fsdb + 519, currprefs.win32_fscodepage);
+       write_log (L"write_uaefsdb '%s' = %x\n", p, h);
+       write_log (L"v=%02x flags=%08x an='%s' nn='%s' c='%s'\n",
+           fsdb[0], ((uae_u32*)(fsdb+1))[0], an, nn, co);
+       xfree (co);
+       xfree (nn);
+       xfree (an);
     }
     if (h == INVALID_HANDLE_VALUE && GetLastError () == ERROR_ACCESS_DENIED) {
        attr = GetFileAttributes (p);
@@ -142,22 +166,22 @@ static int write_uaefsdb (const char *dir, uae_u8 *fsdb)
                h = CreateFile (p, GENERIC_WRITE, 0,
                    NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
                if (fsdb_debug)
-                   write_log ("write_uaefsdb (2) '%s' = %x\n", p, h);
+                   write_log (L"write_uaefsdb (2) '%s' = %x\n", p, h);
            }
        }
     }
     if (h != INVALID_HANDLE_VALUE) {
-       WriteFile (h, fsdb, UAEFSDB_LEN, &written, NULL);
+       WriteFile (h, fsdb, UAEFSDB2_LEN, &written, NULL);
        CloseHandle (h);
-       if (written == UAEFSDB_LEN) {
+       if (written == UAEFSDB2_LEN) {
            if (fsdb_debug)
-               write_log ("->ok\n");
+               write_log (L"->ok\n");
            ret = 1;
            goto end;
        }
     }
     if (fsdb_debug)
-       write_log ("->fail %d, %d\n", written, GetLastError ());
+       write_log (L"->fail %d, %d\n", written, GetLastError ());
 
     DeleteFile (p);
 end:
@@ -177,15 +201,26 @@ end:
 
 static void create_uaefsdb (a_inode *aino, uae_u8 *buf, int winmode)
 {
+    TCHAR *nn;
+    char *s;
     buf[0] = 1;
     do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode);
-    strncpy (buf + 5, aino->aname, 256);
+    s = uacp (aino->nname, currprefs.win32_fscodepage);
+    strncpy (buf + 5, s, 256);
     buf[5 + 256] = '\0';
-    strncpy (buf + 5 + 257, nname_begin (aino->nname), 256);
+    xfree (s);
+    nn = nname_begin (aino->nname);
+    s = uacp (nn, currprefs.win32_fscodepage);
+    strncpy (buf + 5 + 257, s, 256);
     buf[5 + 257 + 256] = '\0';
-    strncpy (buf + 5 + 2 * 257, aino->comment ? aino->comment : "", 80);
+    xfree (s);
+    s = uacp (aino->comment ? aino->comment : L"", currprefs.win32_fscodepage);
+    strncpy (buf + 5 + 2 * 257, s, 80);
     buf[5 + 2 * 257 + 80] = '\0';
+    xfree (s);
     do_put_mem_long ((uae_u32 *)(buf + 5 + 2 * 257 + 81), winmode);
+    _tcsncpy ((TCHAR*)(buf + 604), aino->nname, 256);
+    _tcsncpy ((TCHAR*)(buf + 1118), nn, 256);
     aino->has_dbentry = 0;
     aino->dirty = 0;
 }
@@ -193,25 +228,40 @@ static void create_uaefsdb (a_inode *aino, uae_u8 *buf, int winmode)
 static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, int *winmode)
 {
     uae_u32 mode;
-    a_inode *aino = (a_inode *) xcalloc (sizeof (a_inode), 1);
+    a_inode *aino = xcalloc (sizeof (a_inode), 1);
+    uae_u8 *buf2;
+    TCHAR *s;
 
+    buf2 = buf + 604;
     mode = do_get_mem_long ((uae_u32 *)(buf + 1));
     buf += 5;
-    aino->aname = my_strdup (buf);
+    if (buf2[0]) {
+       aino->aname = my_strdup ((TCHAR*)buf2);
+    } else {
+       aino->aname = aucp (buf, currprefs.win32_fscodepage);
+    }
     buf += 257;
-    aino->nname = build_nname (base->nname, buf);
+    buf2 += 257 * 2;
+    if (buf2[0]) {
+       aino->nname = build_nname (base->nname, (TCHAR*)buf2);
+    } else {
+       s = aucp (buf, currprefs.win32_fscodepage);
+       aino->nname = build_nname (base->nname, s);
+       xfree (s);
+    }
     buf += 257;
-    aino->comment = *buf != '\0' ? my_strdup (buf) : 0;
+    aino->comment = *buf != '\0' ? my_strdup_ansi (buf) : 0;
     buf += 81;
     aino->amigaos_mode = mode;
     *winmode = do_get_mem_long ((uae_u32 *)buf);
+    aino->dir = ((*winmode) & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0;
     *winmode &= FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
     aino->has_dbentry = 0;
     aino->dirty = 0;
     aino->db_offset = 0;
-    if((mode = GetFileAttributes(aino->nname)) == INVALID_FILE_ATTRIBUTES) {
-       write_log ("xGetFileAttributes('%s') failed! error=%d, aino=%p\n",
-           aino->nname, GetLastError(), aino);
+    if((mode = GetFileAttributes (aino->nname)) == INVALID_FILE_ATTRIBUTES) {
+       write_log (L"xGetFileAttributes('%s') failed! error=%d, aino=%p\n",
+           aino->nname, GetLastError (), aino);
        return aino;
     }
     aino->dir = (mode & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0;
@@ -219,14 +269,14 @@ static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, int *winmode)
 }
 
 /* Return nonzero for any name we can't create on the native filesystem.  */
-int fsdb_name_invalid (const char *n)
+int fsdb_name_invalid (const TCHAR *n)
 {
     int i;
-    char a = n[0];
-    char b = (a == '\0' ? a : n[1]);
-    char c = (b == '\0' ? b : n[2]);
-    char d = (c == '\0' ? c : n[3]);
-    int l = strlen (n), ll;
+    TCHAR a = n[0];
+    TCHAR b = (a == '\0' ? a : n[1]);
+    TCHAR c = (b == '\0' ? b : n[2]);
+    TCHAR d = (c == '\0' ? c : n[3]);
+    int l = _tcslen (n), ll;
 
     if (a >= 'a' && a <= 'z')
        a -= 32;
@@ -254,12 +304,12 @@ int fsdb_name_invalid (const char *n)
 
     /* these characters are *never* allowed */
     for (i = 0; i < NUM_EVILCHARS; i++) {
-       if (strchr (n, evilchars[i]) != 0)
+       if (_tcschr (n, evilchars[i]) != 0)
            return 1;
     }
 
     /* the reserved fsdb filename */
-    if (strcmp (n, FSDB_FILE) == 0)
+    if (_tcscmp (n, FSDB_FILE) == 0)
        return 1;
     return 0; /* the filename passed all checks, now it should be ok */
 }
@@ -269,7 +319,7 @@ uae_u32 filesys_parse_mask(uae_u32 mask)
     return mask ^ 0xf;
 }
 
-int fsdb_exists (char *nname)
+int fsdb_exists (TCHAR *nname)
 {
     if (GetFileAttributes(nname) == INVALID_FILE_ATTRIBUTES)
        return 0;
@@ -281,11 +331,11 @@ int fsdb_exists (char *nname)
 int fsdb_fill_file_attrs (a_inode *base, a_inode *aino)
 {
     int mode, winmode, oldamode;
-    uae_u8 fsdb[UAEFSDB_LEN];
+    uae_u8 fsdb[UAEFSDB2_LEN];
     int reset = 0;
 
     if((mode = GetFileAttributes(aino->nname)) == INVALID_FILE_ATTRIBUTES) {
-       write_log ("GetFileAttributes('%s') failed! error=%d, aino=%p dir=%d\n",
+       write_log (L"GetFileAttributes('%s') failed! error=%d, aino=%p dir=%d\n",
            aino->nname, GetLastError(), aino, aino->dir);
        return 0;
     }
@@ -297,11 +347,11 @@ int fsdb_fill_file_attrs (a_inode *base, a_inode *aino)
        xfree (aino->comment);
        aino->comment = NULL;
        if (fsdb[5 + 2 * 257])
-           aino->comment = my_strdup (fsdb + 5 + 2 * 257);
+           aino->comment = my_strdup_ansi (fsdb + 5 + 2 * 257);
        xfree (aino_from_buf (base, fsdb, &winmode));
        if (winmode == mode) /* no Windows-side editing? */
            return 1;
-       write_log ("FS: '%s' protection flags edited from Windows-side\n", aino->nname);
+       write_log (L"FS: '%s' protection flags edited from Windows-side\n", aino->nname);
        reset = 1;
        /* edited from Windows-side -> use Windows side flags instead */
     }
@@ -327,7 +377,7 @@ int fsdb_fill_file_attrs (a_inode *base, a_inode *aino)
 
 static int needs_fsdb (a_inode *aino)
 {
-    const char *nn_begin;
+    const TCHAR *nn_begin;
 
     if (aino->deleted)
        return 0;
@@ -336,13 +386,13 @@ static int needs_fsdb (a_inode *aino)
        return 1;
 
     nn_begin = nname_begin (aino->nname);
-    return strcmp (nn_begin, aino->aname) != 0;
+    return _tcscmp (nn_begin, aino->aname) != 0;
 }
 
 int fsdb_set_file_attrs (a_inode *aino)
 {
     uae_u32 tmpmask;
-    uae_u8 fsdb[UAEFSDB_LEN];
+    uae_u8 fsdb[UAEFSDB2_LEN];
     uae_u32 mode;
 
     tmpmask = filesys_parse_mask (aino->amigaos_mode);
@@ -417,28 +467,28 @@ int fsdb_mode_representable_p (const a_inode *aino, int amigaos_mode)
     return 0;
 }
 
-char *fsdb_create_unique_nname (a_inode *base, const char *suggestion)
+TCHAR *fsdb_create_unique_nname (a_inode *base, const TCHAR *suggestion)
 {
-    char *c;
-    char tmp[256] = UAEFSDB_BEGINS;
+    TCHAR *c;
+    TCHAR tmp[256] = UAEFSDB_BEGINS;
     int i;
 
-    strncat (tmp, suggestion, 240);
+    _tcsncat (tmp, suggestion, 240);
 
     /* replace the evil ones... */
-    for (i=0; i < NUM_EVILCHARS; i++)
-       while ((c = strchr (tmp, evilchars[i])) != 0)
+    for (i = 0; i < NUM_EVILCHARS; i++)
+       while ((c = _tcschr (tmp, evilchars[i])) != 0)
            *c = '_';
 
-    while ((c = strchr (tmp, '.')) != 0)
+    while ((c = _tcschr (tmp, '.')) != 0)
        *c = '_';
-    while ((c = strchr (tmp, ' ')) != 0)
+    while ((c = _tcschr (tmp, ' ')) != 0)
        *c = '_';
 
     for (;;) {
-       char *p = build_nname (base->nname, tmp);
+       TCHAR *p = build_nname (base->nname, tmp);
        if (!fsdb_exists (p)) {
-           write_log ("unique name: %s\n", p);
+           write_log (L"unique name: %s\n", p);
            return p;
        }
        xfree (p);
@@ -450,16 +500,16 @@ char *fsdb_create_unique_nname (a_inode *base, const char *suggestion)
     }
 }
 
-char *fsdb_search_dir (const char *dirname, char *rel)
+TCHAR *fsdb_search_dir (const TCHAR *dirname, TCHAR *rel)
 {
     WIN32_FIND_DATA fd;
     HANDLE h;
-    char *tmp, *p = 0;
+    TCHAR *tmp, *p = 0;
 
     tmp = build_nname (dirname, rel);
     h = FindFirstFile (tmp, &fd);
     if (h != INVALID_HANDLE_VALUE) {
-       if (strcmp (fd.cFileName, rel) == 0)
+       if (_tcscmp (fd.cFileName, rel) == 0)
            p = rel;
        else
            p = my_strdup (fd.cFileName);
@@ -469,25 +519,28 @@ char *fsdb_search_dir (const char *dirname, char *rel)
     return p;
 }
 
-static a_inode *custom_fsdb_lookup_aino (a_inode *base, const char *aname, int offset, int dontcreate)
+static a_inode *custom_fsdb_lookup_aino (a_inode *base, const TCHAR *aname, int offset, int dontcreate)
 {
-    uae_u8 fsdb[UAEFSDB_LEN];
-    char *tmp1;
+    uae_u8 fsdb[UAEFSDB2_LEN];
+    TCHAR *tmp1;
     HANDLE h;
     WIN32_FIND_DATA fd;
     static a_inode dummy;
+    TCHAR *s;
 
     tmp1 = build_nname (base->nname, UAEFSDB_BEGINSX);
     if (!tmp1)
        return NULL;
+    s = au (fsdb + offset);
     h = FindFirstFile (tmp1, &fd);
     if (h != INVALID_HANDLE_VALUE) {
        do {
            if (read_uaefsdb (base->nname, fd.cFileName, fsdb)) {
-               if (same_aname (fsdb + offset, aname)) {
+               if (same_aname (s, aname)) {
                    int winmode;
                    FindClose (h);
                    xfree (tmp1);
+                   xfree (s);
                    if (dontcreate)
                        return &dummy;
                    return aino_from_buf (base, fsdb, &winmode);
@@ -496,32 +549,33 @@ static a_inode *custom_fsdb_lookup_aino (a_inode *base, const char *aname, int o
        } while (FindNextFile (h, &fd));
        FindClose (h);
     }
+    xfree (s);
     xfree (tmp1);
     return NULL;
 }
 
-a_inode *custom_fsdb_lookup_aino_aname (a_inode *base, const char *aname)
+a_inode *custom_fsdb_lookup_aino_aname (a_inode *base, const TCHAR *aname)
 {
     return custom_fsdb_lookup_aino (base, aname, 5, 0);
 }
-a_inode *custom_fsdb_lookup_aino_nname (a_inode *base, const char *nname)
+a_inode *custom_fsdb_lookup_aino_nname (a_inode *base, const TCHAR *nname)
 {
     return custom_fsdb_lookup_aino (base, nname, 5 + 257, 0);
 }
 
-int custom_fsdb_used_as_nname (a_inode *base, const char *nname)
+int custom_fsdb_used_as_nname (a_inode *base, const TCHAR *nname)
 {
     if (custom_fsdb_lookup_aino (base, nname, 5 + 257, 1))
        return 1;
     return 0;
 }
 
-int my_mkdir (const char *name)
+int my_mkdir (const TCHAR *name)
 {
     return CreateDirectory (name, NULL) == 0 ? -1 : 0;
 }
 
-static int recycle (const char *name)
+static int recycle (const TCHAR *name)
 {
     if (currprefs.win32_norecyclebin) {
        DWORD dirattr = GetFileAttributes (name);
@@ -531,10 +585,10 @@ static int recycle (const char *name)
     } else {
        SHFILEOPSTRUCT fos;
        /* name must be terminated by \0\0 */
-       char *p = xcalloc (strlen (name) + 2, 1);
+       TCHAR *p = xcalloc ((_tcslen (name) + 2) * sizeof (TCHAR), 1);
        int v;
 
-       strcpy (p, name);
+       _tcscpy (p, name);
        memset (&fos, 0, sizeof (fos));
        fos.wFunc = FO_DELETE;
        fos.pFrom = p;
@@ -559,11 +613,11 @@ static int recycle (const char *name)
     }
 }
 
-int my_rmdir (const char *name)
+int my_rmdir (const TCHAR *name)
 {
     void *od;
     int cnt;
-    char tname[MAX_DPATH];
+    TCHAR tname[MAX_DPATH];
 
     /* SHFileOperation() ignores FOF_NORECURSION when deleting directories.. */
     od = my_opendir (name);
@@ -573,7 +627,7 @@ int my_rmdir (const char *name)
     }
     cnt = 0;
     while (my_readdir (od, tname)) {
-       if (!strcmp (tname, ".") || !strcmp (tname, ".."))
+       if (!_tcscmp (tname, L".") || !_tcscmp (tname, L".."))
            continue;
        cnt++;
        break;
@@ -588,12 +642,12 @@ int my_rmdir (const char *name)
 }
 
 /* "move to Recycle Bin" (if enabled) -version of DeleteFile() */
-int my_unlink (const char *name)
+int my_unlink (const TCHAR *name)
 {
     return recycle (name);
 }
 
-int my_rename (const char *oldname, const char *newname)
+int my_rename (const TCHAR *oldname, const TCHAR *newname)
 {
     return MoveFile (oldname, newname) == 0 ? -1 : 0;
 }
@@ -604,13 +658,13 @@ struct my_opendirs {
     int first;
 };
 
-void *my_opendir (const char *name)
+void *my_opendir (const TCHAR *name)
 {
     struct my_opendirs *mod;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
-    strcpy (tmp, name);
-    strcat (tmp, "\\*.*");
+    _tcscpy (tmp, name);
+    _tcscat (tmp, L"\\*.*");
     mod = xmalloc (sizeof (struct my_opendirs));
     if (!mod)
        return NULL;
@@ -631,17 +685,17 @@ void my_closedir (void *d)
     xfree (mod);
 }
 
-int my_readdir (void *d, char *name)
+int my_readdir (void *d, TCHAR *name)
 {
     struct my_opendirs *mod = d;
     if (mod->first) {
-       strcpy (name, mod->fd.cFileName);
+       _tcscpy (name, mod->fd.cFileName);
        mod->first = 0;
        return 1;
     }
     if (!FindNextFile (mod->h, &mod->fd))
        return 0;
-    strcpy (name, mod->fd.cFileName);
+    _tcscpy (name, mod->fd.cFileName);
     return 1;
 }
 
@@ -656,11 +710,17 @@ void my_close (void *d)
     xfree (mos);
 }
 
-unsigned int my_lseek (void *d, unsigned int offset, int whence)
+uae_s64 int my_lseek (void *d, uae_s64 int offset, int whence)
 {
     struct my_opens *mos = d;
-    return SetFilePointer (mos->h, offset, NULL,
+    LARGE_INTEGER li;
+
+    li.QuadPart = offset;
+    li.LowPart = SetFilePointer (mos->h, li.LowPart, &li.HighPart,
        whence == SEEK_SET ? FILE_BEGIN : (whence == SEEK_END ? FILE_END : FILE_CURRENT));
+    if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR)
+       li.QuadPart = -1;
+    return li.QuadPart;
 }
 
 unsigned int my_read (void *d, void *b, unsigned int size)
@@ -679,7 +739,7 @@ unsigned int my_write (void *d, void *b, unsigned int size)
     return written;
 }
 
-static DWORD GetFileAttributesSafe(const char *name)
+static DWORD GetFileAttributesSafe(const TCHAR *name)
 {
     DWORD attr, last;
 
@@ -689,7 +749,7 @@ static DWORD GetFileAttributesSafe(const char *name)
     return attr;
 }
 
-int my_existsfile (const char *name)
+int my_existsfile (const TCHAR *name)
 {
     DWORD attr = GetFileAttributesSafe (name);
     if (attr == INVALID_FILE_ATTRIBUTES)
@@ -699,7 +759,7 @@ int my_existsfile (const char *name)
     return 0;
 }
 
-int my_existsdir (const char *name)
+int my_existsdir (const TCHAR *name)
 {
     DWORD attr = GetFileAttributesSafe (name);
     if (attr == INVALID_FILE_ATTRIBUTES)
@@ -709,7 +769,7 @@ int my_existsdir (const char *name)
     return 0;
 }
 
-void *my_open (const char *name, int flags)
+void *my_open (const TCHAR *name, int flags)
 {
     struct my_opens *mos;
     HANDLE h;
@@ -748,7 +808,7 @@ void *my_open (const char *name, int flags)
                err = GetLastError();
        }
        if (h == INVALID_HANDLE_VALUE) {
-           write_log ("failed to open '%s' %x %x err=%d\n", name, DesiredAccess, CreationDisposition, err);
+           write_log (L"failed to open '%s' %x %x err=%d\n", name, DesiredAccess, CreationDisposition, err);
            xfree (mos);
            mos = NULL;
            goto err;
@@ -756,11 +816,11 @@ void *my_open (const char *name, int flags)
     }
     mos->h = h;
 err:
-    //write_log ("open '%s' = %x\n", name, mos ? mos->h : 0);
+    //write_log (L"open '%s' = %x\n", name, mos ? mos->h : 0);
     return mos;
 }
 
-int my_truncate (const char *name, long int len)
+int my_truncate (const TCHAR *name, uae_u64 len)
 {
     HANDLE hFile;
     BOOL bResult = FALSE;
@@ -769,15 +829,18 @@ int my_truncate (const char *name, long int len)
     if ((hFile = CreateFile (name, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ) ) != INVALID_HANDLE_VALUE )
     {
-       if (SetFilePointer (hFile, len, NULL, FILE_BEGIN) == (DWORD)len) {
+       LARGE_INTEGER li;
+       li.QuadPart = len;
+       li.LowPart = SetFilePointer (hFile, li.LowPart, &li.HighPart, FILE_BEGIN);
+       if (li.LowPart == INVALID_SET_FILE_POINTER && GetLastError () != NO_ERROR) {
+           write_log (L"truncate: SetFilePointer() failure for %s to posn %d\n", name, len);
+       } else {
            if (SetEndOfFile (hFile) == TRUE)
                result = 0;
-       } else {
-           write_log ("truncate: SetFilePointer() failure for %s to posn %d\n", name, len);
        }
-       CloseHandle( hFile );
+       CloseHandle (hFile);
     } else {
-       write_log ("truncate: CreateFile() failed to open %s\n", name);
+       write_log (L"truncate: CreateFile() failed to open %s\n", name);
     }
     return result;
 }
@@ -786,7 +849,7 @@ int dos_errno (void)
 {
     DWORD e = GetLastError ();
 
-    //write_log ("ec=%d\n", e);
+    //write_log (L"ec=%d\n", e);
     switch (e) {
      case ERROR_NOT_ENOUGH_MEMORY:
      case ERROR_OUTOFMEMORY:
@@ -822,7 +885,7 @@ int dos_errno (void)
        return ERROR_SEEK_ERROR;
 
      default:
-       write_log ("Unimplemented error %d\n", e);
+       gui_message (L"Unimplemented error %d\nContact author!", e);
        return ERROR_NOT_IMPLEMENTED;
     }
 }
@@ -830,12 +893,12 @@ int dos_errno (void)
 typedef BOOL (CALLBACK* GETVOLUMEPATHNAME)
   (LPCTSTR lpszFileName, LPTSTR lpszVolumePathName, DWORD cchBufferLength);
 
-int my_getvolumeinfo (const char *root)
+int my_getvolumeinfo (const TCHAR *root)
 {
     DWORD v, err;
     int ret = 0;
     GETVOLUMEPATHNAME pGetVolumePathName;
-    char volume[MAX_DPATH];
+    TCHAR volume[MAX_DPATH];
 
     v = GetFileAttributesSafe (root);
     err = GetLastError ();
@@ -848,13 +911,13 @@ int my_getvolumeinfo (const char *root)
        ret |= MYVOLUMEINFO_READONLY;
 */
     pGetVolumePathName = (GETVOLUMEPATHNAME)GetProcAddress(
-       GetModuleHandle("kernel32.dll"), "GetVolumePathNameA");
+       GetModuleHandle (L"kernel32.dll"), "GetVolumePathNameW");
     if (pGetVolumePathName && pGetVolumePathName (root, volume, sizeof (volume))) {
-       char fsname[MAX_DPATH];
+       TCHAR fsname[MAX_DPATH];
        DWORD comlen;
        DWORD flags;
        if (GetVolumeInformation (volume, NULL, 0, NULL, &comlen, &flags, fsname, sizeof (fsname))) {
-           write_log ("Volume %s FS=%s maxlen=%d flags=%08X\n", volume, fsname, comlen, flags);
+           write_log (L"Volume %s FS=%s maxlen=%d flags=%08X\n", volume, fsname, comlen, flags);
            if (flags & FILE_NAMED_STREAMS)
                ret |= MYVOLUMEINFO_STREAMS;
        }
index bb0ba5298f62ad99281731c37c211bb4e6c6e0b8..25736f75a0ea61e5c4a42386273b08ee66175a64 100644 (file)
 static int usefloppydrives = 0;
 
 struct uae_driveinfo {
-    char vendor_id[128];
-    char product_id[128];
-    char product_rev[128];
-    char product_serial[128];
-    char device_name[2048];
-    char device_path[2048];
+    TCHAR vendor_id[128];
+    TCHAR product_id[128];
+    TCHAR product_rev[128];
+    TCHAR product_serial[128];
+    TCHAR device_name[2048];
+    TCHAR device_path[2048];
     uae_u64 size;
     uae_u64 offset;
     int bytespersector;
@@ -77,14 +77,14 @@ static void rdbdump (HANDLE *h, uae_u64 offset, uae_u8 *buf, int blocksize)
 {
     static int cnt = 1;
     int i, blocks;
-    char name[100];
+    TCHAR name[100];
     FILE *f;
 
     blocks = (buf[132] << 24) | (buf[133] << 16) | (buf[134] << 8) | (buf[135] << 0);
     if (blocks < 0 || blocks > 100000)
        return;
-    sprintf (name, "rdb_dump_%d.rdb", cnt);
-    f = fopen (name, "wb");
+    _stprintf (name, L"rdb_dump_%d.rdb", cnt);
+    f = _tfopen (name, L"wb");
     if (!f)
        return;
     for (i = 0; i <= blocks; i++) {
@@ -109,24 +109,24 @@ static int safetycheck (HANDLE *h, uae_u64 offset, uae_u8 *buf, int blocksize)
     for (j = 0; j < blocks; j++) {
        high = (DWORD)(offset >> 32);
        if (SetFilePointer (h, (DWORD)offset, &high, FILE_BEGIN) == INVALID_FILE_SIZE) {
-           write_log ("hd ignored, SetFilePointer failed, error %d\n", GetLastError());
+           write_log (L"hd ignored, SetFilePointer failed, error %d\n", GetLastError());
            return 1;
        }
        memset (buf, 0xaa, blocksize);
        ReadFile (h, buf, blocksize, &outlen, NULL);
        if (outlen != blocksize) {
-           write_log ("hd ignored, read error %d!\n", GetLastError());
+           write_log (L"hd ignored, read error %d!\n", GetLastError());
            return 2;
        }
        if (!memcmp (buf, "RDSK", 4)) {
            if (do_rdbdump)
                rdbdump (h, offset, buf, blocksize);
-           write_log ("hd accepted (rdb detected at block %d)\n", j);
+           write_log (L"hd accepted (rdb detected at block %d)\n", j);
            return -1;
        }
 
        if (!memcmp (buf + 2, "CIS@", 4) && !memcmp (buf + 16, CA, strlen (CA))) {
-           write_log ("hd accepted (PCMCIA RAM)\n");
+           write_log (L"hd accepted (PCMCIA RAM)\n");
            return -2;
        }
        if (j == 0) {
@@ -138,40 +138,40 @@ static int safetycheck (HANDLE *h, uae_u64 offset, uae_u8 *buf, int blocksize)
        offset += blocksize;
     }
     if (!empty) {
-       write_log ("hd ignored, not empty and no RDB detected\n");
+       write_log (L"hd ignored, not empty and no RDB detected\n");
        return 0;
     }
-    write_log ("hd accepted (empty)\n");
+    write_log (L"hd accepted (empty)\n");
     return -9;
 }
 
 
-static void trim (char *s)
+static void trim (TCHAR *s)
 {
-    while(strlen(s) > 0 && s[strlen(s) - 1] == ' ')
-       s[strlen(s) - 1] = 0;
+    while(_tcslen(s) > 0 && s[_tcslen(s) - 1] == ' ')
+       s[_tcslen(s) - 1] = 0;
 }
 
-int isharddrive (const char *name)
+int isharddrive (const TCHAR *name)
 {
     int i;
 
     for (i = 0; i < hdf_getnumharddrives (); i++) {
-       if (!strcmp (uae_drives[i].device_name, name))
+       if (!_tcscmp (uae_drives[i].device_name, name))
            return i;
     }
     return -1;
 }
 
-static char *hdz[] = { "hdz", "zip", "rar", "7z", NULL };
+static TCHAR *hdz[] = { L"hdz", L"zip", L"rar", L"7z", NULL };
 
-int hdf_open_target (struct hardfiledata *hfd, const char *pname)
+int hdf_open_target (struct hardfiledata *hfd, const TCHAR *pname)
 {
     HANDLE h = INVALID_HANDLE_VALUE;
     DWORD flags;
     int i;
     struct uae_driveinfo *udi;
-    char *name = my_strdup (pname);
+    TCHAR *name = my_strdup (pname);
 
     hfd->flags = 0;
     hfd->drive_empty = 0;
@@ -181,11 +181,11 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
     hfd->virtual_size = 0;
     hfd->virtual_rdb = NULL;
     if (!hfd->cache) {
-       write_log ("VirtualAlloc(%d) failed, error %d\n", CACHE_SIZE, GetLastError());
+       write_log (L"VirtualAlloc(%d) failed, error %d\n", CACHE_SIZE, GetLastError());
        goto end;
     }
-    hfd_log ("hfd open: '%s'\n", name);
-    if (strlen (name) > 4 && !memcmp (name, "HD_", 3)) {
+    hfd_log (L"hfd open: '%s'\n", name);
+    if (_tcslen (name) > 4 && !_tcsncmp (name, L"HD_", 3)) {
        hdf_init_target ();
        i = isharddrive (name);
        if (i >= 0) {
@@ -205,10 +205,10 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
            if (h == INVALID_HANDLE_VALUE)
                goto end;
            if (!DeviceIoControl(h, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &r, NULL))
-               write_log ("WARNING: '%s' FSCTL_ALLOW_EXTENDED_DASD_IO returned %d\n", name, GetLastError());
-           strncpy (hfd->vendor_id, udi->vendor_id, 8);
-           strncpy (hfd->product_id, udi->product_id, 16);
-           strncpy (hfd->product_rev, udi->product_rev, 4);
+               write_log (L"WARNING: '%s' FSCTL_ALLOW_EXTENDED_DASD_IO returned %d\n", name, GetLastError());
+           _tcsncpy (hfd->vendor_id, udi->vendor_id, 8);
+           _tcsncpy (hfd->product_id, udi->product_id, 16);
+           _tcsncpy (hfd->product_rev, udi->product_rev, 4);
            hfd->offset = udi->offset;
            hfd->physsize = hfd->virtsize = udi->size;
            hfd->blocksize = udi->bytespersector;
@@ -240,23 +240,23 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
        }
     } else {
        int zmode = 0;
-       char *ext = strrchr (name, '.');
+       TCHAR *ext = _tcsrchr (name, '.');
        if (ext != NULL) {
            ext++;
            for (i = 0; hdz[i]; i++) {
-               if (!stricmp (ext, hdz[i]))
+               if (!_tcsicmp (ext, hdz[i]))
                    zmode = 1;
            }
        }
        h = CreateFile (name, GENERIC_READ | (hfd->readonly ? 0 : GENERIC_WRITE), hfd->readonly ? FILE_SHARE_READ : 0, NULL,
            OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
        hfd->handle = h;
-       i = strlen (name) - 1;
+       i = _tcslen (name) - 1;
        while (i >= 0) {
            if ((i > 0 && (name[i - 1] == '/' || name[i - 1] == '\\')) || i == 0) {
-               strcpy (hfd->vendor_id, "UAE");
-               strncpy (hfd->product_id, name + i, 15);
-               strcpy (hfd->product_rev, "0.3");
+               _tcscpy (hfd->vendor_id, L"UAE");
+               _tcsncpy (hfd->product_id, name + i, 15);
+               _tcscpy (hfd->product_rev, L"0.3");
                break;
            }
            i--;
@@ -274,9 +274,9 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
            hfd->physsize = hfd->virtsize = ((uae_u64)high << 32) | low;
            hfd->handle_valid = HDF_HANDLE_WIN32;
            if (hfd->physsize < 64 * 1024 * 1024 && zmode) {
-               write_log ("HDF '%s' re-opened in zfile-mode\n", name);
+               write_log (L"HDF '%s' re-opened in zfile-mode\n", name);
                CloseHandle (h);
-               hfd->handle = h = zfile_fopen(name, hfd->readonly ? "rb" : "r+b");
+               hfd->handle = h = zfile_fopen(name, hfd->readonly ? L"rb" : L"r+b");
                if (!h)
                    goto end;
                zfile_fseek (h, 0, SEEK_END);
@@ -285,12 +285,12 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
                hfd->handle_valid = HDF_HANDLE_ZFILE;
            }
        } else {
-           write_log ("HDF '%s' failed to open. error = %d\n", name, GetLastError ());
+           write_log (L"HDF '%s' failed to open. error = %d\n", name, GetLastError ());
        }
     }
     hfd->handle = h;
     if (hfd->handle_valid || hfd->drive_empty) {
-       hfd_log ("HDF '%s' opened, size=%dK mode=%d empty=%d\n",
+       hfd_log (L"HDF '%s' opened, size=%dK mode=%d empty=%d\n",
            name, hfd->physsize / 1024, hfd->handle_valid, hfd->drive_empty);
        return 1;
     }
@@ -356,16 +356,16 @@ static int hdf_seek (struct hardfiledata *hfd, uae_u64 offset)
     DWORD high, ret;
 
     if (hfd->handle_valid == 0) {
-       gui_message ("hd: hdf handle is not valid. bug.");
+       gui_message (L"hd: hdf handle is not valid. bug.");
        abort();
     }
     if (offset >= hfd->physsize - hfd->virtual_size) {
-       gui_message ("hd: tried to seek out of bounds! (%I64X >= %I64X)\n", offset, hfd->physsize);
+       gui_message (L"hd: tried to seek out of bounds! (%I64X >= %I64X)\n", offset, hfd->physsize);
        abort ();
     }
     offset += hfd->offset;
     if (offset & (hfd->blocksize - 1)) {
-       gui_message ("hd: poscheck failed, offset not aligned to blocksize! (%I64X & %04X = %04X)\n",
+       gui_message (L"hd: poscheck failed, offset not aligned to blocksize! (%I64X & %04X = %04X)\n",
            offset, hfd->blocksize, offset & (hfd->blocksize - 1));
        abort ();
     }
@@ -390,7 +390,7 @@ static void poscheck (struct hardfiledata *hfd, int len)
        ret = SetFilePointer (hfd->handle, 0, &high, FILE_CURRENT);
        err = GetLastError ();
        if (ret == INVALID_FILE_SIZE && err != NO_ERROR) {
-           gui_message ("hd: poscheck failed. seek failure, error %d", err);
+           gui_message (L"hd: poscheck failed. seek failure, error %d", err);
            abort ();
        }
        pos = ((uae_u64)high) << 32 | ret;
@@ -398,19 +398,19 @@ static void poscheck (struct hardfiledata *hfd, int len)
        pos = zfile_ftell (hfd->handle);
     }
     if (len < 0) {
-       gui_message ("hd: poscheck failed, negative length! (%d)", len);
+       gui_message (L"hd: poscheck failed, negative length! (%d)", len);
        abort ();
     }
     if (pos < hfd->offset) {
-       gui_message ("hd: poscheck failed, offset out of bounds! (%I64d < %I64d)", pos, hfd->offset);
+       gui_message (L"hd: poscheck failed, offset out of bounds! (%I64d < %I64d)", pos, hfd->offset);
        abort ();
     }
     if (pos >= hfd->offset + hfd->physsize - hfd->virtual_size || pos >= hfd->offset + hfd->physsize + len - hfd->virtual_size) {
-       gui_message ("hd: poscheck failed, offset out of bounds! (%I64d >= %I64d, LEN=%d)", pos, hfd->offset + hfd->physsize, len);
+       gui_message (L"hd: poscheck failed, offset out of bounds! (%I64d >= %I64d, LEN=%d)", pos, hfd->offset + hfd->physsize, len);
        abort ();
     }
     if (pos & (hfd->blocksize - 1)) {
-       gui_message ("hd: poscheck failed, offset not aligned to blocksize! (%I64X & %04X = %04X\n", pos, hfd->blocksize, pos & hfd->blocksize);
+       gui_message (L"hd: poscheck failed, offset not aligned to blocksize! (%I64X & %04X = %04X\n", pos, hfd->blocksize, pos & hfd->blocksize);
        abort ();
     }
 }
@@ -560,7 +560,7 @@ static int hdf_read_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, i
        memcpy (buffer, hfd->cache + coffset, len);
        return len;
     }
-    write_log ("hdf_read: cache bug! offset=%I64d len=%d\n", offset, len);
+    write_log (L"hdf_read: cache bug! offset=%I64d len=%d\n", offset, len);
     hfd->cache_valid = 0;
     return 0;
 }
@@ -671,17 +671,17 @@ int hdf_resize_target (struct hardfiledata *hfd, uae_u64 newsize)
 
 static void generatestorageproperty (struct uae_driveinfo *udi, int ignoreduplicates)
 {
-    strcpy (udi->vendor_id, "UAE");
-    strcpy (udi->product_id, "DISK");
-    strcpy (udi->product_rev, "1.0");
-    sprintf (udi->device_name, "%s", udi->device_path);
+    _tcscpy (udi->vendor_id, L"UAE");
+    _tcscpy (udi->product_id, L"DISK");
+    _tcscpy (udi->product_rev, L"1.0");
+    _stprintf (udi->device_name, L"%s", udi->device_path);
     udi->removablemedia = 1;
 }
 
 static int getstorageproperty (PUCHAR outBuf, int returnedLength, struct uae_driveinfo *udi, int ignoreduplicates)
 {
     PSTORAGE_DEVICE_DESCRIPTOR devDesc;
-    char orgname[1024];
+    TCHAR orgname[1024];
     PUCHAR p;
     int i, j;
     int size;
@@ -690,11 +690,11 @@ static int getstorageproperty (PUCHAR outBuf, int returnedLength, struct uae_dri
     size = devDesc->Version;
     p = (PUCHAR) outBuf;
     if (offsetof(STORAGE_DEVICE_DESCRIPTOR, CommandQueueing) > size) {
-       write_log ("too short STORAGE_DEVICE_DESCRIPTOR only %d bytes\n", size);
+       write_log (L"too short STORAGE_DEVICE_DESCRIPTOR only %d bytes\n", size);
        return 1;
     }
     if (devDesc->DeviceType != INQ_DASD && devDesc->DeviceType != INQ_ROMD && devDesc->DeviceType != INQ_OPTD) {
-        write_log ("not a direct access device, ignored (type=%d)\n", devDesc->DeviceType);
+        write_log (L"not a direct access device, ignored (type=%d)\n", devDesc->DeviceType);
         return 1;
     }
     if (size > offsetof(STORAGE_DEVICE_DESCRIPTOR, VendorIdOffset) && devDesc->VendorIdOffset && p[devDesc->VendorIdOffset]) {
@@ -718,50 +718,50 @@ static int getstorageproperty (PUCHAR outBuf, int returnedLength, struct uae_dri
            udi->product_serial[j++] = p[i];
     }
     if (udi->vendor_id[0])
-        strcat (udi->device_name, udi->vendor_id);
+        _tcscat (udi->device_name, udi->vendor_id);
     if (udi->product_id[0]) {
         if (udi->device_name[0])
-           strcat (udi->device_name, " ");
-       strcat (udi->device_name, udi->product_id);
+           _tcscat (udi->device_name, L" ");
+       _tcscat (udi->device_name, udi->product_id);
     }
     if (udi->product_rev[0]) {
         if (udi->device_name[0])
-           strcat (udi->device_name, " ");
-       strcat (udi->device_name, udi->product_rev);
+           _tcscat (udi->device_name, L" ");
+       _tcscat (udi->device_name, udi->product_rev);
     }
     if (udi->product_serial[0]) {
         if (udi->device_name[0])
-           strcat (udi->device_name, " ");
-       strcat (udi->device_name, udi->product_serial);
+           _tcscat (udi->device_name, L" ");
+       _tcscat (udi->device_name, udi->product_serial);
     }
     if (!udi->device_name[0]) {
-        write_log ("empty device id?!?, replacing with device path\n");
-        strcpy (udi->device_name, udi->device_path);
+        write_log (L"empty device id?!?, replacing with device path\n");
+        _tcscpy (udi->device_name, udi->device_path);
     }
     udi->removablemedia = devDesc->RemovableMedia;
-    write_log ("device id string: '%s'\n", udi->device_name);
+    write_log (L"device id string: '%s'\n", udi->device_name);
     if (ignoreduplicates) {
-       sprintf (orgname, "HD_%s", udi->device_name);
+       _stprintf (orgname, L"HD_%s", udi->device_name);
        if (isharddrive (orgname) >= 0) {
-           write_log ("duplicate device, ignored\n");
+           write_log (L"duplicate device, ignored\n");
            return 1;
        }
        if (!udi->removablemedia) {
-           write_log ("drive letter not removable, ignored\n");
+           write_log (L"drive letter not removable, ignored\n");
            return 1;
        }
     }
     return 0;
 }
 
-static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD *index2, uae_u8 *buffer, int ignoreduplicates)
+static BOOL GetDevicePropertyFromName(const TCHAR *DevicePath, DWORD Index, DWORD *index2, uae_u8 *buffer, int ignoreduplicates)
 {
     int i, nosp;
     int ret = -1;
     STORAGE_PROPERTY_QUERY query;
     DRIVE_LAYOUT_INFORMATION           *dli;
     struct uae_driveinfo *udi;
-    char orgname[1024];
+    TCHAR orgname[1024];
     HANDLE hDevice = INVALID_HANDLE_VALUE;
     UCHAR outBuf[20000];
     DISK_GEOMETRY                      dg;
@@ -779,8 +779,8 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
 
     udi = &uae_drives[*index2];
     memset (udi, 0, sizeof (struct uae_driveinfo));
-    strcpy (udi->device_path, DevicePath);
-    write_log ("opening device '%s'\n", udi->device_path);
+    _tcscpy (udi->device_path, DevicePath);
+    write_log (L"opening device '%s'\n", udi->device_path);
     hDevice = CreateFile(
                udi->device_path,    // device interface name
                GENERIC_READ | GENERIC_WRITE,       // dwDesiredAccess
@@ -798,7 +798,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
 
 
     if (hDevice == INVALID_HANDLE_VALUE) {
-       write_log ("CreateFile failed with error: %d\n", GetLastError());
+       write_log (L"CreateFile failed with error: %d\n", GetLastError());
        ret = 1;
        goto end;
     }
@@ -817,7 +817,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
                        NULL
                        );
     if (!status) {
-       write_log ("IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", GetLastError());
+       write_log (L"IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", GetLastError());
     } else {
         adpDesc = (PSTORAGE_ADAPTER_DESCRIPTOR) outBuf;
     }
@@ -836,7 +836,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
                        NULL);
     if (!status) {
        DWORD err = GetLastError ();
-        write_log ("IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", err);
+        write_log (L"IOCTL_STORAGE_QUERY_PROPERTY failed with error code %d.\n", err);
        if (err != ERROR_INVALID_FUNCTION) {
            ret = 1;
            goto end;
@@ -852,7 +852,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
            goto end;
        }
     }
-    strcpy (orgname, udi->device_name);
+    _tcscpy (orgname, udi->device_name);
     udi->bytespersector = 512;
     if (!DeviceIoControl (hDevice, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, (void*)&dg, sizeof (dg), &returnedLength, NULL)) {
        DWORD err = GetLastError();
@@ -860,7 +860,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
            udi->nomedia = 1;
            goto amipartfound;
        }
-       write_log ("IOCTL_DISK_GET_DRIVE_GEOMETRY failed with error code %d.\n", err);
+       write_log (L"IOCTL_DISK_GET_DRIVE_GEOMETRY failed with error code %d.\n", err);
        ret = 1;
        goto end;
     }
@@ -874,29 +874,29 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
     gli_ok = 1;
     if (!DeviceIoControl (hDevice, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, (void*)&gli, sizeof (gli), &returnedLength, NULL)) {
        gli_ok = 0;
-       write_log ("IOCTL_DISK_GET_LENGTH_INFO failed with error code %d.\n", GetLastError());
+       write_log (L"IOCTL_DISK_GET_LENGTH_INFO failed with error code %d.\n", GetLastError());
        if (!nosp)
-           write_log ("IOCTL_DISK_GET_LENGTH_INFO not supported, detected disk size may not be correct.\n");
+           write_log (L"IOCTL_DISK_GET_LENGTH_INFO not supported, detected disk size may not be correct.\n");
     }
     udi->bytespersector = dg.BytesPerSector;
     if (dg.BytesPerSector < 512) {
-       write_log ("unsupported blocksize < 512 (%d)\n", dg.BytesPerSector);
+       write_log (L"unsupported blocksize < 512 (%d)\n", dg.BytesPerSector);
        ret = 1;
        goto end;
     }
     if (dg.BytesPerSector > 2048) {
-       write_log ("unsupported blocksize > 2048 (%d)\n", dg.BytesPerSector);
+       write_log (L"unsupported blocksize > 2048 (%d)\n", dg.BytesPerSector);
        ret = 1;
        goto end;
     }
     udi->offset = 0;
-    write_log ("BPS=%d Cyls=%I64d TPC=%d SPT=%d MediaType=%d\n",
+    write_log (L"BPS=%d Cyls=%I64d TPC=%d SPT=%d MediaType=%d\n",
        dg.BytesPerSector, dg.Cylinders.QuadPart, dg.TracksPerCylinder, dg.SectorsPerTrack, dg.MediaType);
     udi->size = (uae_u64)dg.BytesPerSector * (uae_u64)dg.Cylinders.QuadPart *
        (uae_u64)dg.TracksPerCylinder * (uae_u64)dg.SectorsPerTrack;
     if (gli_ok)
        udi->size = gli.Length.QuadPart;
-    write_log ("device size %I64d (0x%I64x) bytes\n", udi->size, udi->size);
+    write_log (L"device size %I64d (0x%I64x) bytes\n", udi->size, udi->size);
     trim (orgname);
 
     memset (outBuf, 0, sizeof (outBuf));
@@ -904,7 +904,7 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
        &outBuf, sizeof (outBuf), &returnedLength, NULL);
     if (!status) {
        DWORD err = GetLastError();
-       write_log ("IOCTL_DISK_GET_DRIVE_LAYOUT failed with error code %d.\n", err);
+       write_log (L"IOCTL_DISK_GET_DRIVE_LAYOUT failed with error code %d.\n", err);
        if (err != ERROR_INVALID_FUNCTION) {
            ret = 1;
            goto end;
@@ -917,28 +917,28 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
        int nonzeropart = 0;
        int gotpart = 0;
        int safepart = 0;
-       write_log ("%d MBR partitions found\n", dli->PartitionCount);
+       write_log (L"%d MBR partitions found\n", dli->PartitionCount);
        for (i = 0; i < dli->PartitionCount && (*index2) < MAX_FILESYSTEM_UNITS; i++) {
            PARTITION_INFORMATION *pi = &dli->PartitionEntry[i];
            if (pi->PartitionType == PARTITION_ENTRY_UNUSED)
                continue;
-           write_log ("%d: num: %d type: %02X offset: %I64d size: %I64d, ", i, pi->PartitionNumber, pi->PartitionType, pi->StartingOffset.QuadPart, pi->PartitionLength.QuadPart);
+           write_log (L"%d: num: %d type: %02X offset: %I64d size: %I64d, ", i, pi->PartitionNumber, pi->PartitionType, pi->StartingOffset.QuadPart, pi->PartitionLength.QuadPart);
            if (pi->RecognizedPartition == 0) {
-               write_log ("unrecognized\n");
+               write_log (L"unrecognized\n");
                continue;
            }
            nonzeropart++;
            if (pi->PartitionType != 0x76) {
-               write_log ("type not 0x76\n");
+               write_log (L"type not 0x76\n");
                continue;
            }
            memmove (udi, udi2, sizeof (*udi));
            udi->device_name[0] = 0;
            udi->offset = pi->StartingOffset.QuadPart;
            udi->size = pi->PartitionLength.QuadPart;
-           write_log ("used\n");
+           write_log (L"used\n");
            if (safetycheck (hDevice, udi->offset, buffer, dg.BytesPerSector) <= 0) {
-               sprintf (udi->device_name, "HD_P#%d_%s", pi->PartitionNumber, orgname);
+               _stprintf (udi->device_name, L"HD_P#%d_%s", pi->PartitionNumber, orgname);
                udi++;
                (*index2)++;
                safepart = 1;
@@ -946,24 +946,24 @@ static BOOL GetDevicePropertyFromName(const char *DevicePath, DWORD Index, DWORD
            gotpart = 1;
        }
        if (!nonzeropart) {
-           write_log ("empty MBR partition table detected, checking for RDB\n");
+           write_log (L"empty MBR partition table detected, checking for RDB\n");
        } else if (!gotpart) {
-           write_log ("non-empty MBR partition table detected, doing RDB check anyway\n");
+           write_log (L"non-empty MBR partition table detected, doing RDB check anyway\n");
        } else if (safepart) {
            goto amipartfound; /* ugly but bleh.. */
        }
     } else {
-       write_log ("no MBR partition table detected, checking for RDB\n");
+       write_log (L"no MBR partition table detected, checking for RDB\n");
     }
 
     udi->dangerous = safetycheck (hDevice, 0, buffer, dg.BytesPerSector);
     if (udi->dangerous > 0)
        goto end;
 amipartfound:
-    sprintf (udi->device_name, "HD_%s", orgname);
+    _stprintf (udi->device_name, L"HD_%s", orgname);
     {
        int cnt = 1;
-       int off = strlen (udi->device_name);
+       int off = _tcslen (udi->device_name);
        while (isharddrive (udi->device_name) >= 0) {
            udi->device_name[off] = '_';
            udi->device_name[off + 1] = cnt + '0';
@@ -1022,7 +1022,7 @@ Return Value:
     if (status == FALSE) {
        errorCode = GetLastError();
        if (errorCode != ERROR_NO_MORE_ITEMS) {
-           write_log ("SetupDiEnumDeviceInterfaces failed with error: %d\n", errorCode);
+           write_log (L"SetupDiEnumDeviceInterfaces failed with error: %d\n", errorCode);
        }
        ret = 0;
        goto end;
@@ -1050,7 +1050,7 @@ Return Value:
     if (status == FALSE) {
        errorCode = GetLastError();
        if (errorCode != ERROR_INSUFFICIENT_BUFFER) {
-           write_log ("SetupDiGetDeviceInterfaceDetail failed with error: %d\n", errorCode);
+           write_log (L"SetupDiGetDeviceInterfaceDetail failed with error: %d\n", errorCode);
            ret = 0;
            goto end;
        }
@@ -1064,7 +1064,7 @@ Return Value:
     interfaceDetailDataSize = reqSize;
     interfaceDetailData = malloc (interfaceDetailDataSize);
     if (interfaceDetailData == NULL) {
-       write_log ("Unable to allocate memory to get the interface detail data.\n");
+       write_log (L"Unable to allocate memory to get the interface detail data.\n");
        ret = 0;
        goto end;
     }
@@ -1079,7 +1079,7 @@ Return Value:
                  NULL);                    // Interface device info
 
     if (status == FALSE) {
-       write_log ("Error in SetupDiGetDeviceInterfaceDetail failed with error: %d\n", GetLastError());
+       write_log (L"Error in SetupDiGetDeviceInterfaceDetail failed with error: %d\n", GetLastError());
        ret = 0;
        goto end;
     }
@@ -1133,12 +1133,12 @@ static int hdf_init2 (int force)
        dwDriveMask = GetLogicalDrives();
         for(drive = 'A'; drive <= 'Z'; drive++) {
            if((dwDriveMask & 1) && (drive >= 'C' || usefloppydrives)) {
-               char tmp1[20], tmp2[20];
+               TCHAR tmp1[20], tmp2[20];
                DWORD drivetype;
-               sprintf (tmp1, "%c:\\", drive);
+               _stprintf (tmp1, L"%c:\\", drive);
                drivetype = GetDriveType(tmp1);
                if (drivetype != DRIVE_REMOTE) {
-                   sprintf (tmp2, "\\\\.\\%c:", drive);
+                   _stprintf (tmp2, L"\\\\.\\%c:", drive);
                    GetDevicePropertyFromName (tmp2, index, &index2, buffer, 1);
                    num_drives = index2;
                }
@@ -1160,7 +1160,7 @@ static int hdf_init2 (int force)
        VirtualFree (buffer, 0, MEM_RELEASE);
     }
     num_drives = index2;
-    write_log ("Drive scan result: %d Amiga formatted drives detected\n", num_drives);
+    write_log (L"Drive scan result: %d Amiga formatted drives detected\n", num_drives);
 #endif
     return num_drives;
 }
@@ -1175,49 +1175,49 @@ int hdf_getnumharddrives (void)
     return num_drives;
 }
 
-char *hdf_getnameharddrive (int index, int flags, int *sectorsize)
+TCHAR *hdf_getnameharddrive (int index, int flags, int *sectorsize)
 {
-    static char name[512];
-    char tmp[32];
+    static TCHAR name[512];
+    TCHAR tmp[32];
     uae_u64 size = uae_drives[index].size;
     int nomedia = uae_drives[index].nomedia;
-    char *dang = "?";
-    char *rw = "RW";
+    TCHAR *dang = L"?";
+    TCHAR *rw = L"RW";
 
     switch (uae_drives[index].dangerous)
     {
        case -9:
-       dang = "Empty";
+       dang = L"Empty";
        break;
        case -2:
-       dang = "SRAM";
+       dang = L"SRAM";
        break;
        case -1:
-       dang = "RDB";
+       dang = L"RDB";
        break;
        case 0:
-       dang = "NON-EMPTY";
+       dang = L"NON-EMPTY";
        break;
     }
     if (nomedia)       
-       dang = "NO MEDIA";
+       dang = L"NO MEDIA";
     if (uae_drives[index].readonly)
-       rw = "RO";
+       rw = L"RO";
 
     if (sectorsize)
        *sectorsize = uae_drives[index].bytespersector;
     if (flags & 1) {
        if (nomedia) {
-           strcpy (tmp, "N/A");
+           _tcscpy (tmp, L"N/A");
        } else {
            if (size >= 1024 * 1024 * 1024)
-               sprintf (tmp, "%.1fG", ((double)(uae_u32)(size / (1024 * 1024))) / 1024.0);
+               _stprintf (tmp, L"%.1fG", ((double)(uae_u32)(size / (1024 * 1024))) / 1024.0);
            else if (size < 10 * 1024 * 1024)
-               sprintf (tmp, "%dK", size / 1024);
+               _stprintf (tmp, L"%dK", size / 1024);
            else
-               sprintf (tmp, "%.1fM", ((double)(uae_u32)(size / (1024))) / 1024.0);
+               _stprintf (tmp, L"%.1fM", ((double)(uae_u32)(size / (1024))) / 1024.0);
        }
-       sprintf (name, "%10s [%s,%s] %s", dang, tmp, rw, uae_drives[index].device_name + 3);
+       _stprintf (name, L"%10s [%s,%s] %s", dang, tmp, rw, uae_drives[index].device_name + 3);
        return name;
     }
     if (flags & 2)
@@ -1233,7 +1233,7 @@ static int hmc (struct hardfiledata *hfd)
 
     while (hfd->handle_valid) {
        DWORD errormode;
-       write_log ("testing if %s has media inserted\n", hfd->emptyname);
+       write_log (L"testing if %s has media inserted\n", hfd->emptyname);
        status = 0;
        errormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
        SetFilePointer (hfd->handle, 0, NULL, FILE_BEGIN);
@@ -1242,14 +1242,14 @@ static int hmc (struct hardfiledata *hfd)
        SetErrorMode(errormode);
        if (ret) {
            if (got == hfd->blocksize) {
-               write_log ("read ok (%d)\n", got);
+               write_log (L"read ok (%d)\n", got);
            } else {
-               write_log ("read ok but no data (%d)\n", hfd->blocksize);
+               write_log (L"read ok but no data (%d)\n", hfd->blocksize);
                ret = 0;
                err = 0;
            }
        } else {
-           write_log ("=%d\n", err);
+           write_log (L"=%d\n", err);
        }
        if (!ret && (err == ERROR_DEV_NOT_EXIST || err == ERROR_WRONG_DISK)) {
            if (!first)
@@ -1271,7 +1271,7 @@ static int hmc (struct hardfiledata *hfd)
        status = -1;
 end:
     xfree (buf);
-    write_log("hmc returned %d\n", status);
+    write_log (L"hmc returned %d\n", status);
     return status;
 }
 
@@ -1279,7 +1279,7 @@ int hardfile_remount (int nr);
 
 
 static void hmc_check (struct hardfiledata *hfd, struct uaedev_config_info *uci, int *rescanned, int *reopen,
-                      int *gotinsert, const char *drvname, int inserted)
+                      int *gotinsert, const TCHAR *drvname, int inserted)
 {
     int ret;
 
@@ -1289,14 +1289,14 @@ static void hmc_check (struct hardfiledata *hfd, struct uaedev_config_info *uci,
        hdf_init2 (1);
        *rescanned = 1;
     }
-    if (hfd->emptyname && strlen (hfd->emptyname) >= 6 && drvname && strlen (drvname) == 3 && drvname[1] == ':' && drvname[2] == '\\' && !inserted) { /* drive letter check */
-       char tmp[10], *p;
-       sprintf (tmp, "\\\\.\\%c:", drvname[0]);
-       p = hfd->emptyname + strlen (hfd->emptyname) - 6;
-       write_log("workaround-remove test: '%s' and '%s'\n", p, drvname);
-       if (!strcmp (tmp, p)) {
-           char *en = my_strdup (hfd->emptyname);
-           write_log ("workaround-remove done\n");
+    if (hfd->emptyname && _tcslen (hfd->emptyname) >= 6 && drvname && _tcslen (drvname) == 3 && drvname[1] == ':' && drvname[2] == '\\' && !inserted) { /* drive letter check */
+       TCHAR tmp[10], *p;
+       _stprintf (tmp, L"\\\\.\\%c:", drvname[0]);
+       p = hfd->emptyname + _tcslen (hfd->emptyname) - 6;
+       write_log( L"workaround-remove test: '%s' and '%s'\n", p, drvname);
+       if (!_tcscmp (tmp, p)) {
+           TCHAR *en = my_strdup (hfd->emptyname);
+           write_log (L"workaround-remove done\n");
            hdf_close (hfd);
            hfd->emptyname = en;
            hfd->drive_empty = 1;
@@ -1308,9 +1308,9 @@ static void hmc_check (struct hardfiledata *hfd, struct uaedev_config_info *uci,
     if (hfd->drive_empty < 0 || !hfd->handle_valid) {
         int empty = hfd->drive_empty;
         int r;
-        //write_log ("trying to open '%s' de=%d hv=%d\n", hfd->emptyname, hfd->drive_empty, hfd->handle_valid);
+        //write_log (L"trying to open '%s' de=%d hv=%d\n", hfd->emptyname, hfd->drive_empty, hfd->handle_valid);
         r = hdf_open (hfd, hfd->emptyname);
-        //write_log ("=%d\n", r);
+        //write_log (L"=%d\n", r);
         if (!r)
            return;
        *reopen = 1;
@@ -1333,7 +1333,7 @@ static void hmc_check (struct hardfiledata *hfd, struct uaedev_config_info *uci,
     hardfile_do_disk_change (uci, ret < 0 ? 0 : 1);
 }
 
-int win32_hardfile_media_change (const char *drvname, int inserted)
+int win32_hardfile_media_change (const TCHAR *drvname, int inserted)
 {
     int gotinsert = 0, rescanned = 0;
     int i, j;
@@ -1359,7 +1359,7 @@ int win32_hardfile_media_change (const char *drvname, int inserted)
        }
     }
 
-    //write_log ("win32_hardfile_media_change returned %d\n", gotinsert);
+    //write_log (L"win32_hardfile_media_change returned %d\n", gotinsert);
     return gotinsert;
 }
 
@@ -1405,7 +1405,7 @@ int harddrive_to_hdf(HWND hDlg, struct uae_prefs *p, int idx)
     DWORD ret, got, gotdst, get;
     uae_u64 size, sizecnt, written;
     LARGE_INTEGER li;
-    char path[MAX_DPATH], tmp[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR path[MAX_DPATH], tmp[MAX_DPATH], tmp2[MAX_DPATH];
     DWORD retcode = 0;
     HWND hwnd, hwndprogress, hwndprogresstxt;
     MSG msg;
@@ -1455,7 +1455,7 @@ int harddrive_to_hdf(HWND hDlg, struct uae_prefs *p, int idx)
            break;
        if (cnt > 0) {
            SendMessage(hwndprogress, PBM_SETPOS, (WPARAM)pct, 0);
-           sprintf (tmp, "%dM / %dM (%d%%)", (int)(written >> 20), (int)(size >> 20), pct);
+           _stprintf (tmp, L"%dM / %dM (%d%%)", (int)(written >> 20), (int)(size >> 20), pct);
            SendMessage(hwndprogresstxt, WM_SETTEXT, 0, (LPARAM)tmp);
            while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) {
                TranslateMessage (&msg);
@@ -1522,7 +1522,7 @@ int harddrive_to_hdf(HWND hDlg, struct uae_prefs *p, int idx)
 
 err:
     WIN32GUI_LoadUIString (IDS_HDCLONE_FAIL, tmp, MAX_DPATH);
-    sprintf (tmp2, tmp, progressdialogreturn, GetLastError());
+    _stprintf (tmp2, tmp, progressdialogreturn, GetLastError());
     gui_message (tmp2);
 
 ok:
index 04ee241bce72ceddf530a5d02ca194a67cc62f50..1e44478746ac538b771945602907f2cb71f971ae 100644 (file)
@@ -50,7 +50,7 @@ int ioport_init (void)
        return initialized > 0 ? 1 : 0;
 
 #ifndef IOPORT_EMU
-    ioh = WIN32_LoadLibrary ("tvicport.dll");
+    ioh = WIN32_LoadLibrary (L"tvicport.dll");
     if (ioh) {
        for (;;) {
            pOpenTVicPort = (OPENTVICPORT)GetProcAddress (ioh, "OpenTVicPort");
@@ -59,25 +59,25 @@ int ioport_init (void)
            pReadPort = (READPORT)GetProcAddress (ioh, "ReadPort");
            pWritePort = (WRITEPORT)GetProcAddress (ioh, "WritePort");
            if (!pOpenTVicPort || !pCloseTVicPort || !pIsDriverOpened || !pReadPort || !pWritePort) {
-               write_log ("IO: incompatible tvicport.dll\n");
+               write_log (L"IO: incompatible tvicport.dll\n");
                break;
            }
            if (!pOpenTVicPort()) {
-               write_log ("IO: tvicport.dll failed to initialize\n");
+               write_log (L"IO: tvicport.dll failed to initialize\n");
                break;
            }
            if (!pIsDriverOpened()) {
-               write_log ("IO: tvicport.dll failed to initialize!\n");
+               write_log (L"IO: tvicport.dll failed to initialize!\n");
                pCloseTVicPort();
                break;
            }
            initialized = 1;
-           write_log ("IO: tvicport.dll initialized\n");
+           write_log (L"IO: tvicport.dll initialized\n");
            return 1;
        }
     }
     FreeLibrary(ioh);
-    ioh = WIN32_LoadLibrary ("winio.dll");
+    ioh = WIN32_LoadLibrary (L"winio.dll");
     if (ioh) {
        for (;;) {
            pInitializeWinIo = (INITIALIZEWINIO)GetProcAddress (ioh, "InitializeWinIo");
@@ -85,23 +85,23 @@ int ioport_init (void)
            pGetPortVal = (GETPORTVAL)GetProcAddress (ioh, "GetPortVal");
            pSetPortVal = (SETPORTVAL)GetProcAddress (ioh, "SetPortVal");
            if (!pInitializeWinIo || !pShutdownWinIo || !pGetPortVal || !pSetPortVal) {
-               write_log ("IO: incompatible winio.dll\n");
+               write_log (L"IO: incompatible winio.dll\n");
                break;
            }
            __try {
                initialized = pInitializeWinIo() ? 2 : 0;
            } __except (EXCEPTION_EXECUTE_HANDLER) {
-               write_log ("IO: winio.dll initialization failed\n");
+               write_log (L"IO: winio.dll initialization failed\n");
            }
            if (!initialized)
                break;
-           write_log ("IO: winio.dll initialized\n");
+           write_log (L"IO: winio.dll initialized\n");
            return 1;
        }
     }
     FreeLibrary(ioh);
     initialized = -1;
-    write_log ("IO: tvicport.dll or winio.dll failed to initialize\n");
+    write_log (L"IO: tvicport.dll or winio.dll failed to initialize\n");
     return 0;
 #else
     initialized = 1;
@@ -151,7 +151,7 @@ void ioport_write (int port, uae_u8 v)
 
 void paraport_free (void) { }
 int paraport_init (void) { return 0; }
-int paraport_open (char *port) { return 0; }
+int paraport_open (TCHAR *port) { return 0; }
 int parallel_direct_write_status (uae_u8 v, uae_u8 dir) { return 0; }
 int parallel_direct_read_status (uae_u8 *vp) { return 0; }
 int parallel_direct_write_data (uae_u8 v, uae_u8 dir) { return 0; }
@@ -185,14 +185,13 @@ void paraport_free (void)
 
 int paraport_init (void)
 {
-    char tmp[10];
     int mask = 0, i;
     HANDLE pp;
 
     paraport_free ();
-    para = WIN32_LoadLibrary("ParaPort.dll");
+    para = WIN32_LoadLibrary(L"ParaPort.dll");
     if (!para) {
-       write_log ("PARAPORT: no ParaPort.dll, direct parallel port emulation disabled\n");
+       write_log (L"PARAPORT: no ParaPort.dll, direct parallel port emulation disabled\n");
        return 0;
     }
     pp_closeport = (closePort)GetProcAddress (para, "closePort");
@@ -200,48 +199,51 @@ int paraport_init (void)
     pp_getportinfo = (getPortInfo)GetProcAddress (para, "getPortInfo");
     pp_openport = (openPort)GetProcAddress (para, "openPort");
     if (!pp_openport || !pp_closeport || !pp_executecycle) {
-       write_log ("PARAPORT: GetProcAddress() failed\n");
+       write_log (L"PARAPORT: GetProcAddress() failed\n");
        paraport_free ();
     }
-    write_log ("PARAPORT:");
+    write_log (L"PARAPORT:");
     for (i = 0; i < 4 ; i++) {
+       char tmp[10];
        sprintf (tmp, "LPT%d", i + 1);
        pp = pp_openport (tmp);
        if (pp != INVALID_HANDLE_VALUE) {
            mask |= 1 << i;
            pp_closeport (pp);
-           write_log (" %s", tmp);
        }
        pp = 0;
     }
     if (!mask)
-       write_log ("no parallel ports detected");
-    write_log ("\n");
+       write_log (L"no parallel ports detected");
+    write_log (L"\n");
     return mask;
 }
 
-int paraport_open (char *port)
+int paraport_open (TCHAR *port)
 {
-    static char oldport[10];
+    static TCHAR oldport[10];
     PARAPORT_CYCLE c[1];
+    char *port2;
 
     if (!para)
        return 0;
-    if (pport && !strcmp (port, oldport))
+    if (pport && !_tcscmp (port, oldport))
        return 1;
-    pport = pp_openport(port);
+    port2 = ua (port);
+    pport = pp_openport (port2);
+    xfree (port2);
     if (!pport) {
-       write_log ("PARAPORT: couldn't open '%s'\n", port);
+       write_log (L"PARAPORT: couldn't open '%s'\n", port);
        paraport_free ();
        return 0;
     }
-    strcpy (oldport, port);
-    write_log ("PARAPORT: port '%s' opened\n", port);
+    _tcscpy (oldport, port);
+    write_log (L"PARAPORT: port '%s' opened\n", port);
     memset (c, 0, sizeof (PARAPORT_CYCLE));
     c[0].MaskControl = PARAPORT_MASK_CONTROL | PARAPORT_MASK_CONTROL_DIRECTION;
     c[0].Control = PARAPORT_MASK_CONTROL_INIT | PARAPORT_MASK_CONTROL_DIRECTION;
     if (!pp_executecycle (pport, c, 1)) {
-       write_log ("PARAPORT: init executeCycle failed\n");
+       write_log (L"PARAPORT: init executeCycle failed\n");
     }
     return 1;
 }
@@ -257,20 +259,20 @@ int parallel_direct_write_status (uae_u8 v, uae_u8 dir)
     memset (c, 0, sizeof (PARAPORT_CYCLE));
     c[0].MaskControl = PARAPORT_MASK_CONTROL_SELECTIN;
     if ((dir & 1)) {
-       write_log ("PARAPORT: BUSY can't be output\n");
+       write_log (L"PARAPORT: BUSY can't be output\n");
        ok = 0;
     }
     if ((dir & 2)) {
-       write_log ("PARAPORT: POUT can't be output\n");
+       write_log (L"PARAPORT: POUT can't be output\n");
        ok = 0;
     }
     if ((dir & 4) && !(v & 4))
        c[0].Control |= PARAPORT_MASK_CONTROL_SELECTIN;
     if (!pp_executecycle (pport, c, 1)) {
-       write_log ("PARAPORT: write executeCycle failed, CTL=%02X DIR=%02X\n", v & 7, dir & 7);
+       write_log (L"PARAPORT: write executeCycle failed, CTL=%02X DIR=%02X\n", v & 7, dir & 7);
        return 0;
     }
-    para_log ("PARAPORT: write CTL=%02X DIR=%02X\n", v & 7, dir & 7);
+    para_log (L"PARAPORT: write CTL=%02X DIR=%02X\n", v & 7, dir & 7);
     return ok;
 }
 
@@ -286,7 +288,7 @@ int parallel_direct_read_status (uae_u8 *vp)
     memset (c + 0, 0, sizeof (PARAPORT_CYCLE));
     c[0].MaskStatus = PARAPORT_MASK_STATUS;
     if (!pp_executecycle (pport, c, 1)) {
-       write_log ("PARAPORT: CTL read executeCycle failed\n");
+       write_log (L"PARAPORT: CTL read executeCycle failed\n");
        return 0;
     }
     if (c[0].Status & PARAPORT_MASK_STATUS_SELECT)
@@ -303,7 +305,7 @@ int parallel_direct_read_status (uae_u8 *vp)
     } else {
        oldack = 0;
     }
-    para_log ("PARAPORT: read CTL=%02X\n", v);
+    para_log (L"PARAPORT: read CTL=%02X\n", v);
     v &= 7;
     *vp &= ~7;
     *vp |= v;
@@ -318,7 +320,7 @@ int parallel_direct_write_data (uae_u8 v, uae_u8 dir)
     if (!pport)
        return 0;
     if (dir != 0xff) {
-       write_log ("PARAPORT: unsupported mixed i/o attempted, DATA=%02X DIR=%02X, ignored\n", v, dir);
+       write_log (L"PARAPORT: unsupported mixed i/o attempted, DATA=%02X DIR=%02X, ignored\n", v, dir);
        return 0;
     }
     memset (c, 0, 3 * sizeof (PARAPORT_CYCLE));
@@ -333,10 +335,10 @@ int parallel_direct_write_data (uae_u8 v, uae_u8 dir)
     c[2].MaskControl = PARAPORT_MASK_CONTROL_STROBE;
 
     if (!pp_executecycle (pport, c, 3)) {
-       write_log ("PARAPORT: write executeCycle failed, data=%02X\n", v);
+       write_log (L"PARAPORT: write executeCycle failed, data=%02X\n", v);
        return 0;
     }
-    para_log ("PARAPORT: write DATA=%02X\n", v);
+    para_log (L"PARAPORT: write DATA=%02X\n", v);
     return 1;
 }
 
@@ -360,11 +362,11 @@ int parallel_direct_read_data (uae_u8 *v)
     c[2].MaskControl = PARAPORT_MASK_CONTROL_STROBE;
 
     if (!pp_executecycle (pport, c, 3)) {
-       write_log ("PARAPORT: DATA read executeCycle failed\n");
+       write_log (L"PARAPORT: DATA read executeCycle failed\n");
        return 0;
     }
     *v = c[0].Data;
-    para_log ("PARAPORT: read DATA=%02X\n", v);
+    para_log (L"PARAPORT: read DATA=%02X\n", v);
     return ok;
 }
 
index c3eb5c72e75f10f98c33e3fffb6689ebc132eb8b..1fbf2dd4e4c8463478197d2314850bdda21937d0 100644 (file)
@@ -5,5 +5,5 @@ void ioport_write (int,uae_u8);
 uae_u8 ioport_read (int);
 
 int paraport_init (void);
-int paraport_open (char*);
+int paraport_open (TCHAR*);
 void paraport_free (void);
index 8721649f02629ca309b2aa727aa286b31e54d4d0..34988ec8ee9677b9edb2705e686c31ea433a7d04 100644 (file)
@@ -421,10 +421,10 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
                } else {
                    int i;
                    for (i = 0; i < 4; i++) {
-                       if (!strcmp (currprefs.df[i], currprefs.dfxlist[num]))
+                       if (!_tcscmp (currprefs.df[i], currprefs.dfxlist[num]))
                            changed_prefs.df[i][0] = 0;
                    }
-                   strcpy (changed_prefs.df[swapperdrive], currprefs.dfxlist[num]);
+                   _tcscpy (changed_prefs.df[swapperdrive], currprefs.dfxlist[num]);
                }
            }
            break;
index 0a445cb7df1f983fba9b3e134dbb64d5ebb488c2..7bf6aacfa21741d71e54533ded92882ba470b4ba 100644 (file)
@@ -44,25 +44,25 @@ static int lcd_init(void)
     ret = lgLcdInit ();
     if (ret != ERROR_SUCCESS) {
        if (ret == RPC_S_SERVER_UNAVAILABLE || ret == ERROR_OLD_WIN_VERSION) {
-           write_log ("LCD: Logitech LCD system not detected\n");
+           write_log (L"LCD: Logitech LCD system not detected\n");
            return 0;
        }
-       write_log ("LCD: lgLcdInit() returned %d\n", ret);
+       write_log (L"LCD: lgLcdInit() returned %d\n", ret);
        return 0;
     }
     memset (&cctx, 0, sizeof (cctx));
-    cctx.appFriendlyName = "WinUAE";
+    cctx.appFriendlyName = L"WinUAE";
     cctx.isPersistent = TRUE;
     cctx.isAutostartable = FALSE;
     ret = lgLcdConnect (&cctx);
     if (ret != ERROR_SUCCESS) {
-       write_log ("LCD: lgLcdConnect() returned %d\n", ret);
+       write_log (L"LCD: lgLcdConnect() returned %d\n", ret);
        lcd_close();
        return 0;
     }
     ret = lgLcdEnumerate (cctx.connection, 0, &desc);
     if (ret != ERROR_SUCCESS) {
-       write_log ("LCD: lgLcdEnumerate() returned %d\n", ret);
+       write_log (L"LCD: lgLcdEnumerate() returned %d\n", ret);
        lcd_close();
        return 0;
     }
@@ -75,7 +75,7 @@ static int lcd_init(void)
     octx.index = 0;
     ret = lgLcdOpen (&octx);
     if (ret != ERROR_SUCCESS) {
-       write_log ("LCD: lgLcdOpen() returned %d\n", ret);
+       write_log (L"LCD: lgLcdOpen() returned %d\n", ret);
        lcd_close();
        return 0;
     }
@@ -94,7 +94,7 @@ static int lcd_init(void)
     memcpy (origbitmap, bitmap, desc.Width * desc.Height);
     DeleteDC (dc);
 
-    write_log ("LCD: Logitech LCD system initialized\n");
+    write_log (L"LCD: Logitech LCD system initialized\n");
     return 1;
 }
 
index 7b8bb25e9549b60577b72e8b01f2e9a7b5984981..0d281ed16d79691ccdcbc33d376b5a62cb9eb864 100644 (file)
@@ -1,4 +1,4 @@
-extern int lcd_open(void);
-extern void lcd_close(void);
-extern void lcd_update(int, int);
-extern void lcd_priority(int);
\ No newline at end of file
+extern int lcd_open (void);
+extern void lcd_close (void);
+extern void lcd_update (int, int);
+extern void lcd_priority (int);
\ No newline at end of file
index 7831a429c2680d4b30920cbfb50b7bc759b108e7..8a978a01309215dd48113526867c03ece9bd30f1 100644 (file)
@@ -57,7 +57,7 @@ extern int serdev;
 static HMIDIIN inHandle;
 static MIDIHDR midiin[MIDI_INBUFFERS];
 
-static char *inbuffer[MIDI_INBUFFERS] = { 0, 0} ;
+static uae_u8 *inbuffer[MIDI_INBUFFERS] = { 0, 0} ;
 static long inbufferlength[MIDI_INBUFFERS] = { 0,0};
 
 static int in_allocated = 0;
@@ -68,7 +68,7 @@ static MidiOutStatus out_status;
 static HMIDIOUT outHandle;
 static MIDIHDR midiout[MIDI_BUFFERS];
 
-static char *outbuffer[MIDI_BUFFERS] = { 0, 0 };
+static uae_u8 *outbuffer[MIDI_BUFFERS] = { 0, 0 };
 static long outbufferlength[MIDI_BUFFERS] = { 0, 0 };
 static int outbufferselect = 0;
 static int out_allocated = 0;
@@ -91,7 +91,7 @@ static CRITICAL_SECTION cs_proc;
  *   1999.09.06  1.0    Brian King             - Creation
  *
  */
-static char *getmidiouterr(char *txt, int err)
+static TCHAR *getmidiouterr(TCHAR *txt, int err)
 {
     midiOutGetErrorText(err, txt, MAX_DPATH);
     return txt;
@@ -131,7 +131,7 @@ static int MidiOut_Alloc(void)
        }
        outbufferselect = 0;
     } else {
-       write_log ("MIDI: ERROR - MidiOutAlloc() called twice?\n");
+       write_log (L"MIDI: ERROR - MidiOutAlloc() called twice?\n");
     }
     return out_allocated;
 }
@@ -188,7 +188,7 @@ static void MidiOut_Free(void)
 static int MidiOut_PrepareHeader(LPMIDIHDR out, LPSTR data, DWORD length)
 {
     int result = 1;
-    char err[MAX_DPATH];
+    TCHAR err[MAX_DPATH];
 
     out->lpData = data;
     out->dwBufferLength = length;
@@ -197,7 +197,7 @@ static int MidiOut_PrepareHeader(LPMIDIHDR out, LPSTR data, DWORD length)
     out->dwFlags = 0;
 
     if((result = midiOutPrepareHeader(outHandle, out, sizeof( MIDIHDR)))) {
-       write_log ( "MIDI: error %s / %d\n", getmidiouterr(err, result), result);
+       write_log (L"MIDI: error %s / %d\n", getmidiouterr (err, result), result);
        result = 0;
     }
     return result;
@@ -223,7 +223,7 @@ static int MidiOut_PrepareHeader(LPMIDIHDR out, LPSTR data, DWORD length)
  *   1999.09.06  1.0    Brian King             - Creation
  *
  */
-static char *getmidiinerr(char *txt, int err)
+static TCHAR *getmidiinerr(TCHAR *txt, int err)
 {
     midiInGetErrorText(err, txt, MAX_DPATH);
     return txt;
@@ -262,7 +262,7 @@ static int MidiIn_Alloc(void)
            }
        }
     } else {
-       write_log ("MIDI: ERROR - MidiInAlloc() called twice?\n");
+       write_log (L"MIDI: ERROR - MidiInAlloc() called twice?\n");
     }
     return in_allocated;
 }
@@ -298,7 +298,7 @@ static void MidiIn_Free( void )
     only_one_time = 0;
 }
 
-static unsigned char plen[128] = {
+static uae_u8 plen[128] = {
     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
     2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
@@ -333,7 +333,7 @@ int Midi_Parse(midi_direction_e direction, BYTE *dataptr)
 {
     int result = 0;
     static unsigned short bufferindex;
-    static char *bufferpoint = 0;
+    static uae_u8 *bufferpoint = 0;
 
     if(direction == midi_output) {
        BYTE data = *dataptr;
@@ -364,7 +364,7 @@ int Midi_Parse(midi_direction_e direction, BYTE *dataptr)
                        bufferindex = BUFFLEN - 1;
                    out_status.status = MIDI_SYSX;
                    // Flush this buffer using midiOutLongMsg
-                   MidiOut_PrepareHeader(&midiout[ outbufferselect ], bufferpoint, bufferindex);
+                   MidiOut_PrepareHeader(&midiout[outbufferselect], bufferpoint, bufferindex);
                    midiOutLongMsg(outHandle, &midiout[outbufferselect], sizeof(MIDIHDR));
                    outbufferselect = !outbufferselect;
                    bufferpoint = outbuffer[outbufferselect];
@@ -424,7 +424,7 @@ int Midi_Parse(midi_direction_e direction, BYTE *dataptr)
 
  */
 
-static unsigned char midibuf[BUFFLEN];
+static uae_u8 midibuf[BUFFLEN];
 static long midi_inptr = 0, midi_inlast = 0;
 
 static void add1byte(DWORD_PTR w) //put 1 Byte to Midibuffer
@@ -472,7 +472,7 @@ LONG getmidibyte(void) //return midibyte or -1 if none
 
     EnterCriticalSection (&cs_proc);
     if (overflow == 1) {
-       char szMessage[MAX_DPATH];
+       TCHAR szMessage[MAX_DPATH];
        WIN32GUI_LoadUIString(IDS_MIDIOVERFLOW, szMessage, MAX_DPATH);
        gui_message(szMessage);
        overflow = 0;
@@ -611,17 +611,17 @@ end:
 int Midi_Open(void)
 {
     unsigned long result = 0, i;
-    char err[MAX_DPATH];
+    TCHAR err[MAX_DPATH];
 
     if((result = midiOutOpen(&outHandle, currprefs.win32_midioutdev, 0, 0,CALLBACK_NULL))) {
-       write_log ("MIDI OUT: error %s / %d while opening port %d\n", getmidiouterr(err, result), result, currprefs.win32_midioutdev);
+       write_log (L"MIDI OUT: error %s / %d while opening port %d\n", getmidiouterr(err, result), result, currprefs.win32_midioutdev);
        result = 0;
     } else {
        InitializeCriticalSection(&cs_proc);
        // We don't need input for output...
        if((currprefs.win32_midiindev >= 0) &&
            (result = midiInOpen( &inHandle, currprefs.win32_midiindev, (DWORD_PTR)MidiInProc, 0, CALLBACK_FUNCTION|MIDI_IO_STATUS))) {
-           write_log ( "MIDI IN: error %s / %d while opening port %d\n", getmidiinerr(err, result), result, currprefs.win32_midiindev);
+           write_log (L"MIDI IN: error %s / %d while opening port %d\n", getmidiinerr(err, result), result, currprefs.win32_midiindev);
        } else {
            midi_in_ready = TRUE;
            result=midiInStart(inHandle);
@@ -700,7 +700,7 @@ void Midi_Close(void)
            exitin = 0;
        }
        midi_ready = FALSE;
-       write_log ("MIDI: closed.\n");
+       write_log (L"MIDI: closed.\n");
        DeleteCriticalSection(&cs_proc);
     }
 }
index 76dc49deba2f712c6c7abac44355631d8d89e5cb..bb17c1c74848d68e207d2e8056353cef0cc35ad3 100644 (file)
@@ -24,24 +24,24 @@ static int p96mem_size;
 static SYSTEM_INFO si;
 int maxmem;
 
-static void *virtualallocwithlock(LPVOID addr, SIZE_T size, DWORD allocationtype, DWORD protect)
+static void *virtualallocwithlock (LPVOID addr, SIZE_T size, DWORD allocationtype, DWORD protect)
 {
     void *p = VirtualAlloc (addr, size, allocationtype, protect);
     return p;
 }
-static void virtualfreewithlock(LPVOID addr, SIZE_T size, DWORD freetype)
+static void virtualfreewithlock (LPVOID addr, SIZE_T size, DWORD freetype)
 {
     VirtualFree(addr, size, freetype);
 }
 
-void cache_free(void *cache)
+void cache_free (void *cache)
 {
-    virtualfreewithlock(cache, 0, MEM_RELEASE);
+    virtualfreewithlock (cache, 0, MEM_RELEASE);
 }
 
-void *cache_alloc(int size)
+void *cache_alloc (int size)
 {
-    return virtualallocwithlock(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+    return virtualallocwithlock (NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
 }
 
 #if 0
@@ -99,40 +99,40 @@ static int testwritewatch (void)
 
     ps = si.dwPageSize;
 
-    pGetWriteWatch = (GETWRITEWATCH)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetWriteWatch");
+    pGetWriteWatch = (GETWRITEWATCH)GetProcAddress (GetModuleHandle (L"kernel32.dll"), "GetWriteWatch");
     if (pGetWriteWatch == NULL) {
-       write_log ("GetWriteWatch(): missing!?\n");
+       write_log (L"GetWriteWatch(): missing!?\n");
        return 0;
     }
     mem = VirtualAlloc (NULL, TEST_SIZE, MEM_RESERVE | MEM_WRITE_WATCH, PAGE_EXECUTE_READWRITE);
     if (mem == NULL) {
-       write_log ("GetWriteWatch(): MEM_WRITE_WATCH not supported!? err=%d\n", GetLastError());
+       write_log (L"GetWriteWatch(): MEM_WRITE_WATCH not supported!? err=%d\n", GetLastError());
        return 0;
     }
     if (VirtualAlloc (mem, TEST_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE) == NULL) {
-       write_log ("GetWriteWatch(): test memory area MEM_COMMIT failed!? err=%d\n", GetLastError());
+       write_log (L"GetWriteWatch(): test memory area MEM_COMMIT failed!? err=%d\n", GetLastError());
        goto end;
     }
     ResetWriteWatch (mem, TEST_SIZE);
     ((uae_u8*)mem)[1] = 0;
     gwwcnt = TEST_SIZE / ps;
-    if (GetWriteWatch(WRITE_WATCH_FLAG_RESET, mem, TEST_SIZE, pages, &gwwcnt, &ps)) {
-       write_log ("GetWriteWatch(): failed!? err=%d\n", GetLastError ());
+    if (GetWriteWatch (WRITE_WATCH_FLAG_RESET, mem, TEST_SIZE, pages, &gwwcnt, &ps)) {
+       write_log (L"GetWriteWatch(): failed!? err=%d\n", GetLastError ());
        goto end;
     }
     if (ps != si.dwPageSize) {
-       write_log ("GetWriteWatch(): pagesize %d != %d!?\n", si.dwPageSize, ps);
+       write_log (L"GetWriteWatch(): pagesize %d != %d!?\n", si.dwPageSize, ps);
        goto end;
     }
     if (gwwcnt != 1) {
-       write_log ("GetWriteWatch(): modified pages returned %d != 1!?\n", gwwcnt);
+       write_log (L"GetWriteWatch(): modified pages returned %d != 1!?\n", gwwcnt);
        goto end;
     }
     if (pages[0] != mem) {
-       write_log ("GetWriteWatch(): modified page was wrong!?\n");
+       write_log (L"GetWriteWatch(): modified page was wrong!?\n");
        goto end;
     }
-    write_log ("GetWriteWatch() test ok\n");
+    write_log (L"GetWriteWatch() test ok\n");
     ret = 1;
     memwatchok = 1;
 end:
@@ -167,12 +167,12 @@ void mman_ResetWatch (PVOID lpBaseAddress, SIZE_T dwRegionSize)
 {
     if (memwatchok) {
        if (ResetWriteWatch (lpBaseAddress, dwRegionSize))
-           write_log ("ResetWriteWatch() failed, %d\n", GetLastError ());
+           write_log (L"ResetWriteWatch() failed, %d\n", GetLastError ());
     } else {
        DWORD op;
        memset (memwatchtable, 0, p96mem_size / si.dwPageSize);
        if (!VirtualProtect (lpBaseAddress, dwRegionSize, PAGE_READWRITE | PAGE_GUARD, &op))
-           write_log ("VirtualProtect() failed, err=%d\n", GetLastError ());
+           write_log (L"VirtualProtect() failed, err=%d\n", GetLastError ());
     }
 }
 
@@ -216,7 +216,7 @@ void preinit_shm (void)
     GlobalMemoryStatus(&memstats);
     totalphys64 = memstats.dwTotalPhys;
     total64 = (uae_u64)memstats.dwAvailPageFile + (uae_u64)memstats.dwTotalPhys;
-    pGlobalMemoryStatusEx = (GLOBALMEMORYSTATUSEX)GetProcAddress(GetModuleHandle("kernel32.dll"), "GlobalMemoryStatusEx");
+    pGlobalMemoryStatusEx = (GLOBALMEMORYSTATUSEX)GetProcAddress (GetModuleHandle (L"kernel32.dll"), "GlobalMemoryStatusEx");
     if (pGlobalMemoryStatusEx) {
         memstatsex.dwLength = sizeof (MEMORYSTATUSEX);
         if (pGlobalMemoryStatusEx(&memstatsex)) {
@@ -253,7 +253,7 @@ void preinit_shm (void)
         shmids[i].name[0] = 0;
     }
 
-    write_log ("Max Z3FastRAM %dM. Total physical RAM %uM\n", max_z3fastmem >> 20, totalphys64 >> 20);
+    write_log (L"Max Z3FastRAM %dM. Total physical RAM %uM\n", max_z3fastmem >> 20, totalphys64 >> 20);
     testwritewatch ();
     canbang = 1;
 }
@@ -277,9 +277,9 @@ static void resetmem (void)
        shmaddr = natmem_offset + ((uae_u8*)s->attached - (uae_u8*)s->natmembase);
        result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, s->mode);
        if (result != shmaddr)
-           write_log ("NATMEM: realloc(%p,%d,%d) failed, err=%x\n", shmaddr, size, s->mode, GetLastError ());
+           write_log (L"NATMEM: realloc(%p,%d,%d) failed, err=%x\n", shmaddr, size, s->mode, GetLastError ());
        else
-           write_log ("NATMEM: rellocated(%p,%d,%s)\n", shmaddr, size, s->name);
+           write_log (L"NATMEM: rellocated(%p,%d,%s)\n", shmaddr, size, s->name);
     }
 }
 
@@ -293,7 +293,7 @@ restart:
        int lowround = 0;
        LPVOID blah = NULL;
        if (rounds > 0)
-           write_log ("NATMEM: retrying %d..\n", rounds);
+           write_log (L"NATMEM: retrying %d..\n", rounds);
        rounds++;
        if (natmem_offset)
            VirtualFree(natmem_offset, 0, MEM_RELEASE);
@@ -319,11 +319,11 @@ restart:
            int change = lowmem ();
            if (!change)
                return 0;
-           write_log ("NATMEM: %d, %dM > %dM = %dM\n", ++lowround, totalsize >> 20, size64 >> 20, (totalsize - change) >> 20);
+           write_log (L"NATMEM: %d, %dM > %dM = %dM\n", ++lowround, totalsize >> 20, size64 >> 20, (totalsize - change) >> 20);
            totalsize -= change;
        }
        if ((rounds > 1 && totalsize < 0x10000000) || rounds > 20) {
-           write_log ("NATMEM: No special area could be allocated (3)!\n");
+           write_log (L"NATMEM: No special area could be allocated (3)!\n");
            return 0;
        }
        natmemsize = size + z3size;
@@ -332,7 +332,7 @@ restart:
        memwatchtable = 0;
        if (currprefs.gfxmem_size) {
            if (!memwatchok) {
-               write_log ("GetWriteWatch() not supported, using guard pages, RTG performance will be slower.\n");
+               write_log (L"GetWriteWatch() not supported, using guard pages, RTG performance will be slower.\n");
                memwatchtable = xcalloc (currprefs.gfxmem_size / si.dwPageSize + 1, 1);
            }
        }
@@ -347,10 +347,10 @@ restart:
            natmem_offset = blah;
            break;
        }
-       write_log ("NATMEM: %dM area failed to allocate, err=%d (Z3=%dM,RTG=%dM)\n",
+       write_log (L"NATMEM: %dM area failed to allocate, err=%d (Z3=%dM,RTG=%dM)\n",
            natmemsize >> 20, GetLastError (), (currprefs.z3fastmem_size + currprefs.z3fastmem2_size) >> 20, currprefs.gfxmem_size >> 20);
        if (!lowmem ()) {
-           write_log ("NATMEM: No special area could be allocated (2)!\n");
+           write_log (L"NATMEM: No special area could be allocated (2)!\n");
            return 0;
        }
     }
@@ -358,7 +358,7 @@ restart:
     if (p96mem_size) {
        VirtualFree (natmem_offset, 0, MEM_RELEASE);
        if (!VirtualAlloc (natmem_offset, natmemsize + rtgbarrier, MEM_RESERVE, PAGE_READWRITE)) {
-           write_log ("VirtualAlloc() part 2 error %d. RTG disabled.\n", GetLastError ());
+           write_log (L"VirtualAlloc() part 2 error %d. RTG disabled.\n", GetLastError ());
            currprefs.gfxmem_size = changed_prefs.gfxmem_size = 0;
            rtgbarrier = si.dwPageSize;
            rtgextra = 0;
@@ -368,18 +368,18 @@ restart:
            MEM_RESERVE | (memwatchok == 1 ? MEM_WRITE_WATCH : 0), PAGE_READWRITE);
        if (!p96mem_offset) {
            currprefs.gfxmem_size = changed_prefs.gfxmem_size = 0;
-           write_log ("NATMEM: failed to allocate special Picasso96 GFX RAM, err=%d\n", GetLastError ());
+           write_log (L"NATMEM: failed to allocate special Picasso96 GFX RAM, err=%d\n", GetLastError ());
        }
     }
 
     if (!natmem_offset) {
-       write_log ("NATMEM: No special area could be allocated! (1) err=%d\n", GetLastError ());
+       write_log (L"NATMEM: No special area could be allocated! (1) err=%d\n", GetLastError ());
     } else {
-       write_log ("NATMEM: Our special area: 0x%p-0x%p (%08x %dM)\n",
+       write_log (L"NATMEM: Our special area: 0x%p-0x%p (%08x %dM)\n",
            natmem_offset, (uae_u8*)natmem_offset + natmemsize,
            natmemsize, natmemsize >> 20);
        if (currprefs.gfxmem_size)
-           write_log ("NATMEM: P96 special area: 0x%p-0x%p (%08x %dM)\n",
+           write_log (L"NATMEM: P96 special area: 0x%p-0x%p (%08x %dM)\n",
                p96mem_offset, (uae_u8*)p96mem_offset + currprefs.gfxmem_size,
                currprefs.gfxmem_size, currprefs.gfxmem_size >> 20);
        canbang = 1;
@@ -471,58 +471,58 @@ void *shmat (int shmid, void *shmaddr, int shmflg)
        return shmids[shmid].attached;
 
     if ((uae_u8*)shmaddr < natmem_offset) {
-       if(!strcmp(shmids[shmid].name,"chip")) {
+       if(!_tcscmp (shmids[shmid].name, L"chip")) {
            shmaddr=natmem_offset;
            got = TRUE;
            if (currprefs.fastmem_size == 0 || currprefs.chipmem_size < 2 * 1024 * 1024)
                size += BARRIER;
        }
-       if(!strcmp(shmids[shmid].name,"kick")) {
+       if(!_tcscmp (shmids[shmid].name, L"kick")) {
            shmaddr=natmem_offset + 0xf80000;
            got = TRUE;
            size += BARRIER;
        }
-       if(!strcmp(shmids[shmid].name,"rom_a8")) {
+       if(!_tcscmp (shmids[shmid].name, L"rom_a8")) {
            shmaddr=natmem_offset + 0xa80000;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"rom_e0")) {
+       if(!_tcscmp (shmids[shmid].name, L"rom_e0")) {
            shmaddr=natmem_offset + 0xe00000;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"rom_f0")) {
+       if(!_tcscmp (shmids[shmid].name, L"rom_f0")) {
            shmaddr=natmem_offset + 0xf00000;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"rtarea")) {
+       if(!_tcscmp (shmids[shmid].name, L"rtarea")) {
            shmaddr=natmem_offset + rtarea_base;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"fast")) {
+       if(!_tcscmp (shmids[shmid].name, L"fast")) {
            shmaddr=natmem_offset + 0x200000;
            got = TRUE;
            size += BARRIER;
        }
-       if(!strcmp(shmids[shmid].name,"ramsey_low")) {
+       if(!_tcscmp (shmids[shmid].name, L"ramsey_low")) {
            shmaddr=natmem_offset + a3000lmem_start;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"ramsey_high")) {
+       if(!_tcscmp (shmids[shmid].name, L"ramsey_high")) {
            shmaddr=natmem_offset + a3000hmem_start;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"z3")) {
+       if(!_tcscmp (shmids[shmid].name, L"z3")) {
            shmaddr=natmem_offset + currprefs.z3fastmem_start;
            if (!currprefs.z3fastmem2_size)
                size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"z3_2")) {
+       if(!_tcscmp (shmids[shmid].name, L"z3_2")) {
            shmaddr=natmem_offset + currprefs.z3fastmem_start + currprefs.z3fastmem_size;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"gfx")) {
+       if(!_tcscmp (shmids[shmid].name, L"gfx")) {
            got = TRUE;
            p96special = TRUE;
            p96ram_start = p96mem_offset - natmem_offset;
@@ -531,13 +531,13 @@ void *shmat (int shmid, void *shmaddr, int shmflg)
            if (!memwatchok)
                protect |= PAGE_GUARD;
        }
-       if(!strcmp(shmids[shmid].name,"bogo")) {
+       if(!_tcscmp (shmids[shmid].name, L"bogo")) {
            shmaddr=natmem_offset+0x00C00000;
            got = TRUE;
            if (currprefs.bogomem_size <= 0x100000)
                size += BARRIER;
        }
-       if(!strcmp(shmids[shmid].name,"filesys")) {
+       if(!_tcscmp (shmids[shmid].name, L"filesys")) {
            static uae_u8 *filesysptr;
            if (filesysptr == NULL)
                filesysptr = xcalloc (size, 1);
@@ -545,60 +545,60 @@ void *shmat (int shmid, void *shmaddr, int shmflg)
            shmids[shmid].attached = result;
            return result;
        }
-       if(!strcmp(shmids[shmid].name,"custmem1")) {
+       if(!_tcscmp (shmids[shmid].name, L"custmem1")) {
            shmaddr=natmem_offset + currprefs.custom_memory_addrs[0];
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"custmem2")) {
+       if(!_tcscmp (shmids[shmid].name, L"custmem2")) {
            shmaddr=natmem_offset + currprefs.custom_memory_addrs[1];
            got = TRUE;
        }
 
-       if(!strcmp(shmids[shmid].name,"hrtmem")) {
+       if(!_tcscmp (shmids[shmid].name, L"hrtmem")) {
            shmaddr=natmem_offset + 0x00a10000;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"arhrtmon")) {
+       if(!_tcscmp (shmids[shmid].name, L"arhrtmon")) {
            shmaddr=natmem_offset + 0x00800000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"xpower_e2")) {
+       if(!_tcscmp (shmids[shmid].name, L"xpower_e2")) {
            shmaddr=natmem_offset + 0x00e20000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"xpower_f2")) {
+       if(!_tcscmp (shmids[shmid].name, L"xpower_f2")) {
            shmaddr=natmem_offset + 0x00f20000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"nordic_f0")) {
+       if(!_tcscmp (shmids[shmid].name, L"nordic_f0")) {
            shmaddr=natmem_offset + 0x00f00000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"nordic_f4")) {
+       if(!_tcscmp (shmids[shmid].name, L"nordic_f4")) {
            shmaddr=natmem_offset + 0x00f40000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"nordic_f6")) {
+       if(!_tcscmp (shmids[shmid].name, L"nordic_f6")) {
            shmaddr=natmem_offset + 0x00f60000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"superiv_b0")) {
+       if(!_tcscmp(shmids[shmid].name, L"superiv_b0")) {
            shmaddr=natmem_offset + 0x00b00000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"superiv_d0")) {
+       if(!_tcscmp (shmids[shmid].name, L"superiv_d0")) {
            shmaddr=natmem_offset + 0x00d00000;
            size += BARRIER;
            got = TRUE;
        }
-       if(!strcmp(shmids[shmid].name,"superiv_e0")) {
+       if(!_tcscmp (shmids[shmid].name, L"superiv_e0")) {
            shmaddr=natmem_offset + 0x00e00000;
            size += BARRIER;
            got = TRUE;
@@ -614,14 +614,14 @@ void *shmat (int shmid, void *shmaddr, int shmflg)
        result = virtualallocwithlock (shmaddr, size, MEM_COMMIT, protect);
        if (result == NULL) {
            result = (void*)-1;
-           write_log ("VirtualAlloc %08X - %08X %x (%dk) failed %d\n",
+           write_log (L"VirtualAlloc %08X - %08X %x (%dk) failed %d\n",
                (uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size,
                size, size >> 10, GetLastError ());
         } else {
            shmids[shmid].attached = result;
-           write_log ("VirtualAlloc %08X - %08X %x (%dk) ok%s\n",
+           write_log (L"VirtualAlloc %08X - %08X %x (%dk) ok%s\n",
                (uae_u8*)shmaddr - natmem_offset, (uae_u8*)shmaddr - natmem_offset + size,
-               size, size >> 10, p96special ? " P96" : "");
+               size, size >> 10, p96special ? L" P96" : L"");
        }
     }
     return result;
@@ -632,15 +632,15 @@ int shmdt (const void *shmaddr)
     return 0;
 }
 
-int shmget (key_t key, size_t size, int shmflg, const char *name)
+int shmget (key_t key, size_t size, int shmflg, const TCHAR *name)
 {
     int result = -1;
 
     if((key == IPC_PRIVATE) || ((shmflg & IPC_CREAT) && (find_shmkey (key) == -1))) {
-       write_log ("shmget of size %d (%dk) for %s\n", size, size >> 10, name);
+       write_log (L"shmget of size %d (%dk) for %s\n", size, size >> 10, name);
        if ((result = get_next_shmkey ()) != -1) {
            shmids[result].size = size;
-           strcpy(shmids[result].name, name);
+           _tcscpy (shmids[result].name, name);
        } else {
            result = -1;
        }
index 49ba216869664016dfe57d8ee61119e53b999a6b..5ef52c22f548243aa45fc1f04e1b151441863108 100644 (file)
@@ -61,13 +61,13 @@ static PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
 
 static PIXELFORMATDESCRIPTOR pfd;
 
-static void testerror (char *s)
+static void testerror (TCHAR *s)
 {
     for (;;) {
        GLint err = glGetError();
        if (err == 0)
            return;
-       write_log ("OpenGL error %d (%s)\n", err, s);
+       write_log (L"OpenGL error %d (%s)\n", err, s);
     }
 }
 
@@ -85,11 +85,11 @@ static int arbMultisampleFormat;
 #ifdef FSAA
 
 // WGLisExtensionSupported: This Is A Form Of The Extension For WGL
-static int WGLisExtensionSupported(const char *extension)
+static int WGLisExtensionSupported(const TCHAR *extension)
 {
        const size_t extlen = strlen(extension);
-       const char *supported = NULL;
-       const char *p;
+       const TCHAR *supported = NULL;
+       const TCHAR *p;
 
        // Try To Use wglGetExtensionStringARB On Current DC, If Possible
        PROC wglGetExtString = wglGetProcAddress("wglGetExtensionsStringARB");
@@ -169,26 +169,26 @@ static int InitMultisample(HDC hDC, PIXELFORMATDESCRIPTOR *pfd)
            if (valid && numFormats >= 1) {
                arbMultisampleSupported = i;
                arbMultisampleFormat = pixelFormat;
-               write_log ("OPENGL: max FSAA = %d\n", i);
+               write_log (L"OPENGL: max FSAA = %d\n", i);
                return arbMultisampleSupported;
            }
        }
        // Return The Valid Format
-       write_log ("OPENGL: no FSAA support detected\n");
+       write_log (L"OPENGL: no FSAA support detected\n");
        return  arbMultisampleSupported;
 }
 #endif
 
-const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
+const TCHAR *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
 {
     int PixelFormat;
     const char *ext1;
-    static char errmsg[100] = { 0 };
+    static TCHAR errmsg[100] = { 0 };
     static int init;
 
     ogl_enabled = 0;
     if (currprefs.gfx_filter != UAE_FILTER_OPENGL) {
-       strcpy (errmsg, "OPENGL: not enabled");
+       _tcscpy (errmsg, L"OPENGL: not enabled");
        return errmsg;
     }
 
@@ -202,7 +202,7 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     total_textures = 2;
 
     if (isfullscreen() > 0 && WIN32GFX_GetDepth (TRUE) < 15) {
-       strcpy (errmsg, "OPENGL: display depth must be at least 15 bit");
+       _tcscpy (errmsg, L"OPENGL: display depth must be at least 15 bit");
        return errmsg;
     }
 
@@ -220,7 +220,7 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
        if (!arbMultisampleSupported) {
            PixelFormat = ChoosePixelFormat (openglhdc, &pfd);  // Find A Compatible Pixel Format
            if (PixelFormat == 0) {                             // Did We Find A Compatible Format?
-               strcpy (errmsg, "OPENGL: can't find suitable pixelformat");
+               _tcscpy (errmsg, L"OPENGL: can't find suitable pixelformat");
                return errmsg;
            }
        } else {
@@ -228,24 +228,24 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
        }
 
        if (!SetPixelFormat (openglhdc, PixelFormat, &pfd)) {
-           sprintf (errmsg, "OPENGL: can't set pixelformat %x", PixelFormat);
+           _stprintf (errmsg, L"OPENGL: can't set pixelformat %x", PixelFormat);
            return errmsg;
        }
 
        if (!(hrc = wglCreateContext (openglhdc))) {
-           strcpy (errmsg, "OPENGL: can't create gl rendering context");
+           _tcscpy (errmsg, L"OPENGL: can't create gl rendering context");
            return errmsg;
        }
 
        if (!wglMakeCurrent (openglhdc, hrc)) {
-           strcpy (errmsg, "OPENGL: can't activate gl rendering context");
+           _tcscpy (errmsg, L"OPENGL: can't activate gl rendering context");
            return errmsg;
        }
 #ifdef FSAA
        if(!arbMultisampleSupported) {
            if(InitMultisample(openglhdc, &pfd)) {
                OGL_free ();
-               strcpy (errmsg, "*");
+               _tcscpy (errmsg, "*");
                return errmsg;
            }
        }
@@ -256,28 +256,28 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size);
     required_texture_size = 2 << exact_log2 (t_width > t_height ? t_width : t_height);
     if (max_texture_size < t_width || max_texture_size < t_height) {
-       sprintf (errmsg, "OPENGL: %d * %d or bigger texture support required\nYour gfx card's maximum texture size is only %d * %d",
+       _stprintf (errmsg, L"OPENGL: %d * %d or bigger texture support required\nYour gfx card's maximum texture size is only %d * %d",
            required_texture_size, required_texture_size, max_texture_size, max_texture_size);
        return errmsg;
     }
     required_sl_texture_size = 2 << exact_log2 (w_width > w_height ? w_width : w_height);
     if (currprefs.gfx_filter_scanlines > 0 && (max_texture_size < w_width || max_texture_size < w_height)) {
-       gui_message ("OPENGL: %d * %d or bigger texture support required for scanlines (max is only %d * %d)\n"
-           "Scanlines disabled.",
+       gui_message (L"OPENGL: %d * %d or bigger texture support required for scanlines (max is only %d * %d)\n"
+           L"Scanlines disabled.",
            required_sl_texture_size, required_sl_texture_size, max_texture_size, max_texture_size);
        changed_prefs.gfx_filter_scanlines = currprefs.gfx_filter_scanlines = 0;
     }
 
     ext1 = glGetString (GL_EXTENSIONS);
     if (!init)
-       write_log ("OpenGL extensions: %s\n", ext1);
+       write_log (L"OpenGL extensions: %s\n", ext1);
     if (strstr (ext1, "EXT_packed_pixels"))
        packed_pixels = 1;
     if (strstr (ext1, "WGL_EXT_swap_control")) {
        wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress ("wglSwapIntervalEXT");
        wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress ("wglGetSwapIntervalEXT");
        if (!wglGetSwapIntervalEXT || !wglSwapIntervalEXT) {
-           write_log ("OPENGL: WGL_EXT_swap_control extension found but no wglGetSwapIntervalEXT or wglSwapIntervalEXT found!?\n");
+           write_log (L"OPENGL: WGL_EXT_swap_control extension found but no wglGetSwapIntervalEXT or wglSwapIntervalEXT found!?\n");
            wglSwapIntervalEXT = 0;
            wglGetSwapIntervalEXT = 0;
        }
@@ -290,8 +290,8 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     ti2d_type = -1;
     if (depth == 15 || depth == 16) {
        if (!packed_pixels) {
-           sprintf (errmsg, "OPENGL: can't use 15/16 bit screen depths because\n"
-               "EXT_packed_pixels extension was not found.");
+           _stprintf (errmsg, L"OPENGL: can't use 15/16 bit screen depths because\n"
+               L"EXT_packed_pixels extension was not found.");
            OGL_free ();
            return errmsg;
        }
@@ -310,7 +310,7 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
        }
     }
     if (ti2d_type < 0) {
-       sprintf (errmsg, "OPENGL: Only 15, 16 or 32 bit screen depths supported (was %d)", depth);
+       _stprintf (errmsg, L"OPENGL: Only 15, 16 or 32 bit screen depths supported (was %d)", depth);
        OGL_free ();
        return errmsg;
     }
@@ -338,7 +338,7 @@ const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth)
     OGL_refresh ();
     init = 1;
 
-    write_log ("OPENGL: using texture depth %d texture size %d * %d scanline texture size %d * %d\n",
+    write_log (L"OPENGL: using texture depth %d texture size %d * %d scanline texture size %d * %d\n",
        depth, required_texture_size, required_texture_size, required_sl_texture_size, required_sl_texture_size);
     return 0;
 }
@@ -472,7 +472,7 @@ static void OGL_dorender (int newtex)
     float dw, dh;
 
     getfilterrect2 (&dr, &sr, &zr, w_width, w_height, t_width, t_height, 1, t_width, t_height);
-//    write_log ("(%d %d %d %d) - (%d %d %d %d) (%d %d)\n",
+//    write_log (L"(%d %d %d %d) - (%d %d %d %d) (%d %d)\n",
 //     dr.left, dr.top, dr.right, dr.bottom, sr.left, sr.top, sr.right, sr.bottom, zr.left, zr.top);
     dw = dr.right - dr.left;
     dh = dr.bottom - dr.top;
@@ -481,7 +481,7 @@ static void OGL_dorender (int newtex)
 
     multx = dw * t_width / w_width;
     multy = dh * t_height / w_height;
-//    write_log ("%fx%f\n", multx, multy);
+//    write_log (L"%fx%f\n", multx, multy);
 
     x1 = -0.5f + dw * t_width / w_width / 2 - zr.left - sr.left;
     y1 =  0.5f + dh * t_height / w_height / 2 - zr.top - (t_height - 2 * zr.top - h) + sr.top;
index 870c2b48d64074958e56db4efa69ade7d685b61e..44c4f52ea2d93dc7e0939ab9b3e4879f1df1173c 100644 (file)
@@ -1,7 +1,7 @@
 
 extern void OGL_resize (int width, int height);
 extern void OGL_free ();
-extern const char *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth);
+extern const TCHAR *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth);
 extern void OGL_render (void);
 extern void OGL_getpixelformat (int depth,int *rb, int *bb, int *gb, int *rs, int *bs, int *gs, int *ab, int *ar, int *a);
 extern void OGL_refresh (void);
index 62575af7e624cce542f95ec5972af3b79d5cdeb5..582c292ab91f36b5648765ce96fb03767a5d8deb 100644 (file)
@@ -59,7 +59,7 @@ static HANDLE hPrt = INVALID_HANDLE_VALUE;
 static DWORD  dwJob;
 static int prtopen;
 extern void flushpixels(void);
-void DoSomeWeirdPrintingStuff(char val);
+void DoSomeWeirdPrintingStuff(uae_char val);
 static int uartbreak;
 static int parflush;
 
@@ -119,38 +119,48 @@ static void freepsbuffers (void)
 
 static int openprinter_ps (void)
 {
-    char *gsargv[] = {
-       "-dNOPAUSE", "-dBATCH", "-dNOPAGEPROMPT", "-dNOPROMPT", "-dQUIET", "-dNoCancel",
-       "-sDEVICE=mswinpr2", NULL
+    TCHAR *gsargv[] = {
+       L"-dNOPAUSE", L"-dBATCH", L"-dNOPAGEPROMPT", L"-dNOPROMPT", L"-dQUIET", L"-dNoCancel",
+       L"-sDEVICE=mswinpr2", NULL
     };
     int gsargc, gsargc2, i;
-    char *tmpparms[100];
-    char tmp[MAX_DPATH];
+    TCHAR *tmpparms[100];
+    TCHAR tmp[MAX_DPATH];
+    char *gsparms[100];
 
     if (ptr_gsapi_new_instance (&gsinstance, NULL) < 0)
        return 0;
-    tmpparms[0] = "WinUAE";
+    tmpparms[0] = L"WinUAE";
     gsargc2 = cmdlineparser (currprefs.ghostscript_parameters, tmpparms + 1, 100 - 10) + 1;
-    for (gsargc = 0; gsargv[gsargc]; gsargc++);
+
+    for (gsargc = 0; gsargv[gsargc]; gsargc++) {
+       gsparms[gsargc] = ua (gsargv[gsargc]);
+    }
     for (i = 0; i < gsargc; i++)
-       tmpparms[gsargc2++] = gsargv[i];
+       gsparms[gsargc2++] = ua (tmpparms[i]);
     if (currprefs.prtname[0]) {
-       sprintf (tmp, "-sOutputFile=%%printer%%%s", currprefs.prtname);
-       tmpparms[gsargc2++] = tmp;
+       _stprintf (tmp, L"-sOutputFile=%%printer%%%s", currprefs.prtname);
+       gsparms[gsargc2++] = ua (tmp);
     }
     if (postscript_print_debugging) {
-       for(i = 0; i < gsargc2; i++)
-           write_log ("GSPARM%d: '%s'\n", i, tmpparms[i]);
+       for(i = 0; i < gsargc2; i++) {
+           TCHAR *parm = au (gsparms[i]);
+           write_log (L"GSPARM%d: '%s'\n", i, parm);
+           xfree (parm);
+       }
     }
     __try {
-       int rc = ptr_gsapi_init_with_args (gsinstance, gsargc2, tmpparms);
+       int rc = ptr_gsapi_init_with_args (gsinstance, gsargc2, gsparms);
+       for (i = 0; i < gsargc2; i++) {
+           xfree (gsparms[i]);
+       }
        if (rc != 0) {
-           write_log ("GS failed, returncode %d\n", rc);
+           write_log (L"GS failed, returncode %d\n", rc);
            return 0;
        }
        ptr_gsapi_run_string_begin (gsinstance, 0, &gs_exitcode);
     } __except (ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
-       write_log ("GS crashed\n");
+       write_log (L"GS crashed\n");
        return 0;
     }
     psmode = 1;
@@ -168,14 +178,14 @@ static void *prt_thread (void *p)
     SetThreadPriority (GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
     if (load_ghostscript ()) {
        if (openprinter_ps ()) {
-           write_log ("PostScript printing emulation started..\n");
+           write_log (L"PostScript printing emulation started..\n");
            cnt = 0;
            while (buffers[cnt]) {
                uae_u8 *p = buffers[cnt];
                err = ptr_gsapi_run_string_continue (gsinstance, p + 2, (p[0] << 8) | p[1], 0, &gs_exitcode);
                if (err != e_NeedInput && err <= e_Fatal) {
                    ptr_gsapi_exit (gsinstance);
-                   write_log ("PostScript parsing failed.\n");
+                   write_log (L"PostScript parsing failed.\n");
                    ok = 0;
                    break;
                }
@@ -188,14 +198,14 @@ static void *prt_thread (void *p)
            }
            free (buffers);
            if (ok) {
-               write_log ("PostScript printing emulation finished..\n");
+               write_log (L"PostScript printing emulation finished..\n");
                ptr_gsapi_run_string_end (gsinstance, 0, &gs_exitcode);
            }
        } else {
-           write_log ("gsdll32.dll failed to initialize\n");
+           write_log (L"gsdll32.dll failed to initialize\n");
        }
     } else {
-       write_log ("gsdll32.dll failed to load\n");
+       write_log (L"gsdll32.dll failed to load\n");
     }
     unload_ghostscript ();
     prt_running--;
@@ -228,12 +238,12 @@ static void flushprtbuf (void)
     } else if (hPrt != INVALID_HANDLE_VALUE) {
        if (WritePrinter(hPrt, prtbuf, prtbufbytes, &written)) {
            if (written != prtbufbytes)
-               write_log ("PRINTER: Only wrote %d of %d bytes!\n", written, prtbufbytes);
+               write_log (L"PRINTER: Only wrote %d of %d bytes!\n", written, prtbufbytes);
        } else {
-           write_log ("PRINTER: Couldn't write data!\n");
+           write_log (L"PRINTER: Couldn't write data!\n");
        }
     } else {
-       write_log ("PRINTER: Not open!\n");
+       write_log (L"PRINTER: Not open!\n");
     }
     prtbufbytes = 0;
 }
@@ -243,9 +253,9 @@ void finishjob (void)
     flushprtbuf ();
 }
 
-static void DoSomeWeirdPrintingStuff (char val)
+static void DoSomeWeirdPrintingStuff (uae_char val)
 {
-    static char prev[5];
+    static uae_char prev[5];
 
     memmove (prev, prev + 1, 3);
     prev[3] = val;
@@ -256,7 +266,7 @@ static void DoSomeWeirdPrintingStuff (char val)
            *prtbuf = val;
            prtbufbytes = 1;
            flushprtbuf ();
-           write_log ("PostScript end detected..\n");
+           write_log (L"PostScript end detected..\n");
 
            if (postscript_print_debugging) {
                zfile_fclose (prtdump);
@@ -265,7 +275,7 @@ static void DoSomeWeirdPrintingStuff (char val)
 
            if (currprefs.parallel_postscript_emulation) {
                prt_started = 0;
-               if (uae_start_thread ("postscript", prt_thread, psbuffer, NULL)) {
+               if (uae_start_thread (L"postscript", prt_thread, psbuffer, NULL)) {
                    while (!prt_started)
                        Sleep (5);
                    psbuffers = 0;
@@ -279,7 +289,7 @@ static void DoSomeWeirdPrintingStuff (char val)
        } else if (!psmode && !stricmp (prev, "%!PS")) {
 
            if (postscript_print_debugging)
-               prtdump = zfile_fopen ("psdump.dat", "wb");
+               prtdump = zfile_fopen (L"psdump.dat", L"wb");
 
            psmode = 1;
            psbuffer = malloc (sizeof (uae_u8*));
@@ -288,7 +298,7 @@ static void DoSomeWeirdPrintingStuff (char val)
            strcpy (prtbuf, "%!PS");
            prtbufbytes = strlen (prtbuf);
            flushprtbuf ();
-           write_log ("PostScript start detected..\n");
+           write_log (L"PostScript start detected..\n");
            return;
        }
     }
@@ -305,7 +315,7 @@ int isprinter (void)
 {
     if (!currprefs.prtname[0])
        return 0;
-    if (!memcmp(currprefs.prtname,"LPT", 3)) {
+    if (!_tcsncmp (currprefs.prtname, L"LPT", 3)) {
        paraport_open (currprefs.prtname);
        return -1;
     }
@@ -322,33 +332,34 @@ int isprinteropen (void)
 int load_ghostscript (void)
 {
     struct gsapi_revision_s r;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
+    TCHAR *s;
 
     if (gsdll)
        return 1;
-    strcpy(path, "gsdll32.dll");
+    _tcscpy(path, L"gsdll32.dll");
     gsdll = WIN32_LoadLibrary (path);
     if (!gsdll) {
-       if (GetEnvironmentVariable ("GS_DLL", path, sizeof (path)))
+       if (GetEnvironmentVariable (L"GS_DLL", path, sizeof (path) / sizeof (TCHAR)))
            gsdll = LoadLibrary (path);
     }
     if (!gsdll) {
        HKEY key;
-       DWORD ret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\AFPL Ghostscript", 0, KEY_READ, &key);
-       if (ret |= ERROR_SUCCESS)
-           ret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, "SOFTWARE\\GPL Ghostscript", 0, KEY_READ, &key);
+       DWORD ret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\AFPL Ghostscript", 0, KEY_READ, &key);
+       if (ret != ERROR_SUCCESS)
+           ret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\GPL Ghostscript", 0, KEY_READ, &key);
        if (ret == ERROR_SUCCESS) {
            int idx = 0, cnt = 20;
-           char tmp1[MAX_DPATH];
+           TCHAR tmp1[MAX_DPATH];
            while (cnt-- > 0) {
-               DWORD size1 = sizeof (tmp1);
+               DWORD size1 = sizeof (tmp1) / sizeof (TCHAR);
                FILETIME ft;
                if (RegEnumKeyEx (key, idx, tmp1, &size1, NULL, NULL, NULL, &ft) == ERROR_SUCCESS) {
                    HKEY key2;
                    if (RegOpenKeyEx (key, tmp1, 0, KEY_READ, &key2) == ERROR_SUCCESS) {
                        DWORD type = REG_SZ;
-                       DWORD size = sizeof (path);
-                       if (RegQueryValueEx (key2, "GS_DLL", 0, &type, (LPBYTE)path, &size) == ERROR_SUCCESS) {
+                       DWORD size = sizeof (path) / sizeof (TCHAR);
+                       if (RegQueryValueEx (key2, L"GS_DLL", 0, &type, (LPBYTE)path, &size) == ERROR_SUCCESS) {
                            gsdll = LoadLibrary (path);
                        }
                        RegCloseKey (key2);
@@ -366,12 +377,12 @@ int load_ghostscript (void)
     ptr_gsapi_revision = (GSAPI_REVISION)GetProcAddress (gsdll, "gsapi_revision");
     if (!ptr_gsapi_revision) {
        unload_ghostscript ();
-       write_log ("incompatible %s! (1)\n", path);
+       write_log (L"incompatible %s! (1)\n", path);
        return -1;
     }
     if (ptr_gsapi_revision(&r, sizeof(r))) {
        unload_ghostscript ();
-       write_log ("incompatible %s! (2)\n", path);
+       write_log (L"incompatible %s! (2)\n", path);
        return -2;
     }
     ptr_gsapi_new_instance = (GSAPI_NEW_INSTANCE)GetProcAddress (gsdll, "gsapi_new_instance");
@@ -386,10 +397,12 @@ int load_ghostscript (void)
        !ptr_gsapi_run_string_begin || !ptr_gsapi_run_string_continue || !ptr_gsapi_run_string_end ||
        !ptr_gsapi_init_with_args) {
        unload_ghostscript ();
-       write_log ("incompatible %s! (3)\n", path);
+       write_log (L"incompatible %s! (3)\n", path);
        return -3;
     }
-    write_log ("%s: %s rev %d initialized\n", path, r.product, r.revision);
+    s = au (r.product);
+    write_log (L"%s: %s rev %d initialized\n", path, s, r.revision);
+    xfree (s);
     return 1;
 }
 
@@ -422,9 +435,9 @@ void openprinter( void )
        flushprtbuf ();
        if (OpenPrinter (currprefs.prtname, &hPrt, NULL)) {
            // Fill in the structure with info about this "document."
-           DocInfo.pDocName = "My Document";
+           DocInfo.pDocName = L"My Document";
            DocInfo.pOutputFile = NULL;
-           DocInfo.pDatatype = "RAW";
+           DocInfo.pDatatype = L"RAW";
            // Inform the spooler the document is beginning.
            if ((dwJob = StartDocPrinter(hPrt, 1, (LPSTR)&DocInfo)) == 0) {
                ClosePrinter(hPrt );
@@ -437,9 +450,9 @@ void openprinter( void )
        }
     }
     if (hPrt != INVALID_HANDLE_VALUE) {
-       write_log ( "PRINTER: Opening printer \"%s\" with handle 0x%x.\n", currprefs.prtname, hPrt );
+       write_log (L"PRINTER: Opening printer \"%s\" with handle 0x%x.\n", currprefs.prtname, hPrt);
     } else if (*currprefs.prtname) {
-       write_log ( "PRINTER: ERROR - Couldn't open printer \"%s\" for output.\n", currprefs.prtname );
+       write_log (L"PRINTER: ERROR - Couldn't open printer \"%s\" for output.\n", currprefs.prtname);
     }
 }
 
@@ -460,14 +473,14 @@ void closeprinter( void   )
        EndDocPrinter (hPrt);
        ClosePrinter (hPrt);
        hPrt = INVALID_HANDLE_VALUE;
-       write_log ("PRINTER: Closing printer.\n");
+       write_log (L"PRINTER: Closing printer.\n");
     }
     if (currprefs.parallel_postscript_emulation)
        prtopen = 1;
     else
        prtopen = 0;
     if (prt_running) {
-       write_log ("waiting for printing to finish...\n");
+       write_log (L"waiting for printing to finish...\n");
        while (prt_running)
            Sleep (10);
     }
@@ -592,7 +605,7 @@ int uaeser_setparams (struct uaeserialdatawin32 *sd, int baud, int rbuffer, int
     //dcb.XonLim = 2048;
 
     if (!SetCommState (sd->hCom, &dcb)) {
-       write_log ("uaeserial: SetCommState() failed %d\n", GetLastError());
+       write_log (L"uaeserial: SetCommState() failed %d\n", GetLastError());
        return 5;
     }
     SetupComm (sd->hCom, rbuffer, rbuffer);
@@ -694,11 +707,11 @@ void uaeser_clearbuffers (struct uaeserialdatawin32 *sd)
 
 int uaeser_open (struct uaeserialdatawin32 *sd, void *user, int unit)
 {
-    char buf[256];
+    TCHAR buf[256];
     COMMTIMEOUTS CommTimeOuts;
 
     sd->user = user;
-    sprintf (buf, "\\\\.\\COM%d", unit);
+    _stprintf (buf, L"\\\\.\\COM%d", unit);
     sd->evtr = CreateEvent (NULL, TRUE, FALSE, NULL);
     sd->evtw = CreateEvent (NULL, TRUE, FALSE, NULL);
     sd->evtt = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -711,17 +724,17 @@ int uaeser_open (struct uaeserialdatawin32 *sd, void *user, int unit)
     sd->hCom = CreateFile (buf, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
     if (sd->hCom == INVALID_HANDLE_VALUE) {
-       sprintf (buf, "\\.\\\\COM%d", unit);
+       _stprintf (buf, L"\\.\\\\COM%d", unit);
        sd->hCom = CreateFile (buf, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
        if (sd->hCom == INVALID_HANDLE_VALUE) {
-           write_log ("UAESER: '%s' failed to open, err=%d\n", buf, GetLastError());
+           write_log (L"UAESER: '%s' failed to open, err=%d\n", buf, GetLastError());
            goto end;
        }
     }
     uae_sem_init (&sd->sync_sem, 0, 0);
     uae_sem_init (&sd->change_sem, 0, 1);
-    uae_start_thread ("uaeserial_win32", uaeser_trap_thread, sd, NULL);
+    uae_start_thread (L"uaeserial_win32", uaeser_trap_thread, sd, NULL);
     uae_sem_wait (&sd->sync_sem);
 
     CommTimeOuts.ReadIntervalTimeout = 0;
@@ -772,18 +785,18 @@ static int dataininput, dataininputcnt;
 static OVERLAPPED writeol, readol;
 static writepending;
 
-int openser (char *sername)
+int openser (TCHAR *sername)
 {
     COMMTIMEOUTS CommTimeOuts;
 
     if (!(readevent = CreateEvent (NULL, TRUE, FALSE, NULL))) {
-       write_log ("SERIAL: Failed to create r event!\n");
+       write_log (L"SERIAL: Failed to create r event!\n");
        return 0;
     }
     readol.hEvent = readevent;
 
     if (!(writeevent = CreateEvent (NULL, TRUE, FALSE, NULL))) {
-       write_log ("SERIAL: Failed to create w event!\n");
+       write_log (L"SERIAL: Failed to create w event!\n");
        return 0;
     }
     SetEvent (writeevent);
@@ -798,7 +811,7 @@ int openser (char *sername)
                            FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
                            NULL);
     if (hCom == INVALID_HANDLE_VALUE) {
-       write_log ("SERIAL: failed to open '%s' err=%d\n", sername, GetLastError());
+       write_log (L"SERIAL: failed to open '%s' err=%d\n", sername, GetLastError());
        closeser();
        return 0;
     }
@@ -847,11 +860,11 @@ int openser (char *sername)
     //dcb.XonLim = 2048;
 
     if (SetCommState (hCom, &dcb)) {
-       write_log ("SERIAL: Using %s CTS/RTS=%d\n", sername, currprefs.serial_hwctsrts);
+       write_log (L"SERIAL: Using %s CTS/RTS=%d\n", sername, currprefs.serial_hwctsrts);
        return 1;
     }
 
-    write_log ("SERIAL: serial driver didn't accept new parameters\n");
+    write_log (L"SERIAL: serial driver didn't accept new parameters\n");
     closeser();
     return 0;
 }
@@ -892,14 +905,14 @@ void writeser (int c)
 {
     if (midi_ready) {
        BYTE outchar = (BYTE)c;
-       Midi_Parse(midi_output, &outchar);
+       Midi_Parse (midi_output, &outchar);
     } else {
        if (!currprefs.use_serial)
            return;
-       if (datainoutput + 1 < sizeof(outputbuffer)) {
+       if (datainoutput + 1 < sizeof (outputbuffer)) {
            outputbuffer[datainoutput++] = c;
        } else {
-           write_log ("serial output buffer overflow, data will be lost\n");
+           write_log (L"serial output buffer overflow, data will be lost\n");
            datainoutput = 0;
        }
        outser ();
@@ -1038,7 +1051,7 @@ int setbaud (long baud)
         /* MIDI baud-rate */
        if (!midi_ready) {
            if (Midi_Open())
-               write_log ("Midi enabled\n");
+               write_log (L"Midi enabled\n");
        }
        return 1;
     } else {
@@ -1051,11 +1064,11 @@ int setbaud (long baud)
            if (GetCommState (hCom, &dcb))  {
                dcb.BaudRate = baud;
                if (!SetCommState (hCom, &dcb)) {
-                   write_log ("SERIAL: Error setting baud rate %d!\n", baud);
+                   write_log (L"SERIAL: Error setting baud rate %d!\n", baud);
                    return 0;
                }
            } else {
-               write_log ("SERIAL: setbaud internal error!\n");
+               write_log (L"SERIAL: setbaud internal error!\n");
            }
        }
     }
@@ -1067,7 +1080,7 @@ void initparallel (void)
     if (uae_boot_rom) {
        uaecptr a = here (); //this install the ahisound
        org (rtarea_base + 0xFFC0);
-       calltrap (deftrapres (ahi_demux, 0, "ahi_winuae"));
+       calltrap (deftrapres (ahi_demux, 0, L"ahi_winuae"));
        dw (RTS);
        org (a);
        init_ahi_v2 ();
@@ -1135,61 +1148,61 @@ static int enumserialports_2(void)
     SP_DEVICE_INTERFACE_DETAIL_DATA *pDetData = NULL;
     BOOL bOk = TRUE;
     SP_DEVICE_INTERFACE_DATA ifcData;
-    DWORD dwDetDataSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA) + 256;
+    DWORD dwDetDataSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA) + 256;
     DWORD ii;
     int cnt = 0;
 
-    hDevInfo = SetupDiGetClassDevs(&GUID_CLASS_COMPORT, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+    hDevInfo = SetupDiGetClassDevs (&GUID_CLASS_COMPORT, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
     if(hDevInfo == INVALID_HANDLE_VALUE)
        return 0;
     // Enumerate the serial ports
     pDetData = xmalloc (dwDetDataSize);
     // This is required, according to the documentation. Yes,
     // it's weird.
-    ifcData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
-    pDetData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
+    ifcData.cbSize = sizeof (SP_DEVICE_INTERFACE_DATA);
+    pDetData->cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
     for (ii = 0; bOk; ii++) {
-       bOk = SetupDiEnumDeviceInterfaces(hDevInfo, NULL, &GUID_CLASS_COMPORT, ii, &ifcData);
+       bOk = SetupDiEnumDeviceInterfaces (hDevInfo, NULL, &GUID_CLASS_COMPORT, ii, &ifcData);
        if (bOk) {
            // Got a device. Get the details.
-           SP_DEVINFO_DATA devdata = {sizeof(SP_DEVINFO_DATA)};
-           bOk = SetupDiGetDeviceInterfaceDetail(hDevInfo,
+           SP_DEVINFO_DATA devdata = { sizeof (SP_DEVINFO_DATA)};
+           bOk = SetupDiGetDeviceInterfaceDetail (hDevInfo,
                &ifcData, pDetData, dwDetDataSize, NULL, &devdata);
            if (bOk) {
                // Got a path to the device. Try to get some more info.
                TCHAR fname[256];
                TCHAR desc[256];
-               BOOL bSuccess = SetupDiGetDeviceRegistryProperty(
+               BOOL bSuccess = SetupDiGetDeviceRegistryProperty (
                    hDevInfo, &devdata, SPDRP_FRIENDLYNAME, NULL,
-                   (PBYTE)fname, sizeof(fname), NULL);
-               bSuccess = bSuccess && SetupDiGetDeviceRegistryProperty(
+                   (PBYTE)fname, sizeof (fname), NULL);
+               bSuccess = bSuccess && SetupDiGetDeviceRegistryProperty (
                    hDevInfo, &devdata, SPDRP_DEVICEDESC, NULL,
-                   (PBYTE)desc, sizeof(desc), NULL);
+                   (PBYTE)desc, sizeof (desc), NULL);
                if (bSuccess && cnt < MAX_SERIAL_PORTS) {
-                   char *p;
+                   TCHAR *p;
                    comports[cnt].dev = my_strdup (pDetData->DevicePath);
                    comports[cnt].name = my_strdup (fname);
-                   p = strstr(fname,"(COM");
+                   p = _tcsstr (fname, L"(COM");
                    if (p && (p[5] == ')' || p[6] == ')')) {
                        comports[cnt].cfgname = xmalloc (100);
                        if (isdigit(p[5]))
-                           sprintf(comports[cnt].cfgname, "COM%c%c", p[4], p[5]);
+                           _stprintf (comports[cnt].cfgname, L"COM%c%c", p[4], p[5]);
                        else
-                           sprintf(comports[cnt].cfgname, "COM%c", p[4]);
+                           _stprintf (comports[cnt].cfgname, L"COM%c", p[4]);
                    } else {
                        comports[cnt].cfgname = my_strdup (pDetData->DevicePath);
                    }
-                   write_log ("SERPORT: '%s' = '%s' = '%s'\n", comports[cnt].name, comports[cnt].cfgname, comports[cnt].dev);
+                   write_log (L"SERPORT: '%s' = '%s' = '%s'\n", comports[cnt].name, comports[cnt].cfgname, comports[cnt].dev);
                    cnt++;
                }
            } else {
-               write_log ("SetupDiGetDeviceInterfaceDetail failed, err=%d", GetLastError());
+               write_log (L"SetupDiGetDeviceInterfaceDetail failed, err=%d", GetLastError ());
                goto end;
            }
        } else {
            DWORD err = GetLastError();
            if (err != ERROR_NO_MORE_ITEMS) {
-               write_log ("SetupDiEnumDeviceInterfaces failed, err=%d", err);
+               write_log (L"SetupDiEnumDeviceInterfaces failed, err=%d", err);
                goto end;
            }
        }
@@ -1197,67 +1210,67 @@ static int enumserialports_2(void)
 end:
     xfree(pDetData);
     if (hDevInfo != INVALID_HANDLE_VALUE)
-       SetupDiDestroyDeviceInfoList(hDevInfo);
+       SetupDiDestroyDeviceInfoList (hDevInfo);
     return cnt;
 }
 
 int enumserialports(void)
 {
     int cnt, i, j;
-    char name[256];
-    DWORD size = sizeof(COMMCONFIG);
-    char devname[1000];
+    TCHAR name[256];
+    DWORD size = sizeof (COMMCONFIG);
+    TCHAR devname[1000];
 
-    write_log ("Serial port enumeration..\n");
-    cnt = enumserialports_2();
+    write_log (L"Serial port enumeration..\n");
+    cnt = enumserialports_2 ();
     for (i = 0; i < 10; i++) {
-       sprintf(name, "COM%d", i);
-       if (!QueryDosDevice(name, devname, sizeof devname))
+       _stprintf(name, L"COM%d", i);
+       if (!QueryDosDevice (name, devname, sizeof devname))
            continue;
        for(j = 0; j < cnt; j++) {
-           if (!strcmp(comports[j].cfgname, name))
+           if (!_tcscmp(comports[j].cfgname, name))
                break;
        }
        if (j == cnt) {
            if (cnt >= MAX_SERIAL_PORTS)
                break;
-           comports[j].dev = xmalloc(100);
-           sprintf(comports[cnt].dev, "\\.\\\\%s", name);
+           comports[j].dev = xmalloc (100);
+           _stprintf (comports[cnt].dev, L"\\.\\\\%s", name);
            comports[j].cfgname = my_strdup (name);
            comports[j].name = my_strdup (name);
-           write_log ("SERPORT: %d:'%s' = '%s' (%s)\n", cnt, comports[j].name, comports[j].dev, devname);
+           write_log (L"SERPORT: %d:'%s' = '%s' (%s)\n", cnt, comports[j].name, comports[j].dev, devname);
            cnt++;
        }
     }
     if (isIPC (COMPIPENAME)) {
-        comports[j].dev = xmalloc(100);
-       sprintf (comports[cnt].dev, "\\\\.\\pipe\\%s", COMPIPENAME);
+        comports[j].dev = xmalloc (100);
+       _stprintf (comports[cnt].dev, L"\\\\.\\pipe\\%s", COMPIPENAME);
        comports[j].cfgname = my_strdup (COMPIPENAME);
         comports[j].name = my_strdup (COMPIPENAME);
     }
-    write_log ("Serial port enumeration end\n");
+    write_log (L"Serial port enumeration end\n");
     return cnt;
 }
 
-void sernametodev(char *sername)
+void sernametodev(TCHAR *sername)
 {
     int i;
 
     for (i = 0; i < MAX_SERIAL_PORTS && comports[i].name; i++) {
-       if (!strcmp(sername, comports[i].cfgname)) {
-           strcpy (sername, comports[i].dev);
+       if (!_tcscmp(sername, comports[i].cfgname)) {
+           _tcscpy (sername, comports[i].dev);
            return;
        }
     }
     sername[0] = 0;
 }
 
-void serdevtoname(char *sername)
+void serdevtoname(TCHAR *sername)
 {
     int i;
     for (i = 0; i < MAX_SERIAL_PORTS && comports[i].name; i++) {
-       if (!strcmp(sername, comports[i].dev)) {
-           strcpy (sername, comports[i].cfgname);
+       if (!_tcscmp(sername, comports[i].dev)) {
+           _tcscpy (sername, comports[i].cfgname);
            return;
        }
     }
index 88a300a36ccd226b3f65be387fe27606f91da54a..e03c339a0b79a86567ec9a3ab425dd6a7411fea9 100644 (file)
@@ -15,7 +15,7 @@ void setserstat (int mask, int onoff);
 int readser (int *buffer);
 int readseravail (void);
 void writeser (int c);
-int openser (char *sername);
+int openser (TCHAR *sername);
 void closeser (void);
 void doserout (void);
 void closeprinter (void);
@@ -36,13 +36,13 @@ extern int load_ghostscript (void);
 #define MAX_SERIAL_PORTS 32
 struct serialportinfo
 {
-    char *dev;
-    char *cfgname;
-    char *name;
+    TCHAR *dev;
+    TCHAR *cfgname;
+    TCHAR *name;
 };
 extern struct serialportinfo comports[MAX_SERIAL_PORTS];
 
-extern int enumserialports(void);
-extern void sernametodev(char*);
-extern void serdevtoname(char*);
+extern int enumserialports (void);
+extern void sernametodev (TCHAR*);
+extern void serdevtoname (TCHAR*);
 
index 725faea539c9056e36b146046b0c2e8871ed6744..cecd26264258c4d1cfa5055b38aa7b8ab1ad2682 100644 (file)
@@ -189,11 +189,11 @@ static void checkrtglibrary(void)
            uae_u16 ver = get_word (v + 20);
            uae_u16 rev = get_word (v + 22);
            if (ver * 10000 + rev < UAE_RTG_LIBRARY_VERSION * 10000 + UAE_RTG_LIBRARY_REVISION) {
-               char msg[2000];
+               TCHAR msg[2000];
                WIN32GUI_LoadUIString(IDS_OLDRTGLIBRARY, msg, sizeof(msg));
                gui_message(msg, ver, rev, UAE_RTG_LIBRARY_VERSION, UAE_RTG_LIBRARY_REVISION);
            } else {
-               write_log ("P96: rtg.library %d.%d detected\n", ver, rev);
+               write_log (L"P96: rtg.library %d.%d detected\n", ver, rev);
            }
            checked = TRUE;
        }
@@ -226,31 +226,31 @@ static void endianswap (uae_u32 *vp, int bpp)
 */
 static void DumpModeInfoStructure (uaecptr amigamodeinfoptr)
 {
-    write_log ("ModeInfo Structure Dump:\n");
-    write_log ("  Node.ln_Succ  = 0x%x\n", get_long (amigamodeinfoptr));
-    write_log ("  Node.ln_Pred  = 0x%x\n", get_long (amigamodeinfoptr + 4));
-    write_log ("  Node.ln_Type  = 0x%x\n", get_byte (amigamodeinfoptr + 8));
-    write_log ("  Node.ln_Pri   = %d\n", get_byte (amigamodeinfoptr + 9));
-    /*write_log ("  Node.ln_Name  = %s\n", uaememptr->Node.ln_Name); */
-    write_log ("  OpenCount     = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_OpenCount));
-    write_log ("  Active        = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Active));
-    write_log ("  Width         = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Width));
-    write_log ("  Height        = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Height));
-    write_log ("  Depth         = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Depth));
-    write_log ("  Flags         = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Flags));
-    write_log ("  HorTotal      = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorTotal));
-    write_log ("  HorBlankSize  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize));
-    write_log ("  HorSyncStart  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart));
-    write_log ("  HorSyncSize   = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize));
-    write_log ("  HorSyncSkew   = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew));
-    write_log ("  HorEnableSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew));
-    write_log ("  VerTotal      = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerTotal));
-    write_log ("  VerBlankSize  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize));
-    write_log ("  VerSyncStart  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart));
-    write_log ("  VerSyncSize   = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize));
-    write_log ("  Clock         = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_first_union));
-    write_log ("  ClockDivide   = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_second_union));
-    write_log ("  PixelClock    = %d\n", get_long (amigamodeinfoptr + PSSO_ModeInfo_PixelClock));
+    write_log (L"ModeInfo Structure Dump:\n");
+    write_log (L"  Node.ln_Succ  = 0x%x\n", get_long (amigamodeinfoptr));
+    write_log (L"  Node.ln_Pred  = 0x%x\n", get_long (amigamodeinfoptr + 4));
+    write_log (L"  Node.ln_Type  = 0x%x\n", get_byte (amigamodeinfoptr + 8));
+    write_log (L"  Node.ln_Pri   = %d\n", get_byte (amigamodeinfoptr + 9));
+    /*write_log (L"  Node.ln_Name  = %s\n", uaememptr->Node.ln_Name); */
+    write_log (L"  OpenCount     = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_OpenCount));
+    write_log (L"  Active        = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Active));
+    write_log (L"  Width         = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Width));
+    write_log (L"  Height        = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Height));
+    write_log (L"  Depth         = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Depth));
+    write_log (L"  Flags         = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Flags));
+    write_log (L"  HorTotal      = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorTotal));
+    write_log (L"  HorBlankSize  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize));
+    write_log (L"  HorSyncStart  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart));
+    write_log (L"  HorSyncSize   = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize));
+    write_log (L"  HorSyncSkew   = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew));
+    write_log (L"  HorEnableSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew));
+    write_log (L"  VerTotal      = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerTotal));
+    write_log (L"  VerBlankSize  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize));
+    write_log (L"  VerSyncStart  = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart));
+    write_log (L"  VerSyncSize   = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize));
+    write_log (L"  Clock         = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_first_union));
+    write_log (L"  ClockDivide   = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_second_union));
+    write_log (L"  PixelClock    = %d\n", get_long (amigamodeinfoptr + PSSO_ModeInfo_PixelClock));
 }
 
 static void DumpLibResolutionStructure (uaecptr amigalibresptr)
@@ -259,29 +259,29 @@ static void DumpLibResolutionStructure (uaecptr amigalibresptr)
     uaecptr amigamodeinfoptr;
     struct LibResolution *uaememptr = (struct LibResolution *)get_mem_bank(amigalibresptr).xlateaddr(amigalibresptr);
 
-    write_log ("LibResolution Structure Dump:\n");
+    write_log (L"LibResolution Structure Dump:\n");
 
     if (get_long (amigalibresptr + PSSO_LibResolution_DisplayID) == 0xFFFFFFFF) {
-       write_log ("  Finished With LibResolutions...\n");
+       write_log (L"  Finished With LibResolutions...\n");
     } else {
-       write_log ("  Name      = %s\n", uaememptr->P96ID);
-       write_log ("  DisplayID = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_DisplayID));
-       write_log ("  Width     = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Width));
-       write_log ("  Height    = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Height));
-       write_log ("  Flags     = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Flags));
+       write_log (L"  Name      = %s\n", uaememptr->P96ID);
+       write_log (L"  DisplayID = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_DisplayID));
+       write_log (L"  Width     = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Width));
+       write_log (L"  Height    = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Height));
+       write_log (L"  Flags     = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Flags));
        for (i = 0; i < MAXMODES; i++) {
            amigamodeinfoptr = get_long (amigalibresptr + PSSO_LibResolution_Modes + i*4);
-           write_log ("  ModeInfo[%d] = 0x%x\n", i, amigamodeinfoptr);
+           write_log (L"  ModeInfo[%d] = 0x%x\n", i, amigamodeinfoptr);
            if (amigamodeinfoptr)
                DumpModeInfoStructure (amigamodeinfoptr);
        }
-       write_log ("  BoardInfo = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_BoardInfo));
+       write_log (L"  BoardInfo = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_BoardInfo));
     }
 }
 
-static char binary_byte[9] = { 0,0,0,0,0,0,0,0,0 };
+static TCHAR binary_byte[9] = { 0,0,0,0,0,0,0,0,0 };
 
-static char *BuildBinaryString (uae_u8 value)
+static TCHAR *BuildBinaryString (uae_u8 value)
 {
     int i;
     for (i = 0; i < 8; i++) {
@@ -297,9 +297,9 @@ static void DumpPattern (struct Pattern *patt)
     for (row = 0; row < (1 << patt->Size); row++) {
        mem = patt->Memory + row * 2;
        for (col = 0; col < 2; col++) {
-           write_log ("%s ", BuildBinaryString (*mem++));
+           write_log (L"%s ", BuildBinaryString (*mem++));
        }
-       write_log ("\n");
+       write_log (L"\n");
     }
 }
 
@@ -308,35 +308,35 @@ static void DumpTemplate (struct Template *tmp, unsigned long w, unsigned long h
     uae_u8 *mem = tmp->Memory;
     unsigned int row, col, width;
     width = (w + 7) >> 3;
-    write_log ("xoffset = %d, bpr = %d\n", tmp->XOffset, tmp->BytesPerRow);
+    write_log (L"xoffset = %d, bpr = %d\n", tmp->XOffset, tmp->BytesPerRow);
     for (row = 0; row < h; row++) {
        mem = tmp->Memory + row * tmp->BytesPerRow;
        for (col = 0; col < width; col++) {
-           write_log ("%s ", BuildBinaryString (*mem++));
+           write_log (L"%s ", BuildBinaryString (*mem++));
        }
-       write_log ("\n");
+       write_log (L"\n");
     }
 }
 
 static void DumpLine(struct Line *line)
 {
     if (line) {
-       write_log ("Line->X = %d\n", line->X);
-       write_log ("Line->Y = %d\n", line->Y);
-       write_log ("Line->Length = %d\n", line->Length);
-       write_log ("Line->dX = %d\n", line->dX);
-       write_log ("Line->dY = %d\n", line->dY);
-       write_log ("Line->sDelta = %d\n", line->sDelta);
-       write_log ("Line->lDelta = %d\n", line->lDelta);
-       write_log ("Line->twoSDminusLD = %d\n", line->twoSDminusLD);
-       write_log ("Line->LinePtrn = %d\n", line->LinePtrn);
-       write_log ("Line->PatternShift = %d\n", line->PatternShift);
-       write_log ("Line->FgPen = 0x%x\n", line->FgPen);
-       write_log ("Line->BgPen = 0x%x\n", line->BgPen);
-       write_log ("Line->Horizontal = %d\n", line->Horizontal);
-       write_log ("Line->DrawMode = %d\n", line->DrawMode);
-       write_log ("Line->Xorigin = %d\n", line->Xorigin);
-       write_log ("Line->Yorigin = %d\n", line->Yorigin);
+       write_log (L"Line->X = %d\n", line->X);
+       write_log (L"Line->Y = %d\n", line->Y);
+       write_log (L"Line->Length = %d\n", line->Length);
+       write_log (L"Line->dX = %d\n", line->dX);
+       write_log (L"Line->dY = %d\n", line->dY);
+       write_log (L"Line->sDelta = %d\n", line->sDelta);
+       write_log (L"Line->lDelta = %d\n", line->lDelta);
+       write_log (L"Line->twoSDminusLD = %d\n", line->twoSDminusLD);
+       write_log (L"Line->LinePtrn = %d\n", line->LinePtrn);
+       write_log (L"Line->PatternShift = %d\n", line->PatternShift);
+       write_log (L"Line->FgPen = 0x%x\n", line->FgPen);
+       write_log (L"Line->BgPen = 0x%x\n", line->BgPen);
+       write_log (L"Line->Horizontal = %d\n", line->Horizontal);
+       write_log (L"Line->DrawMode = %d\n", line->DrawMode);
+       write_log (L"Line->Xorigin = %d\n", line->Xorigin);
+       write_log (L"Line->Yorigin = %d\n", line->Yorigin);
     }
 }
 
@@ -344,12 +344,12 @@ static void ShowSupportedResolutions (void)
 {
     int i = 0;
 
-    write_log ("-----------------\n");
+    write_log (L"-----------------\n");
     while (newmodes[i].depth >= 0) {
-       write_log ("%s\n", newmodes[i].name);
+       write_log (L"%s\n", newmodes[i].name);
        i++;
     }
-    write_log ("-----------------\n");
+    write_log (L"-----------------\n");
 }
 
 #endif
@@ -400,7 +400,7 @@ static int CopyRenderInfoStructureA2U (uaecptr amigamemptr, struct RenderInfo *r
        ri->RGBFormat = get_long (amigamemptr + PSSO_RenderInfo_RGBFormat);
        return 1;
     }
-    write_log ("ERROR - Invalid RenderInfo memory area...\n");
+    write_log (L"ERROR - Invalid RenderInfo memory area...\n");
     return 0;
 }
 
@@ -417,7 +417,7 @@ static int CopyPatternStructureA2U (uaecptr amigamemptr, struct Pattern *pattern
        pattern->DrawMode = get_byte (amigamemptr + PSSO_Pattern_DrawMode);
        return 1;
     }
-    write_log ("ERROR - Invalid Pattern memory area...\n");
+    write_log (L"ERROR - Invalid Pattern memory area...\n");
     return 0;
 }
 
@@ -478,7 +478,7 @@ static int CopyTemplateStructureA2U (uaecptr amigamemptr, struct Template *tmpl)
        tmpl->BgPen = get_long (amigamemptr + PSSO_Template_BgPen);
        return 1;
     }
-    write_log ("ERROR - Invalid Template memory area...\n");
+    write_log (L"ERROR - Invalid Template memory area...\n");
     return 0;
 }
 
@@ -503,7 +503,7 @@ static int CopyLineStructureA2U(uaecptr amigamemptr, struct Line *line)
        line->Yorigin = get_word (amigamemptr + PSSO_Line_Yorigin);
        return 1;
     }
-    write_log ("ERROR - Invalid Line structure...\n");
+    write_log (L"ERROR - Invalid Line structure...\n");
     return 0;
 }
 
@@ -873,7 +873,7 @@ static void setconvert (void)
        alloc_colors_rgb (8, 8, 8, 16, 8, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc);
     else
        alloc_colors_rgb (5, 6, 5, 11, 5, 0, 0, 0, 0, 0, p96rc, p96gc, p96bc);
-    write_log ("RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n", d, host_mode, picasso96_state.RGBFormat, v);
+    write_log (L"RTG conversion: Depth=%d HostRGBF=%d P96RGBF=%d Mode=%d\n", d, host_mode, picasso96_state.RGBFormat, v);
     recursor ();
     full_refresh = 1;
 }
@@ -939,7 +939,7 @@ void picasso_refresh (void)
        }
        flushpixels ();
     } else {
-       write_log ("ERROR - picasso_refresh() can't refresh!\n");
+       write_log (L"ERROR - picasso_refresh() can't refresh!\n");
     }
 }
 
@@ -1164,7 +1164,7 @@ static int do_blitrect_frame_buffer (struct RenderInfo *ri, struct
     src = ri->Memory + srcx * Bpp + srcy * ri->BytesPerRow;
     dst = dstri->Memory + dstx * Bpp + dsty * dstri->BytesPerRow;
     if (mask != 0xFF && Bpp > 1) {
-       write_log ("WARNING - BlitRect() has mask 0x%x with Bpp %d.\n", mask, Bpp);
+       write_log (L"WARNING - BlitRect() has mask 0x%x with Bpp %d.\n", mask, Bpp);
     }
 
     P96TRACE (("(%dx%d)=(%dx%d)=(%dx%d)=%d\n", srcx, srcy, dstx, dsty, width, height, opcode));
@@ -1424,7 +1424,7 @@ void picasso_clearcursor (void)
     ddrval = IDirectDrawSurface7_Blt (dstsurf, &cursor_r1, dxdata.cursorsurface2, &cursor_r2, DDBLT_WAIT, NULL);
     if (FAILED(ddrval)) {
        if (ddrval != DDERR_SURFACELOST)
-           write_log ("Cursor surface clearblit failed: %s\n", DXError (ddrval));
+           write_log (L"Cursor surface clearblit failed: %s\n", DXError (ddrval));
     }
 }
 
@@ -1556,7 +1556,7 @@ int createwindowscursor (uaecptr src, int w, int h, int hiressprite, int doubled
            }
        }
     }
-    write_log ("wincursor: %dx%d hires=%d doubled=%d\n", w2, h2, hiressprite, doubledsprite);
+    write_log (L"wincursor: %dx%d hires=%d doubled=%d\n", w2, h2, hiressprite, doubledsprite);
 
     xfree (tmp_sprite_data);
     tmp_sprite_data = NULL;
@@ -1647,7 +1647,7 @@ end:
     }
 
     if (!ret)
-       write_log ("RTG Windows color cursor creation failed\n");
+       write_log (L"RTG Windows color cursor creation failed\n");
 
 exit:
     if (currprefs.input_tablet && currprefs.input_magic_mouse && currprefs.input_magic_mouse_cursor == MAGICMOUSE_NATIVE_ONLY) {
@@ -1798,7 +1798,7 @@ static uae_u32 setspriteimage (uaecptr bi)
        if (ddrval == DDERR_SURFACELOST) {
            ddrval = IDirectDrawSurface7_Restore (dxdata.cursorsurface1);
            if (FAILED(ddrval)) {
-               write_log ("sprite surface failed to restore: %s\n", DXError (ddrval));
+               write_log (L"sprite surface failed to restore: %s\n", DXError (ddrval));
                goto end;
            }
        }
@@ -2040,7 +2040,7 @@ static int AssignModeID (int w, int h, int *unkcnt)
            return 0x50001000 | (mi[i].id * 0x10000);
     }
     (*unkcnt)++;
-    write_log ("P96: Non-unique mode %dx%d\n", w, h);
+    write_log (L"P96: Non-unique mode %dx%d\n", w, h);
     return 0x51001000 - (*unkcnt) * 0x10000;
 }
 
@@ -2074,7 +2074,7 @@ static void init_alloc (void)
        int size = get_long (uaegfx_base + CARD_RESLISTSIZE);
        picasso96_amem = get_long (uaegfx_base + CARD_RESLIST);
        picasso96_amemend = picasso96_amem + size;
-       write_log("P96 RESINFO: %08X-%08X (%d,%d)\n", picasso96_amem, picasso96_amemend, size / PSSO_ModeInfo_sizeof, size);
+       write_log (L"P96 RESINFO: %08X-%08X (%d,%d)\n", picasso96_amem, picasso96_amemend, size / PSSO_ModeInfo_sizeof, size);
     }
     xfree (gwwbuf);
     GetSystemInfo (&si);
@@ -2114,7 +2114,7 @@ void picasso96_alloc (TrapContext *ctx)
     struct MultiDisplay *md = getdisplay (&currprefs);
     struct PicassoResolution *DisplayModes = md->DisplayModes;
 
-    uaegfx_resname = ds ("uaegfx.card");
+    uaegfx_resname = ds (L"uaegfx.card");
     xfree (newmodes);
     newmodes = NULL;
     picasso96_amem = picasso96_amemend = 0;
@@ -2162,7 +2162,7 @@ void picasso96_alloc (TrapContext *ctx)
                memcpy (pr, &DisplayModes[i], sizeof (struct PicassoResolution));
                pr->res.width = missmodes[misscnt * 2 + 0];
                pr->res.height = missmodes[misscnt * 2 + 1];
-               sprintf (pr->name, "%dx%d FAKE", pr->res.width, pr->res.height);
+               _stprintf (pr->name, L"%dx%d FAKE", pr->res.width, pr->res.height);
                size += PSSO_ModeInfo_sizeof * depths;
                cnt++;
                misscnt++;
@@ -2272,12 +2272,12 @@ static void uaegfxversion (uaecptr bi)
        if (romtagp == addr) {
            uaecptr ver = get_long (addr + 18);
            if (valid_address (ver, 8)) {
-               char *vers = my_strdup (get_real_address (ver));
+               TCHAR *vers = my_strdup (get_real_address (ver));
                int version = get_byte (addr + 11);
                while (strlen (vers) > 0 && (vers[strlen (vers) - 1] == 10 || vers[strlen (vers) - 1] == 13))
                    vers[strlen (vers) - 1] = 0;
 
-               write_log ("P96: v%d %08X %s\n", version, addr, vers);
+               write_log (L"P96: v%d %08X %s\n", version, addr, vers);
                if (version == 1) {
                    static int warned;
                    if (!warned)
@@ -2292,7 +2292,7 @@ static void uaegfxversion (uaecptr bi)
        }
     }
     if (!ok)
-       write_log ("P96: uaegfx.card not detected!?\n");
+       write_log (L"P96: uaegfx.card not detected!?\n");
 }
 #endif
 
@@ -2306,7 +2306,7 @@ static void inituaegfx (uaecptr ABI)
     cursordeactivate = 0;
     reloadcursor = 0;
 
-    write_log ("RTG mode mask: %x\n", currprefs.picasso96_modeflags);
+    write_log (L"RTG mode mask: %x\n", currprefs.picasso96_modeflags);
     put_word (ABI + PSSO_BoardInfo_BitsPerCannon, 8);
     put_word (ABI + PSSO_BoardInfo_RGBFormats, currprefs.picasso96_modeflags);
     put_long (ABI + PSSO_BoardInfo_BoardType, picasso96_BT);
@@ -2341,24 +2341,24 @@ static void inituaegfx (uaecptr ABI)
     if (flags & BIF_HARDWARESPRITE) {
        hwsprite = 1;
        put_word (ABI + PSSO_BoardInfo_SoftSpriteFlags, 0);
-       write_log ("P96: uaegfx.card: hardware sprite support enabled\n");
+       write_log (L"P96: uaegfx.card: hardware sprite support enabled\n");
     } else {
        hwsprite = 0;
-       write_log ("P96: uaegfx.card: no hardware sprite support\n");
+       write_log (L"P96: uaegfx.card: no hardware sprite support\n");
        put_word (ABI + PSSO_BoardInfo_SoftSpriteFlags, currprefs.picasso96_modeflags);
     }
     if (uaegfxcard_old && (flags & BIF_HARDWARESPRITE)) {
        flags &= ~BIF_HARDWARESPRITE;
-       write_log ("P96: uaegfx.card: old version (<2.0), forced hardware sprite disabled\n");
+       write_log (L"P96: uaegfx.card: old version (<2.0), forced hardware sprite disabled\n");
     }
     if (!(flags & BIF_BLITTER))
-       write_log ("P96: no blitter support, bogus uaegfx.card!?\n");
+       write_log (L"P96: no blitter support, bogus uaegfx.card!?\n");
 #else
     hwsprite = 1;
     flags |= BIF_HARDWARESPRITE;
 #endif
     if (flags & BIF_NOBLITTER)
-       write_log ("P96: blitter disabled in devs:monitors/uaegfx!\n");
+       write_log (L"P96: blitter disabled in devs:monitors/uaegfx!\n");
 
     if (currprefs.win32_rtgvblankrate >= -1)
        flags |= BIF_VBLANKINTERRUPT;
@@ -2380,7 +2380,7 @@ static void inituaegfx (uaecptr ABI)
 #endif
 }
 
-static void addmode (uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const char *name, int display, int *unkcnt)
+static void addmode (uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const TCHAR *name, int display, int *unkcnt)
 {
     int depth;
 
@@ -2394,10 +2394,13 @@ static void addmode (uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution
     res->Height = h;
     res->Flags = P96F_PUBLIC;
     memcpy (res->P96ID, "P96-0:", 6);
-    if (name)
-       strcpy (res->Name, name);
-    else
+    if (name) {
+       char *n2 = ua (name);
+       strcpy (res->Name, n2);
+       xfree (n2);
+    } else {
        sprintf (res->Name, "UAE:%4dx%4d", w, h);
+    }
 
     for (depth = 8; depth <= 32; depth++) {
         if (!p96depth (depth))
@@ -2427,7 +2430,7 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx)
     uaegfxversion (AmigaBoardInfo);
 #endif
     if (!picasso96_amem) {
-       write_log ("P96: InitCard() but no resolution memory!\n");
+       write_log (L"P96: InitCard() but no resolution memory!\n");
        return 0;
     }
     amem = picasso96_amem;
@@ -2438,9 +2441,12 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx)
     unkcnt = 0;
     while (newmodes[i].depth >= 0) {
        struct LibResolution res = { 0 };
+       TCHAR *s;
        j = i;
        addmode (AmigaBoardInfo, &amem, &res, newmodes[i].res.width, newmodes[i].res.height, NULL, 0, &unkcnt);
-       write_log ("%08X %4dx%4d %s\n", res.DisplayID, res.Width, res.Height, res.Name);
+       s = au (res.Name);
+       write_log (L"%08X %4dx%4d %s\n", res.DisplayID, res.Width, res.Height, s);
+       xfree (s);
        while (newmodes[i].depth >= 0
            && newmodes[i].res.width == newmodes[j].res.width
            && newmodes[i].res.height == newmodes[j].res.height)
@@ -2460,13 +2466,13 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx)
        struct MultiDisplay *md = &Displays[i];
        int w = md->rect.right - md->rect.left;
        int h = md->rect.bottom - md->rect.top;
-       char tmp[100];
+       TCHAR tmp[100];
        if (md->primary)
            strcpy (tmp, "UAE:Primary");
        else
-           sprintf (tmp, "UAE:Display#%d", i);
+           _stprintf (tmp, "UAE:Display#%d", i);
        addmode (AmigaBoardInfo, &amem, &res, w, h, tmp, i + 1, &unkcnt);
-       write_log ("%08X %4dx%4d %s\n", res.DisplayID, res.Width + 16, res.Height, res.Name);
+       write_log (L"%08X %4dx%4d %s\n", res.DisplayID, res.Width + 16, res.Height, res.Name);
        LibResolutionStructureCount++;
        CopyLibResolutionStructureU2A (&res, amem);
 #if P96TRACING_ENABLED && P96TRACING_LEVEL > 1
@@ -2478,7 +2484,7 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx)
 #endif
 
     if (amem > picasso96_amemend)
-       write_log ("P96: display resolution list corruption %08x<>%08x (%d)\n", amem, picasso96_amemend, i);
+       write_log (L"P96: display resolution list corruption %08x<>%08x (%d)\n", amem, picasso96_amemend, i);
 
     return -1;
 }
@@ -2499,7 +2505,7 @@ static uae_u32 REGPARAM2 picasso_SetSwitch (TrapContext *ctx)
 {
     struct regstruct *regs = &ctx->regs;
     uae_u16 flag = m68k_dreg (regs, 0) & 0xFFFF;
-    char p96text[100];
+    TCHAR p96text[100];
 
     /* Do not switch immediately.  Tell the custom chip emulation about the
     * desired state, and wait for custom.c to call picasso_enablescreen
@@ -2507,10 +2513,10 @@ static uae_u32 REGPARAM2 picasso_SetSwitch (TrapContext *ctx)
     picasso_requested_on = flag;
     p96text[0] = 0;
     if (flag)
-       sprintf (p96text, "Picasso96 %dx%dx%d (%dx%dx%d)",
+       _stprintf (p96text, L"Picasso96 %dx%dx%d (%dx%dx%d)",
            picasso96_state.Width, picasso96_state.Height, picasso96_state.BytesPerPixel * 8,
            picasso_vidinfo.width, picasso_vidinfo.height, picasso_vidinfo.pixbytes * 8);
-    write_log ("SetSwitch() - %s\n", flag ? p96text : "amiga");
+    write_log (L"SetSwitch() - %s\n", flag ? p96text : L"amiga");
     /* Put old switch-state in D0 */
     return !flag;
 }
@@ -2713,7 +2719,7 @@ static uae_u32 REGPARAM2 picasso_SetPanning (TrapContext *ctx)
        if (picasso96_state.BytesPerPixel == picasso_vidinfo.pixbytes)
            p96surface = createsurface (get_real_address (picasso96_state.Address),
                picasso96_state.Width * picasso96_state.BytesPerPixel, picasso96_state.Width, picasso96_state.Height);
-       write_log ("P96Surface: %08X %p\n", picasso96_state.Address, p96surface);
+       write_log (L"P96Surface: %08X %p\n", picasso96_state.Address, p96surface);
 #endif
     }
 
@@ -2871,7 +2877,7 @@ static uae_u32 REGPARAM2 picasso_FillRect (TrapContext *ctx)
 
            /* We get here only if Mask != 0xFF */
            if (Bpp != 1) {
-               write_log ("WARNING - FillRect() has unhandled mask 0x%x with Bpp %d. Using fall-back routine.\n", Mask, Bpp);
+               write_log (L"WARNING - FillRect() has unhandled mask 0x%x with Bpp %d. Using fall-back routine.\n", Mask, Bpp);
            } else {
                Pen &= Mask;
                Mask = ~Mask;
@@ -2949,7 +2955,7 @@ STATIC_INLINE int BlitRectHelper (void)
     uae_u8 Bpp = GetBytesPerPixel (ri->RGBFormat);
 
     if (opcode == BLIT_DST) {
-       write_log ( "WARNING: BlitRect() being called with opcode of BLIT_DST\n" );
+       write_log ( L"WARNING: BlitRect() being called with opcode of BLIT_DST\n" );
        return 1;
     }
 
@@ -3315,7 +3321,7 @@ static uae_u32 REGPARAM2 picasso_BlitTemplate (TrapContext *ctx)
            if(Bpp > 1)
                Mask = 0xFF;
            if(tmp.DrawMode == COMP) {
-               write_log ("WARNING - BlitTemplate() has unhandled mask 0x%x with COMP DrawMode. Using fall-back routine.\n", Mask);
+               write_log (L"WARNING - BlitTemplate() has unhandled mask 0x%x with COMP DrawMode. Using fall-back routine.\n", Mask);
                return 0;
            } else {
                result = 1;
@@ -3508,7 +3514,7 @@ void init_hz_p96 (void)
     if (p96vblank >= 300)
        p96vblank = 300;
     p96syncrate = maxvpos * vblank_hz / p96vblank;
-    write_log ("P96FREQ: %d*%d = %d / %d = %d\n", maxvpos, vblank_hz, maxvpos * vblank_hz, p96vblank, p96syncrate);
+    write_log (L"P96FREQ: %d*%d = %d / %d = %d\n", maxvpos, vblank_hz, maxvpos * vblank_hz, p96vblank, p96syncrate);
 }
 
 /* NOTE: Watch for those planeptrs of 0x00000000 and 0xFFFFFFFF for all zero / all one bitmaps !!!! */
@@ -3616,7 +3622,7 @@ static uae_u32 REGPARAM2 picasso_BlitPlanar2Chunky (TrapContext *ctx)
     if (NOBLITTER)
        return 0;
     if (minterm != 0x0C) {
-       write_log ("ERROR - BlitPlanar2Chunky() has minterm 0x%x, which I don't handle. Using fall-back routine.\n",
+       write_log (L"ERROR - BlitPlanar2Chunky() has minterm 0x%x, which I don't handle. Using fall-back routine.\n",
            minterm);
     } else if (CopyRenderInfoStructureA2U (ri, &local_ri) && CopyBitMapStructureA2U (bm, &local_bm)) {
        P96TRACE(("BlitPlanar2Chunky(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n",
@@ -3758,7 +3764,7 @@ static uae_u32 REGPARAM2 picasso_BlitPlanar2Direct (TrapContext *ctx)
     if (NOBLITTER)
        return 0;
     if (minterm != 0x0C) {
-       write_log ("WARNING - BlitPlanar2Direct() has unhandled op-code 0x%x. Using fall-back routine.\n", minterm);
+       write_log (L"WARNING - BlitPlanar2Direct() has unhandled op-code 0x%x. Using fall-back routine.\n", minterm);
        return 0;
     }
     if (CopyRenderInfoStructureA2U (ri, &local_ri) && CopyBitMapStructureA2U (bm, &local_bm)) {
@@ -3995,7 +4001,7 @@ static void flushpixels (void)
     uae_u8 *dst = NULL;
     ULONG_PTR gwwcnt;
 #if 0
-    write_log ("%dx%d %dx%d %dx%d\n", picasso96_state.Width, picasso96_state.Width,
+    write_log (L"%dx%d %dx%d %dx%d\n", picasso96_state.Width, picasso96_state.Width,
        picasso96_state.VirtualWidth, picasso96_state.VirtualHeight,
        picasso_vidinfo.width, picasso_vidinfo.height);
 #endif
@@ -4203,7 +4209,7 @@ static uae_u8 *REGPARAM2 gfxmem_xlate (uaecptr addr)
 addrbank gfxmem_bankx = {
     gfxmem_lgetx, gfxmem_wgetx, gfxmem_bgetx,
     gfxmem_lputx, gfxmem_wputx, gfxmem_bputx,
-    gfxmem_xlate, gfxmem_check, NULL, "RTG RAM",
+    gfxmem_xlate, gfxmem_check, NULL, L"RTG RAM",
     dummy_lgeti, dummy_wgeti, ABFLAG_RAM
 };
 
@@ -4239,7 +4245,7 @@ static uae_u32 REGPARAM2 picasso_SetInterrupt (TrapContext *ctx)
     uaecptr bi = m68k_areg (regs, 0);
     uae_u32 onoff = m68k_dreg (regs, 0);
     interrupt_enabled = onoff;
-    //write_log ("Picasso_SetInterrupt(%08x,%d)\n", bi, onoff);
+    //write_log (L"Picasso_SetInterrupt(%08x,%d)\n", bi, onoff);
     return onoff;
 }
 
@@ -4429,7 +4435,7 @@ static uaecptr inituaegfxfuncs (uaecptr start, uaecptr ABI)
 
     RTGCALL2(PSSO_BoardInfo_SetInterrupt, picasso_SetInterrupt);
 
-    write_log ("uaegfx.card magic code: %08X-%08X ABI=%08X\n", start, here (), ABI);
+    write_log (L"uaegfx.card magic code: %08X-%08X ABI=%08X\n", start, here (), ABI);
 
     ptr = here ();
     org (old);
@@ -4508,9 +4514,9 @@ static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize)
     uaecptr findcardfunc, initcardfunc;
     uaecptr exec = get_long (4);
 
-    uaegfx_resid = ds ("UAE Graphics Card 3.2");
-    uaegfx_vblankname = ds ("UAE Graphics Card VBLANK");
-    uaegfx_vblankname = ds ("UAE Graphics Card PORTS");
+    uaegfx_resid = ds (L"UAE Graphics Card 3.2");
+    uaegfx_vblankname = ds (L"UAE Graphics Card VBLANK");
+    uaegfx_vblankname = ds (L"UAE Graphics Card PORTS");
 
     /* Open */
     openfunc = here ();
@@ -4566,7 +4572,7 @@ static uaecptr uaegfx_card_install (TrapContext *ctx, uae_u32 extrasize)
     if (currprefs.win32_rtgvblankrate >= -1)
        initvblankirq (ctx, uaegfx_base);
 
-    write_log ("uaegfx.card %d.%d init @%08X\n", UAEGFX_VERSION, UAEGFX_REVISION, uaegfx_base);
+    write_log (L"uaegfx.card %d.%d init @%08X\n", UAEGFX_VERSION, UAEGFX_REVISION, uaegfx_base);
     return uaegfx_base;
 }
 #endif
index d812bcd0f0b02e1fe625f0c08c9b72578614c3c5..58e0ec842e4251e560de20cb31d28544c5562ecb 100644 (file)
@@ -73,7 +73,7 @@ static void get_time(time_t t, long *days, long *mins, long *ticks)
     *ticks = t * 50;
 }
 
-static DWORD getattr(const char *name, LPFILETIME lpft, size_t *size)
+static DWORD getattr(const TCHAR *name, LPFILETIME lpft, size_t *size)
 {
     HANDLE hFind;
     WIN32_FIND_DATA fd;
@@ -92,7 +92,7 @@ static DWORD getattr(const char *name, LPFILETIME lpft, size_t *size)
     return fd.dwFileAttributes;
 }
 
-int posixemu_stat(const char *name, struct stat *statbuf)
+int posixemu_stat(const TCHAR *name, struct stat *statbuf)
 {
     DWORD attr;
     FILETIME ft, lft;
@@ -111,7 +111,7 @@ int posixemu_stat(const char *name, struct stat *statbuf)
     return 0;
 }
 
-int posixemu_chmod(const char *name, int mode)
+int posixemu_chmod(const TCHAR *name, int mode)
 {
     DWORD attr = FILE_ATTRIBUTE_NORMAL;
     if (!(mode & FILEFLAG_WRITE))
@@ -139,7 +139,7 @@ static void tmToSystemTime(struct tm *tmtime, LPSYSTEMTIME systime)
     }
 }
 
-static int setfiletime (const char *name, unsigned int days, int minute, int tick, int tolocal)
+static int setfiletime (const TCHAR *name, unsigned int days, int minute, int tick, int tolocal)
 {
     FILETIME LocalFileTime, FileTime;
     HANDLE hFile;
@@ -162,7 +162,7 @@ static int setfiletime (const char *name, unsigned int days, int minute, int tic
     return success;
 }
 
-int posixemu_utime (const char *name, struct utimbuf *ttime)
+int posixemu_utime (const TCHAR *name, struct utimbuf *ttime)
 {
     int result = -1, tolocal;
     long days, mins, ticks;
@@ -248,7 +248,7 @@ void uae_end_thread (uae_thread_id *tid)
     }
 }
 
-int uae_start_thread (char *name, void *(*f)(void *), void *arg, uae_thread_id *tid)
+int uae_start_thread (TCHAR *name, void *(*f)(void *), void *arg, uae_thread_id *tid)
 {
     HANDLE hThread;
     int result = 1;
@@ -262,10 +262,10 @@ int uae_start_thread (char *name, void *(*f)(void *), void *arg, uae_thread_id *
     if (hThread) {
        SetThreadPriority (hThread, THREAD_PRIORITY_ABOVE_NORMAL);
        if (name)
-           write_log ("Thread '%s' started (%d)\n", name, hThread);
+           write_log (L"Thread '%s' started (%d)\n", name, hThread);
     } else {
        result = 0;
-       write_log ("Thread '%s' failed to start!?\n", name ? name : "<unknown>");
+       write_log (L"Thread '%s' failed to start!?\n", name ? name : L"<unknown>");
     }
     if (tid)
        *tid = hThread;
index 791ef190ac9b46725f635b2c51718ede7c26739b..5f2f3338ae0c5d2155c1d81abd1e0877ae3d766a 100644 (file)
@@ -9,8 +9,8 @@
 #include "crc32.h"
 
 static int inimode = 0;
-static char *inipath;
-#define PUPPA "eitätäoo"
+static TCHAR *inipath;
+#define PUPPA L"eitätäoo"
 
 static HKEY gr (UAEREG *root)
 {
@@ -18,24 +18,24 @@ static HKEY gr (UAEREG *root)
        return hWinUAEKey;
     return root->fkey;
 }
-static char *gs (UAEREG *root)
+static TCHAR *gs (UAEREG *root)
 {
     if (!root)
-       return "WinUAE";
+       return L"WinUAE";
     return root->inipath;
 }
-static char *gsn (UAEREG *root, const char *name)
+static TCHAR *gsn (UAEREG *root, const TCHAR *name)
 {
-    char *r, *s;
+    TCHAR *r, *s;
     if (!root)
        return my_strdup (name);
     r = gs (root);
-    s = xmalloc (strlen (r) + 1 + strlen (name) + 1);
-    sprintf (s, "%s/%s", r, name);
+    s = xmalloc ((_tcslen (r) + 1 + _tcslen (name) + 1) * sizeof (TCHAR));
+    _stprintf (s, L"%s/%s", r, name);
     return s;
 }
 
-int regsetstr (UAEREG *root, const char *name, const char *str)
+int regsetstr (UAEREG *root, const TCHAR *name, const TCHAR *str)
 {
     if (inimode) {
        DWORD ret;
@@ -45,16 +45,16 @@ int regsetstr (UAEREG *root, const char *name, const char *str)
        HKEY rk = gr (root);
        if (!rk)
            return 0;
-       return RegSetValueEx (rk, name, 0, REG_SZ, (CONST BYTE *)str, strlen (str) + 1) == ERROR_SUCCESS;
+       return RegSetValueEx (rk, name, 0, REG_SZ, (CONST BYTE *)str, (_tcslen (str) + 1) * sizeof (TCHAR)) == ERROR_SUCCESS;
     }
 }
 
-int regsetint (UAEREG *root, const char *name, int val)
+int regsetint (UAEREG *root, const TCHAR *name, int val)
 {
     if (inimode) {
        DWORD ret;
-       char tmp[100];
-       sprintf (tmp, "%d", val);
+       TCHAR tmp[100];
+       _stprintf (tmp, L"%d", val);
        ret = WritePrivateProfileString (gs (root), name, tmp, inipath);
        return ret;
     } else {
@@ -66,14 +66,14 @@ int regsetint (UAEREG *root, const char *name, int val)
     }
 }
 
-int regqueryint (UAEREG *root, const char *name, int *val)
+int regqueryint (UAEREG *root, const TCHAR *name, int *val)
 {
     if (inimode) {
        int ret = 0;
-       char tmp[100];
-       GetPrivateProfileString (gs (root), name, PUPPA, tmp, sizeof (tmp), inipath);
-       if (strcmp (tmp, PUPPA)) {
-           *val = atol (tmp);
+       TCHAR tmp[100];
+       GetPrivateProfileString (gs (root), name, PUPPA, tmp, sizeof (tmp) / sizeof (TCHAR), inipath);
+       if (_tcscmp (tmp, PUPPA)) {
+           *val = _tstol (tmp);
            ret = 1;
        }
        return ret;
@@ -87,14 +87,14 @@ int regqueryint (UAEREG *root, const char *name, int *val)
     }
 }
 
-int regquerystr (UAEREG *root, const char *name, char *str, int *size)
+int regquerystr (UAEREG *root, const TCHAR *name, TCHAR *str, int *size)
 {
     if (inimode) {
        int ret = 0;
-       char *tmp = xmalloc ((*size) + 1);
+       TCHAR *tmp = xmalloc (((*size) + 1) * sizeof (TCHAR));
        GetPrivateProfileString (gs (root), name, PUPPA, tmp, *size, inipath);
-       if (strcmp (tmp, PUPPA)) {
-           strcpy (str, tmp);
+       if (_tcscmp (tmp, PUPPA)) {
+           _tcscpy (str, tmp);
            ret = 1;
        }
        xfree (tmp);
@@ -103,29 +103,31 @@ int regquerystr (UAEREG *root, const char *name, char *str, int *size)
        HKEY rk = gr (root);
        if (!rk)
            return 0;
-       return RegQueryValueEx (rk, name, 0, NULL, str, size) == ERROR_SUCCESS;
+       return RegQueryValueEx (rk, name, 0, NULL, (LPBYTE)str, size) == ERROR_SUCCESS;
     }
 }
 
-int regenumstr (UAEREG *root, int idx, char *name, int *nsize, char *str, int *size)
+int regenumstr (UAEREG *root, int idx, TCHAR *name, int *nsize, TCHAR *str, int *size)
 {
+    name[0] = 0;
+    str[0] = 0;
     if (inimode) {
        int ret = 0;
        int tmpsize = 65536;
-       char *tmp = xmalloc (tmpsize);
+       TCHAR *tmp = xmalloc (tmpsize * sizeof (TCHAR));
        if (GetPrivateProfileSection (gs (root), tmp, tmpsize, inipath) > 0) {
            int i;
-           char *p = tmp, *p2;
+           TCHAR *p = tmp, *p2;
            for (i = 0; i < idx; i++) {
                if (p[0] == 0)
                    break;
-               p += strlen (p) + 1;
+               p += _tcslen (p) + 1;
            }
            if (p[0]) {
-               p2 = strchr (p, '=');
+               p2 = _tcschr (p, '=');
                *p2++ = 0;
-               strcpy_s (name, *nsize, p);
-               strcpy_s (str, *size, p2);
+               _tcscpy_s (name, *nsize, p);
+               _tcscpy_s (str, *size, p2);
                ret = 1;
            }
        }
@@ -135,18 +137,18 @@ int regenumstr (UAEREG *root, int idx, char *name, int *nsize, char *str, int *s
        HKEY rk = gr (root);
        if (!rk)
            return 0;
-       return RegEnumValue (rk, idx, name, nsize, NULL, NULL, str, size) == ERROR_SUCCESS;
+       return RegEnumValue (rk, idx, name, nsize, NULL, NULL, (LPBYTE)str, size) == ERROR_SUCCESS;
     }
 }
 
-int regquerydatasize (UAEREG *root, const char *name, int *size)
+int regquerydatasize (UAEREG *root, const TCHAR *name, int *size)
 {
     if (inimode) {
        int ret = 0;
        int csize = 65536;
-       char *tmp = xmalloc (csize);
+       TCHAR *tmp = xmalloc (csize * sizeof (TCHAR));
        if (regquerystr (root, name, tmp, &csize)) {
-           *size = strlen (tmp) / 2;
+           *size = _tcslen (tmp) / 2;
            ret = 1;
        }
        xfree (tmp);
@@ -159,15 +161,15 @@ int regquerydatasize (UAEREG *root, const char *name, int *size)
     }
 }
 
-int regsetdata (UAEREG *root, const char *name, void *str, int size)
+int regsetdata (UAEREG *root, const TCHAR *name, void *str, int size)
 {
     if (inimode) {
        uae_u8 *in = str;
        DWORD ret;
        int i;
-       char *tmp = xmalloc (size * 2 + 1);
+       TCHAR *tmp = xmalloc ((size * 2 + 1) * sizeof (TCHAR));
        for (i = 0; i < size; i++)
-           sprintf (tmp + i * 2, "%02X", in[i]); 
+           _stprintf (tmp + i * 2, L"%02X", in[i]); 
        ret = WritePrivateProfileString (gs (root), name, tmp, inipath);
        xfree (tmp);
        return ret;
@@ -178,21 +180,21 @@ int regsetdata (UAEREG *root, const char *name, void *str, int size)
        return RegSetValueEx(rk, name, 0, REG_BINARY, (BYTE*)str, size) == ERROR_SUCCESS;
     }
 }
-int regquerydata (UAEREG *root, const char *name, void *str, int *size)
+int regquerydata (UAEREG *root, const TCHAR *name, void *str, int *size)
 {
     if (inimode) {
        int csize = (*size) * 2 + 1;
        int i, j;
        int ret = 0;
-       char *tmp = xmalloc (csize);
+       TCHAR *tmp = xmalloc (csize * sizeof (TCHAR));
        uae_u8 *out = str;
 
        if (!regquerystr (root, name, tmp, &csize))
            goto err;
        j = 0;
-       for (i = 0; i < strlen (tmp); i += 2) {
-           char c1 = toupper(tmp[i + 0]);
-           char c2 = toupper(tmp[i + 1]);
+       for (i = 0; i < _tcslen (tmp); i += 2) {
+           TCHAR c1 = toupper(tmp[i + 0]);
+           TCHAR c2 = toupper(tmp[i + 1]);
            if (c1 >= 'A')
                c1 -= 'A' - 10;
            else if (c1 >= '0')
@@ -219,7 +221,7 @@ int regquerydata (UAEREG *root, const char *name, void *str, int *size)
     }
 }
 
-int regdelete (UAEREG *root, const char *name)
+int regdelete (UAEREG *root, const TCHAR *name)
 {
     if (inimode) {
        WritePrivateProfileString (gs (root), name, NULL, inipath);
@@ -232,14 +234,14 @@ int regdelete (UAEREG *root, const char *name)
     }
 }
 
-int regexists (UAEREG *root, const char *name)
+int regexists (UAEREG *root, const TCHAR *name)
 {
     if (inimode) {
        int ret = 1;
-       char *tmp = xmalloc (strlen (PUPPA) + 1);
-       int size = strlen (PUPPA) + 1;
+       TCHAR *tmp = xmalloc ((_tcslen (PUPPA) + 1) * sizeof (TCHAR));
+       int size = _tcslen (PUPPA) + 1;
        GetPrivateProfileString (gs (root), name, PUPPA, tmp, size, inipath);
-       if (!strcmp (tmp, PUPPA))
+       if (!_tcscmp (tmp, PUPPA))
            ret = 0;
        xfree (tmp);
        return ret;
@@ -251,13 +253,13 @@ int regexists (UAEREG *root, const char *name)
     }
 }
 
-void regdeletetree (UAEREG *root, const char *name)
+void regdeletetree (UAEREG *root, const TCHAR *name)
 {
     if (inimode) {
-       char *s = gsn (root, name);
+       TCHAR *s = gsn (root, name);
        if (!s)
            return;
-       WritePrivateProfileSection (s, "", inipath);
+       WritePrivateProfileSection (s, L"", inipath);
        xfree (s);
     } else {
        HKEY rk = gr (root);
@@ -267,13 +269,13 @@ void regdeletetree (UAEREG *root, const char *name)
     }
 }
 
-int regexiststree (UAEREG *root, const char *name)
+int regexiststree (UAEREG *root, const TCHAR *name)
 {
     if (inimode) {
        int ret = 0;
        int tmpsize = 65536;
-       char *p, *tmp;
-       char *s = gsn (root, name);
+       TCHAR *p, *tmp;
+       TCHAR *s = gsn (root, name);
        if (!s)
            return 0;
        tmp = xmalloc (tmpsize);
@@ -281,11 +283,11 @@ int regexiststree (UAEREG *root, const char *name)
        GetPrivateProfileSectionNames (tmp, tmpsize, inipath);
        p = tmp;
        while (p[0]) {
-           if (!strcmp (p, name)) {
+           if (!_tcscmp (p, name)) {
                ret = 1;
                break;
            }
-           p += strlen (p) + 1;
+           p += _tcslen (p) + 1;
        }
        xfree (tmp);
        xfree (s);
@@ -305,32 +307,36 @@ int regexiststree (UAEREG *root, const char *name)
 }
 
 
-UAEREG *regcreatetree (UAEREG *root, const char *name)
+UAEREG *regcreatetree (UAEREG *root, const TCHAR *name)
 {
     UAEREG *fkey;
     HKEY rkey;
 
     if (inimode) {
-       char *ininame;
+       TCHAR *ininame;
        if (!root) {
            if (!name)
                ininame = my_strdup (gs (NULL));
            else
                ininame = my_strdup (name);
        } else {
-           ininame = xmalloc (strlen (root->inipath) + 1 + strlen (name) + 1);
-           sprintf (ininame, "%s/%s", root->inipath, name);
+           ininame = xmalloc ((_tcslen (root->inipath) + 1 + _tcslen (name) + 1) * sizeof (TCHAR));
+           _stprintf (ininame, L"%s/%s", root->inipath, name);
        }
        fkey = xcalloc (sizeof (UAEREG), 1);
        fkey->inipath = ininame;
     } else {
+       DWORD err;
        HKEY rk = gr (root);
        if (!rk) {
            rk = HKEY_CURRENT_USER;
-           name = "Software\\Arabuusimiehet\\WinUAE";
+           name = L"Software\\Arabuusimiehet\\WinUAE";
+       } else if (!name) {
+           name = L"";
        }
-       if (RegCreateKeyEx(rk, name, 0, NULL, REG_OPTION_NON_VOLATILE,
-           KEY_READ | KEY_WRITE, NULL, &rkey, NULL) != ERROR_SUCCESS)
+       err = RegCreateKeyEx (rk, name, 0, NULL, REG_OPTION_NON_VOLATILE,
+           KEY_READ | KEY_WRITE, NULL, &rkey, NULL);
+       if (err != ERROR_SUCCESS)
            return 0;
        fkey = xcalloc (sizeof (UAEREG), 1);
        fkey->fkey = rkey;
@@ -348,65 +354,66 @@ void regclosetree (UAEREG *key)
     xfree (key);
 }
 
-static uae_u8 crcok[20] = { 0xD3,0x34,0xDE,0x75,0x31,0x2B,0x44,0x51,0xA2,0xB8,0x8D,0xC3,0x52,0xFB,0x65,0x8F,0x95,0xCB,0x0C,0xF2 };
+//static uae_u8 crcok[20] = { 0xD3,0x34,0xDE,0x75,0x31,0x2B,0x44,0x51,0xA2,0xB8,0x8D,0xC3,0x52,0xFB,0x65,0x8F,0x95,0xCB,0x0C,0xF2 };
+static uae_u8 crcok[20] = { 0xaf,0xb7,0x36,0x15,0x05,0xca,0xe6,0x9d,0x23,0x17,0x4d,0x50,0x2b,0x5c,0xc3,0x64,0x38,0xb8,0x4e,0xfc };
 
-int reginitializeinit (const char *ppath)
+int reginitializeinit (const TCHAR *ppath)
 {
     UAEREG *r = NULL;
-    char tmp1[1000];
+    TCHAR tmp1[1000];
     uae_u8 crc[20];
     int s, v1, v2, v3;
-    char path[MAX_DPATH], fpath[MAX_PATH];
+    TCHAR path[MAX_DPATH], fpath[MAX_PATH];
 
     if (!ppath) {
        int ok = 0;
-       char *posn;
-       strcpy (path, _pgmptr);
-       if (strlen (path) > 4 && !stricmp (path + strlen (path) - 4, ".exe")) {
-           strcpy (path + strlen (path) - 3, "ini");
+       TCHAR *posn;
+       _tcscpy (path, pgmptr);
+       if (_tcslen (path) > 4 && !_tcsicmp (path + _tcslen (path) - 4, L".exe")) {
+           _tcscpy (path + _tcslen (path) - 3, L"ini");
            if (GetFileAttributes (path) != INVALID_FILE_ATTRIBUTES)
                ok = 1;
        }
        if (!ok) {
-           strcpy (path, _pgmptr);
-           if((posn = strrchr (path, '\\')))
+           _tcscpy (path, pgmptr);
+           if((posn = _tcsrchr (path, '\\')))
                posn[1] = 0;
-           strcat (path, "winuae.ini");
+           _tcscat (path, L"winuae.ini");
        }
        if (GetFileAttributes (path) == INVALID_FILE_ATTRIBUTES)
            return 0;
     } else {
-       strcpy (path, ppath);
+       _tcscpy (path, ppath);
     }
 
     fpath[0] = 0;
-    GetFullPathName (path, sizeof fpath, fpath, NULL);
-    if (strlen (fpath) < 5 || stricmp (fpath + strlen (fpath) - 4, ".ini"))
+    GetFullPathName (path, sizeof fpath / sizeof (TCHAR), fpath, NULL);
+    if (_tcslen (fpath) < 5 || _tcsicmp (fpath + _tcslen (fpath) - 4, L".ini"))
        return 0;
 
     inimode = 1;
     inipath = my_strdup (fpath);
-    if (!regexists (NULL, "Version"))
+    if (!regexists (NULL, L"Version"))
        goto fail;
-    r = regcreatetree (NULL, "Warning");
+    r = regcreatetree (NULL, L"Warning");
     if (!r)
        goto fail;
     memset (tmp1, 0, sizeof tmp1);
     s = 200;
-    if (!regquerystr (r, "info1", tmp1, &s))
+    if (!regquerystr (r, L"info1", tmp1, &s))
        goto fail;
-    if (!regquerystr (r, "info2", tmp1 + 200, &s))
+    if (!regquerystr (r, L"info2", tmp1 + 200, &s))
        goto fail;
     get_sha1 (tmp1, sizeof tmp1, crc);
     if (memcmp (crc, crcok, sizeof crcok))
        goto fail;
     v1 = v2 = -1;
-    regsetint (r, "check", 1);
-    regqueryint (r, "check", &v1);
-    regsetint (r, "check", 3);
-    regqueryint (r, "check", &v2);
-    regdelete (r, "check");
-    if (regqueryint (r, "check", &v3))
+    regsetint (r, L"check", 1);
+    regqueryint (r, L"check", &v1);
+    regsetint (r, L"check", 3);
+    regqueryint (r, L"check", &v2);
+    regdelete (r, L"check");
+    if (regqueryint (r, L"check", &v3))
        goto fail;
     if (v1 != 1 || v2 != 3)
        goto fail;
@@ -418,11 +425,11 @@ fail:
        DeleteFile (path);
     if (GetFileAttributes (path) != INVALID_FILE_ATTRIBUTES)
        goto end;
-    r = regcreatetree (NULL, "Warning");
+    r = regcreatetree (NULL, L"Warning");
     if (!r)
        goto end;
-    regsetstr (r, "info1", "This is unsupported file. Compatibility between versions is not guaranteed.");
-    regsetstr (r, "info2", "Incompatible ini-files may be re-created from scratch!");
+    regsetstr (r, L"info1", L"This is unsupported file. Compatibility between versions is not guaranteed.");
+    regsetstr (r, L"info2", L"Incompatible ini-files may be re-created from scratch!");
     regclosetree (r);
     return 1;
 end:
@@ -434,10 +441,10 @@ end:
 void regstatus (void)
 {
     if (inimode)
-       write_log ("WARNING: Unsupported '%s' enabled\n", inipath);
+       write_log (L"WARNING: Unsupported '%s' enabled\n", inipath);
 }
 
 int getregmode (void)
 {
     return inimode;
-}
\ No newline at end of file
+}
index 58d67c8867ae2930b35344ebeb428cc33d9e161e..2010ddb7eb44d1432db2a409451010994aff018e 100644 (file)
@@ -2,30 +2,30 @@
 
 typedef struct UAEREG {
     HKEY fkey;
-    char *inipath;
+    TCHAR *inipath;
 } UAEREG;
 
 extern int getregmode (void);
-extern int reginitializeinit (const char *path);
+extern int reginitializeinit (const TCHAR *path);
 extern void regstatus (void);
 
-extern int regsetstr (UAEREG*, const char *name, const char *str);
-extern int regsetint (UAEREG*, const char *name, int val);
-extern int regqueryint (UAEREG*, const char *name, int *val);
-extern int regquerystr (UAEREG*, const char *name, char *str, int *size);
+extern int regsetstr (UAEREG*, const TCHAR *name, const TCHAR *str);
+extern int regsetint (UAEREG*, const TCHAR *name, int val);
+extern int regqueryint (UAEREG*, const TCHAR *name, int *val);
+extern int regquerystr (UAEREG*, const TCHAR *name, TCHAR *str, int *size);
 
-extern int regdelete (UAEREG*, const char *name);
-extern void regdeletetree (UAEREG*, const char *name);
+extern int regdelete (UAEREG*, const TCHAR *name);
+extern void regdeletetree (UAEREG*, const TCHAR *name);
 
-extern int regexists (UAEREG*, const char *name);
-extern int regexiststree (UAEREG *, const char *name);
+extern int regexists (UAEREG*, const TCHAR *name);
+extern int regexiststree (UAEREG *, const TCHAR *name);
 
-extern int regquerydatasize (UAEREG *root, const char *name, int *size);
-extern int regsetdata (UAEREG*, const char *name, const void *str, int size);
-extern int regquerydata (UAEREG *root, const char *name, void *str, int *size);
+extern int regquerydatasize (UAEREG *root, const TCHAR *name, int *size);
+extern int regsetdata (UAEREG*, const TCHAR *name, const void *str, int size);
+extern int regquerydata (UAEREG *root, const TCHAR *name, void *str, int *size);
 
-extern int regenumstr (UAEREG*, int idx, char *name, int *nsize, char *str, int *size);
+extern int regenumstr (UAEREG*, int idx, TCHAR *name, int *nsize, TCHAR *str, int *size);
 
-extern UAEREG *regcreatetree (UAEREG*, const char *name);
+extern UAEREG *regcreatetree (UAEREG*, const TCHAR *name);
 extern void regclosetree (UAEREG *key);
 
index b432feec3a551189c04922fec2dc0f2403cdb071..219d87a26e7631b5bb3dce384f656eb303db6720 100644 (file)
@@ -31,7 +31,7 @@
 static int initialized;
 static RPGUESTINFO guestinfo;
 
-char *rp_param = NULL;
+TCHAR *rp_param = NULL;
 int rp_rpescapekey = 0x01;
 int rp_rpescapeholdtime = 600;
 int rp_screenmode = 0;
@@ -63,119 +63,94 @@ static int isrecursive (void)
 static void outhex (const uae_u8 *s)
 {
     for (;;) {
-       write_log ("%02X%02X ", s[0], s[1]);
+       write_log (L"%02X%02X ", s[0], s[1]);
        if (s[0] == 0 && s[1] == 0)
            break;
        s += 2;
     }
-    write_log ("\n");
+    write_log (L"\n");
 }
 
-static char *ua (const WCHAR *s)
-{
-    char *d;
-    int len;
-
-    if (s == NULL)
-       return NULL;
-    len = WideCharToMultiByte (CP_ACP, 0, s, -1, NULL, 0, 0, FALSE);
-    if (!len)
-       return my_strdup ("");
-    d = xmalloc (len + 1);
-    WideCharToMultiByte (CP_ACP, 0, s, -1, d, len, 0, FALSE);
-    return d;
-}
-static WCHAR *au (const char *s)
-{
-    WCHAR *d;
-    int len = MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, s, -1, NULL, 0);
-    if (!len)
-       return xcalloc (2, 1);
-    d = xmalloc ((len + 1) * sizeof (WCHAR));
-    MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, s, -1, d, len);
-    return d;
-}
-
-static const char *getmsg (int msg)
+static const TCHAR *getmsg (int msg)
 {
     switch (msg)
     {
-       case RPIPCGM_REGISTER: return "RPIPCGM_REGISTER";
-       case RPIPCGM_FEATURES: return "RPIPCGM_FEATURES";
-       case RPIPCGM_CLOSED: return "RPIPCGM_CLOSED";
-       case RPIPCGM_CLOSE: return "RPIPCGM_CLOSE";
-       case RPIPCGM_ACTIVATED: return "RPIPCGM_ACTIVATED";
-       case RPIPCGM_DEACTIVATED: return "RPIPCGM_DEACTIVATED";
-       case RPIPCGM_PARENT: return "RPIPCGM_PARENT";
-       case RPIPCGM_SCREENMODE: return "RPIPCGM_SCREENMODE";
-       case RPIPCGM_POWERLED: return "RPIPCGM_POWERLED";
-       case RPIPCGM_DEVICES: return "RPIPCGM_DEVICES";
-       case RPIPCGM_DEVICEACTIVITY: return "RPIPCGM_DEVICEACTIVITY";
-       case RPIPCGM_MOUSECAPTURE: return "RPIPCGM_MOUSECAPTURE";
-       case RPIPCGM_HOSTAPIVERSION: return "RPIPCGM_HOSTAPIVERSION";
-       case RPIPCGM_PAUSE: return "RPIPCGM_PAUSE";
-       case RPIPCGM_TURBO: return "RPIPCGM_TURBO";
-       case RPIPCGM_VOLUME: return "RPIPCGM_VOLUME";
-       case RPIPCGM_DEVICECONTENT: return "RPIPCGM_DEVICECONTENT";
-       case RPIPCGM_DEVICESEEK: return "RPIPCGM_DEVICESEEK";
-       case RPIPCGM_ESCAPED: return "RPIPCGM_ESCAPED";
-
-       case RPIPCHM_CLOSE: return "RPIPCHM_CLOSE";
-       case RPIPCHM_SCREENMODE: return "RPIPCHM_SCREENMODE";
-       case RPIPCHM_SCREENCAPTURE: return "RPIPCHM_SCREENCAPTURE";
-       case RPIPCHM_PAUSE: return "RPIPCHM_PAUSE";
-       case RPIPCHM_RESET: return "RPIPCHM_RESET";
-       case RPIPCHM_TURBO: return "RPIPCHM_TURBO";
-       case RPIPCHM_VOLUME: return "RPIPCHM_VOLUME";
-       case RPIPCHM_EVENT: return "RPIPCHM_EVENT";
-       case RPIPCHM_ESCAPEKEY: return "RPIPCHM_ESCAPEKEY";
-       case RPIPCHM_MOUSECAPTURE: return "RPIPCHM_MOUSECAPTURE";
-       case RPIPCHM_DEVICECONTENT: return "RPIPCHM_DEVICECONTENT";
-       case RPIPCHM_PING: return "RPIPCHM_PING";
-       case RPIPCHM_SAVESTATE: return "RPIPCHM_SAVESTATE";
-       case RPIPCHM_LOADSTATE: return "RPIPCHM_LOADSTATE";
-
-       default: return "UNKNOWN";
+       case RPIPCGM_REGISTER: return L"RPIPCGM_REGISTER";
+       case RPIPCGM_FEATURES: return L"RPIPCGM_FEATURES";
+       case RPIPCGM_CLOSED: return L"RPIPCGM_CLOSED";
+       case RPIPCGM_CLOSE: return L"RPIPCGM_CLOSE";
+       case RPIPCGM_ACTIVATED: return L"RPIPCGM_ACTIVATED";
+       case RPIPCGM_DEACTIVATED: return L"RPIPCGM_DEACTIVATED";
+       case RPIPCGM_PARENT: return L"RPIPCGM_PARENT";
+       case RPIPCGM_SCREENMODE: return L"RPIPCGM_SCREENMODE";
+       case RPIPCGM_POWERLED: return L"RPIPCGM_POWERLED";
+       case RPIPCGM_DEVICES: return L"RPIPCGM_DEVICES";
+       case RPIPCGM_DEVICEACTIVITY: return L"RPIPCGM_DEVICEACTIVITY";
+       case RPIPCGM_MOUSECAPTURE: return L"RPIPCGM_MOUSECAPTURE";
+       case RPIPCGM_HOSTAPIVERSION: return L"RPIPCGM_HOSTAPIVERSION";
+       case RPIPCGM_PAUSE: return L"RPIPCGM_PAUSE";
+       case RPIPCGM_TURBO: return L"RPIPCGM_TURBO";
+       case RPIPCGM_VOLUME: return L"RPIPCGM_VOLUME";
+       case RPIPCGM_DEVICECONTENT: return L"RPIPCGM_DEVICECONTENT";
+       case RPIPCGM_DEVICESEEK: return L"RPIPCGM_DEVICESEEK";
+       case RPIPCGM_ESCAPED: return L"RPIPCGM_ESCAPED";
+
+       case RPIPCHM_CLOSE: return L"RPIPCHM_CLOSE";
+       case RPIPCHM_SCREENMODE: return L"RPIPCHM_SCREENMODE";
+       case RPIPCHM_SCREENCAPTURE: return L"RPIPCHM_SCREENCAPTURE";
+       case RPIPCHM_PAUSE: return L"RPIPCHM_PAUSE";
+       case RPIPCHM_RESET: return L"RPIPCHM_RESET";
+       case RPIPCHM_TURBO: return L"RPIPCHM_TURBO";
+       case RPIPCHM_VOLUME: return L"RPIPCHM_VOLUME";
+       case RPIPCHM_EVENT: return L"RPIPCHM_EVENT";
+       case RPIPCHM_ESCAPEKEY: return L"RPIPCHM_ESCAPEKEY";
+       case RPIPCHM_MOUSECAPTURE: return L"RPIPCHM_MOUSECAPTURE";
+       case RPIPCHM_DEVICECONTENT: return L"RPIPCHM_DEVICECONTENT";
+       case RPIPCHM_PING: return L"RPIPCHM_PING";
+       case RPIPCHM_SAVESTATE: return L"RPIPCHM_SAVESTATE";
+       case RPIPCHM_LOADSTATE: return L"RPIPCHM_LOADSTATE";
+
+       default: return L"UNKNOWN";
     }
 }
 
-static void trimws (char *s)
+static void trimws (TCHAR *s)
 {
     /* Delete trailing whitespace.  */
-    int len = strlen (s);
-    while (len > 0 && strcspn (s + len - 1, "\t \r\n") == 0)
+    int len = _tcslen (s);
+    while (len > 0 && _tcscspn (s + len - 1, L"\t \r\n") == 0)
         s[--len] = '\0';
 }
 
-static int port_insert2 (int num, const char *name)
+static int port_insert2 (int num, const TCHAR *name)
 {
-    char tmp2[1000];
+    TCHAR tmp2[1000];
     int i, type;
 
     type = 1;
-    strcpy (tmp2, name);
+    _tcscpy (tmp2, name);
     for (i = 1; i <= 4; i++) {
-       char tmp1[1000];
-       sprintf (tmp1, "Mouse%d", i);
-       if (!strcmp (name, tmp1)) {
-           sprintf (tmp2, "mouse%d", i - 1);
+       TCHAR tmp1[1000];
+       _stprintf (tmp1, L"Mouse%d", i);
+       if (!_tcscmp (name, tmp1)) {
+           _stprintf (tmp2, L"mouse%d", i - 1);
            type = 0;
            break;
        }
-       sprintf (tmp1, "Joystick%d", i);
-       if (!strcmp (name, tmp1)) {
+       _stprintf (tmp1, L"Joystick%d", i);
+       if (!_tcscmp (name, tmp1)) {
            if (i - 1 == JSEM_XARCADE1LAYOUT)
-               sprintf (tmp2, "kbd%d", JSEM_XARCADE1LAYOUT);
+               _stprintf (tmp2, L"kbd%d", JSEM_XARCADE1LAYOUT);
            else if (i - 1 == JSEM_XARCADE2LAYOUT)
-               sprintf (tmp2, "kbd%d", JSEM_XARCADE2LAYOUT);
+               _stprintf (tmp2, L"kbd%d", JSEM_XARCADE2LAYOUT);
            else
-               sprintf (tmp2, "joy%d", i - 1);
+               _stprintf (tmp2, L"joy%d", i - 1);
            type = 0;
            break;
        }
-       sprintf (tmp1, "KeyboardLayout%d", i);
-       if (!strcmp (name, tmp1)) {
-           sprintf (tmp2, "kbd%d", i);
+       _stprintf (tmp1, L"KeyboardLayout%d", i);
+       if (!_tcscmp (name, tmp1)) {
+           _stprintf (tmp2, L"kbd%d", i);
            type = 0;
            break;
        }
@@ -184,22 +159,22 @@ static int port_insert2 (int num, const char *name)
     return inputdevice_joyport_config (&changed_prefs, tmp2, num, type);
 }
 
-static int port_insert (int num, const char *name)
+static int port_insert (int num, const TCHAR *name)
 {
-    char tmp1[1000];
+    TCHAR tmp1[1000];
 
     if (num < 0 || num > 1)
        return FALSE;
-    if (strlen (name) == 0) {
-       inputdevice_joyport_config (&changed_prefs, "none", num, 0);
+    if (_tcslen (name) == 0) {
+       inputdevice_joyport_config (&changed_prefs, L"none", num, 0);
        return TRUE;
     }
-    if (strlen (name) >= sizeof (tmp1) - 1)
+    if (_tcslen (name) >= sizeof (tmp1) / sizeof (TCHAR) - 1)
        return FALSE;
 
-    strcpy (tmp1, name);
+    _tcscpy (tmp1, name);
     for (;;) {
-       char *p = strrchr (tmp1, '\\');
+       TCHAR *p = _tcsrchr (tmp1, '\\');
        if (p) {
            int v = port_insert2 (num, p + 1);
            if (v)
@@ -219,7 +194,7 @@ static BOOL RPPostMessagex(UINT uMessage, WPARAM wParam, LPARAM lParam, const RP
     int dolog = log_rp;
 
     if (!pInfo) {
-       write_log ("RPPOST: pInfo == NULL!\n");
+       write_log (L"RPPOST: pInfo == NULL!\n");
         return FALSE;
     }
     if (uMessage == RPIPCGM_DEVICESEEK || uMessage == RPIPCGM_DEVICEACTIVITY)
@@ -228,14 +203,14 @@ static BOOL RPPostMessagex(UINT uMessage, WPARAM wParam, LPARAM lParam, const RP
     cnt++;
     ncnt = cnt;
     if (dolog)
-       write_log ("RPPOST_%d->\n", ncnt);
+       write_log (L"RPPOST_%d->\n", ncnt);
     v = RPPostMessage (uMessage, wParam, lParam, pInfo);
     recursive--;
     if (dolog) {
-       write_log ("RPPOST_%d(%s [%d], %08x, %08x)\n", ncnt,
+       write_log (L"RPPOST_%d(%s [%d], %08x, %08x)\n", ncnt,
            getmsg (uMessage), uMessage - WM_APP, wParam, lParam);
        if (v == FALSE)
-           write_log("ERROR %d\n", GetLastError ());
+           write_log (L"ERROR %d\n", GetLastError ());
     }
     return v;
 }
@@ -249,11 +224,11 @@ static BOOL RPSendMessagex (UINT uMessage, WPARAM wParam, LPARAM lParam,
     int dolog = log_rp;
 
     if (!pInfo) {
-       write_log ("RPSEND: pInfo == NULL!\n");
+       write_log (L"RPSEND: pInfo == NULL!\n");
         return FALSE;
     }
     if (!pInfo->hHostMessageWindow) {
-       write_log ("RPSEND: pInfo->hHostMessageWindow == NULL!\n");
+       write_log (L"RPSEND: pInfo->hHostMessageWindow == NULL!\n");
         return FALSE;
     }
     if (uMessage == RPIPCGM_DEVICESEEK)
@@ -262,14 +237,14 @@ static BOOL RPSendMessagex (UINT uMessage, WPARAM wParam, LPARAM lParam,
     cnt++;
     ncnt = cnt;
     if (dolog)
-       write_log ("RPSEND_%d->\n", ncnt);
+       write_log (L"RPSEND_%d->\n", ncnt);
     v = RPSendMessage (uMessage, wParam, lParam, pData, dwDataSize, pInfo, plResult);
     recursive--;
     if (dolog) {
-       write_log ("RPSEND_%d(%s [%d], %08x, %08x, %08x, %d)\n", ncnt,
+       write_log (L"RPSEND_%d(%s [%d], %08x, %08x, %08x, %d)\n", ncnt,
            getmsg (uMessage), uMessage - WM_APP, wParam, lParam, pData, dwDataSize);
        if (v == FALSE)
-           write_log("ERROR %d\n", GetLastError ());
+           write_log (L"ERROR %d\n", GetLastError ());
     }
     return v;
 }
@@ -353,7 +328,7 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
            vres = max_vert_dbl;
 
        if (log_rp)
-           write_log ("GET_RPSM: hres=%d (%d) vres=%d (%d) full=%d xcpos=%d ycpos=%d w=%d h=%d\n",
+           write_log (L"GET_RPSM: hres=%d (%d) vres=%d (%d) full=%d xcpos=%d ycpos=%d w=%d h=%d\n",
                totalhdbl, hres, totalvdbl, vres, full,
                p->gfx_xcenter_pos,  p->gfx_ycenter_pos,
                p->gfx_size_win.width, p->gfx_size_win.height);
@@ -381,7 +356,7 @@ static void get_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
     sm->dwScreenMode = m;
 
     if (log_rp)
-       write_log ("GET_RPSM: %08X %dx%d %dx%d hres=%d (%d) vres=%d (%d) disp=%d fs=%d\n",
+       write_log (L"GET_RPSM: %08X %dx%d %dx%d hres=%d (%d) vres=%d (%d) disp=%d fs=%d\n",
            sm->dwScreenMode, sm->lClipLeft, sm->lClipTop, sm->lClipWidth, sm->lClipHeight,
            totalhdbl, hres, totalvdbl, vres, p->gfx_display, full);
 }
@@ -406,7 +381,7 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
     disp = getdisplay (p);
 
     if (log_rp)
-       write_log ("SET_RPSM: %08X %dx%d %dx%d hres=%d vres=%d disp=%d fs=%d\n",
+       write_log (L"SET_RPSM: %08X %dx%d %dx%d hres=%d vres=%d disp=%d fs=%d\n",
            sm->dwScreenMode, sm->lClipLeft, sm->lClipTop, sm->lClipWidth, sm->lClipHeight,
            hdbl, vdbl, display, fs);
 
@@ -465,7 +440,7 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p)
        p->gfx_filter_horiz_zoom_mult = 1000;
        p->gfx_filter_vert_zoom_mult = 1000;
        if (log_rp)
-           write_log ("WW=%d WH=%d FW=%d FH=%d\n",
+           write_log (L"WW=%d WH=%d FW=%d FH=%d\n",
                p->gfx_size_win.width, p->gfx_size_win.height,
                p->gfx_size_fs.width, p->gfx_size_fs.height);
        if (fs) {
@@ -517,13 +492,13 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM
                                           LPCVOID pData, DWORD dwDataSize, LPARAM lMsgFunctionParam)
 {
     if (log_rp)
-       write_log ("RPFUNC(%s [%d], %08x, %08x, %08x, %d, %08x)\n",
+       write_log (L"RPFUNC(%s [%d], %08x, %08x, %08x, %d, %08x)\n",
            getmsg (uMessage), uMessage - WM_APP, wParam, lParam, pData, dwDataSize, lMsgFunctionParam);
 
     switch (uMessage)
     {
        default:
-           write_log ("RP: Unknown or unsupported command %x\n", uMessage);
+           write_log (L"RP: Unknown or unsupported command %x\n", uMessage);
        break;
        case RPIPCHM_PING:
            return TRUE;
@@ -570,7 +545,7 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM
        case RPIPCHM_DEVICECONTENT:
        {
            struct RPDeviceContent *dc = (struct RPDeviceContent*)pData;
-           char *n = ua (dc->szContent);
+           TCHAR *n = dc->szContent;
            int num = dc->btDeviceNumber;
            int ok = FALSE;
            switch (dc->btDeviceCategory)
@@ -595,62 +570,58 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM
        }
        case RPIPCHM_EVENT:
        {
-           char out[256];
-           char *s = ua ((WCHAR*)pData);
+           TCHAR out[256];
+           TCHAR *s = (WCHAR*)pData;
            int idx = -1;
            for (;;) {
                int ret;
                out[0] = 0;
-               ret = cfgfile_modify (idx++, s, strlen (s), out, sizeof out);
+               ret = cfgfile_modify (idx++, s, _tcslen (s), out, sizeof out / sizeof (TCHAR));
                if (ret >= 0)
                    break;
            }
-           xfree (s);
            return TRUE;
        }
        case RPIPCHM_SCREENCAPTURE:
        {
-           extern int screenshotf (const char *spath, int mode, int doprepare);
+           extern int screenshotf (const TCHAR *spath, int mode, int doprepare);
            extern int screenshotmode;
            int ok;
            int ossm = screenshotmode;
-           char *s = ua ((WCHAR*)pData);
+           TCHAR *s = (TCHAR*)pData;
            screenshotmode = 0;
            ok = screenshotf (s, 1, 1);
            screenshotmode = ossm;
-           xfree (s);
            return ok ? TRUE : FALSE;
        }
        case RPIPCHM_SAVESTATE:
        {
-           char *s = ua ((WCHAR*)pData);
+           TCHAR *s = (TCHAR*)pData;
            DWORD ret = FALSE;
            if (s == NULL) {
                savestate_initsave (NULL, 0, TRUE);
                return 1;
            }
            if (vpos == 0) {
-               savestate_initsave ("", 1, TRUE);
-               save_state (s, "AF2008");
+               savestate_initsave (L"", 1, TRUE);
+               save_state (s, L"AF2008");
                ret = 1;
            } else {
                //savestate_initsave (s, 1, TRUE);
                //ret = -1;
            }
-           xfree (s);
            return ret;
        }
        case RPIPCHM_LOADSTATE:
        {
-           char *s = ua ((WCHAR*)pData);
+           TCHAR *s = (WCHAR*)pData;
            DWORD ret = FALSE;
            DWORD attr = GetFileAttributes (s);
            if (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY)) {
                savestate_state = STATE_DORESTORE;
-               strcpy (savestate_fname, s);
+               _tcscpy (savestate_fname, s);
                ret = -1;
            }
-           xfree (s);
            return ret;
        }
     }
@@ -674,9 +645,9 @@ HRESULT rp_init (void)
     hr = RPInitializeGuest(&guestinfo, hInst, rp_param, RPHostMsgFunction, 0);
     if (SUCCEEDED (hr)) {
        initialized = TRUE;
-       write_log ("rp_init('%s') succeeded\n", rp_param);
+       write_log (L"rp_init('%s') succeeded\n", rp_param);
     } else {
-       write_log ("rp_init('%s') failed, error code %08x\n", rp_param, hr);
+       write_log (L"rp_init('%s') failed, error code %08x\n", rp_param, hr);
     }
     xfree (rp_param);
     rp_param = NULL;
@@ -732,9 +703,9 @@ void rp_fixup_options (struct uae_prefs *p)
     if (!initialized)
        return;
 
-    write_log ("rp_fixup_options(escapekey=%d,escapeholdtime=%d,screenmode=%d,inputmode=%d)\n",
+    write_log (L"rp_fixup_options(escapekey=%d,escapeholdtime=%d,screenmode=%d,inputmode=%d)\n",
        rp_rpescapekey, rp_rpescapeholdtime, rp_screenmode, rp_inputmode);
-    write_log ("w=%dx%d fs=%dx%d\n",
+    write_log (L"w=%dx%d fs=%dx%d\n",
        p->gfx_size_win.width, p->gfx_size_win.height,
        p->gfx_size_fs.width, p->gfx_size_fs.height);
 
@@ -791,11 +762,11 @@ void rp_fixup_options (struct uae_prefs *p)
        rp_update_leds (i, 0, 0);
 }
 
-static void rp_device_change (int dev, int num, const char *name)
+static void rp_device_change (int dev, int num, const TCHAR *name)
 {
     struct RPDeviceContent *dc;
     int dc_size;
-    char np[MAX_DPATH];
+    TCHAR np[MAX_DPATH];
 
     if (!cando ())
        return;
@@ -803,12 +774,12 @@ static void rp_device_change (int dev, int num, const char *name)
        return;
     np[0] = 0;
     if (name != NULL)
-       strcpy (np, name);
-    dc_size = sizeof (struct RPDeviceContent) + (strlen (np) + 1) * sizeof (WCHAR);
+       _tcscpy (np, name);
+    dc_size = sizeof (struct RPDeviceContent) + (_tcslen (np) + 1) * sizeof (TCHAR);
     dc = xcalloc (dc_size, 1);
     dc->btDeviceCategory = dev;
     dc->btDeviceNumber = num;
-    wcscpy (dc->szContent, au (np));
+    _tcscpy (dc->szContent, np);
     RPSendMessagex (RPIPCGM_DEVICECONTENT, 0, 0, dc, dc_size, &guestinfo, NULL);
     xfree (dc);
 }
@@ -818,8 +789,8 @@ void rp_input_change (int num)
     int j = jsem_isjoy (num, &currprefs);
     int m = jsem_ismouse (num, &currprefs);
     int k = jsem_iskbdjoy (num, &currprefs);
-    char name[MAX_DPATH];
-    char *name2 = NULL, *name3 = NULL;
+    TCHAR name[MAX_DPATH];
+    TCHAR *name2 = NULL, *name3 = NULL;
 
     if (JSEM_ISXARCADE1 (num, &currprefs)) {
        j = 2;
@@ -833,29 +804,29 @@ void rp_input_change (int num)
     if (j >= 0) {
        name2 = inputdevice_get_device_name (IDTYPE_JOYSTICK, j);
        name3 = inputdevice_get_device_unique_name (IDTYPE_JOYSTICK, j);
-       sprintf (name, "Joystick%d", j + 1);
+       _stprintf (name, L"Joystick%d", j + 1);
     } else if (m >= 0) {
        name2 = inputdevice_get_device_name (IDTYPE_MOUSE, m);
        name3 = inputdevice_get_device_unique_name (IDTYPE_MOUSE, m);
-       sprintf (name, "Mouse%d", m + 1);
+       _stprintf (name, L"Mouse%d", m + 1);
     } else if (k >= 0) {
-       sprintf (name, "KeyboardLayout%d", k + 1);
+       _stprintf (name, L"KeyboardLayout%d", k + 1);
     }
     if (name3) {
-        strcat (name, "\\");
-        strcat (name, name3);
+        _tcscat (name, L"\\");
+        _tcscat (name, name3);
        if (name2) {
-           strcat (name, "\\");
-           strcat (name, name2);
+           _tcscat (name, L"\\");
+           _tcscat (name, name2);
        }
     }
     rp_device_change (RP_DEVICE_INPUTPORT, num, name);
 }
-void rp_disk_image_change (int num, const char *name)
+void rp_disk_image_change (int num, const TCHAR *name)
 {
     rp_device_change (RP_DEVICE_FLOPPY, num, name);
 }
-void rp_harddrive_image_change (int num, const char *name)
+void rp_harddrive_image_change (int num, const TCHAR *name)
 {
     rp_device_change (RP_DEVICE_HD, num, name);
 }
index 1aaea487b5b63a27ed69ead617855061d7308cb8..ad0dede9052fd77d65c829734ee52c697f167965 100644 (file)
@@ -24,7 +24,7 @@ extern void rp_vsync (void);
 extern HWND rp_getparent (void);
 extern void rp_rtg_switch (void);
 
-extern char *rp_param;
+extern TCHAR *rp_param;
 extern int rp_rpescapekey;
 extern int rp_rpescapeholdtime;
 extern int rp_screenmode;
@@ -32,5 +32,5 @@ extern int rp_inputmode;
 extern int log_rp;
 
 extern void rp_input_change (int num);
-extern void rp_disk_image_change (int num, const char *name);
-extern void rp_harddrive_image_change (int num, const char *name);
+extern void rp_disk_image_change (int num, const TCHAR *name);
+extern void rp_harddrive_image_change (int num, const TCHAR *name);
index 06852dc1463644ddd54dca1ad4530c7c4c49eb9b..54234e1924c750b0b69f67eb4bce3d06e47dd713 100644 (file)
 
 int screenshotmode = PNG_SCREENSHOTS;
 
-static void namesplit (char *s)
+static void namesplit (TCHAR *s)
 {
     int l;
 
-    l = strlen (s) - 1;
+    l = _tcslen (s) - 1;
     while (l >= 0) {
        if (s[l] == '.')
            s[l] = 0;
@@ -35,7 +35,7 @@ static void namesplit (char *s)
        l--;
     }
     if (l > 0)
-       memmove (s, s + l, strlen (s + l) + 1);
+       memmove (s, s + l, (_tcslen (s + l) + 1) * sizeof (TCHAR));
 }
 
 static int toclipboard (BITMAPINFO *bi, void *bmp)
@@ -153,12 +153,12 @@ oops:
 
 #if PNG_SCREENSHOTS > 0
 
-static void pngtest_blah(png_structp png_ptr, png_const_charp message)
+static void pngtest_blah (png_structp png_ptr, png_const_charp message)
 {
-   char *name = "unknown";
+   TCHAR *name = L"unknown";
    if (png_ptr != NULL && png_ptr->error_ptr != NULL)
       name = png_ptr->error_ptr;
-   write_log ("%s: libpng warning: %s\n", name, message);
+   write_log (L"%s: libpng warning: %s\n", name, message);
 }
 
 static int savepng(FILE *fp)
@@ -188,7 +188,7 @@ static int savepng(FILE *fp)
     png_set_IHDR (png_ptr, info_ptr,
        w, h, 8, PNG_COLOR_TYPE_RGB,
        PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
-    row_pointers = xmalloc (h * sizeof(png_bytep*));
+    row_pointers = xmalloc (h * sizeof (png_bytep*));
     for (i = 0; i < h; i++) {
        int j = h - i - 1;
        row_pointers[i] = (uae_u8*)lpvBits + j * 3 * ((w + 3) & ~3);
@@ -205,13 +205,13 @@ static int savebmp(FILE *fp)
     BITMAPFILEHEADER bfh;
     // write the file header, bitmap information and pixel data
     bfh.bfType = 19778;
-    bfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + bi.bmiHeader.biSizeImage;
+    bfh.bfSize = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER) + bi.bmiHeader.biSizeImage;
     bfh.bfReserved1 = 0;
     bfh.bfReserved2 = 0;
-    bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
-    if (fwrite (&bfh, 1, sizeof(BITMAPFILEHEADER), fp) < sizeof(BITMAPFILEHEADER))
+    bfh.bfOffBits = sizeof (BITMAPFILEHEADER) + sizeof (BITMAPINFOHEADER);
+    if (fwrite (&bfh, 1, sizeof (BITMAPFILEHEADER), fp) < sizeof (BITMAPFILEHEADER))
        return 0; // failed to write bitmap file header
-    if (fwrite (&bi, 1, sizeof(BITMAPINFOHEADER), fp) < sizeof(BITMAPINFOHEADER))
+    if (fwrite (&bi, 1, sizeof (BITMAPINFOHEADER), fp) < sizeof (BITMAPINFOHEADER))
        return 0; // failed to write bitmap infomation header
     if (fwrite (lpvBits, 1, bi.bmiHeader.biSizeImage, fp) < bi.bmiHeader.biSizeImage)
        return 0; // failed to write the bitmap
@@ -221,7 +221,7 @@ static int savebmp(FILE *fp)
 /*
 Captures the Amiga display (DirectDraw, D3D or OpenGL) surface and saves it to file as a 24bit bitmap.
 */
-int screenshotf (const char *spath, int mode, int doprepare)
+int screenshotf (const TCHAR *spath, int mode, int doprepare)
 {
     static int recursive;
     FILE *fp = NULL;
@@ -243,14 +243,14 @@ int screenshotf (const char *spath, int mode, int doprepare)
     if (mode == 0) {
        toclipboard (&bi, lpvBits);
     } else {
-       char filename[MAX_DPATH];
-       char path[MAX_DPATH];
-       char name[MAX_DPATH];
-       char underline[] = "_";
+       TCHAR filename[MAX_DPATH];
+       TCHAR path[MAX_DPATH];
+       TCHAR name[MAX_DPATH];
+       TCHAR underline[] = L"_";
        int number = 0;
 
        if (spath) {
-           fp = fopen (spath, "wb");
+           fp = _tfopen (spath, L"wb");
            if (fp) {
 #if PNG_SCREENSHOTS > 0
                if (screenshotmode)
@@ -263,22 +263,22 @@ int screenshotf (const char *spath, int mode, int doprepare)
                goto oops;
            }
        }
-       fetch_path ("ScreenshotPath", path, sizeof (path));
+       fetch_path (L"ScreenshotPath", path, sizeof (path) / sizeof (TCHAR));
        CreateDirectory (path, NULL);
        name[0] = 0;
        if (currprefs.dfxtype[0] >= 0)
-           strcpy (name, currprefs.df[0]);
+           _tcscpy (name, currprefs.df[0]);
        if (!name[0])
            underline[0] = 0;
        namesplit (name);
 
        while(++number < 1000) // limit 999 iterations / screenshots
        {
-           sprintf (filename, "%s%s%s%03d.%s", path, name, underline, number, screenshotmode ? "png" : "bmp");
-           if ((fp = fopen (filename, "rb")) == NULL) // does file not exist?
+           _stprintf (filename, L"%s%s%s%03d.%s", path, name, underline, number, screenshotmode ? L"png" : L"bmp");
+           if ((fp = _tfopen (filename, L"rb")) == NULL) // does file not exist?
            {
                int ok = 0;
-               if ((fp = fopen (filename, "wb")) == NULL)
+               if ((fp = _tfopen (filename, L"wb")) == NULL)
                    goto oops; // error
 #if PNG_SCREENSHOTS > 0
                if (screenshotmode)
@@ -290,7 +290,7 @@ int screenshotf (const char *spath, int mode, int doprepare)
                fp = NULL;
                if (!ok)
                    goto oops;
-               write_log ("Screenshot saved as \"%s\"\n", filename);
+               write_log (L"Screenshot saved as \"%s\"\n", filename);
                allok = 1;
                break;
            }
index b8eb15bb698a5229da692eed6cf6391cf12fc012..1cdb9b7e51bca57585cf7ab1696c25b2803b476c 100644 (file)
@@ -79,7 +79,7 @@ void SERPER (uae_u16 w)
        serial_period_hsyncs = 1;
     serial_period_hsync_counter = 0;
 
-    write_log ("SERIAL: period=%d, baud=%d, hsyncs=%d, bits=%d, PC=%x\n", w, baud, serial_period_hsyncs, ninebit ? 9 : 8, M68K_GETPC);
+    write_log (L"SERIAL: period=%d, baud=%d, hsyncs=%d, bits=%d, PC=%x\n", w, baud, serial_period_hsyncs, ninebit ? 9 : 8, M68K_GETPC);
 
     if (ninebit)
        baud *= 2;
@@ -93,7 +93,7 @@ void SERPER (uae_u16 w)
 #endif
 }
 
-static char dochar (int v)
+static uae_char dochar (int v)
 {
     v &= 0xff;
     if (v >= 32 && v < 127) return (char)v;
@@ -118,7 +118,7 @@ static void checkreceive (int mode)
            ovrun = 1;
            INTREQ_f (0x8000 | 0x0800);
            while (readser (&recdata));
-           write_log ("SERIAL: overrun\n");
+           write_log (L"SERIAL: overrun\n");
        }
        return;
     }
@@ -136,7 +136,7 @@ static void checkreceive (int mode)
            } else {
                ninebitdata = recdata;
                if ((ninebitdata & ~1) != 0xa8) {
-                   write_log ("SERIAL: 9-bit serial emulation sync lost, %02X != %02X\n", ninebitdata & ~1, 0xa8);
+                   write_log (L"SERIAL: 9-bit serial emulation sync lost, %02X != %02X\n", ninebitdata & ~1, 0xa8);
                    ninebitdata = 0;
                    return;
                }
@@ -154,7 +154,7 @@ static void checkreceive (int mode)
     data_in_serdatr = 1;
     serial_check_irq ();
 #if SERIALDEBUG > 2
-    write_log ("SERIAL: received %02X (%c)\n", serdatr & 0xff, dochar (serdatr));
+    write_log (L"SERIAL: received %02X (%c)\n", serdatr & 0xff, doTCHAR (serdatr));
 #endif
 #endif
 }
@@ -183,7 +183,7 @@ static void checksend (int mode)
        data_in_serdat = 0;
        INTREQ_f (0x8000 | 0x0001);
 #if SERIALDEBUG > 2
-       write_log ("SERIAL: send %04X (%c)\n", serdatshift, dochar (serdatshift));
+       write_log (L"SERIAL: send %04X (%c)\n", serdatshift, doTCHAR (serdatshift));
 #endif
     }
 }
@@ -209,26 +209,26 @@ void SERDAT (uae_u16 w)
 
     if (!(w & 0x3ff)) {
 #if SERIALDEBUG > 1
-       write_log ("SERIAL: zero serial word written?! PC=%x\n", M68K_GETPC);
+       write_log (L"SERIAL: zero serial word written?! PC=%x\n", M68K_GETPC);
 #endif
        return;
     }
 
 #if SERIALDEBUG > 1
     if (data_in_serdat) {
-       write_log ("SERIAL: program wrote to SERDAT but old byte wasn't fetched yet\n");
+       write_log (L"SERIAL: program wrote to SERDAT but old byte wasn't fetched yet\n");
     }
 #endif
 
     if (seriallog)
-       console_out_f ("%c", dochar (w));
+       console_out_f (L"%c", dochar (w));
 
     if (serper == 372) {
        extern int enforcermode;
        if (enforcermode & 2) {
-           console_out_f ("%c", dochar (w));
+           console_out_f (L"%c", dochar (w));
            if (w == 266)
-               console_out("\n");
+               console_out(L"\n");
        }
     }
 
@@ -237,7 +237,7 @@ void SERDAT (uae_u16 w)
        checksend (1);
 
 #if SERIALDEBUG > 2
-    write_log ("SERIAL: wrote 0x%04x (%c) PC=%x\n", w, dochar (w), M68K_GETPC);
+    write_log (L"SERIAL: wrote 0x%04x (%c) PC=%x\n", w, doTCHAR (w), M68K_GETPC);
 #endif
 
     return;
@@ -255,7 +255,7 @@ uae_u16 SERDATR (void)
     if (ovrun)
        serdatr |= 0x8000;
 #if SERIALDEBUG > 2
-    write_log ( "SERIAL: read 0x%04x (%c) %x\n", serdatr, dochar (serdatr), M68K_GETPC);
+    write_log ( "SERIAL: read 0x%04x (%c) %x\n", serdatr, doTCHAR (serdatr), M68K_GETPC);
 #endif
     ovrun = 0;
     data_in_serdatr = 0;
@@ -300,10 +300,10 @@ void serial_flush_buffer (void)
 
 static uae_u8 oldserbits;
 
-static void serial_status_debug (char *s)
+static void serial_status_debug (TCHAR *s)
 {
 #if SERIALHSDEBUG > 1
-    write_log ("%s: DTR=%d RTS=%d CD=%d CTS=%d DSR=%d\n", s,
+    write_log (L"%s: DTR=%d RTS=%d CD=%d CTS=%d DSR=%d\n", s,
        (oldserbits & 0x80) ? 0 : 1, (oldserbits & 0x40) ? 0 : 1,
        (oldserbits & 0x20) ? 0 : 1, (oldserbits & 0x10) ? 0 : 1, (oldserbits & 0x08) ? 0 : 1);
 #endif
@@ -369,7 +369,7 @@ uae_u8 serial_readstatus (uae_u8 dir)
     oldserbits &= ~(0x08 | 0x10 | 0x20);
     oldserbits |= serbits;
 
-    serial_status_debug("read");
+    serial_status_debug (L"read");
 
     return oldserbits;
 }
@@ -391,12 +391,12 @@ uae_u8 serial_writestatus (uae_u8 newstate, uae_u8 dir)
            if (newstate & 0x40) {
                setserstat (TIOCM_RTS, 0);
 #if SERIALHSDEBUG > 0
-               write_log ("SERIAL: RTS cleared\n");
+               write_log (L"SERIAL: RTS cleared\n");
 #endif
            } else {
                setserstat (TIOCM_RTS, 1);
 #if SERIALHSDEBUG > 0
-               write_log ("SERIAL: RTS set\n");
+               write_log (L"SERIAL: RTS set\n");
 #endif
            }
        }
@@ -404,20 +404,20 @@ uae_u8 serial_writestatus (uae_u8 newstate, uae_u8 dir)
 
  #if 0 /* CIA io-pins can be read even when set to output.. */
     if ((newstate & 0x20) != (oldserbits & 0x20) && (dir & 0x20))
-       write_log ("SERIAL: warning, program tries to use CD as an output!\n");
+       write_log (L"SERIAL: warning, program tries to use CD as an output!\n");
     if ((newstate & 0x10) != (oldserbits & 0x10) && (dir & 0x10))
-       write_log ("SERIAL: warning, program tries to use CTS as an output!\n");
+       write_log (L"SERIAL: warning, program tries to use CTS as an output!\n");
     if ((newstate & 0x08) != (oldserbits & 0x08) && (dir & 0x08))
-       write_log ("SERIAL: warning, program tries to use DSR as an output!\n");
+       write_log (L"SERIAL: warning, program tries to use DSR as an output!\n");
 #endif
 
     if (logcnt > 0) {
        if (((newstate ^ oldserbits) & 0x40) && !(dir & 0x40)) {
-           write_log ("SERIAL: warning, program tries to use RTS as an input! PC=%x\n", M68K_GETPC);
+           write_log (L"SERIAL: warning, program tries to use RTS as an input! PC=%x\n", M68K_GETPC);
            logcnt--;
        }
        if (((newstate ^ oldserbits) & 0x80) && !(dir & 0x80)) {
-           write_log ("SERIAL: warning, program tries to use DTR as an input! PC=%x\n", M68K_GETPC);
+           write_log (L"SERIAL: warning, program tries to use DTR as an input! PC=%x\n", M68K_GETPC);
            logcnt--;
        }
     }
@@ -427,7 +427,7 @@ uae_u8 serial_writestatus (uae_u8 newstate, uae_u8 dir)
     oldserbits &= ~(0x80 | 0x40);
     newstate &= 0x80 | 0x40;
     oldserbits |= newstate;
-    serial_status_debug("write");
+    serial_status_debug (L"write");
 
     return oldserbits;
 }
@@ -438,8 +438,8 @@ void serial_open (void)
     if (serdev)
        return;
     serper = 0;
-    if(!openser(currprefs.sername)) {
-       write_log ("SERIAL: Could not open device %s\n", currprefs.sername);
+    if(!openser (currprefs.sername)) {
+       write_log (L"SERIAL: Could not open device %s\n", currprefs.sername);
        return;
     }
     serdev = 1;
index 8d5dc96ce94e5fa9739a38484eac1b8a3e61a376..49b7d3f796d574e5a51788dd442652bb0432b170 100644 (file)
@@ -146,7 +146,7 @@ static void clearbuffer_ds (void)
        hr = IDirectSoundBuffer_Lock (lpDSBsecondary, 0, dsoundbuf, &buffer, &size, NULL, NULL, 0);
     }
     if (FAILED (hr)) {
-       write_log ("SOUND: failed to Lock sound buffer (clear): %s\n", DXError (hr));
+       write_log (L"SOUND: failed to Lock sound buffer (clear): %s\n", DXError (hr));
        return;
     }
     memset (buffer, 0, size);
@@ -166,10 +166,10 @@ static void pause_audio_ds (void)
     waiting_for_buffer = 0;
     hr = IDirectSoundBuffer_Stop (lpDSBsecondary);
     if (FAILED (hr))
-       write_log ("SOUND: DirectSoundBuffer_Stop failed, %s\n", DXError(hr));
+       write_log (L"SOUND: DirectSoundBuffer_Stop failed, %s\n", DXError(hr));
     hr = IDirectSoundBuffer_SetCurrentPosition (lpDSBsecondary, 0);
     if (FAILED (hr))
-       write_log ("SOUND: DirectSoundBuffer_SetCurretPosition failed, %s\n", DXError (hr));
+       write_log (L"SOUND: DirectSoundBuffer_SetCurretPosition failed, %s\n", DXError (hr));
     clearbuffer ();
 }
 static void resume_audio_ds (void)
@@ -182,13 +182,13 @@ static void pause_audio_pa (void)
 {
     PaError err = Pa_StopStream (pastream);
     if (err != paNoError)
-       write_log ("SOUND: Pa_StopStream() error %d (%s)\n", err, Pa_GetErrorText (err));
+       write_log (L"SOUND: Pa_StopStream() error %d (%s)\n", err, Pa_GetErrorText (err));
 }
 static void resume_audio_pa (void)
 {
     PaError err = Pa_StartStream (pastream);
     if (err != paNoError)
-       write_log ("SOUND: Pa_StartStream() error %d (%s)\n", err, Pa_GetErrorText (err));
+       write_log (L"SOUND: Pa_StartStream() error %d (%s)\n", err, Pa_GetErrorText (err));
     paused = 0;
 }
 static void pause_audio_al (void)
@@ -207,10 +207,10 @@ static int restore_ds (DWORD hr)
     if (hr != DSERR_BUFFERLOST)
        return 0;
     if (sound_debug)
-       write_log ("SOUND: sound buffer lost\n");
+       write_log (L"SOUND: sound buffer lost\n");
     hr = IDirectSoundBuffer_Restore (lpDSBsecondary);
     if (FAILED(hr)) {
-       write_log ("SOUND: restore failed %s\n", DXError (hr));
+       write_log (L"SOUND: restore failed %s\n", DXError (hr));
        return 1;
     }
     pause_audio_ds ();
@@ -242,7 +242,7 @@ static void close_audio_ds (void)
 #endif
     if (lpDS) {
        IDirectSound_Release (lpDS);
-       write_log ("SOUND: DirectSound driver freed\n");
+       write_log (L"SOUND: DirectSound driver freed\n");
     }
     lpDS = 0;
 }
@@ -263,7 +263,7 @@ void set_volume (int volume, int mute)
            vol = (LONG)((DSBVOLUME_MIN / 2) + (-DSBVOLUME_MIN / 2) * log (1 + (2.718281828 - 1) * (1 - volume / 100.0)));
        hr = IDirectSoundBuffer_SetVolume (lpDSBsecondary, vol);
        if (FAILED (hr))
-           write_log ("SOUND: SetVolume(%d) failed: %s\n", vol, DXError (hr));
+           write_log (L"SOUND: SetVolume(%d) failed: %s\n", vol, DXError (hr));
        setvolume_ahi (vol);
     }
 }
@@ -432,12 +432,12 @@ static int open_audio_pa (int size)
                break;
            }
        }
-       write_log ("SOUND: sound format not supported\n");
+       write_log (L"SOUND: sound format not supported\n");
        goto end;
     }
     err = Pa_OpenStream (&pastream, NULL, &p, freq, paframesperbuffer, paNoFlag, portAudioCallback, NULL);
     if (err != paNoError) {
-       write_log ("SOUND: Pa_OpenStream() error %d (%s)\n", err, Pa_GetErrorText (err));
+       write_log (L"SOUND: Pa_OpenStream() error %d (%s)\n", err, Pa_GetErrorText (err));
        goto end;
     }
     paevent = CreateEvent (NULL, FALSE, FALSE, NULL);
@@ -475,6 +475,7 @@ static int open_audio_al (int size)
 {
     int freq = currprefs.sound_freq;
     int ch = get_audio_nativechannels ();
+    char *name;
 
     devicetype = SOUND_DEVICE_AL;
     size *= ch * 2;
@@ -483,7 +484,9 @@ static int open_audio_al (int size)
        sndbufsize = SND_MAX_BUFFER;
     al_bufsize = size;
     al_bigbuffer = xcalloc (al_bufsize, 1);
-    al_dev = alcOpenDevice (sound_devices[currprefs.win32_soundcard].alname);
+    name = ua (sound_devices[currprefs.win32_soundcard].alname);
+    al_dev = alcOpenDevice (name);
+    xfree (name);
     if (!al_dev)
        goto error;
     al_ctx = alcCreateContext (al_dev, NULL);
@@ -512,7 +515,7 @@ static int open_audio_al (int size)
     if (al_format == 0)
        goto error;
 
-    write_log ("SOUND: %08X,CH=%d,FREQ=%d '%s' buffer %d (%d)\n",
+    write_log (L"SOUND: %08X,CH=%d,FREQ=%d '%s' buffer %d (%d)\n",
            al_format, ch, freq, sound_devices[currprefs.win32_soundcard].alname,
            sndbufsize, al_bufsize);
     return 1;
@@ -558,13 +561,13 @@ static int open_audio_ds (int size)
 
     hr = DirectSoundCreate8 (&sound_devices[currprefs.win32_soundcard].guid, &lpDS, NULL);
     if (FAILED (hr))  {
-       write_log ("SOUND: DirectSoundCreate8() failure: %s\n", DXError (hr));
+       write_log (L"SOUND: DirectSoundCreate8() failure: %s\n", DXError (hr));
        return 0;
     }
 
     hr = IDirectSound_SetCooperativeLevel (lpDS, hMainWnd, DSSCL_PRIORITY);
     if (FAILED (hr)) {
-       write_log ("SOUND: Can't set cooperativelevel: %s\n", DXError (hr));
+       write_log (L"SOUND: Can't set cooperativelevel: %s\n", DXError (hr));
        goto error;
     }
 
@@ -572,11 +575,11 @@ static int open_audio_ds (int size)
     DSCaps.dwSize = sizeof (DSCaps);
     hr = IDirectSound_GetCaps (lpDS, &DSCaps);
     if (FAILED(hr)) {
-       write_log ("SOUND: Error getting DirectSound capabilities: %s\n", DXError (hr));
+       write_log (L"SOUND: Error getting DirectSound capabilities: %s\n", DXError (hr));
        goto error;
     }
     if (DSCaps.dwFlags & DSCAPS_EMULDRIVER) {
-       write_log ("SOUND: Emulated DirectSound driver detected, don't complain if sound quality is crap :)\n");
+       write_log (L"SOUND: Emulated DirectSound driver detected, don't complain if sound quality is crap :)\n");
     }
     if (DSCaps.dwFlags & DSCAPS_CONTINUOUSRATE) {
        int minfreq = DSCaps.dwMinSecondarySampleRate;
@@ -584,20 +587,20 @@ static int open_audio_ds (int size)
        if (minfreq > freq && freq < 22050) {
            freq = minfreq;
            changed_prefs.sound_freq = currprefs.sound_freq = freq;
-           write_log ("SOUND: minimum supported frequency: %d\n", minfreq);
+           write_log (L"SOUND: minimum supported frequency: %d\n", minfreq);
        }
        if (maxfreq < freq && freq > 44100) {
            freq = maxfreq;
            changed_prefs.sound_freq = currprefs.sound_freq = freq;
-           write_log ("SOUND: maximum supported frequency: %d\n", maxfreq);
+           write_log (L"SOUND: maximum supported frequency: %d\n", maxfreq);
        }
     }
 
     speakerconfig = fillsupportedmodes (lpDS, freq, supportedmodes);
-    write_log ("SOUND: %08X ", speakerconfig);
+    write_log (L"SOUND: %08X ", speakerconfig);
     for (i = 0; supportedmodes[i].ch; i++)
-       write_log ("%d:%08X ", supportedmodes[i].ch, supportedmodes[i].ksmode);
-    write_log ("\n");
+       write_log (L"%d:%08X ", supportedmodes[i].ch, supportedmodes[i].ksmode);
+    write_log (L"\n");
 
     for (round = 0; supportedmodes[round].ch; round++) {
        DWORD ksmode = 0;
@@ -624,7 +627,7 @@ static int open_audio_ds (int size)
        wavfmt.Format.nAvgBytesPerSec = wavfmt.Format.nBlockAlign * wavfmt.Format.nSamplesPerSec;
 
        samplesize = ch * 2;
-       write_log ("SOUND: %08X,CH=%d,FREQ=%d '%s' buffer %d (%d), dist %d\n",
+       write_log (L"SOUND: %08X,CH=%d,FREQ=%d '%s' buffer %d (%d), dist %d\n",
            ksmode, ch, freq, sound_devices[currprefs.win32_soundcard].name,
            max_sndbufsize / samplesize, max_sndbufsize, snd_configsize / samplesize);
 
@@ -645,18 +648,18 @@ static int open_audio_ds (int size)
            sound_buffer.dwFlags |=  DSBCAPS_LOCSOFTWARE;
            hr = IDirectSound_CreateSoundBuffer (lpDS, &sound_buffer, &pdsb, NULL);
            if (SUCCEEDED(hr)) {
-               //write_log ("SOUND: Couldn't use hardware buffer (switched to software): %s\n", DXError (hr2));
+               //write_log (L"SOUND: Couldn't use hardware buffer (switched to software): %s\n", DXError (hr2));
                break;
            }
        }
-       write_log ("SOUND: Secondary CreateSoundBuffer() failure: %s\n", DXError (hr));
+       write_log (L"SOUND: Secondary CreateSoundBuffer() failure: %s\n", DXError (hr));
     }
 
     if (pdsb == NULL)
        goto error;
     hr = IDirectSound_QueryInterface (pdsb, &IID_IDirectSoundBuffer8, (LPVOID*)&lpDSBsecondary);
     if (FAILED (hr))  {
-       write_log ("SOUND: Secondary QueryInterface() failure: %s\n", DXError (hr));
+       write_log (L"SOUND: Secondary QueryInterface() failure: %s\n", DXError (hr));
        goto error;
     }
     IDirectSound_Release (pdsb);
@@ -830,7 +833,7 @@ void restart_sound_buffer (void)
        return;
     hr = IDirectSoundBuffer_GetCurrentPosition (lpDSBsecondary, &playpos, &safed);
     if (FAILED (hr)) {
-       write_log ("SOUND: DirectSoundBuffer_GetCurrentPosition failed, %s\n", DXError (hr));
+       write_log (L"SOUND: DirectSoundBuffer_GetCurrentPosition failed, %s\n", DXError (hr));
        return;
     }
     writepos = safed + snd_writeoffset;
@@ -847,8 +850,8 @@ static int alcheck (int v)
         alGetSourcei (al_Source, AL_BUFFERS_PROCESSED, &v1);
        alGetSourcei (al_Source, AL_BUFFERS_QUEUED, &v2);
        alGetSourcei (al_Source, AL_SOURCE_STATE, &v3);
-       write_log ("OpenAL %d: error %d. PROC=%d QUEUE=%d STATE=%d\n", v, err, v1, v2, v3);
-       write_log ("           %d %08x %08x %08x %d %d\n",
+       write_log (L"OpenAL %d: error %d. PROC=%d QUEUE=%d STATE=%d\n", v, err, v1, v2, v3);
+       write_log (L"           %d %08x %08x %08x %d %d\n",
            al_toggle, al_Buffers[al_toggle], al_format, al_bigbuffer, al_bufsize, currprefs.sound_freq);
        return 1;
     }
@@ -892,7 +895,7 @@ static void finish_sound_buffer_al (void)
         alSourceUnqueueBuffers (al_Source, 1, &tmp);
        alGetError ();
 
-//     write_log ("           %d %08x %08x %08x %d %d\n",
+//     write_log (L"           %d %08x %08x %08x %d %d\n",
 //         al_toggle, al_Buffers[al_toggle], al_format, al_bigbuffer, al_bufsize, currprefs.sound_freq);
 
        alBufferData (al_Buffers[al_toggle], al_format, al_bigbuffer, al_bufsize, currprefs.sound_freq);
@@ -909,7 +912,7 @@ static void finish_sound_buffer_al (void)
        alcheck(3);
        if (v != AL_PLAYING && v2 >= AL_BUFFERS) {
            if (waiting_for_buffer > 0) {
-               write_log ("AL SOUND PLAY!\n");
+               write_log (L"AL SOUND PLAY!\n");
                alSourcePlay (al_Source);
                waiting_for_buffer = -1;
                tfprev = timeframes + 10;
@@ -917,7 +920,7 @@ static void finish_sound_buffer_al (void)
            } else {
                gui_data.sndbuf_status = 2;
                statuscnt = SND_STATUSCNT;
-               write_log ("AL underflow\n");
+               write_log (L"AL underflow\n");
                clearbuffer ();
                waiting_for_buffer = 1;
            }
@@ -958,7 +961,7 @@ static void finish_sound_buffer_al (void)
        }
        if (tfprev != timeframes) {
            if ((0 || sound_debug) && !(tfprev % 10))
-               write_log ("s=%+02.1f\n", skipmode);
+               write_log (L"s=%+02.1f\n", skipmode);
            tfprev = timeframes;
            if (!avioutput_audio)
                sound_setadjust (skipmode);
@@ -996,14 +999,14 @@ static void finish_sound_buffer_ds (void)
     if (waiting_for_buffer == 1) {
        hr = IDirectSoundBuffer_Play (lpDSBsecondary, 0, 0, DSBPLAY_LOOPING);
        if (FAILED (hr)) {
-           write_log ("SOUND: Play failed: %s\n", DXError (hr));
+           write_log (L"SOUND: Play failed: %s\n", DXError (hr));
            restore_ds (DSERR_BUFFERLOST);
            waiting_for_buffer = 0;
            return;
        }
        hr = IDirectSoundBuffer_SetCurrentPosition (lpDSBsecondary, 0);
        if (FAILED (hr)) {
-           write_log ("SOUND: 1st SetCurrentPosition failed: %s\n", DXError (hr));
+           write_log (L"SOUND: 1st SetCurrentPosition failed: %s\n", DXError (hr));
            restore_ds (DSERR_BUFFERLOST);
            waiting_for_buffer = 0;
            return;
@@ -1017,11 +1020,11 @@ static void finish_sound_buffer_ds (void)
            sleep_millis (1);
            counter--;
            if (counter < 0) {
-               write_log ("SOUND: stuck?!?!\n");
+               write_log (L"SOUND: stuck?!?!\n");
                break;
            }
        }
-       write_log ("SOUND: %d = (%d - %d)\n", (safedist - playpos) / samplesize, safedist / samplesize, playpos / samplesize);
+       write_log (L"SOUND: %d = (%d - %d)\n", (safedist - playpos) / samplesize, safedist / samplesize, playpos / samplesize);
        recalc_offsets ();
        safedist -= playpos;
        if (safedist < 64)
@@ -1039,7 +1042,7 @@ static void finish_sound_buffer_ds (void)
 #endif
        waiting_for_buffer = -1;
        restart_sound_buffer ();
-       write_log ("SOUND: bs=%d w=%d max=%d tof=%d tuf=%d\n",
+       write_log (L"SOUND: bs=%d w=%d max=%d tof=%d tuf=%d\n",
            sndbufsize / samplesize, snd_writeoffset / samplesize,
            snd_maxoffset / samplesize, snd_totalmaxoffset_of / samplesize,
            snd_totalmaxoffset_uf / samplesize);
@@ -1050,17 +1053,17 @@ static void finish_sound_buffer_ds (void)
     counter = 5000;
     hr = IDirectSoundBuffer_GetStatus (lpDSBsecondary, &status);
     if (FAILED (hr)) {
-       write_log ("SOUND: GetStatus() failed: %s\n", DXError (hr));
+       write_log (L"SOUND: GetStatus() failed: %s\n", DXError (hr));
        restore_ds (DSERR_BUFFERLOST);
        return;
     }
     if (status & DSBSTATUS_BUFFERLOST) {
-       write_log ("SOUND: buffer lost\n");
+       write_log (L"SOUND: buffer lost\n");
        restore_ds (DSERR_BUFFERLOST);
        return;
     }
     if ((status & (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)) != (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)) {
-       write_log ("SOUND: status = %08X\n", status);
+       write_log (L"SOUND: status = %08X\n", status);
        restore_ds (DSERR_BUFFERLOST);
        return;
     }
@@ -1068,7 +1071,7 @@ static void finish_sound_buffer_ds (void)
        hr = IDirectSoundBuffer_GetCurrentPosition (lpDSBsecondary, &playpos, &safepos);
        if (FAILED (hr)) {
            restore_ds (hr);
-           write_log ("SOUND: GetCurrentPosition failed: %s\n", DXError (hr));
+           write_log (L"SOUND: GetCurrentPosition failed: %s\n", DXError (hr));
            return;
        }
        if (writepos >= safepos)
@@ -1101,7 +1104,7 @@ static void finish_sound_buffer_ds (void)
            statuscnt = SND_STATUSCNT;
            restart_sound_buffer ();
            diff = snd_writeoffset;
-           write_log ("SOUND: underflow (%d %d)\n", diff / samplesize, snd_totalmaxoffset_of / samplesize);
+           write_log (L"SOUND: underflow (%d %d)\n", diff / samplesize, snd_totalmaxoffset_of / samplesize);
            break;
        }
 
@@ -1111,7 +1114,7 @@ static void finish_sound_buffer_ds (void)
            sleep_millis (1);
            counter--;
            if (counter < 0) {
-               write_log ("SOUND: sound system got stuck!?\n");
+               write_log (L"SOUND: sound system got stuck!?\n");
                restore_ds (DSERR_BUFFERLOST);
                return;
            }
@@ -1124,7 +1127,7 @@ static void finish_sound_buffer_ds (void)
     if (restore_ds (hr))
        return;
     if (FAILED (hr)) {
-       write_log ("SOUND: lock failed: %s (%d %d)\n", DXError (hr), writepos / samplesize, sndbufsize / samplesize);
+       write_log (L"SOUND: lock failed: %s (%d %d)\n", DXError (hr), writepos / samplesize, sndbufsize / samplesize);
        return;
     }
     memcpy (b1, sndbuffer, s1);
@@ -1159,7 +1162,7 @@ static void finish_sound_buffer_ds (void)
 
     if (tfprev != timeframes) {
        if (sound_debug && !(tfprev % 10))
-           write_log ("b=%4d,%5d,%5d,%5d d=%5d vd=%5.0f s=%+02.1f\n",
+           write_log (L"b=%4d,%5d,%5d,%5d d=%5d vd=%5.0f s=%+02.1f\n",
                sndbufsize / samplesize, snd_configsize / samplesize, max_sndbufsize / samplesize,
                dsoundbuf / samplesize, diff / samplesize, vdiff, skipmode);
        tfprev = timeframes;
@@ -1286,13 +1289,15 @@ static void OpenALEnumerate (struct sound_device *sds, const char *pDeviceNames,
        if (ok) {
            sd->type = SOUND_DEVICE_AL;
            if (ppDefaultDevice) {
-               char tmp[MAX_DPATH];
-               sprintf (tmp, "Default [%s]", devname);
-               sd->alname = my_strdup (ppDefaultDevice);
+               TCHAR tmp[MAX_DPATH];
+               TCHAR *tdevname = au (devname);
+               _stprintf (tmp, L"Default [%s]", tdevname);
+               xfree (tdevname);
+               sd->alname = my_strdup_ansi (ppDefaultDevice);
                sd->name = my_strdup (tmp);
            } else {
-               sd->alname = my_strdup (pDeviceNames);
-               sd->name = my_strdup (pDeviceNames);
+               sd->alname = my_strdup_ansi (pDeviceNames);
+               sd->name = my_strdup_ansi (pDeviceNames);
            }
            sd->cfgname = my_strdup (sd->alname);
        }
@@ -1303,7 +1308,7 @@ static void OpenALEnumerate (struct sound_device *sds, const char *pDeviceNames,
    }
 }
 
-static int isdllversion (const char *name, int version, int revision, int subver, int subrev)
+static int isdllversion (const TCHAR *name, int version, int revision, int subver, int subrev)
 {
     DWORD  dwVersionHandle, dwFileVersionInfoSize;
     LPVOID lpFileVersionData = NULL;
@@ -1319,7 +1324,7 @@ static int isdllversion (const char *name, int version, int revision, int subver
                    if (vsFileInfo) {
                        uae_u64 v1 = ((uae_u64)vsFileInfo->dwProductVersionMS << 32) | vsFileInfo->dwProductVersionLS;
                        uae_u64 v2 = ((uae_u64)version << 48) | ((uae_u64)revision << 32) | (subver << 16) | (subrev << 0);
-                       write_log ("%s %d.%d.%d.%d\n", name,
+                       write_log (L"%s %d.%d.%d.%d\n", name,
                            HIWORD (vsFileInfo->dwProductVersionMS), LOWORD (vsFileInfo->dwProductVersionMS),
                            HIWORD (vsFileInfo->dwProductVersionLS), LOWORD (vsFileInfo->dwProductVersionLS));
                        if (v1 >= v2)
@@ -1339,7 +1344,7 @@ static void PortAudioEnumerate (struct sound_device *sds)
     struct sound_device *sd;
     int num;
     int i, j;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     num = Pa_GetDeviceCount ();
     for (j = 0; j < num; j++) {
@@ -1360,7 +1365,7 @@ static void PortAudioEnumerate (struct sound_device *sds)
        }
        if (i >= MAX_SOUND_DEVICES)
            return;
-       sprintf (tmp, "[%s] %s", hai->name, di->name);
+       _stprintf (tmp, L"[%s] %s", hai->name, di->name);
        sd->type = SOUND_DEVICE_PA;
        sd->name = my_strdup (tmp);
        sd->cfgname = my_strdup (tmp);
@@ -1372,14 +1377,14 @@ int enumerate_sound_devices (void)
 {
     if (!num_sound_devices) {
        HMODULE l = NULL;
-       write_log ("Enumerating DirectSound devices..\n");
+       write_log (L"Enumerating DirectSound devices..\n");
        DirectSoundEnumerate ((LPDSENUMCALLBACK)DSEnumProc, sound_devices);
        DirectSoundCaptureEnumerate ((LPDSENUMCALLBACK)DSEnumProc, record_devices);
-       if (isdllversion ("openal32.dll", 6, 14, 357, 22)) {
-           write_log ("Enumerating OpenAL devices..\n");
+       if (isdllversion (L"openal32.dll", 6, 14, 357, 22)) {
+           write_log (L"Enumerating OpenAL devices..\n");
            if (alcIsExtensionPresent (NULL, "ALC_ENUMERATION_EXT")) {
-               const ALchar* ppDefaultDevice = alcGetString (NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
-               const ALchar* pDeviceNames = alcGetString (NULL, ALC_DEVICE_SPECIFIER);
+               const char* ppDefaultDevice = alcGetString (NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
+               const char* pDeviceNames = alcGetString (NULL, ALC_DEVICE_SPECIFIER);
                if (alcIsExtensionPresent (NULL, "ALC_ENUMERATE_ALL_EXT"))
                    pDeviceNames = alcGetString (NULL, ALC_ALL_DEVICES_SPECIFIER);
                OpenALEnumerate (sound_devices, pDeviceNames, ppDefaultDevice, FALSE);
@@ -1390,23 +1395,23 @@ int enumerate_sound_devices (void)
        }
 #if PORTAUDIO
        {
-           HMODULE hm = WIN32_LoadLibrary ("portaudio_x86.dll");
+           HMODULE hm = WIN32_LoadLibrary (L"portaudio_x86.dll");
            if (hm) {
                PaError err;
-               write_log ("Enumerating PortAudio devices..\n");
-               write_log ("%s (%d)\n", Pa_GetVersionText (), Pa_GetVersion ());
+               write_log (L"Enumerating PortAudio devices..\n");
+               write_log (L"%s (%d)\n", Pa_GetVersionText (), Pa_GetVersion ());
                err = Pa_Initialize ();
                if (err == paNoError) {
                    PortAudioEnumerate (sound_devices);
                } else {
-                   write_log ("Portaudio initializiation failed: %d (%s)\n",
+                   write_log (L"Portaudio initializiation failed: %d (%s)\n",
                        err, Pa_GetErrorText (err));
                    FreeLibrary (hm);
                }
            }
        }
 #endif
-       write_log("Enumeration end\n");
+       write_log (L"Enumeration end\n");
        for (num_sound_devices = 0; num_sound_devices < MAX_SOUND_DEVICES; num_sound_devices++) {
            if (sound_devices[num_sound_devices].name == NULL)
                break;
@@ -1478,15 +1483,15 @@ static int setget_master_volume_vista (int setvolume, int *volume, int *mute)
     return ok == 2;
 }
 
-static void mcierr (char *str, DWORD err)
+static void mcierr (TCHAR *str, DWORD err)
 {
-    char es[1000];
+    TCHAR es[1000];
     if (err == MMSYSERR_NOERROR)
        return;
-    if (mciGetErrorString (err, es, sizeof es))
-       write_log ("MCIErr: %s: %d = '%s'\n", str, err, es);
+    if (mciGetErrorString (err, es, sizeof es / sizeof (TCHAR)))
+       write_log (L"MCIErr: %s: %d = '%s'\n", str, err, es);
     else
-       write_log ("%s, errcode=%d\n", str, err);
+       write_log (L"%s, errcode=%d\n", str, err);
 }
 /* from http://www.codeproject.com/audio/mixerSetControlDetails.asp */
 static int setget_master_volume_xp (int setvolume, int *volume, int *mute)
@@ -1550,14 +1555,14 @@ static int setget_master_volume_xp (int setvolume, int *volume, int *mute)
                    if (result == MMSYSERR_NOERROR)
                        ok = 1;
                } else
-                   mcierr ("mixerGetLineControls Mute", result);
+                   mcierr (L"mixerGetLineControls Mute", result);
            } else
-               mcierr ("mixerGetLineControls Volume", result);
+               mcierr (L"mixerGetLineControls Volume", result);
        } else
-           mcierr ("mixerGetLineInfo", result);
+           mcierr (L"mixerGetLineInfo", result);
        mixerClose (hMixer);
     } else
-       mcierr ("mixerOpen", result);
+       mcierr (L"mixerOpen", result);
     return ok;
 }
 
index 534476b88b548d7b6afe334d8ad2fc7873fd4440..ad1d8a7db8a935def717e5cb2ac86e01f9b31801 100644 (file)
@@ -22,7 +22,7 @@ struct shmid_ds {
     key_t  key;
     size_t size;
     void   *addr;
-    char   name[MAX_PATH];
+    TCHAR  name[MAX_PATH];
     void   *attached;
     int    mode;
     void   *natmembase;
@@ -31,7 +31,7 @@ struct shmid_ds {
 int mprotect (void *addr, size_t len, int prot);
 void *shmat (int shmid, LPVOID shmaddr, int shmflg);
 int shmdt (const void *shmaddr);
-int shmget (key_t key, size_t size, int shmflg, const char*);
+int shmget (key_t key, size_t size, int shmflg, const TCHAR*);
 int shmctl (int shmid, int cmd, struct shmid_ds *buf);
 int init_shm (void);
 
index d37492e60e44d60c801310353f14af6c8e98fd3a..7f7dc252ffb8b93f06bf1ad14451018cc54755a2 100644 (file)
 #define TARGET_NO_ZFILE
 #define DONT_PARSE_CMDLINE
 #else
-#define TARGET_NAME "win32"
+#define TARGET_NAME L"win32"
 #endif
 #define TARGET_PROVIDES_DEFAULT_PREFS
 #define TARGET_NO_DITHER
 
 #define NO_MAIN_IN_MAIN_C
 
-#define OPTIONSFILENAME "default.uae"
+#define OPTIONSFILENAME L"default.uae"
 
index fe86b1dbadbebbdeecf3358bcc95fad5b374f095..6a2b248e55ff50ea3b0eef25350193b204c8aeee 100644 (file)
@@ -7,7 +7,7 @@ extern int uae_sem_trywait (uae_sem_t*);
 extern void uae_sem_post (uae_sem_t*);
 extern void uae_sem_wait (uae_sem_t*t);
 extern void uae_sem_init (uae_sem_t*, int manual_reset, int initial_state);
-extern int uae_start_thread (char *name, void *(*f)(void *), void *arg, uae_thread_id *thread);
+extern int uae_start_thread (TCHAR *name, void *(*f)(void *), void *arg, uae_thread_id *thread);
 extern int uae_start_thread_fast (void *(*f)(void *), void *arg, uae_thread_id *thread);
 extern void uae_end_thread (uae_thread_id *thread);
 extern void uae_set_thread_priority (int);
diff --git a/od-win32/unicode.c b/od-win32/unicode.c
new file mode 100644 (file)
index 0000000..6e56b82
--- /dev/null
@@ -0,0 +1,80 @@
+
+#include <windows.h>
+
+#include "sysconfig.h"
+#include "sysdeps.h"
+
+static char *ua_2 (const WCHAR *s, UINT cp)
+{
+    char *d;
+    int len;
+
+    if (s == NULL)
+       return NULL;
+    len = WideCharToMultiByte (cp, 0, s, -1, NULL, 0, 0, FALSE);
+    if (!len)
+       return strdup ("");
+    d = xmalloc (len + 1);
+    WideCharToMultiByte (cp, 0, s, -1, d, len, 0, FALSE);
+    return d;
+}
+
+char *ua (const WCHAR *s)
+{
+    return ua_2 (s, CP_ACP);
+}
+char *uacp (const WCHAR *s, UINT cp)
+{
+    return ua_2 (s, cp);
+}
+
+static WCHAR *au_2 (const char *s, UINT cp)
+{
+    WCHAR *d;
+    int len;
+
+    if (s == NULL)
+       return NULL;
+    len = MultiByteToWideChar (cp, MB_PRECOMPOSED, s, -1, NULL, 0);
+    if (!len)
+       return xcalloc (2, 1);
+    d = xmalloc ((len + 1) * sizeof (WCHAR));
+    MultiByteToWideChar (cp, MB_PRECOMPOSED, s, -1, d, len);
+    return d;
+}
+
+WCHAR *au (const char *s)
+{
+    return au_2 (s, CP_ACP);
+}
+WCHAR *aucp (const char *s, UINT cp)
+{
+    return au_2 (s, cp);
+}
+
+WCHAR *au_copy (TCHAR *dst, int maxlen, const char *src)
+{
+    MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, src, -1, dst, maxlen);
+    return dst;
+}
+WCHAR *aucp_copy (TCHAR *dst, int maxlen, const char *src, UINT cp)
+{
+    MultiByteToWideChar (cp, MB_PRECOMPOSED, src, -1, dst, maxlen);
+    return dst;
+}
+
+char *ua_copy (char *dst, int maxlen, const TCHAR *src)
+{
+    WideCharToMultiByte (CP_ACP, 0, src, -1, dst, maxlen, 0, FALSE);
+    return dst;
+}
+char *uacp_copy (char *dst, int maxlen, const TCHAR *src, UINT cp)
+{
+    WideCharToMultiByte (cp, 0, src, -1, dst, maxlen, 0, FALSE);
+    return dst;
+}
+
+TCHAR *my_strdup_ansi (const char *src)
+{
+    return au (src);
+}
index 9d37b2973831f205d4d6270ba508b905e68c25de..aa3dfa6f1eba536fc3e64d3c3c103eeec462036f 100644 (file)
@@ -9,12 +9,13 @@
 
 //#define MEMDEBUG
 
-#include "sysconfig.h"
-
 #include <stdlib.h>
 #include <stdarg.h>
 #include <signal.h>
 
+#include "sysconfig.h"
+
+
 #define _WIN32_WINNT 0x600 /* XButtons + MOUSEHWHEEL */
 
 #include <windows.h>
@@ -101,7 +102,7 @@ static int userdtsc = 0;
 
 HINSTANCE hInst = NULL;
 HMODULE hUIDLL = NULL;
-HWND (WINAPI *pHtmlHelp)(HWND, LPCSTR, UINT, LPDWORD) = NULL;
+HWND (WINAPI *pHtmlHelp)(HWND, LPCWSTR, UINT, LPDWORD) = NULL;
 HWND hAmigaWnd, hMainWnd, hHiddenWnd, hGUIWnd;
 RECT amigawin_rect;
 static int mouseposx, mouseposy;
@@ -113,8 +114,8 @@ static void *tablet;
 HCURSOR normalcursor;
 static HWND hwndNextViewer;
 
-char VersionStr[256];
-char BetaStr[64];
+TCHAR VersionStr[256];
+TCHAR BetaStr[64];
 extern int path_type;
 
 int in_sizemove;
@@ -135,7 +136,8 @@ int pause_emulation;
 static int didmousepos;
 static int sound_closed;
 static int recapture;
-int mouseactive, focus;
+static int focus;
+int mouseactive;
 
 static int mm_timerres;
 static int timermode, timeon;
@@ -145,17 +147,18 @@ static HANDLE timehandle[MAX_TIMEHANDLES];
 int sleep_resolution;
 static CRITICAL_SECTION cs_time;
 
-char start_path_data[MAX_DPATH];
-char start_path_exe[MAX_DPATH];
-char start_path_af[MAX_DPATH]; /* OLD AF */
-char start_path_new1[MAX_DPATH]; /* AF2005 */
-char start_path_new2[MAX_DPATH]; /* AMIGAFOREVERDATA */
-char help_file[MAX_DPATH];
+TCHAR start_path_data[MAX_DPATH];
+TCHAR start_path_exe[MAX_DPATH];
+TCHAR *pgmptr;
+TCHAR start_path_af[MAX_DPATH]; /* OLD AF */
+TCHAR start_path_new1[MAX_DPATH]; /* AF2005 */
+TCHAR start_path_new2[MAX_DPATH]; /* AMIGAFOREVERDATA */
+TCHAR help_file[MAX_DPATH];
 int af_path_2005, af_path_old;
 DWORD quickstart = 1, configurationcache = 1;
 
 static int multi_display = 1;
-static char *inipath = NULL;
+static TCHAR *inipath = NULL;
 
 static int timeend (void)
 {
@@ -164,7 +167,7 @@ static int timeend (void)
     timeon = 0;
     if (timeEndPeriod (mm_timerres) == TIMERR_NOERROR)
        return 1;
-    write_log ("TimeEndPeriod() failed\n");
+    write_log (L"TimeEndPeriod() failed\n");
     return 0;
 }
 
@@ -179,7 +182,7 @@ static int timebegin (void)
        timeon = 1;
        return 1;
     }
-    write_log ("TimeBeginPeriod() failed\n");
+    write_log (L"TimeBeginPeriod() failed\n");
     return 0;
 }
 
@@ -251,7 +254,7 @@ frame_time_t read_processor_time (void)
 
     cnt++;
     if (cnt > 1000000) {
-       write_log("**************\n");
+       write_log(L"**************\n");
        cnt = 0;
     }
 #endif
@@ -305,7 +308,7 @@ static void figure_processor_speed_rdtsc (void)
     clockrate = (win32_read_processor_time () - clockrate) * 2;
     dummythread_die = 0;
     SetThreadPriority (th, oldpri);
-    write_log ("CLOCKFREQ: RDTSC %.2fMHz\n", clockrate / 1000000.0);
+    write_log (L"CLOCKFREQ: RDTSC %.2fMHz\n", clockrate / 1000000.0);
     syncbase = clockrate >> 6;
 }
 
@@ -327,7 +330,7 @@ static void figure_processor_speed_qpf (void)
         qpfrate >>= 1;
         qpcdivisor++;
     }
-    write_log ("CLOCKFREQ: QPF %.2fMHz (%.2fMHz, DIV=%d)\n", freq.QuadPart / 1000000.0,
+    write_log (L"CLOCKFREQ: QPF %.2fMHz (%.2fMHz, DIV=%d)\n", freq.QuadPart / 1000000.0,
         qpfrate / 1000000.0, 1 << qpcdivisor);
     syncbase = (unsigned long)qpfrate;
 }
@@ -354,7 +357,7 @@ static void setcursor (int oldx, int oldy)
        return;
     }
 #if 0
-    write_log ("%d %d %d %d %d - %d %d %d %d %d\n",
+    write_log (L"%d %d %d %d %d - %d %d %d %d %d\n",
        x, amigawin_rect.left, amigawin_rect.right, mouseposx, oldx,
        y, amigawin_rect.top, amigawin_rect.bottom, mouseposy, oldy);
 #endif
@@ -367,7 +370,7 @@ static void setcursor (int oldx, int oldy)
     }
     mouseposx = mouseposy = 0;
     if (oldx < 0 || oldy < 0 || oldx > amigawin_rect.right - amigawin_rect.left || oldy > amigawin_rect.bottom - amigawin_rect.top) {
-       write_log ("Mouse out of range: %dx%d (%dx%d %dx%d)\n", oldx, oldy,
+       write_log (L"Mouse out of range: %dx%d (%dx%d %dx%d)\n", oldx, oldy,
            amigawin_rect.left, amigawin_rect.top, amigawin_rect.right, amigawin_rect.bottom);
        return;
     }
@@ -436,11 +439,11 @@ static void checkpause (void)
 
 static int showcursor;
 
-extern char config_filename[MAX_DPATH];
+extern TCHAR config_filename[MAX_DPATH];
 
 static void setmaintitle (HWND hwnd)
 {
-    char txt[1000], txt2[500];
+    TCHAR txt[1000], txt2[500];
 
 #ifdef RETROPLATFORM
     if (rp_isactive ())
@@ -448,26 +451,26 @@ static void setmaintitle (HWND hwnd)
 #endif
     txt[0] = 0;
     if (config_filename[0]) {
-       strcat (txt, "[");
-       strcat (txt, config_filename);
-       strcat (txt, "] - ");
+       _tcscat (txt, L"[");
+       _tcscat (txt, config_filename);
+       _tcscat (txt, L"] - ");
     }
-    strcat (txt, "WinUAE");
+    _tcscat (txt, L"WinUAE");
     txt2[0] = 0;
     if (mouseactive > 0) {
        WIN32GUI_LoadUIString (currprefs.win32_middle_mouse ? IDS_WINUAETITLE_MMB : IDS_WINUAETITLE_NORMAL,
-           txt2, sizeof (txt2));
+           txt2, sizeof (txt2) / sizeof (TCHAR));
     }
-    if (strlen (WINUAEBETA) > 0) {
-       strcat (txt, BetaStr);
-       if (strlen (WINUAEEXTRA) > 0) {
-           strcat (txt, " ");
-           strcat (txt, WINUAEEXTRA);
+    if (_tcslen (WINUAEBETA) > 0) {
+       _tcscat (txt, BetaStr);
+       if (_tcslen (WINUAEEXTRA) > 0) {
+           _tcscat (txt, L" ");
+           _tcscat (txt, WINUAEEXTRA);
        }
     }
     if (txt2[0]) {
-       strcat (txt, " - ");
-       strcat (txt, txt2);
+       _tcscat (txt, L" - ");
+       _tcscat (txt, txt2);
     }
     SetWindowText (hwnd, txt);
 }
@@ -482,7 +485,7 @@ void setpriority (struct threadpriorities *pri)
     int err;
     err = SetPriorityClass (GetCurrentProcess (), pri->classvalue);
     if (!err)
-       write_log ("priority set failed, %08X\n", GetLastError ());
+       write_log (L"priority set failed, %08X\n", GetLastError ());
 }
 
 static void setcursorshape (void)
@@ -525,7 +528,7 @@ void setmouseactive (int active)
     mouseactive = active;
 
     mouseposx = mouseposy = 0;
-    //write_log ("setmouseactive(%d)\n", active);
+    //write_log (L"setmouseactive(%d)\n", active);
     releasecapture ();
     recapture = 0;
 
@@ -552,7 +555,7 @@ void setmouseactive (int active)
                if (SetForegroundWindow (w1) == FALSE) {
                    if (w3 == NULL || SetForegroundWindow (w3) == FALSE) {
                        donotfocus = 1;
-                       write_log ("wanted focus but SetforegroundWindow() failed\n");
+                       write_log (L"wanted focus but SetforegroundWindow() failed\n");
                    }
                }
            }
@@ -593,7 +596,7 @@ static void winuae_active (HWND hWnd, int minimized)
 {
     struct threadpriorities *pri;
 
-    write_log ("winuae_active(%d)\n", minimized);
+    write_log (L"winuae_active(%d)\n", minimized);
     /* without this returning from hibernate-mode causes wrong timing
      */
     timeend ();
@@ -639,7 +642,7 @@ static void winuae_inactive (HWND hWnd, int minimized)
     struct threadpriorities *pri;
     int wasfocus = focus;
 
-    write_log ("winuae_inactive(%d)\n", minimized);
+    write_log (L"winuae_inactive(%d)\n", minimized);
     if (minimized)
        exit_gui (0);
     focus = 0;
@@ -718,6 +721,17 @@ void setmouseactivexy (int x, int y, int dir)
     }
 }
 
+int isfocus (void)
+{
+    if (isfullscreen () > 0)
+       return 1;
+    if (focus && mouseactive)
+       return 1;
+    if (focus)
+       return -1;
+    return 0;
+}
+
 static void handleXbutton (WPARAM wParam, int updown)
 {
     int b = GET_XBUTTON_WPARAM (wParam);
@@ -736,7 +750,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
     static int mm, minimized, recursive, ignoremousemove;
 
 #if MSGDEBUG > 1
-    write_log ("AWP: %x %d\n", hWnd, message);
+    write_log (L"AWP: %x %d\n", hWnd, message);
 #endif
     if (ignore_messages_all)
        return DefWindowProc (hWnd, message, wParam, lParam);
@@ -774,29 +788,29 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
     return 0;
 
     case WM_LBUTTONUP:
-       if (dinput_winmouse () >= 0)
+       if (dinput_winmouse () >= 0 && isfocus ())
            setmousebuttonstate (dinput_winmouse (), 0, 0);
     return 0;
     case WM_LBUTTONDOWN:
     case WM_LBUTTONDBLCLK:
        if (!mouseactive && isfullscreen() <= 0 && !gui_active && !mousehack_alive ()) {
            setmouseactive (1);
-       } else if (dinput_winmouse () >= 0) {
+       } else if (dinput_winmouse () >= 0 && isfocus ()) {
            setmousebuttonstate (dinput_winmouse (), 0, 1);
        }
     return 0;
     case WM_RBUTTONUP:
-       if (dinput_winmouse () >= 0)
+       if (dinput_winmouse () >= 0 && isfocus ())
            setmousebuttonstate (dinput_winmouse (), 1, 0);
     return 0;
     case WM_RBUTTONDOWN:
     case WM_RBUTTONDBLCLK:
-       if (dinput_winmouse () >= 0)
+       if (dinput_winmouse () >= 0 && isfocus ())
            setmousebuttonstate (dinput_winmouse (), 1, 1);
     return 0;
     case WM_MBUTTONUP:
        if (!currprefs.win32_middle_mouse) {
-           if (dinput_winmouse () >= 0)
+           if (dinput_winmouse () >= 0 && isfocus ())
                setmousebuttonstate (dinput_winmouse (), 2, 0);
        }
     return 0;
@@ -810,25 +824,25 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
            if (mouseactive)
                setmouseactive (0);
        } else {
-           if (dinput_winmouse () >= 0)
+           if (dinput_winmouse () >= 0 && isfocus ())
                setmousebuttonstate (dinput_winmouse (), 2, 1);
        }
     return 0;
     case WM_XBUTTONUP:
-       if (dinput_winmouse () >= 0) {
+       if (dinput_winmouse () >= 0 && isfocus ()) {
            handleXbutton (wParam, 0);
            return TRUE;
        }
     return 0;
     case WM_XBUTTONDOWN:
     case WM_XBUTTONDBLCLK:
-       if (dinput_winmouse () >= 0) {
+       if (dinput_winmouse () >= 0 && isfocus ()) {
            handleXbutton (wParam, 1);
            return TRUE;
        }
     return 0;
     case WM_MOUSEWHEEL:
-       if (dinput_winmouse () >= 0) {
+       if (dinput_winmouse () >= 0 && isfocus ()) {
            int val = ((short)HIWORD (wParam));
            setmousestate (dinput_winmouse (), 2, val, 0);
            if (val < 0)
@@ -839,7 +853,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
        }
     return 0;
     case WM_MOUSEHWHEEL:
-       if (dinput_winmouse () >= 0) {
+       if (dinput_winmouse () >= 0 && isfocus ()) {
            int val = ((short)HIWORD (wParam));
            setmousestate (dinput_winmouse (), 3, val, 0);
            if (val < 0)
@@ -963,7 +977,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
                setmousestate (dinput_winmouse (), 1, my, 1);
                return 0;
            }
-           if (!focus)
+           if (!focus || !mouseactive)
                return DefWindowProc (hWnd, message, wParam, lParam);
            if (dinput_winmousemode () == 0) {
                /* relative */
@@ -974,7 +988,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
                setmousestate (dinput_winmouse (), 0, mx, 0);
                setmousestate (dinput_winmouse (), 1, my, 0);
            }
-       } else if (!mouseactive && isfullscreen () <= 0) {
+       } else if (isfocus () < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) {
            setmousestate (0, 0, mx, 1);
            setmousestate (0, 1, my, 1);
        }
@@ -1005,13 +1019,13 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
            DWORD dwItem1;    // dwItem1 contains the previous PIDL or name of the folder. 
            DWORD dwItem2;    // dwItem2 contains the new PIDL or name of the folder. 
        } SHNOTIFYSTRUCT;
-       char path[MAX_PATH];
+       TCHAR path[MAX_PATH];
 
        if (lParam == SHCNE_MEDIAINSERTED || lParam == SHCNE_MEDIAREMOVED) {
            SHNOTIFYSTRUCT *shns = (SHNOTIFYSTRUCT*)wParam;
            if(SHGetPathFromIDList((struct _ITEMIDLIST *)(shns->dwItem1), path)) {
                int inserted = lParam == SHCNE_MEDIAINSERTED ? 1 : 0;
-               write_log("Shell Notification %d '%s'\n", inserted, path);
+               write_log (L"Shell Notification %d '%s'\n", inserted, path);
                if (!win32_hardfile_media_change (path, inserted)) {    
                    if ((inserted && CheckRM (path)) || !inserted) {
                        if (inserted) {
@@ -1028,9 +1042,9 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
     return TRUE;
     case WM_DEVICECHANGE:
     {
-       extern void win32_spti_media_change (char driveletter, int insert);
-       extern void win32_ioctl_media_change (char driveletter, int insert);
-       extern void win32_aspi_media_change (char driveletter, int insert);
+       extern void win32_spti_media_change (TCHAR driveletter, int insert);
+       extern void win32_ioctl_media_change (TCHAR driveletter, int insert);
+       extern void win32_aspi_media_change (TCHAR driveletter, int insert);
        DEV_BROADCAST_HDR *pBHdr = (DEV_BROADCAST_HDR *)lParam;
        static int waitfornext;
 
@@ -1049,14 +1063,14 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
            if (wParam == DBT_DEVICEARRIVAL || wParam == DBT_DEVICEREMOVECOMPLETE) {
                if (pBVol->dbcv_unitmask) {
                    int inserted, i;
-                   char drive;
+                   TCHAR drive;
                    for (i = 0; i <= 'Z'-'A'; i++) {
                        if (pBVol->dbcv_unitmask & (1 << i)) {
-                           char drvname[10];
+                           TCHAR drvname[10];
                            int type;
 
                            drive = 'A' + i;
-                           sprintf (drvname, "%c:\\", drive);
+                           _stprintf (drvname, L"%c:\\", drive);
                            type = GetDriveType (drvname);
                            if (wParam == DBT_DEVICEARRIVAL)
                                inserted = 1;
@@ -1070,7 +1084,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam,
                                win32_aspi_media_change (drive, inserted);
                            }
                            if (type == DRIVE_REMOVABLE || type == DRIVE_CDROM || !inserted) {
-                               write_log("WM_DEVICECHANGE '%s' type=%d inserted=%d\n", drvname, type, inserted);
+                               write_log (L"WM_DEVICECHANGE '%s' type=%d inserted=%d\n", drvname, type, inserted);
                                if (!win32_hardfile_media_change (drvname, inserted)) {
                                    if ((inserted && CheckRM (drvname)) || !inserted) {
                                        if (type == DRIVE_CDROM && inserted)
@@ -1237,7 +1251,7 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam,
     HDC hDC;
 
 #if MSGDEBUG > 1
-    write_log ("MWP: %x %d\n", hWnd, message);
+    write_log (L"MWP: %x %d\n", hWnd, message);
 #endif
 
     switch (message)
@@ -1331,8 +1345,8 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam,
 
                    }
                    if (store_xy++) {
-                       regsetint (NULL, "MainPosX", left);
-                       regsetint (NULL, "MainPosY", top);
+                       regsetint (NULL, L"MainPosX", left);
+                       regsetint (NULL, L"MainPosY", top);
                    }
                    changed_prefs.gfx_size_win.x = left;
                    changed_prefs.gfx_size_win.y = top;
@@ -1441,7 +1455,7 @@ static LRESULT CALLBACK HiddenWindowProc (HWND hWnd, UINT message, WPARAM wParam
            break;
     }
     if (TaskbarRestart != 0 && TaskbarRestartHWND == hWnd && message == TaskbarRestart) {
-         //write_log ("notif: taskbarrestart\n");
+         //write_log (L"notif: taskbarrestart\n");
          systray (TaskbarRestartHWND, FALSE);
     }
     return DefWindowProc (hWnd, message, wParam, lParam);
@@ -1530,7 +1544,7 @@ static int WIN32_RegisterClasses (void)
     wc.hIcon = LoadIcon (GetModuleHandle (NULL), MAKEINTRESOURCE (IDI_APPICON));
     wc.hCursor = NULL; //LoadCursor (NULL, IDC_ARROW);
     wc.lpszMenuName = 0;
-    wc.lpszClassName = "AmigaPowah";
+    wc.lpszClassName = L"AmigaPowah";
     wc.hbrBackground = CreateSolidBrush (g_dwBackgroundColor);
     if (!RegisterClass (&wc))
        return 0;
@@ -1544,7 +1558,7 @@ static int WIN32_RegisterClasses (void)
     wc.hCursor = NULL; //LoadCursor (NULL, IDC_ARROW);
     wc.hbrBackground = CreateSolidBrush (black);
     wc.lpszMenuName = 0;
-    wc.lpszClassName = "PCsuxRox";
+    wc.lpszClassName = L"PCsuxRox";
     if (!RegisterClass (&wc))
        return 0;
 
@@ -1557,12 +1571,12 @@ static int WIN32_RegisterClasses (void)
     wc.hCursor = NULL; //LoadCursor (NULL, IDC_ARROW);
     wc.hbrBackground = CreateSolidBrush (g_dwBackgroundColor);
     wc.lpszMenuName = 0;
-    wc.lpszClassName = "Useless";
+    wc.lpszClassName = L"Useless";
     if (!RegisterClass (&wc))
        return 0;
 
     hHiddenWnd = CreateWindowEx (0,
-       "Useless", "You don't see me",
+       L"Useless", L"You don't see me",
        WS_POPUP,
        0, 0,
        1, 1,
@@ -1597,14 +1611,14 @@ int WIN32_CleanupLibraries (void)
 /* HtmlHelp Initialization - optional component */
 int WIN32_InitHtmlHelp (void)
 {
-    char *chm = "WinUAE.chm";
+    TCHAR *chm = L"WinUAE.chm";
     int result = 0;
-    sprintf(help_file, "%s%s", start_path_data, chm);
+    _stprintf(help_file, L"%s%s", start_path_data, chm);
     if (!zfile_exists (help_file))
-       sprintf(help_file, "%s%s", start_path_exe, chm);
+       _stprintf(help_file, L"%s%s", start_path_exe, chm);
     if (zfile_exists (help_file)) {
-       if (hHtmlHelp = LoadLibrary ("HHCTRL.OCX")) {
-           pHtmlHelp = (HWND(WINAPI *)(HWND, LPCSTR, UINT, LPDWORD))GetProcAddress (hHtmlHelp, "HtmlHelpA");
+       if (hHtmlHelp = LoadLibrary (L"HHCTRL.OCX")) {
+           pHtmlHelp = (HWND(WINAPI *)(HWND, LPCWSTR, UINT, LPDWORD))GetProcAddress (hHtmlHelp, "HtmlHelpW");
            result = 1;
        }
     }
@@ -1613,77 +1627,77 @@ int WIN32_InitHtmlHelp (void)
 
 struct winuae_lang langs[] =
 {
-    { LANG_AFRIKAANS, "Afrikaans" },
-    { LANG_ARABIC, "Arabic" },
-    { LANG_ARMENIAN, "Armenian" },
-    { LANG_ASSAMESE, "Assamese" },
-    { LANG_AZERI, "Azeri" },
-    { LANG_BASQUE, "Basque" },
-    { LANG_BELARUSIAN, "Belarusian" },
-    { LANG_BENGALI, "Bengali" },
-    { LANG_BULGARIAN, "Bulgarian" },
-    { LANG_CATALAN, "Catalan" },
-    { LANG_CHINESE, "Chinese" },
-    { LANG_CROATIAN, "Croatian" },
-    { LANG_CZECH, "Czech" },
-    { LANG_DANISH, "Danish" },
-    { LANG_DUTCH, "Dutch" },
-    { LANG_ESTONIAN, "Estoanian" },
-    { LANG_FAEROESE, "Faeroese" },
-    { LANG_FARSI, "Farsi" },
-    { LANG_FINNISH, "Finnish" },
-    { LANG_FRENCH, "French" },
-    { LANG_GEORGIAN, "Georgian" },
-    { LANG_GERMAN, "German" },
-    { LANG_GREEK, "Greek" },
-    { LANG_GUJARATI, "Gujarati" },
-    { LANG_HEBREW, "Hebrew" },
-    { LANG_HINDI, "Hindi" },
-    { LANG_HUNGARIAN, "Hungarian" },
-    { LANG_ICELANDIC, "Icelandic" },
-    { LANG_INDONESIAN, "Indonesian" },
-    { LANG_ITALIAN, "Italian" },
-    { LANG_JAPANESE, "Japanese" },
-    { LANG_KANNADA, "Kannada" },
-    { LANG_KASHMIRI, "Kashmiri" },
-    { LANG_KAZAK, "Kazak" },
-    { LANG_KONKANI, "Konkani" },
-    { LANG_KOREAN, "Korean" },
-    { LANG_LATVIAN, "Latvian" },
-    { LANG_LITHUANIAN, "Lithuanian" },
-    { LANG_MACEDONIAN, "Macedonian" },
-    { LANG_MALAY, "Malay" },
-    { LANG_MALAYALAM, "Malayalam" },
-    { LANG_MANIPURI, "Manipuri" },
-    { LANG_MARATHI, "Marathi" },
-    { LANG_NEPALI, "Nepali" },
-    { LANG_NORWEGIAN, "Norwegian" },
-    { LANG_ORIYA, "Oriya" },
-    { LANG_POLISH, "Polish" },
-    { LANG_PORTUGUESE, "Portuguese" },
-    { LANG_PUNJABI, "Punjabi" },
-    { LANG_ROMANIAN, "Romanian" },
-    { LANG_RUSSIAN, "Russian" },
-    { LANG_SANSKRIT, "Sanskrit" },
-    { LANG_SINDHI, "Sindhi" },
-    { LANG_SLOVAK, "Slovak" },
-    { LANG_SLOVENIAN, "Slovenian" },
-    { LANG_SPANISH, "Spanish" },
-    { LANG_SWAHILI, "Swahili" },
-    { LANG_SWEDISH, "Swedish" },
-    { LANG_TAMIL, "Tamil" },
-    { LANG_TATAR, "Tatar" },
-    { LANG_TELUGU, "Telugu" },
-    { LANG_THAI, "Thai" },
-    { LANG_TURKISH, "Turkish" },
-    { LANG_UKRAINIAN, "Ukrainian" },
-    { LANG_UZBEK, "Uzbek" },
-    { LANG_VIETNAMESE, "Vietnamese" },
-    { LANG_ENGLISH, "default" },
-    { 0x400, "guidll.dll"},
+    { LANG_AFRIKAANS, L"Afrikaans" },
+    { LANG_ARABIC, L"Arabic" },
+    { LANG_ARMENIAN, L"Armenian" },
+    { LANG_ASSAMESE, L"Assamese" },
+    { LANG_AZERI, L"Azeri" },
+    { LANG_BASQUE, L"Basque" },
+    { LANG_BELARUSIAN, L"Belarusian" },
+    { LANG_BENGALI, L"Bengali" },
+    { LANG_BULGARIAN, L"Bulgarian" },
+    { LANG_CATALAN, L"Catalan" },
+    { LANG_CHINESE, L"Chinese" },
+    { LANG_CROATIAN, L"Croatian" },
+    { LANG_CZECH, L"Czech" },
+    { LANG_DANISH, L"Danish" },
+    { LANG_DUTCH, L"Dutch" },
+    { LANG_ESTONIAN, L"Estoanian" },
+    { LANG_FAEROESE, L"Faeroese" },
+    { LANG_FARSI, L"Farsi" },
+    { LANG_FINNISH, L"Finnish" },
+    { LANG_FRENCH, L"French" },
+    { LANG_GEORGIAN, L"Georgian" },
+    { LANG_GERMAN, L"German" },
+    { LANG_GREEK, L"Greek" },
+    { LANG_GUJARATI, L"Gujarati" },
+    { LANG_HEBREW, L"Hebrew" },
+    { LANG_HINDI, L"Hindi" },
+    { LANG_HUNGARIAN, L"Hungarian" },
+    { LANG_ICELANDIC, L"Icelandic" },
+    { LANG_INDONESIAN, L"Indonesian" },
+    { LANG_ITALIAN, L"Italian" },
+    { LANG_JAPANESE, L"Japanese" },
+    { LANG_KANNADA, L"Kannada" },
+    { LANG_KASHMIRI, L"Kashmiri" },
+    { LANG_KAZAK, L"Kazak" },
+    { LANG_KONKANI, L"Konkani" },
+    { LANG_KOREAN, L"Korean" },
+    { LANG_LATVIAN, L"Latvian" },
+    { LANG_LITHUANIAN, L"Lithuanian" },
+    { LANG_MACEDONIAN, L"Macedonian" },
+    { LANG_MALAY, L"Malay" },
+    { LANG_MALAYALAM, L"Malayalam" },
+    { LANG_MANIPURI, L"Manipuri" },
+    { LANG_MARATHI, L"Marathi" },
+    { LANG_NEPALI, L"Nepali" },
+    { LANG_NORWEGIAN, L"Norwegian" },
+    { LANG_ORIYA, L"Oriya" },
+    { LANG_POLISH, L"Polish" },
+    { LANG_PORTUGUESE, L"Portuguese" },
+    { LANG_PUNJABI, L"Punjabi" },
+    { LANG_ROMANIAN, L"Romanian" },
+    { LANG_RUSSIAN, L"Russian" },
+    { LANG_SANSKRIT, L"Sanskrit" },
+    { LANG_SINDHI, L"Sindhi" },
+    { LANG_SLOVAK, L"Slovak" },
+    { LANG_SLOVENIAN, L"Slovenian" },
+    { LANG_SPANISH, L"Spanish" },
+    { LANG_SWAHILI, L"Swahili" },
+    { LANG_SWEDISH, L"Swedish" },
+    { LANG_TAMIL, L"Tamil" },
+    { LANG_TATAR, L"Tatar" },
+    { LANG_TELUGU, L"Telugu" },
+    { LANG_THAI, L"Thai" },
+    { LANG_TURKISH, L"Turkish" },
+    { LANG_UKRAINIAN, L"Ukrainian" },
+    { LANG_UZBEK, L"Uzbek" },
+    { LANG_VIETNAMESE, L"Vietnamese" },
+    { LANG_ENGLISH, L"default" },
+    { 0x400, L"guidll.dll"},
     { 0, NULL }
 };
-static char *getlanguagename(DWORD id)
+static TCHAR *getlanguagename(DWORD id)
 {
     int i;
     for (i = 0; langs[i].name; i++) {
@@ -1699,13 +1713,13 @@ static PGETUSERDEFAULTUILANGUAGE pGetUserDefaultUILanguage;
 HMODULE language_load (WORD language)
 {
     HMODULE result = NULL;
-    char dllbuf[MAX_DPATH];
-    char *dllname;
+    TCHAR dllbuf[MAX_DPATH];
+    TCHAR *dllname;
 
     if (language <= 0) {
        /* new user-specific Windows ME/2K/XP method to get UI language */
        pGetUserDefaultUILanguage = (PGETUSERDEFAULTUILANGUAGE)GetProcAddress (
-           GetModuleHandle ("kernel32.dll"), "GetUserDefaultUILanguage");
+           GetModuleHandle (L"kernel32.dll"), "GetUserDefaultUILanguage");
        language = GetUserDefaultLangID ();
        if (pGetUserDefaultUILanguage)
            language = pGetUserDefaultUILanguage ();
@@ -1723,9 +1737,9 @@ HMODULE language_load (WORD language)
        int fail = 1;
 
        if (language == 0x400)
-           strcpy (dllbuf, "guidll.dll");
+           _tcscpy (dllbuf, L"guidll.dll");
        else
-           sprintf (dllbuf, "WinUAE_%s.dll", dllname);
+           _stprintf (dllbuf, L"WinUAE_%s.dll", dllname);
        result = WIN32_LoadLibrary (dllbuf);
        if (result)  {
            dwFileVersionInfoSize = GetFileVersionInfoSize (dllbuf, &dwVersionHandle);
@@ -1741,9 +1755,9 @@ HMODULE language_load (WORD language)
                                && LOWORD(vsFileInfo->dwProductVersionMS) == UAEMINOR
                                && (HIWORD(vsFileInfo->dwProductVersionLS) == UAESUBREV || HIWORD(vsFileInfo->dwProductVersionLS) == UAESUBREV - 1)) {
                                success = TRUE;
-                               write_log ("Translation DLL '%s' loaded and enabled\n", dllbuf);
+                               write_log (L"Translation DLL '%s' loaded and enabled\n", dllbuf);
                            } else {
-                               write_log ("Translation DLL '%s' version mismatch (%d.%d.%d)\n", dllbuf,
+                               write_log (L"Translation DLL '%s' version mismatch (%d.%d.%d)\n", dllbuf,
                                    HIWORD(vsFileInfo->dwProductVersionMS),
                                    LOWORD(vsFileInfo->dwProductVersionMS),
                                    HIWORD(vsFileInfo->dwProductVersionLS));
@@ -1757,7 +1771,7 @@ HMODULE language_load (WORD language)
        if (fail) {
            DWORD err = GetLastError ();
            if (err != ERROR_MOD_NOT_FOUND && err != ERROR_DLL_NOT_FOUND)
-               write_log ("Translation DLL '%s' failed to load, error %d\n", dllbuf, GetLastError ());
+               write_log (L"Translation DLL '%s' failed to load, error %d\n", dllbuf, GetLastError ());
        }
        if (result && !success) {
            FreeLibrary (result);
@@ -1780,8 +1794,8 @@ static void pritransla (void)
     int i;
 
     for (i = 0; priorities[i].id; i++) {
-       char tmp[MAX_DPATH];
-       WIN32GUI_LoadUIString (priorities[i].id, tmp, sizeof (tmp));
+       TCHAR tmp[MAX_DPATH];
+       WIN32GUI_LoadUIString (priorities[i].id, tmp, sizeof (tmp) / sizeof (TCHAR));
        priorities[i].name = my_strdup (tmp);
     }
 }
@@ -1791,7 +1805,7 @@ static void WIN32_InitLang (void)
     int lid;
     WORD langid = -1;
 
-    if (regqueryint (NULL, "Language", &lid))
+    if (regqueryint (NULL, L"Language", &lid))
        langid = (WORD)lid;
     hUIDLL = language_load (langid);
     pritransla ();
@@ -1805,21 +1819,21 @@ static int WIN32_InitLibraries (void)
     CoInitialize (0);
     /* Determine our processor speed and capabilities */
     if (!init_mmtimer ()) {
-       pre_gui_message ("MMTimer initialization failed, exiting..");
+       pre_gui_message (L"MMTimer initialization failed, exiting..");
        return 0;
     }
     if (!QueryPerformanceCounter (&freq)) {
-       pre_gui_message ("No QueryPerformanceFrequency() supported, exiting..\n");
+       pre_gui_message (L"No QueryPerformanceFrequency() supported, exiting..\n");
        return 0;
     }
     rpt_available = 1;
     figure_processor_speed ();
     if (!timebegin ()) {
-       pre_gui_message ("MMTimer second initialization failed, exiting..");
+       pre_gui_message (L"MMTimer second initialization failed, exiting..");
        return 0;
     }
 
-    hRichEdit = LoadLibrary ("RICHED32.DLL");
+    hRichEdit = LoadLibrary (L"RICHED32.DLL");
     return 1;
 }
 
@@ -1831,19 +1845,19 @@ int debuggable (void)
 void toggle_mousegrab (void)
 {
 }
-#define LOG_BOOT "winuaebootlog.txt"
-#define LOG_NORMAL "winuaelog.txt"
+#define LOG_BOOT L"winuaebootlog.txt"
+#define LOG_NORMAL L"winuaelog.txt"
 
 void logging_open(int bootlog, int append)
 {
-    char debugfilename[MAX_DPATH];
+    TCHAR debugfilename[MAX_DPATH];
 
     debugfilename[0] = 0;
 #ifndef        SINGLEFILE
     if (currprefs.win32_logfile)
-       sprintf (debugfilename, "%s%s", start_path_data, LOG_NORMAL);
+       _stprintf (debugfilename, L"%s%s", start_path_data, LOG_NORMAL);
     if (bootlog)
-       sprintf (debugfilename, "%s%s", start_path_data, LOG_BOOT);
+       _stprintf (debugfilename, L"%s%s", start_path_data, LOG_BOOT);
     if (debugfilename[0]) {
        if (!debugfile)
            debugfile = log_open (debugfilename, append, bootlog);
@@ -1861,11 +1875,11 @@ void logging_init(void)
     static int first;
 
     if (first > 1) {
-       write_log ("** RESTART **\n");
+       write_log (L"** RESTART **\n");
        return;
     }
     if (first == 1) {
-       write_log ("Log (%s): '%s%s'\n", currprefs.win32_logfile ? "enabled" : "disabled",
+       write_log (L"Log (%s): '%s%s'\n", currprefs.win32_logfile ? L"enabled" : L"disabled",
            start_path_data, LOG_NORMAL);
        if (debugfile)
            log_close (debugfile);
@@ -1874,25 +1888,25 @@ void logging_init(void)
     logging_open (first ? 0 : 1, 0);
     logging_started = 1;
     first++;
-    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress (GetModuleHandle ("kernel32"), "IsWow64Process");
+    fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress (GetModuleHandle (L"kernel32"), "IsWow64Process");
     if (fnIsWow64Process)
        fnIsWow64Process (GetCurrentProcess (), &wow64);
-    write_log ("%s (%d.%d %s%s[%d])", VersionStr,
+    write_log (L"%s (%d.%d %s%s[%d])", VersionStr,
        osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.szCSDVersion,
-       strlen(osVersion.szCSDVersion) > 0 ? " " : "", os_winnt_admin);
-    write_log (" %d-bit %X.%X %d", wow64 ? 64 : 32,
+       _tcslen (osVersion.szCSDVersion) > 0 ? L" " : L"", os_winnt_admin);
+    write_log (L" %d-bit %X.%X %d", wow64 ? 64 : 32,
        SystemInfo.wProcessorLevel, SystemInfo.wProcessorRevision,
        SystemInfo.dwNumberOfProcessors);
-    write_log ("\n(c) 1995-2001 Bernd Schmidt   - Core UAE concept and implementation."
-              "\n(c) 1998-2009 Toni Wilen      - Win32 port, core code updates."
-              "\n(c) 1996-2001 Brian King      - Win32 port, Picasso96 RTG, and GUI."
-              "\n(c) 1996-1999 Mathias Ortmann - Win32 port and bsdsocket support."
-              "\n(c) 2000-2001 Bernd Meyer     - JIT engine."
-              "\n(c) 2000-2005 Bernd Roesch    - MIDI input, many fixes."
-              "\nPress F12 to show the Settings Dialog (GUI), Alt-F4 to quit."
-              "\nEnd+F1 changes floppy 0, End+F2 changes floppy 1, etc."
-              "\n");
-    write_log ("EXE: '%s', DATA: '%s'\n", start_path_exe, start_path_data);
+    write_log (L"\n(c) 1995-2001 Bernd Schmidt   - Core UAE concept and implementation."
+              L"\n(c) 1998-2009 Toni Wilen      - Win32 port, core code updates."
+              L"\n(c) 1996-2001 Brian King      - Win32 port, Picasso96 RTG, and GUI."
+              L"\n(c) 1996-1999 Mathias Ortmann - Win32 port and bsdsocket support."
+              L"\n(c) 2000-2001 Bernd Meyer     - JIT engine."
+              L"\n(c) 2000-2005 Bernd Roesch    - MIDI input, many fixes."
+              L"\nPress F12 to show the Settings Dialog (GUI), Alt-F4 to quit."
+              L"\nEnd+F1 changes floppy 0, End+F2 changes floppy 1, etc."
+              L"\n");
+    write_log (L"EXE: '%s', DATA: '%s'\n", start_path_exe, start_path_data);
     regstatus ();
 }
 
@@ -1911,7 +1925,7 @@ uae_u8 *save_log (int bootlog, int *len)
 
     if (!logging_started)
        return NULL;
-    f = fopen (bootlog ? LOG_BOOT : LOG_NORMAL, "rb");
+    f = _tfopen (bootlog ? LOG_BOOT : LOG_NORMAL, L"rb");
     if (!f)
        return NULL;
     fseek (f, 0, SEEK_END);
@@ -1929,41 +1943,41 @@ uae_u8 *save_log (int bootlog, int *len)
     return dst;
 }
 
-static void strip_slashes (char *p)
+static void strip_slashes (TCHAR *p)
 {
-    while (strlen (p) > 0 && (p[strlen (p) - 1] == '\\' || p[strlen (p) - 1] == '/'))
-       p[strlen (p) - 1] = 0;
+    while (_tcslen (p) > 0 && (p[_tcslen (p) - 1] == '\\' || p[_tcslen (p) - 1] == '/'))
+       p[_tcslen (p) - 1] = 0;
 }
-static void fixtrailing(char *p)
+static void fixtrailing(TCHAR *p)
 {
-    if (strlen(p) == 0)
+    if (_tcslen(p) == 0)
        return;
-    if (p[strlen(p) - 1] == '/' || p[strlen(p) - 1] == '\\')
+    if (p[_tcslen(p) - 1] == '/' || p[_tcslen(p) - 1] == '\\')
        return;
-    strcat(p, "\\");
+    _tcscat(p, L"\\");
 }
 
 typedef DWORD (STDAPICALLTYPE *PFN_GetKey)(LPVOID lpvBuffer, DWORD dwSize);
-uae_u8 *target_load_keyfile (struct uae_prefs *p, char *path, int *sizep, char *name)
+uae_u8 *target_load_keyfile (struct uae_prefs *p, TCHAR *path, int *sizep, TCHAR *name)
 {
     uae_u8 *keybuf = NULL;
     HMODULE h;
     PFN_GetKey pfnGetKey;
     int size;
-    char *libname = "amigaforever.dll";
+    TCHAR *libname = L"amigaforever.dll";
 
     h = WIN32_LoadLibrary (libname);
     if (!h) {
-       char path[MAX_DPATH];
-       sprintf (path, "%s..\\Player\\%s", start_path_exe, libname);
+       TCHAR path[MAX_DPATH];
+       _stprintf (path, L"%s..\\Player\\%s", start_path_exe, libname);
        h = LoadLibrary (path);
        if (!h) {
-           char *afr = getenv ("AMIGAFOREVERROOT");
+           TCHAR *afr = _wgetenv (L"AMIGAFOREVERROOT");
            if (afr) {
-               char tmp[MAX_DPATH];
-               strcpy (tmp, afr);
+               TCHAR tmp[MAX_DPATH];
+               _tcscpy (tmp, afr);
                fixtrailing (tmp);
-               sprintf (path, "%sPlayer\\%s", tmp, libname);
+               _stprintf (path, L"%sPlayer\\%s", tmp, libname);
                h = LoadLibrary (path);
                if (!h)
                    return NULL;
@@ -1988,7 +2002,7 @@ uae_u8 *target_load_keyfile (struct uae_prefs *p, char *path, int *sizep, char *
 }
 
 
-extern char *get_aspi_path(int);
+extern TCHAR *get_aspi_path(int);
 
 static get_aspi (int old)
 {
@@ -2056,6 +2070,7 @@ void target_default_options (struct uae_prefs *p, int type)
        p->win32_rtgallowscaling = 0;
        p->win32_rtgscaleaspectratio = -1;
        p->win32_rtgvblankrate = 0;
+       p->win32_fscodepage = 1252;
     }
     if (type == 1 || type == 0) {
        p->win32_uaescsimode = get_aspi (p->win32_uaescsimode);
@@ -2070,57 +2085,58 @@ void target_default_options (struct uae_prefs *p, int type)
     }
 }
 
-static const char *scsimode[] = { "none", "SPTI", "SPTI+SCSISCAN", "AdaptecASPI", "NeroASPI", "FrogASPI", 0 };
+static const TCHAR *scsimode[] = { L"none", L"SPTI", L"SPTI+SCSISCAN", L"AdaptecASPI", L"NeroASPI", L"FrogASPI", 0 };
 
 void target_save_options (struct zfile *f, struct uae_prefs *p)
 {
-    cfgfile_target_dwrite (f, "middle_mouse=%s\n", p->win32_middle_mouse ? "true" : "false");
-    cfgfile_target_dwrite (f, "logfile=%s\n", p->win32_logfile ? "true" : "false");
-    cfgfile_target_dwrite (f, "map_drives=%s\n", p->win32_automount_drives ? "true" : "false");
-    cfgfile_target_dwrite (f, "map_drives_auto=%s\n", p->win32_automount_removable ? "true" : "false");
-    cfgfile_target_dwrite (f, "map_cd_drives=%s\n", p->win32_automount_cddrives ? "true" : "false");
-    cfgfile_target_dwrite (f, "map_net_drives=%s\n", p->win32_automount_netdrives ? "true" : "false");
-    cfgfile_target_dwrite (f, "map_removable_drives=%s\n", p->win32_automount_removabledrives ? "true" : "false");
+    cfgfile_target_dwrite (f, L"middle_mouse=%s\n", p->win32_middle_mouse ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"logfile=%s\n", p->win32_logfile ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"map_drives=%s\n", p->win32_automount_drives ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"map_drives_auto=%s\n", p->win32_automount_removable ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"map_cd_drives=%s\n", p->win32_automount_cddrives ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"map_net_drives=%s\n", p->win32_automount_netdrives ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"map_removable_drives=%s\n", p->win32_automount_removabledrives ? L"true" : L"false");
     serdevtoname (p->sername);
-    cfgfile_target_dwrite (f, "serial_port=%s\n", p->sername[0] ? p->sername : "none");
+    cfgfile_target_dwrite (f, L"serial_port=%s\n", p->sername[0] ? p->sername : L"none");
     sernametodev (p->sername);
-    cfgfile_target_dwrite (f, "parallel_port=%s\n", p->prtname[0] ? p->prtname : "none");
-
-    cfgfile_target_dwrite (f, "active_priority=%d\n", priorities[p->win32_active_priority].value);
-    cfgfile_target_dwrite (f, "inactive_priority=%d\n", priorities[p->win32_inactive_priority].value);
-    cfgfile_target_dwrite (f, "inactive_nosound=%s\n", p->win32_inactive_nosound ? "true" : "false");
-    cfgfile_target_dwrite (f, "inactive_pause=%s\n", p->win32_inactive_pause ? "true" : "false");
-    cfgfile_target_dwrite (f, "iconified_priority=%d\n", priorities[p->win32_iconified_priority].value);
-    cfgfile_target_dwrite (f, "iconified_nosound=%s\n", p->win32_iconified_nosound ? "true" : "false");
-    cfgfile_target_dwrite (f, "iconified_pause=%s\n", p->win32_iconified_pause ? "true" : "false");
-
-    cfgfile_target_dwrite (f, "ctrl_f11_is_quit=%s\n", p->win32_ctrl_F11_is_quit ? "true" : "false");
-    cfgfile_target_dwrite (f, "midiout_device=%d\n", p->win32_midioutdev);
-    cfgfile_target_dwrite (f, "midiin_device=%d\n", p->win32_midiindev);
-    cfgfile_target_dwrite (f, "rtg_match_depth=%s\n", p->win32_rtgmatchdepth ? "true" : "false");
-    cfgfile_target_dwrite (f, "rtg_scale_small=%s\n", p->win32_rtgscaleifsmall ? "true" : "false");
-    cfgfile_target_dwrite (f, "rtg_scale_allow=%s\n", p->win32_rtgallowscaling ? "true" : "false");
-    cfgfile_target_dwrite (f, "rtg_scale_aspect_ratio=%d:%d\n",
+    cfgfile_target_dwrite (f, L"parallel_port=%s\n", p->prtname[0] ? p->prtname : L"none");
+
+    cfgfile_target_dwrite (f, L"active_priority=%d\n", priorities[p->win32_active_priority].value);
+    cfgfile_target_dwrite (f, L"inactive_priority=%d\n", priorities[p->win32_inactive_priority].value);
+    cfgfile_target_dwrite (f, L"inactive_nosound=%s\n", p->win32_inactive_nosound ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"inactive_pause=%s\n", p->win32_inactive_pause ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"iconified_priority=%d\n", priorities[p->win32_iconified_priority].value);
+    cfgfile_target_dwrite (f, L"iconified_nosound=%s\n", p->win32_iconified_nosound ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"iconified_pause=%s\n", p->win32_iconified_pause ? L"true" : L"false");
+
+    cfgfile_target_dwrite (f, L"ctrl_f11_is_quit=%s\n", p->win32_ctrl_F11_is_quit ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"midiout_device=%d\n", p->win32_midioutdev);
+    cfgfile_target_dwrite (f, L"midiin_device=%d\n", p->win32_midiindev);
+    cfgfile_target_dwrite (f, L"rtg_match_depth=%s\n", p->win32_rtgmatchdepth ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"rtg_scale_small=%s\n", p->win32_rtgscaleifsmall ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"rtg_scale_allow=%s\n", p->win32_rtgallowscaling ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"rtg_scale_aspect_ratio=%d:%d\n",
        p->win32_rtgscaleaspectratio >= 0 ? (p->win32_rtgscaleaspectratio >> 8) : -1,
        p->win32_rtgscaleaspectratio >= 0 ? (p->win32_rtgscaleaspectratio & 0xff) : -1);
     if (p->win32_rtgvblankrate <= 0)
-       cfgfile_target_dwrite (f, "rtg_vblank=%s\n", p->win32_rtgvblankrate == -1 ? "real" : (p->win32_rtgvblankrate == -2 ? "disabled" : "chipset"));
+       cfgfile_target_dwrite (f, L"rtg_vblank=%s\n", p->win32_rtgvblankrate == -1 ? L"real" : (p->win32_rtgvblankrate == -2 ? L"disabled" : L"chipset"));
     else
-       cfgfile_target_dwrite (f, "rtg_vblank=%d\n", p->win32_rtgvblankrate);
-    cfgfile_target_dwrite (f, "borderless=%s\n", p->win32_borderless ? "true" : "false");
-    cfgfile_target_dwrite (f, "uaescsimode=%s\n", scsimode[p->win32_uaescsimode]);
-    cfgfile_target_dwrite (f, "soundcard=%d\n", p->win32_soundcard);
+       cfgfile_target_dwrite (f, L"rtg_vblank=%d\n", p->win32_rtgvblankrate);
+    cfgfile_target_dwrite (f, L"borderless=%s\n", p->win32_borderless ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"uaescsimode=%s\n", scsimode[p->win32_uaescsimode]);
+    cfgfile_target_dwrite (f, L"soundcard=%d\n", p->win32_soundcard);
     if (sound_devices[p->win32_soundcard].cfgname)
-       cfgfile_target_dwrite (f, "soundcardname=%s\n", sound_devices[p->win32_soundcard].cfgname);
-    cfgfile_target_dwrite (f, "cpu_idle=%d\n", p->cpu_idle);
-    cfgfile_target_dwrite (f, "notaskbarbutton=%s\n", p->win32_notaskbarbutton ? "true" : "false");
-    cfgfile_target_dwrite (f, "always_on_top=%s\n", p->win32_alwaysontop ? "true" : "false");
-    cfgfile_target_dwrite (f, "no_recyclebin=%s\n", p->win32_norecyclebin ? "true" : "false");
-    cfgfile_target_dwrite (f, "specialkey=0x%x\n", p->win32_specialkey);
+       cfgfile_target_dwrite (f, L"soundcardname=%s\n", sound_devices[p->win32_soundcard].cfgname);
+    cfgfile_target_dwrite (f, L"cpu_idle=%d\n", p->cpu_idle);
+    cfgfile_target_dwrite (f, L"notaskbarbutton=%s\n", p->win32_notaskbarbutton ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"always_on_top=%s\n", p->win32_alwaysontop ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"no_recyclebin=%s\n", p->win32_norecyclebin ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"specialkey=0x%x\n", p->win32_specialkey);
     if (p->win32_guikey >= 0)
-       cfgfile_target_dwrite (f, "guikey=0x%x\n", p->win32_guikey);
-    cfgfile_target_dwrite (f, "kbledmode=%d\n", p->win32_kbledmode);
-    cfgfile_target_dwrite (f, "powersavedisabled=%s\n", p->win32_powersavedisabled ? "true" : "false");
+       cfgfile_target_dwrite (f, L"guikey=0x%x\n", p->win32_guikey);
+    cfgfile_target_dwrite (f, L"kbledmode=%d\n", p->win32_kbledmode);
+    cfgfile_target_dwrite (f, L"powersavedisabled=%s\n", p->win32_powersavedisabled ? L"true" : L"false");
+    cfgfile_target_dwrite (f, L"filesystem_codepage=%d\n", p->win32_fscodepage);
 
 }
 
@@ -2135,55 +2151,56 @@ static int fetchpri (int pri, int defpri)
     return defpri;
 }
 
-static const char *obsolete[] = {
-    "killwinkeys", "sound_force_primary", "iconified_highpriority",
-    "sound_sync", "sound_tweak", "directx6", "sound_style",
-    "file_path", "iconified_nospeed", "activepriority", "magic_mouse",
+static const TCHAR *obsolete[] = {
+    L"killwinkeys", L"sound_force_primary", L"iconified_highpriority",
+    L"sound_sync", L"sound_tweak", L"directx6", L"sound_style",
+    L"file_path", L"iconified_nospeed", L"activepriority", L"magic_mouse",
     0
 };
 
-int target_parse_option (struct uae_prefs *p, char *option, char *value)
+int target_parse_option (struct uae_prefs *p, TCHAR *option, TCHAR *value)
 {
-    char tmpbuf[CONFIG_BLEN];
+    TCHAR tmpbuf[CONFIG_BLEN];
     int i, v;
-    int result = (cfgfile_yesno (option, value, "middle_mouse", &p->win32_middle_mouse)
-           || cfgfile_yesno (option, value, "map_drives", &p->win32_automount_drives)
-           || cfgfile_yesno (option, value, "map_drives_auto", &p->win32_automount_removable)
-           || cfgfile_yesno (option, value, "map_cd_drives", &p->win32_automount_cddrives)
-           || cfgfile_yesno (option, value, "map_net_drives", &p->win32_automount_netdrives)
-           || cfgfile_yesno (option, value, "map_removable_drives", &p->win32_automount_removabledrives)
-           || cfgfile_yesno (option, value, "logfile", &p->win32_logfile)
-           || cfgfile_yesno (option, value, "networking", &p->socket_emu)
-           || cfgfile_yesno (option, value, "borderless", &p->win32_borderless)
-           || cfgfile_yesno (option, value, "inactive_pause", &p->win32_inactive_pause)
-           || cfgfile_yesno (option, value, "inactive_nosound", &p->win32_inactive_nosound)
-           || cfgfile_yesno (option, value, "iconified_pause", &p->win32_iconified_pause)
-           || cfgfile_yesno (option, value, "iconified_nosound", &p->win32_iconified_nosound)
-           || cfgfile_yesno (option, value, "ctrl_f11_is_quit", &p->win32_ctrl_F11_is_quit)
-           || cfgfile_yesno (option, value, "no_recyclebin", &p->win32_norecyclebin)
-           || cfgfile_intval (option, value, "midi_device", &p->win32_midioutdev, 1)
-           || cfgfile_intval (option, value, "midiout_device", &p->win32_midioutdev, 1)
-           || cfgfile_intval (option, value, "midiin_device", &p->win32_midiindev, 1)
-           || cfgfile_intval (option, value, "soundcard", &p->win32_soundcard, 1)
-           || cfgfile_yesno (option, value, "notaskbarbutton", &p->win32_notaskbarbutton)
-           || cfgfile_yesno (option, value, "always_on_top", &p->win32_alwaysontop)
-           || cfgfile_yesno (option, value, "powersavedisabled", &p->win32_powersavedisabled)
-           || cfgfile_intval (option, value, "specialkey", &p->win32_specialkey, 1)
-           || cfgfile_intval (option, value, "guikey", &p->win32_guikey, 1)
-           || cfgfile_intval (option, value, "kbledmode", &p->win32_kbledmode, 1)
-           || cfgfile_intval (option, value, "cpu_idle", &p->cpu_idle, 1));
-
-    if (cfgfile_yesno (option, value, "rtg_match_depth", &p->win32_rtgmatchdepth))
+    int result = (cfgfile_yesno (option, value, L"middle_mouse", &p->win32_middle_mouse)
+           || cfgfile_yesno (option, value, L"map_drives", &p->win32_automount_drives)
+           || cfgfile_yesno (option, value, L"map_drives_auto", &p->win32_automount_removable)
+           || cfgfile_yesno (option, value, L"map_cd_drives", &p->win32_automount_cddrives)
+           || cfgfile_yesno (option, value, L"map_net_drives", &p->win32_automount_netdrives)
+           || cfgfile_yesno (option, value, L"map_removable_drives", &p->win32_automount_removabledrives)
+           || cfgfile_yesno (option, value, L"logfile", &p->win32_logfile)
+           || cfgfile_yesno (option, value, L"networking", &p->socket_emu)
+           || cfgfile_yesno (option, value, L"borderless", &p->win32_borderless)
+           || cfgfile_yesno (option, value, L"inactive_pause", &p->win32_inactive_pause)
+           || cfgfile_yesno (option, value, L"inactive_nosound", &p->win32_inactive_nosound)
+           || cfgfile_yesno (option, value, L"iconified_pause", &p->win32_iconified_pause)
+           || cfgfile_yesno (option, value, L"iconified_nosound", &p->win32_iconified_nosound)
+           || cfgfile_yesno (option, value, L"ctrl_f11_is_quit", &p->win32_ctrl_F11_is_quit)
+           || cfgfile_yesno (option, value, L"no_recyclebin", &p->win32_norecyclebin)
+           || cfgfile_intval (option, value, L"midi_device", &p->win32_midioutdev, 1)
+           || cfgfile_intval (option, value, L"midiout_device", &p->win32_midioutdev, 1)
+           || cfgfile_intval (option, value, L"midiin_device", &p->win32_midiindev, 1)
+           || cfgfile_intval (option, value, L"soundcard", &p->win32_soundcard, 1)
+           || cfgfile_yesno (option, value, L"notaskbarbutton", &p->win32_notaskbarbutton)
+           || cfgfile_yesno (option, value, L"always_on_top", &p->win32_alwaysontop)
+           || cfgfile_yesno (option, value, L"powersavedisabled", &p->win32_powersavedisabled)
+           || cfgfile_intval (option, value, L"specialkey", &p->win32_specialkey, 1)
+           || cfgfile_intval (option, value, L"guikey", &p->win32_guikey, 1)
+           || cfgfile_intval (option, value, L"kbledmode", &p->win32_kbledmode, 1)
+           || cfgfile_intval (option, value, L"filesystem_codepage", &p->win32_fscodepage, 1)
+           || cfgfile_intval (option, value, L"cpu_idle", &p->cpu_idle, 1));
+
+    if (cfgfile_yesno (option, value, L"rtg_match_depth", &p->win32_rtgmatchdepth))
        return 1;
-    if (cfgfile_yesno (option, value, "rtg_scale_small", &p->win32_rtgscaleifsmall))
+    if (cfgfile_yesno (option, value, L"rtg_scale_small", &p->win32_rtgscaleifsmall))
        return 1;
-    if (cfgfile_yesno (option, value, "rtg_scale_allow", &p->win32_rtgallowscaling))
+    if (cfgfile_yesno (option, value, L"rtg_scale_allow", &p->win32_rtgallowscaling))
        return 1;
 
-    if (cfgfile_string (option, value, "soundcardname", tmpbuf, sizeof tmpbuf)) {
+    if (cfgfile_string (option, value, L"soundcardname", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
        int i;
        for (i = 0; sound_devices[i].cfgname; i++) {
-           if (!strcmp (sound_devices[i].cfgname, tmpbuf)) {
+           if (!_tcscmp (sound_devices[i].cfgname, tmpbuf)) {
                p->win32_soundcard = i;
                break;
            }
@@ -2191,7 +2208,7 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value)
        return 1;
     }
 
-    if (cfgfile_yesno (option, value, "aspi", &v)) {
+    if (cfgfile_yesno (option, value, L"aspi", &v)) {
        p->win32_uaescsimode = 0;
        if (v)
            p->win32_uaescsimode = get_aspi(0);
@@ -2200,32 +2217,32 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value)
        return 1;
     }
 
-    if (cfgfile_string (option, value, "rtg_vblank", tmpbuf, sizeof tmpbuf)) {
-       if (!strcmp (tmpbuf, "real")) {
+    if (cfgfile_string (option, value, L"rtg_vblank", tmpbuf, sizeof tmpbuf / sizeof (TCHAR))) {
+       if (!_tcscmp (tmpbuf, L"real")) {
            p->win32_rtgvblankrate = -1;
            return 1;
        }
-       if (!strcmp (tmpbuf, "disabled")) {
+       if (!_tcscmp (tmpbuf, L"disabled")) {
            p->win32_rtgvblankrate = -2;
            return 1;
        }
-       if (!strcmp (tmpbuf, "chipset")) {
+       if (!_tcscmp (tmpbuf, L"chipset")) {
            p->win32_rtgvblankrate = 0;
            return 1;
        }
-       p->win32_rtgvblankrate = atol (tmpbuf);
+       p->win32_rtgvblankrate = _tstol (tmpbuf);
        return 1;
     }
 
-    if (cfgfile_string (option, value, "rtg_scale_aspect_ratio", tmpbuf, sizeof tmpbuf)) {
+    if (cfgfile_string (option, value, L"rtg_scale_aspect_ratio", tmpbuf, sizeof tmpbuf) / sizeof (TCHAR)) {
        int v1, v2;
-       char *s;
+       TCHAR *s;
        
        p->gfx_filter_aspect = -1;
-       v1 = atol (tmpbuf);
-       s = strchr (tmpbuf, ':');
+       v1 = _tstol (tmpbuf);
+       s = _tcschr (tmpbuf, ':');
        if (s) {
-           v2 = atol (s + 1);
+           v2 = _tstol (s + 1);
            if (v1 < 0 || v2 < 0)
                p->gfx_filter_aspect = -1;
            else if (v1 == 0 || v2 == 0)
@@ -2236,27 +2253,27 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value)
        return 1;
     }
 
-    if (cfgfile_strval (option, value, "uaescsimode", &p->win32_uaescsimode, scsimode, 0))
+    if (cfgfile_strval (option, value, L"uaescsimode", &p->win32_uaescsimode, scsimode, 0))
        return 1;
 
-    if (cfgfile_intval (option, value, "active_priority", &v, 1)) {
+    if (cfgfile_intval (option, value, L"active_priority", &v, 1)) {
        p->win32_active_priority = fetchpri (v, 1);
        return 1;
     }
-    if (cfgfile_intval (option, value, "activepriority", &v, 1)) {
+    if (cfgfile_intval (option, value, L"activepriority", &v, 1)) {
        p->win32_active_priority = fetchpri (v, 1);
        return 1;
     }
-    if (cfgfile_intval (option, value, "inactive_priority", &v, 1)) {
+    if (cfgfile_intval (option, value, L"inactive_priority", &v, 1)) {
        p->win32_inactive_priority = fetchpri (v, 1);
        return 1;
     }
-    if (cfgfile_intval (option, value, "iconified_priority", &v, 1)) {
+    if (cfgfile_intval (option, value, L"iconified_priority", &v, 1)) {
        p->win32_iconified_priority = fetchpri (v, 2);
        return 1;
     }
 
-    if (cfgfile_string (option, value, "serial_port", &p->sername[0], 256)) {
+    if (cfgfile_string (option, value, L"serial_port", &p->sername[0], 256)) {
        sernametodev(p->sername);
        if (p->sername[0])
            p->use_serial = 1;
@@ -2265,8 +2282,8 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value)
        return 1;
     }
 
-    if (cfgfile_string (option, value, "parallel_port", &p->prtname[0], 256)) {
-       if (!strcmp(p->prtname, "none"))
+    if (cfgfile_string (option, value, L"parallel_port", &p->prtname[0], 256)) {
+       if (!_tcscmp(p->prtname, L"none"))
            p->prtname[0] = 0;
        return 1;
     }
@@ -2274,7 +2291,7 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value)
     i = 0;
     while (obsolete[i]) {
        if (!strcasecmp (obsolete[i], option)) {
-           write_log ("obsolete config entry '%s'\n", option);
+           write_log (L"obsolete config entry '%s'\n", option);
            return 1;
        }
        i++;
@@ -2283,50 +2300,51 @@ int target_parse_option (struct uae_prefs *p, char *option, char *value)
     return result;
 }
 
-static void createdir (const char *path)
+static void createdir (const TCHAR *path)
 {
     CreateDirectory (path, NULL);
 }
 
-void fetch_saveimagepath (char *out, int size, int dir)
+void fetch_saveimagepath (TCHAR *out, int size, int dir)
 {
-    fetch_path ("SaveimagePath", out, size);
+    assert (size > MAX_DPATH);
+    fetch_path (L"SaveimagePath", out, size);
     if (dir) {
-       out[strlen (out) - 1] = 0;
+       out[_tcslen (out) - 1] = 0;
        createdir (out);
-       fetch_path ("SaveimagePath", out, size);
+       fetch_path (L"SaveimagePath", out, size);
     }
 }
-void fetch_configurationpath (char *out, int size)
+void fetch_configurationpath (TCHAR *out, int size)
 {
-    fetch_path ("ConfigurationPath", out, size);
+    fetch_path (L"ConfigurationPath", out, size);
 }
-void fetch_screenshotpath (char *out, int size)
+void fetch_screenshotpath (TCHAR *out, int size)
 {
-    fetch_path ("ScreenshotPath", out, size);
+    fetch_path (L"ScreenshotPath", out, size);
 }
-void fetch_ripperpath (char *out, int size)
+void fetch_ripperpath (TCHAR *out, int size)
 {
-    fetch_path ("RipperPath", out, size);
+    fetch_path (L"RipperPath", out, size);
 }
-void fetch_datapath (char *out, int size)
+void fetch_datapath (TCHAR *out, int size)
 {
     fetch_path (NULL, out, size);
 }
 
-static int isfilesindir(char *p)
+static int isfilesindir (TCHAR *p)
 {
     WIN32_FIND_DATA fd;
     HANDLE h;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
     int i = 0;
     DWORD v;
 
     v = GetFileAttributes (p);
     if (v == INVALID_FILE_ATTRIBUTES || !(v & FILE_ATTRIBUTE_DIRECTORY))
        return 0;
-    strcpy (path, p);
-    strcat (path, "\\*.*");
+    _tcscpy (path, p);
+    _tcscat (path, L"\\*.*");
     h = FindFirstFile (path, &fd);
     if (h != INVALID_HANDLE_VALUE) {
        for (i = 0; i < 3; i++) {
@@ -2340,99 +2358,99 @@ static int isfilesindir(char *p)
     return 0;
 }
 
-void fetch_path (char *name, char *out, int size)
+void fetch_path (TCHAR *name, TCHAR *out, int size)
 {
     int size2 = size;
 
-    strcpy (out, start_path_data);
+    _tcscpy (out, start_path_data);
     if (!name)
        return;
-    if (!strcmp (name, "FloppyPath"))
-       strcat (out, "..\\shared\\adf\\");
-    if (!strcmp (name, "hdfPath"))
-       strcat (out, "..\\shared\\hdf\\");
-    if (!strcmp (name, "KickstartPath"))
-       strcat (out, "..\\shared\\rom\\");
-    if (!strcmp (name, "ConfigurationPath"))
-       strcat (out, "Configurations\\");
+    if (!_tcscmp (name, L"FloppyPath"))
+       _tcscat (out, L"..\\shared\\adf\\");
+    if (!_tcscmp (name, L"hdfPath"))
+       _tcscat (out, L"..\\shared\\hdf\\");
+    if (!_tcscmp (name, L"KickstartPath"))
+       _tcscat (out, L"..\\shared\\rom\\");
+    if (!_tcscmp (name, L"ConfigurationPath"))
+       _tcscat (out, L"Configurations\\");
     if (start_data >= 0)
        regquerystr (NULL, name, out, &size); 
-    if (out[0] == '\\' && (strlen(out) >= 2 && out[1] != '\\')) { /* relative? */
-       strcpy (out, start_path_data);
+    if (out[0] == '\\' && (_tcslen (out) >= 2 && out[1] != '\\')) { /* relative? */
+       _tcscpy (out, start_path_data);
        if (start_data >= 0) {
-           size2 -= strlen (out);
+           size2 -= _tcslen (out);
            regquerystr (NULL, name, out, &size2);
        }
     }
     strip_slashes (out);
-    if (!strcmp (name, "KickstartPath")) {
+    if (!_tcscmp (name, L"KickstartPath")) {
        DWORD v = GetFileAttributes (out);
        if (v == INVALID_FILE_ATTRIBUTES || !(v & FILE_ATTRIBUTE_DIRECTORY))
-           strcpy (out, start_path_data);
+           _tcscpy (out, start_path_data);
     }
     fixtrailing (out);
 }
 
-int get_rom_path(char *out, int mode)
+int get_rom_path(TCHAR *out, int mode)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     tmp[0] = 0;
     switch (mode)
     {
        case 0:
        {
-           if (!strcmp (start_path_data, start_path_exe))
-               strcpy (tmp, ".\\");
+           if (!_tcscmp (start_path_data, start_path_exe))
+               _tcscpy (tmp, L".\\");
            else
-               strcpy (tmp, start_path_data);
+               _tcscpy (tmp, start_path_data);
            if (GetFileAttributes (tmp) != INVALID_FILE_ATTRIBUTES) {
-               char tmp2[MAX_DPATH];
-               strcpy (tmp2, tmp);
-               strcat (tmp2, "rom");
+               TCHAR tmp2[MAX_DPATH];
+               _tcscpy (tmp2, tmp);
+               _tcscat (tmp2, L"rom");
                if (GetFileAttributes (tmp2) != INVALID_FILE_ATTRIBUTES) {
-                   strcpy (tmp, tmp2);
+                   _tcscpy (tmp, tmp2);
                } else {
-                   strcpy (tmp2, tmp);
-                   strcpy (tmp2, "roms");
+                   _tcscpy (tmp2, tmp);
+                   _tcscpy (tmp2, L"roms");
                    if (GetFileAttributes (tmp2) != INVALID_FILE_ATTRIBUTES)
-                       strcpy (tmp, tmp2);
+                       _tcscpy (tmp, tmp2);
                }
            }
        }
        break;
        case 1:
        {
-           char tmp2[MAX_DPATH];
-           strcpy (tmp2, start_path_new1);
-           strcat (tmp2, "..\\system\\rom");
+           TCHAR tmp2[MAX_DPATH];
+           _tcscpy (tmp2, start_path_new1);
+           _tcscat (tmp2, L"..\\system\\rom");
            if (isfilesindir (tmp2))
-               strcpy (tmp, tmp2);
+               _tcscpy (tmp, tmp2);
        }
        break;
        case 2:
        {
-           char tmp2[MAX_DPATH];
-           strcpy (tmp2, start_path_new2);
-           strcat (tmp2, "system\\rom");
+           TCHAR tmp2[MAX_DPATH];
+           _tcscpy (tmp2, start_path_new2);
+           _tcscat (tmp2, L"system\\rom");
            if (isfilesindir (tmp2))
-               strcpy (tmp, tmp2);
+               _tcscpy (tmp, tmp2);
        }
        break;
        case 3:
        {
-           char tmp2[MAX_DPATH];
-           strcpy (tmp2, start_path_af);
-           strcat (tmp2, "..\\shared\\rom");
+           TCHAR tmp2[MAX_DPATH];
+           _tcscpy (tmp2, start_path_af);
+           _tcscat (tmp2, L"..\\shared\\rom");
            if (isfilesindir (tmp2))
-               strcpy (tmp, tmp2);
+               _tcscpy (tmp, tmp2);
        }
        break;
        default:
        return -1;
     }
     if (isfilesindir (tmp)) {
-       strcpy (out, tmp);
+       _tcscpy (out, tmp);
        fixtrailing (out);
     }
     return out[0] ? 1 : 0;
@@ -2440,32 +2458,32 @@ int get_rom_path(char *out, int mode)
 
 
 
-void set_path (char *name, char *path)
+void set_path (TCHAR *name, TCHAR *path)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     if (!path) {
-       if (!strcmp (start_path_data, start_path_exe))
-           strcpy (tmp, ".\\");
+       if (!_tcscmp (start_path_data, start_path_exe))
+           _tcscpy (tmp, L".\\");
        else
-           strcpy (tmp, start_path_data);
-       if (!strcmp (name, "KickstartPath"))
-           strcat (tmp, "Roms");
-       if (!strcmp (name, "ConfigurationPath"))
-           strcat (tmp, "Configurations");
-       if (!strcmp (name, "ScreenshotPath"))
-           strcat (tmp, "Screenshots");
-       if (!strcmp (name, "StatefilePath"))
-           strcat (tmp, "Savestates");
-       if (!strcmp (name, "SaveimagePath"))
-           strcat (tmp, "SaveImages");
-       if (!strcmp (name, "InputPath"))
-           strcat (tmp, "Inputrecordings");
+           _tcscpy (tmp, start_path_data);
+       if (!_tcscmp (name, L"KickstartPath"))
+           _tcscat (tmp, L"Roms");
+       if (!_tcscmp (name, L"ConfigurationPath"))
+           _tcscat (tmp, L"Configurations");
+       if (!_tcscmp (name, L"ScreenshotPath"))
+           _tcscat (tmp, L"Screenshots");
+       if (!_tcscmp (name, L"StatefilePath"))
+           _tcscat (tmp, L"Savestates");
+       if (!_tcscmp (name, L"SaveimagePath"))
+           _tcscat (tmp, L"SaveImages");
+       if (!_tcscmp (name, L"InputPath"))
+           _tcscat (tmp, L"Inputrecordings");
     } else {
-       strcpy (tmp, path);
+       _tcscpy (tmp, path);
     }
     strip_slashes (tmp);
-    if (!strcmp (name, "KickstartPath")) {
+    if (!_tcscmp (name, L"KickstartPath")) {
        DWORD v = GetFileAttributes (tmp);
        if (v == INVALID_FILE_ATTRIBUTES || !(v & FILE_ATTRIBUTE_DIRECTORY))
            get_rom_path (tmp, 0);
@@ -2481,25 +2499,25 @@ void set_path (char *name, char *path)
     regsetstr (NULL, name, tmp);
 }
 
-static void initpath (char *name, char *path)
+static void initpath (TCHAR *name, TCHAR *path)
 {
     if (regexists (NULL, name))
        return;
     set_path (name, NULL);
 }
 
-static void romlist_add2 (char *path, struct romdata *rd)
+static void romlist_add2 (TCHAR *path, struct romdata *rd)
 {
     if (getregmode ()) {
        int ok = 0;
-       char tmp[MAX_DPATH];
+       TCHAR tmp[MAX_DPATH];
        if (path[0] == '/' || path[0] == '\\')
            ok = 1;
-       if (strlen (path) > 1 && path[1] == ':')
+       if (_tcslen (path) > 1 && path[1] == ':')
            ok = 1;
        if (!ok) {
-           strcpy (tmp, start_path_exe);
-           strcat (tmp, path);
+           _tcscpy (tmp, start_path_exe);
+           _tcscat (tmp, path);
            romlist_add (tmp, rd);
            return;
        }
@@ -2510,15 +2528,15 @@ static void romlist_add2 (char *path, struct romdata *rd)
 extern int scan_roms (int);
 void read_rom_list (void)
 {
-    char tmp2[1000];
+    TCHAR tmp2[1000];
     int idx, idx2;
     UAEREG *fkey;
-    char tmp[1000];
+    TCHAR tmp[1000];
     int size, size2, exists;
 
     romlist_clear ();
-    exists = regexiststree (NULL, "DetectedROMs");
-    fkey = regcreatetree (NULL, "DetectedROMs");
+    exists = regexiststree (NULL, L"DetectedROMs");
+    fkey = regcreatetree (NULL, L"DetectedROMs");
     if (fkey == NULL)
        return;
     if (!exists || forceroms) {
@@ -2528,25 +2546,25 @@ void read_rom_list (void)
     forceroms = 0;
     idx = 0;
     for (;;) {
-       size = sizeof (tmp);
-       size2 = sizeof (tmp2);
+       size = sizeof (tmp) / sizeof (TCHAR);
+       size2 = sizeof (tmp2) / sizeof (TCHAR);
        if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2))
            break;
-       if (strlen (tmp) == 7 || strlen (tmp) == 13) {
+       if (_tcslen (tmp) == 7 || _tcslen (tmp) == 13) {
            int group = 0;
            int subitem = 0;
-           idx2 = atol (tmp + 4);
-           if (strlen (tmp) == 13) {
-               group = atol (tmp + 8);
-               subitem = atol (tmp + 11);
+           idx2 = _tstol (tmp + 4);
+           if (_tcslen (tmp) == 13) {
+               group = _tstol (tmp + 8);
+               subitem = _tstol (tmp + 11);
            }
-           if (idx2 >= 0 && strlen (tmp2) > 0) {
+           if (idx2 >= 0 && _tcslen (tmp2) > 0) {
                struct romdata *rd = getromdatabyidgroup (idx2, group, subitem);
                if (rd) {
-                   char *s = strchr (tmp2, '\"');
-                   if (s && strlen (s) > 1) {
-                       char *s2 = my_strdup (s + 1);
-                       s = strchr (s2, '\"');
+                   TCHAR *s = _tcschr (tmp2, '\"');
+                   if (s && _tcslen (s) > 1) {
+                       TCHAR *s2 = my_strdup (s + 1);
+                       s = _tcschr (s2, '\"');
                        if (s)
                            *s = 0;
                        romlist_add2 (s2, rd);
@@ -2563,14 +2581,14 @@ void read_rom_list (void)
     regclosetree (fkey);
 }
 
-static int parseversion (char **vs)
+static int parseversion (TCHAR **vs)
 {
-    char tmp[10];
+    TCHAR tmp[10];
     int i;
 
     i = 0;
     while (**vs >= '0' && **vs <= '9') {
-       if (i >= sizeof (tmp))
+       if (i >= sizeof (tmp) / sizeof (TCHAR))
            return 0;
        tmp[i++] = **vs;
        (*vs)++;
@@ -2578,14 +2596,14 @@ static int parseversion (char **vs)
     if (**vs == '.')
        (*vs)++;
     tmp[i] = 0;
-    return atol (tmp);
+    return _tstol (tmp);
 }
 
-static int checkversion (char *vs)
+static int checkversion (TCHAR *vs)
 {
-    if (strlen (vs) < 10)
+    if (_tcslen (vs) < 10)
        return 0;
-    if (memcmp (vs, "WinUAE ", 7))
+    if (_tcsncmp (vs, L"WinUAE L", 7))
        return 0;
     vs += 7;
     if (parseversion (&vs) > UAEMAJOR)
@@ -2597,138 +2615,138 @@ static int checkversion (char *vs)
     return 1;
 }
 
-static int shell_deassociate (const char *extension)
+static int shell_deassociate (const TCHAR *extension)
 {
     HKEY rkey;
-    const char *progid = "WinUAE";
-    int def = !strcmp (extension, ".uae");
-    char rpath1[MAX_DPATH], rpath2[MAX_DPATH], progid2[MAX_DPATH];
+    const TCHAR *progid = L"WinUAE";
+    int def = !_tcscmp (extension, L".uae");
+    TCHAR rpath1[MAX_DPATH], rpath2[MAX_DPATH], progid2[MAX_DPATH];
     UAEREG *fkey;
 
-    if (extension == NULL || strlen (extension) < 1 || extension[0] != '.')
+    if (extension == NULL || _tcslen (extension) < 1 || extension[0] != '.')
        return 0;
-    strcpy (progid2, progid);
-    strcat (progid2, extension);
+    _tcscpy (progid2, progid);
+    _tcscat (progid2, extension);
     if (os_winnt_admin > 1)
         rkey = HKEY_LOCAL_MACHINE;
     else
         rkey = HKEY_CURRENT_USER;
 
-    strcpy (rpath1, "Software\\Classes\\");
-    strcpy (rpath2, rpath1);
-    strcat (rpath2, extension);
+    _tcscpy (rpath1, L"Software\\Classes\\");
+    _tcscpy (rpath2, rpath1);
+    _tcscat (rpath2, extension);
     if (RegDeleteKey (rkey, rpath2) != ERROR_SUCCESS)
        return 0;
-    strcpy (rpath2, rpath1);
-    strcat (rpath2, progid);
+    _tcscpy (rpath2, rpath1);
+    _tcscat (rpath2, progid);
     if (!def)
-       strcat (rpath2, extension);
+       _tcscat (rpath2, extension);
     SHDeleteKey (rkey, rpath2);
-    fkey = regcreatetree (NULL, "FileAssociations");
+    fkey = regcreatetree (NULL, L"FileAssociations");
     regdelete (fkey, extension);
     regclosetree (fkey);
     return 1;
 }
 
-static int shell_associate_2 (const char *extension, const char *shellcommand, const char *command, const char *perceivedtype,
-                             const char *description, const char *ext2)
+static int shell_associate_2 (const TCHAR *extension, const TCHAR *shellcommand, const TCHAR *command, const TCHAR *perceivedtype,
+                             const TCHAR *description, const TCHAR *ext2)
 {
-    char rpath1[MAX_DPATH], rpath2[MAX_DPATH], progid2[MAX_DPATH];
+    TCHAR rpath1[MAX_DPATH], rpath2[MAX_DPATH], progid2[MAX_DPATH];
     HKEY rkey, key1;
     DWORD disposition;
-    const char *progid = "WinUAE";
-    int def = !strcmp (extension, ".uae");
+    const TCHAR *progid = L"WinUAE";
+    int def = !_tcscmp (extension, L".uae");
     UAEREG *fkey;
 
-    strcpy (progid2, progid);
-    strcat (progid2, ext2 ? ext2 : extension);
+    _tcscpy (progid2, progid);
+    _tcscat (progid2, ext2 ? ext2 : extension);
     if (os_winnt_admin > 1)
         rkey = HKEY_LOCAL_MACHINE;
     else
         rkey = HKEY_CURRENT_USER;
 
-    strcpy (rpath1, "Software\\Classes\\");
-    strcpy (rpath2, rpath1);
-    strcat (rpath2, extension);
+    _tcscpy (rpath1, L"Software\\Classes\\");
+    _tcscpy (rpath2, rpath1);
+    _tcscat (rpath2, extension);
     if (RegCreateKeyEx (rkey, rpath2, 0, NULL, REG_OPTION_NON_VOLATILE,
        KEY_WRITE | KEY_READ, NULL, &key1, &disposition) == ERROR_SUCCESS) {
-       RegSetValueEx (key1, "", 0, REG_SZ, (CONST BYTE *)(def ? progid : progid2), strlen (def ? progid : progid2) + 1);
+       RegSetValueEx (key1, L"", 0, REG_SZ, (CONST BYTE *)(def ? progid : progid2), (_tcslen (def ? progid : progid2) + 1) * sizeof (TCHAR));
        if (perceivedtype)
-           RegSetValueEx (key1, "PerceivedType", 0, REG_SZ, (CONST BYTE *)perceivedtype, strlen (perceivedtype) + 1);
+           RegSetValueEx (key1, L"PerceivedType", 0, REG_SZ, (CONST BYTE *)perceivedtype, (_tcslen (perceivedtype) + 1) * sizeof (TCHAR));
        RegCloseKey (key1);
     }
-    strcpy (rpath2, rpath1);
-    strcat (rpath2, progid);
+    _tcscpy (rpath2, rpath1);
+    _tcscat (rpath2, progid);
     if (!def)
-       strcat (rpath2, ext2 ? ext2 : extension);
+       _tcscat (rpath2, ext2 ? ext2 : extension);
     if (description) {
        if (RegCreateKeyEx (rkey, rpath2, 0, NULL, REG_OPTION_NON_VOLATILE,
            KEY_WRITE | KEY_READ, NULL, &key1, &disposition) == ERROR_SUCCESS) {
-           RegSetValueEx (key1, "", 0, REG_SZ, (CONST BYTE *)description, strlen (description) + 1);
+           RegSetValueEx (key1, L"", 0, REG_SZ, (CONST BYTE *)description, (_tcslen (description) + 1) * sizeof (TCHAR));
            RegCloseKey (key1);
        }
     }
     if (command) {
-       strcat (rpath2, "\\shell\\");
+       _tcscat (rpath2, L"\\shell\\");
        if (shellcommand)
-           strcat (rpath2, shellcommand);
+           _tcscat (rpath2, shellcommand);
        else
-           strcat (rpath2, "open");
-       strcat (rpath2, "\\command");
+           _tcscat (rpath2, L"open");
+       _tcscat (rpath2, L"\\command");
        if (RegCreateKeyEx (rkey, rpath2, 0, NULL, REG_OPTION_NON_VOLATILE,
            KEY_WRITE | KEY_READ, NULL, &key1, &disposition) == ERROR_SUCCESS) {
-           char path[MAX_DPATH];
-           sprintf (path, "\"%sWinUAE.exe\" %s", start_path_exe, command);
-           RegSetValueEx (key1, "", 0, REG_SZ, (CONST BYTE *)path, strlen (path) + 1);
+           TCHAR path[MAX_DPATH];
+           _stprintf (path, L"\"%sWinUAE.exe\" %s", start_path_exe, command);
+           RegSetValueEx (key1, L"", 0, REG_SZ, (CONST BYTE *)path, (_tcslen (path) + 1) * sizeof (TCHAR));
            RegCloseKey (key1);
        }
     }
-    fkey = regcreatetree (NULL, "FileAssociations");
-    regsetstr (fkey, extension, "");
+    fkey = regcreatetree (NULL, L"FileAssociations");
+    regsetstr (fkey, extension, L"");
     regclosetree (fkey);
     return 1;
 }
-static int shell_associate (const char *extension, const char *command, const char *perceivedtype, const char *description, const char *ext2)
+static int shell_associate (const TCHAR *extension, const TCHAR *command, const TCHAR *perceivedtype, const TCHAR *description, const TCHAR *ext2)
 {
     int v = shell_associate_2 (extension, NULL, command, perceivedtype, description, ext2);
-    if (!strcmp (extension, ".uae"))
-       shell_associate_2 (extension, "edit", "-f \"%1\" -s use_gui=yes", "text", description, NULL);
+    if (!_tcscmp (extension, L".uae"))
+       shell_associate_2 (extension, L"edit", L"-f \"%1\" -s use_gui=yes", L"text", description, NULL);
     return v;
 }
 
-static int shell_associate_is (const char *extension)
+static int shell_associate_is (const TCHAR *extension)
 {
-    char rpath1[MAX_DPATH], rpath2[MAX_DPATH];
-    char progid2[MAX_DPATH], tmp[MAX_DPATH];
+    TCHAR rpath1[MAX_DPATH], rpath2[MAX_DPATH];
+    TCHAR progid2[MAX_DPATH], tmp[MAX_DPATH];
     DWORD size;
     HKEY rkey, key1;
-    const char *progid = "WinUAE";
-    int def = !strcmp (extension, ".uae");
+    const TCHAR *progid = L"WinUAE";
+    int def = !_tcscmp (extension, L".uae");
 
-    strcpy (progid2, progid);
-    strcat (progid2, extension);
+    _tcscpy (progid2, progid);
+    _tcscat (progid2, extension);
     if (os_winnt_admin > 1)
         rkey = HKEY_LOCAL_MACHINE;
     else
         rkey = HKEY_CURRENT_USER;
 
-    strcpy (rpath1, "Software\\Classes\\");
-    strcpy (rpath2, rpath1);
-    strcat (rpath2, extension);
+    _tcscpy (rpath1, L"Software\\Classes\\");
+    _tcscpy (rpath2, rpath1);
+    _tcscat (rpath2, extension);
     size = sizeof tmp;
     if (RegOpenKeyEx (rkey, rpath2, 0, KEY_READ, &key1) == ERROR_SUCCESS) {
-       if (RegQueryValueEx (key1, NULL, NULL, NULL, tmp, &size) == ERROR_SUCCESS) {
-           if (strcmp (tmp, def ? progid : progid2)) {
+       if (RegQueryValueEx (key1, NULL, NULL, NULL, (LPBYTE)tmp, &size) == ERROR_SUCCESS) {
+           if (_tcscmp (tmp, def ? progid : progid2)) {
                RegCloseKey (key1);
                return 0;
            }
        }
        RegCloseKey (key1);
     }
-    strcpy (rpath2, rpath1);
-    strcat (rpath2, progid);
+    _tcscpy (rpath2, rpath1);
+    _tcscat (rpath2, progid);
     if (!def)
-       strcat (rpath2, extension);
+       _tcscat (rpath2, extension);
     if (RegOpenKeyEx (rkey, rpath2, 0, KEY_READ, &key1) == ERROR_SUCCESS) {
        RegCloseKey (key1);
        return 1;
@@ -2737,13 +2755,13 @@ static int shell_associate_is (const char *extension)
 }
 
 struct assext exts[] = {
-    { ".uae", "-f \"%1\"", "WinUAE configuration file", },
-    { ".adf", "-0 \"%1\" -s use_gui=no", "WinUAE floppy disk image" },
-    { ".adz", "-0 \"%1\" -s use_gui=no", "WinUAE floppy disk image" },
-    { ".dms", "-0 \"%1\" -s use_gui=no", "WinUAE floppy disk image" },
-    { ".fdi", "-0 \"%1\" -s use_gui=no", "WinUAE floppy disk image" },
-    { ".ipf", "-0 \"%1\" -s use_gui=no", "WinUAE floppy disk image" },
-    { ".uss", "-s statefile=\"%1\" -s use_gui=no", "WinUAE statefile" },
+    { L".uae", L"-f \"%1\"", L"WinUAE configuration file", },
+    { L".adf", L"-0 \"%1\" -s use_gui=no", L"WinUAE floppy disk image" },
+    { L".adz", L"-0 \"%1\" -s use_gui=no", L"WinUAE floppy disk image" },
+    { L".dms", L"-0 \"%1\" -s use_gui=no", L"WinUAE floppy disk image" },
+    { L".fdi", L"-0 \"%1\" -s use_gui=no", L"WinUAE floppy disk image" },
+    { L".ipf", L"-0 \"%1\" -s use_gui=no", L"WinUAE floppy disk image" },
+    { L".uss", L"-s statefile=\"%1\" -s use_gui=no", L"WinUAE statefile" },
     { NULL }
 };
 
@@ -2757,41 +2775,41 @@ static void associate_init_extensions (void)
            exts[i].enabled = 1;
     }
     // associate .uae by default when running for the first time
-    if (!regexiststree (NULL, "FileAssociations")) {
+    if (!regexiststree (NULL, L"FileAssociations")) {
        UAEREG *fkey;
        if (exts[0].enabled == 0) {
            shell_associate (exts[0].ext, exts[0].cmd, NULL, exts[0].desc, NULL);
            exts[0].enabled = shell_associate_is (exts[0].ext);
        }
-        fkey = regcreatetree (NULL, "FileAssociations");
-       regsetstr (fkey, exts[0].ext, "");
+        fkey = regcreatetree (NULL, L"FileAssociations");
+       regsetstr (fkey, exts[0].ext, L"");
        regclosetree (fkey);
     }
 #if 0
     UAEREG *fkey;
-    fkey = regcreatetree (NULL, "FileAssociations");
+    fkey = regcreatetree (NULL, L"FileAssociations");
     if (fkey) {
        int ok = 1;
-       char tmp[MAX_DPATH];
-       strcpy (tmp, "Following file associations:\n");
+       TCHAR tmp[MAX_DPATH];
+       _tcscpy (tmp, L"Following file associations:\n");
        for (i = 0; exts[i].ext; i++) {
-           char tmp2[10];
+           TCHAR tmp2[10];
            int size = sizeof tmp;
            int is1 = exts[i].enabled;
            int is2 = regquerystr (fkey, exts[i].ext, tmp2, &size);
            if (is1 == 0 && is2 != 0) {
-               strcat (tmp, exts[i].ext);
-               strcat (tmp, "\n");
+               _tcscat (tmp, exts[i].ext);
+               _tcscat (tmp, L"\n");
                ok = 0;
            }
        }
        if (!ok) {
-           char szTitle[MAX_DPATH];
+           TCHAR szTitle[MAX_DPATH];
            WIN32GUI_LoadUIString (IDS_ERRORTITLE, szTitle, MAX_DPATH);
-           strcat (szTitle, BetaStr);
+           _tcscat (szTitle, BetaStr);
            if (MessageBox (NULL, tmp, szTitle, MB_YESNO | MB_TASKMODAL) == IDOK) {
                for (i = 0; exts[i].ext; i++) {
-                   char tmp2[10];
+                   TCHAR tmp2[10];
                    int size = sizeof tmp;
                    int is1 = exts[i].enabled;
                    int is2 = regquerystr (fkey, exts[i].ext, tmp2, &size);
@@ -2841,19 +2859,19 @@ static void WIN32_HandleRegistryStuff (void)
     DWORD dwType = REG_DWORD;
     DWORD dwDisplayInfoSize = sizeof (colortype);
     DWORD size;
-    char path[MAX_DPATH] = "";
-    char version[100];
-
-    initpath ("FloppyPath", start_path_data);
-    initpath ("KickstartPath", start_path_data);
-    initpath ("hdfPath", start_path_data);
-    initpath ("ConfigurationPath", start_path_data);
-    initpath ("ScreenshotPath", start_path_data);
-    initpath ("StatefilePath", start_path_data);
-    initpath ("SaveimagePath", start_path_data);
-    initpath ("VideoPath", start_path_data);
-    initpath ("InputPath", start_path_data);
-    if (!regexists (NULL, "MainPosX") || !regexists (NULL, "GUIPosX")) {
+    TCHAR path[MAX_DPATH] = L"";
+    TCHAR version[100];
+
+    initpath (L"FloppyPath", start_path_data);
+    initpath (L"KickstartPath", start_path_data);
+    initpath (L"hdfPath", start_path_data);
+    initpath (L"ConfigurationPath", start_path_data);
+    initpath (L"ScreenshotPath", start_path_data);
+    initpath (L"StatefilePath", start_path_data);
+    initpath (L"SaveimagePath", start_path_data);
+    initpath (L"VideoPath", start_path_data);
+    initpath (L"InputPath", start_path_data);
+    if (!regexists (NULL, L"MainPosX") || !regexists (NULL, L"GUIPosX")) {
        int x = GetSystemMetrics (SM_CXSCREEN);
        int y = GetSystemMetrics (SM_CYSCREEN);
        x = (x - 800) / 2;
@@ -2863,49 +2881,49 @@ static void WIN32_HandleRegistryStuff (void)
        if (y < 10)
            y = 10;
         /* Create and initialize all our sub-keys to the default values */
-        regsetint (NULL, "MainPosX", x);
-        regsetint (NULL, "MainPosY", y);
-        regsetint (NULL, "GUIPosX", x);
-        regsetint (NULL, "GUIPosY", y);
+        regsetint (NULL, L"MainPosX", x);
+        regsetint (NULL, L"MainPosY", y);
+        regsetint (NULL, L"GUIPosX", x);
+        regsetint (NULL, L"GUIPosY", y);
     }
-    size = sizeof (version);
-    if (regquerystr (NULL, "Version", version, &size)) {
+    size = sizeof (version) / sizeof (TCHAR);
+    if (regquerystr (NULL, L"Version", version, &size)) {
         if (checkversion (version))
-       regsetstr (NULL, "Version", VersionStr);
+       regsetstr (NULL, L"Version", VersionStr);
     } else {
-        regsetstr (NULL, "Version", VersionStr);
+        regsetstr (NULL, L"Version", VersionStr);
     }
-    size = sizeof (version);
-    if (regquerystr (NULL, "ROMCheckVersion", version, &size)) {
+    size = sizeof (version) / sizeof (TCHAR);
+    if (regquerystr (NULL, L"ROMCheckVersion", version, &size)) {
         if (checkversion (version)) {
-           if (regsetstr (NULL, "ROMCheckVersion", VersionStr))
+           if (regsetstr (NULL, L"ROMCheckVersion", VersionStr))
                forceroms = 1;
        }
     } else {
-        if (regsetstr (NULL, "ROMCheckVersion", VersionStr))
-       forceroms = 1;
+        if (regsetstr (NULL, L"ROMCheckVersion", VersionStr))
+           forceroms = 1;
     }
 
-    regqueryint (NULL, "DirectDraw_Secondary", &ddforceram);
-    if (regexists (NULL, "ConfigurationCache"))
-       regqueryint (NULL, "ConfigurationCache", &configurationcache);
+    regqueryint (NULL, L"DirectDraw_Secondary", &ddforceram);
+    if (regexists (NULL, L"ConfigurationCache"))
+       regqueryint (NULL, L"ConfigurationCache", &configurationcache);
     else
-       regsetint (NULL, "ConfigurationCache", configurationcache);
-    regqueryint (NULL, "QuickStartMode", &quickstart);
+       regsetint (NULL, L"ConfigurationCache", configurationcache);
+    regqueryint (NULL, L"QuickStartMode", &quickstart);
     reopen_console ();
-    fetch_path ("ConfigurationPath", path, sizeof (path));
-    path[strlen (path) - 1] = 0;
+    fetch_path (L"ConfigurationPath", path, sizeof (path) / sizeof (TCHAR));
+    path[_tcslen (path) - 1] = 0;
     createdir (path);
-    strcat (path, "\\Host");
+    _tcscat (path, L"\\Host");
     createdir (path);
-    fetch_path ("ConfigurationPath", path, sizeof (path));
-    strcat (path, "Hardware");
+    fetch_path (L"ConfigurationPath", path, sizeof (path) / sizeof (TCHAR));
+    _tcscat (path, L"Hardware");
     createdir (path);
-    fetch_path ("StatefilePath", path, sizeof (path));
+    fetch_path (L"StatefilePath", path, sizeof (path) / sizeof (TCHAR));
     createdir (path);
-    strcat (path, "default.uss");
-    strcpy (savestate_fname, path);
-    fetch_path ("InputPath", path, sizeof (path));
+    _tcscat (path, L"default.uss");
+    _tcscpy (savestate_fname, path);
+    fetch_path (L"InputPath", path, sizeof (path) / sizeof (TCHAR));
     createdir (path);
     regclosetree (read_disk_history ());
     associate_init_extensions ();
@@ -2914,8 +2932,8 @@ static void WIN32_HandleRegistryStuff (void)
 }
 
 #if WINUAEPUBLICBETA > 0
-static char *BETAMESSAGE = {
-    "This is unstable beta software. Click cancel if you are not comfortable using software that is incomplete and can have serious programming errors."
+static TCHAR *BETAMESSAGE = {
+    L"This is unstable beta software. Click cancel if you are not comfortable using software that is incomplete and can have serious programming errors."
 };
 #endif
 
@@ -2935,11 +2953,11 @@ static int betamessage (void)
     for (;;) {
        FILETIME ft, sft;
        SYSTEMTIME st;
-       char tmp1[MAX_DPATH];
+       TCHAR tmp1[MAX_DPATH];
 
        if (!hWinUAEKey)
            break;
-       if (GetModuleFileName (NULL, tmp1, sizeof tmp1) == 0)
+       if (GetModuleFileName (NULL, tmp1, sizeof tmp1 / sizeof (TCHAR)) == 0)
            break;
        h = CreateFile (tmp1, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
        if (h == INVALID_HANDLE_VALUE)
@@ -2950,7 +2968,7 @@ static int betamessage (void)
        ft64.HighPart = ft.dwHighDateTime;
        dwType = REG_QWORD;
        size = sizeof regft64;
-       if (RegQueryValueEx (hWinUAEKey, "BetaToken", 0, &dwType, (LPBYTE)&regft64, &size) != ERROR_SUCCESS)
+       if (RegQueryValueEx (hWinUAEKey, L"BetaToken", 0, &dwType, (LPBYTE)&regft64, &size) != ERROR_SUCCESS)
            break;
        GetSystemTime(&st);
        SystemTimeToFileTime(&st, &sft);
@@ -2967,13 +2985,13 @@ static int betamessage (void)
        CloseHandle (h);
     if (showmsg) {
        int r;
-       char title[MAX_DPATH];
+       TCHAR title[MAX_DPATH];
 
        dwType = REG_DWORD;
        size = sizeof data;
-       if (hWinUAEKey && RegQueryValueEx (hWinUAEKey, "Beta_Just_Shut_Up", 0, &dwType, (LPBYTE)&data, &size) == ERROR_SUCCESS) {
+       if (hWinUAEKey && RegQueryValueEx (hWinUAEKey, L"Beta_Just_Shut_Up", 0, &dwType, (LPBYTE)&data, &size) == ERROR_SUCCESS) {
            if (data == 68000) {
-               write_log ("I was told to shut up :(\n");
+               write_log (L"I was told to shut up :(\n");
                return 1;
            }
        }
@@ -2982,16 +3000,16 @@ static int betamessage (void)
        t = _gmtime64 (&ltime);
        /* "expire" in 1 month */
        if (MAKEBD(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday) > WINUAEDATE + 100)
-           pre_gui_message ("This beta build of WinUAE is obsolete.\nPlease download newer version.");
+           pre_gui_message (L"This beta build of WinUAE is obsolete.\nPlease download newer version.");
 
-       strcpy (title, "WinUAE Public Beta Disclaimer");
-       strcat (title, BetaStr);
+       _tcscpy (title, L"WinUAE Public Beta Disclaimer");
+       _tcscat (title, BetaStr);
        r = MessageBox (NULL, BETAMESSAGE, title, MB_OKCANCEL | MB_TASKMODAL | MB_SETFOREGROUND | MB_ICONWARNING | MB_DEFBUTTON2);
        if (r == IDABORT || r == IDCANCEL)
            return 0;
        if (ft64.QuadPart > 0) {
            regft64 = ft64.QuadPart;
-           RegSetValueEx (hWinUAEKey, "BetaToken", 0, REG_QWORD, (LPBYTE)&regft64, sizeof regft64);
+           RegSetValueEx (hWinUAEKey, L"BetaToken", 0, REG_QWORD, (LPBYTE)&regft64, sizeof regft64);
        }
     }
 #endif
@@ -3002,8 +3020,8 @@ static int dxdetect (void)
 {
 #if !defined(WIN64)
     /* believe or not but this is MS supported way of detecting DX8+ */
-    HMODULE h = LoadLibrary ("D3D8.DLL");
-    char szWrongDXVersion[MAX_DPATH];
+    HMODULE h = LoadLibrary (L"D3D8.DLL");
+    TCHAR szWrongDXVersion[MAX_DPATH];
     if (h) {
        FreeLibrary (h);
        return 1;
@@ -3030,7 +3048,7 @@ static int isadminpriv (void)
 
     // Open a handle to the access token for the calling process.
     if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &hToken)) {
-       write_log ("OpenProcessToken Error %u\n", GetLastError ());
+       write_log (L"OpenProcessToken Error %u\n", GetLastError ());
        return FALSE;
     }
 
@@ -3038,7 +3056,7 @@ static int isadminpriv (void)
     if(!GetTokenInformation (hToken, TokenGroups, NULL, dwSize, &dwSize)) {
        dwResult = GetLastError ();
        if(dwResult != ERROR_INSUFFICIENT_BUFFER) {
-           write_log ("GetTokenInformation Error %u\n", dwResult);
+           write_log (L"GetTokenInformation Error %u\n", dwResult);
            return FALSE;
        }
     }
@@ -3048,7 +3066,7 @@ static int isadminpriv (void)
 
     // Call GetTokenInformation again to get the group information.
     if (!GetTokenInformation (hToken, TokenGroups, pGroupInfo, dwSize, &dwSize)) {
-       write_log ("GetTokenInformation Error %u\n", GetLastError ());
+       write_log (L"GetTokenInformation Error %u\n", GetLastError ());
        return FALSE;
     }
 
@@ -3058,7 +3076,7 @@ static int isadminpriv (void)
                 DOMAIN_ALIAS_RID_ADMINS,
                 0, 0, 0, 0, 0, 0,
                 &pSID)) {
-       write_log ("AllocateAndInitializeSid Error %u\n", GetLastError ());
+       write_log (L"AllocateAndInitializeSid Error %u\n", GetLastError ());
        return FALSE;
    }
 
@@ -3084,9 +3102,9 @@ static int osdetect (void)
     PISUSERANADMIN pIsUserAnAdmin;
 
     pGetNativeSystemInfo = (PGETNATIVESYSTEMINFO)GetProcAddress (
-       GetModuleHandle ("kernel32.dll"), "GetNativeSystemInfo");
+       GetModuleHandle (L"kernel32.dll"), "GetNativeSystemInfo");
     pIsUserAnAdmin = (PISUSERANADMIN)GetProcAddress (
-       GetModuleHandle ("shell32.dll"), "IsUserAnAdmin");
+       GetModuleHandle (L"shell32.dll"), "IsUserAnAdmin");
 
     GetSystemInfo (&SystemInfo);
     if (pGetNativeSystemInfo)
@@ -3097,7 +3115,7 @@ static int osdetect (void)
            (osVersion.dwMajorVersion <= 4))
        {
            /* WinUAE not supported on this version of Windows... */
-           char szWrongOSVersion[MAX_DPATH];
+           TCHAR szWrongOSVersion[MAX_DPATH];
            WIN32GUI_LoadUIString (IDS_WRONGOSVERSION, szWrongOSVersion, MAX_DPATH);
            pre_gui_message (szWrongOSVersion);
            return FALSE;
@@ -3130,14 +3148,14 @@ static int osdetect (void)
 
 void create_afnewdir (int remove)
 {
-    char tmp[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH];
 
     if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, tmp))) {
        fixtrailing (tmp);
-       strcpy (tmp2, tmp);
-       strcat (tmp2, "Amiga Files");
-       strcpy (tmp, tmp2);
-       strcat (tmp, "\\WinUAE");
+       _tcscpy (tmp2, tmp);
+       _tcscat (tmp2, L"Amiga Files");
+       _tcscpy (tmp, tmp2);
+       _tcscat (tmp, L"\\WinUAE");
        if (remove) {
            if (GetFileAttributes (tmp) != INVALID_FILE_ATTRIBUTES) {
                RemoveDirectory (tmp);
@@ -3152,78 +3170,79 @@ void create_afnewdir (int remove)
 
 static void getstartpaths (void)
 {
-    char *posn, *p;
-    char tmp[MAX_DPATH], tmp2[MAX_DPATH], prevpath[MAX_DPATH];
+    TCHAR *posn, *p;
+    TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH], prevpath[MAX_DPATH];
     DWORD v;
     UAEREG *key;
-    char xstart_path_uae[MAX_DPATH], xstart_path_old[MAX_DPATH];
-    char xstart_path_new1[MAX_DPATH], xstart_path_new2[MAX_DPATH];
+    TCHAR xstart_path_uae[MAX_DPATH], xstart_path_old[MAX_DPATH];
+    TCHAR xstart_path_new1[MAX_DPATH], xstart_path_new2[MAX_DPATH];
 
     path_type = -1;
+    prevpath[0] = 0;
     xstart_path_uae[0] = xstart_path_old[0] = xstart_path_new1[0] = xstart_path_new2[0] = 0;
     key = regcreatetree (NULL, NULL);
     if (key)  {
-       DWORD size = sizeof (prevpath);
-       if (!regquerystr (key, "PathMode", prevpath, &size))
+       DWORD size = sizeof (prevpath) / sizeof (TCHAR);
+       if (!regquerystr (key, L"PathMode", prevpath, &size))
            prevpath[0] = 0;
        regclosetree (key);
     }
-    if (!strcmp (prevpath, "WinUAE"))
+    if (!_tcscmp (prevpath, L"WinUAE"))
        path_type = PATH_TYPE_WINUAE;
-    if (!strcmp (prevpath, "WinUAE_2"))
+    if (!_tcscmp (prevpath, L"WinUAE_2"))
        path_type = PATH_TYPE_NEWWINUAE;
-    if (!strcmp (prevpath, "AF"))
+    if (!_tcscmp (prevpath, L"AF"))
        path_type = PATH_TYPE_OLDAF;
-    if (!strcmp (prevpath, "AF2005"))
+    if (!_tcscmp (prevpath, L"AF2005"))
        path_type = PATH_TYPE_NEWAF;
-    if (!strcmp (prevpath, "AMIGAFOREVERDATA"))
+    if (!_tcscmp (prevpath, L"AMIGAFOREVERDATA"))
        path_type = PATH_TYPE_AMIGAFOREVERDATA;
 
-    strcpy (start_path_exe, _pgmptr);
-    if((posn = strrchr (start_path_exe, '\\')))
+    _tcscpy (start_path_exe, pgmptr);
+    if((posn = _tcsrchr (start_path_exe, '\\')))
        posn[1] = 0;
 
-    strcpy (tmp, start_path_exe);
-    strcat (tmp, "roms");
+    _tcscpy (tmp, start_path_exe);
+    _tcscat (tmp, L"roms");
     if (isfilesindir (tmp)) {
-       strcpy (xstart_path_uae, start_path_exe);
+       _tcscpy (xstart_path_uae, start_path_exe);
     }
-    strcpy (tmp, start_path_exe);
-    strcat (tmp, "configurations");
+    _tcscpy (tmp, start_path_exe);
+    _tcscat (tmp, L"configurations");
     if (isfilesindir (tmp)) {
-       strcpy (xstart_path_uae, start_path_exe);
+       _tcscpy (xstart_path_uae, start_path_exe);
     }
 
-    strcpy (tmp, start_path_exe);
-    strcat (tmp, "..\\system\\rom\\rom.key");
+    _tcscpy (tmp, start_path_exe);
+    _tcscat (tmp, L"..\\system\\rom\\rom.key");
     v = GetFileAttributes (tmp);
     if (v != INVALID_FILE_ATTRIBUTES) {
        af_path_old = 1;
-       strcpy (xstart_path_old, start_path_exe);
-       strcat (xstart_path_old, "..\\system\\");
-       strcpy (start_path_af, xstart_path_old);
+       _tcscpy (xstart_path_old, start_path_exe);
+       _tcscat (xstart_path_old, L"..\\system\\");
+       _tcscpy (start_path_af, xstart_path_old);
     } else {
-       strcpy (tmp, start_path_exe);
-       strcat (tmp, "..\\shared\\rom\\rom.key");
+       _tcscpy (tmp, start_path_exe);
+       _tcscat (tmp, L"..\\shared\\rom\\rom.key");
        v = GetFileAttributes (tmp);
        if (v != INVALID_FILE_ATTRIBUTES) {
            af_path_old = 1;
-           strcpy (xstart_path_old, start_path_exe);
-           strcat (xstart_path_old, "..\\shared\\");
-           strcpy (start_path_af, xstart_path_old);
+           _tcscpy (xstart_path_old, start_path_exe);
+           _tcscat (xstart_path_old, L"..\\shared\\");
+           _tcscpy (start_path_af, xstart_path_old);
        }
     }
 
-    p = getenv ("AMIGAFOREVERDATA");
+    p = _wgetenv (L"AMIGAFOREVERDATA");
     if (p) {
-       strcpy (tmp, p);
+       _tcscpy (tmp, p);
        fixtrailing (tmp);
-       strcpy (start_path_new2, p);
+       _tcscpy (start_path_new2, p);
        fixtrailing (start_path_af);
        v = GetFileAttributes (tmp);
        if (v != INVALID_FILE_ATTRIBUTES && (v & FILE_ATTRIBUTE_DIRECTORY)) {
-           strcpy (xstart_path_new2, start_path_af);
-           strcat (xstart_path_new2, "WinUAE\\");
+           _tcscpy (xstart_path_new2, start_path_af);
+           _tcscpy (xstart_path_new2, L"WinUAE\\");
            af_path_2005 |= 2;
        }
     }
@@ -3231,23 +3250,23 @@ static void getstartpaths (void)
     {
        if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_DOCUMENTS, NULL, 0, tmp))) {
            fixtrailing (tmp);
-           strcpy (tmp2, tmp);
-           strcat (tmp2, "Amiga Files\\");
-           strcpy (tmp, tmp2);
-           strcat (tmp, "WinUAE");
+           _tcscpy (tmp2, tmp);
+           _tcscat (tmp2, L"Amiga Files\\");
+           _tcscpy (tmp, tmp2);
+           _tcscat (tmp, L"WinUAE");
            v = GetFileAttributes (tmp);
            if (v == INVALID_FILE_ATTRIBUTES || (v & FILE_ATTRIBUTE_DIRECTORY)) {
-               char *p;
-               strcpy (xstart_path_new1, tmp2);
-               strcat (xstart_path_new1, "WinUAE\\");
-               strcpy (xstart_path_uae, start_path_exe);
-               strcpy (start_path_new1, xstart_path_new1);
-               p = tmp2 + strlen (tmp2);
-               strcpy (p, "System");
+               TCHAR *p;
+               _tcscpy (xstart_path_new1, tmp2);
+               _tcscat (xstart_path_new1, L"WinUAE\\");
+               _tcscpy (xstart_path_uae, start_path_exe);
+               _tcscpy (start_path_new1, xstart_path_new1);
+               p = tmp2 + _tcslen (tmp2);
+               _tcscpy (p, L"System");
                if (isfilesindir (tmp2)) {
                    af_path_2005 |= 1;
                } else {
-                   strcpy (p, "Shared");
+                   _tcscpy (p, L"Shared");
                    if (isfilesindir (tmp2)) {
                        af_path_2005 |= 1;
                    }
@@ -3259,55 +3278,55 @@ static void getstartpaths (void)
     if (start_data == 0) {
        start_data = 1;
        if (path_type == 0 && xstart_path_uae[0]) {
-           strcpy (start_path_data, xstart_path_uae);
+           _tcscpy (start_path_data, xstart_path_uae);
        } else if (path_type == PATH_TYPE_OLDAF && af_path_old && xstart_path_old[0]) {
-           strcpy (start_path_data, xstart_path_old);
+           _tcscpy (start_path_data, xstart_path_old);
        } else if (path_type == PATH_TYPE_NEWWINUAE && xstart_path_new1[0]) {
-           strcpy (start_path_data, xstart_path_new1);
+           _tcscpy (start_path_data, xstart_path_new1);
            create_afnewdir(0);
        } else if (path_type == PATH_TYPE_NEWAF && (af_path_2005 & 1) && xstart_path_new1[0]) {
-           strcpy (start_path_data, xstart_path_new1);
+           _tcscpy (start_path_data, xstart_path_new1);
            create_afnewdir(0);
        } else if (path_type == PATH_TYPE_AMIGAFOREVERDATA && (af_path_2005 & 2) && xstart_path_new2[0]) {
-           strcpy (start_path_data, xstart_path_new2);
+           _tcscpy (start_path_data, xstart_path_new2);
        } else if (path_type < 0) {
            path_type = 0;
-           strcpy (start_path_data, xstart_path_uae);
+           _tcscpy (start_path_data, xstart_path_uae);
            if (af_path_old) {
                path_type = PATH_TYPE_OLDAF;
-               strcpy (start_path_data, xstart_path_old);
+               _tcscpy (start_path_data, xstart_path_old);
            }
            if (af_path_2005 & 1) {
                path_type = PATH_TYPE_NEWAF;
                create_afnewdir (1);
-               strcpy (start_path_data, xstart_path_new1);
+               _tcscpy (start_path_data, xstart_path_new1);
            }
            if (af_path_2005 & 2) {
-               strcpy (tmp, xstart_path_new2);
-               strcat (tmp, "system\\rom");
+               _tcscpy (tmp, xstart_path_new2);
+               _tcscat (tmp, L"system\\rom");
                if (isfilesindir (tmp)) {
                    path_type = PATH_TYPE_AMIGAFOREVERDATA;
                } else {
-                   strcpy (tmp, xstart_path_new2);
-                   strcat (tmp, "shared\\rom");
+                   _tcscpy (tmp, xstart_path_new2);
+                   _tcscat (tmp, L"shared\\rom");
                    if (isfilesindir (tmp)) {
                        path_type = PATH_TYPE_AMIGAFOREVERDATA;
                    } else {
                        path_type = PATH_TYPE_NEWWINUAE;
                    }
                }
-               strcpy (start_path_data, xstart_path_new2);
+               _tcscpy (start_path_data, xstart_path_new2);
            }
        }
     }
 
     v = GetFileAttributes (start_path_data);
     if (v == INVALID_FILE_ATTRIBUTES || !(v & FILE_ATTRIBUTE_DIRECTORY) || start_data == 0 || start_data == -2) {
-       strcpy (start_path_data, start_path_exe);
+       _tcscpy (start_path_data, start_path_exe);
     }
     fixtrailing (start_path_data);
-    GetFullPathName (start_path_data, sizeof tmp, tmp, NULL);
-    strcpy (start_path_data, tmp);
+    GetFullPathName (start_path_data, sizeof tmp / sizeof (TCHAR), tmp, NULL);
+    _tcscpy (start_path_data, tmp);
     SetCurrentDirectory (start_path_data);
 }
 
@@ -3318,107 +3337,107 @@ extern int force_direct_catweasel, sound_mode_skip, maxmem;
 extern DWORD_PTR cpu_affinity, cpu_paffinity;
 static DWORD_PTR original_affinity = -1;
 
-static int getval(const char *s)
+static int getval (const TCHAR *s)
 {
     int base = 10;
     int v;
-    char *endptr;
+    TCHAR *endptr;
 
-    if (s[0] == '0' && toupper(s[1]) == 'X')
+    if (s[0] == '0' && _totupper(s[1]) == 'X')
        s += 2, base = 16;
-    v = strtol (s, &endptr, base);
+    v = _tcstol (s, &endptr, base);
     if (*endptr != '\0' || *s == '\0')
        return 0;
     return v;
 }
 
-static void makeverstr(char *s)
+static void makeverstr(TCHAR *s)
 {
-    if (strlen (WINUAEBETA) > 0) {
-       sprintf (BetaStr, " (%sBeta %s, %d.%02d.%02d)", WINUAEPUBLICBETA > 0 ? "Public " : "", WINUAEBETA,
+    if (_tcslen (WINUAEBETA) > 0) {
+       _stprintf (BetaStr, L" (%sBeta %s, %d.%02d.%02d)", WINUAEPUBLICBETA > 0 ? L"Public " : L"", WINUAEBETA,
            GETBDY(WINUAEDATE), GETBDM(WINUAEDATE), GETBDD(WINUAEDATE));
-       sprintf (s, "WinUAE %d.%d.%d%s%s",
+       _stprintf (s, L"WinUAE %d.%d.%d%s%s",
            UAEMAJOR, UAEMINOR, UAESUBREV, WINUAEREV, BetaStr);
     } else {
-       sprintf(s, "WinUAE %d.%d.%d%s (%d.%02d.%02d)",
+       _stprintf(s, L"WinUAE %d.%d.%d%s (%d.%02d.%02d)",
            UAEMAJOR, UAEMINOR, UAESUBREV, WINUAEREV, GETBDY(WINUAEDATE), GETBDM(WINUAEDATE), GETBDD(WINUAEDATE));
     }
-    if (strlen (WINUAEEXTRA) > 0) {
-       strcat (s, " ");
-       strcat (s, WINUAEEXTRA);
+    if (_tcslen (WINUAEEXTRA) > 0) {
+       _tcscat (s, L" ");
+       _tcscat (s, WINUAEEXTRA);
     }
 }
 
-static int parseargs (const char *arg, const char *np)
+static int parseargs (const TCHAR *arg, const TCHAR *np)
 {
 
-    if (!strcmp (arg, "-log")) {
+    if (!_tcscmp (arg, L"-log")) {
         console_logging = 1;
         return 1;
     }
 #ifdef FILESYS
-    if (!strcmp (arg, "-rdbdump")) {
+    if (!_tcscmp (arg, L"-rdbdump")) {
         do_rdbdump = 1;
        return 1;
     }
-    if (!strcmp (arg, "-disableharddrivesafetycheck")) {
+    if (!_tcscmp (arg, L"-disableharddrivesafetycheck")) {
         harddrive_dangerous = 0x1234dead;
        return 1;
     }
-    if (!strcmp (arg, "-noaspifiltering")) {
+    if (!_tcscmp (arg, L"-noaspifiltering")) {
         aspi_allow_all = 1;
        return 1;
     }
 #endif
-    if (!strcmp (arg, "-norawinput")) {
+    if (!_tcscmp (arg, L"-norawinput")) {
         no_rawinput = 1;
        return 1;
     }
-    if (!strcmp (arg, "-rawkeyboard")) {
+    if (!_tcscmp (arg, L"-rawkeyboard")) {
         rawkeyboard = 1;
        return 1;
     }
-    if (!strcmp (arg, "-scsilog")) {
+    if (!_tcscmp (arg, L"-scsilog")) {
         log_scsi = 1;
        return 1;
     }
-    if (!strcmp (arg, "-netlog")) {
+    if (!_tcscmp (arg, L"-netlog")) {
         log_net = 1;
        return 1;
     }
-    if (!strcmp (arg, "-seriallog")) {
+    if (!_tcscmp (arg, L"-seriallog")) {
         log_uaeserial = 1;
        return 1;
     }
-    if (!strcmp (arg, "-clipboarddebug")) {
+    if (!_tcscmp (arg, L"-clipboarddebug")) {
         clipboard_debug = 1;
        return 1;
     }
-    if (!strcmp (arg, "-rplog")) {
+    if (!_tcscmp (arg, L"-rplog")) {
         log_rp = 1;
        return 1;
     }
-    if (!strcmp (arg, "-nomultidisplay")) {
+    if (!_tcscmp (arg, L"-nomultidisplay")) {
         multi_display = 0;
        return 1;
     }
-    if (!strcmp (arg, "-legacypaths")) {
+    if (!_tcscmp (arg, L"-legacypaths")) {
         start_data = -2;
        return 1;
     }
-    if (!strcmp (arg, "-screenshotbmp")) {
+    if (!_tcscmp (arg, L"-screenshotbmp")) {
         screenshotmode = 0;
        return 1;
     }
-    if (!strcmp (arg, "-psprintdebug")) {
+    if (!_tcscmp (arg, L"-psprintdebug")) {
         postscript_print_debugging = 1;
        return 1;
     }
-    if (!strcmp (arg, "-sounddebug")) {
+    if (!_tcscmp (arg, L"-sounddebug")) {
         sound_debug = 1;
        return 1;
     }
-    if (!strcmp (arg, "-directcatweasel")) {
+    if (!_tcscmp (arg, L"-directcatweasel")) {
         force_direct_catweasel = 1;
        if (np) {
            force_direct_catweasel = getval (np);
@@ -3426,26 +3445,26 @@ static int parseargs (const char *arg, const char *np)
        }
        return 1;
     }
-    if (!strcmp (arg, "-forcerdtsc")) {
+    if (!_tcscmp (arg, L"-forcerdtsc")) {
         userdtsc = 1;
        return 1;
     }
-    if (!strcmp (arg, "-ddsoftwarecolorkey")) {
+    if (!_tcscmp (arg, L"-ddsoftwarecolorkey")) {
         extern int ddsoftwarecolorkey;
         ddsoftwarecolorkey = 1;
        return 1;
     }
-    if (!strcmp (arg, "-logflush")) {
+    if (!_tcscmp (arg, L"-logflush")) {
         extern int always_flush_log;
         always_flush_log = 1;
        return 1;
     }
-    if (!strcmp (arg, "-ahidebug")) {
+    if (!_tcscmp (arg, L"-ahidebug")) {
         extern int ahi_debug;
         ahi_debug = 2;
        return 1;
     }
-    if (!strcmp (arg, "-ahidebug2")) {
+    if (!_tcscmp (arg, L"-ahidebug2")) {
         extern int ahi_debug;
         ahi_debug = 3;
        return 1;
@@ -3454,75 +3473,75 @@ static int parseargs (const char *arg, const char *np)
     if (!np)
        return 0;
 
-    if (!strcmp (arg, "-ddforcemode")) {
+    if (!_tcscmp (arg, L"-ddforcemode")) {
        extern int ddforceram;
        ddforceram = getval (np);
        if (ddforceram < 0 || ddforceram > 3)
            ddforceram = 0;
        return 2;
     }
-    if (!strcmp (arg, "-affinity")) {
+    if (!_tcscmp (arg, L"-affinity")) {
        cpu_affinity = getval (np);
        if (cpu_affinity == 0)
            cpu_affinity = original_affinity;
        SetThreadAffinityMask (GetCurrentThread (), cpu_affinity);
        return 2;
     }
-    if (!strcmp (arg, "-paffinity")) {
+    if (!_tcscmp (arg, L"-paffinity")) {
        cpu_paffinity = getval (np);
        if (cpu_paffinity == 0)
            cpu_paffinity = original_affinity;
        SetProcessAffinityMask (GetCurrentProcess (), cpu_paffinity);
        return 2;
     }
-    if (!strcmp (arg, "-datapath")) {
-       strcpy(start_path_data, np);
+    if (!_tcscmp (arg, L"-datapath")) {
+       _tcscpy(start_path_data, np);
        start_data = -1;
        return 2;
     }
-    if (!strcmp (arg, "-maxmem")) {
+    if (!_tcscmp (arg, L"-maxmem")) {
        maxmem = getval (np);
        return 2;
     }
-    if (!strcmp (arg, "-soundmodeskip")) {
+    if (!_tcscmp (arg, L"-soundmodeskip")) {
        sound_mode_skip = getval (np);
        return 2;
     }
-    if (!strcmp (arg, "-ini")) {
+    if (!_tcscmp (arg, L"-ini")) {
        inipath = my_strdup (np);
        return 2;
     }
-    if (!strcmp (arg, "-p96skipmode")) {
+    if (!_tcscmp (arg, L"-p96skipmode")) {
        extern int p96skipmode;
        p96skipmode = getval (np);
        return 2;
     }
-    if (!strcmp (arg, "-minidumpmode")) {
+    if (!_tcscmp (arg, L"-minidumpmode")) {
        minidumpmode = getval (np);
        return 2;
     }
-    if (!strcmp (arg, "-jitevent")) {
+    if (!_tcscmp (arg, L"-jitevent")) {
        pissoff_value = getval (np);
        return 2;
     }
 #ifdef RETROPLATFORM
-    if (!strcmp (arg, "-rphost")) {
+    if (!_tcscmp (arg, L"-rphost")) {
        rp_param = my_strdup (np);
        return 2;
     }
-    if (!strcmp (arg, "-rpescapekey")) {
+    if (!_tcscmp (arg, L"-rpescapekey")) {
        rp_rpescapekey = getval (np);
        return 2;
     }
-    if (!strcmp (arg, "-rpescapeholdtime")) {
+    if (!_tcscmp (arg, L"-rpescapeholdtime")) {
        rp_rpescapeholdtime = getval (np);
        return 2;
     }
-    if (!strcmp (arg, "-rpscreenmode")) {
+    if (!_tcscmp (arg, L"-rpscreenmode")) {
        rp_screenmode = getval (np);
        return 2;
     }
-    if (!strcmp (arg, "-rpinputmode")) {
+    if (!_tcscmp (arg, L"-rpinputmode")) {
        rp_inputmode = getval (np);
        return 2;
     }
@@ -3531,18 +3550,18 @@ static int parseargs (const char *arg, const char *np)
 }
 
 
-static char **parseargstring (char *s, char **xargv)
+static TCHAR **parseargstring (TCHAR *s, TCHAR **xargv)
 {
     int cnt, i, xargc;
-    char **args;
+    TCHAR **args;
 
-    if (strlen (s) == 0)
+    if (_tcslen (s) == 0)
        return NULL;
 
-    args = xcalloc (sizeof (char*), 32 + 1);
+    args = xcalloc (sizeof (TCHAR*), 32 + 1);
     cnt = 0;
     for (;;) {
-       char *p = s;
+       TCHAR *p = s;
        int skip = 0;
        while (*p && isspace (*p))
            p++;
@@ -3571,8 +3590,8 @@ static char **parseargstring (char *s, char **xargv)
     }
     for (xargc = 0; xargv[xargc]; xargc++);
     for (i = 0; i < cnt; i++) {
-       char *arg = args[i];
-       char *next = i + 1 < cnt ? args[i + 1] : NULL;
+       TCHAR *arg = args[i];
+       TCHAR *next = i + 1 < cnt ? args[i + 1] : NULL;
        int v = parseargs (arg, next);
        if (!v)
            xargv[xargc++] = my_strdup (arg);
@@ -3583,17 +3602,17 @@ static char **parseargstring (char *s, char **xargv)
 }
 
 
-static int process_arg (char **xargv)
+static int process_arg (TCHAR **xargv)
 {
     int i, argc, xargc;
     char **argv;
 
     xargc = 0;
     argc = __argc; argv = __argv;
-    xargv[xargc++] = my_strdup (argv[0]);
+    xargv[xargc++] = my_strdup_ansi (argv[0]);
     for (i = 1; i < argc; i++) {
-       char *arg = argv[i];
-       char *next = i + 1 < argc ? argv[i + 1] : NULL;
+       TCHAR *arg = au (argv[i]);
+       TCHAR *next = i + 1 < argc ? au (argv[i + 1]) : NULL;
        int v = parseargs (arg, next);
        if (!v)
            xargv[xargc++] = my_strdup (arg);
@@ -3607,29 +3626,29 @@ static int process_arg (char **xargv)
     return xargc;
 }
 
-static char **WIN32_InitRegistry (char **argv)
+static TCHAR **WIN32_InitRegistry (TCHAR **argv)
 {
     DWORD disposition;
-    char tmp[MAX_DPATH];
-    DWORD size = sizeof tmp;
+    TCHAR tmp[MAX_DPATH];
+    DWORD size = sizeof tmp / sizeof (TCHAR);
 
     reginitializeinit (inipath);
     hWinUAEKey = NULL;
     if (getregmode () == 0 || WINUAEPUBLICBETA > 0) {
        /* Create/Open the hWinUAEKey which points our config-info */
-       RegCreateKeyEx (HKEY_CURRENT_USER, "Software\\Arabuusimiehet\\WinUAE", 0, "", REG_OPTION_NON_VOLATILE,
+       RegCreateKeyEx (HKEY_CURRENT_USER, L"Software\\Arabuusimiehet\\WinUAE", 0, L"", REG_OPTION_NON_VOLATILE,
            KEY_WRITE | KEY_READ, NULL, &hWinUAEKey, &disposition);
     }
-    if (regquerystr (NULL, "Commandline", tmp, &size))
+    if (regquerystr (NULL, L"Commandline", tmp, &size))
        return parseargstring (tmp, argv);
     return NULL;
 }
 
 
-static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 {
     HANDLE hMutex;
-    char **argv = NULL, **argv2 = NULL;
+    TCHAR **argv = NULL, **argv2 = NULL;
     int argc, i;
 
 #ifdef _DEBUG
@@ -3652,12 +3671,12 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
        return 0;
 
     hInst = hInstance;
-    hMutex = CreateMutex (NULL, FALSE, "WinUAE Instantiated"); // To tell the installer we're running
+    hMutex = CreateMutex (NULL, FALSE, L"WinUAE Instantiated"); // To tell the installer we're running
 #ifdef AVIOUTPUT
     AVIOutput_Initialize ();
 #endif
 
-    argv = xcalloc (sizeof (char*),  __argc);
+    argv = xcalloc (sizeof (TCHAR*),  __argc);
     argc = process_arg (argv);
 
     argv2 = WIN32_InitRegistry (argv);
@@ -3665,37 +3684,39 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
     makeverstr (VersionStr);
 
     logging_init ();
+#if 0
     if (__argc > 1) {
-       write_log ("params:\n");
+       write_log (L"params:\n");
        for (i = 1; i < __argc; i++)
-           write_log ("%d: '%s'\n", i, __argv[i]);
+           write_log (L"%d: '%s'\n", i, __argv[i]);
     }
+#endif
     if (argv2) {
-       write_log ("extra params:\n");
+       write_log (L"extra params:\n");
        for (i = 0; argv2[i]; i++)
-           write_log ("%d: '%s'\n", i + 1, argv2[i]);
+           write_log (L"%d: '%s'\n", i + 1, argv2[i]);
     }
     if (WIN32_RegisterClasses () && WIN32_InitLibraries () && DirectDraw_Start (NULL)) {
        DEVMODE devmode;
        DWORD i;
 
        DirectDraw_Release ();
-       write_log ("Enumerating display devices.. \n");
+       write_log (L"Enumerating display devices.. \n");
        enumeratedisplays (multi_display);
-       write_log ("Sorting devices and modes..\n");
+       write_log (L"Sorting devices and modes..\n");
        sortdisplays ();
-       write_log ("Display buffer mode = %d\n", ddforceram);
+       write_log (L"Display buffer mode = %d\n", ddforceram);
        enumerate_sound_devices ();
        for (i = 0; sound_devices[i].name; i++) {
            int type = sound_devices[i].type;
-           write_log ("%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? "DS" : (type == SOUND_DEVICE_AL ? "AL" : "PA"), sound_devices[i].name);
+           write_log (L"%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? L"DS" : (type == SOUND_DEVICE_AL ? L"AL" : L"PA"), sound_devices[i].name);
        }
-       write_log ("Enumerating recording devices:\n");
+       write_log (L"Enumerating recording devices:\n");
        for (i = 0; record_devices[i].name; i++) {
            int type = record_devices[i].type;
-           write_log ("%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? "DS" : (type == SOUND_DEVICE_AL ? "AL" : "PA"), record_devices[i].name);
+           write_log (L"%d:%s: %s\n", i, type == SOUND_DEVICE_DS ? L"DS" : (type == SOUND_DEVICE_AL ? L"AL" : L"PA"), record_devices[i].name);
        }
-       write_log ("done\n");
+       write_log (L"done\n");
        memset (&devmode, 0, sizeof (devmode));
        devmode.dmSize = sizeof (DEVMODE);
        if (EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &devmode)) {
@@ -3717,7 +3738,7 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
 #ifdef PARALLEL_PORT
            paraport_mask = paraport_init ();
 #endif
-           globalipc = createIPC ("WinUAE", 0);
+           globalipc = createIPC (L"WinUAE", 0);
            serialipc = createIPC (COMPIPENAME, 1);
            enumserialports ();
            real_main (argc, argv);
@@ -3765,7 +3786,7 @@ static int PASCAL WinMain2 (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
 }
 
 #if 0
-int execute_command (char *cmd)
+int execute_command (TCHAR *cmd)
 {
     STARTUPINFO si;
     PROCESS_INFORMATION pi;
@@ -3798,7 +3819,7 @@ int driveclick_loadresource (struct drvsample *sp, int drivetype)
     ok = 1;
     for (i = 0; drvsampleres[i] >= 0; i += 2) {
        struct drvsample *s = sp + drvsampleres[i + 1];
-       HRSRC res = FindResource (NULL, MAKEINTRESOURCE (drvsampleres[i + 0]), "WAVE");
+       HRSRC res = FindResource (NULL, MAKEINTRESOURCE (drvsampleres[i + 0]), L"WAVE");
        if (res != 0) {
            HANDLE h = LoadResource (NULL, res);
            int len = SizeofResource (NULL, res);
@@ -3816,7 +3837,7 @@ int driveclick_loadresource (struct drvsample *sp, int drivetype)
 
 static LONG WINAPI WIN32_ExceptionFilter( struct _EXCEPTION_POINTERS * pExceptionPointers, DWORD ec)
 {
-    write_log ("EVALEXCEPTION!\n");
+    write_log (L"EVALEXCEPTION!\n");
     return EXCEPTION_EXECUTE_HANDLER;
 }
 #else
@@ -3844,7 +3865,7 @@ static void savedump (MINIDUMPWRITEDUMP dump, HANDLE f, struct _EXCEPTION_POINTE
     MINIDUMP_EXCEPTION_INFORMATION exinfo;
     MINIDUMP_USER_STREAM_INFORMATION musi, *musip;
     MINIDUMP_USER_STREAM mus[2], *musp;
-    char *log;
+    uae_char *log;
     int loglen;
 
     musip = NULL;
@@ -3883,7 +3904,7 @@ LONG WINAPI WIN32_ExceptionFilter (struct _EXCEPTION_POINTERS *pExceptionPointer
     if (ec == EXCEPTION_ACCESS_VIOLATION && !er->ExceptionFlags &&
        er->NumberParameters >= 2 && !er->ExceptionInformation[0] && regs.pc_p) {
            void *p = (void*)er->ExceptionInformation[1];
-           write_log ("ExceptionFilter Trap: %p %p %p\n", p, regs.pc_p, prevpc);
+           write_log (L"ExceptionFilter Trap: %p %p %p\n", p, regs.pc_p, prevpc);
            if ((p >= (void*)regs.pc_p && p < (void*)(regs.pc_p + 32))
                || (p >= (void*)prevpc && p < (void*)(prevpc + 32))) {
                int got = 0;
@@ -3896,9 +3917,9 @@ LONG WINAPI WIN32_ExceptionFilter (struct _EXCEPTION_POINTERS *pExceptionPointer
                efix (&ctx->Edx, p, ps, &got);
                efix (&ctx->Esi, p, ps, &got);
                efix (&ctx->Edi, p, ps, &got);
-               write_log ("Access violation! (68KPC=%08X HOSTADDR=%p)\n", M68K_GETPC, p);
+               write_log (L"Access violation! (68KPC=%08X HOSTADDR=%p)\n", M68K_GETPC, p);
                if (got == 0) {
-                   write_log ("failed to find and fix the problem (%p). crashing..\n", p);
+                   write_log (L"failed to find and fix the problem (%p). crashing..\n", p);
                } else {
                    void *ppc = regs.pc_p;
                    m68k_setpc (&regs, 0);
@@ -3912,33 +3933,33 @@ LONG WINAPI WIN32_ExceptionFilter (struct _EXCEPTION_POINTERS *pExceptionPointer
     }
 #ifndef        _DEBUG
     if (lRet == EXCEPTION_CONTINUE_SEARCH) {
-       char path[MAX_DPATH];
-       char path2[MAX_DPATH];
-       char msg[1024];
-       char *p;
+       TCHAR path[MAX_DPATH];
+       TCHAR path2[MAX_DPATH];
+       TCHAR msg[1024];
+       TCHAR *p;
        HMODULE dll = NULL;
        struct tm when;
        __time64_t now;
 
        if (os_winnt && GetModuleFileName (NULL, path, MAX_DPATH)) {
-           char *slash = strrchr (path, '\\');
+           TCHAR *slash = _tcsrchr (path, '\\');
            _time64 (&now);
            when = *_localtime64 (&now);
-           strcpy (path2, path);
+           _tcscpy (path2, path);
            if (slash) {
-               strcpy (slash + 1, "DBGHELP.DLL");
+               _tcscpy (slash + 1, L"DBGHELP.DLL");
                dll = WIN32_LoadLibrary (path);
            }
-           slash = strrchr (path2, '\\');
+           slash = _tcsrchr (path2, '\\');
            if (slash)
                p = slash + 1;
            else
                p = path2;
-           sprintf (p, "winuae_%d%d%d%d_%d%02d%02d_%02d%02d%02d.dmp",
+           _stprintf (p, L"winuae_%d%d%d%d_%d%02d%02d_%02d%02d%02d.dmp",
                UAEMAJOR, UAEMINOR, UAESUBREV, WINUAEBETA,
                when.tm_year + 1900, when.tm_mon + 1, when.tm_mday, when.tm_hour, when.tm_min, when.tm_sec);
            if (dll == NULL)
-               dll = WIN32_LoadLibrary ("DBGHELP.DLL");
+               dll = WIN32_LoadLibrary (L"DBGHELP.DLL");
            if (dll) {
                MINIDUMPWRITEDUMP dump = (MINIDUMPWRITEDUMP)GetProcAddress (dll, "MiniDumpWriteDump");
                if (dump) {
@@ -3948,8 +3969,8 @@ LONG WINAPI WIN32_ExceptionFilter (struct _EXCEPTION_POINTERS *pExceptionPointer
                        savedump (dump, f, pExceptionPointers);
                        CloseHandle (f);
                        if (isfullscreen () <= 0) {
-                           sprintf (msg, "Crash detected. MiniDump saved as:\n%s\n", path2);
-                           MessageBox (NULL, msg, "Crash", MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND);
+                           _stprintf (msg, L"Crash detected. MiniDump saved as:\n%s\n", path2);
+                           MessageBox (NULL, msg, L"Crash", MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND);
                        }
                    }
                }
@@ -3958,9 +3979,9 @@ LONG WINAPI WIN32_ExceptionFilter (struct _EXCEPTION_POINTERS *pExceptionPointer
     }
 #endif
 #if 0
-       HMODULE hFaultRepDll = LoadLibrary ("FaultRep.dll") ;
+       HMODULE hFaultRepDll = LoadLibrary (L"FaultRep.dll") ;
        if (hFaultRepDll) {
-           pfn_REPORTFAULT pfn = (pfn_REPORTFAULT)GetProcAddress (hFaultRepDll, "ReportFault");
+           pfn_REPORTFAULT pfn = (pfn_REPORTFAULT)GetProcAddress (hFaultRepDll, L"ReportFault");
            if (pfn) {
                EFaultRepRetVal rc = pfn (pExceptionPointers, 0);
                lRet = EXCEPTION_EXECUTE_HANDLER;
@@ -3994,9 +4015,9 @@ void addnotifications (HWND hwnd, int remove)
     SHCHANGENOTIFYDEREGISTER pSHChangeNotifyDeregister;
 
     pSHChangeNotifyRegister = (SHCHANGENOTIFYREGISTER)GetProcAddress (
-       GetModuleHandle ("shell32.dll"), "SHChangeNotifyRegister");
+       GetModuleHandle (L"shell32.dll"), "SHChangeNotifyRegister");
     pSHChangeNotifyDeregister = (SHCHANGENOTIFYDEREGISTER)GetProcAddress (
-       GetModuleHandle ("shell32.dll"), "SHChangeNotifyDeregister");
+       GetModuleHandle (L"shell32.dll"), "SHChangeNotifyDeregister");
 
     if (remove) {
        if (ret > 0 && pSHChangeNotifyDeregister)
@@ -4031,11 +4052,11 @@ void systray (HWND hwnd, int remove)
     if (rp_isactive ())
        return;
 #endif
-    //write_log ("notif: systray(%x,%d)\n", hwnd, remove);
+    //write_log (L"notif: systray(%x,%d)\n", hwnd, remove);
     if (!remove) {
-       TaskbarRestart = RegisterWindowMessage (TEXT ("TaskbarCreated"));
+       TaskbarRestart = RegisterWindowMessage (L"TaskbarCreated");
        TaskbarRestartHWND = hwnd;
-       //write_log ("notif: taskbarrestart = %d\n", TaskbarRestart);
+       //write_log (L"notif: taskbarrestart = %d\n", TaskbarRestart);
     } else {
        TaskbarRestart = 0;
        hwnd = TaskbarRestartHWND;
@@ -4045,17 +4066,17 @@ void systray (HWND hwnd, int remove)
     memset (&nid, 0, sizeof (nid));
     nid.cbSize = sizeof (nid);
     nid.hWnd = hwnd;
-    nid.hIcon = LoadIcon (hInst, (LPCSTR)MAKEINTRESOURCE(IDI_APPICON));
+    nid.hIcon = LoadIcon (hInst, (LPCWSTR)MAKEINTRESOURCE (IDI_APPICON));
     nid.uFlags = NIF_ICON | NIF_MESSAGE;
     nid.uCallbackMessage = WM_USER + 1;
     v = Shell_NotifyIcon (remove ? NIM_DELETE : NIM_ADD, &nid);
-    //write_log ("notif: Shell_NotifyIcon returned %d\n", v);
+    //write_log (L"notif: Shell_NotifyIcon returned %d\n", v);
     if (v) {
        if (remove)
            TaskbarRestartHWND = NULL;
     } else {
        DWORD err = GetLastError ();
-       write_log ("Notify error code = %x (%d)\n",  err, err);
+       write_log (L"Notify error code = %x (%d)\n",  err, err);
     }
 }
 
@@ -4065,9 +4086,9 @@ static void systraymenu (HWND hwnd)
     HMENU menu, menu2, drvmenu;
     int drvs[] = { ID_ST_DF0, ID_ST_DF1, ID_ST_DF2, ID_ST_DF3, -1 };
     int i;
-    char text[100];
+    TCHAR text[100];
 
-    WIN32GUI_LoadUIString (IDS_STMENUNOFLOPPY, text, sizeof (text));
+    WIN32GUI_LoadUIString (IDS_STMENUNOFLOPPY, text, sizeof (text) / sizeof (TCHAR));
     GetCursorPos (&pt);
     menu = LoadMenu (hUIDLL ? hUIDLL : hInst, MAKEINTRESOURCE (IDM_SYSTRAY));
     if (!menu)
@@ -4077,11 +4098,11 @@ static void systraymenu (HWND hwnd)
     EnableMenuItem (menu2, ID_ST_HELP, pHtmlHelp ? MF_ENABLED : MF_GRAYED);
     i = 0;
     while (drvs[i] >= 0) {
-       char s[MAX_DPATH];
+       TCHAR s[MAX_DPATH];
        if (currprefs.df[i][0])
-           sprintf (s, "DF%d: [%s]", i, currprefs.df[i]);
+           _stprintf (s, L"DF%d: [%s]", i, currprefs.df[i]);
        else
-           sprintf (s, "DF%d: [%s]", i, text);
+           _stprintf (s, L"DF%d: [%s]", i, text);
        ModifyMenu (drvmenu, drvs[i], MF_BYCOMMAND | MF_STRING, drvs[i], s);
        EnableMenuItem (menu2, drvs[i], currprefs.dfxtype[i] < 0 ? MF_GRAYED : MF_ENABLED);
        i++;
@@ -4094,31 +4115,31 @@ static void systraymenu (HWND hwnd)
     DestroyMenu (menu);
 }
 
-static void LLError(const char *s)
+static void LLError(const TCHAR *s)
 {
     DWORD err = GetLastError ();
 
     if (err == ERROR_MOD_NOT_FOUND || err == ERROR_DLL_NOT_FOUND)
        return;
-    write_log ("%s failed to open %d\n", s, err);
+    write_log (L"%s failed to open %d\n", s, err);
 }
 
-HMODULE WIN32_LoadLibrary (const char *name)
+HMODULE WIN32_LoadLibrary (const TCHAR *name)
 {
     HMODULE m = NULL;
-    char *newname;
+    TCHAR *newname;
     DWORD err = -1;
 #ifdef CPU_64_BIT
-    char *p;
+    TCHAR *p;
 #endif
     int round;
 
-    newname = xmalloc (strlen (name) + 1 + 10);
+    newname = xmalloc ((_tcslen (name) + 1 + 10) * sizeof (TCHAR));
     if (!newname)
        return NULL;
     for (round = 0; round < 4; round++) {
-       char *s;
-       strcpy (newname, name);
+       TCHAR *s;
+       _tcscpy (newname, name);
 #ifdef CPU_64_BIT
        switch(round)
        {
@@ -4131,27 +4152,27 @@ HMODULE WIN32_LoadLibrary (const char *name)
            break;
            case 1:
            p = strchr (newname,'.');
-           strcpy(p,"_64");
-           strcat(p, strchr (name,'.'));
+           _tcscpy(p,"_64");
+           _tcscat(p, strchr (name,'.'));
            break;
            case 2:
            p = strchr (newname,'.');
-           strcpy (p,"64");
-           strcat (p, strchr (name,'.'));
+           _tcscpy (p,"64");
+           _tcscat (p, strchr (name,'.'));
            break;
        }
 #endif
-       s = xmalloc (strlen (start_path_exe) + strlen (WIN32_PLUGINDIR) + strlen (newname) + 1);
+       s = xmalloc ((_tcslen (start_path_exe) + _tcslen (WIN32_PLUGINDIR) + _tcslen (newname) + 1) * sizeof (TCHAR));
        if (s) {
-           sprintf (s, "%s%s%s", start_path_exe, WIN32_PLUGINDIR, newname);
+           _stprintf (s, L"%s%s%s", start_path_exe, WIN32_PLUGINDIR, newname);
            m = LoadLibrary (s);
            if (m)
                goto end;
-           sprintf (s, "%s%s", start_path_exe, newname);
+           _stprintf (s, L"%s%s", start_path_exe, newname);
            m = LoadLibrary (s);
            if (m)
                goto end;
-           sprintf (s, "%s%s%s", start_path_exe, WIN32_PLUGINDIR, newname);
+           _stprintf (s, L"%s%s%s", start_path_exe, WIN32_PLUGINDIR, newname);
            LLError(s);
            xfree (s);
        }
@@ -4213,18 +4234,20 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
 #define MSGFLT_ADD 1
     CHANGEWINDOWMESSAGEFILTER pChangeWindowMessageFilter;
     pChangeWindowMessageFilter = (CHANGEWINDOWMESSAGEFILTER)GetProcAddress(
-       GetModuleHandle("user32.dll"), "ChangeWindowMessageFilter");
+       GetModuleHandle(L"user32.dll"), L"ChangeWindowMessageFilter");
     if (pChangeWindowMessageFilter)
        pChangeWindowMessageFilter(WM_DROPFILES, MSGFLT_ADD);
 #endif
 
     pSetProcessDPIAware = (SETPROCESSDPIAWARE)GetProcAddress (
-       GetModuleHandle ("user32.dll"), "SetProcessDPIAware");
+       GetModuleHandle (L"user32.dll"), "SetProcessDPIAware");
     if (pSetProcessDPIAware)
        pSetProcessDPIAware ();
 
+    pgmptr = au (_pgmptr);
+
     __try {
-       WinMain2 (hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+       WinMain2 (hInstance, hPrevInstance, GetCommandLineW (), nCmdShow);
     } __except(WIN32_ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
     }
     //SetThreadAffinityMask(thread, original_affinity);
index d106987b82bb5bc3ec8652ad5cb0d3fa8f2ec125..909c5547c9a24225c16d196546d435650499a0e1 100644 (file)
 
 #define WINUAEPUBLICBETA 1
 
-#define WINUAEBETA "14"
-#define WINUAEDATE MAKEBD(2009, 2, 28)
-#define WINUAEEXTRA ""
-#define WINUAEREV ""
+#define WINUAEBETA L"15"
+#define WINUAEDATE MAKEBD(2009, 3, 7)
+#define WINUAEEXTRA L""
+#define WINUAEREV L""
 
 #define IHF_WINDOWHIDDEN 6
 #define NORMAL_WINDOW_STYLE (WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX)
@@ -31,12 +31,12 @@ extern RECT amigawin_rect;
 extern int in_sizemove;
 extern int manual_painting_needed;
 extern int manual_palette_refresh_needed;
-extern int mouseactive, focus;
+extern int mouseactive;
 extern int ignore_messages_all;
 extern void *globalipc, *serialipc;
 
-extern char start_path_exe[MAX_DPATH];
-extern char start_path_data[MAX_DPATH];
+extern TCHAR start_path_exe[MAX_DPATH];
+extern TCHAR start_path_data[MAX_DPATH];
 
 extern void my_kbd_handler (int, int, int);
 extern void clearallkeys (void);
@@ -53,6 +53,7 @@ extern void setup_brkhandler (void);
 extern void remove_brkhandler (void);
 extern void disablecapture (void);
 extern void fullscreentoggle (void);
+extern int isfocus (void);
 
 extern void setmouseactive (int active);
 extern void minimizewindow (void);
@@ -68,9 +69,9 @@ void init_colors (void);
 extern int pause_emulation;
 extern int sound_available;
 extern int framecnt;
-extern char prtname[];
-extern char VersionStr[256];
-extern char BetaStr[64];
+extern TCHAR prtname[];
+extern TCHAR VersionStr[256];
+extern TCHAR BetaStr[64];
 extern int os_winnt_admin, os_64bit, os_vista, os_winxp, os_win7;
 extern OSVERSIONINFO osVersion;
 extern int paraport_mask;
@@ -83,7 +84,8 @@ extern HINSTANCE hInst;
 extern int win_x_diff, win_y_diff;
 extern int window_extra_width, window_extra_height;
 extern int af_path_2005, af_path_old;
-extern char start_path_af[MAX_DPATH], start_path_new1[MAX_DPATH], start_path_new2[MAX_DPATH];
+extern TCHAR start_path_af[MAX_DPATH], start_path_new1[MAX_DPATH], start_path_new2[MAX_DPATH];
+extern TCHAR *pgmptr;
 #define PATH_TYPE_WINUAE 0
 #define PATH_TYPE_NEWWINUAE 1
 #define PATH_TYPE_OLDAF 2
@@ -99,7 +101,7 @@ extern void handle_rawinput (LPARAM lParam);
 
 #define DEFAULT_PRIORITY 2
 struct threadpriorities {
-    char *name;
+    TCHAR *name;
     int value;
     int classvalue;
     int id;
@@ -118,18 +120,18 @@ extern void send_tablet (int x, int y, int z, int pres, uae_u32 buttons, int fla
 extern void send_tablet_proximity (int);
 
 void addnotifications (HWND hwnd, int remove);
-int win32_hardfile_media_change (const char *drvname, int inserted);
-extern int CheckRM (char *DriveName);
+int win32_hardfile_media_change (const TCHAR *drvname, int inserted);
+extern int CheckRM (TCHAR *DriveName);
 void systray (HWND hwnd, int remove);
 void systraymenu (HWND hwnd);
 void exit_gui (int);
-void fetch_path (char *name, char *out, int size);
-void set_path (char *name, char *path);
+void fetch_path (TCHAR *name, TCHAR *out, int size);
+void set_path (TCHAR *name, TCHAR *path);
 void read_rom_list (void);
 void associate_file_extensions (void);
 
-#define WIN32_PLUGINDIR "plugins\\"
-HMODULE WIN32_LoadLibrary (const char *);
+#define WIN32_PLUGINDIR L"plugins\\"
+HMODULE WIN32_LoadLibrary (const TCHAR *);
 
 extern int screenshot_prepare (void);
 extern void screenshot_free (void);
@@ -137,7 +139,7 @@ extern void screenshot_free (void);
 struct winuae_lang
 {
     WORD id;
-    char *name;
+    TCHAR *name;
 };
 extern struct winuae_lang langs[];
 extern HMODULE language_load (WORD language);
@@ -155,9 +157,9 @@ extern LONG WINAPI WIN32_ExceptionFilter (struct _EXCEPTION_POINTERS *pException
 struct sound_device
 {
     GUID guid;
-    char *name;
-    char *alname;
-    char *cfgname;
+    TCHAR *name;
+    TCHAR *alname;
+    TCHAR *cfgname;
     int panum;
     int type;
 };
@@ -165,9 +167,9 @@ extern struct sound_device sound_devices[MAX_SOUND_DEVICES];
 extern struct sound_device record_devices[MAX_SOUND_DEVICES];
 
 struct assext {
-    char *ext;
-    char *cmd;
-    char *desc;
+    TCHAR *ext;
+    TCHAR *cmd;
+    TCHAR *desc;
     int enabled;
 };
 struct assext exts[];
index ba4e13d5159df42c2b338932b6ce7971df33ec95..dc688fb9586ad56f469c19b78288614506c7f940 100644 (file)
@@ -1,13 +1,13 @@
 
 
 /* Determines if this drive-letter currently has a disk inserted */
-int CheckRM(char *DriveName)
+int CheckRM (TCHAR *DriveName)
 {
-    char filename[MAX_DPATH];
+    TCHAR filename[MAX_DPATH];
     DWORD dwHold;
     BOOL result = FALSE;
 
-    sprintf(filename, "%s.", DriveName);
+    _stprintf(filename, L"%s.", DriveName);
     dwHold = GetFileAttributes(filename);
     if(dwHold != 0xFFFFFFFF)
        result = TRUE;
@@ -16,21 +16,21 @@ int CheckRM(char *DriveName)
 
 /* This function makes sure the volume-name being requested is not already in use, or any of the following
    illegal values: */
-static char *illegal_volumenames[] = { "SYS", "DEVS", "LIBS", "FONTS", "C", "L", "S" };
+static TCHAR *illegal_volumenames[] = { L"SYS", L"DEVS", L"LIBS", L"FONTS", L"C", L"L", L"S" };
 
-static int valid_volumename(struct uaedev_mount_info *mountinfo, char *volumename, int fullcheck)
+static int valid_volumename (struct uaedev_mount_info *mountinfo, TCHAR *volumename, int fullcheck)
 {
-    int i, result = 1, illegal_count = sizeof(illegal_volumenames) / sizeof(char *);
+    int i, result = 1, illegal_count = sizeof (illegal_volumenames) / sizeof(TCHAR*);
     for (i = 0; i < illegal_count; i++) {
-       if(strcmp(volumename, illegal_volumenames[i]) == 0) {
+       if(_tcscmp (volumename, illegal_volumenames[i]) == 0) {
            result = 0;
            break;
        }
     }
     /* if result is still good, we've passed the illegal names check, and must check for duplicates now */
     if(result && fullcheck) {
-       for(i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
-           if(mountinfo->ui[i].open && mountinfo->ui[i].volname && strcmp(mountinfo->ui[i].volname, volumename) == 0) {
+       for (i = 0; i < MAX_FILESYSTEM_UNITS; i++) {
+           if (mountinfo->ui[i].open && mountinfo->ui[i].volname && _tcscmp (mountinfo->ui[i].volname, volumename) == 0) {
                result = 0;
                break;
            }
@@ -40,7 +40,7 @@ static int valid_volumename(struct uaedev_mount_info *mountinfo, char *volumenam
 }
 
 /* Returns 1 if an actual volume-name was found, 2 if no volume-name (so uses some defaults) */
-int target_get_volume_name (struct uaedev_mount_info *mtinf, const char *volumepath, char *volumename, int size, int inserted, int fullcheck)
+int target_get_volume_name (struct uaedev_mount_info *mtinf, const TCHAR *volumepath, TCHAR *volumename, int size, int inserted, int fullcheck)
 {
     int result = 2;
     int drivetype;
@@ -51,12 +51,12 @@ int target_get_volume_name (struct uaedev_mount_info *mtinf, const char *volumep
            volumename[0] && 
            valid_volumename (mtinf, volumename, fullcheck)) {
            // +++Bernd Roesch
-           if(!strcmp (volumename, "AmigaOS35"))
-               strcpy (volumename, "AmigaOS3.5");
-           if(!strcmp (volumename, "AmigaOS39"))
-               strcpy (volumename, "AmigaOS3.9");
+           if(!_tcscmp (volumename, L"AmigaOS35"))
+               _tcscpy (volumename, L"AmigaOS3.5");
+           if(!_tcscmp (volumename, L"AmigaOS39"))
+               _tcscpy (volumename, L"AmigaOS3.9");
            // ---Bernd Roesch
-           if (strlen (volumename) > 0)
+           if (_tcslen (volumename) > 0)
                result = 1;
        }
     }
@@ -65,19 +65,19 @@ int target_get_volume_name (struct uaedev_mount_info *mtinf, const char *volumep
        switch(drivetype)
        {
            case DRIVE_FIXED:
-               sprintf (volumename, "WinDH_%c", volumepath[0]);
+               _stprintf (volumename, L"WinDH_%c", volumepath[0]);
                break;
            case DRIVE_CDROM:
-               sprintf (volumename, "WinCD_%c", volumepath[0]);
+               _stprintf (volumename, L"WinCD_%c", volumepath[0]);
                break;
            case DRIVE_REMOVABLE:
-               sprintf (volumename, "WinRMV_%c", volumepath[0]);
+               _stprintf (volumename, L"WinRMV_%c", volumepath[0]);
                break;
            case DRIVE_REMOTE:
-               sprintf (volumename, "WinNET_%c", volumepath[0]);
+               _stprintf (volumename, L"WinNET_%c", volumepath[0]);
                break;
            case DRIVE_RAMDISK:
-               sprintf (volumename, "WinRAM_%c", volumepath[0]);
+               _stprintf (volumename, L"WinRAM_%c", volumepath[0]);
                break;
            case DRIVE_UNKNOWN:
            case DRIVE_NO_ROOT_DIR:
@@ -94,8 +94,8 @@ static void filesys_addexternals(void)
 {
     int drive, drivetype;
     UINT errormode;
-    char volumename[MAX_DPATH]="";
-    char volumepath[6];
+    TCHAR volumename[MAX_DPATH] = L"";
+    TCHAR volumepath[6];
     DWORD dwDriveMask;
     int drvnum = 0;
 
@@ -104,18 +104,18 @@ static void filesys_addexternals(void)
     dwDriveMask >>= 2; // Skip A and B drives...
 
     for(drive = 'C'; drive <= 'Z'; ++drive) {
-        sprintf(volumepath, "%c:\\", drive);
+        _stprintf(volumepath, L"%c:\\", drive);
         /* Is this drive-letter valid (it used to check for media in drive) */
         if(dwDriveMask & 1) {
-           char devname[100];
-           BOOL inserted = CheckRM(volumepath); /* Is there a disk inserted? */
+           TCHAR devname[100];
+           BOOL inserted = CheckRM (volumepath); /* Is there a disk inserted? */
            int nok = FALSE;
            int rw = 1;
-           drivetype = GetDriveType(volumepath);
+           drivetype = GetDriveType (volumepath);
            devname[0] = 0;
            for (;;) {
                if (drivetype == DRIVE_CDROM && currprefs.win32_automount_cddrives) {
-                   sprintf (devname, "WinCD_%c", drive);
+                   _stprintf (devname, L"WinCD_%c", drive);
                    rw = 0;
                    break;
                }
@@ -138,13 +138,13 @@ static void filesys_addexternals(void)
            if (inserted) {
                target_get_volume_name (&mountinfo, volumepath, volumename, MAX_DPATH, inserted, 1);
                if (!volumename[0])
-                   sprintf (volumename, "WinUNK_%c", drive);
+                   _stprintf (volumename, L"WinUNK_%c", drive);
            }
            if (drivetype == DRIVE_REMOTE)
-               strcat(volumepath, ".");
+               _tcscat (volumepath, L".");
            else
-               strcat(volumepath, "..");
-           //write_log ("Drive type %d: '%s' '%s'\n", drivetype, volumepath, volumename);
+               _tcscat (volumepath, L"..");
+           //write_log (L"Drive type %d: '%s' '%s'\n", drivetype, volumepath, volumename);
            add_filesys_unit (devname[0] ? devname : NULL, volumename, volumepath, !rw, 0, 0, 0, 0, -20 - drvnum, 0, 1, 0, 0, 0);
            drvnum++;
        } /* if drivemask */
index 3433eebbea314d256684c5e147f60feb2f214d05..4987b796d0a6640f1937400f2badbfa16120e51d 100644 (file)
 
 struct uae_filter uaefilters[] =
 {
-    { UAE_FILTER_NULL, 0, 1, "Null filter", "null", 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32, 0, 0, 0 },
+    { UAE_FILTER_NULL, 0, 1, L"Null filter", L"null", 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32, 0, 0, 0 },
 
-    { UAE_FILTER_DIRECT3D, 0, 1, "Direct3D", "direct3d", 1, 0, 0, 0, 0 },
+    { UAE_FILTER_DIRECT3D, 0, 1, L"Direct3D", L"direct3d", 1, 0, 0, 0, 0 },
 
-    { UAE_FILTER_OPENGL, 0, 1, "OpenGL", "opengl", 1, 0, 0, 0, 0 },
+    { UAE_FILTER_OPENGL, 0, 1, L"OpenGL", L"opengl", 1, 0, 0, 0, 0 },
 
-    { UAE_FILTER_SCALE2X, 0, 2, "Scale2X", "scale2x", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32, 0, 0 },
+    { UAE_FILTER_SCALE2X, 0, 2, L"Scale2X", L"scale2x", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32, 0, 0 },
 
-    { UAE_FILTER_HQ, 0, 2, "hq2x/3x/4x", "hqx", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32 },
+    { UAE_FILTER_HQ, 0, 2, L"hq2x/3x/4x", L"hqx", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32 },
 
-    { UAE_FILTER_SUPEREAGLE, 0, 2, "SuperEagle", "supereagle", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, 0, 0 },
+    { UAE_FILTER_SUPEREAGLE, 0, 2, L"SuperEagle", L"supereagle", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, 0, 0 },
 
-    { UAE_FILTER_SUPER2XSAI, 0, 2, "Super2xSaI", "super2xsai", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, 0, 0 },
+    { UAE_FILTER_SUPER2XSAI, 0, 2, L"Super2xSaI", L"super2xsai", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, 0, 0 },
 
-    { UAE_FILTER_2XSAI, 0, 2, "2xSaI", "2xsai", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, 0, 0 },
+    { UAE_FILTER_2XSAI, 0, 2, L"2xSaI", L"2xsai", 0, 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_16_32, 0, 0 },
 
-    { UAE_FILTER_PAL, 1, 1, "PAL", "pal", 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32, 0, 0, 0 },
+    { UAE_FILTER_PAL, 1, 1, L"PAL", L"pal", 0, UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32, 0, 0, 0 },
 
     { 0 }
 };
@@ -404,7 +404,7 @@ void S2X_init (int dw, int dh, int aw, int ah, int mult, int ad, int dd)
         tempsurf = allocsurface (temp_width, temp_height);
     }
     if (!tempsurf)
-        write_log ("DDRAW: failed to create temp surface (%dx%d)\n", temp_width, temp_height);
+        write_log (L"DDRAW: failed to create temp surface (%dx%d)\n", temp_width, temp_height);
 
 }
 
@@ -567,7 +567,7 @@ end:
     unlocksurface (tempsurf);
 
     getfilterrect2 (&dr, &sr, &zr, dst_width, dst_height, aw, ah, scale, temp_width, temp_height);
-    //write_log ("(%d %d %d %d) - (%d %d %d %d) (%d %d)\n", dr.left, dr.top, dr.right, dr.bottom, sr.left, sr.top, sr.right, sr.bottom, zr.left, zr.top);
+    //write_log (L"(%d %d %d %d) - (%d %d %d %d) (%d %d)\n", dr.left, dr.top, dr.right, dr.bottom, sr.left, sr.top, sr.right, sr.bottom, zr.left, zr.top);
     OffsetRect (&sr, zr.left, zr.top);
     if (sr.left >= 0 && sr.top >= 0 && sr.right < temp_width && sr.bottom < temp_height) {
        if (sr.left < sr.right && sr.top < sr.bottom)
index 2d50b07cc77cb81d97ed7b137303038f0898c571..c3b7da1458039574c715b5b0b70a56888e1fea61 100644 (file)
@@ -156,7 +156,7 @@ static void *uaenet_trap_threadr (void *arg)
            uae_sem_post (&sd->change_sem);
        }
        if (r < 0) {
-           write_log ("pcap_next_ex failed, err=%d\n", r);
+           write_log (L"pcap_next_ex failed, err=%d\n", r);
            break;
        }
     }
@@ -198,9 +198,15 @@ void uaenet_trigger (struct uaenetdatawin32 *sd)
 
 int uaenet_open (struct uaenetdatawin32 *sd, struct netdriverdata *tc, void *user, int promiscuous)
 {
-    sd->fp = pcap_open (tc->name, 65536, (promiscuous ? PCAP_OPENFLAG_PROMISCUOUS : 0) | PCAP_OPENFLAG_MAX_RESPONSIVENESS, 100, NULL, sd->errbuf);
+    char *s;
+
+    s = ua (tc->name);
+    sd->fp = pcap_open (s, 65536, (promiscuous ? PCAP_OPENFLAG_PROMISCUOUS : 0) | PCAP_OPENFLAG_MAX_RESPONSIVENESS, 100, NULL, sd->errbuf);
+    xfree (s);
     if (sd->fp == NULL) {
-       write_log ("'%s' failed to open: %s\n", tc->name, sd->errbuf);
+       TCHAR *ss = au (sd->errbuf);
+       write_log (L"'%s' failed to open: %s\n", tc->name, ss);
+       xfree (ss);
        return 0;
     }
     sd->tc = tc;
@@ -215,12 +221,12 @@ int uaenet_open (struct uaenetdatawin32 *sd, struct netdriverdata *tc, void *use
 
     uae_sem_init (&sd->change_sem, 0, 1);
     uae_sem_init (&sd->sync_semr, 0, 0);
-    uae_start_thread ("uaenet_win32r", uaenet_trap_threadr, sd, &sd->tidr);
+    uae_start_thread (L"uaenet_win32r", uaenet_trap_threadr, sd, &sd->tidr);
     uae_sem_wait (&sd->sync_semr);
     uae_sem_init (&sd->sync_semw, 0, 0);
-    uae_start_thread ("uaenet_win32w", uaenet_trap_threadw, sd, &sd->tidw);
+    uae_start_thread (L"uaenet_win32w", uaenet_trap_threadw, sd, &sd->tidw);
     uae_sem_wait (&sd->sync_semw);
-    write_log ("uaenet_win32 initialized\n");
+    write_log (L"uaenet_win32 initialized\n");
     return 1;
 
 end:
@@ -242,14 +248,14 @@ void uaenet_close (struct uaenetdatawin32 *sd)
     if (sd->threadactiver) {
        while (sd->threadactiver)
            Sleep(10);
-       write_log ("uaenet_win32 thread %d killed\n", sd->tidr);
+       write_log (L"uaenet_win32 thread %d killed\n", sd->tidr);
        uae_end_thread (&sd->tidr);
     }
     if (sd->threadactivew) {
        while (sd->threadactivew)
            Sleep(10);
        CloseHandle (sd->evttw);
-       write_log ("uaenet_win32 thread %d killed\n", sd->tidw);
+       write_log (L"uaenet_win32 thread %d killed\n", sd->tidw);
        uae_end_thread (&sd->tidw);
     }
     xfree (sd->readbuffer);
@@ -257,7 +263,7 @@ void uaenet_close (struct uaenetdatawin32 *sd)
     if (sd->fp)
        pcap_close (sd->fp);
     uaeser_initdata (sd, sd->user);
-    write_log ("uaenet_win32 closed\n");
+    write_log (L"uaenet_win32 closed\n");
 }
 
 
@@ -272,56 +278,67 @@ int uaenet_open_driver (struct netdriverdata *tcp)
     struct netdriverdata *tc;
     pcap_t *fp;
     int val;
+    TCHAR *ss;
 
-    hm = LoadLibrary ("wpcap.dll");
+    hm = LoadLibrary (L"wpcap.dll");
     if (hm == NULL) {
-       write_log ("uaenet: winpcap not installed (wpcap.dll)\n");
+       write_log (L"uaenet: winpcap not installed (wpcap.dll)\n");
        return 0;
     }
     FreeLibrary (hm);
-    hm = LoadLibrary ("packet.dll");
+    hm = LoadLibrary (L"packet.dll");
     if (hm == NULL) {
-       write_log ("uaenet: winpcap not installed (packet.dll)\n");
+       write_log (L"uaenet: winpcap not installed (packet.dll)\n");
        return 0;
     }
     FreeLibrary (hm);
-    write_log ("uaenet: %s\n", pcap_lib_version ());
+    ss = au (pcap_lib_version ());
+    write_log (L"uaenet: %s\n", ss);
+    xfree (ss);
 
     if (pcap_findalldevs_ex (PCAP_SRC_IF_STRING, NULL, &alldevs, errbuf) == -1) {
-       write_log ("uaenet: failed to get interfaces: %s\n", errbuf);
+       ss = au (errbuf);
+       write_log (L"uaenet: failed to get interfaces: %s\n", ss);
+       xfree (ss);
        return 0;
     }
 
-    write_log ("uaenet: detecting interfaces\n");
+    write_log (L"uaenet: detecting interfaces\n");
     for(cnt = 0, d = alldevs; d != NULL; d = d->next) {
        char *n2;
+       TCHAR *ss2;
        tc = tcp + cnt;
        if (cnt >= MAX_TOTAL_NET_DEVICES) {
-           write_log ("buffer overflow\n");
+           write_log (L"buffer overflow\n");
            break;
        }
-       write_log ("%s\n- %s\n",
-           d->name, d->description ? d->description : "(no description)");
+       ss = au (d->name);
+       ss2 = d->description ? au (d->description) : L"(no description)";
+       write_log (L"%s\n- %s\n", ss, ss2);
+       xfree (ss2);
+       xfree (ss);
        n2 = d->name;
        if (strlen (n2) <= strlen (PCAP_SRC_IF_STRING)) {
-           write_log ("- corrupt name\n");
+           write_log (L"- corrupt name\n");
            continue;
        }
        fp = pcap_open (d->name, 65536, 0, 0, NULL, errbuf);
        if (!fp) {
-           write_log ("- pcap_open() failed: %s\n", errbuf);
+           ss = au (errbuf);
+           write_log (L"- pcap_open() failed: %s\n", ss);
+           xfree (ss);
            continue;
        }
        val = pcap_datalink (fp);
        pcap_close (fp);
        if (val != DLT_EN10MB) {
-           write_log ("- not an ethernet adapter (%d)\n", val);
+           write_log (L"- not an ethernet adapter (%d)\n", val);
            continue;
        }
 
        lpAdapter = PacketOpenAdapter (n2 + strlen (PCAP_SRC_IF_STRING));
        if (lpAdapter == NULL) {
-           write_log ("- PacketOpenAdapter() failed\n");
+           write_log (L"- PacketOpenAdapter() failed\n");
            continue;
        }
        OidData = calloc(6 + sizeof(PACKET_OID_DATA), 1);
@@ -330,21 +347,21 @@ int uaenet_open_driver (struct netdriverdata *tcp)
            OidData->Oid = OID_802_3_CURRENT_ADDRESS;
            if (PacketRequest (lpAdapter, FALSE, OidData)) {
                memcpy (tc->mac, OidData->Data, 6);
-               write_log ("- MAC %02X:%02X:%02X:%02X:%02X:%02X\n",
+               write_log (L"- MAC %02X:%02X:%02X:%02X:%02X:%02X\n",
                    tc->mac[0], tc->mac[1], tc->mac[2],
                    tc->mac[3], tc->mac[4], tc->mac[5]);
-               write_log ("- mapped as uaenet.device:%d\n", cnt++);
+               write_log (L"- mapped as uaenet.device:%d\n", cnt++);
                tc->active = 1;
                tc->mtu = 1500;
-               tc->name = my_strdup (d->name);
+               tc->name = au (d->name);
            } else {
-               write_log (" - failed to get MAC\n");
+               write_log (L" - failed to get MAC\n");
            }
            free (OidData);
        }
         PacketCloseAdapter (lpAdapter);
     }
-    write_log ("uaenet: end of detection\n");
+    write_log (L"uaenet: end of detection\n");
     pcap_freealldevs(alldevs);
     return 0;
 }
index 66883d8642b209b4a9208f6a296ca9055ef110fd..551b85ab17895b4b48ea5f3ce877957605a97038 100644 (file)
@@ -1,6 +1,6 @@
 struct netdriverdata
 {
-    char *name;
+    TCHAR *name;
     int mtu;
     uae_u8 mac[6];
     int active;
index 33506d783b0b5d157c6036840edd701236c9656d..270122726adf5a29fc0d67489f067bfe5c8b2efc 100644 (file)
@@ -188,14 +188,14 @@ struct MultiDisplay *getdisplay (struct uae_prefs *p)
     i = 0;
     while (Displays[i].name) {
        struct MultiDisplay *md = &Displays[i];
-       if (p->gfx_display_name[0] && !strcmp (md->name, p->gfx_display_name))
+       if (p->gfx_display_name[0] && !_tcscmp (md->name, p->gfx_display_name))
            return md;
-       if (p->gfx_display_name[0] && !strcmp (md->name2, p->gfx_display_name))
+       if (p->gfx_display_name[0] && !_tcscmp (md->name2, p->gfx_display_name))
            return md;
        i++;
     }
     if (i == 0) {
-       gui_message ("no display adapters! Exiting");
+       gui_message (L"no display adapters! Exiting");
        exit (0);
     }
     if (display >= i)
@@ -328,13 +328,13 @@ static int set_ddraw_2 (void)
            }
            if (got == FALSE)
                freq = 0;
-           write_log ("set_ddraw: trying %dx%d, bits=%d, refreshrate=%d\n", width, height, bits, freq);
+           write_log (L"set_ddraw: trying %dx%d, bits=%d, refreshrate=%d\n", width, height, bits, freq);
            ddrval = DirectDraw_SetDisplayMode (width, height, bits, freq);
            if (SUCCEEDED (ddrval))
                break;
            olderr = ddrval;
            if (freq) {
-               write_log ("set_ddraw: failed, trying without forced refresh rate\n");
+               write_log (L"set_ddraw: failed, trying without forced refresh rate\n");
                DirectDraw_SetCooperativeLevel (hAmigaWnd, dxfullscreen, TRUE);
                ddrval = DirectDraw_SetDisplayMode (width, height, bits, 0);
                if (SUCCEEDED (ddrval))
@@ -353,7 +353,7 @@ static int set_ddraw_2 (void)
            goto oops;
        ddrval = DirectDraw_CreateMainSurface (width, height);
        if (FAILED(ddrval)) {
-           write_log ("set_ddraw: couldn't CreateSurface() for primary because %s.\n", DXError (ddrval));
+           write_log (L"set_ddraw: couldn't CreateSurface() for primary because %s.\n", DXError (ddrval));
            goto oops;
        }
        ddrval = DirectDraw_SetClipper (hAmigaWnd);
@@ -367,7 +367,7 @@ static int set_ddraw_2 (void)
            DirectDraw_CreatePalette (currentmode->pal);
     }
 
-    write_log ("set_ddraw: %dx%d@%d-bytes\n", width, height, bits);
+    write_log (L"set_ddraw: %dx%d@%d-bytes\n", width, height, bits);
     return 1;
 oops:
     return 0;
@@ -423,7 +423,7 @@ static HRESULT CALLBACK modesCallback (LPDDSURFACEDESC2 modeDesc, LPVOID context
     md->DisplayModes[i].refresh[1] = 0;
     md->DisplayModes[i].colormodes = ct;
     md->DisplayModes[i + 1].depth = -1;
-    sprintf (md->DisplayModes[i].name, "%dx%d, %d-bit",
+    _stprintf (md->DisplayModes[i].name, L"%dx%d, %d-bit",
        md->DisplayModes[i].res.width, md->DisplayModes[i].res.height, md->DisplayModes[i].depth * 8);
     return DDENUMRET_OK;
 }
@@ -465,28 +465,31 @@ static void modesList (struct MultiDisplay *md)
 
     i = 0;
     while (md->DisplayModes[i].depth >= 0) {
-       write_log ("%d: %s (", i, md->DisplayModes[i].name);
+       write_log (L"%d: %s (", i, md->DisplayModes[i].name);
        j = 0;
        while (md->DisplayModes[i].refresh[j] > 0) {
            if (j > 0)
-               write_log (",");
-           write_log ("%d", md->DisplayModes[i].refresh[j]);
+               write_log (L",");
+           write_log (L"%d", md->DisplayModes[i].refresh[j]);
            j++;
        }
-       write_log (")\n");
+       write_log (L")\n");
        i++;
     }
 }
 
-BOOL CALLBACK displaysCallback (GUID *guid, LPSTR desc, LPSTR name, LPVOID ctx, HMONITOR hm)
+BOOL CALLBACK displaysCallback (GUID *guid, char *adesc, char *aname, LPVOID ctx, HMONITOR hm)
 {
     struct MultiDisplay *md = Displays;
     MONITORINFOEX lpmi;
-    char tmp[200];
+    TCHAR tmp[200];
+    TCHAR *desc = au (adesc);
+    TCHAR *name = au (aname);
+    int ret = 0;
 
     while (md->name) {
        if (md - Displays >= MAX_DISPLAYS)
-           return 0;
+           goto end;
        md++;
     }
     lpmi.cbSize = sizeof (lpmi);
@@ -500,13 +503,17 @@ BOOL CALLBACK displaysCallback (GUID *guid, LPSTR desc, LPSTR name, LPVOID ctx,
     }
     md->rect = lpmi.rcMonitor;
     if (md->rect.left == 0 && md->rect.top == 0)
-        sprintf (tmp, "%s (%d*%d)", desc, md->rect.right - md->rect.left, md->rect.bottom - md->rect.top);
+        _stprintf (tmp, L"%s (%d*%d)", desc, md->rect.right - md->rect.left, md->rect.bottom - md->rect.top);
     else
-        sprintf (tmp, "%s (%d*%d) [%d*%d]", desc, md->rect.right - md->rect.left, md->rect.bottom - md->rect.top, md->rect.left, md->rect.top);
+        _stprintf (tmp, L"%s (%d*%d) [%d*%d]", desc, md->rect.right - md->rect.left, md->rect.bottom - md->rect.top, md->rect.left, md->rect.top);
     md->name = my_strdup (tmp);
     md->name2 = my_strdup (desc);
-    write_log ("'%s' '%s' %s\n", desc, name, outGUID(guid));
-    return 1;
+    write_log (L"'%s' '%s' %s\n", desc, name, outGUID(guid));
+    ret = 1;
+end:
+    xfree (name);
+    xfree (desc);
+    return ret;
 }
 
 static BOOL CALLBACK monitorEnumProc (HMONITOR h, HDC hdc, LPRECT rect, LPARAM data)
@@ -530,9 +537,9 @@ void enumeratedisplays (int multi)
        DirectDraw_EnumDisplays (displaysCallback);
        EnumDisplayMonitors (NULL, NULL, monitorEnumProc, (LPARAM)&cnt);
     } else {
-       write_log ("Multimonitor detection disabled\n");
+       write_log (L"Multimonitor detection disabled\n");
        Displays[0].primary = 1;
-       Displays[0].name = "Display";
+       Displays[0].name = L"Display";
        Displays[0].disabled = 0;
     }
 }
@@ -580,7 +587,7 @@ void sortdisplays (void)
                int w = DirectDraw_CurrentWidth ();
                int h = DirectDraw_CurrentHeight ();
                int b = DirectDraw_GetCurrentDepth ();
-               write_log ("Desktop: W=%d H=%d B=%d. CXVS=%d CYVS=%d\n", w, h, b,
+               write_log (L"Desktop: W=%d H=%d B=%d. CXVS=%d CYVS=%d\n", w, h, b,
                    GetSystemMetrics (SM_CXVIRTUALSCREEN), GetSystemMetrics (SM_CYVIRTUALSCREEN));
                DirectDraw_EnumDisplayModes (DDEDM_REFRESHRATES , modesCallback, md1);
                //dhack();
@@ -594,7 +601,7 @@ void sortdisplays (void)
        i = 0;
        while (md1->DisplayModes[i].depth > 0)
            i++;
-       write_log ("'%s', %d display modes (%s)\n", md1->name, i, md1->disabled ? "disabled" : "enabled");
+       write_log (L"'%s', %d display modes (%s)\n", md1->name, i, md1->disabled ? L"disabled" : L"enabled");
        md1++;
     }
     displayGUID = NULL;
@@ -1025,7 +1032,7 @@ static int open_windows (int full)
     updatewinfsmode (&currprefs);
     if (!DirectDraw_Start (displayGUID))
        return 0;
-    write_log ("DirectDraw GUID=%s\n", outGUID (displayGUID));
+    write_log (L"DirectDraw GUID=%s\n", outGUID (displayGUID));
 
     ret = -2;
     do {
@@ -1073,7 +1080,7 @@ int check_prefs_changed_gfx (void)
     c |= currprefs.gfx_autoresolution != changed_prefs.gfx_autoresolution ? (2|8) : 0;
 
     c |= currprefs.gfx_filter != changed_prefs.gfx_filter ? (2|8) : 0;
-    c |= strcmp (currprefs.gfx_filtershader, changed_prefs.gfx_filtershader) ? (2|8|32) : 0;
+    c |= _tcscmp (currprefs.gfx_filtershader, changed_prefs.gfx_filtershader) ? (2|8|32) : 0;
     c |= currprefs.gfx_filter_filtermode != changed_prefs.gfx_filter_filtermode ? (2|8|32) : 0;
     c |= currprefs.gfx_filter_horiz_zoom_mult != changed_prefs.gfx_filter_horiz_zoom_mult ? (1|8) : 0;
     c |= currprefs.gfx_filter_vert_zoom_mult != changed_prefs.gfx_filter_vert_zoom_mult ? (1|8) : 0;
@@ -1094,7 +1101,7 @@ int check_prefs_changed_gfx (void)
     c |= currprefs.gfx_lores_mode != changed_prefs.gfx_lores_mode ? (2 | 8) : 0;
     c |= currprefs.gfx_scandoubler != changed_prefs.gfx_scandoubler ? (2 | 8) : 0;
     c |= currprefs.gfx_display != changed_prefs.gfx_display ? (2|4|8) : 0;
-    c |= strcmp (currprefs.gfx_display_name, changed_prefs.gfx_display_name) ? (2|4|8) : 0;
+    c |= _tcscmp (currprefs.gfx_display_name, changed_prefs.gfx_display_name) ? (2|4|8) : 0;
     c |= currprefs.gfx_blackerthanblack != changed_prefs.gfx_blackerthanblack ? (2 | 8) : 0;
 
     c |= currprefs.win32_alwaysontop != changed_prefs.win32_alwaysontop ? 32 : 0;
@@ -1134,7 +1141,7 @@ int check_prefs_changed_gfx (void)
        }
 
        currprefs.gfx_filter = changed_prefs.gfx_filter;
-       strcpy (currprefs.gfx_filtershader, changed_prefs.gfx_filtershader);
+       _tcscpy (currprefs.gfx_filtershader, changed_prefs.gfx_filtershader);
        currprefs.gfx_filter_filtermode = changed_prefs.gfx_filter_filtermode;
        currprefs.gfx_filter_horiz_zoom_mult = changed_prefs.gfx_filter_horiz_zoom_mult;
        currprefs.gfx_filter_vert_zoom_mult = changed_prefs.gfx_filter_vert_zoom_mult;
@@ -1156,7 +1163,7 @@ int check_prefs_changed_gfx (void)
        currprefs.gfx_resolution = changed_prefs.gfx_resolution;
        currprefs.gfx_linedbl = changed_prefs.gfx_linedbl;
        currprefs.gfx_display = changed_prefs.gfx_display;
-       strcpy (currprefs.gfx_display_name, changed_prefs.gfx_display_name);
+       _tcscpy (currprefs.gfx_display_name, changed_prefs.gfx_display_name);
        currprefs.gfx_blackerthanblack = changed_prefs.gfx_blackerthanblack;
 
        currprefs.win32_alwaysontop = changed_prefs.win32_alwaysontop;
@@ -1269,25 +1276,25 @@ int check_prefs_changed_gfx (void)
        return 1;
     }
 
-    if (strcmp (currprefs.prtname, changed_prefs.prtname) ||
+    if (_tcscmp (currprefs.prtname, changed_prefs.prtname) ||
        currprefs.parallel_autoflush_time != changed_prefs.parallel_autoflush_time ||
        currprefs.parallel_postscript_emulation != changed_prefs.parallel_postscript_emulation ||
        currprefs.parallel_postscript_detection != changed_prefs.parallel_postscript_detection ||
-       strcmp (currprefs.ghostscript_parameters, changed_prefs.ghostscript_parameters)) {
-       strcpy (currprefs.prtname, changed_prefs.prtname);
+       _tcscmp (currprefs.ghostscript_parameters, changed_prefs.ghostscript_parameters)) {
+       _tcscpy (currprefs.prtname, changed_prefs.prtname);
        currprefs.parallel_autoflush_time = changed_prefs.parallel_autoflush_time;
        currprefs.parallel_postscript_emulation = changed_prefs.parallel_postscript_emulation;
        currprefs.parallel_postscript_detection = changed_prefs.parallel_postscript_detection;
-       strcpy (currprefs.ghostscript_parameters, changed_prefs.ghostscript_parameters);
+       _tcscpy (currprefs.ghostscript_parameters, changed_prefs.ghostscript_parameters);
 #ifdef PARALLEL_PORT
        closeprinter ();
 #endif
     }
-    if (strcmp (currprefs.sername, changed_prefs.sername) ||
+    if (_tcscmp (currprefs.sername, changed_prefs.sername) ||
        currprefs.serial_hwctsrts != changed_prefs.serial_hwctsrts ||
        currprefs.serial_direct != changed_prefs.serial_direct ||
        currprefs.serial_demand != changed_prefs.serial_demand) {
-       strcpy (currprefs.sername, changed_prefs.sername);
+       _tcscpy (currprefs.sername, changed_prefs.sername);
        currprefs.serial_hwctsrts = changed_prefs.serial_hwctsrts;
        currprefs.serial_demand = changed_prefs.serial_demand;
        currprefs.serial_direct = changed_prefs.serial_direct;
@@ -1816,7 +1823,7 @@ static int createnotification (HWND hwnd)
 
     if(!hDevNotify) 
     {
-        write_log ("RegisterDeviceNotification failed: %d\n", GetLastError());
+        write_log (L"RegisterDeviceNotification failed: %d\n", GetLastError());
         return FALSE;
     }
 
@@ -1846,7 +1853,7 @@ static int getbestmode (int nextbest)
     for (; md->DisplayModes[i].depth >= 0; i++) {
        struct PicassoResolution *pr = &md->DisplayModes[i];
        if (pr->res.width >= currentmode->native_width && pr->res.height >= currentmode->native_height) {
-           write_log ("FS: %dx%d -> %dx%d\n", currentmode->native_width, currentmode->native_height,
+           write_log (L"FS: %dx%d -> %dx%d\n", currentmode->native_width, currentmode->native_height,
                pr->res.width, pr->res.height);
            currentmode->native_width = pr->res.width;
            currentmode->native_height = pr->res.height;
@@ -1942,7 +1949,7 @@ static int create_windows_2 (void)
        GetWindowRect (hAmigaWnd, &amigawin_rect);
        if (d3dfs || dxfs)
            SetCursorPos (x + w / 2, y + h / 2);
-       write_log ("window already open\n");
+       write_log (L"window already open\n");
 #ifdef RETROPLATFORM
        rp_set_hwnd (hAmigaWnd);
 #endif
@@ -1964,8 +1971,8 @@ static int create_windows_2 (void)
        int oldx, oldy;
        int first = 2;
 
-       regqueryint (NULL, "MainPosX", &stored_x);
-       regqueryint (NULL, "MainPosY", &stored_y);
+       regqueryint (NULL, L"MainPosX", &stored_x);
+       regqueryint (NULL, L"MainPosY", &stored_y);
 
        while (first) {
            first--;
@@ -1994,7 +2001,7 @@ static int create_windows_2 (void)
            win_y_diff = rc.top - oldy;
 
            if (MonitorFromRect (&rc, MONITOR_DEFAULTTONULL) == NULL) {
-               write_log ("window coordinates are not visible on any monitor, reseting..\n");
+               write_log (L"window coordinates are not visible on any monitor, reseting..\n");
                stored_x = stored_y = 0;
                continue;
            }
@@ -2013,13 +2020,13 @@ static int create_windows_2 (void)
        if (!borderless) {
            RECT rc2;
            hMainWnd = CreateWindowEx (WS_EX_ACCEPTFILES | exstyle | flags,
-               "PCsuxRox", "WinUAE",
+               L"PCsuxRox", L"WinUAE",
                style,
                rc.left, rc.top,
                rc.right - rc.left + 1, rc.bottom - rc.top + 1,
                hhWnd, NULL, hInst, NULL);
            if (!hMainWnd) {
-               write_log ("main window creation failed\n");
+               write_log (L"main window creation failed\n");
                return 0;
            }
            GetWindowRect (hMainWnd, &rc2);
@@ -2054,7 +2061,7 @@ static int create_windows_2 (void)
     if (rp_isactive () && !dxfs && !d3dfs && !fsw) {
        HWND parent = rp_getparent ();
        hAmigaWnd = CreateWindowEx (dxfs || d3dfs ? WS_EX_ACCEPTFILES | WS_EX_TOPMOST : WS_EX_ACCEPTFILES | WS_EX_TOOLWINDOW | (currprefs.win32_alwaysontop ? WS_EX_TOPMOST : 0),
-           "AmigaPowah", "WinUAE",
+           L"AmigaPowah", L"WinUAE",
            WS_POPUP,
            x, y, w, h,
            parent, NULL, hInst, NULL);
@@ -2062,13 +2069,13 @@ static int create_windows_2 (void)
        hAmigaWnd = CreateWindowEx (dxfs || d3dfs ?
            WS_EX_TOPMOST :
            WS_EX_ACCEPTFILES | exstyle | (currprefs.win32_alwaysontop ? WS_EX_TOPMOST : 0),
-           "AmigaPowah", "WinUAE",
+           L"AmigaPowah", L"WinUAE",
            (dxfs || d3dfs ? WS_POPUP : (WS_CLIPCHILDREN | WS_CLIPSIBLINGS | (hMainWnd ? WS_VISIBLE | WS_CHILD : WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_MINIMIZEBOX))),
            x, y, w, h,
            borderless ? NULL : (hMainWnd ? hMainWnd : hhWnd), NULL, hInst, NULL);
     }
     if (!hAmigaWnd) {
-       write_log ("creation of amiga window failed\n");
+       write_log (L"creation of amiga window failed\n");
        close_hwnds();
        return 0;
     }
@@ -2123,7 +2130,7 @@ static int create_windows (void)
 static BOOL doInit (void)
 {
     int fs_warning = -1;
-    char tmpstr[300];
+    TCHAR tmpstr[300];
     RGBFTYPE colortype;
     int tmp_depth;
     int ret = 0;
@@ -2143,13 +2150,13 @@ static BOOL doInit (void)
            currentmode->native_height = rc.bottom - rc.top;
        }
 
-       write_log ("W=%d H=%d B=%d CT=%d\n",
+       write_log (L"W=%d H=%d B=%d CT=%d\n",
            DirectDraw_CurrentWidth (), DirectDraw_CurrentHeight (), DirectDraw_GetCurrentDepth (), colortype);
 
        if (currentmode->current_depth < 15 && (currprefs.chipset_mask & CSMASK_AGA) && isfullscreen () > 0 && !WIN32GFX_IsPicassoScreen()) {
            static int warned;
            if (!warned) {
-               char szMessage[MAX_DPATH];
+               TCHAR szMessage[MAX_DPATH];
                currentmode->current_depth = 16;
                WIN32GUI_LoadUIString(IDS_AGA8BIT, szMessage, MAX_DPATH);
                gui_message(szMessage);
@@ -2175,12 +2182,12 @@ static BOOL doInit (void)
                fs_warning = IDS_UNSUPPORTEDSCREENMODE_3;
        }
        if (fs_warning >= 0 && isfullscreen () <= 0) {
-           char szMessage[MAX_DPATH], szMessage2[MAX_DPATH];
+           TCHAR szMessage[MAX_DPATH], szMessage2[MAX_DPATH];
            WIN32GUI_LoadUIString(IDS_UNSUPPORTEDSCREENMODE, szMessage, MAX_DPATH);
            WIN32GUI_LoadUIString(fs_warning, szMessage2, MAX_DPATH);
            // Temporarily drop the DirectDraw stuff
            DirectDraw_Release ();
-           sprintf (tmpstr, szMessage, szMessage2);
+           _stprintf (tmpstr, szMessage, szMessage2);
            gui_message (tmpstr);
            DirectDraw_Start (displayGUID);
            if (screen_is_picasso)
@@ -2311,7 +2318,7 @@ static BOOL doInit (void)
     }
 #if defined OPENGL
     if (currentmode->flags & DM_OPENGL) {
-       const char *err = OGL_init (hAmigaWnd, currentmode->native_width, currentmode->native_height,
+       const TCHAR *err = OGL_init (hAmigaWnd, currentmode->native_width, currentmode->native_height,
            currentmode->amiga_width, currentmode->amiga_height, currentmode->current_depth);
        if (err) {
            OGL_free ();
@@ -2328,7 +2335,7 @@ static BOOL doInit (void)
 #endif
 #ifdef D3D
     if (currentmode->flags & DM_D3D) {
-       const char *err = D3D_init (hAmigaWnd, currentmode->native_width, currentmode->native_height,
+       const TCHAR *err = D3D_init (hAmigaWnd, currentmode->native_width, currentmode->native_height,
            currentmode->amiga_width, currentmode->amiga_height, currentmode->current_depth);
        if (err) {
            D3D_free ();
index 0c2d4c754c57f0ba7253bbb2724542e1cf2edaf1..d48ddbec27ab36961d528338a3be0379afc68ad3 100644 (file)
 #include "rp.h"
 #include "statusline.h"
 
-#define ARCHIVE_STRING "*.zip;*.7z;*.rar;*.lha;*.lzh;*.lzx"
+#define ARCHIVE_STRING L"*.zip;*.7z;*.rar;*.lha;*.lzh;*.lzx"
 
-#define DISK_FORMAT_STRING "(*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.exe)\0*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.exe;*.ima;*.wrp;*.dsq;" ARCHIVE_STRING "\0"
-#define ROM_FORMAT_STRING "(*.rom;*.roz)\0*.rom;*.roz;" ARCHIVE_STRING "\0"
-#define USS_FORMAT_STRING_RESTORE "(*.uss)\0*.uss;*.gz;"  ARCHIVE_STRING "\0"
-#define USS_FORMAT_STRING_SAVE "(*.uss)\0*.uss\0"
-#define HDF_FORMAT_STRING "(*.hdf;*.rdf;*.hdz;*.rdz)\0*.hdf;*.rdf;*.hdz;*.rdz\0"
-#define INP_FORMAT_STRING "(*.inp)\0*.inp\0"
-#define CONFIG_HOST "Host"
-#define CONFIG_HARDWARE "Hardware"
+#define DISK_FORMAT_STRING L"(*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.exe)\0*.adf;*.adz;*.gz;*.dms;*.fdi;*.ipf;*.exe;*.ima;*.wrp;*.dsq;" ARCHIVE_STRING L"\0"
+#define ROM_FORMAT_STRING L"(*.rom;*.roz)\0*.rom;*.roz;" ARCHIVE_STRING L"\0"
+#define USS_FORMAT_STRING_RESTORE L"(*.uss)\0*.uss;*.gz;"  ARCHIVE_STRING L"\0"
+#define USS_FORMAT_STRING_SAVE L"(*.uss)\0*.uss\0"
+#define HDF_FORMAT_STRING L"(*.hdf;*.rdf;*.hdz;*.rdz)\0*.hdf;*.rdf;*.hdz;*.rdz\0"
+#define INP_FORMAT_STRING L"(*.inp)\0*.inp\0"
+#define CONFIG_HOST L"Host"
+#define CONFIG_HARDWARE L"Hardware"
 
-static char szNone[MAX_DPATH];
+static TCHAR szNone[MAX_DPATH];
 
 static int allow_quit;
 static int restart_requested;
@@ -107,28 +107,28 @@ static int qs_request_reset;
 static int qs_override;
 int gui_active;
 
-extern HWND (WINAPI *pHtmlHelp)(HWND, LPCSTR, UINT, LPDWORD);
+extern HWND (WINAPI *pHtmlHelp)(HWND, LPCWSTR, UINT, LPDWORD);
 
 #undef HtmlHelp
 #ifndef HH_DISPLAY_TOPIC
 #define HH_DISPLAY_TOPIC 0
 #endif
 #define HtmlHelp(a,b,c,d) if(pHtmlHelp) (*pHtmlHelp)(a,b,c,(LPDWORD)d); else \
-{ char szMessage[MAX_DPATH]; WIN32GUI_LoadUIString(IDS_NOHELP, szMessage, MAX_DPATH); gui_message(szMessage); }
+{ TCHAR szMessage[MAX_DPATH]; WIN32GUI_LoadUIString (IDS_NOHELP, szMessage, MAX_DPATH); gui_message (szMessage); }
 
-extern char help_file[MAX_DPATH];
+extern TCHAR help_file[MAX_DPATH];
 
 extern int mouseactive;
 
-char config_filename[MAX_DPATH] = "";
-static char stored_path[MAX_DPATH];
+TCHAR config_filename[MAX_DPATH] = L"";
+static TCHAR stored_path[MAX_DPATH];
 
-#define Error(x) MessageBox(NULL, (x), "WinUAE Error", MB_OK)
+#define Error(x) MessageBox (NULL, (x), L"WinUAE Error", MB_OK)
 
-void WIN32GUI_LoadUIString(DWORD id, char *string, DWORD dwStringLen)
+void WIN32GUI_LoadUIString (DWORD id, TCHAR *string, DWORD dwStringLen)
 {
-    if (LoadString(hUIDLL ? hUIDLL : hInst, id, string, dwStringLen) == 0)
-       LoadString(hInst, id, string, dwStringLen);
+    if (LoadString (hUIDLL ? hUIDLL : hInst, id, string, dwStringLen) == 0)
+       LoadString (hInst, id, string, dwStringLen);
 }
 
 static int C_PAGES;
@@ -158,36 +158,9 @@ static void ew (HWND hDlg, DWORD id, int enable)
     EnableWindow (w, !!enable);
 }
 
-static char *ua (const WCHAR *s)
-{
-    char *d;
-    int len;
-
-    if (s == NULL)
-       return NULL;
-    len = WideCharToMultiByte (CP_ACP, 0, s, -1, NULL, 0, 0, FALSE);
-    if (!len)
-       return my_strdup ("");
-    d = xmalloc (len + 1);
-    WideCharToMultiByte (CP_ACP, 0, s, -1, d, len, 0, FALSE);
-    return d;
-}
-static WCHAR *au (const char *s)
-{
-    WCHAR *d;
-    int len = MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, s, -1, NULL, 0);
-    if (!len)
-       return xcalloc (2, 1);
-    d = xmalloc ((len + 1) * sizeof (WCHAR));
-    MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, s, -1, d, len);
-    return d;
-}
-
-
-
 static int CALLBACK BrowseForFolderCallback (HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
 {
-    char szPath[MAX_PATH];
+    TCHAR szPath[MAX_PATH];
     switch(uMsg)
     {
        case BFFM_INITIALIZED:
@@ -204,8 +177,8 @@ static int DirectorySelection2 (OPENFILENAME *ofn)
 {
     BROWSEINFO bi;
     LPITEMIDLIST pidlBrowse;
-    char buf[MAX_DPATH], fullpath[MAX_DPATH];
-    char *path = ofn->lpstrFile;
+    TCHAR buf[MAX_DPATH], fullpath[MAX_DPATH];
+    TCHAR *path = ofn->lpstrFile;
     int ret = 0;
 
     buf[0] = 0;
@@ -215,7 +188,7 @@ static int DirectorySelection2 (OPENFILENAME *ofn)
     bi.pszDisplayName = buf;
     bi.lpszTitle = NULL;
     bi.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
-    if (path[0] && GetFullPathName (path, sizeof fullpath, fullpath, NULL)) {
+    if (path[0] && GetFullPathName (path, sizeof fullpath / sizeof (TCHAR), fullpath, NULL)) {
        bi.lpfn = BrowseForFolderCallback;
        bi.lParam = (LPARAM)fullpath;
     }
@@ -223,7 +196,7 @@ static int DirectorySelection2 (OPENFILENAME *ofn)
     pidlBrowse = SHBrowseForFolder (&bi);
     if (pidlBrowse != NULL) {
        if (SHGetPathFromIDList (pidlBrowse, buf)) {
-           strcpy (path, buf);
+           _tcscpy (path, buf);
            ret = 1;
        }
        CoTaskMemFree (pidlBrowse);
@@ -231,9 +204,9 @@ static int DirectorySelection2 (OPENFILENAME *ofn)
     return ret;
 }
 
-static char *getfilepath (char *s)
+static TCHAR *getfilepath (TCHAR *s)
 {
-    char *p = strrchr (s, '\\');
+    TCHAR *p = _tcsrchr (s, '\\');
     if (p)
        return p + 1;
     return NULL;
@@ -246,9 +219,6 @@ typedef HRESULT (CALLBACK* SHCREATEITEMFROMPARSINGNAME)
 static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
 {
     SHCREATEITEMFROMPARSINGNAME pSHCreateItemFromParsingName;
-    WCHAR *title = NULL;
-    WCHAR *defext = NULL;
-    WCHAR *initialdir = NULL;
     HRESULT hr;
     IFileOpenDialog *pfd;
     FILEOPENDIALOGOPTIONS pfos;
@@ -260,7 +230,7 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
     hr = -1;
     ret = 0;
     pSHCreateItemFromParsingName = (SHCREATEITEMFROMPARSINGNAME)GetProcAddress (
-       GetModuleHandle ("shell32.dll"), "SHCreateItemFromParsingName");
+       GetModuleHandle (L"shell32.dll"), "SHCreateItemFromParsingName");
     if (pSHCreateItemFromParsingName)
        hr = CoCreateInstance (mode > 0 ? &CLSID_FileSaveDialog : &CLSID_FileOpenDialog, 
                                   NULL, 
@@ -286,21 +256,21 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
        IFileDialog_SetClientGuid (pfd, guid);
 
     if (opn->lpstrFilter) {
-       const char *p = opn->lpstrFilter;
+       const TCHAR *p = opn->lpstrFilter;
        int i;
        while (*p) {
-           p += strlen (p) + 1;
-           p += strlen (p) + 1;
+           p += _tcslen (p) + 1;
+           p += _tcslen (p) + 1;
            filtercnt++;
        }
        if (filtercnt) {
            fs = xmalloc (sizeof (COMDLG_FILTERSPEC) * filtercnt);
            p = opn->lpstrFilter;
            for (i = 0; i < filtercnt; i++) {
-               fs[i].pszName = au (p);
-               p += strlen (p) + 1;
-               fs[i].pszSpec = au (p);
-               p += strlen (p) + 1;
+               fs[i].pszName = p;
+               p += _tcslen (p) + 1;
+               fs[i].pszSpec = p;
+               p += _tcslen (p) + 1;
            }
            IFileDialog_SetFileTypes (pfd, filtercnt, fs);
        }
@@ -308,20 +278,17 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
     }
 
     if (opn->lpstrTitle) {
-       title = au (opn->lpstrTitle);
-       IFileDialog_SetTitle (pfd, title);
+       IFileDialog_SetTitle (pfd, opn->lpstrTitle);
     }
     if (opn->lpstrDefExt) {
-       defext = au (opn->lpstrDefExt);
-       IFileDialog_SetDefaultExtension (pfd, defext);
+       IFileDialog_SetDefaultExtension (pfd, opn->lpstrDefExt);
     }
     if (opn->lpstrInitialDir) {
-       char tmp[MAX_DPATH];
-       const char *p = opn->lpstrInitialDir;
-       if (GetFullPathName (p, sizeof tmp, tmp, NULL)) 
+       TCHAR tmp[MAX_DPATH];
+       const TCHAR *p = opn->lpstrInitialDir;
+       if (GetFullPathName (p, sizeof tmp / sizeof (TCHAR), tmp, NULL)) 
            p = tmp;
-       initialdir = au (p);
-       hr = pSHCreateItemFromParsingName (initialdir, NULL, &IID_IShellItem, &shellitem);
+       hr = pSHCreateItemFromParsingName (p, NULL, &IID_IShellItem, &shellitem);
        if (SUCCEEDED (hr))
            IFileDialog_SetFolder (pfd, shellitem);
     }
@@ -341,14 +308,12 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
                WCHAR *path = NULL;
                hr = IShellItem_GetDisplayName (pitem, SIGDN_FILESYSPATH, &path);
                if (SUCCEEDED (hr)) {
-                   char *spath = ua (path);
-                   char *p = opn->lpstrFile;
-                   strcpy (p, spath);
-                   p[strlen (p) + 1] = 0;
-                   xfree (spath);
+                   TCHAR *p = opn->lpstrFile;
+                   _tcscpy (p, path);
+                   p[_tcslen (p) + 1] = 0;
                    p = getfilepath (opn->lpstrFile);
                    if (p && opn->lpstrFileTitle)
-                       strcpy (opn->lpstrFileTitle, p);
+                       _tcscpy (opn->lpstrFileTitle, p);
                }
                IShellItem_Release (pitem);
            }
@@ -366,19 +331,17 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
                            WCHAR *path = NULL;
                            hr = IShellItem_GetDisplayName (pitem, SIGDN_FILESYSPATH, &path);
                            if (SUCCEEDED (hr)) {
-                               char *spath = ua (path);
-                               char *p = opn->lpstrFile;
+                               TCHAR *p = opn->lpstrFile;
                                while (*p)
-                                   p += strlen (p) + 1;
-                               if (p - opn->lpstrFile + strlen (spath) + 2 < opn->nMaxFile) {
-                                   strcpy (p, spath);
-                                   p[strlen (p) + 1] = 0;
+                                   p += _tcslen (p) + 1;
+                               if (p - opn->lpstrFile + _tcslen (path) + 2 < opn->nMaxFile) {
+                                   _tcscpy (p, path);
+                                   p[_tcslen (p) + 1] = 0;
                                }
-                               xfree (spath);
                                if (opn->lpstrFileTitle && !opn->lpstrFileTitle[0]) {
                                    p = getfilepath (opn->lpstrFile);
                                    if (p && opn->lpstrFileTitle)
-                                       strcpy (opn->lpstrFileTitle, p);
+                                       _tcscpy (opn->lpstrFileTitle, p);
                                }
                            }
                            CoTaskMemFree (path);
@@ -399,16 +362,8 @@ static BOOL GetFileDialog (OPENFILENAME *opn, const GUID *guid, int mode)
     if (shellitem)
        IShellItem_Release (shellitem);
     if (filtercnt) {
-       int i;
-        for (i = 0; i < filtercnt; i++) {
-           xfree (fs[i].pszName);
-           xfree (fs[i].pszSpec);
-       }
        xfree (fs);
     }
-    xfree (title);
-    xfree (defext);
-    xfree (initialdir);
     return ret;
 }
 
@@ -420,7 +375,7 @@ static BOOL GetSaveFileName_2 (OPENFILENAME *opn, const GUID *guid)
 {
     return GetFileDialog (opn, guid, 1);
 }
-int DirectorySelection (HWND hDlg, const GUID *guid, char *path)
+int DirectorySelection (HWND hDlg, const GUID *guid, TCHAR *path)
 {
     OPENFILENAME ofn = { 0 };
     ofn.hwndOwner = hDlg;
@@ -433,24 +388,24 @@ int DirectorySelection (HWND hDlg, const GUID *guid, char *path)
 void write_disk_history (void)
 {
     int i, j;
-    char tmp[16];
+    TCHAR tmp[16];
     UAEREG *fkey;
 
-    fkey = regcreatetree (NULL, "DiskImageMRUList");
+    fkey = regcreatetree (NULL, L"DiskImageMRUList");
     if (fkey == NULL)
        return;
     j = 1;
     for (i = 0; i <= MAX_PREVIOUS_FLOPPIES; i++) {
-       char *s = DISK_history_get (i);
-       if (s == 0 || strlen(s) == 0)
+       TCHAR *s = DISK_history_get (i);
+       if (s == 0 || _tcslen (s) == 0)
            continue;
-       sprintf (tmp, "Image%02d", j);
+       _stprintf (tmp, L"Image%02d", j);
        regsetstr (fkey, tmp, s);
        j++;
    }
     while (j <= MAX_PREVIOUS_FLOPPIES) {
-       char *s = "";
-       sprintf (tmp, "Image%02d", j);
+       TCHAR *s = L"";
+       _stprintf (tmp, L"Image%02d", j);
        regsetstr (fkey, tmp, s);
        j++;
     }
@@ -469,25 +424,25 @@ void reset_disk_history (void)
 UAEREG *read_disk_history (void)
 {
     static int regread;
-    char tmp2[1000];
+    TCHAR tmp2[1000];
     DWORD size2;
     int idx, idx2;
     UAEREG *fkey;
-    char tmp[1000];
+    TCHAR tmp[1000];
     DWORD size;
 
-    fkey = regcreatetree (NULL, "DiskImageMRUList");
+    fkey = regcreatetree (NULL, L"DiskImageMRUList");
     if (fkey == NULL || regread)
        return fkey;
 
     idx = 0;
     for (;;) {
-       size = sizeof (tmp);
-       size2 = sizeof (tmp2);
+       size = sizeof (tmp) / sizeof (TCHAR);
+       size2 = sizeof (tmp2) / sizeof (TCHAR);
        if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2))
            break;
-       if (strlen (tmp) == 7) {
-           idx2 = atol (tmp + 5) - 1;
+       if (_tcslen (tmp) == 7) {
+           idx2 = _tstol (tmp + 5) - 1;
            if (idx2 >= 0)
                DISK_history_add (tmp2, idx2);
        }
@@ -506,7 +461,7 @@ void exit_gui (int ok)
     SendMessage (guiDlg, WM_COMMAND, ok ? IDOK : IDCANCEL, 0);
 }
 
-static int getcbn (HWND hDlg, int v, char *out, int len)
+static int getcbn (HWND hDlg, int v, TCHAR *out, int len)
 {
     LRESULT val = SendDlgItemMessage (hDlg, v, CB_GETCURSEL, 0, 0L);
     out[0] = 0;
@@ -520,29 +475,29 @@ static int getcbn (HWND hDlg, int v, char *out, int len)
 }
 
 #define MAXFAVORITES 30
-static void writefavoritepaths (int num, char **values, char **paths)
+static void writefavoritepaths (int num, TCHAR **values, TCHAR **paths)
 {
     int i;
     UAEREG *fkey;
 
-    fkey = regcreatetree (NULL, "FavoritePaths");
+    fkey = regcreatetree (NULL, L"FavoritePaths");
     if (fkey == NULL)
        return;
     for (i = 0; i < num; i++) {
-       char str[MAX_DPATH];
-       char key[100];
-       if (!strcmp (values[i], paths[i]))
-           strcpy (str, values[i]);
+       TCHAR str[MAX_DPATH];
+       TCHAR key[100];
+       if (!_tcscmp (values[i], paths[i]))
+           _tcscpy (str, values[i]);
        else
-           sprintf (str, "%s \"%s\"", values[i], paths[i]);
-       sprintf (key, "PATH_ALL_%02d", i + 1);
+           _stprintf (str, L"%s \"%s\"", values[i], paths[i]);
+       _stprintf (key, L"PATH_ALL_%02d", i + 1);
        regsetstr (fkey, key, str);
        xfree (values[i]);
        xfree (paths[i]);
     }
     while (i < MAXFAVORITES) {
-       char key[100];
-       sprintf (key, "PATH_ALL_%02d", i + 1);
+       TCHAR key[100];
+       _stprintf (key, L"PATH_ALL_%02d", i + 1);
        regdelete (fkey, key);
        i++;
     }
@@ -550,10 +505,10 @@ static void writefavoritepaths (int num, char **values, char **paths)
 }
 
 
-static int askinputcustom (HWND hDlg, char *custom, int maxlen, DWORD titleid);
-static int addfavoritepath (HWND hDlg, int num, char **values, char **paths)
+static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid);
+static int addfavoritepath (HWND hDlg, int num, TCHAR **values, TCHAR **paths)
 {
-    char name[MAX_DPATH];
+    TCHAR name[MAX_DPATH];
     const GUID favoriteguid = 
     { 0xed6e5ad9, 0xc0aa, 0x42fb, { 0x83, 0x3, 0x37, 0x41, 0x77, 0xb4, 0x6f, 0x18 } };
 
@@ -563,14 +518,14 @@ static int addfavoritepath (HWND hDlg, int num, char **values, char **paths)
         GetModuleFileName (NULL, stored_path, MAX_DPATH);
     while (stored_path[0]) {
        DWORD v = GetFileAttributes (stored_path);
-       char *s;
+       TCHAR *s;
        if (v == INVALID_FILE_ATTRIBUTES)
            break;
        if (v & FILE_ATTRIBUTE_DIRECTORY)
            break;
-       s = strrchr (stored_path, '\\');
+       s = _tcsrchr (stored_path, '\\');
        if (!s)
-           s = strrchr (stored_path, '/');
+           s = _tcsrchr (stored_path, '/');
        if (!s) {
            stored_path[0] = 0;
            break;
@@ -579,8 +534,8 @@ static int addfavoritepath (HWND hDlg, int num, char **values, char **paths)
     }
     if (!DirectorySelection (hDlg, &favoriteguid, stored_path))
        return 0;
-    strcpy (name, stored_path);
-    if (askinputcustom (hDlg, name, sizeof name, IDS_SB_FAVORITENAME)) {
+    _tcscpy (name, stored_path);
+    if (askinputcustom (hDlg, name, sizeof name / sizeof (TCHAR), IDS_SB_FAVORITENAME)) {
        values[num] = my_strdup (name);
        paths[num] = my_strdup (stored_path);
        num++;
@@ -588,7 +543,7 @@ static int addfavoritepath (HWND hDlg, int num, char **values, char **paths)
     }
     return 1;
 }
-static void removefavoritepath (int idx, int num, char **values, char **paths)
+static void removefavoritepath (int idx, int num, TCHAR **values, TCHAR **paths)
 {
     int i;
 
@@ -603,11 +558,11 @@ static void removefavoritepath (int idx, int num, char **values, char **paths)
     writefavoritepaths (num, values, paths);
 }
 
-static void addeditmenu (HMENU menu, char **items)
+static void addeditmenu (HMENU menu, TCHAR **items)
 {
     int i;
     HMENU emenu = CreatePopupMenu ();
-    char newpath[MAX_DPATH];
+    TCHAR newpath[MAX_DPATH];
 
     MENUITEMINFO mii = { 0 };
     mii.cbSize = sizeof mii;
@@ -620,8 +575,8 @@ static void addeditmenu (HMENU menu, char **items)
     mii.fMask = MIIM_STRING | MIIM_ID;
     mii.fType = MFT_STRING;
     mii.fState = MFS_ENABLED;
-    mii.dwTypeData = "Add New";
-    mii.cch = strlen (mii.dwTypeData);
+    mii.dwTypeData = L"Add New";
+    mii.cch = _tcslen (mii.dwTypeData);
     mii.wID = 1000;
     InsertMenuItem (emenu, -1, TRUE, &mii);
     i = 0;
@@ -630,9 +585,9 @@ static void addeditmenu (HMENU menu, char **items)
        mii.fType = MFT_STRING;
        mii.fState = MFS_ENABLED;
        mii.wID = 1001 + i;
-       sprintf (newpath, "Remove '%s'", items[i]);
+       _stprintf (newpath, L"Remove '%s'", items[i]);
        mii.dwTypeData = newpath;
-       mii.cch = strlen (mii.dwTypeData);
+       mii.cch = _tcslen (mii.dwTypeData);
        InsertMenuItem (emenu, -1, TRUE, &mii);
        i++;
     }
@@ -640,13 +595,13 @@ static void addeditmenu (HMENU menu, char **items)
     mii.fMask = MIIM_STRING | MIIM_SUBMENU;
     mii.fType = MFT_STRING;
     mii.fState = MFS_ENABLED;
-    mii.dwTypeData = "Edit";
-    mii.cch = strlen (mii.dwTypeData);
+    mii.dwTypeData = L"Edit";
+    mii.cch = _tcslen (mii.dwTypeData);
     mii.hSubMenu = emenu;
     InsertMenuItem (menu, -1, TRUE, &mii);
 }
 
-static int popupmenu (HWND hwnd, char **items)
+static int popupmenu (HWND hwnd, TCHAR **items)
 {
     int i, item;
     HMENU menu;
@@ -662,7 +617,7 @@ static int popupmenu (HWND hwnd, char **items)
         mii.fState = MFS_ENABLED;
         mii.wID = 1 + i;
         mii.dwTypeData = items[i];
-        mii.cch = strlen (mii.dwTypeData);
+        mii.cch = _tcslen (mii.dwTypeData);
         InsertMenuItem (menu, -1, TRUE, &mii);
         i++;
     }
@@ -674,39 +629,39 @@ static int popupmenu (HWND hwnd, char **items)
     DestroyMenu (menu);
     return item;
 }
-static char *favoritepopup (HWND hwnd)
+static TCHAR *favoritepopup (HWND hwnd)
 {
     UAEREG *fkey;
     int idx, idx2;
-    char *values[MAXFAVORITES + 1];
-    char *paths[MAXFAVORITES + 1];
+    TCHAR *values[MAXFAVORITES + 1];
+    TCHAR *paths[MAXFAVORITES + 1];
     int ret, i, j, num;
 
     for (;;) {
-       fkey = regcreatetree (NULL, "FavoritePaths");
+       fkey = regcreatetree (NULL, L"FavoritePaths");
        if (fkey == NULL)
            return NULL;
        idx = 0;
        num = 0;
        for (;;) {
-           char *p;
+           TCHAR *p;
            DWORD size, size2;
-           char tmp[1000], tmp2[1000];
-           size = sizeof (tmp);
-           size2 = sizeof (tmp2);
+           TCHAR tmp[1000], tmp2[1000];
+           size = sizeof (tmp) / sizeof (TCHAR);
+           size2 = sizeof (tmp2) / sizeof (TCHAR);
            if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2))
                break;
-           p = strrchr (tmp, '_');
+           p = _tcsrchr (tmp, '_');
            if (p) {
-               idx2 = atol (p + 1);
+               idx2 = _tstol (p + 1);
                if (idx2 > 0 && idx2 < MAXFAVORITES) {
-                   char *p2 = strchr (tmp2, '"');
-                   char *str, *fname;
+                   TCHAR *p2 = _tcschr (tmp2, '"');
+                   TCHAR *str, *fname;
                    idx2--;
                    if (p2) {
                        fname = my_strdup (p2 + 1);
                        p2[0] = 0;
-                       p2 = strchr (fname, '"');
+                       p2 = _tcschr (fname, '"');
                        if (p2)
                            *p2 = 0;
                        str = my_strdup (tmp2);
@@ -723,8 +678,8 @@ static char *favoritepopup (HWND hwnd)
        regclosetree (fkey);
        for (i = 0; i < idx; i++) {
            for (j = i + 1; j < idx; j++) {
-               if (strcmp (values[i], values[j]) > 0) {
-                   char *tmp = values[i];
+               if (_tcscmp (values[i], values[j]) > 0) {
+                   TCHAR *tmp = values[i];
                    values[i] = values[j];
                    values[j] = tmp;
                    tmp = paths[i];
@@ -923,15 +878,15 @@ static struct romdata *scan_single_rom_2 (struct zfile *f)
     size = zfile_ftell (f);
     zfile_fseek (f, 0, SEEK_SET);
     if (size > 524288 * 2)  {/* don't skip KICK disks or 1M ROMs */
-       write_log ("'%s': too big %d, ignored\n", zfile_getname(f), size);
+       write_log (L"'%s': too big %d, ignored\n", zfile_getname(f), size);
        return 0;
     }
     zfile_fread (buffer, 1, 11, f);
-    if (!memcmp (buffer, "KICK", 4)) {
+    if (!memcmp (buffer, L"KICK", 4)) {
        zfile_fseek (f, 512, SEEK_SET);
        if (size > 262144)
            size = 262144;
-    } else if (!memcmp (buffer, "AMIROMTYPE1", 11)) {
+    } else if (!memcmp (buffer, L"AMIROMTYPE1", 11)) {
        cl = 1;
        size -= 11;
     } else {
@@ -959,92 +914,92 @@ static struct romdata *scan_single_rom_2 (struct zfile *f)
        }
     }
     if (!rd) {
-       write_log ("!: Name='%s':%d\nCRC32=%08X SHA1=%s\n",
+       write_log (L"!: Name='%s':%d\nCRC32=%08X SHA1=%s\n",
           zfile_getname(f), size, get_crc32(rombuf, size), get_sha1_txt(rombuf, size));
     } else {
-       char tmp[MAX_DPATH];
+       TCHAR tmp[MAX_DPATH];
        getromname (rd, tmp);
-       write_log ("*: %s:%d = %s\nCRC32=%08X SHA1=%s\n",
+       write_log (L"*: %s:%d = %s\nCRC32=%08X SHA1=%s\n",
           zfile_getname(f), size, tmp, get_crc32(rombuf, size), get_sha1_txt(rombuf, size));
     }
     xfree (rombuf);
     return rd;
 }
 
-static struct romdata *scan_single_rom (char *path)
+static struct romdata *scan_single_rom (TCHAR *path)
 {
     struct zfile *z;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     struct romdata *rd;
 
-    strcpy (tmp, path);
+    _tcscpy (tmp, path);
     rd = scan_arcadia_rom (tmp, 0);
     if (rd)
        return rd;
     rd = getromdatabypath (path);
     if (rd && rd->crc32 == 0xffffffff)
        return rd;
-    z = zfile_fopen (path, "rb");
+    z = zfile_fopen (path, L"rb");
     if (!z)
        return 0;
     return scan_single_rom_2 (z);
 }
 
-static void abspathtorelative (char *name)
+static void abspathtorelative (TCHAR *name)
 {
-    if (!strnicmp (start_path_exe, name, strlen (start_path_exe)))
-       memmove (name, name + strlen (start_path_exe), strlen (name) - strlen (start_path_exe) + 1);
+    if (!_tcsncmp (start_path_exe, name, _tcslen (start_path_exe)))
+       memmove (name, name + _tcslen (start_path_exe), (_tcslen (name) - _tcslen (start_path_exe) + 1) * sizeof (TCHAR));
 }
 
-static int addrom (UAEREG *fkey, struct romdata *rd, char *name)
+static int addrom (UAEREG *fkey, struct romdata *rd, TCHAR *name)
 {
-    char tmp1[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
 
-    sprintf (tmp1, "ROM_%03d", rd->id);
+    _stprintf (tmp1, L"ROM_%03d", rd->id);
     if (rd->group) {
-       char *p = tmp1 + strlen (tmp1);
-       sprintf (p, "_%02d_%02d", rd->group >> 16, rd->group & 65535);
+       TCHAR *p = tmp1 + _tcslen (tmp1);
+       _stprintf (p, L"_%02d_%02d", rd->group >> 16, rd->group & 65535);
     }
     if (regexists (fkey, tmp1))
        return 0;
     getromname (rd, tmp2);
     if (name) {
-       strcat (tmp2, " / \"");
+       _tcscat (tmp2, L" / \"");
        if (getregmode ())
            abspathtorelative (name);
-       strcat (tmp2, name);
-       strcat (tmp2, "\"");
+       _tcscat (tmp2, name);
+       _tcscat (tmp2, L"\"");
     }
     if (rd->crc32 == 0xffffffff) {
        if (rd->configname)
-           sprintf(tmp2, ":%s", rd->configname);
+           _stprintf (tmp2, L":%s", rd->configname);
        else
-           sprintf(tmp2, ":ROM_%03d", rd->id);
+           _stprintf (tmp2, L":ROM_%03d", rd->id);
     }
     if (!regsetstr (fkey, tmp1, tmp2))
        return 0;
     return 1;
 }
 
-static int isromext (char *path)
+static int isromext (TCHAR *path)
 {
-    char *ext;
+    TCHAR *ext;
     int i;
 
     if (!path)
        return 0;
-    ext = strrchr (path, '.');
+    ext = _tcsrchr (path, '.');
     if (!ext)
        return 0;
     ext++;
 
-    if (!stricmp (ext, "rom") ||  !stricmp (ext, "adf") || !stricmp (ext, "key")
-       || !stricmp (ext, "a500") || !stricmp (ext, "a1200") || !stricmp (ext, "a4000"))
+    if (!_tcsicmp (ext, L"rom") ||  !_tcsicmp (ext, L"adf") || !_tcsicmp (ext, L"key")
+       || !_tcsicmp (ext, L"a500") || !_tcsicmp (ext, L"a1200") || !_tcsicmp (ext, L"a4000"))
            return 1;
-    if (strlen (ext) >= 2 && toupper(ext[0]) == 'U' && isdigit (ext[1]))
+    if (_tcslen (ext) >= 2 && toupper(ext[0]) == 'U' && isdigit (ext[1]))
        return 1;
     for (i = 0; uae_archive_extensions[i]; i++) {
-       if (!stricmp (ext, uae_archive_extensions[i]))
+       if (!_tcsicmp (ext, uae_archive_extensions[i]))
            return 1;
     }
     return 0;
@@ -1052,7 +1007,7 @@ static int isromext (char *path)
 
 static int scan_rom_2 (struct zfile *f, struct romscandata *rsd)
 {
-    char *path = zfile_getname(f);
+    TCHAR *path = zfile_getname(f);
     struct romdata *rd;
 
     if (!isromext(path))
@@ -1065,7 +1020,7 @@ static int scan_rom_2 (struct zfile *f, struct romscandata *rsd)
     return 0;
 }
 
-static int scan_rom (char *path, UAEREG *fkey)
+static int scan_rom (TCHAR *path, UAEREG *fkey)
 {
     struct romscandata rsd = { fkey, 0 };
     struct romdata *rd;
@@ -1076,8 +1031,8 @@ static int scan_rom (char *path, UAEREG *fkey)
        return 0;
     }
     for (;;) {
-       char tmp[MAX_DPATH];
-       strcpy (tmp, path);
+       TCHAR tmp[MAX_DPATH];
+       _tcscpy (tmp, path);
        rd = scan_arcadia_rom (tmp, cnt++);
        if (rd) {
            if (!addrom (fkey, rd, tmp))
@@ -1106,9 +1061,9 @@ static int listrom (int *roms)
 
 static void show_rom_list (void)
 {
-    char *p;
-    char unavail[MAX_DPATH], avail[MAX_DPATH];
-    char *p1, *p2;
+    TCHAR *p;
+    TCHAR unavail[MAX_DPATH], avail[MAX_DPATH];
+    TCHAR *p1, *p2;
     int *rp;
     int romtable[] = {
        5, 4, -1, -1, // A500 1.2
@@ -1128,24 +1083,24 @@ static void show_rom_list (void)
        0, 0, 0
     };
 
-    WIN32GUI_LoadUIString (IDS_ROM_AVAILABLE, avail, sizeof (avail));
-    WIN32GUI_LoadUIString (IDS_ROM_UNAVAILABLE, unavail, sizeof (avail));
-    strcat (avail, "\n");
-    strcat (unavail, "\n");
-    p1 = "A500 Boot ROM 1.2\0A500 Boot ROM 1.3\0A500+\0A600\0A1000\0A1200\0A3000\0A4000\0\nCD32\0CDTV\0Arcadia Multi Select\0High end WinUAE\0\nA590/A2091 SCSI Boot ROM\0\0";
+    WIN32GUI_LoadUIString (IDS_ROM_AVAILABLE, avail, sizeof (avail) / sizeof (TCHAR));
+    WIN32GUI_LoadUIString (IDS_ROM_UNAVAILABLE, unavail, sizeof (avail) / sizeof (TCHAR));
+    _tcscat (avail, L"\n");
+    _tcscat (unavail, L"\n");
+    p1 = L"A500 Boot ROM 1.2\0A500 Boot ROM 1.3\0A500+\0A600\0A1000\0A1200\0A3000\0A4000\0\nCD32\0CDTV\0Arcadia Multi Select\0High end WinUAE\0\nA590/A2091 SCSI Boot ROM\0\0";
 
     p = malloc (100000);
     if (!p)
        return;
     WIN32GUI_LoadUIString (IDS_ROMSCANEND, p, 100);
-    strcat (p, "\n\n");
+    _tcscat (p, L"\n\n");
 
     rp = romtable;
     while(rp[0]) {
        int ok = 0;
-       p2 = p1 + strlen(p1) + 1;
-       strcat (p, " ");
-       strcat (p, p1); strcat (p, ": ");
+       p2 = p1 + _tcslen (p1) + 1;
+       _tcscat (p, L" ");
+       _tcscat (p, p1); _tcscat (p, L": ");
        if (listrom (rp))
            ok = 1;
        while(*rp++ != -1);
@@ -1159,7 +1114,7 @@ static void show_rom_list (void)
        }
        rp++;
        if (ok)
-           strcat (p, avail); else strcat (p, unavail);
+           _tcscat (p, avail); else _tcscat (p, unavail);
        p1 = p2;
     }
 
@@ -1167,26 +1122,26 @@ static void show_rom_list (void)
     free (p);
 }
 
-static int scan_roms_2 (UAEREG *fkey, char *path)
+static int scan_roms_2 (UAEREG *fkey, TCHAR *path)
 {
-    char buf[MAX_DPATH];
+    TCHAR buf[MAX_DPATH];
     WIN32_FIND_DATA find_data;
     HANDLE handle;
     int ret;
 
     if (!path)
        return 0;
-    write_log("ROM scan directory '%s'\n", path);
-    strcpy (buf, path);
-    strcat (buf, "*.*");
+    write_log (L"ROM scan directory '%s'\n", path);
+    _tcscpy (buf, path);
+    _tcscat (buf, L"*.*");
     ret = 0;
     handle = FindFirstFile (buf, &find_data);
     if (handle == INVALID_HANDLE_VALUE)
        return 0;
     for (;;) {
-       char tmppath[MAX_DPATH];
-       strcpy (tmppath, path);
-       strcat (tmppath, find_data.cFileName);
+       TCHAR tmppath[MAX_DPATH];
+       _tcscpy (tmppath, path);
+       _tcscat (tmppath, find_data.cFileName);
        if (!(find_data.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY |FILE_ATTRIBUTE_SYSTEM)) && find_data.nFileSizeLow < 10000000) {
            if (scan_rom (tmppath, fkey))
                ret = 1;
@@ -1201,15 +1156,15 @@ static int scan_roms_2 (UAEREG *fkey, char *path)
 
 #define MAX_ROM_PATHS 10
 
-static int scan_roms_3(void *fkey, char **paths, char *path)
+static int scan_roms_3(void *fkey, TCHAR **paths, TCHAR *path)
 {
     int i, ret;
-    char pathp[MAX_DPATH];
+    TCHAR pathp[MAX_DPATH];
 
     ret = 0;
     GetFullPathName (path, MAX_DPATH, pathp, NULL);
     for (i = 0; i < MAX_ROM_PATHS; i++) {
-       if (paths[i] && !strcmpi(paths[i], pathp))
+       if (paths[i] && !_tcsicmp (paths[i], pathp))
            return ret;
     }
     ret = scan_roms_2 (fkey, pathp);
@@ -1222,22 +1177,22 @@ static int scan_roms_3(void *fkey, char **paths, char *path)
     return ret;
 }
 
-extern int get_rom_path(char *out, int mode);
+extern int get_rom_path(TCHAR *out, int mode);
 
 int scan_roms (int show)
 {
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
     static int recursive;
     int id, i, ret, keys, cnt;
     UAEREG *fkey, *fkey2;
-    char *paths[MAX_ROM_PATHS];
+    TCHAR *paths[MAX_ROM_PATHS];
 
     if (recursive)
        return 0;
     recursive++;
 
-    regdeletetree (NULL, "DetectedROMs");
-    fkey = regcreatetree (NULL, "DetectedROMs");
+    regdeletetree (NULL, L"DetectedROMs");
+    fkey = regcreatetree (NULL, L"DetectedROMs");
     if (fkey == NULL)
        goto end;
 
@@ -1247,7 +1202,7 @@ int scan_roms (int show)
        paths[i] = NULL;
     for (;;) {
        keys = get_keyring ();
-       fetch_path ("KickstartPath", path, sizeof path);
+       fetch_path (L"KickstartPath", path, sizeof path / sizeof (TCHAR));
        cnt += scan_roms_3 (fkey, paths, path);
        if (TRUE) {
            for(i = 0; i < MAX_ROM_PATHS; i++) {
@@ -1257,7 +1212,7 @@ int scan_roms (int show)
                cnt += scan_roms_3 (fkey, paths, path);
            }
            if (get_keyring() > keys) { /* more keys detected in previous scan? */
-               write_log ("ROM scan: more keys found, restarting..\n");
+               write_log (L"ROM scan: more keys found, restarting..\n");
                for (i = 0; i < MAX_ROM_PATHS; i++) {
                    xfree (paths[i]);
                    paths[i] = NULL;
@@ -1273,7 +1228,7 @@ int scan_roms (int show)
     for (i = 0; i < MAX_ROM_PATHS; i++)
        xfree (paths[i]);
 
-    fkey2 = regcreatetree (NULL, "DetectedROMS");
+    fkey2 = regcreatetree (NULL, L"DetectedROMS");
     if (fkey2) {
        id = 1;
        for (;;) {
@@ -1298,12 +1253,12 @@ end:
 }
 
 struct ConfigStruct {
-    char Name[MAX_DPATH];
-    char Path[MAX_DPATH];
-    char Fullpath[MAX_DPATH];
-    char HostLink[MAX_DPATH];
-    char HardwareLink[MAX_DPATH];
-    char Description[CFG_DESCRIPTION_LENGTH];
+    TCHAR Name[MAX_DPATH];
+    TCHAR Path[MAX_DPATH];
+    TCHAR Fullpath[MAX_DPATH];
+    TCHAR HostLink[MAX_DPATH];
+    TCHAR HardwareLink[MAX_DPATH];
+    TCHAR Description[CFG_DESCRIPTION_LENGTH];
     int Type, Directory;
     struct ConfigStruct *Parent, *Child;
     int host, hardware;
@@ -1311,22 +1266,22 @@ struct ConfigStruct {
     FILETIME t;
 };
 
-static char *configreg[] = { "ConfigFile", "ConfigFileHardware", "ConfigFileHost" };
-static char *configreg2[] = { "", "ConfigFileHardware_Auto", "ConfigFileHost_Auto" };
+static TCHAR *configreg[] = { L"ConfigFile", L"ConfigFileHardware", L"ConfigFileHost" };
+static TCHAR *configreg2[] = { L"", L"ConfigFileHardware_Auto", L"ConfigFileHost_Auto" };
 static struct ConfigStruct **configstore;
 static int configstoresize, configstoreallocated, configtype, configtypepanel;
 
-static struct ConfigStruct *getconfigstorefrompath (char *path, char *out, int type)
+static struct ConfigStruct *getconfigstorefrompath (TCHAR *path, TCHAR *out, int type)
 {
     int i;
     for (i = 0; i < configstoresize; i++) {
        if (((configstore[i]->Type == 0 || configstore[i]->Type == 3) && type == 0) || (configstore[i]->Type == type)) {
-           char path2[MAX_DPATH];
-           strcpy (path2, configstore[i]->Path);
-           strncat (path2, configstore[i]->Name, MAX_DPATH);
-           if (!strcmp (path, path2)) {
-               strcpy (out, configstore[i]->Fullpath);
-               strncat (out, configstore[i]->Name, MAX_DPATH);
+           TCHAR path2[MAX_DPATH];
+           _tcscpy (path2, configstore[i]->Path);
+           _tcsncat (path2, configstore[i]->Name, MAX_DPATH);
+           if (!_tcscmp (path, path2)) {
+               _tcscpy (out, configstore[i]->Fullpath);
+               _tcsncat (out, configstore[i]->Name, MAX_DPATH);
                return configstore[i];
            }
        }
@@ -1334,20 +1289,20 @@ static struct ConfigStruct *getconfigstorefrompath (char *path, char *out, int t
     return 0;
 }
 
-int target_cfgfile_load (struct uae_prefs *p, char *filename, int type, int isdefault)
+int target_cfgfile_load (struct uae_prefs *p, TCHAR *filename, int type, int isdefault)
 {
     int v, i, type2;
     DWORD ct, ct2, size;
-    char tmp1[MAX_DPATH], tmp2[MAX_DPATH];
-    char fname[MAX_DPATH];
+    TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR fname[MAX_DPATH];
 
-    strcpy (fname, filename);
+    _tcscpy (fname, filename);
     if (!zfile_exists (fname)) {
-       fetch_configurationpath (fname, sizeof (fname));
-       if (memcmp(fname, filename, strlen(fname)))
-           strcat (fname, filename);
+       fetch_configurationpath (fname, sizeof (fname) / sizeof (TCHAR));
+       if (memcmp(fname, filename, _tcslen (fname)))
+           _tcscat (fname, filename);
        else
-           strcpy (fname, filename);
+           _tcscpy (fname, filename);
     }
 
     if (isdefault)
@@ -1362,7 +1317,7 @@ int target_cfgfile_load (struct uae_prefs *p, char *filename, int type, int isde
     type2 = type;
     if (type == 0)
        default_prefs (p, type);
-    regqueryint (NULL, "ConfigFile_NoAuto", &ct2);
+    regqueryint (NULL, L"ConfigFile_NoAuto", &ct2);
     v = cfgfile_load (p, fname, &type2, ct2);
     if (!v)
        return v;
@@ -1374,10 +1329,10 @@ int target_cfgfile_load (struct uae_prefs *p, char *filename, int type, int isde
            ct = 0;
            regqueryint (NULL, configreg2[i], &ct);
            if (ct && ((i == 1 && p->config_hardware_path[0] == 0) || (i == 2 && p->config_host_path[0] == 0) || ct2)) {
-               size = sizeof (tmp1);
+               size = sizeof (tmp1) / sizeof (TCHAR);
                regquerystr (NULL, configreg[i], tmp1, &size);
-               fetch_path ("ConfigurationPath", tmp2, sizeof (tmp2));
-               strcat (tmp2, tmp1);
+               fetch_path (L"ConfigurationPath", tmp2, sizeof (tmp2) / sizeof (TCHAR));
+               _tcscat (tmp2, tmp1);
                v = i;
                cfgfile_load (p, tmp2, &v, 1);
            }
@@ -1392,9 +1347,9 @@ static int gui_width = 640, gui_height = 480;
 static int mm = 0;
 static void m(void)
 {
-    write_log ("%d:0: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_size.width, currprefs.gfx_size.height,
+    write_log (L"%d:0: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_size.width, currprefs.gfx_size.height,
        workprefs.gfx_size.width, workprefs.gfx_size.height, changed_prefs.gfx_size.width, changed_prefs.gfx_size.height);
-    write_log ("%d:1: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_size_fs.width, currprefs.gfx_size_fs.height,
+    write_log (L"%d:1: %dx%d %dx%d %dx%d\n", mm, currprefs.gfx_size_fs.width, currprefs.gfx_size_fs.height,
        workprefs.gfx_size_fs.width, workprefs.gfx_size_fs.height, changed_prefs.gfx_size_fs.width, changed_prefs.gfx_size_fs.height);
     mm++;
 }
@@ -1438,7 +1393,7 @@ void gui_display (int shortcut)
     if (isfullscreen () > 0) {
        hr = DirectDraw_FlipToGDISurface ();
        if (FAILED (hr))
-           write_log ("FlipToGDISurface failed, %s\n", DXError (hr));
+           write_log (L"FlipToGDISurface failed, %s\n", DXError (hr));
     }
 
     flush_log ();
@@ -1453,7 +1408,7 @@ void gui_display (int shortcut)
        DiskSelection (hAmigaWnd, IDC_DF0 + shortcut, 0, &changed_prefs, 0);
     } else if (shortcut == 5) {
        if (DiskSelection (hAmigaWnd, IDC_DOSAVESTATE, 9, &changed_prefs, 0))
-           save_state (savestate_fname, "Description!");
+           save_state (savestate_fname, L"Description!");
     } else if (shortcut == 4) {
        if (DiskSelection (hAmigaWnd, IDC_DOLOADSTATE, 10, &changed_prefs, 0))
            savestate_state = STATE_DORESTORE;
@@ -1505,7 +1460,7 @@ static void gui_to_prefs (void)
     changed_prefs = workprefs;
     /* filesys hack */
     currprefs.mountitems = changed_prefs.mountitems;
-    memcpy(&currprefs.mountconfig, &changed_prefs.mountconfig, MOUNT_CONFIG_SIZE * sizeof (struct uaedev_config_info));
+    memcpy (&currprefs.mountconfig, &changed_prefs.mountconfig, MOUNT_CONFIG_SIZE * sizeof (struct uaedev_config_info));
 
     updatewinfsmode (&changed_prefs);
 }
@@ -1532,57 +1487,57 @@ static const GUID diskselectionguids[] = {
 // flag = 14 for loading filesystem
 // flag = 15 for loading input
 // flag = 16 for recording input
-int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, char *path_out, int *multi)
+int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, TCHAR *path_out, int *multi)
 {
     static int statefile_previousfilter;
     static int previousfilter[20];
     OPENFILENAME openFileName;
-    char full_path[MAX_DPATH] = "";
-    char full_path2[MAX_DPATH];
-    char file_name[MAX_DPATH] = "";
-    char init_path[MAX_DPATH] = "";
+    TCHAR full_path[MAX_DPATH] = L"";
+    TCHAR full_path2[MAX_DPATH];
+    TCHAR file_name[MAX_DPATH] = L"";
+    TCHAR init_path[MAX_DPATH] = L"";
     BOOL result = FALSE;
-    char *amiga_path = NULL, *initialdir = NULL, *defext = NULL;
-    char description[CFG_DESCRIPTION_LENGTH] = "";
-    char *p, *nextp;
+    TCHAR *amiga_path = NULL, *initialdir = NULL, *defext = NULL;
+    TCHAR description[CFG_DESCRIPTION_LENGTH] = L"";
+    TCHAR *p, *nextp;
     int all = 1;
     int next;
     int nosavepath = 0;
     const GUID *guid = NULL;
 
-    char szTitle[MAX_DPATH] = { 0 };
-    char szFormat[MAX_DPATH];
-    char szFilter[MAX_DPATH] = { 0 };
+    TCHAR szTitle[MAX_DPATH] = { 0 };
+    TCHAR szFormat[MAX_DPATH];
+    TCHAR szFilter[MAX_DPATH] = { 0 };
 
     memset (&openFileName, 0, sizeof (OPENFILENAME));
 
     if (path_out && path_out[0]) {
-       strcpy (init_path, path_out);
+       _tcscpy (init_path, path_out);
        nosavepath = 1;
     } else {
-       strncpy (init_path, start_path_data, MAX_DPATH);
+       _tcsncpy (init_path, start_path_data, MAX_DPATH);
        switch (flag)
        {
            case 0:
            case 1:
-               fetch_path ("FloppyPath", init_path, sizeof (init_path));
+               fetch_path (L"FloppyPath", init_path, sizeof (init_path) / sizeof (TCHAR));
                guid = &diskselectionguids[0];
            break;
            case 2:
            case 3:
-               fetch_path ("hdfPath", init_path, sizeof (init_path));
+               fetch_path (L"hdfPath", init_path, sizeof (init_path) / sizeof (TCHAR));
                guid = &diskselectionguids[1];
            break;
            case 6:
            case 7:
            case 11:
-               fetch_path ("KickstartPath", init_path, sizeof (init_path));
+               fetch_path (L"KickstartPath", init_path, sizeof (init_path) / sizeof (TCHAR));
                guid = &diskselectionguids[2];
            break;
            case 4:
            case 5:
            case 8:
-               fetch_path ("ConfigurationPath", init_path, sizeof (init_path));
+               fetch_path (L"ConfigurationPath", init_path, sizeof (init_path) / sizeof (TCHAR));
                guid = &diskselectionguids[3];
            break;
            case 9:
@@ -1590,29 +1545,29 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
            {
                int ok = 0;
                if (savestate_fname[0]) {
-                   strcpy (init_path, savestate_fname);
+                   _tcscpy (init_path, savestate_fname);
                    for (;;) {
-                       char *p;
+                       TCHAR *p;
                        if (my_existsdir (init_path)) {
                            ok = 1;
                            break;
                        }
-                       p = strrchr (init_path, '\\');
+                       p = _tcsrchr (init_path, '\\');
                        if (!p)
-                           p = strrchr (init_path, '/');
+                           p = _tcsrchr (init_path, '/');
                        if (!p)
                            break;
                        *p = 0;
                    }
                }
                if (!ok)
-                   fetch_path ("StatefilePath", init_path, sizeof (init_path));
+                   fetch_path (L"StatefilePath", init_path, sizeof (init_path) / sizeof (TCHAR));
                guid = &diskselectionguids[4];
            }
            break;
            case 15:
            case 16:
-               fetch_path ("InputPath", init_path, sizeof (init_path));
+               fetch_path (L"InputPath", init_path, sizeof (init_path) / sizeof (TCHAR));
                guid = &diskselectionguids[5];
            break;
        }
@@ -1624,98 +1579,98 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
     case 0:
        WIN32GUI_LoadUIString (IDS_SELECTADF, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_ADF, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING) + 1);
-       defext = "ADF";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter), DISK_FORMAT_STRING, sizeof (DISK_FORMAT_STRING) + sizeof (TCHAR));
+       defext = L"ADF";
        break;
     case 1:
        WIN32GUI_LoadUIString (IDS_CHOOSEBLANK, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_ADF, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen (szFilter), "(*.adf)\0*.adf\0", 15);
-       defext = "ADF";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter), L"(*.adf)\0*.adf\0", 15);
+       defext = L"ADF";
        break;
     case 2:
     case 3:
        WIN32GUI_LoadUIString (IDS_SELECTHDF, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_HDF, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen (szFilter),  HDF_FORMAT_STRING, sizeof (HDF_FORMAT_STRING) + 1);
-       defext = "HDF";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter),  HDF_FORMAT_STRING, sizeof (HDF_FORMAT_STRING) + sizeof (TCHAR));
+       defext = L"HDF";
        break;
     case 4:
     case 5:
        WIN32GUI_LoadUIString (IDS_SELECTUAE, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_UAE, szFormat, MAX_DPATH );
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen (szFilter), "(*.uae)\0*.uae\0", 15);
-       defext = "UAE";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter), L"(*.uae)\0*.uae\0", 15);
+       defext = L"UAE";
        break;
     case 6:
        WIN32GUI_LoadUIString (IDS_SELECTROM, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_ROM, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen(szFilter), ROM_FORMAT_STRING, sizeof (ROM_FORMAT_STRING) + 1);
-       defext = "ROM";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter), ROM_FORMAT_STRING, sizeof (ROM_FORMAT_STRING) + sizeof (TCHAR));
+       defext = L"ROM";
        break;
     case 7:
        WIN32GUI_LoadUIString (IDS_SELECTKEY, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_KEY, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen(szFilter), "(*.key)\0*.key\0", 15);
-       defext = "KEY";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter), L"(*.key)\0*.key\0", 15);
+       defext = L"KEY";
        break;
     case 15:
     case 16:
        WIN32GUI_LoadUIString (flag == 15 ? IDS_RESTOREINP : IDS_SAVEINP, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_INP, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen(szFilter), INP_FORMAT_STRING, sizeof (INP_FORMAT_STRING) + 1);
-       defext = "IMP";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter), INP_FORMAT_STRING, sizeof (INP_FORMAT_STRING) + sizeof (TCHAR));
+       defext = L"IMP";
        break;
     case 9:
     case 10:
        WIN32GUI_LoadUIString (flag == 10 ? IDS_RESTOREUSS : IDS_SAVEUSS, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_USS, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
+       _stprintf (szFilter, L"%s ", szFormat);
        if (flag == 10) {
-           memcpy (szFilter + strlen(szFilter), USS_FORMAT_STRING_RESTORE, sizeof (USS_FORMAT_STRING_RESTORE) + 1);
+           memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_RESTORE, sizeof (USS_FORMAT_STRING_RESTORE) + sizeof (TCHAR));
            all = 1;
        } else {
-           char tmp[MAX_DPATH];
-           memcpy (szFilter + strlen(szFilter), USS_FORMAT_STRING_SAVE, sizeof (USS_FORMAT_STRING_SAVE) + 1);
+           TCHAR tmp[MAX_DPATH];
+           memcpy (szFilter + _tcslen (szFilter), USS_FORMAT_STRING_SAVE, sizeof (USS_FORMAT_STRING_SAVE) + sizeof (TCHAR));
            p = szFilter;
            while (p[0] != 0 || p[1] !=0 ) p++;
            p++;
-           WIN32GUI_LoadUIString (IDS_STATEFILE_UNCOMPRESSED, tmp, sizeof (tmp));
-           strcat (p, tmp);
-           strcat (p, " (*.uss)");
-           p += strlen (p) + 1;
-           strcpy (p, "*.uss");
-           p += strlen (p) + 1;
-           WIN32GUI_LoadUIString (IDS_STATEFILE_RAMDUMP, tmp, sizeof (tmp));
-           strcat (p, tmp);
-           strcat (p, " (*.dat)");
-           p += strlen(p) + 1;
-           strcpy (p, "*.dat");
-           p += strlen (p) + 1;
-           WIN32GUI_LoadUIString (IDS_STATEFILE_WAVE, tmp, sizeof (tmp));
-           strcat (p, tmp);
-           strcat (p, " (*.wav)");
-           p += strlen (p) + 1;
-           strcpy (p, "*.wav");
-           p += strlen (p) + 1;
+           WIN32GUI_LoadUIString (IDS_STATEFILE_UNCOMPRESSED, tmp, sizeof (tmp) / sizeof (TCHAR));
+           _tcscat (p, tmp);
+           _tcscat (p, L" (*.uss)");
+           p += _tcslen (p) + 1;
+           _tcscpy (p, L"*.uss");
+           p += _tcslen (p) + 1;
+           WIN32GUI_LoadUIString (IDS_STATEFILE_RAMDUMP, tmp, sizeof (tmp) / sizeof (TCHAR));
+           _tcscat (p, tmp);
+           _tcscat (p, L" (*.dat)");
+           p += _tcslen (p) + 1;
+           _tcscpy (p, L"*.dat");
+           p += _tcslen (p) + 1;
+           WIN32GUI_LoadUIString (IDS_STATEFILE_WAVE, tmp, sizeof (tmp) / sizeof (TCHAR));
+           _tcscat (p, tmp);
+           _tcscat (p, L" (*.wav)");
+           p += _tcslen (p) + 1;
+           _tcscpy (p, L"*.wav");
+           p += _tcslen (p) + 1;
            *p = 0;
            all = 0;
        }
-       defext = "USS";
+       defext = L"USS";
        break;
     case 11:
        WIN32GUI_LoadUIString (IDS_SELECTFLASH, szTitle, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_FLASH, szFormat, MAX_DPATH);
-       sprintf (szFilter, "%s ", szFormat);
-       memcpy (szFilter + strlen (szFilter), "(*.nvr)\0*.nvr\0", 15);
-       defext = "NVR";
+       _stprintf (szFilter, L"%s ", szFormat);
+       memcpy (szFilter + _tcslen (szFilter), L"(*.nvr)\0*.nvr\0", 15 * sizeof (TCHAR));
+       defext = L"NVR";
        break;
     case 8:
     default:
@@ -1730,9 +1685,9 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
        initialdir = path_out;
        break;
     case 14:
-       strcpy (szTitle, "Select supported archive file");
-       sprintf (szFilter, "%s (%s)", "Archive", ARCHIVE_STRING);
-       strcpy (szFilter + strlen (szFilter) + 1, ARCHIVE_STRING);
+       _tcscpy (szTitle, L"Select supported archive file");
+       _stprintf (szFilter, L"%s (%s)", L"Archive", ARCHIVE_STRING);
+       _tcscpy (szFilter + _tcslen (szFilter) + 1, ARCHIVE_STRING);
        initialdir = path_out;
        break;
     }
@@ -1740,10 +1695,10 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
        p = szFilter;
        while (p[0] != 0 || p[1] !=0) p++;
        p++;
-       strcpy (p, "All files (*.*)");
-       p += strlen(p) + 1;
-       strcpy (p, "*.*");
-       p += strlen(p) + 1;
+       _tcscpy (p, L"All files (*.*)");
+       p += _tcslen (p) + 1;
+       _tcscpy (p, L"*.*");
+       p += _tcslen (p) + 1;
        *p = 0;
     }
     openFileName.lStructSize = sizeof (OPENFILENAME);
@@ -1767,28 +1722,28 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
        openFileName.Flags |= OFN_ALLOWMULTISELECT;
     if (flag == 1 || flag == 3 || flag == 5 || flag == 9 || flag == 11 || flag == 16) {
        if (!(result = GetSaveFileName_2 (&openFileName, guid)))
-           write_log ("GetSaveFileNameX() failed, err=%d.\n", GetLastError());
+           write_log (L"GetSaveFileNameX() failed, err=%d.\n", GetLastError());
     } else {
        if (!(result = GetOpenFileName_2 (&openFileName, guid)))
-           write_log ("GetOpenFileNameX() failed, err=%d.\n", GetLastError());
+           write_log (L"GetOpenFileNameX() failed, err=%d.\n", GetLastError());
     }
     previousfilter[flag] = openFileName.nFilterIndex;
 
-    memcpy (full_path2, full_path, sizeof (full_path));
-    memcpy (stored_path, full_path, sizeof (stored_path));
+    memcpy (full_path2, full_path, sizeof (full_path) / sizeof (TCHAR));
+    memcpy (stored_path, full_path, sizeof (stored_path) / sizeof (TCHAR));
     next = 0;
     nextp = full_path2 + openFileName.nFileOffset;
     if (path_out) {
        if (multi) {
            while (nextp[0])
-               nextp += strlen (nextp) + 1;
-           memcpy (path_out, full_path2, nextp - full_path2 + 1);
+               nextp += _tcslen (nextp) + 1;
+           memcpy (path_out, full_path2, (nextp - full_path2 + 1) * sizeof (TCHAR));
        } else {
-           strcpy (path_out, full_path2);
+           _tcscpy (path_out, full_path2);
        }
     }
     nextp = full_path2 + openFileName.nFileOffset;
-    if (nextp[strlen(nextp) + 1] == 0)
+    if (nextp[_tcslen (nextp) + 1] == 0)
        multi = 0;
     while (result && next >= 0)
     {
@@ -1796,17 +1751,17 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
        if (multi) {
            if (nextp[0] == 0)
                break;
-           sprintf (full_path, "%s\\%s", full_path2, nextp);
-           nextp += strlen (nextp) + 1;
+           _stprintf (full_path, L"%s\\%s", full_path2, nextp);
+           nextp += _tcslen (nextp) + 1;
        }
        switch (wParam)
        {
        case IDC_PATH_NAME:
        case IDC_PATH_FILESYS:
            if (flag == 8) {
-               if(strstr(full_path, "Configurations\\")) {
-                   strcpy(full_path, init_path);
-                   strcat(full_path, file_name);
+               if(_tcsstr(full_path, L"Configurations\\")) {
+                   _tcscpy(full_path, init_path);
+                   _tcscat(full_path, file_name);
                }
            }
            SetDlgItemText (hDlg, wParam, full_path);
@@ -1814,26 +1769,26 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
        case IDC_DF0:
        case IDC_DF0QQ:
            SetDlgItemText (hDlg, IDC_DF0TEXT, full_path);
-           strcpy(prefs->df[0], full_path);
+           _tcscpy(prefs->df[0], full_path);
            DISK_history_add (full_path, -1);
            next = IDC_DF1;
            break;
        case IDC_DF1:
        case IDC_DF1QQ:
            SetDlgItemText (hDlg, IDC_DF1TEXT, full_path);
-           strcpy(prefs->df[1], full_path);
+           _tcscpy(prefs->df[1], full_path);
            DISK_history_add (full_path, -1);
            next = IDC_DF2;
            break;
        case IDC_DF2:
            SetDlgItemText (hDlg, IDC_DF2TEXT, full_path);
-           strcpy(prefs->df[2], full_path);
+           _tcscpy(prefs->df[2], full_path);
            DISK_history_add (full_path, -1);
            next = IDC_DF3;
            break;
        case IDC_DF3:
            SetDlgItemText (hDlg, IDC_DF3TEXT, full_path);
-           strcpy (prefs->df[3], full_path);
+           _tcscpy (prefs->df[3], full_path);
            DISK_history_add (full_path, -1);
            break;
        case IDC_DOSAVESTATE:
@@ -1842,7 +1797,7 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
            break;
        case IDC_CREATE:
            {
-               char disk_name[32];
+               TCHAR disk_name[32];
                disk_name[0] = 0; disk_name[31] = 0;
                GetDlgItemText (hDlg, IDC_CREATE_NAME, disk_name, 30);
                disk_creatediskfile (full_path, 0, SendDlgItemMessage (hDlg, IDC_FLOPPYTYPE, CB_GETCURSEL, 0, 0L), disk_name);
@@ -1853,7 +1808,7 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
            break;
        case IDC_LOAD:
            if (target_cfgfile_load (&workprefs, full_path, 0, 0) == 0) {
-               char szMessage[MAX_DPATH];
+               TCHAR szMessage[MAX_DPATH];
                WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH);
                pre_gui_message (szMessage);
            } else {
@@ -1867,16 +1822,16 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
            cfgfile_save (&workprefs, full_path, 0);
            break;
        case IDC_ROMFILE:
-           strcpy (workprefs.romfile, full_path);
+           _tcscpy (workprefs.romfile, full_path);
            break;
        case IDC_ROMFILE2:
-           strcpy (workprefs.romextfile, full_path);
+           _tcscpy (workprefs.romextfile, full_path);
            break;
        case IDC_FLASHFILE:
-           strcpy (workprefs.flashfile, full_path);
+           _tcscpy (workprefs.flashfile, full_path);
            break;
        case IDC_CARTFILE:
-           strcpy (workprefs.cartfile, full_path);
+           _tcscpy (workprefs.cartfile, full_path);
            break;
        case IDC_INPREC_PLAY:
            inprec_open (full_path, IsDlgButtonChecked (hDlg, IDC_INPREC_PLAYMODE) == BST_CHECKED ? -1 : -2);
@@ -1887,16 +1842,16 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
        }
        if (!nosavepath) {
            if (flag == 0 || flag == 1) {
-               amiga_path = strstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
+               amiga_path = _tcsstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
                if (amiga_path && amiga_path != openFileName.lpstrFile) {
                    *amiga_path = 0;
-                   regsetstr (NULL, "FloppyPath", openFileName.lpstrFile);
+                   regsetstr (NULL, L"FloppyPath", openFileName.lpstrFile);
                }
            } else if (flag == 2 || flag == 3) {
-               amiga_path = strstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
+               amiga_path = _tcsstr (openFileName.lpstrFile, openFileName.lpstrFileTitle);
                if (amiga_path && amiga_path != openFileName.lpstrFile) {
                    *amiga_path = 0;
-                   regsetstr (NULL, "hdfPath", openFileName.lpstrFile);
+                   regsetstr (NULL, L"hdfPath", openFileName.lpstrFile);
                }
            }
        }
@@ -1907,46 +1862,46 @@ int DiskSelection_2 (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs
     }
     return result;
 }
-int DiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, char *path_out)
+int DiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, TCHAR *path_out)
 {
     return DiskSelection_2 (hDlg, wParam, flag, prefs, path_out, NULL);
 }
-int MultiDiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, char *path_out)
+int MultiDiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, TCHAR *path_out)
 {
     int multi = 0;
     return DiskSelection_2 (hDlg, wParam, flag, prefs, path_out, &multi);
 }
-static int loopmulti (char *s, char *out)
+static int loopmulti (TCHAR *s, TCHAR *out)
 {
     static int index;
 
     if (!out) {
-       index = strlen (s) + 1;
+       index = _tcslen (s) + 1;
        return 1;
     }
     if (index < 0)
        return 0;
     if (!s[index]) {
-       if (s[strlen (s) + 1] == 0) {
-           strcpy (out, s);
+       if (s[_tcslen (s) + 1] == 0) {
+           _tcscpy (out, s);
            index = -1;
            return 1;
        }
        return 0;
     }
-    sprintf (out, "%s\\%s", s, s + index);
-    index += strlen (s + index) + 1;
+    _stprintf (out, L"%s\\%s", s, s + index);
+    index += _tcslen (s + index) + 1;
     return 1;
 }
 
-static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, char *dostype, char *newpath)
+static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, TCHAR *dostype, TCHAR *newpath)
 {
     HANDLE hf;
     int i = 0;
     BOOL result = FALSE;
     LONG highword = 0;
     DWORD ret, written;
-    char init_path[MAX_DPATH] = "";
+    TCHAR init_path[MAX_DPATH] = L"";
     uae_u64 hfsize;
     uae_u32 dt;
     uae_u8 b;
@@ -1981,7 +1936,7 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, char *dostype, char *newpat
                    ret = SetFilePointer (hf, (DWORD)hfsize, NULL, FILE_BEGIN);
                }
                if (ret == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
-                   write_log ("SetFilePointer() failure for %s to posn %ud\n", init_path, hfsize);
+                   write_log (L"SetFilePointer() failure for %s to posn %ud\n", init_path, hfsize);
                else
                    result = SetEndOfFile (hf);
                SetFilePointer (hf, 0, NULL, FILE_BEGIN);
@@ -1990,7 +1945,7 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, char *dostype, char *newpat
                WriteFile (hf, &b, 1, &written, NULL);
                WriteFile (hf, &b, 1, &written, NULL);
                WriteFile (hf, &b, 1, &written, NULL);
-               if (sscanf (dostype, "%x", &dt) > 0) {
+               if (_stscanf (dostype, L"%x", &dt) > 0) {
                    SetFilePointer (hf, 0, NULL, FILE_BEGIN);
                    b = dt >> 24;
                    WriteFile (hf, &b, 1, &written, NULL);
@@ -2003,14 +1958,14 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, char *dostype, char *newpat
                }
                CloseHandle (hf);
            } else {
-               write_log ("CreateFile() failed to create %s\n", init_path);
+               write_log (L"CreateFile() failed to create %s\n", init_path);
            }
            SetCursor (LoadCursor (NULL, IDC_ARROW));
        }
     }
     if (!result) {
-        char szMessage[MAX_DPATH];
-        char szTitle[MAX_DPATH];
+        TCHAR szMessage[MAX_DPATH];
+        TCHAR szTitle[MAX_DPATH];
        WIN32GUI_LoadUIString (IDS_FAILEDHARDFILECREATION, szMessage, MAX_DPATH);
        WIN32GUI_LoadUIString (IDS_CREATIONERROR, szTitle, MAX_DPATH);
        MessageBox (hDlg, szMessage, szTitle, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
@@ -2018,27 +1973,27 @@ static BOOL CreateHardFile (HWND hDlg, UINT hfsizem, char *dostype, char *newpat
     return result;
 }
 
-static const char *memsize_names[] = {
+static const TCHAR *memsize_names[] = {
 /* 0 */ szNone,
-/* 1 */ "256 K",
-/* 2 */ "512 K",
-/* 3 */ "1 MB",
-/* 4 */ "2 MB",
-/* 5 */ "4 MB",
-/* 6 */ "8 MB",
-/* 7 */ "16 MB",
-/* 8 */ "32 MB",
-/* 9 */ "64 MB",
-/* 10*/ "128 MB",
-/* 11*/ "256 MB",
-/* 12*/ "512 MB",
-/* 13*/ "1 GB",
-/* 14*/ "1.5MB",
-/* 15*/ "1.8MB",
-/* 16*/ "2 GB",
-/* 17*/ "384 MB",
-/* 18*/ "768 MB",
-/* 19*/ "1.5 GB",
+/* 1 */ L"256 K",
+/* 2 */ L"512 K",
+/* 3 */ L"1 MB",
+/* 4 */ L"2 MB",
+/* 5 */ L"4 MB",
+/* 6 */ L"8 MB",
+/* 7 */ L"16 MB",
+/* 8 */ L"32 MB",
+/* 9 */ L"64 MB",
+/* 10*/ L"128 MB",
+/* 11*/ L"256 MB",
+/* 12*/ L"512 MB",
+/* 13*/ L"1 GB",
+/* 14*/ L"1.5MB",
+/* 15*/ L"1.8MB",
+/* 16*/ L"2 GB",
+/* 17*/ L"384 MB",
+/* 18*/ L"768 MB",
+/* 19*/ L"1.5 GB",
 };
 
 static unsigned long memsizes[] = {
@@ -2083,54 +2038,54 @@ static int CalculateHardfileSize (HWND hDlg)
     return mbytes;
 }
 
-static const char *nth[] = {
-    "", "second ", "third ", "fourth ", "fifth ", "sixth ", "seventh ", "eighth ", "ninth ", "tenth "
+static const TCHAR *nth[] = {
+    L"", L"second ", L"third ", L"fourth ", L"fifth ", L"sixth ", L"seventh ", L"eighth ", L"ninth ", L"tenth "
 };
 
 static void setguititle (HWND phwnd)
 {
-    static char title[200];
-    char title2[1000];
-    char *name;
+    static TCHAR title[200];
+    TCHAR title2[1000];
+    TCHAR *name;
     static HWND hwnd;
 
     if (phwnd)
        hwnd = phwnd;
     if (hwnd && !title[0]) {
-        GetWindowText (hwnd, title, sizeof (title));
-       if (strlen (WINUAEBETA) > 0) {
-           strcat (title, BetaStr);
-           if (strlen(WINUAEEXTRA) > 0) {
-               strcat (title, " ");
-               strcat (title, WINUAEEXTRA);
+        GetWindowText (hwnd, title, sizeof (title) / sizeof (TCHAR));
+       if (_tcslen (WINUAEBETA) > 0) {
+           _tcscat (title, BetaStr);
+           if (_tcslen (WINUAEEXTRA) > 0) {
+               _tcscat (title, L" ");
+               _tcscat (title, WINUAEEXTRA);
            }
        }
     }
     title2[0] = 0;
     name = config_filename;
-    if (name && strlen (name) > 0) {
-       strcat (title2, "[");
-       strcat (title2, name);
-       strcat (title2, "] - ");
+    if (name && _tcslen (name) > 0) {
+       _tcscat (title2, L"[");
+       _tcscat (title2, name);
+       _tcscat (title2, L"] - ");
     }
-    strcat (title2, title);
+    _tcscat (title2, title);
     SetWindowText (hwnd, title2);
 }
 
 
-static void GetConfigPath (char *path, struct ConfigStruct *parent, int noroot)
+static void GetConfigPath (TCHAR *path, struct ConfigStruct *parent, int noroot)
 {
     if (parent == NULL) {
        path[0] = 0;
        if (!noroot) {
-           fetch_path ("ConfigurationPath", path, MAX_DPATH);
+           fetch_path (L"ConfigurationPath", path, MAX_DPATH);
        }
        return;
     }
     if (parent) {
        GetConfigPath (path, parent->Parent, noroot);
-       strncat (path, parent->Name, MAX_DPATH);
-       strncat (path, "\\", MAX_DPATH);
+       _tcsncat (path, parent->Name, MAX_DPATH);
+       _tcsncat (path, L"\\", MAX_DPATH);
     }
 }
 
@@ -2156,64 +2111,64 @@ static void FreeConfigStore (void)
     configstoresize = configstoreallocated = 0;
 }
 
-static void getconfigcache (char *dst, const char *path)
+static void getconfigcache (TCHAR *dst, const TCHAR *path)
 {
-    strcpy (dst, path);
-    strncat (dst, "configuration.cache", MAX_DPATH);
+    _tcscpy (dst, path);
+    _tcsncat (dst, L"configuration.cache", MAX_DPATH);
 }
 
-static char *fgetsx (char *dst, FILE *f)
+static TCHAR *fgetsx (TCHAR *dst, FILE *f)
 {
-    char *s;
+    TCHAR *s2;
     dst[0] = 0;
-    s = fgets (dst, MAX_DPATH, f);
-    if (!s)
-       return s;
-    if (strlen (dst) == 0)
-       return s;
-    if (dst[strlen (dst) - 1] == '\n')
-       dst[strlen (dst) - 1] = 0;
-    if (dst[strlen (dst) - 1] == '\r')
-       dst[strlen (dst) - 1] = 0;
-    return s;
+    s2 = fgetws (dst, MAX_DPATH, f);
+    if (!s2)
+       return NULL;
+    if (_tcslen (dst) == 0)
+       return dst;
+    if (dst[_tcslen (dst) - 1] == '\n')
+       dst[_tcslen (dst) - 1] = 0;
+    if (dst[_tcslen (dst) - 1] == '\r')
+       dst[_tcslen (dst) - 1] = 0;
+    return dst;
 }
 
-static char configcachever[] = "WinUAE Configuration.Cache";
+static TCHAR configcachever[] = L"WinUAE Configuration.Cache";
 
 static void setconfighosthard (struct ConfigStruct *config)
 {
     if (!config->Directory)
        return;
-    if (!stricmp (config->Name, CONFIG_HOST))
+    if (!_tcsicmp (config->Name, CONFIG_HOST))
        config->host = 1;
-    if (!stricmp (config->Name, CONFIG_HARDWARE))
+    if (!_tcsicmp (config->Name, CONFIG_HARDWARE))
        config->hardware = 1;
 }
 
-static void flushconfigcache (const char *cachepath)
+static void flushconfigcache (const TCHAR *cachepath)
 {
     FILE *zcache;
-    zcache = fopen (cachepath, "r");
+    zcache = _tfopen (cachepath, L"r");
     if (zcache == NULL)
        return;
     fclose (zcache);
-    zcache = fopen (cachepath, "w+");
+    zcache = _tfopen (cachepath, L"w+, ccs=UTF-8");
     if (zcache)
         fclose (zcache);
-    write_log ("'%s' flushed\n", cachepath);
+    write_log (L"'%s' flushed\n", cachepath);
 }
 
-static struct ConfigStruct *readconfigcache (const char *path)
+static struct ConfigStruct *readconfigcache (const TCHAR *path)
 {
     FILE *zcache;
-    char cachepath[MAX_DPATH];
-    char buf[MAX_DPATH];
-    char rootpath[MAX_DPATH];
-    char path2[MAX_DPATH], tmp[MAX_DPATH];
+    TCHAR cachepath[MAX_DPATH];
+    TCHAR buf[MAX_DPATH];
+    TCHAR rootpath[MAX_DPATH];
+    TCHAR path2[MAX_DPATH], tmp[MAX_DPATH];
     struct ConfigStruct *cs, *first;
     int err;
     int filelines, dirlines, headlines, dirmode, lines;
-    char dirsep = '\\';
+    TCHAR dirsep = '\\';
     FILETIME t;
     SYSTEMTIME st;
     ULARGE_INTEGER t1, stt, dirtt;
@@ -2226,23 +2181,23 @@ static struct ConfigStruct *readconfigcache (const char *path)
     err = 0;
     first = NULL;
     getconfigcache (cachepath, path);
-    zcache = fopen (cachepath, "r");
+    zcache = _tfopen (cachepath, L"r");
     if (!zcache)
        return NULL;
     if (!configurationcache) {
        fclose (zcache);
-       unlink (cachepath);
+       _wunlink (cachepath);
        return NULL;
     }
     fgetsx (buf, zcache);
     if (feof (zcache))
        goto end;
-    if (strcmp (buf, configcachever))
+    if (_tcscmp (buf, configcachever))
        goto end;
-    GetFullPathName (path, sizeof path2, path2, NULL);
-    strcpy (rootpath, path2);
-    if (path2[strlen (path2) - 1] == '\\' || path2[strlen (path2) -1] == '/')
-       path2[strlen (path2) - 1] = 0;
+    GetFullPathName (path, sizeof path2 / sizeof (TCHAR), path2, NULL);
+    _tcscpy (rootpath, path2);
+    if (path2[_tcslen (path2) - 1] == '\\' || path2[_tcslen (path2) -1] == '/')
+       path2[_tcslen (path2) - 1] = 0;
     h = FindFirstFile (path2, &ffd);
     if (h == INVALID_HANDLE_VALUE)
        goto end;
@@ -2250,15 +2205,15 @@ static struct ConfigStruct *readconfigcache (const char *path)
     memcpy (&dirtt, &ffd.ftLastWriteTime, sizeof (ULARGE_INTEGER));
 
     fgetsx (buf, zcache);
-    headlines = atol (buf);
+    headlines = _tstol (buf);
     fgetsx (buf, zcache);
     headlines--;
-    dirlines = atol (buf);
+    dirlines = _tstol (buf);
     fgetsx (buf, zcache);
     headlines--;
-    filelines = atol (buf);
+    filelines = _tstol (buf);
     fgetsx (buf, zcache);
-    t1.QuadPart = _atoi64 (buf);
+    t1.QuadPart = _tstoi64 (buf);
     headlines--;
     GetSystemTime (&st);
     SystemTimeToFileTime (&st, &t);
@@ -2275,25 +2230,25 @@ static struct ConfigStruct *readconfigcache (const char *path)
        goto end;
 
     while (fgetsx (buf, zcache)) {
-       char c;
-       char dirpath[MAX_DPATH];
+       TCHAR c;
+       TCHAR dirpath[MAX_DPATH];
 
        dirmode = 0;
-       if (strlen (buf) > 0) {
-           c = buf[strlen (buf) - 1];
+       if (_tcslen (buf) > 0) {
+           c = buf[_tcslen (buf) - 1];
            if (c == '/' || c == '\\') {
                dirmode = 1;
                dirsep = c;
            }
        }
 
-       strcpy (dirpath, buf);
+       _tcscpy (dirpath, buf);
        if (dirmode) {
            lines = dirlines;
        } else {
-           char *p;
+           TCHAR *p;
            lines = filelines;
-           p = strrchr (dirpath, dirsep);
+           p = _tcsrchr (dirpath, dirsep);
            if (p)
                p[0] = 0;
            else
@@ -2311,14 +2266,14 @@ static struct ConfigStruct *readconfigcache (const char *path)
            first = cs;
 
        cs->Directory = dirmode;
-       strcpy (tmp, path);
-       strcat (tmp, dirpath);
-       strcpy (cs->Fullpath, tmp);
-       strcpy (cs->Path, dirpath);
+       _tcscpy (tmp, path);
+       _tcscat (tmp, dirpath);
+       _tcscpy (cs->Fullpath, tmp);
+       _tcscpy (cs->Path, dirpath);
 
        fgetsx (tmp, zcache);
        lines--;
-       t1.QuadPart = _atoi64 (tmp);
+       t1.QuadPart = _tstoi64 (tmp);
        if (t1.QuadPart > stt.QuadPart)
            goto end;
 
@@ -2327,23 +2282,23 @@ static struct ConfigStruct *readconfigcache (const char *path)
         fgetsx (cs->Description, zcache);
        lines--;
 
-       strcpy (tmp, cs->Path);
-       if (strlen (tmp) > 0) {
-           char *p = tmp;
-           if (tmp[strlen (tmp) - 1] == dirsep) {
-               tmp[strlen (tmp) - 1] = 0;
-               p = strrchr (tmp, dirsep);
+       _tcscpy (tmp, cs->Path);
+       if (_tcslen (tmp) > 0) {
+           TCHAR *p = tmp;
+           if (tmp[_tcslen (tmp) - 1] == dirsep) {
+               tmp[_tcslen (tmp) - 1] = 0;
+               p = _tcsrchr (tmp, dirsep);
                if (p)
                    p[1] = 0;
            } else {
-               tmp[strlen (tmp) + 1] = 0;
-               tmp[strlen (tmp)] = dirsep;
+               tmp[_tcslen (tmp) + 1] = 0;
+               tmp[_tcslen (tmp)] = dirsep;
            }
            if (p) {
                int i;
                for (i = 0; i < configstoresize; i++) {
                    struct ConfigStruct *cs2 = configstore[i];
-                   if (cs2 != cs && !strcmp (cs2->Path, tmp) && cs2->Directory) {
+                   if (cs2 != cs && !_tcscmp (cs2->Path, tmp) && cs2->Directory) {
                        cs->Parent = cs2;
                        if (!cs2->Child)
                            cs2->Child = cs;
@@ -2354,9 +2309,9 @@ static struct ConfigStruct *readconfigcache (const char *path)
            }
        }
 
-       if (strlen (cs->Path) > 0 && !dirmode) {
-           strcat (cs->Path, "\\");
-           strcat (cs->Fullpath, "\\");
+       if (_tcslen (cs->Path) > 0 && !dirmode) {
+           _tcscat (cs->Path, L"\\");
+           _tcscat (cs->Fullpath, L"\\");
        }
 
        if (!dirmode) {
@@ -2366,7 +2321,7 @@ static struct ConfigStruct *readconfigcache (const char *path)
            lines--;
            fgetsx (buf, zcache);
            lines--;
-           cs->Type = atol (buf);
+           cs->Type = _tstol (buf);
        }
 
        setconfighosthard (cs);
@@ -2387,59 +2342,59 @@ end:
        err = 1;
     fclose (zcache);
     if (err || first == NULL) {
-       write_log ("'%s' load failed\n", cachepath);
+       write_log (L"'%s' load failed\n", cachepath);
        flushconfigcache (cachepath);
        FreeConfigStore ();
        return NULL;
     } else {
-       write_log ("'%s' loaded successfully\n", cachepath);
+       write_log (L"'%s' loaded successfully\n", cachepath);
     }
     return first;
 }
 
-static void writeconfigcacheentry (FILE *zcache, const char *relpath, struct ConfigStruct *cs)
+static void writeconfigcacheentry (FILE *zcache, const TCHAR *relpath, struct ConfigStruct *cs)
 {
-    char path2[MAX_DPATH];
-    char lf = 10;
-    char el[] = ";\n";
-    char *p;
+    TCHAR path2[MAX_DPATH];
+    TCHAR lf = 10;
+    TCHAR el[] = L";\n";
+    TCHAR *p;
     ULARGE_INTEGER li;
 
-    GetFullPathName (cs->Fullpath, sizeof path2, path2, NULL);
-    if (strlen (path2) < strlen (relpath))
+    GetFullPathName (cs->Fullpath, sizeof path2 / sizeof (TCHAR), path2, NULL);
+    if (_tcslen (path2) < _tcslen (relpath))
        return;
-    if (memcmp (path2, relpath, strlen (relpath)))
+    if (_tcsncmp (path2, relpath, _tcslen (relpath)))
        return;
-    p = path2 + strlen (relpath);
+    p = path2 + _tcslen (relpath);
     if (!cs->Directory)
-       strcat (p, cs->Name);
-    fwrite (p, strlen (p), 1, zcache);
-    fwrite (&lf, 1, 1, zcache);
+       _tcscat (p, cs->Name);
+    fwrite (p, _tcslen (p), sizeof (TCHAR), zcache);
+    fwrite (&lf, 1, sizeof (TCHAR), zcache);
 
     memcpy (&li, &cs->t, sizeof (ULARGE_INTEGER));
-    sprintf (path2, "%I64u", li.QuadPart);
-    fwrite (path2, strlen (path2), 1, zcache);
-    fwrite (&lf, 1, 1, zcache);
+    _stprintf (path2, L"%I64u", li.QuadPart);
+    fwrite (path2, _tcslen (path2), sizeof (TCHAR), zcache);
+    fwrite (&lf, 1, sizeof (TCHAR), zcache);
 
-    fwrite (cs->Name, strlen (cs->Name), 1, zcache);
-    fwrite (&lf, 1, 1, zcache);
-    fwrite (cs->Description, strlen (cs->Description), 1, zcache);
-    fwrite (&lf, 1, 1, zcache);
+    fwrite (cs->Name, _tcslen (cs->Name), sizeof (TCHAR), zcache);
+    fwrite (&lf, 1, sizeof (TCHAR), zcache);
+    fwrite (cs->Description, _tcslen (cs->Description), sizeof (TCHAR), zcache);
+    fwrite (&lf, 1, sizeof (TCHAR), zcache);
 
     if (!cs->Directory) {
-       fwrite (cs->HardwareLink, strlen (cs->HardwareLink), 1, zcache);
-       fwrite (&lf, 1, 1, zcache);
-       fwrite (cs->HostLink, strlen (cs->HostLink), 1, zcache);
-       fwrite (&lf, 1, 1, zcache);
-       sprintf (path2, "%d", cs->Type);
-       fwrite (path2, strlen (path2), 1, zcache);
-       fwrite (&lf, 1, 1, zcache);
+       fwrite (cs->HardwareLink, _tcslen (cs->HardwareLink), sizeof (TCHAR), zcache);
+       fwrite (&lf, 1, sizeof (TCHAR), zcache);
+       fwrite (cs->HostLink, _tcslen (cs->HostLink), sizeof (TCHAR), zcache);
+       fwrite (&lf, 1, sizeof (TCHAR), zcache);
+       _stprintf (path2, L"%d", cs->Type);
+       fwrite (path2, _tcslen (path2), sizeof (TCHAR), zcache);
+       fwrite (&lf, 1, sizeof (TCHAR), zcache);
     }
 
-    fwrite (el, strlen (el), 1, zcache);
+    fwrite (el, _tcslen (el), sizeof (TCHAR), zcache);
 }
 
-static void writeconfigcacherec (FILE *zcache, const char *relpath, struct ConfigStruct *cs)
+static void writeconfigcacherec (FILE *zcache, const TCHAR *relpath, struct ConfigStruct *cs)
 {
     int i;
     
@@ -2453,30 +2408,30 @@ static void writeconfigcacherec (FILE *zcache, const char *relpath, struct Confi
     }
 }
 
-static void writeconfigcache (const char *path)
+static void writeconfigcache (const TCHAR *path)
 {
     int i;
-    char lf = 10;
+    TCHAR lf = 10;
     FILE *zcache;
-    char cachepath[MAX_DPATH];
-    char path2[MAX_DPATH];
+    TCHAR cachepath[MAX_DPATH];
+    TCHAR path2[MAX_DPATH];
     FILETIME t;
     SYSTEMTIME st;
 
     if (!configurationcache)
        return;
     getconfigcache (cachepath, path);
-    zcache = fopen (cachepath, "w");
+    zcache = _tfopen (cachepath, L"w, ccs=UTF-8");
     if (!zcache)
        return;
     t.dwHighDateTime = t.dwLowDateTime = 0;
     GetSystemTime (&st);
     SystemTimeToFileTime (&st, &t);
-    fwrite (configcachever, strlen (configcachever), 1, zcache);
-    fwrite (&lf, 1, 1, zcache);
-    sprintf (path2, "3\n4\n7\n%I64u\n;\n", t);
-    fwrite (path2, strlen (path2), 1, zcache);
-    GetFullPathName (path, sizeof path2, path2, NULL);
+    fwrite (configcachever, _tcslen (configcachever), sizeof (TCHAR), zcache);
+    fwrite (&lf, 1, sizeof (TCHAR), zcache);
+    _stprintf (path2, L"3\n4\n7\n%I64u\n;\n", t);
+    fwrite (path2, _tcslen (path2), sizeof (TCHAR), zcache);
+    GetFullPathName (path, sizeof path2 / sizeof (TCHAR), path2, NULL);
     for (i = 0; i < configstoresize; i++) {
        struct ConfigStruct *cs = configstore[i];
        if (cs->Directory && cs->Parent == NULL)
@@ -2488,15 +2443,15 @@ static void writeconfigcache (const char *path)
            writeconfigcacheentry (zcache, path2, cs);
     }
     fclose (zcache);
-    write_log ("'%s' created\n", cachepath);
+    write_log (L"'%s' created\n", cachepath);
 }
 
 static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int usedirs, int *level, int flushcache)
 {
     DWORD num_bytes = 0;
-    char path[MAX_DPATH];
-    char path2[MAX_DPATH];
-    char shortpath[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
+    TCHAR path2[MAX_DPATH];
+    TCHAR shortpath[MAX_DPATH];
     WIN32_FIND_DATA find_data;
     struct ConfigStruct *config, *first;
     HANDLE handle;
@@ -2507,12 +2462,12 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
     first = NULL;
     GetConfigPath (path, configparent, FALSE);
     GetConfigPath (shortpath, configparent, TRUE);
-    strcpy (path2, path);
-    strncat (path2, "*.*", MAX_DPATH);
+    _tcscpy (path2, path);
+    _tcsncat (path2, L"*.*", MAX_DPATH);
 
     if (*level == 0) {
        if (flushcache) {
-           char cachepath[MAX_DPATH];
+           TCHAR cachepath[MAX_DPATH];
            getconfigcache (cachepath, path);
            flushconfigcache (cachepath);
        }
@@ -2536,22 +2491,22 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
     }
     for (;;) {
        config = NULL;
-       if (strcmp (find_data.cFileName, ".") && strcmp (find_data.cFileName, "..")) {
+       if (_tcscmp (find_data.cFileName, L".") && _tcscmp (find_data.cFileName, L"..")) {
            int ok = 0;
            config = AllocConfigStruct ();
-           strcpy (config->Path, shortpath);
-           strcpy (config->Fullpath, path);
+           _tcscpy (config->Path, shortpath);
+           _tcscpy (config->Fullpath, path);
            memcpy (&config->t, &find_data.ftLastWriteTime, sizeof (FILETIME));
            if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && usedirs) {
                if ((*level) < 2) {
                    struct ConfigStruct *child;
-                   strcpy (config->Name, find_data.cFileName);
-                   strcpy (config->Path, shortpath);
-                   strcat (config->Path, config->Name);
-                   strcat (config->Path, "\\");
-                   strcpy (config->Fullpath, path);
-                   strcat (config->Fullpath, config->Name);
-                   strcat (config->Fullpath, "\\");
+                   _tcscpy (config->Name, find_data.cFileName);
+                   _tcscpy (config->Path, shortpath);
+                   _tcscat (config->Path, config->Name);
+                   _tcscat (config->Path, L"\\");
+                   _tcscpy (config->Fullpath, path);
+                   _tcscat (config->Fullpath, config->Name);
+                   _tcscat (config->Fullpath, L"\\");
                    config->Directory = 1;
                    (*level)++;
                    config->Parent = configparent;
@@ -2563,12 +2518,12 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
                    ok = 1;
                }
            } else if (!(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
-               char path3[MAX_DPATH];
-               if (strlen (find_data.cFileName) > 4 && !strcasecmp (find_data.cFileName + strlen (find_data.cFileName) - 4, ".uae")) {
-                   strcpy (path3, path);
-                   strncat (path3, find_data.cFileName, MAX_DPATH);
+               TCHAR path3[MAX_DPATH];
+               if (_tcslen (find_data.cFileName) > 4 && !strcasecmp (find_data.cFileName + _tcslen (find_data.cFileName) - 4, L".uae")) {
+                   _tcscpy (path3, path);
+                   _tcsncat (path3, find_data.cFileName, MAX_DPATH);
                    if (cfgfile_get_description (path3, config->Description, config->HostLink, config->HardwareLink, &config->Type)) {
-                       strcpy (config->Name, find_data.cFileName);
+                       _tcscpy (config->Name, find_data.cFileName);
                        ok = 1;
                    }
                }
@@ -2605,52 +2560,52 @@ static struct ConfigStruct *GetConfigs (struct ConfigStruct *configparent, int u
 static struct ConfigStruct *CreateConfigStore (struct ConfigStruct *oldconfig, int flushcache)
 {
     int level, i;
-    char path[MAX_DPATH], name[MAX_DPATH];
+    TCHAR path[MAX_DPATH], name[MAX_DPATH];
     struct ConfigStruct *cs;
 
     if (oldconfig) {
-       strcpy (path, oldconfig->Path);
-       strcpy (name, oldconfig->Name);
+       _tcscpy (path, oldconfig->Path);
+       _tcscpy (name, oldconfig->Name);
     }
     level = 0;
     GetConfigs (NULL, 1, &level, flushcache);
     if (oldconfig) {
        for (i = 0; i < configstoresize; i++) {
            cs = configstore[i];
-           if (!cs->Directory && !strcmp (path, cs->Path) && !strcmp (name, cs->Name))
+           if (!cs->Directory && !_tcscmp (path, cs->Path) && !_tcscmp (name, cs->Name))
                return cs;
        }
     }
     return 0;
 }
 
-static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *config, char *newpath)
+static TCHAR *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *config, TCHAR *newpath)
 {
-    char name[MAX_DPATH], desc[MAX_DPATH];
-    char path[MAX_DPATH];
-    static char full_path[MAX_DPATH];
+    TCHAR name[MAX_DPATH], desc[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
+    static TCHAR full_path[MAX_DPATH];
 
     full_path[0] = 0;
     name[0] = 0;
     desc[0] = 0;
     GetDlgItemText (hDlg, IDC_EDITNAME, name, MAX_DPATH);
-    strcpy (config_filename, name);
+    _tcscpy (config_filename, name);
     if (flag == CONFIG_SAVE_FULL || flag == CONFIG_SAVE) {
-       if (strlen (name) < 4 || strcasecmp (name + strlen (name) - 4, ".uae")) {
-           strcat (name, ".uae");
+       if (_tcslen (name) < 4 || strcasecmp (name + _tcslen (name) - 4, L".uae")) {
+           _tcscat (name, L".uae");
            SetDlgItemText (hDlg, IDC_EDITNAME, name);
        }
        if (config)
-           strcpy (config->Name, name);
+           _tcscpy (config->Name, name);
     }
     GetDlgItemText (hDlg, IDC_EDITDESCRIPTION, desc, MAX_DPATH);
     if (config) {
-       strcpy (path, config->Fullpath);
+       _tcscpy (path, config->Fullpath);
     } else {
-       fetch_configurationpath (path, sizeof (path));
+       fetch_configurationpath (path, sizeof (path) / sizeof (TCHAR));
     }
-    strncat (path, name, MAX_DPATH);
-    strcpy (full_path, path);
+    _tcsncat (path, name, MAX_DPATH);
+    _tcscpy (full_path, path);
     switch (flag)
     {
        case CONFIG_SAVE_FULL:
@@ -2663,24 +2618,24 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf
        break;
 
        case CONFIG_SAVE:
-           if (strlen (name) == 0 || strcmp (name, ".uae") == 0) {
-               char szMessage[MAX_DPATH];
+           if (_tcslen (name) == 0 || _tcscmp (name, L".uae") == 0) {
+               TCHAR szMessage[MAX_DPATH];
                WIN32GUI_LoadUIString(IDS_MUSTENTERNAME, szMessage, MAX_DPATH);
                pre_gui_message (szMessage);
            } else {
-               strcpy (workprefs.description, desc);
+               _tcscpy (workprefs.description, desc);
                cfgfile_save (&workprefs, path, configtypepanel);
            }
        break;
 
        case CONFIG_LOAD:
-           if (strlen (name) == 0) {
-               char szMessage[MAX_DPATH];
+           if (_tcslen (name) == 0) {
+               TCHAR szMessage[MAX_DPATH];
                WIN32GUI_LoadUIString (IDS_MUSTSELECTCONFIG, szMessage, MAX_DPATH);
                pre_gui_message (szMessage);
            } else {
                if (target_cfgfile_load (&workprefs, path, configtypepanel, 0) == 0) {
-                   char szMessage[MAX_DPATH];
+                   TCHAR szMessage[MAX_DPATH];
                    WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH);
                    pre_gui_message (szMessage);
                    config_filename[0] = 0;
@@ -2691,20 +2646,20 @@ static char *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *conf
        break;
 
        case CONFIG_DELETE:
-           if (strlen (name) == 0) {
-               char szMessage[MAX_DPATH];
+           if (_tcslen (name) == 0) {
+               TCHAR szMessage[MAX_DPATH];
                WIN32GUI_LoadUIString (IDS_MUSTSELECTCONFIGFORDELETE, szMessage, MAX_DPATH);
                pre_gui_message (szMessage);
            } else {
-               char szMessage[MAX_DPATH];
-               char szTitle[MAX_DPATH];
+               TCHAR szMessage[MAX_DPATH];
+               TCHAR szTitle[MAX_DPATH];
                WIN32GUI_LoadUIString (IDS_DELETECONFIGCONFIRMATION, szMessage, MAX_DPATH);
                WIN32GUI_LoadUIString (IDS_DELETECONFIGTITLE, szTitle, MAX_DPATH );
                if (MessageBox (hDlg, szMessage, szTitle,
                    MB_YESNO | MB_ICONWARNING | MB_APPLMODAL | MB_SETFOREGROUND) == IDYES) {
                    cfgfile_backup (path);
                    DeleteFile (path);
-                   write_log ("deleted config '%s'\n", path);
+                   write_log (L"deleted config '%s'\n", path);
                    config_filename[0] = 0;
                }
            }
@@ -2720,7 +2675,7 @@ static int disk_in_drive (int entry)
 {
     int i;
     for (i = 0; i < 4; i++) {
-       if (strlen (workprefs.dfxlist[entry]) > 0 && !strcmp (workprefs.dfxlist[entry], workprefs.df[i]))
+       if (_tcslen (workprefs.dfxlist[entry]) > 0 && !_tcscmp (workprefs.dfxlist[entry], workprefs.df[i]))
            return i;
     }
     return -1;
@@ -2741,8 +2696,8 @@ static int disk_swap (int entry, int mode)
            return 1;
        }
 
-       if (strcmp (workprefs.df[drv], currprefs.df[drv])) {
-           strcpy (workprefs.df[drv], currprefs.df[drv]);
+       if (_tcscmp (workprefs.df[drv], currprefs.df[drv])) {
+           _tcscpy (workprefs.df[drv], currprefs.df[drv]);
            disk_insert (drv, workprefs.df[drv]);
        } else {
            workprefs.df[drv][0] = 0;
@@ -2752,7 +2707,7 @@ static int disk_swap (int entry, int mode)
            while (drv < 4 && drvs[drv] >= 0)
                drv++;
            if (drv < 4 && workprefs.dfxtype[drv] >= 0) {
-               strcpy (workprefs.df[drv], workprefs.dfxlist[entry]);
+               _tcscpy (workprefs.df[drv], workprefs.dfxlist[entry]);
                disk_insert (drv, workprefs.df[drv]);
            }
        }
@@ -2760,12 +2715,12 @@ static int disk_swap (int entry, int mode)
     }
     for (i = 0; i < 4; i++) {
        if (drvs[i] < 0 && workprefs.dfxtype[i] >= 0) {
-           strcpy (workprefs.df[i], workprefs.dfxlist[entry]);
+           _tcscpy (workprefs.df[i], workprefs.dfxlist[entry]);
            disk_insert (i, workprefs.df[i]);
            return 1;
        }
     }
-    strcpy (workprefs.df[0], workprefs.dfxlist[entry]);
+    _tcscpy (workprefs.df[0], workprefs.dfxlist[entry]);
     disk_insert (0, workprefs.df[0]);
     return 1;
 }
@@ -2776,17 +2731,17 @@ static int input_selected_event, input_selected_sub_num;
 static void set_lventry_input (HWND list, int index)
 {
     int flags, i, sub;
-    char name[256];
-    char custom[MAX_DPATH];
-    char af[10];
+    TCHAR name[256];
+    TCHAR custom[MAX_DPATH];
+    TCHAR af[10];
 
     inputdevice_get_mapped_name (input_selected_device, index, &flags, name, custom, input_selected_sub_num);
     if (flags & IDEV_MAPPED_AUTOFIRE_SET)
-       WIN32GUI_LoadUIString (IDS_YES, af, sizeof (af));
+       WIN32GUI_LoadUIString (IDS_YES, af, sizeof (af) / sizeof (TCHAR));
     else if (flags & IDEV_MAPPED_AUTOFIRE_POSSIBLE)
-       WIN32GUI_LoadUIString (IDS_NO, af, sizeof (af));
+       WIN32GUI_LoadUIString (IDS_NO, af, sizeof (af) / sizeof (TCHAR));
     else
-       strcpy (af,"-");
+       _tcscpy (af, L"-");
     ListView_SetItemText(list, index, 1, custom[0] ? custom : name);
     ListView_SetItemText(list, index, 2, af);
     sub = 0;
@@ -2794,7 +2749,7 @@ static void set_lventry_input (HWND list, int index)
        if (inputdevice_get_mapped_name (input_selected_device, index, &flags, name, custom, i) || custom[0])
            sub++;
     }
-    sprintf (name, "%d", sub);
+    _stprintf (name, L"%d", sub);
     ListView_SetItemText(list, index, 3, name);
 }
 
@@ -2831,22 +2786,22 @@ void InitializeListView (HWND hDlg)
     LV_ITEM lvstruct;
     LV_COLUMN lvcolumn;
     RECT rect;
-    char column_heading[HARDDISK_COLUMNS][MAX_COLUMN_HEADING_WIDTH];
-    char blocksize_str[6] = "";
-    char readwrite_str[10] = "";
-    char size_str[32] = "";
-    char volname_str[MAX_DPATH] = "";
-    char devname_str[MAX_DPATH] = "";
-    char bootpri_str[6] = "";
+    TCHAR column_heading[HARDDISK_COLUMNS][MAX_COLUMN_HEADING_WIDTH];
+    TCHAR blocksize_str[6] = L"";
+    TCHAR readwrite_str[10] = L"";
+    TCHAR size_str[32] = L"";
+    TCHAR volname_str[MAX_DPATH] = L"";
+    TCHAR devname_str[MAX_DPATH] = L"";
+    TCHAR bootpri_str[6] = L"";
     int width = 0;
     int items = 0, result = 0, i, j, entry = 0, temp = 0;
-    char tmp[10], tmp2[MAX_DPATH];
+    TCHAR tmp[10], tmp2[MAX_DPATH];
     int listview_column_width[HARDDISK_COLUMNS];
 
     if (hDlg == pages[HARDDISK_ID]) {
        listview_num_columns = HARDDISK_COLUMNS;
        lv_type = LV_HARDDISK;
-       strcpy (column_heading[0], "*");
+       _tcscpy (column_heading[0], L"*");
        WIN32GUI_LoadUIString(IDS_DEVICE, column_heading[1], MAX_COLUMN_HEADING_WIDTH);
        WIN32GUI_LoadUIString(IDS_VOLUME, column_heading[2], MAX_COLUMN_HEADING_WIDTH);
        WIN32GUI_LoadUIString(IDS_PATH, column_heading[3], MAX_COLUMN_HEADING_WIDTH);
@@ -2861,18 +2816,18 @@ void InitializeListView (HWND hDlg)
        WIN32GUI_LoadUIString(IDS_INPUTHOSTWIDGET, column_heading[0], MAX_COLUMN_HEADING_WIDTH);
        WIN32GUI_LoadUIString(IDS_INPUTAMIGAEVENT, column_heading[1], MAX_COLUMN_HEADING_WIDTH);
        WIN32GUI_LoadUIString(IDS_INPUTAUTOFIRE, column_heading[2], MAX_COLUMN_HEADING_WIDTH);
-       strcpy (column_heading[3], "#");
+       _tcscpy (column_heading[3], L"#");
        list = GetDlgItem(hDlg, IDC_INPUTLIST);
     } else if (hDlg == pages[MISC2_ID]) {
        listview_num_columns = MISC2_COLUMNS;
        lv_type = LV_MISC2;
-       strcpy (column_heading[0], "Extension");
-       strcpy (column_heading[1], "");
+       _tcscpy (column_heading[0], L"Extension");
+       _tcscpy (column_heading[1], L"");
        list = GetDlgItem (hDlg, IDC_ASSOCIATELIST);
     } else {
        listview_num_columns = DISK_COLUMNS;
        lv_type = LV_DISK;
-       strcpy (column_heading[0], "#");
+       _tcscpy (column_heading[0], L"#");
        WIN32GUI_LoadUIString(IDS_DISK_IMAGENAME, column_heading[1], MAX_COLUMN_HEADING_WIDTH);
        WIN32GUI_LoadUIString(IDS_DISK_DRIVENAME, column_heading[2], MAX_COLUMN_HEADING_WIDTH);
        list = GetDlgItem (hDlg, IDC_DISK);
@@ -2906,11 +2861,11 @@ void InitializeListView (HWND hDlg)
            lvstruct.iItem    = i;
            lvstruct.iSubItem = 0;
            result = ListView_InsertItem (list, &lvstruct);
-           ListView_SetItemText (list, result, 1, exts[i].enabled ? "*" : "");
+           ListView_SetItemText (list, result, 1, exts[i].enabled ? L"*" : L"");
        }
     } else if (lv_type == LV_INPUT) {
        for (i = 0; input_total_devices && i < inputdevice_get_widget_num (input_selected_device); i++) {
-           char name[100];
+           TCHAR name[100];
            inputdevice_get_widget_type (input_selected_device, i, name);
            lvstruct.mask     = LVIF_TEXT | LVIF_PARAM;
            lvstruct.pszText  = name;
@@ -2930,15 +2885,15 @@ void InitializeListView (HWND hDlg)
     } else if (lv_type == LV_DISK) {
        for (i = 0; i < MAX_SPARE_DRIVES; i++) {
            int drv;
-           sprintf (tmp, "%d", i + 1);
+           _stprintf (tmp, L"%d", i + 1);
            lvstruct.mask     = LVIF_TEXT | LVIF_PARAM;
            lvstruct.pszText  = tmp;
            lvstruct.lParam   = 0;
            lvstruct.iItem    = i;
            lvstruct.iSubItem = 0;
            result = ListView_InsertItem (list, &lvstruct);
-           strcpy (tmp2, workprefs.dfxlist[i]);
-           j = strlen (tmp2) - 1;
+           _tcscpy (tmp2, workprefs.dfxlist[i]);
+           j = _tcslen (tmp2) - 1;
            if (j < 0)
                j = 0;
            while (j > 0) {
@@ -2952,7 +2907,7 @@ void InitializeListView (HWND hDlg)
            drv = disk_in_drive (i);
            tmp[0] = 0;
            if (drv >= 0)
-               sprintf (tmp, "DF%d:", drv);
+               _stprintf (tmp, L"DF%d:", drv);
            ListView_SetItemText (list, result, 2, tmp);
            width = ListView_GetStringWidth (list, lvstruct.pszText) + 15;
            if (width > listview_column_width[0])
@@ -2970,7 +2925,7 @@ void InitializeListView (HWND hDlg)
            struct uaedev_config_info *uci = &workprefs.mountconfig[i];
            int nosize = 0, type;
            struct mountedinfo mi;
-           char *rootdir = uci->rootdir;
+           TCHAR *rootdir = uci->rootdir;
 
            type = get_filesys_unitconfig (&workprefs, i, &mi);
            if (type < 0) {
@@ -2979,58 +2934,58 @@ void InitializeListView (HWND hDlg)
            }
 
            if (nosize)
-               strcpy (size_str, "n/a");
+               _tcscpy (size_str, L"n/a");
            else if (mi.size >= 1024 * 1024 * 1024)
-               sprintf (size_str, "%.1fG", ((double)(uae_u32)(mi.size / (1024 * 1024))) / 1024.0);
+               _stprintf (size_str, L"%.1fG", ((double)(uae_u32)(mi.size / (1024 * 1024))) / 1024.0);
            else if (mi.size < 10 * 1024 * 1024)
-               sprintf (size_str, "%dK", mi.size / 1024);
+               _stprintf (size_str, L"%dK", mi.size / 1024);
            else
-               sprintf (size_str, "%.1fM", ((double)(uae_u32)(mi.size / (1024))) / 1024.0);
+               _stprintf (size_str, L"%.1fM", ((double)(uae_u32)(mi.size / (1024))) / 1024.0);
 
            if (uci->controller >= HD_CONTROLLER_IDE0 && uci->controller <= HD_CONTROLLER_IDE3) {
-               sprintf (blocksize_str, "%d", uci->blocksize);
-               sprintf (devname_str, "*IDE%d*", uci->controller - HD_CONTROLLER_IDE0);
-               strcpy (volname_str, "n/a");
-               strcpy (bootpri_str, "n/a");
+               _stprintf (blocksize_str, L"%d", uci->blocksize);
+               _stprintf (devname_str, L"*IDE%d*", uci->controller - HD_CONTROLLER_IDE0);
+               _tcscpy (volname_str, L"n/a");
+               _tcscpy (bootpri_str, L"n/a");
            } else if (uci->controller >= HD_CONTROLLER_SCSI0 && uci->controller <= HD_CONTROLLER_SCSI6) {
-               sprintf (blocksize_str, "%d", uci->blocksize);
-               sprintf (devname_str, "*SCSI%d*", uci->controller - HD_CONTROLLER_SCSI0);
-               strcpy (volname_str, "n/a");
-               strcpy (bootpri_str, "n/a");
+               _stprintf (blocksize_str, L"%d", uci->blocksize);
+               _stprintf (devname_str, L"*SCSI%d*", uci->controller - HD_CONTROLLER_SCSI0);
+               _tcscpy (volname_str, L"n/a");
+               _tcscpy (bootpri_str, L"n/a");
            } else if (uci->controller == HD_CONTROLLER_PCMCIA_SRAM) {
-               strcpy (blocksize_str, "n/a");
-               strcpy(devname_str, "*SCSRAM*");
-               strcpy (volname_str, "n/a");
-               strcpy (bootpri_str, "n/a");
+               _tcscpy (blocksize_str, L"n/a");
+               _tcscpy(devname_str, L"*SCSRAM*");
+               _tcscpy (volname_str, L"n/a");
+               _tcscpy (bootpri_str, L"n/a");
            } else if (type == FILESYS_HARDFILE) {
-               sprintf (blocksize_str, "%d", uci->blocksize);
-               strcpy (devname_str, uci->devname);
-               strcpy (volname_str, "n/a");
-               sprintf (bootpri_str, "%d", uci->bootpri);
+               _stprintf (blocksize_str, L"%d", uci->blocksize);
+               _tcscpy (devname_str, uci->devname);
+               _tcscpy (volname_str, L"n/a");
+               _stprintf (bootpri_str, L"%d", uci->bootpri);
            } else if (type == FILESYS_HARDFILE_RDB || type == FILESYS_HARDDRIVE || uci->controller) {
-               sprintf (blocksize_str, "%d", uci->blocksize);
-               strcpy (devname_str, "n/a");
-               strcpy (volname_str, "n/a");
-               strcpy (bootpri_str, "n/a");
-               if (!memcmp (rootdir, "HD_", 3))
+               _stprintf (blocksize_str, L"%d", uci->blocksize);
+               _tcscpy (devname_str, L"n/a");
+               _tcscpy (volname_str, L"n/a");
+               _tcscpy (bootpri_str, L"n/a");
+               if (!memcmp (rootdir, L"HD_", 3))
                    rootdir += 3;
            } else {
-               strcpy (blocksize_str, "n/a");
-               strcpy (devname_str, uci->devname);
-               strcpy (volname_str, uci->volname);
-               strcpy (size_str, "n/a");
-               sprintf (bootpri_str, "%d", uci->bootpri);
+               _tcscpy (blocksize_str, L"n/a");
+               _tcscpy (devname_str, uci->devname);
+               _tcscpy (volname_str, uci->volname);
+               _tcscpy (size_str, L"n/a");
+               _stprintf (bootpri_str, L"%d", uci->bootpri);
            }
            if (!mi.ismedia) {
-               strcpy (blocksize_str, "n/a");
-               strcpy (size_str, "n/a");
+               _tcscpy (blocksize_str, L"n/a");
+               _tcscpy (size_str, L"n/a");
            }
-           WIN32GUI_LoadUIString (uci->readonly ? IDS_NO : IDS_YES, readwrite_str, sizeof (readwrite_str));
+           WIN32GUI_LoadUIString (uci->readonly ? IDS_NO : IDS_YES, readwrite_str, sizeof (readwrite_str) / sizeof (TCHAR));
 
            lvstruct.mask     = LVIF_TEXT | LVIF_PARAM;
-           lvstruct.pszText  = mi.ismedia == 0 ? "E" : (nosize ? "X" : (mi.ismounted ? "*" : " "));
+           lvstruct.pszText  = mi.ismedia == 0 ? L"E" : (nosize ? L"X" : (mi.ismounted ? L"*" : L" "));
            if (uci->controller)
-               lvstruct.pszText = " ";
+               lvstruct.pszText = L" ";
            lvstruct.lParam   = 0;
            lvstruct.iItem    = i;
            lvstruct.iSubItem = 0;
@@ -3192,12 +3147,12 @@ static INT_PTR CALLBACK InfoSettingsProc (HWND hDlg, UINT msg, WPARAM wParam, LP
     return FALSE;
 }
 
-static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *name, char *desc, char *path, int isdir, int expand, HTREEITEM parent)
+static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, TCHAR *name, TCHAR *desc, TCHAR *path, int isdir, int expand, HTREEITEM parent)
 {
     TVINSERTSTRUCT is;
     HWND TVhDlg;
-    char s[MAX_DPATH] = "";
-    char file_name[MAX_DPATH], file_path[MAX_DPATH];
+    TCHAR s[MAX_DPATH] = L"";
+    TCHAR file_name[MAX_DPATH], file_path[MAX_DPATH];
 
     GetDlgItemText (hDlg, IDC_EDITNAME, file_name, MAX_DPATH);
     GetDlgItemText (hDlg, IDC_EDITPATH, file_path, MAX_DPATH);
@@ -3206,12 +3161,12 @@ static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *na
     is.hInsertAfter = isdir < 0 ? TVI_ROOT : TVI_SORT;
     is.hParent = parent;
     is.itemex.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
-    if (!strcmp (file_name, name) && !strcmp (file_path, path)) {
+    if (!_tcscmp (file_name, name) && !_tcscmp (file_path, path)) {
        is.itemex.state |= TVIS_SELECTED;
        is.itemex.stateMask |= TVIS_SELECTED;
     }
     if (isdir) {
-       strcat (s, " ");
+       _tcscat (s, L" ");
        is.itemex.state |= TVIS_BOLD;
        is.itemex.stateMask |= TVIS_BOLD;
     }
@@ -3219,13 +3174,13 @@ static HTREEITEM AddConfigNode (HWND hDlg, struct ConfigStruct *config, char *na
        is.itemex.state |= TVIS_EXPANDED;
        is.itemex.stateMask |= TVIS_EXPANDED;
     }
-    strcat (s, name);
-    if (strlen (s) > 4 && !stricmp (s + strlen (s) - 4, ".uae"))
-       s[strlen(s) - 4] = 0;
-    if (desc && strlen(desc) > 0) {
-       strcat (s, " (");
-       strcat (s, desc);
-       strcat (s, ")");
+    _tcscat (s, name);
+    if (_tcslen (s) > 4 && !_tcsicmp (s + _tcslen (s) - 4, L".uae"))
+       s[_tcslen (s) - 4] = 0;
+    if (desc && _tcslen (desc) > 0) {
+       _tcscat (s, L" (");
+       _tcscat (s, desc);
+       _tcscat (s, L")");
     }
     is.itemex.pszText = s;
     is.itemex.iImage = is.itemex.iSelectedImage = isdir > 0 ? 0 : (isdir < 0) ? 2 : 1;
@@ -3293,25 +3248,25 @@ static void InitializeConfig (HWND hDlg, struct ConfigStruct *config)
     int i, j, idx1, idx2;
 
     if (config == NULL) {
-       SetDlgItemText (hDlg, IDC_EDITNAME, "");
-       SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, "");
+       SetDlgItemText (hDlg, IDC_EDITNAME, L"");
+       SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, L"");
     } else {
        SetDlgItemText (hDlg, IDC_EDITNAME, config->Name);
        SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, config->Description);
     }
     SendDlgItemMessage (hDlg, IDC_CONFIGLINK, CB_RESETCONTENT, 0, 0L);
-    SendDlgItemMessage (hDlg, IDC_CONFIGLINK, CB_ADDSTRING, 0, (LPARAM)"");
+    SendDlgItemMessage (hDlg, IDC_CONFIGLINK, CB_ADDSTRING, 0, (LPARAM)L"");
     idx1 = 1;
     idx2 = 0;
     for (j = 0; j < 2; j++) {
        for (i = 0; i < configstoresize; i++) {
            struct ConfigStruct *cs = configstore[i];
            if ((j == 0 && cs->Type == CONFIG_TYPE_HOST) || (j == 1 && cs->Type == CONFIG_TYPE_HARDWARE)) {
-               char tmp2[MAX_DPATH];
-               strcpy (tmp2, configstore[i]->Path);
-               strncat (tmp2, configstore[i]->Name, MAX_DPATH);
+               TCHAR tmp2[MAX_DPATH];
+               _tcscpy (tmp2, configstore[i]->Path);
+               _tcsncat (tmp2, configstore[i]->Name, MAX_DPATH);
                SendDlgItemMessage (hDlg, IDC_CONFIGLINK, CB_ADDSTRING, 0, (LPARAM)tmp2);
-               if (config && (!strcmpi (tmp2, config->HardwareLink) || !strcmpi (tmp2, config->HostLink)))
+               if (config && (!_tcsicmp (tmp2, config->HardwareLink) || !_tcsicmp (tmp2, config->HostLink)))
                    idx2 = idx1;
                idx1++;
            }
@@ -3334,15 +3289,15 @@ static HTREEITEM InitializeConfigTreeView (HWND hDlg)
     HIMAGELIST himl = ImageList_Create (16, 16, ILC_COLOR8 | ILC_MASK, 3, 0);
     HWND TVhDlg = GetDlgItem(hDlg, IDC_CONFIGTREE);
     HTREEITEM parent;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
 
     if (himl) {
        HICON icon;
-       icon = LoadIcon (hInst, (LPCSTR)MAKEINTRESOURCE(IDI_FOLDER));
+       icon = LoadIcon (hInst, (LPCWSTR)MAKEINTRESOURCE(IDI_FOLDER));
        ImageList_AddIcon (himl, icon);
-       icon = LoadIcon (hInst, (LPCSTR)MAKEINTRESOURCE(IDI_CONFIGFILE));
+       icon = LoadIcon (hInst, (LPCWSTR)MAKEINTRESOURCE(IDI_CONFIGFILE));
        ImageList_AddIcon (himl, icon);
-       icon = LoadIcon (hInst, (LPCSTR)MAKEINTRESOURCE(IDI_ROOT));
+       icon = LoadIcon (hInst, (LPCWSTR)MAKEINTRESOURCE(IDI_ROOT));
        ImageList_AddIcon (himl, icon);
        TreeView_SetImageList (TVhDlg, himl, TVSIL_NORMAL);
     }
@@ -3356,9 +3311,9 @@ static HTREEITEM InitializeConfigTreeView (HWND hDlg)
 static void ConfigToRegistry (struct ConfigStruct *config, int type)
 {
     if (config) {
-       char path[MAX_DPATH];
-       strcpy (path, config->Path);
-       strncat (path, config->Name, MAX_DPATH);
+       TCHAR path[MAX_DPATH];
+       _tcscpy (path, config->Path);
+       _tcsncat (path, config->Name, MAX_DPATH);
        regsetstr (NULL, configreg[type], path);
     }
 }
@@ -3367,7 +3322,7 @@ static void ConfigToRegistry2 (DWORD ct, int type, DWORD noauto)
     if (type > 0)
        regsetint (NULL, configreg2[type], ct);
     if (noauto == 0 || noauto == 1)
-       regsetint (NULL, "ConfigFile_NoAuto", noauto);
+       regsetint (NULL, L"ConfigFile_NoAuto", noauto);
 }
 
 static void checkautoload (HWND        hDlg, struct ConfigStruct *config)
@@ -3382,7 +3337,7 @@ static void checkautoload (HWND   hDlg, struct ConfigStruct *config)
     }
     CheckDlgButton(hDlg, IDC_CONFIGAUTO, ct ? BST_CHECKED : BST_UNCHECKED);
     ew (hDlg, IDC_CONFIGAUTO, configtypepanel > 0 && config && !config->Directory ? TRUE : FALSE);
-    regqueryint (NULL, "ConfigFile_NoAuto", &ct);
+    regqueryint (NULL, L"ConfigFile_NoAuto", &ct);
     CheckDlgButton(hDlg, IDC_CONFIGNOLINK, ct ? BST_CHECKED : BST_UNCHECKED);
 }
 
@@ -3408,12 +3363,12 @@ static struct ConfigStruct *fixloadconfig (HWND hDlg, struct ConfigStruct *confi
 static struct ConfigStruct *initloadsave (HWND hDlg, struct ConfigStruct *config)
 {
     HTREEITEM root;
-    char name_buf[MAX_DPATH];
-    DWORD dwRFPsize = sizeof (name_buf);
-    char path[MAX_DPATH];
+    TCHAR name_buf[MAX_DPATH];
+    DWORD dwRFPsize = sizeof (name_buf) / sizeof (TCHAR);
+    TCHAR path[MAX_DPATH];
 
     EnableWindow (GetDlgItem (hDlg, IDC_VIEWINFO), workprefs.info[0]);
-    SetDlgItemText (hDlg, IDC_EDITPATH, "");
+    SetDlgItemText (hDlg, IDC_EDITPATH, L"");
     SetDlgItemText (hDlg, IDC_EDITDESCRIPTION, workprefs.description);
     root = InitializeConfigTreeView (hDlg);
     if (regquerystr (NULL, configreg[configtypepanel], name_buf, &dwRFPsize)) {
@@ -3433,7 +3388,7 @@ static struct ConfigStruct *initloadsave (HWND hDlg, struct ConfigStruct *config
     return config;
 }
 
-static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **configp, char **pcfgfile, char *newpath)
+static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **configp, TCHAR **pcfgfile, TCHAR *newpath)
 {
     struct ConfigStruct *config = *configp;
     switch (LOWORD (wParam))
@@ -3487,11 +3442,11 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **co
         break;
         case IDC_VIEWINFO:
            if (workprefs.info[0]) {
-               char name_buf[MAX_DPATH];
-               if (strstr (workprefs.info, "Configurations\\"))
-                   sprintf (name_buf, "%s\\%s", start_path_data, workprefs.info);
+               TCHAR name_buf[MAX_DPATH];
+               if (_tcsstr (workprefs.info, L"Configurations\\"))
+                   _stprintf (name_buf, L"%s\\%s", start_path_data, workprefs.info);
                else
-                   strcpy (name_buf, workprefs.info);
+                   _tcscpy (name_buf, workprefs.info);
                ShellExecute (NULL, NULL, name_buf, NULL, NULL, SW_SHOWNORMAL);
            }
         break;
@@ -3514,14 +3469,14 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **co
         case IDC_CONFIGLINK:
            if (HIWORD (wParam) == CBN_SELCHANGE || HIWORD (wParam) == CBN_KILLFOCUS)  {
                LRESULT val;
-               char tmp[MAX_DPATH];
+               TCHAR tmp[MAX_DPATH];
                tmp[0] = 0;
                val = SendDlgItemMessage (hDlg, IDC_CONFIGLINK, CB_GETCURSEL, 0, 0L);
                if (val == CB_ERR)
-                   SendDlgItemMessage (hDlg, IDC_CONFIGLINK, WM_GETTEXT, (WPARAM)sizeof(tmp), (LPARAM)tmp);
+                   SendDlgItemMessage (hDlg, IDC_CONFIGLINK, WM_GETTEXT, (WPARAM)sizeof(tmp) / sizeof (TCHAR), (LPARAM)tmp);
                else
                    SendDlgItemMessage (hDlg, IDC_CONFIGLINK, CB_GETLBTEXT, (WPARAM)val, (LPARAM)tmp);
-               strcpy (workprefs.config_host_path, tmp);
+               _tcscpy (workprefs.config_host_path, tmp);
            }
         break;
     }
@@ -3530,7 +3485,7 @@ static void loadsavecommands (HWND hDlg, WPARAM wParam, struct ConfigStruct **co
 
 static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-    char *cfgfile = NULL;
+    TCHAR *cfgfile = NULL;
     static int recursive;
     static struct ConfigStruct *config;
 
@@ -3556,7 +3511,7 @@ static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
     {
        int id = GetDlgCtrlID((HWND)wParam);
        if (id == IDC_SAVE || id == IDC_LOAD) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
                loadsavecommands (hDlg, id, &config, &cfgfile, s);
                xfree (s);
@@ -3640,9 +3595,9 @@ static INT_PTR CALLBACK LoadSaveDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
 static INT_PTR CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     CHARFORMAT CharFormat;
-    char szContributors1[MAX_CONTRIBUTORS_LENGTH];
-    char szContributors2[MAX_CONTRIBUTORS_LENGTH];
-    char szContributors[MAX_CONTRIBUTORS_LENGTH * 2];
+    TCHAR szContributors1[MAX_CONTRIBUTORS_LENGTH];
+    TCHAR szContributors2[MAX_CONTRIBUTORS_LENGTH];
+    TCHAR szContributors[MAX_CONTRIBUTORS_LENGTH * 2];
 
     switch (msg) {
      case WM_COMMAND:
@@ -3656,14 +3611,14 @@ static INT_PTR CALLBACK ContributorsProc (HWND hDlg, UINT msg, WPARAM wParam, LP
 
        WIN32GUI_LoadUIString(IDS_CONTRIBUTORS1, szContributors1, MAX_CONTRIBUTORS_LENGTH);
        WIN32GUI_LoadUIString(IDS_CONTRIBUTORS2, szContributors2, MAX_CONTRIBUTORS_LENGTH);
-       sprintf(szContributors, "%s%s", szContributors1, szContributors2);
+       _stprintf (szContributors, L"%s%s", szContributors1, szContributors2);
 
        SetDlgItemText (hDlg, IDC_CONTRIBUTORS, szContributors );
        SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
        CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
        CharFormat.yHeight = 8 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
 
-       strcpy (CharFormat.szFaceName, os_vista ? "Segoe UI" : "Tahoma");
+       _tcscpy (CharFormat.szFaceName, os_vista ? L"Segoe UI" : L"Tahoma");
        SendDlgItemMessage (hDlg, IDC_CONTRIBUTORS, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
        return TRUE;
     }
@@ -3679,23 +3634,23 @@ typedef struct url_info
 {
     int   id;
     BOOL  state;
-    char *display;
-    char *url;
+    TCHAR *display;
+    TCHAR *url;
 } urlinfo;
 
 static urlinfo urls[] =
 {
-    {IDC_CLOANTOHOME, FALSE, "Cloanto's Amiga Forever", "http://www.amigaforever.com/"},
-    {IDC_AMIGAHOME, FALSE, "Amiga Inc.", "http://www.amiga.com"},
-    {IDC_PICASSOHOME, FALSE, "Picasso96 Home Page", "http://www.picasso96.cogito.de/"},
-    {IDC_UAEHOME, FALSE, "UAE Home Page", "http://uae.coresystems.de/"},
-    {IDC_WINUAEHOME, FALSE, "WinUAE Home Page", "http://www.winuae.net/"},
-    {IDC_AIABHOME, FALSE, "AIAB", "http://www.amigainabox.co.uk/"},
-    {IDC_THEROOTS, FALSE, "Back To The Roots", "http://www.back2roots.org/"},
-    {IDC_ABIME, FALSE, "abime.net", "http://www.abime.net/"},
-    {IDC_CAPS, FALSE, "SPS", "http://www.softpres.org/"},
-    {IDC_AMIGASYS, FALSE, "AmigaSYS", "http://amigasys.extra.hu/"},
-    {IDC_AMIKIT, FALSE, "AmiKit", "http://amikit.amiga.sk/"},
+    {IDC_CLOANTOHOME, FALSE, L"Cloanto's Amiga Forever", L"http://www.amigaforever.com/"},
+    {IDC_AMIGAHOME, FALSE, L"Amiga Inc.", L"http://www.amiga.com"},
+    {IDC_PICASSOHOME, FALSE, L"Picasso96 Home Page", L"http://www.picasso96.cogito.de/"},
+    {IDC_UAEHOME, FALSE, L"UAE Home Page", L"http://uae.coresystems.de/"},
+    {IDC_WINUAEHOME, FALSE, L"WinUAE Home Page", L"http://www.winuae.net/"},
+    {IDC_AIABHOME, FALSE, L"AIAB", L"http://www.amigainabox.co.uk/"},
+    {IDC_THEROOTS, FALSE, L"Back To The Roots", L"http://www.back2roots.org/"},
+    {IDC_ABIME, FALSE, L"abime.net", L"http://www.abime.net/"},
+    {IDC_CAPS, FALSE, L"SPS", L"http://www.softpres.org/"},
+    {IDC_AMIGASYS, FALSE, L"AmigaSYS", L"http://amigasys.extra.hu/"},
+    {IDC_AMIKIT, FALSE, L"AmiKit", L"http://amikit.amiga.sk/"},
     { -1, FALSE, NULL, NULL }
 };
 
@@ -3711,7 +3666,7 @@ static void SetupRichText(HWND hDlg, urlinfo *url)
     CharFormat.yHeight = 10 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
 
     CharFormat.crTextColor = GetSysColor(COLOR_ACTIVECAPTION);
-    strcpy (CharFormat.szFaceName, os_vista ? "Segoe UI" : "Tahoma");
+    _tcscpy (CharFormat.szFaceName, os_vista ? L"Segoe UI" : L"Tahoma");
     SendDlgItemMessage(hDlg, url->id, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&CharFormat);
     SendDlgItemMessage(hDlg, url->id, EM_SETBKGNDCOLOR, 0, GetSysColor(COLOR_3DFACE));
 }
@@ -3782,7 +3737,7 @@ static void setac (HWND hDlg, int id)
 }
 static void setautocomplete (HWND hDlg, int id)
 {
-    HWND item = FindWindowEx (GetDlgItem (hDlg, id), NULL, "Edit", NULL);
+    HWND item = FindWindowEx (GetDlgItem (hDlg, id), NULL, L"Edit", NULL);
     if (item)
        SHAutoComplete (item, SHACF_FILESYSTEM | SHACF_AUTOAPPEND_FORCE_ON | SHACF_AUTOSUGGEST_FORCE_ON | SHACF_USETAB);
 }
@@ -3793,47 +3748,47 @@ static void setmultiautocomplete (HWND hDlg, int *ids)
        setautocomplete (hDlg, ids[i]);
 }
 
-static void setpath (HWND hDlg, char *name, DWORD d, char *def)
+static void setpath (HWND hDlg, TCHAR *name, DWORD d, TCHAR *def)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
-    strcpy (tmp, def);
-    fetch_path (name, tmp, sizeof (tmp));
+    _tcscpy (tmp, def);
+    fetch_path (name, tmp, sizeof (tmp) / sizeof (TCHAR));
     SetDlgItemText (hDlg, d, tmp);
 }
 
 static void values_to_pathsdialog (HWND hDlg)
 {
-    setpath (hDlg, "KickstartPath", IDC_PATHS_ROM, "Roms");
-    setpath (hDlg, "ConfigurationPath", IDC_PATHS_CONFIG, "Configurations");
-    setpath (hDlg, "ScreenshotPath", IDC_PATHS_SCREENSHOT, "ScreenShots");
-    setpath (hDlg, "StatefilePath", IDC_PATHS_SAVESTATE, "Savestates");
-    setpath (hDlg, "SaveimagePath", IDC_PATHS_SAVEIMAGE, "SaveImages");
-    setpath (hDlg, "VideoPath", IDC_PATHS_AVIOUTPUT, "Videos");
-    setpath (hDlg, "RipperPath", IDC_PATHS_RIP, ".\\");
+    setpath (hDlg, L"KickstartPath", IDC_PATHS_ROM, L"Roms");
+    setpath (hDlg, L"ConfigurationPath", IDC_PATHS_CONFIG, L"Configurations");
+    setpath (hDlg, L"ScreenshotPath", IDC_PATHS_SCREENSHOT, L"ScreenShots");
+    setpath (hDlg, L"StatefilePath", IDC_PATHS_SAVESTATE, L"Savestates");
+    setpath (hDlg, L"SaveimagePath", IDC_PATHS_SAVEIMAGE, L"SaveImages");
+    setpath (hDlg, L"VideoPath", IDC_PATHS_AVIOUTPUT, L"Videos");
+    setpath (hDlg, L"RipperPath", IDC_PATHS_RIP, L".\\");
 }
 
 static void resetregistry (void)
 {
-    regdeletetree (NULL, "DetectedROMs");
-    regdelete (NULL, "QuickStartMode");
-    regdelete (NULL, "ConfigFile");
-    regdelete (NULL, "ConfigFileHardware");
-    regdelete (NULL, "ConfigFileHost");
-    regdelete (NULL, "ConfigFileHardware_Auto");
-    regdelete (NULL, "ConfigFileHost_Auto");
-    regdelete (NULL, "ConfigurationPath");
-    regdelete (NULL, "SaveimagePath");
-    regdelete (NULL, "ScreenshotPath");
-    regdelete (NULL, "StatefilePath");
-    regdelete (NULL, "VideoPath");
-    regdelete (NULL, "RipperPath");
-    regdelete (NULL, "QuickStartModel");
-    regdelete (NULL, "QuickStartConfiguration");
-    regdelete (NULL, "QuickStartCompatibility");
-    regdelete (NULL, "QuickStartHostConfig");
-    regdelete (NULL, "ConfigurationCache");
-    regdelete (NULL, "DirectDraw_Secondary");
+    regdeletetree (NULL, L"DetectedROMs");
+    regdelete (NULL, L"QuickStartMode");
+    regdelete (NULL, L"ConfigFile");
+    regdelete (NULL, L"ConfigFileHardware");
+    regdelete (NULL, L"ConfigFileHost");
+    regdelete (NULL, L"ConfigFileHardware_Auto");
+    regdelete (NULL, L"ConfigFileHost_Auto");
+    regdelete (NULL, L"ConfigurationPath");
+    regdelete (NULL, L"SaveimagePath");
+    regdelete (NULL, L"ScreenshotPath");
+    regdelete (NULL, L"StatefilePath");
+    regdelete (NULL, L"VideoPath");
+    regdelete (NULL, L"RipperPath");
+    regdelete (NULL, L"QuickStartModel");
+    regdelete (NULL, L"QuickStartConfiguration");
+    regdelete (NULL, L"QuickStartCompatibility");
+    regdelete (NULL, L"QuickStartHostConfig");
+    regdelete (NULL, L"ConfigurationCache");
+    regdelete (NULL, L"DirectDraw_Secondary");
 }
 
 int path_type;
@@ -3844,7 +3799,7 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
     static int recursive;
     static int ptypes[3], numtypes;
     int val, selpath = 0;
-    char tmp[MAX_DPATH], pathmode[32];
+    TCHAR tmp[MAX_DPATH], pathmode[32];
 
     switch (msg)
     {
@@ -3864,33 +3819,33 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        numtypes = 0;
        SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_RESETCONTENT, 0, 0L);
        if (af_path_2005 & 1) {
-           WIN32GUI_LoadUIString (IDS_DEFAULT_AF2005, tmp, sizeof tmp);
+           WIN32GUI_LoadUIString (IDS_DEFAULT_AF2005, tmp, sizeof tmp / sizeof (TCHAR));
            SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
            if (path_type == PATH_TYPE_NEWAF)
                selpath = numtypes;
            ptypes[numtypes++] = PATH_TYPE_NEWAF;
        }
        if (start_path_new1[0]) {
-           WIN32GUI_LoadUIString (IDS_DEFAULT_NEWWINUAE, tmp, sizeof tmp);
+           WIN32GUI_LoadUIString (IDS_DEFAULT_NEWWINUAE, tmp, sizeof tmp / sizeof (TCHAR));
            SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
            if (path_type == PATH_TYPE_NEWWINUAE)
                selpath = numtypes;
            ptypes[numtypes++] = PATH_TYPE_NEWWINUAE;
        }
        if (af_path_2005 & 2) {
-           SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)"AmigaForeverData");
+           SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)L"AmigaForeverData");
            if (path_type == PATH_TYPE_AMIGAFOREVERDATA)
                selpath = numtypes;
            ptypes[numtypes++] = PATH_TYPE_AMIGAFOREVERDATA;
        }
        if (af_path_old) {
-           WIN32GUI_LoadUIString (IDS_DEFAULT_AF, tmp, sizeof tmp);
+           WIN32GUI_LoadUIString (IDS_DEFAULT_AF, tmp, sizeof tmp / sizeof (TCHAR));
            SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
            if (path_type == PATH_TYPE_OLDAF)
                selpath = numtypes;
            ptypes[numtypes++] = PATH_TYPE_OLDAF;
        }
-       WIN32GUI_LoadUIString (IDS_DEFAULT_WINUAE, tmp, sizeof tmp);
+       WIN32GUI_LoadUIString (IDS_DEFAULT_WINUAE, tmp, sizeof tmp / sizeof (TCHAR));
        SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
        if (path_type == 0)
            selpath = numtypes;
@@ -3908,123 +3863,123 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
        switch (LOWORD (wParam))
        {
            case IDC_PATHS_ROMS:
-           fetch_path ("KickstartPath", tmp, sizeof (tmp));
+           fetch_path (L"KickstartPath", tmp, sizeof (tmp) / sizeof (TCHAR));
            if (DirectorySelection (hDlg, &pathsguid, tmp)) {
                load_keyring (&workprefs, NULL);
-               set_path ("KickstartPath", tmp);
+               set_path (L"KickstartPath", tmp);
                if (!scan_roms (1))
                    gui_message_id (IDS_ROMSCANNOROMS);
                values_to_pathsdialog (hDlg);
            }
            break;
            case IDC_PATHS_ROM:
-           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_ROM), tmp, sizeof (tmp));
-           set_path ("KickstartPath", tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_ROM), tmp, sizeof (tmp) / sizeof (TCHAR));
+           set_path (L"KickstartPath", tmp);
            break;
            case IDC_PATHS_CONFIGS:
-           fetch_path ("ConfigurationPath", tmp, sizeof (tmp));
+           fetch_path (L"ConfigurationPath", tmp, sizeof (tmp) / sizeof (TCHAR));
            if (DirectorySelection (hDlg, &pathsguid, tmp)) {
-               set_path ("ConfigurationPath", tmp);
+               set_path (L"ConfigurationPath", tmp);
                values_to_pathsdialog (hDlg);
                FreeConfigStore ();
            }
            break;
            case IDC_PATHS_CONFIG:
-           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_CONFIG), tmp, sizeof (tmp));
-           set_path ("ConfigurationPath", tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_CONFIG), tmp, sizeof (tmp) / sizeof (TCHAR));
+           set_path (L"ConfigurationPath", tmp);
            FreeConfigStore ();
            break;
            case IDC_PATHS_SCREENSHOTS:
-           fetch_path ("ScreenshotPath", tmp, sizeof (tmp));
+           fetch_path (L"ScreenshotPath", tmp, sizeof (tmp) / sizeof (TCHAR));
            if (DirectorySelection (hDlg, &pathsguid, tmp)) {
-               set_path ("ScreenshotPath", tmp);
+               set_path (L"ScreenshotPath", tmp);
                values_to_pathsdialog (hDlg);
            }
            break;
            case IDC_PATHS_SCREENSHOT:
-           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SCREENSHOT), tmp, sizeof (tmp));
-           set_path ("ScreenshotPath", tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SCREENSHOT), tmp, sizeof (tmp) / sizeof (TCHAR));
+           set_path (L"ScreenshotPath", tmp);
            break;
            case IDC_PATHS_SAVESTATES:
-           fetch_path ("StatefilePath", tmp, sizeof (tmp));
+           fetch_path (L"StatefilePath", tmp, sizeof (tmp) / sizeof (TCHAR));
            if (DirectorySelection (hDlg, &pathsguid, tmp)) {
-               set_path ("StatefilePath", tmp);
+               set_path (L"StatefilePath", tmp);
                values_to_pathsdialog (hDlg);
            }
            break;
            case IDC_PATHS_SAVESTATE:
-           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SAVESTATE), tmp, sizeof (tmp));
-           set_path ("StatefilePath", tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SAVESTATE), tmp, sizeof (tmp) / sizeof (TCHAR));
+           set_path (L"StatefilePath", tmp);
            break;
            case IDC_PATHS_SAVEIMAGES:
-           fetch_path ("SaveimagePath", tmp, sizeof (tmp));
+           fetch_path (L"SaveimagePath", tmp, sizeof (tmp) / sizeof (TCHAR));
            if (DirectorySelection (hDlg, &pathsguid, tmp)) {
-               set_path ("SaveimagePath", tmp);
+               set_path (L"SaveimagePath", tmp);
                values_to_pathsdialog (hDlg);
            }
            break;
            case IDC_PATHS_SAVEIMAGE:
-           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SAVEIMAGE), tmp, sizeof (tmp));
-           set_path ("SaveimagePath", tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_SAVEIMAGE), tmp, sizeof (tmp) / sizeof (TCHAR));
+           set_path (L"SaveimagePath", tmp);
            break;
            case IDC_PATHS_AVIOUTPUTS:
-           fetch_path ("VideoPath", tmp, sizeof (tmp));
+           fetch_path (L"VideoPath", tmp, sizeof (tmp) / sizeof (TCHAR));
            if (DirectorySelection (hDlg, &pathsguid, tmp)) {
-               set_path ("VideoPath", tmp);
+               set_path (L"VideoPath", tmp);
                values_to_pathsdialog (hDlg);
            }
            break;
            case IDC_PATHS_RIPS:
-           fetch_path ("RipperPath", tmp, sizeof (tmp));
+           fetch_path (L"RipperPath", tmp, sizeof (tmp) / sizeof (TCHAR));
            if (DirectorySelection (hDlg, &pathsguid, tmp)) {
-               set_path ("RipperPath", tmp);
+               set_path (L"RipperPath", tmp);
                values_to_pathsdialog (hDlg);
            }
            break;
            case IDC_PATHS_AVIOUTPUT:
-           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_AVIOUTPUT), tmp, sizeof (tmp));
-           set_path ("VideoPath", tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_AVIOUTPUT), tmp, sizeof (tmp) / sizeof (TCHAR));
+           set_path (L"VideoPath", tmp);
            break;
            case IDC_PATHS_RIP:
-           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_RIP), tmp, sizeof (tmp));
-           set_path ("RipperPath", tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_PATHS_RIP), tmp, sizeof (tmp) / sizeof (TCHAR));
+           set_path (L"RipperPath", tmp);
            break;
            case IDC_PATHS_DEFAULT:
            val = SendDlgItemMessage (hDlg, IDC_PATHS_DEFAULTTYPE, CB_GETCURSEL, 0, 0L);
            if (val != CB_ERR && val >= 0 && val < numtypes) {
                val = ptypes[val];
                if (val == PATH_TYPE_WINUAE) {
-                   strcpy (start_path_data, start_path_exe);
+                   _tcscpy (start_path_data, start_path_exe);
                    path_type = PATH_TYPE_WINUAE;
-                   strcpy (pathmode, "WinUAE");
+                   _tcscpy (pathmode, L"WinUAE");
                } else if (val == PATH_TYPE_NEWWINUAE && start_path_new1[0]) {
-                   strcpy (start_path_data, start_path_new1);
+                   _tcscpy (start_path_data, start_path_new1);
                    path_type = PATH_TYPE_NEWWINUAE;
                    create_afnewdir(0);
-                   strcpy (pathmode, "WinUAE_2");
+                   _tcscpy (pathmode, L"WinUAE_2");
                } else if (val == PATH_TYPE_OLDAF && start_path_af[0]) {
-                   strcpy (start_path_data, start_path_af);
-                   strcpy (pathmode, "AF");
+                   _tcscpy (start_path_data, start_path_af);
+                   _tcscpy (pathmode, L"AF");
                    path_type = PATH_TYPE_OLDAF;
                } else if (val == PATH_TYPE_NEWAF && start_path_new1[0]) {
-                   strcpy (pathmode, "AF2005");
+                   _tcscpy (pathmode, L"AF2005");
                    path_type = PATH_TYPE_NEWAF;
                    create_afnewdir(0);
-                   strcpy (start_path_data, start_path_new1);
+                   _tcscpy (start_path_data, start_path_new1);
                } else if (val == PATH_TYPE_AMIGAFOREVERDATA && start_path_new2[0]) {
-                   strcpy (pathmode, "AMIGAFOREVERDATA");
+                   _tcscpy (pathmode, L"AMIGAFOREVERDATA");
                    path_type = PATH_TYPE_AMIGAFOREVERDATA;
-                   strcpy (start_path_data, start_path_new1);
+                   _tcscpy (start_path_data, start_path_new1);
                }
                SetCurrentDirectory (start_path_data);
-               regsetstr (NULL, "PathMode", pathmode);
-               set_path ("KickstartPath", NULL);
-               set_path ("ConfigurationPath", NULL);
-               set_path ("ScreenshotPath", NULL);
-               set_path ("StatefilePath", NULL);
-               set_path ("SaveimagePath", NULL);
-               set_path ("VideoPath", NULL);
-               set_path ("RipperPath", NULL);
+               regsetstr (NULL, L"PathMode", pathmode);
+               set_path (L"KickstartPath", NULL);
+               set_path (L"ConfigurationPath", NULL);
+               set_path (L"ScreenshotPath", NULL);
+               set_path (L"StatefilePath", NULL);
+               set_path (L"SaveimagePath", NULL);
+               set_path (L"VideoPath", NULL);
+               set_path (L"RipperPath", NULL);
                values_to_pathsdialog (hDlg);
                FreeConfigStore ();
            }
@@ -4040,7 +3995,7 @@ static INT_PTR CALLBACK PathsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
            break;
            case IDC_PATHS_CONFIGCACHE:
            configurationcache = IsDlgButtonChecked (hDlg, IDC_PATHS_CONFIGCACHE) ? 1 : 0;
-           regsetint (NULL, "ConfigurationCache", configurationcache);
+           regsetint (NULL, L"ConfigurationCache", configurationcache);
            break;
 
        }
@@ -4094,10 +4049,10 @@ static void load_quickstart (HWND hDlg, int romcheck)
     setguititle (NULL);
 }
 
-static void quickstarthost (HWND hDlg, char *name)
+static void quickstarthost (HWND hDlg, TCHAR *name)
 {
     int type = CONFIG_TYPE_HOST;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     if (getconfigstorefrompath (name, tmp, CONFIG_TYPE_HOST)) {
        if (cfgfile_load (&workprefs, tmp, &type, 1))
@@ -4105,11 +4060,11 @@ static void quickstarthost (HWND hDlg, char *name)
     }
 }
 
-static void init_quickstartdlg_tooltip (HWND hDlg, char *tt)
+static void init_quickstartdlg_tooltip (HWND hDlg, TCHAR *tt)
 {
     TOOLINFO ti;
 
-    ti.cbSize = sizeof(TOOLINFO);
+    ti.cbSize = sizeof (TOOLINFO);
     ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
     ti.hwnd = hDlg;
     ti.hinst = hInst;
@@ -4125,16 +4080,16 @@ static void init_quickstartdlg (HWND hDlg)
 {
     static int firsttime;
     int i, j, idx, idx2, qssize;
-    char tmp1[2 * MAX_DPATH], tmp2[MAX_DPATH], hostconf[MAX_DPATH];
-    char *p1, *p2;
+    TCHAR tmp1[2 * MAX_DPATH], tmp2[MAX_DPATH], hostconf[MAX_DPATH];
+    TCHAR *p1, *p2;
 
-    qssize = sizeof (tmp1);
-    regquerystr (NULL, "QuickStartHostConfig", hostconf, &qssize);
+    qssize = sizeof (tmp1) / sizeof (TCHAR);
+    regquerystr (NULL, L"QuickStartHostConfig", hostconf, &qssize);
     if (firsttime == 0 && workprefs.start_gui) {
-       regqueryint (NULL, "QuickStartModel", &quickstart_model);
-       regqueryint (NULL, "QuickStartConfiguration", &quickstart_conf);
-       regqueryint (NULL, "QuickStartCompatibility", &quickstart_compa);
-       regqueryint (NULL, "QuickStartFloppies", &quickstart_floppy);
+       regqueryint (NULL, L"QuickStartModel", &quickstart_model);
+       regqueryint (NULL, L"QuickStartConfiguration", &quickstart_conf);
+       regqueryint (NULL, L"QuickStartCompatibility", &quickstart_compa);
+       regqueryint (NULL, L"QuickStartFloppies", &quickstart_floppy);
        if (quickstart) {
            workprefs.df[0][0] = 0;
            workprefs.df[1][0] = 0;
@@ -4148,16 +4103,16 @@ static void init_quickstartdlg (HWND hDlg)
 
     CheckDlgButton (hDlg, IDC_QUICKSTARTMODE, quickstart);
 
-    WIN32GUI_LoadUIString (IDS_QS_MODELS, tmp1, sizeof (tmp1));
-    strcat (tmp1, "\n");
+    WIN32GUI_LoadUIString (IDS_QS_MODELS, tmp1, sizeof (tmp1) / sizeof (TCHAR));
+    _tcscat (tmp1, L"\n");
     p1 = tmp1;
     SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_RESETCONTENT, 0, 0L);
     idx = idx2 = 0;
     i = 0;
     while (amodels[i].compalevels >= 0) {
        if (amodels[i].compalevels > 0) {
-           p2 = strchr (p1, '\n');
-           if (p2 && strlen (p2) > 0) {
+           p2 = _tcschr (p1, '\n');
+           if (p2 && _tcslen (p2) > 0) {
                *p2++ = 0;
                SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_ADDSTRING, 0, (LPARAM)p1);
                p1 = p2;
@@ -4170,24 +4125,24 @@ static void init_quickstartdlg (HWND hDlg)
     }
     SendDlgItemMessage (hDlg, IDC_QUICKSTART_MODEL, CB_SETCURSEL, idx2, 0);
 
-    WIN32GUI_LoadUIString (amodels[quickstart_model].id, tmp1, sizeof (tmp1));
-    strcat (tmp1, "\n");
+    WIN32GUI_LoadUIString (amodels[quickstart_model].id, tmp1, sizeof (tmp1) / sizeof (TCHAR));
+    _tcscat (tmp1, L"\n");
     p1 = tmp1;
     init_quickstartdlg_tooltip (hDlg, 0);
     SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_RESETCONTENT, 0, 0L);
     i = 0;
     for (;;) {
-       p2 = strchr (p1, '\n');
+       p2 = _tcschr (p1, '\n');
        if (!p2)
            break;
        *p2++= 0;
        SendDlgItemMessage (hDlg, IDC_QUICKSTART_CONFIGURATION, CB_ADDSTRING, 0, (LPARAM)p1);
        p1 = p2;
-       p2 = strchr (p1, '\n');
+       p2 = _tcschr (p1, '\n');
        if (!p2)
            break;
        *p2++= 0;
-       if (quickstart_conf == i && strlen (p1) > 0)
+       if (quickstart_conf == i && _tcslen (p1) > 0)
            init_quickstartdlg_tooltip (hDlg, p1);
        p1 = p2;
        i++;
@@ -4207,24 +4162,24 @@ static void init_quickstartdlg (HWND hDlg)
     SendDlgItemMessage( hDlg, IDC_QUICKSTART_COMPATIBILITY, TBM_SETPOS, TRUE, quickstart_compa);
 
     SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_RESETCONTENT, 0, 0L);
-    WIN32GUI_LoadUIString (IDS_DEFAULT_HOST, tmp1, sizeof (tmp1));
+    WIN32GUI_LoadUIString (IDS_DEFAULT_HOST, tmp1, sizeof (tmp1) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_ADDSTRING, 0, (LPARAM)tmp1);
     idx = 0;
     j = 1;
     for (i = 0; i < configstoresize; i++) {
        if (configstore[i]->Type == CONFIG_TYPE_HOST) {
-           strcpy (tmp2, configstore[i]->Path);
-           strncat (tmp2, configstore[i]->Name, MAX_DPATH);
-           if (!strcmp (tmp2, hostconf))
+           _tcscpy (tmp2, configstore[i]->Path);
+           _tcsncat (tmp2, configstore[i]->Name, MAX_DPATH);
+           if (!_tcscmp (tmp2, hostconf))
                idx = j;
            SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_ADDSTRING, 0, (LPARAM)tmp2);
            j++;
        }
     }
     SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_SETCURSEL, idx, 0);
-    regsetint (NULL, "QuickStartModel", quickstart_model);
-    regsetint (NULL, "QuickStartConfiguration", quickstart_conf);
-    regsetint (NULL, "QuickStartCompatibility", quickstart_compa);
+    regsetint (NULL, L"QuickStartModel", quickstart_model);
+    regsetint (NULL, L"QuickStartConfiguration", quickstart_conf);
+    regsetint (NULL, L"QuickStartCompatibility", quickstart_compa);
 }
 
 static void floppytooltip (HWND hDlg, int num, uae_u32 crc32);
@@ -4234,7 +4189,7 @@ static void testimage (HWND hDlg, int num)
     int reload = 0;
     uae_u32 crc32;
     int messageid = -1;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     floppytooltip (hDlg, num, 0);
     quickstart_ok_floppy = 0;
@@ -4284,7 +4239,7 @@ static void testimage (HWND hDlg, int num)
        break;
     }
     if (messageid > 0) {
-       WIN32GUI_LoadUIString (messageid, tmp, sizeof (tmp));
+       WIN32GUI_LoadUIString (messageid, tmp, sizeof (tmp) / sizeof (TCHAR));
        gui_message (tmp);
     }
     if (reload && quickstart) {
@@ -4300,9 +4255,9 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L
 {
     static int recursive;
     int ret = FALSE, i;
-    char tmp[MAX_DPATH];
-    static char df0[MAX_DPATH];
-    static char df1[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
+    static TCHAR df0[MAX_DPATH];
+    static TCHAR df1[MAX_DPATH];
     static int dfxtype[2] = { -1, -1 };
     static int doinit;
     LRESULT val;
@@ -4315,8 +4270,8 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L
            pages[QUICKSTART_ID] = hDlg;
            currentpage = QUICKSTART_ID;
            enable_for_quickstart (hDlg);
-           strcpy (df0, workprefs.df[0]);
-           strcpy (df1, workprefs.df[1]);
+           _tcscpy (df0, workprefs.df[0]);
+           _tcscpy (df1, workprefs.df[1]);
            setmultiautocomplete (hDlg, ids);
            doinit = 1;
            break;
@@ -4382,7 +4337,7 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L
                val = SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_GETCURSEL, 0, 0);
                if (val != CB_ERR) {
                    SendDlgItemMessage (hDlg, IDC_QUICKSTART_HOSTCONFIG, CB_GETLBTEXT, (WPARAM)val, (LPARAM)tmp);
-                   regsetstr (NULL, "QuickStartHostConfig", tmp);
+                   regsetstr (NULL, L"QuickStartHostConfig", tmp);
                    quickstarthost (hDlg, tmp);
                    if (val == 0 && quickstart)
                        load_quickstart (hDlg, 0);
@@ -4394,7 +4349,7 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L
            {
                case IDC_QUICKSTARTMODE:
                quickstart = IsDlgButtonChecked (hDlg, IDC_QUICKSTARTMODE);
-               regsetint (NULL, "QuickStartMode", quickstart);
+               regsetint (NULL, L"QuickStartMode", quickstart);
                if (quickstart) {
                    init_quickstartdlg (hDlg);
                    load_quickstart (hDlg, 0);
@@ -4441,14 +4396,14 @@ static INT_PTR CALLBACK QuickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, L
     }
     if (recursive == 0 && quickstart) {
        recursive++;
-       if (strcmp (workprefs.df[0], df0) || workprefs.dfxtype[0] != dfxtype[0]) {
-           strcpy (df0, workprefs.df[0]);
+       if (_tcscmp (workprefs.df[0], df0) || workprefs.dfxtype[0] != dfxtype[0]) {
+           _tcscpy (df0, workprefs.df[0]);
            dfxtype[0] = workprefs.dfxtype[0];
            testimage (hDlg, 0);
            enable_for_quickstart (hDlg);
        }
-       if (strcmp (workprefs.df[1], df1) || workprefs.dfxtype[1] != dfxtype[1]) {
-           strcpy (df1, workprefs.df[1]);
+       if (_tcscmp (workprefs.df[1], df1) || workprefs.dfxtype[1] != dfxtype[1]) {
+           _tcscpy (df1, workprefs.df[1]);
            dfxtype[1] = workprefs.dfxtype[1];
            testimage (hDlg, 1);
        }
@@ -4464,13 +4419,13 @@ static void init_aboutdlg (HWND hDlg)
 
     CharFormat.cbSize = sizeof (CharFormat);
 
-    SetDlgItemText (hDlg, IDC_RICHEDIT1, "WinUAE");
+    SetDlgItemText (hDlg, IDC_RICHEDIT1, L"WinUAE");
     SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
     CharFormat.dwMask |= CFM_BOLD | CFM_SIZE | CFM_FACE;
     CharFormat.dwEffects = CFE_BOLD;
     CharFormat.yHeight = 18 * 20; /* height in twips, where a twip is 1/20th of a point - for a pt.size of 18 */
 
-    strcpy (CharFormat.szFaceName, "Times New Roman");
+    _tcscpy (CharFormat.szFaceName, L"Times New Roman");
     SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
     SendDlgItemMessage (hDlg, IDC_RICHEDIT1, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
 
@@ -4478,7 +4433,7 @@ static void init_aboutdlg (HWND hDlg)
     SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_GETCHARFORMAT, 0, (LPARAM) & CharFormat);
     CharFormat.dwMask |= CFM_SIZE | CFM_FACE;
     CharFormat.yHeight = 10 * 20;
-    strcpy (CharFormat.szFaceName, "Times New Roman");
+    _tcscpy (CharFormat.szFaceName, L"Times New Roman");
     SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & CharFormat);
     SendDlgItemMessage (hDlg, IDC_RICHEDIT2, EM_SETBKGNDCOLOR, 0, GetSysColor (COLOR_3DFACE));
 
@@ -4549,7 +4504,7 @@ static void enable_for_chipsetdlg (HWND hDlg)
 }
 
 static DWORD idnth[] = { IDS_SECOND, IDS_THIRD, IDS_FOURTH, IDS_FIFTH, IDS_SIXTH, IDS_SEVENTH, IDS_EIGHTH, IDS_NINTH, IDS_TENTH, -1 };
-static void LoadNthString( DWORD value, char *nth, DWORD dwNthMax )
+static void LoadNthString( DWORD value, TCHAR *nth, DWORD dwNthMax )
 {
     nth[0] = 0;
     if (value >= 1 && value <= 9)
@@ -4562,7 +4517,7 @@ static int storedrefreshrates[MAX_REFRESH_RATES + 1];
 static void init_frequency_combo (HWND hDlg, int dmode)
 {
     int i, j, freq, tmp;
-    char hz[20], hz2[20], txt[100];
+    TCHAR hz[20], hz2[20], txt[100];
     LRESULT index;
     struct MultiDisplay *md = getdisplay (&workprefs);
 
@@ -4593,29 +4548,29 @@ static void init_frequency_combo (HWND hDlg, int dmode)
 
     hz[0] = hz2[0] = 0;
     SendDlgItemMessage(hDlg, IDC_REFRESHRATE, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString (IDS_VSYNC_DEFAULT, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_VSYNC_DEFAULT, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage(hDlg, IDC_REFRESHRATE, CB_ADDSTRING, 0, (LPARAM)txt);
     for (i = 0; i < index; i++) {
        freq = storedrefreshrates[i];
        if (freq < 0) {
            freq = -freq;
-           sprintf (hz, "(%dHz)", freq);
+           _stprintf (hz, L"(%dHz)", freq);
        } else {
-           sprintf (hz, "%dHz", freq);
+           _stprintf (hz, L"%dHz", freq);
        }
        if (freq == 50 || freq == 100)
-           strcat (hz, " PAL");
+           _tcscat (hz, L" PAL");
        if (freq == 60 || freq == 120)
-           strcat (hz, " NTSC");
+           _tcscat (hz, L" NTSC");
        if (abs(workprefs.gfx_refreshrate) == freq)
-           strcpy (hz2, hz);
+           _tcscpy (hz2, hz);
        SendDlgItemMessage (hDlg, IDC_REFRESHRATE, CB_ADDSTRING, 0, (LPARAM)hz);
     }
     index = CB_ERR;
     if (hz2[0] >= 0)
        index = SendDlgItemMessage (hDlg, IDC_REFRESHRATE, CB_SELECTSTRING, 0, (LPARAM)hz2);
     if (index == CB_ERR) {
-       WIN32GUI_LoadUIString (IDS_VSYNC_DEFAULT, txt, sizeof (txt));
+       WIN32GUI_LoadUIString (IDS_VSYNC_DEFAULT, txt, sizeof (txt) / sizeof (TCHAR));
        SendDlgItemMessage(hDlg, IDC_REFRESHRATE, CB_SELECTSTRING, i, (LPARAM)txt);
        workprefs.gfx_refreshrate = 0;
     }
@@ -4691,9 +4646,9 @@ void init_da (HWND hDlg)
 {
     int *p;
     SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_ADDSTRING, 0, (LPARAM)"Brightness");
-    SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_ADDSTRING, 0, (LPARAM)"Contrast");
-    SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_ADDSTRING, 0, (LPARAM)"Gamma");
+    SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_ADDSTRING, 0, (LPARAM)L"Brightness");
+    SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_ADDSTRING, 0, (LPARAM)L"Contrast");
+    SendDlgItemMessage(hDlg, IDC_DA_MODE, CB_ADDSTRING, 0, (LPARAM)L"Gamma");
     if (da_mode_selected == CB_ERR)
        da_mode_selected = 0;
     SendDlgItemMessage (hDlg, IDC_DA_MODE, CB_SETCURSEL, da_mode_selected, 0);
@@ -4756,8 +4711,8 @@ static void init_display_mode (HWND hDlg)
     gui_display_depths[0] = gui_display_depths[1] = gui_display_depths[2] = -1;
     for (i = 0; md->DisplayModes[i].depth >= 0; i++) {
         if (md->DisplayModes[i].depth > 1 && md->DisplayModes[i].residx == md->DisplayModes[index].residx) {
-           char tmp[64];
-           sprintf (tmp, "%d", md->DisplayModes[i].depth * 8);
+           TCHAR tmp[64];
+           _stprintf (tmp, L"%d", md->DisplayModes[i].depth * 8);
            SendDlgItemMessage(hDlg, IDC_RESOLUTIONDEPTH, CB_ADDSTRING, 0, (LPARAM)tmp);
            if (md->DisplayModes[i].depth == d)
                SendDlgItemMessage (hDlg, IDC_RESOLUTIONDEPTH, CB_SETCURSEL, cnt, 0);
@@ -4812,10 +4767,10 @@ static void display_fromselect(int val, int *fs, int *vsync, int p96)
 
 static void values_to_displaydlg (HWND hDlg)
 {
-    char buffer[MAX_DPATH], buffer2[MAX_DPATH];
-    char Nth[MAX_NTH_LENGTH];
-    LPSTR blah[1] = { Nth };
-    LPTSTR string = NULL;
+    TCHAR buffer[MAX_DPATH], buffer2[MAX_DPATH];
+    TCHAR Nth[MAX_NTH_LENGTH];
+    TCHAR *blah[1] = { Nth };
+    TCHAR *string = NULL;
     int v;
 
     init_display_mode (hDlg);
@@ -4827,18 +4782,18 @@ static void values_to_displaydlg (HWND hDlg)
     if (v == 0)
        v = currprefs.ntscmode ? 60 : 50;
     SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_SETPOS, TRUE, v);
-    sprintf (buffer, "%d", v);
+    _stprintf (buffer, L"%d", v);
     SetDlgItemText (hDlg, IDC_RATE2TEXT, buffer);
 
     v = workprefs.cpu_cycle_exact ? 1 : workprefs.gfx_framerate;
     SendDlgItemMessage (hDlg, IDC_FRAMERATE, TBM_SETPOS, TRUE, v);
-    WIN32GUI_LoadUIString(IDS_FRAMERATE, buffer, sizeof buffer);
+    WIN32GUI_LoadUIString(IDS_FRAMERATE, buffer, sizeof buffer / sizeof (TCHAR));
     LoadNthString (v - 1, Nth, MAX_NTH_LENGTH);
     if(FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_ALLOCATE_BUFFER,
            buffer, 0, 0, (LPTSTR)&string, MAX_FRAMERATE_LENGTH + MAX_NTH_LENGTH, (va_list *)blah ) == 0)
     {
        DWORD dwLastError = GetLastError();
-       sprintf (buffer, "Every %s Frame", nth[v - 1]);
+       _stprintf (buffer, L"Every %s Frame", nth[v - 1]);
        SetDlgItemText(hDlg, IDC_RATETEXT, buffer);
     } else {
        SetDlgItemText( hDlg, IDC_RATETEXT, string);
@@ -4848,37 +4803,37 @@ static void values_to_displaydlg (HWND hDlg)
     CheckRadioButton (hDlg, IDC_LM_NORMAL, IDC_LM_SCANLINES, IDC_LM_NORMAL + workprefs.gfx_linedbl);
 
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString(IDS_SCREEN_WINDOWED, buffer, sizeof buffer);
+    WIN32GUI_LoadUIString(IDS_SCREEN_WINDOWED, buffer, sizeof buffer / sizeof (TCHAR));
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_ADDSTRING, 0, (LPARAM)buffer);
-    WIN32GUI_LoadUIString(IDS_SCREEN_FULLSCREEN, buffer, sizeof buffer);
+    WIN32GUI_LoadUIString(IDS_SCREEN_FULLSCREEN, buffer, sizeof buffer / sizeof (TCHAR));
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_ADDSTRING, 0, (LPARAM)buffer);
-    WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC, buffer2, sizeof buffer2);
-    sprintf (buffer + strlen(buffer), " + %s", buffer2);
+    WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC, buffer2, sizeof buffer2 / sizeof (TCHAR));
+    _stprintf (buffer + _tcslen (buffer), L" + %s", buffer2);
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_ADDSTRING, 0, (LPARAM)buffer);
-    WIN32GUI_LoadUIString(IDS_SCREEN_FULLWINDOW, buffer, sizeof buffer);
+    WIN32GUI_LoadUIString(IDS_SCREEN_FULLWINDOW, buffer, sizeof buffer / sizeof (TCHAR));
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_ADDSTRING, 0, (LPARAM)buffer);
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_NATIVE, CB_SETCURSEL, display_toselect(workprefs.gfx_afullscreen, workprefs.gfx_avsync, 0), 0);
 
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString(IDS_SCREEN_WINDOWED, buffer, sizeof buffer);
+    WIN32GUI_LoadUIString(IDS_SCREEN_WINDOWED, buffer, sizeof buffer / sizeof (TCHAR));
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
-    sprintf (buffer + strlen(buffer), " + %s", buffer2);
+    _stprintf (buffer + _tcslen (buffer), L" + %s", buffer2);
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
-    WIN32GUI_LoadUIString(IDS_SCREEN_FULLSCREEN, buffer, sizeof buffer);
+    WIN32GUI_LoadUIString(IDS_SCREEN_FULLSCREEN, buffer, sizeof buffer / sizeof (TCHAR));
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
-    WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC, buffer2, sizeof buffer2);
-    sprintf (buffer + strlen(buffer), " + %s", buffer2);
+    WIN32GUI_LoadUIString(IDS_SCREEN_VSYNC, buffer2, sizeof buffer2 / sizeof (TCHAR));
+    _stprintf (buffer + _tcslen (buffer), L" + %s", buffer2);
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
-    WIN32GUI_LoadUIString(IDS_SCREEN_FULLWINDOW, buffer, sizeof buffer);
+    WIN32GUI_LoadUIString(IDS_SCREEN_FULLWINDOW, buffer, sizeof buffer / sizeof (TCHAR));
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
-    sprintf (buffer + strlen(buffer), " + %s", buffer2);
+    _stprintf (buffer + _tcslen (buffer), L" + %s", buffer2);
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_ADDSTRING, 0, (LPARAM)buffer);
     SendDlgItemMessage(hDlg, IDC_SCREENMODE_RTG, CB_SETCURSEL, display_toselect(workprefs.gfx_pfullscreen, workprefs.gfx_pvsync, 1), 0);
 
     SendDlgItemMessage(hDlg, IDC_LORES, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)"Lores");
-    SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)"Hires (normal)");
-    SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)"SuperHires");
+    SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)L"Lores");
+    SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)L"Hires (normal)");
+    SendDlgItemMessage(hDlg, IDC_LORES, CB_ADDSTRING, 0, (LPARAM)L"SuperHires");
     SendDlgItemMessage (hDlg, IDC_LORES, CB_SETCURSEL, workprefs.gfx_resolution, 0);
 
     CheckDlgButton (hDlg, IDC_BLACKER_THAN_BLACK, workprefs.gfx_blackerthanblack);
@@ -4894,13 +4849,13 @@ static void values_to_displaydlg (HWND hDlg)
 static void init_resolution_combo (HWND hDlg)
 {
     int i = 0, idx = -1;
-    char tmp[64];
+    TCHAR tmp[64];
     struct MultiDisplay *md = getdisplay (&workprefs);
 
     SendDlgItemMessage(hDlg, IDC_RESOLUTION, CB_RESETCONTENT, 0, 0);
     while (md->DisplayModes[i].depth >= 0) {
        if (md->DisplayModes[i].depth > 1 && md->DisplayModes[i].residx != idx) {
-           sprintf (tmp, "%dx%d", md->DisplayModes[i].res.width, md->DisplayModes[i].res.height);
+           _stprintf (tmp, L"%dx%d", md->DisplayModes[i].res.width, md->DisplayModes[i].res.height);
            SendDlgItemMessage(hDlg, IDC_RESOLUTION, CB_ADDSTRING, 0, (LPARAM)tmp);
            idx = md->DisplayModes[i].residx;
        }
@@ -4910,14 +4865,14 @@ static void init_resolution_combo (HWND hDlg)
 static void init_displays_combo (HWND hDlg)
 {
     int i = 0;
-    SendDlgItemMessage(hDlg, IDC_DISPLAYSELECT, CB_RESETCONTENT, 0, 0);
+    SendDlgItemMessage (hDlg, IDC_DISPLAYSELECT, CB_RESETCONTENT, 0, 0);
     while (Displays[i].name) {
-       SendDlgItemMessage(hDlg, IDC_DISPLAYSELECT, CB_ADDSTRING, 0, (LPARAM)Displays[i].name);
+       SendDlgItemMessage (hDlg, IDC_DISPLAYSELECT, CB_ADDSTRING, 0, (LPARAM)Displays[i].name);
        i++;
     }
     if (workprefs.gfx_display >= i)
        workprefs.gfx_display = 0;
-    SendDlgItemMessage(hDlg, IDC_DISPLAYSELECT, CB_SETCURSEL, workprefs.gfx_display, 0);
+    SendDlgItemMessage (hDlg, IDC_DISPLAYSELECT, CB_SETCURSEL, workprefs.gfx_display, 0);
 }
 
 static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -4943,10 +4898,10 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
     workprefs.chipset_refreshrate = SendDlgItemMessage (hDlg, IDC_FRAMERATE2, TBM_GETPOS, 0, 0);
 
     {
-       char buffer[MAX_FRAMERATE_LENGTH];
-       char Nth[MAX_NTH_LENGTH];
-       LPSTR blah[1] = { Nth };
-       LPTSTR string = NULL;
+       TCHAR buffer[MAX_FRAMERATE_LENGTH];
+       TCHAR Nth[MAX_NTH_LENGTH];
+       TCHAR *blah[1] = { Nth };
+       TCHAR *string = NULL;
 
        WIN32GUI_LoadUIString(IDS_FRAMERATE, buffer, MAX_FRAMERATE_LENGTH);
        LoadNthString(workprefs.gfx_framerate - 1, Nth, MAX_NTH_LENGTH);
@@ -4954,7 +4909,7 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
                           buffer, 0, 0, (LPTSTR)&string, MAX_FRAMERATE_LENGTH + MAX_NTH_LENGTH, (va_list *)blah ) == 0)
        {
            DWORD dwLastError = GetLastError();
-           sprintf (buffer, "Every %s Frame", nth[workprefs.gfx_framerate - 1]);
+           _stprintf (buffer, L"Every %s Frame", nth[workprefs.gfx_framerate - 1]);
            SetDlgItemText(hDlg, IDC_RATETEXT, buffer);
        }
        else
@@ -4962,7 +4917,7 @@ static void values_from_displaydlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
            SetDlgItemText(hDlg, IDC_RATETEXT, string);
            LocalFree(string);
        }
-       sprintf (buffer, "%d", workprefs.chipset_refreshrate);
+       _stprintf (buffer, L"%d", workprefs.chipset_refreshrate);
        SetDlgItemText (hDlg, IDC_RATE2TEXT, buffer);
        workprefs.gfx_size_win.width  = GetDlgItemInt(hDlg, IDC_XSIZE, &success, FALSE);
        if(!success)
@@ -5118,9 +5073,9 @@ static INT_PTR CALLBACK DisplayDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
 
 static void values_to_chipsetdlg (HWND hDlg)
 {
-    char Nth[MAX_NTH_LENGTH];
-    LPSTR blah[1] = { Nth };
-    LPTSTR string = NULL;
+    TCHAR Nth[MAX_NTH_LENGTH];
+    TCHAR *blah[1] = { Nth };
+    TCHAR *string = NULL;
     int which_button;
 
     switch(workprefs.chipset_mask)
@@ -5155,20 +5110,20 @@ static void values_to_chipsetdlg (HWND hDlg)
     }
     CheckRadioButton (hDlg, IDC_CS_SOUND0, IDC_CS_SOUND2, which_button);
     SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"Generic");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"CDTV");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"CD32");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A500");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A500+");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A600");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A1000");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A1200");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A2000");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A3000");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A3000T");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A4000");
-    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)"A4000T");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"Generic");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"CDTV");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"CD32");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A500");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A500+");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A600");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A1000");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A1200");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A2000");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A3000");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A3000T");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A4000");
+    SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_ADDSTRING, 0, (LPARAM)L"A4000T");
     SendDlgItemMessage (hDlg, IDC_CS_EXT, CB_SETCURSEL, workprefs.cs_compatible, 0);
 }
 
@@ -5258,7 +5213,7 @@ static INT_PTR CALLBACK ChipsetDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
 
 static void values_to_chipsetdlg2 (HWND hDlg)
 {
-    char txt[32];
+    TCHAR txt[32];
     uae_u32 rev;
 
     switch(workprefs.cs_ciaatod)
@@ -5315,20 +5270,20 @@ static void values_to_chipsetdlg2 (HWND hDlg)
     CheckDlgButton (hDlg, IDC_CS_IDE1, workprefs.cs_ide > 0 && (workprefs.cs_ide & 1));
     CheckDlgButton (hDlg, IDC_CS_IDE2, workprefs.cs_ide > 0 && (workprefs.cs_ide & 2));
     txt[0] = 0;
-    sprintf (txt, "%d", workprefs.cs_rtc_adjust);
+    _stprintf (txt, L"%d", workprefs.cs_rtc_adjust);
     SetDlgItemText(hDlg, IDC_CS_RTCADJUST, txt);
     txt[0] = 0;
     if (workprefs.cs_fatgaryrev >= 0)
-       sprintf (txt, "%02X", workprefs.cs_fatgaryrev);
+       _stprintf (txt, L"%02X", workprefs.cs_fatgaryrev);
     SetDlgItemText(hDlg, IDC_CS_FATGARYREV, txt);
     txt[0] = 0;
     if (workprefs.cs_ramseyrev >= 0)
-       sprintf (txt, "%02X", workprefs.cs_ramseyrev);
+       _stprintf (txt, L"%02X", workprefs.cs_ramseyrev);
     SetDlgItemText(hDlg, IDC_CS_RAMSEYREV, txt);
     txt[0] = 0;
     if (workprefs.cs_agnusrev >= 0) {
        rev = workprefs.cs_agnusrev;
-       sprintf (txt, "%02X", rev);
+       _stprintf (txt, L"%02X", rev);
     } else if (workprefs.cs_compatible) {
        rev = 0;
        if (workprefs.ntscmode)
@@ -5337,27 +5292,27 @@ static void values_to_chipsetdlg2 (HWND hDlg)
        rev |= (currprefs.chipset_mask & CSMASK_ECS_AGNUS) ? 0x20 : 0;
        if (workprefs.chipmem_size > 1024 * 1024 && (workprefs.chipset_mask & CSMASK_ECS_AGNUS))
            rev |= 0x21;
-       sprintf (txt, "%02X", rev);
+       _stprintf (txt, L"%02X", rev);
     }
     SetDlgItemText(hDlg, IDC_CS_AGNUSREV, txt);
     txt[0] = 0;
     if (workprefs.cs_deniserev >= 0) {
        rev = workprefs.cs_deniserev;
-       sprintf (txt, "%01.1X", rev);
+       _stprintf (txt, L"%01.1X", rev);
     } else if (workprefs.cs_compatible) {
        rev = 0xf;
        if (workprefs.chipset_mask & CSMASK_ECS_DENISE)
            rev = 0xc;
        if (workprefs.chipset_mask & CSMASK_AGA)
            rev = 0x8;
-       sprintf (txt, "%01.1X", rev);
+       _stprintf (txt, L"%01.1X", rev);
     }
     SetDlgItemText(hDlg, IDC_CS_DENISEREV, txt);
 }
 
 static void values_from_chipsetdlg2 (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-    char txt[32], *p;
+    TCHAR txt[32], *p;
     int v;
 
     workprefs.cs_compatible = IsDlgButtonChecked (hDlg, IDC_CS_COMPATIBLE);
@@ -5397,34 +5352,34 @@ static void values_from_chipsetdlg2 (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 
     if (workprefs.cs_rtc) {
        txt[0] = 0;
-       SendDlgItemMessage (hDlg, IDC_CS_RTCADJUST, WM_GETTEXT, (WPARAM)sizeof(txt), (LPARAM)txt);
-       workprefs.cs_rtc_adjust = atol(txt);
+       SendDlgItemMessage (hDlg, IDC_CS_RTCADJUST, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
+       workprefs.cs_rtc_adjust = _tstol(txt);
     }
     if (workprefs.cs_fatgaryrev >= 0) {
        txt[0] = 0;
-       SendDlgItemMessage (hDlg, IDC_CS_FATGARYREV, WM_GETTEXT, (WPARAM)sizeof(txt), (LPARAM)txt);
-       v = strtol (txt, &p, 16);
+       SendDlgItemMessage (hDlg, IDC_CS_FATGARYREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
+       v = _tcstol (txt, &p, 16);
        if (v >= 0 && v <= 255)
            workprefs.cs_fatgaryrev = v;
     }
     if (workprefs.cs_ramseyrev >= 0) {
        txt[0] = 0;
-       SendDlgItemMessage (hDlg, IDC_CS_RAMSEYREV, WM_GETTEXT, (WPARAM)sizeof(txt), (LPARAM)txt);
-       v = strtol (txt, &p, 16);
+       SendDlgItemMessage (hDlg, IDC_CS_RAMSEYREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
+       v = _tcstol (txt, &p, 16);
        if (v >= 0 && v <= 255)
            workprefs.cs_ramseyrev = v;
     }
     if (workprefs.cs_agnusrev >= 0) {
        txt[0] = 0;
-       SendDlgItemMessage (hDlg, IDC_CS_AGNUSREV, WM_GETTEXT, (WPARAM)sizeof(txt), (LPARAM)txt);
-       v = strtol (txt, &p, 16);
+       SendDlgItemMessage (hDlg, IDC_CS_AGNUSREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
+       v = _tcstol (txt, &p, 16);
        if (v >= 0 && v <= 255)
            workprefs.cs_agnusrev = v;
     }
     if (workprefs.cs_deniserev >= 0) {
        txt[0] = 0;
-       SendDlgItemMessage (hDlg, IDC_CS_DENISEREV, WM_GETTEXT, (WPARAM)sizeof(txt), (LPARAM)txt);
-       v = strtol (txt, &p, 16);
+       SendDlgItemMessage (hDlg, IDC_CS_DENISEREV, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
+       v = _tcstol (txt, &p, 16);
        if (v >= 0 && v <= 15)
            workprefs.cs_deniserev = v;
     }
@@ -5664,8 +5619,8 @@ static void values_to_memorydlg (HWND hDlg)
            (workprefs.win32_rtgvblankrate == 70) ? 5 :
            (workprefs.win32_rtgvblankrate == 75) ? 6 : 0, 0);
     } else {
-       char tmp[10];
-       sprintf (tmp, "%d", workprefs.win32_rtgvblankrate);
+       TCHAR tmp[10];
+       _stprintf (tmp, L"%d", workprefs.win32_rtgvblankrate);
        SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, WM_SETTEXT, 0, (LPARAM)tmp);
     }
        
@@ -5755,7 +5710,7 @@ static void updatez3 (uae_u32 *size1p, uae_u32 *size2p)
 static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     int v;
-    char tmp[100];
+    TCHAR tmp[100];
     static int recursive = 0;
 
     switch (msg)
@@ -5764,26 +5719,26 @@ static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
            pages[MEMORY_ID] = hDlg;
            currentpage = MEMORY_ID;
            SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_RESETCONTENT, 0, 0);
-           SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_ADDSTRING, 0, (LPARAM)"(8bit)");
-           SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_ADDSTRING, 0, (LPARAM)"8-bit (*)");
+           SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_ADDSTRING, 0, (LPARAM)L"(8bit)");
+           SendDlgItemMessage (hDlg, IDC_RTG_8BIT, CB_ADDSTRING, 0, (LPARAM)L"8-bit (*)");
            SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_RESETCONTENT, 0, 0);
-           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)"(15/16bit)");
-           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)"R5G6B5PC (*)");
-           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)"R5G5B5PC");
-           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)"R5G6B5");
-           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)"R5G5B5");
-           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)"B5G6R5PC");
-           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)"B5G5R5PC");
+           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)L"(15/16bit)");
+           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)L"R5G6B5PC (*)");
+           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)L"R5G5B5PC");
+           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)L"R5G6B5");
+           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)L"R5G5B5");
+           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)L"B5G6R5PC");
+           SendDlgItemMessage (hDlg, IDC_RTG_16BIT, CB_ADDSTRING, 0, (LPARAM)L"B5G5R5PC");
            SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_RESETCONTENT, 0, 0);
-           SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)"(24bit)");
-           SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)"R8G8B8");
-           SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)"B8G8R8");
+           SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)L"(24bit)");
+           SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)L"R8G8B8");
+           SendDlgItemMessage (hDlg, IDC_RTG_24BIT, CB_ADDSTRING, 0, (LPARAM)L"B8G8R8");
            SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_RESETCONTENT, 0, 0);
-           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)"(32bit)");
-           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)"A8R8G8B8");
-           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)"A8B8G8R8");
-           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)"R8G8B8A8");
-           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)"B8G8R8A8 (*)");
+           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)L"(32bit)");
+           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)L"A8R8G8B8");
+           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)L"A8B8G8R8");
+           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)L"R8G8B8A8");
+           SendDlgItemMessage (hDlg, IDC_RTG_32BIT, CB_ADDSTRING, 0, (LPARAM)L"B8G8R8A8 (*)");
            SendDlgItemMessage (hDlg, IDC_CHIPMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_CHIP_MEM, MAX_CHIP_MEM));
            SendDlgItemMessage (hDlg, IDC_FASTMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_FAST_MEM, MAX_FAST_MEM));
            SendDlgItemMessage (hDlg, IDC_SLOWMEM, TBM_SETRANGE, TRUE, MAKELONG (MIN_SLOW_MEM, MAX_SLOW_MEM));
@@ -5792,22 +5747,22 @@ static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
            SendDlgItemMessage (hDlg, IDC_MBMEM1, TBM_SETRANGE, TRUE, MAKELONG (MIN_MB_MEM, MAX_MB_MEM));
            SendDlgItemMessage (hDlg, IDC_MBMEM2, TBM_SETRANGE, TRUE, MAKELONG (MIN_MB_MEM, MAX_MB_MEM));
            SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_RESETCONTENT, 0, 0);
-           WIN32GUI_LoadUIString (IDS_DISABLED, tmp, sizeof tmp);
+           WIN32GUI_LoadUIString (IDS_DISABLED, tmp, sizeof tmp / sizeof (TCHAR));
            SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)tmp);
-           WIN32GUI_LoadUIString (IDS_AUTOMATIC, tmp, sizeof tmp);
+           WIN32GUI_LoadUIString (IDS_AUTOMATIC, tmp, sizeof tmp / sizeof (TCHAR));
            SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)tmp);
-           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)"4:3");
-           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)"15:9");
-           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)"16:9");
-           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)"16:10");
+           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)L"4:3");
+           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)L"15:9");
+           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)L"16:9");
+           SendDlgItemMessage (hDlg, IDC_RTG_SCALE_ASPECTRATIO, CB_ADDSTRING, 0, (LPARAM)L"16:10");
            SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_RESETCONTENT, 0, 0);
-           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)"Disabled");
-           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)"Chipset");
-           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)"Real");
-           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)"50");
-           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)"60");
-           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)"70");
-           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)"75");
+           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)L"Disabled");
+           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)L"Chipset");
+           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)L"Real");
+           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)L"50");
+           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)L"60");
+           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)L"70");
+           SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_ADDSTRING, 0, (LPARAM)L"75");
 
        case WM_USER:
            recursive++;
@@ -5938,10 +5893,10 @@ static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
                            v = SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, CB_GETLBTEXT, (WPARAM)v, (LPARAM)tmp);
                        }
                    } else {
-                       v = SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, WM_GETTEXT, (WPARAM)sizeof tmp, (LPARAM)tmp);
+                       v = SendDlgItemMessage (hDlg, IDC_RTG_VBLANKRATE, WM_GETTEXT, (WPARAM)sizeof tmp / sizeof (TCHAR), (LPARAM)tmp);
                    }
                    if (tmp[0])
-                       workprefs.win32_rtgvblankrate = atol (tmp);
+                       workprefs.win32_rtgvblankrate = _tstol (tmp);
                    break;
                }
                workprefs.picasso96_modeflags = mask;
@@ -5954,31 +5909,31 @@ static INT_PTR CALLBACK MemoryDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
     return FALSE;
 }
 
-static void addromfiles (UAEREG *fkey, HWND hDlg, DWORD d, char *path, int type)
+static void addromfiles (UAEREG *fkey, HWND hDlg, DWORD d, TCHAR *path, int type)
 {
     int idx;
-    char tmp[MAX_DPATH];
-    char tmp2[MAX_DPATH];
-    char seltmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
+    TCHAR tmp2[MAX_DPATH];
+    TCHAR seltmp[MAX_DPATH];
     struct romdata *rdx;
 
     rdx = scan_single_rom (path);
     SendDlgItemMessage(hDlg, d, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage(hDlg, d, CB_ADDSTRING, 0, (LPARAM)"");
+    SendDlgItemMessage(hDlg, d, CB_ADDSTRING, 0, (LPARAM)L"");
     idx = 0;
     seltmp[0] = 0;
     for (;fkey;) {
-       DWORD size = sizeof (tmp);
-       DWORD size2 = sizeof (tmp2);
+       DWORD size = sizeof (tmp) / sizeof (TCHAR);
+       DWORD size2 = sizeof (tmp2) / sizeof (TCHAR);
        if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2))
            break;
-       if (strlen (tmp) == 7 || strlen (tmp) == 13) {
+       if (_tcslen (tmp) == 7 || _tcslen (tmp) == 13) {
            int group = 0;
            int subitem = 0;
-           int idx2 = atol (tmp + 4);
-           if (strlen (tmp) == 13) {
-               group = atol (tmp + 8);
-               subitem = atol (tmp + 11);
+           int idx2 = _tstol (tmp + 4);
+           if (_tcslen (tmp) == 13) {
+               group = _tstol (tmp + 8);
+               subitem = _tstol (tmp + 11);
            }
            if (idx2 >= 0) {
                struct romdata *rd = getromdatabyidgroup (idx2, group, subitem);
@@ -5987,7 +5942,7 @@ static void addromfiles (UAEREG *fkey, HWND hDlg, DWORD d, char *path, int type)
                    if (SendDlgItemMessage (hDlg, d, CB_FINDSTRING, (WPARAM)-1, (LPARAM)tmp) < 0)
                        SendDlgItemMessage(hDlg, d, CB_ADDSTRING, 0, (LPARAM)tmp);
                    if (rd == rdx)
-                       strcpy (seltmp, tmp);
+                       _tcscpy (seltmp, tmp);
                }
            }
        }
@@ -5999,13 +5954,13 @@ static void addromfiles (UAEREG *fkey, HWND hDlg, DWORD d, char *path, int type)
        SetDlgItemText(hDlg, d, path);
 }
 
-static void getromfile (HWND hDlg, DWORD d, char *path, int size)
+static void getromfile (HWND hDlg, DWORD d, TCHAR *path, int size)
 {
     LRESULT val = SendDlgItemMessage (hDlg, d, CB_GETCURSEL, 0, 0L);
     if (val == CB_ERR) {
        SendDlgItemMessage (hDlg, d, WM_GETTEXT, (WPARAM)size, (LPARAM)path);
     } else {
-       char tmp1[MAX_DPATH];
+       TCHAR tmp1[MAX_DPATH];
        struct romdata *rd;
        SendDlgItemMessage (hDlg, d, CB_GETLBTEXT, (WPARAM)val, (LPARAM)tmp1);
        path[0] = 0;
@@ -6013,25 +5968,25 @@ static void getromfile (HWND hDlg, DWORD d, char *path, int size)
        if (rd) {
            struct romlist *rl = getromlistbyromdata(rd);
            if (rd->configname)
-               sprintf (path, ":%s", rd->configname);
+               _stprintf (path, L":%s", rd->configname);
            else if (rl)
-               strncpy (path, rl->path, size);
+               _tcsncpy (path, rl->path, size);
        }
     }
 }
 
 static void values_from_kickstartdlg (HWND hDlg)
 {
-    getromfile (hDlg, IDC_ROMFILE, workprefs.romfile, sizeof (workprefs.romfile));
-    getromfile (hDlg, IDC_ROMFILE2, workprefs.romextfile, sizeof (workprefs.romextfile));
-    getromfile (hDlg, IDC_CARTFILE, workprefs.cartfile, sizeof (workprefs.cartfile));
+    getromfile (hDlg, IDC_ROMFILE, workprefs.romfile, sizeof (workprefs.romfile) / sizeof (TCHAR));
+    getromfile (hDlg, IDC_ROMFILE2, workprefs.romextfile, sizeof (workprefs.romextfile) / sizeof (TCHAR));
+    getromfile (hDlg, IDC_CARTFILE, workprefs.cartfile, sizeof (workprefs.cartfile) / sizeof (TCHAR));
 }
 
 static void values_to_kickstartdlg (HWND hDlg)
 {
     UAEREG *fkey;
 
-    fkey = regcreatetree (NULL, "DetectedROMs");
+    fkey = regcreatetree (NULL, L"DetectedROMs");
     load_keyring(&workprefs, NULL);
     addromfiles (fkey, hDlg, IDC_ROMFILE, workprefs.romfile,
         ROMTYPE_KICK | ROMTYPE_KICKCD32);
@@ -6065,11 +6020,11 @@ static void init_kickstart (HWND hDlg)
     ew (hDlg, IDC_CARTCHOOSER), FALSE);
     ew (hDlg, IDC_FLASHCHOOSER), FALSE);
 #endif
-    if (!regexiststree (NULL , "DetectedROMs"))
+    if (!regexiststree (NULL , L"DetectedROMs"))
        scan_roms (1);
 }
 
-static void kickstartfilebuttons (HWND hDlg, WPARAM wParam, char *path)
+static void kickstartfilebuttons (HWND hDlg, WPARAM wParam, TCHAR *path)
 {
     switch (LOWORD(wParam))
     {
@@ -6095,7 +6050,7 @@ static void kickstartfilebuttons (HWND hDlg, WPARAM wParam, char *path)
 static INT_PTR CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     static int recursive;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     switch (msg)
     {
@@ -6116,10 +6071,10 @@ static INT_PTR CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        int id = GetDlgCtrlID((HWND)wParam);
        if (id == IDC_KICKCHOOSER || id == IDC_ROMCHOOSER2
            || id == IDC_FLASHCHOOSER || id == IDC_CARTCHOOSER) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
-               char newfile[MAX_DPATH];
-               strcpy (newfile, s);
+               TCHAR newfile[MAX_DPATH];
+               _tcscpy (newfile, s);
                kickstartfilebuttons (hDlg, id, newfile);
                xfree (s);
            }
@@ -6145,8 +6100,8 @@ static INT_PTR CALLBACK KickstartDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        switch (LOWORD (wParam))
        {
        case IDC_FLASHFILE:
-           GetWindowText (GetDlgItem (hDlg, IDC_FLASHFILE), tmp, sizeof (tmp));
-           strcpy (workprefs.flashfile, tmp);
+           GetWindowText (GetDlgItem (hDlg, IDC_FLASHFILE), tmp, sizeof (tmp) / sizeof (TCHAR));
+           _tcscpy (workprefs.flashfile, tmp);
            break;
 
        case IDC_KICKSHIFTER:
@@ -6205,16 +6160,16 @@ static void enable_for_miscdlg (HWND hDlg)
 
 static void misc_kbled (HWND hDlg, int v, int nv)
 {
-    char *defname = v == IDC_KBLED1 ? "(NumLock)" : v == IDC_KBLED2 ? "(CapsLock)" : "(ScrollLock)";
+    TCHAR *defname = v == IDC_KBLED1 ? L"(NumLock)" : v == IDC_KBLED2 ? L"(CapsLock)" : L"(ScrollLock)";
     SendDlgItemMessage (hDlg, v, CB_RESETCONTENT, 0, 0L);
     SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)defname);
-    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)"POWER");
-    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)"DF0");
-    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)"DF1");
-    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)"DF2");
-    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)"DF3");
-    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)"HD");
-    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)"CD");
+    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)L"POWER");
+    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)L"DF0");
+    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)L"DF1");
+    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)L"DF2");
+    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)L"DF3");
+    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)L"HD");
+    SendDlgItemMessage (hDlg, v, CB_ADDSTRING, 0, (LPARAM)L"CD");
     SendDlgItemMessage (hDlg, v, CB_SETCURSEL, nv, 0);
 }
 
@@ -6247,13 +6202,13 @@ static void misc_addpri (HWND hDlg, int v, int pri)
     SendDlgItemMessage (hDlg, v, CB_SETCURSEL, pri, 0);
 }
 
-extern char *get_aspi_path(int);
+extern TCHAR *get_aspi_path(int);
 
 static void misc_scsi(HWND hDlg)
 {
     SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)"SPTI");
-    SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)"SPTI + SCSI SCAN");
+    SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)L"SPTI");
+    SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)L"SPTI + SCSI SCAN");
     SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(0)) ? "AdaptecASPI" : "(AdaptecASPI)"));
     SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(1)) ? "NeroASPI" : "(NeroASPI)"));
     SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_ADDSTRING, 0, (LPARAM)((get_aspi_path(2)) ? "FrogASPI" : "(FrogASPI)"));
@@ -6265,11 +6220,11 @@ static void misc_lang(HWND hDlg)
     int i, idx = 0, cnt = 0, lid;
     WORD langid = -1;
 
-    if (regqueryint (NULL, "Language", &lid))
+    if (regqueryint (NULL, L"Language", &lid))
        langid = (WORD)lid;
     SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)"Autodetect");
-    SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)"English (built-in)");
+    SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)L"Autodetect");
+    SendDlgItemMessage (hDlg, IDC_LANGUAGE, CB_ADDSTRING, 0, (LPARAM)L"English (built-in)");
     if (langid == 0)
        idx = 1;
     cnt = 2;
@@ -6305,7 +6260,7 @@ static void misc_setlang(int v)
     }
     if (v == -2)
        langid = -1;
-    regsetint (NULL, "Language", langid);
+    regsetint (NULL, L"Language", langid);
     FreeLibrary(hUIDLL);
     hUIDLL = NULL;
     if (langid >= 0)
@@ -6316,7 +6271,7 @@ static void misc_setlang(int v)
 
 static void values_to_miscdlg (HWND hDlg)
 {
-    char txt[100];
+    TCHAR txt[100];
     int cw;
 
     if (currentpage == MISC1_ID) {
@@ -6347,31 +6302,31 @@ static void values_to_miscdlg (HWND hDlg)
        CheckDlgButton (hDlg, IDC_KBLED_USB, workprefs.win32_kbledmode);
 
        SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_RESETCONTENT, 0, 0);
-       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)"1");
-       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)"5");
-       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)"10");
-       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)"20");
-       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)"30");
-       sprintf (txt, "%d", workprefs.statecapturerate / 50);
+       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)L"1");
+       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)L"5");
+       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)L"10");
+       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)L"20");
+       SendDlgItemMessage (hDlg, IDC_STATE_RATE, CB_ADDSTRING, 0, (LPARAM)L"30");
+       _stprintf (txt, L"%d", workprefs.statecapturerate / 50);
        SendDlgItemMessage( hDlg, IDC_STATE_RATE, WM_SETTEXT, 0, (LPARAM)txt);
 
        SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_RESETCONTENT, 0, 0);
-       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)"5");
-       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)"10");
-       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)"20");
-       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)"50");
-       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)"100");
-       sprintf (txt, "%d", workprefs.statecapturebuffersize / (1024 * 1024));
+       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)L"5");
+       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)L"10");
+       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)L"20");
+       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)L"50");
+       SendDlgItemMessage (hDlg, IDC_STATE_BUFFERSIZE, CB_ADDSTRING, 0, (LPARAM)L"100");
+       _stprintf (txt, L"%d", workprefs.statecapturebuffersize / (1024 * 1024));
        SendDlgItemMessage( hDlg, IDC_STATE_BUFFERSIZE, WM_SETTEXT, 0, (LPARAM)txt);
 
        misc_scsi(hDlg);
        misc_lang(hDlg);
 
        SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_RESETCONTENT, 0, 0);
-       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)"NonLocalVRAM");
-       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)"DefaultRAM");
-       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)"LocalVRAM");
-       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)"SystemRAM");
+       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)L"NonLocalVRAM");
+       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)L"DefaultRAM");
+       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)L"LocalVRAM");
+       SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_ADDSTRING, 0, (LPARAM)L"SystemRAM");
        SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_SETCURSEL, ddforceram, 0);
 
     } else if (currentpage == MISC2_ID) {
@@ -6389,7 +6344,7 @@ static void values_to_miscdlg (HWND hDlg)
 
 static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-    char txt[100];
+    TCHAR txt[100];
     int v, i;
     static int recursive;
 
@@ -6408,19 +6363,19 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 
     case WM_CONTEXTMENU:
        if (GetDlgCtrlID((HWND)wParam) == IDC_DOSAVESTATE) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
-               char path[MAX_DPATH];
-               strcpy (path, s);
+               TCHAR path[MAX_DPATH];
+               _tcscpy (path, s);
                xfree (s);
                if (DiskSelection(hDlg, wParam, 9, &workprefs, path))
-                   save_state (savestate_fname, "Description!");
+                   save_state (savestate_fname, L"Description!");
            }
        } else if (GetDlgCtrlID((HWND)wParam) == IDC_DOLOADSTATE) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
-               char path[MAX_DPATH];
-               strcpy (path, s);
+               TCHAR path[MAX_DPATH];
+               _tcscpy (path, s);
                xfree (s);
                if (DiskSelection(hDlg, wParam, 10, &workprefs, path))
                    savestate_state = STATE_DORESTORE;
@@ -6459,11 +6414,11 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
                    misc_getkbled (hDlg, IDC_KBLED3, 2);
                    break;
                    case IDC_STATE_RATE:
-                   getcbn (hDlg, IDC_STATE_RATE, txt, sizeof (txt));
-                   workprefs.statecapturerate = atol (txt) * 50;
+                   getcbn (hDlg, IDC_STATE_RATE, txt, sizeof (txt) / sizeof (TCHAR));
+                   workprefs.statecapturerate = _tstol (txt) * 50;
                    break;
                    case IDC_STATE_BUFFERSIZE:
-                   getcbn (hDlg, IDC_STATE_BUFFERSIZE, txt, sizeof (txt));
+                   getcbn (hDlg, IDC_STATE_BUFFERSIZE, txt, sizeof (txt) / sizeof (TCHAR));
                    break;
                    case IDC_SCSIMODE:
                    v = SendDlgItemMessage (hDlg, IDC_SCSIMODE, CB_GETCURSEL, 0, 0L);
@@ -6481,7 +6436,7 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
                    v = SendDlgItemMessage (hDlg, IDC_DD_SURFACETYPE, CB_GETCURSEL, 0, 0L);
                    if (v != CB_ERR) {
                        ddforceram = v;
-                       regsetint (NULL, "DirectDraw_Secondary", ddforceram);
+                       regsetint (NULL, L"DirectDraw_Secondary", ddforceram);
                    }
                    break;
                }
@@ -6508,7 +6463,7 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
        break;
        case IDC_DOSAVESTATE:
            if (DiskSelection(hDlg, wParam, 9, &workprefs, 0))
-               save_state (savestate_fname, "Description!");
+               save_state (savestate_fname, L"Description!");
            break;
        case IDC_DOLOADSTATE:
            if (DiskSelection(hDlg, wParam, 10, &workprefs, 0))
@@ -6677,7 +6632,7 @@ static void enable_for_cpudlg (HWND hDlg)
 
 static void values_to_cpudlg (HWND hDlg)
 {
-    char cache[8] = "";
+    TCHAR cache[8] = L"";
     int cpu;
 
     SendDlgItemMessage (hDlg, IDC_SPEED, TBM_SETPOS, TRUE, workprefs.m68k_speed <= 0 ? 1 : workprefs.m68k_speed / CYCLE_UNIT );
@@ -6702,7 +6657,7 @@ static void values_to_cpudlg (HWND hDlg)
     CheckRadioButton (hDlg, IDC_TRUST0, IDC_TRUST1, trust_ids[workprefs.comptrustbyte]);
 
     SendDlgItemMessage (hDlg, IDC_CACHE, TBM_SETPOS, TRUE, workprefs.cachesize / 1024);
-    sprintf (cache, "%d MB", workprefs.cachesize / 1024 );
+    _stprintf (cache, L"%d MB", workprefs.cachesize / 1024 );
     SetDlgItemText (hDlg, IDC_CACHETEXT, cache);
 
     CheckDlgButton (hDlg, IDC_NOFLAGS, workprefs.compnf);
@@ -6900,43 +6855,43 @@ static int exact_log2 (int v)
     return l;
 }
 
-static char *drivesounds;
+static TCHAR *drivesounds;
 
 static void sound_loaddrivesamples (void)
 {
     WIN32_FIND_DATA fd;
     HANDLE h;
-    char *p;
+    TCHAR *p;
     int len = 0;
-    char dirname[1024];
+    TCHAR dirname[1024];
 
     free (drivesounds);
     p = drivesounds = 0;
-    sprintf (dirname, "%s\\%sfloppysounds\\*.wav", start_path_data, WIN32_PLUGINDIR);
+    _stprintf (dirname, L"%s\\%sfloppysounds\\*.wav", start_path_data, WIN32_PLUGINDIR);
     h = FindFirstFile (dirname, &fd);
     if (h == INVALID_HANDLE_VALUE) {
-       sprintf (dirname, "%s\\uae_data\\*.wav", start_path_data);
+       _stprintf (dirname, L"%s\\uae_data\\*.wav", start_path_data);
         h = FindFirstFile (dirname, &fd);
         if (h == INVALID_HANDLE_VALUE)
            return;
     }
     for (;;) {
        if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
-           char *name = fd.cFileName;
-           if (strlen (name) > strlen (DS_NAME_CLICK) + 4 && !strncmp (name, DS_NAME_CLICK, strlen (DS_NAME_CLICK))) {
+           TCHAR *name = fd.cFileName;
+           if (_tcslen (name) > _tcslen (DS_NAME_CLICK) + 4 && !_tcsncmp (name, DS_NAME_CLICK, _tcslen (DS_NAME_CLICK))) {
                if (p - drivesounds < 1000) {
-                   char *oldp = p;
+                   TCHAR *oldp = p;
                    len += 2000;
                    drivesounds = p = realloc (drivesounds, len);
                    if (oldp) {
                        do {
-                           p = p + strlen (p) + 1;
+                           p = p + _tcslen (p) + 1;
                        } while (p[0]);
                    }
                }
-               strcpy (p, name + strlen (DS_NAME_CLICK));
-               p[strlen (name + strlen (DS_NAME_CLICK)) - 4] = 0;
-               p += strlen (p);
+               _tcscpy (p, name + _tcslen (DS_NAME_CLICK));
+               p[_tcslen (name + _tcslen (DS_NAME_CLICK)) - 4] = 0;
+               p += _tcslen (p);
                *p++ = 0;
                *p = 0;
            }
@@ -6952,18 +6907,18 @@ extern int soundpercent;
 static void update_soundgui (HWND hDlg)
 {
     int bufsize;
-    char txt[20];
+    TCHAR txt[20];
 
     bufsize = exact_log2 (workprefs.sound_maxbsiz / 1024);
-    sprintf (txt, "%d", bufsize);
+    _stprintf (txt, L"%d", bufsize);
     SetDlgItemText (hDlg, IDC_SOUNDBUFFERMEM, txt);
 
     SendDlgItemMessage( hDlg, IDC_SOUNDVOLUME, TBM_SETPOS, TRUE, 100 - workprefs.sound_volume);
-    sprintf (txt, "%d%%", 100 - workprefs.sound_volume);
+    _stprintf (txt, L"%d%%", 100 - workprefs.sound_volume);
     SetDlgItemText (hDlg, IDC_SOUNDVOLUME2, txt);
 
     SendDlgItemMessage( hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETPOS, TRUE, 100 - workprefs.dfxclickvolume);
-    sprintf (txt, "%d%%", 100 - workprefs.dfxclickvolume);
+    _stprintf (txt, L"%d%%", 100 - workprefs.dfxclickvolume);
     SetDlgItemText (hDlg, IDC_SOUNDDRIVEVOLUME2, txt);
 }
 
@@ -6975,7 +6930,7 @@ static void values_to_sounddlg (HWND hDlg)
     int sound_freq = workprefs.sound_freq;
     int produce_sound = workprefs.produce_sound;
     int stereo = workprefs.sound_stereo;
-    char txt[100], txt2[100], *p;
+    TCHAR txt[100], txt2[100], *p;
     int i, selected;
     LRESULT idx;
 
@@ -6983,15 +6938,15 @@ static void values_to_sounddlg (HWND hDlg)
        workprefs.sound_maxbsiz = DEFAULT_SOUND_MAXB;
 
     SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_OFF, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_OFF, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED_E, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_EMULATED_E, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_AGA, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_AGA, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_A500, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_FILTER_ON_A500, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_ADDSTRING, 0, (LPARAM)txt);
     i = 0;
     switch (workprefs.sound_filter)
@@ -7009,65 +6964,65 @@ static void values_to_sounddlg (HWND hDlg)
     SendDlgItemMessage (hDlg, IDC_SOUNDFILTER, CB_SETCURSEL, i, 0);
 
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString (IDS_SOUND_MONO, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_MONO, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_STEREO, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_STEREO, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_STEREO2, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_STEREO2, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_4CHANNEL, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_4CHANNEL, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_CLONED51, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_CLONED51, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_51, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_51, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_ADDSTRING, 0, (LPARAM)txt);
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREO, CB_SETCURSEL, workprefs.sound_stereo, 0);
 
     SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)"-");
-    WIN32GUI_LoadUIString (IDS_SOUND_SWAP_PAULA, txt, sizeof (txt));
+    SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)L"-");
+    WIN32GUI_LoadUIString (IDS_SOUND_SWAP_PAULA, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_SWAP_AHI, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_SWAP_AHI, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_SOUND_SWAP_BOTH, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_SOUND_SWAP_BOTH, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_ADDSTRING, 0, (LPARAM)txt);
     SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_SETCURSEL,
        workprefs.sound_stereo_swap_paula + workprefs.sound_stereo_swap_ahi * 2, 0);
 
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOSEP, CB_RESETCONTENT, 0, 0);
     for (i = 10; i >= 0; i--) {
-       sprintf (txt, "%d%%", i * 10);
+       _stprintf (txt, L"%d%%", i * 10);
        SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOSEP, CB_ADDSTRING, 0, (LPARAM)txt);
     }
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOSEP, CB_SETCURSEL, 10 - workprefs.sound_stereo_separation, 0);
 
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_ADDSTRING, 0, (LPARAM)"-");
+    SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_ADDSTRING, 0, (LPARAM)L"-");
     for (i = 0; i < 10; i++) {
-       sprintf (txt, "%d", i + 1);
+       _stprintf (txt, L"%d", i + 1);
        SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_ADDSTRING, 0, (LPARAM)txt);
     }
     SendDlgItemMessage (hDlg, IDC_SOUNDSTEREOMIX, CB_SETCURSEL,
        workprefs.sound_mixed_stereo_delay > 0 ? workprefs.sound_mixed_stereo_delay : 0, 0);
 
     SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString (IDS_DISABLED, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_DISABLED, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)txt);
-    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)"Anti");
-    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)"Sinc");
-    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)"RH");
-    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)"Crux");
+    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)L"Anti");
+    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)L"Sinc");
+    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)L"RH");
+    SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_ADDSTRING, 0, (LPARAM)L"Crux");
     SendDlgItemMessage (hDlg, IDC_SOUNDINTERPOLATION, CB_SETCURSEL, workprefs.sound_interpol, 0);
 
     SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, CB_RESETCONTENT, 0, 0);
     i = 0;
     selected = -1;
     while (soundfreqs[i]) {
-       sprintf (txt, "%d", soundfreqs[i]);
+       _stprintf (txt, L"%d", soundfreqs[i]);
        SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, CB_ADDSTRING, 0, (LPARAM)txt);
        i++;
     }
-    sprintf (txt, "%d", workprefs.sound_freq);
+    _stprintf (txt, L"%d", workprefs.sound_freq);
     SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, WM_SETTEXT, 0, (LPARAM)txt);
 
     switch (workprefs.produce_sound)
@@ -7096,20 +7051,20 @@ static void values_to_sounddlg (HWND hDlg)
        idx = 0;
     SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_RESETCONTENT, 0, 0);
     for (i = 0; i < 4; i++) {
-       sprintf (txt, "DF%d:", i);
+       _stprintf (txt, L"DF%d:", i);
        SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_ADDSTRING, 0, (LPARAM)txt);
     }
     SendDlgItemMessage (hDlg, IDC_SOUNDDRIVE, CB_SETCURSEL, idx, 0);
     SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString (IDS_DRIVESOUND_NONE, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_DRIVESOUND_NONE, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)txt);
-    WIN32GUI_LoadUIString (IDS_DRIVESOUND_DEFAULT_A500, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (IDS_DRIVESOUND_DEFAULT_A500, txt, sizeof (txt) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)txt);
     driveclick_fdrawcmd_detect ();
     if (driveclick_pcdrivemask) {
        for (i = 0; i < 2; i++) {
-           WIN32GUI_LoadUIString (IDS_DRIVESOUND_PC_FLOPPY, txt, sizeof (txt));
-           sprintf (txt2, txt, 'A' + i);
+           WIN32GUI_LoadUIString (IDS_DRIVESOUND_PC_FLOPPY, txt, sizeof (txt) / sizeof (TCHAR));
+           _stprintf (txt2, txt, 'A' + i);
            SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)txt2);
        }
     }
@@ -7118,19 +7073,19 @@ static void values_to_sounddlg (HWND hDlg)
     if (p) {
        while (p[0]) {
            SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_ADDSTRING, 0, (LPARAM)p);
-           p += strlen (p) + 1;
+           p += _tcslen (p) + 1;
        }
     }
     if (workprefs.dfxclick[idx] < 0) {
        p = drivesounds;
        i = DS_BUILD_IN_SOUNDS + (driveclick_pcdrivemask ? 2 : 0) + 1;
        while (p && p[0]) {
-           if (!strcmpi (p, workprefs.dfxclickexternal[idx])) {
+           if (!_tcsicmp (p, workprefs.dfxclickexternal[idx])) {
                SendDlgItemMessage (hDlg, IDC_SOUNDDRIVESELECT, CB_SETCURSEL, i, 0);
                break;
            }
            i++;
-           p += strlen (p) + 1;
+           p += _tcslen (p) + 1;
        }
 
     } else {
@@ -7142,15 +7097,15 @@ static void values_to_sounddlg (HWND hDlg)
 
 static void values_from_sounddlg (HWND hDlg)
 {
-    char txt[10];
+    TCHAR txt[10];
     LRESULT idx;
 
     idx = SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, CB_GETCURSEL, 0, 0);
     if (idx >= 0) {
        workprefs.sound_freq = soundfreqs[idx];
     } else {
-       SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, WM_GETTEXT, (WPARAM)sizeof (txt), (LPARAM)txt);
-       workprefs.sound_freq = atol (txt);
+       SendDlgItemMessage (hDlg, IDC_SOUNDFREQ, WM_GETTEXT, (WPARAM)sizeof (txt) / sizeof (TCHAR), (LPARAM)txt);
+       workprefs.sound_freq = _tstol (txt);
     }
     if (workprefs.sound_freq < 8000)
        workprefs.sound_freq = 8000;
@@ -7215,11 +7170,11 @@ static void values_from_sounddlg (HWND hDlg)
            int xtra = driveclick_pcdrivemask ? 2 : 0;
            if (res > DS_BUILD_IN_SOUNDS + xtra) {
                int j = res - (DS_BUILD_IN_SOUNDS + xtra + 1);
-               char *p = drivesounds;
+               TCHAR *p = drivesounds;
                while (j-- > 0)
-                   p += strlen (p) + 1;
+                   p += _tcslen (p) + 1;
                workprefs.dfxclick[idx] = -1;
-               strcpy (workprefs.dfxclickexternal[idx], p);
+               _tcscpy (workprefs.dfxclickexternal[idx], p);
            } else {
                workprefs.dfxclick[idx] = res;
                workprefs.dfxclickexternal[idx][0] = 0;
@@ -7260,13 +7215,13 @@ static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                gotnonds = 1;
        }
        for (card = 0; card < numdevs; card++) {
-           char tmp[MAX_DPATH];
+           TCHAR tmp[MAX_DPATH];
            int type = sound_devices[card].type;
            if (gotnonds)
-               sprintf (tmp, "%s: %s",  type == SOUND_DEVICE_DS ? "DS" : (type == SOUND_DEVICE_AL ? "AL" : "PA"),
+               _stprintf (tmp, L"%s: %s",  type == SOUND_DEVICE_DS ? L"DS" : (type == SOUND_DEVICE_AL ? L"AL" : L"PA"),
                    sound_devices[card].name);
            else
-               strcpy (tmp, sound_devices[card].name);
+               _tcscpy (tmp, sound_devices[card].name);
            SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_ADDSTRING, 0, (LPARAM)tmp);
        }
        if (numdevs == 0)
@@ -7308,9 +7263,9 @@ static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 
 struct fsvdlg_vals
 {
-    char volume[MAX_DPATH];
-    char device[MAX_DPATH];
-    char rootdir[MAX_DPATH];
+    TCHAR volume[MAX_DPATH];
+    TCHAR device[MAX_DPATH];
+    TCHAR rootdir[MAX_DPATH];
     int bootpri;
     int autoboot;
     int donotmount;
@@ -7318,15 +7273,15 @@ struct fsvdlg_vals
     int rdb;
 };
 
-static struct fsvdlg_vals empty_fsvdlg = { "", "", "", 0, 1, 1, 1, 0 };
+static struct fsvdlg_vals empty_fsvdlg = { L"", L"", L"", 0, 1, 1, 1, 0 };
 static struct fsvdlg_vals current_fsvdlg;
 
 struct hfdlg_vals
 {
-    char volumename[MAX_DPATH];
-    char devicename[MAX_DPATH];
-    char filename[MAX_DPATH];
-    char fsfilename[MAX_DPATH];
+    TCHAR volumename[MAX_DPATH];
+    TCHAR devicename[MAX_DPATH];
+    TCHAR filename[MAX_DPATH];
+    TCHAR fsfilename[MAX_DPATH];
     int sectors;
     int reserved;
     int surfaces;
@@ -7340,16 +7295,16 @@ struct hfdlg_vals
     int controller;
 };
 
-static struct hfdlg_vals empty_hfdlg = { "", "", "", "", 32, 2, 1, 0, 512, 1, 0, 0, 0, 1, 0 };
+static struct hfdlg_vals empty_hfdlg = { L"", L"", L"", L"", 32, 2, 1, 0, 512, 1, 0, 0, 0, 1, 0 };
 static struct hfdlg_vals current_hfdlg;
 static int archivehd;
 
 static void volumeselectfile (HWND hDlg)
 {
-    char directory_path[MAX_DPATH];
-    strcpy (directory_path, current_fsvdlg.rootdir);
+    TCHAR directory_path[MAX_DPATH];
+    _tcscpy (directory_path, current_fsvdlg.rootdir);
     if (DiskSelection (hDlg, 0, 14, &workprefs, directory_path)) {
-        char *s = filesys_createvolname (NULL, directory_path, "Harddrive");
+        TCHAR *s = filesys_createvolname (NULL, directory_path, L"Harddrive");
         SetDlgItemText (hDlg, IDC_PATH_NAME, directory_path);
         SetDlgItemText (hDlg, IDC_VOLUME_NAME, s);
         xfree (s);
@@ -7361,10 +7316,10 @@ static void volumeselectfile (HWND hDlg)
 static void volumeselectdir (HWND hDlg, int newdir)
 {
     const GUID volumeguid = { 0x1df05121, 0xcc08, 0x46ea, { 0x80, 0x3f, 0x98, 0x3c, 0x54, 0x88, 0x53, 0x76 } };
-    char szTitle[MAX_DPATH];
-    char directory_path[MAX_DPATH];
+    TCHAR szTitle[MAX_DPATH];
+    TCHAR directory_path[MAX_DPATH];
 
-    strcpy (directory_path, current_fsvdlg.rootdir);
+    _tcscpy (directory_path, current_fsvdlg.rootdir);
     if (!newdir) {
        WIN32GUI_LoadUIString (IDS_SELECTFILESYSROOT, szTitle, MAX_DPATH);
        if (DirectorySelection (hDlg, &volumeguid, directory_path))
@@ -7407,16 +7362,16 @@ static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam,
 
        case WM_CONTEXTMENU:
            if (GetDlgCtrlID ((HWND)wParam) == IDC_FS_SELECT_FILE) {
-               char *s = favoritepopup (hDlg);
+               TCHAR *s = favoritepopup (hDlg);
                if (s) {
-                   strcpy (current_fsvdlg.rootdir, s);
+                   _tcscpy (current_fsvdlg.rootdir, s);
                    xfree (s);
                    volumeselectfile (hDlg);
                }
            } else if (GetDlgCtrlID ((HWND)wParam) == IDC_FS_SELECT_DIR) {
-               char *s = favoritepopup (hDlg);
+               TCHAR *s = favoritepopup (hDlg);
                if (s) {
-                   strcpy (current_fsvdlg.rootdir, s);
+                   _tcscpy (current_fsvdlg.rootdir, s);
                    xfree (s);
                    volumeselectdir (hDlg, 1);
                }
@@ -7431,8 +7386,8 @@ static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam,
                switch (LOWORD (wParam))
                {
                    case IDC_FS_SELECT_EJECT:
-                       SetDlgItemText (hDlg, IDC_PATH_NAME, "");
-                       SetDlgItemText (hDlg, IDC_VOLUME_NAME, "");
+                       SetDlgItemText (hDlg, IDC_PATH_NAME, L"");
+                       SetDlgItemText (hDlg, IDC_VOLUME_NAME, L"");
                        CheckDlgButton (hDlg, IDC_FS_RW, TRUE);
                        ew (hDlg, IDC_FS_RW, TRUE);
                        archivehd = -1;
@@ -7451,9 +7406,9 @@ static INT_PTR CALLBACK VolumeSettingsProc (HWND hDlg, UINT msg, WPARAM wParam,
                    break;
                }
            }
-           GetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir, sizeof current_fsvdlg.rootdir);
-           GetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume, sizeof current_fsvdlg.volume);
-           GetDlgItemText (hDlg, IDC_VOLUME_DEVICE, current_fsvdlg.device, sizeof current_fsvdlg.device);
+           GetDlgItemText (hDlg, IDC_PATH_NAME, current_fsvdlg.rootdir, sizeof current_fsvdlg.rootdir / sizeof (TCHAR));
+           GetDlgItemText (hDlg, IDC_VOLUME_NAME, current_fsvdlg.volume, sizeof current_fsvdlg.volume / sizeof (TCHAR));
+           GetDlgItemText (hDlg, IDC_VOLUME_DEVICE, current_fsvdlg.device, sizeof current_fsvdlg.device / sizeof (TCHAR));
            current_fsvdlg.rw = IsDlgButtonChecked (hDlg, IDC_FS_RW);
            current_fsvdlg.bootpri = GetDlgItemInt (hDlg, IDC_VOLUME_BOOTPRI, NULL, TRUE);
            current_fsvdlg.autoboot = IsDlgButtonChecked (hDlg, IDC_FS_AUTOBOOT);
@@ -7491,33 +7446,33 @@ static void sethardfile (HWND hDlg)
 static void inithdcontroller (HWND hDlg)
 {
     SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_RESETCONTENT, 0, 0);
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"UAE");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"IDE0");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"IDE1");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"IDE2");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"IDE3");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSI0");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSI1");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSI2");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSI3");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSI4");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSI5");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSI6");
-    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)"SCSRAM");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"UAE");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"IDE0");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"IDE1");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"IDE2");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"IDE3");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSI0");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSI1");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSI2");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSI3");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSI4");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSI5");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSI6");
+    SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_ADDSTRING, 0, (LPARAM)L"SCSRAM");
     SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_SETCURSEL, 0, 0);
 }
 
 static void inithardfile (HWND hDlg)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     ew (hDlg, IDC_HF_DOSTYPE, FALSE);
     ew (hDlg, IDC_HF_CREATE, FALSE);
     inithdcontroller (hDlg);
     SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_RESETCONTENT, 0, 0);
-    WIN32GUI_LoadUIString (IDS_HF_FS_CUSTOM, tmp, sizeof (tmp));
-    SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)"OFS/FFS/RDB");
-    SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)"SFS");
+    WIN32GUI_LoadUIString (IDS_HF_FS_CUSTOM, tmp, sizeof (tmp) / sizeof (TCHAR));
+    SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)L"OFS/FFS/RDB");
+    SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)L"SFS");
     SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_ADDSTRING, 0, (LPARAM)tmp);
     SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_SETCURSEL, 0, 0);
 }
@@ -7525,22 +7480,22 @@ static void inithardfile (HWND hDlg)
 static void sethfdostype (HWND hDlg, int idx)
 {
     if (idx == 1)
-       SetDlgItemText (hDlg, IDC_HF_DOSTYPE, "0x53465300");
+       SetDlgItemText (hDlg, IDC_HF_DOSTYPE, L"0x53465300");
     else
-       SetDlgItemText (hDlg, IDC_HF_DOSTYPE, "");
+       SetDlgItemText (hDlg, IDC_HF_DOSTYPE, L"");
 }
 
 static void hardfile_testrdb (HWND hDlg, struct hfdlg_vals *hdf)
 {
-    void *f = zfile_fopen (hdf->filename, "rb");
-    char tmp[8] = { 0 };
+    void *f = zfile_fopen (hdf->filename, L"rb");
+    uae_u8 tmp[8] = { 0 };
     if (!f)
        return;
     zfile_fread (tmp, 1, sizeof (tmp), f);
     zfile_fclose (f);
-    if (!memcmp (tmp + 2, "CIS", 3))
+    if (!memcmp (tmp + 2, L"CIS", 3))
        hdf->controller = HD_CONTROLLER_PCMCIA_SRAM;
-    if (!memcmp (tmp, "RDSK\0\0\0", 7)) {
+    if (!memcmp (tmp, L"RDSK\0\0\0", 7)) {
        hdf->sectors = 0;
        hdf->surfaces = 0;
        hdf->reserved = 0;
@@ -7558,7 +7513,8 @@ static void updatehdfinfo (HWND hDlg, int force)
     static uae_u64 bsize;
     static uae_u8 id[512];
     int blocks, cyls, i;
-    char tmp[200], idtmp[9], tmp2[200];
+    TCHAR tmp[200], tmp2[200];
+    TCHAR idtmp[9];
 
     if (force) {
        struct hardfiledata hfd;
@@ -7576,8 +7532,8 @@ static void updatehdfinfo (HWND hDlg, int force)
     if (current_hfdlg.blocksize * current_hfdlg.sectors * current_hfdlg.surfaces)
         cyls = bsize / (current_hfdlg.blocksize * current_hfdlg.sectors * current_hfdlg.surfaces);
     blocks = cyls * (current_hfdlg.sectors * current_hfdlg.surfaces);
-    for (i = 0; i < 8; i++) {
-       unsigned char c = id[i];
+    for (i = 0; i < sizeof (idtmp) / sizeof (TCHAR) - 1; i++) {
+       TCHAR c = id[i];
        if (c < 32 || c > 126)
            c = '.';
        idtmp[i] = c;
@@ -7586,39 +7542,39 @@ static void updatehdfinfo (HWND hDlg, int force)
 
     tmp[0] = 0;
     if (bsize) {
-       sprintf (tmp2, " %s [%02X%02X%02X%02X%02X%02X%02X%02X]", idtmp, id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
+       _stprintf (tmp2, L" %s [%02X%02X%02X%02X%02X%02X%02X%02X]", idtmp, id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
        if (!cyls || !blocks) {
-           sprintf (tmp, "%dMB", bsize / (1024 * 1024));
+           _stprintf (tmp, L"%dMB", bsize / (1024 * 1024));
        } else {
-           sprintf (tmp, "%u cyls, %u blocks, %.1fMB/%.1fMB",
+           _stprintf (tmp, L"%u cyls, %u blocks, %.1fMB/%.1fMB",
                cyls, blocks,
                (double)blocks * 1.0 * current_hfdlg.blocksize / (1024.0 * 1024.0),
                (double)bsize / (1024.0 * 1024.0));
            if (cyls > 65535) {
-               sprintf (tmp2, " %4.4s [%02X%02X%02X%02X]", idtmp, id[0], id[1], id[2], id[3]);
-               strcat (tmp, " [Too many cyls]");
+               _stprintf (tmp2, L" %4.4s [%02X%02X%02X%02X]", idtmp, id[0], id[1], id[2], id[3]);
+               _tcscat (tmp, L" [Too many cyls]");
            }
        }
-       strcat (tmp, tmp2);
+       _tcscat (tmp, tmp2);
     }
     SetDlgItemText (hDlg, IDC_HDFINFO, tmp);
 }
 
-static void hardfileselecthdf (HWND hDlg, char *newpath)
+static void hardfileselecthdf (HWND hDlg, TCHAR *newpath)
 {
     DiskSelection (hDlg, IDC_PATH_NAME, 2, &workprefs, newpath);
-    GetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.filename, sizeof current_hfdlg.filename);
+    GetDlgItemText (hDlg, IDC_PATH_NAME, current_hfdlg.filename, sizeof current_hfdlg.filename / sizeof (TCHAR));
     inithardfile (hDlg);
     hardfile_testrdb (hDlg, &current_hfdlg);
     updatehdfinfo (hDlg, 1);
 }
 
-static void hardfilecreatehdf (HWND hDlg, char *newpath)
+static void hardfilecreatehdf (HWND hDlg, TCHAR *newpath)
 {
     LRESULT res;
     UINT setting = CalculateHardfileSize (hDlg);
-    char dostype[16];
-    GetDlgItemText (hDlg, IDC_HF_DOSTYPE, dostype, sizeof (dostype));
+    TCHAR dostype[16];
+    GetDlgItemText (hDlg, IDC_HF_DOSTYPE, dostype, sizeof (dostype) / sizeof (TCHAR));
     res = SendDlgItemMessage (hDlg, IDC_HF_TYPE, CB_GETCURSEL, 0, 0);
     if (res == 0)
         dostype[0] = 0;
@@ -7629,7 +7585,7 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam
 {
     static int recursive = 0;
     LRESULT res, posn;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     switch (msg) {
     case WM_INITDIALOG:
@@ -7644,26 +7600,26 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam
 
     case WM_CONTEXTMENU:
         if (GetDlgCtrlID ((HWND)wParam) == IDC_SELECTOR) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
-               char path[MAX_DPATH];
-               strcpy (path, s);
+               TCHAR path[MAX_DPATH];
+               _tcscpy (path, s);
                xfree (s);
                hardfileselecthdf (hDlg, path);
            }
        } else if (GetDlgCtrlID ((HWND)wParam) == IDC_FILESYS_SELECTOR) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
-               char path[MAX_DPATH];
-               strcpy (path, s);
+               TCHAR path[MAX_DPATH];
+               _tcscpy (path, s);
                xfree (s);
                DiskSelection (hDlg, IDC_PATH_FILESYS, 12, &workprefs, path);
            }
        } else if (GetDlgCtrlID ((HWND)wParam) == IDC_HF_CREATE) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
-               char path[MAX_DPATH];
-               strcpy (path, s);
+               TCHAR path[MAX_DPATH];
+               _tcscpy (path, s);
                xfree (s);
                hardfilecreatehdf (hDlg, path);
            }
@@ -7694,9 +7650,9 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam
                DiskSelection (hDlg, IDC_PATH_FILESYS, 12, &workprefs, 0);
                break;
            case IDOK:
-               if (strlen (current_hfdlg.filename) == 0) {
-                   char szMessage[MAX_DPATH];
-                   char szTitle[MAX_DPATH];
+               if (_tcslen (current_hfdlg.filename) == 0) {
+                   TCHAR szMessage[MAX_DPATH];
+                   TCHAR szTitle[MAX_DPATH];
                    WIN32GUI_LoadUIString (IDS_MUSTSELECTFILE, szMessage, MAX_DPATH);
                    WIN32GUI_LoadUIString (IDS_SETTINGSERROR, szTitle, MAX_DPATH);
                    MessageBox (hDlg, szMessage, szTitle, MB_OK | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND);
@@ -7720,8 +7676,8 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam
                SetDlgItemInt (hDlg, IDC_SECTORS, 0, FALSE);
                SetDlgItemInt (hDlg, IDC_RESERVED, 0, FALSE);
                SetDlgItemInt (hDlg, IDC_HEADS, 0, FALSE);
-               SetDlgItemText (hDlg, IDC_PATH_FILESYS, "");
-               SetDlgItemText (hDlg, IDC_HARDFILE_DEVICE, "");
+               SetDlgItemText (hDlg, IDC_PATH_FILESYS, L"");
+               SetDlgItemText (hDlg, IDC_HARDFILE_DEVICE, L"");
                current_hfdlg.sectors = current_hfdlg.reserved = current_hfdlg.surfaces = 0;
                current_hfdlg.autoboot = 1;
                current_hfdlg.donotmount = 0;
@@ -7734,13 +7690,13 @@ static INT_PTR CALLBACK HardfileSettingsProc (HWND hDlg, UINT msg, WPARAM wParam
        current_hfdlg.surfaces  = GetDlgItemInt (hDlg, IDC_HEADS, NULL, FALSE);
        current_hfdlg.blocksize = GetDlgItemInt (hDlg, IDC_BLOCKSIZE, NULL, FALSE);
        current_hfdlg.bootpri = GetDlgItemInt (hDlg, IDC_HARDFILE_BOOTPRI, NULL, TRUE);
-       GetDlgItemText (hDlg, IDC_PATH_NAME, tmp, sizeof tmp);
-       if (strcmp (tmp, current_hfdlg.filename)) {
-           strcpy (current_hfdlg.filename, tmp);
+       GetDlgItemText (hDlg, IDC_PATH_NAME, tmp, sizeof tmp / sizeof (TCHAR));
+       if (_tcscmp (tmp, current_hfdlg.filename)) {
+           _tcscpy (current_hfdlg.filename, tmp);
            updatehdfinfo (hDlg, 1);
        }
-       GetDlgItemText (hDlg, IDC_PATH_FILESYS, current_hfdlg.fsfilename, sizeof current_hfdlg.fsfilename);
-       GetDlgItemText (hDlg, IDC_HARDFILE_DEVICE, current_hfdlg.devicename, sizeof current_hfdlg.devicename);
+       GetDlgItemText (hDlg, IDC_PATH_FILESYS, current_hfdlg.fsfilename, sizeof current_hfdlg.fsfilename / sizeof (TCHAR));
+       GetDlgItemText (hDlg, IDC_HARDFILE_DEVICE, current_hfdlg.devicename, sizeof current_hfdlg.devicename / sizeof (TCHAR));
        posn = SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_GETCURSEL, 0, 0);
        if (posn != CB_ERR)
            current_hfdlg.controller = posn;
@@ -7777,7 +7733,7 @@ static INT_PTR CALLBACK HarddriveSettingsProc (HWND hDlg, UINT msg, WPARAM wPara
        index = -1;
        for (i = 0; i < hdf_getnumharddrives (); i++) {
            SendDlgItemMessage (hDlg, IDC_HARDDRIVE, CB_ADDSTRING, 0, (LPARAM)hdf_getnameharddrive (i, 1, NULL));
-           if (!strcmp (current_hfdlg.filename, hdf_getnameharddrive (i, 0, NULL)))
+           if (!_tcscmp (current_hfdlg.filename, hdf_getnameharddrive (i, 0, NULL)))
                index = i;
        }
        if (index >= 0) {
@@ -7818,7 +7774,7 @@ static INT_PTR CALLBACK HarddriveSettingsProc (HWND hDlg, UINT msg, WPARAM wPara
            }
        }
        if (posn != CB_ERR)
-           strcpy (current_hfdlg.filename, hdf_getnameharddrive ((int)posn, 0, &current_hfdlg.blocksize));
+           _tcscpy (current_hfdlg.filename, hdf_getnameharddrive ((int)posn, 0, &current_hfdlg.blocksize));
        current_hfdlg.rw = IsDlgButtonChecked (hDlg, IDC_HDF_RW);
        posn = SendDlgItemMessage (hDlg, IDC_HDF_CONTROLLER, CB_GETCURSEL, 0, 0);
        if (posn != CB_ERR)
@@ -7921,17 +7877,17 @@ static void harddisk_edit (HWND hDlg)
        current_hfdlg.blocksize = uci->blocksize;
        current_hfdlg.controller = uci->controller;
 
-       strncpy (current_hfdlg.filename, uci->rootdir, (sizeof current_hfdlg.filename) - 1);
-       current_hfdlg.filename[(sizeof current_hfdlg.filename) - 1] = '\0';
+       _tcsncpy (current_hfdlg.filename, uci->rootdir, (sizeof current_hfdlg.filename  / sizeof (TCHAR)) - 1);
+       current_hfdlg.filename[(sizeof current_hfdlg.filename / sizeof (TCHAR)) - 1] = '\0';
        current_hfdlg.fsfilename[0] = 0;
        if (uci->filesys) {
-           strncpy (current_hfdlg.fsfilename, uci->filesys, (sizeof current_hfdlg.fsfilename) - 1);
-           current_hfdlg.fsfilename[(sizeof current_hfdlg.fsfilename) - 1] = '\0';
+           _tcsncpy (current_hfdlg.fsfilename, uci->filesys, (sizeof current_hfdlg.fsfilename / sizeof (TCHAR)) - 1);
+           current_hfdlg.fsfilename[(sizeof current_hfdlg.fsfilename / sizeof (TCHAR)) - 1] = '\0';
        }
        current_fsvdlg.device[0] = 0;
        if (uci->devname) {
-           strncpy (current_hfdlg.devicename, uci->devname, (sizeof current_hfdlg.devicename) - 1);
-           current_hfdlg.devicename[(sizeof current_hfdlg.devicename) - 1] = '\0';
+           _tcsncpy (current_hfdlg.devicename, uci->devname, (sizeof current_hfdlg.devicename / sizeof (TCHAR)) - 1);
+           current_hfdlg.devicename[(sizeof current_hfdlg.devicename / sizeof (TCHAR)) - 1] = '\0';
        }
        current_hfdlg.rw = !uci->readonly;
        current_hfdlg.bootpri = uci->bootpri;
@@ -7945,22 +7901,22 @@ static void harddisk_edit (HWND hDlg)
     {
        current_hfdlg.controller = uci->controller;
        current_hfdlg.rw = !uci->readonly;
-       strncpy (current_hfdlg.filename, uci->rootdir, (sizeof current_hfdlg.filename) - 1);
-       current_hfdlg.filename[(sizeof current_hfdlg.filename) - 1] = '\0';
+       _tcsncpy (current_hfdlg.filename, uci->rootdir, (sizeof current_hfdlg.filename) / sizeof (TCHAR) - 1);
+       current_hfdlg.filename[(sizeof current_hfdlg.filename) / sizeof (TCHAR) - 1] = '\0';
        if (CustomDialogBox (IDD_HARDDRIVE, hDlg, HarddriveSettingsProc)) {
            new_harddrive (hDlg, entry);
        }
     }
     else /* Filesystem */
     {
-       strncpy (current_fsvdlg.rootdir, uci->rootdir, (sizeof current_fsvdlg.rootdir) - 1);
-       current_fsvdlg.rootdir[sizeof (current_fsvdlg.rootdir) - 1] = '\0';
-       strncpy (current_fsvdlg.volume, uci->volname, (sizeof current_fsvdlg.volume) - 1);
-       current_fsvdlg.volume[sizeof (current_fsvdlg.volume) - 1] = '\0';
+       _tcsncpy (current_fsvdlg.rootdir, uci->rootdir, (sizeof current_fsvdlg.rootdir / sizeof (TCHAR)) - 1);
+       current_fsvdlg.rootdir[sizeof (current_fsvdlg.rootdir) / sizeof (TCHAR) - 1] = '\0';
+       _tcsncpy (current_fsvdlg.volume, uci->volname, (sizeof current_fsvdlg.volume / sizeof (TCHAR)) - 1);
+       current_fsvdlg.volume[sizeof (current_fsvdlg.volume) / sizeof (TCHAR) - 1] = '\0';
        current_fsvdlg.device[0] = 0;
        if (uci->devname) {
-           strncpy (current_fsvdlg.device, uci->devname, (sizeof current_fsvdlg.device) - 1);
-           current_fsvdlg.device[sizeof (current_fsvdlg.device) - 1] = '\0';
+           _tcsncpy (current_fsvdlg.device, uci->devname, (sizeof current_fsvdlg.device) / sizeof (TCHAR) - 1);
+           current_fsvdlg.device[sizeof (current_fsvdlg.device) / sizeof (TCHAR) - 1] = '\0';
        }
        current_fsvdlg.rw = !uci->readonly;
        current_fsvdlg.bootpri = uci->bootpri;
@@ -8005,8 +7961,8 @@ static void harddiskdlg_button (HWND hDlg, int button)
      case IDC_NEW_HD:
        memset (&current_hfdlg, 0, sizeof (current_hfdlg));
        if (hdf_init_target () == 0) {
-           char tmp[MAX_DPATH];
-           WIN32GUI_LoadUIString (IDS_NOHARDDRIVES, tmp, sizeof (tmp));
+           TCHAR tmp[MAX_DPATH];
+           WIN32GUI_LoadUIString (IDS_NOHARDDRIVES, tmp, sizeof (tmp) / sizeof (TCHAR));
            gui_message (tmp);
        } else {
            if (CustomDialogBox (IDD_HARDDRIVE, hDlg, HarddriveSettingsProc))
@@ -8175,16 +8131,16 @@ static INT_PTR CALLBACK HarddiskDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPA
 
 static void out_floppyspeed (HWND hDlg)
 {
-    char txt[30];
-    char tmp1[MAX_DPATH];
-    char tmp2[MAX_DPATH];
+    TCHAR txt[30];
+    TCHAR tmp1[MAX_DPATH];
+    TCHAR tmp2[MAX_DPATH];
 
-    WIN32GUI_LoadUIString (IDS_FLOPPY_COMPATIBLE, tmp1, sizeof (tmp1));
-    WIN32GUI_LoadUIString (IDS_FLOPPY_TURBO, tmp2, sizeof (tmp2));
+    WIN32GUI_LoadUIString (IDS_FLOPPY_COMPATIBLE, tmp1, sizeof (tmp1) / sizeof (TCHAR));
+    WIN32GUI_LoadUIString (IDS_FLOPPY_TURBO, tmp2, sizeof (tmp2) / sizeof (TCHAR));
     if (workprefs.floppy_speed)
-       sprintf (txt, "%d%%%s", workprefs.floppy_speed, workprefs.floppy_speed == 100 ? tmp1 : "");
+       _stprintf (txt, L"%d%%%s", workprefs.floppy_speed, workprefs.floppy_speed == 100 ? tmp1 : L"");
     else
-       strcpy (txt, tmp2);
+       _tcscpy (txt, tmp2);
     SetDlgItemText (hDlg, IDC_FLOPPYSPDTEXT, txt);
 }
 
@@ -8206,13 +8162,13 @@ static void floppytooltip (HWND hDlg, int num, uae_u32 crc32)
 {
     TOOLINFO ti;
     int id;
-    char tmp[100];
+    TCHAR tmp[100];
 
     if (currentpage == QUICKSTART_ID)
        id = floppybuttonsq[num][0];
     else
        id = floppybuttons[num][0];
-    ti.cbSize = sizeof(TOOLINFO);
+    ti.cbSize = sizeof (TOOLINFO);
     ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
     ti.hwnd = hDlg;
     ti.hinst = hInst;
@@ -8220,7 +8176,7 @@ static void floppytooltip (HWND hDlg, int num, uae_u32 crc32)
     SendMessage (ToolTipHWND, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
     if (crc32 == 0)
        return;
-    sprintf (tmp, "CRC=%08X", crc32);
+    _stprintf (tmp, L"CRC=%08X", crc32);
     ti.lpszText = tmp;
     SendMessage (ToolTipHWND, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
 }
@@ -8228,7 +8184,7 @@ static void floppytooltip (HWND hDlg, int num, uae_u32 crc32)
 static void addfloppyhistory_2 (HWND hDlg, UAEREG *fkey, int n, int f_text)
 {
     int i, j;
-    char *s;
+    TCHAR *s;
     int nn = workprefs.dfxtype[n] + 1;
 
     if (f_text < 0)
@@ -8237,14 +8193,14 @@ static void addfloppyhistory_2 (HWND hDlg, UAEREG *fkey, int n, int f_text)
     SendDlgItemMessage (hDlg, f_text, WM_SETTEXT, 0, (LPARAM)workprefs.df[n]);
     i = 0;
     while (s = DISK_history_get (i)) {
-       char tmpname[MAX_DPATH], tmppath[MAX_DPATH], *p, *p2;
-       if (strlen(s) == 0)
+       TCHAR tmpname[MAX_DPATH], tmppath[MAX_DPATH], *p, *p2;
+       if (_tcslen (s) == 0)
            break;
        i++;
-       strcpy (tmppath, s);
-       p = tmppath + strlen (tmppath) - 1;
+       _tcscpy (tmppath, s);
+       p = tmppath + _tcslen (tmppath) - 1;
        for (j = 0; uae_archive_extensions[j]; j++) {
-           p2 = strstr (tmppath, uae_archive_extensions[j]);
+           p2 = _tcsstr (tmppath, uae_archive_extensions[j]);
            if (p2) {
                p = p2;
                break;
@@ -8255,16 +8211,16 @@ static void addfloppyhistory_2 (HWND hDlg, UAEREG *fkey, int n, int f_text)
                break;
            p--;
        }
-       strcpy (tmpname, p + 1);
+       _tcscpy (tmpname, p + 1);
        *++p = 0;
        if (tmppath[0]) {
-           strcat (tmpname, " { ");
-           strcat (tmpname, tmppath);
-           strcat (tmpname, " }");
+           _tcscat (tmpname, L" { ");
+           _tcscat (tmpname, tmppath);
+           _tcscat (tmpname, L" }");
        }
        if (f_text >= 0)
            SendDlgItemMessage (hDlg, f_text, CB_ADDSTRING, 0, (LPARAM)tmpname);
-       if (!strcmp (workprefs.df[n], s)) {
+       if (!_tcscmp (workprefs.df[n], s)) {
            if (f_text >= 0)
                SendDlgItemMessage (hDlg, f_text, CB_SETCURSEL, i - 1, 0);
        }
@@ -8379,15 +8335,15 @@ static void getfloppytypeq (HWND hDlg, int n)
            quickstart_floppy = 2;
        else
            quickstart_floppy = 1;
-       regsetint (NULL, "QuickStartFloppies", quickstart_floppy);
+       regsetint (NULL, L"QuickStartFloppies", quickstart_floppy);
     }
 }
 
-static int getfloppybox (HWND hDlg, int f_text, char *out, int maxlen)
+static int getfloppybox (HWND hDlg, int f_text, TCHAR *out, int maxlen)
 {
     LRESULT val;
-    char *p1, *p2, *p;
-    char *tmp;
+    TCHAR *p1, *p2, *p;
+    TCHAR *tmp;
     int i;
 
     out[0] = 0;
@@ -8397,20 +8353,20 @@ static int getfloppybox (HWND hDlg, int f_text, char *out, int maxlen)
     else
        SendDlgItemMessage (hDlg, f_text, WM_GETTEXT, (WPARAM)maxlen, (LPARAM)out);
 
-    tmp = xmalloc (maxlen + 1);
-    strcpy (tmp, out);
-    p1 = strstr(tmp, " { ");
-    p2 = strstr(tmp, " }");
+    tmp = xmalloc ((maxlen + 1) * sizeof (TCHAR));
+    _tcscpy (tmp, out);
+    p1 = _tcsstr(tmp, L" { ");
+    p2 = _tcsstr(tmp, L" }");
     if (p1 && p2 && p2 > p1) {
        *p1 = 0;
-       memset (out, 0, maxlen);
-       memcpy (out, p1 + 3, p2 - p1 - 3);
-       strcat (out, tmp);
+       memset (out, 0, maxlen * sizeof (TCHAR));
+       memcpy (out, p1 + 3, (p2 - p1 - 3) * sizeof (TCHAR));
+       _tcscat (out, tmp);
     }
     xfree (tmp);
     i = 0;
     while ((p = DISK_history_get (i))) {
-       if (!strcmp (p, out)) {
+       if (!_tcscmp (p, out)) {
            DISK_history_add (out, -1);
            break;
        }
@@ -8422,11 +8378,11 @@ static int getfloppybox (HWND hDlg, int f_text, char *out, int maxlen)
 static void getfloppyname (HWND hDlg, int n)
 {
     int f_text = currentpage == QUICKSTART_ID ? floppybuttonsq[n][0] : floppybuttons[n][0];
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
-    if (getfloppybox (hDlg, f_text, tmp, sizeof (tmp))) {
+    if (getfloppybox (hDlg, f_text, tmp, sizeof (tmp) / sizeof (TCHAR))) {
        disk_insert (n, tmp);
-       strcpy (workprefs.df[n], tmp);
+       _tcscpy (workprefs.df[n], tmp);
     }
 }
 
@@ -8447,7 +8403,7 @@ static void floppysetwriteprotect (HWND hDlg, int n, int protect)
 
 static void deletesaveimage (HWND hDlg, int num)
 {
-    char *p = DISK_get_saveimagepath (workprefs.df[num]);
+    TCHAR *p = DISK_get_saveimagepath (workprefs.df[num]);
     if (zfile_exists (p)) {
        DeleteFile (p);
        DISK_reinsert (num);
@@ -8455,7 +8411,7 @@ static void deletesaveimage (HWND hDlg, int num)
     }
 }
 
-static void diskselect (HWND hDlg, WPARAM wParam, struct uae_prefs *p, int drv, char *defaultpath)
+static void diskselect (HWND hDlg, WPARAM wParam, struct uae_prefs *p, int drv, TCHAR *defaultpath)
 {
     MultiDiskSelection (hDlg, wParam, 0, &workprefs, defaultpath);
     disk_insert (0, p->df[0]);
@@ -8488,11 +8444,11 @@ static int diskselectmenu (HWND hDlg, WPARAM wParam)
        break;
     }
     if (num >= 0) {
-       char *s = favoritepopup (hDlg);
+       TCHAR *s = favoritepopup (hDlg);
        if (s) {
            int num = id == IDC_DF0QQ ? 0 : 1;
-           char tmp[MAX_DPATH];
-           strcpy (tmp, s);
+           TCHAR tmp[MAX_DPATH];
+           _tcscpy (tmp, s);
            xfree (s);
            diskselect (hDlg, id, &workprefs, num, tmp);
        }
@@ -8505,20 +8461,20 @@ static INT_PTR CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
 {
     static int recursive = 0;
     int i;
-    static char diskname[40] = { "empty" };
+    static TCHAR diskname[40] = { L"empty" };
 
     switch (msg)
     {
        case WM_INITDIALOG:
        {
-           char ft35dd[20], ft35hd[20], ft525sd[20], ftdis[20], ft35ddescom[20];
+           TCHAR ft35dd[20], ft35hd[20], ft525sd[20], ftdis[20], ft35ddescom[20];
            int df0texts[] = { IDC_DF0TEXT, IDC_DF1TEXT, IDC_DF2TEXT, IDC_DF3TEXT, -1 };
 
-           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE35DD, ft35dd, sizeof ft35dd);
-           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE35HD, ft35hd, sizeof ft35hd);
-           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE525SD, ft525sd, sizeof ft525sd);
-           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE35DDESCOM, ft35ddescom, sizeof ft35ddescom);
-           WIN32GUI_LoadUIString (IDS_FLOPPYTYPEDISABLED, ftdis, sizeof ftdis);
+           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE35DD, ft35dd, sizeof ft35dd / sizeof (TCHAR));
+           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE35HD, ft35hd, sizeof ft35hd / sizeof (TCHAR));
+           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE525SD, ft525sd, sizeof ft525sd / sizeof (TCHAR));
+           WIN32GUI_LoadUIString (IDS_FLOPPYTYPE35DDESCOM, ft35ddescom, sizeof ft35ddescom / sizeof (TCHAR));
+           WIN32GUI_LoadUIString (IDS_FLOPPYTYPEDISABLED, ftdis, sizeof ftdis / sizeof (TCHAR));
            pages[FLOPPY_ID] = hDlg;
            if (workprefs.floppy_speed > 0 && workprefs.floppy_speed < 10)
                workprefs.floppy_speed = 100;
@@ -8650,25 +8606,25 @@ static INT_PTR CALLBACK FloppyDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARA
                break;
            case IDC_EJECT0:
            case IDC_EJECT0Q:
-               SetDlgItemText (hDlg, IDC_DF0TEXT, "");
-               SetDlgItemText (hDlg, IDC_DF0TEXTQ, "");
+               SetDlgItemText (hDlg, IDC_DF0TEXT, L"");
+               SetDlgItemText (hDlg, IDC_DF0TEXTQ, L"");
                workprefs.df[0][0] = 0;
                addfloppytype (hDlg, 0);
                break;
            case IDC_EJECT1:
            case IDC_EJECT1Q:
-               SetDlgItemText (hDlg, IDC_DF1TEXT, "");
-               SetDlgItemText (hDlg, IDC_DF1TEXTQ, "");
+               SetDlgItemText (hDlg, IDC_DF1TEXT, L"");
+               SetDlgItemText (hDlg, IDC_DF1TEXTQ, L"");
                workprefs.df[1][0] = 0;
                addfloppytype (hDlg, 1);
                break;
            case IDC_EJECT2:
-               SetDlgItemText (hDlg, IDC_DF2TEXT, "");
+               SetDlgItemText (hDlg, IDC_DF2TEXT, L"");
                workprefs.df[2][0] = 0;
                addfloppytype (hDlg, 2);
                break;
            case IDC_EJECT3:
-               SetDlgItemText (hDlg, IDC_DF3TEXT, "");
+               SetDlgItemText (hDlg, IDC_DF3TEXT, L"");
                workprefs.df[3][0] = 0;
                addfloppytype (hDlg, 3);
                break;
@@ -8728,19 +8684,19 @@ static void swapperhili (HWND hDlg, int entry)
     SetDlgItemText (hDlg, IDC_DISKTEXT,  workprefs.dfxlist[entry]);
 }
 
-static void addswapperfile (HWND hDlg, int entry, char *newpath)
+static void addswapperfile (HWND hDlg, int entry, TCHAR *newpath)
 {
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
     int lastentry = entry;
 
     path[0] = 0;
     if (newpath)
-       strcpy (path, newpath);
+       _tcscpy (path, newpath);
     if (MultiDiskSelection (hDlg, -1, 0, &changed_prefs, path)) {
-       char dpath[MAX_DPATH];
+       TCHAR dpath[MAX_DPATH];
        loopmulti (path, NULL);
        while (loopmulti (path, dpath) && entry < MAX_SPARE_DRIVES) {
-           strcpy (workprefs.dfxlist[entry], dpath);
+           _tcscpy (workprefs.dfxlist[entry], dpath);
            lastentry = entry;
            entry++;
        }
@@ -8753,7 +8709,7 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
 {
     static int recursive = 0;
     static int entry;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
 
     switch (msg)
     {
@@ -8775,10 +8731,10 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
            entry = item;
            for (i = 0; (item2 = draggeditems[i]) >= 0 && item2 < MAX_SPARE_DRIVES; i++, item++) {
                if (item != item2) {
-                   char tmp[1000];
-                   strcpy (tmp, workprefs.dfxlist[item]);
-                   strcpy (workprefs.dfxlist[item], workprefs.dfxlist[item2]);
-                   strcpy (workprefs.dfxlist[item2], tmp);
+                   TCHAR tmp[1000];
+                   _tcscpy (tmp, workprefs.dfxlist[item]);
+                   _tcscpy (workprefs.dfxlist[item], workprefs.dfxlist[item2]);
+                   _tcscpy (workprefs.dfxlist[item2], tmp);
                }
            }
            InitializeListView(hDlg);
@@ -8794,7 +8750,7 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
     break;
     case WM_CONTEXTMENU:
        if (GetDlgCtrlID ((HWND)wParam) == IDC_DISKLISTINSERT && entry >= 0) {
-           char *s = favoritepopup (hDlg);
+           TCHAR *s = favoritepopup (hDlg);
            if (s) {
                addswapperfile (hDlg, entry, s);
                xfree (s);
@@ -8855,10 +8811,10 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
                int i;
                if (workprefs.dfxtype[drv] >= 0 && entry >= 0) {
                    for (i = 0; i < 4; i++) {
-                       if (!strcmp (workprefs.df[i], workprefs.dfxlist[entry]))
+                       if (!_tcscmp (workprefs.df[i], workprefs.dfxlist[entry]))
                            workprefs.df[i][0] = 0;
                    }
-                   strcpy (workprefs.df[drv], workprefs.dfxlist[entry]);
+                   _tcscpy (workprefs.df[drv], workprefs.dfxlist[entry]);
                    disk_insert (drv, workprefs.df[drv]);
                    InitializeListView (hDlg);
                    swapperhili (hDlg, entry);
@@ -8884,8 +8840,8 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
 
            case IDC_DISKLISTINSERT:
                if (entry >= 0) {
-                   if (getfloppybox (hDlg, IDC_DISKTEXT, tmp, sizeof (tmp))) {
-                       strcpy (workprefs.dfxlist[entry], tmp);
+                   if (getfloppybox (hDlg, IDC_DISKTEXT, tmp, sizeof (tmp) / sizeof (TCHAR))) {
+                       _tcscpy (workprefs.dfxlist[entry], tmp);
                        addfloppyhistory (hDlg);
                        InitializeListView (hDlg);
                        swapperhili (hDlg, entry);
@@ -8904,9 +8860,9 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
                break;
            case IDC_UP:
                if (entry > 0) {
-                   strcpy (tmp, workprefs.dfxlist[entry - 1]);
-                   strcpy (workprefs.dfxlist[entry - 1], workprefs.dfxlist[entry]);
-                   strcpy (workprefs.dfxlist[entry], tmp);
+                   _tcscpy (tmp, workprefs.dfxlist[entry - 1]);
+                   _tcscpy (workprefs.dfxlist[entry - 1], workprefs.dfxlist[entry]);
+                   _tcscpy (workprefs.dfxlist[entry], tmp);
                    InitializeListView (hDlg);
                    entry--;
                    swapperhili (hDlg, entry);
@@ -8914,9 +8870,9 @@ static INT_PTR CALLBACK SwapperDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
                break;
            case IDC_DOWN:
                if (entry >= 0 && entry < MAX_SPARE_DRIVES - 1) {
-                   strcpy (tmp, workprefs.dfxlist[entry + 1]);
-                   strcpy (workprefs.dfxlist[entry + 1], workprefs.dfxlist[entry]);
-                   strcpy (workprefs.dfxlist[entry], tmp);
+                   _tcscpy (tmp, workprefs.dfxlist[entry + 1]);
+                   _tcscpy (workprefs.dfxlist[entry + 1], workprefs.dfxlist[entry]);
+                   _tcscpy (workprefs.dfxlist[entry], tmp);
                    InitializeListView (hDlg);
                    entry++;
                    swapperhili (hDlg, entry);
@@ -9036,7 +8992,7 @@ static void enable_for_portsdlg (HWND hDlg)
 static void updatejoyport (HWND hDlg)
 {
     int i, j;
-    char tmp[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH];
 
     SetDlgItemInt (hDlg, IDC_INPUTSPEEDM, workprefs.input_mouse_speed, FALSE);
     CheckDlgButton (hDlg, IDC_PORT_MOUSETRICK, workprefs.input_magic_mouse);
@@ -9053,19 +9009,19 @@ static void updatejoyport (HWND hDlg)
        int idx = i == 0 ? joy0previous : joy1previous;
        int id = i == 0 ? IDC_PORT0_JOYS : IDC_PORT1_JOYS;
        int v = workprefs.jports[i].id;
-       char *p1, *p2;
+       TCHAR *p1, *p2;
 
        SendDlgItemMessage (hDlg, id, CB_RESETCONTENT, 0, 0L);
-       SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)"");
-       WIN32GUI_LoadUIString (IDS_NONE, tmp, sizeof (tmp) - 3);
-       sprintf (tmp2, "<%s>", tmp);
+       SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)L"");
+       WIN32GUI_LoadUIString (IDS_NONE, tmp, sizeof (tmp) / sizeof (TCHAR) - 3);
+       _stprintf (tmp2, L"<%s>", tmp);
        SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)tmp2);
-       WIN32GUI_LoadUIString (IDS_KEYJOY, tmp, sizeof (tmp));
-       strcat (tmp, "\n");
+       WIN32GUI_LoadUIString (IDS_KEYJOY, tmp, sizeof (tmp) / sizeof (TCHAR));
+       _tcscat (tmp, L"\n");
        p1 = tmp;
        for (;;) {
-           p2 = strchr (p1, '\n');
-           if (p2 && strlen (p2) > 0) {
+           p2 = _tcschr (p1, '\n');
+           if (p2 && _tcslen (p2) > 0) {
                *p2++ = 0;
                SendDlgItemMessage (hDlg, id, CB_ADDSTRING, 0, (LPARAM)p1);
                total++;
@@ -9173,25 +9129,25 @@ static void values_from_gameportsdlg (HWND hDlg, int d)
 static void values_from_portsdlg (HWND hDlg)
 {
     int v;
-    char tmp[256];
+    TCHAR tmp[256];
     BOOL success;
     LRESULT item;
 
     item = SendDlgItemMessage (hDlg, IDC_PRINTERLIST, CB_GETCURSEL, 0, 0L);
     if(item != CB_ERR) {
        int got = 0;
-       strcpy (tmp, workprefs.prtname);
+       _tcscpy (tmp, workprefs.prtname);
        if (item > 0) {
            item--;
            if (item < dwEnumeratedPrinters) {
-               strcpy (workprefs.prtname, pInfo[item].pName);
+               _tcscpy (workprefs.prtname, pInfo[item].pName);
                got = 1;
            } else {
                int i;
                item -= dwEnumeratedPrinters;
                for (i = 0; i < 4; i++) {
                    if ((paraport_mask & (1 << i)) && item == 0) {
-                       sprintf (workprefs.prtname, "LPT%d", i + 1);
+                       _stprintf (workprefs.prtname, L"LPT%d", i + 1);
                        got = 1;
                        break;
                    }
@@ -9202,7 +9158,7 @@ static void values_from_portsdlg (HWND hDlg)
        if (!got)
            workprefs.prtname[0] = 0;
 #ifdef PARALLEL_PORT
-       if (strcmp (workprefs.prtname, tmp))
+       if (_tcscmp (workprefs.prtname, tmp))
            closeprinter ();
 #endif
     }
@@ -9220,7 +9176,7 @@ static void values_from_portsdlg (HWND hDlg)
     item = SendDlgItemMessage (hDlg, IDC_SERIAL, CB_GETCURSEL, 0, 0L);
     if (item != CB_ERR && item > 0) {
        workprefs.use_serial = 1;
-       strcpy (workprefs.sername, comports[item - 1].dev);
+       _tcscpy (workprefs.sername, comports[item - 1].dev);
     } else {
        workprefs.use_serial = 0;
        workprefs.sername[0] = 0;
@@ -9239,7 +9195,7 @@ static void values_from_portsdlg (HWND hDlg)
     if (IsDlgButtonChecked (hDlg, IDC_UAESERIAL))
        workprefs.uaeserial = 1;
 
-    GetDlgItemText (hDlg, IDC_PS_PARAMS, workprefs.ghostscript_parameters, sizeof workprefs.ghostscript_parameters);
+    GetDlgItemText (hDlg, IDC_PS_PARAMS, workprefs.ghostscript_parameters, sizeof workprefs.ghostscript_parameters / sizeof (TCHAR));
     v  = GetDlgItemInt (hDlg, IDC_PRINTERAUTOFLUSH, &success, FALSE);
     if (success)
        workprefs.parallel_autoflush_time = v;
@@ -9252,11 +9208,11 @@ static void values_to_portsdlg (HWND hDlg)
 
     if(workprefs.prtname[0]) {
        int i, got = 1;
-       char tmp[10];
+       TCHAR tmp[10];
        result = SendDlgItemMessage (hDlg, IDC_PRINTERLIST, CB_FINDSTRINGEXACT, -1, (LPARAM)workprefs.prtname);
        for (i = 0; i < 4; i++) {
-           sprintf (tmp, "LPT%d", i + 1);
-           if (!strcmp (tmp, workprefs.prtname)) {
+           _stprintf (tmp, L"LPT%d", i + 1);
+           if (!_tcscmp (tmp, workprefs.prtname)) {
                got = 0;
                if (paraport_mask & (1 << i))
                    got = 1;
@@ -9265,7 +9221,7 @@ static void values_to_portsdlg (HWND hDlg)
        }
        if(result < 0 || got == 0) {
            // Warn the user that their printer-port selection is not valid on this machine
-           char szMessage[MAX_DPATH];
+           TCHAR szMessage[MAX_DPATH];
            WIN32GUI_LoadUIString (IDS_INVALIDPRTPORT, szMessage, MAX_DPATH);
            pre_gui_message (szMessage);
            // Disable the invalid parallel-port selection
@@ -9298,14 +9254,14 @@ static void values_to_portsdlg (HWND hDlg)
        int i;
        LRESULT result = -1;
        for (i = 0; i < MAX_SERIAL_PORTS && comports[i].name; i++) {
-           if (!strcmp (comports[i].dev, workprefs.sername)) {
+           if (!_tcscmp (comports[i].dev, workprefs.sername)) {
                result = SendDlgItemMessage (hDlg, IDC_SERIAL, CB_SETCURSEL, i + 1, 0L);
                break;
            }
        }
        if(result < 0 && workprefs.sername[0]) {
            // Warn the user that their COM-port selection is not valid on this machine
-           char szMessage[MAX_DPATH];
+           TCHAR szMessage[MAX_DPATH];
            WIN32GUI_LoadUIString (IDS_INVALIDCOMPORT, szMessage, MAX_DPATH);
            pre_gui_message (szMessage);
            // Select "none" as the COM-port
@@ -9372,8 +9328,8 @@ static void init_portsdlg (HWND hDlg)
        int i = 1;
        while (mask) {
            if (mask & 1) {
-               char tmp[30];
-               sprintf (tmp, "LPT%d", i);
+               TCHAR tmp[30];
+               _stprintf (tmp, L"LPT%d", i);
                SendDlgItemMessage (hDlg, IDC_PRINTERLIST, CB_ADDSTRING, 0, (LPARAM)tmp);
            }
            i++;
@@ -9386,12 +9342,12 @@ static void init_portsdlg (HWND hDlg)
     if ((numdevs = midiOutGetNumDevs ()) == 0) {
        ew (hDlg, IDC_MIDIOUTLIST, FALSE);
     } else {
-       char szMidiOut[MAX_DPATH];
+       TCHAR szMidiOut[MAX_DPATH];
        WIN32GUI_LoadUIString (IDS_DEFAULTMIDIOUT, szMidiOut, MAX_DPATH);
        SendDlgItemMessage (hDlg, IDC_MIDIOUTLIST, CB_ADDSTRING, 0, (LPARAM)szMidiOut);
 
        for(port = 0; port < numdevs; port++) {
-           if (midiOutGetDevCaps (port, &midiOutCaps, sizeof(midiOutCaps)) == MMSYSERR_NOERROR)
+           if (midiOutGetDevCaps (port, &midiOutCaps, sizeof (midiOutCaps)) == MMSYSERR_NOERROR)
                SendDlgItemMessage (hDlg, IDC_MIDIOUTLIST, CB_ADDSTRING, 0, (LPARAM)midiOutCaps.szPname);
        }
        ew (hDlg, IDC_MIDIOUTLIST, TRUE);
@@ -9403,7 +9359,7 @@ static void init_portsdlg (HWND hDlg)
        bNoMidiIn = TRUE;
     } else {
        for(port = 0; port < numdevs; port++) {
-           if (midiInGetDevCaps (port, &midiInCaps, sizeof(midiInCaps)) == MMSYSERR_NOERROR)
+           if (midiInGetDevCaps (port, &midiInCaps, sizeof (midiInCaps)) == MMSYSERR_NOERROR)
                SendDlgItemMessage (hDlg, IDC_MIDIINLIST, CB_ADDSTRING, 0, (LPARAM)midiInCaps.szPname);
        }
     }
@@ -9422,9 +9378,9 @@ static INT_PTR CALLBACK GamePortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
        pages[GAMEPORTS_ID] = hDlg;
        currentpage = GAMEPORTS_ID;
        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_RESETCONTENT, 0, 0L);
-        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)"Show both cursors");
-        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)"Show native cursor only");
-        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)"Show host cursor only");
+        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)L"Show both cursors");
+        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)L"Show native cursor only");
+        SendDlgItemMessage (hDlg, IDC_PORT_TABLET_CURSOR, CB_ADDSTRING, 0, (LPARAM)L"Show host cursor only");
        inputdevice_updateconfig (&workprefs);
        enable_for_gameportsdlg (hDlg);
        updatejoyport (hDlg);
@@ -9535,7 +9491,7 @@ static INT_PTR CALLBACK IOPortsDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPAR
     return FALSE;
 }
 
-static char *eventnames[INPUTEVENT_END];
+static TCHAR *eventnames[INPUTEVENT_END];
 
 static void values_to_inputdlg (HWND hDlg)
 {
@@ -9579,10 +9535,10 @@ static INT_PTR CALLBACK StringBoxDialogProc (HWND hDlg, UINT msg, WPARAM wParam,
     return FALSE;
 }
 
-static int askinputcustom (HWND hDlg, char *custom, int maxlen, DWORD titleid)
+static int askinputcustom (HWND hDlg, TCHAR *custom, int maxlen, DWORD titleid)
 {
     HWND hwnd;
-    char txt[MAX_DPATH];
+    TCHAR txt[MAX_DPATH];
 
     stringboxdialogactive = 1;
     hwnd = CustomCreateDialog (IDD_STRINGBOX, hDlg, StringBoxDialogProc);
@@ -9606,10 +9562,10 @@ static int askinputcustom (HWND hDlg, char *custom, int maxlen, DWORD titleid)
                TranslateMessage (&msg);
                DispatchMessage (&msg);
            }
-           SendMessage (GetDlgItem (hwnd, IDC_STRINGBOXEDIT), WM_GETTEXT, sizeof txt, (LPARAM)txt);
+           SendMessage (GetDlgItem (hwnd, IDC_STRINGBOXEDIT), WM_GETTEXT, sizeof txt / sizeof (TCHAR), (LPARAM)txt);
        }
        if (stringboxdialogactive == -1) {
-           strcpy (custom, txt);
+           _tcscpy (custom, txt);
            return 1;
        }
     }
@@ -9618,8 +9574,8 @@ static int askinputcustom (HWND hDlg, char *custom, int maxlen, DWORD titleid)
 
 static void init_inputdlg_2(HWND hDlg)
 {
-    char name1[256], name2[256];
-    char custom1[MAX_DPATH], tmp1[MAX_DPATH];
+    TCHAR name1[256], name2[256];
+    TCHAR custom1[MAX_DPATH], tmp1[MAX_DPATH];
     int cnt, index, af, aftmp;
 
     if (input_selected_widget < 0 || workprefs.input_selected_setting == 0) {
@@ -9637,15 +9593,15 @@ static void init_inputdlg_2(HWND hDlg)
        cnt = 2;
        while(inputdevice_iterate (input_selected_device, input_selected_widget, name2, &aftmp)) {
            free (eventnames[cnt]);
-           eventnames[cnt] = strdup (name2);
-           if (name1 && !strcmp (name1, name2)) {
+           eventnames[cnt] = my_strdup (name2);
+           if (name1 && !_tcscmp (name1, name2)) {
                index = cnt;
                af = aftmp;
            }
            cnt++;
            SendDlgItemMessage (hDlg, IDC_INPUTAMIGA, CB_ADDSTRING, 0, (LPARAM)name2);
        }
-       if (strlen(custom1) > 0)
+       if (_tcslen (custom1) > 0)
            index = 1;
        if (index >= 0) {
            SendDlgItemMessage (hDlg, IDC_INPUTAMIGA, CB_SETCURSEL, index, 0);
@@ -9657,42 +9613,42 @@ static void init_inputdlg_2(HWND hDlg)
 static void init_inputdlg (HWND hDlg)
 {
     int i;
-    char buf[100], txt[100];
+    TCHAR buf[100], txt[100];
 
     SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_RESETCONTENT, 0, 0L);
-    WIN32GUI_LoadUIString (IDS_INPUT_COMPATIBILITY, buf, sizeof (buf));
+    WIN32GUI_LoadUIString (IDS_INPUT_COMPATIBILITY, buf, sizeof (buf) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_ADDSTRING, 0, (LPARAM)buf);
-    WIN32GUI_LoadUIString (IDS_INPUT_CUSTOM, buf, sizeof (buf));
+    WIN32GUI_LoadUIString (IDS_INPUT_CUSTOM, buf, sizeof (buf) / sizeof (TCHAR));
     for (i = 0; i < 4; i++) {
-       sprintf (txt, buf, i + 1);
+       _stprintf (txt, buf, i + 1);
        SendDlgItemMessage (hDlg, IDC_INPUTTYPE, CB_ADDSTRING, 0, (LPARAM)txt);
     }
 
     SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_RESETCONTENT, 0, 0L);
-    WIN32GUI_LoadUIString (IDS_INPUT_COPY_DEFAULT, buf, sizeof (buf));
+    WIN32GUI_LoadUIString (IDS_INPUT_COPY_DEFAULT, buf, sizeof (buf) / sizeof (TCHAR));
     SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_ADDSTRING, 0, (LPARAM)buf);
-    WIN32GUI_LoadUIString (IDS_INPUT_COPY_CUSTOM, buf, sizeof (buf));
+    WIN32GUI_LoadUIString (IDS_INPUT_COPY_CUSTOM, buf, sizeof (buf) / sizeof (TCHAR));
     for (i = 0; i < 4; i++) {
-       sprintf (txt, buf, i + 1);
+       _stprintf (txt, buf, i + 1);
        SendDlgItemMessage (hDlg, IDC_INPUTCOPYFROM, CB_ADDSTRING, 0, (LPARAM)txt);
     }
 
     SendDlgItemMessage (hDlg, IDC_INPUTAMIGACNT, CB_RESETCONTENT, 0, 0L);
     for (i = 0; i < MAX_INPUT_SUB_EVENT; i++) {
-       sprintf (buf, "%d", i + 1);
+       _stprintf (buf, L"%d", i + 1);
        SendDlgItemMessage (hDlg, IDC_INPUTAMIGACNT, CB_ADDSTRING, 0, (LPARAM)buf);
     }
     SendDlgItemMessage (hDlg, IDC_INPUTAMIGACNT, CB_SETCURSEL, input_selected_sub_num, 0);
 
     SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_RESETCONTENT, 0, 0L);
     for (i = 0; i < inputdevice_get_device_total (IDTYPE_JOYSTICK); i++) {
-       SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_JOYSTICK, i));
+       SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name (IDTYPE_JOYSTICK, i));
     }
     for (i = 0; i < inputdevice_get_device_total (IDTYPE_MOUSE); i++) {
-       SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_MOUSE, i));
+       SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name (IDTYPE_MOUSE, i));
     }
     for (i = 0; i < inputdevice_get_device_total (IDTYPE_KEYBOARD); i++) {
-       SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name(IDTYPE_KEYBOARD, i));
+       SendDlgItemMessage (hDlg, IDC_INPUTDEVICE, CB_ADDSTRING, 0, (LPARAM)inputdevice_get_device_name (IDTYPE_KEYBOARD, i));
     }
     input_total_devices = inputdevice_get_device_total (IDTYPE_JOYSTICK) +
        inputdevice_get_device_total (IDTYPE_MOUSE) +
@@ -9727,13 +9683,13 @@ static void clearinputlistview (HWND hDlg)
 
 static void doinputcustom (HWND hDlg, int newcustom)
 {
-    char custom1[MAX_DPATH];
+    TCHAR custom1[MAX_DPATH];
     int flags;
     custom1[0] = 0;
     inputdevice_get_mapped_name (input_selected_device, input_selected_widget,
        &flags, 0, custom1, input_selected_sub_num);
-    if (strlen(custom1) > 0 || newcustom) {
-       if (askinputcustom (hDlg, custom1, sizeof custom1, IDS_SB_CUSTOMEVENT)) {
+    if (_tcslen (custom1) > 0 || newcustom) {
+       if (askinputcustom (hDlg, custom1, sizeof custom1 / sizeof (TCHAR), IDS_SB_CUSTOMEVENT)) {
            inputdevice_set_mapping (input_selected_device, input_selected_widget,
                0, custom1, (flags & IDEV_MAPPED_AUTOFIRE_SET) ? 1 : 0, input_selected_sub_num);
        }
@@ -9810,14 +9766,14 @@ static void values_from_inputdlg (HWND hDlg, int inputchange)
 
     if (inputchange && doselect && input_selected_device >= 0 && input_selected_event >= 0) {
        int flags;
-       char custom[MAX_DPATH];
+       TCHAR custom[MAX_DPATH];
        custom[0] = 0;
        inputdevice_get_mapped_name (input_selected_device, input_selected_widget,
            &flags, 0, custom, input_selected_sub_num);
        if (input_selected_event != 1)
            custom[0] = 0;
        inputdevice_set_mapping (input_selected_device, input_selected_widget,
-           eventnames[input_selected_event], strlen(custom) == 0 ? NULL : custom,
+           eventnames[input_selected_event], _tcslen (custom) == 0 ? NULL : custom,
            (flags & IDEV_MAPPED_AUTOFIRE_SET) ? 1 : 0, input_selected_sub_num);
        update_listview_input (hDlg);
        inputdevice_updateconfig (&workprefs);
@@ -9833,7 +9789,7 @@ static void input_swap (HWND hDlg)
 #if 0
 static void input_copy (HWND hDlg)
 {
-    char buf[2000];
+    TCHAR buf[2000];
     inputdevice_acquire (1);
     for (;;) {
        focus = 1;
@@ -9859,8 +9815,8 @@ static void input_copy (HWND hDlg)
 static void input_toggleautofire (void)
 {
     int af, flags, evt;
-    char name[256];
-    char custom[MAX_DPATH];
+    TCHAR name[256];
+    TCHAR custom[MAX_DPATH];
     if (input_selected_device < 0 || input_selected_widget < 0)
        return;
     evt = inputdevice_get_mapped_name (input_selected_device, input_selected_widget,
@@ -9874,8 +9830,8 @@ static void input_toggleautofire (void)
 
 static INT_PTR CALLBACK InputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-    char name_buf[MAX_DPATH] = "", desc_buf[128] = "";
-    char *posn = NULL;
+    TCHAR name_buf[MAX_DPATH] = L"", desc_buf[128] = L"";
+    TCHAR *posn = NULL;
     HWND list;
     int dblclick = 0;
     NM_LISTVIEW *nmlistview;
@@ -10030,23 +9986,23 @@ static void enable_for_hw3ddlg (HWND hDlg)
     ew (hDlg, IDC_FILTERPRESETDELETE, filterpreset_selected > 0 && filterpreset_builtin < 0);
 }
 
-static void makefilter (char *s, int x, int flags)
+static void makefilter (TCHAR *s, int x, int flags)
 {
-    sprintf (s, "%dx", x);
+    _stprintf (s, L"%dx", x);
     if ((flags & (UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32)) == (UAE_FILTER_MODE_16_16 | UAE_FILTER_MODE_32_32)) {
-       strcat (s, " (16bit/32bit)");
+       _tcscat (s, L" (16bit/32bit)");
        return;
     }
     if (flags & UAE_FILTER_MODE_16)
-       strcat (s, " (16bit)");
+       _tcscat (s, L" (16bit)");
     if (flags & UAE_FILTER_MODE_32)
-       strcat (s, " (32bit)");
+       _tcscat (s, L" (32bit)");
 }
 
-static char *filtermultnames[] = { "FS", "1/2x", "1x", "2x", "4x", "6x", "8x", NULL };
+static TCHAR *filtermultnames[] = { L"FS", L"1/2x", L"1x", L"2x", L"4x", L"6x", L"8x", NULL };
 static int filtermults[] = { 0, 2000, 1000, 500, 250, 167, 125 };
 struct filterxtra {
-    char *label;
+    TCHAR *label;
     int *varw, *varc;
     int min, max, step;
 };
@@ -10054,19 +10010,19 @@ static struct filterxtra *filter_extra, *filter_selected;
 
 static struct filterxtra filter_pal_extra[] =
 {
-    "Brightness", &workprefs.gfx_filter_luminance, &currprefs.gfx_filter_luminance, -1000, 1000, 10,
-    "Contrast", &workprefs.gfx_filter_contrast, &currprefs.gfx_filter_contrast, -1000, 1000, 10,
-    "Saturation", &workprefs.gfx_filter_saturation, &currprefs.gfx_filter_saturation, -1000, 1000, 10,
-    "Gamma", &workprefs.gfx_gamma, &currprefs.gfx_gamma, -1000, 1000, 10,
-    "Scanlines", &workprefs.gfx_filter_scanlines, &currprefs.gfx_filter_scanlines, 0, 100, 1,
-    "Blurriness", &workprefs.gfx_filter_blur, &currprefs.gfx_filter_blur,0, 2000, 10,
-    "Noise", &workprefs.gfx_filter_noise, &currprefs.gfx_filter_noise,0, 100, 10,
+    L"Brightness", &workprefs.gfx_filter_luminance, &currprefs.gfx_filter_luminance, -1000, 1000, 10,
+    L"Contrast", &workprefs.gfx_filter_contrast, &currprefs.gfx_filter_contrast, -1000, 1000, 10,
+    L"Saturation", &workprefs.gfx_filter_saturation, &currprefs.gfx_filter_saturation, -1000, 1000, 10,
+    L"Gamma", &workprefs.gfx_gamma, &currprefs.gfx_gamma, -1000, 1000, 10,
+    L"Scanlines", &workprefs.gfx_filter_scanlines, &currprefs.gfx_filter_scanlines, 0, 100, 1,
+    L"Blurriness", &workprefs.gfx_filter_blur, &currprefs.gfx_filter_blur,0, 2000, 10,
+    L"Noise", &workprefs.gfx_filter_noise, &currprefs.gfx_filter_noise,0, 100, 10,
     NULL
 };
 static struct filterxtra filter_3d_extra[] =
 {
-    "Scanline transparency", &workprefs.gfx_filter_scanlines, &currprefs.gfx_filter_scanlines, 0, 100, 10,
-    "Scanline level", &workprefs.gfx_filter_scanlinelevel, &currprefs.gfx_filter_scanlinelevel, 0, 100, 10,
+    L"Scanline transparency", &workprefs.gfx_filter_scanlines, &currprefs.gfx_filter_scanlines, 0, 100, 10,
+    L"Scanline level", &workprefs.gfx_filter_scanlinelevel, &currprefs.gfx_filter_scanlinelevel, 0, 100, 10,
     NULL
 };
 static int dummy_in, dummy_out;
@@ -10100,27 +10056,27 @@ static int *filtervars2[] = {
     };
 
 struct filterpreset {
-    char *name;
+    TCHAR *name;
     int conf[25];
 };
 static struct filterpreset filterpresets[] =
 {
-    { "PAL example", 8, 0, 0, 0, 1000, 1000, 0, 0, 50, 0, 0, 1, 1, 0, 0, 0, 10, 0, 0, 0, 300, 30, 0, 0, 0 },
+    { L"PAL example", 8, 0, 0, 0, 1000, 1000, 0, 0, 50, 0, 0, 1, 1, 0, 0, 0, 10, 0, 0, 0, 300, 30, 0, 0, 0 },
     { NULL }
 };
 
 static int getfiltermult(HWND hDlg, DWORD dlg)
 {
-    char tmp[100];
+    TCHAR tmp[100];
     LRESULT v = SendDlgItemMessage (hDlg, dlg, CB_GETCURSEL, 0, 0L);
     float f;
 
     if (v != CB_ERR)
        return filtermults[v];
-    SendDlgItemMessage (hDlg, dlg, WM_GETTEXT, (WPARAM)sizeof tmp, (LPARAM)tmp);
-    if (!stricmp (tmp, "FS"))
+    SendDlgItemMessage (hDlg, dlg, WM_GETTEXT, (WPARAM)sizeof tmp / sizeof (TCHAR), (LPARAM)tmp);
+    if (!_tcsicmp (tmp, L"FS"))
        return 0;
-    f = atof (tmp);
+    f = (float)_tstof (tmp);
     if (f < 0)
        f = 0;
     if (f > 9)
@@ -10141,10 +10097,10 @@ static void setfiltermult2 (HWND hDlg, int id, int val)
        }
     }
     if (!got) {
-       char tmp[100];
+       TCHAR tmp[100];
        tmp[0] = 0;
        if (val > 0)
-           sprintf (tmp, "%.2f", 1000.0 / val);
+           _stprintf (tmp, L"%.2f", 1000.0 / val);
        SetDlgItemText (hDlg, id, tmp);
     }
 }
@@ -10165,7 +10121,7 @@ static void setfiltermult (HWND hDlg)
 
 static void values_to_hw3ddlg (HWND hDlg)
 {
-    char txt[100], tmp[100];
+    TCHAR txt[100], tmp[100];
     int i, j, nofilter, fltnum, modenum;
     struct uae_filter *uf;
     UAEREG *fkey;
@@ -10179,9 +10135,9 @@ static void values_to_hw3ddlg (HWND hDlg)
        (workprefs.gfx_filter_aspect == 16 * 256 + 10) ? 4 : 0, 0);
 
     SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_RESETCONTENT, 0, 0L);
-    SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)"Disabled");
-    SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)"Automatic scaling");
-    SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)"Automatic resize");
+    SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)L"Disabled");
+    SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)L"Automatic scaling");
+    SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_ADDSTRING, 0, (LPARAM)L"Automatic resize");
     SendDlgItemMessage (hDlg, IDC_FILTERAUTOSCALE, CB_SETCURSEL, workprefs.gfx_filter_autoscale, 0);
 
     SendDlgItemMessage (hDlg, IDC_FILTERHZ, TBM_SETRANGE, TRUE, MAKELONG (-999, +999));
@@ -10229,15 +10185,15 @@ static void values_to_hw3ddlg (HWND hDlg)
     if (D3D_canshaders ()) {
         HANDLE h;
         WIN32_FIND_DATA wfd;
-        char tmp[MAX_DPATH];
-        sprintf (tmp, "%s%sfiltershaders\\direct3d\\*.fx", start_path_exe, WIN32_PLUGINDIR);
+        TCHAR tmp[MAX_DPATH];
+        _stprintf (tmp, L"%s%sfiltershaders\\direct3d\\*.fx", start_path_exe, WIN32_PLUGINDIR);
         h = FindFirstFile (tmp, &wfd);
         while (h != INVALID_HANDLE_VALUE) {
-           char tmp2[100];
-           sprintf (tmp2, "D3D: %s", wfd.cFileName);
-           tmp2[strlen (tmp2) - 3] = 0;
+           TCHAR tmp2[100];
+           _stprintf (tmp2, L"D3D: %s", wfd.cFileName);
+           tmp2[_tcslen (tmp2) - 3] = 0;
            SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_ADDSTRING, 0, (LPARAM)tmp2);
-           if (uf->type == UAE_FILTER_DIRECT3D && !strcmp (workprefs.gfx_filtershader, wfd.cFileName))
+           if (uf->type == UAE_FILTER_DIRECT3D && !_tcscmp (workprefs.gfx_filtershader, wfd.cFileName))
                fltnum = j;
            j++;
            if (!FindNextFile (h, &wfd)) {
@@ -10251,17 +10207,17 @@ static void values_to_hw3ddlg (HWND hDlg)
     filter_extra = NULL;
     SendDlgItemMessage (hDlg, IDC_FILTERFILTER, CB_RESETCONTENT, 0, 0L);
     if (uf->x[0]) {
-       WIN32GUI_LoadUIString (IDS_3D_NO_FILTER, txt, sizeof (txt));
-       sprintf (tmp, txt, 16);
+       WIN32GUI_LoadUIString (IDS_3D_NO_FILTER, txt, sizeof (txt) / sizeof (TCHAR));
+       _stprintf (tmp, txt, 16);
        SendDlgItemMessage (hDlg, IDC_FILTERFILTER, CB_ADDSTRING, 0, (LPARAM)tmp);
-       WIN32GUI_LoadUIString (IDS_3D_BILINEAR, txt, sizeof (txt));
-       sprintf (tmp, txt, 16);
+       WIN32GUI_LoadUIString (IDS_3D_BILINEAR, txt, sizeof (txt) / sizeof (TCHAR));
+       _stprintf (tmp, txt, 16);
        SendDlgItemMessage (hDlg, IDC_FILTERFILTER, CB_ADDSTRING, 0, (LPARAM)tmp);
-       WIN32GUI_LoadUIString (IDS_3D_NO_FILTER, txt, sizeof (txt));
-       sprintf (tmp, txt, 32);
+       WIN32GUI_LoadUIString (IDS_3D_NO_FILTER, txt, sizeof (txt) / sizeof (TCHAR));
+       _stprintf (tmp, txt, 32);
        SendDlgItemMessage (hDlg, IDC_FILTERFILTER, CB_ADDSTRING, 0, (LPARAM)tmp);
-       WIN32GUI_LoadUIString (IDS_3D_BILINEAR, txt, sizeof (txt));
-       sprintf (tmp, txt, 32);
+       WIN32GUI_LoadUIString (IDS_3D_BILINEAR, txt, sizeof (txt) / sizeof (TCHAR));
+       _stprintf (tmp, txt, 32);
        SendDlgItemMessage (hDlg, IDC_FILTERFILTER, CB_ADDSTRING, 0, (LPARAM)tmp);
        modenum = 4;
        filter_extra = filter_3d_extra;
@@ -10316,7 +10272,7 @@ static void values_to_hw3ddlg (HWND hDlg)
     i = j = 0;
     while (scanlineratios[i * 2]) {
        int sl = scanlineratios[i * 2] * 16 + scanlineratios[i * 2 + 1];
-       sprintf (txt, "%d:%d", scanlineratios[i * 2], scanlineratios[i * 2 + 1]);
+       _stprintf (txt, L"%d:%d", scanlineratios[i * 2], scanlineratios[i * 2 + 1]);
        if (workprefs.gfx_filter_scanlineratio == sl)
            j = i;
        SendDlgItemMessage (hDlg, IDC_FILTERSLR, CB_ADDSTRING, 0, (LPARAM)txt);
@@ -10327,21 +10283,21 @@ static void values_to_hw3ddlg (HWND hDlg)
 
     j = 0;
     SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, CB_RESETCONTENT, 0, 0L);
-    SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, CB_ADDSTRING, 0, (LPARAM)"");
+    SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, CB_ADDSTRING, 0, (LPARAM)L"");
     for (i = 0; filterpresets[i].name; i++) {
-       char tmp[MAX_DPATH];
-       sprintf(tmp, "* %s", filterpresets[i].name);
+       TCHAR tmp[MAX_DPATH];
+       _stprintf (tmp, L"* %s", filterpresets[i].name);
        SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, CB_ADDSTRING, 0, (LPARAM)tmp);
     }
-    fkey = regcreatetree (NULL, "FilterPresets");
+    fkey = regcreatetree (NULL, L"FilterPresets");
     if (fkey) {
         int idx = 0;
-        char tmp[MAX_DPATH], tmp2[MAX_DPATH];
+        TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH];
         DWORD size, size2;
 
         for (;;) {
-           size = sizeof (tmp);
-           size2 = sizeof (tmp2);
+           size = sizeof (tmp) / sizeof (TCHAR);
+           size2 = sizeof (tmp2) / sizeof (TCHAR);
            if (!regenumstr (fkey, idx, tmp, &size, tmp2, &size2))
                break;
            SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, CB_ADDSTRING, 0, (LPARAM)tmp);
@@ -10368,7 +10324,7 @@ static void values_from_hw3ddlg (HWND hDlg)
 static void filter_preset (HWND hDlg, WPARAM wParam)
 {
     int ok, load, i, builtin, userfilter;
-    char tmp1[MAX_DPATH], tmp2[MAX_DPATH];
+    TCHAR tmp1[MAX_DPATH], tmp2[MAX_DPATH];
     DWORD outsize;
     UAEREG *fkey;
     LRESULT item;
@@ -10376,7 +10332,7 @@ static void filter_preset (HWND hDlg, WPARAM wParam)
     load = 0;
     ok = 0;
     for (builtin = 0; filterpresets[builtin].name; builtin++);
-    fkey = regcreatetree (NULL, "FilterPresets");
+    fkey = regcreatetree (NULL, L"FilterPresets");
     item = SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, CB_GETCURSEL, 0, 0);
     tmp1[0] = 0;
     if (item != CB_ERR) {
@@ -10384,7 +10340,7 @@ static void filter_preset (HWND hDlg, WPARAM wParam)
        SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, CB_GETLBTEXT, (WPARAM)item, (LPARAM)tmp1);
     } else {
        filterpreset_selected = -1;
-       SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, WM_GETTEXT, (WPARAM)sizeof tmp1, (LPARAM)tmp1);
+       SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, WM_GETTEXT, (WPARAM)sizeof tmp1 / sizeof (TCHAR), (LPARAM)tmp1);
     }
     userfilter = 0;
     filterpreset_builtin = -1;
@@ -10397,35 +10353,35 @@ static void filter_preset (HWND hDlg, WPARAM wParam)
     }
 
     if (filterpreset_builtin < 0) {
-       outsize = sizeof (tmp2);
+       outsize = sizeof (tmp2) / sizeof (TCHAR);
        if (tmp1[0] && regquerystr (fkey, tmp1, tmp2, &outsize))
            ok = 1;
     } else {
-       char *p = tmp2;
+       TCHAR *p = tmp2;
        for (i = 0; filtervars[i]; i++) {
            if (i > 0) {
-               strcat (p, ",");
+               _tcscat (p, L",");
                p++;
            }
-           sprintf (p, "%d", filterpresets[filterpreset_builtin].conf[i]);
-           p += strlen(p);
+           _stprintf (p, L"%d", filterpresets[filterpreset_builtin].conf[i]);
+           p += _tcslen (p);
        }
        ok = 1;
     }
 
     if (wParam == IDC_FILTERPRESETSAVE && userfilter && fkey) {
-       char *p = tmp2;
+       TCHAR *p = tmp2;
        for (i = 0; filtervars[i]; i++) {
            if (i > 0) {
-               strcat (p, ",");
+               _tcscat (p, L",");
                p++;
            }
-           sprintf (p, "%d", *(filtervars[i]));
-           p += strlen(p);
+           _stprintf (p, L"%d", *(filtervars[i]));
+           p += _tcslen (p);
        }
        if (ok == 0) {
            tmp1[0] = 0;
-           SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, WM_GETTEXT, (WPARAM)sizeof (tmp1), (LPARAM)tmp1);
+           SendDlgItemMessage (hDlg, IDC_FILTERPRESETS, WM_GETTEXT, (WPARAM)sizeof (tmp1) / sizeof (TCHAR), (LPARAM)tmp1);
            if (tmp1[0] == 0)
                goto end;
        }
@@ -10437,19 +10393,19 @@ static void filter_preset (HWND hDlg, WPARAM wParam)
            regdelete (fkey, tmp1);
            values_to_hw3ddlg (hDlg);
        } else if (wParam == IDC_FILTERPRESETLOAD) {
-           char *s = tmp2;
-           char *t;
+           TCHAR *s = tmp2;
+           TCHAR *t;
 
            load = 1;
-           strcat (s, ",");
-           t = strchr (s, ',');
+           _tcscat (s, L",");
+           t = _tcschr (s, ',');
            *t++ = 0;
            for (i = 0; filtervars[i]; i++) {
-               *(filtervars[i]) = atol(s);
+               *(filtervars[i]) = _tstol(s);
                if (filtervars2[i])
                    *(filtervars2[i]) = *(filtervars[i]);
                s = t;
-               t = strchr (s, ',');
+               t = _tcschr (s, ',');
                if (!t)
                    break;
                *t++ = 0;
@@ -10469,7 +10425,7 @@ static void filter_handle (HWND hDlg)
 {
     LRESULT item = SendDlgItemMessage (hDlg, IDC_FILTERMODE, CB_GETCURSEL, 0, 0L);
     if (item != CB_ERR) {
-       char tmp[MAX_DPATH];
+       TCHAR tmp[MAX_DPATH];
        int of = workprefs.gfx_filter;
        int off = workprefs.gfx_filter_filtermode;
        tmp[0] = 0;
@@ -10480,7 +10436,7 @@ static void filter_handle (HWND hDlg)
            item--;
            if (item > UAE_FILTER_PAL) {
                item = UAE_FILTER_DIRECT3D - 1;
-               sprintf (workprefs.gfx_filtershader, "%s.fx", tmp + 5);
+               _stprintf (workprefs.gfx_filtershader, L"%s.fx", tmp + 5);
            }
            workprefs.gfx_filter = uaefilters[item].type;
            item = SendDlgItemMessage (hDlg, IDC_FILTERFILTER, CB_GETCURSEL, 0, 0L);
@@ -10502,7 +10458,7 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 {
     static int recursive;
     LRESULT item;
-    char tmp[100];
+    TCHAR tmp[100];
 
     switch (msg)
     {
@@ -10510,12 +10466,12 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
            pages[HW3D_ID] = hDlg;
            currentpage = HW3D_ID;
            SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_RESETCONTENT, 0, 0);
-           WIN32GUI_LoadUIString (IDS_DISABLED, tmp, sizeof tmp);
+           WIN32GUI_LoadUIString (IDS_DISABLED, tmp, sizeof tmp / sizeof (TCHAR));
            SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)tmp);
-           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)"4:3");
-           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)"15:9");
-           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)"16:9");
-           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)"16:10");
+           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)L"4:3");
+           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)L"15:9");
+           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)L"16:9");
+           SendDlgItemMessage (hDlg, IDC_FILTERASPECT, CB_ADDSTRING, 0, (LPARAM)L"16:10");
            enable_for_hw3ddlg (hDlg);
 
        case WM_USER:
@@ -10679,15 +10635,15 @@ static INT_PTR CALLBACK hw3dDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 #ifdef AVIOUTPUT
 static void values_to_avioutputdlg (HWND hDlg)
 {
-    char tmpstr[256];
+    TCHAR tmpstr[256];
 
     updatewinfsmode (&workprefs);
     SetDlgItemText (hDlg, IDC_AVIOUTPUT_FILETEXT, avioutput_filename);
 
-    sprintf (tmpstr, "%d fps", avioutput_fps);
+    _stprintf (tmpstr, L"%d fps", avioutput_fps);
     SendMessage (GetDlgItem(hDlg, IDC_AVIOUTPUT_FPS_STATIC), WM_SETTEXT, (WPARAM) 0, (LPARAM) tmpstr);
 
-    sprintf (tmpstr, "Actual: %d x %d", workprefs.gfx_size.width, workprefs.gfx_size.height);
+    _stprintf (tmpstr, L"Actual: %d x %d", workprefs.gfx_size.width, workprefs.gfx_size.height);
     SendMessage (GetDlgItem(hDlg, IDC_AVIOUTPUT_DIMENSIONS_STATIC), WM_SETTEXT, (WPARAM) 0, (LPARAM) tmpstr);
 
     switch(avioutput_fps)
@@ -10728,7 +10684,7 @@ static void values_from_avioutputdlg (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
 
 static void enable_for_avioutputdlg(HWND hDlg)
 {
-    char tmp[1000];
+    TCHAR tmp[1000];
 #if defined (PROWIZARD)
     ew (hDlg, IDC_PROWIZARD, TRUE);
     if (full_property_sheet)
@@ -10753,21 +10709,21 @@ static void enable_for_avioutputdlg(HWND hDlg)
     }
 
     if (avioutput_audio == AVIAUDIO_WAV) {
-       strcpy (tmp, "Wave (internal)");
+       _tcscpy (tmp, L"Wave (internal)");
     } else {
-       avioutput_audio = AVIOutput_GetAudioCodec (tmp, sizeof tmp);
+       avioutput_audio = AVIOutput_GetAudioCodec (tmp, sizeof tmp / sizeof (TCHAR));
     }
     if(!avioutput_audio) {
        CheckDlgButton (hDlg, IDC_AVIOUTPUT_AUDIO, BST_UNCHECKED);
-       WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, tmp, sizeof tmp);
+       WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, tmp, sizeof tmp / sizeof (TCHAR));
     }
     SetWindowText (GetDlgItem (hDlg, IDC_AVIOUTPUT_AUDIO_STATIC), tmp);
 
     if (avioutput_audio != AVIAUDIO_WAV)
-       avioutput_video = AVIOutput_GetVideoCodec (tmp, sizeof tmp);
+       avioutput_video = AVIOutput_GetVideoCodec (tmp, sizeof tmp / sizeof (TCHAR));
     if(!avioutput_video) {
        CheckDlgButton (hDlg, IDC_AVIOUTPUT_VIDEO, BST_UNCHECKED);
-       WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, tmp, sizeof tmp);
+       WIN32GUI_LoadUIString (IDS_AVIOUTPUT_NOCODEC, tmp, sizeof tmp / sizeof (TCHAR));
     }
     SetWindowText (GetDlgItem (hDlg, IDC_AVIOUTPUT_VIDEO_STATIC), tmp);
 
@@ -10790,7 +10746,7 @@ static void enable_for_avioutputdlg(HWND hDlg)
 static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     static int recursive = 0;
-    char tmp[1000];
+    TCHAR tmp[1000];
 
     switch(msg)
     {
@@ -10803,8 +10759,8 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
            SendDlgItemMessage (hDlg, IDC_AVIOUTPUT_FPS, TBM_SETPOS, TRUE, avioutput_fps);
            SendMessage (hDlg, WM_HSCROLL, (WPARAM) NULL, (LPARAM) NULL);
            if (!avioutput_filename[0]) {
-               fetch_path ("VideoPath", avioutput_filename, sizeof (avioutput_filename));
-               strcat (avioutput_filename, "output.avi");
+               fetch_path (L"VideoPath", avioutput_filename, sizeof (avioutput_filename) / sizeof (TCHAR));
+               _tcscat (avioutput_filename, L"output.avi");
            }
 
        case WM_USER:
@@ -10894,7 +10850,7 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
                    if (avioutput_enabled)
                        AVIOutput_End ();
                    if(IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_AUDIO) == BST_CHECKED) {
-                       avioutput_audio = AVIOutput_ChooseAudioCodec (hDlg, tmp, sizeof tmp);
+                       avioutput_audio = AVIOutput_ChooseAudioCodec (hDlg, tmp, sizeof tmp / sizeof (TCHAR));
                        enable_for_avioutputdlg (hDlg);
                    } else {
                        avioutput_audio = 0;
@@ -10907,7 +10863,7 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
                    if (avioutput_enabled)
                        AVIOutput_End ();
                    if(IsDlgButtonChecked (hDlg, IDC_AVIOUTPUT_VIDEO) == BST_CHECKED) {
-                       avioutput_video = AVIOutput_ChooseVideoCodec (hDlg, tmp, sizeof tmp);
+                       avioutput_video = AVIOutput_ChooseVideoCodec (hDlg, tmp, sizeof tmp / sizeof (TCHAR));
                        if (avioutput_audio = AVIAUDIO_WAV)
                            avioutput_audio = 0;
                        enable_for_avioutputdlg (hDlg);
@@ -10938,15 +10894,15 @@ static INT_PTR CALLBACK AVIOutputDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
                    ofn.lpfnHook = NULL;
                    ofn.lpTemplateName = NULL;
                    ofn.lCustData = 0;
-                   ofn.lpstrFilter = "Video Clip (*.avi)\0*.avi\0Wave Sound (*.wav)\0";
+                   ofn.lpstrFilter = L"Video Clip (*.avi)\0*.avi\0Wave Sound (*.wav)\0";
 
                    if(!GetSaveFileName (&ofn))
                        break;
                    if (ofn.nFilterIndex == 2) {
                        avioutput_audio = AVIAUDIO_WAV;
                        avioutput_video = 0;
-                       if (strlen (avioutput_filename) > 4 && !stricmp (avioutput_filename + strlen (avioutput_filename) - 4, ".avi"))
-                           strcpy (avioutput_filename + strlen (avioutput_filename) - 4, ".wav");
+                       if (_tcslen (avioutput_filename) > 4 && !_tcsicmp (avioutput_filename + _tcslen (avioutput_filename) - 4, L".avi"))
+                           _tcscpy (avioutput_filename + _tcslen (avioutput_filename) - 4, L".wav");
                    }
                    break;
                }
@@ -10972,7 +10928,7 @@ struct GUIPAGE {
     HTREEITEM tv;
     int himg;
     int idx;
-    const char *help;
+    const TCHAR *help;
     HACCEL accel;
     int fullpanel;
     struct newresource *nres;
@@ -11090,8 +11046,8 @@ static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam)
 {
     int i;
     TOOLINFO ti;
-    char tmp[MAX_DPATH];
-    char *p;
+    TCHAR tmp[MAX_DPATH];
+    TCHAR *p;
     LRESULT v;
 
     if (GetParent (hwnd) != panelDlg)
@@ -11112,17 +11068,17 @@ static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam)
        }
     }
     tmp[0] = 0;
-    SendMessage (hwnd, WM_GETTEXT, (WPARAM)sizeof (tmp), (LPARAM)tmp);
-    p = strchr (tmp, '[');
-    if (strlen (tmp) > 0 && p && strlen(p) > 2 && p[1] == ']') {
+    SendMessage (hwnd, WM_GETTEXT, (WPARAM)sizeof (tmp) / sizeof (TCHAR), (LPARAM)tmp);
+    p = _tcschr (tmp, '[');
+    if (_tcslen (tmp) > 0 && p && _tcslen (p) > 2 && p[1] == ']') {
        int imageid = 0;
        *p++ = 0;
        *p++ = 0;
        if (p[0] == ' ')
            *p++;
        if (p[0] == '#')
-           imageid = atol (p + 1);
-       tmp[strlen(tmp) - 1] = 0;
+           imageid = _tstol (p + 1);
+       tmp[_tcslen (tmp) - 1] = 0;
        ti.cbSize = sizeof (TOOLINFO);
        ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
        ti.hwnd = GetParent (hwnd);
@@ -11163,14 +11119,14 @@ static BOOL CALLBACK childenumproc (HWND hwnd, LPARAM lParam)
        }
        return 1;
     }
-    p = strchr (tmp, ']');
-    if (strlen (tmp) > 0 && p && strlen(p) > 2 && p[1] == '[') {
+    p = _tcschr (tmp, ']');
+    if (_tcslen (tmp) > 0 && p && _tcslen (p) > 2 && p[1] == '[') {
        RECT r;
        *p++ = 0;
        *p++ = 0;
        if (p[0] == ' ')
            *p++;
-       tmp[strlen(tmp) - 1] = 0;
+       tmp[_tcslen (tmp) - 1] = 0;
        SendMessage (hwnd, WM_SETTEXT, 0, (LPARAM)tmp);
        ti.cbSize = sizeof (TOOLINFO);
        ti.uFlags = TTF_SUBCLASS;
@@ -11226,8 +11182,8 @@ static HWND updatePanel (HWND hDlg, int id)
                LONG left, top;
                left = r.left;
                top = r.top;
-               regsetint (NULL, "GUIPosX", left);
-               regsetint (NULL, "GUIPosY", top);
+               regsetint (NULL, L"GUIPosX", left);
+               regsetint (NULL, L"GUIPosY", top);
            }
        }
        ew (hDlg, IDHELP, FALSE);
@@ -11294,13 +11250,13 @@ static HWND updatePanel (HWND hDlg, int id)
 static HTREEITEM CreateFolderNode (HWND TVhDlg, int nameid, HTREEITEM parent, int nodeid, int sub)
 {
     TVINSERTSTRUCT is;
-    char txt[100];
+    TCHAR txt[100];
 
     memset (&is, 0, sizeof (is));
     is.hInsertAfter = TVI_LAST;
     is.hParent = parent;
     is.itemex.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
-    WIN32GUI_LoadUIString (nameid, txt, sizeof (txt));
+    WIN32GUI_LoadUIString (nameid, txt, sizeof (txt) / sizeof (TCHAR));
     is.itemex.pszText = txt;
     is.itemex.lParam = (LPARAM)(nodeid | (sub << 16));
     is.itemex.iImage = C_PAGES;
@@ -11322,7 +11278,7 @@ static void CreateNode (HWND TVhDlg, int page, HTREEITEM parent)
     is.hInsertAfter = TVI_LAST;
     is.hParent = parent;
     is.itemex.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
-    is.itemex.pszText = (char*)p->title;
+    is.itemex.pszText = (TCHAR*)p->title;
     is.itemex.lParam = (LPARAM)p->idx;
     is.itemex.iImage = p->himg;
     is.itemex.iSelectedImage = is.itemex.iImage;
@@ -11341,7 +11297,7 @@ static void createTreeView (HWND hDlg, int currentpage)
     if (himl) {
        HICON icon;
        for (i = 0; i < C_PAGES; i++) {
-           icon = LoadIcon (hInst, (LPCSTR)ppage[i].icon);
+           icon = LoadIcon (hInst, (LPCWSTR)ppage[i].icon);
            ppage[i].himg = ImageList_AddIcon (himl, icon);
        }
        icon = LoadIcon (hInst, MAKEINTRESOURCE (IDI_ROOT));
@@ -11395,8 +11351,8 @@ static void centerWindow (HWND hDlg)
     if (owner == NULL)
        owner = GetDesktopWindow ();
     if (isfullscreen () <= 0) {
-       regqueryint (NULL, "GUIPosX", &x);
-       regqueryint (NULL, "GUIPosY", &y);
+       regqueryint (NULL, L"GUIPosX", &x);
+       regqueryint (NULL, L"GUIPosY", &y);
     } else {
        GetWindowRect (owner, &rcOwner);
        GetWindowRect (hDlg, &rcDlg);
@@ -11426,7 +11382,7 @@ static void centerWindow (HWND hDlg)
     SetWindowPos (hDlg,  HWND_TOP, x, y, 0, 0, SWP_NOSIZE);
 }
 
-static int do_filesys_insert (const char *root)
+static int do_filesys_insert (const TCHAR *root)
 {
     if (filesys_insert (-1, NULL, root, 0, 0) == 0)
        return filesys_media_change (root, 2, NULL);
@@ -11436,7 +11392,7 @@ static int do_filesys_insert (const char *root)
 int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int        currentpage)
 {
     int cnt, i, drv, drvdrag, firstdrv, list;
-    char file[MAX_DPATH];
+    TCHAR file[MAX_DPATH];
     int dfxtext[] = { IDC_DF0TEXT, IDC_DF0TEXTQ, IDC_DF1TEXT, IDC_DF1TEXTQ, IDC_DF2TEXT, -1, IDC_DF3TEXT, -1 };
     POINT pt;
     RECT r, r2;
@@ -11481,13 +11437,13 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int       currentpage)
        struct zfile *z;
        int type = -1, zip = 0;
 
-       DragQueryFile (hd, i, file, sizeof (file));
+       DragQueryFile (hd, i, file, sizeof (file) / sizeof (TCHAR));
        flags = GetFileAttributes (file);
        if (flags & FILE_ATTRIBUTE_DIRECTORY)
            type = ZFILE_HDF;
        if (type < 0) {
            if (currentpage < 0) {
-               z = zfile_fopen_nozip (file, "rb");
+               z = zfile_fopen_nozip (file, L"rb");
                if (z) {
                    if (iszip (z))
                        zip = 1;
@@ -11495,7 +11451,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage)
                }
            }
            if (!zip) {
-               z = zfile_fopen (file, "rb");
+               z = zfile_fopen (file, L"rb");
                if (z) {
                    if (currentpage < 0 && iszip (z)) {
                        zip = 1;
@@ -11531,17 +11487,17 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int       currentpage)
                        list = 0;
                        while (list < MAX_SPARE_DRIVES) {
                            if (!prefs->dfxlist[list][0]) {
-                               strcpy (prefs->dfxlist[list], file);
+                               _tcscpy (prefs->dfxlist[list], file);
                                break;
                            }
                            list++;
                        }
                    }
                } else if (currentpage == HARDDISK_ID) {
-                   add_filesys_config (&workprefs, -1, NULL, "", file, 0,
+                   add_filesys_config (&workprefs, -1, NULL, L"", file, 0,
                        0, 0, 0, 0, 0, NULL, 0, 0);
                } else {
-                   strcpy (workprefs.df[drv], file);
+                   _tcscpy (workprefs.df[drv], file);
                    disk_insert (drv, workprefs.df[drv]);
                    drv++;
                    if (drv >= (currentpage == QUICKSTART_ID ? 2 : 4))
@@ -11555,13 +11511,13 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int       currentpage)
            case ZFILE_ROM:
                if (rd) {
                    if (rd->type == ROMTYPE_KICK || rd->type == ROMTYPE_KICKCD32)
-                       strcpy (prefs->romfile, file);
+                       _tcscpy (prefs->romfile, file);
                    if (rd->type == ROMTYPE_EXTCD32 || rd->type == ROMTYPE_EXTCDTV)
-                       strcpy (prefs->romextfile, file);
+                       _tcscpy (prefs->romextfile, file);
                    if (rd->type == ROMTYPE_AR)
-                       strcpy (prefs->cartfile, file);
+                       _tcscpy (prefs->cartfile, file);
                } else {
-                   strcpy (prefs->romfile, file);
+                   _tcscpy (prefs->romfile, file);
                }
            break;
            case ZFILE_HDF:
@@ -11569,7 +11525,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage)
                    if (!full_property_sheet && currentpage < 0)
                        do_filesys_insert (file);
                    else
-                       add_filesys_config (&workprefs, -1, NULL, "", file, 0,
+                       add_filesys_config (&workprefs, -1, NULL, L"", file, 0,
                            0, 0, 0, 0, 0, NULL, 0, 0);
                } else {
                    add_filesys_config (&workprefs, -1, NULL, NULL, file, 0,
@@ -11581,7 +11537,7 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage)
                    0, 0, 0, 512, 0, NULL, 0, 0);
            break;
            case ZFILE_NVR:
-               strcpy (prefs->flashfile, file);
+               _tcscpy (prefs->flashfile, file);
            break;
            case ZFILE_CONFIGURATION:
                if (target_cfgfile_load (&workprefs, file, 0, 0)) {
@@ -11597,22 +11553,22 @@ int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int       currentpage)
            break;
            case ZFILE_STATEFILE:
                savestate_state = STATE_DORESTORE;
-               strcpy (savestate_fname, file);
+               _tcscpy (savestate_fname, file);
                ret = 1;
            break;
            default:
                if (currentpage < 0 && !full_property_sheet) {
                    do_filesys_insert (file);
                } else if (currentpage == HARDDISK_ID) {
-                   add_filesys_config (&workprefs, -1, NULL, "", file, 0,
+                   add_filesys_config (&workprefs, -1, NULL, L"", file, 0,
                        0, 0, 0, 0, 0, NULL, 0, 0);
                } else {
                    rd = scan_arcadia_rom (file, 0);
                    if (rd) {
                        if (rd->type == ROMTYPE_ARCADIABIOS)
-                           strcpy (prefs->romextfile, file);
+                           _tcscpy (prefs->romextfile, file);
                        else if (rd->type == ROMTYPE_ARCADIAGAME)
-                           strcpy (prefs->cartfile, file);
+                           _tcscpy (prefs->cartfile, file);
                    }
                }
            break;
@@ -11639,7 +11595,7 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
                    doit = 1;
            } else if (pBHdr && pBHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
                DEV_BROADCAST_DEVICEINTERFACE *dbd = (DEV_BROADCAST_DEVICEINTERFACE*)lParam;
-               write_log ("%s: %s\n", wParam == DBT_DEVICEREMOVECOMPLETE ? "Removed" : "Inserted",
+               write_log (L"%s: %s\n", wParam == DBT_DEVICEREMOVECOMPLETE ? "Removed" : "Inserted",
                    dbd->dbcc_name);
                if (wParam == DBT_DEVICEREMOVECOMPLETE)
                    doit = 1;
@@ -11672,8 +11628,8 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l
            guiDlg = hDlg;
            SendMessage (hDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon (GetModuleHandle (NULL), MAKEINTRESOURCE(IDI_APPICON)));
            if (full_property_sheet) {
-               char tmp[100];
-               WIN32GUI_LoadUIString (IDS_STARTEMULATION, tmp, sizeof (tmp));
+               TCHAR tmp[100];
+               WIN32GUI_LoadUIString (IDS_STARTEMULATION, tmp, sizeof (tmp) / sizeof (TCHAR));
                SetWindowText (GetDlgItem (guiDlg, IDOK), tmp);
            }
            ShowWindow (GetDlgItem(guiDlg, IDC_RESTARTEMU), full_property_sheet ? SW_HIDE : SW_SHOW);
@@ -11761,7 +11717,7 @@ static ACCEL EmptyAccel[] = {
 
 struct newresource *getresource (int tmpl)
 {
-    char rid[10];
+    TCHAR rid[10];
     HRSRC hrsrc;
     HGLOBAL res;
     HINSTANCE inst = hUIDLL ? hUIDLL : hInst;
@@ -11769,7 +11725,7 @@ struct newresource *getresource (int tmpl)
     struct newresource *nr;
     int size;
 
-    sprintf (rid,"#%d", tmpl);
+    _stprintf (rid, L"#%d", tmpl);
     hrsrc = FindResource (inst, rid, RT_DIALOG);
     if (!hrsrc) {
        inst = hInst;
@@ -11827,7 +11783,7 @@ HWND CustomCreateDialog (int templ, HWND hDlg, DLGPROC proc)
 }
 
 static int init_page (int tmpl, int icon, int title,
-    INT_PTR (CALLBACK FAR *func) (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam), ACCEL *accels, char *help)
+    INT_PTR (CALLBACK FAR *func) (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam), ACCEL *accels, TCHAR *help)
 {
     LPTSTR lpstrTitle;
     static id = 0;
@@ -11938,32 +11894,32 @@ static int GetSettings (int all_options, HWND hwnd)
     if (!init_called) {
        first = 1;
        panelresource = getresource (IDD_PANEL);
-       LOADSAVE_ID = init_page (IDD_LOADSAVE, IDI_CONFIGFILE, IDS_LOADSAVE, LoadSaveDlgProc, NULL, "gui/configurations.htm");
-       MEMORY_ID = init_page (IDD_MEMORY, IDI_MEMORY, IDS_MEMORY, MemoryDlgProc, NULL, "gui/ram.htm");
-       KICKSTART_ID = init_page (IDD_KICKSTART, IDI_MEMORY, IDS_KICKSTART, KickstartDlgProc, NULL, "gui/rom.htm");
-       CPU_ID = init_page (IDD_CPU, IDI_CPU, IDS_CPU, CPUDlgProc, NULL, "gui/cpu.htm");
-       DISPLAY_ID = init_page (IDD_DISPLAY, IDI_DISPLAY, IDS_DISPLAY, DisplayDlgProc, NULL, "gui/display.htm");
+       LOADSAVE_ID = init_page (IDD_LOADSAVE, IDI_CONFIGFILE, IDS_LOADSAVE, LoadSaveDlgProc, NULL, L"gui/configurations.htm");
+       MEMORY_ID = init_page (IDD_MEMORY, IDI_MEMORY, IDS_MEMORY, MemoryDlgProc, NULL, L"gui/ram.htm");
+       KICKSTART_ID = init_page (IDD_KICKSTART, IDI_MEMORY, IDS_KICKSTART, KickstartDlgProc, NULL, L"gui/rom.htm");
+       CPU_ID = init_page (IDD_CPU, IDI_CPU, IDS_CPU, CPUDlgProc, NULL, L"gui/cpu.htm");
+       DISPLAY_ID = init_page (IDD_DISPLAY, IDI_DISPLAY, IDS_DISPLAY, DisplayDlgProc, NULL, L"gui/display.htm");
 #if defined (GFXFILTER)
-       HW3D_ID = init_page (IDD_FILTER, IDI_DISPLAY, IDS_FILTER, hw3dDlgProc, NULL, "gui/filter.htm");
+       HW3D_ID = init_page (IDD_FILTER, IDI_DISPLAY, IDS_FILTER, hw3dDlgProc, NULL, L"gui/filter.htm");
 #endif
-       CHIPSET_ID = init_page (IDD_CHIPSET, IDI_CPU, IDS_CHIPSET, ChipsetDlgProc, NULL, "gui/chipset.htm");
-       CHIPSET2_ID = init_page (IDD_CHIPSET2, IDI_CPU, IDS_CHIPSET2, ChipsetDlgProc2, NULL, "gui/chipset.htm");
-       SOUND_ID = init_page (IDD_SOUND, IDI_SOUND, IDS_SOUND, SoundDlgProc, NULL, "gui/sound.htm");
-       FLOPPY_ID = init_page (IDD_FLOPPY, IDI_FLOPPY, IDS_FLOPPY, FloppyDlgProc, NULL, "gui/floppies.htm");
-       DISK_ID = init_page (IDD_DISK, IDI_FLOPPY, IDS_DISK, SwapperDlgProc, SwapperAccel, "gui/disk.htm");
+       CHIPSET_ID = init_page (IDD_CHIPSET, IDI_CPU, IDS_CHIPSET, ChipsetDlgProc, NULL, L"gui/chipset.htm");
+       CHIPSET2_ID = init_page (IDD_CHIPSET2, IDI_CPU, IDS_CHIPSET2, ChipsetDlgProc2, NULL, L"gui/chipset.htm");
+       SOUND_ID = init_page (IDD_SOUND, IDI_SOUND, IDS_SOUND, SoundDlgProc, NULL, L"gui/sound.htm");
+       FLOPPY_ID = init_page (IDD_FLOPPY, IDI_FLOPPY, IDS_FLOPPY, FloppyDlgProc, NULL, L"gui/floppies.htm");
+       DISK_ID = init_page (IDD_DISK, IDI_FLOPPY, IDS_DISK, SwapperDlgProc, SwapperAccel, L"gui/disk.htm");
 #ifdef FILESYS
-       HARDDISK_ID = init_page (IDD_HARDDISK, IDI_HARDDISK, IDS_HARDDISK, HarddiskDlgProc, HarddiskAccel, "gui/hard-drives.htm");
+       HARDDISK_ID = init_page (IDD_HARDDISK, IDI_HARDDISK, IDS_HARDDISK, HarddiskDlgProc, HarddiskAccel, L"gui/hard-drives.htm");
 #endif
-       GAMEPORTS_ID = init_page (IDD_GAMEPORTS, IDI_GAMEPORTS, IDS_GAMEPORTS, GamePortsDlgProc, NULL, "gui/gameports.htm");
-       IOPORTS_ID = init_page (IDD_IOPORTS, IDI_IOPORTS, IDS_IOPORTS, IOPortsDlgProc, NULL, "gui/ioports.htm");
-       INPUT_ID = init_page (IDD_INPUT, IDI_INPUT, IDS_INPUT, InputDlgProc, NULL, "gui/input.htm");
-       MISC1_ID = init_page (IDD_MISC1, IDI_MISC1, IDS_MISC1, MiscDlgProc1, NULL, "gui/misc.htm");
-       MISC2_ID = init_page (IDD_MISC2, IDI_MISC2, IDS_MISC2, MiscDlgProc2, NULL, "gui/misc2.htm");
+       GAMEPORTS_ID = init_page (IDD_GAMEPORTS, IDI_GAMEPORTS, IDS_GAMEPORTS, GamePortsDlgProc, NULL, L"gui/gameports.htm");
+       IOPORTS_ID = init_page (IDD_IOPORTS, IDI_IOPORTS, IDS_IOPORTS, IOPortsDlgProc, NULL, L"gui/ioports.htm");
+       INPUT_ID = init_page (IDD_INPUT, IDI_INPUT, IDS_INPUT, InputDlgProc, NULL, L"gui/input.htm");
+       MISC1_ID = init_page (IDD_MISC1, IDI_MISC1, IDS_MISC1, MiscDlgProc1, NULL, L"gui/misc.htm");
+       MISC2_ID = init_page (IDD_MISC2, IDI_MISC2, IDS_MISC2, MiscDlgProc2, NULL, L"gui/misc2.htm");
 #ifdef AVIOUTPUT
-       AVIOUTPUT_ID = init_page (IDD_AVIOUTPUT, IDI_AVIOUTPUT, IDS_AVIOUTPUT, AVIOutputDlgProc, NULL, "gui/output.htm");
+       AVIOUTPUT_ID = init_page (IDD_AVIOUTPUT, IDI_AVIOUTPUT, IDS_AVIOUTPUT, AVIOutputDlgProc, NULL, L"gui/output.htm");
 #endif
-       PATHS_ID = init_page (IDD_PATHS, IDI_PATHS, IDS_PATHS, PathsDlgProc, NULL, "gui/paths.htm");
-       QUICKSTART_ID = init_page (IDD_QUICKSTART, IDI_QUICKSTART, IDS_QUICKSTART, QuickstartDlgProc, NULL, "gui/quickstart.htm");
+       PATHS_ID = init_page (IDD_PATHS, IDI_PATHS, IDS_PATHS, PathsDlgProc, NULL, L"gui/paths.htm");
+       QUICKSTART_ID = init_page (IDD_QUICKSTART, IDI_QUICKSTART, IDS_QUICKSTART, QuickstartDlgProc, NULL, L"gui/quickstart.htm");
        ABOUT_ID = init_page (IDD_ABOUT, IDI_ABOUT, IDS_ABOUT, AboutDlgProc, NULL, NULL);
        FRONTEND_ID = init_page (IDD_FRONTEND, IDI_QUICKSTART, IDS_FRONTEND, AboutDlgProc, NULL, NULL);
        C_PAGES = FRONTEND_ID + 1;
@@ -11981,7 +11937,7 @@ static int GetSettings (int all_options, HWND hwnd)
     hAccelTable = NULL;
     DragAcceptFiles (hwnd, TRUE);
     if (first)
-       write_log ("Entering GUI idle loop\n");
+       write_log (L"Entering GUI idle loop\n");
 
     scaleresource_setmaxsize (800, 600);
     tres = scaleresource (panelresource, hwnd);
@@ -12091,7 +12047,7 @@ void check_prefs_changed_gui (void)
 {
 }
 
-void gui_disk_image_change (int unitnum, const char *name)
+void gui_disk_image_change (int unitnum, const TCHAR *name)
 {
 #ifdef RETROPLATFORM
     rp_disk_image_change (unitnum, name);
@@ -12152,9 +12108,9 @@ void gui_fps (int fps, int idle)
 void gui_led (int led, int on)
 {
     WORD type;
-    static char drive_text[NUM_LEDS * 16];
-    static char dfx[4][300];
-    char *ptr, *tt, *p;
+    static TCHAR drive_text[NUM_LEDS * 16];
+    static TCHAR dfx[4][300];
+    TCHAR *ptr, *tt, *p;
     int pos = -1, j;
     int writing = 0;
 
@@ -12176,11 +12132,11 @@ void gui_led (int led, int on)
        pos = 6 + (led - 1);
        ptr = drive_text + pos * 16;
        if (gui_data.drive_disabled[led - 1])
-           strcpy (ptr, "");
+           _tcscpy (ptr, L"");
        else
-           sprintf (ptr , "%02d  .", gui_data.drive_track[led - 1]);
+           _stprintf (ptr , L"%02d  .", gui_data.drive_track[led - 1]);
        p = gui_data.df[led - 1];
-       j = strlen (p) - 1;
+       j = _tcslen (p) - 1;
        if (j < 0)
            j = 0;
        while (j > 0) {
@@ -12190,38 +12146,38 @@ void gui_led (int led, int on)
        }
        tt = dfx[led - 1];
        tt[0] = 0;
-       if (strlen (p + j) > 0)
-           sprintf (tt, "%s [CRC=%08X]", p + j, gui_data.crc32[led - 1]);
+       if (_tcslen (p + j) > 0)
+           _stprintf (tt, L"%s [CRC=%08X]", p + j, gui_data.crc32[led - 1]);
     } else if (led == 0) {
        pos = 3;
-       ptr = strcpy (drive_text + pos * 16, "Power");
+       ptr = _tcscpy (drive_text + pos * 16, L"Power");
     } else if (led == 5) {
        pos = 4;
-       ptr = strcpy (drive_text + pos * 16, "HD");
+       ptr = _tcscpy (drive_text + pos * 16, L"HD");
     } else if (led == 6) {
        pos = 5;
-       ptr = strcpy (drive_text + pos * 16, "CD");
+       ptr = _tcscpy (drive_text + pos * 16, L"CD");
     } else if (led == 7) {
        extern int p96vblank;
        pos = 2;
        ptr = drive_text + pos * 16;
        if (picasso_on)
-           sprintf (ptr, "%d [%.1f]", p96vblank, (double)(gui_data.fps  / 10.0));
+           _stprintf (ptr, L"%d [%.1f]", p96vblank, (double)(gui_data.fps  / 10.0));
        else
-           sprintf (ptr, "FPS: %.1f", (double)(gui_data.fps  / 10.0));
+           _stprintf (ptr, L"FPS: %.1f", (double)(gui_data.fps  / 10.0));
        if (pause_emulation)
-           strcpy (ptr, "PAUSED");
+           _tcscpy (ptr, L"PAUSED");
     } else if (led == 8) {
        pos = 1;
        ptr = drive_text + pos * 16;
-       sprintf (ptr, "CPU: %.0f%%", (double)((gui_data.idle) / 10.0));
+       _stprintf (ptr, L"CPU: %.0f%%", (double)((gui_data.idle) / 10.0));
     } else if (led == 9) {
        pos = 0;
        ptr = drive_text + pos * 16;
        if (gui_data.sndbuf_status < 3) {
-           sprintf (ptr, "SND: %+.0f%%", (double)((gui_data.sndbuf) / 10.0));
+           _stprintf (ptr, L"SND: %+.0f%%", (double)((gui_data.sndbuf) / 10.0));
        } else {
-           strcpy (ptr, "SND: -");
+           _tcscpy (ptr, L"SND: -");
            on = 0;
        }
     }
@@ -12236,7 +12192,7 @@ void gui_led (int led, int on)
     }
 }
 
-void gui_filename (int num, const char *name)
+void gui_filename (int num, const TCHAR *name)
 {
 }
 
@@ -12255,7 +12211,7 @@ static int fsdialog (HWND *hwnd, DWORD *flags)
        return 0;
     hr = DirectDraw_FlipToGDISurface ();
     if (FAILED (hr))
-       write_log ("FlipToGDISurface failed, %s\n", DXError (hr));
+       write_log (L"FlipToGDISurface failed, %s\n", DXError (hr));
     *flags |= MB_SETFOREGROUND;
     *flags |= MB_TOPMOST;
     return 0;
@@ -12263,7 +12219,7 @@ static int fsdialog (HWND *hwnd, DWORD *flags)
     HRESULT hr;
     hr = DirectDraw_FlipToGDISurface();
     if (FAILED(hr)) {
-       write_log ("FlipToGDISurface failed, %s\n", DXError (hr));
+       write_log (L"FlipToGDISurface failed, %s\n", DXError (hr));
        return 0;
     }
     *hwnd = NULL;
@@ -12271,14 +12227,14 @@ static int fsdialog (HWND *hwnd, DWORD *flags)
 */
 }
 
-int gui_message_multibutton (int flags, const char *format,...)
+int gui_message_multibutton (int flags, const TCHAR *format,...)
 {
-    char msg[2048];
-    char szTitle[MAX_DPATH];
+    TCHAR msg[2048];
+    TCHAR szTitle[MAX_DPATH];
     va_list parms;
     int flipflop = 0;
     int fullscreen = 0;
-    int focuso = focus;
+    int focuso = isfocus ();
     int mbflags, ret;
     HWND hwnd;
 
@@ -12296,11 +12252,11 @@ int gui_message_multibutton (int flags, const char *format,...)
        ShowWindow (hAmigaWnd, SW_MINIMIZE);
 
     va_start (parms, format);
-    vsprintf (msg, format, parms);
+    _vstprintf (msg, format, parms);
     va_end (parms);
     write_log (msg);
-    if (msg[strlen (msg)-1]!='\n')
-       write_log ("\n");
+    if (msg[_tcslen (msg) - 1]!='\n')
+       write_log (L"\n");
 
     WIN32GUI_LoadUIString (IDS_ERRORTITLE, szTitle, MAX_DPATH);
 
@@ -12310,7 +12266,7 @@ int gui_message_multibutton (int flags, const char *format,...)
        ShowWindow (hAmigaWnd, SW_RESTORE);
 
     resume_sound ();
-    setmouseactive (focuso);
+    setmouseactive (focuso > 0 ? 1 : 0);
     if (ret == IDOK)
        return 0;
     if (ret == IDYES)
@@ -12322,19 +12278,19 @@ int gui_message_multibutton (int flags, const char *format,...)
     return 0;
 }
 
-void gui_message (const char *format,...)
+void gui_message (const TCHAR *format,...)
 {
-    char msg[2048];
-    char szTitle[MAX_DPATH];
+    TCHAR msg[2048];
+    TCHAR szTitle[MAX_DPATH];
     va_list parms;
     int flipflop = 0;
     int fullscreen = 0;
-    int focuso = focus;
+    int focuso = isfocus ();
     DWORD flags = MB_OK | MB_TASKMODAL;
     HWND hwnd;
 
     va_start (parms, format);
-    vsprintf (msg, format, parms);
+    _vstprintf (msg, format, parms);
     va_end (parms);
     if (full_property_sheet) {
        pre_gui_message (msg);
@@ -12346,42 +12302,42 @@ void gui_message (const char *format,...)
        ShowWindow (hAmigaWnd, SW_MINIMIZE);
 
     write_log (msg);
-    if (msg[strlen(msg) - 1] != '\n')
-       write_log ("\n");
+    if (msg[_tcslen (msg) - 1] != '\n')
+       write_log (L"\n");
 
     WIN32GUI_LoadUIString (IDS_ERRORTITLE, szTitle, MAX_DPATH);
 
     if (!MessageBox (hwnd, msg, szTitle, flags))
-       write_log ("MessageBox(%s) failed, err=%d\n", msg, GetLastError());
+       write_log (L"MessageBox(%s) failed, err=%d\n", msg, GetLastError());
 
     if (flipflop)
        ShowWindow (hAmigaWnd, SW_RESTORE);
     resume_sound ();
-    setmouseactive (focuso);
+    setmouseactive (focuso > 0 ? 1 : 0);
 }
 
 void gui_message_id (int id)
 {
-    char msg[MAX_DPATH];
-    WIN32GUI_LoadUIString (id, msg, sizeof (msg));
+    TCHAR msg[MAX_DPATH];
+    WIN32GUI_LoadUIString (id, msg, sizeof (msg) / sizeof (TCHAR));
     gui_message (msg);
 }
 
-void pre_gui_message (const char *format,...)
+void pre_gui_message (const TCHAR *format,...)
 {
-    char msg[2048];
-    char szTitle[MAX_DPATH];
+    TCHAR msg[2048];
+    TCHAR szTitle[MAX_DPATH];
     va_list parms;
 
     va_start (parms, format);
-    vsprintf (msg, format, parms);
+    _vstprintf (msg, format, parms);
     va_end (parms);
     write_log (msg);
-    if (msg[strlen (msg)-1]!='\n')
-       write_log ("\n");
+    if (msg[_tcslen (msg) - 1] != '\n')
+       write_log (L"\n");
 
     WIN32GUI_LoadUIString (IDS_ERRORTITLE, szTitle, MAX_DPATH);
-    strcat (szTitle, BetaStr);
+    _tcscat (szTitle, BetaStr);
     MessageBox (guiDlg, msg, szTitle, MB_OK | MB_TASKMODAL | MB_SETFOREGROUND);
 
 }
@@ -12425,7 +12381,7 @@ static int gettranslation (int msg)
 
 void notify_user (int msg)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     int c = 0;
 
     c = gettranslation (msg);
@@ -12435,10 +12391,10 @@ void notify_user (int msg)
     gui_message (tmp);
 }
 
-void notify_user_parms (int msg, const char *parms, ...)
+void notify_user_parms (int msg, const TCHAR *parms, ...)
 {
-    char msgtxt[MAX_DPATH];
-    char tmp[MAX_DPATH];
+    TCHAR msgtxt[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     int c = 0;
     va_list parms2;
 
@@ -12447,13 +12403,13 @@ void notify_user_parms (int msg, const char *parms, ...)
        return;
     WIN32GUI_LoadUIString (c, tmp, MAX_DPATH);
     va_start (parms2, parms);
-    vsprintf (msgtxt, tmp, parms2);
+    _vstprintf (msgtxt, tmp, parms2);
     gui_message (msgtxt);
-    va_end (parms);
+    va_end (parms2);
 }
 
 
-int translate_message (int msg,        char *out)
+int translate_message (int msg,        TCHAR *out)
 {
     msg = gettranslation (msg);
     out[0] = 0;
index 80a3cca0bb13ea686ead853f9f024e9794b491ed..285d7534072d6e4c314ad3ca8a1834aa449a0b35 100644 (file)
@@ -9,10 +9,10 @@
 #define CONFIG_LOAD_FULL 3
 #define CONFIG_DELETE 4
 
-void WIN32GUI_LoadUIString (DWORD id, char *string, DWORD dwStringLen);
-extern int DiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, char *);
+void WIN32GUI_LoadUIString (DWORD id, TCHAR *string, DWORD dwStringLen);
+extern int DiskSelection (HWND hDlg, WPARAM wParam, int flag, struct uae_prefs *prefs, TCHAR *);
 void InitializeListView (HWND hDlg);
-extern void pre_gui_message (const char*,...);
+extern void pre_gui_message (const TCHAR*,...);
 extern void gui_message_id (int id);
 int dragdrop (HWND hDlg, HDROP hd, struct uae_prefs *prefs, int currentpage);
 UAEREG *read_disk_history (void);
@@ -33,6 +33,6 @@ extern void scaleresource_setmaxsize(int w, int h);
 extern HWND CustomCreateDialog (int templ, HWND hDlg, DLGPROC proc);
 extern INT_PTR CustomDialogBox (int templ, HWND hDlg, DLGPROC proc);
 extern struct newresource *getresource(int tmpl);
-extern struct newresource *resourcefont(struct newresource*, char *font, int size);
+extern struct newresource *resourcefont(struct newresource*, TCHAR *font, int size);
 
 #endif
index 99acdfff93c6f7df06d6328dc934f75e131e5c12..ad2cbe724a59a8c721b406172e34ac808f7bc61d 100644 (file)
@@ -75,11 +75,11 @@ static int font_vista_ok;
 static wchar_t wfont_vista[] = L"Segoe UI";
 static wchar_t wfont_xp[] = L"Tahoma";
 static wchar_t wfont_old[] = L"MS Sans Serif";
-static char font_vista[] = "Segoe UI";
-static char font_xp[] = "Tahoma";
+static TCHAR font_vista[] = L"Segoe UI";
+static TCHAR font_xp[] = L"Tahoma";
 
 
-static BYTE *skiptext(BYTE *s)
+static BYTE *skiptext (BYTE *s)
 {
     if (s[0] == 0xff && s[1] == 0xff) {
        s += 4;
@@ -91,21 +91,21 @@ static BYTE *skiptext(BYTE *s)
     return s;
 }
 
-static BYTE *todword(BYTE *p)
+static BYTE *todword (BYTE *p)
 {
     while ((LONG_PTR)p & 3)
        p++;
     return p;
 }
 
-static void modifytemplate(DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2, int id, int mult)
+static void modifytemplate (DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2, int id, int mult)
 {
 
     d->cx = d->cx * mult / 100;
     d->cy = d->cy * mult / 100;
 }
 
-static void modifytemplatefont(DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2)
+static void modifytemplatefont (DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2)
 {
     wchar_t *p = NULL;
 
@@ -117,7 +117,7 @@ static void modifytemplatefont(DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2)
        wcscpy (d2->typeface, p);
 }
 
-static void modifyitem(DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2, DLGITEMTEMPLATEEX *dt, int id, int mult)
+static void modifyitem (DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2, DLGITEMTEMPLATEEX *dt, int id, int mult)
 {
     dt->cy = dt->cy * mult / 100;
     dt->cx = dt->cx * mult / 100;
@@ -125,7 +125,7 @@ static void modifyitem(DLGTEMPLATEEX *d, DLGTEMPLATEEX_END *d2, DLGITEMTEMPLATEE
     dt->x = dt->x * mult / 100;
 }
 
-static INT_PTR CALLBACK DummyProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+static INT_PTR CALLBACK DummyProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 {
     switch(msg)
     {
@@ -141,7 +141,7 @@ static INT_PTR CALLBACK DummyProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lPa
     return FALSE;
 }
 
-struct newresource *scaleresource(struct newresource *res, HWND parent)
+struct newresource *scaleresource (struct newresource *res, HWND parent)
 {
     DLGTEMPLATEEX *d;
     DLGTEMPLATEEX_END *d2;
@@ -168,20 +168,20 @@ struct newresource *scaleresource(struct newresource *res, HWND parent)
     d = ns->resource;
     d2 = ns->resource;
     p = (BYTE*)d + sizeof (DLGTEMPLATEEX);
-    p = skiptext(p);
-    p = skiptext(p);
-    p = skiptext(p);
+    p = skiptext (p);
+    p = skiptext (p);
+    p = skiptext (p);
     d2 = (DLGTEMPLATEEX_END*)p;
     p2 = p;
     p2 += sizeof (DLGTEMPLATEEX_END);
-    p2 = skiptext(p2);
-    p2 = todword(p2);
+    p2 = skiptext (p2);
+    p2 = todword (p2);
 
-    modifytemplatefont(d, d2);
+    modifytemplatefont (d, d2);
 
     p += sizeof (DLGTEMPLATEEX_END);
-    p = skiptext(p);
-    p = todword(p);
+    p = skiptext (p);
+    p = todword (p);
 
     if (p != p2)
        memmove (p, p2, ns->size - (p2 - (BYTE*)ns->resource));
@@ -190,13 +190,13 @@ struct newresource *scaleresource(struct newresource *res, HWND parent)
 
     for (i = 0; i < d->cDlgItems; i++) {
        dt = (DLGITEMTEMPLATEEX*)p;
-       modifyitem(d, d2, dt, ns->tmpl, mult);
+       modifyitem (d, d2, dt, ns->tmpl, mult);
        p += sizeof (DLGITEMTEMPLATEEX);
        p = skiptext(p);
        p = skiptext(p);
        p += ((WORD*)p)[0];
        p += sizeof (WORD);
-       p = todword(p);
+       p = todword (p);
     }
 
     ns->width = d->cx;
@@ -204,13 +204,13 @@ struct newresource *scaleresource(struct newresource *res, HWND parent)
     return ns;
 }
 
-void freescaleresource(struct newresource *ns)
+void freescaleresource (struct newresource *ns)
 {
     xfree (ns->resource);
     xfree (ns);
 }
 
-void scaleresource_setmaxsize(int w, int h)
+void scaleresource_setmaxsize (int w, int h)
 {
     if (os_vista)
        font_vista_ok = 1;
index e1bf8f52e69af09a18d6f81179982afd22ca8c17..14b3674170e2bcd8af040f009d9c00c1efc7b964 100644 (file)
@@ -25,7 +25,7 @@
                        ConfigurationType="1"
                        UseOfMFC="0"
                        ATLMinimizesCRunTimeLibraryUsage="false"
-                       CharacterSet="2"
+                       CharacterSet="1"
                        >
                        <Tool
                                Name="VCPreBuildEventTool"
@@ -52,7 +52,7 @@
                                AdditionalOptions=""
                                Optimization="0"
                                AdditionalIncludeDirectories="..\..\include,..\..,..\,..\resources,..\osdep,..\sounddep,..\..\prowizard\include,..\tun"
-                               PreprocessorDefinitions="WINVER=0x0500,_DEBUG,WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS"
+                               PreprocessorDefinitions="WINVER=0x0500,_DEBUG,WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS;_CRT_SECURE_NO_WARNINGS"
                                GeneratePreprocessedFile="0"
                                KeepComments="false"
                                ExceptionHandling="0"
                        ConfigurationType="1"
                        UseOfMFC="0"
                        ATLMinimizesCRunTimeLibraryUsage="false"
-                       CharacterSet="2"
+                       CharacterSet="1"
                        >
                        <Tool
                                Name="VCPreBuildEventTool"
                        ConfigurationType="1"
                        UseOfMFC="0"
                        ATLMinimizesCRunTimeLibraryUsage="false"
-                       CharacterSet="2"
+                       CharacterSet="1"
                        WholeProgramOptimization="1"
                        >
                        <Tool
                                OmitFramePointers="true"
                                WholeProgramOptimization="true"
                                AdditionalIncludeDirectories="..\..\include,..\..,..\,..\resources,..\osdep,..\sounddep,..\..\prowizard\include"
-                               PreprocessorDefinitions="WINVER=0x0500;NDEBUG;_WIN32_IE=0x0501;WIN32;CINTERFACE;COBJMACROS"
+                               PreprocessorDefinitions="WINVER=0x0500;NDEBUG;_WIN32_IE=0x0700;WIN32;CINTERFACE;COBJMACROS"
                                StringPooling="true"
                                ExceptionHandling="0"
                                BasicRuntimeChecks="0"
                                RelativePath="..\sounddep\sound.c"
                                >
                        </File>
+                       <File
+                               RelativePath="..\unicode.c"
+                               >
+                       </File>
                        <File
                                RelativePath="..\win32.c"
                                >
index 38faa88893b9607e0604984d3254c32738a80714..54f6d6c0bd88eb6342a537ee210fd90a7c5e8848 100644 (file)
@@ -1,4 +1,41 @@
 
+Beta 15:
+
+- WinUAE is now native unicode application (internally all strings are
+  NT native UTF16-LE format instead of 8-bit "ANSI")
+  What does this mean?
+  - lots of breakage possible, size of one byte = size of one character
+  isn't true anymore and finding all cases is difficult. Report all
+  mysterious crashes (they are usually easily duplicated)
+  - Windows<>Amiga directory filesystem character set conversion can
+  be configured (Windows "code page" may not match Amiga charset =
+  "special" characters should work better now. Default is CP 1252 which
+  is functionally identical to Amiga standard ISO-8859-1)
+  - logs and configuration.cache are UTF-8 formatted (UTF-8 is more
+  human readable than UTF-16), "old" charset supported
+  - log window supports unicode now, no more weird characters in
+  (for example) device names containing national characters
+  - configuration files are still in old format (would cause too many
+  problems with old versions and front ends..)
+  - I simply wanted to do this when I dropped 98/ME support but I wasn't
+  ready until now. (also most new Vista+ APIs are unicode only,
+  converting between ansi<>unicode was getting too annoying)
+
+- ACTION_EXAMINE_ALL was quite broken, it always returned full directory
+  entry data (wrong variable used..) Most (all) programs didn't care.
+- "not implemented error" filesystem warning is now shown to user
+  (nobody apparently noticed it in the log = I can never fix it..)
+- directory filesystem >2G files are shown as 2G minus 1 byte (instead
+  of truncating to 32-bit and showing negative or other random sizes),
+  >4G files internally supported
+- directory filesystem ACTION_CHANGE_FILE_POSITION64,
+  ACTION_GET_FILE_POSITION64, ACTION_CHANGE_FILE_SIZE64 and
+  ACTION_GET_FILE_SIZE64 implemented (OS4+ packets but also supported
+  by 68k SFS2)
+- ignore all input events (except activation events or if mousehack
+  is enabled) if no focus and not active (previously only focus was
+  required)
+
 Beta 14:
 
 - filter out PortAudio DS and MME drivers (useless duplication only)
index 806e152dfd131d43b0636142cabe59f545809f09..597227d1a68b80a6b3bb2ffab885fdedbe853d49 100644 (file)
@@ -38,7 +38,7 @@ static HWND myGetConsoleWindow (void)
     GETCONSOLEWINDOW pGetConsoleWindow;
     /* Windows 2000 or newer only */
     pGetConsoleWindow = (GETCONSOLEWINDOW)GetProcAddress (
-       GetModuleHandle ("kernel32.dll"), "GetConsoleWindow");
+       GetModuleHandle (L"kernel32.dll"), "GetConsoleWindow");
     if (pGetConsoleWindow)
        return pGetConsoleWindow ();
     return NULL;
@@ -49,7 +49,9 @@ static void open_console_window (void)
     AllocConsole();
     stdinput = GetStdHandle (STD_INPUT_HANDLE);
     stdoutput = GetStdHandle (STD_OUTPUT_HANDLE);
-    SetConsoleMode (stdinput,ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_PROCESSED_OUTPUT);
+    SetConsoleMode (stdinput, ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_PROCESSED_OUTPUT);
+    SetConsoleCP (65001);
+    SetConsoleOutputCP (65001);
     consoleopen = -1;
     reopen_console ();
 }
@@ -60,7 +62,7 @@ static void openconsole( void)
        if (consoleopen > 0 || debuggerinitializing)
            return;
        if (debugger_type < 0) {
-           regqueryint (NULL, "DebuggerType", &debugger_type);
+           regqueryint (NULL, L"DebuggerType", &debugger_type);
            if (debugger_type <= 0)
                debugger_type = 2;
            openconsole();
@@ -88,7 +90,7 @@ void debugger_change (int mode)
        debugger_type = mode;
     if (debugger_type != 1 && debugger_type != 2)
        debugger_type = 2;
-    regsetint (NULL, "DebuggerType", debugger_type);
+    regsetint (NULL, L"DebuggerType", debugger_type);
     openconsole ();
 }
 
@@ -102,13 +104,13 @@ void reopen_console (void)
     if (hwnd) {
        int newpos = 1;
        LONG x, y, w, h;
-       if (!regqueryint (NULL, "LoggerPosX", &x))
+       if (!regqueryint (NULL, L"LoggerPosX", &x))
            newpos = 0;
-       if (!regqueryint (NULL, "LoggerPosY", &y))
+       if (!regqueryint (NULL, L"LoggerPosY", &y))
            newpos = 0;
-       if (!regqueryint (NULL, "LoggerPosW", &w))
+       if (!regqueryint (NULL, L"LoggerPosW", &w))
            newpos = 0;
-       if (!regqueryint (NULL, "LoggerPosH", &h))
+       if (!regqueryint (NULL, L"LoggerPosH", &h))
            newpos = 0;
        if (newpos) {
            RECT rc;
@@ -136,10 +138,10 @@ void close_console (void)
            if (GetWindowRect (hwnd, &r)) {
                r.bottom -= r.top;
                r.right -= r.left;
-               regsetint (NULL, "LoggerPosX", r.left);
-               regsetint (NULL, "LoggerPosY", r.top);
-               regsetint (NULL, "LoggerPosW", r.right);
-               regsetint (NULL, "LoggerPosH", r.bottom);
+               regsetint (NULL, L"LoggerPosX", r.left);
+               regsetint (NULL, L"LoggerPosY", r.top);
+               regsetint (NULL, L"LoggerPosW", r.right);
+               regsetint (NULL, L"LoggerPosH", r.bottom);
            }
        }
        FreeConsole ();
@@ -147,35 +149,35 @@ void close_console (void)
     consoleopen = 0;
 }
 
-static void writeconsole (const char *buffer)
+static void writeconsole (const TCHAR *buffer)
 {
     DWORD temp;
     if (!consoleopen)
        openconsole();
     if (consoleopen > 0)
-       WriteOutput (buffer, strlen(buffer));
+       WriteOutput (buffer, _tcslen(buffer));
     else if (consoleopen < 0)
-       WriteConsole (stdoutput, buffer, strlen (buffer), &temp,0);
+       WriteConsole (stdoutput, buffer, _tcslen (buffer), &temp,0);
 }
 
-void console_out_f (const char *format,...)
+void console_out_f (const TCHAR *format,...)
 {
     va_list parms;
-    char buffer[WRITE_LOG_BUF_SIZE];
+    TCHAR buffer[WRITE_LOG_BUF_SIZE];
 
     va_start (parms, format);
-    _vsnprintf (buffer, WRITE_LOG_BUF_SIZE-1, format, parms);
+    _vsntprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
     va_end (parms);
     openconsole ();
     writeconsole (buffer);
 }
-void console_out (const char *txt)
+void console_out (const TCHAR *txt)
 {
     openconsole ();
     writeconsole (txt);
 }
 
-int console_get (char *out, int maxlen)
+int console_get (TCHAR *out, int maxlen)
 {
     *out = 0;
     if (consoleopen > 0) {
@@ -206,43 +208,43 @@ void console_flush (void)
 
 static int lfdetected = 1;
 
-static char *writets (void)
+static TCHAR *writets (void)
 {
     struct tm *t;
     struct _timeb tb;
-    static char out[100];
-    char *p;
-    static char lastts[100];
-    char curts[100];
+    static TCHAR out[100];
+    TCHAR *p;
+    static TCHAR lastts[100];
+    TCHAR curts[100];
 
     if (bootlogmode)
        return NULL;
     _ftime(&tb);
     t = localtime (&tb.time);
-    strftime (curts, sizeof curts, "%Y-%m-%d %H:%M:%S\n", t);
+    _tcsftime (curts, sizeof curts / sizeof (TCHAR), L"%Y-%m-%d %H:%M:%S\n", t);
     p = out;
     *p = 0;
-    if (memcmp (curts, lastts, strlen (curts))) {
-       strcat (p, curts);
-       p += strlen (p);
-       strcpy (lastts, curts);
+    if (!_tcsncmp (curts, lastts, _tcslen (curts))) {
+       _tcscat (p, curts);
+       p += _tcslen (p);
+       _tcscpy (lastts, curts);
     }
-    strftime (p, sizeof out - (p - out) , "%S-", t);
-    p += strlen (p);
-    sprintf (p, "%03d", tb.millitm);
-    p += strlen (p);
+    _tcsftime (p, sizeof out / sizeof (TCHAR) - (p - out) , L"%S-", t);
+    p += _tcslen (p);
+    _stprintf (p, L"%03d", tb.millitm);
+    p += _tcslen (p);
     if (timeframes || vpos > 0 && current_hpos () > 0)
-       sprintf (p, " [%d %03dx%03d]", timeframes, current_hpos (), vpos);
-    strcat (p, ": ");
+       _stprintf (p, L" [%d %03dx%03d]", timeframes, current_hpos (), vpos);
+    _tcscat (p, L": ");
     return out;
 }
 
 
-void write_dlog (const char *format, ...)
+void write_dlog (const TCHAR *format, ...)
 {
     int count;
-    char buffer[WRITE_LOG_BUF_SIZE];
-    char *ts;
+    TCHAR buffer[WRITE_LOG_BUF_SIZE];
+    TCHAR *ts;
     va_list parms;
 
     if (!SHOW_CONSOLE && !console_logging && !debugfile)
@@ -250,7 +252,7 @@ void write_dlog (const char *format, ...)
 
     EnterCriticalSection (&cs);
     va_start (parms, format);
-    count = _vsnprintf(buffer, WRITE_LOG_BUF_SIZE-1, format, parms);
+    count = _vsntprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
     ts = writets ();
     if (SHOW_CONSOLE || console_logging) {
        if (lfdetected && ts)
@@ -259,29 +261,29 @@ void write_dlog (const char *format, ...)
     }
     if (debugfile) {
        if (lfdetected && ts)
-           fprintf (debugfile, ts);
-       fprintf (debugfile, buffer);
+           _ftprintf (debugfile, ts);
+       _ftprintf (debugfile, buffer);
     }
     lfdetected = 0;
-    if (strlen (buffer) > 0 && buffer[strlen(buffer) - 1] == '\n')
+    if (_tcslen (buffer) > 0 && buffer[_tcslen(buffer) - 1] == '\n')
        lfdetected = 1;
     va_end (parms);
     LeaveCriticalSection (&cs);
 }
 
-void write_log (const char *format, ...)
+void write_log (const TCHAR *format, ...)
 {
     int count;
-    char buffer[WRITE_LOG_BUF_SIZE], *ts;
+    TCHAR buffer[WRITE_LOG_BUF_SIZE], *ts;
     int bufsize = WRITE_LOG_BUF_SIZE;
-    char *bufp;
+    TCHAR *bufp;
     va_list parms;
 
-    EnterCriticalSection(&cs);
+    EnterCriticalSection (&cs);
     va_start(parms, format);
     bufp = buffer;
     for (;;) {
-       count = _vsnprintf(bufp, bufsize - 1, format, parms);
+       count = _vsntprintf (bufp, bufsize - 1, format, parms);
        if (count < 0) {
            bufsize *= 10;
            if (bufp != buffer)
@@ -292,7 +294,7 @@ void write_log (const char *format, ...)
        break;
     }
     bufp[bufsize - 1] = 0;
-    if (!memcmp (bufp, "write ",6))
+    if (!_tcsncmp (bufp, L"write ", 6))
        bufsize--;
     ts = writets ();
     if (bufp[0] == '*')
@@ -304,18 +306,18 @@ void write_log (const char *format, ...)
     }
     if (debugfile) {
        if (lfdetected && ts)
-           fprintf (debugfile, ts);
-       fprintf (debugfile, bufp);
+           _ftprintf (debugfile, ts);
+       _ftprintf (debugfile, bufp);
     }
     lfdetected = 0;
-    if (strlen (bufp) > 0 && bufp[strlen(bufp) - 1] == '\n')
+    if (_tcslen (bufp) > 0 && bufp[_tcslen(bufp) - 1] == '\n')
        lfdetected = 1;
     va_end (parms);
     if (bufp != buffer)
        xfree (bufp);
     if (always_flush_log)
        flush_log ();
-    LeaveCriticalSection(&cs);
+    LeaveCriticalSection (&cs);
 }
 
 void flush_log (void)
@@ -324,22 +326,22 @@ void flush_log (void)
        fflush (debugfile);
 }
 
-void f_out (void *f, const char *format, ...)
+void f_out (void *f, const TCHAR *format, ...)
 {
     int count;
-    char buffer[WRITE_LOG_BUF_SIZE];
+    TCHAR buffer[WRITE_LOG_BUF_SIZE];
     va_list parms;
     va_start (parms, format);
 
     if (f == NULL)
        return;
-    count = _vsnprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
+    count = _vsntprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
     openconsole ();
     writeconsole (buffer);
     va_end (parms);
 }
 
-char* buf_out (char *buffer, int *bufsize, const char *format, ...)
+TCHAR* buf_out (TCHAR *buffer, int *bufsize, const TCHAR *format, ...)
 {
     int count;
     va_list parms;
@@ -347,17 +349,17 @@ char* buf_out (char *buffer, int *bufsize, const char *format, ...)
 
     if (buffer == NULL)
        return 0;
-    count = _vsnprintf (buffer, (*bufsize)-1, format, parms);
+    count = _vsntprintf (buffer, (*bufsize)-1, format, parms);
     va_end (parms);
-    *bufsize -= strlen (buffer);
-    return buffer + strlen (buffer);
+    *bufsize -= _tcslen (buffer);
+    return buffer + _tcslen (buffer);
 }
 
-void *log_open (const char *name, int append, int bootlog)
+void *log_open (const TCHAR *name, int append, int bootlog)
 {
     FILE *f;
 
-    f = fopen (name, append ? "a" : "wt");
+    f = _tfopen (name, append ? L"a, ccs=UTF-8" : L"wt, ccs=UTF-8");
     bootlogmode = bootlog;
     if (!cs_init)
        InitializeCriticalSection (&cs);
@@ -370,19 +372,19 @@ void log_close (void *f)
     fclose (f);
 }
 
-void jit_abort (const char *format,...)
+void jit_abort (const TCHAR *format,...)
 {
     static int happened;
     int count;
-    char buffer[WRITE_LOG_BUF_SIZE];
+    TCHAR buffer[WRITE_LOG_BUF_SIZE];
     va_list parms;
     va_start (parms, format);
 
-    count = _vsnprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
+    count = _vsntprintf (buffer, WRITE_LOG_BUF_SIZE - 1, format, parms);
     writeconsole (buffer);
     va_end (parms);
     if (!happened)
-       gui_message ("JIT: Serious error:\n%s", buffer);
+       gui_message (L"JIT: Serious error:\n%s", buffer);
     happened = 1;
     uae_reset (1);
 }
index 5fa94af631bda8c620a1a121db917155c43592df..a562ff1fe689a041e5905b346bc83105446d4280 100644 (file)
--- a/readcpu.c
+++ b/readcpu.c
 int nr_cpuop_funcs;
 
 struct mnemolookup lookuptab[] = {
-    { i_ILLG, "ILLEGAL" },
-    { i_OR, "OR" },
-    { i_CHK, "CHK" },
-    { i_CHK2, "CHK2" },
-    { i_AND, "AND" },
-    { i_EOR, "EOR" },
-    { i_ORSR, "ORSR" },
-    { i_ANDSR, "ANDSR" },
-    { i_EORSR, "EORSR" },
-    { i_SUB, "SUB" },
-    { i_SUBA, "SUBA" },
-    { i_SUBX, "SUBX" },
-    { i_SBCD, "SBCD" },
-    { i_ADD, "ADD" },
-    { i_ADDA, "ADDA" },
-    { i_ADDX, "ADDX" },
-    { i_ABCD, "ABCD" },
-    { i_NEG, "NEG" },
-    { i_NEGX, "NEGX" },
-    { i_NBCD, "NBCD" },
-    { i_CLR, "CLR" },
-    { i_NOT, "NOT" },
-    { i_TST, "TST" },
-    { i_BTST, "BTST" },
-    { i_BCHG, "BCHG" },
-    { i_BCLR, "BCLR" },
-    { i_BSET, "BSET" },
-    { i_CMP, "CMP" },
-    { i_CMPM, "CMPM" },
-    { i_CMPA, "CMPA" },
-    { i_MVPRM, "MVPRM" },
-    { i_MVPMR, "MVPMR" },
-    { i_MOVE, "MOVE" },
-    { i_MOVEA, "MOVEA" },
-    { i_MVSR2, "MVSR2" },
-    { i_MV2SR, "MV2SR" },
-    { i_SWAP, "SWAP" },
-    { i_EXG, "EXG" },
-    { i_EXT, "EXT" },
-    { i_MVMEL, "MVMEL", "MOVEM" },
-    { i_MVMLE, "MVMLE", "MOVEM" },
-    { i_TRAP, "TRAP" },
-    { i_MVR2USP, "MVR2USP" },
-    { i_MVUSP2R, "MVUSP2R" },
-    { i_NOP, "NOP" },
-    { i_RESET, "RESET" },
-    { i_RTE, "RTE" },
-    { i_RTD, "RTD" },
-    { i_LINK, "LINK" },
-    { i_UNLK, "UNLK" },
-    { i_RTS, "RTS" },
-    { i_STOP, "STOP" },
-    { i_TRAPV, "TRAPV" },
-    { i_RTR, "RTR" },
-    { i_JSR, "JSR" },
-    { i_JMP, "JMP" },
-    { i_BSR, "BSR" },
-    { i_Bcc, "Bcc" },
-    { i_LEA, "LEA" },
-    { i_PEA, "PEA" },
-    { i_DBcc, "DBcc" },
-    { i_Scc, "Scc" },
-    { i_DIVU, "DIVU" },
-    { i_DIVS, "DIVS" },
-    { i_MULU, "MULU" },
-    { i_MULS, "MULS" },
-    { i_ASR, "ASR" },
-    { i_ASL, "ASL" },
-    { i_LSR, "LSR" },
-    { i_LSL, "LSL" },
-    { i_ROL, "ROL" },
-    { i_ROR, "ROR" },
-    { i_ROXL, "ROXL" },
-    { i_ROXR, "ROXR" },
-    { i_ASRW, "ASRW" },
-    { i_ASLW, "ASLW" },
-    { i_LSRW, "LSRW" },
-    { i_LSLW, "LSLW" },
-    { i_ROLW, "ROLW" },
-    { i_RORW, "RORW" },
-    { i_ROXLW, "ROXLW" },
-    { i_ROXRW, "ROXRW" },
-
-    { i_MOVE2C, "MOVE2C", "MOVEC" },
-    { i_MOVEC2, "MOVEC2", "MOVEC" },
-    { i_CAS, "CAS" },
-    { i_CAS2, "CAS2" },
-    { i_MULL, "MULL" },
-    { i_DIVL, "DIVL" },
-    { i_BFTST, "BFTST" },
-    { i_BFEXTU, "BFEXTU" },
-    { i_BFCHG, "BFCHG" },
-    { i_BFEXTS, "BFEXTS" },
-    { i_BFCLR, "BFCLR" },
-    { i_BFFFO, "BFFFO" },
-    { i_BFSET, "BFSET" },
-    { i_BFINS, "BFINS" },
-    { i_PACK, "PACK" },
-    { i_UNPK, "UNPK" },
-    { i_TAS, "TAS" },
-    { i_BKPT, "BKPT" },
-    { i_CALLM, "CALLM" },
-    { i_RTM, "RTM" },
-    { i_TRAPcc, "TRAPcc" },
-    { i_MOVES, "MOVES" },
-    { i_FPP, "FPP" },
-    { i_FDBcc, "FDBcc" },
-    { i_FScc, "FScc" },
-    { i_FTRAPcc, "FTRAPcc" },
-    { i_FBcc, "FBcc" },
-    { i_FBcc, "FBcc" },
-    { i_FSAVE, "FSAVE" },
-    { i_FRESTORE, "FRESTORE" },
-
-    { i_CINVL, "CINVL" },
-    { i_CINVP, "CINVP" },
-    { i_CINVA, "CINVA" },
-    { i_CPUSHL, "CPUSHL" },
-    { i_CPUSHP, "CPUSHP" },
-    { i_CPUSHA, "CPUSHA" },
-    { i_MOVE16, "MOVE16" },
-
-    { i_MMUOP030, "MMUOP030" },
-    { i_PFLUSHN, "PFLUSHN" },
-    { i_PFLUSH, "PFLUSH" },
-    { i_PFLUSHAN, "PFLUSHAN" },
-    { i_PFLUSHA, "PFLUSHA" },
-
-    { i_PLPAR, "PLPAR" },
-    { i_PLPAW, "PLPAW" },
-    { i_PTESTR, "PTESTR" },
-    { i_PTESTW, "PTESTW" },
-
-    { i_LPSTOP, "LPSTOP" },
-    { i_ILLG, "" },
+    { i_ILLG, L"ILLEGAL" },
+    { i_OR, L"OR" },
+    { i_CHK, L"CHK" },
+    { i_CHK2, L"CHK2" },
+    { i_AND, L"AND" },
+    { i_EOR, L"EOR" },
+    { i_ORSR, L"ORSR" },
+    { i_ANDSR, L"ANDSR" },
+    { i_EORSR, L"EORSR" },
+    { i_SUB, L"SUB" },
+    { i_SUBA, L"SUBA" },
+    { i_SUBX, L"SUBX" },
+    { i_SBCD, L"SBCD" },
+    { i_ADD, L"ADD" },
+    { i_ADDA, L"ADDA" },
+    { i_ADDX, L"ADDX" },
+    { i_ABCD, L"ABCD" },
+    { i_NEG, L"NEG" },
+    { i_NEGX, L"NEGX" },
+    { i_NBCD, L"NBCD" },
+    { i_CLR, L"CLR" },
+    { i_NOT, L"NOT" },
+    { i_TST, L"TST" },
+    { i_BTST, L"BTST" },
+    { i_BCHG, L"BCHG" },
+    { i_BCLR, L"BCLR" },
+    { i_BSET, L"BSET" },
+    { i_CMP, L"CMP" },
+    { i_CMPM, L"CMPM" },
+    { i_CMPA, L"CMPA" },
+    { i_MVPRM, L"MVPRM" },
+    { i_MVPMR, L"MVPMR" },
+    { i_MOVE, L"MOVE" },
+    { i_MOVEA, L"MOVEA" },
+    { i_MVSR2, L"MVSR2" },
+    { i_MV2SR, L"MV2SR" },
+    { i_SWAP, L"SWAP" },
+    { i_EXG, L"EXG" },
+    { i_EXT, L"EXT" },
+    { i_MVMEL, L"MVMEL", L"MOVEM" },
+    { i_MVMLE, L"MVMLE", L"MOVEM" },
+    { i_TRAP, L"TRAP" },
+    { i_MVR2USP, L"MVR2USP" },
+    { i_MVUSP2R, L"MVUSP2R" },
+    { i_NOP, L"NOP" },
+    { i_RESET, L"RESET" },
+    { i_RTE, L"RTE" },
+    { i_RTD, L"RTD" },
+    { i_LINK, L"LINK" },
+    { i_UNLK, L"UNLK" },
+    { i_RTS, L"RTS" },
+    { i_STOP, L"STOP" },
+    { i_TRAPV, L"TRAPV" },
+    { i_RTR, L"RTR" },
+    { i_JSR, L"JSR" },
+    { i_JMP, L"JMP" },
+    { i_BSR, L"BSR" },
+    { i_Bcc, L"Bcc" },
+    { i_LEA, L"LEA" },
+    { i_PEA, L"PEA" },
+    { i_DBcc, L"DBcc" },
+    { i_Scc, L"Scc" },
+    { i_DIVU, L"DIVU" },
+    { i_DIVS, L"DIVS" },
+    { i_MULU, L"MULU" },
+    { i_MULS, L"MULS" },
+    { i_ASR, L"ASR" },
+    { i_ASL, L"ASL" },
+    { i_LSR, L"LSR" },
+    { i_LSL, L"LSL" },
+    { i_ROL, L"ROL" },
+    { i_ROR, L"ROR" },
+    { i_ROXL, L"ROXL" },
+    { i_ROXR, L"ROXR" },
+    { i_ASRW, L"ASRW" },
+    { i_ASLW, L"ASLW" },
+    { i_LSRW, L"LSRW" },
+    { i_LSLW, L"LSLW" },
+    { i_ROLW, L"ROLW" },
+    { i_RORW, L"RORW" },
+    { i_ROXLW, L"ROXLW" },
+    { i_ROXRW, L"ROXRW" },
+
+    { i_MOVE2C, L"MOVE2C", L"MOVEC" },
+    { i_MOVEC2, L"MOVEC2", L"MOVEC" },
+    { i_CAS, L"CAS" },
+    { i_CAS2, L"CAS2" },
+    { i_MULL, L"MULL" },
+    { i_DIVL, L"DIVL" },
+    { i_BFTST, L"BFTST" },
+    { i_BFEXTU, L"BFEXTU" },
+    { i_BFCHG, L"BFCHG" },
+    { i_BFEXTS, L"BFEXTS" },
+    { i_BFCLR, L"BFCLR" },
+    { i_BFFFO, L"BFFFO" },
+    { i_BFSET, L"BFSET" },
+    { i_BFINS, L"BFINS" },
+    { i_PACK, L"PACK" },
+    { i_UNPK, L"UNPK" },
+    { i_TAS, L"TAS" },
+    { i_BKPT, L"BKPT" },
+    { i_CALLM, L"CALLM" },
+    { i_RTM, L"RTM" },
+    { i_TRAPcc, L"TRAPcc" },
+    { i_MOVES, L"MOVES" },
+    { i_FPP, L"FPP" },
+    { i_FDBcc, L"FDBcc" },
+    { i_FScc, L"FScc" },
+    { i_FTRAPcc, L"FTRAPcc" },
+    { i_FBcc, L"FBcc" },
+    { i_FBcc, L"FBcc" },
+    { i_FSAVE, L"FSAVE" },
+    { i_FRESTORE, L"FRESTORE" },
+
+    { i_CINVL, L"CINVL" },
+    { i_CINVP, L"CINVP" },
+    { i_CINVA, L"CINVA" },
+    { i_CPUSHL, L"CPUSHL" },
+    { i_CPUSHP, L"CPUSHP" },
+    { i_CPUSHA, L"CPUSHA" },
+    { i_MOVE16, L"MOVE16" },
+
+    { i_MMUOP030, L"MMUOP030" },
+    { i_PFLUSHN, L"PFLUSHN" },
+    { i_PFLUSH, L"PFLUSH" },
+    { i_PFLUSHAN, L"PFLUSHAN" },
+    { i_PFLUSHA, L"PFLUSHA" },
+
+    { i_PLPAR, L"PLPAR" },
+    { i_PLPAW, L"PLPAW" },
+    { i_PTESTR, L"PTESTR" },
+    { i_PTESTW, L"PTESTW" },
+
+    { i_LPSTOP, L"LPSTOP" },
+    { i_ILLG, L"" },
 };
 
 struct instr *table68k;
@@ -176,20 +176,20 @@ static int specialcase (uae_u16 opcode, int cpu_lev)
     return cpu_lev;
 }
 
-static amodes mode_from_str (const char *str)
+static amodes mode_from_str (const TCHAR *str)
 {
-    if (strncmp (str, "Dreg", 4) == 0) return Dreg;
-    if (strncmp (str, "Areg", 4) == 0) return Areg;
-    if (strncmp (str, "Aind", 4) == 0) return Aind;
-    if (strncmp (str, "Apdi", 4) == 0) return Apdi;
-    if (strncmp (str, "Aipi", 4) == 0) return Aipi;
-    if (strncmp (str, "Ad16", 4) == 0) return Ad16;
-    if (strncmp (str, "Ad8r", 4) == 0) return Ad8r;
-    if (strncmp (str, "absw", 4) == 0) return absw;
-    if (strncmp (str, "absl", 4) == 0) return absl;
-    if (strncmp (str, "PC16", 4) == 0) return PC16;
-    if (strncmp (str, "PC8r", 4) == 0) return PC8r;
-    if (strncmp (str, "Immd", 4) == 0) return imm;
+    if (_tcsncmp (str, L"Dreg", 4) == 0) return Dreg;
+    if (_tcsncmp (str, L"Areg", 4) == 0) return Areg;
+    if (_tcsncmp (str, L"Aind", 4) == 0) return Aind;
+    if (_tcsncmp (str, L"Apdi", 4) == 0) return Apdi;
+    if (_tcsncmp (str, L"Aipi", 4) == 0) return Aipi;
+    if (_tcsncmp (str, L"Ad16", 4) == 0) return Ad16;
+    if (_tcsncmp (str, L"Ad8r", 4) == 0) return Ad8r;
+    if (_tcsncmp (str, L"absw", 4) == 0) return absw;
+    if (_tcsncmp (str, L"absl", 4) == 0) return absl;
+    if (_tcsncmp (str, L"PC16", 4) == 0) return PC16;
+    if (_tcsncmp (str, L"PC8r", 4) == 0) return PC8r;
+    if (_tcsncmp (str, L"Immd", 4) == 0) return imm;
     abort ();
     return 0;
 }
@@ -226,7 +226,7 @@ static void build_insn (int insn)
     int variants;
     int isjmp = 0;
     struct instr_def id;
-    const char *opcstr;
+    const TCHAR *opcstr;
     int i;
 
     int flaglive = 0, flagdead = 0;
@@ -274,7 +274,7 @@ static void build_insn (int insn)
        int pos = 0;
        int mnp = 0;
        int bitno = 0;
-       char mnemonic[10];
+       TCHAR mnemonic[10];
 
        wordsizes sz = sz_long;
        int srcgather = 0, dstgather = 0;
@@ -320,7 +320,7 @@ static void build_insn (int insn)
            bitval[bitc] = bitval[bitC];
 
        pos = 0;
-       while (opcstr[pos] && !isspace(opcstr[pos])) {
+       while (opcstr[pos] && !_istspace(opcstr[pos])) {
            if (opcstr[pos] == '.') {
                pos++;
                switch (opcstr[pos]) {
@@ -355,7 +355,7 @@ static void build_insn (int insn)
        mnemonic[mnp] = 0;
 
        /* now, we have read the mnemonic and the size */
-       while (opcstr[pos] && isspace(opcstr[pos]))
+       while (opcstr[pos] && _istspace(opcstr[pos]))
            pos++;
 
        /* A goto a day keeps the D******a away. */
@@ -718,14 +718,14 @@ static void build_insn (int insn)
       endofline:
        /* now, we have a match */
        if (table68k[opc].mnemo != i_ILLG)
-           ;//write_log ("Double match: %x: %s\n", opc, opcstr);
+           ;//write_log (L"Double match: %x: %s\n", opc, opcstr);
        if (find == -1) {
            for (find = 0;; find++) {
-               if (strcmp(mnemonic, lookuptab[find].name) == 0) {
+               if (_tcscmp (mnemonic, lookuptab[find].name) == 0) {
                    table68k[opc].mnemo = lookuptab[find].mnemo;
                    break;
                }
-               if (strlen(lookuptab[find].name) == 0)
+               if (_tcslen (lookuptab[find].name) == 0)
                    abort();
            }
        }
diff --git a/sana2.c b/sana2.c
index b84a9da3b7d83f56c06733d6109478f2fae9d02c..5292470f6603baaefa8fccf97836da6df8a2d47d 100644 (file)
--- a/sana2.c
+++ b/sana2.c
@@ -28,7 +28,7 @@
 #include "win32_uaenet.h"
 #include "execio.h"
 
-#define SANA2NAME "uaenet.device"
+#define SANA2NAME L"uaenet.device"
 
 #define MAX_ASYNC_REQUESTS 200
 #define MAX_OPEN_DEVICES 20
@@ -149,9 +149,9 @@ static uaecptr ROM_netdev_resname = 0,
     ROM_netdev_resid = 0,
     ROM_netdev_init = 0;
 
-static char *getdevname (void)
+static TCHAR *getdevname (void)
 {
-    return "uaenet.device";
+    return L"uaenet.device";
 }
 
 struct asyncreq {
@@ -245,7 +245,7 @@ static struct priv_devstruct *getpdevstruct (uaecptr request)
 {
     int i = get_long (request + 24);
     if (i < 0 || i >= MAX_OPEN_DEVICES || pdevst[i].inuse == 0) {
-       write_log ("%s: corrupt iorequest %08X %d\n", SANA2NAME, request, i);
+       write_log (L"%s: corrupt iorequest %08X %d\n", SANA2NAME, request, i);
        return 0;
     }
     return &pdevst[i];
@@ -270,16 +270,16 @@ static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context)
     struct devstruct *dev;
 
     if (!pdev) {
-       write_log ("%s close with unknown request %08X!?\n", SANA2NAME, request);
+       write_log (L"%s close with unknown request %08X!?\n", SANA2NAME, request);
        return 0;
     }
     dev = getdevstruct (pdev->unit);
     if (!dev) {
-       write_log ("%s:%d close with unknown request %08X!?\n", SANA2NAME, pdev->unit, request);
+       write_log (L"%s:%d close with unknown request %08X!?\n", SANA2NAME, pdev->unit, request);
        return 0;
     }
     if (log_net)
-       write_log ("%s:%d close, open=%d req=%08X\n", SANA2NAME, pdev->unit, dev->opencnt, request);
+       write_log (L"%s:%d close, open=%d req=%08X\n", SANA2NAME, pdev->unit, dev->opencnt, request);
     put_long (request + 24, 0);
     dev->opencnt--;
     pdev->inuse = 0;
@@ -295,7 +295,7 @@ static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context)
        xfree (dev->sysdata);
        dev->sysdata = NULL;
        write_comm_pipe_u32 (&dev->requests, 0, 1);
-        write_log ("%s: opencnt == 0, all instances closed\n", SANA2NAME);
+        write_log (L"%s: opencnt == 0, all instances closed\n", SANA2NAME);
     }
     put_word (m68k_areg (&context->regs, 6) + 32, get_word (m68k_areg (&context->regs, 6) + 32) - 1);
     return 0;
@@ -316,7 +316,7 @@ static int openfail (uaecptr ioreq, int error)
     put_byte (ioreq + 31, error);
     put_long (ioreq + 32, 0); /* io_device */
     if (log_net)
-       write_log("-> failed with error %d\n", error);
+       write_log (L"-> failed with error %d\n", error);
     return (uae_u32)-1;
 }
 
@@ -335,7 +335,7 @@ static int initint (TrapContext *ctx)
     if (!p)
        return 0;
     tmp1 = here ();
-    calltrap (deftrap2 (uaenet_int_handler, TRAPFLAG_EXTRA_STACK, "uaenet_int_handler"));
+    calltrap (deftrap2 (uaenet_int_handler, TRAPFLAG_EXTRA_STACK, L"uaenet_int_handler"));
     put_word (p + 8, 0x020a);
     put_long (p + 10, ROM_netdev_resid);
     put_long (p + 18, tmp1);
@@ -364,7 +364,7 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context)
     if (!initint(context))
        return openfail (ioreq, IOERR_SELFTEST);
     if (log_net)
-       write_log ("opening %s:%d opencnt=%d ioreq=%08X\n", SANA2NAME, unit, dev->opencnt, ioreq);
+       write_log (L"opening %s:%d opencnt=%d ioreq=%08X\n", SANA2NAME, unit, dev->opencnt, ioreq);
     if (get_word (ioreq + 0x12) < IOSTDREQ_SIZE)
        return openfail (ioreq, IOERR_BADLENGTH);
     if ((flags & SANA2OPF_PROM) && dev->opencnt > 0)
@@ -396,7 +396,7 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context)
            dev->sysdata = NULL;
            return openfail (ioreq, IOERR_OPENFAIL);
        }
-       write_log ("%s: initializing unit %d\n", getdevname (), unit);
+       write_log (L"%s: initializing unit %d\n", getdevname (), unit);
        dev->td = pdev->td;
        dev->adapter = pdev->td->active;
        if (dev->adapter) {
@@ -448,7 +448,7 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context)
            }
        }
        if (log_net)
-           write_log("%s:%d CTB=%08x CFB=%08x PF=%08x\n",
+           write_log (L"%s:%d CTB=%08x CFB=%08x PF=%08x\n",
                getdevname(), unit, pdev->copytobuff, pdev->copyfrombuff, pdev->packetfilter);
        m68k_dreg (&context->regs, 0) = dev->td->mtu + ETH_HEADER_SIZE + 2;
        m68k_dreg (&context->regs, 1) = 1;
@@ -556,7 +556,7 @@ static int add_async_request (struct devstruct *dev, uaecptr request)
     struct asyncreq *ar, *ar2;
 
     if (log_net)
-       write_log ("%s:%d async request %x added\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d async request %x added\n", getdevname(), dev->unit, request);
 
     uae_sem_wait (&async_sem);
     ar = (struct asyncreq*)xcalloc (sizeof (struct asyncreq), 1);
@@ -589,14 +589,14 @@ static int release_async_request (struct devstruct *dev, uaecptr request)
            uae_sem_post (&async_sem);
            xfree (ar);
            if (log_net)
-               write_log ("%s:%d async request %x removed\n", getdevname(), dev->unit, request);
+               write_log (L"%s:%d async request %x removed\n", getdevname(), dev->unit, request);
            return 1;
        }
        prevar = ar;
        ar = ar->next;
     }
     uae_sem_post (&async_sem);
-    write_log ("%s:%d async request %x not found for removal!\n", getdevname(), dev->unit, request);
+    write_log (L"%s:%d async request %x not found for removal!\n", getdevname(), dev->unit, request);
     return 0;
 }
 
@@ -612,11 +612,11 @@ static void abort_async (struct devstruct *dev, uaecptr request)
 {
     struct asyncreq *ar = get_async_request (dev, request, 1);
     if (!ar) {
-       write_log ("%s:%d: abort async but no request %x found!\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d: abort async but no request %x found!\n", getdevname(), dev->unit, request);
        return;
     }
     if (log_net)
-       write_log ("%s:%d asyncronous request=%08X aborted\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d asyncronous request=%08X aborted\n", getdevname(), dev->unit, request);
     do_abort_async (dev, request);
 }
 
@@ -625,7 +625,7 @@ static void signalasync (struct devstruct *dev, struct asyncreq *ar, int actual,
     uaecptr request = ar->request;
     int command = get_word (request + 28);
     if (log_net)
-        write_log ("%s:%d CMD=%d async request %x completed\n", getdevname(), dev->unit, command, request);
+        write_log (L"%s:%d CMD=%d async request %x completed\n", getdevname(), dev->unit, command, request);
     put_long (request + 32, actual);
     put_byte (request + 31, err);
     ar->ready = 1;
@@ -833,7 +833,7 @@ void uaenet_gotdata (struct devstruct *dev, const uae_u8 *d, int len)
     type = (d[12] << 8) | d[13];
     s2p = createreadpacket (dev, d, len);
     if (log_net)
-       write_log ("<-DST:%02X.%02X.%02X.%02X.%02X.%02X SRC:%02X.%02X.%02X.%02X.%02X.%02X E=%04X L=%d P=%p\n",
+       write_log (L"<-DST:%02X.%02X.%02X.%02X.%02X.%02X SRC:%02X.%02X.%02X.%02X.%02X.%02X E=%04X L=%d P=%p\n",
            d[0], d[1], d[2], d[3], d[4], d[5],
            d[6], d[7], d[8], d[9], d[10], d[11],
            type, len, s2p);
@@ -907,7 +907,7 @@ int uaenet_getdata (struct devstruct *dev, uae_u8 *d, int *len)
                        *len = ars2p->s2p->len;
                        memcpy (d, ars2p->s2p->data, *len);
                        if (log_net)
-                           write_log ("->DST:%02X.%02X.%02X.%02X.%02X.%02X SRC:%02X.%02X.%02X.%02X.%02X.%02X E=%04X S=%d\n",
+                           write_log (L"->DST:%02X.%02X.%02X.%02X.%02X.%02X SRC:%02X.%02X.%02X.%02X.%02X.%02X E=%04X S=%d\n",
                                d[0], d[1], d[2], d[3], d[4], d[5],
                                d[6], d[7], d[8], d[9], d[10], d[11],
                                packettype, *len);
@@ -990,7 +990,7 @@ static int dev_do_io_2 (struct devstruct *dev, uaecptr request, int quick)
     struct priv_devstruct *pdev = getpdevstruct (request);
 
     if (log_net)
-       write_log ("S2: C=%02d T=%04X S=%02X%02X%02X%02X%02X%02X D=%02X%02X%02X%02X%02X%02X L=%d D=%08X SD=%08X BM=%08X\n",
+       write_log (L"S2: C=%02d T=%04X S=%02X%02X%02X%02X%02X%02X D=%02X%02X%02X%02X%02X%02X L=%d D=%08X SD=%08X BM=%08X\n",
            command, packettype,
            get_byte (srcaddr + 0), get_byte (srcaddr + 1), get_byte (srcaddr + 2), get_byte (srcaddr + 3), get_byte (srcaddr + 4), get_byte (srcaddr + 5),
            get_byte (dstaddr + 0), get_byte (dstaddr + 1), get_byte (dstaddr + 2), get_byte (dstaddr + 3), get_byte (dstaddr + 4), get_byte (dstaddr + 5), 
@@ -1044,7 +1044,7 @@ static int dev_do_io_2 (struct devstruct *dev, uaecptr request, int quick)
            dev->flush_timeout_cnt = 0;
            dev->flush_timeout = FLUSH_TIMEOUT;
            if (log_net)
-               write_log ("CMD_FLUSH started %08x\n", request);
+               write_log (L"CMD_FLUSH started %08x\n", request);
            uae_sem_wait (&async_sem);
            flush (pdev);
            uae_sem_post (&async_sem);
@@ -1224,7 +1224,7 @@ static int dev_do_io_2 (struct devstruct *dev, uaecptr request, int quick)
     }
 end:
     if (log_net && (io_error || wire_error))
-       write_log("-> %d (%d)\n", io_error, wire_error);
+       write_log (L"-> %d (%d)\n", io_error, wire_error);
     put_long (request + 32, wire_error);
     put_byte (request + 31, io_error);
     return async;
@@ -1238,7 +1238,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request, int quick)
 
     put_byte (request + 31, 0);
     if (!pdev) {
-       write_log ("%s unknown iorequest %08x\n", getdevname (), request);
+       write_log (L"%s unknown iorequest %08x\n", getdevname (), request);
        return 0;
     }
     if (command == NSCMD_DEVICEQUERY) {
@@ -1288,20 +1288,20 @@ static uae_u32 REGPARAM2 dev_beginio (TrapContext *context)
 
     put_byte (request + 8, NT_MESSAGE);
     if (!pdev) {
-       write_log ("%s unknown iorequest (1) %08x\n", getdevname (), request);
+       write_log (L"%s unknown iorequest (1) %08x\n", getdevname (), request);
        put_byte (request + 31, 32);
        return get_byte (request + 31);
     }
     dev = getdevstruct (pdev->unit);
     if (!dev) {
-       write_log ("%s unknown iorequest (2) %08x\n", getdevname (), request);
+       write_log (L"%s unknown iorequest (2) %08x\n", getdevname (), request);
        put_byte (request + 31, 32);
        return get_byte (request + 31);
     }
     put_byte (request + 31, 0);
     if ((flags & 1) && dev_canquick (dev, request)) {
        if (dev_do_io (dev, request, 1))
-           write_log ("%s: command %d bug with IO_QUICK\n", SANA2NAME, command);
+           write_log (L"%s: command %d bug with IO_QUICK\n", SANA2NAME, command);
        return get_byte (request + 31);
     } else {
        if (command == CMD_WRITE || command == S2_BROADCAST || command == S2_MULTICAST) {
@@ -1351,7 +1351,7 @@ static void *dev_thread (void *devs)
            dev->thread_running = 0;
            uae_sem_post (&dev->sync_sem);
            uae_sem_post (&change_sem);
-           write_log ("%s: dev_thread killed\n", getdevname ());
+           write_log (L"%s: dev_thread killed\n", getdevname ());
            return 0;
        } else if (get_async_request (dev, request, 1)) {
            uae_ReplyMsg (request);
@@ -1373,7 +1373,7 @@ static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context)
 {
     uae_u32 base = m68k_dreg (&context->regs,0);
     if (log_net)
-       write_log ("%s init\n", SANA2NAME);
+       write_log (L"%s init\n", SANA2NAME);
     return base;
 }
 
@@ -1389,18 +1389,18 @@ static uae_u32 REGPARAM2 dev_abortio (TrapContext *context)
     struct devstruct *dev;
 
     if (!pdev) {
-       write_log ("%s abortio but no request %08x found!\n", getdevname(), request);
+       write_log (L"%s abortio but no request %08x found!\n", getdevname(), request);
        put_byte (request + 31, 32);
        return get_byte (request + 31);
     }
     dev = getdevstruct (pdev->unit);
     if (!dev) {
-       write_log ("%s (%d) abortio but no request %08x found!\n", getdevname(), pdev->unit, request);
+       write_log (L"%s (%d) abortio but no request %08x found!\n", getdevname(), pdev->unit, request);
        put_byte (request + 31, 32);
        return get_byte (request + 31);
     }
     if (log_net)
-       write_log ("%s:%d abortio %08x\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d abortio %08x\n", getdevname(), dev->unit, request);
     abort_async (dev, request);
     return 0;
 }
@@ -1439,14 +1439,14 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx)
                            if (pdev && pdev->tmp == 0) {
                                if (handleread (ctx, pdev, request, p->data, p->len, command)) {
                                    if (log_net)
-                                       write_log("-> %p Accepted, CMD_READ, REQ=%08X LEN=%d\n", p, request, p->len);
+                                       write_log (L"-> %p Accepted, CMD_READ, REQ=%08X LEN=%d\n", p, request, p->len);
                                    write_comm_pipe_u32 (&dev->requests, request, 1);
                                    dev->packetsreceived++;
                                    gotit = 1;
                                    pdev->tmp = 1;
                                } else {
                                    if (log_net)
-                                       write_log("-> %p PacketFilter() rejected, CMD_READ, REQ=%08X LEN=%d\n", p, request, p->len);
+                                       write_log (L"-> %p PacketFilter() rejected, CMD_READ, REQ=%08X LEN=%d\n", p, request, p->len);
                                    pdev->tmp = -1;
                                }
                            }
@@ -1463,7 +1463,7 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx)
                            struct priv_devstruct *pdev = getpdevstruct (request);
                            if (pdev && pdev->tmp <= 0) {
                                if (log_net)
-                                   write_log("-> %p Accepted, S2_READORPHAN, REQ=%08X LEN=%d\n", p, request, p->len);
+                                   write_log (L"-> %p Accepted, S2_READORPHAN, REQ=%08X LEN=%d\n", p, request, p->len);
                                handleread (ctx, pdev, request, p->data, p->len, command);
                                write_comm_pipe_u32 (&dev->requests, request, 1);
                                dev->packetsreceived++;
@@ -1477,7 +1477,7 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx)
                }
                if (!gotit) {
                    if (log_net)
-                       write_log ("-> %p packet dropped, LEN=%d\n", p, p->len);
+                       write_log (L"-> %p packet dropped, LEN=%d\n", p, p->len);
                    for (j = 0; j < MAX_OPEN_DEVICES; j++) {
                        if (pdevst[j].unit == dev->unit) {
                            if (pdevst[j].tracks[type])
@@ -1526,7 +1526,7 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx)
                    /* do not reply CMD_FLUSH until all other requests are gone */
                    if (dev->ar->next == NULL) {
                        if (log_net)
-                           write_log ("CMD_FLUSH replied %08x\n", request);
+                           write_log (L"CMD_FLUSH replied %08x\n", request);
                        write_comm_pipe_u32 (&dev->requests, request, 1);
                        uaenet_vsync_requested--;
                    } else {
@@ -1536,7 +1536,7 @@ static uae_u32 REGPARAM2 uaenet_int_handler (TrapContext *ctx)
                            if (dev->flush_timeout <= 0) {
                                dev->flush_timeout = FLUSH_TIMEOUT;
                                if (dev->flush_timeout_cnt > 1)
-                                   write_log ("WARNING: %s:%d CMD_FLUSH possibly frozen..\n", getdevname(), pdev->unit);
+                                   write_log (L"WARNING: %s:%d CMD_FLUSH possibly frozen..\n", getdevname(), pdev->unit);
                                dev->flush_timeout_cnt++;
                                flush (pdev);
                            }
@@ -1562,7 +1562,7 @@ static void dev_reset (void)
     struct devstruct *dev;
     int unitnum = 0;
 
-    write_log ("%s reset\n", getdevname());
+    write_log (L"%s reset\n", getdevname());
     for (i = 0; i < MAX_TOTAL_NET_DEVICES; i++) {
        dev = &devst[i];
        if (dev->opencnt) {
@@ -1594,7 +1594,7 @@ uaecptr netdev_startup (uaecptr resaddr)
     if (!currprefs.sana2)
        return resaddr;
     if (log_net)
-       write_log ("netdev_startup(0x%x)\n", resaddr);
+       write_log (L"netdev_startup(0x%x)\n", resaddr);
     /* Build a struct Resident. This will set up and initialize
      * the uaescsi.device */
     put_word (resaddr + 0x0, 0x4AFC);
@@ -1618,38 +1618,38 @@ void netdev_install (void)
     if (!currprefs.sana2)
        return;
     if (log_net)
-       write_log ("netdev_install(): 0x%x\n", here ());
+       write_log (L"netdev_install(): 0x%x\n", here ());
 
     uaenet_close_driver (td);
     uaenet_open_driver (td);
 
     ROM_netdev_resname = ds (getdevname());
-    ROM_netdev_resid = ds ("UAE net.device 0.2");
-    timerdevname = ds ("timer.device");
+    ROM_netdev_resid = ds (L"UAE net.device 0.2");
+    timerdevname = ds (L"timer.device");
 
     /* initcode */
     initcode = here ();
-    calltrap (deftrap2 (dev_init, TRAPFLAG_EXTRA_STACK, "uaenet.init")); dw (RTS);
+    calltrap (deftrap2 (dev_init, TRAPFLAG_EXTRA_STACK, L"uaenet.init")); dw (RTS);
 
     /* Open */
     openfunc = here ();
-    calltrap (deftrap2 (dev_open, TRAPFLAG_EXTRA_STACK, "uaenet.open")); dw (RTS);
+    calltrap (deftrap2 (dev_open, TRAPFLAG_EXTRA_STACK, L"uaenet.open")); dw (RTS);
 
     /* Close */
     closefunc = here ();
-    calltrap (deftrap2 (dev_close, TRAPFLAG_EXTRA_STACK, "uaenet.close")); dw (RTS);
+    calltrap (deftrap2 (dev_close, TRAPFLAG_EXTRA_STACK, L"uaenet.close")); dw (RTS);
 
     /* Expunge */
     expungefunc = here ();
-    calltrap (deftrap2 (dev_expunge, TRAPFLAG_EXTRA_STACK, "uaenet.expunge")); dw (RTS);
+    calltrap (deftrap2 (dev_expunge, TRAPFLAG_EXTRA_STACK, L"uaenet.expunge")); dw (RTS);
 
     /* BeginIO */
     beginiofunc = here ();
-    calltrap (deftrap2 (dev_beginio, TRAPFLAG_EXTRA_STACK, "uaenet.beginio")); dw (RTS);
+    calltrap (deftrap2 (dev_beginio, TRAPFLAG_EXTRA_STACK, L"uaenet.beginio")); dw (RTS);
 
     /* AbortIO */
     abortiofunc = here ();
-    calltrap (deftrap2 (dev_abortio, TRAPFLAG_EXTRA_STACK, "uaenet.abortio")); dw (RTS);
+    calltrap (deftrap2 (dev_abortio, TRAPFLAG_EXTRA_STACK, L"uaenet.abortio")); dw (RTS);
 
     /* FuncTable */
     functable = here ();
@@ -1721,7 +1721,7 @@ void netdev_start_threads (void)
     if (!currprefs.sana2)
        return;
     if (log_net)
-       write_log ("netdev_start_threads()\n");
+       write_log (L"netdev_start_threads()\n");
     uae_sem_init (&change_sem, 0, 1);
     uae_sem_init (&async_sem, 0, 1);
 }
index 250382f8fb00815dd08041da13cc2d8ffca418c6..bf0c0f492102348a305d788e92dc3fcc6ea80300 100644 (file)
@@ -78,7 +78,7 @@ static uae_u8 *replaybuffer, *replaybufferend;
 static int savestate_docompress, savestate_specialdump, savestate_nodialogs;
 static int replaybuffersize;
 
-char savestate_fname[MAX_DPATH];
+TCHAR savestate_fname[MAX_DPATH];
 static struct staterecord staterecords[MAX_STATERECORDS];
 
 static void state_incompatible_warn (void)
@@ -147,13 +147,16 @@ void save_u8_func (uae_u8 **dstp, uae_u8 v)
     *dst++ = v;
     *dstp = dst;
 }
-void save_string_func (uae_u8 **dstp, const char *from)
+void save_string_func (uae_u8 **dstp, const TCHAR *from)
 {
     uae_u8 *dst = *dstp;
-    while (from && *from)
-       *dst++ = *from++;
+    char *s;
+    s = ua (from);
+    while (s && *s)
+       *dst++ = *s++;
     *dst++ = 0;
     *dstp = dst;
+    xfree (s);
 }
 
 uae_u32 restore_u32_func (uae_u8 **dstp)
@@ -189,12 +192,14 @@ uae_u8 restore_u8_func (uae_u8 **dstp)
     *dstp = dst + 1;
     return v;
 }
-char *restore_string_func (uae_u8 **dstp)
+TCHAR *restore_string_func (uae_u8 **dstp)
 {
     int len;
     uae_u8 v;
     uae_u8 *dst = *dstp;
     char *top, *to;
+    TCHAR *s;
+
     len = strlen(dst) + 1;
     top = to = (char*)malloc (len);
     do {
@@ -202,12 +207,14 @@ char *restore_string_func (uae_u8 **dstp)
        *top++ = v;
     } while(v);
     *dstp = dst;
-    return to;
+    s = au (to);
+    xfree (to);
+    return s;
 }
 
 /* read and write IFF-style hunks */
 
-static void save_chunk (struct zfile *f, uae_u8 *chunk, size_t len, char *name, int compress)
+static void save_chunk (struct zfile *f, uae_u8 *chunk, size_t len, TCHAR *name, int compress)
 {
     uae_u8 tmp[8], *dst;
     uae_u8 zero[4]= { 0, 0, 0, 0 };
@@ -267,19 +274,20 @@ static void save_chunk (struct zfile *f, uae_u8 *chunk, size_t len, char *name,
     if (len2)
        zfile_fwrite (zero, 1, len2, f);
 
-    write_log ("Chunk '%s' chunk size %d (%d)\n", name, chunklen, len);
+    write_log (L"Chunk '%s' chunk size %d (%d)\n", name, chunklen, len);
 }
 
-static uae_u8 *restore_chunk (struct zfile *f, char *name, size_t *len, size_t *totallen, size_t *filepos)
+static uae_u8 *restore_chunk (struct zfile *f, TCHAR *name, size_t *len, size_t *totallen, size_t *filepos)
 {
-    uae_u8 tmp[4], dummy[4], *mem, *src;
+    uae_u8 tmp[5], dummy[4], *mem, *src;
     uae_u32 flags;
     int len2;
 
     *totallen = 0;
     /* chunk name */
-    zfile_fread (name, 1, 4, f);
-    name[4] = 0;
+    zfile_fread (tmp, 1, 4, f);
+    tmp[4] = 0;
+    au_copy (name, 5, tmp);
     /* chunk size */
     zfile_fread (tmp, 1, 4, f);
     src = tmp;
@@ -308,13 +316,13 @@ static uae_u8 *restore_chunk (struct zfile *f, char *name, size_t *len, size_t *
     }
     /* chunk data.  RAM contents will be loaded during the reset phase,
        no need to malloc multiple megabytes here.  */
-    if (strcmp (name, "CRAM") != 0
-       && strcmp (name, "BRAM") != 0
-       && strcmp (name, "FRAM") != 0
-       && strcmp (name, "ZRAM") != 0
-       && strcmp (name, "PRAM") != 0
-       && strcmp (name, "A3K1") != 0
-       && strcmp (name, "A3K2") != 0)
+    if (_tcscmp (name, L"CRAM") != 0
+       && _tcscmp (name, L"BRAM") != 0
+       && _tcscmp (name, L"FRAM") != 0
+       && _tcscmp (name, L"ZRAM") != 0
+       && _tcscmp (name, L"PRAM") != 0
+       && _tcscmp (name, L"A3K1") != 0
+       && _tcscmp (name, L"A3K2") != 0)
     {
        /* without zeros at the end old state files may not work */
        mem = (uae_u8*)calloc (1, *totallen + 32);
@@ -362,20 +370,20 @@ void restore_ram (size_t filepos, uae_u8 *memory)
 
 static uae_u8 *restore_log (uae_u8 *src)
 {
-    write_log (src);
-    src += strlen(src) + 1;
+    //write_log (src);
+    src += strlen (src) + 1;
     return src;
 }
 
 static void restore_header (uae_u8 *src)
 {
-    char *emuname, *emuversion, *description;
+    TCHAR *emuname, *emuversion, *description;
 
     restore_u32 ();
     emuname = restore_string ();
     emuversion = restore_string ();
     description = restore_string ();
-    write_log ("Saved with: '%s %s', description: '%s'\n",
+    write_log (L"Saved with: '%s %s', description: '%s'\n",
        emuname,emuversion,description);
     xfree (description);
     xfree (emuversion);
@@ -384,17 +392,17 @@ static void restore_header (uae_u8 *src)
 
 /* restore all subsystems */
 
-void restore_state (const char *filename)
+void restore_state (const TCHAR *filename)
 {
     struct zfile *f;
     uae_u8 *chunk,*end;
-    char name[5];
+    TCHAR name[5];
     size_t len, totallen;
     size_t filepos, filesize;
     int z3num;
 
     chunk = 0;
-    f = zfile_fopen (filename, "rb");
+    f = zfile_fopen (filename, L"rb");
     if (!f)
        goto error;
     zfile_fseek (f, 0, SEEK_END);
@@ -403,8 +411,8 @@ void restore_state (const char *filename)
     savestate_init ();
 
     chunk = restore_chunk (f, name, &len, &totallen, &filepos);
-    if (!chunk || memcmp (name, "ASF ", 4)) {
-       write_log ("%s is not an AmigaStateFile\n",filename);
+    if (!chunk || _tcsncmp (name, L"ASF ", 4)) {
+       write_log (L"%s is not an AmigaStateFile\n", filename);
        goto error;
     }
     savestate_file = f;
@@ -422,137 +430,137 @@ void restore_state (const char *filename)
     for (;;) {
        name[0] = 0;
        chunk = end = restore_chunk (f, name, &len, &totallen, &filepos);
-       write_log ("Chunk '%s' size %d (%d)\n", name, len, totallen);
-       if (!strcmp (name, "END ")) {
+       write_log (L"Chunk '%s' size %d (%d)\n", name, len, totallen);
+       if (!_tcscmp (name, L"END ")) {
 #ifdef _DEBUG
            if (filesize > filepos + 8)
                continue;
 #endif
            break;
        }
-       if (!strcmp (name, "CRAM")) {
+       if (!_tcscmp (name, L"CRAM")) {
            restore_cram (totallen, filepos);
            continue;
-       } else if (!strcmp (name, "BRAM")) {
+       } else if (!_tcscmp (name, L"BRAM")) {
            restore_bram (totallen, filepos);
            continue;
-       } else if (!strcmp (name, "A3K1")) {
+       } else if (!_tcscmp (name, L"A3K1")) {
            restore_a3000lram (totallen, filepos);
            continue;
-       } else if (!strcmp (name, "A3K2")) {
+       } else if (!_tcscmp (name, L"A3K2")) {
            restore_a3000hram (totallen, filepos);
            continue;
 #ifdef AUTOCONFIG
-       } else if (!strcmp (name, "FRAM")) {
+       } else if (!_tcscmp (name, L"FRAM")) {
            restore_fram (totallen, filepos);
            continue;
-       } else if (!strcmp (name, "ZRAM")) {
+       } else if (!_tcscmp (name, L"ZRAM")) {
            restore_zram (totallen, filepos, z3num++);
            continue;
-       } else if (!strcmp (name, "BORO")) {
+       } else if (!_tcscmp (name, L"BORO")) {
            restore_bootrom (totallen, filepos);
            continue;
 #endif
 #ifdef PICASSO96
-       } else if (!strcmp (name, "PRAM")) {
+       } else if (!_tcscmp (name, L"PRAM")) {
            restore_pram (totallen, filepos);
            continue;
 #endif
-       } else if (!strcmp (name, "CPU "))
+       } else if (!_tcscmp (name, L"CPU "))
            end = restore_cpu (chunk);
 #ifdef FPUEMU
-       else if (!strcmp (name, "FPU "))
+       else if (!_tcscmp (name, L"FPU "))
            end = restore_fpu (chunk);
 #endif
-       else if (!strcmp (name, "AGAC"))
+       else if (!_tcscmp (name, L"AGAC"))
            end = restore_custom_agacolors (chunk);
-       else if (!strcmp (name, "SPR0"))
+       else if (!_tcscmp (name, L"SPR0"))
            end = restore_custom_sprite (0, chunk);
-       else if (!strcmp (name, "SPR1"))
+       else if (!_tcscmp (name, L"SPR1"))
            end = restore_custom_sprite (1, chunk);
-       else if (!strcmp (name, "SPR2"))
+       else if (!_tcscmp (name, L"SPR2"))
            end = restore_custom_sprite (2, chunk);
-       else if (!strcmp (name, "SPR3"))
+       else if (!_tcscmp (name, L"SPR3"))
            end = restore_custom_sprite (3, chunk);
-       else if (!strcmp (name, "SPR4"))
+       else if (!_tcscmp (name, L"SPR4"))
            end = restore_custom_sprite (4, chunk);
-       else if (!strcmp (name, "SPR5"))
+       else if (!_tcscmp (name, L"SPR5"))
            end = restore_custom_sprite (5, chunk);
-       else if (!strcmp (name, "SPR6"))
+       else if (!_tcscmp (name, L"SPR6"))
            end = restore_custom_sprite (6, chunk);
-       else if (!strcmp (name, "SPR7"))
+       else if (!_tcscmp (name, L"SPR7"))
            end = restore_custom_sprite (7, chunk);
-       else if (!strcmp (name, "CIAA"))
+       else if (!_tcscmp (name, L"CIAA"))
            end = restore_cia (0, chunk);
-       else if (!strcmp (name, "CIAB"))
+       else if (!_tcscmp (name, L"CIAB"))
            end = restore_cia (1, chunk);
-       else if (!strcmp (name, "CHIP"))
+       else if (!_tcscmp (name, L"CHIP"))
            end = restore_custom (chunk);
-       else if (!strcmp (name, "AUD0"))
+       else if (!_tcscmp (name, L"AUD0"))
            end = restore_audio (0, chunk);
-       else if (!strcmp (name, "AUD1"))
+       else if (!_tcscmp (name, L"AUD1"))
            end = restore_audio (1, chunk);
-       else if (!strcmp (name, "AUD2"))
+       else if (!_tcscmp (name, L"AUD2"))
            end = restore_audio (2, chunk);
-       else if (!strcmp (name, "AUD3"))
+       else if (!_tcscmp (name, L"AUD3"))
            end = restore_audio (3, chunk);
-       else if (!strcmp (name, "BLIT"))
+       else if (!_tcscmp (name, L"BLIT"))
            end = restore_blitter (chunk);
-       else if (!strcmp (name, "DISK"))
+       else if (!_tcscmp (name, L"DISK"))
            end = restore_floppy (chunk);
-       else if (!strcmp (name, "DSK0"))
+       else if (!_tcscmp (name, L"DSK0"))
            end = restore_disk (0, chunk);
-       else if (!strcmp (name, "DSK1"))
+       else if (!_tcscmp (name, L"DSK1"))
            end = restore_disk (1, chunk);
-       else if (!strcmp (name, "DSK2"))
+       else if (!_tcscmp (name, L"DSK2"))
            end = restore_disk (2, chunk);
-       else if (!strcmp (name, "DSK3"))
+       else if (!_tcscmp (name, L"DSK3"))
            end = restore_disk (3, chunk);
-       else if (!strcmp (name, "KEYB"))
+       else if (!_tcscmp (name, L"KEYB"))
            end = restore_keyboard (chunk);
 #ifdef AUTOCONFIG
-       else if (!strcmp (name, "EXPA"))
+       else if (!_tcscmp (name, L"EXPA"))
            end = restore_expansion (chunk);
 #endif
-       else if (!strcmp (name, "ROM "))
+       else if (!_tcscmp (name, L"ROM "))
            end = restore_rom (chunk);
 #ifdef PICASSO96
-       else if (!strcmp (name, "P96 "))
+       else if (!_tcscmp (name, L"P96 "))
            end = restore_p96 (chunk);
 #endif
 #ifdef ACTION_REPLAY
-       else if (!strcmp (name, "ACTR"))
+       else if (!_tcscmp (name, L"ACTR"))
            end = restore_action_replay (chunk);
-       else if (!strcmp (name, "HRTM"))
+       else if (!_tcscmp (name, L"HRTM"))
            end = restore_hrtmon (chunk);
 #endif
 #ifdef FILESYS
-       else if (!strcmp (name, "FSYS"))
+       else if (!_tcscmp (name, L"FSYS"))
            end = restore_filesys (chunk);
-       else if (!strcmp (name, "FSYC"))
+       else if (!_tcscmp (name, L"FSYC"))
            end = restore_filesys_common (chunk);
 #endif
 #ifdef CD32
-       else if (!strcmp (name, "CD32"))
+       else if (!_tcscmp (name, L"CD32"))
            end = restore_akiko (chunk);
 #endif
-       else if (!strcmp (name, "GAYL"))
+       else if (!_tcscmp (name, L"GAYL"))
            end = restore_gayle (chunk);
-       else if (!strcmp (name, "IDE "))
+       else if (!_tcscmp (name, L"IDE "))
            end = restore_ide (chunk);
-       else if (!strcmp (name, "CONF"))
+       else if (!_tcscmp (name, L"CONF"))
            end = restore_configuration (chunk);
-       else if (!strcmp (name, "LOG "))
+       else if (!_tcscmp (name, L"LOG "))
            end = restore_log (chunk);
        else {
            end = chunk + len;
-           write_log ("unknown chunk '%s' size %d bytes\n", name, len);
+           write_log (L"unknown chunk '%s' size %d bytes\n", name, len);
        }
        if (end == NULL)
-           write_log ("Chunk '%s', size %d bytes was not accepted!\n",
+           write_log (L"Chunk '%s', size %d bytes was not accepted!\n",
                name, len);
        else if (len != end - chunk)
-           write_log ("Chunk '%s' total size %d bytes but read %d bytes!\n",
+           write_log (L"Chunk '%s' total size %d bytes but read %d bytes!\n",
                       name, len, end - chunk);
        xfree (chunk);
     }
@@ -582,7 +590,7 @@ void savestate_restore_finish (void)
 }
 
 /* 1=compressed,2=not compressed,3=ram dump,4=audio dump */
-void savestate_initsave (const char *filename, int mode, int nodialogs)
+void savestate_initsave (const TCHAR *filename, int mode, int nodialogs)
 {
     if (filename == NULL) {
        savestate_fname[0] = 0;
@@ -591,7 +599,7 @@ void savestate_initsave (const char *filename, int mode, int nodialogs)
        savestate_nodialogs = 0;
        return;
     }
-    strcpy (savestate_fname, filename);
+    _tcscpy (savestate_fname, filename);
     savestate_docompress = (mode == 1) ? 1 : 0;
     savestate_specialdump = (mode == 3) ? 1 : (mode == 4) ? 2 : 0;
     savestate_nodialogs = nodialogs;
@@ -603,54 +611,54 @@ static void save_rams (struct zfile *f, int comp)
     int len;
 
     dst = save_cram (&len);
-    save_chunk (f, dst, len, "CRAM", comp);
+    save_chunk (f, dst, len, L"CRAM", comp);
     dst = save_bram (&len);
-    save_chunk (f, dst, len, "BRAM", comp);
+    save_chunk (f, dst, len, L"BRAM", comp);
     dst = save_a3000lram (&len);
-    save_chunk (f, dst, len, "A3K1", comp);
+    save_chunk (f, dst, len, L"A3K1", comp);
     dst = save_a3000hram (&len);
-    save_chunk (f, dst, len, "A3K2", comp);
+    save_chunk (f, dst, len, L"A3K2", comp);
 #ifdef AUTOCONFIG
     dst = save_fram (&len);
-    save_chunk (f, dst, len, "FRAM", comp);
+    save_chunk (f, dst, len, L"FRAM", comp);
     dst = save_zram (&len, 0);
-    save_chunk (f, dst, len, "ZRAM", comp);
+    save_chunk (f, dst, len, L"ZRAM", comp);
     dst = save_zram (&len, 1);
-    save_chunk (f, dst, len, "ZRAM", comp);
+    save_chunk (f, dst, len, L"ZRAM", comp);
     dst = save_bootrom (&len);
-    save_chunk (f, dst, len, "BORO", comp);
+    save_chunk (f, dst, len, L"BORO", comp);
 #endif
 #ifdef PICASSO96
     dst = save_p96 (&len, 0);
-    save_chunk (f, dst, len, "P96 ", 0);
+    save_chunk (f, dst, len, L"P96 ", 0);
     dst = save_pram (&len);
-    save_chunk (f, dst, len, "PRAM", comp);
+    save_chunk (f, dst, len, L"PRAM", comp);
 #endif
 }
 
 /* Save all subsystems */
 
-int save_state (const char *filename, const char *description)
+int save_state (const TCHAR *filename, const TCHAR *description)
 {
     uae_u8 endhunk[] = { 'E', 'N', 'D', ' ', 0, 0, 0, 8 };
     uae_u8 header[1000];
-    char tmp[100];
+    TCHAR tmp[100];
     uae_u8 *dst;
     struct zfile *f;
     int len,i;
-    char name[5];
+    TCHAR name[5];
     int comp = savestate_docompress;
 
     if (!savestate_specialdump && !savestate_nodialogs) {
        state_incompatible_warn ();
        if (!save_filesys_cando ()) {
-           gui_message("Filesystem active. Try again later");
+           gui_message (L"Filesystem active. Try again later");
            return -1;
        }
     }
     savestate_nodialogs = 0;
     custom_prepare_savestate ();
-    f = zfile_fopen (filename, "w+b");
+    f = zfile_fopen (filename, L"w+b");
     if (!f)
        return 0;
     if (savestate_specialdump) {
@@ -678,23 +686,23 @@ int save_state (const char *filename, const char *description)
 
     dst = header;
     save_u32 (0);
-    save_string ("UAE");
-    sprintf (tmp, "%d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
+    save_string (L"UAE");
+    _stprintf (tmp, L"%d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
     save_string (tmp);
     save_string (description);
-    save_chunk (f, header, dst-header, "ASF ", 0);
+    save_chunk (f, header, dst-header, L"ASF ", 0);
 
     dst = save_cpu (&len, 0);
-    save_chunk (f, dst, len, "CPU ", 0);
+    save_chunk (f, dst, len, L"CPU ", 0);
     xfree (dst);
 
 #ifdef FPUEMU
     dst = save_fpu (&len,0 );
-    save_chunk (f, dst, len, "FPU ", 0);
+    save_chunk (f, dst, len, L"FPU ", 0);
     xfree (dst);
 #endif
 
-    strcpy(name, "DSKx");
+    _tcscpy(name, L"DSKx");
     for (i = 0; i < 4; i++) {
        dst = save_disk (i, &len, 0);
        if (dst) {
@@ -704,22 +712,22 @@ int save_state (const char *filename, const char *description)
        }
     }
     dst = save_floppy (&len, 0);
-    save_chunk (f, dst, len, "DISK", 0);
+    save_chunk (f, dst, len, L"DISK", 0);
     xfree (dst);
 
     dst = save_blitter (&len, 0);
-    save_chunk (f, dst, len, "BLIT", 0);
+    save_chunk (f, dst, len, L"BLIT", 0);
     xfree (dst);
 
     dst = save_custom (&len, 0, 0);
-    save_chunk (f, dst, len, "CHIP", 0);
+    save_chunk (f, dst, len, L"CHIP", 0);
     xfree (dst);
 
     dst = save_custom_agacolors (&len, 0);
-    save_chunk (f, dst, len, "AGAC", 0);
+    save_chunk (f, dst, len, L"AGAC", 0);
     xfree (dst);
 
-    strcpy (name, "SPRx");
+    _tcscpy (name, L"SPRx");
     for (i = 0; i < 8; i++) {
        dst = save_custom_sprite (i, &len, 0);
        name[3] = i + '0';
@@ -727,7 +735,7 @@ int save_state (const char *filename, const char *description)
        xfree (dst);
     }
 
-    strcpy (name, "AUDx");
+    _tcscpy (name, L"AUDx");
     for (i = 0; i < 4; i++) {
        dst = save_audio (i, &len, 0);
        name[3] = i + '0';
@@ -736,20 +744,20 @@ int save_state (const char *filename, const char *description)
     }
 
     dst = save_cia (0, &len, 0);
-    save_chunk (f, dst, len, "CIAA", 0);
+    save_chunk (f, dst, len, L"CIAA", 0);
     xfree (dst);
 
     dst = save_cia (1, &len, 0);
-    save_chunk (f, dst, len, "CIAB", 0);
+    save_chunk (f, dst, len, L"CIAB", 0);
     xfree (dst);
 
     dst = save_keyboard (&len);
-    save_chunk (f, dst, len, "KEYB", 0);
+    save_chunk (f, dst, len, L"KEYB", 0);
     xfree (dst);
 
 #ifdef AUTOCONFIG
     dst = save_expansion (&len, 0);
-    save_chunk (f, dst, len, "EXPA", 0);
+    save_chunk (f, dst, len, L"EXPA", 0);
 #endif
     save_rams (f, comp);
 
@@ -757,29 +765,29 @@ int save_state (const char *filename, const char *description)
     do {
        if (!dst)
            break;
-       save_chunk (f, dst, len, "ROM ", 0);
+       save_chunk (f, dst, len, L"ROM ", 0);
        xfree (dst);
     } while ((dst = save_rom (0, &len, 0)));
 
 #ifdef CD32
     dst = save_akiko (&len);
-    save_chunk (f, dst, len, "CD32", 0);
+    save_chunk (f, dst, len, L"CD32", 0);
     xfree (dst);
 #endif
 #ifdef ACTION_REPLAY
     dst = save_action_replay (&len, 0);
-    save_chunk (f, dst, len, "ACTR", 1);
+    save_chunk (f, dst, len, L"ACTR", 1);
     dst = save_hrtmon (&len, 0);
-    save_chunk (f, dst, len, "HRTM", 1);
+    save_chunk (f, dst, len, L"HRTM", 1);
 #endif
 #ifdef FILESYS
     dst = save_filesys_common (&len);
     if (dst) {
-       save_chunk (f, dst, len, "FSYC", 0);
+       save_chunk (f, dst, len, L"FSYC", 0);
        for (i = 0; i < nr_units (); i++) {
            dst = save_filesys (i, &len);
            if (dst) {
-               save_chunk (f, dst, len, "FSYS", 0);
+               save_chunk (f, dst, len, L"FSYS", 0);
                xfree (dst);
            }
        }
@@ -787,13 +795,13 @@ int save_state (const char *filename, const char *description)
 #endif
     dst = save_gayle(&len);
     if (dst) {
-       save_chunk (f, dst, len, "GAYL", 0);
+       save_chunk (f, dst, len, L"GAYL", 0);
        xfree(dst);
     }
     for (i = 0; i < 4; i++) {
        dst = save_ide (i, &len);
        if (dst) {
-           save_chunk (f, dst, len, "IDE ", 0);
+           save_chunk (f, dst, len, L"IDE ", 0);
            xfree(dst);
        }
     }
@@ -804,18 +812,18 @@ int save_state (const char *filename, const char *description)
 
     dst = save_configuration (&len);
     if (dst) {
-       save_chunk (f, dst, len, "CONF", 1);
+       save_chunk (f, dst, len, L"CONF", 1);
        xfree(dst);
     }
     dst = save_log (TRUE, &len);
     if (dst) {
-       save_chunk (f, dst, len, "LOG ", 1);
+       save_chunk (f, dst, len, L"LOG ", 1);
        xfree(dst);
     }
 
     zfile_fwrite (endhunk, 1, 8, f);
 
-    write_log ("Save of '%s' complete\n", filename);
+    write_log (L"Save of '%s' complete\n", filename);
     zfile_fclose (f);
     savestate_state = 0;
     return 1;
@@ -823,7 +831,7 @@ int save_state (const char *filename, const char *description)
 
 void savestate_quick (int slot, int save)
 {
-    int i, len = strlen (savestate_fname);
+    int i, len = _tcslen (savestate_fname);
     i = len - 1;
     while (i >= 0 && savestate_fname[i] != '_')
        i--;
@@ -832,24 +840,24 @@ void savestate_quick (int slot, int save)
        while (i >= 0 && savestate_fname[i] != '.')
            i--;
        if (i <= 0) {
-           write_log ("savestate name skipped '%s'\n", savestate_fname);
+           write_log (L"savestate name skipped '%s'\n", savestate_fname);
            return;
        }
     }
-    strcpy (savestate_fname + i, ".uss");
+    _tcscpy (savestate_fname + i, L".uss");
     if (slot > 0)
-       sprintf (savestate_fname + i, "_%d.uss", slot);
+       _stprintf (savestate_fname + i, L"_%d.uss", slot);
     if (save) {
-       write_log ("saving '%s'\n", savestate_fname);
+       write_log (L"saving '%s'\n", savestate_fname);
        savestate_docompress = 1;
-       save_state (savestate_fname, "");
+       save_state (savestate_fname, L"");
     } else {
        if (!zfile_exists (savestate_fname)) {
-           write_log ("staterestore, file '%s' not found\n", savestate_fname);
+           write_log (L"staterestore, file '%s' not found\n", savestate_fname);
            return;
        }
        savestate_state = STATE_DORESTORE;
-       write_log ("staterestore starting '%s'\n", savestate_fname);
+       write_log (L"staterestore starting '%s'\n", savestate_fname);
     }
 }
 
@@ -891,7 +899,7 @@ void savestate_listrewind (void)
            break;
        p = st->cpu + 17 * 4;
        pc = restore_u32_func (&p);
-       console_out_f ("%d: PC=%08X %c\n", cnt, pc, regs.pc == pc ? '*' : ' ');
+       console_out_f (L"%d: PC=%08X %c\n", cnt, pc, regs.pc == pc ? '*' : ' ');
        cnt++;
        i--;
        if (i < 0)
@@ -911,7 +919,7 @@ void savestate_rewind (void)
     frameextra = timeframes % currprefs.statecapturerate;
     p =  st->start;
     p2 = st->end;
-    write_log ("rewinding from %d\n", replaycounter);
+    write_log (L"rewinding from %d\n", replaycounter);
     p = restore_cpu (p);
 #ifdef FPUEMU
     if (restore_u32_func (&p))
@@ -955,7 +963,7 @@ void savestate_rewind (void)
 #endif
     p += 4;
     if (p != p2) {
-       gui_message ("reload failure, address mismatch %p != %p", p, p2);
+       gui_message (L"reload failure, address mismatch %p != %p", p, p2);
        uae_reset (0);
        return;
     }
@@ -971,7 +979,7 @@ static int bufcheck (uae_u8 **pp, int len)
 {
     uae_u8 *p = *pp;
     if (p + len + BS >= replaybuffer + replaybuffersize) {
-       //write_log ("capture buffer wrap-around\n");
+       //write_log (L"capture buffer wrap-around\n");
        return 1;
     }
     return 0;
@@ -1141,13 +1149,13 @@ retry2:
        }
        i--;
     }
-    //write_log ("state capture %d (%d bytes)\n", replaycounter, p - p2);
+    //write_log (L"state capture %d (%d bytes)\n", replaycounter, p - p2);
     return;
 retry:
     staterecords[replaycounter].next = replaybuffer;
     retrycnt++;
     if (retrycnt > 1) {
-       write_log ("can't save, too small capture buffer\n");
+       write_log (L"can't save, too small capture buffer\n");
        return;
     }
     goto retry2;
diff --git a/scsi.c b/scsi.c
index a1fdf9421019db9368414a068de267e824b982fd..636e4500e5973196d1926275230b9da77f72ddf4 100644 (file)
--- a/scsi.c
+++ b/scsi.c
@@ -40,7 +40,7 @@ int scsi_data_dir(struct scsi_data *sd)
            return 0;
        }
     }
-    write_log ("SCSI command %02X, no direction specified (IN?)!\n", sd->cmd[0]);
+    write_log (L"SCSI command %02X, no direction specified (IN?)!\n", sd->cmd[0]);
     return -2;
 }
 
@@ -99,7 +99,7 @@ struct scsi_data *scsi_alloc_native(int id, int nativeunit)
 {
     struct scsi_data *sd;
     if (!sys_command_open (DF_SCSI, nativeunit)) {
-       write_log ("SCSI: native scsi unit %d failed to open\n", nativeunit);
+       write_log (L"SCSI: native scsi unit %d failed to open\n", nativeunit);
        return NULL;
     }
     sd = (struct scsi_data*)xcalloc(sizeof (struct scsi_data), 1);
@@ -133,13 +133,13 @@ int scsi_send_data(struct scsi_data *sd, uae_u8 b)
 {
     if (sd->direction) {
        if (sd->offset >= SCSI_DATA_BUFFER_SIZE) {
-           write_log ("SCSI data buffer overflow!\n");
+           write_log (L"SCSI data buffer overflow!\n");
            return 0;
        }
        sd->buffer[sd->offset++] = b;
     } else {
        if (sd->offset >= 16) {
-           write_log ("SCSI command buffer overflow!\n");
+           write_log (L"SCSI command buffer overflow!\n");
            return 0;
        }
        sd->cmd[sd->offset++] = b;
index 5c9dff61c93cd19e79c3f2e9262041ad0577f65e..0a288c0cbf78e302c90511d7e61712c0a98e61cc 100644 (file)
@@ -30,9 +30,9 @@
 
 #define CDDEV_COMMANDS
 
-#define UAEDEV_SCSI "uaescsi.device"
+#define UAEDEV_SCSI L"uaescsi.device"
 #define UAEDEV_SCSI_ID 1
-#define UAEDEV_DISK "uaedisk.device"
+#define UAEDEV_DISK L"uaedisk.device"
 #define UAEDEV_DISK_ID 2
 
 #define MAX_ASYNC_REQUESTS 20
@@ -81,10 +81,10 @@ static struct device_info *devinfo (int mode, int unitnum, struct device_info *d
     return sys_command_info (mode, unitnum, di);
 }
 
-static void io_log (const char *msg, uaecptr request)
+static void io_log (const TCHAR *msg, uaecptr request)
 {
     if (log_scsi)
-       write_log ("%s: %08X %d %08X %d %d io_actual=%d io_error=%d\n",
+       write_log (L"%s: %08X %d %08X %d %d io_actual=%d io_error=%d\n",
            msg, request, get_word (request + 28), get_long (request + 40),
            get_long (request + 36), get_long (request + 44),
            get_long (request + 32), get_byte (request + 31));
@@ -103,13 +103,13 @@ static struct priv_devstruct *getpdevstruct (uaecptr request)
 {
     int i = get_long (request + 24);
     if (i < 0 || i >= MAX_OPEN_DEVICES || pdevst[i].inuse == 0) {
-       write_log ("uaescsi.device: corrupt iorequest %08X %d\n", request, i);
+       write_log (L"uaescsi.device: corrupt iorequest %08X %d\n", request, i);
        return 0;
     }
     return &pdevst[i];
 }
 
-static char *getdevname (int type)
+static TCHAR *getdevname (int type)
 {
     switch (type) {
        case UAEDEV_SCSI_ID:
@@ -117,7 +117,7 @@ static char *getdevname (int type)
        case UAEDEV_DISK_ID:
        return UAEDEV_DISK;
        default:
-       return "NULL";
+       return L"NULL";
     }
 }
 
@@ -128,7 +128,7 @@ static int start_thread (struct devstruct *dev)
        return 1;
     init_comm_pipe (&dev->requests, 100, 1);
     uae_sem_init (&dev->sync_sem, 0, 0);
-    uae_start_thread ("uaescsi", dev_thread, dev, NULL);
+    uae_start_thread (L"uaescsi", dev_thread, dev, NULL);
     uae_sem_wait (&dev->sync_sem);
     return dev->thread_running;
 }
@@ -157,7 +157,7 @@ static uae_u32 REGPARAM2 dev_close_2 (TrapContext *context)
        return 0;
     dev = getdevstruct (pdev->unit);
     if (log_scsi)
-       write_log ("%s:%d close, req=%08X\n", getdevname (pdev->type), pdev->unit, request);
+       write_log (L"%s:%d close, req=%08X\n", getdevname (pdev->type), pdev->unit, request);
     if (!dev)
        return 0;
     dev_close_3 (dev, pdev);
@@ -192,7 +192,7 @@ static uae_u32 REGPARAM2 dev_open_2 (TrapContext *context, int type)
     int i;
 
     if (log_scsi)
-       write_log ("opening %s:%d ioreq=%08X\n", getdevname (type), unit, ioreq);
+       write_log (L"opening %s:%d ioreq=%08X\n", getdevname (type), unit, ioreq);
     if (get_word (ioreq + 0x12) < IOSTDREQ_SIZE)
        return openfail (ioreq, IOERR_BADLENGTH);
     if (!dev)
@@ -293,7 +293,7 @@ static int add_async_request (struct devstruct *dev, uaecptr request, int type,
     int i;
 
     if (log_scsi)
-       write_log ("async request %08x (%d) added\n", request, type);
+       write_log (L"async request %08x (%d) added\n", request, type);
     i = 0;
     while (i < MAX_ASYNC_REQUESTS) {
        if (dev->d_request[i] == request) {
@@ -321,7 +321,7 @@ static int release_async_request (struct devstruct *dev, uaecptr request)
     int i = 0;
 
     if (log_scsi)
-       write_log ("async request %p removed\n", request);
+       write_log (L"async request %p removed\n", request);
     while (i < MAX_ASYNC_REQUESTS) {
        if (dev->d_request[i] == request) {
            int type = dev->d_request_type[i];
@@ -350,7 +350,7 @@ static void abort_async (struct devstruct *dev, uaecptr request, int errcode, in
     }
     i = release_async_request (dev, request);
     if (i >= 0 && log_scsi)
-       write_log ("asyncronous request=%08X aborted, error=%d\n", request, errcode);
+       write_log (L"asyncronous request=%08X aborted, error=%d\n", request, errcode);
 }
 
 static int command_read (int mode, struct devstruct *dev, uaecptr data, uae_u64 offset, uae_u32 length, uae_u32 *io_actual)
@@ -455,7 +455,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
     switch (command)
     {
        case CMD_READ:
-       //write_log ("CMD_READ %08x %d %d %08x\n", io_data, io_offset, io_length, bmask);
+       //write_log (L"CMD_READ %08x %d %d %08x\n", io_data, io_offset, io_length, bmask);
        if (dev->drivetype == INQ_ROMD) {
            io_error = command_cd_read (pdev->mode, dev, io_data, io_offset, io_length, &io_actual);
        } else {
@@ -582,7 +582,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
            uae_u32 sdd = get_long (request + 40);
            io_error = sys_command_scsi_direct (dev->unitnum, sdd);
            if (log_scsi)
-               write_log ("scsidev: did io: sdd %p request %p error %d\n", sdd, request, get_byte (request + 31));
+               write_log (L"scsidev: did io: sdd %p request %p error %d\n", sdd, request, get_byte (request + 31));
        } else {
            io_error = IOERR_NOCMD;
        }
@@ -607,7 +607,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request)
     }
     put_long (request + 32, io_actual);
     put_byte (request + 31, io_error);
-    io_log ("dev_io",request);
+    io_log (L"dev_io",request);
     return async;
 }
 
@@ -654,7 +654,7 @@ static uae_u32 REGPARAM2 dev_beginio (TrapContext *context)
     put_byte (request+31, 0);
     if ((flags & 1) && dev_canquick (dev, request)) {
        if (dev_do_io (dev, request))
-           write_log ("device %s command %d bug with IO_QUICK\n", getdevname (pdev->type), command);
+           write_log (L"device %s command %d bug with IO_QUICK\n", getdevname (pdev->type), command);
        return get_byte (request + 31);
     } else {
        add_async_request (dev, request, ASYNC_REQUEST_TEMP, 0);
@@ -685,7 +685,7 @@ static void *dev_thread (void *devs)
            uae_ReplyMsg (request);
        } else {
            if (log_scsi)
-               write_log ("%s:%d async request %08X\n", getdevname(0), dev->unitnum, request);
+               write_log (L"%s:%d async request %08X\n", getdevname(0), dev->unitnum, request);
        }
        uae_sem_post (&change_sem);
     }
@@ -696,7 +696,7 @@ static uae_u32 REGPARAM2 dev_init_2 (TrapContext *context, int type)
 {
     uae_u32 base = m68k_dreg (&context->regs,0);
     if (log_scsi)
-       write_log ("%s init\n", getdevname (type));
+       write_log (L"%s init\n", getdevname (type));
     return base;
 }
 
@@ -726,7 +726,7 @@ static uae_u32 REGPARAM2 dev_abortio (TrapContext *context)
     }
     put_byte (request + 31, IOERR_ABORTED);
     if (log_scsi)
-       write_log ("abortio %s unit=%d, request=%08X\n", getdevname (pdev->type), pdev->unit, request);
+       write_log (L"abortio %s unit=%d, request=%08X\n", getdevname (pdev->type), pdev->unit, request);
     abort_async (dev, request, IOERR_ABORTED, 0);
     return 0;
 }
@@ -795,7 +795,7 @@ static void dev_reset (void)
                dev->aunit = unitnum;
                unitnum++;
            }
-           write_log ("%s:%d = '%s'\n", UAEDEV_SCSI, dev->aunit, dev->di.label);
+           write_log (L"%s:%d = '%s'\n", UAEDEV_SCSI, dev->aunit, dev->di.label);
        }
        dev->di.label[0] = 0;
     }
@@ -815,7 +815,7 @@ static uaecptr diskdev_startup (uaecptr resaddr)
     /* Build a struct Resident. This will set up and initialize
      * the cd.device */
     if (log_scsi)
-       write_log ("diskdev_startup(0x%x)\n", resaddr);
+       write_log (L"diskdev_startup(0x%x)\n", resaddr);
     put_word (resaddr + 0x0, 0x4AFC);
     put_long (resaddr + 0x2, resaddr);
     put_long (resaddr + 0x6, resaddr + 0x1A); /* Continue scan here */
@@ -833,7 +833,7 @@ uaecptr scsidev_startup (uaecptr resaddr)
     if (currprefs.scsi != 1)
        return resaddr;
     if (log_scsi)
-       write_log ("scsidev_startup(0x%x)\n", resaddr);
+       write_log (L"scsidev_startup(0x%x)\n", resaddr);
     /* Build a struct Resident. This will set up and initialize
      * the uaescsi.device */
     put_word (resaddr + 0x0, 0x4AFC);
@@ -858,10 +858,10 @@ static void diskdev_install (void)
     if (currprefs.scsi != 1)
        return;
     if (log_scsi)
-       write_log ("diskdev_install(): 0x%x\n", here ());
+       write_log (L"diskdev_install(): 0x%x\n", here ());
 
     ROM_diskdev_resname = ds (UAEDEV_DISK);
-    ROM_diskdev_resid = ds ("UAE disk.device 0.1");
+    ROM_diskdev_resid = ds (L"UAE disk.device 0.1");
 
     /* initcode */
     initcode = here ();
@@ -937,10 +937,10 @@ void scsidev_install (void)
     if (currprefs.scsi != 1)
        return;
     if (log_scsi)
-       write_log ("scsidev_install(): 0x%x\n", here ());
+       write_log (L"scsidev_install(): 0x%x\n", here ());
 
     ROM_scsidev_resname = ds (UAEDEV_SCSI);
-    ROM_scsidev_resid = ds ("UAE scsi.device 0.2");
+    ROM_scsidev_resid = ds (L"UAE scsi.device 0.2");
 
     /* initcode */
     initcode = here ();
@@ -1041,7 +1041,7 @@ void scsidev_start_threads (void)
     if (currprefs.scsi != 1) /* quite useless.. */
        return;
     if (log_scsi)
-       write_log ("scsidev_start_threads()\n");
+       write_log (L"scsidev_start_threads()\n");
     uae_sem_init (&change_sem, 0, 1);
 }
 
diff --git a/traps.c b/traps.c
index 9a777d70fc705155c2deee91537f4abe0175d8e6..7fc2b473c37c34902330a39528dcb952369cb381 100644 (file)
--- a/traps.c
+++ b/traps.c
@@ -65,7 +65,7 @@ struct Trap
 {
     TrapHandler handler;       /* Handler function to be invoked for this trap. */
     int         flags;         /* Trap attributes. */
-    const char *name;          /* For debugging purposes. */
+    const TCHAR *name;         /* For debugging purposes. */
     uaecptr addr;
 };
 
@@ -80,13 +80,13 @@ static const int trace_traps = 0;
 
 static void trap_HandleExtendedTrap (TrapHandler, int has_retval);
 
-uaecptr find_trap (const char *name)
+uaecptr find_trap (const TCHAR *name)
 {
     int i;
 
     for (i = 0; i < trap_count; i++) {
        struct Trap *trap = &traps[i];
-       if ((trap->flags & TRAPFLAG_UAERES) && trap->name && !strcmp (trap->name, name))
+       if ((trap->flags & TRAPFLAG_UAERES) && trap->name && !_tcscmp (trap->name, name))
            return trap->addr;
     }
     return 0;
@@ -102,10 +102,10 @@ uaecptr find_trap (const char *name)
  *
  * returns trap number of defined trap
  */
-unsigned int define_trap (TrapHandler handler_func, int flags, const char *name)
+unsigned int define_trap (TrapHandler handler_func, int flags, const TCHAR *name)
 {
     if (trap_count == MAX_TRAPS) {
-       write_log ("Ran out of emulator traps\n");
+       write_log (L"Ran out of emulator traps\n");
        abort ();
        return -1;
     } else {
@@ -137,7 +137,7 @@ void REGPARAM2 m68k_handle_trap (unsigned int trap_num, struct regstruct *regs)
     int implicit_rts = (trap->flags & TRAPFLAG_DORET) != 0;
 
     if (trap->name && trap->name[0] != 0 && trace_traps)
-       write_log ("TRAP: %s\n", trap->name);
+       write_log (L"TRAP: %s\n", trap->name);
 
     if (trap_num < trap_count) {
 
@@ -162,7 +162,7 @@ void REGPARAM2 m68k_handle_trap (unsigned int trap_num, struct regstruct *regs)
        }
 
     } else {
-       write_log ("Illegal emulator trap %d\n", trap_num);
+       write_log (L"Illegal emulator trap %d\n", trap_num);
     }
 }
 
@@ -480,13 +480,13 @@ void init_traps (void)
 void init_extended_traps (void)
 {
     m68k_call_trapaddr = here ();
-    calltrap (deftrap2 ((TrapHandler)m68k_call_handler, TRAPFLAG_NO_RETVAL, "m68k_call"));
+    calltrap (deftrap2 ((TrapHandler)m68k_call_handler, TRAPFLAG_NO_RETVAL, L"m68k_call"));
 
     m68k_return_trapaddr = here();
-    calltrap (deftrap2 ((TrapHandler)m68k_return_handler, TRAPFLAG_NO_RETVAL, "m68k_return"));
+    calltrap (deftrap2 ((TrapHandler)m68k_return_handler, TRAPFLAG_NO_RETVAL, L"m68k_return"));
 
     exit_trap_trapaddr = here();
-    calltrap (deftrap2 ((TrapHandler)exit_trap_handler, TRAPFLAG_NO_RETVAL, "exit_trap"));
+    calltrap (deftrap2 ((TrapHandler)exit_trap_handler, TRAPFLAG_NO_RETVAL, L"exit_trap"));
 
     uae_sem_init (&trap_mutex, 0, 1);
 }
index f884dbaf1afd89ff31c7a0c3bd3ec4751ae1375a..691515b9e2923ed6993841a2180e2e401ba282f7 100644 (file)
--- a/uaeexe.c
+++ b/uaeexe.c
@@ -18,7 +18,7 @@
 
 static struct uae_xcmd *first = NULL;
 static struct uae_xcmd *last  = NULL;
-static char running = 0;
+static TCHAR running = 0;
 static uae_u32 REGPARAM3 uaeexe_server (TrapContext *context) REGPARAM;
 
 /*
@@ -30,7 +30,7 @@ void uaeexe_install (void)
 
     loop = here ();
     org (UAEEXE_ORG);
-    calltrap (deftrapres (uaeexe_server, 0, "uaeexe_server"));
+    calltrap (deftrapres (uaeexe_server, 0, L"uaeexe_server"));
     dw (RTS);
     org (loop);
 }
@@ -44,7 +44,7 @@ void uaeexe_install (void)
  * to launch the command asynchronously. Please note also that the
  * remote cli works better if you've got the fifo-handler installed.
  */
-int uaeexe (const char *cmd)
+int uaeexe (const TCHAR *cmd)
 {
     struct uae_xcmd *nw;
 
@@ -54,13 +54,13 @@ int uaeexe (const char *cmd)
     nw = malloc (sizeof *nw);
     if (!nw)
        goto NOMEM;
-    nw->cmd = malloc (strlen (cmd) + 1);
+    nw->cmd = malloc ((_tcslen (cmd) + 1) * sizeof (TCHAR));
     if (!nw->cmd) {
        free (nw);
        goto NOMEM;
     }
 
-    strcpy (nw->cmd, cmd);
+    _tcscpy (nw->cmd, cmd);
     nw->prev = last;
     nw->next = NULL;
 
@@ -76,17 +76,17 @@ int uaeexe (const char *cmd)
   NOMEM:
     return UAEEXE_NOMEM;
   NORUN:
-    write_log ("Remote cli is not running.\n");
+    write_log (L"Remote cli is not running.\n");
     return UAEEXE_NOTRUNNING;
 }
 
 /*
  * returns next command to be executed
  */
-static char *get_cmd (void)
+static TCHAR *get_cmd (void)
 {
     struct uae_xcmd *cmd;
-    char *s;
+    TCHAR *s;
 
     if (!first)
        return NULL;
@@ -106,12 +106,12 @@ static char *get_cmd (void)
 static uae_u32 REGPARAM2 uaeexe_server (TrapContext *context)
 {
     int len;
-    char *cmd;
-    char *dst;
+    TCHAR *cmd;
+    char *dst, *s;
 
     if (ARG (0) && !running) {
        running = 1;
-       write_log ("Remote CLI started.\n");
+       write_log (L"Remote CLI started.\n");
     }
 
     cmd = get_cmd ();
@@ -122,10 +122,12 @@ static uae_u32 REGPARAM2 uaeexe_server (TrapContext *context)
        return 0;
     }
 
-    dst = (char *)get_real_address (ARG (0));
+    dst = (char*)get_real_address (ARG (0));
     len = ARG (1);
-    strncpy (dst, cmd, len);
-    write_log ("Sending '%s' to remote cli\n", cmd);
-    free (cmd);
+    s = ua (cmd);
+    strncpy (dst, s, len);
+    write_log (L"Sending '%s' to remote cli\n", cmd);
+    xfree (s);
+    xfree (cmd);
     return ARG (0);
 }
index 9872fd70e4aeccd47221045585ee1951244732f7..d1b81f3fc5740dff5634d67439039a2bea530a17 100644 (file)
--- a/uaeipc.c
+++ b/uaeipc.c
@@ -23,39 +23,39 @@ struct uaeipc
     uae_u8 buffer[IPC_BUFFER_SIZE], outbuf[IPC_BUFFER_SIZE];
     int connected, readpending, writepending;
     int binary;
-    char *outmsg[MAX_OUTMESSAGES];
+    TCHAR *outmsg[MAX_OUTMESSAGES];
     int outmessages;
     uae_u8 outbin[MAX_OUTMESSAGES][MAX_BINMESSAGE];
     int outbinlen[MAX_OUTMESSAGES];
 };
 
-static void parsemessage(char *in, struct uae_prefs *p, char *out, int outsize)
+static void parsemessage(TCHAR *in, struct uae_prefs *p, TCHAR *out, int outsize)
 {
     out[0] = 0;
-    if (!memcmp(in, "CFG ", 4) || !memcmp(in, "EVT ", 4)) {
-       char tmpout[256];
+    if (!_tcsncmp (in, L"CFG ", 4) || !_tcsncmp (in, L"EVT ", 4)) {
+       TCHAR tmpout[256];
        int index = -1;
        int cnt = 0;
        in += 4;
        for (;;) {
            int ret;
            tmpout[0] = 0;
-           ret = cfgfile_modify (index, in, strlen (in), tmpout, sizeof (tmpout));
+           ret = cfgfile_modify (index, in, _tcslen (in), tmpout, sizeof (tmpout) * sizeof (TCHAR));
            index++;
-           if (strlen(tmpout) > 0) {
-               if (strlen(out) == 0)
-                   strcat (out, "200 ");
-               strncat (out, "\n", outsize);
-               strncat (out, tmpout, outsize);
+           if (_tcslen (tmpout) > 0) {
+               if (_tcslen (out) == 0)
+                   _tcscat (out, L"200 ");
+               _tcsncat (out, L"\n", outsize);
+               _tcsncat (out, tmpout, outsize);
            }
            cnt++;
            if (ret >= 0)
                break;
        }
-       if (strlen (out) == 0)
-           strcat (out, "404");
+       if (_tcslen (out) == 0)
+           _tcscat (out, L"404");
     } else {
-       strcpy (out, "501");
+       _tcscpy (out, L"501");
     }
 }
 
@@ -66,19 +66,19 @@ static int listenIPC(struct uaeipc *ipc)
     memset(&ipc->ol, 0, sizeof (OVERLAPPED));
     ipc->ol.hEvent = ipc->olevent;
     if (ConnectNamedPipe(ipc->hipc, &ipc->ol)) {
-       write_log ("IPC: ConnectNamedPipe init failed, err=%d\n", GetLastError());
+       write_log (L"IPC: ConnectNamedPipe init failed, err=%d\n", GetLastError());
        closeIPC(ipc);
        return 0;
     }
     err = GetLastError();
     if (err == ERROR_PIPE_CONNECTED) {
        if (SetEvent(ipc->olevent)) {
-           write_log ("IPC: ConnectNamedPipe SetEvent failed, err=%d\n", GetLastError());
+           write_log (L"IPC: ConnectNamedPipe SetEvent failed, err=%d\n", GetLastError());
            closeIPC(ipc);
            return 0;
        }
     } else if (err != ERROR_IO_PENDING) {
-       write_log ("IPC: ConnectNamedPipe failed, err=%d\n", err);
+       write_log (L"IPC: ConnectNamedPipe failed, err=%d\n", err);
        closeIPC(ipc);
        return 0;
     }
@@ -90,7 +90,7 @@ static void disconnectIPC(struct uaeipc *ipc)
     ipc->readpending = ipc->writepending = FALSE;
     if (ipc->connected) {
        if (!DisconnectNamedPipe(ipc->hipc))
-           write_log ("IPC: DisconnectNamedPipe failed, err=%d\n", GetLastError());
+           write_log (L"IPC: DisconnectNamedPipe failed, err=%d\n", GetLastError());
        ipc->connected = FALSE;
     }
 }
@@ -116,9 +116,9 @@ void closeIPC(struct uaeipc *ipc)
     xfree (ipc);
 }
 
-void *createIPC(const char *name, int binary)
+void *createIPC(const TCHAR *name, int binary)
 {
-    char tmpname[100];
+    TCHAR tmpname[100];
     int cnt = 0;
     struct uaeipc *ipc;
 
@@ -129,18 +129,18 @@ void *createIPC(const char *name, int binary)
     ipc->olevent = INVALID_HANDLE_VALUE;
     ipc->binary = 1;
     while (cnt < 10) {
-       sprintf (tmpname, "\\\\.\\pipe\\%s", name);
+       _stprintf (tmpname, L"\\\\.\\pipe\\%s", name);
        if (cnt > 0) {
-           char *p = tmpname + strlen (tmpname);
-           sprintf(p, "_%d", cnt);
+           TCHAR *p = tmpname + _tcslen (tmpname);
+           _stprintf (p, L"_%d", cnt);
        }
-       ipc->hipc = CreateNamedPipe(tmpname,
+       ipc->hipc = CreateNamedPipe (tmpname,
            PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | FILE_FLAG_FIRST_PIPE_INSTANCE,
            PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
            1, IPC_BUFFER_SIZE, IPC_BUFFER_SIZE,
            NMPWAIT_USE_DEFAULT_WAIT, NULL);
        if (ipc->hipc == INVALID_HANDLE_VALUE) {
-           DWORD err = GetLastError();
+           DWORD err = GetLastError ();
            if (err == ERROR_ALREADY_EXISTS || err == ERROR_PIPE_BUSY) {
                cnt++;
                continue;
@@ -149,7 +149,7 @@ void *createIPC(const char *name, int binary)
        }
        break;
     }
-    write_log ("IPC: Named Pipe '%s' open\n", tmpname);
+    write_log (L"IPC: Named Pipe '%s' open\n", tmpname);
     ipc->olevent = CreateEvent(NULL, TRUE, TRUE, NULL);
     if (listenIPC(ipc))
        return ipc;
@@ -162,7 +162,7 @@ void *geteventhandleIPC(struct uaeipc *ipc)
     return ipc->olevent;
 }
 
-int sendIPC(struct uaeipc *ipc, char *msg)
+int sendIPC(struct uaeipc *ipc, TCHAR *msg)
 {
     if (ipc->hipc == INVALID_HANDLE_VALUE)
        return 0;
@@ -199,32 +199,32 @@ int checkIPC(struct uaeipc *ipc, struct uae_prefs *p)
        memset (&ipc->ol, 0, sizeof (OVERLAPPED));
        ipc->ol.hEvent = ipc->olevent;
        if (ipc->binary) {
-           ok = WriteFile(ipc->hipc, &ipc->outbin[ipc->outmessages][0], ipc->outbinlen[ipc->outmessages], &ret, &ipc->ol);
+           ok = WriteFile (ipc->hipc, &ipc->outbin[ipc->outmessages][0], ipc->outbinlen[ipc->outmessages], &ret, &ipc->ol);
        } else {
-           ok = WriteFile(ipc->hipc, ipc->outmsg[ipc->outmessages], strlen (ipc->outmsg[ipc->outmessages]) + 1, &ret, &ipc->ol);
+           ok = WriteFile (ipc->hipc, ipc->outmsg[ipc->outmessages], (_tcslen (ipc->outmsg[ipc->outmessages]) + 1) * sizeof (TCHAR), &ret, &ipc->ol);
        }
-       xfree(ipc->outmsg[ipc->outmessages--]);
-       err = GetLastError();
+       xfree (ipc->outmsg[ipc->outmessages--]);
+       err = GetLastError ();
        if (!ok && err != ERROR_IO_PENDING) {
-           write_log ("IPC: WriteFile() err=%d\n", err);
-           resetIPC(ipc);
+           write_log (L"IPC: WriteFile() err=%d\n", err);
+           resetIPC (ipc);
            return 0;
        }
        ipc->writepending = TRUE;
        return 1;
     }
     if (ipc->readpending || ipc->writepending) {
-       ok = GetOverlappedResult(ipc->hipc, &ipc->ol, &ret, FALSE);
+       ok = GetOverlappedResult (ipc->hipc, &ipc->ol, &ret, FALSE);
        if (!ok) {
-           err = GetLastError();
+           err = GetLastError ();
            if (err == ERROR_IO_INCOMPLETE)
                return 0;
-           write_log ("IPC: GetOverlappedResult error %d\n", err);
-           resetIPC(ipc);
+           write_log (L"IPC: GetOverlappedResult error %d\n", err);
+           resetIPC (ipc);
            return 0;
        }
        if (!ipc->connected) {
-           write_log ("IPC: Pipe connected\n");
+           write_log (L"IPC: Pipe connected\n");
            ipc->connected = TRUE;
            return 0;
        }
@@ -237,18 +237,18 @@ int checkIPC(struct uaeipc *ipc, struct uae_prefs *p)
        }
     }
     if (!ipc->readpending) {
-       ok = ReadFile(ipc->hipc, ipc->buffer, IPC_BUFFER_SIZE, &ret, &ipc->ol);
-       err = GetLastError();
+       ok = ReadFile (ipc->hipc, ipc->buffer, IPC_BUFFER_SIZE, &ret, &ipc->ol);
+       err = GetLastError ();
        if (!ok) {
            if (err == ERROR_IO_PENDING) {
                ipc->readpending = TRUE;
                return 0;
            } else if (err == ERROR_BROKEN_PIPE) {
-               write_log ("IPC: IPC client disconnected\n");
+               write_log (L"IPC: IPC client disconnected\n");
            } else {
-               write_log ("IPC: ReadFile() err=%d\n", err);
+               write_log (L"IPC: ReadFile() err=%d\n", err);
            }
-           resetIPC(ipc);
+           resetIPC (ipc);
            return 0;
        }
     }
@@ -256,15 +256,15 @@ int checkIPC(struct uaeipc *ipc, struct uae_prefs *p)
     if (ipc->binary) {
 
     } else {
-       write_log ("IPC: got message '%s'\n", ipc->buffer);
-       parsemessage((char*)ipc->buffer, p, (char*)ipc->outbuf, sizeof ipc->outbuf);
+       write_log (L"IPC: got message '%s'\n", ipc->buffer);
+       parsemessage ((TCHAR*)ipc->buffer, p, (TCHAR*)ipc->outbuf, sizeof ipc->outbuf);
        memset (&ipc->ol, 0, sizeof (OVERLAPPED));
        ipc->ol.hEvent = ipc->olevent;
-       ok = WriteFile(ipc->hipc, ipc->outbuf, strlen ((char*)ipc->outbuf) + 1, &ret, &ipc->ol);
-       err = GetLastError();
+       ok = WriteFile (ipc->hipc, ipc->outbuf, strlen ((char*)ipc->outbuf) + 1, &ret, &ipc->ol);
+       err = GetLastError ();
        if (!ok && err != ERROR_IO_PENDING) {
-           write_log ("IPC: WriteFile() err=%d\n", err);
-           resetIPC(ipc);
+           write_log (L"IPC: WriteFile() err=%d\n", err);
+           resetIPC (ipc);
            return 0;
        }
        ipc->writepending = TRUE;
@@ -272,7 +272,7 @@ int checkIPC(struct uaeipc *ipc, struct uae_prefs *p)
     return 1;
 }
 
-int isIPC (const char *pipename)
+int isIPC (const TCHAR *pipename)
 {
     HANDLE *p;
 
index b915e36eb1c753291c19426798028d2ed7e57727..2e323f7a714158662f4d2090f2d13393fc2d1987 100644 (file)
--- a/uaelib.c
+++ b/uaelib.c
@@ -135,7 +135,7 @@ static uae_u32 REGPARAM2 emulib_ChgCMemSize (struct regstruct *regs, uae_u32 mem
     if (memsize != 0x80000 && memsize != 0x100000 &&
        memsize != 0x200000) {
        memsize = 0x200000;
-       write_log ("Unsupported chipmem size!\n");
+       write_log (L"Unsupported chipmem size!\n");
     }
     m68k_dreg (regs, 0) = 0;
 
@@ -153,7 +153,7 @@ static uae_u32 REGPARAM2 emulib_ChgSMemSize (struct regstruct *regs, uae_u32 mem
     if (memsize != 0x80000 && memsize != 0x100000 &&
        memsize != 0x180000 && memsize != 0x1C0000) {
        memsize = 0;
-       write_log ("Unsupported bogomem size!\n");
+       write_log (L"Unsupported bogomem size!\n");
     }
 
     m68k_dreg (regs, 0) = 0;
@@ -171,7 +171,7 @@ static uae_u32 REGPARAM2 emulib_ChgFMemSize (struct regstruct *regs, uae_u32 mem
     if (memsize != 0x100000 && memsize != 0x200000 &&
        memsize != 0x400000 && memsize != 0x800000) {
        memsize = 0;
-       write_log ("Unsupported fastmem size!\n");
+       write_log (L"Unsupported fastmem size!\n");
     }
     m68k_dreg (regs, 0) = 0;
     currprefs.fastmem_size = memsize;
@@ -186,6 +186,7 @@ static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive)
 {
     int i = 0;
     char real_name[256];
+    TCHAR *s;
 
     if (drive > 3)
        return 0;
@@ -196,7 +197,9 @@ static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive)
     if (i == 255)
        return 0; /* ENAMETOOLONG */
 
-    strcpy (changed_prefs.df[drive], real_name);
+    s = au (real_name);
+    _tcscpy (changed_prefs.df[drive], s);
+    xfree (s);
 
     return 1;
 }
@@ -289,29 +292,6 @@ static uae_u32 emulib_Debug (void)
 #endif
 }
 
-/* We simply find the first "text" hunk, get the offset of its actual code segment (20 bytes away)
- * and add that offset to the base address of the object.  Now we've got code to execute.
- *
- * @@@ Brian: does anything actually use this yet?
- * @@@ Bernd: Not yet.  It needs to get much better.  Should spawn off a seperate task to handle the
- *            function, and then somehow "signal" the Amiga caller that completion or error has
- *            occurred.  I don't know how to do that, so right now it is a synchronous call.  Yuck!
- *            Would be nice to implement jpg decompression functionality for the Amiga which used
- *            the UAE Host to do all the work, for example.
- * @@@ Brian: I disabled it to prevent people from starting to use it - if that happens, we're
- *            stuck with this.
- */
-static uae_u32 FindFunctionInObject (uae_u8 *objectptr)
-{
-    uae_u8 *text_hdr;
-    uae_u8 offset;
-    text_hdr = (uae_u8 *)strstr ("text", (char *)objectptr);
-    if (text_hdr != 0) {
-       offset = *(text_hdr + 19);
-       return (uae_u32)(objectptr + offset);
-    }
-    return 0;
-}
 
 #define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func) (uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
                                                        uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32)
@@ -359,7 +339,8 @@ static uae_u32 emulib_Minimize (void)
 
 static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
+    char *s;
     int v, i;
 
     if (mode)
@@ -370,10 +351,12 @@ static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3)
     v = get_native_path (p1, tmp);
     if (v)
        return v;
-    for (i = 0; i <= strlen(tmp) && i < p3 - 1; i++) {
-       put_byte (p2 + i, tmp[i]);
+    s = ua (tmp);
+    for (i = 0; i <= strlen (s) && i < p3 - 1; i++) {
+       put_byte (p2 + i, s[i]);
        put_byte (p2 + i + 1, 0);
     }
+    xfree (s);
     return 0;
 }
 #ifndef UAEGFX_INTERNAL
@@ -429,7 +412,7 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context)
      case 85: return native_dos_op (ARG1, ARG2, ARG3, ARG4);
      case 86:
         if (valid_address (ARG1, 1))
-           write_log ("DBG: %s\n", get_real_address (ARG1));
+           write_log (L"DBG: %s\n", get_real_address (ARG1));
         return 1;
     }
     return 0;
@@ -442,19 +425,19 @@ static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context)
     struct regstruct *r = &context->regs;
 
     if (uaelib_debug)
-       write_log ("%d: %08x %08x %08x %08x %08x %08x %08x %08x, %08x %08x %08x %08x %08x %08x %08x %08x\n",
+       write_log (L"%d: %08x %08x %08x %08x %08x %08x %08x %08x, %08x %08x %08x %08x %08x %08x %08x %08x\n",
            ARG0,
            r->regs[0],r->regs[1],r->regs[2],r->regs[3],r->regs[4],r->regs[5],r->regs[6],r->regs[7],
            r->regs[8],r->regs[9],r->regs[10],r->regs[11],r->regs[12],r->regs[13],r->regs[14],r->regs[15]);
 #ifdef UAEGFX_INTERNAL
     if (ARG0 >= 16 && ARG0 <= 39) {
-       write_log ("uaelib: obsolete Picasso96 uaelib hook called, call ignored\n");
+       write_log (L"uaelib: obsolete Picasso96 uaelib hook called, call ignored\n");
        return 0;
     }
 #endif
     v = uaelib_demux2 (context);
     if (uaelib_debug)
-       write_log ("=%08x\n", v);
+       write_log (L"=%08x\n", v);
     return v;
 }
 
@@ -474,7 +457,7 @@ void emulib_install (void)
     dw ((rtarea_base >> 16) | get_word (rtarea_base + 36));
     dw (get_word (rtarea_base + 38) + 12);
 #endif
-    calltrap (deftrapres (uaelib_demux, 0, "uaelib_demux"));
+    calltrap (deftrapres (uaelib_demux, 0, L"uaelib_demux"));
     dw (RTS);
     org (a);
 }
index 397a595eaad125b7ad634840880e0fd92893d90d..2351505f6f071df6e8e0aa71544cc3b2bcbe67cf 100644 (file)
@@ -42,11 +42,17 @@ static uaecptr res_init, res_name, res_id, base;
 static uae_u32 REGPARAM2 res_getfunc (TrapContext *ctx)
 {
     uaecptr funcname = m68k_areg (&ctx->regs, 0);
-    char tmp[256];
+    uae_char tmp[256];
+    uae_u32 p;
+    TCHAR *s;
+
     if (funcname == 0)
        return 0;
     strcpyah_safe (tmp, funcname, sizeof tmp);
-    return find_trap (tmp);
+    s = au (tmp);
+    p = find_trap (s);
+    xfree (s);
+    return p;
 }
 
 static uae_u32 REGPARAM2 res_initcode (TrapContext *ctx)
@@ -80,10 +86,10 @@ void uaeres_install (void)
 {
     uae_u32 functable, datatable;
     uae_u32 initcode, getfunc;
-    char tmp[100];
+    TCHAR tmp[100];
 
-    sprintf (tmp, "UAE resource %d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
-    res_name = ds ("uae.resource");
+    _stprintf (tmp, L"UAE resource %d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
+    res_name = ds (L"uae.resource");
     res_id = ds (tmp);
 
     /* initcode */
index 2e4a6b2cddd0cf22d17c4c3de598a628753a38a9..d9d6dbb879324fbe670682afe983c198e6f6a9e6 100644 (file)
@@ -131,15 +131,15 @@ static uae_u32 nscmd_cmd;
 static struct devstruct devst[MAX_TOTAL_DEVICES];
 static uae_sem_t change_sem, async_sem;
 
-static char *getdevname (void)
+static TCHAR *getdevname (void)
 {
-    return "uaeserial.device";
+    return L"uaeserial.device";
 }
 
-static void io_log (char *msg, uaecptr request)
+static void io_log (TCHAR *msg, uaecptr request)
 {
     if (log_uaeserial)
-       write_log ("%s: %08X %d %08X %d %d io_actual=%d io_error=%d\n",
+       write_log (L"%s: %08X %d %08X %d %d io_actual=%d io_error=%d\n",
                   msg, request, get_word (request + 28), get_long (request + 40),
                   get_long (request + 36), get_long (request + 44),
                   get_long (request + 32), get_byte (request + 31));
@@ -160,7 +160,7 @@ static int start_thread (struct devstruct *dev)
 {
     init_comm_pipe (&dev->requests, 100, 1);
     uae_sem_init (&dev->sync_sem, 0, 0);
-    uae_start_thread ("uaeserial", dev_thread, dev, NULL);
+    uae_start_thread (L"uaeserial", dev_thread, dev, NULL);
     uae_sem_wait (&dev->sync_sem);
     return dev->thread_running;
 }
@@ -182,7 +182,7 @@ static uae_u32 REGPARAM2 dev_close (TrapContext *context)
     if (!dev)
        return 0;
     if (log_uaeserial)
-       write_log ("%s:%d close, req=%x\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d close, req=%x\n", getdevname(), dev->unit, request);
     dev_close_3 (dev);
     put_long (request + 24, 0);
     put_word (m68k_areg (&context->regs, 6) + 32, get_word (m68k_areg (&context->regs, 6) + 32) - 1);
@@ -213,13 +213,13 @@ static int setparams (struct devstruct *dev, uaecptr req)
     rbuffer = get_long (req + io_RBufLen);
     v = get_long (req + io_ExtFlags);
     if (v) {
-       write_log ("UAESER: io_ExtFlags=%08x, not supported\n", v);
+       write_log (L"UAESER: io_ExtFlags=%08x, not supported\n", v);
        return 5;
     }
     baud = get_long (req + io_Baud);
     v = get_byte (req + io_SerFlags);
     if (v & SERF_EOFMODE) {
-       write_log ("UAESER: SERF_EOFMODE not supported\n");
+       write_log (L"UAESER: SERF_EOFMODE not supported\n");
        return 5;
     }
     xonxoff = (v & SERF_XDISABLED) ? 0 : 1;
@@ -234,16 +234,16 @@ static int setparams (struct devstruct *dev, uaecptr req)
     wbits = get_byte (req + io_WriteLen);
     sbits = get_byte (req + io_StopBits);
     if ((rbits != 7 && rbits != 8) || (wbits != 7 && wbits != 8) || (sbits != 1 && sbits != 2) || rbits != wbits) {
-       write_log ("UAESER: Read=%d, Write=%d, Stop=%d, not supported\n", rbits, wbits, sbits);
+       write_log (L"UAESER: Read=%d, Write=%d, Stop=%d, not supported\n", rbits, wbits, sbits);
        return 5;
     }
-    write_log ("%s:%d BAUD=%d BUF=%d BITS=%d+%d RTSCTS=%d PAR=%d XO=%06X\n",
+    write_log (L"%s:%d BAUD=%d BUF=%d BITS=%d+%d RTSCTS=%d PAR=%d XO=%06X\n",
        getdevname(), dev->unit,
        baud, rbuffer, rbits, sbits, rtscts, parity, xonxoff);
     v = uaeser_setparams (dev->sysdata, baud, rbuffer,
        rbits, sbits, rtscts, parity, xonxoff);
     if (v) {
-       write_log ("->failed\n");
+       write_log (L"->failed\n");
        return v;
     }
     return 0;
@@ -296,7 +296,7 @@ static uae_u32 REGPARAM2 dev_open (TrapContext *context)
        return openfail (ioreq, err);
     }
     if (log_uaeserial)
-       write_log ("%s:%d open ioreq=%08X\n", getdevname(), unit, ioreq);
+       write_log (L"%s:%d open ioreq=%08X\n", getdevname(), unit, ioreq);
     start_thread (dev);
 
     put_word (m68k_areg (&context->regs, 6) + 32, get_word (m68k_areg (&context->regs, 6) + 32) + 1);
@@ -334,7 +334,7 @@ static int add_async_request (struct devstruct *dev, uaecptr request)
     struct asyncreq *ar, *ar2;
 
     if (log_uaeserial)
-       write_log ("%s:%d async request %x added\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d async request %x added\n", getdevname(), dev->unit, request);
 
     uae_sem_wait (&async_sem);
     ar = (struct asyncreq*)xcalloc (sizeof (struct asyncreq), 1);
@@ -367,14 +367,14 @@ static int release_async_request (struct devstruct *dev, uaecptr request)
            uae_sem_post (&async_sem);
            xfree (ar);
            if (log_uaeserial)
-               write_log ("%s:%d async request %x removed\n", getdevname(), dev->unit, request);
+               write_log (L"%s:%d async request %x removed\n", getdevname(), dev->unit, request);
            return 1;
        }
        prevar = ar;
        ar = ar->next;
     }
     uae_sem_post (&async_sem);
-    write_log ("%s:%d async request %x not found for removal!\n", getdevname(), dev->unit, request);
+    write_log (L"%s:%d async request %x not found for removal!\n", getdevname(), dev->unit, request);
     return 0;
 }
 
@@ -382,11 +382,11 @@ static void abort_async (struct devstruct *dev, uaecptr request)
 {
     struct asyncreq *ar = get_async_request (dev, request, 1);
     if (!ar) {
-       write_log ("%s:%d: abort async but no request %x found!\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d: abort async but no request %x found!\n", getdevname(), dev->unit, request);
        return;
     }
     if (log_uaeserial)
-       write_log ("%s:%d asyncronous request=%08X aborted\n", getdevname(), dev->unit, request);
+       write_log (L"%s:%d asyncronous request=%08X aborted\n", getdevname(), dev->unit, request);
     put_byte (request + 31, IOERR_ABORTED);
     put_byte (request + 30, get_byte (request + 30) | 0x20);
     write_comm_pipe_u32 (&dev->requests, request, 1);
@@ -451,13 +451,13 @@ void uaeser_signal (struct devstruct *dev, int sigmask)
                }
                break;
                default:
-                   write_log ("%s:%d incorrect async request %x (cmd=%d) signaled?!", getdevname(), dev->unit, request, command);
+                   write_log (L"%s:%d incorrect async request %x (cmd=%d) signaled?!", getdevname(), dev->unit, request, command);
                break;
            }
 
            if (io_done) {
                if (log_uaeserial)
-                   write_log ("%s:%d async request %x completed\n", getdevname(), dev->unit, request);
+                   write_log (L"%s:%d async request %x completed\n", getdevname(), dev->unit, request);
                put_long (request + 32, io_actual);
                put_byte (request + 31, io_error);
                ar->ready = 1;
@@ -501,7 +501,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request, int quick)
     if (!dev)
        return 0;
     command = get_word (request + 28);
-    io_log ("dev_io_START",request);
+    io_log (L"dev_io_START",request);
 
     switch (command)
     {
@@ -551,7 +551,7 @@ static int dev_do_io (struct devstruct *dev, uaecptr request, int quick)
     }
     put_long (request + 32, io_actual);
     put_byte (request + 31, io_error);
-    io_log ("dev_io_END",request);
+    io_log (L"dev_io_END",request);
     return async;
 }
 
@@ -575,7 +575,7 @@ static uae_u32 REGPARAM2 dev_beginio (TrapContext *context)
     put_byte (request + 31, 0);
     if ((flags & 1) && dev_canquick (dev, request)) {
        if (dev_do_io (dev, request, 1))
-           write_log ("device %s:%d command %d bug with IO_QUICK\n", getdevname(), dev->unit, command);
+           write_log (L"device %s:%d command %d bug with IO_QUICK\n", getdevname(), dev->unit, command);
        return get_byte (request + 31);
     } else {
        put_byte (request + 30, get_byte (request + 30) & ~1);
@@ -617,7 +617,7 @@ static uae_u32 REGPARAM2 dev_init (TrapContext *context)
 {
     uae_u32 base = m68k_dreg (&context->regs, 0);
     if (log_uaeserial)
-       write_log ("%s init\n", getdevname ());
+       write_log (L"%s init\n", getdevname ());
     return base;
 }
 
@@ -660,7 +660,7 @@ uaecptr uaeserialdev_startup (uaecptr resaddr)
     if (!currprefs.uaeserial)
        return resaddr;
     if (log_uaeserial)
-       write_log ("uaeserialdev_startup(0x%x)\n", resaddr);
+       write_log (L"uaeserialdev_startup(0x%x)\n", resaddr);
     /* Build a struct Resident. This will set up and initialize
      * the serial.device */
     put_word (resaddr + 0x0, 0x4AFC);
@@ -685,8 +685,8 @@ void uaeserialdev_install (void)
     if (!currprefs.uaeserial)
        return;
 
-    ROM_uaeserialdev_resname = ds ("uaeserial.device");
-    ROM_uaeserialdev_resid = ds ("UAE serial.device 0.1");
+    ROM_uaeserialdev_resname = ds (L"uaeserial.device");
+    ROM_uaeserialdev_resid = ds (L"UAE serial.device 0.1");
 
     /* initcode */
     initcode = here ();
diff --git a/zfile.c b/zfile.c
index 094d598206603e90d557bcb3daccc32524437055..246612abf03661e30ccf8e014df3398cc24cb304 100644 (file)
--- a/zfile.c
+++ b/zfile.c
@@ -28,7 +28,7 @@
 
 static struct zfile *zlist = 0;
 
-const char *uae_archive_extensions[] = { "zip", "rar", "7z", "lha", "lzh", "lzx", NULL };
+const TCHAR *uae_archive_extensions[] = { L"zip", L"rar", L"7z", L"lha", L"lzh", L"lzx", NULL };
 
 static struct zfile *zfile_create (void)
 {
@@ -48,8 +48,8 @@ static void zfile_free (struct zfile *f)
     if (f->f)
        fclose (f->f);
     if (f->deleteafterclose) {
-       unlink (f->name);
-       write_log ("deleted temporary file '%s'\n", f->name);
+       _wunlink (f->name);
+       write_log (L"deleted temporary file '%s'\n", f->name);
     }
     xfree (f->name);
     xfree (f->data);
@@ -75,7 +75,7 @@ void zfile_fclose (struct zfile *f)
        return;
     while (l != f) {
        if (l == 0) {
-           write_log ("zfile: tried to free already freed filehandle!\n");
+           write_log (L"zfile: tried to free already freed filehandle!\n");
            return;
        }
        pl = l;
@@ -92,16 +92,16 @@ void zfile_fclose (struct zfile *f)
        pl->next = nxt;
 }
 
-static uae_u8 exeheader[]={0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00};
-static char *diskimages[] = { "adf", "adz", "ipf", "fdi", "dms", "wrp", "dsq", 0 };
+static uae_u8 exeheader[]={ 0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00 };
+static TCHAR *diskimages[] = { L"adf", L"adz", L"ipf", L"fdi", L"dms", L"wrp", L"dsq", 0 };
 int zfile_gettype (struct zfile *z)
 {
     uae_u8 buf[8];
-    char *ext;
+    TCHAR *ext;
 
     if (!z || !z->name)
        return ZFILE_UNKNOWN;
-    ext = strrchr (z->name, '.');
+    ext = _tcsrchr (z->name, '.');
     if (ext != NULL) {
        int i;
        ext++;
@@ -109,17 +109,17 @@ int zfile_gettype (struct zfile *z)
            if (strcasecmp (ext, diskimages[i]) == 0)
                return ZFILE_DISKIMAGE;
        }
-       if (strcasecmp (ext, "roz") == 0)
+       if (strcasecmp (ext, L"roz") == 0)
            return ZFILE_ROM;
-       if (strcasecmp (ext, "uss") == 0)
+       if (strcasecmp (ext, L"uss") == 0)
            return ZFILE_STATEFILE;
-       if (strcasecmp (ext, "rom") == 0)
+       if (strcasecmp (ext, L"rom") == 0)
            return ZFILE_ROM;
-       if (strcasecmp (ext, "key") == 0)
+       if (strcasecmp (ext, L"key") == 0)
            return ZFILE_KEY;
-       if (strcasecmp (ext, "nvr") == 0)
+       if (strcasecmp (ext, L"nvr") == 0)
            return ZFILE_NVR;
-       if (strcasecmp (ext, "uae") == 0)
+       if (strcasecmp (ext, L"uae") == 0)
            return ZFILE_CONFIGURATION;
     }
     memset (buf, 0, sizeof (buf));
@@ -132,9 +132,9 @@ int zfile_gettype (struct zfile *z)
     if (!memcmp (buf, "DOS", 3))
        return ZFILE_HDF;
     if (ext != NULL) {
-       if (strcasecmp (ext, "hdf") == 0)
+       if (strcasecmp (ext, L"hdf") == 0)
            return ZFILE_HDF;
-       if (strcasecmp (ext, "hdz") == 0)
+       if (strcasecmp (ext, L"hdz") == 0)
            return ZFILE_HDF;
     }
     return ZFILE_UNKNOWN;
@@ -148,13 +148,13 @@ struct zfile *zfile_gunzip (struct zfile *z)
     z_stream zs;
     int i, size, ret, first;
     uae_u8 flags;
-    long offset;
-    char name[MAX_DPATH];
+    uae_s64 offset;
+    TCHAR name[MAX_DPATH];
     uae_u8 buffer[8192];
     struct zfile *z2;
     uae_u8 b;
 
-    strcpy (name, z->name);
+    _tcscpy (name, z->name);
     memset (&zs, 0, sizeof (zs));
     memset (header, 0, sizeof (header));
     zfile_fread (header, sizeof (header), 1, z);
@@ -228,7 +228,7 @@ static struct zfile *dsq (struct zfile *z)
 {
     struct zfile *zo;
 
-    zo = zfile_fopen_empty ("zipped.dsq", 1760 * 512);
+    zo = zfile_fopen_empty (L"zipped.dsq", 1760 * 512);
     if (zo) {
        struct zvolume *zv = archive_directory_lzx (z);
        if (zv) {
@@ -272,7 +272,7 @@ static struct zfile *dms (struct zfile *z)
     int ret;
     struct zfile *zo;
 
-    zo = zfile_fopen_empty ("undms.adf", 1760 * 512);
+    zo = zfile_fopen_empty (L"undms.adf", 1760 * 512);
     if (!zo)
        return z;
     ret = DMS_Process_File (z, zo, CMD_UNPACK, OPT_VERBOSE, 0, 0);
@@ -283,30 +283,30 @@ static struct zfile *dms (struct zfile *z)
     return z;
 }
 
-const char *uae_ignoreextensions[] =
-    { ".gif", ".jpg", ".png", ".xml", ".pdf", ".txt", 0 };
-const char *uae_diskimageextensions[] =
-    { ".adf", ".adz", ".ipf", ".fdi", ".exe", ".dms", ".wrp", ".dsq", 0 };
+const TCHAR *uae_ignoreextensions[] =
+    { L".gif", L".jpg", L".png", L".xml", L".pdf", L".txt", 0 };
+const TCHAR *uae_diskimageextensions[] =
+    { L".adf", L".adz", L".ipf", L".fdi", L".exe", L".dms", L".wrp", L".dsq", 0 };
 
-int zfile_is_ignore_ext (const char *name)
+int zfile_is_ignore_ext (const TCHAR *name)
 {
     int i;
 
     for (i = 0; uae_ignoreextensions[i]; i++) {
-       if (strlen(name) > strlen (uae_ignoreextensions[i]) &&
-           !strcasecmp (uae_ignoreextensions[i], name + strlen (name) - strlen (uae_ignoreextensions[i])))
+       if (_tcslen(name) > _tcslen (uae_ignoreextensions[i]) &&
+           !strcasecmp (uae_ignoreextensions[i], name + _tcslen (name) - _tcslen (uae_ignoreextensions[i])))
                return 1;
     }
     return 0;
 }
 
-int zfile_isdiskimage (const char *name)
+int zfile_isdiskimage (const TCHAR *name)
 {
     int i;
 
     i = 0;
     while (uae_diskimageextensions[i]) {
-       if (strlen (name) > 3 && !strcasecmp (name + strlen (name) - 4, uae_diskimageextensions[i]))
+       if (_tcslen (name) > 3 && !strcasecmp (name + _tcslen (name) - 4, uae_diskimageextensions[i]))
            return 1;
        i++;
     }
@@ -314,14 +314,14 @@ int zfile_isdiskimage (const char *name)
 }
 
 
-static const char *plugins_7z[] = { "7z", "rar", "zip", "lha", "lzh", "lzx", NULL };
-static const char *plugins_7z_x[] = { "7z", "Rar!", "MK", NULL, NULL, NULL, NULL };
+static const TCHAR *plugins_7z[] = { L"7z", L"rar", L"zip", L"lha", L"lzh", L"lzx", NULL };
+static const TCHAR *plugins_7z_x[] = { L"7z", L"Rar!", L"MK", NULL, NULL, NULL, NULL };
 static const int plugins_7z_t[] = { ArchiveFormat7Zip, ArchiveFormatRAR, ArchiveFormatZIP, ArchiveFormatLHA, ArchiveFormatLHA, ArchiveFormatLZX };
 
 int iszip (struct zfile *z)
 {
-    char *name = z->name;
-    char *ext = strrchr (name, '.');
+    TCHAR *name = z->name;
+    TCHAR *ext = _tcsrchr (name, '.');
     uae_u8 header[7];
     int i;
 
@@ -331,20 +331,20 @@ int iszip (struct zfile *z)
     zfile_fseek (z, 0, SEEK_SET);
     zfile_fread (header, sizeof (header), 1, z);
     zfile_fseek (z, 0, SEEK_SET);
-    if (!strcasecmp (ext, ".zip") && header[0] == 'P' && header[1] == 'K')
+    if (!strcasecmp (ext, L".zip") && header[0] == 'P' && header[1] == 'K')
        return ArchiveFormatZIP;
-    if (!strcasecmp (ext, ".7z") && header[0] == '7' && header[1] == 'z')
+    if (!strcasecmp (ext, L".7z") && header[0] == '7' && header[1] == 'z')
        return ArchiveFormat7Zip;
-    if (!strcasecmp (ext, ".rar") && header[0] == 'R' && header[1] == 'a' && header[2] == 'r' && header[3] == '!')
+    if (!strcasecmp (ext, L".rar") && header[0] == 'R' && header[1] == 'a' && header[2] == 'r' && header[3] == '!')
        return ArchiveFormatRAR;
-    if ((!strcasecmp (ext, ".lha") || !strcasecmp (ext, ".lzh")) && header[2] == '-' && header[3] == 'l' && header[4] == 'h' && header[6] == '-')
+    if ((!strcasecmp (ext, L".lha") || !strcasecmp (ext, L".lzh")) && header[2] == '-' && header[3] == 'l' && header[4] == 'h' && header[6] == '-')
        return ArchiveFormatLHA;
-    if (!strcasecmp (ext, ".lzx") && header[0] == 'L' && header[1] == 'Z' && header[2] == 'X')
+    if (!strcasecmp (ext, L".lzx") && header[0] == 'L' && header[1] == 'Z' && header[2] == 'X')
        return ArchiveFormatLZX;
 #if defined(ARCHIVEACCESS)
     for (i = 0; plugins_7z_x[i]; i++) {
        if (plugins_7z_x[i] && !strcasecmp (ext + 1, plugins_7z[i]) &&
-           !memcmp (header, plugins_7z_x[i], strlen (plugins_7z_x[i])))
+           !memcmp (header, plugins_7z_x[i], _tcslen (plugins_7z_x[i])))
                return plugins_7z_t[i];
     }
 #endif
@@ -353,36 +353,36 @@ int iszip (struct zfile *z)
 
 static struct zfile *zuncompress (struct zfile *z, int dodefault)
 {
-    char *name = z->name;
-    char *ext = strrchr (name, '.');
+    TCHAR *name = z->name;
+    TCHAR *ext = _tcsrchr (name, '.');
     uae_u8 header[7];
     int i;
 
     if (ext != NULL) {
        ext++;
-       if (strcasecmp (ext, "7z") == 0)
+       if (strcasecmp (ext, L"7z") == 0)
             return archive_access_select (z, ArchiveFormat7Zip, dodefault);
-       if (strcasecmp (ext, "zip") == 0)
+       if (strcasecmp (ext, L"zip") == 0)
             return archive_access_select (z, ArchiveFormatZIP, dodefault);
-       if (strcasecmp (ext, "lha") == 0 || strcasecmp (ext, "lzh") == 0)
+       if (strcasecmp (ext, L"lha") == 0 || strcasecmp (ext, L"lzh") == 0)
             return archive_access_select (z, ArchiveFormatLHA, dodefault);
-       if (strcasecmp (ext, "lzx") == 0)
+       if (strcasecmp (ext, L"lzx") == 0)
             return archive_access_select (z, ArchiveFormatLZX, dodefault);
-       if (strcasecmp (ext, "rar") == 0)
+       if (strcasecmp (ext, L"rar") == 0)
             return archive_access_select (z, ArchiveFormatRAR, dodefault);
-       if (strcasecmp (ext, "gz") == 0)
+       if (strcasecmp (ext, L"gz") == 0)
             return zfile_gunzip (z);
-       if (strcasecmp (ext, "adz") == 0)
+       if (strcasecmp (ext, L"adz") == 0)
             return zfile_gunzip (z);
-       if (strcasecmp (ext, "roz") == 0)
+       if (strcasecmp (ext, L"roz") == 0)
             return zfile_gunzip (z);
-       if (strcasecmp (ext, "hdz") == 0)
+       if (strcasecmp (ext, L"hdz") == 0)
             return zfile_gunzip (z);
-       if (strcasecmp (ext, "dms") == 0)
+       if (strcasecmp (ext, L"dms") == 0)
             return dms (z);
-       if (strcasecmp (ext, "wrp") == 0)
+       if (strcasecmp (ext, L"wrp") == 0)
             return wrp (z);
-       if (strcasecmp (ext, "dsq") == 0)
+       if (strcasecmp (ext, L"dsq") == 0)
             return dsq (z);
 #if defined(ARCHIVEACCESS)
        for (i = 0; plugins_7z_x[i]; i++) {
@@ -418,14 +418,14 @@ static struct zfile *zfile_opensinglefile(struct zfile *l)
 {
     uae_u8 *p = singlefile_data;
     int size, offset;
-    char tmp[256], *s;
+    TCHAR tmp[256], *s;
 
-    strcpy (tmp, l->name);
-    s = tmp + strlen (tmp) - 1;
+    _tcscpy (tmp, l->name);
+    s = tmp + _tcslen (tmp) - 1;
     while (*s != 0 && *s != '/' && *s != '\\') s--;
     if (s > tmp)
        s++;
-    write_log ("loading from singlefile: '%s'\n", tmp);
+    write_log (L"loading from singlefile: '%s'\n", tmp);
     while (*p++);
     offset = (p[0] << 24)|(p[1] << 16)|(p[2] << 8)|(p[3] << 0);
     p += 4;
@@ -436,19 +436,19 @@ static struct zfile *zfile_opensinglefile(struct zfile *l)
        if (!strcmpi (tmp, p + 4)) {
            l->data = singlefile_data + offset;
            l->size = size;
-           write_log ("found, size %d\n", size);
+           write_log (L"found, size %d\n", size);
            return l;
        }
        offset += size;
        p += 4;
-       p += strlen (p) + 1;
+       p += _tcslen (p) + 1;
     }
-    write_log ("not found\n");
+    write_log (L"not found\n");
     return 0;
 }
 #endif
 
-struct zfile *zfile_fopen_nozip (const char *name, const char *mode)
+struct zfile *zfile_fopen_nozip (const TCHAR *name, const TCHAR *mode)
 {
     struct zfile *l;
     FILE *f;
@@ -456,8 +456,8 @@ struct zfile *zfile_fopen_nozip (const char *name, const char *mode)
     if(*name == '\0')
        return NULL;
     l = zfile_create ();
-    l->name = strdup (name);
-    f = fopen (name, mode);
+    l->name = my_strdup (name);
+    f = _tfopen (name, mode);
     if (!f) {
        zfile_fclose (l);
        return 0;
@@ -467,24 +467,24 @@ struct zfile *zfile_fopen_nozip (const char *name, const char *mode)
 }
 
 
-static struct zfile *openzip (const char *pname)
+static struct zfile *openzip (const TCHAR *pname)
 {
     int i, j;
-    char v;
-    char name[MAX_DPATH];
-    char zippath[MAX_DPATH];
+    TCHAR v;
+    TCHAR name[MAX_DPATH];
+    TCHAR zippath[MAX_DPATH];
 
     zippath[0] = 0;
-    strcpy (name, pname);
-    i = strlen (name) - 2;
+    _tcscpy (name, pname);
+    i = _tcslen (name) - 2;
     while (i > 0) {
        if (name[i] == '/' || name[i] == '\\' && i > 4) {
            v = name[i];
            name[i] = 0;
            for (j = 0; plugins_7z[j]; j++) {
-               int len = strlen (plugins_7z[j]);
+               int len = _tcslen (plugins_7z[j]);
                if (name[i - len - 1] == '.' && !strcasecmp (name + i - len, plugins_7z[j])) {
-                   struct zfile *f = zfile_fopen_nozip (name, "rb");
+                   struct zfile *f = zfile_fopen_nozip (name, L"rb");
                    if (f) {
                        f->zipname = my_strdup (name + i + 1);
                        return f;
@@ -499,7 +499,7 @@ static struct zfile *openzip (const char *pname)
     return 0;
 }
 
-static struct zfile *zfile_fopen_2 (const char *name, const char *mode)
+static struct zfile *zfile_fopen_2 (const TCHAR *name, const TCHAR *mode)
 {
     struct zfile *l;
     FILE *f;
@@ -512,14 +512,14 @@ static struct zfile *zfile_fopen_2 (const char *name, const char *mode)
 #endif
     l = openzip (name);
     if (l) {
-       if (strcmpi (mode, "rb") && strcmpi (mode, "r")) {
+       if (_tcsicmp (mode, L"rb") && _tcsicmp (mode, L"r")) {
            zfile_fclose (l);
            return 0;
        }
     } else {
        l = zfile_create ();
-       l->name = strdup (name);
-       f = fopen (l->name, mode);
+       l->name = my_strdup (name);
+       f = _tfopen (l->name, mode);
        if (!f) {
            zfile_fclose (l);
            return 0;
@@ -532,32 +532,32 @@ static struct zfile *zfile_fopen_2 (const char *name, const char *mode)
 #ifdef _WIN32
 #include "win32.h"
 
-#define AF "%AMIGAFOREVERDATA%"
+#define AF L"%AMIGAFOREVERDATA%"
 
-static void manglefilename(char *out, const char *in)
+static void manglefilename (TCHAR *out, const TCHAR *in)
 {
     out[0] = 0;
-    if (!strncasecmp (in, AF, strlen(AF)))
-       strcpy (out, start_path_data);
-    if ((in[0] == '/' || in[0] == '\\') || (strlen(in) > 3 && in[1] == ':' && in[2] == '\\'))
+    if (!strncasecmp (in, AF, _tcslen (AF)))
+       _tcscpy (out, start_path_data);
+    if ((in[0] == '/' || in[0] == '\\') || (_tcslen(in) > 3 && in[1] == ':' && in[2] == '\\'))
        out[0] = 0;
-    strcat (out, in);
+    _tcscat (out, in);
 }
 #else
-static void manglefilename(char *out, const char *in)
+static void manglefilename(TCHAR *out, const TCHAR *in)
 {
-    strcpy(out, in);
+    _tcscpy(out, in);
 }
 #endif
 
-int zfile_zopen (const char *name, zfile_callback zc, void *user)
+int zfile_zopen (const TCHAR *name, zfile_callback zc, void *user)
 {
     struct zfile *l;
     int ztype;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
 
     manglefilename (path, name);
-    l = zfile_fopen_2 (path, "rb");
+    l = zfile_fopen_2 (path, L"rb");
     if (!l)
        return 0;
     ztype = iszip (l);
@@ -572,11 +572,11 @@ int zfile_zopen (const char *name, zfile_callback zc, void *user)
 /*
  * fopen() for a compressed file
  */
-struct zfile *zfile_fopen (const char *name, const char *mode)
+struct zfile *zfile_fopen (const TCHAR *name, const TCHAR *mode)
 {
     int cnt = 10;
     struct zfile *l, *l2;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
 
     manglefilename (path, name);
     l = zfile_fopen_2 (path, mode);
@@ -607,12 +607,12 @@ struct zfile *zfile_dup (struct zfile *zf)
     return nzf;
 }
 
-int zfile_exists (const char *name)
+int zfile_exists (const TCHAR *name)
 {
-    char fname[2000];
+    TCHAR fname[2000];
     struct zfile *f;
 
-    if (strlen (name) == 0)
+    if (_tcslen (name) == 0)
        return 0;
     manglefilename (fname, name);
     f = openzip (fname);
@@ -621,7 +621,7 @@ int zfile_exists (const char *name)
        manglefilename (fname, name);
        if (!my_existsfile (fname))
            return 0;
-       f2 = fopen (fname, "rb");
+       f2 = _tfopen (fname, L"rb");
        if (!f2)
            return 0;
        fclose (f2);
@@ -635,11 +635,11 @@ int zfile_iscompressed (struct zfile *z)
     return z->data ? 1 : 0;
 }
 
-struct zfile *zfile_fopen_empty (const char *name, int size)
+struct zfile *zfile_fopen_empty (const TCHAR *name, uae_u64 size)
 {
     struct zfile *l;
     l = zfile_create ();
-    l->name = name ? strdup (name) : "";
+    l->name = name ? my_strdup (name) : L"";
     if (size) {
        l->data = xcalloc (size, 1);
        l->size = size;
@@ -650,25 +650,25 @@ struct zfile *zfile_fopen_empty (const char *name, int size)
     return l;
 }
 
-struct zfile *zfile_fopen_data (const char *name, int size, uae_u8 *data)
+struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, uae_u8 *data)
 {
     struct zfile *l;
     l = zfile_create ();
-    l->name = name ? strdup (name) : "";
+    l->name = name ? my_strdup (name) : L"";
     l->data = xmalloc (size);
     l->size = size;
     memcpy (l->data, data, size);
     return l;
 }
 
-long zfile_ftell (struct zfile *z)
+uae_s64 zfile_ftell (struct zfile *z)
 {
     if (z->data)
        return z->seek;
-    return ftell (z->f);
+    return _ftelli64 (z->f);
 }
 
-int zfile_fseek (struct zfile *z, long offset, int mode)
+uae_s64 zfile_fseek (struct zfile *z, uae_s64 offset, int mode)
 {
     if (z->data) {
        int ret = 0;
@@ -694,7 +694,7 @@ int zfile_fseek (struct zfile *z, long offset, int mode)
        }
        return ret;
     }
-    return fseek (z->f, offset, mode);
+    return _fseeki64 (z->f, offset, mode);
 }
 
 size_t zfile_fread  (void *b, size_t l1, size_t l2,struct zfile *z)
@@ -733,15 +733,20 @@ size_t zfile_fwrite (void *b, size_t l1, size_t l2, struct zfile *z)
     return fwrite (b, l1, l2, z->f);
 }
 
-size_t zfile_fputs (struct zfile *z, char *s)
+size_t zfile_fputs (struct zfile *z, TCHAR *s)
 {
-    return zfile_fwrite (s, strlen (s), 1, z);
+    char *s2 = ua (s);
+    size_t t;
+    t = zfile_fwrite (s2, strlen (s2), 1, z);
+    xfree (s2);
+    return t;
 }
 
-char *zfile_fgets (char *s, int size, struct zfile *z)
+TCHAR *zfile_fgets (TCHAR *s, int size, struct zfile *z)
 {
     if (z->data) {
-       char *os = s;
+       char s2[MAX_DPATH];
+       char *p = s2;
        int i;
        for (i = 0; i < size - 1; i++) {
            if (z->seek == z->size) {
@@ -749,17 +754,28 @@ char *zfile_fgets (char *s, int size, struct zfile *z)
                    return NULL;
                break;
            }
-           *s = z->data[z->seek++];
-           if (*s == '\n') {
-               s++;
+           *p = z->data[z->seek++];
+           if (*p == '\n') {
+               p++;
                break;
            }
-           s++;
+           p++;
        }
-       *s = 0;
-       return os;
+       *p = 0;
+       if (size > strlen (s2) + 1)
+           size = strlen (s2) + 1;
+       au_copy (s, size, s2);
+       return s + size;
     } else {
-       return fgets (s, size, z->f);
+       char s2[MAX_DPATH];
+       char *s1;
+       s1 = fgets (s2, size, z->f);
+       if (!s1)
+           return NULL;
+       if (size > strlen (s2) + 1)
+           size = strlen (s2) + 1;
+       au_copy (s, size, s2);
+       return s + size;
     }
 }
 
@@ -786,9 +802,9 @@ int zfile_ferror (struct zfile *z)
     return 0;
 }
 
-char *zfile_getdata (struct zfile *z, int offset, int len)
+uae_u8 *zfile_getdata (struct zfile *z, uae_s64 offset, int len)
 {
-    size_t pos;
+    uae_s64 pos;
     uae_u8 *b;
     if (len < 0)
        len = z->size;
@@ -857,7 +873,7 @@ int zfile_zcompress (struct zfile *f, void *src, int size)
     return zs.total_out;
 }
 
-char *zfile_getname (struct zfile *f)
+TCHAR *zfile_getname (struct zfile *f)
 {
     return f->name;
 }
@@ -889,12 +905,12 @@ uae_u32 zfile_crc32 (struct zfile *f)
 
 static struct zvolume *zvolume_list;
 
-static struct znode *znode_alloc (struct znode *parent, const char *name)
+static struct znode *znode_alloc (struct znode *parent, const TCHAR *name)
 {
-    char fullpath[MAX_DPATH];
+    TCHAR fullpath[MAX_DPATH];
     struct znode *zn = xcalloc (sizeof (struct znode), 1);
 
-    sprintf (fullpath,"%s%c%s", parent->fullname, FSDB_DIR_SEPARATOR, name);
+    _stprintf (fullpath, L"%s%c%s", parent->fullname, FSDB_DIR_SEPARATOR, name);
     zn->fullname = my_strdup (fullpath);
     zn->name = my_strdup (name);
     zn->volume = parent->volume;
@@ -904,7 +920,7 @@ static struct znode *znode_alloc (struct znode *parent, const char *name)
     return zn;
 }
 
-static struct znode *znode_alloc_child (struct znode *parent, const char *name)
+static struct znode *znode_alloc_child (struct znode *parent, const TCHAR *name)
 {
     struct znode *zn = znode_alloc (parent, name);
 
@@ -919,7 +935,7 @@ static struct znode *znode_alloc_child (struct znode *parent, const char *name)
     zn->parent = parent;
     return zn;
 }
-static struct znode *znode_alloc_sibling (struct znode *sibling, const char *name)
+static struct znode *znode_alloc_sibling (struct znode *sibling, const TCHAR *name)
 {
     struct znode *zn = znode_alloc (sibling->parent, name);
 
@@ -949,11 +965,11 @@ static void zvolume_addtolist (struct zvolume *zv)
     }
 }
 
-static struct zvolume *zvolume_alloc_2 (const char *name, struct zfile *z, unsigned int id, void *handle)
+static struct zvolume *zvolume_alloc_2 (const TCHAR *name, struct zfile *z, unsigned int id, void *handle)
 {
     struct zvolume *zv = xcalloc (sizeof (struct zvolume), 1);
     struct znode *root;
-    size_t pos;
+    uae_s64 pos;
 
     root = &zv->root;
     zv->last = root;
@@ -976,17 +992,17 @@ struct zvolume *zvolume_alloc (struct zfile *z, unsigned int id, void *handle)
 {
     return zvolume_alloc_2 (zfile_getname (z), z, id, handle);
 }
-struct zvolume *zvolume_alloc_empty (const char *name)
+struct zvolume *zvolume_alloc_empty (const TCHAR *name)
 {
     return zvolume_alloc_2(name, 0, 0, 0);
 }
 
-static struct zvolume *get_zvolume (const char *path)
+static struct zvolume *get_zvolume (const TCHAR *path)
 {
     struct zvolume *zv = zvolume_list;
     while (zv) {
-       char *s = zfile_getname (zv->archive);
-       if (strlen (path) >= strlen(s) && !memcmp (path, s, strlen(s)))
+       TCHAR *s = zfile_getname (zv->archive);
+       if (_tcslen (path) >= _tcslen(s) && !memcmp (path, s, _tcslen(s)))
            return zv;
        zv = zv->next;
     }
@@ -996,19 +1012,19 @@ static struct zvolume *get_zvolume (const char *path)
 static struct zvolume *zfile_fopen_archive_ext (struct zfile *zf)
 {
     struct zvolume *zv = NULL;
-    char *ext = strrchr (zfile_getname(zf), '.');
+    TCHAR *ext = _tcsrchr (zfile_getname(zf), '.');
 
     if (ext != NULL) {
        ext++;
-       if (strcasecmp (ext, "lha") == 0 || strcasecmp (ext, "lzh") == 0)
+       if (strcasecmp (ext, L"lha") == 0 || strcasecmp (ext, L"lzh") == 0)
             zv = archive_directory_lha (zf);
-       if (strcasecmp (ext, "zip") == 0)
+       if (strcasecmp (ext, L"zip") == 0)
             zv = archive_directory_zip (zf);
-       if (strcasecmp (ext, "7z") == 0)
+       if (strcasecmp (ext, L"7z") == 0)
             zv = archive_directory_7z (zf);
-       if (strcasecmp (ext, "lzx") == 0)
+       if (strcasecmp (ext, L"lzx") == 0)
             zv = archive_directory_lzx (zf);
-       if (strcasecmp (ext, "rar") == 0)
+       if (strcasecmp (ext, L"rar") == 0)
             zv = archive_directory_rar (zf);
     }
     return zv;
@@ -1034,7 +1050,7 @@ struct zvolume *zfile_fopen_archive_data (struct zfile *zf)
     return zv;
 }
 
-static struct znode *get_znode (struct zvolume *zv, const char *ppath);
+static struct znode *get_znode (struct zvolume *zv, const TCHAR *ppath);
 
 static int zfile_fopen_archive_recurse (struct zvolume *zv)
 {
@@ -1044,15 +1060,15 @@ static int zfile_fopen_archive_recurse (struct zvolume *zv)
     added = 0;
     zn = zv->root.child;
     while (zn) {
-       char *ext = strrchr (zn->name, '.');
+       TCHAR *ext = _tcsrchr (zn->name, '.');
        if (ext && !zn->vchild && zn->isfile) {
            for (i = 0; plugins_7z[i]; i++) {
                if (!strcasecmp (ext + 1, plugins_7z[i])) {
                    struct zvolume *zvnew;
                    struct znode *zndir;
-                   char tmp[MAX_DPATH];
+                   TCHAR tmp[MAX_DPATH];
 
-                   sprintf (tmp, "%s.DIR", zn->fullname + strlen (zv->root.name) + 1);
+                   _stprintf (tmp, L"%s.DIR", zn->fullname + _tcslen (zv->root.name) + 1);
                    zndir = get_znode (zv, tmp);
                    if (!zndir) {
                        struct zarchive_info zai = { 0 };
@@ -1072,22 +1088,22 @@ static int zfile_fopen_archive_recurse (struct zvolume *zv)
     return 0;
 }
 
-static void recursivepath (char *path, struct zvolume *zv)
+static void recursivepath (TCHAR *path, struct zvolume *zv)
 {
-    char tmp[2] = { FSDB_DIR_SEPARATOR, 0 };
+    TCHAR tmp[2] = { FSDB_DIR_SEPARATOR, 0 };
     if (!zv)
        return;
     recursivepath (path, zv->parent);
-    strcat (path, zv->root.fullname);
-    strcat (path, tmp);
+    _tcscat (path, zv->root.fullname);
+    _tcscat (path, tmp);
 }
 
-static struct zvolume *prepare_recursive_volume (struct zvolume *zv, const char *path)
+static struct zvolume *prepare_recursive_volume (struct zvolume *zv, const TCHAR *path)
 {
     struct zfile *zf = NULL;
     struct zvolume *zvnew = NULL;
 
-    write_log ("unpacking '%s'\n", path);
+    write_log (L"unpacking '%s'\n", path);
     zf = zfile_open_archive (path, 0);
     if (!zf)
        goto end;
@@ -1099,39 +1115,39 @@ static struct zvolume *prepare_recursive_volume (struct zvolume *zv, const char
     zfile_fclose_archive (zv);
     return zvnew;
 end:
-    write_log ("unpack failed\n");
+    write_log (L"unpack failed\n");
     zfile_fclose_archive (zvnew);
     zfile_fclose (zf);
     return NULL;
 }
 
-static struct znode *get_znode (struct zvolume *zv, const char *ppath)
+static struct znode *get_znode (struct zvolume *zv, const TCHAR *ppath)
 {
     struct znode *zn;
     int prevlen = 0;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
 
     if (!zv)
        return NULL;
-    strcpy (path, ppath);
+    _tcscpy (path, ppath);
     zn = &zv->root;
     while (zn) {
        if (zn->isfile) {
-           if (!stricmp (zn->fullname, path))
+           if (!_tcsicmp (zn->fullname, path))
                return zn;
        } else {
-           int len = strlen (zn->fullname);
-           if (strlen (path) >= len && (path[len] == 0 || path[len] == FSDB_DIR_SEPARATOR) && !strnicmp (zn->fullname, path, len)) {
+           int len = _tcslen (zn->fullname);
+           if (_tcslen (path) >= len && (path[len] == 0 || path[len] == FSDB_DIR_SEPARATOR) && !_tcsncmp (zn->fullname, path, len)) {
                if (path[len] == 0)
                    return zn;
                if (zn->vchild) {
                    /* jump to separate tree, recursive archives */
                    struct zvolume *zvdeep = zn->vchild;
-                   char *p = path + prevlen + 1;
+                   TCHAR *p = path + prevlen + 1;
                    if (zvdeep->archive == NULL) {
                        zvdeep = prepare_recursive_volume (zvdeep, zn->fullname);
                        if (!zvdeep) {
-                           write_log ("failed to unpack '%s'\n", zn->fullname);
+                           write_log (L"failed to unpack '%s'\n", zn->fullname);
                            return NULL;
                        }
                        /* replace dummy empty volume with real volume */
@@ -1143,9 +1159,9 @@ static struct znode *get_znode (struct zvolume *zv, const char *ppath)
                    if (*p == 0)
                        return NULL;
                    p++;
-                   strcpy (path, zn->volume->root.name);
-                   memmove (path + strlen (path) + 1, p, strlen (p) + 1);
-                   path[strlen(path)] = FSDB_DIR_SEPARATOR;
+                   _tcscpy (path, zn->volume->root.name);
+                   memmove (path + _tcslen (path) + 1, p, _tcslen (p) + 1);
+                   path[_tcslen(path)] = FSDB_DIR_SEPARATOR;
                } else {
                    zn = zn->child;
                }
@@ -1159,9 +1175,9 @@ static struct znode *get_znode (struct zvolume *zv, const char *ppath)
 }
 
 
-static void addvolumesize (struct zvolume *zv, int size)
+static void addvolumesize (struct zvolume *zv, uae_s64 size)
 {
-    int blocks = (size + 511) / 512;
+    unsigned int blocks = (size + 511) / 512;
 
     if (blocks == 0)
        blocks++;
@@ -1172,12 +1188,12 @@ static void addvolumesize (struct zvolume *zv, int size)
     }
 }
 
-struct znode *znode_adddir (struct znode *parent, const char *name, struct zarchive_info *zai)
+struct znode *znode_adddir (struct znode *parent, const TCHAR *name, struct zarchive_info *zai)
 {
     struct znode *zn;
-    char path[MAX_DPATH];
+    TCHAR path[MAX_DPATH];
 
-    sprintf(path, "%s%c%s", parent->fullname, FSDB_DIR_SEPARATOR, name);
+    _stprintf (path, L"%s%c%s", parent->fullname, FSDB_DIR_SEPARATOR, name);
     zn = get_znode (parent->volume, path);
     if (zn)
        return zn;
@@ -1190,16 +1206,16 @@ struct znode *znode_adddir (struct znode *parent, const char *name, struct zarch
 struct znode *zvolume_adddir_abs (struct zvolume *zv, struct zarchive_info *zai)
 {
     struct znode *zn2;
-    char *path = my_strdup (zai->name);
-    char *p, *p2;
+    TCHAR *path = my_strdup (zai->name);
+    TCHAR *p, *p2;
     int i;
 
-    if (strlen (path) > 0) {
+    if (_tcslen (path) > 0) {
        /* remove possible trailing / or \ */
-       char last;
-       last = path[strlen (path) - 1];
+       TCHAR last;
+       last = path[_tcslen (path) - 1];
        if (last == '/' || last == '\\')
-           path[strlen (path) - 1] = 0;
+           path[_tcslen (path) - 1] = 0;
     }
     zn2 = &zv->root;
     p = p2 = path;
@@ -1218,8 +1234,8 @@ struct znode *zvolume_addfile_abs (struct zvolume *zv, struct zarchive_info *zai
 {
     struct znode *zn, *zn2;
     int i;
-    char *path = my_strdup (zai->name);
-    char *p, *p2;
+    TCHAR *path = my_strdup (zai->name);
+    TCHAR *p, *p2;
 
     zn2 = &zv->root;
     p = p2 = path;
@@ -1245,10 +1261,10 @@ struct znode *zvolume_addfile_abs (struct zvolume *zv, struct zarchive_info *zai
     return zn;
 }
 
-struct zvolume *zfile_fopen_archive (const char *filename)
+struct zvolume *zfile_fopen_archive (const TCHAR *filename)
 {
     struct zvolume *zv = NULL;
-    struct zfile *zf = zfile_fopen_nozip (filename, "rb");
+    struct zfile *zf = zfile_fopen_nozip (filename, L"rb");
 
     if (!zf)
        return NULL;
@@ -1309,7 +1325,7 @@ struct zdirectory {
     struct znode *n;
 };
 
-void *zfile_opendir_archive (const char *path)
+void *zfile_opendir_archive (const TCHAR *path)
 {
     struct zvolume *zv = get_zvolume (path);
     struct znode *zn = get_znode (zv, path);
@@ -1333,16 +1349,16 @@ void zfile_closedir_archive (struct zdirectory *zd)
 {
     xfree (zd);
 }
-int zfile_readdir_archive (struct zdirectory *zd, char *out)
+int zfile_readdir_archive (struct zdirectory *zd, TCHAR *out)
 {
     if (!zd->n)
        return 0;
-    strcpy (out, zd->n->name);
+    _tcscpy (out, zd->n->name);
     zd->n = zd->n->sibling;
     return 1;
 }
 
-int zfile_fill_file_attrs_archive (const char *path, int *isdir, int *flags, char **comment)
+int zfile_fill_file_attrs_archive (const TCHAR *path, int *isdir, int *flags, TCHAR **comment)
 {
     struct zvolume *zv = get_zvolume (path);
     struct znode *zn = get_znode (zv, path);
@@ -1359,7 +1375,7 @@ int zfile_fill_file_attrs_archive (const char *path, int *isdir, int *flags, cha
     return 1;
 }
 
-int zfile_fs_usage_archive (const char *path, const char *disk, struct fs_usage *fsp)
+int zfile_fs_usage_archive (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp)
 {
     struct zvolume *zv = get_zvolume (path);
 
@@ -1370,7 +1386,7 @@ int zfile_fs_usage_archive (const char *path, const char *disk, struct fs_usage
     return 0;
 }
 
-int zfile_stat_archive (const char *path, struct stat *s)
+int zfile_stat_archive (const TCHAR *path, struct _stat64 *s)
 {
     struct zvolume *zv = get_zvolume (path);
     struct znode *zn = get_znode (zv, path);
@@ -1383,7 +1399,7 @@ int zfile_stat_archive (const char *path, struct stat *s)
     return 1;
 }
 
-unsigned int zfile_lseek_archive (void *d, unsigned int offset, int whence)
+uae_s64 zfile_lseek_archive (void *d, uae_s64 offset, int whence)
 {
     if (zfile_fseek (d, offset, whence))
        return -1;
@@ -1400,7 +1416,7 @@ void zfile_close_archive (void *d)
     /* do nothing, keep file cached */
 }
 
-void *zfile_open_archive (const char *path, int flags)
+void *zfile_open_archive (const TCHAR *path, int flags)
 {
     struct zvolume *zv = get_zvolume (path);
     struct znode *zn = get_znode (zv, path);
@@ -1421,13 +1437,13 @@ void *zfile_open_archive (const char *path, int flags)
     return zn->f;
 }
 
-int zfile_exists_archive (const char *path, const char *rel)
+int zfile_exists_archive (const TCHAR *path, const TCHAR *rel)
 {
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
     struct zvolume *zv;
     struct znode *zn;
 
-    sprintf (tmp, "%s%c%s", path, FSDB_DIR_SEPARATOR, rel);
+    _stprintf (tmp, L"%s%c%s", path, FSDB_DIR_SEPARATOR, rel);
     zv = get_zvolume (tmp);
     zn = get_znode (zv, tmp);
     return zn ? 1 : 0;
index d6636ac7783c2b17b48a3ff71f0f57aa817af0e2..b7c918ba8232f8e02f01bf28410ef71d0f834916 100644 (file)
 #include "win32.h"
 #endif
 
-static time_t fromdostime(uae_u32 dd)
+static time_t fromdostime (uae_u32 dd)
 {
     struct tm tm;
     time_t t;
-    memset(&tm, 0, sizeof tm);
+
+    memset (&tm, 0, sizeof tm);
     tm.tm_hour = (dd >> 11) & 0x1f;
     tm.tm_min  = (dd >> 5) & 0x3f;
     tm.tm_sec  = ((dd >> 0) & 0x1f) * 2;
     tm.tm_year = ((dd >> 25) & 0x7f) + 80;
     tm.tm_mon  = ((dd >> 21) & 0x0f) - 1;
     tm.tm_mday = (dd >> 16) & 0x1f;
-    t = mktime(&tm);
-    _tzset();
+    t = mktime (&tm);
+    _tzset ();
     t -= _timezone;
     return t;
 }
 
-static struct zvolume *getzvolume(struct zfile *zf, unsigned int id)
+static struct zvolume *getzvolume (struct zfile *zf, unsigned int id)
 {
     struct zvolume *zv;
 
@@ -105,11 +106,11 @@ struct zfile *archive_access_select (struct zfile *zf, unsigned int id, int dode
     struct zvolume *zv;
     struct znode *zn;
     int zipcnt, first, select;
-    char tmphist[MAX_DPATH];
+    TCHAR tmphist[MAX_DPATH];
     struct zfile *z = NULL;
     int we_have_file;
 
-    zv = getzvolume(zf, id);
+    zv = getzvolume (zf, id);
     if (!zv)
        return zf;
     we_have_file = 0;
@@ -122,7 +123,7 @@ struct zfile *archive_access_select (struct zfile *zf, unsigned int id, int dode
 
        if (!zn->isfile)
            isok = 0;
-       if (zfile_is_ignore_ext(zn->fullname))
+       if (zfile_is_ignore_ext (zn->fullname))
            isok = 0;
        if (isok) {
            if (tmphist[0]) {
@@ -132,26 +133,26 @@ struct zfile *archive_access_select (struct zfile *zf, unsigned int id, int dode
            }
            if (first) {
                if (zfile_isdiskimage (zn->fullname))
-                   strcpy (tmphist, zn->fullname);
+                   _tcscpy (tmphist, zn->fullname);
            } else {
-               strcpy (tmphist, zn->fullname);
+               _tcscpy (tmphist, zn->fullname);
                DISK_history_add (tmphist, -1);
                tmphist[0] = 0;
            }
            select = 0;
            if (!zf->zipname)
                select = 1;
-           if (zf->zipname && strlen (zn->fullname) >= strlen (zf->zipname) && !strcasecmp (zf->zipname, zn->fullname + strlen (zn->fullname) - strlen (zf->zipname)))
+           if (zf->zipname && _tcslen (zn->fullname) >= _tcslen (zf->zipname) && !strcasecmp (zf->zipname, zn->fullname + _tcslen (zn->fullname) - _tcslen (zf->zipname)))
                select = -1;
-           if (zf->zipname && zf->zipname[0] == '#' && atol (zf->zipname + 1) == zipcnt)
+           if (zf->zipname && zf->zipname[0] == '#' && _tstol (zf->zipname + 1) == zipcnt)
                select = -1;
            if (select && !we_have_file) {
-               z = archive_getzfile(zn, id);
+               z = archive_getzfile (zn, id);
                if (z) {
                    if (select < 0 || zfile_gettype (z))
                        we_have_file = 1;
                    if (!we_have_file) {
-                       zfile_fclose(z);
+                       zfile_fclose (z);
                        z = NULL;
                    }
                }
@@ -164,10 +165,10 @@ struct zfile *archive_access_select (struct zfile *zf, unsigned int id, int dode
        DISK_history_add (zfile_getname(zf), -1);
     zfile_fclose_archive (zv);
     if (z) {
-       zfile_fclose(zf);
+       zfile_fclose (zf);
        zf = z;
     } else if (!dodefault && zf->zipname && zf->zipname[0]) {
-       zfile_fclose(zf);
+       zfile_fclose (zf);
        zf = NULL;
     }
     return zf;
@@ -196,7 +197,7 @@ void archive_access_scan (struct zfile *zf, zfile_callback zc, void *user, unsig
                    zfile_fclose (zf2);
                } else {
                    int ret = zc (zf2, user);
-                   zfile_fclose(zf2);
+                   zfile_fclose (zf2);
                    if (ret)
                        break;
                }
@@ -218,7 +219,6 @@ struct zvolume *archive_directory_zip (struct zfile *z)
 {
     unzFile uz;
     unz_file_info file_info;
-    char filename_inzip[MAX_DPATH];
     struct zvolume *zv;
     int err;
 
@@ -227,21 +227,25 @@ struct zvolume *archive_directory_zip (struct zfile *z)
        return 0;
     if (unzGoToFirstFile (uz) != UNZ_OK)
        return 0;
-    zv = zvolume_alloc(z, ArchiveFormatZIP, uz);
+    zv = zvolume_alloc (z, ArchiveFormatZIP, uz);
     for (;;) {
-       char c;
+       char filename_inzip2[MAX_DPATH];
+       TCHAR c;
        struct zarchive_info zai;
        time_t t;
        unsigned int dd;
-       err = unzGetCurrentFileInfo(uz, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0);
+        TCHAR *filename_inzip;
+
+       err = unzGetCurrentFileInfo (uz, &file_info, filename_inzip2, sizeof (filename_inzip2), NULL, 0, NULL, 0);
        if (err != UNZ_OK)
            return 0;
+       filename_inzip = au (filename_inzip2);
        dd = file_info.dosDate;
-       t = fromdostime(dd);
+       t = fromdostime (dd);
        memset(&zai, 0, sizeof zai);
        zai.name = filename_inzip;
        zai.t = t;
-       c = filename_inzip[strlen(filename_inzip) - 1];
+       c = filename_inzip[_tcslen (filename_inzip) - 1];
        if (c != '/' && c != '\\') {
            int err = unzOpenCurrentFile (uz);
            if (err == UNZ_OK) {
@@ -250,9 +254,10 @@ struct zvolume *archive_directory_zip (struct zfile *z)
                zn = zvolume_addfile_abs(zv, &zai);
            }
        } else {
-           filename_inzip[strlen(filename_inzip) - 1] = 0;
-           zvolume_adddir_abs(zv, &zai);
+           filename_inzip[_tcslen (filename_inzip) - 1] = 0;
+           zvolume_adddir_abs (zv, &zai);
        }
+       xfree (filename_inzip);
        err = unzGoToNextFile (uz);
        if (err != UNZ_OK)
            break;
@@ -267,23 +272,31 @@ struct zfile *archive_access_zip (struct znode *zn)
     struct zfile *z = NULL;
     unzFile uz = zn->volume->handle;
     int i, err;
-    char tmp[MAX_DPATH];
+    TCHAR tmp[MAX_DPATH];
+    char *s;
 
-    strcpy (tmp, zn->fullname + strlen(zn->volume->root.fullname) + 1);
+    _tcscpy (tmp, zn->fullname + _tcslen(zn->volume->root.fullname) + 1);
     if (unzGoToFirstFile (uz) != UNZ_OK)
        return 0;
     for (i = 0; tmp[i]; i++) {
        if (tmp[i] == '\\')
            tmp[i] = '/';
     }
-    if (unzLocateFile (uz, tmp, 1) != UNZ_OK) {
+    s = ua (tmp);
+    if (unzLocateFile (uz, s, 1) != UNZ_OK) {
+       xfree (s);
        for (i = 0; tmp[i]; i++) {
            if (tmp[i] == '/')
                tmp[i] = '\\';
        }
-       if (unzLocateFile (uz, tmp, 1) != UNZ_OK)
+       s = ua (tmp);
+       if (unzLocateFile (uz, s, 1) != UNZ_OK) {
+           xfree (s);
            return 0;
+       }
     }
+    xfree (s);
+    s = NULL;
     if (unzOpenCurrentFile (uz) != UNZ_OK)
        return 0;
     z = zfile_fopen_empty (zn->fullname, zn->size);
@@ -309,10 +322,10 @@ typedef struct _CFileInStream
 static ISzAlloc allocImp;
 static ISzAlloc allocTempImp;
 
-static SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size, size_t *processedSize)
+static SZ_RESULT SzFileReadImp (void *object, void *buffer, size_t size, size_t *processedSize)
 {
   CFileInStream *s = (CFileInStream *)object;
-  size_t processedSizeLoc = zfile_fread(buffer, 1, size, s->zf);
+  size_t processedSizeLoc = zfile_fread (buffer, 1, size, s->zf);
   if (processedSize != 0)
     *processedSize = processedSizeLoc;
   return SZ_OK;
@@ -321,7 +334,7 @@ static SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size, size_t *
 static SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
 {
   CFileInStream *s = (CFileInStream *)object;
-  int res = zfile_fseek(s->zf, pos, SEEK_SET);
+  int res = zfile_fseek (s->zf, pos, SEEK_SET);
   if (res == 0)
     return SZ_OK;
   return SZE_FAIL;
@@ -338,7 +351,7 @@ static void init_7z(void)
     allocImp.Free = SzFree;
     allocTempImp.Alloc = SzAllocTemp;
     allocTempImp.Free = SzFreeTemp;
-    InitCrcTable();
+    InitCrcTable ();
 }
 
 struct SevenZContext
@@ -352,9 +365,9 @@ struct SevenZContext
 
 static void archive_close_7z (struct SevenZContext *ctx)
 {
-    SzArDbExFree(&ctx->db, allocImp.Free);
-    allocImp.Free(ctx->outBuffer);
-    xfree(ctx);
+    SzArDbExFree (&ctx->db, allocImp.Free);
+    allocImp.Free (ctx->outBuffer);
+    xfree (ctx);
 }
 
 struct zvolume *archive_directory_7z (struct zfile *z)
@@ -369,26 +382,27 @@ struct zvolume *archive_directory_7z (struct zfile *z)
     ctx->blockIndex = 0xffffffff;
     ctx->archiveStream.InStream.Read = SzFileReadImp;
     ctx->archiveStream.InStream.Seek = SzFileSeekImp;
-    SzArDbExInit(&ctx->db);
+    SzArDbExInit (&ctx->db);
     ctx->archiveStream.zf = z;
-    res = SzArchiveOpen(&ctx->archiveStream.InStream, &ctx->db, &allocImp, &allocTempImp);
+    res = SzArchiveOpen (&ctx->archiveStream.InStream, &ctx->db, &allocImp, &allocTempImp);
     if (res != SZ_OK) {
-       write_log ("7Z: SzArchiveOpen %s returned %d\n", zfile_getname(z), res);
+       write_log (L"7Z: SzArchiveOpen %s returned %d\n", zfile_getname(z), res);
        return NULL;
     }
-    zv = zvolume_alloc(z, ArchiveFormat7Zip, ctx);
+    zv = zvolume_alloc (z, ArchiveFormat7Zip, ctx);
     for (i = 0; i < ctx->db.Database.NumFiles; i++) {
        CFileItem *f = ctx->db.Database.Files + i;
-       char *name = f->Name;
+       TCHAR *name = au (f->Name);
        struct zarchive_info zai;
 
        memset(&zai, 0, sizeof zai);
        zai.name = name;
        zai.size = f->Size;
        if (!f->IsDirectory) {
-           struct znode *zn = zvolume_addfile_abs(zv, &zai);
+           struct znode *zn = zvolume_addfile_abs (zv, &zai);
            zn->offset = i;
        }
+       xfree (name);
     }
     zv->method = ArchiveFormat7Zip;
     return zv;
@@ -404,7 +418,7 @@ struct zfile *archive_access_7z (struct znode *zn)
     struct SevenZContext *ctx;
 
     ctx = zv->handle;
-    res = SzExtract(&ctx->archiveStream.InStream, &ctx->db, zn->offset,
+    res = SzExtract (&ctx->archiveStream.InStream, &ctx->db, zn->offset,
                    &ctx->blockIndex, &ctx->outBuffer, &ctx->outBufferSize,
                    &offset, &outSizeProcessed,
                    &allocImp, &allocTempImp);
@@ -412,7 +426,7 @@ struct zfile *archive_access_7z (struct znode *zn)
        z = zfile_fopen_empty (zn->fullname, zn->size);
        zfile_fwrite (ctx->outBuffer + offset, zn->size, 1, z);
     } else {
-       write_log ("7Z: SzExtract %s returned %d\n", zn->fullname, res);
+       write_log (L"7Z: SzExtract %s returned %d\n", zn->fullname, res);
     }
     return z;
 }
@@ -428,7 +442,7 @@ typedef HANDLE (_stdcall* RAROPENARCHIVE)(struct RAROpenArchiveData*);
 static RAROPENARCHIVE pRAROpenArchive;
 typedef int (_stdcall* RARREADHEADEREX)(HANDLE,struct RARHeaderDataEx*);
 static RARREADHEADEREX pRARReadHeaderEx;
-typedef int (_stdcall* RARPROCESSFILE)(HANDLE,int,char*,char *);
+typedef int (_stdcall* RARPROCESSFILE)(HANDLE,int,char*,char*);
 static RARPROCESSFILE pRARProcessFile;
 typedef int (_stdcall* RARCLOSEARCHIVE)(HANDLE);
 static RARCLOSEARCHIVE pRARCloseArchive;
@@ -437,9 +451,9 @@ static RARSETCALLBACK pRARSetCallback;
 typedef int (_stdcall* RARGETDLLVERSION)(void);
 static RARGETDLLVERSION pRARGetDllVersion;
 
-static int rar_resetf(struct zfile *z)
+static int rar_resetf (struct zfile *z)
 {
-    z->f = fopen (z->name, "rb");
+    z->f = _tfopen (z->name, L"rb");
     if (!z->f) {
        zfile_fclose (z);
        return 0;
@@ -457,7 +471,7 @@ static int canrar(void)
        {
            HMODULE rarlib;
 
-           rarlib = WIN32_LoadLibrary("unrar.dll");
+           rarlib = WIN32_LoadLibrary (L"unrar.dll");
            if (rarlib) {
                pRAROpenArchive = (RAROPENARCHIVE)GetProcAddress (rarlib, "RAROpenArchive");
                pRARReadHeaderEx = (RARREADHEADEREX)GetProcAddress (rarlib, "RARReadHeaderEx");
@@ -467,7 +481,7 @@ static int canrar(void)
                pRARGetDllVersion = (RARGETDLLVERSION)GetProcAddress (rarlib, "RARGetDllVersion");
                if (pRAROpenArchive && pRARReadHeaderEx && pRARProcessFile && pRARCloseArchive && pRARSetCallback) {
                    israr = 1;
-                   write_log ("unrar.dll version %08X detected and used\n", pRARGetDllVersion ? pRARGetDllVersion() : -1);
+                   write_log (L"unrar.dll version %08X detected and used\n", pRARGetDllVersion ? pRARGetDllVersion() : -1);
 
                }
            }
@@ -477,10 +491,10 @@ static int canrar(void)
     return israr < 0 ? 0 : 1;
 }
 
-static int CALLBACK RARCallbackProc(UINT msg,LONG UserData,LONG P1,LONG P2)
+static int CALLBACK RARCallbackProc (UINT msg,LONG UserData,LONG P1,LONG P2)
 {
     if (msg == UCM_PROCESSDATA) {
-       zfile_fwrite((uae_u8*)P1, 1, P2, rarunpackzf);
+       zfile_fwrite ((uae_u8*)P1, 1, P2, rarunpackzf);
        return 0;
     }
     return -1;
@@ -494,7 +508,7 @@ struct RARContext
 };
 
 
-static void archive_close_rar(struct RARContext *rc)
+static void archive_close_rar (struct RARContext *rc)
 {
     xfree(rc);
 }
@@ -512,36 +526,38 @@ struct zvolume *archive_directory_rar (struct zfile *z)
         /* wtf? stupid unrar.dll only accept filename as an input.. */
        return archive_directory_arcacc (z, ArchiveFormatRAR);
     rc = xcalloc (sizeof (struct RARContext), 1);
-    zv = zvolume_alloc(z, ArchiveFormatRAR, rc);
+    zv = zvolume_alloc (z, ArchiveFormatRAR, rc);
     fclose (z->f); /* bleh, unrar.dll fails to open the archive if it is already open.. */
     z->f = NULL;
-    rc->OpenArchiveData.ArcName = z->name;
+    rc->OpenArchiveData.ArcName = ua (z->name);
     rc->OpenArchiveData.OpenMode = RAR_OM_LIST;
-    rc->hArcData = pRAROpenArchive(&rc->OpenArchiveData);
+    rc->hArcData = pRAROpenArchive (&rc->OpenArchiveData);
+    xfree (rc->OpenArchiveData.ArcName);
     if (rc->OpenArchiveData.OpenResult != 0) {
        xfree(rc);
-       if (!rar_resetf(z)) {
-           zfile_fclose_archive(zv);
+       if (!rar_resetf (z)) {
+           zfile_fclose_archive (zv);
            return NULL;
        }
-       zfile_fclose_archive(zv);
+       zfile_fclose_archive (zv);
        return archive_directory_arcacc (z, ArchiveFormatRAR);
     }
-    pRARSetCallback(rc->hArcData, RARCallbackProc, 0);
+    pRARSetCallback (rc->hArcData, RARCallbackProc, 0);
     cnt = 0;
-    while (pRARReadHeaderEx(rc->hArcData, &rc->HeaderData) == 0) {
-       char *name = rc->HeaderData.FileName;
+    while (pRARReadHeaderEx (rc->hArcData, &rc->HeaderData) == 0) {
+       TCHAR *name = au (rc->HeaderData.FileName);
        struct zarchive_info zai;
        struct znode *zn;
        memset(&zai, 0, sizeof zai);
        zai.name = name;
        zai.size = rc->HeaderData.UnpSize;
-       zai.t = fromdostime(rc->HeaderData.FileTime);
-       zn = zvolume_addfile_abs(zv, &zai);
+       zai.t = fromdostime (rc->HeaderData.FileTime);
+       zn = zvolume_addfile_abs (zv, &zai);
        zn->offset = cnt++;
-       pRARProcessFile(rc->hArcData, RAR_SKIP, NULL, NULL);
+       pRARProcessFile (rc->hArcData, RAR_SKIP, NULL, NULL);
+       xfree (name);
     }
-    pRARCloseArchive(rc->hArcData);
+    pRARCloseArchive (rc->hArcData);
     zftmp = zfile_fopen_empty (z->name, 0);
     zv->archive = zftmp;
     zv->method = ArchiveFormatRAR;
@@ -601,12 +617,12 @@ struct aaFileInArchiveInfo {
        uae_u32 attributes;
        int IsDir, IsEncrypted;
        struct aaFILETIME LastWriteTime;
-       char path[FileInArchiveInfoStringSize];
+       TCHAR path[FileInArchiveInfoStringSize];
 };
 
 typedef HRESULT (__stdcall *aaReadCallback)(int StreamID, uae_u64 offset, uae_u32 count, void* buf, uae_u32 *processedSize);
 typedef HRESULT (__stdcall *aaWriteCallback)(int StreamID, uae_u64 offset, uae_u32 count, const void *buf, uae_u32 *processedSize);
-typedef aaHandle (__stdcall *aapOpenArchive)(aaReadCallback function, int StreamID, uae_u64 FileSize, int ArchiveType, int *result, char *password);
+typedef aaHandle (__stdcall *aapOpenArchive)(aaReadCallback function, int StreamID, uae_u64 FileSize, int ArchiveType, int *result, TCHAR *password);
 typedef int (__stdcall *aapGetFileCount)(aaHandle ArchiveHandle);
 typedef int (__stdcall *aapGetFileInfo)(aaHandle ArchiveHandle, int FileNum, struct aaFileInArchiveInfo *FileInfo);
 typedef int (__stdcall *aapExtract)(aaHandle ArchiveHandle, int FileNum, int StreamID, aaWriteCallback WriteFunc, uae_u64 *written);
@@ -632,9 +648,9 @@ static int arcacc_init (struct zfile *zf)
 {
     if (arcacc_mod)
        return 1;
-    arcacc_mod = WIN32_LoadLibrary ("archiveaccess.dll");
+    arcacc_mod = WIN32_LoadLibrary (L"archiveaccess.dll");
     if (!arcacc_mod) {
-       write_log ("failed to open archiveaccess.dll ('%s')\n", zfile_getname (zf));
+       write_log (L"failed to open archiveaccess.dll ('%s')\n", zfile_getname (zf));
        return 0;
     }
     aaOpenArchive = (aapOpenArchive) GetProcAddress (arcacc_mod, "aaOpenArchive");
@@ -643,7 +659,7 @@ static int arcacc_init (struct zfile *zf)
     aaExtract = (aapExtract) GetProcAddress (arcacc_mod, "aaExtract");
     aaCloseArchive = (aapCloseArchive) GetProcAddress (arcacc_mod, "aaCloseArchive");
     if (!aaOpenArchive || !aaGetFileCount || !aaGetFileInfo || !aaExtract || !aaCloseArchive) {
-       write_log ("Missing functions in archiveaccess.dll. Old version?\n");
+       write_log (L"Missing functions in archiveaccess.dll. Old version?\n");
        arcacc_free ();
        return 0;
     }
@@ -710,7 +726,7 @@ struct zvolume *archive_directory_arcacc (struct zfile *z, unsigned int id)
        fc = aaGetFileCount (ah);
        for (f = 0; f < fc; f++) {
            struct aaFileInArchiveInfo fi;
-           char *name;
+           TCHAR *name;
            struct znode *zn;
            struct zarchive_info zai;
 
@@ -793,21 +809,21 @@ void archive_access_close (void *handle, unsigned int id)
 
 /* plain single file */
 
-static void addfile(struct zvolume *zv, const char *path, uae_u8 *data, int size)
+static void addfile (struct zvolume *zv, const TCHAR *path, uae_u8 *data, int size)
 {
     struct zarchive_info zai;
     struct znode *zn;
     struct zfile *z = zfile_fopen_empty (path, size);
 
-    zfile_fwrite(data, size, 1, z);
+    zfile_fwrite (data, size, 1, z);
     memset(&zai, 0, sizeof zai);
     zai.name = path;
     zai.size = size;
-    zn = zvolume_addfile_abs(zv, &zai);
+    zn = zvolume_addfile_abs (zv, &zai);
     if (zn)
        zn->f = z;
     else
-       zfile_fclose(z);
+       zfile_fclose (z);
 }
 
 static uae_u8 exeheader[]={0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00};
@@ -817,12 +833,12 @@ struct zvolume *archive_directory_plain (struct zfile *z)
     struct znode *zn;
     struct zarchive_info zai;
     int i;
-    char *filename;
+    TCHAR *filename;
     uae_u8 id[8];
 
-    memset(&zai, 0, sizeof zai);
-    zv = zvolume_alloc(z, ArchiveFormatPLAIN, NULL);
-    for (i = strlen(z->name) - 1; i >= 0; i--) {
+    memset (&zai, 0, sizeof zai);
+    zv = zvolume_alloc (z, ArchiveFormatPLAIN, NULL);
+    for (i = _tcslen (z->name) - 1; i >= 0; i--) {
        if (z->name[i] == '\\' || z->name[i] == '/' || z->name[i] == ':') {
            i++;
            break;
@@ -836,12 +852,12 @@ struct zvolume *archive_directory_plain (struct zfile *z)
     zfile_fseek(z, 0, SEEK_SET);
     zfile_fread(id, sizeof id, 1, z);
     zfile_fseek(z, 0, SEEK_SET);
-    zn = zvolume_addfile_abs(zv, &zai);
+    zn = zvolume_addfile_abs (zv, &zai);
     if (!memcmp (id, exeheader, sizeof id)) {
-       uae_u8 *data = xmalloc(1 + strlen(filename) + 1 + 2);
-       sprintf(data,"\"%s\"\n", filename);
-       addfile(zv, "s/startup-sequence", data, strlen(data));
-       xfree(data);
+       uae_u8 *data = xmalloc (1 + _tcslen (filename) + 1 + 2);
+       sprintf (data, "\"%s\"\n", filename);
+       addfile (zv, L"s/startup-sequence", data, strlen (data));
+       xfree (data);
     }
     return zv;
 }
@@ -850,6 +866,6 @@ struct zfile *archive_access_plain (struct znode *zn)
     struct zfile *z;
 
     z = zfile_fopen_empty (zn->fullname, zn->size);
-    zfile_fread(z->data, zn->size, 1, zn->volume->archive);
+    zfile_fread (z->data, zn->size, 1, zn->volume->archive);
     return z;
 }