aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2007-03-10 14:52:33 +0000
committerNicola Mettifogo2007-03-10 14:52:33 +0000
commit479c8bdc18080e1d39740fc151bcb88628382a5a (patch)
treeac576e808997beeec88c250f8db74b83fb308e06 /engines
parent6ee9e52f4b1c1481a88d1285f8e5c53e33939255 (diff)
downloadscummvm-rg350-479c8bdc18080e1d39740fc151bcb88628382a5a.tar.gz
scummvm-rg350-479c8bdc18080e1d39740fc151bcb88628382a5a.tar.bz2
scummvm-rg350-479c8bdc18080e1d39740fc151bcb88628382a5a.zip
character loading/freeing routines now also handle Heads and Talks, instead of having scattered code around
svn-id: r26059
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/dialogue.cpp23
-rw-r--r--engines/parallaction/graphics.cpp2
-rw-r--r--engines/parallaction/parallaction.cpp19
-rw-r--r--engines/parallaction/parallaction.h2
-rw-r--r--engines/parallaction/zone.cpp27
5 files changed, 35 insertions, 38 deletions
diff --git a/engines/parallaction/dialogue.cpp b/engines/parallaction/dialogue.cpp
index d0bd979b69..27ba38ded0 100644
--- a/engines/parallaction/dialogue.cpp
+++ b/engines/parallaction/dialogue.cpp
@@ -229,15 +229,13 @@ void runDialogue(SpeakData *data) {
debugC(1, kDebugDialogue, "runDialogue: special trick for 'museum' location");
}
- _vm->_disk->loadTalk(_vm->_characterName, &_characterFace);
-
_vm->_graphics->setFont("comic");
Cnv v6E;
StaticCnv v5C, v48;
if (!scumm_stricmp(data->_name, "yourself") || data->_name[0] == '\0') {
- memcpy(&v6E, &_characterFace, sizeof(Cnv));
+ memcpy(&v6E, &_yourTalk, sizeof(Cnv));
debugC(1, kDebugDialogue, "runDialogue: using default character head");
} else {
debugC(1, kDebugDialogue, "runDialogue: loading 2nd character head '%s'", _vm->_characterName);
@@ -248,8 +246,8 @@ void runDialogue(SpeakData *data) {
v5C._width = v6E._width;
v5C._height = v6E._height;
- v48._width = _characterFace._width;
- v48._height = _characterFace._height;
+ v48._width = _yourTalk._width;
+ v48._height = _yourTalk._height;
bool displayedAnswers = false;
int16 question_width = 0, question_height = 0;
@@ -262,8 +260,8 @@ void runDialogue(SpeakData *data) {
v5C._data0 = v6E._array[v60->_mood & 0xF];
// v5C._data1 = v6E.field_8[v60->_mood & 0xF];
- v48._data0 = _characterFace._array[0];
-// v48._data1 = _characterFace.field_8[0];
+ v48._data0 = _yourTalk._array[0];
+// v48._data1 = _yourTalk.field_8[0];
// display Question if any
if (scumm_stricmp(v60->_text, "NULL")) {
@@ -497,9 +495,6 @@ void runDialogue(SpeakData *data) {
debugC(1, kDebugDialogue, "runDialogue: out of dialogue loop");
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
- _vm->_graphics->freeCnv(&_characterFace);
- debugC(1, kDebugDialogue, "runDialogue: 1st character head free'd");
-
if (scumm_stricmp(data->_name, "yourself") || data->_name[0] == '\0') {
_vm->_graphics->freeCnv(&v6E);
debugC(1, kDebugDialogue, "runDialogue: 2nd character head free'd");
@@ -551,8 +546,8 @@ int16 selectAnswer(Question *q, StaticCnv *cnv) {
0
);
- cnv->_data0 = _characterFace._array[q->_answer_moods[_di] & 0xF];
-// cnv->_data1 = _characterFace.field_8[q->_answer_moods[_di] & 0xF];
+ cnv->_data0 = _yourTalk._array[q->_answer_moods[_di] & 0xF];
+// cnv->_data1 = _yourTalk.field_8[q->_answer_moods[_di] & 0xF];
_vm->_graphics->flatBlitCnv(
cnv,
@@ -593,8 +588,8 @@ int16 selectAnswer(Question *q, StaticCnv *cnv) {
0
);
- cnv->_data0 = _characterFace._array[q->_answer_moods[_si] & 0xF];
-// cnv->_data1 = _characterFace.field_8[q->_answer_moods[_si] & 0xF];
+ cnv->_data0 = _yourTalk._array[q->_answer_moods[_si] & 0xF];
+// cnv->_data1 = _yourTalk.field_8[q->_answer_moods[_si] & 0xF];
_vm->_graphics->flatBlitCnv(
cnv,
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp
index 1b2168e8ee..775035e78a 100644
--- a/engines/parallaction/graphics.cpp
+++ b/engines/parallaction/graphics.cpp
@@ -926,7 +926,7 @@ void Graphics::freeCnv(Cnv *cnv) {
for (uint16 _si = 0; _si < cnv->_count; _si++) {
free(cnv->_array[_si]);
}
- free(cnv->_array);
+ if (cnv->_array) free(cnv->_array);
cnv->_array = NULL;
return;
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index cb31ad63f4..1a958eb3e9 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -56,6 +56,8 @@ uint32 _engineFlags = 0;
char *_objectsNames[100];
Zone *_activeZone = NULL;
Animation _yourself;
+StaticCnv _yourHead;
+Cnv _yourTalk;
uint16 _score = 1;
Command *_locationACommands = NULL;
Command *_locationCommands = NULL;
@@ -131,7 +133,6 @@ Point _firstPosition = { -1000, -1000 };
char _newLocation[100];
char *_globalTable[32];
uint16 _firstFrame = 0;
-Cnv _characterFace;
byte _mouseHidden = 0;
Node _locationWalkNodes = { 0, 0 };
uint32 _commandFlags = 0;
@@ -261,6 +262,17 @@ int Parallaction::init() {
memset(_locationNames, 0, 120*32);
_numLocations = 0;
+ _yourTalk._width = 0;
+ _yourTalk._height = 0;
+ _yourTalk._count = 0;
+ _yourTalk._array = NULL;
+
+ _yourHead._width = 0;
+ _yourHead._height = 0;
+ _yourHead._data0 = NULL;
+ _yourHead._data1 = NULL;
+ _yourHead._data2 = NULL;
+
_yourself._zone.pos._position._x = 150;
_yourself._zone.pos._position._y = 100;
initInventory();
@@ -820,6 +832,8 @@ void freeCharacterFrames() {
if (_vm->_characterName[0] != 'D') {
_vm->_graphics->freeCnv(&_miniCharacterFrames);
_vm->freeTable(_objectsNames);
+ _vm->_graphics->freeCnv(&_yourTalk);
+ _vm->_graphics->freeStaticCnv(&_yourHead);
}
return;
@@ -858,6 +872,9 @@ void Parallaction::changeCharacter(const char *name) {
strcpy(path, v32);
_disk->loadFrames(path, &_tempFrames);
+ _disk->loadHead(path, &_yourHead);
+ _disk->loadTalk(path, &_yourTalk);
+
if (name[0] != 'D') {
sprintf(path, "mini%s", v32);
_disk->loadFrames(path, &_miniCharacterFrames);
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 65afe9da94..6309fd442b 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -119,7 +119,7 @@ extern char *_globalTable[];
extern char _saveData1[];
extern Point _firstPosition; // starting position after load game??
extern uint16 _firstFrame; // starting frame after load game??
-extern Cnv _characterFace;
+extern Cnv _yourTalk;
extern byte _mouseHidden;
extern uint32 _commandFlags;
extern Cnv _tempFrames;
diff --git a/engines/parallaction/zone.cpp b/engines/parallaction/zone.cpp
index 82669c3ca4..bfb730b856 100644
--- a/engines/parallaction/zone.cpp
+++ b/engines/parallaction/zone.cpp
@@ -37,6 +37,7 @@ Node _zones = { NULL, NULL };
Node _animations = { NULL, NULL };
extern Node helperNode;
+extern StaticCnv _yourHead;
Zone *findZone(const char *name) {
@@ -365,13 +366,11 @@ void Parallaction::parseZoneTypeBlock(Script &script, Zone *z) {
void displayCharacterComment(ExamineData *data) {
if (data->_description == NULL) return;
- _vm->_disk->loadTalk(_vm->_characterName, &_characterFace);
-
StaticCnv v3C;
- v3C._width = _characterFace._width;
- v3C._height = _characterFace._height;
- v3C._data0 = _characterFace._array[0];
- v3C._data1 = NULL; //_characterFace.field_8[0];
+ v3C._width = _yourTalk._width;
+ v3C._height = _yourTalk._height;
+ v3C._data0 = _yourTalk._array[0];
+ v3C._data1 = NULL; //_yourTalk.field_8[0];
v3C._data2 = NULL;
_vm->_graphics->setFont("comic");
@@ -382,15 +381,9 @@ void displayCharacterComment(ExamineData *data) {
_vm->_graphics->drawBalloon(140, 10, v28, v26, 0);
_vm->_graphics->displayWrappedString(data->_description, 140, 10, 130, 0);
-// printf("wait left");
-
waitUntilLeftClick();
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
- _vm->_graphics->freeCnv(&_characterFace);
-
-// printf("done");
-
return;
}
@@ -408,24 +401,18 @@ void displayItemComment(ExamineData *data) {
if (data->_description == NULL) return;
-// printf("displayItemComment()...");
-
char v68[PATH_LEN];
strcpy(v68, data->_filename);
_vm->_disk->loadStatic(v68, &data->_cnv);
_vm->_graphics->flatBlitCnv(&data->_cnv, 140, (SCREEN_HEIGHT - data->_cnv._height)/2, Graphics::kBitFront, data->_cnv._data1);
_vm->_graphics->freeStaticCnv(&data->_cnv);
- StaticCnv cnv;
- _vm->_disk->loadHead(_vm->_characterName, &cnv);
-
int16 v6A = 0, v6C = 0;
_vm->_graphics->setFont("comic");
_vm->_graphics->getStringExtent(data->_description, 130, &v6C, &v6A);
_vm->_graphics->drawBalloon(0, 90, v6C, v6A, 0);
- _vm->_graphics->flatBlitCnv(&cnv, 100, 152, Graphics::kBitFront, cnv._data1);
- _vm->_graphics->freeStaticCnv(&cnv);
+ _vm->_graphics->flatBlitCnv(&_yourHead, 100, 152, Graphics::kBitFront, _yourHead._data1);
_vm->_graphics->displayWrappedString(data->_description, 0, 90, 130, 0);
jobEraseAnimations((void*)1, NULL);
@@ -434,8 +421,6 @@ void displayItemComment(ExamineData *data) {
_vm->_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
-// printf("done");
-
return;
}