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 /* 24 * This code is based on original Sfinx source code 25 * Copyright (c) 1994-1997 Janusz B. Wisniewski and L.K. Avalon 26 */ 27 28 #ifndef CGE2_SNAIL_H 29 #define CGE2_SNAIL_H 30 31 #include "cge2/cge2.h" 32 33 namespace CGE2 { 34 35 #define kCommandFrameRate 80 36 #define kCommandFrameDelay (1000 / kCommandFrameRate) 37 #define kNoByte -1 // Recheck this! We have no proof for it's original value. 38 39 40 enum CommandType { 41 kCmdCom0 = 128, 42 kCmdNop, // NOP :: do nothing 43 kCmdUse, // USE <spr> <cav>|<lab> :: hint for using 44 kCmdPause, // PAUSE -1 <dly> :: delay <dly>/72 seconds 45 kCmdInf, // INF -1 <ref> :: show text referrenced by <ref> 46 kCmdCave, // CAVE -1 <cav> :: go to board <cav> 47 kCmdSetX, // SETX <x> <idx> :: set sprite shift in x axis 48 kCmdSetY, // SETX <y> <idx> :: set sprite shift in y axis 49 kCmdSetZ, // SETX <z> <idx> :: set sprite shift in z axis 50 kCmdAdd, // ADD <idx1> <idx2> :: sum vectors 51 kCmdFlash, // FLASH -1 0|1 :: lighten whole image (on/off) 52 kCmdCycle, // CYCLE <cnt> :: rotate <cnt> colors from 1 53 kCmdClear, // CLEAR -1 0 :: clear kCmdAIL queue 54 kCmdMouse, // MOUSE -1 0|1 :: enable mouse (on/off) 55 kCmdMap, // MAP 0|1 0 :: temporarily turn off map for hero 56 kCmdMidi, // MIDI -1 <midi> :: play MIDI referenced by <midi> (-1 = off) 57 58 kCmdSpr, 59 60 kCmdWait, // WAIT <spr> <seq>|-1 :: wait for SEQ <seq> (-1 = freeze) 61 kCmdHide, // HIDE <spr> 0|1 :: visibility of sprite 62 kCmdRoom, // ROOM <hero> 0|1 :: additional room in pocket (no/yes) 63 kCmdSay, // SAY <spr> <ref> :: say text referenced by <ref> 64 kCmdSound, // SOUND <spr> <ref> :: play sound effect referenced by <ref> 65 kCmdKill, // KILL <spr> 0 :: remove sprite 66 kCmdRSeq, // RSEQ <spr> <nr> :: relative jump SEQ <nr> lines 67 kCmdSeq, // SEQ <spr> <seq> :: jump to certain SEQ 68 kCmdSend, // SEND <spr> <cav> :: move sprite to board <cav> 69 kCmdSwap, // SWAP <spr1> spr2> :: sprite exchange 70 kCmdKeep, // KEEP <spr> <seq> :: take sprite into pocket and jump to <seq> 71 kCmdGive, // GIVE <spr> <seq> :: remove sprite from pocket and jump to <seq> 72 kCmdGetPos, // GETPOS <spr> <idx> :: take sprite's position 73 kCmdGoto, // GOTO <spr> <idx> :: move sprite to position 74 kCmdPort, // PORT <spr> 0|1 :: clear/set "takeability" of sprite 75 kCmdNext, // NEXT <spr> <nr> :: jump to <nr> - NEAR or TAKE 76 kCmdNNext, // NNEXT <spr> <nr> :: jump to <nr> - NEAR 77 kCmdMTNext, // MTNEXT <spr> <nr> :: jump to <nr> - TAKE 78 kCmdFTNext, // FTNEXT <spr> <nr> :: jump to <nr> - TAKE 79 kCmdRNNext, // RNNEXT <spr> <nr> :: relative jump to <nr> - NEAR 80 kCmdRMTNext, // RMTNEXT <spr> <nr> :: relative jump to <nr> - TAKE 81 kCmdRFTNext, // RFTNEXT <spr> <nr> :: relative jump to <nr> - TAKE 82 kCmdRMNear, // RMNEAR <spr> 0 :: remove NEAR list 83 kCmdRMMTake, // RMMTAKE <spr> 0 :: remove TAKE list 84 kCmdRMFTake, // RMFTAKE <spr> 0 :: remove TAKE list 85 kCmdSetRef, // SETREF <spr> <ref> :: change reference of sprite <spr> to <ref> 86 kCmdWalk, // WALKTO <hero> <ref>|<point> :: go close to the sprite or point 87 kCmdReach, // REACH <hero> <ref>|<m> :: reach the sprite or point with <m> method 88 kCmdCover, // COVER <sp1> <sp2> :: cover sprite <sp1> with sprite <sp2> 89 kCmdUncover, // UNCOVER <sp1> <sp2> :: restore the state before COVER 90 91 kCmdExec, 92 kCmdGhost 93 }; 94 95 class CommandHandler { 96 public: 97 struct Command { 98 CommandType _commandType; 99 byte _lab; 100 int _ref; 101 int _val; 102 void *_spritePtr; 103 CallbackType _cbType; 104 } *_commandList; 105 static const char *_commandText[]; 106 bool _talkEnable; 107 108 CommandHandler(CGE2Engine *vm, bool turbo); 109 ~CommandHandler(); 110 void runCommand(); 111 void addCommand(CommandType com, int ref, int val, void *ptr); 112 void addCallback(CommandType com, int ref, int val, CallbackType cbType); 113 void insertCommand(CommandType com, int ref, int val, void *ptr); 114 bool idle(); 115 void clear(); 116 int getComId(const char *com); 117 const char *getComStr(CommandType cmdType); 118 private: 119 CGE2Engine *_vm; 120 bool _turbo; 121 uint8 _head; 122 uint8 _tail; 123 bool _textDelay; 124 uint32 _timerExpiry; // "pause" in the original. 125 }; 126 127 } // End of namespace CGE2 128 129 #endif 130