copied the SwordRouter from the original BS1 sources.

It doesn't fit to our coding guidelines but at least it's working, so please bear with it for now. :)

svn-id: r11687
This commit is contained in:
Robert Göffringmann 2003-12-16 18:23:15 +00:00
parent de51f631be
commit 0cf52df651
6 changed files with 2139 additions and 1449 deletions

View File

@ -50,7 +50,6 @@ public:
void engine(void);
void updateScreenParams(void);
void runMouseScript(BsObject *cpt, int32 scriptId);
SwordRouter *giveRouter(void) { return _router; }; // for router debugging
static uint32 _scriptVars[NUM_SCRIPT_VARS];
private:

File diff suppressed because it is too large Load Diff

View File

@ -79,7 +79,7 @@ struct PathData {
int32 num;
};
struct FrameInfos {
/*struct FrameInfos {
int32 framesPerStep, framesPerChar;
int32 standFrames;
int32 slowInFrames, slowOutFrames;
@ -87,7 +87,7 @@ struct FrameInfos {
int32 walkFramesLeft, walkFramesRight;
uint16 startX, startY, targetX, targetY, targetDir;
int32 scaleA, scaleB;
};
};*/
#define ROUTE_END_FLAG 255
#define NO_DIRECTIONS 8
@ -97,20 +97,21 @@ struct FrameInfos {
class ObjectMan;
class ResMan;
class SwordScreen;
class SwordRouter {
public:
SwordRouter(ObjectMan *pObjMan, ResMan *pResMan);
~SwordRouter(void);
int routeFinder(int32 id, BsObject *mega, int32 x, int32 y, int32 dir);
int32 routeFinder(int32 id, BsObject *mega, int32 x, int32 y, int32 dir);
int whatTarget(int32 startX, int32 startY, int32 destX, int32 destY);
void setPlayerTarget(int32 x, int32 y, int32 dir, int32 stance);
void resetExtraData(void);
// these should be private but are read by SwordScreen for debugging:
int32 _nBars, _nNodes;
BarData _bars[O_GRID_SIZE + EXTRA_GRID_SIZE];
NodeData _node[O_GRID_SIZE + EXTRA_GRID_SIZE];
BarData bars[O_GRID_SIZE+EXTRA_GRID_SIZE];
NodeData node[O_GRID_SIZE+EXTRA_GRID_SIZE];
int32 nbars, nnodes;
private:
// when the player collides with another mega, we'll receive a ReRouteRequest here.
// that's why we need to remember the player's target coordinates
@ -122,40 +123,63 @@ private:
ObjectMan *_objMan;
ResMan *_resMan;
uint8 _nWalkFrames, _nTurnFrames;
/*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 _diagonalx, _diagonaly;*/
RouteData _route[O_ROUTE_SIZE];
int32 startX, startY, startDir;
int32 targetX, targetY, targetDir;
int32 scaleA, scaleB;
int32 megaId;
/*RouteData _route[O_ROUTE_SIZE];
//int32 _routeLength;
PathData _smoothPath[O_ROUTE_SIZE];
PathData _modularPath[O_ROUTE_SIZE];
PathData _modularPath[O_ROUTE_SIZE];*/
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;
void loadWalkResources(int32 megaId, BsObject *mega, int32 x, int32 y, int32 targetDir);
int getRoute(void);
int checkTarget(int16 x, int16 y);
int32 LoadWalkResources(BsObject *mega, int32 x, int32 y, int32 targetDir);
int32 GetRoute(void);
int32 CheckTarget(int32 x, int32 y);
int scan(int32 level);
int newCheck(int32 status, int16 x1, int16 x2, int16 y1, int16 y2);
int check(int16 x1, int16 y1, int16 x2, int16 y2);
int horizCheck(int16 x1, int16 y, int16 x2);
int vertCheck(int16 x, int16 y1, int16 y2);
int lineCheck(int16 x1, int16 y1, int16 x2, int16 y2);
int32 Scan(int32 level);
int32 NewCheck(int32 status, int32 x1, int32 x2, int32 y1, int32 y2);
int32 Check(int32 x1, int32 y1, int32 x2, int32 y2);
int32 HorizCheck(int32 x1, int32 y, int32 x2);
int32 VertCheck(int32 x, int32 y1, int32 y2);
int32 LineCheck(int32 x1, int32 y1, int32 x2, int32 y2);
int32 extractRoute(int32 targetDir);
void ExtractRoute();
void slidyPath(int32 scaleA, int32 scaleB, uint16 targetDir);
void slidyWalkAnimator(WalkData *walkAnim, FrameInfos *frInfo, int32 megaId);
int32 SlidyPath();
void SlidyWalkAnimator(WalkData *walkAnim);
int32 smoothestPath(uint16 startX, uint16 startY, uint16 startDir, int32 routeLength);
int32 smoothCheck(int32 best, int32 p, int32 dirS, int32 dirD);
int32 SmoothestPath();
int32 SmoothCheck(int32 best, int32 p, int32 dirS, int32 dirD);
int32 solidPath(int32 scaleA, int32 scaleB);
int32 solidWalkAnimator(WalkData *walkAnim, FrameInfos *frInfo, int32 megaId);
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);
};
#endif //BSROUTER_H

View File

@ -285,7 +285,7 @@ void SwordScreen::newScreen(uint32 screen) {
_targetPalette[0] = _targetPalette[1] = _targetPalette[2] = 0;
_system->set_palette(_targetPalette, 0, 256);
_resMan->resClose(_roomDefTable[_currentScreen].palettes[0]);
_resMan->resClose(_roomDefTable[_currentScreen].palettes[1]);
//_resMan->resClose(_roomDefTable[_currentScreen].palettes[1]);
}
void SwordScreen::quitScreen(void) {
@ -861,24 +861,5 @@ void SwordScreen::drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
bsubline_4(x1, y1, x2, y2);
} else {
bsubline_3(x1, y1, x2, y2);
}
}
}
void SwordScreen::showBarsAndNodes(SwordRouter *router) {
for (uint16 cnt = 0; cnt < router->_nBars; cnt++) {
drawLine(router->_bars[cnt].x1 - 128, router->_bars[cnt].y1 - 128, router->_bars[cnt].x2 - 128, router->_bars[cnt].y2 - 128);
}
if (!router->_nNodes)
return;
for (uint16 cnt = 0; cnt <= router->_nNodes; cnt++) {
uint16 y = router->_node[cnt].y - 128;
uint16 x = router->_node[cnt].x - 128;
vline(x, y - 2, y + 2);
hline(x - 2, x + 2, y);
if (router->_node[cnt].dist != 9999) {
drawLine(x, y, router->_node[router->_node[cnt].prev].x - 128, router->_node[router->_node[cnt].prev].y - 128);
}
}
}

View File

@ -19,8 +19,6 @@
*
*/
// vertical_mask from layers.c belongs here, as well.
#ifndef BSSCREEN_H
#define BSSCREEN_H
@ -94,8 +92,6 @@ public:
void fnFlash(uint8 color);
void fnBorder(uint8 color);
void showBarsAndNodes(SwordRouter *router);
private:
// for router debugging
void drawLine(uint16 x1, uint16 y1, uint16 x2, uint16 y2);

View File

@ -218,7 +218,6 @@ void SwordEngine::mainLoop(void) {
}*/
_sound->engine();
_screen->showBarsAndNodes(_logic->giveRouter());
_screen->updateScreen();
//-
_menu->refresh(MENU_TOP);