Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
lang equ ru ; ru en fr ge fi
2
 
3
;
4
;   Assembler
5
;     SMALL
6
;       CODE
7
;         Libary
8
;
9
;  Ver 0.09 By Pavlushin Evgeni (RUSSIA)
10
;  www.waptap@mail.ru
11
 
12
;InfoList
13
;0.01 scank,putpix,puttxt
14
;0.02 label,random,colors
15
;0.03 window,startwd,endwd,attributes
16
;0.04 close,delay,scevent ~30.04.2004
17
;0.05 small random, ~04.05.2004
18
;0.06 wtevent ~09.05.2004
19
;0.07 timeevent ~23.05.2004
20
;0.08 txtput ~14.06.2004
21
;0.09 opendialog,savedialog ~20.06.2004
22
 
23
macro opendialog redproc,openoff,erroff,path,testtime
24
{
25
local still, dlg_file, clip_file, redwait
26
local button, key, red, zzz, still, zzz2, incf, file_is_open, zzz3
27
 
28
    mov ecx,200
29
zzz3:
30
    mov byte [path+ecx-1],0
31
    loop zzz3
32
 
33
    dec byte [clip_file+7]
34
incf:
35
    inc byte [clip_file+7]
36
    mov eax,6
37
    mov ebx,clip_file
38
    mov ecx,0
485 heavyiron 39
    or edx,-1
31 halyavin 40
    mov esi,path
485 heavyiron 41
    mcall
31 halyavin 42
    cmp byte [clip_file+7],'Z'
43
    je  erroff
44
    cmp eax,0xffffffff
45
    jne incf
46
 
47
    mov ecx,200
48
zzz2:
49
    mov byte [path+ecx],0
50
    loop zzz2
51
 
52
    mov ebx,clip_file
53
    mov ecx,path
54
    mov edx,100
55
    mov esi,0
56
    mov eax,33
485 heavyiron 57
    mcall
31 halyavin 58
 
59
    mov ebx,dlg_file
60
    mov ecx,clip_file
61
    mov eax,19
485 heavyiron 62
    mcall
31 halyavin 63
 
64
still:
65
    scevent red,key,button
66
    cmp byte [path],0
67
    jne file_is_open
68
    cmp dword [redwait],testtime ;20
69
    jnae zzz
70
    mov eax,6
71
    mov ebx,clip_file
72
    mov ecx,0
73
    mov edx,-1
74
    mov esi,path
485 heavyiron 75
    mcall
31 halyavin 76
    cmp eax,0xffffffff
77
    je  erroff ;errexit
78
    mov dword [redwait],0
79
zzz:
80
    delay 5
81
    inc dword [redwait]
82
    jmp still
83
 
84
file_is_open:
85
    mov eax,32
86
    mov ebx,clip_file
485 heavyiron 87
    mcall
31 halyavin 88
    jmp openoff
89
 
90
key:                          ; key
485 heavyiron 91
    mcall                   ; read (eax=2)
31 halyavin 92
    jmp  still
93
button:                       ; button
94
    mov  eax,17                 ; get id
485 heavyiron 95
    mcall
31 halyavin 96
    cmp  ah,1                   ; button id=1 ?
97
    jne  still
98
    mov  eax,-1                 ; close this program
485 heavyiron 99
    mcall
31 halyavin 100
 
101
red:
102
    call redproc
103
    jmp  still
104
 
105
dlg_file  db 'SYSXTREE   '
106
clip_file db 'OPENCLPACLP'
107
          db 'O'  ;Dialog type O-open S-save
108
          db 0    ;Marker
109
redwait dd 0
110
}
111
 
112
macro savedialog redproc,openoff,erroff,path,testtime
113
{
114
local still, dlg_file, clip_file, redwait, zzz3
115
local button, key, red, zzz, still, zzz2, incf, file_is_open
116
 
117
    mov ecx,200
118
zzz3:
119
    mov byte [path+ecx-1],0
120
    loop zzz3
121
 
122
    dec byte [clip_file+7]
123
incf:
124
    inc byte [clip_file+7]
125
    mov eax,6
126
    mov ebx,clip_file
127
    mov ecx,0
128
    mov edx,-1
129
    mov esi,path
485 heavyiron 130
    mcall
31 halyavin 131
    cmp byte [clip_file+7],'Z'
132
    je  erroff
133
    cmp eax,0xffffffff
134
    jne incf
135
 
136
    mov ecx,200
137
zzz2:
138
    mov byte [path+ecx],0
139
    loop zzz2
140
 
141
    mov ebx,clip_file
142
    mov ecx,path
143
    mov edx,100
144
    mov esi,0
145
    mov eax,33
485 heavyiron 146
    mcall
31 halyavin 147
 
148
    mov ebx,dlg_file
149
    mov ecx,clip_file
150
    mov eax,19
485 heavyiron 151
    mcall
31 halyavin 152
 
153
still:
154
    scevent red,key,button
155
    cmp byte [path],0
156
    jne file_is_open
157
    cmp dword [redwait],testtime ;20
158
    jnae zzz
159
    mov eax,6
160
    mov ebx,clip_file
161
    mov ecx,0
162
    mov edx,-1
163
    mov esi,path
485 heavyiron 164
    mcall
31 halyavin 165
    cmp eax,0xffffffff
166
    je  erroff ;errexit
167
    mov dword [redwait],0
168
zzz:
169
    delay 5
170
    inc dword [redwait]
171
    jmp still
172
 
173
file_is_open:
174
    mov eax,32
175
    mov ebx,clip_file
485 heavyiron 176
    mcall
31 halyavin 177
    jmp openoff
178
 
179
key:                          ; key
485 heavyiron 180
    mcall                   ; read (eax=2)
31 halyavin 181
    jmp  still
182
button:                       ; button
183
    mov  eax,17                 ; get id
485 heavyiron 184
    mcall
31 halyavin 185
    cmp  ah,1                   ; button id=1 ?
186
    jne  still
187
    mov  eax,-1                 ; close this program
485 heavyiron 188
    mcall
31 halyavin 189
 
190
red:
191
    call redproc
192
    jmp  still
193
 
194
dlg_file  db 'SYSXTREE   '
195
clip_file db 'SAVECLPACLP'
196
          db 'S'  ;Dialog type O-open S-save
197
          db 0    ;Marker
198
redwait dd 0
199
}
200
 
201
 
202
; RANDOM - generate random count (small)
203
; (SYNTAX)  RANDOM MaxCount,OutArgument
204
; (SAMPLE)  RANDOM 10000,eax
205
; ( NOTE )  Maxint<65536 ; use random 65536,eax for more combinations
206
 
207
randomuse = 0
208
 
209
macro random arg1,arg2
210
{
211
local rxproc
212
randomuse = randomuse + 1
213
 
214
      jmp rxproc
215
 
216
if defined randomuse & randomuse = 1
217
randomproc:
218
      jmp rnj
219
rsx1 dw 0x4321
220
rsx2 dw 0x1234
221
rnj:
222
;    mov eax,arg1
223
    push bx
224
    push cx
225
    push dx
226
    push si
227
    push di
228
    mov cx,ax
229
    mov ax,word ptr rsx1
230
    mov bx,word ptr rsx2
231
    mov si,ax
232
    mov di,bx
233
    mov dl,ah
234
    mov ah,al
235
    mov al,bh
236
    mov bh,bl
237
    xor bl,bl
238
    rcr dl,1
239
    rcr ax,1
240
    rcr bx,1
241
    add bx,di
242
    adc ax,si
243
    add bx,0x62e9
244
    adc ax,0x3619
245
    mov word ptr rsx1,bx
246
    mov word ptr rsx2,ax
247
    xor dx,dx
248
    cmp ax,0
249
    je nodiv
250
    cmp cx,0
251
    je nodiv
252
    div cx
253
nodiv:
254
    mov ax,dx
255
    pop di
256
    pop si
257
    pop dx
258
    pop cx
259
    pop bx
260
;    mov arg2,0
261
;    mov arg2,eax
262
    ret
263
end if
264
 
265
rxproc:
266
    mov eax,arg1
267
    call randomproc
268
    mov arg2,0
269
    mov arg2,eax
270
}
271
 
272
macro scank
273
{
274
    mov eax,10
485 heavyiron 275
    mcall
31 halyavin 276
}
277
 
278
macro putpix x,y,color
279
{
280
    mov ebx,x
281
    mov ecx,y
282
    mov edx,color
283
    mov eax,1
485 heavyiron 284
    mcall
31 halyavin 285
}
286
 
287
macro puttxt x,y,offs,size,color
288
{
289
    mov ebx,x
290
    shl ebx,16
291
    add ebx,y
292
    mov ecx,color
293
    mov edx,offs
294
    mov esi,size
295
    mov eax,4
485 heavyiron 296
    mcall
31 halyavin 297
}
298
 
299
;_ equ '____'
300
 
301
;macro libtest x,y,color
302
;{
303
;if x = as dword
304
;    mov ebx,x
305
;end if
306
;    mov ecx,y
307
;    mov edx,color
308
;    mov eax,1
485 heavyiron 309
;    mcall
31 halyavin 310
;}
311
 
312
 
313
macro outcount data, x, y, color, numtype
314
{
315
    mov ecx,data
316
    mov ebx,numtype
317
    mov bl,0
318
    mov edx,x*65536+y
319
    mov esi,color
320
    mov eax,47
485 heavyiron 321
    mcall
31 halyavin 322
}
323
 
324
; SCEVENT - Scan event
325
 
326
macro scevent red,key,but
327
{
328
    mov eax,11
485 heavyiron 329
    mcall
31 halyavin 330
    dec eax
331
    jz  red
332
    dec eax
333
    jz  key
334
    dec eax
335
    jz  but
336
}
337
 
338
; WTEVENT - Wait event
339
 
340
macro wtevent red,key,but
341
{
342
    mov eax,10
485 heavyiron 343
    mcall
31 halyavin 344
    dec eax
345
    jz  red
346
    dec eax
347
    jz  key
348
    dec eax
349
    jz  but
350
}
351
 
352
; TIMEEVENT - Wite for event with timeout
353
 
354
macro timeevent xfps,noevent,red,key,but
355
{
356
    mov eax,23
357
    mov ebx,xfps
485 heavyiron 358
    mcall
31 halyavin 359
    cmp eax,0
360
    je  noevent
361
    dec eax
362
    jz  red
363
    dec eax
364
    jz  key
365
    dec eax
366
    jz  but
367
}
368
 
369
 
370
; CLOSE - Close program
371
 
372
macro close
373
{
374
    mov eax,-1
485 heavyiron 375
    mcall
31 halyavin 376
}
377
 
378
; DELAY - Create delay 1/100 sec
379
; (SYNTAX)  Delay time
380
; (SAMPLE)  Delay 100   ;delay 2 sec 1/100*200=2 sec
381
 
382
macro delay arg1
383
{
384
    mov eax,5
385
    mov ebx,arg1
485 heavyiron 386
    mcall
31 halyavin 387
}
388
 
389
; WINDOW - Draw window
390
; (SYNTAX)  WINDOW Xstart,Ystart,'Text',Color
391
; (SAMPLE)  WINDOW 10,10,640+8,480+24,window_Skinned
392
 
393
macro window arg1,arg2,arg3,arg4,arg5
394
{
395
    mov ebx,arg1*65536+arg3
396
    mov ecx,arg2*65536+arg4
397
    mov edx,arg5
398
    mov eax,0
485 heavyiron 399
    mcall
31 halyavin 400
}
401
 
402
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
403
{
404
    mov ebx,arg1*65536+arg3
405
    mov ecx,arg2*65536+arg4
406
    mov edx,arg5
407
    mov esi,arg6
408
    mov edi,arg7
409
    mov eax,0
485 heavyiron 410
    mcall
31 halyavin 411
}
412
 
413
 
414
; STARTWD - Start of window draw
415
 
416
macro startwd
417
{
418
    mov eax,12
419
    mov ebx,1
485 heavyiron 420
    mcall
31 halyavin 421
}
422
 
423
; ENDWD - End window draw
424
 
425
macro endwd
426
{
427
    mov eax,12
428
    mov ebx,2
485 heavyiron 429
    mcall
31 halyavin 430
}
431
 
432
; LABEL - Put text to frame
433
; (SYNTAX)  LABEL Xstart,Ystart,'Text',Color
434
; (SAMPLE)  LABEL 10,12,'Hello World!',cl_Green+font_Big
435
 
436
macro label arg1,arg2,arg3,arg4
437
{
438
local asd,lab
439
    jmp asd
440
lab db  arg3                 ;arg label
441
asd:
442
    mov ebx,arg1             ;arg1=y arg2=x
443
    shl ebx,16
444
    add ebx,arg2
445
    mov ecx,arg4             ;arg4 color
446
    mov edx,lab
447
    mov esi,asd-lab          ;calc size
448
    mov eax,4
485 heavyiron 449
    mcall
31 halyavin 450
}
451
 
452
;Key's
453
key_Up     equ 178
454
key_Down   equ 177
455
key_Right  equ 179
456
key_Left   equ 176
457
key_Esc    equ 27
458
key_Space  equ 32
459
key_Enter  equ 13
460
key_Bspace equ 8
461
key_F1     equ 50
462
key_F2     equ 51
463
key_F3     equ 52
464
key_F4     equ 53
465
key_F5     equ 54
466
key_F6     equ 55
467
key_F7     equ 56
468
key_F8     equ 57
469
key_F9     equ 48
470
key_F10    equ 49
471
key_F11    equ 68
472
key_F12    equ 255
473
key_Home   equ 180
474
key_End    equ 181
475
key_PgUp   equ 184
476
key_PgDown equ 183
477
 
478
;Attributes
479
 
480
;Window Attributes
481
window_Skinned equ 0x03000000
482
window_Type2   equ 0x02000000
483
window_Type1   equ 0x00000000
484
window_Reserve equ 0x01000000
485
 
486
;Font Attributes
487
font_Big  equ 0x10000000
488
 
489
;Colors
490
cl_White  equ 0x00ffffff
491
cl_Black  equ 0x00000000
492
cl_Grey   equ 0x00888888
493
cl_Red    equ 0x00ff0000
494
cl_Lime   equ 0x0000ff00
495
cl_Green  equ 0x0000af00
496
cl_Blue   equ 0x000000ff
497
cl_Purple equ 0x008080ff
498
cl_Violet equ 0x008040ff
499
cl_Cyan   equ 0x0040e0ff