diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-30 11:00:33 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2004-12-30 11:00:33 +0000 |
commit | b1bc2a3bac28bc9f05e8f5e94eb6ba20962db807 (patch) | |
tree | 459fa53165b4731745d5f1f0a87aacd7a6dd3e6a /src | |
parent | 3128cc4f5b3fe73d352d748008b3bc870836009f (diff) | |
download | mana-b1bc2a3bac28bc9f05e8f5e94eb6ba20962db807.tar.gz mana-b1bc2a3bac28bc9f05e8f5e94eb6ba20962db807.tar.bz2 mana-b1bc2a3bac28bc9f05e8f5e94eb6ba20962db807.tar.xz mana-b1bc2a3bac28bc9f05e8f5e94eb6ba20962db807.zip |
Cleanup, mainly removing unused code.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/being.h | 12 | ||||
-rw-r--r-- | src/game.h | 1 | ||||
-rw-r--r-- | src/graphic/2xsai.cpp | 686 | ||||
-rw-r--r-- | src/graphic/2xsai.h | 22 | ||||
-rw-r--r-- | src/graphic/graphic.cpp | 1 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 1 | ||||
-rw-r--r-- | src/gui/gui.cpp | 340 | ||||
-rw-r--r-- | src/gui/gui.h | 8 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/main.h | 1 |
11 files changed, 32 insertions, 1042 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 2de7cba9..51d8b71b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,5 @@ bin_PROGRAMS = tmw tmw_SOURCES = sound/sound.cpp \ - graphic/2xsai.cpp \ graphic/graphic.cpp \ graphic/image.cpp \ gui/allegroinput.cpp \ diff --git a/src/being.h b/src/being.h index 23e1e5fa..48e5825b 100644 --- a/src/being.h +++ b/src/being.h @@ -90,18 +90,6 @@ class Being { unsigned char action, frame; }; -class Npc { -}; - -class Warp { -}; - -class Player { -}; - -class Monster { -}; - //std::vector<Being *> beings; #endif @@ -32,7 +32,6 @@ #include "main.h" #include "./gui/gui.h" #include "./gui/skill.h" -#include "./graphic/2xsai.h" #include <stdio.h> #include <allegro.h> diff --git a/src/graphic/2xsai.cpp b/src/graphic/2xsai.cpp deleted file mode 100644 index 59e824b9..00000000 --- a/src/graphic/2xsai.cpp +++ /dev/null @@ -1,686 +0,0 @@ -#include "2xsai.h" - -#define uint32 unsigned long -#define uint16 unsigned short -#define uint8 unsigned char - -static uint32 colorMask = 0xF7DEF7DE; -static uint32 lowPixelMask = 0x08210821; -static uint32 qcolorMask = 0xE79CE79C; -static uint32 qlowpixelMask = 0x18631863; -static uint32 redblueMask = 0xF81F; -static uint32 greenMask = 0x7E0; -static int PixelsPerMask = 2; -static int xsai_depth = 0; - -int Init_2xSaI(int d) { - - int minr = 0, ming = 0, minb = 0; - int i; - - if (d != 15 && d != 16 && d != 24 && d != 32) - return -1; - - /* Get lowest color bit */ - for (i = 0; i < 255; i++) { - if (!minr) - minr = makecol(i, 0, 0); - if (!ming) - ming = makecol(0, i, 0); - if (!minb) - minb = makecol(0, 0, i); - } - - colorMask = (makecol_depth(d, 255, 0, 0) - minr) | (makecol_depth(d, 0, 255, 0) - ming) | (makecol_depth(d, 0, 0, 255) - minb); - lowPixelMask = minr | ming | minb; - qcolorMask = (makecol_depth(d, 255, 0, 0) - 3 * minr) | (makecol_depth(d, 0, 255, 0) - 3 * ming) | (makecol_depth(d, 0, 0, 255) - 3 * minb); - qlowpixelMask = (minr * 3) | (ming * 3) | (minb * 3); - redblueMask = makecol_depth(d, 255, 0, 255); - greenMask = makecol_depth(d, 0, 255, 0); - - PixelsPerMask = (d <= 16) ? 2 : 1; - - if (PixelsPerMask == 2) { - colorMask |= (colorMask << 16); - qcolorMask |= (qcolorMask << 16); - lowPixelMask |= (lowPixelMask << 16); - qlowpixelMask |= (qlowpixelMask << 16); - } - - TRACE("Color Mask: 0x%lX\n", colorMask); - TRACE("Low Pixel Mask: 0x%lX\n", lowPixelMask); - TRACE("QColor Mask: 0x%lX\n", qcolorMask); - TRACE("QLow Pixel Mask: 0x%lX\n", qlowpixelMask); - - xsai_depth = d; - - return 0; -} - - -static int GetResult1(uint32 A, uint32 B, uint32 C, uint32 D) -{ - int x = 0; - int y = 0; - int r = 0; - if (A == C) - x += 1; - else if (B == C) - y += 1; - if (A == D) - x += 1; - else if (B == D) - y += 1; - if (x <= 1) - r += 1; - if (y <= 1) - r -= 1; - return r; -} - -static int GetResult2(uint32 A, uint32 B, uint32 C, uint32 D, uint32 E) -{ - int x = 0; - int y = 0; - int r = 0; - if (A == C) - x += 1; - else if (B == C) - y += 1; - if (A == D) - x += 1; - else if (B == D) - y += 1; - if (x <= 1) - r -= 1; - if (y <= 1) - r += 1; - return r; -} - - -#define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D)) - -#define INTERPOLATE(A, B) (((A & colorMask) >> 1) + ((B & colorMask) >> 1) + (A & B & lowPixelMask)) - -#define Q_INTERPOLATE(A, B, C, D) ((A & qcolorMask) >> 2) + ((B & qcolorMask) >> 2) + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2) \ - + ((((A & qlowpixelMask) + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask)) >> 2) & qlowpixelMask) - - -/* Clipping Macro, stolen from Allegro, modified to work with 2xSaI */ -#define BLIT_CLIP2(src, dest, s_x, s_y, d_x, d_y, w, h, xscale, yscale) \ - /* check for ridiculous cases */ \ - if ((s_x >= src->cr) || (s_y >= src->cb) || \ - (d_x >= dest->cr) || (d_y >= dest->cb)) \ - return; \ - \ - if ((s_x + w < src->cl) || (s_y + h < src->ct) || \ - (d_x + w * xscale < dest->cl) || (d_y + h * yscale < dest->ct)) \ - return; \ - \ - if (xscale < 1 || yscale < 1) \ - return; \ - \ - /* clip src left */ \ - if (s_x < src->cl) { \ - w += s_x; \ - d_x -= s_x * xscale; \ - s_x = src->cl; \ - } \ - \ - /* clip src top */ \ - if (s_y < src->ct) { \ - h += s_y; \ - d_y -= s_y * yscale; \ - s_y = src->ct; \ - } \ - \ - /* clip src right */ \ - if (s_x + w > src->cr) \ - w = src->cr - s_x; \ - \ - /* clip src bottom */ \ - if (s_y + h > src->cb) \ - h = src->cb - s_y; \ - \ - /* clip dest left */ \ - if (d_x < dest->cl) { \ - d_x -= dest->cl; \ - w += d_x / xscale; \ - s_x -= d_x / xscale; \ - d_x = dest->cl; \ - } \ - \ - /* clip dest top */ \ - if (d_y < dest->ct) { \ - d_y -= dest->ct; \ - h += d_y / yscale; \ - s_y -= d_y / yscale; \ - d_y = dest->ct; \ - } \ - \ - /* clip dest right */ \ - if (d_x + w * xscale > dest->cr) \ - w = (dest->cr - d_x) / xscale; \ - \ - /* clip dest bottom */ \ - if (d_y + h * yscale > dest->cb) \ - h = (dest->cb - d_y) / yscale; \ - \ - /* bottle out if zero size */ \ - if ((w <= 0) || (h <= 0)) \ - return; - - -static unsigned char *src_line[4]; -static unsigned char *dst_line[2]; - - -void Super2xSaI(BITMAP * src, BITMAP * dest, int s_x, int s_y, int d_x, int d_y, int w, int h) -{ - int sbpp, dbpp; - - BITMAP *dst2 = NULL; - - if (!src || !dest) - return; - - sbpp = bitmap_color_depth(src); - dbpp = bitmap_color_depth(dest); - - if ((sbpp != xsai_depth) || (sbpp != dbpp)) /* Must be same color depth */ - return; - - BLIT_CLIP2(src, dest, s_x, s_y, d_x, d_y, w, h, 2, 2); - - if (w < 4 || h < 4) { /* Image is too small to be 2xSaI'ed. */ - stretch_blit(src, dest, s_x, s_y, w, h, d_x, d_y, w * 2, h * 2); - return; - } - - sbpp = BYTES_PER_PIXEL(sbpp); - if (d_x || d_y) - dst2 = create_sub_bitmap(dest, d_x, d_y, w * 2, h * 2); - - Super2xSaI_ex(src->line[s_y] + s_x * sbpp, (unsigned int)(src->line[1] - src->line[0]), NULL, dst2 ? dst2 : dest, w, h); - - if (dst2) - destroy_bitmap(dst2); - - return; -} - -void Super2xSaI_ex(uint8 *src, uint32 src_pitch, uint8 *unused, BITMAP *dest, uint32 width, uint32 height) { - - int j, v; - unsigned int x, y; - int sbpp = BYTES_PER_PIXEL(bitmap_color_depth(dest)); - unsigned long color[16]; - - /* Point to the first 3 lines. */ - src_line[0] = src; - src_line[1] = src; - src_line[2] = src + src_pitch; - src_line[3] = src + src_pitch * 2; - - /* Can we write the results directly? */ - if (is_video_bitmap(dest) || is_planar_bitmap(dest)) { - dst_line[0] = (unsigned char *)malloc(sizeof(char) * sbpp * width); - dst_line[1] = (unsigned char *)malloc(sizeof(char) * sbpp * width); - v = 1; - } - else { - dst_line[0] = dest->line[0]; - dst_line[1] = dest->line[1]; - v = 0; - } - - /* Set destination */ - bmp_select(dest); - - x = 0, y = 0; - - if (PixelsPerMask == 2) { - unsigned short *sbp; - sbp = (unsigned short*)src_line[0]; - color[0] = *sbp; color[1] = color[0]; color[2] = color[0]; color[3] = color[0]; - color[4] = color[0]; color[5] = color[0]; color[6] = *(sbp + 1); color[7] = *(sbp + 2); - sbp = (unsigned short*)src_line[2]; - color[8] = *sbp; color[9] = color[8]; color[10] = *(sbp + 1); color[11] = *(sbp + 2); - sbp = (unsigned short*)src_line[3]; - color[12] = *sbp; color[13] = color[12]; color[14] = *(sbp + 1); color[15] = *(sbp + 2); - } - else { - unsigned long *lbp; - lbp = (unsigned long*)src_line[0]; - color[0] = *lbp; color[1] = color[0]; color[2] = color[0]; color[3] = color[0]; - color[4] = color[0]; color[5] = color[0]; color[6] = *(lbp + 1); color[7] = *(lbp + 2); - lbp = (unsigned long*)src_line[2]; - color[8] = *lbp; color[9] = color[8]; color[10] = *(lbp + 1); color[11] = *(lbp + 2); - lbp = (unsigned long*)src_line[3]; - color[12] = *lbp; color[13] = color[12]; color[14] = *(lbp + 1); color[15] = *(lbp + 2); - } - - for (y = 0; y < height; y++) { - - /* Todo: x = width - 2, x = width - 1 */ - - for (x = 0; x < width; x++) { - unsigned long product1a, product1b, product2a, product2b; - -//--------------------------------------- B0 B1 B2 B3 0 1 2 3 -// 4 5* 6 S2 -> 4 5* 6 7 -// 1 2 3 S1 8 9 10 11 -// A0 A1 A2 A3 12 13 14 15 -//-------------------------------------- - if (color[9] == color[6] && color[5] != color[10]) { - product2b = color[9]; - product1b = product2b; - } - else if (color[5] == color[10] && color[9] != color[6]) { - product2b = color[5]; - product1b = product2b; - } - else if (color[5] == color[10] && color[9] == color[6]) { - int r = 0; - - r += GET_RESULT(color[6], color[5], color[8], color[13]); - r += GET_RESULT(color[6], color[5], color[4], color[1]); - r += GET_RESULT(color[6], color[5], color[14], color[11]); - r += GET_RESULT(color[6], color[5], color[2], color[7]); - - if (r > 0) - product1b = color[6]; - else if (r < 0) - product1b = color[5]; - else - product1b = INTERPOLATE(color[5], color[6]); - - product2b = product1b; - - } - else { - if (color[6] == color[10] && color[10] == color[13] && color[9] != color[14] && color[10] != color[12]) - product2b = Q_INTERPOLATE(color[10], color[10], color[10], color[9]); - else if (color[5] == color[9] && color[9] == color[14] && color[13] != color[10] && color[9] != color[15]) - product2b = Q_INTERPOLATE(color[9], color[9], color[9], color[10]); - else - product2b = INTERPOLATE(color[9], color[10]); - - if (color[6] == color[10] && color[6] == color[1] && color[5] != color[2] && color[6] != color[0]) - product1b = Q_INTERPOLATE(color[6], color[6], color[6], color[5]); - else if (color[5] == color[9] && color[5] == color[2] && color[1] != color[6] && color[5] != color[3]) - product1b = Q_INTERPOLATE(color[6], color[5], color[5], color[5]); - else - product1b = INTERPOLATE(color[5], color[6]); - } - - if (color[5] == color[10] && color[9] != color[6] && color[4] == color[5] && color[5] != color[14]) - product2a = INTERPOLATE(color[9], color[5]); - else if (color[5] == color[8] && color[6] == color[5] && color[4] != color[9] && color[5] != color[12]) - product2a = INTERPOLATE(color[9], color[5]); - else - product2a = color[9]; - - if (color[9] == color[6] && color[5] != color[10] && color[8] == color[9] && color[9] != color[2]) - product1a = INTERPOLATE(color[9], color[5]); - else if (color[4] == color[9] && color[10] == color[9] && color[8] != color[5] && color[9] != color[0]) - product1a = INTERPOLATE(color[9], color[5]); - else - product1a = color[5]; - - if (PixelsPerMask == 2) { - *((unsigned long *) (&dst_line[0][x * 4])) = product1a | (product1b << 16); - *((unsigned long *) (&dst_line[1][x * 4])) = product2a | (product2b << 16); - } - else { - *((unsigned long *) (&dst_line[0][x * 8])) = product1a; - *((unsigned long *) (&dst_line[0][x * 8 + 4])) = product1b; - *((unsigned long *) (&dst_line[1][x * 8])) = product2a; - *((unsigned long *) (&dst_line[1][x * 8 + 4])) = product2b; - } - - /* Move color matrix forward */ - color[0] = color[1]; color[4] = color[5]; color[8] = color[9]; color[12] = color[13]; - color[1] = color[2]; color[5] = color[6]; color[9] = color[10]; color[13] = color[14]; - color[2] = color[3]; color[6] = color[7]; color[10] = color[11]; color[14] = color[15]; - - if (x < width - 3) { - x += 3; - if (PixelsPerMask == 2) { - color[3] = *(((unsigned short*)src_line[0]) + x); - color[7] = *(((unsigned short*)src_line[1]) + x); - color[11] = *(((unsigned short*)src_line[2]) + x); - color[15] = *(((unsigned short*)src_line[3]) + x); - } - else { - color[3] = *(((unsigned long*)src_line[0]) + x); - color[7] = *(((unsigned long*)src_line[1]) + x); - color[11] = *(((unsigned long*)src_line[2]) + x); - color[15] = *(((unsigned long*)src_line[3]) + x); - } - x -= 3; - } - } - - /* We're done with one line, so we shift the source lines up */ - src_line[0] = src_line[1]; - src_line[1] = src_line[2]; - src_line[2] = src_line[3]; - - /* Read next line */ - if (y + 3 >= height) - src_line[3] = src_line[2]; - else - src_line[3] = src_line[2] + src_pitch; - - /* Then shift the color matrix up */ - if (PixelsPerMask == 2) { - unsigned short *sbp; - sbp = (unsigned short*)src_line[0]; - color[0] = *sbp; color[1] = color[0]; color[2] = *(sbp + 1); color[3] = *(sbp + 2); - sbp = (unsigned short*)src_line[1]; - color[4] = *sbp; color[5] = color[4]; color[6] = *(sbp + 1); color[7] = *(sbp + 2); - sbp = (unsigned short*)src_line[2]; - color[8] = *sbp; color[9] = color[9]; color[10] = *(sbp + 1); color[11] = *(sbp + 2); - sbp = (unsigned short*)src_line[3]; - color[12] = *sbp; color[13] = color[12]; color[14] = *(sbp + 1); color[15] = *(sbp + 2); - } - else { - unsigned long *lbp; - lbp = (unsigned long*)src_line[0]; - color[0] = *lbp; color[1] = color[0]; color[2] = *(lbp + 1); color[3] = *(lbp + 2); - lbp = (unsigned long*)src_line[1]; - color[4] = *lbp; color[5] = color[4]; color[6] = *(lbp + 1); color[7] = *(lbp + 2); - lbp = (unsigned long*)src_line[2]; - color[8] = *lbp; color[9] = color[9]; color[10] = *(lbp + 1); color[11] = *(lbp + 2); - lbp = (unsigned long*)src_line[3]; - color[12] = *lbp; color[13] = color[12]; color[14] = *(lbp + 1); color[15] = *(lbp + 2); - } - - - /* Write the 2 lines, if not already done so */ - if (v) { - unsigned long dst_addr; - - dst_addr = bmp_write_line(dest, y * 2); - for (j = 0; j < dest->w * sbpp; j += sizeof(long)) - bmp_write32(dst_addr + j, *((unsigned long *) (dst_line[0] + j))); - - dst_addr = bmp_write_line(dest, y * 2 + 1); - for (j = 0; j < dest->w * sbpp; j += sizeof(long)) - bmp_write32(dst_addr + j, *((unsigned long *) (dst_line[1] + j))); - } - else { - if (y < height - 1) { - dst_line[0] = dest->line[y * 2 + 2]; - dst_line[1] = dest->line[y * 2 + 3]; - } - } - } - bmp_unwrite_line(dest); - - if (v) { - free(dst_line[0]); - free(dst_line[1]); - } -} - - - -void SuperEagle(BITMAP * src, BITMAP * dest, int s_x, int s_y, int d_x, int d_y, int w, int h) -{ - int sbpp, dbpp; - - BITMAP *dst2 = NULL; - - if (!src || !dest) - return; - - sbpp = bitmap_color_depth(src); - dbpp = bitmap_color_depth(dest); - - if ((sbpp != xsai_depth) || (sbpp != dbpp)) /* Must be same color depth */ - return; - - BLIT_CLIP2(src, dest, s_x, s_y, d_x, d_y, w, h, 2, 2); - - if (w < 4 || h < 4) { /* Image is too small to be 2xSaI'ed. */ - stretch_blit(src, dest, s_x, s_y, w, h, d_x, d_y, w * 2, h * 2); - return; - } - - sbpp = BYTES_PER_PIXEL(sbpp); - if (d_x || d_y) - dst2 = create_sub_bitmap(dest, d_x, d_y, w * 2, h * 2); - - SuperEagle_ex(src->line[s_y] + s_x * sbpp, (unsigned int)(src->line[1] - src->line[0]), NULL, dst2 ? dst2 : dest, w, h); - - if (dst2) - destroy_bitmap(dst2); - - return; -} - -void SuperEagle_ex(uint8 *src, uint32 src_pitch, uint8 *unused, BITMAP *dest, uint32 width, uint32 height) { - - int j, v; - unsigned int x, y; - int sbpp = BYTES_PER_PIXEL(bitmap_color_depth(dest)); - unsigned long color[12]; - - /* Point to the first 3 lines. */ - src_line[0] = src; - src_line[1] = src; - src_line[2] = src + src_pitch; - src_line[3] = src + src_pitch * 2; - - /* Can we write the results directly? */ - if (is_video_bitmap(dest) || is_planar_bitmap(dest)) { - dst_line[0] = (unsigned char *)malloc(sizeof(char) * sbpp * width); - dst_line[1] = (unsigned char *)malloc(sizeof(char) * sbpp * width); - v = 1; - } - else { - dst_line[0] = dest->line[0]; - dst_line[1] = dest->line[1]; - v = 0; - } - - /* Set destination */ - bmp_select(dest); - - x = 0, y = 0; - - if (PixelsPerMask == 2) { - unsigned short *sbp; - sbp = (unsigned short*)src_line[0]; - color[0] = *sbp; color[1] = color[0]; color[2] = color[0]; color[3] = color[0]; - color[4] = *(sbp + 1); color[5] = *(sbp + 2); - sbp = (unsigned short*)src_line[2]; - color[6] = *sbp; color[7] = color[6]; color[8] = *(sbp + 1); color[9] = *(sbp + 2); - sbp = (unsigned short*)src_line[3]; - color[10] = *sbp; color[11] = *(sbp + 1); - } - else { - unsigned long *lbp; - lbp = (unsigned long*)src_line[0]; - color[0] = *lbp; color[1] = color[0]; color[2] = color[0]; color[3] = color[0]; - color[4] = *(lbp + 1); color[5] = *(lbp + 2); - lbp = (unsigned long*)src_line[2]; - color[6] = *lbp; color[7] = color[6]; color[8] = *(lbp + 1); color[9] = *(lbp + 2); - lbp = (unsigned long*)src_line[3]; - color[10] = *lbp; color[11] = *(lbp + 1); - } - - for (y = 0; y < height; y++) { - - /* Todo: x = width - 2, x = width - 1 */ - - for (x = 0; x < width; x++) { - unsigned long product1a, product1b, product2a, product2b; - -//--------------------------------------- B1 B2 0 1 -// 4 5 6 S2 -> 2 3 4 5 -// 1 2 3 S1 6 7 8 9 -// A1 A2 10 11 - - if (color[7] == color[4] && color[3] != color[8]) { - product1b = product2a = color[7]; - - if ((color[6] == color[7]) || (color[4] == color[1])) - product1a = INTERPOLATE(color[7], INTERPOLATE(color[7], color[3])); - else - product1a = INTERPOLATE(color[3], color[4]); - - if ((color[4] == color[5]) || (color[7] == color[10])) - product2b = INTERPOLATE(color[7], INTERPOLATE(color[7], color[8])); - else - product2b = INTERPOLATE(color[7], color[8]); - } - else if (color[3] == color[8] && color[7] != color[4]) { - product2b = product1a = color[3]; - - if ((color[0] == color[3]) || (color[5] == color[9])) - product1b = INTERPOLATE(color[3], INTERPOLATE(color[3], color[4])); - else - product1b = INTERPOLATE(color[3], color[1]); - - if ((color[8] == color[11]) || (color[2] == color[3])) - product2a = INTERPOLATE(color[3], INTERPOLATE(color[3], color[2])); - else - product2a = INTERPOLATE(color[7], color[8]); - - } - else if (color[3] == color[8] && color[7] == color[4]) { - register int r = 0; - - r += GET_RESULT(color[4], color[3], color[6], color[10]); - r += GET_RESULT(color[4], color[3], color[2], color[0]); - r += GET_RESULT(color[4], color[3], color[11], color[9]); - r += GET_RESULT(color[4], color[3], color[1], color[5]); - - if (r > 0) { - product1b = product2a = color[7]; - product1a = product2b = INTERPOLATE(color[3], color[4]); - } - else if (r < 0) { - product2b = product1a = color[3]; - product1b = product2a = INTERPOLATE(color[3], color[4]); - } - else { - product2b = product1a = color[3]; - product1b = product2a = color[7]; - } - } - else { - product2b = product1a = INTERPOLATE(color[7], color[4]); - product2b = Q_INTERPOLATE(color[8], color[8], color[8], product2b); - product1a = Q_INTERPOLATE(color[3], color[3], color[3], product1a); - - product2a = product1b = INTERPOLATE(color[3], color[8]); - product2a = Q_INTERPOLATE(color[7], color[7], color[7], product2a); - product1b = Q_INTERPOLATE(color[4], color[4], color[4], product1b); - } - - if (PixelsPerMask == 2) { - *((unsigned long *) (&dst_line[0][x * 4])) = product1a | (product1b << 16); - *((unsigned long *) (&dst_line[1][x * 4])) = product2a | (product2b << 16); - } - else { - *((unsigned long *) (&dst_line[0][x * 8])) = product1a; - *((unsigned long *) (&dst_line[0][x * 8 + 4])) = product1b; - *((unsigned long *) (&dst_line[1][x * 8])) = product2a; - *((unsigned long *) (&dst_line[1][x * 8 + 4])) = product2b; - } - - /* Move color matrix forward */ - color[0] = color[1]; - color[2] = color[3]; color[3] = color[4]; color[4] = color[5]; - color[6] = color[7]; color[7] = color[8]; color[8] = color[9]; - color[10] = color[11]; - - if (x < width - 2) { - x += 2; - if (PixelsPerMask == 2) { - color[1] = *(((unsigned short*)src_line[0]) + x); - if (x < width) { - color[5] = *(((unsigned short*)src_line[1]) + x + 1); - color[9] = *(((unsigned short*)src_line[2]) + x + 1); - } - color[11] = *(((unsigned short*)src_line[3]) + x); - } - else { - color[1] = *(((unsigned long*)src_line[0]) + x); - if (x < width) { - color[5] = *(((unsigned long*)src_line[1]) + x + 1); - color[9] = *(((unsigned long*)src_line[2]) + x + 1); - } - color[11] = *(((unsigned long*)src_line[3]) + x); - } - x -= 2; - } - } - - /* We're done with one line, so we shift the source lines up */ - src_line[0] = src_line[1]; - src_line[1] = src_line[2]; - src_line[2] = src_line[3]; - - /* Read next line */ - if (y + 3 >= height) - src_line[3] = src_line[2]; - else - src_line[3] = src_line[2] + src_pitch; - - /* Then shift the color matrix up */ - if (PixelsPerMask == 2) { - unsigned short *sbp; - sbp = (unsigned short*)src_line[0]; - color[0] = *sbp; color[1] = *(sbp + 1); - sbp = (unsigned short*)src_line[1]; - color[2] = *sbp; color[3] = color[2]; color[4] = *(sbp + 1); color[5] = *(sbp + 2); - sbp = (unsigned short*)src_line[2]; - color[6] = *sbp; color[7] = color[6]; color[8] = *(sbp + 1); color[9] = *(sbp + 2); - sbp = (unsigned short*)src_line[3]; - color[10] = *sbp; color[11] = *(sbp + 1); - } - else { - unsigned long *lbp; - lbp = (unsigned long*)src_line[0]; - color[0] = *lbp; color[1] = *(lbp + 1); - lbp = (unsigned long*)src_line[1]; - color[2] = *lbp; color[3] = color[2]; color[4] = *(lbp + 1); color[5] = *(lbp + 2); - lbp = (unsigned long*)src_line[2]; - color[6] = *lbp; color[7] = color[6]; color[8] = *(lbp + 1); color[9] = *(lbp + 2); - lbp = (unsigned long*)src_line[3]; - color[10] = *lbp; color[11] = *(lbp + 1); - } - - - /* Write the 2 lines, if not already done so */ - if (v) { - unsigned long dst_addr; - - dst_addr = bmp_write_line(dest, y * 2); - for (j = 0; j < dest->w * sbpp; j += sizeof(long)) - bmp_write32(dst_addr + j, *((unsigned long *) (dst_line[0] + j))); - - dst_addr = bmp_write_line(dest, y * 2 + 1); - for (j = 0; j < dest->w * sbpp; j += sizeof(long)) - bmp_write32(dst_addr + j, *((unsigned long *) (dst_line[1] + j))); - } - else { - if (y < height - 1) { - dst_line[0] = dest->line[y * 2 + 2]; - dst_line[1] = dest->line[y * 2 + 3]; - } - } - } - bmp_unwrite_line(dest); - - if (v) { - free(dst_line[0]); - free(dst_line[1]); - } -} diff --git a/src/graphic/2xsai.h b/src/graphic/2xsai.h deleted file mode 100644 index 35068ba8..00000000 --- a/src/graphic/2xsai.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef WIN32 -#pragma warning(disable:4312) -#endif - -#ifndef _2XSAI_H -#define _2XSAI_H - -#include <allegro.h> -#include <allegro/internal/aintern.h> - -#define uint32 unsigned long -#define uint16 unsigned short -#define uint8 unsigned char - -int Init_2xSaI(int depth); -void Super2xSaI(BITMAP * src, BITMAP * dest, int s_x, int s_y, int d_x, int d_y, int w, int h); -void Super2xSaI_ex(uint8 *src, uint32 src_pitch, uint8 *unused, BITMAP *dest, uint32 width, uint32 height); - -void SuperEagle(BITMAP * src, BITMAP * dest, int s_x, int s_y, int d_x, int d_y, int w, int h); -void SuperEagle_ex(uint8 *src, uint32 src_pitch, uint8 *unused, BITMAP *dest, uint32 width, uint32 height); - -#endif diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp index be20aeb9..b00f602f 100644 --- a/src/graphic/graphic.cpp +++ b/src/graphic/graphic.cpp @@ -20,7 +20,6 @@ */ #include "graphic.h" -#include "2xsai.h" #include "../gui/gui.h" #include "../gui/textfield.h" #include "../gui/status.h" diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 4e2ef1a9..04fa5317 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -24,7 +24,6 @@ #include "char_select.h" #include "textfield.h" #include "../graphic/graphic.h" -#include "../graphic/2xsai.h" CharSelectDialog::CharSelectDialog(gcn::Container *parent) : Window(parent, "Select Character") diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index e301f422..e2a22df3 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -52,10 +52,6 @@ bool drag; DATAFILE *gui_gfx; -/* very internal update stuff */ -int (*gui__external_slider_callback)(void *, int); -int reroute_slider_proc(void *dp3, int d2); - // Guichan Allegro stuff gcn::AllegroInput* guiInput; // Input driver gcn::AllegroGraphics* guiGraphics; // Graphics driver @@ -167,7 +163,6 @@ void loadButtonSkin() { } } - void loadSliderSkin() { int x, y, w, h,o1,o2; char **tokens; @@ -344,38 +339,42 @@ void loadListboxSkin() { } } + void loadBarSkin() { -BITMAP *temp1 = load_bitmap("data/bar.bmp", NULL); -BITMAP *temp2 = load_bitmap("data/bar_filled.bmp", NULL); -gui_skin.bar.bg.grid[0] = create_bitmap(3,11); -gui_skin.bar.bg.grid[1] = create_bitmap(1,11); -gui_skin.bar.bg.grid[2] = create_bitmap(3,11); -blit(temp1, gui_skin.bar.bg.grid[0], 0, 0, 0, 0, 3, 11); -blit(temp1, gui_skin.bar.bg.grid[1], 4, 0, 0, 0, 1, 11); -blit(temp1, gui_skin.bar.bg.grid[2], 13, 0, 0, 0, 3, 11); -gui_skin.bar.bg.grid[3] = create_bitmap(3,11); -gui_skin.bar.bg.grid[4] = create_bitmap(1,11); -gui_skin.bar.bg.grid[5] = create_bitmap(3,11); -blit(temp2, gui_skin.bar.bg.grid[3], 0, 0, 0, 0, 3, 11); -blit(temp2, gui_skin.bar.bg.grid[4], 4, 0, 0, 0, 1, 11); -blit(temp2, gui_skin.bar.bg.grid[5], 13, 0, 0, 0, 3, 11); + BITMAP *temp1 = load_bitmap("data/bar.bmp", NULL); + BITMAP *temp2 = load_bitmap("data/bar_filled.bmp", NULL); + gui_skin.bar.bg.grid[0] = create_bitmap(3,11); + gui_skin.bar.bg.grid[1] = create_bitmap(1,11); + gui_skin.bar.bg.grid[2] = create_bitmap(3,11); + blit(temp1, gui_skin.bar.bg.grid[0], 0, 0, 0, 0, 3, 11); + blit(temp1, gui_skin.bar.bg.grid[1], 4, 0, 0, 0, 1, 11); + blit(temp1, gui_skin.bar.bg.grid[2], 13, 0, 0, 0, 3, 11); + gui_skin.bar.bg.grid[3] = create_bitmap(3,11); + gui_skin.bar.bg.grid[4] = create_bitmap(1,11); + gui_skin.bar.bg.grid[5] = create_bitmap(3,11); + blit(temp2, gui_skin.bar.bg.grid[3], 0, 0, 0, 0, 3, 11); + blit(temp2, gui_skin.bar.bg.grid[4], 4, 0, 0, 0, 1, 11); + blit(temp2, gui_skin.bar.bg.grid[5], 13, 0, 0, 0, 3, 11); } + void loadRadioSkin() { -gui_skin.radiobutton.normal = load_bitmap("data/Skin/radioout.bmp", NULL); -gui_skin.radiobutton.checked = load_bitmap("data/Skin/radioin.bmp", NULL); -gui_skin.radiobutton.disabled = load_bitmap("data/Skin/radioout.bmp", NULL); -gui_skin.radiobutton.disabled_checked = load_bitmap("data/Skin/radioin.bmp", NULL); + gui_skin.radiobutton.normal = load_bitmap("data/Skin/radioout.bmp", NULL); + gui_skin.radiobutton.checked = load_bitmap("data/Skin/radioin.bmp", NULL); + gui_skin.radiobutton.disabled = load_bitmap("data/Skin/radioout.bmp", NULL); + gui_skin.radiobutton.disabled_checked = load_bitmap("data/Skin/radioin.bmp", NULL); } + void loadPlusSkin() { -//BITMAP *temp1 = load_bitmap("data/bar.bmp", NULL); -//BITMAP *temp2 = load_bitmap("data/bar_filled.bmp", NULL); -gui_skin.plus.bg.grid[0] = load_bitmap("data/plus.bmp", NULL); -gui_skin.plus.bg.grid[1] = load_bitmap("data/plus_sel.bmp", NULL); -gui_skin.plus.bg.grid[2] = load_bitmap("data/plus_dis.bmp", NULL); -//blit(temp1, gui_skin.bar.bg.grid[0], 0, 0, 0, 0, 3, 11); -//blit(temp1, gui_skin.bar.bg.grid[1], 4, 0, 0, 0, 1, 11); -//blit(temp1, gui_skin.bar.bg.grid[2], 13, 0, 0, 0, 3, 11); + //BITMAP *temp1 = load_bitmap("data/bar.bmp", NULL); + //BITMAP *temp2 = load_bitmap("data/bar_filled.bmp", NULL); + gui_skin.plus.bg.grid[0] = load_bitmap("data/plus.bmp", NULL); + gui_skin.plus.bg.grid[1] = load_bitmap("data/plus_sel.bmp", NULL); + gui_skin.plus.bg.grid[2] = load_bitmap("data/plus_dis.bmp", NULL); + //blit(temp1, gui_skin.bar.bg.grid[0], 0, 0, 0, 0, 3, 11); + //blit(temp1, gui_skin.bar.bg.grid[1], 4, 0, 0, 0, 1, 11); + //blit(temp1, gui_skin.bar.bg.grid[2], 13, 0, 0, 0, 3, 11); } + void loadDialogSkin() { char **tokens; int tokenCount; @@ -446,7 +445,6 @@ void draw_skinned_rect(BITMAP*dst, LexSkinnedRect *skin, int x, int y,int w, int int gui_load_skin(const char* skinname) { - gui__external_slider_callback = NULL; push_config_state(); set_config_file(skinname); gui_gfx = load_datafile(get_config_string("skin", "gfx", 0)); @@ -601,84 +599,6 @@ int tmw_button_proc(int msg, DIALOG *d, int c) { return ret; } -int tmw_slider_proc(int msg, DIALOG *d, int c) { - int w = 0; - int h = 0; - int x,y; - - int ret = D_O_K; - - static int watchdog = 0; - - watchdog++; - if (watchdog == 1) { - gui__external_slider_callback = (int(__cdecl *)(void *, int))d->dp2; - d->dp2 = (void*)reroute_slider_proc; - } - - if (msg == MSG_DRAW) { - if (d->w >= d->h) { - //rectfill(gui_bitmap, d->x, d->y, d->x + d->w, d->y+d->h, d->bg); - /* horiz */ - x = d->x; - y = d->y + (d->h- gui_skin.slider.hSlider[0]->h)/2; - masked_blit(gui_skin.slider.hSlider[0], gui_bitmap, 0, 0, x, y, gui_skin.slider.hSlider[0]->w, gui_skin.slider.hSlider[0]->h); - w = d->w -gui_skin.slider.hSlider[0]->w - gui_skin.slider.hSlider[2]->w; - x+= gui_skin.slider.hSlider[0]->w; - - masked_stretch_blit( - gui_skin.slider.hSlider[1], gui_bitmap, - 0, 0, gui_skin.slider.hSlider[1]->w, gui_skin.slider.hSlider[1]->h, - x, y, w, gui_skin.slider.hSlider[1]->h); - - x+=w; - masked_blit(gui_skin.slider.hSlider[2], gui_bitmap, 0, 0, x, y, gui_skin.slider.hSlider[2]->w, gui_skin.slider.hSlider[2]->h); - - if(d->d1==0)d->d1=1; // Fix by 0 division - - x = d->x + ((d->w-gui_skin.slider.hGrip->w) * d->d2)/d->d1; - y = d->y + (d->h - gui_skin.slider.hGrip->h)/2; - if(!gui_bitmap)error("gui_bitmap"); - if(!gui_skin.slider.hGrip)error("hGrip"); - masked_blit(gui_skin.slider.hGrip, gui_bitmap, 0, 0, x, y, gui_skin.slider.hGrip->w, gui_skin.slider.hGrip->h); - } else { - rectfill(gui_bitmap, d->x, d->y, d->x + d->w, d->y+d->h, d->bg); - /* vertic */ - x = d->x+ (d->w- gui_skin.slider.vSlider[0]->w)/2; - y = d->y; - masked_blit(gui_skin.slider.vSlider[0], gui_bitmap, 0, 0, x, y, gui_skin.slider.vSlider[0]->w, gui_skin.slider.vSlider[0]->h); - h = d->h - gui_skin.slider.vSlider[0]->h - gui_skin.slider.vSlider[2]->h; - y += gui_skin.slider.vSlider[0]->h; - - masked_stretch_blit( - gui_skin.slider.vSlider[1], gui_bitmap, - 0, 0, gui_skin.slider.vSlider[1]->w, gui_skin.slider.vSlider[1]->h, - x, y, gui_skin.slider.vSlider[1]->w, h); - - y+=h; - masked_blit(gui_skin.slider.vSlider[2], gui_bitmap, 0, 0, x, y, gui_skin.slider.vSlider[2]->w, gui_skin.slider.vSlider[2]->h); - - y = d->y + d->h - (((d->h-gui_skin.slider.vGrip->h) * d->d2)/d->d1)-gui_skin.slider.vGrip->h; - x = d->x + (d->w - gui_skin.slider.vGrip->w)/2; - if (gui_skin.slider.vGrip->w % 2 !=0) { - x++; - } - masked_blit(gui_skin.slider.vGrip, gui_bitmap, 0, 0, x, y, gui_skin.slider.vGrip->w, gui_skin.slider.vGrip->h); - } - //textprintf(gui_bitmap, font,10, 10, makecol(255,255,255), "%i", d->d2); - } else { - if(d->d1==0)d->d1 = 1; - ret = d_slider_proc(msg,d,c); - } - - if (watchdog == 1) { - d->dp2 = (void*)gui__external_slider_callback; - } - watchdog--; - return ret; -} - - int tmw_radio_proc(int msg, DIALOG *d, int c) { BITMAP *box = NULL; int x, y; @@ -958,60 +878,6 @@ int tmw_dialog_proc(int msg, DIALOG *d, int c) { } -/** - dialog box w/ left aligned head -*/ -int tmw_ldialog_proc(int msg, DIALOG *d, int c) { - int x, y; - - if (msg == MSG_CLICK) { - if(mouse_y < d->y + gui_skin.dialog.bg.grid[1]->h) { - //drag = true; - d->d1 = mouse_x - d->x; - d->d2 = mouse_y - d->y; - } - } else if (msg == MSG_DRAW) { - if((mouse_b & 1)&&(d->d1>=0)&&(d->d2>=0)) {//(drag==true)) { - x = mouse_x-d->d1; - y = mouse_y-d->d2; - if(x<15) { - x=0; - position_mouse(d->d1, mouse_y); - } - if(y<15) { - y=0; - position_mouse(mouse_x, d->d2); - } - if(x+d->w>=785) { - x=800-d->w; - position_mouse(x+d->d1, mouse_y); - } - if(y+d->h>=585) { - y=600-d->h; - position_mouse(mouse_x, y+d->d2); - } - position_dialog(active_dialog, x, y); - } else { - //drag = false; - d->d1 = -1; - d->d2 = -1; - } - draw_skinned_rect(gui_bitmap, &gui_skin.dialog.bg, d->x, d->y, d->w, d->h); - - textprintf_ex(gui_bitmap, font, d->x + 4, d->y + (gui_skin.dialog.bg.grid[1]->h - text_height(font))/2, d->fg, -1, "%s", (char*)d->dp); - } - return D_O_K; -} - -int reroute_slider_proc(void *dp3, int d2) { - int ret = 0; - - if (gui__external_slider_callback != NULL) { - ret = gui__external_slider_callback(dp3, d2); - } - return ret; -} - // Helper function to draw a scrollable bar void _gui_draw_scrollable_frame(DIALOG *d, int listsize, int offset, int height, int fg_color, int bg) { int i, len; @@ -1207,152 +1073,6 @@ void _gui_draw_textbox(char *thetext, int *listsize, int draw, int offset, } } -int tmw_textbox_proc(int msg, DIALOG *d, int c) { - int height, bar, ret = D_O_K; - int start, top, bottom, l; - int used, delta; - int fg_color = (d->flags & D_DISABLED) ? gui_mg_color : d->fg; - - /* calculate the actual height */ - height = (d->h-8) / text_height(font); - - switch (msg) { - - case MSG_START: - /* measure how many lines of text we contain */ - _gui_draw_textbox((char *)d->dp, &d->d1, - 0, /* DONT DRAW anything */ - d->d2, !(d->flags & D_SELECTED), 8, - d->x, d->y, d->w, d->h, - (d->flags & D_DISABLED), - 0, 0, 0); - break; - - case MSG_DRAW: - /* tell the object to sort of draw, but only calculate the listsize */ - _gui_draw_textbox((char *)d->dp, &d->d1, - 0, /* DONT DRAW anything */ - d->d2, !(d->flags & D_SELECTED), 8, - d->x, d->y, d->w, d->h, - (d->flags & D_DISABLED), - 0, 0, 0); - - if (d->d1 > height) { - bar = 12; - } - else { - bar = 0; - d->d2 = 0; - } - - /* now do the actual drawing */ - _gui_draw_textbox((char *)d->dp, &d->d1, 1, d->d2, - !(d->flags & D_SELECTED), 8, - d->x, d->y, d->w-bar, d->h, - (d->flags & D_DISABLED), - fg_color, d->bg, gui_mg_color); - - /* draw the frame around */ - _gui_draw_scrollable_frame(d, d->d1, d->d2, height, fg_color, d->bg); - - break; - - case MSG_CLICK: - /* figure out if it's on the text or the scrollbar */ - bar = (d->d1 > height); - - if ((!bar) || (gui_mouse_x() < d->x+d->w-13)) /* clicked on the text area */ - ret = D_O_K; - else /* clicked on the scroll area */ - //_handle_scrollable_scroll_click(d, d->d1, &d->d2, height); - break; - - case MSG_CHAR: - start = d->d2; - used = D_USED_CHAR; - - if (d->d1 > 0) { - if (d->d2 > 0) - top = d->d2+1; - else - top = 0; - - l = (d->h-8)/text_height(font); - - bottom = d->d2 + l - 1; - if (bottom >= d->d1-1) - bottom = d->d1-1; - else - bottom--; - - if ((c>>8) == KEY_UP) - d->d2--; - else if ((c>>8) == KEY_DOWN) - d->d2++; - else if ((c>>8) == KEY_HOME) - d->d2 = 0; - else if ((c>>8) == KEY_END) - d->d2 = d->d1-l; - else if ((c>>8) == KEY_PGUP) - d->d2 -= (bottom-top) ? bottom-top : 1; - else if ((c>>8) == KEY_PGDN) - d->d2 += (bottom-top) ? bottom-top : 1; - else - used = D_O_K; - - /* make sure that the list stays in bounds */ - if (d->d2 > d->d1-l) - d->d2 = d->d1-l; - if (d->d2 < 0) - d->d2 = 0; - } - else - used = D_O_K; - - /* if we changed something, better redraw... */ - if (d->d2 != start) - d->flags |= D_DIRTY; - - ret = used; - break; - - case MSG_WHEEL: - l = (d->h-8)/text_height(font); - delta = (l > 3) ? 3 : 1; - - /* scroll, making sure that the list stays in bounds */ - start = d->d2; - d->d2 = (c > 0) ? MAX(0, d->d2-delta) : MIN(d->d1-l, d->d2+delta); - - /* if we changed something, better redraw... */ - if (d->d2 != start) - d->flags |= D_DIRTY; - - ret = D_O_K; - break; - - case MSG_WANTFOCUS: - /* if we don't have a scrollbar we can't do anything with the focus */ - if (d->d1 > height) - ret = D_WANTFOCUS; - break; - - default: - ret = D_O_K; - } - - return ret; -} - -int tmw_bitmap_proc(int msg, DIALOG *d, int c) { - if(msg==MSG_DRAW) { - draw_skinned_rect(gui_bitmap, &gui_skin.textbox.bg, d->x, d->y, d->w, d->h); - if(d->dp!=NULL) - masked_blit(((BITMAP *)d->dp), gui_bitmap, 0, 0, d->x+(d->w-d->d1)/2, d->y+2, d->d1, d->d2); - } - return D_O_K; -} - void ok(const char *title, const char *message) { DIALOG alert_dialog[] = { /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ diff --git a/src/gui/gui.h b/src/gui/gui.h index 81e533bf..6aa9be57 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -100,8 +100,8 @@ typedef struct { LexTextbox textbox; LexListbox listbox; LexDialog dialog; - LexBar bar; - LexPlus plus; + LexBar bar; + LexPlus plus; } LexSkin; extern LexSkin gui_skin; @@ -129,14 +129,10 @@ int gui_text(BITMAP *bmp, AL_CONST char *s, // Old Allegro GUI procs int tmw_button_proc(int msg, DIALOG *d, int c); -int tmw_slider_proc(int msg, DIALOG *d, int c); int tmw_radio_proc(int msg, DIALOG *d, int c); int tmw_list_proc(int msg, DIALOG *d, int c); int tmw_text_proc(int msg, DIALOG *d, int c); int tmw_dialog_proc(int msg, DIALOG *d, int c); -int tmw_ldialog_proc(int msg, DIALOG *d, int c); -int tmw_textbox_proc(int msg, DIALOG *d, int c); -int tmw_bitmap_proc(int msg, DIALOG *d, int c); int tmw_plus_proc(int msg, DIALOG *d, int c); void ok(const char *title, const char *message); diff --git a/src/main.cpp b/src/main.cpp index ffbd4f5a..ec22a389 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,6 @@ #include "main.h" #include "./sound/sound.h" #include "./graphic/graphic.h" -#include "./graphic/2xsai.h" #include <iostream> @@ -42,7 +42,6 @@ #include "log.h" #include "game.h" #include "./net/protocol.h" -#include "./graphic/2xsai.h" #include "../data/graphic/gfx_data.h" #include <allegro.h> #ifdef WIN32 |