Subversion Repositories Kolibri OS

Rev

Rev 111 | 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
264
    mov ecx,200
265
    rep stosb
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
304
    mov edx,150      ; size 150 bytes
305
    int 0x40
306
 
307
    mcall 40,1000111b
308
;
309
; STEP 3 run SYSTEM XTREE with parameters
310
;
311
 
312
    mcall 58,run_fileinfo
313
 
314
    call redproc
315
 
316
    mov [get_loops],0
317
getmesloop:
318
    mov eax,23
319
    mov ebx,50     ;0.5 sec
320
    int 0x40
321
 
322
    cmp eax,1
323
    je  mred
324
    cmp eax,2
325
    je  mkey
326
    cmp eax,3
327
    je  mbutton
328
    cmp eax,7
329
    je  mgetmes
330
 
331
; Get number of procces
332
    mcall 9,os_work,-1
333
    mov ebp,eax
334
 
335
loox:
336
    mcall 9,os_work,ebp
337
    mov eax,[DLGPID]
338
    cmp dword[os_work+30],eax    ;IF Dialog find
339
    je  dlg_is_work          ;jmp to dlg_is_work
340
    dec ebp
341
    jnz loox
342
 
343
    jmp erroff
344
 
345
dlg_is_work:
346
    cmp word[os_work+50],word 9 ;If slot state 9 - dialog is terminated
347
    je  erroff                 ;TESTODP2 terminated too
348
 
349
    cmp [dlg_pid_get],dword 1
350
    je  getmesloop
351
    inc [get_loops]
352
    cmp [get_loops],4  ;2 sec if DLG_PID not get, TESTOP2  terminated
353
    jae erroff
354
    jmp getmesloop
355
 
356
mred:
357
    call redproc
358
    jmp  getmesloop
359
mkey:
360
    mcall 2  ; read (eax=2)
361
    jmp  getmesloop
362
mbutton:
363
    mov  eax,17                 ; get id
364
    int  0x40
365
    cmp  ah,1                   ; button id=1 ?
366
    jne  getmesloop
367
    mov  eax,-1                 ; close this program
368
    int  0x40
369
mgetmes:
370
; If dlg_pid_get then second message get jmp to still
371
    cmp  [dlg_pid_get],dword 1
372
    je   ready
373
 
374
; First message is number of PID SYSXTREE dialog
375
 
376
; convert PID dec to PID bin
377
    movzx eax,byte [path+16]
378
    sub eax,48
379
    imul eax,10
380
    movzx ebx,byte [path+16+1]
381
    add eax,ebx
382
    sub eax,48
383
    imul eax,10
384
    movzx ebx,byte [path+16+2]
385
    add eax,ebx
386
    sub eax,48
387
    imul eax,10
388
    movzx ebx,byte [path+16+3]
389
    add eax,ebx
390
    sub eax,48
391
    mov [DLGPID],eax
392
 
393
; Claear and prepare IPC area for next message
394
    mov [path],dword 0
395
    mov [path+4],dword 8
396
    mov [path+8],dword 0
397
    mov [path+12],dword 0
398
    mov [path+16],dword 0
399
 
400
; Set dlg_pid_get for get next message
401
    mov [dlg_pid_get],dword 1
402
    call redproc   ;show DLG_PID
403
    jmp  getmesloop
404
 
405
ready:
406
;
407
; The second message get
408
; Second message is 100 bytes path to SAVE/OPEN file
409
; shl path string on 16 bytes
410
;
411
    cld
412
    mov esi,path+16
413
    mov edi,path
414
    mov ecx,200
415
    rep movsb
416
    mov [edi],byte 0
417
 
418
    jmp openoff
419
 
420
 
421
; DATA AREA
422
get_loops   dd 0
423
dlg_pid_get dd 0
424
DLGPID      dd 0
425
 
426
param:
427
   dd 0    ; My dec PID
428
   dd 0,0  ; Type of dialog
429
 
430
run_fileinfo:
431
 dd 16
432
 dd 0
433
 dd param
434
 dd 0
435
 dd os_work ; 0x10000
436
;run_filepath
437
 db '/RD/1/SYSXTREE',0
438
 
439
}
440