Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00012 #include "../stdafx.h"
00013 #include "../gfx_func.h"
00014 #include "8bpp_base.hpp"
00015
00016 void Blitter_8bppBase::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
00017 {
00018 const uint8 *ctab = GetNonSprite(pal, ST_RECOLOUR) + 1;
00019
00020 do {
00021 for (int i = 0; i != width; i++) *((uint8 *)dst + i) = ctab[((uint8 *)dst)[i]];
00022 dst = (uint8 *)dst + _screen.pitch;
00023 } while (--height);
00024 }
00025
00026 void *Blitter_8bppBase::MoveTo(void *video, int x, int y)
00027 {
00028 return (uint8 *)video + x + y * _screen.pitch;
00029 }
00030
00031 void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8 colour)
00032 {
00033 *((uint8 *)video + x + y * _screen.pitch) = colour;
00034 }
00035
00036 void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8 colour)
00037 {
00038 do {
00039 memset(video, colour, width);
00040 video = (uint8 *)video + _screen.pitch;
00041 } while (--height);
00042 }
00043
00044 void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height)
00045 {
00046 uint8 *dst = (uint8 *)video;
00047 const uint8 *usrc = (const uint8 *)src;
00048
00049 for (; height > 0; height--) {
00050 memcpy(dst, usrc, width * sizeof(uint8));
00051 usrc += width;
00052 dst += _screen.pitch;
00053 }
00054 }
00055
00056 void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height)
00057 {
00058 uint8 *udst = (uint8 *)dst;
00059 const uint8 *src = (const uint8 *)video;
00060
00061 for (; height > 0; height--) {
00062 memcpy(udst, src, width * sizeof(uint8));
00063 src += _screen.pitch;
00064 udst += width;
00065 }
00066 }
00067
00068 void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch)
00069 {
00070 uint8 *udst = (uint8 *)dst;
00071 const uint8 *src = (const uint8 *)video;
00072
00073 for (; height > 0; height--) {
00074 memcpy(udst, src, width * sizeof(uint8));
00075 src += _screen.pitch;
00076 udst += dst_pitch;
00077 }
00078 }
00079
00080 void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
00081 {
00082 const uint8 *src;
00083 uint8 *dst;
00084
00085 if (scroll_y > 0) {
00086
00087 dst = (uint8 *)video + left + (top + height - 1) * _screen.pitch;
00088 src = dst - scroll_y * _screen.pitch;
00089
00090
00091 top += scroll_y;
00092 height -= scroll_y;
00093 assert(height > 0);
00094
00095
00096 if (scroll_x >= 0) {
00097 dst += scroll_x;
00098 left += scroll_x;
00099 width -= scroll_x;
00100 } else {
00101 src -= scroll_x;
00102 width += scroll_x;
00103 }
00104
00105 for (int h = height; h > 0; h--) {
00106 memcpy(dst, src, width * sizeof(uint8));
00107 src -= _screen.pitch;
00108 dst -= _screen.pitch;
00109 }
00110 } else {
00111
00112 dst = (uint8 *)video + left + top * _screen.pitch;
00113 src = dst - scroll_y * _screen.pitch;
00114
00115
00116 height += scroll_y;
00117 assert(height > 0);
00118
00119
00120 if (scroll_x >= 0) {
00121 dst += scroll_x;
00122 left += scroll_x;
00123 width -= scroll_x;
00124 } else {
00125 src -= scroll_x;
00126 width += scroll_x;
00127 }
00128
00129
00130
00131 for (int h = height; h > 0; h--) {
00132 memmove(dst, src, width * sizeof(uint8));
00133 src += _screen.pitch;
00134 dst += _screen.pitch;
00135 }
00136 }
00137 }
00138
00139 int Blitter_8bppBase::BufferSize(int width, int height)
00140 {
00141 return width * height;
00142 }
00143
00144 void Blitter_8bppBase::PaletteAnimate(uint start, uint count)
00145 {
00146
00147 }
00148
00149 Blitter::PaletteAnimation Blitter_8bppBase::UsePaletteAnimation()
00150 {
00151 return Blitter::PALETTE_ANIMATION_VIDEO_BACKEND;
00152 }