Use COutputStream::Put

This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-11 21:35:41 +03:00
parent c41d43ebcb
commit a02037e266
No known key found for this signature in database
GPG Key ID: E224F951761145F8
7 changed files with 27 additions and 24 deletions

View File

@ -152,7 +152,7 @@ InitializeFromGameState__13SGameFileSlotFv:
/* 8024C394 002492F4 48 0F 2F A9 */ bl __ct__16CMemoryStreamOutFPvUlQ216CMemoryStreamOut10EOwnerShipi /* 8024C394 002492F4 48 0F 2F A9 */ bl __ct__16CMemoryStreamOutFPvUlQ216CMemoryStreamOut10EOwnerShipi
/* 8024C398 002492F8 80 6D A0 80 */ lwz r3, gpGameState@sda21(r13) /* 8024C398 002492F8 80 6D A0 80 */ lwz r3, gpGameState@sda21(r13)
/* 8024C39C 002492FC 38 81 00 30 */ addi r4, r1, 0x30 /* 8024C39C 002492FC 38 81 00 30 */ addi r4, r1, 0x30
/* 8024C3A0 00249300 4B F8 7C E9 */ bl PutTo__10CGameStateFR16CMemoryStreamOut /* 8024C3A0 00249300 4B F8 7C E9 */ bl PutTo__10CGameStateCFR13COutputStream
/* 8024C3A4 00249304 38 61 00 30 */ addi r3, r1, 0x30 /* 8024C3A4 00249304 38 61 00 30 */ addi r3, r1, 0x30
/* 8024C3A8 00249308 38 80 FF FF */ li r4, -1 /* 8024C3A8 00249308 38 80 FF FF */ li r4, -1
/* 8024C3AC 0024930C 48 0F 2F 15 */ bl __dt__16CMemoryStreamOutFv /* 8024C3AC 0024930C 48 0F 2F 15 */ bl __dt__16CMemoryStreamOutFv
@ -181,8 +181,8 @@ InitializeFromGameState__13SGameFileSlotFv:
/* 8024C408 00249368 38 21 00 D0 */ addi r1, r1, 0xd0 /* 8024C408 00249368 38 21 00 D0 */ addi r1, r1, 0xd0
/* 8024C40C 0024936C 4E 80 00 20 */ blr /* 8024C40C 0024936C 4E 80 00 20 */ blr
.global DoPut__13SGameFileSlotCFR16CMemoryStreamOut .global PutTo__13SGameFileSlotCFR13COutputStream
DoPut__13SGameFileSlotCFR16CMemoryStreamOut: PutTo__13SGameFileSlotCFR13COutputStream:
/* 8024C410 00249370 94 21 FF F0 */ stwu r1, -0x10(r1) /* 8024C410 00249370 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 8024C414 00249374 7C 08 02 A6 */ mflr r0 /* 8024C414 00249374 7C 08 02 A6 */ mflr r0
/* 8024C418 00249378 90 01 00 14 */ stw r0, 0x14(r1) /* 8024C418 00249378 90 01 00 14 */ stw r0, 0x14(r1)
@ -376,8 +376,8 @@ lbl_8024C674:
/* 8024C698 002495F8 38 21 00 10 */ addi r1, r1, 0x10 /* 8024C698 002495F8 38 21 00 10 */ addi r1, r1, 0x10
/* 8024C69C 002495FC 4E 80 00 20 */ blr /* 8024C69C 002495FC 4E 80 00 20 */ blr
.global DoPut__11SSaveHeaderCFR16CMemoryStreamOut .global PutTo__11SSaveHeaderCFR13COutputStream
DoPut__11SSaveHeaderCFR16CMemoryStreamOut: PutTo__11SSaveHeaderCFR13COutputStream:
/* 8024C6A0 00249600 94 21 FF E0 */ stwu r1, -0x20(r1) /* 8024C6A0 00249600 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8024C6A4 00249604 7C 08 02 A6 */ mflr r0 /* 8024C6A4 00249604 7C 08 02 A6 */ mflr r0
/* 8024C6A8 00249608 90 01 00 24 */ stw r0, 0x24(r1) /* 8024C6A8 00249608 90 01 00 24 */ stw r0, 0x24(r1)
@ -1299,7 +1299,7 @@ InitializeFileInfo__17CMemoryCardDriverFv:
/* 8024D35C 0024A2BC 7C 00 2B 78 */ or r0, r0, r5 /* 8024D35C 0024A2BC 7C 00 2B 78 */ or r0, r0, r5
/* 8024D360 0024A2C0 54 00 0F FE */ srwi r0, r0, 0x1f /* 8024D360 0024A2C0 54 00 0F FE */ srwi r0, r0, 0x1f
/* 8024D364 0024A2C4 98 01 00 0E */ stb r0, 0xe(r1) /* 8024D364 0024A2C4 98 01 00 0E */ stb r0, 0xe(r1)
/* 8024D368 0024A2C8 4B FF F3 39 */ bl DoPut__11SSaveHeaderCFR16CMemoryStreamOut /* 8024D368 0024A2C8 4B FF F3 39 */ bl PutTo__11SSaveHeaderCFR13COutputStream
/* 8024D36C 0024A2CC 38 61 00 A0 */ addi r3, r1, 0xa0 /* 8024D36C 0024A2CC 38 61 00 A0 */ addi r3, r1, 0xa0
/* 8024D370 0024A2D0 48 0F 21 49 */ bl FlushShiftRegister__13COutputStreamFv /* 8024D370 0024A2D0 48 0F 21 49 */ bl FlushShiftRegister__13COutputStreamFv
/* 8024D374 0024A2D4 38 61 00 A0 */ addi r3, r1, 0xa0 /* 8024D374 0024A2D4 38 61 00 A0 */ addi r3, r1, 0xa0
@ -1313,7 +1313,7 @@ lbl_8024D38C:
/* 8024D390 0024A2F0 28 03 00 00 */ cmplwi r3, 0 /* 8024D390 0024A2F0 28 03 00 00 */ cmplwi r3, 0
/* 8024D394 0024A2F4 41 82 00 0C */ beq lbl_8024D3A0 /* 8024D394 0024A2F4 41 82 00 0C */ beq lbl_8024D3A0
/* 8024D398 0024A2F8 38 81 00 A0 */ addi r4, r1, 0xa0 /* 8024D398 0024A2F8 38 81 00 A0 */ addi r4, r1, 0xa0
/* 8024D39C 0024A2FC 4B FF F0 75 */ bl DoPut__13SGameFileSlotCFR16CMemoryStreamOut /* 8024D39C 0024A2FC 4B FF F0 75 */ bl PutTo__13SGameFileSlotCFR13COutputStream
lbl_8024D3A0: lbl_8024D3A0:
/* 8024D3A0 0024A300 3B BD 00 08 */ addi r29, r29, 8 /* 8024D3A0 0024A300 3B BD 00 08 */ addi r29, r29, 8
lbl_8024D3A4: lbl_8024D3A4:

View File

@ -336,7 +336,7 @@ WriteBackupBuf__10CGameStateFv:
/* 801D3BEC 001D0B4C 48 16 B7 51 */ bl __ct__16CMemoryStreamOutFPvUlQ216CMemoryStreamOut10EOwnerShipi /* 801D3BEC 001D0B4C 48 16 B7 51 */ bl __ct__16CMemoryStreamOutFPvUlQ216CMemoryStreamOut10EOwnerShipi
/* 801D3BF0 001D0B50 7F E3 FB 78 */ mr r3, r31 /* 801D3BF0 001D0B50 7F E3 FB 78 */ mr r3, r31
/* 801D3BF4 001D0B54 38 81 00 08 */ addi r4, r1, 8 /* 801D3BF4 001D0B54 38 81 00 08 */ addi r4, r1, 8
/* 801D3BF8 001D0B58 48 00 04 91 */ bl PutTo__10CGameStateFR16CMemoryStreamOut /* 801D3BF8 001D0B58 48 00 04 91 */ bl PutTo__10CGameStateCFR13COutputStream
/* 801D3BFC 001D0B5C 38 61 00 08 */ addi r3, r1, 8 /* 801D3BFC 001D0B5C 38 61 00 08 */ addi r3, r1, 8
/* 801D3C00 001D0B60 38 80 FF FF */ li r4, -1 /* 801D3C00 001D0B60 38 80 FF FF */ li r4, -1
/* 801D3C04 001D0B64 48 16 B6 BD */ bl __dt__16CMemoryStreamOutFv /* 801D3C04 001D0B64 48 16 B6 BD */ bl __dt__16CMemoryStreamOutFv
@ -679,8 +679,8 @@ ReadSystemOptions__10CGameStateFR12CInputStream:
/* 801D4080 001D0FE0 38 21 00 F0 */ addi r1, r1, 0xf0 /* 801D4080 001D0FE0 38 21 00 F0 */ addi r1, r1, 0xf0
/* 801D4084 001D0FE4 4E 80 00 20 */ blr /* 801D4084 001D0FE4 4E 80 00 20 */ blr
.global PutTo__10CGameStateFR16CMemoryStreamOut .global PutTo__10CGameStateCFR13COutputStream
PutTo__10CGameStateFR16CMemoryStreamOut: PutTo__10CGameStateCFR13COutputStream:
/* 801D4088 001D0FE8 94 21 FF B0 */ stwu r1, -0x50(r1) /* 801D4088 001D0FE8 94 21 FF B0 */ stwu r1, -0x50(r1)
/* 801D408C 001D0FEC 7C 08 02 A6 */ mflr r0 /* 801D408C 001D0FEC 7C 08 02 A6 */ mflr r0
/* 801D4090 001D0FF0 90 01 00 54 */ stw r0, 0x54(r1) /* 801D4090 001D0FF0 90 01 00 54 */ stw r0, 0x54(r1)

View File

@ -4,10 +4,9 @@
#include "types.h" #include "types.h"
class COutputStream; class COutputStream;
template < typename T > template < typename T >
void coutput_stream_helper(const T& t, COutputStream& out) { void coutput_stream_helper(const T& t, COutputStream& out);
t.PutTo(out);
}
class COutputStream { class COutputStream {
void DoPut(const void* ptr, size_t len); void DoPut(const void* ptr, size_t len);
@ -57,6 +56,11 @@ private:
uchar mScratch[96]; uchar mScratch[96];
}; };
template < typename T >
inline void coutput_stream_helper(const T& t, COutputStream& out) {
t.PutTo(out);
}
template <> template <>
inline void coutput_stream_helper(const float& t, COutputStream& out) { inline void coutput_stream_helper(const float& t, COutputStream& out) {
int tmp = *(int*)&t; int tmp = *(int*)&t;

View File

@ -44,7 +44,7 @@ struct SSaveHeader {
explicit SSaveHeader(int); explicit SSaveHeader(int);
explicit SSaveHeader(CMemoryInStream& in); explicit SSaveHeader(CMemoryInStream& in);
void DoPut(CMemoryStreamOut& out) const; void PutTo(COutputStream& out) const;
}; };
struct SGameFileSlot { struct SGameFileSlot {
@ -56,7 +56,7 @@ struct SGameFileSlot {
void InitializeFromGameState(); void InitializeFromGameState();
void LoadGameState(int idx); void LoadGameState(int idx);
void DoPut(CMemoryStreamOut& w) const; void PutTo(COutputStream& w) const;
}; };
CHECK_SIZEOF(SGameFileSlot, 0x3d8) CHECK_SIZEOF(SGameFileSlot, 0x3d8)

View File

@ -15,14 +15,13 @@
#include "rstl/reserved_vector.hpp" #include "rstl/reserved_vector.hpp"
#include "rstl/vector.hpp" #include "rstl/vector.hpp"
class CMemoryStreamOut;
class CGameState { class CGameState {
public: public:
CGameState(); CGameState();
CGameState(CInputStream& in, int saveIdx); CGameState(CInputStream& in, int saveIdx);
void ReadSystemOptions(CInputStream& in); void ReadSystemOptions(CInputStream& in);
void PutTo(CMemoryStreamOut& out); void PutTo(COutputStream& out) const;
void WriteSystemOptions(COutputStream& out); void WriteSystemOptions(COutputStream& out);
rstl::rc_ptr< CPlayerState >& PlayerState(); rstl::rc_ptr< CPlayerState >& PlayerState();

View File

@ -14,7 +14,7 @@ public:
CSystemOptions(); CSystemOptions();
explicit CSystemOptions(CInputStream&); explicit CSystemOptions(CInputStream&);
~CSystemOptions(); ~CSystemOptions();
void PutTo(COutputStream&); void PutTo(COutputStream&) const;
void SetHasFusion(bool v); void SetHasFusion(bool v);
bool GetHasFusion() const { return xd0_28_fusionSuitActive; } bool GetHasFusion() const { return xd0_28_fusionSuitActive; }

View File

@ -672,7 +672,7 @@ void CMemoryCardDriver::InitializeFileInfo() {
for (int i = 0; i < xe4_fileSlots.capacity(); ++i) { for (int i = 0; i < xe4_fileSlots.capacity(); ++i) {
header.x4_savePresent[i] = !xe4_fileSlots[i].null(); header.x4_savePresent[i] = !xe4_fileSlots[i].null();
} }
header.DoPut(w); w.Put(header);
w.Put(x30_systemData.data(), x30_systemData.capacity()); w.Put(x30_systemData.data(), x30_systemData.capacity());
@ -680,7 +680,7 @@ void CMemoryCardDriver::InitializeFileInfo() {
xe4_fileSlots.begin(); xe4_fileSlots.begin();
it != xe4_fileSlots.end(); ++it) { it != xe4_fileSlots.end(); ++it) {
if (!it->null()) { if (!it->null()) {
(*it)->DoPut(w); w.Put(**it);
} }
} }
} }
@ -761,7 +761,7 @@ void CMemoryCardDriver::ExportPersistentOptions() {
gpGameState->ExportPersistentOptions(opts); gpGameState->ExportPersistentOptions(opts);
CMemoryStreamOut w(data, x30_systemData.capacity()); CMemoryStreamOut w(data, x30_systemData.capacity());
opts.PutTo(w); w.Put(opts);
} }
SSaveHeader::SSaveHeader(int i) : x0_version(i) {} SSaveHeader::SSaveHeader(int i) : x0_version(i) {}
@ -773,7 +773,7 @@ SSaveHeader::SSaveHeader(CMemoryInStream& in) {
} }
} }
void SSaveHeader::DoPut(CMemoryStreamOut& out) const { void SSaveHeader::PutTo(COutputStream& out) const {
out.WriteLong(x0_version); out.WriteLong(x0_version);
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
out.Put(x4_savePresent[i]); out.Put(x4_savePresent[i]);
@ -787,14 +787,14 @@ SGameFileSlot::SGameFileSlot(CMemoryInStream& in) : x0_saveBuffer('\x00') {
x944_fileInfo = gpGameState->LoadGameFileState(x0_saveBuffer.data()); x944_fileInfo = gpGameState->LoadGameFileState(x0_saveBuffer.data());
} }
void SGameFileSlot::DoPut(CMemoryStreamOut& w) const { void SGameFileSlot::PutTo(COutputStream& w) const {
w.Put(x0_saveBuffer.data(), x0_saveBuffer.capacity()); w.Put(x0_saveBuffer.data(), x0_saveBuffer.capacity());
} }
void SGameFileSlot::InitializeFromGameState() { void SGameFileSlot::InitializeFromGameState() {
{ {
CMemoryStreamOut w(x0_saveBuffer.data(), x0_saveBuffer.capacity()); CMemoryStreamOut w(x0_saveBuffer.data(), x0_saveBuffer.capacity());
gpGameState->PutTo(w); w.Put(*gpGameState);
} }
x944_fileInfo = CGameState::LoadGameFileState(x0_saveBuffer.data()); x944_fileInfo = CGameState::LoadGameFileState(x0_saveBuffer.data());
} }