diff --git a/engines/chewy/globals.h b/engines/chewy/globals.h index 96a895f92fa..0b7278e6d63 100644 --- a/engines/chewy/globals.h +++ b/engines/chewy/globals.h @@ -340,7 +340,7 @@ void delInventory(int16 nr); bool isCurInventory(int16 nr); -void checkShadow(int16 palIdx, int16 mode); +void setShadowPalette(int16 palIdx, bool setPartialPalette); void get_scroll_off(int16 x, int16 y, int16 pic_x, int16 pic_y, int16 *sc_x, int16 *sc_y); diff --git a/engines/chewy/main.cpp b/engines/chewy/main.cpp index ffb3f80e7a3..ec67eaeb99b 100644 --- a/engines/chewy/main.cpp +++ b/engines/chewy/main.cpp @@ -512,7 +512,7 @@ void setupScreen(SetupScreenMode mode) { const int16 paletteId = _G(barriers)->getBarrierId( _G(moveState)[P_CHEWY].Xypos[0] + _G(spieler_mi)[P_CHEWY].HotX, _G(moveState)[P_CHEWY].Xypos[1] + _G(spieler_mi)[P_CHEWY].HotY); - checkShadow(paletteId, 0); + setShadowPalette(paletteId, false); } else { for (i = 0; i < MAX_PERSON; i++) { mov_objekt(&_G(moveState)[i], &_G(spieler_mi)[i]); @@ -1009,31 +1009,24 @@ void swap_if_l(int16 *x1, int16 *x2) { } } -void palcopy(byte *destPal, const byte *srcPal, int16 destStartIndex, int16 srcStartIndex, int16 colorNbr) { - int16 j = srcStartIndex; - for (int16 i = destStartIndex; i < destStartIndex + colorNbr; ++i) { - destPal[i * 3] = srcPal[j * 3]; - destPal[i * 3 + 1] = srcPal[j * 3 + 1]; - destPal[i * 3 + 2] = srcPal[j * 3 + 2]; - ++j; - } -} - -void checkShadow(int16 palIdx, int16 mode) { +void setShadowPalette(int16 palIdx, bool setPartialPalette) { static const uint8 PAL_0[] = { 0, 0, 0, 39, 0, 26, 43, 0, 29, 51, 42, 29, + 51, 0, 34, 49, 13, 34, 55, 0, 37, 63, 54, 40, + 63, 0, 42, 63, 30, 42, 63, 12, 46, 63, 24, 50 }; + static const uint8 PAL_1[] = { 0, 0, 0, 34, 0, 21, @@ -1050,6 +1043,7 @@ void checkShadow(int16 palIdx, int16 mode) { 58, 7, 41, 58, 19, 45 }; + static const uint8 PAL_2[] = { 0, 0, 0, 26, 0, 13, @@ -1066,6 +1060,7 @@ void checkShadow(int16 palIdx, int16 mode) { 50, 0, 33, 50, 11, 37 }; + static const uint8 PAL_3[] = { 0, 0, 0, 21, 3, 8, @@ -1083,34 +1078,21 @@ void checkShadow(int16 palIdx, int16 mode) { 45, 6, 32 }; - switch (palIdx) { - case 1: - if (mode) - _G(out)->set_partialpalette(PAL_1, 1, 11); - palcopy(_G(pal), PAL_1, 0, 0, 12); - break; + const uint8 *palette; + if (palIdx == 1) + palette = PAL_1; + else if (palIdx == 2) + palette = PAL_2; + else if (palIdx == 3) + palette = PAL_3; + else if (palIdx == 4) + palette = PAL_0; + else + return; - case 2: - if (mode) - _G(out)->set_partialpalette(PAL_2, 1, 11); - palcopy(_G(pal), PAL_2, 0, 0, 12); - break; - - case 3: - if (mode) - _G(out)->set_partialpalette(PAL_3, 1, 11); - palcopy(_G(pal), PAL_3, 0, 0, 12); - break; - - case 4: - if (mode) - _G(out)->set_partialpalette(PAL_0, 1, 11); - palcopy(_G(pal), PAL_0, 0, 0, 12); - break; - - default: - break; - } + if (setPartialPalette) + _G(out)->set_partialpalette(palette, 1, 11); + memcpy(_G(pal), palette, 12 * 3); } void printShadowed(int16 x, int16 y, int16 fgCol, int16 bgCol, int16 shadowFgCol, int16 scrWidth, const char *txtPtr) { @@ -1684,7 +1666,7 @@ void calc_ausgang(int16 x, int16 y) { const int16 paletteId = _G(barriers)->getBarrierId(_G(moveState)[P_CHEWY].Xypos[0] + _G(spieler_mi)[P_CHEWY].HotX, _G(moveState)[P_CHEWY].Xypos[1] + _G(spieler_mi)[P_CHEWY].HotY); - checkShadow(paletteId, 0); + setShadowPalette(paletteId, false); setPersonSpr(_G(Rdi)->AutoMov[_G(gameState).room_e_obj[nr].ExitMov]._sprNr, P_CHEWY); _G(moveState)[P_CHEWY]._delayCount = 0; _G(fx_blend) = BLEND1; diff --git a/engines/chewy/r_event.cpp b/engines/chewy/r_event.cpp index 5238c8e4dd7..bf5c20f8c18 100644 --- a/engines/chewy/r_event.cpp +++ b/engines/chewy/r_event.cpp @@ -1113,7 +1113,7 @@ int16 sib_event_no_inv(int16 sib_nr) { case SIB_LAMPE_R52: _G(atds)->delControlBit(338, ATS_ACTIVE_BIT); _G(gameState).R52LichtAn ^= 1; - checkShadow(2 * (_G(gameState).R52LichtAn + 1), 1); + setShadowPalette(2 * (_G(gameState).R52LichtAn + 1), true); break; case SIB_KAUTABAK_R56: diff --git a/engines/chewy/rooms/room00.cpp b/engines/chewy/rooms/room00.cpp index 6168796624b..57a7686b65d 100644 --- a/engines/chewy/rooms/room00.cpp +++ b/engines/chewy/rooms/room00.cpp @@ -752,7 +752,7 @@ void Room0::feederAni() { _G(Rdi)->AutoMov[4]._y - CH_HOT_MOV_Y, P_CHEWY, P_RIGHT); _G(moveState)[P_CHEWY]._delayCount = 0; - checkShadow(4, 0); + setShadowPalette(4, false); _G(fx_blend) = BLEND1; setupScreen(DO_SETUP); } else { diff --git a/engines/chewy/rooms/room02.cpp b/engines/chewy/rooms/room02.cpp index 753cc13b59a..6a345bca5ad 100644 --- a/engines/chewy/rooms/room02.cpp +++ b/engines/chewy/rooms/room02.cpp @@ -52,7 +52,7 @@ void Room2::jump_out_r1(int16 nr) { _G(gameState)._personHide[P_CHEWY] = false; clear_prog_ani(); switchRoom(1); - checkShadow(2, 1); + setShadowPalette(2, true); } void Room2::electrifyWalkway1() { diff --git a/engines/chewy/rooms/room52.cpp b/engines/chewy/rooms/room52.cpp index 31a9425fec0..82f6586bdcd 100644 --- a/engines/chewy/rooms/room52.cpp +++ b/engines/chewy/rooms/room52.cpp @@ -53,7 +53,7 @@ void Room52::entry() { autoMove(2, P_CHEWY); _G(gameState).R52TuerAuf = false; _G(det)->hideStaticSpr(4); - checkShadow(2, 1); + setShadowPalette(2, true); } } diff --git a/engines/chewy/rooms/room63.cpp b/engines/chewy/rooms/room63.cpp index e5619945f18..0de7c58f254 100644 --- a/engines/chewy/rooms/room63.cpp +++ b/engines/chewy/rooms/room63.cpp @@ -137,7 +137,7 @@ void Room63::bork_platt() { flic_cut(FCUT_081); flic_cut(FCUT_082); _G(gameState)._personHide[P_CHEWY] = false; - checkShadow(4, 1); + setShadowPalette(4, true); _G(spieler_mi)[P_CHEWY].Mode = true; autoMove(6, P_CHEWY); _G(spieler_mi)[P_CHEWY].Mode = false; diff --git a/engines/chewy/sprite.cpp b/engines/chewy/sprite.cpp index 9cfb51da073..1ff46c0105d 100644 --- a/engines/chewy/sprite.cpp +++ b/engines/chewy/sprite.cpp @@ -324,7 +324,7 @@ void setPersonPos(int16 x, int16 y, int16 personNr, int16 direction) { _G(atds)->set_split_win(tmpNr, x1, y1); if (!_G(flags).ExitMov && personNr == P_CHEWY) { const int16 paletteId = _G(barriers)->getBarrierId(x + _G(spieler_mi)[personNr].HotX, y + _G(spieler_mi)[personNr].HotY); - checkShadow(paletteId, 1); + setShadowPalette(paletteId, true); } } @@ -795,7 +795,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) { tmpy = 1; } if (mi->Id == CHEWY_OBJ) - checkShadow(u_index, 1); + setShadowPalette(u_index, true); if (abs(om->Xypos[1] - mi->XyzEnd[1]) <= abs(tmpy)) { om->Count = 0; @@ -832,7 +832,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) { tmpx = 1; } if (mi->Id == CHEWY_OBJ) - checkShadow(u_index, 1); + setShadowPalette(u_index, true); if (abs(om->Xypos[0] - mi->XyzEnd[0]) <= abs(tmpx)) { om->Count = 0; @@ -864,7 +864,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) { } } else { if (mi->Id == CHEWY_OBJ) - checkShadow(u_index, 1); + setShadowPalette(u_index, true); om->Xypos[0] += tmpx; om->Xypos[1] += tmpy; om->Xypos[2] += tmpz; @@ -889,7 +889,7 @@ void mov_objekt(ObjMov *om, MovInfo *mi) { if (mi->Id == CHEWY_OBJ) { u_index = _G(barriers)->getBarrierId(om->Xypos[0] + mi->HotX, om->Xypos[1] + mi->HotY); - checkShadow(u_index, 1); + setShadowPalette(u_index, true); } } if (mi->Id == CHEWY_OBJ) {