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

@@ -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;
}