Major clean-up, including:
- Cutting down the code-dup - Plucking leaks - Removing dead/unused code - Properly naming "word_2342F"-style variables and functions (removing the warnings alongside) - Fleshing out the "stubby" functions - Moving functions and variables to more appropriate/logical places - Re-ordering functions and variables - Re-structuring functions - Moving the IMD stuff into a new "Imd" class in the new imd.cpp/.h (still to be completely implemented and cleaned up) - Formatting - Getting rid off the classes "Anim", "Pack" and "Timer", along with their files svn-id: r26252
This commit is contained in:
parent
d94979c936
commit
2dc7cb2cd4
70 changed files with 10954 additions and 12610 deletions
|
@ -25,89 +25,52 @@
|
|||
#include "common/endian.h"
|
||||
|
||||
#include "gob/gob.h"
|
||||
#include "gob/dataio.h"
|
||||
#include "gob/global.h"
|
||||
#include "gob/init.h"
|
||||
#include "gob/video.h"
|
||||
#include "gob/sound.h"
|
||||
#include "gob/timer.h"
|
||||
#include "gob/sound.h"
|
||||
#include "gob/game.h"
|
||||
#include "gob/draw.h"
|
||||
#include "gob/global.h"
|
||||
#include "gob/util.h"
|
||||
#include "gob/dataio.h"
|
||||
#include "gob/cdrom.h"
|
||||
#include "gob/draw.h"
|
||||
#include "gob/game.h"
|
||||
#include "gob/sound.h"
|
||||
#include "gob/video.h"
|
||||
|
||||
namespace Gob {
|
||||
|
||||
void game_start(void);
|
||||
|
||||
const char *Init::_fontNames[] = { "jeulet1.let", "jeulet2.let", "jeucar1.let", "jeumath.let" };
|
||||
|
||||
Init::Init(GobEngine *vm) : _vm(vm) {
|
||||
_palDesc = 0;
|
||||
}
|
||||
|
||||
void Init::findBestCfg(void) {
|
||||
_vm->_global->_videoMode = VIDMODE_VGA;
|
||||
_vm->_global->_useMouse = _vm->_global->_mousePresent;
|
||||
_vm->_global->_soundFlags = MIDI_FLAG | SPEAKER_FLAG | BLASTER_FLAG | ADLIB_FLAG;
|
||||
}
|
||||
|
||||
void Init::cleanup(void) {
|
||||
if (_vm->_global->_debugFlag == 0)
|
||||
_vm->_gtimer->disableTimer();
|
||||
|
||||
_vm->_video->freeDriver();
|
||||
_vm->_video->freeSurfDesc(_vm->_global->_pPrimarySurfDesc);
|
||||
_vm->_global->_pPrimarySurfDesc = 0;
|
||||
_vm->_global->_primarySurfDesc = 0;
|
||||
|
||||
_vm->_snd->speakerOff();
|
||||
|
||||
_vm->_dataio->closeDataFile();
|
||||
|
||||
if (_vm->_global->_sprAllocated != 0)
|
||||
warning("cleanup: Allocated sprites left: %d", _vm->_global->_sprAllocated);
|
||||
|
||||
_vm->_snd->stopSound(0);
|
||||
_vm->_dataIO->closeDataFile();
|
||||
}
|
||||
|
||||
void Init::initGame(char *totName) {
|
||||
int16 handle2;
|
||||
int16 handle;
|
||||
int32 i;
|
||||
char *infBuf;
|
||||
char *infPtr;
|
||||
char *infEnd;
|
||||
int16 j;
|
||||
char buffer[20];
|
||||
int32 varsCount;
|
||||
/*
|
||||
src = byte ptr -2Eh
|
||||
var_1A = word ptr -1Ah
|
||||
var_18 = word ptr -18h
|
||||
var_16 = dword ptr -16h
|
||||
var_12 = word ptr -12h
|
||||
var_10 = word ptr -10h
|
||||
handle2 = word ptr -0Eh
|
||||
fileHandle = word ptr -0Ch
|
||||
numFromTot = word ptr -0Ah
|
||||
memAvail = dword ptr -6
|
||||
memBlocks = word ptr -2*/
|
||||
|
||||
_vm->_global->_disableVideoCfg = 0x11;
|
||||
_vm->_global->_disableMouseCfg = 0x15;
|
||||
initVideo();
|
||||
|
||||
soundVideo(1000, 1);
|
||||
|
||||
handle2 = _vm->_dataio->openData("intro.stk");
|
||||
handle2 = _vm->_dataIO->openData("intro.stk");
|
||||
if (handle2 >= 0) {
|
||||
_vm->_dataio->closeData(handle2);
|
||||
_vm->_dataio->openDataFile("intro.stk");
|
||||
_vm->_dataIO->closeData(handle2);
|
||||
_vm->_dataIO->openDataFile("intro.stk");
|
||||
}
|
||||
|
||||
_vm->_util->initInput();
|
||||
|
||||
_vm->_video->setHandlers();
|
||||
_vm->_video->initPrimary(_vm->_global->_videoMode);
|
||||
_vm->_global->_mouseXShift = 1;
|
||||
_vm->_global->_mouseYShift = 1;
|
||||
|
@ -119,74 +82,71 @@ memBlocks = word ptr -2*/
|
|||
_vm->_global->_inter_variablesSizes = 0;
|
||||
_palDesc = new Video::PalDesc;
|
||||
|
||||
if ((_vm->_global->_videoMode != 0x13) && (_vm->_global->_videoMode != 0x14))
|
||||
error("initGame: Only 0x13 or 0x14 video mode is supported!");
|
||||
_vm->validateVideoMode(_vm->_global->_videoMode);
|
||||
|
||||
_vm->_global->_setAllPalette = true;
|
||||
_palDesc->vgaPal = _vm->_draw->_vgaPalette;
|
||||
_palDesc->unused1 = _vm->_draw->_unusedPalette1;
|
||||
_palDesc->unused2 = _vm->_draw->_unusedPalette2;
|
||||
_vm->_video->setFullPalette(_palDesc);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
for (int i = 0; i < 8; i++)
|
||||
_vm->_draw->_fonts[i] = 0;
|
||||
|
||||
handle = _vm->_dataio->openData("intro.inf");
|
||||
handle = _vm->_dataIO->openData("intro.inf");
|
||||
|
||||
if (handle < 0) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
handle2 = _vm->_dataio->openData(_fontNames[i]);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
handle2 = _vm->_dataIO->openData(_fontNames[i]);
|
||||
if (handle2 >= 0) {
|
||||
_vm->_dataio->closeData(handle2);
|
||||
_vm->_draw->_fonts[i] =
|
||||
_vm->_util->loadFont(_fontNames[i]);
|
||||
_vm->_dataIO->closeData(handle2);
|
||||
_vm->_draw->_fonts[i] = _vm->_util->loadFont(_fontNames[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_vm->_dataio->closeData(handle);
|
||||
_vm->_dataIO->closeData(handle);
|
||||
|
||||
infPtr = _vm->_dataio->getData("intro.inf");
|
||||
infPtr = _vm->_dataIO->getData("intro.inf");
|
||||
infBuf = infPtr;
|
||||
|
||||
infEnd = infBuf + _vm->_dataio->getDataSize("intro.inf");
|
||||
infEnd = infBuf + _vm->_dataIO->getDataSize("intro.inf");
|
||||
|
||||
for (i = 0; i < 4; i++, infPtr++) {
|
||||
for (j = 0; infPtr < infEnd && *infPtr >= ' ';
|
||||
j++, infPtr++)
|
||||
for (int i = 0; i < 4; i++, infPtr++) {
|
||||
int j;
|
||||
|
||||
for (j = 0; infPtr < infEnd && *infPtr >= ' '; j++, infPtr++)
|
||||
buffer[j] = *infPtr;
|
||||
|
||||
buffer[j] = 0;
|
||||
|
||||
strcat(buffer, ".let");
|
||||
handle2 = _vm->_dataio->openData(buffer);
|
||||
handle2 = _vm->_dataIO->openData(buffer);
|
||||
if (handle2 >= 0) {
|
||||
_vm->_dataio->closeData(handle2);
|
||||
_vm->_dataIO->closeData(handle2);
|
||||
_vm->_draw->_fonts[i] = _vm->_util->loadFont(buffer);
|
||||
}
|
||||
|
||||
if (infPtr == infEnd)
|
||||
if ((infPtr + 1) >= infEnd)
|
||||
break;
|
||||
|
||||
infPtr++;
|
||||
if (infPtr == infEnd)
|
||||
break;
|
||||
}
|
||||
delete[] infBuf;
|
||||
}
|
||||
|
||||
if (totName != 0) {
|
||||
if (totName) {
|
||||
strcpy(buffer, totName);
|
||||
strcat(buffer, ".tot");
|
||||
} else {
|
||||
} else
|
||||
strcpy(buffer, _vm->_startTot);
|
||||
}
|
||||
|
||||
handle = _vm->_dataio->openData(buffer);
|
||||
handle = _vm->_dataIO->openData(buffer);
|
||||
|
||||
if (handle >= 0) {
|
||||
// Get variables count
|
||||
_vm->_dataio->seekData(handle, 0x2c, SEEK_SET);
|
||||
_vm->_dataio->readData(handle, (char *)&varsCount, 2);
|
||||
_vm->_dataIO->seekData(handle, 0x2C, SEEK_SET);
|
||||
_vm->_dataIO->readData(handle, (char *) &varsCount, 2);
|
||||
varsCount = FROM_LE_16(varsCount);
|
||||
_vm->_dataio->closeData(handle);
|
||||
_vm->_dataIO->closeData(handle);
|
||||
|
||||
_vm->_global->_inter_variables = new char[varsCount * 4];
|
||||
_vm->_global->_inter_variablesSizes = new byte[varsCount * 4];
|
||||
|
@ -216,15 +176,15 @@ memBlocks = word ptr -2*/
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (_vm->_draw->_fonts[i] != 0)
|
||||
_vm->_util->freeFont(_vm->_draw->_fonts[i]);
|
||||
}
|
||||
|
||||
delete _palDesc;
|
||||
_vm->_dataio->closeDataFile();
|
||||
_vm->_dataIO->closeDataFile();
|
||||
_vm->_video->initPrimary(-1);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
} // End of namespace Gob
|
||||
} // End of namespace Gob
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue