2006-02-13 10:29:25 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* 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"
|
2006-04-04 01:38:53 +00:00
|
|
|
|
|
|
|
#include "common/savefile.h"
|
|
|
|
|
2006-02-13 10:29:25 +00:00
|
|
|
#include "simon/simon.h"
|
|
|
|
#include "simon/intern.h"
|
|
|
|
#include "simon/vga.h"
|
|
|
|
|
|
|
|
namespace Simon {
|
|
|
|
|
2006-04-04 07:34:48 +00:00
|
|
|
void SimonEngine::checkLinkBox() { // Check for boxes spilling over to next row of text
|
|
|
|
if (_hyperLink != 0) {
|
|
|
|
_variableArray[52] = _textWindow->x + _textWindow->textColumn - _variableArray[50];
|
|
|
|
if (_variableArray[52] != 0) {
|
|
|
|
addNewHitArea(_variableArray[53], _variableArray[50], _variableArray[51], _variableArray[52], 15, 145, 208, _dummyItem1);
|
|
|
|
_variableArray[53]++;
|
|
|
|
}
|
|
|
|
_variableArray[50] = _textWindow->x;
|
|
|
|
_variableArray[51] = _textWindow->textRow + _textWindow->y + (_oracleMaxScrollY-_textWindow->scrollY) * 15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-04 01:38:53 +00:00
|
|
|
void SimonEngine::hyperLinkOn(uint16 x) {
|
2006-04-05 00:37:42 +00:00
|
|
|
if (!getBitFlag(51))
|
2006-02-13 10:29:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_hyperLink = x;
|
|
|
|
_variableArray[50] = _textWindow->textColumn+_textWindow->x;
|
2006-04-04 07:34:48 +00:00
|
|
|
_variableArray[51] = _textWindow->textRow+_textWindow->y + (_oracleMaxScrollY - _textWindow->scrollY) * 15;
|
2006-02-13 10:29:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-04-04 01:38:53 +00:00
|
|
|
void SimonEngine::hyperLinkOff() {
|
2006-04-05 00:37:42 +00:00
|
|
|
if (!getBitFlag(51))
|
2006-02-13 10:29:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_variableArray[52] = _textWindow->x + _textWindow->textColumn - _variableArray[50];
|
|
|
|
addNewHitArea(_variableArray[53], _variableArray[50], _variableArray[51], _variableArray[52], 15, 145, 208, _dummyItem1);
|
|
|
|
_variableArray[53]++;
|
|
|
|
_hyperLink = 0;
|
|
|
|
}
|
|
|
|
|
2006-04-04 07:34:48 +00:00
|
|
|
void SimonEngine::linksUp() { // Scroll Oracle Links
|
|
|
|
uint16 j;
|
|
|
|
for (j = 700; j < _variableArray[53]; j++) {
|
|
|
|
moveBox(j, 0, -15);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::linksDown() {
|
|
|
|
uint16 i;
|
|
|
|
for (i = 700; i < _variableArray[53]; i++) {
|
|
|
|
moveBox(i,0, 15);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::scrollOracle() {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
scrollOracleUp();
|
|
|
|
bltOracleText();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::oracleTextUp() {
|
2006-04-04 01:38:53 +00:00
|
|
|
Subroutine *sub;
|
|
|
|
int i = 0;
|
|
|
|
changeWindow(3);
|
|
|
|
_noOracleScroll = 0;
|
|
|
|
|
2006-04-07 13:39:59 +00:00
|
|
|
if (_textWindow->scrollY > _oracleMaxScrollY) // For scroll up
|
2006-04-04 07:34:48 +00:00
|
|
|
_oracleMaxScrollY = _textWindow->scrollY;
|
2006-04-04 01:38:53 +00:00
|
|
|
|
|
|
|
while(1) {
|
2006-04-07 13:39:59 +00:00
|
|
|
if (_textWindow->scrollY == _oracleMaxScrollY)
|
2006-04-04 01:38:53 +00:00
|
|
|
break;
|
2006-04-04 07:34:48 +00:00
|
|
|
_textWindow->textRow = 105;
|
2006-04-04 01:38:53 +00:00
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
_newLines = 0;
|
|
|
|
_textWindow->textColumn = 0;
|
2006-04-04 07:34:48 +00:00
|
|
|
_textWindow->textRow -= 3;
|
2006-04-07 13:39:59 +00:00
|
|
|
if (i == 2) {
|
2006-04-04 07:34:48 +00:00
|
|
|
_textWindow->scrollY += 1;
|
|
|
|
_textWindow->textRow += 15;
|
|
|
|
linksUp();
|
2006-04-04 01:38:53 +00:00
|
|
|
}
|
2006-04-04 07:34:48 +00:00
|
|
|
scrollOracleUp();
|
2006-04-05 00:37:42 +00:00
|
|
|
setBitFlag(94, true);
|
2006-04-04 01:38:53 +00:00
|
|
|
sub = getSubroutineByID(_variableArray[104]);
|
2006-04-04 07:34:48 +00:00
|
|
|
if(sub)
|
2006-04-04 01:38:53 +00:00
|
|
|
startSubroutineEx(sub);
|
2006-04-05 00:37:42 +00:00
|
|
|
setBitFlag(94, false);
|
2006-04-04 01:38:53 +00:00
|
|
|
bltOracleText();
|
|
|
|
}
|
2006-04-06 08:21:44 +00:00
|
|
|
if (_currentBoxNumber != 600 || !_leftButtonDown)
|
2006-04-04 01:38:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-04 07:34:48 +00:00
|
|
|
void SimonEngine::oracleTextDown() {
|
2006-04-04 01:38:53 +00:00
|
|
|
Subroutine *sub;
|
|
|
|
int i = 0;
|
|
|
|
changeWindow(3);
|
|
|
|
_noOracleScroll = 0;
|
|
|
|
|
2006-04-07 13:39:59 +00:00
|
|
|
if (_textWindow->scrollY > _oracleMaxScrollY) // For scroll up
|
2006-04-04 07:34:48 +00:00
|
|
|
_oracleMaxScrollY = _textWindow->scrollY;
|
2006-04-04 01:38:53 +00:00
|
|
|
|
|
|
|
while(1) {
|
2006-04-07 13:39:59 +00:00
|
|
|
if (_textWindow->scrollY == 0)
|
2006-04-04 01:38:53 +00:00
|
|
|
break;
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
_newLines = 0;
|
|
|
|
_textWindow->textColumn = 0;
|
2006-04-04 07:34:48 +00:00
|
|
|
_textWindow->textRow = (i + 1) * 3;
|
2006-04-07 13:39:59 +00:00
|
|
|
if (i == 4) {
|
2006-04-04 07:34:48 +00:00
|
|
|
_textWindow->scrollY -= 1;
|
|
|
|
_textWindow->textRow = 0;
|
|
|
|
linksDown();
|
2006-04-04 01:38:53 +00:00
|
|
|
}
|
2006-04-04 07:34:48 +00:00
|
|
|
scrollOracleDown();
|
2006-04-05 00:37:42 +00:00
|
|
|
setBitFlag(93, true);
|
2006-04-04 01:38:53 +00:00
|
|
|
sub = getSubroutineByID(_variableArray[104]);
|
2006-04-04 07:34:48 +00:00
|
|
|
if (sub)
|
2006-04-04 01:38:53 +00:00
|
|
|
startSubroutineEx(sub);
|
2006-04-05 00:37:42 +00:00
|
|
|
setBitFlag(93, false);
|
2006-04-04 01:38:53 +00:00
|
|
|
bltOracleText();
|
|
|
|
}
|
2006-04-06 08:21:44 +00:00
|
|
|
if (_currentBoxNumber != 601 || !_leftButtonDown)
|
2006-04-04 01:38:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::listSaveGames(int n) {
|
|
|
|
char b[108];
|
|
|
|
Common::InSaveFile *in;
|
|
|
|
uint16 j, k, z, maxFiles;
|
|
|
|
int OK;
|
|
|
|
memset(b, 0, 108);
|
|
|
|
|
|
|
|
maxFiles = countSaveGames();
|
2006-04-08 00:24:46 +00:00
|
|
|
j = maxFiles - n;
|
|
|
|
k = maxFiles - j;
|
2006-04-04 01:38:53 +00:00
|
|
|
z = maxFiles;
|
2006-04-04 23:29:24 +00:00
|
|
|
if (getBitFlag(95)) {
|
2006-04-04 01:38:53 +00:00
|
|
|
j++;
|
|
|
|
z++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
OK=1;
|
2006-04-05 00:24:53 +00:00
|
|
|
if (getBitFlag(93) || getBitFlag(94)) {
|
2006-04-04 01:38:53 +00:00
|
|
|
OK = 0;
|
|
|
|
if(j > z)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-04 23:29:24 +00:00
|
|
|
if (getBitFlag(93)) {
|
2006-04-08 00:24:46 +00:00
|
|
|
if (((_newLines + 1) >= _textWindow->scrollY) && ((_newLines + 1) < (_textWindow->scrollY + 3)))
|
2006-04-04 01:38:53 +00:00
|
|
|
OK = 1;
|
|
|
|
}
|
|
|
|
|
2006-04-04 23:29:24 +00:00
|
|
|
if (getBitFlag(94)) {
|
2006-04-04 07:34:48 +00:00
|
|
|
if ((_newLines + 1) == (_textWindow->scrollY + 7))
|
2006-04-04 01:38:53 +00:00
|
|
|
OK = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (OK == 1) {
|
|
|
|
if (j == maxFiles + 1) {
|
|
|
|
showMessageFormat("\n");
|
|
|
|
hyperLinkOn(j + 400);
|
|
|
|
o_setTextColor(116);
|
|
|
|
showMessageFormat(" %d. ",1);
|
|
|
|
hyperLinkOff();
|
|
|
|
o_setTextColor(113);
|
|
|
|
k++;
|
|
|
|
j--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(in = _saveFileMan->openForLoading(gen_savename(j))))
|
|
|
|
break;
|
|
|
|
in->read(b, 100);
|
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
|
|
|
|
showMessageFormat("\n");
|
|
|
|
hyperLinkOn(j + 400);
|
|
|
|
o_setTextColor(116);
|
|
|
|
if (k < 10)
|
|
|
|
showMessageFormat(" ");
|
|
|
|
showMessageFormat("%d. ",k);
|
|
|
|
o_setTextColor(113);
|
|
|
|
showMessageFormat("%s ",b);
|
|
|
|
hyperLinkOff();
|
|
|
|
j--;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::scrollOracleUp() {
|
2006-04-07 12:57:40 +00:00
|
|
|
byte *src, *dst;
|
|
|
|
uint16 w, h;
|
|
|
|
|
|
|
|
dst = getFrontBuf() + 103 * _screenWidth + 136;
|
|
|
|
src = getFrontBuf() + 106 * _screenWidth + 136;
|
|
|
|
|
|
|
|
for (h = 0; h < 21; h++) {
|
|
|
|
for (w = 0; w < 360; w++) {
|
|
|
|
if (dst[w] == 0 || dst[w] == 113 || dst[w] == 116 || dst[w] == 252)
|
|
|
|
dst[w] = src[w];
|
|
|
|
}
|
|
|
|
dst += _screenWidth;
|
|
|
|
src += _screenWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (h = 0; h < 80; h++) {
|
|
|
|
memcpy(dst, src, 360);
|
|
|
|
dst += _screenWidth;
|
|
|
|
src += _screenWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (h = 0; h < 3; h++) {
|
|
|
|
memset(dst, 0, 360);
|
|
|
|
dst += _screenWidth;
|
|
|
|
src += _screenWidth;
|
|
|
|
}
|
2006-04-04 01:38:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::scrollOracleDown() {
|
2006-04-07 12:57:40 +00:00
|
|
|
byte *src, *dst;
|
|
|
|
uint16 w, h;
|
|
|
|
|
|
|
|
src = getFrontBuf() + 203 * _screenWidth + 136;
|
|
|
|
dst = getFrontBuf() + 206 * _screenWidth + 136;
|
|
|
|
|
|
|
|
for (h = 0; h < 77; h++) {
|
|
|
|
memcpy(dst, src, 360);
|
|
|
|
dst -= _screenWidth;
|
|
|
|
src -= _screenWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (h = 0; h < 24; h++) {
|
|
|
|
for (w = 0; w < 360; w++) {
|
|
|
|
if (src[w] == 0)
|
|
|
|
dst[w] = src[w];
|
|
|
|
|
|
|
|
if (src[w] == 113 || src[w] == 116 || src[w] == 252) {
|
|
|
|
dst[w] = src[w];
|
|
|
|
src[w] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dst -= _screenWidth;
|
|
|
|
src -= _screenWidth;
|
|
|
|
}
|
2006-04-04 01:38:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::bltOracleText() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2006-04-03 14:40:07 +00:00
|
|
|
void SimonEngine::oracleLogo() {
|
|
|
|
Common::Rect srcRect, dstRect;
|
|
|
|
byte *src, *dst;
|
|
|
|
uint16 w, h;
|
|
|
|
|
|
|
|
dstRect.left = 16;
|
|
|
|
dstRect.top = 16;
|
|
|
|
dstRect.right = 58;
|
|
|
|
dstRect.bottom = 59;
|
|
|
|
|
|
|
|
srcRect.left = 0;
|
|
|
|
srcRect.top = 0;
|
|
|
|
srcRect.right = 42;
|
|
|
|
srcRect.bottom = 43;
|
|
|
|
|
|
|
|
src = _iconFilePtr;
|
|
|
|
dst = getBackBuf() + _screenWidth * dstRect.top + dstRect.left;
|
|
|
|
|
|
|
|
for (h = 0; h < dstRect.height(); h++) {
|
|
|
|
for (w = 0; w < dstRect.width(); w++) {
|
|
|
|
if (src[w])
|
|
|
|
dst[w] = src[w];
|
|
|
|
}
|
|
|
|
src += 336;
|
|
|
|
dst += _screenWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SimonEngine::swapCharacterLogo() {
|
|
|
|
Common::Rect srcRect, dstRect;
|
|
|
|
byte *src, *dst;
|
|
|
|
uint16 w, h;
|
|
|
|
int x;
|
|
|
|
|
|
|
|
dstRect.left = 64;
|
|
|
|
dstRect.top = 16;
|
|
|
|
dstRect.right = 106;
|
|
|
|
dstRect.bottom = 59;
|
|
|
|
|
|
|
|
srcRect.top = 0;
|
|
|
|
srcRect.bottom = 43;
|
|
|
|
|
|
|
|
x = _variableArray[91];
|
|
|
|
if (x > _variableArray[90])
|
|
|
|
x--;
|
2006-04-04 23:29:24 +00:00
|
|
|
if (x < _variableArray[90])
|
2006-04-03 14:40:07 +00:00
|
|
|
x++;
|
|
|
|
_variableArray[91] = x;
|
|
|
|
|
|
|
|
x++;
|
|
|
|
x *= 42;
|
|
|
|
|
|
|
|
srcRect.left = x;
|
|
|
|
srcRect.right = srcRect.left + 42;
|
|
|
|
|
|
|
|
src = _iconFilePtr + srcRect.top * 336 + srcRect.left;
|
|
|
|
dst = getBackBuf() + _screenWidth * dstRect.top + dstRect.left;
|
|
|
|
|
|
|
|
for (h = 0; h < dstRect.height(); h++) {
|
|
|
|
for (w = 0; w < dstRect.width(); w++) {
|
|
|
|
if (src[w])
|
|
|
|
dst[w] = src[w];
|
|
|
|
}
|
|
|
|
src += 336;
|
|
|
|
dst += _screenWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-13 10:29:25 +00:00
|
|
|
} // End of namespace Simon
|