author | rubidium |
Sun, 06 Apr 2008 12:26:40 +0000 | |
branch | noai |
changeset 9867 | b7d9ffe24f81 |
parent 9723 | eee46cb39750 |
child 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
9627 | 1 |
/* $Id$ */ |
2 |
||
3 |
/** @file 8bpp_debug.cpp */ |
|
4 |
||
9626 | 5 |
#include "../stdafx.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9628
diff
changeset
|
6 |
#include "../zoom_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9628
diff
changeset
|
7 |
#include "../core/random_func.hpp" |
9626 | 8 |
#include "8bpp_debug.hpp" |
9 |
||
10 |
static FBlitter_8bppDebug iFBlitter_8bppDebug; |
|
11 |
||
12 |
void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) |
|
13 |
{ |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
14 |
const uint8 *src, *src_line; |
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
15 |
uint8 *dst, *dst_line; |
9626 | 16 |
|
17 |
/* Find where to start reading in the source sprite */ |
|
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9627
diff
changeset
|
18 |
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
|
19 |
dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; |
9626 | 20 |
|
21 |
for (int y = 0; y < bp->height; y++) { |
|
22 |
dst = dst_line; |
|
23 |
dst_line += bp->pitch; |
|
24 |
||
25 |
src = src_line; |
|
26 |
src_line += bp->sprite_width * ScaleByZoom(1, zoom); |
|
27 |
||
28 |
for (int x = 0; x < bp->width; x++) { |
|
29 |
if (*src != 0) *dst = *src; |
|
30 |
dst++; |
|
31 |
src += ScaleByZoom(1, zoom); |
|
32 |
} |
|
33 |
assert(src <= src_line); |
|
34 |
} |
|
35 |
} |
|
36 |
||
37 |
Sprite *Blitter_8bppDebug::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) |
|
38 |
{ |
|
39 |
Sprite *dest_sprite; |
|
40 |
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width); |
|
41 |
||
42 |
dest_sprite->height = sprite->height; |
|
43 |
dest_sprite->width = sprite->width; |
|
44 |
dest_sprite->x_offs = sprite->x_offs; |
|
45 |
dest_sprite->y_offs = sprite->y_offs; |
|
46 |
||
47 |
/* Write a random color as sprite; this makes debugging really easy */ |
|
48 |
uint color = InteractiveRandom() % 150 + 2; |
|
49 |
for (int i = 0; i < sprite->height * sprite->width; i++) { |
|
50 |
dest_sprite->data[i] = (sprite->data[i].m == 0) ? 0 : color; |
|
51 |
} |
|
52 |
||
53 |
return dest_sprite; |
|
54 |
} |