-
Notifications
You must be signed in to change notification settings - Fork 7
/
c2p1x1_8_c5_040.s
405 lines (361 loc) · 6.83 KB
/
c2p1x1_8_c5_040.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
;
;
; Date: 2000-04-11 Mikael Kalms (Scout/C-Lous & more)
; Email: mikael@kalms.org
;
; About:
; 1x1 8bpl cpu5 C2P for contigous bitplanes and no horizontal modulo
;
; This routine is intended for use on all 68040 and 68060 based systems.
; It is not designed to perform well on 68020-030.
;
; This routine is released into the public domain. It may be freely used
; for non-commercial as well as commercial purposes. A short notice via
; email is always appreciated, though.
;
; Timings:
; Estimated to run at copyspeed on 040-40 and 060
;
; Features:
; Handles bitplanes of virtually any size (4GB)
;
; Restrictions:
; Chunky-buffer must be an even multiple of 32 pixels wide
; If incorrect/invalid parameters are specified, the routine will
; most probably crash.
;
; c2p1x1_8_c5_040_init sets chunkybuffer size/pos & bplsize
; c2p1x1_8_c5_040 performs the actual c2p conversion
;
section code,code
; d0.w chunkyx [chunky-pixels]
; d1.w chunkyy [chunky-pixels]
; d2.w (scroffsx) [screen-pixels]
; d3.w scroffsy [screen-pixels]
; d4.l (rowlen) [bytes] -- offset between one row and the next in a bpl
; d5.l bplsize [bytes] -- offset between one row in one bpl and the next bpl
; d6.l (chunkylen) [bytes] -- offset between one row and the next in chunkybuf
XDEF _c2p1x1_8_c5_040_init
XDEF c2p1x1_8_c5_040_init
_c2p1x1_8_c5_040_init
c2p1x1_8_c5_040_init
move.l d3,-(sp)
mulu.w d0,d3
lsr.l #3,d3
move.l d3,c2p1x1_8_c5_040_scroffs
mulu.w d0,d1
move.l d1,c2p1x1_8_c5_040_pixels
move.l d5,d0
lsl.l #3,d0
sub.l d5,d0
move.l d0,c2p1x1_8_c5_040_delta0
addq.l #4,d0
move.l d0,c2p1x1_8_c5_040_delta4
move.l d5,d0
lsl.l #2,d0
move.l d0,c2p1x1_8_c5_040_delta1
move.l d0,c2p1x1_8_c5_040_delta3
move.l d0,c2p1x1_8_c5_040_delta5
move.l d0,c2p1x1_8_c5_040_delta7
sub.l d5,d0
move.l d0,c2p1x1_8_c5_040_delta2
move.l d0,c2p1x1_8_c5_040_delta6
move.l d0,c2p1x1_8_c5_040_delta8
move.l (sp)+,d3
rts
; a0 c2pscreen
; a1 bitplanes
XDEF _c2p1x1_8_c5_040
XDEF c2p1x1_8_c5_040
_c2p1x1_8_c5_040
c2p1x1_8_c5_040
movem.l d2-d7/a2-a6,-(sp)
add.l c2p1x1_8_c5_040_delta0(pc),a1
add.l c2p1x1_8_c5_040_scroffs(pc),a1
move.l c2p1x1_8_c5_040_pixels(pc),d0
beq .none
add.l a0,d0
move.l d0,-(sp)
tst.b 16(a0)
move.l (a0)+,d0
move.l (a0)+,d1
move.l (a0)+,d2
move.l (a0)+,d3
tst.b 16(a0)
move.l (a0)+,d4
move.l (a0)+,d5
move.l (a0)+,a5
move.l (a0)+,a6
swap d4 ; Swap 16x4, part 1
swap d5
eor.w d0,d4
eor.w d1,d5
eor.w d4,d0
eor.w d5,d1
eor.w d0,d4
eor.w d1,d5
swap d4
swap d5
move.l d4,d6 ; Swap 2x4, part 1
move.l d5,d7
lsr.l #2,d6
lsr.l #2,d7
eor.l d0,d6
eor.l d1,d7
and.l #$33333333,d6
and.l #$33333333,d7
eor.l d6,d0
eor.l d7,d1
lsl.l #2,d6
lsl.l #2,d7
eor.l d6,d4
eor.l d7,d5
exg d4,a5
exg d5,a6
swap d4 ; Swap 16x4, part 2
swap d5
eor.w d2,d4
eor.w d3,d5
eor.w d4,d2
eor.w d5,d3
eor.w d2,d4
eor.w d3,d5
swap d4
swap d5
move.l d4,d6 ; Swap 2x4, part 1
move.l d5,d7
lsr.l #2,d6
lsr.l #2,d7
eor.l d2,d6
eor.l d3,d7
and.l #$33333333,d6
and.l #$33333333,d7
eor.l d6,d2
eor.l d7,d3
lsl.l #2,d6
lsl.l #2,d7
eor.l d6,d4
eor.l d7,d5
move.l d1,d6 ; Swap 4x1, part 1
move.l d3,d7
lsr.l #4,d6
lsr.l #4,d7
eor.l d0,d6
eor.l d2,d7
and.l #$0f0f0f0f,d6
and.l #$0f0f0f0f,d7
eor.l d6,d0
eor.l d7,d2
lsl.l #4,d6
lsl.l #4,d7
eor.l d6,d1
eor.l d7,d3
move.l d2,d6 ; Swap 8x2, part 1
move.l d3,d7
lsr.l #8,d6
lsr.l #8,d7
eor.l d0,d6
eor.l d1,d7
and.l #$00ff00ff,d6
and.l #$00ff00ff,d7
eor.l d6,d0
eor.l d7,d1
lsl.l #8,d6
lsl.l #8,d7
eor.l d6,d2
eor.l d7,d3
bra .start
cnop 0,4
.x
tst.b 32(a0)
move.l (a0)+,d0
move.l (a0)+,d1
move.l (a0)+,d2
move.l (a0)+,d3
tst.b 32(a0)
move.l (a0)+,d4
move.l (a0)+,d5
move.l (a0)+,a5
move.l (a0)+,a6
move.l d6,(a1)
swap d4 ; Swap 16x4, part 1
swap d5
eor.w d0,d4
eor.w d1,d5
eor.w d4,d0
eor.w d5,d1
eor.w d0,d4
sub.l c2p1x1_8_c5_040_delta1(pc),a1
eor.w d1,d5
swap d4
swap d5
move.l d4,d6 ; Swap 2x4, part 1
move.l d7,(a1)
move.l d5,d7
lsr.l #2,d6
lsr.l #2,d7
eor.l d0,d6
eor.l d1,d7
and.l #$33333333,d6
and.l #$33333333,d7
eor.l d6,d0
eor.l d7,d1
lsl.l #2,d6
lsl.l #2,d7
eor.l d6,d4
eor.l d7,d5
exg d4,a5
add.l c2p1x1_8_c5_040_delta2(pc),a1
exg d5,a6
swap d4 ; Swap 16x4, part 2
swap d5
eor.w d2,d4
eor.w d3,d5
eor.w d4,d2
eor.w d5,d3
eor.w d2,d4
eor.w d3,d5
swap d4
swap d5
move.l a3,(a1)
move.l d4,d6 ; Swap 2x4, part 2
move.l d5,d7
lsr.l #2,d6
lsr.l #2,d7
eor.l d2,d6
eor.l d3,d7
and.l #$33333333,d6
and.l #$33333333,d7
eor.l d6,d2
eor.l d7,d3
lsl.l #2,d6
lsl.l #2,d7
eor.l d6,d4
eor.l d7,d5
move.l d1,d6 ; Swap 4x1, part 1
move.l d3,d7
lsr.l #4,d6
lsr.l #4,d7
eor.l d0,d6
eor.l d2,d7
and.l #$0f0f0f0f,d6
and.l #$0f0f0f0f,d7
sub.l c2p1x1_8_c5_040_delta3(pc),a1
eor.l d6,d0
eor.l d7,d2
lsl.l #4,d6
lsl.l #4,d7
eor.l d6,d1
move.l a4,(a1)
eor.l d7,d3
move.l d2,d6 ; Swap 8x2, part 1
move.l d3,d7
lsr.l #8,d6
lsr.l #8,d7
eor.l d0,d6
eor.l d1,d7
and.l #$00ff00ff,d6
and.l #$00ff00ff,d7
eor.l d6,d0
eor.l d7,d1
lsl.l #8,d6
lsl.l #8,d7
eor.l d6,d2
add.l c2p1x1_8_c5_040_delta4(pc),a1
eor.l d7,d3
.start
move.l d2,d6 ; Swap 1x2, part 1
move.l d3,d7
lsr.l #1,d6
lsr.l #1,d7
eor.l d0,d6
eor.l d1,d7
and.l #$55555555,d6
and.l #$55555555,d7
eor.l d6,d0
eor.l d7,d1
move.l d0,(a1)
add.l d6,d6
add.l d7,d7
eor.l d6,d2
eor.l d7,d3
move.l a5,d6
move.l a6,d7
move.l d2,a3
move.l d3,a4
move.l d5,d2 ; Swap 4x1, part 2
move.l d7,d3
lsr.l #4,d2
lsr.l #4,d3
sub.l c2p1x1_8_c5_040_delta5(pc),a1
eor.l d4,d2
eor.l d6,d3
and.l #$0f0f0f0f,d2
and.l #$0f0f0f0f,d3
eor.l d2,d4
move.l d1,(a1)
eor.l d3,d6
lsl.l #4,d2
lsl.l #4,d3
eor.l d2,d5
eor.l d3,d7
move.l d4,d2 ; Swap 8x2, part 2
move.l d5,d3
lsr.l #8,d2
lsr.l #8,d3
add.l c2p1x1_8_c5_040_delta6(pc),a1
eor.l d6,d2
eor.l d7,d3
and.l #$00ff00ff,d2
and.l #$00ff00ff,d3
eor.l d2,d6
move.l a3,(a1)
eor.l d3,d7
lsl.l #8,d2
lsl.l #8,d3
eor.l d2,d4
eor.l d3,d5
move.l d4,d2 ; Swap 1x2, part 2
move.l d5,d3
sub.l c2p1x1_8_c5_040_delta7(pc),a1
lsr.l #1,d2
lsr.l #1,d3
eor.l d6,d2
eor.l d7,d3
and.l #$55555555,d2
move.l a4,(a1)
and.l #$55555555,d3
eor.l d2,d6
eor.l d3,d7
add.l d2,d2
add.l d3,d3
eor.l d2,d4
eor.l d3,d5
add.l c2p1x1_8_c5_040_delta8(pc),a1
move.l d4,a3
move.l d5,a4
cmp.l (sp),a0
bne .x
move.l d6,(a1)
sub.l c2p1x1_8_c5_040_delta1(pc),a1
move.l d7,(a1)
add.l c2p1x1_8_c5_040_delta2(pc),a1
move.l a3,(a1)
sub.l c2p1x1_8_c5_040_delta3(pc),a1
move.l a4,(a1)
addq.l #4,sp
.none movem.l (sp)+,d2-d7/a2-a6
rts
cnop 0,4
c2p1x1_8_c5_040_data
c2p1x1_8_c5_040_scroffs ds.l 1
c2p1x1_8_c5_040_pixels ds.l 1
c2p1x1_8_c5_040_delta0 ds.l 1
c2p1x1_8_c5_040_delta1 ds.l 1
c2p1x1_8_c5_040_delta2 ds.l 1
c2p1x1_8_c5_040_delta3 ds.l 1
c2p1x1_8_c5_040_delta4 ds.l 1
c2p1x1_8_c5_040_delta5 ds.l 1
c2p1x1_8_c5_040_delta6 ds.l 1
c2p1x1_8_c5_040_delta7 ds.l 1
c2p1x1_8_c5_040_delta8 ds.l 1