RCS file: /cvsroot/scummvm/scummvm/scumm/smush/chunk.cpp,v
retrieving revision 1.36
diff -u -d -r1.36 chunk.cpp
|
|
|
85 | 85 | return true; |
86 | 86 | } |
87 | 87 | |
88 | | FileChunk::FileChunk(const Common::String &name, int offset) |
89 | | : _name(name) { |
90 | | if (!g_scumm->openFile(_data, name.c_str())) |
| 88 | FileChunk::FileChunk(ScummFile *data, int offset) { |
| 89 | _data = data; |
| 90 | _deleteData = false; |
| 91 | |
| 92 | _data->seek(offset, seek_start); |
| 93 | _type = _data->readUint32BE(); |
| 94 | _size = _data->readUint32BE(); |
| 95 | _offset = _data->pos(); |
| 96 | _curPos = 0; |
| 97 | } |
| 98 | |
| 99 | FileChunk::FileChunk(const Common::String &name, int offset) { |
| 100 | _data = new ScummFile(); |
| 101 | _deleteData = true; |
| 102 | if (!g_scumm->openFile(*_data, name.c_str())) |
91 | 103 | error("FileChunk: Unable to open file %s", name.c_str()); |
92 | 104 | |
93 | | _data.seek(offset); |
94 | | _type = _data.readUint32BE(); |
95 | | _size = _data.readUint32BE(); |
96 | | _offset = _data.pos(); |
| 105 | _data->seek(offset, seek_start); |
| 106 | _type = _data->readUint32BE(); |
| 107 | _size = _data->readUint32BE(); |
| 108 | _offset = _data->pos(); |
97 | 109 | _curPos = 0; |
98 | 110 | } |
99 | 111 | |
100 | 112 | FileChunk::~FileChunk() { |
| 113 | if (_deleteData) |
| 114 | delete _data; |
101 | 115 | } |
102 | 116 | |
103 | 117 | Chunk *FileChunk::subBlock() { |
104 | | FileChunk *ptr = new FileChunk(_name, _offset + _curPos); |
105 | | _data.seek(_offset + _curPos + sizeof(Chunk::type) + sizeof(uint32)); |
| 118 | FileChunk *ptr = new FileChunk(_data, _offset + _curPos); |
106 | 119 | seek(sizeof(Chunk::type) + sizeof(uint32) + ptr->getSize()); |
107 | 120 | return ptr; |
108 | 121 | } |
109 | 122 | |
| 123 | void FileChunk::reseek() { |
| 124 | _data->seek(_offset + _curPos); |
| 125 | } |
| 126 | |
110 | 127 | bool FileChunk::read(void *buffer, uint32 size) { |
111 | 128 | if (size <= 0 || (_curPos + size) > _size) |
112 | 129 | error("invalid buffer read request"); |
113 | 130 | |
114 | | // _data.seek(_offset + _curPos); |
115 | | _data.read(buffer, size); |
| 131 | _data->read(buffer, size); |
116 | 132 | _curPos += size; |
117 | 133 | return true; |
118 | 134 | } |
… |
… |
|
122 | 138 | } |
123 | 139 | |
124 | 140 | byte FileChunk::getByte() { |
125 | | // _data.seek(_offset + _curPos); |
126 | 141 | _curPos++; |
127 | 142 | |
128 | 143 | if (_curPos > _size) |
129 | 144 | error("invalid byte read request"); |
130 | 145 | |
131 | | return _data.readByte(); |
| 146 | return _data->readByte(); |
132 | 147 | } |
133 | 148 | |
134 | 149 | int16 FileChunk::getShort() { |
… |
… |
|
136 | 151 | } |
137 | 152 | |
138 | 153 | uint16 FileChunk::getWord() { |
139 | | // _data.seek(_offset + _curPos); |
140 | 154 | _curPos += 2; |
141 | 155 | |
142 | 156 | if (_curPos > _size) |
143 | 157 | error("invalid word read request"); |
144 | 158 | |
145 | | return _data.readUint16LE(); |
| 159 | return _data->readUint16LE(); |
146 | 160 | } |
147 | 161 | |
148 | 162 | uint32 FileChunk::getDword() { |
149 | | // _data.seek(_offset + _curPos); |
150 | 163 | _curPos += 4; |
151 | 164 | |
152 | 165 | if (_curPos > _size) |
153 | 166 | error("invalid dword read request"); |
154 | 167 | |
155 | | return _data.readUint32LE(); |
| 168 | return _data->readUint32LE(); |
156 | 169 | } |
157 | 170 | |
158 | 171 | MemoryChunk::MemoryChunk(byte *data) { |
… |
… |
|
171 | 184 | return ptr; |
172 | 185 | } |
173 | 186 | |
| 187 | void MemoryChunk::reseek() { |
| 188 | } |
| 189 | |
174 | 190 | bool MemoryChunk::read(void *buffer, uint32 size) { |
175 | 191 | if (size <= 0 || (_curPos + size) > _size) |
176 | 192 | error("invalid buffer read request"); |
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/chunk.h,v
retrieving revision 1.19
diff -u -d -r1.19 chunk.h
|
|
|
39 | 39 | virtual type getType() const = 0; |
40 | 40 | virtual uint32 getSize() const = 0; |
41 | 41 | virtual Chunk *subBlock() = 0; |
| 42 | virtual void reseek() = 0; |
42 | 43 | virtual bool eof() const = 0; |
43 | 44 | virtual uint32 tell() const = 0; |
44 | 45 | virtual bool seek(int32 delta, seek_type dir = seek_cur) = 0; |
… |
… |
|
47 | 48 | virtual byte getByte() = 0; |
48 | 49 | virtual int16 getShort() = 0; |
49 | 50 | virtual uint16 getWord() = 0; |
50 | | virtual uint32 getDword()= 0; |
| 51 | virtual uint32 getDword() = 0; |
51 | 52 | }; |
52 | 53 | |
53 | 54 | // Common functionality for concrete chunks (FileChunk, MemoryChunk) |
… |
… |
|
69 | 70 | |
70 | 71 | class FileChunk : public BaseChunk { |
71 | 72 | private: |
72 | | Common::String _name; |
73 | | ScummFile _data; |
| 73 | ScummFile *_data; |
| 74 | bool _deleteData; |
74 | 75 | uint32 _offset; |
75 | 76 | |
| 77 | FileChunk(ScummFile *data, int offset); |
76 | 78 | public: |
77 | 79 | FileChunk(const Common::String &name, int offset = 0); |
78 | 80 | virtual ~FileChunk(); |
79 | 81 | Chunk *subBlock(); |
| 82 | void reseek(); |
80 | 83 | bool read(void *buffer, uint32 size); |
81 | 84 | int8 getChar(); |
82 | 85 | byte getByte(); |
… |
… |
|
92 | 95 | public: |
93 | 96 | MemoryChunk(byte *data); |
94 | 97 | Chunk *subBlock(); |
| 98 | void reseek(); |
95 | 99 | bool read(void *buffer, uint32 size); |
96 | 100 | int8 getChar(); |
97 | 101 | byte getByte(); |
RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
retrieving revision 1.170
diff -u -d -r1.170 smush_player.cpp
|
|
|
892 | 892 | |
893 | 893 | while (!b.eof()) { |
894 | 894 | Chunk *sub = b.subBlock(); |
895 | | if (sub->getSize() & 1) b.seek(1); |
896 | 895 | switch (sub->getType()) { |
897 | 896 | case TYPE_NPAL: |
898 | 897 | handleNewPalette(*sub); |
… |
… |
|
942 | 941 | default: |
943 | 942 | error("Unknown frame subChunk found : %s, %d", Chunk::ChunkString(sub->getType()), sub->getSize()); |
944 | 943 | } |
| 944 | |
| 945 | b.reseek(); |
| 946 | if (sub->getSize() & 1) |
| 947 | b.seek(1); |
| 948 | |
945 | 949 | delete sub; |
946 | 950 | } |
947 | 951 | |
… |
… |
|
1085 | 1089 | } |
1086 | 1090 | delete sub; |
1087 | 1091 | |
| 1092 | _base->reseek(); |
| 1093 | |
1088 | 1094 | if (_insanity) |
1089 | 1095 | _vm->_sound->processSound(); |
1090 | 1096 | |