forked from rofl0r/gnuboy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
refresh.h
240 lines (219 loc) · 4.53 KB
/
refresh.h
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#ifndef REFRESH_H
#define REFRESH_H
#include "defs.h"
#ifdef USE_ASM
#include "asm.h"
#endif
#ifdef ASM_REFRESH_1
void refresh_1(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_2
void refresh_2(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_3
void refresh_3(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_4
void refresh_4(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_1_2X
void refresh_1_2x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_2_2X
void refresh_2_2x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_3_2X
void refresh_3_2x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_4_2X
void refresh_4_2x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_2_3X
void refresh_2_3x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_3_3X
void refresh_3_3x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_4_3X
void refresh_4_3x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_3_4X
void refresh_3_4x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef ASM_REFRESH_4_4X
void refresh_4_4x(void *dest, byte *src, void *pal, int cnt);
#endif
#ifdef __GNUC__
#define MAY_ALIAS __attribute__((__may_alias__))
#else
#define MAY_ALIAS
#endif
typedef un16 un16a MAY_ALIAS;
typedef un32 un32a MAY_ALIAS;
#ifndef ASM_REFRESH_1
static void refresh_1(void *dest_, byte *src, void *pal_, int cnt)
{
byte *dest = dest_, *pal = pal_;
while(cnt--) *(dest++) = pal[*(src++)];
}
#endif
#ifndef ASM_REFRESH_2
static void refresh_2(void *dest_, byte *src, void *pal_, int cnt)
{
un16a *dest = dest_, *pal = pal_;
while (cnt--) *(dest++) = pal[*(src++)];
}
#endif
#ifndef ASM_REFRESH_3
static void refresh_3(void *dest_, byte *src, void *pal_, int cnt)
{
byte *dest = dest_;
un32a *pal = pal_;
un32 c;
while (cnt--)
{
c = pal[*(src++)];
*(dest++) = c;
*(dest++) = c>>8;
*(dest++) = c>>16;
}
}
#endif
#ifndef ASM_REFRESH_4
static void refresh_4(void *dest_, byte *src, void *pal_, int cnt)
{
un32a *dest = dest_, *pal = pal_;
while (cnt--) *(dest++) = pal[*(src++)];
}
#endif
#ifndef ASM_REFRESH_1_2X
static void refresh_1_2x(void *dest_, byte *src, void *pal_, int cnt)
{
byte *dest = dest_, *pal = pal_;
byte c;
while (cnt--)
{
c = pal[*(src++)];
*(dest++) = c;
*(dest++) = c;
}
}
#endif
#ifndef ASM_REFRESH_2_2X
static void refresh_2_2x(void *dest_, byte *src, void *pal_, int cnt)
{
un16a *dest = dest_, *pal = pal_;
un16 c;
while (cnt--)
{
c = pal[*(src++)];
*(dest++) = c;
*(dest++) = c;
}
}
#endif
#ifndef ASM_REFRESH_3_2X
static void refresh_3_2x(void *dest_, byte *src, void *pal_, int cnt)
{
byte *dest = dest_;
un32a *pal = pal;
un32 c;
while (cnt--)
{
c = pal[*(src++)];
dest[0] = dest[3] = c;
dest[1] = dest[4] = c>>8;
dest[2] = dest[5] = c>>16;
dest += 6;
}
}
#endif
#ifndef ASM_REFRESH_4_2X
static void refresh_4_2x(void *dest_, byte *src, void *pal_, int cnt)
{
un32a *dest = dest_, *pal = pal_;
un32 c;
while (cnt--)
{
c = pal[*(src++)];
*(dest++) = c;
*(dest++) = c;
}
}
#endif
#ifndef ASM_REFRESH_2_3X
static void refresh_2_3x(void *dest_, byte *src, void *pal_, int cnt)
{
un16a *dest = dest_, *pal = pal_;
un16 c;
while (cnt--)
{
c = pal[*(src++)];
*(dest++) = c;
*(dest++) = c;
*(dest++) = c;
}
}
#endif
#ifndef ASM_REFRESH_3_3X
static void refresh_3_3x(void *dest_, byte *src, void *pal_, int cnt)
{
byte* dest = dest_;
un32a *pal = pal_;
un32 c;
while (cnt--)
{
c = pal[*(src++)];
dest[0] = dest[3] = dest[6] = c;
dest[1] = dest[4] = dest[7] = c>>8;
dest[2] = dest[5] = dest[8] = c>>16;
dest += 9;
}
}
#endif
#ifndef ASM_REFRESH_4_3X
static void refresh_4_3x(void *dest_, byte *src, void *pal_, int cnt)
{
un32a *dest = dest_, *pal = pal_;
un32 c;
while (cnt--)
{
c = pal[*(src++)];
*(dest++) = c;
*(dest++) = c;
*(dest++) = c;
}
}
#endif
#ifndef ASM_REFRESH_3_4X
static void refresh_3_4x(void *dest_, byte *src, void *pal_, int cnt)
{
byte *dest = dest_;
un32a *pal = pal_;
un32 c;
while (cnt--)
{
c = pal[*(src++)];
dest[0] = dest[3] = dest[6] = dest[9] = c;
dest[1] = dest[4] = dest[7] = dest[10] = c>>8;
dest[2] = dest[5] = dest[8] = dest[11] = c>>16;
dest += 12;
}
}
#endif
#ifndef ASM_REFRESH_4_4X
static void refresh_4_4x(void *dest_, byte *src, void *pal_, int cnt)
{
un32a *dest = dest_, *pal = pal_;
un32 c;
while (cnt--)
{
c = pal[*(src++)];
*(dest++) = c;
*(dest++) = c;
*(dest++) = c;
*(dest++) = c;
}
}
#endif
#endif