Subversion Repositories Kolibri OS

Rev

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

Rev 109 Rev 485
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.10 By Pavlushin Evgeni (RUSSIA)
10
;   Ver 0.10 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, add at ~07.06.2004
23
;0.10 all macros optimized by halyavin, add at ~07.06.2004
24
 
24
 
25
;DrawBox
25
;DrawBox
26
macro drawfbox x,y,xs,ys,color
26
macro drawfbox x,y,xs,ys,color
27
{
27
{
28
    mov  ecx,y
28
    mov  ecx,y
29
    mov  ebx,x
29
    mov  ebx,x
30
    shl  ebx,16
30
    shl  ebx,16
31
    add  ebx,xs
31
    add  ebx,xs
32
    shl  ecx,16
32
    shl  ecx,16
33
    add  ecx,ys
33
    add  ecx,ys
34
    mov  edx,color
34
    mov  edx,color
35
    mov  eax,13
35
    mov  eax,13
36
    int  0x40
36
    mcall
37
}
37
}
38
 
38
 
39
; FPS - Set Frame Per Second Display
39
; FPS - Set Frame Per Second Display
40
fps_show_frequency=40
40
fps_show_frequency=40
41
macro fps x,y,color,delcolor
41
macro fps x,y,color,delcolor
42
{
42
{
43
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
43
local spdat,savetime,new_time,fps,fps_cntr,out_fps,new_time,ttt
44
local no_out_fps
44
local no_out_fps
45
    jmp spdat
45
    jmp spdat
46
savetime dd 0
46
savetime dd 0
47
fps_cntr dd 0
47
fps_cntr dd 0
48
fps      dd 0
48
fps      dd 0
49
ttt      dd 0
49
ttt      dd 0
50
spdat:
50
spdat:
51
get_time:
51
get_time:
52
    mov eax,3
52
    mov eax,3
53
    int 0x40
53
    mcall
54
    cmp eax,[savetime]
54
    cmp eax,[savetime]
55
    jne new_time
55
    jne new_time
56
    inc [fps_cntr]
56
    inc [fps_cntr]
57
    cmp dword [ttt],0
57
    cmp dword [ttt],0
58
    je  out_fps
58
    je  out_fps
59
    dec dword [ttt]
59
    dec dword [ttt]
60
    jmp no_out_fps
60
    jmp no_out_fps
61
new_time:
61
new_time:
62
    mov [savetime],eax
62
    mov [savetime],eax
63
    mov ebx,[fps_cntr]
63
    mov ebx,[fps_cntr]
64
    mov [fps],ebx
64
    mov [fps],ebx
65
    mov [fps_cntr],0
65
    mov [fps_cntr],0
66
out_fps:
66
out_fps:
67
if ~(delcolor eq )
67
if ~(delcolor eq )
68
    mov ebx,x*65536+30
68
    mov ebx,x*65536+30
69
    mov ecx,y*65536+7
69
    mov ecx,y*65536+7
70
    mov edx,delcolor
70
    mov edx,delcolor
71
    mov eax,13
71
    mov eax,13
72
    int 0x40
72
    mcall
73
end if
73
end if
74
    mov dword [ttt],fps_show_frequency
74
    mov dword [ttt],fps_show_frequency
75
    mov eax,47
75
    mov eax,47
76
    mov ebx,5*65536
76
    mov ebx,5*65536
77
;   mov bl,0
77
;   mov bl,0
78
    mov edx,x*65536+y
78
    mov edx,x*65536+y
79
    mov esi,color
79
    mov esi,color
80
    mov ecx,[fps]
80
    mov ecx,[fps]
81
    int 0x40
81
    mcall
82
no_out_fps:
82
no_out_fps:
83
}
83
}
84
 
84
 
85
 
85
 
86
 
86
 
87
; COLLIMG - Collusion image's
87
; COLLIMG - Collusion image's
88
_1dbounce_count=0;
88
_1dbounce_count=0;
89
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
89
macro collimg img1_off,x1,y1,img2_off,x2,y2,otv
90
{
90
{
91
local bounce,exit,anot,bc,nbc
91
local bounce,exit,anot,bc,nbc
92
	mov esi,[img1_off] ;xs1
92
	mov esi,[img1_off] ;xs1
93
	mov edi,[img2_off] ;ys2
93
	mov edi,[img2_off] ;ys2
94
	mov eax,x1 ;
94
	mov eax,x1 ;
95
	mov ebx,x2 ;
95
	mov ebx,x2 ;
96
	call _1dbounce
96
	call _1dbounce
97
	mov edx,ecx
97
	mov edx,ecx
98
	mov esi,[img1_off+4] ;ys1
98
	mov esi,[img1_off+4] ;ys1
99
	mov edi,[img2_off+4] ;ys2
99
	mov edi,[img2_off+4] ;ys2
100
	mov eax,y1 ;
100
	mov eax,y1 ;
101
	mov ebx,y2 ;
101
	mov ebx,y2 ;
102
	call _1dbounce
102
	call _1dbounce
103
	add edx,ecx
103
	add edx,ecx
104
	cmp edx,2
104
	cmp edx,2
105
	je bounce
105
	je bounce
106
	mov otv,0
106
	mov otv,0
107
	jmp exit
107
	jmp exit
108
_1dbounce_count=_1dbounce_count+1
108
_1dbounce_count=_1dbounce_count+1
109
if (_1dbounce_count = 1)
109
if (_1dbounce_count = 1)
110
_1dbounce:
110
_1dbounce:
111
	cmp ebx,eax
111
	cmp ebx,eax
112
	jnae anot
112
	jnae anot
113
	add eax,esi
113
	add eax,esi
114
	cmp eax,ebx
114
	cmp eax,ebx
115
	jna nbc
115
	jna nbc
116
	jmp bc
116
	jmp bc
117
anot: 
117
anot: 
118
    add ebx,edi
118
    add ebx,edi
119
	cmp ebx,eax
119
	cmp ebx,eax
120
	jna nbc
120
	jna nbc
121
bc:	
121
bc:	
122
    mov ecx,1
122
    mov ecx,1
123
	ret
123
	ret
124
nbc:
124
nbc:
125
	mov ecx,0
125
	mov ecx,0
126
	ret
126
	ret
127
end if
127
end if
128
bounce:	
128
bounce:	
129
	mov otv,1
129
	mov otv,1
130
exit:	
130
exit:	
131
}
131
}
132
 
132
 
133
; SETBMP -  Set bmp to window
133
; SETBMP -  Set bmp to window
134
; (SYNTAX)  SETBMP dd xstart ,dd ystart ,BMP_offset,dd soi
134
; (SYNTAX)  SETBMP dd xstart ,dd ystart ,BMP_offset,dd soi
135
; (SAMPLE)  SETBMP dword [xt],dword [yt],I_END,dword [tsoi]
135
; (SAMPLE)  SETBMP dword [xt],dword [yt],I_END,dword [tsoi]
136
;           SETBMP 15,10,I_END,dword [tsoi]
136
;           SETBMP 15,10,I_END,dword [tsoi]
137
; ( NOTE )  SOI - Start of image
137
; ( NOTE )  SOI - Start of image
138
 
138
 
139
macro setbmp arg1,arg2,arg3,arg4
139
macro setbmp arg1,arg2,arg3,arg4
140
{
140
{
141
local nodi
141
local nodi
142
    cmp  word [arg3],word 'BM'
142
    cmp  word [arg3],word 'BM'
143
    jne  nodi
143
    jne  nodi
144
    mov  eax,7
144
    mov  eax,7
145
    mov  ebx,arg4 ;[soi]
145
    mov  ebx,arg4 ;[soi]
146
    mov  ecx,dword [arg3+18]
146
    mov  ecx,dword [arg3+18]
147
    shl  ecx,16
147
    shl  ecx,16
148
    add  ecx,dword [arg3+22]
148
    add  ecx,dword [arg3+22]
149
if (arg1 eqtype 0) & (arg2 eqtype 0)
149
if (arg1 eqtype 0) & (arg2 eqtype 0)
150
    mov  edx,arg1*65536+arg2
150
    mov  edx,arg1*65536+arg2
151
else
151
else
152
    mov  edx,arg1
152
    mov  edx,arg1
153
    shl  edx,16
153
    shl  edx,16
154
    add  edx,arg2
154
    add  edx,arg2
155
end if    
155
end if    
156
    int  0x40
156
    mcall
157
  nodi:
157
  nodi:
158
}
158
}
159
 
159
 
160
macro setimg arg1,arg2,arg3
160
macro setimg arg1,arg2,arg3
161
{
161
{
162
local nodi
162
local nodi
163
    mov  eax,7
163
    mov  eax,7
164
    mov  ebx,arg3
164
    mov  ebx,arg3
165
    add  ebx,8
165
    add  ebx,8
166
    mov  ecx,dword [arg3]
166
    mov  ecx,dword [arg3]
167
    shl  ecx,16
167
    shl  ecx,16
168
    add  ecx,dword [arg3+4]
168
    add  ecx,dword [arg3+4]
169
if (arg1 eqtype 0) & (arg2 eqtype 0)
169
if (arg1 eqtype 0) & (arg2 eqtype 0)
170
    mov  edx,arg1*65536+arg2
170
    mov  edx,arg1*65536+arg2
171
else   
171
else   
172
    mov  edx,arg1
172
    mov  edx,arg1
173
    shl  edx,16
173
    shl  edx,16
174
    add  edx,arg2
174
    add  edx,arg2
175
end if   
175
end if   
176
    int  0x40
176
    mcall
177
}
177
}
178
 
178
 
179
;Not optimiz
179
;Not optimiz
180
macro getimg imgsrc,x,y,xs,ys,imgdest
180
macro getimg imgsrc,x,y,xs,ys,imgdest
181
{
181
{
182
local cyc
182
local cyc
183
    mov eax,xs
183
    mov eax,xs
184
    mov dword [imgdest],eax
184
    mov dword [imgdest],eax
185
    mov eax,ys
185
    mov eax,ys
186
    mov dword [imgdest+4],eax
186
    mov dword [imgdest+4],eax
187
 
187
 
188
    mov eax,dword [imgsrc] ;getx size
188
    mov eax,dword [imgsrc] ;getx size
189
    mov edi,eax
189
    mov edi,eax
190
    mov ebx,y
190
    mov ebx,y
191
    mul ebx
191
    mul ebx
192
    add eax,x
192
    add eax,x
193
    mov ebx,3
193
    mov ebx,3
194
    mul ebx     ;eax=offset on imsrc
194
    mul ebx     ;eax=offset on imsrc
195
 
195
 
196
    mov ecx,0
196
    mov ecx,0
197
    mov ebx,0
197
    mov ebx,0
198
    mov ebp,eax
198
    mov ebp,eax
199
    mov esi,0
199
    mov esi,0
200
 
200
 
201
    add esi,8
201
    add esi,8
202
    add ebp,8
202
    add ebp,8
203
 
203
 
204
cyc:
204
cyc:
205
    mov al,byte [imgsrc+ebp]
205
    mov al,byte [imgsrc+ebp]
206
    mov [imgdest+esi],al
206
    mov [imgdest+esi],al
207
    mov al,byte [imgsrc+ebp+1]
207
    mov al,byte [imgsrc+ebp+1]
208
    mov [imgdest+esi+1],al
208
    mov [imgdest+esi+1],al
209
    mov al,byte [imgsrc+ebp+2]
209
    mov al,byte [imgsrc+ebp+2]
210
    mov [imgdest+esi+2],al
210
    mov [imgdest+esi+2],al
211
    add esi,3
211
    add esi,3
212
    add ebp,3
212
    add ebp,3
213
    inc ecx
213
    inc ecx
214
    cmp ecx,xs
214
    cmp ecx,xs
215
    jne cyc
215
    jne cyc
216
    add ebp,edi
216
    add ebp,edi
217
    add ebp,edi
217
    add ebp,edi
218
    add ebp,edi
218
    add ebp,edi
219
    sub ebp,xs
219
    sub ebp,xs
220
    sub ebp,xs
220
    sub ebp,xs
221
    sub ebp,xs
221
    sub ebp,xs
222
    mov ecx,0
222
    mov ecx,0
223
    inc ebx
223
    inc ebx
224
    cmp ebx,ys
224
    cmp ebx,ys
225
    jne cyc
225
    jne cyc
226
 
226
 
227
}
227
}
228
 
228
 
229
;
229
;
230
macro bmptoimg bmp_off,soi,img_off
230
macro bmptoimg bmp_off,soi,img_off
231
{
231
{
232
local nodix,conv
232
local nodix,conv
233
    cmp  word [bmp_off],word 'BM'
233
    cmp  word [bmp_off],word 'BM'
234
    jne  nodix
234
    jne  nodix
235
    mov  eax,dword [bmp_off+18]
235
    mov  eax,dword [bmp_off+18]
236
    mov  ebx,dword [bmp_off+22]
236
    mov  ebx,dword [bmp_off+22]
237
    mov  dword [img_off],eax
237
    mov  dword [img_off],eax
238
    mov  dword [img_off+4],ebx
238
    mov  dword [img_off+4],ebx
239
    mul  ebx
239
    mul  ebx
240
    lea  ecx,[eax+2*eax]
240
    lea  ecx,[eax+2*eax]
241
    lea  edi,[img_off+8]
241
    lea  edi,[img_off+8]
242
    mov  esi,dword [soi]
242
    mov  esi,dword [soi]
243
    cld
243
    cld
244
    rep  movsb
244
    rep  movsb
245
nodix:
245
nodix:
246
}
246
}
247
 
247
 
248
macro copyimg img2_off,img1_off
248
macro copyimg img2_off,img1_off
249
{
249
{
250
local cop
250
local cop
251
    mov  eax,dword [img1_off]
251
    mov  eax,dword [img1_off]
252
    mov  ebx,dword [img1_off+4]
252
    mov  ebx,dword [img1_off+4]
253
    mul  ebx
253
    mul  ebx
254
    lea  ecx,[eax+2*eax]
254
    lea  ecx,[eax+2*eax]
255
    lea  esi,[img1_off+8]
255
    lea  esi,[img1_off+8]
256
    lea  edi,[img2_off+8]
256
    lea  edi,[img2_off+8]
257
    cld
257
    cld
258
    rep  movsb
258
    rep  movsb
259
}
259
}
260
 
260
 
261
macro fullimg img_off,xs,ys,color
261
macro fullimg img_off,xs,ys,color
262
{
262
{
263
local cop
263
local cop
264
    mov eax,xs
264
    mov eax,xs
265
    mov ebx,ys
265
    mov ebx,ys
266
    mov  dword [img_off],eax
266
    mov  dword [img_off],eax
267
    mov  dword [img_off+4],ebx
267
    mov  dword [img_off+4],ebx
268
    mul  ebx
268
    mul  ebx
269
    lea  ebp,[eax+2*eax]
269
    lea  ebp,[eax+2*eax]
270
    mov  esi,color
270
    mov  esi,color
271
if color eqtype 0
271
if color eqtype 0
272
    mov  ecx,color/65536
272
    mov  ecx,color/65536
273
else
273
else
274
    mov  ecx,esi
274
    mov  ecx,esi
275
    shr  ecx,16
275
    shr  ecx,16
276
end if
276
end if
277
    xor  edi,edi
277
    xor  edi,edi
278
cop:
278
cop:
279
    mov  word [img_off+8+edi],si
279
    mov  word [img_off+8+edi],si
280
    add  edi,2
280
    add  edi,2
281
    mov  byte [img_off+8+edi],cl
281
    mov  byte [img_off+8+edi],cl
282
    inc  edi
282
    inc  edi
283
    cmp  edi,ebp
283
    cmp  edi,ebp
284
    jne  cop
284
    jne  cop
285
}
285
}
286
 
286
 
287
 
287
 
288
 
288
 
289
 
289
 
290
macro convbmp bmp_load_area,bmp_soi
290
macro convbmp bmp_load_area,bmp_soi
291
{
291
{
292
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
292
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
293
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
293
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
294
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
294
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
295
local noaddword
295
local noaddword
296
;local qwe,bmpfn
296
;local qwe,bmpfn
297
 
297
 
298
;  convert:
298
;  convert:
299
    movzx eax,word [bmp_load_area+28]
299
    movzx eax,word [bmp_load_area+28]
300
    mul  dword [bmp_load_area+18]
300
    mul  dword [bmp_load_area+18]
301
    mov  ebx,32
301
    mov  ebx,32
302
    div  ebx
302
    div  ebx
303
    test edx,edx
303
    test edx,edx
304
    je   noaddword
304
    je   noaddword
305
    inc  eax
305
    inc  eax
306
  noaddword:
306
  noaddword:
307
    mov  dword [dwps],eax  ;dwps-doublewords per string
307
    mov  dword [dwps],eax  ;dwps-doublewords per string
308
    shl  eax,2
308
    shl  eax,2
309
    mov  dword [bps],eax   ;bps-bytes per string
309
    mov  dword [bps],eax   ;bps-bytes per string
310
 
310
 
311
    cmp dword [bmp_load_area+34],0
311
    cmp dword [bmp_load_area+34],0
312
    jne  yespicsize  ;if picture size is defined
312
    jne  yespicsize  ;if picture size is defined
313
    mul dword [bmp_load_area+22]
313
    mul dword [bmp_load_area+22]
314
    mov dword [bmp_load_area+34],eax
314
    mov dword [bmp_load_area+34],eax
315
 
315
 
316
  yespicsize:
316
  yespicsize:
317
    mov  eax,bmp_load_area
317
    mov  eax,bmp_load_area
318
    mov  ebx,eax
318
    mov  ebx,eax
319
    add  ebx, [bmp_load_area+2];file size
319
    add  ebx, [bmp_load_area+2];file size
320
    inc  ebx
320
    inc  ebx
321
    mov  dword [bmp_soi],ebx   ;soi-start of image area for drawing
321
    mov  dword [bmp_soi],ebx   ;soi-start of image area for drawing
322
    add  eax, [bmp_load_area+10]
322
    add  eax, [bmp_load_area+10]
323
    mov  dword [sop],eax   ;sop-start of picture in file
323
    mov  dword [sop],eax   ;sop-start of picture in file
324
    add  eax, [bmp_load_area+34]
324
    add  eax, [bmp_load_area+34]
325
    mov  dword [eop],eax   ;eop-end of picture in file
325
    mov  dword [eop],eax   ;eop-end of picture in file
326
    mov  eax, [bmp_load_area+18]
326
    mov  eax, [bmp_load_area+18]
327
    lea  eax,[eax+2*eax]   ;3x pixels in eax
327
    lea  eax,[eax+2*eax]   ;3x pixels in eax
328
 
328
 
329
    mov  edi,dword [bmp_soi]   ;initializing
329
    mov  edi,dword [bmp_soi]   ;initializing
330
    mov  esi,dword [eop]
330
    mov  esi,dword [eop]
331
    sub  esi,dword [bps]
331
    sub  esi,dword [bps]
332
 
332
 
333
 
333
 
334
  nextstring:
334
  nextstring:
335
    push edi
335
    push edi
336
    cmp  word [bmp_load_area+28],24
336
    cmp  word [bmp_load_area+28],24
337
    jne  convertno32
337
    jne  convertno32
338
 
338
 
339
    mov  ecx,[dwps]
339
    mov  ecx,[dwps]
340
    cld
340
    cld
341
    rep movsd
341
    rep movsd
342
  convert1:
342
  convert1:
343
    pop  edi
343
    pop  edi
344
    sub  esi,dword [bps]
344
    sub  esi,dword [bps]
345
    sub  esi,dword [bps]
345
    sub  esi,dword [bps]
346
    cmp  esi,dword [sop]
346
    cmp  esi,dword [sop]
347
    jb   end_bmp;nomorestring
347
    jb   end_bmp;nomorestring
348
    add  edi,eax
348
    add  edi,eax
349
    jmp  nextstring
349
    jmp  nextstring
350
 
350
 
351
;  nomorestring:
351
;  nomorestring:
352
;    jmp end_bmp
352
;    jmp end_bmp
353
 
353
 
354
  convertno32:
354
  convertno32:
355
    mov  ebx,bmp_load_area
355
    mov  ebx,bmp_load_area
356
    add  ebx, [bmp_load_area+14]
356
    add  ebx, [bmp_load_area+14]
357
    add  ebx,14          ;start of color table
357
    add  ebx,14          ;start of color table
358
    push esi
358
    push esi
359
    add  esi,dword [bps]
359
    add  esi,dword [bps]
360
    mov  dword [eos],esi
360
    mov  dword [eos],esi
361
    pop  esi
361
    pop  esi
362
  nextelem:
362
  nextelem:
363
    push eax
363
    push eax
364
    movzx eax,byte [esi]
364
    movzx eax,byte [esi]
365
    cmp  word [bmp_load_area+28],4
365
    cmp  word [bmp_load_area+28],4
366
    je   convert4bpp
366
    je   convert4bpp
367
    cmp  word [bmp_load_area+28],1
367
    cmp  word [bmp_load_area+28],1
368
    je   convert1bpp
368
    je   convert1bpp
369
    call converttable
369
    call converttable
370
  convert2:
370
  convert2:
371
    pop  eax
371
    pop  eax
372
    inc  esi
372
    inc  esi
373
    cmp  esi,dword [eos]
373
    cmp  esi,dword [eos]
374
    jae  convert1
374
    jae  convert1
375
    add  edi,3
375
    add  edi,3
376
    jmp  nextelem
376
    jmp  nextelem
377
 
377
 
378
  convert4bpp:
378
  convert4bpp:
379
    shl  ax,4
379
    shl  ax,4
380
    shr  al,4
380
    shr  al,4
381
    push ax
381
    push ax
382
    movzx eax,ah
382
    movzx eax,ah
383
    call converttable
383
    call converttable
384
    add  edi,3
384
    add  edi,3
385
    pop  ax
385
    pop  ax
386
    movzx eax,al
386
    movzx eax,al
387
    call converttable
387
    call converttable
388
    jmp  convert2
388
    jmp  convert2
389
 
389
 
390
  convert1bpp:
390
  convert1bpp:
391
    mov  ecx,eax
391
    mov  ecx,eax
392
    mov  edx,7
392
    mov  edx,7
393
  nextbit:
393
  nextbit:
394
    xor  eax,eax
394
    xor  eax,eax
395
    bt   ecx,edx
395
    bt   ecx,edx
396
    jnc  noaddelem
396
    jnc  noaddelem
397
    inc  eax
397
    inc  eax
398
  noaddelem:
398
  noaddelem:
399
    push edx
399
    push edx
400
    call converttable
400
    call converttable
401
    pop  edx
401
    pop  edx
402
    dec  edx
402
    dec  edx
403
    cmp  edx,0xffffffff
403
    cmp  edx,0xffffffff
404
    je   convert2
404
    je   convert2
405
    add  edi,3
405
    add  edi,3
406
    jmp  nextbit
406
    jmp  nextbit
407
 
407
 
408
  converttable:
408
  converttable:
409
    shl  eax,2
409
    shl  eax,2
410
    add  eax,ebx
410
    add  eax,ebx
411
    mov  edx, dword [eax]
411
    mov  edx, dword [eax]
412
    mov  dword [edi],edx
412
    mov  dword [edi],edx
413
    ret
413
    ret
414
 
414
 
415
 
415
 
416
; DATA AREA
416
; DATA AREA
417
 
417
 
418
;status   dd 0  ;bit0=1 if file thread is created
418
;status   dd 0  ;bit0=1 if file thread is created
419
bps      dd 0
419
bps      dd 0
420
dwps     dd 0
420
dwps     dd 0
421
;soi      dd 0
421
;soi      dd 0
422
sop      dd 0
422
sop      dd 0
423
eop      dd 0
423
eop      dd 0
424
eos      dd 0
424
eos      dd 0
425
;process  dd 0
425
;process  dd 0
426
 
426
 
427
end_bmp:
427
end_bmp:
428
;    mov eax,dword [soi]
428
;    mov eax,dword [soi]
429
;    mov dword [bmp_soi],eax
429
;    mov dword [bmp_soi],eax
430
 
430
 
431
}
431
}
432
 
432
 
433
 
433
 
434
 
434
 
435
 
435
 
436
; LOADBMP - Load bmp image from file
436
; LOADBMP - Load bmp image from file
437
; (SYNTAX)  LOADBMP 'file_path',temp_area(rb 0x10000),load_area,dd soi
437
; (SYNTAX)  LOADBMP 'file_path',temp_area(rb 0x10000),load_area,dd soi
438
; (SAMPLE)  LOADBMP '/rd/1/menuet.bmp',temp_area,I_END,tsoi
438
; (SAMPLE)  LOADBMP '/rd/1/menuet.bmp',temp_area,I_END,tsoi
439
; ( NOTE )  Macros create on Base of
439
; ( NOTE )  Macros create on Base of
440
;           Picture browser by lisovin@26.ru & Ivan Poddubny
440
;           Picture browser by lisovin@26.ru & Ivan Poddubny
441
;           SOI - Start of image
441
;           SOI - Start of image
442
 
442
 
443
macro loadbmp bmp_file_name,bmp_temp_area,bmp_load_area,bmp_soi
443
macro loadbmp bmp_file_name,bmp_temp_area,bmp_load_area,bmp_soi
444
{
444
{
445
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
445
local status,bps,dwps,soi,sop,eop,eos,process,fileinfo,string,end_bmp
446
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
446
local converttable,noaddelem,nextbit,convert1bpp,convert4bpp,convert2
447
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
447
local nextelem,convertno32,nomorestring,convert1,nextstring,yespicsize
448
local noaddword
448
local noaddword
449
;local qwe,bmpfn
449
;local qwe,bmpfn
450
 
450
 
451
    mov  dword [fileinfo+8],1 ; how many blocks to read (1)
451
    mov  dword [fileinfo+8],1 ; how many blocks to read (1)
452
    mov  eax,58
452
    mov  eax,58
453
    mov  ebx,fileinfo
453
    mov  ebx,fileinfo
454
    int  0x40
454
    mcall
455
    mov  eax,[bmp_load_area+2]
455
    mov  eax,[bmp_load_area+2]
456
    shr  eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
456
    shr  eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
457
    inc  eax
457
    inc  eax
458
    mov  dword [fileinfo+8],eax
458
    mov  dword [fileinfo+8],eax
459
    mov  eax,58
459
    mov  eax,58
460
    mov  ebx,fileinfo
460
    mov  ebx,fileinfo
461
    int  0x40
461
    mcall
462
 
462
 
463
;     jmp  qwe
463
;     jmp  qwe
464
;bmpfn db bmp_file_name
464
;bmpfn db bmp_file_name
465
;qwe:
465
;qwe:
466
;     mov eax,6
466
;     mov eax,6
467
;     mov ebx,bmpfn
467
;     mov ebx,bmpfn
468
;     mov ecx,0
468
;     mov ecx,0
469
;     mov edx,0xFFFFFF
469
;     mov edx,0xFFFFFF
470
;     mov esi,bmp_load_area
470
;     mov esi,bmp_load_area
471
;     mov edi,0
471
;     mov edi,0
472
;     int 0x40
472
;     mcall
473
 
473
 
474
;  convert:
474
;  convert:
475
    movzx eax,word [bmp_load_area+28]
475
    movzx eax,word [bmp_load_area+28]
476
    mul dword [bmp_load_area+18]
476
    mul dword [bmp_load_area+18]
477
    mov  ebx,32
477
    mov  ebx,32
478
    div  ebx
478
    div  ebx
479
    test edx,edx
479
    test edx,edx
480
    je   noaddword
480
    je   noaddword
481
    inc  eax
481
    inc  eax
482
  noaddword:
482
  noaddword:
483
    mov  dword [dwps],eax  ;dwps-doublewords per string
483
    mov  dword [dwps],eax  ;dwps-doublewords per string
484
    shl  eax,2
484
    shl  eax,2
485
    mov  dword [bps],eax   ;bps-bytes per string
485
    mov  dword [bps],eax   ;bps-bytes per string
486
 
486
 
487
    cmp dword [bmp_load_area+34],0
487
    cmp dword [bmp_load_area+34],0
488
    jne  yespicsize  ;if picture size is defined
488
    jne  yespicsize  ;if picture size is defined
489
    mul dword [bmp_load_area+22]
489
    mul dword [bmp_load_area+22]
490
    mov dword [bmp_load_area+34],eax
490
    mov dword [bmp_load_area+34],eax
491
 
491
 
492
  yespicsize:
492
  yespicsize:
493
    mov  eax,bmp_load_area
493
    mov  eax,bmp_load_area
494
    push eax
494
    push eax
495
    add  eax, [bmp_load_area+2];file size
495
    add  eax, [bmp_load_area+2];file size
496
    inc  eax
496
    inc  eax
497
    mov  dword [soi],eax   ;soi-start of image area for drawing
497
    mov  dword [soi],eax   ;soi-start of image area for drawing
498
    pop  eax
498
    pop  eax
499
    add  eax, [bmp_load_area+10]
499
    add  eax, [bmp_load_area+10]
500
    mov  dword [sop],eax   ;sop-start of picture in file
500
    mov  dword [sop],eax   ;sop-start of picture in file
501
    add  eax, [bmp_load_area+34]
501
    add  eax, [bmp_load_area+34]
502
    mov  dword [eop],eax   ;eop-end of picture in file
502
    mov  dword [eop],eax   ;eop-end of picture in file
503
    mov  eax, [bmp_load_area+18]
503
    mov  eax, [bmp_load_area+18]
504
    mov  ebx,3
504
    mov  ebx,3
505
    mul  ebx             ;3x pixels in eax
505
    mul  ebx             ;3x pixels in eax
506
 
506
 
507
    mov  edi,dword [soi]   ;initializing
507
    mov  edi,dword [soi]   ;initializing
508
    mov  esi,dword [eop]
508
    mov  esi,dword [eop]
509
    sub  esi,dword [bps]
509
    sub  esi,dword [bps]
510
 
510
 
511
 
511
 
512
  nextstring:
512
  nextstring:
513
    push edi
513
    push edi
514
    cmp word [bmp_load_area+28],24
514
    cmp word [bmp_load_area+28],24
515
    jne  convertno32
515
    jne  convertno32
516
 
516
 
517
    mov  ecx,[dwps]
517
    mov  ecx,[dwps]
518
    cld
518
    cld
519
    rep movsd
519
    rep movsd
520
  convert1:
520
  convert1:
521
    pop  edi
521
    pop  edi
522
    sub  esi,dword [bps]
522
    sub  esi,dword [bps]
523
    sub  esi,dword [bps]
523
    sub  esi,dword [bps]
524
    cmp  esi,dword [sop]
524
    cmp  esi,dword [sop]
525
    jb   nomorestring
525
    jb   nomorestring
526
    add  edi,eax
526
    add  edi,eax
527
    jmp  nextstring
527
    jmp  nextstring
528
 
528
 
529
  nomorestring:
529
  nomorestring:
530
    jmp end_bmp
530
    jmp end_bmp
531
 
531
 
532
  convertno32:
532
  convertno32:
533
    mov  ebx,bmp_load_area
533
    mov  ebx,bmp_load_area
534
    add  ebx, [bmp_load_area+14]
534
    add  ebx, [bmp_load_area+14]
535
    add  ebx,14          ;start of color table
535
    add  ebx,14          ;start of color table
536
    push esi
536
    push esi
537
    add  esi,dword [bps]
537
    add  esi,dword [bps]
538
    mov  dword [eos],esi
538
    mov  dword [eos],esi
539
    pop  esi
539
    pop  esi
540
  nextelem:
540
  nextelem:
541
    push eax
541
    push eax
542
    movzx eax,byte [esi]
542
    movzx eax,byte [esi]
543
    cmp word [bmp_load_area+28],4
543
    cmp word [bmp_load_area+28],4
544
    je   convert4bpp
544
    je   convert4bpp
545
    cmp word [bmp_load_area+28],1
545
    cmp word [bmp_load_area+28],1
546
    je   convert1bpp
546
    je   convert1bpp
547
    call converttable
547
    call converttable
548
  convert2:
548
  convert2:
549
    pop  eax
549
    pop  eax
550
    inc  esi
550
    inc  esi
551
    cmp  esi,dword [eos]
551
    cmp  esi,dword [eos]
552
    jae  convert1
552
    jae  convert1
553
    add  edi,3
553
    add  edi,3
554
    jmp  nextelem
554
    jmp  nextelem
555
 
555
 
556
  convert4bpp:
556
  convert4bpp:
557
    shl  ax,4
557
    shl  ax,4
558
    shr  al,4
558
    shr  al,4
559
    push ax
559
    push ax
560
    movzx eax,ah
560
    movzx eax,ah
561
    call converttable
561
    call converttable
562
    add  edi,3
562
    add  edi,3
563
    pop  ax
563
    pop  ax
564
    movzx eax,al
564
    movzx eax,al
565
    call converttable
565
    call converttable
566
    jmp  convert2
566
    jmp  convert2
567
 
567
 
568
  convert1bpp:
568
  convert1bpp:
569
    mov  ecx,eax
569
    mov  ecx,eax
570
    mov  edx,7
570
    mov  edx,7
571
  nextbit:
571
  nextbit:
572
    xor  eax,eax
572
    xor  eax,eax
573
    bt   ecx,edx
573
    bt   ecx,edx
574
    jnc  noaddelem
574
    jnc  noaddelem
575
    inc  eax
575
    inc  eax
576
  noaddelem:
576
  noaddelem:
577
    push edx
577
    push edx
578
    call converttable
578
    call converttable
579
    pop  edx
579
    pop  edx
580
    dec  edx
580
    dec  edx
581
    cmp  edx,0xffffffff
581
    cmp  edx,0xffffffff
582
    je   convert2
582
    je   convert2
583
    add  edi,3
583
    add  edi,3
584
    jmp  nextbit
584
    jmp  nextbit
585
 
585
 
586
  converttable:
586
  converttable:
587
    shl  eax,2
587
    shl  eax,2
588
    add  eax,ebx
588
    add  eax,ebx
589
    mov  edx, dword [eax]
589
    mov  edx, dword [eax]
590
    mov  dword [edi],edx
590
    mov  dword [edi],edx
591
    ret
591
    ret
592
 
592
 
593
 
593
 
594
; DATA AREA
594
; DATA AREA
595
 
595
 
596
;status   dd 0  ;bit0=1 if file thread is created
596
;status   dd 0  ;bit0=1 if file thread is created
597
bps      dd 0
597
bps      dd 0
598
dwps     dd 0
598
dwps     dd 0
599
soi      dd 0
599
soi      dd 0
600
sop      dd 0
600
sop      dd 0
601
eop      dd 0
601
eop      dd 0
602
eos      dd 0
602
eos      dd 0
603
;process  dd 0
603
;process  dd 0
604
 
604
 
605
; DATA AREA
605
; DATA AREA
606
fileinfo:
606
fileinfo:
607
     dd 0
607
     dd 0
608
     dd 0
608
     dd 0
609
     dd 1          ;number of blocks  of 512 bytes
609
     dd 1          ;number of blocks  of 512 bytes
610
     dd bmp_load_area
610
     dd bmp_load_area
611
     dd bmp_temp_area
611
     dd bmp_temp_area
612
string:
612
string:
613
  db bmp_file_name,0
613
  db bmp_file_name,0
614
  db '                                            '
614
  db '                                            '
615
  db '                                            '
615
  db '                                            '
616
  db '                                            '
616
  db '                                            '
617
  db '                                            ',0
617
  db '                                            ',0
618
 
618
 
619
 
619
 
620
end_bmp:
620
end_bmp:
621
    mov eax,dword [soi]
621
    mov eax,dword [soi]
622
    mov dword [bmp_soi],eax
622
    mov dword [bmp_soi],eax
623
 
623
 
624
}
624
}