bool Cutscene::readFrameHeader(CinFrameHeader *hdr) { hdr->videoFrameType = fileReadByte(_fp); hdr->soundFrameType = fileReadByte(_fp); hdr->palColorsCount = fileReadUint16LE(_fp); hdr->videoFrameSize = fileReadUint32LE(_fp); hdr->soundFrameSize = fileReadUint32LE(_fp); hdr->mark = fileReadUint32LE(_fp); return !fileEof(_fp) && hdr->mark == 0xAA55AA55; }
bool Cutscene::readFileHeader(CinFileHeader *hdr) { hdr->mark = fileReadUint32LE(_fp); hdr->videoFrameSize = fileReadUint32LE(_fp); hdr->videoFrameWidth = fileReadUint16LE(_fp); hdr->videoFrameHeight = fileReadUint16LE(_fp); hdr->soundFreq = fileReadUint32LE(_fp); hdr->soundBits = fileReadByte(_fp); hdr->soundStereo = fileReadByte(_fp); hdr->soundFrameSize = fileReadUint16LE(_fp); return !fileEof(_fp) && (hdr->mark >> 16) == 0x55AA; }
void Sound::loadDigiSnd(FILE *fp) { struct { uint32_t name; uint32_t data; } offsets[1024]; _digiCount = 0; for (int i = 0; i < 1024; ++i) { offsets[i].name = fileReadUint32LE(fp); offsets[i].data = fileReadUint32LE(fp); if (i != 0 && offsets[i].name == offsets[0].data) { _digiCount = i; break; } } _digiTable = (DigiSnd *)calloc(_digiCount, sizeof(DigiSnd)); if (_digiTable) { for (int i = 0; i < _digiCount; ++i) { fileSetPos(fp, offsets[i].name, kFilePosition_SET); char *p = _digiTable[i].name; for (int j = 0; j < 16; ++j) { p[j] = fileReadByte(fp); if (p[j] == 0) { break; } } _digiTable[i].offset = offsets[i].data; _digiTable[i].size = offsets[i + 1].data - offsets[i].data; } } }
uint16 ScummDiskImage::extractIndex(Common::WriteStream *out) { int i; uint16 reslen = 0; openDisk(1); if (_game.platform == Common::kPlatformApple2GS) { File::seek(142080); } else { File::seek(0); } // skip signature fileReadUint16LE(); // write expected signature if (_game.platform == Common::kPlatformApple2GS) { reslen += write_word(out, 0x0032); } else { reslen += write_word(out, 0x0132); } // copy object flags for (i = 0; i < _numGlobalObjects; i++) reslen += write_byte(out, fileReadByte()); // copy room offsets for (i = 0; i < _numRooms; i++) { _roomDisks[i] = fileReadByte(); reslen += write_byte(out, _roomDisks[i]); } for (i = 0; i < _numRooms; i++) { _roomSectors[i] = fileReadByte(); reslen += write_byte(out, _roomSectors[i]); _roomTracks[i] = fileReadByte(); reslen += write_byte(out, _roomTracks[i]); } for (i = 0; i < _numCostumes; i++) reslen += write_byte(out, fileReadByte()); for (i = 0; i < _numCostumes; i++) reslen += write_word(out, fileReadUint16LE()); for (i = 0; i < _numScripts; i++) reslen += write_byte(out, fileReadByte()); for (i = 0; i < _numScripts; i++) reslen += write_word(out, fileReadUint16LE()); for (i = 0; i < _numSounds; i++) reslen += write_byte(out, fileReadByte()); for (i = 0; i < _numSounds; i++) reslen += write_word(out, fileReadUint16LE()); return reslen; }
uint16 ScummDiskImage::extractResource(Common::WriteStream *out, int res) { const int AppleSectorOffset[36] = { 0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 416, 432, 448, 464, 480, 496, 512, 528, 544, 560 }; const int C64SectorOffset[36] = { 0, 0, 21, 42, 63, 84, 105, 126, 147, 168, 189, 210, 231, 252, 273, 294, 315, 336, 357, 376, 395, 414, 433, 452, 471, 490, 508, 526, 544, 562, 580, 598, 615, 632, 649, 666 }; int i; uint16 reslen = 0; openDisk(_roomDisks[res]); if (_game.platform == Common::kPlatformApple2GS) { File::seek((AppleSectorOffset[_roomTracks[res]] + _roomSectors[res]) * 256); } else { File::seek((C64SectorOffset[_roomTracks[res]] + _roomSectors[res]) * 256); } for (i = 0; i < _resourcesPerFile[res]; i++) { uint16 len; do { // Note: len might be 0xFFFF for padding in zak-c64-german len = fileReadUint16LE(); reslen += write_word(out, len); } while (len == 0xFFFF); for (len -= 2; len > 0; len--) reslen += write_byte(out, fileReadByte()); } return reslen; }
uint16 ScummDiskImage::fileReadUint16LE() { uint16 a = fileReadByte(); uint16 b = fileReadByte(); return a | (b << 8); }