aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2011-09-07 23:54:34 +0200
committerJohannes Schickel2011-09-07 23:54:34 +0200
commit928cb5ab1196f800049ba3e22038acf9cab3bc60 (patch)
treeae0b956c483dd157e06ae04a85e586f09757306c
parentc346bf79b472eefea2a1e6b9ce01c5c3e342de73 (diff)
downloadscummvm-rg350-928cb5ab1196f800049ba3e22038acf9cab3bc60.tar.gz
scummvm-rg350-928cb5ab1196f800049ba3e22038acf9cab3bc60.tar.bz2
scummvm-rg350-928cb5ab1196f800049ba3e22038acf9cab3bc60.zip
SWORD1: Made code conform a bit better to our formatting guidelines.
Most is automatically converted via astyle + some manual fixes, hopefully I did not miss anything astyle messed up...
-rw-r--r--engines/sword1/control.cpp110
-rw-r--r--engines/sword1/control.h4
-rw-r--r--engines/sword1/detection.cpp36
-rw-r--r--engines/sword1/eventman.cpp36
-rw-r--r--engines/sword1/logic.cpp160
-rw-r--r--engines/sword1/logic.h188
-rw-r--r--engines/sword1/memman.cpp2
-rw-r--r--engines/sword1/memman.h6
-rw-r--r--engines/sword1/menu.cpp4
-rw-r--r--engines/sword1/mouse.cpp36
-rw-r--r--engines/sword1/mouse.h22
-rw-r--r--engines/sword1/object.h160
-rw-r--r--engines/sword1/objectman.cpp28
-rw-r--r--engines/sword1/objectman.h8
-rw-r--r--engines/sword1/resman.cpp108
-rw-r--r--engines/sword1/resman.h24
-rw-r--r--engines/sword1/router.cpp338
-rw-r--r--engines/sword1/router.h54
-rw-r--r--engines/sword1/screen.cpp58
-rw-r--r--engines/sword1/screen.h24
-rw-r--r--engines/sword1/sound.cpp94
-rw-r--r--engines/sword1/sound.h16
-rw-r--r--engines/sword1/sword1.cpp76
-rw-r--r--engines/sword1/sword1.h42
-rw-r--r--engines/sword1/sworddefs.h100
-rw-r--r--engines/sword1/text.cpp30
-rw-r--r--engines/sword1/text.h10
27 files changed, 887 insertions, 887 deletions
diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp
index 36d5a24e99..6e395116f9 100644
--- a/engines/sword1/control.cpp
+++ b/engines/sword1/control.cpp
@@ -122,8 +122,8 @@ ControlButton::ControlButton(uint16 x, uint16 y, uint32 resId, uint8 id, uint8 f
_width = (_width > SCREEN_WIDTH) ? SCREEN_WIDTH : _width;
_height = _resMan->getUint16(tmp->height);
if ((x == 0) && (y == 0)) { // center the frame (used for panels);
- _x = (((640 - _width) / 2) < 0)? 0 : ((640 - _width) / 2);
- _y = (((480 - _height) / 2) < 0)? 0 : ((480 - _height) / 2);
+ _x = (((640 - _width) / 2) < 0) ? 0 : ((640 - _width) / 2);
+ _y = (((480 - _height) / 2) < 0) ? 0 : ((480 - _height) / 2);
}
_dstBuf = screenBuf + _y * SCREEN_WIDTH + _x;
_system = system;
@@ -139,11 +139,11 @@ bool ControlButton::isSaveslot() {
void ControlButton::draw() {
FrameHeader *fHead = _resMan->fetchFrame(_resMan->fetchRes(_resId), _frameIdx);
- uint8 *src = (uint8*)fHead + sizeof(FrameHeader);
+ uint8 *src = (uint8 *)fHead + sizeof(FrameHeader);
uint8 *dst = _dstBuf;
if (SwordEngine::isPsx() && _resId) {
- uint8 *HIFbuf = (uint8*)malloc(_resMan->readUint16(&fHead->height) * _resMan->readUint16(&fHead->width));
+ uint8 *HIFbuf = (uint8 *)malloc(_resMan->readUint16(&fHead->height) * _resMan->readUint16(&fHead->width));
memset(HIFbuf, 0, _resMan->readUint16(&fHead->height) * _resMan->readUint16(&fHead->width));
Screen::decompressHIF(src, HIFbuf);
src = HIFbuf;
@@ -163,24 +163,24 @@ void ControlButton::draw() {
src += _resMan->readUint16(&fHead->width);
}
else if (_resId == SR_DEATHPANEL) { // Check for death panel psx version (which is 1/3 of original width)
- for (uint16 cnt = 0; cnt < _resMan->readUint16(&fHead->height)/2; cnt++) {
+ for (uint16 cnt = 0; cnt < _resMan->readUint16(&fHead->height) / 2; cnt++) {
//Stretched panel is bigger than 640px, check we don't draw outside screen
- for (uint16 cntx = 0; (cntx < (_resMan->readUint16(&fHead->width))/3) && (cntx < (SCREEN_WIDTH-3) ); cntx++)
+ for (uint16 cntx = 0; (cntx < (_resMan->readUint16(&fHead->width)) / 3) && (cntx < (SCREEN_WIDTH - 3)); cntx++)
if (src[cntx]) {
dst[cntx * 3] = src[cntx];
dst[cntx * 3 + 1] = src[cntx];
dst[cntx * 3 + 2] = src[cntx];
}
- dst+= SCREEN_WIDTH;
+ dst += SCREEN_WIDTH;
- for (uint16 cntx = 0; cntx < (_resMan->readUint16(&fHead->width))/3; cntx++)
+ for (uint16 cntx = 0; cntx < (_resMan->readUint16(&fHead->width)) / 3; cntx++)
if (src[cntx]) {
dst[cntx * 3] = src[cntx];
dst[cntx * 3 + 1] = src[cntx];
dst[cntx * 3 + 2] = src[cntx];
}
dst += SCREEN_WIDTH;
- src += _resMan->readUint16(&fHead->width)/3;
+ src += _resMan->readUint16(&fHead->width) / 3;
}
} else { //save slots needs to be multiplied by 2 in height
for (uint16 cnt = 0; cnt < _resMan->readUint16(&fHead->height); cnt++) {
@@ -198,7 +198,7 @@ void ControlButton::draw() {
}
dst += SCREEN_WIDTH;
- src += _resMan->readUint16(&fHead->width)/2;
+ src += _resMan->readUint16(&fHead->width) / 2;
}
}
@@ -242,13 +242,13 @@ Control::Control(Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMa
}
void Control::askForCd() {
- _screenBuf = (uint8*)malloc(640 * 480);
+ _screenBuf = (uint8 *)malloc(640 * 480);
uint32 fontId = SR_FONT;
if (SwordEngine::_systemVars.language == BS1_CZECH)
fontId = CZECH_SR_FONT;
- _font = (uint8*)_resMan->openFetchRes(fontId);
- uint8 *pal = (uint8*)_resMan->openFetchRes(SR_PALETTE);
- uint8 *palOut = (uint8*)malloc(256 * 3);
+ _font = (uint8 *)_resMan->openFetchRes(fontId);
+ uint8 *pal = (uint8 *)_resMan->openFetchRes(SR_PALETTE);
+ uint8 *palOut = (uint8 *)malloc(256 * 3);
for (uint16 cnt = 1; cnt < 256; cnt++) {
palOut[cnt * 3 + 0] = pal[cnt * 3 + 0] << 2;
palOut[cnt * 3 + 1] = pal[cnt * 3 + 1] << 2;
@@ -262,7 +262,7 @@ void Control::askForCd() {
char fName[10];
uint8 textA[50];
sprintf(fName, "cd%d.id", SwordEngine::_systemVars.currentCD);
- sprintf((char*)textA, "%s%d", _lStrings[STR_INSERT_CD_A], SwordEngine::_systemVars.currentCD);
+ sprintf((char *)textA, "%s%d", _lStrings[STR_INSERT_CD_A], SwordEngine::_systemVars.currentCD);
bool notAccepted = true;
bool refreshText = true;
do {
@@ -304,7 +304,7 @@ uint8 Control::runPanel() {
_restoreBuf = NULL;
_keyPressed.reset();
_numButtons = 0;
- _screenBuf = (uint8*)malloc(640 * 480);
+ _screenBuf = (uint8 *)malloc(640 * 480);
memset(_screenBuf, 0, 640 * 480);
_system->copyRectToScreen(_screenBuf, 640, 0, 0, 640, 480);
_sound->quitScreen();
@@ -314,11 +314,11 @@ uint8 Control::runPanel() {
fontId = CZECH_SR_FONT;
redFontId = CZECH_SR_REDFONT;
}
- _font = (uint8*)_resMan->openFetchRes(fontId);
- _redFont = (uint8*)_resMan->openFetchRes(redFontId);
+ _font = (uint8 *)_resMan->openFetchRes(fontId);
+ _redFont = (uint8 *)_resMan->openFetchRes(redFontId);
- uint8 *pal = (uint8*)_resMan->openFetchRes(SR_PALETTE);
- uint8 *palOut = (uint8*)malloc(256 * 3);
+ uint8 *pal = (uint8 *)_resMan->openFetchRes(SR_PALETTE);
+ uint8 *palOut = (uint8 *)malloc(256 * 3);
for (uint16 cnt = 1; cnt < 256; cnt++) {
palOut[cnt * 3 + 0] = pal[cnt * 3 + 0] << 2;
palOut[cnt * 3 + 1] = pal[cnt * 3 + 1] << 2;
@@ -491,7 +491,7 @@ uint8 Control::handleButtonClick(uint8 id, uint8 mode, uint8 *retVal) {
else
return mode;
} else if ((id == BUTTON_RESTORE_PANEL) || (id == BUTTON_SAVE_PANEL) ||
- (id == BUTTON_DONE) || (id == BUTTON_VOLUME_PANEL))
+ (id == BUTTON_DONE) || (id == BUTTON_VOLUME_PANEL))
return id;
else if (id == BUTTON_TEXT) {
SwordEngine::_systemVars.showText ^= 1;
@@ -641,14 +641,14 @@ void Control::handleVolumeClicks() {
clickDest = 2;
else if (ABS(mouseDiffY) <= 8) // right
clickDest = 3;
- else // lower right
+ else // lower right
clickDest = 4;
} else if (mouseDiffX < -8) { // left part
if (mouseDiffY < -8) // upper left
clickDest = 8;
else if (ABS(mouseDiffY) <= 8) // left
clickDest = 7;
- else // lower left
+ else // lower left
clickDest = 6;
} else { // middle
if (mouseDiffY < -8)
@@ -754,9 +754,9 @@ bool Control::getConfirm(const uint8 *title) {
bool Control::keyAccepted(uint16 ascii) {
static const char allowedSpecials[] = ",.:-()?! \"\'";
if (((ascii >= 'A') && (ascii <= 'Z')) ||
- ((ascii >= 'a') && (ascii <= 'z')) ||
- ((ascii >= '0') && (ascii <= '9')) ||
- strchr(allowedSpecials, ascii))
+ ((ascii >= 'a') && (ascii <= 'z')) ||
+ ((ascii >= '0') && (ascii <= '9')) ||
+ strchr(allowedSpecials, ascii))
return true;
else
return false;
@@ -792,7 +792,7 @@ void Control::readSavegameDescriptions() {
char saveName[40];
Common::String pattern = "sword1.???";
Common::StringArray filenames = _saveFileMan->listSavefiles(pattern);
- sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
_saveNames.clear();
@@ -811,7 +811,7 @@ void Control::readSavegameDescriptions() {
num++;
Common::InSaveFile *in = _saveFileMan->openForLoading(*file);
if (in) {
- in->readUint32LE(); // header
+ in->readUint32LE(); // header
in->read(saveName, 40);
_saveNames.push_back(saveName);
delete in;
@@ -860,9 +860,9 @@ void Control::checkForOldSaveGames() {
}
GUI::MessageDialog dialog0(
- _("ScummVM found that you have old savefiles for Broken Sword 1 that should be converted.\n"
- "The old save game format is no longer supported, so you will not be able to load your games if you don't convert them.\n\n"
- "Press OK to convert them now, otherwise you will be asked again the next time you start the game.\n"), _("OK"), _("Cancel"));
+ _("ScummVM found that you have old savefiles for Broken Sword 1 that should be converted.\n"
+ "The old save game format is no longer supported, so you will not be able to load your games if you don't convert them.\n\n"
+ "Press OK to convert them now, otherwise you will be asked again the next time you start the game.\n"), _("OK"), _("Cancel"));
int choice = dialog0.runModal();
if (choice == GUI::kMessageCancel) {
@@ -889,8 +889,8 @@ void Control::checkForOldSaveGames() {
}
} while ((ch != 10) && (ch != 255) && (!inf->eos()));
- if (pos > 1) // if the slot has a description
- convertSaveGame(slot, (char*)saveName);
+ if (pos > 1) // if the slot has a description
+ convertSaveGame(slot, (char *)saveName);
slot++;
} while ((ch != 255) && (!inf->eos()));
@@ -906,12 +906,12 @@ void Control::showSavegameNames() {
uint8 textMode = TEXT_LEFT_ALIGN;
uint16 ycoord = _saveButtons[cnt].y + 2;
uint8 str[40];
- sprintf((char*)str, "%d. %s", cnt + _saveScrollPos + 1, _saveNames[cnt + _saveScrollPos].c_str());
+ sprintf((char *)str, "%d. %s", cnt + _saveScrollPos + 1, _saveNames[cnt + _saveScrollPos].c_str());
if (cnt + _saveScrollPos == _selectedSavegame) {
textMode |= TEXT_RED_FONT;
ycoord += 2;
if (_cursorVisible)
- strcat((char*)str, "_");
+ strcat((char *)str, "_");
}
renderText(str, _saveButtons[cnt].x + 6, ycoord, textMode);
}
@@ -1013,7 +1013,7 @@ void Control::renderText(const uint8 *str, uint16 x, uint16 y, uint8 mode) {
uint8 *dst = _screenBuf + y * SCREEN_WIDTH + destX;
FrameHeader *chSpr = _resMan->fetchFrame(font, *str - 32);
- uint8 *sprData = (uint8*)chSpr + sizeof(FrameHeader);
+ uint8 *sprData = (uint8 *)chSpr + sizeof(FrameHeader);
uint8 *HIFbuf = NULL;
if (SwordEngine::isPsx()) { //Text fonts are compressed in psx version
@@ -1056,7 +1056,7 @@ void Control::renderVolumeBar(uint8 id, uint8 volL, uint8 volR) {
uint8 vol = (chCnt == 0) ? volL : volR;
FrameHeader *frHead = _resMan->fetchFrame(_resMan->openFetchRes(SR_VLIGHT), (vol + 15) >> 4);
uint8 *destMem = _screenBuf + destY * SCREEN_WIDTH + destX;
- uint8 *srcMem = (uint8*)frHead + sizeof(FrameHeader);
+ uint8 *srcMem = (uint8 *)frHead + sizeof(FrameHeader);
uint16 barHeight = _resMan->getUint16(frHead->height);
uint8 *psxVolBuf = NULL;
@@ -1135,7 +1135,7 @@ void Control::saveGameToFile(uint8 slot) {
outf->writeUint32LE(Logic::_scriptVars[cnt]);
uint32 playerSize = (sizeof(Object) - 12000) / 4;
- uint32 *playerRaw = (uint32*)cpt;
+ uint32 *playerRaw = (uint32 *)cpt;
for (uint32 cnt2 = 0; cnt2 < playerSize; cnt2++)
outf->writeUint32LE(playerRaw[cnt2]);
outf->finalize();
@@ -1163,7 +1163,7 @@ bool Control::restoreGameFromFile(uint8 slot) {
return false;
}
- inf->skip(40); // skip description
+ inf->skip(40); // skip description
uint8 saveVersion = inf->readByte();
if (saveVersion > SAVEGAME_VERSION) {
@@ -1176,8 +1176,8 @@ bool Control::restoreGameFromFile(uint8 slot) {
Graphics::skipThumbnail(*inf);
- inf->readUint32BE(); // save date
- inf->readUint16BE(); // save time
+ inf->readUint32BE(); // save date
+ inf->readUint16BE(); // save time
if (saveVersion < 2) { // Before version 2 we didn't had play time feature
g_engine->setTotalPlayTime(0);
@@ -1185,14 +1185,14 @@ bool Control::restoreGameFromFile(uint8 slot) {
g_engine->setTotalPlayTime(inf->readUint32BE() * 1000);
}
- _restoreBuf = (uint8*)malloc(
- TOTAL_SECTIONS * 2 +
- NUM_SCRIPT_VARS * 4 +
- (sizeof(Object) - 12000));
+ _restoreBuf = (uint8 *)malloc(
+ TOTAL_SECTIONS * 2 +
+ NUM_SCRIPT_VARS * 4 +
+ (sizeof(Object) - 12000));
- uint16 *liveBuf = (uint16*)_restoreBuf;
- uint32 *scriptBuf = (uint32*)(_restoreBuf + 2 * TOTAL_SECTIONS);
- uint32 *playerBuf = (uint32*)(_restoreBuf + 2 * TOTAL_SECTIONS + 4 * NUM_SCRIPT_VARS);
+ uint16 *liveBuf = (uint16 *)_restoreBuf;
+ uint32 *scriptBuf = (uint32 *)(_restoreBuf + 2 * TOTAL_SECTIONS);
+ uint32 *playerBuf = (uint32 *)(_restoreBuf + 2 * TOTAL_SECTIONS + 4 * NUM_SCRIPT_VARS);
for (cnt = 0; cnt < TOTAL_SECTIONS; cnt++)
liveBuf[cnt] = inf->readUint16LE();
@@ -1215,7 +1215,7 @@ bool Control::restoreGameFromFile(uint8 slot) {
return true;
}
-bool Control::convertSaveGame(uint8 slot, char* desc) {
+bool Control::convertSaveGame(uint8 slot, char *desc) {
char oldFileName[15];
char newFileName[40];
sprintf(oldFileName, "SAVEGAME.%03d", slot);
@@ -1230,8 +1230,8 @@ bool Control::convertSaveGame(uint8 slot, char* desc) {
delete testSave;
Common::String msg = Common::String::format(_("Target new save game already exists!\n"
- "Would you like to keep the old save game (%s) or the new one (%s)?\n"),
- oldFileName, newFileName);
+ "Would you like to keep the old save game (%s) or the new one (%s)?\n"),
+ oldFileName, newFileName);
GUI::MessageDialog dialog0(msg, _("Keep the old one"), _("Keep the new one"));
int choice = dialog0.runModal();
@@ -1299,17 +1299,17 @@ bool Control::convertSaveGame(uint8 slot, char* desc) {
void Control::doRestore() {
uint8 *bufPos = _restoreBuf;
- _objMan->loadLiveList((uint16*)bufPos);
+ _objMan->loadLiveList((uint16 *)bufPos);
bufPos += TOTAL_SECTIONS * 2;
for (uint16 cnt = 0; cnt < NUM_SCRIPT_VARS; cnt++) {
- Logic::_scriptVars[cnt] = *(uint32*)bufPos;
+ Logic::_scriptVars[cnt] = *(uint32 *)bufPos;
bufPos += 4;
}
uint32 playerSize = (sizeof(Object) - 12000) / 4;
- uint32 *playerRaw = (uint32*)_objMan->fetchObject(PLAYER);
+ uint32 *playerRaw = (uint32 *)_objMan->fetchObject(PLAYER);
Object *cpt = _objMan->fetchObject(PLAYER);
for (uint32 cnt2 = 0; cnt2 < playerSize; cnt2++) {
- *playerRaw = *(uint32*)bufPos;
+ *playerRaw = *(uint32 *)bufPos;
playerRaw++;
bufPos += 4;
}
diff --git a/engines/sword1/control.h b/engines/sword1/control.h
index c3550e6f02..a80ea05b03 100644
--- a/engines/sword1/control.h
+++ b/engines/sword1/control.h
@@ -101,7 +101,7 @@ public:
private:
int displayMessage(const char *altButton, const char *message, ...) GCC_PRINTF(3, 4);
- bool convertSaveGame(uint8 slot, char* desc);
+ bool convertSaveGame(uint8 slot, char *desc);
void showSavegameNames();
void deselectSaveslots();
uint8 *_restoreBuf;
@@ -142,7 +142,7 @@ private:
ControlButton *_buttons[MAX_BUTTONS];
static const ButtonInfo _deathButtons[3], _panelButtons[7], _saveButtons[16], _volumeButtons[4];
static const uint8 _languageStrings[8 * 20][43];
- const uint8 (*_lStrings)[43];
+ const uint8(*_lStrings)[43];
Common::SaveFileManager *_saveFileMan;
ObjectMan *_objMan;
ResMan *_resMan;
diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp
index 4da636bce9..c2c03dee9f 100644
--- a/engines/sword1/detection.cpp
+++ b/engines/sword1/detection.cpp
@@ -48,7 +48,7 @@ static const PlainGameDescriptor sword1PSXDemoSettings =
// check these subdirectories (if present)
-static const char *g_dirNames[] = { "clusters", "speech", "english", "italian"};
+static const char *g_dirNames[] = { "clusters", "speech", "english", "italian"};
#define NUM_COMMON_FILES_TO_CHECK 1
#define NUM_PC_FILES_TO_CHECK 3
@@ -68,7 +68,7 @@ static const char *g_filesToCheck[NUM_FILES_TO_CHECK] = { // these files have to
"compacts.clm", // Mac version only
"scripts.clm", // Mac version only
"paris2.clm", // Mac version (full game only)
- "cows.mad", // this one should only exist in the demo version
+ "cows.mad", // this one should only exist in the demo version
"scripts.clm", // Mac version both demo and full game
"train.plx", // PSX version only
"speech.dat", // PSX version only
@@ -99,20 +99,20 @@ public:
bool SwordMetaEngine::hasFeature(MetaEngineFeature f) const {
return
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave) ||
- (f == kSavesSupportMetaInfo) ||
- (f == kSavesSupportThumbnail) ||
- (f == kSavesSupportCreationDate) ||
- (f == kSavesSupportPlayTime);
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate) ||
+ (f == kSavesSupportPlayTime);
}
bool Sword1::SwordEngine::hasFeature(EngineFeature f) const {
return
- (f == kSupportsRTL) ||
- (f == kSupportsSavingDuringRuntime) ||
- (f == kSupportsLoadingDuringRuntime);
+ (f == kSupportsRTL) ||
+ (f == kSupportsSavingDuringRuntime) ||
+ (f == kSupportsLoadingDuringRuntime);
}
GameList SwordMetaEngine::getSupportedGames() const {
@@ -225,7 +225,7 @@ SaveStateList SwordMetaEngine::listSaves(const char *target) const {
char saveName[40];
Common::StringArray filenames = saveFileMan->listSavefiles("sword1.???");
- sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
+ sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
int slotNum = 0;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
@@ -235,7 +235,7 @@ SaveStateList SwordMetaEngine::listSaves(const char *target) const {
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
- in->readUint32LE(); // header
+ in->readUint32LE(); // header
in->read(saveName, 40);
saveList.push_back(SaveStateDescriptor(slotNum, saveName));
delete in;
@@ -261,9 +261,9 @@ SaveStateDescriptor SwordMetaEngine::querySaveMetaInfos(const char *target, int
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName);
if (in) {
- in->skip(4); // header
+ in->skip(4); // header
in->read(name, sizeof(name));
- in->read(&versionSave, 1); // version
+ in->read(&versionSave, 1); // version
SaveStateDescriptor desc(slot, name);
@@ -323,7 +323,7 @@ Common::Error SwordEngine::loadGameState(int slot) {
reinitialize();
_control->doRestore();
reinitRes();
- return Common::kNoError; // TODO: return success/failure
+ return Common::kNoError; // TODO: return success/failure
}
bool SwordEngine::canLoadGameStateCurrently() {
@@ -333,7 +333,7 @@ bool SwordEngine::canLoadGameStateCurrently() {
Common::Error SwordEngine::saveGameState(int slot, const Common::String &desc) {
_control->setSaveDescription(slot, desc.c_str());
_control->saveGameToFile(slot);
- return Common::kNoError; // TODO: return success/failure
+ return Common::kNoError; // TODO: return success/failure
}
bool SwordEngine::canSaveGameStateCurrently() {
diff --git a/engines/sword1/eventman.cpp b/engines/sword1/eventman.cpp
index d95adebd86..113151bfd5 100644
--- a/engines/sword1/eventman.cpp
+++ b/engines/sword1/eventman.cpp
@@ -44,14 +44,14 @@ void EventManager::checkForEvent(Object *compact) {
if (compact->o_event_list[objCnt].o_event)
for (uint8 globCnt = 0; globCnt < TOTAL_EVENT_SLOTS; globCnt++) {
if (_eventPendingList[globCnt].delay &&
- (_eventPendingList[globCnt].eventNumber == compact->o_event_list[objCnt].o_event)) {
- compact->o_logic = LOGIC_script; //force into script mode
- _eventPendingList[globCnt].delay = 0; //started, so remove from queue
- compact->o_tree.o_script_level++;
- compact->o_tree.o_script_id[compact->o_tree.o_script_level] =
- compact->o_event_list[objCnt].o_event_script;
- compact->o_tree.o_script_pc[compact->o_tree.o_script_level] =
- compact->o_event_list[objCnt].o_event_script;
+ (_eventPendingList[globCnt].eventNumber == compact->o_event_list[objCnt].o_event)) {
+ compact->o_logic = LOGIC_script; //force into script mode
+ _eventPendingList[globCnt].delay = 0; //started, so remove from queue
+ compact->o_tree.o_script_level++;
+ compact->o_tree.o_script_id[compact->o_tree.o_script_level] =
+ compact->o_event_list[objCnt].o_event_script;
+ compact->o_tree.o_script_pc[compact->o_tree.o_script_level] =
+ compact->o_event_list[objCnt].o_event_script;
}
}
}
@@ -60,7 +60,7 @@ void EventManager::checkForEvent(Object *compact) {
bool EventManager::eventValid(int32 event) {
for (uint8 slot = 0; slot < TOTAL_EVENT_SLOTS; slot++)
if ((_eventPendingList[slot].eventNumber == event) &&
- (_eventPendingList[slot].delay))
+ (_eventPendingList[slot].delay))
return true;
return false;
}
@@ -76,15 +76,15 @@ int EventManager::fnCheckForEvent(Object *cpt, int32 id, int32 pause) {
if (cpt->o_event_list[objCnt].o_event)
for (uint8 globCnt = 0; globCnt < TOTAL_EVENT_SLOTS; globCnt++) {
if (_eventPendingList[globCnt].delay &&
- (_eventPendingList[globCnt].eventNumber == cpt->o_event_list[objCnt].o_event)) {
- cpt->o_logic = LOGIC_script; //force into script mode
- _eventPendingList[globCnt].delay = 0; //started, so remove from queue
- cpt->o_tree.o_script_level++;
- cpt->o_tree.o_script_id[cpt->o_tree.o_script_level] =
- cpt->o_event_list[objCnt].o_event_script;
- cpt->o_tree.o_script_pc[cpt->o_tree.o_script_level] =
- cpt->o_event_list[objCnt].o_event_script;
- return SCRIPT_STOP;
+ (_eventPendingList[globCnt].eventNumber == cpt->o_event_list[objCnt].o_event)) {
+ cpt->o_logic = LOGIC_script; //force into script mode
+ _eventPendingList[globCnt].delay = 0; //started, so remove from queue
+ cpt->o_tree.o_script_level++;
+ cpt->o_tree.o_script_id[cpt->o_tree.o_script_level] =
+ cpt->o_event_list[objCnt].o_event_script;
+ cpt->o_tree.o_script_pc[cpt->o_tree.o_script_level] =
+ cpt->o_event_list[objCnt].o_event_script;
+ return SCRIPT_STOP;
}
}
}
diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index 5b42c9340e..d8933bc2f7 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -89,14 +89,14 @@ void Logic::initialize() {
delete _textMan;
_textMan = new Text(_objMan, _resMan,
- (SwordEngine::_systemVars.language == BS1_CZECH) ? true : false);
+ (SwordEngine::_systemVars.language == BS1_CZECH) ? true : false);
_screen->useTextManager(_textMan);
_textRunning = _speechRunning = false;
_speechFinished = true;
}
void Logic::newScreen(uint32 screen) {
- Object *compact = (Object*)_objMan->fetchObject(PLAYER);
+ Object *compact = (Object *)_objMan->fetchObject(PLAYER);
// work around script bug #911508
if (((screen == 25) || (_scriptVars[SCREEN] == 25)) && (_scriptVars[SAND_FLAG] == 4)) {
@@ -115,15 +115,15 @@ void Logic::newScreen(uint32 screen) {
if (SwordEngine::_systemVars.justRestoredGame) { // if we've just restored a game - we want George to be exactly as saved
fnAddHuman(NULL, 0, 0, 0, 0, 0, 0, 0);
if (_scriptVars[GEORGE_WALKING]) { // except that if George was walking when we saveed the game
- fnStandAt(compact, PLAYER, _scriptVars[CHANGE_X], _scriptVars[CHANGE_Y], _scriptVars[CHANGE_DIR], _scriptVars[CHANGE_STANCE], 0,0);
- fnIdle(compact,PLAYER,0,0,0,0,0,0);
+ fnStandAt(compact, PLAYER, _scriptVars[CHANGE_X], _scriptVars[CHANGE_Y], _scriptVars[CHANGE_DIR], _scriptVars[CHANGE_STANCE], 0, 0);
+ fnIdle(compact, PLAYER, 0, 0, 0, 0, 0, 0);
_scriptVars[GEORGE_WALKING] = 0;
}
SwordEngine::_systemVars.justRestoredGame = 0;
_music->startMusic(_scriptVars[CURRENT_MUSIC], 1);
} else { // if we haven't just restored a game, set George to stand, etc
compact->o_screen = _scriptVars[NEW_SCREEN]; //move the mega/player at this point between screens
- fnStandAt(compact, PLAYER, _scriptVars[CHANGE_X], _scriptVars[CHANGE_Y], _scriptVars[CHANGE_DIR], _scriptVars[CHANGE_STANCE], 0,0);
+ fnStandAt(compact, PLAYER, _scriptVars[CHANGE_X], _scriptVars[CHANGE_Y], _scriptVars[CHANGE_DIR], _scriptVars[CHANGE_STANCE], 0, 0);
fnChangeFloor(compact, PLAYER, _scriptVars[CHANGE_PLACE], 0, 0, 0, 0, 0);
}
}
@@ -227,7 +227,7 @@ void Logic::processLogic(Object *compact, uint32 id) {
case LOGIC_restart:
compact->o_tree.o_script_pc[compact->o_tree.o_script_level] = compact->o_tree.o_script_id[compact->o_tree.o_script_level];
compact->o_logic = LOGIC_script;
- logicRet=1;
+ logicRet = 1;
break;
case LOGIC_bookmark:
memcpy(&(compact->o_tree.o_script_level), &(compact->o_bookmark.o_script_level), sizeof(ScriptTree));
@@ -293,41 +293,41 @@ int Logic::logicArAnimate(Object *compact, uint32 id) {
compact->o_status |= STAT_SHRINK;
route = compact->o_route;
- walkPc =compact->o_walk_pc;
- compact->o_frame =route[walkPc].frame;
- compact->o_dir =route[walkPc].dir;
- compact->o_xcoord =route[walkPc].x;
- compact->o_ycoord =route[walkPc].y;
- compact->o_anim_x =compact->o_xcoord;
- compact->o_anim_y =compact->o_ycoord;
+ walkPc = compact->o_walk_pc;
+ compact->o_frame = route[walkPc].frame;
+ compact->o_dir = route[walkPc].dir;
+ compact->o_xcoord = route[walkPc].x;
+ compact->o_ycoord = route[walkPc].y;
+ compact->o_anim_x = compact->o_xcoord;
+ compact->o_anim_y = compact->o_ycoord;
if (((_scriptVars[GEORGE_WALKING] == 2) && (walkPc > 5) && (id == PLAYER) &&
- (route[walkPc - 1].step == 5) && (route[walkPc].step == 0)) ||
- ((_scriptVars[GEORGE_WALKING] == 3) && (id == PLAYER))) {
-
- compact->o_frame = 96 + compact->o_dir; //reset
- if ((compact->o_dir != 2) && (compact->o_dir != 6)) { // on verticals and diagonals stand where george is
- compact->o_xcoord = route[walkPc - 1].x;
- compact->o_ycoord = route[walkPc - 1].y;
- compact->o_anim_x = compact->o_xcoord;
- compact->o_anim_y = compact->o_ycoord;
- }
- compact->o_logic = LOGIC_script;
- compact->o_down_flag = 0; //0 means error
- _scriptVars[GEORGE_WALKING] = 0;
- route[compact->o_walk_pc+1].frame = 512; //end of sequence
- if (_scriptVars[MEGA_ON_GRID] == 2)
- _scriptVars[MEGA_ON_GRID] = 0;
+ (route[walkPc - 1].step == 5) && (route[walkPc].step == 0)) ||
+ ((_scriptVars[GEORGE_WALKING] == 3) && (id == PLAYER))) {
+
+ compact->o_frame = 96 + compact->o_dir; //reset
+ if ((compact->o_dir != 2) && (compact->o_dir != 6)) { // on verticals and diagonals stand where george is
+ compact->o_xcoord = route[walkPc - 1].x;
+ compact->o_ycoord = route[walkPc - 1].y;
+ compact->o_anim_x = compact->o_xcoord;
+ compact->o_anim_y = compact->o_ycoord;
+ }
+ compact->o_logic = LOGIC_script;
+ compact->o_down_flag = 0; //0 means error
+ _scriptVars[GEORGE_WALKING] = 0;
+ route[compact->o_walk_pc + 1].frame = 512; //end of sequence
+ if (_scriptVars[MEGA_ON_GRID] == 2)
+ _scriptVars[MEGA_ON_GRID] = 0;
}
compact->o_walk_pc++;
- if (route[compact->o_walk_pc].frame == 512) { //end of sequence
+ if (route[compact->o_walk_pc].frame == 512) { //end of sequence
compact->o_logic = LOGIC_script;
if (((_scriptVars[GEORGE_WALKING] == 2) || (_scriptVars[GEORGE_WALKING] == 1)) &&
- (id == PLAYER)) {
- _scriptVars[GEORGE_WALKING] = 0;
- if (_scriptVars[MEGA_ON_GRID] == 2)
- _scriptVars[MEGA_ON_GRID] = 0;
+ (id == PLAYER)) {
+ _scriptVars[GEORGE_WALKING] = 0;
+ if (_scriptVars[MEGA_ON_GRID] == 2)
+ _scriptVars[MEGA_ON_GRID] = 0;
}
}
return 0;
@@ -360,16 +360,16 @@ int Logic::speechDriver(Object *compact) {
_speechFinished = true;
}
if (compact->o_anim_resource) {
- uint8 *animData = ((uint8*)_resMan->openFetchRes(compact->o_anim_resource)) + sizeof(Header);
+ uint8 *animData = ((uint8 *)_resMan->openFetchRes(compact->o_anim_resource)) + sizeof(Header);
int32 numFrames = _resMan->readUint32(animData);
animData += 4;
compact->o_anim_pc++; // go to next frame of anim
if (_speechFinished || (compact->o_anim_pc >= numFrames) ||
- (_speechRunning && (_sound->amISpeaking() == 0)))
- compact->o_anim_pc = 0; //set to frame 0, closed mouth
+ (_speechRunning && (_sound->amISpeaking() == 0)))
+ compact->o_anim_pc = 0; //set to frame 0, closed mouth
- AnimUnit *animPtr = (AnimUnit*)(animData + sizeof(AnimUnit) * compact->o_anim_pc);
+ AnimUnit *animPtr = (AnimUnit *)(animData + sizeof(AnimUnit) * compact->o_anim_pc);
if (!(compact->o_status & STAT_SHRINK)) {
compact->o_anim_x = _resMan->getUint32(animPtr->animX);
compact->o_anim_y = _resMan->getUint32(animPtr->animY);
@@ -385,10 +385,10 @@ int Logic::fullAnimDriver(Object *compact) {
compact->o_logic = LOGIC_script;
return 1;
}
- uint8 *data = ((uint8*)_resMan->openFetchRes(compact->o_anim_resource)) + sizeof(Header);
+ uint8 *data = ((uint8 *)_resMan->openFetchRes(compact->o_anim_resource)) + sizeof(Header);
uint32 numFrames = _resMan->readUint32(data);
data += 4;
- AnimUnit *animPtr = (AnimUnit*)(data + compact->o_anim_pc * sizeof(AnimUnit));
+ AnimUnit *animPtr = (AnimUnit *)(data + compact->o_anim_pc * sizeof(AnimUnit));
compact->o_anim_x = compact->o_xcoord = _resMan->getUint32(animPtr->animX);
compact->o_anim_y = compact->o_ycoord = _resMan->getUint32(animPtr->animY);
@@ -407,9 +407,9 @@ int Logic::animDriver(Object *compact) {
compact->o_logic = LOGIC_script;
return 1;
}
- uint8 *data = ((uint8*)_resMan->openFetchRes(compact->o_anim_resource)) + sizeof(Header);
+ uint8 *data = ((uint8 *)_resMan->openFetchRes(compact->o_anim_resource)) + sizeof(Header);
uint32 numFrames = _resMan->readUint32(data);
- AnimUnit *animPtr = (AnimUnit*)(data + 4 + compact->o_anim_pc * sizeof(AnimUnit));
+ AnimUnit *animPtr = (AnimUnit *)(data + 4 + compact->o_anim_pc * sizeof(AnimUnit));
if (!(compact->o_status & STAT_SHRINK)) {
compact->o_anim_x = _resMan->getUint32(animPtr->animX);
@@ -426,9 +426,9 @@ int Logic::animDriver(Object *compact) {
}
void Logic::updateScreenParams() {
- Object *compact = (Object*)_objMan->fetchObject(PLAYER);
+ Object *compact = (Object *)_objMan->fetchObject(PLAYER);
_screen->setScrolling((int16)(compact->o_xcoord - _scriptVars[FEET_X]),
- (int16)(compact->o_ycoord - _scriptVars[FEET_Y]));
+ (int16)(compact->o_ycoord - _scriptVars[FEET_Y]));
}
int Logic::scriptManager(Object *compact, uint32 id) {
@@ -465,7 +465,7 @@ void Logic::runMouseScript(Object *cpt, int32 scriptId) {
}
int Logic::interpretScript(Object *compact, int id, Header *scriptModule, int scriptBase, int scriptNum) {
- int32 *scriptCode = (int32*)(((uint8*)scriptModule) + sizeof(Header));
+ int32 *scriptCode = (int32 *)(((uint8 *)scriptModule) + sizeof(Header));
int32 stack[MAX_STACK_SIZE];
int32 stackIdx = 0;
int32 offset;
@@ -609,7 +609,7 @@ int Logic::interpretScript(Object *compact, int id, Header *scriptModule, int sc
debug(9, "IT_SCRIPTEND");
return 0;
case IT_POPVAR: // pop a variable
- debug(9, "IT_POPVAR: ScriptVars[%d] = %d", scriptCode[pc], stack[stackIdx-1]);
+ debug(9, "IT_POPVAR: ScriptVars[%d] = %d", scriptCode[pc], stack[stackIdx - 1]);
varNum = scriptCode[pc++];
if (SwordEngine::_systemVars.isDemo && SwordEngine::isPc()) {
if (varNum >= 397) // BS1 Demo has different number of script variables
@@ -622,15 +622,15 @@ int Logic::interpretScript(Object *compact, int id, Header *scriptModule, int sc
case IT_POPLONGOFFSET:
offset = scriptCode[pc++];
debug(9, "IT_POPLONGOFFSET: Cpt[%d] = %d", offset, stack[stackIdx - 1]);
- *((int32 *)((uint8*)compact + offset)) = stack[--stackIdx];
+ *((int32 *)((uint8 *)compact + offset)) = stack[--stackIdx];
break;
case IT_PUSHLONGOFFSET:
offset = scriptCode[pc++];
- debug(9, "IT_PUSHLONGOFFSET: PUSH Cpt[%d] (==%d)", offset, *((int32 *)((uint8*)compact + offset)));
- stack[stackIdx++] = *((int32 *)((uint8*)compact + offset));
+ debug(9, "IT_PUSHLONGOFFSET: PUSH Cpt[%d] (==%d)", offset, *((int32 *)((uint8 *)compact + offset)));
+ stack[stackIdx++] = *((int32 *)((uint8 *)compact + offset));
break;
case IT_SKIPONFALSE:
- debug(9, "IT_SKIPONFALSE: %d (%s)", scriptCode[pc], (stack[stackIdx-1] ? "IS TRUE (NOT SKIPPED)" : "IS FALSE (SKIPPED)"));
+ debug(9, "IT_SKIPONFALSE: %d (%s)", scriptCode[pc], (stack[stackIdx - 1] ? "IS TRUE (NOT SKIPPED)" : "IS FALSE (SKIPPED)"));
if (stack[--stackIdx])
pc++;
else
@@ -645,12 +645,12 @@ int Logic::interpretScript(Object *compact, int id, Header *scriptModule, int sc
{
int switchValue = stack[--stackIdx];
int switchCount = scriptCode[pc++];
- int doneSwitch=0;
+ int doneSwitch = 0;
- for (int cnt = 0; (cnt < switchCount) && (doneSwitch==0); cnt++) {
+ for (int cnt = 0; (cnt < switchCount) && (doneSwitch == 0); cnt++) {
if (switchValue == scriptCode[pc]) {
- pc += scriptCode[pc+1];
- doneSwitch=1;
+ pc += scriptCode[pc + 1];
+ doneSwitch = 1;
} else
pc += 2;
}
@@ -659,7 +659,7 @@ int Logic::interpretScript(Object *compact, int id, Header *scriptModule, int sc
}
break;
case IT_SKIPONTRUE: // skip if expression true
- debug(9, "IT_SKIPONTRUE: %d (%s)", scriptCode[pc], (stack[stackIdx-1] ? "IS TRUE (SKIPPED)" : "IS FALSE (NOT SKIPPED)"));
+ debug(9, "IT_SKIPONTRUE: %d (%s)", scriptCode[pc], (stack[stackIdx - 1] ? "IS TRUE (SKIPPED)" : "IS FALSE (NOT SKIPPED)"));
stackIdx--;
if (stack[stackIdx])
pc += scriptCode[pc];
@@ -667,7 +667,7 @@ int Logic::interpretScript(Object *compact, int id, Header *scriptModule, int sc
pc++;
break;
case IT_PRINTF:
- debug(0, "IT_PRINTF(%d)",stack[stackIdx]);
+ debug(0, "IT_PRINTF(%d)", stack[stackIdx]);
break;
case IT_RESTARTSCRIPT:
debug(9, "IT_RESTARTSCRIPT");
@@ -676,16 +676,16 @@ int Logic::interpretScript(Object *compact, int id, Header *scriptModule, int sc
case IT_POPWORDOFFSET:
offset = scriptCode[pc++];
debug(9, "IT_POPWORDOFFSET: Cpt[%d] = %d", offset, stack[stackIdx - 1] & 0xFFFF);
- *((int32 *)((uint8*)compact + offset)) = stack[--stackIdx] & 0xffff;
+ *((int32 *)((uint8 *)compact + offset)) = stack[--stackIdx] & 0xffff;
break;
case IT_PUSHWORDOFFSET:
offset = scriptCode[pc++];
- debug(9, "IT_PUSHWORDOFFSET: PUSH Cpt[%d] == %d", offset, (*((int32 *)((uint8*)compact + offset))) & 0xffff);
- stack[stackIdx++] = (*((int32 *)((uint8*)compact + offset))) & 0xffff;
+ debug(9, "IT_PUSHWORDOFFSET: PUSH Cpt[%d] == %d", offset, (*((int32 *)((uint8 *)compact + offset))) & 0xffff);
+ stack[stackIdx++] = (*((int32 *)((uint8 *)compact + offset))) & 0xffff;
break;
default:
- error("Invalid operator %d",scriptCode[pc-1]);
- return 0; // for compilers that don't support NORETURN
+ error("Invalid operator %d", scriptCode[pc - 1]);
+ return 0; // for compilers that don't support NORETURN
}
}
}
@@ -831,7 +831,7 @@ int Logic::fnAnim(Object *cpt, int32 id, int32 cdt, int32 spr, int32 e, int32 f,
AnimSet *animTab;
if (cdt && (!spr)) {
- animTab = (AnimSet*)((uint8*)_resMan->openFetchRes(cdt) + sizeof(Header));
+ animTab = (AnimSet *)((uint8 *)_resMan->openFetchRes(cdt) + sizeof(Header));
animTab += cpt->o_dir;
cpt->o_anim_resource = _resMan->getUint32(animTab->cdt);
@@ -865,13 +865,13 @@ int Logic::fnSetFrame(Object *cpt, int32 id, int32 cdt, int32 spr, int32 frameNo
AnimUnit *animPtr;
- uint8 *data = (uint8*)_resMan->openFetchRes(cdt);
+ uint8 *data = (uint8 *)_resMan->openFetchRes(cdt);
data += sizeof(Header);
if (frameNo == LAST_FRAME)
frameNo = _resMan->readUint32(data) - 1;
data += 4;
- animPtr = (AnimUnit*)(data + frameNo * sizeof(AnimUnit));
+ animPtr = (AnimUnit *)(data + frameNo * sizeof(AnimUnit));
cpt->o_anim_x = _resMan->getUint32(animPtr->animX);
cpt->o_anim_y = _resMan->getUint32(animPtr->animY);
@@ -895,13 +895,13 @@ int Logic::fnFullAnim(Object *cpt, int32 id, int32 anim, int32 graphic, int32 e,
}
int Logic::fnFullSetFrame(Object *cpt, int32 id, int32 cdt, int32 spr, int32 frameNo, int32 f, int32 z, int32 x) {
- uint8 *data = (uint8*)_resMan->openFetchRes(cdt) + sizeof(Header);
+ uint8 *data = (uint8 *)_resMan->openFetchRes(cdt) + sizeof(Header);
if (frameNo == LAST_FRAME)
frameNo = _resMan->readUint32(data) - 1;
data += 4;
- AnimUnit *animPtr = (AnimUnit*)(data + sizeof(AnimUnit) * frameNo);
+ AnimUnit *animPtr = (AnimUnit *)(data + sizeof(AnimUnit) * frameNo);
cpt->o_anim_x = cpt->o_xcoord = _resMan->getUint32(animPtr->animX);
cpt->o_anim_y = cpt->o_ycoord = _resMan->getUint32(animPtr->animY);
cpt->o_frame = _resMan->getUint32(animPtr->animFrame);
@@ -1115,7 +1115,7 @@ int Logic::fnISpeak(Object *cpt, int32 id, int32 cdt, int32 textNo, int32 spr, i
// first setup the talk animation
if (cdt && (!spr)) { // if 'cdt' is non-zero but 'spr' is zero - 'cdt' is an anim table tag
- AnimSet *animTab = (AnimSet*)((uint8*)_resMan->openFetchRes(cdt) + sizeof(Header));
+ AnimSet *animTab = (AnimSet *)((uint8 *)_resMan->openFetchRes(cdt) + sizeof(Header));
animTab += cpt->o_dir;
cpt->o_anim_resource = _resMan->getUint32(animTab->cdt);
@@ -1152,10 +1152,10 @@ int Logic::fnISpeak(Object *cpt, int32 id, int32 cdt, int32 textNo, int32 spr, i
char *text = _objMan->lockText(textNo);
cpt->o_speech_time = strlen(text) + 5;
- uint32 textCptId = _textMan->lowTextManager((uint8*)text, cpt->o_speech_width, (uint8)cpt->o_speech_pen);
+ uint32 textCptId = _textMan->lowTextManager((uint8 *)text, cpt->o_speech_width, (uint8)cpt->o_speech_pen);
_objMan->unlockText(textNo);
- Object * textCpt = _objMan->fetchObject(textCptId);
+ Object *textCpt = _objMan->fetchObject(textCptId);
textCpt->o_screen = cpt->o_screen;
textCpt->o_target = textCptId;
@@ -1247,7 +1247,7 @@ int Logic::fnChangeSpeechText(Object *cpt, int32 id, int32 tar, int32 width, int
//The game is halted for debugging. Maybe we'll remove this later.
int Logic::fnTalkError(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x) {
error("fnTalkError for id %d, instruction %d", id, cpt->o_down_flag);
- return SCRIPT_STOP; // for compilers that don't support NORETURN
+ return SCRIPT_STOP; // for compilers that don't support NORETURN
}
int Logic::fnStartTalk(Object *cpt, int32 id, int32 target, int32 d, int32 e, int32 f, int32 z, int32 x) {
@@ -1414,12 +1414,12 @@ int Logic::fnWalk(Object *cpt, int32 id, int32 x, int32 y, int32 dir, int32 stan
int32 target = _scriptVars[CLICK_ID];
// exceptions: compacts that use hand pointers but are not actually exits
if ((target != LEFT_SCROLL_POINTER) && (target != RIGHT_SCROLL_POINTER) &&
- (target != FLOOR_63) && (target != ROOF_63) && (target != GUARD_ROOF_63) &&
- (target != LEFT_TREE_POINTER_71) && (target != RIGHT_TREE_POINTER_71)) {
+ (target != FLOOR_63) && (target != ROOF_63) && (target != GUARD_ROOF_63) &&
+ (target != LEFT_TREE_POINTER_71) && (target != RIGHT_TREE_POINTER_71)) {
target = _objMan->fetchObject(_scriptVars[CLICK_ID])->o_mouse_on;
if ((target >= SCR_exit0) && (target <= SCR_exit9)) {
- fnStandAt(cpt,id,x,y,dir,stance,0,0);
+ fnStandAt(cpt, id, x, y, dir, stance, 0, 0);
return SCRIPT_STOP;
}
}
@@ -1439,13 +1439,13 @@ int Logic::fnTurn(Object *cpt, int32 id, int32 dir, int32 stance, int32 c, int32
dir = 9;
int route = _router->routeFinder(id, cpt, cpt->o_xcoord, cpt->o_ycoord, dir);
- if (route)
- cpt->o_down_flag = 1; //1 means ok
+ if (route)
+ cpt->o_down_flag = 1; //1 means ok
else
- cpt->o_down_flag = 0; //0 means error
+ cpt->o_down_flag = 0; //0 means error
cpt->o_logic = LOGIC_AR_animate;
- cpt->o_walk_pc = 0; //reset
+ cpt->o_walk_pc = 0; //reset
return SCRIPT_STOP;
}
@@ -1602,7 +1602,7 @@ int Logic::fnStopMusic(Object *cpt, int32 id, int32 a, int32 b, int32 c, int32 d
int Logic::fnInnerSpace(Object *cpt, int32 id, int32 a, int32 b, int32 c, int32 d, int32 z, int32 x) {
error("fnInnerSpace() not working");
- return SCRIPT_STOP; // for compilers that don't support NORETURN
+ return SCRIPT_STOP; // for compilers that don't support NORETURN
}
int Logic::fnSetScreen(Object *cpt, int32 id, int32 target, int32 screen, int32 c, int32 d, int32 z, int32 x) {
@@ -1690,7 +1690,7 @@ int Logic::fnBlack(Object *cpt, int32 id, int32 a, int32 b, int32 c, int32 d, in
}
uint16 Logic::inRange(uint16 a, uint16 b, uint16 c) {
- return (a > b)? a : (((b > c) ? c : b));
+ return (a > b) ? a : (((b > c) ? c : b));
}
void Logic::startPosCallFn(uint8 fnId, uint32 param1, uint32 param2, uint32 param3) {
@@ -1789,7 +1789,7 @@ void Logic::startPositions(uint32 pos) {
if (pos == 0)
pos = 1;
Object *compact = _objMan->fetchObject(PLAYER);
- fnEnterSection(compact, PLAYER, pos, 0, 0, 0, 0, 0); // (automatically opens the compact resource for that section)
+ fnEnterSection(compact, PLAYER, pos, 0, 0, 0, 0, 0); // (automatically opens the compact resource for that section)
SwordEngine::_systemVars.controlPanelMode = CP_NORMAL;
SwordEngine::_systemVars.wantFade = true;
}
diff --git a/engines/sword1/logic.h b/engines/sword1/logic.h
index 13ddbc989b..b6686f6249 100644
--- a/engines/sword1/logic.h
+++ b/engines/sword1/logic.h
@@ -35,7 +35,7 @@ class OSystem;
namespace Sword1 {
#define NON_ZERO_SCRIPT_VARS 95
-#define NUM_SCRIPT_VARS 1179
+#define NUM_SCRIPT_VARS 1179
class SwordEngine;
class Text;
@@ -63,7 +63,7 @@ public:
static uint32 _scriptVars[NUM_SCRIPT_VARS];
// public for mouse (menu looking)
- int cfnPresetScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int cfnPresetScript(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
private:
SwordEngine *_vm;
ObjectMan *_objMan;
@@ -100,112 +100,112 @@ private:
uint16 inRange(uint16 a, uint16 b, uint16 c);
//- mcodeTable:
- int fnBackground (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnForeground (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSort (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnNoSprite (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnMegaSet (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnAnim (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSetFrame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnFullAnim (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnFullSetFrame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnFadeDown (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnFadeUp (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnCheckFade (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnBackground(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnForeground(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSort(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnNoSprite(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnMegaSet(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnAnim(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSetFrame(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnFullAnim(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnFullSetFrame(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnFadeDown(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnFadeUp(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnCheckFade(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnSetSpritePalette(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnSetWholePalette(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnSetFadeTargetPalette(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnSetPaletteToFade(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnSetPaletteToCut(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnPlaySequence (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
-
- int fnIdle (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnPause (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnPauseSeconds (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnQuit (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnKillId (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSuicide (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnNewScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSubScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnRestartScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSetBookmark (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnGotoBookmark (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSendSync (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnWaitSync (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnPlaySequence(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+
+ int fnIdle(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnPause(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnPauseSeconds(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnQuit(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnKillId(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSuicide(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnNewScript(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSubScript(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnRestartScript(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSetBookmark(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnGotoBookmark(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSendSync(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnWaitSync(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int cfnClickInteract(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int cfnSetScript (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
-
- int fnInteract (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnIssueEvent (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnCheckForEvent (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnWipeHands (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnISpeak (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnTheyDo (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnTheyDoWeWait (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnWeWait (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int cfnSetScript(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+
+ int fnInteract(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnIssueEvent(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnCheckForEvent(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnWipeHands(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnISpeak(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnTheyDo(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnTheyDoWeWait(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnWeWait(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnChangeSpeechText(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnTalkError (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnStartTalk (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnTalkError(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnStartTalk(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnCheckForTextLine(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnAddTalkWaitStatusBit(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnRemoveTalkWaitStatusBit(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnNoHuman (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnAddHuman (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnBlankMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnNormalMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnLockMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnUnlockMouse (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnNoHuman(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnAddHuman(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnBlankMouse(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnNormalMouse(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnLockMouse(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnUnlockMouse(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnSetMousePointer(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
int fnSetMouseLuggage(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnMouseOn (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnMouseOff (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnChooser (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnEndChooser (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnStartMenu (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnEndMenu (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
-
- int cfnReleaseMenu (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
-
- int fnAddSubject (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnAddObject (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnRemoveObject (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnEnterSection (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnLeaveSection (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnChangeFloor (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnWalk (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnTurn (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnStand (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnStandAt (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnFace (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnFaceXy (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnIsFacing (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnGetTo (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnGetToError (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnGetPos (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnGetGamepadXy (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnPlayFx (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnStopFx (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnPlayMusic (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnStopMusic (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnInnerSpace (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnRandom (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSetScreen (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnPreload (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnCheckCD (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnRestartGame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnQuitGame (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnDeathScreen (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnSetParallax (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnTdebug (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
-
- int fnRedFlash (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnBlueFlash (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnYellow (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnGreen (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnPurple (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
- int fnBlack (Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnMouseOn(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnMouseOff(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnChooser(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnEndChooser(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnStartMenu(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnEndMenu(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+
+ int cfnReleaseMenu(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+
+ int fnAddSubject(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnAddObject(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnRemoveObject(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnEnterSection(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnLeaveSection(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnChangeFloor(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnWalk(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnTurn(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnStand(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnStandAt(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnFace(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnFaceXy(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnIsFacing(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnGetTo(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnGetToError(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnGetPos(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnGetGamepadXy(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnPlayFx(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnStopFx(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnPlayMusic(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnStopMusic(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnInnerSpace(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnRandom(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSetScreen(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnPreload(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnCheckCD(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnRestartGame(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnQuitGame(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnDeathScreen(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnSetParallax(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnTdebug(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+
+ int fnRedFlash(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnBlueFlash(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnYellow(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnGreen(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnPurple(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
+ int fnBlack(Object *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x);
static const uint32 _scriptVarInit[NON_ZERO_SCRIPT_VARS][2];
static const uint8 *_startData[];
static const uint8 *_helperData[];
diff --git a/engines/sword1/memman.cpp b/engines/sword1/memman.cpp
index 9fd763084a..19809249b5 100644
--- a/engines/sword1/memman.cpp
+++ b/engines/sword1/memman.cpp
@@ -40,7 +40,7 @@ MemMan::~MemMan() {
void MemMan::alloc(MemHandle *bsMem, uint32 pSize, uint16 pCond) {
_alloced += pSize;
- bsMem->data = (void*)malloc(pSize);
+ bsMem->data = (void *)malloc(pSize);
if (!bsMem->data)
error("MemMan::alloc(): Can't alloc %d bytes of memory.", pSize);
bsMem->cond = pCond;
diff --git a/engines/sword1/memman.h b/engines/sword1/memman.h
index 3f822189eb..7f84720248 100644
--- a/engines/sword1/memman.h
+++ b/engines/sword1/memman.h
@@ -35,9 +35,9 @@ struct MemHandle {
MemHandle *next, *prev;
};
// mem conditions:
-#define MEM_FREED 0
-#define MEM_CAN_FREE 1
-#define MEM_DONT_FREE 2
+#define MEM_FREED 0
+#define MEM_CAN_FREE 1
+#define MEM_DONT_FREE 2
#define MAX_ALLOC (6*1024*1024) // max amount of mem we want to alloc().
diff --git a/engines/sword1/menu.cpp b/engines/sword1/menu.cpp
index 3a99602fec..f61e10106a 100644
--- a/engines/sword1/menu.cpp
+++ b/engines/sword1/menu.cpp
@@ -85,7 +85,7 @@ void MenuIcon::setSelect(bool pSel) {
void MenuIcon::draw(const byte *fadeMask, int8 fadeStatus) {
uint16 x = _menuPos * 40;
- uint16 y = (_menuType == MENU_TOP)?(0):(440);
+ uint16 y = (_menuType == MENU_TOP) ? (0) : (440);
_screen->showFrame(x, y, _resId, _frame + (_selected ? 1 : 0), fadeMask, fadeStatus);
}
@@ -193,7 +193,7 @@ uint8 Menu::checkMenuClick(uint8 menuType) {
_mouse->setLuggage(0, 0);
Logic::_scriptVars[OBJECT_HELD] = 0; // reselected => deselect it
} else { // the player is clicking another item on this one.
- // run its use-script, if there is one
+ // run its use-script, if there is one
Logic::_scriptVars[SECOND_ITEM] = _menuList[cnt];
_mouse->setLuggage(0, 0);
}
diff --git a/engines/sword1/mouse.cpp b/engines/sword1/mouse.cpp
index cbf951aebc..4a62995d96 100644
--- a/engines/sword1/mouse.cpp
+++ b/engines/sword1/mouse.cpp
@@ -47,7 +47,7 @@ Mouse::~Mouse() {
setLuggage(0, 0);
setPointer(0, 0);
- for (uint8 cnt = 0; cnt < 17; cnt++) // close mouse cursor resources
+ for (uint8 cnt = 0; cnt < 17; cnt++) // close mouse cursor resources
_resMan->resClose(MSE_POINTER + cnt);
}
@@ -60,7 +60,7 @@ void Mouse::initialize() {
_mouseOverride = false;
_currentPtrId = _currentLuggageId = 0;
- for (uint8 cnt = 0; cnt < 17; cnt++) // force res manager to keep mouse
+ for (uint8 cnt = 0; cnt < 17; cnt++) // force res manager to keep mouse
_resMan->resOpen(MSE_POINTER + cnt); // cursors in memory all the time
CursorMan.showMouse(false);
@@ -112,7 +112,7 @@ void Mouse::engine(uint16 x, uint16 y, uint16 eventFlags) {
_mouse.y = y;
if (!(Logic::_scriptVars[MOUSE_STATUS] & 1)) { // no human?
_numObjs = 0;
- return; // no human, so we don't want the mouse engine
+ return; // no human, so we don't want the mouse engine
}
if (!Logic::_scriptVars[TOP_MENU_DISABLED]) {
@@ -144,12 +144,12 @@ void Mouse::engine(uint16 x, uint16 y, uint16 eventFlags) {
for (uint16 priority = 0; (priority < 10) && (!touchedId); priority++) {
for (uint16 cnt = 0; (cnt < _numObjs) && (!touchedId); cnt++) {
if ((_objList[cnt].compact->o_priority == priority) &&
- (Logic::_scriptVars[MOUSE_X] >= (uint32)_objList[cnt].compact->o_mouse_x1) &&
- (Logic::_scriptVars[MOUSE_X] <= (uint32)_objList[cnt].compact->o_mouse_x2) &&
- (Logic::_scriptVars[MOUSE_Y] >= (uint32)_objList[cnt].compact->o_mouse_y1) &&
- (Logic::_scriptVars[MOUSE_Y] <= (uint32)_objList[cnt].compact->o_mouse_y2)) {
- touchedId = _objList[cnt].id;
- clicked = cnt;
+ (Logic::_scriptVars[MOUSE_X] >= (uint32)_objList[cnt].compact->o_mouse_x1) &&
+ (Logic::_scriptVars[MOUSE_X] <= (uint32)_objList[cnt].compact->o_mouse_x2) &&
+ (Logic::_scriptVars[MOUSE_Y] >= (uint32)_objList[cnt].compact->o_mouse_y1) &&
+ (Logic::_scriptVars[MOUSE_Y] <= (uint32)_objList[cnt].compact->o_mouse_y2)) {
+ touchedId = _objList[cnt].id;
+ clicked = cnt;
}
}
}
@@ -160,7 +160,7 @@ void Mouse::engine(uint16 x, uint16 y, uint16 eventFlags) {
_getOff = 0;
}
if (touchedId) { // there's something new selected, now.
- if (_objList[clicked].compact->o_mouse_on) //run its get on
+ if (_objList[clicked].compact->o_mouse_on) //run its get on
_logic->runMouseScript(_objList[clicked].compact, _objList[clicked].compact->o_mouse_on);
_getOff = _objList[clicked].compact->o_mouse_off; //setup get-off for later
@@ -197,7 +197,7 @@ void Mouse::createPointer(uint32 ptrId, uint32 luggageId) {
if (ptrId) {
MousePtr *lugg = NULL;
- MousePtr *ptr = (MousePtr*)_resMan->openFetchRes(ptrId);
+ MousePtr *ptr = (MousePtr *)_resMan->openFetchRes(ptrId);
uint16 noFrames = _resMan->getLEUint16(ptr->numFrames);
uint16 ptrSizeX = _resMan->getLEUint16(ptr->sizeX);
uint16 ptrSizeY = _resMan->getLEUint16(ptr->sizeY);
@@ -210,7 +210,7 @@ void Mouse::createPointer(uint32 ptrId, uint32 luggageId) {
ptrSizeY *= 2;
if (luggageId) {
- lugg = (MousePtr*)_resMan->openFetchRes(luggageId);
+ lugg = (MousePtr *)_resMan->openFetchRes(luggageId);
luggSizeX = _resMan->getLEUint16(lugg->sizeX);
luggSizeY = _resMan->getLEUint16(lugg->sizeY);
@@ -223,18 +223,18 @@ void Mouse::createPointer(uint32 ptrId, uint32 luggageId) {
resSizeX = ptrSizeX;
resSizeY = ptrSizeY;
}
- _currentPtr = (MousePtr*)malloc(sizeof(MousePtr) + resSizeX * resSizeY * noFrames);
+ _currentPtr = (MousePtr *)malloc(sizeof(MousePtr) + resSizeX * resSizeY * noFrames);
_currentPtr->hotSpotX = _resMan->getLEUint16(ptr->hotSpotX);
_currentPtr->hotSpotY = _resMan->getLEUint16(ptr->hotSpotY);
_currentPtr->numFrames = noFrames;
_currentPtr->sizeX = resSizeX;
_currentPtr->sizeY = resSizeY;
- uint8 *ptrData = (uint8*)_currentPtr + sizeof(MousePtr);
+ uint8 *ptrData = (uint8 *)_currentPtr + sizeof(MousePtr);
memset(ptrData, 255, resSizeX * resSizeY * noFrames);
if (luggageId) {
uint8 *dstData = ptrData + resSizeX - luggSizeX;
for (uint32 frameCnt = 0; frameCnt < noFrames; frameCnt++) {
- uint8 *luggSrc = (uint8*)lugg + sizeof(MousePtr);
+ uint8 *luggSrc = (uint8 *)lugg + sizeof(MousePtr);
dstData += (resSizeY - luggSizeY) * resSizeX;
for (uint32 cnty = 0; cnty < (uint32)(SwordEngine::isPsx() ? luggSizeY / 2 : luggSizeY); cnty++) {
for (uint32 cntx = 0; cntx < luggSizeX; cntx++)
@@ -256,7 +256,7 @@ void Mouse::createPointer(uint32 ptrId, uint32 luggageId) {
}
uint8 *dstData = ptrData;
- uint8 *srcData = (uint8*)ptr + sizeof(MousePtr);
+ uint8 *srcData = (uint8 *)ptr + sizeof(MousePtr);
for (uint32 frameCnt = 0; frameCnt < noFrames; frameCnt++) {
for (uint32 cnty = 0; cnty < (uint32)(SwordEngine::isPsx() ? ptrSizeY / 2 : ptrSizeY); cnty++) {
for (uint32 cntx = 0; cntx < ptrSizeX; cntx++)
@@ -264,7 +264,7 @@ void Mouse::createPointer(uint32 ptrId, uint32 luggageId) {
dstData[cntx] = srcData[cntx];
if (SwordEngine::isPsx()) {
- dstData +=resSizeX;
+ dstData += resSizeX;
for (uint32 cntx = 0; cntx < ptrSizeX; cntx++)
if (srcData[cntx])
dstData[cntx] = srcData[cntx];
@@ -309,7 +309,7 @@ void Mouse::animate() {
if (_activeFrame == _frame)
return;
- uint8 *ptrData = (uint8*)_currentPtr + sizeof(MousePtr);
+ uint8 *ptrData = (uint8 *)_currentPtr + sizeof(MousePtr);
ptrData += _frame * _currentPtr->sizeX * _currentPtr->sizeY;
CursorMan.replaceCursor(ptrData, _currentPtr->sizeX, _currentPtr->sizeY, _currentPtr->hotSpotX, _currentPtr->hotSpotY, 255);
diff --git a/engines/sword1/mouse.h b/engines/sword1/mouse.h
index 44a6f76ad7..b2a844d0a9 100644
--- a/engines/sword1/mouse.h
+++ b/engines/sword1/mouse.h
@@ -34,22 +34,22 @@ namespace Sword1 {
#define MAX_MOUSE 30
-#define BS1L_BUTTON_DOWN 2
-#define BS1L_BUTTON_UP 4
-#define BS1R_BUTTON_DOWN 8
-#define BS1R_BUTTON_UP 16
-#define BS1_WHEEL_UP 32
-#define BS1_WHEEL_DOWN 64
-#define MOUSE_BOTH_BUTTONS (BS1L_BUTTON_DOWN | BS1R_BUTTON_DOWN)
-#define MOUSE_DOWN_MASK (BS1L_BUTTON_DOWN | BS1R_BUTTON_DOWN)
-#define MOUSE_UP_MASK (BS1L_BUTTON_UP | BS1R_BUTTON_UP)
+#define BS1L_BUTTON_DOWN 2
+#define BS1L_BUTTON_UP 4
+#define BS1R_BUTTON_DOWN 8
+#define BS1R_BUTTON_UP 16
+#define BS1_WHEEL_UP 32
+#define BS1_WHEEL_DOWN 64
+#define MOUSE_BOTH_BUTTONS (BS1L_BUTTON_DOWN | BS1R_BUTTON_DOWN)
+#define MOUSE_DOWN_MASK (BS1L_BUTTON_DOWN | BS1R_BUTTON_DOWN)
+#define MOUSE_UP_MASK (BS1L_BUTTON_UP | BS1R_BUTTON_UP)
struct MouseObj {
int id;
Object *compact;
};
-#include "common/pack-start.h" // START STRUCT PACKING
+#include "common/pack-start.h" // START STRUCT PACKING
struct MousePtr {
uint16 numFrames;
@@ -60,7 +60,7 @@ struct MousePtr {
uint8 dummyData[0x30];
} PACKED_STRUCT;
-#include "common/pack-end.h" // END STRUCT PACKING
+#include "common/pack-end.h" // END STRUCT PACKING
class Logic;
class Menu;
diff --git a/engines/sword1/object.h b/engines/sword1/object.h
index 4f5371fa72..0dab5519bd 100644
--- a/engines/sword1/object.h
+++ b/engines/sword1/object.h
@@ -27,98 +27,98 @@
namespace Sword1 {
-#define O_TOTAL_EVENTS 5
-#define O_WALKANIM_SIZE 600 //max number of nodes in router output
-#define O_GRID_SIZE 200
-#define EXTRA_GRID_SIZE 20
+#define O_TOTAL_EVENTS 5
+#define O_WALKANIM_SIZE 600 //max number of nodes in router output
+#define O_GRID_SIZE 200
+#define EXTRA_GRID_SIZE 20
-#include "common/pack-start.h" // START STRUCT PACKING
+#include "common/pack-start.h" // START STRUCT PACKING
-struct OEventSlot { //receiving event list in the compact -
- int32 o_event; //array of these with O_TOTAL_EVENTS elements
- int32 o_event_script;
-} PACKED_STRUCT; // size = 2*int32 = 8 bytes
+struct OEventSlot { //receiving event list in the compact -
+ int32 o_event; //array of these with O_TOTAL_EVENTS elements
+ int32 o_event_script;
+} PACKED_STRUCT; // size = 2*int32 = 8 bytes
-#define TOTAL_script_levels 5
+#define TOTAL_script_levels 5
-struct ScriptTree { //this is a logic tree, used by OBJECTs
- int32 o_script_level; //logic level
- int32 o_script_id[TOTAL_script_levels]; //script id's (are unique to each level)
- int32 o_script_pc[TOTAL_script_levels]; //pc of script for each (if script_manager)
-} PACKED_STRUCT; // size = 11*int32 = 44 bytes
+struct ScriptTree { //this is a logic tree, used by OBJECTs
+ int32 o_script_level; //logic level
+ int32 o_script_id[TOTAL_script_levels]; //script id's (are unique to each level)
+ int32 o_script_pc[TOTAL_script_levels]; //pc of script for each (if script_manager)
+} PACKED_STRUCT; // size = 11*int32 = 44 bytes
struct TalkOffset {
- int32 x;
- int32 y;
-} PACKED_STRUCT; // size = 2*int32 = 8 bytes
+ int32 x;
+ int32 y;
+} PACKED_STRUCT; // size = 2*int32 = 8 bytes
struct WalkData {
- int32 frame;
- int32 x;
- int32 y;
- int32 step;
- int32 dir;
-} PACKED_STRUCT; // size = 5*int32 = 20 bytes
+ int32 frame;
+ int32 x;
+ int32 y;
+ int32 step;
+ int32 dir;
+} PACKED_STRUCT; // size = 5*int32 = 20 bytes
struct Object {
- int32 o_type; // 0 broad description of type - object, floor, etc.
- int32 o_status; // 4 bit flags for logic, graphics, mouse, etc.
- int32 o_logic; // 8 logic type
- int32 o_place; // 12 where is the mega character
- int32 o_down_flag; // 16 pass back down with this - with C possibly both are unnecessary?
- int32 o_target; // 20 target object for the GTM *these are linked to script
- int32 o_screen; // 24 physical screen/section
- int32 o_frame; // 28 frame number &
- int32 o_resource; // 32 id of spr file it comes from
- int32 o_sync; // 36 receive sync here
- int32 o_pause; // 40 logic_engine() pauses these cycles
- int32 o_xcoord; // 44
- int32 o_ycoord; // 48
- int32 o_mouse_x1; // 52 top-left of mouse area is (x1,y1)
- int32 o_mouse_y1; // 56
- int32 o_mouse_x2; // 60 bottom-right of area is (x2,y2) (these coords are inclusive)
- int32 o_mouse_y2; // 64
- int32 o_priority; // 68
- int32 o_mouse_on; // 72
- int32 o_mouse_off; // 76
- int32 o_mouse_click; // 80
- int32 o_interact; // 84
- int32 o_get_to_script; // 88
- int32 o_scale_a; // 92 used by floors
- int32 o_scale_b; // 96
- int32 o_anim_x; // 100
- int32 o_anim_y; // 104
-
- ScriptTree o_tree; // 108 size = 44 bytes
- ScriptTree o_bookmark; // 152 size = 44 bytes
-
- int32 o_dir; // 196
- int32 o_speech_pen; // 200
- int32 o_speech_width; // 204
- int32 o_speech_time; // 208
- int32 o_text_id; // 212 working back from o_ins1
- int32 o_tag; // 216
- int32 o_anim_pc; // 220 position within an animation structure
- int32 o_anim_resource; // 224 cdt or anim table
-
- int32 o_walk_pc; // 228
-
- TalkOffset talk_table[6]; // 232 size = 6*8 bytes = 48
-
- OEventSlot o_event_list[O_TOTAL_EVENTS]; // 280 size = 5*8 bytes = 40
-
- int32 o_ins1; // 320
- int32 o_ins2; // 324
- int32 o_ins3; // 328
-
- int32 o_mega_resource; // 332
- int32 o_walk_resource; // 336
-
- WalkData o_route[O_WALKANIM_SIZE]; // 340 size = 600*20 bytes = 12000
- // mega size = 12340 bytes (+ 8 byte offset table + 20 byte header = 12368)
+ int32 o_type; // 0 broad description of type - object, floor, etc.
+ int32 o_status; // 4 bit flags for logic, graphics, mouse, etc.
+ int32 o_logic; // 8 logic type
+ int32 o_place; // 12 where is the mega character
+ int32 o_down_flag; // 16 pass back down with this - with C possibly both are unnecessary?
+ int32 o_target; // 20 target object for the GTM *these are linked to script
+ int32 o_screen; // 24 physical screen/section
+ int32 o_frame; // 28 frame number &
+ int32 o_resource; // 32 id of spr file it comes from
+ int32 o_sync; // 36 receive sync here
+ int32 o_pause; // 40 logic_engine() pauses these cycles
+ int32 o_xcoord; // 44
+ int32 o_ycoord; // 48
+ int32 o_mouse_x1; // 52 top-left of mouse area is (x1,y1)
+ int32 o_mouse_y1; // 56
+ int32 o_mouse_x2; // 60 bottom-right of area is (x2,y2) (these coords are inclusive)
+ int32 o_mouse_y2; // 64
+ int32 o_priority; // 68
+ int32 o_mouse_on; // 72
+ int32 o_mouse_off; // 76
+ int32 o_mouse_click; // 80
+ int32 o_interact; // 84
+ int32 o_get_to_script; // 88
+ int32 o_scale_a; // 92 used by floors
+ int32 o_scale_b; // 96
+ int32 o_anim_x; // 100
+ int32 o_anim_y; // 104
+
+ ScriptTree o_tree; // 108 size = 44 bytes
+ ScriptTree o_bookmark; // 152 size = 44 bytes
+
+ int32 o_dir; // 196
+ int32 o_speech_pen; // 200
+ int32 o_speech_width; // 204
+ int32 o_speech_time; // 208
+ int32 o_text_id; // 212 working back from o_ins1
+ int32 o_tag; // 216
+ int32 o_anim_pc; // 220 position within an animation structure
+ int32 o_anim_resource; // 224 cdt or anim table
+
+ int32 o_walk_pc; // 228
+
+ TalkOffset talk_table[6]; // 232 size = 6*8 bytes = 48
+
+ OEventSlot o_event_list[O_TOTAL_EVENTS]; // 280 size = 5*8 bytes = 40
+
+ int32 o_ins1; // 320
+ int32 o_ins2; // 324
+ int32 o_ins3; // 328
+
+ int32 o_mega_resource; // 332
+ int32 o_walk_resource; // 336
+
+ WalkData o_route[O_WALKANIM_SIZE]; // 340 size = 600*20 bytes = 12000
+ // mega size = 12340 bytes (+ 8 byte offset table + 20 byte header = 12368)
} PACKED_STRUCT;
-#include "common/pack-end.h" // END STRUCT PACKING
+#include "common/pack-end.h" // END STRUCT PACKING
} // End of namespace Sword1
diff --git a/engines/sword1/objectman.cpp b/engines/sword1/objectman.cpp
index 8de29615d5..52b5ea2121 100644
--- a/engines/sword1/objectman.cpp
+++ b/engines/sword1/objectman.cpp
@@ -39,15 +39,15 @@ void ObjectMan::initialize() {
uint16 cnt;
for (cnt = 0; cnt < TOTAL_SECTIONS; cnt++)
_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.
+ // 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;
+ _liveList[134] = _liveList[145] = _liveList[146] = _liveList[TEXT_sect] = 1;
for (cnt = 0; cnt < TOTAL_SECTIONS; cnt++) {
if (_liveList[cnt])
- _cptData[cnt] = (uint8*)_resMan->cptResOpen(_objectList[cnt]) + sizeof(Header);
+ _cptData[cnt] = (uint8 *)_resMan->cptResOpen(_objectList[cnt]) + sizeof(Header);
else
_cptData[cnt] = NULL;
}
@@ -66,7 +66,7 @@ bool ObjectMan::sectionAlive(uint16 section) {
void ObjectMan::megaEntering(uint16 section) {
_liveList[section]++;
if (_liveList[section] == 1)
- _cptData[section] = ((uint8*)_resMan->cptResOpen(_objectList[section])) + sizeof(Header);
+ _cptData[section] = ((uint8 *)_resMan->cptResOpen(_objectList[section])) + sizeof(Header);
}
void ObjectMan::megaLeaving(uint16 section, int id) {
@@ -87,7 +87,7 @@ uint8 ObjectMan::fnCheckForTextLine(uint32 textId) {
return 0; // section does not exist
uint8 lang = SwordEngine::_systemVars.language;
- uint32 *textData = (uint32*)((uint8*)_resMan->openFetchRes(_textList[textId / ITM_PER_SEC][lang]) + sizeof(Header));
+ uint32 *textData = (uint32 *)((uint8 *)_resMan->openFetchRes(_textList[textId / ITM_PER_SEC][lang]) + sizeof(Header));
if ((textId & ITM_ID) < _resMan->readUint32(textData)) {
textData++;
if (textData[textId & ITM_ID])
@@ -99,7 +99,7 @@ uint8 ObjectMan::fnCheckForTextLine(uint32 textId) {
char *ObjectMan::lockText(uint32 textId) {
uint8 lang = SwordEngine::_systemVars.language;
- char *addr = (char*)_resMan->openFetchRes(_textList[textId / ITM_PER_SEC][lang]);
+ char *addr = (char *)_resMan->openFetchRes(_textList[textId / ITM_PER_SEC][lang]);
if (addr == 0)
return _missingSubTitleStr;
addr += sizeof(Header);
@@ -107,12 +107,12 @@ char *ObjectMan::lockText(uint32 textId) {
warning("ObjectMan::lockText(%d): only %d texts in file", textId & ITM_ID, _resMan->readUint32(addr));
textId = 0; // get first line instead
}
- uint32 offset = _resMan->readUint32(addr + ((textId & ITM_ID) + 1)* 4);
+ uint32 offset = _resMan->readUint32(addr + ((textId & ITM_ID) + 1) * 4);
if (offset == 0) {
// Workaround bug for missing sentence in some langages in Syria (see bug #1977094).
// We use the hardcoded text in this case.
if (textId == 2950145)
- return const_cast<char*>(_translationId2950145[lang]);
+ return const_cast<char *>(_translationId2950145[lang]);
warning("ObjectMan::lockText(%d): text number has no text lines", textId);
return _missingSubTitleStr;
@@ -125,7 +125,7 @@ void ObjectMan::unlockText(uint32 textId) {
}
uint32 ObjectMan::lastTextNumber(int section) {
- uint8 *data = (uint8*)_resMan->openFetchRes(_textList[section][SwordEngine::_systemVars.language]) + sizeof(Header);
+ uint8 *data = (uint8 *)_resMan->openFetchRes(_textList[section][SwordEngine::_systemVars.language]) + sizeof(Header);
uint32 result = _resMan->readUint32(data) - 1;
_resMan->resClose(_textList[section][SwordEngine::_systemVars.language]);
return result;
@@ -137,17 +137,17 @@ Object *ObjectMan::fetchObject(uint32 id) {
error("fetchObject: section %d is not open", id / ITM_PER_SEC);
id &= ITM_ID;
// DON'T do endian conversion here. it's already done.
- return (Object*)(addr + *(uint32*)(addr + (id + 1)*4));
+ return (Object *)(addr + * (uint32 *)(addr + (id + 1) * 4));
}
uint32 ObjectMan::fetchNoObjects(int section) {
if (_cptData[section] == NULL)
error("fetchNoObjects: section %d is not open", section);
- return *(uint32*)_cptData[section];
+ return *(uint32 *)_cptData[section];
}
void ObjectMan::closeSection(uint32 screen) {
- if (_liveList[screen] == 0) // close the section that PLAYER has just left, if it's empty now
+ if (_liveList[screen] == 0) // close the section that PLAYER has just left, if it's empty now
_resMan->resClose(_objectList[screen]);
}
@@ -159,7 +159,7 @@ void ObjectMan::loadLiveList(uint16 *src) {
}
_liveList[cnt] = src[cnt];
if (_liveList[cnt])
- _cptData[cnt] = ((uint8*)_resMan->cptResOpen(_objectList[cnt])) + sizeof(Header);
+ _cptData[cnt] = ((uint8 *)_resMan->cptResOpen(_objectList[cnt])) + sizeof(Header);
}
}
diff --git a/engines/sword1/objectman.h b/engines/sword1/objectman.h
index 23047c14ea..7bc31b08d7 100644
--- a/engines/sword1/objectman.h
+++ b/engines/sword1/objectman.h
@@ -54,12 +54,12 @@ public:
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
- uint16 _liveList[TOTAL_SECTIONS]; //which sections are active
+ 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
+ uint16 _liveList[TOTAL_SECTIONS]; //which sections are active
uint8 *_cptData[TOTAL_SECTIONS];
static char _missingSubTitleStr[];
- static const char *_translationId2950145[7]; //translation for textId 2950145 (missing from cluster file for some langages)
+ static const char *_translationId2950145[7]; //translation for textId 2950145 (missing from cluster file for some langages)
};
} // End of namespace Sword1
diff --git a/engines/sword1/resman.cpp b/engines/sword1/resman.cpp
index 807679a40e..878ba8eceb 100644
--- a/engines/sword1/resman.cpp
+++ b/engines/sword1/resman.cpp
@@ -31,14 +31,14 @@
#include "gui/message.h"
namespace Sword1 {
- void guiFatalError(char *msg) {
- // Displays a dialog on-screen before terminating the engine.
- // TODO: We really need to setup a special palette for cases when
- // the engine is erroring before setting one... otherwise invisible cursor :)
-
- GUI::MessageDialog dialog(msg);
- dialog.runModal();
- error("%s", msg);
+void guiFatalError(char *msg) {
+ // Displays a dialog on-screen before terminating the engine.
+ // TODO: We really need to setup a special palette for cases when
+ // the engine is erroring before setting one... otherwise invisible cursor :)
+
+ GUI::MessageDialog dialog(msg);
+ dialog.runModal();
+ error("%s", msg);
}
#define MAX_PATH_LEN 260
@@ -62,7 +62,7 @@ ResMan::~ResMan() {
for (uint32 resCnt = 0; resCnt < group->noRes; resCnt++) {
if (group->resHandle[resCnt].cond == MEM_DONT_FREE) {
warning("ResMan::~ResMan: Resource %02X.%04X.%02X is still open",
- clusCnt + 1, grpCnt, resCnt);
+ clusCnt + 1, grpCnt, resCnt);
}
}
}
@@ -92,7 +92,7 @@ void ResMan::loadCluDescript(const char *fileName) {
_prj.clu = new Clu[_prj.noClu];
memset(_prj.clu, 0, _prj.noClu * sizeof(Clu));
- uint32 *cluIndex = (uint32*)malloc(_prj.noClu * 4);
+ uint32 *cluIndex = (uint32 *)malloc(_prj.noClu * 4);
file.read(cluIndex, _prj.noClu * 4);
for (uint32 clusCnt = 0; clusCnt < _prj.noClu; clusCnt++)
@@ -107,7 +107,7 @@ void ResMan::loadCluDescript(const char *fileName) {
memset(cluster->grp, 0, cluster->noGrp * sizeof(Grp));
cluster->refCount = 0;
- uint32 *grpIndex = (uint32*)malloc(cluster->noGrp * 4);
+ uint32 *grpIndex = (uint32 *)malloc(cluster->noGrp * 4);
file.read(grpIndex, cluster->noGrp * 4);
for (uint32 grpCnt = 0; grpCnt < cluster->noGrp; grpCnt++)
@@ -117,7 +117,7 @@ void ResMan::loadCluDescript(const char *fileName) {
group->resHandle = new MemHandle[group->noRes];
group->offset = new uint32[group->noRes];
group->length = new uint32[group->noRes];
- uint32 *resIdIdx = (uint32*)malloc(group->noRes * 4);
+ uint32 *resIdIdx = (uint32 *)malloc(group->noRes * 4);
file.read(resIdIdx, group->noRes * 4);
for (uint32 resCnt = 0; resCnt < group->noRes; resCnt++) {
@@ -227,7 +227,7 @@ Header *ResMan::lockScript(uint32 scrID) {
#else
openScriptResourceLittleEndian(scrID);
#endif
- return (Header*)resHandle(scrID)->data;
+ return (Header *)resHandle(scrID)->data;
}
void ResMan::unlockScript(uint32 scrID) {
@@ -276,23 +276,23 @@ void ResMan::resClose(uint32 id) {
} else {
handle->refCount--;
if (!handle->refCount)
- _memMan->setCondition( handle, MEM_CAN_FREE);
+ _memMan->setCondition(handle, MEM_CAN_FREE);
}
}
FrameHeader *ResMan::fetchFrame(void *resourceData, uint32 frameNo) {
- uint8 *frameFile = (uint8*)resourceData;
+ uint8 *frameFile = (uint8 *)resourceData;
uint8 *idxData = frameFile + sizeof(Header);
if (_isBigEndian) {
if (frameNo >= READ_BE_UINT32(idxData))
error("fetchFrame:: frame %d doesn't exist in resource.", frameNo);
- frameFile += READ_BE_UINT32(idxData + (frameNo+1) * 4);
+ frameFile += READ_BE_UINT32(idxData + (frameNo + 1) * 4);
} else {
if (frameNo >= READ_LE_UINT32(idxData))
error("fetchFrame:: frame %d doesn't exist in resource.", frameNo);
- frameFile += READ_LE_UINT32(idxData + (frameNo+1) * 4);
+ frameFile += READ_LE_UINT32(idxData + (frameNo + 1) * 4);
}
- return (FrameHeader*)frameFile;
+ return (FrameHeader *)frameFile;
}
Common::File *ResMan::resFile(uint32 id) {
@@ -310,9 +310,9 @@ Common::File *ResMan::resFile(uint32 id) {
// Supposes that big endian means mac cluster file and little endian means PC cluster file.
// This works, but we may want to separate the file name from the endianess or try .CLM extension if opening.clu file fail.
if (_isBigEndian)
- sprintf(fileName, "%s.CLM", _prj.clu[(id >> 24)-1].label);
+ sprintf(fileName, "%s.CLM", _prj.clu[(id >> 24) - 1].label);
else
- sprintf(fileName, "%s.CLU", _prj.clu[(id >> 24)-1].label);
+ sprintf(fileName, "%s.CLU", _prj.clu[(id >> 24) - 1].label);
cluster->file->open(fileName);
if (!cluster->file->isOpen()) {
char msg[512];
@@ -392,7 +392,7 @@ void ResMan::openCptResourceBigEndian(uint32 id) {
if (!handle)
return;
uint32 totSize = handle->size;
- uint32 *data = (uint32*)((uint8*)handle->data + sizeof(Header));
+ uint32 *data = (uint32 *)((uint8 *)handle->data + sizeof(Header));
totSize -= sizeof(Header);
if (totSize & 3)
error("Illegal compact size for id %d: %d", id, totSize);
@@ -420,7 +420,7 @@ void ResMan::openCptResourceLittleEndian(uint32 id) {
if (!handle)
return;
uint32 totSize = handle->size;
- uint32 *data = (uint32*)((uint8*)handle->data + sizeof(Header));
+ uint32 *data = (uint32 *)((uint8 *)handle->data + sizeof(Header));
totSize -= sizeof(Header);
if (totSize & 3)
error("Illegal compact size for id %d: %d", id, totSize);
@@ -448,11 +448,11 @@ void ResMan::openScriptResourceBigEndian(uint32 id) {
if (!handle)
return;
// uint32 totSize = handle->size;
- Header *head = (Header*)handle->data;
+ Header *head = (Header *)handle->data;
head->comp_length = FROM_LE_32(head->comp_length);
head->decomp_length = FROM_LE_32(head->decomp_length);
head->version = FROM_LE_16(head->version);
- uint32 *data = (uint32*)((uint8*)handle->data + sizeof(Header));
+ uint32 *data = (uint32 *)((uint8 *)handle->data + sizeof(Header));
uint32 size = handle->size - sizeof(Header);
if (size & 3)
error("Odd size during script endian conversion. Resource ID =%d, size = %d", id, size);
@@ -480,11 +480,11 @@ void ResMan::openScriptResourceLittleEndian(uint32 id) {
if (!handle)
return;
// uint32 totSize = handle->size;
- Header *head = (Header*)handle->data;
+ Header *head = (Header *)handle->data;
head->comp_length = FROM_BE_32(head->comp_length);
head->decomp_length = FROM_BE_32(head->decomp_length);
head->version = FROM_BE_16(head->version);
- uint32 *data = (uint32*)((uint8*)handle->data + sizeof(Header));
+ uint32 *data = (uint32 *)((uint8 *)handle->data + sizeof(Header));
uint32 size = handle->size - sizeof(Header);
if (size & 3)
error("Odd size during script endian conversion. Resource ID =%d, size = %d", id, size);
@@ -498,34 +498,34 @@ void ResMan::openScriptResourceLittleEndian(uint32 id) {
uint32 ResMan::_srIdList[29] = { // the file numbers differ for the control panel file IDs, so we need this array
- OTHER_SR_FONT, // SR_FONT
- 0x04050000, // SR_BUTTON
- OTHER_SR_REDFONT, // SR_REDFONT
- 0x04050001, // SR_PALETTE
- 0x04050002, // SR_PANEL_ENGLISH
- 0x04050003, // SR_PANEL_FRENCH
- 0x04050004, // SR_PANEL_GERMAN
- 0x04050005, // SR_PANEL_ITALIAN
- 0x04050006, // SR_PANEL_SPANISH
- 0x04050007, // SR_PANEL_AMERICAN
- 0x04050008, // SR_TEXT_BUTTON
- 0x04050009, // SR_SPEED
- 0x0405000A, // SR_SCROLL1
- 0x0405000B, // SR_SCROLL2
- 0x0405000C, // SR_CONFIRM
- 0x0405000D, // SR_VOLUME
- 0x0405000E, // SR_VLIGHT
- 0x0405000F, // SR_VKNOB
- 0x04050010, // SR_WINDOW
- 0x04050011, // SR_SLAB1
- 0x04050012, // SR_SLAB2
- 0x04050013, // SR_SLAB3
- 0x04050014, // SR_SLAB4
- 0x04050015, // SR_BUTUF
- 0x04050016, // SR_BUTUS
- 0x04050017, // SR_BUTDS
- 0x04050018, // SR_BUTDF
- 0x04050019, // SR_DEATHPANEL
+ OTHER_SR_FONT, // SR_FONT
+ 0x04050000, // SR_BUTTON
+ OTHER_SR_REDFONT, // SR_REDFONT
+ 0x04050001, // SR_PALETTE
+ 0x04050002, // SR_PANEL_ENGLISH
+ 0x04050003, // SR_PANEL_FRENCH
+ 0x04050004, // SR_PANEL_GERMAN
+ 0x04050005, // SR_PANEL_ITALIAN
+ 0x04050006, // SR_PANEL_SPANISH
+ 0x04050007, // SR_PANEL_AMERICAN
+ 0x04050008, // SR_TEXT_BUTTON
+ 0x04050009, // SR_SPEED
+ 0x0405000A, // SR_SCROLL1
+ 0x0405000B, // SR_SCROLL2
+ 0x0405000C, // SR_CONFIRM
+ 0x0405000D, // SR_VOLUME
+ 0x0405000E, // SR_VLIGHT
+ 0x0405000F, // SR_VKNOB
+ 0x04050010, // SR_WINDOW
+ 0x04050011, // SR_SLAB1
+ 0x04050012, // SR_SLAB2
+ 0x04050013, // SR_SLAB3
+ 0x04050014, // SR_SLAB4
+ 0x04050015, // SR_BUTUF
+ 0x04050016, // SR_BUTUS
+ 0x04050017, // SR_BUTDS
+ 0x04050018, // SR_BUTDF
+ 0x04050019, // SR_DEATHPANEL
0,
};
diff --git a/engines/sword1/resman.h b/engines/sword1/resman.h
index 82074e5740..49d974c1db 100644
--- a/engines/sword1/resman.h
+++ b/engines/sword1/resman.h
@@ -33,11 +33,11 @@ namespace Sword1 {
#define MAX_LABEL_SIZE (31+1)
#if defined(__PSP__)
-#define MAX_OPEN_CLUS 4 // the PSP can't have more than 8 files open simultaneously
- // since we also need filehandles for music and sometimes savegames
- // set the maximum number of open clusters to 4.
+#define MAX_OPEN_CLUS 4 // the PSP can't have more than 8 files open simultaneously
+ // since we also need filehandles for music and sometimes savegames
+ // set the maximum number of open clusters to 4.
#else
-#define MAX_OPEN_CLUS 8 // don't open more than 8 files at once
+#define MAX_OPEN_CLUS 8 // don't open more than 8 files at once
#endif
struct Grp {
@@ -77,10 +77,10 @@ public:
FrameHeader *fetchFrame(void *resourceData, uint32 frameNo);
uint16 getUint16(uint16 value) {
- return (_isBigEndian) ? FROM_BE_16(value): FROM_LE_16(value);
+ return (_isBigEndian) ? FROM_BE_16(value) : FROM_LE_16(value);
}
uint32 getUint32(uint32 value) {
- return (_isBigEndian) ? FROM_BE_32(value): FROM_LE_32(value);
+ return (_isBigEndian) ? FROM_BE_32(value) : FROM_LE_32(value);
}
uint16 getLEUint16(uint16 value) {
return FROM_LE_16(value);
@@ -89,24 +89,24 @@ public:
return FROM_LE_32(value);
}
uint16 readUint16(const void *ptr) {
- return (_isBigEndian) ? READ_BE_UINT16(ptr): READ_LE_UINT16(ptr);
+ return (_isBigEndian) ? READ_BE_UINT16(ptr) : READ_LE_UINT16(ptr);
}
uint32 readUint32(const void *ptr) {
- return (_isBigEndian) ? READ_BE_UINT32(ptr):READ_LE_UINT32(ptr);
+ return (_isBigEndian) ? READ_BE_UINT32(ptr) : READ_LE_UINT32(ptr);
}
uint32 readLEUint32(const void *ptr) {
return READ_LE_UINT32(ptr);
}
uint16 toUint16(uint16 value) {
- return (_isBigEndian) ? TO_BE_16(value): TO_LE_16(value);
+ return (_isBigEndian) ? TO_BE_16(value) : TO_LE_16(value);
}
uint32 toUint32(uint32 value) {
- return (_isBigEndian) ? TO_BE_32(value): TO_LE_32(value);
+ return (_isBigEndian) ? TO_BE_32(value) : TO_LE_32(value);
}
private:
- uint32 resLength(uint32 id);
+ uint32 resLength(uint32 id);
MemHandle *resHandle(uint32 id);
uint32 resOffset(uint32 id);
Common::File *resFile(uint32 id);
@@ -120,7 +120,7 @@ private:
void freeCluDescript();
Prj _prj;
MemMan *_memMan;
- static const uint32 _scriptList[TOTAL_SECTIONS]; //a table of resource tags
+ static const uint32 _scriptList[TOTAL_SECTIONS]; //a table of resource tags
static uint32 _srIdList[29];
Clu *_openCluStart, *_openCluEnd;
int _openClus;
diff --git a/engines/sword1/router.cpp b/engines/sword1/router.cpp
index aaf475912d..ef07a0bf02 100644
--- a/engines/sword1/router.cpp
+++ b/engines/sword1/router.cpp
@@ -33,25 +33,25 @@
namespace Sword1 {
/****************************************************************************
- * JROUTER.C polygon router with modular walks
- * using a tree of modules
- * 21 july 94
+ * JROUTER.C polygon router with modular walks
+ * using a tree of modules
+ * 21 july 94
* 3 november 94
- * System currently works by scanning grid data and coming up with a ROUTE
+ * System currently works by scanning grid data and coming up with a ROUTE
* as a series of way points(nodes), the smoothest eight directional PATH
- * through these nodes is then found, and a WALK created to fit the PATH.
+ * through these nodes is then found, and a WALK created to fit the PATH.
*
- * Two funtions are called by the user, RouteFinder creates a route as a
- * module list, HardWalk creates an animation list from the module list.
- * The split is only provided to allow the possibility of turning the
- * autorouter over two game cycles.
+ * Two funtions are called by the user, RouteFinder creates a route as a
+ * module list, HardWalk creates an animation list from the module list.
+ * The split is only provided to allow the possibility of turning the
+ * autorouter over two game cycles.
****************************************************************************
*
* Routine timings on osborne 486
*
- * Read floor resource (file already loaded) 112 pixels
+ * Read floor resource (file already loaded) 112 pixels
*
- * Read mega resource (file already loaded) 112 pixels
+ * Read mega resource (file already loaded) 112 pixels
*
*
*
@@ -59,16 +59,16 @@ namespace Sword1 {
*
* Modified 12 Oct 95
*
- * Target Points within 1 pixel of a line are ignored ???
+ * Target Points within 1 pixel of a line are ignored ???
*
- * Modules split into Points within 1 pixel of a line are ignored ???
+ * Modules split into Points within 1 pixel of a line are ignored ???
*
****************************************************************************/
-#define NO_DIRECTIONS 8
-#define SLOW_IN 3
-#define SLOW_OUT 7
-#define ROUTE_END_FLAG 255
+#define NO_DIRECTIONS 8
+#define SLOW_IN 3
+#define SLOW_OUT 7
+#define ROUTE_END_FLAG 255
Router::Router(ObjectMan *pObjMan, ResMan *pResMan) {
_objMan = pObjMan;
@@ -85,9 +85,9 @@ Router::Router(ObjectMan *pObjMan, ResMan *pResMan) {
int32 Router::routeFinder(int32 id, Object *megaObject, int32 x, int32 y, int32 dir) {
/*********************************************************************
- * RouteFinder.C polygon router with modular walks
- * 21 august 94
- * 3 november 94
+ * RouteFinder.C polygon router with modular walks
+ * 21 august 94
+ * 3 november 94
* routeFinder creates a list of modules that enables HardWalk to
* create an animation list.
*
@@ -99,11 +99,11 @@ int32 Router::routeFinder(int32 id, Object *megaObject, int32 x, int32 y, int32
*
* 30 november 94 return values modified
*
- * return 0 = failed to find a route
+ * return 0 = failed to find a route
*
- * 1 = found a route
+ * 1 = found a route
*
- * 2 = mega already at target
+ * 2 = mega already at target
*
*********************************************************************/
@@ -117,7 +117,7 @@ int32 Router::routeFinder(int32 id, Object *megaObject, int32 x, int32 y, int32
walkAnim = megaObject->o_route;
- _framesPerStep = _nWalkFrames/2;
+ _framesPerStep = _nWalkFrames / 2;
_framesPerChar = _nWalkFrames * NO_DIRECTIONS;
// offset pointers added Oct 30 95 JPS
@@ -145,12 +145,12 @@ int32 Router::routeFinder(int32 id, Object *megaObject, int32 x, int32 y, int32
slowOutFrames = 0;
}
-// **************************************************************************
-// All route data now loaded start finding a route
-// **************************************************************************
-// **************************************************************************
-// check if we can get a route through the floor changed 12 Oct95 JPS
-// **************************************************************************
+ // **************************************************************************
+ // All route data now loaded start finding a route
+ // **************************************************************************
+ // **************************************************************************
+ // check if we can get a route through the floor changed 12 Oct95 JPS
+ // **************************************************************************
routeFlag = getRoute();
@@ -220,26 +220,26 @@ int32 Router::routeFinder(int32 id, Object *megaObject, int32 x, int32 y, int32
break;
}
- return routeFlag; // send back null route
+ return routeFlag; // send back null route
}
int32 Router::getRoute() {
/*********************************************************************
- * GetRoute.C extract a path from walk grid
- * 12 october 94
+ * GetRoute.C extract a path from walk grid
+ * 12 october 94
*
* GetRoute currently works by scanning grid data and coming up with
* a ROUTE as a series of way points(nodes).
*
* static routeData _route[O_ROUTE_SIZE];
*
- * return 0 = failed to find a route
+ * return 0 = failed to find a route
*
- * 1 = found a route
+ * 1 = found a route
*
- * 2 = mega already at target
+ * 2 = mega already at target
*
- * 3 = failed to find a route because target was on a line
+ * 3 = failed to find a route because target was on a line
*
*********************************************************************/
@@ -459,7 +459,7 @@ void Router::smoothCheck(int32 &k, int32 best, int32 p, int32 dirS, int32 dirD)
// set up sd0-ss2 to reflect possible movement in each direction
- if (dirS == 0 || dirS == 4) { // vert and diag
+ if (dirS == 0 || dirS == 4) { // vert and diag
ddx = ldx;
ddy = (ldx * _diagonaly) / _diagonalx;
dsy = ldy - ddy;
@@ -492,7 +492,7 @@ void Router::smoothCheck(int32 &k, int32 best, int32 p, int32 dirS, int32 dirD)
}
switch (best) {
- case 0: // halfsquare, diagonal, halfsquare
+ case 0: // halfsquare, diagonal, halfsquare
_smoothPath[k].x = x + dsx / 2;
_smoothPath[k].y = y + dsy / 2;
_smoothPath[k].dir = dirS;
@@ -512,7 +512,7 @@ void Router::smoothCheck(int32 &k, int32 best, int32 p, int32 dirS, int32 dirD)
k++;
break;
- case 1: // square, diagonal
+ case 1: // square, diagonal
_smoothPath[k].x = x + dsx;
_smoothPath[k].y = y + dsy;
_smoothPath[k].dir = dirS;
@@ -526,7 +526,7 @@ void Router::smoothCheck(int32 &k, int32 best, int32 p, int32 dirS, int32 dirD)
k++;
break;
- case 2: // diagonal square
+ case 2: // diagonal square
_smoothPath[k].x = x + ddx;
_smoothPath[k].y = y + ddy;
_smoothPath[k].dir = dirD;
@@ -540,7 +540,7 @@ void Router::smoothCheck(int32 &k, int32 best, int32 p, int32 dirS, int32 dirD)
k++;
break;
- default: // halfdiagonal, square, halfdiagonal
+ default: // halfdiagonal, square, halfdiagonal
_smoothPath[k].x = x + ddx / 2;
_smoothPath[k].y = y + ddy / 2;
_smoothPath[k].dir = dirD;
@@ -627,17 +627,17 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
* fits the smoothPath and uses foot slipping to fit whole steps into
* the route
*
- * Parameters: georgeg, mouseg
- * Returns: rout
+ * Parameters: georgeg, mouseg
+ * Returns: rout
*
* produce a module list from the line data
*********************************************************************/
int32 p;
- int32 lastDir;
- int32 lastRealDir;
- int32 currentDir;
- int32 turnDir;
+ int32 lastDir;
+ int32 lastRealDir;
+ int32 currentDir;
+ int32 turnDir;
int32 scale;
int32 step;
int32 module;
@@ -677,7 +677,7 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// START THE WALK WITH THE FIRST STANDFRAME THIS MAY CAUSE A DELAY
// BUT IT STOPS THE PLAYER MOVING FOR COLLISIONS ARE DETECTED
//****************************************************************************
- module = _framesPerChar + lastDir;
+ module = _framesPerChar + lastDir;
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
walkAnim[stepCount].dir = lastDir;
@@ -694,7 +694,7 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// get the direction to turn
turnDir = currentDir - lastDir;
if (turnDir < 0)
- turnDir += NO_DIRECTIONS;
+ turnDir += NO_DIRECTIONS;
if (turnDir > 4)
turnDir = -1;
@@ -704,10 +704,10 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// rotate to new walk direction
// for george and nico put in a head turn at the start
if ((megaId == GEORGE) || (megaId == NICO)) {
- if (turnDir < 0) { // new frames for turn frames 29oct95jps
- module = turnFramesLeft + lastDir;
+ if (turnDir < 0) { // new frames for turn frames 29oct95jps
+ module = turnFramesLeft + lastDir;
} else {
- module = turnFramesRight + lastDir;
+ module = turnFramesRight + lastDir;
}
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
@@ -720,14 +720,14 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// rotate till were facing new dir then go back 45 degrees
while (lastDir != currentDir) {
lastDir += turnDir;
- if (turnDir < 0) { // new frames for turn frames 29oct95jps
+ if (turnDir < 0) { // new frames for turn frames 29oct95jps
if (lastDir < 0)
- lastDir += NO_DIRECTIONS;
- module = turnFramesLeft + lastDir;
+ lastDir += NO_DIRECTIONS;
+ module = turnFramesLeft + lastDir;
} else {
if (lastDir > 7)
- lastDir -= NO_DIRECTIONS;
- module = turnFramesRight + lastDir;
+ lastDir -= NO_DIRECTIONS;
+ module = turnFramesRight + lastDir;
}
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
@@ -760,17 +760,17 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
lastDir = currentDir;
lastCount = stepCount;
}
- //calculate average amount to lose in each step on the way to the next _node
+ //calculate average amount to lose in each step on the way to the next _node
currentDir = _modularPath[p].dir;
if (currentDir < NO_DIRECTIONS) {
- module = currentDir * _framesPerStep * 2 + _slidyWalkAnimatorState * _framesPerStep;
+ module = currentDir * _framesPerStep * 2 + _slidyWalkAnimatorState * _framesPerStep;
_slidyWalkAnimatorState = !_slidyWalkAnimatorState;
moduleEnd = module + _framesPerStep;
step = 0;
scale = (_scaleA * moduleY + _scaleB);
do {
- module16X += _dx[module]*scale;
- module16Y += _dy[module]*scale;
+ module16X += _dx[module] * scale;
+ module16Y += _dy[module] * scale;
moduleX = module16X >> 16;
moduleY = module16Y >> 16;
walkAnim[stepCount].frame = module;
@@ -781,53 +781,53 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
stepCount += 1;
step += 1;
module += 1;
- } while ( module < moduleEnd);
+ } while (module < moduleEnd);
stepX = _modX[_modularPath[p].dir];
stepY = _modY[_modularPath[p].dir];
- errorX = _modularPath[p].x - moduleX;
+ errorX = _modularPath[p].x - moduleX;
errorX = errorX * stepX;
- errorY = _modularPath[p].y - moduleY;
+ errorY = _modularPath[p].y - moduleY;
errorY = errorY * stepY;
if ((errorX < 0) || (errorY < 0)) {
- _modularPath[p].num = 0; // the end of the path
+ _modularPath[p].num = 0; // the end of the path
// okay those last steps took us past our target but do we want to scoot or moonwalk
frames = stepCount - lastCount;
- errorX = _modularPath[p].x - walkAnim[stepCount-1].x;
- errorY = _modularPath[p].y - walkAnim[stepCount-1].y;
+ errorX = _modularPath[p].x - walkAnim[stepCount - 1].x;
+ errorY = _modularPath[p].y - walkAnim[stepCount - 1].y;
if (frames > _framesPerStep) {
- lastErrorX = _modularPath[p].x - walkAnim[stepCount-7].x;
- lastErrorY = _modularPath[p].y - walkAnim[stepCount-7].y;
- if (stepX==0) {
- if (3*ABS(lastErrorY) < ABS(errorY)) { //the last stop was closest
+ lastErrorX = _modularPath[p].x - walkAnim[stepCount - 7].x;
+ lastErrorY = _modularPath[p].y - walkAnim[stepCount - 7].y;
+ if (stepX == 0) {
+ if (3 * ABS(lastErrorY) < ABS(errorY)) { //the last stop was closest
stepCount -= _framesPerStep;
_slidyWalkAnimatorState = !_slidyWalkAnimatorState;
}
} else {
- if (3*ABS(lastErrorX) < ABS(errorX)) { //the last stop was closest
+ if (3 * ABS(lastErrorX) < ABS(errorX)) { //the last stop was closest
stepCount -= _framesPerStep;
_slidyWalkAnimatorState = !_slidyWalkAnimatorState;
}
}
}
- errorX = _modularPath[p].x - walkAnim[stepCount-1].x;
- errorY = _modularPath[p].y - walkAnim[stepCount-1].y;
+ errorX = _modularPath[p].x - walkAnim[stepCount - 1].x;
+ errorY = _modularPath[p].y - walkAnim[stepCount - 1].y;
// okay we've reached the end but we still have an error
if (errorX != 0) {
frameCount = 0;
frames = stepCount - lastCount;
do {
frameCount += 1;
- walkAnim[lastCount + frameCount - 1].x += errorX*frameCount/frames;
- } while (frameCount<frames);
+ walkAnim[lastCount + frameCount - 1].x += errorX * frameCount / frames;
+ } while (frameCount < frames);
}
if (errorY != 0) {
frameCount = 0;
frames = stepCount - lastCount;
do {
frameCount += 1;
- walkAnim[lastCount + frameCount-1].y += errorY*frameCount/frames;
- } while (frameCount<frames);
+ walkAnim[lastCount + frameCount - 1].y += errorY * frameCount / frames;
+ } while (frameCount < frames);
}
// Now is the time to put in the turn frames for the last turn
if (frames < _framesPerStep)
@@ -858,8 +858,8 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// all turns checked
lastCount = stepCount;
- moduleX = walkAnim[stepCount-1].x;
- moduleY = walkAnim[stepCount-1].y;
+ moduleX = walkAnim[stepCount - 1].x;
+ moduleY = walkAnim[stepCount - 1].y;
module16X = moduleX << 16;
module16Y = moduleY << 16;
}
@@ -879,9 +879,9 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// We've done the walk now put in any turns at the end
- if (_targetDir == NO_DIRECTIONS) { // stand in the last direction
- module = standFrames + lastRealDir;
- _targetDir = lastRealDir;
+ if (_targetDir == NO_DIRECTIONS) { // stand in the last direction
+ module = standFrames + lastRealDir;
+ _targetDir = lastRealDir;
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
walkAnim[stepCount].dir = lastRealDir;
@@ -891,7 +891,7 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
}
if (_targetDir == 9) {
if (stepCount == 0) {
- module = _framesPerChar + lastRealDir;
+ module = _framesPerChar + lastRealDir;
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
walkAnim[stepCount].dir = lastRealDir;
@@ -913,10 +913,10 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// rotate to target direction
// for george and nico put in a head turn at the start
if ((megaId == GEORGE) || (megaId == NICO)) {
- if (turnDir < 0) { // new frames for turn frames 29oct95jps
- module = turnFramesLeft + lastDir;
+ if (turnDir < 0) { // new frames for turn frames 29oct95jps
+ module = turnFramesLeft + lastDir;
} else {
- module = turnFramesRight + lastDir;
+ module = turnFramesRight + lastDir;
}
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
@@ -929,14 +929,14 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
// rotate if we need to
while (lastRealDir != _targetDir) {
lastRealDir += turnDir;
- if (turnDir < 0) { // new frames for turn frames 29oct95jps
+ if (turnDir < 0) { // new frames for turn frames 29oct95jps
if (lastRealDir < 0)
- lastRealDir += NO_DIRECTIONS;
- module = turnFramesLeft + lastRealDir;
+ lastRealDir += NO_DIRECTIONS;
+ module = turnFramesLeft + lastRealDir;
} else {
if (lastRealDir > 7)
- lastRealDir -= NO_DIRECTIONS;
- module = turnFramesRight + lastRealDir;
+ lastRealDir -= NO_DIRECTIONS;
+ module = turnFramesRight + lastRealDir;
}
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
@@ -945,10 +945,10 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
walkAnim[stepCount].y = moduleY;
stepCount += 1;
}
- module = standFrames + lastRealDir;
- walkAnim[stepCount-1].frame = module;
+ module = standFrames + lastRealDir;
+ walkAnim[stepCount - 1].frame = module;
} else { // just stand at the end
- module = standFrames + lastRealDir;
+ module = standFrames + lastRealDir;
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
walkAnim[stepCount].dir = lastRealDir;
@@ -962,7 +962,7 @@ void Router::slidyWalkAnimator(WalkData *walkAnim) {
walkAnim[stepCount].frame = 512;
stepCount += 1;
walkAnim[stepCount].frame = 512;
-// Tdebug("RouteFinder RouteSize is %d", stepCount);
+ //Tdebug("RouteFinder RouteSize is %d", stepCount);
return;
}
@@ -1071,7 +1071,7 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
// start at the begining for a change
lastDir = _modularPath[0].dir;
currentDir = _modularPath[1].dir;
- module = _framesPerChar + lastDir;
+ module = _framesPerChar + lastDir;
moduleX = _startX;
moduleY = _startY;
module16X = moduleX << 16;
@@ -1100,7 +1100,7 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
// get the direction to turn
turnDir = currentDir - lastDir;
if (turnDir < 0)
- turnDir += NO_DIRECTIONS;
+ turnDir += NO_DIRECTIONS;
if (turnDir > 4)
turnDir = -1;
@@ -1110,10 +1110,10 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
// rotate to new walk direction
// for george and nico put in a head turn at the start
if ((megaId == GEORGE) || (megaId == NICO)) {
- if (turnDir < 0) { // new frames for turn frames 29oct95jps
- module = turnFramesLeft + lastDir;
+ if (turnDir < 0) { // new frames for turn frames 29oct95jps
+ module = turnFramesLeft + lastDir;
} else {
- module = turnFramesRight + lastDir;
+ module = turnFramesRight + lastDir;
}
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
@@ -1126,14 +1126,14 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
// rotate till were facing new dir then go back 45 degrees
while (lastDir != currentDir) {
lastDir += turnDir;
- if (turnDir < 0) { // new frames for turn frames 29oct95jps
+ if (turnDir < 0) { // new frames for turn frames 29oct95jps
if (lastDir < 0)
lastDir += NO_DIRECTIONS;
- module = turnFramesLeft + lastDir;
+ module = turnFramesLeft + lastDir;
} else {
if (lastDir > 7)
lastDir -= NO_DIRECTIONS;
- module = turnFramesRight + lastDir;
+ module = turnFramesRight + lastDir;
}
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
@@ -1213,19 +1213,19 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
int32 p;
- for (p = 1; _modularPath[p].dir < NO_DIRECTIONS; ++p) {
+ for (p = 1; _modularPath[p].dir < NO_DIRECTIONS; ++p) {
while (_modularPath[p].num > 0) {
currentDir = _modularPath[p].dir;
if (currentDir < NO_DIRECTIONS) {
- module = currentDir * _framesPerStep * 2 + left * _framesPerStep;
+ module = currentDir * _framesPerStep * 2 + left * _framesPerStep;
left = !left;
moduleEnd = module + _framesPerStep;
step = 0;
scale = (_scaleA * moduleY + _scaleB);
do {
- module16X += _dx[module]*scale;
- module16Y += _dy[module]*scale;
+ module16X += _dx[module] * scale;
+ module16Y += _dy[module] * scale;
moduleX = module16X >> 16;
moduleY = module16Y >> 16;
walkAnim[stepCount].frame = module;
@@ -1236,22 +1236,22 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
stepCount += 1;
module += 1;
step += 1;
- } while ( module < moduleEnd);
- errorX = _modularPath[p].x - moduleX;
+ } while (module < moduleEnd);
+ errorX = _modularPath[p].x - moduleX;
errorX = errorX * _modX[_modularPath[p].dir];
- errorY = _modularPath[p].y - moduleY;
+ errorY = _modularPath[p].y - moduleY;
errorY = errorY * _modY[_modularPath[p].dir];
if ((errorX < 0) || (errorY < 0)) {
_modularPath[p].num = 0;
stepCount -= _framesPerStep;
left = !left;
// Okay this is the end of a section
- moduleX = walkAnim[stepCount-1].x;
- moduleY = walkAnim[stepCount-1].y;
+ moduleX = walkAnim[stepCount - 1].x;
+ moduleY = walkAnim[stepCount - 1].y;
module16X = moduleX << 16;
module16Y = moduleY << 16;
- _modularPath[p].x =moduleX;
- _modularPath[p].y =moduleY;
+ _modularPath[p].x = moduleX;
+ _modularPath[p].y = moduleY;
// Now is the time to put in the turn frames for the last turn
if ((stepCount - lastCount) < _framesPerStep) { // no step taken
currentDir = 99;// this ensures that we don't put in turn frames for this walk or the next
@@ -1350,10 +1350,10 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
stepCount += 1;
}
}
- module = _framesPerChar + _modularPath[p-1].dir;
+ module = _framesPerChar + _modularPath[p - 1].dir;
walkAnim[stepCount].frame = module;
walkAnim[stepCount].step = 0;
- walkAnim[stepCount].dir = _modularPath[p-1].dir;
+ walkAnim[stepCount].dir = _modularPath[p - 1].dir;
walkAnim[stepCount].x = moduleX;
walkAnim[stepCount].y = moduleY;
stepCount += 1;
@@ -1395,7 +1395,7 @@ int32 Router::solidWalkAnimator(WalkData *walkAnim) {
bool Router::scan(int32 level) {
/*********************************************************************
- * Called successively from routeFinder until no more changes take
+ * Called successively from routeFinder until no more changes take
* place in the grid array, ie he best path has been found
*
* Scans through every point in the node array and checks if there is
@@ -1447,7 +1447,7 @@ bool Router::scan(int32 level) {
}
-int32 Router::newCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 y2) {
+int32 Router::newCheck(int32 status, int32 x1, int32 y1, int32 x2, int32 y2) {
/*********************************************************************
* newCheck routine checks if the route between two points can be
* achieved without crossing any of the bars in the Bars array.
@@ -1531,7 +1531,7 @@ int32 Router::newCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 y2) {
step2 = check(x1 + ldx / 2, y1, x1 + ldx / 2 + dlx, y2);
if (step2 != 0) {
step3 = check(x1 + ldx / 2 + dlx, y2, x2, y2);
- if (step3 != 0) {
+ if (step3 != 0) {
steps = step1 + step2 + step3;
options |= 1;
}
@@ -1565,8 +1565,8 @@ int32 Router::newCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 y2) {
ldx = 0;
// options are square, diagonal a code 1 route
- step1 = check(x1 ,y1, x1, y1 + ldy);
- if (step1 != 0) {
+ step1 = check(x1 , y1, x1, y1 + ldy);
+ if (step1 != 0) {
step2 = check(x1, y1 + ldy, x2, y2);
if (step2 != 0) {
steps = step1 + step2;
@@ -1608,7 +1608,7 @@ int32 Router::newCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 y2) {
step2 = check(x1 + dlx / 2, y1 + dly / 2, x1 + dlx / 2, y1 + ldy + dly / 2);
if (step2 != 0) {
step3 = check(x1 + dlx / 2, y1 + ldy + dly / 2, x2, y2);
- if (step3 != 0) {
+ if (step3 != 0) {
steps = step1 + step2 + step3;
options |= 8;
}
@@ -1659,7 +1659,7 @@ bool Router::lineCheck(int32 x1, int32 y1, int32 x2, int32 y2) {
int32 dirx = x2 - x1;
int32 diry = y2 - y1;
- int32 co = (y1 * dirx) - (x1 * diry); // new line equation
+ int32 co = (y1 * dirx) - (x1 * diry); // new line equation
for (int i = 0; i < _nBars && linesCrossed; i++) {
// skip if not on module
@@ -1668,7 +1668,7 @@ bool Router::lineCheck(int32 x1, int32 y1, int32 x2, int32 y2) {
// but all this arithmetic we must have loads of time
// slope it he slope between the two lines
- int32 slope = (_bars[i].dx * diry) - (_bars[i].dy *dirx);
+ int32 slope = (_bars[i].dx * diry) - (_bars[i].dy * dirx);
// assuming parallel lines don't cross
if (slope != 0) {
// calculate x intercept and check its on both
@@ -1818,50 +1818,50 @@ int32 Router::checkTarget(int32 x, int32 y) {
// ****************************************************************************
int32 Router::LoadWalkResources(Object *megaObject, int32 x, int32 y, int32 dir) {
- WalkGridHeader floorHeader;
- int32 i;
- uint8 *fPolygrid;
- uint8 *fMegaWalkData;
+ WalkGridHeader floorHeader;
+ int32 i;
+ uint8 *fPolygrid;
+ uint8 *fMegaWalkData;
- int32 floorId;
- int32 walkGridResourceId;
+ int32 floorId;
+ int32 walkGridResourceId;
Object *floorObject;
- int32 cnt;
+ int32 cnt;
uint32 cntu;
// load in floor grid for current mega
floorId = megaObject->o_place;
- //floorObject = (object *) Lock_object(floorId);
+ //floorObject = (object *)Lock_object(floorId);
floorObject = _objMan->fetchObject(floorId);
walkGridResourceId = floorObject->o_resource;
//Unlock_object(floorId);
- //ResOpen(walkGridResourceId); // mouse wiggle
- //fPolygrid = ResLock(walkGridResourceId); // mouse wiggle
- fPolygrid = (uint8*)_resMan->openFetchRes(walkGridResourceId);
+ //ResOpen(walkGridResourceId); // mouse wiggle
+ //fPolygrid = ResLock(walkGridResourceId); // mouse wiggle
+ fPolygrid = (uint8 *)_resMan->openFetchRes(walkGridResourceId);
fPolygrid += sizeof(Header);
- memcpy(&floorHeader,fPolygrid,sizeof(WalkGridHeader));
+ memcpy(&floorHeader, fPolygrid, sizeof(WalkGridHeader));
fPolygrid += sizeof(WalkGridHeader);
_nBars = _resMan->getUint32(floorHeader.numBars);
if (_nBars >= O_GRID_SIZE) {
- #ifdef DEBUG //check for id > number in file,
+#ifdef DEBUG //check for id > number in file,
error("RouteFinder Error too many _bars %d", _nBars);
- #endif
+#endif
_nBars = 0;
}
- _nNodes = _resMan->getUint32(floorHeader.numNodes)+1; //array starts at 0 begins at a start _node has nnodes nodes and a target _node
+ _nNodes = _resMan->getUint32(floorHeader.numNodes) + 1; //array starts at 0 begins at a start _node has nnodes nodes and a target _node
if (_nNodes >= O_GRID_SIZE) {
- #ifdef DEBUG //check for id > number in file,
- error("RouteFinder Error too many nodes %d", _nNodes);
- #endif
+#ifdef DEBUG //check for id > number in file,
+ error("RouteFinder Error too many nodes %d", _nNodes);
+#endif
_nNodes = 0;
}
@@ -1883,37 +1883,37 @@ int32 Router::LoadWalkResources(Object *megaObject, int32 x, int32 y, int32 dir)
/*j = 1;// leave _node 0 for start _node
do {
- memmove(&_node[j].x,fPolygrid,2*sizeof(int16));
- fPolygrid += 2*sizeof(int16);
- j ++;
+ memmove(&_node[j].x,fPolygrid,2*sizeof(int16));
+ fPolygrid += 2*sizeof(int16);
+ j ++;
} while (j < _nNodes);//array starts at 0*/
for (cnt = 1; cnt < _nNodes; cnt++) {
_node[cnt].x = _resMan->readUint16(fPolygrid); fPolygrid += 2;
_node[cnt].y = _resMan->readUint16(fPolygrid); fPolygrid += 2;
}
- //ResUnlock(walkGridResourceId); // mouse wiggle
- //ResClose(walkGridResourceId); // mouse wiggle
+ //ResUnlock(walkGridResourceId); // mouse wiggle
+ //ResClose(walkGridResourceId); // mouse wiggle
_resMan->resClose(walkGridResourceId);
// floor grid loaded
-// copy the mega structure into the local variables for use in all subroutines
+ // copy the mega structure into the local variables for use in all subroutines
_startX = megaObject->o_xcoord;
_startY = megaObject->o_ycoord;
_startDir = megaObject->o_dir;
_targetX = x;
- _targetY= y;
+ _targetY = y;
_targetDir = dir;
_scaleA = megaObject->o_scale_a;
_scaleB = megaObject->o_scale_b;
- //ResOpen(megaObject->o_mega_resource); // mouse wiggle
- //fMegaWalkData = ResLock(megaObject->o_mega_resource); // mouse wiggle
- fMegaWalkData = (uint8*)_resMan->openFetchRes(megaObject->o_mega_resource);
+ //ResOpen(megaObject->o_mega_resource); // mouse wiggle
+ //fMegaWalkData = ResLock(megaObject->o_mega_resource); // mouse wiggle
+ fMegaWalkData = (uint8 *)_resMan->openFetchRes(megaObject->o_mega_resource);
// Apparently this resource is in little endian in both the Mac and the PC version
_nWalkFrames = fMegaWalkData[0];
@@ -1945,28 +1945,28 @@ int32 Router::LoadWalkResources(Object *megaObject, int32 x, int32 y, int32 dir)
memmove(&_modY[0],fMegaWalkData,NO_DIRECTIONS*sizeof(int32));
fMegaWalkData += NO_DIRECTIONS*sizeof(int32);*/
- //ResUnlock(megaObject->o_mega_resource); // mouse wiggle
- //ResClose(megaObject->o_mega_resource); // mouse wiggle
+ //ResUnlock(megaObject->o_mega_resource); // mouse wiggle
+ //ResClose(megaObject->o_mega_resource); // mouse wiggle
_resMan->resClose(megaObject->o_mega_resource);
_diagonalx = _modX[3]; //36
_diagonaly = _modY[3]; //8
-// mega data ready
+ // mega data ready
-// finish setting grid by putting mega _node at begining
-// and target _node at end and reset current values
+ // finish setting grid by putting mega _node at begining
+ // and target _node at end and reset current values
_node[0].x = _startX;
_node[0].y = _startY;
_node[0].level = 1;
_node[0].prev = 0;
_node[0].dist = 0;
- i=1;
+ i = 1;
do {
_node[i].level = 0;
_node[i].prev = 0;
_node[i].dist = 9999;
- i=i+1;
+ i = i + 1;
} while (i < _nNodes);
_node[_nNodes].x = _targetX;
_node[_nNodes].y = _targetY;
@@ -2088,12 +2088,12 @@ void Router::extractRoute() {
#define DIAGONALY 8
int whatTarget(int32 startX, int32 startY, int32 destX, int32 destY) {
int tar_dir;
-//setting up
- int deltaX = destX-startX;
- int deltaY = destY-startY;
+ //setting up
+ int deltaX = destX - startX;
+ int deltaY = destY - startY;
int signX = (deltaX > 0);
int signY = (deltaY > 0);
- int slope;
+ int slope;
if ((ABS(deltaY) * DIAGONALX) < (ABS(deltaX) * DIAGONALY / 2))
slope = 0;// its flat
@@ -2103,22 +2103,22 @@ int whatTarget(int32 startX, int32 startY, int32 destX, int32 destY) {
slope = 1;// its diagonal
if (slope == 0) { //flat
- if (signX == 1) // going right
+ if (signX == 1) // going right
tar_dir = 2;
else
tar_dir = 6;
} else if (slope == 2) { //vertical
- if (signY == 1) // going down
+ if (signY == 1) // going down
tar_dir = 4;
else
tar_dir = 0;
} else if (signX == 1) { //right diagonal
- if (signY == 1) // going down
+ if (signY == 1) // going down
tar_dir = 3;
else
tar_dir = 1;
} else { //left diagonal
- if (signY == 1) // going down
+ if (signY == 1) // going down
tar_dir = 5;
else
tar_dir = 7;
diff --git a/engines/sword1/router.h b/engines/sword1/router.h
index 31c4291eed..82724b1e6e 100644
--- a/engines/sword1/router.h
+++ b/engines/sword1/router.h
@@ -27,7 +27,7 @@
namespace Sword1 {
-#include "common/pack-start.h" // START STRUCT PACKING
+#include "common/pack-start.h" // START STRUCT PACKING
struct BarData {
int16 x1;
@@ -38,9 +38,9 @@ struct BarData {
int16 ymin;
int16 xmax;
int16 ymax;
- int16 dx; // x2 - x1
- int16 dy; // y2 - y1
- int32 co; // co = (y1*dx) - (x1*dy) from an equation for a line y*dx = x*dy + co
+ int16 dx; // x2 - x1
+ int16 dy; // y2 - y1
+ int32 co; // co = (y1*dx) - (x1*dy) from an equation for a line y*dx = x*dy + co
} PACKED_STRUCT;
struct NodeData {
@@ -51,13 +51,13 @@ struct NodeData {
int16 dist;
} PACKED_STRUCT;
-#include "common/pack-end.h" // END STRUCT PACKING
+#include "common/pack-end.h" // END STRUCT PACKING
struct FloorData {
- int32 nbars;
- BarData *bars;
- int32 nnodes;
- NodeData *node;
+ int32 nbars;
+ BarData *bars;
+ int32 nnodes;
+ NodeData *node;
};
struct RouteData {
@@ -115,24 +115,24 @@ private:
int32 megaId;
- RouteData _route[O_ROUTE_SIZE];
- PathData _smoothPath[O_ROUTE_SIZE];
- PathData _modularPath[O_ROUTE_SIZE];
- int32 _routeLength;
-
- int32 _framesPerStep, _framesPerChar;
- uint8 _nWalkFrames, _nTurnFrames;
- int32 _dx[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
- int32 _dy[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
- int32 _modX[NO_DIRECTIONS];
- int32 _modY[NO_DIRECTIONS];
- int32 _diagonalx, _diagonaly;
- int32 standFrames;
- int32 turnFramesLeft, turnFramesRight;
- int32 walkFramesLeft, walkFramesRight; // left/right walking turn
- int32 slowInFrames, slowOutFrames;
-
- bool _slidyWalkAnimatorState;
+ RouteData _route[O_ROUTE_SIZE];
+ PathData _smoothPath[O_ROUTE_SIZE];
+ PathData _modularPath[O_ROUTE_SIZE];
+ int32 _routeLength;
+
+ int32 _framesPerStep, _framesPerChar;
+ uint8 _nWalkFrames, _nTurnFrames;
+ int32 _dx[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
+ int32 _dy[NO_DIRECTIONS + MAX_FRAMES_PER_CHAR];
+ int32 _modX[NO_DIRECTIONS];
+ int32 _modY[NO_DIRECTIONS];
+ int32 _diagonalx, _diagonaly;
+ int32 standFrames;
+ int32 turnFramesLeft, turnFramesRight;
+ int32 walkFramesLeft, walkFramesRight; // left/right walking turn
+ int32 slowInFrames, slowOutFrames;
+
+ bool _slidyWalkAnimatorState;
int32 LoadWalkResources(Object *mega, int32 x, int32 y, int32 dir);
int32 getRoute();
diff --git a/engines/sword1/screen.cpp b/engines/sword1/screen.cpp
index 1da89a1091..c7368c9184 100644
--- a/engines/sword1/screen.cpp
+++ b/engines/sword1/screen.cpp
@@ -134,13 +134,13 @@ void Screen::fadeUpPalette() {
}
void Screen::fnSetPalette(uint8 start, uint16 length, uint32 id, bool fadeUp) {
- uint8 *palData = (uint8*)_resMan->openFetchRes(id);
+ uint8 *palData = (uint8 *)_resMan->openFetchRes(id);
if (start == 0) // force color 0 to black
palData[0] = palData[1] = palData[2] = 0;
if (SwordEngine::isMac()) { // see bug #1701058
if (start != 0 && start + length == 256) // and force color 255 to black as well
- palData[(length-1)*3+0] = palData[(length-1)*3+1] = palData[(length-1)*3+2] = 0;
+ palData[(length - 1) * 3 + 0] = palData[(length - 1) * 3 + 1] = palData[(length - 1) * 3 + 2] = 0;
}
for (uint32 cnt = 0; cnt < length; cnt++) {
@@ -172,7 +172,7 @@ bool Screen::showScrollFrame() {
if ((!_fullRefresh) || Logic::_scriptVars[NEW_PALETTE] || _updatePalette)
return false; // don't draw an additional frame if we aren't scrolling or have to change the palette
if ((_oldScrollX == Logic::_scriptVars[SCROLL_OFFSET_X]) &&
- (_oldScrollY == Logic::_scriptVars[SCROLL_OFFSET_Y]))
+ (_oldScrollY == Logic::_scriptVars[SCROLL_OFFSET_Y]))
return false; // check again if we *really* are scrolling.
uint16 avgScrlX = (uint16)(_oldScrollX + Logic::_scriptVars[SCROLL_OFFSET_X]) / 2;
@@ -322,25 +322,25 @@ void Screen::newScreen(uint32 screen) {
if (SwordEngine::isPsx())
flushPsxCache();
- _screenBuf = (uint8*)malloc(_scrnSizeX * _scrnSizeY);
- _screenGrid = (uint8*)malloc(_gridSizeX * _gridSizeY);
+ _screenBuf = (uint8 *)malloc(_scrnSizeX * _scrnSizeY);
+ _screenGrid = (uint8 *)malloc(_gridSizeX * _gridSizeY);
memset(_screenGrid, 0, _gridSizeX * _gridSizeY);
for (cnt = 0; cnt < _roomDefTable[_currentScreen].totalLayers; cnt++) {
// open and lock all resources, will be closed in quitScreen()
- _layerBlocks[cnt] = (uint8*)_resMan->openFetchRes(_roomDefTable[_currentScreen].layers[cnt]);
+ _layerBlocks[cnt] = (uint8 *)_resMan->openFetchRes(_roomDefTable[_currentScreen].layers[cnt]);
if (cnt > 0)
_layerBlocks[cnt] += sizeof(Header);
}
for (cnt = 0; cnt < _roomDefTable[_currentScreen].totalLayers - 1; cnt++) {
// there's no grid for the background layer, so it's totalLayers - 1
- _layerGrid[cnt] = (uint16*)_resMan->openFetchRes(_roomDefTable[_currentScreen].grids[cnt]);
+ _layerGrid[cnt] = (uint16 *)_resMan->openFetchRes(_roomDefTable[_currentScreen].grids[cnt]);
_layerGrid[cnt] += 14;
}
_parallax[0] = _parallax[1] = NULL;
if (_roomDefTable[_currentScreen].parallax[0])
- _parallax[0] = (uint8*)_resMan->openFetchRes(_roomDefTable[_currentScreen].parallax[0]);
+ _parallax[0] = (uint8 *)_resMan->openFetchRes(_roomDefTable[_currentScreen].parallax[0]);
if (_roomDefTable[_currentScreen].parallax[1])
- _parallax[1] = (uint8*)_resMan->openFetchRes(_roomDefTable[_currentScreen].parallax[1]);
+ _parallax[1] = (uint8 *)_resMan->openFetchRes(_roomDefTable[_currentScreen].parallax[1]);
_updatePalette = true;
_fullRefresh = true;
@@ -393,13 +393,13 @@ void Screen::draw() {
src++;
dest++;
}
- }
+ }
} else if (!(SwordEngine::isPsx())) {
memcpy(_screenBuf, _layerBlocks[0], _scrnSizeX * _scrnSizeY);
} else { //We are using PSX version
if (_currentScreen == 45 || _currentScreen == 55 ||
- _currentScreen == 57 || _currentScreen == 63 || _currentScreen == 71) { // Width shrinked backgrounds
+ _currentScreen == 57 || _currentScreen == 63 || _currentScreen == 71) { // Width shrinked backgrounds
if (!_psxCache.decodedBackground)
_psxCache.decodedBackground = psxShrinkedBackgroundToIndexed(_layerBlocks[0], _scrnSizeX, _scrnSizeY);
} else {
@@ -431,7 +431,7 @@ void Screen::draw() {
if (!_psxCache.extPlxCache) {
Common::File parallax;
parallax.open("TRAIN.PLX");
- _psxCache.extPlxCache = (uint8*) malloc(parallax.size());
+ _psxCache.extPlxCache = (uint8 *)malloc(parallax.size());
parallax.read(_psxCache.extPlxCache, parallax.size());
parallax.close();
}
@@ -456,7 +456,7 @@ void Screen::processImage(uint32 id) {
else
frameHead = _resMan->fetchFrame(_resMan->openFetchRes(compact->o_resource), compact->o_frame);
- uint8 *sprData = ((uint8*)frameHead) + sizeof(FrameHeader);
+ uint8 *sprData = ((uint8 *)frameHead) + sizeof(FrameHeader);
uint16 spriteX = compact->o_anim_x;
uint16 spriteY = compact->o_anim_y;
@@ -474,8 +474,8 @@ void Screen::processImage(uint32 id) {
uint8 *tonyBuf = NULL;
uint8 *hifBuf = NULL;
if (SwordEngine::isPsx() && compact->o_type != TYPE_TEXT) { // PSX sprites are compressed with HIF
- hifBuf = (uint8*)malloc(_resMan->readUint16(&frameHead->width) * _resMan->readUint16(&frameHead->height)/2);
- memset(hifBuf, 0x00, (_resMan->readUint16(&frameHead->width) * _resMan->readUint16(&frameHead->height)/2));
+ hifBuf = (uint8 *)malloc(_resMan->readUint16(&frameHead->width) * _resMan->readUint16(&frameHead->height) / 2);
+ memset(hifBuf, 0x00, (_resMan->readUint16(&frameHead->width) * _resMan->readUint16(&frameHead->height) / 2));
decompressHIF(sprData, hifBuf);
sprData = hifBuf;
} else if (frameHead->runTimeComp[3] == '7') { // RLE7 encoded?
@@ -485,7 +485,7 @@ void Screen::processImage(uint32 id) {
decompressRLE0(sprData, _resMan->readUint32(&frameHead->compSize), _rleBuffer);
sprData = _rleBuffer;
} else if (frameHead->runTimeComp[1] == 'I') { // new type
- tonyBuf = (uint8*)malloc(_resMan->readUint16(&frameHead->width) * _resMan->readUint16(&frameHead->height));
+ tonyBuf = (uint8 *)malloc(_resMan->readUint16(&frameHead->width) * _resMan->readUint16(&frameHead->height));
decompressTony(sprData, _resMan->readUint32(&frameHead->compSize), tonyBuf);
sprData = tonyBuf;
}
@@ -538,16 +538,16 @@ void Screen::processImage(uint32 id) {
if ((sprSizeX > 0) && (sprSizeY > 0)) {
if ((!(SwordEngine::isPsx()) || (compact->o_type == TYPE_TEXT)
- || (compact->o_resource == LVSFLY) || (!(compact->o_resource == GEORGE_MEGA) && (sprSizeX < 260))))
+ || (compact->o_resource == LVSFLY) || (!(compact->o_resource == GEORGE_MEGA) && (sprSizeX < 260))))
drawSprite(sprData + incr, spriteX, spriteY, sprSizeX, sprSizeY, sprPitch);
else if (((sprSizeX >= 260) && (sprSizeX < 450)) || ((compact->o_resource == GMWRITH) && (sprSizeX < 515)) // a psx shrinked sprite (1/2 width)
- || ((compact->o_resource == GMPOWER) && (sprSizeX < 515))) // some needs to be hardcoded, headers don't give useful infos
+ || ((compact->o_resource == GMPOWER) && (sprSizeX < 515))) // some needs to be hardcoded, headers don't give useful infos
drawPsxHalfShrinkedSprite(sprData + incr, spriteX, spriteY, sprSizeX / 2, sprSizeY, sprPitch / 2);
else if (sprSizeX >= 450) // A PSX double shrinked sprite (1/3 width)
drawPsxFullShrinkedSprite(sprData + incr, spriteX, spriteY, sprSizeX / 3, sprSizeY, sprPitch / 3);
else // This is for psx half shrinked, walking george and remaining sprites
drawPsxHalfShrinkedSprite(sprData + incr, spriteX, spriteY, sprSizeX, sprSizeY, sprPitch);
- if (!(compact->o_status&STAT_FORE) && !(SwordEngine::isPsx() && (compact->o_resource == MOUBUSY))) // Check fixes moue sprite being masked by layer, happens only on psx
+ if (!(compact->o_status & STAT_FORE) && !(SwordEngine::isPsx() && (compact->o_resource == MOUBUSY))) // Check fixes moue sprite being masked by layer, happens only on psx
verticalMask(spriteX, spriteY, sprSizeX, sprSizeY);
}
@@ -636,8 +636,8 @@ void Screen::renderParallax(uint8 *data) {
if (SwordEngine::isPsx()) //Parallax headers are different in PSX version
fetchPsxParallaxSize(data, &paraSizeX, &paraSizeY);
else {
- header = (ParallaxHeader*)data;
- lineIndexes = (uint32*)(data + sizeof(ParallaxHeader));
+ header = (ParallaxHeader *)data;
+ lineIndexes = (uint32 *)(data + sizeof(ParallaxHeader));
paraSizeX = _resMan->getUint16(header->sizeX);
paraSizeY = _resMan->getUint16(header->sizeY);
}
@@ -832,7 +832,7 @@ void Screen::addToGraphicList(uint8 listId, uint32 objId) {
_sortList[_sortLength].id = objId;
_sortList[_sortLength].y = cpt->o_anim_y; // gives feet coords if boxed mega, otherwise top of sprite box
if (!(cpt->o_status & STAT_SHRINK)) { // not a boxed mega using shrinking
- Header *frameRaw = (Header*)_resMan->openFetchRes(cpt->o_resource);
+ Header *frameRaw = (Header *)_resMan->openFetchRes(cpt->o_resource);
FrameHeader *frameHead = _resMan->fetchFrame(frameRaw, cpt->o_frame);
_sortList[_sortLength].y += _resMan->readUint16(&frameHead->height) - 1; // now pointing to base of sprite
_resMan->resClose(cpt->o_resource);
@@ -845,7 +845,7 @@ void Screen::addToGraphicList(uint8 listId, uint32 objId) {
}
}
-uint8* Screen::psxBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres) {
+uint8 *Screen::psxBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres) {
uint32 xresInTiles = bakXres / 16;
uint32 yresInTiles = ((bakYres / 2) % 16) ? (bakYres / 32) + 1 : (bakYres / 32);
uint32 totTiles = xresInTiles * yresInTiles;
@@ -867,7 +867,7 @@ uint8* Screen::psxBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint
if (isCompressed)
decompressHIF(psxBackground + tileOffset - 4, decomp_tile); //Decompress the tile into decomp_tile
else
- memcpy(decomp_tile, psxBackground + tileOffset - 4, 16*16);
+ memcpy(decomp_tile, psxBackground + tileOffset - 4, 16 * 16);
if (currentTile > 0 && !(currentTile % xresInTiles)) { //Finished a line of tiles, going down
tileYpos++;
@@ -887,7 +887,7 @@ uint8* Screen::psxBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint
}
// needed because some psx backgrounds are half width and half height
-uint8* Screen::psxShrinkedBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres) {
+uint8 *Screen::psxShrinkedBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres) {
uint32 xresInTiles = ((bakXres / 2) % 16) ? (bakXres / 32) + 1 : (bakXres / 32);
uint32 yresInTiles = ((bakYres / 2) % 16) ? (bakYres / 32) + 1 : (bakYres / 32);
uint32 totTiles = xresInTiles * yresInTiles;
@@ -899,7 +899,7 @@ uint8* Screen::psxShrinkedBackgroundToIndexed(uint8 *psxBackground, uint32 bakXr
uint8 *fullres_buffer = (uint8 *)malloc(bakXres * (yresInTiles + 1) * 32);
memset(fullres_buffer, 0, bakXres * (yresInTiles + 1) * 32);
- bool isCompressed = (READ_LE_UINT32(psxBackground) == MKTAG('C','O','M','P'));
+ bool isCompressed = (READ_LE_UINT32(psxBackground) == MKTAG('C', 'O', 'M', 'P'));
totTiles -= xresInTiles;
psxBackground += 4; //We skip the id tag
@@ -1182,7 +1182,7 @@ void Screen::spriteClipAndSet(uint16 *pSprX, uint16 *pSprY, uint16 *pSprWidth, u
if (*pSprWidth && *pSprHeight) {
// sprite will be drawn, so mark it in the grid buffer
uint16 gridH = (*pSprHeight + (sprY & (SCRNGRID_Y - 1)) + (SCRNGRID_Y - 1)) / SCRNGRID_Y;
- uint16 gridW = (*pSprWidth + (sprX & (SCRNGRID_X - 1)) + (SCRNGRID_X - 1)) / SCRNGRID_X;
+ uint16 gridW = (*pSprWidth + (sprX & (SCRNGRID_X - 1)) + (SCRNGRID_X - 1)) / SCRNGRID_X;
if (SwordEngine::isPsx()) {
gridH *= 2; // This will correct the PSX sprite being cut at half height
@@ -1229,10 +1229,10 @@ void Screen::showFrame(uint16 x, uint16 y, uint32 resId, uint32 frameNo, const b
if (resId != 0xffffffff) {
FrameHeader *frameHead = _resMan->fetchFrame(_resMan->openFetchRes(resId), frameNo);
- uint8 *frameData = ((uint8*)frameHead) + sizeof(FrameHeader);
+ uint8 *frameData = ((uint8 *)frameHead) + sizeof(FrameHeader);
if (SwordEngine::isPsx()) { //We need to decompress PSX frames
- uint8 *frameBufferPSX = (uint8 *)malloc(_resMan->getUint16(frameHead->width) * _resMan->getUint16(frameHead->height)/2);
+ uint8 *frameBufferPSX = (uint8 *)malloc(_resMan->getUint16(frameHead->width) * _resMan->getUint16(frameHead->height) / 2);
decompressHIF(frameData, frameBufferPSX);
for (i = 0; i < _resMan->getUint16(frameHead->height) / 2; i++) {
diff --git a/engines/sword1/screen.h b/engines/sword1/screen.h
index ff4df8c7c6..45608531fb 100644
--- a/engines/sword1/screen.h
+++ b/engines/sword1/screen.h
@@ -38,14 +38,14 @@ struct SortSpr {
};
struct RoomDef {
- int totalLayers;
- int sizeX;
- int sizeY;
- int gridWidth; //number of 16*16 grid blocks across - including off screen edges.
- uint32 layers[4];
- uint32 grids[3];
- uint32 palettes[2];
- uint32 parallax[2];
+ int totalLayers;
+ int sizeX;
+ int sizeY;
+ int gridWidth; //number of 16*16 grid blocks across - including off screen edges.
+ uint32 layers[4];
+ uint32 grids[3];
+ uint32 palettes[2];
+ uint32 parallax[2];
};
struct PSXDataCache { // Cache for PSX screen, to avoid decompressing background at every screen update
@@ -68,7 +68,7 @@ struct PSXDataCache { // Cache for PSX screen, to avoid decompressing background
class ResMan;
class ObjectMan;
class Text; // Text objects use sprites that are created internally at run-time
- // the buffer belongs to Text, so we need a reference here.
+ // the buffer belongs to Text, so we need a reference here.
class Screen {
public:
@@ -118,8 +118,8 @@ private:
void drawSprite(uint8 *sprData, uint16 sprX, uint16 sprY, uint16 sprWidth, uint16 sprHeight, uint16 sprPitch);
void drawPsxHalfShrinkedSprite(uint8 *sprData, uint16 sprX, uint16 sprY, uint16 sprWidth, uint16 sprHeight, uint16 sprPitch);
void drawPsxFullShrinkedSprite(uint8 *sprData, uint16 sprX, uint16 sprY, uint16 sprWidth, uint16 sprHeight, uint16 sprPitch);
- uint8* psxBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres);
- uint8* psxShrinkedBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres);
+ uint8 *psxBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres);
+ uint8 *psxShrinkedBackgroundToIndexed(uint8 *psxBackground, uint32 bakXres, uint32 bakYres);
void fetchPsxParallaxSize(uint8 *psxParallax, uint16 *paraSizeX, uint16 *paraSizeY);
void drawPsxParallax(uint8 *psxParallax, uint16 paraScrlX, uint16 scrnScrlX, uint16 scrnWidth);
void decompressRLE7(uint8 *src, uint32 compSize, uint8 *dest);
@@ -163,7 +163,7 @@ private:
uint8 _fadingStep;
int8 _fadingDirection; // 1 for fade up, -1 for fade down
bool _isBlack; // if the logic already faded down the palette, this is set to show the
- // mainloop that no further fading is necessary.
+ // mainloop that no further fading is necessary.
};
} // End of namespace Sword1
diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp
index 677a9869ce..b74cd8c393 100644
--- a/engines/sword1/sound.cpp
+++ b/engines/sword1/sound.cpp
@@ -124,10 +124,10 @@ void Sound::checkSpeechFileEndianness() {
size = 2000;
else
size /= 2;
- int16 prev_be_value = (int16)SWAP_BYTES_16(*((uint16*)(data)));
+ int16 prev_be_value = (int16)SWAP_BYTES_16(*((uint16 *)(data)));
for (uint32 i = 1; i < size; ++i) {
- le_diff_sum += fabs((double)(data[i] - data[i-1]));
- int16 be_value = (int16)SWAP_BYTES_16(*((uint16*)(data + i)));
+ le_diff_sum += fabs((double)(data[i] - data[i - 1]));
+ int16 be_value = (int16)SWAP_BYTES_16(*((uint16 *)(data + i)));
be_diff_sum += fabs((double)(be_value - prev_be_value));
prev_be_value = be_value;
}
@@ -187,7 +187,7 @@ void Sound::engine() {
} else {
if (!_mixer->isSoundHandleActive(_fxQueue[cnt2].handle)) { // sound finished
_resMan->resClose(_fxList[_fxQueue[cnt2].id].sampleId);
- if (cnt2 != _endOfQueue-1)
+ if (cnt2 != _endOfQueue - 1)
_fxQueue[cnt2] = _fxQueue[_endOfQueue - 1];
_endOfQueue--;
}
@@ -201,8 +201,8 @@ void Sound::fnStopFx(int32 fxNo) {
if (_fxQueue[cnt].id == (uint32)fxNo) {
if (!_fxQueue[cnt].delay) // sound was started
_resMan->resClose(_fxList[_fxQueue[cnt].id].sampleId);
- if (cnt != _endOfQueue-1)
- _fxQueue[cnt] = _fxQueue[_endOfQueue-1];
+ if (cnt != _endOfQueue - 1)
+ _fxQueue[cnt] = _fxQueue[_endOfQueue - 1];
_endOfQueue--;
return;
}
@@ -243,36 +243,36 @@ void Sound::quitScreen() {
}
void Sound::playSample(QueueElement *elem) {
- uint8 *sampleData = (uint8*)_resMan->fetchRes(_fxList[elem->id].sampleId);
+ uint8 *sampleData = (uint8 *)_resMan->fetchRes(_fxList[elem->id].sampleId);
for (uint16 cnt = 0; cnt < MAX_ROOMS_PER_FX; cnt++) {
if (_fxList[elem->id].roomVolList[cnt].roomNo) {
if ((_fxList[elem->id].roomVolList[cnt].roomNo == (int)Logic::_scriptVars[SCREEN]) ||
- (_fxList[elem->id].roomVolList[cnt].roomNo == -1)) {
-
- uint8 volL = (_fxList[elem->id].roomVolList[cnt].leftVol * 10 * _sfxVolL) / 255;
- uint8 volR = (_fxList[elem->id].roomVolList[cnt].rightVol * 10 * _sfxVolR) / 255;
- int8 pan = (volR - volL) / 2;
- uint8 volume = (volR + volL) / 2;
-
- if (SwordEngine::isPsx()) {
- // We ignore FX_LOOP as XA has its own looping mechanism
- uint32 size = READ_LE_UINT32(sampleData);
- Audio::AudioStream *audStream = Audio::makeXAStream(new Common::MemoryReadStream(sampleData + 4, size-4), 11025);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan);
- } else {
- uint32 size = READ_LE_UINT32(sampleData + 0x28);
- uint8 flags;
- if (READ_LE_UINT16(sampleData + 0x22) == 16)
- flags = Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
- else
- flags = Audio::FLAG_UNSIGNED;
- if (READ_LE_UINT16(sampleData + 0x16) == 2)
- flags |= Audio::FLAG_STEREO;
- Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
- Audio::makeRawStream(sampleData + 0x2C, size, 11025, flags, DisposeAfterUse::NO),
- (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &elem->handle, stream, elem->id, volume, pan);
- }
+ (_fxList[elem->id].roomVolList[cnt].roomNo == -1)) {
+
+ uint8 volL = (_fxList[elem->id].roomVolList[cnt].leftVol * 10 * _sfxVolL) / 255;
+ uint8 volR = (_fxList[elem->id].roomVolList[cnt].rightVol * 10 * _sfxVolR) / 255;
+ int8 pan = (volR - volL) / 2;
+ uint8 volume = (volR + volL) / 2;
+
+ if (SwordEngine::isPsx()) {
+ // We ignore FX_LOOP as XA has its own looping mechanism
+ uint32 size = READ_LE_UINT32(sampleData);
+ Audio::AudioStream *audStream = Audio::makeXAStream(new Common::MemoryReadStream(sampleData + 4, size - 4), 11025);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &elem->handle, audStream, elem->id, volume, pan);
+ } else {
+ uint32 size = READ_LE_UINT32(sampleData + 0x28);
+ uint8 flags;
+ if (READ_LE_UINT16(sampleData + 0x22) == 16)
+ flags = Audio::FLAG_16BITS | Audio::FLAG_LITTLE_ENDIAN;
+ else
+ flags = Audio::FLAG_UNSIGNED;
+ if (READ_LE_UINT16(sampleData + 0x16) == 2)
+ flags |= Audio::FLAG_STEREO;
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawStream(sampleData + 0x2C, size, 11025, flags, DisposeAfterUse::NO),
+ (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &elem->handle, stream, elem->id, volume, pan);
+ }
}
} else
break;
@@ -294,7 +294,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
uint16 i;
if (!file.open("speech.lis")) {
- warning ("Could not open speech.lis");
+ warning("Could not open speech.lis");
return false;
}
@@ -306,12 +306,12 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
file.close();
if (locIndex == 0xFFFFFFFF) {
- warning ("Could not find room %d in speech.lis", roomNo);
+ warning("Could not find room %d in speech.lis", roomNo);
return false;
}
if (!file.open("speech.inf")) {
- warning ("Could not open speech.inf");
+ warning("Could not open speech.inf");
return false;
}
@@ -333,7 +333,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
}
if (locIndex == 0xFFFFFFFF) {
- warning ("Could not find local number %d in room %d in speech.inf", roomNo, localNo);
+ warning("Could not find local number %d in room %d in speech.inf", roomNo, localNo);
return false;
}
@@ -421,7 +421,7 @@ bool Sound::startSpeech(uint16 roomNo, uint16 localNo) {
}
int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
- uint8 *fBuf = (uint8*)malloc(cSize);
+ uint8 *fBuf = (uint8 *)malloc(cSize);
_cowFile.seek(index);
_cowFile.read(fBuf, cSize);
uint32 headerPos = 0;
@@ -456,7 +456,7 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
resSize >>= 1;
} else {
resSize = 0;
- srcData = (int16*)fBuf;
+ srcData = (int16 *)fBuf;
srcPos = headerPos >> 1;
while (srcPos < cSize) {
length = (int16)READ_LE_UINT16(srcData + srcPos);
@@ -472,10 +472,10 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
}
}
assert(!(headerPos & 1));
- srcData = (int16*)fBuf;
+ srcData = (int16 *)fBuf;
srcPos = headerPos >> 1;
uint32 dstPos = 0;
- int16 *dstData = (int16*)malloc(resSize * 2);
+ int16 *dstData = (int16 *)malloc(resSize * 2);
int32 samplesLeft = resSize;
while (srcPos < cSize && samplesLeft > 0) {
length = (int16)(_bigEndianSpeech ? READ_BE_UINT16(srcData + srcPos) : READ_LE_UINT16(srcData + srcPos));
@@ -486,7 +486,7 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
length = samplesLeft;
int16 value;
if (_bigEndianSpeech) {
- value = (int16)SWAP_BYTES_16(*((uint16*)(srcData + srcPos)));
+ value = (int16)SWAP_BYTES_16(*((uint16 *)(srcData + srcPos)));
} else {
value = srcData[srcPos];
}
@@ -498,7 +498,7 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
length = samplesLeft;
if (_bigEndianSpeech) {
for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
- dstData[dstPos++] = (int16)SWAP_BYTES_16(*((uint16*)(srcData + (srcPos++))));
+ dstData[dstPos++] = (int16)SWAP_BYTES_16(*((uint16 *)(srcData + (srcPos++))));
} else {
memcpy(dstData + dstPos, srcData + srcPos, length * 2);
dstPos += length;
@@ -511,7 +511,7 @@ int16 *Sound::uncompressSpeech(uint32 index, uint32 cSize, uint32 *size) {
memset(dstData + dstPos, 0, samplesLeft * 2);
}
if (_cowMode == CowDemo) // demo has wave output size embedded in the compressed data
- *(uint32*)dstData = 0;
+ *(uint32 *)dstData = 0;
free(fBuf);
*size = resSize * 2;
calcWaveVolume(dstData, resSize);
@@ -607,7 +607,7 @@ void Sound::initCowSystem() {
_currentCowFile = SwordEngine::_systemVars.currentCD;
if (!_cowFile.isOpen()) {
if (!_cowFile.open("speech.dat"))
- error ("Could not open speech.dat");
+ error("Could not open speech.dat");
_cowMode = CowPSX;
}
}
@@ -626,7 +626,7 @@ void Sound::initCowSystem() {
// Get data from the external table file
Common::File tableFile;
if (!tableFile.open("speech.tab"))
- error ("Could not open speech.tab");
+ error("Could not open speech.tab");
_cowHeaderSize = tableFile.size();
_cowHeader = (uint32 *)malloc(_cowHeaderSize);
if (_cowHeaderSize & 3)
@@ -635,7 +635,7 @@ void Sound::initCowSystem() {
_cowHeader[cnt] = tableFile.readUint32LE();
} else {
_cowHeaderSize = _cowFile.readUint32LE();
- _cowHeader = (uint32*)malloc(_cowHeaderSize);
+ _cowHeader = (uint32 *)malloc(_cowHeaderSize);
if (_cowHeaderSize & 3)
error("Unexpected cow header size %d", _cowHeaderSize);
for (uint32 cnt = 0; cnt < (_cowHeaderSize / 4) - 1; cnt++)
diff --git a/engines/sword1/sound.h b/engines/sword1/sound.h
index a6313f85eb..112ae5b6aa 100644
--- a/engines/sword1/sound.h
+++ b/engines/sword1/sound.h
@@ -36,9 +36,9 @@ class Mixer;
namespace Sword1 {
-#define TOTAL_FX_PER_ROOM 7 // total loop & random fx per room (see fx_list.c)
-#define MAX_ROOMS_PER_FX 7 // max no. of rooms in the fx's room,vol list
-#define MAX_FXQ_LENGTH 32 // max length of sound queue - ie. max number of fx that can be stored up/playing together
+#define TOTAL_FX_PER_ROOM 7 // total loop & random fx per room (see fx_list.c)
+#define MAX_ROOMS_PER_FX 7 // max no. of rooms in the fx's room,vol list
+#define MAX_FXQ_LENGTH 32 // max length of sound queue - ie. max number of fx that can be stored up/playing together
#define FX_SPOT 1
#define FX_LOOP 2
@@ -105,15 +105,15 @@ private:
bool _waveVolume[WAVE_VOL_TAB_LENGTH];
uint16 _waveVolPos;
Common::File _cowFile;
- uint32 *_cowHeader;
- uint32 _cowHeaderSize;
- uint8 _currentCowFile;
- CowMode _cowMode;
+ uint32 *_cowHeader;
+ uint32 _cowHeaderSize;
+ uint8 _currentCowFile;
+ CowMode _cowMode;
Audio::SoundHandle _speechHandle, _fxHandle;
Common::RandomSource _rnd;
QueueElement _fxQueue[MAX_FXQ_LENGTH];
- uint8 _endOfQueue;
+ uint8 _endOfQueue;
Audio::Mixer *_mixer;
ResMan *_resMan;
bool _bigEndianSpeech;
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index 23dff4dec2..6a3f215c4b 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -48,9 +48,9 @@ SystemVars SwordEngine::_systemVars;
SwordEngine::SwordEngine(OSystem *syst)
: Engine(syst) {
- if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1demo") ||
- !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1psxdemo") ||
- !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo"))
+ if (!scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1demo") ||
+ !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1psxdemo") ||
+ !scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo"))
_features = GF_DEMO;
else
_features = 0;
@@ -85,11 +85,11 @@ Common::Error SwordEngine::init() {
initGraphics(640, 480, true);
- if ( 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1mac") ||
- 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo") )
+ if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1mac") ||
+ 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1macdemo"))
_systemVars.platform = Common::kPlatformMacintosh;
- else if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1psx") ||
- 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1psxdemo") )
+ else if (0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1psx") ||
+ 0 == scumm_stricmp(ConfMan.get("gameid").c_str(), "sword1psxdemo"))
_systemVars.platform = Common::kPlatformPSX;
else
_systemVars.platform = Common::kPlatformWindows;
@@ -279,18 +279,18 @@ const CdFile SwordEngine::_pcCdFileList[] = {
{ "text.clu", FLAG_CD1 | FLAG_DEMO },
{ "cows.mad", FLAG_DEMO },
{ "speech1.clu", FLAG_SPEECH1 },
- { "speech2.clu", FLAG_SPEECH2 }
+ { "speech2.clu", FLAG_SPEECH2 }
#ifdef USE_FLAC
- ,{ "speech1.clf", FLAG_SPEECH1 },
- { "speech2.clf", FLAG_SPEECH2 }
+ , { "speech1.clf", FLAG_SPEECH1 },
+ { "speech2.clf", FLAG_SPEECH2 }
#endif
#ifdef USE_VORBIS
- ,{ "speech1.clv", FLAG_SPEECH1 },
- { "speech2.clv", FLAG_SPEECH2 }
+ , { "speech1.clv", FLAG_SPEECH1 },
+ { "speech2.clv", FLAG_SPEECH2 }
#endif
#ifdef USE_MAD
- ,{ "speech1.cl3", FLAG_SPEECH1 },
- { "speech2.cl3", FLAG_SPEECH2 }
+ , { "speech1.cl3", FLAG_SPEECH1 },
+ { "speech2.cl3", FLAG_SPEECH2 }
#endif
};
@@ -311,18 +311,18 @@ const CdFile SwordEngine::_macCdFileList[] = {
{ "swordres.rif", FLAG_CD1 | FLAG_DEMO | FLAG_IMMED },
{ "text.clm", FLAG_CD1 | FLAG_DEMO },
{ "speech1.clu", FLAG_SPEECH1 },
- { "speech2.clu", FLAG_SPEECH2 }
+ { "speech2.clu", FLAG_SPEECH2 }
#ifdef USE_FLAC
,{ "speech1.clf", FLAG_SPEECH1 },
- { "speech2.clf", FLAG_SPEECH2 }
+ { "speech2.clf", FLAG_SPEECH2 }
#endif
#ifdef USE_VORBIS
,{ "speech1.clv", FLAG_SPEECH1 },
- { "speech2.clv", FLAG_SPEECH2 }
+ { "speech2.clv", FLAG_SPEECH2 }
#endif
#ifdef USE_MAD
,{ "speech1.cl3", FLAG_SPEECH1 },
- { "speech2.cl3", FLAG_SPEECH2 }
+ { "speech2.cl3", FLAG_SPEECH2 }
#endif
};
@@ -364,7 +364,7 @@ void SwordEngine::showFileErrorMsg(uint8 type, bool *fileExists) {
int msgId = (type == TYPE_IMMED) ? 0 : 2;
if (missCnt == 1) {
sprintf(msg, errorMsgs[msgId],
- _macCdFileList[missNum].name, (_macCdFileList[missNum].flags & FLAG_CD2) ? 2 : 1);
+ _macCdFileList[missNum].name, (_macCdFileList[missNum].flags & FLAG_CD2) ? 2 : 1);
warning("%s", msg);
} else {
char *pos = msg + sprintf(msg, errorMsgs[msgId + 1], missCnt);
@@ -407,7 +407,7 @@ void SwordEngine::showFileErrorMsg(uint8 type, bool *fileExists) {
int msgId = (type == TYPE_IMMED) ? 0 : 2;
if (missCnt == 1) {
sprintf(msg, errorMsgs[msgId],
- _pcCdFileList[missNum].name, (_pcCdFileList[missNum].flags & FLAG_CD2) ? 2 : 1);
+ _pcCdFileList[missNum].name, (_pcCdFileList[missNum].flags & FLAG_CD2) ? 2 : 1);
warning("%s", msg);
} else {
char *pos = msg + sprintf(msg, errorMsgs[msgId + 1], missCnt);
@@ -454,9 +454,9 @@ void SwordEngine::checkCdFiles() { // check if we're running from cd, hdd or wha
if (Common::File::exists(_psxCdFileList[fcnt].name)) {
fileExists[fcnt] = true;
flagsToBool(foundTypes, _psxCdFileList[fcnt].flags);
- if (!(_psxCdFileList[fcnt].flags & FLAG_DEMO))
+ if (!(_psxCdFileList[fcnt].flags & FLAG_DEMO))
isFullVersion = true;
- cd2FilesFound = true;
+ cd2FilesFound = true;
} else {
flagsToBool(missingTypes, _psxCdFileList[fcnt].flags);
fileExists[fcnt] = false;
@@ -486,9 +486,9 @@ void SwordEngine::checkCdFiles() { // check if we're running from cd, hdd or wha
if (foundTypes[TYPE_SPEECH2]) // same for speech2
missingTypes[TYPE_SPEECH2] = false;
- if (isFullVersion) // if this is the full version...
+ if (isFullVersion) // if this is the full version...
missingTypes[TYPE_DEMO] = false; // then we don't need demo files...
- else // and vice versa
+ else // and vice versa
missingTypes[TYPE_SPEECH1] = missingTypes[TYPE_SPEECH2] = missingTypes[TYPE_CD1] = missingTypes[TYPE_CD2] = false;
bool somethingMissing = false;
@@ -526,13 +526,13 @@ void SwordEngine::checkCdFiles() { // check if we're running from cd, hdd or wha
showFileErrorMsg(TYPE_IMMED, fileExists);
} else if ((!missingTypes[TYPE_CD1]) && !cd2FilesFound) {
/* we have all the data from cd one, but not a single one from CD2.
- I'm not sure how we should handle this, for now I'll just assume that the
- user has set up the extrapath correctly and copied the necessary files to HDD.
- A quite optimistic assumption, I'd say. Maybe we should change this for the release
- to warn the user? */
+ I'm not sure how we should handle this, for now I'll just assume that the
+ user has set up the extrapath correctly and copied the necessary files to HDD.
+ A quite optimistic assumption, I'd say. Maybe we should change this for the release
+ to warn the user? */
warning("CD2 data files not found. I hope you know what you're doing and that\n"
- "you have set up the extrapath and additional data correctly.\n"
- "If you didn't, you should better read the ScummVM readme file");
+ "you have set up the extrapath and additional data correctly.\n"
+ "If you didn't, you should better read the ScummVM readme file");
_systemVars.runningFromCd = true;
_systemVars.playSpeech = true;
} else if (missingTypes[TYPE_CD1] || missingTypes[TYPE_CD2]) {
@@ -542,13 +542,13 @@ void SwordEngine::checkCdFiles() { // check if we're running from cd, hdd or wha
// not so important, but there won't be any voices
if (missingTypes[TYPE_SPEECH1] && missingTypes[TYPE_SPEECH2])
warning("Unable to find the speech files. The game will work, but you won't hear any voice output.\n"
- "Please copy the SPEECH.CLU files from both CDs and rename them to SPEECH1.CLU and SPEECH2.CLU,\n"
- "corresponding to the CD number.\n"
- "Please read the ScummVM Readme file for more information");
+ "Please copy the SPEECH.CLU files from both CDs and rename them to SPEECH1.CLU and SPEECH2.CLU,\n"
+ "corresponding to the CD number.\n"
+ "Please read the ScummVM Readme file for more information");
else
warning("Unable to find the speech file from CD %d.\n"
- "You won't hear any voice output in that part of the game.\n"
- "Please read the ScummVM Readme file for more information", missingTypes[TYPE_SPEECH1] ? 1 : 2);
+ "You won't hear any voice output in that part of the game.\n"
+ "Please read the ScummVM Readme file for more information", missingTypes[TYPE_SPEECH1] ? 1 : 2);
} else if (missingTypes[TYPE_DEMO]) {
// for the demo version, we simply expect to have all files immediately
showFileErrorMsg(TYPE_IMMED, fileExists);
@@ -618,9 +618,9 @@ void SwordEngine::checkCd() {
_music->startMusic(0, 0); //
_sound->closeCowSystem(); // close music and sound files before changing CDs
_systemVars.currentCD = needCd; // askForCd will ask the player to insert _systemVars.currentCd,
- _control->askForCd(); // so it has to be updated before calling it.
+ _control->askForCd(); // so it has to be updated before calling it.
}
- } else { // we're running from HDD, we don't have to care about music files and Sound will take care of
+ } else { // we're running from HDD, we don't have to care about music files and Sound will take care of
if (needCd) // switching sound.clu files on Sound::newScreen by itself, so there's nothing to be done.
_systemVars.currentCD = needCd;
else if (_systemVars.currentCD == 0)
@@ -673,7 +673,7 @@ uint8 SwordEngine::mainLoop() {
// The control panel is triggered by F5 or ESC.
else if (((_keyPressed.keycode == Common::KEYCODE_F5 || _keyPressed.keycode == Common::KEYCODE_ESCAPE)
- && (Logic::_scriptVars[MOUSE_STATUS] & 1)) || (_systemVars.controlPanelMode)) {
+ && (Logic::_scriptVars[MOUSE_STATUS] & 1)) || (_systemVars.controlPanelMode)) {
retCode = _control->runPanel();
if (retCode == CONTROL_NOTHING_DONE)
_screen->fullRefresh();
diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h
index 2d6db21d19..e973c12754 100644
--- a/engines/sword1/sword1.h
+++ b/engines/sword1/sword1.h
@@ -63,16 +63,16 @@ class Music;
class Control;
struct SystemVars {
- bool runningFromCd;
- uint32 currentCD; // starts at zero, then either 1 or 2 depending on section being played
- uint32 justRestoredGame; // see main() in sword.c & New_screen() in gtm_core.c
-
- uint8 controlPanelMode; // 1 death screen version of the control panel, 2 = successful end of game, 3 = force restart
- bool forceRestart;
- bool wantFade; // when true => fade during scene change, else cut.
- uint8 playSpeech;
- uint8 showText;
- uint8 language;
+ bool runningFromCd;
+ uint32 currentCD; // starts at zero, then either 1 or 2 depending on section being played
+ uint32 justRestoredGame; // see main() in sword.c & New_screen() in gtm_core.c
+
+ uint8 controlPanelMode; // 1 death screen version of the control panel, 2 = successful end of game, 3 = force restart
+ bool forceRestart;
+ bool wantFade; // when true => fade during scene change, else cut.
+ uint8 playSpeech;
+ uint8 showText;
+ uint8 language;
bool isDemo;
Common::Platform platform;
};
@@ -131,18 +131,18 @@ private:
uint16 _mouseState;
Common::KeyState _keyPressed;
- ResMan *_resMan;
- ObjectMan *_objectMan;
- Screen *_screen;
- Mouse *_mouse;
- Logic *_logic;
- Sound *_sound;
- Menu *_menu;
- Music *_music;
- Control *_control;
+ ResMan *_resMan;
+ ObjectMan *_objectMan;
+ Screen *_screen;
+ Mouse *_mouse;
+ Logic *_logic;
+ Sound *_sound;
+ Menu *_menu;
+ Music *_music;
+ Control *_control;
static const uint8 _cdList[TOTAL_SECTIONS];
- static const CdFile _pcCdFileList[];
- static const CdFile _macCdFileList[];
+ static const CdFile _pcCdFileList[];
+ static const CdFile _macCdFileList[];
static const CdFile _psxCdFileList[];
};
diff --git a/engines/sword1/sworddefs.h b/engines/sword1/sworddefs.h
index 15736dcae0..db4146f37e 100644
--- a/engines/sword1/sworddefs.h
+++ b/engines/sword1/sworddefs.h
@@ -29,13 +29,13 @@ namespace Sword1 {
#define LOOPED 1
-#define FRAME_RATE 12 // number of frames per second (max rate)
-#define SCREEN_WIDTH 640
-#define SCREEN_DEPTH 400
-#define SCREEN_LEFT_EDGE 128
-#define SCREEN_RIGHT_EDGE (128+SCREEN_WIDTH-1)
-#define SCREEN_TOP_EDGE 128
-#define SCREEN_BOTTOM_EDGE (128+SCREEN_DEPTH-1)
+#define FRAME_RATE 12 // number of frames per second (max rate)
+#define SCREEN_WIDTH 640
+#define SCREEN_DEPTH 400
+#define SCREEN_LEFT_EDGE 128
+#define SCREEN_RIGHT_EDGE (128+SCREEN_WIDTH-1)
+#define SCREEN_TOP_EDGE 128
+#define SCREEN_BOTTOM_EDGE (128+SCREEN_DEPTH-1)
#define TYPE_FLOOR 1
#define TYPE_MOUSE 2
#define TYPE_SPRITE 3
@@ -81,22 +81,22 @@ namespace Sword1 {
#define TOTAL_subjects (375-256+1)
#define BASE_SUBJECT 256
-#define TOTAL_SECTIONS 150 //number of sections, rooms + mega sections
-#define TOTAL_ROOMS 100 //total number of rooms
-#define ITM_PER_SEC 0x10000 //65536 items per section -> was originally called "SIZE"
-#define ITM_ID 0xFFFF //& with this -> originally "NuSIZE"
+#define TOTAL_SECTIONS 150 //number of sections, rooms + mega sections
+#define TOTAL_ROOMS 100 //total number of rooms
+#define ITM_PER_SEC 0x10000 //65536 items per section -> was originally called "SIZE"
+#define ITM_ID 0xFFFF //& with this -> originally "NuSIZE"
-#define MAX_text_obs 2 //text compacts
-#define TEXT_sect 149 //text compacts exist in section 149, probably after all the megas
+#define MAX_text_obs 2 //text compacts
+#define TEXT_sect 149 //text compacts exist in section 149, probably after all the megas
-#include "common/pack-start.h" // START STRUCT PACKING
+#include "common/pack-start.h" // START STRUCT PACKING
struct Header {
char type[6];
uint16 version;
- uint32 comp_length;
- char compression[4];
- uint32 decomp_length;
+ uint32 comp_length;
+ char compression[4];
+ uint32 decomp_length;
} PACKED_STRUCT;
struct FrameHeader {
@@ -132,7 +132,7 @@ struct WalkGridHeader {
int32 numNodes;
} PACKED_STRUCT;
-#include "common/pack-end.h" // END STRUCT PACKING
+#include "common/pack-end.h" // END STRUCT PACKING
enum fileTypes {
TYPE_CD1 = 0,
@@ -144,12 +144,12 @@ enum fileTypes {
};
enum fileFlags {
- FLAG_CD1 = (1 << TYPE_CD1), // this file is on cd1
- FLAG_CD2 = (1 << TYPE_CD2), // this file is on cd2
- FLAG_DEMO = (1 << TYPE_DEMO), // file for the demo version
- FLAG_IMMED = (1 << TYPE_IMMED), // this file is needed immediately, game won't start without it
- FLAG_SPEECH1 = (1 << TYPE_SPEECH1),
- FLAG_SPEECH2 = (1 << TYPE_SPEECH2)
+ FLAG_CD1 = (1 << TYPE_CD1), // this file is on cd1
+ FLAG_CD2 = (1 << TYPE_CD2), // this file is on cd2
+ FLAG_DEMO = (1 << TYPE_DEMO), // file for the demo version
+ FLAG_IMMED = (1 << TYPE_IMMED), // this file is needed immediately, game won't start without it
+ FLAG_SPEECH1 = (1 << TYPE_SPEECH1),
+ FLAG_SPEECH2 = (1 << TYPE_SPEECH2)
};
struct CdFile {
@@ -167,29 +167,29 @@ enum Language {
BS1_PORT
};
-#define SAM 2162689
-#define PLAYER 8388608
-#define GEORGE 8388608
-#define NICO 8454144
-#define BENOIR 8585216
-#define ROSSO 8716288
-#define DUANE 8781824
-#define MOUE 9502720
-#define ALBERT 9568256
+#define SAM 2162689
+#define PLAYER 8388608
+#define GEORGE 8388608
+#define NICO 8454144
+#define BENOIR 8585216
+#define ROSSO 8716288
+#define DUANE 8781824
+#define MOUE 9502720
+#define ALBERT 9568256
-#define STAND 0
-#define UP 0
-#define UP_RIGHT 1
-#define U_R 1
-#define RIGHT 2
-#define DOWN_RIGHT 3
-#define D_R 3
-#define DOWN 4
-#define DOWN_LEFT 5
-#define D_L 5
-#define LEFT 6
-#define UP_LEFT 7
-#define U_L 7
+#define STAND 0
+#define UP 0
+#define UP_RIGHT 1
+#define U_R 1
+#define RIGHT 2
+#define DOWN_RIGHT 3
+#define D_R 3
+#define DOWN 4
+#define DOWN_LEFT 5
+#define D_L 5
+#define LEFT 6
+#define UP_LEFT 7
+#define U_L 7
#define BEER_TOWEL 3
#define HOTEL_KEY 4
@@ -373,10 +373,10 @@ enum Language {
#define IT_MINUS 12
#define IT_AND 13
#define IT_OR 14
-#define IT_GTE 15 // >=
-#define IT_LTE 16 // <=
-#define IT_DEVIDE 17 // <=
-#define IT_GT 18 // >
+#define IT_GTE 15 // >=
+#define IT_LTE 16 // <=
+#define IT_DEVIDE 17 // <=
+#define IT_GT 18 // >
#define IT_SCRIPTEND 20
#define IT_POPVAR 21
diff --git a/engines/sword1/text.cpp b/engines/sword1/text.cpp
index 2d4b07020f..3bd2fdb2e6 100644
--- a/engines/sword1/text.cpp
+++ b/engines/sword1/text.cpp
@@ -35,7 +35,7 @@ namespace Sword1 {
#define OVERLAP 3
#define SPACE ' '
-#define MAX_LINES 30
+#define MAX_LINES 30
Text::Text(ObjectMan *pObjMan, ResMan *pResMan, bool czechVersion) {
@@ -43,7 +43,7 @@ Text::Text(ObjectMan *pObjMan, ResMan *pResMan, bool czechVersion) {
_resMan = pResMan;
_textCount = 0;
_fontId = (czechVersion) ? CZECH_GAME_FONT : GAME_FONT;
- _font = (uint8*)_resMan->openFetchRes(_fontId);
+ _font = (uint8 *)_resMan->openFetchRes(_fontId);
_joinWidth = charWidth(SPACE) - 2 * OVERLAP;
_charHeight = _resMan->getUint16(_resMan->fetchFrame(_font, 0)->height); // all chars have the same height
@@ -86,16 +86,16 @@ void Text::makeTextSprite(uint8 slot, const uint8 *text, uint16 maxWidth, uint8
uint16 sprHeight = _charHeight * numLines;
uint32 sprSize = sprWidth * sprHeight;
assert(!_textBlocks[slot]); // if this triggers, the speechDriver failed to call Text::releaseText.
- _textBlocks[slot] = (FrameHeader*)malloc(sprSize + sizeof(FrameHeader));
+ _textBlocks[slot] = (FrameHeader *)malloc(sprSize + sizeof(FrameHeader));
memcpy(_textBlocks[slot]->runTimeComp, "Nu ", 4);
- _textBlocks[slot]->compSize = 0;
- _textBlocks[slot]->width = _resMan->toUint16(sprWidth);
- _textBlocks[slot]->height = _resMan->toUint16(sprHeight);
- _textBlocks[slot]->offsetX = 0;
- _textBlocks[slot]->offsetY = 0;
+ _textBlocks[slot]->compSize = 0;
+ _textBlocks[slot]->width = _resMan->toUint16(sprWidth);
+ _textBlocks[slot]->height = _resMan->toUint16(sprHeight);
+ _textBlocks[slot]->offsetX = 0;
+ _textBlocks[slot]->offsetY = 0;
- uint8 *linePtr = ((uint8*)_textBlocks[slot]) + sizeof(FrameHeader);
+ uint8 *linePtr = ((uint8 *)_textBlocks[slot]) + sizeof(FrameHeader);
memset(linePtr, NO_COL, sprSize);
for (lineCnt = 0; lineCnt < numLines; lineCnt++) {
uint8 *sprPtr = linePtr + (sprWidth - lines[lineCnt].width) / 2; // center the text
@@ -132,7 +132,7 @@ uint16 Text::analyzeSentence(const uint8 *text, uint16 maxWidth, LineInfo *line)
text++;
wordWidth += OVERLAP; // no overlap on final letter of word!
- if (firstWord) { // first word on first line, so no separating SPACE needed
+ if (firstWord) { // first word on first line, so no separating SPACE needed
line[0].width = wordWidth;
line[0].length = wordLength;
firstWord = false;
@@ -144,7 +144,7 @@ uint16 Text::analyzeSentence(const uint8 *text, uint16 maxWidth, LineInfo *line)
if (line[lineNo].width + spaceNeeded <= maxWidth) {
line[lineNo].width += spaceNeeded;
line[lineNo].length += 1 + wordLength; // NB. space+word characters
- } else { // put word (without separating SPACE) at start of next line
+ } else { // put word (without separating SPACE) at start of next line
lineNo++;
assert(lineNo < MAX_LINES);
line[lineNo].width = wordWidth;
@@ -152,21 +152,21 @@ uint16 Text::analyzeSentence(const uint8 *text, uint16 maxWidth, LineInfo *line)
}
}
}
- return lineNo+1; // return no of lines
+ return lineNo + 1; // return no of lines
}
uint16 Text::copyChar(uint8 ch, uint8 *sprPtr, uint16 sprWidth, uint8 pen) {
FrameHeader *chFrame = _resMan->fetchFrame(_font, ch - SPACE);
- uint8 *chData = ((uint8*)chFrame) + sizeof(FrameHeader);
+ uint8 *chData = ((uint8 *)chFrame) + sizeof(FrameHeader);
uint8 *dest = sprPtr;
uint8 *decBuf = NULL;
uint8 *decChr;
uint16 frameHeight = 0;
if (SwordEngine::isPsx()) {
- frameHeight = _resMan->getUint16(chFrame->height)/2;
+ frameHeight = _resMan->getUint16(chFrame->height) / 2;
if (_fontId == CZECH_GAME_FONT) { //Czech game fonts are compressed
- decBuf = (uint8*) malloc((_resMan->getUint16(chFrame->width))*(_resMan->getUint16(chFrame->height)/2));
+ decBuf = (uint8 *)malloc((_resMan->getUint16(chFrame->width)) * (_resMan->getUint16(chFrame->height) / 2));
Screen::decompressHIF(chData, decBuf);
decChr = decBuf;
} else //Normal game fonts are not compressed
diff --git a/engines/sword1/text.h b/engines/sword1/text.h
index 2224fbcac5..4dcb9e26a7 100644
--- a/engines/sword1/text.h
+++ b/engines/sword1/text.h
@@ -30,17 +30,17 @@ namespace Sword1 {
#define MAX_TEXT_OBS 3
-#define BORDER_COL 200
+#define BORDER_COL 200
#define BORDER_COL_PSX 199
-#define LETTER_COL 193
-#define NO_COL 0 // sprite background - 0 for transparency
+#define LETTER_COL 193
+#define NO_COL 0 // sprite background - 0 for transparency
class ObjectMan;
class ResMan;
struct LineInfo {
- uint16 width; // width of line in pixels
- uint16 length; // length of line in characters
+ uint16 width; // width of line in pixels
+ uint16 length; // length of line in characters
};
class Text {