src/video/ataricommon/SDL_ataric2p.S
changeset 281 c5010ab8ba35
child 297 f6ffac90895c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/ataricommon/SDL_ataric2p.S	Sun Feb 17 19:54:28 2002 +0000
     1.3 @@ -0,0 +1,377 @@
     1.4 +/*
     1.5 +    SDL - Simple DirectMedia Layer
     1.6 +    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
     1.7 +
     1.8 +    This library is free software; you can redistribute it and/or
     1.9 +    modify it under the terms of the GNU Library General Public
    1.10 +    License as published by the Free Software Foundation; either
    1.11 +    version 2 of the License, or (at your option) any later version.
    1.12 +
    1.13 +    This library is distributed in the hope that it will be useful,
    1.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.16 +    Library General Public License for more details.
    1.17 +
    1.18 +    You should have received a copy of the GNU Library General Public
    1.19 +    License along with this library; if not, write to the Free
    1.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.21 +
    1.22 +    Sam Lantinga
    1.23 +    slouken@libsdl.org
    1.24 +*/
    1.25 +
    1.26 +#ifdef SAVE_RCSID
    1.27 +static char rcsid =
    1.28 + "@(#) $Id$";
    1.29 +#endif
    1.30 +
    1.31 +/*
    1.32 + *	Chunky to planar conversion routine
    1.33 + *	1 byte/pixel -> 4 or 8 bit planes
    1.34 + *
    1.35 + *	Patrice Mandin
    1.36 + *	Xavier Joubert
    1.37 + */
    1.38 +
    1.39 +/* ------------	Function pointers ------------ */
    1.40 +
    1.41 +	.globl	_Atari_C2pInit
    1.42 +	.globl	_Atari_C2pConvert
    1.43 +
    1.44 +	.data
    1.45 +
    1.46 +	.even
    1.47 +	.comm	_Atari_C2pInit,4
    1.48 +	.comm	_Atari_C2pConvert,4
    1.49 +
    1.50 +/* ------------	Conversion Table C2P ------------ */
    1.51 +
    1.52 +	.globl	_Atari_table_c2p
    1.53 +
    1.54 +	.data
    1.55 +
    1.56 +	.comm	_Atari_table_c2p,2048
    1.57 +
    1.58 +/* ------------	Init table C2P, 8 bits ------------ */
    1.59 +
    1.60 +	.globl	_Atari_C2pInit8
    1.61 +
    1.62 +	.text
    1.63 +_Atari_C2pInit8:
    1.64 +	movel	d2,sp@-
    1.65 +
    1.66 +	lea	_Atari_table_c2p,a0
    1.67 +	movew	#255,d0
    1.68 +c2p_initbcl:
    1.69 +#if defined (__M68020__)
    1.70 +	lea	a0@(0,d0:w:8),a1
    1.71 +#else
    1.72 +	movew	d0,d2
    1.73 +	lslw	#3,d2
    1.74 +	lea	a0@(0,d2:w),a1
    1.75 +#endif
    1.76 +	moveq	#7,d1
    1.77 +c2p_initbyte:
    1.78 +	btst	d1,d0
    1.79 +	sne	d2
    1.80 +	negw	d2
    1.81 +	moveb	d2,a1@(0,d1:w)
    1.82 +
    1.83 +	dbra	d1,c2p_initbyte
    1.84 +
    1.85 +	dbra	d0,c2p_initbcl
    1.86 +
    1.87 +	movel	sp@+,d2
    1.88 +	rts
    1.89 +
    1.90 +/* ------------	Conversion C2P, 8 bits ------------ */
    1.91 +
    1.92 +	.globl	_Atari_C2pConvert8
    1.93 +
    1.94 +	.text
    1.95 +_Atari_C2pConvert8:
    1.96 +	movel	sp@(4),c2p_source
    1.97 +	movel	sp@(8),c2p_dest
    1.98 +	movel	sp@(12),c2p_width
    1.99 +	movel	sp@(16),c2p_height
   1.100 +	movel	sp@(20),c2p_dblligne
   1.101 +	movel	sp@(24),c2p_srcpitch
   1.102 +	movel	sp@(28),c2p_dstpitch
   1.103 +
   1.104 +	moveml	d2-d7/a2-a6,sp@-
   1.105 +
   1.106 +	movel	c2p_source,a0
   1.107 +	movel	c2p_dest,a1
   1.108 +	lea	_Atari_table_c2p,a2
   1.109 +	movel	#0x000f0001,d3
   1.110 +#if defined(__M68020__)
   1.111 +	moveq	#0,d0
   1.112 +#endif
   1.113 +	
   1.114 +	movel	c2p_height,d7
   1.115 +	subql	#1,d7
   1.116 +c2p8_bcly:
   1.117 +	movel	a0,a4	| Save start address of source
   1.118 +	movel	a1,a5	| Save start address of dest
   1.119 +
   1.120 +	| Conversion
   1.121 +                 
   1.122 +	movel	c2p_width,d6
   1.123 +	lsrw	#4,d6
   1.124 +	subql	#1,d6
   1.125 +c2p8_bclx:
   1.126 +	| Octets 0-7
   1.127 +	
   1.128 +	moveq	#0,d1
   1.129 +	moveq	#0,d2
   1.130 +	moveq	#7,d5
   1.131 +c2p8_bcl07:
   1.132 +#if defined(__M68020__)
   1.133 +	moveb	a0@+,d0
   1.134 +	lea	a2@(0,d0:w:8),a3
   1.135 +#else
   1.136 +	moveq	#0,d0
   1.137 +	moveb	a0@+,d0
   1.138 +	lslw	#3,d0
   1.139 +	lea	a2@(0,d0:w),a3
   1.140 +#endif
   1.141 +	lsll	#1,d1
   1.142 +	lsll	#1,d2
   1.143 +	orl	a3@+,d1
   1.144 +	orl	a3@,d2
   1.145 +	dbra	d5,c2p8_bcl07
   1.146 +
   1.147 +	movepl	d1,a1@(0)
   1.148 +	movepl	d2,a1@(8)
   1.149 +	addw	d3,a1
   1.150 +	swap	d3
   1.151 +	
   1.152 +	| Octets 8-15
   1.153 +
   1.154 +	moveq	#0,d1
   1.155 +	moveq	#0,d2
   1.156 +	moveq	#7,d5
   1.157 +c2p8_bcl815:
   1.158 +#if defined(__M68020__)
   1.159 +	moveb	a0@+,d0
   1.160 +	lea	a2@(0,d0:w:8),a3
   1.161 +#else
   1.162 +	moveq	#0,d0
   1.163 +	moveb	a0@+,d0
   1.164 +	lslw	#3,d0
   1.165 +	lea	a2@(0,d0:w),a3
   1.166 +#endif
   1.167 +	lsll	#1,d1
   1.168 +	lsll	#1,d2
   1.169 +	orl	a3@+,d1
   1.170 +	orl	a3@,d2
   1.171 +	dbra	d5,c2p8_bcl815
   1.172 +
   1.173 +	movepl	d1,a1@(0)
   1.174 +	movepl	d2,a1@(8)
   1.175 +	addw	d3,a1
   1.176 +	swap	d3
   1.177 +
   1.178 +	dbra	d6,c2p8_bclx
   1.179 +
   1.180 +	| Double line ?
   1.181 +
   1.182 +	tstl	c2p_dblligne
   1.183 +	beq	c2p8_nodblligne
   1.184 +
   1.185 +	movel	a5,a6			| src line
   1.186 +	movel	a5,a1			| dest line
   1.187 +	addl	c2p_dstpitch,a1
   1.188 +
   1.189 +	movel	c2p_width,d6
   1.190 +	lsrw	#2,d6
   1.191 +	subql	#1,d6
   1.192 +c2p8_copydbl:
   1.193 +	movel	a6@+,a1@+
   1.194 +	dbra	d6,c2p8_copydbl
   1.195 +
   1.196 +	addl	c2p_dstpitch,a5
   1.197 +c2p8_nodblligne:
   1.198 +
   1.199 +	| Next line
   1.200 +
   1.201 +	movel	a4,a0		
   1.202 +	addl	c2p_srcpitch,a0
   1.203 +	movel	a5,a1
   1.204 +	addl	c2p_dstpitch,a1
   1.205 +
   1.206 +	dbra	d7,c2p8_bcly
   1.207 +
   1.208 +	moveml	sp@+,d2-d7/a2-a6
   1.209 +	rts
   1.210 +
   1.211 +/* ------------	Init table C2P, 4 bits ------------ */
   1.212 +
   1.213 +	.globl	_Atari_C2pInit4
   1.214 +
   1.215 +	.text
   1.216 +_Atari_C2pInit4:
   1.217 +	/* Nothing to do */
   1.218 +	/* work is done in convert_c2p_pal */
   1.219 +	rts
   1.220 +
   1.221 +/* ------------	Conversion C2P, 4 bits ------------ */
   1.222 +
   1.223 +	.globl	_Atari_C2pConvert4
   1.224 +
   1.225 +	.text
   1.226 +_Atari_C2pConvert4:
   1.227 +	movel	sp@(4),c2p_source
   1.228 +	movel	sp@(8),c2p_dest
   1.229 +	movel	sp@(12),c2p_width
   1.230 +	movel	sp@(16),c2p_height
   1.231 +	movel	sp@(20),c2p_dblligne
   1.232 +	movel	sp@(24),c2p_srcpitch
   1.233 +	movel	sp@(28),c2p_dstpitch
   1.234 +
   1.235 +	moveml	d2-d7/a2-a6,sp@-
   1.236 +
   1.237 +	movel	c2p_source,a0
   1.238 +	movel	c2p_dest,a1
   1.239 +	lea	_Atari_table_c2p,a2
   1.240 +	movel	#0x00070001,d3
   1.241 +#if defined(__M68020__)
   1.242 +	moveq	#0,d0
   1.243 +#endif
   1.244 +	
   1.245 +	movel	c2p_height,d7
   1.246 +	subql	#1,d7
   1.247 +c2p4_bcly:
   1.248 +	movel	a0,a4	| Save start address of source
   1.249 +	movel	a1,a5	| Save start address of dest
   1.250 +
   1.251 +	| Conversion
   1.252 +                 			
   1.253 +	movel	c2p_width,d6
   1.254 +	lsrw	#4,d6
   1.255 +	subql	#1,d6
   1.256 +c2p4_bclx:
   1.257 +	| Octets 0-7
   1.258 +	
   1.259 +	moveq	#0,d1
   1.260 +	moveq	#7,d5
   1.261 +c2p4_bcl07:
   1.262 +#if defined(__M68020__)
   1.263 +	moveb	a0@+,d0
   1.264 +	lea	a2@(0,d0:w:4),a3
   1.265 +#else
   1.266 +	moveq	#0,d0
   1.267 +	moveb	a0@+,d0
   1.268 +	lslw	#2,d0
   1.269 +	lea	a2@(0,d0:w),a3
   1.270 +#endif
   1.271 +	lsll	#1,d1
   1.272 +	orl	a3@,d1
   1.273 +	dbra	d5,c2p4_bcl07
   1.274 +
   1.275 +	movepl	d1,a1@(0)
   1.276 +	addw	d3,a1
   1.277 +	swap	d3
   1.278 +	
   1.279 +	| Octets 8-15
   1.280 +
   1.281 +	moveq	#0,d1
   1.282 +	moveq	#7,d5
   1.283 +c2p4_bcl815:
   1.284 +#if defined(__M68020__)
   1.285 +	moveb	a0@+,d0
   1.286 +	lea	a2@(0,d0:w:4),a3
   1.287 +#else
   1.288 +	moveq	#0,d0
   1.289 +	moveb	a0@+,d0
   1.290 +	lslw	#2,d0
   1.291 +	lea	a2@(0,d0:w),a3
   1.292 +#endif
   1.293 +	lsll	#1,d1
   1.294 +	orl	a3@,d1
   1.295 +	dbra	d5,c2p4_bcl815
   1.296 +
   1.297 +	movepl	d1,a1@(0)
   1.298 +	addw	d3,a1
   1.299 +	swap	d3
   1.300 +
   1.301 +	dbra	d6,c2p4_bclx
   1.302 +
   1.303 +	| Double line ?
   1.304 +
   1.305 +	tstl	c2p_dblligne
   1.306 +	beq	c2p4_nodblligne
   1.307 +
   1.308 +	movel	a5,a6			| src line
   1.309 +	movel	a5,a1			| dest line
   1.310 +	addl	c2p_dstpitch,a1
   1.311 +
   1.312 +	movel	c2p_width,d6
   1.313 +	lsrw	#3,d6
   1.314 +	subql	#1,d6
   1.315 +c2p4_copydbl:
   1.316 +	movel	a6@+,a1@+
   1.317 +	dbra	d6,c2p4_copydbl
   1.318 +
   1.319 +	addl	c2p_dstpitch,a5
   1.320 +c2p4_nodblligne:
   1.321 +
   1.322 +	| Next line
   1.323 +
   1.324 +	movel	a4,a0		
   1.325 +	addl	c2p_srcpitch,a0
   1.326 +	movel	a5,a1
   1.327 +	addl	c2p_dstpitch,a1
   1.328 +
   1.329 +	dbra	d7,c2p4_bcly
   1.330 +
   1.331 +	moveml	sp@+,d2-d7/a2-a6
   1.332 +	rts
   1.333 +
   1.334 +* ------------	Conversion of a light palette in 4 bits ------------ */
   1.335 +
   1.336 +	.globl	_Atari_C2pConvert4_pal
   1.337 +
   1.338 +	.text
   1.339 +_Atari_C2pConvert4_pal:
   1.340 +	/* a0 is a 256-word light palette */
   1.341 +	movel	sp@(4),a0
   1.342 +
   1.343 +	moveml	d2-d3,sp@-
   1.344 +
   1.345 +	lea	_Atari_table_c2p,a1
   1.346 +	movew	#255,d3
   1.347 +c2p_pal_initbcl:
   1.348 +	movew	a0@+,d0
   1.349 +	lsrw	#4,d0
   1.350 +	and	#15,d0
   1.351 +
   1.352 +	moveq	#3,d1
   1.353 +c2p_pal_initbyte:
   1.354 +	btst	d1,d0
   1.355 +	sne	d2
   1.356 +	negw	d2
   1.357 +	moveb	d2,a1@(0,d1:w)
   1.358 +
   1.359 +	dbra	d1,c2p_pal_initbyte
   1.360 +
   1.361 +	addql	#4,a1
   1.362 +	dbra	d3,c2p_pal_initbcl
   1.363 +
   1.364 +	moveml	sp@+,d2-d3
   1.365 +
   1.366 +	rts
   1.367 +
   1.368 +/* ------------	Buffers ------------ */
   1.369 +
   1.370 +	.data
   1.371 +
   1.372 +	.even
   1.373 +	.comm	c2p_source,4
   1.374 +	.comm	c2p_dest,4
   1.375 +	.comm	c2p_width,4
   1.376 +	.comm	c2p_height,4
   1.377 +	.comm	c2p_dblligne,4
   1.378 +	.comm	c2p_srcpitch,4
   1.379 +	.comm	c2p_dstpitch,4
   1.380 +