aboutsummaryrefslogtreecommitdiff
path: root/backends/PalmOS/Src/arm/blit.cpp
blob: 674b4dd365c36c5d0d887ea117bf29cae41539bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "native.h"
#include "endianutils.h"

#define MAIN_TYPE	BlitType
#include "macros.h"

#define memcpy MemMove

UInt32 Display_blit(void *userData68KP) {
// import variables
	SETPTR	(uint8 *,		dstBuf		)
	SETPTR	(const uint8 *,	srcBuf		)
	SET16	(uint16,		dstPitch	)
	SET16	(uint16,		srcPitch	)
	SET16	(uint16,	w		)
	SET16	(uint16,	h		)
	SET8	(bool,		xflip	)
	SET8	(bool,		masked	)
// end of import

	if (!masked) { // Unmasked always unflipped
		while (h--) {
			memcpy(dstBuf, srcBuf, w);
			srcBuf += srcPitch;
			dstBuf += dstPitch;
		}
	} else if (!xflip) { // Masked bitmap unflipped
		while (h--) {
			for(int i = 0; i < w; ++i) {
				uint8 b = *(srcBuf + i);
				if(b != 0) {
					*(dstBuf + i) = b;
				}
			}
			srcBuf += srcPitch;
			dstBuf += dstPitch;
		}
	} else { // Masked bitmap flipped
		while (h--) {
			for(int i = 0; i < w; ++i) {
				uint8 b = *(srcBuf + i);
				if(b != 0) {
					*(dstBuf - i) = b;
				}
			}
			srcBuf += srcPitch;
			dstBuf += dstPitch;
		}
	}
	
	return 0;
}