diff options
author | Travis Howell | 2006-10-07 03:02:56 +0000 |
---|---|---|
committer | Travis Howell | 2006-10-07 03:02:56 +0000 |
commit | 8afacd96b9cc22edcd8e2df937667b7e0f131e5a (patch) | |
tree | cb5b7b64e30c70042f4e3b3c21e53347cd7711e9 | |
parent | f11c3d1f26a1085cb37591da31aa58d2b0a3b076 (diff) | |
download | scummvm-rg350-8afacd96b9cc22edcd8e2df937667b7e0f131e5a.tar.gz scummvm-rg350-8afacd96b9cc22edcd8e2df937667b7e0f131e5a.tar.bz2 scummvm-rg350-8afacd96b9cc22edcd8e2df937667b7e0f131e5a.zip |
Add code for printing to boxes in Waxworks
svn-id: r24156
-rw-r--r-- | engines/agos/agos.cpp | 14 | ||||
-rw-r--r-- | engines/agos/agos.h | 35 | ||||
-rw-r--r-- | engines/agos/debug.h | 36 | ||||
-rw-r--r-- | engines/agos/items.cpp | 86 | ||||
-rw-r--r-- | engines/agos/string.cpp | 257 |
5 files changed, 379 insertions, 49 deletions
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp index 978c0b9adb..eb049d5592 100644 --- a/engines/agos/agos.cpp +++ b/engines/agos/agos.cpp @@ -318,13 +318,27 @@ AGOSEngine::AGOSEngine(OSystem *syst) _nextVgaTimerToProcess = 0; + _agosMenu = 0; _classMask = 0; _classMode1 = 0; _classMode2 = 0; _superRoomNumber = 0; + _boxLineCount = 0; + _boxCR = 0; + memset(_boxBuffer, 0, sizeof(_boxBuffer)); + + _linePtrs[0] = 0; + _linePtrs[1] = 0; + _linePtrs[2] = 0; + _linePtrs[3] = 0; + _linePtrs[4] = 0; + _linePtrs[5] = 0; + memset(_lineCounts, 0, sizeof(_lineCounts)); + memset(_objectArray, 0, sizeof(_objectArray)); memset(_itemStore, 0, sizeof(_itemStore)); + memset(_textMenu, 0, sizeof(_textMenu)); memset(_shortText, 0, sizeof(_shortText)); memset(_shortTextX, 0, sizeof(_shortText)); diff --git a/engines/agos/agos.h b/engines/agos/agos.h index dbcbc947c4..2b6e726c38 100644 --- a/engines/agos/agos.h +++ b/engines/agos/agos.h @@ -302,7 +302,18 @@ protected: const byte *_scrollImage; byte _boxStarHeight; - uint16 _hyperLink, _newLines; + char _boxBuffer[310]; + int _boxLineCount; + int _lineCounts[6]; + char *_linePtrs[6]; + int _boxCR; + + uint _classMask, _classMode1, _classMode2; + int _agosMenu; + byte _textMenu[10]; + uint _superRoomNumber; + + uint16 _hyperLink, _newLines; uint16 _oracleMaxScrollY, _noOracleScroll; uint16 _interactY; @@ -756,6 +767,12 @@ protected: void renderStringAmiga(uint vga_sprite_id, uint color, uint width, uint height, const char *txt); void renderString(uint vga_sprite_id, uint color, uint width, uint height, const char *txt); + void boxTextMessage(const char *x); + void boxTextMsg(const char *x); + void printBox(); + uint16 getBoxSize(); + uint16 checkFit(char *Ptr, int width, int lines); + byte *allocBlock(uint32 size); void checkNoOverWrite(); void checkRunningAnims(); @@ -1010,9 +1027,6 @@ public: void moveDirn_e2(Item *i, uint x); void moveDirn_ww(Item *i, uint x); - uint _classMask, _classMode1, _classMode2; - uint _superRoomNumber; - int sizeContents(Item *x); int sizeOfRec(Item *o, int d); int sizeRec(Item *x, int d); @@ -1040,11 +1054,13 @@ public: void oe1_pobj(); void oe1_pName(); void oe1_pcName(); + void oe1_means(); void oe1_setUserItem(); void oe1_getUserItem(); void oe1_clearUserItem(); void oe1_findMaster(); void oe1_nextMaster(); + void oe1_setTime(); void oe1_bitTest(); void oe1_zoneDisk(); void oe1_printStats(); @@ -1059,6 +1075,8 @@ public: void oe2_ifDoorLocked(); void oe2_opcode161(); void oe2_screenTextMsg(); + void oe2_setSuperRoom(); + void oe2_getSuperRoom(); // Opcodes, Waxworks only void oww_moveDirn(); @@ -1066,10 +1084,11 @@ public: void oww_whereTo(); void oww_menu(); void oww_textMenu(); - void oww_opcode184(); - void oww_opcode185(); - void oww_opcode186(); - void oww_opcode187(); + void oww_boxMessage(); + void oww_boxMsg(); + void oww_boxLongText(); + void oww_printBox(); + void oww_boxPObj(); // Opcodes, Simon 1 only void o1_printLongText(); diff --git a/engines/agos/debug.h b/engines/agos/debug.h index 99e38399e6..1c1145c550 100644 --- a/engines/agos/debug.h +++ b/engines/agos/debug.h @@ -39,9 +39,9 @@ static const char *const elvira1_opcode_name_table[300] = { "IJ|NOT_CARRIED", /* 8 */ "IIJ|IS_AT", - NULL, - NULL, - NULL, + "IIJ|IS_NOT_AT", + "IIJ|IS_SIBLING", + "IIJ|IS_NOT_SIBLING", /* 12 */ "WJ|IS_ZERO", "WJ|ISNOT_ZERO", @@ -234,7 +234,7 @@ static const char *const elvira1_opcode_name_table[300] = { NULL, /* 164 */ "|RESCAN", - NULL, + "wwwW|MEANS", NULL, NULL, /* 168 */ @@ -351,7 +351,7 @@ static const char *const elvira1_opcode_name_table[300] = { "W|SYNC", "WI|DEF_OBJ", NULL, - NULL, + "|SET_TIME", /* 260 */ NULL, "IJ|IS_SIBLING_WITH_A", @@ -396,9 +396,9 @@ static const char *const ww_opcode_name_table[256] = { "IJ|NOT_CARRIED", "IIJ|IS_AT", /* 8 */ - NULL, - NULL, - NULL, + "IIJ|IS_NOT_AT", + "IIJ|IS_SIBLING", + "IIJ|IS_NOT_SIBLING", "VJ|IS_ZERO", /* 12 */ "VJ|ISNOT_ZERO", @@ -539,7 +539,7 @@ static const char *const ww_opcode_name_table[256] = { "W|SYNC", "BI|DEF_OBJ", NULL, - NULL, + "|SET_TIME", /* 124 */ NULL, "IJ|IS_SIBLING_WITH_A", @@ -592,8 +592,8 @@ static const char *const ww_opcode_name_table[256] = { "W|PLAY_EFFECT", /* 164 */ "|getDollar2", - "IWWJ|IS_ADJ_NOUN", - "B|SET_BIT2", + "W|SET_SUPER_ROOM", + "BV|GET_SUPER_ROOM", "B|CLEAR_BIT2", /* 168 */ "BJ|IS_BIT2_CLEAR", @@ -616,14 +616,14 @@ static const char *const ww_opcode_name_table[256] = { "BJ|IS_BIT2_CLEAR", "BJ|IS_BIT2_SET", /* 184 */ - "T|UNK_184", - "T|UNK_185", - "B|UNK_186", - "|UNK_187", + "T|BOX_MESSAGE", + "T|BOX_MSG", + "B|BOX_LONG_TEXT", + "|PRINT_BOX", /* 188 */ - "I|UNK_188", - "|UNK_189", - "|UNK_190", + "I|BOX_POBJ", + "|LOCK_ZONES", + "|UNLOCK_ZONES", }; static const char *const simon1dos_opcode_name_table[256] = { diff --git a/engines/agos/items.cpp b/engines/agos/items.cpp index 458e48d77e..9d170b4bc9 100644 --- a/engines/agos/items.cpp +++ b/engines/agos/items.cpp @@ -261,6 +261,7 @@ void AGOSEngine::setupElvira1Opcodes(OpcodeProc *op) { op[152] = &AGOSEngine::o_debug; op[164] = &AGOSEngine::o1_rescan; + op[165] = &AGOSEngine::oe1_means; op[176] = &AGOSEngine::oe1_setUserItem; op[177] = &AGOSEngine::oe1_getUserItem; @@ -301,6 +302,8 @@ void AGOSEngine::setupElvira1Opcodes(OpcodeProc *op) { op[253] = &AGOSEngine::oe1_bitTest; + op[259] = &AGOSEngine::oe1_setTime; + op[255] = &AGOSEngine::o_waitSync; op[256] = &AGOSEngine::o_sync; op[257] = &AGOSEngine::o_defObj; @@ -331,6 +334,9 @@ void AGOSEngine::setupElvira1Opcodes(OpcodeProc *op) { void AGOSEngine::setupElvira2Opcodes(OpcodeProc *op) { setupCommonOpcodes(op); + op[8] = &AGOSEngine::oe1_isNotAt; + op[9] = &AGOSEngine::oe1_sibling; + op[10] = &AGOSEngine::oe1_notSibling; op[24] = &AGOSEngine::oe1_isPlayer; op[29] = &AGOSEngine::oe1_canPut; op[34] = &AGOSEngine::oe1_copyof; @@ -344,6 +350,7 @@ void AGOSEngine::setupElvira2Opcodes(OpcodeProc *op) { op[89] = &AGOSEngine::oe2_loadUserGame; op[98] = &AGOSEngine::o1_animate; op[99] = &AGOSEngine::o1_stopAnimate; + op[123] = &AGOSEngine::oe1_setTime; op[127] = &AGOSEngine::o1_playTune; op[144] = &AGOSEngine::oe2_setDoorOpen; op[145] = &AGOSEngine::oe2_setDoorClosed; @@ -354,6 +361,8 @@ void AGOSEngine::setupElvira2Opcodes(OpcodeProc *op) { op[150] = &AGOSEngine::oe2_ifDoorLocked; op[161] = &AGOSEngine::oe2_opcode161; op[162] = &AGOSEngine::oe2_screenTextMsg; + op[165] = &AGOSEngine::oe2_setSuperRoom; + op[166] = &AGOSEngine::oe2_getSuperRoom; op[175] = &AGOSEngine::o_getDollar2; op[179] = &AGOSEngine::o_isAdjNoun; op[180] = &AGOSEngine::o_b2Set; @@ -364,8 +373,6 @@ void AGOSEngine::setupElvira2Opcodes(OpcodeProc *op) { // Code difference, check if triggered op[163] = NULL; op[164] = NULL; - op[165] = NULL; - op[166] = NULL; op[167] = NULL; op[168] = NULL; op[169] = NULL; @@ -383,6 +390,9 @@ void AGOSEngine::setupWaxworksOpcodes(OpcodeProc *op) { setupCommonOpcodes(op); // Confirmed + op[8] = &AGOSEngine::oe1_isNotAt; + op[9] = &AGOSEngine::oe1_sibling; + op[10] = &AGOSEngine::oe1_notSibling; op[24] = &AGOSEngine::oe1_isPlayer; op[29] = &AGOSEngine::oe1_canPut; op[34] = &AGOSEngine::oe1_copyof; @@ -401,6 +411,7 @@ void AGOSEngine::setupWaxworksOpcodes(OpcodeProc *op) { op[89] = &AGOSEngine::oe2_loadUserGame; op[105] = &AGOSEngine::oww_menu; op[106] = &AGOSEngine::oww_textMenu; + op[123] = &AGOSEngine::oe1_setTime; op[127] = &AGOSEngine::o1_playTune; op[144] = &AGOSEngine::oe2_setDoorOpen; op[145] = &AGOSEngine::oe2_setDoorClosed; @@ -416,10 +427,13 @@ void AGOSEngine::setupWaxworksOpcodes(OpcodeProc *op) { op[181] = &AGOSEngine::o_b2Clear; op[182] = &AGOSEngine::o_b2Zero; op[183] = &AGOSEngine::o_b2NotZero; - op[184] = &AGOSEngine::oww_opcode184; - op[185] = &AGOSEngine::oww_opcode185; - op[186] = &AGOSEngine::oww_opcode186; - op[187] = &AGOSEngine::oww_opcode187; + op[184] = &AGOSEngine::oww_boxMessage; + op[185] = &AGOSEngine::oww_boxMsg; + op[186] = &AGOSEngine::oww_boxLongText; + op[187] = &AGOSEngine::oww_printBox; + op[188] = &AGOSEngine::oww_boxPObj; + op[189] = &AGOSEngine::o_lockZones; + op[190] = &AGOSEngine::o_unlockZones; // Code difference, check if triggered op[161] = NULL; @@ -439,8 +453,6 @@ void AGOSEngine::setupWaxworksOpcodes(OpcodeProc *op) { op[177] = NULL; op[178] = NULL; op[188] = NULL; - op[189] = NULL; - op[190] = NULL; } void AGOSEngine::setupSimon1Opcodes(OpcodeProc *op) { @@ -1911,6 +1923,10 @@ void AGOSEngine::oe1_pcName() { showMessageFormat("%s", name.c_str()); } +void AGOSEngine::oe1_means() { + // TODO +} + void AGOSEngine::oe1_setUserItem() { // 176: set user item Item *i = getNextItemPtr(); @@ -1975,6 +1991,11 @@ void AGOSEngine::oe1_bitTest() { setScriptCondition((_variableArray[var] & (1 << bit)) != 0); } +void AGOSEngine::oe1_setTime() { + // 259: set time + time(&_timeStore); +} + void AGOSEngine::oe1_zoneDisk() { // 267: set disk number of each zone getVarOrWord(); @@ -2043,6 +2064,16 @@ void AGOSEngine::oe2_screenTextMsg() { getVarOrByte(); } +void AGOSEngine::oe2_setSuperRoom() { + // 165: set super room + _superRoomNumber = getVarOrWord(); +} + +void AGOSEngine::oe2_getSuperRoom() { + // 166: get super room + writeNextVarContents(_superRoomNumber); +} + // ----------------------------------------------------------------------- // Waxworks Opcodes // ----------------------------------------------------------------------- @@ -2070,33 +2101,42 @@ void AGOSEngine::oww_whereTo() { } void AGOSEngine::oww_menu() { - // 105: menu - getVarOrByte(); + // 105: set agos menu + _agosMenu = getVarOrByte(); } void AGOSEngine::oww_textMenu() { - // 106: text menu - - /* byte tmp = getVarOrByte(); - TextMenu[tmp] = getVarOrByte(); */ + // 106: set text menu + byte slot = getVarOrByte(); + _textMenu[slot] = getVarOrByte(); +} - getVarOrByte(); - getVarOrByte(); +void AGOSEngine::oww_boxMessage() { + // 184: print message to box + boxTextMessage((const char *)getStringPtrByID(getNextStringID())); } -void AGOSEngine::oww_opcode184() { - printf("%s\n", getStringPtrByID(getNextStringID())); +void AGOSEngine::oww_boxMsg() { + // 185: print msg to box + boxTextMsg((const char *)getStringPtrByID(getNextStringID())); } -void AGOSEngine::oww_opcode185() { - printf("%s\n", getStringPtrByID(getNextStringID())); +void AGOSEngine::oww_boxLongText() { + // 186: print long text to box + boxTextMsg((const char *)getStringPtrByID(_longText[getVarOrByte()])); } -void AGOSEngine::oww_opcode186() { - printf("%s\n", getStringPtrByID(_longText[getVarOrByte()])); +void AGOSEngine::oww_printBox() { + // 187: print box + printBox(); } -void AGOSEngine::oww_opcode187() { +void AGOSEngine::oww_boxPObj() { + // 188: print object flag name to box + SubObject *subObject = (SubObject *)findChildOfType(getNextItemPtr(), 2); + + if (subObject != NULL && subObject->objectFlags & kOFText) + boxTextMsg((const char *)getStringPtrByID(subObject->objectFlagValue[0])); } // ----------------------------------------------------------------------- diff --git a/engines/agos/string.cpp b/engines/agos/string.cpp index 64dd443669..4e523ec104 100644 --- a/engines/agos/string.cpp +++ b/engines/agos/string.cpp @@ -467,4 +467,261 @@ void AGOSEngine::printScreenText(uint vgaSpriteId, uint color, const char *strin loadSprite(b, 2, vgaSpriteId, x, y, 12); } +// String code for boxes in Waxworks +uint16 AGOSEngine::getBoxSize() { + int x; + switch (_boxLineCount) { + case 1: x = _lineCounts[0]; + if (x <= 26) + return 1; + if (x <= 64) + if (checkFit(_linePtrs[0],32,2)) + return 2; + if (x <= 111) + if (checkFit(_linePtrs[0],37,3)) + return 3; + if (x <= 168) + if (checkFit(_linePtrs[0],42,4)) + return 4; + if (x <= 240) + if (checkFit(_linePtrs[0],48,5)) + return 5; + return 6; + case 2: if (_lineCounts[0] <= 32) { + if (_lineCounts[1] <= 32) + return 2; + if (_lineCounts[1] <= 74) + if (checkFit(_linePtrs[1],37,2)) + return 3; + if (_lineCounts[1] <= 126) + if (checkFit(_linePtrs[1],42,3)) + return 4; + if (_lineCounts[1] <= 172) + if (checkFit(_linePtrs[1],48,4)) + return 5; + return 6; + } + if ((_lineCounts[0] <= 74) && (checkFit(_linePtrs[0],37,2))) { + if (_lineCounts[1] <= 37) + return 3; + if (_lineCounts[1] <= 84) + if (checkFit(_linePtrs[1],42,2)) + return 4; + if (_lineCounts[1] <= 144) + if (checkFit(_linePtrs[1],48,3)) + return 5; + return 6; + } + if ((_lineCounts[0] <= 126) && (checkFit(_linePtrs[0],42,3))) { + if (_lineCounts[1] <= 42) + return 4; + if (_lineCounts[1] <= 84) + if (checkFit(_linePtrs[1],48,2)) + return 5; + return 6; + } + if ((_lineCounts[0] <= 192) && (checkFit(_linePtrs[0],48,4))) { + if (_lineCounts[1] <= 48) + return 5; + return 6; + } + return 6; + case 3: if (_lineCounts[0] <= 37) { + if (_lineCounts[1] <= 37) { + if (_lineCounts[2] <= 37) + return 3; + if (_lineCounts[2] <= 84) + if (checkFit(_linePtrs[2],42,2)) + return 4; + if (_lineCounts[2] <= 144) + if (checkFit(_linePtrs[2],48,3)) + return 5; + return 6; + } + if ((_lineCounts[1] <= 84) && (checkFit(_linePtrs[1],42,2))) { + if (_lineCounts[2] <= 42) + return 4; + if (_lineCounts[2] <= 96) + if (checkFit(_linePtrs[2],48,2)) + return 5; + return 6; + } + if ((_lineCounts[1] <= 144) && (checkFit(_linePtrs[1],48,3))) { + if (_lineCounts[2] <= 48) + return 5; + return 6; + } + return 6; + } + if ((_lineCounts[0] <= 84) && (checkFit(_linePtrs[0],42,2))) { + if (_lineCounts[1] <= 42) { + if (_lineCounts[2] <= 42) + return 4; + if (_lineCounts[2] <= 96) + if (checkFit(_linePtrs[2],48,2)) + return 5; + return 6; + } + if ((_lineCounts[1] <= 96) && (checkFit(_linePtrs[1],48,2))) { + if (_lineCounts[2] <= 48) + return 5; + return 6; + } + return 6; + } + if ((_lineCounts[0] <= 96) && (checkFit(_linePtrs[0],48,3))) { + if (_lineCounts[1] <= 48) { + if (_lineCounts[2] <= 48) + return 5; + } + return 6; + } + return 6; + case 4: if (_lineCounts[0] <= 42) { + if (_lineCounts[1] <= 42) { + if (_lineCounts[2] <= 42) { + if (_lineCounts[3] <= 42) + return 4; + if (_lineCounts[3] <= 96) + if (checkFit(_linePtrs[3],48,2)) + return 5; + return 6; + } + if ((_lineCounts[2] <= 96) && (checkFit(_linePtrs[2],48,2))) + if (_lineCounts[3] <= 48) + return 5; + return 6; + } + if ((_lineCounts[1] <= 96) && (checkFit(_linePtrs[1],48,2))) + if ((_lineCounts[2] <= 48) && (_lineCounts[3] <= 48)) + return 5; + return 6; + } + if ((_lineCounts[0] <= 96) && (checkFit(_linePtrs[0],48,2))) + if ((_lineCounts[1] <= 48) && (_lineCounts[2] <= 48) && (_lineCounts[3] <= 48)) + return 5; + return 6; + case 5: if ((_lineCounts[0]>48)||(_lineCounts[1]>48)||(_lineCounts[2]>48) + ||(_lineCounts[3]>48)||(_lineCounts[4]>48)) + return 6; + else + return 5; + default:return 6; + + } +} + + +uint16 AGOSEngine::checkFit(char *Ptr, int width, int lines) { + int countw = 0; + int countl = 0; + char *x; + while( *Ptr) { + if (*Ptr == '\n') + return 1; + if (countw == width) { + countl++; + countw = 0; + Ptr = x; + } + if (*Ptr == ' ') { + x = Ptr; + x++; + } + countw++; + if (countl == lines) + return 0; + Ptr++; + } + return 1; +} + +void AGOSEngine::boxTextMessage(const char *x) { + char *BoxBufferPtr = _boxBuffer; + sprintf(BoxBufferPtr, "%s\n", x); + _lineCounts[_boxLineCount] += strlen(x); + BoxBufferPtr += strlen(x) + 1; + _boxLineCount++; + _linePtrs[_boxLineCount] = BoxBufferPtr; + _boxCR = 1; +} + +void AGOSEngine::boxTextMsg(const char *x) { + char *BoxBufferPtr = _boxBuffer; + sprintf(BoxBufferPtr, "%s", x); + _lineCounts[_boxLineCount] += strlen(x); + BoxBufferPtr += strlen(x); + _boxCR = 0; +} + +void AGOSEngine::printBox() { + char *BoxBufferPtr = 0; + uint16 BoxSize; + _linePtrs[0] = _boxBuffer; + if (_boxCR == 0) + _boxLineCount++; + stopAnimateSimon1(105); + BoxSize=getBoxSize(); + _variableArray[53] = BoxSize; + loadSprite(3, 1, 100, 0, 0, 0); + changeWindow(5); + + switch(BoxSize) { + case 1: _textWindow->x = 10; + _textWindow->y = 163; + _textWindow->width = 20; + _textWindow->height = 1; + _textWindow->textMaxLength = 26; + break; + case 2: _textWindow->x = 8; + _textWindow->y = 160; + _textWindow->width = 24; + _textWindow->height = 2; + _textWindow->textMaxLength = 32; + break; + case 3: _textWindow->x = 6; + _textWindow->y = 156; + _textWindow->width = 28; + _textWindow->height = 3; + _textWindow->textMaxLength = 37; + break; + case 4: _textWindow->x = 4; + _textWindow->y = 153; + _textWindow->width = 32; + _textWindow->height = 4; + _textWindow->textMaxLength = 42; + break; + case 5: _textWindow->x = 2; + _textWindow->y = 150; + _textWindow->width = 36; + _textWindow->height = 5; + _textWindow->textMaxLength = 48; + break; + default:_textWindow->x = 1; + _textWindow->y = 147; + _textWindow->width = 38; + _textWindow->height = 6; + _textWindow->textMaxLength = 50; + break; + } + _textWindow->textColumn = 0; + _textWindow->textRow = 0; + //_textWindow->w_curpixel = 0; + _textWindow->textLength = 0; + showmessage_helper_3(_textWindow->textLength,_textWindow->textMaxLength); + waitForSync(99); + BoxBufferPtr = _boxBuffer; + while (*BoxBufferPtr) + showmessage_print_char(*BoxBufferPtr++); + _boxLineCount = 0; + BoxBufferPtr = _boxBuffer; + _lineCounts[0] = 0; + _lineCounts[1] = 0; + _lineCounts[2] = 0; + _lineCounts[3] = 0; + _lineCounts[4] = 0; + _lineCounts[5] = 0; + changeWindow(0); +} + } // End of namespace AGOS |