Add sentence line to C64 maniac

svn-id: r21007
This commit is contained in:
Travis Howell 2006-03-02 10:31:11 +00:00
parent f4f8a9263a
commit 949057f790
3 changed files with 120 additions and 16 deletions

View File

@ -415,8 +415,10 @@ protected:
virtual void initScummVars();
virtual void decodeParseString();
void initC64Verbs();
virtual void checkExecVerbs();
virtual void handleMouseOver(bool updateInventory);
void initC64Verbs();
void drawSentence();
virtual int getVarOrDirectWord(byte mask);
virtual uint fetchScriptWord();

View File

@ -459,6 +459,100 @@ void ScummEngine_c64::ifNotStateCommon(byte type) {
}
}
void ScummEngine_c64::drawSentence() {
Common::Rect sentenceline;
static char sentence[256];
const byte *temp;
int sentencePrep = 0;
if (!(_userState & 32))
return;
if (getResourceAddress(rtVerb, _activeVerb)) {
strcpy(sentence, (char*)getResourceAddress(rtVerb, _activeVerb));
} else {
return;
}
if (_activeObject > 0) {
temp = getObjOrActorName(_activeObject);
if (temp) {
strcat(sentence, " ");
strcat(sentence, (const char*)temp);
}
if (_verbs[_activeVerb].prep == 0xFF) {
byte *ptr = getOBCDFromObject(_activeObject);
assert(ptr);
sentencePrep = (*(ptr + 11) >> 5);
} else {
sentencePrep = _verbs[_activeVerb].prep;
}
}
if (sentencePrep > 0 && sentencePrep <= 4) {
printf("sentencePrep is %d\n", sentencePrep);
// The prepositions, like the fonts, were hard code in the engine. Thus
// we have to do that, too, and provde localized versions for all the
// languages MM/Zak are available in.
//
// The order here matches the one defined in gameDetector.h
const char *prepositions[][5] = {
{ " ", " in", " with", " on", " to" }, // English
{ " ", " mit", " mit", " mit", " zu" }, // German
{ " ", " dans", " avec", " sur", " <" },// French
{ " ", " in", " con", " su", " a" }, // Italian
{ " ", " in", " with", " on", " to" }, // Portugese
{ " ", " en", " con", " en", " a" }, // Spanish
{ " ", " in", " with", " on", " to" }, // Japanese
{ " ", " in", " with", " on", " to" }, // Chinese
{ " ", " in", " with", " on", " to" } // Korean
};
int lang = (_language <= 8) ? _language : 0; // Default to english
strcat(sentence, prepositions[lang][sentencePrep]);
}
/* if (_activeObject2 > 0) {
temp = getObjOrActorName(_activeObject2);
if (temp) {
strcat(sentence, " ");
strcat(sentence, (const char*)temp);
}
} */
_string[2].charset = 1;
_string[2].ypos = virtscr[kVerbVirtScreen].topline;
_string[2].xpos = 0;
_string[2].color = 16;
byte string[80];
char *ptr = sentence;
int i = 0, len = 0;
// Maximum length of printable characters
int maxChars = 40;
while (*ptr) {
if (*ptr != '@')
len++;
if (len > maxChars) {
break;
}
string[i++] = *ptr++;
}
string[i] = 0;
sentenceline.top = virtscr[kVerbVirtScreen].topline;
sentenceline.bottom = virtscr[kVerbVirtScreen].topline + 8;
sentenceline.left = 0;
sentenceline.right = 319;
restoreBG(sentenceline);
drawString(2, (byte*)string);
}
void ScummEngine_c64::o_setState08() {
int obj = getObjectFlag();
putState(obj, getState(obj) | 0x08);

View File

@ -42,26 +42,27 @@ struct VerbSettings {
int id;
int x_pos;
int y_pos;
int prep;
const char *name;
};
static const VerbSettings C64VerbTable[] =
{
{ 1, 8, 0, "Open"},
{ 2, 8, 1, "Close"},
{ 3, 0, 2, "Give"},
{ 4, 32, 0, "Turn On"},
{ 5, 32, 1, "Turn Off"},
{ 6, 32, 2, "Fix"},
{ 7, 24, 0, "New Kid"},
{ 8, 24, 1, "Unlock"},
{ 9, 0, 0, "Push"},
{10, 0, 1, "Pull"},
{11, 24, 2, "Use"},
{12, 8, 2, "Read"},
{13, 15, 0, "Walk To"},
{14, 15, 1, "Pick Up"},
{15, 15, 2, "What Is"}
{ 1, 8, 0, 0, "Open"},
{ 2, 8, 1, 0, "Close"},
{ 3, 0, 2, 4, "Give"},
{ 4, 32, 0, 0, "Turn On"},
{ 5, 32, 1, 0, "Turn Off"},
{ 6, 32, 2, 2, "Fix"},
{ 7, 24, 0, 0, "New Kid"},
{ 8, 24, 1, 2, "Unlock"},
{ 9, 0, 0, 0, "Push"},
{10, 0, 1, 0, "Pull"},
{11, 24, 2, 255, "Use"},
{12, 8, 2, 0, "Read"},
{13, 15, 0, 0, "Walk To"},
{14, 15, 1, 0, "Pick Up"},
{15, 15, 2, 0, "What Is"}
};
void ScummEngine_c64::initC64Verbs() {
@ -82,6 +83,7 @@ void ScummEngine_c64::initC64Verbs() {
vs->key = 0;
vs->center = 0;
vs->imgindex = 0;
vs->prep = C64VerbTable[i - 1].prep;
vs->curRect.left = C64VerbTable[i - 1].x_pos * 8;
vs->curRect.top = C64VerbTable[i - 1].y_pos * 8 + virt->topline + 8;
@ -431,6 +433,12 @@ void ScummEngine_v2::handleMouseOver(bool updateInventory) {
checkV2MouseOver(_mouse);
}
void ScummEngine_c64::handleMouseOver(bool updateInventory) {
ScummEngine_v2::handleMouseOver(updateInventory);
drawSentence();
}
void ScummEngine::checkExecVerbs() {
int i, over;
VerbSlot *vs;