8bpp_debug.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "../stdafx.h"
00013 #include "../zoom_func.h"
00014 #include "../core/random_func.hpp"
00015 #include "8bpp_debug.hpp"
00016
00017 static FBlitter_8bppDebug iFBlitter_8bppDebug;
00018
00019 void Blitter_8bppDebug::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
00020 {
00021 const uint8 *src, *src_line;
00022 uint8 *dst, *dst_line;
00023
00024
00025 src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
00026 dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left;
00027
00028 for (int y = 0; y < bp->height; y++) {
00029 dst = dst_line;
00030 dst_line += bp->pitch;
00031
00032 src = src_line;
00033 src_line += bp->sprite_width * ScaleByZoom(1, zoom);
00034
00035 for (int x = 0; x < bp->width; x++) {
00036 if (*src != 0) *dst = *src;
00037 dst++;
00038 src += ScaleByZoom(1, zoom);
00039 }
00040 assert(src <= src_line);
00041 }
00042 }
00043
00044 Sprite *Blitter_8bppDebug::Encode(SpriteLoader::Sprite *sprite, Blitter::AllocatorProc *allocator)
00045 {
00046 Sprite *dest_sprite;
00047 dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);
00048
00049 dest_sprite->height = sprite->height;
00050 dest_sprite->width = sprite->width;
00051 dest_sprite->x_offs = sprite->x_offs;
00052 dest_sprite->y_offs = sprite->y_offs;
00053
00054
00055 uint colour = InteractiveRandom() % 150 + 2;
00056 for (int i = 0; i < sprite->height * sprite->width; i++) {
00057 dest_sprite->data[i] = (sprite->data[i].m == 0) ? 0 : colour;
00058 }
00059
00060 return dest_sprite;
00061 }