peter1138@6872: /* $Id$ */ peter1138@6872: peter1138@6872: /** @file 8bpp_debug.cpp */ peter1138@6872: truelight@6852: #include "../stdafx.h" truelight@6852: #include "../zoom.hpp" truelight@6852: #include "../gfx.h" truelight@6852: #include "../functions.h" truelight@6852: #include "8bpp_debug.hpp" truelight@6852: truelight@6852: static FBlitter_8bppDebug iFBlitter_8bppDebug; truelight@6852: truelight@6852: void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) truelight@6852: { truelight@6878: const uint8 *src, *src_line; truelight@6878: uint8 *dst, *dst_line; truelight@6852: truelight@6852: /* Find where to start reading in the source sprite */ truelight@6878: src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); truelight@6878: dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; truelight@6852: truelight@6852: for (int y = 0; y < bp->height; y++) { truelight@6852: dst = dst_line; truelight@6852: dst_line += bp->pitch; truelight@6852: truelight@6852: src = src_line; truelight@6852: src_line += bp->sprite_width * ScaleByZoom(1, zoom); truelight@6852: truelight@6852: for (int x = 0; x < bp->width; x++) { truelight@6852: if (*src != 0) *dst = *src; truelight@6852: dst++; truelight@6852: src += ScaleByZoom(1, zoom); truelight@6852: } truelight@6852: assert(src <= src_line); truelight@6852: } truelight@6852: } truelight@6852: truelight@6856: Sprite *Blitter_8bppDebug::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator) truelight@6852: { truelight@6852: Sprite *dest_sprite; truelight@6856: dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width); truelight@6852: truelight@6852: dest_sprite->height = sprite->height; truelight@6852: dest_sprite->width = sprite->width; truelight@6852: dest_sprite->x_offs = sprite->x_offs; truelight@6852: dest_sprite->y_offs = sprite->y_offs; truelight@6852: truelight@6852: /* Write a random color as sprite; this makes debugging really easy */ truelight@6852: uint color = InteractiveRandom() % 150 + 2; truelight@6852: for (int i = 0; i < sprite->height * sprite->width; i++) { truelight@6852: dest_sprite->data[i] = (sprite->data[i].m == 0) ? 0 : color; truelight@6852: } truelight@6852: truelight@6852: return dest_sprite; truelight@6852: }