From 188e3e71bc2b323dddf6f0fb2a1d757593477e6f Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Fri, 15 Mar 2024 19:05:06 +0100 Subject: [PATCH] Fixed ZeDMD HD support and added a test (#21) --- include/DMDUtil/DMD.h | 3 ++- platforms/android/arm64-v8a/external.sh | 2 +- platforms/ios/arm64/external.sh | 2 +- platforms/linux/aarch64/external.sh | 2 +- platforms/linux/x64/external.sh | 2 +- platforms/macos/arm64/external.sh | 2 +- platforms/macos/x64/external.sh | 2 +- platforms/tvos/arm64/external.sh | 2 +- platforms/win/x64/external.sh | 2 +- platforms/win/x86/external.sh | 2 +- src/DMD.cpp | 14 ++++++++++---- src/test.h | 25 ++++++++++++++++++++++--- 12 files changed, 43 insertions(+), 17 deletions(-) diff --git a/include/DMDUtil/DMD.h b/include/DMDUtil/DMD.h index 770cde3..b560852 100644 --- a/include/DMDUtil/DMD.h +++ b/include/DMDUtil/DMD.h @@ -102,7 +102,7 @@ class DMDUTILAPI DMD Mode mode = Mode::Data; // int uint16_t width = 0; uint16_t height = 0; - uint8_t buffered = 0; // 0 => unbuffered, 1 => buffered + uint8_t buffered = 0; // 0 => unbuffered, 1 => buffered uint8_t disconnectOthers = 0; // 0 => no, 1 => yes uint32_t length = 0; }; @@ -118,6 +118,7 @@ class DMDUTILAPI DMD void FindDisplays(); static bool IsFinding(); bool HasDisplay() const; + bool HasHDDisplay() const; void SetRomName(const char* name); void SetAltColorPath(const char* path); void DumpDMDTxt(); diff --git a/platforms/android/arm64-v8a/external.sh b/platforms/android/arm64-v8a/external.sh index 6af550d..e095397 100755 --- a/platforms/android/arm64-v8a/external.sh +++ b/platforms/android/arm64-v8a/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/ios/arm64/external.sh b/platforms/ios/arm64/external.sh index 3ecb4c4..b8122ac 100755 --- a/platforms/ios/arm64/external.sh +++ b/platforms/ios/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/linux/aarch64/external.sh b/platforms/linux/aarch64/external.sh index 1975be9..2c00f26 100755 --- a/platforms/linux/aarch64/external.sh +++ b/platforms/linux/aarch64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/linux/x64/external.sh b/platforms/linux/x64/external.sh index b104f0b..106f901 100755 --- a/platforms/linux/x64/external.sh +++ b/platforms/linux/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/macos/arm64/external.sh b/platforms/macos/arm64/external.sh index 2ebe7b1..5d6a34d 100755 --- a/platforms/macos/arm64/external.sh +++ b/platforms/macos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/macos/x64/external.sh b/platforms/macos/x64/external.sh index a89f6eb..e35051f 100755 --- a/platforms/macos/x64/external.sh +++ b/platforms/macos/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/tvos/arm64/external.sh b/platforms/tvos/arm64/external.sh index 3ee1501..8780c31 100755 --- a/platforms/tvos/arm64/external.sh +++ b/platforms/tvos/arm64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/win/x64/external.sh b/platforms/win/x64/external.sh index 177d7eb..99ac6ca 100755 --- a/platforms/win/x64/external.sh +++ b/platforms/win/x64/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/platforms/win/x86/external.sh b/platforms/win/x86/external.sh index 5220229..e5b7651 100755 --- a/platforms/win/x86/external.sh +++ b/platforms/win/x86/external.sh @@ -3,7 +3,7 @@ set -e CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251 -LIBZEDMD_SHA=08e98a858eb6e1394b4844bec7dd27c7c0d9a845 +LIBZEDMD_SHA=317070d7b5e344f58f966caccf1bc9c2979cb775 LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5 SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f diff --git a/src/DMD.cpp b/src/DMD.cpp index da5bf92..7760e05 100644 --- a/src/DMD.cpp +++ b/src/DMD.cpp @@ -174,6 +174,8 @@ bool DMD::HasDisplay() const #endif } +bool DMD::HasHDDisplay() const { return (m_pZeDMD != nullptr && m_pZeDMD->GetWidth() == 256); } + void DMD::SetRomName(const char* name) { strcpy(m_romName, name ? name : ""); } void DMD::SetAltColorPath(const char* path) { strcpy(m_altColorPath, path ? path : ""); } @@ -436,12 +438,11 @@ void DMD::FindDisplays() if (pZeDMD->Open()) { if (pConfig->IsZeDMDDebug()) pZeDMD->EnableDebug(); - if (pConfig->GetZeDMDRGBOrder() != -1) pZeDMD->SetRGBOrder(pConfig->GetZeDMDRGBOrder()); - if (pConfig->GetZeDMDBrightness() != -1) pZeDMD->SetBrightness(pConfig->GetZeDMDBrightness()); - if (pConfig->IsZeDMDSaveSettings()) pZeDMD->SaveSettings(); + pZeDMD->EnablePreDownscaling(); + pZeDMD->EnablePreUpscaling(); m_pZeDMDThread = new std::thread(&DMD::ZeDMDThread, this); } @@ -461,7 +462,8 @@ void DMD::FindDisplays() if (pConfig->IsPixelcade()) { - pPixelcadeDMD = PixelcadeDMD::Connect(pConfig->GetPixelcadeDevice(), pConfig->GetPixelcadeMatrix(), 128, 32); + pPixelcadeDMD = + PixelcadeDMD::Connect(pConfig->GetPixelcadeDevice(), pConfig->GetPixelcadeMatrix(), 128, 32); if (pPixelcadeDMD) m_pPixelcadeDMDThread = new std::thread(&DMD::PixelcadeDMDThread, this); } @@ -569,11 +571,15 @@ void DMD::ZeDMDThread() AdjustRGB24Depth(m_pUpdateBufferQueue[bufferPosition]->data, rgb24Data, width * height, palette, m_pUpdateBufferQueue[bufferPosition]->depth); + m_pZeDMD->DisablePreUpscaling(); m_pZeDMD->RenderRgb24(rgb24Data); + m_pZeDMD->EnablePreUpscaling(); } else if (m_pUpdateBufferQueue[bufferPosition]->mode == Mode::RGB16) { + m_pZeDMD->DisablePreUpscaling(); m_pZeDMD->RenderRgb565(m_pUpdateBufferQueue[bufferPosition]->segData); + m_pZeDMD->EnablePreUpscaling(); } else { diff --git a/src/test.h b/src/test.h index a18e72c..077676b 100644 --- a/src/test.h +++ b/src/test.h @@ -153,7 +153,7 @@ void run(DMDUtil::DMD* pDmd) } FILE* fileptr; - uint16_t size = width * height * 2; + uint16_t size = 256 * 64 * 2; uint8_t* buffer = (uint8_t*)malloc(size * sizeof(uint8_t)); uint16_t* rgb565 = (uint16_t*)malloc(size / 2 * sizeof(uint16_t)); char filename[28]; @@ -168,8 +168,27 @@ void run(DMDUtil::DMD* pDmd) fclose(fileptr); memcpy(rgb565, buffer, size); - pDmd->UpdateRGB16Data(rgb565, 128, 32); - std::this_thread::sleep_for(std::chrono::milliseconds(80)); + pDmd->UpdateRGB16Data(rgb565, width, height); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + if (pDmd->HasHDDisplay()) + { + width = 256; + height = 64; + for (int i = 1; i <= 100; i++) + { + snprintf(filename, 28, "test/rgb565_%dx%d/%04d.raw", width, height, i); + printf("Render raw: %s\n", filename); + fileptr = fopen(filename, "rb"); + if (!fileptr) continue; + fread(buffer, size, 1, fileptr); + fclose(fileptr); + + memcpy(rgb565, buffer, size); + pDmd->UpdateRGB16Data(rgb565, width, height); + std::this_thread::sleep_for(std::chrono::milliseconds(240)); + } } free(buffer);