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