diff options
author | David Corrales | 2007-08-05 19:34:20 +0000 |
---|---|---|
committer | David Corrales | 2007-08-05 19:34:20 +0000 |
commit | 6856535010bd2fa4449bcfde1c88dc06cd46e26f (patch) | |
tree | b81a2234c2beff0312c93e039d6cafda4babeca6 /engines/agi/graphics.cpp | |
parent | 1400d28bfb37fc94f3c44dec0a4d0cef65fb8fb7 (diff) | |
parent | ec1803f838d5efc7decf75c05a1fb4a9633751e5 (diff) | |
download | scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.gz scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.tar.bz2 scummvm-rg350-6856535010bd2fa4449bcfde1c88dc06cd46e26f.zip |
Merged fsnode with trunk: r27971:28460
svn-id: r28462
Diffstat (limited to 'engines/agi/graphics.cpp')
-rw-r--r-- | engines/agi/graphics.cpp | 258 |
1 files changed, 226 insertions, 32 deletions
diff --git a/engines/agi/graphics.cpp b/engines/agi/graphics.cpp index 54f1783d83..b6430e0f81 100644 --- a/engines/agi/graphics.cpp +++ b/engines/agi/graphics.cpp @@ -68,6 +68,158 @@ uint8 egaPalette[16 * 3] = { }; /** + * Atari ST AGI palette. + * Used by all of the tested Atari ST AGI games + * from Donald Duck's Playground (1986) to Manhunter II (1989). + * 16 RGB colors. 3 bits per color component. + */ +uint8 atariStAgiPalette[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0x7, + 0x0, 0x4, 0x0, + 0x0, 0x5, 0x4, + 0x5, 0x0, 0x0, + 0x5, 0x3, 0x6, + 0x4, 0x3, 0x0, + 0x5, 0x5, 0x5, + 0x3, 0x3, 0x2, + 0x0, 0x5, 0x7, + 0x0, 0x6, 0x0, + 0x0, 0x7, 0x6, + 0x7, 0x2, 0x3, + 0x7, 0x4, 0x7, + 0x7, 0x7, 0x4, + 0x7, 0x7, 0x7 +}; + +/** + * Second generation Apple IIGS AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Apple IIGS AGI versions: + * 1.003 (Leisure Suit Larry I v1.0E, intro says 1987) + * 1.005 (AGI Demo 2 1987-06-30?) + * 1.006 (King's Quest I v1.0S 1988-02-23) + * 1.007 (Police Quest I v2.0B 1988-04-21 8:00am) + * 1.013 (King's Quest II v2.0A 1988-06-16 (CE)) + * 1.013 (Mixed-Up Mother Goose v2.0A 1988-05-31 10:00am) + * 1.014 (King's Quest III v2.0A 1988-08-28 (CE)) + * 1.014 (Space Quest II v2.0A, LOGIC.141 says 1988) + * 2.004 (Manhunter I v2.0E 1988-10-05 (CE)) + * 2.006 (King's Quest IV v1.0K 1988-11-22 (CE)) + * 3.001 (Black Cauldron v1.0O 1989-02-24 (CE)) + * 3.003 (Gold Rush! v1.0M 1989-02-28 (CE)) + */ +uint8 appleIIgsAgiPaletteV2[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xF, + 0x0, 0x8, 0x0, + 0x0, 0xD, 0xB, + 0xC, 0x0, 0x0, + 0xB, 0x7, 0xD, + 0x8, 0x5, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0xB, 0xF, + 0x0, 0xE, 0x0, + 0x0, 0xF, 0xD, + 0xF, 0x9, 0x8, + 0xD, 0x9, 0xF, // Only this differs from the 1st generation palette + 0xE, 0xE, 0x0, + 0xF, 0xF, 0xF +}; + +/** + * First generation Amiga & Apple IIGS AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Amiga AGI versions: + * 2.082 (King's Quest I v1.0U 1986) + * 2.082 (Space Quest I v1.2 1986) + * 2.090 (King's Quest III v1.01 1986-11-08) + * 2.107 (King's Quest II v2.0J 1987-01-29) + * x.yyy (Black Cauldron v2.00 1987-06-14) + * x.yyy (Larry I v1.05 1987-06-26) + * + * Also used by at least the following Apple IIGS AGI versions: + * 1.002 (Space Quest I, intro says v2.2 1987) + */ +uint8 amigaAgiPaletteV1[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xF, + 0x0, 0x8, 0x0, + 0x0, 0xD, 0xB, + 0xC, 0x0, 0x0, + 0xB, 0x7, 0xD, + 0x8, 0x5, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0xB, 0xF, + 0x0, 0xE, 0x0, + 0x0, 0xF, 0xD, + 0xF, 0x9, 0x8, + 0xF, 0x7, 0x0, + 0xE, 0xE, 0x0, + 0xF, 0xF, 0xF +}; + +/** + * Second generation Amiga AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Amiga AGI versions: + * 2.202 (Space Quest II v2.0F. Intro says 1988. ScummVM 0.10.0 detects as 1986-12-09) + */ +uint8 amigaAgiPaletteV2[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xF, + 0x0, 0x8, 0x0, + 0x0, 0xD, 0xB, + 0xC, 0x0, 0x0, + 0xB, 0x7, 0xD, + 0x8, 0x5, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0xB, 0xF, + 0x0, 0xE, 0x0, + 0x0, 0xF, 0xD, + 0xF, 0x9, 0x8, + 0xD, 0x0, 0xF, + 0xE, 0xE, 0x0, + 0xF, 0xF, 0xF +}; + +/** + * Third generation Amiga AGI palette. + * A 16-color, 12-bit RGB palette. + * + * Used by at least the following Amiga AGI versions: + * 2.310 (Police Quest I v2.0B 1989-02-22) + * 2.316 (Gold Rush! v2.05 1989-03-09) + * x.yyy (Manhunter I v1.06 1989-03-18) + * 2.333 (Manhunter II v3.06 1989-08-17) + * 2.333 (King's Quest III v2.15 1989-11-15) + */ +uint8 amigaAgiPaletteV3[16 * 3] = { + 0x0, 0x0, 0x0, + 0x0, 0x0, 0xB, + 0x0, 0xB, 0x0, + 0x0, 0xB, 0xB, + 0xB, 0x0, 0x0, + 0xB, 0x0, 0xB, + 0xC, 0x7, 0x0, + 0xB, 0xB, 0xB, + 0x7, 0x7, 0x7, + 0x0, 0x0, 0xF, + 0x0, 0xF, 0x0, + 0x0, 0xF, 0xF, + 0xF, 0x0, 0x0, + 0xF, 0x0, 0xF, + 0xF, 0xF, 0x0, + 0xF, 0xF, 0xF +}; + +/** * 16 color amiga-ish palette. */ uint8 newPalette[16 * 3] = { @@ -554,13 +706,42 @@ void GfxMgr::printCharacter(int x, int y, char c, int fg, int bg) { } /** - * Draw button + * Draw a default style button. + * Swaps background and foreground color if button is in focus or being pressed. * @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 + * @param fgcolor foreground color of the button when it is neither in focus nor being pressed + * @param bgcolor background color of the button when it is neither in focus nor being pressed */ -void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) { +void GfxMgr::drawDefaultStyleButton(int x, int y, const char *s, int a, int p, int fgcolor, int bgcolor) { + int textOffset = _vm->_defaultButtonStyle.getTextOffset(a > 0, p > 0); + AgiTextColor color = _vm->_defaultButtonStyle.getColor (a > 0, p > 0, fgcolor, bgcolor); + bool border = _vm->_defaultButtonStyle.getBorder (a > 0, p > 0); + + rawDrawButton(x, y, s, color.fg, color.bg, border, textOffset); +} + +/** + * Draw a button using the currently chosen style. + * Amiga-style is used for the Amiga-rendering mode, PC-style is used otherwise. + * @param x x coordinate of the button + * @param y y coordinate of the button + * @param hasFocus set if the button has focus + * @param pressed set if the button is pressed + * @param positive set if button is positive, otherwise button is negative (Only matters with Amiga-style buttons) + * TODO: Make Amiga-style buttons a bit wider as they were in Amiga AGI games. + */ +void GfxMgr::drawCurrentStyleButton(int x, int y, const char *label, bool hasFocus, bool pressed, bool positive) { + int textOffset = _vm->_buttonStyle.getTextOffset(hasFocus, pressed); + AgiTextColor color = _vm->_buttonStyle.getColor(hasFocus, pressed, positive); + bool border = _vm->_buttonStyle.getBorder(hasFocus, pressed); + + rawDrawButton(x, y, label, color.fg, color.bg, border, textOffset); +} + +void GfxMgr::rawDrawButton(int x, int y, const char *s, int fgcolor, int bgcolor, bool border, int textOffset) { int len = strlen(s); int x1, y1, x2, y2; @@ -569,8 +750,12 @@ void GfxMgr::drawButton(int x, int y, const char *s, int a, int p, int fgcolor, x2 = x + CHAR_COLS * len + 2; y2 = y + CHAR_LINES + 2; + // Draw a filled rectangle that's larger than the button. Used for drawing + // a border around the button as the button itself is drawn after this. + drawRectangle(x1, y1, x2, y2, border ? BUTTON_BORDER : MSG_BOX_COLOUR); + while (*s) { - putTextCharacter(0, x + (!!p), y + (!!p), *s++, a ? bgcolor : fgcolor, a ? fgcolor : bgcolor); + putTextCharacter(0, x + textOffset, y + textOffset, *s++, fgcolor, bgcolor); x += CHAR_COLS; } @@ -623,39 +808,26 @@ int GfxMgr::keypress() { /** * Initialize the color palette - * This function initializes the color palette using the specified 16-color + * This function initializes the color palette using the specified * RGB palette. - * @param p A pointer to the 16-color RGB palette. + * @param p A pointer to the source RGB palette. + * @param colorCount Count of colors in the source palette. + * @param fromBits Bits per source color component. + * @param toBits Bits per destination color component. */ -void GfxMgr::initPalette(uint8 *p) { - int i; - - for (i = 0; i < 48; i++) { - _palette[i] = p[i]; +void GfxMgr::initPalette(uint8 *p, uint colorCount, uint fromBits, uint toBits) { + const uint srcMax = (1 << fromBits) - 1; + const uint destMax = (1 << toBits) - 1; + for (uint col = 0; col < colorCount; col++) { + for (uint comp = 0; comp < 3; comp++) { // Convert RGB components + _palette[col * 4 + comp] = (p[col * 3 + comp] * destMax) / srcMax; + } + _palette[col * 4 + 3] = 0; // Set alpha to zero } } void GfxMgr::gfxSetPalette() { - int i; - byte pal[256 * 4]; - - if (!(_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2))) { - for (i = 0; i < 16; 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, 16); - } 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); - } + g_system->setPalette(_palette, 0, 256); } //Gets AGIPAL Data @@ -739,7 +911,27 @@ static const byte sciMouseCursor[] = { }; /** - * RGBA-palette for the black and white SCI-style arrow cursor. + * A black and white Apple IIGS style arrow cursor (9x11). + * 0 = Transparent. + * 1 = Black (#000000 in 24-bit RGB). + * 2 = White (#FFFFFF in 24-bit RGB). + */ +static const byte appleIIgsMouseCursor[] = { + 2,2,0,0,0,0,0,0,0, + 2,1,2,0,0,0,0,0,0, + 2,1,1,2,0,0,0,0,0, + 2,1,1,1,2,0,0,0,0, + 2,1,1,1,1,2,0,0,0, + 2,1,1,1,1,1,2,0,0, + 2,1,1,1,1,1,1,2,0, + 2,1,1,1,1,1,1,1,2, + 2,1,1,2,1,1,2,2,0, + 2,2,2,0,2,1,1,2,0, + 0,0,0,0,0,2,2,2,0 +}; + +/** + * RGBA-palette for the black and white SCI and Apple IIGS arrow cursors. */ static const byte sciMouseCursorPalette[] = { 0x00, 0x00, 0x00, 0x00, // Black @@ -819,7 +1011,9 @@ void GfxMgr::setCursor(bool amigaStyleCursor) { * @see deinit_video() */ int GfxMgr::initVideo() { - if (_vm->_renderMode == Common::kRenderEGA) + if (_vm->getFeatures() & (GF_AGI256 | GF_AGI256_2)) + initPalette(vgaPalette, 256, 8); + else if (_vm->_renderMode == Common::kRenderEGA) initPalette(egaPalette); else initPalette(newPalette); |