mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
120 lines
3.1 KiB
C++
120 lines
3.1 KiB
C++
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*
|
|
* Based on the original sources
|
|
* Faery Tale II -- The Halls of the Dead
|
|
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
|
|
*/
|
|
|
|
#ifndef SAGA2_CALENDAR_H
|
|
#define SAGA2_CALENDAR_H
|
|
|
|
namespace Saga2 {
|
|
|
|
/* ===================================================================== *
|
|
CalendarTime class
|
|
* ===================================================================== */
|
|
|
|
class CalendarTime {
|
|
public:
|
|
enum {
|
|
// Basic constants
|
|
kDaysPerWeek = 7,
|
|
kDaysPerYear = 365,
|
|
kHoursPerDay = 24,
|
|
kRealMinutesPerDay = 30,
|
|
|
|
// Number of animation frames per day
|
|
kFramesPerDay = 10 * 60 * kRealMinutesPerDay,
|
|
|
|
// Derived variables
|
|
kFramesPerHour = (kFramesPerDay / kHoursPerDay),
|
|
kFramesAtNoon = (kFramesPerDay / 2),
|
|
|
|
kDayBias = kFramesAtNoon / 6,
|
|
|
|
kGameStartHour = 5
|
|
};
|
|
|
|
uint16 _years,
|
|
_weeks,
|
|
_days,
|
|
_dayInYear,
|
|
_dayInWeek,
|
|
_hour,
|
|
_frameInHour;
|
|
|
|
bool _calendarPaused;
|
|
|
|
CalendarTime() {
|
|
_years = _weeks = _days = _dayInYear = _dayInWeek = _hour = _frameInHour = 0;
|
|
_calendarPaused = false;
|
|
}
|
|
|
|
void read(Common::InSaveFile *in);
|
|
void write(Common::MemoryWriteStreamDynamic *out);
|
|
|
|
void update();
|
|
int lightLevel(int maxLevel);
|
|
|
|
uint16 frameInDay() {
|
|
return _hour * kFramesPerHour + _frameInHour;
|
|
}
|
|
};
|
|
|
|
/* ===================================================================== *
|
|
FrameAlarm class
|
|
* ===================================================================== */
|
|
|
|
class FrameAlarm {
|
|
uint16 _baseFrame,
|
|
_duration;
|
|
public:
|
|
void set(uint16 dur);
|
|
bool check();
|
|
uint16 elapsed();
|
|
|
|
void write(Common::MemoryWriteStreamDynamic *out);
|
|
void read(Common::InSaveFile *in);
|
|
};
|
|
|
|
/* ===================================================================== *
|
|
Calendar management functions
|
|
* ===================================================================== */
|
|
|
|
void updateCalendar();
|
|
void pauseCalendar();
|
|
void resumeCalendar();
|
|
|
|
uint32 operator - (const CalendarTime &time1, const CalendarTime &time2);
|
|
|
|
void initCalendar();
|
|
|
|
void saveCalendar(Common::OutSaveFile *outS);
|
|
void loadCalendar(Common::InSaveFile *in);
|
|
|
|
bool isDayTime();
|
|
|
|
const int MAX_LIGHT = 12; // maximum light level
|
|
|
|
}
|
|
|
|
#endif
|