mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
Programs are now handled in their own list, instead of being accessed via the referring Animation.
svn-id: r30768
This commit is contained in:
parent
54576cbf11
commit
85171eadaa
@ -316,8 +316,8 @@ DECLARE_INSTRUCTION_OPCODE(set) {
|
||||
DECLARE_INSTRUCTION_OPCODE(loop) {
|
||||
Instruction *inst = *_instRunCtxt.inst;
|
||||
|
||||
_instRunCtxt.a->_program->_loopCounter = inst->_opB.getRValue();
|
||||
_instRunCtxt.a->_program->_loopStart = _instRunCtxt.inst;
|
||||
_instRunCtxt.program->_loopCounter = inst->_opB.getRValue();
|
||||
_instRunCtxt.program->_loopStart = _instRunCtxt.inst;
|
||||
}
|
||||
|
||||
|
||||
@ -444,11 +444,11 @@ DECLARE_INSTRUCTION_OPCODE(stop) {
|
||||
}
|
||||
|
||||
DECLARE_INSTRUCTION_OPCODE(endscript) {
|
||||
if ((_instRunCtxt.a->_flags & kFlagsLooping) == 0) {
|
||||
_instRunCtxt.a->_flags &= ~kFlagsActing;
|
||||
runCommands(_instRunCtxt.a->_commands, _instRunCtxt.a);
|
||||
if ((_instRunCtxt.anim->_flags & kFlagsLooping) == 0) {
|
||||
_instRunCtxt.anim->_flags &= ~kFlagsActing;
|
||||
runCommands(_instRunCtxt.anim->_commands, _instRunCtxt.anim);
|
||||
}
|
||||
_instRunCtxt.a->_program->_ip = _instRunCtxt.a->_program->_instructions.begin();
|
||||
_instRunCtxt.program->_ip = _instRunCtxt.program->_instructions.begin();
|
||||
|
||||
_instRunCtxt.suspend = true;
|
||||
}
|
||||
|
@ -76,14 +76,14 @@ DECLARE_INSTRUCTION_OPCODE(off) {
|
||||
DECLARE_INSTRUCTION_OPCODE(loop) {
|
||||
Instruction *inst = *_instRunCtxt.inst;
|
||||
|
||||
_instRunCtxt.a->_program->_loopCounter = inst->_opB.getRValue();
|
||||
_instRunCtxt.a->_program->_loopStart = _instRunCtxt.inst;
|
||||
_instRunCtxt.program->_loopCounter = inst->_opB.getRValue();
|
||||
_instRunCtxt.program->_loopStart = _instRunCtxt.inst;
|
||||
}
|
||||
|
||||
|
||||
DECLARE_INSTRUCTION_OPCODE(endloop) {
|
||||
if (--_instRunCtxt.a->_program->_loopCounter > 0) {
|
||||
_instRunCtxt.inst = _instRunCtxt.a->_program->_loopStart;
|
||||
if (--_instRunCtxt.program->_loopCounter > 0) {
|
||||
_instRunCtxt.inst = _instRunCtxt.program->_loopStart;
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,11 +177,11 @@ DECLARE_INSTRUCTION_OPCODE(move) {
|
||||
}
|
||||
|
||||
DECLARE_INSTRUCTION_OPCODE(endscript) {
|
||||
if ((_instRunCtxt.a->_flags & kFlagsLooping) == 0) {
|
||||
_instRunCtxt.a->_flags &= ~kFlagsActing;
|
||||
runCommands(_instRunCtxt.a->_commands, _instRunCtxt.a);
|
||||
if ((_instRunCtxt.anim->_flags & kFlagsLooping) == 0) {
|
||||
_instRunCtxt.anim->_flags &= ~kFlagsActing;
|
||||
runCommands(_instRunCtxt.anim->_commands, _instRunCtxt.anim);
|
||||
}
|
||||
_instRunCtxt.a->_program->_ip = _instRunCtxt.a->_program->_instructions.begin();
|
||||
_instRunCtxt.program->_ip = _instRunCtxt.program->_instructions.begin();
|
||||
|
||||
_instRunCtxt.suspend = true;
|
||||
}
|
||||
@ -373,9 +373,9 @@ void Parallaction_ns::runScripts() {
|
||||
|
||||
static uint16 modCounter = 0;
|
||||
|
||||
for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++) {
|
||||
for (ProgramList::iterator it = _programs.begin(); it != _programs.end(); it++) {
|
||||
|
||||
Animation *a = *it;
|
||||
Animation *a = (*it)->_anim;
|
||||
|
||||
if (a->_flags & kFlagsCharacter)
|
||||
a->_z = a->_top + a->height();
|
||||
@ -383,13 +383,14 @@ void Parallaction_ns::runScripts() {
|
||||
if ((a->_flags & kFlagsActing) == 0)
|
||||
continue;
|
||||
|
||||
InstructionList::iterator inst = a->_program->_ip;
|
||||
InstructionList::iterator inst = (*it)->_ip;
|
||||
while (((*inst)->_index != INST_SHOW) && (a->_flags & kFlagsActing)) {
|
||||
|
||||
debugC(9, kDebugExec, "Animation: %s, instruction: %s", a->_name, _instructionNamesRes[(*inst)->_index - 1]);
|
||||
|
||||
_instRunCtxt.inst = inst;
|
||||
_instRunCtxt.a = a;
|
||||
_instRunCtxt.anim = a;
|
||||
_instRunCtxt.program = *it;
|
||||
_instRunCtxt.modCounter = modCounter;
|
||||
_instRunCtxt.suspend = false;
|
||||
|
||||
@ -403,7 +404,7 @@ void Parallaction_ns::runScripts() {
|
||||
inst++;
|
||||
}
|
||||
|
||||
a->_program->_ip = ++inst;
|
||||
(*it)->_ip = ++inst;
|
||||
|
||||
label1:
|
||||
if (a->_flags & kFlagsCharacter)
|
||||
|
@ -44,14 +44,12 @@ Command::~Command() {
|
||||
|
||||
Animation::Animation() {
|
||||
gfxobj = NULL;
|
||||
_program = NULL;
|
||||
_scriptName = 0;
|
||||
_frame = 0;
|
||||
_z = 0;
|
||||
}
|
||||
|
||||
Animation::~Animation() {
|
||||
delete _program;
|
||||
free(_scriptName);
|
||||
}
|
||||
|
||||
|
@ -365,6 +365,8 @@ struct Instruction {
|
||||
|
||||
|
||||
struct Program {
|
||||
Animation *_anim;
|
||||
|
||||
LocalVariable *_locals;
|
||||
|
||||
uint16 _loopCounter;
|
||||
@ -382,12 +384,11 @@ struct Program {
|
||||
int16 addLocal(const char *name, int16 value = 0, int16 min = -10000, int16 max = 10000);
|
||||
};
|
||||
|
||||
|
||||
typedef ManagedList<Program*> ProgramList;
|
||||
|
||||
struct Animation : public Zone {
|
||||
|
||||
Common::Point _oldPos;
|
||||
Program *_program;
|
||||
GfxObj *gfxobj;
|
||||
char *_scriptName;
|
||||
int16 _frame;
|
||||
|
@ -715,6 +715,7 @@ void Parallaction::freeLocation() {
|
||||
_gfx->clearGfxObjects();
|
||||
freeBackground();
|
||||
|
||||
_programs.clear();
|
||||
freeZones();
|
||||
freeAnimations();
|
||||
|
||||
|
@ -325,7 +325,8 @@ public:
|
||||
OpcodeSet _instructionOpcodes;
|
||||
|
||||
struct {
|
||||
Animation *a;
|
||||
Animation *anim;
|
||||
Program *program;
|
||||
InstructionList::iterator inst;
|
||||
uint16 modCounter;
|
||||
bool suspend;
|
||||
@ -404,6 +405,7 @@ public:
|
||||
|
||||
ZoneList _zones;
|
||||
AnimationList _animations;
|
||||
ProgramList _programs;
|
||||
|
||||
Font *_labelFont;
|
||||
Font *_menuFont;
|
||||
@ -787,7 +789,7 @@ protected:
|
||||
DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(null);
|
||||
DECLARE_UNQUALIFIED_INSTRUCTION_PARSER(endscript);
|
||||
|
||||
void parseInstruction(Animation *a, LocalVariable *locals);
|
||||
void parseInstruction(Program *program);
|
||||
void loadProgram(Animation *a, const char *filename);
|
||||
void parseLValue(ScriptVar &var, const char *str);
|
||||
virtual void parseRValue(ScriptVar &var, const char *str);
|
||||
|
@ -208,6 +208,7 @@ void Parallaction_br::changeLocation(char *location) {
|
||||
clearSubtitles();
|
||||
freeBackground();
|
||||
_gfx->clearGfxObjects();
|
||||
_programs.clear();
|
||||
freeZones();
|
||||
freeAnimations();
|
||||
// free(_location._comment);
|
||||
|
@ -949,7 +949,7 @@ void Parallaction_br::parseLocation(const char* filename) {
|
||||
|
||||
AnimationList::iterator it = _animations.begin();
|
||||
for ( ; it != _animations.end(); it++) {
|
||||
if (((*it)->_scriptName) && ((*it)->_program == 0)) {
|
||||
if ((*it)->_scriptName) {
|
||||
loadProgram(*it, (*it)->_scriptName);
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ Animation *Parallaction_ns::parseAnimation(Script& script, AnimationList &list,
|
||||
return a;
|
||||
}
|
||||
|
||||
void Parallaction_ns::parseInstruction(Animation *a, LocalVariable *locals) {
|
||||
void Parallaction_ns::parseInstruction(Program *program) {
|
||||
|
||||
Instruction *inst = new Instruction;
|
||||
|
||||
@ -208,15 +208,15 @@ void Parallaction_ns::parseInstruction(Animation *a, LocalVariable *locals) {
|
||||
_tokens[1][1] = '\0';
|
||||
_instParseCtxt.a = findAnimation(&_tokens[1][2]);
|
||||
} else
|
||||
_instParseCtxt.a = a;
|
||||
_instParseCtxt.a = program->_anim;
|
||||
|
||||
inst->_index = _instructionNames->lookup(_tokens[0]);
|
||||
_instParseCtxt.inst = inst;
|
||||
_instParseCtxt.locals = locals;
|
||||
_instParseCtxt.locals = program->_locals;
|
||||
|
||||
(*(_instructionParsers[inst->_index]))();
|
||||
|
||||
a->_program->_instructions.push_back(inst);
|
||||
program->_instructions.push_back(inst);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -225,22 +225,24 @@ void Parallaction_ns::loadProgram(Animation *a, const char *filename) {
|
||||
debugC(1, kDebugParser, "loadProgram(Animation: %s, script: %s)", a->_name, filename);
|
||||
|
||||
Script *script = _disk->loadScript(filename);
|
||||
|
||||
a->_program = new Program;
|
||||
Program *program = new Program;
|
||||
program->_anim = a;
|
||||
|
||||
_instParseCtxt.openIf = NULL;
|
||||
_instParseCtxt.end = false;
|
||||
_instParseCtxt.program = a->_program;
|
||||
_instParseCtxt.program = program;
|
||||
|
||||
do {
|
||||
script->readLineToken();
|
||||
parseInstruction(a, a->_program->_locals);
|
||||
parseInstruction(program);
|
||||
} while (!_instParseCtxt.end);
|
||||
|
||||
a->_program->_ip = a->_program->_instructions.begin();
|
||||
program->_ip = program->_instructions.begin();
|
||||
|
||||
delete script;
|
||||
|
||||
_programs.push_back(program);
|
||||
|
||||
debugC(1, kDebugParser, "loadProgram() done");
|
||||
|
||||
return;
|
||||
@ -998,7 +1000,7 @@ void Parallaction_ns::parseLocation(const char *filename) {
|
||||
// this loads animation scripts
|
||||
AnimationList::iterator it = _animations.begin();
|
||||
for ( ; it != _animations.end(); it++) {
|
||||
if (((*it)->_scriptName) && ((*it)->_program == 0)) {
|
||||
if ((*it)->_scriptName) {
|
||||
loadProgram(*it, (*it)->_scriptName);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user