Ported the MPU401 core of dosbox-x to 86box, intelligent mode works (SB16 and up only)

Renamed the mpu401 source files to be about generic mpu401 handling as it is no longer UART specific.
This commit is contained in:
TC1995
2017-05-09 21:42:08 +02:00
parent d3b39f61bd
commit 7f509c9850
4 changed files with 85 additions and 74 deletions

View File

@@ -144,7 +144,7 @@ SNDOBJ = sound.o \
snd_adlib.o snd_adlibgold.o snd_ad1848.o \
snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \
snd_emu8k.o snd_gus.o snd_opl.o \
snd_mpu401_uart.o snd_pas16.o snd_resid.o \
snd_mpu401.o snd_pas16.o snd_resid.o \
snd_sn76489.o snd_ssi2001.o snd_wss.o \
snd_ym7128.o
VIDOBJ = video.o \

View File

@@ -1,60 +0,0 @@
#include "../ibm.h"
#include "../io.h"
#include "../plat-midi.h"
#include "snd_mpu401_uart.h"
enum
{
STATUS_OUTPUT_NOT_READY = 0x40,
STATUS_INPUT_NOT_READY = 0x80
};
static void mpu401_uart_write(uint16_t addr, uint8_t val, void *p)
{
mpu401_uart_t *mpu = (mpu401_uart_t *)p;
if (addr & 1) /*Command*/
{
switch (val)
{
case 0xff: /*Reset*/
mpu->rx_data = 0xfe; /*Acknowledge*/
mpu->status = 0;
mpu->uart_mode = 0;
break;
case 0x3f: /*Enter UART mode*/
mpu->rx_data = 0xfe; /*Acknowledge*/
mpu->status = 0;
mpu->uart_mode = 1;
break;
}
return;
}
/*Data*/
if (mpu->uart_mode)
midi_write(val);
}
static uint8_t mpu401_uart_read(uint16_t addr, void *p)
{
mpu401_uart_t *mpu = (mpu401_uart_t *)p;
if (addr & 1) /*Status*/
return mpu->status;
/*Data*/
mpu->status |= STATUS_INPUT_NOT_READY;
return mpu->rx_data;
}
void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr)
{
mpu->status = STATUS_INPUT_NOT_READY;
mpu->uart_mode = 0;
io_sethandler(addr, 0x0002, mpu401_uart_read, NULL, NULL, mpu401_uart_write, NULL, NULL, mpu);
}

View File

@@ -1,9 +0,0 @@
typedef struct mpu401_uart_t
{
uint8_t status;
uint8_t rx_data;
int uart_mode;
} mpu401_uart_t;
void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr);

View File

@@ -7,7 +7,7 @@
#include "../device.h"
#include "sound.h"
#include "snd_emu8k.h"
#include "snd_mpu401_uart.h"
#include "snd_mpu401.h"
#include "snd_opl.h"
#include "snd_sb.h"
#include "snd_sb_dsp.h"
@@ -33,7 +33,7 @@ typedef struct sb_t
opl_t opl;
sb_dsp_t dsp;
sb_mixer_t mixer;
mpu401_uart_t mpu;
mpu_t mpu;
emu8k_t emu8k;
int pos;
@@ -631,7 +631,7 @@ void *sb_16_init()
io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
io_sethandler(addr + 4, 0x0002, sb_16_mixer_read, NULL, NULL, sb_16_mixer_write, NULL, NULL, sb);
sound_add_handler(sb_get_buffer_opl3, sb);
mpu401_uart_init(&sb->mpu, device_get_config_int("addr401"));
mpu401_init(&sb->mpu, device_get_config_int("addr401"), device_get_config_int("irq401"), device_get_config_int("mode401"));
sb->mixer.regs[0x30] = 31 << 3;
sb->mixer.regs[0x31] = 31 << 3;
@@ -677,7 +677,7 @@ void *sb_awe32_init()
io_sethandler(0x0388, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
io_sethandler(addr + 4, 0x0002, sb_16_mixer_read, NULL, NULL, sb_16_mixer_write, NULL, NULL, sb);
sound_add_handler(sb_get_buffer_emu8k, sb);
mpu401_uart_init(&sb->mpu, device_get_config_int("addr401"));
mpu401_init(&sb->mpu, device_get_config_int("addr401"), device_get_config_int("irq401"), device_get_config_int("mode401"));
emu8k_init(&sb->emu8k, onboard_ram);
sb->mixer.regs[0x30] = 31 << 3;
@@ -934,6 +934,32 @@ static device_config_t sb_16_config[] =
}
}
},
{
"irq401", "MPU-401 IRQ", CONFIG_SELECTION, "", 9,
{
{
"IRQ 9", 9
},
{
"IRQ 3", 3
},
{
"IRQ 4", 4
},
{
"IRQ 5", 5
},
{
"IRQ 7", 7
},
{
"IRQ 10", 10
},
{
""
}
}
},
{
"dma", "Low DMA channel", CONFIG_SELECTION, "", 1,
{
@@ -971,6 +997,20 @@ static device_config_t sb_16_config[] =
{
"midi", "MIDI out device", CONFIG_MIDI, "", 0
},
{
"mode", "MPU-401 mode", CONFIG_SELECTION, "", 1,
{
{
"UART", M_UART
},
{
"Intelligent", M_INTELLIGENT
},
{
""
}
}
},
{
"", "", -1
}
@@ -1032,6 +1072,32 @@ static device_config_t sb_awe32_config[] =
}
}
},
{
"irq401", "MPU-401 IRQ", CONFIG_SELECTION, "", 2,
{
{
"IRQ 2", 2
},
{
"IRQ 3", 3
},
{
"IRQ 4", 4
},
{
"IRQ 5", 5
},
{
"IRQ 7", 7
},
{
"IRQ 10", 10
},
{
""
}
}
},
{
"dma", "Low DMA channel", CONFIG_SELECTION, "", 1,
{
@@ -1069,6 +1135,20 @@ static device_config_t sb_awe32_config[] =
{
"midi", "MIDI out device", CONFIG_MIDI, "", 0
},
{
"mode", "MPU-401 mode", CONFIG_SELECTION, "", 1,
{
{
"UART", M_UART
},
{
"Intelligent", M_INTELLIGENT
},
{
""
}
}
},
{
"onboard_ram", "Onboard RAM", CONFIG_SELECTION, "", 512,
{