- Implemented opcodes: sfHomeText, sfDrawAnimPic
- Comments on unneeded opcodes - Simplified getting/setting strings in Objects svn-id: r32361
This commit is contained in:
parent
3f91c579fc
commit
b9776d46b2
5 changed files with 44 additions and 29 deletions
|
@ -281,6 +281,20 @@ void GameDatabase::setVar(int16 index, int16 value) {
|
|||
WRITE_LE_UINT16(_gameState + index * 2, value);
|
||||
}
|
||||
|
||||
const char *GameDatabase::getObjectString(int16 index) {
|
||||
Object *obj = getObject(index);
|
||||
if (obj)
|
||||
return obj->getString();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
void GameDatabase::setObjectString(int16 index, const char *str) {
|
||||
Object *obj = getObject(index);
|
||||
if (obj)
|
||||
obj->setString(str);
|
||||
}
|
||||
|
||||
int16 GameDatabase::getObjectProperty(int16 objectIndex, int16 propertyId) {
|
||||
|
||||
if (objectIndex == 0)
|
||||
|
|
|
@ -130,6 +130,9 @@ public:
|
|||
int16 getVar(int16 index);
|
||||
void setVar(int16 index, int16 value);
|
||||
|
||||
const char *getObjectString(int16 index);
|
||||
void setObjectString(int16 index, const char *str);
|
||||
|
||||
virtual int16 *getObjectPropertyPtr(int16 objectIndex, int16 propertyId, int16 &propertyFlag) = 0;
|
||||
virtual const char *getString(uint16 offset) = 0;
|
||||
virtual bool getSavegameDescription(const char *filename, Common::String &description) = 0;
|
||||
|
|
|
@ -328,7 +328,7 @@ void Screen::drawSpriteChannels(const ClipInfo &clipInfo, int16 includeStateMask
|
|||
break;
|
||||
|
||||
case 4: // drawMenuText
|
||||
// TODO
|
||||
// Never used in any game
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -430,7 +430,7 @@ uint16 Screen::drawSprite(uint16 flexIndex, int16 x, int16 y) {
|
|||
|
||||
uint16 Screen::placeSprite(uint16 channelIndex, uint16 flexIndex, int16 x, int16 y) {
|
||||
|
||||
debug(2, "placeSprite(%d, %04X, %d, %d)\n", channelIndex, flexIndex, x, y); fflush(stdout);
|
||||
debug(2, "placeSprite(%d, %04X, %d, %d)\n", channelIndex, flexIndex, x, y);
|
||||
|
||||
if (channelIndex < 1 || channelIndex >= 100)
|
||||
return 0;
|
||||
|
|
|
@ -136,6 +136,11 @@ public:
|
|||
_textY = y;
|
||||
}
|
||||
|
||||
void homeText() {
|
||||
_textX = _textRect.left;
|
||||
_textY = _textRect.top;
|
||||
}
|
||||
|
||||
uint16 updateChannel(uint16 channelIndex);
|
||||
void deleteChannel(uint16 channelIndex);
|
||||
int16 getChannelType(uint16 channelIndex);
|
||||
|
@ -149,6 +154,7 @@ public:
|
|||
void clearChannels();
|
||||
|
||||
uint16 drawFlex(uint16 flexIndex, int16 x, int16 y, int16 flipX, int16 flipY, int16 mask, const ClipInfo &clipInfo);
|
||||
|
||||
void drawAnimFrame(uint16 animIndex, int16 x, int16 y, int16 frameNum, int16 flipX, int16 flipY, const ClipInfo &clipInfo);
|
||||
|
||||
uint16 drawPic(uint16 index, int16 x, int16 y, int16 flipX, int16 flipY);
|
||||
|
|
|
@ -267,10 +267,11 @@ int16 ScriptFunctions::sfIsMusicPlaying(int16 argc, int16 *argv) {
|
|||
}
|
||||
|
||||
int16 ScriptFunctions::sfSetTextPos(int16 argc, int16 *argv) {
|
||||
// TODO: Used in Manhole:NE
|
||||
warning("Unimplemented opcode: sfSetTextPos");
|
||||
// Used in Manhole:NE
|
||||
//warning("Unimplemented opcode: sfSetTextPos");
|
||||
// This seems to be some kind of low-level opcode.
|
||||
// The original engine calls int 10h to set the VGA cursor position.
|
||||
// Since this seems to be used for debugging purposes only it's left out.
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -405,8 +406,7 @@ int16 ScriptFunctions::sfDrawText(int16 argc, int16 *argv) {
|
|||
const char *text = NULL;
|
||||
|
||||
if (_vm->getGameID() == GID_RTZ) {
|
||||
Object *obj = _vm->_dat->getObject(argv[argc - 1]);
|
||||
text = obj->getString();
|
||||
text = _vm->_dat->getObjectString(argv[argc - 1]);
|
||||
} if (_vm->getGameID() == GID_LGOP2 || _vm->getGameID() == GID_MANHOLE) {
|
||||
text = _vm->_dat->getString(argv[argc - 1]);
|
||||
}
|
||||
|
@ -440,8 +440,7 @@ int16 ScriptFunctions::sfDrawText(int16 argc, int16 *argv) {
|
|||
}
|
||||
|
||||
int16 ScriptFunctions::sfHomeText(int16 argc, int16 *argv) {
|
||||
// TODO: Used in LGOP2
|
||||
warning("Unimplemented opcode: sfHomeText");
|
||||
_vm->_screen->homeText();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -578,8 +577,7 @@ int16 ScriptFunctions::sfPlayCdSegment(int16 argc, int16 *argv) {
|
|||
}
|
||||
|
||||
int16 ScriptFunctions::sfPrintf(int16 argc, int16 *argv) {
|
||||
Object *obj = _vm->_dat->getObject(argv[argc - 1]);
|
||||
const char *text = obj->getString();
|
||||
const char *text = _vm->_dat->getObjectString(argv[argc - 1]);
|
||||
debug(4, "--> text = %s", text);
|
||||
return 0;
|
||||
}
|
||||
|
@ -614,15 +612,14 @@ int16 ScriptFunctions::sfAnimText(int16 argc, int16 *argv) {
|
|||
int16 ScriptFunctions::sfGetTextWidth(int16 argc, int16 *argv) {
|
||||
int16 width = 0;
|
||||
if (argv[1] > 0) {
|
||||
Object *obj = _vm->_dat->getObject(argv[1]);
|
||||
const char *text = obj->getString();
|
||||
const char *text = _vm->_dat->getObjectString(argv[1]);
|
||||
width = _vm->_screen->getTextWidth(argv[0], text);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
int16 ScriptFunctions::sfPlayMovie(int16 argc, int16 *argv) {
|
||||
const char *movieName = _vm->_dat->getObject(argv[1])->getString();
|
||||
const char *movieName = _vm->_dat->getObjectString(argv[1]);
|
||||
_vm->_system->showMouse(false);
|
||||
_vm->_pmvPlayer->play(movieName);
|
||||
_vm->_system->showMouse(true);
|
||||
|
@ -663,8 +660,10 @@ int16 ScriptFunctions::sfSetMusicVolume(int16 argc, int16 *argv) {
|
|||
}
|
||||
|
||||
int16 ScriptFunctions::sfRestartEvents(int16 argc, int16 *argv) {
|
||||
// TODO: Used in RTZ
|
||||
warning("Unimplemented opcode: sfRestartEvents");
|
||||
// Used in RTZ
|
||||
//warning("Unimplemented opcode: sfRestartEvents");
|
||||
// This is used to reset the event recording/queue.
|
||||
// Since we don't use either it's left out.
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -765,9 +764,7 @@ int16 ScriptFunctions::sfSetSoundRate(int16 argc, int16 *argv) {
|
|||
}
|
||||
|
||||
int16 ScriptFunctions::sfDrawAnimPic(int16 argc, int16 *argv) {
|
||||
// TODO: Used in RTZ
|
||||
warning("Unimplemented opcode: sfDrawAnimPic");
|
||||
return 0;
|
||||
return _vm->_screen->drawAnimPic(argv[5], argv[4], argv[3], argv[2], argv[1], argv[0]);
|
||||
}
|
||||
|
||||
int16 ScriptFunctions::sfLoadAnim(int16 argc, int16 *argv) {
|
||||
|
@ -794,11 +791,12 @@ int16 ScriptFunctions::sfReadMenu(int16 argc, int16 *argv) {
|
|||
if (menu) {
|
||||
const char *text = menu->getString(textIndex);
|
||||
debug(4, "objectIndex = %04X; text = %s\n", objectIndex, text);
|
||||
Object *obj = _vm->_dat->getObject(objectIndex);
|
||||
obj->setString(text);
|
||||
_vm->_dat->setObjectString(objectIndex, text);
|
||||
_vm->_res->freeResource(menu);
|
||||
if (text)
|
||||
length = strlen(text);
|
||||
} else {
|
||||
_vm->_dat->setObjectString(objectIndex, "");
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
@ -836,11 +834,8 @@ int16 ScriptFunctions::sfSaveGame(int16 argc, int16 *argv) {
|
|||
if (saveNum > 999)
|
||||
return 6;
|
||||
|
||||
Object *obj = _vm->_dat->getObject(descObjectIndex);
|
||||
const char *description = obj->getString();
|
||||
|
||||
const char *description = _vm->_dat->getObjectString(descObjectIndex);
|
||||
Common::String filename = _vm->getSavegameFilename(saveNum);
|
||||
|
||||
return _vm->_dat->savegame(filename.c_str(), description, version);
|
||||
|
||||
}
|
||||
|
@ -854,7 +849,6 @@ int16 ScriptFunctions::sfLoadGame(int16 argc, int16 *argv) {
|
|||
return 1;
|
||||
|
||||
Common::String filename = _vm->getSavegameFilename(saveNum);
|
||||
|
||||
return _vm->_dat->loadgame(filename.c_str(), version);
|
||||
|
||||
}
|
||||
|
@ -871,13 +865,11 @@ int16 ScriptFunctions::sfGetGameDescription(int16 argc, int16 *argv) {
|
|||
|
||||
Common::String filename = _vm->getSavegameFilename(saveNum);
|
||||
|
||||
Object *obj = _vm->_dat->getObject(descObjectIndex);
|
||||
|
||||
if (_vm->_dat->getSavegameDescription(filename.c_str(), description)) {
|
||||
obj->setString(description.c_str());
|
||||
_vm->_dat->setObjectString(descObjectIndex, description.c_str());
|
||||
return 0;
|
||||
} else {
|
||||
obj->setString("");
|
||||
_vm->_dat->setObjectString(descObjectIndex, "");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue