From bbab8fecd780c01d7f6ac2acf95f895c371efb1f Mon Sep 17 00:00:00 2001 From: waltje Date: Mon, 29 Apr 2019 21:02:42 -0500 Subject: [PATCH] Updates to no longer have the selected machine's data as a global variable. Fixed the 'crash on unknown machine name in config' bug. Fixed some issues with the ROM loader, PS/2 M50 still doesnt work. Made the error message from dynld.c a DEBUG message. Fixed some stuff in the VNC driver (pending changes in the VNC DLL.) Cleaned up the MinGW Makefile, VC will follow. Added screenshots code to the D2D renderer. --- src/config.c | 11 +- src/devices/disk/hdc.c | 4 +- src/devices/system/nvr_at.c | 8 +- src/devices/video/video.c | 9 +- src/machines/m_europc.c | 4 +- src/machines/m_ps2_mca.c | 13 +- src/machines/m_tosh1x00.c | 4 +- src/machines/machine.c | 57 ++++- src/machines/machine.h | 8 +- src/mem.c | 4 +- src/pc.c | 24 ++- src/rom.c | 1 + src/rom_load.c | 19 +- src/vnc.c | 156 ++++++++------ src/win/mingw/Makefile.MinGW | 404 ++++++++++++++++------------------- src/win/msvc/Makefile.VC | 26 +-- src/win/win_d2d.cpp | 34 +-- src/win/win_dynld.c | 8 +- 18 files changed, 418 insertions(+), 376 deletions(-) diff --git a/src/config.c b/src/config.c index eb21901..1b03aca 100644 --- a/src/config.c +++ b/src/config.c @@ -12,7 +12,7 @@ * it on Windows XP, and possibly also Vista. Use the * -DANSI_CFG for use on these systems. * - * Version: @(#)config.c 1.0.45 2019/04/08 + * Version: @(#)config.c 1.0.46 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -397,7 +397,8 @@ load_machine(const char *cat) machine_type = machine_get_from_internal_name(p); else machine_type = -1; - (void)machine_load(); + if (machine_load() == NULL) + machine_type = -1; cpu_manufacturer = config_get_int(cat, "cpu_manufacturer", 0); cpu_type = config_get_int(cat, "cpu", 0); @@ -464,13 +465,13 @@ load_video(const char *cat) { char *p; - if (machine->flags_fixed & MACHINE_VIDEO) { + if (machine_get_flags_fixed() & MACHINE_VIDEO) { config_delete_var(cat, "video_card"); video_card = VID_INTERNAL; } else { p = config_get_string(cat, "video_card", NULL); if (p == NULL) { - if (machine->flags & MACHINE_VIDEO) + if (machine_get_flags() & MACHINE_VIDEO) p = "internal"; else p = "none"; @@ -800,7 +801,7 @@ load_other(const char *cat) p = config_get_string(cat, "hdc", NULL); if (p == NULL) { - if (machine->flags & MACHINE_HDC) + if (machine_get_flags() & MACHINE_HDC) p = "internal"; else p = "none"; diff --git a/src/devices/disk/hdc.c b/src/devices/disk/hdc.c index 1c74a90..b0db80f 100644 --- a/src/devices/disk/hdc.c +++ b/src/devices/disk/hdc.c @@ -8,7 +8,7 @@ * * Common code to handle all sorts of disk controllers. * - * Version: @(#)hdc.c 1.0.18 2019/04/20 + * Version: @(#)hdc.c 1.0.19 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -129,7 +129,7 @@ void hdc_reset(void) { INFO("HDC: reset(current=%d, internal=%d)\n", - hdc_type, !!(machine->flags & MACHINE_HDC)); + hdc_type, !!(machine_get_flags() & MACHINE_HDC)); /* If we have a valid controller, add its device. */ if (controllers[hdc_type].device != NULL) diff --git a/src/devices/system/nvr_at.c b/src/devices/system/nvr_at.c index 4aff6be..8853d77 100644 --- a/src/devices/system/nvr_at.c +++ b/src/devices/system/nvr_at.c @@ -189,7 +189,7 @@ * including the later update (DS12887A) which implemented a * "century" register to be compatible with Y2K. * - * Version: @(#)nvr_at.c 1.0.16 2019/04/26 + * Version: @(#)nvr_at.c 1.0.17 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -515,6 +515,7 @@ nvr_write(uint16_t addr, uint8_t val, void *priv) local_t *local = (local_t *)nvr->data; struct tm tm; uint8_t old; + int f; cycles -= ISA_CYCLES(8); @@ -562,7 +563,8 @@ nvr_write(uint16_t addr, uint8_t val, void *priv) } } else { local->addr = (val & (nvr->size - 1)); - if (!(machine->flags&MACHINE_MCA) && !(machine->flags&MACHINE_NONMI)) + f = machine_get_flags(); + if (!(f & MACHINE_MCA) && !(f & MACHINE_NONMI)) nmi_mask = (~val & 0x80); } } @@ -667,7 +669,7 @@ nvr_at_init(const device_t *info, UNUSED(void *parent)) nvr->data = local; /* This is machine specific. */ - nvr->size = machine->nvrsz; + nvr->size = machine_get_nvrsize(); switch(info->local) { case 0: /* standard AT (no century register) */ nvr->irq = 8; diff --git a/src/devices/video/video.c b/src/devices/video/video.c index 2155f64..cb66e4b 100644 --- a/src/devices/video/video.c +++ b/src/devices/video/video.c @@ -8,7 +8,7 @@ * * Main video-rendering module. * - * Version: @(#)video.c 1.0.28 2019/04/19 + * Version: @(#)video.c 1.0.29 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -811,15 +811,14 @@ video_reset(void) const device_t *dev; INFO("VIDEO: reset (video_card=%i, internal=%i)\n", - video_card, (machine->flags & MACHINE_VIDEO) ? 1 : 0); + video_card, (machine_get_flags() & MACHINE_VIDEO) ? 1 : 0); /* Initialize the video font tables. */ video_load_font(MDA_FONT_ROM_PATH, FONT_MDA); /* Do not initialize internal cards here. */ - if ((video_card == VID_NONE) || \ - (video_card == VID_INTERNAL) || \ - (machine->flags_fixed & MACHINE_VIDEO)) return; + if ((video_card == VID_NONE) || (video_card == VID_INTERNAL) || \ + (machine_get_flags_fixed() & MACHINE_VIDEO)) return; /* Configure default timing parameters for the card. */ video_inform(VID_TYPE_SPEC, NULL); diff --git a/src/machines/m_europc.c b/src/machines/m_europc.c index 7efc884..e34c0e2 100644 --- a/src/machines/m_europc.c +++ b/src/machines/m_europc.c @@ -69,7 +69,7 @@ * FIXME: Find a new way to handle the switching of color/mono on * external cards. New video_get_type(int card) function? * - * Version: @(#)m_europc.c 1.0.22 2019/04/23 + * Version: @(#)m_europc.c 1.0.23 2019/04/29 * * Author: Fred N. van Kempen, * @@ -561,7 +561,7 @@ europc_init(const device_t *info, void *arg) dev->jim = (i == 1) ? 0x0350 : 0x0250; /* Set up and initialize the NVR. */ - dev->nvr.size = machine->nvrsz; + dev->nvr.size = machine_get_nvrsize(); dev->nvr.irq = -1; dev->nvr.reset = rtc_reset; dev->nvr.start = rtc_start; diff --git a/src/machines/m_ps2_mca.c b/src/machines/m_ps2_mca.c index f40021e..27750a2 100644 --- a/src/machines/m_ps2_mca.c +++ b/src/machines/m_ps2_mca.c @@ -48,7 +48,7 @@ * * This works around the timing loop mentioned above. * - * Version: @(#)m_ps2_mca.c 1.0.23 2019/04/27 + * Version: @(#)m_ps2_mca.c 1.0.24 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1493,12 +1493,9 @@ ps2_init(const device_t *info, void *arg) } -static const CPU cpus_ps2_m30_286[] = { +static const CPU cpus_ps2_m50[] = { { "286/10", CPU_286, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2, 1 }, { "286/12", CPU_286, 12000000, 1, 0, 0, 0, 0, 0, 3,3,3,3, 2 }, - { "286/16", CPU_286, 16000000, 1, 0, 0, 0, 0, 0, 3,3,3,3, 2 }, - { "286/20", CPU_286, 20000000, 1, 0, 0, 0, 0, 0, 4,4,4,4, 3 }, - { "286/25", CPU_286, 25000000, 1, 0, 0, 0, 0, 0, 4,4,4,4, 3 }, { NULL } }; @@ -1506,11 +1503,11 @@ static const machine_t m50_info = { MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_VIDEO | MACHINE_HDC_PS2, 0, 1, 10, 1, 64, -1, - {{"",cpus_ps2_m30_286}} //FIXME:??? is for M30-286! + {{"",cpus_ps2_m50}} }; const device_t m_ps2_m50 = { - "IBM PS/2 M50", + "IBM PS/2 M50 Type 1", DEVICE_ROOT, 50, L"ibm/ps2_m50", @@ -1529,7 +1526,7 @@ static const machine_t m55_info = { }; const device_t m_ps2_m55sx = { - "IBM PS/2 M50", + "IBM PS/2 M55SX", DEVICE_ROOT, 55, L"ibm/ps2_m55sx", diff --git a/src/machines/m_tosh1x00.c b/src/machines/m_tosh1x00.c index 1d539fe..3fe71c6 100644 --- a/src/machines/m_tosh1x00.c +++ b/src/machines/m_tosh1x00.c @@ -96,7 +96,7 @@ * * FIXME: The ROM drive should be re-done using the "option file". * - * Version: @(#)m_tosh1x00.c 1.0.18 2019/04/11 + * Version: @(#)m_tosh1x00.c 1.0.19 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1027,7 +1027,7 @@ t1000_init(const device_t *info, void *arg) device_add(&keyboard_xt_device); - tc8521_init(&dev->nvr, machine->nvrsz); + tc8521_init(&dev->nvr, machine_get_nvrsize()); if (dev->is_t1200) { dev->fdc = (fdc_t *)device_add(&fdc_toshiba_device); diff --git a/src/machines/machine.c b/src/machines/machine.c index 28c27e6..87c0d0f 100644 --- a/src/machines/machine.c +++ b/src/machines/machine.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.c 1.0.20 2019/04/19 + * Version: @(#)machine.c 1.0.21 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -56,10 +56,7 @@ #include "machine.h" -const machine_t *machine; - - -static void *m_priv; +static const machine_t *machine = NULL; /* Get the machine definition for the selected machine. */ @@ -124,7 +121,7 @@ machine_reset(void) rom_add_bios(); /* All good, boot the machine! */ - m_priv = dev->init(dev, &roms); + (void)dev->init(dev, &roms); } @@ -141,14 +138,56 @@ machine_get_flags(void) } +/* Return the current machine's 'fixed devices' flags. */ +int +machine_get_flags_fixed(void) +{ + int ret = 0; + + if (machine != NULL) + ret = machine->flags_fixed; + + return(ret); +} + + +/* Return a machine's maximum memory size. */ +int +machine_get_maxmem(void) +{ + int ret = 0; + + if (machine != NULL) + ret = machine->max_ram; + + return(ret); +} + + +/* Return a machine's NVR size. */ +int +machine_get_nvrsize(void) +{ + int ret = 0; + + if (machine != NULL) + ret = machine->nvrsz; + + return(ret); +} + + /* Return a machine's (adjusted) memory size. */ int machine_get_memsize(int mem) { - int k; + int k = 0; - k = ((machine->flags & MACHINE_AT) && (machine->ram_granularity < 128)) - ? machine->min_ram * 1024 : machine->min_ram; + if (machine != NULL) { + k = machine->min_ram; + if ((machine->flags & MACHINE_AT) && (machine->ram_granularity < 128)) + k *= 1024; + } if (mem < k) mem = k; diff --git a/src/machines/machine.h b/src/machines/machine.h index 75a6b64..a26654e 100644 --- a/src/machines/machine.h +++ b/src/machines/machine.h @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.h 1.0.31 2019/04/23 + * Version: @(#)machine.h 1.0.32 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -83,9 +83,6 @@ typedef struct { /* Global variables. */ -extern const machine_t *machine; - - #ifdef EMU_DEVICE_H extern const device_t m_pc81, m_pc82; @@ -242,7 +239,10 @@ extern const char *machine_get_internal_name(void); extern const device_t *machine_get_device(void); #endif extern int machine_get_flags(void); +extern int machine_get_flags_fixed(void); +extern int machine_get_maxmem(void); extern int machine_get_memsize(int memsz); +extern int machine_get_nvrsize(void); extern uint32_t machine_get_speed(int turbo); extern const char *machine_get_name_ex(int m); diff --git a/src/mem.c b/src/mem.c index 7f51003..550ce41 100644 --- a/src/mem.c +++ b/src/mem.c @@ -12,7 +12,7 @@ * The Port92 stuff should be moved to devices/system/memctl.c * as a standard device. * - * Version: @(#)mem.c 1.0.33 2019/04/27 + * Version: @(#)mem.c 1.0.34 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1441,7 +1441,7 @@ mem_reset(void) * nasty crashes all over the place. */ m = mem_size; - c = machine->max_ram; + c = machine_get_maxmem(); if (AT) c <<= 10; /* make KB */ if (m > c) { diff --git a/src/pc.c b/src/pc.c index 10deec9..e737f24 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.71 2019/04/26 + * Version: @(#)pc.c 1.0.72 2019/04/29 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -226,16 +226,20 @@ pclog_ex(const char *fmt, va_list ap) } } - vsprintf(temp, fmt, ap); - if (logdetect && !strcmp(logbuff, temp)) { - logseen++; + if (logdetect) { + vsprintf(temp, fmt, ap); + if (strcmp(logbuff, temp)) { + if (logseen) + fprintf(logfp, "*** %i repeats ***\n", logseen); + logseen = 0; + if (logdetect) + strcpy(logbuff, temp); + fprintf(logfp, temp); + } else + logseen++; } else { - if (logseen) - fprintf(logfp, "*** %i repeats ***\n", logseen); - logseen = 0; - if (logdetect) - strcpy(logbuff, temp); - fprintf(logfp, temp, ap); + /* Not detecting duplicates, do not buffer. */ + vfprintf(logfp, fmt, ap); } fflush(logfp); diff --git a/src/rom.c b/src/rom.c index 49dedf0..4a42023 100644 --- a/src/rom.c +++ b/src/rom.c @@ -282,6 +282,7 @@ rom_load_interleaved(const wchar_t *fnl, const wchar_t *fnh, uint32_t addr, int addr = 0; else addr &= 0x03ffff; +INFO("ROM: loading %i bytes at %06lx\n", sz, addr); (void)fseek(fl, off, SEEK_SET); (void)fseek(fh, off, SEEK_SET); diff --git a/src/rom_load.c b/src/rom_load.c index f035fef..bd67c06 100644 --- a/src/rom_load.c +++ b/src/rom_load.c @@ -421,13 +421,14 @@ rom_load_bios(romdef_t *r, const wchar_t *fn, int test_only) case 1: /* interleaved file(s) */ /* We loop on all files. */ - for (c = 0; c < r->nfiles / 2; c += 2) { + for (c = 0; c < r->nfiles; c += 2) { /* If this is a no-load file, skip. */ if (r->files[c].offset == 0xffffffff) continue; pc_path(script, sizeof_w(script), r->files[c].path); pc_path(temp, sizeof_w(temp), r->files[c+1].path); +INFO("ROM: loading '%ls'/'%ls' at %06lx, size=%i, skip=%i\n", script, temp, r->files[c].offset, r->files[c].size, r->files[c].skip); i = rom_load_interleaved(script, temp, r->files[c].offset, @@ -439,11 +440,25 @@ rom_load_bios(romdef_t *r, const wchar_t *fn, int test_only) } /* Update BIOS mask. */ - if (r->total >= 0x10000) + if (r->total >= 0x010000) biosmask = (r->total - 1); else biosmask = 0x00ffff; +#if defined(WALTJE) && defined(_DEBUG) +//FIXME: this will go away again! +{ +char foo[32768]; +INFO("ROM loaded, total=%i, mask=%06x\n", r->total, biosmask); +pclog_repeat(0); +for (i = 0; i < r->total; i += 4096) { + hexdump_p(foo, i, &bios[i], 4096); + pclog(0, foo); +} +pclog_repeat(1); +} +#endif + /* Create a full pathname for the video font file. */ if (r->fontnum != -1) { plat_append_filename(temp, path, r->fontfn); diff --git a/src/vnc.c b/src/vnc.c index 9d58980..1df4d61 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -10,7 +10,7 @@ * * TODO: Implement screenshots, and Audio Redirection. * - * Version: @(#)vnc.c 1.0.9 2019/03/08 + * Version: @(#)vnc.c 1.0.10 2019/04/28 * * Author: Fred N. van Kempen, * Based on raw code by RichardG, @@ -53,6 +53,7 @@ #include #include #include +//#define LIBVNCSERVER_HAVE_LIBPTHREAD #include #include "emu.h" #include "device.h" @@ -61,15 +62,14 @@ #include "devices/input/mouse.h" #include "ui/ui.h" #include "plat.h" +#if USE_LIBPNG +# include "png.h" +#endif #include "vnc.h" #ifdef _WIN32 -# ifdef _DEBUG -# define PATH_VNC_DLL "libvncserver-debug.dll" -# else -# define PATH_VNC_DLL "libvncserver.dll" -# endif +# define PATH_VNC_DLL "libvncserver.dll" #else # define PATH_VNC_DLL "libvncserver.so" #endif @@ -80,7 +80,6 @@ #define VNC_MAX_Y 2048 -static void *vnc_handle = NULL; /* handle to libVNCserver DLL */ static rfbScreenInfoPtr rfb = NULL; static int clients; static int updatingSize; @@ -89,35 +88,48 @@ static int allowedX, static int ptr_x, ptr_y, ptr_but; +#if USE_VNC == 2 +# define DLLFUNC(x) rfb_##x + +static void *vnc_handle = NULL; /* handle to libVNCserver DLL */ + + /* Pointers to the real functions. */ -static rfbScreenInfoPtr (*f_rfbGetScreen)(int* argc,char** argv,int width, - int height,int bitsPerSample, - int samplesPerPixel, - int bytesPerPixel); -static void (*f_rfbInitServer)(rfbScreenInfoPtr rfbScreen); -static void (*f_rfbRunEventLoop)(rfbScreenInfoPtr screenInfo, - long usec, - rfbBool runInBackground); -static void (*f_rfbScreenCleanup)(rfbScreenInfoPtr screenInfo); -static rfbClientIteratorPtr (*f_rfbGetClientIterator)(rfbScreenInfoPtr rfbScreen); -static rfbClientPtr (*f_rfbClientIteratorNext)(rfbClientIteratorPtr iterator); -static void (*f_rfbMarkRectAsModified)(rfbScreenInfoPtr rfbScreen, - int x1,int y1,int x2,int y2); -static void (*f_rfbDefaultPtrAddEvent)(int buttonMask,int x, - int y,rfbClientPtr cl); +static rfbScreenInfoPtr (*rfb_GetScreen)(int *,char **,int,int,int,int,int); +static void (*rfb_InitServer)(rfbScreenInfoPtr); +static void (*rfb_RunEventLoop)(rfbScreenInfoPtr, long, rfbBool); +static void (*rfb_ScreenCleanup)(rfbScreenInfoPtr); +static rfbClientIteratorPtr (*rfb_GetClientIterator)(rfbScreenInfoPtr); +static rfbClientPtr (*rfb_ClientIteratorNext)(rfbClientIteratorPtr); +static void (*rfb_MarkRectAsModified)(rfbScreenInfoPtr, + int,int,int,int); +static void (*rfb_DefaultPtrAddEvent)(int,int,int,rfbClientPtr); +static void (*rfb_ClientLock)(rfbClientPtr); +static void (*rfb_ClientUnlock)(rfbClientPtr); +static void (*rfb_LogEnable)(int); +static void (*rfb_Log)(const char *fmt, ...); +static void (*rfb_Err)(const char *fmt, ...); -static dllimp_t vnc_imports[] = { - { "rfbGetScreen", &f_rfbGetScreen }, - { "rfbInitServerWithPthreadsAndZRLE", &f_rfbInitServer }, - { "rfbRunEventLoop", &f_rfbRunEventLoop }, - { "rfbScreenCleanup", &f_rfbScreenCleanup }, - { "rfbGetClientIterator", &f_rfbGetClientIterator }, - { "rfbClientIteratorNext", &f_rfbClientIteratorNext }, - { "rfbMarkRectAsModified", &f_rfbMarkRectAsModified }, - { "rfbDefaultPtrAddEvent", &f_rfbDefaultPtrAddEvent }, +static const dllimp_t vnc_imports[] = { + { "rfbGetScreen", &rfb_GetScreen }, + { "rfbInitServerWithPthreadsAndZRLE", &rfb_InitServer }, + { "rfbRunEventLoop", &rfb_RunEventLoop }, + { "rfbScreenCleanup", &rfb_ScreenCleanup }, + { "rfbGetClientIterator", &rfb_GetClientIterator }, + { "rfbClientIteratorNext", &rfb_ClientIteratorNext }, + { "rfbMarkRectAsModified", &rfb_MarkRectAsModified }, + { "rfbDefaultPtrAddEvent", &rfb_DefaultPtrAddEvent }, + { "rfbClientLock", &rfb_ClientLock }, + { "rfbClientUnlock", &rfb_ClientUnlock }, + { "rfbLogEnable", &rfb_LogEnable }, + { "rfbLog", &rfb_Log }, + { "rfbErr", &rfb_Err }, { NULL, NULL } }; +#else +# define DLLFUNC(x) rfb##x +#endif /* Local handlers for VNCserver event logging. */ @@ -178,7 +190,7 @@ vnc_ptrevent(int but, int x, int y, rfbClientPtr cl) } } - f_rfbDefaultPtrAddEvent(but, x, y, cl); + DLLFUNC(DefaultPtrAddEvent)(but, x, y, cl); } @@ -250,6 +262,8 @@ vnc_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) uint32_t *p; int yy; +INFO("VNC: blit(%i,%i, %i,%i, %i,%i)\n", x,y, y1,y2, w,h); + for (yy = y1; yy < y2; yy++) { p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]); @@ -264,7 +278,30 @@ vnc_blit(bitmap_t *scr, int x, int y, int y1, int y2, int w, int h) video_blit_done(); if (! updatingSize) - f_rfbMarkRectAsModified(rfb, 0,0, allowedX,allowedY); + DLLFUNC(MarkRectAsModified)(rfb, 0,0, allowedX,allowedY); +} + + +static void +vnc_close(void) +{ + video_blit_set(NULL); + + if (rfb != NULL) { + free(rfb->frameBuffer); + + DLLFUNC(ScreenCleanup)(rfb); + + rfb = NULL; + } + +#if USE_VNC == 2 + /* Unload the DLL if possible. */ + if (vnc_handle != NULL) { + dynld_close(vnc_handle); + vnc_handle = NULL; + } +#endif } @@ -285,8 +322,10 @@ vnc_init(int fs) */ 32, 32, 0, 1, 255,255,255, 16, 8, 0, 0, 0 }; +#if USE_VNC == 2 wchar_t temp[512]; const char *fn = PATH_VNC_DLL; +#endif /* We do not support fullscreen, folks. */ if (fs) { @@ -294,6 +333,7 @@ vnc_init(int fs) return(0); } +#if USE_VNC == 2 /* Try loading the DLL. */ vnc_handle = dynld_module(fn, vnc_imports); if (vnc_handle == NULL) { @@ -302,14 +342,17 @@ vnc_init(int fs) ui_msgbox(MBX_ERROR, temp); vnc_errlog("unable to load '%s', VNC not available.\n", fn); return(0); + } else { + INFO("VNC: module '%s' loaded.\n", fn); } +#endif #ifdef _WIN32 //FIXME: these are defined in Linux version, but not present.. --FvK /* Set up and enable VNC server logging. */ - rfbLog = vnc_dbglog; - rfbErr = vnc_errlog; - rfbLogEnable(1); + DLLFUNC(Log) = vnc_dbglog; + DLLFUNC(Err) = vnc_errlog; + DLLFUNC(LogEnable)(1); #endif if (rfb == NULL) { @@ -318,7 +361,7 @@ vnc_init(int fs) allowedX = scrnsz_x; allowedY = scrnsz_y; - rfb = f_rfbGetScreen(0, NULL, VNC_MAX_X, VNC_MAX_Y, 8, 3, 4); + rfb = DLLFUNC(GetScreen)(0, NULL, VNC_MAX_X, VNC_MAX_Y, 8, 3, 4); rfb->desktopName = title; rfb->frameBuffer = (char *)mem_alloc(VNC_MAX_X*VNC_MAX_Y*4); @@ -333,9 +376,9 @@ vnc_init(int fs) rfb->width = allowedX; rfb->height = allowedY; - f_rfbInitServer(rfb); + DLLFUNC(InitServer)(rfb); - f_rfbRunEventLoop(rfb, -1, TRUE); + DLLFUNC(RunEventLoop)(rfb, -1, TRUE); } /* Set up our BLIT handlers. */ @@ -349,27 +392,6 @@ vnc_init(int fs) } -static void -vnc_close(void) -{ - video_blit_set(NULL); - - if (rfb != NULL) { - free(rfb->frameBuffer); - - f_rfbScreenCleanup(rfb); - - rfb = NULL; - } - - /* Unload the DLL if possible. */ - if (vnc_handle != NULL) { - dynld_close(vnc_handle); - vnc_handle = NULL; - } -} - - static void vnc_resize(int x, int y) { @@ -380,7 +402,7 @@ vnc_resize(int x, int y) /* TightVNC doesn't like certain sizes.. */ if (x < VNC_MIN_X || x > VNC_MAX_X || y < VNC_MIN_Y || y > VNC_MAX_Y) { - vnc_errlog("invalid resoltion %ix%i requested!\n", x, y); + vnc_errlog("invalid resolution %ix%i requested!\n", x, y); return; } @@ -393,11 +415,11 @@ vnc_resize(int x, int y) rfb->width = x; rfb->height = y; - iterator = f_rfbGetClientIterator(rfb); - while ((cl = f_rfbClientIteratorNext(iterator)) != NULL) { - LOCK(cl->updateMutex); + iterator = DLLFUNC(GetClientIterator)(rfb); + while ((cl = DLLFUNC(ClientIteratorNext)(iterator)) != NULL) { + DLLFUNC(ClientLock)(cl); cl->newFBSizePending = 1; - UNLOCK(cl->updateMutex); + DLLFUNC(ClientUnlock)(cl); } } } @@ -422,6 +444,7 @@ vnc_screenshot(const wchar_t *fn) static int vnc_available(void) { +#if USE_VNC == 2 void *handle; handle = dynld_module(PATH_VNC_DLL, NULL); @@ -431,6 +454,9 @@ vnc_available(void) } return(0); +#else + return(1); +#endif } diff --git a/src/win/mingw/Makefile.MinGW b/src/win/mingw/Makefile.MinGW index 3806eb3..254999c 100644 --- a/src/win/mingw/Makefile.MinGW +++ b/src/win/mingw/Makefile.MinGW @@ -8,7 +8,7 @@ # # Makefile for Windows systems using the MinGW32 environment. # -# Version: @(#)Makefile.mingw 1.0.82 2019/04/23 +# Version: @(#)Makefile.mingw 1.0.83 2019/04/28 # # Author: Fred N. van Kempen, # @@ -56,161 +56,9 @@ ifndef EXTRAS endif # Defaults for several build options (possibly defined in a chained file.) -ifndef AUTODEP - AUTODEP := n -endif -ifndef CRASHDUMP - CRASHDUMP := n -endif -ifndef CROSS - CROSS := n -endif -ifndef DEBUG - DEBUG := n -endif -ifndef LOGGING - LOGGING := n -endif -ifndef PROFILER - PROFILER := n -endif -ifndef OPTIM - OPTIM := n -endif -ifndef RELEASE - RELEASE := n -endif -ifndef X64 - X64 := n -endif -ifndef ARM -ARM := n -endif -ifndef ARM64 -ARM64 := n -endif -ifndef DYNAREC - DYNAREC := y - ifeq ($(ARM), y) - DYNAREC := n - endif - ifeq ($(ARM64), y) - DYNAREC := n - endif -endif ifndef WX WX := n endif -ifndef USB - USB := n -endif -ifndef VNS - VNS := n -endif -ifndef SDL - SDL := n -endif -ifndef D2D - D2D := n -endif -ifndef VNC - VNC := n -endif -ifndef RDP - RDP := n -endif -ifndef PNG - PNG := n -endif -ifndef DEV_BUILD - DEV_BUILD := n -endif -ifndef DEV_BRANCH - DEV_BRANCH := n -endif -ifndef AMD_K - AMD_K := n -endif -ifndef SIS471 - SIS471 := n -endif -ifndef SIS496 - SIS496 := n -endif -ifndef COMPAQ - COMPAQ := n -endif -ifndef MICRAL - MICRAL := n -endif -ifndef SUPERSPORT - SUPERSPORT := n -endif -ifndef DINPUT - DINPUT := y - ifeq ($(ARM), y) - DINPUT := n - endif -endif -ifndef D3DX - D3DX := y - ifeq ($(ARM), y) - D3DX := n - endif - ifeq ($(ARM64), y) - D3DX := n - endif -endif -ifndef OPENAL - OPENAL := y -endif -ifndef FLUIDSYNTH - FLUIDSYNTH := y -endif -ifndef MUNT - MUNT := y -endif -ifndef PAS16 - PAS16 := n -endif -ifndef GUSMAX - GUSMAX := n -endif -ifndef XL24 - XL24 := n -endif -ifndef WONDER - WONDER := n -endif -ifndef PRINTER - PRINTER := n -endif -ifndef HOSTCD - HOSTCD := n -endif -ifndef CASSETTE - CASSETTE := n -endif - - -# Name of the executable. -NETIF := pcap_if -ifndef PROG - ifneq ($(WX), n) - PROG := WxVARCem - else - PROG := VARCem - endif -endif -ifeq ($(DEBUG), y) - PROG := $(PROG)-d - NETIF := $(NETIF)-d - LOGGING := y -else - ifeq ($(LOGGING), y) - PROG := $(PROG)-l - endif -endif # Which modules to include a development build. @@ -233,6 +81,12 @@ ifeq ($(DEV_BUILD), y) endif +# What is the location of our external dependencies? +ifeq ($(EXT_PATH), ) + EXT_PATH := ../external +endif + + # WxWidgets basic info. Extract using the config program. ifneq ($(WX), n) EXPATH += wx @@ -283,11 +137,31 @@ VPATH := $(EXPATH) . cpu \ devices/video \ machines ui win +# +# Name of the executable. +# +NETIF := pcap_if +ifndef PROG + ifneq ($(WX), n) + PROG := WxVARCem + else + PROG := VARCem + endif +endif +ifeq ($(DEBUG), y) + PROG := $(PROG)-d + NETIF := $(NETIF)-d + LOGGING := y +else + ifeq ($(LOGGING), y) + PROG := $(PROG)-l + endif +endif # # Select the required build environment. We have, uhm, many.. # -ifneq ($(CROSS), n) +ifeq ($(CROSS), y) # Cross-compiling (under Linux), select proper version. ifeq ($(X64), y) MINGW := x86_64-w64-mingw32 @@ -386,6 +260,7 @@ ifeq ($(ARM64), y) endif +# Add general build options from the environment. ifdef BUILD OPTS += -DBUILD=$(BUILD) endif @@ -402,7 +277,7 @@ ifdef EXINC OPTS += -I$(EXINC) endif OPTS += $(SYSINC) -ifneq ($(CROSS), n) +ifeq ($(CROSS), y) OPTS += -DUSE_CROSS endif ifeq ($(DEBUG), y) @@ -438,10 +313,6 @@ ifeq ($(RELEASE), y) OPTS += -DRELEASE_BUILD RFLAGS += -DRELEASE_BUILD endif -ifeq ($(VRAMDUMP), y) - OPTS += -DENABLE_VRAM_DUMP - RFLAGS += -DENABLE_VRAM_DUMP -endif ifeq ($(X64), y) PLATCG := codegen_x86-64.o CGOPS := codegen_ops_x86-64.h @@ -453,23 +324,21 @@ else endif LIBS := -mwindows \ -lddraw -ldxguid -ld3d9 -lversion -lcomctl32 -lwinmm -ifeq ($(DINPUT), y) - LIBS += -ldinput8 -else - LIBS += -lxinput -endif -ifeq ($(D3DX), y) - LIBS += -ld3dx9 -endif -LIBS += -lws2_32 -lwsock32 -liphlpapi -lpsapi -LIBS += -static -lstdc++ -lgcc -#ifneq ($(X64), y) -# LIBS += -Wl,--large-address-aware -#endif # Optional modules. MISCOBJ := + +# Dynamic Recompiler (compiled-in) +ifndef DYNAREC + DYNAREC := y + ifeq ($(ARM), y) + DYNAREC := n + endif + ifeq ($(ARM64), y) + DYNAREC := n + endif +endif ifeq ($(DYNAREC), y) OPTS += -DUSE_DYNAREC RFLAGS += -DUSE_DYNAREC @@ -481,20 +350,51 @@ ifeq ($(DYNAREC), y) codegen_timing_winchip.o $(PLATCG) endif -ifeq ($(VNS), y) +# VNS: N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +ifndef VNS + VNS := n +endif +ifneq ($(VNS), n) OPTS += -DUSE_VNS + ifeq ($(VNS_PATH), ) + VNS_PATH := $(EXT_PATH)/vns + endif + OPTS += -I$(VNS_PATH)/include/mingw -I$(VNS_PATH)/include + ifeq ($(X64), y) + LIBS += -L$(VNS_PATH)/lib/mingw/x64 + else + LIBS += -L$(VNS_PATH)/lib/mingw/x86 + endif + ifeq ($(VNS), y) + LIBS += -lvns.dll + endif + ifeq ($(VNS), s) + LIBS += -lvns + endif MISCOBJ += net_vns.o endif +# OpenAL (always dynamic) +ifndef OPENAL + OPENAL := y +endif ifeq ($(OPENAL), y) OPTS += -DUSE_OPENAL endif +# FluidSynth (always dynamic) +ifndef FLUIDSYNTH + FLUIDSYNTH := y +endif ifeq ($(FLUIDSYNTH), y) OPTS += -DUSE_FLUIDSYNTH MISCOBJ += midi_fluidsynth.o endif +# MunT (compiled-in) +ifndef MUNT + MUNT := y +endif ifeq ($(MUNT), y) OPTS += -DUSE_MUNT MISCOBJ += midi_mt32.o \ @@ -505,32 +405,40 @@ ifeq ($(MUNT), y) Tables.o TVA.o TVF.o TVP.o sha1.o c_interface.o endif -# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +# SDL: N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +ifndef SDL + SDL := n +endif ifneq ($(SDL), n) OPTS += -DUSE_SDL - RFLAGS += -DUSE_SDL - ifneq ($(SDL_PATH), ) - OPTS += -I$(SDL_PATH)/include/mingw -I$(SDL_PATH)/include - ifeq ($(X64), y) - LIBS += -L$(SDL_PATH)/lib/mingw/x64 - else - LIBS += -L$(SDL_PATH)/lib/mingw/x86 - endif + ifeq ($(SDL_PATH), ) + SDL_PATH := $(EXT_PATH)/sdl + endif + OPTS += -I$(SDL_PATH)/include/mingw -I$(SDL_PATH)/include + ifeq ($(X64), y) + LIBS += -L$(SDL_PATH)/lib/mingw/x64 + else + LIBS += -L$(SDL_PATH)/lib/mingw/x86 endif ifeq ($(SDL), y) + LIBS += -lsdl2.dll + endif + ifeq ($(SDL), s) LIBS += -lsdl2 endif SDLOBJ := win_sdl.o endif -# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +# D2D: N=no, Y=yes,linked, D=yes,dynamic +ifndef D2D + D2D := n +endif ifneq ($(D2D), n) ifeq ($(D2D), d) OPTS += -DUSE_D2D=2 else OPTS += -DUSE_D2D=1 endif - RFLAGS += -DUSE_D2D ifneq ($(D2D_PATH), ) OPTS += -I$(D2D_PATH)/include/mingw -I$(D2D_PATH)/include ifeq ($(X64), y) @@ -545,73 +453,121 @@ ifneq ($(D2D), n) D2DOBJ := win_d2d.o endif +# D3DX (always hard-linked) +ifndef D3DX + D3DX := y + ifeq ($(ARM), y) + D3DX := n + endif + ifeq ($(ARM64), y) + D3DX := n + endif +endif ifeq ($(D3DX), y) -OPTS += -DUSE_D3DX + OPTS += -DUSE_D3DX + LIBS += -ld3dx9 endif +# DINPUT and XInput (always hard-linked) +ifndef DINPUT + DINPUT := y + ifeq ($(ARM), y) + DINPUT := n + endif +endif ifeq ($(DINPUT), y) -OPTS += -DUSE_DINPUT + OPTS += -DUSE_DINPUT + LIBS += -ldinput8 +else + LIBS += -lxinput endif -# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +# VNC: N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +ifndef VNC + VNC := n +endif ifneq ($(VNC), n) - OPTS += -DUSE_VNC - RFLAGS += -DUSE_VNC - ifneq ($(VNC_PATH), ) - OPTS += -I$(VNC_PATH)/include/mingw -I$(VNC_PATH)/include - ifeq ($(X64), y) - LIBS += -L$(VNC_PATH)/lib/x64 - else - LIBS += -L$(VNC_PATH)/lib/x86 - endif + ifeq ($(VNC), d) + OPTS += -DUSE_VNC=2 + else + OPTS += -DUSE_VNC=1 + endif + ifeq ($(VNC_PATH), ) + VNC_PATH := $(EXT_PATH)/vnc + endif + OPTS += -I$(VNC_PATH)/include/mingw -I$(VNC_PATH)/include + ifeq ($(X64), y) + LIBS += -L$(VNC_PATH)/lib/x64 + else + LIBS += -L$(VNC_PATH)/lib/x86 endif ifeq ($(VNC), y) - LIBS += -lvncserver_shared #-static -lpthreads + LIBS += -lvncserver.dll + endif + ifeq ($(VNC), s) + LIBS += -lvncserver -lz -static -lpthread endif MISCOBJ += vnc.o vnc_keymap.o endif -# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +# RDP: N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +ifndef RDP + RDP := n +endif ifneq ($(RDP), n) - OPTS += -DUSE_RDP - RFLAGS += -DUSE_RDP - ifneq ($(RDP_PATH), ) - OPTS += -I$(RDP_PATH)/include/mingw -I$(RDP_PATH)/include - ifeq ($(X64), y) - LIBS += -L$(RDP_PATH)/lib/x64 - else - LIBS += -L$(RDP_PATH)/lib/x86 - endif + ifeq ($(RDP), d) + OPTS += -DUSE_RDP=2 + else + OPTS += -DUSE_RDP=1 + endif + ifeq ($(RDP_PATH), ) + RDP_PATH := $(EXT_PATH)/rdp + endif + OPTS += -I$(RDP_PATH)/include/mingw -I$(RDP_PATH)/include + ifeq ($(X64), y) + LIBS += -L$(RDP_PATH)/lib/x64 + else + LIBS += -L$(RDP_PATH)/lib/x86 endif ifeq ($(RDP), y) + LIBS += -lrdp.dll + endif + ifeq ($(RDP), s) LIBS += -lrdp endif MISCOBJ += rdp.o endif -# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +# PNG: N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +ifndef PNG + PNG := n +endif ifneq ($(PNG), n) ifeq ($(PNG), d) OPTS += -DUSE_LIBPNG=2 else OPTS += -DUSE_LIBPNG=1 endif - RFLAGS += -DUSE_PNG - ifneq ($(PNG_PATH), ) - OPTS += -I$(PNG_PATH)/include/mingw -I$(PNG_PATH)/include - ifeq ($(X64), y) - LIBS += -L$(PNG_PATH)/lib/x64 - else - LIBS += -L$(PNG_PATH)/lib/x86 - endif + ifeq ($(PNG_PATH), ) + PNG_PATH := $(EXT_PATH)/png + endif + OPTS += -I$(PNG_PATH)/include/mingw -I$(PNG_PATH)/include + ifeq ($(X64), y) + LIBS += -L$(PNG_PATH)/lib/x64 + else + LIBS += -L$(PNG_PATH)/lib/x86 endif ifeq ($(PNG), y) + # FIXME: should be -lpng.dll + LIBS += -lpng -lz + endif + ifeq ($(PNG), s) LIBS += -lpng -lz endif MISCOBJ += png.o endif -# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static +# WX: N=no, Y=yes,linked, D=yes,dynamic, S=yes,static ifneq ($(WX), n) OPTS += -DUSE_WX=$(WX) $(WX_FLAGS) LIBS += $(WX_LIBS) -lm @@ -699,17 +655,27 @@ ifeq ($(DEV_BRANCH), y) endif +# Finalize the list of libraries to load. +LIBS += -lws2_32 -lwsock32 -liphlpapi -lpsapi +LIBS += -static -lstdc++ -lgcc +#ifneq ($(X64), y) +# LIBS += -Wl,--large-address-aware +#endif + + # Final versions of the toolchain flags. # FIXME: add the -Wsign-compare option soon! CFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ $(AFLAGS) -fomit-frame-pointer -mstackrealign \ + -fno-strict-aliasing \ -Wall -Wundef #-Wshadow #-Wunused-parameter -Wmissing-declarations CXXFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ - $(AFLAGS) -fno-strict-aliasing -fvisibility=hidden \ - -fvisibility-inlines-hidden \ + $(AFLAGS) -fomit-frame-pointer -mstackrealign \ + -fno-strict-aliasing \ -Wall -Wundef -Wunused-parameter -Wmissing-declarations \ -Wno-ctor-dtor-privacy -Woverloaded-virtual +# -fvisibility=hidden -fvisibility-inlines-hidden ######################################################################### diff --git a/src/win/msvc/Makefile.VC b/src/win/msvc/Makefile.VC index daf0778..9cf312e 100644 --- a/src/win/msvc/Makefile.VC +++ b/src/win/msvc/Makefile.VC @@ -8,7 +8,7 @@ # # Makefile for Windows using Visual Studio 2015. # -# Version: @(#)Makefile.VC 1.0.66 2019/04/23 +# Version: @(#)Makefile.VC 1.0.67 2019/04/28 # # Author: Fred N. van Kempen, # @@ -63,9 +63,6 @@ endif ifndef CRASHDUMP CRASHDUMP := n endif -ifndef CROSS - CROSS := n -endif ifndef DEBUG DEBUG := n endif @@ -323,13 +320,13 @@ COPTS := -W3 CXXOPTS := -EHsc DOPTS := ifeq ($(X64), y) -LOPTS := -MACHINE:$(ARCH) -LIBPATH:win\msvc\Lib\$(ARCH) -LOPTS_C := -SUBSYSTEM:CONSOLE -LOPTS_W := -SUBSYSTEM:WINDOWS + LOPTS := -MACHINE:$(ARCH) -LIBPATH:win\msvc\Lib\$(ARCH) + LOPTS_C := -SUBSYSTEM:CONSOLE + LOPTS_W := -SUBSYSTEM:WINDOWS else -LOPTS := -MACHINE:$(ARCH) -LIBPATH:win\msvc\Lib\$(ARCH) -LOPTS_C := -SUBSYSTEM:CONSOLE,5.01 -LOPTS_W := -SUBSYSTEM:WINDOWS,5.01 + LOPTS := -MACHINE:$(ARCH) -LIBPATH:win\msvc\Lib\$(ARCH) + LOPTS_C := -SUBSYSTEM:CONSOLE,5.01 + LOPTS_W := -SUBSYSTEM:WINDOWS,5.01 endif ifdef BUILD OPTS += -DBUILD=$(BUILD) @@ -379,10 +376,6 @@ endif ifeq ($(PROFILER), y) LOPTS += /MAP endif -ifeq ($(VRAMDUMP), y) - OPTS += -DENABLE_VRAM_DUMP - RFLAGS += -DENABLE_VRAM_DUMP -endif ifeq ($(X64), y) PLATCG := codegen_x86-64.obj CGOPS := codegen_ops_x86-64.h @@ -450,7 +443,6 @@ endif # N=no, Y=yes,linked, D=yes,dynamic, S=yes,static ifneq ($(SDL), n) OPTS += -DUSE_SDL - RFLAGS += -DUSE_SDL ifneq ($(SDL_PATH), ) OPTS += -I$(SDL_PATH)/include/msvc -I$(SDL_PATH)/include ifeq ($(X64), y) @@ -472,7 +464,6 @@ ifneq ($(D2D), n) else OPTS += -DUSE_D2D=1 endif - RFLAGS += -DUSE_D2D ifneq ($(D2D_PATH), ) OPTS += -I$(D2D_PATH)/include/msvc -I$(D2D_PATH)/include ifeq ($(X64), y) @@ -498,7 +489,6 @@ endif # N=no, Y=yes,linked, D=yes,dynamic, S=yes,static ifneq ($(VNC), n) OPTS += -DUSE_VNC - RFLAGS += -DUSE_VNC ifneq ($(VNC_PATH), ) OPTS += -I$(VNC_PATH)/include/msvc -I$(VNC_PATH)/include ifeq ($(X64), y) @@ -516,7 +506,6 @@ endif # N=no, Y=yes,linked, D=yes,dynamic, S=yes,static ifneq ($(RDP), n) OPTS += -DUSE_RDP - RFLAGS += -DUSE_RDP ifneq ($(RDP_PATH), ) OPTS += -I$(RDP_PATH)/include/msvc -I$(RDP_PATH)/include ifeq ($(X64), y) @@ -538,7 +527,6 @@ ifneq ($(PNG), n) else OPTS += -DUSE_LIBPNG=1 endif - RFLAGS += -DUSE_LIBPNG ifneq ($(PNG_PATH), ) OPTS += -I$(PNG_PATH)/include/msvc -I$(PNG_PATH)/include ifeq ($(X64), y) diff --git a/src/win/win_d2d.cpp b/src/win/win_d2d.cpp index f8d8eff..e6e35c6 100644 --- a/src/win/win_d2d.cpp +++ b/src/win/win_d2d.cpp @@ -8,7 +8,10 @@ * * Rendering module for Microsoft Direct2D. * - * Version: @(#)win_d2d.cpp 1.0.4 2019/03/08 + * **NOTE** This module currently does not work when compiled using + * the GCC compiler (MinGW) and when used in dynamic mode. + * + * Version: @(#)win_d2d.cpp 1.0.5 2019/04/28 * * Authors: Fred N. van Kempen, * David Hrdlicka, @@ -61,7 +64,7 @@ #if USE_D2D == 2 -# define DLLFUNC(x) D2D1_ ## x +# define DLLFUNC(x) D2D1_##x /* Pointers to the real functions. */ @@ -77,7 +80,7 @@ static const dllimp_t d2d_imports[] = { static void *d2d_handle = NULL; #else -# define DLLFUNC(x) D2D1 ## x +# define DLLFUNC(x) D2D1##x #endif @@ -338,13 +341,14 @@ d2d_init(int fs) { WCHAR title[200]; D2D1_HWND_RENDER_TARGET_PROPERTIES props; - HRESULT hr; + HRESULT hr = S_OK; INFO("D2D: init(fs=%d)\n", fs); #if USE_D2D == 2 /* Try loading the DLL. */ - d2d_handle = dynld_module(PATH_D2D_DLL, d2d_imports); + if (d2d_handle == NULL) + d2d_handle = dynld_module(PATH_D2D_DLL, d2d_imports); if (d2d_handle == NULL) { ERRLOG("D2D: unable to load '%s', D2D not available.\n", PATH_D2D_DLL); return(0); @@ -352,16 +356,6 @@ d2d_init(int fs) INFO("D2D: module '%s' loaded.\n", PATH_D2D_DLL); #endif - hr = DLLFUNC(CreateFactory)(D2D1_FACTORY_TYPE_MULTI_THREADED, - __uuidof(ID2D1Factory), - NULL, - reinterpret_cast (&d2d_factory)); - if (FAILED(hr)) { - ERRLOG("D2D: unable to load factory, D2D not available.\n"); - d2d_close(); - return(0); - } - if (fs) { /* * Direct2D seems to lack any proper fullscreen mode, @@ -397,6 +391,16 @@ d2d_init(int fs) props = D2D1::HwndRenderTargetProperties(hwndRender); } + hr = DLLFUNC(CreateFactory)(D2D1_FACTORY_TYPE_MULTI_THREADED, + __uuidof(ID2D1Factory), + NULL, + reinterpret_cast (&d2d_factory)); + if (FAILED(hr)) { + ERRLOG("D2D: unable to load factory, D2D not available.\n"); + d2d_close(); + return(0); + } + hr = d2d_factory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(), props, &d2d_hwndRT); if (SUCCEEDED(hr)) { diff --git a/src/win/win_dynld.c b/src/win/win_dynld.c index 4818d8d..4e8f585 100644 --- a/src/win/win_dynld.c +++ b/src/win/win_dynld.c @@ -8,11 +8,11 @@ * * Try to load a support DLL. * - * Version: @(#)win_dynld.c 1.0.7 2018/10/05 + * Version: @(#)win_dynld.c 1.0.8 2019/04/28 * - * Authors: Fred N. van Kempen, + * Author: Fred N. van Kempen, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. * * Redistribution and use in source and binary forms, with * or without modification, are permitted provided that the @@ -64,7 +64,7 @@ dynld_module(const char *name, const dllimp_t *table) /* See if we can load the desired module. */ if ((h = LoadLibrary(name)) == NULL) { - ERRLOG("DynLd(\"%s\"): library not found!\n", name); + DEBUG("DynLd(\"%s\"): library not found!\n", name); return(NULL); }