Skip to content

Commit

Permalink
Use the faster indexed matching for PUP. Fixed crash. (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner authored Mar 29, 2024
1 parent 7c7fe99 commit 3f96b5d
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion platforms/android/arm64-v8a/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

if [[ $(uname) == "Linux" ]]; then
NUM_PROCS=$(nproc)
Expand Down
2 changes: 1 addition & 1 deletion platforms/ios/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

NUM_PROCS=$(sysctl -n hw.ncpu)

Expand Down
2 changes: 1 addition & 1 deletion platforms/linux/aarch64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

NUM_PROCS=$(nproc)

Expand Down
2 changes: 1 addition & 1 deletion platforms/linux/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

NUM_PROCS=$(nproc)

Expand Down
2 changes: 1 addition & 1 deletion platforms/macos/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

NUM_PROCS=$(sysctl -n hw.ncpu)

Expand Down
2 changes: 1 addition & 1 deletion platforms/macos/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

NUM_PROCS=$(sysctl -n hw.ncpu)

Expand Down
2 changes: 1 addition & 1 deletion platforms/tvos/arm64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

NUM_PROCS=$(sysctl -n hw.ncpu)

Expand Down
2 changes: 1 addition & 1 deletion platforms/win/x64/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

echo "Building libraries..."
echo " CARGS_SHA: ${CARGS_SHA}"
Expand Down
2 changes: 1 addition & 1 deletion platforms/win/x86/external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CARGS_SHA=5949a20a926e902931de4a32adaad9f19c76f251
LIBZEDMD_SHA=42d95ed6f1fe2065ecbd247502d177d7e5eb7e4c
LIBSERUM_SHA=b69d2b436bc93570a2e7e78d0946cd3c43f7aed5
SOCKPP_SHA=e6c4688a576d95f42dd7628cefe68092f6c5cd0f
LIBPUPDMD_SHA=63cae52ccae975fb509f7f992a5503be43b08456
LIBPUPDMD_SHA=611ff0afcb051038cda46c8c6c68f9e9904d91ea

echo "Building libraries..."
echo " CARGS_SHA: ${CARGS_SHA}"
Expand Down
28 changes: 18 additions & 10 deletions src/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ DMD::DMD()
m_pAlphaNumeric = new AlphaNumeric();
m_pSerum = nullptr;
m_pZeDMD = nullptr;
m_pPupDMD = nullptr;
m_pZeDMDThread = nullptr;
m_pLevelDMDThread = nullptr;
m_pRGB24DMDThread = nullptr;
m_pConsoleDMDThread = nullptr;
m_pDumpDMDTxtThread = nullptr;
m_pDumpDMDRawThread = nullptr;
m_pPupDMDThread = nullptr;
#if !( \
(defined(__APPLE__) && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_TV) && TARGET_OS_TV))) || \
defined(__ANDROID__))
Expand Down Expand Up @@ -1325,19 +1325,27 @@ void DMD::PupDMDThread()
// @todo scaling/centering 128x16 and 192x64 or check how PUP deals with it.
if (m_pPupDMD && m_pUpdateBufferQueue[bufferPosition]->width == 128 &&
m_pUpdateBufferQueue[bufferPosition]->height == 32 && m_pUpdateBufferQueue[bufferPosition]->hasData &&
m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data)
m_pUpdateBufferQueue[bufferPosition]->mode == Mode::Data && m_pUpdateBufferQueue[bufferPosition]->depth != 24)
{
int length = m_pUpdateBufferQueue[bufferPosition]->width * m_pUpdateBufferQueue[bufferPosition]->height;
UpdatePalette(palette, m_pUpdateBufferQueue[bufferPosition]->depth, m_pUpdateBufferQueue[bufferPosition]->r,
m_pUpdateBufferQueue[bufferPosition]->g, m_pUpdateBufferQueue[bufferPosition]->b);
uint16_t triggerID = 0;
if (Config::GetInstance()->IsPupExactColorMatch())
{
int length = m_pUpdateBufferQueue[bufferPosition]->width * m_pUpdateBufferQueue[bufferPosition]->height;
UpdatePalette(palette, m_pUpdateBufferQueue[bufferPosition]->depth, m_pUpdateBufferQueue[bufferPosition]->r,
m_pUpdateBufferQueue[bufferPosition]->g, m_pUpdateBufferQueue[bufferPosition]->b);

uint8_t frame[128 * 32 * 3];
for (int i = 0; i < length; i++)
uint8_t frame[128 * 32 * 3];
for (int i = 0; i < length; i++)
{
int pos = m_pUpdateBufferQueue[bufferPosition]->data[i] * 3;
memcpy(&frame[i * 3], &palette[pos], 3);
}
triggerID = m_pPupDMD->Match(frame, true);
}
else
{
int pos = m_pUpdateBufferQueue[bufferPosition]->data[i] * 3;
memcpy(&frame[i * 3], &palette[pos], 3);
triggerID = m_pPupDMD->MatchIndexed(m_pUpdateBufferQueue[bufferPosition]->data);
}
uint16_t triggerID = m_pPupDMD->Match(frame, Config::GetInstance()->IsPupExactColorMatch());

if (triggerID > 0) handleTrigger(triggerID);
}
Expand Down

0 comments on commit 3f96b5d

Please sign in to comment.