|
1 #include "../stdafx.h" |
|
2 #include "../gfx.h" |
|
3 #include "32bpp_base.hpp" |
|
4 |
|
5 void *Blitter_32bppBase::MoveTo(const void *video, int x, int y) |
|
6 { |
|
7 return (uint32 *)video + x + y * _screen.pitch; |
|
8 } |
|
9 |
|
10 void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8 color) |
|
11 { |
|
12 *((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color); |
|
13 } |
|
14 |
|
15 void Blitter_32bppBase::SetPixelIfEmpty(void *video, int x, int y, uint8 color) |
|
16 { |
|
17 uint32 *dst = (uint32 *)video + x + y * _screen.pitch; |
|
18 if (*dst == 0) *dst = LookupColourInPalette(color); |
|
19 } |
|
20 |
|
21 void Blitter_32bppBase::SetHorizontalLine(void *video, int width, uint8 color) |
|
22 { |
|
23 uint32 *dst = (uint32 *)video; |
|
24 uint32 color32 = LookupColourInPalette(color); |
|
25 |
|
26 for (; width > 0; width--) { |
|
27 *dst = color32; |
|
28 dst++; |
|
29 } |
|
30 } |
|
31 |
|
32 void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height, int src_pitch) |
|
33 { |
|
34 int direction = (height < 0) ? -1 : 1; |
|
35 uint32 *dst = (uint32 *)video; |
|
36 uint32 *usrc = (uint32 *)src; |
|
37 |
|
38 height = abs(height); |
|
39 for (; height > 0; height--) { |
|
40 memcpy(dst, usrc, width * sizeof(uint32)); |
|
41 usrc += src_pitch * direction; |
|
42 dst += _screen.pitch * direction; |
|
43 } |
|
44 } |
|
45 |
|
46 void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) |
|
47 { |
|
48 int direction = (height < 0) ? -1 : 1; |
|
49 uint32 *udst = (uint32 *)dst; |
|
50 uint32 *src = (uint32 *)video; |
|
51 |
|
52 height = abs(height); |
|
53 for (; height > 0; height--) { |
|
54 memcpy(udst, src, width * sizeof(uint32)); |
|
55 src += _screen.pitch * direction; |
|
56 udst += dst_pitch * direction; |
|
57 } |
|
58 } |
|
59 |
|
60 void Blitter_32bppBase::MoveBuffer(void *video_dst, const void *video_src, int width, int height) |
|
61 { |
|
62 uint32 *dst = (uint32 *)video_dst; |
|
63 uint32 *src = (uint32 *)video_src; |
|
64 |
|
65 for (; height > 0; height--) { |
|
66 memmove(dst, src, width * sizeof(uint32)); |
|
67 src += _screen.pitch; |
|
68 dst += _screen.pitch; |
|
69 } |
|
70 } |
|
71 |
|
72 int Blitter_32bppBase::BufferSize(int width, int height) |
|
73 { |
|
74 return width * height * sizeof(uint32); |
|
75 } |