Subversion Repositories Kolibri OS

Rev

Rev 109 | Rev 539 | 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.14 By Pavlushin Evgeni (RUSSIA)
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
485 heavyiron 53
    mcall
31 halyavin 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
485 heavyiron 60
    mcall
31 halyavin 61
}
62
 
63
 
64
macro wordstoreg reg,hiword,loword
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
70
    add  reg,dword loword
71
else if hiword eqtype 12 & loword eqtype [123]
72
    mov  reg,dword (hiword)*65536
73
    add  reg,dword loword
74
else
75
    mov  reg,dword hiword
76
    shl  reg,16
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
87
else
88
   mov reg,dword doubleword
89
end if
90
}
91
 
92
macro words2reg reg,hiword,lowword
93
{
94
if hiword eq
95
   if lowword eq
96
      ; not changes
97
   else
98
      if lowword eqtype 12
99
         and reg,dword 0xffff0000
100
         add reg,dword lowword
101
      else
102
         and reg,dword 0xffff0000
103
         add reg,dword lowword
104
      end if
105
   end if
106
else
107
   if lowword eq
108
      if hiword eqtype 12
109
         and reg,dword 0x0000ffff
110
         add reg,dword hiword*65536
111
      else
112
         shl reg,16
113
         add reg,dword hiword
114
         ror reg,16
115
      end if
116
   else
117
      if lowword eqtype 12 & hiword eqtype 12
118
         if lowword eq 0 & hiword eq 0
119
               xor reg,reg
120
            else
121
               mov reg,dword hiword*65536+lowword
122
         end if
123
      else
124
         mov reg,dword hiword
125
         shl reg,16
126
         add reg,dword lowword
127
      end if
128
   end if
129
end if
130
}
131
 
132
 
133
 
134
 
135
; DRAW BUTTON with label
136
 
137
macro drawlbut x,y,xs,ys,text,id,bcolor,tcolor
138
{
139
local asd,lab
140
    jmp asd
141
lab db  text                 ;arg label
142
asd:
143
    words2reg ebx,x,xs
144
    words2reg ecx,y,ys
145
    mov edx,id
146
    mov esi,bcolor
147
    mov eax,8
485 heavyiron 148
    mcall
31 halyavin 149
 
150
    mov eax,asd-lab          ;calc size
151
    mov ebx,6
152
    mul ebx
153
    mov esi,eax
154
 
155
    mov eax,xs
156
    sub eax,esi
157
    shr eax,1
158
    add eax,x
159
 
160
    mov edx,ys
161
    sub edx,7
162
    shr edx,1
163
    add edx,y
164
 
165
    mov ebx,eax
166
    shl ebx,16
167
    add ebx,edx
168
 
169
    mov ecx,tcolor             ;arg4 color
170
    mov edx,lab
171
    mov esi,asd-lab          ;calc size
172
    mov eax,4
485 heavyiron 173
    mcall
31 halyavin 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
485 heavyiron 202
    mcall
31 halyavin 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
233
    mov ebx,1        ; define IPC
234
    mov ecx,path     ; offset of area
235
    mov edx,150      ; size 150 bytes
485 heavyiron 236
    mcall
31 halyavin 237
 
238
; change wanted events list 7-bit IPC event
239
    mov eax,40
240
    mov ebx,01000111b
485 heavyiron 241
    mcall
31 halyavin 242
 
243
;
244
; STEP 3 run SYSTEM XTREE with parameters
245
;
246
 
247
    mov eax,58
248
    mov ebx,run_fileinfo
485 heavyiron 249
    mcall
31 halyavin 250
 
251
    call redproc
252
 
253
    mov [get_loops],0
254
getmesloop:
255
    mov eax,23
256
    mov ebx,50     ;0.5 sec
485 heavyiron 257
    mcall
31 halyavin 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