[hatari-devel] ikbd overrun when using midi (Bad Mood for Falcon) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
Hi
as discussed on atari-forum.com, the game Bad Mood by DML shows some
error in the sequence of received ikbd bytes, resulting in loss of
synchronisation when processing multi-bytes packets (when moving mouse
for example)
problem is not reproducible on real Falcon ; under Hatari it happens
when midi runs at the same time.
Looking at the code for both ikbd and midi IRQ, I might have an idea of
what is causing this.
Eero, as you managed to reproduce the bug on Hatari, can you try the
following patch with Bad Mood latest binary and see if any hang in Bad
Mood happens after printing those debug lines ""error clearing mfp irq" ?
It's possible some lines are printed and bad mood doesn't hang, but I
think than when bad mood hangs this error line should be printed just
before.
Nicolas
diff --git a/src/acia.c b/src/acia.c
index 7e429475..f449126b 100644
--- a/src/acia.c
+++ b/src/acia.c
@@ -162,6 +162,7 @@ const char ACIA_fileid[] = "Hatari acia.c";
#include "clocks_timings.h"
#include "mfp.h"
#include "video.h"
+#include "midi.h"
#define ACIA_SR_BIT_RDRF 0x01 /* Receive Data Register Full */
@@ -382,6 +383,8 @@ static void ACIA_Set_Line_IRQ_MFP ( int bit )
else
{
MFP_GPIP_Set_Line_Input ( pMFP_Main , MFP_GPIP_LINE_ACIA , MFP_GPIP_STATE_HIGH );
+if ( MidiStatusRegister & ACIA_SR_BIT_IRQ )
+ fprintf ( stderr , "error clearing mfp irq for acia but midi irq is still set\n" );
}
}
diff --git a/src/includes/midi.h b/src/includes/midi.h
index 48a85699..7cb37afa 100644
--- a/src/includes/midi.h
+++ b/src/includes/midi.h
@@ -23,4 +23,6 @@ extern void Midi_InterruptHandler_Update(void);
extern const char* Midi_Host_GetPortName(const char *name, int offset, bool forInput);
#endif
+extern uint8_t MidiStatusRegister;
+
#endif
diff --git a/src/midi.c b/src/midi.c
index 35455415..d4bee2d0 100644
--- a/src/midi.c
+++ b/src/midi.c
@@ -48,7 +48,7 @@ const char Midi_fileid[] = "Hatari midi.c";
#define MIDI_TRANSFER_BYTE_CYCLE (MIDI_TRANSFER_BIT_CYCLE * 10)
static uint8_t MidiControlRegister;
-static uint8_t MidiStatusRegister;
+uint8_t MidiStatusRegister;
static uint8_t nRxDataByte;
static uint64_t TDR_Write_Time; /* Time of the last write in TDR fffc06 */
static uint64_t TDR_Empty_Time; /* Time when TDR will be empty after a write to fffc06 (ie when TDR is transferred to TSR) */
@@ -169,6 +169,8 @@ static void MIDI_UpdateIRQ ( void )
/* Clear interrupt request by setting GPIP to high/1 */
MFP_GPIP_Set_Line_Input ( pMFP_Main , MFP_GPIP_LINE_ACIA , MFP_GPIP_STATE_HIGH );
MidiStatusRegister &= ~ACIA_SR_INTERRUPT_REQUEST;
+if ( pACIA_IKBD->SR & ACIA_SR_INTERRUPT_REQUEST )
+ fprintf ( stderr , "error clearing mfp irq for midi but acia irq is still set\n" );
}
}
}