Skip to content

Commit

Permalink
renamed PUP options (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner authored Mar 29, 2024
1 parent 110775f commit 9341124
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 48 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ Port = 6789
AltColor = 1
# Overwrite the AltColorPath sent by the client and set it to a fixed value.
AltColorPath =
# Set to 1 if PUP DMD frame matching should be used, 0 if not.
PUPCapture = 1
# Overwrite the PUPVideosPath sent by the client and set it to a fixed value.
PUPVideosPath =
# Set to 1 if PUP DMD frame matching should respect the exact colors, 0 if not.
PUPExactColorMatch = 0
[ZeDMD]
# Set to 1 if ZeDMD is attached.
Expand Down
10 changes: 5 additions & 5 deletions dmdserver.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ Port = 6789
AltColor = 1
# Overwrite the AltColorPath sent by the client and set it to a fixed value.
AltColorPath =
# Set to 1 if Pup DMD frame matching should be used, 0 if not.
Pup = 1
# Overwrite the PupPath sent by the client and set it to a fixed value.
PupPath =
# Set to 1 if PUP DMD frame matching should be used, 0 if not.
PUPCapture = 1
# Overwrite the PUPVideosPath sent by the client and set it to a fixed value.
PUPVideosPath =
# Set to 1 if PUP DMD frame matching should respect the exact colors, 0 if not.
PupExactColorMatch = 0
PUPExactColorMatch = 0

[ZeDMD]
# Set to 1 if ZeDMD is attached.
Expand Down
16 changes: 8 additions & 8 deletions include/DMDUtil/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ class DMDUTILAPI Config
void SetAltColor(bool altColor) { m_altColor = altColor; }
void SetAltColorPath(const char* path) { m_altColorPath = path; }
const char* GetAltColorPath() const { return m_altColorPath.c_str(); }
bool IsPup() const { return m_pup; }
void SetPup(bool pup) { m_pup = pup; }
void SetPupPath(const char* path) { m_pupPath = path; }
const char* GetPupPath() const { return m_pupPath.c_str(); }
bool IsPupExactColorMatch() const { return m_pupExactColorMatch; }
void SetPupExactColorMatch(bool exactColorMatch) { m_pupExactColorMatch = exactColorMatch; }
bool IsPUPCapture() const { return m_pupCapture; }
void SetPUPCapture(bool pupCapture) { m_pupCapture = pupCapture; }
void SetPUPVideosPath(const char* path) { m_pupVideosPath = path; }
const char* GetPUPVideosPath() const { return m_pupVideosPath.c_str(); }
bool IsPUPExactColorMatch() const { return m_pupExactColorMatch; }
void SetPUPExactColorMatch(bool exactColorMatch) { m_pupExactColorMatch = exactColorMatch; }
void SetIgnoreUnknownFramesTimeout(int framesTimeout) { m_framesTimeout = framesTimeout; }
void SetMaximumUnknownFramesToSkip(int framesToSkip) { m_framesToSkip = framesToSkip; }
int GetIgnoreUnknownFramesTimeout() { return m_framesTimeout; }
Expand Down Expand Up @@ -68,8 +68,8 @@ class DMDUTILAPI Config
static Config* m_pInstance;
bool m_altColor;
std::string m_altColorPath;
bool m_pup;
std::string m_pupPath;
bool m_pupCapture;
std::string m_pupVideosPath;
bool m_pupExactColorMatch;
int m_framesTimeout;
int m_framesToSkip;
Expand Down
8 changes: 4 additions & 4 deletions include/DMDUtil/DMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class DMDUTILAPI DMD
char header[6] = "Paths";
char name[DMDUTIL_MAX_NAME_SIZE] = {0};
char altColorPath[DMDUTIL_MAX_PATH_SIZE] = {0};
char pupPath[DMDUTIL_MAX_PATH_SIZE] = {0};
char pupVideosPath[DMDUTIL_MAX_PATH_SIZE] = {0};
};
#pragma pack(pop) // Reset to default packing

Expand All @@ -126,7 +126,7 @@ class DMDUTILAPI DMD
bool HasHDDisplay() const;
void SetRomName(const char* name);
void SetAltColorPath(const char* path);
void SetPupPath(const char* path);
void SetPUPVideosPath(const char* path);
void DumpDMDTxt();
void DumpDMDRaw();
LevelDMD* CreateLevelDMD(uint16_t width, uint16_t height, bool sam);
Expand Down Expand Up @@ -169,11 +169,11 @@ class DMDUTILAPI DMD
uint8_t m_updateBufferQueuePosition = 0;
char m_romName[DMDUTIL_MAX_NAME_SIZE] = {0};
char m_altColorPath[DMDUTIL_MAX_PATH_SIZE] = {0};
char m_pupPath[DMDUTIL_MAX_PATH_SIZE] = {0};
char m_pupVideosPath[DMDUTIL_MAX_PATH_SIZE] = {0};
AlphaNumeric* m_pAlphaNumeric;
Serum* m_pSerum;
ZeDMD* m_pZeDMD;
PUPDMD::DMD* m_pPupDMD;
PUPDMD::DMD* m_pPUPDMD;
std::vector<LevelDMD*> m_levelDMDs;
std::vector<RGB24DMD*> m_rgb24DMDs;
std::vector<ConsoleDMD*> m_consoleDMDs;
Expand Down
4 changes: 2 additions & 2 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Config::Config()
{
m_altColor = true;
m_altColorPath.clear();
m_pup = true;
m_pupPath.clear();
m_pupCapture = false;
m_pupVideosPath.clear();
m_pupExactColorMatch = false;
m_framesTimeout = 0;
m_framesToSkip = 0;
Expand Down
38 changes: 19 additions & 19 deletions src/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ DMD::DMD()
m_pAlphaNumeric = new AlphaNumeric();
m_pSerum = nullptr;
m_pZeDMD = nullptr;
m_pPupDMD = nullptr;
m_pPUPDMD = nullptr;
m_pZeDMDThread = nullptr;
m_pLevelDMDThread = nullptr;
m_pRGB24DMDThread = nullptr;
Expand Down Expand Up @@ -144,7 +144,7 @@ DMD::~DMD()
delete m_pAlphaNumeric;
delete m_pSerum;
delete m_pZeDMD;
delete m_pPupDMD;
delete m_pPUPDMD;
#if !( \
(defined(__APPLE__) && ((defined(TARGET_OS_IOS) && TARGET_OS_IOS) || (defined(TARGET_OS_TV) && TARGET_OS_TV))) || \
defined(__ANDROID__))
Expand Down Expand Up @@ -199,7 +199,7 @@ void DMD::SetRomName(const char* name) { strcpy(m_romName, name ? name : ""); }

void DMD::SetAltColorPath(const char* path) { strcpy(m_altColorPath, path ? path : ""); }

void DMD::SetPupPath(const char* path) { strcpy(m_pupPath, path ? path : ""); }
void DMD::SetPUPVideosPath(const char* path) { strcpy(m_pupVideosPath, path ? path : ""); }

void DMD::DumpDMDTxt() { m_pDumpDMDTxtThread = new std::thread(&DMD::DumpDMDTxtThread, this); }

Expand Down Expand Up @@ -337,7 +337,7 @@ void DMD::QueueUpdate(Update dmdUpdate, bool buffered)
PathsHeader pathsHeader;
strcpy(pathsHeader.name, m_romName);
strcpy(pathsHeader.altColorPath, m_altColorPath);
strcpy(pathsHeader.pupPath, m_pupPath);
strcpy(pathsHeader.pupVideosPath, m_pupVideosPath);
m_pDMDServerConnector->write_n(&pathsHeader, sizeof(PathsHeader));
m_pDMDServerConnector->write_n(&dmdUpdate, sizeof(Update));
}
Expand Down Expand Up @@ -1309,31 +1309,31 @@ void DMD::PupDMDThread()
{
strcpy(name, m_romName);

if (Config::GetInstance()->IsPup())
if (Config::GetInstance()->IsPUPCapture())
{
if (m_pPupDMD)
if (m_pPUPDMD)
{
delete (m_pPupDMD);
m_pPupDMD = nullptr;
delete (m_pPUPDMD);
m_pPUPDMD = nullptr;
}

if (name[0] != '\0')
{
if (m_pupPath[0] == '\0') strcpy(m_pupPath, Config::GetInstance()->GetPupPath());
m_pPupDMD = new PUPDMD::DMD();
m_pPupDMD->SetLogCallback(PUPDMDLogCallback, nullptr);
if (m_pupVideosPath[0] == '\0') strcpy(m_pupVideosPath, Config::GetInstance()->GetPUPVideosPath());
m_pPUPDMD = new PUPDMD::DMD();
m_pPUPDMD->SetLogCallback(PUPDMDLogCallback, nullptr);

if (!m_pPupDMD->Load(m_pupPath, m_romName))
if (!m_pPUPDMD->Load(m_pupVideosPath, m_romName))
{
delete (m_pPupDMD);
m_pPupDMD = nullptr;
delete (m_pPUPDMD);
m_pPUPDMD = nullptr;
}
}
}
}

// @todo scaling/centering 128x16 and 192x64 or check how PUP deals with it.
if (m_pPupDMD && m_pUpdateBufferQueue[bufferPosition]->width == 128 &&
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]->depth != 24)
{
Expand All @@ -1343,7 +1343,7 @@ void DMD::PupDMDThread()
memcpy(renderBuffer, m_pUpdateBufferQueue[bufferPosition]->data, length);

uint16_t triggerID = 0;
if (Config::GetInstance()->IsPupExactColorMatch())
if (Config::GetInstance()->IsPUPExactColorMatch())
{
UpdatePalette(palette, m_pUpdateBufferQueue[bufferPosition]->depth, m_pUpdateBufferQueue[bufferPosition]->r,
m_pUpdateBufferQueue[bufferPosition]->g, m_pUpdateBufferQueue[bufferPosition]->b);
Expand All @@ -1354,12 +1354,12 @@ void DMD::PupDMDThread()
uint16_t pos = renderBuffer[i] * 3;
memcpy(&pFrame[i * 3], &palette[pos], 3);
}
triggerID = m_pPupDMD->Match(pFrame, true);
triggerID = m_pPUPDMD->Match(pFrame, true);
free(pFrame);
}
else
{
triggerID = m_pPupDMD->MatchIndexed(renderBuffer);
triggerID = m_pPUPDMD->MatchIndexed(renderBuffer);
}

if (triggerID > 0) handleTrigger(triggerID);
Expand All @@ -1371,7 +1371,7 @@ void DMD::PupDMDThread()

void DMD::handleTrigger(uint16_t id)
{
Log("PUP Trigger D%d\n", id);
Log("PUP Trigger D%d", id);
// @todo
}

Expand Down
19 changes: 9 additions & 10 deletions src/dmdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ static struct cag_option options[] = {
.description = "Fixed alt color path, overwriting paths transmitted by DMDUpdates (optional)"},
{.identifier = 'u',
.access_letters = "u",
.access_name = "pup-path",
.access_name = "pup-videos-path",
.value_name = "VALUE",
.description = "Fixed pup path, overwriting paths transmitted by DMDUpdates (optional)"},
.description = "Fixed PupVideos path, overwriting paths transmitted by DMDUpdates (optional)"},
{.identifier = 'a',
.access_letters = "a",
.access_name = "addr",
Expand Down Expand Up @@ -118,8 +118,7 @@ void run(sockpp::tcp_socket sock, uint32_t threadId)
switch (pStreamHeader->mode)
{
case DMDUtil::DMD::Mode::Data:
if ((n = sock.read_n(buffer, sizeof(DMDUtil::DMD::PathsHeader))) ==
sizeof(DMDUtil::DMD::PathsHeader) &&
if ((n = sock.read_n(buffer, sizeof(DMDUtil::DMD::PathsHeader))) == sizeof(DMDUtil::DMD::PathsHeader) &&
threadId == currentThreadId)
{
DMDUtil::DMD::PathsHeader pathsHeader;
Expand All @@ -131,15 +130,15 @@ void run(sockpp::tcp_socket sock, uint32_t threadId)
{
if (opt_verbose)
DMDUtil::Log("%d: Received AltColor header: ROM '%s', AltColorPath '%s', PupPath '%s'", threadId,
pathsHeader.name, pathsHeader.altColorPath, pathsHeader.pupPath);
pathsHeader.name, pathsHeader.altColorPath, pathsHeader.pupVideosPath);
DMDUtil::DMD::Update data;
memcpy(&data, buffer, n);

if (data.width <= DMDSERVER_MAX_WIDTH && data.height <= DMDSERVER_MAX_HEIGHT)
{
pDmd->SetRomName(pathsHeader.name);
if (!opt_fixedAltColorPath) pDmd->SetAltColorPath(pathsHeader.altColorPath);
if (!opt_fixedPupPath) pDmd->SetPupPath(pathsHeader.pupPath);
if (!opt_fixedPupPath) pDmd->SetPUPVideosPath(pathsHeader.pupVideosPath);

pDmd->QueueUpdate(data, (pStreamHeader->buffered == 1));
}
Expand Down Expand Up @@ -238,9 +237,9 @@ int main(int argc, char* argv[])
pConfig->SetDMDServerPort(r.Get<int>("DMDServer", "Port", 6789));
pConfig->SetAltColor(r.Get<bool>("DMDServer", "AltColor", true));
pConfig->SetAltColorPath(r.Get<string>("DMDServer", "AltColorPath", "").c_str());
pConfig->SetPup(r.Get<bool>("DMDServer", "Pup", true));
pConfig->SetPupPath(r.Get<string>("DMDServer", "PupPath", "").c_str());
pConfig->SetPupExactColorMatch(r.Get<bool>("DMDServer", "PupExactColorMatch", false));
pConfig->SetPUPCapture(r.Get<bool>("DMDServer", "PUPCapture", false));
pConfig->SetPUPVideosPath(r.Get<string>("DMDServer", "PUPVideosPath", "").c_str());
pConfig->SetPUPExactColorMatch(r.Get<bool>("DMDServer", "PUPExactColorMatch", false));
// ZeDMD
pConfig->SetZeDMD(r.Get<bool>("ZeDMD", "Enabled", true));
pConfig->SetZeDMDDevice(r.Get<string>("ZeDMD", "Device", "").c_str());
Expand All @@ -261,7 +260,7 @@ int main(int argc, char* argv[])
}
else if (identifier == 'u')
{
pConfig->SetPupPath(cag_option_get_value(&cag_context));
pConfig->SetPUPVideosPath(cag_option_get_value(&cag_context));
}
else if (identifier == 'a')
{
Expand Down

0 comments on commit 9341124

Please sign in to comment.