ScummVM API documentation
calendar.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 * Based on the original sources
22 * Faery Tale II -- The Halls of the Dead
23 * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24 */
25
26#ifndef SAGA2_CALENDAR_H
27#define SAGA2_CALENDAR_H
28
29namespace Saga2 {
30
31/* ===================================================================== *
32 CalendarTime class
33 * ===================================================================== */
34
36public:
37 enum {
38 // Basic constants
39 kDaysPerWeek = 7,
40 kDaysPerYear = 365,
41 kHoursPerDay = 24,
42 kRealMinutesPerDay = 30,
43
44 // Number of animation frames per day
45 kFramesPerDay = 10 * 60 * kRealMinutesPerDay,
46
47 // Derived variables
48 kFramesPerHour = (kFramesPerDay / kHoursPerDay),
49 kFramesAtNoon = (kFramesPerDay / 2),
50
51 kDayBias = kFramesAtNoon / 6,
52
53 kGameStartHour = 5
54 };
55
56 uint16 _years,
57 _weeks,
58 _days,
59 _dayInYear,
60 _dayInWeek,
61 _hour,
62 _frameInHour;
63
64 bool _calendarPaused;
65
66 CalendarTime() {
67 _years = _weeks = _days = _dayInYear = _dayInWeek = _hour = _frameInHour = 0;
68 _calendarPaused = false;
69 }
70
71 void read(Common::InSaveFile *in);
72 void write(Common::MemoryWriteStreamDynamic *out);
73
74 void update();
75 int lightLevel(int maxLevel);
76
77 uint16 frameInDay() {
78 return _hour * kFramesPerHour + _frameInHour;
79 }
80};
81
82/* ===================================================================== *
83 FrameAlarm class
84 * ===================================================================== */
85
87 uint16 _baseFrame,
88 _duration;
89public:
90 void set(uint16 dur);
91 bool check();
92 uint16 elapsed();
93
94 void write(Common::MemoryWriteStreamDynamic *out);
95 void read(Common::InSaveFile *in);
96};
97
98/* ===================================================================== *
99 Calendar management functions
100 * ===================================================================== */
101
102void updateCalendar();
103void pauseCalendar();
104void resumeCalendar();
105
106uint32 operator - (const CalendarTime &time1, const CalendarTime &time2);
107
108void initCalendar();
109
110void saveCalendar(Common::OutSaveFile *outS);
111void loadCalendar(Common::InSaveFile *in);
112
113bool isDayTime();
114
115const int MAX_LIGHT = 12; // maximum light level
116
117}
118
119#endif
Definition: memstream.h:194
Definition: savefile.h:54
Definition: stream.h:745
Definition: calendar.h:35
Definition: calendar.h:86