mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-17 14:09:59 +00:00
Change the AGI image stack to use Common::Stack
svn-id: r29608
This commit is contained in:
parent
ddaa391110
commit
207ecdb332
@ -297,46 +297,27 @@ void AgiEngine::agiTimerFunctionLow(void *refCon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::clearImageStack(void) {
|
void AgiEngine::clearImageStack(void) {
|
||||||
_imageStackPointer = 0;
|
_imageStack.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::releaseImageStack(void) {
|
void AgiEngine::releaseImageStack(void) {
|
||||||
if (_imageStack)
|
_imageStack.clear();
|
||||||
free(_imageStack);
|
|
||||||
_imageStack = NULL;
|
|
||||||
_stackSize = 0;
|
|
||||||
_imageStackPointer = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
void AgiEngine::recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
||||||
int16 p4, int16 p5, int16 p6, int16 p7) {
|
int16 p4, int16 p5, int16 p6, int16 p7) {
|
||||||
struct ImageStackElement *pnew;
|
ImageStackElement pnew;
|
||||||
|
|
||||||
if (_imageStackPointer == _stackSize) {
|
pnew.type = type;
|
||||||
if (_stackSize == 0) { /* first call */
|
pnew.parm1 = p1;
|
||||||
_imageStack = (ImageStackElement *)malloc(INITIAL_IMAGE_STACK_SIZE * sizeof(ImageStackElement));
|
pnew.parm2 = p2;
|
||||||
_stackSize = INITIAL_IMAGE_STACK_SIZE;
|
pnew.parm3 = p3;
|
||||||
} else { /* has to grow */
|
pnew.parm4 = p4;
|
||||||
struct ImageStackElement *newStack;
|
pnew.parm5 = p5;
|
||||||
newStack = (ImageStackElement *)malloc(2 * _stackSize * sizeof(ImageStackElement));
|
pnew.parm6 = p6;
|
||||||
memcpy(newStack, _imageStack, _stackSize * sizeof(ImageStackElement));
|
pnew.parm7 = p7;
|
||||||
free(_imageStack);
|
|
||||||
_imageStack = newStack;
|
|
||||||
_stackSize *= 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pnew = &_imageStack[_imageStackPointer];
|
_imageStack.push(pnew);
|
||||||
_imageStackPointer++;
|
|
||||||
|
|
||||||
pnew->type = type;
|
|
||||||
pnew->parm1 = p1;
|
|
||||||
pnew->parm2 = p2;
|
|
||||||
pnew->parm3 = p3;
|
|
||||||
pnew->parm4 = p4;
|
|
||||||
pnew->parm5 = p5;
|
|
||||||
pnew->parm6 = p6;
|
|
||||||
pnew->parm7 = p7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgiEngine::replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
void AgiEngine::replayImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
||||||
@ -660,10 +641,6 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
|
|||||||
|
|
||||||
_intobj = NULL;
|
_intobj = NULL;
|
||||||
|
|
||||||
_stackSize = 0;
|
|
||||||
_imageStack = NULL;
|
|
||||||
_imageStackPointer = 0;
|
|
||||||
|
|
||||||
_menu = NULL;
|
_menu = NULL;
|
||||||
|
|
||||||
_lastSentence[0] = 0;
|
_lastSentence[0] = 0;
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "common/savefile.h"
|
#include "common/savefile.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/hash-str.h"
|
#include "common/hash-str.h"
|
||||||
|
#include "common/stack.h"
|
||||||
|
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
|
|
||||||
@ -658,12 +659,6 @@ public:
|
|||||||
|
|
||||||
AgiBase(OSystem *syst, const AGIGameDescription *gameDesc);
|
AgiBase(OSystem *syst, const AGIGameDescription *gameDesc);
|
||||||
|
|
||||||
#define INITIAL_IMAGE_STACK_SIZE 32
|
|
||||||
|
|
||||||
int _stackSize;
|
|
||||||
ImageStackElement *_imageStack;
|
|
||||||
int _imageStackPointer;
|
|
||||||
|
|
||||||
virtual void clearImageStack() = 0;
|
virtual void clearImageStack() = 0;
|
||||||
virtual void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
virtual void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
||||||
int16 p4, int16 p5, int16 p6, int16 p7) = 0;
|
int16 p4, int16 p5, int16 p6, int16 p7) = 0;
|
||||||
@ -746,6 +741,8 @@ public:
|
|||||||
PictureMgr *_picture;
|
PictureMgr *_picture;
|
||||||
AgiLoader *_loader; /* loader */
|
AgiLoader *_loader; /* loader */
|
||||||
|
|
||||||
|
Common::Stack<ImageStackElement> _imageStack;
|
||||||
|
|
||||||
void clearImageStack();
|
void clearImageStack();
|
||||||
void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3,
|
||||||
int16 p4, int16 p5, int16 p6, int16 p7);
|
int16 p4, int16 p5, int16 p6, int16 p7);
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
GfxMgr *_gfx;
|
GfxMgr *_gfx;
|
||||||
SoundMgr *_sound;
|
//SoundMgr *_sound;
|
||||||
PictureMgr *_picture;
|
PictureMgr *_picture;
|
||||||
PreAGI_Console *_console;
|
PreAGI_Console *_console;
|
||||||
|
|
||||||
|
@ -53,7 +53,6 @@ static const uint32 AGIflag=MKID_BE('AGI:');
|
|||||||
int AgiEngine::saveGame(const char *fileName, const char *description) {
|
int AgiEngine::saveGame(const char *fileName, const char *description) {
|
||||||
char gameIDstring[8]="gameIDX";
|
char gameIDstring[8]="gameIDX";
|
||||||
int i;
|
int i;
|
||||||
struct ImageStackElement *ptr = _imageStack;
|
|
||||||
Common::OutSaveFile *out;
|
Common::OutSaveFile *out;
|
||||||
int result = errOK;
|
int result = errOK;
|
||||||
|
|
||||||
@ -190,16 +189,16 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
|
|||||||
|
|
||||||
/* Save image stack */
|
/* Save image stack */
|
||||||
|
|
||||||
for (i = 0; i < _imageStackPointer; i++) {
|
for (i = 0; i < _imageStack.size(); i++) {
|
||||||
ptr = &_imageStack[i];
|
ImageStackElement ise = _imageStack[i];
|
||||||
out->writeByte(ptr->type);
|
out->writeByte(ise.type);
|
||||||
out->writeSint16BE(ptr->parm1);
|
out->writeSint16BE(ise.parm1);
|
||||||
out->writeSint16BE(ptr->parm2);
|
out->writeSint16BE(ise.parm2);
|
||||||
out->writeSint16BE(ptr->parm3);
|
out->writeSint16BE(ise.parm3);
|
||||||
out->writeSint16BE(ptr->parm4);
|
out->writeSint16BE(ise.parm4);
|
||||||
out->writeSint16BE(ptr->parm5);
|
out->writeSint16BE(ise.parm5);
|
||||||
out->writeSint16BE(ptr->parm6);
|
out->writeSint16BE(ise.parm6);
|
||||||
out->writeSint16BE(ptr->parm7);
|
out->writeSint16BE(ise.parm7);
|
||||||
}
|
}
|
||||||
out->writeByte(0);
|
out->writeByte(0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user