diff options
Diffstat (limited to 'engines/cine/bg.cpp')
-rw-r--r-- | engines/cine/bg.cpp | 101 |
1 files changed, 37 insertions, 64 deletions
diff --git a/engines/cine/bg.cpp b/engines/cine/bg.cpp index 4fc76d264c..9e53c2f33c 100644 --- a/engines/cine/bg.cpp +++ b/engines/cine/bg.cpp @@ -30,53 +30,44 @@ namespace Cine { uint16 bgVar0; void loadCtHigh(uint8 * currentPtr) { - currentPtr += 256 * 3; - memcpy(page3Raw, currentPtr, 320 * 200); } uint8 loadCt(const char *ctName) { - uint8 *ptr; - uint8 *currentPtr; - uint8 i; uint16 header[32]; - /// - strcpy(currentCtName, ctName); - currentPtr = ptr = readBundleFile(findFileInBundle(ctName)); + uint8 *ptr = readBundleFile(findFileInBundle(ctName)); if (gameType == Cine::GID_OS) { - if (READ_BE_UINT16(currentPtr) == 8) { // detect 256 color background - loadCtHigh(currentPtr + 2); - return 0; + uint16 bpp = READ_BE_UINT16(ptr); ptr += 2; + if (bpp == 8) { + ptr += 3 * 256; + loadCtHigh(ptr); + } else { + ptr += 32; + gfxResetRawPage(page3Raw); + gfxConvertSpriteToRaw(page3Raw, ptr, 160, 200); } - - currentPtr += 2; - - currentPtr += 0x20; - gfxResetRawPage(page3Raw); - gfxConvertSpriteToRaw(page3Raw, ptr + 0x22, 160, 200); } else { loadRelatedPalette(ctName); ASSERT(strstr(ctName, ".NEO")); - memcpy(header, currentPtr, 32); - currentPtr += 32; + memcpy(header, ptr, 32); ptr += 32; - for (i = 0; i < 16; i++) { + for (int i = 0; i < 16; i++) { header[i] = TO_BE_16(header[i]); } - gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200); + gfxConvertSpriteToRaw(page3Raw, ptr + 0x80 - 0x22, 160, 200); } return 0; } -void loadBgHigh(char *currentPtr) { +void loadBgHigh(const char *currentPtr) { memcpy(palette256, currentPtr, 256 * 3); currentPtr += 256 * 3; @@ -86,39 +77,28 @@ void loadBgHigh(char *currentPtr) { } uint8 loadBg(const char *bgName) { - uint8 *ptr; - uint8 *currentPtr; - uint8 i; - uint8 fileIdx; - strcpy(currentBgName[0], bgName); - fileIdx = findFileInBundle(bgName); - - currentPtr = ptr = readBundleFile(fileIdx); + uint8 fileIdx = findFileInBundle(bgName); + uint8 *ptr = readBundleFile(fileIdx); - if (READ_BE_UINT16(currentPtr) == 8) { // detect 256 color background - loadBgHigh((char *)currentPtr + 2); - return 0; - } + uint16 bpp = READ_BE_UINT16(ptr); ptr += 2; + if (bpp == 8) { + loadBgHigh((const char *)ptr); + } else { + colorMode256 = 0; - colorMode256 = 0; + memcpy(tempPalette, ptr, 32); ptr += 32; - memcpy(&dummyU16, currentPtr, 2); - currentPtr += 2; + for (int i = 0; i < 16; i++) { + tempPalette[i] = TO_BE_16(tempPalette[i]); + } - memcpy(tempPalette, currentPtr, 32); - currentPtr += 32; + loadRelatedPalette(bgName); - for (i = 0; i < 16; i++) { - tempPalette[i] = TO_BE_16(tempPalette[i]); + gfxResetRawPage(page2Raw); + gfxConvertSpriteToRaw(page2Raw, ptr, 160, 200); } - - loadRelatedPalette(bgName); - - gfxResetRawPage(page2Raw); - gfxConvertSpriteToRaw(page2Raw, ptr + 0x22, 160, 200); - return 0; } @@ -126,29 +106,22 @@ uint8 *additionalBgTable[9] = { page2Raw, NULL, NULL, NULL, NULL, NULL, NULL, NU uint8 currentAdditionalBgIdx = 0; uint8 currentAdditionalBgIdx2 = 0; -void addBackground(char *bgName, uint16 bgIdx) { - uint8 *ptr; - uint8 *currentPtr; - uint8 fileIdx; - +void addBackground(const char *bgName, uint16 bgIdx) { strcpy(currentBgName[bgIdx], bgName); - fileIdx = findFileInBundle(bgName); - - currentPtr = ptr = readBundleFile(fileIdx); + uint8 fileIdx = findFileInBundle(bgName); + uint8 *ptr = readBundleFile(fileIdx); additionalBgTable[bgIdx] = (uint8 *) malloc(320 * 200); - if (READ_BE_UINT16(currentPtr) == 8) { // detect 256 color background - memcpy(additionalBgTable[bgIdx], currentPtr + 2 + 3 * 256, 320 * 200); - return; + uint16 bpp = READ_BE_UINT16(ptr); ptr += 2; + if (bpp == 8) { + ptr += 3 * 256; + memcpy(additionalBgTable[bgIdx], ptr, 320 * 200); + } else { + ptr += 32; + gfxConvertSpriteToRaw(additionalBgTable[bgIdx], ptr, 160, 200); } - - currentPtr += 2; - - currentPtr += 0x20; - - gfxConvertSpriteToRaw(additionalBgTable[bgIdx], ptr + 0x22, 160, 200); } } // End of namespace Cine |