From 5c0b03c10c59ebcd522bb1e8afdd2674101b6772 Mon Sep 17 00:00:00 2001 From: ripsaw8080 Date: Sun, 10 Sep 2017 11:25:45 +0000 Subject: [PATCH] Process repeated reset commands without delay. Fixes MPU detection in several games. Correct ACK for reset: entirely absent with dumb setting (mpu401=uart), and also absent when returning to intelligent mode from UART mode. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4047 --- src/hardware/mpu401.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/hardware/mpu401.cpp b/src/hardware/mpu401.cpp index 1eff7ec3..a5aec2a6 100644 --- a/src/hardware/mpu401.cpp +++ b/src/hardware/mpu401.cpp @@ -122,7 +122,15 @@ static Bitu MPU401_ReadStatus(Bitu port,Bitu iolen) { } static void MPU401_WriteCommand(Bitu port,Bitu val,Bitu iolen) { - if (mpu.state.reset) {mpu.state.cmd_pending=val+1;return;} + if (mpu.mode==M_UART && val!=0xff) return; + if (mpu.state.reset) { + if (mpu.state.cmd_pending || (val!=0x3f && val!=0xff)) { + mpu.state.cmd_pending=val+1; + return; + } + PIC_RemoveEvents(MPU401_ResetDone); + mpu.state.reset=false; + } if (val<=0x2f) { switch (val&3) { /* MIDI stop, start, continue */ case 1: {MIDI_RawOutByte(0xfc);break;} @@ -246,8 +254,11 @@ static void MPU401_WriteCommand(Bitu port,Bitu val,Bitu iolen) { LOG(LOG_MISC,LOG_NORMAL)("MPU-401:Reset %X",val); PIC_AddEvent(MPU401_ResetDone,MPU401_RESETBUSY); mpu.state.reset=true; + if (mpu.mode==M_UART) { + MPU401_Reset(); + return; //do not send ack in UART mode + } MPU401_Reset(); - if (mpu.mode==M_UART) return;//do not send ack in UART mode break; case 0x3f: /* UART mode */ LOG(LOG_MISC,LOG_NORMAL)("MPU-401:Set UART mode %X",val); @@ -537,7 +548,6 @@ static void MPU401_Event(Bitu val) { } if (!mpu.state.irq_pending && mpu.state.req_mask) MPU401_EOIHandler(); next_event: - PIC_RemoveEvents(MPU401_Event); Bitu new_time; if ((new_time=mpu.clock.tempo*mpu.clock.timebase)==0) return; PIC_AddEvent(MPU401_Event,MPU401_TIMECONSTANT/new_time);