[Scummvm-cvs-logs] CVS: scummvm/sword1 control.cpp,1.9,1.10 control.h,1.2,1.3 logic.cpp,1.24,1.25 mouse.cpp,1.12,1.13 music.cpp,1.8,1.9 screen.cpp,1.26,1.27 sound.cpp,1.18,1.19 sound.h,1.7,1.8 sword1.cpp,1.23,1.24
Robert G?ffringmann
lavosspawn at users.sourceforge.net
Sun Dec 28 15:25:01 CET 2003
Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1:/tmp/cvs-serv29895/sword1
Modified Files:
control.cpp control.h logic.cpp mouse.cpp music.cpp screen.cpp
sound.cpp sound.h sword1.cpp
Log Message:
this fixes the remaining glitches
Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- control.cpp 28 Dec 2003 19:03:35 -0000 1.9
+++ control.cpp 28 Dec 2003 23:24:02 -0000 1.10
@@ -31,6 +31,7 @@
#include "sword1.h"
#include "common/util.h"
#include "mouse.h"
+#include "music.h"
#define SAVEFILE_WRITE true
#define SAVEFILE_READ false
@@ -144,11 +145,12 @@
draw();
}
-SwordControl::SwordControl(ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, SwordMouse *pMouse, const char *savePath) {
+SwordControl::SwordControl(ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, SwordMouse *pMouse, SwordMusic *pMusic, const char *savePath) {
_resMan = pResMan;
_objMan = pObjMan;
_system = system;
_mouse = pMouse;
+ _music = pMusic;
strcpy(_savePath, savePath);
}
@@ -173,8 +175,10 @@
bool fullRefresh = false;
_mouse->controlPanel(true);
uint8 retVal = CONTROL_NOTHING_DONE;
+ _music->startMusic(61, 1);
do {
+ _music->stream();
if (newMode) {
mode = newMode;
fullRefresh = true;
@@ -214,6 +218,7 @@
_system->copy_rect(_screenBuf, 640, 0, 0, 640, 480);
free(_screenBuf);
_mouse->controlPanel(false);
+ _music->startMusic(SwordLogic::_scriptVars[CURRENT_MUSIC], 1);
return retVal;
}
@@ -306,7 +311,7 @@
}
if (SwordEngine::_systemVars.deathScreenFlag == 2) // end of game
- renderText(_lStrings[STR_THE_END], 480, 188, TEXT_RIGHT_ALIGN);
+ renderText(_lStrings[STR_THE_END], 480, 188 + 40, TEXT_RIGHT_ALIGN);
if (SwordEngine::_systemVars.deathScreenFlag == 0) { // normal panel
renderText(_lStrings[STR_SAVE], 180, 188 + 40, TEXT_LEFT_ALIGN);
@@ -321,7 +326,7 @@
} else {
renderText(_lStrings[STR_RESTORE], 285, 224 + 40, TEXT_LEFT_ALIGN);
if (SwordEngine::_systemVars.deathScreenFlag == 3) // just started game
- renderText(_lStrings[STR_START], 285, 260, TEXT_LEFT_ALIGN);
+ renderText(_lStrings[STR_START], 285, 260 + 40, TEXT_LEFT_ALIGN);
else
renderText(_lStrings[STR_RESTART], 285, 260 + 40, TEXT_LEFT_ALIGN);
renderText(_lStrings[STR_QUIT], 285, 296 + 40, TEXT_LEFT_ALIGN);
@@ -543,7 +548,7 @@
while (*str) {
uint8 *dst = _screenBuf + y * SCREEN_WIDTH + destX;
- FrameHeader *chSpr = _resMan->fetchFrame(_font, *str - 32);
+ FrameHeader *chSpr = _resMan->fetchFrame(_font, ((uint8)*str) - 32);
uint8 *sprData = (uint8*)chSpr + sizeof(FrameHeader);
for (uint16 cnty = 0; cnty < FROM_LE_16(chSpr->height); cnty++) {
for (uint16 cntx = 0; cntx < FROM_LE_16(chSpr->width); cntx++) {
@@ -563,7 +568,6 @@
}
-// I can hardly believe this is all it takes for loading and saving...
void SwordControl::saveGameToFile(uint8 slot) {
char fName[15];
uint16 cnt;
@@ -703,9 +707,9 @@
}
const ButtonInfo SwordControl::_deathButtons[3] = {
- {250, 224, SR_BUTTON, BUTTON_RESTORE_PANEL },
- {250, 260, SR_BUTTON, BUTTON_RESTART },
- {250, 296, SR_BUTTON, BUTTON_QUIT }
+ {250, 224 + 40, SR_BUTTON, BUTTON_RESTORE_PANEL },
+ {250, 260 + 40, SR_BUTTON, BUTTON_RESTART },
+ {250, 296 + 40, SR_BUTTON, BUTTON_QUIT }
};
const ButtonInfo SwordControl::_panelButtons[8] = {
Index: control.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- control.h 23 Dec 2003 16:58:06 -0000 1.2
+++ control.h 28 Dec 2003 23:24:02 -0000 1.3
@@ -29,7 +29,7 @@
class ResMan;
class OSystem;
class SwordMouse;
-class SwordEngine;
+class SwordMusic;
#define MAX_BUTTONS 16
@@ -63,7 +63,7 @@
class SwordControl {
public:
- SwordControl(ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, SwordMouse *pMouse, const char *savePath);
+ SwordControl(ResMan *pResMan, ObjectMan *pObjMan, OSystem *system, SwordMouse *pMouse, SwordMusic *pMusic, const char *savePath);
~SwordControl(void);
uint8 runPanel(void);
void doRestore(void);
@@ -113,7 +113,7 @@
ResMan *_resMan;
OSystem *_system;
SwordMouse *_mouse;
- SwordEngine *_engine;
+ SwordMusic *_music;
char _savePath[256];
uint8 *_font;
uint32 _fontId;
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/logic.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- logic.cpp 28 Dec 2003 19:03:35 -0000 1.24
+++ logic.cpp 28 Dec 2003 23:24:02 -0000 1.25
@@ -864,12 +864,11 @@
}
int SwordLogic::fnFadeUp(BsObject *cpt, int32 id, int32 speed, int32 d, int32 e, int32 f, int32 z, int32 x) {
- _scriptVars[NEW_PALETTE] = 1;
+ _screen->fadeUpPalette();
return SCRIPT_CONT;
}
int SwordLogic::fnCheckFade(BsObject *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x) {
-
_scriptVars[RETURN_VALUE] = (uint8)_screen->stillFading();
return SCRIPT_CONT;
}
@@ -901,7 +900,7 @@
int SwordLogic::fnPlaySequence(BsObject *cpt, int32 id, int32 sequenceId, int32 d, int32 e, int32 f, int32 z, int32 x) {
warning("fnPlaySequence(%d) called", sequenceId);
- _scriptVars[NEW_PALETTE] = 1;
+ //_scriptVars[NEW_PALETTE] = 1;
/* the logic usually calls fnFadeDown before playing the sequence, so we have to
set NEW_PALETTE now to force a palette refresh */
return SCRIPT_CONT;
Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/mouse.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mouse.cpp 21 Dec 2003 18:50:05 -0000 1.12
+++ mouse.cpp 28 Dec 2003 23:24:02 -0000 1.13
@@ -134,7 +134,7 @@
uint16 clicked = 0;
if (y > 40) {
for (uint16 priority = 0; (priority < 10) && (!touchedId); priority++) {
- for (uint16 cnt = 0; cnt < _numObjs; cnt++) {
+ for (uint16 cnt = 0; (cnt < _numObjs) && (!touchedId); cnt++) {
if ((_objList[cnt].compact->o_priority == priority) &&
(SwordLogic::_scriptVars[MOUSE_X] >= (uint32)_objList[cnt].compact->o_mouse_x1) &&
(SwordLogic::_scriptVars[MOUSE_X] <= (uint32)_objList[cnt].compact->o_mouse_x2) &&
Index: music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/music.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- music.cpp 22 Dec 2003 23:21:28 -0000 1.8
+++ music.cpp 28 Dec 2003 23:24:03 -0000 1.9
@@ -130,7 +130,7 @@
void SwordMusic::stream(void) {
// make sure we've got enough samples in buffer.
- if ((_smpInBuf < 4 * SAMPLERATE) && _playing) {
+ if ((_smpInBuf < 4 * SAMPLERATE) && _playing && _musicFile.isOpen()) {
_system->lock_mutex(_mutex);
uint32 loadTotal = BUFSIZE - _smpInBuf;
while (uint32 doLoad = loadTotal) {
Index: screen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/screen.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- screen.cpp 23 Dec 2003 00:59:18 -0000 1.26
+++ screen.cpp 28 Dec 2003 23:24:03 -0000 1.27
@@ -86,7 +86,7 @@
}
void SwordScreen::fadeUpPalette(void) {
- _fadingStep = 15;
+ _fadingStep = 1;
_fadingDirection = FADE_UP;
}
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- sound.cpp 28 Dec 2003 15:01:44 -0000 1.18
+++ sound.cpp 28 Dec 2003 23:24:03 -0000 1.19
@@ -105,7 +105,8 @@
}
bool SwordSound::amISpeaking(void) {
- return true;
+ _waveVolPos++;
+ return _waveVolume[_waveVolPos - 1];
}
bool SwordSound::speechFinished(void) {
@@ -202,12 +203,38 @@
}
free(fBuf);
*size = resSize * 2;
+ calcWaveVolume(dstData, resSize);
return dstData;
} else {
free(fBuf);
warning("SwordSound::uncompressSpeech(): DATA tag not found in wave header");
*size = 0;
return NULL;
+ }
+}
+
+void SwordSound::calcWaveVolume(int16 *data, uint32 length) {
+ int16 *blkPos = data + 918;
+ for (uint32 cnt = 0; cnt < WAVE_VOL_TAB_LENGTH; cnt++)
+ _waveVolume[cnt] = false;
+ _waveVolPos = 0;
+ for (uint32 blkCnt = 1; blkCnt < length / 918; blkCnt++) {
+ if (blkCnt >= WAVE_VOL_TAB_LENGTH) {
+ warning("Wave vol tab too small.");
+ return;
+ }
+ int32 average = 0;
+ for (uint32 cnt = 0; cnt < 918; cnt++)
+ average += blkPos[cnt];
+ average /= 918;
+ uint32 diff = 0;
+ for (uint32 cnt = 0; cnt < 918; cnt++) {
+ int16 smpDiff = *blkPos - average;
+ diff += (uint32)ABS(smpDiff);
+ blkPos++;
+ }
+ if (diff > WAVE_VOL_THRESHOLD)
+ _waveVolume[blkCnt - 1] = true;
}
}
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- sound.h 21 Dec 2003 15:55:55 -0000 1.7
+++ sound.h 28 Dec 2003 23:24:03 -0000 1.8
@@ -52,6 +52,8 @@
class SoundMixer;
class ResMan;
+#define WAVE_VOL_TAB_LENGTH 480
+#define WAVE_VOL_THRESHOLD 190000 //120000
class SwordSound {
public:
@@ -60,11 +62,10 @@
void newScreen(uint32 screen);
void quitScreen(void);
- bool startSpeech(uint16 roomNo, uint16 localNo); // this should work more or less.
- // Maybe we'll need a delay of 3 gameCycles.
+ bool startSpeech(uint16 roomNo, uint16 localNo);
bool speechFinished(void);
void stopSpeech();
- bool amISpeaking(void); // this is supposed to return if the sounddata is near the ending or very silent...
+ bool amISpeaking(void);
void fnStopFx(int32 fxNo);
int addToQueue(int32 fxNo);
@@ -77,6 +78,9 @@
void closeCowSystem(void);
int16 *uncompressSpeech(uint32 index, uint32 cSize, uint32 *size);
+ void calcWaveVolume(int16 *data, uint32 length);
+ bool _waveVolume[WAVE_VOL_TAB_LENGTH];
+ uint16 _waveVolPos;
File _cowFile;
uint32 *_cowHeader;
uint32 _cowHeaderSize;
Index: sword1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- sword1.cpp 28 Dec 2003 19:03:35 -0000 1.23
+++ sword1.cpp 28 Dec 2003 23:24:03 -0000 1.24
@@ -148,7 +148,7 @@
_logic->initialize();
_objectMan->initialize();
_mouse->initialize();
- _control = new SwordControl(_resMan, _objectMan, _system, _mouse, getSavePath());
+ _control = new SwordControl(_resMan, _objectMan, _system, _mouse, _music, getSavePath());
}
void SwordEngine::reinitialize(void) {
@@ -1023,6 +1023,7 @@
compact = (BsObject*)_objectMan->fetchObject(PLAYER);
_logic->fnEnterSection(compact, PLAYER, startNumber, 0, 0, 0, 0, 0); // (automatically opens the compact resource for that section)
_systemVars.deathScreenFlag = 0;
+ _systemVars.wantFade = true;
}
void SwordEngine::go(void) {
@@ -1055,6 +1056,8 @@
reinitialize();
if (action == CONTROL_GAME_RESTORED)
_control->doRestore();
+ else if (action == CONTROL_RESTART_GAME)
+ startPositions(1);
_systemVars.forceRestart = false;
_systemVars.deathScreenFlag = 0;
} while (true);
@@ -1108,7 +1111,7 @@
if (_systemVars.forceRestart)
retCode = CONTROL_RESTART_GAME;
- else if (_keyPressed == 63) {
+ else if (((_keyPressed == 63) && (SwordLogic::_scriptVars[MOUSE_STATUS] & 1)) || (_systemVars.deathScreenFlag)) {
retCode = _control->runPanel();
if (!retCode)
_screen->refreshPalette();
More information about the Scummvm-git-logs
mailing list