[Scummvm-cvs-logs] CVS: scummvm/sword1 logic.cpp,1.15,1.16 logic.h,1.6,1.7 memman.cpp,1.2,1.3 memman.h,1.1,1.2 mouse.cpp,1.8,1.9 mouse.h,1.5,1.6 music.cpp,1.5,1.6 objectman.cpp,1.2,1.3 objectman.h,1.2,1.3 resman.cpp,1.6,1.7 resman.h,1.3,1.4 router.h,1.4,1.5 sound.cpp,1.9,1.10 sound.h,1.4,1.5 sword1.cpp,1.13,1.14 sword1.h,1.4,1.5 swordres.h,1.1,1.2 text.cpp,1.4,1.5
Robert G?ffringmann
lavosspawn at users.sourceforge.net
Sat Dec 20 01:13:01 CET 2003
Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1:/tmp/cvs-serv14060/sword1
Modified Files:
logic.cpp logic.h memman.cpp memman.h mouse.cpp mouse.h
music.cpp objectman.cpp objectman.h resman.cpp resman.h
router.h sound.cpp sound.h sword1.cpp sword1.h swordres.h
text.cpp
Log Message:
added SwordControl (the control panel). Not yet finished.
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/logic.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- logic.cpp 19 Dec 2003 14:16:31 -0000 1.15
+++ logic.cpp 20 Dec 2003 09:12:54 -0000 1.16
@@ -48,19 +48,26 @@
_music = pMusic;
_sound = pSound;
_menu = pMenu;
- _textMan = new SwordText(_objMan, _resMan, false);
+ _textMan = NULL;
_screen->useTextManager(_textMan);
_router = new SwordRouter(_objMan, _resMan);
+ _eventMan = NULL;
+}
- //_collision = new SwordCollision(_objMan, this);
- _eventMan = new EventManager();
-
+void SwordLogic::initialize(void) {
memset(_scriptVars, 0, NUM_SCRIPT_VARS * sizeof(uint32));
for (uint8 cnt = 0; cnt < NON_ZERO_SCRIPT_VARS; cnt++)
_scriptVars[_scriptVarInit[cnt][0]] = _scriptVarInit[cnt][1];
+
+ delete _eventMan;
+ _eventMan = new EventManager();
+ delete _textMan;
+ _textMan = new SwordText(_objMan, _resMan, false);
+ _screen->useTextManager(_textMan);
_textRunning = _speechRunning = false;
_speechFinished = true;
+ _router->resetExtraData();
}
void SwordLogic::newScreen(uint32 screen) {
@@ -1542,7 +1549,7 @@
}
int SwordLogic::fnRestartGame(BsObject *cpt, int32 id, int32 a, int32 b, int32 c, int32 d, int32 z, int32 x) {
- SwordEngine::_systemVars.saveGameFlag = 3;
+ SwordEngine::_systemVars.forceRestart = true;
cpt->o_logic = LOGIC_quit;
return SCRIPT_STOP;
}
@@ -1553,8 +1560,7 @@
}
int SwordLogic::fnDeathScreen(BsObject *cpt, int32 id, int32 a, int32 b, int32 c, int32 d, int32 z, int32 x) {
- SwordEngine::_systemVars.saveGameFlag = 1;
- SwordEngine::_systemVars.snrStatus = 1;
+
if (_scriptVars[FINALE_OPTION_FLAG] == 4) // successful end of game!
SwordEngine::_systemVars.deathScreenFlag = 2;
else
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/logic.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- logic.h 17 Dec 2003 23:41:14 -0000 1.6
+++ logic.h 20 Dec 2003 09:12:54 -0000 1.7
@@ -46,6 +46,7 @@
public:
SwordLogic(ObjectMan *pObjMan, ResMan *resMan, SwordScreen *pScreen, SwordMouse *pMouse, SwordSound *pSound, SwordMusic *pMusic, SwordMenu *pMenu);
~SwordLogic(void);
+ void initialize(void);
void newScreen(uint32 screen);
void engine(void);
void updateScreenParams(void);
Index: memman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/memman.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- memman.cpp 19 Dec 2003 14:07:12 -0000 1.2
+++ memman.cpp 20 Dec 2003 09:12:54 -0000 1.3
@@ -67,6 +67,18 @@
}
}
+void MemMan::flush(void) {
+ while (_memListFree) {
+ free(_memListFreeEnd->data);
+ _memListFreeEnd->data = NULL;
+ _memListFreeEnd->cond = MEM_FREED;
+ _alloced -= _memListFreeEnd->size;
+ removeFromFreeList(_memListFreeEnd);
+ }
+ if (_alloced)
+ warning("MemMan::flush: Something's wrong: still %d bytes alloced", _alloced);
+}
+
void MemMan::checkMemoryUsage(void) {
while ((_alloced > MAX_ALLOC) && _memListFree) {
free(_memListFreeEnd->data);
@@ -92,19 +104,6 @@
}
void MemMan::removeFromFreeList(BsMemHandle *bsMem) {
- /*BsMemHandle *forw = _memListFree;
- BsMemHandle *rev = _memListFreeEnd;
-
- while (forw || rev) {
- if (!(forw && rev))
- error("mem list is completely fubared");
- printf("%p <-> %p\n", forw, rev);
- forw = forw->next;
- rev = rev->prev;
- }
- printf("\n");*/
- if (!(bsMem->prev || bsMem->next))
- warning("removeFromFreeList: memory block wasn't in list");
if (_memListFree == bsMem)
_memListFree = bsMem->next;
if (_memListFreeEnd == bsMem)
Index: memman.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/memman.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- memman.h 16 Dec 2003 02:09:24 -0000 1.1
+++ memman.h 20 Dec 2003 09:12:54 -0000 1.2
@@ -46,6 +46,7 @@
void setCondition(BsMemHandle *bsMem, uint16 pCond);
void freeNow(BsMemHandle *bsMem);
void initHandle(BsMemHandle *bsMem);
+ void flush(void);
private:
void addToFreeList(BsMemHandle *bsMem);
void removeFromFreeList(BsMemHandle *bsMem);
Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/mouse.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mouse.cpp 19 Dec 2003 14:07:12 -0000 1.8
+++ mouse.cpp 20 Dec 2003 09:12:54 -0000 1.9
@@ -35,14 +35,6 @@
_resMan = pResMan;
_objMan = pObjMan;
_system = system;
- _numObjs = 0;
- _menuStatus = _mouseStatus = 0; // mouse off and unlocked
- _getOff = 0;
- _specialPtrId = 0;
- _inTopMenu = false;
-
- for (uint8 cnt = 0; cnt < 17; cnt++)
- _pointers[cnt] = (MousePtr*)_resMan->mouseResOpen(MSE_POINTER + cnt);
/*_resMan->resOpen(MSE_POINTER); // normal mouse (1 frame anim)
_resMan->resOpen(MSE_OPERATE);
_resMan->resOpen(MSE_PICKUP);
@@ -63,6 +55,37 @@
// luggage & chess stuff is opened dynamically
}
+void SwordMouse::initialize(void) {
+ _numObjs = 0;
+ _menuStatus = _mouseStatus = 0; // mouse off and unlocked
+ _getOff = 0;
+ _specialPtrId = 0;
+ _inTopMenu = false;
+
+ for (uint8 cnt = 0; cnt < 17; cnt++)
+ _pointers[cnt] = (MousePtr*)_resMan->mouseResOpen(MSE_POINTER + cnt);
+}
+
+void SwordMouse::controlPanel(bool on) { // true on entering cpanel, false when leaving
+ static uint32 savedPtrId = 0, savedSpecialId = 0;
+ static uint8 savedMouseStatus;
+ if (on) {
+ savedPtrId = _currentPtrId;
+ savedSpecialId = _specialPtrId;
+ savedMouseStatus = _mouseStatus;
+ _mouseStatus = 1;
+ setPointer(MSE_POINTER, 0);
+ } else {
+ _currentPtrId = savedPtrId;
+ _mouseStatus = savedMouseStatus;
+ _specialPtrId = savedSpecialId;
+ if (_specialPtrId)
+ setPointer(_specialPtrId, 0);
+ else
+ setPointer(_currentPtrId + MSE_POINTER, 0);
+ }
+}
+
void SwordMouse::useLogicAndMenu(SwordLogic *pLogic, SwordMenu *pMenu) {
_logic = pLogic;
_menu = pMenu;
@@ -186,7 +209,7 @@
}
_frame = 0;
- if (resId == 0) {
+ if ((resId == 0) || (!(_mouseStatus & 1))) {
_system->set_mouse_cursor(NULL, 0, 0, 0, 0);
_system->show_mouse(false);
} else {
Index: mouse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/mouse.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- mouse.h 19 Dec 2003 14:07:12 -0000 1.5
+++ mouse.h 20 Dec 2003 09:12:54 -0000 1.6
@@ -67,6 +67,7 @@
class SwordMouse {
public:
SwordMouse(OSystem *system, ResMan *pResMan, ObjectMan *pObjMan);
+ void initialize(void);
void addToList(int id, BsObject *compact);
void useLogicAndMenu(SwordLogic *pLogic, SwordMenu *pMenu);
void setLuggage(uint32 resID, uint32 rate);
@@ -83,9 +84,9 @@
void fnLockMouse(void);
void fnUnlockMouse(void);
void setMenuStatus(uint8 status);
+ void controlPanel(bool on);
private:
MousePtr *_pointers[17];
- uint32 _currentPtrId, _frame;
OSystem *_system;
SwordLogic *_logic;
SwordMenu *_menu;
@@ -94,6 +95,7 @@
ObjectMan *_objMan;
uint16 _mouseX, _mouseY;
+ uint32 _currentPtrId, _frame;
uint8 _mouseStatus, _mouseCount;
uint16 _numObjs;
uint16 _lastState, _state;
Index: music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/music.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- music.cpp 19 Dec 2003 01:08:30 -0000 1.5
+++ music.cpp 20 Dec 2003 09:12:54 -0000 1.6
@@ -54,9 +54,7 @@
else {
_system->lock_mutex(_mutex);
len >>= 1;
- if (len > _smpInBuf)
- warning("SwordMusic::mixer: sample buffer underrun");
- else {
+ if (len <= _smpInBuf) {
uint32 maxLen = BUFSIZE - _bufPos;
if (len >= maxLen) {
for (uint32 cnt = 0; cnt < maxLen; cnt++)
Index: objectman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/objectman.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- objectman.cpp 17 Dec 2003 01:47:47 -0000 1.2
+++ objectman.cpp 20 Dec 2003 09:12:54 -0000 1.3
@@ -29,9 +29,14 @@
ObjectMan::ObjectMan(ResMan *pResourceMan) {
_resMan = pResourceMan;
+}
+
+void ObjectMan::initialize(void) {
for (uint16 cnt = 0; cnt < TOTAL_SECTIONS; cnt++)
- _liveList[cnt] = 0;
-
+ _liveList[cnt] = 0; // we don't need to close the files here. When this routine is
+ // called, the memory was flushed() anyways, so these resources
+ // already *are* closed.
+
_liveList[128] = _liveList[129] = _liveList[130] = _liveList[131] = _liveList[133] =
_liveList[134] = _liveList[145] = _liveList[146] = _liveList[TEXT_sect] = 1;
@@ -41,7 +46,6 @@
else
_cptData[cnt] = NULL;
}
-
}
ObjectMan::~ObjectMan(void) {
@@ -130,4 +134,20 @@
void ObjectMan::closeSection(uint32 screen) {
if (_liveList[screen] == 0) // close the section that PLAYER has just left, if it's empty now
_resMan->resClose(_objectList[screen]);
+}
+
+void ObjectMan::loadLiveList(uint16 *src) {
+ for (uint16 cnt = 0; cnt < TOTAL_SECTIONS; cnt++) {
+ if (_liveList[cnt]) {
+ _resMan->resClose(_objectList[cnt]);
+ _cptData[cnt] = NULL;
+ }
+ _liveList[cnt] = src[cnt];
+ if (_liveList[cnt])
+ _cptData[cnt] = ((uint8*)_resMan->cptResOpen(_objectList[cnt])) + sizeof(Header);
+ }
+}
+
+void ObjectMan::saveLiveList(uint16 *dest) {
+ memcpy(dest, _liveList, TOTAL_SECTIONS * sizeof(uint16));
}
Index: objectman.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/objectman.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- objectman.h 19 Dec 2003 14:07:12 -0000 1.2
+++ objectman.h 20 Dec 2003 09:12:54 -0000 1.3
@@ -32,8 +32,9 @@
public:
ObjectMan(ResMan *pResourceMan);
~ObjectMan(void);
+ void initialize(void);
+
BsObject *fetchObject(uint32 id);
- //void unlockObject(uint32 id);
uint32 fetchNoObjects(int section);
bool sectionAlive(uint16 section);
void megaEntering(uint16 section);
@@ -44,12 +45,15 @@
void unlockText(uint32 textId);
uint32 lastTextNumber(int section);
- void closeSection(uint32 screen);
+ void closeSection(uint32 screen);
+
+ void saveLiveList(uint16 *dest); // for loading/saving
+ void loadLiveList(uint16 *src);
private:
ResMan *_resMan;
static const uint32 _objectList[TOTAL_SECTIONS]; //a table of pointers to object files
static const uint32 _textList[TOTAL_SECTIONS][7]; //a table of pointers to text files
- int _liveList[TOTAL_SECTIONS]; //which sections are active
+ uint16 _liveList[TOTAL_SECTIONS]; //which sections are active
uint8 *_cptData[TOTAL_SECTIONS];
};
Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/resman.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- resman.cpp 19 Dec 2003 14:07:12 -0000 1.6
+++ resman.cpp 20 Dec 2003 09:12:54 -0000 1.7
@@ -100,7 +100,8 @@
if (BsClu *cluster = _prj.clu[clusCnt]) {
for (uint32 grpCnt = 0; grpCnt < cluster->noGrp; grpCnt++)
if (BsGrp *group = cluster->grp[grpCnt]) {
- _memMan->freeNow(group->resHandle);
+ for (uint32 resCnt = 0; resCnt < group->noRes; resCnt++)
+ _memMan->freeNow(group->resHandle + resCnt);
delete[] group->resHandle;
delete[] group->offset;
delete[] group->length;
@@ -112,6 +113,18 @@
delete[] _prj.clu;
}
+void ResMan::flush(void) {
+ for (uint32 clusCnt = 0; clusCnt < _prj.noClu; clusCnt++)
+ if (BsClu *cluster = _prj.clu[clusCnt])
+ for (uint32 grpCnt = 0; grpCnt < cluster->noGrp; grpCnt++)
+ if (BsGrp *group = cluster->grp[grpCnt])
+ for (uint32 resCnt = 0; resCnt < group->noRes; resCnt++)
+ if (group->resHandle[resCnt].cond != MEM_FREED) {
+ _memMan->setCondition(group->resHandle + resCnt, MEM_CAN_FREE);
+ group->resHandle[resCnt].refCount = 0;
+ }
+}
+
void *ResMan::fetchRes(uint32 id) {
BsMemHandle *memHandle = resHandle(id);
if (!memHandle->data)
@@ -192,10 +205,11 @@
BsMemHandle *handle = resHandle(id);
if (!handle->refCount) {
warning("Resource Manager fail: unlocking object with refCount 0. Id: %d\n", id);
- } else
+ } else {
handle->refCount--;
- if (!handle->refCount)
- _memMan->setCondition( handle, MEM_CAN_FREE);
+ if (!handle->refCount)
+ _memMan->setCondition( handle, MEM_CAN_FREE);
+ }
}
FrameHeader *ResMan::fetchFrame(void *resourceData, uint32 frameNo) {
Index: resman.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/resman.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- resman.h 19 Dec 2003 14:07:12 -0000 1.3
+++ resman.h 20 Dec 2003 09:12:54 -0000 1.4
@@ -50,6 +50,7 @@
public:
ResMan(const char *resFile, MemMan *pMemoMan);
~ResMan(void);
+ void flush(void);
void resClose(uint32 id);
void resOpen(uint32 id);
void *fetchRes(uint32 id);
Index: router.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/router.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- router.h 19 Dec 2003 14:07:12 -0000 1.4
+++ router.h 20 Dec 2003 09:12:54 -0000 1.5
@@ -79,16 +79,6 @@
int32 num;
};
-/*struct FrameInfos {
- int32 framesPerStep, framesPerChar;
- int32 standFrames;
- int32 slowInFrames, slowOutFrames;
- int32 turnFramesLeft, turnFramesRight;
- int32 walkFramesLeft, walkFramesRight;
- uint16 startX, startY, targetX, targetY, targetDir;
- int32 scaleA, scaleB;
-};*/
-
#define ROUTE_END_FLAG 255
#define NO_DIRECTIONS 8
#define MAX_FRAMES_PER_CYCLE 16
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sound.cpp 19 Dec 2003 14:07:12 -0000 1.9
+++ sound.cpp 20 Dec 2003 09:12:54 -0000 1.10
@@ -121,7 +121,7 @@
return (_speechHandle == 0);
}
-void SwordSound::newScreen(uint16 screen) {
+void SwordSound::quitScreen(void) {
// stop all running SFX
while (_endOfQueue)
fnStopFx(_fxQueue[0].id);
Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sound.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound.h 19 Dec 2003 06:51:32 -0000 1.4
+++ sound.h 20 Dec 2003 09:12:54 -0000 1.5
@@ -57,7 +57,7 @@
public:
SwordSound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan);
~SwordSound(void);
- void newScreen(uint16 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.
Index: sword1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- sword1.cpp 19 Dec 2003 14:07:12 -0000 1.13
+++ sword1.cpp 20 Dec 2003 09:12:54 -0000 1.14
@@ -39,6 +39,7 @@
#include "swordres.h"
#include "menu.h"
#include "music.h"
+#include "control.h"
/* Broken Sword 1 */
static const GameSettings sword1_setting =
@@ -113,10 +114,10 @@
_mouse->useLogicAndMenu(_logic, _menu);
_systemVars.justRestoredGame = _systemVars.currentCD =
- _systemVars.gamePaused = _systemVars.saveGameFlag =
- _systemVars.deathScreenFlag = _systemVars.currentMusic = 0;
- _systemVars.snrStatus = 0;
+ _systemVars.gamePaused = 0;
+ _systemVars.deathScreenFlag = 3;
_systemVars.rate = 8;
+ _systemVars.forceRestart = false;
switch (Common::parseLanguage(ConfMan.get("language"))) {
case Common::DE_DEU:
@@ -142,8 +143,21 @@
_systemVars.showText = ConfMan.getBool("subtitles");
_systemVars.playSpeech = 1;
- startPositions(ConfMan.getInt("boot_param"));
_mouseState = 0;
+
+ _logic->initialize();
+ _objectMan->initialize();
+ _mouse->initialize();
+}
+
+void SwordEngine::reinitialize(void) {
+ _resMan->flush(); // free everything that's currently alloced and opened.
+ _memMan->flush(); // Handle with care.
+
+ _logic->initialize(); // now reinitialize these objects as they (may) have locked
+ _objectMan->initialize(); // resources which have just been wiped.
+ _mouse->initialize();
+ // todo: reinitialize swordmenu.
}
void SwordEngine::startPositions(int32 startNumber) {
@@ -1000,27 +1014,63 @@
error("Can't start in location %d", startNumber);
}
-
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;
}
void SwordEngine::go(void) {
initialize();
+ _systemVars.deathScreenFlag = 3;
// check if we have savegames. if we do, show control panel, else start intro.
+ /* death flags:
+ 0 = not dead, normal game
+ 1 = dead
+ 2 = game won
+ 3 = game was just started */
+ SwordControl *control = new SwordControl(_resMan, _objectMan, _system, _mouse, getSavePath());
+ uint8 controlRes = 0;
+
+ uint8 startPos = ConfMan.getInt("boot_param");
+ if (startPos) {
+ startPositions(startPos);
+ _systemVars.deathScreenFlag = 0;
+ } else {
+ // Temporary:
+ startPositions(0);
+ _systemVars.deathScreenFlag = 0;
+ //todo: check if we have savegames. if we do, show control panel, else start intro.
+ //control->runPanel();
+ }
+
do {
- mainLoop();
- // mainLoop was left, show control panel
+ mainLoop();
+
+ // the mainloop was left, either because the player pressed F5 or because the logic
+ // wants to restart the game.
+ if (!_systemVars.forceRestart)
+ controlRes = control->runPanel();
+ if ((controlRes == CONTROL_RESTART_GAME) || (_systemVars.forceRestart)) {
+ _music->fadeDown();
+ startPositions(1);
+ _systemVars.forceRestart = false;
+ } else if (controlRes == CONTROL_GAME_RESTORED) {
+ reinitialize(); // first clear anything which was loaded
+ control->doRestore(); // then actually load the savegame data.
+ _mouse->fnUnlockMouse(); // and allow mouse movements.
+ _mouse->fnAddHuman();
+ }
+ _systemVars.deathScreenFlag = 0;
} while (true);
}
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
- _sound->newScreen(SwordLogic::_scriptVars[NEW_SCREEN]);
_screen->newScreen(SwordLogic::_scriptVars[NEW_SCREEN]);
_logic->newScreen(SwordLogic::_scriptVars[NEW_SCREEN]);
SwordLogic::_scriptVars[SCREEN] = SwordLogic::_scriptVars[NEW_SCREEN];
@@ -1028,7 +1078,6 @@
do {
_music->stream();
frameTime = _system->get_msecs();
- _systemVars.saveGameFlag = 0;
_logic->engine();
_logic->updateScreenParams(); // sets scrolling
@@ -1066,23 +1115,24 @@
_mouse->engine( _mouseX, _mouseY, _mouseState);
_mouseState = 0;
+ if (_keyPressed == 63)
+ wantControlPanel = true;
// do something smart here to implement pausing the game. If we even want that, that is.
} while ((SwordLogic::_scriptVars[SCREEN] == SwordLogic::_scriptVars[NEW_SCREEN]) &&
- (_systemVars.saveGameFlag < 2)); // change screen
-
+ (!_systemVars.forceRestart) && (!wantControlPanel));
+
if (SwordLogic::_scriptVars[SCREEN] != 53) // we don't fade down after syria pan (53).
_screen->fadeDownPalette();
while (_screen->stillFading()) {
_music->stream();
_screen->updateScreen();
delay(1000/12);
- // todo: fade sfx?
}
+ _sound->quitScreen();
_screen->quitScreen(); // close graphic resources
_objectMan->closeSection(SwordLogic::_scriptVars[SCREEN]); // close the section that PLAYER has just left, if it's empty now
- // todo: stop sfx, clear sfx queue, free sfx memory
- } while (_systemVars.saveGameFlag < 2);
+ } while ((!_systemVars.forceRestart) && (!wantControlPanel));
}
void SwordEngine::delay(uint amount) { //copied and mutilated from sky.cpp
@@ -1091,7 +1141,7 @@
uint32 start = _system->get_msecs();
uint32 cur = start;
- uint16 _key_pressed = 0; //reset
+ _keyPressed = 0;
do {
while (_system->poll_event(&event)) {
@@ -1100,9 +1150,9 @@
// Make sure backspace works right (this fixes a small issue on OS X)
if (event.kbd.keycode == 8)
- _key_pressed = 8;
+ _keyPressed = 8;
else
- _key_pressed = (byte)event.kbd.ascii;
+ _keyPressed = (uint8)event.kbd.ascii;
break;
case OSystem::EVENT_MOUSEMOVE:
_mouseX = event.mouse.x;
Index: sword1.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/sword1.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sword1.h 19 Dec 2003 14:07:12 -0000 1.4
+++ sword1.h 20 Dec 2003 09:12:54 -0000 1.5
@@ -45,11 +45,12 @@
//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
+ //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;
+ //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"
@@ -57,8 +58,8 @@
//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;
+ uint8 language;
+ //int32 currentMusic;
//uint32 gameCycle;
};
@@ -68,16 +69,19 @@
SwordEngine(GameDetector *detector, OSystem *syst);
virtual ~SwordEngine();
static SystemVars _systemVars;
+ void reinitialize(void);
protected:
void go();
private:
void delay(uint amount);
void initialize(void);
+
void mainLoop(void);
void fnCheckCd(uint32 newScreen);
void startPositions(int32 startNumber);
uint16 _mouseX, _mouseY, _mouseState;
+ uint8 _keyPressed;
GameDetector *_detector;
OSystem *_system;
Index: swordres.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/swordres.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- swordres.h 16 Dec 2003 02:09:25 -0000 1.1
+++ swordres.h 20 Dec 2003 09:12:54 -0000 1.2
@@ -996,32 +996,34 @@
#define ICON_YES 0x0404005D
// 94 entities in TXTs, 94 in datafiles.
// save_menu
-#define SR_BUTTON 0x04050000
-#define SR_PALETTE 0x04050001
-#define SR_PANEL_ENGLISH 0x04050002
-#define SR_PANEL_FRENCH 0x04050003
-#define SR_PANEL_GERMAN 0x04050004
-#define SR_PANEL_ITALIAN 0x04050005
-#define SR_PANEL_SPANISH 0x04050006
-#define SR_PANEL_AMERICAN 0x04050007
-#define SR_TEXT_BUTTON 0x04050008
-#define SR_SPEED 0x04050009
-#define SR_SCROLL1 0x0405000A
-#define SR_SCROLL2 0x0405000B
-#define SR_CONFIRM 0x0405000C
-#define SR_VOLUME 0x0405000D
-#define SR_VLIGHT 0x0405000E
-#define SR_VKNOB 0x0405000F
-#define SR_WINDOW 0x04050010
-#define SR_SLAB1 0x04050011
-#define SR_SLAB2 0x04050012
-#define SR_SLAB3 0x04050013
-#define SR_SLAB4 0x04050014
-#define SR_BUTUF 0x04050015
-#define SR_BUTUS 0x04050016
-#define SR_BUTDS 0x04050017
-#define SR_BUTDF 0x04050018
-#define SR_DEATHPANEL 0x04050019
+#define SR_UNKNOWN_RESOURCE1 0x04050000
+#define SR_BUTTON 0x04050001
+#define SR_UNKNOWN_RESOURCE2 0x04050002 // this is actually the red font
+#define SR_PALETTE 0x04050003
+#define SR_PANEL_ENGLISH 0x04050004
+#define SR_PANEL_FRENCH 0x04050005
+#define SR_PANEL_GERMAN 0x04050006
+#define SR_PANEL_ITALIAN 0x04050007
+#define SR_PANEL_SPANISH 0x04050008
+#define SR_PANEL_AMERICAN 0x04050009
+#define SR_TEXT_BUTTON 0x0405000A
+#define SR_SPEED 0x0405000B
+#define SR_SCROLL1 0x0405000C
+#define SR_SCROLL2 0x0405000D
+#define SR_CONFIRM 0x0405000E
+#define SR_VOLUME 0x0405000F
+#define SR_VLIGHT 0x04050010
+#define SR_VKNOB 0x04050011
+#define SR_WINDOW 0x04050012
+#define SR_SLAB1 0x04050013
+#define SR_SLAB2 0x04050014
+#define SR_SLAB3 0x04050015
+#define SR_SLAB4 0x04050016
+#define SR_BUTUF 0x04050017
+#define SR_BUTUS 0x04050018
+#define SR_BUTDS 0x04050019
+#define SR_BUTDF 0x0405001A
+#define SR_DEATHPANEL 0x0405001B // 0x04050019
// 26 entities in TXTs, 29 in datafiles.
// george
#define GEORGE_MEGA 0x04060000
Index: text.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/text.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- text.cpp 18 Dec 2003 12:52:04 -0000 1.4
+++ text.cpp 20 Dec 2003 09:12:54 -0000 1.5
@@ -48,6 +48,13 @@
_textBlocks[0] = _textBlocks[1] = NULL;
}
+SwordText::~SwordText(void) {
+ if (_textBlocks[0])
+ free(_textBlocks[0]);
+ if (_textBlocks[1])
+ free(_textBlocks[1]);
+}
+
uint32 SwordText::lowTextManager(uint8 *ascii, int32 width, uint8 pen) {
_textCount++;
if (_textCount > MAX_TEXT_OBS)
@@ -170,7 +177,9 @@
void SwordText::releaseText(uint32 id) {
id &= ITM_ID;
assert(id <= 1);
- free(_textBlocks[id]);
- _textBlocks[id] = NULL;
- _textCount--;
+ if (_textBlocks[id]) {
+ free(_textBlocks[id]);
+ _textBlocks[id] = NULL;
+ _textCount--;
+ }
}
More information about the Scummvm-git-logs
mailing list