fix crash when specifying --source on command line
[rofl0r-gnuboy.git] / refresh.h
blob796b3643405626f748b69999bcf23a8dccdd074e
1 #ifndef REFRESH_H
2 #define REFRESH_H
3 #include "defs.h"
5 #ifdef USE_ASM
6 #include "asm.h"
7 #endif
9 #ifdef ASM_REFRESH_1
10 void refresh_1(void *dest, byte *src, void *pal, int cnt);
11 #endif
12 #ifdef ASM_REFRESH_2
13 void refresh_2(void *dest, byte *src, void *pal, int cnt);
14 #endif
15 #ifdef ASM_REFRESH_3
16 void refresh_3(void *dest, byte *src, void *pal, int cnt);
17 #endif
18 #ifdef ASM_REFRESH_4
19 void refresh_4(void *dest, byte *src, void *pal, int cnt);
20 #endif
21 #ifdef ASM_REFRESH_1_2X
22 void refresh_1_2x(void *dest, byte *src, void *pal, int cnt);
23 #endif
24 #ifdef ASM_REFRESH_2_2X
25 void refresh_2_2x(void *dest, byte *src, void *pal, int cnt);
26 #endif
27 #ifdef ASM_REFRESH_3_2X
28 void refresh_3_2x(void *dest, byte *src, void *pal, int cnt);
29 #endif
30 #ifdef ASM_REFRESH_4_2X
31 void refresh_4_2x(void *dest, byte *src, void *pal, int cnt);
32 #endif
33 #ifdef ASM_REFRESH_2_3X
34 void refresh_2_3x(void *dest, byte *src, void *pal, int cnt);
35 #endif
36 #ifdef ASM_REFRESH_3_3X
37 void refresh_3_3x(void *dest, byte *src, void *pal, int cnt);
38 #endif
39 #ifdef ASM_REFRESH_4_3X
40 void refresh_4_3x(void *dest, byte *src, void *pal, int cnt);
41 #endif
42 #ifdef ASM_REFRESH_3_4X
43 void refresh_3_4x(void *dest, byte *src, void *pal, int cnt);
44 #endif
45 #ifdef ASM_REFRESH_4_4X
46 void refresh_4_4x(void *dest, byte *src, void *pal, int cnt);
47 #endif
49 #ifdef __GNUC__
50 #define MAY_ALIAS __attribute__((__may_alias__))
51 #else
52 #define MAY_ALIAS
53 #endif
55 typedef un16 un16a MAY_ALIAS;
56 typedef un32 un32a MAY_ALIAS;
59 #ifndef ASM_REFRESH_1
60 static void refresh_1(void *dest_, byte *src, void *pal_, int cnt)
62 byte *dest = dest_, *pal = pal_;
63 while(cnt--) *(dest++) = pal[*(src++)];
65 #endif
67 #ifndef ASM_REFRESH_2
68 static void refresh_2(void *dest_, byte *src, void *pal_, int cnt)
70 un16a *dest = dest_, *pal = pal_;
71 while (cnt--) *(dest++) = pal[*(src++)];
73 #endif
75 #ifndef ASM_REFRESH_3
76 static void refresh_3(void *dest_, byte *src, void *pal_, int cnt)
78 byte *dest = dest_;
79 un32a *pal = pal_;
80 un32 c;
81 while (cnt--)
83 c = pal[*(src++)];
84 *(dest++) = c;
85 *(dest++) = c>>8;
86 *(dest++) = c>>16;
89 #endif
91 #ifndef ASM_REFRESH_4
92 static void refresh_4(void *dest_, byte *src, void *pal_, int cnt)
94 un32a *dest = dest_, *pal = pal_;
95 while (cnt--) *(dest++) = pal[*(src++)];
97 #endif
100 #ifndef ASM_REFRESH_1_2X
101 static void refresh_1_2x(void *dest_, byte *src, void *pal_, int cnt)
103 byte *dest = dest_, *pal = pal_;
104 byte c;
105 while (cnt--)
107 c = pal[*(src++)];
108 *(dest++) = c;
109 *(dest++) = c;
112 #endif
114 #ifndef ASM_REFRESH_2_2X
115 static void refresh_2_2x(void *dest_, byte *src, void *pal_, int cnt)
117 un16a *dest = dest_, *pal = pal_;
118 un16 c;
119 while (cnt--)
121 c = pal[*(src++)];
122 *(dest++) = c;
123 *(dest++) = c;
126 #endif
128 #ifndef ASM_REFRESH_3_2X
129 static void refresh_3_2x(void *dest_, byte *src, void *pal_, int cnt)
131 byte *dest = dest_;
132 un32a *pal = pal;
133 un32 c;
134 while (cnt--)
136 c = pal[*(src++)];
137 dest[0] = dest[3] = c;
138 dest[1] = dest[4] = c>>8;
139 dest[2] = dest[5] = c>>16;
140 dest += 6;
143 #endif
145 #ifndef ASM_REFRESH_4_2X
146 static void refresh_4_2x(void *dest_, byte *src, void *pal_, int cnt)
148 un32a *dest = dest_, *pal = pal_;
149 un32 c;
150 while (cnt--)
152 c = pal[*(src++)];
153 *(dest++) = c;
154 *(dest++) = c;
157 #endif
159 #ifndef ASM_REFRESH_2_3X
160 static void refresh_2_3x(void *dest_, byte *src, void *pal_, int cnt)
162 un16a *dest = dest_, *pal = pal_;
163 un16 c;
164 while (cnt--)
166 c = pal[*(src++)];
167 *(dest++) = c;
168 *(dest++) = c;
169 *(dest++) = c;
172 #endif
174 #ifndef ASM_REFRESH_3_3X
175 static void refresh_3_3x(void *dest_, byte *src, void *pal_, int cnt)
177 byte* dest = dest_;
178 un32a *pal = pal_;
179 un32 c;
180 while (cnt--)
182 c = pal[*(src++)];
183 dest[0] = dest[3] = dest[6] = c;
184 dest[1] = dest[4] = dest[7] = c>>8;
185 dest[2] = dest[5] = dest[8] = c>>16;
186 dest += 9;
189 #endif
191 #ifndef ASM_REFRESH_4_3X
192 static void refresh_4_3x(void *dest_, byte *src, void *pal_, int cnt)
194 un32a *dest = dest_, *pal = pal_;
195 un32 c;
196 while (cnt--)
198 c = pal[*(src++)];
199 *(dest++) = c;
200 *(dest++) = c;
201 *(dest++) = c;
204 #endif
206 #ifndef ASM_REFRESH_3_4X
207 static void refresh_3_4x(void *dest_, byte *src, void *pal_, int cnt)
209 byte *dest = dest_;
210 un32a *pal = pal_;
211 un32 c;
212 while (cnt--)
214 c = pal[*(src++)];
215 dest[0] = dest[3] = dest[6] = dest[9] = c;
216 dest[1] = dest[4] = dest[7] = dest[10] = c>>8;
217 dest[2] = dest[5] = dest[8] = dest[11] = c>>16;
218 dest += 12;
221 #endif
223 #ifndef ASM_REFRESH_4_4X
224 static void refresh_4_4x(void *dest_, byte *src, void *pal_, int cnt)
226 un32a *dest = dest_, *pal = pal_;
227 un32 c;
228 while (cnt--)
230 c = pal[*(src++)];
231 *(dest++) = c;
232 *(dest++) = c;
233 *(dest++) = c;
234 *(dest++) = c;
237 #endif
239 #endif