/* ScummVM - Scumm Interpreter * Copyright (C) 2006 The ScummVM project * * cinE Engine is (C) 2004-2005 by CinE Team * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $URL$ * $Id$ * */ #include "cruise/cruise_main.h" namespace Cruise { FILE* PAL_fileHandle = NULL; uint8* PAL_ptr = NULL; int16 numLoadedPal; int16 fileData2; void loadPal(volumeDataStruct* entry) { char name[20]; return; if(PAL_fileHandle) { fclose(PAL_fileHandle); } removeExtention(entry->ident, name); strcat(name,".PAL"); PAL_fileHandle = fopen(name,"rb"); fread(&numLoadedPal, 2, 1, PAL_fileHandle); fread(&fileData2, 2, 1, PAL_fileHandle); flipShort(&numLoadedPal); flipShort(&fileData2); PAL_ptr = (uint8*)malloc(numLoadedPal*fileData2); } int getVolumeDataEntry(volumeDataStruct* entry) { char buffer[256]; int i; volumeNumEntry = 0; volumeNumberOfEntry = 0; if(currentVolumeFile.isOpen()) { freeDisk(); } askDisk(-1); strcpyuint8(buffer,entry->ident); currentVolumeFile.open(buffer); if(!currentVolumeFile.isOpen()) { return(-14); } changeCursor(1); currentVolumeFile.read(&volumeNumberOfEntry,2); currentVolumeFile.read(&volumeSizeOfEntry,2); flipShort(&volumeNumberOfEntry); flipShort(&volumeSizeOfEntry); volumeNumEntry = volumeNumberOfEntry; assert(volumeSizeOfEntry == 14+4+4+4+4); volumePtrToFileDescriptor = (fileEntry*)mallocAndZero(sizeof(fileEntry) * volumeNumEntry); for(i=0;i='a' && character<='z') { character&=0xDF; *fileName = character; } fileName++; }while(character); } int16 fileExist(uint8* fileName) { FILE* fHandle; fHandle = fopenuint8(fileName,"rb"); if(fHandle) { fclose(fHandle); return(0); } return(1); } void freeDisk(void) { if(currentVolumeFile.isOpen()) { currentVolumeFile.close(); free(volumePtrToFileDescriptor); } /* TODO if(PAL_fileHandle) { freeAllDataPtr(); } */ } int16 findFileInList(uint8* fileName) { int i; if(!currentVolumeFile.isOpen()) { return(-1); } strToUpper(fileName); if(volumeNumEntry<=0) { return(-1); } for(i=0;i=0) { return(fileIdx); } disk = searchFileInVolCnf(fileName,currentDiskNumber); if(disk>=0) { int temp; printf("File found on disk %d\n", disk); if(currentVolumeFile.isOpen()) { askDisk(-1); } freeDisk(); askDisk(volumeData[disk].diskNumber); getVolumeDataEntry(&volumeData[disk]); temp = findFileInList(fileName); if(temp>=0) return(temp); return(-1); } else { int temp; temp = findFileInDisksSub1(fileName); if(temp>=0) { int temp2; askDisk(volumeData[temp].diskNumber); getVolumeDataEntry(&volumeData[temp]); temp2 = findFileInList(fileName); if(temp2>=0) return(temp2); } return(-1); } } int16 readVolCnf(void) { int i; Common::File fileHandle; short int sizeHEntry; volumeDataLoaded = 0; for(i=0;i<20;i++) { volumeData[i].ident[0] = 0; volumeData[i].ptr = NULL; volumeData[i].diskNumber = i+1; volumeData[i].size = 0; } fileHandle.open("VOL.CNF"); if(!fileHandle.isOpen()) { return(0); } fileHandle.read(&numOfDisks,2); flipShort(&numOfDisks); fileHandle.read(&sizeHEntry,2); flipShort(&sizeHEntry); // size of one header entry - 20 bytes for(i=0;i