ScummVM API documentation
convert_shape.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 ULTIMA8_CONVERT_CONVERTSHAPE_H
23 #define ULTIMA8_CONVERT_CONVERTSHAPE_H
24 
25 #include "common/scummsys.h"
26 #include "common/stream.h"
27 
28 namespace Ultima {
29 namespace Ultima8 {
30 
31 
32 // Convert shape C
33 
34 /********** Update AutoShapeFormat in shapeconv/ShapeConv.cpp when changed! **********/
36  const char * _name;
37  // U8 U8 Gump U8.SKF Cru Cru2D Pent Comp
38  uint32 _len_header; // 6 6 2 6 6 8 11
39  const char * _ident; // "" "" "\2\0" "" "" "PSHP" ""
40  uint32 _bytes_ident; // 0 0 2 0 0 4 0
41  uint32 _bytes_special; // 0 0 0 0 0 0 5
42  uint32 _bytes_header_unk; // 4 4 0 4 4 0 4
43  uint32 _bytes_num_frames; // 2 2 0 2 2 4 2
44 
45  uint32 _len_frameheader; // 6 6 0 8 8 8 6
46  uint32 _bytes_frame_offset; // 3 3 0 3 3 4 4
47  uint32 _bytes_frameheader_unk; // 1 2 0 2 2 0 0
48  uint32 _bytes_frame_length; // 2 2 0 3 3 4 2
49  uint32 _bytes_frame_length_kludge; // 0 8 0 0 0 0 0
50 
51  uint32 _len_frameheader2; // 18 18 10 28 20 20 10
52  uint32 _bytes_frame_unknown; // 8 8 0 8 0 0 0
53  uint32 _bytes_frame_compression; // 2 2 2 4 4 4 2
54  uint32 _bytes_frame_width; // 2 2 2 4 4 4 2
55  uint32 _bytes_frame_height; // 2 2 2 4 4 4 2
56  uint32 _bytes_frame_xoff; // 2 2 2 4 4 4 2
57  uint32 _bytes_frame_yoff; // 2 2 2 4 4 4 2
58 
59  uint32 _bytes_line_offset; // 2 2 2 4 4 4 0
60  uint32 _line_offset_absolute; // 0 0 0 0 0 1 0
61 };
62 
63 // ConvertShapeFrame structure
64 
66  uint8 _header_unknown[2];
67 
68  uint8 _unknown[8];
69  uint32 _compression;
70  int32 _width;
71  int32 _height;
72  int32 _xoff;
73  int32 _yoff;
74 
75  uint32 *_line_offsets; // Note these are offsets into rle_data
76 
77  int32 _bytes_rle; // Number of bytes of RLE Data
78  uint8 *_rle_data;
79 
80  void Free();
81 
82  void Read(Common::SeekableReadStream &source, const ConvertShapeFormat *csf, uint32 frame_length);
83 
84  void ReadCmpFrame(Common::SeekableReadStream &source, const ConvertShapeFormat *csf, const uint8 special[256], ConvertShapeFrame *prev);
85 
86  void GetPixels(uint8 *buf, int32 count, int32 x, int32 y);
87 };
88 
89 
90 // ConvertShape structure
91 
93 {
94  uint8 _header_unknown[4];
95  uint32 _num_frames;
96  ConvertShapeFrame *_frames;
97 
98 public:
99  ConvertShape();
100 
101  ~ConvertShape()
102  {
103  Free();
104  }
105 
106  void Free();
107 
108  void Read(Common::SeekableReadStream &source, const ConvertShapeFormat *csf, uint32 real_len);
109  void Write(Common::SeekableWriteStream &source, const ConvertShapeFormat *csf, uint32 &write_len);
110 
111  // This will check to see if a Shape is of a certain type. Return true if ok, false if bad
112  static bool Check(Common::SeekableReadStream &source, const ConvertShapeFormat *csf, uint32 real_len);
113 
114  // This will also check to see if a shape is of a certain type. However it won't check
115  // the rle data, it only checks headers. Return true if ok, false if bad
116  static bool CheckUnsafe(Common::SeekableReadStream &source, const ConvertShapeFormat *csf, uint32 real_len);
117 
118  // Algorithmically calculate the number of frames
119  static int CalcNumFrames(Common::SeekableReadStream &source, const ConvertShapeFormat *csf, uint32 real_len, uint32 start_pos);
120 };
121 
122 // Shape format configuration for Pentagram format
123 extern const ConvertShapeFormat PentagramShapeFormat;
124 
125 } // End of namespace Ultima8
126 } // End of namespace Ultima
127 
128 #endif
Definition: convert_shape.h:92
Definition: convert_shape.h:65
Definition: convert_shape.h:35
Definition: stream.h:745
Definition: detection.h:27
Definition: stream.h:351