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