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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef SCI_ENGINE_SELECTOR_H 24 #define SCI_ENGINE_SELECTOR_H 25 26 #include "common/scummsys.h" 27 28 #include "sci/engine/vm_types.h" // for reg_t 29 #include "sci/engine/vm.h" 30 31 namespace Sci { 32 33 /** Contains selector IDs for a few selected selectors */ 34 struct SelectorCache { SelectorCacheSelectorCache35 SelectorCache() { 36 memset(this, 0, sizeof(*this)); 37 } 38 39 // Statically defined selectors, (almost the) same in all SCI versions 40 Selector _info_; ///< Removed in SCI3 41 Selector y; 42 Selector x; 43 Selector view, loop, cel; ///< Description of a specific image 44 Selector underBits; ///< Used by the graphics subroutines to store backupped BG pic data 45 Selector nsTop, nsLeft, nsBottom, nsRight; ///< View boundaries ('now seen') 46 Selector lsTop, lsLeft, lsBottom, lsRight; ///< Used by Animate() subfunctions and scroll list controls 47 Selector signal; ///< Used by Animate() to control a view's behavior 48 Selector illegalBits; ///< Used by CanBeHere 49 Selector brTop, brLeft, brBottom, brRight; ///< Bounding Rectangle 50 // name, key, time 51 Selector text; ///< Used by controls 52 Selector elements; ///< Used by SetSynonyms() 53 // color, back 54 Selector mode; ///< Used by text controls (-> DrawControl()) 55 // style 56 Selector state, font, type;///< Used by controls 57 // window 58 Selector cursor; ///< Used by EditControl 59 Selector max; ///< Used by EditControl, removed in SCI3 60 Selector mark; //< Used by list controls (script internal, is needed by us for the QfG import rooms) 61 Selector sort; //< Used by list controls (script internal, is needed by us for QfG3 import room) 62 // who 63 Selector message; ///< Used by GetEvent 64 // edit 65 Selector play; ///< Play function (first function to be called) 66 Selector restore; 67 Selector number; 68 Selector handle; ///< Replaced by nodePtr in SCI1+ 69 Selector nodePtr; ///< Replaces handle in SCI1+ 70 Selector client; ///< The object that wants to be moved 71 Selector dx, dy; ///< Deltas 72 Selector b_movCnt, b_i1, b_i2, b_di, b_xAxis, b_incr; ///< Various Bresenham vars 73 Selector xStep, yStep; ///< BR adjustments 74 Selector xLast, yLast; ///< BR last position of client 75 Selector moveSpeed; ///< Used for DoBresen 76 Selector canBeHere; ///< Funcselector: Checks for movement validity in SCI0 77 Selector heading, mover; ///< Used in DoAvoider 78 Selector doit; ///< Called (!) by the Animate() system call 79 Selector isBlocked, looper; ///< Used in DoAvoider 80 Selector priority; 81 Selector modifiers; ///< Used by GetEvent 82 Selector replay; ///< Replay function 83 // setPri, at, next, done, width 84 Selector wordFail, syntaxFail; ///< Used by Parse() 85 // semanticFail, pragmaFail 86 // said 87 Selector claimed; ///< Used generally by the event mechanism 88 // value, save, restore, title, button, icon, draw 89 Selector delete_; ///< Called by Animate() to dispose a view object 90 Selector z; 91 Selector setPri; 92 93 // SCI1+ static selectors 94 Selector parseLang; 95 Selector printLang; ///< Used for i18n 96 Selector subtitleLang; 97 Selector size; 98 Selector points; ///< Used by AvoidPath() 99 Selector palette; ///< Used by the SCI0-SCI1.1 animate code, unused in SCI2-SCI2.1, removed in SCI3 100 Selector dataInc; ///< Used to sync music with animations, removed in SCI3 101 // handle (in SCI1) 102 Selector min; ///< SMPTE time format 103 Selector sec; 104 Selector frame; 105 Selector vol; 106 Selector pri; 107 // perform 108 Selector moveDone; ///< used for DoBresen 109 110 // SCI1 selectors which have been moved a bit in SCI1.1, but otherwise static 111 Selector cantBeHere; ///< Checks for movement avoidance in SCI1+. Replaces canBeHere 112 Selector topString; ///< SCI1 scroll lists use this instead of lsTop. Removed in SCI3 113 Selector flags; 114 115 // SCI1+ audio sync related selectors, not static. They're used for lip syncing in 116 // CD talkie games 117 Selector syncCue; ///< Used by DoSync() 118 Selector syncTime; 119 120 // SCI1.1 specific selectors 121 Selector scaleSignal; //< Used by kAnimate() for cel scaling (SCI1.1+) 122 Selector scaleX, scaleY; ///< SCI1.1 view scaling 123 Selector maxScale; ///< SCI1.1 view scaling, limit for cel, when using global scaling 124 Selector vanishingX; ///< SCI1.1 view scaling, used by global scaling 125 Selector vanishingY; ///< SCI1.1 view scaling, used by global scaling 126 127 // Used for auto detection purposes 128 Selector overlay; ///< Used to determine if a game is using old gfx functions or not 129 130 // SCI1.1 Mac icon bar selectors 131 Selector iconIndex; ///< Used to index icon bar objects 132 Selector select; 133 134 Selector handsOff; 135 Selector setStep; 136 Selector setMotion; 137 Selector cycleSpeed; 138 Selector owner; 139 140 #ifdef ENABLE_SCI32 141 Selector data; // Used by Array()/String() 142 Selector picture; // Used to hold the picture ID for SCI32 pictures 143 Selector bitmap; // Used to hold the text bitmap for SCI32 texts 144 145 Selector plane; 146 Selector top, left, bottom, right; 147 Selector resX, resY; 148 149 Selector fore; 150 Selector back; 151 Selector skip; 152 Selector dimmed; 153 Selector borderColor; 154 Selector width; 155 156 Selector fixPriority; 157 Selector mirrored; 158 Selector visible; 159 160 Selector seenRect; 161 Selector useInsetRect; 162 Selector inTop, inLeft, inBottom, inRight; 163 Selector textTop, textLeft, textBottom, textRight; 164 Selector title, titleFont, titleFore, titleBack; 165 166 Selector magnifier; 167 Selector frameOut; 168 Selector casts; // needed for sync'ing screen items/planes with scripts, when our save/restore code is patched in (see GfxFrameout::syncWithScripts) 169 Selector setVol; // for GK2 volume sync on restore 170 Selector reSyncVol; // for Torin volume sync on restore 171 Selector set; // for LSL6hires subtitle sync 172 Selector clear; // for LSL6hires subtitle sync 173 Selector curPos; // for LSL6hires volume sync 174 Selector update; // for LSL6hires volume sync 175 Selector show; // for GK1 volume sync 176 Selector position; // for GK1 volume sync 177 Selector musicVolume; // for GK1 volume sync 178 Selector soundVolume; // for GK1 volume sync 179 Selector initialOff; // for GK2 volume sync 180 Selector setPos; // for Torin volume sync 181 Selector setSize; // for PQ4 volume sync 182 Selector displayValue; // for PQ:SWAT volume sync 183 Selector new_; // for Torin/LSL7 save/load patching 184 Selector mainCel; // for MGDX volume sync 185 Selector move; // for Phant2 volume sync 186 Selector eachElementDo; // for Phant2 volume sync 187 Selector physicalBar; // for Phant2 volume sync 188 Selector init; // for Phant2 save/load patching 189 Selector scratch; // for Phant2 save/load patching 190 Selector num; // for Phant2 restore from launcher 191 Selector reallyRestore; // for Phant2 restore from launcher 192 Selector bookMark; // for Phant2 auto-save 193 Selector fileNumber; // for RAMA save/load 194 Selector description; // for RAMA save/load 195 Selector dispose; // for RAMA save/load save from launcher 196 Selector masterVolume; // for RAMA volume sync 197 Selector setCel; // for RAMA volume sync 198 Selector value; // for QFG4 import dialog 199 #endif 200 }; 201 202 /** 203 * Map a selector name to a selector id. Shortcut for accessing the selector cache. 204 */ 205 #define SELECTOR(_slc_) (g_sci->getKernel()->_selectorCache._slc_) 206 207 /** 208 * Retrieves a selector from an object. 209 * @param segMan the segment mananger 210 * @param _obj_ the address of the object which the selector should be read from 211 * @param _slc_ the selector to refad 212 * @return the selector value as a reg_t 213 * This macro halts on error. 'selector' must be a selector name registered in vm.h's 214 * SelectorCache and mapped in script.cpp. 215 */ 216 reg_t readSelector(SegManager *segMan, reg_t object, Selector selectorId); 217 #define readSelectorValue(segMan, _obj_, _slc_) (readSelector(segMan, _obj_, _slc_).getOffset()) 218 219 /** 220 * Writes a selector value to an object. 221 * @param segMan the segment mananger 222 * @param _obj_ the address of the object which the selector should be written to 223 * @param _slc_ the selector to read 224 * @param _val_ the value to write 225 * This macro halts on error. 'selector' must be a selector name registered in vm.h's 226 * SelectorCache and mapped in script.cpp. 227 */ 228 void writeSelector(SegManager *segMan, reg_t object, Selector selectorId, reg_t value); 229 #define writeSelectorValue(segMan, _obj_, _slc_, _val_) writeSelector(segMan, _obj_, _slc_, make_reg(0, _val_)) 230 231 /** 232 * Invokes a selector from an object. 233 */ 234 void invokeSelector(EngineState *s, reg_t object, int selectorId, 235 int k_argc, StackPtr k_argp, int argc = 0, const reg_t *argv = 0); 236 237 #ifdef ENABLE_SCI32 238 /** 239 * SCI32 set kInfoFlagViewVisible in the -info- selector if a certain 240 * range of properties was written to. 241 * This function checks if index is in the right range, and sets the flag 242 * on obj.-info- if it is. 243 */ 244 void updateInfoFlagViewVisible(Object *obj, int index, bool fromPropertyOp = false); 245 #endif 246 247 } // End of namespace Sci 248 249 #endif // SCI_ENGINE_KERNEL_H 250