Assorted MIDI and MPU-401 intelligent mode fixes, fixes #4419.

This commit is contained in:
OBattler
2024-08-04 05:13:24 +02:00
parent 61e6052a9e
commit 6979b6a6c0
5 changed files with 486 additions and 524 deletions

View File

@@ -32,6 +32,7 @@ typedef struct midi_device_t {
void (*play_sysex)(uint8_t *sysex, unsigned int len);
void (*play_msg)(uint8_t *msg);
void (*poll)(void);
void (*reset)(void);
int (*write)(uint8_t val);
} midi_device_t;
@@ -77,6 +78,7 @@ extern void midi_raw_out_thru_rt_byte(uint8_t val);
extern void midi_raw_out_byte(uint8_t val);
extern void midi_clear_buffer(void);
extern void midi_poll(void);
extern void midi_reset(void);
extern void midi_in_handler(int set, void (*msg)(void *priv, uint8_t *msg, uint32_t len), int (*sysex)(void *priv, uint8_t *buffer, uint32_t len, int abort), void *priv);
extern void midi_in_handlers_clear(void);

View File

@@ -26,9 +26,9 @@
#define MPU401_VERSION 0x15
#define MPU401_REVISION 0x01
#define MPU401_QUEUE 1024
#define MPU401_QUEUE 32
#define MPU401_INPUT_QUEUE 1024
#define MPU401_TIMECONSTANT (60000000 / 1000.0f)
#define MPU401_TIMECONSTANT (60000000.0 / 1000.0)
#define MPU401_RESETBUSY 27.0f
/*helpers*/
@@ -89,7 +89,7 @@ typedef struct mpu_t {
uint32_t ch_toref[16];
struct track {
int counter;
uint8_t value[3];
uint8_t value[8];
uint8_t sys_val;
uint8_t vlength;
uint8_t length;
@@ -106,7 +106,6 @@ typedef struct mpu_t {
int wsm;
int wsd_start;
int run_irq;
int irq_pending;
int track_req;
int send_now;
int eoi_scheduled;
@@ -116,9 +115,11 @@ typedef struct mpu_t {
int sysex_in_finished;
int rec_copy;
RecState rec;
uint8_t irq_pending;
uint8_t tmask;
uint8_t cmask;
uint8_t amask;
uint8_t queued_eois;
uint8_t last_rtcmd;
uint16_t midi_mask;
uint16_t req_mask;

View File

@@ -341,7 +341,7 @@ midi_raw_out_byte(uint8_t val)
else if ((midi_out->midi_sysex_data[5] == 0x10) && (midi_out->midi_sysex_data[6] == 0x00) && (midi_out->midi_sysex_data[7] == 0x01))
midi_out->midi_sysex_delay = 30; /* Dark Sun 1 */
else
midi_out->midi_sysex_delay = (unsigned int) (((float) (midi_out->midi_pos) * 1.25f) * 1000.0f / 3125.0f) + 2;
midi_out->midi_sysex_delay = (unsigned int) (((double) (midi_out->midi_pos) * 1.25) / 3.125) + 2;
midi_out->midi_sysex_start = plat_get_ticks();
}
@@ -584,3 +584,10 @@ midi_in_sysex(uint8_t *buffer, uint32_t len)
break;
}
}
void
midi_reset(void)
{
if (midi_out && midi_out->m_out_device && midi_out->m_out_device->reset)
midi_out->m_out_device->reset();
}

File diff suppressed because it is too large Load Diff

View File

@@ -442,7 +442,7 @@ sb_dsp_set_mpu(sb_dsp_t *dsp, mpu_t *mpu)
{
dsp->mpu = mpu;
if (mpu != NULL)
if (IS_NOT_ESS(dsp) && (mpu != NULL))
mpu401_irq_attach(mpu, sb_dsp_irq_update, sb_dsp_irq_pending, dsp);
}