Subversion Repositories Kolibri OS

Rev

Rev 485 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 485 Rev 552
1
lang equ ru
1
lang equ ru
2
 
2
 
3
;
3
;
4
;   Assembler
4
;   Assembler
5
;     SMALL
5
;     SMALL
6
;       CODE
6
;       CODE
7
;         Graphics
7
;         Graphics
8
;           Libary
8
;           Libary
9
;
9
;
10
;   Ver 0.18 By Pavlushin Evgeni (RUSSIA)
10
;   Ver 0.18 By Pavlushin Evgeni (RUSSIA)
11
;   www.waptap@mail.ru
11
;   www.waptap@mail.ru
12
 
12
 
13
;InfoList
13
;InfoList
14
;0.01 LoadImage
14
;0.01 LoadImage
15
;0.02 SetBmp
15
;0.02 SetBmp
16
;0.03 Bmptoimg, Setimg ~01.03.2004
16
;0.03 Bmptoimg, Setimg ~01.03.2004
17
;0.04 Bug deleted, copyimg ~03.05.2004
17
;0.04 Bug deleted, copyimg ~03.05.2004
18
;0.05 fullimg, collimg ~05.05.2004
18
;0.05 fullimg, collimg ~05.05.2004
19
;0.06 getimg ~09.05.2004
19
;0.06 getimg ~09.05.2004
20
;0.07 convbmp ~13.05.2004
20
;0.07 convbmp ~13.05.2004
21
;0.08 fps ~14.05.2004
21
;0.08 fps ~14.05.2004
22
;0.09 drawfbox ~03.06.2004
22
;0.09 drawfbox ~03.06.2004
23
;0.10 all macros optimized by Halyavin A., add at ~07.06.2004
23
;0.10 all macros optimized by Halyavin A., add at ~07.06.2004
24
;0.11 many macros optimized by Halyavin A., add at ~30.08.2004
24
;0.11 many macros optimized by Halyavin A., add at ~30.08.2004
25
;0.12 bmptoimg ~07.09.2004
25
;0.12 bmptoimg ~07.09.2004
26
;0.13 imgtoimg ~08.09.2004
26
;0.13 imgtoimg ~08.09.2004
27
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
27
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
28
;0.15 giftoimg, giftoani ~10.09.2004
28
;0.15 giftoimg, giftoani ~10.09.2004
29
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
29
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
30
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
30
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
31
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
31
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
32
 
32
 
33
aframetoimg_use_count=0
33
aframetoimg_use_count=0
34
macro aframetoimg img, x, y, canvas,acol
34
macro aframetoimg img, x, y, canvas,acol
35
{
35
{
36
local loo,loo2,acolor
36
local loo,loo2,acolor
37
aframetoimg_use_count=aframetoimg_use_count+1
37
aframetoimg_use_count=aframetoimg_use_count+1
38
if aframetoimg_use_count = 1
38
if aframetoimg_use_count = 1
39
 
39
 
40
     jmp end_aframetoimg_proc
40
     jmp end_aframetoimg_proc
41
 
41
 
42
acolor dd 0
42
acolor dd 0
43
aframetoimg_proc:
43
aframetoimg_proc:
44
;getout coord
44
;getout coord
45
    mov [acolor],ebp
45
    mov [acolor],ebp
46
 
46
 
47
    mov edx,ebx ;img   ;xsize
47
    mov edx,ebx ;img   ;xsize
48
    movzx eax,word [edx]
48
    movzx eax,word [edx]
49
    add eax,esi ;y cor
49
    add eax,esi ;y cor
50
 
50
 
51
;    mov eax,esi ;y cor
51
;    mov eax,esi ;y cor
52
    mul dword [ecx] ;canvas xsize
52
    mul dword [ecx] ;canvas xsize
53
    add eax,edi ;x cor
53
    add eax,edi ;x cor
54
 
54
 
55
    mov ebp,ebx ;img   ;xsize
55
    mov ebp,ebx ;img   ;xsize
56
    movzx edx,word [ebp]
56
    movzx edx,word [ebp]
57
    add eax,edx
57
    add eax,edx
58
 
58
 
59
    mov ebp,eax
59
    mov ebp,eax
60
    shl eax,1
60
    shl eax,1
61
    add ebp,eax
61
    add ebp,eax
62
    add ebp,ecx ;canvas+8;start
62
    add ebp,ecx ;canvas+8;start
63
    add ebp,8
63
    add ebp,8
64
;get img size
64
;get img size
65
    add ebx,4
65
    add ebx,4
66
    mov eax,ebx ;img   ;xsize
66
    mov eax,ebx ;img   ;xsize
67
    movzx esi,word [eax]
67
    movzx esi,word [eax]
68
    movzx edi,word [eax+2]
68
    movzx edi,word [eax+2]
69
    add ebx,4
69
    add ebx,4
70
    mov edx,ebx ;img+8
70
    mov edx,ebx ;img+8
71
loo2:
71
loo2:
72
push esi
72
push esi
73
loo:
73
loo:
74
;test on alpha color
74
;test on alpha color
75
    mov eax,[edx]
75
    mov eax,[edx]
76
    shl eax,8
76
    shl eax,8
77
    shr eax,8
77
    shr eax,8
78
    cmp eax,[acolor]
78
    cmp eax,[acolor]
79
    jne  yx
79
    jne  yx
80
    add edx,3
80
    add edx,3
81
    add ebp,3
81
    add ebp,3
82
    jmp nx
82
    jmp nx
83
yx:
83
yx:
84
 
84
 
85
    mov al,byte [edx]
85
    mov al,byte [edx]
86
    mov byte [ebp],al
86
    mov byte [ebp],al
87
    inc ebp
87
    inc ebp
88
    inc edx
88
    inc edx
89
    mov al,byte [edx]
89
    mov al,byte [edx]
90
    mov byte [ebp],al
90
    mov byte [ebp],al
91
    inc ebp
91
    inc ebp
92
    inc edx
92
    inc edx
93
    mov al,byte [edx]
93
    mov al,byte [edx]
94
    mov byte [ebp],al
94
    mov byte [ebp],al
95
    inc ebp
95
    inc ebp
96
    inc edx
96
    inc edx
97
nx:
97
nx:
98
    dec esi
98
    dec esi
99
    jnz loo
99
    jnz loo
100
pop esi
100
pop esi
101
    sub ebp,3
101
    sub ebp,3
102
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
102
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
103
    sub eax,esi
103
    sub eax,esi
104
    add ebp,eax
104
    add ebp,eax
105
    shl eax,1
105
    shl eax,1
106
    add ebp,eax
106
    add ebp,eax
107
 
107
 
108
    add ebp,3
108
    add ebp,3
109
 
109
 
110
    dec edi
110
    dec edi
111
    jnz loo2
111
    jnz loo2
112
    ret
112
    ret
113
end_aframetoimg_proc:
113
end_aframetoimg_proc:
114
end if
114
end if
115
    push img
115
    push img
116
    push canvas
116
    push canvas
117
    push x
117
    push x
118
    push y
118
    push y
119
    push acol
119
    push acol
120
    pop  ebp
120
    pop  ebp
121
    pop  esi
121
    pop  esi
122
    pop  edi
122
    pop  edi
123
    pop ecx
123
    pop ecx
124
    pop ebx
124
    pop ebx
125
    call aframetoimg_proc
125
    call aframetoimg_proc
126
}
126
}
127
 
127
 
128
frametoimg_use_count=0
128
frametoimg_use_count=0
129
macro frametoimg img, x, y, canvas
129
macro frametoimg img, x, y, canvas
130
{
130
{
131
local loo,loo2
131
local loo,loo2
132
frametoimg_use_count=frametoimg_use_count+1
132
frametoimg_use_count=frametoimg_use_count+1
133
if frametoimg_use_count = 1
133
if frametoimg_use_count = 1
134
 
134
 
135
    jmp end_frametoimg_proc
135
    jmp end_frametoimg_proc
136
 
136
 
137
frametoimg_proc:
137
frametoimg_proc:
138
;getout coord
138
;getout coord
139
    mov edx,ebx ;img   ;xsize
139
    mov edx,ebx ;img   ;xsize
140
    movzx eax,word [edx]
140
    movzx eax,word [edx]
141
    add eax,esi ;y cor
141
    add eax,esi ;y cor
142
 
142
 
143
;    mov eax,esi ;y cor
143
;    mov eax,esi ;y cor
144
    mul dword [ecx] ;canvas xsize
144
    mul dword [ecx] ;canvas xsize
145
    add eax,edi ;x cor
145
    add eax,edi ;x cor
146
 
146
 
147
    mov ebp,ebx ;img   ;xsize
147
    mov ebp,ebx ;img   ;xsize
148
    movzx edx,word [ebp]
148
    movzx edx,word [ebp]
149
    add eax,edx
149
    add eax,edx
150
 
150
 
151
    mov ebp,eax
151
    mov ebp,eax
152
    shl eax,1
152
    shl eax,1
153
    add ebp,eax
153
    add ebp,eax
154
    add ebp,ecx ;canvas+8;start
154
    add ebp,ecx ;canvas+8;start
155
    add ebp,8
155
    add ebp,8
156
;get img size
156
;get img size
157
    add ebx,4
157
    add ebx,4
158
    mov eax,ebx ;img   ;xsize
158
    mov eax,ebx ;img   ;xsize
159
    movzx esi,word [eax]
159
    movzx esi,word [eax]
160
    movzx edi,word [eax+2]
160
    movzx edi,word [eax+2]
161
    add ebx,4
161
    add ebx,4
162
    mov edx,ebx ;img+8
162
    mov edx,ebx ;img+8
163
loo2:
163
loo2:
164
push esi
164
push esi
165
loo:
165
loo:
166
    mov al,byte [edx]
166
    mov al,byte [edx]
167
    mov byte [ebp],al
167
    mov byte [ebp],al
168
    inc ebp
168
    inc ebp
169
    inc edx
169
    inc edx
170
    mov al,byte [edx]
170
    mov al,byte [edx]
171
    mov byte [ebp],al
171
    mov byte [ebp],al
172
    inc ebp
172
    inc ebp
173
    inc edx
173
    inc edx
174
    mov al,byte [edx]
174
    mov al,byte [edx]
175
    mov byte [ebp],al
175
    mov byte [ebp],al
176
    inc ebp
176
    inc ebp
177
    inc edx
177
    inc edx
178
 
178
 
179
    dec esi
179
    dec esi
180
    jnz loo
180
    jnz loo
181
pop esi
181
pop esi
182
    sub ebp,3
182
    sub ebp,3
183
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
183
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
184
    sub eax,esi
184
    sub eax,esi
185
    add ebp,eax
185
    add ebp,eax
186
    shl eax,1
186
    shl eax,1
187
    add ebp,eax
187
    add ebp,eax
188
 
188
 
189
    add ebp,3
189
    add ebp,3
190
 
190
 
191
    dec edi
191
    dec edi
192
    jnz loo2
192
    jnz loo2
193
    ret
193
    ret
194
end_frametoimg_proc:
194
end_frametoimg_proc:
195
end if
195
end if
196
    push img
196
    push img
197
    push canvas
197
    push canvas
198
    push x
198
    push x
199
    push y
199
    push y
200
    pop  esi
200
    pop  esi
201
    pop  edi
201
    pop  edi
202
    pop ecx
202
    pop ecx
203
    pop ebx
203
    pop ebx
204
    call frametoimg_proc
204
    call frametoimg_proc
205
}
205
}
206
 
206
 
207
 
207
 
208
aimgtoimg_use_count=0
208
aimgtoimg_use_count=0
209
macro aimgtoimg img, x, y, canvas,acol
209
macro aimgtoimg img, x, y, canvas,acol
210
{
210
{
211
local loo,loo2,acolor
211
local loo,loo2,acolor
212
aimgtoimg_use_count=aimgtoimg_use_count+1
212
aimgtoimg_use_count=aimgtoimg_use_count+1
213
if aimgtoimg_use_count = 1
213
if aimgtoimg_use_count = 1
214
 
214
 
215
     jmp end_aimgtoimg_proc
215
     jmp end_aimgtoimg_proc
216
 
216
 
217
acolor dd 0
217
acolor dd 0
218
aimgtoimg_proc:
218
aimgtoimg_proc:
219
;getout coord
219
;getout coord
220
    mov [acolor],ebp
220
    mov [acolor],ebp
221
 
221
 
222
    mov eax,esi ;y cor
222
    mov eax,esi ;y cor
223
    mul dword [ecx] ;canvas xsize
223
    mul dword [ecx] ;canvas xsize
224
    add eax,edi ;x cor
224
    add eax,edi ;x cor
225
    mov ebp,eax
225
    mov ebp,eax
226
    shl eax,1
226
    shl eax,1
227
    add ebp,eax
227
    add ebp,eax
228
    add ebp,ecx ;canvas+8;start
228
    add ebp,ecx ;canvas+8;start
229
    add ebp,8
229
    add ebp,8
230
;get img size
230
;get img size
231
    mov eax,ebx ;img   ;xsize
231
    mov eax,ebx ;img   ;xsize
232
    mov esi,[eax]
232
    mov esi,[eax]
233
    add ebx,4
233
    add ebx,4
234
    mov eax,ebx ; img+4 ;ysize
234
    mov eax,ebx ; img+4 ;ysize
235
    mov edi,[eax]
235
    mov edi,[eax]
236
    add ebx,4
236
    add ebx,4
237
    mov edx,ebx ;img+8
237
    mov edx,ebx ;img+8
238
loo2:
238
loo2:
239
push esi
239
push esi
240
loo:
240
loo:
241
 
241
 
242
;test on alpha color
242
;test on alpha color
243
    mov eax,[edx]
243
    mov eax,[edx]
244
    shl eax,8
244
    shl eax,8
245
    shr eax,8
245
    shr eax,8
246
    cmp eax,[acolor]
246
    cmp eax,[acolor]
247
    jne  yx
247
    jne  yx
248
    add edx,3
248
    add edx,3
249
    add ebp,3
249
    add ebp,3
250
    jmp nx
250
    jmp nx
251
yx:
251
yx:
252
 
252
 
253
    mov al,byte [edx]
253
    mov al,byte [edx]
254
    mov byte [ebp],al
254
    mov byte [ebp],al
255
    inc ebp
255
    inc ebp
256
    inc edx
256
    inc edx
257
    mov al,byte [edx]
257
    mov al,byte [edx]
258
    mov byte [ebp],al
258
    mov byte [ebp],al
259
    inc ebp
259
    inc ebp
260
    inc edx
260
    inc edx
261
    mov al,byte [edx]
261
    mov al,byte [edx]
262
    mov byte [ebp],al
262
    mov byte [ebp],al
263
    inc ebp
263
    inc ebp
264
    inc edx
264
    inc edx
265
nx:
265
nx:
266
    dec esi
266
    dec esi
267
    jnz loo
267
    jnz loo
268
pop esi
268
pop esi
269
    sub ebp,3
269
    sub ebp,3
270
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
270
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
271
    sub eax,esi
271
    sub eax,esi
272
    add ebp,eax
272
    add ebp,eax
273
    shl eax,1
273
    shl eax,1
274
    add ebp,eax
274
    add ebp,eax
275
 
275
 
276
    add ebp,3
276
    add ebp,3
277
 
277
 
278
    dec edi
278
    dec edi
279
    jnz loo2
279
    jnz loo2
280
    ret
280
    ret
281
end_aimgtoimg_proc:
281
end_aimgtoimg_proc:
282
end if
282
end if
283
    push img
283
    push img
284
    push canvas
284
    push canvas
285
    push x
285
    push x
286
    push y
286
    push y
287
    push acol
287
    push acol
288
    pop  ebp
288
    pop  ebp
289
    pop  esi
289
    pop  esi
290
    pop  edi
290
    pop  edi
291
    pop ecx
291
    pop ecx
292
    pop ebx
292
    pop ebx
293
    call aimgtoimg_proc
293
    call aimgtoimg_proc
294
}
294
}
295
 
295
 
296
 
296
 
297
 
297
 
298
 
298
 
299
imgtoimg_use_count=0
299
imgtoimg_use_count=0
300
macro imgtoimg img, x, y, canvas
300
macro imgtoimg img, x, y, canvas
301
{
301
{
302
local loo,loo2
302
local loo,loo2
303
imgtoimg_use_count=imgtoimg_use_count+1
303
imgtoimg_use_count=imgtoimg_use_count+1
304
if imgtoimg_use_count = 1
304
if imgtoimg_use_count = 1
305
 
305
 
306
     jmp end_imgtoimg_proc
306
     jmp end_imgtoimg_proc
307
imgtoimg_proc:
307
imgtoimg_proc:
308
;getout coord
308
;getout coord
309
    mov eax,esi ;y cor
309
    mov eax,esi ;y cor
310
    mul dword [ecx] ;canvas xsize
310
    mul dword [ecx] ;canvas xsize
311
    add eax,edi ;x cor
311
    add eax,edi ;x cor
312
    mov ebp,eax
312
    mov ebp,eax
313
    shl eax,1
313
    shl eax,1
314
    add ebp,eax
314
    add ebp,eax
315
    add ebp,ecx ;canvas+8;start
315
    add ebp,ecx ;canvas+8;start
316
    add ebp,8
316
    add ebp,8
317
;get img size
317
;get img size
318
    mov eax,ebx ;img   ;xsize
318
    mov eax,ebx ;img   ;xsize
319
    mov esi,[eax]
319
    mov esi,[eax]
320
    add ebx,4
320
    add ebx,4
321
    mov eax,ebx ; img+4 ;ysize
321
    mov eax,ebx ; img+4 ;ysize
322
    mov edi,[eax]
322
    mov edi,[eax]
323
    add ebx,4
323
    add ebx,4
324
    mov edx,ebx ;img+8
324
    mov edx,ebx ;img+8
325
loo2:
325
loo2:
326
push esi
326
push esi
327
loo:
327
loo:
328
    mov al,byte [edx]
328
    mov al,byte [edx]
329
    mov byte [ebp],al
329
    mov byte [ebp],al
330
    inc ebp
330
    inc ebp
331
    inc edx
331
    inc edx
332
    mov al,byte [edx]
332
    mov al,byte [edx]
333
    mov byte [ebp],al
333
    mov byte [ebp],al
334
    inc ebp
334
    inc ebp
335
    inc edx
335
    inc edx
336
    mov al,byte [edx]
336
    mov al,byte [edx]
337
    mov byte [ebp],al
337
    mov byte [ebp],al
338
    inc ebp
338
    inc ebp
339
    inc edx
339
    inc edx
340
    dec esi
340
    dec esi
341
    jnz loo
341
    jnz loo
342
pop esi
342
pop esi
343
    sub ebp,3
343
    sub ebp,3
344
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
344
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
345
    sub eax,esi
345
    sub eax,esi
346
    add ebp,eax
346
    add ebp,eax
347
    shl eax,1
347
    shl eax,1
348
    add ebp,eax
348
    add ebp,eax
349
 
349
 
350
    add ebp,3
350
    add ebp,3
351
 
351
 
352
    dec edi
352
    dec edi
353
    jnz loo2
353
    jnz loo2
354
    ret
354
    ret
355
end_imgtoimg_proc:
355
end_imgtoimg_proc:
356
end if
356
end if
357
    push img
357
    push img
358
    push canvas
358
    push canvas
359
    push x
359
    push x
360
    push y
360
    push y
361
    pop  esi
361
    pop  esi
362
    pop  edi
362
    pop  edi
363
    pop  ecx
363
    pop  ecx
364
    pop  ebx
364
    pop  ebx
365
    call imgtoimg_proc
365
    call imgtoimg_proc
366
}
366
}
367
 
367
 
368
 
368
 
369
;DrawBox
369
;DrawBox
370
macro drawfbox x,y,xs,ys,color
370
macro drawfbox x,y,xs,ys,color
371
{
371
{
372
    words2reg ebx,x,xs ;x*65536+xs
372
    words2reg ebx,x,xs ;x*65536+xs
373
    words2reg ecx,y,ys ;y*65536+ys
373
    words2reg ecx,y,ys ;y*65536+ys
374
    mov  edx,color
374
    mov  edx,color
375
    mov  eax,13
375
    mov  eax,13
376
    mcall
376
    mcall
377
}
377
}
378
 
378
 
379
; FPS - Set Frame Per Second Display
379
; FPS - Set Frame Per Second Display
380
fps_show_frequency=40
380
fps_show_frequency=40
381
macro fps x,y,color,delcolor
381
macro fps x,y,color,delcolor
382
{
382
{
383
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
383
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
384
local no_out_fps
384
local no_out_fps
385
    jmp spdat
385
    jmp spdat
386
savetime dd 0
386
savetime dd 0
387
fps_cntr dd 0
387
fps_cntr dd 0
388
fps	 dd 0
388
fps	 dd 0
389
ttt	 dd 0
389
ttt	 dd 0
390
spdat:
390
spdat:
391
get_time:
391
get_time:
392
    mov eax,3
392
    mov eax,3
393
    mcall
393
    mcall
394
    cmp eax,[savetime]
394
    cmp eax,[savetime]
395
    jne new_time
395
    jne new_time
396
    inc [fps_cntr]
396
    inc [fps_cntr]
397
    cmp dword [ttt],0
397
    cmp dword [ttt],0
398
    je	out_fps
398
    je	out_fps
399
    dec dword [ttt]
399
    dec dword [ttt]
400
    jmp no_out_fps
400
    jmp no_out_fps
401
new_time:
401
new_time:
402
    mov [savetime],eax
402
    mov [savetime],eax
403
    mov ebx,[fps_cntr]
403
    mov ebx,[fps_cntr]
404
    mov [fps],ebx
404
    mov [fps],ebx
405
    mov [fps_cntr],0
405
    mov [fps_cntr],0
406
out_fps:
406
out_fps:
407
if ~(delcolor eq )
407
if ~(delcolor eq )
408
    mov ebx,x*65536+36
408
    mov ebx,x*65536+36
409
    mov ecx,y*65536+7
409
    mov ecx,y*65536+7
410
    mov edx,delcolor
410
    mov edx,delcolor
411
    mov eax,13
411
    mov eax,13
412
    mcall
412
    mcall
413
end if
413
end if
414
    mov dword [ttt],fps_show_frequency
414
    mov dword [ttt],fps_show_frequency
415
    mov eax,47
415
    mov eax,47
416
    mov ebx,6*65536
416
    mov ebx,6*65536
417
;   mov bl,0
417
;   mov bl,0
418
    mov edx,x*65536+y
418
    mov edx,x*65536+y
419
    mov esi,color
419
    mov esi,color
420
    mov ecx,[fps]
420
    mov ecx,[fps]
421
    mcall
421
    mcall
422
no_out_fps:
422
no_out_fps:
423
}
423
}
424
 
424
 
425
; COLLIMG - Collusion image's
425
; COLLIMG - Collusion image's
426
_1dbounce_count=0;
426
_1dbounce_count=0;
427
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
427
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
428
{
428
{
429
local bounce,exit,anot,bc,nbc
429
local bounce,exit,anot,bc,nbc
430
    mov esi,[img1_off] ;xs1
430
    mov esi,[img1_off] ;xs1
431
    mov edi,[img2_off] ;ys2
431
    mov edi,[img2_off] ;ys2
432
    mov eax,x1 ;
432
    mov eax,x1 ;
433
    mov ebx,x2 ;
433
    mov ebx,x2 ;
434
    call _1dbounce
434
    call _1dbounce
435
    mov edx,ecx
435
    mov edx,ecx
436
    mov esi,[img1_off+4] ;ys1
436
    mov esi,[img1_off+4] ;ys1
437
    mov edi,[img2_off+4] ;ys2
437
    mov edi,[img2_off+4] ;ys2
438
    mov eax,y1 ;
438
    mov eax,y1 ;
439
    mov ebx,y2 ;
439
    mov ebx,y2 ;
440
    call _1dbounce
440
    call _1dbounce
441
    add edx,ecx
441
    add edx,ecx
442
    cmp edx,2
442
    cmp edx,2
443
    je bounce
443
    je bounce
444
    mov otv,0
444
    mov otv,0
445
    jmp exit
445
    jmp exit
446
_1dbounce_count=_1dbounce_count+1
446
_1dbounce_count=_1dbounce_count+1
447
if _1dbounce_count = 1
447
if _1dbounce_count = 1
448
_1dbounce:
448
_1dbounce:
449
    cmp ebx,eax
449
    cmp ebx,eax
450
    jb	anot
450
    jb	anot
451
    add eax,esi
451
    add eax,esi
452
    cmp eax,ebx
452
    cmp eax,ebx
453
    jbe nbc
453
    jbe nbc
454
bc:
454
bc:
455
    mov ecx,1
455
    mov ecx,1
456
    ret
456
    ret
457
anot:
457
anot:
458
    add ebx,edi
458
    add ebx,edi
459
    cmp ebx,eax
459
    cmp ebx,eax
460
    ja	bc
460
    ja	bc
461
nbc:
461
nbc:
462
    xor ecx,ecx
462
    xor ecx,ecx
463
    ret
463
    ret
464
end if
464
end if
465
bounce:
465
bounce:
466
    mov otv,1
466
    mov otv,1
467
exit:
467
exit:
468
}
468
}
469
 
469
 
470
macro rgbtobgr image
470
macro rgbtobgr image
471
{
471
{
472
local loo
472
local loo
473
    mov eax,[image]
473
    mov eax,[image]
474
    mul dword [image+4]
474
    mul dword [image+4]
475
    mov ecx,eax
475
    mov ecx,eax
476
    mov esi,image+8
476
    mov esi,image+8
477
;   add esi,8
477
;   add esi,8
478
loo:
478
loo:
479
   mov al,[esi]
479
   mov al,[esi]
480
   mov bl,[esi+2]
480
   mov bl,[esi+2]
481
   mov [esi],bl
481
   mov [esi],bl
482
   mov [esi+2],al
482
   mov [esi+2],al
483
   add esi,3
483
   add esi,3
484
   dec ecx
484
   dec ecx
485
   jnz loo
485
   jnz loo
486
}
486
}
487
 
487
 
488
 
488
 
489
macro setimg x , y ,arg3
489
macro setimg x , y ,arg3
490
{
490
{
491
    mov  eax,7
491
    mov  eax,7
492
    mov  ebx,arg3
492
    mov  ebx,arg3
493
    add  ebx,8
493
    add  ebx,8
494
    mov  cx,[arg3]
494
    mov  cx,[arg3]
495
    shl  ecx,16
495
    shl  ecx,16
496
    add  cx,[arg3+4]
496
    add  cx,[arg3+4]
497
;    wordstoreg ecx,[arg3],[arg3+4]
497
;    wordstoreg ecx,[arg3],[arg3+4]
498
    words2reg edx, x , y  ;arg1*65536+arg2
498
    words2reg edx, x , y  ;arg1*65536+arg2
499
    mcall
499
    mcall
500
}
500
}
501
 
501
 
502
macro setframe x , y ,arg3
502
macro setframe x , y ,arg3
503
{
503
{
504
    mov  eax,7
504
    mov  eax,7
505
    mov  ebx,arg3
505
    mov  ebx,arg3
506
    add  ebx,8
506
    add  ebx,8
507
    words2reg edx, x , y  ;arg1*65536+arg2
507
    words2reg edx, x , y  ;arg1*65536+arg2
508
    add  edx,dword [arg3]
508
    add  edx,dword [arg3]
509
    mov  ecx,dword [arg3+4]
509
    mov  ecx,dword [arg3+4]
510
    mcall
510
    mcall
511
}
511
}
512
 
512
 
513
 
513
 
514
macro getimg imgsrc,x,y,xs,ys,imgdest
514
macro getimg imgsrc,x,y,xs,ys,imgdest
515
{
515
{
516
local cyc
516
local cyc
517
if xs eqtype 0
517
if xs eqtype 0
518
    mov dword [imgdest],xs
518
    mov dword [imgdest],xs
519
else
519
else
520
    mov eax,xs
520
    mov eax,xs
521
    mov dword [imgdest],eax
521
    mov dword [imgdest],eax
522
end if
522
end if
523
if ys eqtype 0
523
if ys eqtype 0
524
    mov dword [imgdest+4],ys
524
    mov dword [imgdest+4],ys
525
else
525
else
526
    mov eax,ys
526
    mov eax,ys
527
    mov dword [imgdest+4],eax
527
    mov dword [imgdest+4],eax
528
end if
528
end if
529
 
529
 
530
    mov eax,dword [imgsrc] ;getx size
530
    mov eax,dword [imgsrc] ;getx size
531
;    lea ecx,[eax+2*eax]
531
;    lea ecx,[eax+2*eax]
532
    mov ecx,eax
532
    mov ecx,eax
533
    shl ecx,1
533
    shl ecx,1
534
    add ecx,eax
534
    add ecx,eax
535
 
535
 
536
    mov ebx,y
536
    mov ebx,y
537
    mul ebx
537
    mul ebx
538
    add eax,x
538
    add eax,x
539
    mov edx,ecx
539
    mov edx,ecx
540
    lea eax,[eax+2*eax]  ;eax=offset on imsrc
540
    lea eax,[eax+2*eax]  ;eax=offset on imsrc
541
;    mov ebp,eax
541
;    mov ebp,eax
542
;    shl eax,1
542
;    shl eax,1
543
;    add eax,ebp
543
;    add eax,ebp
544
 
544
 
545
    mov ecx,xs
545
    mov ecx,xs
546
    mov ebx,ys
546
    mov ebx,ys
547
 
547
 
548
    mov edi,8+imgdest
548
    mov edi,8+imgdest
549
    lea esi,[eax+8+imgsrc]
549
    lea esi,[eax+8+imgsrc]
550
;    mov esi,eax
550
;    mov esi,eax
551
;    add esi,8
551
;    add esi,8
552
;    add esi,imgsrc
552
;    add esi,imgsrc
553
 
553
 
554
    cld
554
    cld
555
cyc:
555
cyc:
556
    movsw
556
    movsw
557
    movsb
557
    movsb
558
    dec ecx
558
    dec ecx
559
    jne cyc
559
    jne cyc
560
    add esi,edx
560
    add esi,edx
561
    mov ecx,xs
561
    mov ecx,xs
562
    sub esi,ecx
562
    sub esi,ecx
563
    sub esi,ecx
563
    sub esi,ecx
564
    sub esi,ecx
564
    sub esi,ecx
565
    dec ebx
565
    dec ebx
566
    jne cyc
566
    jne cyc
567
}
567
}
568
 
568
 
569
macro copyimg img2_off,img1_off
569
macro copyimg img2_off,img1_off
570
{
570
{
571
    mov  eax,dword [img1_off]
571
    mov  eax,dword [img1_off]
572
    mov  ebx,dword [img1_off+4]
572
    mov  ebx,dword [img1_off+4]
573
    mul  ebx
573
    mul  ebx
574
    lea  ecx,[eax+2*eax]
574
    lea  ecx,[eax+2*eax]
575
    lea  esi,[img1_off+8]
575
    lea  esi,[img1_off+8]
576
    lea  edi,[img2_off+8]
576
    lea  edi,[img2_off+8]
577
    cld
577
    cld
578
    rep  movsb
578
    rep  movsb
579
}
579
}
580
 
580
 
581
macro fullimg img_off,xs,ys,color
581
macro fullimg img_off,xs,ys,color
582
{
582
{
583
local cop
583
local cop
584
    mov eax,xs
584
    mov eax,xs
585
    mov ebx,ys
585
    mov ebx,ys
586
    mov  dword [img_off],eax
586
    mov  dword [img_off],eax
587
    mov  dword [img_off+4],ebx
587
    mov  dword [img_off+4],ebx
588
    mul  ebx
588
    mul  ebx
589
    lea  ebp,[eax+2*eax]
589
    lea  ebp,[eax+2*eax]
590
    mov  esi,color
590
    mov  esi,color
591
if color eqtype 0
591
if color eqtype 0
592
    mov  ecx,color/65536
592
    mov  ecx,color/65536
593
else
593
else
594
    mov  ecx,esi
594
    mov  ecx,esi
595
    shr  ecx,16
595
    shr  ecx,16
596
end if
596
end if
597
    xor  edi,edi
597
    xor  edi,edi
598
cop:
598
cop:
599
    mov  word [img_off+8+edi],si
599
    mov  word [img_off+8+edi],si
600
    add  edi,2
600
    add  edi,2
601
    mov  byte [img_off+8+edi],cl
601
    mov  byte [img_off+8+edi],cl
602
    inc  edi
602
    inc  edi
603
    cmp  edi,ebp
603
    cmp  edi,ebp
604
    jne  cop
604
    jne  cop
605
}
605
}
606
 
606
 
607
 
607
 
608
 
608
 
609
  ; number of frame in ecx
609
  ; number of frame in ecx
610
  ; callculatin offset of raw data
610
  ; callculatin offset of raw data
611
 
611
 
612
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
612
macro getframeoff num_of_frame,offset_of_animation,offset_of_frame
613
{
613
{
614
local loo,setpic
614
local loo,setpic
615
  mov ebp,num_of_frame ;ecx
615
  mov ebp,num_of_frame ;ecx
616
  mov esi,offset_of_animation;Image
616
  mov esi,offset_of_animation;Image
617
loo:
617
loo:
618
  cmp ebp,0
618
  cmp ebp,0
619
  je  setpic
619
  je  setpic
620
  movzx eax,word [esi+4]
620
  movzx eax,word [esi+4]
621
  movzx ebx,word [esi+6]
621
  movzx ebx,word [esi+6]
622
  mul ebx ;dword [esi+4]
622
  mul ebx ;dword [esi+4]
623
  mov ebx,3
623
  mov ebx,3
624
  mul ebx
624
  mul ebx
625
  add eax,8
625
  add eax,8
626
  add esi,eax
626
  add esi,eax
627
  dec ebp
627
  dec ebp
628
  jmp loo
628
  jmp loo
629
setpic:
629
setpic:
630
  mov dword offset_of_frame,esi
630
  mov dword offset_of_frame,esi
631
}
631
}
632
 
632
 
633
 
633
 
634
; BMPTOIMG -Convert BMP format TO IMG format
634
; BMPTOIMG -Convert BMP format TO IMG format
635
; (SYNTAX)  BMPTOIMG BMP_source_offset,IMG_dest_ofset
635
; (SYNTAX)  BMPTOIMG BMP_source_offset,IMG_dest_ofset
636
; (SAMPLE)  View BMPLS.ASM sample.
636
; (SAMPLE)  View BMPLS.ASM sample.
637
; ( NOTE )  This is macros is not brake bmp structure! Tested in 32,8,4 bits
637
; ( NOTE )  This is macros is not brake bmp structure! Tested in 32,8,4 bits
638
 
638
 
639
 
639
 
640
bmptoimg_data_area_count=0
640
bmptoimg_data_area_count=0
641
macro bmptoimg bmp_load_area,img_dest_area
641
macro bmptoimg bmp_load_area,img_dest_area
642
{
642
{
643
local fileinfo,string,end_bmp,nodix
643
local fileinfo,string,end_bmp,nodix
644
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
644
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
645
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
645
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
646
;local qwe,bmpfn
646
;local qwe,bmpfn
647
 
647
 
648
;  convert:
648
;  convert:
649
    movzx eax,word [bmp_load_area+28]
649
    movzx eax,word [bmp_load_area+28]
650
    mul  dword [bmp_load_area+18]
650
    mul  dword [bmp_load_area+18]
651
    add  eax,31
651
    add  eax,31
652
    shr  eax,5
652
    shr  eax,5
653
    mov  dword [bmptoimg_data_area_dwps],eax  ;dwps-doublewords per string
653
    mov  dword [bmptoimg_data_area_dwps],eax  ;dwps-doublewords per string
654
    shl  eax,2
654
    shl  eax,2
655
    mov  dword [bmptoimg_data_area_bps],eax   ;bps-bytes per string
655
    mov  dword [bmptoimg_data_area_bps],eax   ;bps-bytes per string
656
 
656
 
657
    cmp dword [bmp_load_area+34],0
657
    cmp dword [bmp_load_area+34],0
658
    jne  yespicsize  ;if picture size is defined
658
    jne  yespicsize  ;if picture size is defined
659
    mul dword [bmp_load_area+22]
659
    mul dword [bmp_load_area+22]
660
    mov dword [bmp_load_area+34],eax
660
    mov dword [bmp_load_area+34],eax
661
 
661
 
662
  yespicsize:
662
  yespicsize:
663
    mov ebp,img_dest_area+8
663
    mov ebp,img_dest_area+8
664
 
664
 
665
    mov  eax,bmp_load_area
665
    mov  eax,bmp_load_area
666
    mov  ebx,eax
666
    mov  ebx,eax
667
    add  ebx, [bmp_load_area+2];file size
667
    add  ebx, [bmp_load_area+2];file size
668
    inc  ebx
668
    inc  ebx
669
    mov  dword [bmptoimg_soi],ebx   ;soi-start of image area for drawing
669
    mov  dword [bmptoimg_soi],ebx   ;soi-start of image area for drawing
670
 
670
 
671
    add  eax, [bmp_load_area+10]
671
    add  eax, [bmp_load_area+10]
672
    mov  dword [bmptoimg_data_area_sop],eax   ;sop-start of picture in file
672
    mov  dword [bmptoimg_data_area_sop],eax   ;sop-start of picture in file
673
    add  eax, [bmp_load_area+34]
673
    add  eax, [bmp_load_area+34]
674
    mov  dword [bmptoimg_data_area_eop],eax   ;eop-end of picture in file
674
    mov  dword [bmptoimg_data_area_eop],eax   ;eop-end of picture in file
675
    mov  eax, [bmp_load_area+18]
675
    mov  eax, [bmp_load_area+18]
676
    lea  eax,[eax+2*eax]   ;3x pixels in eax
676
    lea  eax,[eax+2*eax]   ;3x pixels in eax
677
 
677
 
678
    mov  edi,dword [bmptoimg_soi]   ;initializing
678
    mov  edi,dword [bmptoimg_soi]   ;initializing
679
    mov  esi,dword [bmptoimg_data_area_eop]
679
    mov  esi,dword [bmptoimg_data_area_eop]
680
    sub  esi,dword [bmptoimg_data_area_bps]
680
    sub  esi,dword [bmptoimg_data_area_bps]
681
 
681
 
682
 
682
 
683
  nextstring:
683
  nextstring:
684
    push edi
684
    push edi
685
    push ebp
685
    push ebp
686
    cmp  word [bmp_load_area+28],24
686
    cmp  word [bmp_load_area+28],24
687
    jne  convertno32
687
    jne  convertno32
688
 
688
 
689
    mov edi,ebp
689
    mov edi,ebp
690
    mov  ecx,[bmptoimg_data_area_dwps]
690
    mov  ecx,[bmptoimg_data_area_dwps]
691
    cld
691
    cld
692
    rep movsd
692
    rep movsd
693
 
693
 
694
  convert1:
694
  convert1:
695
    pop  ebp
695
    pop  ebp
696
    pop  edi
696
    pop  edi
697
    sub  esi,dword [bmptoimg_data_area_bps]
697
    sub  esi,dword [bmptoimg_data_area_bps]
698
    sub  esi,dword [bmptoimg_data_area_bps]
698
    sub  esi,dword [bmptoimg_data_area_bps]
699
    cmp  esi,dword [bmptoimg_data_area_sop]
699
    cmp  esi,dword [bmptoimg_data_area_sop]
700
    jb	 end_bmp
700
    jb	 end_bmp
701
    add  edi,eax
701
    add  edi,eax
702
    add  ebp,eax
702
    add  ebp,eax
703
    jmp  nextstring
703
    jmp  nextstring
704
 
704
 
705
  convertno32:
705
  convertno32:
706
    mov  ebx,bmp_load_area
706
    mov  ebx,bmp_load_area
707
    add  ebx, [bmp_load_area+14]
707
    add  ebx, [bmp_load_area+14]
708
    add  ebx,14 	 ;start of color table
708
    add  ebx,14 	 ;start of color table
709
    push esi
709
    push esi
710
    add  esi,dword [bmptoimg_data_area_bps]
710
    add  esi,dword [bmptoimg_data_area_bps]
711
    mov  dword [bmptoimg_data_area_eos],esi
711
    mov  dword [bmptoimg_data_area_eos],esi
712
    pop  esi
712
    pop  esi
713
  nextelem:
713
  nextelem:
714
    push eax
714
    push eax
715
    movzx eax,byte [esi]
715
    movzx eax,byte [esi]
716
    cmp  word [bmp_load_area+28],4
716
    cmp  word [bmp_load_area+28],4
717
    je	 convert4bpp
717
    je	 convert4bpp
718
    cmp  word [bmp_load_area+28],1
718
    cmp  word [bmp_load_area+28],1
719
    je	 convert1bpp
719
    je	 convert1bpp
720
    call converttable
720
    call converttable
721
 
721
 
722
  convert2:
722
  convert2:
723
    pop  eax
723
    pop  eax
724
    inc  esi
724
    inc  esi
725
    cmp  esi,dword [bmptoimg_data_area_eos]
725
    cmp  esi,dword [bmptoimg_data_area_eos]
726
    jae  convert1
726
    jae  convert1
727
    add  edi,3
727
    add  edi,3
728
 
728
 
729
    add  ebp,3
729
    add  ebp,3
730
 
730
 
731
    jmp  nextelem
731
    jmp  nextelem
732
 
732
 
733
  convert4bpp:
733
  convert4bpp:
734
    shl  ax,4
734
    shl  ax,4
735
    shr  al,4
735
    shr  al,4
736
    push ax
736
    push ax
737
    movzx eax,ah
737
    movzx eax,ah
738
    call converttable
738
    call converttable
739
    add  edi,3
739
    add  edi,3
740
 
740
 
741
    add ebp,3
741
    add ebp,3
742
 
742
 
743
    pop  ax
743
    pop  ax
744
    movzx eax,al
744
    movzx eax,al
745
    call converttable
745
    call converttable
746
    jmp  convert2
746
    jmp  convert2
747
 
747
 
748
  convert1bpp:
748
  convert1bpp:
749
    mov  ecx,eax
749
    mov  ecx,eax
750
    mov  edx,7
750
    mov  edx,7
751
  nextbit:
751
  nextbit:
752
    xor  eax,eax
752
    xor  eax,eax
753
    bt	 ecx,edx
753
    bt	 ecx,edx
754
    jnc  noaddelem
754
    jnc  noaddelem
755
    inc  eax
755
    inc  eax
756
  noaddelem:
756
  noaddelem:
757
    push edx
757
    push edx
758
    call converttable
758
    call converttable
759
    pop  edx
759
    pop  edx
760
    dec  edx
760
    dec  edx
761
    js	 convert2
761
    js	 convert2
762
    add  edi,3
762
    add  edi,3
763
 
763
 
764
    add  ebp,3
764
    add  ebp,3
765
 
765
 
766
    jmp  nextbit
766
    jmp  nextbit
767
 
767
 
768
  converttable:
768
  converttable:
769
    shl  eax,2
769
    shl  eax,2
770
    add  eax,ebx
770
    add  eax,ebx
771
    mov  edx, dword [eax]
771
    mov  edx, dword [eax]
772
;    mov  dword [edi],edx
772
;    mov  dword [edi],edx
773
    mov [ebp],edx
773
    mov [ebp],edx
774
    ret
774
    ret
775
 
775
 
776
bmptoimg_data_area_count=bmptoimg_data_area_count+1
776
bmptoimg_data_area_count=bmptoimg_data_area_count+1
777
if bmptoimg_data_area_count = 1
777
if bmptoimg_data_area_count = 1
778
; DATA AREA
778
; DATA AREA
779
bmptoimg_soi		    dd 0
779
bmptoimg_soi		    dd 0
780
bmptoimg_data_area_bps	    dd 0
780
bmptoimg_data_area_bps	    dd 0
781
bmptoimg_data_area_dwps     dd 0
781
bmptoimg_data_area_dwps     dd 0
782
bmptoimg_data_area_sop	    dd 0
782
bmptoimg_data_area_sop	    dd 0
783
bmptoimg_data_area_eop	    dd 0
783
bmptoimg_data_area_eop	    dd 0
784
bmptoimg_data_area_eos	    dd 0
784
bmptoimg_data_area_eos	    dd 0
785
end if
785
end if
786
 
786
 
787
end_bmp:
787
end_bmp:
788
    mov  eax,dword [bmp_load_area+18]
788
    mov  eax,dword [bmp_load_area+18]
789
    mov  ebx,dword [bmp_load_area+22]
789
    mov  ebx,dword [bmp_load_area+22]
790
    mov  dword [img_dest_area],eax
790
    mov  dword [img_dest_area],eax
791
    mov  dword [img_dest_area+4],ebx
791
    mov  dword [img_dest_area+4],ebx
792
}
792
}
-
 
793
 
793
 
794
if used ReadGIF
794
; For convert RGB to BGR
795
; For convert RGB to BGR
-
 
796
COLOR_ORDER equ MENUETOS
-
 
797
include 'gif_lite.inc'
795
COLOR_ORDER equ MENUETOS
798
end if
796
 
799
 
797
macro giftoani gifsrc,imgsrc,num_of_frames
800
macro giftoani gifsrc,imgsrc,num_of_frames
798
{
801
{
799
local hasharea, ReadGIF, nextblock,_null
-
 
800
local globalColor, img_count, cur_info, img_start
802
gif_img_count = num_of_frames
801
local codesize, compsize, bit_count, CC, EOI, Palette
-
 
802
local block_ofs, table_ptr, gifmacend
-
 
803
local no_gc, block_skip, no_comm, noextblock, uselocal
-
 
804
local setPal, filltable, reinit, cycle, zadd, noinc
-
 
805
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
-
 
806
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
-
 
807
local Gif_output, next, loop2
-
 
808
 
-
 
809
_null = 0x1000 ; 0x1000
-
 
810
 
-
 
811
;    jmp sss
-
 
812
;    if defined gif_hash_offset
803
        mov     esi, gifsrc
813
;    else
-
 
814
;    hasharea:
-
 
815
;    times 4096 dd 0 ;4096
804
        mov     edi, imgsrc
816
;    end if
-
 
817
;sss:
-
 
818
 
-
 
819
    mov  esi,gifsrc	      ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
-
 
820
    mov  edi,imgsrc	      ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
-
 
821
 
-
 
822
    if defined gif_hash_offset
-
 
823
    mov  eax,gif_hash_offset	; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
-
 
824
    else
-
 
825
    mov  eax,hasharea	      ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
-
 
826
    end if
-
 
827
 
-
 
828
    call ReadGIF
805
        call    ReadGIF
829
    push ecx
-
 
830
    pop  dword num_of_frames
-
 
831
    jmp  gifmacend
-
 
832
 
-
 
833
    if defined gif_hash_offset
-
 
834
    else
-
 
835
    hasharea:
-
 
836
    times 4096 dd 0 ;4096
-
 
837
    end if
-
 
838
 
-
 
839
ReadGIF:
-
 
840
    push esi edi
-
 
841
    mov  [table_ptr],eax
-
 
842
    mov  [cur_info],edi
-
 
843
    xor  eax,eax
-
 
844
    mov  [globalColor],eax
-
 
845
    mov  [img_count],eax
-
 
846
    inc  eax
-
 
847
    cmp  dword[esi],'GIF8'
-
 
848
    jne  er	       ; signature
-
 
849
    mov  ecx,[esi+0xa]
-
 
850
    inc  eax
-
 
851
    add  esi,0xd
-
 
852
    mov  edi,esi
-
 
853
    bt	 ecx,7
-
 
854
    jnc  nextblock
-
 
855
    mov  [globalColor],esi
-
 
856
    call Gif_skipmap
-
 
857
nextblock:
-
 
858
    cmp  byte[edi],0x21
-
 
859
    jne  noextblock
-
 
860
    inc  edi
-
 
861
    cmp  byte[edi],0xf9 ; Graphic Control Ext
-
 
862
    jne  no_gc
-
 
863
    add  edi,7
-
 
864
    jmp  nextblock
-
 
865
no_gc:
-
 
866
    cmp  byte[edi],0xfe ; Comment Ext
-
 
867
    jne  no_comm
-
 
868
    inc  edi
-
 
869
block_skip:
-
 
870
    movzx eax,byte[edi]
-
 
871
    lea  edi,[edi+eax+1]
-
 
872
    cmp  byte[edi],0
-
 
873
    jnz  block_skip
-
 
874
    inc  edi
-
 
875
    jmp  nextblock
-
 
876
no_comm:
-
 
877
    cmp  byte[edi],0xff ; Application Ext
-
 
878
    jne  nextblock
-
 
879
    add  edi,13
-
 
880
    jmp  block_skip
-
 
881
noextblock:
-
 
882
    cmp  byte[edi],0x2c    ; image beginning
-
 
883
    jne  er
-
 
884
    inc  [img_count]
-
 
885
    inc  edi
-
 
886
    mov  esi,[cur_info]
-
 
887
    xchg esi,edi
-
 
888
    movsd
-
 
889
    movsd
-
 
890
 
-
 
891
    push edi
-
 
892
    movzx ecx,word[esi]
-
 
893
    inc  esi
-
 
894
    bt	 ecx,7
-
 
895
    jc	 uselocal
-
 
896
    push [globalColor]
-
 
897
    mov  edi,esi
-
 
898
    jmp  setPal
-
 
899
uselocal:
-
 
900
    call Gif_skipmap
-
 
901
    push esi
-
 
902
setPal:
-
 
903
    movzx ecx,byte[edi]
-
 
904
    inc  ecx
-
 
905
    mov  [codesize],ecx
-
 
906
    dec  ecx
-
 
907
    pop  [Palette]
-
 
908
    lea  esi,[edi+1]
-
 
909
    mov  edi,[table_ptr]
-
 
910
    xor  eax,eax
-
 
911
    cld
-
 
912
    lodsb		; eax - block_count
-
 
913
    add  eax,esi
-
 
914
    mov  [block_ofs],eax
-
 
915
    mov  [bit_count],8
-
 
916
    mov  eax,1
-
 
917
    shl  eax,cl
-
 
918
    mov  [CC],eax
-
 
919
    inc  eax
-
 
920
    mov  [EOI],eax
-
 
921
    lea  ecx,[eax-1]
-
 
922
    mov  eax, _null shl 16
-
 
923
filltable:
-
 
924
    stosd
-
 
925
    inc  eax
-
 
926
    loop filltable
-
 
927
    pop  edi
-
 
928
    mov  [img_start],edi
-
 
929
reinit:
-
 
930
    mov  edx,[EOI]
-
 
931
    inc  edx
-
 
932
    push [codesize]
-
 
933
    pop  [compsize]
-
 
934
    call Gif_get_sym
-
 
935
    cmp  eax,[CC]
-
 
936
    je	 reinit
-
 
937
    call Gif_output
-
 
938
cycle:
-
 
939
    movzx ebx,ax
-
 
940
    call Gif_get_sym
-
 
941
    cmp  eax,edx
-
 
942
    jae  notintable
-
 
943
    cmp  eax,[CC]
-
 
944
    je	 reinit
-
 
945
    cmp  eax,[EOI]
-
 
946
    je	 zend
-
 
947
    call Gif_output
-
 
948
zadd:
-
 
949
    push eax
-
 
950
    mov  eax,[table_ptr]
-
 
951
    mov  [eax+edx*4],ebx
-
 
952
    pop  eax
-
 
953
    cmp  edx,0xFFF
-
 
954
    jae  cycle
-
 
955
    inc  edx
-
 
956
    bsr  ebx,edx
-
 
957
    cmp  ebx,[compsize]
-
 
958
    jne  noinc
-
 
959
    inc  [compsize]
-
 
960
noinc:
-
 
961
    jmp  cycle
-
 
962
notintable:
-
 
963
    push eax
-
 
964
    mov  eax,ebx
-
 
965
    call Gif_output
-
 
966
    push ebx
-
 
967
    movzx eax,bx
-
 
968
    call Gif_output
-
 
969
    pop  ebx eax
-
 
970
    jmp  zadd
-
 
971
er:
-
 
972
    pop  edi
-
 
973
    jmp  ex
-
 
974
zend:
-
 
975
;    mov  eax,[.cur_info]    ; skip offset to next frame
-
 
976
;    mov  [eax],edi
-
 
977
    mov  [cur_info],edi
-
 
978
    add  esi,2
-
 
979
    xchg esi,edi
-
 
980
nxt:
-
 
981
    cmp  byte[edi],0
-
 
982
    jnz  continue
-
 
983
    inc  edi
-
 
984
    jmp  nxt
-
 
985
continue:
-
 
986
    cmp  byte[edi],0x3b    ;read next frame
-
 
987
    jne  nextblock
-
 
988
    xor  eax,eax
-
 
989
    stosd
-
 
990
    mov  ecx,[img_count]
-
 
991
ex:
-
 
992
    pop  edi esi
-
 
993
    ret
-
 
994
 
-
 
995
Gif_skipmap:
-
 
996
; in: ecx - image descriptor, esi - pointer to colormap
-
 
997
; out: edi - pointer to area after colormap
-
 
998
 
-
 
999
    and  ecx,111b
-
 
1000
    inc  ecx		; color map size
-
 
1001
    mov  ebx,1
-
 
1002
    shl  ebx,cl
-
 
1003
    lea  ebx,[ebx*2+ebx]
-
 
1004
    lea  edi,[esi+ebx]
-
 
1005
    ret
-
 
1006
 
-
 
1007
Gif_get_sym:
-
 
1008
    mov  ecx,[compsize]
-
 
1009
    push ecx
-
 
1010
    xor  eax,eax
-
 
1011
shift:
-
 
1012
    ror  byte[esi],1
-
 
1013
    rcr  eax,1
-
 
1014
    dec  [bit_count]
-
 
1015
    jnz  loop1
-
 
1016
    inc  esi
-
 
1017
    cmp  esi,[block_ofs]
-
 
1018
    jb	 noblock
-
 
1019
    push eax
-
 
1020
    xor  eax,eax
-
 
1021
    lodsb
-
 
1022
    test eax,eax
-
 
1023
    jnz  nextbl
-
 
1024
    mov  eax,[EOI]
-
 
1025
    sub  esi,2
-
 
1026
    add  esp,8
-
 
1027
    jmp  exx
-
 
1028
nextbl:
-
 
1029
    add  eax,esi
-
 
1030
    mov  [block_ofs],eax
-
 
1031
    pop  eax
-
 
1032
noblock:
-
 
1033
    mov  [bit_count],8
-
 
1034
loop1:
-
 
1035
    loop shift
-
 
1036
    pop  ecx
-
 
1037
    rol  eax,cl
-
 
1038
exx:
-
 
1039
    xor  ecx,ecx
-
 
1040
    ret
-
 
1041
 
-
 
1042
Gif_output:
-
 
1043
    push esi eax edx
-
 
1044
    mov  edx,[table_ptr]
-
 
1045
next:
-
 
1046
    push word[edx+eax*4]
-
 
1047
    mov  ax,word[edx+eax*4+2]
-
 
1048
    inc  ecx
-
 
1049
    cmp  ax,_null
-
 
1050
    jnz  next
-
 
1051
    shl  ebx,16
-
 
1052
    mov  bx,[esp]
-
 
1053
loop2:
-
 
1054
    pop  ax
-
 
1055
 
-
 
1056
    lea  esi,[eax+eax*2]
-
 
1057
    add  esi,[Palette]
-
 
1058
 
-
 
1059
    if COLOR_ORDER eq MENUETOS
-
 
1060
	mov  esi,[esi]
-
 
1061
	bswap esi
-
 
1062
	shr  esi,8
-
 
1063
	mov  [edi],esi
-
 
1064
	add  edi,3
-
 
1065
    else
-
 
1066
	movsw
-
 
1067
	movsb
-
 
1068
    end if
-
 
1069
 
-
 
1070
    loop loop2
-
 
1071
    pop  edx eax esi
-
 
1072
    ret
-
 
1073
 
-
 
1074
    globalColor dd 1
-
 
1075
    img_count dd 1
-
 
1076
    cur_info dd 1	 ; image table pointer
-
 
1077
    img_start dd 1
-
 
1078
    codesize dd 1
-
 
1079
    compsize dd 1
-
 
1080
    bit_count dd 1
-
 
1081
    CC dd 1
-
 
1082
    EOI dd 1
-
 
1083
    Palette dd 1
-
 
1084
    block_ofs dd 1
-
 
1085
    table_ptr dd 1
-
 
1086
 
-
 
1087
gifmacend:
-
 
1088
}
806
}
1089
 
-
 
1090
 
-
 
1091
 
807
 
1092
macro giftoimg gifsrc,imgsrc
808
macro giftoimg gifsrc,imgsrc
1093
{
-
 
1094
local hasharea, ReadGIF, nextblock,_null
-
 
1095
local globalColor, img_count, cur_info, img_start
-
 
1096
local codesize, compsize, bit_count, CC, EOI, Palette
-
 
1097
local block_ofs, table_ptr, gifmacend
-
 
1098
local no_gc, block_skip, no_comm, noextblock, uselocal
-
 
1099
local setPal, filltable, reinit, cycle, zadd, noinc
-
 
1100
local notintable, er, zend, nxt, continue, ex, Gif_skipmap
-
 
1101
local Gif_get_sym, shift, nextbl, noblock, loop1, exx
-
 
1102
local Gif_output, next, loop2
-
 
1103
 
-
 
1104
_null = 0x1000 ; 0x1000
-
 
1105
 
-
 
1106
    mov  esi,gifsrc	      ;“ª § â¥«ì ­  ƒˆ” ä ¨« ¢ ¯ ¬ïâ¨
-
 
1107
    mov  edi,imgsrc	      ;“ª § â¥«ì ­  ᯨ᮪ ª à⨭®ª
-
 
1108
 
809
{
1109
    if defined gif_hash_offset
810
if defined gif_img_count
1110
    mov  eax,gif_hash_offset	; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
-
 
1111
    else
-
 
1112
    mov  eax,hasharea	      ; ¡®ç ï ®¡« áâì ¬¨­¨¬ã¬ 4096*4 ¡ ©â
811
error 'giftoimg cannot be used in GIF multiple images mode. Use giftoani instead.'
1113
    end if
-
 
-
 
812
end if
-
 
813
        mov     esi, gifsrc
1114
 
814
        mov     edi, imgsrc
1115
    call ReadGIF
-
 
1116
    jmp  gifmacend
-
 
1117
 
-
 
1118
    if defined gif_hash_offset
-
 
1119
    else
-
 
1120
    hasharea:
-
 
1121
    times 4096 dd 0 ;4096
-
 
1122
    end if
-
 
1123
 
-
 
1124
ReadGIF:
-
 
1125
    push esi edi
-
 
1126
    mov  [table_ptr],eax
-
 
1127
    mov  [cur_info],edi
-
 
1128
    xor  eax,eax
-
 
1129
    mov  [globalColor],eax
-
 
1130
    mov  [img_count],eax
-
 
1131
    inc  eax
-
 
1132
    cmp  dword[esi],'GIF8'
-
 
1133
    jne  er	       ; signature
-
 
1134
    mov  ecx,[esi+0xa]
-
 
1135
    inc  eax
-
 
1136
    add  esi,0xd
-
 
1137
    mov  edi,esi
-
 
1138
    bt	 ecx,7
-
 
1139
    jnc  nextblock
-
 
1140
    mov  [globalColor],esi
-
 
1141
    call Gif_skipmap
-
 
1142
nextblock:
-
 
1143
    cmp  byte[edi],0x21
-
 
1144
    jne  noextblock
-
 
1145
    inc  edi
-
 
1146
    cmp  byte[edi],0xf9 ; Graphic Control Ext
-
 
1147
    jne  no_gc
-
 
1148
    add  edi,7
-
 
1149
    jmp  nextblock
-
 
1150
no_gc:
-
 
1151
    cmp  byte[edi],0xfe ; Comment Ext
-
 
1152
    jne  no_comm
-
 
1153
    inc  edi
-
 
1154
block_skip:
-
 
1155
    movzx eax,byte[edi]
-
 
1156
    lea  edi,[edi+eax+1]
-
 
1157
    cmp  byte[edi],0
-
 
1158
    jnz  block_skip
-
 
1159
    inc  edi
-
 
1160
    jmp  nextblock
-
 
1161
no_comm:
-
 
1162
    cmp  byte[edi],0xff ; Application Ext
-
 
1163
    jne  nextblock
-
 
1164
    add  edi,13
-
 
1165
    jmp  block_skip
-
 
1166
noextblock:
-
 
1167
    cmp  byte[edi],0x2c    ; image beginning
-
 
1168
    jne  er
-
 
1169
    inc  [img_count]
-
 
1170
    inc  edi
-
 
1171
    mov  esi,[cur_info]
-
 
1172
    xchg esi,edi
-
 
1173
;    movsd
-
 
1174
;    movsd
-
 
1175
 
-
 
1176
    mov   bp,word[esi+4]
-
 
1177
    movzx ebx,bp
-
 
1178
    mov   [edi],ebx
-
 
1179
 
-
 
1180
    mov   bp,word[esi+6]
-
 
1181
    movzx ebx,bp
-
 
1182
    mov   [edi+4],ebx
-
 
1183
 
-
 
1184
    add edi,8
-
 
1185
    add esi,8
-
 
1186
 
-
 
1187
    push edi
-
 
1188
    movzx ecx,word[esi]
-
 
1189
    inc  esi
-
 
1190
    bt	 ecx,7
-
 
1191
    jc	 uselocal
-
 
1192
    push [globalColor]
-
 
1193
    mov  edi,esi
-
 
1194
    jmp  setPal
-
 
1195
uselocal:
-
 
1196
    call Gif_skipmap
-
 
1197
    push esi
-
 
1198
setPal:
-
 
1199
    movzx ecx,byte[edi]
-
 
1200
    inc  ecx
-
 
1201
    mov  [codesize],ecx
-
 
1202
    dec  ecx
-
 
1203
    pop  [Palette]
-
 
1204
    lea  esi,[edi+1]
-
 
1205
    mov  edi,[table_ptr]
-
 
1206
    xor  eax,eax
-
 
1207
    cld
-
 
1208
    lodsb		; eax - block_count
-
 
1209
    add  eax,esi
-
 
1210
    mov  [block_ofs],eax
-
 
1211
    mov  [bit_count],8
-
 
1212
    mov  eax,1
-
 
1213
    shl  eax,cl
-
 
1214
    mov  [CC],eax
-
 
1215
    inc  eax
-
 
1216
    mov  [EOI],eax
-
 
1217
    lea  ecx,[eax-1]
-
 
1218
    mov  eax, _null shl 16
-
 
1219
filltable:
-
 
1220
    stosd
-
 
1221
    inc  eax
-
 
1222
    loop filltable
-
 
1223
    pop  edi
-
 
1224
    mov  [img_start],edi
-
 
1225
reinit:
-
 
1226
    mov  edx,[EOI]
-
 
1227
    inc  edx
-
 
1228
    push [codesize]
-
 
1229
    pop  [compsize]
-
 
1230
    call Gif_get_sym
-
 
1231
    cmp  eax,[CC]
-
 
1232
    je	 reinit
-
 
1233
    call Gif_output
-
 
1234
cycle:
-
 
1235
    movzx ebx,ax
-
 
1236
    call Gif_get_sym
-
 
1237
    cmp  eax,edx
-
 
1238
    jae  notintable
-
 
1239
    cmp  eax,[CC]
-
 
1240
    je	 reinit
-
 
1241
    cmp  eax,[EOI]
-
 
1242
    je	 zend
-
 
1243
    call Gif_output
-
 
1244
zadd:
-
 
1245
    push eax
-
 
1246
    mov  eax,[table_ptr]
-
 
1247
    mov  [eax+edx*4],ebx
-
 
1248
    pop  eax
-
 
1249
    cmp  edx,0xFFF
-
 
1250
    jae  cycle
-
 
1251
    inc  edx
-
 
1252
    bsr  ebx,edx
-
 
1253
    cmp  ebx,[compsize]
-
 
1254
    jne  noinc
-
 
1255
    inc  [compsize]
-
 
1256
noinc:
-
 
1257
    jmp  cycle
-
 
1258
notintable:
-
 
1259
    push eax
-
 
1260
    mov  eax,ebx
-
 
1261
    call Gif_output
-
 
1262
    push ebx
-
 
1263
    movzx eax,bx
-
 
1264
    call Gif_output
-
 
1265
    pop  ebx eax
-
 
1266
    jmp  zadd
-
 
1267
er:
-
 
1268
    pop  edi
-
 
1269
    jmp  ex
-
 
1270
zend:
-
 
1271
;    mov  eax,[.cur_info]    ; skip offset to next frame
-
 
1272
;    mov  [eax],edi
-
 
1273
    mov  [cur_info],edi
-
 
1274
    add  esi,2
-
 
1275
    xchg esi,edi
-
 
1276
nxt:
-
 
1277
    cmp  byte[edi],0
-
 
1278
    jnz  continue
-
 
1279
    inc  edi
-
 
1280
    jmp  nxt
-
 
1281
continue:
-
 
1282
;    cmp  byte[edi],0x3b    ;read next frame
-
 
1283
;    jne  nextblock
-
 
1284
    xor  eax,eax
-
 
1285
    stosd
-
 
1286
    mov  ecx,[img_count]
-
 
1287
ex:
-
 
1288
    pop  edi esi
-
 
1289
    ret
-
 
1290
 
-
 
1291
Gif_skipmap:
-
 
1292
; in: ecx - image descriptor, esi - pointer to colormap
-
 
1293
; out: edi - pointer to area after colormap
-
 
1294
    and  ecx,111b
-
 
1295
    inc  ecx		; color map size
-
 
1296
    mov  ebx,1
-
 
1297
    shl  ebx,cl
-
 
1298
    lea  ebx,[ebx*2+ebx]
-
 
1299
    lea  edi,[esi+ebx]
-
 
1300
    ret
-
 
1301
 
-
 
1302
Gif_get_sym:
-
 
1303
    mov  ecx,[compsize]
-
 
1304
    push ecx
-
 
1305
    xor  eax,eax
-
 
1306
shift:
-
 
1307
    ror  byte[esi],1
-
 
1308
    rcr  eax,1
-
 
1309
    dec  [bit_count]
-
 
1310
    jnz  loop1
-
 
1311
    inc  esi
-
 
1312
    cmp  esi,[block_ofs]
-
 
1313
    jb	 noblock
-
 
1314
    push eax
-
 
1315
    xor  eax,eax
-
 
1316
    lodsb
-
 
1317
    test eax,eax
-
 
1318
    jnz  nextbl
-
 
1319
    mov  eax,[EOI]
-
 
1320
    sub  esi,2
-
 
1321
    add  esp,8
-
 
1322
    jmp  exx
-
 
1323
nextbl:
-
 
1324
    add  eax,esi
-
 
1325
    mov  [block_ofs],eax
-
 
1326
    pop  eax
-
 
1327
noblock:
-
 
1328
    mov  [bit_count],8
-
 
1329
loop1:
-
 
1330
    loop shift
-
 
1331
    pop  ecx
-
 
1332
    rol  eax,cl
-
 
1333
exx:
-
 
1334
    xor  ecx,ecx
-
 
1335
    ret
-
 
1336
 
-
 
1337
Gif_output:
-
 
1338
    push esi eax edx
-
 
1339
    mov  edx,[table_ptr]
-
 
1340
next:
-
 
1341
    push word[edx+eax*4]
-
 
1342
    mov  ax,word[edx+eax*4+2]
-
 
1343
    inc  ecx
-
 
1344
    cmp  ax,_null
-
 
1345
    jnz  next
-
 
1346
    shl  ebx,16
-
 
1347
    mov  bx,[esp]
-
 
1348
loop2:
-
 
1349
    pop  ax
-
 
1350
 
-
 
1351
    lea  esi,[eax+eax*2]
-
 
1352
    add  esi,[Palette]
-
 
1353
 
-
 
1354
    if COLOR_ORDER eq MENUETOS
-
 
1355
	mov  esi,[esi]
-
 
1356
	bswap esi
-
 
1357
	shr  esi,8
-
 
1358
	mov  [edi],esi
-
 
1359
	add  edi,3
-
 
1360
    else
-
 
1361
	movsw
-
 
1362
	movsb
-
 
1363
    end if
-
 
1364
 
-
 
1365
    loop loop2
-
 
1366
    pop  edx eax esi
-
 
1367
    ret
-
 
1368
 
-
 
1369
    globalColor dd 1
-
 
1370
    img_count dd 1
-
 
1371
    cur_info dd 1	 ; image table pointer
-
 
1372
    img_start dd 1
-
 
1373
    codesize dd 1
-
 
1374
    compsize dd 1
-
 
1375
    bit_count dd 1
-
 
1376
    CC dd 1
-
 
1377
    EOI dd 1
-
 
1378
    Palette dd 1
-
 
1379
    block_ofs dd 1
-
 
1380
    table_ptr dd 1
-
 
1381
 
-
 
1382
gifmacend:
815
        call    ReadGIF
1383
}
-
 
-
 
816
}