diff options
author | Arnaud Boutonné | 2011-01-29 23:05:12 +0000 |
---|---|---|
committer | Arnaud Boutonné | 2011-01-29 23:05:12 +0000 |
commit | 98e329bbd190a687df6b6728e523fd315f24a694 (patch) | |
tree | 78d63beafa19e6660acfd516754546504b0832d6 /engines/hugo | |
parent | 9c17cedd406d5a05cbb4c544eeb426c45d93f004 (diff) | |
download | scummvm-rg350-98e329bbd190a687df6b6728e523fd315f24a694.tar.gz scummvm-rg350-98e329bbd190a687df6b6728e523fd315f24a694.tar.bz2 scummvm-rg350-98e329bbd190a687df6b6728e523fd315f24a694.zip |
HUGO: Cleanup drawRectangle() and keyHandler()
svn-id: r55642
Diffstat (limited to 'engines/hugo')
-rw-r--r-- | engines/hugo/display.cpp | 19 | ||||
-rw-r--r-- | engines/hugo/hugo.cpp | 4 | ||||
-rw-r--r-- | engines/hugo/parser.cpp | 90 |
3 files changed, 44 insertions, 69 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index 79c6da15e5..0ce2534a17 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -106,9 +106,9 @@ void Screen::displayRect(int16 x, int16 y, int16 dx, int16 dy) { debugC(3, kDebugDisplay, "displayRect(%d, %d, %d, %d)", x, y, dx, dy); int16 xClip, yClip; - xClip = CLIP<int16>(x, 0, 320); - yClip = CLIP<int16>(y, 0, 200); - g_system->copyRectToScreen(&_frontBuffer[x + y * 320], 320, xClip, yClip, CLIP<int16>(dx, 0, 320 - x), CLIP<int16>(dy, 0, 200 - y)); + xClip = CLIP<int16>(x, 0, 319); + yClip = CLIP<int16>(y, 0, 199); + g_system->copyRectToScreen(&_frontBuffer[xClip + yClip * 320], 320, xClip, yClip, CLIP<int16>(dx, 0, 319 - xClip), CLIP<int16>(dy, 0, 199 - yClip)); } /** @@ -493,21 +493,20 @@ void Screen::drawShape(int x, int y, int color1, int color2) { void Screen::drawRectangle(bool filledFl, int16 x1, int16 y1, int16 x2, int16 y2, int color) { assert(x1 <= x2); assert(y1 <= y2); + int16 x2Clip = CLIP<int16>(x2, 0, 320); + int16 y2Clip = CLIP<int16>(y2, 0, 200); if (filledFl) { - for (int i = y1; i <= CLIP<int16>(y2, 0, 200); i++) { - for (int j = x1; j <= CLIP<int16>(x2, 0, 320); j++) { - _backBuffer[320 * i + j] = color; + for (int i = y1; i < y2Clip; i++) { + for (int j = x1; j < x2Clip; j++) _frontBuffer[320 * i + j] = color; - _backBufferBackup[320 * i + j] = color; - } } } else { - for (int i = y1; i <= CLIP<int16>(y2, 0, 200); i++) { + for (int i = y1; i < y2Clip; i++) { _frontBuffer[320 * i + x1] = color; _frontBuffer[320 * i + x2] = color; } - for (int i = x1; i < CLIP<int16>(x2, 0, 320); i++) { + for (int i = x1; i < x2Clip; i++) { _frontBuffer[320 * y1 + i] = color; _frontBuffer[320 * y2 + i] = color; } diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index 77b3dede50..eeeb915401 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -264,10 +264,6 @@ Common::Error HugoEngine::run() { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: - if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) { - this->getDebugger()->attach(); - this->getDebugger()->onFrame(); - } _parser->keyHandler(event); break; case Common::EVENT_MOUSEMOVE: diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp index 10a328de51..cc46d2938f 100644 --- a/engines/hugo/parser.cpp +++ b/engines/hugo/parser.cpp @@ -33,6 +33,10 @@ #include "common/system.h" #include "common/events.h" +#include "common/random.h" +#include "common/EventRecorder.h" +#include "common/debug-channels.h" + #include "hugo/hugo.h" #include "hugo/display.h" #include "hugo/parser.h" @@ -131,6 +135,37 @@ void Parser::keyHandler(Common::Event event) { status_t &gameStatus = _vm->getGameStatus(); uint16 nChar = event.kbd.keycode; + if ((event.kbd.hasFlags(Common::KBD_ALT)) || (event.kbd.hasFlags(Common::KBD_SCRL))) + return; + + if (event.kbd.hasFlags(Common::KBD_CTRL)) { + switch (nChar) { + case Common::KEYCODE_d: + _vm->getDebugger()->attach(); + _vm->getDebugger()->onFrame(); + break; + case Common::KEYCODE_l: + _vm->_file->restoreGame(-1); + _vm->_scheduler->restoreScreen(*_vm->_screen_p); + gameStatus.viewState = kViewPlay; + break; + case Common::KEYCODE_n: + warning("STUB: CTRL-N (WIN) - New Game"); + break; + case Common::KEYCODE_s: + if (gameStatus.viewState == kViewPlay) { + if (gameStatus.gameOverFl) + Utils::gameOverMsg(); + else + _vm->_file->saveGame(-1, Common::String()); + } + break; + default: + break; + } + return; + } + // Process key down event - called from OnKeyDown() switch (nChar) { // Set various toggle states case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT @@ -197,61 +232,6 @@ void Parser::keyHandler(Common::Event event) { case Common::KEYCODE_F9: // Boss button warning("STUB: F9 (DOS) - BossKey"); break; - case Common::KEYCODE_l: - if (event.kbd.hasFlags(Common::KBD_CTRL)) { - _vm->_file->restoreGame(-1); - _vm->_scheduler->restoreScreen(*_vm->_screen_p); - gameStatus.viewState = kViewPlay; - } else { - if (!gameStatus.storyModeFl) { // Keyboard disabled - // Add printable keys to ring buffer - uint16 bnext = _putIndex + 1; - if (bnext >= sizeof(_ringBuffer)) - bnext = 0; - if (bnext != _getIndex) { - _ringBuffer[_putIndex] = event.kbd.ascii; - _putIndex = bnext; - } - } - } - break; - case Common::KEYCODE_n: - if (event.kbd.hasFlags(Common::KBD_CTRL)) { - warning("STUB: CTRL-N (WIN) - New Game"); - } else { - if (!gameStatus.storyModeFl) { // Keyboard disabled - // Add printable keys to ring buffer - uint16 bnext = _putIndex + 1; - if (bnext >= sizeof(_ringBuffer)) - bnext = 0; - if (bnext != _getIndex) { - _ringBuffer[_putIndex] = event.kbd.ascii; - _putIndex = bnext; - } - } - } - break; - case Common::KEYCODE_s: - if (event.kbd.hasFlags(Common::KBD_CTRL)) { - if (gameStatus.viewState == kViewPlay) { - if (gameStatus.gameOverFl) - Utils::gameOverMsg(); - else - _vm->_file->saveGame(-1, Common::String()); - } - } else { - if (!gameStatus.storyModeFl) { // Keyboard disabled - // Add printable keys to ring buffer - uint16 bnext = _putIndex + 1; - if (bnext >= sizeof(_ringBuffer)) - bnext = 0; - if (bnext != _getIndex) { - _ringBuffer[_putIndex] = event.kbd.ascii; - _putIndex = bnext; - } - } - } - break; default: // Any other key if (!gameStatus.storyModeFl) { // Keyboard disabled // Add printable keys to ring buffer |