/* ScummVM - Scumm Interpreter * Copyright (C) 2001 Ludvig Strigeus * Copyright (C) 2001-2006 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * $URL$ * $Id$ * */ #include "common/stdafx.h" #include "common/file.h" #include "agos/agos.h" #include "agos/intern.h" using Common::File; namespace AGOS { void AGOSEngine::loadMenuFile() { Common::File in; in.open(getFileName(GAME_MENUFILE)); if (in.isOpen() == false) { error("loadMenuFile: Can't load menus file '%s'", getFileName(GAME_MENUFILE)); } uint fileSize = in.size(); _menuBase = (byte *)malloc(fileSize); if (_menuBase == NULL) error("loadMenuFile: Out of memory for menu data"); in.read(_menuBase, fileSize); in.close(); } // Elvira 1 specific void AGOSEngine::drawMenuStrip(uint windowNum, uint menuNum) { WindowBlock *window = _windowArray[windowNum % 8]; mouseOff(); byte *srcPtr = _menuBase; int menu = (menuNum != 0) ? menuNum * 4 + 1 : 0; while (menu--) { if (READ_LE_UINT16(srcPtr) != 0xFFFF) { srcPtr += 2; while (*srcPtr != 0) srcPtr++; srcPtr++; } else { srcPtr += 2; } } clearWindow(window); int newline = 0; while (READ_LE_UINT16(srcPtr) != 0xFFFF) { byte *tmp = srcPtr; srcPtr += 2; if (newline != 0) { windowPutChar(window, 10); } uint len = 0; while (*srcPtr != 0 && *srcPtr != 1) { len++; srcPtr++; } if (*srcPtr == 1) srcPtr++; uint maxLen = window->textMaxLength - len; if (window->flags & 1) window->textColumnOffset += 4; maxLen /= 2; while (maxLen--) windowPutChar(window, 32); srcPtr = tmp; uint verb = READ_BE_UINT16(srcPtr); srcPtr += 2; while (*srcPtr != 0) { windowPutChar(window, *srcPtr++); } srcPtr++; if (verb != 0xFFFE) { HitArea *ha = findEmptyHitArea(); ha->x = window->x * 8 + 3; ha->y = window->textRow * 8 + window->y; ha->data = menuNum; ha->width = window->width * 8 - 6; ha->height = 7; ha->flags = kBFBoxInUse | kBFInvertTouch; ha->id = 30000; ha->priority = 1; ha->verb = verb; } newline = 0xFFFF; } mouseOn(); } // Waxworks specific? uint AGOSEngine::menuFor(Item *item, uint id) { if (id != 0xFFFF && id < 10 && _textMenu[id] != 0) { return _textMenu[id]; } else { // TODO } return 0; } void AGOSEngine::clearMenuStrip() { int i; for (i = 111; i != 115; i++) disableBox(i); set_video_mode_internal(2, 101); } void AGOSEngine::doMenuStrip(uint menuNum) { int i; for (i = 111; i != 115; i++) disableBox(i); for (i = 11; i != 16; i++) _variableArray[i] = 0; byte *srcPtr = _menuBase; while (menuNum--) { while (READ_BE_UINT16(srcPtr) != 0) srcPtr += 2; srcPtr += 2; } uint id = 111; uint var = 11; while (READ_BE_UINT16(srcPtr) != 0) { uint verb = READ_BE_UINT16(srcPtr); _variableArray[var] = verb; HitArea *ha = findBox(id); if (ha != NULL) { ha->flags &= ~kBFBoxDead; ha->verb = verb; } id++; srcPtr += 2; var++; } _variableArray[15] = id - 111; set_video_mode_internal(2, 102); } } // End of namespace AGOS