aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorAndrew Kurushin2005-04-24 15:17:38 +0000
committerAndrew Kurushin2005-04-24 15:17:38 +0000
commita909052c8d0f5b87c2a7602f2cc64237bd381343 (patch)
treea8d5a57c1177b684e28d2b34d5bd84ce2c87ce49 /saga
parentce3cd9b194633e97eabf693f66498335f1f7557d (diff)
downloadscummvm-rg350-a909052c8d0f5b87c2a7602f2cc64237bd381343.tar.gz
scummvm-rg350-a909052c8d0f5b87c2a7602f2cc64237bd381343.tar.bz2
scummvm-rg350-a909052c8d0f5b87c2a7602f2cc64237bd381343.zip
fixed object frawing
implemented sfGetObjImage, sfSetObjImage, sfSetObjName svn-id: r17789
Diffstat (limited to 'saga')
-rw-r--r--saga/actor.cpp9
-rw-r--r--saga/interface.cpp5
-rw-r--r--saga/interface.h11
-rw-r--r--saga/saga.h2
-rw-r--r--saga/scene.cpp52
-rw-r--r--saga/script.h6
-rw-r--r--saga/sfuncs.cpp71
-rw-r--r--saga/sthread.cpp15
8 files changed, 62 insertions, 109 deletions
diff --git a/saga/actor.cpp b/saga/actor.cpp
index 7b62c36bc2..297919d67c 100644
--- a/saga/actor.cpp
+++ b/saga/actor.cpp
@@ -1246,11 +1246,14 @@ bool Actor::getSpriteParams(CommonObjectData *commonObjectData, int &frameNumber
frameNumber = 8;
spriteList = &_vm->_sprite->_mainSprites;
} else {
- frameNumber = commonObjectData->frameNumber;
if (validActorId(commonObjectData->id)) {
spriteList = &((ActorData*)commonObjectData)->spriteList;
+ frameNumber = commonObjectData->frameNumber;
} else {
- spriteList = &_vm->_sprite->_mainSprites;
+ if (validObjId(commonObjectData->id)) {
+ spriteList = &_vm->_sprite->_mainSprites;
+ frameNumber = commonObjectData->spriteListResourceId;
+ }
}
}
@@ -1806,8 +1809,6 @@ void Actor::findActorPath(ActorData *actor, const Point &fromPoint, const Point
for (iteratorPoint.y = 0; iteratorPoint.y < _yCellCount; iteratorPoint.y++) {
for (iteratorPoint.x = 0; iteratorPoint.x < _xCellCount; iteratorPoint.x++) {
- // This is almost, but not quite, the same thing as canWalk().
- // Is that difference significant or not?
if (_vm->_scene->validBGMaskPoint(iteratorPoint)) {
maskType = _vm->_scene->getBGMaskType(iteratorPoint);
setPathCell(iteratorPoint, _vm->_scene->getDoorState(maskType) ? kPathCellBarrier : kPathCellEmpty);
diff --git a/saga/interface.cpp b/saga/interface.cpp
index f1e5c03cab..7e1c5e500e 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -412,7 +412,7 @@ int Interface::draw() {
_vm->_sprite->draw(backBuffer, _scenePortraits, _rightPortrait, rightPortraitPoint, 256);
}
- drawInventory();
+ drawInventory(backBuffer);
return SUCCESS;
}
@@ -692,10 +692,9 @@ int Interface::inventoryItemPosition(int objectId) {
return -1;
}
-void Interface::drawInventory() {
+void Interface::drawInventory(SURFACE *backBuffer) {
if (_panelMode != kPanelMain)
return;
- SURFACE *backBuffer = _vm->_gfx->getBackBuffer();
int i;
Rect rect;
int ci;
diff --git a/saga/interface.h b/saga/interface.h
index df48e0b775..ea0d31f4c0 100644
--- a/saga/interface.h
+++ b/saga/interface.h
@@ -163,14 +163,21 @@ public:
bool processKeyCode(int keyCode);
+private:
+ void drawInventory(SURFACE *backBuffer);
+ void updateInventory(int pos);
void inventoryChangePos(int chg);
void inventorySetPos(int key);
+
+public:
+ void refreshInventory() {
+ updateInventory(_inventoryCount);
+ draw();
+ }
void addToInventory(int objectId, int pos = -1);
void removeFromInventory(int objectId);
void clearInventory();
int inventoryItemPosition(int objectId);
- void drawInventory();
- void updateInventory(int pos);
int getInventoryContentByPanelButton(PanelButton * panelButton) {
int cell = _inventoryStart + panelButton->id;
if (cell >= _inventoryCount) {
diff --git a/saga/saga.h b/saga/saga.h
index f77ede24a7..081d820275 100644
--- a/saga/saga.h
+++ b/saga/saga.h
@@ -71,6 +71,8 @@ class PalAnim;
#define OBJECT_TYPE_SHIFT 13
#define OBJECT_TYPE_MASK ((1 << OBJECT_TYPE_SHIFT) - 1)
+#define OBJ_SPRITE_BASE 9
+
#define memoryError(Place) error("%s Memory allocation error.", Place)
struct RSCFILE_CONTEXT;
diff --git a/saga/scene.cpp b/saga/scene.cpp
index e92df32030..166195827b 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -387,7 +387,6 @@ bool Scene::offscreenPath(Point &testPoint) {
Point first;
Point second;
Point third;
- int maskType;
if (!_bgMask.loaded) {
return false;
@@ -404,57 +403,6 @@ bool Scene::offscreenPath(Point &testPoint) {
}
testPoint = first;
- if (testPoint.y != first.y) {
- second.x = third.x = testPoint.x;
- second.y = third.y = first.y;
- for (;; second.x--, third.x++ ) {
- if (second.x > 1) {
- maskType = getBGMaskType(second);
- if (getDoorState(maskType) == 0) {
- testPoint.x = second.x - 1;
- break;
- }
- } else {
- if (third.x >= _bgMask.w) {
- return false;
- }
- }
-
- if (third.x < _bgMask.w) {
- maskType = getBGMaskType(third);
- if (getDoorState(maskType) == 0) {
- testPoint.x = third.x + 1;
- break;
- }
- }
- }
- }
-
- if (testPoint.x != first.x) {
- second.y = third.y = testPoint.y;
- second.x = third.x = first.x;
- for (;; second.y--, third.y++ ) {
- if (second.y > 1) {
- maskType = getBGMaskType(second);
- if (getDoorState(maskType) == 0) {
- testPoint.y = second.y - 1;
- break;
- }
- } else {
- if (third.y >= _bgMask.h) {
- return false;
- }
- }
-
- if (third.y < _bgMask.h) {
- maskType = getBGMaskType(third);
- if (getDoorState(maskType) == 0) {
- testPoint.y = third.y + 1;
- break;
- }
- }
- }
- }
return true;
}
diff --git a/saga/script.h b/saga/script.h
index 3334dab1f7..807dd3111c 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -479,9 +479,9 @@ private:
void sfSetFollower(SCRIPTFUNC_PARAMS);
void sfScriptGotoScene(SCRIPTFUNC_PARAMS);
- void SF_setObjImage(SCRIPTFUNC_PARAMS);
- void SF_setObjName(SCRIPTFUNC_PARAMS);
- void SF_getObjImage(SCRIPTFUNC_PARAMS);
+ void sfSetObjImage(SCRIPTFUNC_PARAMS);
+ void sfSetObjName(SCRIPTFUNC_PARAMS);
+ void sfGetObjImage(SCRIPTFUNC_PARAMS);
void SF_getNumber(SCRIPTFUNC_PARAMS);
void sfScriptOpenDoor(SCRIPTFUNC_PARAMS);
void sfScriptCloseDoor(SCRIPTFUNC_PARAMS);
diff --git a/saga/sfuncs.cpp b/saga/sfuncs.cpp
index 6b5f1fe1ab..434873069c 100644
--- a/saga/sfuncs.cpp
+++ b/saga/sfuncs.cpp
@@ -67,9 +67,9 @@ void Script::setupScriptFuncList(void) {
OPCODE(sfFaceTowards),
OPCODE(sfSetFollower),
OPCODE(sfScriptGotoScene),
- OPCODE(SF_setObjImage),
- OPCODE(SF_setObjName),
- OPCODE(SF_getObjImage),
+ OPCODE(sfSetObjImage),
+ OPCODE(sfSetObjName),
+ OPCODE(sfGetObjImage),
OPCODE(SF_getNumber),
OPCODE(sfScriptOpenDoor),
OPCODE(sfScriptCloseDoor),
@@ -521,52 +521,46 @@ void Script::sfScriptGotoScene(SCRIPTFUNC_PARAMS) {
}
// Script function #17 (0x11)
-void Script::SF_setObjImage(SCRIPTFUNC_PARAMS) {
- error("SF_setObjImage Not implemented");
-/* int16 obj_param = getSWord(thread->pop());
- int16 sprite_param = getSWord(thread->pop());
-
-
- int index = obj_param & 0x1FFF;
+// Param1: object id
+// Param2: sprite index
+void Script::sfSetObjImage(SCRIPTFUNC_PARAMS) {
+ uint16 objectId;
+ uint16 spriteId;
+ ObjectData *obj;
- if (index >= ARRAYSIZE(ObjectTable)) {
- return FAILURE;
- }
+ objectId = thread->pop();
+ spriteId = thread->pop();
- ObjectTable[index].spritelistRn = sprite_param + 9;
- _vm->_interface->draw();
-*/
+ obj = _vm->_actor->getObj(objectId);
+ obj->spriteListResourceId = OBJ_SPRITE_BASE + spriteId;
+ _vm->_interface->refreshInventory();
}
// Script function #18 (0x12)
-void Script::SF_setObjName(SCRIPTFUNC_PARAMS) {
- error("SF_setObjName Not implemented");
-
-/* int obj_param = getSWord(thread->pop());
- int name_param = getSWord(thread->pop());
-
- int index = obj_param & 0x1FFF;
+// Param1: object id
+// Param2: name index
+void Script::sfSetObjName(SCRIPTFUNC_PARAMS) {
+ uint16 objectId;
+ uint16 nameIdx;
+ ObjectData *obj;
- if (index >= ARRAYSIZE(ObjectTable)) {
- return FAILURE;
- }
+ objectId = thread->pop();
+ nameIdx = thread->pop();
- ObjectTable[index].nameIndex = name_param;*/
+ obj = _vm->_actor->getObj(objectId);
+ obj->nameIndex = nameIdx;
}
// Script function #19 (0x13)
-void Script::SF_getObjImage(SCRIPTFUNC_PARAMS) {
- error("SF_getObjImage Not implemented");
-
-/* int param = getSWord(thread->pop());
- int index = param & 0x1FFF;
+// Param1: object id
+void Script::sfGetObjImage(SCRIPTFUNC_PARAMS) {
+ uint16 objectId;
+ ObjectData *obj;
- if (index >= ARRAYSIZE(ObjectTable)) {
- thread->retVal = 0;
- return FAILURE;
- }
+ objectId = thread->pop();
- thread->retVal = ObjectTable[index].spritelistRn;*/
+ obj = _vm->_actor->getObj(objectId);
+ thread->_returnValue = obj->spriteListResourceId - OBJ_SPRITE_BASE;
}
// Script function #20 (0x14)
@@ -702,7 +696,6 @@ void Script::sfSetActorState(SCRIPTFUNC_PARAMS) {
}
actor->currentAction = currentAction;
actor->actorFlags &= ~kActorBackwards;
-
}
// Script function #30 (0x1E) nonblocking
@@ -754,7 +747,7 @@ void Script::sfDropObject(SCRIPTFUNC_PARAMS) {
}
obj->sceneNumber = _vm->_scene->currentSceneNumber();
- obj->spriteListResourceId = 9 + spriteId;
+ obj->spriteListResourceId = OBJ_SPRITE_BASE + spriteId;
obj->location.x = x;
obj->location.y = y;
}
diff --git a/saga/sthread.cpp b/saga/sthread.cpp
index dea95a6a14..f253810f24 100644
--- a/saga/sthread.cpp
+++ b/saga/sthread.cpp
@@ -223,9 +223,12 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
savedInstructionOffset = thread->_instructionOffset;
operandChar = scriptS.readByte();
-#define CASEOP(opName) case opName: \
- if (operandChar == opName) { \
- operandName = #opName; \
+
+#define CASEOP(opName) case opName: \
+ if (operandChar == opName) { \
+ operandName = #opName; \
+ debug(8, operandName); \
+ _vm->_console->DebugPrintf("%s\n", operandName); \
}
// debug(8, "Executing thread offset: %lu (%x) stack: %d", thread->_instructionOffset, operandChar, thread->pushedSize());
@@ -254,6 +257,7 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
CASEOP(opStrlit)
iparam1 = scriptS.readSint16LE();
thread->push(iparam1);
+ debug(8, "0x%X", iparam1);
break;
// DATA INSTRUCTIONS
@@ -269,6 +273,7 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
iparam1 = scriptS.readSint16LE();
addr += iparam1;
thread->push(*((uint16*)addr));
+ debug(8, "0x%X", *((uint16*)addr));
break;
CASEOP(opPutFlag)
addr = thread->baseAddress(scriptS.readByte());
@@ -513,6 +518,7 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
iparam2 = thread->pop();
iparam1 = thread->pop();
thread->push((iparam1 == iparam2) ? 1 : 0);
+ debug(8, "0x%X 0x%X", iparam1, iparam2);
break;
CASEOP(opNe)
iparam2 = thread->pop();
@@ -689,9 +695,6 @@ bool Script::runThread(ScriptThread *thread, uint instructionLimit) {
error("Script::runThread() Invalid opcode encountered 0x%X", operandChar);
}
- debug(8, operandName);
- _vm->_console->DebugPrintf("%s\n", operandName);
-
if (thread->_flags & (kTFlagFinished | kTFlagAborted)) {
error("Wrong flags %d in thread", thread->_flags);
}