Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_ataric2p060.c @ 281:c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 17 Feb 2002 19:54:28 +0000 |
parents | |
children | f6ffac90895c |
comparison
equal
deleted
inserted
replaced
280:0ddcea45d829 | 281:c5010ab8ba35 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Library General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Library General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Library General Public | |
16 License along with this library; if not, write to the Free | |
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 | |
23 #ifdef SAVE_RCSID | |
24 static char rcsid = | |
25 "@(#) $Id$"; | |
26 #endif | |
27 | |
28 /* | |
29 * Chunky to planar conversion routine | |
30 * for 68060 CPU, without movep instruction | |
31 * 1 byte/pixel -> 4 or 8 bit planes | |
32 * | |
33 * Patrice Mandin | |
34 */ | |
35 | |
36 #include <string.h> | |
37 | |
38 #include <sys/cookie.h> | |
39 | |
40 #include "SDL_ataric2p_s.h" | |
41 | |
42 /*--- Variables ---*/ | |
43 | |
44 /* CPU is 060 ? */ | |
45 int atari_cpu060_avail; | |
46 | |
47 /*--- Functions ---*/ | |
48 | |
49 void atari_test_cpu060_present(void) | |
50 { | |
51 unsigned long cookie_cpu; | |
52 | |
53 atari_cpu060_avail=0; | |
54 | |
55 /* Cookie _CPU present ? */ | |
56 if (Getcookie(C__CPU, &cookie_cpu) == C_FOUND) { | |
57 atari_cpu060_avail = (cookie_cpu == 60); | |
58 } | |
59 } | |
60 | |
61 void Atari_C2pConvert8_060( | |
62 Uint8 *src, /* Source screen (one byte=one pixel) */ | |
63 Uint8 *dest, /* Destination (8 bits planes) */ | |
64 Uint32 width, /* Dimensions of screen to convert */ | |
65 Uint32 height, | |
66 Uint32 dblligne, /* Double the lines when converting ? */ | |
67 Uint32 srcpitch, /* Length of one source line in bytes */ | |
68 Uint32 dstpitch /* Length of one destination line in bytes */ | |
69 ) | |
70 { | |
71 int x,y,z; | |
72 Uint8 *src_line, *dst_line; | |
73 | |
74 for (y=0; y<height; y++) { | |
75 src_line = src; | |
76 dst_line = dest; | |
77 | |
78 for (x=0; x<(width>>4); x++) { | |
79 Uint32 somme1, somme2; | |
80 Uint32 *convtable; | |
81 | |
82 /* bytes 0-7 */ | |
83 somme1 = somme2 = 0; | |
84 for (z=0; z<8 ;z++) { | |
85 convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<3]; | |
86 somme1 <<= 1; | |
87 somme2 <<= 1; | |
88 somme1 |= *convtable++; | |
89 somme2 |= *convtable; | |
90 } | |
91 | |
92 *(dst_line+14) = somme2; /* 000000FF */ | |
93 *(dst_line+6) = somme1; /* 000000FF */ | |
94 somme2 >>= 8; | |
95 somme1 >>= 8; | |
96 *(dst_line+12) = somme2; /* 0000FF00 */ | |
97 *(dst_line+4) = somme1; /* 0000FF00 */ | |
98 somme2 >>= 8; | |
99 somme1 >>= 8; | |
100 *(dst_line+10) = somme2; /* 00FF0000 */ | |
101 *(dst_line+2) = somme1; /* 00FF0000 */ | |
102 somme2 >>= 8; | |
103 somme1 >>= 8; | |
104 *(dst_line+8) = somme2; /* FF000000 */ | |
105 *dst_line++ = somme1; /* FF000000 */ | |
106 | |
107 /* bytes 8-15 */ | |
108 somme1 = somme2 = 0; | |
109 for (z=0; z<8 ;z++) { | |
110 convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<3]; | |
111 somme1 <<= 1; | |
112 somme2 <<= 1; | |
113 somme1 |= *convtable++; | |
114 somme2 |= *convtable; | |
115 } | |
116 | |
117 *(dst_line+14) = somme2; /* 000000FF */ | |
118 *(dst_line+6) = somme1; /* 000000FF */ | |
119 somme2 >>= 8; | |
120 somme1 >>= 8; | |
121 *(dst_line+12) = somme2; /* 0000FF00 */ | |
122 *(dst_line+4) = somme1; /* 0000FF00 */ | |
123 somme2 >>= 8; | |
124 somme1 >>= 8; | |
125 *(dst_line+10) = somme2; /* 00FF0000 */ | |
126 *(dst_line+2) = somme1; /* 00FF0000 */ | |
127 somme2 >>= 8; | |
128 somme1 >>= 8; | |
129 *(dst_line+8) = somme2; /* FF000000 */ | |
130 *dst_line = somme1; /* FF000000 */ | |
131 | |
132 dst_line += 15; | |
133 } | |
134 | |
135 if (dblligne) { | |
136 memcpy(dest+dstpitch, dest, width); | |
137 dest += dstpitch; | |
138 } | |
139 | |
140 src += srcpitch; | |
141 dest += dstpitch; | |
142 } | |
143 } | |
144 | |
145 void Atari_C2pConvert4_060( | |
146 Uint8 *src, /* Source screen (one byte=one pixel) */ | |
147 Uint8 *dest, /* Destination (4 bits planes) */ | |
148 Uint32 width, /* Dimensions of screen to convert */ | |
149 Uint32 height, | |
150 Uint32 dblligne, /* Double the lines when converting ? */ | |
151 Uint32 srcpitch, /* Length of one source line in bytes */ | |
152 Uint32 dstpitch /* Length of one destination line in bytes */ | |
153 ) | |
154 { | |
155 int x,y,z; | |
156 Uint8 *src_line, *dst_line; | |
157 | |
158 for (y=0;y<height;y++) { | |
159 src_line = src; | |
160 dst_line = dest; | |
161 | |
162 for (x=0; x<(width>>4);x++) { | |
163 Uint32 somme; | |
164 Uint32 *convtable; | |
165 | |
166 /* bytes 0-7 */ | |
167 somme=0; | |
168 for (z=0; z<8 ; z++) { | |
169 convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<2]; | |
170 somme <<= 1; | |
171 somme |= *convtable; | |
172 } | |
173 | |
174 *(dst_line+6) = somme; somme >>= 8; /* 000000FF */ | |
175 *(dst_line+4) = somme; somme >>= 8; /* 0000FF00 */ | |
176 *(dst_line+2) = somme; somme >>= 8; /* 00FF0000 */ | |
177 *dst_line++ = somme; /* FF000000 */ | |
178 | |
179 /* bytes 8-15 */ | |
180 somme = 0; | |
181 for (z=0; z<8 ;z++) { | |
182 convtable = (Uint32 *) &Atari_table_c2p[(*src_line++)<<2]; | |
183 somme <<= 1; | |
184 somme |= *convtable; | |
185 } | |
186 | |
187 *(dst_line+6) = somme; somme >>= 8; /* 000000FF */ | |
188 *(dst_line+4) = somme; somme >>= 8; /* 0000FF00 */ | |
189 *(dst_line+2) = somme; somme >>= 8; /* 00FF0000 */ | |
190 *dst_line = somme; /* FF000000 */ | |
191 | |
192 dst_line += 7; | |
193 } | |
194 | |
195 if (dblligne) { | |
196 memcpy(dest+dstpitch, dest, width>>1); | |
197 dest += dstpitch; | |
198 } | |
199 | |
200 src += srcpitch; | |
201 dest += dstpitch; | |
202 } | |
203 } |