From 6b101cc177a9e689dd193041b82661ab140b817c Mon Sep 17 00:00:00 2001 From: truelight Date: Mon, 11 Jun 2007 11:50:49 +0000 Subject: (svn r10092) -Codechange: code-seperated the spriteloader and blitter from the rest of the code -Add: make it possible to pick your own blitter (-b , -h for overview) -Add: added a new optimized 8bpp blitter (default, caches sprites of all zoom-levels) -Add: added a debug 8bpp blitter and a very slow normal 8bpp blitter --- src/blitter/8bpp_debug.cpp | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/blitter/8bpp_debug.cpp (limited to 'src/blitter/8bpp_debug.cpp') diff --git a/src/blitter/8bpp_debug.cpp b/src/blitter/8bpp_debug.cpp new file mode 100644 index 000000000..dea100c3f --- /dev/null +++ b/src/blitter/8bpp_debug.cpp @@ -0,0 +1,53 @@ +#include "../stdafx.h" +#include "../zoom.hpp" +#include "../gfx.h" +#include "../functions.h" +#include "8bpp_debug.hpp" + +static FBlitter_8bppDebug iFBlitter_8bppDebug; + +extern void* AllocSprite(size_t); + +void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) +{ + const byte *src, *src_line; + Pixel8 *dst, *dst_line; + + /* Find where to start reading in the source sprite */ + src_line = (const byte *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); + dst_line = (Pixel8 *)bp->dst + bp->top * bp->pitch + bp->left; + + 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); + } +} + +Sprite *Blitter_8bppDebug::Encode(SpriteLoader::Sprite *sprite) +{ + Sprite *dest_sprite; + dest_sprite = (Sprite *)AllocSprite(sizeof(*dest_sprite) + sprite->height * sprite->width); + + 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; +} -- cgit v1.2.3-70-g09d2