Implement remaining Write functions

This commit is contained in:
Christian Semmler 2024-12-15 10:08:57 -07:00
parent 4694dc94ca
commit ece0c4afd8
2 changed files with 255 additions and 25 deletions

View File

@ -30,8 +30,28 @@ LegoResult LegoUnknownKey::Read(LegoStorage* p_storage)
return result;
}
result = p_storage->Read(&m_z, sizeof(m_z));
return result == SUCCESS ? SUCCESS : result;
if ((result = p_storage->Read(&m_z, sizeof(m_z))) != SUCCESS) {
return result;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009f060
// FUNCTION: BETA10 0x1018133f
LegoResult LegoUnknownKey::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = LegoAnimKey::Write(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
return result;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009f0a0
@ -67,6 +87,49 @@ LegoAnimScene::~LegoAnimScene()
}
}
// FUNCTION: LEGO1 0x1009f120
// FUNCTION: BETA10 0x101814be
LegoResult LegoAnimScene::Write(LegoStorage* p_storage)
{
LegoResult result;
LegoS32 i;
if ((result = p_storage->Write(&m_unk0x00, sizeof(m_unk0x00))) != SUCCESS) {
return result;
}
if (m_unk0x00 != 0) {
for (i = 0; i < m_unk0x00; i++) {
if ((result = m_unk0x04[i].Write(p_storage)) != SUCCESS) {
return result;
}
}
}
if ((result = p_storage->Write(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
return result;
}
if (m_unk0x08 != 0) {
for (i = 0; i < m_unk0x08; i++) {
if ((result = m_unk0x0c[i].Write(p_storage)) != SUCCESS) {
return result;
}
}
}
if ((result = p_storage->Write(&m_unk0x10, sizeof(m_unk0x10))) != SUCCESS) {
return result;
}
if (m_unk0x10 != 0) {
for (i = 0; i < m_unk0x10; i++) {
if ((result = m_unk0x14[i].Write(p_storage)) != SUCCESS) {
return result;
}
}
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009f200
LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
{
@ -76,8 +139,7 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
if ((result = p_storage->Read(&m_unk0x00, sizeof(m_unk0x00))) != SUCCESS) {
return result;
}
if (m_unk0x00) {
if (m_unk0x00 != 0) {
m_unk0x04 = new LegoTranslationKey[m_unk0x00];
for (i = 0; i < m_unk0x00; i++) {
if ((result = m_unk0x04[i].Read(p_storage)) != SUCCESS) {
@ -89,8 +151,7 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
if ((result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
return result;
}
if (m_unk0x08) {
if (m_unk0x08 != 0) {
m_unk0x0c = new LegoTranslationKey[m_unk0x08];
for (i = 0; i < m_unk0x08; i++) {
if ((result = m_unk0x0c[i].Read(p_storage)) != SUCCESS) {
@ -102,8 +163,7 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
if ((result = p_storage->Read(&m_unk0x10, sizeof(m_unk0x10))) != SUCCESS) {
return result;
}
if (m_unk0x10) {
if (m_unk0x10 != 0) {
m_unk0x14 = new LegoUnknownKey[m_unk0x10];
for (i = 0; i < m_unk0x10; i++) {
if ((result = m_unk0x14[i].Read(p_storage)) != SUCCESS) {
@ -136,14 +196,6 @@ LegoResult LegoAnimScene::Read(LegoStorage* p_storage)
return result;
}
// STUB: LEGO1 0x1009f120
// STUB: BETA10 0x101814be
LegoResult LegoAnimScene::Write(LegoStorage* p_storage)
{
// TODO
return FAILURE;
}
// FUNCTION: LEGO1 0x1009f490
// FUNCTION: BETA10 0x10181a83
LegoResult LegoAnimScene::FUN_1009f490(LegoFloat p_time, Matrix4& p_matrix)
@ -240,14 +292,28 @@ LegoAnimKey::LegoAnimKey()
LegoResult LegoAnimKey::Read(LegoStorage* p_storage)
{
LegoResult result;
LegoS32 und;
LegoS32 timeAndFlags;
if ((result = p_storage->Read(&und, sizeof(und))) != SUCCESS) {
if ((result = p_storage->Read(&timeAndFlags, sizeof(timeAndFlags))) != SUCCESS) {
return result;
}
m_flags = (LegoU32) timeAndFlags >> 24;
m_time = timeAndFlags & 0xffffff;
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009f950
// FUNCTION: BETA10 0x1017e018
LegoResult LegoAnimKey::Write(LegoStorage* p_storage)
{
LegoResult result;
LegoS32 timeAndFlags = (LegoS32) m_time | (m_flags << 24);
if ((result = p_storage->Write(&timeAndFlags, sizeof(timeAndFlags))) != SUCCESS) {
return result;
}
m_flags = (LegoU32) und >> 24;
m_time = und & 0xffffff;
return SUCCESS;
}
@ -287,6 +353,31 @@ LegoResult LegoTranslationKey::Read(LegoStorage* p_storage)
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009fa40
// FUNCTION: BETA10 0x1017e1fd
LegoResult LegoTranslationKey::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = LegoAnimKey::Write(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_x, sizeof(m_x))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_y, sizeof(m_y))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
return result;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009faa0
// FUNCTION: BETA10 0x1017e2b3
LegoRotationKey::LegoRotationKey()
@ -329,6 +420,35 @@ LegoResult LegoRotationKey::Read(LegoStorage* p_storage)
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009fb30
// FUNCTION: BETA10 0x1017e3fc
LegoResult LegoRotationKey::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = LegoAnimKey::Write(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_angle, sizeof(m_angle))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_x, sizeof(m_x))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_y, sizeof(m_y))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
return result;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009fba0
LegoScaleKey::LegoScaleKey()
{
@ -365,6 +485,31 @@ LegoResult LegoScaleKey::Read(LegoStorage* p_storage)
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009fc90
// FUNCTION: BETA10 0x1017e664
LegoResult LegoScaleKey::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = LegoAnimKey::Write(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_x, sizeof(m_x))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_y, sizeof(m_y))) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_z, sizeof(m_z))) != SUCCESS) {
return result;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x1009fcf0
// FUNCTION: BETA10 0x1017e71a
LegoAnimNodeData::LegoAnimNodeData()
@ -499,11 +644,70 @@ LegoResult LegoAnimNodeData::Read(LegoStorage* p_storage)
return SUCCESS;
}
// STUB: LEGO1 0x100a01e0
// STUB: BETA10 0x1017ef0f
// FUNCTION: LEGO1 0x100a01e0
// FUNCTION: BETA10 0x1017ef0f
LegoResult LegoAnimNodeData::Write(LegoStorage* p_storage)
{
// TODO
LegoResult result;
LegoU32 length = 0;
LegoU32 i;
if (m_name != NULL) {
length = strlen(m_name);
}
if ((result = p_storage->Write(&length, sizeof(length))) != SUCCESS) {
return result;
}
if (m_name != NULL && (result = p_storage->Write(m_name, length)) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_numTranslationKeys, sizeof(m_numTranslationKeys))) != SUCCESS) {
return result;
}
if (m_numTranslationKeys != 0) {
for (i = 0; i < m_numTranslationKeys; i++) {
if ((result = m_translationKeys[i].Write(p_storage)) != SUCCESS) {
return result;
}
}
}
if ((result = p_storage->Write(&m_numRotationKeys, sizeof(m_numRotationKeys))) != SUCCESS) {
return result;
}
if (m_numRotationKeys != 0) {
for (i = 0; i < m_numRotationKeys; i++) {
if ((result = m_rotationKeys[i].Write(p_storage)) != SUCCESS) {
return result;
}
}
}
if ((result = p_storage->Write(&m_numScaleKeys, sizeof(m_numScaleKeys))) != SUCCESS) {
return result;
}
if (m_numScaleKeys != 0) {
for (i = 0; i < m_numScaleKeys; i++) {
if ((result = m_scaleKeys[i].Write(p_storage)) != SUCCESS) {
return result;
}
}
}
if ((result = p_storage->Write(&m_numMorphKeys, sizeof(m_numMorphKeys))) != SUCCESS) {
return result;
}
if (m_numMorphKeys != 0) {
for (i = 0; i < m_numMorphKeys; i++) {
if ((result = m_morphKeys[i].Write(p_storage)) != SUCCESS) {
return result;
}
}
}
return SUCCESS;
}
@ -978,6 +1182,26 @@ LegoResult LegoMorphKey::Read(LegoStorage* p_storage)
return result;
}
result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08));
return result == SUCCESS ? SUCCESS : result;
if ((result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
return result;
}
return SUCCESS;
}
// FUNCTION: LEGO1 0x100a0fb0
// FUNCTION: BETA10 0x10180308
LegoResult LegoMorphKey::Write(LegoStorage* p_storage)
{
LegoResult result;
if ((result = LegoAnimKey::Write(p_storage)) != SUCCESS) {
return result;
}
if ((result = p_storage->Write(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) {
return result;
}
return SUCCESS;
}

View File

@ -18,6 +18,7 @@ class LegoAnimKey {
LegoAnimKey();
LegoResult Read(LegoStorage* p_storage);
LegoResult Write(LegoStorage* p_storage);
LegoFloat GetTime() { return m_time; }
// The different types (LegoFloat vs. MxS32) are correct according to BETA10
@ -49,6 +50,7 @@ class LegoTranslationKey : public LegoAnimKey {
public:
LegoTranslationKey();
LegoResult Read(LegoStorage* p_storage);
LegoResult Write(LegoStorage* p_storage);
LegoFloat GetX() { return m_x; }
void SetX(LegoFloat p_x) { m_x = p_x; }
LegoFloat GetY() { return m_y; }
@ -67,6 +69,7 @@ class LegoRotationKey : public LegoAnimKey {
public:
LegoRotationKey();
LegoResult Read(LegoStorage* p_storage);
LegoResult Write(LegoStorage* p_storage);
// FUNCTION: BETA10 0x10073a00
LegoFloat GetAngle() { return m_angle; }
@ -104,6 +107,7 @@ class LegoScaleKey : public LegoAnimKey {
public:
LegoScaleKey();
LegoResult Read(LegoStorage* p_storage);
LegoResult Write(LegoStorage* p_storage);
LegoFloat GetX() { return m_x; }
void SetX(LegoFloat p_x) { m_x = p_x; }
LegoFloat GetY() { return m_y; }
@ -122,6 +126,7 @@ class LegoMorphKey : public LegoAnimKey {
public:
LegoMorphKey();
LegoResult Read(LegoStorage* p_storage);
LegoResult Write(LegoStorage* p_storage);
LegoBool GetUnknown0x08() { return m_unk0x08; }
// FUNCTION: BETA10 0x100738d0
@ -136,6 +141,7 @@ class LegoUnknownKey : public LegoAnimKey {
public:
LegoUnknownKey();
LegoResult Read(LegoStorage* p_storage);
LegoResult Write(LegoStorage* p_storage);
LegoFloat GetZ() { return m_z; }