Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
31 halyavin 1
; @RCHER macros and messages
2
; Written in pure assembler by Ivushkin Andrey aka Willow
3
 
4
macro stop
5
{
6
  if SYS eq win & NO_STOPS eq 0
7
    int3
8
  end if
9
}
10
 
11
macro wait
12
{
13
if ~ SYS eq win
14
local .nodrw,.ex
15
   pusha
16
   mcall 10
17
   cmp   eax,1
18
   jne   .nodrw
19
   call  draw_window
20
 .nodrw:
21
   mcall 17
22
 .ex:
23
   popa
24
end if
25
}
26
 
27
macro rbits dest,cnt
28
{
29
    if ~ cnt eq
30
      mov  ecx,cnt
31
    end if
32
    if   dest eq 0
33
      xor  eax,eax
34
    else
35
      mov  eax,dest
36
    end if
37
    call read_bits
38
}
39
 
40
 
41
macro rep_err cond_ok, result, msg
42
{
43
  local .m
44
    j#cond_ok .m
45
   if ~ msg eq
46
    Msg msg
47
   end if
48
    mov  edx,result
49
    jmp  .err
50
  .m:
51
}
52
 
53
macro memcpy_esi dest, count,_add
54
{
55
    push esi
56
  if ~ _add eq
57
    add  esi,_add
58
  end if
59
    mov  edi,dest
60
    mov  ecx,count
61
    rep  movsb
62
    pop  esi
63
}
64
 
65
DebugPrint:
66
; in: edx-asciiz string ptr
67
    pusha
68
if SYS eq win
69
    mov  ecx,255
70
    xor  eax,eax
71
    mov  edi,edx
72
    repne scasb
73
    sub  edi,edx
74
    dec  edi
75
    invoke WriteConsole,[cons],edx,edi,cparam1,NULL
76
else
77
    call debug_outstr
78
end if
79
    popa
80
    ret
81
 
82
macro DebugPrintDec
83
{
84
if SYS eq win
85
    call int2str
86
    mov  edx,os_work
87
    call DebugPrint
88
else
89
    call debug_outdec
90
end if
91
}
92
 
93
macro Newline
94
{
95
if SYS eq win
96
    pusha
97
    invoke WriteConsole,[cons],cr_lf,2,cparam1,NULL
98
    popa
99
else
100
    newline
101
end if
102
}
103
 
104
Msgcall:
105
; edx - msg number
106
  pusha
107
  movzx edx,word[strs+edx*2]
108
  add  edx,msgs
109
  call DebugPrint
110
  popa
111
  ret
112
 
113
macro Msg num
114
{
115
 if ~ num eq edx
116
   mov  edx,num
117
 end if
118
   call Msgcall
119
}
120
 
121
MSG_COUNT=0
122
macro str_table [str]
123
{
124
 forward
125
   local label
126
   dw label-msgs
127
 common
128
   msgs:
129
 forward
130
   label db str,0
131
   MSG_COUNT=MSG_COUNT+1
132
}
133
 
134
 
135
 
136
strs:
137
if  language eq ru
138
str_table \
139
   <'***  @RCHER - Deflate Unpacker  ***',13,10>,\  ;0
140
   <'*** Copyright Wiland Inc., 2005 ***',13,10>,\  ;1
141
   'Файлов в архиве: ',\ ;2
142
   <'End of Directory достигнут',13,10>,\  ;3
143
   'Нет файла с таким номером',\  ;4
144
   <'FindByNumber ОК',13,10>,\  ;5
145
   <'Неверный ID блока Хаффмана',13,10>,\  ;6
146
   <'Ошибка в кодах Хаффмана!',13,10>,\  ;7
147
   <13,10,'Расчет таблицы CRC32',13,10>,\  ;8
148
   '.',\  ;9
149
   'Adler32',\  ;10
150
   'CRC32',\ ;11
151
   <'Завершено.',13,10>,\  ;12
152
   <'Файл имеет нулевую длину, распаковка отменена.',13,10>,\  ;13
153
   <'Странная длина файла-источника. Ошибка в имени? Отмена.',13,10>,\  ;14
154
   <'Не GZIP архив',13,10>,\  ;15
155
   <'Слишком большой размер выходного файла',13,10>,\  ;16
156
   <"Ошибка при распаковке.",13,10>,\  ; 17
157
   <'Не рисунок PNG',13,10>,\ ; 18
158
   <13,10,'*д'>,\  ;19
159
   <13,10,'*с'>,\  ;20
160
   'Неожиданный конец блоков IDAT',\  ;21
161
   'Дефильтрация:',\  ;22
162
   'Фильтры: None ',\  ;23
163
   ' Sub ',\  ;24
164
   ' Up ',\  ;25
165
   ' Avg ',\  ;26
166
   ' Paeth ',\  ;27
167
   ' Ошибок: ',\  ;28
168
   <'Чересстрочный PNG',13,10>,\  ;29
169
   <'Блок без сжатия',13,10>,\  ;30
170
   <'Тип цвета не поддерживается',13,10>,\  ;31
171
   <'Введите пароль для зашифрованного файла:',13,10>,\  ;32
172
   <'Поиск файла...',13,10>,\  ;33
173
   'Не модуль SFX',\  ;34
174
   ' неверна! ',\  ;35
175
   ' OK: ',\  ;36
176
   <'Запись OUT.TXT',13,10>,\  ;37
177
   ' ',\  ;38
178
   <'Подготовка изображения...',13,10>,\  ;39
179
   <'Укажите "R" для обработки сырых данных. Отмена.',13,10>,\  ;40
131 diamond 180
   <'Не хватает памяти! Отмена.',13,10>,\  ; 41
31 halyavin 181
   ' ',\  ;
182
   ' ',\  ;
183
   ' ',\  ;
184
   ' ',\  ;
185
   ' ',\  ;
186
   ' ',\  ;
187
   ' ',\  ;
188
   ' ',\  ;
189
   ' <- неизвестный метод сжатия',\  ;50
190
   ' <- зашифрован',\  ;51
191
   <'Не ZIP архив',13,10> ; 52
192
else
193
str_table \
194
   <'***  @RCHER - Deflate Unpacker  ***',13,10>,\  ;0
195
   <'*** Copyright Wiland Inc., 2005 ***',13,10>,\  ;1
196
   'Files in archive: ',\ ;2
197
   <'End of Directory reached',13,10>,\  ;3
198
   'No file has this number',\  ;4
199
   <'FindByNumber succeded',13,10>,\  ;5
200
   <'Invalid Huffman block ID',13,10>,\  ;6
201
   <'Error while getting Huffman codes!',13,10>,\  ;7
202
   <13,10,'Rebuilding CRC32 table',13,10>,\  ;8
203
   '.',\  ;9
204
   'Adler32',\  ;10
205
   'CRC32',\ ;11
206
   <'Job finished.',13,10>,\  ;12
207
   <'File of zero length, unpacking aborted.',13,10>,\  ;13
208
   <'Source file has strange length, may be missing? Abort.',13,10>,\  ;14
209
   <'Not a GZIP archive',13,10>,\  ;15
210
   <'Destination file is too large for now',13,10>,\  ;16
211
   <"Can't unpack content.",13,10>,\  ; 17
212
   <'Not a PNG image',13,10>,\ ; 18
213
   <13,10,'*d'>,\  ;19
214
   <13,10,'*s'>,\  ;20
215
   'Unexpected end of IDAT chunks',\  ;21
216
   'Unfiltering:',\  ;22
217
   'Filters: None ',\  ;23
218
   ' Sub ',\  ;24
219
   ' Up ',\  ;25
220
   ' Avg ',\  ;26
221
   ' Paeth ',\  ;27
222
   ' Invalid ',\  ;28
223
   <'Interlaced PNG',13,10>,\  ;29
224
   <'Stored block',13,10>,\  ;30
225
   <'Color type not supported',13,10>,\  ;31
226
   <'Enter password for encrypted file:',13,10>,\  ;32
227
   <'Searching for file...',13,10>,\  ;33
228
   'Not a SFX module',\  ;34
229
   ' error! ',\  ;35
230
   ' OK: ',\  ;36
231
   <'Creating OUT.TXT',13,10>,\  ;37
232
   ' ',\  ;38
233
   <'Preparing bitmap...',13,10>,\  ;39
234
   <'Specify "R" to force raw data. Abort.',13,10>,\  ;40
131 diamond 235
   <'Not enough memory! Abort.',13,10>,\  ;
31 halyavin 236
   ' ',\  ;
237
   ' ',\  ;
238
   ' ',\  ;
239
   ' ',\  ;
240
   ' ',\  ;
241
   ' ',\  ;
242
   ' ',\  ;
243
   ' ',\  ;
244
   ' <- unknown compression method',\  ;50
245
   ' <- encrypted',\  ;51
246
   <'Not a ZIP archive',13,10> ; 52
247
end if
248
 
249
macro opendialog redproc,openoff,erroff,path
250
{
251
local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc
252
local run_fileinfo, param
253
local getmesloop, loox, mred, mkey, mbutton, mgetmes
254
local dlg_is_work, ready
255
;
256
; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec,
257
; 1 byte space, 1 byte type of dialog (O - Open ,S - Save)
258
;
259
 
260
    cld
261
;;    mov esi,path
262
    mov edi,path
263
    xor eax,eax
134 diamond 264
    mov ecx,(1024+16)/4
265
    rep stosd
31 halyavin 266
 
267
;mov [get_loops],0
268
mov [dlg_pid_get],0
269
 
270
; Get my PID in dec format 4 bytes
271
    mcall 9,os_work,-1
272
 
273
; convert eax bin to param dec
274
    mov eax,dword [os_work+30]  ;offset of myPID
275
    mov edi,param+4-1            ;offset to 4 bytes
276
    mov ecx,4
277
    mov ebx,10
278
    cld
279
new_d:
280
    xor edx,edx
281
    div ebx
282
    add dl,'0'
283
    mov [edi],dl
284
    dec edi
285
    loop new_d
286
 
287
; write 1 byte space to param
288
    mov [param+4],byte 32    ;Space for next parametr
289
; and 1 byte type of dialog to param
290
    mov [param+5],byte 'O'   ;Get Open dialog (Use 'S' for Save dialog)
291
 
292
;
293
; STEP2 prepare IPC area for get messages
294
;
295
 
296
; prepare IPC area
297
    mov [path],dword 0
298
    mov [path+4],dword 8
299
 
300
; define IPC memory
301
    mov eax,60
302
    mov ebx,1        ; define IPC
303
    mov ecx,path     ; offset of area
134 diamond 304
    mov edx,1024+16  ; size
485 heavyiron 305
    mcall
31 halyavin 306
 
307
    mcall 40,1000111b
308
;
309
; STEP 3 run SYSTEM XTREE with parameters
310
;
311
 
134 diamond 312
    mcall 70,run_fileinfo
31 halyavin 313
 
314
    call redproc
315
 
316
    mov [get_loops],0
317
getmesloop:
318
    mov eax,23
319
    mov ebx,50     ;0.5 sec
485 heavyiron 320
    mcall
134 diamond 321
        dec     eax
322
        jz      mred
323
        dec     eax
324
        jz      mkey
325
        dec     eax
326
        jz      mbutton
327
        cmp     al, 7-3
328
        jz      mgetmes
31 halyavin 329
 
330
; Get number of procces
331
    mcall 9,os_work,-1
332
    mov ebp,eax
333
 
334
loox:
335
    mcall 9,os_work,ebp
336
    mov eax,[DLGPID]
337
    cmp dword[os_work+30],eax    ;IF Dialog find
338
    je  dlg_is_work          ;jmp to dlg_is_work
339
    dec ebp
340
    jnz loox
341
 
342
    jmp erroff
343
 
344
dlg_is_work:
345
    cmp word[os_work+50],word 9 ;If slot state 9 - dialog is terminated
346
    je  erroff                 ;TESTODP2 terminated too
347
 
348
    cmp [dlg_pid_get],dword 1
349
    je  getmesloop
350
    inc [get_loops]
351
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
352
    jae erroff
353
    jmp getmesloop
354
 
355
mred:
356
    call redproc
357
    jmp  getmesloop
358
mkey:
359
    mcall 2  ; read (eax=2)
360
    jmp  getmesloop
361
mbutton:
362
    mov  eax,17                 ; get id
485 heavyiron 363
    mcall
31 halyavin 364
    cmp  ah,1                   ; button id=1 ?
365
    jne  getmesloop
366
    mov  eax,-1                 ; close this program
485 heavyiron 367
    mcall
31 halyavin 368
mgetmes:
369
; If dlg_pid_get then second message get jmp to still
370
    cmp  [dlg_pid_get],dword 1
371
    je   ready
372
 
373
; First message is number of PID SYSXTREE dialog
374
 
375
; convert PID dec to PID bin
376
    movzx eax,byte [path+16]
377
    sub eax,48
378
    imul eax,10
379
    movzx ebx,byte [path+16+1]
380
    add eax,ebx
381
    sub eax,48
382
    imul eax,10
383
    movzx ebx,byte [path+16+2]
384
    add eax,ebx
385
    sub eax,48
386
    imul eax,10
387
    movzx ebx,byte [path+16+3]
388
    add eax,ebx
389
    sub eax,48
390
    mov [DLGPID],eax
391
 
392
; Claear and prepare IPC area for next message
393
    mov [path],dword 0
394
    mov [path+4],dword 8
395
    mov [path+8],dword 0
396
    mov [path+12],dword 0
397
    mov [path+16],dword 0
398
 
399
; Set dlg_pid_get for get next message
400
    mov [dlg_pid_get],dword 1
401
    call redproc   ;show DLG_PID
402
    jmp  getmesloop
403
 
404
ready:
405
;
406
; The second message get
134 diamond 407
; Second message is 1024 bytes path to SAVE/OPEN file
31 halyavin 408
; shl path string on 16 bytes
409
;
410
    cld
411
    mov esi,path+16
412
    mov edi,path
134 diamond 413
    mov ecx,1024/4
414
    rep movsd
31 halyavin 415
    mov [edi],byte 0
416
 
417
    jmp openoff
418
 
419
 
420
; DATA AREA
421
get_loops   dd 0
422
dlg_pid_get dd 0
423
DLGPID      dd 0
424
 
425
param:
426
   dd 0    ; My dec PID
427
   dd 0,0  ; Type of dialog
428
 
429
run_fileinfo:
134 diamond 430
 dd 7
31 halyavin 431
 dd 0
432
 dd param
433
 dd 0
134 diamond 434
 dd 0
31 halyavin 435
;run_filepath
539 spraid 436
 db '/sys/SYSXTREE',0
31 halyavin 437
 
438
}
439