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  */
22 
23 #ifndef QUEEN_BANKMAN_H
24 #define QUEEN_BANKMAN_H
25 
26 #include "common/util.h"
27 #include "queen/structs.h"
28 
29 namespace Queen {
30 
31 class Resource;
32 
33 class BankManager {
34 public:
35 
36 	BankManager(Resource *res);
37 	~BankManager();
38 
39 	//! load a bank into the specified slot
40 	void load(const char *bankname, uint32 bankslot);
41 
42 	//! unpack a frame from a loaded bank
43 	void unpack(uint32 srcframe, uint32 dstframe, uint32 bankslot);
44 
45 	//! unpack a frame over an existing one from a loaded bank
46 	void overpack(uint32 srcframe, uint32 dstframe, uint32 bankslot);
47 
48 	//! close a bank
49 	void close(uint32 bankslot);
50 
51 	//! get a reference to unpacked frame
52 	BobFrame *fetchFrame(uint32 index);
53 
54 	//! erase a frame
55 	void eraseFrame(uint32 index);
56 
57 	//! erase all unpacked frames
58 	void eraseFrames(bool joe);
59 
60 	enum {
61 		MAX_BANK_SIZE     = 110,
62 		MAX_FRAMES_NUMBER = 256,
63 		MAX_BANKS_NUMBER  =  18
64 	};
65 
66 private:
67 
68 	struct PackedBank {
69 		uint32 indexes[MAX_BANK_SIZE];
70 		uint8 *data;
71 		char name[20];
72 	};
73 
74 	//! unpacked bob frames
75 	BobFrame _frames[MAX_FRAMES_NUMBER];
76 
77 	 //! banked bob frames
78 	PackedBank _banks[MAX_BANKS_NUMBER];
79 
80 	Resource *_res;
81 };
82 
83 } // End of namespace Queen
84 
85 #endif
86