ScummVM API documentation
helpers.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 
22 #ifndef LASTEXPRESS_HELPERS_H
23 #define LASTEXPRESS_HELPERS_H
24 
26 // Misc helpers
28 
29 #define LOW_BYTE(w) ((unsigned char)(((unsigned long)(w)) & 0xff))
30 
31 // Misc
32 #define getArchiveMember(name) _engine->getResourceManager()->getFileStream(name)
33 #define rnd(value) _engine->getRandom().getRandomNumber(value - 1)
34 
35 // Engine subclasses
36 #define getLogic() _engine->getGameLogic()
37 #define getMenu() _engine->getGameMenu()
38 
39 // Logic
40 #define getAction() getLogic()->getGameAction()
41 #define getBeetle() getLogic()->getGameBeetle()
42 #define getFight() getLogic()->getGameFight()
43 #define getEntities() getLogic()->getGameEntities()
44 #define getSaveLoad() getLogic()->getGameSaveLoad()
45 #define isNight() getLogic()->getGameState()->isNightTime()
46 
47 // State
48 #define getState() getLogic()->getGameState()->getGameState()
49 #define getEvent(id) getState()->events[id]
50 #define getFlags() getLogic()->getGameState()->getGameFlags()
51 #define getInventory() getLogic()->getGameState()->getGameInventory()
52 #define getObjects() getLogic()->getGameState()->getGameObjects()
53 #define getProgress() getState()->progress
54 #define getSavePoints() getLogic()->getGameState()->getGameSavePoints()
55 #define getGlobalTimer() getLogic()->getGameState()->getTimer()
56 #define setGlobalTimer(timer) getLogic()->getGameState()->setTimer(timer)
57 #define setCoords(coords) getLogic()->getGameState()->setCoordinates(coords)
58 #define getCoords() getLogic()->getGameState()->getCoordinates()
59 #define getFrameCount() _engine->getFrameCounter()
60 
61 // Scenes
62 #define getScenes() _engine->getSceneManager()
63 
64 // Sound
65 #define getSound() _engine->getSoundManager()
66 #define getSoundQueue() _engine->getSoundManager()->getQueue()
67 
68 // Others
69 #define getEntityData(entity) getEntities()->getData(entity)
70 
72 // Graphics
74 
75 // Sequences
76 #define loadSequence(name) Sequence::load(name, getArchiveMember(name))
77 #define loadSequence1(name, field30) Sequence::load(name, getArchiveMember(name), field30)
78 
79 #define clearBg(type) _engine->getGraphicsManager()->clear(type)
80 #define showScene(index, type) _engine->getGraphicsManager()->draw(getScenes()->get(index), type);
81 
82 #define askForRedraw() _engine->getGraphicsManager()->change()
83 #define redrawScreen() do { _engine->getGraphicsManager()->update(); _engine->_system->updateScreen(); } while (false)
84 
85 // Used to delete entity sequences
86 #define SAFE_DELETE(_p) do { delete (_p); (_p) = NULL; } while (false)
87 
89 // Output
91 extern const char *g_actionNames[];
92 extern const char *g_directionNames[];
93 extern const char *g_entityNames[];
94 
95 #define ACTION_NAME(action) (action > 18 ? Common::String::format("%d", action).c_str() : g_actionNames[action])
96 #define DIRECTION_NAME(direction) (direction >= 6 ? "INVALID" : g_directionNames[direction])
97 #define ENTITY_NAME(index) (index >= 40 ? "INVALID" : g_entityNames[index])
98 
99 
100 #endif // LASTEXPRESS_HELPERS_H