byte loadCtFW(const char *ctName) { debugC(1, kCineDebugCollision, "loadCtFW(\"%s\")", ctName); uint16 header[32]; byte *ptr, *dataPtr; int16 foundFileIdx = findFileInBundle(ctName); if (foundFileIdx == -1) { warning("loadCtFW: Unable to find collision data file '%s'", ctName); // FIXME: Rework this function's return value policy and return an appropriate value here. // The return value isn't yet used for anything so currently it doesn't really matter. return 0; } if (currentCtName != ctName) strcpy(currentCtName, ctName); ptr = dataPtr = readBundleFile(foundFileIdx); loadRelatedPalette(ctName); assert(strstr(ctName, ".NEO")); Common::MemoryReadStream readS(ptr, 32); for (int i = 0; i < 16; i++) { header[i] = readS.readUint16BE(); } gfxConvertSpriteToRaw(collisionPage, ptr + 0x80, 160, 200); free(dataPtr); return 0; }
byte loadCt(const char *ctName) { uint16 header[32]; strcpy(currentCtName, ctName); byte *ptr = readBundleFile(findFileInBundle(ctName)); if (gameType == Cine::GID_OS) { 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); } } else { loadRelatedPalette(ctName); assert(strstr(ctName, ".NEO")); Common::MemoryReadStream readS(ptr, 32); for (int i = 0; i < 16; i++) { header[i] = readS.readUint16BE(); } gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200); } return 0; }
/** * Load animDataTable from save * @param fHandle Savefile open for reading * @param saveGameFormat The used savegame format * @todo Add Operation Stealth savefile support * * Unlike the old code, this one actually rebuilds the table one frame * at a time. */ void loadResourcesFromSave(Common::SeekableReadStream &fHandle, enum CineSaveGameFormat saveGameFormat) { int16 foundFileIdx; char *animName, part[256], name[10]; strcpy(part, currentPartName); // We only support these variations of the savegame format at the moment. assert(saveGameFormat == ANIMSIZE_23 || saveGameFormat == ANIMSIZE_30_PTRS_INTACT); const int entrySize = ((saveGameFormat == ANIMSIZE_23) ? 23 : 30); const int fileStartPos = fHandle.pos(); for(int resourceIndex=0; resourceIndex<NUM_MAX_ANIMDATA; resourceIndex++) { // Seek to the start of the current animation's entry fHandle.seek(fileStartPos + resourceIndex * entrySize); // Read in the current animation entry fHandle.readUint16BE(); // width fHandle.readUint16BE(); fHandle.readUint16BE(); // bpp fHandle.readUint16BE(); // height bool validPtr = false; // Handle variables only present in animation entries of size 30 if (entrySize == 30) { validPtr = (fHandle.readUint32BE() != 0); // Read data pointer fHandle.readUint32BE(); // Discard mask pointer } foundFileIdx = fHandle.readSint16BE(); int16 frameIndex = fHandle.readSint16BE(); // frame fHandle.read(name, 10); // Handle variables only present in animation entries of size 23 if (entrySize == 23) { validPtr = (fHandle.readByte() != 0); } // Don't try to load invalid entries. if (foundFileIdx < 0 || !validPtr) { //resourceIndex++; // Jump over the invalid entry continue; } // Alright, the animation entry looks to be valid so let's start handling it... if (strcmp(currentPartName, name) != 0) { closePart(); loadPart(name); } animName = g_cine->_partBuffer[foundFileIdx].partName; loadRelatedPalette(animName); // Is this for Future Wars only? loadResource(animName, resourceIndex, frameIndex); } loadPart(part); // Make sure we jump over all the animation entries fHandle.seek(fileStartPos + NUM_MAX_ANIMDATA * entrySize); }
void loadTextData(const char *pFileName, byte *pDestinationBuffer) { Common::File pFileHandle; uint16 entrySize; uint16 numEntry; uint16 i; byte *tempBuffer; uint16 dataSize; assert(pFileName); assert(pDestinationBuffer); pFileHandle.open(pFileName); assert(pFileHandle.isOpen()); entrySize = pFileHandle.readUint16BE(); numEntry = pFileHandle.readUint16BE(); dataSize = numEntry * entrySize; pFileHandle.read(pDestinationBuffer, numEntry * entrySize); tempBuffer = pDestinationBuffer; if (gameType == Cine::GID_FW) { dataSize = dataSize / 0x4E; loadRelatedPalette(pFileName); for (i = 0; i < 0x4E; i++) { gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 16, 8); generateMask(textTable[i][0], textTable[i][1], 16 * 8, 0); tempBuffer += dataSize; } } else { for (i = 0; i < 90; i++) { gfxConvertSpriteToRaw(textTable[i][0], tempBuffer, 8, 8); generateMask(textTable[i][0], textTable[i][1], 8 * 8, 0); tempBuffer += 0x40; } } pFileHandle.close(); }
byte loadBg(const char *bgName) { byte *ptr, *dataPtr; byte fileIdx = findFileInBundle(bgName); ptr = dataPtr = readBundleFile(fileIdx); uint16 bpp = READ_BE_UINT16(ptr); ptr += 2; if (bpp == 8) { renderer->loadBg256(ptr, bgName); } else { if (g_cine->getGameType() == Cine::GType_FW) { loadRelatedPalette(bgName); } renderer->loadBg16(ptr, bgName); } free(dataPtr); return 0; }
byte loadBg(const char *bgName) { strcpy(currentBgName[0], bgName); byte fileIdx = findFileInBundle(bgName); byte *ptr = readBundleFile(fileIdx); uint16 bpp = READ_BE_UINT16(ptr); ptr += 2; if (bpp == 8) { loadBgHigh((const char *)ptr); } else { colorMode256 = 0; for (int i = 0; i < 16; i++) { tempPalette[i] = READ_BE_UINT16(ptr); ptr += 2; } loadRelatedPalette(bgName); gfxResetRawPage(page2Raw); gfxConvertSpriteToRaw(page2Raw, ptr, 160, 200); } return 0; }