From 37e364b2c6cc7487a1c888d256a73e5337bb7189 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Jun 2023 00:50:34 +0100 Subject: initial commit --- src/T2DLL/T2PaletteAnimeDef.cpp | 112 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/T2DLL/T2PaletteAnimeDef.cpp (limited to 'src/T2DLL/T2PaletteAnimeDef.cpp') diff --git a/src/T2DLL/T2PaletteAnimeDef.cpp b/src/T2DLL/T2PaletteAnimeDef.cpp new file mode 100644 index 0000000..98628fc --- /dev/null +++ b/src/T2DLL/T2PaletteAnimeDef.cpp @@ -0,0 +1,112 @@ +#include "CResFile.h" +#include "GlobalFunc.h" +#include "T2PaletteAnimeDef.h" + +int DLL_EXPORT gCommonColor[20]; + +T2PaletteAnimeDef::T2PaletteAnimeDef(HINSTANCE instance, CResFile* resFile) { + int i, j; + + Init(); + + *resFile >> mNumOfTowerColor; + *resFile >> mNumOfAnimColor; + *resFile >> mAnimStartIndex; + *resFile >> mNumOfRefrectColor; + *resFile >> mNumOfSkyColor; + *resFile >> mNumOfSEKind; + *resFile >> mNumOfSEColor; + *resFile >> mSEInterval; + + LOGPALETTE *basePal = LoadACTPaletteEntries(instance, 100); +#line 22 + _ASSERT(basePal); + + for (i = mAnimStartIndex; i < (mAnimStartIndex + mNumOfAnimColor); i++) + basePal->palPalEntry[i].peFlags = PC_RESERVED; + basePal->palPalEntry[253].peFlags = PC_RESERVED; + basePal->palPalEntry[254].peFlags = PC_RESERVED; + + mTowerPalette = new CPalette; + mTowerPalette->CreatePalette(basePal); + + + mSEPalette = LoadACTPaletteEntries(instance, 102); +#line 31 + _ASSERT(mSEPalette); + + for (i = 0; i < (mNumOfSEKind * mNumOfSEColor); i++) + mSEPalette->palPalEntry[i].peFlags = PC_RESERVED; + + + mDayLightPalette = LoadACTPaletteEntries(instance, 101); +#line 36 + _ASSERT(mDayLightPalette); + + for (i = 0; i < (mNumOfRefrectColor + mNumOfSkyColor); i++) + mDayLightPalette->palPalEntry[i].peFlags = PC_RESERVED; + + + mUnknownPalette = LoadACTPaletteEntries(instance, 103); +#line 41 + _ASSERT(mUnknownPalette); + + gCommonColor[0] = 0; + gCommonColor[1] = 255; + for (i = 2; i <= 19; i++) { + if ( + mUnknownPalette->palPalEntry[i].peRed == 0 && + mUnknownPalette->palPalEntry[i].peGreen == 0 && + mUnknownPalette->palPalEntry[i].peBlue == 0 + ) + { + gCommonColor[i] = 255; + } + else { + for (j = 0; j < mNumOfTowerColor; j++) { + if ( + basePal->palPalEntry[j].peRed == mUnknownPalette->palPalEntry[i].peRed && + basePal->palPalEntry[j].peGreen == mUnknownPalette->palPalEntry[i].peGreen && + basePal->palPalEntry[j].peBlue == mUnknownPalette->palPalEntry[i].peBlue + ) + { + break; + } + } + +#line 53 + _ASSERT(j < mNumOfTowerColor); + gCommonColor[i] = j; + } + } + + free(basePal); +} + +T2PaletteAnimeDef::~T2PaletteAnimeDef() { + delete mTowerPalette; + free(mSEPalette); + free(mDayLightPalette); + free(mUnknownPalette); +} + +void T2PaletteAnimeDef::Init() { + mUnknownPalette = NULL; + mSEPalette = NULL; + mDayLightPalette = NULL; +} + +void T2PaletteAnimeDef::ReplaceDayLightPalette(HINSTANCE instance, int id) { + LOGPALETTE *pal = LoadACTPaletteEntries(instance, id); +#line 80 + _ASSERT(pal); + + for (int i = 0; i < (mNumOfRefrectColor + mNumOfSkyColor); i++) { + pal->palPalEntry[i].peFlags = PC_RESERVED; + mDayLightPalette->palPalEntry[i] = pal->palPalEntry[i]; + } +} + +/*static*/ int T2PaletteAnimeDef::GetCommonColor(int i) { + return gCommonColor[i]; +} -- cgit v1.2.3