From 428b5ae8dbff80edfbea88647f363b1f9cc18bbb Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Fri, 30 Jun 2023 19:24:00 -0400 Subject: [PATCH] Initial implementation of MxBitmap (#34) Co-authored-by: Anonymous Maarten --- LEGO1/mxbitmap.cpp | 61 ++++++++++++++++++++++++++++++++++++++++------ LEGO1/mxbitmap.h | 15 ++++++++++-- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/LEGO1/mxbitmap.cpp b/LEGO1/mxbitmap.cpp index 81126d9b..a7425dd8 100644 --- a/LEGO1/mxbitmap.cpp +++ b/LEGO1/mxbitmap.cpp @@ -3,25 +3,72 @@ // OFFSET: LEGO1 0x100bc980 MxBitmap::MxBitmap() { - // TODO + this->m_info = NULL; + this->m_bmiHeader = NULL; + this->m_paletteData = NULL; + this->m_data = NULL; + this->m_unk18 = FALSE; + this->m_palette = NULL; } // OFFSET: LEGO1 0x100bca10 MxBitmap::~MxBitmap() { - // TODO + if (this->m_info != NULL) { + delete m_info; + } + if (this->m_data != NULL) { + delete m_data; + } + if (this->m_palette != NULL) { + delete m_palette; + } } // OFFSET: LEGO1 0x100bd1c0 MxPalette *MxBitmap::CreatePalette() { - // TODO - return NULL; + // FIXME: This function needs MxPalette to be completed. Also INFERRING usage of MxBool + MxPalette *pal = NULL; + MxPalette *ppal; + MxBool success = FALSE; + + if(this->m_unk18 == FALSE) { + // ppal = MxPalette::FromBitmapPalette(this->m_paletteData); + } else { + if(this->m_unk18 != TRUE) { + if(!success && pal != NULL) { + delete pal; + pal = NULL; + } + } + //.pal = MxPalette::Clone(this->m_palette); + } + if(pal != NULL) { + success = TRUE; + } + + return pal; } // OFFSET: LEGO1 0x100bcd10 -long MxBitmap::Read(const char *) +long MxBitmap::Read(const char *filename) { - // TODO - return 0; + HANDLE handle; + int unk1; + MxResult ret = FAILURE; + + handle = CreateFileA(filename,GENERIC_READ,FILE_SHARE_READ,(LPSECURITY_ATTRIBUTES)NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,(HANDLE)NULL); + if(handle != (HANDLE)INVALID_HANDLE_VALUE) { // INVALID_HANDLE_VALUE = -1, or 0xffffffff + // FIXME: line 16. iVar gets changed in this line + if(unk1 == 0) { + ret = SUCCESS; + } + } + if(handle != (HANDLE)NULL) { + CloseHandle(handle); + } + + return ret; } + diff --git a/LEGO1/mxbitmap.h b/LEGO1/mxbitmap.h index 1fc54260..24d9e166 100644 --- a/LEGO1/mxbitmap.h +++ b/LEGO1/mxbitmap.h @@ -1,15 +1,26 @@ #ifndef MXBITMAP_H #define MXBITMAP_H -#include "mxpalette.h" +#include -class MxBitmap +#include "mxcore.h" +#include "mxpalette.h" +#include "mxtypes.h" + +class MxBitmap : public MxCore { public: __declspec(dllexport) MxBitmap(); __declspec(dllexport) virtual ~MxBitmap(); __declspec(dllexport) virtual MxPalette *CreatePalette(); __declspec(dllexport) virtual long Read(const char *); +private: + BITMAPINFO *m_info; + BITMAPINFOHEADER *m_bmiHeader; + RGBQUAD *m_paletteData; + LPVOID *m_data; + MxBool m_unk18; + MxPalette *m_palette; }; #endif // MXBITMAP_H