src/video/ataricommon/SDL_ataric2p.S
author Sam Lantinga <slouken@libsdl.org>
Wed, 06 Mar 2002 11:23:08 +0000
changeset 297 f6ffac90895c
parent 281 c5010ab8ba35
child 734 0310bb01091f
permissions -rw-r--r--
Updated copyright information for 2002
slouken@281
     1
/*
slouken@281
     2
    SDL - Simple DirectMedia Layer
slouken@297
     3
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
slouken@281
     4
slouken@281
     5
    This library is free software; you can redistribute it and/or
slouken@281
     6
    modify it under the terms of the GNU Library General Public
slouken@281
     7
    License as published by the Free Software Foundation; either
slouken@281
     8
    version 2 of the License, or (at your option) any later version.
slouken@281
     9
slouken@281
    10
    This library is distributed in the hope that it will be useful,
slouken@281
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@281
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@281
    13
    Library General Public License for more details.
slouken@281
    14
slouken@281
    15
    You should have received a copy of the GNU Library General Public
slouken@281
    16
    License along with this library; if not, write to the Free
slouken@281
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@281
    18
slouken@281
    19
    Sam Lantinga
slouken@281
    20
    slouken@libsdl.org
slouken@281
    21
*/
slouken@281
    22
slouken@281
    23
#ifdef SAVE_RCSID
slouken@281
    24
static char rcsid =
slouken@281
    25
 "@(#) $Id$";
slouken@281
    26
#endif
slouken@281
    27
slouken@281
    28
/*
slouken@281
    29
 *	Chunky to planar conversion routine
slouken@281
    30
 *	1 byte/pixel -> 4 or 8 bit planes
slouken@281
    31
 *
slouken@281
    32
 *	Patrice Mandin
slouken@281
    33
 *	Xavier Joubert
slouken@281
    34
 */
slouken@281
    35
slouken@281
    36
/* ------------	Function pointers ------------ */
slouken@281
    37
slouken@281
    38
	.globl	_Atari_C2pInit
slouken@281
    39
	.globl	_Atari_C2pConvert
slouken@281
    40
slouken@281
    41
	.data
slouken@281
    42
slouken@281
    43
	.even
slouken@281
    44
	.comm	_Atari_C2pInit,4
slouken@281
    45
	.comm	_Atari_C2pConvert,4
slouken@281
    46
slouken@281
    47
/* ------------	Conversion Table C2P ------------ */
slouken@281
    48
slouken@281
    49
	.globl	_Atari_table_c2p
slouken@281
    50
slouken@281
    51
	.data
slouken@281
    52
slouken@281
    53
	.comm	_Atari_table_c2p,2048
slouken@281
    54
slouken@281
    55
/* ------------	Init table C2P, 8 bits ------------ */
slouken@281
    56
slouken@281
    57
	.globl	_Atari_C2pInit8
slouken@281
    58
slouken@281
    59
	.text
slouken@281
    60
_Atari_C2pInit8:
slouken@281
    61
	movel	d2,sp@-
slouken@281
    62
slouken@281
    63
	lea	_Atari_table_c2p,a0
slouken@281
    64
	movew	#255,d0
slouken@281
    65
c2p_initbcl:
slouken@281
    66
#if defined (__M68020__)
slouken@281
    67
	lea	a0@(0,d0:w:8),a1
slouken@281
    68
#else
slouken@281
    69
	movew	d0,d2
slouken@281
    70
	lslw	#3,d2
slouken@281
    71
	lea	a0@(0,d2:w),a1
slouken@281
    72
#endif
slouken@281
    73
	moveq	#7,d1
slouken@281
    74
c2p_initbyte:
slouken@281
    75
	btst	d1,d0
slouken@281
    76
	sne	d2
slouken@281
    77
	negw	d2
slouken@281
    78
	moveb	d2,a1@(0,d1:w)
slouken@281
    79
slouken@281
    80
	dbra	d1,c2p_initbyte
slouken@281
    81
slouken@281
    82
	dbra	d0,c2p_initbcl
slouken@281
    83
slouken@281
    84
	movel	sp@+,d2
slouken@281
    85
	rts
slouken@281
    86
slouken@281
    87
/* ------------	Conversion C2P, 8 bits ------------ */
slouken@281
    88
slouken@281
    89
	.globl	_Atari_C2pConvert8
slouken@281
    90
slouken@281
    91
	.text
slouken@281
    92
_Atari_C2pConvert8:
slouken@281
    93
	movel	sp@(4),c2p_source
slouken@281
    94
	movel	sp@(8),c2p_dest
slouken@281
    95
	movel	sp@(12),c2p_width
slouken@281
    96
	movel	sp@(16),c2p_height
slouken@281
    97
	movel	sp@(20),c2p_dblligne
slouken@281
    98
	movel	sp@(24),c2p_srcpitch
slouken@281
    99
	movel	sp@(28),c2p_dstpitch
slouken@281
   100
slouken@281
   101
	moveml	d2-d7/a2-a6,sp@-
slouken@281
   102
slouken@281
   103
	movel	c2p_source,a0
slouken@281
   104
	movel	c2p_dest,a1
slouken@281
   105
	lea	_Atari_table_c2p,a2
slouken@281
   106
	movel	#0x000f0001,d3
slouken@281
   107
#if defined(__M68020__)
slouken@281
   108
	moveq	#0,d0
slouken@281
   109
#endif
slouken@281
   110
	
slouken@281
   111
	movel	c2p_height,d7
slouken@281
   112
	subql	#1,d7
slouken@281
   113
c2p8_bcly:
slouken@281
   114
	movel	a0,a4	| Save start address of source
slouken@281
   115
	movel	a1,a5	| Save start address of dest
slouken@281
   116
slouken@281
   117
	| Conversion
slouken@281
   118
                 
slouken@281
   119
	movel	c2p_width,d6
slouken@281
   120
	lsrw	#4,d6
slouken@281
   121
	subql	#1,d6
slouken@281
   122
c2p8_bclx:
slouken@281
   123
	| Octets 0-7
slouken@281
   124
	
slouken@281
   125
	moveq	#0,d1
slouken@281
   126
	moveq	#0,d2
slouken@281
   127
	moveq	#7,d5
slouken@281
   128
c2p8_bcl07:
slouken@281
   129
#if defined(__M68020__)
slouken@281
   130
	moveb	a0@+,d0
slouken@281
   131
	lea	a2@(0,d0:w:8),a3
slouken@281
   132
#else
slouken@281
   133
	moveq	#0,d0
slouken@281
   134
	moveb	a0@+,d0
slouken@281
   135
	lslw	#3,d0
slouken@281
   136
	lea	a2@(0,d0:w),a3
slouken@281
   137
#endif
slouken@281
   138
	lsll	#1,d1
slouken@281
   139
	lsll	#1,d2
slouken@281
   140
	orl	a3@+,d1
slouken@281
   141
	orl	a3@,d2
slouken@281
   142
	dbra	d5,c2p8_bcl07
slouken@281
   143
slouken@281
   144
	movepl	d1,a1@(0)
slouken@281
   145
	movepl	d2,a1@(8)
slouken@281
   146
	addw	d3,a1
slouken@281
   147
	swap	d3
slouken@281
   148
	
slouken@281
   149
	| Octets 8-15
slouken@281
   150
slouken@281
   151
	moveq	#0,d1
slouken@281
   152
	moveq	#0,d2
slouken@281
   153
	moveq	#7,d5
slouken@281
   154
c2p8_bcl815:
slouken@281
   155
#if defined(__M68020__)
slouken@281
   156
	moveb	a0@+,d0
slouken@281
   157
	lea	a2@(0,d0:w:8),a3
slouken@281
   158
#else
slouken@281
   159
	moveq	#0,d0
slouken@281
   160
	moveb	a0@+,d0
slouken@281
   161
	lslw	#3,d0
slouken@281
   162
	lea	a2@(0,d0:w),a3
slouken@281
   163
#endif
slouken@281
   164
	lsll	#1,d1
slouken@281
   165
	lsll	#1,d2
slouken@281
   166
	orl	a3@+,d1
slouken@281
   167
	orl	a3@,d2
slouken@281
   168
	dbra	d5,c2p8_bcl815
slouken@281
   169
slouken@281
   170
	movepl	d1,a1@(0)
slouken@281
   171
	movepl	d2,a1@(8)
slouken@281
   172
	addw	d3,a1
slouken@281
   173
	swap	d3
slouken@281
   174
slouken@281
   175
	dbra	d6,c2p8_bclx
slouken@281
   176
slouken@281
   177
	| Double line ?
slouken@281
   178
slouken@281
   179
	tstl	c2p_dblligne
slouken@281
   180
	beq	c2p8_nodblligne
slouken@281
   181
slouken@281
   182
	movel	a5,a6			| src line
slouken@281
   183
	movel	a5,a1			| dest line
slouken@281
   184
	addl	c2p_dstpitch,a1
slouken@281
   185
slouken@281
   186
	movel	c2p_width,d6
slouken@281
   187
	lsrw	#2,d6
slouken@281
   188
	subql	#1,d6
slouken@281
   189
c2p8_copydbl:
slouken@281
   190
	movel	a6@+,a1@+
slouken@281
   191
	dbra	d6,c2p8_copydbl
slouken@281
   192
slouken@281
   193
	addl	c2p_dstpitch,a5
slouken@281
   194
c2p8_nodblligne:
slouken@281
   195
slouken@281
   196
	| Next line
slouken@281
   197
slouken@281
   198
	movel	a4,a0		
slouken@281
   199
	addl	c2p_srcpitch,a0
slouken@281
   200
	movel	a5,a1
slouken@281
   201
	addl	c2p_dstpitch,a1
slouken@281
   202
slouken@281
   203
	dbra	d7,c2p8_bcly
slouken@281
   204
slouken@281
   205
	moveml	sp@+,d2-d7/a2-a6
slouken@281
   206
	rts
slouken@281
   207
slouken@281
   208
/* ------------	Init table C2P, 4 bits ------------ */
slouken@281
   209
slouken@281
   210
	.globl	_Atari_C2pInit4
slouken@281
   211
slouken@281
   212
	.text
slouken@281
   213
_Atari_C2pInit4:
slouken@281
   214
	/* Nothing to do */
slouken@281
   215
	/* work is done in convert_c2p_pal */
slouken@281
   216
	rts
slouken@281
   217
slouken@281
   218
/* ------------	Conversion C2P, 4 bits ------------ */
slouken@281
   219
slouken@281
   220
	.globl	_Atari_C2pConvert4
slouken@281
   221
slouken@281
   222
	.text
slouken@281
   223
_Atari_C2pConvert4:
slouken@281
   224
	movel	sp@(4),c2p_source
slouken@281
   225
	movel	sp@(8),c2p_dest
slouken@281
   226
	movel	sp@(12),c2p_width
slouken@281
   227
	movel	sp@(16),c2p_height
slouken@281
   228
	movel	sp@(20),c2p_dblligne
slouken@281
   229
	movel	sp@(24),c2p_srcpitch
slouken@281
   230
	movel	sp@(28),c2p_dstpitch
slouken@281
   231
slouken@281
   232
	moveml	d2-d7/a2-a6,sp@-
slouken@281
   233
slouken@281
   234
	movel	c2p_source,a0
slouken@281
   235
	movel	c2p_dest,a1
slouken@281
   236
	lea	_Atari_table_c2p,a2
slouken@281
   237
	movel	#0x00070001,d3
slouken@281
   238
#if defined(__M68020__)
slouken@281
   239
	moveq	#0,d0
slouken@281
   240
#endif
slouken@281
   241
	
slouken@281
   242
	movel	c2p_height,d7
slouken@281
   243
	subql	#1,d7
slouken@281
   244
c2p4_bcly:
slouken@281
   245
	movel	a0,a4	| Save start address of source
slouken@281
   246
	movel	a1,a5	| Save start address of dest
slouken@281
   247
slouken@281
   248
	| Conversion
slouken@281
   249
                 			
slouken@281
   250
	movel	c2p_width,d6
slouken@281
   251
	lsrw	#4,d6
slouken@281
   252
	subql	#1,d6
slouken@281
   253
c2p4_bclx:
slouken@281
   254
	| Octets 0-7
slouken@281
   255
	
slouken@281
   256
	moveq	#0,d1
slouken@281
   257
	moveq	#7,d5
slouken@281
   258
c2p4_bcl07:
slouken@281
   259
#if defined(__M68020__)
slouken@281
   260
	moveb	a0@+,d0
slouken@281
   261
	lea	a2@(0,d0:w:4),a3
slouken@281
   262
#else
slouken@281
   263
	moveq	#0,d0
slouken@281
   264
	moveb	a0@+,d0
slouken@281
   265
	lslw	#2,d0
slouken@281
   266
	lea	a2@(0,d0:w),a3
slouken@281
   267
#endif
slouken@281
   268
	lsll	#1,d1
slouken@281
   269
	orl	a3@,d1
slouken@281
   270
	dbra	d5,c2p4_bcl07
slouken@281
   271
slouken@281
   272
	movepl	d1,a1@(0)
slouken@281
   273
	addw	d3,a1
slouken@281
   274
	swap	d3
slouken@281
   275
	
slouken@281
   276
	| Octets 8-15
slouken@281
   277
slouken@281
   278
	moveq	#0,d1
slouken@281
   279
	moveq	#7,d5
slouken@281
   280
c2p4_bcl815:
slouken@281
   281
#if defined(__M68020__)
slouken@281
   282
	moveb	a0@+,d0
slouken@281
   283
	lea	a2@(0,d0:w:4),a3
slouken@281
   284
#else
slouken@281
   285
	moveq	#0,d0
slouken@281
   286
	moveb	a0@+,d0
slouken@281
   287
	lslw	#2,d0
slouken@281
   288
	lea	a2@(0,d0:w),a3
slouken@281
   289
#endif
slouken@281
   290
	lsll	#1,d1
slouken@281
   291
	orl	a3@,d1
slouken@281
   292
	dbra	d5,c2p4_bcl815
slouken@281
   293
slouken@281
   294
	movepl	d1,a1@(0)
slouken@281
   295
	addw	d3,a1
slouken@281
   296
	swap	d3
slouken@281
   297
slouken@281
   298
	dbra	d6,c2p4_bclx
slouken@281
   299
slouken@281
   300
	| Double line ?
slouken@281
   301
slouken@281
   302
	tstl	c2p_dblligne
slouken@281
   303
	beq	c2p4_nodblligne
slouken@281
   304
slouken@281
   305
	movel	a5,a6			| src line
slouken@281
   306
	movel	a5,a1			| dest line
slouken@281
   307
	addl	c2p_dstpitch,a1
slouken@281
   308
slouken@281
   309
	movel	c2p_width,d6
slouken@281
   310
	lsrw	#3,d6
slouken@281
   311
	subql	#1,d6
slouken@281
   312
c2p4_copydbl:
slouken@281
   313
	movel	a6@+,a1@+
slouken@281
   314
	dbra	d6,c2p4_copydbl
slouken@281
   315
slouken@281
   316
	addl	c2p_dstpitch,a5
slouken@281
   317
c2p4_nodblligne:
slouken@281
   318
slouken@281
   319
	| Next line
slouken@281
   320
slouken@281
   321
	movel	a4,a0		
slouken@281
   322
	addl	c2p_srcpitch,a0
slouken@281
   323
	movel	a5,a1
slouken@281
   324
	addl	c2p_dstpitch,a1
slouken@281
   325
slouken@281
   326
	dbra	d7,c2p4_bcly
slouken@281
   327
slouken@281
   328
	moveml	sp@+,d2-d7/a2-a6
slouken@281
   329
	rts
slouken@281
   330
slouken@281
   331
* ------------	Conversion of a light palette in 4 bits ------------ */
slouken@281
   332
slouken@281
   333
	.globl	_Atari_C2pConvert4_pal
slouken@281
   334
slouken@281
   335
	.text
slouken@281
   336
_Atari_C2pConvert4_pal:
slouken@281
   337
	/* a0 is a 256-word light palette */
slouken@281
   338
	movel	sp@(4),a0
slouken@281
   339
slouken@281
   340
	moveml	d2-d3,sp@-
slouken@281
   341
slouken@281
   342
	lea	_Atari_table_c2p,a1
slouken@281
   343
	movew	#255,d3
slouken@281
   344
c2p_pal_initbcl:
slouken@281
   345
	movew	a0@+,d0
slouken@281
   346
	lsrw	#4,d0
slouken@281
   347
	and	#15,d0
slouken@281
   348
slouken@281
   349
	moveq	#3,d1
slouken@281
   350
c2p_pal_initbyte:
slouken@281
   351
	btst	d1,d0
slouken@281
   352
	sne	d2
slouken@281
   353
	negw	d2
slouken@281
   354
	moveb	d2,a1@(0,d1:w)
slouken@281
   355
slouken@281
   356
	dbra	d1,c2p_pal_initbyte
slouken@281
   357
slouken@281
   358
	addql	#4,a1
slouken@281
   359
	dbra	d3,c2p_pal_initbcl
slouken@281
   360
slouken@281
   361
	moveml	sp@+,d2-d3
slouken@281
   362
slouken@281
   363
	rts
slouken@281
   364
slouken@281
   365
/* ------------	Buffers ------------ */
slouken@281
   366
slouken@281
   367
	.data
slouken@281
   368
slouken@281
   369
	.even
slouken@281
   370
	.comm	c2p_source,4
slouken@281
   371
	.comm	c2p_dest,4
slouken@281
   372
	.comm	c2p_width,4
slouken@281
   373
	.comm	c2p_height,4
slouken@281
   374
	.comm	c2p_dblligne,4
slouken@281
   375
	.comm	c2p_srcpitch,4
slouken@281
   376
	.comm	c2p_dstpitch,4
slouken@281
   377