forked from vpinball/libdmdutil
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
367c832
commit 518db66
Showing
5 changed files
with
193 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#ifdef _MSC_VER | ||
#define DMDUTILAPI __declspec(dllexport) | ||
#define DMDUTILCALLBACK __stdcall | ||
#else | ||
#define DMDUTILAPI __attribute__((visibility("default"))) | ||
#define DMDUTILCALLBACK | ||
#endif | ||
|
||
#include <cstdint> | ||
|
||
namespace DMDUtil | ||
{ | ||
|
||
class DMDUTILAPI LevelDMD | ||
{ | ||
public: | ||
LevelDMD(uint16_t width, uint16_t height, bool sam); | ||
~LevelDMD(); | ||
|
||
void Update(uint8_t* pLevelData, uint8_t depth); | ||
int GetWidth() { return m_width; } | ||
int GetHeight() { return m_height; } | ||
int GetLength() const { return m_length; } | ||
int GetPitch() const { return m_pitch; } | ||
uint8_t* GetData(); | ||
|
||
private: | ||
static constexpr uint8_t LEVELS_WPC[] = {0x14, 0x21, 0x43, 0x64}; | ||
static constexpr uint8_t LEVELS_GTS3[] = {0x00, 0x1E, 0x23, 0x28, 0x2D, 0x32, 0x37, 0x3C, | ||
0x41, 0x46, 0x4B, 0x50, 0x55, 0x5A, 0x5F, 0x64}; | ||
static constexpr uint8_t LEVELS_SAM[] = {0x00, 0x14, 0x19, 0x1E, 0x23, 0x28, 0x2D, 0x32, | ||
0x37, 0x3C, 0x41, 0x46, 0x4B, 0x50, 0x5A, 0x64}; | ||
|
||
uint16_t m_width; | ||
uint16_t m_height; | ||
int m_length; | ||
int m_pitch; | ||
int m_update; | ||
bool m_sam; | ||
|
||
uint8_t* m_pData; | ||
}; | ||
|
||
} // namespace DMDUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#ifdef _MSC_VER | ||
#define DMDUTILAPI __declspec(dllexport) | ||
#define DMDUTILCALLBACK __stdcall | ||
#else | ||
#define DMDUTILAPI __attribute__((visibility("default"))) | ||
#define DMDUTILCALLBACK | ||
#endif | ||
|
||
#include <cstdint> | ||
|
||
namespace DMDUtil | ||
{ | ||
|
||
class DMDUTILAPI RGB24DMD | ||
{ | ||
public: | ||
RGB24DMD(uint16_t width, uint16_t height); | ||
~RGB24DMD(); | ||
|
||
void Update(uint8_t* pRGB24Data); | ||
int GetWidth() { return m_width; } | ||
int GetHeight() { return m_height; } | ||
int GetLength() const { return m_length; } | ||
int GetPitch() const { return m_pitch; } | ||
uint8_t* GetData(); | ||
|
||
private: | ||
uint16_t m_width; | ||
uint16_t m_height; | ||
int m_length; | ||
int m_pitch; | ||
int m_update; | ||
|
||
uint8_t* m_pData; | ||
}; | ||
|
||
} // namespace DMDUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include "DMDUtil/LevelDMD.h" | ||
|
||
#include <cstdint> | ||
#include <cstring> | ||
#include <string> | ||
|
||
namespace DMDUtil | ||
{ | ||
|
||
LevelDMD::LevelDMD(uint16_t width, uint16_t height, bool sam) | ||
{ | ||
m_width = width; | ||
m_height = height; | ||
m_length = width * height; | ||
m_pitch = width * 3; | ||
m_sam = sam; | ||
|
||
m_pData = (uint8_t*)malloc(m_length); | ||
memset(m_pData, 0, m_length); | ||
|
||
m_update = false; | ||
} | ||
|
||
LevelDMD::~LevelDMD() { free(m_pData); } | ||
|
||
void LevelDMD::Update(uint8_t* pData, uint8_t depth) | ||
{ | ||
memcpy(m_pData, pData, m_length); | ||
if (depth == 2) | ||
{ | ||
for (int i = 0; i < m_length; i++) m_pData[i] = LEVELS_WPC[pData[i]]; | ||
m_update = true; | ||
} | ||
else if (depth == 4) | ||
{ | ||
if (m_sam) | ||
{ | ||
for (int i = 0; i < m_length; i++) m_pData[i] = LEVELS_SAM[pData[i]]; | ||
} | ||
else | ||
{ | ||
for (int i = 0; i < m_length; i++) m_pData[i] = LEVELS_GTS3[pData[i]]; | ||
} | ||
m_update = true; | ||
} | ||
} | ||
|
||
uint8_t* LevelDMD::GetData() | ||
{ | ||
if (!m_update) return nullptr; | ||
|
||
m_update = false; | ||
return m_pData; | ||
} | ||
|
||
} // namespace DMDUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "DMDUtil/RGB24DMD.h" | ||
|
||
#include <cstdint> | ||
#include <cstring> | ||
#include <string> | ||
|
||
namespace DMDUtil | ||
{ | ||
|
||
RGB24DMD::RGB24DMD(uint16_t width, uint16_t height) | ||
{ | ||
m_width = width; | ||
m_height = height; | ||
m_length = width * height * 3; | ||
m_pitch = width * 3; | ||
|
||
m_pData = (uint8_t*)malloc(m_length); | ||
memset(m_pData, 0, m_length); | ||
|
||
m_update = false; | ||
} | ||
|
||
RGB24DMD::~RGB24DMD() { free(m_pData); } | ||
|
||
void RGB24DMD::Update(uint8_t* pData) | ||
{ | ||
memcpy(m_pData, pData, m_length); | ||
|
||
m_update = true; | ||
} | ||
|
||
uint8_t* RGB24DMD::GetData() | ||
{ | ||
if (!m_update) return nullptr; | ||
|
||
m_update = false; | ||
return m_pData; | ||
} | ||
|
||
} // namespace DMDUtil |