forked from amix/photoshop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
UGIFFormat.a
121 lines (88 loc) · 2.09 KB
/
UGIFFormat.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
;Photoshop version 1.0.1, file: UGIFFormat.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 'AGIFFormat'
ExtractGIF PROC EXPORT
; Calling sequence (Pascal conventions):
;
; FUNCTION ExtractGIF (buffer: Ptr;
; offset: LONGINT;
; count: INTEGER): INTEGER;
;
; Parameter Offsets
@result EQU 18
@buffer EQU 14
@offset EQU 10
@count EQU 8
; Size of parameters
@params EQU 10
; Save registers
LINK A6,#0
; Extract the bits
MOVE.L @buffer(A6),A0
MOVE.L @offset(A6),D0
LSR.L #3,D0
MOVE.B 2(A0,D0.L),D1
SWAP D1
MOVE.B 1(A0,D0.L),D1
LSL.W #8,D1
MOVE.B (A0,D0.L),D1
MOVE.W @offset+2(A6),D0
AND.W #$7,D0
LSR.L D0,D1
; Mask the bits
MOVE.W @count(A6),D0
MOVE.L #-1,D2
LSL.W D0,D2
NOT.W D2
AND.W D2,D1
; Return the extracted bits
MOVE.W D1,@result(A6)
; Clean up and exit
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
SEG 'AGIFFormat'
StuffGIF PROC EXPORT
; Calling sequence (Pascal conventions):
;
; PROCEDURE StuffGIF (buffer: Ptr;
; offset: LONGINT;
; code: INTEGER);
;
; Parameter Offsets
@buffer EQU 14
@offset EQU 10
@code EQU 8
; Size of parameters
@params EQU 10
; Save registers
LINK A6,#0
; Stuff the bits
MOVE.L @buffer(A6),A0
CLR.L D0
MOVE.W @code(A6),D0
MOVE.W @offset+2(A6),D1
AND.W #7,D1
LSL.L D1,D0
MOVE.L @offset(A6),D1
LSR.L #3,D1
OR.B D0,(A0,D1.L)
LSR.W #8,D0
OR.B D0,1(A0,D1.L)
SWAP D0
OR.B D0,2(A0,D1.L)
; Clean up and exit
UNLK A6
MOVE.L (SP)+,A0
ADD.W #@params,SP
JMP (A0)
; **********************************************************************
END