CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

ICONCACH.H (7236B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /***********************************************************************************************
     17  ***             C O N F I D E N T I A L  ---  W E S T W O O D   S T U D I O S               ***
     18  ***********************************************************************************************
     19  *                                                                                             *
     20  *                 Project Name : Drawbuff - Westwood win95 library                            *
     21  *                                                                                             *
     22  *                    File Name : Iconcach.H                                                   *
     23  *                                                                                             *
     24  *                   Programmer : Steve Tall                                                   *
     25  *                                                                                             *
     26  *                   Start Date : November 8th, 1995                                           *
     27  *                                                                                             *
     28  *                  Last Update : November 16th, 1995 [ST]                                     *
     29  *                                                                                             *
     30  *---------------------------------------------------------------------------------------------*
     31  * Overview: This file cantains definition of the IconCacheClass and associated non member     *
     32  *           function prototypes.                                                              *
     33  *                                                                                             *
     34  * Functions:                                                                                  *
     35  *  IconCacheClass::Get_Is_Cached -- member to allow access to private IsCached flag           *
     36  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     37 
     38 
     39 
     40 
     41 #ifndef	ICONCACH_H
     42 #define	ICONCACH_H
     43 
     44 #include	<tile.h>
     45 
     46 #define	ICON_WIDTH			24			// Icons must be this width to be cached
     47 #define	ICON_HEIGHT			24			// Icons must be this height to be cached
     48 #define	MAX_CACHED_ICONS	500		// Maximum number of icons that can be cached
     49 #define	MAX_ICON_SETS		100		// Maximum number of icon sets that can be registered
     50 #define	MAX_LOOKUP_ENTRIES 3000		// Size of icon index table
     51 
     52 
     53 /*
     54 ** IconCacheClass for tracking individual icons cached into video memory
     55 **
     56 ** Use Register_Icon_Set to identify a set of icons as cachable. Once registered, the icons
     57 ** will be cached automatically when drawn.
     58 ** Use Invalidate_Cached_Icons at the end of icon drawing to release the video memory used by the
     59 ** caching system.
     60 ** Restore_Cached_Icons may be used to reload the icons into video memory after a focus loss.
     61 **
     62 */
     63 
     64 class IconCacheClass {
     65 
     66 	public:
     67 
     68 		IconCacheClass (void);					// class constructor
     69 		~IconCacheClass (void);					// class destructor
     70 
     71 		void Restore(void);						// restore the surface
     72 		BOOL Cache_It (void * icon_ptr);		// Cache the icon to video memory
     73 		void Uncache_It (void);					// Restore the video memory and flag the icon as uncached
     74 		void Draw_It (LPDIRECTDRAWSURFACE dest_surface , int x_pixel, int y_pixel, int window_left , int window_top , int window_width , int window_height);
     75 		inline BOOL Get_Is_Cached(void);		// Return the IsCached member
     76 
     77 		int						TimesDrawn;		// counter of times cached icon has been drawn
     78 		int						TimesFailed;	// counter of times cached icon has failed to draw
     79 
     80 
     81 	private:
     82 
     83 		LPDIRECTDRAWSURFACE	CacheSurface;	// Ptr to direct draw surface where icon resides
     84 		BOOL						IsCached;		// Flag to say whether an icon is cached
     85 		BOOL						SurfaceLost;	// Flag to indicate that our icons surface has been lost
     86 		int						DrawFrequency;	// Number of times icon has been drawn
     87 		void						*IconSource;	// Ptr to original icon data in system memory
     88 
     89 };
     90 
     91 
     92 
     93 /*
     94 ** Structure to keep track of registered icon sets
     95 **
     96 */
     97 
     98 typedef struct tIconSetType{
     99 	IControl_Type	*IconSetPtr;				// Ptr to icon set data
    100 	int				IconListOffset;			// Offset into icon index table for this icon set
    101 }IconSetType;
    102 
    103 
    104 extern	IconCacheClass	CachedIcons[MAX_CACHED_ICONS];
    105 
    106 extern void Invalidate_Cached_Icons (void);
    107 extern void Restore_Cached_Icons (void);
    108 extern void Register_Icon_Set (void *icon_data , BOOL pre_cache);
    109 
    110 //
    111 // Prototypes for assembly language procedures in STMPCACH.ASM
    112 //
    113 extern "C" void Clear_Icon_Pointers (void);
    114 extern "C" void Cache_Copy_Icon (void const *icon_ptr ,void * , int);
    115 extern "C" int Is_Icon_Cached (void const *icon_data , int icon);
    116 extern "C" int Get_Icon_Index (void *icon_ptr);
    117 extern "C" int Get_Free_Index (void);
    118 extern "C" BOOL Cache_New_Icon (int icon_index, void *icon_ptr);
    119 extern "C" int Get_Free_Cache_Slot(void);
    120 
    121 
    122 extern	int	CachedIconsDrawn;
    123 extern	int	UnCachedIconsDrawn;
    124 
    125 
    126 /***********************************************************************************************
    127  * ICC::Get_Is_Cached -- member to allow access to the private IsCached flag                   *
    128  *                                                                                             *
    129  *                                                                                             *
    130  *                                                                                             *
    131  * INPUT:    Nothing                                                                           *
    132  *                                                                                             *
    133  * OUTPUT:   IsCached                                                                          *
    134  *                                                                                             *
    135  * WARNINGS: None                                                                              *
    136  *                                                                                             *
    137  * HISTORY:                                                                                    *
    138  *    11/13/95 9:42AM ST : Created                                                             *
    139  *=============================================================================================*/
    140 inline BOOL IconCacheClass::Get_Is_Cached (void)
    141 {
    142 	return (IsCached);
    143 }
    144 
    145 
    146 
    147 
    148 
    149 #endif	//ICONCACH_H
    150