aboutsummaryrefslogtreecommitdiff
path: root/engines/avalanche
diff options
context:
space:
mode:
authoruruk2014-01-15 23:04:59 +0100
committeruruk2014-01-15 23:04:59 +0100
commit19ae43aa18b39882c99de1b65742218c09acdf4c (patch)
tree888bb52b0c43dac26b5a78834f69abb0ffe57522 /engines/avalanche
parentf2206381bc528a0e5a59fc0bf82efc7100a8fa7a (diff)
downloadscummvm-rg350-19ae43aa18b39882c99de1b65742218c09acdf4c.tar.gz
scummvm-rg350-19ae43aa18b39882c99de1b65742218c09acdf4c.tar.bz2
scummvm-rg350-19ae43aa18b39882c99de1b65742218c09acdf4c.zip
AVALANCHE: Move Clock to dedicated files.
Diffstat (limited to 'engines/avalanche')
-rw-r--r--engines/avalanche/avalanche.h1
-rw-r--r--engines/avalanche/avalot.cpp81
-rw-r--r--engines/avalanche/avalot.h21
-rw-r--r--engines/avalanche/clock.cpp116
-rw-r--r--engines/avalanche/clock.h60
-rw-r--r--engines/avalanche/module.mk3
6 files changed, 179 insertions, 103 deletions
diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h
index 7392bf3fae..ef2338e629 100644
--- a/engines/avalanche/avalanche.h
+++ b/engines/avalanche/avalanche.h
@@ -42,6 +42,7 @@
#include "avalanche/closing.h"
#include "avalanche/sound.h"
#include "avalanche/nim.h"
+#include "avalanche/clock.h"
#include "common/serializer.h"
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp
index 9555bb4505..04fd2a8d98 100644
--- a/engines/avalanche/avalot.cpp
+++ b/engines/avalanche/avalot.cpp
@@ -116,88 +116,7 @@ Room AvalancheEngine::_whereIs[29] = {
kRoomWiseWomans // The Wise Woman.
};
-Clock::Clock(AvalancheEngine *vm) {
- _vm = vm;
- // Magic value to determine if we just created the instance
- _oldHour = _oldHourAngle = _oldMinute = 17717;
- _hour = _minute = _second = 0;
- _hourAngle = 0;
-}
-
-void Clock::update() {
- TimeDate t;
- _vm->_system->getTimeAndDate(t);
- _hour = t.tm_hour;
- _minute = t.tm_min;
- _second = t.tm_sec;
-
- _hourAngle = (_hour % 12) * 30 + _minute / 2;
-
- if (_oldHour != _hour) {
- plotHands();
- chime();
- }
-
- if (_oldMinute != _minute)
- plotHands();
-
- if ((_hour == 0) && (_oldHour != 0) && (_oldHour != 17717)) {
- Common::String tmpStr = Common::String::format("Good morning!%c%cYes, it's just past " \
- "midnight. Are you having an all-night Avvy session? Glad you like the game that much!",
- kControlNewLine, kControlNewLine);
- _vm->_dialogs->displayText(tmpStr);
- }
- _oldHour = _hour;
- _oldHourAngle = _hourAngle;
- _oldMinute = _minute;
-}
-
-Common::Point Clock::calcHand(uint16 angle, uint16 length, Color color) {
- if (angle > 900) {
- return(Common::Point(177, 177));
- }
-
- return(_vm->_graphics->drawScreenArc(kCenterX, kCenterY, 449 - angle, 450 - angle, length, color));
-}
-void Clock::drawHand(const Common::Point &endPoint, Color color) {
- if (endPoint.x == 177)
- return;
-
- _vm->_graphics->drawScreenLine(kCenterX, kCenterY, endPoint.x, endPoint.y, color);
-}
-
-void Clock::plotHands() {
- _clockHandHour = calcHand(_oldHourAngle, 14, kColorYellow);
- _clockHandMinute = calcHand(_oldMinute * 6, 17, kColorYellow);
- drawHand(_clockHandHour, kColorBrown);
- drawHand(_clockHandMinute, kColorBrown);
-
- _clockHandHour = calcHand(_hourAngle, 14, kColorBrown);
- _clockHandMinute = calcHand(_minute * 6, 17, kColorBrown);
- drawHand(_clockHandHour, kColorYellow);
- drawHand(_clockHandMinute, kColorYellow);
-}
-
-void Clock::chime() {
- // Too high - must be first time around
- // Mute - skip the sound generation
- if ((_oldHour == 17717) || (!_vm->_soundFx))
- return;
-
- byte hour = _hour % 12;
- if (hour == 0)
- hour = 12;
-
- _vm->_graphics->loadMouse(kCurWait);
-
- for (int i = 1; i <= hour; i++) {
- for (int j = 1; j <= 3; j++)
- _vm->_sound->playNote((i % 3) * 64 + 140 - j * 30, 50 - j * 12);
- if (i != hour)
- _vm->_system->delayMillis(100);
- }
-}
void AvalancheEngine::handleKeyDown(Common::Event &event) {
_sound->click();
diff --git a/engines/avalanche/avalot.h b/engines/avalanche/avalot.h
index f50ad28bc4..e5b8f3d490 100644
--- a/engines/avalanche/avalot.h
+++ b/engines/avalanche/avalot.h
@@ -35,27 +35,6 @@
namespace Avalanche {
class AvalancheEngine;
-class Clock {
-public:
- Clock(AvalancheEngine *vm);
-
- void update();
-
-private:
- static const int kCenterX = 510;
- static const int kCenterY = 183;
-
- AvalancheEngine *_vm;
-
- uint16 _hour, _minute, _second, _hourAngle, _oldHour, _oldMinute, _oldHourAngle;
- Common::Point _clockHandHour, _clockHandMinute;
-
- Common::Point calcHand(uint16 angle, uint16 length, Color color);
- void drawHand(const Common::Point &endPoint, Color color);
- void plotHands();
- void chime();
-};
-
static const byte kObjectNum = 18; // always preface with a #
static const int16 kCarryLimit = 12; // carry limit
diff --git a/engines/avalanche/clock.cpp b/engines/avalanche/clock.cpp
new file mode 100644
index 0000000000..1c2c50c3bf
--- /dev/null
+++ b/engines/avalanche/clock.cpp
@@ -0,0 +1,116 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+/*
+* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
+* Copyright (c) 1994-1995 Mike: Mark and Thomas Thurman.
+*/
+
+#include "avalanche/clock.h"
+#include "avalanche/avalanche.h"
+
+namespace Avalanche {
+
+Clock::Clock(AvalancheEngine *vm) {
+ _vm = vm;
+ // Magic value to determine if we just created the instance
+ _oldHour = _oldHourAngle = _oldMinute = 17717;
+ _hour = _minute = _second = 0;
+ _hourAngle = 0;
+}
+
+void Clock::update() {
+ TimeDate t;
+ _vm->_system->getTimeAndDate(t);
+ _hour = t.tm_hour;
+ _minute = t.tm_min;
+ _second = t.tm_sec;
+
+ _hourAngle = (_hour % 12) * 30 + _minute / 2;
+
+ if (_oldHour != _hour) {
+ plotHands();
+ chime();
+ }
+
+ if (_oldMinute != _minute)
+ plotHands();
+
+ if ((_hour == 0) && (_oldHour != 0) && (_oldHour != 17717)) {
+ Common::String tmpStr = Common::String::format("Good morning!%c%cYes, it's just past " \
+ "midnight. Are you having an all-night Avvy session? Glad you like the game that much!",
+ kControlNewLine, kControlNewLine);
+ _vm->_dialogs->displayText(tmpStr);
+ }
+ _oldHour = _hour;
+ _oldHourAngle = _hourAngle;
+ _oldMinute = _minute;
+}
+
+Common::Point Clock::calcHand(uint16 angle, uint16 length, Color color) {
+ if (angle > 900) {
+ return(Common::Point(177, 177));
+ }
+
+ return(_vm->_graphics->drawScreenArc(kCenterX, kCenterY, 449 - angle, 450 - angle, length, color));
+}
+
+void Clock::drawHand(const Common::Point &endPoint, Color color) {
+ if (endPoint.x == 177)
+ return;
+
+ _vm->_graphics->drawScreenLine(kCenterX, kCenterY, endPoint.x, endPoint.y, color);
+}
+
+void Clock::plotHands() {
+ _clockHandHour = calcHand(_oldHourAngle, 14, kColorYellow);
+ _clockHandMinute = calcHand(_oldMinute * 6, 17, kColorYellow);
+ drawHand(_clockHandHour, kColorBrown);
+ drawHand(_clockHandMinute, kColorBrown);
+
+ _clockHandHour = calcHand(_hourAngle, 14, kColorBrown);
+ _clockHandMinute = calcHand(_minute * 6, 17, kColorBrown);
+ drawHand(_clockHandHour, kColorYellow);
+ drawHand(_clockHandMinute, kColorYellow);
+}
+
+void Clock::chime() {
+ // Too high - must be first time around
+ // Mute - skip the sound generation
+ if ((_oldHour == 17717) || (!_vm->_soundFx))
+ return;
+
+ byte hour = _hour % 12;
+ if (hour == 0)
+ hour = 12;
+
+ _vm->_graphics->loadMouse(kCurWait);
+
+ for (int i = 1; i <= hour; i++) {
+ for (int j = 1; j <= 3; j++)
+ _vm->_sound->playNote((i % 3) * 64 + 140 - j * 30, 50 - j * 12);
+ if (i != hour)
+ _vm->_system->delayMillis(100);
+ }
+}
+
+} // End of namespace Avalanche
diff --git a/engines/avalanche/clock.h b/engines/avalanche/clock.h
new file mode 100644
index 0000000000..68e8e119f0
--- /dev/null
+++ b/engines/avalanche/clock.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*/
+
+/*
+* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
+* Copyright (c) 1994-1995 Mike: Mark and Thomas Thurman.
+*/
+
+#ifndef AVALANCHE_CLOCK_H
+#define AVALANCHE_CLOCK_H
+
+#include "common/rect.h"
+#include "avalanche/enums.h"
+
+namespace Avalanche {
+class AvalancheEngine;
+
+class Clock {
+public:
+ Clock(AvalancheEngine *vm);
+
+ void update();
+
+private:
+ static const int kCenterX = 510;
+ static const int kCenterY = 183;
+
+ AvalancheEngine *_vm;
+
+ uint16 _hour, _minute, _second, _hourAngle, _oldHour, _oldMinute, _oldHourAngle;
+ Common::Point _clockHandHour, _clockHandMinute;
+
+ Common::Point calcHand(uint16 angle, uint16 length, Color color);
+ void drawHand(const Common::Point &endPoint, Color color);
+ void plotHands();
+ void chime();
+};
+
+} // End of namespace Avalanche
+
+#endif // AVALANCHE_CLOCK_H
diff --git a/engines/avalanche/module.mk b/engines/avalanche/module.mk
index 0f66bb8213..39ca94e3f8 100644
--- a/engines/avalanche/module.mk
+++ b/engines/avalanche/module.mk
@@ -16,7 +16,8 @@ MODULE_OBJS = \
sequence.o \
sound.o \
timer.o \
- nim.o
+ nim.o \
+ clock.o
# This module can be built as a plugin
ifeq ($(ENABLE_AVALANCHE), DYNAMIC_PLUGIN)