author | rubidium |
Wed, 09 Jan 2008 18:11:12 +0000 | |
branch | noai |
changeset 9723 | eee46cb39750 |
parent 9628 | b5c2449616b5 |
child 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
9627 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file 8bpp_simple.cpp */ |
|
4 |
||
5 |
#include "../stdafx.h" |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9628
diff
changeset
|
6 |
#include "../zoom_func.h" |
9627 | 7 |
#include "8bpp_simple.hpp" |
8 |
||
9 |
static FBlitter_8bppSimple iFBlitter_8bppSimple; |
|
10 |
||
11 |
void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) |
|
12 |
{ |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
13 |
const uint8 *src, *src_line; |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
14 |
uint8 *dst, *dst_line; |
9627 | 15 |
|
16 |
/* Find where to start reading in the source sprite */ |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
17 |
src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
18 |
dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; |
9627 | 19 |
|
20 |
for (int y = 0; y < bp->height; y++) { |
|
21 |
dst = dst_line; |
|
22 |
dst_line += bp->pitch; |
|
23 |
||
24 |
src = src_line; |
|
25 |
src_line += bp->sprite_width * ScaleByZoom(1, zoom); |
|
26 |
||
27 |
for (int x = 0; x < bp->width; x++) { |
|
28 |
uint color = 0; |
|
29 |
||
30 |
switch (mode) { |
|
31 |
case BM_COLOUR_REMAP: |
|
32 |
color = bp->remap[*src]; |
|
33 |
break; |
|
34 |
||
35 |
case BM_TRANSPARENT: |
|
36 |
if (*src != 0) color = bp->remap[*dst]; |
|
37 |
break; |
|
38 |
||
39 |
default: |
|
40 |
color = *src; |
|
41 |
break; |
|
42 |
} |
|
43 |
if (color != 0) *dst = color; |
|
44 |
dst++; |
|
45 |
src += ScaleByZoom(1, zoom); |
|
46 |
} |
|
47 |
} |
|
48 |
} |
|
49 |
||
50 |
Sprite *Blitter_8bppSimple::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) |
|
51 |
{ |
|
52 |
Sprite *dest_sprite; |
|
53 |
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);; |
|
54 |
||
55 |
dest_sprite->height = sprite->height; |
|
56 |
dest_sprite->width = sprite->width; |
|
57 |
dest_sprite->x_offs = sprite->x_offs; |
|
58 |
dest_sprite->y_offs = sprite->y_offs; |
|
59 |
||
60 |
/* Copy over only the 'remap' channel, as that is what we care about in 8bpp */ |
|
61 |
for (int i = 0; i < sprite->height * sprite->width; i++) { |
|
62 |
dest_sprite->data[i] = sprite->data[i].m; |
|
63 |
} |
|
64 |
||
65 |
return dest_sprite; |
|
66 |
} |