~ubuntu-branches/debian/jessie/scummvm/jessie

« back to all changes in this revision

Viewing changes to common/macresman.h

  • Committer: Bazaar Package Importer
  • Author(s): Moritz Muehlenhoff
  • Date: 2010-05-07 18:57:09 UTC
  • mto: This revision was merged to the branch mainline in revision 18.
  • Revision ID: james.westby@ubuntu.com-20100507185709-34v8yycywjrou5o3
Tags: upstream-1.1.1
ImportĀ upstreamĀ versionĀ 1.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
8
 * modify it under the terms of the GNU General Public License
 
9
 * as published by the Free Software Foundation; either version 2
 
10
 * of the License, or (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, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
20
 *
 
21
 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-1-1/common/macresman.h $
 
22
 * $Id: macresman.h 47258 2010-01-11 20:41:07Z sev $
 
23
 *
 
24
 */
 
25
 
 
26
#include "common/array.h"
 
27
#include "common/file.h"
 
28
 
 
29
#ifndef COMMON_MACRESMAN_H
 
30
#define COMMON_MACRESMAN_H
 
31
 
 
32
namespace Common {
 
33
 
 
34
typedef Common::Array<int16> MacResIDArray;
 
35
 
 
36
/**
 
37
 * Class for reading Mac Binary files.
 
38
 * Is able to read dumped resource forks too.
 
39
 */
 
40
class MacResManager {
 
41
 
 
42
public:
 
43
        MacResManager(Common::String fileName);
 
44
        ~MacResManager();
 
45
 
 
46
        /**
 
47
         * Read resource from the Mac Binary file
 
48
         * @param typeID FourCC with type ID
 
49
         * @param resID Resource ID to fetch
 
50
         * @param size Pointer to int where loaded data size will be stored
 
51
         * @return Pointer to memory with loaded resource. Malloc()'ed
 
52
         */
 
53
        byte *getResource(const char *typeID, int16 resID, int *size);
 
54
 
 
55
        char *getResName(const char *typeID, int16 resID);
 
56
        /**
 
57
         * Convert cursor from Mac format to format suitable for feeding to CursorMan
 
58
         * @param data Pointer to the cursor data
 
59
         * @param datasize Size of the cursor data
 
60
         * @param cursor Pointer to memory where result cursor will be stored. The memory
 
61
         *               block will be malloc()'ed
 
62
         * @param w Pointer to int where the cursor width will be stored
 
63
         * @param h Pointer to int where the cursor height will be stored
 
64
         * @param hotspot_x Storage for cursor hotspot X coordinate
 
65
         * @param hotspot_Y Storage for cursor hotspot Y coordinate
 
66
         * @param keycolor Pointer to int where the transpared color value will be stored
 
67
         * @param colored If set to true then colored cursor will be returned (if any).
 
68
         *                b/w version will be used otherwise
 
69
         * @param palette Pointer to memory where the cursor palette will be stored.
 
70
         *                The memory will be malloc()'ed
 
71
         * @param palSize Pointer to integer where the palette size will be stored.
 
72
         */
 
73
        void convertCursor(byte *data, int datasize, byte **cursor, int *w, int *h,
 
74
                                          int *hotspot_x, int *hotspot_y, int *keycolor, bool colored, byte **palette, int *palSize);
 
75
 
 
76
        /**
 
77
         * Return list of resource IDs with specified type ID
 
78
         */
 
79
        MacResIDArray getResIDArray(const char *typeID);
 
80
 
 
81
        Common::String getFileName() { return _fileName; }
 
82
 
 
83
private:
 
84
        int extractResource(int id, byte **buf);
 
85
        bool init();
 
86
        void readMap();
 
87
 
 
88
        struct ResMap {
 
89
                int16 resAttr;
 
90
                int16 typeOffset;
 
91
                int16 nameOffset;
 
92
                int16 numTypes;
 
93
        };
 
94
 
 
95
        struct ResType {
 
96
                char  id[5];
 
97
                int16 items;
 
98
                int16 offset;
 
99
        };
 
100
 
 
101
        struct Resource {
 
102
                int16 id;
 
103
                int16 nameOffset;
 
104
                byte  attr;
 
105
                int32 dataOffset;
 
106
                char  *name;
 
107
        };
 
108
 
 
109
        typedef Resource *ResPtr;
 
110
 
 
111
private:
 
112
        int _resOffset;
 
113
        int32 _dataOffset;
 
114
        int32 _dataLength;
 
115
        int32 _mapOffset;
 
116
        int32 _mapLength;
 
117
        ResMap _resMap;
 
118
        ResType *_resTypes;
 
119
        ResPtr  *_resLists;
 
120
 
 
121
        Common::String _fileName;
 
122
        Common::File _resFile;
 
123
};
 
124
 
 
125
} // End of namespace Common
 
126
 
 
127
#endif