Applied the recent mainline PCem commits (and fixed the Pentium machines);

Ported the Roland MT-32 emulation (using MUNT) from bit's MT32 emulation branch of PCem;
Sanitized the OpenAL give buffer code in openal.c a bit;
NVR path is now specifiable in the Settings dialog;
Added Logitech 3-button serial mouse per protocol description by waltje;
The RTL8029AS and the BT-958D now actually use the PCI IRQ routing;
Fixed BT-958D PCI device initialization on the bus;
PCI IRQ routing now respects the edge/level setting set on ports 4D0/4D1.
This commit is contained in:
OBattler
2017-06-19 06:46:08 +02:00
parent 9c9f7b1b9a
commit 1e7668f1db
112 changed files with 16289 additions and 732 deletions

View File

@@ -44,13 +44,47 @@ MAINMENU MENU DISCARDABLE
BEGIN
POPUP "&Action"
BEGIN
MENUITEM "Take s&creenshot\tCtrl+F11", IDM_ACTION_SCREENSHOT
MENUITEM SEPARATOR
MENUITEM "&Hard Reset", IDM_ACTION_HRESET
MENUITEM "&Ctrl+Alt+Del\tCtrl+F12", IDM_ACTION_RESET_CAD
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_ACTION_EXIT
END
POPUP "&View"
BEGIN
MENUITEM "&Resizeable window", IDM_VID_RESIZE
MENUITEM "R&emember size && position", IDM_VID_REMEMBER
MENUITEM SEPARATOR
POPUP "Re&nderer"
BEGIN
MENUITEM "&DirectDraw", IDM_VID_DDRAW
MENUITEM "Direct&3D 9", IDM_VID_D3D
END
MENUITEM SEPARATOR
POPUP "&Window scale factor"
BEGIN
MENUITEM "&0.5x", IDM_VID_SCALE_1X
MENUITEM "&1x", IDM_VID_SCALE_2X
MENUITEM "1.&5x", IDM_VID_SCALE_3X
MENUITEM "&2x", IDM_VID_SCALE_4X
END
MENUITEM SEPARATOR
MENUITEM "&Fullscreen\tCtrl+Alt+PageUP", IDM_VID_FULLSCREEN
POPUP "Fullscreen &stretch mode"
BEGIN
MENUITEM "&Full screen stretch", IDM_VID_FS_FULL
MENUITEM "&4:3", IDM_VID_FS_43
MENUITEM "&Square pixels", IDM_VID_FS_SQ
MENUITEM "&Integer scale", IDM_VID_FS_INT
END
POPUP "E&GA/(S)VGA settings"
BEGIN
MENUITEM "&Inverted VGA monitor", IDM_VID_INVERT
MENUITEM "E&GA/(S)VGA overscan", IDM_VID_OVERSCAN
END
MENUITEM SEPARATOR
MENUITEM "F&orce 4:3 display ratio", IDM_VID_FORCE43
MENUITEM "Change contrast for &monochrome display", IDM_VID_CGACON
END
POPUP "&Tools"
BEGIN
MENUITEM "&Settings...", IDM_CONFIG
@@ -58,38 +92,8 @@ BEGIN
MENUITEM "&Load configuration...", IDM_CONFIG_LOAD
MENUITEM "&Save configuration...", IDM_CONFIG_SAVE
MENUITEM SEPARATOR
POPUP "&Video"
BEGIN
MENUITEM "&Resizeable window", IDM_VID_RESIZE
MENUITEM "R&emember size && position", IDM_VID_REMEMBER
MENUITEM SEPARATOR
MENUITEM "&DirectDraw", IDM_VID_DDRAW
MENUITEM "Direct&3D 9", IDM_VID_D3D
MENUITEM SEPARATOR
POPUP "&Window scale factor"
BEGIN
MENUITEM "&0.5x", IDM_VID_SCALE_1X
MENUITEM "&1x", IDM_VID_SCALE_2X
MENUITEM "1.&5x", IDM_VID_SCALE_3X
MENUITEM "&2x", IDM_VID_SCALE_4X
END
MENUITEM SEPARATOR
MENUITEM "&Fullscreen\tCtrl+Alt+PageUP", IDM_VID_FULLSCREEN
POPUP "Fullscreen &stretch mode"
BEGIN
MENUITEM "&Full screen stretch", IDM_VID_FS_FULL
MENUITEM "&4:3", IDM_VID_FS_43
MENUITEM "&Square pixels", IDM_VID_FS_SQ
MENUITEM "&Integer scale", IDM_VID_FS_INT
END
MENUITEM SEPARATOR
MENUITEM "&Inverted VGA monitor", IDM_VID_INVERT
MENUITEM "F&orce 4:3 display ratio", IDM_VID_FORCE43
MENUITEM "E&GA/(S)VGA overscan", IDM_VID_OVERSCAN
MENUITEM "Change contrast for &monochrome display", IDM_VID_CGACON
END
MENUITEM "S&tatus", IDM_STATUS
MENUITEM "Take s&creenshot\tCtrl+F11", IDM_ACTION_SCREENSHOT
END
#if defined(ENABLE_LOG_TOGGLES) || defined(ENABLE_LOG_COMMANDS)
POPUP "&Logging"
@@ -211,12 +215,15 @@ BEGIN
CONTROL "List2",IDC_SETTINGSCATLIST,"SysListView32",LVS_LIST |
LVS_SHOWSELALWAYS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP,7,7,90,197
CONTROL "",-1,"Static",SS_BLACKFRAME | SS_SUNKEN,1,211,363,1
/* Leave this commented out until we get into localization. */
#if 0
LTEXT "Language:",IDT_1700,7,222,41,10
COMBOBOX IDC_COMBO_LANG,48,221,108,120,CBS_DROPDOWN | WS_VSCROLL |
WS_TABSTOP
#endif
END
DLG_CFG_MACHINE DIALOG DISCARDABLE 97, 0, 267, 112
DLG_CFG_MACHINE DIALOG DISCARDABLE 97, 0, 267, 132
STYLE DS_CONTROL | WS_CHILD
FONT 9, "Segoe UI"
BEGIN
@@ -227,24 +234,27 @@ BEGIN
COMBOBOX IDC_COMBO_CPU_TYPE,71,25,45,120,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "CPU type:",IDT_1702,7,26,59,10
COMBOBOX IDC_COMBO_WS,71,44,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
LTEXT "Wait states:",IDT_1703,7,45,60,10
COMBOBOX IDC_COMBO_CPU,145,25,115,120,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
LTEXT "CPU:",IDT_1704,124,26,18,10
CONTROL "Dynamic Recompiler",IDC_CHECK_DYNAREC,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10
CONTROL "Enable FPU",IDC_CHECK_FPU,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,147,80,113,10
COMBOBOX IDC_COMBO_WS,71,44,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
LTEXT "Wait states:",IDT_1703,7,45,60,10
EDITTEXT IDC_MEMTEXT,70,63,45,12,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "",IDC_MEMSPIN,"msctls_updown32",UDS_SETBUDDYINT |
UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,113,63,
12,12
LTEXT "MB",IDT_1705,123,64,10,10
LTEXT "Memory:",IDT_1706,7,64,30,10
LTEXT "NVR Path:",IDT_1700,7,83,60,10
EDITTEXT IDC_EDIT_NVR_PATH,71,82,138,12
PUSHBUTTON "&Specify...",IDC_BUTTON_NVR_PATH,214,82,46,12
CONTROL "Dynamic Recompiler",IDC_CHECK_DYNAREC,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,100,94,10
CONTROL "Enable FPU",IDC_CHECK_FPU,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,147,100,113,10
CONTROL "Enable time sync",IDC_CHECK_SYNC,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,95,102,10
BS_AUTOCHECKBOX | WS_TABSTOP,7,115,102,10
END
DLG_CFG_VIDEO DIALOG DISCARDABLE 97, 0, 267, 63
@@ -287,9 +297,11 @@ BEGIN
WS_TABSTOP
LTEXT "Sound card:",IDT_1711,7,8,59,10
PUSHBUTTON "Configure",IDC_CONFIGURE_SND,214,7,46,12
COMBOBOX IDC_COMBO_MIDI,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL |
COMBOBOX IDC_COMBO_MIDI,71,25,140,120,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
LTEXT "MIDI Out Device:",IDT_1712,7,26,59,10
PUSHBUTTON "Configure",IDC_CONFIGURE_MIDI,214,25,46,12
CONTROL "Standalone MPU-401",IDC_CHECK_MPU401,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,45,199,10
@@ -868,10 +880,12 @@ BEGIN
IDS_2221 "Turbo"
IDS_2222 "On"
IDS_2223 "Off"
IDS_2224 "<Placeholder string>"
IDS_2225 "English (United States)"
IDS_2224 "Logitech 3-button mouse (serial)"
IDS_2225 "Specify the NVR Path"
IDS_2226 "<Placeholder string>"
IDS_2227 "English (United States)"
END
#define IDS_LANG_ENUS IDS_2225
#define IDS_LANG_ENUS IDS_2227
#ifndef _MAC

View File

@@ -1,10 +1,7 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
void midi_init();
void midi_close();
void midi_write(uint8_t val);
int midi_get_num_devs();
void midi_get_dev_name(int num, char *s);
extern int midi_id;
void plat_midi_init();
void plat_midi_close();
void plat_midi_play_msg(uint8_t* val);
void plat_midi_play_sysex(uint8_t* data, unsigned int len);
int plat_midi_write(uint8_t val);
int plat_midi_get_num_devs();
void plat_midi_get_dev_name(int num, char *s);

2
src/WIN/plat_ticks.h Normal file
View File

@@ -0,0 +1,2 @@
uint32_t get_ticks(void);
void delay_ms(uint32_t count);

View File

@@ -87,7 +87,10 @@
#define IDC_SETTINGSCATLIST 1001 /* generic config */
#define IDC_CFILE 1002 /* Select File dialog */
#define IDC_CHECK_SYNC 1008
/* Leave this as is until we finally get into localization in 86Box 3.00(?). */
#if 0
#define IDC_COMBO_LANG 1009
#endif
#define IDC_COMBO_MACHINE 1010 /* machine/cpu config */
#define IDC_CONFIGURE_MACHINE 1011
@@ -99,6 +102,8 @@
#define IDC_MEMTEXT 1017
#define IDC_MEMSPIN 1018
#define IDC_TEXT_MB IDT_1705
#define IDC_EDIT_NVR_PATH 1019
#define IDC_BUTTON_NVR_PATH 1020
#define IDC_VIDEO 1030 /* video config */
#define IDC_COMBO_VIDEO 1031
@@ -181,6 +186,7 @@
#define IDC_CONFIGURE_BUSLOGIC 1205
#define IDC_CONFIGURE_PCAP 1206
#define IDC_CONFIGURE_NET 1207
#define IDC_CONFIGURE_MIDI 1208
#define IDC_JOY1 1210
#define IDC_JOY2 1211
#define IDC_JOY3 1212
@@ -367,11 +373,13 @@
#define IDS_2221 2221 // "Turbo"
#define IDS_2222 2222 // "On"
#define IDS_2223 2223 // "Off"
#define IDS_2224 2224 // "<Placeholder string>"
#define IDS_2225 2225 // "English (United States)"
#define IDS_2224 2224 // "Logitech 3-button mouse (serial)"
#define IDS_2225 2225 // "Specify the NVR Path"
#define IDS_2226 2226 // "<Placeholder string>"
#define IDS_2227 2227 // "English (United States)"
#define IDS_LANG_ENUS IDS_2225
#define STRINGS_NUM 178
#define IDS_LANG_ENUS IDS_2227
#define STRINGS_NUM 180
#define IDM_ABOUT 40001

View File

@@ -49,6 +49,7 @@
#include "plat_mouse.h"
#include "plat_midi.h"
#include "plat_thread.h"
#include "plat_ticks.h"
#include "plat_ui.h"
#include "win.h"
@@ -271,6 +272,16 @@ void leave_fullscreen(void)
leave_fullscreen_flag = 1;
}
uint32_t get_ticks(void)
{
return GetTickCount();
}
void delay_ms(uint32_t count)
{
Sleep(count);
}
void mainthread(LPVOID param)
{
int frames = 0;
@@ -2044,6 +2055,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
null_close(i);
}
}
resetpchard_close();
loadconfig(wopenfilestring);
for (i = 0; i < CDROM_NUM; i++)
{
@@ -2075,7 +2087,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
mem_resize();
loadbios();
update_status_bar_panes(hwndStatus);
resetpchard();
resetpchard_init();
}
}
pause = 0;
@@ -2318,7 +2330,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR
break;
}
ret = file_dlg_w_st(hwnd, IDS_2173, discfns[id], id);
ret = file_dlg_w_st(hwnd, IDS_2173, discfns[id], 0);
if (!ret)
{
disc_close(id);

View File

@@ -8,7 +8,7 @@
*
* Windows device configuration dialog implementation.
*
* Version: @(#)win_deviceconfig.c 1.0.0 2017/05/30
* Version: @(#)win_deviceconfig.c 1.0.1 2017/06/19
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -18,8 +18,10 @@
#include "../ibm.h"
#include "../config.h"
#include "../device.h"
#include "plat_midi.h"
#define NO_UNICODE /*FIXME: not Unicode? */
#include "win.h"
#include "win_language.h"
#include <windowsx.h>
@@ -29,15 +31,22 @@ static device_t *config_device;
static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND h;
int val_int;
int ret;
int id;
device_config_t *config;
int c;
int num;
int changed;
char s[80];
switch (message)
{
case WM_INITDIALOG:
{
int id = IDC_CONFIG_BASE;
device_config_t *config = config_device->config;
int c;
id = IDC_CONFIG_BASE;
config = config_device->config;
while (config->type != -1)
{
@@ -70,6 +79,21 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2;
break;
case CONFIG_MIDI:
val_int = config_get_int(config_device->name, config->name, config->default_int);
num = plat_midi_get_num_devs();
for (c = 0; c < num; c++)
{
plat_midi_get_dev_name(c, s);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
if (val_int == c)
SendMessage(h, CB_SETCURSEL, c, 0);
}
id += 2;
break;
case CONFIG_HEX16:
val_int = config_get_hex16(config_device->name, config->name, config->default_int);
@@ -112,10 +136,9 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
{
case IDOK:
{
int id = IDC_CONFIG_BASE;
device_config_t *config = config_device->config;
int c;
int changed = 0;
id = IDC_CONFIG_BASE;
config = config_device->config;
changed = 0;
while (config->type != -1)
{
@@ -147,6 +170,17 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2;
break;
case CONFIG_MIDI:
val_int = config_get_int(config_device->name, config->name, config->default_int);
c = SendMessage(h, CB_GETCURSEL, 0, 0);
if (val_int != c)
changed = 1;
id += 2;
break;
case CONFIG_HEX16:
val_int = config_get_hex16(config_device->name, config->name, config->default_int);
@@ -183,11 +217,17 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
EndDialog(hdlg, 0);
return TRUE;
}
if (MessageBox(NULL, "This will reset 86Box!\nOkay to continue?", "86Box", MB_OKCANCEL) != IDOK)
{
EndDialog(hdlg, 0);
return TRUE;
ret = msgbox_reset(ghwnd);
switch(ret)
{
case IDNO:
EndDialog(hdlg, 0);
return TRUE;
case IDCANCEL:
return FALSE;
default:
break;
}
id = IDC_CONFIG_BASE;
@@ -215,6 +255,13 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam
id += 2;
break;
case CONFIG_MIDI:
c = SendMessage(h, CB_GETCURSEL, 0, 0);
config_set_int(config_device->name, config->name, c);
id += 2;
break;
case CONFIG_HEX16:
c = SendMessage(h, CB_GETCURSEL, 0, 0);
for (; c > 0; c--)
@@ -308,6 +355,7 @@ void deviceconfig_open(HWND hwnd, device_t *device)
break;
case CONFIG_SELECTION:
case CONFIG_MIDI:
case CONFIG_HEX16:
case CONFIG_HEX20:
/*Combo box*/

View File

@@ -237,10 +237,10 @@ static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg, LPARAM lParam, LPARA
WCHAR path[MAX_PATH];
wchar_t *BrowseFolder(wchar_t *saved_path)
wchar_t *BrowseFolder(wchar_t *saved_path, wchar_t *title)
{
BROWSEINFO bi = { 0 };
bi.lpszTitle = L"Browse for folder...";
bi.lpszTitle = title;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) saved_path;
@@ -253,15 +253,12 @@ wchar_t *BrowseFolder(wchar_t *saved_path)
SHGetPathFromIDList(pidl, path);
/* Free memory used. */
#if 0
IMalloc *imalloc = 0;
if (SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->Free(pidl);
imalloc->Release();
imalloc->lpVtbl->Free(imalloc, pidl);
imalloc->lpVtbl->Release(imalloc);
}
#endif
free(pidl);
return path;
}

View File

@@ -46,6 +46,8 @@ void win_language_check();
LPTSTR win_language_get_string_from_id(int i);
LPTSTR win_language_get_string_from_string(char *str);
wchar_t *BrowseFolder(wchar_t *saved_path, wchar_t *title);
#ifdef __cplusplus
}
#endif

View File

@@ -1,25 +1,8 @@
/*
* 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.
*
* MIDI interface to host device.
*
* Version: @(#)win_midi.c 1.0.0 2017/05/30
*
* Author: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
* Copyright 2008-2017 Sarah Walker.
* Copyright 2016-2017 Miran Grca.
*/
#include <windows.h>
#include <mmsystem.h>
#include "../ibm.h"
#include "../config.h"
#include "../SOUND/midi.h"
#include "plat_midi.h"
int midi_id = 0;
@@ -27,8 +10,6 @@ static HMIDIOUT midi_out_device = NULL;
HANDLE m_event;
void midi_close();
static uint8_t midi_rt_buf[1024];
static uint8_t midi_cmd_buf[1024];
static int midi_cmd_pos = 0;
@@ -37,31 +18,20 @@ static uint8_t midi_status = 0;
static unsigned int midi_sysex_start = 0;
static unsigned int midi_sysex_delay = 0;
uint8_t MIDI_evt_len[256] = {
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x00
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x10
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x20
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x30
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x40
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x50
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x60
0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x70
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x80
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x90
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xa0
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xb0
2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xc0
2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xd0
3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xe0
0,2,3,2, 0,0,1,0, 1,0,1,1, 1,0,1,0 // 0xf0
};
void midi_init()
void plat_midi_init()
{
/* This is for compatibility with old configuration files. */
midi_id = config_get_int("Sound", "midi_host_device", -1);
if (midi_id == -1)
{
midi_id = config_get_int(SYSTEM_MIDI_NAME, "midi", 0);
}
else
{
config_delete_var("Sound", "midi_host_device");
config_set_int(SYSTEM_MIDI_NAME, "midi", midi_id);
}
MMRESULT hr = MMSYSERR_NOERROR;
memset(midi_rt_buf, 0, sizeof(midi_rt_buf));
@@ -86,11 +56,11 @@ void midi_init()
return;
}
}
midiOutReset(midi_out_device);
}
void midi_close()
void plat_midi_close()
{
if (midi_out_device != NULL)
{
@@ -101,11 +71,11 @@ void midi_close()
}
}
int midi_get_num_devs()
int plat_midi_get_num_devs()
{
return midiOutGetNumDevs();
}
void midi_get_dev_name(int num, char *s)
void plat_midi_get_dev_name(int num, char *s)
{
MIDIOUTCAPS caps;
@@ -113,17 +83,14 @@ void midi_get_dev_name(int num, char *s)
strcpy(s, caps.szPname);
}
static int midi_pos;
static uint8_t midi_sysex_data[1024+2];
void PlayMsg(uint8_t *msg)
void plat_midi_play_msg(uint8_t *msg)
{
midiOutShortMsg(midi_out_device, *(uint32_t *) msg);
}
MIDIHDR m_hdr;
void PlaySysex(uint8_t *sysex, unsigned int len)
void plat_midi_play_sysex(uint8_t *sysex, unsigned int len)
{
MMRESULT result;
@@ -152,124 +119,7 @@ void PlaySysex(uint8_t *sysex, unsigned int len)
}
}
#define SYSEX_SIZE 1024
#define RAWBUF 1024
void midi_write(uint8_t val)
int plat_midi_write(uint8_t val)
{
uint32_t passed_ticks;
if (midi_sysex_start)
{
passed_ticks = GetTickCount() - midi_sysex_start;
if (passed_ticks < midi_sysex_delay)
{
Sleep(midi_sysex_delay - passed_ticks);
}
}
/* Test for a realtime MIDI message */
if (val >= 0xf8)
{
midi_rt_buf[0] = val;
PlayMsg(midi_rt_buf);
return;
}
/* Test for a active sysex transfer */
if (midi_status == 0xf0)
{
if (!(val & 0x80))
{
if (midi_pos < (SYSEX_SIZE-1)) midi_sysex_data[midi_pos++] = val;
return;
}
else
{
midi_sysex_data[midi_pos++] = 0xf7;
if ((midi_sysex_start) && (midi_pos >= 4) && (midi_pos <= 9) && (midi_sysex_data[1] == 0x411) && (midi_sysex_data[3] == 0x16))
{
/* pclog("MIDI: Skipping invalid MT-32 SysEx MIDI message\n"); */
}
else
{
PlaySysex(midi_sysex_data, midi_pos);
if (midi_sysex_start)
{
if (midi_sysex_data[5] == 0x7f)
{
midi_sysex_delay = 290; /* All parameters reset */
}
else if ((midi_sysex_data[5] == 0x10) && (midi_sysex_data[6] == 0x00) && (midi_sysex_data[7] == 0x04))
{
midi_sysex_delay = 145; /* Viking Child */
}
else if ((midi_sysex_data[5] == 0x10) && (midi_sysex_data[6] == 0x00) && (midi_sysex_data[7] == 0x01))
{
midi_sysex_delay = 30; /* Dark Sun 1 */
}
else
midi_sysex_delay = (unsigned int) (((float) (midi_pos) * 1.25f) * 1000.0f / 3125.0f) + 2;
midi_sysex_start = GetTickCount();
}
}
}
}
if (val & 0x80)
{
midi_status = val;
midi_cmd_pos = 0;
midi_cmd_len = MIDI_evt_len[val];
if (midi_status == 0xf0)
{
midi_sysex_data[0] = 0xf0;
midi_pos = 1;
}
}
if (midi_cmd_len)
{
midi_cmd_buf[midi_cmd_pos++] = val;
if (midi_cmd_pos >= midi_cmd_len)
{
PlayMsg(midi_cmd_buf);
midi_cmd_pos = 1;
}
}
}
void midi_reset()
{
uint8_t buf[64];
/* Flush buffers */
midiOutReset(midi_out_device);
/* GM1 reset */
buf[0] = 0xf0;
buf[1] = 0x7e;
buf[2] = 0x7f;
buf[3] = 0x09;
buf[4] = 0x01;
buf[5] = 0xf7;
PlaySysex((uint8_t *) buf, 6);
/* GS1 reset */
buf[0] = 0xf0;
buf[1] = 0x41;
buf[2] = 0x10;
buf[3] = 0x42;
buf[4] = 0x12;
buf[5] = 0x40;
buf[6] = 0x00;
buf[7] = 0x7f;
buf[8] = 0x00;
buf[9] = 0x41;
buf[10] = 0xf7;
PlaySysex((uint8_t *) buf, 11);
return 0;
}

View File

@@ -8,7 +8,7 @@
*
* Windows 86Box Settings dialog handler.
*
* Version: @(#)win_settings.c 1.0.3 2017/06/14
* Version: @(#)win_settings.c 1.0.4 2017/06/19
*
* Author: Miran Grca, <mgrca8@gmail.com>
* Copyright 2016-2017 Miran Grca.
@@ -35,6 +35,7 @@
#include "../scsi.h"
#include "../scsi_buslogic.h"
#include "../network/network.h"
#include "../sound/midi.h"
#include "../sound/sound.h"
#include "../sound/snd_dbopl.h"
#include "../sound/snd_mpu401.h"
@@ -49,6 +50,7 @@
/* Machine category */
static int temp_model, temp_cpu_m, temp_cpu, temp_wait_states, temp_mem_size, temp_dynarec, temp_fpu, temp_sync;
static wchar_t temp_nvr_path[520];
/* Video category */
static int temp_gfxcard, temp_video_speed, temp_voodoo;
@@ -57,7 +59,7 @@ static int temp_gfxcard, temp_video_speed, temp_voodoo;
static int temp_mouse, temp_joystick;
/* Sound category */
static int temp_sound_card, temp_midi_id, temp_mpu401, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type;
static int temp_sound_card, temp_midi_device, temp_mpu401, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type;
static int temp_float;
/* Network category */
@@ -87,6 +89,7 @@ static int displayed_category = 0;
extern int is486;
static int romstolist[ROM_MAX], listtomodel[ROM_MAX], romstomodel[ROM_MAX], modeltolist[ROM_MAX];
static int settings_sound_to_list[20], settings_list_to_sound[20];
static int settings_midi_to_list[20], settings_list_to_midi[20];
static int settings_mouse_to_list[20], settings_list_to_mouse[20];
static int settings_scsi_to_list[20], settings_list_to_scsi[20];
static int settings_network_to_list[20], settings_list_to_network[20];
@@ -104,6 +107,8 @@ static void win_settings_init(void)
temp_wait_states = cpu_waitstates;
temp_cpu = cpu;
temp_mem_size = mem_size;
memset(temp_nvr_path, 0, sizeof(temp_nvr_path));
wcscpy(temp_nvr_path, nvr_path);
temp_dynarec = cpu_use_dynarec;
temp_fpu = enable_external_fpu;
temp_sync = enable_sync;
@@ -119,7 +124,7 @@ static void win_settings_init(void)
/* Sound category */
temp_sound_card = sound_card_current;
temp_midi_id = midi_id;
temp_midi_device = midi_device_current;
temp_mpu401 = mpu401_standalone_enable;
temp_SSI2001 = SSI2001;
temp_GAMEBLASTER = GAMEBLASTER;
@@ -170,6 +175,7 @@ static int win_settings_changed(void)
i = i || (cpu_waitstates != temp_wait_states);
i = i || (cpu != temp_cpu);
i = i || (mem_size != temp_mem_size);
i = i || wcscmp(temp_nvr_path, nvr_path);
i = i || (temp_dynarec != cpu_use_dynarec);
i = i || (temp_fpu != enable_external_fpu);
i = i || (temp_sync != enable_sync);
@@ -185,7 +191,7 @@ static int win_settings_changed(void)
/* Sound category */
i = i || (sound_card_current != temp_sound_card);
i = i || (midi_id != temp_midi_id);
i = i || (midi_device_current != temp_midi_device);
i = i || (mpu401_standalone_enable != temp_mpu401);
i = i || (SSI2001 != temp_SSI2001);
i = i || (GAMEBLASTER != temp_GAMEBLASTER);
@@ -261,6 +267,8 @@ static void win_settings_save(void)
{
int i = 0;
resetpchard_close();
/* Machine category */
model = temp_model;
romset = model_getromset();
@@ -268,6 +276,8 @@ static void win_settings_save(void)
cpu_waitstates = temp_wait_states;
cpu = temp_cpu;
mem_size = temp_mem_size;
memset(nvr_path, 0, sizeof(nvr_path));
wcscpy(nvr_path, temp_nvr_path);
cpu_use_dynarec = temp_dynarec;
enable_external_fpu = temp_fpu;
enable_sync = temp_sync;
@@ -283,7 +293,7 @@ static void win_settings_save(void)
/* Sound category */
sound_card_current = temp_sound_card;
midi_id = temp_midi_id;
midi_device_current = temp_midi_device;
mpu401_standalone_enable = temp_mpu401;
SSI2001 = temp_SSI2001;
GAMEBLASTER = temp_GAMEBLASTER;
@@ -327,7 +337,7 @@ static void win_settings_save(void)
sound_realloc_buffers();
resetpchard();
resetpchard_init();
cpu_set();
@@ -493,7 +503,7 @@ static void win_settings_machine_recalc_model(HWND hdlg)
accel.nSec = 0;
accel.nInc = models[romstomodel[temp_romset]].ram_granularity;
SendMessage(h, UDM_SETACCEL, 1, (LPARAM)&accel);
if (!(models[romstomodel[temp_romset]].flags & MODEL_AT))
if (!(models[romstomodel[temp_romset]].flags & MODEL_AT) || (models[romstomodel[temp_romset]].ram_granularity >= 128))
{
SendMessage(h, UDM_SETPOS, 0, temp_mem_size);
h = GetDlgItem(hdlg, IDC_TEXT_MB);
@@ -517,6 +527,7 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w
int d = 0;
LPTSTR lptsTemp;
char *stransi;
wchar_t *p;
switch (message)
{
@@ -568,6 +579,9 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w
win_settings_machine_recalc_model(hdlg);
h = GetDlgItem(hdlg, IDC_EDIT_NVR_PATH);
SendMessage(h, WM_SETTEXT, 0, (LPARAM) temp_nvr_path);
free(lptsTemp);
return TRUE;
@@ -609,6 +623,24 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w
deviceconfig_open(hdlg, (void *)model_getdevice(temp_model));
break;
case IDC_BUTTON_NVR_PATH:
p = BrowseFolder(temp_nvr_path, win_language_get_string_from_id(IDS_2225));
if (wcscmp(p, L""))
{
memset(temp_nvr_path, 0, sizeof(temp_nvr_path));
wcscpy(temp_nvr_path, p);
if (temp_nvr_path[wcslen(temp_nvr_path) - 1] == L'/')
{
temp_nvr_path[wcslen(temp_nvr_path) - 1] = L'\\';
}
else if (temp_nvr_path[wcslen(temp_nvr_path) - 1] != L'\\')
{
temp_nvr_path[wcslen(temp_nvr_path)] = L'\\';
}
h = GetDlgItem(hdlg, IDC_EDIT_NVR_PATH);
SendMessage(h, WM_SETTEXT, 0, (LPARAM) temp_nvr_path);
}
break;
}
return FALSE;
@@ -892,7 +924,10 @@ static BOOL CALLBACK win_settings_input_proc(HWND hdlg, UINT message, WPARAM wPa
case 6: /* MouseSystems */
str_id = IDS_2140;
break;
case 7: /* Genius Bus */
case 7: /* Logitech Serial */
str_id = IDS_2224;
break;
case 8: /* Genius Bus */
str_id = IDS_2161;
break;
}
@@ -1114,8 +1149,6 @@ int find_irq_in_array(int irq, int def)
}
static char midi_dev_name_buf[512];
int mpu401_present(void)
{
char *n;
@@ -1134,9 +1167,10 @@ int mpu401_present(void)
int mpu401_standalone_allow(void)
{
char *n;
char *n, *md;
n = sound_card_get_internal_name(temp_sound_card);
md = midi_device_get_internal_name(temp_midi_device);
if (n != NULL)
{
if (!strcmp(n, "sb16") || !strcmp(n, "sbawe32"))
@@ -1145,6 +1179,14 @@ int mpu401_standalone_allow(void)
}
}
if (md != NULL)
{
if (!strcmp(md, "none"))
{
return 0;
}
}
return 1;
}
@@ -1154,8 +1196,8 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
int c = 0;
int d = 0;
LPTSTR lptsTemp;
device_t *sound_dev;
int num = 0;
device_t *sound_dev, *midi_dev;
char *s;
switch (message)
{
@@ -1166,7 +1208,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
c = d = 0;
while (1)
{
char *s = sound_card_getname(c);
s = sound_card_getname(c);
if (!s[0])
{
@@ -1210,15 +1252,50 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
}
h = GetDlgItem(hdlg, IDC_COMBO_MIDI);
num = midi_get_num_devs();
for (c = 0; c < num; c++)
c = d = 0;
while (1)
{
memset(midi_dev_name_buf, 0, 512);
midi_get_dev_name(c, midi_dev_name_buf);
mbstowcs(lptsTemp, midi_dev_name_buf, strlen(midi_dev_name_buf) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
if (c == temp_midi_id)
SendMessage(h, CB_SETCURSEL, c, 0);
s = midi_device_getname(c);
if (!s[0])
{
break;
}
settings_midi_to_list[c] = d;
if (midi_device_available(c))
{
midi_dev = midi_device_getdevice(c);
if (!midi_dev || (midi_dev->flags & DEVICE_MCA) == (models[temp_model].flags & MODEL_MCA))
{
if (c == 0)
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(IDS_2152));
}
else
{
mbstowcs(lptsTemp, s, strlen(s) + 1);
SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp);
}
settings_list_to_midi[d] = c;
d++;
}
}
c++;
}
SendMessage(h, CB_SETCURSEL, settings_sound_to_list[temp_midi_device], 0);
h = GetDlgItem(hdlg, IDC_CONFIGURE_MIDI);
if (midi_device_has_config(temp_midi_device))
{
EnableWindow(h, TRUE);
}
else
{
EnableWindow(h, FALSE);
}
EnableWindow(h, mpu401_present() ? TRUE : FALSE);
@@ -1251,13 +1328,6 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_CONFIGURE_SND:
h = GetDlgItem(hdlg, IDC_COMBO_SOUND);
temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)sound_card_getdevice(temp_sound_card));
break;
case IDC_COMBO_SOUND:
h = GetDlgItem(hdlg, IDC_COMBO_SOUND);
temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
@@ -1276,6 +1346,38 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
EnableWindow(h, mpu401_present() ? TRUE : FALSE);
break;
case IDC_CONFIGURE_SND:
h = GetDlgItem(hdlg, IDC_COMBO_SOUND);
temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)sound_card_getdevice(temp_sound_card));
break;
case IDC_COMBO_MIDI:
h = GetDlgItem(hdlg, IDC_COMBO_MIDI);
temp_midi_device = settings_list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_CONFIGURE_MIDI);
if (midi_device_has_config(temp_midi_device))
{
EnableWindow(h, TRUE);
}
else
{
EnableWindow(h, FALSE);
}
h = GetDlgItem(hdlg, IDC_COMBO_MIDI);
EnableWindow(h, mpu401_present() ? TRUE : FALSE);
break;
case IDC_CONFIGURE_MIDI:
h = GetDlgItem(hdlg, IDC_COMBO_MIDI);
temp_midi_device = settings_list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)midi_device_getdevice(temp_midi_device));
break;
case IDC_CHECK_MPU401:
h = GetDlgItem(hdlg, IDC_CHECK_MPU401);
temp_mpu401 = SendMessage(h, BM_GETCHECK, 0, 0);
@@ -1298,7 +1400,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_COMBO_MIDI);
temp_midi_id = SendMessage(h, CB_GETCURSEL, 0, 0);
temp_midi_device = settings_list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)];
h = GetDlgItem(hdlg, IDC_CHECK_MPU401);
temp_mpu401 = SendMessage(h, BM_GETCHECK, 0, 0);
@@ -4185,12 +4287,15 @@ static BOOL CALLBACK win_settings_main_proc(HWND hdlg, UINT message, WPARAM wPar
win_settings_main_image_list_init(h);
win_settings_main_insert_categories(h);
ListView_SetItemState(h, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
/* Leave this commented out until we do localization. */
#if 0
h = GetDlgItem(hdlg, IDC_COMBO_LANG); /* This is currently disabled, I am going to add localization options in the future. */
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
h = GetDlgItem(hdlg, IDS_LANG_ENUS); /*was:2047 !*/
EnableWindow(h, FALSE);
ShowWindow(h, SW_HIDE);
#endif
return TRUE;
case WM_NOTIFY:
if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_SETTINGSCATLIST))