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