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