Subversion Repositories Kolibri OS

Rev

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

Rev 539 Rev 936
1
; @RCHER system-dependent and other stuff
1
; @RCHER system-dependent and other stuff
2
; Written in pure assembler by Ivushkin Andrey aka Willow
2
; Written in pure assembler by Ivushkin Andrey aka Willow
3
 
3
 
4
OpenFile:
4
OpenFile:
5
    mov  [outp],output
5
    mov  [outp],output
6
    mov  esi,area
6
    mov  esi,area
7
    and  [Finfo.block],0
7
    and  [Finfo.block],0
8
if SYS eq win
8
if SYS eq win
9
    invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \
9
    invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \
10
    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL
10
    OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL
11
    inc  eax
11
    inc  eax
12
    test eax,eax
12
    test eax,eax
13
    jz   .ex
13
    jz   .ex
14
    dec  eax
14
    dec  eax
15
    mov  [hnd],eax
15
    mov  [hnd],eax
16
    invoke GetFileSize,eax,NULL
16
    invoke GetFileSize,eax,NULL
17
  .ex:
17
  .ex:
18
    mov  ebx,eax
18
    mov  ebx,eax
19
    mov  [filesize],eax
19
    mov  [filesize],eax
20
else
20
else
21
    and  dword [attrinfo+32], 0
21
    and  dword [attrinfo+32], 0
22
    mcall 70,attrinfo
22
    mcall 70,attrinfo
23
    mov  eax,[attrinfo+32]
23
    mov  eax,[attrinfo+32]
24
    mov  [filesize],ebx
24
    mov  [filesize],ebx
25
    mcall 70,Finfo
25
    mcall 70,Finfo
26
end if
26
end if
27
    ret
27
    ret
28
 
28
 
29
ResetFile:
29
ResetFile:
30
    and  [file_count],0
30
    and  [file_count],0
31
    mov  eax,[arc_base]
31
    mov  eax,[arc_base]
32
    xor  ebx,ebx
32
    xor  ebx,ebx
33
    mov  esi,area
33
    mov  esi,area
34
    call FileSeek
34
    call FileSeek
35
    ret
35
    ret
36
 
36
 
37
 
37
 
38
FileSeek:
38
FileSeek:
39
; eax - offset
39
; eax - offset
40
; esi - current pointer (in memory!)
40
; esi - current pointer (in memory!)
41
; ebx - translation method: 0 - beginning, 1 - current, 2 - end
41
; ebx - translation method: 0 - beginning, 1 - current, 2 - end
42
    push eax ecx edx
42
    push eax ecx edx
43
    sub  esi,BUFPTR
43
    sub  esi,BUFPTR
44
    add  esi,[Finfo.block]
44
    add  esi,[Finfo.block]
45
    cmp  ebx,1
45
    cmp  ebx,1
46
    je   .cur
46
    je   .cur
47
    jb   .begin
47
    jb   .begin
48
    mov  esi,[filesize]
48
    mov  esi,[filesize]
49
    not  eax
49
    not  eax
50
  .cur:
50
  .cur:
51
    add  eax,esi
51
    add  eax,esi
52
  .begin:
52
  .begin:
53
    mov  esi,BUFPTR
53
    mov  esi,BUFPTR
54
    mov  [Finfo.block],eax
54
    mov  [Finfo.block],eax
55
if SYS eq win
55
if SYS eq win
56
    invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN
56
    invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN
57
    invoke ReadFile,[hnd],area,INBUF, os_work, NULL
57
    invoke ReadFile,[hnd],area,INBUF, os_work, NULL
58
;    add  [byte_count],area
58
;    add  [byte_count],area
59
else
59
else
60
;    pregs
60
;    pregs
61
;    wait
61
;    wait
62
    mov  [Finfo.count],BUFSIZE*1024
62
    mov  [Finfo.count],BUFSIZE*1024
63
    mcall 70,Finfo
63
    mcall 70,Finfo
64
;    mov  [byte_count],area+INBUF
64
;    mov  [byte_count],area+INBUF
65
end if
65
end if
66
    pop  edx ecx eax
66
    pop  edx ecx eax
67
    ret
67
    ret
68
 
68
 
69
macro QueryFile
69
macro QueryFile
70
{
70
{
71
local ex
71
local ex
72
if SYS eq win
72
if SYS eq win
73
  	invoke GetOpenFileName,ofstruc
73
  	invoke GetOpenFileName,ofstruc
74
else
74
else
75
   opendialog draw_window,QFok,QFcanc,filename
75
   opendialog draw_window,QFok,QFcanc,filename
76
 QFok:
76
 QFok:
77
   xor eax,eax
77
   xor eax,eax
78
   jmp ex
78
   jmp ex
79
   ret
79
   ret
80
 QFcanc:
80
 QFcanc:
81
   mov eax,1
81
   mov eax,1
82
end if
82
end if
83
 ex:
83
 ex:
84
}
84
}
85
 
85
 
86
RunViewer:
86
RunViewer:
87
    test   [Flags],PNG_MODE
87
    test   [Flags],PNG_MODE
88
    jz   .ex
88
    jz   .ex
89
 if SYS eq win
89
 if SYS eq win
90
   	mov   eax,[PNG_info.Width]
90
   	mov   eax,[PNG_info.Width]
91
   	call  int2str
91
   	call  int2str
92
   	invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file
92
   	invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file
93
   	mov   eax,[PNG_info.Height]
93
   	mov   eax,[PNG_info.Height]
94
   	call  int2str
94
   	call  int2str
95
   	invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file
95
   	invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file
96
   	invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\
96
   	invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\
97
    		NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo
97
    		NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo
98
   	invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF
98
   	invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF
99
   	invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt
99
   	invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt
100
   	invoke FindWindowEx, eax,NULL,NULL,ok_txt
100
   	invoke FindWindowEx, eax,NULL,NULL,ok_txt
101
   	invoke SendMessage,eax,BM_CLICK,NULL,NULL
101
   	invoke SendMessage,eax,BM_CLICK,NULL,NULL
102
 else
102
 else
103
    test [Flags],THREAD_YES
103
    test [Flags],THREAD_YES
104
    jnz  .ex
104
    jnz  .ex
105
    mcall 51,1,thread,child_stack_top;MEMORY
105
    mcall 51,1,thread,child_stack_top;MEMORY
106
    mov  [child],eax
106
    mov  [child],eax
107
 end if
107
 end if
108
  .ex:	
108
  .ex:	
109
	   ret
109
	   ret
110
 
110
 
111
if SYS eq win
111
if SYS eq win
112
int2str:
112
int2str:
113
; in: eax - number
113
; in: eax - number
114
; out: formatted string -> os_work
114
; out: formatted string -> os_work
115
   	invoke wsprintf,os_work,fmt_str,eax
115
   	invoke wsprintf,os_work,fmt_str,eax
116
   	add   esp,12
116
   	add   esp,12
117
    ret
117
    ret
118
 
118
 
119
rawwnd_txt db 'Set RAW open parameters',0
119
rawwnd_txt db 'Set RAW open parameters',0
120
ok_txt  db 'OK',0
120
ok_txt  db 'OK',0
121
ini_sec db 'RAW',0
121
ini_sec db 'RAW',0
122
ini_rwidth db 'RWidth',0
122
ini_rwidth db 'RWidth',0
123
ini_rheight db 'RHeight',0
123
ini_rheight db 'RHeight',0
124
ini_file db "C:\Program Files\IrfanView\i_view32.ini",0
124
ini_file db "C:\Program Files\IrfanView\i_view32.ini",0
125
fmt_str db "%d",0	
125
fmt_str db "%d",0	
126
iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"'
126
iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"'
127
          db ' "D:\Ivushkin\projects\zip\output.raw"',0
127
          db ' "D:\Ivushkin\projects\zip\output.raw"',0
128
filt_str:
128
filt_str:
129
	db 'Pictures (*.png)',0,'*.png',0
129
	db 'Pictures (*.png)',0,'*.png',0
130
	db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0
130
	db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0
131
	db 'All files (*.*)',0,'*.*',0,0
131
	db 'All files (*.*)',0,'*.*',0,0
132
	
132
	
133
suinfo STARTUPINFO
133
suinfo STARTUPINFO
134
pinfo  PROCESS_INFORMATION
134
pinfo  PROCESS_INFORMATION
135
cpstruc:
135
cpstruc:
136
ofstruc:
136
ofstruc:
137
	dd  ofstruc_end-ofstruc
137
	dd  ofstruc_end-ofstruc
138
	dd  NULL
138
	dd  NULL
139
	dd  NULL
139
	dd  NULL
140
	dd  filt_str
140
	dd  filt_str
141
	dd  NULL
141
	dd  NULL
142
	dd  NULL
142
	dd  NULL
143
	dd  0
143
	dd  0
144
	dd  filename
144
	dd  filename
145
	dd  256
145
	dd  256
146
	dd  NULL
146
	dd  NULL
147
	dd  0
147
	dd  0
148
	dd  NULL
148
	dd  NULL
149
	dd  NULL
149
	dd  NULL
150
	dd  NULL
150
	dd  NULL
151
	dw  NULL
151
	dw  NULL
152
	dw  NULL
152
	dw  NULL
153
	dd  NULL
153
	dd  NULL
154
	dd  NULL
154
	dd  NULL
155
	dd  NULL
155
	dd  NULL
156
	dd  NULL
156
	dd  NULL
157
	dd  NULL
157
	dd  NULL
158
	dd  NULL
158
	dd  NULL
159
	dd  NULL
159
	dd  NULL
160
ofstruc_end:	 		
160
ofstruc_end:	 		
161
 
161
 
162
 else
162
 else
163
    mov  ebx,-1
163
    mov  ebx,-1
164
    mov  ecx,ebx
164
    mov  ecx,ebx
165
    mov  edx,[PNG_info.Width]
165
    mov  edx,[PNG_info.Width]
166
    add  edx,10
166
    add  edx,10
167
    mov  esi,[PNG_info.Width]
167
    mov  esi,[PNG_info.Width]
168
    add  esi,30
168
    add  esi,30
169
    mcall 67
169
    mcall 67
170
    mcall 7,outfile,[outfile.size],10 shl 16+15
170
    mcall 7,outfile,[outfile.size],10 shl 16+15
171
 .ext:
171
 .ext:
172
    ret
172
    ret
173
 
173
 
174
MIN_WIDTH equ 300
174
MIN_WIDTH equ 300
175
thread:
175
thread:
176
 .red:
176
 .red:
177
    mcall 12,1
177
    mcall 12,1
178
    mov  ebx,[PNG_info.Width]
178
    mov  ebx,[PNG_info.Width]
179
    cmp  ebx,MIN_WIDTH
179
    cmp  ebx,MIN_WIDTH
180
    jae  .more
180
    jae  .more
181
    mov  ebx,MIN_WIDTH
181
    mov  ebx,MIN_WIDTH
182
  .more:
182
  .more:
183
    add  ebx,20
183
    add  ebx,20
184
    mov  ecx,[PNG_info.Height]
184
    mov  ecx,[PNG_info.Height]
185
    add  ecx,30
185
    add  ecx,30
186
    mcall 0,,,0x3808080
186
    mcall 0,,,0x3808080
187
    mcall 4,<5,7>,0x10f0f0f0,filename,255
187
    ;mcall 4,<5,7>,0x10f0f0f0,filename,255
-
 
188
    mcall 71,1,filename,255 ;by Leency
188
    mov  ecx,[PNG_info.Width]
189
    mov  ecx,[PNG_info.Width]
189
    shl  ecx,16
190
    shl  ecx,16
190
    add  ecx,[PNG_info.Height]
191
    add  ecx,[PNG_info.Height]
191
    mcall 7,[png_],,10 shl 16+25
192
    mcall 7,[png_],,10 shl 16+25
192
    mcall 12,2
193
    mcall 12,2
193
  .still:
194
  .still:
194
    mcall 10
195
    mcall 10
195
    cmp  eax,1
196
    cmp  eax,1
196
    je   .red
197
    je   .red
197
    cmp  eax,2
198
    cmp  eax,2
198
    jne  .nokey
199
    jne  .nokey
199
    mcall 2
200
    mcall 2
200
    cmp  ah,27 ; Esc - close
201
    cmp  ah,27 ; Esc - close
201
    je   .close
202
    je   .close
202
    jmp  .still
203
    jmp  .still
203
  .nokey:
204
  .nokey:
204
    cmp  eax,3
205
    cmp  eax,3
205
    jne  .still
206
    jne  .still
206
  .close:
207
  .close:
207
    and  [child],0
208
    and  [child],0
208
    mcall 64,1,MEMINIT
209
    mcall 64,1,MEMINIT
209
    mcall -1
210
    mcall -1
210
 
211
 
211
KillViewer:
212
KillViewer:
212
    pusha
213
    pusha
213
    mov  edi,[child]
214
    mov  edi,[child]
214
    test edi,edi
215
    test edi,edi
215
    jz   .noth
216
    jz   .noth
216
    mcall 9,os_work,-1
217
    mcall 9,os_work,-1
217
    mov  ecx,eax
218
    mov  ecx,eax
218
  .fchild:
219
  .fchild:
219
    push ecx
220
    push ecx
220
    mcall 9,os_work
221
    mcall 9,os_work
221
    cmp  edi,[ebx+30]
222
    cmp  edi,[ebx+30]
222
    jne  .lp
223
    jne  .lp
223
    mov  ecx,[esp]
224
    mov  ecx,[esp]
224
    mcall 18,2
225
    mcall 18,2
225
    pop  ecx
226
    pop  ecx
226
    jmp  .noth
227
    jmp  .noth
227
  .lp:
228
  .lp:
228
    pop  ecx
229
    pop  ecx
229
    loop .fchild
230
    loop .fchild
230
  .noth:
231
  .noth:
231
    popa
232
    popa
232
    ret
233
    ret
233
 
234
 
234
macro CmdLine
235
macro CmdLine
235
{
236
{
236
    mov  esi,PARAM_PTR
237
    mov  esi,PARAM_PTR
237
  .parse:
238
  .parse:
238
    lodsb
239
    lodsb
239
 
240
 
240
    test al,al
241
    test al,al
241
    jnz  .noend
242
    jnz  .noend
242
    or  [Flags],STAY_MODE
243
    or  [Flags],STAY_MODE
243
    jmp  red
244
    jmp  red
244
  .noend:
245
  .noend:
245
    cmp  al,' '
246
    cmp  al,' '
246
    je   .stay
247
    je   .stay
247
    cmp  al,'/'
248
    cmp  al,'/'
248
    jne  .yespar
249
    jne  .yespar
249
    dec  esi
250
    dec  esi
250
    mov  ecx,255
251
    mov  ecx,255
251
    mov  edi,filename
252
    mov  edi,filename
252
    rep  movsb
253
    rep  movsb
253
    jmp  again;cmdl
254
    jmp  again;cmdl
254
  .yespar:
255
  .yespar:
255
    cmp  al,'N'
256
    cmp  al,'N'
256
    jne  .nonum
257
    jne  .nonum
257
    call get_6ASCII_num
258
    call get_6ASCII_num
258
  .fnum:
259
  .fnum:
259
    mov  [FileNum],eax
260
    mov  [FileNum],eax
260
    jmp  .parse
261
    jmp  .parse
261
  .nonum:
262
  .nonum:
262
    cmp  al,'n'
263
    cmp  al,'n'
263
    jne  .nonum2
264
    jne  .nonum2
264
    lodsd
265
    lodsd
265
    jmp  .fnum
266
    jmp  .fnum
266
  .nonum2:
267
  .nonum2:
267
    cmp  al,'s'
268
    cmp  al,'s'
268
    jne  .nostay
269
    jne  .nostay
269
  .stay:
270
  .stay:
270
    or   [Flags],STAY_MODE
271
    or   [Flags],STAY_MODE
271
    jmp  .parse
272
    jmp  .parse
272
  .nostay:
273
  .nostay:
273
    cmp  al,'i'
274
    cmp  al,'i'
274
    jne  .noclPID
275
    jne  .noclPID
275
    lodsd
276
    lodsd
276
    mov  [clientPID],eax
277
    mov  [clientPID],eax
277
    or   [Flags],IPC_MODE
278
    or   [Flags],IPC_MODE
278
    jmp  .parse
279
    jmp  .parse
279
  .noclPID:
280
  .noclPID:
280
    cmp  al,'R'
281
    cmp  al,'R'
281
    jne  .noraw
282
    jne  .noraw
282
    or   [Flags],RAW_MODE
283
    or   [Flags],RAW_MODE
283
    jmp  .parse
284
    jmp  .parse
284
  .noraw:
285
  .noraw:
285
    cmp  al,'q'
286
    cmp  al,'q'
286
    jne  .noofs
287
    jne  .noofs
287
    lodsd
288
    lodsd
288
  .fofs:
289
  .fofs:
289
    mov  [arc_base],eax
290
    mov  [arc_base],eax
290
    jmp  .parse
291
    jmp  .parse
291
  .noofs:
292
  .noofs:
292
    cmp  al,'Q'
293
    cmp  al,'Q'
293
    jne  .noofs2
294
    jne  .noofs2
294
    call get_6ASCII_num
295
    call get_6ASCII_num
295
    jmp  .fofs
296
    jmp  .fofs
296
  .noofs2:
297
  .noofs2:
297
    cmp  al,'L'
298
    cmp  al,'L'
298
    jne  .nolist
299
    jne  .nolist
299
    or   [Flags],LIST_MODE
300
    or   [Flags],LIST_MODE
300
  .nolist:
301
  .nolist:
301
    jmp  .parse
302
    jmp  .parse
302
 
303
 
303
get_6ASCII_num:
304
get_6ASCII_num:
304
; in: esi - str ptr, out: eax - num
305
; in: esi - str ptr, out: eax - num
305
    xor  edx,edx
306
    xor  edx,edx
306
    mov  ebx,10
307
    mov  ebx,10
307
    mov  ecx,6
308
    mov  ecx,6
308
  .lp:
309
  .lp:
309
    xor  eax,eax
310
    xor  eax,eax
310
    lodsb
311
    lodsb
311
    sub  al,'0'
312
    sub  al,'0'
312
    imul edx,ebx
313
    imul edx,ebx
313
    add  edx,eax
314
    add  edx,eax
314
    loop .lp
315
    loop .lp
315
    mov  eax,edx
316
    mov  eax,edx
316
    ret
317
    ret
317
}
318
}
318
 
319
 
319
StartPad:
320
StartPad:
320
    pusha
321
    pusha
321
    mov   esi,[outfile.size]
322
    mov   esi,[outfile.size]
322
;    dpd  esi
323
;    dpd  esi
323
; convert number in esi to decimal representation
324
; convert number in esi to decimal representation
324
        mov     ecx, 10
325
        mov     ecx, 10
325
        push    -'0'
326
        push    -'0'
326
        mov     eax, esi
327
        mov     eax, esi
327
@@:
328
@@:
328
        xor	edx, edx
329
        xor	edx, edx
329
        div     ecx
330
        div     ecx
330
        push    edx
331
        push    edx
331
        test    eax, eax
332
        test    eax, eax
332
        jnz     @b
333
        jnz     @b
333
        mov     edi, par_fsize
334
        mov     edi, par_fsize
334
@@:
335
@@:
335
        pop     eax
336
        pop     eax
336
        add     al, '0'
337
        add     al, '0'
337
        stosb
338
        stosb
338
        jnz     @b
339
        jnz     @b
339
    mcall 70,fileinfo
340
    mcall 70,fileinfo
340
    mov  ecx,eax
341
    mov  ecx,eax
341
    mcall 5,20
342
    mcall 5,20
342
    mcall 60,2,,[outfile.out];output
343
    mcall 60,2,,[outfile.out];output
343
    mcall 64,1,MEMINIT
344
    mcall 64,1,MEMINIT
344
    popa
345
    popa
345
    ret
346
    ret
346
 
347
 
347
fileinfo:
348
fileinfo:
348
        dd      7
349
        dd      7
349
        dd      0
350
        dd      0
350
        dd      editor_par
351
        dd      editor_par
351
        dd      0
352
        dd      0
352
        dd      0
353
        dd      0
353
        db      '/sys/TINYPAD',0
354
        db      '/sys/TINYPAD',0
354
editor_par db '*'
355
editor_par db '*'
355
par_fsize rb 11
356
par_fsize rb 11
356
end if
357
end if