Exemple #1
0
int loadResource(const char *fileName, short int arg_4, unsigned char** ptr)
{
	FILE* resourceFile;
	int headerSize;
	int offToData;
	int dataSize;
	int compressedSize;
	short int mode;
	unsigned char *temp;

	resourceFile=openResource(fileName);

	if(!resourceFile)
		return (-1);

	readResource(resourceFile,(char*)&headerSize,4);

	if(arg_4>=headerSize/4)
	{
		closeResource(resourceFile);
		return (-1);
	}

	fseek(resourceFile,arg_4*4,SEEK_SET);
	readResource(resourceFile,(char*)&offToData,4);

	fseek(resourceFile,offToData,SEEK_SET);
	readResource(resourceFile,(char*)&dataSize,4);
	readResource(resourceFile,(char*)&compressedSize,4);
	readResource(resourceFile,(char*)&mode,2);

	*ptr=(unsigned char*)malloc(dataSize);

	if(!(*ptr))
		return (-1);

	if(mode<=0) // uncompressed
	{
		readResource(resourceFile,(char*)*ptr,dataSize);
	}
	else // compressed: both modes (1 & 2)
	{
		temp=(unsigned char*)malloc(compressedSize);
   	    readResource(resourceFile,(char*)temp,compressedSize);
		decompResource(dataSize,*ptr,temp,(unsigned char)mode);
		free(temp);
   }

   closeResource(resourceFile);
   return dataSize;
}
Exemple #2
0
void ArchiveReader::dump(uint resIndex) {
	int32 resourceSize = getResourceSize(resIndex);
	byte *data = new byte[resourceSize];

	Common::String fn = Common::String::format("toltecs_res.%03d", resIndex);

	openResource(resIndex);
	read(data, resourceSize);
	closeResource();

	Common::DumpFile o;
	o.open(fn);
	o.write(data, resourceSize);
	o.finalize();
	o.close();

	delete[] data;
}
Exemple #3
0
void ArchiveReader::dump(uint resIndex, const char *prefix) {
	int32 resourceSize = getResourceSize(resIndex);
	byte *data = new byte[resourceSize];

	Common::String fn;
	
	if (prefix)
		fn = Common::String::format("%s_%04X.0", prefix, resIndex);
	else
		fn = Common::String::format("%04X.0", resIndex);

	openResource(resIndex);
	read(data, resourceSize);
	closeResource();

	Common::DumpFile o;
	o.open(fn);
	o.write(data, resourceSize);
	o.finalize();
	o.close();

	delete[] data;
}
Exemple #4
0
void ResourceManager::askForCD(int cd) {
    byte *textRes;

    // Stop any music from playing - so the system no longer needs the
    // current CD - otherwise when we take out the CD, Windows will
    // complain!

    _vm->_sound->stopMusic(true);

    textRes = openResource(2283);
    _vm->_screen->displayMsg(_vm->fetchTextLine(textRes, 5 + cd) + 2, 0);
    closeResource(2283);

    // The original code probably determined automagically when the correct
    // CD had been inserted, but our backend doesn't support that, and
    // anyway I don't know if all systems allow that sort of thing. So we
    // wait for the user to press any key instead, or click the mouse.
    //
    // But just in case we ever try to identify the CDs by their labels,
    // they should be:
    //
    // CD1: "RBSII1" (or "PCF76" for the PCF76 version, whatever that is)
    // CD2: "RBSII2"
}