2004-01-06 13:44:17 +00:00
|
|
|
/* Copyright (C) 1994-2004 Revolution Software Ltd
|
2003-07-28 01:44:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RESMAN_H
|
|
|
|
#define RESMAN_H
|
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
#define MAX_res_files 20
|
|
|
|
|
2003-11-08 15:47:51 +00:00
|
|
|
class Sword2Engine;
|
|
|
|
|
2003-10-04 01:09:29 +00:00
|
|
|
class ResourceManager {
|
2003-09-26 10:07:18 +00:00
|
|
|
public:
|
2003-11-08 15:47:51 +00:00
|
|
|
ResourceManager(Sword2Engine *vm); // read in the config file
|
2003-11-03 07:47:42 +00:00
|
|
|
~ResourceManager(void);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
// Returns ad of resource. Loads if not in memory. Retains a count.
|
|
|
|
// Resource can be aged out of memory if count = 0
|
|
|
|
// The resource is locked while count != 0
|
|
|
|
// Resource floats when count = 0
|
|
|
|
|
2003-11-23 13:40:24 +00:00
|
|
|
uint8 *openResource(uint32 res, bool dump = false);
|
2003-11-03 07:47:42 +00:00
|
|
|
void closeResource(uint32 res); // decrements the count
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
// returns '0' if resource out of range or null, otherwise '1' for ok
|
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint8 checkValid(uint32 res);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
//for mem_view to query the owners of mem blocs
|
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
char *fetchCluster(uint32 res);
|
|
|
|
uint32 fetchAge(uint32 res);
|
|
|
|
uint32 fetchCount(uint32 count);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint32 helpTheAgedOut(void);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint32 fetchLen(uint32 res);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
void nextCycle(void);
|
|
|
|
uint32 fetchUsage(void);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
// Prompts the user for the specified CD.
|
2003-09-30 09:27:27 +00:00
|
|
|
void getCd(int cd);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
int whichCd() {
|
|
|
|
return _curCd;
|
2003-09-26 10:07:18 +00:00
|
|
|
}
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-26 10:07:18 +00:00
|
|
|
// ----console commands
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
void printConsoleClusters(void);
|
2003-10-26 15:42:49 +00:00
|
|
|
void examine(int res);
|
|
|
|
void kill(int res);
|
|
|
|
void killAll(bool wantInfo);
|
|
|
|
void killAllObjects(bool wantInfo);
|
2003-09-30 09:27:27 +00:00
|
|
|
void remove(uint32 res);
|
|
|
|
void removeAll(void);
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
// pointer to a pointer (or list of pointers in-fact)
|
2003-12-28 15:08:12 +00:00
|
|
|
Memory **_resList;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
private:
|
2003-11-08 15:47:51 +00:00
|
|
|
Sword2Engine *_vm;
|
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
int _curCd;
|
|
|
|
uint32 _totalResFiles;
|
|
|
|
uint32 _totalClusters;
|
|
|
|
uint32 _currentMemoryUsage;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
// Inc's each time open is called and is given to resource as its age.
|
|
|
|
// Cannot be allowed to start at 0! (A pint if you can tell me why)
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint32 _resTime;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint32 *_age;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
|
|
|
// Gode generated res-id to res number/rel number conversion table
|
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint16 *_resConvTable;
|
2003-09-26 10:07:18 +00:00
|
|
|
|
2003-09-30 09:27:27 +00:00
|
|
|
uint16 *_count;
|
|
|
|
char _resourceFiles[MAX_res_files][20];
|
|
|
|
uint8 _cdTab[MAX_res_files]; // Location of each cluster.
|
2003-09-26 10:07:18 +00:00
|
|
|
};
|
2003-07-28 01:44:38 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
} // End of namespace Sword2
|
|
|
|
|
2003-07-28 01:44:38 +00:00
|
|
|
#endif
|