/* 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 2 * 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, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ /* * This code is based on original Sfinx source code * Copyright (c) 1994-1997 Janus B. Wisniewski and L.K. Avalon */ #ifndef CGE2_SNAIL_H #define CGE2_SNAIL_H #include "cge2/cge2.h" namespace CGE2 { #define kCommandFrameRate 80 #define kCommandFrameDelay (1000 / kCommandFrameRate) #define kNoByte -1 // Recheck this! We have no proof for it's original value. enum CommandType { kCmdCom0 = 128, kCmdNop, // NOP :: do nothing kCmdUse, // USE | :: hint for using kCmdPause, // PAUSE -1 :: delay /72 seconds kCmdInf, // INF -1 :: show text referrenced by kCmdCave, // CAVE -1 :: go to board kCmdSetX, // SETX :: set sprite shift in x axis kCmdSetY, // SETX :: set sprite shift in y axis kCmdSetZ, // SETX :: set sprite shift in z axis kCmdAdd, // ADD :: sum vectors kCmdFlash, // FLASH -1 0|1 :: lighten whole image (on/off) kCmdCycle, // CYCLE :: rotate colors from 1 kCmdClear, // CLEAR -1 0 :: clear kCmdAIL queue kCmdMouse, // MOUSE -1 0|1 :: enable mouse (on/off) kCmdMap, // MAP 0|1 0 :: temporarily turn off map for hero kCmdMidi, // MIDI -1 :: play MIDI referenced by (-1 = off) kCmdSpr, kCmdWait, // WAIT |-1 :: wait for SEQ (-1 = freeze) kCmdHide, // HIDE 0|1 :: visibility of sprite kCmdRoom, // ROOM 0|1 :: additional room in pocket (no/yes) kCmdSay, // SAY :: say text referenced by kCmdSound, // SOUND :: play sound effect referenced by kCmdKill, // KILL 0 :: remove sprite kCmdRSeq, // RSEQ :: relative jump SEQ lines kCmdSeq, // SEQ :: jump to certain SEQ kCmdSend, // SEND :: move sprite to board kCmdSwap, // SWAP spr2> :: sprite exchange kCmdKeep, // KEEP :: take sprite into pocket and jump to kCmdGive, // GIVE :: remove sprite from pocket and jump to kCmdGetPos, // GETPOS :: take sprite's position kCmdGoto, // GOTO :: move sprite to position kCmdPort, // PORT 0|1 :: clear/set "takeability" of sprite kCmdNext, // NEXT :: jump to - NEAR or TAKE kCmdNNext, // NNEXT :: jump to - NEAR kCmdMTNext, // MTNEXT :: jump to - TAKE kCmdFTNext, // FTNEXT :: jump to - TAKE kCmdRNNext, // RNNEXT :: relative jump to - NEAR kCmdRMTNext, // RMTNEXT :: relative jump to - TAKE kCmdRFTNext, // RFTNEXT :: relative jump to - TAKE kCmdRMNear, // RMNEAR 0 :: remove NEAR list kCmdRMMTake, // RMMTAKE 0 :: remove TAKE list kCmdRMFTake, // RMFTAKE 0 :: remove TAKE list kCmdSetRef, // SETREF :: change reference of sprite to kCmdWalk, // WALKTO | :: go close to the sprite or point kCmdReach, // REACH | :: reach the sprite or point with method kCmdCover, // COVER :: cover sprite with sprite kCmdUncover, // UNCOVER :: restore the state before COVER kCmdExec, kCmdGhost }; class CommandHandler { public: struct Command { CommandType _commandType; byte _lab; int _ref; int _val; void *_spritePtr; CallbackType _cbType; } *_commandList; static const char *_commandText[]; bool _talkEnable; CommandHandler(CGE2Engine *vm, bool turbo); ~CommandHandler(); void runCommand(); void addCommand(CommandType com, int ref, int val, void *ptr); void addCallback(CommandType com, int ref, int val, CallbackType cbType); void insertCommand(CommandType com, int ref, int val, void *ptr); bool idle(); void clear(); int getComId(const char *com); const char *getComStr(CommandType cmdType); private: CGE2Engine *_vm; bool _turbo; uint8 _head; uint8 _tail; bool _textDelay; uint32 _timerExpiry; // "pause" in the original. }; } // End of namespace CGE2 #endif