ScummVM API documentation
remora_sprite.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  * 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 modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (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, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_REMORA_SPRITE_H_INCLUDED
28 #define ICB_REMORA_SPRITE_H_INCLUDED
29 
30 #include "engines/icb/p4.h"
31 #include "engines/icb/debug.h"
32 #include "engines/icb/string_vest.h"
33 #include "engines/icb/common/px_clu_api.h"
34 #include "engines/icb/common/px_string.h"
35 #include "engines/icb/common/px_common.h"
36 #include "engines/icb/common/px_bitmap.h"
37 
38 namespace ICB {
39 
40 // Use this structure to pass extra information into the Remora sprite drawing functions.
41 struct _rs_params {
42  uint32 nW, nH; // PSX only. Width to draw (use values in sprite if nW==0 and nH==0.
43  bool8 bAllFrames; // PSX only. Used for decompression.
44  uint8 r, g, b; // PSX only. RGB scaling values.
45  bool8 bCentre; // PC & PSX. If true, sprite is centred on coordinate.
46  uint8 nOpacity; // PC only (I think). If not 255, sprite is blended into surface.
47  bool8 bUpdate; // PC & PSX. If true, frame count is automatically updated.
48  uint8 nPad1;
49 
50  // Initialisation.
51  _rs_params() {
52  nW = 0; // Defaults to zero, so value is read from the sprite.
53  nH = 0; // Ditto.
54  bAllFrames = FALSE8; // Whatever it is, it's off.
55  r = 128; // I'll have to check these. I think 128 means 'no colour scale'.
56  g = 128; // Ditto.
57  b = 128; // Ditto.
58  bCentre = TRUE8; // Centre the sprite by default.
59  nOpacity = 255; // Draw it with no transparency.
60  bUpdate = TRUE8; // Update the frame counter, so it animates.
61  }
62 };
63 
65 public:
66  // Constructor and destructor.
68  ~_remora_sprite() { ; }
69 
70  // Copy constructor and assignment.
71  _remora_sprite(const _remora_sprite &oX);
72  const _remora_sprite &operator=(const _remora_sprite &oOpB);
73 
74  // This sets up the object for a particular animating bitmap.
75  void InitialiseFromBitmapName(const char *pcBitmapName, const char *pcClusterName, uint32 nClusterash);
76 
77  // These return the size of a loaded sprite.
78  uint32 GetHeight();
79  uint32 GetWidth();
80 
81  // These draw sprites on the Remora's screen.
82  inline void DrawSprite(const _rs_params *pParams = NULL);
83  inline void DrawXYSprite(int32 nX, int32 nY, const _rs_params *pParams = NULL);
84 
85  inline bool8 FitsOnScreen(int32 nX, int32 nZ, int32 nScreenWidth, int32 nScreenHeight) const;
86 
87 private:
88  char m_pcName[MAXLEN_URL]; // The full path and name of the sprite.
89 
90  uint32 m_nNameHash; // The hash version of the name of the sprite.
91  char m_pcClusterName[MAXLEN_CLUSTER_URL]; // Name of the cluster the sprite is coming from.
92  uint32 m_nClusterHash; // Hash of the cluster the sprite is coming from.
93 
94  uint32 m_nFramePC; // Frame counter for running animations.
95  uint32 m_nNumFrames; // Number of frames in the animation.
96 
97  int32 m_nHalfSpriteWidth; // These two store half the sprite's width and height
98  int32 m_nHalfSpriteHeight; // so we can work out an area that they can legally be plotted.
99 
100  // Private functions used only in this class.
101  void GenericSpriteDraw(int32 nX, int32 nY, bool8 bPosition, const _rs_params *pParams);
102 };
103 
104 inline void _remora_sprite::DrawSprite(const _rs_params *pParams) { GenericSpriteDraw(0, 0, FALSE8, pParams); }
105 
106 inline void _remora_sprite::DrawXYSprite(int32 nX, int32 nY, const _rs_params *pParams) { GenericSpriteDraw(nX, nY, TRUE8, pParams); }
107 
108 inline bool8 _remora_sprite::FitsOnScreen(int32 nX, int32 nZ, int32 nScreenWidth, int32 nScreenHeight) const {
109  if ((nX > m_nHalfSpriteWidth) && (nX < (nScreenWidth - m_nHalfSpriteWidth)) && (nZ > m_nHalfSpriteHeight) && (nZ < (nScreenHeight - m_nHalfSpriteHeight)))
110  return (TRUE8);
111  else
112  return (FALSE8);
113 
114 }
115 
116 } // End of namespace ICB
117 
118 #endif // #if !defined( REMORA_SPRITE_H_INCLUDED )
Definition: actor.h:32
Definition: remora_sprite.h:41
Definition: remora_sprite.h:64