-
Notifications
You must be signed in to change notification settings - Fork 74
/
UFilters.a
2659 lines (1981 loc) · 41.9 KB
/
UFilters.a
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
;Photoshop version 1.0.1, file: UFilters.a
; Computer History Museum, www.computerhistory.org
; This material is (C)Copyright 1990 Adobe Systems Inc.
; It may not be distributed to third parties.
; It is licensed for non-commercial use according to
; www.computerhistory.org/softwarelicense/photoshop/
INCLUDE 'Traps.a'
; **********************************************************************
SEG 'ADoCommand'
UpdateTotals PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE UpdateTotals (buffPtr: Ptr;
; dataPtr: Ptr;
; count: INTEGER;
; radius: INTEGER;
; add: BOOLEAN);
;
; Parameter Offsets
@buffPtr EQU 18
@dataPtr EQU 14
@count EQU 12
@radius EQU 10
@add EQU 8
; Size of parameters
@params EQU 14
; Save registers
LINK A6,#0
; Unload addresses
MOVE.L @buffPtr(A6),A0
MOVE.L @dataPtr(A6),A1
; Use first pixel radius times
MOVE.W @radius(A6),D0
SUB.W #1,D0
CLR.W D1
MOVE.B (A1),D1
TST.B @add(A6)
BNE.S @1
NEG.W D1
@1 ADD.W D1,(A0)+
DBF D0,@1
; Now use count pixels
MOVE.W @count(A6),D0
SUB.W #1,D0
CLR.W D1
TST.B @add(A6)
BEQ.S @3
@2 MOVE.B (A1)+,D1
ADD.W D1,(A0)+
DBF D0,@2
BRA.S @4
@3 MOVE.B (A1)+,D1
SUB.W D1,(A0)+
DBF D0,@3
; Use last pixel radius times
@4 MOVE.W @radius(A6),D0
SUB.W #1,D0
TST.B @add(A6)
BNE.S @5
NEG.W D1
@5 ADD.W D1,(A0)+
DBF D0,@5
; Clean up and exit
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoCommand'
DoBoxFilter PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE DoBoxFilter (buffPtr: Ptr;
; dataPtr: Ptr;
; radius: INTEGER;
; count: INTEGER);
;
; Parameter Offsets
@buffPtr EQU 16
@dataPtr EQU 12
@radius EQU 10
@count EQU 8
; Size of parameters
@params EQU 12
; Save registers
LINK A6,#0
MOVEM.L A2/D3-D4,-(SP)
; Unload address
MOVE.L @buffPtr(A6),A0
MOVE.L A0,A1
MOVE.L @dataPtr(A6),A2
; D0 = area of box
MOVE.W @radius(A6),D0
ASL.W #1,D0
ADD.W #1,D0
MULU.W D0,D0
; Compute initial total
MOVE.L D0,D1
ASR.L #1,D1
MOVE.W @radius(A6),D2
ASL.W #1,D2
SUB.W #1,D2
CLR.L D3
@1 MOVE.W (A0)+,D3
ADD.L D3,D1
DBF D2,@1
; Initialize loop
MOVE.W @count(A6),D2
SUB.W #1,D2
; Add in leading total
@2 MOVE.W (A0)+,D3
ADD.L D3,D1
; Compute output value
MOVE.L D1,D4
DIVU.W D0,D4
MOVE.B D4,(A2)+
; Subtract trailing total
MOVE.W (A1)+,D3
SUB.L D3,D1
; Move to next pixel
DBF D2,@2
; Clean up and exit
MOVEM.L (SP)+,A2/D3-D4
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoCommand'
DoWeightedFilter PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE DoWeightedFilter (srcPtr: Ptr;
; dstPtr: Ptr;
; step: INTEGER;
; count: INTEGER;
; radius: INTEGER;
; weights: Ptr);
;
; Parameter Offsets
@srcPtr EQU 22
@dstPtr EQU 18
@step EQU 16
@count EQU 14
@radius EQU 12
@weights EQU 8
; Size of parameters
@params EQU 18
; Save registers
LINK A6,#0
MOVEM.L A2-A4/D3-D5,-(SP)
; Unload parameters
MOVE.L @srcPtr(A6),A0
MOVE.L @dstPtr(A6),A1
MOVE.L @weights(A6),A2
MOVE.W @step(A6),D0
MOVE.W @count(A6),D1
SUB.W #1,D1
MOVE.W @radius(A6),D2
ASL.W #1,D2
; Compute weighted average
@1 MOVE.L A0,A3
ADDA.W #1,A0
MOVE.L A2,A4
MOVE.W D2,D3
MOVE.L #$8000,D4
@2 CLR.W D5
MOVE.B (A3),D5
ADDA.W D0,A3
MULU.W (A4)+,D5
ADD.L D5,D4
DBF D3,@2
SWAP D4
MOVE.B D4,(A1)+
DBF D1,@1
; Clean up and exit
MOVEM.L (SP)+,A2-A4/D3-D5
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoFilter'
SobelLine PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE SobelLine (prevPtr: Ptr;
; thisPtr: Ptr;
; nextPtr: Ptr;
; destPtr: Ptr;
; count: INTEGER;
; atStart: BOOLEAN;
; atEnd: BOOLEAN);
;
; Parameter Offsets
@prevPtr EQU 26
@thisPtr EQU 22
@nextPtr EQU 18
@destPtr EQU 14
@count EQU 12
@atStart EQU 10
@atEnd EQU 8
; Size of parameters
@params EQU 22
; Local variables
@p1 EQU -2
@p2 EQU -4
@p3 EQU -6
@p4 EQU -8
@p5 EQU -10
@p6 EQU -12
@p7 EQU -14
@p8 EQU -16
@p9 EQU -18
; Size of local variables
@localVars EQU -18
; Save registers
LINK A6,#@localVars
MOVEM.L A2-A4,-(SP)
; Unload pointers
MOVE.L @prevPtr(A6),A0
MOVE.L @thisPtr(A6),A1
MOVE.L @nextPtr(A6),A2
MOVE.L @destPtr(A6),A3
; Load hypot table
LEA @table,A4
; Initialize local variables
CLR.W @p1(A6)
CLR.W @p2(A6)
CLR.W @p3(A6)
CLR.W @p4(A6)
CLR.W @p5(A6)
CLR.W @p6(A6)
CLR.W @p7(A6)
CLR.W @p8(A6)
CLR.W @p9(A6)
; Initialize loop
MOVE.W @count(A6),D0
SUB.W #1,D0
; Copy pixel values to local variables
@1 MOVE.B -1(A0),@p1+1(A6)
MOVE.B (A0)+,@p2+1(A6)
MOVE.B (A0),@p3+1(A6)
MOVE.B -1(A1),@p4+1(A6)
MOVE.B (A1)+,@p5+1(A6)
MOVE.B (A1),@p6+1(A6)
MOVE.B -1(A2),@p7+1(A6)
MOVE.B (A2)+,@p8+1(A6)
MOVE.B (A2),@p9+1(A6)
; If at start, copy center column to first column
TST.B @atStart(A6)
BEQ.S @2
CLR.B @atStart(A6)
MOVE.W @p2(A6),@p1(A6)
MOVE.W @p5(A6),@p4(A6)
MOVE.W @p8(A6),@p7(A6)
; If at end, copy center column to last column
@2 TST.W D0
BNE.S @3
TST.B @atEnd(A6)
BEQ.S @3
MOVE.W @p2(A6),@p3(A6)
MOVE.W @p5(A6),@p6(A6)
MOVE.W @p8(A6),@p9(A6)
; Compute x
@3 MOVE.W @p3(A6),D1
ADD.W @p6(A6),D1
ADD.W @p6(A6),D1
ADD.W @p9(A6),D1
SUB.W @p1(A6),D1
SUB.W @p4(A6),D1
SUB.W @p4(A6),D1
SUB.W @p7(A6),D1
; Compute abs value
BPL.S @4
NEG.W D1
; Compute y
@4 MOVE.W @p1(A6),D2
ADD.W @p2(A6),D2
ADD.W @p2(A6),D2
ADD.W @p3(A6),D2
SUB.W @p7(A6),D2
SUB.W @p8(A6),D2
SUB.W @p8(A6),D2
SUB.W @p9(A6),D2
; Compute abs value
BPL.S @5
NEG.W D2
; Make D2 the larger
@5 CMP.W D1,D2
BGE.S @6
EXG D1,D2
; Make sure both are not zero
@6 TST.W D2
BEQ.S @7
; Compute table index
EXT.L D1
LSL.L #8,D1
DIVU.W D2,D1
; Scale by table value
LSL.W #1,D1
MULU.W (A4,D1.W),D2
LSL.L #2,D2
SWAP D2
; Truncate to 255
CMP.W #255,D2
BLE.S @7
MOVE.L #-1,D2
; Store and move to next pixel
@7 MOVE.B D2,(A3)+
DBF D0,@1
; Clean up and exit
MOVEM.L (SP)+,A2-A4
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; Hypotenuse Table
@table DC.W 16384,16384,16384,16385,16386,16387,16388,16390
DC.W 16392,16394,16396,16399,16402,16405,16408,16412
DC.W 16416,16420,16424,16429,16434,16439,16444,16450
DC.W 16456,16462,16468,16475,16482,16489,16496,16504
DC.W 16512,16520,16528,16536,16545,16554,16564,16573
DC.W 16583,16593,16603,16614,16624,16635,16646,16658
DC.W 16670,16681,16694,16706,16719,16731,16745,16758
DC.W 16771,16785,16799,16813,16828,16843,16858,16873
DC.W 16888,16904,16920,16936,16952,16969,16985,17002
DC.W 17020,17037,17055,17073,17091,17109,17128,17146
DC.W 17165,17185,17204,17224,17243,17264,17284,17304
DC.W 17325,17346,17367,17388,17410,17432,17454,17476
DC.W 17498,17521,17543,17566,17590,17613,17637,17660
DC.W 17684,17709,17733,17758,17782,17807,17832,17858
DC.W 17883,17909,17935,17961,17988,18014,18041,18068
DC.W 18095,18122,18149,18177,18205,18233,18261,18289
DC.W 18318,18347,18375,18405,18434,18463,18493,18523
DC.W 18552,18583,18613,18643,18674,18705,18736,18767
DC.W 18798,18830,18861,18893,18925,18957,18989,19022
DC.W 19054,19087,19120,19153,19186,19220,19253,19287
DC.W 19321,19355,19389,19423,19458,19492,19527,19562
DC.W 19597,19632,19667,19703,19739,19774,19810,19846
DC.W 19882,19919,19955,19992,20029,20066,20103,20140
DC.W 20177,20214,20252,20290,20327,20365,20403,20442
DC.W 20480,20518,20557,20596,20635,20674,20713,20752
DC.W 20791,20831,20870,20910,20950,20990,21030,21070
DC.W 21110,21151,21191,21232,21273,21314,21355,21396
DC.W 21437,21478,21520,21561,21603,21645,21686,21728
DC.W 21771,21813,21855,21897,21940,21983,22025,22068
DC.W 22111,22154,22197,22240,22284,22327,22371,22414
DC.W 22458,22502,22546,22590,22634,22678,22722,22767
DC.W 22811,22856,22901,22945,22990,23035,23080,23125
DC.W 23170
; **********************************************************************
SEG 'ADoCommand'
MinOrMaxRow PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE MinOrMaxRow (srcPtr: Ptr;
; dstPtr: Ptr;
; count: INTEGER;
; maxFlag: BOOLEAN);
;
; Parameter Offsets
@srcPtr EQU 16
@dstPtr EQU 12
@count EQU 10
@maxFlag EQU 8
; Size of parameters
@params EQU 12
; Save registers
LINK A6,#0
MOVE.L D3,-(SP)
; Unload pointers
MOVE.L @srcPtr(A6),A0
MOVE.L @dstPtr(A6),A1
; Initial 3 pixel wide buffer
MOVE.B (A0)+,D3
MOVE.B D3,D2
; Loop through all except last
MOVE.W @count(A6),D0
SUB.W #2,D0
; If only 1 pixel wide, just copy it
BPL.S @1
MOVE.B D2,(A1)
BRA.S @exit
; Decide which loop to use
@1 TST.B @maxFlag(A6)
BNE.S @6
; Minimum value loop
@2 MOVE.B D2,D1
MOVE.B D3,D2
MOVE.B (A0)+,D3
CMP.B D2,D1
BLS.S @3
MOVE.B D2,D1
@3 CMP.B D3,D1
BLS.S @4
MOVE.B D3,D1
@4 MOVE.B D1,(A1)+
DBF D0,@2
CMP.B D3,D2
BLS.S @5
MOVE.B D3,D2
@5 MOVE.B D2,(A1)
BRA.S @exit
; Maximum value loop
@6 MOVE.B D2,D1
MOVE.B D3,D2
MOVE.B (A0)+,D3
CMP.B D2,D1
BHS.S @7
MOVE.B D2,D1
@7 CMP.B D3,D1
BHS.S @8
MOVE.B D3,D1
@8 MOVE.B D1,(A1)+
DBF D0,@6
CMP.B D3,D2
BHS.S @9
MOVE.B D3,D2
@9 MOVE.B D2,(A1)
; Clean up and exit
@exit MOVE.L (SP)+,D3
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoCommand'
MinOrMaxRows PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE MinOrMaxRows (prevPtr: Ptr;
; thisPtr: Ptr;
; nextPtr: Ptr;
; destPtr: Ptr;
; count: INTEGER;
; maxFlag: BOOLEAN);
;
; Parameter Offsets
@prevPtr EQU 24
@thisPtr EQU 20
@nextPtr EQU 16
@destPtr EQU 12
@count EQU 10
@maxFlag EQU 8
; Size of parameters
@params EQU 20
; Save registers
LINK A6,#0
MOVEM.L A2-A3,-(SP)
; Unload pointers
MOVE.L @prevPtr(A6),A0
MOVE.L @thisPtr(A6),A1
MOVE.L @nextPtr(A6),A2
MOVE.L @destPtr(A6),A3
; Initialize loop
MOVE.W @count(A6),D0
SUB.W #1,D0
; Decide which loop to use
TST.B @maxFlag(A6)
BNE.S @4
; Minimum value loop
@1 MOVE.B (A0)+,D1
MOVE.B (A1)+,D2
CMP.B D2,D1
BLS.S @2
MOVE.B D2,D1
@2 MOVE.B (A2)+,D2
CMP.B D2,D1
BLS.S @3
MOVE.B D2,D1
@3 MOVE.B D1,(A3)+
DBF D0,@1
BRA.S @7
; Maximum value loop
@4 MOVE.B (A0)+,D1
MOVE.B (A1)+,D2
CMP.B D2,D1
BHS.S @5
MOVE.B D2,D1
@5 MOVE.B (A2)+,D2
CMP.B D2,D1
BHS.S @6
MOVE.B D2,D1
@6 MOVE.B D1,(A3)+
DBF D0,@4
; Clean up and exit
@7 MOVEM.L (SP)+,A2-A3
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoFilter'
ConvolveRow PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE ConvolveRow (inPtr: Ptr;
; outPtr: Ptr;
; numRows: INTEGER;
; numCols: INTEGER;
; rowBytes: INTEGER;
; row: INTEGER;
; col1: INTEGER;
; col2: INTEGER;
; kernel: UNIV Ptr);
; Parameter Offsets
@inPtr EQU 28
@outPtr EQU 24
@numRows EQU 22
@numCols EQU 20
@rowBytes EQU 18
@row EQU 16
@col1 EQU 14
@col2 EQU 12
@kernel EQU 8
; Size of parameters
@params EQU 24
; Save registers
LINK A6,#0
MOVEM.L A2-A3/D3-D7,-(SP)
; A0 is the input pointer
MOVE.L @inPtr(A6),A0
; A1 is the output pointer
MOVE.L @outPtr(A6),A1
; A2 points to the kernel
MOVE.L @kernel(A6),A2
; D0 and D1 are current row and column
MOVE.W @row(A6),D0
MOVE.W @col1(A6),D1
; D2 is computed total
@1 CLR.L D2
; D3 is element counter
MOVE.W (A2),D3
; A3 is pointer to kernel element
LEA 16(A2),A3
; D7 is inside valid rectangle flag
MOVE.L #1,D7
CMP.W 8(A2),D0
BGE.S @2
CLR.W D7
@2 CMP.W 10(A2),D1
BGE.S @3
CLR.W D7
@3 CMP.W 12(A2),D0
BLT.S @4
CLR.W D7
@4 CMP.W 14(A2),D1
BLT.S @5
CLR.W D7
; Process next kernel element
@5 TST.W D7
BNE.S @10
; Compute clipped offset
MOVE.W D0,D5
MOVE.W D1,D6
ADD.W (A3),D5
BPL.S @6
CLR.W D5
@6 ADD.W 2(A3),D6
BPL.S @7
CLR.W D6
@7 CMP.W @numRows(A6),D5
BLT.S @8
MOVE.W @numRows(A6),D5
SUB.W #1,D5
@8 CMP.W @numCols(A6),D6
BLT.S @9
MOVE.W @numCols(A6),D6
SUB.W #1,D6
@9 SUB.W D0,D5
SUB.W D1,D6
MULS.W @rowBytes(A6),D5
EXT.L D6
ADD.L D6,D5
BRA.S @11
; Center is inside valid rectangle, use offset
@10 MOVE.L 8(A3),D5
; Load in pixel value
@11 CLR.L D4
MOVE.B (A0,D5.L),D4
; See if we can do a bit shift
MOVE.W 6(A3),D5
BMI.S @12
LSL.L D5,D4
TST.W 4(A3)
BPL.S @13
SUB.L D4,D2
BRA.S @14
; Else do a multiply
@12 MULS.W 4(A3),D4
@13 ADD.L D4,D2
; Move to next element
@14 ADDA.W #12,A3
DBF D3,@5
; Scale and store pixel
MOVE.W 6(A2),D3
BMI.S @17
TST.L D2
BPL.S @15
NEG.L D2
LSR.L D3,D2
NEG.W D2
BRA.S @16
@15 LSR.L D3,D2
@16 TST.W 2(A2)
BPL.S @18
NEG.W D2
BRA.S @18
@17 DIVS.W 2(A2),D2
@18 ADD.W 4(A2),D2
BPL.S @19
CLR.W D2
@19 CMP.W #255,D2
BLE.S @20
MOVE.W #255,D2
@20 MOVE.B D2,(A1)+
; Move to next pixel
ADDA.W #1,A0
ADD.W #1,D1
CMP.W @col2(A6),D1
BNE @1
; Clean up and exit
MOVEM.L (SP)+,A2-A3/D3-D7
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoFilter'
BlurLine PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE BlurLine (prevPtr: Ptr;
; thisPtr: Ptr;
; nextPtr: Ptr;
; destPtr: Ptr;
; count: INTEGER);
;
; Parameter Offsets
@prevPtr EQU 22
@thisPtr EQU 18
@nextPtr EQU 14
@destPtr EQU 10
@count EQU 8
; Size of parameters
@params EQU 18
; Save registers
LINK A6,#0
MOVEM.L A2-A3,-(SP)
; Unload pointers
MOVE.L @prevPtr(A6),A0
MOVE.L @thisPtr(A6),A1
MOVE.L @nextPtr(A6),A2
MOVE.L @destPtr(A6),A3
; D0 is loop counter
MOVE.W @count(A6),D0
SUB.W #1,D0
; Set up registers
CLR.W D1
CLR.W D2
; Compute new values
@1 MOVE.B (A1)+,D1
ASL.W #2,D1
MOVE.B (A0)+,D2
ADD.W D2,D1
MOVE.B (A2)+,D2
ADD.W D2,D1
MOVE.B (A1),D2
ADD.W D2,D1
MOVE.B -2(A1),D2
ADD.W D2,D1
ADD.W #4,D1
ASR.W #3,D1
MOVE.B D1,(A3)+
DBF D0,@1
; Clean up and exit
MOVEM.L (SP)+,A2-A3
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoFilter'
BlurMoreLine PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE BlurMoreLine (prevPtr: Ptr;
; thisPtr: Ptr;
; nextPtr: Ptr;
; destPtr: Ptr;
; count: INTEGER);
;
; Parameter Offsets
@prevPtr EQU 22
@thisPtr EQU 18
@nextPtr EQU 14
@destPtr EQU 10
@count EQU 8
; Size of parameters
@params EQU 18
; Save registers
LINK A6,#0
MOVEM.L A2-A3,-(SP)
; Unload pointers
MOVE.L @prevPtr(A6),A0
MOVE.L @thisPtr(A6),A1
MOVE.L @nextPtr(A6),A2
MOVE.L @destPtr(A6),A3
; D0 is loop counter
MOVE.W @count(A6),D0
SUB.W #1,D0
; Set up registers
CLR.W D1
CLR.W D2
; Compute new values
@1 MOVE.B -1(A1),D1
MOVE.B (A1)+,D2
ADD.W D2,D1
MOVE.B (A1),D2
ADD.W D2,D1
MOVE.B (A0)+,D2
ADD.W D2,D1
MOVE.B (A2)+,D2
ADD.W D2,D1
ADD.W D1,D1
MOVE.B -2(A0),D2
ADD.W D2,D1
MOVE.B (A0),D2
ADD.W D2,D1
MOVE.B -2(A2),D2
ADD.W D2,D1
MOVE.B (A2),D2
ADD.W D2,D1
ADD.W #7,D1
MULU.W #4681,D1
SWAP D1
MOVE.B D1,(A3)+
DBF D0,@1
; Clean up and exit
MOVEM.L (SP)+,A2-A3
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************