SLUDGE: Reset engine when launching a new game data file
This commit is contained in:
parent
4783541529
commit
867b8dbb92
24 changed files with 313 additions and 133 deletions
|
@ -36,13 +36,22 @@ namespace Sludge {
|
|||
|
||||
CursorManager::CursorManager(SludgeEngine *vm) {
|
||||
_vm = vm;
|
||||
init();
|
||||
}
|
||||
|
||||
CursorManager::~CursorManager() {
|
||||
kill();
|
||||
}
|
||||
|
||||
void CursorManager::init() {
|
||||
_mouseCursorAnim = makeNullAnim();
|
||||
_mouseCursorFrameNum = 0;
|
||||
_mouseCursorCountUp = 0;
|
||||
}
|
||||
|
||||
CursorManager::~CursorManager() {
|
||||
|
||||
void CursorManager::kill() {
|
||||
deleteAnim(_mouseCursorAnim);
|
||||
_mouseCursorAnim = nullptr;
|
||||
}
|
||||
|
||||
void CursorManager::pickAnimCursor(PersonaAnimation *pp) {
|
||||
|
|
|
@ -34,6 +34,9 @@ public:
|
|||
CursorManager(SludgeEngine *vm);
|
||||
virtual ~CursorManager();
|
||||
|
||||
void init();
|
||||
void kill();
|
||||
|
||||
// cursor
|
||||
void pickAnimCursor(struct PersonaAnimation *pp);
|
||||
void displayCursor();
|
||||
|
|
|
@ -127,18 +127,18 @@ static const SludgeGameDescription gameDescriptions[] = {
|
|||
0
|
||||
},
|
||||
|
||||
// {
|
||||
// {
|
||||
// "tgttpoacs",
|
||||
// "",
|
||||
// AD_ENTRY1s("gamedata", "d5ec4d7d8440f7744335d25d25e1e943", 40368),
|
||||
// Common::EN_ANY,
|
||||
// Common::kPlatformWindows,
|
||||
// ADGF_NO_FLAGS,
|
||||
// GUIO0()
|
||||
// },
|
||||
// 0
|
||||
// },
|
||||
{
|
||||
{
|
||||
"tgttpoacs",
|
||||
"",
|
||||
AD_ENTRY1s("gamedata", "d5ec4d7d8440f7744335d25d25e1e943", 40368),
|
||||
Common::EN_ANY,
|
||||
Common::kPlatformWindows,
|
||||
ADGF_NO_FLAGS,
|
||||
GUIO0()
|
||||
},
|
||||
0
|
||||
},
|
||||
|
||||
{
|
||||
{
|
||||
|
@ -205,18 +205,18 @@ static const SludgeGameDescription gameDescriptions[] = {
|
|||
3
|
||||
},
|
||||
|
||||
// {
|
||||
// {
|
||||
// "cubert",
|
||||
// "",
|
||||
// AD_ENTRY1s("gamedata", "0078eb54f63cc0a22e50f17d904fcfde", 26799),
|
||||
// Common::UNK_LANG,
|
||||
// Common::kPlatformWindows,
|
||||
// ADGF_NO_FLAGS,
|
||||
// GUIO0()
|
||||
// },
|
||||
// 0
|
||||
// },
|
||||
{
|
||||
{
|
||||
"cubert",
|
||||
"",
|
||||
AD_ENTRY1s("gamedata", "0078eb54f63cc0a22e50f17d904fcfde", 26799),
|
||||
Common::UNK_LANG,
|
||||
Common::kPlatformWindows,
|
||||
ADGF_NO_FLAGS,
|
||||
GUIO0()
|
||||
},
|
||||
0
|
||||
},
|
||||
|
||||
{
|
||||
{
|
||||
|
|
|
@ -41,21 +41,31 @@ extern ScreenRegion *lastRegion;
|
|||
|
||||
EventManager::EventManager(SludgeEngine *vm) {
|
||||
_vm = vm;
|
||||
_currentEvents = new EventHandlers;
|
||||
init();
|
||||
}
|
||||
|
||||
EventManager::~EventManager() {
|
||||
kill();
|
||||
if (_currentEvents) {
|
||||
delete _currentEvents;
|
||||
_currentEvents = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EventManager::init() {
|
||||
_weAreDoneSoQuit = 0;
|
||||
_reallyWantToQuit = false;
|
||||
|
||||
_input.leftClick = _input.rightClick = _input.justMoved = _input.leftRelease = _input.rightRelease = false;
|
||||
_input.keyPressed = 0;
|
||||
|
||||
_currentEvents = new EventHandlers;
|
||||
for (uint i = 0; i < EVENT_FUNC_NB; ++i) {
|
||||
_currentEvents->func[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
EventManager::~EventManager() {
|
||||
|
||||
void EventManager::kill() {
|
||||
}
|
||||
|
||||
void EventManager::checkInput() {
|
||||
|
|
|
@ -56,6 +56,9 @@ public:
|
|||
EventManager(SludgeEngine *vm);
|
||||
virtual ~EventManager();
|
||||
|
||||
void init();
|
||||
void kill();
|
||||
|
||||
// Input
|
||||
void checkInput();
|
||||
bool handleInput();
|
||||
|
|
|
@ -31,6 +31,30 @@
|
|||
|
||||
namespace Sludge {
|
||||
|
||||
ResourceManager::ResourceManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
ResourceManager::~ResourceManager() {
|
||||
kill();
|
||||
}
|
||||
|
||||
void ResourceManager::init() {
|
||||
_sliceBusy = true;
|
||||
_bigDataFile = nullptr;
|
||||
_startOfDataIndex = 0;
|
||||
_startOfTextIndex = 0;
|
||||
_startOfSubIndex = 0;
|
||||
_startOfObjectIndex = 0;
|
||||
_startIndex = 0;
|
||||
}
|
||||
void ResourceManager::kill() {
|
||||
if (_bigDataFile) {
|
||||
delete _bigDataFile;
|
||||
_bigDataFile = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool ResourceManager::openSubSlice(int num) {
|
||||
if (_sliceBusy) {
|
||||
fatal("Can't read from data file", "I'm already reading something");
|
||||
|
|
|
@ -29,14 +29,11 @@ namespace Sludge {
|
|||
class ResourceManager {
|
||||
|
||||
public:
|
||||
ResourceManager():
|
||||
_sliceBusy(true),
|
||||
_bigDataFile(0),
|
||||
_startOfDataIndex(0),
|
||||
_startOfTextIndex(0),
|
||||
_startOfSubIndex(0),
|
||||
_startOfObjectIndex(0),
|
||||
_startIndex(0) {}
|
||||
ResourceManager();
|
||||
~ResourceManager();
|
||||
|
||||
void init();
|
||||
void kill();
|
||||
|
||||
void setData(Common::File *readStream);
|
||||
void setFileIndices(uint, uint);
|
||||
|
|
|
@ -105,16 +105,18 @@ bool initFloor() {
|
|||
}
|
||||
|
||||
void killFloor() {
|
||||
for (int i = 0; i < currentFloor->numPolygons; i++) {
|
||||
delete []currentFloor->polygon[i].vertexID;
|
||||
delete []currentFloor->matrix[i];
|
||||
if (currentFloor) {
|
||||
for (int i = 0; i < currentFloor->numPolygons; i++) {
|
||||
delete []currentFloor->polygon[i].vertexID;
|
||||
delete []currentFloor->matrix[i];
|
||||
}
|
||||
delete []currentFloor->polygon;
|
||||
currentFloor->polygon = NULL;
|
||||
delete []currentFloor->vertex;
|
||||
currentFloor->vertex = NULL;
|
||||
delete []currentFloor->matrix;
|
||||
currentFloor->matrix = NULL;
|
||||
}
|
||||
delete []currentFloor->polygon;
|
||||
currentFloor->polygon = NULL;
|
||||
delete []currentFloor->vertex;
|
||||
currentFloor->vertex = NULL;
|
||||
delete []currentFloor->matrix;
|
||||
currentFloor->matrix = NULL;
|
||||
}
|
||||
|
||||
void setFloorNull() {
|
||||
|
|
|
@ -32,6 +32,14 @@
|
|||
namespace Sludge {
|
||||
|
||||
TextManager::TextManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
TextManager::~TextManager() {
|
||||
kill();
|
||||
}
|
||||
|
||||
void TextManager::init() {
|
||||
_theFont.total = 0;
|
||||
_theFont.sprites = nullptr;
|
||||
|
||||
|
@ -43,8 +51,8 @@ TextManager::TextManager() {
|
|||
_fontTable.clear();
|
||||
}
|
||||
|
||||
TextManager::~TextManager() {
|
||||
g_sludge->_gfxMan->forgetSpriteBank(_theFont);
|
||||
void TextManager::kill() {
|
||||
GraphicsManager::forgetSpriteBank(_theFont);
|
||||
}
|
||||
|
||||
bool TextManager::isInFont(const Common::String &theText) {
|
||||
|
|
|
@ -38,6 +38,9 @@ public:
|
|||
TextManager();
|
||||
virtual ~TextManager();
|
||||
|
||||
void init();
|
||||
void kill();
|
||||
|
||||
int stringWidth(const Common::String &theText);
|
||||
int stringLength(const Common::String &theText);
|
||||
|
||||
|
|
|
@ -37,7 +37,14 @@ namespace Sludge {
|
|||
|
||||
GraphicsManager::GraphicsManager(SludgeEngine *vm) {
|
||||
_vm = vm;
|
||||
init();
|
||||
}
|
||||
|
||||
GraphicsManager::~GraphicsManager() {
|
||||
kill();
|
||||
}
|
||||
|
||||
void GraphicsManager::init() {
|
||||
// Init screen surface
|
||||
_winWidth = _sceneWidth = 640;
|
||||
_winHeight = _sceneHeight = 480;
|
||||
|
@ -78,11 +85,13 @@ GraphicsManager::GraphicsManager(SludgeEngine *vm) {
|
|||
_currentBurnB = 0;
|
||||
}
|
||||
|
||||
GraphicsManager::~GraphicsManager() {
|
||||
void GraphicsManager::kill() {
|
||||
// kill parallax
|
||||
killParallax();
|
||||
delete _parallaxStuff;
|
||||
_parallaxStuff = nullptr;
|
||||
if (_parallaxStuff) {
|
||||
_parallaxStuff->kill();
|
||||
delete _parallaxStuff;
|
||||
_parallaxStuff = nullptr;
|
||||
}
|
||||
|
||||
// kill frozen stuff
|
||||
FrozenStuffStruct *killMe = _frozenStuff;
|
||||
|
@ -98,9 +107,11 @@ GraphicsManager::~GraphicsManager() {
|
|||
}
|
||||
|
||||
// kill sprite layers
|
||||
killSpriteLayers();
|
||||
delete _spriteLayers;
|
||||
_spriteLayers = nullptr;
|
||||
if (_spriteLayers) {
|
||||
killSpriteLayers();
|
||||
delete _spriteLayers;
|
||||
_spriteLayers = nullptr;
|
||||
}
|
||||
|
||||
// kill sprite banks
|
||||
LoadedSpriteBanks::iterator it;
|
||||
|
@ -111,9 +122,11 @@ GraphicsManager::~GraphicsManager() {
|
|||
_allLoadedBanks.clear();
|
||||
|
||||
// kill zbuffer
|
||||
killZBuffer();
|
||||
delete _zBuffer;
|
||||
_zBuffer = nullptr;
|
||||
if (_zBuffer) {
|
||||
killZBuffer();
|
||||
delete _zBuffer;
|
||||
_zBuffer = nullptr;
|
||||
}
|
||||
|
||||
// kill surfaces
|
||||
if (_renderSurface.getPixels())
|
||||
|
@ -129,13 +142,15 @@ GraphicsManager::~GraphicsManager() {
|
|||
_origBackdropSurface.free();
|
||||
}
|
||||
|
||||
bool GraphicsManager::init() {
|
||||
bool GraphicsManager::initGfx() {
|
||||
initGraphics(_winWidth, _winHeight, true, _vm->getScreenPixelFormat());
|
||||
_renderSurface.create(_winWidth, _winHeight, *_vm->getScreenPixelFormat());
|
||||
|
||||
if (!killResizeBackdrop(_winWidth, _winHeight))
|
||||
return fatal("Couldn't allocate memory for backdrop");
|
||||
|
||||
blankAllScreen();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,12 @@ public:
|
|||
GraphicsManager(SludgeEngine *vm);
|
||||
virtual ~GraphicsManager();
|
||||
|
||||
void init();
|
||||
void kill();
|
||||
|
||||
// graphics
|
||||
void setWindowSize(uint winWidth, uint winHeight) { _winWidth = winWidth; _winHeight = winHeight; }
|
||||
bool init();
|
||||
bool initGfx();
|
||||
void display();
|
||||
void clear();
|
||||
|
||||
|
@ -125,7 +128,7 @@ public:
|
|||
bool isFrozen() { return (_frozenStuff != nullptr); }
|
||||
|
||||
// Sprites
|
||||
void forgetSpriteBank(SpriteBank &forgetme);
|
||||
static void forgetSpriteBank(SpriteBank &forgetme);
|
||||
bool loadSpriteBank(char *filename, SpriteBank &loadhere);
|
||||
bool loadSpriteBank(int fileNum, SpriteBank &loadhere, bool isFont);
|
||||
|
||||
|
|
|
@ -32,19 +32,35 @@
|
|||
|
||||
namespace Sludge {
|
||||
|
||||
LanguageManager::LanguageManager() {
|
||||
init();
|
||||
}
|
||||
|
||||
LanguageManager::~LanguageManager() {
|
||||
kill();
|
||||
}
|
||||
|
||||
void LanguageManager::init() {
|
||||
_languageID = 0;
|
||||
_languageIdx = -1;
|
||||
_numLanguages = 0;
|
||||
_languageTable = nullptr;
|
||||
_languageNames = nullptr;
|
||||
}
|
||||
|
||||
void LanguageManager::kill() {
|
||||
if (_languageTable) {
|
||||
delete []_languageTable;
|
||||
_languageTable = NULL;
|
||||
_languageTable = nullptr;
|
||||
}
|
||||
|
||||
if (_languageNames) {
|
||||
delete []_languageNames;
|
||||
_languageNames = NULL;
|
||||
_languageNames = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void LanguageManager::init(Common::File *fp) {
|
||||
void LanguageManager::createTable(Common::File *fp) {
|
||||
// get number of languages
|
||||
_numLanguages =
|
||||
(gameVersion >= VERSION(1, 3)) ? (fp->readByte()) : 0;
|
||||
|
|
|
@ -30,15 +30,13 @@ namespace Sludge {
|
|||
|
||||
class LanguageManager {
|
||||
public:
|
||||
LanguageManager() :
|
||||
_languageID(0),
|
||||
_languageIdx(-1),
|
||||
_numLanguages(0),
|
||||
_languageTable(0),
|
||||
_languageNames(0) {}
|
||||
LanguageManager();
|
||||
~LanguageManager();
|
||||
|
||||
void init(Common::File *table);
|
||||
void init();
|
||||
void kill();
|
||||
|
||||
void createTable(Common::File *table);
|
||||
void setLanguageID(uint id);
|
||||
void saveLanguageSetting(Common::WriteStream *writeStream);
|
||||
void loadLanguageSetting(Common::SeekableReadStream *readStream);
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "common/config-manager.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include "graphics/surface.h"
|
||||
|
@ -55,22 +54,7 @@ int main_loop(Common::String filename) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
g_sludge->_gfxMan->init();
|
||||
|
||||
g_sludge->_gfxMan->blankAllScreen();
|
||||
if (!initPeople())
|
||||
return fatal("Couldn't initialise people stuff");
|
||||
if (!initFloor())
|
||||
return fatal("Couldn't initialise floor stuff");
|
||||
if (!g_sludge->_objMan->initObjectTypes())
|
||||
return fatal("Couldn't initialise object type stuff");
|
||||
initSpeech();
|
||||
initStatusBar();
|
||||
resetRandW();
|
||||
|
||||
if (!ConfMan.hasKey("mute") || !ConfMan.getBool("mute")) {
|
||||
g_sludge->_soundMan->initSoundStuff();
|
||||
}
|
||||
g_sludge->_gfxMan->initGfx();
|
||||
|
||||
startNewFunctionNum(0, 0, NULL, noStack);
|
||||
|
||||
|
@ -88,9 +72,7 @@ int main_loop(Common::String filename) {
|
|||
g_sludge->_timer.waitFrame();
|
||||
}
|
||||
|
||||
killAllFunctions();
|
||||
killAllRegions();
|
||||
g_sludge->_soundMan->killSoundStuff();
|
||||
killSludge();
|
||||
|
||||
// Load next game
|
||||
if (!g_sludge->launchNext.empty()) {
|
||||
|
|
|
@ -32,16 +32,22 @@
|
|||
namespace Sludge {
|
||||
|
||||
ObjectManager::~ObjectManager() {
|
||||
kill();
|
||||
}
|
||||
|
||||
bool ObjectManager::init() {
|
||||
_allObjectTypes.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ObjectManager::kill() {
|
||||
ObjectTypeList::iterator it;
|
||||
for (it = _allObjectTypes.begin(); it != _allObjectTypes.end(); ++it) {
|
||||
delete [](*it)->allCombis;
|
||||
delete (*it);
|
||||
(*it) = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool ObjectManager::initObjectTypes() {
|
||||
return true;
|
||||
_allObjectTypes.clear();
|
||||
}
|
||||
|
||||
ObjectType *ObjectManager::findObjectType(int i) {
|
||||
|
|
|
@ -44,10 +44,12 @@ typedef Common::List<ObjectType *> ObjectTypeList;
|
|||
|
||||
class ObjectManager {
|
||||
public:
|
||||
ObjectManager(SludgeEngine *vm) : _vm(vm) {}
|
||||
ObjectManager(SludgeEngine *vm) : _vm(vm) { init(); }
|
||||
~ObjectManager();
|
||||
|
||||
bool initObjectTypes();
|
||||
bool init();
|
||||
void kill();
|
||||
|
||||
ObjectType *findObjectType(int i);
|
||||
ObjectType *loadObjectType(int i);
|
||||
int getCombinationFunction(int a, int b);
|
||||
|
|
|
@ -20,12 +20,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "common/config-manager.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include "sludge/allfiles.h"
|
||||
#include "sludge/backdrop.h"
|
||||
#include "sludge/builtin.h"
|
||||
#include "sludge/cursors.h"
|
||||
#include "sludge/event.h"
|
||||
#include "sludge/fonttext.h"
|
||||
#include "sludge/freeze.h"
|
||||
#include "sludge/floor.h"
|
||||
|
@ -76,7 +78,17 @@ LoadedFunction *allRunningFunctions = NULL;
|
|||
VariableStack *noStack = NULL;
|
||||
Variable *globalVars;
|
||||
|
||||
int numGlobals;
|
||||
int numGlobals = 0;
|
||||
|
||||
extern SpritePalette pastePalette;
|
||||
extern int speechMode;
|
||||
extern float speechSpeed;
|
||||
extern Variable *launchResult;
|
||||
extern int lastFramesPerSecond, thumbWidth, thumbHeight;
|
||||
|
||||
extern bool allowAnyFilename;
|
||||
extern byte fadeMode;
|
||||
extern uint16 saveEncoding;
|
||||
|
||||
const char *sludgeText[] = { "?????", "RETURN", "BRANCH", "BR_ZERO",
|
||||
"SET_GLOBAL", "SET_LOCAL", "LOAD_GLOBAL", "LOAD_LOCAL", "PLUS", "MINUS",
|
||||
|
@ -136,9 +148,69 @@ Common::File *openAndVerify(const Common::String &filename, char extra1, char ex
|
|||
return fp;
|
||||
}
|
||||
|
||||
bool initSludge(const Common::String &filename) {
|
||||
int a = 0;
|
||||
void initSludge() {
|
||||
g_sludge->_languageMan->init();
|
||||
g_sludge->_gfxMan->init();
|
||||
g_sludge->_resMan->init();
|
||||
initPeople();
|
||||
initFloor();
|
||||
g_sludge->_objMan->init();
|
||||
initSpeech();
|
||||
initStatusBar();
|
||||
resetRandW();
|
||||
g_sludge->_evtMan->init();
|
||||
g_sludge->_txtMan->init();
|
||||
g_sludge->_cursorMan->init();
|
||||
|
||||
g_sludge->_soundMan->init();
|
||||
if (!ConfMan.hasKey("mute") || !ConfMan.getBool("mute")) {
|
||||
g_sludge->_soundMan->initSoundStuff();
|
||||
}
|
||||
|
||||
// global variables
|
||||
numGlobals = 0;
|
||||
speechMode = 0;
|
||||
launchResult = nullptr;
|
||||
|
||||
lastFramesPerSecond = -1;
|
||||
thumbWidth = thumbHeight = 0;
|
||||
allowAnyFilename = true;
|
||||
captureAllKeys = false;
|
||||
noStack = nullptr;
|
||||
numBIFNames = numUserFunc = 0;
|
||||
allUserFunc = allBIFNames = nullptr;
|
||||
speechSpeed = 1;
|
||||
brightnessLevel = 255;
|
||||
fadeMode = 2;
|
||||
saveEncoding = false;
|
||||
}
|
||||
|
||||
void killSludge() {
|
||||
killAllFunctions();
|
||||
killAllPeople();
|
||||
killAllRegions();
|
||||
setFloorNull();
|
||||
killAllSpeech();
|
||||
g_sludge->_languageMan->kill();
|
||||
g_sludge->_gfxMan->kill();
|
||||
g_sludge->_resMan->kill();
|
||||
g_sludge->_objMan->kill();
|
||||
g_sludge->_soundMan->killSoundStuff();
|
||||
g_sludge->_evtMan->kill();
|
||||
g_sludge->_txtMan->kill();
|
||||
g_sludge->_cursorMan->kill();
|
||||
|
||||
// global variables
|
||||
pastePalette.reset();
|
||||
numBIFNames = numUserFunc = 0;
|
||||
delete []allUserFunc;
|
||||
delete []allBIFNames;
|
||||
}
|
||||
|
||||
bool initSludge(const Common::String &filename) {
|
||||
initSludge();
|
||||
|
||||
int a = 0;
|
||||
Common::File *fp = openAndVerify(filename, 'G', 'E', ERROR_BAD_HEADER, gameVersion);
|
||||
if (!fp)
|
||||
return false;
|
||||
|
@ -201,7 +273,7 @@ bool initSludge(const Common::String &filename) {
|
|||
Common::String dataFol = (gameVersion >= VERSION(1, 3)) ? readString(fp) : "";
|
||||
debugC(2, kSludgeDebugDataLoad, "dataFol : %s", dataFol.c_str());
|
||||
|
||||
g_sludge->_languageMan->init(fp);
|
||||
g_sludge->_languageMan->createTable(fp);
|
||||
|
||||
if (gameVersion >= VERSION(1, 6)) {
|
||||
fp->readByte();
|
||||
|
@ -901,12 +973,8 @@ bool runSludge() {
|
|||
}
|
||||
|
||||
void killAllFunctions() {
|
||||
LoadedFunction *ptr = allRunningFunctions;
|
||||
while (ptr) {
|
||||
LoadedFunction *kill = ptr;
|
||||
ptr = ptr->next;
|
||||
abortFunction(kill);
|
||||
}
|
||||
while (allRunningFunctions)
|
||||
finishFunction(allRunningFunctions);
|
||||
}
|
||||
|
||||
bool loadFunctionCode(LoadedFunction *newFunc) {
|
||||
|
|
|
@ -60,6 +60,10 @@ struct LoadedFunction {
|
|||
|
||||
bool initSludge(const Common::String &);
|
||||
bool runSludge();
|
||||
|
||||
void initSludge();
|
||||
void killSludge();
|
||||
|
||||
void displayBase();
|
||||
void sludgeDisplay();
|
||||
int startNewFunctionNum(uint, uint, LoadedFunction *, VariableStack*&, bool = true);
|
||||
|
|
|
@ -43,24 +43,13 @@ const int SoundManager::MAX_SAMPLES = 8;
|
|||
const int SoundManager::MAX_MODS = 3;
|
||||
|
||||
SoundManager::SoundManager() {
|
||||
// there's possibility that several sound list played at the same time
|
||||
_soundListHandles.clear();
|
||||
|
||||
_soundOK = false;
|
||||
_silenceIKillYou = false;
|
||||
_isHandlingSoundList = false;
|
||||
|
||||
_soundCache = nullptr;
|
||||
_soundCache = new SoundThing[MAX_SAMPLES];
|
||||
|
||||
_modCache = nullptr;
|
||||
_modCache = new SoundThing[MAX_MODS];
|
||||
|
||||
_defVol = 128;
|
||||
_defSoundVol = 255;
|
||||
_modLoudness = 0.95f;
|
||||
|
||||
_emptySoundSlot = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
SoundManager::~SoundManager() {
|
||||
|
@ -73,14 +62,29 @@ SoundManager::~SoundManager() {
|
|||
_modCache = nullptr;
|
||||
}
|
||||
|
||||
void SoundManager::init() {
|
||||
// there's possibility that several sound list played at the same time
|
||||
_soundListHandles.clear();
|
||||
|
||||
_soundOK = false;
|
||||
_silenceIKillYou = false;
|
||||
_isHandlingSoundList = false;
|
||||
|
||||
_defVol = 128;
|
||||
_defSoundVol = 255;
|
||||
_modLoudness = 0.95f;
|
||||
|
||||
_emptySoundSlot = 0;
|
||||
}
|
||||
|
||||
bool SoundManager::initSoundStuff() {
|
||||
for (int a = 0; a < MAX_SAMPLES; a ++) {
|
||||
for (int a = 0; a < MAX_SAMPLES; ++a) {
|
||||
_soundCache[a].fileLoaded = -1;
|
||||
_soundCache[a].looping = false;
|
||||
_soundCache[a].inSoundList = false;
|
||||
}
|
||||
|
||||
for (int a = 0; a < MAX_MODS; a ++) {
|
||||
for (int a = 0; a < MAX_MODS; ++a) {
|
||||
_soundCache[a].fileLoaded = -1;
|
||||
_soundCache[a].looping = false;
|
||||
_soundCache[a].inSoundList = false;
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
void handleSoundLists(); // to produce the same effects as end of stream call back functions
|
||||
|
||||
// GENERAL...
|
||||
void init();
|
||||
bool initSoundStuff();
|
||||
void killSoundStuff();
|
||||
|
||||
|
|
|
@ -54,13 +54,15 @@ void GraphicsManager::forgetSpriteBank(SpriteBank &forgetme) {
|
|||
forgetme.myPalette.b = NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < forgetme.total; ++i) {
|
||||
forgetme.sprites[i].surface.free();
|
||||
forgetme.sprites[i].burnSurface.free();
|
||||
}
|
||||
if (forgetme.sprites) {
|
||||
for (int i = 0; i < forgetme.total; ++i) {
|
||||
forgetme.sprites[i].surface.free();
|
||||
forgetme.sprites[i].burnSurface.free();
|
||||
}
|
||||
|
||||
delete []forgetme.sprites;
|
||||
forgetme.sprites = NULL;
|
||||
delete []forgetme.sprites;
|
||||
forgetme.sprites = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool GraphicsManager::reserveSpritePal(SpritePalette &sP, int n) {
|
||||
|
|
|
@ -41,15 +41,32 @@ public:
|
|||
byte *b;
|
||||
byte originalRed, originalGreen, originalBlue, total;
|
||||
|
||||
SpritePalette() : pal(0), r(0), g(0), b(0), total(0) {
|
||||
SpritePalette() { init(); }
|
||||
|
||||
~SpritePalette() { kill(); }
|
||||
|
||||
void reset() {
|
||||
kill();
|
||||
init();
|
||||
}
|
||||
|
||||
private:
|
||||
void init() {
|
||||
pal = nullptr;
|
||||
r = g = b = nullptr;
|
||||
total = 0;
|
||||
originalRed = originalGreen = originalBlue = 255;
|
||||
}
|
||||
|
||||
~SpritePalette() {
|
||||
delete[] pal;
|
||||
delete[] r;
|
||||
delete[] g;
|
||||
delete[] b;
|
||||
void kill() {
|
||||
if (pal)
|
||||
delete[] pal;
|
||||
if (r)
|
||||
delete[] r;
|
||||
if (g)
|
||||
delete[] g;
|
||||
if (b)
|
||||
delete[] b;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ void initSpeech() {
|
|||
}
|
||||
|
||||
void killAllSpeech() {
|
||||
if (!speech)
|
||||
return;
|
||||
|
||||
if (speech->lastFile != -1) {
|
||||
g_sludge->_soundMan->huntKillSound(speech->lastFile);
|
||||
speech->lastFile = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue