Skip to content

Commit

Permalink
ACCESS: Implement chkVLine and chkHLine
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke authored and dreammaster committed Dec 13, 2014
1 parent c748211 commit 4ca5cc5
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 8 deletions.
94 changes: 88 additions & 6 deletions engines/access/amazon/amazon_scripts.cpp
Expand Up @@ -683,12 +683,94 @@ void AmazonScripts::mWhile(int param1) {
}
}

void AmazonScripts::CHKVLINE() {
warning("TODO: CHKVLINE()");
void AmazonScripts::VCODE(Common::Rect bounds) {
warning("TODO: VCODE()");
}

void AmazonScripts::CHKHLINE() {
warning("TODO: CHKHLINE()");
void AmazonScripts::HCODE(Common::Rect bounds) {
warning("TODO: HCODE()");
}

void AmazonScripts::chkVLine() {
if (_game->_guard._position.x > _vm->_player->_rawPlayer.x)
_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
else
_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);

if (_vm->_screen->_orgY1 > _vm->_screen->_orgY2)
SWAP(_vm->_screen->_orgY1, _vm->_screen->_orgY2);

while (true) {
VCODE(_game->_guard._bounds);
int code = _game->_guard._gCode1 | _game->_guard._gCode2;
if (code == 10) {
_game->_guardFind = 0;
return;
}

int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
code2 &= 5;
if (((code & 10) == 8) || ((code & 10) == 2) || (code2 != 0))
return;

int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;

if (midX < _vm->_screen->_orgX1) {
if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
return;

_game->_guard._bounds.left = midX;
_game->_guard._bounds.top = midY;
} else {
if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
return;

_game->_guard._bounds.right = midX;
_game->_guard._bounds.bottom = midY;
}
}
}

void AmazonScripts::chkHLine() {
if (_game->_guard._position.y > _vm->_player->_rawPlayer.y)
_game->_guard._bounds = Common::Rect(_vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y, _game->_guard._position.x, _game->_guard._position.y);
else
_game->_guard._bounds = Common::Rect(_game->_guard._position.x, _game->_guard._position.y, _vm->_player->_rawPlayer.x, _vm->_player->_rawPlayer.y);

if (_vm->_screen->_orgX1 > _vm->_screen->_orgX2)
SWAP(_vm->_screen->_orgX1, _vm->_screen->_orgX2);

while (true) {
HCODE(_game->_guard._bounds);
int code = _game->_guard._gCode1 | _game->_guard._gCode2;
if (code == 5) {
_game->_guardFind = 0;
return;
}

int code2 = _game->_guard._gCode1 & _game->_guard._gCode2;
code2 &= 10;
if (((code & 5) == 4) || ((code & 5) == 1) || (code2 != 0))
return;

int midX = (_game->_guard._bounds.left + _game->_guard._bounds.right) / 2;
int midY = (_game->_guard._bounds.top + _game->_guard._bounds.bottom) / 2;

if (midY < _vm->_screen->_orgY1) {
if ((midX == _game->_guard._bounds.left) && (midY == _game->_guard._bounds.top))
return;

_game->_guard._bounds.left = midX;
_game->_guard._bounds.top = midY;
} else {
if ((midX == _game->_guard._bounds.right) && (midY == _game->_guard._bounds.bottom))
return;

_game->_guard._bounds.right = midX;
_game->_guard._bounds.bottom = midY;
}
}
}

void AmazonScripts::guardSee() {
Expand All @@ -712,11 +794,11 @@ void AmazonScripts::guardSee() {
_vm->_screen->_orgX2 = _vm->_room->_plotter._walls[idx].right;
_vm->_screen->_orgY2 = _vm->_room->_plotter._walls[idx].bottom;
if (_vm->_screen->_orgX1 == _vm->_screen->_orgX2) {
CHKVLINE();
chkVLine();
if (_game->_guardFind == 0)
return;
} else if (_vm->_screen->_orgY1 == _vm->_screen->_orgY2) {
CHKHLINE();
chkHLine();
if (_game->_guardFind == 0)
return;
}
Expand Down
6 changes: 4 additions & 2 deletions engines/access/amazon/amazon_scripts.h
Expand Up @@ -72,8 +72,10 @@ class AmazonScripts: public Scripts {
void mWhileJWalk();
void mWhileDoOpen();
void mWhile(int param1);
void CHKVLINE();
void CHKHLINE();
void VCODE(Common::Rect bounds);
void HCODE(Common::Rect bounds);
void chkVLine();
void chkHLine();
void guardSee();
void setGuardFrame();
void guard();
Expand Down

0 comments on commit 4ca5cc5

Please sign in to comment.