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