summaryrefslogtreecommitdiff
path: root/src/rops.h.last
blob: 5ec3e247f101917653f7ce9050f4bd877b72962d (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
	Raster Operations macros 
*/

// -------------
// RGB_565
// a.red = a.red - b.red
// a.blue = a.blue - b.blue
// a.green = a.green - b.green
/*
#define ROP_SUB(a, b) \
			"	bics	" #b ", " #b ", #0b00000100000100000	\n"\
			"	orr	" #a ", " #a ", #0b00000100000100000	\n"\
			"	orr	" #a ", " #a ", #0b10000000000000000	\n"\
			"	sub	" #a ", " #a ", " #b " 			\n"\
			"	tst	" #a ", #0b00000000000100000	\n"\
			"	biceq	" #a ", " #a ", #0b00000000000011111	\n"\
			"	tst	" #a ", #0b00000100000000000	\n"\
			"	biceq	" #a ", " #a ", #0b00000011111100000	\n"\
			"	tst	" #a ", #0b10000000000000000	\n"\
			"	biceq	" #a ", " #a ", #0b01111100000000000	\n"
*/
#define ROP_SUB(a, b) \
			"	bics	" #b ", " #b ", #0b00000100000100000	\n"\
			"	beq	999f	\n"\
			"	orr	" #a ", " #a ", #0b00000100000100000	\n"\
			"	orr	" #a ", " #a ", #(1 << 31)	\n"\
			"	subs	" #a ", " #a ", " #b " 			\n"\
			"	bicpl	" #a ", " #a ", #0b01111100000000000	\n"\
			"	tst	" #a ", #0b00000000000100000	\n"\
			"	biceq	" #a ", " #a ", #0b00000000000011111	\n"\
			"	tst	" #a ", #0b00000100000000000	\n"\
			"	biceq	" #a ", " #a ", #0b00000011111100000	\n"\
			"999:\n"


// -------------
// RGB_565
// if ZF set do ROP_SUB, else:
// a.red = (a.red - b.red) / 2
// a.blue = (a.blue - b.blue) / 2
// a.green = (a.green - b.green) / 2
/*
#define ROP_SUB1_2(a, b) \
			"	movne	" #a ", " #a ", lsr #1			\n"\
			"	bicne	" #a ", " #a ", #0b00000010000010000	\n"\
			"	movne	" #b ", " #b ", lsr #1			\n"\
			"	bicne	" #b ", " #b ", #0b00000010000010000	\n"\
										\
			"	bic	" #b ", " #b ", #0b00000100000100000	\n"\
			"	orr	" #a ", " #a ", #0b00000100000100000	\n"\
			"	orr	" #a ", " #a ", #0b10000000000000000	\n"\
			"	sub	" #a ", " #a ", " #b " 			\n"\
			"	tst	" #a ", #0b00000000000100000	\n"\
			"	biceq	" #a ", " #a ", #0b00000000000011111	\n"\
			"	tst	" #a ", #0b00000100000000000	\n"\
			"	biceq	" #a ", " #a ", #0b00000011111100000	\n"\
			"	tst	" #a ", #0b10000000000000000	\n"\
			"	biceq	" #a ", " #a ", #0b01111100000000000	\n"
*/

#define ROP_SUB1_2(a, b) \
			"	movne	" #a ", " #a ", lsr #1			\n"\
			"	bicne	" #a ", " #a ", #0b00000010000010000	\n"\
			"	movne	" #b ", " #b ", lsr #1			\n"\
			"	bicne	" #b ", " #b ", #0b00000010000010000	\n"\
										\
			"	bics	" #b ", " #b ", #0b00000100000100000	\n"\
			"	beq	999f \n"\
			"	orr	" #a ", " #a ", #0b00000100000100000	\n"\
			"	orr	" #a ", " #a ", #(1 << 31)	\n"\
			"	subs	" #a ", " #a ", " #b " 			\n"\
			"	bicpl	" #a ", " #a ", #0b01111100000000000	\n"\
			"	tst	" #a ", #0b00000000000100000	\n"\
			"	biceq	" #a ", " #a ", #0b00000000000011111	\n"\
			"	tst	" #a ", #0b00000100000000000	\n"\
			"	biceq	" #a ", " #a ", #0b00000011111100000	\n"\
			"999:\n"


// -------------
// RGB_565
// a.red = a.red + b.red
// a.blue = a.blue + b.blue
// a.green = a.green + b.green
#define ROP_ADD(a, b) \
			"	bics	" #b ", " #b ", #0b00000100000100000	\n"\
			"	beq	999f \n"\
			"	bics	" #a ", " #a ", #0b00000100000100000	\n"\
			"	add	" #a ", " #a ", " #b " 			\n"\
			"	tst	" #a ", #0b00000000000100000	\n"\
			"	orrne	" #a ", " #a ", #0b00000000000011111	\n"\
			"	tst	" #a ", #0b00000100000000000	\n"\
			"	orrne	" #a ", " #a ", #0b00000011111100000	\n"\
			"	tst	" #a ", #0b10000000000000000	\n"\
			"	orrne	" #a ", " #a ", #0b01111100000000000	\n"\
			"999:\n"

// -------------
// RGB_565
// if ZF set do ROP_ADD, else:
// a.red = (a.red + b.red) / 2
// a.blue = (a.blue + b.blue) / 2
// a.green = (a.green + b.green) / 2
#define ROP_ADD1_2(a, b) \
			"	bic	" #a ", " #a ", #0b00000100000100000	\n"\
			"	bicne	" #a ", " #a ", #0b00001000001000000	\n"\
			"	bic	" #b ", " #b ", #0b00000100000100000	\n"\
			"	bicne	" #b ", " #b ", #0b00001000001000000	\n"\
			"	add	" #a ", " #a ", " #b "			\n"\
			"	movne	" #a ", " #a ", lsr #1			\n"\
			"	tst	" #a ", #0b00000000000100000	\n"\
			"	orrne	" #a ", " #a ", #0b00000000000011111	\n"\
			"	tst	" #a ", #0b00000100000000000	\n"\
			"	orrne	" #a ", " #a ", #0b00000011111100000	\n"\
			"	tst	" #a ", #0b10000000000000000	\n"\
			"	orrne	" #a ", " #a ", #0b01111100000000000	\n"