comparison src/video/ataricommon/SDL_ataric2p.S @ 734:0310bb01091f

New C2P conversion routine
author Patrice Mandin <patmandin@gmail.com>
date Wed, 12 Nov 2003 18:45:48 +0000
parents f6ffac90895c
children 93207759e065
comparison
equal deleted inserted replaced
733:9557ac1857a3 734:0310bb01091f
24 static char rcsid = 24 static char rcsid =
25 "@(#) $Id$"; 25 "@(#) $Id$";
26 #endif 26 #endif
27 27
28 /* 28 /*
29 * Chunky to planar conversion routine 29 Chunky to planar conversion routine
30 * 1 byte/pixel -> 4 or 8 bit planes 30 1 byte/pixel -> 4 or 8 bit planes
31 * 31
32 * Patrice Mandin 32 Patrice Mandin
33 * Xavier Joubert 33 Xavier Joubert
34 */ 34 Mikael Kalms
35 35 */
36 /* ------------ Function pointers ------------ */ 36
37 37 .globl _SDL_Atari_C2pConvert
38 .globl _Atari_C2pInit 38 .globl _SDL_Atari_C2pConvert8
39 .globl _Atari_C2pConvert 39 .globl _SDL_Atari_C2pConvert4
40 40 .globl _SDL_Atari_C2pConvert4_pal
41 .data 41 .globl _SDL_Atari_table_c2p
42 42
43 .even 43 /* ------------ Conversion C2P, 8 bits ------------ */
44 .comm _Atari_C2pInit,4
45 .comm _Atari_C2pConvert,4
46
47 /* ------------ Conversion Table C2P ------------ */
48
49 .globl _Atari_table_c2p
50
51 .data
52
53 .comm _Atari_table_c2p,2048
54
55 /* ------------ Init table C2P, 8 bits ------------ */
56
57 .globl _Atari_C2pInit8
58 44
59 .text 45 .text
60 _Atari_C2pInit8: 46 _SDL_Atari_C2pConvert8:
61 movel d2,sp@-
62
63 lea _Atari_table_c2p,a0
64 movew #255,d0
65 c2p_initbcl:
66 #if defined (__M68020__)
67 lea a0@(0,d0:w:8),a1
68 #else
69 movew d0,d2
70 lslw #3,d2
71 lea a0@(0,d2:w),a1
72 #endif
73 moveq #7,d1
74 c2p_initbyte:
75 btst d1,d0
76 sne d2
77 negw d2
78 moveb d2,a1@(0,d1:w)
79
80 dbra d1,c2p_initbyte
81
82 dbra d0,c2p_initbcl
83
84 movel sp@+,d2
85 rts
86
87 /* ------------ Conversion C2P, 8 bits ------------ */
88
89 .globl _Atari_C2pConvert8
90
91 .text
92 _Atari_C2pConvert8:
93 movel sp@(4),c2p_source 47 movel sp@(4),c2p_source
94 movel sp@(8),c2p_dest 48 movel sp@(8),c2p_dest
95 movel sp@(12),c2p_width 49 movel sp@(12),c2p_width
96 movel sp@(16),c2p_height 50 movel sp@(16),c2p_height
97 movel sp@(20),c2p_dblligne 51 movel sp@(20),c2p_dblligne
98 movel sp@(24),c2p_srcpitch 52 movel sp@(24),c2p_srcpitch
99 movel sp@(28),c2p_dstpitch 53 movel sp@(28),c2p_dstpitch
100 54
101 moveml d2-d7/a2-a6,sp@- 55 moveml d2-d7/a2-a6,sp@-
102 56
103 movel c2p_source,a0 57 movel c2p_source,c2p_cursrc
104 movel c2p_dest,a1 58 movel c2p_dest,c2p_curdst
105 lea _Atari_table_c2p,a2 59 movel #0x0f0f0f0f,d4
106 movel #0x000f0001,d3 60 movel #0x00ff00ff,d5
107 #if defined(__M68020__) 61 movel #0x55555555,d6
108 moveq #0,d0 62 movew c2p_height+2,c2p_row
109 #endif 63 movew c2p_width+2,d0
110 64 andw #-8,d0
111 movel c2p_height,d7 65 movew d0,c2p_rowlen
66
67 SDL_Atari_C2p8_rowloop:
68
69 movel c2p_cursrc,a0
70 movel c2p_curdst,a1
71
72 movel a0,a2
73 addw c2p_rowlen,a2
74
75 movel a0@+,d0
76 movel a0@+,d1
77 movel a0@+,d2
78 movel a0@+,d3
79 /*
80 d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0
81 d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0
82 d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0
83 d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0
84 */
85 movel d1,d7
86 lsrl #4,d7
87 eorl d0,d7
88 andl d4,d7
89 eorl d7,d0
90 lsll #4,d7
91 eorl d7,d1
92
93 movel d3,d7
94 lsrl #4,d7
95 eorl d2,d7
96 andl d4,d7
97 eorl d7,d2
98 lsll #4,d7
99 eorl d7,d3
100
101 movel d2,d7
102 lsrl #8,d7
103 eorl d0,d7
104 andl d5,d7
105 eorl d7,d0
106 lsll #8,d7
107 eorl d7,d2
108
109 movel d3,d7
110 lsrl #8,d7
111 eorl d1,d7
112 andl d5,d7
113 eorl d7,d1
114 lsll #8,d7
115 eorl d7,d3
116 /*
117 d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4
118 d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0
119 d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4
120 d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0
121 */
122 bras SDL_Atari_C2p8_start
123
124 SDL_Atari_C2p8_pix16:
125
126 movel a0@+,d0
127 movel a0@+,d1
128 movel a0@+,d2
129 movel a0@+,d3
130 /*
131 d0 = a7a6a5a4a3a2a1a0 b7b6b5b4b3b2b1b0 c7c6c5c4c3c2c1c0 d7d6d5d4d3d2d1d0
132 d1 = e7e6e5e4e3e2e1e0 f7f6f5f4f3f2f1f0 g7g6g5g4g3g2g1g0 h7h6h5h4h3h2h1h0
133 d2 = i7i6i5i4i3i2i1i0 j7j6j5j4j3j2j1j0 k7k6k5k4k3k2k1k0 l7l6l5l4l3l2l1l0
134 d3 = m7m6m5m4m3m2m1m0 n7n6n5n4n3n2n1n0 o7o6o5o4o3o2o1o0 p7p6p5p4p3p2p1p0
135 */
136 movel d1,d7
137 lsrl #4,d7
138 movel a3,a1@+
139 eorl d0,d7
140 andl d4,d7
141 eorl d7,d0
142 lsll #4,d7
143 eorl d7,d1
144
145 movel d3,d7
146 lsrl #4,d7
147 eorl d2,d7
148 andl d4,d7
149 eorl d7,d2
150 movel a4,a1@+
151 lsll #4,d7
152 eorl d7,d3
153
154 movel d2,d7
155 lsrl #8,d7
156 eorl d0,d7
157 andl d5,d7
158 eorl d7,d0
159 movel a5,a1@+
160 lsll #8,d7
161 eorl d7,d2
162
163 movel d3,d7
164 lsrl #8,d7
165 eorl d1,d7
166 andl d5,d7
167 eorl d7,d1
168 movel a6,a1@+
169 lsll #8,d7
170 eorl d7,d3
171 /*
172 d0 = a7a6a5a4e7e6e5e4 i7i6i5i4m7m6m5m4 c7c6c5c4g7g6g5g4 k7k6k5k4o7o6o5o4
173 d1 = a3a2a1a0e3e2e1e0 i3i2i1i0m3m2m1m0 c3c2c1c0g3g2g1g0 k3k2k1k0o3o2o1o0
174 d2 = b7b6b5b4f7f6f5f4 j7j6j5j4n7n6n5n4 d7d6d5d4h7h6h5h4 l7l6l5l4p7p6p5p4
175 d3 = b3b2b1b0f3f2f1f0 j3j2j1j0n3n2n1n0 d3d2d1d0h3h2h1h0 l3l2l1l0p3p2p1p0
176 */
177
178 SDL_Atari_C2p8_start:
179
180 movel d2,d7
181 lsrl #1,d7
182 eorl d0,d7
183 andl d6,d7
184 eorl d7,d0
185 addl d7,d7
186 eorl d7,d2
187
188 movel d3,d7
189 lsrl #1,d7
190 eorl d1,d7
191 andl d6,d7
192 eorl d7,d1
193 addl d7,d7
194 eorl d7,d3
195 /*
196 d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5
197 d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1
198 d2 = a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4
199 d3 = a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0
200 */
201 movew d2,d7
202 movew d0,d2
203 swap d2
204 movew d2,d0
205 movew d7,d2
206
207 movew d3,d7
208 movew d1,d3
209 swap d3
210 movew d3,d1
211 movew d7,d3
212 /*
213 d0 = a7b7a5b5e7f7e5f5 i7j7i5j5m7n7m5n5 a6b6a4b4e6f6e4f4 i6j6i4j4m6n6m4n4
214 d1 = a3b3a1b1e3f3e1f1 i3j3i1j1m3n3m1n1 a2b2a0b0e2f2e0f0 i2j2i0j0m2n2m0n0
215 d2 = c7d7c5d5g7h7g5h5 k7l7k5l5o7p7o5p5 c6d6c4d4g6h6g4h4 k6l6k4l4o6p6o4p4
216 d3 = c3d3c1d1g3h3g1h1 k3l3k1l1o3p3o1p1 c2d2c0d0g2h2g0h0 k2l2k0l0o2p2o0p0
217 */
218 movel d2,d7
219 lsrl #2,d7
220 eorl d0,d7
221 andl #0x33333333,d7
222 eorl d7,d0
223 lsll #2,d7
224 eorl d7,d2
225
226 movel d3,d7
227 lsrl #2,d7
228 eorl d1,d7
229 andl #0x33333333,d7
230 eorl d7,d1
231 lsll #2,d7
232 eorl d7,d3
233 /*
234 d0 = a7b7c7d7e7f7g7h7 i7j7k7l7m7n7o7p7 a6b6c6d6e6f6g6h6 i6j6k6l6m6n6o6p6
235 d1 = a3b3c3d3e3f3g3h3 i3j3k3l3m3n3o3p3 a2b2c2d2e2f2g2h2 i2j2k2l2m2n2o2p2
236 d2 = a5b5c5d5e5f5g5h5 i5j5k5l5m5n5o5p5 a4b4c4d4e4f4g4h4 i4j4k4l4m4n4o4p4
237 d3 = a1b1c1d1e1f1g1h1 i1j1k1l1m1n1o1p1 a0b0c0d0e0f0g0h0 i0j0k0l0m0n0o0p0
238 */
239 swap d0
240 swap d1
241 swap d2
242 swap d3
243
244 movel d0,a6
245 movel d2,a5
246 movel d1,a4
247 movel d3,a3
248
249 cmpl a0,a2
250 bgt SDL_Atari_C2p8_pix16
251
252 movel a3,a1@+
253 movel a4,a1@+
254 movel a5,a1@+
255 movel a6,a1@+
256
257 /* Double the line ? */
258
259 movel c2p_srcpitch,d0
260 movel c2p_dstpitch,d1
261
262 tstl c2p_dblligne
263 beqs SDL_Atari_C2p8_nodblline
264
265 movel c2p_curdst,a0
266 movel a0,a1
267 addl d1,a1
268
269 movew c2p_width+2,d7
270 lsrw #4,d7
112 subql #1,d7 271 subql #1,d7
113 c2p8_bcly: 272 SDL_Atari_C2p8_dblloop:
114 movel a0,a4 | Save start address of source 273 movel a0@+,a1@+
115 movel a1,a5 | Save start address of dest 274 movel a0@+,a1@+
116 275 movel a0@+,a1@+
117 | Conversion 276 movel a0@+,a1@+
118 277 dbra d7,SDL_Atari_C2p8_dblloop
119 movel c2p_width,d6 278
120 lsrw #4,d6 279 addl d1,c2p_curdst
121 subql #1,d6 280
122 c2p8_bclx: 281 SDL_Atari_C2p8_nodblline:
123 | Octets 0-7 282
124 283 /* Next line */
125 moveq #0,d1 284
126 moveq #0,d2 285 addl d0,c2p_cursrc
127 moveq #7,d5 286 addl d1,c2p_curdst
128 c2p8_bcl07: 287
129 #if defined(__M68020__) 288 subqw #1,c2p_row
130 moveb a0@+,d0 289 bne SDL_Atari_C2p8_rowloop
131 lea a2@(0,d0:w:8),a3
132 #else
133 moveq #0,d0
134 moveb a0@+,d0
135 lslw #3,d0
136 lea a2@(0,d0:w),a3
137 #endif
138 lsll #1,d1
139 lsll #1,d2
140 orl a3@+,d1
141 orl a3@,d2
142 dbra d5,c2p8_bcl07
143
144 movepl d1,a1@(0)
145 movepl d2,a1@(8)
146 addw d3,a1
147 swap d3
148
149 | Octets 8-15
150
151 moveq #0,d1
152 moveq #0,d2
153 moveq #7,d5
154 c2p8_bcl815:
155 #if defined(__M68020__)
156 moveb a0@+,d0
157 lea a2@(0,d0:w:8),a3
158 #else
159 moveq #0,d0
160 moveb a0@+,d0
161 lslw #3,d0
162 lea a2@(0,d0:w),a3
163 #endif
164 lsll #1,d1
165 lsll #1,d2
166 orl a3@+,d1
167 orl a3@,d2
168 dbra d5,c2p8_bcl815
169
170 movepl d1,a1@(0)
171 movepl d2,a1@(8)
172 addw d3,a1
173 swap d3
174
175 dbra d6,c2p8_bclx
176
177 | Double line ?
178
179 tstl c2p_dblligne
180 beq c2p8_nodblligne
181
182 movel a5,a6 | src line
183 movel a5,a1 | dest line
184 addl c2p_dstpitch,a1
185
186 movel c2p_width,d6
187 lsrw #2,d6
188 subql #1,d6
189 c2p8_copydbl:
190 movel a6@+,a1@+
191 dbra d6,c2p8_copydbl
192
193 addl c2p_dstpitch,a5
194 c2p8_nodblligne:
195
196 | Next line
197
198 movel a4,a0
199 addl c2p_srcpitch,a0
200 movel a5,a1
201 addl c2p_dstpitch,a1
202
203 dbra d7,c2p8_bcly
204 290
205 moveml sp@+,d2-d7/a2-a6 291 moveml sp@+,d2-d7/a2-a6
206 rts 292 rts
207 293
208 /* ------------ Init table C2P, 4 bits ------------ */
209
210 .globl _Atari_C2pInit4
211
212 .text
213 _Atari_C2pInit4:
214 /* Nothing to do */
215 /* work is done in convert_c2p_pal */
216 rts
217
218 /* ------------ Conversion C2P, 4 bits ------------ */ 294 /* ------------ Conversion C2P, 4 bits ------------ */
219 295
220 .globl _Atari_C2pConvert4 296 _SDL_Atari_C2pConvert4:
221
222 .text
223 _Atari_C2pConvert4:
224 movel sp@(4),c2p_source 297 movel sp@(4),c2p_source
225 movel sp@(8),c2p_dest 298 movel sp@(8),c2p_dest
226 movel sp@(12),c2p_width 299 movel sp@(12),c2p_width
227 movel sp@(16),c2p_height 300 movel sp@(16),c2p_height
228 movel sp@(20),c2p_dblligne 301 movel sp@(20),c2p_dblligne
231 304
232 moveml d2-d7/a2-a6,sp@- 305 moveml d2-d7/a2-a6,sp@-
233 306
234 movel c2p_source,a0 307 movel c2p_source,a0
235 movel c2p_dest,a1 308 movel c2p_dest,a1
236 lea _Atari_table_c2p,a2 309 lea _SDL_Atari_table_c2p,a2
237 movel #0x00070001,d3 310 movel #0x00070001,d3
238 #if defined(__M68020__) 311 #if defined(__M68020__)
239 moveq #0,d0 312 moveq #0,d0
240 #endif 313 #endif
241 314
326 dbra d7,c2p4_bcly 399 dbra d7,c2p4_bcly
327 400
328 moveml sp@+,d2-d7/a2-a6 401 moveml sp@+,d2-d7/a2-a6
329 rts 402 rts
330 403
331 * ------------ Conversion of a light palette in 4 bits ------------ */ 404 /* ------------ Conversion of a light palette in 4 bits ------------ */
332 405
333 .globl _Atari_C2pConvert4_pal 406 _SDL_Atari_C2pConvert4_pal:
334
335 .text
336 _Atari_C2pConvert4_pal:
337 /* a0 is a 256-word light palette */ 407 /* a0 is a 256-word light palette */
338 movel sp@(4),a0 408 movel sp@(4),a0
339 409
340 moveml d2-d3,sp@- 410 moveml d2-d3,sp@-
341 411
342 lea _Atari_table_c2p,a1 412 lea _SDL_Atari_table_c2p,a1
343 movew #255,d3 413 movew #255,d3
344 c2p_pal_initbcl: 414 c2p_pal_initbcl:
345 movew a0@+,d0 415 movew a0@+,d0
346 lsrw #4,d0 416 lsrw #4,d0
347 and #15,d0 417 and #15,d0
365 /* ------------ Buffers ------------ */ 435 /* ------------ Buffers ------------ */
366 436
367 .data 437 .data
368 438
369 .even 439 .even
370 .comm c2p_source,4 440 .comm _SDL_Atari_C2pConvert,4
371 .comm c2p_dest,4 441 .comm _SDL_Atari_table_c2p,2048
372 .comm c2p_width,4 442
373 .comm c2p_height,4 443 .comm c2p_source,4 /* Source framebuffer */
374 .comm c2p_dblligne,4 444 .comm c2p_dest,4 /* Destination framebuffer */
375 .comm c2p_srcpitch,4 445 .comm c2p_width,4 /* Width of zone to convert */
376 .comm c2p_dstpitch,4 446 .comm c2p_height,4 /* Height of zone to convert */
377 447 .comm c2p_dblligne,4 /* Double the lines while converting ? */
448 .comm c2p_srcpitch,4 /* Source pitch */
449 .comm c2p_dstpitch,4 /* Destination pitch */
450 .comm c2p_cursrc,4 /* Current source line */
451 .comm c2p_curdst,4 /* Current destination line */
452 .comm c2p_rowlen,2 /* Line length in bytes */
453 .comm c2p_row,2 /* Current line number */