[Scummvm-cvs-logs] CVS: scummvm/sky control.cpp,1.77,1.78 disk.cpp,1.58,1.59 disk.h,1.15,1.16 grid.cpp,1.16,1.17 grid.h,1.8,1.9 intro.cpp,1.50,1.51 logic.cpp,1.146,1.147 mouse.cpp,1.35,1.36 screen.cpp,1.61,1.62 sky.cpp,1.152,1.153 sound.cpp,1.47,1.48 text.cpp,1.61,1.62

Robert Göffringmann lavosspawn at users.sourceforge.net
Thu Nov 11 02:15:02 CET 2004


Update of /cvsroot/scummvm/scummvm/sky
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29202/sky

Modified Files:
	control.cpp disk.cpp disk.h grid.cpp grid.h intro.cpp 
	logic.cpp mouse.cpp screen.cpp sky.cpp sound.cpp text.cpp 
Log Message:
misc cleanup

Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/control.cpp,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- control.cpp	28 Sep 2004 20:19:31 -0000	1.77
+++ control.cpp	11 Nov 2004 10:14:30 -0000	1.78
@@ -246,19 +246,19 @@
 	uint16 spdY = (SkyEngine::_systemVars.gameSpeed - 2) / SPEED_MULTIPLY;
 	spdY += MPNL_Y + 83; // speed slider's initial position
 
-	_sprites.controlPanel	= _skyDisk->loadFile(60500, NULL);
-	_sprites.button			= _skyDisk->loadFile(60501, NULL);
-	_sprites.buttonDown		= _skyDisk->loadFile(60502, NULL);
-	_sprites.savePanel		= _skyDisk->loadFile(60503, NULL);
-	_sprites.yesNo			= _skyDisk->loadFile(60504, NULL);
-	_sprites.slide			= _skyDisk->loadFile(60505, NULL);
-	_sprites.slode			= _skyDisk->loadFile(60506, NULL);
-	_sprites.slode2			= _skyDisk->loadFile(60507, NULL);
-	_sprites.slide2			= _skyDisk->loadFile(60508, NULL);
+	_sprites.controlPanel	= _skyDisk->loadFile(60500);
+	_sprites.button			= _skyDisk->loadFile(60501);
+	_sprites.buttonDown		= _skyDisk->loadFile(60502);
+	_sprites.savePanel		= _skyDisk->loadFile(60503);
+	_sprites.yesNo			= _skyDisk->loadFile(60504);
+	_sprites.slide			= _skyDisk->loadFile(60505);
+	_sprites.slode			= _skyDisk->loadFile(60506);
+	_sprites.slode2			= _skyDisk->loadFile(60507);
+	_sprites.slide2			= _skyDisk->loadFile(60508);
 	if (SkyEngine::_systemVars.gameVersion < 368) 
 		_sprites.musicBodge = NULL;
 	else
-		_sprites.musicBodge = _skyDisk->loadFile(60509, NULL);
+		_sprites.musicBodge = _skyDisk->loadFile(60509);
 
 	//Main control panel:                                            X    Y Text       OnClick
 	_controlPanel     = createResource(_sprites.controlPanel, 1, 0,  0,   0,  0,      DO_NOTHING, MAINPANEL);
@@ -1538,7 +1538,7 @@
 	*(uint32 *)saveData = TO_LE_32(infSize);
 
 	if (inf->read(saveData+4, infSize-4) != infSize-4) {
-		displayMessage("Can't read from file '%s'", fName);
+		displayMessage(NULL, "Can't read from file '%s'", fName);
 		free(saveData);
 		delete inf;
 		return RESTORE_FAILED;

Index: disk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/disk.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- disk.cpp	19 Aug 2004 11:16:55 -0000	1.58
+++ disk.cpp	11 Nov 2004 10:14:35 -0000	1.59
@@ -42,8 +42,8 @@
 	uint32 entriesRead;
 
 	_dnrHandle->open(dinnerFilename);
-	if (_dnrHandle->isOpen() == false)
-			error("Could not open %s%s", gameDataPath.c_str(), dinnerFilename);
+	if (!_dnrHandle->isOpen())
+		error("Could not open %s%s", gameDataPath.c_str(), dinnerFilename);
 
 	if (!(_dinnerTableEntries = _dnrHandle->readUint32LE()))
 		error("Error reading from sky.dnr"); //even though it was opened correctly?!
@@ -55,7 +55,7 @@
 		warning("entriesRead != dinnerTableEntries. [%d/%d]", entriesRead, _dinnerTableEntries);
 
 	_dataDiskHandle->open(dataFilename);
-	if (_dataDiskHandle->isOpen() == false) 
+	if (!_dataDiskHandle->isOpen()) 
 		error("Error opening %s%s", gameDataPath.c_str(), dataFilename);
 
 	printf("Found BASS version v0.0%d (%d dnr entries)\n", determineGameVersion(), _dinnerTableEntries);
@@ -73,8 +73,10 @@
 		fEntry = fEntry->next;
 		delete fTemp;
 	}
-	if (_dnrHandle->isOpen()) _dnrHandle->close();
-	if (_dataDiskHandle->isOpen()) _dataDiskHandle->close();
+	if (_dnrHandle->isOpen())
+		_dnrHandle->close();
+	if (_dataDiskHandle->isOpen())
+		_dataDiskHandle->close();
 	delete _dnrHandle;
 	delete _dataDiskHandle;
 }
@@ -96,133 +98,101 @@
 	return (getFileInfo(fileNr) != NULL);
 }
 
-//load in file file_nr to address dest
-//if dest == NULL, then allocate memory for this file
-uint8 *Disk::loadFile(uint16 fileNr, uint8 *dest) {
-	
+// allocate memory, load the file and return a pointer
+uint8 *Disk::loadFile(uint16 fileNr) {
+
 	uint8 cflag;
-	int32 bytesRead;
-	uint8 *filePtr, *inputPtr, *outputPtr;
-	dataFileHeader fileHeader;
 
 	uint8 *prefData = givePrefetched(fileNr, &_lastLoadedFileSize);
-	if (prefData) {
-		if (dest == NULL) return prefData;
-		else {
-			memcpy(dest, prefData, _lastLoadedFileSize);
-			free(prefData);
-			return dest;
-		}
-	}
+	if (prefData)
+		return prefData;
 
-	_compFile = fileNr;
 	debug(2, "load file %d,%d (%d)", (fileNr >> 11), (fileNr & 2047), fileNr); 
 
-	filePtr = getFileInfo(fileNr);
-	if (filePtr == NULL) {
+	uint8 *fileInfoPtr = getFileInfo(fileNr);
+	if (fileInfoPtr == NULL) {
 		debug(1, "File %d not found", fileNr);
 		return NULL;
 	}
 
-	_fileFlags = READ_LE_UINT24(filePtr + 5);
-	_fileSize = _fileFlags & 0x03fffff;
-	_lastLoadedFileSize = _fileSize;
-	
-	_fileOffset = READ_LE_UINT32(filePtr + 2) & 0x0ffffff;
+	uint32 fileFlags = READ_LE_UINT24(fileInfoPtr + 5);
+	uint32 fileSize = fileFlags & 0x03fffff;
+	uint32 fileOffset = READ_LE_UINT32(fileInfoPtr + 2) & 0x0ffffff;
 
-	cflag = (uint8)((_fileOffset >> 23) & 0x1);
-	_fileOffset &= 0x7FFFFF;
+	_lastLoadedFileSize = fileSize;
+	cflag = (uint8)((fileOffset >> 23) & 0x1);
+	fileOffset &= 0x7FFFFF;
 
 	if (cflag) {
 		if (SkyEngine::_systemVars.gameVersion == 331)
-			_fileOffset <<= 3;
+			fileOffset <<= 3;
 		else
-			_fileOffset <<= 4;
+			fileOffset <<= 4;
 	}
 
-	_fixedDest = dest;
-	_fileDest = dest;
-	_compDest = dest;
-
-	if (dest == NULL) //we need to allocate memory for this file
-		_fileDest = (uint8 *)malloc(_fileSize + 4);
+	uint8 *fileDest = (uint8 *)malloc(fileSize + 4); // allocate memory for file
 
-	_dataDiskHandle->seek(_fileOffset, SEEK_SET);
+	_dataDiskHandle->seek(fileOffset, SEEK_SET);
 
 	//now read in the data
-	bytesRead = _dataDiskHandle->read(_fileDest, 1 * _fileSize);
-
-	if (bytesRead != (int32)_fileSize)
-		warning("ERROR: Unable to read %d bytes from datadisk (%d bytes read)", _fileSize, bytesRead);
+	int32 bytesRead = _dataDiskHandle->read(fileDest, fileSize);
 
-	cflag = (uint8)((_fileFlags >> (23)) & 0x1);
+	if (bytesRead != (int32)fileSize)
+		warning("Unable to read %d bytes from datadisk (%d bytes read)", fileSize, bytesRead);
 
+	cflag = (uint8)((fileFlags >> 23) & 0x1);
 	//if cflag == 0 then file is compressed, 1 == uncompressed
 
-	if ((!cflag) && ((FROM_LE_16(((dataFileHeader *)_fileDest)->flag) >> 7)&1)) {
-		debug(2, "File is RNC compressed.");
+	dataFileHeader *fileHeader = (dataFileHeader*)fileDest;
 
-		memcpy(&fileHeader, _fileDest, sizeof(struct dataFileHeader));
-		_decompSize = (FROM_LE_16(fileHeader.flag) & 0xFFFFFF00) << 8;
-		_decompSize |= FROM_LE_16((uint16)fileHeader.s_tot_size);
+	if ((!cflag) && ((FROM_LE_16(fileHeader->flag) >> 7) & 1)) {
+		debug(2, "File is RNC compressed.");
 
-		if (_fixedDest == NULL) // is this valid?
-			_compDest = (uint8 *)malloc(_decompSize);
+		uint32 decompSize = (FROM_LE_16(fileHeader->flag) & ~0xFF) << 8;
+		decompSize |= FROM_LE_16(fileHeader->s_tot_size);
 
-		inputPtr = _fileDest;
-		outputPtr = _compDest;
+		uint8 *uncompDest = (uint8 *)malloc(decompSize);
 
-		if ( (uint8)(_fileFlags >> (22) & 0x1) ) //do we include the header?
-			inputPtr += sizeof(struct dataFileHeader);
-		else {
+		RncDecoder rncDecoder;
+		int32 unpackLen;
+		if ((fileFlags >> 22) & 0x1) { //do we include the header?
+			// don't return the file's header
+			unpackLen = rncDecoder.unpackM1(fileDest + sizeof(dataFileHeader), uncompDest, 0);
+		} else {
 #ifdef SCUMM_BIG_ENDIAN
 			// Convert dataFileHeader to BE (it only consists of 16 bit words)
 			uint16 *headPtr = (uint16 *)_fileDest;
 			for (uint i = 0; i < sizeof(struct dataFileHeader) / 2; i++)
 				*(headPtr + i) = READ_LE_UINT16(headPtr + i);
 #endif
-			memcpy(outputPtr, inputPtr, sizeof(struct dataFileHeader));
-			inputPtr += sizeof(struct dataFileHeader);
-			outputPtr += sizeof(struct dataFileHeader);
+			memcpy(uncompDest, fileDest, sizeof(dataFileHeader));
+			unpackLen = rncDecoder.unpackM1(fileDest + sizeof(dataFileHeader), uncompDest + sizeof(dataFileHeader), 0);
+			unpackLen += sizeof(dataFileHeader);
 		}
 
-		RncDecoder rncDecoder;
-		int32 unPackLen = rncDecoder.unpackM1(inputPtr, outputPtr, 0);
-
-		debug(3, "UnpackM1 returned: %d", unPackLen);
-
-		if (unPackLen == 0) { //Unpack returned 0: file was probably not packed.
-			if (_fixedDest == NULL)
-				free(_compDest);
-
-			return _fileDest;
-		}
+		debug(3, "UnpackM1 returned: %d", unpackLen);
 
-		if (! (uint8)(_fileFlags >> (22) & 0x1) ) { // include header?
-			unPackLen += sizeof(struct dataFileHeader);
+		if (unpackLen == 0) { //Unpack returned 0: file was probably not packed.
+			free(uncompDest);
+			return fileDest;
+		} else {
+			if (unpackLen != (int32)decompSize)
+				debug(1, "ERROR: invalid decomp size! (was: %d, should be: %d)", unpackLen, decompSize);
+			_lastLoadedFileSize = decompSize;
 
-			if (unPackLen != (int32)_decompSize) {
-				debug(1, "ERROR: invalid decomp size! (was: %d, should be: %d)", unPackLen, _decompSize);
-			}
+			free(fileDest);
+			return uncompDest;
 		}
-
-		_lastLoadedFileSize = _decompSize; //including header
-			
-		if (_fixedDest == NULL)
-			free(_fileDest);
 	} else {
 #ifdef SCUMM_BIG_ENDIAN
 		if (!cflag) {
-			warning("patching header for uncompressed file %d", fileNr);
-			uint16 *headPtr = (uint16 *)_fileDest;
+			uint16 *headPtr = (uint16 *)fileDest;
 			for (uint i = 0; i < sizeof(struct dataFileHeader) / 2; i++)
 				*(headPtr + i) = READ_LE_UINT16(headPtr + i);
 		}
 #endif
-		return _fileDest;
+		return fileDest;
 	}
-
-	return _compDest;
 }
 
 void Disk::prefetchFile(uint16 fileNr) {
@@ -230,14 +200,15 @@
 	PrefFile **fEntry = &_prefRoot;
 	bool found = false;
 	while (*fEntry) {
-		if ((*fEntry)->fileNr == fileNr) found = true;
+		if ((*fEntry)->fileNr == fileNr)
+			found = true;
 		fEntry = &((*fEntry)->next);
 	}
 	if (found) {
 		debug(1,"Disk::prefetchFile: File %d was already prefetched",fileNr);
 		return ;
 	}
-	uint8 *temp = loadFile(fileNr, NULL);
+	uint8 *temp = loadFile(fileNr);
 	*fEntry = new PrefFile;
 	(*fEntry)->data = temp;
 	(*fEntry)->fileSize = _lastLoadedFileSize;
@@ -250,8 +221,10 @@
 	PrefFile **fEntry = &_prefRoot;
 	bool found = false;
 	while ((*fEntry) && (!found)) {
-		if ((*fEntry)->fileNr == fileNr) found = true;
-		else fEntry = &((*fEntry)->next);
+		if ((*fEntry)->fileNr == fileNr)
+			found = true;
+		else
+			fEntry = &((*fEntry)->next);
 	}
 	if (!found) {
 		*fSize = 0;
@@ -315,8 +288,10 @@
 		bCnt = 0;
 		found = false;
 		while (_buildList[bCnt] && (!found)) {
-			if ((_buildList[bCnt] & 0x7FFFU) == _loadedFilesList[lCnt]) found = true;
-			else bCnt++;
+			if ((_buildList[bCnt] & 0x7FFFU) == _loadedFilesList[lCnt])
+				found = true;
+			else
+				bCnt++;
 		}
 		if (found) {
 			_loadedFilesList[targCnt] = _loadedFilesList[lCnt];
@@ -338,7 +313,8 @@
 		lCnt = 0;
 		found = false;
 		while (_loadedFilesList[lCnt] && (!found)) {
-			if (_loadedFilesList[lCnt] == (_buildList[bCnt] & 0x7FFFU)) found = true;
+			if (_loadedFilesList[lCnt] == (_buildList[bCnt] & 0x7FFFU))
+				found = true;
 			lCnt++;
 		}
 		if (found) {
@@ -349,7 +325,7 @@
 		_loadedFilesList[targCnt] = _buildList[bCnt] & 0x7FFFU;
 		targCnt++;
 		_loadedFilesList[targCnt] = 0;
-		SkyEngine::_itemList[_buildList[bCnt] & 2047] = (void**)loadFile(_buildList[bCnt] & 0x7FFF, NULL);
+		SkyEngine::_itemList[_buildList[bCnt] & 2047] = (void**)loadFile(_buildList[bCnt] & 0x7FFF);
 		if (!SkyEngine::_itemList[_buildList[bCnt] & 2047])
 			warning("fnCacheFiles: Disk::loadFile() returned NULL for file %d",_buildList[bCnt] & 0x7FFF);
 		bCnt++;
@@ -369,7 +345,7 @@
 	cnt = 0;
 	while (list[cnt]) {
 		_loadedFilesList[cnt] = list[cnt];
-		SkyEngine::_itemList[_loadedFilesList[cnt] & 2047] = (void**)loadFile((uint16)(_loadedFilesList[cnt] & 0x7FFF), NULL);
+		SkyEngine::_itemList[_loadedFilesList[cnt] & 2047] = (void**)loadFile((uint16)(_loadedFilesList[cnt] & 0x7FFF));
 		cnt++;
 	}
 	_loadedFilesList[cnt] = 0;
@@ -379,12 +355,13 @@
 
 	uint16 cnt = 0;
 	while (_loadedFilesList[cnt]) {
-		if (_loadedFilesList[cnt] == fileNum) return ;
+		if (_loadedFilesList[cnt] == fileNum)
+			return ;
 		cnt++;
 	}
 	_loadedFilesList[cnt] = fileNum & 0x7FFFU;
 	_loadedFilesList[cnt + 1] = 0;
-	SkyEngine::_itemList[fileNum & 2047] = (void**)loadFile(fileNum, NULL);
+	SkyEngine::_itemList[fileNum & 2047] = (void**)loadFile(fileNum);
 }
 
 void Disk::fnFlushBuffers(void) {
@@ -404,7 +381,7 @@
 	File out;
 	byte* filePtr;
 
-	filePtr = loadFile(fileNr, NULL);
+	filePtr = loadFile(fileNr);
 	sprintf(buf, "dumps/file-%d.dmp", fileNr);
 
 	out.open(buf, File::kFileReadMode, "");
@@ -435,8 +412,10 @@
 		return 303;
 	case 1445:
 		//floppy (v0.0331 or v0.0348)
-		if (_dataDiskHandle->size() == 8830435) return 348;
-		else return 331;
+		if (_dataDiskHandle->size() == 8830435)
+			return 348;
+		else
+			return 331;
 	case 1711:
 		//cd demo (v0.0365)
 		return 365;

Index: disk.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/disk.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- disk.h	6 Jan 2004 12:45:32 -0000	1.15
+++ disk.h	11 Nov 2004 10:14:35 -0000	1.16
@@ -44,7 +44,7 @@
 	Disk(const Common::String &gameDataPath);
 	~Disk(void);
 
-	uint8 *loadFile(uint16 fileNr, uint8 *dest);
+	uint8 *loadFile(uint16 fileNr);
 	bool fileExists(uint16 fileNr);
 
 	void prefetchFile(uint16 fileNr);
@@ -71,13 +71,12 @@
 	void dumpFile(uint16 fileNr);
 
 	uint32 _dinnerTableEntries;
+	uint8 *_dinnerTableArea;
+	File *_dataDiskHandle;
+	File *_dnrHandle;
 
-	uint8 *_dinnerTableArea, *_fixedDest, *_fileDest, *_compDest;
-	uint32 _fileFlags, _fileOffset, _fileSize, _decompSize, _compFile;
 	uint16 _buildList[MAX_FILES_IN_LIST];
 	uint32 _loadedFilesList[MAX_FILES_IN_LIST];
-	File *_dataDiskHandle;
-	File *_dnrHandle;
 };
 
 } // End of namespace Sky

Index: grid.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/grid.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- grid.cpp	6 Jan 2004 12:45:32 -0000	1.16
+++ grid.cpp	11 Nov 2004 10:14:35 -0000	1.17
@@ -130,21 +130,24 @@
 };
 
 Grid::Grid(Disk *pDisk) {
-
-	_gameGrids = (uint8 *)malloc(TOT_NO_GRIDS * GRID_SIZE);
+	for (int cnt = 0; cnt < TOT_NO_GRIDS; cnt++)
+		_gameGrids[cnt] = NULL;
 	_skyDisk = pDisk;
 }
 
 Grid::~Grid(void) {
-
-	free(_gameGrids);
+	for (uint8 cnt = 0; cnt < TOT_NO_GRIDS; cnt++)
+		if (_gameGrids[cnt])
+			free(_gameGrids[cnt]);
 }
 
 void Grid::loadGrids(void) {
-
 	// no endian conversion necessary as I'm using uint8* instead of uint32*
-	for (uint8 cnt = 0; cnt < TOT_NO_GRIDS; cnt++)
-		_skyDisk->loadFile(GRID_FILE_START + cnt, _gameGrids + (cnt * GRID_SIZE));
+	for (uint8 cnt = 0; cnt < TOT_NO_GRIDS; cnt++) {
+		if (_gameGrids[cnt])
+			free(_gameGrids[cnt]);
+		_gameGrids[cnt] = _skyDisk->loadFile(GRID_FILE_START + cnt);
+	}
 	if (!SkyEngine::isDemo()) { // single disk demos never get that far
 		// Reloading the grids can sometimes cause problems eg when reichs door is
 		// open the door grid bit gets replaced so you can't get back in (or out)
@@ -153,25 +156,26 @@
 	}
 }
 
-bool Grid::getGridValues(Compact *cpt, uint32 *resBitNum, uint32 *resWidth) {
-
+bool Grid::getGridValues(Compact *cpt, uint8 *resGrid, uint32 *resBitNum, uint32 *resWidth) {
 	uint16 width = SkyCompact::getMegaSet(cpt, cpt->extCompact->megaSet)->gridWidth;
-	return getGridValues(cpt->xcood, cpt->ycood, width, cpt, resBitNum, resWidth);
+	return getGridValues(cpt->xcood, cpt->ycood, width, cpt, resGrid, resBitNum, resWidth);
 }
 
-bool Grid::getGridValues(uint32 x, uint32 y, uint32 width, Compact *cpt, uint32 *resBitNum, uint32 *resWidth) {
-
+bool Grid::getGridValues(uint32 x, uint32 y, uint32 width, Compact *cpt, uint8 *resGrid, uint32 *resBitNum, uint32 *resWidth) {
 	uint32 bitPos;
-	if (y < TOP_LEFT_Y) return false; // off screen
+	if (y < TOP_LEFT_Y) 
+		return false; // off screen
 	y -= TOP_LEFT_Y;
 	y >>= 3; // convert to blocks
-	if (y >= GAME_SCREEN_HEIGHT >> 3) return false; // off screen
+	if (y >= GAME_SCREEN_HEIGHT >> 3) 
+		return false; // off screen
 	bitPos = y * 40;
 	width++;
 	x >>= 3; // convert to blocks
 	
 	if (x < (TOP_LEFT_X >> 3)) { // at least partially off screen
-		if (x + width < (TOP_LEFT_X >> 3)) return false; // completely off screen
+		if (x + width < (TOP_LEFT_X >> 3)) 
+			return false; // completely off screen
 		else {
 			width -= (TOP_LEFT_X >> 3) - x;
 			x = 0;
@@ -179,13 +183,15 @@
 	} else
 		x -= TOP_LEFT_X >> 3;
 
-	if ((GAME_SCREEN_WIDTH >> 3) <= x) return false; // off screen
+	if ((GAME_SCREEN_WIDTH >> 3) <= x) 
+		return false; // off screen
 	if ((GAME_SCREEN_WIDTH >> 3) < x + width) // partially off screen
 		width = (GAME_SCREEN_WIDTH >> 3) - x;
 
 	bitPos += x;
-	int32 screenGridOfs = _gridConvertTable[cpt->screen] * GRID_SIZE;
-	bitPos += (screenGridOfs << 3); // convert to bits
+	assert((_gridConvertTable[cpt->screen] >= 0) && (_gridConvertTable[cpt->screen] < TOT_NO_GRIDS));
+	*resGrid = (uint8)_gridConvertTable[cpt->screen];
+
 	uint32 tmpBits = 0x1F - (bitPos&0x1F);
 	bitPos &= ~0x1F; // divide into dword address and bit number
 	bitPos += tmpBits;
@@ -195,56 +201,56 @@
 }
 
 void Grid::removeObjectFromWalk(Compact *cpt) {
-
 	uint32 bitNum, width;
-	if (getGridValues(cpt, &bitNum, &width))
-		removeObjectFromWalk(bitNum, width);
+	uint8 gridIdx;
+	if (getGridValues(cpt, &gridIdx, &bitNum, &width))
+		removeObjectFromWalk(gridIdx, bitNum, width);
 }
 
-void Grid::removeObjectFromWalk(uint32 bitNum, uint32 width) {
-
+void Grid::removeObjectFromWalk(uint8 gridIdx, uint32 bitNum, uint32 width) {
 	for (uint32 cnt = 0; cnt < width; cnt++) {
-		_gameGrids[bitNum >> 3] &= ~(1 << (bitNum & 0x7));
+		_gameGrids[gridIdx][bitNum >> 3] &= ~(1 << (bitNum & 0x7));
 		if ((bitNum & 0x1F) == 0)
 			bitNum += 0x3F;
-		else bitNum--;
+		else
+			bitNum--;
 	}
 }
 
 void Grid::objectToWalk(Compact *cpt) {
-
 	uint32 bitNum, width;
-	if (getGridValues(cpt, &bitNum, &width))
-		objectToWalk(bitNum, width);
+	uint8 gridIdx;
+	if (getGridValues(cpt, &gridIdx, &bitNum, &width))
+		objectToWalk(gridIdx, bitNum, width);
 }
 
-void Grid::objectToWalk(uint32 bitNum, uint32 width) {
-
+void Grid::objectToWalk(uint8 gridIdx, uint32 bitNum, uint32 width) {
 	for (uint32 cnt = 0; cnt < width; cnt++) {
-		_gameGrids[bitNum >> 3] |= (1 << (bitNum & 0x7));
+		_gameGrids[gridIdx][bitNum >> 3] |= (1 << (bitNum & 0x7));
 		if ((bitNum & 0x1F) == 0)
 			bitNum += 0x3F;
-		else bitNum--;
+		else
+			bitNum--;
 	}
 }
 
 void Grid::plotGrid(uint32 x, uint32 y, uint32 width, Compact *cpt) {
-
 	uint32 resBitPos, resWidth;
-	if (getGridValues(x, y, width-1, cpt, &resBitPos, &resWidth))
-		objectToWalk(resBitPos, resWidth);
+	uint8 resGridIdx;
+	if (getGridValues(x, y, width-1, cpt, &resGridIdx, &resBitPos, &resWidth))
+		objectToWalk(resGridIdx, resBitPos, resWidth);
 }
 
 void Grid::removeGrid(uint32 x, uint32 y, uint32 width, Compact *cpt) {
-
 	uint32 resBitPos, resWidth;
-	if (getGridValues(x, y, width, cpt, &resBitPos, &resWidth))
-		removeObjectFromWalk(resBitPos, resWidth);
+	uint8 resGridIdx;
+	if (getGridValues(x, y, width, cpt, &resGridIdx, &resBitPos, &resWidth))
+		removeObjectFromWalk(resGridIdx, resBitPos, resWidth);
 }
 
-uint8 *Grid::giveGrid(uint32 pScreen)
-{
-	return _gameGrids + GRID_SIZE * _gridConvertTable[pScreen];
+uint8 *Grid::giveGrid(uint32 pScreen) {
+	assert((_gridConvertTable[pScreen] >= 0) && (_gridConvertTable[pScreen] < TOT_NO_GRIDS));
+	return _gameGrids[_gridConvertTable[pScreen]];
 }
 
 } // End of namespace Sky

Index: grid.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/grid.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- grid.h	6 Jan 2004 12:45:32 -0000	1.8
+++ grid.h	11 Nov 2004 10:14:35 -0000	1.9
@@ -37,12 +37,8 @@
 
 	// grid.asm routines
 	void loadGrids(void);
-	bool getGridValues(Compact *cpt, uint32 *resBitNum, uint32 *resWidth);
-	bool getGridValues(uint32 x, uint32 y, uint32 width, Compact *cpt, uint32 *resBitNum, uint32 *resWidth);
 	void removeObjectFromWalk(Compact *cpt);
-	void removeObjectFromWalk(uint32 bitNum, uint32 width);
 	void objectToWalk(Compact *cpt);
-	void objectToWalk(uint32 bitNum, uint32 width);
 
 	// function.asm
 	// note that this routine does the same as objectToWalk, it just doesn't get
@@ -50,12 +46,16 @@
 	void plotGrid(uint32 x, uint32 y, uint32 width, Compact *cpt);
 	// same here, it's basically the same as removeObjectFromWalk
 	void removeGrid(uint32 x, uint32 y, uint32 width, Compact *cpt);
-	// note that this function actually returns the byte after the end of the requested grid
 	uint8 *giveGrid(uint32 pScreen);
 
 private:
+	void objectToWalk(uint8 gridIdx, uint32 bitNum, uint32 width);
+	void removeObjectFromWalk(uint8 gridIdx, uint32 bitNum, uint32 width);
+	bool getGridValues(Compact *cpt, uint8 *resGrid, uint32 *resBitNum, uint32 *resWidth);
+	bool getGridValues(uint32 x, uint32 y, uint32 width, Compact *cpt, uint8 *resGrid, uint32 *resBitNum, uint32 *resWidth);
+
 	static int8 _gridConvertTable[];
-	uint8 *_gameGrids;
+	uint8 *_gameGrids[TOT_NO_GRIDS];
 	Disk *_skyDisk;
 };
 

Index: intro.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/intro.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- intro.cpp	25 Oct 2004 00:27:53 -0000	1.50
+++ intro.cpp	11 Nov 2004 10:14:35 -0000	1.51
@@ -725,7 +725,7 @@
 	case PLAYVOICE:
 		if (!escDelay(200))
 			return false;
-		vData = _skyDisk->loadFile(*data++, NULL);
+		vData = _skyDisk->loadFile(*data++);
 		// HACK: Fill the header with silence. We should
 		// probably use _skySound instead of calling playRaw()
 		// directly, but this will have to do for now.
@@ -742,7 +742,7 @@
 		_mixer->stopID(SOUND_BG);
 		if (_bgBuf)
 			free(_bgBuf);
-		_bgBuf = _skyDisk->loadFile(*data++, NULL);
+		_bgBuf = _skyDisk->loadFile(*data++);
 		_bgSize = _skyDisk->_lastLoadedFileSize;
 		return true;
 	case LOOPBG:
@@ -770,8 +770,8 @@
 	memset(scrollScreen, 0, FRAME_SIZE);
 	memcpy(scrollScreen + FRAME_SIZE, _skyScreen->giveCurrent(), FRAME_SIZE);
 	uint8 *scrollPos = scrollScreen + FRAME_SIZE;
-	uint8 *vgaData = _skyDisk->loadFile(60100, NULL);
-	uint8 *diffData = _skyDisk->loadFile(60101, NULL);
+	uint8 *vgaData = _skyDisk->loadFile(60100);
+	uint8 *diffData = _skyDisk->loadFile(60101);
 	uint16 frameNum = READ_LE_UINT16(diffData);
 	uint8 *diffPtr = diffData + 2;
 	uint8 *vgaPtr = vgaData;

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/logic.cpp,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -d -r1.146 -r1.147
--- logic.cpp	21 Oct 2004 05:18:06 -0000	1.146
+++ logic.cpp	11 Nov 2004 10:14:35 -0000	1.147
@@ -788,7 +788,7 @@
 
 void Logic::checkModuleLoaded(uint16 moduleNo) {
 	if (!_moduleList[moduleNo])
-		_moduleList[moduleNo] = (uint16 *)_skyDisk->loadFile((uint16)moduleNo + F_MODULE_0, NULL);
+		_moduleList[moduleNo] = (uint16 *)_skyDisk->loadFile((uint16)moduleNo + F_MODULE_0);
 }
 
 void Logic::push(uint32 a) {
@@ -1191,7 +1191,7 @@
 	uint16 *scriptData = _moduleList[moduleNo]; // get module address
 
 	if (!scriptData) { // The module has not been loaded
-		scriptData = (uint16 *)_skyDisk->loadFile(moduleNo + F_MODULE_0, NULL);
+		scriptData = (uint16 *)_skyDisk->loadFile(moduleNo + F_MODULE_0);
 		_moduleList[moduleNo] = scriptData; // module has been loaded
 	}
 

Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/mouse.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- mouse.cpp	28 Sep 2004 20:19:32 -0000	1.35
+++ mouse.cpp	11 Nov 2004 10:14:35 -0000	1.36
@@ -94,10 +94,10 @@
 	_mouseX = GAME_SCREEN_WIDTH / 2;
 	_mouseY = GAME_SCREEN_HEIGHT / 2;
 	
-	_miceData = _skyDisk->loadFile(MICE_FILE, NULL);
+	_miceData = _skyDisk->loadFile(MICE_FILE);
 
 	//load in the object mouse file
-	_objectMouseData = _skyDisk->loadFile(MICE_FILE + 1, NULL);
+	_objectMouseData = _skyDisk->loadFile(MICE_FILE + 1);
 }
 
 Mouse::~Mouse( ){
@@ -106,7 +106,8 @@
 }
 
 void Mouse::replaceMouseCursors(uint16 fileNo) {
-	_skyDisk->loadFile(fileNo, _objectMouseData);
+	free(_objectMouseData);
+	_objectMouseData = _skyDisk->loadFile(fileNo);
 }
 
 bool Mouse::fnAddHuman(void) {
@@ -188,8 +189,10 @@
 	uint16 mouseHeight = ((struct dataFileHeader *)_miceData)->s_height;
 
 	_system->setMouseCursor(newCursor, mouseWidth, mouseHeight, mouseX, mouseY, 0);
-	if (frameNum == MOUSE_BLANK) _system->showMouse(false);
-	else _system->showMouse(true);
+	if (frameNum == MOUSE_BLANK)
+		_system->showMouse(false);
+	else
+		_system->showMouse(true);
 }
 
 void Mouse::mouseEngine(uint16 mouseX, uint16 mouseY) {

Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/screen.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- screen.cpp	25 Oct 2004 00:27:53 -0000	1.61
+++ screen.cpp	11 Nov 2004 10:14:35 -0000	1.62
@@ -133,7 +133,7 @@
 
 void Screen::setPalette(uint16 fileNum) {
 
-	uint8 *tmpPal = _skyDisk->loadFile(fileNum, NULL);
+	uint8 *tmpPal = _skyDisk->loadFile(fileNum);
 	if (tmpPal) {
 		setPalette(tmpPal);
 		free(tmpPal);
@@ -143,7 +143,7 @@
 void Screen::showScreen(uint16 fileNum) {
 
 	if (_currentScreen) free(_currentScreen);
-	_currentScreen = _skyDisk->loadFile(fileNum, NULL);
+	_currentScreen = _skyDisk->loadFile(fileNum);
 	
 	if (_currentScreen) showScreen(_currentScreen);
 	else warning("Screen::showScreen: can't load file nr. %d",fileNum);
@@ -281,7 +281,7 @@
 
 void Screen::paletteFadeUp(uint16 fileNr) {
 
-	uint8 *pal = _skyDisk->loadFile(fileNr, NULL);
+	uint8 *pal = _skyDisk->loadFile(fileNr);
 	if (pal) {
 		paletteFadeUp(pal);
 		free(pal);
@@ -401,7 +401,7 @@
 
 void Screen::startSequence(uint16 fileNum) {
 
-	_seqInfo.seqData = _skyDisk->loadFile(fileNum, NULL);
+	_seqInfo.seqData = _skyDisk->loadFile(fileNum);
 	_seqInfo.framesLeft = _seqInfo.seqData[0];
 	_seqInfo.seqDataPos = _seqInfo.seqData + 1;
 	_seqInfo.delay = SEQ_DELAY;

Index: sky.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sky.cpp,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- sky.cpp	22 Oct 2004 08:25:07 -0000	1.152
+++ sky.cpp	11 Nov 2004 10:14:35 -0000	1.153
@@ -247,8 +247,10 @@
 		if (!_skyLogic->checkProtection()) { // don't let copy prot. screen flash up
 			_skyScreen->recreate();
 			_skyScreen->spriteEngine();
-			if (_debugger->showGrid())
+			if (_debugger->showGrid()) {
 				_skyScreen->showGrid(_skyLogic->_skyGrid->giveGrid(Logic::_scriptVariables[SCREEN]));
+				_skyScreen->forceRefresh();
+			}
 			_skyScreen->flip();
 		}
 	}
@@ -394,24 +396,24 @@
 void SkyEngine::loadFixedItems(void) {
 
 	if (!isDemo())
-		_itemList[36] = (void **)_skyDisk->loadFile(36, NULL);
+		_itemList[36] = (void **)_skyDisk->loadFile(36);
 
-	_itemList[49] = (void **)_skyDisk->loadFile(49, NULL);
-	_itemList[50] = (void **)_skyDisk->loadFile(50, NULL);
-	_itemList[73] = (void **)_skyDisk->loadFile(73, NULL);
-	_itemList[262] = (void **)_skyDisk->loadFile(262, NULL);
+	_itemList[49] = (void **)_skyDisk->loadFile(49);
+	_itemList[50] = (void **)_skyDisk->loadFile(50);
+	_itemList[73] = (void **)_skyDisk->loadFile(73);
+	_itemList[262] = (void **)_skyDisk->loadFile(262);
 
 	if (isDemo()) 
 		return;
 	
-	_itemList[263] = (void **)_skyDisk->loadFile(263, NULL);
-	_itemList[264] = (void **)_skyDisk->loadFile(264, NULL);
-	_itemList[265] = (void **)_skyDisk->loadFile(265, NULL);
-	_itemList[266] = (void **)_skyDisk->loadFile(266, NULL);
-	_itemList[267] = (void **)_skyDisk->loadFile(267, NULL);
-	_itemList[269] = (void **)_skyDisk->loadFile(269, NULL);
-	_itemList[271] = (void **)_skyDisk->loadFile(271, NULL);
-	_itemList[272] = (void **)_skyDisk->loadFile(272, NULL);
+	_itemList[263] = (void **)_skyDisk->loadFile(263);
+	_itemList[264] = (void **)_skyDisk->loadFile(264);
+	_itemList[265] = (void **)_skyDisk->loadFile(265);
+	_itemList[266] = (void **)_skyDisk->loadFile(266);
+	_itemList[267] = (void **)_skyDisk->loadFile(267);
+	_itemList[269] = (void **)_skyDisk->loadFile(269);
+	_itemList[271] = (void **)_skyDisk->loadFile(271);
+	_itemList[272] = (void **)_skyDisk->loadFile(272);
 		
 }
 

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/sound.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- sound.cpp	16 Feb 2004 16:51:44 -0000	1.47
+++ sound.cpp	11 Nov 2004 10:14:35 -0000	1.48
@@ -1049,7 +1049,7 @@
 	_mixer->stopAll();
 
 	if (_soundData) free(_soundData);
-	_soundData = _skyDisk->loadFile(pSection * 4 + SOUND_FILE_BASE, NULL);
+	_soundData = _skyDisk->loadFile(pSection * 4 + SOUND_FILE_BASE);
 	uint16 asmOfs;
 	if (SkyEngine::_systemVars.gameVersion == 109) {
 		if (pSection == 0)
@@ -1219,7 +1219,7 @@
 		return false;
 	uint16 speechFileNum = _speechConvertTable[textNum >> 12] + (textNum & 0xFFF);
 	
-	uint8 *speechData = _skyDisk->loadFile(speechFileNum + 50000, NULL);
+	uint8 *speechData = _skyDisk->loadFile(speechFileNum + 50000);
 	if (!speechData) {
 		debug(9,"File %d (speechFile %d from section %d) wasn't found", speechFileNum + 50000, textNum & 0xFFF, textNum >> 12);
 		return false;

Index: text.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sky/text.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- text.cpp	13 Mar 2004 22:58:50 -0000	1.61
+++ text.cpp	11 Nov 2004 10:14:35 -0000	1.62
@@ -41,18 +41,18 @@
 
 	initHuffTree();
 
-	_mainCharacterSet.addr = _skyDisk->loadFile(CHAR_SET_FILE, NULL);
+	_mainCharacterSet.addr = _skyDisk->loadFile(CHAR_SET_FILE);
 	_mainCharacterSet.charHeight = MAIN_CHAR_HEIGHT;
 	_mainCharacterSet.charSpacing = 0;
 	
 	fnSetFont(0);
 
 	if (!SkyEngine::isDemo()) {
-		_controlCharacterSet.addr = _skyDisk->loadFile(60520, NULL);
+		_controlCharacterSet.addr = _skyDisk->loadFile(60520);
 		_controlCharacterSet.charHeight = 12;
 		_controlCharacterSet.charSpacing = 0;
 
-		_linkCharacterSet.addr = _skyDisk->loadFile(60521, NULL);
+		_linkCharacterSet.addr = _skyDisk->loadFile(60521);
 		_linkCharacterSet.charHeight = 12;
 		_linkCharacterSet.charSpacing = 1;
 
@@ -63,7 +63,7 @@
 	}
 
 	if (SkyEngine::isCDVersion()) {
-		_preAfterTableArea = _skyDisk->loadFile(60522, NULL);
+		_preAfterTableArea = _skyDisk->loadFile(60522);
 	} else
 		_preAfterTableArea = NULL;
 }
@@ -267,7 +267,7 @@
 		debug(5, "Loading Text item(s) for Section %d", (sectionNo>>2));
 		
 		uint32 fileNo = sectionNo + ((SkyEngine::_systemVars.language * NO_OF_TEXT_SECTIONS) + 60600);
-		SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo] = (void **)_skyDisk->loadFile((uint16)fileNo, NULL);
+		SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo] = (void **)_skyDisk->loadFile((uint16)fileNo);
 	}
 	_textItemPtr = (uint8 *)SkyEngine::_itemList[FIRST_TEXT_SEC + sectionNo];
 





More information about the Scummvm-git-logs mailing list