Added preliminary MPU-401 emulation (UART mode only) for SB16. Currently outputs to default Windows MIDI device. This allows Windows 3.x SB16 drivers to work.
This commit is contained in:
parent
f822488656
commit
b9062a1d0c
7 changed files with 152 additions and 15 deletions
62
src/win-midi.c
Normal file
62
src/win-midi.c
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include "ibm.h"
|
||||
#include "plat-midi.h"
|
||||
|
||||
static int midi_id;
|
||||
static HMIDIOUT midi_out_device = NULL;
|
||||
|
||||
void midi_close();
|
||||
|
||||
void midi_init()
|
||||
{
|
||||
int c;
|
||||
int n;
|
||||
MIDIOUTCAPS ocaps;
|
||||
MMRESULT hr;
|
||||
|
||||
midi_id=0;
|
||||
|
||||
hr = midiOutOpen(&midi_out_device, midi_id, 0,
|
||||
0, CALLBACK_NULL);
|
||||
if (hr != MMSYSERR_NOERROR) {
|
||||
printf("midiOutOpen error - %08X\n",hr);
|
||||
return;
|
||||
}
|
||||
|
||||
midiOutReset(midi_out_device);
|
||||
}
|
||||
|
||||
void midi_close()
|
||||
{
|
||||
if (midi_out_device != NULL)
|
||||
{
|
||||
midiOutReset(midi_out_device);
|
||||
midiOutClose(midi_out_device);
|
||||
midi_out_device = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int midi_pos, midi_len;
|
||||
static uint32_t midi_command;
|
||||
static int midi_lengths[8] = {3, 3, 3, 3, 2, 2, 3, 0};
|
||||
|
||||
void midi_out(uint8_t val)
|
||||
{
|
||||
if (val & 0x80)
|
||||
{
|
||||
midi_pos = 0;
|
||||
midi_len = midi_lengths[(val >> 4) & 7];
|
||||
midi_command = 0;
|
||||
}
|
||||
|
||||
if (midi_len)
|
||||
{
|
||||
midi_command |= (val << (midi_pos * 8));
|
||||
|
||||
midi_pos++;
|
||||
|
||||
if (midi_pos == midi_len)
|
||||
midiOutShortMsg(midi_out_device, midi_command);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue