diff --git a/LEGO1/mxpalette.cpp b/LEGO1/mxpalette.cpp index 36f8be83..c3440db2 100644 --- a/LEGO1/mxpalette.cpp +++ b/LEGO1/mxpalette.cpp @@ -5,8 +5,15 @@ MxPalette::MxPalette() { this->m_overrideSkyColor = FALSE; this->m_attached = NULL; - // GetDefaultSkyPalette - // this->m_skyColor = whatever it is once i figure out how m_palette works + GetDefaultPalette(this->m_entries); + this->m_skyColor = this->m_entries[0x8d]; + // FIXME: Incomplete +} + +// OFFSET: LEGO1 100bef90 +MxPalette::~MxPalette() +{ + delete m_attached; // yes this matches more } // OFFSET: LEGO1 0x100bf150 @@ -16,6 +23,23 @@ MxResult MxPalette::GetEntries(LPPALETTEENTRY p_entries) return SUCCESS; } +// OFFSET: LEGO1 0x100bf420 +void MxPalette::GetDefaultPalette(LPPALETTEENTRY p_entries) +{ + HDC hdc = GetDC((HWND) NULL); + int rasterCaps = GetDeviceCaps(hdc, RASTERCAPS); + if ((rasterCaps & RC_PALETTE) != 0) { + int paletteSize = GetDeviceCaps(hdc, SIZEPALETTE); + if (paletteSize == 256) { + GetSystemPaletteEntries(hdc, 0, 256, p_entries); + p_entries += 10; + memcpy(p_entries, this->m_entries, sizeof(this->m_entries)); + } + } + + ReleaseDC((HWND) NULL, hdc); +} + // OFFSET: LEGO1 0x100bf330 void MxPalette::Detach() { diff --git a/LEGO1/mxpalette.h b/LEGO1/mxpalette.h index 48ee5500..a8778924 100644 --- a/LEGO1/mxpalette.h +++ b/LEGO1/mxpalette.h @@ -14,6 +14,8 @@ public: __declspec(dllexport) void Detach(); MxPalette(); + ~MxPalette(); + void GetDefaultPalette(LPPALETTEENTRY p_entries); MxResult GetEntries(LPPALETTEENTRY p_entries); private: