aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-09-30 09:27:27 +0000
committerTorbjörn Andersson2003-09-30 09:27:27 +0000
commit568a4bd8394e8ada14c6dabb1dda149c8e5f5608 (patch)
treeb96d7c29d6c68b9dbe549242e93993e1cfd195fe
parente70fcf1737812b3afa35f5350ba80e07d8359569 (diff)
downloadscummvm-rg350-568a4bd8394e8ada14c6dabb1dda149c8e5f5608.tar.gz
scummvm-rg350-568a4bd8394e8ada14c6dabb1dda149c8e5f5608.tar.bz2
scummvm-rg350-568a4bd8394e8ada14c6dabb1dda149c8e5f5608.zip
Changed the resource manager object to use more ScummVM-like naming.
svn-id: r10499
-rw-r--r--sword2/anims.cpp32
-rw-r--r--sword2/build_display.cpp52
-rw-r--r--sword2/console.cpp20
-rw-r--r--sword2/controls.cpp22
-rw-r--r--sword2/debug.cpp4
-rw-r--r--sword2/defs.h2
-rw-r--r--sword2/function.cpp20
-rw-r--r--sword2/icons.cpp12
-rw-r--r--sword2/layers.cpp8
-rw-r--r--sword2/logic.cpp22
-rw-r--r--sword2/maketext.cpp16
-rw-r--r--sword2/mem_view.cpp12
-rw-r--r--sword2/memory.cpp2
-rw-r--r--sword2/memory.h2
-rw-r--r--sword2/mouse.cpp22
-rw-r--r--sword2/protocol.cpp4
-rw-r--r--sword2/resman.cpp441
-rw-r--r--sword2/resman.h85
-rw-r--r--sword2/router.cpp4
-rw-r--r--sword2/save_rest.cpp32
-rw-r--r--sword2/sound.cpp14
-rw-r--r--sword2/speech.cpp50
-rw-r--r--sword2/startup.cpp20
-rw-r--r--sword2/sword2.cpp24
-rw-r--r--sword2/walker.cpp24
25 files changed, 470 insertions, 476 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp
index a37f1fbec4..7eae4971d8 100644
--- a/sword2/anims.cpp
+++ b/sword2/anims.cpp
@@ -128,8 +128,8 @@ int32 Animate(int32 *params, uint8 reverse_flag) {
if (res_man.Res_check_valid(res)) {
// Open the resource. Can close it immediately.
// We've got a pointer to the header.
- head = (_standardHeader *) res_man.Res_open(res);
- res_man.Res_close(res);
+ head = (_standardHeader *) res_man.open(res);
+ res_man.close(res);
// if it's not an animation file
if (head->fileType != ANIMATION_FILE) {
@@ -159,7 +159,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) {
#endif
// open anim file
- anim_file = res_man.Res_open(res);
+ anim_file = res_man.open(res);
#ifdef _SWORD2_DEBUG
// check this this resource is actually an animation file!
@@ -198,7 +198,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) {
// frame of the anim.
// open anim file and point to anim header
- anim_file = res_man.Res_open(ob_graphic->anim_resource);
+ anim_file = res_man.open(ob_graphic->anim_resource);
anim_head = FetchAnimHeader(anim_file);
if (reverse_flag)
@@ -218,7 +218,7 @@ int32 Animate(int32 *params, uint8 reverse_flag) {
}
// close the anim file
- res_man.Res_close(ob_graphic->anim_resource);
+ res_man.close(ob_graphic->anim_resource);
// check if we want the script to loop back & call this function again
return ob_logic->looping ? IR_REPEAT : IR_STOP;
@@ -282,7 +282,7 @@ int32 FN_set_frame(int32 *params) {
// open the resource (& check it's valid)
- anim_file = res_man.Res_open(res);
+ anim_file = res_man.open(res);
#ifdef _SWORD2_DEBUG
// check this this resource is actually an animation file!
@@ -312,7 +312,7 @@ int32 FN_set_frame(int32 *params) {
// Close the anim file and drop out of script
- res_man.Res_close(ob_graphic->anim_resource);
+ res_man.close(ob_graphic->anim_resource);
return IR_CONT;
}
@@ -531,11 +531,11 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
local_text = sequence_text_list[line].textNumber & 0xffff;
// open text resource & get the line
- text = FetchTextLine(res_man.Res_open(text_res), local_text);
+ text = FetchTextLine(res_man.open(text_res), local_text);
wavId = (int32) READ_LE_UINT16(text);
// now ok to close the text file
- res_man.Res_close(text_res);
+ res_man.close(text_res);
// 1st word of text line is the official line number
debug(5,"(%d) SEQUENCE TEXT: %s", *(uint16 *) text, text + 2);
@@ -557,7 +557,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
File fp;
- sprintf(speechFile, "speech%d.clu", res_man.WhichCd());
+ sprintf(speechFile, "speech%d.clu", res_man.whichCd());
if (fp.open(speechFile))
fp.close();
else
@@ -574,7 +574,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
if (subtitles || !speechRunning) {
// open text resource & get the line
- text = FetchTextLine(res_man.Res_open(text_res), local_text);
+ text = FetchTextLine(res_man.open(text_res), local_text);
// make the sprite
// 'text+2' to skip the first 2 bytes which form the
// line reference number
@@ -585,7 +585,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
sequence_text_list[line].text_mem = MakeTextSprite(text + 2, 600, 255, speech_font_id);
// ok to close the text resource now
- res_man.Res_close(text_res);
+ res_man.close(text_res);
} else {
sequence_text_list[line].text_mem = NULL;
sequenceText[line]->textSprite = NULL;
@@ -660,7 +660,7 @@ int32 FN_smacker_lead_in(int32 *params) {
_standardHeader *header;
#endif
- leadIn = res_man.Res_open(params[0]);
+ leadIn = res_man.open(params[0]);
#ifdef _SWORD2_DEBUG
header = (_standardHeader *) leadIn;
@@ -675,7 +675,7 @@ int32 FN_smacker_lead_in(int32 *params) {
if (rv)
debug(5, "SFX ERROR: PlayFx() returned %.8x", rv);
- res_man.Res_close(params[0]);
+ res_man.close(params[0]);
// fade out any music that is currently playing (James22july97)
FN_stop_music(NULL);
@@ -733,7 +733,7 @@ int32 FN_play_sequence(int32 *params) {
// open the lead-out music resource, if there is one
if (smackerLeadOut) {
- leadOut = res_man.Res_open(smackerLeadOut);
+ leadOut = res_man.open(smackerLeadOut);
#ifdef _SWORD2_DEBUG
header = (_standardHeader *)leadOut;
@@ -763,7 +763,7 @@ int32 FN_play_sequence(int32 *params) {
// close the lead-out music resource
if (smackerLeadOut) {
- res_man.Res_close(smackerLeadOut);
+ res_man.close(smackerLeadOut);
smackerLeadOut = 0;
}
diff --git a/sword2/build_display.cpp b/sword2/build_display.cpp
index fcca838f14..653b513c1b 100644
--- a/sword2/build_display.cpp
+++ b/sword2/build_display.cpp
@@ -154,46 +154,46 @@ void Build_display(void) { //Tony21Sept96
// first background parallax + related anims
// open the screen resource
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->bg_parallax[0]) {
RenderParallax(FetchBackgroundParallaxLayer(file, 0), 0);
// release the screen resource before cacheing
// the sprites
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
Send_back_par0_frames();
} else {
// release the screen resource
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
}
// ---------------------------------------------------
// second background parallax + related anims
// open the screen resource
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->bg_parallax[1]) {
RenderParallax(FetchBackgroundParallaxLayer(file, 1), 1);
// release the screen resource before cacheing
// the sprites
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
Send_back_par1_frames();
} else {
// release the screen resource
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
}
// ---------------------------------------------------
// normal backround layer (just the one!)
// open the screen resource
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
RenderParallax(FetchBackgroundLayer(file), 2);
// release the screen resource
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
// ---------------------------------------------------
// sprites & layers
@@ -207,36 +207,36 @@ void Build_display(void) { //Tony21Sept96
// first foreground parallax + related anims
// open the screen resource
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->fg_parallax[0]) {
RenderParallax(FetchForegroundParallaxLayer(file, 0), 3);
// release the screen resource before cacheing
// the sprites
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
Send_fore_par0_frames();
} else {
// release the screen resource
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
}
//----------------------------------------------------
// second foreground parallax + related anims
// open the screen resource
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->fg_parallax[1]) {
RenderParallax(FetchForegroundParallaxLayer(file, 1), 4);
// release the screen resource before cacheing
// the sprites
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
Send_fore_par1_frames();
} else {
// release the screen resource
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
}
// ---------------------------------------------------
@@ -510,7 +510,7 @@ void Process_layer(uint32 layer_number) {
#endif
// file points to 1st byte in the layer file
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
// point to layer header
layer_head = FetchLayerHeader(file,layer_number);
@@ -548,7 +548,7 @@ void Process_layer(uint32 layer_number) {
if (rv)
error("Driver Error %.8x in Process_layer(%d)", rv, layer_number);
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
}
void Process_image(buildit *build_unit) {
@@ -565,7 +565,7 @@ void Process_image(buildit *build_unit) {
#endif
// open anim resource file & point to base
- file = res_man.Res_open(build_unit->anim_resource);
+ file = res_man.open(build_unit->anim_resource);
anim_head = FetchAnimHeader(file);
cdt_entry = FetchCdtEntry(file, build_unit->anim_pc);
@@ -685,7 +685,7 @@ void Process_image(buildit *build_unit) {
build_unit->anim_resource);
// release the anim resource
- res_man.Res_close(build_unit->anim_resource);
+ res_man.close(build_unit->anim_resource);
}
void Reset_render_lists(void) { //Tony18Sept96
@@ -758,7 +758,7 @@ void Register_frame(int32 *params, buildit *build_unit) {
Con_fatal_error("ERROR: %s(%d) has no anim resource in Register_frame", FetchObjectName(ID), ID);
#endif
- file = res_man.Res_open(ob_graph->anim_resource);
+ file = res_man.open(ob_graph->anim_resource);
anim_head = FetchAnimHeader(file);
cdt_entry = FetchCdtEntry(file, ob_graph->anim_pc);
@@ -875,7 +875,7 @@ void Register_frame(int32 *params, buildit *build_unit) {
}
// close animation file
- res_man.Res_close(ob_graph->anim_resource);
+ res_man.close(ob_graph->anim_resource);
}
int32 FN_register_frame(int32 *params) {
@@ -972,7 +972,7 @@ void Start_new_palette(void) {
WaitForFade();
// open the screen file
- screenFile = res_man.Res_open(this_screen.background_layer_id);
+ screenFile = res_man.open(this_screen.background_layer_id);
UpdatePaletteMatchTable((uint8 *) FetchPaletteMatchTable(screenFile));
@@ -982,7 +982,7 @@ void Start_new_palette(void) {
lastPaletteRes = 0;
// close screen file
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
// start fade up
// FadeUp((float) 1.75);
@@ -1095,7 +1095,7 @@ void SetFullPalette(int32 palRes) {
// non-zero: set palette to this separate palette file
if (palRes) {
// open the palette file
- head = (_standardHeader*) res_man.Res_open(palRes);
+ head = (_standardHeader*) res_man.open(palRes);
#ifdef _SWORD2_DEBUG
if (head->fileType != PALETTE_FILE)
@@ -1124,12 +1124,12 @@ void SetFullPalette(int32 palRes) {
}
// close palette file
- res_man.Res_close(palRes);
+ res_man.close(palRes);
} else {
// 0: set palette to current screen palette
if (this_screen.background_layer_id) {
// open the screen file
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
UpdatePaletteMatchTable((uint8 *) FetchPaletteMatchTable(file));
BS2_SetPalette(0, 256, FetchPalette(file), RDPAL_INSTANT);
@@ -1138,7 +1138,7 @@ void SetFullPalette(int32 palRes) {
lastPaletteRes = 0;
// close screen file
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
} else
Con_fatal_error("FN_set_palette(0) called, but no current screen available!");
}
diff --git a/sword2/console.cpp b/sword2/console.cpp
index 3232aa4f5d..b90f99ab7c 100644
--- a/sword2/console.cpp
+++ b/sword2/console.cpp
@@ -453,7 +453,7 @@ uint32 Parse_user_input(void) {
Print_to_console("What about him?");
return 0;
case 6: // RES
- res_man.Print_console_clusters();
+ res_man.printConsoleClusters();
return 0;
case 7: // STARTS
Con_print_start_menu();
@@ -493,7 +493,7 @@ uint32 Parse_user_input(void) {
Print_to_console("player feet marker off");
return 0;
case 13: // RESLOOK
- res_man.Examine_res(&input[1][0]);
+ res_man.examine(&input[1][0]);
return 0;
case 14: // CUR
Print_current_info();
@@ -502,12 +502,12 @@ uint32 Parse_user_input(void) {
LLogic.examineRunList();
return 0;
case 16: // KILL
- res_man.Kill_res(&input[1][0]);
+ res_man.kill(&input[1][0]);
return 0;
case 17: // NUKE
Print_to_console("killing all resources except variable file & player object...");
// '1' means we want output to console
- res_man.Kill_all_res(1);
+ res_man.killAll(1);
return 0;
case 19: // VAR
if (total_commands == 2)
@@ -527,7 +527,7 @@ uint32 Parse_user_input(void) {
case 21: // CLEAR
Print_to_console("killing all object resources except player...");
// '1' means we want output to console
- res_man.Kill_all_objects(1);
+ res_man.killAllObjects(1);
return 0;
case 22: // DEBUGON
displayDebugText = 1;
@@ -754,7 +754,7 @@ void Con_print(uint8 *ascii, uint32 pen, uint32 paper) {
int chr, x = 0;
// open font file
- charSet = res_man.Res_open(CONSOLE_FONT_ID);
+ charSet = res_man.open(CONSOLE_FONT_ID);
do {
chr = (int) *(ascii);
@@ -770,7 +770,7 @@ void Con_print(uint8 *ascii, uint32 pen, uint32 paper) {
} while(*(ascii));
// close font file
- res_man.Res_close(CONSOLE_FONT_ID);
+ res_man.close(CONSOLE_FONT_ID);
}
void Con_colour_block(int x, int width, int height, uint32 pen, uint32 paper, uint8 *sprite_data_ad) {
@@ -835,7 +835,7 @@ void Var_check(uint8 *pointer) {
sscanf((char *) pointer, "%d", &var);
- Print_to_console("%d", *(uint32 *) (res_man.resList[1]->ad + sizeof(_standardHeader) + 4 * var));
+ Print_to_console("%d", *(uint32 *) (res_man._resList[1]->ad + sizeof(_standardHeader) + 4 * var));
}
void Var_set(uint8 *pointer, uint8 *p2) {
@@ -845,9 +845,9 @@ void Var_set(uint8 *pointer, uint8 *p2) {
sscanf((char *) pointer, "%d", &var);
sscanf((char *) p2, "%d", &val);
- Print_to_console("was %d", *(uint32 *) (res_man.resList[1]->ad + sizeof(_standardHeader) + 4 * var));
+ Print_to_console("was %d", *(uint32 *) (res_man._resList[1]->ad + sizeof(_standardHeader) + 4 * var));
- *(uint32 *) (res_man.resList[1]->ad + sizeof(_standardHeader) + 4 * var) = val;
+ *(uint32 *) (res_man._resList[1]->ad + sizeof(_standardHeader) + 4 * var) = val;
Print_to_console("now %d", val);
}
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index 5e7af38e98..819a7b6a76 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -70,7 +70,7 @@ private:
public:
Sword2FontRenderer(int fontId) : _fontId(fontId) {
- uint8 *font = res_man.Res_open(fontId);
+ uint8 *font = res_man.open(fontId);
_frameHeader *head;
_spriteInfo sprite;
@@ -86,7 +86,7 @@ public:
_glyph[i]._height = head->height;
}
- res_man.Res_close(fontId);
+ res_man.close(fontId);
}
~Sword2FontRenderer() {
@@ -95,7 +95,7 @@ public:
}
void fetchText(int textId, char *buf) {
- uint8 *data = FetchTextLine(res_man.Res_open(textId / SIZE), textId & 0xffff);
+ uint8 *data = FetchTextLine(res_man.open(textId / SIZE), textId & 0xffff);
int i;
for (i = 0; data[i + 2]; i++) {
@@ -104,7 +104,7 @@ public:
}
buf[i] = 0;
- res_man.Res_close(textId / SIZE);
+ res_man.close(textId / SIZE);
}
int getTextWidth(char *text) {
@@ -257,7 +257,7 @@ void Sword2Widget::createSurfaceImage(int state, uint32 res, int x, int y, uint3
uint32 spriteType = RDSPR_TRANS;
// open anim resource file, point to base
- file = res_man.Res_open(res);
+ file = res_man.open(res);
anim_head = FetchAnimHeader(file);
cdt_entry = FetchCdtEntry(file, pc);
@@ -302,7 +302,7 @@ void Sword2Widget::createSurfaceImage(int state, uint32 res, int x, int y, uint3
_surfaces[state]._original = true;
// Release the anim resource
- res_man.Res_close(res);
+ res_man.close(res);
};
void Sword2Widget::linkSurfaceImage(Sword2Widget *from, int state, int x, int y) {
@@ -1271,7 +1271,7 @@ public:
break;
}
- Control_error((char*) (FetchTextLine(res_man.Res_open(textId / SIZE), textId & 0xffff) + 2));
+ Control_error((char*) (FetchTextLine(res_man.open(textId / SIZE), textId & 0xffff) + 2));
result = 0;
}
} else {
@@ -1292,7 +1292,7 @@ public:
break;
}
- Control_error((char *) (FetchTextLine(res_man.Res_open(textId / SIZE), textId & 0xffff) + 2));
+ Control_error((char *) (FetchTextLine(res_man.open(textId / SIZE), textId & 0xffff) + 2));
result = 0;
} else {
// Prime system with a game cycle
@@ -1366,12 +1366,12 @@ void Restart_control(void) {
// remove all resources from memory, including player object and
// global variables
- res_man.Remove_all_res();
+ res_man.removeAll();
// reopen global variables resource & send address to interpreter -
// it won't be moving
- SetGlobalInterpreterVariables((int32 *) (res_man.Res_open(1) + sizeof(_standardHeader)));
- res_man.Res_close(1);
+ SetGlobalInterpreterVariables((int32 *) (res_man.open(1) + sizeof(_standardHeader)));
+ res_man.close(1);
DEMO = temp_demo_flag;
diff --git a/sword2/debug.cpp b/sword2/debug.cpp
index 17ef343f94..86801be9a5 100644
--- a/sword2/debug.cpp
+++ b/sword2/debug.cpp
@@ -332,7 +332,7 @@ void Build_debug_text(void) {
showVarPos = 115; // y-coord for first showVar
// res 1 is the global variables resource
- varTable = (int32 *) (res_man.Res_open(1) + sizeof(_standardHeader));
+ varTable = (int32 *) (res_man.open(1) + sizeof(_standardHeader));
for (showVarNo = 0; showVarNo < MAX_SHOWVARS; showVarNo++) {
varNo = showVar[showVarNo]; // get variable number
@@ -348,7 +348,7 @@ void Build_debug_text(void) {
}
}
- res_man.Res_close(1); // close global variables resource
+ res_man.close(1); // close global variables resource
// memory indicator - this should come last, to show all the
// sprite blocks above!
diff --git a/sword2/defs.h b/sword2/defs.h
index 0ae8ff0bec..61604016f8 100644
--- a/sword2/defs.h
+++ b/sword2/defs.h
@@ -29,7 +29,7 @@
// global variable references
// NB. 4 * <number from linc's Global Variables list>
-#define VAR(n) (*(uint32 *) (res_man.resList[1]->ad + sizeof(_standardHeader) + 4 * (n)))
+#define VAR(n) (*(uint32 *) (res_man._resList[1]->ad + sizeof(_standardHeader) + 4 * (n)))
#define ID VAR(0)
#define RESULT VAR(1)
diff --git a/sword2/function.cpp b/sword2/function.cpp
index 4f3e8d87a1..e1557bdd84 100644
--- a/sword2/function.cpp
+++ b/sword2/function.cpp
@@ -102,8 +102,8 @@ int32 FN_preload(int32 *params) {
// "preloading" gets it into memory in advance to avoid the cacheing
// delay that normally occurs before the first frame.
- res_man.Res_open(params[0]); // open resource
- res_man.Res_close(params[0]); // close resource
+ res_man.open(params[0]); // open resource
+ res_man.close(params[0]); // close resource
return IR_CONT; // continue script
}
@@ -336,8 +336,8 @@ int32 FN_display_msg(int32 *params) {
// +2 to skip the encoded text number in the first 2 chars; 3 is
// duration in seconds
- DisplayMsg(FetchTextLine(res_man.Res_open(text_res), local_text) + 2, 3);
- res_man.Res_close(text_res);
+ DisplayMsg(FetchTextLine(res_man.open(text_res), local_text) + 2, 3);
+ res_man.close(text_res);
RemoveMsg();
return IR_CONT;
@@ -351,26 +351,26 @@ int32 FN_reset_globals(int32 *params) {
uint32 *globals;
int j;
- size = res_man.Res_fetch_len(1);
+ size = res_man.fetchLen(1);
size -= sizeof(_standardHeader);
debug(5, "globals size %d", size / 4);
- globals = (uint32*) ((uint8 *) res_man.Res_open(1) + sizeof(_standardHeader));
+ globals = (uint32*) ((uint8 *) res_man.open(1) + sizeof(_standardHeader));
// blank each global variable
for (j = 0; j < size / 4; j++)
globals[j] = 0;
- res_man.Res_close(1);
+ res_man.close(1);
// all objects but george
- res_man.Kill_all_objects(0);
+ res_man.killAllObjects(0);
// reopen global variables resource & send address to interpreter - it
// won't be moving
- // SetGlobalInterpreterVariables((int32 *) (res_man.Res_open(1) + sizeof(_standardHeader)));
- // res_man.Res_close(1);
+ // SetGlobalInterpreterVariables((int32 *) (res_man.open(1) + sizeof(_standardHeader)));
+ // res_man.close(1);
// FOR THE DEMO - FORCE THE SCROLLING TO BE RESET! (James29may97)
// - this is taken from FN_init_background
diff --git a/sword2/icons.cpp b/sword2/icons.cpp
index 095dcf485f..3e6695666b 100644
--- a/sword2/icons.cpp
+++ b/sword2/icons.cpp
@@ -92,9 +92,9 @@ void Build_top_menu(void) {
// Call menu builder script which will register all carried menu
// objects. Run the 'build_menu' script in the 'menu_master' object
- head = res_man.Res_open(MENU_MASTER_OBJECT);
+ head = res_man.open(MENU_MASTER_OBJECT);
RunScript((char*) head, (char*) head, &null_pc);
- res_man.Res_close(MENU_MASTER_OBJECT);
+ res_man.close(MENU_MASTER_OBJECT);
// Compare new with old. Anything in master thats not in new gets
// removed from master - if found in new too, remove from temp
@@ -196,7 +196,7 @@ void Build_top_menu(void) {
icon_coloured = 1;
}
- icon = res_man.Res_open(master_menu_list[j].icon_resource) + sizeof(_standardHeader);
+ icon = res_man.open(master_menu_list[j].icon_resource) + sizeof(_standardHeader);
// The coloured icon is stored directly after the
// greyed out one.
@@ -205,7 +205,7 @@ void Build_top_menu(void) {
icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
SetMenuIcon(RDMENU_BOTTOM, j, icon);
- res_man.Res_close(res);
+ res_man.close(res);
} else {
// no icon here
SetMenuIcon(RDMENU_BOTTOM, j, NULL);
@@ -234,7 +234,7 @@ void Build_system_menu(void) {
// rest will grey out
for (j = 0; j < ARRAYSIZE(icon_list); j++) {
- icon = res_man.Res_open(icon_list[j]) + sizeof(_standardHeader);
+ icon = res_man.open(icon_list[j]) + sizeof(_standardHeader);
// The only case when an icon is grayed is when the player
// is dead. Then SAVE is not available.
@@ -243,7 +243,7 @@ void Build_system_menu(void) {
icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
SetMenuIcon(RDMENU_TOP, j, icon);
- res_man.Res_close(icon_list[j]);
+ res_man.close(icon_list[j]);
}
ShowMenu(RDMENU_TOP);
diff --git a/sword2/layers.cpp b/sword2/layers.cpp
index b432e88404..f8cb339519 100644
--- a/sword2/layers.cpp
+++ b/sword2/layers.cpp
@@ -89,7 +89,7 @@ int32 FN_init_background(int32 *params) {
// each cycle
// file points to 1st byte in the layer file
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
screen_head = FetchScreenHeader(file);
@@ -186,7 +186,7 @@ int32 FN_init_background(int32 *params) {
}
// close the screen file
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
SetUpBackgroundLayers();
@@ -208,7 +208,7 @@ void SetUpBackgroundLayers(void) {
// open resource & set pointers to headers
// file points to 1st byte in the layer file
- file = res_man.Res_open(this_screen.background_layer_id);
+ file = res_man.open(this_screen.background_layer_id);
screen_head = FetchScreenHeader(file);
@@ -237,6 +237,6 @@ void SetUpBackgroundLayers(void) {
}
// close the screen file
- res_man.Res_close(this_screen.background_layer_id);
+ res_man.close(this_screen.background_layer_id);
}
}
diff --git a/sword2/logic.cpp b/sword2/logic.cpp
index 770982f94f..dab370d76c 100644
--- a/sword2/logic.cpp
+++ b/sword2/logic.cpp
@@ -62,7 +62,7 @@ int logic::processSession(void) {
// processing on the current list
while (_pc != 0xffffffff) {
- head = (_standardHeader*) res_man.Res_open(run_list);
+ head = (_standardHeader*) res_man.open(run_list);
if (head->fileType != RUN_LIST)
Con_fatal_error("Logic_engine %d not a run_list", run_list);
@@ -76,7 +76,7 @@ int logic::processSession(void) {
// release the list again so it can float in memory - at this
// point not one thing should be locked
- res_man.Res_close(run_list);
+ res_man.close(run_list);
debug(5, "%d", ID);
@@ -86,7 +86,7 @@ int logic::processSession(void) {
return 0;
}
- head = (_standardHeader*) res_man.Res_open(ID);
+ head = (_standardHeader*) res_man.open(ID);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("Logic_engine %d not an object", ID);
@@ -132,7 +132,7 @@ int logic::processSession(void) {
raw_data_ad = (char*) head;
- far_head = (_standardHeader*) res_man.Res_open(script / SIZE);
+ far_head = (_standardHeader*) res_man.open(script / SIZE);
if (far_head->fileType != GAME_OBJECT && far_head->fileType != SCREEN_MANAGER)
Con_fatal_error("Logic_engine %d not a far object (its a %d)", script / SIZE, far_head->fileType);
@@ -147,7 +147,7 @@ int logic::processSession(void) {
ret = RunScript(raw_script_ad, raw_data_ad, &_curObjectHub->script_pc[LEVEL]);
// close foreign object again
- res_man.Res_close(script / SIZE);
+ res_man.close(script / SIZE);
// reset to us for service script
raw_script_ad = raw_data_ad;
@@ -203,7 +203,7 @@ int logic::processSession(void) {
// and that's it so close the object resource
- res_man.Res_close(ID);
+ res_man.close(ID);
}
// leaving a room so remove all ids that must reboot correctly
@@ -328,14 +328,14 @@ uint32 logic::examineRunList(void) {
if (_currentRunList) {
// open and lock in place
- game_object_list = (uint32 *) (res_man.Res_open(_currentRunList) + sizeof(_standardHeader));
+ game_object_list = (uint32 *) (res_man.open(_currentRunList) + sizeof(_standardHeader));
Print_to_console("runlist number %d", _currentRunList);
while(*(game_object_list)) {
- file_header = (_standardHeader*) res_man.Res_open(*(game_object_list));
+ file_header = (_standardHeader*) res_man.open(*(game_object_list));
Print_to_console(" %d %s", *(game_object_list), file_header->name);
- res_man.Res_close(*(game_object_list++));
+ res_man.close(*(game_object_list++));
scrolls++;
Build_display();
@@ -361,7 +361,7 @@ uint32 logic::examineRunList(void) {
}
}
- res_man.Res_close(_currentRunList);
+ res_man.close(_currentRunList);
} else
Print_to_console("no run list set");
@@ -440,7 +440,7 @@ int32 FN_add_to_kill_list(int32 *params) {
void logic::processKillList(void) {
for (uint32 j = 0; j < kills; j++)
- res_man.Remove_res(object_kill_list[j]);
+ res_man.remove(object_kill_list[j]);
kills = 0;
}
diff --git a/sword2/maketext.cpp b/sword2/maketext.cpp
index cb4152d937..ad97f4c38a 100644
--- a/sword2/maketext.cpp
+++ b/sword2/maketext.cpp
@@ -283,7 +283,7 @@ mem* BuildTextSprite(uint8 *sentence, uint32 fontRes, uint8 pen, _lineInfo *line
memset(linePtr, NO_COL, sizeOfSprite);
// open font file
- charSet = res_man.Res_open(fontRes);
+ charSet = res_man.open(fontRes);
// fill sprite with characters, one line at a time
@@ -317,7 +317,7 @@ mem* BuildTextSprite(uint8 *sentence, uint32 fontRes, uint8 pen, _lineInfo *line
}
// close font file
- res_man.Res_close(fontRes);
+ res_man.close(fontRes);
// unlock the sprite memory block, so it's movable
Float_mem(textSprite);
@@ -334,14 +334,14 @@ uint16 CharWidth(uint8 ch, uint32 fontRes) {
uint16 width;
// open font file
- charSet = res_man.Res_open(fontRes);
+ charSet = res_man.open(fontRes);
// move to approp. sprite (header)
charFrame = FindChar(ch, charSet);
width = charFrame->width;
// close font file
- res_man.Res_close(fontRes);
+ res_man.close(fontRes);
// return its width
return width;
@@ -356,14 +356,14 @@ uint16 CharHeight(uint32 fontRes) {
uint16 height;
// open font file
- charSet = res_man.Res_open(fontRes);
+ charSet = res_man.open(fontRes);
// assume all chars the same height, i.e. FIRST_CHAR is as good as any
charFrame = FindChar(FIRST_CHAR, charSet);
height = charFrame->height;
// close font file
- res_man.Res_close(fontRes);
+ res_man.close(fontRes);
// return its height
return height;
@@ -625,7 +625,7 @@ void InitialiseFontResourceFlags(void) {
uint8 language;
// open the text resource
- textFile = res_man.Res_open(TEXT_RES);
+ textFile = res_man.open(TEXT_RES);
// If language is Polish or Finnish it requires alternate fonts.
// Otherwise, use regular fonts
@@ -662,7 +662,7 @@ void InitialiseFontResourceFlags(void) {
SetWindowName((char*) textLine);
// now ok to close the text file
- res_man.Res_close(TEXT_RES);
+ res_man.close(TEXT_RES);
}
// called from the above function, and also from console.cpp
diff --git a/sword2/mem_view.cpp b/sword2/mem_view.cpp
index 60b7ba8792..0e3ceb83b4 100644
--- a/sword2/mem_view.cpp
+++ b/sword2/mem_view.cpp
@@ -44,9 +44,9 @@ void Console_mem_display(void) {
j = base_mem_block;
do {
if (mem_list[j].uid < 65536) {
- file_header = (_standardHeader*) res_man.Res_open(mem_list[j].uid);
+ file_header = (_standardHeader*) res_man.open(mem_list[j].uid);
// close immediately so give a true count
- res_man.Res_close(mem_list[j].uid);
+ res_man.close(mem_list[j].uid);
debug(5, "view %d", mem_list[j].uid);
@@ -73,10 +73,10 @@ void Console_mem_display(void) {
mem_list[j].size / 1024,
(mem_list[j].size * 100) / total_free_memory,
mem_list[j].uid,
- res_man.Fetch_cluster(mem_list[j].uid),
+ res_man.fetchCluster(mem_list[j].uid),
file_header->name,
- res_man.Fetch_age(mem_list[j].uid),
- res_man.Fetch_count(mem_list[j].uid));
+ res_man.fetchAge(mem_list[j].uid),
+ res_man.fetchCount(mem_list[j].uid));
} else
Print_to_console(" %d is an illegal resource", mem_list[j].uid);
} else {
@@ -182,5 +182,5 @@ void Create_mem_string(char *string) {
sprintf(string,
"locked(%u)+float(%u)+free(%u) = %u/%u blocks (%u%% used)(cur %uk)",
mem_locked, mem_floating, mem_free, blocksUsed, MAX_mem_blocks,
- percent, (res_man.Res_fetch_useage() / 1024));
+ percent, (res_man.fetchUsage() / 1024));
}
diff --git a/sword2/memory.cpp b/sword2/memory.cpp
index 8c772ec88f..9499579862 100644
--- a/sword2/memory.cpp
+++ b/sword2/memory.cpp
@@ -498,7 +498,7 @@ mem *Twalloc(uint32 size, uint32 type, uint32 unique_id) {
while (VirtualDefrag(size)) {
// trash the oldest closed resource
- if (!res_man.Help_the_aged_out()) {
+ if (!res_man.helpTheAgedOut()) {
error("Twalloc ran out of memory: size=%d type=%d unique_id=%d", size, type, unique_id);
}
}
diff --git a/sword2/memory.h b/sword2/memory.h
index 0effce6043..6a1fa6c7bb 100644
--- a/sword2/memory.h
+++ b/sword2/memory.h
@@ -28,7 +28,7 @@ typedef struct {
uint32 size;
int32 parent; // who is before us
int32 child; // who is after us
- // id of a position in the resList or some other unique id - for the
+ // id of a position in the _resList or some other unique id - for the
// visual display only
uint32 uid;
uint8 *ad;
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index 49d74fc7d5..9581075ac2 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -209,9 +209,9 @@ void System_menu(void) {
for (j = 0; j < ARRAYSIZE(icon_list); j++) {
// change all others to grey
if (j != hit) {
- icon = res_man.Res_open(icon_list[j]) + sizeof(_standardHeader);
+ icon = res_man.open(icon_list[j]) + sizeof(_standardHeader);
SetMenuIcon(RDMENU_TOP, j, icon);
- res_man.Res_close( icon_list[j] );
+ res_man.close( icon_list[j] );
}
}
@@ -798,8 +798,8 @@ void Set_mouse(uint32 res) {
mouse_pointer_res = res;
if (res) {
- icon = res_man.Res_open(res) + sizeof(_standardHeader);
- len = res_man.resList[res]->size - sizeof(_standardHeader);
+ icon = res_man.open(res) + sizeof(_standardHeader);
+ len = res_man._resList[res]->size - sizeof(_standardHeader);
// don't pulse the normal pointer - just do the regular anim
// loop
@@ -809,7 +809,7 @@ void Set_mouse(uint32 res) {
else
SetMouseAnim(icon, len, RDMOUSE_FLASH);
- res_man.Res_close(res);
+ res_man.close(res);
} else {
// blank cursor
SetMouseAnim(NULL, 0, 0);
@@ -823,12 +823,12 @@ void Set_luggage(uint32 res) {
real_luggage_item = res;
if (res) {
- icon = res_man.Res_open(res) + sizeof(_standardHeader);
- len = res_man.resList[res]->size - sizeof(_standardHeader);
+ icon = res_man.open(res) + sizeof(_standardHeader);
+ len = res_man._resList[res]->size - sizeof(_standardHeader);
SetLuggageAnim(icon, len);
- res_man.Res_close(res);
+ res_man.close(res);
} else
SetLuggageAnim(NULL, 0);
}
@@ -1017,7 +1017,7 @@ void CreatePointerText(uint32 textId, uint32 pointerRes) {
local_text = textId & 0xffff;
// open text file & get the line
- text = FetchTextLine(res_man.Res_open(text_res), local_text);
+ text = FetchTextLine(res_man.open(text_res), local_text);
// 'text+2' to skip the first 2 bytes which form the
// line reference number
@@ -1029,7 +1029,7 @@ void CreatePointerText(uint32 textId, uint32 pointerRes) {
speech_font_id, justification);
// now ok to close the text file
- res_man.Res_close(text_res);
+ res_man.close(text_res);
}
}
}
@@ -1153,7 +1153,7 @@ int32 FN_add_human(int32 *params) {
// Trash all object resources so they load in fresh & restart
// their logic scripts
- res_man.Kill_all_objects(0);
+ res_man.killAllObjects(0);
BS2_SetPalette(0, 1, black, RDPAL_INSTANT);
}
diff --git a/sword2/protocol.cpp b/sword2/protocol.cpp
index ae1882643c..dd234f3751 100644
--- a/sword2/protocol.cpp
+++ b/sword2/protocol.cpp
@@ -204,8 +204,8 @@ uint8 CheckTextLine(uint8 *file, uint32 text_line) {
uint8 *FetchObjectName(int32 resourceId) {
_standardHeader *header;
- header = (_standardHeader*) res_man.Res_open(resourceId);
- res_man.Res_close(resourceId);
+ header = (_standardHeader*) res_man.open(resourceId);
+ res_man.close(resourceId);
// note this pointer is no longer valid, but it should be ok until
// another resource is opened!
diff --git a/sword2/resman.cpp b/sword2/resman.cpp
index b46ce60887..5c844f809a 100644
--- a/sword2/resman.cpp
+++ b/sword2/resman.cpp
@@ -39,8 +39,8 @@
#include "mouse.h" // for system Set_mouse & Set_luggage routines
#include "protocol.h"
#include "resman.h"
-#include "sound.h" // (James22july97) for Clear_fx_queue() called from CacheNewCluster()
-#include "sword2.h" // (James11aug97) for CloseGame()
+#include "sound.h" // for Clear_fx_queue() called from cacheNewCluster()
+#include "sword2.h" // for CloseGame()
#include "router.h"
// ---------------------------------------------------------------------------
@@ -59,7 +59,7 @@
#define BUFFERSIZE 4096
-resMan res_man; //declare the object global
+ResourceManager res_man; //declare the object global
// ---------------------------------------------------------------------------
//
@@ -88,9 +88,9 @@ typedef struct {
#pragma END_PACK_STRUCTS
#endif
-// ---------------------------------------------------------------------------
+// FIXME: Should init() / exit() be moved to constructor / destructor instead?
-void resMan::InitResMan(void) {
+void ResourceManager::init(void) {
// We read in the resource info which tells us the names of the
// resource cluster files ultimately, although there might be groups
// within the clusters at this point it makes no difference. We only
@@ -102,10 +102,10 @@ void resMan::InitResMan(void) {
uint32 pos = 0;
uint32 j = 0;
- total_clusters = 0;
+ _totalClusters = 0;
if (!file.open("resource.inf")) {
- error("InitResMan cannot *OPEN* resource.inf");
+ error("init cannot *OPEN* resource.inf");
}
end = file.size();
@@ -115,7 +115,7 @@ void resMan::InitResMan(void) {
if (file.read(temp->ad, end) != end) {
file.close();
- error("InitResMan cannot *READ* resource.inf");
+ error("init cannot *READ* resource.inf");
}
file.close();
@@ -125,95 +125,94 @@ void resMan::InitResMan(void) {
do {
// item must have an #0d0a
while(temp->ad[j] != 13) {
- resource_files[total_clusters][pos] = temp->ad[j];
+ _resourceFiles[_totalClusters][pos] = temp->ad[j];
j++;
pos++;
}
// NULL terminate our extracted string
- resource_files[total_clusters][pos]=0;
+ _resourceFiles[_totalClusters][pos]=0;
// Reset position in current slot between entries, skip the
// 0x0a in the source and increase the number of clusters.
pos = 0;
j += 2;
- total_clusters++;
+ _totalClusters++;
// TODO: put overload check here
} while (j != end); // using this method the Gode generated resource.inf must have #0d0a on the last entry
// now load in the binary id to res conversion table
if (!file.open("resource.tab")) {
- error("InitResMan cannot *OPEN* resource.tab");
+ error("init cannot *OPEN* resource.tab");
}
// find how many resources
end = file.size();
- total_res_files = end / 4;
+ _totalResFiles = end / 4;
// table seems ok so malloc some space
- res_conv_table = (uint16 *) malloc(end);
+ _resConvTable = (uint16 *) malloc(end);
for (j = 0; j < end / 2; j++)
- res_conv_table[j] = file.readUint16LE();
+ _resConvTable[j] = file.readUint16LE();
if (file.ioFailed()) {
file.close();
- error("InitResMan cannot *READ* resource.tab");
+ error("init cannot *READ* resource.tab");
}
file.close();
if (!file.open("cd.inf")) {
- error("InitResMan cannot *OPEN* cd.inf");
+ error("init cannot *OPEN* cd.inf");
}
- _cd_inf *cdInf = new _cd_inf[total_clusters];
+ _cd_inf *cdInf = new _cd_inf[_totalClusters];
- for (j = 0; j < total_clusters; j++) {
+ for (j = 0; j < _totalClusters; j++) {
file.read(cdInf[j].clusterName, sizeof(cdInf[j].clusterName));
cdInf[j].cd = file.readByte();
if (file.ioFailed()) {
- error("InitResMan failed to read cd.inf. Insufficient entries?");
+ error("init failed to read cd.inf. Insufficient entries?");
}
}
file.close();
- for (j = 0; j < total_clusters; j++) {
+ for (j = 0; j < _totalClusters; j++) {
uint32 i = 0;
- while (scumm_stricmp((char *) cdInf[i].clusterName, resource_files[j]) != 0 && i < total_clusters)
+ while (scumm_stricmp((char *) cdInf[i].clusterName, _resourceFiles[j]) != 0 && i < _totalClusters)
i++;
- if (i == total_clusters) {
- error("InitResMan, %s is not in cd.inf",resource_files[j]);
+ if (i == _totalClusters) {
+ error("init, %s is not in cd.inf", _resourceFiles[j]);
} else
- cdTab[j] = cdInf[i].cd;
+ _cdTab[j] = cdInf[i].cd;
}
- debug(5, "%d resources in %d cluster files", total_res_files, total_clusters);
- for (j = 0; j < total_clusters; j++)
- debug(5, "filename of cluster %d: -%s", j, resource_files[j]);
+ debug(5, "%d resources in %d cluster files", _totalResFiles, _totalClusters);
+ for (j = 0; j < _totalClusters; j++)
+ debug(5, "filename of cluster %d: -%s", j, _resourceFiles[j]);
// create space for a list of pointers to mem's
- resList = (mem **) malloc(total_res_files * sizeof(mem *));
+ _resList = (mem **) malloc(_totalResFiles * sizeof(mem *));
- age = (uint32 *) malloc(total_res_files * sizeof(uint32));
- // status = (uint16 *) malloc(total_res_files * sizeof(uint16));
- count = (uint16 *) malloc(total_res_files * sizeof(uint16));
+ _age = (uint32 *) malloc(_totalResFiles * sizeof(uint32));
+ _count = (uint16 *) malloc(_totalResFiles * sizeof(uint16));
- for (j = 0; j < total_res_files; j++) {
+ for (j = 0; j < _totalResFiles; j++) {
// age must be 0 if the file is not in memory at all
- age[j] = 0;
- count[j] = 0;
+ _age[j] = 0;
+ _count[j] = 0;
}
- resTime = 1; //cannot start at 0
+ _resTime = 1; //cannot start at 0
Free_mem(temp); //get that memory back
// FIXME: Is this really needed?
@@ -223,39 +222,36 @@ void resMan::InitResMan(void) {
/*
// Scan for CD drives.
for (char c = 'C'; c <= 'Z'; c++) {
- sprintf(cdPath, "%c:\\", c);
- if (GetDriveType(cdPath) == DRIVE_CDROM)
- cdDrives[index++] = c;
+ sprintf(_cdPath, "%c:\\", c);
+ if (GetDriveType(_cdPath) == DRIVE_CDROM)
+ _cdDrives[index++] = c;
}
*/
- cdDrives[index++] = 'C';
+ _cdDrives[index++] = 'C';
if (index == 0) {
- error("InitResMan, cannot find CD drive");
+ error("init, cannot find CD drive");
}
while (index < 24)
- cdDrives[index++] = 0;
+ _cdDrives[index++] = 0;
}
else
file.close();
}
-char *resMan::GetCdPath(void) {
- return cdPath;
-}
-
-void resMan::Close_ResMan(void) {
+void ResourceManager::exit(void) {
// free up our mallocs
- free(resList);
- free(age);
- // free(status);
- free(count);
+ free(_resList);
+ free(_age);
+ free(_count);
}
// Quick macro to make swapping in-place easier to write
+
#define SWAP16(x) x = SWAP_BYTES_16(x)
#define SWAP32(x) x = SWAP_BYTES_32(x)
+
void convertEndian(uint8 *file, uint32 len) {
int i;
_standardHeader *hdr = (_standardHeader *)file;
@@ -437,7 +433,7 @@ void convertEndian(uint8 *file, uint32 len) {
}
}
-uint8 *resMan::Res_open(uint32 res) {
+uint8 *ResourceManager::open(uint32 res) {
// returns ad of resource. Loads if not in memory
// retains a count
// resource can be aged out of memory if count = 0
@@ -452,31 +448,31 @@ uint8 *resMan::Res_open(uint32 res) {
uint32 table_offset;
//#ifdef _SWORD2_DEBUG
- if (res >= total_res_files)
- Con_fatal_error("Res_open illegal resource %d (there are %d resources 0-%d)", res, total_res_files, total_res_files - 1);
+ if (res >= _totalResFiles)
+ Con_fatal_error("open illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
//#endif
// is the resource in memory already?
// if the file is not in memory then age should and MUST be 0
- if (!age[res]) {
+ if (!_age[res]) {
// fetch the correct file and read in the correct portion
// if the file cannot fit then we must trash the oldest large
// enough floating file
// points to the number of the ascii filename
- parent_res_file = res_conv_table[res * 2];
+ parent_res_file = _resConvTable[res * 2];
//#ifdef _SWORD2_DEBUG
if (parent_res_file == 0xffff)
- Con_fatal_error("Res_open tried to open null & void resource number %d", res);
+ Con_fatal_error("open tried to open null & void resource number %d", res);
//#endif
// relative resource within the file
- actual_res = res_conv_table[(res * 2) + 1];
+ actual_res = _resConvTable[(res * 2) + 1];
- // first we have to find the file via the res_conv_table
+ // first we have to find the file via the _resConvTable
- debug(5, "resOpen %s res %d", resource_files[parent_res_file], res);
+ debug(5, "resOpen %s res %d", _resourceFiles[parent_res_file], res);
// ** at this point here we start to think about where the
// ** file is and prompt the user for the right CD to be
@@ -486,12 +482,12 @@ uint8 *resMan::Res_open(uint32 res) {
// ** game - LINC should write this someplace.
/* these probably aren't necessary - khalek
- if (!(cdTab[parent_res_file] & LOCAL_CACHE) && !(cdTab[parent_res_file] & LOCAL_PERM)) {
+ if (!(_cdTab[parent_res_file] & LOCAL_CACHE) && !(_cdTab[parent_res_file] & LOCAL_PERM)) {
// This cluster is on a CD, we need to cache a new one.
- CacheNewCluster(parent_res_file);
- } else if (!(cdTab[parent_res_file] & LOCAL_PERM)) {
+ cacheNewCluster(parent_res_file);
+ } else if (!(_cdTab[parent_res_file] & LOCAL_PERM)) {
// Makes sure that the correct CD is in the drive.
- GetCd(cdTab[parent_res_file] & 3);
+ getCd(_cdTab[parent_res_file] & 3);
}
*/
@@ -504,18 +500,18 @@ uint8 *resMan::Res_open(uint32 res) {
// The code to ask for the correct CD will probably be needed
// later, too.
//
- // And there's some music / FX stuff in CacheNewCluster() that
+ // And there's some music / FX stuff in cacheNewCluster() that
// might be needed as well.
//
// But this will do for now.
- if (!(cdTab[parent_res_file] & LOCAL_PERM)) {
- curCd = cdTab[parent_res_file] & 3;
+ if (!(_cdTab[parent_res_file] & LOCAL_PERM)) {
+ _curCd = _cdTab[parent_res_file] & 3;
}
// open the cluster file
- if (!file.open(resource_files[parent_res_file]))
- Con_fatal_error("Res_open cannot *OPEN* %s", resource_files[parent_res_file]);
+ if (!file.open(_resourceFiles[parent_res_file]))
+ Con_fatal_error("open cannot *OPEN* %s", _resourceFiles[parent_res_file]);
// 1st DWORD of a cluster is an offset to the look-up table
@@ -537,7 +533,7 @@ uint8 *resMan::Res_open(uint32 res) {
// ok, we know the length so try and allocate the memory
// if it can't then old files will be ditched until it works
- resList[res] = Twalloc(len, MEM_locked, res);
+ _resList[res] = Twalloc(len, MEM_locked, res);
/* This probably isn't needed
// Do a quick ServiceWindows to stop the music screwing up.
@@ -546,44 +542,44 @@ uint8 *resMan::Res_open(uint32 res) {
// now load the file
// hurray, load it in.
- file.read(resList[res]->ad, len);
+ file.read(_resList[res]->ad, len);
//close the cluster
file.close();
#ifdef SCUMM_BIG_ENDIAN
- convertEndian((uint8 *)resList[res]->ad, len);
+ convertEndian((uint8 *) _resList[res]->ad, len);
#endif
} else {
- debug(5, "RO %d, already open count=%d", res, count[res]);
+ debug(5, "RO %d, already open count=%d", res, _count[res]);
}
// number of times opened - the file won't move in memory while count
// is non zero
- count[res]++;
+ _count[res]++;
// update the accessed time stamp - touch the file in other words
- age[res] = resTime;
+ _age[res] = _resTime;
// pass the address of the mem & lock the memory too
// might be locked already (if count > 1)
- Lock_mem(resList[res]);
+ Lock_mem(_resList[res]);
- return (uint8 *) resList[res]->ad;
+ return (uint8 *) _resList[res]->ad;
}
-uint8 resMan::Res_check_valid(uint32 res) {
+uint8 ResourceManager::checkValid(uint32 res) {
// returns '1' if resource is valid, otherwise returns '0'
// used in startup.cpp to ignore invalid screen-manager resources
uint16 parent_res_file;
// resource number out of range
- if (res >= total_res_files)
+ if (res >= _totalResFiles)
return 0;
// points to the number of the ascii filename
- parent_res_file = res_conv_table[res * 2];
+ parent_res_file = _resConvTable[res * 2];
// null & void resource
if (parent_res_file == 0xffff)
@@ -593,7 +589,7 @@ uint8 resMan::Res_check_valid(uint32 res) {
return 1;
}
-void resMan::Res_next_cycle(void) {
+void ResourceManager::nextCycle(void) {
// increment the cycle and calculate actual per-cycle memory useage
#ifdef _SWORD2_DEBUG
@@ -601,16 +597,16 @@ void resMan::Res_next_cycle(void) {
#endif
#ifdef _SWORD2_DEBUG
- current_memory_useage = 0;
+ _currentMemoryUsage = 0;
- for (j = 1; j < total_res_files; j++) {
+ for (j = 1; j < _totalResFiles; j++) {
// was accessed last cycle
- if (age[j] == resTime)
- current_memory_useage += resList[j]->size;
+ if (_age[j] == _resTime)
+ _currentMemoryUsage += _resList[j]->size;
}
#endif
- resTime++;
+ _resTime++;
// if you left the game running for a hundred years when this went to 0
// there'd be a resource left stuck in memory - after another hundred
@@ -619,39 +615,38 @@ void resMan::Res_next_cycle(void) {
// Mind you, by then the our get_msecs() function will have wrapped
// around too, probably causing a mess of other problems.
- if (!resTime)
- resTime++;
+ if (!_resTime)
+ _resTime++;
}
-uint32 resMan::Res_fetch_useage(void) {
+uint32 ResourceManager::fetchUsage(void) {
// returns memory usage previous cycle
- return current_memory_useage;
+ return _currentMemoryUsage;
}
-void resMan::Res_close(uint32 res) {
+void ResourceManager::close(uint32 res) {
// decrements the count
// resource floats when count = 0
//#ifdef _SWORD2_DEBUG
- if (res >= total_res_files)
- Con_fatal_error("Res_closeing illegal resource %d (there are %d resources 0-%d)", res, total_res_files, total_res_files - 1);
+ if (res >= _totalResFiles)
+ Con_fatal_error("closing illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
//closing but isnt open?
- if (!(count[res]))
- Con_fatal_error("Res_close closing %d but it isn't open", res);
+ if (!(_count[res]))
+ Con_fatal_error("close: closing %d but it isn't open", res);
//#endif
//one less has it open
- count[res]--;
+ _count[res]--;
//if noone has the file open then unlock and allow to float
- if (!count[res]) {
- Float_mem(resList[res]); // pass the address of the mem
- // *(status+res) -= RES_locked; // unlock the resource
+ if (!_count[res]) {
+ Float_mem(_resList[res]); // pass the address of the mem
}
}
-uint32 resMan::Res_fetch_len(uint32 res) {
+uint32 ResourceManager::fetchLen(uint32 res) {
// returns the total file length of a resource - i.e. all headers are
// included too
@@ -662,16 +657,16 @@ uint32 resMan::Res_fetch_len(uint32 res) {
uint32 table_offset;
// points to the number of the ascii filename
- parent_res_file = res_conv_table[res * 2];
+ parent_res_file = _resConvTable[res * 2];
// relative resource within the file
- actual_res = res_conv_table[(res * 2) + 1];
+ actual_res = _resConvTable[(res * 2) + 1];
- // first we have to find the file via the res_conv_table
+ // first we have to find the file via the _resConvTable
// open the cluster file
- if (!fh.open(resource_files[parent_res_file]))
- Con_fatal_error("Res_fetch_len cannot *OPEN* %s", resource_files[parent_res_file]);
+ if (!fh.open(_resourceFiles[parent_res_file]))
+ Con_fatal_error("fetchLen cannot *OPEN* %s", _resourceFiles[parent_res_file]);
// 1st DWORD of a cluster is an offset to the look-up table
table_offset = fh.readUint32LE();
@@ -684,45 +679,45 @@ uint32 resMan::Res_fetch_len(uint32 res) {
return len;
}
-char *resMan::Fetch_cluster(uint32 res) {
+char *ResourceManager::fetchCluster(uint32 res) {
// returns a pointer to the ascii name of the cluster file which
// contains resource res
- return resource_files[res_conv_table[res * 2]];
+ return _resourceFiles[_resConvTable[res * 2]];
}
-uint32 resMan::Fetch_age(uint32 res) {
+uint32 ResourceManager::fetchAge(uint32 res) {
// return the age of res
- return age[res];
+ return _age[res];
}
-uint32 resMan::Fetch_count(uint32 res) {
+uint32 ResourceManager::fetchCount(uint32 res) {
// return the open count of res
- return count[res];
+ return _count[res];
}
-uint32 resMan::Help_the_aged_out(void) {
+uint32 ResourceManager::helpTheAgedOut(void) {
// remove from memory the oldest closed resource
- uint32 oldest_res; //holds id of oldest found so far when we have to chuck stuff out of memory
- uint32 oldest_age; //age of above during search
+ uint32 oldest_res; // holds id of oldest found so far when we have to chuck stuff out of memory
+ uint32 oldest_age; // age of above during search
uint32 j;
uint32 largestResource = 0;
- oldest_age = resTime;
+ oldest_age = _resTime;
oldest_res = 0;
- for (j = 2; j < total_res_files; j++) {
+ for (j = 2; j < _totalResFiles; j++) {
// not held open and older than this one
- if (!count[j] && age[j] && age[j] <= oldest_age) {
- if (age[j] == oldest_age && resList[j]->size > largestResource) {
+ if (!_count[j] && _age[j] && _age[j] <= oldest_age) {
+ if (_age[j] == oldest_age && _resList[j]->size > largestResource) {
// Kick old resource of oldest age and largest
// size (Helps the poor defragger).
oldest_res = j;
- largestResource = resList[j]->size;
- } else if (age[j] < oldest_age) {
+ largestResource = _resList[j]->size;
+ } else if (_age[j] < oldest_age) {
oldest_res = j;
- oldest_age = age[j];
- largestResource = resList[j]->size;
+ oldest_age = _age[j];
+ largestResource = _resList[j]->size;
}
}
}
@@ -732,30 +727,30 @@ uint32 resMan::Help_the_aged_out(void) {
if (!oldest_res)
return 0;
- debug(5, "removing %d, age %d, size %d", oldest_res, age[oldest_res], resList[oldest_res]->size);
+ debug(5, "removing %d, age %d, size %d", oldest_res, _age[oldest_res], _resList[oldest_res]->size);
// trash this old resource
- age[oldest_res] = 0; // effectively gone from resList
- Free_mem(resList[oldest_res]); // release the memory too
+ _age[oldest_res] = 0; // effectively gone from _resList
+ Free_mem(_resList[oldest_res]); // release the memory too
- return resList[oldest_res]->size; //return bytes freed
+ return _resList[oldest_res]->size; // return bytes freed
}
-void resMan::Print_console_clusters(void) {
+void ResourceManager::printConsoleClusters(void) {
uint32 j;
- if (total_clusters) {
- for (j = 0; j < total_clusters; j++)
- Print_to_console(" %s", resource_files[j]);
- Print_to_console(" %d resources", total_res_files);
+ if (_totalClusters) {
+ for (j = 0; j < _totalClusters; j++)
+ Print_to_console(" %s", _resourceFiles[j]);
+ Print_to_console(" %d resources", _totalResFiles);
} else
Print_to_console(" argh! No resources");
Scroll_console();
}
-void resMan::Examine_res(uint8 *input) {
+void ResourceManager::examine(uint8 *input) {
uint32 j = 0;
uint32 res;
_standardHeader *file_header;
@@ -773,13 +768,13 @@ void resMan::Examine_res(uint8 *input) {
if (!res)
Print_to_console("illegal resource");
- else if (res >= total_res_files)
- Print_to_console("illegal resource %d (there are %d resources 0-%d)", res, total_res_files, total_res_files - 1);
- else if (res_conv_table[res * 2] == 0xffff)
+ else if (res >= _totalResFiles)
+ Print_to_console("illegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
+ else if (_resConvTable[res * 2] == 0xffff)
Print_to_console("%d is a null & void resource number", res);
else {
//open up the resource and take a look inside!
- file_header = (_standardHeader*) res_man.Res_open(res);
+ file_header = (_standardHeader*) res_man.open(res);
// Print_to_console("%d", file_header->fileType);
// Print_to_console("%s", file_header->name);
@@ -861,14 +856,14 @@ void resMan::Examine_res(uint8 *input) {
Print_to_console(" unrecognised fileType %d", file_header->fileType);
break;
}
- res_man.Res_close(res);
+ res_man.close(res);
}
} else {
Print_to_console("try typing a number");
}
}
-void resMan::Kill_res(uint8 *input) {
+void ResourceManager::kill(uint8 *input) {
int j = 0;
uint32 res;
@@ -883,19 +878,19 @@ void resMan::Kill_res(uint8 *input) {
if (!input[j]) {
res = atoi((char*) input);
-//#ifdef _SWORD2_DEBUG
+// #ifdef _SWORD2_DEBUG
if (!res)
Print_to_console("illegal resource");
- if (res >= total_res_files)
- Con_fatal_error(" llegal resource %d (there are %d resources 0-%d)", res, total_res_files, total_res_files - 1);
-//#endif
+ if (res >= _totalResFiles)
+ Con_fatal_error(" llegal resource %d (there are %d resources 0-%d)", res, _totalResFiles, _totalResFiles - 1);
+// #endif
// if noone has the file open then unlock and allow to float
- if (!count[res]) {
- if (age[res]) {
- age[res] = 0; //effectively gone from resList
- Free_mem(resList[res]); //release the memory too
+ if (!_count[res]) {
+ if (_age[res]) {
+ _age[res] = 0; // effectively gone from _resList
+ Free_mem(_resList[res]); // release the memory too
Print_to_console(" trashed %d", res);
} else
Print_to_console("%d not in memory", res);
@@ -906,16 +901,16 @@ void resMan::Kill_res(uint8 *input) {
}
}
-void resMan::Remove_res(uint32 res) {
- if (age[res]) {
- age[res] = 0; //effectively gone from resList
- Free_mem(resList[res]); //release the memory too
+void ResourceManager::remove(uint32 res) {
+ if (_age[res]) {
+ _age[res] = 0; // effectively gone from _resList
+ Free_mem(_resList[res]); // release the memory too
debug(5, " - Trashing %d", res);
} else
- debug(5, "Remove_res(%d) not even in memory!", res);
+ debug(5, "remove(%d) not even in memory!", res);
}
-void resMan::Remove_all_res(void) {
+void ResourceManager::removeAll(void) {
// remove all res files from memory - ready for a total restart
// including player object & global variables resource
@@ -927,15 +922,15 @@ void resMan::Remove_all_res(void) {
do {
if (mem_list[j].uid < 65536) { // a resource
res = mem_list[j].uid;
- age[res] = 0; // effectively gone from resList
- Free_mem(resList[res]); // release the memory too
+ _age[res] = 0; // effectively gone from _resList
+ Free_mem(_resList[res]); // release the memory too
}
j = mem_list[j].child;
} while (j != -1);
}
-void resMan::Kill_all_res(uint8 wantInfo) {
+void ResourceManager::killAll(uint8 wantInfo) {
// remove all res files from memory
// its quicker to search the mem blocs for res files than search
// resource lists for those in memory
@@ -954,13 +949,13 @@ void resMan::Kill_all_res(uint8 wantInfo) {
res = mem_list[j].uid;
// not the global vars which are assumed to be open in
- // memory & not the player object! (James17jan97)
+ // memory & not the player object!
if (res != 1 && res != CUR_PLAYER_ID) {
- header = (_standardHeader*) res_man.Res_open(res);
- res_man.Res_close(res);
+ header = (_standardHeader *) res_man.open(res);
+ res_man.close(res);
- age[res] = 0; // effectively gone from resList
- Free_mem(resList[res]); // release the memory too
+ _age[res] = 0; // effectively gone from _resList
+ Free_mem(_resList[res]); // release the memory too
nuked++;
// if this was called from the console + we
@@ -979,8 +974,8 @@ void resMan::Kill_all_res(uint8 wantInfo) {
ServiceWindows();
} while(!KeyWaiting());
- ReadKey(&ke); //kill the key we just pressed
- if (ke.keycode == 27) //ESC
+ ReadKey(&ke);
+ if (ke.keycode == 27)
break;
// clear the Press Esc message ready for the new line
@@ -1001,14 +996,14 @@ void resMan::Kill_all_res(uint8 wantInfo) {
}
//----------------------------------------------------------------------------
-// Like Kill_all_res but only kills objects (except George & the variable
-// table of course) - ie. forcing them to reload & restart their scripts,
-// which simulates the effect of a save & restore, thus checking that each
-// object's re-entrant logic works correctly, and doesn't cause a statuette to
+// Like killAll but only kills objects (except George & the variable table of
+// course) - ie. forcing them to reload & restart their scripts, which
+// simulates the effect of a save & restore, thus checking that each object's
+// re-entrant logic works correctly, and doesn't cause a statuette to
// disappear forever, or some plaster-filled holes in sand to crash the game &
// get James in trouble again.
-void resMan::Kill_all_objects(uint8 wantInfo) {
+void ResourceManager::killAllObjects(uint8 wantInfo) {
// remove all object res files from memory, excluding George
// its quicker to search the mem blocs for res files than search
// resource lists for those in memory
@@ -1028,12 +1023,12 @@ void resMan::Kill_all_objects(uint8 wantInfo) {
//not the global vars which are assumed to be open in
// memory & not the player object! (James17jan97)
if (res != 1 && res != CUR_PLAYER_ID) {
- header = (_standardHeader*) res_man.Res_open(res);
- res_man.Res_close(res);
+ header = (_standardHeader*) res_man.open(res);
+ res_man.close(res);
if (header->fileType == GAME_OBJECT) {
- age[res] = 0; // effectively gone from resList
- Free_mem(resList[res]); // release the memory too
+ _age[res] = 0; // effectively gone from _resList
+ Free_mem(_resList[res]); // release the memory too
nuked++;
// if this was called from the console + we want info
@@ -1072,7 +1067,7 @@ void resMan::Kill_all_objects(uint8 wantInfo) {
Print_to_console(" expelled %d object resource(s)", nuked);
}
-void resMan::CacheNewCluster(uint32 newCluster) {
+void ResourceManager::cacheNewCluster(uint32 newCluster) {
// Stop any music from streaming off the CD before we start the
// cluster-copy!
//
@@ -1080,46 +1075,46 @@ void resMan::CacheNewCluster(uint32 newCluster) {
// restored a game to a different cluster on the same CD - and music
// streaming would interfere with cluster copying, slowing it right
// down - but if we restored to a different CD the music is stopped
- // in GetCd() when it asks for the CD
+ // in getCd() when it asks for the CD
FN_stop_music(NULL);
Clear_fx_queue(); // stops all fx & clears the queue (James22july97)
- GetCd(cdTab[newCluster] & 3);
+ getCd(_cdTab[newCluster] & 3);
// Kick out old cached cluster and load the new one.
uint32 i = 0;
- while (!(cdTab[i] & LOCAL_CACHE) && i < total_clusters)
+ while (!(_cdTab[i] & LOCAL_CACHE) && i < _totalClusters)
i++;
- if (i < total_clusters) {
- SVM_SetFileAttributes(resource_files[i], FILE_ATTRIBUTE_NORMAL);
- SVM_DeleteFile(resource_files[i]);
- cdTab[i] &= (0xff - LOCAL_CACHE);
+ if (i < _totalClusters) {
+ SVM_SetFileAttributes(_resourceFiles[i], FILE_ATTRIBUTE_NORMAL);
+ SVM_DeleteFile(_resourceFiles[i]);
+ _cdTab[i] &= (0xff - LOCAL_CACHE);
FILE *file;
file = fopen("cd.inf", "r+b");
if (file == NULL) {
- Con_fatal_error("InitResMan cannot *OPEN* cd.inf");
+ Con_fatal_error("init cannot *OPEN* cd.inf");
}
_cd_inf cdInf;
do {
fread(&cdInf, 1, sizeof(_cd_inf), file);
- } while ((scumm_stricmp((char *) cdInf.clusterName, resource_files[i]) != 0) && !feof(file));
+ } while ((scumm_stricmp((char *) cdInf.clusterName, _resourceFiles[i]) != 0) && !feof(file));
if (feof(file)) {
- Con_fatal_error("CacheNewCluster cannot find %s in cd.inf", resource_files[i]);
+ Con_fatal_error("cacheNewCluster cannot find %s in cd.inf", _resourceFiles[i]);
}
fseek(file, -1, SEEK_CUR);
- fwrite(&cdTab[i], 1, 1, file);
+ fwrite(&_cdTab[i], 1, 1, file);
fclose(file);
}
char buf[1024];
- sprintf(buf, "%sClusters\\%s", cdPath, resource_files[newCluster]);
+ sprintf(buf, "%sClusters\\%s", _cdPath, _resourceFiles[newCluster]);
WaitForFade();
@@ -1134,7 +1129,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
Set_luggage(0); //tw28Aug
uint8 *bgfile;
- bgfile = res_man.Res_open(2950); // open the screen resource
+ bgfile = res_man.open(2950); // open the screen resource
InitialiseBackgroundLayer(NULL);
InitialiseBackgroundLayer(NULL);
InitialiseBackgroundLayer(FetchBackgroundLayer(bgfile));
@@ -1143,18 +1138,18 @@ void resMan::CacheNewCluster(uint32 newCluster) {
BS2_SetPalette(0, 256, FetchPalette(bgfile), RDPAL_FADE);
RenderParallax(FetchBackgroundLayer(bgfile), 2);
- res_man.Res_close(2950); // release the screen resource
+ res_man.close(2950); // release the screen resource
// Git rid of read-only status, if it is set.
- SVM_SetFileAttributes(resource_files[newCluster], FILE_ATTRIBUTE_NORMAL);
+ SVM_SetFileAttributes(_resourceFiles[newCluster], FILE_ATTRIBUTE_NORMAL);
File inFile, outFile;
inFile.open(buf);
- outFile.open(resource_files[newCluster], NULL, File::kFileWriteMode);
+ outFile.open(_resourceFiles[newCluster], NULL, File::kFileWriteMode);
if (!inFile.isOpen() || !outFile.isOpen()) {
- Con_fatal_error("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]);
+ Con_fatal_error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
}
_spriteInfo textSprite;
@@ -1164,7 +1159,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
uint8 *loadingBar;
_cdtEntry *cdt;
- text_spr = MakeTextSprite(FetchTextLine(res_man.Res_open(2283), 8) + 2, 640, 187, speech_font_id);
+ text_spr = MakeTextSprite(FetchTextLine(res_man.open(2283), 8) + 2, 640, 187, speech_font_id);
frame = (_frameHeader*) text_spr->ad;
@@ -1179,9 +1174,9 @@ void resMan::CacheNewCluster(uint32 newCluster) {
textSprite.blend = 0;
textSprite.colourTable = 0;
- res_man.Res_close(2283);
+ res_man.close(2283);
- loadingBar = res_man.Res_open(2951);
+ loadingBar = res_man.open(2951);
frame = FetchFrameHeader(loadingBar, 0);
cdt = FetchCdtEntry(loadingBar, 0);
@@ -1197,12 +1192,12 @@ void resMan::CacheNewCluster(uint32 newCluster) {
barSprite.blend = 0;
barSprite.colourTable = 0;
- res_man.Res_close(2951);
+ res_man.close(2951);
- loadingBar = res_man.Res_open(2951);
+ loadingBar = res_man.open(2951);
frame = FetchFrameHeader(loadingBar, 0);
barSprite.data = (uint8 *) (frame + 1);
- res_man.Res_close(2951);
+ res_man.close(2951);
int16 barX = barSprite.x;
int16 barY = barSprite.y;
@@ -1235,20 +1230,20 @@ void resMan::CacheNewCluster(uint32 newCluster) {
realRead = inFile.read(buffer, BUFFERSIZE);
read += realRead;
if (outFile.write(buffer, realRead) != realRead) {
- Con_fatal_error("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]);
+ Con_fatal_error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
}
if (step == stepSize) {
step = 0;
// open the screen resource
- bgfile = res_man.Res_open(2950);
+ bgfile = res_man.open(2950);
RenderParallax(FetchBackgroundLayer(bgfile), 2);
// release the screen resource
- res_man.Res_close(2950);
- loadingBar = res_man.Res_open(2951);
+ res_man.close(2950);
+ loadingBar = res_man.open(2951);
frame = FetchFrameHeader(loadingBar, fr);
barSprite.data = (uint8 *) (frame + 1);
- res_man.Res_close(2951);
+ res_man.close(2951);
DrawSprite(&barSprite);
barSprite.x = barX;
barSprite.y = barY;
@@ -1266,7 +1261,7 @@ void resMan::CacheNewCluster(uint32 newCluster) {
} while ((read % BUFFERSIZE) == 0);
if (read != size) {
- Con_fatal_error("Cache new cluster could not copy %s to %s", buf, resource_files[newCluster]);
+ Con_fatal_error("Cache new cluster could not copy %s to %s", buf, _resourceFiles[newCluster]);
}
inFile.close();
@@ -1280,34 +1275,34 @@ void resMan::CacheNewCluster(uint32 newCluster) {
FadeUp((float) 0.75);
// Git rid of read-only status.
- SVM_SetFileAttributes(resource_files[newCluster], FILE_ATTRIBUTE_NORMAL);
+ SVM_SetFileAttributes(_resourceFiles[newCluster], FILE_ATTRIBUTE_NORMAL);
- // Update cd.inf and cdTab
- cdTab[newCluster] |= LOCAL_CACHE;
+ // Update cd.inf and _cdTab
+ _cdTab[newCluster] |= LOCAL_CACHE;
FILE *file;
file = fopen("cd.inf", "r+b");
if (file == NULL) {
- Con_fatal_error("InitResMan cannot *OPEN* cd.inf");
+ Con_fatal_error("init cannot *OPEN* cd.inf");
}
_cd_inf cdInf;
do {
fread(&cdInf, 1, sizeof(_cd_inf), file);
- } while (scumm_stricmp((char *) cdInf.clusterName, resource_files[newCluster]) != 0 && !feof(file));
+ } while (scumm_stricmp((char *) cdInf.clusterName, _resourceFiles[newCluster]) != 0 && !feof(file));
if (feof(file)) {
- Con_fatal_error("CacheNewCluster cannot find %s in cd.inf", resource_files[newCluster]);
+ Con_fatal_error("cacheNewCluster cannot find %s in cd.inf", _resourceFiles[newCluster]);
}
fseek(file, -1, SEEK_CUR);
- fwrite(&cdTab[newCluster], 1, 1, file);
+ fwrite(&_cdTab[newCluster], 1, 1, file);
fclose(file);
}
-void resMan::GetCd(int cd) {
+void ResourceManager::getCd(int cd) {
// TODO support a seperate path for cd data?
bool done = false;
@@ -1341,15 +1336,15 @@ void resMan::GetCd(int cd) {
// Determine what CD is in the drive, and either use it or ask
// the user to insert the correct CD.
// Scan all CD drives for our CD as well.
- while(cdDrives[index] != 0 && index < 24) {
- sprintf(cdPath, "%c:\\", cdDrives[index]);
+ while(_cdDrives[index] != 0 && index < 24) {
+ sprintf(_cdPath, "%c:\\", _cdDrives[index]);
- if (!SVM_GetVolumeInformation(cdPath, sCDName, _MAX_PATH, NULL, &dwMaxCompLength, &dwFSFlags, NULL, 0)) {
+ if (!SVM_GetVolumeInformation(_cdPath, sCDName, _MAX_PATH, NULL, &dwMaxCompLength, &dwFSFlags, NULL, 0)) {
// Force the following code to ask for the correct CD.
sCDName[0] = 0;
}
- curCd = cd;
+ _curCd = cd;
if (!scumm_stricmp(sCDName,CD1_LABEL)) {
if (cd == CD1)
@@ -1367,13 +1362,13 @@ void resMan::GetCd(int cd) {
// from CD
debug(5, "RUNNING OFF NETWORK");
- fscanf(file, "%s", cdPath);
+ fscanf(file, "%s", _cdPath);
fclose(file);
- if (curCd == cd)
+ if (_curCd == cd)
return;
else
- curCd = cd;
+ _curCd = cd;
// don't show CD-requests if testing anims or text/speech
if (SYSTEM_TESTING_ANIMS || SYSTEM_TESTING_TEXT)
@@ -1388,7 +1383,7 @@ void resMan::GetCd(int cd) {
FN_stop_music(NULL);
- textRes = res_man.Res_open(2283);
+ textRes = res_man.open(2283);
DisplayMsg(FetchTextLine(textRes, 5 + cd) + 2, 0);
text_spr = MakeTextSprite(FetchTextLine(textRes, 5 + cd) + 2, 640, 187, speech_font_id);
@@ -1408,24 +1403,24 @@ void resMan::GetCd(int cd) {
oldY = spriteInfo.y;
oldX = spriteInfo.x;
- res_man.Res_close(2283);
+ res_man.close(2283);
do {
if (offNetwork == 1)
done = true;
else {
index = 0;
- while (cdDrives[index] != 0 && !done && index < 24) {
- sprintf(cdPath, "%c:\\", cdDrives[index]);
+ while (_cdDrives[index] != 0 && !done && index < 24) {
+ sprintf(_cdPath, "%c:\\", _cdDrives[index]);
- if (!SVM_GetVolumeInformation(cdPath, sCDName, _MAX_PATH, NULL, &dwMaxCompLength, &dwFSFlags, NULL, 0)) {
+ if (!SVM_GetVolumeInformation(_cdPath, sCDName, _MAX_PATH, NULL, &dwMaxCompLength, &dwFSFlags, NULL, 0)) {
sCDName[0] = 0;
}
- if (!scumm_stricmp(sCDName,CD1_LABEL)) {
+ if (!scumm_stricmp(sCDName, CD1_LABEL)) {
if (cd == CD1)
done = true;
- } else if (!scumm_stricmp(sCDName,CD2_LABEL)) {
+ } else if (!scumm_stricmp(sCDName, CD2_LABEL)) {
if (cd == CD2)
done = true;
}
diff --git a/sword2/resman.h b/sword2/resman.h
index 241efb49ca..089f214077 100644
--- a/sword2/resman.h
+++ b/sword2/resman.h
@@ -24,91 +24,90 @@
#define MAX_res_files 20
+#if 0
#define RES_locked 1
#define RES_perm 2
+#endif
-
-class resMan {
+class ResourceManager {
public:
- void InitResMan(void); // read in the config file
- void Close_ResMan(void);
+ void init(void); // read in the config file
+ void exit(void);
// 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
- uint8 *Res_open(uint32 res);
- void Res_close(uint32 res); // decrements the count
+ uint8 *open(uint32 res);
+ void close(uint32 res); // decrements the count
// returns '0' if resource out of range or null, otherwise '1' for ok
- uint8 Res_check_valid(uint32 res);
+ uint8 checkValid(uint32 res);
//for mem_view to query the owners of mem blocs
- char *Fetch_cluster(uint32 res);
- uint32 Fetch_age(uint32 res);
- uint32 Fetch_count(uint32 count);
+ char *fetchCluster(uint32 res);
+ uint32 fetchAge(uint32 res);
+ uint32 fetchCount(uint32 count);
- uint32 Help_the_aged_out(void);
+ uint32 helpTheAgedOut(void);
- uint32 Res_fetch_len(uint32 res);
+ uint32 fetchLen(uint32 res);
- void Res_next_cycle( void );
- uint32 Res_fetch_useage( void );
+ void nextCycle(void);
+ uint32 fetchUsage(void);
// Prompts the user for the specified CD.
- void GetCd(int cd);
+ void getCd(int cd);
- int WhichCd() {
- return curCd;
+ int whichCd() {
+ return _curCd;
}
// ----console commands
- void Print_console_clusters(void);
- void Examine_res(uint8 *input);
- void Kill_all_res(uint8 wantInfo);
- void Kill_all_objects(uint8 wantInfo);
- void Remove_res(uint32 res);
- void Remove_all_res(void);
- void Kill_res(uint8 *res);
- char *GetCdPath(void);
+ void printConsoleClusters(void);
+ void examine(uint8 *input);
+ void kill(uint8 *res);
+ void killAll(uint8 wantInfo);
+ void killAllObjects(uint8 wantInfo);
+ void remove(uint32 res);
+ void removeAll(void);
// pointer to a pointer (or list of pointers in-fact)
- mem **resList;
+ mem **_resList;
private:
- int curCd;
- uint32 total_res_files;
- uint32 total_clusters;
- uint32 current_memory_useage;
+ int _curCd;
+ uint32 _totalResFiles;
+ uint32 _totalClusters;
+ uint32 _currentMemoryUsage;
- // Inc's each time Res_open is called and is given to resource as its
- // age. Ccannot be allowed to start at 0! (A pint if you can tell me
- // why)
+ // 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)
- uint32 resTime;
+ uint32 _resTime;
- uint32 *age;
+ uint32 *_age;
// Gode generated res-id to res number/rel number conversion table
- uint16 *res_conv_table;
+ uint16 *_resConvTable;
- uint16 *count;
- char resource_files[MAX_res_files][20];
- uint8 cdTab[MAX_res_files]; // Location of each cluster.
+ uint16 *_count;
+ char _resourceFiles[MAX_res_files][20];
+ uint8 _cdTab[MAX_res_files]; // Location of each cluster.
// Drive letter of the CD-ROM drive or false CD path.
- char cdPath[256];
+ char _cdPath[256];
- void CacheNewCluster(uint32 newCluster);
- char cdDrives[24];
+ void cacheNewCluster(uint32 newCluster);
+ char _cdDrives[24];
};
-extern resMan res_man; //declare the object global
+extern ResourceManager res_man; //declare the object global
#endif
diff --git a/sword2/router.cpp b/sword2/router.cpp
index 8265c548e7..b64c5c2b42 100644
--- a/sword2/router.cpp
+++ b/sword2/router.cpp
@@ -2732,7 +2732,7 @@ void LoadWalkGrid(void) {
for (entry = 0; entry < MAX_WALKGRIDS; entry++) {
if (walkGridList[entry]) {
// open walk grid file
- fPolygrid = res_man.Res_open(walkGridList[entry]);
+ fPolygrid = res_man.open(walkGridList[entry]);
fPolygrid += sizeof(_standardHeader);
memmove((uint8 *) &floorHeader, fPolygrid, sizeof(_walkGridHeader));
fPolygrid += sizeof(_walkGridHeader);
@@ -2774,7 +2774,7 @@ void LoadWalkGrid(void) {
}
// close walk grid file
- res_man.Res_close(walkGridList[entry]);
+ res_man.close(walkGridList[entry]);
// increment counts of total bars & nodes in whole
// walkgrid
diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp
index 9740b802fa..1040232c2f 100644
--- a/sword2/save_rest.cpp
+++ b/sword2/save_rest.cpp
@@ -163,7 +163,7 @@ uint32 SaveGame(uint16 slotNo, uint8 *desc) {
uint32 FindBufferSize(void) {
// size of savegame header + size of global variables
- return (sizeof(g_header) + res_man.Res_fetch_len(1));
+ return (sizeof(g_header) + res_man.fetchLen(1));
}
void FillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
@@ -177,7 +177,7 @@ void FillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
sprintf(g_header.description, "%s", (char*) desc);
// length of global variables resource
- g_header.varLength = res_man.Res_fetch_len(1);
+ g_header.varLength = res_man.fetchLen(1);
// resource id of current screen file
g_header.screenId = this_screen.background_layer_id;
@@ -193,8 +193,8 @@ void FillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
g_header.music_id = looping_music_id;
// object hub
- memcpy(&g_header.player_hub, res_man.Res_open(CUR_PLAYER_ID) + sizeof(_standardHeader), sizeof(_object_hub));
- res_man.Res_close(CUR_PLAYER_ID);
+ memcpy(&g_header.player_hub, res_man.open(CUR_PLAYER_ID) + sizeof(_standardHeader), sizeof(_object_hub));
+ res_man.close(CUR_PLAYER_ID);
// logic, graphic & mega structures
// copy the 4 essential player object structures into the header
@@ -212,7 +212,7 @@ void FillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
// copy the global variables to the buffer
// open variables resource
- varsRes = res_man.Res_open(1);
+ varsRes = res_man.open(1);
// copy that to the buffer, following the header
memcpy(buffer->ad + sizeof(g_header), varsRes, FROM_LE_32(g_header.varLength));
@@ -226,7 +226,7 @@ void FillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
#endif
// close variables resource
- res_man.Res_close(1);
+ res_man.close(1);
// set the checksum & copy that to the buffer (James05aug97)
@@ -368,7 +368,7 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
// shorter than the current expected length
// if header contradicts actual current size of global variables
- if (g_header.varLength != res_man.Res_fetch_len(1)) {
+ if (g_header.varLength != res_man.fetchLen(1)) {
Free_mem(buffer);
// error: incompatible save-data - can't use!
@@ -379,7 +379,7 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
// trash all resources from memory except player object & global
// variables
- res_man.Kill_all_res(0);
+ res_man.killAll(0);
// clean out the system kill list (no more objects to kill)
LLogic.resetKillList();
@@ -387,9 +387,9 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
// get player character data from savegame buffer
// object hub is just after the standard header
- memcpy(res_man.Res_open(CUR_PLAYER_ID) + sizeof(_standardHeader), &g_header.player_hub, sizeof(_object_hub));
+ memcpy(res_man.open(CUR_PLAYER_ID) + sizeof(_standardHeader), &g_header.player_hub, sizeof(_object_hub));
- res_man.Res_close(CUR_PLAYER_ID);
+ res_man.close(CUR_PLAYER_ID);
// fill in the 4 essential player object structures from the header
PutPlayerStructures();
@@ -397,7 +397,7 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
// get variables resource from the savegame buffer
// open variables resource
- varsRes = res_man.Res_open(1);
+ varsRes = res_man.open(1);
// copy that to the buffer, following the header
memcpy(varsRes, buffer->ad + sizeof(g_header), g_header.varLength );
@@ -411,7 +411,7 @@ uint32 RestoreFromBuffer(mem *buffer, uint32 size) {
#endif
// close variables resource
- res_man.Res_close(1);
+ res_man.close(1);
// free it now, rather than in RestoreGame, to unblock memory before
// new screen & runlist loaded
@@ -515,14 +515,14 @@ void GetPlayerStructures(void) {
char *raw_script_ad;
_standardHeader *head;
- head = (_standardHeader*) res_man.Res_open(CUR_PLAYER_ID);
+ head = (_standardHeader*) res_man.open(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
raw_script_ad = (char *) head;
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(CUR_PLAYER_ID);
+ res_man.close(CUR_PLAYER_ID);
}
void PutPlayerStructures(void) {
@@ -534,7 +534,7 @@ void PutPlayerStructures(void) {
char *raw_script_ad;
_standardHeader *head;
- head = (_standardHeader*) res_man.Res_open(CUR_PLAYER_ID);
+ head = (_standardHeader*) res_man.open(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
@@ -572,7 +572,7 @@ void PutPlayerStructures(void) {
}
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(CUR_PLAYER_ID);
+ res_man.close(CUR_PLAYER_ID);
}
int32 FN_pass_player_savedata(int32 *params) {
diff --git a/sword2/sound.cpp b/sword2/sound.cpp
index a1d1093129..b35baa3589 100644
--- a/sword2/sound.cpp
+++ b/sword2/sound.cpp
@@ -109,12 +109,12 @@ void Trigger_fx(uint8 j) {
if (fxq[j].type == FX_SPOT) {
// load in the sample
- data = res_man.Res_open(fxq[j].resource);
+ data = res_man.open(fxq[j].resource);
data += sizeof(_standardHeader);
// wav data gets copied to sound memory
rv = g_sound->PlayFx(id, data, fxq[j].volume, fxq[j].pan, RDSE_FXSPOT);
// release the sample
- res_man.Res_close(fxq[j].resource);
+ res_man.close(fxq[j].resource);
} else {
// random & looped fx are already loaded into sound memory
// by FN_play_fx()
@@ -204,7 +204,7 @@ int32 FN_play_fx(int32 *params) {
if (fxq[j].type == FX_SPOT) {
// "pre-load" the sample; this gets it into memory
- data = res_man.Res_open(fxq[j].resource);
+ data = res_man.open(fxq[j].resource);
#ifdef _SWORD2_DEBUG
header = (_standardHeader*) data;
@@ -213,14 +213,14 @@ int32 FN_play_fx(int32 *params) {
#endif
// but then releases it to "age" out if the space is needed
- res_man.Res_close(fxq[j].resource);
+ res_man.close(fxq[j].resource);
} else {
// random & looped fx
id = (uint32) j + 1; // because 0 is not a valid id
// load in the sample
- data = res_man.Res_open(fxq[j].resource);
+ data = res_man.open(fxq[j].resource);
#ifdef _SWORD2_DEBUG
header = (_standardHeader*)data;
@@ -237,7 +237,7 @@ int32 FN_play_fx(int32 *params) {
debug(5, "SFX ERROR: OpenFx() returned %.8x", rv);
// release the sample
- res_man.Res_close(fxq[j].resource);
+ res_man.close(fxq[j].resource);
}
// (James07uag97)
@@ -399,7 +399,7 @@ int32 FN_play_music(int32 *params) {
} else {
File f;
- sprintf(filename, "music%d.clu", res_man.WhichCd());
+ sprintf(filename, "music%d.clu", res_man.whichCd());
if (f.open(filename))
f.close();
else
diff --git a/sword2/speech.cpp b/sword2/speech.cpp
index c95fa119d4..fddcb59f4f 100644
--- a/sword2/speech.cpp
+++ b/sword2/speech.cpp
@@ -219,9 +219,9 @@ int32 FN_choose(int32 *params) {
for (j = 0; j < 15; j++) {
if (j < IN_SUBJECT) {
debug(5, " ICON res %d for %d", subject_list[j].res, j);
- icon = res_man.Res_open(subject_list[j].res) + sizeof(_standardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
+ icon = res_man.open(subject_list[j].res) + sizeof(_standardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
SetMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
- res_man.Res_close(subject_list[j].res);
+ res_man.close(subject_list[j].res);
} else {
//no icon here
debug(5, " NULL for %d", j);
@@ -267,9 +267,9 @@ int32 FN_choose(int32 *params) {
// change all others to grey
if (j != hit) {
- icon = res_man.Res_open( subject_list[j].res ) + sizeof(_standardHeader);
+ icon = res_man.open( subject_list[j].res ) + sizeof(_standardHeader);
SetMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
- res_man.Res_close(subject_list[j].res);
+ res_man.close(subject_list[j].res);
}
}
@@ -373,7 +373,7 @@ int32 FN_they_do(int32 *params) {
int32 target = params[0];
// request status of target
- head = (_standardHeader*) res_man.Res_open(target);
+ head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("FN_they_do %d not an object", target);
@@ -382,7 +382,7 @@ int32 FN_they_do(int32 *params) {
//call the base script - this is the graphic/mouse service call
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(target);
+ res_man.close(target);
// result is 1 for waiting, 0 for busy
@@ -437,7 +437,7 @@ int32 FN_they_do_we_wait(int32 *params) {
// ok, see if the target is busy - we must request this info from the
// target object
- head = (_standardHeader*) res_man.Res_open(target);
+ head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("FN_they_do_we_wait %d not an object", target);
@@ -446,7 +446,7 @@ int32 FN_they_do_we_wait(int32 *params) {
// call the base script - this is the graphic/mouse service call
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(target);
+ res_man.close(target);
ob_logic = (Object_logic *) params[0];
@@ -516,7 +516,7 @@ int32 FN_we_wait(int32 *params) {
int32 target = params[0];
// request status of target
- head = (_standardHeader*) res_man.Res_open(target);
+ head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("FN_we_wait %d not an object", target);
@@ -525,7 +525,7 @@ int32 FN_we_wait(int32 *params) {
// call the base script - this is the graphic/mouse service call
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(target);
+ res_man.close(target);
// result is 1 for waiting, 0 for busy
@@ -564,7 +564,7 @@ int32 FN_timed_wait(int32 *params) {
ob_logic->looping = params[2]; //first time in
// request status of target
- head = (_standardHeader*) res_man.Res_open(target);
+ head = (_standardHeader*) res_man.open(target);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("FN_timed_wait %d not an object", target);
@@ -573,7 +573,7 @@ int32 FN_timed_wait(int32 *params) {
// call the base script - this is the graphic/mouse service call
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(target);
+ res_man.close(target);
// result is 1 for waiting, 0 for busy
@@ -1010,9 +1010,9 @@ int32 FN_i_speak(int32 *params) {
// if the resource number is within range & it's not
// a null resource
- if (res_man.Res_check_valid(text_res)) {
+ if (res_man.checkValid(text_res)) {
// open the resource
- head = (_standardHeader*) res_man.Res_open(text_res);
+ head = (_standardHeader*) res_man.open(text_res);
if (head->fileType == TEXT_FILE) {
// if it's not an animation file
@@ -1027,7 +1027,7 @@ int32 FN_i_speak(int32 *params) {
}
// close the resource
- res_man.Res_close(text_res);
+ res_man.close(text_res);
if (RESULT)
return IR_CONT;
@@ -1048,11 +1048,11 @@ int32 FN_i_speak(int32 *params) {
local_text = params[S_TEXT] & 0xffff;
// open text file & get the line
- text = FetchTextLine(res_man.Res_open(text_res), local_text);
+ text = FetchTextLine(res_man.open(text_res), local_text);
officialTextNumber = READ_LE_UINT16(text);
// now ok to close the text file
- res_man.Res_close(text_res);
+ res_man.close(text_res);
#ifdef _SWORD2_DEBUG
// prevent dud lines from appearing while testing text & speech
@@ -1191,7 +1191,7 @@ int32 FN_i_speak(int32 *params) {
File fp;
- sprintf(speechFile, "speech%d.clu", res_man.WhichCd());
+ sprintf(speechFile, "speech%d.clu", res_man.whichCd());
if (fp.open(speechFile))
fp.close();
@@ -1234,7 +1234,7 @@ int32 FN_i_speak(int32 *params) {
ob_graphic->anim_pc++;
// open the anim file
- anim_file = res_man.Res_open(ob_graphic->anim_resource);
+ anim_file = res_man.open(ob_graphic->anim_resource);
anim_head = FetchAnimHeader(anim_file);
if (!speech_anim_type) {
@@ -1264,7 +1264,7 @@ int32 FN_i_speak(int32 *params) {
}
// close the anim file
- res_man.Res_close(ob_graphic->anim_resource);
+ res_man.close(ob_graphic->anim_resource);
} else if (speech_anim_type) {
// Placed here so we actually display the last frame of the
// anim.
@@ -1436,7 +1436,7 @@ void LocateTalker(int32 *params) {
// build_display.cpp
// open animation file & set up the necessary pointers
- file = res_man.Res_open(anim_id);
+ file = res_man.open(anim_id);
anim_head = FetchAnimHeader(file);
@@ -1488,7 +1488,7 @@ void LocateTalker(int32 *params) {
text_y -= this_screen.scroll_offset_y;
// release the anim resource
- res_man.Res_close(anim_id);
+ res_man.close(anim_id);
}
}
@@ -1542,7 +1542,7 @@ void Form_text(int32 *params) {
local_text = params[S_TEXT] & 0xffff;
// open text file & get the line
- text = FetchTextLine(res_man.Res_open(text_res), local_text);
+ text = FetchTextLine(res_man.open(text_res), local_text);
// 'text + 2' to skip the first 2 bytes which form the line
// reference number
@@ -1553,7 +1553,7 @@ void Form_text(int32 *params) {
POSITION_AT_CENTRE_OF_BASE);
// now ok to close the text file
- res_man.Res_close(text_res);
+ res_man.close(text_res);
// set speech duration, in case not using wav
// no. of cycles = (no. of chars) + 30
@@ -1583,7 +1583,7 @@ void GetCorrectCdForSpeech(int32 wavId) {
// if we specifically need CD1 or CD2 (ie. it's not on both)
// then check it's there (& ask for it if it's not there)
if (cd == 1 || cd == 2)
- res_man.GetCd(cd);
+ res_man.getCd(cd);
}
#endif
diff --git a/sword2/startup.cpp b/sword2/startup.cpp
index 9b32a78fb3..5aad72b40b 100644
--- a/sword2/startup.cpp
+++ b/sword2/startup.cpp
@@ -124,12 +124,12 @@ uint32 Init_start_menu(void) {
// - need to check in case un-built sections included in
// start list
- if (res_man.Res_check_valid(res)) {
+ if (res_man.checkValid(res)) {
debug(5, "- resource %d ok", res);
- raw_script = (char*) res_man.Res_open(res);
+ raw_script = (char*) res_man.open(res);
null_pc = 0;
RunScript(raw_script, raw_script, &null_pc);
- res_man.Res_close(res);
+ res_man.close(res);
} else
debug(5, "- resource %d invalid", res);
}
@@ -264,12 +264,12 @@ uint32 Con_start(uint8 *input) {
// remove all resources from memory, including player
// object & global variables
- res_man.Remove_all_res();
+ res_man.removeAll();
// reopen global variables resource & send address to
// interpreter - it won't be moving
- SetGlobalInterpreterVariables((int32 *) (res_man.Res_open(1) + sizeof(_standardHeader)));
- res_man.Res_close(1);
+ SetGlobalInterpreterVariables((int32 *) (res_man.open(1) + sizeof(_standardHeader)));
+ res_man.close(1);
// free all the route memory blocks from previous game
FreeAllRouteMem();
@@ -283,8 +283,8 @@ uint32 Con_start(uint8 *input) {
// set the key
// Open George
- raw_data_ad = (char*) (res_man.Res_open(8));
- raw_script = (char*) (res_man.Res_open(start_list[start].start_res_id));
+ raw_data_ad = (char*) (res_man.open(8));
+ raw_script = (char*) (res_man.open(start_list[start].start_res_id));
// denotes script to run
null_pc = start_list[start].key & 0xffff;
@@ -292,10 +292,10 @@ uint32 Con_start(uint8 *input) {
Print_to_console("running start %d", start);
RunScript(raw_script, raw_data_ad, &null_pc);
- res_man.Res_close(start_list[start].start_res_id);
+ res_man.close(start_list[start].start_res_id);
// Close George
- res_man.Res_close(8);
+ res_man.close(8);
// make sure thre's a mouse, in case restarting while
// mouse not available
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index f3f288dac0..4e97f904b6 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -138,12 +138,12 @@ int32 Sword2State::InitialiseGame(void) {
Init_memory_manager();
// initialise the resource manager
- debug(5, "CALLING: res_man.InitResMan");
- res_man.InitResMan();
+ debug(5, "CALLING: res_man.init");
+ res_man.init();
// initialise global script variables
// res 1 is the globals list
- file = res_man.Res_open(1);
+ file = res_man.open(1);
debug(5, "CALLING: SetGlobalInterpreterVariables");
SetGlobalInterpreterVariables((int32 * ) (file + sizeof(_standardHeader)));
@@ -153,7 +153,7 @@ int32 Sword2State::InitialiseGame(void) {
// DON'T CLOSE PLAYER OBJECT RESOURCE - KEEP IT OPEN IN MEMORY SO IT
// CAN'T MOVE!
- file = res_man.Res_open(8);
+ file = res_man.open(8);
// Set up font resource variables for this language version
@@ -206,7 +206,7 @@ void Close_game() {
// free the memory again
Close_memory_manager();
- res_man.Close_ResMan();
+ res_man.exit();
}
int32 GameCycle(void) {
@@ -241,7 +241,7 @@ int32 GameCycle(void) {
Process_fx_queue();
// update age and calculate previous cycle memory usage
- res_man.Res_next_cycle();
+ res_man.nextCycle();
if (quitGame)
return 1;
@@ -456,19 +456,19 @@ void Sword2State::Start_game(void) {
uint32 null_pc = 1;
// open george object, ready for start script to reference
- raw_data_ad = (char *) res_man.Res_open(8);
+ raw_data_ad = (char *) res_man.open(8);
// open the ScreenManager object
- raw_script = (char *) res_man.Res_open(screen_manager_id);
+ raw_script = (char *) res_man.open(screen_manager_id);
// run the start script now (because no console)
RunScript(raw_script, raw_data_ad, &null_pc);
// close the ScreenManager object
- res_man.Res_close(screen_manager_id);
+ res_man.close(screen_manager_id);
// close george
- res_man.Res_close(8);
+ res_man.close(8);
debug(5, "Start_game() DONE.");
}
@@ -477,10 +477,10 @@ void PauseGame(void) {
// uint8 *text;
// open text file & get the line "PAUSED"
- // text = FetchTextLine(res_man.Res_open(3258), 449);
+ // text = FetchTextLine(res_man.open(3258), 449);
// pause_text_bloc_no = Build_new_block(text + 2, 320, 210, 640, 184, RDSPR_TRANS | RDSPR_DISPLAYALIGN, SPEECH_FONT_ID, POSITION_AT_CENTRE_OF_BASE);
// now ok to close the text file
- // res_man.Res_close(3258);
+ // res_man.close(3258);
// don't allow Pause while screen fading or while black (James 03sep97)
if (GetFadeStatus() != RDFADE_NONE)
diff --git a/sword2/walker.cpp b/sword2/walker.cpp
index cca3fef6a3..c3d6221845 100644
--- a/sword2/walker.cpp
+++ b/sword2/walker.cpp
@@ -270,7 +270,7 @@ int32 FN_walk_to_anim(int32 *params) {
if (ob_logic->looping == 0) {
// open anim file
- anim_file = res_man.Res_open(params[4]);
+ anim_file = res_man.open(params[4]);
// point to animation header
anim_head = FetchAnimHeader( anim_file );
@@ -280,7 +280,7 @@ int32 FN_walk_to_anim(int32 *params) {
pars[6] = anim_head->feetStartDir; // target_dir
// close anim file
- res_man.Res_close(params[4]);
+ res_man.close(params[4]);
// if start coords not yet set in anim header, use the standby
// coords (which should be set beforehand in the script)
@@ -428,7 +428,7 @@ int32 FN_stand_after_anim(int32 *params) {
// open the anim file & set up a pointer to the animation header
// open anim file
- anim_file = res_man.Res_open(params[2]);
+ anim_file = res_man.open(params[2]);
anim_head = FetchAnimHeader(anim_file);
// set up the parameter list for FN_walk_to()
@@ -455,7 +455,7 @@ int32 FN_stand_after_anim(int32 *params) {
Con_fatal_error("Invalid direction (%d) in FN_stand_after_anim", pars[4]);
// close the anim file
- res_man.Res_close(params[2]);
+ res_man.close(params[2]);
// call FN_stand_at() with target coords set to anim end position
return FN_stand_at(pars);
@@ -475,7 +475,7 @@ int32 FN_stand_at_anim(int32 *params) {
// open the anim file & set up a pointer to the animation header
// open anim file
- anim_file = res_man.Res_open(params[2]);
+ anim_file = res_man.open(params[2]);
anim_head = FetchAnimHeader(anim_file);
// set up the parameter list for FN_walk_to()
@@ -502,7 +502,7 @@ int32 FN_stand_at_anim(int32 *params) {
Con_fatal_error("Invalid direction (%d) in FN_stand_after_anim", pars[4]);
// close the anim file
- res_man.Res_close(params[2]);
+ res_man.close(params[2]);
// call FN_stand_at() with target coords set to anim end position
return FN_stand_at(pars);
@@ -599,7 +599,7 @@ int32 FN_face_mega(int32 *params) {
if (ob_logic->looping == 0) {
// get targets info
- head = (_standardHeader*) res_man.Res_open(params[4]);
+ head = (_standardHeader*) res_man.open(params[4]);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("FN_face_mega %d not an object", params[4]);
@@ -609,7 +609,7 @@ int32 FN_face_mega(int32 *params) {
//call the base script - this is the graphic/mouse service call
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(params[4]);
+ res_man.close(params[4]);
// engine_mega is now the Object_mega of mega we want to turn
// to face
@@ -662,7 +662,7 @@ int32 FN_walk_to_talk_to_mega(int32 *params) {
// not been here before so decide where to walk-to
if (!ob_logic->looping) {
// first request the targets info
- head = (_standardHeader*) res_man.Res_open(params[4]);
+ head = (_standardHeader*) res_man.open(params[4]);
if (head->fileType != GAME_OBJECT)
Con_fatal_error("FN_walk_to_talk_to_mega %d not an object", params[4]);
@@ -673,7 +673,7 @@ int32 FN_walk_to_talk_to_mega(int32 *params) {
// call
RunScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man.Res_close(params[4]);
+ res_man.close(params[4]);
// engine_mega is now the Object_mega of mega we want to
// route to
@@ -739,8 +739,8 @@ int32 FN_add_walkgrid(int32 *params) {
AddWalkGrid(params[0]);
// Touch the grid, getting it into memory.
- res_man.Res_open(params[0]);
- res_man.Res_close(params[0]);
+ res_man.open(params[0]);
+ res_man.close(params[0]);
return IR_CONT;
}