Major changes to NVR, system initialization (pc.c), and what goes on in the Windows startup (win.c.) Not fully done yet, but good enough for a first commit.

This commit is contained in:
waltje
2017-10-07 00:46:54 -04:00
parent 95fe21b651
commit 2b37b7fbfb
108 changed files with 5628 additions and 5912 deletions

View File

@@ -8,7 +8,7 @@
*
* Windows resource script.
*
* Version: @(#)86Box.rc 1.0.14 2017/10/01
* Version: @(#)86Box.rc 1.0.15 2017/10/05
*
* Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com>
@@ -40,7 +40,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// Menu
//
MAINMENU MENU DISCARDABLE
MainMenu MENU DISCARDABLE
BEGIN
POPUP "&Action"
BEGIN
@@ -157,13 +157,17 @@ BEGIN
END
END
StatusBarMenu MENU DISCARDABLE
BEGIN
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
MAINACCEL ACCELERATORS MOVEABLE PURE
MainAccel ACCELERATORS MOVEABLE PURE
BEGIN
#ifdef ENABLE_VRAM_DUMP
VK_F1, IDM_DUMP_VRAM, CONTROL, VIRTKEY
@@ -686,9 +690,7 @@ BEGIN
IDS_2053 "Invalid number of sectors (valid values are between 1 and 63)"
IDS_2054 "Invalid number of heads (valid values are between 1 and 16)"
IDS_2055 "Invalid number of cylinders (valid values are between 1 and 266305)"
#if NOTUSED
IDS_2056
#endif
IDS_2056 "No usable ROM images found!"
IDS_2057 "(empty)"
IDS_2058 "(host drive %c:)"
IDS_2059 "Turbo"
@@ -735,6 +737,7 @@ BEGIN
IDS_2092 "Bus"
IDS_2093 "DMA"
IDS_2094 "KB"
IDS_2095 "Neither DirectDraw nor Direct3D available !"
END
STRINGTABLE DISCARDABLE
@@ -807,10 +810,8 @@ BEGIN
IDS_2150 "Thrustmaster Flight Control System"
IDS_2151 "Disabled"
IDS_2152 "None"
#if UNUSED
IDS_2153
IDS_2154
#endif
IDS_2153 "Unable to load Keyboard Accelerators!"
IDS_2154 "Unable to register Raw Input!"
IDS_2155 "IRQ %i"
IDS_2156 "%" PRIu64
IDS_2157 "%" PRIu64 " MB (CHS: %" PRIu64 ", %" PRIu64 ", %" PRIu64 ")"

View File

@@ -9,11 +9,8 @@
* Windows resource defines.
*
* NOTE: FIXME: Strings 2176 and 2193 are same.
* NOTE: FIXME: string 2052 not in use.
* NOTE: FIXME: string 2095 not in use.
* NOTE: FIXME: strings 2153-2154 not in use.
*
* Version: @(#)resource.h 1.0.9 2017/10/01
* Version: @(#)resource.h 1.0.10 2017/10/05
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -211,7 +208,7 @@
#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 // "Please enter a valid file name"
#define IDS_2056 2056 // "No usable ROM images found!"
#define IDS_2057 2057 // "Unable to open the file for write"
#define IDS_2058 2058 // "Attempting to create a HDI.."
#define IDS_2059 2059 // "Remember to partition and.."
@@ -250,7 +247,7 @@
#define IDS_2092 2092 // "Bus"
#define IDS_2093 2093 // "DMA"
#define IDS_2094 2094 // "KB"
#define IDS_2095 2095
#define IDS_2095 2095 // "No renderer available!"
#define IDS_2096 2096 // "Slave"
#define IDS_2097 2097 // "SCSI (ID %s, LUN %s)"
#define IDS_2098 2098 // "Adapter Type"
@@ -308,12 +305,10 @@
#define IDS_2150 2150 // "Thrustmaster Flight Control System"
#define IDS_2151 2151 // "Disabled"
#define IDS_2152 2152 // "None"
#if NOTUSED
#define IDS_2153 2153
#define IDS_2154 2154
#endif
#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 // "MFM (%01i:%01i)"
#define IDS_2156 2156 // "MFM/RLL (%91i:%01i)"
#define IDS_2157 2157 // "IDE (PIO+DMA) (%01i:%01i)"
#define IDS_2158 2158 // "SCSI (%02i:%02i)"
#define IDS_2159 2159 // "Invalid number of cylinders.."

File diff suppressed because it is too large Load Diff

View File

@@ -8,22 +8,17 @@
*
* The Emulator's Windows core.
*
* Version: @(#)win.h 1.0.0 2017/05/30
* NOTE This should be named 'plat.h' and then include any
* Windows-specific header files needed, to keep them
* out of the main code.
*
* Author: Sarah Walker, <http://pcem-emulator.co.uk/>
* Version: @(#)win.h 1.0.2 2017/10/05
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Copyright 2008-2017 Sarah Walker.
* Copyright 2016-2017 Miran Grca.
*/
/*
* This should be named 'plat.h' and then include any
* Windows-specific header files needed, to keep them
* out of the main code.
*/
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#ifndef BOX_WIN_H
# define BOX_WIN_H
@@ -31,32 +26,34 @@
# define UNICODE
# endif
# define BITMAP WINDOWS_BITMAP
/* # ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif */
# if 0
# ifdef _WIN32_WINNT
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
# endif
# include <windows.h>
# include "resource.h"
# undef BITMAP
#define szClassName L"86BoxMainWnd"
#define szSubClassName L"86BoxSubWnd"
#define szStatusBarClassName L"86BoxStatusBar"
/* Class names and such. */
#define CLASS_NAME L"86BoxMainWnd"
#define MENU_NAME L"MainMenu"
#define ACCEL_NAME L"MainAccel"
#define SUB_CLASS_NAME L"86BoxSubWnd"
#define SB_CLASS_NAME L"86BoxStatusBar"
#define SB_MENU_NAME L"StatusBarMenu"
#define RENDER_NAME L"RenderWindow"
#define WM_RESETD3D WM_USER
#define WM_LEAVEFULLSCREEN WM_USER + 1
#define WM_SAVESETTINGS 0x8888 /* 86Box-specific message, used to tell the child dialog to save the currently specified settings. */
#define SB_ICON_WIDTH 24
/* Application-specific window messages. */
#define WM_RESETD3D WM_USER
#define WM_LEAVEFULLSCREEN WM_USER+1
#define WM_SAVESETTINGS 0x8888
extern HINSTANCE hinstance;
extern HWND ghwnd;
extern HWND status_hwnd;
extern HWND hwndStatus;
extern HWND hwndMain;
extern int status_is_open;
extern int mousecapture;
@@ -65,9 +62,6 @@ extern WCHAR wopenfilestring[260];
extern int pause;
extern HMENU smenu;
extern HMENU *sb_menu_handles;
#ifdef __cplusplus
extern "C" {
@@ -75,9 +69,9 @@ extern "C" {
extern void leave_fullscreen(void);
extern void status_open(HWND hwnd);
extern void deviceconfig_open(HWND hwnd, struct device_t *device);
#ifdef EMU_DEVICE_H
extern void deviceconfig_open(HWND hwnd, device_t *device);
#endif
extern void joystickconfig_open(HWND hwnd, int joy_nr, int type);
extern int getfile(HWND hwnd, char *f, char *fn);
@@ -92,23 +86,40 @@ extern void endblit(void);
extern void win_settings_open(HWND hwnd);
extern void win_menu_update();
extern void update_status_bar_panes(HWND hwnds);
extern int fdd_type_to_icon(int type);
extern void hard_disk_add_open(HWND hwnd, int is_existing);
extern int hard_disk_was_added(void);
extern void get_registry_key_map(void);
extern void process_raw_input(LPARAM lParam, int infocus);
extern int find_status_bar_part(int tag);
extern void cdrom_init_host_drives(void);
extern void cdrom_close(uint8_t id);
extern void update_tip(int meaning);
extern BOOL DirectoryExists(LPCTSTR szPath);
/* Status Window definitions. */
extern HWND hwndStatus;
extern void StatusWindowCreate(HWND hwnd);
/* Status Bar definitions. */
#define SB_ICON_WIDTH 24
#define SB_FLOPPY 0x00
#define SB_CDROM 0x10
#define SB_RDISK 0x20
#define SB_HDD 0x40
#define SB_NETWORK 0x50
#define SB_TEXT 0x60
extern int fdd_type_to_icon(int type);
extern int StatusBarFindPart(int tag);
extern void StatusBarUpdatePanes(void);
extern void StatusBarUpdateTip(int meaning);
extern void StatusBarUpdateIcon(int tag, int val);
extern void StatusBarUpdateIconState(int tag, int active);
extern void StatusBarSetTextW(wchar_t *wstr);
extern void StatusBarSetText(char *str);
#ifdef __cplusplus
}
#endif

View File

@@ -6,9 +6,9 @@
*
* This file is part of the 86Box distribution.
*
* Direct3D 9 full screen rendererer and screenshots taking.
* Direct3D 9 full-screen rendererer.
*
* Version: @(#)win_d3d_fs.cc 1.0.2 2017/08/23
* Version: @(#)win_d3d_fs.cc 1.0.3 2017/10/05
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -45,9 +45,9 @@ static D3DPRESENT_PARAMETERS d3dpp;
static HWND d3d_hwnd;
static HWND d3d_device_window;
static int d3d_fs_w, d3d_fs_h;
struct CUSTOMVERTEX
{
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
@@ -55,55 +55,72 @@ struct CUSTOMVERTEX
FLOAT tu, tv;
};
PALETTE cgapal =
{
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
{0,0,0},{21,63,21},{63,21,21},{63,63,21},
{0,0,0},{21,63,63},{63,21,63},{63,63,63},
{0,0,0},{0,0,42},{0,42,0},{0,42,42},
{42,0,0},{42,0,42},{42,21,00},{42,42,42},
{21,21,21},{21,21,63},{21,63,21},{21,63,63},
{63,21,21},{63,21,63},{63,63,21},{63,63,63},
PALETTE cgapal = {
{0,0,0},{0,42,0},{42,0,0},{42,21,0},
{0,0,0},{0,42,42},{42,0,42},{42,42,42},
{0,0,0},{21,63,21},{63,21,21},{63,63,21},
{0,0,0},{21,63,63},{63,21,63},{63,63,63},
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
{21,21,21},{21,63,21},{42,21,42},{21,63,63},
{63,0,0},{42,42,0},{63,21,42},{41,41,41},
{0,0,0},{0,0,42},{0,42,0},{0,42,42},
{42,0,0},{42,0,42},{42,21,00},{42,42,42},
{21,21,21},{21,21,63},{21,63,21},{21,63,63},
{63,21,21},{63,21,63},{63,63,21},{63,63,63},
{0,0,0},{0,21,0},{0,0,42},{0,42,42},
{42,0,21},{21,10,21},{42,0,42},{42,0,63},
{21,21,21},{21,63,21},{42,21,42},{21,63,63},
{63,0,0},{42,42,0},{63,21,42},{41,41,41},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,42,42},{42,0,0},{42,42,42},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
{0,0,0},{0,63,63},{63,0,0},{63,63,63},
};
PALETTE cgapal_mono[6] =
{
{ // 0 - green, 4-color-optimized contrast
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05},{0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a},{0x03,0x39,0x0d},{0x03,0x3c,0x0e},
{0x00,0x07,0x01},{0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08},{0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17},
},
{ // 1 - green, 16-color-optimized contrast
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05},{0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08},{0x02,0x2e,0x0b},{0x02,0x31,0x0b},
{0x01,0x22,0x08},{0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c},{0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17},
},
{ // 2 - amber, 4-color-optimized contrast
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00},{0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00},{0x3f,0x26,0x01},{0x3f,0x2b,0x06},
{0x0b,0x02,0x00},{0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00},{0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d},
},
{ // 3 - amber, 16-color-optimized contrast
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00},{0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00},{0x38,0x1c,0x00},{0x3b,0x1e,0x00},
{0x2c,0x13,0x00},{0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00},{0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d},
},
{ // 4 - grey, 4-color-optimized contrast
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x15,0x17,0x18},{0x18,0x1a,0x1b},{0x24,0x25,0x25},{0x27,0x28,0x28},{0x33,0x34,0x32},{0x37,0x38,0x35},
{0x09,0x0a,0x0b},{0x11,0x12,0x13},{0x1c,0x1e,0x1e},{0x20,0x22,0x22},{0x2c,0x2d,0x2c},{0x2f,0x30,0x2f},{0x3c,0x3c,0x38},{0x3f,0x3f,0x3b},
},
{ // 5 - grey, 16-color-optimized contrast
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x13,0x14,0x15},{0x15,0x17,0x18},{0x1e,0x20,0x20},{0x20,0x22,0x22},{0x29,0x2a,0x2a},{0x2c,0x2d,0x2c},
{0x1f,0x21,0x21},{0x23,0x25,0x25},{0x2b,0x2c,0x2b},{0x2d,0x2e,0x2d},{0x34,0x35,0x33},{0x37,0x37,0x34},{0x3e,0x3e,0x3a},{0x3f,0x3f,0x3b},
}
PALETTE cgapal_mono[6] = {
{ /* 0 - green, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x17,0x05},
{0x01,0x1a,0x06},{0x02,0x28,0x09},{0x02,0x2c,0x0a},
{0x03,0x39,0x0d},{0x03,0x3c,0x0e},{0x00,0x07,0x01},
{0x01,0x13,0x04},{0x01,0x1f,0x07},{0x01,0x23,0x08},
{0x02,0x31,0x0b},{0x02,0x35,0x0c},{0x05,0x3f,0x11},{0x0d,0x3f,0x17},
},
{ /* 1 - green, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x00,0x0d,0x03},{0x01,0x15,0x05},
{0x01,0x17,0x05},{0x01,0x21,0x08},{0x01,0x24,0x08},
{0x02,0x2e,0x0b},{0x02,0x31,0x0b},{0x01,0x22,0x08},
{0x02,0x28,0x09},{0x02,0x30,0x0b},{0x02,0x32,0x0c},
{0x03,0x39,0x0d},{0x03,0x3b,0x0e},{0x09,0x3f,0x14},{0x0d,0x3f,0x17},
},
{ /* 2 - amber, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x20,0x0b,0x00},
{0x24,0x0d,0x00},{0x33,0x18,0x00},{0x37,0x1b,0x00},
{0x3f,0x26,0x01},{0x3f,0x2b,0x06},{0x0b,0x02,0x00},
{0x1b,0x08,0x00},{0x29,0x11,0x00},{0x2e,0x14,0x00},
{0x3b,0x1e,0x00},{0x3e,0x21,0x00},{0x3f,0x32,0x0a},{0x3f,0x38,0x0d},
},
{ /* 3 - amber, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x15,0x05,0x00},{0x1e,0x09,0x00},
{0x21,0x0b,0x00},{0x2b,0x12,0x00},{0x2f,0x15,0x00},
{0x38,0x1c,0x00},{0x3b,0x1e,0x00},{0x2c,0x13,0x00},
{0x32,0x17,0x00},{0x3a,0x1e,0x00},{0x3c,0x1f,0x00},
{0x3f,0x27,0x01},{0x3f,0x2a,0x04},{0x3f,0x36,0x0c},{0x3f,0x38,0x0d},
},
{ /* 4 - grey, 4-color-optimized contrast. */
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x15,0x17,0x18},
{0x18,0x1a,0x1b},{0x24,0x25,0x25},{0x27,0x28,0x28},
{0x33,0x34,0x32},{0x37,0x38,0x35},{0x09,0x0a,0x0b},
{0x11,0x12,0x13},{0x1c,0x1e,0x1e},{0x20,0x22,0x22},
{0x2c,0x2d,0x2c},{0x2f,0x30,0x2f},{0x3c,0x3c,0x38},{0x3f,0x3f,0x3b},
},
{ /* 5 - grey, 16-color-optimized contrast. */
{0x00,0x00,0x00},{0x0e,0x0f,0x10},{0x13,0x14,0x15},
{0x15,0x17,0x18},{0x1e,0x20,0x20},{0x20,0x22,0x22},
{0x29,0x2a,0x2a},{0x2c,0x2d,0x2c},{0x1f,0x21,0x21},
{0x23,0x25,0x25},{0x2b,0x2c,0x2b},{0x2d,0x2e,0x2d},
{0x34,0x35,0x33},{0x37,0x37,0x34},{0x3e,0x3e,0x3a},{0x3f,0x3f,0x3b},
}
};
uint32_t pal_lookup[256];
@@ -182,7 +199,7 @@ int d3d_fs_init(HWND h)
_swprintf(emulator_title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W);
d3d_device_window = CreateWindowEx (
0,
szSubClassName,
SUB_CLASS_NAME,
emulator_title,
WS_POPUP,
CW_USEDEFAULT,
@@ -497,7 +514,7 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
hr = d3ddev->Present(NULL, NULL, d3d_device_window, NULL);
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
PostMessage(ghwnd, WM_RESETD3D, 0, 0);
PostMessage(hwndMain, WM_RESETD3D, 0, 0);
}
static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h)
@@ -615,7 +632,7 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h)
hr = d3ddev->Present(NULL, NULL, d3d_device_window, NULL);
if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL)
PostMessage(ghwnd, WM_RESETD3D, 0, 0);
PostMessage(hwndMain, WM_RESETD3D, 0, 0);
}

View File

@@ -33,7 +33,9 @@ static HWND ddraw_hwnd;
int ddraw_init(HWND h)
{
#if NO_THIS_CRASHES_NOW
cgapal_rebuild();
#endif
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
return 0;

View File

@@ -119,7 +119,7 @@ void SaveBitmap(wchar_t *szFilename,HBITMAP hBitmap)
if((fp = _wfopen(szFilename,L"wb"))==NULL)
{
_swprintf(szMessage, win_language_get_string_from_id(IDS_2088), szFilename);
msgbox_error_wstr(ghwnd, szMessage);
msgbox_error_wstr(hwndMain, szMessage);
break;
}

View File

@@ -8,7 +8,7 @@
*
* Windows device configuration dialog implementation.
*
* Version: @(#)win_deviceconfig.c 1.0.3 2017/09/24
* Version: @(#)win_deviceconfig.c 1.0.4 2017/10/05
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -32,7 +32,8 @@
static device_t *config_device;
static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
static BOOL CALLBACK
deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND h;
@@ -270,7 +271,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
return TRUE;
}
ret = msgbox_reset(ghwnd);
ret = msgbox_reset(hwndMain);
switch(ret)
{
case IDNO:

View File

@@ -1,204 +0,0 @@
/*
* 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.
*
* Windows IO device menu handler.
*
* Version: @(#)win_iodev.c 1.0.4 2017/10/01
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
*/
#define UNICODE
#define _WIN32_WINNT 0x0501
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#undef BITMAP
#include <commctrl.h>
#include <commdlg.h>
#include <process.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#include "../ibm.h"
#include "../config.h"
#include "../device.h"
#include "../cdrom/cdrom.h"
#include "../cdrom/cdrom_image.h"
#include "../cdrom/cdrom_ioctl.h"
#include "../cdrom/cdrom_null.h"
#include "../disk/hdd.h"
#include "../scsi/scsi_disk.h"
#include "plat_iodev.h"
#include "win.h"
void cdrom_eject(uint8_t id)
{
int part;
part = find_status_bar_part(SB_CDROM | id);
if ((part == -1) || (sb_menu_handles == NULL))
{
return;
}
if (cdrom_drives[id].host_drive == 0)
{
/* Switch from empty to empty. Do nothing. */
return;
}
if ((cdrom_drives[id].host_drive >= 'A') && (cdrom_drives[id].host_drive <= 'Z'))
{
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_UNCHECKED);
}
if (cdrom_drives[id].host_drive == 200)
{
wcscpy(cdrom_image[id].prev_image_path, cdrom_image[id].image_path);
}
cdrom_drives[id].prev_host_drive = cdrom_drives[id].host_drive;
cdrom_drives[id].handler->exit(id);
cdrom_close(id);
cdrom_null_open(id, 0);
if (cdrom_drives[id].bus_type)
{
/* Signal disc change to the emulated machine. */
cdrom_insert(id);
}
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_UNCHECKED);
cdrom_drives[id].host_drive=0;
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_CHECKED);
update_status_bar_icon_state(SB_CDROM | id, 1);
EnableMenuItem(sb_menu_handles[part], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
update_tip(SB_CDROM | id);
config_save();
}
void cdrom_reload(uint8_t id)
{
int part;
int new_cdrom_drive;
part = find_status_bar_part(SB_CDROM | id);
if ((part == -1) || (sb_menu_handles == NULL))
{
return;
}
if ((cdrom_drives[id].host_drive == cdrom_drives[id].prev_host_drive) || (cdrom_drives[id].prev_host_drive == 0) || (cdrom_drives[id].host_drive != 0))
{
/* Switch from empty to empty. Do nothing. */
return;
}
cdrom_close(id);
if (cdrom_drives[id].prev_host_drive == 200)
{
wcscpy(cdrom_image[id].image_path, cdrom_image[id].prev_image_path);
image_open(id, cdrom_image[id].image_path);
if (cdrom_drives[id].bus_type)
{
/* Signal disc change to the emulated machine. */
cdrom_insert(id);
}
if (wcslen(cdrom_image[id].image_path) == 0)
{
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_CHECKED);
cdrom_drives[id].host_drive = 0;
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_UNCHECKED);
update_status_bar_icon_state(SB_CDROM | id, 1);
}
else
{
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED);
cdrom_drives[id].host_drive = 200;
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_IMAGE | id, MF_CHECKED);
update_status_bar_icon_state(SB_CDROM | id, 0);
}
}
else
{
new_cdrom_drive = cdrom_drives[id].prev_host_drive;
ioctl_open(id, new_cdrom_drive);
if (cdrom_drives[id].bus_type)
{
/* Signal disc change to the emulated machine. */
cdrom_insert(id);
}
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_EMPTY | id, MF_UNCHECKED);
cdrom_drives[id].host_drive = new_cdrom_drive;
CheckMenuItem(sb_menu_handles[part], IDM_CDROM_HOST_DRIVE | id | ((cdrom_drives[id].host_drive - 'A') << 3), MF_CHECKED);
update_status_bar_icon_state(SB_CDROM | id, 0);
}
EnableMenuItem(sb_menu_handles[part], IDM_CDROM_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
update_tip(SB_CDROM | id);
config_save();
}
void removable_disk_unload(uint8_t id)
{
if (wcslen(hdd[id].fn) == 0)
{
/* Switch from empty to empty. Do nothing. */
return;
}
scsi_unloadhd(hdd[id].scsi_id, hdd[id].scsi_lun, id);
scsi_disk_insert(id);
}
void removable_disk_eject(uint8_t id)
{
int part = 0;
part = find_status_bar_part(SB_CDROM | id);
if ((part == -1) || (sb_menu_handles == NULL))
{
return;
}
removable_disk_unload(id);
update_status_bar_icon_state(SB_RDISK | id, 1);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_EJECT | id, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_ENABLED);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | MF_GRAYED);
update_tip(SB_RDISK | id);
config_save();
}
void removable_disk_reload(uint8_t id)
{
int part = 0;
part = find_status_bar_part(SB_CDROM | id);
if ((part == -1) || (sb_menu_handles == NULL))
{
return;
}
if (wcslen(hdd[id].fn) != 0)
{
/* Attempting to reload while an image is already loaded. Do nothing. */
return;
}
scsi_reloadhd(id);
/* scsi_disk_insert(id); */
update_status_bar_icon_state(SB_RDISK | id, wcslen(hdd[id].fn) ? 0 : 1);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_EJECT | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED));
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_RELOAD | id, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(sb_menu_handles[part], IDM_RDISK_SEND_CHANGE | id, MF_BYCOMMAND | (wcslen(hdd[id].fn) ? MF_ENABLED : MF_GRAYED));
update_tip(SB_RDISK | id);
config_save();
}

View File

@@ -151,7 +151,7 @@ void joystick_init()
lpdi_joystick[c]->EnumObjects(DIEnumDeviceObjectsCallback, &plat_joystick_state[c], DIDFT_ALL);
if (FAILED(lpdi_joystick[c]->SetCooperativeLevel(ghwnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
if (FAILED(lpdi_joystick[c]->SetCooperativeLevel(hwndMain, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
fatal("joystick_init : SetCooperativeLevel failed\n");
if (FAILED(lpdi_joystick[c]->SetDataFormat(&c_dfDIJoystick)))
fatal("joystick_init : SetDataFormat failed\n");

View File

@@ -8,14 +8,13 @@
*
* Windows localization core.
*
* Version: @(#)win_language.c 1.0.2 2017/09/24
* Version: @(#)win_language.c 1.0.3 2017/10/05
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Copyright 2008-2017 Sarah Walker.
* Copyright 2016,2017 Miran Grca.
*/
//#include <inttypes.h>
#define UNICODE
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
@@ -129,7 +128,9 @@ LPTSTR win_language_get_settings_category(int i)
void win_language_update()
{
win_language_set();
#if 0
win_menu_update();
#endif
win_language_load_common_strings();
}
@@ -225,7 +226,7 @@ void msgbox_error(HWND hwndParent, int i)
void plat_msgbox_error(int i)
{
msgbox_error(ghwnd, i);
msgbox_error(hwndMain, i);
}
void msgbox_error_wstr(HWND hwndParent, WCHAR *wstr)
@@ -252,7 +253,7 @@ void msgbox_fatal(HWND hwndParent, char *string)
void plat_msgbox_fatal(char *string)
{
msgbox_fatal(ghwnd, string);
msgbox_fatal(hwndMain, string);
}
int file_dlg_w(HWND hwnd, WCHAR *f, WCHAR *fn, int save)

View File

@@ -48,7 +48,7 @@ void mouse_init(void)
fatal("mouse_init : DirectInputCreate failed\n");
if (FAILED(lpdi->CreateDevice(GUID_SysMouse, &lpdi_mouse, NULL)))
fatal("mouse_init : CreateDevice failed\n");
if (FAILED(lpdi_mouse->SetCooperativeLevel(ghwnd, DISCL_FOREGROUND | (video_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE))))
if (FAILED(lpdi_mouse->SetCooperativeLevel(hwndMain, DISCL_FOREGROUND | (video_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE))))
fatal("mouse_init : SetCooperativeLevel failed\n");
if (FAILED(lpdi_mouse->SetDataFormat(&c_dfDIMouse)))
fatal("mouse_init : SetDataFormat failed\n");

View File

@@ -8,7 +8,7 @@
*
* Windows 86Box Settings dialog handler.
*
* Version: @(#)win_settings.c 1.0.17 2017/10/02
* Version: @(#)win_settings.c 1.0.18 2017/10/05
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016,2017 Miran Grca.
@@ -279,7 +279,7 @@ static void win_settings_save(void)
{
int i = 0;
resetpchard_close();
pc_reset_hard_close();
/* Machine category */
machine = temp_machine;
@@ -348,11 +348,11 @@ static void win_settings_save(void)
mem_resize();
rom_load_bios(romset);
update_status_bar_panes(hwndStatus);
StatusBarUpdatePanes();
sound_realloc_buffers();
resetpchard_init();
pc_reset_hard_init();
cpu_set();
@@ -2804,7 +2804,7 @@ hd_add_ok_common:
if (f != NULL)
{
fclose(f);
if (msgbox_question(ghwnd, IDS_4111) != IDYES)
if (msgbox_question(hwndMain, IDS_4111) != IDYES)
{
return FALSE;
}

View File

@@ -17,81 +17,89 @@
#include "win.h"
HWND status_hwnd;
int status_is_open = 0;
HWND hwndStatus = NULL;
extern int sreadlnum, swritelnum, segareads, segawrites, scycles_lost;
extern uint64_t main_time;
static uint64_t status_time;
static BOOL CALLBACK status_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
static BOOL CALLBACK
StatusWindowProcedure(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char device_s[4096];
switch (message)
{
case WM_INITDIALOG:
status_is_open = 1;
case WM_USER:
{
uint64_t new_time = timer_read();
uint64_t status_diff = new_time - status_time;
status_time = new_time;
sprintf(device_s,
"CPU speed : %f MIPS\n"
"FPU speed : %f MFLOPS\n\n"
char temp[4096];
uint64_t new_time;
uint64_t status_diff;
"Video throughput (read) : %i bytes/sec\n"
"Video throughput (write) : %i bytes/sec\n\n"
"Effective clockspeed : %iHz\n\n"
"Timer 0 frequency : %fHz\n\n"
"CPU time : %f%% (%f%%)\n"
switch (message) {
case WM_INITDIALOG:
hwndStatus = hdlg;
/*FALLTHROUGH*/
"New blocks : %i\nOld blocks : %i\nRecompiled speed : %f MIPS\nAverage size : %f\n"
"Flushes : %i\nEvicted : %i\nReused : %i\nRemoved : %i\nReal speed : %f MIPS"
,mips,
flops,
segareads,
segawrites,
clockrate - scycles_lost,
pit_timer0_freq(),
((double)main_time * 100.0) / status_diff,
((double)main_time * 100.0) / timer_freq
case WM_USER:
new_time = timer_read();
status_diff = new_time - status_time;
status_time = new_time;
sprintf(temp,
"CPU speed : %f MIPS\n"
"FPU speed : %f MFLOPS\n\n"
, cpu_new_blocks_latched, cpu_recomp_blocks_latched, (double)cpu_recomp_ins_latched / 1000000.0, (double)cpu_recomp_ins_latched/cpu_recomp_blocks_latched,
cpu_recomp_flushes_latched, cpu_recomp_evicted_latched,
cpu_recomp_reuse_latched, cpu_recomp_removed_latched,
((double)cpu_recomp_ins_latched / 1000000.0) / ((double)main_time / timer_freq)
);
main_time = 0;
SendDlgItemMessage(hdlg, IDT_SDEVICE, WM_SETTEXT, (WPARAM)NULL, (LPARAM)device_s);
"Video throughput (read) : %i bytes/sec\n"
"Video throughput (write) : %i bytes/sec\n\n"
"Effective clockspeed : %iHz\n\n"
"Timer 0 frequency : %fHz\n\n"
"CPU time : %f%% (%f%%)\n"
device_s[0] = 0;
device_add_status_info(device_s, 4096);
SendDlgItemMessage(hdlg, IDT_STEXT, WM_SETTEXT, (WPARAM)NULL, (LPARAM)device_s);
}
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
case IDCANCEL:
status_is_open = 0;
EndDialog(hdlg, 0);
return TRUE;
}
break;
}
"New blocks : %i\nOld blocks : %i\nRecompiled speed : %f MIPS\nAverage size : %f\n"
"Flushes : %i\nEvicted : %i\nReused : %i\nRemoved : %i\nReal speed : %f MIPS"
,mips,
flops,
segareads,
segawrites,
clockrate - scycles_lost,
pit_timer0_freq(),
((double)main_time * 100.0) / status_diff,
((double)main_time * 100.0) / timer_freq
return FALSE;
, cpu_new_blocks_latched, cpu_recomp_blocks_latched, (double)cpu_recomp_ins_latched / 1000000.0, (double)cpu_recomp_ins_latched/cpu_recomp_blocks_latched,
cpu_recomp_flushes_latched, cpu_recomp_evicted_latched,
cpu_recomp_reuse_latched, cpu_recomp_removed_latched,
((double)cpu_recomp_ins_latched / 1000000.0) / ((double)main_time / timer_freq)
);
main_time = 0;
SendDlgItemMessage(hdlg, IDT_SDEVICE, WM_SETTEXT,
(WPARAM)NULL, (LPARAM)temp);
temp[0] = 0;
device_add_status_info(temp, 4096);
SendDlgItemMessage(hdlg, IDT_STEXT, WM_SETTEXT,
(WPARAM)NULL, (LPARAM)temp);
return(TRUE);
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
hwndStatus = NULL;
EndDialog(hdlg, 0);
return(TRUE);
}
break;
}
return(FALSE);
}
void status_open(HWND hwnd)
void
StatusWindowCreate(HWND hwndParent)
{
status_hwnd = CreateDialog(hinstance, (LPCSTR)DLG_STATUS, hwnd, status_dlgproc);
ShowWindow(status_hwnd, SW_SHOW);
HWND hwnd;
hwnd = CreateDialog(hinstance, (LPCSTR)DLG_STATUS,
hwndParent, StatusWindowProcedure);
ShowWindow(hwnd, SW_SHOW);
}

147
src/win/win_thread.c Normal file
View File

@@ -0,0 +1,147 @@
/*
* 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.
*
* Implement threads and mutexes for the Win32 platform.
*
* Version: @(#)win_thread.c 1.0.1 2017/10/05
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Fred N. van Kempen, <decwiz@yahoo.com>
* Copyright 2008-2017 Sarah Walker.
* Copyright 2017 Fred N. van Kempen.
*/
#define UNICODE
#define BITMAP WINDOWS_BITMAP
#include <windows.h>
#include <windowsx.h>
#include <process.h>
#undef BITMAP
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#include "../ibm.h"
#include "plat_thread.h"
typedef struct {
HANDLE handle;
} win_event_t;
void *
thread_create(void (*thread_rout)(void *param), void *param)
{
return((void *)_beginthread(thread_rout, 0, param));
}
void
thread_kill(void *handle)
{
TerminateThread(handle, 0);
}
void
thread_sleep(int t)
{
Sleep(t);
}
event_t *
thread_create_event(void)
{
win_event_t *event = malloc(sizeof(win_event_t));
event->handle = CreateEvent(NULL, FALSE, FALSE, NULL);
return((event_t *)event);
}
void
thread_set_event(event_t *_event)
{
win_event_t *event = (win_event_t *)_event;
SetEvent(event->handle);
}
void
thread_reset_event(event_t *_event)
{
win_event_t *event = (win_event_t *)_event;
ResetEvent(event->handle);
}
int
thread_wait_event(event_t *_event, int timeout)
{
win_event_t *event = (win_event_t *)_event;
if (timeout == -1)
timeout = INFINITE;
if (WaitForSingleObject(event->handle, timeout)) return(1);
return(0);
}
void
thread_destroy_event(event_t *_event)
{
win_event_t *event = (win_event_t *)_event;
CloseHandle(event->handle);
free(event);
}
void *
thread_create_mutex(wchar_t *name)
{
return((void*)CreateMutex(NULL, FALSE, name));
}
void
thread_close_mutex(void *mutex)
{
CloseHandle((HANDLE)mutex);
}
uint8_t
thread_wait_mutex(void *mutex)
{
DWORD dwres = WaitForSingleObject((HANDLE)mutex, INFINITE);
switch (dwres) {
case WAIT_OBJECT_0:
return(1);
case WAIT_ABANDONED:
default:
return(0);
}
}
uint8_t
thread_release_mutex(void *mutex)
{
return(!!ReleaseMutex((HANDLE)mutex));
}