2021-05-17 08:41:54 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2021-05-17 08:41:54 +00:00
|
|
|
*
|
|
|
|
* 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
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2021-05-17 08:41:54 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/system.h"
|
2021-07-10 13:21:00 +00:00
|
|
|
#include "graphics/macega.h"
|
2021-06-21 05:50:16 +00:00
|
|
|
#include "scumm/actor.h"
|
2021-05-17 08:41:54 +00:00
|
|
|
#include "scumm/charset.h"
|
|
|
|
#include "scumm/usage_bits.h"
|
2021-06-28 07:12:40 +00:00
|
|
|
#include "scumm/verbs.h"
|
2021-05-17 08:41:54 +00:00
|
|
|
|
|
|
|
namespace Scumm {
|
|
|
|
|
2022-10-15 10:24:55 +00:00
|
|
|
void ScummEngine::mac_markScreenAsDirty(int x, int y, int w, int h) {
|
|
|
|
// Mark the virtual screen as dirty. The top and left coordinates are
|
|
|
|
// rounded down, while the bottom and right ones are rounded up.
|
|
|
|
|
|
|
|
VirtScreen *vs = &_virtscr[kMainVirtScreen];
|
|
|
|
|
|
|
|
int vsTop = y / 2 - vs->topline;
|
|
|
|
int vsBottom = (y + h) / 2 - vs->topline;
|
|
|
|
int vsLeft = x / 2;
|
|
|
|
int vsRight = (x + w) / 2;
|
|
|
|
|
|
|
|
if ((y + h) & 1)
|
|
|
|
vsBottom++;
|
|
|
|
|
|
|
|
if ((x + w) & 1)
|
|
|
|
vsRight++;
|
|
|
|
|
|
|
|
markRectAsDirty(kMainVirtScreen, vsLeft, vsRight, vsTop, vsBottom);
|
|
|
|
}
|
|
|
|
|
2021-05-17 08:41:54 +00:00
|
|
|
void ScummEngine::mac_drawStripToScreen(VirtScreen *vs, int top, int x, int y, int width, int height) {
|
2021-07-10 13:21:00 +00:00
|
|
|
|
2021-05-17 08:41:54 +00:00
|
|
|
const byte *pixels = vs->getPixels(x, top);
|
|
|
|
const byte *ts = (byte *)_textSurface.getBasePtr(x * 2, y * 2);
|
|
|
|
byte *mac = (byte *)_macScreen->getBasePtr(x * 2, y * 2);
|
|
|
|
|
|
|
|
int pixelsPitch = vs->pitch;
|
|
|
|
int tsPitch = _textSurface.pitch;
|
|
|
|
int macPitch = _macScreen->pitch;
|
|
|
|
|
2021-07-11 07:47:03 +00:00
|
|
|
// In b/w Mac rendering mode, the shadow palette is implemented here,
|
|
|
|
// and not as a palette manipulation. See special cases in o5_roomOps()
|
|
|
|
// and updatePalette().
|
|
|
|
//
|
|
|
|
// This is used at the very least for the lightning flashes at Castle
|
|
|
|
// Brunwald in Indy 3, as well as the scene where the dragon finds
|
|
|
|
// Rusty in Loom.
|
|
|
|
//
|
|
|
|
// Interestingly, the original Mac interpreter does not seem to do
|
|
|
|
// this, and instead just renders the scene as if the palette was
|
|
|
|
// unmodified. At least, that's what Mini vMac did when I tried it.
|
|
|
|
|
2021-07-10 13:21:00 +00:00
|
|
|
if (_renderMode == Common::kRenderMacintoshBW) {
|
|
|
|
for (int h = 0; h < height; h++) {
|
|
|
|
for (int w = 0; w < width; w++) {
|
2022-03-20 09:50:47 +00:00
|
|
|
int color = _enableEnhancements ? _shadowPalette[pixels[w]] : pixels[w];
|
2021-07-10 13:21:00 +00:00
|
|
|
if (ts[2 * w] == CHARSET_MASK_TRANSPARENCY)
|
2021-07-11 07:47:03 +00:00
|
|
|
mac[2 * w] = Graphics::macEGADither[color][0];
|
2021-07-10 13:21:00 +00:00
|
|
|
if (ts[2 * w + 1] == CHARSET_MASK_TRANSPARENCY)
|
2021-07-11 07:47:03 +00:00
|
|
|
mac[2 * w + 1] = Graphics::macEGADither[color][1];
|
2021-07-10 13:21:00 +00:00
|
|
|
if (ts[2 * w + tsPitch] == CHARSET_MASK_TRANSPARENCY)
|
2021-07-11 07:47:03 +00:00
|
|
|
mac[2 * w + macPitch] = Graphics::macEGADither[color][2];
|
2021-07-10 13:21:00 +00:00
|
|
|
if (ts[2 * w + tsPitch + 1] == CHARSET_MASK_TRANSPARENCY)
|
2021-07-11 07:47:03 +00:00
|
|
|
mac[2 * w + macPitch + 1] = Graphics::macEGADither[color][3];
|
2021-07-10 13:21:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pixels += pixelsPitch;
|
|
|
|
ts += tsPitch * 2;
|
|
|
|
mac += macPitch * 2;
|
2021-05-17 08:41:54 +00:00
|
|
|
}
|
2021-07-10 13:21:00 +00:00
|
|
|
} else {
|
|
|
|
for (int h = 0; h < height; h++) {
|
|
|
|
for (int w = 0; w < width; w++) {
|
|
|
|
if (ts[2 * w] == CHARSET_MASK_TRANSPARENCY)
|
|
|
|
mac[2 * w] = pixels[w];
|
|
|
|
if (ts[2 * w + 1] == CHARSET_MASK_TRANSPARENCY)
|
|
|
|
mac[2 * w + 1] = pixels[w];
|
|
|
|
if (ts[2 * w + tsPitch] == CHARSET_MASK_TRANSPARENCY)
|
|
|
|
mac[2 * w + macPitch] = pixels[w];
|
|
|
|
if (ts[2 * w + tsPitch + 1] == CHARSET_MASK_TRANSPARENCY)
|
|
|
|
mac[2 * w + macPitch + 1] = pixels[w];
|
|
|
|
}
|
2021-05-17 08:41:54 +00:00
|
|
|
|
2021-07-10 13:21:00 +00:00
|
|
|
pixels += pixelsPitch;
|
|
|
|
ts += tsPitch * 2;
|
|
|
|
mac += macPitch * 2;
|
|
|
|
}
|
2021-05-17 08:41:54 +00:00
|
|
|
}
|
|
|
|
|
2021-07-10 13:21:00 +00:00
|
|
|
|
2021-05-17 08:41:54 +00:00
|
|
|
_system->copyRectToScreen(_macScreen->getBasePtr(x * 2, y * 2), _macScreen->pitch, x * 2, y * 2, width * 2, height * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine::mac_drawLoomPracticeMode() {
|
|
|
|
// In practice mode, the game shows the notes as they are being played.
|
|
|
|
// In the DOS version, this is drawn by script 27 but the Mac version
|
2021-06-28 07:12:40 +00:00
|
|
|
// just sets variables 50 and 54. The box is actually a verb, and it
|
|
|
|
// seems that setting variable 50 is pretty much equal to turning verb
|
|
|
|
// 53 on or off. I'm not sure what the purpose of variable 54 is.
|
2021-05-17 08:41:54 +00:00
|
|
|
|
|
|
|
int x = 216;
|
|
|
|
int y = 377;
|
|
|
|
int width = 62;
|
|
|
|
int height = 22;
|
|
|
|
int var = 50;
|
|
|
|
|
|
|
|
byte *ptr = (byte *)_macScreen->getBasePtr(x, y);
|
|
|
|
int pitch = _macScreen->pitch;
|
|
|
|
|
2021-06-28 07:12:40 +00:00
|
|
|
int slot = getVerbSlot(53, 0);
|
|
|
|
VerbSlot *vs = &_verbs[slot];
|
|
|
|
|
|
|
|
vs->curmode = (VAR(var) != 0);
|
|
|
|
vs->curRect.left = x / 2;
|
|
|
|
vs->curRect.right = (x + width) / 2;
|
|
|
|
vs->curRect.top = y / 22;
|
|
|
|
vs->curRect.bottom = (y + height) / 2;
|
|
|
|
|
2021-05-17 08:41:54 +00:00
|
|
|
_macScreen->fillRect(Common::Rect(x, y, x + width, y + height), 0);
|
|
|
|
|
|
|
|
if (VAR(var)) {
|
|
|
|
for (int w = 1; w < width - 1; w++) {
|
|
|
|
ptr[w] = 7;
|
|
|
|
ptr[w + pitch * (height - 1)] = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int h = 1; h < height - 1; h++) {
|
|
|
|
ptr[h * pitch] = 7;
|
|
|
|
ptr[h * pitch + width - 1] = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the notes
|
|
|
|
int colors[] = { 4, 12, 14, 10, 11, 3, 9, 15 };
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
int note = (VAR(var) >> (4 * i)) & 0x0F;
|
|
|
|
|
|
|
|
if (note >= 2 && note <= 9) {
|
|
|
|
_charset->setColor(colors[note - 2]);
|
|
|
|
_charset->drawChar(14 + note, *_macScreen, i * 13 + x + 8, y + 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_system->copyRectToScreen(ptr, pitch, x, y, width, height);
|
|
|
|
}
|
|
|
|
|
2021-06-22 08:06:50 +00:00
|
|
|
void ScummEngine::mac_createIndy3TextBox(Actor *a) {
|
|
|
|
int width = _macIndy3TextBox->w;
|
|
|
|
int height = _macIndy3TextBox->h;
|
2021-06-21 05:50:16 +00:00
|
|
|
|
2021-06-22 08:06:50 +00:00
|
|
|
_macIndy3TextBox->fillRect(Common::Rect(width, height), 0);
|
2021-06-21 05:50:16 +00:00
|
|
|
|
|
|
|
int nameWidth = 0;
|
|
|
|
|
|
|
|
if (a) {
|
|
|
|
int oldID = _charset->getCurID();
|
2022-10-15 10:24:55 +00:00
|
|
|
_charset->setCurID(2 | 0x80);
|
2021-06-21 05:50:16 +00:00
|
|
|
|
|
|
|
const char *name = (const char *)a->getActorName();
|
2021-06-22 08:06:50 +00:00
|
|
|
int charX = 25;
|
2021-06-21 05:50:16 +00:00
|
|
|
|
2021-06-25 10:09:57 +00:00
|
|
|
for (int i = 0; name[i] && nameWidth < width - 50; i++) {
|
2021-06-22 08:06:50 +00:00
|
|
|
_charset->drawChar(name[i], *_macIndy3TextBox, charX, 0);
|
2021-06-21 05:50:16 +00:00
|
|
|
nameWidth += _charset->getCharWidth(name[i]);
|
|
|
|
charX += _charset->getCharWidth(name[i]);
|
|
|
|
}
|
|
|
|
|
2021-06-22 08:06:50 +00:00
|
|
|
_charset->drawChar(':', *_macIndy3TextBox, charX, 0);
|
2021-06-21 05:50:16 +00:00
|
|
|
_charset->setCurID(oldID);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nameWidth) {
|
2021-06-22 08:06:50 +00:00
|
|
|
_macIndy3TextBox->hLine(2, 3, 20, 15);
|
|
|
|
_macIndy3TextBox->hLine(32 + nameWidth, 3, width - 3, 15);
|
2021-06-21 05:50:16 +00:00
|
|
|
} else
|
2021-06-22 08:06:50 +00:00
|
|
|
_macIndy3TextBox->hLine(2, 3, width - 3, 15);
|
2021-06-21 05:50:16 +00:00
|
|
|
|
2021-06-22 08:06:50 +00:00
|
|
|
_macIndy3TextBox->vLine(1, 4, height - 3, 15);
|
|
|
|
_macIndy3TextBox->vLine(width - 2, 4, height - 3, 15);
|
|
|
|
_macIndy3TextBox->hLine(2, height - 2, width - 3, 15);
|
|
|
|
}
|
2021-06-21 05:50:16 +00:00
|
|
|
|
2021-06-22 08:06:50 +00:00
|
|
|
void ScummEngine::mac_drawIndy3TextBox() {
|
2021-06-22 11:47:06 +00:00
|
|
|
// The first two rows of the text box are padding for font rendering.
|
|
|
|
// They are not drawn to the screen.
|
|
|
|
|
|
|
|
int x = 96;
|
|
|
|
int y = 32;
|
|
|
|
int w = _macIndy3TextBox->w;
|
|
|
|
int h = _macIndy3TextBox->h - 2;
|
|
|
|
|
|
|
|
// The text box is drawn to the Mac screen and text surface, as if it
|
2021-06-22 12:47:40 +00:00
|
|
|
// had been one giant glyph. Note that it will be drawn on the main
|
|
|
|
// virtual screen, but we still pretend it's on the text one.
|
2021-06-22 11:47:06 +00:00
|
|
|
|
|
|
|
byte *ptr = (byte *)_macIndy3TextBox->getBasePtr(0, 2);
|
|
|
|
int pitch = _macIndy3TextBox->pitch;
|
|
|
|
|
|
|
|
_macScreen->copyRectToSurface(ptr, pitch, x, y, w, h);
|
|
|
|
_textSurface.fillRect(Common::Rect(x, y, x + w, y + h), 0);
|
|
|
|
|
2022-10-15 10:24:55 +00:00
|
|
|
mac_markScreenAsDirty(x, y, w, h);
|
2021-06-22 12:47:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScummEngine::mac_undrawIndy3TextBox() {
|
|
|
|
int x = 96;
|
|
|
|
int y = 32;
|
|
|
|
int w = _macIndy3TextBox->w;
|
|
|
|
int h = _macIndy3TextBox->h - 2;
|
|
|
|
|
|
|
|
_macScreen->fillRect(Common::Rect(x, y, x + w, y + h), 0);
|
|
|
|
_textSurface.fillRect(Common::Rect(x, y, x + w, y + h), CHARSET_MASK_TRANSPARENCY);
|
|
|
|
|
2022-10-15 10:24:55 +00:00
|
|
|
mac_markScreenAsDirty(x, y, w, h);
|
2021-06-21 05:50:16 +00:00
|
|
|
}
|
|
|
|
|
2021-06-25 13:09:42 +00:00
|
|
|
void ScummEngine::mac_undrawIndy3CreditsText() {
|
2021-06-29 19:57:54 +00:00
|
|
|
if (_macScreen) {
|
|
|
|
// Set _masMask to make the text clear, and _textScreenID to
|
|
|
|
// ensure that it's the main area that's cleared. Note that
|
|
|
|
// this only works with the high-resolution font.
|
|
|
|
_charset->_hasMask = true;
|
|
|
|
_charset->_textScreenID = kMainVirtScreen;
|
|
|
|
restoreCharsetBg();
|
|
|
|
} else {
|
|
|
|
// The DOS VGA version clear the text by using the putState
|
|
|
|
// opcode. I would have been more comfortable if I could have
|
|
|
|
// compared it to the EGA version, but I don't have that.
|
|
|
|
// Judging by the size and position of the object, they should
|
|
|
|
// be the same.
|
|
|
|
putState(946, 0);
|
|
|
|
markObjectRectAsDirty(946);
|
|
|
|
if (_bgNeedsRedraw)
|
|
|
|
clearDrawObjectQueue();
|
|
|
|
}
|
2021-06-25 13:09:42 +00:00
|
|
|
}
|
|
|
|
|
2022-10-15 10:24:55 +00:00
|
|
|
void ScummEngine::mac_drawBorder(int x, int y, int w, int h, byte color) {
|
|
|
|
_macScreen->hLine(x + 2, y, x + w - 2, 0);
|
|
|
|
_macScreen->hLine(x + 2, y + h - 1, x + w - 2, 0);
|
|
|
|
_macScreen->vLine(x, y + 2, y + h - 3, 0);
|
|
|
|
_macScreen->vLine(x + w, y + 2, y + h - 3, 0);
|
|
|
|
_macScreen->setPixel(x + 1, y + 1, 0);
|
|
|
|
_macScreen->setPixel(x + w - 1, y + 1, 0);
|
|
|
|
_macScreen->setPixel(x + 1, y + h - 2, 0);
|
|
|
|
_macScreen->setPixel(x + w - 1, y + h - 2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::KeyState ScummEngine::mac_showOldStyleBannerAndPause(const char *msg, int32 waitTime) {
|
|
|
|
char bannerMsg[512];
|
|
|
|
|
|
|
|
_messageBannerActive = true;
|
|
|
|
|
|
|
|
// Fetch the translated string for the message...
|
|
|
|
convertMessageToString((const byte *)msg, (byte *)bannerMsg, sizeof(bannerMsg));
|
|
|
|
|
2022-10-18 21:59:14 +00:00
|
|
|
// Backup the surfaces...
|
|
|
|
int x = 70;
|
|
|
|
int y = 189;
|
|
|
|
int w = 499;
|
|
|
|
int h = 22;
|
|
|
|
|
|
|
|
Graphics::Surface backupTextSurface;
|
|
|
|
Graphics::Surface backupMacScreen;
|
|
|
|
|
|
|
|
backupTextSurface.create(w + 1, h, Graphics::PixelFormat::createFormatCLUT8());
|
|
|
|
backupMacScreen.create(w + 1, h, Graphics::PixelFormat::createFormatCLUT8());
|
|
|
|
|
|
|
|
backupTextSurface.copyRectToSurface(_textSurface, 0, 0, Common::Rect(x, y, x + w + 1, y + h));
|
|
|
|
backupMacScreen.copyRectToSurface(*_macScreen, 0, 0, Common::Rect(x, y, x + w + 1, y + h));
|
2022-10-15 10:24:55 +00:00
|
|
|
|
|
|
|
// Pause shake effect
|
|
|
|
_shakeTempSavedState = _shakeEnabled;
|
|
|
|
setShake(0);
|
|
|
|
|
|
|
|
// Pause the engine
|
|
|
|
PauseToken pt = pauseEngine();
|
|
|
|
|
|
|
|
// Backup the current charsetId...
|
|
|
|
int oldId = _charset->getCurID();
|
|
|
|
_charset->setCurID(1 | 0x80);
|
|
|
|
_charset->setColor(0);
|
|
|
|
|
|
|
|
_textSurface.fillRect(Common::Rect(x, y, x + w + 1, y + h), 0);
|
|
|
|
_macScreen->fillRect(Common::Rect(x + 1, y + 1, x + w, y + h - 1), 15);
|
|
|
|
mac_drawBorder(x, y, w, h, 0);
|
|
|
|
mac_drawBorder(x + 2, y + 2, w - 4, h - 4, 0);
|
|
|
|
|
|
|
|
int stringWidth = 0;
|
|
|
|
|
|
|
|
for (int i = 0; msg[i]; i++)
|
|
|
|
stringWidth += _charset->getCharWidth(msg[i]);
|
|
|
|
|
|
|
|
int stringX = 1 + x + (w - stringWidth) / 2;
|
|
|
|
|
|
|
|
for (int i = 0; msg[i]; i++) {
|
|
|
|
_charset->drawChar(msg[i], *_macScreen, stringX, y + 4);
|
|
|
|
stringX += _charset->getCharWidth(msg[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
mac_markScreenAsDirty(x, y, w, h);
|
|
|
|
ScummEngine::drawDirtyScreenParts();
|
|
|
|
|
|
|
|
Common::KeyState ks = Common::KEYCODE_INVALID;
|
|
|
|
bool leftBtnPressed = false, rightBtnPressed = false;
|
|
|
|
if (waitTime) {
|
|
|
|
waitForBannerInput(waitTime, ks, leftBtnPressed, rightBtnPressed);
|
|
|
|
}
|
|
|
|
|
2022-10-18 21:59:14 +00:00
|
|
|
// Restore the surfaces...
|
|
|
|
_textSurface.copyRectToSurface(backupTextSurface, x, y, Common::Rect(0, 0, w + 1, h));
|
|
|
|
_macScreen->copyRectToSurface(backupMacScreen, x, y, Common::Rect(0, 0, w + 1, h));
|
2022-10-15 10:24:55 +00:00
|
|
|
|
|
|
|
backupTextSurface.free();
|
|
|
|
backupMacScreen.free();
|
|
|
|
|
2022-10-18 21:59:14 +00:00
|
|
|
// Notify the gfx system that we restored the surfaces...
|
|
|
|
mac_markScreenAsDirty(x, y, w + 1, h);
|
|
|
|
ScummEngine::drawDirtyScreenParts();
|
|
|
|
|
2022-10-15 10:24:55 +00:00
|
|
|
// Finally, resume the engine, clear the input state, and restore the charset.
|
|
|
|
pt.clear();
|
|
|
|
clearClickedStatus();
|
|
|
|
|
|
|
|
_charset->setCurID(oldId);
|
|
|
|
|
|
|
|
_messageBannerActive = false;
|
|
|
|
|
|
|
|
return ks;
|
|
|
|
}
|
|
|
|
|
2021-05-17 08:41:54 +00:00
|
|
|
} // End of namespace Scumm
|