-
Notifications
You must be signed in to change notification settings - Fork 90
/
blit.h
518 lines (518 loc) · 11.7 KB
/
blit.h
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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
STATIC_INLINE uae_u32 blit_func(uae_u32 srca, uae_u32 srcb, uae_u32 srcc, uae_u8 mt)
{
switch(mt){
case 0x0:
return 0;
case 0x1:
return ~(srca | srcb | srcc);
case 0x2:
return (srcc & ~(srca | srcb));
case 0x3:
return ~(srca | srcb);
case 0x4:
return (srcb & ~(srca | srcc));
case 0x5:
return ~(srca | srcc);
case 0x6:
return (~srca & (srcb ^ srcc));
case 0x7:
return ~(srca | (srcb & srcc));
case 0x8:
return (~srca & srcb & srcc);
case 0x9:
return ~(srca | (srcb ^ srcc));
case 0xa:
return (~srca & srcc);
case 0xb:
return ~(srca | (srcb & ~srcc));
case 0xc:
return (~srca & srcb);
case 0xd:
return ~(srca | (~srcb & srcc));
case 0xe:
return (~srca & (srcb | srcc));
case 0xf:
return ~srca;
case 0x10:
return (srca & ~(srcb | srcc));
case 0x11:
return ~(srcb | srcc);
case 0x12:
return (~srcb & (srca ^ srcc));
case 0x13:
return ~(srcb | (srca & srcc));
case 0x14:
return (~srcc & (srca ^ srcb));
case 0x15:
return ~(srcc | (srca & srcb));
case 0x16:
return (srca ^ ((srca & srcb) | (srcb ^ srcc)));
case 0x17:
return ~(srca ^ ((srca ^ srcb) & (srca ^ srcc)));
case 0x18:
return ((srca ^ srcb) & (srca ^ srcc));
case 0x19:
return (srcb ^ (~srcc | (srca & srcb)));
case 0x1a:
return (srca ^ (srcc | (srca & srcb)));
case 0x1b:
return (srca ^ (srcc | ~(srca ^ srcb)));
case 0x1c:
return (srca ^ (srcb | (srca & srcc)));
case 0x1d:
return (srca ^ (srcb | ~(srca ^ srcc)));
case 0x1e:
return (srca ^ (srcb | srcc));
case 0x1f:
return ~(srca & (srcb | srcc));
case 0x20:
return (srca & ~srcb & srcc);
case 0x21:
return ~(srcb | (srca ^ srcc));
case 0x22:
return (~srcb & srcc);
case 0x23:
return ~(srcb | (srca & ~srcc));
case 0x24:
return ((srca ^ srcb) & (srcb ^ srcc));
case 0x25:
return (srca ^ (~srcc | (srca & srcb)));
case 0x26:
return (srcb ^ (srcc | (srca & srcb)));
case 0x27:
return ~(srca ^ (srcc & (srca ^ srcb)));
case 0x28:
return (srcc & (srca ^ srcb));
case 0x29:
return ~(srca ^ srcb ^ (srcc | (srca & srcb)));
case 0x2a:
return (srcc & ~(srca & srcb));
case 0x2b:
return ~(srca ^ ((srca ^ srcb) & (srcb ^ srcc)));
case 0x2c:
return (srcb ^ (srca & (srcb | srcc)));
case 0x2d:
return (srca ^ (srcb | ~srcc));
case 0x2e:
return (srca ^ (srcb | (srca ^ srcc)));
case 0x2f:
return ~(srca & (srcb | ~srcc));
case 0x30:
return (srca & ~srcb);
case 0x31:
return ~(srcb | (~srca & srcc));
case 0x32:
return (~srcb & (srca | srcc));
case 0x33:
return ~srcb;
case 0x34:
return (srcb ^ (srca | (srcb & srcc)));
case 0x35:
return (srcb ^ (srca | ~(srcb ^ srcc)));
case 0x36:
return (srcb ^ (srca | srcc));
case 0x37:
return ~(srcb & (srca | srcc));
case 0x38:
return (srca ^ (srcb & (srca | srcc)));
case 0x39:
return (srcb ^ (srca | ~srcc));
case 0x3a:
return (srcb ^ (srca | (srcb ^ srcc)));
case 0x3b:
return ~(srcb & (srca | ~srcc));
case 0x3c:
return (srca ^ srcb);
case 0x3d:
return (srca ^ (srcb | ~(srca | srcc)));
case 0x3e:
return (srca ^ (srcb | (srca ^ (srca | srcc))));
case 0x3f:
return ~(srca & srcb);
case 0x40:
return (srca & srcb & ~srcc);
case 0x41:
return ~(srcc | (srca ^ srcb));
case 0x42:
return ((srca ^ srcc) & (srcb ^ srcc));
case 0x43:
return (srca ^ (~srcb | (srca & srcc)));
case 0x44:
return (srcb & ~srcc);
case 0x45:
return ~(srcc | (srca & ~srcb));
case 0x46:
return (srcc ^ (srcb | (srca & srcc)));
case 0x47:
return ~(srca ^ (srcb & (srca ^ srcc)));
case 0x48:
return (srcb & (srca ^ srcc));
case 0x49:
return ~(srca ^ srcc ^ (srcb | (srca & srcc)));
case 0x4a:
return (srcc ^ (srca & (srcb | srcc)));
case 0x4b:
return (srca ^ (~srcb | srcc));
case 0x4c:
return (srcb & ~(srca & srcc));
case 0x4d:
return (srca ^ ((srca ^ srcb) | ~(srca ^ srcc)));
case 0x4e:
return (srca ^ (srcc | (srca ^ srcb)));
case 0x4f:
return ~(srca & (~srcb | srcc));
case 0x50:
return (srca & ~srcc);
case 0x51:
return ~(srcc | (~srca & srcb));
case 0x52:
return (srcc ^ (srca | (srcb & srcc)));
case 0x53:
return ~(srcb ^ (srca & (srcb ^ srcc)));
case 0x54:
return (~srcc & (srca | srcb));
case 0x55:
return ~srcc;
case 0x56:
return (srcc ^ (srca | srcb));
case 0x57:
return ~(srcc & (srca | srcb));
case 0x58:
return (srca ^ (srcc & (srca | srcb)));
case 0x59:
return (srcc ^ (srca | ~srcb));
case 0x5a:
return (srca ^ srcc);
case 0x5b:
return (srca ^ (srcc | ~(srca | srcb)));
case 0x5c:
return (srcc ^ (srca | (srcb ^ srcc)));
case 0x5d:
return ~(srcc & (srca | ~srcb));
case 0x5e:
return (srca ^ (srcc | (srca ^ (srca | srcb))));
case 0x5f:
return ~(srca & srcc);
case 0x60:
return (srca & (srcb ^ srcc));
case 0x61:
return ~(srcb ^ srcc ^ (srca | (srcb & srcc)));
case 0x62:
return (srcc ^ (srcb & (srca | srcc)));
case 0x63:
return (srcb ^ (~srca | srcc));
case 0x64:
return (srcb ^ (srcc & (srca | srcb)));
case 0x65:
return (srcc ^ (~srca | srcb));
case 0x66:
return (srcb ^ srcc);
case 0x67:
return (srcb ^ (srcc | ~(srca | srcb)));
case 0x68:
return ((srca & srcb) ^ (srcc & (srca | srcb)));
case 0x69:
return ~(srca ^ srcb ^ srcc);
case 0x6a:
return (srcc ^ (srca & srcb));
case 0x6b:
return ~(srca ^ srcb ^ (srcc & (srca | srcb)));
case 0x6c:
return (srcb ^ (srca & srcc));
case 0x6d:
return ~(srca ^ srcc ^ (srcb & (srca | srcc)));
case 0x6e:
return ((~srca & srcb) | (srcb ^ srcc));
case 0x6f:
return (~srca | (srcb ^ srcc));
case 0x70:
return (srca & ~(srcb & srcc));
case 0x71:
return ~(srca ^ ((srca ^ srcb) | (srca ^ srcc)));
case 0x72:
return (srcb ^ (srcc | (srca ^ srcb)));
case 0x73:
return ~(srcb & (~srca | srcc));
case 0x74:
return (srcc ^ (srcb | (srca ^ srcc)));
case 0x75:
return ~(srcc & (~srca | srcb));
case 0x76:
return (srcb ^ (srcc | (srca ^ (srca & srcb))));
case 0x77:
return ~(srcb & srcc);
case 0x78:
return (srca ^ (srcb & srcc));
case 0x79:
return ~(srcb ^ srcc ^ (srca & (srcb | srcc)));
case 0x7a:
return ((srca & ~srcb) | (srca ^ srcc));
case 0x7b:
return (~srcb | (srca ^ srcc));
case 0x7c:
return ((srca ^ srcb) | (srca & ~srcc));
case 0x7d:
return (~srcc | (srca ^ srcb));
case 0x7e:
return ((srca ^ srcb) | (srca ^ srcc));
case 0x7f:
return ~(srca & srcb & srcc);
case 0x80:
return (srca & srcb & srcc);
case 0x81:
return ~((srca ^ srcb) | (srca ^ srcc));
case 0x82:
return (srcc & ~(srca ^ srcb));
case 0x83:
return (srca ^ (~srcb | (srca & ~srcc)));
case 0x84:
return (srcb & ~(srca ^ srcc));
case 0x85:
return (srca ^ (~srcc | (srca & ~srcb)));
case 0x86:
return (srcb ^ srcc ^ (srca & (srcb | srcc)));
case 0x87:
return ~(srca ^ (srcb & srcc));
case 0x88:
return (srcb & srcc);
case 0x89:
return (srcb ^ (~srcc & (~srca | srcb)));
case 0x8a:
return (srcc & (~srca | srcb));
case 0x8b:
return (srca ^ (~srcb | (srca ^ srcc)));
case 0x8c:
return (srcb & (~srca | srcc));
case 0x8d:
return (srca ^ (~srcc | (srca ^ srcb)));
case 0x8e:
return (srca ^ ((srca ^ srcb) | (srca ^ srcc)));
case 0x8f:
return (~srca | (srcb & srcc));
case 0x90:
return (srca & ~(srcb ^ srcc));
case 0x91:
return (srcb ^ (~srcc | (~srca & srcb)));
case 0x92:
return (srca ^ srcc ^ (srcb & (srca | srcc)));
case 0x93:
return ~(srcb ^ (srca & srcc));
case 0x94:
return (srca ^ srcb ^ (srcc & (srca | srcb)));
case 0x95:
return ~(srcc ^ (srca & srcb));
case 0x96:
return (srca ^ srcb ^ srcc);
case 0x97:
return (srca ^ srcb ^ (srcc | ~(srca | srcb)));
case 0x98:
return (srcb ^ (~srcc & (srca | srcb)));
case 0x99:
return ~(srcb ^ srcc);
case 0x9a:
return (srcc ^ (srca & ~srcb));
case 0x9b:
return ~(srcb ^ (srcc & (srca | srcb)));
case 0x9c:
return (srcb ^ (srca & ~srcc));
case 0x9d:
return ~(srcc ^ (srcb & (srca | srcc)));
case 0x9e:
return (srcb ^ srcc ^ (srca | (srcb & srcc)));
case 0x9f:
return ~(srca & (srcb ^ srcc));
case 0xa0:
return (srca & srcc);
case 0xa1:
return (srca ^ (~srcc & (srca | ~srcb)));
case 0xa2:
return (srcc & (srca | ~srcb));
case 0xa3:
return (srcb ^ (~srca | (srcb ^ srcc)));
case 0xa4:
return (srca ^ (~srcc & (srca | srcb)));
case 0xa5:
return ~(srca ^ srcc);
case 0xa6:
return (srcc ^ (~srca & srcb));
case 0xa7:
return ~(srca ^ (srcc & (srca | srcb)));
case 0xa8:
return (srcc & (srca | srcb));
case 0xa9:
return ~(srcc ^ (srca | srcb));
case 0xaa:
return srcc;
case 0xab:
return (srcc | ~(srca | srcb));
case 0xac:
return (srcb ^ (srca & (srcb ^ srcc)));
case 0xad:
return ~(srcc ^ (srca | (srcb & srcc)));
case 0xae:
return (srcc | (~srca & srcb));
case 0xaf:
return (~srca | srcc);
case 0xb0:
return (srca & (~srcb | srcc));
case 0xb1:
return ~(srca ^ (srcc | (srca ^ srcb)));
case 0xb2:
return (srca ^ ((srca ^ srcc) & (srcb ^ srcc)));
case 0xb3:
return (~srcb | (srca & srcc));
case 0xb4:
return (srca ^ (srcb & ~srcc));
case 0xb5:
return ~(srcc ^ (srca & (srcb | srcc)));
case 0xb6:
return (srca ^ srcc ^ (srcb | (srca & srcc)));
case 0xb7:
return ~(srcb & (srca ^ srcc));
case 0xb8:
return (srca ^ (srcb & (srca ^ srcc)));
case 0xb9:
return ~(srcc ^ (srcb | (srca & srcc)));
case 0xba:
return (srcc | (srca & ~srcb));
case 0xbb:
return (~srcb | srcc);
case 0xbc:
return ((srca ^ srcb) | (srca & srcc));
case 0xbd:
return ((srca ^ srcb) | ~(srca ^ srcc));
case 0xbe:
return (srcc | (srca ^ srcb));
case 0xbf:
return (srcc | ~(srca & srcb));
case 0xc0:
return (srca & srcb);
case 0xc1:
return (srca ^ (~srcb & (srca | ~srcc)));
case 0xc2:
return (srca ^ (~srcb & (srca | srcc)));
case 0xc3:
return ~(srca ^ srcb);
case 0xc4:
return (srcb & (srca | ~srcc));
case 0xc5:
return ~(srcb ^ (srca | (srcb ^ srcc)));
case 0xc6:
return (srcb ^ (~srca & srcc));
case 0xc7:
return ~(srca ^ (srcb & (srca | srcc)));
case 0xc8:
return (srcb & (srca | srcc));
case 0xc9:
return ~(srcb ^ (srca | srcc));
case 0xca:
return (srcc ^ (srca & (srcb ^ srcc)));
case 0xcb:
return ~(srcb ^ (srca | (srcb & srcc)));
case 0xcc:
return srcb;
case 0xcd:
return (srcb | ~(srca | srcc));
case 0xce:
return (srcb | (~srca & srcc));
case 0xcf:
return (~srca | srcb);
case 0xd0:
return (srca & (srcb | ~srcc));
case 0xd1:
return ~(srca ^ (srcb | (srca ^ srcc)));
case 0xd2:
return (srca ^ (~srcb & srcc));
case 0xd3:
return ~(srcb ^ (srca & (srcb | srcc)));
case 0xd4:
return (srca ^ ((srca ^ srcb) & (srcb ^ srcc)));
case 0xd5:
return (~srcc | (srca & srcb));
case 0xd6:
return (srca ^ srcb ^ (srcc | (srca & srcb)));
case 0xd7:
return ~(srcc & (srca ^ srcb));
case 0xd8:
return (srca ^ (srcc & (srca ^ srcb)));
case 0xd9:
return ~(srcb ^ (srcc | (srca & srcb)));
case 0xda:
return ((srca & srcb) | (srca ^ srcc));
case 0xdb:
return ~((srca ^ srcb) & (srcb ^ srcc));
case 0xdc:
return (srcb | (srca & ~srcc));
case 0xdd:
return (srcb | ~srcc);
case 0xde:
return (srcb | (srca ^ srcc));
case 0xdf:
return (srcb | ~(srca & srcc));
case 0xe0:
return (srca & (srcb | srcc));
case 0xe1:
return ~(srca ^ (srcb | srcc));
case 0xe2:
return (srcc ^ (srcb & (srca ^ srcc)));
case 0xe3:
return ~(srca ^ (srcb | (srca & srcc)));
case 0xe4:
return (srcb ^ (srcc & (srca ^ srcb)));
case 0xe5:
return ~(srca ^ (srcc | (srca & srcb)));
case 0xe6:
return ((srca & srcb) | (srcb ^ srcc));
case 0xe7:
return ~((srca ^ srcb) & (srca ^ srcc));
case 0xe8:
return (srca ^ ((srca ^ srcb) & (srca ^ srcc)));
case 0xe9:
return (srca ^ srcb ^ (~srcc | (srca & srcb)));
case 0xea:
return (srcc | (srca & srcb));
case 0xeb:
return (srcc | ~(srca ^ srcb));
case 0xec:
return (srcb | (srca & srcc));
case 0xed:
return (srcb | ~(srca ^ srcc));
case 0xee:
return (srcb | srcc);
case 0xef:
return (~srca | srcb | srcc);
case 0xf0:
return srca;
case 0xf1:
return (srca | ~(srcb | srcc));
case 0xf2:
return (srca | (~srcb & srcc));
case 0xf3:
return (srca | ~srcb);
case 0xf4:
return (srca | (srcb & ~srcc));
case 0xf5:
return (srca | ~srcc);
case 0xf6:
return (srca | (srcb ^ srcc));
case 0xf7:
return (srca | ~(srcb & srcc));
case 0xf8:
return (srca | (srcb & srcc));
case 0xf9:
return (srca | ~(srcb ^ srcc));
case 0xfa:
return (srca | srcc);
case 0xfb:
return (srca | ~srcb | srcc);
case 0xfc:
return (srca | srcb);
case 0xfd:
return (srca | srcb | ~srcc);
case 0xfe:
return (srca | srcb | srcc);
case 0xff:
return 0xFFFFFFFF;
}
return 0;
}