author | rubidium |
Sun, 25 May 2008 19:17:03 +0000 | |
changeset 9354 | 845e07db4549 |
parent 9111 | 48ce04029fe4 |
permissions | -rw-r--r-- |
6872
0a4a20ef71c3
(svn r10113) -Fix (r10092): Missing svn properties and some Id/@file comments
peter1138
parents:
6856
diff
changeset
|
1 |
/* $Id$ */ |
0a4a20ef71c3
(svn r10113) -Fix (r10092): Missing svn properties and some Id/@file comments
peter1138
parents:
6856
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:
8131
diff
changeset
|
3 |
/** @file 8bpp_debug.cpp Implementation of 8 bpp debug blitter. */ |
6872
0a4a20ef71c3
(svn r10113) -Fix (r10092): Missing svn properties and some Id/@file comments
peter1138
parents:
6856
diff
changeset
|
4 |
|
6852
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
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" |
8131
160939e24ed3
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8123
diff
changeset
|
7 |
#include "../core/random_func.hpp" |
6852
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
8 |
#include "8bpp_debug.hpp" |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
9 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
10 |
static FBlitter_8bppDebug iFBlitter_8bppDebug; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
11 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
12 |
void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
13 |
{ |
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
|
14 |
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
|
15 |
uint8 *dst, *dst_line; |
6852
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
16 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
17 |
/* 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
|
18 |
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
|
19 |
dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; |
6852
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
20 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
21 |
for (int y = 0; y < bp->height; y++) { |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
22 |
dst = dst_line; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
23 |
dst_line += bp->pitch; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
24 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
25 |
src = src_line; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
26 |
src_line += bp->sprite_width * ScaleByZoom(1, zoom); |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
27 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
28 |
for (int x = 0; x < bp->width; x++) { |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
29 |
if (*src != 0) *dst = *src; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
30 |
dst++; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
31 |
src += ScaleByZoom(1, zoom); |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
32 |
} |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
33 |
assert(src <= src_line); |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
34 |
} |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
35 |
} |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
36 |
|
6856
aa95d0fd29f1
(svn r10096) -Fix r10092: freetype bypassed the Blitter::Encode, making fonts look weird
truelight
parents:
6852
diff
changeset
|
37 |
Sprite *Blitter_8bppDebug::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) |
6852
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
38 |
{ |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
39 |
Sprite *dest_sprite; |
6856
aa95d0fd29f1
(svn r10096) -Fix r10092: freetype bypassed the Blitter::Encode, making fonts look weird
truelight
parents:
6852
diff
changeset
|
40 |
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width); |
6852
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
41 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
42 |
dest_sprite->height = sprite->height; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
43 |
dest_sprite->width = sprite->width; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
44 |
dest_sprite->x_offs = sprite->x_offs; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
45 |
dest_sprite->y_offs = sprite->y_offs; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
46 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
47 |
/* Write a random color as sprite; this makes debugging really easy */ |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
48 |
uint color = InteractiveRandom() % 150 + 2; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
49 |
for (int i = 0; i < sprite->height * sprite->width; i++) { |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
50 |
dest_sprite->data[i] = (sprite->data[i].m == 0) ? 0 : color; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
51 |
} |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
52 |
|
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
53 |
return dest_sprite; |
439563b70fd3
(svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code
truelight
parents:
diff
changeset
|
54 |
} |