diff options
Diffstat (limited to 'engines/cine/bg_list.cpp')
-rw-r--r-- | engines/cine/bg_list.cpp | 147 |
1 files changed, 135 insertions, 12 deletions
diff --git a/engines/cine/bg_list.cpp b/engines/cine/bg_list.cpp index 3b2026e7cf..8f46994aa3 100644 --- a/engines/cine/bg_list.cpp +++ b/engines/cine/bg_list.cpp @@ -22,32 +22,155 @@ * */ -#include "cine/bg_list.h" -#include "cine/gfx.h" +#include "common/stdafx.h" +#include "common/endian.h" +#include "common/stream.h" + +#include "cine/cine.h" +#include "cine/main_loop.h" #include "cine/object.h" -#include "cine/part.h" +#include "cine/various.h" +#include "cine/bg_list.h" namespace Cine { -void createVar9Element(int16 objIdx, int16 param); +uint32 var8; +BGIncrustList *bgIncrustList; -void addSpriteFilledToBGList(int16 idx) { +void addToBGList(int16 objIdx, bool addList) { int16 x; int16 y; int16 width; int16 height; + int16 part; + + x = objectTable[objIdx].x; + y = objectTable[objIdx].y; + + width = animDataTable[objectTable[objIdx].frame].var1; + height = animDataTable[objectTable[objIdx].frame].height; + + part = objectTable[objIdx].part; + + if (g_cine->getGameType() == GType_OS) { + drawSpriteRaw2(animDataTable[objectTable[objIdx].frame].ptr1, objectTable[objIdx].part, width, height, page2Raw, x, y); + } else { + drawSpriteRaw(animDataTable[objectTable[objIdx].frame].ptr1, animDataTable[objectTable[objIdx].frame].ptr2, width, height, page2Raw, x, y); + } + + if (addList) + createBgIncrustListElement(objIdx, 0); +} + +void addSpriteFilledToBGList(int16 objIdx, bool addList) { + int16 x; + int16 y; + int16 width; + int16 height; + + x = objectTable[objIdx].x; + y = objectTable[objIdx].y; + + width = animDataTable[objectTable[objIdx].frame].width; + height = animDataTable[objectTable[objIdx].frame].height; + + if (animDataTable[objectTable[objIdx].frame].ptr1) { + gfxFillSprite(animDataTable[objectTable[objIdx].frame].ptr1, width / 2, height, page2Raw, x, y); + } - x = objectTable[idx].x; - y = objectTable[idx].y; + if (addList) + createBgIncrustListElement(objIdx, 1); +} + +void createBgIncrustListElement(int16 objIdx, int16 param) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + BGIncrustList *bgIncrustPtrP = 0; + + // Find first empty element + while (bgIncrustPtr) { + bgIncrustPtrP = bgIncrustPtr; + bgIncrustPtr = bgIncrustPtr->next; + } + + bgIncrustPtr = (BGIncrustList *)malloc(sizeof(BGIncrustList)); + if (bgIncrustPtrP) + bgIncrustPtrP->next = bgIncrustPtr; + else + bgIncrustList = bgIncrustPtr; - width = animDataTable[objectTable[idx].frame].width; - height = animDataTable[objectTable[idx].frame].height; + bgIncrustPtr->next = 0; - if (animDataTable[objectTable[idx].frame].ptr1) { - gfxFillSprite(animDataTable[objectTable[idx].frame].ptr1, width / 2, height, page2Raw, x, y); + bgIncrustPtr->objIdx = objIdx; + bgIncrustPtr->param = param; + bgIncrustPtr->x = objectTable[objIdx].x; + bgIncrustPtr->y = objectTable[objIdx].y; + bgIncrustPtr->frame = objectTable[objIdx].frame; + bgIncrustPtr->part = objectTable[objIdx].part; +} + +void freeBgIncrustList(void) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + BGIncrustList *bgIncrustPtrN; + + while (bgIncrustPtr) { + bgIncrustPtrN = bgIncrustPtr->next; + free(bgIncrustPtr); + bgIncrustPtr = bgIncrustPtrN; } +} + +void resetBgIncrustList(void) { + bgIncrustList = NULL; + var8 = 0; +} + +void loadBgIncrustFromSave(Common::InSaveFile *fHandle) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + BGIncrustList *bgIncrustPtrP = 0; + + // Find first empty element + while (bgIncrustPtr) { + bgIncrustPtrP = bgIncrustPtr; + bgIncrustPtr = bgIncrustPtr->next; + } + + bgIncrustPtr = (BGIncrustList *)malloc(sizeof(BGIncrustList)); + if (bgIncrustPtrP) + bgIncrustPtrP->next = bgIncrustPtr; + else + bgIncrustList = bgIncrustPtr; + + bgIncrustPtr->next = 0; + + fHandle->readUint32BE(); + fHandle->readUint32BE(); + + bgIncrustPtr->objIdx = fHandle->readUint16BE(); + bgIncrustPtr->param = fHandle->readUint16BE(); + bgIncrustPtr->x = fHandle->readUint16BE(); + bgIncrustPtr->y = fHandle->readUint16BE(); + bgIncrustPtr->frame = fHandle->readUint16BE(); + bgIncrustPtr->part = fHandle->readUint16BE(); +} + +void reincrustAllBg(void) { + BGIncrustList *bgIncrustPtr = bgIncrustList; + + while (bgIncrustPtr) { +#if 0 + objectTable[bgIncrustPtr->objIdx].x = bgIncrustPtr->x; + objectTable[bgIncrustPtr->objIdx].y = bgIncrustPtr->y; + objectTable[bgIncrustPtr->objIdx].frame = bgIncrustPtr->frame; + objectTable[bgIncrustPtr->objIdx].part = bgIncrustPtr->part; +#endif + if (bgIncrustPtr->param == 0) { + addToBGList(bgIncrustPtr->objIdx, false); + } else { + addSpriteFilledToBGList(bgIncrustPtr->objIdx, false); + } - createVar9Element(idx, 1); + bgIncrustPtr = bgIncrustPtr->next; + } } } // End of namespace Cine |