ScummVM API documentation
segment.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 TEENAGENT_SEGMENT_H
23 #define TEENAGENT_SEGMENT_H
24 
25 #include "common/stream.h"
26 #include "common/endian.h"
27 
28 namespace TeenAgent {
29 
30 class Segment {
31  uint32 _size;
32  byte *_data;
33 
34 public:
35  Segment() : _size(0), _data(0) {}
36  ~Segment();
37 
38  void read(Common::ReadStream *s, uint32 _size);
39 
40  inline byte get_byte(uint32 offset) const {
41  assert(offset < _size);
42  return _data[offset];
43  }
44 
45  inline uint16 get_word(uint32 offset) const {
46  assert(offset + 1 < _size);
47  return READ_LE_UINT16(_data + offset);
48  }
49 
50  inline void set_byte(uint32 offset, byte v) const {
51  assert(offset < _size);
52  _data[offset] = v;
53  }
54 
55  inline void set_word(uint32 offset, uint16 v) const {
56  assert(offset + 1 < _size);
57  return WRITE_LE_UINT16(_data + offset, v);
58  }
59 
60  const byte *ptr(uint32 addr) const {
61  assert(addr < _size);
62  return _data + addr;
63  }
64 
65  byte *ptr(uint32 addr) {
66  assert(addr < _size);
67  return _data + addr;
68  }
69 
70  uint size() const { return _size; }
71 };
72 
73 } // End of namespace TeenAgent
74 
75 #endif
Definition: segment.h:30
Definition: actor.h:29
Definition: stream.h:385