2007-06-12 12:27:40 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file 8bpp_debug.cpp Implementation of 8 bpp debug blitter. */
|
2007-06-12 12:27:40 +00:00
|
|
|
|
2007-06-11 11:50:49 +00:00
|
|
|
#include "../stdafx.h"
|
2007-12-23 10:56:02 +00:00
|
|
|
#include "../zoom_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "../core/random_func.hpp"
|
2007-06-11 11:50:49 +00:00
|
|
|
#include "8bpp_debug.hpp"
|
|
|
|
|
|
|
|
static FBlitter_8bppDebug iFBlitter_8bppDebug;
|
|
|
|
|
|
|
|
void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
|
|
|
|
{
|
2007-06-12 20:24:12 +00:00
|
|
|
const uint8 *src, *src_line;
|
|
|
|
uint8 *dst, *dst_line;
|
2007-06-11 11:50:49 +00:00
|
|
|
|
|
|
|
/* Find where to start reading in the source sprite */
|
2007-06-12 20:24:12 +00:00
|
|
|
src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
|
|
|
|
dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left;
|
2007-06-11 11:50:49 +00:00
|
|
|
|
|
|
|
for (int y = 0; y < bp->height; y++) {
|
|
|
|
dst = dst_line;
|
|
|
|
dst_line += bp->pitch;
|
|
|
|
|
|
|
|
src = src_line;
|
|
|
|
src_line += bp->sprite_width * ScaleByZoom(1, zoom);
|
|
|
|
|
|
|
|
for (int x = 0; x < bp->width; x++) {
|
|
|
|
if (*src != 0) *dst = *src;
|
|
|
|
dst++;
|
|
|
|
src += ScaleByZoom(1, zoom);
|
|
|
|
}
|
|
|
|
assert(src <= src_line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-11 13:38:11 +00:00
|
|
|
Sprite *Blitter_8bppDebug::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator)
|
2007-06-11 11:50:49 +00:00
|
|
|
{
|
|
|
|
Sprite *dest_sprite;
|
2007-06-11 13:38:11 +00:00
|
|
|
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);
|
2007-06-11 11:50:49 +00:00
|
|
|
|
|
|
|
dest_sprite->height = sprite->height;
|
|
|
|
dest_sprite->width = sprite->width;
|
|
|
|
dest_sprite->x_offs = sprite->x_offs;
|
|
|
|
dest_sprite->y_offs = sprite->y_offs;
|
|
|
|
|
|
|
|
/* Write a random color as sprite; this makes debugging really easy */
|
|
|
|
uint color = InteractiveRandom() % 150 + 2;
|
|
|
|
for (int i = 0; i < sprite->height * sprite->width; i++) {
|
|
|
|
dest_sprite->data[i] = (sprite->data[i].m == 0) ? 0 : color;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dest_sprite;
|
|
|
|
}
|