From b179e8f6ec6d24f6b46a1b9e14e46ad777374d94 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Fri, 19 Dec 2003 14:07:12 +0000 Subject: Whitespace changes svn-id: r11760 --- sword1/debug.h | 2 +- sword1/eventman.cpp | 2 +- sword1/logic.cpp | 20 +- sword1/memman.cpp | 2 +- sword1/mouse.cpp | 4 +- sword1/mouse.h | 4 +- sword1/objectman.h | 2 +- sword1/resman.cpp | 4 +- sword1/resman.h | 2 +- sword1/router.cpp | 1072 +++++++++++++++++++++++++-------------------------- sword1/router.h | 2 +- sword1/screen.cpp | 128 +++--- sword1/screen.h | 2 +- sword1/sound.cpp | 6 +- sword1/sword1.cpp | 4 +- sword1/sword1.h | 2 +- sword1/sworddefs.h | 2 +- 17 files changed, 629 insertions(+), 631 deletions(-) (limited to 'sword1') diff --git a/sword1/debug.h b/sword1/debug.h index ee902d83b3..e8347ee74d 100644 --- a/sword1/debug.h +++ b/sword1/debug.h @@ -26,7 +26,7 @@ class SwordDebug { public: - static void interpretScript(uint32 id, uint32 level, uint32 script, uint32 pc); + static void interpretScript(uint32 id, uint32 level, uint32 script, uint32 pc); static void callMCode(uint32 mcodeNum, uint32 paramCount, int32 a, int32 b, int32 c, int32 d, int32 e, int32 f); private: diff --git a/sword1/eventman.cpp b/sword1/eventman.cpp index 8f7692d93e..37412bcc02 100644 --- a/sword1/eventman.cpp +++ b/sword1/eventman.cpp @@ -65,7 +65,7 @@ int EventManager::fnCheckForEvent(BsObject *cpt, int32 id, int32 pause) { if (pause) { cpt->o_pause = pause; cpt->o_logic = LOGIC_pause_for_event; - return SCRIPT_STOP; + return SCRIPT_STOP; } for (uint8 objCnt = 0; objCnt < O_TOTAL_EVENTS; objCnt++) { diff --git a/sword1/logic.cpp b/sword1/logic.cpp index 8b4e0d98ca..508413417f 100644 --- a/sword1/logic.cpp +++ b/sword1/logic.cpp @@ -184,7 +184,7 @@ void SwordLogic::processLogic(BsObject *compact, uint32 id) { logicRet=1; break; case LOGIC_bookmark: - memcpy(&(compact->o_tree.o_script_level), &(compact->o_bookmark.o_script_level), sizeof(ScriptTree)); + memcpy(&(compact->o_tree.o_script_level), &(compact->o_bookmark.o_script_level), sizeof(ScriptTree)); compact->o_logic = LOGIC_script; logicRet = 1; break; @@ -395,7 +395,7 @@ int SwordLogic::scriptManager(BsObject *compact, uint32 id) { } else compact->o_tree.o_script_pc[level] = ret; } while (!ret); - return 1; + return 1; //Logic continues - but the script must have changed logic mode //this is a radical change from S2.0 where once a script finished there //was no more processing for that object on that cycle - the Logic_engine terminated. @@ -549,7 +549,7 @@ int SwordLogic::interpretScript(BsObject *compact, int id, Header *scriptModule, 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]); _scriptVars[scriptCode[pc++]] = stack[--stackIdx]; break; case IT_POPLONGOFFSET: @@ -788,7 +788,7 @@ int SwordLogic::fnAnim(BsObject *cpt, int32 id, int32 cdt, int32 spr, int32 e, i cpt->o_logic = LOGIC_anim; cpt->o_anim_pc = 0; cpt->o_sync = 0; - return SCRIPT_STOP; + return SCRIPT_STOP; } int SwordLogic::fnSetFrame(BsObject *cpt, int32 id, int32 cdt, int32 spr, int32 frameNo, int32 f, int32 z, int32 x) { @@ -1067,7 +1067,7 @@ int SwordLogic::fnISpeak(BsObject *cpt, int32 id, int32 cdt, int32 textNo, int32 _speechRunning = _sound->startSpeech(textNo >> 16, textNo & 0xFFFF); else _speechRunning = false; - _speechFinished = false; + _speechFinished = false; if (SwordEngine::_systemVars.showText || (!_speechRunning)) { _textRunning = true; @@ -1125,7 +1125,7 @@ int SwordLogic::fnTheyDo(BsObject *cpt, int32 id, int32 tar, int32 instruc, int3 target->o_ins1 = param1; target->o_ins2 = param2; target->o_ins3 = param3; - return SCRIPT_CONT; + return SCRIPT_CONT; } //send an instruction to mega we're talking to and wait @@ -1176,7 +1176,7 @@ int SwordLogic::fnStartTalk(BsObject *cpt, int32 id, int32 target, int32 d, int3 int SwordLogic::fnCheckForTextLine(BsObject *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x) { _scriptVars[RETURN_VALUE] = _objMan->fnCheckForTextLine(id); - return SCRIPT_CONT; + return SCRIPT_CONT; } int SwordLogic::fnAddTalkWaitStatusBit(BsObject *cpt, int32 id, int32 c, int32 d, int32 e, int32 f, int32 z, int32 x) { @@ -1306,7 +1306,7 @@ int SwordLogic::fnChangeFloor(BsObject *cpt, int32 id, int32 floor, int32 d, int BsObject *floorCpt = _objMan->fetchObject(floor); cpt->o_scale_a = floorCpt->o_scale_a; cpt->o_scale_b = floorCpt->o_scale_b; - return SCRIPT_CONT; + return SCRIPT_CONT; } int SwordLogic::fnWalk(BsObject *cpt, int32 id, int32 x, int32 y, int32 dir, int32 stance, int32 a, int32 b) { @@ -1350,7 +1350,7 @@ int SwordLogic::fnWalk(BsObject *cpt, int32 id, int32 x, int32 y, int32 dir, int cpt->o_down_flag = 1; // pretend it was successful else cpt->o_down_flag = 0; // 0 means error - + return SCRIPT_CONT; } @@ -1446,7 +1446,7 @@ int SwordLogic::fnGetTo(BsObject *cpt, int32 id, int32 a, int32 b, int32 c, int3 cpt->o_tree.o_script_level++; cpt->o_tree.o_script_pc[cpt->o_tree.o_script_level] = place->o_get_to_script; cpt->o_tree.o_script_id[cpt->o_tree.o_script_level] = place->o_get_to_script; - return SCRIPT_STOP; + return SCRIPT_STOP; } int SwordLogic::fnGetToError(BsObject *cpt, int32 id, int32 a, int32 b, int32 c, int32 d, int32 z, int32 x) { diff --git a/sword1/memman.cpp b/sword1/memman.cpp index 82e5fd7b8c..bee3c736ae 100644 --- a/sword1/memman.cpp +++ b/sword1/memman.cpp @@ -42,7 +42,7 @@ void MemMan::alloc(BsMemHandle *bsMem, uint32 pSize, uint16 pCond) { warning("%d Bytes alloced as FREEABLE.", pSize); // why should one want to alloc mem if it can be freed? addToFreeList(bsMem); } else if (bsMem->next || bsMem->prev) // it's in our _freeAble list, remove it from there - removeFromFreeList(bsMem); + removeFromFreeList(bsMem); checkMemoryUsage(); } diff --git a/sword1/mouse.cpp b/sword1/mouse.cpp index 7a65783a38..585fba3bc2 100644 --- a/sword1/mouse.cpp +++ b/sword1/mouse.cpp @@ -197,7 +197,7 @@ void SwordMouse::setPointer(uint32 resId, uint32 rate) { _specialPtrId = resId; _specialPtr = (MousePtr*)_resMan->mouseResOpen(resId); } - animate(); + animate(); _system->show_mouse(true); } } @@ -249,7 +249,7 @@ void SwordMouse::fnLockMouse(void) { } void SwordMouse::fnUnlockMouse(void) { - _mouseStatus &= 1; + _mouseStatus &= 1; } void SwordMouse::giveCoords(uint16 *x, uint16 *y) { diff --git a/sword1/mouse.h b/sword1/mouse.h index a6abdd3e9a..0f36cc83d3 100644 --- a/sword1/mouse.h +++ b/sword1/mouse.h @@ -67,8 +67,8 @@ class OSystem; class SwordMouse { public: SwordMouse(OSystem *system, ResMan *pResMan, ObjectMan *pObjMan); - void addToList(int id, BsObject *compact); - void useLogicAndMenu(SwordLogic *pLogic, SwordMenu *pMenu); + void addToList(int id, BsObject *compact); + void useLogicAndMenu(SwordLogic *pLogic, SwordMenu *pMenu); void setLuggage(uint32 resID, uint32 rate); void setPointer(uint32 resID, uint32 rate); void animate(void); diff --git a/sword1/objectman.h b/sword1/objectman.h index 04e1aa38bd..8b06abe56a 100644 --- a/sword1/objectman.h +++ b/sword1/objectman.h @@ -44,7 +44,7 @@ public: void unlockText(uint32 textId); uint32 lastTextNumber(int section); - void closeSection(uint32 screen); + void closeSection(uint32 screen); private: ResMan *_resMan; static const uint32 _objectList[TOTAL_SECTIONS]; //a table of pointers to object files diff --git a/sword1/resman.cpp b/sword1/resman.cpp index ca3e3b7a72..2097874acd 100644 --- a/sword1/resman.cpp +++ b/sword1/resman.cpp @@ -85,7 +85,7 @@ void ResMan::loadCluDescript(const char *fileName) { _memMan->initHandle(group->resHandle + resCnt); } } - free(resIdIdx); + free(resIdIdx); } else cluster->grp[grpCnt] = NULL; free(grpIndex); @@ -200,7 +200,7 @@ void ResMan::resClose(uint32 id) { FrameHeader *ResMan::fetchFrame(void *resourceData, uint32 frameNo) { uint8 *frameFile = (uint8*)resourceData; - uint8 *idxData = frameFile + sizeof(Header); + uint8 *idxData = frameFile + sizeof(Header); if (frameNo >= READ_LE_UINT32(idxData)) error("fetchFrame:: frame %d doesn't exist in resource.", frameNo); frameFile += READ_LE_UINT32(idxData + (frameNo+1) * 4); diff --git a/sword1/resman.h b/sword1/resman.h index 847e467d8c..527f776d52 100644 --- a/sword1/resman.h +++ b/sword1/resman.h @@ -68,7 +68,7 @@ private: void openCptResourceBigEndian(uint32 id); void openScriptResourceBigEndian(uint32 id); - File *openClusterFile(uint32 id); + File *openClusterFile(uint32 id); void makePathToCluster(char *str); void loadCluDescript(const char *fileName); void freeCluDescript(void); diff --git a/sword1/router.cpp b/sword1/router.cpp index 2574ec6643..e575c9575c 100644 --- a/sword1/router.cpp +++ b/sword1/router.cpp @@ -326,7 +326,7 @@ int32 SwordRouter::SmoothestPath() * steps taken between two points to the shrunken step size * */ - int32 p; + int32 p; int32 dirS; int32 dirD; int32 dS; @@ -345,12 +345,12 @@ int32 SwordRouter::SmoothestPath() int32 steps; int32 option; int32 options; - int32 lastDir; - int32 nextDirS; - int32 nextDirD; - int32 tempturns[4]; - int32 turns[4]; - int32 turntable[NO_DIRECTIONS] = {0,1,3,5,7,5,3,1}; + int32 lastDir; + int32 nextDirS; + int32 nextDirD; + int32 tempturns[4]; + int32 turns[4]; + int32 turntable[NO_DIRECTIONS] = {0,1,3,5,7,5,3,1}; // targetDir;// no warnings @@ -359,12 +359,11 @@ int32 SwordRouter::SmoothestPath() smoothPath[0].y = startY; smoothPath[0].dir = startDir; smoothPath[0].num = 0; - p = 0; - lastDir = startDir; - // for each section of the route - do - { - + p = 0; + lastDir = startDir; + // for each section of the route + do + { dirS = route[p].dirS; dirD = route[p].dirD; nextDirS = route[p+1].dirS; @@ -473,16 +472,16 @@ int32 SwordRouter::SmoothestPath() while ((steps == 0) && (i < 4)); #ifdef PLOT_PATHS // plot the best path - if (steps != 0) - { - i = 0; - do + if (steps != 0) { - RouteLine(smoothPath[i].x, smoothPath[i].y, smoothPath[i+1].x, smoothPath[i+1].y, 228); - i = i + 1; + i = 0; + do + { + RouteLine(smoothPath[i].x, smoothPath[i].y, smoothPath[i+1].x, smoothPath[i+1].y, 228); + i = i + 1; + } + while (i < steps); } - while (i < steps); - } #endif if (steps == 0) @@ -516,7 +515,7 @@ int32 SwordRouter::SmoothCheck(int32 best, int32 p, int32 dirS, int32 dirD) * No longer checks the data it only creates the smoothPath array JPS ****************************************************************************/ { -static int32 k; + static int32 k; int32 tempK; int32 x; int32 y; @@ -524,12 +523,12 @@ static int32 k; int32 y2; int32 dx; int32 dy; - int32 dsx; - int32 dsy; - int32 ddx; - int32 ddy; - int32 dirX; - int32 dirY; + int32 dsx; + int32 dsy; + int32 ddx; + int32 ddy; + int32 dirX; + int32 dirY; int32 ss0; int32 ss1; int32 ss2; @@ -563,107 +562,107 @@ static int32 k; } // set up sd0-ss2 to reflect possible movement in each direction - if ((dirS == 0) || (dirS == 4))// vert and diag - { - ddx = dx; - ddy = (dx*diagonaly)/diagonalx; - dsy = dy - ddy; - ddx = ddx * dirX; - ddy = ddy * dirY; - dsy = dsy * dirY; - dsx = 0; - - sd0 = (ddx + modX[dirD]/2)/ modX[dirD]; - ss0 = (dsy + modY[dirS]/2) / modY[dirS]; - sd1 = sd0/2; - ss1 = ss0/2; - sd2 = sd0 - sd1; - ss2 = ss0 - ss1; - } - else - { - ddy = dy; - ddx = (dy*diagonalx)/diagonaly; - dsx = dx - ddx; - ddy = ddy * dirY; - ddx = ddx * dirX; - dsx = dsx * dirX; - dsy = 0; - - sd0 = (ddy + modY[dirD]/2)/ modY[dirD]; - ss0 = (dsx + modX[dirS]/2)/ modX[dirS]; - sd1 = sd0/2; - ss1 = ss0/2; - sd2 = sd0 - sd1; - ss2 = ss0 - ss1; - } + if ((dirS == 0) || (dirS == 4))// vert and diag + { + ddx = dx; + ddy = (dx*diagonaly)/diagonalx; + dsy = dy - ddy; + ddx = ddx * dirX; + ddy = ddy * dirY; + dsy = dsy * dirY; + dsx = 0; + + sd0 = (ddx + modX[dirD]/2)/ modX[dirD]; + ss0 = (dsy + modY[dirS]/2) / modY[dirS]; + sd1 = sd0/2; + ss1 = ss0/2; + sd2 = sd0 - sd1; + ss2 = ss0 - ss1; + } + else + { + ddy = dy; + ddx = (dy*diagonalx)/diagonaly; + dsx = dx - ddx; + ddy = ddy * dirY; + ddx = ddx * dirX; + dsx = dsx * dirX; + dsy = 0; + + sd0 = (ddy + modY[dirD]/2)/ modY[dirD]; + ss0 = (dsx + modX[dirS]/2)/ modX[dirS]; + sd1 = sd0/2; + ss1 = ss0/2; + sd2 = sd0 - sd1; + ss2 = ss0 - ss1; + } - if (best == 0) //halfsquare, diagonal, halfsquare - { - smoothPath[k].x = x+dsx/2; - smoothPath[k].y = y+dsy/2; - smoothPath[k].dir = dirS; - smoothPath[k].num = ss1; - k = k + 1; - smoothPath[k].x = x+dsx/2+ddx; - smoothPath[k].y = y+dsy/2+ddy; - smoothPath[k].dir = dirD; - smoothPath[k].num = sd0; - k = k + 1; - smoothPath[k].x = x+dsx+ddx; - smoothPath[k].y = y+dsy+ddy; - smoothPath[k].dir = dirS; - smoothPath[k].num = ss2; - k = k + 1; - tempK = k; - } - else if (best == 1) //square, diagonal - { - smoothPath[k].x = x+dsx; - smoothPath[k].y = y+dsy; - smoothPath[k].dir = dirS; - smoothPath[k].num = ss0; - k = k + 1; - smoothPath[k].x = x2; - smoothPath[k].y = y2; - smoothPath[k].dir = dirD; - smoothPath[k].num = sd0; - k = k + 1; - tempK = k; - } - else if (best == 2) //diagonal square - { - smoothPath[k].x = x+ddx; - smoothPath[k].y = y+ddy; - smoothPath[k].dir = dirD; - smoothPath[k].num = sd0; - k = k + 1; - smoothPath[k].x = x2; - smoothPath[k].y = y2; - smoothPath[k].dir = dirS; - smoothPath[k].num = ss0; - k = k + 1; - tempK = k; - } - else //halfdiagonal, square, halfdiagonal - { - smoothPath[k].x = x+ddx/2; - smoothPath[k].y = y+ddy/2; - smoothPath[k].dir = dirD; - smoothPath[k].num = sd1; - k = k + 1; - smoothPath[k].x = x+dsx+ddx/2; - smoothPath[k].y = y+dsy+ddy/2; - smoothPath[k].dir = dirS; - smoothPath[k].num = ss0; - k = k + 1; - smoothPath[k].x = x2; - smoothPath[k].y = y2; - smoothPath[k].dir = dirD; - smoothPath[k].num = sd2; - k = k + 1; - tempK = k; - } + if (best == 0) //halfsquare, diagonal, halfsquare + { + smoothPath[k].x = x+dsx/2; + smoothPath[k].y = y+dsy/2; + smoothPath[k].dir = dirS; + smoothPath[k].num = ss1; + k = k + 1; + smoothPath[k].x = x+dsx/2+ddx; + smoothPath[k].y = y+dsy/2+ddy; + smoothPath[k].dir = dirD; + smoothPath[k].num = sd0; + k = k + 1; + smoothPath[k].x = x+dsx+ddx; + smoothPath[k].y = y+dsy+ddy; + smoothPath[k].dir = dirS; + smoothPath[k].num = ss2; + k = k + 1; + tempK = k; + } + else if (best == 1) //square, diagonal + { + smoothPath[k].x = x+dsx; + smoothPath[k].y = y+dsy; + smoothPath[k].dir = dirS; + smoothPath[k].num = ss0; + k = k + 1; + smoothPath[k].x = x2; + smoothPath[k].y = y2; + smoothPath[k].dir = dirD; + smoothPath[k].num = sd0; + k = k + 1; + tempK = k; + } + else if (best == 2) //diagonal square + { + smoothPath[k].x = x+ddx; + smoothPath[k].y = y+ddy; + smoothPath[k].dir = dirD; + smoothPath[k].num = sd0; + k = k + 1; + smoothPath[k].x = x2; + smoothPath[k].y = y2; + smoothPath[k].dir = dirS; + smoothPath[k].num = ss0; + k = k + 1; + tempK = k; + } + else //halfdiagonal, square, halfdiagonal + { + smoothPath[k].x = x+ddx/2; + smoothPath[k].y = y+ddy/2; + smoothPath[k].dir = dirD; + smoothPath[k].num = sd1; + k = k + 1; + smoothPath[k].x = x+dsx+ddx/2; + smoothPath[k].y = y+dsy+ddy/2; + smoothPath[k].dir = dirS; + smoothPath[k].num = ss0; + k = k + 1; + smoothPath[k].x = x2; + smoothPath[k].y = y2; + smoothPath[k].dir = dirD; + smoothPath[k].num = sd2; + k = k + 1; + tempK = k; + } return tempK; } @@ -678,13 +677,13 @@ int32 SwordRouter::SlidyPath() * produce a module list from the line data * ****************************************************************************/ -int32 smooth; -int32 slidy; -int32 scale; -int32 stepX; -int32 stepY; -int32 deltaX; -int32 deltaY; + int32 smooth; + int32 slidy; + int32 scale; + int32 stepX; + int32 stepY; + int32 deltaX; + int32 deltaY; // strip out the short sections slidy = 1; @@ -747,31 +746,31 @@ void SwordRouter::SlidyWalkAnimator(WalkData *walkAnim) ****************************************************************************/ { -static int32 left = 0; -int32 p; -int32 lastDir; -int32 lastRealDir; -int32 currentDir; -int32 turnDir; -int32 scale; -int32 step; -int32 module; -int32 moduleEnd; -int32 moduleX; -int32 moduleY; -int32 module16X = 0; -int32 module16Y = 0; -int32 stepX; -int32 stepY; -int32 errorX; -int32 errorY; -int32 lastErrorX; -int32 lastErrorY; -int32 lastCount; -int32 stepCount; -int32 frameCount; -int32 frames; -int32 frame; + static int32 left = 0; + int32 p; + int32 lastDir; + int32 lastRealDir; + int32 currentDir; + int32 turnDir; + int32 scale; + int32 step; + int32 module; + int32 moduleEnd; + int32 moduleX; + int32 moduleY; + int32 module16X = 0; + int32 module16Y = 0; + int32 stepX; + int32 stepY; + int32 errorX; + int32 errorY; + int32 lastErrorX; + int32 lastErrorY; + int32 lastCount; + int32 stepCount; + int32 frameCount; + int32 frames; + int32 frame; // start at the begining for a change p = 0; @@ -872,9 +871,9 @@ int32 frame; //**************************************************************************** if (left == 0) - left = framesPerStep; + left = framesPerStep; else - left = 0; + left = 0; lastCount = stepCount; lastDir = 99;// this ensures that we don't put in turn frames for the start @@ -895,9 +894,9 @@ int32 frame; { module = currentDir * framesPerStep * 2 + left; if (left == 0) - left = framesPerStep; + left = framesPerStep; else - left = 0; + left = 0; moduleEnd = module + framesPerStep; step = 0; scale = (scaleA * moduleY + scaleB); @@ -991,7 +990,7 @@ int32 frame; // check each turn condition in turn if (((lastDir != 99) && (currentDir != 99)) && (megaId == GEORGE)) // only for george { - lastDir = currentDir - lastDir;//1 and -7 going right -1 and 7 going left + lastDir = currentDir - lastDir;//1 and -7 going right -1 and 7 going left if (((lastDir == -1) || (lastDir == 7)) || ((lastDir == -2) || (lastDir == 6))) { // turn at the end of the last walk @@ -1071,7 +1070,7 @@ int32 frame; // rotate to target direction turnDir = targetDir - lastRealDir; if ( turnDir < 0) - turnDir += NO_DIRECTIONS; + turnDir += NO_DIRECTIONS; if (turnDir > 4) turnDir = -1; @@ -1161,13 +1160,13 @@ int32 SwordRouter::SolidPath() * produce a module list from the line data * ****************************************************************************/ -int32 smooth; -int32 solid; -int32 scale; -int32 stepX; -int32 stepY; -int32 deltaX; -int32 deltaY; + int32 smooth; + int32 solid; + int32 scale; + int32 stepX; + int32 stepY; + int32 deltaX; + int32 deltaY; // strip out the short sections solid = 1; @@ -1202,9 +1201,9 @@ int32 deltaY; // in case the last bit had no steps if (solid == 1) //there were no paths so put in a dummy end { - solid = 2; - modularPath[1].dir = smoothPath[0].dir; - modularPath[1].num = 0; + solid = 2; + modularPath[1].dir = smoothPath[0].dir; + modularPath[1].num = 0; } modularPath[solid-1].x = smoothPath[smooth-1].x; modularPath[solid-1].y = smoothPath[smooth-1].y; @@ -1228,26 +1227,26 @@ int32 SwordRouter::SolidWalkAnimator(WalkData *walkAnim) * * returns 0 if solid route not found ****************************************************************************/ -int32 p; -int32 i; -int32 left; -int32 lastDir; -int32 currentDir; -int32 turnDir; -int32 scale; -int32 step; -int32 module; -int32 moduleX; -int32 moduleY; -int32 module16X; -int32 module16Y; -int32 errorX; -int32 errorY; -int32 moduleEnd; -int32 slowStart; -int32 stepCount; -int32 lastCount; -int32 frame; + int32 p; + int32 i; + int32 left; + int32 lastDir; + int32 currentDir; + int32 turnDir; + int32 scale; + int32 step; + int32 module; + int32 moduleX; + int32 moduleY; + int32 module16X; + int32 module16Y; + int32 errorX; + int32 errorY; + int32 moduleEnd; + int32 slowStart; + int32 stepCount; + int32 lastCount; + int32 frame; // start at the begining for a change lastDir = modularPath[0].dir; @@ -1317,13 +1316,13 @@ int32 frame; if ( turnDir < 0) // new frames for turn frames 29oct95jps { if ( lastDir < 0) - lastDir += NO_DIRECTIONS; + lastDir += NO_DIRECTIONS; module = turnFramesLeft + lastDir; } else { if ( lastDir > 7) - lastDir -= NO_DIRECTIONS; + lastDir -= NO_DIRECTIONS; module = turnFramesRight + lastDir; } walkAnim[stepCount].frame = module; @@ -1472,7 +1471,7 @@ int32 frame; // check each turn condition in turn if (((lastDir != 99) && (currentDir != 99)) && (megaId == GEORGE)) // only for george { - lastDir = currentDir - lastDir;//1 and -7 going right -1 and 7 going left + lastDir = currentDir - lastDir;//1 and -7 going right -1 and 7 going left if (((lastDir == -1) || (lastDir == 7)) || ((lastDir == -2) || (lastDir == 6))) { // turn at the end of the last walk @@ -1605,29 +1604,29 @@ int32 frame; // Tdebug("RouteFinder RouteSize is %d", stepCount); // now check the route - i = 0; - do - { - if (!Check(modularPath[i].x, modularPath[i].y, modularPath[i+1].x, modularPath[i+1].y)) - p=0; - #ifdef PLOT_PATHS - RouteLine(modularPath[i].x, modularPath[i].y, modularPath[i+1].x, modularPath[i+1].y, 227); - #endif - i += 1; - } - while(i (diagonalx * dy)) // dir = 1,2 or 2,3 or 5,6 or 6,7 { - dly = dy; + dly = dy; dlx = (dy*diagonalx)/diagonaly; dx = dx - dlx; dlx = dlx * dirX; @@ -1773,14 +1772,14 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 { steps = step1 + step2; // yes options = options + 2; - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1, x1+dx, y1, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dx, y1, x2, y2, 231); - #endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1, x1+dx, y1, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dx, y1, x2, y2, 231); +#endif } } //diagonal, square a code 2 route @@ -1794,14 +1793,14 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 { steps = step1 + step2; // yes options = options + 4; - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1, x1+dlx,y1+dly, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dlx, y2, x2, y2, 231); - #endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1, x1+dlx,y1+dly, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dlx, y2, x2, y2, 231); +#endif } } } @@ -1818,19 +1817,19 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 if (step3 != 0) { steps = step1 + step2 + step3; // yes - options = options + 1; - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1, x1+dx/2, y1, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dx/2, y1, x1+dx/2+dlx, y2, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dx/2+dlx, y2, x2, y2, 231); - #endif + options = options + 1; +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1, x1+dx/2, y1, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dx/2, y1, x1+dx/2+dlx, y2, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dx/2+dlx, y2, x2, y2, 231); +#endif } } } @@ -1848,18 +1847,18 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 if (step3 != 0) { steps = step1 + step2 + step3; // yes - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1, x1+dlx/2, y1+dly/2, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dlx/2, y1+dly/2, x1+dx+dlx/2, y1+dly/2, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dx+dlx/2, y1+dly/2, x2, y2, 231); - #endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1, x1+dlx/2, y1+dly/2, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dlx/2, y1+dly/2, x1+dx+dlx/2, y1+dly/2, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dx+dlx/2, y1+dly/2, x2, y2, 231); +#endif options = options + 8; } } @@ -1868,7 +1867,7 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 } else // dir = 7,0 or 0,1 or 3,4 or 4,5 { - dlx = dx; + dlx = dx; dly = (dx*diagonaly)/diagonalx; dy = dy - dly; dlx = dlx * dirX; @@ -1885,14 +1884,14 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 if (step2 != 0) { steps = step1 + step2; // yes - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1 ,y1 ,x1 ,y1+dy, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1 ,y1+dy ,x2, y2, 231); - #endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1 ,y1 ,x1 ,y1+dy, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1 ,y1+dy ,x2, y2, 231); +#endif options = options + 2; } } @@ -1906,14 +1905,14 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 if (step2 != 0) { steps = step1 + step2; // yes - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1, x2, y1+dly, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x2, y1+dly, x2, y2, 231); - #endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1, x2, y1+dly, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x2, y1+dly, x2, y2, 231); +#endif options = options + 4; } } @@ -1931,18 +1930,18 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 if (step3 != 0) { steps = step1 + step2 + step3; // yes - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1, x1, y1+dy/2, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1+dy/2, x2, y1+dy/2+dly, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x2, y1+dy/2+dly, x2, y2, 231); - #endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1, x1, y1+dy/2, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1+dy/2, x2, y1+dy/2+dly, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x2, y1+dy/2+dly, x2, y2, 231); +#endif options = options + 1; } } @@ -1962,18 +1961,18 @@ int32 SwordRouter::NewCheck(int32 status, int32 x1 , int32 y1 , int32 x2 ,int32 { steps = step1 + step2 + step3; // yes options = options + 8; - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1, y1, x1+dlx/2, y1+dly/2, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dlx/2, y1+dly/2, x1+dlx/2, y1+dy+dly/2, 231); - #endif - #ifdef PLOT_PATHS - if (status == 1) - RouteLine(x1+dlx/2, y1+dy+dly/2, x2, y2, 231); - #endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1, y1, x1+dlx/2, y1+dly/2, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dlx/2, y1+dly/2, x1+dlx/2, y1+dy+dly/2, 231); +#endif +#ifdef PLOT_PATHS + if (status == 1) + RouteLine(x1+dlx/2, y1+dy+dly/2, x2, y2, 231); +#endif } } } @@ -2002,7 +2001,7 @@ int32 SwordRouter::Check(int32 x1 , int32 y1 , int32 x2 ,int32 y2) { //call the fastest line check for the given line //returns 1 if line didn't cross any bars - int32 steps; + int32 steps; if ((x1 == x2) && (y1 == y2)) { @@ -2027,74 +2026,74 @@ int32 SwordRouter::Check(int32 x1 , int32 y1 , int32 x2 ,int32 y2) int32 SwordRouter::LineCheck(int32 x1 , int32 y1 , int32 x2 ,int32 y2) { - int32 dirx; - int32 diry; - int32 co; - int32 slope; - int32 i; - int32 xc; - int32 yc; - int32 xmin; - int32 ymin; - int32 xmax; - int32 ymax; - int32 linesCrossed = 1; - - - if (x1 > x2) - { - xmin = x2; - xmax = x1; - } - else - { - xmin = x1; - xmax = x2; - } - if (y1 > y2) - { - ymin = y2; - ymax = y1; - } - else - { - ymin = y1; - ymax = y2; - } - //line set to go one step in chosen direction - //so ignore if it hits anything - dirx = x2 - x1; + int32 dirx; + int32 diry; + int32 co; + int32 slope; + int32 i; + int32 xc; + int32 yc; + int32 xmin; + int32 ymin; + int32 xmax; + int32 ymax; + int32 linesCrossed = 1; + + + if (x1 > x2) + { + xmin = x2; + xmax = x1; + } + else + { + xmin = x1; + xmax = x2; + } + if (y1 > y2) + { + ymin = y2; + ymax = y1; + } + else + { + ymin = y1; + ymax = y2; + } + //line set to go one step in chosen direction + //so ignore if it hits anything + dirx = x2 - x1; diry = y2 - y1; - co = (y1 *dirx)- (x1*diry); //new line equation + co = (y1 *dirx)- (x1*diry); //new line equation - i = 0; - do - { + i = 0; + do + { // this is the inner inner loop - if ((xmax >= bars[i].xmin) && ( xmin <= bars[i].xmax)) //skip if not on module - { + if ((xmax >= bars[i].xmin) && ( xmin <= bars[i].xmax)) //skip if not on module + { if ((ymax >= bars[i].ymin) && ( ymin <= bars[i].ymax)) //skip if not on module - { + { // okay its a valid line calculate an intersept // wow but all this arithmatic we must have loads of time - slope = (bars[i].dx * diry) - (bars[i].dy *dirx);// slope it he slope between the two lines - if (slope != 0)//assuming parallel lines don't cross - { + slope = (bars[i].dx * diry) - (bars[i].dy *dirx);// slope it he slope between the two lines + if (slope != 0)//assuming parallel lines don't cross + { //calculate x intercept and check its on both lines - xc = ((bars[i].co * dirx) - (co * bars[i].dx)) / slope; + xc = ((bars[i].co * dirx) - (co * bars[i].dx)) / slope; - if ((xc >= xmin-1) && (xc <= xmax+1)) //skip if not on module - { - if ((xc >= bars[i].xmin-1) && (xc <= bars[i].xmax+1)) //skip if not on line - { + if ((xc >= xmin-1) && (xc <= xmax+1)) //skip if not on module + { + if ((xc >= bars[i].xmin-1) && (xc <= bars[i].xmax+1)) //skip if not on line + { - yc = ((bars[i].co * diry) - (co * bars[i].dy)) / slope; + yc = ((bars[i].co * diry) - (co * bars[i].dy)) / slope; - if ((yc >= ymin-1) && (yc <= ymax+1)) //skip if not on module - { - if ((yc >= bars[i].ymin-1) && (yc <= bars[i].ymax+1)) //skip if not on line - { - linesCrossed = 0; + if ((yc >= ymin-1) && (yc <= ymax+1)) //skip if not on module + { + if ((yc >= bars[i].ymin-1) && (yc <= bars[i].ymax+1)) //skip if not on line + { + linesCrossed = 0; } } } @@ -2102,175 +2101,175 @@ int32 SwordRouter::LineCheck(int32 x1 , int32 y1 , int32 x2 ,int32 y2) } } } - i = i + 1; - } - while((i < nbars) && linesCrossed); + i = i + 1; + } + while((i < nbars) && linesCrossed); - return linesCrossed; + return linesCrossed; } int32 SwordRouter::HorizCheck(int32 x1 , int32 y , int32 x2) { - int32 dy; - int32 i; - int32 xc; - int32 xmin; - int32 xmax; - int32 linesCrossed = 1; - - if (x1 > x2) - { - xmin = x2; - xmax = x1; - } - else - { - xmin = x1; - xmax = x2; - } - //line set to go one step in chosen direction - //so ignore if it hits anything - - i = 0; - do - { + int32 dy; + int32 i; + int32 xc; + int32 xmin; + int32 xmax; + int32 linesCrossed = 1; + + if (x1 > x2) + { + xmin = x2; + xmax = x1; + } + else + { + xmin = x1; + xmax = x2; + } + //line set to go one step in chosen direction + //so ignore if it hits anything + + i = 0; + do + { // this is the inner inner loop - if ((xmax >= bars[i].xmin) && ( xmin <= bars[i].xmax)) //skip if not on module - { + if ((xmax >= bars[i].xmin) && ( xmin <= bars[i].xmax)) //skip if not on module + { if ((y >= bars[i].ymin) && ( y <= bars[i].ymax)) //skip if not on module - { + { // okay its a valid line calculate an intersept // wow but all this arithmatic we must have loads of time - if (bars[i].dy == 0) - { - linesCrossed = 0; - } + if (bars[i].dy == 0) + { + linesCrossed = 0; + } else { dy = y-bars[i].y1; xc = bars[i].x1 + (bars[i].dx * dy)/bars[i].dy; - if ((xc >= xmin-1) && (xc <= xmax+1)) //skip if not on module - { - linesCrossed = 0; - } + if ((xc >= xmin-1) && (xc <= xmax+1)) //skip if not on module + { + linesCrossed = 0; + } } } } - i = i + 1; - } - while((i < nbars) && linesCrossed); + i = i + 1; + } + while((i < nbars) && linesCrossed); - return linesCrossed; + return linesCrossed; } int32 SwordRouter::VertCheck(int32 x, int32 y1, int32 y2) { - int32 dx; - int32 i; - int32 yc; - int32 ymin; - int32 ymax; - int32 linesCrossed = 1; - - if (y1 > y2) - { - ymin = y2; - ymax = y1; - } - else - { - ymin = y1; - ymax = y2; - } - //line set to go one step in chosen direction - //so ignore if it hits anything - i = 0; - do // this is the inner inner loop - { - if ((x >= bars[i].xmin) && ( x <= bars[i].xmax)) //overlapping - { + int32 dx; + int32 i; + int32 yc; + int32 ymin; + int32 ymax; + int32 linesCrossed = 1; + + if (y1 > y2) + { + ymin = y2; + ymax = y1; + } + else + { + ymin = y1; + ymax = y2; + } + //line set to go one step in chosen direction + //so ignore if it hits anything + i = 0; + do // this is the inner inner loop + { + if ((x >= bars[i].xmin) && ( x <= bars[i].xmax)) //overlapping + { if ((ymax >= bars[i].ymin) && ( ymin <= bars[i].ymax)) //skip if not on module - { + { // okay its a valid line calculate an intersept // wow but all this arithmatic we must have loads of time - if (bars[i].dx == 0)//both lines vertical and overlap in x and y so they cross - { - linesCrossed = 0; - } + if (bars[i].dx == 0)//both lines vertical and overlap in x and y so they cross + { + linesCrossed = 0; + } else { - dx = x-bars[i].x1; + dx = x-bars[i].x1; yc = bars[i].y1 + (bars[i].dy * dx)/bars[i].dx; - if ((yc >= ymin-1) && (yc <= ymax+1)) //the intersept overlaps - { - linesCrossed = 0; - } + if ((yc >= ymin-1) && (yc <= ymax+1)) //the intersept overlaps + { + linesCrossed = 0; + } } } - } - i = i + 1; - } - while((i < nbars) && linesCrossed); + } + i = i + 1; + } + while((i < nbars) && linesCrossed); - return linesCrossed; + return linesCrossed; } int32 SwordRouter::CheckTarget(int32 x , int32 y) /******************************************************************************* *******************************************************************************/ { - int32 dx; - int32 dy; - int32 i; - int32 xc; - int32 yc; - int32 xmin; - int32 xmax; - int32 ymin; - int32 ymax; - int32 onLine = 0; - - xmin = x - 1; + int32 dx; + int32 dy; + int32 i; + int32 xc; + int32 yc; + int32 xmin; + int32 xmax; + int32 ymin; + int32 ymax; + int32 onLine = 0; + + xmin = x - 1; xmax = x + 1; - ymin = y - 1; + ymin = y - 1; ymax = y + 1; // check if point +- 1 is on the line - //so ignore if it hits anything + //so ignore if it hits anything - i = 0; - do - { + i = 0; + do + { // this is the inner inner loop - if ((xmax >= bars[i].xmin) && ( xmin <= bars[i].xmax)) //overlapping line - { + if ((xmax >= bars[i].xmin) && ( xmin <= bars[i].xmax)) //overlapping line + { if ((ymax >= bars[i].ymin) && ( ymin <= bars[i].ymax)) //overlapping line - { + { // okay this line overlaps the target calculate an y intersept for x - if (bars[i].dx == 0)// vertical line so we know it overlaps y - { + if (bars[i].dx == 0)// vertical line so we know it overlaps y + { yc = 0; - } + } else { dx = x-bars[i].x1; yc = bars[i].y1 + (bars[i].dy * dx)/bars[i].dx; } - if ((yc >= ymin) && (yc <= ymax)) //overlapping point for y - { - onLine = 3;// target on a line so drop out + if ((yc >= ymin) && (yc <= ymax)) //overlapping point for y + { + onLine = 3;// target on a line so drop out //Tdebug("RouteFail due to target on a line %d %d",x,y); } else { - if (bars[i].dy == 0)// vertical line so we know it overlaps y + if (bars[i].dy == 0)// vertical line so we know it overlaps y { xc = 0; } @@ -2280,20 +2279,19 @@ int32 SwordRouter::CheckTarget(int32 x , int32 y) xc = bars[i].x1 + (bars[i].dx * dy)/bars[i].dy; } - if ((xc >= xmin) && (xc <= xmax)) //skip if not on module - { - onLine = 3;// target on a line so drop out + if ((xc >= xmin) && (xc <= xmax)) //skip if not on module + { + onLine = 3;// target on a line so drop out //Tdebug("RouteFail due to target on a line %d %d",x,y); - } + } } - } - } - i = i + 1; - } - while((i < nbars) && (onLine == 0)); - + } + } + i = i + 1; + } + while((i < nbars) && (onLine == 0)); - return onLine; + return onLine; } /******************************************************************************* @@ -2307,18 +2305,18 @@ int32 SwordRouter::CheckTarget(int32 x , int32 y) int32 SwordRouter::LoadWalkResources(BsObject *megaObject, int32 x, int32 y, int32 dir) { WalkGridHeader floorHeader; - int32 i; - int32 j; - uint8 *fPolygrid; - uint8 *fMegaWalkData; + int32 i; + int32 j; + uint8 *fPolygrid; + uint8 *fMegaWalkData; - int32 floorId; + int32 floorId; int32 walkGridResourceId; - BsObject *floorObject; - + BsObject *floorObject; -// load in floor grid for current mega + + // load in floor grid for current mega floorId = megaObject->o_place; @@ -2372,12 +2370,12 @@ int32 SwordRouter::LoadWalkResources(BsObject *megaObject, int32 x, int32 y, int bars[cnt].co = READ_LE_UINT32(fPolygrid); fPolygrid += 4; } - /*j = 1;// leave node 0 for start node + /*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 (int32 cnt = 1; cnt < nnodes; cnt++) { @@ -2390,8 +2388,8 @@ int32 SwordRouter::LoadWalkResources(BsObject *megaObject, int32 x, int32 y, int _resMan->resClose(walkGridResourceId); -// floor grid loaded -// if its george copy extra bars and nodes + // floor grid loaded + // if its george copy extra bars and nodes if (megaId == GEORGE) { @@ -2403,15 +2401,15 @@ int32 SwordRouter::LoadWalkResources(BsObject *megaObject, int32 x, int32 y, int nbars += _numExtraBars; // copy any extra nodes from extraNode array - j = 0; + j = 0; while(j < _numExtraNodes)//array starts at 0 { - node[nnodes+j].x = _extraNodes[j].x ; - node[nnodes+j].y = _extraNodes[j].y ; - j++; + node[nnodes+j].x = _extraNodes[j].x ; + node[nnodes+j].y = _extraNodes[j].y ; + j++; } - nnodes += _numExtraNodes; + nnodes += _numExtraNodes; } @@ -2473,25 +2471,25 @@ int32 SwordRouter::LoadWalkResources(BsObject *megaObject, int32 x, int32 y, int // 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; + node[0].x = startX; + node[0].y = startY; + node[0].level = 1; + node[0].prev = 0; + node[0].dist = 0; i=1; do { - node[i].level = 0; - node[i].prev = 0; - node[i].dist = 9999; + node[i].level = 0; + node[i].prev = 0; + node[i].dist = 9999; i=i+1; } while (i < nnodes); - node[nnodes].x = targetX; - node[nnodes].y = targetY; - node[nnodes].level = 0; - node[nnodes].prev = 0; - node[nnodes].dist = 9999; + node[nnodes].x = targetX; + node[nnodes].y = targetY; + node[nnodes].level = 0; + node[nnodes].prev = 0; + node[nnodes].dist = 9999; return 1; } @@ -2515,7 +2513,7 @@ void SwordRouter::ExtractRoute() int32 prevy; int32 last; int32 point; - int32 p; + int32 p; int32 dirx; int32 diry; int32 dir; @@ -2554,12 +2552,12 @@ void SwordRouter::ExtractRoute() routeLength = routeLength - 1; // okay the route exists as a series point now put in some directions - p = 0; - do - { - #ifdef PLOT_PATHS - BresenhamLine(route[p+1].x-128,route[p+1].y-128, route[p].x-128,route[p].y-128, (uint8*)screen_ad, true_pixel_size_x, pixel_size_y, ROUTE_END_FLAG); - #endif + p = 0; + do + { +#ifdef PLOT_PATHS + BresenhamLine(route[p+1].x-128,route[p+1].y-128, route[p].x-128,route[p].y-128, (uint8*)screen_ad, true_pixel_size_x, pixel_size_y, ROUTE_END_FLAG); +#endif dx = route[p+1].x - route[p].x; dy = route[p+1].y - route[p].y; dirx = 1; diff --git a/sword1/router.h b/sword1/router.h index 62aba682d6..e7a8e807fc 100644 --- a/sword1/router.h +++ b/sword1/router.h @@ -177,7 +177,7 @@ private: int32 SmoothestPath(); int32 SmoothCheck(int32 best, int32 p, int32 dirS, int32 dirD); - int32 SolidPath(); + int32 SolidPath(); int32 SolidWalkAnimator(WalkData *walkAnim); void RouteLine(int32 x1,int32 y1,int32 x2,int32 y2 ,int32 colour); void BresenhamLine(int32 x1,int32 y1,int32 x2,int32 y2, uint8 *screen, int32 width, int32 height, int32 colour); diff --git a/sword1/screen.cpp b/sword1/screen.cpp index 8fd61be6b9..69f9e247ac 100644 --- a/sword1/screen.cpp +++ b/sword1/screen.cpp @@ -292,7 +292,7 @@ void SwordScreen::spritesAndParallax(void) { for (uint8 cnt = 0; cnt < _sortLength - 1; cnt++) for (uint8 sCnt = 0; sCnt < _sortLength - 1; sCnt++) if (_sortList[sCnt].y > _sortList[sCnt + 1].y) { - temp = _sortList[sCnt]; + temp = _sortList[sCnt]; _sortList[sCnt] = _sortList[sCnt + 1]; _sortList[sCnt + 1] = temp; } @@ -422,7 +422,7 @@ void SwordScreen::verticalMask(uint16 x, uint16 y, uint16 bWidth, uint16 bHeight for (uint16 blky = 0; blky < bHeight; blky++) { if (*grid) { uint8 *blkData = _layerBlocks[level + 1] + (READ_LE_UINT16(grid) - 1) * 128; - blitBlockClear(x + blkx, y + blky, blkData); + blitBlockClear(x + blkx, y + blky, blkData); } grid += lGridSizeX; } @@ -460,7 +460,7 @@ void SwordScreen::renderParallax(uint8 *data) { if (doSkip <= remain) remain -= doSkip; else { - xPos = doSkip - remain; + xPos = doSkip - remain; dest += xPos; remain = 0; } @@ -528,7 +528,7 @@ void SwordScreen::fastShrink(uint8 *src, uint32 width, uint32 height, uint32 sca uint32 newRow = step >> 1; uint32 oldRow = 0; - uint8 *destPos = dest; + uint8 *destPos = dest; for (uint16 lnCnt = 0; lnCnt < resHeight; lnCnt++) { while (oldRow < (newRow >> 8)) { oldRow++; @@ -681,7 +681,7 @@ void SwordScreen::spriteClipAndSet(uint16 *pSprX, uint16 *pSprY, uint16 *pSprWid sprH = _scrnSizeY - sprY; if (sprX + sprW > _scrnSizeX) sprW = _scrnSizeX - sprX; - + if (sprH < 0) *pSprHeight = 0; else @@ -742,48 +742,48 @@ void SwordScreen::vline(uint16 x, uint16 y1, uint16 y2) { } void SwordScreen::hline(uint16 x1, uint16 x2, uint16 y) { - for (uint16 cntx = x1; cntx <= x2; cntx++) + for (uint16 cntx = x1; cntx <= x2; cntx++) _screenBuf[y * _scrnSizeX + cntx] = 0; } void SwordScreen::bsubline_1(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddx = abs(x2 - x1); - ddy = abs(y2 - y1) << 1; - e = ddx - ddy; - ddx <<= 1; - - if (x1 > x2) { + ddx = abs(x2 - x1); + ddy = abs(y2 - y1) << 1; + e = ddx - ddy; + ddx <<= 1; + + if (x1 > x2) { uint16 tmp; tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; - } - - for (x = x1, y = y1; x <= x2; x++) { + } + + for (x = x1, y = y1; x <= x2; x++) { _screenBuf[y * _scrnSizeX + x] = 0; if (e < 0) { - y++; - e += ddx - ddy; + y++; + e += ddx - ddy; } else { - e -= ddy; + e -= ddy; } - } + } } void SwordScreen::bsubline_2(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddx = abs(x2 - x1) << 1; - ddy = abs(y2 - y1); - e = ddy - ddx; - ddy <<= 1; - - if (y1 > y2) { + ddx = abs(x2 - x1) << 1; + ddy = abs(y2 - y1); + e = ddy - ddx; + ddy <<= 1; + + if (y1 > y2) { uint16 tmp; tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; - } - - for (y = y1, x = x1; y <= y2; y++) { + } + + for (y = y1, x = x1; y <= y2; y++) { _screenBuf[y * _scrnSizeX + x] = 0; if (e < 0) { x++; @@ -791,80 +791,80 @@ void SwordScreen::bsubline_2(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { } else { e -= ddx; } - } + } } void SwordScreen::bsubline_3(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddx = abs(x1 - x2) << 1; - ddy = abs(y2 - y1); - e = ddy - ddx; - ddy <<= 1; - - if (y1 > y2) { + ddx = abs(x1 - x2) << 1; + ddy = abs(y2 - y1); + e = ddy - ddx; + ddy <<= 1; + + if (y1 > y2) { uint16 tmp; tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; - } + } - for (y = y1, x = x1; y <= y2; y++) { + for (y = y1, x = x1; y <= y2; y++) { _screenBuf[y * _scrnSizeX + x] = 0; if (e < 0) { x--; - e += ddy - ddx; + e += ddy - ddx; } else { e -= ddx; } - } + } } void SwordScreen::bsubline_4(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { int x, y, ddx, ddy, e; - ddy = abs(y2 - y1) << 1; - ddx = abs(x1 - x2); - e = ddx - ddy; - ddx <<= 1; - - if (x1 > x2) { + ddy = abs(y2 - y1) << 1; + ddx = abs(x1 - x2); + e = ddx - ddy; + ddx <<= 1; + + if (x1 > x2) { uint16 tmp; tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; - } - - for (x = x1, y = y1; x <= x2; x++) { + } + + for (x = x1, y = y1; x <= x2; x++) { _screenBuf[y * _scrnSizeX + x] = 0; if (e < 0) { - y--; - e += ddx - ddy; + y--; + e += ddx - ddy; } else { - e -= ddy; + e -= ddy; } - } + } } void SwordScreen::drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2) { if ((x1 == x2) && (y1 == y2)) { _screenBuf[x1 + y1 * _scrnSizeX] = 0; } - if (x1 == x2) { + if (x1 == x2) { vline(x1, MIN(y1, y2), MAX(y1, y2)); return; - } - - if (y1 == y2) { + } + + if (y1 == y2) { hline(MIN(x1, x2), MAX(x1, x2), y1); return; - } + } + + float k = float(y2 - y1) / float(x2 - x1); - float k = float(y2 - y1) / float(x2 - x1); - - if ((k >= 0) && (k <= 1)) { + if ((k >= 0) && (k <= 1)) { bsubline_1(x1, y1, x2, y2); - } else if (k > 1) { + } else if (k > 1) { bsubline_2(x1, y1, x2, y2); - } else if ((k < 0) && (k >= -1)) { + } else if ((k < 0) && (k >= -1)) { bsubline_4(x1, y1, x2, y2); - } else { + } else { bsubline_3(x1, y1, x2, y2); - } + } } diff --git a/sword1/screen.h b/sword1/screen.h index 64b506227f..bef314791b 100644 --- a/sword1/screen.h +++ b/sword1/screen.h @@ -119,7 +119,7 @@ private: ObjectMan *_objMan; SwordText *_textMan; - uint16 _currentScreen; + uint16 _currentScreen; uint8 *_screenBuf; uint8 *_screenGrid; uint16 *_layerGrid[4]; diff --git a/sword1/sound.cpp b/sword1/sound.cpp index 14be42676b..6ba4393d93 100644 --- a/sword1/sound.cpp +++ b/sword1/sound.cpp @@ -95,7 +95,7 @@ void SwordSound::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) + if (cnt != _endOfQueue-1) _fxQueue[cnt] = _fxQueue[_endOfQueue-1]; _endOfQueue--; return ; @@ -118,7 +118,7 @@ void SwordSound::closeCowSysten(void) { bool SwordSound::speechFinished(void) { //warning("stub: SwordSound::speechFinished()"); //return true; - return (_speechHandle == 0); + return (_speechHandle == 0); } void SwordSound::newScreen(uint16 screen) { @@ -171,7 +171,7 @@ bool SwordSound::startSpeech(uint16 roomNo, uint16 localNo) { uint8 *buf = (uint8*)malloc(sampleSize); _cowFile.read(buf, sampleSize); uint8 *smpBuf = (uint8*)malloc(uncompressedSize(buf)); - uint32 size = expandSpeech(buf, smpBuf, sampleSize); + uint32 size = expandSpeech(buf, smpBuf, sampleSize); free(buf); if (!size) { free(smpBuf); diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp index c5f57a82ac..24cdb02c59 100644 --- a/sword1/sword1.cpp +++ b/sword1/sword1.cpp @@ -1010,7 +1010,7 @@ void SwordEngine::go(void) { initialize(); // check if we have savegames. if we do, show control panel, else start intro. do { - mainLoop(); + mainLoop(); // mainLoop was left, show control panel } while (true); } @@ -1081,7 +1081,7 @@ void SwordEngine::mainLoop(void) { _screen->quitScreen(); // close graphic resources _objectMan->closeSection(SwordLogic::_scriptVars[SCREEN]); // close the section that PLAYER has just left, if it's empty now - // todo: stop sfx, clear sfx queue, free sfx memory + // todo: stop sfx, clear sfx queue, free sfx memory } while (_systemVars.saveGameFlag < 2); } diff --git a/sword1/sword1.h b/sword1/sword1.h index 46804a006c..7844e9d7e9 100644 --- a/sword1/sword1.h +++ b/sword1/sword1.h @@ -57,7 +57,7 @@ struct SystemVars { //uint8 framesPerSecond; // toggles one frame pre second mode on "1" //uint8 writingPCXs; // writing a PCX every frame on "f" //int16 parallaxOn; I think we don't need this. - uint8 language; + uint8 language; int32 currentMusic; //uint32 gameCycle; }; diff --git a/sword1/sworddefs.h b/sword1/sworddefs.h index 4f6f0cfe43..374c8d4f7c 100644 --- a/sword1/sworddefs.h +++ b/sword1/sworddefs.h @@ -85,7 +85,7 @@ struct ParallaxHeader { char type[16]; uint16 sizeX; uint16 sizeY; - uint32 lineIndexes[2]; //2 is arbitrary number + uint32 lineIndexes[2]; //2 is arbitrary number } GCC_PACK; struct AnimUnit { -- cgit v1.2.3