Update
This commit is contained in:
+62
-5
@@ -24,10 +24,67 @@ DLL_FUNCTION(const char*) BS_Helper_FormatUnixTime(uint32_t unTime, const char*
|
||||
delete tm;
|
||||
return output;
|
||||
}
|
||||
DLL_FUNCTION(double_t*) BS_Helper_CreateDouble(float_t value) {
|
||||
return new double_t(value);
|
||||
}
|
||||
|
||||
DLL_FUNCTION(void) BS_Helper_DeleteDouble(double_t* pDouble) {
|
||||
delete pDouble;
|
||||
DLL_FUNCTION(void) BS_Helper_CopyMemoryIntMangle(void* pSource, void* pDest, int32_t iMangling,
|
||||
uint32_t iSourceW, uint32_t iSourceH, uint32_t iDestW, uint32_t iDestH,
|
||||
uint32_t iAreaX, uint32_t iAreaY, uint32_t iAreaW, uint32_t iAreaH) {
|
||||
int8_t iMangleByte0 = static_cast<int8_t>((iMangling & 0xFF));
|
||||
int8_t iMangleByte1 = static_cast<int8_t>((iMangling & 0xFF00) >> 8);
|
||||
int8_t iMangleByte2 = static_cast<int8_t>((iMangling & 0xFF0000) >> 16);
|
||||
int8_t iMangleByte3 = static_cast<int8_t>((iMangling & 0xFF000000) >> 24);
|
||||
|
||||
if (pSource > pDest) {
|
||||
// Start at beginning
|
||||
for (uint32_t iY = iAreaY; iY < (iAreaY + iAreaH); iY++) {
|
||||
// Only do this once per loop
|
||||
for (uint32_t iX = iAreaX; iX < (iAreaX + iAreaW); iX++) {
|
||||
// Could technically optimize the following into single instructions, but this is fast enough for now.
|
||||
uint32_t* pSourceOff = reinterpret_cast<uint32_t*>(pSource) + ((iSourceW * iY) + iX);
|
||||
uint32_t* pDestOff = reinterpret_cast<uint32_t*>(pDest) + ((iDestW * iY) + iX);
|
||||
|
||||
// Allow Mangling using just a single integer and checking on the fly if it's positive or negative to branch out to the correct shift.
|
||||
*pDestOff =
|
||||
(iMangleByte0 > 0 ?
|
||||
(*pSourceOff & 0xFF) >> iMangleByte0 :
|
||||
(*pSourceOff & 0xFF) << -iMangleByte0)
|
||||
+ (iMangleByte1 > 0 ?
|
||||
(*pSourceOff & 0xFF00) >> iMangleByte1 :
|
||||
(*pSourceOff & 0xFF00) << -iMangleByte1)
|
||||
+ (iMangleByte2 > 0 ?
|
||||
(*pSourceOff & 0xFF0000) >> iMangleByte2 :
|
||||
(*pSourceOff & 0xFF0000) << -iMangleByte2)
|
||||
+ (iMangleByte3 > 0 ?
|
||||
(*pSourceOff & 0xFF000000) >> iMangleByte3 :
|
||||
(*pSourceOff & 0xFF000000) << -iMangleByte3);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//ToDo, mirror the above. Instead of adding we subtract.
|
||||
//// Start at end
|
||||
|
||||
//for (uint32_t iY = y + h; iY >= y; iY--) {
|
||||
// pSourceOff = reinterpret_cast<uint32_t*>(pSource) + ((tw * iY) + x);
|
||||
// pDestOff = reinterpret_cast<uint32_t*>(pDest) + ((tw * iY) + x);
|
||||
|
||||
// for (uint32_t iX = x + w; iX >= x; iX--) {
|
||||
// *pDestOff =
|
||||
// (iMangleByte0 > 0 ?
|
||||
// (*pSourceOff & 0xFF) >> iMangleByte0 :
|
||||
// (*pSourceOff & 0xFF) << -iMangleByte0)
|
||||
// + (iMangleByte1 > 0 ?
|
||||
// (*pSourceOff & 0xFF00) >> iMangleByte1 :
|
||||
// (*pSourceOff & 0xFF00) << -iMangleByte1)
|
||||
// + (iMangleByte2 > 0 ?
|
||||
// (*pSourceOff & 0xFF0000) >> iMangleByte2 :
|
||||
// (*pSourceOff & 0xFF0000) << -iMangleByte2)
|
||||
// + (iMangleByte3 > 0 ?
|
||||
// (*pSourceOff & 0xFF000000) >> iMangleByte3 :
|
||||
// (*pSourceOff & 0xFF000000) << -iMangleByte3);
|
||||
|
||||
// // Above is some mangling magic i learned in some source code. Allows you to define a byte bit shift using a single integer.
|
||||
// pSourceOff -= 1;
|
||||
// pDestOff -= 1;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user