-
Notifications
You must be signed in to change notification settings - Fork 0
/
2xSaImmx.asm
1359 lines (1145 loc) · 33.1 KB
/
2xSaImmx.asm
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
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;/*---------------------------------------------------------------------*
; * The following (piece of) code, (part of) the 2xSaI engine, *
; * copyright (c) 1999 by Derek Liauw Kie Fa. *
; * Non-Commercial use of the engine is allowed and is encouraged, *
; * provided that appropriate credit be given and that this copyright *
; * notice will not be removed under any circumstance. *
; * You may freely modify this code, but I request *
; * that any improvements to the engine be submitted to me, so *
; * that I can implement these improvements in newer versions of *
; * the engine. *
; * If you need more information, have any comments or suggestions, *
; * you can e-mail me. My e-mail: [email protected]. *
; *---------------------------------------------------------------------*/
;----------------------
; 2xSaI version 0.59 WIP, soon to become version 0.60
;----------------------
BITS 32
%ifdef __DJGPP__
GLOBAL __2xSaILine
GLOBAL __2xSaISuperEagleLine
GLOBAL _Init_2xSaIMMX
%else
GLOBAL __2xSaILine
GLOBAL __2xSaISuperEagleLine
GLOBAL _Init_2xSaIMMX
%endif
SECTION .text ALIGN = 32
%ifdef __DJGPP__
;EXTERN_C void _2xSaILine (uint8 *srcPtr, uint32 srcPitch, uint32 width,
; uint8 *dstPtr, uint32 dstPitch, uint16 dstSegment);
%else
;EXTERN_C void _2xSaILine (uint8 *srcPtr, uint32 srcPitch, uint32 width,
; uint8 *dstPtr, uint32 dstPitch);
%endif
srcPtr equ 8
deltaPtr equ 12
srcPitch equ 16
width equ 20
dstOffset equ 24
dstPitch equ 28
dstSegment equ 32
colorB0 equ -2
colorB1 equ 0
colorB2 equ 2
colorB3 equ 4
color7 equ -2
color8 equ 0
color9 equ 2
color4 equ -2
color5 equ 0
color6 equ 2
colorS2 equ 4
color1 equ -2
color2 equ 0
color3 equ 2
colorS1 equ 4
colorA0 equ -2
colorA1 equ 0
colorA2 equ 2
colorA3 equ 4
%ifdef __DJGPP__
__2xSaISuperEagleLine:
%else
__2xSaISuperEagleLine:
%endif
; Store some stuff
push ebp
mov ebp, esp
pushad
; Prepare the destination
%ifdef __DJGPP__
; Set the selector
mov eax, [ebp+dstSegment]
mov fs, ax
%endif
mov edx, [ebp+dstOffset] ; edx points to the screen
; Prepare the source
; eax points to colorA
mov eax, [ebp+srcPtr]
mov ebx, [ebp+srcPitch]
mov ecx, [ebp+width]
; eax now points to colorB1
sub eax, ebx
; Main Loop
.Loop: push ecx
;-----Check Delta------------------
mov ecx, [ebp+deltaPtr]
movq mm0, [eax+colorB0]
movq mm1, [eax+colorB3]
movq mm2, [eax+ebx+color4]
movq mm3, [eax+ebx+colorS2]
movq mm4, [eax+ebx+ebx+color1]
movq mm5, [eax+ebx+ebx+colorS1]
push eax
add eax, ebx
movq mm6, [eax+ebx+ebx+colorA0]
movq mm7, [eax+ebx+ebx+colorA3]
pop eax
pcmpeqw mm0, [ecx+2+colorB0]
pcmpeqw mm1, [ecx+2+colorB3]
pcmpeqw mm2, [ecx+ebx+2+color4]
pcmpeqw mm3, [ecx+ebx+2+colorS2]
pcmpeqw mm4, [ecx+ebx+ebx+2+color1]
pcmpeqw mm5, [ecx+ebx+ebx+2+colorS1]
add ecx, ebx
pcmpeqw mm6, [ecx+ebx+ebx+2+colorA0]
pcmpeqw mm7, [ecx+ebx+ebx+2+colorA3]
sub ecx, ebx
pand mm0, mm1
pand mm2, mm3
pand mm4, mm5
pand mm6, mm7
pand mm0, mm2
pand mm4, mm6
pxor mm7, mm7
pand mm0, mm4
movq mm6, [eax+colorB0]
pcmpeqw mm7, mm0
movq [ecx+2+colorB0], mm6
packsswb mm7, mm7
movd ecx, mm7
test ecx, ecx
jz near .SKIP_PROCESS
;End Delta
;---------------------------------
movq mm0, [eax+ebx+color5]
movq mm1, [eax+ebx+color6]
movq mm2, mm0
movq mm3, mm1
movq mm4, mm0
movq mm5, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3 ;mm0 contains the interpolated values
movq [I56Pixel], mm0
movq mm7, mm0
;-------------------
movq mm0, mm7
movq mm1, mm4 ;5,5,5,6
movq mm2, mm0
movq mm3, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3 ;mm0 contains the interpolated values
movq [product1a], mm0
;--------------------
movq mm0, mm7
movq mm1, mm5 ;6,6,6,5
movq mm2, mm0
movq mm3, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3
movq [product1b], mm0
;-------------------------
;-------------------------
movq mm0, [eax+ebx+ebx+color2]
movq mm1, [eax+ebx+ebx+color3]
movq mm2, mm0
movq mm3, mm1
movq mm4, mm0
movq mm5, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3
movq [I23Pixel], mm0
movq mm7, mm0
;---------------------
movq mm0, mm7
movq mm1, mm4 ;2,2,2,3
movq mm2, mm0
movq mm3, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3
movq [product2a], mm0
;----------------------
movq mm0, mm7
movq mm1, mm5 ;3,3,3,2
movq mm2, mm0
movq mm3, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3
movq [product2b], mm0
;////////////////////////////////
; Decide which "branch" to take
;--------------------------------
movq mm4, [eax+ebx+color5]
movq mm5, [eax+ebx+color6]
movq mm6, [eax+ebx+ebx+color3]
movq mm7, [eax+ebx+ebx+color2]
pxor mm3, mm3
movq mm0, mm4
movq mm1, mm5
pcmpeqw mm0, mm6
pcmpeqw mm1, mm7
pcmpeqw mm1, mm3
pand mm0, mm1
movq [Mask35], mm0
movq mm0, [eax+ebx+ebx+colorS1]
movq mm1, [eax+ebx+color4]
push eax
add eax, ebx
movq mm2, [eax+ebx+ebx+colorA2]
pop eax
movq mm3, [eax+colorB1]
pcmpeqw mm0, mm4
pcmpeqw mm1, mm4
pcmpeqw mm2, mm4
pcmpeqw mm3, mm4
pand mm0, mm1
pand mm2, mm3
por mm0, mm2
pand mm0, [Mask35]
movq [Mask35b], mm0
;-----------
pxor mm3, mm3
movq mm0, mm4
movq mm1, mm5
pcmpeqw mm0, mm6
pcmpeqw mm1, mm7
pcmpeqw mm0, mm3
pand mm0, mm1
movq [Mask26], mm0
movq mm0, [eax+ebx+ebx+color1]
movq mm1, [eax+ebx+colorS2]
push eax
add eax, ebx
movq mm2, [eax+ebx+ebx+colorA1]
pop eax
movq mm3, [eax+colorB2]
pcmpeqw mm0, mm5
pcmpeqw mm1, mm5
pcmpeqw mm2, mm5
pcmpeqw mm3, mm5
pand mm0, mm1
pand mm2, mm3
por mm0, mm2
pand mm0, [Mask26]
movq [Mask26b], mm0
;--------------------
movq mm0, mm4
movq mm1, mm5
movq mm2, mm0
pcmpeqw mm2, mm1
pcmpeqw mm0, mm6
pcmpeqw mm1, mm7
pand mm0, mm1
pand mm2, mm0
pxor mm0, mm2
movq mm7, mm0
;------------------
packsswb mm7, mm7
movd ecx, mm7
test ecx, ecx
jz near .SKIP_GUESS
;---------------------------------------------
; Map of the pixels: I|E F|J
; G|A B|K
; H|C D|L
; M|N O|P
movq mm6, mm0
movq mm4, [eax+ebx+color5]
movq mm5, [eax+ebx+color6]
pxor mm7, mm7
pand mm6, [ONE]
movq mm0, [eax+colorB1]
movq mm1, [eax+ebx+color4]
movq mm2, mm0
movq mm3, mm1
pcmpeqw mm0, mm4
pcmpeqw mm1, mm4
pcmpeqw mm2, mm5
pcmpeqw mm3, mm5
pand mm0, mm6
pand mm1, mm6
pand mm2, mm6
pand mm3, mm6
paddw mm0, mm1
paddw mm2, mm3
pxor mm3, mm3
pcmpgtw mm0, mm6
pcmpgtw mm2, mm6
pcmpeqw mm0, mm3
pcmpeqw mm2, mm3
pand mm0, mm6
pand mm2, mm6
paddw mm7, mm0
psubw mm7, mm2
movq mm0, [eax+colorB2]
movq mm1, [eax+ebx+colorS2]
movq mm2, mm0
movq mm3, mm1
pcmpeqw mm0, mm4
pcmpeqw mm1, mm4
pcmpeqw mm2, mm5
pcmpeqw mm3, mm5
pand mm0, mm6
pand mm1, mm6
pand mm2, mm6
pand mm3, mm6
paddw mm0, mm1
paddw mm2, mm3
pxor mm3, mm3
pcmpgtw mm0, mm6
pcmpgtw mm2, mm6
pcmpeqw mm0, mm3
pcmpeqw mm2, mm3
pand mm0, mm6
pand mm2, mm6
paddw mm7, mm0
psubw mm7, mm2
push eax
add eax, ebx
movq mm0, [eax+ebx+color1]
movq mm1, [eax+ebx+ebx+colorA1]
movq mm2, mm0
movq mm3, mm1
pcmpeqw mm0, mm4
pcmpeqw mm1, mm4
pcmpeqw mm2, mm5
pcmpeqw mm3, mm5
pand mm0, mm6
pand mm1, mm6
pand mm2, mm6
pand mm3, mm6
paddw mm0, mm1
paddw mm2, mm3
pxor mm3, mm3
pcmpgtw mm0, mm6
pcmpgtw mm2, mm6
pcmpeqw mm0, mm3
pcmpeqw mm2, mm3
pand mm0, mm6
pand mm2, mm6
paddw mm7, mm0
psubw mm7, mm2
movq mm0, [eax+ebx+colorS1]
movq mm1, [eax+ebx+ebx+colorA2]
movq mm2, mm0
movq mm3, mm1
pcmpeqw mm0, mm4
pcmpeqw mm1, mm4
pcmpeqw mm2, mm5
pcmpeqw mm3, mm5
pand mm0, mm6
pand mm1, mm6
pand mm2, mm6
pand mm3, mm6
paddw mm0, mm1
paddw mm2, mm3
pxor mm3, mm3
pcmpgtw mm0, mm6
pcmpgtw mm2, mm6
pcmpeqw mm0, mm3
pcmpeqw mm2, mm3
pand mm0, mm6
pand mm2, mm6
paddw mm7, mm0
psubw mm7, mm2
pop eax
movq mm1, mm7
pxor mm0, mm0
pcmpgtw mm7, mm0
pcmpgtw mm0, mm1
por mm7, [Mask35]
por mm1, [Mask26]
movq [Mask35], mm7
movq [Mask26], mm1
.SKIP_GUESS:
;Start the ASSEMBLY !!!
movq mm4, [Mask35]
movq mm5, [Mask26]
movq mm6, [Mask35b]
movq mm7, [Mask26b]
movq mm0, [eax+ebx+color5]
movq mm1, [eax+ebx+color6]
movq mm2, [eax+ebx+ebx+color2]
movq mm3, [eax+ebx+ebx+color3]
pcmpeqw mm0, mm2
pcmpeqw mm1, mm3
movq mm2, mm4
movq mm3, mm5
por mm0, mm1
por mm2, mm3
pand mm2, mm0
pxor mm0, mm2
movq mm3, mm0
movq mm2, mm0
pxor mm0, mm0
por mm2, mm4
pxor mm4, mm6
por mm2, mm5
pxor mm5, mm7
pcmpeqw mm2, mm0
;----------------
movq mm0, [eax+ebx+color5]
movq mm1, mm3
por mm1, mm4
por mm1, mm6
pand mm0, mm1
movq mm1, mm5
pand mm1, [I56Pixel]
por mm0, mm1
movq mm1, mm7
pand mm1, [product1b]
por mm0, mm1
movq mm1, mm2
pand mm1, [product1a]
por mm0, mm1
movq [final1a], mm0
movq mm0, [eax+ebx+color6]
movq mm1, mm3
por mm1, mm5
por mm1, mm7
pand mm0, mm1
movq mm1, mm4
pand mm1, [I56Pixel]
por mm0, mm1
movq mm1, mm6
pand mm1, [product1a]
por mm0, mm1
movq mm1, mm2
pand mm1, [product1b]
por mm0, mm1
movq [final1b], mm0
movq mm0, [eax+ebx+ebx+color2]
movq mm1, mm3
por mm1, mm5
por mm1, mm7
pand mm0, mm1
movq mm1, mm4
pand mm1, [I23Pixel]
por mm0, mm1
movq mm1, mm6
pand mm1, [product2b]
por mm0, mm1
movq mm1, mm2
pand mm1, [product2a]
por mm0, mm1
movq [final2a], mm0
movq mm0, [eax+ebx+ebx+color3]
movq mm1, mm3
por mm1, mm4
por mm1, mm6
pand mm0, mm1
movq mm1, mm5
pand mm1, [I23Pixel]
por mm0, mm1
movq mm1, mm7
pand mm1, [product2a]
por mm0, mm1
movq mm1, mm2
pand mm1, [product2b]
por mm0, mm1
movq [final2b], mm0
movq mm0, [final1a]
movq mm2, [final1b]
movq mm1, mm0
movq mm4, [final2a]
movq mm6, [final2b]
movq mm5, mm4
punpcklwd mm0, mm2
punpckhwd mm1, mm2
punpcklwd mm4, mm6
punpckhwd mm5, mm6
%ifdef __DJGPP__
movq [fs:edx], mm0
movq [fs:edx+8], mm1
push edx
add edx, [ebp+dstPitch]
movq [fs:edx], mm4
movq [fs:edx+8], mm5
pop edx
%else
movq [edx], mm0
movq [edx+8], mm1
push edx
add edx, [ebp+dstPitch]
movq [edx], mm4
movq [edx+8], mm5
pop edx
%endif
.SKIP_PROCESS:
mov ecx, [ebp+deltaPtr]
add ecx, 8
mov [ebp+deltaPtr], ecx
add edx, 16
add eax, 8
pop ecx
sub ecx, 4
cmp ecx, 0
jg near .Loop
; Restore some stuff
popad
mov esp, ebp
pop ebp
emms
ret
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
;-------------------------------------------------------------------------
;This is version 0.50
colorI equ -2
colorE equ 0
colorF equ 2
colorJ equ 4
colorG equ -2
colorA equ 0
colorB equ 2
colorK equ 4
colorH equ -2
colorC equ 0
colorD equ 2
colorL equ 4
colorM equ -2
colorN equ 0
colorO equ 2
colorP equ 4
%ifdef __DJGPP__
__2xSaILine:
%else
__2xSaILine:
%endif
; Store some stuff
push ebp
mov ebp, esp
pushad
; Prepare the destination
%ifdef __DJGPP__
; Set the selector
mov eax, [ebp+dstSegment]
mov fs, ax
%endif
mov edx, [ebp+dstOffset] ; edx points to the screen
; Prepare the source
; eax points to colorA
mov eax, [ebp+srcPtr]
mov ebx, [ebp+srcPitch]
mov ecx, [ebp+width]
; eax now points to colorE
sub eax, ebx
; Main Loop
.Loop: push ecx
;-----Check Delta------------------
mov ecx, [ebp+deltaPtr]
movq mm0, [eax+colorI]
movq mm1, [eax+colorJ]
movq mm2, [eax+ebx+colorG]
movq mm3, [eax+ebx+colorK]
movq mm4, [eax+ebx+ebx+colorH]
movq mm5, [eax+ebx+ebx+colorL]
push eax
add eax, ebx
movq mm6, [eax+ebx+ebx+colorM]
movq mm7, [eax+ebx+ebx+colorP]
pop eax
pcmpeqw mm0, [ecx+2+colorI]
pcmpeqw mm1, [ecx+2+colorK]
pcmpeqw mm2, [ecx+ebx+2+colorG]
pcmpeqw mm3, [ecx+ebx+2+colorK]
pcmpeqw mm4, [ecx+ebx+ebx+2+colorH]
pcmpeqw mm5, [ecx+ebx+ebx+2+colorL]
add ecx, ebx
pcmpeqw mm6, [ecx+ebx+ebx+2+colorM]
pcmpeqw mm7, [ecx+ebx+ebx+2+colorP]
sub ecx, ebx
pand mm0, mm1
pand mm2, mm3
pand mm4, mm5
pand mm6, mm7
pand mm0, mm2
pand mm4, mm6
pxor mm7, mm7
pand mm0, mm4
movq mm6, [eax+colorI]
pcmpeqw mm7, mm0
movq [ecx+2+colorI], mm6
packsswb mm7, mm7
movd ecx, mm7
test ecx, ecx
jz near .SKIP_PROCESS
;End Delta
;---------------------------------
;1
;if ((colorA == colorD) && (colorB != colorC) && (colorA == colorE) && (colorB == colorL)
movq mm0, [eax+ebx+colorA] ;mm0 and mm1 contain colorA
movq mm2, [eax+ebx+colorB] ;mm2 and mm3 contain colorB
movq mm1, mm0
movq mm3, mm2
pcmpeqw mm0, [eax+ebx+ebx+colorD]
pcmpeqw mm1, [eax+colorE]
pcmpeqw mm2, [eax+ebx+ebx+colorL]
pcmpeqw mm3, [eax+ebx+ebx+colorC]
pand mm0, mm1
pxor mm1, mm1
pand mm0, mm2
pcmpeqw mm3, mm1
pand mm0, mm3 ;result in mm0
;if ((colorA == colorC) && (colorB != colorE) && (colorA == colorF) && (colorB == colorJ)
movq mm4, [eax+ebx+colorA] ;mm4 and mm5 contain colorA
movq mm6, [eax+ebx+colorB] ;mm6 and mm7 contain colorB
movq mm5, mm4
movq mm7, mm6
pcmpeqw mm4, [eax+ebx+ebx+colorC]
pcmpeqw mm5, [eax+colorF]
pcmpeqw mm6, [eax+colorJ]
pcmpeqw mm7, [eax+colorE]
pand mm4, mm5
pxor mm5, mm5
pand mm4, mm6
pcmpeqw mm7, mm5
pand mm4, mm7 ;result in mm4
por mm0, mm4 ;combine the masks
movq [Mask1], mm0
;--------------------------------------------
;2
;if ((colorB == colorC) && (colorA != colorD) && (colorB == colorF) && (colorA == colorH)
movq mm0, [eax+ebx+colorB] ;mm0 and mm1 contain colorB
movq mm2, [eax+ebx+colorA] ;mm2 and mm3 contain colorA
movq mm1, mm0
movq mm3, mm2
pcmpeqw mm0, [eax+ebx+ebx+colorC]
pcmpeqw mm1, [eax+colorF]
pcmpeqw mm2, [eax+ebx+ebx+colorH]
pcmpeqw mm3, [eax+ebx+ebx+colorD]
pand mm0, mm1
pxor mm1, mm1
pand mm0, mm2
pcmpeqw mm3, mm1
pand mm0, mm3 ;result in mm0
;if ((colorB == colorE) && (colorB == colorD) && (colorA != colorF) && (colorA == colorI)
movq mm4, [eax+ebx+colorB] ;mm4 and mm5 contain colorB
movq mm6, [eax+ebx+colorA] ;mm6 and mm7 contain colorA
movq mm5, mm4
movq mm7, mm6
pcmpeqw mm4, [eax+ebx+ebx+colorD]
pcmpeqw mm5, [eax+colorE]
pcmpeqw mm6, [eax+colorI]
pcmpeqw mm7, [eax+colorF]
pand mm4, mm5
pxor mm5, mm5
pand mm4, mm6
pcmpeqw mm7, mm5
pand mm4, mm7 ;result in mm4
por mm0, mm4 ;combine the masks
movq [Mask2], mm0
;interpolate colorA and colorB
movq mm0, [eax+ebx+colorA]
movq mm1, [eax+ebx+colorB]
movq mm2, mm0
movq mm3, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3 ;mm0 contains the interpolated values
;assemble the pixels
movq mm1, [eax+ebx+colorA]
movq mm2, [eax+ebx+colorB]
movq mm3, [Mask1]
movq mm5, mm1
movq mm4, [Mask2]
movq mm6, mm1
pand mm1, mm3
por mm3, mm4
pxor mm7, mm7
pand mm2, mm4
pcmpeqw mm3, mm7
por mm1, mm2
pand mm0, mm3
por mm0, mm1
punpcklwd mm5, mm0
punpckhwd mm6, mm0
%ifdef __DJGPP__
movq [fs:edx], mm5
movq [fs:edx+8], mm6
%else
movq [edx], mm5
movq [edx+8], mm6
%endif
;------------------------------------------------
; Create the Nextline
;------------------------------------------------
;3 ;if ((colorA == colorD) && (colorB != colorC) && (colorA == colorG) && (colorC == colorO)
movq mm0, [eax+ebx+colorA] ;mm0 and mm1 contain colorA
movq mm2, [eax+ebx+ebx+colorC] ;mm2 and mm3 contain colorC
movq mm1, mm0
movq mm3, mm2
push eax
add eax, ebx
pcmpeqw mm0, [eax+ebx+colorD]
pcmpeqw mm1, [eax+colorG]
pcmpeqw mm2, [eax+ebx+ebx+colorO]
pcmpeqw mm3, [eax+colorB]
pop eax
pand mm0, mm1
pxor mm1, mm1
pand mm0, mm2
pcmpeqw mm3, mm1
pand mm0, mm3 ;result in mm0
;if ((colorA == colorB) && (colorG != colorC) && (colorA == colorH) && (colorC == colorM)
movq mm4, [eax+ebx+colorA] ;mm4 and mm5 contain colorA
movq mm6, [eax+ebx+ebx+colorC] ;mm6 and mm7 contain colorC
movq mm5, mm4
movq mm7, mm6
push eax
add eax, ebx
pcmpeqw mm4, [eax+ebx+colorH]
pcmpeqw mm5, [eax+colorB]
pcmpeqw mm6, [eax+ebx+ebx+colorM]
pcmpeqw mm7, [eax+colorG]
pop eax
pand mm4, mm5
pxor mm5, mm5
pand mm4, mm6
pcmpeqw mm7, mm5
pand mm4, mm7 ;result in mm4
por mm0, mm4 ;combine the masks
movq [Mask1], mm0
;--------------------------------------------
;4
;if ((colorB == colorC) && (colorA != colorD) && (colorC == colorH) && (colorA == colorF)
movq mm0, [eax+ebx+ebx+colorC] ;mm0 and mm1 contain colorC
movq mm2, [eax+ebx+colorA] ;mm2 and mm3 contain colorA
movq mm1, mm0
movq mm3, mm2
pcmpeqw mm0, [eax+ebx+colorB]
pcmpeqw mm1, [eax+ebx+ebx+colorH]
pcmpeqw mm2, [eax+colorF]
pcmpeqw mm3, [eax+ebx+ebx+colorD]
pand mm0, mm1
pxor mm1, mm1
pand mm0, mm2
pcmpeqw mm3, mm1
pand mm0, mm3 ;result in mm0
;if ((colorC == colorG) && (colorC == colorD) && (colorA != colorH) && (colorA == colorI)
movq mm4, [eax+ebx+ebx+colorC] ;mm4 and mm5 contain colorC
movq mm6, [eax+ebx+colorA] ;mm6 and mm7 contain colorA
movq mm5, mm4
movq mm7, mm6
pcmpeqw mm4, [eax+ebx+ebx+colorD]
pcmpeqw mm5, [eax+ebx+colorG]
pcmpeqw mm6, [eax+colorI]
pcmpeqw mm7, [eax+ebx+ebx+colorH]
pand mm4, mm5
pxor mm5, mm5
pand mm4, mm6
pcmpeqw mm7, mm5
pand mm4, mm7 ;result in mm4
por mm0, mm4 ;combine the masks
movq [Mask2], mm0
;----------------------------------------------
;interpolate colorA and colorC
movq mm0, [eax+ebx+colorA]
movq mm1, [eax+ebx+ebx+colorC]
movq mm2, mm0
movq mm3, mm1
pand mm0, [colorMask]
pand mm1, [colorMask]
psrlw mm0, 1
psrlw mm1, 1
pand mm3, [lowPixelMask]
paddw mm0, mm1
pand mm3, mm2
paddw mm0, mm3 ;mm0 contains the interpolated values
;-------------
;assemble the pixels
movq mm1, [eax+ebx+colorA]
movq mm2, [eax+ebx+ebx+colorC]
movq mm3, [Mask1]
movq mm4, [Mask2]
pand mm1, mm3
pand mm2, mm4
por mm3, mm4
pxor mm7, mm7
por mm1, mm2
pcmpeqw mm3, mm7
pand mm0, mm3
por mm0, mm1
movq [ACPixel], mm0
;////////////////////////////////
; Decide which "branch" to take
;--------------------------------
movq mm0, [eax+ebx+colorA]
movq mm1, [eax+ebx+colorB]
movq mm6, mm0
movq mm7, mm1
pcmpeqw mm0, [eax+ebx+ebx+colorD]
pcmpeqw mm1, [eax+ebx+ebx+colorC]
pcmpeqw mm6, mm7
movq mm2, mm0