2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2006-05-23 23:43:52 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2006-05-23 23:43:52 +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 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-03-21 20:13:40 +00:00
|
|
|
#include "common/file.h"
|
2006-05-23 23:43:52 +00:00
|
|
|
#include "common/stdafx.h"
|
|
|
|
|
2006-05-25 22:51:42 +00:00
|
|
|
#include "graphics/cursorman.h"
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
#include "agi/agi.h"
|
|
|
|
#include "agi/graphics.h"
|
|
|
|
|
|
|
|
namespace Agi {
|
|
|
|
|
|
|
|
#define DEV_X0(x) ((x) << 1)
|
|
|
|
#define DEV_X1(x) (((x) << 1) + 1)
|
|
|
|
#define DEV_Y(x) (x)
|
|
|
|
|
|
|
|
#ifndef MAX_INT
|
|
|
|
# define MAX_INT (int)((unsigned)~0 >> 1)
|
|
|
|
#endif
|
|
|
|
|
2007-01-16 09:24:13 +00:00
|
|
|
#include "agi/font.h"
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 16 color RGB palette (plus 16 transparent colors).
|
|
|
|
* This array contains the 6-bit RGB values of the EGA palette exported
|
|
|
|
* to the console drivers.
|
|
|
|
*/
|
2007-01-16 12:40:51 +00:00
|
|
|
uint8 egaPalette[16 * 3] = {
|
2006-05-23 23:43:52 +00:00
|
|
|
0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x2a,
|
|
|
|
0x00, 0x2a, 0x00,
|
|
|
|
0x00, 0x2a, 0x2a,
|
|
|
|
0x2a, 0x00, 0x00,
|
|
|
|
0x2a, 0x00, 0x2a,
|
|
|
|
0x2a, 0x15, 0x00,
|
|
|
|
0x2a, 0x2a, 0x2a,
|
|
|
|
0x15, 0x15, 0x15,
|
|
|
|
0x15, 0x15, 0x3f,
|
|
|
|
0x15, 0x3f, 0x15,
|
|
|
|
0x15, 0x3f, 0x3f,
|
|
|
|
0x3f, 0x15, 0x15,
|
|
|
|
0x3f, 0x15, 0x3f,
|
|
|
|
0x3f, 0x3f, 0x15,
|
|
|
|
0x3f, 0x3f, 0x3f
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 16 color amiga-ish palette.
|
|
|
|
*/
|
2007-01-16 12:40:51 +00:00
|
|
|
uint8 newPalette[16 * 3] = {
|
2006-05-23 23:43:52 +00:00
|
|
|
0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x3f,
|
|
|
|
0x00, 0x2A, 0x00,
|
|
|
|
0x00, 0x2A, 0x2A,
|
|
|
|
0x33, 0x00, 0x00,
|
|
|
|
0x2f, 0x1c, 0x37,
|
|
|
|
0x23, 0x14, 0x00,
|
|
|
|
0x2f, 0x2f, 0x2f,
|
|
|
|
0x15, 0x15, 0x15,
|
|
|
|
0x00, 0x2f, 0x3f,
|
|
|
|
0x00, 0x33, 0x15,
|
|
|
|
0x15, 0x3F, 0x3F,
|
|
|
|
0x3f, 0x27, 0x23,
|
|
|
|
0x3f, 0x15, 0x3f,
|
|
|
|
0x3b, 0x3b, 0x00,
|
|
|
|
0x3F, 0x3F, 0x3F
|
|
|
|
};
|
|
|
|
|
2007-06-20 22:16:18 +00:00
|
|
|
/**
|
|
|
|
* 256 color palette used with AGI256 and AGI256-2 games.
|
|
|
|
* Uses full 8 bits per color component.
|
|
|
|
*/
|
|
|
|
uint8 vgaPalette[256 * 3] = {
|
|
|
|
0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0xA8,
|
|
|
|
0x00, 0xA8, 0x00,
|
|
|
|
0x00, 0xA8, 0xA8,
|
|
|
|
0xA8, 0x00, 0x00,
|
|
|
|
0xA8, 0x00, 0xA8,
|
|
|
|
0xA8, 0x54, 0x00,
|
|
|
|
0xA8, 0xA8, 0xA8,
|
|
|
|
0x54, 0x54, 0x54,
|
|
|
|
0x54, 0x54, 0xFC,
|
|
|
|
0x54, 0xFC, 0x54,
|
|
|
|
0x54, 0xFC, 0xFC,
|
|
|
|
0xFC, 0x54, 0x54,
|
|
|
|
0xFC, 0x54, 0xFC,
|
|
|
|
0xFC, 0xFC, 0x54,
|
|
|
|
0xFC, 0xFC, 0xFC,
|
|
|
|
0x00, 0x00, 0x00,
|
|
|
|
0x14, 0x14, 0x14,
|
|
|
|
0x20, 0x20, 0x20,
|
|
|
|
0x2C, 0x2C, 0x2C,
|
|
|
|
0x38, 0x38, 0x38,
|
|
|
|
0x44, 0x44, 0x44,
|
|
|
|
0x50, 0x50, 0x50,
|
|
|
|
0x60, 0x60, 0x60,
|
|
|
|
0x70, 0x70, 0x70,
|
|
|
|
0x80, 0x80, 0x80,
|
|
|
|
0x90, 0x90, 0x90,
|
|
|
|
0xA0, 0xA0, 0xA0,
|
|
|
|
0xB4, 0xB4, 0xB4,
|
|
|
|
0xC8, 0xC8, 0xC8,
|
|
|
|
0xE0, 0xE0, 0xE0,
|
|
|
|
0xFC, 0xFC, 0xFC,
|
|
|
|
0x00, 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0x1C, 0x00,
|
|
|
|
0x70, 0x38, 0x00,
|
|
|
|
0x70, 0x54, 0x00,
|
|
|
|
0x70, 0x70, 0x00,
|
|
|
|
0x54, 0x70, 0x00,
|
|
|
|
0x38, 0x70, 0x00,
|
|
|
|
0x1C, 0x70, 0x00,
|
|
|
|
0x00, 0x70, 0x00,
|
|
|
|
0x00, 0x70, 0x1C,
|
|
|
|
0x00, 0x70, 0x38,
|
|
|
|
0x00, 0x70, 0x54,
|
|
|
|
0x00, 0x70, 0x70,
|
|
|
|
0x00, 0x54, 0x70,
|
|
|
|
0x00, 0x38, 0x70,
|
|
|
|
0x00, 0x1C, 0x70,
|
|
|
|
0x38, 0x38, 0x70,
|
|
|
|
0x44, 0x38, 0x70,
|
|
|
|
0x54, 0x38, 0x70,
|
|
|
|
0x60, 0x38, 0x70,
|
|
|
|
0x70, 0x38, 0x70,
|
|
|
|
0x70, 0x38, 0x60,
|
|
|
|
0x70, 0x38, 0x54,
|
|
|
|
0x70, 0x38, 0x44,
|
|
|
|
0x70, 0x38, 0x38,
|
|
|
|
0x70, 0x44, 0x38,
|
|
|
|
0x70, 0x54, 0x38,
|
|
|
|
0x70, 0x60, 0x38,
|
|
|
|
0x70, 0x70, 0x38,
|
|
|
|
0x60, 0x70, 0x38,
|
|
|
|
0x54, 0x70, 0x38,
|
|
|
|
0x44, 0x70, 0x38,
|
|
|
|
0x38, 0x70, 0x38,
|
|
|
|
0x38, 0x70, 0x44,
|
|
|
|
0x38, 0x70, 0x54,
|
|
|
|
0x38, 0x70, 0x60,
|
|
|
|
0x38, 0x70, 0x70,
|
|
|
|
0x38, 0x60, 0x70,
|
|
|
|
0x38, 0x54, 0x70,
|
|
|
|
0x38, 0x44, 0x70,
|
|
|
|
0x50, 0x50, 0x70,
|
|
|
|
0x58, 0x50, 0x70,
|
|
|
|
0x60, 0x50, 0x70,
|
|
|
|
0x68, 0x50, 0x70,
|
|
|
|
0x70, 0x50, 0x70,
|
|
|
|
0x70, 0x50, 0x68,
|
|
|
|
0x70, 0x50, 0x60,
|
|
|
|
0x70, 0x50, 0x58,
|
|
|
|
0x70, 0x50, 0x50,
|
|
|
|
0x70, 0x58, 0x50,
|
|
|
|
0x70, 0x60, 0x50,
|
|
|
|
0x70, 0x68, 0x50,
|
|
|
|
0x70, 0x70, 0x50,
|
|
|
|
0x68, 0x70, 0x50,
|
|
|
|
0x60, 0x70, 0x50,
|
|
|
|
0x58, 0x70, 0x50,
|
|
|
|
0x50, 0x70, 0x50,
|
|
|
|
0x50, 0x70, 0x58,
|
|
|
|
0x50, 0x70, 0x60,
|
|
|
|
0x50, 0x70, 0x68,
|
|
|
|
0x50, 0x70, 0x70,
|
|
|
|
0x50, 0x68, 0x70,
|
|
|
|
0x50, 0x60, 0x70,
|
|
|
|
0x50, 0x58, 0x70,
|
|
|
|
0x00, 0x00, 0x40,
|
|
|
|
0x10, 0x00, 0x40,
|
|
|
|
0x20, 0x00, 0x40,
|
|
|
|
0x30, 0x00, 0x40,
|
|
|
|
0x40, 0x00, 0x40,
|
|
|
|
0x40, 0x00, 0x30,
|
|
|
|
0x40, 0x00, 0x20,
|
|
|
|
0x40, 0x00, 0x10,
|
|
|
|
0x40, 0x00, 0x00,
|
|
|
|
0x40, 0x10, 0x00,
|
|
|
|
0x40, 0x20, 0x00,
|
|
|
|
0x40, 0x30, 0x00,
|
|
|
|
0x40, 0x40, 0x00,
|
|
|
|
0x30, 0x40, 0x00,
|
|
|
|
0x20, 0x40, 0x00,
|
|
|
|
0x10, 0x40, 0x00,
|
|
|
|
0x00, 0x40, 0x00,
|
|
|
|
0x00, 0x40, 0x10,
|
|
|
|
0x00, 0x40, 0x20,
|
|
|
|
0x00, 0x40, 0x30,
|
|
|
|
0x00, 0x40, 0x40,
|
|
|
|
0x00, 0x30, 0x40,
|
|
|
|
0x00, 0x20, 0x40,
|
|
|
|
0x00, 0x10, 0x40,
|
|
|
|
0x20, 0x20, 0x40,
|
|
|
|
0x28, 0x20, 0x40,
|
|
|
|
0x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3C, 0x40,
|
|
|
|
0x2C, 0x34, 0x40,
|
|
|
|
0x2C, 0x30, 0x40,
|
|
|
|
0x40, 0x40, 0x40,
|
|
|
|
0x38, 0x38, 0x38,
|
|
|
|
0x30, 0x30, 0x30,
|
|
|
|
0x28, 0x28, 0x28,
|
|
|
|
0x24, 0x24, 0x24,
|
|
|
|
0x1C, 0x1C, 0x1C,
|
|
|
|
0x14, 0x14, 0x14,
|
|
|
|
0x0C, 0x0C, 0x0C
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
static uint16 cgaMap[16] = {
|
2006-05-23 23:43:52 +00:00
|
|
|
0x0000, /* 0 - black */
|
|
|
|
0x0d00, /* 1 - blue */
|
|
|
|
0x0b00, /* 2 - green */
|
|
|
|
0x0f00, /* 3 - cyan */
|
|
|
|
0x000b, /* 4 - red */
|
|
|
|
0x0b0d, /* 5 - magenta */
|
|
|
|
0x000d, /* 6 - brown */
|
|
|
|
0x0b0b, /* 7 - gray */
|
|
|
|
0x0d0d, /* 8 - dark gray */
|
|
|
|
0x0b0f, /* 9 - light blue */
|
|
|
|
0x0b0d, /* 10 - light green */
|
|
|
|
0x0f0d, /* 11 - light cyan */
|
|
|
|
0x0f0d, /* 12 - light red */
|
|
|
|
0x0f00, /* 13 - light magenta */
|
|
|
|
0x0f0b, /* 14 - yellow */
|
|
|
|
0x0f0f /* 15 - white */
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
struct UpdateBlock {
|
2006-05-23 23:43:52 +00:00
|
|
|
int x1, y1;
|
|
|
|
int x2, y2;
|
|
|
|
};
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
static struct UpdateBlock update = {
|
2006-05-23 23:43:52 +00:00
|
|
|
MAX_INT, MAX_INT, 0, 0
|
|
|
|
};
|
|
|
|
|
2007-03-22 22:29:00 +00:00
|
|
|
GfxMgr::GfxMgr(AgiEngine *vm) : _vm(vm) {
|
|
|
|
_shakeH = NULL;
|
|
|
|
_shakeV = NULL;
|
|
|
|
_agipalFileNum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
/*
|
|
|
|
* Layer 4: 640x480? ================== User display
|
|
|
|
* ^
|
|
|
|
* | do_update(), put_block()
|
|
|
|
* |
|
|
|
|
* Layer 3: 640x480? ================== Framebuffer
|
|
|
|
* ^
|
|
|
|
* | flush_block(), put_pixels()
|
|
|
|
* |
|
|
|
|
* Layer 2: 320x200 ================== AGI engine screen (console), put_pixel()
|
|
|
|
* |
|
|
|
|
* Layer 1: 160x168 ================== AGI screen
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SHAKE_MAG 3
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::shakeStart() {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if ((_shakeH = (uint8 *)malloc(GFX_WIDTH * SHAKE_MAG)) == NULL)
|
2006-05-23 23:43:52 +00:00
|
|
|
return;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if ((_shakeV = (uint8 *)malloc(SHAKE_MAG * (GFX_HEIGHT - SHAKE_MAG))) == NULL) {
|
|
|
|
free(_shakeH);
|
2006-05-23 23:43:52 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < GFX_HEIGHT - SHAKE_MAG; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memcpy(_shakeV + i * SHAKE_MAG, _agiScreen + i * GFX_WIDTH, SHAKE_MAG);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < SHAKE_MAG; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memcpy(_shakeH + i * GFX_WIDTH, _agiScreen + i * GFX_WIDTH, GFX_WIDTH);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::shakeScreen(int n) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (n == 0) {
|
|
|
|
for (i = 0; i < (GFX_HEIGHT - SHAKE_MAG); i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memmove(&_agiScreen[GFX_WIDTH * i],
|
|
|
|
&_agiScreen[GFX_WIDTH * (i + SHAKE_MAG) + SHAKE_MAG],
|
2006-05-23 23:43:52 +00:00
|
|
|
GFX_WIDTH - SHAKE_MAG);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = GFX_HEIGHT - SHAKE_MAG - 1; i >= 0; i--) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memmove(&_agiScreen[GFX_WIDTH * (i + SHAKE_MAG) + SHAKE_MAG],
|
|
|
|
&_agiScreen[GFX_WIDTH * i], GFX_WIDTH - SHAKE_MAG);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::shakeEnd() {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < GFX_HEIGHT - SHAKE_MAG; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memcpy(_agiScreen + i * GFX_WIDTH, _shakeV + i * SHAKE_MAG, SHAKE_MAG);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < SHAKE_MAG; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memcpy(_agiScreen + i * GFX_WIDTH, _shakeH + i * GFX_WIDTH, GFX_WIDTH);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
free(_shakeV);
|
|
|
|
free(_shakeH);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2007-01-06 05:11:41 +00:00
|
|
|
void GfxMgr::putTextCharacter(int l, int x, int y, unsigned int c, int fg, int bg, bool checkerboard) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int x1, y1, xx, yy, cc;
|
2007-01-16 09:24:13 +00:00
|
|
|
const uint8 *p;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
p = Agi::curFont + ((unsigned int)c * CHAR_LINES);
|
2006-05-23 23:43:52 +00:00
|
|
|
for (y1 = 0; y1 < CHAR_LINES; y1++) {
|
|
|
|
for (x1 = 0; x1 < CHAR_COLS; x1++) {
|
|
|
|
xx = x + x1;
|
|
|
|
yy = y + y1;
|
|
|
|
cc = (*p & (1 << (7 - x1))) ? fg : bg;
|
2007-01-16 12:40:51 +00:00
|
|
|
_agiScreen[xx + yy * GFX_WIDTH] = cc;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
p++;
|
|
|
|
}
|
2007-01-06 05:11:41 +00:00
|
|
|
|
|
|
|
// Simple checkerboard effect to simulate "greyed out" text.
|
|
|
|
// This is what Sierra's interpreter does for things like menu items
|
|
|
|
// that aren't selectable (such as separators). -- dsymonds
|
|
|
|
if (checkerboard) {
|
|
|
|
for (yy = y; yy < y + CHAR_LINES; yy++)
|
|
|
|
for (xx = x + (~yy & 1); xx < x + CHAR_COLS; xx += 2)
|
2007-01-16 12:40:51 +00:00
|
|
|
_agiScreen[xx + yy * GFX_WIDTH] = 15;
|
2007-01-06 05:11:41 +00:00
|
|
|
}
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
/* FIXME: we don't want this when we're writing on the
|
|
|
|
* console!
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
flushBlock(x, y, x + CHAR_COLS - 1, y + CHAR_LINES - 1);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::drawRectangle(int x1, int y1, int x2, int y2, int c) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int y, w, h;
|
|
|
|
uint8 *p0;
|
|
|
|
|
|
|
|
if (x1 >= GFX_WIDTH)
|
|
|
|
x1 = GFX_WIDTH - 1;
|
|
|
|
if (y1 >= GFX_HEIGHT)
|
|
|
|
y1 = GFX_HEIGHT - 1;
|
|
|
|
if (x2 >= GFX_WIDTH)
|
|
|
|
x2 = GFX_WIDTH - 1;
|
|
|
|
if (y2 >= GFX_HEIGHT)
|
|
|
|
y2 = GFX_HEIGHT - 1;
|
|
|
|
|
|
|
|
w = x2 - x1 + 1;
|
|
|
|
h = y2 - y1 + 1;
|
2007-01-16 12:40:51 +00:00
|
|
|
p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
|
2006-05-23 23:43:52 +00:00
|
|
|
for (y = 0; y < h; y++) {
|
|
|
|
memset(p0, c, w);
|
|
|
|
p0 += GFX_WIDTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::drawFrame(int x1, int y1, int x2, int y2, int c1, int c2) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int y, w;
|
|
|
|
uint8 *p0;
|
|
|
|
|
|
|
|
/* top line */
|
|
|
|
w = x2 - x1 + 1;
|
2007-01-16 12:40:51 +00:00
|
|
|
p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
|
2006-05-23 23:43:52 +00:00
|
|
|
memset(p0, c1, w);
|
|
|
|
|
|
|
|
/* bottom line */
|
2007-01-16 12:40:51 +00:00
|
|
|
p0 = &_agiScreen[x1 + y2 * GFX_WIDTH];
|
2006-05-23 23:43:52 +00:00
|
|
|
memset(p0, c2, w);
|
|
|
|
|
|
|
|
/* side lines */
|
|
|
|
for (y = y1; y <= y2; y++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
_agiScreen[x1 + y * GFX_WIDTH] = c1;
|
|
|
|
_agiScreen[x2 + y * GFX_WIDTH] = c2;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::drawBox(int x1, int y1, int x2, int y2, int colour1, int colour2, int m) {
|
2006-05-23 23:43:52 +00:00
|
|
|
x1 += m;
|
|
|
|
y1 += m;
|
|
|
|
x2 -= m;
|
|
|
|
y2 -= m;
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
drawRectangle(x1, y1, x2, y2, colour1);
|
|
|
|
drawFrame(x1 + 2, y1 + 2, x2 - 2, y2 - 2, colour2, colour2);
|
|
|
|
flushBlock(x1, y1, x2, y2);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::printCharacter(int x, int y, char c, int fg, int bg) {
|
2006-05-23 23:43:52 +00:00
|
|
|
x *= CHAR_COLS;
|
|
|
|
y *= CHAR_LINES;
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
putTextCharacter(0, x, y, c, fg, bg);
|
2006-05-23 23:43:52 +00:00
|
|
|
// redundant! already inside put_text_character!
|
|
|
|
// flush_block (x, y, x + CHAR_COLS - 1, y + CHAR_LINES - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw button
|
|
|
|
* @param x x coordinate of the button
|
|
|
|
* @param y y coordinate of the button
|
|
|
|
* @param a set if the button has focus
|
|
|
|
* @param p set if the button is pressed
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int len = strlen(s);
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
|
|
|
|
x1 = x - 3;
|
|
|
|
y1 = y - 3;
|
|
|
|
x2 = x + CHAR_COLS * len + 2;
|
|
|
|
y2 = y + CHAR_LINES + 2;
|
|
|
|
|
|
|
|
while (*s) {
|
2006-12-07 01:00:26 +00:00
|
|
|
putTextCharacter(0, x + (!!p), y + (!!p), *s++, a ? bgcolor : fgcolor, a ? fgcolor : bgcolor);
|
2006-05-23 23:43:52 +00:00
|
|
|
x += CHAR_COLS;
|
|
|
|
}
|
|
|
|
|
|
|
|
x1 -= 2;
|
|
|
|
y1 -= 2;
|
|
|
|
x2 += 2;
|
|
|
|
y2 += 2;
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
flushBlock(x1, y1, x2, y2);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int GfxMgr::testButton(int x, int y, const char *s) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int len = strlen(s);
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
|
|
|
|
x1 = x - 3;
|
|
|
|
y1 = y - 3;
|
|
|
|
x2 = x + CHAR_COLS * len + 2;
|
|
|
|
y2 = y + CHAR_LINES + 2;
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
if ((int)g_mouse.x >= x1 && (int)g_mouse.y >= y1 && (int)g_mouse.x <= x2 && (int)g_mouse.y <= y2)
|
2006-05-23 23:43:52 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::putBlock(int x1, int y1, int x2, int y2) {
|
|
|
|
gfxPutBlock(x1, y1, x2, y2);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::putScreen() {
|
|
|
|
putBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::pollTimer() {
|
|
|
|
_vm->agiTimerLow();
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int GfxMgr::getKey() {
|
|
|
|
return _vm->agiGetKeypressLow();
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int GfxMgr::keypress() {
|
|
|
|
return _vm->agiIsKeypressLow();
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Public functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the color palette
|
|
|
|
* This function initializes the color palette using the specified 16-color
|
|
|
|
* RGB palette and creates 16 extra palette entries with translucent colors
|
|
|
|
* for the interpreter console.
|
|
|
|
* @param p A pointer to the 16-color RGB palette.
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::initPalette(uint8 *p) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 48; i++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
_palette[i] = p[i];
|
|
|
|
_palette[i + 48] = (p[i] + 0x30) >> 2;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::gfxSetPalette() {
|
2006-05-23 23:43:52 +00:00
|
|
|
int i;
|
2007-06-20 22:16:18 +00:00
|
|
|
byte pal[256 * 4];
|
|
|
|
|
|
|
|
if (!(_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))) {
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
pal[i * 4 + 0] = _palette[i * 3 + 0] << 2;
|
|
|
|
pal[i * 4 + 1] = _palette[i * 3 + 1] << 2;
|
|
|
|
pal[i * 4 + 2] = _palette[i * 3 + 2] << 2;
|
|
|
|
pal[i * 4 + 3] = 0;
|
|
|
|
}
|
|
|
|
g_system->setPalette(pal, 0, 32);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < 256; i++) {
|
|
|
|
pal[i * 4 + 0] = vgaPalette[i * 3 + 0];
|
|
|
|
pal[i * 4 + 1] = vgaPalette[i * 3 + 1];
|
|
|
|
pal[i * 4 + 2] = vgaPalette[i * 3 + 2];
|
|
|
|
pal[i * 4 + 3] = 0;
|
|
|
|
}
|
|
|
|
g_system->setPalette(pal, 0, 256);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-21 20:13:40 +00:00
|
|
|
//Gets AGIPAL Data
|
|
|
|
void GfxMgr::setAGIPal(int p0) {
|
2007-03-22 22:03:21 +00:00
|
|
|
//If 0 from savefile, do not use
|
|
|
|
if (p0 == 0)
|
|
|
|
return;
|
2007-03-21 20:13:40 +00:00
|
|
|
|
|
|
|
char filename[15];
|
|
|
|
sprintf(filename, "pal.%d", p0);
|
2007-03-29 16:50:06 +00:00
|
|
|
|
|
|
|
Common::File agipal;
|
|
|
|
if (!agipal.open(filename))
|
|
|
|
error("Couldn't open AGIPAL palette file '%s'", filename);
|
2007-03-21 20:13:40 +00:00
|
|
|
|
|
|
|
//Chunk0 holds colors 0-7
|
2007-03-29 16:50:06 +00:00
|
|
|
agipal.read(&_agipalPalette[0], 24);
|
2007-03-21 20:13:40 +00:00
|
|
|
|
|
|
|
//Chunk1 is the same as the chunk0
|
2007-03-29 16:50:06 +00:00
|
|
|
|
2007-03-21 20:13:40 +00:00
|
|
|
//Chunk2 chunk holds colors 8-15
|
2007-03-29 16:50:06 +00:00
|
|
|
agipal.seek(24, SEEK_CUR);
|
|
|
|
agipal.read(&_agipalPalette[24], 24);
|
2007-03-21 20:13:40 +00:00
|
|
|
|
|
|
|
//Chunk3 is the same as the chunk2
|
2007-03-29 16:50:06 +00:00
|
|
|
|
2007-03-21 20:13:40 +00:00
|
|
|
//Chunks4-7 are duplicates of chunks0-3
|
|
|
|
|
2007-03-29 16:50:06 +00:00
|
|
|
if (agipal.ioFailed())
|
|
|
|
error("Couldn't read AGIPAL palette from '%s'", filename);
|
|
|
|
|
|
|
|
_agipalFileNum = p0;
|
|
|
|
|
2007-03-21 20:13:40 +00:00
|
|
|
initPalette(_agipalPalette);
|
|
|
|
gfxSetPalette();
|
2007-03-22 22:03:21 +00:00
|
|
|
|
2007-03-29 16:50:06 +00:00
|
|
|
debug(1, "Using AGIPAL palette from '%s'", filename);
|
2007-03-21 20:13:40 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:03:21 +00:00
|
|
|
int GfxMgr::getAGIPalFileNum() {
|
|
|
|
return _agipalFileNum;
|
|
|
|
}
|
|
|
|
|
2006-05-23 23:43:52 +00:00
|
|
|
/* put a block onto the screen */
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::gfxPutBlock(int x1, int y1, int x2, int y2) {
|
2006-05-23 23:43:52 +00:00
|
|
|
if (x1 >= GFX_WIDTH)
|
|
|
|
x1 = GFX_WIDTH - 1;
|
|
|
|
if (y1 >= GFX_HEIGHT)
|
|
|
|
y1 = GFX_HEIGHT - 1;
|
|
|
|
if (x2 >= GFX_WIDTH)
|
|
|
|
x2 = GFX_WIDTH - 1;
|
|
|
|
if (y2 >= GFX_HEIGHT)
|
|
|
|
y2 = GFX_HEIGHT - 1;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
g_system->copyRectToScreen(_screen + y1 * 320 + x1, 320, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const byte mouseCursorArrow[] = {
|
2007-02-11 23:46:23 +00:00
|
|
|
// This is the same arrow cursor that was later used in early SCI games
|
2006-05-23 23:43:52 +00:00
|
|
|
0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00,
|
|
|
|
0x78, 0x00, 0x7C, 0x00, 0x7E, 0x00, 0x7F, 0x00,
|
2007-02-11 23:46:23 +00:00
|
|
|
0x7F, 0x80, 0x7F, 0xC0, 0x7C, 0x00, 0x46, 0x00,
|
|
|
|
0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x01, 0x80,
|
|
|
|
0xC0, 0x00, 0xA0, 0x00, 0x90, 0x00, 0x88, 0x00,
|
|
|
|
0x84, 0x00, 0x82, 0x00, 0x81, 0x00, 0x80, 0x80,
|
|
|
|
0x80, 0x40, 0x80, 0x20, 0x82, 0x00, 0xA9, 0x00,
|
|
|
|
0xC9, 0x00, 0x04, 0x80, 0x04, 0x80, 0x02, 0x40
|
2006-05-23 23:43:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize graphics device.
|
|
|
|
*
|
|
|
|
* @see deinit_video()
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
int GfxMgr::initVideo() {
|
2007-02-13 15:27:36 +00:00
|
|
|
if (_vm->_renderMode == Common::kRenderEGA)
|
2007-01-16 12:40:51 +00:00
|
|
|
initPalette(egaPalette);
|
2006-05-23 23:43:52 +00:00
|
|
|
else
|
2007-01-16 12:40:51 +00:00
|
|
|
initPalette(newPalette);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
if ((_agiScreen = (uint8 *)calloc(GFX_WIDTH, GFX_HEIGHT)) == NULL)
|
|
|
|
return errNotEnoughMemory;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
gfxSetPalette();
|
2006-05-23 23:43:52 +00:00
|
|
|
|
|
|
|
byte mouseCursor[16 * 16];
|
|
|
|
const byte *src = mouseCursorArrow;
|
|
|
|
for (int i = 0; i < 32; ++i) {
|
|
|
|
int offs = i * 8;
|
|
|
|
for (byte mask = 0x80; mask != 0; mask >>= 1) {
|
|
|
|
if (src[0] & mask) {
|
|
|
|
mouseCursor[offs] = 2;
|
|
|
|
} else if (src[32] & mask) {
|
|
|
|
mouseCursor[offs] = 0;
|
|
|
|
} else {
|
|
|
|
mouseCursor[offs] = 0xFF;
|
|
|
|
}
|
|
|
|
++offs;
|
|
|
|
}
|
|
|
|
++src;
|
|
|
|
}
|
2007-02-11 23:46:23 +00:00
|
|
|
|
|
|
|
const byte cursorPalette[] = {
|
|
|
|
0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
255, 255, 255, 0
|
|
|
|
};
|
|
|
|
|
2007-02-12 00:04:56 +00:00
|
|
|
CursorMan.replaceCursorPalette(cursorPalette, 0, 3);
|
2006-05-25 22:51:42 +00:00
|
|
|
CursorMan.replaceCursor(mouseCursor, 16, 16, 1, 1);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
return errOK;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deinitialize graphics device.
|
|
|
|
*
|
|
|
|
* @see init_video()
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
int GfxMgr::deinitVideo() {
|
2007-01-16 12:40:51 +00:00
|
|
|
free(_agiScreen);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
return errOK;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int GfxMgr::initMachine() {
|
2007-01-16 12:40:51 +00:00
|
|
|
_screen = (unsigned char *)malloc(320 * 200);
|
|
|
|
_vm->_clockCount = 0;
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
return errOK;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
int GfxMgr::deinitMachine() {
|
2007-01-16 12:40:51 +00:00
|
|
|
free(_screen);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
return errOK;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write pixels on the output device.
|
|
|
|
* This function writes a row of pixels on the output device. Only the
|
|
|
|
* lower 4 bits of each pixel in the row will be used, making this
|
|
|
|
* function suitable for use with rows from the AGI screen.
|
|
|
|
* @param x x coordinate of the row start (AGI coord.)
|
|
|
|
* @param y y coordinate of the row start (AGI coord.)
|
|
|
|
* @param n number of pixels in the row
|
|
|
|
* @param p pointer to the row start in the AGI screen
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::putPixelsA(int x, int y, int n, uint8 *p) {
|
2007-02-13 15:27:36 +00:00
|
|
|
if (_vm->_renderMode == Common::kRenderCGA) {
|
2006-05-23 23:43:52 +00:00
|
|
|
for (x *= 2; n--; p++, x += 2) {
|
2007-01-16 12:40:51 +00:00
|
|
|
register uint16 q = (cgaMap[(*p & 0xf0) >> 4] << 4) | cgaMap[*p & 0x0f];
|
2006-12-06 19:27:02 +00:00
|
|
|
if (_vm->_debug.priority)
|
2006-05-23 23:43:52 +00:00
|
|
|
q >>= 4;
|
2007-01-16 12:40:51 +00:00
|
|
|
*(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = q & 0x0f0f;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (x *= 2; n--; p++, x += 2) {
|
|
|
|
register uint16 q = ((uint16) * p << 8) | *p;
|
2006-12-06 19:27:02 +00:00
|
|
|
if (_vm->_debug.priority)
|
2006-05-23 23:43:52 +00:00
|
|
|
q >>= 4;
|
2007-01-16 12:40:51 +00:00
|
|
|
*(uint16 *)&_agiScreen[x + y * GFX_WIDTH] = q & 0x0f0f;
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Schedule blocks for blitting on the output device.
|
|
|
|
* This function gets the coordinates of a block in the AGI screen and
|
|
|
|
* schedule it to be updated in the output device.
|
|
|
|
* @param x1 x coordinate of the upper left corner of the block (AGI coord.)
|
|
|
|
* @param y1 y coordinate of the upper left corner of the block (AGI coord.)
|
|
|
|
* @param x2 x coordinate of the lower right corner of the block (AGI coord.)
|
|
|
|
* @param y2 y coordinate of the lower right corner of the block (AGI coord.)
|
|
|
|
*
|
|
|
|
* @see do_update()
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::scheduleUpdate(int x1, int y1, int x2, int y2) {
|
2006-05-23 23:43:52 +00:00
|
|
|
if (x1 < update.x1)
|
|
|
|
update.x1 = x1;
|
|
|
|
if (y1 < update.y1)
|
|
|
|
update.y1 = y1;
|
|
|
|
if (x2 > update.x2)
|
|
|
|
update.x2 = x2;
|
|
|
|
if (y2 > update.y2)
|
|
|
|
update.y2 = y2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update scheduled blocks on the output device.
|
|
|
|
* This function exposes the blocks scheduled for updating to the output
|
|
|
|
* device. Blocks can be scheduled at any point of the AGI cycle.
|
|
|
|
*
|
|
|
|
* @see schedule_update()
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::doUpdate() {
|
2006-05-23 23:43:52 +00:00
|
|
|
if (update.x1 <= update.x2 && update.y1 <= update.y2) {
|
2006-12-06 19:27:02 +00:00
|
|
|
gfxPutBlock(update.x1, update.y1, update.x2, update.y2);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* reset update block variables */
|
|
|
|
update.x1 = MAX_INT;
|
|
|
|
update.y1 = MAX_INT;
|
|
|
|
update.x2 = 0;
|
|
|
|
update.y2 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates a block of the framebuffer with contents of the AGI engine screen.
|
|
|
|
* This function updates a block in the output device with the contents of
|
|
|
|
* the AGI engine screen, handling console transparency.
|
|
|
|
* @param x1 x coordinate of the upper left corner of the block
|
|
|
|
* @param y1 y coordinate of the upper left corner of the block
|
|
|
|
* @param x2 x coordinate of the lower right corner of the block
|
|
|
|
* @param y2 y coordinate of the lower right corner of the block
|
|
|
|
*
|
|
|
|
* @see flush_block_a()
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::flushBlock(int x1, int y1, int x2, int y2) {
|
2006-05-23 23:43:52 +00:00
|
|
|
int y, w;
|
|
|
|
uint8 *p0;
|
|
|
|
|
2006-12-06 19:27:02 +00:00
|
|
|
scheduleUpdate(x1, y1, x2, y2);
|
2006-05-23 23:43:52 +00:00
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
p0 = &_agiScreen[x1 + y1 * GFX_WIDTH];
|
2006-05-23 23:43:52 +00:00
|
|
|
w = x2 - x1 + 1;
|
|
|
|
|
|
|
|
for (y = y1; y <= y2; y++) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memcpy(_screen + 320 * y + x1, p0, w);
|
2006-05-23 23:43:52 +00:00
|
|
|
p0 += GFX_WIDTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates a block of the framebuffer receiving AGI picture coordinates.
|
|
|
|
* @param x1 x AGI picture coordinate of the upper left corner of the block
|
|
|
|
* @param y1 y AGI picture coordinate of the upper left corner of the block
|
|
|
|
* @param x2 x AGI picture coordinate of the lower right corner of the block
|
|
|
|
* @param y2 y AGI picture coordinate of the lower right corner of the block
|
|
|
|
*
|
|
|
|
* @see flush_block()
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::flushBlockA(int x1, int y1, int x2, int y2) {
|
2006-05-23 23:43:52 +00:00
|
|
|
//y1 += 8;
|
|
|
|
//y2 += 8;
|
2006-12-06 19:27:02 +00:00
|
|
|
flushBlock(DEV_X0(x1), DEV_Y(y1), DEV_X1(x2), DEV_Y(y2));
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the framebuffer with contents of the AGI engine screen (console-aware).
|
|
|
|
* This function updates the output device with the contents of the AGI
|
|
|
|
* screen, handling console transparency.
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::flushScreen() {
|
|
|
|
flushBlock(0, 0, GFX_WIDTH - 1, GFX_HEIGHT - 1);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear the output device screen (console-aware).
|
|
|
|
* This function clears the output device screen and updates the
|
|
|
|
* output device. Contents of the AGI screen are left untouched. This
|
|
|
|
* function can be used to simulate a switch to a text mode screen in
|
|
|
|
* a graphic-only device.
|
|
|
|
* @param c color to clear the screen
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::clearScreen(int c) {
|
2007-01-16 12:40:51 +00:00
|
|
|
memset(_agiScreen, c, GFX_WIDTH * GFX_HEIGHT);
|
2006-12-06 19:27:02 +00:00
|
|
|
flushScreen();
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save a block of the AGI engine screen
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::saveBlock(int x1, int y1, int x2, int y2, uint8 *b) {
|
2006-05-23 23:43:52 +00:00
|
|
|
uint8 *p0;
|
|
|
|
int w, h;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
p0 = &_agiScreen[x1 + GFX_WIDTH * y1];
|
2006-05-23 23:43:52 +00:00
|
|
|
w = x2 - x1 + 1;
|
|
|
|
h = y2 - y1 + 1;
|
|
|
|
while (h--) {
|
|
|
|
memcpy(b, p0, w);
|
|
|
|
b += w;
|
|
|
|
p0 += GFX_WIDTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restore a block of the AGI engine screen
|
|
|
|
*/
|
2006-12-06 19:27:02 +00:00
|
|
|
void GfxMgr::restoreBlock(int x1, int y1, int x2, int y2, uint8 *b) {
|
2006-05-23 23:43:52 +00:00
|
|
|
uint8 *p0;
|
|
|
|
int w, h;
|
|
|
|
|
2007-01-16 12:40:51 +00:00
|
|
|
p0 = &_agiScreen[x1 + GFX_WIDTH * y1];
|
2006-05-23 23:43:52 +00:00
|
|
|
w = x2 - x1 + 1;
|
|
|
|
h = y2 - y1 + 1;
|
|
|
|
while (h--) {
|
|
|
|
memcpy(p0, b, w);
|
|
|
|
b += w;
|
|
|
|
p0 += GFX_WIDTH;
|
|
|
|
}
|
2006-12-06 19:27:02 +00:00
|
|
|
flushBlock(x1, y1, x2, y2);
|
2006-05-23 23:43:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Agi
|