2007-06-28 10:47:08 -07:00
|
|
|
/*
|
|
|
|
* FrameResources.h
|
|
|
|
*
|
|
|
|
* Resource file processing functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _resource_h
|
|
|
|
#define _resource_h
|
|
|
|
|
|
|
|
/* Maximum number of characters in a resource type */
|
|
|
|
#define RESTYPE_MAXCHAR 20
|
|
|
|
|
|
|
|
/* Maximum number of characters in a resource ID */
|
|
|
|
#define RESID_MAXCHAR 40
|
|
|
|
|
|
|
|
/* Function pointer for a function that loads from a memory buffer */
|
2006-08-12 09:52:37 -07:00
|
|
|
typedef BOOL (*RES_BUFFERLOAD)(char *pBuffer, UDWORD size, void **pData);
|
2007-06-28 10:47:08 -07:00
|
|
|
/* Function pointer for a function that loads from a filename */
|
2006-08-12 09:52:37 -07:00
|
|
|
typedef BOOL (*RES_FILELOAD)(char *pFile, void **pData);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
/* Function pointer for releasing a resource loaded by the above functions */
|
|
|
|
typedef void (*RES_FREE)(void *pData);
|
|
|
|
|
|
|
|
/* callback type for resload display callback*/
|
|
|
|
typedef void (*RESLOAD_CALLBACK)(void);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct res_data
|
|
|
|
{
|
|
|
|
STRING aID[RESID_MAXCHAR]; // ID of the resource - filename from the .wrf - e.g. "TRON.PIE"
|
|
|
|
void *pData; // pointer to the acutal data
|
|
|
|
SDWORD blockID; // which of the blocks is it in (so we can clear some of them...)
|
|
|
|
|
|
|
|
UDWORD HashedID; // hashed version of the name of the id
|
|
|
|
struct res_data *psNext; // next entry - most likely to be following on!
|
2006-07-04 06:35:01 -07:00
|
|
|
UDWORD usage;
|
2007-06-28 10:47:08 -07:00
|
|
|
} RES_DATA;
|
|
|
|
|
|
|
|
|
|
|
|
// New reduced resource type ... specially for PSX
|
|
|
|
// These types are statically defined in data.c
|
|
|
|
typedef struct _res_type
|
|
|
|
{
|
|
|
|
// type is still needed on psx ... strings are defined in source - data.c (yak!)
|
|
|
|
STRING aType[RESTYPE_MAXCHAR]; // type string (e.g. "PIE" - just for debug use only, only aplicable when loading from wrf (not wdg)
|
|
|
|
|
2006-07-04 06:35:01 -07:00
|
|
|
RES_BUFFERLOAD buffLoad; // routine to process the data for this type
|
2007-06-28 10:47:08 -07:00
|
|
|
RES_FREE release; // routine to release the data (NULL indicates none)
|
|
|
|
|
|
|
|
// we must have a pointer to the data here so that we can do a resGetData();
|
|
|
|
RES_DATA *psRes; // Linked list of data items of this type
|
|
|
|
UDWORD HashedType; // hashed version of the name of the id - // a null hashedtype indicates end of list
|
2006-07-04 06:35:01 -07:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
RES_FILELOAD fileLoad; // This isn't really used any more ?
|
|
|
|
struct _res_type *psNext;
|
|
|
|
} RES_TYPE;
|
|
|
|
|
|
|
|
|
|
|
|
/* set the function to call when loading files with resloadfile*/
|
2006-09-13 02:09:05 -07:00
|
|
|
extern void resSetLoadCallback(RESLOAD_CALLBACK funcToCall);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
/* callback type for res pre-load callback*/
|
|
|
|
typedef BOOL (*RESPRELOAD_CALLBACK)(char *type, char *name, char *directory);
|
|
|
|
|
|
|
|
/* set the function to call when loading files with resloadfile*/
|
2006-09-13 02:09:05 -07:00
|
|
|
extern void resSetPreLoadCallback(RESPRELOAD_CALLBACK funcToCall);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Initialise the resource module */
|
|
|
|
extern BOOL resInitialise(void);
|
|
|
|
|
|
|
|
/* Shutdown the resource module */
|
|
|
|
extern void resShutDown(void);
|
|
|
|
|
|
|
|
// set the base resource directory
|
|
|
|
extern void resSetBaseDir(STRING *pResDir);
|
|
|
|
|
|
|
|
/* Parse the res file */
|
|
|
|
struct _block_heap;
|
|
|
|
BOOL resLoad(STRING *pResFile, SDWORD blockID,
|
2006-08-12 09:52:37 -07:00
|
|
|
char *pLoadBuffer, SDWORD bufferSize,
|
2007-06-28 10:47:08 -07:00
|
|
|
struct _block_heap *psMemHeap);
|
|
|
|
|
|
|
|
/* Release all the resources currently loaded and the resource load functions */
|
|
|
|
extern void resReleaseAll(void);
|
|
|
|
|
|
|
|
// release the data for a particular block ID
|
|
|
|
extern void resReleaseBlockData(SDWORD blockID);
|
|
|
|
|
|
|
|
/* Release all the resources currently loaded but keep the resource load functions */
|
|
|
|
extern void resReleaseAllData(void);
|
|
|
|
|
|
|
|
/* Add a buffer load and release function for a file type */
|
2006-09-13 14:16:17 -07:00
|
|
|
extern BOOL resAddBufferLoad(const STRING *pType, RES_BUFFERLOAD buffLoad,
|
2007-06-28 10:47:08 -07:00
|
|
|
RES_FREE release);
|
|
|
|
|
|
|
|
/* Add a file name load and release function for a file type */
|
|
|
|
extern BOOL resAddFileLoad(STRING *pType, RES_FILELOAD fileLoad,
|
|
|
|
RES_FREE release);
|
|
|
|
|
|
|
|
/* Call the load function for a file */
|
|
|
|
extern BOOL resLoadFile(STRING *pType, STRING *pFile);
|
|
|
|
|
|
|
|
// Add data to the resource system
|
|
|
|
extern BOOL resAddData(STRING *pType, STRING *pID, void *pData);
|
|
|
|
|
|
|
|
/* Return the resource for a type and ID */
|
2006-09-13 14:16:17 -07:00
|
|
|
extern void *resGetDataFromHash(const STRING *pType, UDWORD HashedID);
|
2006-09-13 02:09:05 -07:00
|
|
|
extern void *resGetData(const STRING *pType, const STRING *pID);
|
2006-09-13 14:16:17 -07:00
|
|
|
extern BOOL resPresent(const STRING *pType, const STRING *pID);
|
2007-06-28 10:47:08 -07:00
|
|
|
void resToLower(STRING *pStr);
|
|
|
|
|
|
|
|
// return the HashedID string for a piece of data
|
2006-09-13 14:16:17 -07:00
|
|
|
extern BOOL resGetHashfromData(const STRING *pType, const void *pData, UDWORD *pHash);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-09-13 02:09:05 -07:00
|
|
|
void resDoResLoadCallback(void);
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
//return last imd resource
|
|
|
|
char *GetLastResourceFilename(void);
|
|
|
|
// Set the resource name of the last resource file loaded
|
|
|
|
void SetLastResourceFilename(char *pName);
|
|
|
|
|
|
|
|
// Returns the filename of the last resource file loaded
|
|
|
|
UDWORD GetLastHashName(void);
|
|
|
|
// Set the resource name of the last resource file loaded
|
|
|
|
void SetLastHashName(UDWORD HashName);
|
|
|
|
|
|
|
|
void SetLastResourceHash(char *fname);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|