From 1617763a92eadba98ba992046b67c97107ed47f6 Mon Sep 17 00:00:00 2001 From: probonopd Date: Thu, 24 Feb 2022 21:28:05 +0100 Subject: [PATCH] Output MIDI messages for debugging and development https://github.com/probonopd/MiniDexed/issues/8#issuecomment-1050231502 Closes #8 Thanks @rsta2 --- src/circle_stdlib_app.h | 11 +++++++---- src/kernel.cpp | 2 ++ src/minidexed.cpp | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/circle_stdlib_app.h b/src/circle_stdlib_app.h index 789a1fb..170a39d 100644 --- a/src/circle_stdlib_app.h +++ b/src/circle_stdlib_app.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -94,7 +95,8 @@ class CStdlibAppScreen : public CStdlibApp public: CStdlibAppScreen(const char *kernel) : CStdlibApp (kernel), - mScreen (mOptions.GetWidth (), mOptions.GetHeight ()), + mScreenUnbuffered (mOptions.GetWidth (), mOptions.GetHeight ()), + mScreen (&mScreenUnbuffered), mTimer (&mInterrupt), mLogger (mOptions.GetLogLevel (), &mTimer) { @@ -107,7 +109,7 @@ public: return false; } - if (!mScreen.Initialize ()) + if (!mScreenUnbuffered.Initialize ()) { return false; } @@ -133,8 +135,9 @@ public: } protected: - CScreenDevice mScreen; + CScreenDevice mScreenUnbuffered; //CSerialDevice mSerial; + CWriteBufferDevice mScreen; CTimer mTimer; CLogger mLogger; }; @@ -161,7 +164,7 @@ public: mUSBHCI (&mInterrupt, &mTimer, TRUE), mEMMC (&mInterrupt, &mTimer, &mActLED), #if !defined(__aarch64__) || !defined(LEAVE_QEMU_ON_HALT) - mConsole (0, TRUE) + mConsole (&mScreen, TRUE) #else mConsole (&mScreen) #endif diff --git a/src/kernel.cpp b/src/kernel.cpp index 674d124..8170972 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -83,6 +83,8 @@ CStdlibApp::TShutdownMode CKernel::Run (void) boolean bUpdated = mUSBHCI.UpdatePlugAndPlay (); m_pDexed->Process(bUpdated); + + mScreen.Update (); } return ShutdownHalt; diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 572fd2b..272e2e3 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -3,6 +3,9 @@ // #include "minidexed.h" #include +#include + +#define MIDI_DUMP #define MIDI_NOTE_OFF 0b1000 #define MIDI_NOTE_ON 0b1001 @@ -107,6 +110,25 @@ void CMiniDexed::MIDIPacketHandler (unsigned nCable, u8 *pPacket, unsigned nLeng // The packet contents are just normal MIDI data - see // https://www.midi.org/specifications/item/table-1-summary-of-midi-message +#ifdef MIDI_DUMP + switch (nLength) + { + case 1: + printf ("MIDI %u: %02X\n", nCable, (unsigned) pPacket[0]); + break; + + case 2: + printf ("MIDI %u: %02X %02X\n", nCable, + (unsigned) pPacket[0], (unsigned) pPacket[1]); + break; + + case 3: + printf ("MIDI %u: %02X %02X %02X\n", nCable, + (unsigned) pPacket[0], (unsigned) pPacket[1], (unsigned) pPacket[2]); + break; + } +#endif + if (nLength < 3) { return;