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