aboutsummaryrefslogtreecommitdiff
path: root/sword2
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-11-04 18:02:49 +0000
committerTorbjörn Andersson2003-11-04 18:02:49 +0000
commitba098a3a5b27967c5e3f629cb6e8a0dc453aded8 (patch)
tree54e9193bc66152082fdade1221b313c92aeb2ac7 /sword2
parent64ec1907c2d99e7ecc46e0a5d5605e474c548248 (diff)
downloadscummvm-rg350-ba098a3a5b27967c5e3f629cb6e8a0dc453aded8.tar.gz
scummvm-rg350-ba098a3a5b27967c5e3f629cb6e8a0dc453aded8.tar.bz2
scummvm-rg350-ba098a3a5b27967c5e3f629cb6e8a0dc453aded8.zip
Create g_logic dynamically. More moving of stuff into classes.
svn-id: r11129
Diffstat (limited to 'sword2')
-rw-r--r--sword2/console.cpp12
-rw-r--r--sword2/controls.cpp6
-rw-r--r--sword2/debug.cpp10
-rw-r--r--sword2/events.cpp2
-rw-r--r--sword2/icons.cpp2
-rw-r--r--sword2/logic.cpp2
-rw-r--r--sword2/logic.h30
-rw-r--r--sword2/mouse.cpp10
-rw-r--r--sword2/resman.cpp4
-rw-r--r--sword2/save_rest.cpp16
-rw-r--r--sword2/startup.cpp92
-rw-r--r--sword2/startup.h20
-rw-r--r--sword2/sword2.cpp21
13 files changed, 113 insertions, 114 deletions
diff --git a/sword2/console.cpp b/sword2/console.cpp
index 20465e9a79..387a6a7824 100644
--- a/sword2/console.cpp
+++ b/sword2/console.cpp
@@ -197,7 +197,7 @@ bool Debugger::Cmd_Res(int argc, const char **argv) {
}
bool Debugger::Cmd_Starts(int argc, const char **argv) {
- Con_print_start_menu();
+ g_logic->conPrintStartMenu();
return true;
}
@@ -209,7 +209,7 @@ bool Debugger::Cmd_Start(int argc, const char **argv) {
return true;
}
- Con_start(atoi(argv[1]));
+ g_logic->conStart(atoi(argv[1]));
g_display->setPalette(187, 1, pal, RDPAL_INSTANT);
return true;
}
@@ -272,7 +272,7 @@ bool Debugger::Cmd_CurrentInfo(int argc, const char **argv) {
}
bool Debugger::Cmd_RunList(int argc, const char **argv) {
- g_logic.examineRunList();
+ g_logic->examineRunList();
return true;
}
@@ -612,7 +612,7 @@ bool Debugger::Cmd_AnimTest(int argc, const char **argv) {
}
// Automatically do "s 32" to run the animation testing start script
- Con_start(32);
+ g_logic->conStart(32);
// Same as typing "VAR 912 <value>" at the console
varSet(912, atoi(argv[1]));
@@ -628,7 +628,7 @@ bool Debugger::Cmd_TextTest(int argc, const char **argv) {
}
// Automatically do "s 33" to run the text/speech testing start script
- Con_start(33);
+ g_logic->conStart(33);
// Same as typing "VAR 1230 <value>" at the console
varSet(1230, atoi(argv[1]));
@@ -647,7 +647,7 @@ bool Debugger::Cmd_LineTest(int argc, const char **argv) {
}
// Automatically do "s 33" to run the text/speech testing start script
- Con_start(33);
+ g_logic->conStart(33);
// Same as typing "VAR 1230 <value>" at the console
varSet(1230, atoi(argv[1]));
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index 3a93a3b410..cc224871ab 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -1295,7 +1295,7 @@ public:
// fnRegisterMouse and fnRegisterFrame)
g_sword2->resetMouseList();
- if (g_logic.processSession())
+ if (g_logic->processSession())
error("restore 1st cycle failed??");
}
}
@@ -1446,7 +1446,7 @@ void Gui::restartControl(void) {
// reopen global variables resource & send address to interpreter -
// it won't be moving
- g_logic.setGlobalInterpreterVariables((int32 *) (res_man->openResource(1) + sizeof(_standardHeader)));
+ g_logic->setGlobalInterpreterVariables((int32 *) (res_man->openResource(1) + sizeof(_standardHeader)));
res_man->closeResource(1);
DEMO = temp_demo_flag;
@@ -1475,7 +1475,7 @@ void Gui::restartControl(void) {
g_sword2->_thisScreen.scroll_flag = 2;
- if (g_logic.processSession())
+ if (g_logic->processSession())
error("restart 1st cycle failed??");
// So palette not restored immediately after control panel - we want
diff --git a/sword2/debug.cpp b/sword2/debug.cpp
index 453321c7e0..8d5861eaaa 100644
--- a/sword2/debug.cpp
+++ b/sword2/debug.cpp
@@ -152,7 +152,7 @@ void Debugger::buildDebugText(void) {
sprintf(buf, "pos: %d", _textNumber & 0xffff);
makeDebugTextBlock(buf, 0, 370);
- sprintf(buf, "TEXT: %d", g_logic._officialTextNumber);
+ sprintf(buf, "TEXT: %d", g_logic->_officialTextNumber);
makeDebugTextBlock(buf, 0, 385);
}
}
@@ -269,10 +269,10 @@ void Debugger::buildDebugText(void) {
// "waiting for person" indicator - set form fnTheyDo and
// fnTheyDoWeWait
- if (g_logic._speechScriptWaiting) {
+ if (g_logic->_speechScriptWaiting) {
sprintf(buf, "script waiting for %s (%d)",
- g_sword2->fetchObjectName(g_logic._speechScriptWaiting),
- g_logic._speechScriptWaiting);
+ g_sword2->fetchObjectName(g_logic->_speechScriptWaiting),
+ g_logic->_speechScriptWaiting);
makeDebugTextBlock(buf, 0, 90);
}
@@ -360,7 +360,7 @@ void Debugger::printCurrentInfo(void) {
Debug_Printf("%d wide, %d high\n", g_sword2->_thisScreen.screen_wide, g_sword2->_thisScreen.screen_deep);
Debug_Printf("%d normal layers\n", g_sword2->_thisScreen.number_of_layers);
- g_logic.examineRunList();
+ g_logic->examineRunList();
} else
Debug_Printf("No screen\n");
}
diff --git a/sword2/events.cpp b/sword2/events.cpp
index 0a270283f7..c5924f445a 100644
--- a/sword2/events.cpp
+++ b/sword2/events.cpp
@@ -87,7 +87,7 @@ void Sword2Engine::startEvent(void) {
for (int i = 0; i < MAX_events; i++) {
if (_eventList[i].id == ID) {
// run 3rd script of target object on level 1
- g_logic.logicOne(_eventList[i].interact_id);
+ g_logic->logicOne(_eventList[i].interact_id);
// clear the slot
_eventList[i].id = 0;
diff --git a/sword2/icons.cpp b/sword2/icons.cpp
index f8513a654b..6771bef83c 100644
--- a/sword2/icons.cpp
+++ b/sword2/icons.cpp
@@ -88,7 +88,7 @@ void Sword2Engine::buildMenu(void) {
// objects. Run the 'build_menu' script in the 'menu_master' object
head = res_man->openResource(MENU_MASTER_OBJECT);
- g_logic.runScript((char*) head, (char*) head, &null_pc);
+ g_logic->runScript((char*) head, (char*) head, &null_pc);
res_man->closeResource(MENU_MASTER_OBJECT);
// Compare new with old. Anything in master thats not in new gets
diff --git a/sword2/logic.cpp b/sword2/logic.cpp
index 51346af950..3dd94a7af6 100644
--- a/sword2/logic.cpp
+++ b/sword2/logic.cpp
@@ -31,7 +31,7 @@
namespace Sword2 {
-Logic g_logic;
+Logic *g_logic;
#define LEVEL (_curObjectHub->logic_level)
diff --git a/sword2/logic.h b/sword2/logic.h
index d276c3b1a8..9eda55c624 100644
--- a/sword2/logic.h
+++ b/sword2/logic.h
@@ -25,6 +25,7 @@
#include "sword2/header.h"
#include "sword2/memory.h"
#include "sword2/speech.h"
+#include "sword2/startup.h"
#include "sword2/driver/driver96.h"
namespace Sword2 {
@@ -140,14 +141,36 @@ private:
void getCorrectCdForSpeech(int32 wavId);
#endif
+ uint32 _totalStartups;
+ uint32 _totalScreenManagers;
+ uint32 _startRes;
+
+ struct _startup {
+ char description[MAX_description];
+
+ // id of screen manager object
+ uint32 start_res_id;
+
+ //tell the manager which startup you want (if there are more
+ // than 1) (i.e more than 1 entrance to a screen and/or
+ // seperate game boots)
+ uint32 key;
+ };
+
+ _startup _startList[MAX_starts];
+
+ uint32 initStartMenu(void);
+
public:
Logic() : _globals(NULL), _kills(0), _debugFlag(false),
_smackerLeadOut(0), _sequenceTextLines(0), _speechTime(0),
_animId(0), _leftClickDelay(0), _rightClickDelay(0),
- _defaultResponseId(0), _officialTextNumber(0),
+ _defaultResponseId(0), _totalStartups(0),
+ _totalScreenManagers(0), _officialTextNumber(0),
_speechScriptWaiting(0), _speechTextBlocNo(0),
_choosing(false), _unpauseZone(0) {
memset(_subjectList, 0, sizeof(_subjectList));
+ initStartMenu();
setupOpcodes();
}
@@ -171,6 +194,9 @@ public:
uint32 _unpauseZone;
+ void conPrintStartMenu(void);
+ void conStart(int start);
+
void setGlobalInterpreterVariables(int32 *vars);
int runScript(char *scriptData, char *objectData, uint32 *offset);
@@ -316,7 +342,7 @@ public:
};
-extern Logic g_logic;
+extern Logic *g_logic;
} // End of namespace Sword2
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index a4fd99af90..7957c433b0 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -181,7 +181,7 @@ void Sword2Engine::systemMenuMouse(void) {
pars[0] = 221; // SystemM234 (M234.wav)
pars[1] = FX_LOOP;
- g_logic.fnPlayMusic(pars);
+ g_logic->fnPlayMusic(pars);
// restore proper looping_music_id
_loopingMusicId = safe_looping_music_id;
@@ -254,7 +254,7 @@ void Sword2Engine::systemMenuMouse(void) {
if (_loopingMusicId) {
pars[0] = _loopingMusicId;
pars[1] = FX_LOOP;
- g_logic.fnPlayMusic(pars);
+ g_logic->fnPlayMusic(pars);
// cross-fades into the required music:
// - either a restored game tune
@@ -262,7 +262,7 @@ void Sword2Engine::systemMenuMouse(void) {
// entering control panels
} else {
// stop the control panel music
- g_logic.fnStopMusic(NULL);
+ g_logic->fnStopMusic(NULL);
}
}
}
@@ -604,8 +604,8 @@ void Sword2Engine::normalMouse(void) {
// let the existing interaction continue and
// start fading down - switch the human off too
- g_logic.fnNoHuman(NULL);
- g_logic.fnFadeDown(NULL);
+ g_logic->fnNoHuman(NULL);
+ g_logic->fnFadeDown(NULL);
EXIT_FADING = 1; // tell the walker
} else if (_oldButton == _buttonClick && _mouseTouching == CLICKED_ID && _mousePointerRes != NORMAL_MOUSE_ID) {
// re-click - do nothing - except on floors
diff --git a/sword2/resman.cpp b/sword2/resman.cpp
index 79cf76d7a6..4da9dc4ee6 100644
--- a/sword2/resman.cpp
+++ b/sword2/resman.cpp
@@ -979,7 +979,7 @@ void ResourceManager::cacheNewCluster(uint32 newCluster) {
// down - but if we restored to a different CD the music is stopped
// in getCd() when it asks for the CD
- g_logic.fnStopMusic(NULL);
+ g_logic->fnStopMusic(NULL);
g_sword2->clearFxQueue(); // stops all fx & clears the queue (James22july97)
getCd(_cdTab[newCluster] & 3);
@@ -1282,7 +1282,7 @@ void ResourceManager::getCd(int cd) {
// current CD - otherwise when we take out the CD, Windows will
// complain!
- g_logic.fnStopMusic(NULL);
+ g_logic->fnStopMusic(NULL);
textRes = openResource(2283);
g_sword2->displayMsg(g_sword2->fetchTextLine(textRes, 5 + cd) + 2, 0);
diff --git a/sword2/save_rest.cpp b/sword2/save_rest.cpp
index 7c95c6ddaf..169d5af1a9 100644
--- a/sword2/save_rest.cpp
+++ b/sword2/save_rest.cpp
@@ -148,7 +148,7 @@ void Sword2Engine::fillSaveBuffer(mem *buffer, uint32 size, uint8 *desc) {
g_header.screenId = _thisScreen.background_layer_id;
// resource id of current run-list
- g_header.runListId = g_logic.getRunList();
+ g_header.runListId = g_logic->getRunList();
// those scroll position control things
g_header.feet_x = _thisScreen.feet_x;
@@ -346,7 +346,7 @@ uint32 Sword2Engine::restoreFromBuffer(mem *buffer, uint32 size) {
res_man->killAll(false);
// clean out the system kill list (no more objects to kill)
- g_logic.resetKillList();
+ g_logic->resetKillList();
// get player character data from savegame buffer
@@ -383,7 +383,7 @@ uint32 Sword2Engine::restoreFromBuffer(mem *buffer, uint32 size) {
pars[0] = g_header.screenId;
pars[1] = 1;
- g_logic.fnInitBackground(pars);
+ g_logic->fnInitBackground(pars);
// So palette not restored immediately after control panel - we want to
// fade up instead!
@@ -396,7 +396,7 @@ uint32 Sword2Engine::restoreFromBuffer(mem *buffer, uint32 size) {
_thisScreen.feet_y = g_header.feet_y;
// start the new run list
- g_logic.expressChangeSession(g_header.runListId);
+ g_logic->expressChangeSession(g_header.runListId);
// Force in the new scroll position, so unsightly scroll-catch-up does
// not occur when screen first draws after returning from restore panel
@@ -484,7 +484,7 @@ void Sword2Engine::getPlayerStructures(void) {
error("incorrect CUR_PLAYER_ID=%d", CUR_PLAYER_ID);
raw_script_ad = (char *) head;
- g_logic.runScript(raw_script_ad, raw_script_ad, &null_pc);
+ g_logic->runScript(raw_script_ad, raw_script_ad, &null_pc);
res_man->closeResource(CUR_PLAYER_ID);
}
@@ -507,12 +507,12 @@ void Sword2Engine::putPlayerStructures(void) {
// script no. 8 - 'george_savedata_return' calls fnGetPlayerSaveData
null_pc = 8;
- g_logic.runScript(raw_script_ad, raw_script_ad, &null_pc);
+ g_logic->runScript(raw_script_ad, raw_script_ad, &null_pc);
// script no. 14 - 'set_up_nico_anim_tables'
null_pc = 14;
- g_logic.runScript(raw_script_ad, raw_script_ad, &null_pc);
+ g_logic->runScript(raw_script_ad, raw_script_ad, &null_pc);
// which megaset was the player at the time of saving?
@@ -534,7 +534,7 @@ void Sword2Engine::putPlayerStructures(void) {
break;
}
- g_logic.runScript(raw_script_ad, raw_script_ad, &null_pc);
+ g_logic->runScript(raw_script_ad, raw_script_ad, &null_pc);
res_man->closeResource(CUR_PLAYER_ID);
}
diff --git a/sword2/startup.cpp b/sword2/startup.cpp
index cdc8699f61..19cb2838dd 100644
--- a/sword2/startup.cpp
+++ b/sword2/startup.cpp
@@ -40,13 +40,7 @@
namespace Sword2 {
-uint32 total_startups = 0;
-uint32 total_screen_managers = 0;
-uint32 res;
-
-_startup start_list[MAX_starts];
-
-uint32 Init_start_menu(void) {
+uint32 Logic::initStartMenu(void) {
// Print out a list of all the start points available.
// There should be a linc produced file called startup.txt.
// This file should contain ascii numbers of all the resource game
@@ -65,7 +59,7 @@ uint32 Init_start_menu(void) {
// ok, load in the master screen manager file
- total_startups = 0; // no starts
+ _totalStartups = 0; // no starts
debug(5, "initialising start menu");
@@ -79,13 +73,13 @@ uint32 Init_start_menu(void) {
do {
while (temp->ad[j] != 13) { // item must have an #0d0a
- ascii_start_ids[total_screen_managers][pos] = temp->ad[j];
+ ascii_start_ids[_totalScreenManagers][pos] = temp->ad[j];
j++;
pos++;
}
// NULL terminate our extracted string
- ascii_start_ids[total_screen_managers][pos] = 0;
+ ascii_start_ids[_totalScreenManagers][pos] = 0;
// reset position in current slot between entries
pos = 0;
@@ -94,9 +88,9 @@ uint32 Init_start_menu(void) {
j += 2;
// done another
- total_screen_managers++;
+ _totalScreenManagers++;
- if (total_screen_managers == MAX_starts) {
+ if (_totalScreenManagers == MAX_starts) {
debug(5, "WARNING MAX_starts exceeded!");
break;
}
@@ -105,34 +99,34 @@ uint32 Init_start_menu(void) {
// using this method the Gode generated resource.inf must have #0d0a
// on the last entry
- debug(5, "%d screen manager objects", total_screen_managers);
+ debug(5, "%d screen manager objects", _totalScreenManagers);
// Open each object and make a query call. The object must fill in a
// startup structure. It may fill in several if it wishes - for
// instance a startup could be set for later in the game where
// specific vars are set
- for (j = 0; j < total_screen_managers; j++) {
- res = atoi(ascii_start_ids[j]);
+ for (j = 0; j < _totalScreenManagers; j++) {
+ _startRes = atoi(ascii_start_ids[j]);
- debug(5, "+querying screen manager %d", res);
+ debug(5, "+querying screen manager %d", _startRes);
// resopen each one and run through the interpretter
// script 0 is the query request script
// if the resource number is within range & it's not a null
- // resource (James 12mar97)
+ // resource
// - need to check in case un-built sections included in
// start list
- if (res_man->checkValid(res)) {
- debug(5, "- resource %d ok", res);
- raw_script = (char*) res_man->openResource(res);
+ if (res_man->checkValid(_startRes)) {
+ debug(5, "- resource %d ok", _startRes);
+ raw_script = (char*) res_man->openResource(_startRes);
null_pc = 0;
- g_logic.runScript(raw_script, raw_script, &null_pc);
- res_man->closeResource(res);
+ runScript(raw_script, raw_script, &null_pc);
+ res_man->closeResource(_startRes);
} else
- debug(5, "- resource %d invalid", res);
+ debug(5, "- resource %d invalid", _startRes);
}
memory->freeMemory(temp);
@@ -145,8 +139,8 @@ int32 Logic::fnRegisterStartPoint(int32 *params) {
// 1 pointer to ascii message
#ifdef _SWORD2_DEBUG
- if (total_startups == MAX_starts)
- error("ERROR: start_list full");
+ if (_totalStartups == MAX_starts)
+ error("ERROR: _startList full");
// +1 to allow for NULL terminator
if (strlen((char*) params[1]) + 1 > MAX_description)
@@ -154,45 +148,45 @@ int32 Logic::fnRegisterStartPoint(int32 *params) {
#endif
// this objects id
- start_list[total_startups].start_res_id = res;
+ _startList[_totalStartups].start_res_id = _startRes;
// a key code to be passed to a script via a script var to SWITCH in
// the correct start
- start_list[total_startups].key = params[0];
+ _startList[_totalStartups].key = params[0];
- strcpy(start_list[total_startups].description, (char*) params[1]);
+ strcpy(_startList[_totalStartups].description, (char*) params[1]);
// point to next
- total_startups++;
+ _totalStartups++;
return 1;
}
-void Con_print_start_menu(void) {
+void Logic::conPrintStartMenu(void) {
// the console 'starts' (or 's') command which lists out all the
// registered start points in the game
- if (!total_startups) {
+ if (!_totalStartups) {
Debug_Printf("Sorry - no startup positions registered?\n");
- if (!total_screen_managers)
+ if (!_totalScreenManagers)
Debug_Printf("There is a problem with startup.inf\n");
else
- Debug_Printf(" (%d screen managers found in startup.inf)\n", total_screen_managers);
+ Debug_Printf(" (%d screen managers found in startup.inf)\n", _totalScreenManagers);
} else {
- for (uint i = 0; i < total_startups; i++)
- Debug_Printf("%d (%s)\n", i, start_list[i].description);
+ for (uint i = 0; i < _totalStartups; i++)
+ Debug_Printf("%d (%s)\n", i, _startList[i].description);
}
}
-void Con_start(int start) {
+void Logic::conStart(int start) {
char *raw_script;
char *raw_data_ad;
uint32 null_pc;
- if (!total_startups)
+ if (!_totalStartups)
Debug_Printf("Sorry - there are no startups!\n");
- else if (start >= 0 && start < (int) total_startups) {
+ else if (start >= 0 && start < (int) _totalStartups) {
// do the startup as we've specified a legal start
// restarting - stop sfx, music & speech!
@@ -200,14 +194,14 @@ void Con_start(int start) {
g_sword2->clearFxQueue();
// fade out any music that is currently playing
- g_logic.fnStopMusic(NULL);
+ fnStopMusic(NULL);
// halt the sample prematurely
g_sound->unpauseSpeech();
g_sound->stopSpeech();
// clean out all resources & flags, ready for a total
- // restart (James24mar97)
+ // restart
// remove all resources from memory, including player
// object & global variables
@@ -216,38 +210,38 @@ void Con_start(int start) {
// reopen global variables resource & send address to
// interpreter - it won't be moving
- g_logic.setGlobalInterpreterVariables((int32 *) (res_man->openResource(1) + sizeof(_standardHeader)));
+ setGlobalInterpreterVariables((int32 *) (res_man->openResource(1) + sizeof(_standardHeader)));
res_man->closeResource(1);
// free all the route memory blocks from previous game
router.freeAllRouteMem();
// if there was speech text, kill the text block
- if (g_logic._speechTextBlocNo) {
- fontRenderer.killTextBloc(g_logic._speechTextBlocNo);
- g_logic._speechTextBlocNo = 0;
+ if (_speechTextBlocNo) {
+ fontRenderer.killTextBloc(_speechTextBlocNo);
+ _speechTextBlocNo = 0;
}
// set the key
// Open George
raw_data_ad = (char *) res_man->openResource(8);
- raw_script = (char *) res_man->openResource(start_list[start].start_res_id);
+ raw_script = (char *) res_man->openResource(_startList[start].start_res_id);
// denotes script to run
- null_pc = start_list[start].key & 0xffff;
+ null_pc = _startList[start].key & 0xffff;
Debug_Printf("Running start %d\n", start);
- g_logic.runScript(raw_script, raw_data_ad, &null_pc);
+ runScript(raw_script, raw_data_ad, &null_pc);
- res_man->closeResource(start_list[start].start_res_id);
+ res_man->closeResource(_startList[start].start_res_id);
// Close George
res_man->closeResource(8);
// make sure thre's a mouse, in case restarting while
// mouse not available
- g_logic.fnAddHuman(NULL);
+ fnAddHuman(NULL);
} else
Debug_Printf("Not a legal start position\n");
}
diff --git a/sword2/startup.h b/sword2/startup.h
index aaf3588655..5501a657d9 100644
--- a/sword2/startup.h
+++ b/sword2/startup.h
@@ -20,28 +20,10 @@
#ifndef _STARTUP
#define _STARTUP
-namespace Sword2 {
-
#define MAX_starts 100
#define MAX_description 100
-typedef struct {
- char description[MAX_description];
-
- // id of screen manager object
- uint32 start_res_id;
-
- //tell the manager which startup you want (if there are more than 1)
- // (i.e more than 1 entrance to a screen and/or seperate game boots)
- uint32 key;
-} _startup;
-
-extern _startup start_list[MAX_starts];
-
-uint32 Init_start_menu(void);
-void Con_print_start_menu(void);
-void Con_start(int start);
-
+namespace Sword2 {
} // End of namespace Sword2
#endif
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index 07705a49c0..d3909b8024 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -138,6 +138,7 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst)
memory = new MemoryManager();
res_man = new ResourceManager();
+ g_logic = new Logic();
g_sound = _sound = new Sound(_mixer);
g_display = _display = new Display(640, 480);
gui = new Gui();
@@ -196,6 +197,7 @@ Sword2Engine::~Sword2Engine() {
delete _display;
delete _debugger;
delete gui;
+ delete g_logic;
delete res_man;
delete memory;
}
@@ -226,7 +228,7 @@ int32 Sword2Engine::InitialiseGame(void) {
// res 1 is the globals list
file = res_man->openResource(1);
debug(5, "CALLING: SetGlobalInterpreterVariables");
- g_logic.setGlobalInterpreterVariables((int32 * ) (file + sizeof(_standardHeader)));
+ g_logic->setGlobalInterpreterVariables((int32 * ) (file + sizeof(_standardHeader)));
// DON'T CLOSE VARIABLES RESOURCE - KEEP IT OPEN AT VERY START OF
// MEMORY SO IT CAN'T MOVE!
@@ -241,11 +243,6 @@ int32 Sword2Engine::InitialiseGame(void) {
debug(5, "CALLING: initialiseFontResourceFlags");
initialiseFontResourceFlags();
- // read in all the startup information
-
- debug(5, "CALLING: Init_start_menu");
- Init_start_menu();
-
debug(5, "CALLING: Init_sync_system");
Init_sync_system();
@@ -279,7 +276,7 @@ int32 GameCycle(void) {
// do one game cycle
// got a screen to run?
- if (g_logic.getRunList()) {
+ if (g_logic->getRunList()) {
//run the logic session UNTIL a full loop has been performed
do {
// reset the graphic 'buildit' list before a new
@@ -292,7 +289,7 @@ int32 GameCycle(void) {
// keep going as long as new lists keep getting put in
// - i.e. screen changes
- } while (g_logic.processSession());
+ } while (g_logic->processSession());
} else {
// start the console and print the start options perhaps?
g_sword2->_debugger->attach("AWAITING START COMMAND: (Enter 's 1' then 'q' to start from beginning)");
@@ -413,7 +410,7 @@ void Sword2Engine::go() {
// 'P' while not paused = pause!
PauseGame();
} else if (c == 'C' && !(_features & GF_DEMO)) {
- g_logic.fnPlayCredits(NULL);
+ g_logic->fnPlayCredits(NULL);
}
#ifdef _SWORD2_DEBUG
else if (c == 'S') {
@@ -490,7 +487,7 @@ void Sword2Engine::Start_game(void) {
raw_script = (char *) res_man->openResource(screen_manager_id);
// run the start script now (because no console)
- g_logic.runScript(raw_script, raw_data_ad, &null_pc);
+ g_logic->runScript(raw_script, raw_data_ad, &null_pc);
// close the ScreenManager object
res_man->closeResource(screen_manager_id);
@@ -580,10 +577,10 @@ void UnpauseGame(void) {
}
gamePaused = 0;
- g_logic._unpauseZone = 2;
+ g_logic->_unpauseZone = 2;
// if mouse is about or we're in a chooser menu
- if (!g_sword2->_mouseStatus || g_logic._choosing)
+ if (!g_sword2->_mouseStatus || g_logic->_choosing)
g_sword2->setMouse(NORMAL_MOUSE_ID);
}