gfx.c
author tron
Fri, 08 Jul 2005 21:24:27 +0000
changeset 2025 b0b897359fdf
parent 2014 0230ed9186bc
child 2037 380e80aed97a
permissions -rw-r--r--
(svn r2534) Small cleanup
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1829
diff changeset
     2
#include "openttd.h"
1349
07514c2cc6d1 (svn r1853) Move spritecache function declarations into a header of their own and use SpriteID as parameter type where appropriate
tron
parents: 1348
diff changeset
     3
#include "spritecache.h"
1309
dab90d4cbf2d (svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents: 1130
diff changeset
     4
#include "strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#include "table/palettes.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
#include "hal.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
     9
Colour _cur_palette[256];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
    10
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
    11
static void GfxMainBlitter(const Sprite *sprite, int x, int y, int mode);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
static int _stringwidth_out;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
static byte _cursor_backup[64*64];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
static Rect _invalid_rect;
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
    16
static const byte *_color_remap_ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
static byte _string_colorremap[3];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
    19
#define DIRTY_BYTES_PER_LINE (MAX_SCREEN_WIDTH / 64)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
    23
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
    24
void memcpy_pitch(void *d, void *s, int w, int h, int spitch, int dpitch)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	byte *dp = (byte*)d;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
	byte *sp = (byte*)s;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
	assert(h >= 0);
1056
ff3cfd9042a3 (svn r1557) Replace strange if () do while () construct with a plain for ()
tron
parents: 1009
diff changeset
    30
	for (; h != 0; --h) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
		memcpy(dp, sp, w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
		dp += dpitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
		sp += spitch;
1056
ff3cfd9042a3 (svn r1557) Replace strange if () do while () construct with a plain for ()
tron
parents: 1009
diff changeset
    34
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
    38
void GfxScroll(int left, int top, int width, int height, int xo, int yo)
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
    39
{
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
    40
	byte *src;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
    41
	byte *dst;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	int p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
	int ht;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
    45
	if (xo == 0 && yo == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
    47
	if (_cursor.visible) UndrawMouseCursor();
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
    48
	UndrawTextMessage();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	p = _screen.pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    52
	if (yo > 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
		// Calculate pointers
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    54
		dst = _screen.dst_ptr + (top + height - 1) * p + left;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
		src = dst - yo * p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
		// Decrease height and increase top
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
		top += yo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
		height -= yo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
		assert(height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
		// Adjust left & width
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
		if (xo >= 0) {
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    64
			dst += xo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
			left += xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
			width -= xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
		} else {
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    68
			src -= xo;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
			width += xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    72
		for (ht = height; ht > 0; --ht) {
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    73
			memcpy(dst, src, width);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
			src -= p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
			dst -= p;
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    76
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
	} else {
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    78
		// Calculate pointers
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
		dst = _screen.dst_ptr + top * p + left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
		src = dst - yo * p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
		// Decrese height. (yo is <=0).
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
		height += yo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
		assert(height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
		// Adjust left & width
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
		if (xo >= 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
			dst += xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
			left += xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
			width -= xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
			src -= xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
			width += xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    96
		// the y-displacement may be 0 therefore we have to use memmove,
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    97
		// because source and destination may overlap
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    98
		for (ht = height; ht > 0; --ht) {
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
    99
			memmove(dst, src, width);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
			src += p;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
			dst += p;
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
   102
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	}
375
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
   104
	// This part of the screen is now dirty.
6a1e279049d2 (svn r564) Simplify scroll logic and correct one erroneous use of memcpy()
tron
parents: 332
diff changeset
   105
	_video_driver->make_dirty(left, top, width, height);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   109
void GfxFillRect(int left, int top, int right, int bottom, int color)
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   110
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	DrawPixelInfo *dpi = _cur_dpi;
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   112
	byte *dst;
332
745ec2bbdd5e (svn r499) Merge r498 to trunk:
tron
parents: 306
diff changeset
   113
	const int otop = top;
745ec2bbdd5e (svn r499) Merge r498 to trunk:
tron
parents: 306
diff changeset
   114
	const int oleft = left;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   116
	if (dpi->zoom != 0) return;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   117
	if (left > right || top > bottom) return;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   118
	if (right < dpi->left || left >= dpi->left + dpi->width) return;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   119
	if (bottom < dpi->top || top >= dpi->top + dpi->height) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	if ( (left -= dpi->left) < 0) left = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   122
	right = right - dpi->left + 1;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   123
	if (right > dpi->width) right = dpi->width;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	right -= left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
	assert(right > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	if ( (top -= dpi->top) < 0) top = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	bottom = bottom - dpi->top + 1;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   129
	if (bottom > dpi->height) bottom = dpi->height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
	bottom -= top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	assert(bottom > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
	dst = dpi->dst_ptr + top * dpi->pitch + left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	if (!(color & 0x8000)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
		if (!(color & 0x4000)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
				memset(dst, color, right);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
				dst += dpi->pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
			} while (--bottom);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
			/* use colortable mode */
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   143
			const byte* ctab = GetNonSprite(color & 0x3FFF) + 1;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   144
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
				int i;
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
   147
				for (i = 0; i != right; i++) dst[i] = ctab[dst[i]];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
				dst += dpi->pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
			} while (--bottom);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
	} else {
332
745ec2bbdd5e (svn r499) Merge r498 to trunk:
tron
parents: 306
diff changeset
   152
		byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   153
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   154
			int i;
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
   155
			for (i = (bo ^= 1); i < right; i += 2) dst[i] = (byte)color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
			dst += dpi->pitch;
332
745ec2bbdd5e (svn r499) Merge r498 to trunk:
tron
parents: 306
diff changeset
   157
		} while (--bottom > 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
410
8de2aaf20800 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 375
diff changeset
   161
static void GfxSetPixel(int x, int y, int color)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
	DrawPixelInfo *dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
	if ((x-=dpi->left) < 0 || x>=dpi->width || (y-=dpi->top)<0 || y>=dpi->height)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
		return;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   166
	dpi->dst_ptr[y * dpi->pitch + x] = color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
void GfxDrawLine(int x, int y, int x2, int y2, int color)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
	int dy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
	int dx;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   173
	int stepx;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   174
	int stepy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
	int frac;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
	// Check clipping first
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
		DrawPixelInfo *dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
		int t;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   182
		if (x < dpi->left && x2 < dpi->left) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   184
		if (y < dpi->top && y2 < dpi->top) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   186
		t = dpi->left + dpi->width;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   187
		if (x > t && x2 > t) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   189
		t = dpi->top + dpi->height;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   190
		if (y > t && y2 > t) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
	dy = (y2 - y) * 2;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   194
	if (dy < 0) {
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   195
		dy = -dy;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   196
		stepy = -1;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   197
	} else {
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   198
		stepy = 1;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   199
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
	dx = (x2 - x) * 2;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   202
	if (dx < 0) {
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   203
		dx = -dx;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   204
		stepx = -1;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   205
	} else {
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   206
		stepx = 1;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   207
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
	GfxSetPixel(x, y, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
	if (dx > dy) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
		frac = dy - (dx >> 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
		while (x != x2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
			if (frac >= 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
				y += stepy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
				frac -= dx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
			x += stepx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
			frac += dy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
			GfxSetPixel(x, y, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   221
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
		frac = dx - (dy >> 1);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
		while (y != y2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
			if (frac >= 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
				x += stepx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
				frac -= dy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   228
			y += stepy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   229
			frac += dx;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   230
			GfxSetPixel(x, y, color);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
// ASSIGNMENT OF ASCII LETTERS < 32
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
// 0 - end of string
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
// 1 - SETX <BYTE>
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
// 2 - SETXY <BYTE> <BYTE>
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
   239
// 3-7 -
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
// 8 - TINYFONT
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
// 9 - BIGFONT
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
// 10 - newline
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
   243
// 11-14 -
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   244
// 15-31 - 17 colors
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   245
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
	ASCII_SETX = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   249
	ASCII_SETXY = 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   250
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   251
	ASCII_TINYFONT = 8,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
	ASCII_BIGFONT = 9,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
	ASCII_NL = 10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
	ASCII_COLORSTART = 15,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
/* returns right coordinate */
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   260
int DrawString(int x, int y, uint16 str, uint16 color)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   261
{
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   262
	char buffer[512];
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   263
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   264
	GetString(buffer, str);
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   265
	return DoDrawString(buffer, x, y, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   266
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   269
void DrawStringRightAligned(int x, int y, uint16 str, uint16 color)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
{
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   271
	char buffer[512];
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   272
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   273
	GetString(buffer, str);
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   274
	DoDrawString(buffer, x - GetStringWidth(buffer), y, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   275
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   278
int DrawStringCentered(int x, int y, uint16 str, uint16 color)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
{
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   280
	char buffer[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	int w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   283
	GetString(buffer, str);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   285
	w = GetStringWidth(buffer);
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   286
	DoDrawString(buffer, x - w / 2, y, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	return w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   291
void DrawStringCenterUnderline(int x, int y, uint16 str, uint16 color)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
	int w = DrawStringCentered(x, y, str, color);
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   294
	GfxFillRect(x - (w >> 1), y + 10, x - (w >> 1) + w, y + 10, _string_colorremap[1]);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   297
static uint32 FormatStringLinebreaks(char *str, int maxw)
1095
90220990fd7c (svn r1596) Add some more statics
tron
parents: 1093
diff changeset
   298
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
	int num = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
	int base = _stringwidth_base;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	int w;
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   302
	char *last_space;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
	byte c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
	for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
		w = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   307
		last_space = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   308
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   309
		for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
			c = *str++;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1357
diff changeset
   311
			if (c == ASCII_LETTERSTART) last_space = str;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
			if (c >= ASCII_LETTERSTART) {
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1357
diff changeset
   314
				w += GetCharacterWidth(base + (byte)c);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   315
				if (w > maxw) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   316
					str = last_space;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   317
					if (str == NULL)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
						return num + (base << 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   319
					break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   322
				if (c == 0) return num + (base << 16);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
				if (c == ASCII_NL) break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
				if (c == ASCII_SETX) str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   326
				else if (c == ASCII_SETXY) str += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
				else if (c == ASCII_TINYFONT) base = 224;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
				else if (c == ASCII_BIGFONT) base = 448;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
		num++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   333
		str[-1] = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
void DrawStringMultiCenter(int x, int y, uint16 str, int maxw)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
{
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   340
	char buffer[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
	uint32 tmp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   342
	int num, w, mt, t;
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   343
	const char *src;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   344
	byte c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   345
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   346
	GetString(buffer, str);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   347
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   348
	tmp = FormatStringLinebreaks(buffer, maxw);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   349
	num = (uint16)tmp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   350
	t = tmp >> 16;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   352
	mt = 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
	if (t != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
		mt = 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
		if (t != 244) mt = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
	y -= (mt >> 1) * num;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   360
	src = buffer;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
		w = GetStringWidth(src);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
		DoDrawString(src, x - (w>>1), y, 0xFE);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
		_stringwidth_base = _stringwidth_out;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
		for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
			c = *src++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   369
			if (c == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
				y += mt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
				if (--num < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   372
					_stringwidth_base = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   373
					return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   374
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   375
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   376
			} else if (c == ASCII_SETX) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
				src++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   378
			} else if (c == ASCII_SETXY) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   379
				src+=2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   383
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   385
void DrawStringMultiLine(int x, int y, uint16 str, int maxw)
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   386
{
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   387
	char buffer[512];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
	uint32 tmp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
	int num, w, mt, t;
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   390
	const char *src;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
	byte c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   393
	GetString(buffer, str);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   395
	tmp = FormatStringLinebreaks(buffer, maxw);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
	num = (uint16)tmp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
	t = tmp >> 16;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	mt = 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
	if (t != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
		mt = 6;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
		if (t != 244) mt = 18;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
1336
c9e6b766bf21 (svn r1840) Repel str_buffr and use local buffers where possible
tron
parents: 1323
diff changeset
   404
	src = buffer;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
	for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
		w = GetStringWidth(src);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   408
		DoDrawString(src, x, y, 0xFE);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
		_stringwidth_base = _stringwidth_out;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
		for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
			c = *src++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
			if (c == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   414
				y += mt;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
				if (--num < 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
					_stringwidth_base = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
					return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
				break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
			} else if (c == ASCII_SETX) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
				src++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
			} else if (c == ASCII_SETXY) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
				src+=2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   426
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   427
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   429
int GetStringWidth(const char *str)
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   430
{
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1357
diff changeset
   431
	int w = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
	byte c;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
	int base = _stringwidth_base;
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1357
diff changeset
   434
	for (c = *str; c != '\0'; c = *(++str)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   435
		if (c >= ASCII_LETTERSTART) {
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1357
diff changeset
   436
			w += GetCharacterWidth(base + c);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   437
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
			if (c == ASCII_SETX) str++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
			else if (c == ASCII_SETXY) str += 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
			else if (c == ASCII_TINYFONT) base = 224;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
			else if (c == ASCII_BIGFONT) base = 448;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
	}
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1357
diff changeset
   444
	return w;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   446
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   447
void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags)
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   448
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
	byte color_2 = _color_list[ctab].window_color_1a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
	byte color_interior = _color_list[ctab].window_color_bga;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
	byte color_3 = _color_list[ctab].window_color_bgb;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
	byte color = _color_list[ctab].window_color_2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
   454
	if (!(flags & 0x8)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
		if (!(flags & 0x20)) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   456
			GfxFillRect(left, top, left, bottom - 1, color);
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   457
			GfxFillRect(left + 1, top, right - 1, top, color);
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   458
			GfxFillRect(right, top, right, bottom - 1, color_2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
			GfxFillRect(left, bottom, right, bottom, color_2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   460
			if (!(flags & 0x10)) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   461
				GfxFillRect(left + 1, top + 1, right - 1, bottom - 1, color_interior);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
			GfxFillRect(left, top, left, bottom, color_2);
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   465
			GfxFillRect(left + 1, top, right, top, color_2);
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   466
			GfxFillRect(right, top + 1, right, bottom - 1, color);
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   467
			GfxFillRect(left + 1, bottom, right, bottom, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
			if (!(flags & 0x10)) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   469
				GfxFillRect(left + 1, top + 1, right - 1, bottom - 1,
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   470
					flags & 0x40 ? color_interior : color_3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
	} else if (flags & 0x1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
		// transparency
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
		GfxFillRect(left, top, right, bottom, 0x4322);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
		GfxFillRect(left, top, right, bottom, color_interior);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   481
int DoDrawString(const char *string, int x, int y, uint16 real_color)
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   482
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   483
	DrawPixelInfo *dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
	int base = _stringwidth_base;
509
52dde395d888 (svn r819) Code cleanup: colors for langfile strings are now taken from a color table instead of a sprite
dominik
parents: 461
diff changeset
   485
	byte c;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   486
	byte color;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
	int xo = x, yo = y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   489
	color = real_color & 0xFF;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   490
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
	if (color != 0xFE) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   492
		if (x >= dpi->left + dpi->width ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
				x + _screen.width*2 <= dpi->left ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
				y >= dpi->top + dpi->height ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
				y + _screen.height <= dpi->top)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
					return x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
		if (color != 0xFF) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
switch_color:;
657
40a9032b454b (svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents: 619
diff changeset
   500
			if (real_color & IS_PALETTE_COLOR) {
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   501
				_string_colorremap[1] = color;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   502
				_string_colorremap[2] = 215;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   503
			} else {
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   504
				_string_colorremap[1] = _string_colormap[color].text;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   505
				_string_colorremap[2] = _string_colormap[color].shadow;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
   506
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
			_color_remap_ptr = _string_colorremap;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
check_bounds:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   512
	if (y + 19 <= dpi->top || dpi->top + dpi->height <= y) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
skip_char:;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
		for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   515
			c = *string++;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
   516
			if (c < ASCII_LETTERSTART) goto skip_cont;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
	for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
		c = *string++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
skip_cont:;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
		if (c == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
			_stringwidth_out = base;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
			return x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
		if (c >= ASCII_LETTERSTART) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   528
			if (x >= dpi->left + dpi->width) goto skip_char;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
			if (x + 26 >= dpi->left) {
1350
067b22970f19 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
   530
				GfxMainBlitter(GetSprite(base + 2 + c - ASCII_LETTERSTART), x, y, 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
			}
1390
53a5713cf3f9 (svn r1894) - Codechange: cleaned up the console a bit, wholly unified handling of text with that of editboxes
Darkvater
parents: 1357
diff changeset
   532
			x += GetCharacterWidth(base + c);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   533
		} else if (c == ASCII_NL) { // newline = {}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   534
			x = xo;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   535
			y += 10;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   536
			if (base != 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   537
				y -= 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   538
				if (base != 0xE0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   539
					y += 12;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
			goto check_bounds;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
		} else if (c >= ASCII_COLORSTART) { // change color?
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
			color = (byte)(c - ASCII_COLORSTART);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
			goto switch_color;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
		} else if (c == ASCII_SETX) { // {SETX}
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   546
			x = xo + (byte)*string++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
		} else if (c == ASCII_SETXY) {// {SETXY}
1323
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   548
			x = xo + (byte)*string++;
41397685320a (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1309
diff changeset
   549
			y = yo + (byte)*string++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
		} else if (c == ASCII_TINYFONT) { // {TINYFONT}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
			base = 0xE0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
		} else if (c == ASCII_BIGFONT) { // {BIGFONT}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
			base = 0x1C0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
			printf("Unknown string command character %d\n", c);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   560
void DrawSprite(uint32 img, int x, int y)
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   561
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
	if (img & 0x8000) {
1350
067b22970f19 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
   563
		_color_remap_ptr = GetNonSprite(img >> 16) + 1;
067b22970f19 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
   564
		GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   565
	} else if (img & 0x4000) {
1350
067b22970f19 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
   566
		_color_remap_ptr = GetNonSprite(img >> 16) + 1;
067b22970f19 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
   567
		GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 2);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   568
	} else {
1350
067b22970f19 (svn r1854) Split GetSpritePtr() into GetSprite() for regular sprites (returning a Sprite*) and GetNonSprite() for "sprites" of type 0xFF (returning byte*)
tron
parents: 1349
diff changeset
   569
		GfxMainBlitter(GetSprite(img & 0x3FFF), x, y, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   570
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   573
typedef struct BlitterParams {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   574
	int start_x, start_y;
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   575
	const byte* sprite;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   576
	const byte* sprite_org;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   577
	byte *dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   578
	int mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
	int width, height;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   580
	int width_org;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   581
	int height_org;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   582
	int pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
	byte info;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
} BlitterParams;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
static void GfxBlitTileZoomIn(BlitterParams *bp)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   587
{
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   588
	const byte* src_o = bp->sprite;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   589
	const byte* src;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
	int num, skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   591
	byte done;
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   592
	byte *dst;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   593
	const byte* ctab;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   595
	if (bp->mode & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   596
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
   597
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   598
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   601
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   602
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   603
				src = src_o + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   605
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   607
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   608
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   609
					dst += skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   610
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   611
					src -= skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   612
					num += skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   613
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   614
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   615
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   616
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   619
					num -= skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   620
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   621
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   623
				ctab = _color_remap_ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   624
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   625
				for (; num >= 4; num -=4) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
					dst[3] = ctab[src[3]];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   627
					dst[2] = ctab[src[2]];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   628
					dst[1] = ctab[src[1]];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   629
					dst[0] = ctab[src[0]];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
					dst += 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
					src += 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   632
				}
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   633
				for (; num != 0; num--) *dst++ = ctab[*src++];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   634
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   635
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   636
			bp->dst += bp->pitch;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   637
		} while (--bp->height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
	} else if (bp->mode & 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   640
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   641
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   644
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   646
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   649
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
					dst += skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
					num += skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   653
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   655
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   656
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   657
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
					num -= skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   660
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   661
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   662
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   663
				ctab = _color_remap_ptr;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   664
				for (; num != 0; num--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
					*dst = ctab[*dst];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   666
					dst++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
			bp->dst += bp->pitch;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   671
		} while (--bp->height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
				src = src_o + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   683
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
					dst += skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   686
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   687
					src -= skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
					num += skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   689
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   690
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   692
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   693
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   695
					num -= skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   696
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
#if defined(_WIN32)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   699
				if (num & 1) *dst++ = *src++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
				if (num & 2) { *(uint16*)dst = *(uint16*)src; dst += 2; src += 2; }
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
				if (num >>= 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   702
					do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   703
						*(uint32*)dst = *(uint32*)src;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   704
						dst += 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
						src += 4;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   706
					} while (--num != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   708
#else
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
				memcpy(dst, src, num);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   710
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   711
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
			bp->dst += bp->pitch;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   714
		} while (--bp->height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   715
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   717
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
static void GfxBlitZoomInUncomp(BlitterParams *bp)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
{
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   720
	const byte *src = bp->sprite;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   721
	byte *dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   722
	int height = bp->height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   723
	int width = bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   724
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   725
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   726
	assert(height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   727
	assert(width > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   728
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   729
	if (bp->mode & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   730
		if (bp->info & 1) {
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   731
			const byte *ctab = _color_remap_ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   732
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   733
			do {
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   734
				for (i = 0; i != width; i++) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   735
					byte b = ctab[src[i]];
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   736
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   737
					if (b != 0) dst[i] = b;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   738
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   739
				src += bp->width_org;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   740
				dst += bp->pitch;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   741
			} while (--height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   743
	} else if (bp->mode & 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   744
		if (bp->info & 1) {
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   745
			const byte *ctab = _color_remap_ptr;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   746
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   747
			do {
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   748
				for (i = 0; i != width; i++)
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   749
					if (src[i] != 0) dst[i] = ctab[dst[i]];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   750
				src += bp->width_org;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
				dst += bp->pitch;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   752
			} while (--height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   753
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   754
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   755
		if (!(bp->info & 1)) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   756
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   757
				memcpy(dst, src, width);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
				src += bp->width_org;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   759
				dst += bp->pitch;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   760
			} while (--height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
		} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   763
				int n = width;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   764
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   765
				for (; n >= 4; n -= 4) {
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   766
					if (src[0] != 0) dst[0] = src[0];
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   767
					if (src[1] != 0) dst[1] = src[1];
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   768
					if (src[2] != 0) dst[2] = src[2];
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   769
					if (src[3] != 0) dst[3] = src[3];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   771
					dst += 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
					src += 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   774
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   775
				for (; n != 0; n--) {
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   776
					if (src[0] != 0) dst[0] = src[0];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
					src++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   778
					dst++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   779
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   780
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   781
				src += bp->width_org - width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   782
				dst += bp->pitch - width;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   783
			} while (--height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   784
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   785
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   786
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   787
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   788
static void GfxBlitTileZoomMedium(BlitterParams *bp)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   789
{
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   790
	const byte* src_o = bp->sprite;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   791
	const byte* src;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   792
	int num, skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   793
	byte done;
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   794
	byte *dst;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   795
	const byte* ctab;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   796
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   797
	if (bp->mode & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   798
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   799
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   800
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   801
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   802
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   803
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
				src = src_o + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   806
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
				if (skip & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   810
					skip++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   811
					src++;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   812
					if (--num == 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   814
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   816
					dst += skip >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   817
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   818
					src -= skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   819
					num += skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   820
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   821
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   822
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   824
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   825
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   826
					num -= skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   827
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   828
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   829
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   830
				ctab = _color_remap_ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
				num = (num + 1) >> 1;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   832
				for (; num != 0; num--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   833
						*dst = ctab[*src];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   834
						dst++;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   835
						src += 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   836
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   837
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   838
			bp->dst += bp->pitch;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   839
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   840
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   841
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   842
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
			} while (!(done & 0x80));
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   845
		} while (--bp->height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   846
	} else if (bp->mode & 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   848
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   849
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   850
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   852
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   856
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   857
				if (skip & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   858
					skip++;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   859
					if (--num == 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   860
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   861
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   863
					dst += skip >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   864
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   865
					num += skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   866
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   867
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   868
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   869
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   870
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   871
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   872
					num -= skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   873
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   874
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   875
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   876
				ctab = _color_remap_ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   877
				num = (num + 1) >> 1;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   878
				for (; num != 0; num--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   879
						*dst = ctab[*dst];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   880
						dst++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   881
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   882
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   883
			bp->dst += bp->pitch;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   884
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   885
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   886
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   887
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   888
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   889
			} while (!(done & 0x80));
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   890
		} while (--bp->height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   891
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   892
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   893
		do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   894
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   895
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   896
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   897
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   898
				src = src_o + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   899
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   900
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   901
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   902
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   903
				if (skip & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   904
					skip++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
					src++;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   906
					if (--num == 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
					dst += skip >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   911
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   912
					src -= skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   913
					num += skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   914
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   915
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   918
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   919
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   920
					num -= skip;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   921
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   922
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   923
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   924
				num = (num + 1) >> 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   925
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   926
				for (; num != 0; num--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   927
						*dst = *src;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   928
						dst++;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
   929
						src += 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   931
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   932
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   934
			bp->dst += bp->pitch;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
   935
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   936
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   937
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   938
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   939
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   940
			} while (!(done & 0x80));
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
   941
		} while (--bp->height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   942
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   943
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   944
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   945
static void GfxBlitZoomMediumUncomp(BlitterParams *bp)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   946
{
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   947
	const byte *src = bp->sprite;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   948
	byte *dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   949
	int height = bp->height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   950
	int width = bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   951
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   952
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   953
	assert(height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   954
	assert(width > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   955
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   956
	if (bp->mode & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   957
		if (bp->info & 1) {
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   958
			const byte *ctab = _color_remap_ptr;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   959
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   960
			for (height >>= 1; height != 0; height--) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   961
				for (i = 0; i != width >> 1; i++) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   962
					byte b = ctab[src[i * 2]];
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   963
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   964
					if (b != 0) dst[i] = b;
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   965
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   966
				src += bp->width_org * 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   967
				dst += bp->pitch;
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   968
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   969
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   970
	} else if (bp->mode & 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   971
		if (bp->info & 1) {
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   972
			const byte *ctab = _color_remap_ptr;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   973
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   974
			for (height >>= 1; height != 0; height--) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   975
				for (i = 0; i != width >> 1; i++)
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   976
					if (src[i * 2] != 0) dst[i] = ctab[dst[i]];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   977
				src += bp->width_org * 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   978
				dst += bp->pitch;
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   979
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   980
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   981
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   982
		if (bp->info & 1) {
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   983
			for (height >>= 1; height != 0; height--) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   984
				for (i = 0; i != width >> 1; i++)
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   985
					if (src[i * 2] != 0) dst[i] = src[i * 2];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   986
				src += bp->width_org * 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   987
				dst += bp->pitch;
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
   988
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   989
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   990
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   991
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   992
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   993
static void GfxBlitTileZoomOut(BlitterParams *bp)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   994
{
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   995
	const byte* src_o = bp->sprite;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   996
	const byte* src;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   997
	int num, skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   998
	byte done;
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
   999
	byte *dst;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
  1000
	const byte* ctab;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1001
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1002
	if (bp->mode & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1003
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1004
		for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1005
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1007
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1008
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1009
				src = src_o + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1010
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1011
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1012
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1013
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1014
				if (skip & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1015
					skip++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1016
					src++;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1017
					if (--num == 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1018
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1019
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1020
				if (skip & 2) {
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1021
					skip += 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1022
					src += 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1023
					num -= 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1024
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1025
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1026
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1027
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1028
					dst += skip >> 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1029
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1030
					src -= skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1031
					num += skip;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1032
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1033
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1034
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1035
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1036
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1037
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1038
					num -= skip;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1039
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1040
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1041
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1042
				ctab = _color_remap_ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1043
				num = (num + 3) >> 2;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
  1044
				for (; num != 0; num--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1045
						*dst = ctab[*src];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1046
						dst++;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
  1047
						src += 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1048
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1049
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1050
			bp->dst += bp->pitch;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1051
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1052
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1053
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1054
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1055
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1056
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1057
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1059
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1060
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1061
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1062
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1063
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1064
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1065
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1066
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1067
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1068
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1069
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1070
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1071
	} else if (bp->mode & 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1072
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1073
		for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1074
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1075
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1076
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1077
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1078
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1079
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1080
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1082
				if (skip & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1083
					skip++;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1084
					if (--num == 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1085
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1086
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1087
				if (skip & 2) {
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1088
					skip += 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1089
					num -= 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1090
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1091
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1092
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1093
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1094
					dst += skip >> 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1095
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1096
					num += skip;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1097
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1098
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1099
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1100
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1101
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1103
					num -= skip;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1104
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1105
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1106
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1107
				ctab = _color_remap_ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1108
				num = (num + 3) >> 2;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
  1109
				for (; num != 0; num--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1110
						*dst = ctab[*dst];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1111
						dst++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1112
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1114
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1115
			bp->dst += bp->pitch;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1116
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1117
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1118
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1119
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1120
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1121
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1122
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1123
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1124
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1125
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1126
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1127
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1128
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1129
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1130
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1131
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1132
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1133
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1134
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1135
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1136
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1137
		src_o += READ_LE_UINT16(src_o + bp->start_y * 2);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1138
		for(;;) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1139
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1140
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1141
				num = done & 0x7F;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1142
				skip = src_o[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1143
				src = src_o + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1144
				src_o += num + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1145
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1146
				dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1147
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1148
				if (skip & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1149
					skip++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1150
					src++;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1151
					if (--num == 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1152
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1153
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1154
				if (skip & 2) {
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1155
					skip += 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1156
					src += 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1157
					num -= 2;
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1158
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1159
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1160
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1161
				if ( (skip -= bp->start_x) > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1162
					dst += skip >> 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1163
				} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1164
					src -= skip;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1165
					num += skip;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1166
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1167
					skip = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1168
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1169
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1170
				skip = skip + num - bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1171
				if (skip > 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1172
					num -= skip;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1173
					if (num <= 0) continue;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1174
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1175
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1176
				num = (num + 3) >> 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1177
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
  1178
				for (; num != 0; num--) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1179
						*dst = *src;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1180
						dst++;
1997
91085465f12b (svn r2503) Small cleanup
tron
parents: 1996
diff changeset
  1181
						src += 4;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1182
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1183
			} while (!(done & 0x80));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1184
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1185
			bp->dst += bp->pitch;
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1186
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1187
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1188
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1189
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1190
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1191
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1192
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1193
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1194
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1195
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1196
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1197
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1198
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1199
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1200
			do {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1201
				done = src_o[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1202
				src_o += (done & 0x7F) + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1203
			} while (!(done & 0x80));
2004
6b975f28c351 (svn r2512) Small cleanup
tron
parents: 1997
diff changeset
  1204
			if (--bp->height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1205
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1206
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1207
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1208
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1209
static void GfxBlitZoomOutUncomp(BlitterParams *bp)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1210
{
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
  1211
	const byte* src = bp->sprite;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1212
	byte *dst = bp->dst;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1213
	int height = bp->height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1214
	int width = bp->width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1215
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1216
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1217
	assert(height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1218
	assert(width > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1219
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1220
	if (bp->mode & 1) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1221
		if (bp->info & 1) {
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
  1222
			const byte *ctab = _color_remap_ptr;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
  1223
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1224
			for (height >>= 2; height != 0; height--) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1225
				for (i = 0; i != width >> 2; i++) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1226
					byte b = ctab[src[i * 4]];
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1227
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1228
					if (b != 0) dst[i] = b;
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1229
				}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1230
				src += bp->width_org * 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1231
				dst += bp->pitch;
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1232
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1233
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1234
	} else if (bp->mode & 2) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1235
		if (bp->info & 1) {
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
  1236
			const byte *ctab = _color_remap_ptr;
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
  1237
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1238
			for (height >>= 2; height != 0; height--) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1239
				for (i = 0; i != width >> 2; i++)
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1240
					if (src[i * 4] != 0) dst[i] = ctab[dst[i]];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1241
				src += bp->width_org * 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1242
				dst += bp->pitch;
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1243
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1244
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1245
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1246
		if (bp->info & 1) {
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1247
			for (height >>= 2; height != 0; height--) {
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1248
				for (i = 0; i != width >> 2; i++)
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1249
					if (src[i * 4] != 0) dst[i] = src[i * 4];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1250
				src += bp->width_org * 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1251
				dst += bp->pitch;
1996
beb1489efefd (svn r2502) Small cleanup
tron
parents: 1991
diff changeset
  1252
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1253
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1254
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1255
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1256
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1257
typedef void (*BlitZoomFunc)(BlitterParams *bp);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1258
1357
a5acbb1f20fe (svn r1861) Constify Get(Non)Sprite()
tron
parents: 1351
diff changeset
  1259
static void GfxMainBlitter(const Sprite* sprite, int x, int y, int mode)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1260
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1261
	DrawPixelInfo *dpi = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1262
	int start_x, start_y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1263
	byte info;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1264
	BlitterParams bp;
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1265
	int zoom_mask = ~((1 << dpi->zoom) - 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1266
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1267
	static const BlitZoomFunc zf_tile[3] =
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1268
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1269
		GfxBlitTileZoomIn,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1270
		GfxBlitTileZoomMedium,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1271
		GfxBlitTileZoomOut
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1272
	};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1273
	static const BlitZoomFunc zf_uncomp[3] =
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1274
	{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1275
		GfxBlitZoomInUncomp,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1276
		GfxBlitZoomMediumUncomp,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1277
		GfxBlitZoomOutUncomp
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1278
	};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1279
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1280
	/* decode sprite header */
1351
3e7aa0d35f8f (svn r1855) Handle endianness of sprite headers when loading a sprite, not everytime when accessing it
tron
parents: 1350
diff changeset
  1281
	x += sprite->x_offs;
3e7aa0d35f8f (svn r1855) Handle endianness of sprite headers when loading a sprite, not everytime when accessing it
tron
parents: 1350
diff changeset
  1282
	y += sprite->y_offs;
3e7aa0d35f8f (svn r1855) Handle endianness of sprite headers when loading a sprite, not everytime when accessing it
tron
parents: 1350
diff changeset
  1283
	bp.width_org = bp.width = sprite->width;
1348
1d123409026e (svn r1852) Start cleaning up sprite handling:
tron
parents: 1336
diff changeset
  1284
	bp.height_org = bp.height = sprite->height;
1d123409026e (svn r1852) Start cleaning up sprite handling:
tron
parents: 1336
diff changeset
  1285
	info = sprite->info;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1286
	bp.info = info;
1348
1d123409026e (svn r1852) Start cleaning up sprite handling:
tron
parents: 1336
diff changeset
  1287
	bp.sprite_org = bp.sprite = sprite->data;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1288
	bp.dst = dpi->dst_ptr;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1289
	bp.mode = mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1290
	bp.pitch = dpi->pitch;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1291
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1292
	assert(bp.height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1293
	assert(bp.width > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1294
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1295
	if (info & 8) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1296
		/* tile blit */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1297
		start_y = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1298
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1299
		if (dpi->zoom > 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1300
			start_y += bp.height & ~zoom_mask;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
  1301
			bp.height &= zoom_mask;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1302
			if (bp.height == 0) return;
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1303
			y &= zoom_mask;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1304
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1305
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1306
		if ( (y -= dpi->top) < 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1307
			bp.height += y;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1308
			if (bp.height <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1309
			start_y -= y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1310
			y = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1311
		} else {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1312
			bp.dst += bp.pitch * (y >> dpi->zoom);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1313
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1314
		bp.start_y = start_y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1315
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1316
		if ( (y = y + bp.height - dpi->height) > 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1317
			bp.height -= y;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1318
			if (bp.height <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1319
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1320
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1321
		start_x = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1322
		x &= zoom_mask;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1323
		if ( (x -= dpi->left) < 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1324
			bp.width += x;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1325
			if (bp.width <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1326
			start_x -= x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1327
			x = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1328
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1329
		bp.start_x = start_x;
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1330
		bp.dst += x >> dpi->zoom;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1331
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1332
		if ( (x = x + bp.width - dpi->width) > 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1333
			bp.width -= x;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1334
			if (bp.width <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1335
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1336
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1337
		zf_tile[dpi->zoom](&bp);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1338
	} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1339
		bp.sprite += bp.width * (bp.height & ~zoom_mask);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1340
		bp.height &= zoom_mask;
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1341
		if (bp.height == 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1342
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1343
		y &= zoom_mask;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1344
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1345
		if ( (y -= dpi->top) < 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1346
			bp.height += y;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1347
			if (bp.height <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1348
			bp.sprite -= bp.width * y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1349
			y = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1350
		} else {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1351
			bp.dst += bp.pitch * (y >> dpi->zoom);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1352
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1353
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1354
		if ( (y = y + bp.height - dpi->height) > 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1355
			bp.height -= y;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1356
			if (bp.height <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1357
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1358
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1359
		start_x = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1360
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1361
		x &= zoom_mask;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1362
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1363
		if ( (x -= dpi->left) < 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1364
			bp.width += x;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1365
			if (bp.width <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1366
			start_x -= x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1367
			bp.sprite -= x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1368
			x = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1369
		}
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1370
		bp.dst += x >> dpi->zoom;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1371
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1372
		if ( (x = x + bp.width - dpi->width) > 0) {
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1373
			bp.width -= x;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1374
			if (bp.width <= 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1375
			start_x += x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1376
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1377
		bp.start_x = start_x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1378
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1379
		zf_uncomp[dpi->zoom](&bp);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1380
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1381
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1382
798
6b5518bf858f (svn r1268) -Fix: some warnings in gfx.c fixed
darkvater
parents: 657
diff changeset
  1383
#if 0
410
8de2aaf20800 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 375
diff changeset
  1384
static void GfxScalePalette(int pal, byte scaling)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1385
{
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1386
	const Colour* src;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1387
	uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1388
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1389
	GfxInitPalettes();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1390
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1391
	src = GET_PALETTE(pal);
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1392
	for (i = 0; i < lengthof(_cur_palette); i++) {
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1393
		_cur_palette[i].r = src[i].r * scaling >> 8;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1394
		_cur_palette[i].g = src[i].g * scaling >> 8;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1395
		_cur_palette[i].b = src[i].b * scaling >> 8;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1396
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1397
}
798
6b5518bf858f (svn r1268) -Fix: some warnings in gfx.c fixed
darkvater
parents: 657
diff changeset
  1398
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1399
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1400
void DoPaletteAnimations(void);
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1401
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1402
void GfxInitPalettes(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1403
{
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1404
	memcpy(_cur_palette, _palettes[_use_dos_palette ? 1 : 0], sizeof(_cur_palette));
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1405
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1406
	_pal_first_dirty = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1407
	_pal_last_dirty = 255;
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1408
	DoPaletteAnimations();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1409
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1410
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1411
#define EXTR(p, q) (((uint16)(_timer_counter * (p)) * (q)) >> 16)
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1412
#define EXTR2(p, q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1413
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1414
void DoPaletteAnimations(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1415
{
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1416
	const Colour* s;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1417
	Colour* d;
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1418
	/* Amount of colors to be rotated.
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1419
	 * A few more for the DOS palette, because the water colors are
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1420
	 * 245-254 for DOS and 217-226 for Windows.  */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1421
	const ExtraPaletteValues *ev = &_extra_palette_values;
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1422
	int c = _use_dos_palette ? 38 : 28;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1423
	Colour old_val[38]; // max(38, 28)
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1424
	uint i;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1425
	uint j;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1426
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1427
	d = &_cur_palette[217];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1428
	memcpy(old_val, d, c * sizeof(*old_val));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1429
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1430
	// Dark blue water
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1431
	s = (_opt.landscape == LT_CANDY) ? ev->ac : ev->a;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1432
	j = EXTR(320, 5);
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1433
	for (i = 0; i != 5; i++) {
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1434
		*d++ = s[j];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1435
		j++;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1436
		if (j == 5) j = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1437
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1438
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1439
	// Glittery water
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1440
	s = (_opt.landscape == LT_CANDY) ? ev->bc : ev->b;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1441
	j = EXTR(128, 15);
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1442
	for (i = 0; i != 5; i++) {
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1443
		*d++ = s[j];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1444
		j += 3;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1445
		if (j >= 15) j -= 15;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1446
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1447
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1448
	s = ev->e;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1449
	j = EXTR2(512, 5);
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1450
	for (i = 0; i != 5; i++) {
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1451
		*d++ = s[j];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1452
		j++;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1453
		if (j == 5) j = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1454
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1455
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1456
	// Oil refinery fire animation
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1457
	s = ev->oil_ref;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1458
	j = EXTR2(512, 7);
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1459
	for (i = 0; i != 7; i++) {
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1460
		*d++ = s[j];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1461
		j++;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1462
		if (j == 7) j = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1463
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1464
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1465
	// Radio tower blinking
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1466
	{
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1467
		byte i = (_timer_counter >> 1) & 0x7F;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1468
		byte v;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1469
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1470
		(v = 255, i < 0x3f) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1471
		(v = 128, i < 0x4A || i >= 0x75) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1472
		(v = 20);
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1473
		d->r = v;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1474
		d->g = 0;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1475
		d->b = 0;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1476
		d++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1477
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1478
		i ^= 0x40;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1479
		(v = 255, i < 0x3f) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1480
		(v = 128, i < 0x4A || i >= 0x75) ||
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1481
		(v = 20);
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1482
		d->r = v;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1483
		d->g = 0;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1484
		d->b = 0;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1485
		d++;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1486
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1487
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1488
	// Handle lighthouse and stadium animation
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1489
	s = ev->lighthouse;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1490
	j = EXTR(256, 4);
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1491
	for (i = 0; i != 4; i++) {
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1492
		*d++ = s[j];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1493
		j++;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1494
		if (j == 4) j = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1495
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1496
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1497
	// Animate water for old DOS graphics
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1498
	if (_use_dos_palette) {
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1499
		// Dark blue water DOS
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1500
		s = (_opt.landscape == LT_CANDY) ? ev->ac : ev->a;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1501
		j = EXTR(320, 5);
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1502
		for (i = 0; i != 5; i++) {
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1503
			*d++ = s[j];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1504
			j++;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1505
			if (j == 5) j = 0;
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1506
		}
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 798
diff changeset
  1507
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1508
		// Glittery water DOS
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1509
		s = (_opt.landscape == LT_CANDY) ? ev->bc : ev->b;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1510
		j = EXTR(128, 15);
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1511
		for (i = 0; i != 5; i++) {
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1512
			*d++ = s[j];
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1513
			j += 3;
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1514
			if (j >= 15) j -= 15;
614
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1515
		}
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1516
	}
e016770cb781 (svn r1038) Feature: OpenTTD runs with the grf files of the DOS version
dominik
parents: 543
diff changeset
  1517
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1518
	if (memcmp(old_val, &_cur_palette[217], c * sizeof(*old_val)) != 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1519
		if (_pal_first_dirty > 217) _pal_first_dirty = 217;
1991
f3d5e35731a2 (svn r2497) Use a struct array for palette entries instead of a flat byte array
tron
parents: 1914
diff changeset
  1520
		if (_pal_last_dirty < 217 + c) _pal_last_dirty = 217 + c;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1521
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1522
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1523
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1524
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1525
void LoadStringWidthTable(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1526
{
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1527
	byte *b = _stringwidth_table;
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1528
	uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1529
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1530
	// 2 equals space.
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1531
	for (i = 2; i != 226; i++) {
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1532
		*b++ = (i < 93 || i >= 129 || i == 98) ? GetSprite(i)->width : 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1533
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1534
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1535
	for (i = 226; i != 450; i++) {
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1536
		*b++ = (i < 317 || i >= 353) ? GetSprite(i)->width + 1 : 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1537
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1538
2005
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1539
	for (i = 450; i != 674; i++) {
8331cf472aea (svn r2513) Small cleanup
tron
parents: 2004
diff changeset
  1540
		*b++ = (i < 541 || i >= 577) ? GetSprite(i)->width + 1 : 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1541
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1542
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1543
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1544
void ScreenSizeChanged(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1545
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1546
	// check the dirty rect
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1547
	if (_invalid_rect.right >= _screen.width) _invalid_rect.right = _screen.width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1548
	if (_invalid_rect.bottom >= _screen.height) _invalid_rect.bottom = _screen.height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1549
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1550
	// screen size changed and the old bitmap is invalid now, so we don't want to undraw it
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1551
	_cursor.visible = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1552
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1553
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1554
void UndrawMouseCursor(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1555
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1556
	if (_cursor.visible) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1557
		_cursor.visible = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1558
		memcpy_pitch(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1559
			_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1560
			_cursor_backup,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1561
			_cursor.draw_size.x, _cursor.draw_size.y, _cursor.draw_size.x, _screen.pitch);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
  1562
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1563
		_video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1564
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1565
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1566
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1567
void DrawMouseCursor(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1568
{
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1569
	int x;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1570
	int y;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1571
	int w;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1572
	int h;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1573
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1574
	// Don't draw the mouse cursor if it's already drawn
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1575
	if (_cursor.visible) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1576
		if (!_cursor.dirty) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1577
		UndrawMouseCursor();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1578
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1579
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1580
	w = _cursor.size.x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1581
	x = _cursor.pos.x + _cursor.offs.x;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1582
	if (x < 0) {
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1583
		w += x;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1584
		x = 0;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1585
	}
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1586
	if (w > _screen.width - x) w = _screen.width - x;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1587
	if (w <= 0) return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1588
	_cursor.draw_pos.x = x;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1589
	_cursor.draw_size.x = w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1590
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1591
	h = _cursor.size.y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1592
	y = _cursor.pos.y + _cursor.offs.y;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1593
	if (y < 0) {
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1594
		h += y;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1595
		y = 0;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1596
	}
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1597
	if (h > _screen.height - y) h = _screen.height - y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1598
	if (h <= 0) return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1599
	_cursor.draw_pos.y = y;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1600
	_cursor.draw_size.y = h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1601
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1602
	assert(w * h < (int)sizeof(_cursor_backup));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1603
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1604
	// Make backup of stuff below cursor
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1605
	memcpy_pitch(
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1606
		_cursor_backup,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1607
		_screen.dst_ptr + _cursor.draw_pos.x + _cursor.draw_pos.y * _screen.pitch,
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 298
diff changeset
  1608
		_cursor.draw_size.x, _cursor.draw_size.y, _screen.pitch, _cursor.draw_size.x);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1609
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1610
	// Draw cursor on screen
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1611
	_cur_dpi = &_screen;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1612
	DrawSprite(_cursor.sprite, _cursor.pos.x, _cursor.pos.y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1613
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1614
	_video_driver->make_dirty(_cursor.draw_pos.x, _cursor.draw_pos.y, _cursor.draw_size.x, _cursor.draw_size.y);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1615
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1616
	_cursor.visible = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1617
	_cursor.dirty = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1618
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1619
798
6b5518bf858f (svn r1268) -Fix: some warnings in gfx.c fixed
darkvater
parents: 657
diff changeset
  1620
#if defined(_DEBUG)
410
8de2aaf20800 (svn r607) -Patch: [ 985102 ] static cleanup
tron
parents: 375
diff changeset
  1621
static void DbgScreenRect(int left, int top, int right, int bottom)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1622
{
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1623
	DrawPixelInfo dp;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1624
	DrawPixelInfo* old;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1625
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1626
	old = _cur_dpi;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1627
	_cur_dpi = &dp;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1628
	dp = _screen;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1629
	GfxFillRect(left, top, right - 1, bottom - 1, rand() & 255);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1630
	_cur_dpi = old;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1631
}
798
6b5518bf858f (svn r1268) -Fix: some warnings in gfx.c fixed
darkvater
parents: 657
diff changeset
  1632
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1633
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1634
extern bool _dbg_screen_rect;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1635
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1636
void RedrawScreenRect(int left, int top, int right, int bottom)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1637
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1638
	assert(right <= _screen.width && bottom <= _screen.height);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1639
	if (_cursor.visible) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1640
		if (right > _cursor.draw_pos.x &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1641
				left < _cursor.draw_pos.x + _cursor.draw_size.x &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1642
				bottom > _cursor.draw_pos.y &&
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1643
				top < _cursor.draw_pos.y + _cursor.draw_size.y) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1644
			UndrawMouseCursor();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1645
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1646
	}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1647
	UndrawTextMessage();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1648
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1649
#if defined(_DEBUG)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1650
	if (_dbg_screen_rect)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1651
		DbgScreenRect(left, top, right, bottom);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1652
	else
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1653
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1654
		DrawOverlappedWindowForAll(left, top, right, bottom);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1655
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1656
	_video_driver->make_dirty(left, top, right - left, bottom - top);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1657
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1658
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1659
void DrawDirtyBlocks(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1660
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1661
	byte *b = _dirty_blocks;
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 298
diff changeset
  1662
	const int w = (_screen.width + 63) & ~63;
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 298
diff changeset
  1663
	const int h = (_screen.height + 7) & ~7;
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1664
	int x;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1665
	int y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1666
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1667
	y = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1668
	do {
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1669
		x = 0;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1670
		do {
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1671
			if (*b != 0) {
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1672
				int left;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1673
				int top;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1674
				int right = x + 64;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1675
				int bottom = y;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1676
				byte *p = b;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1677
				int h2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1678
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1679
				// First try coalescing downwards
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1680
				do {
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1681
					*p = 0;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1682
					p += DIRTY_BYTES_PER_LINE;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1683
					bottom += 8;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1684
				} while (bottom != h && *p != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1685
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1686
				// Try coalescing to the right too.
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1687
				h2 = (bottom - y) >> 3;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1688
				assert(h2 > 0);
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1689
				p = b;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1690
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1691
				while (right != w) {
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1692
					byte *p2 = ++p;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1693
					int h = h2;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1694
					// Check if a full line of dirty flags is set.
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1695
					do {
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1696
						if (!*p2) goto no_more_coalesc;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1697
						p2 += DIRTY_BYTES_PER_LINE;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1698
					} while (--h != 0);
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1699
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1700
					// Wohoo, can combine it one step to the right!
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1701
					// Do that, and clear the bits.
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1702
					right += 64;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1703
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1704
					h = h2;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1705
					p2 = p;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1706
					do {
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1707
						*p2 = 0;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1708
						p2 += DIRTY_BYTES_PER_LINE;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1709
					} while (--h != 0);
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1710
				}
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1711
				no_more_coalesc:
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1712
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1713
				left = x;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1714
				top = y;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1715
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1716
				if (left   < _invalid_rect.left  ) left   = _invalid_rect.left;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1717
				if (top    < _invalid_rect.top   ) top    = _invalid_rect.top;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1718
				if (right  > _invalid_rect.right ) right  = _invalid_rect.right;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1719
				if (bottom > _invalid_rect.bottom) bottom = _invalid_rect.bottom;
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1720
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1721
				if (left < right && top < bottom) {
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1722
					RedrawScreenRect(left, top, right, bottom);
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1723
				}
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1724
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1725
			}
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1726
		} while (b++, (x += 64) != w);
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1727
	} while (b += -(w >> 6) + DIRTY_BYTES_PER_LINE, (y += 8) != h);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1728
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1729
	_invalid_rect.left = w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1730
	_invalid_rect.top = h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1731
	_invalid_rect.right = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1732
	_invalid_rect.bottom = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1733
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1734
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1735
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1736
void SetDirtyBlocks(int left, int top, int right, int bottom)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1737
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1738
	byte *b;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1739
	int width;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1740
	int height;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1741
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1742
	if (left < 0) left = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1743
	if (top < 0) top = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1744
	if (right > _screen.width) right = _screen.width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1745
	if (bottom > _screen.height) bottom = _screen.height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1746
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1747
	if (left >= right || top >= bottom) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1748
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1749
	if (left   < _invalid_rect.left  ) _invalid_rect.left   = left;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1750
	if (top    < _invalid_rect.top   ) _invalid_rect.top    = top;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1751
	if (right  > _invalid_rect.right ) _invalid_rect.right  = right;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1752
	if (bottom > _invalid_rect.bottom) _invalid_rect.bottom = bottom;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1753
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1754
	left >>= 6;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1755
	top  >>= 3;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1756
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1757
	b = _dirty_blocks + top * DIRTY_BYTES_PER_LINE + left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1758
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1759
	width  = ((right  - 1) >> 6) - left + 1;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1760
	height = ((bottom - 1) >> 3) - top  + 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1761
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1762
	assert(width > 0 && height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1763
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1764
	do {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1765
		int i = width;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1766
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1767
		do b[--i] = 0xFF; while (i);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1768
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1769
		b += DIRTY_BYTES_PER_LINE;
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1770
	} while (--height != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1771
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1772
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1773
void MarkWholeScreenDirty(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1774
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1775
	SetDirtyBlocks(0, 0, _screen.width, _screen.height);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1776
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1777
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1778
bool FillDrawPixelInfo(DrawPixelInfo *n, DrawPixelInfo *o, int left, int top, int width, int height)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1779
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1780
	int t;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1781
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1782
	if (o == NULL) o = _cur_dpi;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1783
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1784
	n->zoom = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1785
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1786
	assert(width > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1787
	assert(height > 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1788
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1789
	n->left = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1790
	if ((left -= o->left) < 0) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1791
		width += left;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1792
		if (width < 0) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1793
		n->left = -left;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1794
		left = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1795
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1796
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1797
	if ((t=width + left - o->width) > 0) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1798
		width -= t;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1799
		if (width < 0) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1800
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1801
	n->width = width;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1802
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1803
	n->top = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1804
	if ((top -= o->top) < 0) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1805
		height += top;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1806
		if (height < 0) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1807
		n->top = -top;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1808
		top = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1809
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1810
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1811
	n->dst_ptr = o->dst_ptr + left + top * (n->pitch = o->pitch);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1812
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1813
	if ((t=height + top - o->height) > 0) {
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1814
		height -= t;
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1815
		if (height < 0) return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1816
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1817
	n->height = height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1818
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1819
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1820
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1821
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1822
static void SetCursorSprite(CursorID cursor)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1823
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1824
	CursorVars *cv = &_cursor;
1348
1d123409026e (svn r1852) Start cleaning up sprite handling:
tron
parents: 1336
diff changeset
  1825
	const Sprite *p;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1826
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1827
	if (cv->sprite == cursor) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1828
2025
b0b897359fdf (svn r2534) Small cleanup
tron
parents: 2014
diff changeset
  1829
	p = GetSprite(cursor & 0x3FFF);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1830
	cv->sprite = cursor;
1348
1d123409026e (svn r1852) Start cleaning up sprite handling:
tron
parents: 1336
diff changeset
  1831
	cv->size.y = p->height;
1351
3e7aa0d35f8f (svn r1855) Handle endianness of sprite headers when loading a sprite, not everytime when accessing it
tron
parents: 1350
diff changeset
  1832
	cv->size.x = p->width;
3e7aa0d35f8f (svn r1855) Handle endianness of sprite headers when loading a sprite, not everytime when accessing it
tron
parents: 1350
diff changeset
  1833
	cv->offs.x = p->x_offs;
3e7aa0d35f8f (svn r1855) Handle endianness of sprite headers when loading a sprite, not everytime when accessing it
tron
parents: 1350
diff changeset
  1834
	cv->offs.y = p->y_offs;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1835
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1836
	cv->dirty = true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1837
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1838
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1839
static void SwitchAnimatedCursor(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1840
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1841
	CursorVars *cv = &_cursor;
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1842
	const CursorID *cur = cv->animate_cur;
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1843
	CursorID sprite;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1844
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1845
	// ANIM_CURSOR_END is 0xFFFF in table/animcursors.h
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1846
	if (cur == NULL || *cur == 0xFFFF) cur = cv->animate_list;
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1847
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1848
	sprite = cur[0];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1849
	cv->animate_timeout = cur[1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1850
	cv->animate_cur = cur + 2;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1851
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1852
	SetCursorSprite(sprite);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1853
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1854
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1855
void CursorTick(void)
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1056
diff changeset
  1856
{
2010
fc4e04467881 (svn r2518) Small cleanup
tron
parents: 2005
diff changeset
  1857
	if (_cursor.animate_timeout != 0 && --_cursor.animate_timeout == 0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1858
		SwitchAnimatedCursor();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1859
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1860
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1861
void SetMouseCursor(CursorID cursor)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1862
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1863
	// Turn off animation
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1864
	_cursor.animate_timeout = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1865
	// Set cursor
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1866
	SetCursorSprite(cursor);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1867
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1868
1914
5ede46fd496f (svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents: 1891
diff changeset
  1869
void SetAnimatedMouseCursor(const CursorID *table)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1870
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1871
	_cursor.animate_list = table;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1872
	_cursor.animate_cur = NULL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1873
	SwitchAnimatedCursor();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1874
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1875
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1876
bool ChangeResInGame(int w, int h)
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
  1877
{
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1878
	if ((_screen.width != w || _screen.height != h) && !_video_driver->change_resolution(w, h))
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 126
diff changeset
  1879
		return false;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1880
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1881
	_cur_resolution[0] = w;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1882
	_cur_resolution[1] = h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1883
	return true;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1884
}
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
  1885
1829
0b6de3b4458a (svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents: 1806
diff changeset
  1886
void ToggleFullScreen(bool fs) {_video_driver->toggle_fullscreen(fs);}
0b6de3b4458a (svn r2334) - Fix (regression): moved togglefullscreen into the video-driver, now windows works, dedicated works and sdl works. Also reverted the change to the makefile.
Darkvater
parents: 1806
diff changeset
  1887
1806
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1888
static int CDECL compare_res(const void *pa, const void *pb)
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
  1889
{
1806
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1890
	int x = ((const uint16*)pa)[0] - ((const uint16*)pb)[0];
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1891
	if (x != 0) return x;
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1892
	return ((const uint16*)pa)[1] - ((const uint16*)pb)[1];
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1893
}
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1894
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1895
void SortResolutions(int count)
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1896
{
75dc9c737892 (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1390
diff changeset
  1897
	qsort(_resolutions, count, sizeof(_resolutions[0]), compare_res);
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
  1898
}
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1899
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1900
uint16 GetDrawStringPlayerColor(byte player)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1901
{
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1902
	// Get the color for DrawString-subroutines which matches the color
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1903
	//  of the player
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1904
	if (player == OWNER_SPECTATOR || player == OWNER_SPECTATOR - 1)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1905
			return 1;
657
40a9032b454b (svn r1091) Fix: Finally station names use 100% the correct color in transparent mode
dominik
parents: 619
diff changeset
  1906
	return (_color_list[_player_colors[player]].window_color_1b) | IS_PALETTE_COLOR;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 510
diff changeset
  1907
}