ScummVM API documentation
vcr.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 ASYLUM_PUZZLES_VCR_H
23 #define ASYLUM_PUZZLES_VCR_H
24 
25 #include "asylum/puzzles/puzzle.h"
26 
27 #include "asylum/shared.h"
28 
29 namespace Asylum {
30 
31 class AsylumEngine;
32 
33 typedef struct VCRDrawInfo {
34  int32 resourceId;
35  Common::Point point;
36 } VCRDrawInfo;
37 
38 const int16 puzzleVCRPolygons[10][4] = {
39  {0x0F7, 0x157, 0x13A, 0x183}, // rewind button region
40  {0x14B, 0x15C, 0x17B, 0x18B}, // stop button region
41  {0x18C, 0x161, 0x1D2, 0x18F}, // play button region
42  {0x1FB, 0x156, 0x233, 0x185}, // rec button region
43  {0x154, 0x196, 0x173, 0x1AF}, // red jack hole region
44  {0x19A, 0x19B, 0x1B9, 0x1B3}, // yellow jack hole region
45  {0x1E3, 0x1A0, 0x202, 0x1BC}, // black jack hole region
46  {0x0, 0x19B, 0x3C, 0x1E0}, // black jack on table region
47  {0x4C, 0x1AC, 0x0A0, 0x1E0}, // red jack on table region
48  {0x0BB, 0x1B7, 0x0F0, 0x1E0} // yellow jack on table region
49 };
50 
52 // Puzzle 1
54 class PuzzleVCR : public Puzzle {
55 public:
56  PuzzleVCR(AsylumEngine *engine);
57  ~PuzzleVCR();
58 
59  // Serializable
60  virtual void saveLoadWithSerializer(Common::Serializer &s);
61 
62 private:
63  enum Color {
64  kNone = -1,
65  kBlack = 0,
66  kRed = 1,
67  kYellow = 2
68  };
69 
70  enum JackState {
71  kOnTable = 0,
72  kPluggedOnRed = 1,
73  kPluggedOnYellow = 2,
74  kPluggedOnBlack = 3,
75  kOnHand = 4
76  };
77 
78  enum VCRRegions {
79  kRewindButton = 0,
80  kStopButton = 1,
81  kPlayButton = 2,
82  kPowerButton = 3,
83  kRedHole = 4,
84  kYellowHole = 5,
85  kBlackHole = 6,
86  kBlackJack = 7,
87  kRedJack = 8,
88  kYellowJack = 9
89  };
90 
91  enum ButtonState {
92  kOFF = 0,
93  kON = 1,
94  kDownON = 2,
95  kDownOFF = 3
96  };
97 
98  JackState _jacksState[3];
99  JackState _holesState[3];
100  ButtonState _buttonsState[4];
101  uint32 _tvScreenFrameIndex;
102  bool _isAccomplished;
103 
105  // Event Handling
107  bool init(const AsylumEvent &evt);
108  bool mouseLeftDown(const AsylumEvent &evt);
109  bool mouseLeftUp(const AsylumEvent &evt);
110  bool exitPuzzle();
111 
113  // Drawing
115  void updateScreen();
116  void updateCursor();
117 
119  // Updates
121  void updateJack(Color jack, const VCRDrawInfo &onTable, const VCRDrawInfo &pluggedOnRed, const VCRDrawInfo &pluggedOnYellow, const VCRDrawInfo &pluggedOnBlack, int32 resourceOnHandIndex);
122  void updateBlackJack();
123  void updateRedJack();
124  void updateYellowJack();
125 
126  void updateButton(VCRRegions button, const VCRDrawInfo &btON, const VCRDrawInfo &btDown);
127  void updatePowerButton();
128  void updateRewindButton();
129  void updatePlayButton();
130  void updateStopButton();
131 
132  void updateTVSync();
133 
135  // Helpers
137  int inPolygon(const Common::Point &point, int polyIdx) const;
138  Color getJackOnHand() const;
139  void setJackOnHole(Color hole, JackState state, JackState newState);
140  void pickJack(Color jack);
141 
142 };
143 
144 } // end of namespace Asylum
145 
146 #endif // ASYLUM_PUZZLES_VCR_H
Definition: asylum.h:53
Definition: serializer.h:79
Definition: eventhandler.h:43
Definition: rect.h:45
Definition: asylum.h:73
Definition: vcr.h:54
Definition: puzzle.h:41
Definition: vcr.h:33