[Scummvm-cvs-logs] CVS: scummvm/sword1 control.cpp,1.2,1.3 logic.cpp,1.16,1.17 screen.cpp,1.15,1.16 screen.h,1.5,1.6 sound.cpp,1.10,1.11 sound.h,1.5,1.6 staticres.cpp,1.3,1.4 sword1.cpp,1.14,1.15 sword1.h,1.5,1.6

Robert G?ffringmann lavosspawn at users.sourceforge.net
Sat Dec 20 12:22:02 CET 2003


Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1:/tmp/cvs-serv18436/sword1

Modified Files:
	control.cpp logic.cpp screen.cpp screen.h sound.cpp sound.h 
	staticres.cpp sword1.cpp sword1.h 
Log Message:
fixed crashes after restoring a savegame, added fnSetPaletteToFade and changed speech code to distinguish between CD1 and CD2. (now needs SPEECH1.CLU and SPEECH2.CLU)

Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- control.cpp	20 Dec 2003 19:19:42 -0000	1.2
+++ control.cpp	20 Dec 2003 20:20:53 -0000	1.3
@@ -603,12 +603,19 @@
 	}
 	uint32 playerSize = (sizeof(BsObject) - 12000) / 4;
 	uint32 *playerRaw = (uint32*)_objMan->fetchObject(PLAYER);
+	BsObject *cpt = _objMan->fetchObject(PLAYER);
 	for (uint32 cnt = 0; cnt < playerSize; cnt++) {
 		*playerRaw = *(uint32*)bufPos;
 		playerRaw++;
 		bufPos += 4;
 	}
     free(_restoreBuf);
+	SwordLogic::_scriptVars[CHANGE_DIR] = cpt->o_dir;
+	SwordLogic::_scriptVars[CHANGE_X] = cpt->o_xcoord;
+	SwordLogic::_scriptVars[CHANGE_Y] = cpt->o_ycoord;
+	SwordLogic::_scriptVars[CHANGE_STANCE] = STAND;
+	SwordLogic::_scriptVars[CHANGE_PLACE] = cpt->o_place;
+	SwordEngine::_systemVars.justRestoredGame = 1;
 }
 
 void SwordControl::delay(uint32 msecs) {

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/logic.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- logic.cpp	20 Dec 2003 09:12:54 -0000	1.16
+++ logic.cpp	20 Dec 2003 20:20:53 -0000	1.17
@@ -856,8 +856,8 @@
 }
 
 int SwordLogic::fnFadeUp(BsObject *cpt, int32 id, int32 speed, int32 d, int32 e, int32 f, int32 z, int32 x) {
-	warning("fnFadeUp speed = %d", speed);
-	_screen->fadeUpPalette();
+	//warning("fnFadeUp speed = %d", speed);
+	//_screen->fadeUpPalette();
 	return SCRIPT_CONT;
 }
 
@@ -878,10 +878,7 @@
 }
 
 int SwordLogic::fnSetFadeTargetPalette(BsObject *cpt, int32 id, int32 spritePal, int32 d, int32 e, int32 f, int32 z, int32 x) {
-	uint8 *pal = (uint8*)_resMan->openFetchRes(spritePal);
-	pal[0] = pal[1] = pal[2] = 0;
-	_resMan->resClose(spritePal);
-	warning("fnSetFadeTargetPalette(xx, %d, %X, %d)", id, spritePal, d);
+	_screen->fnSetPalette(0, 184, spritePal, true);
 	return SCRIPT_CONT;
 }
 

Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- screen.cpp	20 Dec 2003 15:26:44 -0000	1.15
+++ screen.cpp	20 Dec 2003 20:20:53 -0000	1.16
@@ -109,6 +109,8 @@
 	if (fadeUp) {
 		_fadingStep = 1;
 		_fadingDirection = FADE_UP;
+		memset(_currentPalette, 0, 256 * 4);
+		_system->set_palette(_currentPalette, 0, 256);
 	} else
 		_system->set_palette(_targetPalette, start, length);
 }
@@ -121,10 +123,8 @@
 	if (SwordLogic::_scriptVars[NEW_PALETTE]) {
 		_fadingStep = 1;
 		_fadingDirection = FADE_UP;
-		memcpy(_targetPalette, _resMan->openFetchRes(_roomDefTable[_currentScreen].palettes[0]), 184 * 3); // set colours 0-183 for background palette
-		_resMan->resClose(_roomDefTable[_currentScreen].palettes[0]);
-		memcpy(_targetPalette + 184 * 3, _resMan->openFetchRes(_roomDefTable[_currentScreen].palettes[1]),  72 * 3); // set colours 184-255 for sprite palette - george, icons & menubar
-		_resMan->resClose(_roomDefTable[_currentScreen].palettes[1]);
+		fnSetPalette(0, 184, _roomDefTable[_currentScreen].palettes[0], true);
+		fnSetPalette(184, 72, _roomDefTable[_currentScreen].palettes[1], true);
 		SwordLogic::_scriptVars[NEW_PALETTE] = 0;
 	}
 	if (_fadingStep) {
@@ -223,7 +223,6 @@
 
 void SwordScreen::newScreen(uint32 screen) {
 	// set sizes and scrolling, initialize/load screengrid, force screen refresh
-	// force palette fadeup?
 	_currentScreen = screen;
 	_scrnSizeX = _roomDefTable[screen].sizeX;
 	_scrnSizeY = _roomDefTable[screen].sizeY;

Index: screen.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- screen.h	19 Dec 2003 14:07:12 -0000	1.5
+++ screen.h	20 Dec 2003 20:20:53 -0000	1.6
@@ -81,6 +81,7 @@
 	void fadeDownPalette(void);
 	void fadeUpPalette(void);
 	void fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeUp);
+	//void fnSetFadeTargetPalette(uint32 id);
 	bool stillFading(void);
 
 	void updateScreen(void);

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- sound.cpp	20 Dec 2003 09:12:54 -0000	1.10
+++ sound.cpp	20 Dec 2003 20:20:53 -0000	1.11
@@ -24,6 +24,7 @@
 #include "common/util.h"
 #include "resman.h"
 #include "logic.h"
+#include "sword1.h"
 
 #define SOUND_SPEECH_ID 1
 #define SPEECH_FLAGS (SoundMixer::FLAG_16BITS | SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_LITTLE_ENDIAN)
@@ -33,8 +34,8 @@
 	_mixer = mixer;
 	_resMan = pResMan;
 	_cowHeader = NULL;
-	initCowSystem();
 	_endOfQueue = 0;
+	_currentCowFile = 0;
 }
 
 int SwordSound::addToQueue(int32 fxNo) {
@@ -107,25 +108,22 @@
 	return true;
 }
 
-void SwordSound::clearAllFx(void) {
-	warning("Stub: SwordSound::clearAllFx()");
-}
-
-void SwordSound::closeCowSysten(void) {
-	warning("stub: SwordSound::closeCowSystem()");
-}
-
 bool SwordSound::speechFinished(void) {
-	//warning("stub: SwordSound::speechFinished()");
-	//return true;
 	return (_speechHandle == 0);
 }
 
+void SwordSound::newScreen(uint32 screen) {
+	if (_currentCowFile != SwordEngine::_systemVars.currentCD) {
+		if (_currentCowFile)
+			closeCowSystem();
+		initCowSystem();			
+	}
+}
+
 void SwordSound::quitScreen(void) {
 	// stop all running SFX
 	while (_endOfQueue)
 		fnStopFx(_fxQueue[0].id);
-	// I don't think that we even have to start SFX here.
 }
 
 void SwordSound::playSample(QueueElement *elem) {
@@ -216,9 +214,13 @@
 }
 
 void SwordSound::initCowSystem(void) {
-	_cowFile.open("SPEECH.CLU");
-	if (_cowFile.isOpen() == false)
-		_cowFile.open("speech/SPEECH.CLU");
+	char cowName[25];
+	sprintf(cowName, "SPEECH%d.CLU", SwordEngine::_systemVars.currentCD);
+	_cowFile.open(cowName);
+	if (!_cowFile.isOpen()) {
+		sprintf(cowName, "speech/SPEECH%d.CLU", SwordEngine::_systemVars.currentCD);
+		_cowFile.open(cowName);
+	}
 	if (_cowFile.isOpen()) {
 		_cowHeaderSize = _cowFile.readUint32LE();
 		_cowHeader = (uint32*)malloc(_cowHeaderSize);
@@ -226,6 +228,17 @@
 			error("Unexpected cow header size %d", _cowHeaderSize);
 		for (uint32 cnt = 0; cnt < (_cowHeaderSize / 4) - 1; cnt++)
 			_cowHeader[cnt] = _cowFile.readUint32LE();
+		_currentCowFile = SwordEngine::_systemVars.currentCD;
 	} else
-		warning("SwordSound::initCowSystem: Can't open SPEECH.CLU");	
+		warning("SwordSound::initCowSystem: Can't open SPEECH%d.CLU", SwordEngine::_systemVars.currentCD);	
 }
+
+void SwordSound::closeCowSystem(void) {
+	if (_cowFile.isOpen())
+		_cowFile.close();
+	if (_cowHeader)
+		free(_cowHeader);
+	_cowHeader = NULL;
+	_currentCowFile = NULL;
+}
+

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sound.h	20 Dec 2003 09:12:54 -0000	1.5
+++ sound.h	20 Dec 2003 20:20:53 -0000	1.6
@@ -57,6 +57,7 @@
 public:
 	SwordSound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan);
 	~SwordSound(void);
+	void newScreen(uint32 screen);
 	void quitScreen(void);
 
 	bool startSpeech(uint16 roomNo, uint16 localNo); // this should work more or less.
@@ -66,7 +67,6 @@
 	bool amISpeaking(void); // this is supposed to return if the sounddata is near the ending or very silent...
 
 	void fnStopFx(int32 fxNo);
-	void clearAllFx(void);
 	int addToQueue(int32 fxNo);
 
 	void engine(void);
@@ -74,12 +74,13 @@
 private:
 	void playSample(QueueElement *elem);
 	void initCowSystem(void);
-	void closeCowSysten(void);
+	void closeCowSystem(void);
 	uint32 uncompressedSize(uint8 *data);
 	uint32 expandSpeech(void *src, void *dest, uint32 srcSize);
 	File		 _cowFile;
 	uint32		 *_cowHeader;
 	uint32		 _cowHeaderSize;
+	uint8		 _currentCowFile;
 	PlayingSoundHandle _speechHandle, _fxHandle;
 	Common::RandomSource _rnd;
 	

Index: staticres.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/staticres.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- staticres.cpp	17 Dec 2003 02:19:03 -0000	1.3
+++ staticres.cpp	20 Dec 2003 20:20:53 -0000	1.4
@@ -27,6 +27,176 @@
 #include "menu.h"
 #include "music.h"
 #include "sound.h"
+#include "sword1.h"
+
+const uint8 SwordEngine::_cdList[TOTAL_SECTIONS] = {
+	0,		// 0		inventory
+
+	1,		// 1		PARIS 1
+	1,		// 2
+	1,		// 3
+	1,		// 4
+	1,		// 5
+	1,		// 6
+	1,		// 7
+	1,		// 8
+
+	1,		// 9		PARIS 2
+	1,		// 10
+	1,		// 11
+	1,		// 12
+	1,		// 13
+	1,		// 14
+	1,		// 15
+	1,		// 16
+	1,		// 17
+	1,		// 18
+
+	2,		// 19		IRELAND
+	2,		// 20
+	2,		// 21
+	2,		// 22
+	2,		// 23
+	2,		// 24
+	2,		// 25
+	2,		// 26
+
+	1,		// 27		PARIS 3
+	1,		// 28
+	1,		// 29
+ 	1,		// 30 - Heart Monitor
+	1,		// 31
+	1,		// 32
+	1,		// 33
+	1,		// 34
+	1,		// 35
+
+	1,		// 36		PARIS 4
+	1,		// 37
+	1,		// 38
+	1,		// 39
+	1,		// 40
+	1,		// 41
+	1,		// 42
+	1,		// 43
+	0,		// 44	<NOT USED>
+
+	2,		// 45		SYRIA
+	1,		// 46		PARIS 4
+	2,		// 47
+	1,		// 48		PARIS 4
+	2,		// 49
+	2,		// 50
+	0,		// 51 <NOT USED>
+	0,		// 52 <NOT USED>
+	2,		// 53
+	2,		// 54
+	2,		// 55
+
+	2,		// 56		SPAIN
+	2,		// 57
+	2,		// 58
+	2,		// 59
+	2,		// 60
+	2,		// 61
+	2,		// 62
+
+	2,		// 63		NIGHT TRAIN
+	0,		// 64 <NOT USED>
+	2,		// 65
+	2,		// 66
+	2,		// 67
+	0,		// 68 <NOT USED>
+	2,		// 69
+	0,		// 70 <NOT USED>
+
+	2,		// 71		SCOTLAND
+	2,		// 72
+	2,	 	// 73
+	2,		// 74		END SEQUENCE IN SECRET_CRYPT
+	2,		// 75
+	2,		// 76
+	2,		// 77
+	2,		// 78
+	2,		// 79
+
+	1,		// 80		PARIS MAP
+
+	1,		// 81	Full-screen for "Asstair" in Paris2
+
+	2,		// 82	Full-screen BRITMAP in sc55 (Syrian Cave)
+	0,		// 83 <NOT USED>
+	0,		// 84 <NOT USED>
+	0,		// 85 <NOT USED>
+
+	1,		// 86		EUROPE MAP
+	1,		// 87		fudged in for normal window (sc48)
+	1,		// 88		fudged in for filtered window (sc48)
+	0,		// 89 <NOT USED>
+
+	0,		// 90		PHONE SCREEN
+	0,		// 91		ENVELOPE SCREEN
+	1,		// 92		fudged in for George close-up surprised in sc17 wardrobe
+	1,		// 93		fudged in for George close-up inquisitive in sc17 wardrobe
+	1,		// 94		fudged in for George close-up in sc29 sarcophagus
+	1,		// 95		fudged in for George close-up in sc29 sarcophagus
+	1,		// 96		fudged in for chalice close-up from sc42
+	0,		// 97 <NOT USED>
+	0,		// 98 <NOT USED>
+	0,		// 99		MESSAGE SCREEN (BLANK)
+
+	0,		// 100
+	0,		// 101
+	0,		// 102
+	0,		// 103
+	0,		// 104
+	0,		// 105
+	0,		// 106
+	0,		// 107
+	0,		// 108
+	0,		// 109
+
+	0,		// 110
+	0,		// 111
+	0,		// 112
+	0,		// 113
+	0,		// 114
+	0,		// 115
+	0,		// 116
+	0,		// 117
+	0,		// 118
+	0,		// 119
+
+	0,		// 120
+	0,		// 121
+	0,		// 122
+	0,		// 123
+	0,		// 124
+	0,		// 125
+	0,		// 126
+	0,		// 127
+	0,		// 128  GEORGE'S GAME SECTION
+	0,		// 129	NICO'S TEXT		- on both CD's
+
+	0,		// 130
+	1,		// 131	BENOIR'S TEXT - on CD1
+	0,		// 132
+	1,		// 133	ROSSO'S TEXT	- on CD1
+	0,		// 134
+	0,		// 135
+	0,		// 136
+	0,		// 137
+	0,		// 138
+	0,		// 139
+
+	0,		// 140
+	0,		// 141
+	0,		// 142
+	0,		// 143
+	0,		// 144
+	1,		// 145	MOUE'S TEXT		- on CD1
+	1,		// 146	ALBERT'S TEXT	- on CD1
+};
 
 const MenuObject SwordMenu::_objectDefs[TOTAL_pockets + 1] = {
 	{	// 0 can't use

Index: sword1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sword1.cpp	20 Dec 2003 09:12:54 -0000	1.14
+++ sword1.cpp	20 Dec 2003 20:20:53 -0000	1.15
@@ -1065,16 +1065,27 @@
 	} while (true);
 }
 
+void SwordEngine::checkCd(void) {
+	uint8 needCd = _cdList[SwordLogic::_scriptVars[NEW_SCREEN]];
+	if (needCd == 0) {
+		if (_systemVars.currentCD == 0)
+			_systemVars.currentCD = 1;
+	} else
+		_systemVars.currentCD = needCd;
+}
+
 void SwordEngine::mainLoop(void) {
 	uint32 newTime, frameTime;
 	bool wantControlPanel = false;
 	do {
 		// do we need the section45-hack from sword.c here?
-		// todo: ensure right cd is inserted
+		checkCd();
+
 		_screen->newScreen(SwordLogic::_scriptVars[NEW_SCREEN]);
 		_logic->newScreen(SwordLogic::_scriptVars[NEW_SCREEN]);
+		_sound->newScreen(SwordLogic::_scriptVars[NEW_SCREEN]);
 		SwordLogic::_scriptVars[SCREEN] = SwordLogic::_scriptVars[NEW_SCREEN];
-		//		 let swordSound start room sfx
+		
 		do {
 			_music->stream();
 			frameTime = _system->get_msecs();

Index: sword1.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- sword1.h	20 Dec 2003 09:12:54 -0000	1.5
+++ sword1.h	20 Dec 2003 20:20:53 -0000	1.6
@@ -24,6 +24,7 @@
 #include "common/util.h"
 #include "sound/mixer.h"
 #include "base/gameDetector.h"
+#include "sworddefs.h"
 
 class SwordScreen;
 class SwordSound;
@@ -41,26 +42,12 @@
 	uint32	justRestoredGame;	// see main() in sword.c & New_screen() in gtm_core.c
 	uint32	gamePaused;			// 1 when paused
 	uint32	rate;				// game rate  => what's this for?
-	//uint32	textNumber;		// holds last text_no displayed => I think it was only for debugging
-	//uint32	endOfQ;				// next available slot in sound fx queue
-	//uint8	debug;				// toggles tdebug file
 
-	//uint8	saveGameFlag;		// controls save game loop							0=off 1=save game 2=restore game 3=restart 4=quit to dos
 	uint8	deathScreenFlag;	// 1 death screen version of the control panel, 2 = successful end of game, 3 = force restart
 	bool	forceRestart;
 	uint8	playSpeech;
 	uint8   showText;
-	//uint8   snrStatus;
-			// ^=> move into SwordControl... or whatever it will be.
-	//uint8	displayText;		// toggles debug text display						on "t"
-	//uint8	displayGrid;		// toggles debug grid display						on "g"
-	//uint8	displayMouse;		// toggles debug mouse display 					on "m"
-	//uint8	framesPerSecond;	// toggles one frame pre second mode		on "1"
-	//uint8	writingPCXs;		// writing a PCX every frame						on "f"
-	//int16	parallaxOn;			I think we don't need this.
     uint8	language;
-	//int32	currentMusic;
-	//uint32	gameCycle;
 };
 
 class SwordEngine : public Engine {
@@ -76,8 +63,8 @@
 	void delay(uint amount);
 	void initialize(void);
 
+	void checkCd(void);
 	void mainLoop(void);
-	void fnCheckCd(uint32 newScreen);
 	void startPositions(int32 startNumber);
 
 	uint16 _mouseX, _mouseY, _mouseState;
@@ -95,4 +82,5 @@
 	SwordSound	*_sound;
 	SwordMenu	*_menu;
 	SwordMusic  *_music;
+	static const uint8 _cdList[TOTAL_SECTIONS];
 };





More information about the Scummvm-git-logs mailing list