summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PaletteAnimeDef.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
committerAsh Wolf <ninji@wuffs.org>2023-06-14 00:50:34 +0100
commit37e364b2c6cc7487a1c888d256a73e5337bb7189 (patch)
treeeaf6e857382eef16c2dd940eb4125536fbe068bd /src/T2DLL/T2PaletteAnimeDef.cpp
downloadt2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.tar.gz
t2win-37e364b2c6cc7487a1c888d256a73e5337bb7189.zip
initial commit
Diffstat (limited to '')
-rw-r--r--src/T2DLL/T2PaletteAnimeDef.cpp112
1 files changed, 112 insertions, 0 deletions
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];
+}