Subversion Repositories Kolibri OS

Rev

Rev 552 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 552 Rev 9241
Line 5... Line 5...
5
;     SMALL
5
;     SMALL
6
;       CODE
6
;       CODE
7
;         Graphics
7
;         Graphics
8
;           Libary
8
;           Libary
9
;
9
;
-
 
10
;   Ver 0.18
-
 
11
;
-
 
12
 
10
;   Ver 0.18 By Pavlushin Evgeni (RUSSIA)
13
; draw image into image with alpha color mask
-
 
14
; image_draw_acimage dest, source, x, y, alpha_color
-
 
15
;
-
 
16
macro image_draw_acimage dest, source, x, y, alpha_color
-
 
17
{
-
 
18
local next_pix,next_line,skip_pix,no_skip
-
 
19
   push dest
-
 
20
   push source
-
 
21
   push x
-
 
22
   push y
11
;   www.waptap@mail.ru
23
   push alpha_color
-
 
24
   pop ebp  ; alpha color
-
 
25
   pop eax  ; y
-
 
26
   pop ebx  ; x
-
 
27
   pop esi  ; src
-
 
28
   pop edi  ; dest
-
 
29
   call image_draw_acimage_proc
-
 
30
 
-
 
31
if ~ defined image_draw_acimage_used
-
 
32
image_draw_acimage_used equ 1
-
 
33
 
-
 
34
   jmp end_image_draw_acimage_proc
-
 
35
image_draw_acimage_proc:
-
 
36
   mov ecx,dword [edi]   ; ecx = canvas width
-
 
37
   mul ecx       ; edx:eax = ypos * canvas width
-
 
38
   add eax,ebx   ; eax =  (ypos * canvas width) + xpos
-
 
39
   lea eax,[eax+eax*2+8] ; eax=(y*xsize+x)*3+8 (8=skip xy size dwords)
-
 
40
 
-
 
41
   mov edx,[esi]   ; edx = img width
-
 
42
   sub ecx,edx     ; ecx = canvas width - img width
-
 
43
   lea ebx,[ecx*2+ecx] ; ebx = how many pixels skip for new line
-
 
44
   mov ecx,[esi+4] ; ecx = img height
-
 
45
   add esi,8       ; esi + 8 for skip xy size dwords
-
 
46
   add edi,eax     ; edi = dest position
-
 
47
   shl ebp,8       ; for fast compare with alpha color
-
 
48
   cld             ; set movs direction flag
-
 
49
next_line:
-
 
50
   push edx
-
 
51
next_pix:
-
 
52
   mov eax,[esi]
-
 
53
   shl eax,8
-
 
54
   cmp eax,ebp
-
 
55
   je  skip_pix
-
 
56
   movsw
-
 
57
   movsb
-
 
58
   jmp no_skip
-
 
59
skip_pix:
-
 
60
   add esi,3
-
 
61
   add edi,3
-
 
62
no_skip:
-
 
63
   dec edx
-
 
64
   jnz next_pix
-
 
65
   pop edx
-
 
66
   add edi,ebx
-
 
67
   dec ecx
-
 
68
   jnz next_line
-
 
69
   ret
-
 
70
end_image_draw_acimage_proc :
-
 
71
end if
-
 
72
 
-
 
73
}
-
 
74
 
-
 
75
macro image_set_size image,width,height
-
 
76
{
-
 
77
   mov dword [image],width
-
 
78
   mov dword [image+4],height
-
 
79
}
-
 
80
 
-
 
81
; label - draw label on window
-
 
82
; example:
-
 
83
; label 10,12,'Hello World!',cl_Green+font_size_x4+utf16
-
 
84
 
-
 
85
macro image_draw_label image,x,y,text,color
-
 
86
{
-
 
87
local label_text
-
 
88
   draw_to_buffer   equ 00001000b shl 24
-
 
89
   jmp @f
-
 
90
label_text db text
-
 
91
@@:
-
 
92
   words2reg ebx,x,y       ; ebx - position
-
 
93
   dword2reg ecx,color+draw_to_buffer ; ecx - color
-
 
94
   mov edi,image
-
 
95
   mov edx,label_text      ; edx - address of label text
-
 
96
   mov esi,@b-label_text   ; esi - size of libel in bytes
-
 
97
   mov eax,4
-
 
98
   mcall
-
 
99
}
-
 
100
 
-
 
101
; draw_frect - draw filled rect
-
 
102
macro draw_frect x,y,xs,ys,color
-
 
103
{
-
 
104
   wordstoreg ebx,x,xs ;x*65536+xs
-
 
105
   wordstoreg ecx,y,ys ;y*65536+ys
-
 
106
   mov  edx,color
-
 
107
   mov  eax,13
-
 
108
   mcall
-
 
109
}
-
 
110
 
-
 
111
; draw_label - Draw label in window
-
 
112
; example:
-
 
113
; draw_label 10,12,'Hello World!',cl_Green+font_size_x4+utf16
Line -... Line 114...
-
 
114
 
12
 
115
macro draw_label x,y,text,color
13
;InfoList
116
{
-
 
117
local label_text
-
 
118
   words2reg ebx,x,y   ; ebx - position
14
;0.01 LoadImage
119
if text eqtype 123 | text eqtype eax
15
;0.02 SetBmp
120
   movt edx,text
-
 
121
   mov ecx,color+(1 shl 31)  ; ecx - color
16
;0.03 Bmptoimg, Setimg ~01.03.2004
122
else
-
 
123
   mov edx,label_text  ; edx - address of label text
-
 
124
   jmp @f
-
 
125
label_text db text
-
 
126
@@:
17
;0.04 Bug deleted, copyimg ~03.05.2004
127
   mov esi,@b-label_text     ; esi - size of libel in bytes
-
 
128
   movt ecx,color            ; ecx - color
18
;0.05 fullimg, collimg ~05.05.2004
129
end if
-
 
130
   mov eax,4
-
 
131
   mcall
-
 
132
}
19
;0.06 getimg ~09.05.2004
133
 
20
;0.07 convbmp ~13.05.2004
134
hide_zeros equ (1 shl 31)
21
;0.08 fps ~14.05.2004
135
use_bg_color equ (1 shl 30)
-
 
136
use_big_font equ (1 shl 28)
22
;0.09 drawfbox ~03.06.2004
137
 
-
 
138
macro draw_number data, x, y, color, numtype, bg_color
-
 
139
{
-
 
140
   movt ecx,data
23
;0.10 all macros optimized by halyavin, add at ~07.06.2004
141
   movt ebx,numtype
-
 
142
   mov bl,0     ; if bl = 0, ecx is contain number
-
 
143
   words2reg edx,x,y
-
 
144
if bg_color eq
-
 
145
   movt esi,color
24
;0.11 many macros optimized by halyavin, add at ~30.08.2004
146
else
25
;0.12 bmptoimg ~07.09.2004
147
   movt esi,color+use_bg_color
-
 
148
   movt edi,bg_color
-
 
149
end if
-
 
150
   mov eax,47
-
 
151
   mcall
-
 
152
}
26
;0.13 imgtoimg ~08.09.2004
153
 
27
;0.14 imgtoimg modify not brake bmp pict! ~09.09.2004
154
; draw_image - macro for draw image on window area
-
 
155
macro draw_image x, y, image
28
;0.15 giftoimg, giftoani ~10.09.2004
156
{
29
;0.16 setframe, rgbtobgr, setbmp deleted ~20.09.2004
157
   mov ecx,[image-2]    ; -2 for except shl ecx,16
-
 
158
   mov cx,[image+4]     ; ecx = xsize*65536+ysize
30
;0.17 modification giftoimg, giftoani, getframeoff ~01.10.2004
159
   wordstoreg edx, x, y ; edx = x*65536+y
-
 
160
   lea ebx,[image+8]    ; ebx = image data address
-
 
161
   mov eax,7            ; eax = 7 is draw image function
-
 
162
   mcall
Line 31... Line 163...
31
;0.18 aframetoimg,aimgtoimg,frametoimg ~03.10.2004
163
}
32
 
164
 
33
aframetoimg_use_count=0
165
aframetoimg_use_count=0
34
macro aframetoimg img, x, y, canvas,acol
166
macro aframetoimg img, x, y, canvas,acol
35
{
167
{
36
local loo,loo2,acolor
168
local loo,loo2,acolor
Line 37... Line 169...
37
aframetoimg_use_count=aframetoimg_use_count+1
169
aframetoimg_use_count=aframetoimg_use_count+1
Line 38... Line 170...
38
if aframetoimg_use_count = 1
170
if aframetoimg_use_count = 1
39
 
171
 
40
     jmp end_aframetoimg_proc
172
   jmp end_aframetoimg_proc
41
 
173
 
Line 42... Line 174...
42
acolor dd 0
174
acolor dd 0
43
aframetoimg_proc:
175
aframetoimg_proc:
44
;getout coord
176
;getout coord
Line 45... Line 177...
45
    mov [acolor],ebp
177
   mov [acolor],ebp
46
 
178
 
47
    mov edx,ebx ;img   ;xsize
179
   mov edx,ebx ;img   ;xsize
Line 48... Line 180...
48
    movzx eax,word [edx]
180
   movzx eax,word [edx]
49
    add eax,esi ;y cor
181
   add eax,esi ;y cor
50
 
182
 
51
;    mov eax,esi ;y cor
183
;    mov eax,esi ;y cor
52
    mul dword [ecx] ;canvas xsize
184
   mul dword [ecx] ;canvas xsize
53
    add eax,edi ;x cor
185
   add eax,edi ;x cor
54
 
186
 
55
    mov ebp,ebx ;img   ;xsize
187
   mov ebp,ebx ;img   ;xsize
56
    movzx edx,word [ebp]
188
   movzx edx,word [ebp]
57
    add eax,edx
189
   add eax,edx
58
 
190
 
59
    mov ebp,eax
191
   mov ebp,eax
60
    shl eax,1
192
   shl eax,1
61
    add ebp,eax
193
   add ebp,eax
62
    add ebp,ecx ;canvas+8;start
194
   add ebp,ecx ;canvas+8;start
63
    add ebp,8
195
   add ebp,8
64
;get img size
196
;get img size
65
    add ebx,4
197
   add ebx,4
66
    mov eax,ebx ;img   ;xsize
198
   mov eax,ebx ;img   ;xsize
67
    movzx esi,word [eax]
199
   movzx esi,word [eax]
68
    movzx edi,word [eax+2]
200
   movzx edi,word [eax+2]
69
    add ebx,4
201
   add ebx,4
70
    mov edx,ebx ;img+8
202
   mov edx,ebx ;img+8
71
loo2:
203
loo2:
72
push esi
204
push esi
73
loo:
205
loo:
74
;test on alpha color
206
;test on alpha color
75
    mov eax,[edx]
207
   mov eax,[edx]
76
    shl eax,8
208
   shl eax,8
77
    shr eax,8
-
 
78
    cmp eax,[acolor]
209
   shr eax,8
79
    jne  yx
210
   cmp eax,[acolor]
80
    add edx,3
211
   jne  yx
81
    add ebp,3
212
   add edx,3
82
    jmp nx
213
   add ebp,3
83
yx:
214
   jmp nx
84
 
215
yx:
85
    mov al,byte [edx]
216
   mov al,byte [edx]
86
    mov byte [ebp],al
217
   mov byte [ebp],al
87
    inc ebp
218
   inc ebp
88
    inc edx
219
   inc edx
89
    mov al,byte [edx]
220
   mov al,byte [edx]
90
    mov byte [ebp],al
221
   mov byte [ebp],al
91
    inc ebp
222
   inc ebp
92
    inc edx
223
   inc edx
93
    mov al,byte [edx]
224
   mov al,byte [edx]
94
    mov byte [ebp],al
225
   mov byte [ebp],al
95
    inc ebp
226
   inc ebp
96
    inc edx
227
   inc edx
97
nx:
228
nx:
98
    dec esi
229
   dec esi
99
    jnz loo
230
   jnz loo
100
pop esi
231
pop esi
101
    sub ebp,3
232
   sub ebp,3
102
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
233
   mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
103
    sub eax,esi
234
   sub eax,esi
104
    add ebp,eax
235
   add ebp,eax
105
    shl eax,1
236
   shl eax,1
106
    add ebp,eax
237
   add ebp,eax
107
 
238
 
108
    add ebp,3
239
   add ebp,3
109
 
240
 
110
    dec edi
241
   dec edi
111
    jnz loo2
242
   jnz loo2
112
    ret
243
   ret
113
end_aframetoimg_proc:
244
end_aframetoimg_proc:
114
end if
245
end if
115
    push img
246
   push img
116
    push canvas
247
   push canvas
117
    push x
248
   push x
118
    push y
249
   push y
119
    push acol
250
   push acol
Line 120... Line 251...
120
    pop  ebp
251
   pop  ebp
121
    pop  esi
252
   pop  esi
122
    pop  edi
253
   pop  edi
123
    pop ecx
254
   pop ecx
124
    pop ebx
255
   pop ebx
125
    call aframetoimg_proc
256
   call aframetoimg_proc
Line 126... Line 257...
126
}
257
}
Line 127... Line 258...
127
 
258
 
128
frametoimg_use_count=0
259
frametoimg_use_count=0
129
macro frametoimg img, x, y, canvas
260
macro frametoimg img, x, y, canvas
130
{
261
{
131
local loo,loo2
262
local loo,loo2
Line 132... Line 263...
132
frametoimg_use_count=frametoimg_use_count+1
263
frametoimg_use_count=frametoimg_use_count+1
133
if frametoimg_use_count = 1
264
if frametoimg_use_count = 1
134
 
265
 
Line 135... Line 266...
135
    jmp end_frametoimg_proc
266
   jmp end_frametoimg_proc
136
 
267
 
137
frametoimg_proc:
268
frametoimg_proc:
138
;getout coord
269
;getout coord
139
    mov edx,ebx ;img   ;xsize
270
   mov edx,ebx ;img   ;xsize
140
    movzx eax,word [edx]
271
   movzx eax,word [edx]
141
    add eax,esi ;y cor
272
   add eax,esi ;y cor
142
 
273
 
143
;    mov eax,esi ;y cor
274
;    mov eax,esi ;y cor
144
    mul dword [ecx] ;canvas xsize
275
   mul dword [ecx] ;canvas xsize
145
    add eax,edi ;x cor
276
   add eax,edi ;x cor
146
 
277
 
147
    mov ebp,ebx ;img   ;xsize
278
   mov ebp,ebx ;img   ;xsize
148
    movzx edx,word [ebp]
279
   movzx edx,word [ebp]
149
    add eax,edx
280
   add eax,edx
150
 
281
 
151
    mov ebp,eax
282
   mov ebp,eax
152
    shl eax,1
283
   shl eax,1
153
    add ebp,eax
284
   add ebp,eax
154
    add ebp,ecx ;canvas+8;start
285
   add ebp,ecx ;canvas+8;start
155
    add ebp,8
286
   add ebp,8
156
;get img size
287
;get img size
157
    add ebx,4
288
   add ebx,4
158
    mov eax,ebx ;img   ;xsize
289
   mov eax,ebx ;img   ;xsize
159
    movzx esi,word [eax]
290
   movzx esi,word [eax]
160
    movzx edi,word [eax+2]
291
   movzx edi,word [eax+2]
161
    add ebx,4
292
   add ebx,4
162
    mov edx,ebx ;img+8
293
   mov edx,ebx ;img+8
163
loo2:
294
loo2:
164
push esi
295
push esi
165
loo:
296
loo:
Line 166... Line 297...
166
    mov al,byte [edx]
297
   mov al,byte [edx]
167
    mov byte [ebp],al
298
   mov byte [ebp],al
168
    inc ebp
299
   inc ebp
169
    inc edx
300
   inc edx
170
    mov al,byte [edx]
301
   mov al,byte [edx]
171
    mov byte [ebp],al
302
   mov byte [ebp],al
172
    inc ebp
303
   inc ebp
173
    inc edx
304
   inc edx
174
    mov al,byte [edx]
305
   mov al,byte [edx]
175
    mov byte [ebp],al
306
   mov byte [ebp],al
176
    inc ebp
307
   inc ebp
177
    inc edx
308
   inc edx
178
 
309
 
179
    dec esi
310
   dec esi
180
    jnz loo
311
   jnz loo
181
pop esi
312
pop esi
182
    sub ebp,3
313
   sub ebp,3
183
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
314
   mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
184
    sub eax,esi
315
   sub eax,esi
185
    add ebp,eax
316
   add ebp,eax
186
    shl eax,1
317
   shl eax,1
187
    add ebp,eax
318
   add ebp,eax
188
 
319
 
189
    add ebp,3
320
   add ebp,3
190
 
321
 
191
    dec edi
322
   dec edi
192
    jnz loo2
323
   jnz loo2
Line 193... Line -...
193
    ret
-
 
194
end_frametoimg_proc:
-
 
195
end if
-
 
196
    push img
-
 
197
    push canvas
-
 
198
    push x
-
 
199
    push y
-
 
200
    pop  esi
-
 
201
    pop  edi
-
 
202
    pop ecx
-
 
203
    pop ebx
-
 
204
    call frametoimg_proc
-
 
205
}
-
 
206
 
-
 
207
 
-
 
208
aimgtoimg_use_count=0
-
 
209
macro aimgtoimg img, x, y, canvas,acol
-
 
210
{
-
 
211
local loo,loo2,acolor
-
 
212
aimgtoimg_use_count=aimgtoimg_use_count+1
-
 
213
if aimgtoimg_use_count = 1
-
 
214
 
-
 
215
     jmp end_aimgtoimg_proc
-
 
216
 
-
 
217
acolor dd 0
-
 
218
aimgtoimg_proc:
-
 
219
;getout coord
-
 
220
    mov [acolor],ebp
-
 
221
 
-
 
222
    mov eax,esi ;y cor
-
 
223
    mul dword [ecx] ;canvas xsize
-
 
224
    add eax,edi ;x cor
-
 
225
    mov ebp,eax
-
 
226
    shl eax,1
-
 
227
    add ebp,eax
-
 
228
    add ebp,ecx ;canvas+8;start
-
 
229
    add ebp,8
-
 
230
;get img size
-
 
231
    mov eax,ebx ;img   ;xsize
-
 
232
    mov esi,[eax]
-
 
233
    add ebx,4
-
 
234
    mov eax,ebx ; img+4 ;ysize
-
 
235
    mov edi,[eax]
-
 
236
    add ebx,4
-
 
237
    mov edx,ebx ;img+8
-
 
238
loo2:
-
 
239
push esi
-
 
240
loo:
-
 
241
 
-
 
242
;test on alpha color
-
 
243
    mov eax,[edx]
-
 
244
    shl eax,8
-
 
245
    shr eax,8
-
 
246
    cmp eax,[acolor]
-
 
247
    jne  yx
-
 
248
    add edx,3
-
 
249
    add ebp,3
-
 
250
    jmp nx
-
 
251
yx:
-
 
252
 
-
 
253
    mov al,byte [edx]
-
 
254
    mov byte [ebp],al
-
 
255
    inc ebp
-
 
256
    inc edx
-
 
257
    mov al,byte [edx]
-
 
258
    mov byte [ebp],al
-
 
259
    inc ebp
-
 
260
    inc edx
-
 
261
    mov al,byte [edx]
-
 
262
    mov byte [ebp],al
-
 
263
    inc ebp
-
 
264
    inc edx
-
 
265
nx:
-
 
266
    dec esi
-
 
267
    jnz loo
-
 
268
pop esi
-
 
269
    sub ebp,3
-
 
270
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
-
 
271
    sub eax,esi
-
 
272
    add ebp,eax
-
 
273
    shl eax,1
-
 
274
    add ebp,eax
-
 
275
 
-
 
276
    add ebp,3
-
 
277
 
-
 
278
    dec edi
-
 
279
    jnz loo2
-
 
280
    ret
-
 
281
end_aimgtoimg_proc:
-
 
282
end if
-
 
283
    push img
-
 
284
    push canvas
324
   ret
285
    push x
325
end_frametoimg_proc:
286
    push y
326
end if
287
    push acol
327
   push img
288
    pop  ebp
328
   push canvas
289
    pop  esi
329
   push x
Line 290... Line 330...
290
    pop  edi
330
   push y
291
    pop ecx
331
   pop  esi
292
    pop ebx
332
   pop  edi
293
    call aimgtoimg_proc
333
   pop ecx
294
}
334
   pop ebx
295
 
335
   call frametoimg_proc
296
 
336
}
297
 
337
 
298
 
338
 
299
imgtoimg_use_count=0
339
imgtoimg_use_count=0
300
macro imgtoimg img, x, y, canvas
340
macro imgtoimg img, x, y, canvas
301
{
341
{
302
local loo,loo2
342
local loo,loo2
303
imgtoimg_use_count=imgtoimg_use_count+1
343
imgtoimg_use_count=imgtoimg_use_count+1
304
if imgtoimg_use_count = 1
344
if imgtoimg_use_count = 1
305
 
345
 
306
     jmp end_imgtoimg_proc
346
   jmp end_imgtoimg_proc
307
imgtoimg_proc:
347
imgtoimg_proc:
308
;getout coord
348
;getout coord
309
    mov eax,esi ;y cor
349
   mov eax,esi ;y cor
310
    mul dword [ecx] ;canvas xsize
350
   mul dword [ecx] ;canvas xsize
311
    add eax,edi ;x cor
351
   add eax,edi ;x cor
312
    mov ebp,eax
352
   mov ebp,eax
313
    shl eax,1
353
   shl eax,1
314
    add ebp,eax
354
   add ebp,eax
315
    add ebp,ecx ;canvas+8;start
355
   add ebp,ecx ;canvas+8;start
316
    add ebp,8
356
   add ebp,8
317
;get img size
357
;get img size
318
    mov eax,ebx ;img   ;xsize
358
   mov eax,ebx ;img   ;xsize
319
    mov esi,[eax]
359
   mov esi,[eax]
320
    add ebx,4
360
   add ebx,4
321
    mov eax,ebx ; img+4 ;ysize
361
   mov eax,ebx ; img+4 ;ysize
322
    mov edi,[eax]
362
   mov edi,[eax]
323
    add ebx,4
363
   add ebx,4
324
    mov edx,ebx ;img+8
364
   mov edx,ebx ;img+8
325
loo2:
365
loo2:
326
push esi
366
push esi
327
loo:
367
loo:
328
    mov al,byte [edx]
368
   mov al,byte [edx]
329
    mov byte [ebp],al
369
   mov byte [ebp],al
330
    inc ebp
370
   inc ebp
331
    inc edx
371
   inc edx
332
    mov al,byte [edx]
372
   mov al,byte [edx]
333
    mov byte [ebp],al
-
 
334
    inc ebp
373
   mov byte [ebp],al
335
    inc edx
-
 
336
    mov al,byte [edx]
374
   inc ebp
337
    mov byte [ebp],al
375
   inc edx
338
    inc ebp
376
   mov al,byte [edx]
339
    inc edx
377
   mov byte [ebp],al
340
    dec esi
378
   inc ebp
341
    jnz loo
379
   inc edx
342
pop esi
380
   dec esi
343
    sub ebp,3
381
   jnz loo
344
    mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
382
pop esi
345
    sub eax,esi
383
   sub ebp,3
346
    add ebp,eax
384
   mov eax,[ecx]  ;offset = offset+((canxsize-imgxsize)*3)
347
    shl eax,1
385
   sub eax,esi
348
    add ebp,eax
386
   add ebp,eax
349
 
387
   shl eax,1
350
    add ebp,3
-
 
351
 
-
 
352
    dec edi
-
 
353
    jnz loo2
-
 
354
    ret
-
 
355
end_imgtoimg_proc:
-
 
356
end if
-
 
357
    push img
-
 
358
    push canvas
-
 
359
    push x
-
 
360
    push y
-
 
361
    pop  esi
388
   add ebp,eax
Line 362... Line 389...
362
    pop  edi
389
   add ebp,3
363
    pop  ecx
390
   dec edi
364
    pop  ebx
391
   jnz loo2
365
    call imgtoimg_proc
392
   ret
366
}
393
end_imgtoimg_proc:
367
 
394
end if
368
 
395
   push img
369
;DrawBox
396
   push canvas
370
macro drawfbox x,y,xs,ys,color
397
   push x
371
{
398
   push y
372
    wordstoreg ebx,x,xs ;x*65536+xs
399
   pop  esi
373
    wordstoreg ecx,y,ys ;y*65536+ys
400
   pop  edi
374
    mov  edx,color
401
   pop  ecx
375
    mov  eax,13
402
   pop  ebx
376
    mcall
403
   call imgtoimg_proc
377
}
404
}
378
 
405
 
379
; FPS - Set Frame Per Second Display
406
; FPS - Set Frame Per Second Display
380
fps_show_frequency=40
407
fps_show_frequency=40
381
macro fps x,y,color,delcolor
408
macro fps x,y,color,delcolor
382
{
409
{
383
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
410
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
384
local no_out_fps
411
local no_out_fps
385
    jmp spdat
412
   jmp spdat
386
savetime dd 0
413
savetime dd 0
387
fps_cntr dd 0
414
fps_cntr dd 0
388
fps      dd 0
415
fps      dd 0
389
ttt      dd 0
416
ttt      dd 0
390
spdat:
417
spdat:
391
get_time:
418
get_time:
392
    mov eax,3
419
   mov eax,3
393
    mcall
420
   mcall
394
    cmp eax,[savetime]
421
   cmp eax,[savetime]
395
    jne new_time
422
   jne new_time
396
    inc [fps_cntr]
423
   inc [fps_cntr]
397
    cmp dword [ttt],0
424
   cmp dword [ttt],0
398
    je  out_fps
425
   je  out_fps
399
    dec dword [ttt]
426
   dec dword [ttt]
400
    jmp no_out_fps
427
   jmp no_out_fps
401
new_time:
428
new_time:
402
    mov [savetime],eax
429
   mov [savetime],eax
403
    mov ebx,[fps_cntr]
430
   mov ebx,[fps_cntr]
404
    mov [fps],ebx
431
   mov [fps],ebx
405
    mov [fps_cntr],0
432
   mov [fps_cntr],0
406
out_fps:
433
out_fps:
Line 407... Line -...
407
if ~(delcolor eq )
-
 
408
    mov ebx,x*65536+30
-
 
409
    mov ecx,y*65536+7
-
 
410
    mov edx,delcolor
-
 
411
    mov eax,13
-
 
412
    mcall
-
 
413
end if
-
 
414
    mov dword [ttt],fps_show_frequency
-
 
415
    mov eax,47
-
 
416
    mov ebx,5*65536
-
 
417
;   mov bl,0
-
 
418
    mov edx,x*65536+y
-
 
419
    mov esi,color
-
 
420
    mov ecx,[fps]
-
 
421
    mcall
-
 
422
no_out_fps:
-
 
423
}
-
 
424
 
-
 
425
; COLLIMG - Collusion image's
-
 
426
_1dbounce_count=0;
-
 
427
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
-
 
428
{
-
 
429
local bounce,exit,anot,bc,nbc
-
 
430
	mov esi,[img1_off] ;xs1
-
 
431
	mov edi,[img2_off] ;ys2
-
 
432
	mov eax,x1 ;
-
 
433
	mov ebx,x2 ;
-
 
434
	call _1dbounce
-
 
435
	mov edx,ecx
-
 
436
	mov esi,[img1_off+4] ;ys1
-
 
437
	mov edi,[img2_off+4] ;ys2
-
 
438
	mov eax,y1 ;
-
 
439
	mov ebx,y2 ;
-
 
440
	call _1dbounce
-
 
441
	add edx,ecx
-
 
442
	cmp edx,2
-
 
443
	je bounce
-
 
444
	mov otv,0
-
 
445
	jmp exit
-
 
446
_1dbounce_count=_1dbounce_count+1
-
 
447
if _1dbounce_count = 1
-
 
448
_1dbounce:
-
 
449
	cmp ebx,eax
-
 
450
	jb  anot
-
 
451
	add eax,esi
-
 
452
	cmp eax,ebx
434
if ~(delcolor eq )
453
	jbe nbc
435
   mov ebx,x*65536+30
454
bc:
-
 
455
	mov ecx,1
436
   mov ecx,y*65536+7
456
	ret
437
   mov edx,delcolor
457
anot:
438
   mov eax,13
458
    add ebx,edi
439
   mcall
459
	cmp ebx,eax
-
 
460
	ja  bc
440
end if
461
nbc:
441
   mov dword [ttt],fps_show_frequency
462
	xor ecx,ecx
442
   mov eax,47
463
	ret
443
   mov ebx,5*65536
464
end if
444
   ;   mov bl,0
465
bounce:	
445
   mov edx,x*65536+y
466
	mov otv,1
446
   mov esi,color
467
exit:	
447
   mov ecx,[fps]
468
}
-
 
469
 
-
 
470
macro rgbtobgr image
-
 
471
{
-
 
472
local loo
-
 
473
    mov eax,[image]
-
 
474
    mul dword [image+4]
-
 
475
    mov ecx,eax
-
 
476
    mov esi,image+8
-
 
477
;   add esi,8
-
 
478
loo:
-
 
479
   mov al,[esi]
-
 
480
   mov bl,[esi+2]
-
 
481
   mov [esi],bl
-
 
482
   mov [esi+2],al
448
   mcall
Line 483... Line 449...
483
   add esi,3
449
no_out_fps:
484
   dec ecx
450
}
485
   jnz loo
451
 
486
}
452
macro rgbtobgr image
487
 
453
{
488
 
454
   mov eax,[image]
489
macro setimg x , y ,arg3
455
   mul dword [image+4]
490
{
456
   mov ecx,eax
491
    mov  eax,7
457
   mov esi,image+8
492
    mov  ebx,arg3
458
@@:
Line 493... Line 459...
493
    add  ebx,8
459
   mov al,[esi]
494
    mov  cx,[arg3]
460
   mov bl,[esi+2]
-
 
461
   mov [esi],bl
495
    shl  ecx,16
462
   mov [esi+2],al
496
    add  cx,[arg3+4]
463
   add esi,3
497
;    wordstoreg ecx,[arg3],[arg3+4]
464
   dec ecx
498
    wordstoreg edx, x , y  ;arg1*65536+arg2
465
   jnz @b
499
    mcall
466
}
500
}
467
 
501
 
468
macro setframe x , y ,arg3
502
macro setframe x , y ,arg3
469
{
503
{
470
   mov  eax,7
504
    mov  eax,7
471
   mov  ebx,arg3
-
 
472
   add  ebx,8
-
 
473
   wordstoreg edx, x , y  ;arg1*65536+arg2
505
    mov  ebx,arg3
474
   add  edx,dword [arg3]
506
    add  ebx,8
475
   mov  ecx,dword [arg3+4]
507
    wordstoreg edx, x , y  ;arg1*65536+arg2
476
   mcall
508
    add  edx,dword [arg3]
477
}
509
    mov  ecx,dword [arg3+4]
478
 
510
    mcall
479
 
511
}
-
 
512
 
-
 
513
 
480
macro getimg imgsrc,x,y,xs,ys,imgdest
514
macro getimg imgsrc,x,y,xs,ys,imgdest
-
 
515
{
481
{
516
local cyc
482
local next_pixel,next_line
517
if xs eqtype 0
483
; store image size
518
    mov dword [imgdest],xs
-
 
519
else
484
if xs eqtype 0 | xs eqtype eax
520
    mov eax,xs
485
   mov dword [imgdest],xs
521
    mov dword [imgdest],eax
486
else
522
end if
487
   mov eax,xs
523
if ys eqtype 0
-
 
524
    mov dword [imgdest+4],ys
-
 
525
else
-
 
526
    mov eax,ys
488
   mov dword [imgdest],eax
527
    mov dword [imgdest+4],eax
489
end if
528
end if
490
if ys eqtype 0 | ys eqtype eax
529
 
491
   mov dword [imgdest+4],ys
530
    mov eax,dword [imgsrc] ;getx size
492
else
531
;    lea ecx,[eax+2*eax]
493
   ;push ys
532
    mov ecx,eax
-
 
533
    shl ecx,1
494
   ;pop dword [imgdest+4]
534
    add ecx,eax
-
 
535
 
495
   mov eax,ys
536
    mov ebx,y
496
   mov dword [imgdest+4],eax
537
    mul ebx
497
end if
538
    add eax,x
498
 
539
    mov edx,ecx
499
   lea edi,[8+imgdest]    ; edi = destinaton address
540
    lea eax,[eax+2*eax]  ;eax=offset on imsrc
-
 
541
;    mov ebp,eax
-
 
542
;    shl eax,1
-
 
543
;    add eax,ebp
-
 
544
 
500
   mov eax,dword [imgsrc] ; eax = xsize of source image in pixels
545
    mov ecx,xs
501
   push eax               ; store eax before mul operation
546
    mov ebx,ys
502
   mov edx,y
Line 547... Line 503...
547
 
503
   mul edx                ; edx:eax = eax*edx
548
    mov edi,8+imgdest
504
   add eax,x
549
    lea esi,[eax+8+imgsrc]
505
   lea esi,[imgsrc+8+eax+2*eax]    ; esi = start offset on img src
550
;    mov esi,eax
506
   pop eax                ; restore eax
551
;    add esi,8
507
   sub eax,xs             ; eax = src image xsize - crop fragment xsize
552
;    add esi,imgsrc
508
   lea eax,[eax+eax*2]    ; eax = eax * 3 (bytes per pixel)
553
 
509
 
554
    cld
510
   ; this loop used esi,edi,ecx,edx,eax registers
555
cyc:
511
   mov edx,ys     ; edx = ysize in pixels
556
    movsw
512
   cld            ; set direction
557
    movsb
513
next_line:
Line 558... Line 514...
558
    dec ecx
514
   mov ecx,xs     ; ecx = xsize in pixels
559
    jne cyc
515
next_pixel:
560
    add esi,edx
516
   movsw
561
    mov ecx,xs
517
   movsb          ; write 3 bytes pixel
562
    sub esi,ecx
518
   dec ecx
563
    sub esi,ecx
519
   jnz next_pixel
564
    sub esi,ecx
520
   add esi,eax
565
    dec ebx
521
   dec edx
566
    jne cyc
522
   jnz next_line
567
}
523
}
568
 
524
 
569
macro copyimg img2_off,img1_off
525
macro copyimg img2_off,img1_off
570
{
526
{
571
    mov  eax,dword [img1_off]
527
   mov  eax,dword [img1_off]
572
    mov  ebx,dword [img1_off+4]
528
   mov  ebx,dword [img1_off+4]
573
    mul  ebx
529
   mul  ebx
574
    lea  ecx,[eax+2*eax]
530
   lea  ecx,[eax+2*eax]
575
    lea  esi,[img1_off+8]
531
   lea  esi,[img1_off+8]
576
    lea  edi,[img2_off+8]
532
   lea  edi,[img2_off+8]
577
    cld
533
   cld
578
    rep  movsb
534
   rep  movsb
579
}
535
}
580
 
536
 
581
macro fullimg img_off,xs,ys,color
537
macro fullimg img_off,xs,ys,color
582
{
538
{
Line 583... Line -...
583
local cop
-
 
584
    mov eax,xs
-
 
585
    mov ebx,ys
539
local cop
586
    mov  dword [img_off],eax
540
   mov eax,xs
Line 587... Line 541...
587
    mov  dword [img_off+4],ebx
541
   mov ebx,ys
588
    mul  ebx
542
   mov  dword [img_off],eax
589
    lea  ebp,[eax+2*eax]
543
   mov  dword [img_off+4],ebx
590
    mov  esi,color
544
   mul  ebx
Line 628... Line 582...
628
  jmp loo
582
  jmp loo
629
setpic:
583
setpic:
630
  mov dword offset_of_frame,esi
584
  mov dword offset_of_frame,esi
631
}
585
}
Line 632... Line -...
632
 
-
 
633
 
586
 
634
; BMPTOIMG -Convert BMP format TO IMG format
587
; BMPTOIMG -Convert BMP format TO IMG format
635
; (SYNTAX)  BMPTOIMG BMP_source_offset,IMG_dest_ofset
588
; (SYNTAX)  BMPTOIMG BMP_source_offset,IMG_dest_ofset
636
; (SAMPLE)  View BMPLS.ASM sample.
589
; (SAMPLE)  View BMPLS.ASM sample.
637
; ( NOTE )  This is macros is not brake bmp structure! Tested in 32,8,4 bits
-
 
Line 638... Line 590...
638
 
590
; ( NOTE )  This is macro is not brake bmp structure! Tested in 32,8,4 bits
639
 
591
 
640
bmptoimg_data_area_count=0
592
bmptoimg_data_area_count=0
641
macro bmptoimg bmp_load_area,img_dest_area
593
macro bmptoimg bmp_load_area,img_dest_area
642
{
594
{
643
local fileinfo,string,end_bmp,nodix
595
local fileinfo,string,end_bmp,nodix
644
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
596
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
Line 645... Line 597...
645
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
597
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
Line 772... Line 717...
772
;    mov  dword [edi],edx
717
   ;    mov  dword [edi],edx
773
    mov [ebp],edx
718
   mov [ebp],edx
774
    ret
719
   ret
775
 
720
 
Line 783... Line 728...
783
bmptoimg_data_area_eop      dd 0
728
bmptoimg_data_area_eop      dd 0
784
bmptoimg_data_area_eos      dd 0
729
bmptoimg_data_area_eos      dd 0
785
end if
730
end if
Line 786... Line 731...
786
 
731
 
787
end_bmp:
732
end_bmp:
788
    mov  eax,dword [bmp_load_area+18]
733
   mov  eax,dword [bmp_load_area+18]
789
    mov  ebx,dword [bmp_load_area+22]
734
   mov  ebx,dword [bmp_load_area+22]
790
    mov  dword [img_dest_area],eax
735
   mov  dword [img_dest_area],eax
791
    mov  dword [img_dest_area+4],ebx
736
   mov  dword [img_dest_area+4],ebx
Line 792... Line 737...
792
}
737
}
793
 
738
 
794
if used ReadGIF
739
if used ReadGIF
Line 798... Line 743...
798
end if
743
end if
Line 799... Line 744...
799
 
744
 
800
macro giftoani gifsrc,imgsrc,num_of_frames
745
macro giftoani gifsrc,imgsrc,num_of_frames
801
{
746
{
802
gif_img_count = num_of_frames
747
gif_img_count = num_of_frames
803
        mov     esi, gifsrc
748
   mov     esi, gifsrc
804
        mov     edi, imgsrc
749
   mov     edi, imgsrc
805
        call    ReadGIF
750
   call    ReadGIF
Line 806... Line 751...
806
}
751
}
807
 
752
 
808
macro giftoimg gifsrc,imgsrc
753
macro giftoimg gifsrc,imgsrc
809
{
754
{
810
if defined gif_img_count
755
if defined gif_img_count
811
error 'giftoimg cannot be used in GIF multiple images mode. Use giftoani instead.'
756
error 'giftoimg cannot be used in GIF multiple images mode. Use giftoani instead.'
812
end if
757
end if
813
        mov     esi, gifsrc
758
   mov     esi, gifsrc
814
        mov     edi, imgsrc
759
   mov     edi, imgsrc