-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc2p1x1_6_c5_030.s
429 lines (352 loc) · 6.36 KB
/
c2p1x1_6_c5_030.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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
;
; 2000-04-17
;
; c2p1x1_6_c5_030
;
; 1.12vbl [all dma off] on Blizzard 1230-IV@50MHz
;
; 2000-04-17: added bplsize modifying init (smcinit)
; 1999-01-08: initial version
;
; bplsize must be less than or equal to 16kB!
;
xdef _c2p1x1_6_c5_030_smcinit
xdef c2p1x1_6_c5_030_smcinit
xdef _c2p1x1_6_c5_030_init
xdef c2p1x1_6_c5_030_init
xdef _c2p1x1_6_c5_030
xdef c2p1x1_6_c5_030
IFND BPLX
BPLX EQU 320
ENDC
IFND BPLY
BPLY EQU 180
ENDC
IFND BPLSIZE
BPLSIZE EQU BPLX*BPLY/8
ENDC
IFND CHUNKYXMAX
CHUNKYXMAX EQU BPLX
ENDC
IFND CHUNKYYMAX
CHUNKYYMAX EQU BPLY
ENDC
; incdir include:
include exec_lib.i
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
_c2p1x1_6_c5_030_smcinit
c2p1x1_6_c5_030_smcinit
movem.l d2-d3/d5/a6,-(sp)
andi.l #$ffff,d0
mulu.w d0,d3
lsr.l #3,d3
move.l d3,c2p1x1_6_c5_030_scroffs
mulu.w d0,d1
move.l d1,c2p1x1_6_c5_030_pixels
move.w d5,c2p1x1_6_c5_030_smc1
move.w d5,c2p1x1_6_c5_030_smc2
move.w d5,c2p1x1_6_c5_030_smc5
move.w d5,d0
neg.w d0
move.w d0,c2p1x1_6_c5_030_smc8
move.w d0,c2p1x1_6_c5_030_smc9
subq.w #4,d0
move.w d0,c2p1x1_6_c5_030_smc3
move.w d0,c2p1x1_6_c5_030_smc6
add.l d5,d5
move.w d5,c2p1x1_6_c5_030_smc4
add.l d5,d5
move.l d5,c2p1x1_6_c5_030_smc7
move.l $4.w,a6
jsr _LVOCacheClearU(a6)
movem.l (sp)+,d2-d3/d5/a6
rts
; 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
_c2p1x1_6_c5_030_init
c2p1x1_6_c5_030_init
movem.l d2-d3,-(sp)
andi.l #$ffff,d0
mulu.w d0,d3
lsr.l #3,d3
move.l d3,c2p1x1_6_c5_030_scroffs
mulu.w d0,d1
move.l d1,c2p1x1_6_c5_030_pixels
movem.l (sp)+,d2-d3
rts
; a0 c2pscreen
; a1 bitplanes
_c2p1x1_6_c5_030
c2p1x1_6_c5_030
movem.l d2-d7/a2-a6,-(sp)
move.l #$33333333,d5
move.l #$55555555,d6
move.l #$00ff00ff,a6
add.w #BPLSIZE,a1
c2p1x1_6_c5_030_smc1 EQU *-2
add.l c2p1x1_6_c5_030_scroffs,a1
move.l c2p1x1_6_c5_030_pixels,a2
add.l a0,a2
cmp.l a0,a2
beq .none
addq.l #4,a2
movem.l a0-a1,-(sp)
move.l (a0)+,d0
move.l (a0)+,d2
move.l (a0)+,d1
move.l (a0)+,d3
move.l #$0f0f0f0f,d4 ; Merge 4x1, part 1
and.l d4,d0
and.l d4,d2
lsl.l #4,d0
or.l d2,d0
and.l d4,d1
and.l d4,d3
move.l (a0)+,d2
lsl.l #4,d1
or.l d3,d1
move.l d1,a3
move.l (a0)+,d1
move.l (a0)+,d3
move.l (a0)+,d7
and.l d4,d1 ; Merge 4x1, part 2
and.l d4,d2
lsl.l #4,d2
or.l d1,d2
and.l d4,d3
and.l d4,d7
lsl.l #4,d3
or.l d7,d3
move.l a3,d1
move.w d2,d7 ; Swap 16x2
move.w d0,d2
swap d2
move.w d2,d0
move.w d7,d2
move.w d3,d7
move.w d1,d3
swap d3
move.w d3,d1
move.w d7,d3
bra.s .start1
.x1
move.l (a0)+,d2
move.l (a0)+,d1
move.l (a0)+,d3
move.l d7,BPLSIZE(a1)
c2p1x1_6_c5_030_smc2 EQU *-2
move.l #$0f0f0f0f,d4 ; Merge 4x1, part 1
and.l d4,d0
and.l d4,d2
lsl.l #4,d0
or.l d2,d0
and.l d4,d1
and.l d4,d3
lsl.l #4,d1
or.l d3,d1
move.l d1,a3
move.l (a0)+,d2
and.l d4,d2
lsl.l #4,d2
move.l (a0)+,d1
move.l (a0)+,d3
move.l (a0)+,d7
move.l a4,(a1)+
and.l d4,d1 ; Merge 4x1, part 2
or.l d1,d2
and.l d4,d3
and.l d4,d7
lsl.l #4,d3
or.l d7,d3
move.l a3,d1
move.w d2,d7 ; Swap 16x2
move.w d0,d2
swap d2
move.w d2,d0
move.w d7,d2
move.w d3,d7
move.w d1,d3
swap d3
move.w d3,d1
move.w d7,d3
move.l a5,-BPLSIZE-4(a1)
c2p1x1_6_c5_030_smc3 EQU *-2
.start1
move.l a6,d4
move.l d2,d7 ; Swap 2x2
lsr.l #2,d7
eor.l d0,d7
and.l d5,d7
eor.l d7,d0
lsl.l #2,d7
eor.l d7,d2
move.l d3,d7
lsr.l #2,d7
eor.l d1,d7
and.l d5,d7
eor.l d7,d1
lsl.l #2,d7
eor.l d7,d3
move.l d1,d7
lsr.l #8,d7
eor.l d0,d7
and.l d4,d7
eor.l d7,d0
lsl.l #8,d7
eor.l d7,d1
move.l d1,d7
lsr.l #1,d7
eor.l d0,d7
and.l d6,d7
eor.l d7,d0
move.l d0,BPLSIZE*2(a1)
c2p1x1_6_c5_030_smc4 EQU *-2
add.l d7,d7
eor.l d1,d7
move.l d3,d1
lsr.l #8,d1
eor.l d2,d1
and.l d4,d1
eor.l d1,d2
lsl.l #8,d1
eor.l d1,d3
move.l d3,d1
lsr.l #1,d1
eor.l d2,d1
and.l d6,d1
eor.l d1,d2
add.l d1,d1
eor.l d1,d3
move.l (a0)+,d0
move.l d2,a4
move.l d3,a5
cmpa.l a0,a2
bne .x1
move.l d7,BPLSIZE(a1)
c2p1x1_6_c5_030_smc5 EQU *-2
move.l a4,(a1)+
move.l a5,-BPLSIZE-4(a1)
c2p1x1_6_c5_030_smc6 EQU *-2
movem.l (sp)+,a0-a1
add.l #BPLSIZE*4,a1
c2p1x1_6_c5_030_smc7 EQU *-4
move.l #$30303030,a5
move.l (a0)+,d0
move.l (a0)+,d2
move.l (a0)+,d1
move.l (a0)+,d3
move.l a5,d4 ; Merge 4x1, part 1
and.l d4,d0
and.l d4,d2
lsr.l #4,d2
or.l d2,d0
and.l d4,d1
and.l d4,d3
move.l (a0)+,d2
lsr.l #4,d3
or.l d3,d1
move.l (a0)+,d5
move.l (a0)+,d3
move.l (a0)+,d7
and.l d4,d5 ; Merge 4x1, part 2
and.l d4,d2
lsr.l #4,d5
or.l d5,d2
and.l d4,d3
and.l d4,d7
lsr.l #4,d7
or.l d7,d3
move.w d2,d7 ; Swap 16x2
move.w d0,d2
swap d2
move.w d2,d0
move.w d7,d2
move.w d3,d7
move.w d1,d3
swap d3
move.w d3,d1
move.w d7,d3
bra.s .start2
.x2
move.l (a0)+,d2
move.l (a0)+,d1
move.l (a0)+,d3
move.l d7,-BPLSIZE(a1)
c2p1x1_6_c5_030_smc8 EQU *-2
move.l a5,d4 ; Merge 4x1, part 1
and.l d4,d0
and.l d4,d2
lsr.l #4,d2
or.l d2,d0
and.l d4,d1
and.l d4,d3
lsr.l #4,d3
or.l d3,d1
move.l (a0)+,d2
and.l d4,d2
move.l (a0)+,d5
move.l (a0)+,d3
move.l (a0)+,d7
move.l a4,(a1)+
and.l d4,d5 ; Merge 4x1, part 2
lsr.l #4,d5
or.l d5,d2
and.l d4,d3
and.l d4,d7
lsr.l #4,d7
or.l d7,d3
move.w d2,d7 ; Swap 16x2
move.w d0,d2
swap d2
move.w d2,d0
move.w d7,d2
move.w d3,d7
move.w d1,d3
swap d3
move.w d3,d1
move.w d7,d3
.start2
move.l a6,d4
lsl.l #2,d0 ; Merge 2x2
or.l d2,d0
lsl.l #2,d1
or.l d3,d1
move.l d1,d7 ; Swap 8x1
lsr.l #8,d7
eor.l d0,d7
and.l d4,d7
eor.l d7,d0
lsl.l #8,d7
eor.l d7,d1
move.l d1,d7 ; Swap 1x1
lsr.l #1,d7
eor.l d0,d7
and.l d6,d7
eor.l d7,d0
add.l d7,d7
eor.l d1,d7
move.l d0,a4
move.l (a0)+,d0
cmpa.l a0,a2
bne.s .x2
move.l d7,-BPLSIZE(a1)
c2p1x1_6_c5_030_smc9 EQU *-2
move.l a4,(a1)+
.none
movem.l (sp)+,d2-d7/a2-a6
rts
section bss,bss
c2p1x1_6_c5_030_scroffs ds.l 1
c2p1x1_6_c5_030_pixels ds.l 1