author | rubidium |
Wed, 17 Dec 2008 23:08:11 +0000 | |
changeset 10434 | 3659467c844c |
parent 9111 | 48ce04029fe4 |
permissions | -rw-r--r-- |
6872
0a4a20ef71c3
(svn r10113) -Fix (r10092): Missing svn properties and some Id/@file comments
peter1138
parents:
6861
diff
changeset
|
1 |
/* $Id$ */ |
0a4a20ef71c3
(svn r10113) -Fix (r10092): Missing svn properties and some Id/@file comments
peter1138
parents:
6861
diff
changeset
|
2 |
|
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8123
diff
changeset
|
3 |
/** @file 8bpp_simple.cpp Implementation of the simple 8 bpp blitter. */ |
6872
0a4a20ef71c3
(svn r10113) -Fix (r10092): Missing svn properties and some Id/@file comments
peter1138
parents:
6861
diff
changeset
|
4 |
|
6861
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
5 |
#include "../stdafx.h" |
8123
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
6937
diff
changeset
|
6 |
#include "../zoom_func.h" |
6861
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
7 |
#include "8bpp_simple.hpp" |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
8 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
9 |
static FBlitter_8bppSimple iFBlitter_8bppSimple; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
10 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
11 |
void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
12 |
{ |
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6872
diff
changeset
|
13 |
const uint8 *src, *src_line; |
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6872
diff
changeset
|
14 |
uint8 *dst, *dst_line; |
6861
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
15 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
16 |
/* Find where to start reading in the source sprite */ |
6878
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6872
diff
changeset
|
17 |
src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); |
5cefd3ac59c7
(svn r10121) -Codechange: split renderer from rest of code; no longer any code directly accesses the video-buffer
truelight
parents:
6872
diff
changeset
|
18 |
dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; |
6861
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
19 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
20 |
for (int y = 0; y < bp->height; y++) { |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
21 |
dst = dst_line; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
22 |
dst_line += bp->pitch; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
23 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
24 |
src = src_line; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
25 |
src_line += bp->sprite_width * ScaleByZoom(1, zoom); |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
26 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
27 |
for (int x = 0; x < bp->width; x++) { |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
28 |
uint color = 0; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
29 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
30 |
switch (mode) { |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
31 |
case BM_COLOUR_REMAP: |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
32 |
color = bp->remap[*src]; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
33 |
break; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
34 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
35 |
case BM_TRANSPARENT: |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
36 |
if (*src != 0) color = bp->remap[*dst]; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
37 |
break; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
38 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
39 |
default: |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
40 |
color = *src; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
41 |
break; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
42 |
} |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
43 |
if (color != 0) *dst = color; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
44 |
dst++; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
45 |
src += ScaleByZoom(1, zoom); |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
46 |
} |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
47 |
} |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
48 |
} |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
49 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
50 |
Sprite *Blitter_8bppSimple::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
51 |
{ |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
52 |
Sprite *dest_sprite; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
53 |
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
54 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
55 |
dest_sprite->height = sprite->height; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
56 |
dest_sprite->width = sprite->width; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
57 |
dest_sprite->x_offs = sprite->x_offs; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
58 |
dest_sprite->y_offs = sprite->y_offs; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
59 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
60 |
/* Copy over only the 'remap' channel, as that is what we care about in 8bpp */ |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
61 |
for (int i = 0; i < sprite->height * sprite->width; i++) { |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
62 |
dest_sprite->data[i] = sprite->data[i].m; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
63 |
} |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
64 |
|
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
65 |
return dest_sprite; |
bb680703bab2
(svn r10101) -Codechange: the class is named 8bppSimple, so name the files like that too
truelight
parents:
diff
changeset
|
66 |
} |