1 /* ResidualVM - A 3D game interpreter
2 *
3 * ResidualVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the AUTHORS
5 * file distributed with this source distribution.
6 *
7 * Additional copyright for this file:
8 * Copyright (C) 1999-2000 Revolution Software Ltd.
9 * This code is based on source code created by Revolution Software,
10 * used with permission.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 *
26 */
27
28 #ifndef ICB_PX_BITMAP_PC_H_INCLUDED
29 #define ICB_PX_BITMAP_PC_H_INCLUDED
30
31 #include "engines/icb/common/px_common.h"
32
33 namespace ICB {
34
35 // These define the extension for the finding the bitmap files
36 #ifndef PX_BITMAP_PC_EXT
37 #define PX_BITMAP_PC_EXT "bitmap_pc"
38 #endif
39
40 // Replaced pxHeader with id and added schema control to datafiles
41 #define PC_BITMAP_SCHEMA 1
42 #define PC_BITMAP_ID "PCB"
43
44 // Data structure to overlay the sprite data.
45 typedef struct {
46 uint32 x, y; // X and Y position of sprite.
47 uint32 width, height; // Width and height of the sprite in pixels.
48 uint8 data[1]; // Sprite data.
49
50 } _pxPCSprite;
51
52 // This holds information about a bitmap (which may contain a number of frames).
53 class _pxPCBitmap {
54 public:
55 // Constructor and destructor (don't need to do anything because these items are always created
56 // by doing a Res_open and casting a block of memory to this type).
_pxPCBitmap()57 _pxPCBitmap() { ; }
~_pxPCBitmap()58 ~_pxPCBitmap() { ; }
59
60 char id[4]; // "PCB" Pc bitmap
61 uint32 schema; // The current schema number
62
63 // Gets and sets.
Fetch_number_of_items()64 uint32 Fetch_number_of_items() const { return num_sprites; }
65 inline _pxPCSprite *Fetch_item_by_number(uint32 nNumber);
66
Fetch_palette_pointer()67 uint8 *Fetch_palette_pointer() { return &palette[0]; }
68
69 private:
70 uint8 palette[4 * 256]; // RGB but padded with 0 to 32-bits.
71 uint32 num_sprites; // Number of sprites in this file.
72 uint32 sprite_offsets[1]; // Offsets to sprite data for each sprite.
73
_pxPCBitmap(const _pxPCBitmap &)74 _pxPCBitmap(const _pxPCBitmap &) { ; }
75 void operator=(const _pxPCBitmap &) { ; }
76 };
77
Fetch_item_by_number(uint32 nNumber)78 inline _pxPCSprite *_pxPCBitmap::Fetch_item_by_number(uint32 nNumber) {
79 // Make sure requested sprite is in the resource.
80 assert(nNumber < num_sprites);
81
82 // Return the pointer.
83 return ((_pxPCSprite *)(((uint8 *)this) + sprite_offsets[nNumber]));
84 }
85
86 } // End of namespace ICB
87
88 #endif // #ifndef _PX_BITMAP_PC_H_INCLUDED
89