Let's replace the hack through a hack? Should fix the double swapping of #208 (and maybe more)

This commit is contained in:
Lurs
2026-04-12 22:39:05 +02:00
parent 2c1cd98d4a
commit 6b3728c5ab
2 changed files with 29 additions and 17 deletions
@@ -4,6 +4,9 @@
#include "JSystem/JGadget/linklist.h"
#include "JSystem/JStudio/JStudio/fvb-data-parse.h"
#include "JSystem/JStudio/JStudio/object-id.h"
#if TARGET_PC
#include <vector>
#endif
namespace JStudio {
namespace fvb {
@@ -126,6 +129,9 @@ public:
private:
TFunctionValue_list fnValue;
#if TARGET_PC
std::vector<f32> mSwappedData;
#endif
};
class TObject_list_parameter : public TObject {
@@ -141,6 +147,9 @@ public:
private:
TFunctionValue_list_parameter fnValue;
#if TARGET_PC
std::vector<f32> mSwappedData;
#endif
};
struct TObject_hermite : public TObject {
@@ -156,6 +165,9 @@ public:
private:
TFunctionValue_hermite fnValue;
#if TARGET_PC
std::vector<f32> mSwappedData;
#endif
};
} // namespace fvb
+17 -17
View File
@@ -5,15 +5,7 @@
#include <cstring>
#if TARGET_PC
namespace {
void endianSwapListData(const f32* data, u32 count) {
// const hack to swap endianness
f32* nonConstData = const_cast<f32*>(data);
for (int i = 0; i < count; i++) {
be_swap(nonConstData[i]);
}
}
}
#include <vector>
#endif
namespace JStudio {
@@ -281,12 +273,14 @@ void TObject_list::prepare_data_(const data::TParse_TParagraph::TData& rData, TC
const ListData* pContent = static_cast<const ListData*>(rData.pContent);
ASSERT(pContent != NULL);
#if TARGET_PC
endianSwapListData(pContent->_8, pContent->_4);
#endif
fnValue.data_setInterval(pContent->_0);
#if TARGET_PC
mSwappedData.assign(pContent->_8, pContent->_8 + (u32)pContent->_4);
be_swap(mSwappedData.data(), pContent->_4);
fnValue.data_set(mSwappedData.data(), pContent->_4);
#else
fnValue.data_set(pContent->_8, pContent->_4);
#endif
}
TObject_list_parameter::TObject_list_parameter(data::TParse_TBlock const& param_0)
@@ -303,9 +297,13 @@ void TObject_list_parameter::prepare_data_(const data::TParse_TParagraph::TData&
ASSERT(pContent != NULL);
#if TARGET_PC
endianSwapListData(pContent->_4, pContent->_0 * 2);
#endif
u32 count = pContent->_0 * 2;
mSwappedData.assign(pContent->_4, pContent->_4 + count);
be_swap(mSwappedData.data(), count);
fnValue.data_set(mSwappedData.data(), pContent->_0);
#else
fnValue.data_set(pContent->_4, pContent->_0);
#endif
}
TObject_hermite::TObject_hermite(data::TParse_TBlock const& param_0) : TObject(param_0, &fnValue) {}
@@ -323,8 +321,10 @@ void TObject_hermite::prepare_data_(const data::TParse_TParagraph::TData& rData,
#if TARGET_PC
u32 u = (pContent->_0 & 0xFFFFFFF);
u32 uSize = (pContent->_0 >> 0x1C);
endianSwapListData(pContent->_4, u * uSize);
fnValue.data_set(pContent->_4, u, uSize);
u32 total = u * uSize;
mSwappedData.assign(pContent->_4, pContent->_4 + total);
be_swap(mSwappedData.data(), total);
fnValue.data_set(mSwappedData.data(), u, uSize);
#else
fnValue.data_set(pContent->_4, pContent->_0 & 0xFFFFFFF, pContent->_0 >> 0x1C);
#endif