Subversion Repositories Kolibri OS

Rev

Rev 551 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 551 Rev 9241
Line 4... Line 4...
4
;   Assembler
4
;   Assembler
5
;     SMALL
5
;     SMALL
6
;       CODE
6
;       CODE
7
;         Libary
7
;         Libary
8
;
8
;
9
;  Ver 0.14 By Pavlushin Evgeni (RUSSIA)
9
;  Ver 0.17 (for FASM v1.54 or higer)
10
;  www.waptap@mail.ru
-
 
11
 
-
 
12
;Please compile aplications on FASM ver1.54 or higer!!!
-
 
13
 
-
 
14
;InfoList
-
 
15
;0.01 scank,putpix,puttxt
-
 
16
;0.02 label,random,colors
-
 
17
;0.03 window,startwd,endwd,attributes
-
 
18
;0.04 close,delay,scevent ~30.04.2004
-
 
19
;0.05 small random, ~04.05.2004
-
 
20
;0.06 wtevent ~09.05.2004
-
 
21
;0.07 timeevent ~23.05.2004
-
 
22
;0.08 txtput ~14.06.2004
-
 
23
;0.09 opendialog,savedialog ~20.06.2004
-
 
24
;0.10 wordstoreg by halyavin, add at ~30.08.2004
-
 
25
; random bug deleted eax is use.
-
 
26
;0.11 loadfile from me +puttxt bug del ~07.09.2004
-
 
27
;0.12 open/save dialog ~13.09.2004
-
 
28
;0.13 dialogs bugs deleted
-
 
29
;0.14 drawlbut ~03.10.2004
-
 
30
;0.15 extendet label!
-
 
31
 
-
 
32
; LOADFILE
-
 
33
; (SYNTAX)  LOADFILE 'full_path_to_file',file_load_area,file_temp_area
-
 
34
; (SAMPLE)  LOADFILE '/rd/1/clock.bmp',load_area,temp_area
-
 
35
 
-
 
36
 
-
 
37
macro loadfile file_name,file_load_area,file_temp_area
-
 
38
{
-
 
39
local open,fileinfo,string
-
 
40
    jmp open
-
 
41
fileinfo:
-
 
42
    dd 0
-
 
43
    dd 0
-
 
44
    dd 1
-
 
45
    dd file_load_area
-
 
46
    dd file_temp_area
-
 
47
string:
-
 
48
    db file_name,0
-
 
49
open:
-
 
50
    mov  dword [fileinfo+8],1 ; how many blocks to read (1)
-
 
51
    mov  eax,58
-
 
52
    mov  ebx,fileinfo
-
 
53
    mcall
-
 
54
    mov  eax,[file_load_area+2]
-
 
55
    shr  eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
-
 
56
    inc  eax
-
 
57
    mov  dword [fileinfo+8],eax
-
 
58
    mov  eax,58
-
 
59
    mov  ebx,fileinfo
-
 
60
    mcall
-
 
61
}
10
;
62
 
-
 
Line 63... Line 11...
63
 
11
 
64
macro wordstoreg reg,hiword,loword
12
macro movt op1,op2
65
{
-
 
66
if  hiword eqtype 0 & loword eqtype 0
-
 
67
    mov  reg,dword (hiword)*65536+(loword)
-
 
68
else if hiword eqtype 12 & loword eqtype eax
-
 
69
    mov  reg,dword (hiword)*65536
13
{
70
    add  reg,dword loword
-
 
71
else if hiword eqtype 12 & loword eqtype [123]
-
 
72
    mov  reg,dword (hiword)*65536
14
   if op2 eq
73
    add  reg,dword loword
15
      ;display 'not set'
74
else
16
   else
75
    mov  reg,dword hiword
17
      if op1 eq op2
76
    shl  reg,16
18
         display '+'
77
    add  reg,dword loword
-
 
78
end if
-
 
79
}
-
 
80
 
-
 
81
 
-
 
82
 
-
 
83
macro dword2reg reg,doubleword
-
 
84
{
-
 
85
if doubleword eq
-
 
86
   ; not changes
19
         ;display 'skip mov ' # `op1 # ',' # `op2 , 10,13
87
else
20
      else
-
 
21
         mov op1,op2
88
   mov reg,dword doubleword
22
      end if
89
end if
23
   end if
Line 90... Line 24...
90
}
24
}
91
 
25
 
92
macro words2reg reg,hiword,lowword
-
 
93
{
-
 
94
if hiword eq
-
 
95
   if lowword eq
-
 
96
      ; not changes
26
macro clear_buffer buffer, buf_size, value
97
   else
27
{
98
      if lowword eqtype 12
-
 
99
         and reg,dword 0xffff0000
28
   movt edi,buffer    ; edi = buffer adress
100
         add reg,dword lowword
29
   movt ecx,buf_size  ; ecx = buffer size
-
 
30
   movt al,value
101
      else
31
   call clear_buffer_proc
102
         and reg,dword 0xffff0000
32
 
103
         add reg,dword lowword
33
if ~ defined clear_buffer_used
104
      end if
-
 
105
   end if
34
clear_buffer_used equ 1
106
else
35
   jmp @f
107
   if lowword eq
-
 
108
      if hiword eqtype 12
-
 
109
         and reg,dword 0x0000ffff
36
clear_buffer_proc:
110
         add reg,dword hiword*65536
37
   mov ah,al
111
      else
38
   push ax
112
         shl reg,16
-
 
113
         add reg,dword hiword
-
 
114
         ror reg,16
39
   shl eax,16
115
      end if
-
 
116
   else
40
   pop ax            ; eax = al:al:al:al
117
      if lowword eqtype 12 & hiword eqtype 12
41
   push ecx
118
         if lowword eq 0 & hiword eq 0
-
 
119
               xor reg,reg
-
 
120
            else
42
   shr ecx,2         ; ecx = ecx/4 when we use stosd
121
               mov reg,dword hiword*65536+lowword
43
   cld               ; set direction flag
122
         end if
44
   rep stosd
123
      else
45
   pop ecx
124
         mov reg,dword hiword
-
 
125
         shl reg,16
46
   and ecx,011b      ; last two bits
126
         add reg,dword lowword
47
   rep stosb
127
      end if
48
   ret
128
   end if
49
@@:
Line -... Line 50...
-
 
50
end if
Line 129... Line -...
129
end if
-
 
130
}
-
 
131
 
-
 
132
 
-
 
133
 
51
}
134
 
52
 
135
; DRAW BUTTON with label
53
; draw_button - function for draw button with label placed at center
136
 
54
 
137
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
55
macro draw_button button_id,x,y,xs,ys,text,button_color,text_color
138
{
56
{
139
local asd,lab
57
local end_of_data,label
140
    jmp asd
58
   jmp end_of_data
141
lab db  text                 ;arg label
59
label db  text               ;arg label
142
asd:
60
end_of_data:
-
 
61
   words2reg ebx,x,xs        ; ebx = x * 65536 + xsize
-
 
62
   words2reg ecx,y,ys        ; ecx = y * 65536 + ysize
-
 
63
   mov edx,button_id
-
 
64
   mov esi,button_color
-
 
65
   push dword end_of_data-label
-
 
66
   push dword text_color
143
    words2reg ebx,x,xs
67
   push dword label
-
 
68
   call draw_button_proc
-
 
69
if ~ defined draw_button_used
144
    words2reg ecx,y,ys
70
draw_button_used equ 1
145
    mov edx,id
71
   jmp @f
146
    mov esi,bcolor
72
draw_button_proc:
147
    mov eax,8
73
   mov eax,8     ; eax = 8 add button function
148
    mcall
74
   mcall
149
 
75
 
150
    mov eax,asd-lab          ;calc size
76
   mov esi,[esp+12] ; esi = lenght of label
151
    mov ebx,6
77
   mov eax,esi
-
 
78
   mov edx,6     ; 6 - width of one char
152
    mul ebx
79
   mul edx       ; eax = size of label in pixels (chars number * 6)
153
    mov esi,eax
80
 
154
 
81
   sub bx,ax
155
    mov eax,xs
82
   shr bx,1
156
    sub eax,esi
83
   mov edi,ebx
157
    shr eax,1
84
   shr edi,16
-
 
85
   add bx,di
158
    add eax,x
86
 
159
 
87
   sub cx,7
Line 160... Line -...
160
    mov edx,ys
-
 
161
    sub edx,7
88
   shr cx,1
162
    shr edx,1
89
   mov edi,ecx
Line 163... Line 90...
163
    add edx,y
90
   shr edi,16
164
 
91
   add cx,di
165
    mov ebx,eax
92
 
166
    shl ebx,16
-
 
167
    add ebx,edx
93
   shl ebx,16
-
 
94
   mov bx,cx     ; ebx = bx * 65536 + edx
-
 
95
 
-
 
96
   mov ecx,[esp+8] ; text color
168
 
97
   mov edx,[esp+4] ; set address of label
Line 169... Line -...
169
    mov ecx,tcolor             ;arg4 color
-
 
-
 
98
   mov eax,4       ; eax = 4 draw label function
170
    mov edx,lab
99
   mcall
171
    mov esi,asd-lab          ;calc size
100
   ret 3*4
172
    mov eax,4
-
 
173
    mcall
-
 
174
}
-
 
175
 
-
 
176
 
-
 
177
macro opendialog redproc,openoff,erroff,path
-
 
178
{
-
 
179
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
-
 
180
local run_fileinfo, param
-
 
181
local getmesloop, loox, mred, mkey, mbutton, mgetmes
-
 
182
local dlg_is_work, ready, procinfo
-
 
183
;
-
 
184
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
-
 
185
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
-
 
186
;
-
 
187
 
-
 
188
    cld
-
 
189
;;    mov esi,path
-
 
190
    mov edi,path
-
 
191
    mov eax,0
-
 
192
    mov ecx,200
-
 
193
    rep stosb
-
 
194
 
-
 
195
;mov [get_loops],0
-
 
196
mov [dlg_pid_get],0
-
 
197
 
-
 
198
; Get my PID in dec format 4 bytes
-
 
199
    mov eax,9
-
 
200
    mov ebx,procinfo
-
 
201
    mov ecx,-1
-
 
202
    mcall
-
 
203
 
-
 
204
; convert eax bin to param dec
-
 
205
    mov eax,dword [procinfo+30]  ;offset of myPID
-
 
206
    mov edi,param+4-1            ;offset to 4 bytes
-
 
207
    mov ecx,4
-
 
208
    mov ebx,10
-
 
209
    cld
-
 
210
new_d:
-
 
211
    xor edx,edx
-
 
212
    div ebx
-
 
213
    add dl,'0'
-
 
214
    mov [edi],dl
-
 
215
    dec edi
-
 
216
    loop new_d
-
 
217
 
-
 
218
; wirite 1 byte space to param
-
 
219
    mov [param+4],byte 32    ;Space for next parametr
-
 
220
; and 1 byte type of dialog to param
-
 
221
    mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
-
 
222
 
-
 
223
;
-
 
224
; STEP2 prepare IPC area for get messages
-
 
225
;
-
 
226
 
-
 
227
; prepare IPC area
-
 
228
    mov [path],dword 0
-
 
229
    mov [path+4],dword 8
-
 
230
 
-
 
231
; define IPC memory
-
 
232
    mov eax,60
101
@@:
233
    mov ebx,1        ; define IPC
-
 
234
    mov ecx,path     ; offset of area
102
end if
-
 
103
}
-
 
104
 
-
 
105
; scan_event - Scan event without wait
-
 
106
macro scan_event redraw,key,button
-
 
107
{
-
 
108
   mov eax,11
-
 
109
   mcall
Line 235... Line -...
235
    mov edx,150      ; size 150 bytes
-
 
236
    mcall
110
   dec eax
-
 
111
   jz  redraw
237
 
112
   dec eax
238
; change wanted events list 7-bit IPC event
-
 
239
    mov eax,40
113
   jz  key
240
    mov ebx,01000111b
-
 
241
    mcall
114
   dec eax
-
 
115
   jz  button
-
 
116
}
-
 
117
 
-
 
118
; wait_event - Wait for event
-
 
119
macro wait_event redraw,key,button
-
 
120
{
-
 
121
   mov eax,10
Line 242... Line 122...
242
 
122
   mcall
-
 
123
   dec eax
243
;
124
   jz  redraw
244
; STEP 3 run SYSTEM XTREE with parameters
-
 
245
;
-
 
246
 
125
   dec eax
247
    mov eax,58
126
   jz  key
248
    mov ebx,run_fileinfo
127
   dec eax
249
    mcall
-
 
250
 
128
   jz  button
251
    call redproc
129
}
252
 
130
 
253
    mov [get_loops],0
131
; time_event - Wait for event with timeout
254
getmesloop:
-
 
255
    mov eax,23
-
 
256
    mov ebx,50     ;0.5 sec
-
 
257
    mcall
132
macro time_event xfps,noevent,redraw,key,button
258
 
-
 
259
    cmp eax,1
-
 
260
    je  mred
-
 
261
    cmp eax,2
-
 
262
    je  mkey
-
 
263
    cmp eax,3
-
 
264
    je  mbutton
-
 
265
    cmp eax,7
-
 
266
    je  mgetmes
-
 
267
 
-
 
268
; Get number of procces
-
 
269
    mov ebx,procinfo
-
 
270
    mov ecx,-1
-
 
271
    mov eax,9
-
 
272
    mcall
-
 
273
    mov ebp,eax
-
 
274
 
133
{
275
loox:
134
   mov eax,23
276
    mov eax,9
-
 
277
    mov ebx,procinfo
-
 
278
    mov ecx,ebp
-
 
279
    mcall
-
 
280
    mov eax,[DLGPID]
-
 
281
    cmp [procinfo+30],eax    ;IF Dialog find
-
 
282
    je  dlg_is_work          ;jmp to dlg_is_work
-
 
283
    dec ebp
-
 
284
    jnz loox
-
 
285
 
-
 
286
    jmp erroff
-
 
287
 
-
 
288
dlg_is_work:
-
 
289
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
-
 
290
    je  erroff                 ;TESTODP2 terminated too
-
 
291
 
-
 
292
    cmp [dlg_pid_get],dword 1
-
 
293
    je  getmesloop
-
 
294
    inc [get_loops]
135
   mov ebx,xfps
295
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
-
 
296
    jae erroff
-
 
297
    jmp getmesloop
-
 
298
 
-
 
299
mred:
-
 
300
    call redproc
-
 
301
    jmp  getmesloop
-
 
302
mkey:
-
 
303
    mov  eax,2
-
 
304
    mcall                   ; read (eax=2)
-
 
305
    jmp  getmesloop
-
 
306
mbutton:
-
 
307
    mov  eax,17                 ; get id
-
 
308
    mcall
136
   mcall
309
    cmp  ah,1                   ; button id=1 ?
-
 
310
    jne  getmesloop
-
 
311
    mov  eax,-1                 ; close this program
-
 
312
    mcall
-
 
313
mgetmes:
-
 
314
 
-
 
315
; If dlg_pid_get then second message get jmp to still
-
 
316
    cmp  [dlg_pid_get],dword 1
-
 
317
    je   ready
-
 
318
 
-
 
319
; First message is number of PID SYSXTREE dialog
-
 
320
 
-
 
321
; convert PID dec to PID bin
-
 
322
    movzx eax,byte [path+16]
-
 
323
    sub eax,48
-
 
324
    imul eax,10
-
 
325
    movzx ebx,byte [path+16+1]
-
 
326
    add eax,ebx
-
 
327
    sub eax,48
-
 
328
    imul eax,10
-
 
329
    movzx ebx,byte [path+16+2]
-
 
330
    add eax,ebx
-
 
331
    sub eax,48
-
 
332
    imul eax,10
-
 
333
    movzx ebx,byte [path+16+3]
-
 
334
    add eax,ebx
-
 
335
    sub eax,48
-
 
336
    mov [DLGPID],eax
-
 
337
 
-
 
338
; Claear and prepare IPC area for next message
-
 
339
    mov [path],dword 0
-
 
340
    mov [path+4],dword 8
-
 
341
    mov [path+8],dword 0
-
 
342
    mov [path+12],dword 0
-
 
343
    mov [path+16],dword 0
-
 
344
 
-
 
345
; Set dlg_pid_get for get next message
-
 
346
    mov [dlg_pid_get],dword 1
-
 
347
    call redproc   ;show DLG_PID
-
 
348
    jmp  getmesloop
-
 
349
 
-
 
350
ready:
-
 
351
;
-
 
352
; The second message get
-
 
353
; Second message is 100 bytes path to SAVE/OPEN file
-
 
354
; shl path string on 16 bytes
-
 
355
;
-
 
356
    cld
-
 
357
    mov esi,path+16
-
 
358
    mov edi,path
-
 
359
    mov ecx,200
-
 
360
    rep movsb
-
 
361
    mov [edi],byte 0
-
 
362
 
-
 
363
    jmp openoff
-
 
364
 
-
 
365
 
-
 
366
; DATA AREA
-
 
367
get_loops   dd 0
-
 
368
dlg_pid_get dd 0
-
 
369
DLGPID      dd 0
-
 
370
 
-
 
371
param:
-
 
372
   dd 0    ; My dec PID
-
 
373
   dd 0,0  ; Type of dialog
-
 
374
 
-
 
375
run_fileinfo:
-
 
376
 dd 16
-
 
377
 dd 0
137
   ;cmp eax,0
Line 378... Line -...
378
 dd param
-
 
-
 
138
   ;je  noevent
379
 dd 0
139
   dec eax
380
 dd procinfo ; 0x10000
140
   js  noevent
381
;run_filepath
-
 
382
 db '/sys/SYSXTREE',0
-
 
383
 
141
   jz  redraw
384
procinfo:
-
 
385
times 256 db 0
-
 
386
}
142
   dec eax
387
 
143
   jz  key
388
 
-
 
389
macro savedialog redproc,openoff,erroff,path
-
 
390
{
-
 
391
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
-
 
392
local run_fileinfo, run_filepath, param
-
 
393
local getmesloop, loox, mred, mkey, mbutton, mgetmes
-
 
394
local dlg_is_work, ready, procinfo
-
 
395
;
-
 
396
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
-
 
397
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
-
 
398
;
-
 
399
 
-
 
400
    cld
-
 
401
;;    mov esi,path
-
 
402
    mov edi,path
-
 
403
    mov eax,0
-
 
404
    mov ecx,200
144
   dec eax
405
    rep stosb
-
 
406
 
-
 
407
;mov [get_loops],0
-
 
408
mov [dlg_pid_get],0
-
 
409
 
-
 
410
; Get my PID in dec format 4 bytes
-
 
411
    mov eax,9
-
 
412
    mov ebx,procinfo
-
 
413
    mov ecx,-1
-
 
414
    mcall
-
 
415
 
-
 
416
; convert eax bin to param dec
-
 
417
    mov eax,dword [procinfo+30]  ;offset of myPID
-
 
418
    mov edi,param+4-1            ;offset to 4 bytes
-
 
419
    mov ecx,4
-
 
420
    mov ebx,10
-
 
421
    cld
-
 
422
new_d:
-
 
423
    xor edx,edx
-
 
424
    div ebx
-
 
425
    add dl,'0'
-
 
426
    mov [edi],dl
-
 
427
    dec edi
145
   jz  button
Line 428... Line 146...
428
    loop new_d
146
}
429
 
-
 
430
; wirite 1 byte space to param
147
 
431
    mov [param+4],byte 32    ;Space for next parametr
148
; function for set ascii or scan code keyboard input mode
432
; and 1 byte type of dialog to param
-
 
433
    mov [param+5],byte 'S'   ;Get Open dialog (Use 'S' for Save dialog)
149
macro keyboard_set_input_mode mode
434
 
150
{
435
;
151
   mov eax,66      ; eax = 66 - keyboard service function
436
; STEP2 prepare IPC area for get messages
152
   mov ebx,1       ; ebx = 1 - sub function for set input mode for keyboard
437
;
153
   mov ecx,mode    ; ecx = mode 0 - ASCII; 1 - scan codes;
-
 
154
   mcall
Line 438... Line 155...
438
 
155
}
439
; prepare IPC area
156
 
-
 
157
; function for read layout to 128 byte array
440
    mov [path],dword 0
158
macro keyboard_get_layout layout_type, layout_array
441
    mov [path+4],dword 8
159
{
-
 
160
   mov eax,26           ; eax = 26 - hardware service function
-
 
161
   mov ebx,2            ; ebx = 2 - subfunction for get keyboard layout
-
 
162
   mov ecx,layout_type  ; ecx = layout type: 1 - for normal layout
-
 
163
   mov edx,layout_array ; edx = address to 128 byte array
Line -... Line 164...
-
 
164
   mcall
-
 
165
}
442
 
166
 
443
; define IPC memory
167
; function for get key from keyboard buffer
-
 
168
macro window_get_key output
-
 
169
{
-
 
170
   mov  eax,2  ; eax = 2 - get keyboard pressed key function
-
 
171
   mcall
444
    mov eax,60
172
   if ~output eq
Line -... Line 173...
-
 
173
      mov output,eax
-
 
174
   end if
-
 
175
}
445
    mov ebx,1        ; define IPC
176
 
446
    mov ecx,path ; offset of area
177
; function for get id of button pressed in window
-
 
178
macro window_get_button output
447
    mov edx,120      ; size 150 bytes
179
{
-
 
180
   mov  eax,17 ; eax = 17 - get id of pressed button function
Line -... Line 181...
-
 
181
   mcall
-
 
182
   if ~output eq
-
 
183
      mov output,eax
-
 
184
   end if
448
    mcall
185
}
-
 
186
 
-
 
187
macro draw_pixel x,y,color
-
 
188
{
-
 
189
   mov ebx,x
Line 449... Line 190...
449
 
190
   mov ecx,y
450
; change wanted events list 7-bit IPC event
191
   mov edx,color
-
 
192
   mov eax,1
451
    mov eax,40
193
   mcall
452
    mov ebx,01000111b
194
}
453
    mcall
195
 
-
 
196
macro puttxt x,y,offs,size,color
Line 454... Line -...
454
 
-
 
455
;
-
 
456
; STEP 3 run SYSTEM XTREE with parameters
-
 
457
;
-
 
458
 
-
 
459
    mov eax,58
-
 
460
    mov ebx,run_fileinfo
-
 
461
    mcall
-
 
462
 
-
 
463
    call redproc
197
{
464
 
-
 
465
    mov [get_loops],0
-
 
466
getmesloop:
-
 
467
    mov eax,23
-
 
468
    mov ebx,50     ;0.5 sec
198
   words2reg ebx,x,y
469
    mcall
199
   mov ecx,color
470
 
-
 
471
    cmp eax,1
200
   mov edx,offs
472
    je  mred
-
 
473
    cmp eax,2
201
   mov esi,size
474
    je  mkey
-
 
475
    cmp eax,3
-
 
476
    je  mbutton
-
 
477
    cmp eax,7
-
 
478
    je  mgetmes
-
 
479
 
-
 
480
; Get number of procces
-
 
481
    mov ebx,procinfo
-
 
482
    mov ecx,-1
-
 
483
    mov eax,9
-
 
484
    mcall
-
 
485
    mov ebp,eax
-
 
486
 
-
 
487
loox:
-
 
488
    mov eax,9
-
 
489
    mov ebx,procinfo
-
 
490
    mov ecx,ebp
-
 
491
    mcall
-
 
492
    mov eax,[DLGPID]
-
 
493
    cmp [procinfo+30],eax    ;IF Dialog find
-
 
494
    je  dlg_is_work          ;jmp to dlg_is_work
-
 
495
    dec ebp
-
 
496
    jnz loox
-
 
497
 
-
 
498
    jmp erroff
-
 
499
 
-
 
500
dlg_is_work:
-
 
501
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
-
 
502
    je  erroff                 ;TESTODP2 terminated too
-
 
503
 
-
 
504
    cmp [dlg_pid_get],dword 1
-
 
505
    je  getmesloop
-
 
506
    inc [get_loops]
202
   mov eax,4
507
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
-
 
508
    jae erroff
-
 
509
    jmp getmesloop
-
 
510
 
-
 
511
mred:
-
 
512
    call redproc
-
 
513
    jmp  getmesloop
-
 
514
mkey:
-
 
515
    mcall                   ; read (eax=2)
-
 
516
    jmp  getmesloop
-
 
517
mbutton:
-
 
518
    mov  eax,17                 ; get id
-
 
519
    mcall
-
 
520
    cmp  ah,1                   ; button id=1 ?
-
 
521
    jne  getmesloop
-
 
522
    mov  eax,-1                 ; close this program
-
 
523
    mcall
-
 
524
mgetmes:
-
 
525
 
-
 
526
; If dlg_pid_get then second message get jmp to still
-
 
527
    cmp  [dlg_pid_get],dword 1
-
 
528
    je   ready
-
 
529
 
-
 
530
; First message is number of PID SYSXTREE dialog
-
 
531
 
-
 
532
; convert PID dec to PID bin
-
 
533
    movzx eax,byte [path+16]
-
 
534
    sub eax,48
-
 
535
    imul eax,10
-
 
536
    movzx ebx,byte [path+16+1]
-
 
537
    add eax,ebx
-
 
538
    sub eax,48
203
   mcall
539
    imul eax,10
-
 
540
    movzx ebx,byte [path+16+2]
-
 
541
    add eax,ebx
-
 
542
    sub eax,48
-
 
Line 543... Line -...
543
    imul eax,10
-
 
544
    movzx ebx,byte [path+16+3]
-
 
545
    add eax,ebx
-
 
546
    sub eax,48
204
}
547
    mov [DLGPID],eax
-
 
548
 
-
 
549
; Claear and prepare IPC area for next message
-
 
550
    mov [path],dword 0
-
 
551
    mov [path+4],dword 8
-
 
552
    mov [path+8],dword 0
-
 
553
    mov [path+12],dword 0
-
 
554
    mov [path+16],dword 0
-
 
555
 
-
 
556
; Set dlg_pid_get for get next message
-
 
557
    mov [dlg_pid_get],dword 1
-
 
558
    call redproc   ;show DLG_PID
-
 
559
    jmp  getmesloop
-
 
560
 
-
 
561
ready:
-
 
562
;
-
 
563
; The second message get
-
 
564
; Second message is 100 bytes path to SAVE/OPEN file
205
 
565
; shl path string on 16 bytes
-
 
566
;
206
; window_begin_draw - Begin of draw window
Line -... Line 207...
-
 
207
macro window_begin_draw
-
 
208
{
567
    cld
209
   mov eax,12
568
    mov esi,path+16
210
   mov ebx,1
-
 
211
   mcall
569
    mov edi,path
212
}
570
    mov ecx,200
-
 
571
    rep movsb
213
 
-
 
214
; window_end_draw - End draw of window
572
    mov [edi],byte 0
215
macro window_end_draw
573
 
216
{
-
 
217
   mov eax,12
574
    jmp openoff
218
   mov ebx,2
575
 
219
   mcall
-
 
220
}
-
 
221
 
-
 
222
; fs_read_file - read file from file system and save it to array
-
 
223
; example:
-
 
224
; fs_read_file '/rd/1/clock.bmp',load_area,temp_area
-
 
225
 
576
 
226
macro fs_read_file file_name,file_load_area,file_temp_area
-
 
227
{
577
; DATA AREA
228
local open,fileinfo,string
-
 
229
   jmp open
-
 
230
fileinfo:
578
get_loops   dd 0
231
   dd 0
Line 579... Line -...
579
dlg_pid_get dd 0
-
 
580
DLGPID      dd 0
-
 
581
 
-
 
582
param:
232
   dd 0
-
 
233
   dd 1
583
   rb 4  ; My dec PID
234
   dd file_load_area
-
 
235
   dd file_temp_area
584
   rb 6  ; Type of dialog
236
string:
585
 
237
   db file_name,0
Line 586... Line 238...
586
run_fileinfo:
238
open:
587
 dd 16
-
 
588
 dd 0
239
   mov  dword [fileinfo+8],1 ; how many blocks to read (1)
589
 dd param
240
   mov  eax,58
590
 dd 0
241
   mov  ebx,fileinfo
591
 dd procinfo
242
   mcall
592
run_filepath:
-
 
593
 db '/sys/SYSXTREE',0
243
   mov  eax,[file_load_area+2]
Line 594... Line 244...
594
 
244
   shr  eax,9    ; div to 512 and add 1 - for get number of blocks
595
procinfo:
245
   inc  eax
596
times 256 db 0
246
   mov  dword [fileinfo+8],eax
597
}
-
 
598
 
-
 
599
 
-
 
600
 
247
   mov  eax,58
601
 
248
   mov  ebx,fileinfo
602
; RANDOM - generate random count (small)
249
   mcall
603
; (SYNTAX)  RANDOM MaxCount,OutArgument
250
}
604
; (SAMPLE)  RANDOM 10000,eax
251
 
605
; ( NOTE )  Maxint<65536 ; use random 65536,eax for more combinations
252
; random - generate random count (small)
606
 
253
; example:
607
randomuse = 0
254
; random 10000,eax ; generate random value from 0 to 10000 and save it in eax
608
 
255
; note:
609
macro random arg1,arg2
256
; max_value<65536
610
{
257
; only modificate eax register
Line 649... Line 296...
649
    je nodiv
296
      je nodiv
650
    cmp cx,0
297
      cmp cx,0
651
    je nodiv
298
      je nodiv
652
    div cx
299
      div cx
653
nodiv:
300
   nodiv:
654
    mov ax,dx
301
      mov [rnd_result],dx
655
    pop di
302
      popad
656
    pop si
-
 
657
    pop dx
-
 
658
    pop cx
-
 
659
    pop bx
-
 
660
    and eax,0000ffffh
-
 
661
;    mov arg2,0
-
 
662
;    mov arg2,eax
303
      mov eax,dword [rnd_result]
663
    ret
304
      ret
-
 
305
   ; data block after ret
-
 
306
   rsx1   dw 0x4321
-
 
307
   rsx2   dw 0x1234
-
 
308
   rnd_result dw 0
-
 
309
   dw 0
664
end if
310
end if
Line 665... Line 311...
665
 
311
 
666
rxproc:
312
rxproc:
667
    mov eax,arg1
313
   movt eax,max_value
668
    call randomproc
-
 
669
    mov arg2,eax
-
 
670
}
-
 
671
 
-
 
672
macro scank
-
 
673
{
-
 
674
    mov eax,10
-
 
675
    mcall
-
 
676
}
-
 
677
 
-
 
678
macro putpix x,y,color
-
 
679
{
-
 
680
    mov ebx,x
-
 
681
    mov ecx,y
-
 
682
    mov edx,color
-
 
683
    mov eax,1
-
 
684
    mcall
-
 
685
}
-
 
686
 
-
 
687
macro puttxt x,y,offs,size,color
-
 
688
{
-
 
689
;    mov ebx,x
-
 
690
;    shl ebx,16
-
 
691
;    add ebx,y
-
 
692
    words2reg ebx,x,y
-
 
693
    mov ecx,color
-
 
694
    mov edx,offs
-
 
695
    mov esi,size
-
 
696
    mov eax,4
-
 
697
    mcall
-
 
698
}
-
 
699
 
-
 
700
macro outcount data, x, y, color, numtype
-
 
701
{
-
 
702
    mov ecx,data
-
 
703
    mov ebx,numtype
-
 
704
    mov bl,0
-
 
705
;    mov edx,x*65536+y
-
 
706
    words2reg edx,x,y
-
 
707
    mov esi,color
-
 
708
    mov eax,47
-
 
709
    mcall
-
 
710
}
-
 
711
 
-
 
712
; SCEVENT - Scan event
-
 
713
 
-
 
714
macro scevent red,key,but
-
 
715
{
-
 
716
    mov eax,11
-
 
717
    mcall
-
 
718
    dec eax
-
 
719
    jz  red
-
 
720
    dec eax
-
 
721
    jz  key
-
 
722
    dec eax
-
 
723
    jz  but
-
 
724
}
-
 
725
 
-
 
726
; WTEVENT - Wait event
-
 
727
 
-
 
728
macro wtevent red,key,but
-
 
729
{
-
 
730
    mov eax,10
-
 
731
    mcall
-
 
732
    dec eax
-
 
733
    jz  red
-
 
734
    dec eax
-
 
735
    jz  key
-
 
736
    dec eax
-
 
737
    jz  but
-
 
738
}
-
 
739
 
-
 
740
; TIMEEVENT - Wite for event with timeout
-
 
741
 
314
   call randomproc
742
macro timeevent xfps,noevent,red,key,but
-
 
743
{
-
 
744
    mov eax,23
-
 
745
    mov ebx,xfps
-
 
746
    mcall
-
 
747
    cmp eax,0
-
 
748
    je  noevent
-
 
749
    dec eax
-
 
750
    jz  red
-
 
751
    dec eax
-
 
752
    jz  key
-
 
753
    dec eax
-
 
754
    jz  but
315
   movt result,eax ;dword [rnd_result]
Line 755... Line -...
755
}
-
 
756
 
316
}
Line 757... Line 317...
757
 
317
 
758
; CLOSE - Close program
318
; close - Close application
759
 
319
 
760
macro close
320
macro close
761
{
321
{
Line 762... Line 322...
762
    mov eax,-1
322
   mov eax,-1
763
    mcall
323
   mcall
764
}
324
}
Line 765... Line 325...
765
 
325
 
766
; DELAY - Create delay 1/100 sec
326
; delay - Create delay 1/100 sec
767
; (SYNTAX)  Delay time
327
; example:
768
; (SAMPLE)  Delay 100   ;delay 2 sec 1/100*200=2 sec
328
; delay 100   ;delay 2 sec 1/100*200=2 sec
769
 
329
 
770
macro delay arg1
330
macro delay arg1
Line 771... Line 331...
771
{
331
{
772
    mov eax,5
332
   mov eax,5
-
 
333
   mov ebx,arg1
773
    mov ebx,arg1
334
   mcall
Line 774... Line 335...
774
    mcall
335
}
775
}
336
 
776
 
-
 
777
; WINDOW - Draw window
-
 
778
; (SYNTAX)  WINDOW Xstart,Ystart,'Text',Color
337
; window - Draw window
779
; (SAMPLE)  WINDOW 10,10,640+8,480+24,window_Skinned
338
; window Xstart,Ystart,'Text',Color
780
 
339
; example:
781
macro window arg1,arg2,arg3,arg4,arg5
340
; window 10,10,640+8,480+24,window_Skinned
782
{
341
 
Line 798... Line 357...
798
    mov edi,arg7
357
   mov edi,arg7
799
    mov eax,0
358
   mov eax,0
800
    mcall
359
   mcall
801
}
360
}
Line -... Line 361...
-
 
361
 
Line -... Line 362...
-
 
362
;Key's scan codes
802
 
363
 
-
 
364
ErrorCode      equ   0 ; 0x00
-
 
365
key_Esc        equ   1 ; 0x01
-
 
366
key_1          equ   2 ; 0x02 !
-
 
367
key_2          equ   3 ; 0x03 @
-
 
368
key_3          equ   4 ; 0x04 #
-
 
369
key_4          equ   5 ; 0x05 $
-
 
370
key_5          equ   6 ; 0x06 %
-
 
371
key_6          equ   7 ; 0x07 "
-
 
372
key_7          equ   8 ; 0x08 &
-
 
373
key_8          equ   9 ; 0x09 *
803
 
374
key_9          equ  10 ; 0x0A (
804
; STARTWD - Start of window draw
375
key_0          equ  11 ; 0x0B )
805
 
-
 
806
macro startwd
376
 
807
{
377
key_Backspace  equ  14 ; 0x0E
808
    mov eax,12
378
key_Q          equ  16 ; 0x10
809
    mov ebx,1
-
 
-
 
379
key_W          equ  17 ; 0x11
-
 
380
key_E          equ  18 ; 0x12
-
 
381
key_R          equ  19 ; 0x13
-
 
382
key_T          equ  20 ; 0x14
-
 
383
key_Y          equ  21 ; 0x15
-
 
384
key_U          equ  22 ; 0x16
-
 
385
key_I          equ  23 ; 0x17
810
    mcall
386
key_O          equ  24 ; 0x18
811
}
387
key_P          equ  25 ; 0x19
812
 
-
 
-
 
388
 
-
 
389
key_Enter     equ 28   ; 0x1C
-
 
390
key_A         equ 30   ; 0x1E
-
 
391
key_S         equ 31   ; 0x1F
-
 
392
key_D         equ 32   ; 0x20
-
 
393
key_F         equ 33   ; 0x21
-
 
394
key_G         equ 34   ; 0x22
-
 
395
key_H         equ 35   ; 0x23
-
 
396
key_J         equ 36   ; 0x24
-
 
397
key_K         equ 37   ; 0x25
-
 
398
key_L         equ 38   ; 0x26
-
 
399
key_Colon     equ 39   ; 0x27 ':;'
813
; ENDWD - End window draw
400
key_DQuotes   equ 0x28 ; 40 '"''
814
 
-
 
815
macro endwd
401
key_Tilda     equ 0x29 ; 41 '~`'
816
{
402
key_LShift    equ 0x2A ; 42
817
    mov eax,12
403
key_Z         equ 0x2C ; 44
818
    mov ebx,2
-
 
819
    mcall
-
 
-
 
404
key_X         equ 0x2D ; 45
820
}
405
key_C         equ 0x2E ; 46
-
 
406
key_V         equ 0x2F ; 47
-
 
407
key_B         equ 0x30 ; 48
821
 
408
key_N         equ 0x31 ; 49
822
; LABEL - Put text to frame
409
key_M         equ 0x32 ; 50
823
; (SYNTAX)  LABEL Xstart,Ystart,'Text',Color
-
 
824
; (SAMPLE)  LABEL 10,12,'Hello World!',cl_Green+font_Big
410
key_Comma     equ 0x33 ; 51 ',<'
825
 
-
 
-
 
411
key_Dot       equ 0x34 ; 52 '.>'
-
 
412
key_Question  equ 0x35 ; 53 '?/'
-
 
413
key_RShift    equ 0x36 ; 54
-
 
414
key_NumStar   equ 0x37 ; 55 '*'
826
macro label arg1,arg2,arg3,arg4
415
key_LAlt      equ 0x38 ; 56
-
 
416
key_Space     equ 0x39 ; 57
827
{
417
key_CapsLock  equ 0x3A ; 58
828
local asd,lab
418
key_F1        equ 0x3B ; 59
-
 
419
key_F2        equ 0x3C ; 60
829
    jmp asd
420
key_F3        equ 0x3D ; 61
830
lab db  arg3                 ;arg label
421
key_F4        equ 62
-
 
422
key_F5        equ 63
831
asd:
423
key_F6        equ 64
832
;    mov ebx,arg1             ;arg1=y arg2=x
424
key_F7        equ 65
833
;    shl ebx,16
-
 
834
;    add ebx,arg2
-
 
-
 
425
key_F8        equ 66
-
 
426
key_F9        equ 67
-
 
427
key_F10       equ 0x44 ; 68
835
 
428
key_NumLock   equ 0x45 ; 69
836
 
-
 
-
 
429
key_ScrollLock equ 0x46 ; 70
-
 
430
key_Up        equ 0x48 ; 72
-
 
431
key_Num8      equ 0x48 ; 72
-
 
432
key_PageUp    equ 0x49 ; 73
-
 
433
key_Num9      equ 0x49 ; 73
-
 
434
key_NumMinus  equ 0x4A ; 74
-
 
435
key_Left      equ 0x4B ; 75
-
 
436
key_Num4      equ 0x4B ; 75
837
   words2reg ebx,arg1,arg2
437
key_Num5      equ 0x4C ; 76
-
 
438
key_Right     equ 0x4D ; 77
-
 
439
key_Down      equ 0x50 ; 80
-
 
440
key_Num2      equ 0x50 ; 80
-
 
441
key_F11       equ 0x57 ; 87
-
 
442
key_F12       equ 0x58 ; 88
-
 
443
key_PA1       equ  90 ; 0x5A
-
 
444
key_Lwin      equ  91 ; 0x5B
-
 
445
key_F13       equ  91 ; 0x5B
-
 
446
key_Rwin      equ  92 ; 0x5C
-
 
447
key_F14       equ  92 ; 0x5C
-
 
448
key_Menu      equ  93 ; 0x5D
-
 
449
key_F15       equ  93 ; 0x5D
-
 
450
key_F16       equ  99 ; 0x63
-
 
451
key_F17       equ 100 ; 0x64
-
 
452
key_F18       equ 101 ; 0x65
-
 
453
key_F19       equ 102 ; 0x66
-
 
454
key_F20       equ 103 ; 0x67
-
 
455
key_F21       equ 104 ; 0x68
-
 
456
key_F22       equ 105 ; 0x69
-
 
457
key_F23       equ 106 ; 0x6A
-
 
458
key_F24       equ 107 ; 0x6B
-
 
459
key_EraseEOF  equ 109 ; 0x6D
-
 
460
key_CopyPlay  equ 111 ; 0x6F
-
 
461
key_CrSel     equ 114 ; 0x72
-
 
462
key_Delta     equ 115 ; 0x73
Line 838... Line -...
838
 
-
 
839
   dword2reg ecx,arg4
-
 
840
 
-
 
841
 
-
 
842
    mov edx,lab
-
 
843
    mov esi,asd-lab          ;calc size
-
 
844
    mov eax,4
-
 
845
    mcall
-
 
846
}
-
 
847
 
-
 
848
;Key's
-
 
849
key_Up     equ 178
-
 
850
key_Down   equ 177
-
 
851
key_Right  equ 179
-
 
852
key_Left   equ 176
-
 
853
key_Esc    equ 27
-
 
854
key_Space  equ 32
-
 
855
key_Enter  equ 13
-
 
856
key_Bspace equ 8
-
 
857
key_F1     equ 50
-
 
858
key_F2     equ 51
-
 
859
key_F3     equ 52
-
 
860
key_F4     equ 53
-
 
861
key_F5     equ 54
-
 
862
key_F6     equ 55
-
 
863
key_F7     equ 56
-
 
864
key_F8     equ 57
-
 
865
key_F9     equ 48
-
 
866
key_F10    equ 49
-
 
867
key_F11    equ 68
-
 
868
key_F12    equ 255
-
 
Line 869... Line 463...
869
key_Home   equ 180
463
key_ExSel     equ 116 ; 0x74
Line 870... Line 464...
870
key_End    equ 181
464
key_Clear     equ 118 ; 0x76
871
key_PgUp   equ 184
465
 
872
key_PgDown equ 183
466
 
873
 
467
 
874
;Attributes
468
;Attributes
Line 875... Line 469...
875
 
469
 
-
 
470
;Window Attributes
-
 
471
window_Skinned equ 0x04000000
-
 
472
window_Type2   equ 0x02000000
-
 
473
window_Type1   equ 0x00000000
-
 
474
window_Reserve equ 0x01000000
-
 
475
 
876
;Window Attributes
476
;Label Attributes
-
 
477
ends_by_zero     equ 10000000b shl 24
-
 
478
fill_background  equ 01000000b shl 24
-
 
479
cp866_small      equ 00000000b shl 24
-
 
480
cp866            equ 00010000b shl 24
-
 
481
utf16            equ 00100000b shl 24
-
 
482
utf8             equ 00110000b shl 24
-
 
483
font_size_x1     equ 00000000b shl 24
Line 877... Line 484...
877
window_Skinned equ 0x04000000
484
font_size_x2     equ 00000001b shl 24
878
window_Type2   equ 0x02000000
485
font_size_x3     equ 00000010b shl 24
879
window_Type1   equ 0x00000000
486
font_size_x4     equ 00000011b shl 24
880
window_Reserve equ 0x01000000
487
font_size_x5     equ 00000100b shl 24
881
 
488
font_size_x6     equ 00000101b shl 24
882
;Font Attributes
489
font_size_x7     equ 00000110b shl 24
-
 
490
font_size_x8     equ 00000111b shl 24
-
 
491
 
-
 
492
;Colors
883
font_Big  equ 0x10000000
493
cl_White  equ 0x00ffffff
884
 
494
cl_Black  equ 0x00000000
885
;Colors
495
cl_Grey   equ 0x00888888
886
cl_White  equ 0x00ffffff
496
cl_Red    equ 0x00ff0000
887
cl_Black  equ 0x00000000
497
cl_Lime   equ 0x0000ff00
-
 
498
cl_Blue   equ 0x000000ff
-
 
499
cl_Yellow equ 0x00ffff00
-
 
500
cl_Cyan   equ 0x0000ffff
-
 
501
cl_Green  equ 0x0000af00
-
 
502
cl_Blue   equ 0x000000ff
-
 
503
cl_Purple equ 0x008080ff
-
 
504
cl_Violet equ 0x008040ff
-
 
505
;cl_Cyan   equ 0x0040e0ff
-
 
506
 
-
 
507
macro wordstoreg reg,hiword,loword
-
 
508
{
-
 
509
if  hiword eqtype 0 & loword eqtype 0
-
 
510
    mov  reg,dword (hiword)*65536+(loword)
-
 
511
else if hiword eqtype 12 & loword eqtype eax
-
 
512
    mov  reg,dword (hiword)*65536
-
 
513
    add  reg,dword loword
-
 
514
else if hiword eqtype 12 & loword eqtype [123]
-
 
515
    mov  reg,dword (hiword)*65536
-
 
516
    add  reg,dword loword
-
 
517
else
-
 
518
    mov  reg,dword hiword
-
 
519
    shl  reg,16
-
 
520
    add  reg,dword loword
-
 
521
end if
-
 
522
}
-
 
523
 
-
 
524
macro dword2reg reg,doubleword
-
 
525
{
-
 
526
if doubleword eq
-
 
527
   ; not changes
-
 
528
else
-
 
529
   mov reg,dword doubleword
-
 
530
end if
-
 
531
}
-
 
532
 
-
 
533
macro words2reg reg,hiword,lowword
-
 
534
{
-
 
535
if hiword eq
-
 
536
   if lowword eq
-
 
537
      ; if operators empty nothing do
-
 
538
   else
-
 
539
      if lowword eqtype 12/4
-
 
540
         and reg,dword 0xffff0000
-
 
541
         add reg,dword lowword
-
 
542
      else
-
 
543
         and reg,dword 0xffff0000
-
 
544
         add reg,dword lowword
-
 
545
      end if
-
 
546
   end if
-
 
547
else
-
 
548
   if lowword eq
-
 
549
      if hiword eqtype 12/4
-
 
550
         and reg,dword 0x0000ffff
-
 
551
         add reg,dword hiword*65536
-
 
552
      else
-
 
553
         shl reg,16
-
 
554
         add reg,dword hiword
-
 
555
         ror reg,16
-
 
556
      end if
-
 
557
   else
-
 
558
      if lowword eqtype 12/4 & hiword eqtype 12/4
-
 
559
         if lowword = 0 & hiword = 0
-
 
560
            xor reg,reg
-
 
561
         else
-
 
562
            ; use brackets for calcualtion without error!!!
-
 
563
            mov reg,dword (hiword)*65536+(lowword)
-
 
564
         end if