[Scummvm-cvs-logs] CVS: scummvm/sword2 anims.cpp,1.45,1.46 build_display.cpp,1.48,1.49 console.cpp,1.34,1.35 console.h,1.13,1.14 controls.cpp,1.50,1.51 controls.h,1.10,1.11 debug.cpp,1.30,1.31 defs.h,1.7,1.8 events.cpp,1.21,1.22 function.cpp,1.40,1.41 header.h,1.4,1.5 icons.cpp,1.26,1.27 icons.h,1.8,1.9 interpreter.cpp,1.24,1.25 layers.cpp,1.21,1.22 logic.cpp,1.32,1.33 logic.h,1.20,1.21 maketext.cpp,1.29,1.30 maketext.h,1.8,1.9 mem_view.cpp,1.20,1.21 memory.cpp,1.17,1.18 memory.h,1.11,1.12 mouse.cpp,1.43,1.44 mouse.h,1.10,1.11 protocol.cpp,1.19,1.20 resman.cpp,1.71,1.72 resman.h,1.15,1.16 router.cpp,1.30,1.31 router.h,1.11,1.12 save_rest.cpp,1.39,1.40 scroll.cpp,1.14,1.15 sound.cpp,1.34,1.35 speech.cpp,1.49,1.50 startup.cpp,1.33,1.34 sword2.cpp,1.85,1.86 sword2.h,1.41,1.42 sync.cpp,1.14,1.15 tony_gsdk.cpp,1.17,1.18 walker.cpp,1.28,1.29 credits.h,1.7,NONE
Torbj?rn Andersson
eriktorbjorn at users.sourceforge.net
Sun Nov 16 06:20:44 CET 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2/driver _mouse.cpp,1.27,1.28 d_draw.cpp,1.44,1.45 d_draw.h,1.15,1.16 d_sound.cpp,1.81,1.82 d_sound.h,1.31,1.32 driver96.h,1.61,1.62 keyboard.cpp,1.13,1.14 language.cpp,1.10,1.11 menu.cpp,1.22,1.23 palette.cpp,1.25,1.26 rdwin.cpp,1.37,1.38 render.cpp,1.42,1.43 sprite.cpp,1.32,1.33
- Next message: [Scummvm-cvs-logs] CVS: scummvm/dists/msvc7 sword2.vcproj,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1:/tmp/cvs-serv23499
Modified Files:
anims.cpp build_display.cpp console.cpp console.h controls.cpp
controls.h debug.cpp defs.h events.cpp function.cpp header.h
icons.cpp icons.h interpreter.cpp layers.cpp logic.cpp logic.h
maketext.cpp maketext.h mem_view.cpp memory.cpp memory.h
mouse.cpp mouse.h protocol.cpp resman.cpp resman.h router.cpp
router.h save_rest.cpp scroll.cpp sound.cpp speech.cpp
startup.cpp sword2.cpp sword2.h sync.cpp tony_gsdk.cpp
walker.cpp
Removed Files:
credits.h
Log Message:
More cleanup. I've eliminated all the temporary global variables I've added
over the past few weeks, except for g_sword2. (Of course, this doesn't
necessarily make the code any prettier, but we can work on that later.)
Index: anims.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/anims.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- anims.cpp 15 Nov 2003 09:37:59 -0000 1.45
+++ anims.cpp 16 Nov 2003 14:18:27 -0000 1.46
@@ -23,21 +23,11 @@
// DON'T TOUCH!
// ---------------------------------------------------------------------------
-#include "stdafx.h"
+#include "common/stdafx.h"
+#include "common/file.h"
#include "sword2/sword2.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/driver/d_draw.h"
-#include "sword2/console.h"
-#include "sword2/controls.h" // for 'subtitles'
#include "sword2/defs.h"
-#include "sword2/header.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/maketext.h" // for makeTextSprite used by fnPlaySequence ultimately
-#include "sword2/object.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/sound.h" // for Speech stuff.
namespace Sword2 {
@@ -97,8 +87,8 @@
// read the main parameters
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
- ob_graphic = (Object_graphic *) memory->intToPtr(params[1]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
+ ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[1]);
if (ob_logic->looping == 0) {
// This is the start of the anim - set up the first frame
@@ -114,11 +104,11 @@
// if the resource number is within range & it's not
// a null resource
- if (res_man->Res_check_valid(res)) {
+ if (_resman->Res_check_valid(res)) {
// Open the resource. Can close it immediately.
// We've got a pointer to the header.
- head = (_standardHeader *) res_man->openResource(res);
- res_man->closeResource(res);
+ head = (_standardHeader *) _resman->openResource(res);
+ _resman->closeResource(res);
// if it's not an animation file
if (head->fileType != ANIMATION_FILE) {
@@ -144,17 +134,17 @@
#ifdef _SWORD2_DEBUG
// check that we haven't been passed a zero resource number
if (res == 0)
- error("animate: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID);
+ error("animate: %s (id %d) passed zero anim resource", _vm->fetchObjectName(ID), ID);
#endif
// open anim file
- anim_file = res_man->openResource(res);
+ anim_file = _vm->_resman->openResource(res);
#ifdef _SWORD2_DEBUG
// check this this resource is actually an animation file!
head = (_standardHeader *) anim_file;
if (head->fileType != ANIMATION_FILE)
- error("animate: %s (%d) is not an anim!", FetchObjectName(res), res);
+ error("animate: %s (%d) is not an anim!", _vm->fetchObjectName(res), res);
#endif
// point to anim header
@@ -163,7 +153,7 @@
/* #ifdef _SWORD2_DEBUG
// check there's at least one frame
if (anim_head->noAnimFrames == 0)
- error("animate: %s (%d) has zero frame count!", FetchObjectName(res), res);
+ error("animate: %s (%d) has zero frame count!", _vm->fetchObjectName(res), res);
#endif */
// now running an anim, looping back to this 'FN' call again
@@ -187,7 +177,7 @@
// frame of the anim.
// open anim file and point to anim header
- anim_file = res_man->openResource(ob_graphic->anim_resource);
+ anim_file = _vm->_resman->openResource(ob_graphic->anim_resource);
anim_head = _vm->fetchAnimHeader(anim_file);
if (reverse)
@@ -207,7 +197,7 @@
}
// close the anim file
- res_man->closeResource(ob_graphic->anim_resource);
+ _vm->_resman->closeResource(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;
@@ -227,11 +217,11 @@
// if this is the start of the anim, read the anim table to get the
// appropriate anim resource
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
- anim_table = (uint32 *) memory->intToPtr(params[3]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
+ anim_table = (uint32 *) _vm->_memory->intToPtr(params[3]);
// appropriate anim resource is in 'table[direction]'
pars[2] = anim_table[ob_mega->current_dir];
@@ -266,18 +256,18 @@
#ifdef _SWORD2_DEBUG
// check that we haven't been passed a zero resource number
if (res == 0)
- error("fnSetFrame: %s (id %d) passed zero anim resource", FetchObjectName(ID), ID);
+ error("fnSetFrame: %s (id %d) passed zero anim resource", _vm->fetchObjectName(ID), ID);
#endif
// open the resource (& check it's valid)
- anim_file = res_man->openResource(res);
+ anim_file = _vm->_resman->openResource(res);
#ifdef _SWORD2_DEBUG
// check this this resource is actually an animation file!
head = (_standardHeader *) anim_file;
if (head->fileType != ANIMATION_FILE)
- error("fnSetFrame: %s (%d) is not an anim!", FetchObjectName(res), res);
+ error("fnSetFrame: %s (%d) is not an anim!", _vm->fetchObjectName(res), res);
#endif
// set up pointer to the animation header
@@ -286,12 +276,12 @@
/* #ifdef _SWORD2_DEBUG
// check there's at least one frame
if (anim_head->noAnimFrames == 0)
- error("fnSetFrame: %s (%d) has zero frame count!", FetchObjectName(res), res);
+ error("fnSetFrame: %s (%d) has zero frame count!", _vm->fetchObjectName(res), res);
#endif */
// set up anim resource in graphic object
- ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
ob_graphic->anim_resource = res;
if (params[2])
@@ -301,14 +291,14 @@
// Close the anim file and drop out of script
- res_man->closeResource(ob_graphic->anim_resource);
+ _vm->_resman->closeResource(ob_graphic->anim_resource);
return IR_CONT;
}
int32 Logic::fnNoSprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -321,7 +311,7 @@
int32 Logic::fnBackPar0Sprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -334,7 +324,7 @@
int32 Logic::fnBackPar1Sprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -347,7 +337,7 @@
int32 Logic::fnBackSprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -360,7 +350,7 @@
int32 Logic::fnSortSprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -373,7 +363,7 @@
int32 Logic::fnForeSprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -386,7 +376,7 @@
int32 Logic::fnForePar0Sprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -399,7 +389,7 @@
int32 Logic::fnForePar1Sprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0xffff0000;
@@ -412,7 +402,7 @@
int32 Logic::fnShadedSprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0x0000ffff;
@@ -428,7 +418,7 @@
int32 Logic::fnUnshadedSprite(int32 *params) {
// params: 0 pointer to object's graphic structure
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
// remove previous status (but don't affect the shading upper-word)
ob_graphic->type &= 0x0000ffff;
@@ -494,11 +484,11 @@
local_text = _sequenceTextList[line].textNumber & 0xffff;
// open text resource & get the line
- text = _vm->fetchTextLine(res_man->openResource(text_res), local_text);
+ text = _vm->fetchTextLine(_vm->_resman->openResource(text_res), local_text);
wavId = (int32) READ_LE_UINT16(text);
// now ok to close the text file
- res_man->closeResource(text_res);
+ _vm->_resman->closeResource(text_res);
// 1st word of text line is the official line number
debug(5,"(%d) SEQUENCE TEXT: %s", READ_LE_UINT16(text), text + 2);
@@ -510,7 +500,7 @@
_sequenceTextList[line].speech_mem = NULL;
sequenceText[line]->speech = NULL;
- if (!g_sound->isSpeechMute()) {
+ if (!_vm->_sound->isSpeechMute()) {
// speech is selected, so try that first
// set up path to speech cluster
@@ -520,13 +510,13 @@
File fp;
- sprintf(speechFile, "speech%d.clu", res_man->whichCd());
+ sprintf(speechFile, "speech%d.clu", _vm->_resman->whichCd());
if (fp.open(speechFile))
fp.close();
else
strcpy(speechFile, "speech.clu");
- _sequenceTextList[line].speechBufferSize = g_sound->preFetchCompSpeech((char *) speechFile, wavId, &_sequenceTextList[line].speech_mem);
+ _sequenceTextList[line].speechBufferSize = _vm->_sound->preFetchCompSpeech((char *) speechFile, wavId, &_sequenceTextList[line].speech_mem);
if (_sequenceTextList[line].speechBufferSize) {
// ok, we've got speech!
speechRunning = true;
@@ -535,9 +525,9 @@
// if we want subtitles, or speech failed to load
- if (gui->_subtitles || !speechRunning) {
+ if (_vm->_gui->_subtitles || !speechRunning) {
// open text resource & get the line
- text = _vm->fetchTextLine(res_man->openResource(text_res), local_text);
+ text = _vm->fetchTextLine(_vm->_resman->openResource(text_res), local_text);
// make the sprite
// 'text+2' to skip the first 2 bytes which form the
// line reference number
@@ -548,10 +538,10 @@
// When rendering text over a sequence we need a
// different colour for the border.
- _sequenceTextList[line].text_mem = fontRenderer->makeTextSprite(text + 2, 600, 255, _vm->_speechFontId, 1);
+ _sequenceTextList[line].text_mem = _vm->_fontRenderer->makeTextSprite(text + 2, 600, 255, _vm->_speechFontId, 1);
// ok to close the text resource now
- res_man->closeResource(text_res);
+ _vm->_resman->closeResource(text_res);
} else {
_sequenceTextList[line].text_mem = NULL;
sequenceText[line]->textSprite = NULL;
@@ -569,7 +559,7 @@
// if we've made a text sprite for this line...
if (_sequenceTextList[line].text_mem) {
- memory->lockMemory(_sequenceTextList[line].text_mem);
+ _vm->_memory->lockMemory(_sequenceTextList[line].text_mem);
// now fill out the _spriteInfo structure in the
// _movieTextObjectStructure
@@ -608,7 +598,7 @@
// free up the mem block containing this text sprite
if (_sequenceTextList[line].text_mem)
- memory->freeMemory(_sequenceTextList[line].text_mem);
+ _vm->_memory->freeMemory(_sequenceTextList[line].text_mem);
// free up the mem block containing this speech sample
if (_sequenceTextList[line].speech_mem)
@@ -628,7 +618,7 @@
// params: 0 id of lead-in music
- leadIn = res_man->openResource(params[0]);
+ leadIn = _vm->_resman->openResource(params[0]);
#ifdef _SWORD2_DEBUG
header = (_standardHeader *) leadIn;
@@ -638,12 +628,12 @@
leadIn += sizeof(_standardHeader);
// wav data gets copied to sound memory
- rv = g_sound->playFx(0, leadIn, 0, 0, RDSE_FXLEADIN);
+ rv = _vm->_sound->playFx(0, leadIn, 0, 0, RDSE_FXLEADIN);
if (rv)
debug(5, "SFX ERROR: playFx() returned %.8x", rv);
- res_man->closeResource(params[0]);
+ _vm->_resman->closeResource(params[0]);
// fade out any music that is currently playing
fnStopMusic(NULL);
@@ -680,17 +670,17 @@
// of computer games" - but at the very least we want to show the
// cutscene subtitles, so I removed them.
- debug(5, "fnPlaySequence(\"%s\");", (const char *) memory->intToPtr(params[0]));
+ debug(5, "fnPlaySequence(\"%s\");", (const char *) _vm->_memory->intToPtr(params[0]));
#ifdef _SWORD2_DEBUG
// check that the name paseed from script is 8 chars or less
- if (strlen((const char *) memory->intToPtr(params[0])) > 8)
+ if (strlen((const char *) _vm->_memory->intToPtr(params[0])) > 8)
error("Sequence filename too long");
#endif
// add the appropriate file extension & play it
- sprintf(filename, "%s.smk", (const char *) memory->intToPtr(params[0]));
+ sprintf(filename, "%s.smk", (const char *) _vm->_memory->intToPtr(params[0]));
// Write to walkthrough file (zebug0.txt)
debug(5, "PLAYING SEQUENCE \"%s\"", filename);
@@ -703,7 +693,7 @@
// open the lead-out music resource, if there is one
if (_smackerLeadOut) {
- leadOut = res_man->openResource(_smackerLeadOut);
+ leadOut = _vm->_resman->openResource(_smackerLeadOut);
#ifdef _SWORD2_DEBUG
header = (_standardHeader *) leadOut;
@@ -720,9 +710,9 @@
fnStopMusic(NULL);
// pause sfx during sequence, except the one used for lead-in music
- g_sound->pauseFxForSequence();
+ _vm->_sound->pauseFxForSequence();
- MoviePlayer player;
+ MoviePlayer player(_vm);
if (_sequenceTextLines && !(_vm->_features & GF_DEMO))
rv = player.play(filename, sequenceSpeechArray, leadOut);
@@ -730,12 +720,12 @@
rv = player.play(filename, NULL, leadOut);
// unpause sound fx again, in case we're staying in same location
- g_sound->unpauseFx();
+ _vm->_sound->unpauseFx();
// close the lead-out music resource
if (_smackerLeadOut) {
- res_man->closeResource(_smackerLeadOut);
+ _vm->_resman->closeResource(_smackerLeadOut);
_smackerLeadOut = 0;
}
@@ -751,14 +741,14 @@
// now clear the screen in case the Sequence was quitted (using ESC)
// rather than fading down to black
- g_graphics->clearScene();
+ _vm->_graphics->clearScene();
// zero the entire palette in case we're about to fade up!
_palEntry pal[256];
memset(pal, 0, 256 * sizeof(_palEntry));
- g_graphics->setPalette(0, 256, (uint8 *) pal, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 256, (uint8 *) pal, RDPAL_INSTANT);
debug(5, "fnPlaySequence FINISHED");
Index: build_display.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/build_display.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- build_display.cpp 13 Nov 2003 07:59:52 -0000 1.48
+++ build_display.cpp 16 Nov 2003 14:18:27 -0000 1.49
@@ -21,20 +21,10 @@
// BUILD_DISPLAY.CPP like the old spr_engi but slightly more aptly named
// ---------------------------------------------------------------------------
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/debug.h"
-#include "sword2/build_display.h"
-#include "sword2/console.h"
#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/layers.h"
-#include "sword2/logic.h"
-#include "sword2/maketext.h"
-#include "sword2/mouse.h"
-#include "sword2/object.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
namespace Sword2 {
@@ -54,11 +44,11 @@
// there is a valid screen to run
if (_thisScreen.background_layer_id) {
// set the scroll position
- g_graphics->setScrollTarget(_thisScreen.scroll_offset_x, _thisScreen.scroll_offset_y);
+ _graphics->setScrollTarget(_thisScreen.scroll_offset_x, _thisScreen.scroll_offset_y);
// increment the mouse frame
- g_graphics->animateMouse();
+ _graphics->animateMouse();
- g_graphics->startRenderCycle();
+ _graphics->startRenderCycle();
while (1) {
// clear the back buffer, before building up the new
@@ -67,49 +57,49 @@
// FIXME: I'm not convinced that this is needed. Isn't
// the whole screen redrawn each time?
- // g_graphics->clearScene();
+ // _graphics->clearScene();
// first background parallax + related anims
// open the screen resource
- file = res_man->openResource(_thisScreen.background_layer_id);
+ file = _resman->openResource(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->bg_parallax[0]) {
- g_graphics->renderParallax(fetchBackgroundParallaxLayer(file, 0), 0);
+ _graphics->renderParallax(fetchBackgroundParallaxLayer(file, 0), 0);
// release the screen resource before cacheing
// the sprites
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
sendBackPar0Frames();
} else {
// release the screen resource
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
}
// second background parallax + related anims
// open the screen resource
- file = res_man->openResource(_thisScreen.background_layer_id);
+ file = _resman->openResource(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->bg_parallax[1]) {
- g_graphics->renderParallax(fetchBackgroundParallaxLayer(file, 1), 1);
+ _graphics->renderParallax(fetchBackgroundParallaxLayer(file, 1), 1);
// release the screen resource before cacheing
// the sprites
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
sendBackPar1Frames();
} else {
// release the screen resource
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
}
// normal backround layer (just the one!)
// open the screen resource
- file = res_man->openResource(_thisScreen.background_layer_id);
- g_graphics->renderParallax(fetchBackgroundLayer(file), 2);
+ file = _resman->openResource(_thisScreen.background_layer_id);
+ _graphics->renderParallax(fetchBackgroundLayer(file), 2);
// release the screen resource
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
// sprites & layers
@@ -121,35 +111,35 @@
// first foreground parallax + related anims
// open the screen resource
- file = res_man->openResource(_thisScreen.background_layer_id);
+ file = _resman->openResource(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->fg_parallax[0]) {
- g_graphics->renderParallax(fetchForegroundParallaxLayer(file, 0), 3);
+ _graphics->renderParallax(fetchForegroundParallaxLayer(file, 0), 3);
// release the screen resource before cacheing
// the sprites
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
sendForePar0Frames();
} else {
// release the screen resource
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
}
// second foreground parallax + related anims
// open the screen resource
- file = res_man->openResource(_thisScreen.background_layer_id);
+ file = _resman->openResource(_thisScreen.background_layer_id);
screenLayerTable = (_multiScreenHeader *) ((uint8 *) file + sizeof(_standardHeader));
if (screenLayerTable->fg_parallax[1]) {
- g_graphics->renderParallax(fetchForegroundParallaxLayer(file, 1), 4);
+ _graphics->renderParallax(fetchForegroundParallaxLayer(file, 1), 4);
// release the screen resource before cacheing
// the sprites
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
sendForePar1Frames();
} else {
// release the screen resource
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
}
// walkgrid, mouse & player markers & mouse area
@@ -160,15 +150,15 @@
// text blocks
// speech blocks and headup debug text
- fontRenderer->printTextBlocs();
+ _fontRenderer->printTextBlocs();
// menu bar & icons
- g_graphics->processMenu();
+ _graphics->processMenu();
// ready - blit to screen
- g_graphics->updateDisplay();
+ _graphics->updateDisplay();
// update our fps reading
@@ -187,7 +177,7 @@
// If we haven't got time to render again this cycle,
// drop out of 'render cycle' while-loop
- if (g_graphics->endRenderCycle())
+ if (_graphics->endRenderCycle())
break;
}
}
@@ -207,24 +197,24 @@
debug(2, "DisplayMsg: %s", (char *) text);
- if (g_graphics->getFadeStatus() != RDFADE_BLACK) {
- g_graphics->fadeDown();
- g_graphics->waitForFade();
+ if (_graphics->getFadeStatus() != RDFADE_BLACK) {
+ _graphics->fadeDown();
+ _graphics->waitForFade();
}
setMouse(0);
setLuggage(0);
- g_graphics->closeMenuImmediately();
- g_graphics->clearScene();
+ _graphics->closeMenuImmediately();
+ _graphics->clearScene();
- text_spr = fontRenderer->makeTextSprite(text, 640, 187, _speechFontId);
+ text_spr = _fontRenderer->makeTextSprite(text, 640, 187, _speechFontId);
frame = (_frameHeader *) text_spr->ad;
- spriteInfo.x = g_graphics->_screenWide / 2 - frame->width / 2;
+ spriteInfo.x = _graphics->_screenWide / 2 - frame->width / 2;
if (!time)
- spriteInfo.y = g_graphics->_screenDeep / 2 - frame->height / 2 - RDMENU_MENUDEEP;
+ spriteInfo.y = _graphics->_screenDeep / 2 - frame->height / 2 - RDMENU_MENUDEEP;
else
spriteInfo.y = 400 - frame->height;
spriteInfo.w = frame->width;
@@ -237,29 +227,29 @@
spriteInfo.data = text_spr->ad + sizeof(_frameHeader);
spriteInfo.colourTable = 0;
- rv = g_graphics->drawSprite(&spriteInfo);
+ rv = _graphics->drawSprite(&spriteInfo);
if (rv)
error("Driver Error %.8x (in DisplayMsg)", rv);
- memcpy((char *) oldPal, (char *) g_graphics->_palCopy, 256 * sizeof(_palEntry));
+ memcpy((char *) oldPal, (char *) _graphics->_palCopy, 256 * sizeof(_palEntry));
memset(pal, 0, 256 * sizeof(_palEntry));
pal[187].red = 255;
pal[187].green = 255;
pal[187].blue = 255;
- g_graphics->setPalette(0, 256, (uint8 *) pal, RDPAL_FADE);
+ _graphics->setPalette(0, 256, (uint8 *) pal, RDPAL_FADE);
- g_graphics->fadeUp();
+ _graphics->fadeUp();
- memory->freeMemory(text_spr);
+ _memory->freeMemory(text_spr);
- g_graphics->waitForFade();
+ _graphics->waitForFade();
uint32 targetTime = _system->get_msecs() + (time * 1000);
sleepUntil(targetTime);
- g_graphics->setPalette(0, 256, (uint8 *) oldPal, RDPAL_FADE);
+ _graphics->setPalette(0, 256, (uint8 *) oldPal, RDPAL_FADE);
}
//
@@ -267,11 +257,11 @@
//
void Sword2Engine::removeMsg(void) {
- g_graphics->fadeDown();
- g_graphics->waitForFade();
- g_graphics->clearScene();
+ _graphics->fadeDown();
+ _graphics->waitForFade();
+ _graphics->clearScene();
- // g_graphics->fadeUp();
+ // _graphics->fadeUp();
// removed by JEL (08oct97) to prevent "eye" smacker corruption when
// restarting game from CD2 and also to prevent palette flicker when
// restoring game to a different CD since the "insert CD" message uses
@@ -351,7 +341,7 @@
uint32 current_layer_area = 0;
// file points to 1st byte in the layer file
- file = res_man->openResource(_thisScreen.background_layer_id);
+ file = _resman->openResource(_thisScreen.background_layer_id);
// point to layer header
layer_head = fetchLayerHeader(file,layer_number);
@@ -380,11 +370,11 @@
layer_number, layer_head->width, layer_head->height);
}
- rv = g_graphics->drawSprite(&spriteInfo);
+ rv = _graphics->drawSprite(&spriteInfo);
if (rv)
error("Driver Error %.8x in Process_layer(%d)", rv, layer_number);
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
}
void Sword2Engine::processImage(buildit *build_unit) {
@@ -399,7 +389,7 @@
uint32 current_sprite_area = 0;
// open anim resource file & point to base
- file = res_man->openResource(build_unit->anim_resource);
+ file = _resman->openResource(build_unit->anim_resource);
anim_head = fetchAnimHeader(file);
cdt_entry = fetchCdtEntry(file, build_unit->anim_pc);
@@ -506,14 +496,14 @@
// }
// #endif
- rv = g_graphics->drawSprite(&spriteInfo);
+ rv = _graphics->drawSprite(&spriteInfo);
if (rv)
error("Driver Error %.8x with sprite %s (%d) in processImage",
rv, fetchObjectName(build_unit->anim_resource),
build_unit->anim_resource);
// release the anim resource
- res_man->closeResource(build_unit->anim_resource);
+ _resman->closeResource(build_unit->anim_resource);
}
void Sword2Engine::resetRenderLists(void) {
@@ -571,11 +561,11 @@
// open animation file & set up the necessary pointers
- ob_graph = (Object_graphic *) memory->intToPtr(params[1]);
+ ob_graph = (Object_graphic *) _memory->intToPtr(params[1]);
assert(ob_graph->anim_resource);
- file = res_man->openResource(ob_graph->anim_resource);
+ file = _resman->openResource(ob_graph->anim_resource);
anim_head = fetchAnimHeader(file);
cdt_entry = fetchCdtEntry(file, ob_graph->anim_pc);
@@ -609,7 +599,7 @@
if (cdt_entry->frameType & FRAME_OFFSET) {
// param 2 is pointer to mega structure
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_mega = (Object_mega *) _memory->intToPtr(params[2]);
// calc scale at which to print the sprite, based on feet
// y-coord & scaling constants (NB. 'scale' is actually
@@ -650,7 +640,7 @@
if (params[0]) {
// passed a mouse structure, so add to the _mouseList
- ob_mouse = (Object_mouse *) memory->intToPtr(params[0]);
+ ob_mouse = (Object_mouse *) _memory->intToPtr(params[0]);
// only if 'pointer' isn't NULL
if (ob_mouse->pointer) {
@@ -685,7 +675,7 @@
}
// close animation file
- res_man->closeResource(ob_graph->anim_resource);
+ _resman->closeResource(ob_graph->anim_resource);
}
int32 Logic::fnRegisterFrame(int32 *params) {
@@ -701,7 +691,7 @@
}
int32 Sword2Engine::registerFrame(int32 *params) {
- Object_graphic *ob_graph = (Object_graphic *) memory->intToPtr(params[1]);
+ Object_graphic *ob_graph = (Object_graphic *) _memory->intToPtr(params[1]);
// check low word for sprite type
switch (ob_graph->type & 0x0000ffff) {
@@ -756,23 +746,23 @@
// if the screen is still fading down then wait for black - could
// happen when everythings cached into a large memory model
- g_graphics->waitForFade();
+ _graphics->waitForFade();
// open the screen file
- screenFile = res_man->openResource(_thisScreen.background_layer_id);
+ screenFile = _resman->openResource(_thisScreen.background_layer_id);
- g_graphics->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(screenFile));
+ _graphics->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(screenFile));
- g_graphics->setPalette(0, 256, fetchPalette(screenFile), RDPAL_FADE);
+ _graphics->setPalette(0, 256, fetchPalette(screenFile), RDPAL_FADE);
// indicating that it's a screen palette
_lastPaletteRes = 0;
// close screen file
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
// start fade up
- g_graphics->fadeUp();
+ _graphics->fadeUp();
// reset
_thisScreen.new_palette = 0;
@@ -783,7 +773,7 @@
// params: 0 pointer to mega structure
- Object_mega *ob_mega = (Object_mega *) memory->intToPtr(params[0]);
+ Object_mega *ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[0]);
_vm->_thisScreen.player_feet_x = ob_mega->feet_x;
_vm->_thisScreen.player_feet_y = ob_mega->feet_y;
@@ -806,8 +796,8 @@
// params: none
- if (g_graphics->getFadeStatus() == RDFADE_NONE)
- g_graphics->fadeDown();
+ if (_vm->_graphics->getFadeStatus() == RDFADE_NONE)
+ _vm->_graphics->fadeDown();
return IR_CONT;
}
@@ -815,10 +805,10 @@
int32 Logic::fnFadeUp(int32 *params) {
// params: none
- g_graphics->waitForFade();
+ _vm->_graphics->waitForFade();
- if (g_graphics->getFadeStatus() == RDFADE_BLACK)
- g_graphics->fadeUp();
+ if (_vm->_graphics->getFadeStatus() == RDFADE_BLACK)
+ _vm->_graphics->fadeUp();
return IR_CONT;
}
@@ -867,7 +857,7 @@
// non-zero: set palette to this separate palette file
if (palRes) {
// open the palette file
- head = (_standardHeader *) res_man->openResource(palRes);
+ head = (_standardHeader *) _resman->openResource(palRes);
assert(head->fileType == PALETTE_FILE);
@@ -883,9 +873,9 @@
file[3] = 0;
// not yet in separate palette files
- // g_graphics->updatePaletteMatchTable(file + (256 * 4));
+ // _graphics->updatePaletteMatchTable(file + (256 * 4));
- g_graphics->setPalette(0, 256, file, RDPAL_INSTANT);
+ _graphics->setPalette(0, 256, file, RDPAL_INSTANT);
if (palRes != CONTROL_PANEL_PALETTE) { // (James 03sep97)
// indicating that it's a separate palette resource
@@ -893,21 +883,21 @@
}
// close palette file
- res_man->closeResource(palRes);
+ _resman->closeResource(palRes);
} else {
// 0: set palette to current screen palette
if (_thisScreen.background_layer_id) {
// open the screen file
- file = res_man->openResource(_thisScreen.background_layer_id);
- g_graphics->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(file));
+ file = _resman->openResource(_thisScreen.background_layer_id);
+ _graphics->updatePaletteMatchTable((uint8 *) fetchPaletteMatchTable(file));
- g_graphics->setPalette(0, 256, fetchPalette(file), RDPAL_INSTANT);
+ _graphics->setPalette(0, 256, fetchPalette(file), RDPAL_INSTANT);
// indicating that it's a screen palette
_lastPaletteRes = 0;
// close screen file
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
} else
error("setFullPalette(0) called, but no current screen available!");
}
@@ -923,7 +913,7 @@
// if last screen was using a shading mask (see below)
if (_vm->_thisScreen.mask_flag) {
- uint32 rv = g_graphics->closeLightMask();
+ uint32 rv = _vm->_graphics->closeLightMask();
if (rv)
error("Driver Error %.8x [%s line %u]", rv);
Index: console.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/console.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- console.cpp 15 Nov 2003 09:37:59 -0000 1.34
+++ console.cpp 16 Nov 2003 14:18:27 -0000 1.35
@@ -17,33 +17,14 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
-#include "sword2/debug.h"
#include "sword2/defs.h"
-#include "sword2/logic.h"
-#include "sword2/maketext.h"
-#include "sword2/mouse.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/save_rest.h"
-#include "sword2/startup.h"
#include "common/debugger.cpp"
namespace Sword2 {
-void Debugger::varGet(int var) {
- Debug_Printf("%d\n", VAR(var));
-}
-
-void Debugger::varSet(int var, int val) {
- Debug_Printf("was %d, ", VAR(var));
- VAR(var) = val;
- Debug_Printf("now %d\n", VAR(var));
-}
-
Debugger::Debugger(Sword2Engine *vm)
: Common::Debugger<Debugger>() {
_vm = vm;
@@ -130,22 +111,31 @@
DCmd_Register("polish", &Debugger::Cmd_Polish);
}
+void Debugger::varGet(int var) {
+ Debug_Printf("%d\n", VAR(var));
+}
+
+void Debugger::varSet(int var, int val) {
+ Debug_Printf("was %d, ", VAR(var));
+ VAR(var) = val;
+ Debug_Printf("now %d\n", VAR(var));
+}
+
void Debugger::preEnter() {
// Pause sound output
- g_sound->pauseFx();
- g_sound->pauseSpeech();
- g_sound->pauseMusic();
+ _vm->_sound->pauseFx();
+ _vm->_sound->pauseSpeech();
+ _vm->_sound->pauseMusic();
}
void Debugger::postEnter() {
// Resume previous sound state
- g_sound->unpauseFx();
- g_sound->unpauseSpeech();
- g_sound->unpauseMusic();
+ _vm->_sound->unpauseFx();
+ _vm->_sound->unpauseSpeech();
+ _vm->_sound->unpauseMusic();
// Restore old mouse cursor
- g_graphics->drawMouse();
-
+ _vm->_graphics->drawMouse();
}
///////////////////////////////////////////////////
@@ -181,7 +171,7 @@
}
bool Debugger::Cmd_Mem(int argc, const char **argv) {
- memory->displayMemory();
+ _vm->_memory->displayMemory();
return true;
}
@@ -191,7 +181,7 @@
}
bool Debugger::Cmd_Res(int argc, const char **argv) {
- res_man->printConsoleClusters();
+ _vm->_resman->printConsoleClusters();
return true;
}
@@ -209,7 +199,7 @@
}
_vm->_logic->conStart(atoi(argv[1]));
- g_graphics->setPalette(187, 1, pal, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(187, 1, pal, RDPAL_INSTANT);
return true;
}
@@ -261,7 +251,7 @@
if (argc != 2)
DebugPrintf("Usage: %s number\n", argv[0]);
else
- res_man->examine(atoi(argv[1]));
+ _vm->_resman->examine(atoi(argv[1]));
return true;
}
@@ -279,13 +269,13 @@
if (argc != 2)
DebugPrintf("Usage: %s number\n", argv[0]);
else
- res_man->kill(atoi(argv[1]));
+ _vm->_resman->kill(atoi(argv[1]));
return true;
}
bool Debugger::Cmd_Nuke(int argc, const char **argv) {
DebugPrintf("Killing all resources except variable file and player object\n");
- res_man->killAll(true);
+ _vm->_resman->killAll(true);
return true;
}
@@ -318,7 +308,7 @@
}
bool Debugger::Cmd_Clear(int argc, const char **argv) {
- res_man->killAllObjects(true);
+ _vm->_resman->killAllObjects(true);
return true;
}
@@ -451,14 +441,14 @@
// FIXME: Replace these with a command to modify the graphics detail setting
bool Debugger::Cmd_BltFxOn(int argc, const char **argv) {
- // g_graphics->setBltFx();
+ // _vm->_graphics->setBltFx();
// DebugPrintf("Blit fx enabled\n");
DebugPrintf("FIXME: The setBltFx() function no longer exists\n");
return true;
}
bool Debugger::Cmd_BltFxOff(int argc, const char **argv) {
- // g_graphics->clearBltFx();
+ // _vm->_graphics->clearBltFx();
// DebugPrintf("Blit fx disabled\n");
DebugPrintf("FIXME: The clearBltFx() function no longer exists\n");
return true;
@@ -466,9 +456,9 @@
bool Debugger::Cmd_TimeOn(int argc, const char **argv) {
if (argc == 2)
- _startTime = g_system->get_msecs() - atoi(argv[1]) * 1000;
+ _startTime = _vm->_system->get_msecs() - atoi(argv[1]) * 1000;
else if (_startTime == 0)
- _startTime = g_system->get_msecs();
+ _startTime = _vm->_system->get_msecs();
_displayTime = true;
DebugPrintf("Timer display on\n");
return true;
Index: console.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/console.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- console.h 8 Nov 2003 15:47:51 -0000 1.13
+++ console.h 16 Nov 2003 14:18:27 -0000 1.14
@@ -28,8 +28,6 @@
namespace Sword2 {
-class Sword2Engine;
-
class Debugger : public Common::Debugger<Debugger> {
private:
void varGet(int var);
Index: controls.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/controls.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- controls.cpp 15 Nov 2003 09:37:59 -0000 1.50
+++ controls.cpp 16 Nov 2003 14:18:27 -0000 1.51
@@ -17,27 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "common/config-manager.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/build_display.h"
-#include "sword2/console.h"
-#include "sword2/controls.h"
-#include "sword2/defs.h"
[...1203 lines suppressed...]
// FOR THE DEMO - FORCE THE SCROLLING TO BE RESET!
// - this is taken from fnInitBackground
@@ -1479,7 +1547,7 @@
}
void Gui::optionControl(void) {
- OptionsDialog optionsDialog;
+ OptionsDialog optionsDialog(this);
optionsDialog.run();
return;
@@ -1491,7 +1559,7 @@
else if (newLevel > 3)
newLevel = 3;
- g_graphics->setRenderLevel(newLevel);
+ _vm->_graphics->setRenderLevel(newLevel);
// update our global variable - which needs to be checked when dimming
// the palette in PauseGame() in sword2.cpp (since palette-matching
Index: controls.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/controls.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- controls.h 8 Nov 2003 15:47:51 -0000 1.10
+++ controls.h 16 Nov 2003 14:18:27 -0000 1.11
@@ -26,12 +26,12 @@
class Gui {
private:
- Sword2Engine *_vm;
-
int _musicVolume[17];
int _soundVolume[15];
public:
+ Sword2Engine *_vm;
+
int _baseSlot;
uint8 _currentGraphicsLevel;
@@ -50,8 +50,6 @@
void writeOptionSettings(void);
void updateGraphicsLevel(int newLevel);
};
-
-extern Gui *gui;
} // End of namespace Sword2
Index: debug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/debug.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- debug.cpp 15 Nov 2003 09:37:59 -0000 1.30
+++ debug.cpp 16 Nov 2003 14:18:28 -0000 1.31
@@ -17,21 +17,9 @@
* $Header$
*/
-#include "stdafx.h"
-#include "sword2/driver/driver96.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/debug.h"
-#include "sword2/console.h"
#include "sword2/defs.h"
-#include "sword2/layers.h"
-#include "sword2/logic.h"
-#include "sword2/maketext.h"
-#include "sword2/mouse.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/router.h" // for plotWalkGrid()
-#include "sword2/speech.h" // for '_officialTextNumber'
- // and '_speechScriptWaiting'
namespace Sword2 {
@@ -40,7 +28,7 @@
while (blockNo < MAX_DEBUG_TEXT_BLOCKS && _debugTextBlocks[blockNo] > 0) {
// kill the system text block
- fontRenderer->killTextBloc(_debugTextBlocks[blockNo]);
+ _vm->_fontRenderer->killTextBloc(_debugTextBlocks[blockNo]);
// clear this element of our array of block numbers
_debugTextBlocks[blockNo] = 0;
@@ -57,7 +45,7 @@
assert(blockNo < MAX_DEBUG_TEXT_BLOCKS);
- _debugTextBlocks[blockNo] = fontRenderer->buildNewBloc((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION);
+ _debugTextBlocks[blockNo] = _vm->_fontRenderer->buildNewBloc((uint8 *) text, x, y, 640 - x, 0, RDSPR_DISPLAYALIGN, CONSOLE_FONT_ID, NO_JUSTIFICATION);
}
void Debugger::buildDebugText(void) {
@@ -120,7 +108,7 @@
// debug info at top of screen - enabled/disabled as one complete unit
if (_displayTime) {
- int32 time = g_system->get_msecs();
+ int32 time = _vm->_system->get_msecs();
if ((time - _startTime) / 1000 >= 10000)
_startTime = time;
@@ -186,14 +174,14 @@
if (_vm->_mouseTouching)
sprintf(buf, "mouse %d,%d (id %d: %s)",
- g_input->_mouseX + _vm->_thisScreen.scroll_offset_x,
- g_input->_mouseY + _vm->_thisScreen.scroll_offset_y,
+ _vm->_input->_mouseX + _vm->_thisScreen.scroll_offset_x,
+ _vm->_input->_mouseY + _vm->_thisScreen.scroll_offset_y,
_vm->_mouseTouching,
_vm->fetchObjectName(_vm->_mouseTouching));
else
sprintf(buf, "mouse %d,%d (not touching)",
- g_input->_mouseX + _vm->_thisScreen.scroll_offset_x,
- g_input->_mouseY + _vm->_thisScreen.scroll_offset_y);
+ _vm->_input->_mouseX + _vm->_thisScreen.scroll_offset_x,
+ _vm->_input->_mouseY + _vm->_thisScreen.scroll_offset_y);
makeDebugTextBlock(buf, 0, 30);
@@ -280,7 +268,7 @@
showVarPos = 115; // y-coord for first showVar
// res 1 is the global variables resource
- varTable = (int32 *) (res_man->openResource(1) + sizeof(_standardHeader));
+ varTable = (int32 *) (_vm->_resman->openResource(1) + sizeof(_standardHeader));
for (showVarNo = 0; showVarNo < MAX_SHOWVARS; showVarNo++) {
varNo = _showVar[showVarNo]; // get variable number
@@ -295,12 +283,12 @@
}
}
- res_man->closeResource(1); // close global variables resource
+ _vm->_resman->closeResource(1); // close global variables resource
// memory indicator - this should come last, to show all the
// sprite blocks above!
- memory->memoryString(buf);
+ _vm->_memory->memoryString(buf);
makeDebugTextBlock(buf, 0, 0);
}
}
@@ -319,7 +307,7 @@
// mouse marker & coords
if (_displayMouseMarker)
- plotCrossHair(g_input->_mouseX + _vm->_thisScreen.scroll_offset_x, g_input->_mouseY + _vm->_thisScreen.scroll_offset_y, 215);
+ plotCrossHair(_vm->_input->_mouseX + _vm->_thisScreen.scroll_offset_x, _vm->_input->_mouseY + _vm->_thisScreen.scroll_offset_y, 215);
// mouse area rectangle / sprite box rectangle when testing anims
@@ -335,20 +323,20 @@
}
void Debugger::plotCrossHair(int16 x, int16 y, uint8 pen) {
- g_graphics->plotPoint(x, y, pen); // driver function
+ _vm->_graphics->plotPoint(x, y, pen);
- g_graphics->drawLine(x - 2, y, x - 5, y, pen); // driver function
- g_graphics->drawLine(x + 2, y, x + 5, y, pen);
+ _vm->_graphics->drawLine(x - 2, y, x - 5, y, pen);
+ _vm->_graphics->drawLine(x + 2, y, x + 5, y, pen);
- g_graphics->drawLine(x, y - 2, x, y - 5, pen);
- g_graphics->drawLine(x, y + 2, x, y + 5, pen);
+ _vm->_graphics->drawLine(x, y - 2, x, y - 5, pen);
+ _vm->_graphics->drawLine(x, y + 2, x, y + 5, pen);
}
void Debugger::drawRect(int16 x1, int16 y1, int16 x2, int16 y2, uint8 pen) {
- g_graphics->drawLine(x1, y1, x2, y1, pen); // top edge
- g_graphics->drawLine(x1, y2, x2, y2, pen); // bottom edge
- g_graphics->drawLine(x1, y1, x1, y2, pen); // left edge
- g_graphics->drawLine(x2, y1, x2, y2, pen); // right edge
+ _vm->_graphics->drawLine(x1, y1, x2, y1, pen); // top edge
+ _vm->_graphics->drawLine(x1, y2, x2, y2, pen); // bottom edge
+ _vm->_graphics->drawLine(x1, y1, x1, y2, pen); // left edge
+ _vm->_graphics->drawLine(x2, y1, x2, y2, pen); // right edge
}
void Debugger::printCurrentInfo(void) {
Index: defs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/defs.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- defs.h 3 Nov 2003 07:47:41 -0000 1.7
+++ defs.h 16 Nov 2003 14:18:28 -0000 1.8
@@ -20,16 +20,13 @@
#ifndef DEFS
#define DEFS
-#include "sword2/header.h"
-#include "sword2/resman.h"
-
#define SIZE 0x10000 // 65536 items per section
#define NuSIZE 0xffff // & with this
// 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 *) (g_sword2->_resman->_resList[1]->ad + sizeof(_standardHeader) + 4 * (n)))
#define ID VAR(0)
#define RESULT VAR(1)
Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/events.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- events.cpp 15 Nov 2003 09:37:59 -0000 1.21
+++ events.cpp 16 Nov 2003 14:18:28 -0000 1.22
@@ -17,14 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
-#include "sword2/debug.h"
#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/object.h"
namespace Sword2 {
@@ -185,7 +181,7 @@
// params: 0 pointer to object's logic structure
// 1 number of game-cycles to pause
- Object_logic *ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ Object_logic *ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
// first, check for an event
Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/function.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- function.cpp 11 Nov 2003 07:43:02 -0000 1.40
+++ function.cpp 16 Nov 2003 14:18:28 -0000 1.41
@@ -17,19 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/build_display.h"
-#include "sword2/credits.h"
-#include "sword2/debug.h"
+#include "common/stdafx.h"
+#include "sword2/sword2.h"
#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/layers.h" // for '_thisScreen' structure
-#include "sword2/logic.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/sound.h"
-#include "sword2/sword2.h"
namespace Sword2 {
@@ -97,8 +88,8 @@
// params: 0 resource to preload
- res_man->openResource(params[0]);
- res_man->closeResource(params[0]);
+ _vm->_resman->openResource(params[0]);
+ _vm->_resman->closeResource(params[0]);
return IR_CONT;
}
@@ -148,7 +139,7 @@
// NB. Pause-value of 0 causes script to continue, 1 causes a 1-cycle
// quit, 2 gives 2 cycles, etc.
- Object_logic *ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ Object_logic *ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
// start the pause
@@ -177,7 +168,7 @@
// 1 minimum number of game-cycles to pause
// 2 maximum number of game-cycles to pause
- Object_logic *ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ Object_logic *ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
int32 pars[2];
if (ob_logic->looping == 0) {
@@ -202,7 +193,7 @@
// params: 0 pointer to a graphic structure (might not need this?)
- memcpy(&_vm->_engineGraph, memory->intToPtr(params[0]), sizeof(Object_graphic));
+ memcpy(&_vm->_engineGraph, _vm->_memory->intToPtr(params[0]), sizeof(Object_graphic));
// makes no odds
return IR_CONT;
@@ -218,7 +209,7 @@
// params: 0 pointer to a mega structure
- memcpy(&_vm->_engineMega, memory->intToPtr(params[0]), sizeof(Object_mega));
+ memcpy(&_vm->_engineMega, _vm->_memory->intToPtr(params[0]), sizeof(Object_mega));
// makes no odds
return IR_CONT;
@@ -233,7 +224,7 @@
// params: 0 pointer to object's mega structure
// 1 value to set it to
- Object_mega *ob_mega = (Object_mega *) memory->intToPtr(params[0]);
+ Object_mega *ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[0]);
ob_mega->megaset_res = params[1];
@@ -266,25 +257,25 @@
// what colour?
switch (params[0]) {
case WHITE:
- g_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
break;
case RED:
- g_graphics->setPalette(0, 1, red, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, red, RDPAL_INSTANT);
break;
case GREEN:
- g_graphics->setPalette(0, 1, green, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, green, RDPAL_INSTANT);
break;
case BLUE:
- g_graphics->setPalette(0, 1, blue, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, blue, RDPAL_INSTANT);
break;
}
// There used to be a busy-wait loop here, so I don't know how long
// the delay was meant to be. Probably doesn't matter much.
- g_graphics->updateDisplay();
- g_system->delay_msecs(250);
- g_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
+ _vm->_graphics->updateDisplay();
+ _vm->_system->delay_msecs(250);
+ _vm->_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
#endif
return IR_CONT;
@@ -302,19 +293,19 @@
// what colour?
switch (params[0]) {
case BLACK:
- g_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
break;
case WHITE:
- g_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
break;
case RED:
- g_graphics->setPalette(0, 1, red, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, red, RDPAL_INSTANT);
break;
case GREEN:
- g_graphics->setPalette(0, 1, green, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, green, RDPAL_INSTANT);
break;
case BLUE:
- g_graphics->setPalette(0, 1, blue, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, blue, RDPAL_INSTANT);
break;
}
#endif
@@ -335,8 +326,8 @@
// +2 to skip the encoded text number in the first 2 chars; 3 is
// duration in seconds
- _vm->displayMsg(_vm->fetchTextLine(res_man->openResource(text_res), local_text) + 2, 3);
- res_man->closeResource(text_res);
+ _vm->displayMsg(_vm->fetchTextLine(_vm->_resman->openResource(text_res), local_text) + 2, 3);
+ _vm->_resman->closeResource(text_res);
_vm->removeMsg();
return IR_CONT;
@@ -351,20 +342,20 @@
int32 size;
uint32 *globals;
- size = res_man->fetchLen(1);
+ size = _vm->_resman->fetchLen(1);
size -= sizeof(_standardHeader);
debug(5, "globals size: %d", size);
- globals = (uint32 *) ((uint8 *) res_man->openResource(1) + sizeof(_standardHeader));
+ globals = (uint32 *) ((uint8 *) _vm->_resman->openResource(1) + sizeof(_standardHeader));
// blank each global variable
memset(globals, 0, size);
- res_man->closeResource(1);
+ _vm->_resman->closeResource(1);
// all objects but george
- res_man->killAllObjects(false);
+ _vm->_resman->killAllObjects(false);
// FOR THE DEMO - FORCE THE SCROLLING TO BE RESET!
// - this is taken from fnInitBackground
@@ -387,23 +378,23 @@
int32 music_length;
int32 pars[2];
- g_sound->saveMusicState();
+ _vm->_sound->saveMusicState();
- g_sound->muteFx(true);
- g_sound->muteSpeech(true);
- g_sound->stopMusic();
+ _vm->_sound->muteFx(true);
+ _vm->_sound->muteSpeech(true);
+ _vm->_sound->stopMusic();
- memcpy(oldPal, g_graphics->_palCopy, 1024);
+ memcpy(oldPal, _vm->_graphics->_palCopy, 1024);
memset(tmpPal, 0, 1024);
- g_graphics->waitForFade();
- g_graphics->fadeDown();
- g_graphics->waitForFade();
+ _vm->_graphics->waitForFade();
+ _vm->_graphics->fadeDown();
+ _vm->_graphics->waitForFade();
tmpPal[4] = 255;
tmpPal[5] = 255;
tmpPal[6] = 255;
- g_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 256, tmpPal, RDPAL_INSTANT);
// Play the credits music. Is it enough with just one
// repetition of it?
@@ -412,41 +403,41 @@
pars[1] = FX_SPOT;
fnPlayMusic(pars);
- music_length = 1000 * g_sound->musicTimeRemaining();
+ music_length = 1000 * _vm->_sound->musicTimeRemaining();
debug(0, "Credits music length: ~%d ms", music_length);
- g_graphics->closeMenuImmediately();
+ _vm->_graphics->closeMenuImmediately();
- while (g_sound->musicTimeRemaining()) {
- g_graphics->clearScene();
- g_graphics->setNeedFullRedraw();
+ while (_vm->_sound->musicTimeRemaining()) {
+ _vm->_graphics->clearScene();
+ _vm->_graphics->setNeedFullRedraw();
// FIXME: Draw the credits text. The actual text
// messages are stored in credits.clu, and I'm guessing
// that credits.bmp or font.clu may be the font.
- g_graphics->updateDisplay();
+ _vm->_graphics->updateDisplay();
_keyboardEvent ke;
- if (g_input->readKey(&ke) == RD_OK && ke.keycode == 27)
+ if (_vm->_input->readKey(&ke) == RD_OK && ke.keycode == 27)
break;
- g_system->delay_msecs(30);
+ _vm->_system->delay_msecs(30);
}
fnStopMusic(NULL);
- g_sound->restoreMusicState();
+ _vm->_sound->restoreMusicState();
- g_graphics->setPalette(0, 256, oldPal, RDPAL_FADE);
- g_graphics->fadeUp();
- g_graphics->updateDisplay();
+ _vm->_graphics->setPalette(0, 256, oldPal, RDPAL_FADE);
+ _vm->_graphics->fadeUp();
+ _vm->_graphics->updateDisplay();
_vm->buildDisplay();
- g_graphics->waitForFade();
+ _vm->_graphics->waitForFade();
- g_sound->muteFx(false);
- g_sound->muteSpeech(false);
+ _vm->_sound->muteFx(false);
+ _vm->_sound->muteSpeech(false);
}
if (_vm->_features & GF_DEMO) {
Index: header.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/header.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- header.h 4 Oct 2003 00:52:25 -0000 1.4
+++ header.h 16 Nov 2003 14:18:28 -0000 1.5
@@ -20,8 +20,6 @@
#ifndef _HEADER
#define _HEADER
-#include "common/scummsys.h"
-
namespace Sword2 {
//----------------------------------------------------------
Index: icons.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/icons.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- icons.cpp 15 Nov 2003 09:37:59 -0000 1.26
+++ icons.cpp 16 Nov 2003 14:18:28 -0000 1.27
@@ -17,14 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/driver/driver96.h"
#include "sword2/defs.h"
-#include "sword2/icons.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/mouse.h"
namespace Sword2 {
@@ -34,7 +30,7 @@
assert(_vm->_totalTemp < TOTAL_engine_pockets);
// copy the structure to our in-the-engine list
- memcpy(&_vm->_tempList[_vm->_totalTemp], memory->intToPtr(params[0]), sizeof(menu_object));
+ memcpy(&_vm->_tempList[_vm->_totalTemp], _vm->_memory->intToPtr(params[0]), sizeof(menu_object));
_vm->_totalTemp++;
// script continue
@@ -87,9 +83,9 @@
// Call menu builder script which will register all carried menu
// objects. Run the 'build_menu' script in the 'menu_master' object
- head = res_man->openResource(MENU_MASTER_OBJECT);
+ head = _resman->openResource(MENU_MASTER_OBJECT);
_logic->runScript((char*) head, (char*) head, &null_pc);
- res_man->closeResource(MENU_MASTER_OBJECT);
+ _resman->closeResource(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
@@ -191,7 +187,7 @@
icon_coloured = true;
}
- icon = res_man->openResource(_masterMenuList[j].icon_resource) + sizeof(_standardHeader);
+ icon = _resman->openResource(_masterMenuList[j].icon_resource) + sizeof(_standardHeader);
// The coloured icon is stored directly after the
// greyed out one.
@@ -199,16 +195,16 @@
if (icon_coloured)
icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
- g_graphics->setMenuIcon(RDMENU_BOTTOM, j, icon);
- res_man->closeResource(res);
+ _graphics->setMenuIcon(RDMENU_BOTTOM, j, icon);
+ _resman->closeResource(res);
} else {
// no icon here
- g_graphics->setMenuIcon(RDMENU_BOTTOM, j, NULL);
+ _graphics->setMenuIcon(RDMENU_BOTTOM, j, NULL);
debug(5, " NULL for %d", j);
}
}
- g_graphics->showMenu(RDMENU_BOTTOM);
+ _graphics->showMenu(RDMENU_BOTTOM);
}
void Sword2Engine::buildSystemMenu(void) {
@@ -228,7 +224,7 @@
// rest will grey out
for (int i = 0; i < ARRAYSIZE(icon_list); i++) {
- icon = res_man->openResource(icon_list[i]) + sizeof(_standardHeader);
+ icon = _resman->openResource(icon_list[i]) + sizeof(_standardHeader);
// The only case when an icon is grayed is when the player
// is dead. Then SAVE is not available.
@@ -236,11 +232,11 @@
if (!DEAD || icon_list[i] != SAVE_ICON)
icon += (RDMENU_ICONWIDE * RDMENU_ICONDEEP);
- g_graphics->setMenuIcon(RDMENU_TOP, i, icon);
- res_man->closeResource(icon_list[i]);
+ _graphics->setMenuIcon(RDMENU_TOP, i, icon);
+ _resman->closeResource(icon_list[i]);
}
- g_graphics->showMenu(RDMENU_TOP);
+ _graphics->showMenu(RDMENU_TOP);
}
} // End of namespace Sword2
Index: icons.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/icons.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- icons.h 2 Nov 2003 15:58:45 -0000 1.8
+++ icons.h 16 Nov 2003 14:18:28 -0000 1.9
@@ -20,8 +20,6 @@
#ifndef _ICONS
#define _ICONS
-#include "sword2/object.h"
-
#define MENU_MASTER_OBJECT 44
#define TOTAL_subjects (375 - 256 + 1) // the speech subject bar
#define TOTAL_engine_pockets (15 + 10) // +10 for overflow
Index: interpreter.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/interpreter.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- interpreter.cpp 10 Nov 2003 07:52:15 -0000 1.24
+++ interpreter.cpp 16 Nov 2003 14:18:28 -0000 1.25
@@ -17,11 +17,9 @@
* $Header$
*/
-#include "stdafx.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/console.h"
+#include "common/stdafx.h"
+#include "sword2/sword2.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
namespace Sword2 {
@@ -353,8 +351,8 @@
case CP_PUSH_LOCAL_ADDR:
// push the address of a local variable
Read16ip(parameter);
- debug(5, "Push address of local variable %d (%x)", parameter, memory->ptrToInt((const uint8 *) (variables + parameter)));
- PUSHONSTACK(memory->ptrToInt((uint8 *) (variables + parameter)));
+ debug(5, "Push address of local variable %d (%x)", parameter, _vm->_memory->ptrToInt((const uint8 *) (variables + parameter)));
+ PUSHONSTACK(_vm->_memory->ptrToInt((uint8 *) (variables + parameter)));
break;
case CP_PUSH_INT32:
// Push a long word value on to the stack
@@ -589,14 +587,14 @@
Read8ip(parameter);
// ip points to the string
- PUSHONSTACK(memory->ptrToInt((const uint8 *) (code + ip)));
+ PUSHONSTACK(_vm->_memory->ptrToInt((const uint8 *) (code + ip)));
ip += (parameter + 1);
break;
case CP_PUSH_DEREFERENCED_STRUCTURE:
// Push the address of a dereferenced structure
Read32ip(parameter);
- debug(5, "Push address of far variable (%x)", memory->ptrToInt((const uint8 *) (objectData + sizeof(int32) + sizeof(_standardHeader) + sizeof(_object_hub) + parameter)));
- PUSHONSTACK(memory->ptrToInt((const uint8 *) (objectData + sizeof(int32) + sizeof(_standardHeader) + sizeof(_object_hub) + parameter)));
+ debug(5, "Push address of far variable (%x)", _vm->_memory->ptrToInt((const uint8 *) (objectData + sizeof(int32) + sizeof(_standardHeader) + sizeof(_object_hub) + parameter)));
+ PUSHONSTACK(_vm->_memory->ptrToInt((const uint8 *) (objectData + sizeof(int32) + sizeof(_standardHeader) + sizeof(_object_hub) + parameter)));
break;
case OP_GTTHANE:
// '>='
Index: layers.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/layers.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- layers.cpp 11 Nov 2003 07:43:02 -0000 1.21
+++ layers.cpp 16 Nov 2003 14:18:28 -0000 1.22
@@ -25,16 +25,8 @@
// 3 normal sorted layers
// up to 2 foreground parallax layers
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/build_display.h"
-#include "sword2/debug.h"
-#include "sword2/header.h"
-#include "sword2/layers.h"
-#include "sword2/logic.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/sound.h" // for clearFxQueue() called from fnInitBackground()
namespace Sword2 {
@@ -69,11 +61,11 @@
#endif
// if the screen is still fading down then wait for black
- g_graphics->waitForFade();
+ _graphics->waitForFade();
// if last screen was using a shading mask (see below)
if (_thisScreen.mask_flag) {
- rv = g_graphics->closeLightMask();
+ rv = _graphics->closeLightMask();
if (rv)
error("Driver Error %.8x", rv);
}
@@ -82,7 +74,7 @@
// for drivers: close the previous screen if one is open
if (_thisScreen.background_layer_id)
- g_graphics->closeBackgroundLayer();
+ _graphics->closeBackgroundLayer();
_thisScreen.background_layer_id = res;
_thisScreen.new_palette = new_palette;
@@ -92,7 +84,7 @@
// each cycle
// file points to 1st byte in the layer file
- file = res_man->openResource(_thisScreen.background_layer_id);
+ file = _resman->openResource(_thisScreen.background_layer_id);
screen_head = fetchScreenHeader(file);
@@ -104,7 +96,7 @@
debug(5, "res test layers=%d width=%d depth=%d", screen_head->noLayers, screen_head->width, screen_head->height);
//initialise the driver back buffer
- g_graphics->setLocationMetrics(screen_head->width, screen_head->height);
+ _graphics->setLocationMetrics(screen_head->width, screen_head->height);
if (screen_head->noLayers) {
for (int i = 0; i < screen_head->noLayers; i++) {
@@ -126,7 +118,7 @@
// using the screen size setup the scrolling variables
// if layer is larger than physical screen
- if (screen_head->width > g_graphics->_screenWide || screen_head->height > g_graphics->_screenDeep) {
+ if (screen_head->width > _graphics->_screenWide || screen_head->height > _graphics->_screenDeep) {
// switch on scrolling (2 means first time on screen)
_thisScreen.scroll_flag = 2;
@@ -141,9 +133,9 @@
// calc max allowed offsets (to prevent scrolling off edge) -
// MOVE TO NEW_SCREEN in GTM_CORE.C !!
// NB. min scroll offsets are both zero
- _thisScreen.max_scroll_offset_x = screen_head->width - g_graphics->_screenWide;
+ _thisScreen.max_scroll_offset_x = screen_head->width - _graphics->_screenWide;
// 'screenDeep' includes the menu's, so take away 80 pixels
- _thisScreen.max_scroll_offset_y = screen_head->height - (g_graphics->_screenDeep - (RDMENU_MENUDEEP * 2));
+ _thisScreen.max_scroll_offset_y = screen_head->height - (_graphics->_screenDeep - (RDMENU_MENUDEEP * 2));
} else {
// layer fits on physical screen - scrolling not required
_thisScreen.scroll_flag = 0; // switch off scrolling
@@ -153,7 +145,7 @@
// no inter-cycle scroll between new screens (see setScrollTarget in
// build display)
- g_graphics->resetRenderEngine();
+ _graphics->resetRenderEngine();
// these are the physical screen coords where the system
// will try to maintain George's actual feet coords
@@ -177,7 +169,7 @@
spriteInfo.data = fetchShadingMask(file);
spriteInfo.colourTable = 0;
- rv = g_graphics->openLightMask(&spriteInfo);
+ rv = _graphics->openLightMask(&spriteInfo);
if (rv)
error("Driver Error %.8x", rv);
@@ -189,7 +181,7 @@
}
// close the screen file
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
setUpBackgroundLayers();
@@ -211,7 +203,7 @@
// open resource & set pointers to headers
// file points to 1st byte in the layer file
- file = res_man->openResource(_thisScreen.background_layer_id);
+ file = _resman->openResource(_thisScreen.background_layer_id);
screen_head = fetchScreenHeader(file);
@@ -221,26 +213,26 @@
for (i = 0; i < 2; i++) {
if (screenLayerTable->bg_parallax[i])
- g_graphics->initialiseBackgroundLayer(fetchBackgroundParallaxLayer(file, i));
+ _graphics->initialiseBackgroundLayer(fetchBackgroundParallaxLayer(file, i));
else
- g_graphics->initialiseBackgroundLayer(NULL);
+ _graphics->initialiseBackgroundLayer(NULL);
}
// Normal backround layer
- g_graphics->initialiseBackgroundLayer(fetchBackgroundLayer(file));
+ _graphics->initialiseBackgroundLayer(fetchBackgroundLayer(file));
// Foreground parallax layers
for (i = 0; i < 2; i++) {
if (screenLayerTable->fg_parallax[i])
- g_graphics->initialiseBackgroundLayer(fetchForegroundParallaxLayer(file, i));
+ _graphics->initialiseBackgroundLayer(fetchForegroundParallaxLayer(file, i));
else
- g_graphics->initialiseBackgroundLayer(NULL);
+ _graphics->initialiseBackgroundLayer(NULL);
}
// close the screen file
- res_man->closeResource(_thisScreen.background_layer_id);
+ _resman->closeResource(_thisScreen.background_layer_id);
}
}
Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- logic.cpp 15 Nov 2003 09:37:59 -0000 1.32
+++ logic.cpp 16 Nov 2003 14:18:28 -0000 1.33
@@ -17,16 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
#include "sword2/defs.h"
-#include "sword2/build_display.h"
-#include "sword2/console.h"
-#include "sword2/debug.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/router.h" // for clearWalkGridList()
-#include "sword2/sound.h"
namespace Sword2 {
@@ -57,7 +51,7 @@
// processing on the current list
while (_pc != 0xffffffff) {
- head = (_standardHeader*) res_man->openResource(run_list);
+ head = (_standardHeader*) _vm->_resman->openResource(run_list);
if (head->fileType != RUN_LIST)
error("Logic_engine %d not a run_list", run_list);
@@ -71,7 +65,7 @@
// release the list again so it can float in memory - at this
// point not one thing should be locked
- res_man->closeResource(run_list);
+ _vm->_resman->closeResource(run_list);
debug(5, "%d", ID);
@@ -81,7 +75,7 @@
return 0;
}
- head = (_standardHeader*) res_man->openResource(ID);
+ head = (_standardHeader*) _vm->_resman->openResource(ID);
if (head->fileType != GAME_OBJECT)
error("Logic_engine %d not an object", ID);
@@ -127,7 +121,7 @@
raw_data_ad = (char*) head;
- far_head = (_standardHeader*) res_man->openResource(script / SIZE);
+ far_head = (_standardHeader*) _vm->_resman->openResource(script / SIZE);
if (far_head->fileType != GAME_OBJECT && far_head->fileType != SCREEN_MANAGER)
error("Logic_engine %d not a far object (its a %d)", script / SIZE, far_head->fileType);
@@ -142,7 +136,7 @@
ret = runScript(raw_script_ad, raw_data_ad, &_curObjectHub->script_pc[LEVEL]);
// close foreign object again
- res_man->closeResource(script / SIZE);
+ _vm->_resman->closeResource(script / SIZE);
// reset to us for service script
raw_script_ad = raw_data_ad;
@@ -198,7 +192,7 @@
// and that's it so close the object resource
- res_man->closeResource(ID);
+ _vm->_resman->closeResource(ID);
}
// leaving a room so remove all ids that must reboot correctly
@@ -336,17 +330,17 @@
if (_currentRunList) {
// open and lock in place
- game_object_list = (uint32 *) (res_man->openResource(_currentRunList) + sizeof(_standardHeader));
+ game_object_list = (uint32 *) (_vm->_resman->openResource(_currentRunList) + sizeof(_standardHeader));
Debug_Printf("Runlist number %d\n", _currentRunList);
for (int i = 0; game_object_list[i]; i++) {
- file_header = (_standardHeader *) res_man->openResource(game_object_list[i]);
+ file_header = (_standardHeader *) _vm->_resman->openResource(game_object_list[i]);
Debug_Printf("%d %s\n", game_object_list[i], file_header->name);
- res_man->closeResource(game_object_list[i]);
+ _vm->_resman->closeResource(game_object_list[i]);
}
- res_man->closeResource(_currentRunList);
+ _vm->_resman->closeResource(_currentRunList);
} else
Debug_Printf("No run list set\n");
}
@@ -427,7 +421,7 @@
void Logic::processKillList(void) {
for (uint32 i = 0; i < _kills; i++)
- res_man->remove(_objectKillList[i]);
+ _vm->_resman->remove(_objectKillList[i]);
_kills = 0;
}
Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/logic.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- logic.h 15 Nov 2003 09:37:59 -0000 1.20
+++ logic.h 16 Nov 2003 14:18:28 -0000 1.21
@@ -22,7 +22,6 @@
#ifndef _LOGIC
#define _LOGIC
-#include "sword2/driver/driver96.h"
#include "sword2/header.h"
#include "sword2/memory.h"
#include "sword2/router.h"
@@ -189,7 +188,7 @@
memset(_subjectList, 0, sizeof(_subjectList));
memset(_eventList, 0, sizeof(_eventList));
memset(_syncList, 0, sizeof(_syncList));
- _router = new Router();
+ _router = new Router(_vm);
setupOpcodes();
initStartMenu();
}
Index: maketext.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/maketext.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- maketext.cpp 11 Nov 2003 07:43:02 -0000 1.29
+++ maketext.cpp 16 Nov 2003 14:18:28 -0000 1.30
@@ -46,22 +46,12 @@
#define LAST_CHAR 255 // last character in character set
#define DUD 64 // the first "chequered flag" (dud) symbol in
// our character set is in the '@' position
-#include "stdafx.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/console.h"
-#include "sword2/debug.h"
-#include "sword2/defs.h" // for SPEECH_FONT_ID & CONSOLE_FONT_ID
-#include "sword2/header.h"
-#include "sword2/maketext.h"
-#include "sword2/memory.h"
-#include "sword2/protocol.h" // for fetchFrameHeader()
-#include "sword2/resman.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
+#include "sword2/defs.h"
namespace Sword2 {
-FontRenderer *fontRenderer;
-
// info for each line of words in the output text sprite
mem* FontRenderer::makeTextSprite(uint8 *sentence, uint16 maxWidth, uint8 pen, uint32 fontRes, uint8 border) {
@@ -94,7 +84,7 @@
// allocate memory for array of lineInfo structures
- line = memory->allocMemory(MAX_LINES * sizeof(LineInfo), MEM_locked, UID_temp);
+ line = _vm->_memory->allocMemory(MAX_LINES * sizeof(LineInfo), MEM_locked, UID_temp);
// get details of sentence breakdown into array of LineInfo structures
// and get the no of lines involved
@@ -107,7 +97,7 @@
textSprite = buildTextSprite(sentence, fontRes, pen, (LineInfo *) line->ad, noOfLines);
// free up the lineInfo array now
- memory->freeMemory(line);
+ _vm->_memory->freeMemory(line);
return textSprite;
}
@@ -220,7 +210,7 @@
// allocate memory for sprite, and lock it ready for use
// NB. 'textSprite' is the given pointer to the handle to be used
- textSprite = memory->allocMemory(sizeof(_frameHeader) + sizeOfSprite, MEM_locked, UID_text_sprite);
+ textSprite = _vm->_memory->allocMemory(sizeof(_frameHeader) + sizeOfSprite, MEM_locked, UID_text_sprite);
// the handle (*textSprite) now points to UNMOVABLE memory block
// set up the frame header
@@ -244,7 +234,7 @@
memset(linePtr, NO_COL, sizeOfSprite);
// open font file
- charSet = res_man->openResource(fontRes);
+ charSet = _vm->_resman->openResource(fontRes);
// fill sprite with characters, one line at a time
@@ -278,10 +268,10 @@
}
// close font file
- res_man->closeResource(fontRes);
+ _vm->_resman->closeResource(fontRes);
// unlock the sprite memory block, so it's movable
- memory->floatMemory(textSprite);
+ _vm->_memory->floatMemory(textSprite);
return textSprite;
}
@@ -295,14 +285,14 @@
uint16 width;
// open font file
- charSet = res_man->openResource(fontRes);
+ charSet = _vm->_resman->openResource(fontRes);
// move to approp. sprite (header)
charFrame = findChar(ch, charSet);
width = charFrame->width;
// close font file
- res_man->closeResource(fontRes);
+ _vm->_resman->closeResource(fontRes);
// return its width
return width;
@@ -317,14 +307,14 @@
uint16 height;
// open font file
- charSet = res_man->openResource(fontRes);
+ charSet = _vm->_resman->openResource(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->closeResource(fontRes);
+ _vm->_resman->closeResource(fontRes);
// return its height
return height;
@@ -525,7 +515,7 @@
spriteInfo.data = _blocList[j].text_mem->ad + sizeof(_frameHeader);
spriteInfo.colourTable = 0;
- rv = g_graphics->drawSprite(&spriteInfo);
+ rv = _vm->_graphics->drawSprite(&spriteInfo);
if (rv)
error("Driver Error %.8x in Print_text_blocs", rv);
}
@@ -538,7 +528,7 @@
if (_blocList[bloc_number].text_mem) {
// release the floating memory and mark it as free
- memory->freeMemory(_blocList[bloc_number].text_mem);
+ _vm->_memory->freeMemory(_blocList[bloc_number].text_mem);
_blocList[bloc_number].text_mem = 0;
} else {
// illegal kill - stop the system
@@ -564,7 +554,7 @@
uint8 language;
// open the text resource
- textFile = res_man->openResource(TEXT_RES);
+ textFile = _resman->openResource(TEXT_RES);
// If language is Polish or Finnish it requires alternate fonts.
// Otherwise, use regular fonts
@@ -603,10 +593,10 @@
// GERMAN: "Baphomet's Fluch II"
// default: "Some game or other, part 86"
- g_graphics->setWindowName((char *) textLine);
+ _graphics->setWindowName((char *) textLine);
// now ok to close the text file
- res_man->closeResource(TEXT_RES);
+ _resman->closeResource(TEXT_RES);
}
// called from the above function, and also from console.cpp
Index: maketext.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/maketext.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- maketext.h 8 Nov 2003 15:47:51 -0000 1.8
+++ maketext.h 16 Nov 2003 14:18:28 -0000 1.9
@@ -57,7 +57,6 @@
#ifndef _MAKETEXT_H
#define _MAKETEXT_H
-#include "sword2/memory.h"
#include "sword2/debug.h"
// Output colour for character border - should be be black but note that we
@@ -108,6 +107,7 @@
class FontRenderer {
private:
+ Sword2Engine *_vm;
TextBloc _blocList[MAX_text_blocs];
// layout variables - these used to be defines, but now we're dealing
@@ -128,7 +128,7 @@
void copyChar(_frameHeader *charPtr, uint8 *spritePtr, uint16 spriteWidth, uint8 pen);
public:
- FontRenderer() {
+ FontRenderer(Sword2Engine *vm) : _vm(vm) {
for (int i = 0; i < MAX_text_blocs; i++)
_blocList[i].text_mem = NULL;
}
@@ -140,8 +140,6 @@
uint32 buildNewBloc(uint8 *ascii, int16 x, int16 y, uint16 width, uint8 pen, uint32 type, uint32 fontRes, uint8 justification);
};
-
-extern FontRenderer *fontRenderer;
} // End of namespace Sword2
Index: mem_view.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mem_view.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mem_view.cpp 3 Nov 2003 07:47:41 -0000 1.20
+++ mem_view.cpp 16 Nov 2003 14:18:28 -0000 1.21
@@ -17,19 +17,11 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/build_display.h"
-#include "sword2/console.h"
-#include "sword2/header.h"
-#include "sword2/memory.h"
-#include "sword2/resman.h"
namespace Sword2 {
-// has to be global because a local in Fetch_mem_owner is destroyed on exit
-char buf[50];
-
void MemoryManager::displayMemory(void) {
int pass, found_end, k, j, free = 0;
_standardHeader *file_header;
@@ -44,9 +36,9 @@
j = _baseMemBlock;
do {
if (_memList[j].uid < 65536) {
- file_header = (_standardHeader*) res_man->openResource(_memList[j].uid);
+ file_header = (_standardHeader*) _vm->_resman->openResource(_memList[j].uid);
// close immediately so give a true count
- res_man->closeResource(_memList[j].uid);
+ _vm->_resman->closeResource(_memList[j].uid);
debug(5, "view %d", _memList[j].uid);
@@ -73,10 +65,10 @@
_memList[j].size / 1024,
(_memList[j].size * 100) / _totalFreeMemory,
_memList[j].uid,
- res_man->fetchCluster(_memList[j].uid),
+ _vm->_resman->fetchCluster(_memList[j].uid),
file_header->name,
- res_man->fetchAge(_memList[j].uid),
- res_man->fetchCount(_memList[j].uid));
+ _vm->_resman->fetchAge(_memList[j].uid),
+ _vm->_resman->fetchCount(_memList[j].uid));
} else
Debug_Printf(" %d is an illegal resource\n", _memList[j].uid);
} else {
@@ -100,6 +92,8 @@
}
const char *MemoryManager::fetchOwner(uint32 uid) {
+ static char buf[50];
+
switch (uid) {
case UID_memman:
return "MEMMAN";
@@ -160,7 +154,7 @@
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->fetchUsage() / 1024));
+ percent, (_vm->_resman->fetchUsage() / 1024));
}
} // End of namespace Sword2
Index: memory.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/memory.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- memory.cpp 10 Nov 2003 07:52:15 -0000 1.17
+++ memory.cpp 16 Nov 2003 14:18:28 -0000 1.18
@@ -34,21 +34,16 @@
// MemMan v1.1
-#include "stdafx.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/debug.h"
-#include "sword2/memory.h"
-#include "sword2/resman.h"
+#include "common/stdafx.h"
+#include "sword2/sword2.h"
namespace Sword2 {
-MemoryManager *memory;
-
#define MEMORY_POOL (1024 * 12000)
// #define MEMDEBUG 1
-MemoryManager::MemoryManager(void) {
+MemoryManager::MemoryManager(Sword2Engine *vm) : _vm(vm) {
uint32 j;
uint8 *memory_base;
@@ -56,12 +51,10 @@
_totalFreeMemory = MEMORY_POOL;
- // malloc memory and adjust for long boundaries
memory_base = (uint8 *) malloc(_totalFreeMemory);
- if (!memory_base) { //could not grab the memory
- error("Init_memory_manager() couldn't malloc %d bytes", _totalFreeMemory);
- }
+ if (!memory_base)
+ error("MemoryManager: couldn't malloc %d bytes", _totalFreeMemory);
// the original malloc address
_freeMemman = memory_base;
@@ -501,7 +494,7 @@
while (virtualDefrag(size)) {
// trash the oldest closed resource
- if (!res_man->helpTheAgedOut()) {
+ if (!_vm->_resman->helpTheAgedOut()) {
error("alloc ran out of memory: size=%d type=%d unique_id=%d", size, type, unique_id);
}
}
Index: memory.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/memory.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- memory.h 10 Nov 2003 07:52:15 -0000 1.11
+++ memory.h 16 Nov 2003 14:18:28 -0000 1.12
@@ -66,6 +66,8 @@
class MemoryManager {
private:
+ Sword2Engine *_vm;
+
// Address of init malloc to be freed later
uint8 *_freeMemman;
@@ -92,7 +94,7 @@
mem _memList[MAX_mem_blocks];
uint32 _baseMemBlock;
- MemoryManager(void);
+ MemoryManager(Sword2Engine *vm);
~MemoryManager(void);
int32 ptrToInt(const uint8 *p);
@@ -107,8 +109,6 @@
void displayMemory(void);
void memoryString(char *string);
};
-
-extern MemoryManager *memory;
} // End of namespace Sword2
Index: mouse.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- mouse.cpp 15 Nov 2003 09:37:59 -0000 1.43
+++ mouse.cpp 16 Nov 2003 14:18:28 -0000 1.44
@@ -17,23 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/build_display.h"
-#include "sword2/console.h"
-#include "sword2/controls.h"
+#include "common/stdafx.h"
+#include "sword2/sword2.h"
#include "sword2/defs.h"
-#include "sword2/icons.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/layers.h"
-#include "sword2/maketext.h"
-#include "sword2/mouse.h"
-#include "sword2/object.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/sound.h"
-#include "sword2/sword2.h"
namespace Sword2 {
@@ -180,9 +167,9 @@
for (int i = 0; i < ARRAYSIZE(icon_list); i++) {
if (i != hit) {
- icon = res_man->openResource(icon_list[i]) + sizeof(_standardHeader);
+ icon = _resman->openResource(icon_list[i]) + sizeof(_standardHeader);
_graphics->setMenuIcon(RDMENU_TOP, i, icon);
- res_man->closeResource(icon_list[i]);
+ _resman->closeResource(icon_list[i]);
}
}
@@ -211,19 +198,19 @@
switch (hit) {
case 0:
- gui->optionControl();
+ _gui->optionControl();
break;
case 1:
- gui->quitControl();
+ _gui->quitControl();
break;
case 2:
- gui->saveControl();
+ _gui->saveControl();
break;
case 3:
- gui->restoreControl();
+ _gui->restoreControl();
break;
case 4:
- gui->restartControl();
+ _gui->restartControl();
break;
}
@@ -773,8 +760,8 @@
_mousePointerRes = res;
if (res) {
- icon = res_man->openResource(res) + sizeof(_standardHeader);
- len = res_man->_resList[res]->size - sizeof(_standardHeader);
+ icon = _resman->openResource(res) + sizeof(_standardHeader);
+ len = _resman->_resList[res]->size - sizeof(_standardHeader);
// don't pulse the normal pointer - just do the regular anim
// loop
@@ -784,7 +771,7 @@
else
_graphics->setMouseAnim(icon, len, RDMOUSE_FLASH);
- res_man->closeResource(res);
+ _resman->closeResource(res);
} else {
// blank cursor
_graphics->setMouseAnim(NULL, 0, 0);
@@ -798,12 +785,12 @@
_realLuggageItem = res;
if (res) {
- icon = res_man->openResource(res) + sizeof(_standardHeader);
- len = res_man->_resList[res]->size - sizeof(_standardHeader);
+ icon = _resman->openResource(res) + sizeof(_standardHeader);
+ len = _resman->_resList[res]->size - sizeof(_standardHeader);
_graphics->setLuggageAnim(icon, len);
- res_man->closeResource(res);
+ _resman->closeResource(res);
} else
_graphics->setLuggageAnim(NULL, 0);
}
@@ -862,7 +849,7 @@
int16 xOffset, yOffset;
uint8 justification;
- if (!gui->_pointerTextSelected || !text_id)
+ if (!_gui->_pointerTextSelected || !text_id)
return;
// Check what the pointer is, to set offsets correctly for text
@@ -992,12 +979,12 @@
local_text = text_id & 0xffff;
// open text file & get the line
- text = fetchTextLine(res_man->openResource(text_res), local_text);
+ text = fetchTextLine(_resman->openResource(text_res), local_text);
// 'text+2' to skip the first 2 bytes which form the
// line reference number
- _pointerTextBlocNo = fontRenderer->buildNewBloc(
+ _pointerTextBlocNo = _fontRenderer->buildNewBloc(
text + 2, _input->_mouseX + xOffset,
_input->_mouseY + yOffset,
POINTER_TEXT_WIDTH, POINTER_TEXT_PEN,
@@ -1005,12 +992,12 @@
_speechFontId, justification);
// now ok to close the text file
- res_man->closeResource(text_res);
+ _resman->closeResource(text_res);
}
void Sword2Engine::clearPointerText(void) {
if (_pointerTextBlocNo) {
- fontRenderer->killTextBloc(_pointerTextBlocNo);
+ _fontRenderer->killTextBloc(_pointerTextBlocNo);
_pointerTextBlocNo = 0;
}
}
@@ -1090,12 +1077,12 @@
// dont hide menu in conversations
if (TALK_FLAG == 0)
- g_graphics->hideMenu(RDMENU_BOTTOM);
+ _vm->_graphics->hideMenu(RDMENU_BOTTOM);
if (_vm->_mouseMode == MOUSE_system_menu) {
// close menu
_vm->_mouseMode = MOUSE_normal;
- g_graphics->hideMenu(RDMENU_TOP);
+ _vm->_graphics->hideMenu(RDMENU_TOP);
}
// script continue
@@ -1138,7 +1125,7 @@
}
// if mouse is over menu area
- if (g_input->_mouseY > 399) {
+ if (_vm->_input->_mouseY > 399) {
if (_vm->_mouseMode != MOUSE_holding) {
// VITAL - reset things & rebuild the menu
_vm->_mouseMode = MOUSE_normal;
@@ -1157,7 +1144,7 @@
// testing logic scripts by simulating an instant Save &
// Restore
- g_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, white, RDPAL_INSTANT);
// stops all fx & clears the queue - eg. when leaving a
// location
@@ -1167,9 +1154,9 @@
// Trash all object resources so they load in fresh & restart
// their logic scripts
- res_man->killAllObjects(false);
+ _vm->_resman->killAllObjects(false);
- g_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
+ _vm->_graphics->setPalette(0, 1, black, RDPAL_INSTANT);
}
return IR_CONT;
@@ -1184,7 +1171,7 @@
// params: 0 pointer to Object_mouse or 0 for no write to mouse
// list
- _vm->registerMouse((Object_mouse *) memory->intToPtr(params[0]));
+ _vm->registerMouse((Object_mouse *) _vm->_memory->intToPtr(params[0]));
return IR_CONT;
}
@@ -1209,7 +1196,7 @@
int32 Logic::fnInitFloorMouse(int32 *params) {
// params: 0 pointer to object's mouse structure
- Object_mouse *ob_mouse = (Object_mouse *) memory->intToPtr(params[0]);
+ Object_mouse *ob_mouse = (Object_mouse *) _vm->_memory->intToPtr(params[0]);
// floor is always lowest priority
@@ -1228,7 +1215,7 @@
int32 Logic::fnSetScrollLeftMouse(int32 *params) {
// params: 0 pointer to object's mouse structure
- Object_mouse *ob_mouse = (Object_mouse *) memory->intToPtr(params[0]);
+ Object_mouse *ob_mouse = (Object_mouse *) _vm->_memory->intToPtr(params[0]);
// Highest priority
@@ -1252,11 +1239,11 @@
int32 Logic::fnSetScrollRightMouse(int32 *params) {
// params: 0 pointer to object's mouse structure
- Object_mouse *ob_mouse = (Object_mouse *) memory->intToPtr(params[0]);
+ Object_mouse *ob_mouse = (Object_mouse *) _vm->_memory->intToPtr(params[0]);
// Highest priority
- ob_mouse->x1 = _vm->_thisScreen.scroll_offset_x + g_graphics->_screenWide - SCROLL_MOUSE_WIDTH;
+ ob_mouse->x1 = _vm->_thisScreen.scroll_offset_x + _vm->_graphics->_screenWide - SCROLL_MOUSE_WIDTH;
ob_mouse->y1 = 0;
ob_mouse->x2 = _vm->_thisScreen.screen_wide - 1;
ob_mouse->y2 = _vm->_thisScreen.screen_deep - 1;
@@ -1293,7 +1280,7 @@
int32 Logic::fnRemoveChooser(int32 *params) {
// params: none
- g_graphics->hideMenu(RDMENU_BOTTOM);
+ _vm->_graphics->hideMenu(RDMENU_BOTTOM);
return IR_CONT;
}
Index: mouse.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/mouse.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mouse.h 12 Nov 2003 08:21:18 -0000 1.10
+++ mouse.h 16 Nov 2003 14:18:28 -0000 1.11
@@ -20,8 +20,6 @@
#ifndef MOUSE_H
#define MOUSE_H
-#include "sword2/object.h"
-
#define TOTAL_mouse_list 50
namespace Sword2 {
Index: protocol.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/protocol.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- protocol.cpp 3 Nov 2003 07:47:41 -0000 1.19
+++ protocol.cpp 16 Nov 2003 14:18:28 -0000 1.20
@@ -17,14 +17,8 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
-#include "sword2/defs.h"
-#include "sword2/header.h"
-#include "sword2/memory.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
namespace Sword2 {
@@ -223,8 +217,8 @@
uint8 *Sword2Engine::fetchObjectName(int32 resourceId) {
_standardHeader *header;
- header = (_standardHeader *) res_man->openResource(resourceId);
- res_man->closeResource(resourceId);
+ header = (_standardHeader *) _resman->openResource(resourceId);
+ _resman->closeResource(resourceId);
// note this pointer is no longer valid, but it should be ok until
// another resource is opened!
Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/resman.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- resman.cpp 15 Nov 2003 09:37:59 -0000 1.71
+++ resman.cpp 16 Nov 2003 14:18:28 -0000 1.72
@@ -17,23 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
+#include "common/file.h"
#include "sword2/sword2.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/build_display.h"
-#include "sword2/console.h"
-#include "sword2/debug.h"
#include "sword2/defs.h"
-#include "sword2/header.h"
-#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/maketext.h"
-#include "sword2/memory.h"
-#include "sword2/mouse.h" // for system setMouse & setLuggage routines
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/sound.h" // for clearFxQueue() called from cacheNewCluster()
-#include "sword2/router.h"
namespace Sword2 {
@@ -53,8 +40,6 @@
#define BUFFERSIZE 4096
-ResourceManager *res_man; // declare the object global
-
// ---------------------------------------------------------------------------
//
//
@@ -107,7 +92,7 @@
end = file.size();
//get some space for the incoming resource file - soon to be trashed
- temp = memory->allocMemory(end, MEM_locked, UID_temp);
+ temp = _vm->_memory->allocMemory(end, MEM_locked, UID_temp);
if (file.read(temp->ad, end) != end) {
file.close();
@@ -191,6 +176,8 @@
_cdTab[j] = cdInf[i].cd;
}
+ delete cdInf;
+
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]);
@@ -208,7 +195,7 @@
}
_resTime = 1; //cannot start at 0
- memory->freeMemory(temp); //get that memory back
+ _vm->_memory->freeMemory(temp); //get that memory back
}
ResourceManager::~ResourceManager(void) {
@@ -487,7 +474,7 @@
// 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] = memory->allocMemory(len, MEM_locked, res);
+ _resList[res] = _vm->_memory->allocMemory(len, MEM_locked, res);
// now load the file
// hurray, load it in.
@@ -512,7 +499,7 @@
// pass the address of the mem & lock the memory too
// might be locked already (if count > 1)
- memory->lockMemory(_resList[res]);
+ _vm->_memory->lockMemory(_resList[res]);
return (uint8 *) _resList[res]->ad;
}
@@ -592,7 +579,7 @@
//if noone has the file open then unlock and allow to float
if (!_count[res]) {
// pass the address of the mem
- memory->floatMemory(_resList[res]);
+ _vm->_memory->floatMemory(_resList[res]);
}
}
@@ -682,7 +669,7 @@
// trash this old resource
_age[oldest_res] = 0; // effectively gone from _resList
- memory->freeMemory(_resList[oldest_res]); // release the memory too
+ _vm->_memory->freeMemory(_resList[oldest_res]); // release the memory too
return _resList[oldest_res]->size; // return bytes freed
}
@@ -817,7 +804,7 @@
if (!_count[res]) {
if (_age[res]) {
_age[res] = 0; // effectively gone from _resList
- memory->freeMemory(_resList[res]); // release the memory too
+ _vm->_memory->freeMemory(_resList[res]); // release the memory too
Debug_Printf("Trashed %d\n", res);
} else
Debug_Printf("%d not in memory\n", res);
@@ -828,7 +815,7 @@
void ResourceManager::remove(uint32 res) {
if (_age[res]) {
_age[res] = 0; // effectively gone from _resList
- memory->freeMemory(_resList[res]); // release the memory too
+ _vm->_memory->freeMemory(_resList[res]); // release the memory too
debug(5, " - Trashing %d", res);
} else
debug(5, "remove(%d) not even in memory!", res);
@@ -841,16 +828,16 @@
int j;
uint32 res;
- j = memory->_baseMemBlock;
+ j = _vm->_memory->_baseMemBlock;
do {
- if (memory->_memList[j].uid < 65536) { // a resource
- res = memory->_memList[j].uid;
+ if (_vm->_memory->_memList[j].uid < 65536) { // a resource
+ res = _vm->_memory->_memList[j].uid;
_age[res] = 0; // effectively gone from _resList
- memory->freeMemory(_resList[res]); // release the memory too
+ _vm->_memory->freeMemory(_resList[res]); // release the memory too
}
- j = memory->_memList[j].child;
+ j = _vm->_memory->_memList[j].child;
} while (j != -1);
}
@@ -864,11 +851,11 @@
uint32 nuked = 0;
_standardHeader *header;
- j = memory->_baseMemBlock;
+ j = _vm->_memory->_baseMemBlock;
do {
- if (memory->_memList[j].uid < 65536) { // a resource
- res = memory->_memList[j].uid;
+ if (_vm->_memory->_memList[j].uid < 65536) { // a resource
+ res = _vm->_memory->_memList[j].uid;
// not the global vars which are assumed to be open in
// memory & not the player object!
@@ -877,7 +864,7 @@
closeResource(res);
_age[res] = 0; // effectively gone from _resList
- memory->freeMemory(_resList[res]); // release the memory too
+ _vm->_memory->freeMemory(_resList[res]); // release the memory too
nuked++;
// if this was called from the console,
@@ -887,7 +874,7 @@
}
}
}
- j = memory->_memList[j].child;
+ j = _vm->_memory->_memList[j].child;
} while (j != -1);
// if this was called from the console
@@ -914,11 +901,11 @@
uint32 nuked = 0;
_standardHeader *header;
- j = memory->_baseMemBlock;
+ j = _vm->_memory->_baseMemBlock;
do {
- if (memory->_memList[j].uid < 65536) { // a resource
- res = memory->_memList[j].uid;
+ if (_vm->_memory->_memList[j].uid < 65536) { // a resource
+ res = _vm->_memory->_memList[j].uid;
//not the global vars which are assumed to be open in
// memory & not the player object!
if (res != 1 && res != CUR_PLAYER_ID) {
@@ -927,7 +914,7 @@
if (header->fileType == GAME_OBJECT) {
_age[res] = 0; // effectively gone from _resList
- memory->freeMemory(_resList[res]); // release the memory too
+ _vm->_memory->freeMemory(_resList[res]); // release the memory too
nuked++;
// if this was called from the console
@@ -938,7 +925,7 @@
}
}
}
- j = memory->_memList[j].child;
+ j = _vm->_memory->_memList[j].child;
} while (j != -1);
// if this was called from the console
@@ -974,15 +961,15 @@
_keyboardEvent ke;
_mouseEvent *me;
- me = g_input->mouseEvent();
+ me = _vm->_input->mouseEvent();
if (me && (me->buttons & (RD_LEFTBUTTONDOWN | RD_RIGHTBUTTONDOWN)))
break;
- if (g_input->readKey(&ke) == RD_OK)
+ if (_vm->_input->readKey(&ke) == RD_OK)
break;
- g_graphics->updateDisplay();
- g_system->delay_msecs(50);
+ _vm->_graphics->updateDisplay();
+ _vm->_system->delay_msecs(50);
}
_vm->removeMsg();
Index: resman.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/resman.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- resman.h 13 Nov 2003 07:59:52 -0000 1.15
+++ resman.h 16 Nov 2003 14:18:28 -0000 1.16
@@ -20,8 +20,6 @@
#ifndef RESMAN_H
#define RESMAN_H
-#include "sword2/memory.h"
-
namespace Sword2 {
#define MAX_res_files 20
@@ -101,8 +99,6 @@
char _resourceFiles[MAX_res_files][20];
uint8 _cdTab[MAX_res_files]; // Location of each cluster.
};
-
-extern ResourceManager *res_man; // declare the object global
} // End of namespace Sword2
Index: router.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/router.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- router.cpp 11 Nov 2003 07:43:02 -0000 1.30
+++ router.cpp 16 Nov 2003 14:18:28 -0000 1.31
@@ -73,18 +73,9 @@
*
****************************************************************************/
-#include "stdafx.h"
-#include "sword2/driver/driver96.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
-#include "sword2/debug.h"
#include "sword2/defs.h"
-#include "sword2/header.h"
-#include "sword2/interpreter.h"
-#include "sword2/memory.h"
-#include "sword2/object.h"
-#include "sword2/resman.h"
-#include "sword2/router.h"
namespace Sword2 {
@@ -115,7 +106,7 @@
if (_routeSlots[slotNo])
freeRouteMem();
- _routeSlots[slotNo] = memory->allocMemory(sizeof(_walkData) * O_WALKANIM_SIZE, MEM_locked, UID_walk_anim);
+ _routeSlots[slotNo] = _vm->_memory->allocMemory(sizeof(_walkData) * O_WALKANIM_SIZE, MEM_locked, UID_walk_anim);
// 12000 bytes were used for this in Sword1 mega compacts, based on
// 20 bytes per '_walkData' frame
@@ -133,14 +124,14 @@
_walkData* Router::lockRouteMem(void) {
uint8 slotNo = returnSlotNo(ID);
- memory->lockMemory(_routeSlots[slotNo]);
+ _vm->_memory->lockMemory(_routeSlots[slotNo]);
return (_walkData *) _routeSlots[slotNo]->ad;
}
void Router::floatRouteMem(void) {
uint8 slotNo = returnSlotNo(ID);
- memory->floatMemory(_routeSlots[slotNo]);
+ _vm->_memory->floatMemory(_routeSlots[slotNo]);
}
void Router::freeRouteMem(void) {
@@ -148,7 +139,7 @@
// free the mem block pointed to from this entry of _routeSlots[]
- memory->freeMemory(_routeSlots[slotNo]);
+ _vm->_memory->freeMemory(_routeSlots[slotNo]);
_routeSlots[slotNo] = NULL;
}
@@ -157,7 +148,7 @@
if (_routeSlots[i]) {
// free the mem block pointed to from this entry of
// _routeSlots[]
- memory->freeMemory(_routeSlots[i]);
+ _vm->_memory->freeMemory(_routeSlots[i]);
_routeSlots[i] = NULL;
}
}
@@ -2530,7 +2521,7 @@
// lines
for (i = 0; i < _nbars; i++)
- g_graphics->drawLine(_bars[i].x1, _bars[i].y1, _bars[i].x2, _bars[i].y2, 254);
+ _vm->_graphics->drawLine(_bars[i].x1, _bars[i].y1, _bars[i].x2, _bars[i].y2, 254);
// nodes
@@ -2540,8 +2531,8 @@
}
void Router::plotCross(int16 x, int16 y, uint8 colour) {
- g_graphics->drawLine(x - 1, y - 1, x + 1, y + 1, colour);
- g_graphics->drawLine(x + 1, y - 1, x - 1, y + 1, colour);
+ _vm->_graphics->drawLine(x - 1, y - 1, x + 1, y + 1, colour);
+ _vm->_graphics->drawLine(x + 1, y - 1, x - 1, y + 1, colour);
}
void Router::loadWalkGrid(void) {
@@ -2559,7 +2550,7 @@
for (int i = 0; i < MAX_WALKGRIDS; i++) {
if (_walkGridList[i]) {
// open walk grid file
- fPolygrid = res_man->openResource(_walkGridList[i]);
+ fPolygrid = _vm->_resman->openResource(_walkGridList[i]);
fPolygrid += sizeof(_standardHeader);
memmove((uint8 *) &floorHeader, fPolygrid, sizeof(_walkGridHeader));
fPolygrid += sizeof(_walkGridHeader);
@@ -2601,7 +2592,7 @@
}
// close walk grid file
- res_man->closeResource(_walkGridList[i]);
+ _vm->_resman->closeResource(_walkGridList[i]);
// increment counts of total bars & nodes in whole
// walkgrid
Index: router.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/router.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- router.h 8 Nov 2003 15:47:51 -0000 1.11
+++ router.h 16 Nov 2003 14:18:28 -0000 1.12
@@ -20,9 +20,6 @@
#ifndef _ROUTER_H
#define _ROUTER_H
-#include "sword2/memory.h"
-#include "sword2/object.h"
-
// This used to be a variable, but it was never set. Actually, it wasn't even
// initialised!
//
@@ -31,6 +28,8 @@
//
// #define FORCE_SLIDY
+#include "sword2/object.h"
+
namespace Sword2 {
#if !defined(__GNUC__)
@@ -103,6 +102,8 @@
class Router {
private:
+ Sword2Engine *_vm;
+
// stores pointers to mem blocks containing routes created & used by
// megas (NULL if slot not in use)
mem *_routeSlots[TOTAL_ROUTE_SLOTS];
@@ -214,9 +215,9 @@
void plotCross(int16 x, int16 y, uint8 colour);
public:
- Router() :
- _nExtraBars(0), _nExtraNodes(0), _diagonalx(0),
- _diagonaly(0) {
+ Router(Sword2Engine *vm)
+ : _vm(vm), _nExtraBars(0), _nExtraNodes(0), _diagonalx(0),
+ _diagonaly(0) {
memset(_routeSlots, 0, sizeof(_routeSlots));
memset(_bars, 0, sizeof(_bars));
memset(_node, 0, sizeof(_node));
Index: save_rest.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/save_rest.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- save_rest.cpp 15 Nov 2003 09:37:59 -0000 1.39
+++ save_rest.cpp 16 Nov 2003 14:18:28 -0000 1.40
@@ -26,21 +26,10 @@
//
// ---------------------------------------------------------------------------
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/console.h"
#include "sword2/defs.h"
-#include "sword2/interpreter.h" // for IR_CONT, etc
-#include "sword2/layers.h"
-#include "sword2/logic.h"
-#include "sword2/memory.h"
-#include "sword2/object.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/router.h"
-#include "sword2/save_rest.h"
-#include "sword2/sound.h"
+#include "sword2/interpreter.h"
namespace Sword2 {
@@ -105,7 +94,7 @@
// allocate the savegame buffer
bufferSize = findBufferSize();
- saveBufferMem = memory->allocMemory(bufferSize, MEM_locked, UID_savegame_buffer);
+ saveBufferMem = _memory->allocMemory(bufferSize, MEM_locked, UID_savegame_buffer);
fillSaveBuffer(saveBufferMem, bufferSize, desc);
@@ -116,7 +105,7 @@
// free the buffer
- memory->freeMemory(saveBufferMem);
+ _memory->freeMemory(saveBufferMem);
return errorCode;
}
@@ -125,38 +114,38 @@
uint32 Sword2Engine::findBufferSize(void) {
// size of savegame header + size of global variables
- return sizeof(g_header) + res_man->fetchLen(1);
+ return sizeof(_saveGameHeader) + _resman->fetchLen(1);
}
void Sword2Engine::fillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
uint8 *varsRes;
- // set up the g_header
+ // set up the _saveGameHeader
// 'checksum' gets filled in last of all
// player's description of savegame
- strcpy(g_header.description, (char *) desc);
+ strcpy(_saveGameHeader.description, (char *) desc);
// length of global variables resource
- g_header.varLength = res_man->fetchLen(1);
+ _saveGameHeader.varLength = _resman->fetchLen(1);
// resource id of current screen file
- g_header.screenId = _thisScreen.background_layer_id;
+ _saveGameHeader.screenId = _thisScreen.background_layer_id;
// resource id of current run-list
- g_header.runListId = _logic->getRunList();
+ _saveGameHeader.runListId = _logic->getRunList();
// those scroll position control things
- g_header.feet_x = _thisScreen.feet_x;
- g_header.feet_y = _thisScreen.feet_y;
+ _saveGameHeader.feet_x = _thisScreen.feet_x;
+ _saveGameHeader.feet_y = _thisScreen.feet_y;
// id of currently looping music (or zero)
- g_header.music_id = _loopingMusicId;
+ _saveGameHeader.music_id = _loopingMusicId;
// object hub
- memcpy(&g_header.player_hub, res_man->openResource(CUR_PLAYER_ID) + sizeof(_standardHeader), sizeof(_object_hub));
- res_man->closeResource(CUR_PLAYER_ID);
+ memcpy(&_saveGameHeader.player_hub, _resman->openResource(CUR_PLAYER_ID) + sizeof(_standardHeader), sizeof(_object_hub));
+ _resman->closeResource(CUR_PLAYER_ID);
// logic, graphic & mega structures
// copy the 4 essential player object structures into the header
@@ -165,42 +154,42 @@
// copy the header to the buffer
#ifdef SCUMM_BIG_ENDIAN
- convertHeaderEndian(g_header);
+ convertHeaderEndian(_saveGameHeader);
#endif
// copy the header to the savegame buffer
- memcpy(buffer->ad, &g_header, sizeof(g_header));
+ memcpy(buffer->ad, &_saveGameHeader, sizeof(_saveGameHeader));
// copy the global variables to the buffer
// open variables resource
- varsRes = res_man->openResource(1);
+ varsRes = _resman->openResource(1);
// copy that to the buffer, following the header
- memcpy(buffer->ad + sizeof(g_header), varsRes, FROM_LE_32(g_header.varLength));
+ memcpy(buffer->ad + sizeof(_saveGameHeader), varsRes, FROM_LE_32(_saveGameHeader.varLength));
#ifdef SCUMM_BIG_ENDIAN
- uint32 *globalVars = (uint32 *) (buffer->ad + sizeof(g_header) + sizeof(_standardHeader));
- const uint numVars = (FROM_LE_32(g_header.varLength) - sizeof(_standardHeader)) / 4;
+ uint32 *globalVars = (uint32 *) (buffer->ad + sizeof(_saveGameHeader) + sizeof(_standardHeader));
+ const uint numVars = (FROM_LE_32(_saveGameHeader.varLength) - sizeof(_standardHeader)) / 4;
for (uint i = 0; i < numVars; i++)
globalVars[i] = SWAP_BYTES_32(globalVars[i]);
#endif
// close variables resource
- res_man->closeResource(1);
+ _resman->closeResource(1);
// set the checksum & copy that to the buffer
- g_header.checksum = TO_LE_32(calcChecksum((buffer->ad) + sizeof(g_header.checksum), size - sizeof(g_header.checksum)));
- memcpy(buffer->ad, &g_header.checksum, sizeof(g_header.checksum));
+ _saveGameHeader.checksum = TO_LE_32(calcChecksum((buffer->ad) + sizeof(_saveGameHeader.checksum), size - sizeof(_saveGameHeader.checksum)));
+ memcpy(buffer->ad, &_saveGameHeader.checksum, sizeof(_saveGameHeader.checksum));
}
uint32 Sword2Engine::saveData(uint16 slotNo, uint8 *buffer, uint32 bufferSize) {
char saveFileName[MAX_FILENAME_LEN];
uint32 itemsWritten;
SaveFile *out;
- SaveFileManager *mgr = g_system->get_savefile_manager();
+ SaveFileManager *mgr = _system->get_savefile_manager();
// construct filename
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
@@ -235,7 +224,7 @@
// allocate the savegame buffer
bufferSize = findBufferSize();
- saveBufferMem = memory->allocMemory(bufferSize, MEM_locked, UID_savegame_buffer);
+ saveBufferMem = _memory->allocMemory(bufferSize, MEM_locked, UID_savegame_buffer);
// read the savegame file into our buffer
@@ -253,7 +242,7 @@
// loading in the new screen & runlist
} else {
// because restoreFromBuffer would have freed it
- memory->freeMemory(saveBufferMem);
+ _memory->freeMemory(saveBufferMem);
}
return errorCode;
@@ -262,7 +251,7 @@
uint32 Sword2Engine::restoreData(uint16 slotNo, uint8 *buffer, uint32 bufferSize) {
char saveFileName[MAX_FILENAME_LEN];
SaveFile *in;
- SaveFileManager *mgr = g_system->get_savefile_manager();
+ SaveFileManager *mgr = _system->get_savefile_manager();
uint32 itemsRead;
// construct filename
@@ -306,16 +295,16 @@
int32 pars[2];
// get a copy of the header from the savegame buffer
- memcpy(&g_header, buffer->ad, sizeof(g_header));
+ memcpy(&_saveGameHeader, buffer->ad, sizeof(_saveGameHeader));
#ifdef SCUMM_BIG_ENDIAN
- convertHeaderEndian(g_header);
+ convertHeaderEndian(_saveGameHeader);
#endif
// Calc checksum & check that aginst the value stored in the header
- if (g_header.checksum != calcChecksum(buffer->ad + sizeof(g_header.checksum), size - sizeof(g_header.checksum))) {
- memory->freeMemory(buffer);
+ if (_saveGameHeader.checksum != calcChecksum(buffer->ad + sizeof(_saveGameHeader.checksum), size - sizeof(_saveGameHeader.checksum))) {
+ _memory->freeMemory(buffer);
// error: incompatible save-data - can't use!
return SR_ERR_INCOMPATIBLE;
@@ -329,8 +318,8 @@
// shorter than the current expected length
// if header contradicts actual current size of global variables
- if (g_header.varLength != res_man->fetchLen(1)) {
- memory->freeMemory(buffer);
+ if (_saveGameHeader.varLength != _resman->fetchLen(1)) {
+ _memory->freeMemory(buffer);
// error: incompatible save-data - can't use!
return SR_ERR_INCOMPATIBLE;
@@ -340,7 +329,7 @@
// trash all resources from memory except player object & global
// variables
- res_man->killAll(false);
+ _resman->killAll(false);
// clean out the system kill list (no more objects to kill)
_logic->resetKillList();
@@ -348,9 +337,9 @@
// get player character data from savegame buffer
// object hub is just after the standard header
- memcpy(res_man->openResource(CUR_PLAYER_ID) + sizeof(_standardHeader), &g_header.player_hub, sizeof(_object_hub));
+ memcpy(_resman->openResource(CUR_PLAYER_ID) + sizeof(_standardHeader), &_saveGameHeader.player_hub, sizeof(_object_hub));
- res_man->closeResource(CUR_PLAYER_ID);
+ _resman->closeResource(CUR_PLAYER_ID);
// fill in the 4 essential player object structures from the header
putPlayerStructures();
@@ -358,27 +347,27 @@
// get variables resource from the savegame buffer
// open variables resource
- varsRes = res_man->openResource(1);
+ varsRes = _resman->openResource(1);
// copy that to the buffer, following the header
- memcpy(varsRes, buffer->ad + sizeof(g_header), g_header.varLength );
+ memcpy(varsRes, buffer->ad + sizeof(_saveGameHeader), _saveGameHeader.varLength );
#ifdef SCUMM_BIG_ENDIAN
uint32 *globalVars = (uint32 *) (varsRes + sizeof(_standardHeader));
- const uint numVars = (g_header.varLength - sizeof(_standardHeader)) / 4;
+ const uint numVars = (_saveGameHeader.varLength - sizeof(_standardHeader)) / 4;
for (uint i = 0; i < numVars; i++)
globalVars[i] = SWAP_BYTES_32(globalVars[i]);
#endif
// close variables resource
- res_man->closeResource(1);
+ _resman->closeResource(1);
// free it now, rather than in RestoreGame, to unblock memory before
// new screen & runlist loaded
- memory->freeMemory(buffer);
+ _memory->freeMemory(buffer);
- pars[0] = g_header.screenId;
+ pars[0] = _saveGameHeader.screenId;
pars[1] = 1;
_logic->fnInitBackground(pars);
@@ -389,11 +378,11 @@
// these need setting after the defaults get set in fnInitBackground
// remember that these can change through the game, so need saving &
// restoring too
- _thisScreen.feet_x = g_header.feet_x;
- _thisScreen.feet_y = g_header.feet_y;
+ _thisScreen.feet_x = _saveGameHeader.feet_x;
+ _thisScreen.feet_y = _saveGameHeader.feet_y;
// start the new run list
- _logic->expressChangeSession(g_header.runListId);
+ _logic->expressChangeSession(_saveGameHeader.runListId);
// Force in the new scroll position, so unsightly scroll-catch-up does
// not occur when screen first draws after returning from restore panel
@@ -401,8 +390,8 @@
// set '_thisScreen's record of player position
// - ready for setScrolling()
- _thisScreen.player_feet_x = g_header.mega.feet_x;
- _thisScreen.player_feet_y = g_header.mega.feet_y;
+ _thisScreen.player_feet_x = _saveGameHeader.mega.feet_x;
+ _thisScreen.player_feet_y = _saveGameHeader.mega.feet_y;
// if this screen is wide, recompute the scroll offsets now
if (_thisScreen.scroll_flag)
@@ -411,11 +400,11 @@
// Any music required will be started after we've returned from
// Restore_control() - see System_menu() in mouse.cpp!
- _loopingMusicId = g_header.music_id;
+ _loopingMusicId = _saveGameHeader.music_id;
// Write to walkthrough file (zebug0.txt)
- debug(5, "RESTORED GAME \"%s\"", g_header.description);
+ debug(5, "RESTORED GAME \"%s\"", _saveGameHeader.description);
// game restored ok
return SR_OK;
@@ -425,9 +414,9 @@
uint32 Sword2Engine::getSaveDescription(uint16 slotNo, uint8 *description) {
char saveFileName[MAX_FILENAME_LEN];
- _savegameHeader dummy;
+ SaveGameHeader dummy;
SaveFile *in;
- SaveFileManager *mgr = g_system->get_savefile_manager();
+ SaveFileManager *mgr = _system->get_savefile_manager();
// construct filename
sprintf(saveFileName, "%s.%.3d", _targetName, slotNo);
@@ -439,7 +428,7 @@
}
// read header
- in->read(&dummy, sizeof(_savegameHeader));
+ in->read(&dummy, sizeof(dummy));
delete in;
delete mgr;
@@ -449,7 +438,7 @@
bool Sword2Engine::saveExists(uint16 slotNo) {
char saveFileName[MAX_FILENAME_LEN];
- SaveFileManager *mgr = g_system->get_savefile_manager();
+ SaveFileManager *mgr = _system->get_savefile_manager();
SaveFile *in;
// construct filename
@@ -475,14 +464,14 @@
char *raw_script_ad;
_standardHeader *head;
- head = (_standardHeader*) res_man->openResource(CUR_PLAYER_ID);
+ head = (_standardHeader*) _resman->openResource(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT)
error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
raw_script_ad = (char *) head;
_logic->runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(CUR_PLAYER_ID);
+ _resman->closeResource(CUR_PLAYER_ID);
}
void Sword2Engine::putPlayerStructures(void) {
@@ -494,7 +483,7 @@
char *raw_script_ad;
_standardHeader *head;
- head = (_standardHeader*) res_man->openResource(CUR_PLAYER_ID);
+ head = (_standardHeader*) _resman->openResource(CUR_PLAYER_ID);
if (head->fileType != GAME_OBJECT)
error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
@@ -513,7 +502,7 @@
// which megaset was the player at the time of saving?
- switch (g_header.mega.megaset_res) {
+ switch (_saveGameHeader.mega.megaset_res) {
case 36: // GeoMega:
null_pc = 9; // script no.9 - 'player_is_george'
break;
@@ -532,7 +521,7 @@
}
_logic->runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(CUR_PLAYER_ID);
+ _resman->closeResource(CUR_PLAYER_ID);
}
uint32 Sword2Engine::calcChecksum(uint8 *buffer, uint32 size) {
@@ -557,9 +546,9 @@
// copy from player object to savegame header
- memcpy(&_vm->g_header.logic, memory->intToPtr(params[0]), sizeof(Object_logic));
- memcpy(&_vm->g_header.graphic, memory->intToPtr(params[1]), sizeof(Object_graphic));
- memcpy(&_vm->g_header.mega, memory->intToPtr(params[2]), sizeof(Object_mega));
+ memcpy(&_vm->_saveGameHeader.logic, _vm->_memory->intToPtr(params[0]), sizeof(Object_logic));
+ memcpy(&_vm->_saveGameHeader.graphic, _vm->_memory->intToPtr(params[1]), sizeof(Object_graphic));
+ memcpy(&_vm->_saveGameHeader.mega, _vm->_memory->intToPtr(params[2]), sizeof(Object_mega));
// makes no odds
return IR_CONT;
@@ -573,17 +562,17 @@
// 1 pointer to object's graphic structure
// 2 pointer to object's mega structure
- Object_logic *ob_logic = (Object_logic *) memory->intToPtr(params[0]);
- Object_graphic *ob_graphic = (Object_graphic *) memory->intToPtr(params[1]);
- Object_mega *ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ Object_logic *ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
+ Object_graphic *ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[1]);
+ Object_mega *ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
int32 pars[3];
// copy from savegame header to player object
- memcpy((uint8 *) ob_logic, &_vm->g_header.logic, sizeof(Object_logic));
- memcpy((uint8 *) ob_graphic, &_vm->g_header.graphic, sizeof(Object_graphic));
- memcpy((uint8 *) ob_mega, &_vm->g_header.mega, sizeof(Object_mega));
+ memcpy((uint8 *) ob_logic, &_vm->_saveGameHeader.logic, sizeof(Object_logic));
+ memcpy((uint8 *) ob_graphic, &_vm->_saveGameHeader.graphic, sizeof(Object_graphic));
+ memcpy((uint8 *) ob_mega, &_vm->_saveGameHeader.mega, sizeof(Object_mega));
// any walk-data must be cleared - the player will be set to stand if
// he was walking when saved
Index: scroll.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/scroll.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- scroll.cpp 8 Nov 2003 19:47:20 -0000 1.14
+++ scroll.cpp 16 Nov 2003 14:18:28 -0000 1.15
@@ -17,15 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/debug.h"
#include "sword2/defs.h"
-#include "sword2/header.h"
#include "sword2/interpreter.h"
-#include "sword2/layers.h"
-#include "sword2/logic.h"
namespace Sword2 {
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- sound.cpp 8 Nov 2003 19:47:20 -0000 1.34
+++ sound.cpp 16 Nov 2003 14:18:28 -0000 1.35
@@ -27,16 +27,11 @@
//
// ---------------------------------------------------------------------------
-#include "stdafx.h"
+#include "common/stdafx.h"
+#include "common/file.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
-#include "sword2/defs.h" // for RESULT
+#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/protocol.h" // for fetchObjectName() for debugging fnPlayFx
-#include "sword2/resman.h"
-#include "sword2/sound.h"
-#include "sword2/sword2.h"
namespace Sword2 {
@@ -72,7 +67,7 @@
break;
case FX_SPOT2:
// Once the Fx has finished remove it from the queue.
- if (g_sound->isFxOpen(i + 1))
+ if (_sound->isFxOpen(i + 1))
_fxQueue[i].resource = 0;
break;
}
@@ -90,12 +85,12 @@
if (_fxQueue[j].type == FX_SPOT) {
// load in the sample
- data = res_man->openResource(_fxQueue[j].resource);
+ data = _resman->openResource(_fxQueue[j].resource);
data += sizeof(_standardHeader);
// wav data gets copied to sound memory
- rv = g_sound->playFx(id, data, _fxQueue[j].volume, _fxQueue[j].pan, RDSE_FXSPOT);
+ rv = _sound->playFx(id, data, _fxQueue[j].volume, _fxQueue[j].pan, RDSE_FXSPOT);
// release the sample
- res_man->closeResource(_fxQueue[j].resource);
+ _resman->closeResource(_fxQueue[j].resource);
} else {
// random & looped fx are already loaded into sound memory
// by fnPlayFx()
@@ -103,10 +98,10 @@
if (_fxQueue[j].type == FX_RANDOM) {
// Not looped
- rv = g_sound->playFx(id, NULL, _fxQueue[j].volume, _fxQueue[j].pan, RDSE_FXSPOT);
+ rv = _sound->playFx(id, NULL, _fxQueue[j].volume, _fxQueue[j].pan, RDSE_FXSPOT);
} else {
// Looped
- rv = g_sound->playFx(id, NULL, _fxQueue[j].volume, _fxQueue[j].pan, RDSE_FXLOOP);
+ rv = _sound->playFx(id, NULL, _fxQueue[j].volume, _fxQueue[j].pan, RDSE_FXLOOP);
}
}
@@ -118,7 +113,7 @@
void Sword2Engine::clearFxQueue(void) {
// stop all fx & remove the samples from sound memory
- g_sound->clearAllFx();
+ _sound->clearAllFx();
// clean out the queue
initFxQueue();
@@ -126,19 +121,19 @@
void Sword2Engine::killMusic(void) {
_loopingMusicId = 0; // clear the 'looping' flag
- g_sound->stopMusic();
+ _sound->stopMusic();
}
void Sword2Engine::pauseAllSound(void) {
- g_sound->pauseMusic();
- g_sound->pauseSpeech();
- g_sound->pauseFx();
+ _sound->pauseMusic();
+ _sound->pauseSpeech();
+ _sound->pauseFx();
}
void Sword2Engine::unpauseAllSound(void) {
- g_sound->unpauseMusic();
- g_sound->unpauseSpeech();
- g_sound->unpauseFx();
+ _sound->unpauseMusic();
+ _sound->unpauseSpeech();
+ _sound->unpauseFx();
}
// called from script only
@@ -212,26 +207,26 @@
if (_vm->_fxQueue[j].type == FX_SPOT) {
// "pre-load" the sample; this gets it into memory
- data = res_man->openResource(_vm->_fxQueue[j].resource);
+ data = _vm->_resman->openResource(_vm->_fxQueue[j].resource);
#ifdef _SWORD2_DEBUG
- header = (_standardHeader*) data;
+ header = (_standardHeader *) data;
if (header->fileType != WAV_FILE)
error("fnPlayFx given invalid resource");
#endif
// but then releases it to "age" out if the space is needed
- res_man->closeResource(_vm->_fxQueue[j].resource);
+ _vm->_resman->closeResource(_vm->_fxQueue[j].resource);
} else {
// random & looped fx
id = (uint32) j + 1; // because 0 is not a valid id
// load in the sample
- data = res_man->openResource(_vm->_fxQueue[j].resource);
+ data = _vm->_resman->openResource(_vm->_fxQueue[j].resource);
#ifdef _SWORD2_DEBUG
- header = (_standardHeader*)data;
+ header = (_standardHeader *) data;
if (header->fileType != WAV_FILE)
error("fnPlayFx given invalid resource");
#endif
@@ -239,13 +234,13 @@
data += sizeof(_standardHeader);
// copy it to sound memory, using position in queue as 'id'
- rv = g_sound->openFx(id, data);
+ rv = _vm->_sound->openFx(id, data);
if (rv)
debug(5, "SFX ERROR: openFx() returned %.8x", rv);
// release the sample
- res_man->closeResource(_vm->_fxQueue[j].resource);
+ _vm->_resman->closeResource(_vm->_fxQueue[j].resource);
}
if (_vm->_fxQueue[j].type == FX_LOOP) {
@@ -278,7 +273,7 @@
// setFxIdVolumePan(int32 id, uint8 vol, uint8 pan);
// driver fx_id is 1 + <pos in queue>
- g_sound->setFxIdVolumePan(1 + params[0], params[1], params[2]);
+ _vm->_sound->setFxIdVolumePan(1 + params[0], params[1], params[2]);
return IR_CONT;
}
@@ -290,7 +285,7 @@
// 1 new volume (0..16)
// SetFxIdVolume(int32 id, uint8 vol);
- g_sound->setFxIdVolume(1 + params[0], params[1]);
+ _vm->_sound->setFxIdVolume(1 + params[0], params[1]);
return IR_CONT;
}
@@ -311,7 +306,7 @@
id = (uint32) j + 1; // because 0 is not a valid id
// stop fx & remove sample from sound memory
- rv = g_sound->closeFx(id);
+ rv = _vm->_sound->closeFx(id);
if (rv)
debug(5, "SFX ERROR: closeFx() returned %.8x", rv);
@@ -374,14 +369,14 @@
} else {
File f;
- sprintf(filename, "music%d.clu", res_man->whichCd());
+ sprintf(filename, "music%d.clu", _vm->_resman->whichCd());
if (f.open(filename))
f.close();
else
strcpy(filename, "music.clu");
}
- rv = g_sound->streamCompMusic(filename, params[0], loopFlag);
+ rv = _vm->_sound->streamCompMusic(filename, params[0], loopFlag);
if (rv)
debug(5, "ERROR: streamCompMusic(%s, %d, %d) returned error 0x%.8x", filename, params[0], loopFlag, rv);
@@ -395,7 +390,7 @@
// params: none
_vm->_loopingMusicId = 0; // clear the 'looping' flag
- g_sound->stopMusic();
+ _vm->_sound->stopMusic();
return IR_CONT;
}
@@ -406,7 +401,7 @@
// or 0 if no music playing
// in seconds, rounded up to the nearest second
- RESULT = g_sound->musicTimeRemaining();
+ RESULT = _vm->_sound->musicTimeRemaining();
return IR_CONT;
}
Index: speech.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/speech.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- speech.cpp 11 Nov 2003 07:43:02 -0000 1.49
+++ speech.cpp 16 Nov 2003 14:18:28 -0000 1.50
@@ -17,23 +17,11 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
+#include "common/file.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
-#include "sword2/controls.h" // for 'subtitles' & 'speechSelected'
-#include "sword2/debug.h"
#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/layers.h" // for 'this_screen'
-#include "sword2/logic.h"
-#include "sword2/maketext.h"
-#include "sword2/memory.h"
-#include "sword2/mouse.h"
-#include "sword2/object.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/sound.h"
-#include "sword2/speech.h"
namespace Sword2 {
@@ -171,18 +159,18 @@
for (j = 0; j < 15; j++) {
if (j < IN_SUBJECT) {
debug(5, " ICON res %d for %d", _subjectList[j].res, j);
- icon = res_man->openResource(_subjectList[j].res) + sizeof(_standardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
- g_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
- res_man->closeResource(_subjectList[j].res);
+ icon = _vm->_resman->openResource(_subjectList[j].res) + sizeof(_standardHeader) + RDMENU_ICONWIDE * RDMENU_ICONDEEP;
+ _vm->_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
+ _vm->_resman->closeResource(_subjectList[j].res);
} else {
//no icon here
debug(5, " NULL for %d", j);
- g_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, NULL);
+ _vm->_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, NULL);
}
}
// start menus appearing
- g_graphics->showMenu(RDMENU_BOTTOM);
+ _vm->_graphics->showMenu(RDMENU_BOTTOM);
// lets have the mouse pointer back
_vm->setMouse(NORMAL_MOUSE_ID);
@@ -195,7 +183,7 @@
// menu is there - we're just waiting for a click
debug(5, "choosing");
- me = g_input->mouseEvent();
+ me = _vm->_input->mouseEvent();
// we only care about left clicks
// we ignore mouse releases
@@ -205,9 +193,9 @@
// if so then end the choose, highlight only the
// chosen, blank the mouse and return the ref code * 8
- if (g_input->_mouseY > 399 && g_input->_mouseX >= 24 && g_input->_mouseX < 640 - 24) {
+ if (_vm->_input->_mouseY > 399 && _vm->_input->_mouseX >= 24 && _vm->_input->_mouseX < 640 - 24) {
//which are we over?
- hit = (g_input->_mouseX - 24) / 40;
+ hit = (_vm->_input->_mouseX - 24) / 40;
//clicked on something - what button?
if (hit < IN_SUBJECT) {
@@ -219,9 +207,9 @@
// change all others to grey
if (j != hit) {
- icon = res_man->openResource( _subjectList[j].res ) + sizeof(_standardHeader);
- g_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
- res_man->closeResource(_subjectList[j].res);
+ icon = _vm->_resman->openResource( _subjectList[j].res ) + sizeof(_standardHeader);
+ _vm->_graphics->setMenuIcon(RDMENU_BOTTOM, (uint8) j, icon);
+ _vm->_resman->closeResource(_subjectList[j].res);
}
}
@@ -279,9 +267,9 @@
// params: none
- g_graphics->hideMenu(RDMENU_BOTTOM);
+ _vm->_graphics->hideMenu(RDMENU_BOTTOM);
- if (g_input->_mouseY > 399) {
+ if (_vm->_input->_mouseY > 399) {
// will wait for cursor to move off the bottom menu
_vm->_mouseMode = MOUSE_holding;
debug(5, " holding");
@@ -290,7 +278,7 @@
TALK_FLAG = 0; // in-case DC forgets
// restart george's base script
- // LLogic.totalRestart();
+ // totalRestart();
//drop out without saving pc and go around again
return IR_CONT;
@@ -314,7 +302,7 @@
int32 target = params[0];
// request status of target
- head = (_standardHeader*) res_man->openResource(target);
+ head = (_standardHeader *) _vm->_resman->openResource(target);
if (head->fileType != GAME_OBJECT)
error("fnTheyDo %d not an object", target);
@@ -323,7 +311,7 @@
// call the base script - this is the graphic/mouse service call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(target);
+ _vm->_resman->closeResource(target);
// result is 1 for waiting, 0 for busy
@@ -376,7 +364,7 @@
// ok, see if the target is busy - we must request this info from the
// target object
- head = (_standardHeader*) res_man->openResource(target);
+ head = (_standardHeader *) _vm->_resman->openResource(target);
if (head->fileType != GAME_OBJECT)
error("fnTheyDoWeWait %d not an object", target);
@@ -385,9 +373,9 @@
// call the base script - this is the graphic/mouse service call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(target);
+ _vm->_resman->closeResource(target);
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (!INS_COMMAND && RESULT == 1 && ob_logic->looping == 0) {
// first time so set up targets command if target is waiting
@@ -456,7 +444,7 @@
int32 target = params[0];
// request status of target
- head = (_standardHeader*) res_man->openResource(target);
+ head = (_standardHeader *) _vm->_resman->openResource(target);
if (head->fileType != GAME_OBJECT)
error("fnWeWait: %d not an object", target);
@@ -465,7 +453,7 @@
// call the base script - this is the graphic/mouse service call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(target);
+ _vm->_resman->closeResource(target);
// result is 1 for waiting, 0 for busy
@@ -498,13 +486,13 @@
_standardHeader *head;
int32 target = params[1];
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (!ob_logic->looping)
ob_logic->looping = params[2]; // first time in
// request status of target
- head = (_standardHeader*) res_man->openResource(target);
+ head = (_standardHeader *) _vm->_resman->openResource(target);
if (head->fileType != GAME_OBJECT)
error("fnTimedWait %d not an object", target);
@@ -513,7 +501,7 @@
// call the base script - this is the graphic/mouse service call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(target);
+ _vm->_resman->closeResource(target);
// result is 1 for waiting, 0 for busy
@@ -580,7 +568,7 @@
int32 pars[9];
int32 ret;
- ob_speech = (Object_speech *) memory->intToPtr(params[1]);
+ ob_speech = (Object_speech *) _vm->_memory->intToPtr(params[1]);
debug(5, " SP");
@@ -896,8 +884,8 @@
// set up the pointers which we know we'll always need
- ob_logic = (Object_logic *) memory->intToPtr(params[S_OB_LOGIC]);
- ob_graphic = (Object_graphic *) memory->intToPtr(params[S_OB_GRAPHIC]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[S_OB_LOGIC]);
+ ob_graphic = (Object_graphic *) _vm->_memory->intToPtr(params[S_OB_GRAPHIC]);
// FIRST TIME ONLY: create the text, load the wav, set up the anim,
// etc.
@@ -906,7 +894,7 @@
// New fudge to wait for smacker samples to finish
// since they can over-run into the game
- if (g_sound->getSpeechStatus() != RDSE_SAMPLEFINISHED)
+ if (_vm->_sound->getSpeechStatus() != RDSE_SAMPLEFINISHED)
return IR_REPEAT;
// New fudge for 'fx' subtitles
@@ -914,7 +902,7 @@
// for this line either, then just quit back to script right
// now!
- if (gui->_subtitles == 0 && wantSpeechForLine(params[S_WAV]) == 0)
+ if (_vm->_gui->_subtitles == 0 && wantSpeechForLine(params[S_WAV]) == 0)
return IR_CONT;
if (cycle_skip == 0) {
@@ -947,14 +935,14 @@
// if the resource number is within range & it's not
// a null resource
- if (res_man->checkValid(text_res)) {
+ if (_vm->_resman->checkValid(text_res)) {
// open the resource
- head = (_standardHeader*) res_man->openResource(text_res);
+ head = (_standardHeader *) _vm->_resman->openResource(text_res);
if (head->fileType == TEXT_FILE) {
// if it's not an animation file
// if line number is out of range
- if (_vm->checkTextLine((uint8*) head, local_text) == 0) {
+ if (_vm->checkTextLine((uint8 *) head, local_text) == 0) {
// line number out of range
RESULT = 2;
}
@@ -964,7 +952,7 @@
}
// close the resource
- res_man->closeResource(text_res);
+ _vm->_resman->closeResource(text_res);
if (RESULT)
return IR_CONT;
@@ -984,11 +972,11 @@
local_text = params[S_TEXT] & 0xffff;
// open text file & get the line
- text = _vm->fetchTextLine(res_man->openResource(text_res), local_text);
+ text = _vm->fetchTextLine(_vm->_resman->openResource(text_res), local_text);
_officialTextNumber = READ_LE_UINT16(text);
// now ok to close the text file
- res_man->closeResource(text_res);
+ _vm->_resman->closeResource(text_res);
// prevent dud lines from appearing while testing text & speech
// since these will not occur in the game anyway
@@ -1039,10 +1027,10 @@
// use this direction table to derive the anim
// NB. ASSUMES WE HAVE A MEGA OBJECT!!
- ob_mega = (Object_mega *) memory->intToPtr(params[S_OB_MEGA]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[S_OB_MEGA]);
// pointer to anim table
- anim_table = (int32 *) memory->intToPtr(params[S_DIR_TABLE]);
+ anim_table = (int32 *) _vm->_memory->intToPtr(params[S_DIR_TABLE]);
// appropriate anim resource is in 'table[direction]'
_animId = anim_table[ob_mega->current_dir];
@@ -1077,7 +1065,7 @@
// if speech is selected, and this line is allowed speech
// (not if it's an fx subtitle!)
- if (!g_sound->isSpeechMute() && wantSpeechForLine(_officialTextNumber)) {
+ if (!_vm->_sound->isSpeechMute() && wantSpeechForLine(_officialTextNumber)) {
// if the wavId paramter is zero because not yet
// compiled into speech command, we can still get it
// from the 1st 2 chars of the text line
@@ -1111,7 +1099,7 @@
if (text_res != currentTextResource && params[S_WAV]) {
// ensure correct CD is in for this
// wavId
- // GetCorrectCdForSpeech(params[S_WAV]);
+ // getCorrectCdForSpeech(params[S_WAV]);
currentTextResource = text_res;
}
}
@@ -1123,7 +1111,7 @@
File fp;
- sprintf(speechFile, "speech%d.clu", res_man->whichCd());
+ sprintf(speechFile, "speech%d.clu", _vm->_resman->whichCd());
if (fp.open(speechFile))
fp.close();
@@ -1131,7 +1119,7 @@
strcpy(speechFile, "speech.clu");
// Load speech but don't start playing yet
- rv = g_sound->playCompSpeech(speechFile, params[S_WAV], SPEECH_VOLUME, speech_pan);
+ rv = _vm->_sound->playCompSpeech(speechFile, params[S_WAV], SPEECH_VOLUME, speech_pan);
if (rv == RD_OK) {
// ok, we've got something to play
// (2 means not playing yet - see below)
@@ -1139,14 +1127,14 @@
// set it playing now (we might want to do
// this next cycle, don't know yet)
- g_sound->unpauseSpeech();
+ _vm->_sound->unpauseSpeech();
} else {
debug(5, "ERROR: PlayCompSpeech(speechFile=\"%s\", wav=%d (res=%d pos=%d)) returned %.8x", speechFile, params[S_WAV], text_res, local_text, rv);
}
}
// if we want subtitles, or speech failed to load
- if (gui->_subtitles || speechRunning == 0) {
+ if (_vm->_gui->_subtitles || speechRunning == 0) {
// then we're going to show the text
textRunning = 1;
@@ -1166,7 +1154,7 @@
ob_graphic->anim_pc++;
// open the anim file
- anim_file = res_man->openResource(ob_graphic->anim_resource);
+ anim_file = _vm->_resman->openResource(ob_graphic->anim_resource);
anim_head = _vm->fetchAnimHeader(anim_file);
if (!_speechAnimType) {
@@ -1179,7 +1167,7 @@
// if playing a sample
if (!_unpauseZone) {
// if we're at a quiet bit
- if (g_sound->amISpeaking() == RDSE_QUIET) {
+ if (_vm->_sound->amISpeaking() == RDSE_QUIET) {
// restart from frame 0
// ('closed mouth' frame)
ob_graphic->anim_pc = 0;
@@ -1196,7 +1184,7 @@
}
// close the anim file
- res_man->closeResource(ob_graphic->anim_resource);
+ _vm->_resman->closeResource(ob_graphic->anim_resource);
} else if (_speechAnimType) {
// Placed here so we actually display the last frame of the
// anim.
@@ -1212,7 +1200,7 @@
if (speechRunning == 1) {
if (!_unpauseZone) {
// has it finished?
- if (g_sound->getSpeechStatus() == RDSE_SAMPLEFINISHED)
+ if (_vm->_sound->getSpeechStatus() == RDSE_SAMPLEFINISHED)
speechFinished = 1;
} else
_unpauseZone--;
@@ -1233,8 +1221,8 @@
// so that we can go to the options panel while text & speech is
// being tested
- if (SYSTEM_TESTING_TEXT == 0 || g_input->_mouseY > 0) {
- me = g_input->mouseEvent();
+ if (SYSTEM_TESTING_TEXT == 0 || _vm->_input->_mouseY > 0) {
+ me = _vm->_input->mouseEvent();
// Note that we now have TWO click-delays - one for LEFT
// button, one for RIGHT BUTTON
@@ -1258,7 +1246,7 @@
do {
// trash anything thats buffered
- me = g_input->mouseEvent();
+ me = _vm->_input->mouseEvent();
} while (me);
speechFinished = 1;
@@ -1266,7 +1254,7 @@
// if speech sample playing
if (speechRunning) {
// halt the sample prematurely
- g_sound->stopSpeech();
+ _vm->_sound->stopSpeech();
}
}
}
@@ -1280,7 +1268,7 @@
// if there is text
if (_speechTextBlocNo) {
// kill the text block
- fontRenderer->killTextBloc(_speechTextBlocNo);
+ _vm->_fontRenderer->killTextBloc(_speechTextBlocNo);
_speechTextBlocNo = 0;
}
@@ -1358,7 +1346,7 @@
// build_display.cpp
// open animation file & set up the necessary pointers
- file = res_man->openResource(_animId);
+ file = _vm->_resman->openResource(_animId);
anim_head = _vm->fetchAnimHeader(file);
@@ -1373,7 +1361,7 @@
if (cdt_entry->frameType & FRAME_OFFSET) {
// this may be NULL
- ob_mega = (Object_mega *) memory->intToPtr(params[S_OB_MEGA]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[S_OB_MEGA]);
// calc scale at which to print the sprite, based on
// feet y-coord & scaling constants (NB. 'scale' is
@@ -1410,7 +1398,7 @@
_textY -= _vm->_thisScreen.scroll_offset_y;
// release the anim resource
- res_man->closeResource(_animId);
+ _vm->_resman->closeResource(_animId);
}
}
@@ -1446,7 +1434,7 @@
// text
if (params[S_TEXT]) {
- ob_speech = (Object_speech *) memory->intToPtr(params[S_OB_SPEECH]);
+ ob_speech = (Object_speech *) _vm->_memory->intToPtr(params[S_OB_SPEECH]);
// establish the max width allowed for this text sprite
@@ -1464,19 +1452,19 @@
local_text = params[S_TEXT] & 0xffff;
// open text file & get the line
- text = _vm->fetchTextLine(res_man->openResource(text_res), local_text);
+ text = _vm->fetchTextLine(_vm->_resman->openResource(text_res), local_text);
// 'text + 2' to skip the first 2 bytes which form the line
// reference number
- _speechTextBlocNo = fontRenderer->buildNewBloc(
+ _speechTextBlocNo = _vm->_fontRenderer->buildNewBloc(
text + 2, _textX, _textY,
textWidth, ob_speech->pen,
RDSPR_TRANS | RDSPR_DISPLAYALIGN,
_vm->_speechFontId, POSITION_AT_CENTRE_OF_BASE);
// now ok to close the text file
- res_man->closeResource(text_res);
+ _vm->_resman->closeResource(text_res);
// set speech duration, in case not using wav
// no. of cycles = (no. of chars) + 30
@@ -1506,7 +1494,7 @@
// 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);
+ _vm->_resman->getCd(cd);
}
#endif
Index: startup.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/startup.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- startup.cpp 15 Nov 2003 09:38:00 -0000 1.33
+++ startup.cpp 16 Nov 2003 14:18:29 -0000 1.34
@@ -17,24 +17,8 @@
* $Header$
*/
-#include "stdafx.h"
-#include "sword2/sword2.h" // for CloseGame()
-#include "sword2/build_display.h"
-#include "sword2/console.h"
-#include "sword2/debug.h"
-#include "sword2/defs.h"
-#include "sword2/header.h"
-#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/maketext.h" // for Kill_text_bloc()
-#include "sword2/memory.h"
-#include "sword2/mouse.h"
-#include "sword2/object.h"
-#include "sword2/resman.h"
-#include "sword2/router.h"
-#include "sword2/sound.h"
-#include "sword2/speech.h" // for '_speechTextBlocNo' - so that speech text can be cleared when running a new start-script
-#include "sword2/startup.h"
+#include "common/stdafx.h"
+#include "sword2/sword2.h"
namespace Sword2 {
@@ -117,17 +101,17 @@
// - need to check in case un-built sections included in
// start list
- if (res_man->checkValid(_startRes)) {
+ if (_vm->_resman->checkValid(_startRes)) {
debug(5, "- resource %d ok", _startRes);
- raw_script = (char *) res_man->openResource(_startRes);
+ raw_script = (char *) _vm->_resman->openResource(_startRes);
null_pc = 0;
runScript(raw_script, raw_script, &null_pc);
- res_man->closeResource(_startRes);
+ _vm->_resman->closeResource(_startRes);
} else
debug(5, "- resource %d invalid", _startRes);
}
- memory->freeMemory(temp);
+ _vm->_memory->freeMemory(temp);
return 1;
}
@@ -141,7 +125,7 @@
error("ERROR: _startList full");
// +1 to allow for NULL terminator
- if (strlen((const char *) memory->intToPtr(params[1])) + 1 > MAX_description)
+ if (strlen((const char *) _vm->_memory->intToPtr(params[1])) + 1 > MAX_description)
error("ERROR: startup description too long");
#endif
@@ -152,7 +136,7 @@
// the correct start
_startList[_totalStartups].key = params[0];
- strcpy(_startList[_totalStartups].description, (const char *) memory->intToPtr(params[1]));
+ strcpy(_startList[_totalStartups].description, (const char *) _vm->_memory->intToPtr(params[1]));
// point to next
_totalStartups++;
@@ -195,8 +179,8 @@
fnStopMusic(NULL);
// halt the sample prematurely
- g_sound->unpauseSpeech();
- g_sound->stopSpeech();
+ _vm->_sound->unpauseSpeech();
+ _vm->_sound->stopSpeech();
// clean out all resources & flags, ready for a total
// restart
@@ -204,27 +188,27 @@
// remove all resources from memory, including player
// object & global variables
- res_man->removeAll();
+ _vm->_resman->removeAll();
// reopen global variables resource & send address to
// interpreter - it won't be moving
- setGlobalInterpreterVariables((int32 *) (res_man->openResource(1) + sizeof(_standardHeader)));
- res_man->closeResource(1);
+ setGlobalInterpreterVariables((int32 *) (_vm->_resman->openResource(1) + sizeof(_standardHeader)));
+ _vm->_resman->closeResource(1);
// free all the route memory blocks from previous game
_router->freeAllRouteMem();
// if there was speech text, kill the text block
if (_speechTextBlocNo) {
- fontRenderer->killTextBloc(_speechTextBlocNo);
+ _vm->_fontRenderer->killTextBloc(_speechTextBlocNo);
_speechTextBlocNo = 0;
}
// set the key
// Open George
- raw_data_ad = (char *) res_man->openResource(8);
- raw_script = (char *) res_man->openResource(_startList[start].start_res_id);
+ raw_data_ad = (char *) _vm->_resman->openResource(8);
+ raw_script = (char *) _vm->_resman->openResource(_startList[start].start_res_id);
// denotes script to run
null_pc = _startList[start].key & 0xffff;
@@ -232,10 +216,10 @@
Debug_Printf("Running start %d\n", start);
runScript(raw_script, raw_data_ad, &null_pc);
- res_man->closeResource(_startList[start].start_res_id);
+ _vm->_resman->closeResource(_startList[start].start_res_id);
// Close George
- res_man->closeResource(8);
+ _vm->_resman->closeResource(8);
// make sure thre's a mouse, in case restarting while
// mouse not available
Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- sword2.cpp 15 Nov 2003 09:38:00 -0000 1.85
+++ sword2.cpp 16 Nov 2003 14:18:29 -0000 1.86
@@ -17,32 +17,13 @@
* $Header$
*/
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "backends/fs/fs.h"
#include "base/gameDetector.h"
#include "base/plugins.h"
#include "common/config-manager.h"
#include "sword2/sword2.h"
-#include "sword2/driver/driver96.h"
#include "sword2/defs.h"
-#include "sword2/build_display.h"
-#include "sword2/console.h"
-#include "sword2/controls.h"
-#include "sword2/credits.h"
-#include "sword2/debug.h"
-#include "sword2/header.h"
-#include "sword2/interpreter.h"
-#include "sword2/layers.h"
-#include "sword2/logic.h"
-#include "sword2/maketext.h"
-#include "sword2/memory.h"
-#include "sword2/mouse.h"
-#include "sword2/protocol.h"
-#include "sword2/resman.h"
-#include "sword2/save_rest.h"
-#include "sword2/sound.h"
-#include "sword2/speech.h"
-#include "sword2/startup.h"
#ifdef _WIN32_WCE
extern bool isSmartphone(void);
@@ -98,9 +79,6 @@
namespace Sword2 {
Sword2Engine *g_sword2 = NULL;
-Input *g_input = NULL;
-Sound *g_sound = NULL;
-Graphics *g_graphics = NULL;
Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
: Engine(syst) {
@@ -126,14 +104,14 @@
// get some falling RAM and put it in your pocket, never let it slip
// away
- memory = new MemoryManager();
- res_man = new ResourceManager(this);
+ _memory = new MemoryManager(this);
+ _resman = new ResourceManager(this);
_logic = new Logic(this);
- fontRenderer = new FontRenderer();
- gui = new Gui(this);
- g_input = _input = new Input();
- g_sound = _sound = new Sound(_mixer);
- g_graphics = _graphics = new Graphics(640, 480);
+ _fontRenderer = new FontRenderer(this);
+ _gui = new Gui(this);
+ _input = new Input(this);
+ _sound = new Sound(this);
+ _graphics = new Graphics(this, 640, 480);
_debugger = new Debugger(this);
_lastPaletteRes = 0;
@@ -192,11 +170,11 @@
delete _graphics;
delete _sound;
delete _input;
- delete gui;
- delete fontRenderer;
+ delete _gui;
+ delete _fontRenderer;
delete _logic;
- delete res_man;
- delete memory;
+ delete _resman;
+ delete _memory;
}
void Sword2Engine::errorString(const char *buf1, char *buf2) {
@@ -223,9 +201,9 @@
// initialise global script variables
// res 1 is the globals list
- file = res_man->openResource(1);
+ file = _resman->openResource(1);
debug(5, "CALLING: SetGlobalInterpreterVariables");
- _logic->setGlobalInterpreterVariables((int32 * ) (file + sizeof(_standardHeader)));
+ _logic->setGlobalInterpreterVariables((int32 *) (file + sizeof(_standardHeader)));
// DON'T CLOSE VARIABLES RESOURCE - KEEP IT OPEN AT VERY START OF
// MEMORY SO IT CAN'T MOVE!
@@ -233,7 +211,7 @@
// DON'T CLOSE PLAYER OBJECT RESOURCE - KEEP IT OPEN IN MEMORY SO IT
// CAN'T MOVE!
- file = res_man->openResource(8);
+ file = _resman->openResource(8);
// Set up font resource variables for this language version
@@ -257,7 +235,7 @@
void Sword2Engine::closeGame(void) {
// Stop music instantly!
killMusic();
- g_system->quit();
+ _system->quit();
}
void Sword2Engine::gameCycle(void) {
@@ -291,7 +269,7 @@
processFxQueue();
// update age and calculate previous cycle memory usage
- res_man->nextCycle();
+ _resman->nextCycle();
}
void Sword2Engine::go() {
@@ -306,7 +284,7 @@
// via a window, thus time becomes a loop.
debug(5, "CALLING: readOptionSettings");
- gui->readOptionSettings();
+ _gui->readOptionSettings();
debug(5, "CALLING: InitialiseGame");
if (InitialiseGame()) {
@@ -319,7 +297,7 @@
restoreGame(_saveSlot);
else { // show restore menu
setMouse(NORMAL_MOUSE_ID);
- if (!gui->restoreControl())
+ if (!_gui->restoreControl())
startGame();
}
} else
@@ -359,8 +337,8 @@
}
#endif
- if (g_input->keyWaiting()) {
- g_input->readKey(&ke);
+ if (_input->keyWaiting()) {
+ _input->readKey(&ke);
char c = toupper(ke.ascii);
@@ -458,19 +436,19 @@
uint32 null_pc = 1;
// open george object, ready for start script to reference
- raw_data_ad = (char *) res_man->openResource(8);
+ raw_data_ad = (char *) _resman->openResource(8);
// open the ScreenManager object
- raw_script = (char *) res_man->openResource(screen_manager_id);
+ raw_script = (char *) _resman->openResource(screen_manager_id);
// run the start script now (because no console)
_logic->runScript(raw_script, raw_data_ad, &null_pc);
// close the ScreenManager object
- res_man->closeResource(screen_manager_id);
+ _resman->closeResource(screen_manager_id);
// close george
- res_man->closeResource(8);
+ _resman->closeResource(8);
debug(5, "startGame() DONE.");
}
@@ -491,10 +469,10 @@
// uint8 *text;
// open text file & get the line "PAUSED"
- // text = FetchTextLine(res_man->openResource(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);
+ // text = fetchTextLine(_resman->openResource(3258), 449);
+ // pause_text_bloc_no = _fontRenderer->buildNewBloc(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->closeResource(3258);
+ // _resman->closeResource(3258);
// don't allow Pause while screen fading or while black
if (_graphics->getFadeStatus() != RDFADE_NONE)
@@ -519,8 +497,8 @@
// if level at max, turn down because palette-matching won't work
// when dimmed
- if (gui->_currentGraphicsLevel == 3) {
- gui->updateGraphicsLevel(2);
+ if (_gui->_currentGraphicsLevel == 3) {
+ _gui->updateGraphicsLevel(2);
_graphicsLevelFudged = true;
}
@@ -535,7 +513,7 @@
void Sword2Engine::unpauseGame(void) {
// removed "PAUSED" from screen
- // Kill_text_bloc(pause_text_bloc_no);
+ // _fontRenderer->killTextBloc(pause_text_bloc_no);
if (OBJECT_HELD && _realLuggageItem)
setLuggage(_realLuggageItem);
@@ -547,7 +525,7 @@
// If graphics level at max, turn up again
if (_graphicsLevelFudged) {
- gui->updateGraphicsLevel(3);
+ _gui->updateGraphicsLevel(3);
_graphicsLevelFudged = false;
}
Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- sword2.h 15 Nov 2003 09:38:00 -0000 1.41
+++ sword2.h 16 Nov 2003 14:18:29 -0000 1.42
@@ -21,23 +21,22 @@
#define _SWORD2
#include "base/engine.h"
-#include "common/file.h"
-#include "common/map.h"
-#include "common/rect.h"
-#include "common/str.h"
+#include "sword2/driver/driver96.h"
+#include "sword2/driver/d_sound.h"
+#include "sword2/driver/d_draw.h"
#include "sword2/build_display.h"
#include "sword2/console.h"
-#include "sword2/header.h"
+#include "sword2/controls.h"
#include "sword2/icons.h"
#include "sword2/layers.h"
#include "sword2/logic.h"
+#include "sword2/maketext.h"
#include "sword2/memory.h"
#include "sword2/mouse.h"
#include "sword2/object.h"
+#include "sword2/resman.h"
#include "sword2/save_rest.h"
#include "sword2/sound.h"
-#include "sword2/driver/d_sound.h"
-#include "sword2/driver/d_draw.h"
class GameDetector;
@@ -137,10 +136,14 @@
uint32 _features;
char *_targetName; // target name for saves
+ MemoryManager *_memory;
+ ResourceManager *_resman;
Input *_input;
Sound *_sound;
Graphics *_graphics;
Logic *_logic;
+ FontRenderer *_fontRenderer;
+ Gui *_gui;
Debugger *_debugger;
@@ -281,7 +284,7 @@
// savegame file header
- struct _savegameHeader {
+ struct SaveGameHeader {
// sum of all bytes in file, excluding this uint32
uint32 checksum;
@@ -304,7 +307,7 @@
Object_mega mega;
};
- _savegameHeader g_header;
+ SaveGameHeader _saveGameHeader;
uint32 saveGame(uint16 slotNo, uint8 *description);
uint32 restoreGame(uint16 slotNo);
@@ -366,9 +369,6 @@
};
extern Sword2Engine *g_sword2;
-extern Input *g_input;
-extern Sound *g_sound;
-extern Graphics *g_graphics;
} // End of namespace Sword2
Index: sync.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sync.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- sync.cpp 8 Nov 2003 18:15:35 -0000 1.14
+++ sync.cpp 16 Nov 2003 14:18:29 -0000 1.15
@@ -17,13 +17,10 @@
* $Header$
*/
-#include "stdafx.h"
-#include "common/util.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/debug.h"
#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
namespace Sword2 {
Index: tony_gsdk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/tony_gsdk.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- tony_gsdk.cpp 8 Nov 2003 18:15:35 -0000 1.17
+++ tony_gsdk.cpp 16 Nov 2003 14:18:29 -0000 1.18
@@ -19,11 +19,9 @@
// general odds and ends
-#include "stdafx.h"
+#include "common/stdafx.h"
+#include "common/file.h"
#include "sword2/sword2.h"
-#include "sword2/driver/driver96.h"
-#include "sword2/debug.h"
-#include "sword2/memory.h"
namespace Sword2 {
@@ -41,7 +39,7 @@
size = fh.size();
// reserve enough floating memory for the file
- *membloc = memory->allocMemory(size, MEM_float, uid);
+ *membloc = _memory->allocMemory(size, MEM_float, uid);
if (fh.read((*membloc)->ad, size) != size) {
debug(5, "Read_file read fail %d", name);
Index: walker.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/walker.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- walker.cpp 11 Nov 2003 07:43:02 -0000 1.28
+++ walker.cpp 16 Nov 2003 14:18:29 -0000 1.29
@@ -22,15 +22,10 @@
// script functions for moving megas about the place & also for keeping tabs
// on them
-#include "stdafx.h"
+#include "common/stdafx.h"
#include "sword2/sword2.h"
-#include "sword2/console.h"
#include "sword2/defs.h"
#include "sword2/interpreter.h"
-#include "sword2/logic.h"
-#include "sword2/object.h"
-#include "sword2/protocol.h"
-#include "sword2/router.h"
namespace Sword2 {
@@ -60,9 +55,9 @@
// get the parameters
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
- ob_graph = (Object_graphic *) memory->intToPtr(params[1]);
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
+ ob_graph = (Object_graphic *) _vm->_memory->intToPtr(params[1]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
target_x = (int16) params[4];
target_y = (int16) params[5];
@@ -88,7 +83,7 @@
if (params[6] < 0 || params[6] > 8)
error("Invalid direction (%d) in fnWalk", params[6]);
- ob_walkdata = (Object_walkdata *) memory->intToPtr(params[3]);
+ ob_walkdata = (Object_walkdata *) _vm->_memory->intToPtr(params[3]);
ob_mega->walk_pc = 0; // always
@@ -131,7 +126,7 @@
// resource
ob_graph->anim_resource = ob_mega->megaset_res;
- } else if (EXIT_FADING && g_graphics->getFadeStatus() == RDFADE_BLACK) {
+ } else if (EXIT_FADING && _vm->_graphics->getFadeStatus() == RDFADE_BLACK) {
// double clicked an exit so quit the walk when screen is black
// ok, thats it - back to script and change screen
@@ -170,7 +165,7 @@
if (checkEventWaiting()) {
if (walkAnim[walk_pc].step == 0 && walkAnim[walk_pc + 1].step == 1) {
// at the beginning of a step
- ob_walkdata = (Object_walkdata *) memory->intToPtr(params[3]);
+ ob_walkdata = (Object_walkdata *) _vm->_memory->intToPtr(params[3]);
_router->earlySlowOut(ob_mega, ob_walkdata);
}
}
@@ -255,11 +250,11 @@
// if this is the start of the walk, read anim file to get start coords
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
// open anim file
- anim_file = res_man->openResource(params[4]);
+ anim_file = _vm->_resman->openResource(params[4]);
// point to animation header
anim_head = _vm->fetchAnimHeader( anim_file );
@@ -269,7 +264,7 @@
pars[6] = anim_head->feetStartDir; // target_dir
// close anim file
- res_man->closeResource(params[4]);
+ _vm->_resman->closeResource(params[4]);
// if start coords not yet set in anim header, use the standby
// coords (which should be set beforehand in the script)
@@ -320,13 +315,13 @@
// if this is the start of the turn, get the mega's current feet
// coords + the required direction
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
if (params[4] < 0 || params[4] > 7)
error("Invalid direction (%d) in fnTurn", params[4]);
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
pars[4] = ob_mega->feet_x;
pars[5] = ob_mega->feet_y;
@@ -367,8 +362,8 @@
// set up pointers to the graphic & mega structure
- ob_graph = (Object_graphic *) memory->intToPtr(params[0]);
- ob_mega = (Object_mega *) memory->intToPtr(params[1]);
+ ob_graph = (Object_graphic *) _vm->_memory->intToPtr(params[0]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[1]);
// set up the stand frame & set the mega's new direction
@@ -394,7 +389,7 @@
// 1 pointer to object's mega structure
// 2 target direction
- Object_mega *ob_mega = (Object_mega *) memory->intToPtr(params[1]);
+ Object_mega *ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[1]);
int32 pars[5];
pars[0] = params[0];
@@ -423,7 +418,7 @@
// open the anim file & set up a pointer to the animation header
// open anim file
- anim_file = res_man->openResource(params[2]);
+ anim_file = _vm->_resman->openResource(params[2]);
anim_head = _vm->fetchAnimHeader(anim_file);
// set up the parameter list for fnWalkTo()
@@ -450,7 +445,7 @@
error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
// close the anim file
- res_man->closeResource(params[2]);
+ _vm->_resman->closeResource(params[2]);
// call fnStandAt() with target coords set to anim end position
return fnStandAt(pars);
@@ -470,7 +465,7 @@
// open the anim file & set up a pointer to the animation header
// open anim file
- anim_file = res_man->openResource(params[2]);
+ anim_file = _vm->_resman->openResource(params[2]);
anim_head = _vm->fetchAnimHeader(anim_file);
// set up the parameter list for fnWalkTo()
@@ -497,7 +492,7 @@
error("Invalid direction (%d) in fnStandAfterAnim", pars[4]);
// close the anim file
- res_man->closeResource(params[2]);
+ _vm->_resman->closeResource(params[2]);
// call fnStandAt() with target coords set to anim end position
return fnStandAt(pars);
@@ -556,10 +551,10 @@
// if this is the start of the turn, get the mega's current feet
// coords + the required direction
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
pars[4] = ob_mega->feet_x;
pars[5] = ob_mega->feet_y;
@@ -591,12 +586,12 @@
Object_mega *ob_mega;
_standardHeader *head;
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
if (ob_logic->looping == 0) {
// get targets info
- head = (_standardHeader *) res_man->openResource(params[4]);
+ head = (_standardHeader *) _vm->_resman->openResource(params[4]);
if (head->fileType != GAME_OBJECT)
error("fnFaceMega %d not an object", params[4]);
@@ -606,7 +601,7 @@
//call the base script - this is the graphic/mouse service call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(params[4]);
+ _vm->_resman->closeResource(params[4]);
// engineMega is now the Object_mega of mega we want to turn
// to face
@@ -647,8 +642,8 @@
int mega_separation = params[5];
_standardHeader *head;
- ob_logic = (Object_logic *) memory->intToPtr(params[0]);
- ob_mega = (Object_mega *) memory->intToPtr(params[2]);
+ ob_logic = (Object_logic *) _vm->_memory->intToPtr(params[0]);
+ ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[2]);
pars[0] = params[0]; // standard stuff
pars[1] = params[1];
@@ -658,7 +653,7 @@
// not been here before so decide where to walk-to
if (!ob_logic->looping) {
// first request the targets info
- head = (_standardHeader *) res_man->openResource(params[4]);
+ head = (_standardHeader *) _vm->_resman->openResource(params[4]);
if (head->fileType != GAME_OBJECT)
error("fnWalkToTalkToMega %d not an object", params[4]);
@@ -669,7 +664,7 @@
// call
runScript(raw_script_ad, raw_script_ad, &null_pc);
- res_man->closeResource(params[4]);
+ _vm->_resman->closeResource(params[4]);
// engineMega is now the Object_mega of mega we want to
// route to
@@ -737,8 +732,8 @@
_router->addWalkGrid(params[0]);
// Touch the grid, getting it into memory.
- res_man->openResource(params[0]);
- res_man->closeResource(params[0]);
+ _vm->_resman->openResource(params[0]);
+ _vm->_resman->closeResource(params[0]);
return IR_CONT;
}
@@ -771,7 +766,7 @@
// where s is system scale, which itself is (256 * actual_scale) ie.
// s == 128 is half size
- Object_mega *ob_mega = (Object_mega *) memory->intToPtr(params[0]);
+ Object_mega *ob_mega = (Object_mega *) _vm->_memory->intToPtr(params[0]);
ob_mega->scale_a = params[1];
ob_mega->scale_b = params[2];
--- credits.h DELETED ---
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2/driver _mouse.cpp,1.27,1.28 d_draw.cpp,1.44,1.45 d_draw.h,1.15,1.16 d_sound.cpp,1.81,1.82 d_sound.h,1.31,1.32 driver96.h,1.61,1.62 keyboard.cpp,1.13,1.14 language.cpp,1.10,1.11 menu.cpp,1.22,1.23 palette.cpp,1.25,1.26 rdwin.cpp,1.37,1.38 render.cpp,1.42,1.43 sprite.cpp,1.32,1.33
- Next message: [Scummvm-cvs-logs] CVS: scummvm/dists/msvc7 sword2.vcproj,1.4,1.5
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list