-
Notifications
You must be signed in to change notification settings - Fork 74
/
UAdjust.a
603 lines (533 loc) · 23.4 KB
/
UAdjust.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
;Photoshop version 1.0.1, file: UAdjust.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 'ARes3'
FindGamma PROC EXPORT
; Calling sequence (Pascal conventions):
;
; FUNCTION FindGamma (x: INTEGER; gamma: INTEGER): INTEGER;
;
; Parameter Offsets
@result EQU 12
@x EQU 10
@gamma EQU 8
; Size of parameters
@params EQU 4
; Save registers
LINK A6,#0
; Default to zero
CLR.W @result(A6)
; Get input value
MOVE.W @x(A6),D0
BEQ.S @2
; Look up in first table
LEA @table1,A0
ASL.W #1,D0
MOVE.W (A0,D0.W),D0
; Scale by gamma value
MULU.W #100,D0
MOVE.W @gamma(A6),D1
MOVE.W D1,D2
ASR.W #1,D2
EXT.L D2
ADD.L D2,D0
DIVU.W D1,D0
BVS.S @2
; See if outside range of second table
CMP.W #4607,D0
BHI.S @2
CMP.W #3796,D0
BLE.S @1
MOVE.W #3796,D0
; Look up in second table
@1 LEA @table2,A0
MOVE.B (A0,D0.W),@result+1(A6)
; Clean up and exit
@2 UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; LN table
@table1 DC.W 4095,4095,3583,3283,3071,2906,2771,2657
DC.W 2558,2471,2393,2323,2259,2199,2145,2094
DC.W 2046,2001,1959,1919,1881,1845,1811,1778
DC.W 1746,1716,1687,1659,1632,1607,1582,1557
DC.W 1534,1511,1489,1468,1447,1427,1407,1388
DC.W 1369,1351,1333,1315,1298,1282,1266,1250
DC.W 1234,1219,1204,1189,1175,1161,1147,1134
DC.W 1120,1107,1094,1082,1069,1057,1045,1033
DC.W 1022,1010, 999, 988, 977, 966, 955, 945
DC.W 935, 924, 914, 904, 895, 885, 875, 866
DC.W 857, 847, 838, 829, 821, 812, 803, 795
DC.W 786, 778, 770, 761, 753, 745, 738, 730
DC.W 722, 714, 707, 699, 692, 684, 677, 670
DC.W 663, 656, 649, 642, 635, 628, 621, 615
DC.W 608, 601, 595, 588, 582, 576, 569, 563
DC.W 557, 551, 545, 539, 533, 527, 521, 515
DC.W 509, 504, 498, 492, 487, 481, 475, 470
DC.W 465, 459, 454, 448, 443, 438, 433, 427
DC.W 422, 417, 412, 407, 402, 397, 392, 387
DC.W 382, 378, 373, 368, 363, 358, 354, 349
DC.W 344, 340, 335, 331, 326, 322, 317, 313
DC.W 308, 304, 300, 295, 291, 287, 282, 278
DC.W 274, 270, 266, 262, 257, 253, 249, 245
DC.W 241, 237, 233, 229, 225, 221, 217, 214
DC.W 210, 206, 202, 198, 194, 191, 187, 183
DC.W 180, 176, 172, 169, 165, 161, 158, 154
DC.W 151, 147, 143, 140, 136, 133, 130, 126
DC.W 123, 119, 116, 112, 109, 106, 102, 99
DC.W 96, 92, 89, 86, 83, 79, 76, 73
DC.W 70, 67, 64, 60, 57, 54, 51, 48
DC.W 45, 42, 39, 36, 33, 30, 27, 24
DC.W 21, 18, 15, 12, 9, 6, 3, 0
; EXP table
@table2 DC.B 255,255,254,254,254,253,253,253,252,252,252,251
DC.B 251,251,250,250,250,249,249,249,248,248,248,247
DC.B 247,247,246,246,246,245,245,245,244,244,244,243
DC.B 243,243,242,242,242,241,241,241,240,240,240,239
DC.B 239,239,238,238,238,237,237,237,236,236,236,235
DC.B 235,235,234,234,234,234,233,233,233,232,232,232
DC.B 231,231,231,230,230,230,229,229,229,229,228,228
DC.B 228,227,227,227,226,226,226,225,225,225,225,224
DC.B 224,224,223,223,223,222,222,222,222,221,221,221
DC.B 220,220,220,219,219,219,219,218,218,218,217,217
DC.B 217,216,216,216,216,215,215,215,214,214,214,214
DC.B 213,213,213,212,212,212,212,211,211,211,210,210
DC.B 210,210,209,209,209,208,208,208,208,207,207,207
DC.B 206,206,206,206,205,205,205,205,204,204,204,203
DC.B 203,203,203,202,202,202,202,201,201,201,200,200
DC.B 200,200,199,199,199,199,198,198,198,197,197,197
DC.B 197,196,196,196,196,195,195,195,195,194,194,194
DC.B 193,193,193,193,192,192,192,192,191,191,191,191
DC.B 190,190,190,190,189,189,189,189,188,188,188,188
DC.B 187,187,187,187,186,186,186,186,185,185,185,185
DC.B 184,184,184,184,183,183,183,183,182,182,182,182
DC.B 181,181,181,181,180,180,180,180,179,179,179,179
DC.B 178,178,178,178,177,177,177,177,176,176,176,176
DC.B 176,175,175,175,175,174,174,174,174,173,173,173
DC.B 173,172,172,172,172,172,171,171,171,171,170,170
DC.B 170,170,169,169,169,169,169,168,168,168,168,167
DC.B 167,167,167,167,166,166,166,166,165,165,165,165
DC.B 164,164,164,164,164,163,163,163,163,162,162,162
DC.B 162,162,161,161,161,161,161,160,160,160,160,159
DC.B 159,159,159,159,158,158,158,158,158,157,157,157
DC.B 157,156,156,156,156,156,155,155,155,155,155,154
DC.B 154,154,154,154,153,153,153,153,152,152,152,152
DC.B 152,151,151,151,151,151,150,150,150,150,150,149
DC.B 149,149,149,149,148,148,148,148,148,147,147,147
DC.B 147,147,146,146,146,146,146,145,145,145,145,145
DC.B 144,144,144,144,144,143,143,143,143,143,143,142
DC.B 142,142,142,142,141,141,141,141,141,140,140,140
DC.B 140,140,139,139,139,139,139,139,138,138,138,138
DC.B 138,137,137,137,137,137,136,136,136,136,136,136
DC.B 135,135,135,135,135,134,134,134,134,134,134,133
DC.B 133,133,133,133,132,132,132,132,132,132,131,131
DC.B 131,131,131,131,130,130,130,130,130,129,129,129
DC.B 129,129,129,128,128,128,128,128,128,127,127,127
DC.B 127,127,127,126,126,126,126,126,125,125,125,125
DC.B 125,125,124,124,124,124,124,124,123,123,123,123
DC.B 123,123,122,122,122,122,122,122,121,121,121,121
DC.B 121,121,120,120,120,120,120,120,120,119,119,119
DC.B 119,119,119,118,118,118,118,118,118,117,117,117
DC.B 117,117,117,116,116,116,116,116,116,116,115,115
DC.B 115,115,115,115,114,114,114,114,114,114,114,113
DC.B 113,113,113,113,113,112,112,112,112,112,112,112
DC.B 111,111,111,111,111,111,110,110,110,110,110,110
DC.B 110,109,109,109,109,109,109,109,108,108,108,108
DC.B 108,108,108,107,107,107,107,107,107,107,106,106
DC.B 106,106,106,106,106,105,105,105,105,105,105,105
DC.B 104,104,104,104,104,104,104,103,103,103,103,103
DC.B 103,103,102,102,102,102,102,102,102,101,101,101
DC.B 101,101,101,101,101,100,100,100,100,100,100,100
DC.B 99, 99, 99, 99, 99, 99, 99, 98, 98, 98, 98, 98
DC.B 98, 98, 98, 97, 97, 97, 97, 97, 97, 97, 97, 96
DC.B 96, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 95
DC.B 95, 95, 94, 94, 94, 94, 94, 94, 94, 94, 93, 93
DC.B 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92
DC.B 92, 92, 91, 91, 91, 91, 91, 91, 91, 91, 90, 90
DC.B 90, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 89
DC.B 89, 89, 89, 88, 88, 88, 88, 88, 88, 88, 88, 87
DC.B 87, 87, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86
DC.B 86, 86, 86, 86, 85, 85, 85, 85, 85, 85, 85, 85
DC.B 85, 84, 84, 84, 84, 84, 84, 84, 84, 84, 83, 83
DC.B 83, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82
DC.B 82, 82, 82, 81, 81, 81, 81, 81, 81, 81, 81, 81
DC.B 81, 80, 80, 80, 80, 80, 80, 80, 80, 80, 79, 79
DC.B 79, 79, 79, 79, 79, 79, 79, 78, 78, 78, 78, 78
DC.B 78, 78, 78, 78, 78, 77, 77, 77, 77, 77, 77, 77
DC.B 77, 77, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76
DC.B 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 74, 74
DC.B 74, 74, 74, 74, 74, 74, 74, 74, 73, 73, 73, 73
DC.B 73, 73, 73, 73, 73, 73, 72, 72, 72, 72, 72, 72
DC.B 72, 72, 72, 72, 71, 71, 71, 71, 71, 71, 71, 71
DC.B 71, 71, 71, 70, 70, 70, 70, 70, 70, 70, 70, 70
DC.B 70, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69
DC.B 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 67
DC.B 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, 66, 66
DC.B 66, 66, 66, 66, 66, 66, 66, 66, 66, 65, 65, 65
DC.B 65, 65, 65, 65, 65, 65, 65, 65, 64, 64, 64, 64
DC.B 64, 64, 64, 64, 64, 64, 64, 64, 63, 63, 63, 63
DC.B 63, 63, 63, 63, 63, 63, 63, 63, 62, 62, 62, 62
DC.B 62, 62, 62, 62, 62, 62, 62, 62, 61, 61, 61, 61
DC.B 61, 61, 61, 61, 61, 61, 61, 61, 60, 60, 60, 60
DC.B 60, 60, 60, 60, 60, 60, 60, 60, 59, 59, 59, 59
DC.B 59, 59, 59, 59, 59, 59, 59, 59, 58, 58, 58, 58
DC.B 58, 58, 58, 58, 58, 58, 58, 58, 58, 57, 57, 57
DC.B 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 56, 56
DC.B 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 55
DC.B 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55
DC.B 55, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54
DC.B 54, 54, 54, 53, 53, 53, 53, 53, 53, 53, 53, 53
DC.B 53, 53, 53, 53, 52, 52, 52, 52, 52, 52, 52, 52
DC.B 52, 52, 52, 52, 52, 52, 52, 51, 51, 51, 51, 51
DC.B 51, 51, 51, 51, 51, 51, 51, 51, 51, 50, 50, 50
DC.B 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50
DC.B 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49
DC.B 49, 49, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48
DC.B 48, 48, 48, 48, 48, 48, 47, 47, 47, 47, 47, 47
DC.B 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 46, 46
DC.B 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46
DC.B 46, 46, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45
DC.B 45, 45, 45, 45, 45, 45, 45, 44, 44, 44, 44, 44
DC.B 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 43
DC.B 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43
DC.B 43, 43, 43, 43, 43, 42, 42, 42, 42, 42, 42, 42
DC.B 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 41, 41
DC.B 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41
DC.B 41, 41, 41, 41, 40, 40, 40, 40, 40, 40, 40, 40
DC.B 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 39
DC.B 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39
DC.B 39, 39, 39, 39, 39, 39, 38, 38, 38, 38, 38, 38
DC.B 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38
DC.B 38, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37
DC.B 37, 37, 37, 37, 37, 37, 37, 37, 37, 36, 36, 36
DC.B 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36
DC.B 36, 36, 36, 36, 36, 36, 35, 35, 35, 35, 35, 35
DC.B 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35
DC.B 35, 35, 35, 34, 34, 34, 34, 34, 34, 34, 34, 34
DC.B 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34
DC.B 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33
DC.B 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 32
DC.B 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32
DC.B 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 31, 31
DC.B 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31
DC.B 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 30, 30
DC.B 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30
DC.B 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 29, 29
DC.B 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
DC.B 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
DC.B 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28
DC.B 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28
DC.B 28, 28, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27
DC.B 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27
DC.B 27, 27, 27, 27, 27, 27, 26, 26, 26, 26, 26, 26
DC.B 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26
DC.B 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 25, 25
DC.B 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
DC.B 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
DC.B 25, 25, 25, 25, 24, 24, 24, 24, 24, 24, 24, 24
DC.B 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
DC.B 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 23, 23
DC.B 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23
DC.B 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23
DC.B 23, 23, 23, 23, 23, 23, 23, 22, 22, 22, 22, 22
DC.B 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22
DC.B 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22
DC.B 22, 22, 22, 22, 21, 21, 21, 21, 21, 21, 21, 21
DC.B 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21
DC.B 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21
DC.B 21, 21, 21, 20, 20, 20, 20, 20, 20, 20, 20, 20
DC.B 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
DC.B 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20
DC.B 20, 20, 20, 20, 19, 19, 19, 19, 19, 19, 19, 19
DC.B 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19
DC.B 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19
DC.B 19, 19, 19, 19, 19, 19, 19, 18, 18, 18, 18, 18
DC.B 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18
DC.B 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18
DC.B 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18
DC.B 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17
DC.B 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17
DC.B 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17
DC.B 17, 17, 17, 17, 17, 17, 17, 17, 16, 16, 16, 16
DC.B 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
DC.B 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
DC.B 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
DC.B 16, 16, 16, 16, 16, 16, 15, 15, 15, 15, 15, 15
DC.B 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15
DC.B 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15
DC.B 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15
DC.B 15, 15, 15, 15, 15, 15, 15, 14, 14, 14, 14, 14
DC.B 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
DC.B 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
DC.B 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
DC.B 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
DC.B 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
DC.B 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
DC.B 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
DC.B 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13
DC.B 13, 13, 13, 13, 13, 13, 13, 13, 13, 12, 12, 12
DC.B 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
DC.B 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
DC.B 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
DC.B 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
DC.B 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 11
DC.B 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
DC.B 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
DC.B 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
DC.B 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
DC.B 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
DC.B 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10
DC.B 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
DC.B 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
DC.B 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
DC.B 10, 10, 10, 10, 10, 10, 10, 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.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
DC.B 2, 2, 2, 2, 1
; **********************************************************************
SEG 'AHistogram'
DoHistLuminosity PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE DoHistLuminosity (data1Ptr: Ptr;
; data2Ptr: Ptr;
; data3Ptr: Ptr;
; maskPtr: Ptr;
; maps: TRGBLookUpTable;
; count: INTEGER;
; VAR hist: THistogram);
;
; Parameter Offsets
@data1Ptr EQU 30
@data2Ptr EQU 26
@data3Ptr EQU 22
@maskPtr EQU 18
@maps EQU 14
@count EQU 12
@hist EQU 8
; Size of parameters
@params EQU 26
; Save registers
LINK A6,#0
MOVEM.L A2-A5,-(SP)
; Unload parameters
MOVE.L @hist(A6),A0
MOVE.L @data1Ptr(A6),A1
MOVE.L @data2Ptr(A6),A2
MOVE.L @data3Ptr(A6),A3
MOVE.L @maskPtr(A6),A4
MOVE.L @maps(A6),A5
MOVE.W @count(A6),D0
SUB.W #1,D0
; Compute luminosity histogram
@1 CLR.W D1
CLR.W D2
MOVE.B (A1)+,D1
MOVE.B (A5,D1.W),D1
MOVE.B (A2)+,D2
ADDA.W #256,A5
ADD.B (A5,D2.W),D1
MOVE.B (A3)+,D2
ADDA.W #256,A5
ADD.B (A5,D2.W),D1
SUBA.W #512,A5
MOVE.L A4,D2
BEQ.S @2
TST.B (A4)+
BPL.S @3
@2 LSL.W #2,D1
ADD.L #1,(A0,D1.W)
@3 DBF D0,@1
; Clean up and exit
MOVEM.L (SP)+,A2-A5
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'ADoAdjust'
ThresholdLuminosity PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE ThresholdLuminosity (data1Ptr: Ptr;
; data2Ptr: Ptr;
; data3Ptr: Ptr;
; maps: TRGBLookUpTable;
; count: INTEGER;
; threshold: INTEGER);
;
; Parameter Offsets
@data1Ptr EQU 24
@data2Ptr EQU 20
@data3Ptr EQU 16
@maps EQU 12
@count EQU 10
@threshold EQU 8
; Size of parameters
@params EQU 20
; Save registers
LINK A6,#0
MOVEM.L A2-A3/D3-D4,-(SP)
; Unload parameters
MOVE.L @data1Ptr(A6),A0
MOVE.L @data2Ptr(A6),A1
MOVE.L @data3Ptr(A6),A2
MOVE.L @maps(A6),A3
MOVE.W @count(A6),D0
SUB.W #1,D0
MOVE.W @threshold(A6),D1
; D2 holds 255
MOVE.W #255,D2
; Compute pixel's luminosity
CLR.W D3
CLR.W D4
@1 MOVE.B (A0),D3
MOVE.B (A3,D3.W),D3
MOVE.B (A1),D4
ADDA.W #256,A3
ADD.B (A3,D4.W),D3
MOVE.B (A2),D4
ADDA.W #256,A3
ADD.B (A3,D4.W),D3
SUBA.W #512,A3
; Compare to threshold
CMP.B D3,D1
BLS.S @2
; None >= threshold, set to zero
CLR.B (A0)+
CLR.B (A1)+
CLR.B (A2)+
BRA.S @3
; Yes, set to 255
@2 MOVE.B D2,(A0)+
MOVE.B D2,(A1)+
MOVE.B D2,(A2)+
; Move to next pixel
@3 DBF D0,@1
; Clean up and exit
MOVEM.L (SP)+,A2-A3/D3-D4
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
END