diff --git a/src/disk/hdd.c b/src/disk/hdd.c index ef87d8c5a..e4f682dd9 100644 --- a/src/disk/hdd.c +++ b/src/disk/hdd.c @@ -8,7 +8,7 @@ * * Common code to handle all sorts of hard disk images. * - * Version: @(#)hdd.c 1.0.6 2017/11/01 + * Version: @(#)hdd.c 1.0.7 2017/11/18 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -21,6 +21,7 @@ #include #include #include "../86box.h" +#include "../plat.h" #include "../ui.h" #include "hdd.h" diff --git a/src/game/gameport.h b/src/game/gameport.h index af663b78b..7b8d90d61 100644 --- a/src/game/gameport.h +++ b/src/game/gameport.h @@ -24,6 +24,12 @@ typedef struct char pov_names[4][32]; } joystick_if_t; + + +#ifdef __cplusplus +extern "C" { +#endif + extern device_t gameport_device; extern device_t gameport_201_device; @@ -41,5 +47,9 @@ extern char *joystick_get_pov_name(int64_t joystick, int64_t id); extern void gameport_update_joystick_type(void); +#ifdef __cplusplus +} +#endif + #endif /*EMU_GAMEPORT_H*/ diff --git a/src/lang/language.h b/src/lang/language.h new file mode 100644 index 000000000..4ed67f79f --- /dev/null +++ b/src/lang/language.h @@ -0,0 +1,232 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Definitions for the language management module. + * + * NOTE: FIXME: Strings 2176 and 2193 are same. + * + * Version: @(#)language.h 1.0.3 2017/11/18 + * + * Author: Fred N. van Kempem, + * + * Copyright 2017 Fred N. van Kempen. + */ +#ifndef LANG_UAGE_H +# define LANG_UAGE_H + + +/* String IDs. */ +#define IDS_STRINGS 2048 // "86Box" +#define IDS_2049 2049 // "86Box Error" +#define IDS_2050 2050 // "86Box Fatal Error" +#define IDS_2051 2051 // "This will reset 86Box.." +#define IDS_2052 2052 // "DirectDraw Screenshot Error" +#define IDS_2053 2053 // "Invalid number of sectors.." +#define IDS_2054 2054 // "Invalid number of heads.." +#define IDS_2055 2055 // "Invalid number of cylinders.." +#define IDS_2056 2056 // "No usable ROM images found!" +#define IDS_2057 2057 // "(empty)" +#define IDS_2058 2058 // "(host drive %c:)" +#define IDS_2059 2059 // "(Turbo)" +#define IDS_2060 2060 // "On" +#define IDS_2061 2061 // "Off" +#define IDS_2062 2062 // "86Box was unable to find any.." +#define IDS_2063 2063 // "Configured ROM set not avai.." +#define IDS_2064 2064 // "Configured video BIOS not.." +#define IDS_2065 2065 // "Machine" +#define IDS_2066 2066 // "Display" +#define IDS_2067 2067 // "Input devices" +#define IDS_2068 2068 // "Sound" +#define IDS_2069 2069 // "Network" +#define IDS_2070 2070 // "Ports (COM & LPT)" +#define IDS_2071 2071 // "Other peripherals" +#define IDS_2072 2072 // "Hard disks" +#define IDS_2073 2073 // "Removable devices" +#define IDS_2074 2074 // "Use CTRL+ALT+PAGE DOWN.." +#define IDS_2075 2075 // "CD-ROM images (*.ISO;*.CU.." +#define IDS_2076 2076 // "Host CD/DVD Drive (%c:)" +#define IDS_2077 2077 // "Click to capture mouse" +#define IDS_2078 2078 // "Press F12-F8 to release mouse" +#define IDS_2079 2079 // "Press F12-F8 or middle button.." +#define IDS_2080 2080 // "Drive" +#define IDS_2081 2081 // "Location" +#define IDS_2082 2082 // "Bus" +#define IDS_2083 2083 // "File" +#define IDS_2084 2084 // "C" +#define IDS_2085 2085 // "H" +#define IDS_2086 2086 // "S" +#define IDS_2087 2087 // "MB" +#define IDS_2088 2088 // "Unable to create bitmap file: %s" +#define IDS_2089 2089 // "Enabled" +#define IDS_2090 2090 // "Mute" +#define IDS_2091 2091 // "Type" +#define IDS_2092 2092 // "Bus" +#define IDS_2093 2093 // "DMA" +#define IDS_2094 2094 // "KB" +#define IDS_2095 2095 // "Neither DirectDraw nor Dire.." +#define IDS_2096 2096 // "Slave" +#define IDS_2097 2097 // "SCSI (ID %s, LUN %s)" +#define IDS_2098 2098 // "Adapter Type" +#define IDS_2099 2099 // "Base Address" +#define IDS_2100 2100 // "IRQ" +#define IDS_2101 2101 // "8-bit DMA" +#define IDS_2102 2102 // "16-bit DMA" +#define IDS_2103 2103 // "BIOS" +#define IDS_2104 2104 // "Network Type" +#define IDS_2105 2105 // "Surround Module" +#define IDS_2106 2106 // "MPU-401 Base Address" +#define IDS_2107 2107 // "PCAP not found.." +#define IDS_2108 2108 // "On-board RAM" +#define IDS_2109 2109 // "Memory Size" +#define IDS_2110 2110 // "Display Type" +#define IDS_2111 2111 // "RGB" +#define IDS_2112 2112 // "Composite" +#define IDS_2113 2113 // "Composite Type" +#define IDS_2114 2114 // "Old" +#define IDS_2115 2115 // "New" +#define IDS_2116 2116 // "RGB Type" +#define IDS_2117 2117 // "Color" +#define IDS_2118 2118 // "Monochrome (Green)" +#define IDS_2119 2119 // "Monochrome (Amber)" +#define IDS_2120 2120 // "Monochrome (Gray)" +#define IDS_2121 2121 // "Color (no brown)" +#define IDS_2122 2122 // "Monochrome (Default)" +#define IDS_2123 2123 // "Snow Emulation" +#define IDS_2124 2124 // "Bilinear Filtering" +#define IDS_2125 2125 // "Dithering" +#define IDS_2126 2126 // "Framebuffer Memory Size" +#define IDS_2127 2127 // "Texture Memory Size" +#define IDS_2128 2128 // "Screen Filter" +#define IDS_2129 2129 // "Render Threads" +#define IDS_2130 2130 // "Recompiler" +#define IDS_2131 2131 // "System Default" +#define IDS_2132 2132 // "%i Wait state(s)" +#define IDS_2133 2133 // "8-bit" +#define IDS_2134 2134 // "Slow 16-bit" +#define IDS_2135 2135 // "Fast 16-bit" +#define IDS_2136 2136 // "Slow VLB/PCI" +#define IDS_2137 2137 // "Mid VLB/PCI" +#define IDS_2138 2138 // "Fast VLB/PCI" +#define IDS_2139 2139 // "PCap failed to set up.." +#define IDS_2140 2140 // "No PCap devices found" +#define IDS_2141 2141 // "Invalid PCap device" +#define IDS_2142 2142 // "&Notify disk change" +#define IDS_2143 2143 // "Type" +#define IDS_2144 2144 // "Standard 2-button joystick(s)" +#define IDS_2145 2145 // "Standard 4-button joystick" +#define IDS_2146 2146 // "Standard 6-button joystick" +#define IDS_2147 2147 // "Standard 8-button joystick" +#define IDS_2148 2148 // "CH Flightstick Pro" +#define IDS_2149 2149 // "Microsoft SideWinder Pad" +#define IDS_2150 2150 // "Thrustmaster Flight Cont.." +#define IDS_2151 2151 // "Disabled" +#define IDS_2152 2152 // "None" +#define IDS_2153 2153 // "Unable to load Accelerators" +#define IDS_2154 2154 // "Unable to register Raw Input" +#define IDS_2155 2155 // "IRQ %i" +#define IDS_2156 2156 // "%" PRIu64 +#define IDS_2157 2157 // "%" PRIu64 " MB (CHS: %".." +#define IDS_2158 2158 // "Floppy %i (%s): %ls" +#define IDS_2159 2159 // "All floppy images (*.0??;*.." +#define IDS_2160 2160 // "Configuration files (*.CF.." +#define IDS_2161 2161 // "&New image..." +#define IDS_2162 2162 // "Existing image..." +#define IDS_2163 2163 // "Existing image (&Write-pr..." +#define IDS_2164 2164 // "E&ject" +#define IDS_2165 2165 // "&Mute" +#define IDS_2166 2166 // "E&mpty" +#define IDS_2167 2167 // "&Reload previous image" +#define IDS_2168 2168 // "&Image..." +#define IDS_2169 2169 // "Image (&Write-protected)..." +#define IDS_2170 2170 // "Check BPB" +#define IDS_2171 2171 // "Unable to initialize Flui.." + +#define IDS_3072 3072 // "None" +#define IDS_3073 3073 // "Internal" +#define IDS_3074 3074 // "[Bus] Logitech Bus Mouse" +#define IDS_3075 3075 // "[Bus] Microsoft Bus Mous.." +#define IDS_3076 3076 // "[Serial] Mouse Systems Mouse" +#define IDS_3077 3077 // "[Serial] Microsoft 2-button Mouse" +#define IDS_3078 3078 // "[Serial] Logitech 3-button Mouse" +#define IDS_3079 3079 // "[Serial] Microsoft Wheel Mouse" +#define IDS_3080 3080 // "[PS/2] 2-button Mouse" +#define IDS_3081 3081 // "[PS/2] Microsoft Intellimouse" +#define IDS_3082 3082 // "[Proprietary] Amstrad Mouse" +#define IDS_3083 3083 // "[Proprietary] Olivetti M24.." + +#define IDS_4096 4096 // "Hard disk (%s)" +#define IDS_4097 4097 // "%01i:%01i" +#define IDS_4098 4098 // "%i" +#define IDS_4099 4099 // "Disabled" +#define IDS_4100 4100 // "Custom..." +#define IDS_4101 4101 // "Custom (large)..." +#define IDS_4102 4102 // "Add New Hard Disk" +#define IDS_4103 4103 // "Add Existing Hard Disk" +#define IDS_4104 4104 // "Attempting to create a HDI ima.." +#define IDS_4105 4105 // "Attempting to create a spurio.." +#define IDS_4106 4106 // "Hard disk images (*.HDI;*.HD.." +#define IDS_4107 4107 // "Unable to open the file for read" +#define IDS_4108 4108 // "Unable to open the file for write" +#define IDS_4109 4109 // "HDI or HDX image with a sect.." +#define IDS_4110 4110 // "USB is not yet supported" +#define IDS_4111 4111 // "This image exists and will be.." +#define IDS_4112 4112 // "Please enter a valid file name" +#define IDS_4113 4113 // "Remember to partition and fo.." +#define IDS_4114 4114 // "MFM/RLL or ESDI CD-ROM driv.." +#define IDS_4115 4115 // "Removable disk %i (SCSI): %ls" + +#define IDS_4352 4352 // "MFM/RLL" +#define IDS_4353 4353 // "XT IDE" +#define IDS_4354 4354 // "ESDI" +#define IDS_4355 4355 // "IDE (PIO-only)" +#define IDS_4356 4356 // "IDE (PIO+DMA)" +#define IDS_4357 4357 // "SCSI" +#define IDS_4358 4358 // "SCSI (removable)" + +#define IDS_4608 4608 // "MFM/RLL (%01i:%01i)" +#define IDS_4609 4609 // "XT IDE (%01i:%01i)" +#define IDS_4610 4610 // "ESDI (%01i:%01i)" +#define IDS_4611 4611 // "IDE (PIO-only) (%01i:%01i)" +#define IDS_4612 4612 // "IDE (PIO+DMA) (%01i:%01i)" +#define IDS_4613 4613 // "SCSI (%02i:%02i)" +#define IDS_4614 4614 // "SCSI (removable) (%02i:%02i)" + +#define IDS_5120 5120 // "CD-ROM %i (%s): %s" + +#define IDS_5376 5376 // "Disabled" +#define IDS_5377 5377 // "" +#define IDS_5378 5378 // "" +#define IDS_5379 5379 // "" +#define IDS_5380 5380 // "ATAPI (PIO-only)" +#define IDS_5381 5381 // "ATAPI (PIO and DMA)" +#define IDS_5382 5382 // "SCSI" + +#define IDS_5632 5632 // "Disabled" +#define IDS_5633 5633 // "" +#define IDS_5634 5634 // "" +#define IDS_5635 5635 // "" +#define IDS_5636 5636 // "ATAPI (PIO-only) (%01i:%01i)" +#define IDS_5637 5637 // "ATAPI (PIO and DMA) (%01i:%01i)" +#define IDS_5638 5638 // "SCSI (%02i:%02i)" + +#define IDS_6144 6144 // "English (United States)" + +#define IDS_LANG_ENUS IDS_6144 + +#define STR_NUM_2048 124 +#define STR_NUM_3072 11 +#define STR_NUM_4096 20 +#define STR_NUM_4352 7 +#define STR_NUM_4608 7 +#define STR_NUM_5120 1 +#define STR_NUM_5376 7 +#define STR_NUM_5632 7 +#define STR_NUM_6144 1 + + +#endif /*LANG_UAGE_H*/ diff --git a/src/plat.h b/src/plat.h index 97563986f..4e739476b 100644 --- a/src/plat.h +++ b/src/plat.h @@ -8,7 +8,7 @@ * * Define the various platform support functions. * - * Version: @(#)plat.h 1.0.20 2017/11/18 + * Version: @(#)plat.h 1.0.21 2017/11/18 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -23,10 +23,8 @@ # define GLOBAL extern #endif - -#ifndef _WIN32 -# define RENDER_FPS 30 /* default render speed */ -#endif +/* String ID numbers. */ +#include "lang/language.h" /* The Win32 API uses _wcsicmp. */ #ifdef _WIN32 diff --git a/src/ui.h b/src/ui.h index f1da22301..794b2995a 100644 --- a/src/ui.h +++ b/src/ui.h @@ -8,7 +8,7 @@ * * Define the various UI functions. * - * Version: @(#)ui.h 1.0.9 2017/11/01 + * Version: @(#)ui.h 1.0.10 2017/11/18 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -24,14 +24,10 @@ extern "C" { #endif -/* Strings. Those are defined within the platform. */ -#ifdef _WIN32 -# include "win/resource.h" -#endif -#ifdef UNIX -# include "unix/resource.h" -#endif +#ifdef USE_WX +# define RENDER_FPS 30 /* default render speed */ +#endif /* Message Box functions. */ #define MBX_INFO 1 diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index 4df49fde5..f1b89b5c9 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -84,26 +84,21 @@ static int tris = 0; static uint64_t status_time = 0; -typedef union int_float -{ +typedef union { uint32_t i; float f; } int_float; -typedef struct rgb_t -{ +typedef struct { uint8_t b, g, r; uint8_t pad; -} rgb_t; -typedef struct rgba8_t -{ +} rgbp_t; +typedef struct { uint8_t b, g, r, a; } rgba8_t; -typedef union rgba_u -{ - struct - { +typedef union { + struct { uint8_t b, g, r, a; } rgba; uint32_t u; @@ -175,7 +170,7 @@ typedef struct voodoo_params_t uint32_t fbzColorPath; uint32_t fogMode; - rgb_t fogColor; + rgbp_t fogColor; struct { uint8_t fog, dfog; @@ -401,9 +396,9 @@ typedef struct voodoo_t int dst_stride; } blt; - rgb_t clutData[33]; + rgbp_t clutData[33]; int clutData_dirty; - rgb_t clutData256[256]; + rgbp_t clutData256[256]; uint32_t video_16to32[0x10000]; uint8_t dirty_line[1024]; diff --git a/src/video/vid_voodoo_codegen_x86-64.h b/src/video/vid_voodoo_codegen_x86-64.h index f9f41e570..56b154830 100644 --- a/src/video/vid_voodoo_codegen_x86-64.h +++ b/src/video/vid_voodoo_codegen_x86-64.h @@ -6,13 +6,11 @@ */ #ifdef __linux__ -#include -#include +# include +# include #endif #if WIN64 -#define BITMAP windows_BITMAP -#include -#undef BITMAP +# include #endif #include diff --git a/src/video/vid_voodoo_codegen_x86.h b/src/video/vid_voodoo_codegen_x86.h index dc6bb9e33..9551216f9 100644 --- a/src/video/vid_voodoo_codegen_x86.h +++ b/src/video/vid_voodoo_codegen_x86.h @@ -6,13 +6,11 @@ */ #ifdef __linux__ -#include -#include +# include +# include #endif #if defined WIN32 || defined _WIN32 || defined _WIN32 -#define BITMAP windows_BITMAP -#include -#undef BITMAP +# include #endif #include diff --git a/src/video/video.c b/src/video/video.c index 05f1634e8..1302ef1de 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -40,7 +40,7 @@ * W = 3 bus clocks * L = 4 bus clocks * - * Version: @(#)video.c 1.0.9 2017/11/05 + * Version: @(#)video.c 1.0.10 2017/11/18 * * Authors: Sarah Walker, * Miran Grca, @@ -73,9 +73,9 @@ enum { }; -BITMAP *screen = NULL; -BITMAP *buffer= NULL, - *buffer32= NULL; +bitmap_t *screen = NULL, + *buffer = NULL, + *buffer32 = NULL; uint8_t fontdat[256][8]; /* IBM CGA font */ uint8_t fontdatm[256][16]; /* IBM MDA font */ uint8_t fontdatw[512][32]; /* Wyse700 font */ @@ -414,7 +414,7 @@ calc_16to32(int c) void -hline(BITMAP *b, int x1, int y, int x2, uint32_t col) +hline(bitmap_t *b, int x1, int y, int x2, uint32_t col) { if (y < 0 || y >= buffer->h) return; @@ -427,19 +427,19 @@ hline(BITMAP *b, int x1, int y, int x2, uint32_t col) void -blit(BITMAP *src, BITMAP *dst, int x1, int y1, int x2, int y2, int xs, int ys) +blit(bitmap_t *src, bitmap_t *dst, int x1, int y1, int x2, int y2, int xs, int ys) { } void -stretch_blit(BITMAP *src, BITMAP *dst, int x1, int y1, int xs1, int ys1, int x2, int y2, int xs2, int ys2) +stretch_blit(bitmap_t *src, bitmap_t *dst, int x1, int y1, int xs1, int ys1, int x2, int y2, int xs2, int ys2) { } void -rectfill(BITMAP *b, int x1, int y1, int x2, int y2, uint32_t col) +rectfill(bitmap_t *b, int x1, int y1, int x2, int y2, uint32_t col) { } @@ -451,15 +451,18 @@ set_palette(PALETTE p) void -destroy_bitmap(BITMAP *b) +destroy_bitmap(bitmap_t *b) { + if (b->dat != NULL) + free(b->dat); + free(b); } -BITMAP * +bitmap_t * create_bitmap(int x, int y) { - BITMAP *b = malloc(sizeof(BITMAP) + (y * sizeof(uint8_t *))); + bitmap_t *b = malloc(sizeof(bitmap_t) + (y * sizeof(uint8_t *))); int c; b->dat = malloc(x * y * 4); diff --git a/src/video/video.h b/src/video/video.h index 539194d5e..6b64f968c 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -8,7 +8,7 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.3 2017/11/05 + * Version: @(#)video.h 1.0.4 2017/11/18 * * Authors: Sarah Walker, * Miran Grca, @@ -125,13 +125,13 @@ typedef struct { int w, h; uint8_t *dat; uint8_t *line[]; -} BITMAP; +} bitmap_t; typedef struct { uint8_t r, g, b; -} RGB; +} rgb_t; -typedef RGB PALETTE[256]; +typedef rgb_t PALETTE[256]; extern int gfx_present[GFX_MAX]; @@ -139,7 +139,7 @@ extern int egareads, egawrites; extern int changeframecount; -extern BITMAP *screen, +extern bitmap_t *screen, *buffer, *buffer32; extern PALETTE cgapal, @@ -203,10 +203,10 @@ extern void video_blit_complete(void); extern void video_wait_for_blit(void); extern void video_wait_for_buffer(void); -extern BITMAP *create_bitmap(int w, int h); -extern void destroy_bitmap(BITMAP *b); +extern bitmap_t *create_bitmap(int w, int h); +extern void destroy_bitmap(bitmap_t *b); extern void cgapal_rebuild(void); -extern void hline(BITMAP *b, int x1, int y, int x2, uint32_t col); +extern void hline(bitmap_t *b, int x1, int y, int x2, uint32_t col); extern void updatewindowsize(int x, int y); extern void video_init(void); diff --git a/src/vnc.c b/src/vnc.c index a21152968..781f37014 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -8,7 +8,7 @@ * * Implement the VNC remote renderer with LibVNCServer. * - * Version: @(#)vnc.c 1.0.8 2017/10/25 + * Version: @(#)vnc.c 1.0.9 2017/11/18 * * Authors: Fred N. van Kempen, * Based on raw code by RichardG, @@ -20,9 +20,7 @@ #include #include #include -#define BITMAP MY_BITMAP #include -#undef BITMAP #include "86box.h" #include "device.h" #include "video/video.h" diff --git a/src/win/86Box.rc b/src/win/86Box.rc index f9acec7db..306e3687f 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -6,9 +6,9 @@ * * This file is part of the 86Box distribution. * - * Windows resource script. + * Application resource script for Windows. * - * Version: @(#)86Box.rc 1.0.19 2017/11/12 + * Version: @(#)86Box.rc 1.0.20 2017/11/18 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -19,6 +19,7 @@ #define IN_RESOURCE_H #include "resource.h" #include "../86box.h" +#include "../plat.h" #undef IN_RESOURCE_H #define APSTUDIO_READONLY_SYMBOLS diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index a39ae9f4e..93b1d861f 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -8,17 +8,12 @@ # # Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.77 2017/11/17 +# Version: @(#)Makefile.mingw 1.0.78 2017/11/18 # # Authors: Miran Grca, # Fred N. van Kempen, # -# Name of the executable. -ifndef PROG -PROG := 86Box -endif - # Various compile-time options. ifndef STUFF STUFF := @@ -45,11 +40,17 @@ endif ifndef RELEASE RELEASE := n endif +ifndef X64 +X64 := n +endif +ifndef WX +WX := n +endif ifndef USB USB := n endif ifndef VNC -VNC := n +VNC := y endif ifndef RDP RDP := n @@ -84,8 +85,15 @@ endif ifndef DYNAREC DYNAREC := y endif -ifndef X64 -X64 := n + + +# Name of the executable. +ifndef PROG + ifneq ($(WX), n) + PROG := Wx86Box + else + PROG := 86Box + endif endif ifeq ($(DEV_BUILD), y) @@ -94,7 +102,38 @@ CIRRUS := y NE1000 := y NV_RIVA := y PAS16 := y -VNC := y +endif + +# WxWidgets basic info. Extract using the config program. +ifneq ($(WX), n) + EXPATH += wx + WX_CONFIG := wx-config.exe + ifeq ($(WX), y) + WX_PATH := C:/MinGW32/WxWidgets + WX_FLAGS := -I$(WX_PATH)/lib/wx/include/msw-unicode-3.0 \ + -I$(WX_PATH)/include/wx-3.0 \ + -D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -pthread +# -lwx_mswu_gl-3.0 -lwxtiff-3.0 -llzma + WX_LIBS := -mwindows -mthreads -L$(WX_PATH)/lib \ + -lwx_mswu-3.0.dll \ + -lrpcrt4 -loleaut32 -lole32 -luuid \ + -lwinspool -lwinmm -lshell32 -lcomctl32 \ + -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32 + endif + ifeq ($(WX), static) + WX_PATH := C:/MinGW32/WxWidgets + WX_FLAGS := -I$(WX_PATH)/lib/wx/include/msw-unicode-3.0 \ + -I$(WX_PATH)/include/wx-3.0 \ + -D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -pthread +# -lwx_mswu_gl-3.0 -lwxtiff-3.0 -llzma + WX_LIBS := -mwindows -mthreads -L$(WX_PATH)/lib \ + -lwx_mswu-3.0 -lwxscintilla-3.0 \ + -lwxjpeg-3.0 -lwxpng-3.0 -lwxzlib-3.0 \ + -lwxregexu-3.0 -lwxexpat-3.0 \ + -lrpcrt4 -loleaut32 -lole32 -luuid \ + -lwinspool -lwinmm -lshell32 -lcomctl32 \ + -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32 + endif endif @@ -159,18 +198,16 @@ else endif endif AFLAGS := -msse -msse2 -mfpmath=sse -CFLAGS := $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) $(AFLAGS) \ - -fomit-frame-pointer -mstackrealign -Wall RFLAGS := --input-format=rc -O coff ifeq ($(CRASHDUMP), y) -CFLAGS += -DUSE_CRASHDUMP +OPTS += -DUSE_CRASHDUMP endif ifeq ($(RELEASE), y) -CFLAGS += -DRELEASE_BUILD +OPTS += -DRELEASE_BUILD RFLAGS += -DRELEASE_BUILD endif ifeq ($(VRAMDUMP), y) -CFLAGS += -DENABLE_VRAM_DUMP +OPTS += -DENABLE_VRAM_DUMP RFLAGS += -DENABLE_VRAM_DUMP endif ifeq ($(X64), y) @@ -186,7 +223,7 @@ endif # Optional modules. ifeq ($(DYNAREC), y) -CFLAGS += -DUSE_DYNAREC +OPTS += -DUSE_DYNAREC RFLAGS += -DUSE_DYNAREC DYNARECOBJ := 386_dynarec_ops.o \ codegen.o \ @@ -196,16 +233,26 @@ DYNARECOBJ := 386_dynarec_ops.o \ codegen_timing_winchip.o $(PLATCG) endif +ifneq ($(WX), n) + OPTS += -DUSE_WX $(WX_FLAGS) + LIBS += $(WX_LIBS) + UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o +else + UIOBJ := win_ui.o win_ddraw.o win_d3d.o win_png.o \ + win_dialog.o win_about.o win_status.o win_stbar.o \ + win_settings.o win_devconf.o win_jsconf.o +endif + ifeq ($(OPENAL), y) -CFLAGS += -DUSE_OPENAL +OPTS += -DUSE_OPENAL endif ifeq ($(FLUIDSYNTH), y) -CFLAGS += -DUSE_FLUIDSYNTH +OPTS += -DUSE_FLUIDSYNTH FSYNTHOBJ := midi_fluidsynth.o endif ifeq ($(MUNT), y) -CFLAGS += -DUSE_MUNT +OPTS += -DUSE_MUNT MUNTOBJ := midi_mt32.o \ Analog.o BReverbModel.o File.o FileStream.o LA32Ramp.o \ LA32FloatWaveGenerator.o LA32WaveGenerator.o \ @@ -215,10 +262,10 @@ MUNTOBJ := midi_mt32.o \ endif ifeq ($(VNC), y) -CFLAGS += -DUSE_VNC +OPTS += -DUSE_VNC RFLAGS += -DUSE_VNC ifneq ($(VNC_PATH), ) - CFLAGS += -I$(VNC_PATH)\INCLUDE + OPTS += -I$(VNC_PATH)\INCLUDE VNCLIB := -L$(VNC_PATH)\LIB endif VNCLIB += -lvncserver @@ -226,10 +273,10 @@ VNCOBJ := vnc.o vnc_keymap.o endif ifeq ($(RDP), y) -CFLAGS += -DUSE_RDP +OPTS += -DUSE_RDP RFLAGS += -DUSE_RDP ifneq ($(RDP_PATH), ) - CFLAGS += -I$(RDP_PATH)\INCLUDE + OPTS += -I$(RDP_PATH)\INCLUDE RDPLIB := -L$(RDP_PATH)\LIB endif RDPLIB += -lrdp @@ -238,25 +285,25 @@ endif # Options for the DEV branch. ifeq ($(DEV_BRANCH), y) -CFLAGS += -DDEV_BRANCH +OPTS += -DDEV_BRANCH DEVBROBJ := ifeq ($(CIRRUS), y) -CFLAGS += -DUSE_CIRRUS +OPTS += -DUSE_CIRRUS DEVBROBJ += vid_cl_gd.o vid_cl_gd_blit.o vid_cl_ramdac.o endif ifeq ($(NE1000), y) -CFLAGS += -DUSE_NE1000 +OPTS += -DUSE_NE1000 endif ifeq ($(NV_RIVA), y) -CFLAGS += -DUSE_RIVA +OPTS += -DUSE_RIVA DEVBROBJ += vid_nv_riva128.o endif ifeq ($(PAS16), y) -CFLAGS += -DUSE_PAS16 +OPTS += -DUSE_PAS16 DEVBROBJ += snd_pas16.o endif @@ -272,41 +319,14 @@ EUROPC := m_europc.o endif -ifeq ($(WX), y) -CFLAGS += -I$(WXLIB)/wx/include/msw-unicode-3.0 -I$(WXINC) \ - -D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -# -lwx_mswu_gl-3.0.dll -llzma -WXLIBS := -mwindows -mthreads \ - -L$(WXLIB) \ - -lwx_mswu-3.0.dll \ - -lrpcrt4 -loleaut32 -lole32 -luuid \ - -lwinspool -lwinmm -lshell32 -lcomctl32 \ - -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32 -endif - -ifeq ($(WX), static) -CFLAGS += -I$(WXLIB)/wx/include/msw-unicode-3.0 -I$(WXINC) \ - -D__WXMSW__ -DWX_PRECOMP -D_FILE_OFFSET_BITS=64 -# -lwx_mswu_gl-3.0 -lwxtiff-3.0 -llzma -WXLIBS := -mwindows -mthreads \ - -L$(WXLIB) \ - -lwx_mswu-3.0 -lwxscintilla-3.0 \ - -lwxjpeg-3.0 -lwxpng-3.0 -lwxzlib-3.0 \ - -lwxregexu-3.0 -lwxexpat-3.0 \ - -lrpcrt4 -loleaut32 -lole32 -luuid \ - -lwinspool -lwinmm -lshell32 -lcomctl32 \ - -lcomdlg32 -ladvapi32 -lwsock32 -lgdi32 -endif - - # Final versions of the toolchain flags. -#CFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ -# $(AFLAGS) -fomit-frame-pointer -mstackrealign -Wall -#CXXFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(AOPTIM) \ -# $(AFLAGS) -fno-strict-aliasing -fvisibility=hidden \ -# -Wall -Wundef -fvisibility-inlines-hidden \ -# -Wunused-parameter -Wno-ctor-dtor-privacy \ -# -Woverloaded-virtual +CFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ + $(AFLAGS) -fomit-frame-pointer -mstackrealign -Wall +CXXFLAGS := $(WX_FLAGS) $(OPTS) $(DFLAGS) $(COPTIM) $(AOPTIM) \ + $(AFLAGS) -fno-strict-aliasing -fvisibility=hidden \ + -Wall -Wundef -fvisibility-inlines-hidden \ + -Wunused-parameter -Wno-ctor-dtor-privacy \ + -Woverloaded-virtual ######################################################################### @@ -424,17 +444,14 @@ VIDOBJ := video.o \ vid_voodoo.o PLATOBJ := win.o \ - win_crashdump.o win_ddraw.o win_d3d.o win_png.o \ - win_dynld.o win_thread.o $(WSERIAL) win_video.o \ + win_crashdump.o win_dynld.o win_thread.o $(WSERIAL) \ win_cdrom.o win_cdrom_ioctl.o win_keyboard.o \ - win_mouse.o win_joystick.o win_midi.o \ - win_dialog.o win_about.o win_status.o win_stbar.o \ - win_settings.o win_deviceconfig.o win_joystickconfig.o + win_mouse.o win_joystick.o win_midi.o win_video.o OBJ := $(MAINOBJ) $(CPUOBJ) $(MCHOBJ) $(DEVOBJ) \ $(FDDOBJ) $(CDROMOBJ) $(HDDOBJ) \ $(USBOBJ) $(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) \ - $(PLATOBJ) $(DEVBROBJ) + $(PLATOBJ) $(UIOBJ) $(DEVBROBJ) ifdef EXOBJ OBJ += $(EXOBJ) endif @@ -451,6 +468,9 @@ endif ifeq ($(RDP), y) LIBS += $(RDPLIB) endif +ifneq ($(WX), n) +LIBS += $(WX_LIBS) -lz -lm +endif LIBS += -lkernel32 -lwsock32 -liphlpapi -lpsapi LIBS += -lpthread -static -lstdc++ -lgcc LIBS += -Wl,--large-address-aware @@ -464,11 +484,11 @@ ifeq ($(AUTODEP), y) %.o: %.cc @echo $< - @$(CPP) $(CFLAGS) $(DEPS) -c $< + @$(CPP) $(CXXFLAGS) $(DEPS) -c $< %.o: %.cpp @echo $< - @$(CPP) $(CFLAGS) $(DEPS) -c $< + @$(CPP) $(CXXFLAGS) $(DEPS) -c $< else %.o: %.c @echo $< @@ -476,11 +496,11 @@ else %.o: %.cc @echo $< - @$(CPP) $(CFLAGS) -c $< + @$(CPP) $(CXXFLAGS) -c $< %.o: %.cpp @echo $< - @$(CPP) $(CFLAGS) -c $< + @$(CPP) $(CXXFLAGS) -c $< %.d: %.c $(wildcard $*.d) @echo $< @@ -488,11 +508,11 @@ else %.d: %.cc $(wildcard $*.d) @echo $< - @$(CPP) $(CFLAGS) $(DEPS) -E $< >NUL + @$(CPP) $(CXXFLAGS) $(DEPS) -E $< >NUL %.d: %.cpp $(wildcard $*.d) @echo $< - @$(CPP) $(CFLAGS) $(DEPS) -E $< >NUL + @$(CPP) $(CXXFLAGS) $(DEPS) -E $< >NUL endif diff --git a/src/win/resource.h b/src/win/resource.h index 1d74dd7e4..eceb71025 100644 --- a/src/win/resource.h +++ b/src/win/resource.h @@ -8,9 +8,7 @@ * * Windows resource defines. * - * NOTE: FIXME: Strings 2176 and 2193 are same. - * - * Version: @(#)resource.h 1.0.13 2017/11/11 + * Version: @(#)resource.h 1.0.14 2017/11/18 * * Authors: Sarah Walker, * Miran Grca, @@ -202,215 +200,6 @@ #define IDC_STATUS 1282 -/* String IDs. */ -#define IDS_STRINGS 2048 // "86Box" -#define IDS_2049 2049 // "86Box Error" -#define IDS_2050 2050 // "86Box Fatal Error" -#define IDS_2051 2051 // "This will reset 86Box.." -#define IDS_2052 2052 // "DirectDraw Screenshot Error" -#define IDS_2053 2053 // "Invalid number of sectors.." -#define IDS_2054 2054 // "Invalid number of heads.." -#define IDS_2055 2055 // "Invalid number of cylinders.." -#define IDS_2056 2056 // "No usable ROM images found!" -#define IDS_2057 2057 // "(empty)" -#define IDS_2058 2058 // "(host drive %c:)" -#define IDS_2059 2059 // "(Turbo)" -#define IDS_2060 2060 // "On" -#define IDS_2061 2061 // "Off" -#define IDS_2062 2062 // "86Box was unable to find any.." -#define IDS_2063 2063 // "Configured ROM set not avai.." -#define IDS_2064 2064 // "Configured video BIOS not.." -#define IDS_2065 2065 // "Machine" -#define IDS_2066 2066 // "Display" -#define IDS_2067 2067 // "Input devices" -#define IDS_2068 2068 // "Sound" -#define IDS_2069 2069 // "Network" -#define IDS_2070 2070 // "Ports (COM & LPT)" -#define IDS_2071 2071 // "Other peripherals" -#define IDS_2072 2072 // "Hard disks" -#define IDS_2073 2073 // "Removable devices" -#define IDS_2074 2074 // "Use CTRL+ALT+PAGE DOWN.." -#define IDS_2075 2075 // "CD-ROM images (*.ISO;*.CU.." -#define IDS_2076 2076 // "Host CD/DVD Drive (%c:)" -#define IDS_2077 2077 // "Click to capture mouse" -#define IDS_2078 2078 // "Press F12-F8 to release mouse" -#define IDS_2079 2079 // "Press F12-F8 or middle button.." -#define IDS_2080 2080 // "Drive" -#define IDS_2081 2081 // "Location" -#define IDS_2082 2082 // "Bus" -#define IDS_2083 2083 // "File" -#define IDS_2084 2084 // "C" -#define IDS_2085 2085 // "H" -#define IDS_2086 2086 // "S" -#define IDS_2087 2087 // "MB" -#define IDS_2088 2088 // "Unable to create bitmap file: %s" -#define IDS_2089 2089 // "Enabled" -#define IDS_2090 2090 // "Mute" -#define IDS_2091 2091 // "Type" -#define IDS_2092 2092 // "Bus" -#define IDS_2093 2093 // "DMA" -#define IDS_2094 2094 // "KB" -#define IDS_2095 2095 // "Neither DirectDraw nor Dire.." -#define IDS_2096 2096 // "Slave" -#define IDS_2097 2097 // "SCSI (ID %s, LUN %s)" -#define IDS_2098 2098 // "Adapter Type" -#define IDS_2099 2099 // "Base Address" -#define IDS_2100 2100 // "IRQ" -#define IDS_2101 2101 // "8-bit DMA" -#define IDS_2102 2102 // "16-bit DMA" -#define IDS_2103 2103 // "BIOS" -#define IDS_2104 2104 // "Network Type" -#define IDS_2105 2105 // "Surround Module" -#define IDS_2106 2106 // "MPU-401 Base Address" -#define IDS_2107 2107 // "PCAP not found.." -#define IDS_2108 2108 // "On-board RAM" -#define IDS_2109 2109 // "Memory Size" -#define IDS_2110 2110 // "Display Type" -#define IDS_2111 2111 // "RGB" -#define IDS_2112 2112 // "Composite" -#define IDS_2113 2113 // "Composite Type" -#define IDS_2114 2114 // "Old" -#define IDS_2115 2115 // "New" -#define IDS_2116 2116 // "RGB Type" -#define IDS_2117 2117 // "Color" -#define IDS_2118 2118 // "Monochrome (Green)" -#define IDS_2119 2119 // "Monochrome (Amber)" -#define IDS_2120 2120 // "Monochrome (Gray)" -#define IDS_2121 2121 // "Color (no brown)" -#define IDS_2122 2122 // "Monochrome (Default)" -#define IDS_2123 2123 // "Snow Emulation" -#define IDS_2124 2124 // "Bilinear Filtering" -#define IDS_2125 2125 // "Dithering" -#define IDS_2126 2126 // "Framebuffer Memory Size" -#define IDS_2127 2127 // "Texture Memory Size" -#define IDS_2128 2128 // "Screen Filter" -#define IDS_2129 2129 // "Render Threads" -#define IDS_2130 2130 // "Recompiler" -#define IDS_2131 2131 // "System Default" -#define IDS_2132 2132 // "%i Wait state(s)" -#define IDS_2133 2133 // "8-bit" -#define IDS_2134 2134 // "Slow 16-bit" -#define IDS_2135 2135 // "Fast 16-bit" -#define IDS_2136 2136 // "Slow VLB/PCI" -#define IDS_2137 2137 // "Mid VLB/PCI" -#define IDS_2138 2138 // "Fast VLB/PCI" -#define IDS_2139 2139 // "PCap failed to set up.." -#define IDS_2140 2140 // "No PCap devices found" -#define IDS_2141 2141 // "Invalid PCap device" -#define IDS_2142 2142 // "&Notify disk change" -#define IDS_2143 2143 // "Type" -#define IDS_2144 2144 // "Standard 2-button joystick(s)" -#define IDS_2145 2145 // "Standard 4-button joystick" -#define IDS_2146 2146 // "Standard 6-button joystick" -#define IDS_2147 2147 // "Standard 8-button joystick" -#define IDS_2148 2148 // "CH Flightstick Pro" -#define IDS_2149 2149 // "Microsoft SideWinder Pad" -#define IDS_2150 2150 // "Thrustmaster Flight Cont.." -#define IDS_2151 2151 // "Disabled" -#define IDS_2152 2152 // "None" -#define IDS_2153 2153 // "Unable to load Accelerators" -#define IDS_2154 2154 // "Unable to register Raw Input" -#define IDS_2155 2155 // "IRQ %i" -#define IDS_2156 2156 // "%" PRIu64 -#define IDS_2157 2157 // "%" PRIu64 " MB (CHS: %".." -#define IDS_2158 2158 // "Floppy %i (%s): %ls" -#define IDS_2159 2159 // "All floppy images (*.0??;*.." -#define IDS_2160 2160 // "Configuration files (*.CF.." -#define IDS_2161 2161 // "&New image..." -#define IDS_2162 2162 // "Existing image..." -#define IDS_2163 2163 // "Existing image (&Write-pr..." -#define IDS_2164 2164 // "E&ject" -#define IDS_2165 2165 // "&Mute" -#define IDS_2166 2166 // "E&mpty" -#define IDS_2167 2167 // "&Reload previous image" -#define IDS_2168 2168 // "&Image..." -#define IDS_2169 2169 // "Image (&Write-protected)..." -#define IDS_2170 2170 // "Check BPB" -#define IDS_2171 2171 // "Unable to initialize Flui.." - -#define IDS_3072 3072 // "None" -#define IDS_3073 3073 // "Internal" -#define IDS_3074 3074 // "[Bus] Logitech Bus Mouse" -#define IDS_3075 3075 // "[Bus] Microsoft Bus Mous.." -#define IDS_3076 3076 // "[Serial] Mouse Systems Mouse" -#define IDS_3077 3077 // "[Serial] Microsoft 2-button Mouse" -#define IDS_3078 3078 // "[Serial] Logitech 3-button Mouse" -#define IDS_3079 3079 // "[Serial] Microsoft Wheel Mouse" -#define IDS_3080 3080 // "[PS/2] 2-button Mouse" -#define IDS_3081 3081 // "[PS/2] Microsoft Intellimouse" -#define IDS_3082 3082 // "[Proprietary] Amstrad Mouse" -#define IDS_3083 3083 // "[Proprietary] Olivetti M24.." - -#define IDS_4096 4096 // "Hard disk (%s)" -#define IDS_4097 4097 // "%01i:%01i" -#define IDS_4098 4098 // "%i" -#define IDS_4099 4099 // "Disabled" -#define IDS_4100 4100 // "Custom..." -#define IDS_4101 4101 // "Custom (large)..." -#define IDS_4102 4102 // "Add New Hard Disk" -#define IDS_4103 4103 // "Add Existing Hard Disk" -#define IDS_4104 4104 // "Attempting to create a HDI ima.." -#define IDS_4105 4105 // "Attempting to create a spurio.." -#define IDS_4106 4106 // "Hard disk images (*.HDI;*.HD.." -#define IDS_4107 4107 // "Unable to open the file for read" -#define IDS_4108 4108 // "Unable to open the file for write" -#define IDS_4109 4109 // "HDI or HDX image with a sect.." -#define IDS_4110 4110 // "USB is not yet supported" -#define IDS_4111 4111 // "This image exists and will be.." -#define IDS_4112 4112 // "Please enter a valid file name" -#define IDS_4113 4113 // "Remember to partition and fo.." -#define IDS_4114 4114 // "MFM/RLL or ESDI CD-ROM driv.." -#define IDS_4115 4115 // "Removable disk %i (SCSI): %ls" - -#define IDS_4352 4352 // "MFM/RLL" -#define IDS_4353 4353 // "XT IDE" -#define IDS_4354 4354 // "ESDI" -#define IDS_4355 4355 // "IDE (PIO-only)" -#define IDS_4356 4356 // "IDE (PIO+DMA)" -#define IDS_4357 4357 // "SCSI" -#define IDS_4358 4358 // "SCSI (removable)" - -#define IDS_4608 4608 // "MFM/RLL (%01i:%01i)" -#define IDS_4609 4609 // "XT IDE (%01i:%01i)" -#define IDS_4610 4610 // "ESDI (%01i:%01i)" -#define IDS_4611 4611 // "IDE (PIO-only) (%01i:%01i)" -#define IDS_4612 4612 // "IDE (PIO+DMA) (%01i:%01i)" -#define IDS_4613 4613 // "SCSI (%02i:%02i)" -#define IDS_4614 4614 // "SCSI (removable) (%02i:%02i)" - -#define IDS_5120 5120 // "CD-ROM %i (%s): %s" - -#define IDS_5376 5376 // "Disabled" -#define IDS_5377 5377 // "" -#define IDS_5378 5378 // "" -#define IDS_5379 5379 // "" -#define IDS_5380 5380 // "ATAPI (PIO-only)" -#define IDS_5381 5381 // "ATAPI (PIO and DMA)" -#define IDS_5382 5382 // "SCSI" - -#define IDS_5632 5632 // "Disabled" -#define IDS_5633 5633 // "" -#define IDS_5634 5634 // "" -#define IDS_5635 5635 // "" -#define IDS_5636 5636 // "ATAPI (PIO-only) (%01i:%01i)" -#define IDS_5637 5637 // "ATAPI (PIO and DMA) (%01i:%01i)" -#define IDS_5638 5638 // "SCSI (%02i:%02i)" - -#define IDS_6144 6144 // "English (United States)" - -#define IDS_LANG_ENUS IDS_6144 - -#define STRINGS_NUM_2048 124 -#define STRINGS_NUM_3072 11 -#define STRINGS_NUM_4096 20 -#define STRINGS_NUM_4352 7 -#define STRINGS_NUM_4608 7 -#define STRINGS_NUM_5120 1 -#define STRINGS_NUM_5376 7 -#define STRINGS_NUM_5632 7 -#define STRINGS_NUM_6144 1 - - #define IDM_ABOUT 40001 #define IDC_ABOUT_ICON 65535 #define IDM_ACTION_SCREENSHOT 40011 diff --git a/src/win/win.c b/src/win/win.c index a67cb0760..081c94730 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * Platform main support module for Windows. * - * Version: @(#)win.c 1.0.35 2017/11/12 + * Version: @(#)win.c 1.0.36 2017/11/18 * * Authors: Sarah Walker, * Miran Grca, @@ -19,16 +19,7 @@ * Copyright 2017 Fred N. van Kempen. */ #define UNICODE -#define BITMAP WINDOWS_BITMAP #include -#include -#include -#include -#include -#include -#include -#include -#undef BITMAP #include #include #include @@ -37,32 +28,12 @@ #include #include "../86box.h" #include "../config.h" -#include "../machine/machine.h" -#include "../mem.h" // because of load_config -#include "../rom.h" // because of load_config -#include "../device.h" -#include "../nvr.h" -#include "../mouse.h" -#include "../keyboard.h" -#include "../cdrom/cdrom.h" -#include "../cdrom/cdrom_image.h" -#include "../cdrom/cdrom_null.h" -#include "../floppy/floppy.h" -#include "../scsi/scsi.h" -#include "../network/network.h" -#include "../video/video.h" -#include "../video/vid_ega.h" // for update_overscan -#include "../sound/sound.h" #define GLOBAL #include "../plat.h" #include "../plat_mouse.h" #include "../plat_midi.h" #include "../ui.h" #include "win.h" -#include "win_d3d.h" - - -#define TIMER_1SEC 1 /* ID of the one-second timer */ typedef struct { @@ -70,32 +41,15 @@ typedef struct { } rc_str_t; -/* Platform Public data, specific (defined in lnx.h.) */ +/* Platform Public data, specific. */ HINSTANCE hinstance; /* application instance */ -HWND hwndMain, /* application main window */ - hwndRender; /* machine render window */ -HMENU menuMain; /* application main menu */ HANDLE ghMutex; -HICON hIcon[512]; /* icon data loaded from resources */ LCID lang_id; /* current language ID used */ DWORD dwSubLangID; -RECT oldclip; /* mouse rect */ -int infocus = 1; - -char openfilestring[260]; -WCHAR wopenfilestring[260]; /* Local data. */ static HANDLE thMain; -static wchar_t wTitle[512]; -static RAWINPUTDEVICE device; -static HHOOK hKeyboardHook; -static int hook_enabled = 0; -static int save_window_pos = 0; -static wchar_t **argv; -static int argc; -static wchar_t *argbuf; static rc_str_t *lpRCstr2048, *lpRCstr3072, *lpRCstr4096, @@ -107,659 +61,104 @@ static rc_str_t *lpRCstr2048, *lpRCstr6144; -HICON -LoadIconEx(PCTSTR pszIconName) -{ - return((HICON)LoadImage(hinstance, pszIconName, IMAGE_ICON, - 16, 16, LR_SHARED)); -} - - -#if 0 -static void -win_menu_update(void) -{ - menuMain = LoadMenu(hinstance, L"MainMenu")); - - menuSBAR = LoadMenu(hinstance, L"StatusBarMenu"); - - initmenu(); - - SetMenu(hwndMain, menu); - - win_title_update = 1; -} -#endif - - -static void -video_toggle_option(HMENU h, int *val, int id) -{ - startblit(); - video_wait_for_blit(); - *val ^= 1; - CheckMenuItem(h, id, *val ? MF_CHECKED : MF_UNCHECKED); - endblit(); - config_save(); - device_force_redraw(); -} - - -static void -ResetAllMenus(void) -{ -#ifdef ENABLE_LOG_TOGGLES -# ifdef ENABLE_BUSLOGIC_LOG - CheckMenuItem(menuMain, IDM_LOG_BUSLOGIC, MF_UNCHECKED); -# endif -# ifdef ENABLE_CDROM_LOG - CheckMenuItem(menuMain, IDM_LOG_CDROM, MF_UNCHECKED); -# endif -# ifdef ENABLE_D86F_LOG - CheckMenuItem(menuMain, IDM_LOG_D86F, MF_UNCHECKED); -# endif -# ifdef ENABLE_FDC_LOG - CheckMenuItem(menuMain, IDM_LOG_FDC, MF_UNCHECKED); -# endif -# ifdef ENABLE_IDE_LOG - CheckMenuItem(menuMain, IDM_LOG_IDE, MF_UNCHECKED); -# endif -# ifdef ENABLE_SERIAL_LOG - CheckMenuItem(menuMain, IDM_LOG_SERIAL, MF_UNCHECKED); -# endif -# ifdef ENABLE_NIC_LOG - CheckMenuItem(menuMain, IDM_LOG_NIC, MF_UNCHECKED); -# endif -#endif - - CheckMenuItem(menuMain, IDM_VID_FORCE43, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_OVERSCAN, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_INVERT, MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_DDRAW+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_DDRAW+1, MF_UNCHECKED); -#ifdef USE_VNC - CheckMenuItem(menuMain, IDM_VID_DDRAW+2, MF_UNCHECKED); -#endif -#ifdef USE_VNC - CheckMenuItem(menuMain, IDM_VID_DDRAW+3, MF_UNCHECKED); -#endif - CheckMenuItem(menuMain, IDM_VID_FS_FULL+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+3, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_REMEMBER, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+3, MF_UNCHECKED); - - CheckMenuItem(menuMain, IDM_VID_CGACON, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+0, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+1, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+2, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+3, MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+4, MF_UNCHECKED); - -#ifdef ENABLE_LOG_TOGGLES -# ifdef ENABLE_BUSLOGIC_LOG - CheckMenuItem(menuMain, IDM_LOG_BUSLOGIC, buslogic_do_log?MF_CHECKED:MF_UNCHECKED); -# endif -# ifdef ENABLE_CDROM_LOG - CheckMenuItem(menuMain, IDM_LOG_CDROM, cdrom_do_log?MF_CHECKED:MF_UNCHECKED); -# endif -# ifdef ENABLE_D86F_LOG - CheckMenuItem(menuMain, IDM_LOG_D86F, d86f_do_log?MF_CHECKED:MF_UNCHECKED); -# endif -# ifdef ENABLE_FDC_LOG - CheckMenuItem(menuMain, IDM_LOG_FDC, fdc_do_log?MF_CHECKED:MF_UNCHECKED); -# endif -# ifdef ENABLE_IDE_LOG - CheckMenuItem(menuMain, IDM_LOG_IDE, ide_do_log?MF_CHECKED:MF_UNCHECKED); -# endif -# ifdef ENABLE_SERIAL_LOG - CheckMenuItem(menuMain, IDM_LOG_SERIAL, serial_do_log?MF_CHECKED:MF_UNCHECKED); -# endif -# ifdef ENABLE_NIC_LOG - CheckMenuItem(menuMain, IDM_LOG_NIC, nic_do_log?MF_CHECKED:MF_UNCHECKED); -# endif -#endif - - CheckMenuItem(menuMain, IDM_VID_FORCE43, force_43?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED); - - if (vid_resize) - CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_DDRAW+vid_api, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_SCALE_1X+scale, MF_CHECKED); - - CheckMenuItem(menuMain, IDM_VID_CGACON, vid_cga_contrast?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED); -} - - -static LRESULT CALLBACK -LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) -{ - BOOL bControlKeyDown; - KBDLLHOOKSTRUCT *p; - - if (nCode < 0 || nCode != HC_ACTION) - return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); - - p = (KBDLLHOOKSTRUCT*)lParam; - - /* disable alt-tab */ - if (p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN) return(1); - - /* disable alt-space */ - if (p->vkCode == VK_SPACE && p->flags & LLKHF_ALTDOWN) return(1); - - /* disable alt-escape */ - if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return(1); - - /* disable windows keys */ - if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return(1); - - /* checks ctrl key pressed */ - bControlKeyDown = GetAsyncKeyState(VK_CONTROL)>>((sizeof(SHORT)*8)-1); - - /* disable ctrl-escape */ - if (p->vkCode == VK_ESCAPE && bControlKeyDown) return(1); - - return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); -} - - -static LRESULT CALLBACK -MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - HMENU hmenu; - RECT rect; - int i = 0; - - switch (message) { - case WM_CREATE: - SetTimer(hwnd, TIMER_1SEC, 1000, NULL); - hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, - LowLevelKeyboardProc, - GetModuleHandle(NULL), 0); - hook_enabled = 1; - break; - - case WM_COMMAND: - hmenu = GetMenu(hwnd); - switch (LOWORD(wParam)) { - case IDM_ACTION_SCREENSHOT: - take_screenshot(); - break; - - case IDM_ACTION_HRESET: - pc_reset(1); - break; - - case IDM_ACTION_RESET_CAD: - pc_reset(0); - break; - - case IDM_ACTION_EXIT: - PostQuitMessage(0); - break; - - case IDM_ACTION_CTRL_ALT_ESC: - pc_send_cae(); - break; - - case IDM_ACTION_PAUSE: - plat_pause(dopause ^ 1); - break; - - case IDM_CONFIG: - win_settings_open(hwnd); - break; - - case IDM_ABOUT: - AboutDialogCreate(hwnd); - break; - - case IDM_STATUS: - StatusWindowCreate(hwnd); - break; - - case IDM_VID_RESIZE: - vid_resize = !vid_resize; - CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize)? MF_CHECKED : MF_UNCHECKED); - if (vid_resize) - SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_MINIMIZEBOX) | WS_VISIBLE); - else - SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX) | WS_VISIBLE); - GetWindowRect(hwnd, &rect); - SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); - GetWindowRect(hwndSBAR,&rect); - SetWindowPos(hwndSBAR, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); - if (vid_resize) { - CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED); - CheckMenuItem(hmenu, IDM_VID_SCALE_2X, MF_CHECKED); - scale = 1; - } - EnableMenuItem(hmenu, IDM_VID_SCALE_1X, vid_resize ? MF_GRAYED : MF_ENABLED); - EnableMenuItem(hmenu, IDM_VID_SCALE_2X, vid_resize ? MF_GRAYED : MF_ENABLED); - EnableMenuItem(hmenu, IDM_VID_SCALE_3X, vid_resize ? MF_GRAYED : MF_ENABLED); - EnableMenuItem(hmenu, IDM_VID_SCALE_4X, vid_resize ? MF_GRAYED : MF_ENABLED); - doresize = 1; - config_save(); - break; - - case IDM_VID_REMEMBER: - window_remember = !window_remember; - CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED); - GetWindowRect(hwnd, &rect); - if (window_remember) { - window_x = rect.left; - window_y = rect.top; - window_w = rect.right - rect.left; - window_h = rect.bottom - rect.top; - } - config_save(); - break; - - case IDM_VID_DDRAW: - case IDM_VID_D3D: -#ifdef USE_VNC - case IDM_VID_VNC: -#endif -#ifdef USE_RDP - case IDM_VID_RDP: -#endif - CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_UNCHECKED); - plat_setvid(LOWORD(wParam) - IDM_VID_DDRAW); - CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_CHECKED); - config_save(); - break; - - case IDM_VID_FULLSCREEN: - plat_setfullscreen(1); - config_save(); - break; - - case IDM_VID_FS_FULL: - case IDM_VID_FS_43: - case IDM_VID_FS_SQ: - case IDM_VID_FS_INT: - CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_UNCHECKED); - video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL; - CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); - device_force_redraw(); - config_save(); - break; - - case IDM_VID_SCALE_1X: - case IDM_VID_SCALE_2X: - case IDM_VID_SCALE_3X: - case IDM_VID_SCALE_4X: - CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_UNCHECKED); - scale = LOWORD(wParam) - IDM_VID_SCALE_1X; - CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_CHECKED); - device_force_redraw(); - video_force_resize_set(1); - config_save(); - break; - - case IDM_VID_FORCE43: - video_toggle_option(hmenu, &force_43, IDM_VID_FORCE43); - video_force_resize_set(1); - break; - - case IDM_VID_INVERT: - video_toggle_option(hmenu, &invert_display, IDM_VID_INVERT); - break; - - case IDM_VID_OVERSCAN: - update_overscan = 1; - video_toggle_option(hmenu, &enable_overscan, IDM_VID_OVERSCAN); - video_force_resize_set(1); - break; - - case IDM_VID_CGACON: - vid_cga_contrast ^= 1; - CheckMenuItem(hmenu, IDM_VID_CGACON, vid_cga_contrast ? MF_CHECKED : MF_UNCHECKED); - cgapal_rebuild(); - config_save(); - break; - - case IDM_VID_GRAYCT_601: - case IDM_VID_GRAYCT_709: - case IDM_VID_GRAYCT_AVE: - CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_UNCHECKED); - video_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601; - CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED); - device_force_redraw(); - config_save(); - break; - - case IDM_VID_GRAY_RGB: - case IDM_VID_GRAY_MONO: - case IDM_VID_GRAY_AMBER: - case IDM_VID_GRAY_GREEN: - case IDM_VID_GRAY_WHITE: - CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_UNCHECKED); - video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB; - CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED); - device_force_redraw(); - config_save(); - break; - -#ifdef ENABLE_LOG_TOGGLES -# ifdef ENABLE_BUSLOGIC_LOG - case IDM_LOG_BUSLOGIC: - buslogic_do_log ^= 1; - CheckMenuItem(hmenu, IDM_LOG_BUSLOGIC, buslogic_do_log ? MF_CHECKED : MF_UNCHECKED); - break; -# endif - -# ifdef ENABLE_CDROM_LOG - case IDM_LOG_CDROM: - cdrom_do_log ^= 1; - CheckMenuItem(hmenu, IDM_LOG_CDROM, cdrom_do_log ? MF_CHECKED : MF_UNCHECKED); - break; -# endif - -# ifdef ENABLE_D86F_LOG - case IDM_LOG_D86F: - d86f_do_log ^= 1; - CheckMenuItem(hmenu, IDM_LOG_D86F, d86f_do_log ? MF_CHECKED : MF_UNCHECKED); - break; -# endif - -# ifdef ENABLE_FDC_LOG - case IDM_LOG_FDC: - fdc_do_log ^= 1; - CheckMenuItem(hmenu, IDM_LOG_FDC, fdc_do_log ? MF_CHECKED : MF_UNCHECKED); - break; -# endif - -# ifdef ENABLE_IDE_LOG - case IDM_LOG_IDE: - ide_do_log ^= 1; - CheckMenuItem(hmenu, IDM_LOG_IDE, ide_do_log ? MF_CHECKED : MF_UNCHECKED); - break; -# endif - -# ifdef ENABLE_SERIAL_LOG - case IDM_LOG_SERIAL: - serial_do_log ^= 1; - CheckMenuItem(hmenu, IDM_LOG_SERIAL, serial_do_log ? MF_CHECKED : MF_UNCHECKED); - break; -# endif - -# ifdef ENABLE_NIC_LOG - case IDM_LOG_NIC: - nic_do_log ^= 1; - CheckMenuItem(hmenu, IDM_LOG_NIC, nic_do_log ? MF_CHECKED : MF_UNCHECKED); - break; -# endif -#endif - -#ifdef ENABLE_LOG_BREAKPOINT - case IDM_LOG_BREAKPOINT: - pclog("---- LOG BREAKPOINT ----\n"); - break; -#endif - -#ifdef ENABLE_VRAM_DUMP - case IDM_DUMP_VRAM: - svga_dump_vram(); - break; -#endif - - case IDM_CONFIG_LOAD: - plat_pause(1); - if (! file_dlg_st(hwnd, IDS_2160, "", 0)) { - if (ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == IDYES) { - config_write(config_file_default); - for (i = 0; i < FDD_NUM; i++) - floppy_close(i); - for (i = 0; i < CDROM_NUM; i++) - { - cdrom_drives[i].handler->exit(i); - if (cdrom_drives[i].host_drive == 200) - image_close(i); - else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) - ioctl_close(i); - else - null_close(i); - } - pc_reset_hard_close(); - config_load(wopenfilestring); - for (i = 0; i < CDROM_NUM; i++) - { - if (cdrom_drives[i].bus_type) - SCSIReset(cdrom_drives[i].scsi_device_id, cdrom_drives[i].scsi_device_lun); - - if (cdrom_drives[i].host_drive == 200) - image_open(i, cdrom_image[i].image_path); - else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) - ioctl_open(i, cdrom_drives[i].host_drive); - else - cdrom_null_open(i, cdrom_drives[i].host_drive); - } - - floppy_load(0, floppyfns[0]); - floppy_load(1, floppyfns[1]); - floppy_load(2, floppyfns[2]); - floppy_load(3, floppyfns[3]); - - mem_resize(); - rom_load_bios(romset); - network_init(); - ResetAllMenus(); - pc_reset_hard_init(); - } - } - plat_pause(0); - break; - - case IDM_CONFIG_SAVE: - plat_pause(1); - if (! file_dlg_st(hwnd, IDS_2160, "", 1)) { - config_write(wopenfilestring); - } - plat_pause(0); - break; - } - return(0); - - case WM_INPUT: - keyboard_handle(lParam, infocus); - break; - - case WM_SETFOCUS: - infocus = 1; - if (! hook_enabled) { - hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, - LowLevelKeyboardProc, - GetModuleHandle(NULL), - 0); - hook_enabled = 1; - } - break; - - case WM_KILLFOCUS: - infocus = 0; - plat_mouse_capture(0); - if (video_fullscreen) - leave_fullscreen_flag = 1; - if (hook_enabled) { - UnhookWindowsHookEx(hKeyboardHook); - hook_enabled = 0; - } - break; - - case WM_LBUTTONUP: - if (! video_fullscreen) - plat_mouse_capture(1); - break; - - case WM_MBUTTONUP: - if (!(mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON)) - plat_mouse_capture(0); - break; - - case WM_ENTERMENULOOP: - break; - - case WM_SIZE: - scrnsz_x = (lParam & 0xFFFF); - scrnsz_y = (lParam >> 16) - (17 + 6); - if (scrnsz_y < 0) - scrnsz_y = 0; - - MoveWindow(hwndRender, 0, 0, scrnsz_x, scrnsz_y, TRUE); - - plat_vidsize(scrnsz_x, scrnsz_y); - - MoveWindow(hwndSBAR, 0, scrnsz_y + 6, scrnsz_x, 17, TRUE); - - if (mouse_capture) { - GetWindowRect(hwndRender, &rect); - - ClipCursor(&rect); - } - - if (window_remember) { - GetWindowRect(hwnd, &rect); - window_x = rect.left; - window_y = rect.top; - window_w = rect.right - rect.left; - window_h = rect.bottom - rect.top; - save_window_pos = 1; - } - - config_save(); - break; - - case WM_MOVE: - if (window_remember) { - GetWindowRect(hwnd, &rect); - window_x = rect.left; - window_y = rect.top; - window_w = rect.right - rect.left; - window_h = rect.bottom - rect.top; - save_window_pos = 1; - } - break; - - case WM_TIMER: - if (wParam == TIMER_1SEC) { - pc_onesec(); - } - break; - - case WM_RESETD3D: - startblit(); - if (video_fullscreen) - d3d_reset_fs(); - else - d3d_reset(); - endblit(); - break; - - case WM_LEAVEFULLSCREEN: - plat_setfullscreen(0); - config_save(); - cgapal_rebuild(); - break; - - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - return(0); - - case WM_DESTROY: - UnhookWindowsHookEx(hKeyboardHook); - KillTimer(hwnd, TIMER_1SEC); - PostQuitMessage(0); - break; - - case WM_SYSCOMMAND: - /* - * Disable ALT key *ALWAYS*, - * I don't think there's any use for - * reaching the menu that way. - */ - if (wParam == SC_KEYMENU && HIWORD(lParam) <= 0) { - return 0; /*disable ALT key for menu*/ - } - - default: - return(DefWindowProc(hwnd, message, wParam, lParam)); - } - - return(0); -} - - -static LRESULT CALLBACK -SubWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - return(DefWindowProc(hwnd, message, wParam, lParam)); -} - - static void LoadCommonStrings(void) { int i; - lpRCstr2048 = (rc_str_t *)malloc(STRINGS_NUM_2048*sizeof(rc_str_t)); - lpRCstr3072 = (rc_str_t *)malloc(STRINGS_NUM_3072*sizeof(rc_str_t)); - lpRCstr4096 = (rc_str_t *)malloc(STRINGS_NUM_4096*sizeof(rc_str_t)); - lpRCstr4352 = (rc_str_t *)malloc(STRINGS_NUM_4352*sizeof(rc_str_t)); - lpRCstr4608 = (rc_str_t *)malloc(STRINGS_NUM_4608*sizeof(rc_str_t)); - lpRCstr5120 = (rc_str_t *)malloc(STRINGS_NUM_5120*sizeof(rc_str_t)); - lpRCstr5376 = (rc_str_t *)malloc(STRINGS_NUM_5376*sizeof(rc_str_t)); - lpRCstr5632 = (rc_str_t *)malloc(STRINGS_NUM_5632*sizeof(rc_str_t)); - lpRCstr6144 = (rc_str_t *)malloc(STRINGS_NUM_6144*sizeof(rc_str_t)); + lpRCstr2048 = (rc_str_t *)malloc(STR_NUM_2048*sizeof(rc_str_t)); + lpRCstr3072 = (rc_str_t *)malloc(STR_NUM_3072*sizeof(rc_str_t)); + lpRCstr4096 = (rc_str_t *)malloc(STR_NUM_4096*sizeof(rc_str_t)); + lpRCstr4352 = (rc_str_t *)malloc(STR_NUM_4352*sizeof(rc_str_t)); + lpRCstr4608 = (rc_str_t *)malloc(STR_NUM_4608*sizeof(rc_str_t)); + lpRCstr5120 = (rc_str_t *)malloc(STR_NUM_5120*sizeof(rc_str_t)); + lpRCstr5376 = (rc_str_t *)malloc(STR_NUM_5376*sizeof(rc_str_t)); + lpRCstr5632 = (rc_str_t *)malloc(STR_NUM_5632*sizeof(rc_str_t)); + lpRCstr6144 = (rc_str_t *)malloc(STR_NUM_6144*sizeof(rc_str_t)); - for (i=0; i= 2048) && (i <= 3071)) { + str = lpRCstr2048[i-2048].str; + } else if ((i >= 3072) && (i <= 4095)) { + str = lpRCstr3072[i-3072].str; + } else if ((i >= 4096) && (i <= 4351)) { + str = lpRCstr4096[i-4096].str; + } else if ((i >= 4352) && (i <= 4607)) { + str = lpRCstr4352[i-4352].str; + } else if ((i >= 4608) && (i <= 5119)) { + str = lpRCstr4608[i-4608].str; + } else if ((i >= 5120) && (i <= 5375)) { + str = lpRCstr5120[i-5120].str; + } else if ((i >= 5376) && (i <= 5631)) { + str = lpRCstr5376[i-5376].str; + } else if ((i >= 5632) && (i <= 6143)) { + str = lpRCstr5632[i-5632].str; + } else { + str = lpRCstr6144[i-6144].str; + } + + return((wchar_t *)str); +} + + +#ifndef USE_WX +# ifdef USE_CONSOLE /* Create a console if we don't already have one. */ static void CreateConsole(int init) @@ -806,28 +205,30 @@ CreateConsole(int init) *stdin = *fp; #endif } -#endif +# endif /* Process the commandline, and create standard argc/argv array. */ -static void -ProcessCommandLine(void) +static int +ProcessCommandLine(wchar_t ***argw) { WCHAR *cmdline; + wchar_t *argbuf; + wchar_t **args; int argc_max; - int i, q; + int i, q, argc; cmdline = GetCommandLine(); i = wcslen(cmdline) + 1; - argbuf = malloc(i * 2); - memcpy(argbuf, cmdline, i * 2); + argbuf = (wchar_t *)malloc(sizeof(wchar_t)*i); + wcscpy(argbuf, cmdline); argc = 0; argc_max = 64; - argv = malloc(sizeof(wchar_t *) * argc_max); - if (argv == NULL) { + args = (wchar_t **)malloc(sizeof(wchar_t *) * argc_max); + if (args == NULL) { free(argbuf); - return; + return(0); } /* parse commandline into argc/argv format */ @@ -844,14 +245,14 @@ ProcessCommandLine(void) } else q = 0; - argv[argc++] = &argbuf[i]; + args[argc++] = &argbuf[i]; if (argc >= argc_max) { argc_max += 64; - argv = realloc(argv, sizeof(wchar_t *) * argc_max); - if (argv == NULL) { + args = realloc(args, sizeof(wchar_t *)*argc_max); + if (args == NULL) { free(argbuf); - return; + return(0); } } @@ -865,7 +266,10 @@ ProcessCommandLine(void) } } - argv[argc] = NULL; + args[argc] = NULL; + *argw = args; + + return(argc); } @@ -875,12 +279,8 @@ ProcessCommandLine(void) int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil) { - WCHAR title[200]; - WNDCLASSEX wincl; /* buffer for main window's class */ - MSG messages; /* received-messages buffer */ - HWND hwnd; /* handle for our window */ - HACCEL haccel; /* handle to accelerator table */ - int bRet; + wchar_t **argw = NULL; + int argc, i; /* We need this later. */ hinstance = hInst; @@ -896,19 +296,16 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil) /* First, set our (default) language. */ set_language(0x0409); - /* Load common strings from the resource file. */ - LoadCommonStrings(); - #ifdef USE_CONSOLE /* Create console window. */ CreateConsole(1); #endif /* Process the command line for options. */ - ProcessCommandLine(); + argc = ProcessCommandLine(&argw); /* Pre-initialize the system, this loads the config file. */ - if (! pc_init(argc, argv)) { + if (! pc_init(argc, argw)) { #ifdef USE_CONSOLE /* Detach from console. */ CreateConsole(0); @@ -916,231 +313,16 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil) return(1); } - /* Create our main window's class and register it. */ - wincl.hInstance = hinstance; - wincl.lpszClassName = CLASS_NAME; - wincl.lpfnWndProc = MainWindowProcedure; - wincl.style = CS_DBLCLKS; /* Catch double-clicks */ - wincl.cbSize = sizeof(WNDCLASSEX); - wincl.hIcon = LoadIcon(hinstance, (LPCTSTR)100); - wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR)100); - wincl.hCursor = NULL; - wincl.lpszMenuName = NULL; - wincl.cbClsExtra = 0; - wincl.cbWndExtra = 0; - wincl.hbrBackground = CreateSolidBrush(RGB(0,0,0)); - if (! RegisterClassEx(&wincl)) - return(2); - wincl.lpszClassName = SUB_CLASS_NAME; - wincl.lpfnWndProc = SubWindowProcedure; - if (! RegisterClassEx(&wincl)) - return(2); + /* Cleanup: we no longer need the commandline arguments. */ + free(argw[0]); + free(argw); - /* Load the Window Menu(s) from the resources. */ - menuMain = LoadMenu(hinstance, MENU_NAME); + /* Handle our GUI. */ + i = ui_init(nFunsterStil); - /* Set the initial title for the program's main window. */ - _swprintf(title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W); - - /* Now create our main window. */ - hwnd = CreateWindowEx ( - 0, /* no extended possibilites */ - CLASS_NAME, /* class name */ - title, /* Title Text */ - (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX) | DS_3DLOOK, - CW_USEDEFAULT, /* Windows decides the position */ - CW_USEDEFAULT, /* where window ends up on the screen */ - scrnsz_x+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* width */ - scrnsz_y+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */ - HWND_DESKTOP, /* window is a child to desktop */ - menuMain, /* menu */ - hinstance, /* Program Instance handler */ - NULL); /* no Window Creation data */ - hwndMain = hwnd; - - ui_window_title(title); - - /* Set up main window for resizing if configured. */ - if (vid_resize) - SetWindowLongPtr(hwnd, GWL_STYLE, - (WS_OVERLAPPEDWINDOW)); - else - SetWindowLongPtr(hwnd, GWL_STYLE, - (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)); - - /* Move to the last-saved position if needed. */ - if (window_remember) - MoveWindow(hwnd, window_x, window_y, window_w, window_h, TRUE); - - /* Reset all menus to their defaults. */ - ResetAllMenus(); - - /* Make the window visible on the screen. */ - ShowWindow(hwnd, nFunsterStil); - - /* Load the accelerator table */ - haccel = LoadAccelerators(hinstance, ACCEL_NAME); - if (haccel == NULL) { - MessageBox(hwndMain, - plat_get_string(IDS_2053), - plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); - return(3); - } - - /* Initialize the input (keyboard, mouse, game) module. */ - device.usUsagePage = 0x01; - device.usUsage = 0x06; - device.dwFlags = RIDEV_NOHOTKEYS; - device.hwndTarget = hwnd; - if (! RegisterRawInputDevices(&device, 1, sizeof(device))) { - MessageBox(hwndMain, - plat_get_string(IDS_2054), - plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); - return(4); - } - keyboard_getkeymap(); - - /* Create the status bar window. */ - StatusBarCreate(hwndMain, IDC_STATUS, hinstance); - - /* - * Before we can create the Render window, we first have - * to prepare some other things that it depends on. - */ - ghMutex = CreateMutex(NULL, FALSE, L"86Box.BlitMutex"); - - /* Create the Machine Rendering window. */ - hwndRender = CreateWindow(L"STATIC", NULL, WS_CHILD|SS_BITMAP, - 0, 0, 1, 1, hwnd, NULL, hInst, NULL); - MoveWindow(hwndRender, 0, 0, scrnsz_x, scrnsz_y, TRUE); - - /* Initialize the configured Video API. */ - if (! plat_setvid(vid_api)) { - MessageBox(hwnd, - plat_get_string(IDS_2095), - plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); - return(5); - } - - /* Initialize the rendering window, or fullscreen. */ - if (start_in_fullscreen) - plat_setfullscreen(1); - - /* Set up the current window size. */ - plat_resize(scrnsz_x, scrnsz_y); - - /* All done, fire up the actual emulated machine. */ - if (! pc_init_modules()) { - /* Dang, no ROMs found at all! */ - MessageBox(hwnd, - plat_get_string(IDS_2056), - plat_get_string(IDS_2050), - MB_OK | MB_ICONERROR); - return(6); - } - - /* Fire up the machine. */ - pc_reset_hard(); - - /* Set the PAUSE mode depending on the renderer. */ - plat_pause(0); - - /* - * Everything has been configured, and all seems to work, - * so now it is time to start the main thread to do some - * real work, and we will hang in here, dealing with the - * UI until we're done. - */ - do_start(); - - /* Run the message loop. It will run until GetMessage() returns 0 */ - while (! quited) { - bRet = GetMessage(&messages, NULL, 0, 0); - if ((bRet == 0) || quited) break; - - if (bRet == -1) { - fatal("bRet is -1\n"); - } - - if (messages.message == WM_QUIT) { - quited = 1; - break; - } - - if (! TranslateAccelerator(hwnd, haccel, &messages)) { - TranslateMessage(&messages); - DispatchMessage(&messages); - } - - if (mouse_capture && keyboard_ismsexit()) { - /* Release the in-app mouse. */ - plat_mouse_capture(0); - } - - if (video_fullscreen && keyboard_isfsexit()) { - /* Signal "exit fullscreen mode". */ - plat_setfullscreen(0); - } - } - - timeEndPeriod(1); - - if (mouse_capture) - plat_mouse_capture(0); - - UnregisterClass(SUB_CLASS_NAME, hinstance); - UnregisterClass(CLASS_NAME, hinstance); - - /* Close down the emulator. */ - do_stop(); - - return(messages.wParam); -} - - -wchar_t * -ui_window_title(wchar_t *s) -{ - if (! video_fullscreen) { - if (s != NULL) - wcscpy(wTitle, s); - else - s = wTitle; - - SetWindowText(hwndMain, s); - } else { - if (s == NULL) - s = wTitle; - } - - return(s); -} - - -/* Set (or re-set) the language for the application. */ -void -set_language(int id) -{ - LCID lcidNew = MAKELCID(id, dwSubLangID); - - if (lang_id != lcidNew) { - /* Set our new language ID. */ - lang_id = lcidNew; - - SetThreadLocale(lang_id); - - /* Load the strings table for this ID. */ - LoadCommonStrings(); - -#if 0 - /* Update the menus for this ID. */ - MenuUpdate(); -#endif - } + return(i); } +#endif /*USE_WX*/ /* @@ -1315,123 +497,3 @@ plat_delay_ms(uint32_t count) { Sleep(count); } - - -/* We should have the language ID as a parameter. */ -void -plat_pause(int p) -{ - static wchar_t oldtitle[512]; - wchar_t title[512]; - - /* If un-pausing, as the renderer if that's OK. */ - if (p == 0) - p = get_vidpause(); - - /* If already so, done. */ - if (dopause == p) return; - - if (p) { - wcscpy(oldtitle, ui_window_title(NULL)); - wcscpy(title, oldtitle); - wcscat(title, L" - PAUSED -"); - ui_window_title(title); - } else { - ui_window_title(oldtitle); - } - - dopause = p; - - /* Update the actual menu. */ - CheckMenuItem(menuMain, IDM_ACTION_PAUSE, - (dopause) ? MF_CHECKED : MF_UNCHECKED); -} - - -wchar_t * -plat_get_string(int i) -{ - LPTSTR str; - - if ((i >= 2048) && (i <= 3071)) { - str = lpRCstr2048[i-2048].str; - } else if ((i >= 3072) && (i <= 4095)) { - str = lpRCstr3072[i-3072].str; - } else if ((i >= 4096) && (i <= 4351)) { - str = lpRCstr4096[i-4096].str; - } else if ((i >= 4352) && (i <= 4607)) { - str = lpRCstr4352[i-4352].str; - } else if ((i >= 4608) && (i <= 5119)) { - str = lpRCstr4608[i-4608].str; - } else if ((i >= 5120) && (i <= 5375)) { - str = lpRCstr5120[i-5120].str; - } else if ((i >= 5376) && (i <= 5631)) { - str = lpRCstr5376[i-5376].str; - } else if ((i >= 5632) && (i <= 6143)) { - str = lpRCstr5632[i-5632].str; - } else { - str = lpRCstr6144[i-6144].str; - } - - return((wchar_t *)str); -} - - -/* Tell the UI about a new screen resolution. */ -void -plat_resize(int x, int y) -{ - int sb_borders[3]; - RECT r; - -#if 0 -pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", video_fullscreen, vid_api, x, y); -#endif - /* First, see if we should resize the UI window. */ - if (!vid_resize) { - video_wait_for_blit(); - SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders); - GetWindowRect(hwndMain, &r); - MoveWindow(hwndRender, 0, 0, x, y, TRUE); - GetWindowRect(hwndRender, &r); - MoveWindow(hwndSBAR, - 0, r.bottom + GetSystemMetrics(SM_CYEDGE), - x, 17, TRUE); - GetWindowRect(hwndMain, &r); - - MoveWindow(hwndMain, r.left, r.top, - x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2), - y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resize ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 17 + sb_borders[1] + 1, - TRUE); - - if (mouse_capture) { - GetWindowRect(hwndRender, &r); - ClipCursor(&r); - } - } -} - - -void -plat_mouse_capture(int on) -{ - RECT rect; - - if (on && !mouse_capture) { - /* Enable the in-app mouse. */ - GetClipCursor(&oldclip); - GetWindowRect(hwndRender, &rect); - ClipCursor(&rect); - while (1) { - if (ShowCursor(FALSE) < 0) break; - } - - mouse_capture = 1; - } else if (!on && mouse_capture) { - /* Disable the in-app mouse. */ - ClipCursor(&oldclip); - ShowCursor(TRUE); - - mouse_capture = 0; - } -} diff --git a/src/win/win.h b/src/win/win.h index cc5e6505d..528b1f3b9 100644 --- a/src/win/win.h +++ b/src/win/win.h @@ -98,6 +98,10 @@ extern void hard_disk_add_open(HWND hwnd, int is_existing); extern int hard_disk_was_added(void); +/* Platform UI support functions. */ +extern int ui_init(int nStyle); + + /* Functions in win_about.c: */ extern void AboutDialogCreate(HWND hwnd); diff --git a/src/win/win_deviceconfig.c b/src/win/win_devconf.c similarity index 99% rename from src/win/win_deviceconfig.c rename to src/win/win_devconf.c index 46355f0c0..b91552ecd 100644 --- a/src/win/win_deviceconfig.c +++ b/src/win/win_devconf.c @@ -8,7 +8,7 @@ * * Windows device configuration dialog implementation. * - * Version: @(#)win_deviceconfig.c 1.0.8 2017/10/16 + * Version: @(#)win_devconf.c 1.0.9 2017/11/18 * * Authors: Sarah Walker, * Miran Grca, diff --git a/src/win/win_dialog.c b/src/win/win_dialog.c index 9621a8e4e..c47000f2b 100644 --- a/src/win/win_dialog.c +++ b/src/win/win_dialog.c @@ -8,7 +8,7 @@ * * Several dialogs for the application. * - * Version: @(#)win_dialog.c 1.0.4 2017/10/16 + * Version: @(#)win_dialog.c 1.0.5 2017/11/18 * * Author: Miran Grca, * Fred N. van Kempen, @@ -17,11 +17,9 @@ * Copyright 2017 Fred N. van Kempen. */ #define UNICODE -#define BITMAP WINDOWS_BITMAP #include #include #include -#undef BITMAP #include #include #include @@ -34,7 +32,9 @@ #include "win.h" -WCHAR path[MAX_PATH]; +WCHAR path[MAX_PATH]; +WCHAR wopenfilestring[260]; +char openfilestring[260]; static int CALLBACK diff --git a/src/win/win_joystick.cc b/src/win/win_joystick.cc index 56d2627e8..56d6ddc00 100644 --- a/src/win/win_joystick.cc +++ b/src/win/win_joystick.cc @@ -8,7 +8,7 @@ * * Joystick interface to host device. * - * Version: @(#)win_joystick.cc 1.0.5 2017/10/17 + * Version: @(#)win_joystick.cc 1.0.6 2017/11/18 * * Authors: Sarah Walker, * Miran Grca, @@ -21,33 +21,25 @@ #include #include #include -extern "C" { +#include "../86box.h" #include "../device.h" -#include "../game/gameport.h" -} #include "../plat.h" +#include "../game/gameport.h" #include "../plat_joystick.h" #include "win.h" -extern "C" int video_fullscreen; - -extern "C" void fatal(const char *format, ...); -extern "C" void pclog(const char *format, ...); - -extern "C" void joystick_init(); -extern "C" void joystick_close(); -extern "C" void poll_joystick(); plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; joystick_t joystick_state[MAX_JOYSTICKS]; +int joysticks_present = 0; + static LPDIRECTINPUT8 lpdi; static LPDIRECTINPUTDEVICE8 lpdi_joystick[2] = {NULL, NULL}; - -int joysticks_present = 0; static GUID joystick_guids[MAX_JOYSTICKS]; -static BOOL CALLBACK joystick_enum_callback(LPCDIDEVICEINSTANCE lpddi, LPVOID data) + +static BOOL CALLBACK joystick_enum_callback(LPCDIDEVICEINSTANCE lpddi, UNUSED(LPVOID data)) { if (joysticks_present >= MAX_JOYSTICKS) return DIENUM_STOP; diff --git a/src/win/win_joystickconfig.c b/src/win/win_jsconf.c similarity index 99% rename from src/win/win_joystickconfig.c rename to src/win/win_jsconf.c index cd5304805..2d9ecb3ea 100644 --- a/src/win/win_joystickconfig.c +++ b/src/win/win_jsconf.c @@ -1,10 +1,8 @@ /* Copyright holders: Sarah Walker see COPYING for more details */ -#define BITMAP WINDOWS_BITMAP #include #include -#undef BITMAP #include #include #include diff --git a/src/win/win_ui.c b/src/win/win_ui.c new file mode 100644 index 000000000..7989d2eaa --- /dev/null +++ b/src/win/win_ui.c @@ -0,0 +1,991 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * user Interface module for WinAPI on Windows. + * + * Version: @(#)win_ui.c 1.0.2 2017/11/18 + * + * Authors: Sarah Walker, + * Miran Grca, + * Fred N. van Kempen, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + * Copyright 2017 Fred N. van Kempen. + */ +#define UNICODE +#include +#include +#include +#include +#include +#include +#include +#include +#include "../86box.h" +#include "../config.h" +#include "../machine/machine.h" +#include "../mem.h" // because of load_config +#include "../rom.h" // because of load_config +#include "../device.h" +#include "../mouse.h" +#include "../keyboard.h" +#include "../cdrom/cdrom.h" +#include "../cdrom/cdrom_image.h" +#include "../cdrom/cdrom_null.h" +#include "../floppy/floppy.h" +#include "../scsi/scsi.h" +#include "../network/network.h" +#include "../video/video.h" +#include "../video/vid_ega.h" // for update_overscan +#include "../sound/sound.h" +#include "../plat.h" +#include "../plat_mouse.h" +#include "../plat_midi.h" +#include "../ui.h" +#include "win.h" +#include "win_d3d.h" + + +#define TIMER_1SEC 1 /* ID of the one-second timer */ + + +/* Platform Public data, specific. */ +HINSTANCE hinstance; /* application instance */ +HWND hwndMain, /* application main window */ + hwndRender; /* machine render window */ +HMENU menuMain; /* application main menu */ +HANDLE ghMutex; +HICON hIcon[512]; /* icon data loaded from resources */ +LCID lang_id; /* current language ID used */ +DWORD dwSubLangID; +RECT oldclip; /* mouse rect */ +int infocus = 1; + +char openfilestring[260]; +WCHAR wopenfilestring[260]; + + +/* Local data. */ +//static HANDLE thMain; +static wchar_t wTitle[512]; +static RAWINPUTDEVICE device; +static HHOOK hKeyboardHook; +static int hook_enabled = 0; +static int save_window_pos = 0; + + +HICON +LoadIconEx(PCTSTR pszIconName) +{ + return((HICON)LoadImage(hinstance, pszIconName, IMAGE_ICON, + 16, 16, LR_SHARED)); +} + + +#if 0 +static void +win_menu_update(void) +{ + menuMain = LoadMenu(hinstance, L"MainMenu")); + + menuSBAR = LoadMenu(hinstance, L"StatusBarMenu"); + + initmenu(); + + SetMenu(hwndMain, menu); + + win_title_update = 1; +} +#endif + + +static void +video_toggle_option(HMENU h, int *val, int id) +{ + startblit(); + video_wait_for_blit(); + *val ^= 1; + CheckMenuItem(h, id, *val ? MF_CHECKED : MF_UNCHECKED); + endblit(); + config_save(); + device_force_redraw(); +} + + +static void +ResetAllMenus(void) +{ +#ifdef ENABLE_LOG_TOGGLES +# ifdef ENABLE_BUSLOGIC_LOG + CheckMenuItem(menuMain, IDM_LOG_BUSLOGIC, MF_UNCHECKED); +# endif +# ifdef ENABLE_CDROM_LOG + CheckMenuItem(menuMain, IDM_LOG_CDROM, MF_UNCHECKED); +# endif +# ifdef ENABLE_D86F_LOG + CheckMenuItem(menuMain, IDM_LOG_D86F, MF_UNCHECKED); +# endif +# ifdef ENABLE_FDC_LOG + CheckMenuItem(menuMain, IDM_LOG_FDC, MF_UNCHECKED); +# endif +# ifdef ENABLE_IDE_LOG + CheckMenuItem(menuMain, IDM_LOG_IDE, MF_UNCHECKED); +# endif +# ifdef ENABLE_SERIAL_LOG + CheckMenuItem(menuMain, IDM_LOG_SERIAL, MF_UNCHECKED); +# endif +# ifdef ENABLE_NIC_LOG + CheckMenuItem(menuMain, IDM_LOG_NIC, MF_UNCHECKED); +# endif +#endif + + CheckMenuItem(menuMain, IDM_VID_FORCE43, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_OVERSCAN, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_INVERT, MF_UNCHECKED); + + CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_DDRAW+0, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_DDRAW+1, MF_UNCHECKED); +#ifdef USE_VNC + CheckMenuItem(menuMain, IDM_VID_DDRAW+2, MF_UNCHECKED); +#endif +#ifdef USE_VNC + CheckMenuItem(menuMain, IDM_VID_DDRAW+3, MF_UNCHECKED); +#endif + CheckMenuItem(menuMain, IDM_VID_FS_FULL+0, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_FS_FULL+1, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_FS_FULL+2, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_FS_FULL+3, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_REMEMBER, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_SCALE_1X+0, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_SCALE_1X+1, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_SCALE_1X+2, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_SCALE_1X+3, MF_UNCHECKED); + + CheckMenuItem(menuMain, IDM_VID_CGACON, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+0, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+1, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+2, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+0, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+1, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+2, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+3, MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+4, MF_UNCHECKED); + +#ifdef ENABLE_LOG_TOGGLES +# ifdef ENABLE_BUSLOGIC_LOG + CheckMenuItem(menuMain, IDM_LOG_BUSLOGIC, buslogic_do_log?MF_CHECKED:MF_UNCHECKED); +# endif +# ifdef ENABLE_CDROM_LOG + CheckMenuItem(menuMain, IDM_LOG_CDROM, cdrom_do_log?MF_CHECKED:MF_UNCHECKED); +# endif +# ifdef ENABLE_D86F_LOG + CheckMenuItem(menuMain, IDM_LOG_D86F, d86f_do_log?MF_CHECKED:MF_UNCHECKED); +# endif +# ifdef ENABLE_FDC_LOG + CheckMenuItem(menuMain, IDM_LOG_FDC, fdc_do_log?MF_CHECKED:MF_UNCHECKED); +# endif +# ifdef ENABLE_IDE_LOG + CheckMenuItem(menuMain, IDM_LOG_IDE, ide_do_log?MF_CHECKED:MF_UNCHECKED); +# endif +# ifdef ENABLE_SERIAL_LOG + CheckMenuItem(menuMain, IDM_LOG_SERIAL, serial_do_log?MF_CHECKED:MF_UNCHECKED); +# endif +# ifdef ENABLE_NIC_LOG + CheckMenuItem(menuMain, IDM_LOG_NIC, nic_do_log?MF_CHECKED:MF_UNCHECKED); +# endif +#endif + + CheckMenuItem(menuMain, IDM_VID_FORCE43, force_43?MF_CHECKED:MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_OVERSCAN, enable_overscan?MF_CHECKED:MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_INVERT, invert_display ? MF_CHECKED : MF_UNCHECKED); + + if (vid_resize) + CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED); + CheckMenuItem(menuMain, IDM_VID_DDRAW+vid_api, MF_CHECKED); + CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); + CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember?MF_CHECKED:MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_SCALE_1X+scale, MF_CHECKED); + + CheckMenuItem(menuMain, IDM_VID_CGACON, vid_cga_contrast?MF_CHECKED:MF_UNCHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED); +} + + +static LRESULT CALLBACK +LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + BOOL bControlKeyDown; + KBDLLHOOKSTRUCT *p; + + if (nCode < 0 || nCode != HC_ACTION) + return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); + + p = (KBDLLHOOKSTRUCT*)lParam; + + /* disable alt-tab */ + if (p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN) return(1); + + /* disable alt-space */ + if (p->vkCode == VK_SPACE && p->flags & LLKHF_ALTDOWN) return(1); + + /* disable alt-escape */ + if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return(1); + + /* disable windows keys */ + if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return(1); + + /* checks ctrl key pressed */ + bControlKeyDown = GetAsyncKeyState(VK_CONTROL)>>((sizeof(SHORT)*8)-1); + + /* disable ctrl-escape */ + if (p->vkCode == VK_ESCAPE && bControlKeyDown) return(1); + + return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); +} + + +static LRESULT CALLBACK +MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + HMENU hmenu; + RECT rect; + int i = 0; + + switch (message) { + case WM_CREATE: + SetTimer(hwnd, TIMER_1SEC, 1000, NULL); + hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, + LowLevelKeyboardProc, + GetModuleHandle(NULL), 0); + hook_enabled = 1; + break; + + case WM_COMMAND: + hmenu = GetMenu(hwnd); + switch (LOWORD(wParam)) { + case IDM_ACTION_SCREENSHOT: + take_screenshot(); + break; + + case IDM_ACTION_HRESET: + pc_reset(1); + break; + + case IDM_ACTION_RESET_CAD: + pc_reset(0); + break; + + case IDM_ACTION_EXIT: + PostQuitMessage(0); + break; + + case IDM_ACTION_CTRL_ALT_ESC: + pc_send_cae(); + break; + + case IDM_ACTION_PAUSE: + plat_pause(dopause ^ 1); + break; + + case IDM_CONFIG: + win_settings_open(hwnd); + break; + + case IDM_ABOUT: + AboutDialogCreate(hwnd); + break; + + case IDM_STATUS: + StatusWindowCreate(hwnd); + break; + + case IDM_VID_RESIZE: + vid_resize = !vid_resize; + CheckMenuItem(hmenu, IDM_VID_RESIZE, (vid_resize)? MF_CHECKED : MF_UNCHECKED); + if (vid_resize) + SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_MINIMIZEBOX) | WS_VISIBLE); + else + SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX) | WS_VISIBLE); + GetWindowRect(hwnd, &rect); + SetWindowPos(hwnd, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); + GetWindowRect(hwndSBAR,&rect); + SetWindowPos(hwndSBAR, 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_FRAMECHANGED); + if (vid_resize) { + CheckMenuItem(hmenu, IDM_VID_SCALE_1X + scale, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_VID_SCALE_2X, MF_CHECKED); + scale = 1; + } + EnableMenuItem(hmenu, IDM_VID_SCALE_1X, vid_resize ? MF_GRAYED : MF_ENABLED); + EnableMenuItem(hmenu, IDM_VID_SCALE_2X, vid_resize ? MF_GRAYED : MF_ENABLED); + EnableMenuItem(hmenu, IDM_VID_SCALE_3X, vid_resize ? MF_GRAYED : MF_ENABLED); + EnableMenuItem(hmenu, IDM_VID_SCALE_4X, vid_resize ? MF_GRAYED : MF_ENABLED); + doresize = 1; + config_save(); + break; + + case IDM_VID_REMEMBER: + window_remember = !window_remember; + CheckMenuItem(hmenu, IDM_VID_REMEMBER, window_remember ? MF_CHECKED : MF_UNCHECKED); + GetWindowRect(hwnd, &rect); + if (window_remember) { + window_x = rect.left; + window_y = rect.top; + window_w = rect.right - rect.left; + window_h = rect.bottom - rect.top; + } + config_save(); + break; + + case IDM_VID_DDRAW: + case IDM_VID_D3D: +#ifdef USE_VNC + case IDM_VID_VNC: +#endif +#ifdef USE_RDP + case IDM_VID_RDP: +#endif + CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_UNCHECKED); + plat_setvid(LOWORD(wParam) - IDM_VID_DDRAW); + CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_CHECKED); + config_save(); + break; + + case IDM_VID_FULLSCREEN: + plat_setfullscreen(1); + config_save(); + break; + + case IDM_VID_FS_FULL: + case IDM_VID_FS_43: + case IDM_VID_FS_SQ: + case IDM_VID_FS_INT: + CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_UNCHECKED); + video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL; + CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); + device_force_redraw(); + config_save(); + break; + + case IDM_VID_SCALE_1X: + case IDM_VID_SCALE_2X: + case IDM_VID_SCALE_3X: + case IDM_VID_SCALE_4X: + CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_UNCHECKED); + scale = LOWORD(wParam) - IDM_VID_SCALE_1X; + CheckMenuItem(hmenu, IDM_VID_SCALE_1X+scale, MF_CHECKED); + device_force_redraw(); + video_force_resize_set(1); + config_save(); + break; + + case IDM_VID_FORCE43: + video_toggle_option(hmenu, &force_43, IDM_VID_FORCE43); + video_force_resize_set(1); + break; + + case IDM_VID_INVERT: + video_toggle_option(hmenu, &invert_display, IDM_VID_INVERT); + break; + + case IDM_VID_OVERSCAN: + update_overscan = 1; + video_toggle_option(hmenu, &enable_overscan, IDM_VID_OVERSCAN); + video_force_resize_set(1); + break; + + case IDM_VID_CGACON: + vid_cga_contrast ^= 1; + CheckMenuItem(hmenu, IDM_VID_CGACON, vid_cga_contrast ? MF_CHECKED : MF_UNCHECKED); + cgapal_rebuild(); + config_save(); + break; + + case IDM_VID_GRAYCT_601: + case IDM_VID_GRAYCT_709: + case IDM_VID_GRAYCT_AVE: + CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_UNCHECKED); + video_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601; + CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED); + device_force_redraw(); + config_save(); + break; + + case IDM_VID_GRAY_RGB: + case IDM_VID_GRAY_MONO: + case IDM_VID_GRAY_AMBER: + case IDM_VID_GRAY_GREEN: + case IDM_VID_GRAY_WHITE: + CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_UNCHECKED); + video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB; + CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED); + device_force_redraw(); + config_save(); + break; + +#ifdef ENABLE_LOG_TOGGLES +# ifdef ENABLE_BUSLOGIC_LOG + case IDM_LOG_BUSLOGIC: + buslogic_do_log ^= 1; + CheckMenuItem(hmenu, IDM_LOG_BUSLOGIC, buslogic_do_log ? MF_CHECKED : MF_UNCHECKED); + break; +# endif + +# ifdef ENABLE_CDROM_LOG + case IDM_LOG_CDROM: + cdrom_do_log ^= 1; + CheckMenuItem(hmenu, IDM_LOG_CDROM, cdrom_do_log ? MF_CHECKED : MF_UNCHECKED); + break; +# endif + +# ifdef ENABLE_D86F_LOG + case IDM_LOG_D86F: + d86f_do_log ^= 1; + CheckMenuItem(hmenu, IDM_LOG_D86F, d86f_do_log ? MF_CHECKED : MF_UNCHECKED); + break; +# endif + +# ifdef ENABLE_FDC_LOG + case IDM_LOG_FDC: + fdc_do_log ^= 1; + CheckMenuItem(hmenu, IDM_LOG_FDC, fdc_do_log ? MF_CHECKED : MF_UNCHECKED); + break; +# endif + +# ifdef ENABLE_IDE_LOG + case IDM_LOG_IDE: + ide_do_log ^= 1; + CheckMenuItem(hmenu, IDM_LOG_IDE, ide_do_log ? MF_CHECKED : MF_UNCHECKED); + break; +# endif + +# ifdef ENABLE_SERIAL_LOG + case IDM_LOG_SERIAL: + serial_do_log ^= 1; + CheckMenuItem(hmenu, IDM_LOG_SERIAL, serial_do_log ? MF_CHECKED : MF_UNCHECKED); + break; +# endif + +# ifdef ENABLE_NIC_LOG + case IDM_LOG_NIC: + nic_do_log ^= 1; + CheckMenuItem(hmenu, IDM_LOG_NIC, nic_do_log ? MF_CHECKED : MF_UNCHECKED); + break; +# endif +#endif + +#ifdef ENABLE_LOG_BREAKPOINT + case IDM_LOG_BREAKPOINT: + pclog("---- LOG BREAKPOINT ----\n"); + break; +#endif + +#ifdef ENABLE_VRAM_DUMP + case IDM_DUMP_VRAM: + svga_dump_vram(); + break; +#endif + + case IDM_CONFIG_LOAD: + plat_pause(1); + if (! file_dlg_st(hwnd, IDS_2160, "", 0)) { + if (ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051) == IDYES) { + config_write(config_file_default); + for (i = 0; i < FDD_NUM; i++) + floppy_close(i); + for (i = 0; i < CDROM_NUM; i++) + { + cdrom_drives[i].handler->exit(i); + if (cdrom_drives[i].host_drive == 200) + image_close(i); + else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) + ioctl_close(i); + else + null_close(i); + } + pc_reset_hard_close(); + config_load(wopenfilestring); + for (i = 0; i < CDROM_NUM; i++) + { + if (cdrom_drives[i].bus_type) + SCSIReset(cdrom_drives[i].scsi_device_id, cdrom_drives[i].scsi_device_lun); + + if (cdrom_drives[i].host_drive == 200) + image_open(i, cdrom_image[i].image_path); + else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) + ioctl_open(i, cdrom_drives[i].host_drive); + else + cdrom_null_open(i, cdrom_drives[i].host_drive); + } + + floppy_load(0, floppyfns[0]); + floppy_load(1, floppyfns[1]); + floppy_load(2, floppyfns[2]); + floppy_load(3, floppyfns[3]); + + mem_resize(); + rom_load_bios(romset); + network_init(); + ResetAllMenus(); + pc_reset_hard_init(); + } + } + plat_pause(0); + break; + + case IDM_CONFIG_SAVE: + plat_pause(1); + if (! file_dlg_st(hwnd, IDS_2160, "", 1)) { + config_write(wopenfilestring); + } + plat_pause(0); + break; + } + return(0); + + case WM_INPUT: + keyboard_handle(lParam, infocus); + break; + + case WM_SETFOCUS: + infocus = 1; + if (! hook_enabled) { + hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, + LowLevelKeyboardProc, + GetModuleHandle(NULL), + 0); + hook_enabled = 1; + } + break; + + case WM_KILLFOCUS: + infocus = 0; + plat_mouse_capture(0); + if (video_fullscreen) + leave_fullscreen_flag = 1; + if (hook_enabled) { + UnhookWindowsHookEx(hKeyboardHook); + hook_enabled = 0; + } + break; + + case WM_LBUTTONUP: + if (! video_fullscreen) + plat_mouse_capture(1); + break; + + case WM_MBUTTONUP: + if (!(mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON)) + plat_mouse_capture(0); + break; + + case WM_ENTERMENULOOP: + break; + + case WM_SIZE: + scrnsz_x = (lParam & 0xFFFF); + scrnsz_y = (lParam >> 16) - (17 + 6); + if (scrnsz_y < 0) + scrnsz_y = 0; + + MoveWindow(hwndRender, 0, 0, scrnsz_x, scrnsz_y, TRUE); + + plat_vidsize(scrnsz_x, scrnsz_y); + + MoveWindow(hwndSBAR, 0, scrnsz_y + 6, scrnsz_x, 17, TRUE); + + if (mouse_capture) { + GetWindowRect(hwndRender, &rect); + + ClipCursor(&rect); + } + + if (window_remember) { + GetWindowRect(hwnd, &rect); + window_x = rect.left; + window_y = rect.top; + window_w = rect.right - rect.left; + window_h = rect.bottom - rect.top; + save_window_pos = 1; + } + + config_save(); + break; + + case WM_MOVE: + if (window_remember) { + GetWindowRect(hwnd, &rect); + window_x = rect.left; + window_y = rect.top; + window_w = rect.right - rect.left; + window_h = rect.bottom - rect.top; + save_window_pos = 1; + } + break; + + case WM_TIMER: + if (wParam == TIMER_1SEC) { + pc_onesec(); + } + break; + + case WM_RESETD3D: + startblit(); + if (video_fullscreen) + d3d_reset_fs(); + else + d3d_reset(); + endblit(); + break; + + case WM_LEAVEFULLSCREEN: + plat_setfullscreen(0); + config_save(); + cgapal_rebuild(); + break; + + case WM_KEYDOWN: + case WM_KEYUP: + case WM_SYSKEYDOWN: + case WM_SYSKEYUP: + return(0); + + case WM_DESTROY: + UnhookWindowsHookEx(hKeyboardHook); + KillTimer(hwnd, TIMER_1SEC); + PostQuitMessage(0); + break; + + case WM_SYSCOMMAND: + /* + * Disable ALT key *ALWAYS*, + * I don't think there's any use for + * reaching the menu that way. + */ + if (wParam == SC_KEYMENU && HIWORD(lParam) <= 0) { + return 0; /*disable ALT key for menu*/ + } + + default: + return(DefWindowProc(hwnd, message, wParam, lParam)); + } + + return(0); +} + + +static LRESULT CALLBACK +SubWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + return(DefWindowProc(hwnd, message, wParam, lParam)); +} + + +int +ui_init(int nFunsterStil) +{ + WCHAR title[200]; + WNDCLASSEX wincl; /* buffer for main window's class */ + MSG messages; /* received-messages buffer */ + HWND hwnd; /* handle for our window */ + HACCEL haccel; /* handle to accelerator table */ + int bRet; + + /* Create our main window's class and register it. */ + wincl.hInstance = hinstance; + wincl.lpszClassName = CLASS_NAME; + wincl.lpfnWndProc = MainWindowProcedure; + wincl.style = CS_DBLCLKS; /* Catch double-clicks */ + wincl.cbSize = sizeof(WNDCLASSEX); + wincl.hIcon = LoadIcon(hinstance, (LPCTSTR)100); + wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR)100); + wincl.hCursor = NULL; + wincl.lpszMenuName = NULL; + wincl.cbClsExtra = 0; + wincl.cbWndExtra = 0; + wincl.hbrBackground = CreateSolidBrush(RGB(0,0,0)); + if (! RegisterClassEx(&wincl)) + return(2); + wincl.lpszClassName = SUB_CLASS_NAME; + wincl.lpfnWndProc = SubWindowProcedure; + if (! RegisterClassEx(&wincl)) + return(2); + + /* Load the Window Menu(s) from the resources. */ + menuMain = LoadMenu(hinstance, MENU_NAME); + + /* Now create our main window. */ + mbstowcs(title, emu_version, sizeof_w(title)); + hwnd = CreateWindowEx ( + 0, /* no extended possibilites */ + CLASS_NAME, /* class name */ + title, /* Title Text */ + (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX) | DS_3DLOOK, + CW_USEDEFAULT, /* Windows decides the position */ + CW_USEDEFAULT, /* where window ends up on the screen */ + scrnsz_x+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* width */ + scrnsz_y+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */ + HWND_DESKTOP, /* window is a child to desktop */ + menuMain, /* menu */ + hinstance, /* Program Instance handler */ + NULL); /* no Window Creation data */ + hwndMain = hwnd; + + ui_window_title(title); + + /* Set up main window for resizing if configured. */ + if (vid_resize) + SetWindowLongPtr(hwnd, GWL_STYLE, + (WS_OVERLAPPEDWINDOW)); + else + SetWindowLongPtr(hwnd, GWL_STYLE, + (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX)); + + /* Move to the last-saved position if needed. */ + if (window_remember) + MoveWindow(hwnd, window_x, window_y, window_w, window_h, TRUE); + + /* Reset all menus to their defaults. */ + ResetAllMenus(); + + /* Make the window visible on the screen. */ + ShowWindow(hwnd, nFunsterStil); + + /* Load the accelerator table */ + haccel = LoadAccelerators(hinstance, ACCEL_NAME); + if (haccel == NULL) { + MessageBox(hwndMain, + plat_get_string(IDS_2053), + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); + return(3); + } + + /* Initialize the input (keyboard, mouse, game) module. */ + device.usUsagePage = 0x01; + device.usUsage = 0x06; + device.dwFlags = RIDEV_NOHOTKEYS; + device.hwndTarget = hwnd; + if (! RegisterRawInputDevices(&device, 1, sizeof(device))) { + MessageBox(hwndMain, + plat_get_string(IDS_2054), + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); + return(4); + } + keyboard_getkeymap(); + + /* Create the status bar window. */ + StatusBarCreate(hwndMain, IDC_STATUS, hinstance); + + /* + * Before we can create the Render window, we first have + * to prepare some other things that it depends on. + */ + ghMutex = CreateMutex(NULL, FALSE, L"86Box.BlitMutex"); + + /* Create the Machine Rendering window. */ + hwndRender = CreateWindow(L"STATIC", NULL, WS_CHILD|SS_BITMAP, + 0, 0, 1, 1, hwnd, NULL, hinstance, NULL); + MoveWindow(hwndRender, 0, 0, scrnsz_x, scrnsz_y, TRUE); + + /* Initialize the configured Video API. */ + if (! plat_setvid(vid_api)) { + MessageBox(hwnd, + plat_get_string(IDS_2095), + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); + return(5); + } + + /* Initialize the rendering window, or fullscreen. */ + if (start_in_fullscreen) + plat_setfullscreen(1); + + /* Set up the current window size. */ + plat_resize(scrnsz_x, scrnsz_y); + + /* All done, fire up the actual emulated machine. */ + if (! pc_init_modules()) { + /* Dang, no ROMs found at all! */ + MessageBox(hwnd, + plat_get_string(IDS_2056), + plat_get_string(IDS_2050), + MB_OK | MB_ICONERROR); + return(6); + } + + /* Fire up the machine. */ + pc_reset_hard(); + + /* Set the PAUSE mode depending on the renderer. */ + plat_pause(0); + + /* + * Everything has been configured, and all seems to work, + * so now it is time to start the main thread to do some + * real work, and we will hang in here, dealing with the + * UI until we're done. + */ + do_start(); + + /* Run the message loop. It will run until GetMessage() returns 0 */ + while (! quited) { + bRet = GetMessage(&messages, NULL, 0, 0); + if ((bRet == 0) || quited) break; + + if (bRet == -1) { + fatal("bRet is -1\n"); + } + + if (messages.message == WM_QUIT) { + quited = 1; + break; + } + + if (! TranslateAccelerator(hwnd, haccel, &messages)) { + TranslateMessage(&messages); + DispatchMessage(&messages); + } + + if (mouse_capture && keyboard_ismsexit()) { + /* Release the in-app mouse. */ + plat_mouse_capture(0); + } + + if (video_fullscreen && keyboard_isfsexit()) { + /* Signal "exit fullscreen mode". */ + plat_setfullscreen(0); + } + } + + timeEndPeriod(1); + + if (mouse_capture) + plat_mouse_capture(0); + + UnregisterClass(SUB_CLASS_NAME, hinstance); + UnregisterClass(CLASS_NAME, hinstance); + + /* Close down the emulator. */ + do_stop(); + + return(messages.wParam); +} + + +wchar_t * +ui_window_title(wchar_t *s) +{ + if (! video_fullscreen) { + if (s != NULL) + wcscpy(wTitle, s); + else + s = wTitle; + + SetWindowText(hwndMain, s); + } else { + if (s == NULL) + s = wTitle; + } + + return(s); +} + + +/* We should have the language ID as a parameter. */ +void +plat_pause(int p) +{ + static wchar_t oldtitle[512]; + wchar_t title[512]; + + /* If un-pausing, as the renderer if that's OK. */ + if (p == 0) + p = get_vidpause(); + + /* If already so, done. */ + if (dopause == p) return; + + if (p) { + wcscpy(oldtitle, ui_window_title(NULL)); + wcscpy(title, oldtitle); + wcscat(title, L" - PAUSED -"); + ui_window_title(title); + } else { + ui_window_title(oldtitle); + } + + dopause = p; + + /* Update the actual menu. */ + CheckMenuItem(menuMain, IDM_ACTION_PAUSE, + (dopause) ? MF_CHECKED : MF_UNCHECKED); +} + + +/* Tell the UI about a new screen resolution. */ +void +plat_resize(int x, int y) +{ + int sb_borders[3]; + RECT r; + +#if 0 +pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", video_fullscreen, vid_api, x, y); +#endif + /* First, see if we should resize the UI window. */ + if (!vid_resize) { + video_wait_for_blit(); + SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM) sb_borders); + GetWindowRect(hwndMain, &r); + MoveWindow(hwndRender, 0, 0, x, y, TRUE); + GetWindowRect(hwndRender, &r); + MoveWindow(hwndSBAR, + 0, r.bottom + GetSystemMetrics(SM_CYEDGE), + x, 17, TRUE); + GetWindowRect(hwndMain, &r); + + MoveWindow(hwndMain, r.left, r.top, + x + (GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2), + y + (GetSystemMetrics(SM_CYEDGE) * 2) + (GetSystemMetrics(vid_resize ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME) * 2) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 17 + sb_borders[1] + 1, + TRUE); + + if (mouse_capture) { + GetWindowRect(hwndRender, &r); + ClipCursor(&r); + } + } +} + + +void +plat_mouse_capture(int on) +{ + RECT rect; + + if (on && !mouse_capture) { + /* Enable the in-app mouse. */ + GetClipCursor(&oldclip); + GetWindowRect(hwndRender, &rect); + ClipCursor(&rect); + while (1) { + if (ShowCursor(FALSE) < 0) break; + } + + mouse_capture = 1; + } else if (!on && mouse_capture) { + /* Disable the in-app mouse. */ + ClipCursor(&oldclip); + ShowCursor(TRUE); + + mouse_capture = 0; + } +} diff --git a/src/win/win_video.c b/src/win/win_video.c index bf2ce7181..57b8b443a 100644 --- a/src/win/win_video.c +++ b/src/win/win_video.c @@ -6,20 +6,18 @@ * * This file is part of the 86Box distribution. * - * Platform video API support for Win32. + * Video API platform support for Windows. * - * Version: @(#)win_video.c 1.0.7 2017/11/12 + * Version: @(#)win_video.c 1.0.8 2017/11/18 * * Author: Fred N. van Kempen, * * Copyright 2017 Fred N. van Kempen. */ #define UNICODE -#define BITMAP WINDOWS_BITMAP #include #include #include -#undef BITMAP #include #include #include @@ -40,9 +38,13 @@ #ifdef USE_RDP # include "../rdp.h" #endif +#ifdef USE_WX +# include "../wx/wx_ui.h" +#else +# include "win_ddraw.h" +# include "win_d3d.h" +#endif #include "win.h" -#include "win_ddraw.h" -#include "win_d3d.h" static struct { @@ -54,8 +56,13 @@ static struct { int (*pause)(void); } vid_apis[2][4] = { { +#ifdef USE_WX + { "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause }, + { "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause }, +#else { "DDraw", 1, (int(*)(void*))ddraw_init, ddraw_close, NULL, ddraw_pause }, { "D3D", 1, (int(*)(void*))d3d_init, d3d_close, d3d_resize, d3d_pause }, +#endif #ifdef USE_VNC { "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause }, #else @@ -68,8 +75,13 @@ static struct { #endif }, { +#ifdef USE_WX + { "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause }, + { "WxWidgets", 1, wx_init, wx_close, NULL, wx_pause }, +#else { "DDraw", 1, (int(*)(void*))ddraw_init_fs, ddraw_close, NULL, ddraw_pause }, { "D3D", 1, (int(*)(void*))d3d_init_fs, d3d_close, NULL, d3d_pause }, +#endif #ifdef USE_VNC { "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause }, #else @@ -109,6 +121,14 @@ plat_vidapi_name(int api) char *name = "default"; switch(api) { +#if USE_WX + case 0: + break; + + case 1: + name = "wxwidgets"; + break; +#else case 0: name = "ddraw"; break; @@ -119,6 +139,7 @@ plat_vidapi_name(int api) name = "d3d"; #endif break; +#endif #ifdef USE_VNC case 2: @@ -148,15 +169,25 @@ plat_setvid(int api) /* Close the (old) API. */ vid_apis[0][vid_api].close(); +//#ifdef USE_WX +// ui_check_menu_item(IDM_View_WX+vid_api, 0); +//#endif vid_api = api; +#ifndef USE_WX if (vid_apis[0][vid_api].local) ShowWindow(hwndRender, SW_SHOW); else ShowWindow(hwndRender, SW_HIDE); +#endif /* Initialize the (new) API. */ +#ifdef USE_WX +// ui_check_menu_item(IDM_View_WX+vid_api, 1); + i = vid_apis[0][vid_api].init(NULL); +#else i = vid_apis[0][vid_api].init((void *)hwndRender); +#endif endblit(); if (! i) return(0); @@ -202,6 +233,9 @@ plat_setfullscreen(int on) /* We want to leave FS mode. */ flag = 1; +#ifdef USE_WX + goto doit; +#endif return; } @@ -211,6 +245,9 @@ plat_setfullscreen(int on) } /* OK, claim the video. */ +#ifdef USE_WX +doit: +#endif startblit(); video_wait_for_blit(); @@ -223,6 +260,10 @@ plat_setfullscreen(int on) vid_apis[video_fullscreen][vid_api].init((void *) *hw); flag = 0; +#ifdef USE_WX + wx_set_fullscreen(on); +#endif + mouse_init(); leave_fullscreen_flag = 0; @@ -256,26 +297,32 @@ take_screenshot(void) wcscat(path, L"\\"); switch(vid_api) { +#ifdef USE_WX + case 0: + case 1: + wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info); + wcscat(path, fn); + wx_screenshot(path); + break; +#else case 0: /* ddraw */ wcsftime(path, 128, L"%Y%m%d_%H%M%S.bmp", info); wcscat(path, fn); ddraw_take_screenshot(path); - pclog("Screenshot: fn='%ls'\n", path); break; case 1: /* d3d9 */ wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info); wcscat(path, fn); d3d_take_screenshot(path); - pclog("Screenshot: fn='%ls'\n", path); break; +#endif #ifdef USE_VNC case 2: /* vnc */ wcsftime(fn, 128, L"%Y%m%d_%H%M%S.png", info); wcscat(path, fn); vnc_take_screenshot(path); - pclog("Screenshot: fn='%ls'\n", path); break; #endif } @@ -294,3 +341,54 @@ endblit(void) { ReleaseMutex(ghMutex); } + + +#if 0 +/* Tell the UI and/or renderers about a new screen resolution. */ +void +plat_resize(int x, int y) +{ +pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", video_fullscreen, vid_api, x, y); + + /* Do not accept these sizes. */ + if (x==0 || x<320 || y==0 || y<200) return; + + /* First, see if we should resize the UI window. */ + if (! vid_resize) +#ifdef USE_WX + wx_resize(x, y); +#else + ui_resize(x, y); +#endif + +#if 0 + /* Now, tell the renderer about the new screen size we want. */ + if (vid_apis[video_fullscreen][vid_api].resize) { + startblit(); + vid_apis[video_fullscreen][vid_api].resize(x, y); + endblit(); + } +#endif +} + + +void +plat_mouse_capture(int on) +{ + if (on && !mouse_capture) { + /* Enable the in-app mouse. */ +#ifdef USE_WX + wx_capture_mouse(1); +#endif + + mouse_capture = 1; + } else if (!on && mouse_capture) { + /* Disable the in-app mouse. */ +#ifdef USE_WX + wx_capture_mouse(0); +#endif + + mouse_capture = 0; + } +} +#endif