From 13f61c79717370d2dacf3889342de82e1214bb3b Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 24 Jan 2024 11:36:07 -0500 Subject: [PATCH] Minor changes --- LEGO1/lego/sources/misc/LegoImage.cpp | 9 +++++++ LEGO1/lego/sources/misc/LegoImage.h | 18 +++++++------- LEGO1/lego/sources/misc/LegoStorage.cpp | 9 +++---- LEGO1/lego/sources/misc/LegoStorage.h | 32 ++++++++++++++----------- LEGO1/lego/sources/misc/LegoTexture.h | 3 ++- 5 files changed, 44 insertions(+), 27 deletions(-) diff --git a/LEGO1/lego/sources/misc/LegoImage.cpp b/LEGO1/lego/sources/misc/LegoImage.cpp index fe6bf50b..7b083c06 100644 --- a/LEGO1/lego/sources/misc/LegoImage.cpp +++ b/LEGO1/lego/sources/misc/LegoImage.cpp @@ -98,13 +98,16 @@ LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square) if ((result = p_storage->Read(m_bits, m_width * m_height)) != SUCCESS) { return result; } + if (p_square && m_width != m_height) { LegoU8* newBits; + if (m_height < m_width) { LegoU32 aspect = m_width / m_height; newBits = new LegoU8[m_width * m_width]; LegoU8* src = m_bits; LegoU8* dst = newBits; + for (LegoU32 row = 0; row < m_height; row++) { for (LegoU32 dup = aspect; dup; dup--) { memcpy(dst, src, m_width); @@ -112,6 +115,7 @@ LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square) } src += m_width; } + m_height = m_width; } else { @@ -119,20 +123,25 @@ LegoResult LegoImage::Read(LegoStorage* p_storage, LegoU32 p_square) newBits = new LegoU8[m_height * m_height]; LegoU8* src = m_bits; LegoU8* dst = newBits; + for (LegoU32 row = 0; row < m_height; row++) { for (LegoU32 col = 0; col < m_width; col++) { for (LegoU32 dup = aspect; dup; dup--) { *dst = *src; dst++; } + src++; } } + m_width = m_height; } + delete m_bits; m_bits = newBits; } + return SUCCESS; } diff --git a/LEGO1/lego/sources/misc/LegoImage.h b/LEGO1/lego/sources/misc/LegoImage.h index bc382a02..7990277e 100644 --- a/LEGO1/lego/sources/misc/LegoImage.h +++ b/LEGO1/lego/sources/misc/LegoImage.h @@ -5,6 +5,7 @@ class LegoStorage; +// SIZE 0x3 class LegoPaletteEntry { public: LegoPaletteEntry(); @@ -19,11 +20,12 @@ class LegoPaletteEntry { LegoResult Write(LegoStorage* p_storage); protected: - LegoU8 m_red; - LegoU8 m_green; - LegoU8 m_blue; + LegoU8 m_red; // 0x00 + LegoU8 m_green; // 0x01 + LegoU8 m_blue; // 0x02 }; +// 0x310 class LegoImage { public: LegoImage(); @@ -42,11 +44,11 @@ class LegoImage { LegoResult Write(LegoStorage* p_storage); protected: - LegoU32 m_width; - LegoU32 m_height; - LegoU32 m_count; - LegoPaletteEntry m_palette[256]; - LegoU8* m_bits; + LegoU32 m_width; // 0x00 + LegoU32 m_height; // 0x04 + LegoU32 m_count; // 0x08 + LegoPaletteEntry m_palette[256]; // 0x0c + LegoU8* m_bits; // 0x30c }; #endif // __LEGOIMAGE_H diff --git a/LEGO1/lego/sources/misc/LegoStorage.cpp b/LEGO1/lego/sources/misc/LegoStorage.cpp index eb4cd110..50621f73 100644 --- a/LEGO1/lego/sources/misc/LegoStorage.cpp +++ b/LEGO1/lego/sources/misc/LegoStorage.cpp @@ -7,7 +7,7 @@ DECOMP_SIZE_ASSERT(LegoStorage, 0x8); DECOMP_SIZE_ASSERT(LegoMemory, 0x10); -DECOMP_SIZE_ASSERT(LegoFile, 0xC); +DECOMP_SIZE_ASSERT(LegoFile, 0xc); // FUNCTION: LEGO1 0x10099080 LegoMemory::LegoMemory(void* p_buffer) : LegoStorage() @@ -105,12 +105,12 @@ LegoResult LegoFile::Open(const char* p_name, LegoU32 p_mode) char mode[4]; mode[0] = '\0'; if (p_mode & c_read) { - m_mode = LEGOSTREAM_MODE_READ; + m_mode = c_read; strcat(mode, "r"); } if (p_mode & c_write) { - if (m_mode != LEGOSTREAM_MODE_READ) - m_mode = LEGOSTREAM_MODE_WRITE; + if (m_mode != c_read) + m_mode = c_write; strcat(mode, "w"); } if ((p_mode & c_text) != 0) @@ -130,6 +130,7 @@ LegoResult LegoMemory::GetPosition(LegoU32& p_position) p_position = m_position; return SUCCESS; } + // FUNCTION: LEGO1 0x100994b0 LegoResult LegoMemory::SetPosition(LegoU32 p_position) { diff --git a/LEGO1/lego/sources/misc/LegoStorage.h b/LEGO1/lego/sources/misc/LegoStorage.h index e4704f0d..1aff1351 100644 --- a/LEGO1/lego/sources/misc/LegoStorage.h +++ b/LEGO1/lego/sources/misc/LegoStorage.h @@ -6,33 +6,41 @@ #include -#define LEGOSTREAM_MODE_READ 1 -#define LEGOSTREAM_MODE_WRITE 2 - // VTABLE: LEGO1 0x100d7d80 +// SIZE 0x08 class LegoStorage { public: + enum OpenFlags { + c_read = 1, + c_write = 2, + c_text = 4 + }; + LegoStorage() : m_mode(0) {} + // FUNCTION: LEGO1 0x10045ad0 virtual ~LegoStorage(){}; + virtual LegoResult Read(void* p_buffer, LegoU32 p_size) = 0; virtual LegoResult Write(const void* p_buffer, LegoU32 p_size) = 0; virtual LegoResult GetPosition(LegoU32& p_position) = 0; virtual LegoResult SetPosition(LegoU32 p_position) = 0; // FUNCTION: LEGO1 0x10045ae0 - virtual LegoBool IsWriteMode() { return m_mode == LEGOSTREAM_MODE_WRITE; } + virtual LegoBool IsWriteMode() { return m_mode == c_read; } + // FUNCTION: LEGO1 0x10045af0 - virtual LegoBool IsReadMode() { return m_mode == LEGOSTREAM_MODE_READ; } + virtual LegoBool IsReadMode() { return m_mode == c_write; } // SYNTHETIC: LEGO1 0x10045b00 // LegoStorage::`scalar deleting destructor' protected: - LegoU8 m_mode; + LegoU8 m_mode; // 0x04 }; // VTABLE: LEGO1 0x100db710 +// SIZE 0x10 class LegoMemory : public LegoStorage { public: LegoMemory(void* p_buffer); @@ -45,18 +53,14 @@ class LegoMemory : public LegoStorage { // LegoMemory::`scalar deleting destructor' protected: - LegoU8* m_buffer; - LegoU32 m_position; + LegoU8* m_buffer; // 0x04 + LegoU32 m_position; // 0x08 }; // VTABLE: LEGO1 0x100db730 +// SIZE 0x0c class LegoFile : public LegoStorage { public: - enum OpenFlags { - c_read = 1, - c_write = 2, - c_text = 4 - }; LegoFile(); virtual ~LegoFile(); virtual LegoResult Read(void* p_buffer, LegoU32 p_size); @@ -82,7 +86,7 @@ class LegoFile : public LegoStorage { // LegoFile::`scalar deleting destructor' protected: - FILE* m_file; + FILE* m_file; // 0x08 }; #endif // __LEGOSTORAGE_H diff --git a/LEGO1/lego/sources/misc/LegoTexture.h b/LEGO1/lego/sources/misc/LegoTexture.h index e2203d57..1e279660 100644 --- a/LEGO1/lego/sources/misc/LegoTexture.h +++ b/LEGO1/lego/sources/misc/LegoTexture.h @@ -6,6 +6,7 @@ class LegoImage; class LegoStorage; +// SIZE 0x04 class LegoTexture { public: LegoTexture(); @@ -16,7 +17,7 @@ class LegoTexture { LegoResult Write(LegoStorage* p_storage); protected: - LegoImage* m_image; + LegoImage* m_image; // 0x00 }; #endif // __LEGOTEXTURE_H