Subversion Repositories Kolibri OS

Rev

Rev 539 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 539 Rev 9587
1
;
1
;
2
;   Assembler
2
;   Assembler
3
;     SMALL
3
;     SMALL
4
;       CODE
4
;       CODE
5
;         Libary
5
;         Libary
6
;
6
;
7
;  Ver 0.14 By Pavlushin Evgeni (RUSSIA)
7
;  Ver 0.14 By Pavlushin Evgeni (RUSSIA)
8
;  www.waptap@mail.ru
8
;  www.waptap@mail.ru
9
 
9
 
10
;Please compile aplications on FASM ver1.54 or higer!!!
10
;Please compile aplications on FASM ver1.54 or higer!!!
11
 
11
 
12
;InfoList
12
;InfoList
13
;0.01 scank,putpix,puttxt
13
;0.01 scank,putpix,puttxt
14
;0.02 label,random,colors
14
;0.02 label,random,colors
15
;0.03 window,startwd,endwd,attributes
15
;0.03 window,startwd,endwd,attributes
16
;0.04 close,delay,scevent ~30.04.2004
16
;0.04 close,delay,scevent ~30.04.2004
17
;0.05 small random, ~04.05.2004
17
;0.05 small random, ~04.05.2004
18
;0.06 wtevent ~09.05.2004
18
;0.06 wtevent ~09.05.2004
19
;0.07 timeevent ~23.05.2004
19
;0.07 timeevent ~23.05.2004
20
;0.08 txtput ~14.06.2004
20
;0.08 txtput ~14.06.2004
21
;0.09 opendialog,savedialog ~20.06.2004
21
;0.09 opendialog,savedialog ~20.06.2004
22
;0.10 wordstoreg by halyavin, add at ~30.08.2004
22
;0.10 wordstoreg by halyavin, add at ~30.08.2004
23
; random bug deleted eax is use.
23
; random bug deleted eax is use.
24
;0.11 loadfile from me +puttxt bug del ~07.09.2004
24
;0.11 loadfile from me +puttxt bug del ~07.09.2004
25
;0.12 open/save dialog ~13.09.2004
25
;0.12 open/save dialog ~13.09.2004
26
;0.13 dialogs bugs deleted
26
;0.13 dialogs bugs deleted
27
;0.14 drawlbut ~03.10.2004
27
;0.14 drawlbut ~03.10.2004
28
 
28
 
29
; LOADFILE
29
; LOADFILE
30
; (SYNTAX)  LOADFILE 'full_path_to_file',file_load_area,file_temp_area
30
; (SYNTAX)  LOADFILE 'full_path_to_file',file_load_area,file_temp_area
31
; (SAMPLE)  LOADFILE '/rd/1/clock.bmp',load_area,temp_area
31
; (SAMPLE)  LOADFILE '/sys/clock.bmp',load_area,temp_area
32
 
32
 
33
macro loadfile file_name,file_load_area,file_temp_area
33
macro loadfile file_name,file_load_area,file_temp_area
34
{
34
{
35
local open,fileinfo,string
35
local open,fileinfo,string
36
    jmp open
36
    jmp open
37
fileinfo:
37
fileinfo:
38
    dd 0
38
    dd 0
39
    dd 0
39
    dd 0
40
    dd 1
40
    dd 1
41
    dd file_load_area
41
    dd file_load_area
42
    dd file_temp_area
42
    dd file_temp_area
43
string:
43
string:
44
    db file_name,0
44
    db file_name,0
45
open:
45
open:
46
    mov  dword [fileinfo+8],1 ; how many blocks to read (1)
46
    mov  dword [fileinfo+8],1 ; how many blocks to read (1)
47
    mov  eax,58
47
    mov  eax,58
48
    mov  ebx,fileinfo
48
    mov  ebx,fileinfo
49
    mcall
49
    mcall
50
    mov  eax,[file_load_area+2]
50
    mov  eax,[file_load_area+2]
51
    shr  eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
51
    shr  eax,9 ; ¯®¤¥«¨¬ ­  512 ¨ ¯à¨¡ ¢¨¬ 1 - ¯®«ã稬 ç¨á«® ¡«®ª®¢
52
    inc  eax
52
    inc  eax
53
    mov  dword [fileinfo+8],eax
53
    mov  dword [fileinfo+8],eax
54
    mov  eax,58
54
    mov  eax,58
55
    mov  ebx,fileinfo
55
    mov  ebx,fileinfo
56
    mcall
56
    mcall
57
}
57
}
58
 
58
 
59
 
59
 
60
macro wordstoreg reg,hiword,loword
60
macro wordstoreg reg,hiword,loword
61
{
61
{
62
if  hiword eqtype 0 & loword eqtype 0
62
if  hiword eqtype 0 & loword eqtype 0
63
    mov  reg,hiword*65536+loword
63
    mov  reg,hiword*65536+loword
64
else if hiword eqtype 12 & loword eqtype eax
64
else if hiword eqtype 12 & loword eqtype eax
65
    mov  reg,hiword*65536
65
    mov  reg,hiword*65536
66
    add  reg,loword
66
    add  reg,loword
67
else if hiword eqtype 12 & loword eqtype [123]
67
else if hiword eqtype 12 & loword eqtype [123]
68
    mov  reg,hiword*65536
68
    mov  reg,hiword*65536
69
    add  reg,loword
69
    add  reg,loword
70
else
70
else
71
    mov  reg,hiword
71
    mov  reg,hiword
72
    shl  reg,16
72
    shl  reg,16
73
    add  reg,loword
73
    add  reg,loword
74
end if
74
end if
75
}
75
}
76
 
76
 
77
 
77
 
78
; DRAW BUTTON with label
78
; DRAW BUTTON with label
79
 
79
 
80
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
80
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
81
{
81
{
82
local asd,lab
82
local asd,lab
83
    jmp asd
83
    jmp asd
84
lab db  text                 ;arg label
84
lab db  text                 ;arg label
85
asd:
85
asd:
86
    wordstoreg ebx,x,xs
86
    wordstoreg ebx,x,xs
87
    wordstoreg ecx,y,ys
87
    wordstoreg ecx,y,ys
88
    mov edx,id
88
    mov edx,id
89
    mov esi,bcolor
89
    mov esi,bcolor
90
    mov eax,8
90
    mov eax,8
91
    mcall
91
    mcall
92
 
92
 
93
    mov eax,asd-lab          ;calc size
93
    mov eax,asd-lab          ;calc size
94
    mov ebx,6
94
    mov ebx,6
95
    mul ebx
95
    mul ebx
96
    mov esi,eax
96
    mov esi,eax
97
 
97
 
98
    mov eax,xs
98
    mov eax,xs
99
    sub eax,esi
99
    sub eax,esi
100
    shr eax,1
100
    shr eax,1
101
    add eax,x
101
    add eax,x
102
 
102
 
103
    mov edx,ys
103
    mov edx,ys
104
    sub edx,7
104
    sub edx,7
105
    shr edx,1
105
    shr edx,1
106
    add edx,y
106
    add edx,y
107
 
107
 
108
    mov ebx,eax
108
    mov ebx,eax
109
    shl ebx,16
109
    shl ebx,16
110
    add ebx,edx
110
    add ebx,edx
111
 
111
 
112
    mov ecx,tcolor             ;arg4 color
112
    mov ecx,tcolor             ;arg4 color
113
    mov edx,lab
113
    mov edx,lab
114
    mov esi,asd-lab          ;calc size
114
    mov esi,asd-lab          ;calc size
115
    mov eax,4
115
    mov eax,4
116
    mcall
116
    mcall
117
}
117
}
118
 
118
 
119
 
119
 
120
macro opendialog redproc,openoff,erroff,path
120
macro opendialog redproc,openoff,erroff,path
121
{
121
{
122
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
122
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
123
local run_fileinfo, param
123
local run_fileinfo, param
124
local getmesloop, loox, mred, mkey, mbutton, mgetmes
124
local getmesloop, loox, mred, mkey, mbutton, mgetmes
125
local dlg_is_work, ready, procinfo
125
local dlg_is_work, ready, procinfo
126
;
126
;
127
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
127
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
128
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
128
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
129
;
129
;
130
 
130
 
131
    cld
131
    cld
132
;;    mov esi,path
132
;;    mov esi,path
133
    mov edi,path
133
    mov edi,path
134
    mov eax,0
134
    mov eax,0
135
    mov ecx,200
135
    mov ecx,200
136
    rep stosb
136
    rep stosb
137
 
137
 
138
;mov [get_loops],0
138
;mov [get_loops],0
139
mov [dlg_pid_get],0
139
mov [dlg_pid_get],0
140
 
140
 
141
; Get my PID in dec format 4 bytes
141
; Get my PID in dec format 4 bytes
142
    mov eax,9
142
    mov eax,9
143
    mov ebx,procinfo
143
    mov ebx,procinfo
144
    mov ecx,-1
144
    mov ecx,-1
145
    mcall
145
    mcall
146
 
146
 
147
; convert eax bin to param dec
147
; convert eax bin to param dec
148
    mov eax,dword [procinfo+30]  ;offset of myPID
148
    mov eax,dword [procinfo+30]  ;offset of myPID
149
    mov edi,param+4-1            ;offset to 4 bytes
149
    mov edi,param+4-1            ;offset to 4 bytes
150
    mov ecx,4
150
    mov ecx,4
151
    mov ebx,10
151
    mov ebx,10
152
    cld
152
    cld
153
new_d:
153
new_d:
154
    xor edx,edx
154
    xor edx,edx
155
    div ebx
155
    div ebx
156
    add dl,'0'
156
    add dl,'0'
157
    mov [edi],dl
157
    mov [edi],dl
158
    dec edi
158
    dec edi
159
    loop new_d
159
    loop new_d
160
 
160
 
161
; wirite 1 byte space to param
161
; wirite 1 byte space to param
162
    mov [param+4],byte 32    ;Space for next parametr
162
    mov [param+4],byte 32    ;Space for next parametr
163
; and 1 byte type of dialog to param
163
; and 1 byte type of dialog to param
164
    mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
164
    mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
165
 
165
 
166
;
166
;
167
; STEP2 prepare IPC area for get messages
167
; STEP2 prepare IPC area for get messages
168
;
168
;
169
 
169
 
170
; prepare IPC area
170
; prepare IPC area
171
    mov [path],dword 0
171
    mov [path],dword 0
172
    mov [path+4],dword 8
172
    mov [path+4],dword 8
173
 
173
 
174
; define IPC memory
174
; define IPC memory
175
    mov eax,60
175
    mov eax,60
176
    mov ebx,1        ; define IPC
176
    mov ebx,1        ; define IPC
177
    mov ecx,path     ; offset of area
177
    mov ecx,path     ; offset of area
178
    mov edx,150      ; size 150 bytes
178
    mov edx,150      ; size 150 bytes
179
    mcall
179
    mcall
180
 
180
 
181
; change wanted events list 7-bit IPC event
181
; change wanted events list 7-bit IPC event
182
    mov eax,40
182
    mov eax,40
183
    mov ebx,01000111b
183
    mov ebx,01000111b
184
    mcall
184
    mcall
185
 
185
 
186
;
186
;
187
; STEP 3 run SYSTEM XTREE with parameters
187
; STEP 3 run SYSTEM XTREE with parameters
188
;
188
;
189
 
189
 
190
    mov eax,58
190
    mov eax,58
191
    mov ebx,run_fileinfo
191
    mov ebx,run_fileinfo
192
    mcall
192
    mcall
193
 
193
 
194
    call redproc
194
    call redproc
195
 
195
 
196
    mov [get_loops],0
196
    mov [get_loops],0
197
getmesloop:
197
getmesloop:
198
    mov eax,23
198
    mov eax,23
199
    mov ebx,50     ;0.5 sec
199
    mov ebx,50     ;0.5 sec
200
    mcall
200
    mcall
201
 
201
 
202
    cmp eax,1
202
    cmp eax,1
203
    je  mred
203
    je  mred
204
    cmp eax,2
204
    cmp eax,2
205
    je  mkey
205
    je  mkey
206
    cmp eax,3
206
    cmp eax,3
207
    je  mbutton
207
    je  mbutton
208
    cmp eax,7
208
    cmp eax,7
209
    je  mgetmes
209
    je  mgetmes
210
 
210
 
211
; Get number of procces
211
; Get number of procces
212
    mov ebx,procinfo
212
    mov ebx,procinfo
213
    mov ecx,-1
213
    mov ecx,-1
214
    mov eax,9
214
    mov eax,9
215
    mcall
215
    mcall
216
    mov ebp,eax
216
    mov ebp,eax
217
 
217
 
218
loox:
218
loox:
219
    mov eax,9
219
    mov eax,9
220
    mov ebx,procinfo
220
    mov ebx,procinfo
221
    mov ecx,ebp
221
    mov ecx,ebp
222
    mcall
222
    mcall
223
    mov eax,[DLGPID]
223
    mov eax,[DLGPID]
224
    cmp [procinfo+30],eax    ;IF Dialog find
224
    cmp [procinfo+30],eax    ;IF Dialog find
225
    je  dlg_is_work          ;jmp to dlg_is_work
225
    je  dlg_is_work          ;jmp to dlg_is_work
226
    dec ebp
226
    dec ebp
227
    jnz loox
227
    jnz loox
228
 
228
 
229
    jmp erroff
229
    jmp erroff
230
 
230
 
231
dlg_is_work:
231
dlg_is_work:
232
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
232
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
233
    je  erroff                 ;TESTODP2 terminated too
233
    je  erroff                 ;TESTODP2 terminated too
234
 
234
 
235
    cmp [dlg_pid_get],dword 1
235
    cmp [dlg_pid_get],dword 1
236
    je  getmesloop
236
    je  getmesloop
237
    inc [get_loops]
237
    inc [get_loops]
238
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
238
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
239
    jae erroff
239
    jae erroff
240
    jmp getmesloop
240
    jmp getmesloop
241
 
241
 
242
mred:
242
mred:
243
    call redproc
243
    call redproc
244
    jmp  getmesloop
244
    jmp  getmesloop
245
mkey:
245
mkey:
246
    mov  eax,2
246
    mov  eax,2
247
    mcall                   ; read (eax=2)
247
    mcall                   ; read (eax=2)
248
    jmp  getmesloop
248
    jmp  getmesloop
249
mbutton:
249
mbutton:
250
    mov  eax,17                 ; get id
250
    mov  eax,17                 ; get id
251
    mcall
251
    mcall
252
    cmp  ah,1                   ; button id=1 ?
252
    cmp  ah,1                   ; button id=1 ?
253
    jne  getmesloop
253
    jne  getmesloop
254
    mov  eax,-1                 ; close this program
254
    mov  eax,-1                 ; close this program
255
    mcall
255
    mcall
256
mgetmes:
256
mgetmes:
257
 
257
 
258
; If dlg_pid_get then second message get jmp to still
258
; If dlg_pid_get then second message get jmp to still
259
    cmp  [dlg_pid_get],dword 1
259
    cmp  [dlg_pid_get],dword 1
260
    je   ready
260
    je   ready
261
 
261
 
262
; First message is number of PID SYSXTREE dialog
262
; First message is number of PID SYSXTREE dialog
263
 
263
 
264
; convert PID dec to PID bin
264
; convert PID dec to PID bin
265
    movzx eax,byte [path+16]
265
    movzx eax,byte [path+16]
266
    sub eax,48
266
    sub eax,48
267
    imul eax,10
267
    imul eax,10
268
    movzx ebx,byte [path+16+1]
268
    movzx ebx,byte [path+16+1]
269
    add eax,ebx
269
    add eax,ebx
270
    sub eax,48
270
    sub eax,48
271
    imul eax,10
271
    imul eax,10
272
    movzx ebx,byte [path+16+2]
272
    movzx ebx,byte [path+16+2]
273
    add eax,ebx
273
    add eax,ebx
274
    sub eax,48
274
    sub eax,48
275
    imul eax,10
275
    imul eax,10
276
    movzx ebx,byte [path+16+3]
276
    movzx ebx,byte [path+16+3]
277
    add eax,ebx
277
    add eax,ebx
278
    sub eax,48
278
    sub eax,48
279
    mov [DLGPID],eax
279
    mov [DLGPID],eax
280
 
280
 
281
; Claear and prepare IPC area for next message
281
; Claear and prepare IPC area for next message
282
    mov [path],dword 0
282
    mov [path],dword 0
283
    mov [path+4],dword 8
283
    mov [path+4],dword 8
284
    mov [path+8],dword 0
284
    mov [path+8],dword 0
285
    mov [path+12],dword 0
285
    mov [path+12],dword 0
286
    mov [path+16],dword 0
286
    mov [path+16],dword 0
287
 
287
 
288
; Set dlg_pid_get for get next message
288
; Set dlg_pid_get for get next message
289
    mov [dlg_pid_get],dword 1
289
    mov [dlg_pid_get],dword 1
290
    call redproc   ;show DLG_PID
290
    call redproc   ;show DLG_PID
291
    jmp  getmesloop
291
    jmp  getmesloop
292
 
292
 
293
ready:
293
ready:
294
;
294
;
295
; The second message get
295
; The second message get
296
; Second message is 100 bytes path to SAVE/OPEN file
296
; Second message is 100 bytes path to SAVE/OPEN file
297
; shl path string on 16 bytes
297
; shl path string on 16 bytes
298
;
298
;
299
    cld
299
    cld
300
    mov esi,path+16
300
    mov esi,path+16
301
    mov edi,path
301
    mov edi,path
302
    mov ecx,200
302
    mov ecx,200
303
    rep movsb
303
    rep movsb
304
    mov [edi],byte 0
304
    mov [edi],byte 0
305
 
305
 
306
    jmp openoff
306
    jmp openoff
307
 
307
 
308
 
308
 
309
; DATA AREA
309
; DATA AREA
310
get_loops   dd 0
310
get_loops   dd 0
311
dlg_pid_get dd 0
311
dlg_pid_get dd 0
312
DLGPID      dd 0
312
DLGPID      dd 0
313
 
313
 
314
param:
314
param:
315
   dd 0    ; My dec PID
315
   dd 0    ; My dec PID
316
   dd 0,0  ; Type of dialog
316
   dd 0,0  ; Type of dialog
317
 
317
 
318
run_fileinfo:
318
run_fileinfo:
319
 dd 16
319
 dd 16
320
 dd 0
320
 dd 0
321
 dd param
321
 dd param
322
 dd 0
322
 dd 0
323
 dd procinfo ; 0x10000
323
 dd procinfo ; 0x10000
324
;run_filepath
324
;run_filepath
325
 db '/sys/SYSXTREE',0
325
 db '/sys/SYSXTREE',0
326
 
326
 
327
procinfo:
327
procinfo:
328
times 256 db 0
328
times 256 db 0
329
}
329
}
330
 
330
 
331
 
331
 
332
macro savedialog redproc,openoff,erroff,path
332
macro savedialog redproc,openoff,erroff,path
333
{
333
{
334
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
334
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
335
local run_fileinfo, run_filepath, param
335
local run_fileinfo, run_filepath, param
336
local getmesloop, loox, mred, mkey, mbutton, mgetmes
336
local getmesloop, loox, mred, mkey, mbutton, mgetmes
337
local dlg_is_work, ready, procinfo
337
local dlg_is_work, ready, procinfo
338
;
338
;
339
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
339
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
340
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
340
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
341
;
341
;
342
 
342
 
343
    cld
343
    cld
344
;;    mov esi,path
344
;;    mov esi,path
345
    mov edi,path
345
    mov edi,path
346
    mov eax,0
346
    mov eax,0
347
    mov ecx,200
347
    mov ecx,200
348
    rep stosb
348
    rep stosb
349
 
349
 
350
;mov [get_loops],0
350
;mov [get_loops],0
351
mov [dlg_pid_get],0
351
mov [dlg_pid_get],0
352
 
352
 
353
; Get my PID in dec format 4 bytes
353
; Get my PID in dec format 4 bytes
354
    mov eax,9
354
    mov eax,9
355
    mov ebx,procinfo
355
    mov ebx,procinfo
356
    mov ecx,-1
356
    mov ecx,-1
357
    mcall
357
    mcall
358
 
358
 
359
; convert eax bin to param dec
359
; convert eax bin to param dec
360
    mov eax,dword [procinfo+30]  ;offset of myPID
360
    mov eax,dword [procinfo+30]  ;offset of myPID
361
    mov edi,param+4-1            ;offset to 4 bytes
361
    mov edi,param+4-1            ;offset to 4 bytes
362
    mov ecx,4
362
    mov ecx,4
363
    mov ebx,10
363
    mov ebx,10
364
    cld
364
    cld
365
new_d:
365
new_d:
366
    xor edx,edx
366
    xor edx,edx
367
    div ebx
367
    div ebx
368
    add dl,'0'
368
    add dl,'0'
369
    mov [edi],dl
369
    mov [edi],dl
370
    dec edi
370
    dec edi
371
    loop new_d
371
    loop new_d
372
 
372
 
373
; wirite 1 byte space to param
373
; wirite 1 byte space to param
374
    mov [param+4],byte 32    ;Space for next parametr
374
    mov [param+4],byte 32    ;Space for next parametr
375
; and 1 byte type of dialog to param
375
; and 1 byte type of dialog to param
376
    mov [param+5],byte 'S'   ;Get Open dialog (Use 'S' for Save dialog)
376
    mov [param+5],byte 'S'   ;Get Open dialog (Use 'S' for Save dialog)
377
 
377
 
378
;
378
;
379
; STEP2 prepare IPC area for get messages
379
; STEP2 prepare IPC area for get messages
380
;
380
;
381
 
381
 
382
; prepare IPC area
382
; prepare IPC area
383
    mov [path],dword 0
383
    mov [path],dword 0
384
    mov [path+4],dword 8
384
    mov [path+4],dword 8
385
 
385
 
386
; define IPC memory
386
; define IPC memory
387
    mov eax,60
387
    mov eax,60
388
    mov ebx,1        ; define IPC
388
    mov ebx,1        ; define IPC
389
    mov ecx,path ; offset of area
389
    mov ecx,path ; offset of area
390
    mov edx,120      ; size 150 bytes
390
    mov edx,120      ; size 150 bytes
391
    mcall
391
    mcall
392
 
392
 
393
; change wanted events list 7-bit IPC event
393
; change wanted events list 7-bit IPC event
394
    mov eax,40
394
    mov eax,40
395
    mov ebx,01000111b
395
    mov ebx,01000111b
396
    mcall
396
    mcall
397
 
397
 
398
;
398
;
399
; STEP 3 run SYSTEM XTREE with parameters
399
; STEP 3 run SYSTEM XTREE with parameters
400
;
400
;
401
 
401
 
402
    mov eax,58
402
    mov eax,58
403
    mov ebx,run_fileinfo
403
    mov ebx,run_fileinfo
404
    mcall
404
    mcall
405
 
405
 
406
    call redproc
406
    call redproc
407
 
407
 
408
    mov [get_loops],0
408
    mov [get_loops],0
409
getmesloop:
409
getmesloop:
410
    mov eax,23
410
    mov eax,23
411
    mov ebx,50     ;0.5 sec
411
    mov ebx,50     ;0.5 sec
412
    mcall
412
    mcall
413
 
413
 
414
    cmp eax,1
414
    cmp eax,1
415
    je  mred
415
    je  mred
416
    cmp eax,2
416
    cmp eax,2
417
    je  mkey
417
    je  mkey
418
    cmp eax,3
418
    cmp eax,3
419
    je  mbutton
419
    je  mbutton
420
    cmp eax,7
420
    cmp eax,7
421
    je  mgetmes
421
    je  mgetmes
422
 
422
 
423
; Get number of procces
423
; Get number of procces
424
    mov ebx,procinfo
424
    mov ebx,procinfo
425
    mov ecx,-1
425
    mov ecx,-1
426
    mov eax,9
426
    mov eax,9
427
    mcall
427
    mcall
428
    mov ebp,eax
428
    mov ebp,eax
429
 
429
 
430
loox:
430
loox:
431
    mov eax,9
431
    mov eax,9
432
    mov ebx,procinfo
432
    mov ebx,procinfo
433
    mov ecx,ebp
433
    mov ecx,ebp
434
    mcall
434
    mcall
435
    mov eax,[DLGPID]
435
    mov eax,[DLGPID]
436
    cmp [procinfo+30],eax    ;IF Dialog find
436
    cmp [procinfo+30],eax    ;IF Dialog find
437
    je  dlg_is_work          ;jmp to dlg_is_work
437
    je  dlg_is_work          ;jmp to dlg_is_work
438
    dec ebp
438
    dec ebp
439
    jnz loox
439
    jnz loox
440
 
440
 
441
    jmp erroff
441
    jmp erroff
442
 
442
 
443
dlg_is_work:
443
dlg_is_work:
444
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
444
    cmp [procinfo+50],word 9 ;If slot state 9 - dialog is terminated
445
    je  erroff                 ;TESTODP2 terminated too
445
    je  erroff                 ;TESTODP2 terminated too
446
 
446
 
447
    cmp [dlg_pid_get],dword 1
447
    cmp [dlg_pid_get],dword 1
448
    je  getmesloop
448
    je  getmesloop
449
    inc [get_loops]
449
    inc [get_loops]
450
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
450
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
451
    jae erroff
451
    jae erroff
452
    jmp getmesloop
452
    jmp getmesloop
453
 
453
 
454
mred:
454
mred:
455
    call redproc
455
    call redproc
456
    jmp  getmesloop
456
    jmp  getmesloop
457
mkey:
457
mkey:
458
    mcall                   ; read (eax=2)
458
    mcall                   ; read (eax=2)
459
    jmp  getmesloop
459
    jmp  getmesloop
460
mbutton:
460
mbutton:
461
    mov  eax,17                 ; get id
461
    mov  eax,17                 ; get id
462
    mcall
462
    mcall
463
    cmp  ah,1                   ; button id=1 ?
463
    cmp  ah,1                   ; button id=1 ?
464
    jne  getmesloop
464
    jne  getmesloop
465
    mov  eax,-1                 ; close this program
465
    mov  eax,-1                 ; close this program
466
    mcall
466
    mcall
467
mgetmes:
467
mgetmes:
468
 
468
 
469
; If dlg_pid_get then second message get jmp to still
469
; If dlg_pid_get then second message get jmp to still
470
    cmp  [dlg_pid_get],dword 1
470
    cmp  [dlg_pid_get],dword 1
471
    je   ready
471
    je   ready
472
 
472
 
473
; First message is number of PID SYSXTREE dialog
473
; First message is number of PID SYSXTREE dialog
474
 
474
 
475
; convert PID dec to PID bin
475
; convert PID dec to PID bin
476
    movzx eax,byte [path+16]
476
    movzx eax,byte [path+16]
477
    sub eax,48
477
    sub eax,48
478
    imul eax,10
478
    imul eax,10
479
    movzx ebx,byte [path+16+1]
479
    movzx ebx,byte [path+16+1]
480
    add eax,ebx
480
    add eax,ebx
481
    sub eax,48
481
    sub eax,48
482
    imul eax,10
482
    imul eax,10
483
    movzx ebx,byte [path+16+2]
483
    movzx ebx,byte [path+16+2]
484
    add eax,ebx
484
    add eax,ebx
485
    sub eax,48
485
    sub eax,48
486
    imul eax,10
486
    imul eax,10
487
    movzx ebx,byte [path+16+3]
487
    movzx ebx,byte [path+16+3]
488
    add eax,ebx
488
    add eax,ebx
489
    sub eax,48
489
    sub eax,48
490
    mov [DLGPID],eax
490
    mov [DLGPID],eax
491
 
491
 
492
; Claear and prepare IPC area for next message
492
; Claear and prepare IPC area for next message
493
    mov [path],dword 0
493
    mov [path],dword 0
494
    mov [path+4],dword 8
494
    mov [path+4],dword 8
495
    mov [path+8],dword 0
495
    mov [path+8],dword 0
496
    mov [path+12],dword 0
496
    mov [path+12],dword 0
497
    mov [path+16],dword 0
497
    mov [path+16],dword 0
498
 
498
 
499
; Set dlg_pid_get for get next message
499
; Set dlg_pid_get for get next message
500
    mov [dlg_pid_get],dword 1
500
    mov [dlg_pid_get],dword 1
501
    call redproc   ;show DLG_PID
501
    call redproc   ;show DLG_PID
502
    jmp  getmesloop
502
    jmp  getmesloop
503
 
503
 
504
ready:
504
ready:
505
;
505
;
506
; The second message get
506
; The second message get
507
; Second message is 100 bytes path to SAVE/OPEN file
507
; Second message is 100 bytes path to SAVE/OPEN file
508
; shl path string on 16 bytes
508
; shl path string on 16 bytes
509
;
509
;
510
    cld
510
    cld
511
    mov esi,path+16
511
    mov esi,path+16
512
    mov edi,path
512
    mov edi,path
513
    mov ecx,200
513
    mov ecx,200
514
    rep movsb
514
    rep movsb
515
    mov [edi],byte 0
515
    mov [edi],byte 0
516
 
516
 
517
    jmp openoff
517
    jmp openoff
518
 
518
 
519
 
519
 
520
; DATA AREA
520
; DATA AREA
521
get_loops   dd 0
521
get_loops   dd 0
522
dlg_pid_get dd 0
522
dlg_pid_get dd 0
523
DLGPID      dd 0
523
DLGPID      dd 0
524
 
524
 
525
param:
525
param:
526
   rb 4  ; My dec PID
526
   rb 4  ; My dec PID
527
   rb 6  ; Type of dialog
527
   rb 6  ; Type of dialog
528
 
528
 
529
run_fileinfo:
529
run_fileinfo:
530
 dd 16
530
 dd 16
531
 dd 0
531
 dd 0
532
 dd param
532
 dd param
533
 dd 0
533
 dd 0
534
 dd procinfo
534
 dd procinfo
535
run_filepath:
535
run_filepath:
536
 db '/sys/SYSXTREE',0
536
 db '/sys/SYSXTREE',0
537
 
537
 
538
procinfo:
538
procinfo:
539
times 256 db 0
539
times 256 db 0
540
}
540
}
541
 
541
 
542
 
542
 
543
 
543
 
544
 
544
 
545
; RANDOM - generate random count (small)
545
; RANDOM - generate random count (small)
546
; (SYNTAX)  RANDOM MaxCount,OutArgument
546
; (SYNTAX)  RANDOM MaxCount,OutArgument
547
; (SAMPLE)  RANDOM 10000,eax
547
; (SAMPLE)  RANDOM 10000,eax
548
; ( NOTE )  Maxint<65536 ; use random 65536,eax for more combinations
548
; ( NOTE )  Maxint<65536 ; use random 65536,eax for more combinations
549
 
549
 
550
randomuse = 0
550
randomuse = 0
551
 
551
 
552
macro random arg1,arg2
552
macro random arg1,arg2
553
{
553
{
554
local rxproc
554
local rxproc
555
randomuse = randomuse + 1
555
randomuse = randomuse + 1
556
 
556
 
557
      jmp rxproc
557
      jmp rxproc
558
 
558
 
559
if defined randomuse & randomuse = 1
559
if defined randomuse & randomuse = 1
560
randomproc:
560
randomproc:
561
      jmp rnj
561
      jmp rnj
562
rsx1 dw 0x4321
562
rsx1 dw 0x4321
563
rsx2 dw 0x1234
563
rsx2 dw 0x1234
564
rnj:
564
rnj:
565
;    mov eax,arg1
565
;    mov eax,arg1
566
    push bx
566
    push bx
567
    push cx
567
    push cx
568
    push dx
568
    push dx
569
    push si
569
    push si
570
    push di
570
    push di
571
    mov cx,ax
571
    mov cx,ax
572
    mov ax,word ptr rsx1
572
    mov ax,word ptr rsx1
573
    mov bx,word ptr rsx2
573
    mov bx,word ptr rsx2
574
    mov si,ax
574
    mov si,ax
575
    mov di,bx
575
    mov di,bx
576
    mov dl,ah
576
    mov dl,ah
577
    mov ah,al
577
    mov ah,al
578
    mov al,bh
578
    mov al,bh
579
    mov bh,bl
579
    mov bh,bl
580
    xor bl,bl
580
    xor bl,bl
581
    rcr dl,1
581
    rcr dl,1
582
    rcr ax,1
582
    rcr ax,1
583
    rcr bx,1
583
    rcr bx,1
584
    add bx,di
584
    add bx,di
585
    adc ax,si
585
    adc ax,si
586
    add bx,0x62e9
586
    add bx,0x62e9
587
    adc ax,0x3619
587
    adc ax,0x3619
588
    mov word ptr rsx1,bx
588
    mov word ptr rsx1,bx
589
    mov word ptr rsx2,ax
589
    mov word ptr rsx2,ax
590
    xor dx,dx
590
    xor dx,dx
591
    cmp ax,0
591
    cmp ax,0
592
    je nodiv
592
    je nodiv
593
    cmp cx,0
593
    cmp cx,0
594
    je nodiv
594
    je nodiv
595
    div cx
595
    div cx
596
nodiv:
596
nodiv:
597
    mov ax,dx
597
    mov ax,dx
598
    pop di
598
    pop di
599
    pop si
599
    pop si
600
    pop dx
600
    pop dx
601
    pop cx
601
    pop cx
602
    pop bx
602
    pop bx
603
    and eax,0000ffffh
603
    and eax,0000ffffh
604
;    mov arg2,0
604
;    mov arg2,0
605
;    mov arg2,eax
605
;    mov arg2,eax
606
    ret
606
    ret
607
end if
607
end if
608
 
608
 
609
rxproc:
609
rxproc:
610
    mov eax,arg1
610
    mov eax,arg1
611
    call randomproc
611
    call randomproc
612
    mov arg2,eax
612
    mov arg2,eax
613
}
613
}
614
 
614
 
615
macro scank
615
macro scank
616
{
616
{
617
    mov eax,10
617
    mov eax,10
618
    mcall
618
    mcall
619
}
619
}
620
 
620
 
621
macro putpix x,y,color
621
macro putpix x,y,color
622
{
622
{
623
    mov ebx,x
623
    mov ebx,x
624
    mov ecx,y
624
    mov ecx,y
625
    mov edx,color
625
    mov edx,color
626
    mov eax,1
626
    mov eax,1
627
    mcall
627
    mcall
628
}
628
}
629
 
629
 
630
macro puttxt x,y,offs,size,color
630
macro puttxt x,y,offs,size,color
631
{
631
{
632
;    mov ebx,x
632
;    mov ebx,x
633
;    shl ebx,16
633
;    shl ebx,16
634
;    add ebx,y
634
;    add ebx,y
635
    wordstoreg ebx,x,y
635
    wordstoreg ebx,x,y
636
    mov ecx,color
636
    mov ecx,color
637
    mov edx,offs
637
    mov edx,offs
638
    mov esi,size
638
    mov esi,size
639
    mov eax,4
639
    mov eax,4
640
    mcall
640
    mcall
641
}
641
}
642
 
642
 
643
macro outcount data, x, y, color, numtype
643
macro outcount data, x, y, color, numtype
644
{
644
{
645
    mov ecx,data
645
    mov ecx,data
646
    mov ebx,numtype
646
    mov ebx,numtype
647
    mov bl,0
647
    mov bl,0
648
;    mov edx,x*65536+y
648
;    mov edx,x*65536+y
649
    wordstoreg edx,x,y
649
    wordstoreg edx,x,y
650
    mov esi,color
650
    mov esi,color
651
    mov eax,47
651
    mov eax,47
652
    mcall
652
    mcall
653
}
653
}
654
 
654
 
655
; SCEVENT - Scan event
655
; SCEVENT - Scan event
656
 
656
 
657
macro scevent red,key,but
657
macro scevent red,key,but
658
{
658
{
659
    mov eax,11
659
    mov eax,11
660
    mcall
660
    mcall
661
    dec eax
661
    dec eax
662
    jz  red
662
    jz  red
663
    dec eax
663
    dec eax
664
    jz  key
664
    jz  key
665
    dec eax
665
    dec eax
666
    jz  but
666
    jz  but
667
}
667
}
668
 
668
 
669
; WTEVENT - Wait event
669
; WTEVENT - Wait event
670
 
670
 
671
macro wtevent red,key,but
671
macro wtevent red,key,but
672
{
672
{
673
    mov eax,10
673
    mov eax,10
674
    mcall
674
    mcall
675
    dec eax
675
    dec eax
676
    jz  red
676
    jz  red
677
    dec eax
677
    dec eax
678
    jz  key
678
    jz  key
679
    dec eax
679
    dec eax
680
    jz  but
680
    jz  but
681
}
681
}
682
 
682
 
683
; TIMEEVENT - Wite for event with timeout
683
; TIMEEVENT - Wite for event with timeout
684
 
684
 
685
macro timeevent xfps,noevent,red,key,but
685
macro timeevent xfps,noevent,red,key,but
686
{
686
{
687
    mov eax,23
687
    mov eax,23
688
    mov ebx,xfps
688
    mov ebx,xfps
689
    mcall
689
    mcall
690
    cmp eax,0
690
    cmp eax,0
691
    je  noevent
691
    je  noevent
692
    dec eax
692
    dec eax
693
    jz  red
693
    jz  red
694
    dec eax
694
    dec eax
695
    jz  key
695
    jz  key
696
    dec eax
696
    dec eax
697
    jz  but
697
    jz  but
698
}
698
}
699
 
699
 
700
 
700
 
701
; CLOSE - Close program
701
; CLOSE - Close program
702
 
702
 
703
macro close
703
macro close
704
{
704
{
705
    mov eax,-1
705
    mov eax,-1
706
    mcall
706
    mcall
707
}
707
}
708
 
708
 
709
; DELAY - Create delay 1/100 sec
709
; DELAY - Create delay 1/100 sec
710
; (SYNTAX)  Delay time
710
; (SYNTAX)  Delay time
711
; (SAMPLE)  Delay 100   ;delay 2 sec 1/100*200=2 sec
711
; (SAMPLE)  Delay 100   ;delay 2 sec 1/100*200=2 sec
712
 
712
 
713
macro delay arg1
713
macro delay arg1
714
{
714
{
715
    mov eax,5
715
    mov eax,5
716
    mov ebx,arg1
716
    mov ebx,arg1
717
    mcall
717
    mcall
718
}
718
}
719
 
719
 
720
; WINDOW - Draw window
720
; WINDOW - Draw window
721
; (SYNTAX)  WINDOW Xstart,Ystart,'Text',Color
721
; (SYNTAX)  WINDOW Xstart,Ystart,'Text',Color
722
; (SAMPLE)  WINDOW 10,10,640+8,480+24,window_Skinned
722
; (SAMPLE)  WINDOW 10,10,640+8,480+24,window_Skinned
723
 
723
 
724
macro window arg1,arg2,arg3,arg4,arg5
724
macro window arg1,arg2,arg3,arg4,arg5
725
{
725
{
726
;    mov ebx,arg1*65536+arg3
726
;    mov ebx,arg1*65536+arg3
727
;    mov ecx,arg2*65536+arg4
727
;    mov ecx,arg2*65536+arg4
728
    wordstoreg ebx,arg1,arg3
728
    wordstoreg ebx,arg1,arg3
729
    wordstoreg ecx,arg2,arg4
729
    wordstoreg ecx,arg2,arg4
730
    mov edx,arg5
730
    mov edx,arg5
731
    mov eax,0
731
    mov eax,0
732
    mcall
732
    mcall
733
}
733
}
734
 
734
 
735
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
735
macro colorwindow arg1,arg2,arg3,arg4,arg5,arg6,arg7
736
{
736
{
737
    mov ebx,arg1*65536+arg3
737
    mov ebx,arg1*65536+arg3
738
    mov ecx,arg2*65536+arg4
738
    mov ecx,arg2*65536+arg4
739
    mov edx,arg5
739
    mov edx,arg5
740
    mov esi,arg6
740
    mov esi,arg6
741
    mov edi,arg7
741
    mov edi,arg7
742
    mov eax,0
742
    mov eax,0
743
    mcall
743
    mcall
744
}
744
}
745
 
745
 
746
 
746
 
747
; STARTWD - Start of window draw
747
; STARTWD - Start of window draw
748
 
748
 
749
macro startwd
749
macro startwd
750
{
750
{
751
    mov eax,12
751
    mov eax,12
752
    mov ebx,1
752
    mov ebx,1
753
    mcall
753
    mcall
754
}
754
}
755
 
755
 
756
; ENDWD - End window draw
756
; ENDWD - End window draw
757
 
757
 
758
macro endwd
758
macro endwd
759
{
759
{
760
    mov eax,12
760
    mov eax,12
761
    mov ebx,2
761
    mov ebx,2
762
    mcall
762
    mcall
763
}
763
}
764
 
764
 
765
; LABEL - Put text to frame
765
; LABEL - Put text to frame
766
; (SYNTAX)  LABEL Xstart,Ystart,'Text',Color
766
; (SYNTAX)  LABEL Xstart,Ystart,'Text',Color
767
; (SAMPLE)  LABEL 10,12,'Hello World!',cl_Green+font_Big
767
; (SAMPLE)  LABEL 10,12,'Hello World!',cl_Green+font_Big
768
 
768
 
769
macro label arg1,arg2,arg3,arg4
769
macro label arg1,arg2,arg3,arg4
770
{
770
{
771
local asd,lab
771
local asd,lab
772
    jmp asd
772
    jmp asd
773
lab db  arg3                 ;arg label
773
lab db  arg3                 ;arg label
774
asd:
774
asd:
775
;    mov ebx,arg1             ;arg1=y arg2=x
775
;    mov ebx,arg1             ;arg1=y arg2=x
776
;    shl ebx,16
776
;    shl ebx,16
777
;    add ebx,arg2
777
;    add ebx,arg2
778
    wordstoreg ebx,arg1,arg2
778
    wordstoreg ebx,arg1,arg2
779
    mov ecx,arg4             ;arg4 color
779
    mov ecx,arg4             ;arg4 color
780
    mov edx,lab
780
    mov edx,lab
781
    mov esi,asd-lab          ;calc size
781
    mov esi,asd-lab          ;calc size
782
    mov eax,4
782
    mov eax,4
783
    mcall
783
    mcall
784
}
784
}
785
 
785
 
786
;Key's
786
;Key's
787
key_Up     equ 178
787
key_Up     equ 178
788
key_Down   equ 177
788
key_Down   equ 177
789
key_Right  equ 179
789
key_Right  equ 179
790
key_Left   equ 176
790
key_Left   equ 176
791
key_Esc    equ 27
791
key_Esc    equ 27
792
key_Space  equ 32
792
key_Space  equ 32
793
key_Enter  equ 13
793
key_Enter  equ 13
794
key_Bspace equ 8
794
key_Bspace equ 8
795
key_F1     equ 50
795
key_F1     equ 50
796
key_F2     equ 51
796
key_F2     equ 51
797
key_F3     equ 52
797
key_F3     equ 52
798
key_F4     equ 53
798
key_F4     equ 53
799
key_F5     equ 54
799
key_F5     equ 54
800
key_F6     equ 55
800
key_F6     equ 55
801
key_F7     equ 56
801
key_F7     equ 56
802
key_F8     equ 57
802
key_F8     equ 57
803
key_F9     equ 48
803
key_F9     equ 48
804
key_F10    equ 49
804
key_F10    equ 49
805
key_F11    equ 68
805
key_F11    equ 68
806
key_F12    equ 255
806
key_F12    equ 255
807
key_Home   equ 180
807
key_Home   equ 180
808
key_End    equ 181
808
key_End    equ 181
809
key_PgUp   equ 184
809
key_PgUp   equ 184
810
key_PgDown equ 183
810
key_PgDown equ 183
811
 
811
 
812
;Attributes
812
;Attributes
813
 
813
 
814
;Window Attributes
814
;Window Attributes
815
window_Skinned equ 0x03000000
815
window_Skinned equ 0x03000000
816
window_Type2   equ 0x02000000
816
window_Type2   equ 0x02000000
817
window_Type1   equ 0x00000000
817
window_Type1   equ 0x00000000
818
window_Reserve equ 0x01000000
818
window_Reserve equ 0x01000000
819
 
819
 
820
;Font Attributes
820
;Font Attributes
821
font_Big  equ 0x10000000
821
font_Big  equ 0x10000000
822
 
822
 
823
;Colors
823
;Colors
824
cl_White  equ 0x00ffffff
824
cl_White  equ 0x00ffffff
825
cl_Black  equ 0x00000000
825
cl_Black  equ 0x00000000
826
cl_Grey   equ 0x00888888
826
cl_Grey   equ 0x00888888
827
cl_Red    equ 0x00ff0000
827
cl_Red    equ 0x00ff0000
828
cl_Lime   equ 0x0000ff00
828
cl_Lime   equ 0x0000ff00
829
cl_Green  equ 0x0000af00
829
cl_Green  equ 0x0000af00
830
cl_Blue   equ 0x000000ff
830
cl_Blue   equ 0x000000ff
831
cl_Purple equ 0x008080ff
831
cl_Purple equ 0x008080ff
832
cl_Violet equ 0x008040ff
832
cl_Violet equ 0x008040ff
833
cl_Cyan   equ 0x0040e0ff
833
cl_Cyan   equ 0x0040e0ff