diff --git a/programs/other/archer/trunk/@RCHER.ASM b/programs/other/outdated/archer/trunk/@RCHER.ASM similarity index 100% rename from programs/other/archer/trunk/@RCHER.ASM rename to programs/other/outdated/archer/trunk/@RCHER.ASM diff --git a/programs/other/archer/trunk/archer.txt b/programs/other/outdated/archer/trunk/archer.txt similarity index 97% rename from programs/other/archer/trunk/archer.txt rename to programs/other/outdated/archer/trunk/archer.txt index 2cb2f70c44..223775ee72 100644 --- a/programs/other/archer/trunk/archer.txt +++ b/programs/other/outdated/archer/trunk/archer.txt @@ -1,176 +1,176 @@ -@RCHER FOR MENUET v1.0 July 14, 2005 - Written in pure assembler by Ivushkin Andrey aka Willow - -Deflate unpacker - -Vivat assembler et MENUETOS! -I tender thanks to everyone who spends his time in feasible effortsfor that -little OS evolution. Now in my own rating the Mario79's distro named Kolibri4 -takes 1th place. It is always pleasant to use modern software. Go on! - -@RCHER is intended to view & unpack data compressed by Deflate method -(including both static and dynamic Huffman). This method (although it isn't the -best already) is used by such file formats as ZIP (modern versions: PKZIP for -MS-DOS can create archives using other, less effective compression methods, -which @RCHER doesn't support), GZIP, JAR, OpenOffice files, SFX ZIP executables -and some others. I couldn't prevent myself to include support of PNG images -(they use the similar compression) and TAR and TAR+GZIP archives. - -When the program is started, a little button carrying a @ symbol appears in the -left top corner of screen. Clicking this button opens a SYSXTREE dialog to -select a file being unpacked. Doubleclick closes the application. @RCHER -outputs its information messages to Debug Board. If an archive contains more -than one file, the 1st is by default unpacked into /HD/1/OUT.TXT (you may -change the DUMPFILE constant in @RCHER.ASM) and is opened through TINYPAD -or - if it's a PNG image - in the built-in viewer. - -These are unpacking flags that may exist in a commandline before an archive -filename: - - s - do not close the program after unpacking; - n - decompress the K-th archive file, where K is the following dword in - commandline; - N - decompress the K-th archive file, where K is ASCII number from the - following 6 bytes of commandline; - R - "raw" Deflate data, without descriptors and headers; - q - begin file parsing from offset of K, where K is following dword in - commandline; - Q - begin file parsing from offset of K, where K is ASCII number from the - following 6 bytes of commandline. - -Commandline example: - -cmd_string: - db 'sN000037q' - dd 1465 - db '/hd/1/png.zip',0 - -It means to open the 34th (counting from 0) file of archive /hd/1/png.zip -and do not terminate. Archive will be parsed starting at offset 1465. - - -To-Do list: - -1. Support for interlaced PNG, alpha-channels, gamma-correction, background, - Significant bits and a lot of cool parts of that format. -2. Output of archive content through IPC or into a built-in window like SYSTREE - (as we are going to decide with the respected colleagues). -3. Searching of archive files by name and wildcards! -4. Unpacking into a file specified. -5. Means on saving memory space (now @RCHER gorges 8 Mb!): moving RAM areas, - blocked file output. To do the last thing it is necessary to test carefully - the reliability of harddisk I/O, directory creation and file deletion. These - kernel capabilities aren't still documented. -6. Archive contents integration into SYSXTREE & MFAR filemanagers. We have to - unify the calling format (like a structure in the sysfunc 58). -7. Add comments to source. -8. Correct bugs to be found - -Special thanks to: - - Explanation of algorythm of Deflate format decoder with decoding samples - (evm.narod.ru) - RFC 1951 DEFLATE Compressed Data Format Specification version 1.3 - ZIP File Format Specification version 4.5 by PKWARE Inc. - "An Explanation of the Deflate Algorithm" by Antaeus Feldspar - RFC 1952 GZIP file format specification version 4.3 - TAR Format. Information from File Format List 2.0 by Max Maischein. - RFC 1950 ZLIB Compressed Data Format Specification version 3.3 - PNG (Portable Network Graphics) Specification version 1.0 - Michael Dipperstein's Huffman Code Page - -I expect your remarks and suggestions on the @RCHER's topic, "Coding" section -at meos.sysbin.com forum. - -See you later! - - -**************************************** -**************************************** - -@RCHER ДЛЯ MENUET v1.0 14 июля 2005 г. - Написана на чистом ассемблере Ивушкиным Андреем (Willow) - -Deflate распаковщик - -Vivat assembler et MenuetOS! -Выражаю искреннюю благодарность всем тем, кто не жалея своего времени, -делает посильный вклад в развитие этой маленькой ОС. Сейчас в моем собственном -рейтинге 1-е место занимает дистрибутив Mario79 Kolibri4. Всегда приятно -пользоваться современным ПО. Так держать! - -@RCHER предназначен для просмотра и распаковки данных, сжатых с помощью метода -Deflate (включая статический и динамический Хаффман). Данным методом (хотя он -уже не претендует на звание наилучшего) пользуются форматы файлов ZIP -(современные версии: PKZIP для MS-DOS может создавать архивы с другими, менее -эффективными методами сжатия, которые @RCHER не поддерживает), GZIP, JAR, -файлы OpenOffice, SFX-ZIP приложения и ряд других. Я не мог удержаться и не -сделать поддержку изображений в формате PNG (использующих родственный метод -сжатия) и архивов TAR и TAR+GZIP. - -При запуске программы в левом верхнем углу экрана появляется маленькая кнопка -со значком @. При нажатии на нее открывается окно выбора файла (SYSXTREE) для -распаковки. Двойной щелчок закрывает приложение. Информационные сообщения -@RCHER выводит на доску отладки. Если архив содержит несколько файлов, по -умолчанию первый из них распаковывается на /HD/1/OUT.TXT (поменяйте при -необходимости константу DUMPFILE в @RCHER.ASM) и открывается через TINYPAD -или - в случае картинки PNG - в окне встроенного просмотрщика. - -В командной строке перед именем архива могут в произвольном порядке указываться -флаги распаковки: - - s - не закрывать программу после распаковки; - n - распаковать K-й файл архива, где K - следующий dword в командной строке; - N - распаковать K-й файл архива, где K - ASCII число из следующих 6 байт - командной строки; - R - "сырые" Deflate-данные, без описателей и заголовков; - q - просмотр файла начать со смещения K, где K - следующий dword в командной - строке; - Q - просмотр файла начать со смещения K, где K - ASCII число из следующих 6 - байт командной строки. - -Пример командной строки: - -cmd_string: - db 'sN000037q' - dd 1465 - db '/hd/1/png.zip',0 - -Это означает, что следует открыть 34-й (считая от 0) файл архива /hd/1/png.zip -и не завершать работу. Просмотр архива начнется со смещения 1465. - - -Что еще нужно сделать: - -1. Поддержка чересстрочных (interlaced) PNG, а также альфа-каналов, гаммы, - фона, Significant bits и кучи других примочек этого формата. -2. Вывод содержимого архивов через IPC или во встроенном окне наподобие SYSTREE - (это как решим с уважаемыми коллегами). -3. Поиск файлов в архиве по имени и даже маске! -4. Распаковка в указанный файл. -5. Мероприятия по экономии памяти (сейчас @RCHER жрет 8 Мб!): перемещение - участков памяти, блочный вывод в файл. Для последнего необходимо тщательно - протестировать надежность воода-вывода на ЖД, создания каталогов и удаления - файлов. Пока эти возможности ядра не документированы. -6. Интеграция архивных каталогов в файловые менеджеры SYSXTREE, MFAR. - Потребуется унифицировать формат вызова (наподобие структуры в 58 функции). -7. Откомментировать код. -8. Исправить баги, которые, несомненно, найдутся ;-) - -Особые благодарности: - - Описание алгоритма декодера формата Deflate на примерах декодирования - (evm.narod.ru) - RFC 1951 DEFLATE Compressed Data Format Specification version 1.3 - ZIP File Format Specification version 4.5 by PKWARE Inc. - "An Explanation of the Deflate Algorithm" by Antaeus Feldspar - RFC 1952 GZIP file format specification version 4.3 - TAR Format. Information from File Format List 2.0 by Max Maischein. - RFC 1950 ZLIB Compressed Data Format Specification version 3.3 - PNG (Portable Network Graphics) Specification version 1.0 - Michael Dipperstein's Huffman Code Page - -Жду ваших замечаний и предложений на одноименной ветке раздела "Кодинг" форума -meos.sysbin.com - -До новых встреч! +@RCHER FOR MENUET v1.0 July 14, 2005 + Written in pure assembler by Ivushkin Andrey aka Willow + +Deflate unpacker + +Vivat assembler et MENUETOS! +I tender thanks to everyone who spends his time in feasible effortsfor that +little OS evolution. Now in my own rating the Mario79's distro named Kolibri4 +takes 1th place. It is always pleasant to use modern software. Go on! + +@RCHER is intended to view & unpack data compressed by Deflate method +(including both static and dynamic Huffman). This method (although it isn't the +best already) is used by such file formats as ZIP (modern versions: PKZIP for +MS-DOS can create archives using other, less effective compression methods, +which @RCHER doesn't support), GZIP, JAR, OpenOffice files, SFX ZIP executables +and some others. I couldn't prevent myself to include support of PNG images +(they use the similar compression) and TAR and TAR+GZIP archives. + +When the program is started, a little button carrying a @ symbol appears in the +left top corner of screen. Clicking this button opens a SYSXTREE dialog to +select a file being unpacked. Doubleclick closes the application. @RCHER +outputs its information messages to Debug Board. If an archive contains more +than one file, the 1st is by default unpacked into /HD/1/OUT.TXT (you may +change the DUMPFILE constant in @RCHER.ASM) and is opened through TINYPAD +or - if it's a PNG image - in the built-in viewer. + +These are unpacking flags that may exist in a commandline before an archive +filename: + + s - do not close the program after unpacking; + n - decompress the K-th archive file, where K is the following dword in + commandline; + N - decompress the K-th archive file, where K is ASCII number from the + following 6 bytes of commandline; + R - "raw" Deflate data, without descriptors and headers; + q - begin file parsing from offset of K, where K is following dword in + commandline; + Q - begin file parsing from offset of K, where K is ASCII number from the + following 6 bytes of commandline. + +Commandline example: + +cmd_string: + db 'sN000037q' + dd 1465 + db '/hd/1/png.zip',0 + +It means to open the 34th (counting from 0) file of archive /hd/1/png.zip +and do not terminate. Archive will be parsed starting at offset 1465. + + +To-Do list: + +1. Support for interlaced PNG, alpha-channels, gamma-correction, background, + Significant bits and a lot of cool parts of that format. +2. Output of archive content through IPC or into a built-in window like SYSTREE + (as we are going to decide with the respected colleagues). +3. Searching of archive files by name and wildcards! +4. Unpacking into a file specified. +5. Means on saving memory space (now @RCHER gorges 8 Mb!): moving RAM areas, + blocked file output. To do the last thing it is necessary to test carefully + the reliability of harddisk I/O, directory creation and file deletion. These + kernel capabilities aren't still documented. +6. Archive contents integration into SYSXTREE & MFAR filemanagers. We have to + unify the calling format (like a structure in the sysfunc 58). +7. Add comments to source. +8. Correct bugs to be found + +Special thanks to: + + Explanation of algorythm of Deflate format decoder with decoding samples + (evm.narod.ru) + RFC 1951 DEFLATE Compressed Data Format Specification version 1.3 + ZIP File Format Specification version 4.5 by PKWARE Inc. + "An Explanation of the Deflate Algorithm" by Antaeus Feldspar + RFC 1952 GZIP file format specification version 4.3 + TAR Format. Information from File Format List 2.0 by Max Maischein. + RFC 1950 ZLIB Compressed Data Format Specification version 3.3 + PNG (Portable Network Graphics) Specification version 1.0 + Michael Dipperstein's Huffman Code Page + +I expect your remarks and suggestions on the @RCHER's topic, "Coding" section +at meos.sysbin.com forum. + +See you later! + + +**************************************** +**************************************** + +@RCHER ДЛЯ MENUET v1.0 14 июля 2005 г. + Написана на чистом ассемблере Ивушкиным Андреем (Willow) + +Deflate распаковщик + +Vivat assembler et MenuetOS! +Выражаю искреннюю благодарность всем тем, кто не жалея своего времени, +делает посильный вклад в развитие этой маленькой ОС. Сейчас в моем собственном +рейтинге 1-е место занимает дистрибутив Mario79 Kolibri4. Всегда приятно +пользоваться современным ПО. Так держать! + +@RCHER предназначен для просмотра и распаковки данных, сжатых с помощью метода +Deflate (включая статический и динамический Хаффман). Данным методом (хотя он +уже не претендует на звание наилучшего) пользуются форматы файлов ZIP +(современные версии: PKZIP для MS-DOS может создавать архивы с другими, менее +эффективными методами сжатия, которые @RCHER не поддерживает), GZIP, JAR, +файлы OpenOffice, SFX-ZIP приложения и ряд других. Я не мог удержаться и не +сделать поддержку изображений в формате PNG (использующих родственный метод +сжатия) и архивов TAR и TAR+GZIP. + +При запуске программы в левом верхнем углу экрана появляется маленькая кнопка +со значком @. При нажатии на нее открывается окно выбора файла (SYSXTREE) для +распаковки. Двойной щелчок закрывает приложение. Информационные сообщения +@RCHER выводит на доску отладки. Если архив содержит несколько файлов, по +умолчанию первый из них распаковывается на /HD/1/OUT.TXT (поменяйте при +необходимости константу DUMPFILE в @RCHER.ASM) и открывается через TINYPAD +или - в случае картинки PNG - в окне встроенного просмотрщика. + +В командной строке перед именем архива могут в произвольном порядке указываться +флаги распаковки: + + s - не закрывать программу после распаковки; + n - распаковать K-й файл архива, где K - следующий dword в командной строке; + N - распаковать K-й файл архива, где K - ASCII число из следующих 6 байт + командной строки; + R - "сырые" Deflate-данные, без описателей и заголовков; + q - просмотр файла начать со смещения K, где K - следующий dword в командной + строке; + Q - просмотр файла начать со смещения K, где K - ASCII число из следующих 6 + байт командной строки. + +Пример командной строки: + +cmd_string: + db 'sN000037q' + dd 1465 + db '/hd/1/png.zip',0 + +Это означает, что следует открыть 34-й (считая от 0) файл архива /hd/1/png.zip +и не завершать работу. Просмотр архива начнется со смещения 1465. + + +Что еще нужно сделать: + +1. Поддержка чересстрочных (interlaced) PNG, а также альфа-каналов, гаммы, + фона, Significant bits и кучи других примочек этого формата. +2. Вывод содержимого архивов через IPC или во встроенном окне наподобие SYSTREE + (это как решим с уважаемыми коллегами). +3. Поиск файлов в архиве по имени и даже маске! +4. Распаковка в указанный файл. +5. Мероприятия по экономии памяти (сейчас @RCHER жрет 8 Мб!): перемещение + участков памяти, блочный вывод в файл. Для последнего необходимо тщательно + протестировать надежность воода-вывода на ЖД, создания каталогов и удаления + файлов. Пока эти возможности ядра не документированы. +6. Интеграция архивных каталогов в файловые менеджеры SYSXTREE, MFAR. + Потребуется унифицировать формат вызова (наподобие структуры в 58 функции). +7. Откомментировать код. +8. Исправить баги, которые, несомненно, найдутся ;-) + +Особые благодарности: + + Описание алгоритма декодера формата Deflate на примерах декодирования + (evm.narod.ru) + RFC 1951 DEFLATE Compressed Data Format Specification version 1.3 + ZIP File Format Specification version 4.5 by PKWARE Inc. + "An Explanation of the Deflate Algorithm" by Antaeus Feldspar + RFC 1952 GZIP file format specification version 4.3 + TAR Format. Information from File Format List 2.0 by Max Maischein. + RFC 1950 ZLIB Compressed Data Format Specification version 3.3 + PNG (Portable Network Graphics) Specification version 1.0 + Michael Dipperstein's Huffman Code Page + +Жду ваших замечаний и предложений на одноименной ветке раздела "Кодинг" форума +meos.sysbin.com + +До новых встреч! diff --git a/programs/other/archer/trunk/arcmacro.inc b/programs/other/outdated/archer/trunk/arcmacro.inc similarity index 95% rename from programs/other/archer/trunk/arcmacro.inc rename to programs/other/outdated/archer/trunk/arcmacro.inc index 65894961d6..32852881ac 100644 --- a/programs/other/archer/trunk/arcmacro.inc +++ b/programs/other/outdated/archer/trunk/arcmacro.inc @@ -1,439 +1,439 @@ -; @RCHER macros and messages -; Written in pure assembler by Ivushkin Andrey aka Willow - -macro stop -{ - if SYS eq win & NO_STOPS eq 0 - int3 - end if -} - -macro wait -{ -if ~ SYS eq win -local .nodrw,.ex - pusha - mcall 10 - cmp eax,1 - jne .nodrw - call draw_window - .nodrw: - mcall 17 - .ex: - popa -end if -} - -macro rbits dest,cnt -{ - if ~ cnt eq - mov ecx,cnt - end if - if dest eq 0 - xor eax,eax - else - mov eax,dest - end if - call read_bits -} - - -macro rep_err cond_ok, result, msg -{ - local .m - j#cond_ok .m - if ~ msg eq - Msg msg - end if - mov edx,result - jmp .err - .m: -} - -macro memcpy_esi dest, count,_add -{ - push esi - if ~ _add eq - add esi,_add - end if - mov edi,dest - mov ecx,count - rep movsb - pop esi -} - -DebugPrint: -; in: edx-asciiz string ptr - pusha -if SYS eq win - mov ecx,255 - xor eax,eax - mov edi,edx - repne scasb - sub edi,edx - dec edi - invoke WriteConsole,[cons],edx,edi,cparam1,NULL -else - call debug_outstr -end if - popa - ret - -macro DebugPrintDec -{ -if SYS eq win - call int2str - mov edx,os_work - call DebugPrint -else - call debug_outdec -end if -} - -macro Newline -{ -if SYS eq win - pusha - invoke WriteConsole,[cons],cr_lf,2,cparam1,NULL - popa -else - newline -end if -} - -Msgcall: -; edx - msg number - pusha - movzx edx,word[strs+edx*2] - add edx,msgs - call DebugPrint - popa - ret - -macro Msg num -{ - if ~ num eq edx - mov edx,num - end if - call Msgcall -} - -MSG_COUNT=0 -macro str_table [str] -{ - forward - local label - dw label-msgs - common - msgs: - forward - label db str,0 - MSG_COUNT=MSG_COUNT+1 -} - - - -strs: -if language eq ru -str_table \ - <'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0 - <'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1 - 'Файлов в архиве: ',\ ;2 - <'End of Directory достигнут',13,10>,\ ;3 - 'Нет файла с таким номером',\ ;4 - <'FindByNumber ОК',13,10>,\ ;5 - <'Неверный ID блока Хаффмана',13,10>,\ ;6 - <'Ошибка в кодах Хаффмана!',13,10>,\ ;7 - <13,10,'Расчет таблицы CRC32',13,10>,\ ;8 - '.',\ ;9 - 'Adler32',\ ;10 - 'CRC32',\ ;11 - <'Завершено.',13,10>,\ ;12 - <'Файл имеет нулевую длину, распаковка отменена.',13,10>,\ ;13 - <'Странная длина файла-источника. Ошибка в имени? Отмена.',13,10>,\ ;14 - <'Не GZIP архив',13,10>,\ ;15 - <'Слишком большой размер выходного файла',13,10>,\ ;16 - <"Ошибка при распаковке.",13,10>,\ ; 17 - <'Не рисунок PNG',13,10>,\ ; 18 - <13,10,'*д'>,\ ;19 - <13,10,'*с'>,\ ;20 - 'Неожиданный конец блоков IDAT',\ ;21 - 'Дефильтрация:',\ ;22 - 'Фильтры: None ',\ ;23 - ' Sub ',\ ;24 - ' Up ',\ ;25 - ' Avg ',\ ;26 - ' Paeth ',\ ;27 - ' Ошибок: ',\ ;28 - <'Чересстрочный PNG',13,10>,\ ;29 - <'Блок без сжатия',13,10>,\ ;30 - <'Тип цвета не поддерживается',13,10>,\ ;31 - <'Введите пароль для зашифрованного файла:',13,10>,\ ;32 - <'Поиск файла...',13,10>,\ ;33 - 'Не модуль SFX',\ ;34 - ' неверна! ',\ ;35 - ' OK: ',\ ;36 - <'Запись OUT.TXT',13,10>,\ ;37 - ' ',\ ;38 - <'Подготовка изображения...',13,10>,\ ;39 - <'Укажите "R" для обработки сырых данных. Отмена.',13,10>,\ ;40 - <'Не хватает памяти! Отмена.',13,10>,\ ; 41 - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' <- неизвестный метод сжатия',\ ;50 - ' <- зашифрован',\ ;51 - <'Не ZIP архив',13,10> ; 52 -else -str_table \ - <'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0 - <'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1 - 'Files in archive: ',\ ;2 - <'End of Directory reached',13,10>,\ ;3 - 'No file has this number',\ ;4 - <'FindByNumber succeded',13,10>,\ ;5 - <'Invalid Huffman block ID',13,10>,\ ;6 - <'Error while getting Huffman codes!',13,10>,\ ;7 - <13,10,'Rebuilding CRC32 table',13,10>,\ ;8 - '.',\ ;9 - 'Adler32',\ ;10 - 'CRC32',\ ;11 - <'Job finished.',13,10>,\ ;12 - <'File of zero length, unpacking aborted.',13,10>,\ ;13 - <'Source file has strange length, may be missing? Abort.',13,10>,\ ;14 - <'Not a GZIP archive',13,10>,\ ;15 - <'Destination file is too large for now',13,10>,\ ;16 - <"Can't unpack content.",13,10>,\ ; 17 - <'Not a PNG image',13,10>,\ ; 18 - <13,10,'*d'>,\ ;19 - <13,10,'*s'>,\ ;20 - 'Unexpected end of IDAT chunks',\ ;21 - 'Unfiltering:',\ ;22 - 'Filters: None ',\ ;23 - ' Sub ',\ ;24 - ' Up ',\ ;25 - ' Avg ',\ ;26 - ' Paeth ',\ ;27 - ' Invalid ',\ ;28 - <'Interlaced PNG',13,10>,\ ;29 - <'Stored block',13,10>,\ ;30 - <'Color type not supported',13,10>,\ ;31 - <'Enter password for encrypted file:',13,10>,\ ;32 - <'Searching for file...',13,10>,\ ;33 - 'Not a SFX module',\ ;34 - ' error! ',\ ;35 - ' OK: ',\ ;36 - <'Creating OUT.TXT',13,10>,\ ;37 - ' ',\ ;38 - <'Preparing bitmap...',13,10>,\ ;39 - <'Specify "R" to force raw data. Abort.',13,10>,\ ;40 - <'Not enough memory! Abort.',13,10>,\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' ',\ ; - ' <- unknown compression method',\ ;50 - ' <- encrypted',\ ;51 - <'Not a ZIP archive',13,10> ; 52 -end if - -macro opendialog redproc,openoff,erroff,path -{ -local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc -local run_fileinfo, param -local getmesloop, loox, mred, mkey, mbutton, mgetmes -local dlg_is_work, ready -; -; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, -; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) -; - - cld -;; mov esi,path - mov edi,path - xor eax,eax - mov ecx,(1024+16)/4 - rep stosd - -;mov [get_loops],0 -mov [dlg_pid_get],0 - -; Get my PID in dec format 4 bytes - mcall 9,os_work,-1 - -; convert eax bin to param dec - mov eax,dword [os_work+30] ;offset of myPID - mov edi,param+4-1 ;offset to 4 bytes - mov ecx,4 - mov ebx,10 - cld -new_d: - xor edx,edx - div ebx - add dl,'0' - mov [edi],dl - dec edi - loop new_d - -; write 1 byte space to param - mov [param+4],byte 32 ;Space for next parametr -; and 1 byte type of dialog to param - mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) - -; -; STEP2 prepare IPC area for get messages -; - -; prepare IPC area - mov [path],dword 0 - mov [path+4],dword 8 - -; define IPC memory - mov eax,60 - mov ebx,1 ; define IPC - mov ecx,path ; offset of area - mov edx,1024+16 ; size - mcall - - mcall 40,1000111b -; -; STEP 3 run SYSTEM XTREE with parameters -; - - mcall 70,run_fileinfo - - call redproc - - mov [get_loops],0 -getmesloop: - mov eax,23 - mov ebx,50 ;0.5 sec - mcall - dec eax - jz mred - dec eax - jz mkey - dec eax - jz mbutton - cmp al, 7-3 - jz mgetmes - -; Get number of procces - mcall 9,os_work,-1 - mov ebp,eax - -loox: - mcall 9,os_work,ebp - mov eax,[DLGPID] - cmp dword[os_work+30],eax ;IF Dialog find - je dlg_is_work ;jmp to dlg_is_work - dec ebp - jnz loox - - jmp erroff - -dlg_is_work: - cmp word[os_work+50],word 9 ;If slot state 9 - dialog is terminated - je erroff ;TESTODP2 terminated too - - cmp [dlg_pid_get],dword 1 - je getmesloop - inc [get_loops] - cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated - jae erroff - jmp getmesloop - -mred: - call redproc - jmp getmesloop -mkey: - mcall 2 ; read (eax=2) - jmp getmesloop -mbutton: - mov eax,17 ; get id - mcall - cmp ah,1 ; button id=1 ? - jne getmesloop - mov eax,-1 ; close this program - mcall -mgetmes: -; If dlg_pid_get then second message get jmp to still - cmp [dlg_pid_get],dword 1 - je ready - -; First message is number of PID SYSXTREE dialog - -; convert PID dec to PID bin - movzx eax,byte [path+16] - sub eax,48 - imul eax,10 - movzx ebx,byte [path+16+1] - add eax,ebx - sub eax,48 - imul eax,10 - movzx ebx,byte [path+16+2] - add eax,ebx - sub eax,48 - imul eax,10 - movzx ebx,byte [path+16+3] - add eax,ebx - sub eax,48 - mov [DLGPID],eax - -; Claear and prepare IPC area for next message - mov [path],dword 0 - mov [path+4],dword 8 - mov [path+8],dword 0 - mov [path+12],dword 0 - mov [path+16],dword 0 - -; Set dlg_pid_get for get next message - mov [dlg_pid_get],dword 1 - call redproc ;show DLG_PID - jmp getmesloop - -ready: -; -; The second message get -; Second message is 1024 bytes path to SAVE/OPEN file -; shl path string on 16 bytes -; - cld - mov esi,path+16 - mov edi,path - mov ecx,1024/4 - rep movsd - mov [edi],byte 0 - - jmp openoff - - -; DATA AREA -get_loops dd 0 -dlg_pid_get dd 0 -DLGPID dd 0 - -param: - dd 0 ; My dec PID - dd 0,0 ; Type of dialog - -run_fileinfo: - dd 7 - dd 0 - dd param - dd 0 - dd 0 -;run_filepath - db '/sys/SYSXTREE',0 - -} - +; @RCHER macros and messages +; Written in pure assembler by Ivushkin Andrey aka Willow + +macro stop +{ + if SYS eq win & NO_STOPS eq 0 + int3 + end if +} + +macro wait +{ +if ~ SYS eq win +local .nodrw,.ex + pusha + mcall 10 + cmp eax,1 + jne .nodrw + call draw_window + .nodrw: + mcall 17 + .ex: + popa +end if +} + +macro rbits dest,cnt +{ + if ~ cnt eq + mov ecx,cnt + end if + if dest eq 0 + xor eax,eax + else + mov eax,dest + end if + call read_bits +} + + +macro rep_err cond_ok, result, msg +{ + local .m + j#cond_ok .m + if ~ msg eq + Msg msg + end if + mov edx,result + jmp .err + .m: +} + +macro memcpy_esi dest, count,_add +{ + push esi + if ~ _add eq + add esi,_add + end if + mov edi,dest + mov ecx,count + rep movsb + pop esi +} + +DebugPrint: +; in: edx-asciiz string ptr + pusha +if SYS eq win + mov ecx,255 + xor eax,eax + mov edi,edx + repne scasb + sub edi,edx + dec edi + invoke WriteConsole,[cons],edx,edi,cparam1,NULL +else + call debug_outstr +end if + popa + ret + +macro DebugPrintDec +{ +if SYS eq win + call int2str + mov edx,os_work + call DebugPrint +else + call debug_outdec +end if +} + +macro Newline +{ +if SYS eq win + pusha + invoke WriteConsole,[cons],cr_lf,2,cparam1,NULL + popa +else + newline +end if +} + +Msgcall: +; edx - msg number + pusha + movzx edx,word[strs+edx*2] + add edx,msgs + call DebugPrint + popa + ret + +macro Msg num +{ + if ~ num eq edx + mov edx,num + end if + call Msgcall +} + +MSG_COUNT=0 +macro str_table [str] +{ + forward + local label + dw label-msgs + common + msgs: + forward + label db str,0 + MSG_COUNT=MSG_COUNT+1 +} + + + +strs: +if language eq ru +str_table \ + <'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0 + <'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1 + 'Файлов в архиве: ',\ ;2 + <'End of Directory достигнут',13,10>,\ ;3 + 'Нет файла с таким номером',\ ;4 + <'FindByNumber ОК',13,10>,\ ;5 + <'Неверный ID блока Хаффмана',13,10>,\ ;6 + <'Ошибка в кодах Хаффмана!',13,10>,\ ;7 + <13,10,'Расчет таблицы CRC32',13,10>,\ ;8 + '.',\ ;9 + 'Adler32',\ ;10 + 'CRC32',\ ;11 + <'Завершено.',13,10>,\ ;12 + <'Файл имеет нулевую длину, распаковка отменена.',13,10>,\ ;13 + <'Странная длина файла-источника. Ошибка в имени? Отмена.',13,10>,\ ;14 + <'Не GZIP архив',13,10>,\ ;15 + <'Слишком большой размер выходного файла',13,10>,\ ;16 + <"Ошибка при распаковке.",13,10>,\ ; 17 + <'Не рисунок PNG',13,10>,\ ; 18 + <13,10,'*д'>,\ ;19 + <13,10,'*с'>,\ ;20 + 'Неожиданный конец блоков IDAT',\ ;21 + 'Дефильтрация:',\ ;22 + 'Фильтры: None ',\ ;23 + ' Sub ',\ ;24 + ' Up ',\ ;25 + ' Avg ',\ ;26 + ' Paeth ',\ ;27 + ' Ошибок: ',\ ;28 + <'Чересстрочный PNG',13,10>,\ ;29 + <'Блок без сжатия',13,10>,\ ;30 + <'Тип цвета не поддерживается',13,10>,\ ;31 + <'Введите пароль для зашифрованного файла:',13,10>,\ ;32 + <'Поиск файла...',13,10>,\ ;33 + 'Не модуль SFX',\ ;34 + ' неверна! ',\ ;35 + ' OK: ',\ ;36 + <'Запись OUT.TXT',13,10>,\ ;37 + ' ',\ ;38 + <'Подготовка изображения...',13,10>,\ ;39 + <'Укажите "R" для обработки сырых данных. Отмена.',13,10>,\ ;40 + <'Не хватает памяти! Отмена.',13,10>,\ ; 41 + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' <- неизвестный метод сжатия',\ ;50 + ' <- зашифрован',\ ;51 + <'Не ZIP архив',13,10> ; 52 +else +str_table \ + <'*** @RCHER - Deflate Unpacker ***',13,10>,\ ;0 + <'*** Copyright Wiland Inc., 2005 ***',13,10>,\ ;1 + 'Files in archive: ',\ ;2 + <'End of Directory reached',13,10>,\ ;3 + 'No file has this number',\ ;4 + <'FindByNumber succeded',13,10>,\ ;5 + <'Invalid Huffman block ID',13,10>,\ ;6 + <'Error while getting Huffman codes!',13,10>,\ ;7 + <13,10,'Rebuilding CRC32 table',13,10>,\ ;8 + '.',\ ;9 + 'Adler32',\ ;10 + 'CRC32',\ ;11 + <'Job finished.',13,10>,\ ;12 + <'File of zero length, unpacking aborted.',13,10>,\ ;13 + <'Source file has strange length, may be missing? Abort.',13,10>,\ ;14 + <'Not a GZIP archive',13,10>,\ ;15 + <'Destination file is too large for now',13,10>,\ ;16 + <"Can't unpack content.",13,10>,\ ; 17 + <'Not a PNG image',13,10>,\ ; 18 + <13,10,'*d'>,\ ;19 + <13,10,'*s'>,\ ;20 + 'Unexpected end of IDAT chunks',\ ;21 + 'Unfiltering:',\ ;22 + 'Filters: None ',\ ;23 + ' Sub ',\ ;24 + ' Up ',\ ;25 + ' Avg ',\ ;26 + ' Paeth ',\ ;27 + ' Invalid ',\ ;28 + <'Interlaced PNG',13,10>,\ ;29 + <'Stored block',13,10>,\ ;30 + <'Color type not supported',13,10>,\ ;31 + <'Enter password for encrypted file:',13,10>,\ ;32 + <'Searching for file...',13,10>,\ ;33 + 'Not a SFX module',\ ;34 + ' error! ',\ ;35 + ' OK: ',\ ;36 + <'Creating OUT.TXT',13,10>,\ ;37 + ' ',\ ;38 + <'Preparing bitmap...',13,10>,\ ;39 + <'Specify "R" to force raw data. Abort.',13,10>,\ ;40 + <'Not enough memory! Abort.',13,10>,\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' ',\ ; + ' <- unknown compression method',\ ;50 + ' <- encrypted',\ ;51 + <'Not a ZIP archive',13,10> ; 52 +end if + +macro opendialog redproc,openoff,erroff,path +{ +local new_d, get_loops, dlg_pid_get, DLGPID, num_of_proc +local run_fileinfo, param +local getmesloop, loox, mred, mkey, mbutton, mgetmes +local dlg_is_work, ready +; +; STEP 1 Run SYSXTREE with parametrs MYPID 4 bytes in dec, +; 1 byte space, 1 byte type of dialog (O - Open ,S - Save) +; + + cld +;; mov esi,path + mov edi,path + xor eax,eax + mov ecx,(1024+16)/4 + rep stosd + +;mov [get_loops],0 +mov [dlg_pid_get],0 + +; Get my PID in dec format 4 bytes + mcall 9,os_work,-1 + +; convert eax bin to param dec + mov eax,dword [os_work+30] ;offset of myPID + mov edi,param+4-1 ;offset to 4 bytes + mov ecx,4 + mov ebx,10 + cld +new_d: + xor edx,edx + div ebx + add dl,'0' + mov [edi],dl + dec edi + loop new_d + +; write 1 byte space to param + mov [param+4],byte 32 ;Space for next parametr +; and 1 byte type of dialog to param + mov [param+5],byte 'O' ;Get Open dialog (Use 'S' for Save dialog) + +; +; STEP2 prepare IPC area for get messages +; + +; prepare IPC area + mov [path],dword 0 + mov [path+4],dword 8 + +; define IPC memory + mov eax,60 + mov ebx,1 ; define IPC + mov ecx,path ; offset of area + mov edx,1024+16 ; size + mcall + + mcall 40,1000111b +; +; STEP 3 run SYSTEM XTREE with parameters +; + + mcall 70,run_fileinfo + + call redproc + + mov [get_loops],0 +getmesloop: + mov eax,23 + mov ebx,50 ;0.5 sec + mcall + dec eax + jz mred + dec eax + jz mkey + dec eax + jz mbutton + cmp al, 7-3 + jz mgetmes + +; Get number of procces + mcall 9,os_work,-1 + mov ebp,eax + +loox: + mcall 9,os_work,ebp + mov eax,[DLGPID] + cmp dword[os_work+30],eax ;IF Dialog find + je dlg_is_work ;jmp to dlg_is_work + dec ebp + jnz loox + + jmp erroff + +dlg_is_work: + cmp word[os_work+50],word 9 ;If slot state 9 - dialog is terminated + je erroff ;TESTODP2 terminated too + + cmp [dlg_pid_get],dword 1 + je getmesloop + inc [get_loops] + cmp [get_loops],4 ;2 sec if DLG_PID not get, TESTOP2 terminated + jae erroff + jmp getmesloop + +mred: + call redproc + jmp getmesloop +mkey: + mcall 2 ; read (eax=2) + jmp getmesloop +mbutton: + mov eax,17 ; get id + mcall + cmp ah,1 ; button id=1 ? + jne getmesloop + mov eax,-1 ; close this program + mcall +mgetmes: +; If dlg_pid_get then second message get jmp to still + cmp [dlg_pid_get],dword 1 + je ready + +; First message is number of PID SYSXTREE dialog + +; convert PID dec to PID bin + movzx eax,byte [path+16] + sub eax,48 + imul eax,10 + movzx ebx,byte [path+16+1] + add eax,ebx + sub eax,48 + imul eax,10 + movzx ebx,byte [path+16+2] + add eax,ebx + sub eax,48 + imul eax,10 + movzx ebx,byte [path+16+3] + add eax,ebx + sub eax,48 + mov [DLGPID],eax + +; Claear and prepare IPC area for next message + mov [path],dword 0 + mov [path+4],dword 8 + mov [path+8],dword 0 + mov [path+12],dword 0 + mov [path+16],dword 0 + +; Set dlg_pid_get for get next message + mov [dlg_pid_get],dword 1 + call redproc ;show DLG_PID + jmp getmesloop + +ready: +; +; The second message get +; Second message is 1024 bytes path to SAVE/OPEN file +; shl path string on 16 bytes +; + cld + mov esi,path+16 + mov edi,path + mov ecx,1024/4 + rep movsd + mov [edi],byte 0 + + jmp openoff + + +; DATA AREA +get_loops dd 0 +dlg_pid_get dd 0 +DLGPID dd 0 + +param: + dd 0 ; My dec PID + dd 0,0 ; Type of dialog + +run_fileinfo: + dd 7 + dd 0 + dd param + dd 0 + dd 0 +;run_filepath + db '/sys/SYSXTREE',0 + +} + diff --git a/programs/other/archer/trunk/build_en.bat b/programs/other/outdated/archer/trunk/build_en.bat similarity index 100% rename from programs/other/archer/trunk/build_en.bat rename to programs/other/outdated/archer/trunk/build_en.bat diff --git a/programs/other/archer/trunk/build_ru.bat b/programs/other/outdated/archer/trunk/build_ru.bat similarity index 100% rename from programs/other/archer/trunk/build_ru.bat rename to programs/other/outdated/archer/trunk/build_ru.bat diff --git a/programs/other/archer/trunk/data.inc b/programs/other/outdated/archer/trunk/data.inc similarity index 94% rename from programs/other/archer/trunk/data.inc rename to programs/other/outdated/archer/trunk/data.inc index a507020bbe..11886c8c89 100644 --- a/programs/other/archer/trunk/data.inc +++ b/programs/other/outdated/archer/trunk/data.inc @@ -1,182 +1,182 @@ -; @RCHER data area -; Written in pure assembler by Ivushkin Andrey aka Willow - -if SYS eq win - dumpfile: - db 'D:\Ivushkin\projects\zip\output.dmp',0 - dumpf_len=$-dumpfile -end if -outfile: -if SYS eq win - db 'D:\Ivushkin\projects\zip\output.raw',0 -end if - dd 2 - dd 0 - dd 0 - .size dd 0 - .out dd output -if ~SYS eq win - dumpfile: - db DUMPFILE,0 - dumpf_len=$-dumpfile -end if -attrinfo: - dd 5 - dd 0 - dd 0 - dd 0 - dd fileattr - db 0 - dd filename -Finfo: - dd 0 - .block dd 0 - dd 0 - .count dd BUFSIZE*1024 - .ptr dd BUFPTR - -filename: -if SYS eq win -db 'png\absolut0.png',0 -;db 'fasm-1.54.tgz',0 -;include 'testsu~1.inc' -; db 'pngsuite\pngsuite.tar.gz',0 ; OK -; db 'pngsuite\basn4a08.png',0 ; OK -; db 'goldhill.png',0 ; beeping -; db 'arl_logo.png',0 ; wrong out -; db 'tech.png',0 ; wrong out -; db 'png\lena0000.png',0 -; db 'arcs\' -; db 'NTOSKRNL.gz' -; db 'msg_enc.zip' - ;db 'msgplain.zip' -; db 'c_866.gz' -; db 'zalman_2.png' ;OK -; db 'arcs\headerbar.png',0 ;OK -; db 'fonts1.png' ;OK -; db 'fonts.png' ; -; db 'skin.png' ;OK -; db 'JavaPowered8.png'; OK -; db 'opr008S8.png' -; db 'goldhill.png' -; db 'k3b.png',0 -; db 'image0051.png' -; db 'window-elements.png',0 -; db 'WWW.zip',0 -; db 'png.zip',0 -; db 'zlib09.zip',0 - -else - if ~ FNAME eq - db FNAME - end if -; db '/hd/1/zip/png.zip',0 -; db '/hd/1/zip/files/opossum.png' -; db '/rd/1/www.zip',0 -; db '/hd/1/zip/test2.zip',0 -end if - db 0 -I_END: -rb 1024+16-($-filename) - -if SYS eq win - cr_lf db 0xa,0xd - hnd dd ? - cons dd ? - cons_in dd ? - cparam1 dd ? - cparam2 dd ? -end if - -DKeys rd 3 -Dheader rb 12 -Dpassword rb PASSW_LEN - -if ~SYS eq win -fileattr rd 40/4 -end if - -png_ dd ? -fat_ dd ? -fat_fnum dd ? -lpath dd ? -lpath_len dd ? -png_bpp dd ? -sline_len dd ? -IDATcount dd ? -IDATsize dd ? -PNG_info: - .Width dd ? - .Height dd ? - .Bit_depth db ? - .Color_type db ? - .Compression_method db ? - .Filter_method db ? - .Interlace_method db ? - .Palette rb 3*256 -gpbf dw ? -file_count dd ? -filters rd 6 -arc_base dd ? -outp dd ? -unp_size dd ? -CRC_check dd ? -_CRC32_ dd ? -CRC32table rd 256 -Adler32 dd ? -child dd ? -clientPID dd ? - -filesize dd ? -bits db ? -cur_byte dd ? -lastblk db ? -Flags dd ? -tblCount dw ? -tblLen dw ? -hclen db ? -max_len dw ? - -align 4 -fat: - rb 4096;512 -child_stack: - rb 1024 -child_stack_top: -main_stack: - rb 1024 -main_stack_top: -area: - rb INBUF -os_work rb 4*1024 - -bl_count rb BITS - -next_code rw BITS -tmp_clit: - rw 20 -calph: - rw 20 -sorted_clit rw 20 - -seql_c db ? -seql rb BITS - -seqd_c db ? -seqd rb BITS - -hlit dw ? -Literal rw 286 -Lit_c rw 286 - -hdist db ? -Distance rw 32 -Dist_c rw 32 - -output: -;rb OUTBUF - -;png_image: -if SYS eq win - rb OUTBUF -end if +; @RCHER data area +; Written in pure assembler by Ivushkin Andrey aka Willow + +if SYS eq win + dumpfile: + db 'D:\Ivushkin\projects\zip\output.dmp',0 + dumpf_len=$-dumpfile +end if +outfile: +if SYS eq win + db 'D:\Ivushkin\projects\zip\output.raw',0 +end if + dd 2 + dd 0 + dd 0 + .size dd 0 + .out dd output +if ~SYS eq win + dumpfile: + db DUMPFILE,0 + dumpf_len=$-dumpfile +end if +attrinfo: + dd 5 + dd 0 + dd 0 + dd 0 + dd fileattr + db 0 + dd filename +Finfo: + dd 0 + .block dd 0 + dd 0 + .count dd BUFSIZE*1024 + .ptr dd BUFPTR + +filename: +if SYS eq win +db 'png\absolut0.png',0 +;db 'fasm-1.54.tgz',0 +;include 'testsu~1.inc' +; db 'pngsuite\pngsuite.tar.gz',0 ; OK +; db 'pngsuite\basn4a08.png',0 ; OK +; db 'goldhill.png',0 ; beeping +; db 'arl_logo.png',0 ; wrong out +; db 'tech.png',0 ; wrong out +; db 'png\lena0000.png',0 +; db 'arcs\' +; db 'NTOSKRNL.gz' +; db 'msg_enc.zip' + ;db 'msgplain.zip' +; db 'c_866.gz' +; db 'zalman_2.png' ;OK +; db 'arcs\headerbar.png',0 ;OK +; db 'fonts1.png' ;OK +; db 'fonts.png' ; +; db 'skin.png' ;OK +; db 'JavaPowered8.png'; OK +; db 'opr008S8.png' +; db 'goldhill.png' +; db 'k3b.png',0 +; db 'image0051.png' +; db 'window-elements.png',0 +; db 'WWW.zip',0 +; db 'png.zip',0 +; db 'zlib09.zip',0 + +else + if ~ FNAME eq + db FNAME + end if +; db '/hd/1/zip/png.zip',0 +; db '/hd/1/zip/files/opossum.png' +; db '/rd/1/www.zip',0 +; db '/hd/1/zip/test2.zip',0 +end if + db 0 +I_END: +rb 1024+16-($-filename) + +if SYS eq win + cr_lf db 0xa,0xd + hnd dd ? + cons dd ? + cons_in dd ? + cparam1 dd ? + cparam2 dd ? +end if + +DKeys rd 3 +Dheader rb 12 +Dpassword rb PASSW_LEN + +if ~SYS eq win +fileattr rd 40/4 +end if + +png_ dd ? +fat_ dd ? +fat_fnum dd ? +lpath dd ? +lpath_len dd ? +png_bpp dd ? +sline_len dd ? +IDATcount dd ? +IDATsize dd ? +PNG_info: + .Width dd ? + .Height dd ? + .Bit_depth db ? + .Color_type db ? + .Compression_method db ? + .Filter_method db ? + .Interlace_method db ? + .Palette rb 3*256 +gpbf dw ? +file_count dd ? +filters rd 6 +arc_base dd ? +outp dd ? +unp_size dd ? +CRC_check dd ? +_CRC32_ dd ? +CRC32table rd 256 +Adler32 dd ? +child dd ? +clientPID dd ? + +filesize dd ? +bits db ? +cur_byte dd ? +lastblk db ? +Flags dd ? +tblCount dw ? +tblLen dw ? +hclen db ? +max_len dw ? + +align 4 +fat: + rb 4096;512 +child_stack: + rb 1024 +child_stack_top: +main_stack: + rb 1024 +main_stack_top: +area: + rb INBUF +os_work rb 4*1024 + +bl_count rb BITS + +next_code rw BITS +tmp_clit: + rw 20 +calph: + rw 20 +sorted_clit rw 20 + +seql_c db ? +seql rb BITS + +seqd_c db ? +seqd rb BITS + +hlit dw ? +Literal rw 286 +Lit_c rw 286 + +hdist db ? +Distance rw 32 +Dist_c rw 32 + +output: +;rb OUTBUF + +;png_image: +if SYS eq win + rb OUTBUF +end if diff --git a/programs/other/archer/trunk/deflate.inc b/programs/other/outdated/archer/trunk/deflate.inc similarity index 94% rename from programs/other/archer/trunk/deflate.inc rename to programs/other/outdated/archer/trunk/deflate.inc index fb16b85b2c..52c33f6607 100644 --- a/programs/other/archer/trunk/deflate.inc +++ b/programs/other/outdated/archer/trunk/deflate.inc @@ -1,615 +1,615 @@ -; @RCHER main algorythm -; Written in pure assembler by Ivushkin Andrey aka Willow - -macro get_a _type,_size,c1,c2,c3,c4,c5 -{ -get_#_type: -local .no,.no0,.ex - push edx - and [Flags],not 1 -if _type eq Len - cmp eax,c4 - jne .no - mov eax,c5 - jmp .ex - .no: -end if - sub eax,c1 - ja .no0 - add eax,c2 - jmp .ex - .no0: - add eax,c3 - push eax - mov ecx,eax - shr ecx,_size - xor eax,eax - call read_bits - pop edx - and edx,1 shl _size-1 - shl edx,cl - movzx ecx,[tblH#_type+ecx*2] - add edx,ecx - add eax,edx - .ex: - or [Flags],1 - pop edx - ret -} -; ************************* - -Deflate: - mov edi,[outp] - .init: - mov [bits],8 - lodsb - call setcurb - .blkbegin: - and [lastblk],0 - and [Flags],not 1 - rbits 0,1 - test eax,eax - je .nolast - mov [lastblk],1 - .nolast: - rbits 0,2 - cmp eax,10b - je .DynHuff - cmp eax,01b - je .static - test eax,eax - jnz .errorID - Msg 30 - movzx ecx,[bits] - call read_bits - movzx ecx,word[esi-1] - add esi,3 - rep movsb - jmp .check_last - .errorID: - Msg 6 - ret -; Static Huffman - .static: -if SHOW_METH eq 1 - Msg 20 -end if - mov edi,[outp] - or [Flags],1 - .next: - rbits 0,7 -; stop - cmp eax,0x17 - ja .no7 - add eax,256 - cmp eax,256 - jne .noend - .check_last: - mov [outp],edi - cmp [lastblk],1 - je .ex - jmp .blkbegin - .noend: - call get_Len - mov ebx,eax - rbits 0,5 - call get_Dist - neg eax - push esi - lea esi,[edi+eax] - mov ecx,ebx - rep movsb - pop esi - jmp .next - .no7: - rbits eax,1 - cmp eax,0xc8 - jb .no9 - rbits eax,1 - sub eax,0xd0 - jmp .no81 - .no9: - cmp eax,0xc0 - jb .no81 - add eax,0x58 - jmp .noend - .no81: - sub eax,0x30 - stosb - jmp .next - .ex: - ret -; ************* dynamic Huffman ************ - -.DynHuff: -; dps '##' -if SHOW_METH eq 1 - Msg 19 -end if - pusha - xor eax,eax - mov ecx,(output-bl_count) / 4 - mov edi,bl_count - rep stosd - popa - -; max_len=0 - and [max_len],0 - rbits 0,5 -; hlit-257 - add eax,257 - mov [hlit],ax - rbits 0,5 -; hdist-1 - inc eax - mov [hdist],al - rbits 0,4 -; hclen-4 - add eax,4 - mov [hclen],al - mov ecx,eax - push edi - mov edi,tmp_clit -; read code lengths for code lengths - .alphloop: - push ecx - rbits 0,3 - stosb - pop ecx - loop .alphloop -; sort code lengths for code lengths - push esi - movzx ecx,[hclen] - xor eax,eax - mov edi,tmp_clit - mov esi,tblSort - .sortloop: - lodsb - movzx bx,byte[edi] - mov [sorted_clit+eax*2],bx - inc edi - loop .sortloop - pop esi edi -.generate: - mov ecx,19 - mov ebx,calph - mov edx,seql - mov eax,sorted_clit - call Huffc - and [tblCount],0 - or [Flags],1 - mov edi,Lit_c - mov ebp,sorted_clit - .again: - cmp edi,output+OUTBUF - jb ._ok - Msg 16 - jmp .ex - ._ok: - mov edx,seql - mov ebx,calph - call get_code - call ExpLen - cmp [hlit],ax - ja .again -if SHOW_CHARS eq 1 - mov edi,Lit_c - call Show_codes -end if - mov edi,Dist_c - and [tblCount],0 - .again2: - mov ebx,calph - - call get_code - call ExpLen - cmp [hdist],al - ja .again2 - movzx ecx,[hlit] - mov ebx,Literal - mov edx,seql - mov eax,Lit_c - call Huffc - movzx ecx,[hdist] - mov ebx,Distance - mov edx,seqd - mov eax,Dist_c - call Huffc - - push [hlit] - pop [tblLen] - mov ebp,Lit_c - mov edx,seql - mov ebx,Literal - mov edi,[outp] - and [tblCount],0 - .again3: ; <------------ - call get_code - cmp eax,256 - je .check_last - ja .dist - stosb - jmp .again3 - .dist: - call get_Len - push eax ebx edx ebp - mov ecx,32 - mov ebp,Dist_c - mov edx,seqd - mov ebx,Distance - mov [tblLen],32 - call get_code - call get_Dist - push [hlit] - pop [tblLen] - neg eax - pop ebp edx ebx ecx - push esi - lea esi,[edi+eax] - rep movsb - pop esi - jmp .again3 - -; ****************************************** -Huffc: -; EBX - dest array, ECX - length, EDX - br_seq dest, EAX - source array - push esi edi eax ecx - mov edi,bl_count - xor eax,eax - mov ecx,BITS - rep stosw - pop ecx - mov esi,[esp] - mov [tblLen],cx - mov [max_len],ax -; Count the number of codes for each code length - .cnt_loop: - lodsw - cmp [max_len],ax - jae .skip - mov [max_len],ax - .skip: - inc byte[bl_count+eax] - loop .cnt_loop - movzx ecx,[max_len] - xor eax,eax - and [bl_count],al - xor esi,esi ; edx - bits - mov edi,next_code+2 - push ebx -; Find the numerical value of the smallest code for each code length - .nc_loop: - movzx bx,byte[bl_count+esi] - add ax,bx - shl ax,1 - stosw - inc esi - loop .nc_loop - pop ebx -; clear table - movzx ecx,[tblLen] - xor eax,eax - dec eax - mov edi,ebx - rep stosw - inc eax - movzx ecx,[tblLen] - mov esi,[esp] - mov edi,ebx -; Assign numerical values to all codes - .loop3: - lodsw - test eax,eax - jz .lp - push [next_code+eax*2] - pop word[edi] - inc [next_code+eax*2] - .lp: - add edi,2 - loop .loop3 -; Clear all codes - xor eax,eax - mov edi,edx - movzx ecx,[max_len] - mov [edi-1],al -; Prepare read bit sequences - .rebiloop: - inc eax - cmp [bl_count+eax],0 - jz .sk - stosb - inc byte[edx-1] - .sk: - loop .rebiloop - movzx ecx,byte[edx-1] - dec ecx - jecxz .noreb2 - .reb2loop: - mov al,[edx+ecx-1] - sub [edx+ecx],al - loop .reb2loop - .noreb2: - pop eax edi esi - ret - -; ****************************************** - -; get Codes of variable sizes -get_code: -; EDX - br_seq, EBX - source table, EBP - codelength table - push edx edi - xor eax,eax - movzx ecx,byte[edx-1] - mov [codel],ax - .rb3: - push ecx - movzx ecx,byte[edx] - add [codel],cx - call read_bits - movzx ecx,[tblLen] - inc ecx - mov edi,ebx - .scas: - repne scasw - jecxz .notfound - push edi ecx - sub edi,ebx - sub edi,2 - mov cx,[codel] - cmp cx,[ds:ebp+edi] - jne .notfound2 - mov eax,edi - shr eax,1 - add esp,12 - .pp: - pop edi edx - ret - .notfound2: - pop ecx - pop edi - jmp .scas - .notfound: - pop ecx - inc edx - loop .rb3 - Msg 7 - jmp .pp - -codel dw ? -; ****************************************** -ExpLen: - cmp eax,16 - jae .noliteral - inc [tblCount] - stosw - jmp .nomatch - .noliteral: - and [Flags],not 1 - mov ebx,3 - cmp eax,17 - jae .code1718 - mov ecx,2 - xor eax,eax - call read_bits - lea ecx,[eax+ebx] - mov ax,[edi-2] - .cc: - add [tblCount],cx - rep stosw - or [Flags],1 - jmp .nomatch - .code1718: - jne .code18 - mov ecx,3 - .cc2: - xor eax,eax - call read_bits - lea ecx,[eax+ebx] - xor eax,eax - jmp .cc - .code18: - mov ebx,11 - mov ecx,7 - jmp .cc2 - .nomatch: - mov ax,[tblCount] - ret -get_a Len,2,256+8,10,3,285,258 -get_a Dist,1,3,4,1 - - -; ****************************************** -read_bits: ; eax-dest; ecx-count - push edx ecx - .shift: - if RBLOCK eq 4 - ror [cur_byte],1 - else - ror byte[cur_byte],1 - end if - pushf - test [Flags],1 - je .noh1 - popf - rcl eax,1 - jmp .dec - .noh1: - popf - rcr eax,1 - .dec: - dec [bits] - jnz .loop1 - .push: - push eax - mov eax,[esi] - call setcurb - pop eax - if RBLOCK eq 1 - inc esi - inc [IDATcount] - else - inc esi - inc [IDATcount] - end if - cmp esi,area+INBUF-BSIZE - jbe .ok - pusha -if SHOW_RBLOCK eq 1 - Msg 9 -end if - mov eax,0 - mov ebx,1 - call FileSeek - mov [esp+4],esi - popa - .ok: - test [Flags],PNG_MODE - jz .idatok - mov edx,[IDATcount] - cmp edx,[IDATsize] - jbe .idatok - pusha - lodsd - call PngParse.nxt_sec - mov [IDATcount],1 - mov [esp+4],esi - mov [esp+20],edx - popa - cmp edx,21 - jne .idatok - mov eax,256 - pop ecx - jmp .exx - .idatok: - - mov [bits],8 - .loop1: - loop .shift2 - jmp .popc - .shift2: - jmp .shift - .popc: - pop ecx - test [Flags],1 - jne .exx - .noh2: - rol eax,cl - .exx: - pop edx - ret - -if SHOW_CHARS eq 1 -Show_codes: - pusha - movzx ecx,[tblLen] - mov ecx,256 - xor eax,eax - .lp2: - mov [braces+1],al - push eax ecx - invoke StrFormat,eax,strbuf,20 - invoke WriteConsole,[cons],strbuf,16,param1,NULL - invoke WriteConsole,[cons],braces,6,param1,NULL - mov eax,[esp+4] - movzx eax,word[edi+eax*2] - test eax,eax - jz .skip - invoke WriteConsole,[cons],exist,6,param1,NULL - .skip: - invoke WriteConsole,[cons],braces+6,2,param1,NULL - pop ecx eax - inc eax - loop .lp - jmp .ex - .lp: - jmp .lp2 - .ex: - popa - ret - - cons dd ? - param1 dd ? - braces db '( ) = ',0xa, 0xd - strbuf rb 20 - exist db 'exists' -end if - -makeCRC: - pusha - Msg 8 - mov edi,CRC32table - add edi,255*4 - std - mov ecx,255 - mov ebx,0xedb88320 - .m1: - mov eax,ecx - push ecx - mov ecx,8 - .m2: - shr eax,1 - jnc .m3 - xor eax,ebx - .m3: - loop .m2 - pop ecx - stosd - loop .m1 - popa - cld - ret - -UCRC: -; in: esi - data to calculate CRC -; ecx - its length -; [_CRC32_] - previous CRC32 -; out: [_CRC32_]- partial CRC32 (no pre- & post-conditioning!) - pusha - cmp dword[CRC32table+4],0x77073096 - je .tbl_rdy - call makeCRC - .tbl_rdy: - mov eax,[_CRC32_] - not eax - .m1: - movzx ebx,al - shr eax,8 - xor bl,[esi] - xor eax,[CRC32table+ebx*4] - inc esi - loop .m1 - not eax - mov [_CRC32_],eax - popa - ret - -UAdler: -; in: esi - data to calculate CRC -; ecx - its length -; [Adler32] - previous Adler32 -; out: [Adler32]- partial Adler32 - pusha - mov ebp,65521 - movzx ebx,word[Adler32] ; s1-ebx - movzx edi,word[Adler32+2] ; s2-edi - .m1: - movzx eax,byte[esi] - add eax,ebx - xor edx,edx - div ebp - mov ebx,edx - lea eax,[edi+ebx] - xor edx,edx - div ebp - mov edi,edx - inc esi - loop .m1 - shl edi,16 - add edi,ebx - mov [Adler32],edi - popa - ret - -tblSort db 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 -tblHLen dw 7,11,19,35,67,131 -tblHDist dw 3,5,9,17,33,65,129,257,513,1025,2049,4097,8193,16385 +; @RCHER main algorythm +; Written in pure assembler by Ivushkin Andrey aka Willow + +macro get_a _type,_size,c1,c2,c3,c4,c5 +{ +get_#_type: +local .no,.no0,.ex + push edx + and [Flags],not 1 +if _type eq Len + cmp eax,c4 + jne .no + mov eax,c5 + jmp .ex + .no: +end if + sub eax,c1 + ja .no0 + add eax,c2 + jmp .ex + .no0: + add eax,c3 + push eax + mov ecx,eax + shr ecx,_size + xor eax,eax + call read_bits + pop edx + and edx,1 shl _size-1 + shl edx,cl + movzx ecx,[tblH#_type+ecx*2] + add edx,ecx + add eax,edx + .ex: + or [Flags],1 + pop edx + ret +} +; ************************* + +Deflate: + mov edi,[outp] + .init: + mov [bits],8 + lodsb + call setcurb + .blkbegin: + and [lastblk],0 + and [Flags],not 1 + rbits 0,1 + test eax,eax + je .nolast + mov [lastblk],1 + .nolast: + rbits 0,2 + cmp eax,10b + je .DynHuff + cmp eax,01b + je .static + test eax,eax + jnz .errorID + Msg 30 + movzx ecx,[bits] + call read_bits + movzx ecx,word[esi-1] + add esi,3 + rep movsb + jmp .check_last + .errorID: + Msg 6 + ret +; Static Huffman + .static: +if SHOW_METH eq 1 + Msg 20 +end if + mov edi,[outp] + or [Flags],1 + .next: + rbits 0,7 +; stop + cmp eax,0x17 + ja .no7 + add eax,256 + cmp eax,256 + jne .noend + .check_last: + mov [outp],edi + cmp [lastblk],1 + je .ex + jmp .blkbegin + .noend: + call get_Len + mov ebx,eax + rbits 0,5 + call get_Dist + neg eax + push esi + lea esi,[edi+eax] + mov ecx,ebx + rep movsb + pop esi + jmp .next + .no7: + rbits eax,1 + cmp eax,0xc8 + jb .no9 + rbits eax,1 + sub eax,0xd0 + jmp .no81 + .no9: + cmp eax,0xc0 + jb .no81 + add eax,0x58 + jmp .noend + .no81: + sub eax,0x30 + stosb + jmp .next + .ex: + ret +; ************* dynamic Huffman ************ + +.DynHuff: +; dps '##' +if SHOW_METH eq 1 + Msg 19 +end if + pusha + xor eax,eax + mov ecx,(output-bl_count) / 4 + mov edi,bl_count + rep stosd + popa + +; max_len=0 + and [max_len],0 + rbits 0,5 +; hlit-257 + add eax,257 + mov [hlit],ax + rbits 0,5 +; hdist-1 + inc eax + mov [hdist],al + rbits 0,4 +; hclen-4 + add eax,4 + mov [hclen],al + mov ecx,eax + push edi + mov edi,tmp_clit +; read code lengths for code lengths + .alphloop: + push ecx + rbits 0,3 + stosb + pop ecx + loop .alphloop +; sort code lengths for code lengths + push esi + movzx ecx,[hclen] + xor eax,eax + mov edi,tmp_clit + mov esi,tblSort + .sortloop: + lodsb + movzx bx,byte[edi] + mov [sorted_clit+eax*2],bx + inc edi + loop .sortloop + pop esi edi +.generate: + mov ecx,19 + mov ebx,calph + mov edx,seql + mov eax,sorted_clit + call Huffc + and [tblCount],0 + or [Flags],1 + mov edi,Lit_c + mov ebp,sorted_clit + .again: + cmp edi,output+OUTBUF + jb ._ok + Msg 16 + jmp .ex + ._ok: + mov edx,seql + mov ebx,calph + call get_code + call ExpLen + cmp [hlit],ax + ja .again +if SHOW_CHARS eq 1 + mov edi,Lit_c + call Show_codes +end if + mov edi,Dist_c + and [tblCount],0 + .again2: + mov ebx,calph + + call get_code + call ExpLen + cmp [hdist],al + ja .again2 + movzx ecx,[hlit] + mov ebx,Literal + mov edx,seql + mov eax,Lit_c + call Huffc + movzx ecx,[hdist] + mov ebx,Distance + mov edx,seqd + mov eax,Dist_c + call Huffc + + push [hlit] + pop [tblLen] + mov ebp,Lit_c + mov edx,seql + mov ebx,Literal + mov edi,[outp] + and [tblCount],0 + .again3: ; <------------ + call get_code + cmp eax,256 + je .check_last + ja .dist + stosb + jmp .again3 + .dist: + call get_Len + push eax ebx edx ebp + mov ecx,32 + mov ebp,Dist_c + mov edx,seqd + mov ebx,Distance + mov [tblLen],32 + call get_code + call get_Dist + push [hlit] + pop [tblLen] + neg eax + pop ebp edx ebx ecx + push esi + lea esi,[edi+eax] + rep movsb + pop esi + jmp .again3 + +; ****************************************** +Huffc: +; EBX - dest array, ECX - length, EDX - br_seq dest, EAX - source array + push esi edi eax ecx + mov edi,bl_count + xor eax,eax + mov ecx,BITS + rep stosw + pop ecx + mov esi,[esp] + mov [tblLen],cx + mov [max_len],ax +; Count the number of codes for each code length + .cnt_loop: + lodsw + cmp [max_len],ax + jae .skip + mov [max_len],ax + .skip: + inc byte[bl_count+eax] + loop .cnt_loop + movzx ecx,[max_len] + xor eax,eax + and [bl_count],al + xor esi,esi ; edx - bits + mov edi,next_code+2 + push ebx +; Find the numerical value of the smallest code for each code length + .nc_loop: + movzx bx,byte[bl_count+esi] + add ax,bx + shl ax,1 + stosw + inc esi + loop .nc_loop + pop ebx +; clear table + movzx ecx,[tblLen] + xor eax,eax + dec eax + mov edi,ebx + rep stosw + inc eax + movzx ecx,[tblLen] + mov esi,[esp] + mov edi,ebx +; Assign numerical values to all codes + .loop3: + lodsw + test eax,eax + jz .lp + push [next_code+eax*2] + pop word[edi] + inc [next_code+eax*2] + .lp: + add edi,2 + loop .loop3 +; Clear all codes + xor eax,eax + mov edi,edx + movzx ecx,[max_len] + mov [edi-1],al +; Prepare read bit sequences + .rebiloop: + inc eax + cmp [bl_count+eax],0 + jz .sk + stosb + inc byte[edx-1] + .sk: + loop .rebiloop + movzx ecx,byte[edx-1] + dec ecx + jecxz .noreb2 + .reb2loop: + mov al,[edx+ecx-1] + sub [edx+ecx],al + loop .reb2loop + .noreb2: + pop eax edi esi + ret + +; ****************************************** + +; get Codes of variable sizes +get_code: +; EDX - br_seq, EBX - source table, EBP - codelength table + push edx edi + xor eax,eax + movzx ecx,byte[edx-1] + mov [codel],ax + .rb3: + push ecx + movzx ecx,byte[edx] + add [codel],cx + call read_bits + movzx ecx,[tblLen] + inc ecx + mov edi,ebx + .scas: + repne scasw + jecxz .notfound + push edi ecx + sub edi,ebx + sub edi,2 + mov cx,[codel] + cmp cx,[ds:ebp+edi] + jne .notfound2 + mov eax,edi + shr eax,1 + add esp,12 + .pp: + pop edi edx + ret + .notfound2: + pop ecx + pop edi + jmp .scas + .notfound: + pop ecx + inc edx + loop .rb3 + Msg 7 + jmp .pp + +codel dw ? +; ****************************************** +ExpLen: + cmp eax,16 + jae .noliteral + inc [tblCount] + stosw + jmp .nomatch + .noliteral: + and [Flags],not 1 + mov ebx,3 + cmp eax,17 + jae .code1718 + mov ecx,2 + xor eax,eax + call read_bits + lea ecx,[eax+ebx] + mov ax,[edi-2] + .cc: + add [tblCount],cx + rep stosw + or [Flags],1 + jmp .nomatch + .code1718: + jne .code18 + mov ecx,3 + .cc2: + xor eax,eax + call read_bits + lea ecx,[eax+ebx] + xor eax,eax + jmp .cc + .code18: + mov ebx,11 + mov ecx,7 + jmp .cc2 + .nomatch: + mov ax,[tblCount] + ret +get_a Len,2,256+8,10,3,285,258 +get_a Dist,1,3,4,1 + + +; ****************************************** +read_bits: ; eax-dest; ecx-count + push edx ecx + .shift: + if RBLOCK eq 4 + ror [cur_byte],1 + else + ror byte[cur_byte],1 + end if + pushf + test [Flags],1 + je .noh1 + popf + rcl eax,1 + jmp .dec + .noh1: + popf + rcr eax,1 + .dec: + dec [bits] + jnz .loop1 + .push: + push eax + mov eax,[esi] + call setcurb + pop eax + if RBLOCK eq 1 + inc esi + inc [IDATcount] + else + inc esi + inc [IDATcount] + end if + cmp esi,area+INBUF-BSIZE + jbe .ok + pusha +if SHOW_RBLOCK eq 1 + Msg 9 +end if + mov eax,0 + mov ebx,1 + call FileSeek + mov [esp+4],esi + popa + .ok: + test [Flags],PNG_MODE + jz .idatok + mov edx,[IDATcount] + cmp edx,[IDATsize] + jbe .idatok + pusha + lodsd + call PngParse.nxt_sec + mov [IDATcount],1 + mov [esp+4],esi + mov [esp+20],edx + popa + cmp edx,21 + jne .idatok + mov eax,256 + pop ecx + jmp .exx + .idatok: + + mov [bits],8 + .loop1: + loop .shift2 + jmp .popc + .shift2: + jmp .shift + .popc: + pop ecx + test [Flags],1 + jne .exx + .noh2: + rol eax,cl + .exx: + pop edx + ret + +if SHOW_CHARS eq 1 +Show_codes: + pusha + movzx ecx,[tblLen] + mov ecx,256 + xor eax,eax + .lp2: + mov [braces+1],al + push eax ecx + invoke StrFormat,eax,strbuf,20 + invoke WriteConsole,[cons],strbuf,16,param1,NULL + invoke WriteConsole,[cons],braces,6,param1,NULL + mov eax,[esp+4] + movzx eax,word[edi+eax*2] + test eax,eax + jz .skip + invoke WriteConsole,[cons],exist,6,param1,NULL + .skip: + invoke WriteConsole,[cons],braces+6,2,param1,NULL + pop ecx eax + inc eax + loop .lp + jmp .ex + .lp: + jmp .lp2 + .ex: + popa + ret + + cons dd ? + param1 dd ? + braces db '( ) = ',0xa, 0xd + strbuf rb 20 + exist db 'exists' +end if + +makeCRC: + pusha + Msg 8 + mov edi,CRC32table + add edi,255*4 + std + mov ecx,255 + mov ebx,0xedb88320 + .m1: + mov eax,ecx + push ecx + mov ecx,8 + .m2: + shr eax,1 + jnc .m3 + xor eax,ebx + .m3: + loop .m2 + pop ecx + stosd + loop .m1 + popa + cld + ret + +UCRC: +; in: esi - data to calculate CRC +; ecx - its length +; [_CRC32_] - previous CRC32 +; out: [_CRC32_]- partial CRC32 (no pre- & post-conditioning!) + pusha + cmp dword[CRC32table+4],0x77073096 + je .tbl_rdy + call makeCRC + .tbl_rdy: + mov eax,[_CRC32_] + not eax + .m1: + movzx ebx,al + shr eax,8 + xor bl,[esi] + xor eax,[CRC32table+ebx*4] + inc esi + loop .m1 + not eax + mov [_CRC32_],eax + popa + ret + +UAdler: +; in: esi - data to calculate CRC +; ecx - its length +; [Adler32] - previous Adler32 +; out: [Adler32]- partial Adler32 + pusha + mov ebp,65521 + movzx ebx,word[Adler32] ; s1-ebx + movzx edi,word[Adler32+2] ; s2-edi + .m1: + movzx eax,byte[esi] + add eax,ebx + xor edx,edx + div ebp + mov ebx,edx + lea eax,[edi+ebx] + xor edx,edx + div ebp + mov edi,edx + inc esi + loop .m1 + shl edi,16 + add edi,ebx + mov [Adler32],edi + popa + ret + +tblSort db 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 +tblHLen dw 7,11,19,35,67,131 +tblHDist dw 3,5,9,17,33,65,129,257,513,1025,2049,4097,8193,16385 diff --git a/programs/other/archer/trunk/dump.inc b/programs/other/outdated/archer/trunk/dump.inc similarity index 100% rename from programs/other/archer/trunk/dump.inc rename to programs/other/outdated/archer/trunk/dump.inc diff --git a/programs/other/archer/trunk/parser.inc b/programs/other/outdated/archer/trunk/parser.inc similarity index 94% rename from programs/other/archer/trunk/parser.inc rename to programs/other/outdated/archer/trunk/parser.inc index ad3531abeb..d6ef44c1aa 100644 --- a/programs/other/archer/trunk/parser.inc +++ b/programs/other/outdated/archer/trunk/parser.inc @@ -1,996 +1,996 @@ -; @RCHER parser and filter routines -; Written in pure assembler by Ivushkin Andrey aka Willow - - fhs_local equ 0x04034b50 - fhs_central equ 0x02014b50 - fhs_end equ 0x06054b50 - fhs_enc equ 0x08074b50 - -SkipASCIIZ: - xor eax,eax - mov ecx,255 - mov edi,esi - repne scasb - mov esi,edi - ret - -PrintFilename: - pusha - mov esi,edx - mov edi,os_work - mov edx,edi - rep movsb - mov dword[edi],0x00a0d - call DebugPrint - popa - call Add2Fat - ret - -Add2Fat: -; edx - ptr, ecx - len - - pusha - test [Flags],LIST_MODE - jz .ex - mov ebp,8 - mov edi,edx - lea ebx,[edx+ecx] - mov ecx,[lpath_len] - cmp ecx,1 - je .lbl - mov esi,[lpath] - repe cmpsb - jne .full - mov eax,[lpath_len] - sub dword[esp+24],eax;path_len-path - cmp edi,ebx - je .full - mov edx,edi - .lbl: - mov ecx,[esp+24] - mov al,'/' - repne scasb - mov eax,[fat_] - mov ecx,[esp+24] - jne .nofol - cmp edi,ebx - jne .full - lea ecx,[edi-1] - sub ecx,edx - or byte[eax+11],0x10 -; sub edx,ecx - .nofol: - - push [fat_fnum] - pop dword[eax+12] - mov edi,eax - mov esi,edx - .lp1: - - mov bl,[esi] - lea edx,[eax+ebp] - inc esi - cmp bl,'.' - jne .nodot - lea edi,[eax+ebp] - mov ebp,11 - jmp .ll - .nodot: - cmp edi,edx - jae .ll - mov [edi],bl - inc edi - .ll: - loop .lp1 - mov ecx,11 - dec eax - .lp2: - cmp byte[eax+ecx],0 - jne .no0 - mov byte[eax+ecx],' ' - .no0: - loop .lp2 - cmp eax,child_stack-1 - jae .full - add [fat_],32 - .full: - inc [fat_fnum] - .ex: - popa - ret - -;path db '/';'fasm/examples/elfexe/' -;path_len: - -; Parse routines: -; out: edx= 0 if all ok, 1 - central dir, 2-EOD -; 50 - encrypted -; 51 - not deflated -; 52 - invalid format -; 53 - dir skipped -; 1 - encrypted - -; **************************************************** -ZipParse: - - call ResetFile - .nxt: - call ZipCrawl - - cmp edx,3 - je .ex - cmp edx,1 - je .skipinc -if IGNORE_DIRS eq 1 - cmp edx,53 - jne .skipinc -end if - inc [file_count] - .skipinc: - cmp edx,52 - je .er1 - cmp edx,50 - jne .seek - .er1: - Msg edx - ret - .seek: - add eax,ecx - mov ebx,1 - call FileSeek - jmp .nxt - .ex: - Msg 2 - mov eax,[file_count] - if ~ SYS eq win - dpd eax - else - pusha - call int2str - mov edx,os_work - call DebugPrint - popa - end if - Newline -; Dump fat,160,os_work - ret - -ZipFindN: -; ecx - file # - Msg 33 - or [Flags],FIND_MODE - cmp ecx,[file_count] - jae .err - push ecx - call ResetFile - .nxt: - - call ZipCrawl - cmp edx,51 - je .ok2 - .noenc: - test edx,edx - jnz .err - .ok2: - add eax,ecx - cmp dword[esp],0 - jz .ok - dec dword[esp] - mov ebx,1 - call FileSeek - jmp .nxt - .err: - mov edx,4 - jmp .ex - .ok: - pop ecx - sub eax,[esi+18] - add esi,eax - mov edx,5 - .ex: - and [Flags],-1-FIND_MODE - push edx - Msg edx - pop edx - ret - -ZipCrawl: - mov edx,52 - cmp dword[esi],fhs_central - jne .noc - mov eax,46 - movzx ecx,word[esi+28] - add eax,ecx - movzx ecx,word[esi+30] - add eax,ecx - movzx ecx,word[esi+32] - mov edx,1 - ret - .noc: - cmp dword[esi],fhs_end - jne .noe - .edx3: - Msg 3 - mov edx,3 - ret - .noe: - cmp dword[esi],fhs_local - je .loc - cmp dword[esi],fhs_enc - jne .err - mov eax,16 - xor ecx,ecx - mov edx,1 - ret - .loc: - push word[esi+6] - pop [gpbf] - push dword[esi+14] - pop [CRC_check] - push dword[esi+22] - pop [unp_size] - movzx ecx,word[esi+26] - mov eax,30 - lea edx,[esi+eax] - add eax,ecx -if IGNORE_DIRS eq 1 - cmp byte[edx+ecx-1],'/' - je .skipdp -end if - test [Flags],FIND_MODE - jnz .skipdp - call PrintFilename - .skipdp: - movzx ecx,word[esi+28] - add eax,[esi+18] - test [gpbf],1 - jz .no_enc - or [Flags],DECRYPT_MODE ; encrypted - mov edx,51 - jmp .err - .no_enc: - test word[esi+8],7 - rep_err z,50 - .ok: - xor edx,edx - .err: - ret - -; *********************************************** -GzipParse: - ID1ID2 equ 0x8b1f - FTEXT equ 1b - FHCRC equ 10b - FEXTRA equ 100b - FNAME equ 1000b - FCOMMENT equ 10000b - mov eax,7 - mov ebx,2 - call FileSeek - push dword[esi] - pop [CRC_check] - push dword[esi+4] - pop [unp_size] - call ResetFile - xor edx,edx - cmp word[esi],ID1ID2 - rep_err e, 52, 15 - cmp byte[esi+2],8 - rep_err e, 52, 50 - mov bl,[esi+3] ; bl - FLG - add esi,10 ; esi->extra - test bl,FEXTRA - jz .noextr - movzx eax,word[esi] - lea esi,[esi+eax+2] ; esi->FNAME - .noextr: - test bl,FNAME - jz .nofname - mov edx,esi - call DebugPrint - call SkipASCIIZ - cmp dword[esi-5],'.tar' - jne .nofname - or [Flags],TAR_MODE - .nofname: ; esi->FCOMMENT - test bl,FCOMMENT - jz .nocomm - call SkipASCIIZ - .nocomm: ; esi->HCRC - test bl,FHCRC - jz .noCRC16 - add esi,2 - .noCRC16: - cmp [unp_size],OUTBUF - jb .sizeok2 - Msg 16 - mov edx,15 - ret - .sizeok2: - xor edx,edx - .err: - ret - -PngParse: - ID1 equ 0x474e5089 - ID2 equ 0x0a1a0a0d - FDICT equ 100000b - InitIDAT equ 2 - mov [IDATcount],InitIDAT - call ResetFile - cmp dword[esi],ID1 - rep_err e, 52, 18 - cmp dword[esi+4],ID2 - rep_err e, 52, 18 - add esi,8 - cmp dword[esi+4],'IHDR' - rep_err e,52, 18 - memcpy_esi PNG_info,13,8 - mov eax,[PNG_info.Width] - bswap eax - mov [PNG_info.Width],eax - mov eax,[PNG_info.Height] - bswap eax - mov ebx,eax - mov [PNG_info.Height],eax - call scanline_calc -; dps 'All=' - cmp [PNG_info.Color_type],3 - jne .nopal - shl eax,3 - inc eax - .nopal: - inc eax - imul eax,ebx - mov [unp_size],eax -; dpd eax - add esi,25 - cmp byte[esi-5],0 - rep_err e,52,29 - or [Flags],PNG_MODE - .nxt_sec: - lodsd - bswap eax ; eax - section size - push eax - lodsd - mov edi,Png_ch - mov ecx,(E_ch-Png_ch) / 4 - repne scasd - pop eax - mov ebx,[esi-4] - mov edx,os_work - mov [edx],ebx - mov dword[edx+4],0x0a0d - .dp: - sub edi,Png_ch - shr edi,2 ; edi- chunk # - if SHOW_PNG_SEC eq 1 - call DebugPrint - end if - cmp edi,1 - jne .noend - mov edx,21 - jmp .err - .noend: - cmp edi,2 - jne .noplte - memcpy_esi PNG_info.Palette,eax - jmp .noidat - .noplte: - cmp edi,3 - jne .noidat - mov [IDATsize],eax - cmp [IDATcount],InitIDAT - jne .ex - mov [bits],8 - if RBLOCK eq 4 - lodsd - else - lodsb - end if - call setcurb - rbits 0,16 - test ah,FDICT - jz .ex - rbits 0,32 - add [IDATcount],4 - jmp .ex - .noidat: - add eax,4 - mov ebx,1 - call FileSeek - jmp .nxt_sec - .ex: - xor edx,edx - .err: - ret - -Png_ch: - dd 'IEND','PLTE','IDAT','????' -E_ch: - -ZipDecrypt: - push edi - mov ecx,3 - mov edi,Dheader - rep movsd - pop edi - call QueryPwd - jecxz .ex - push esi - mov [DKeys], 305419896 - mov [DKeys+4],591751049 - mov [DKeys+8],878082192 - xor eax,eax - mov esi,Dpassword - .enc_init: - lodsb - call UKeys - loop .enc_init - mov ecx,12 - mov esi,Dheader - .dec_header: - call decrypt_byte - xor al,[esi] - call UKeys - mov [esi],al - inc esi - loop .dec_header - mov eax,[CRC_check] - pop esi - .ex: - ret - -QueryPwd: -; out: ecx - passwd len -if SYS eq win - Msg 32 - invoke ReadConsole,[cons_in],Dpassword,PASSW_LEN,cparam1,NULL - test eax,eax - jnz .inp_ok - xor ecx,ecx - jmp .ex - .inp_ok: - mov ecx,[cparam1] - cmp ecx,PASSW_LEN - je .ex - sub ecx,2 -else -end if - .ex: - ret - -UKeys: -; in: al - char - pusha - mov edi,134775813 - mov ebx,DKeys - mov esi,os_work - mov byte[esi],al - mov ecx,1 - push dword[ebx] - pop [_CRC32_] - call UCRC - push [_CRC32_] - pop dword[ebx] - mov eax,[ebx] - and eax,0xff - add eax,[ebx+4] - mul edi - inc eax - mov [ebx+4],eax - shr eax,24 - mov byte[esi],al - push dword[ebx+8] - pop [_CRC32_] - call UCRC - push [_CRC32_] - pop dword[ebx+8] - popa - ret - -decrypt_byte: -; out: al - push ebx edx - movzx ebx,word[DKeys+8] - or ebx,2 - mov eax,ebx - xor eax,1 - mul ebx - shr eax,8 - pop edx ebx - ret - -setcurb: -; in: eax - test [Flags],DECRYPT_MODE - jz .noenc - push eax - call decrypt_byte - xor al,byte[esp] - add esp,4 - call UKeys - .noenc: - mov [cur_byte],eax - ret - -TarParse: - mov esi,output -; call ResetFile - .nxt: - call TarCrawl -; wait - cmp edx,3 - je ZipParse.ex -if IGNORE_DIRS eq 1 - cmp edx,53 - jne .skipinc -end if - inc [file_count] - .skipinc: - add eax,ecx -; mov ebx,1 - add esi,eax -; call FileSeek - jmp .nxt - -TarFindN: -; in: ecx - file number -; ecx - file # - Msg 33 - cmp ecx,[file_count] - jae .err - push ecx - mov esi,output -; call ResetFile - .nxt: - call TarCrawl -if IGNORE_DIRS eq 1 - cmp edx,53 - je .seek -end if - test edx,edx - jnz .err - cmp dword[esp],0 - jz .ok - dec dword[esp] - .seek: - add eax,ecx -; mov ebx,1 - add esi,eax -; call FileSeek - jmp .nxt - .err: - mov edx,4 - jmp .ex - .ok: - pop ecx - add esi,eax - mov edx,5 - .ex: - Msg edx - ret - -TarCrawl: - cmp byte[esi],0 - jz ZipCrawl.edx3 - push esi - mov ecx,11 - add esi,0x7c - call Octal_str - mov esi,[esp] - mov [outfile.size],eax - call SkipASCIIZ -if IGNORE_DIRS eq 1 - cmp byte[esi-2],'/' - je .skipdp -end if - mov edx,[esp] - lea ecx,[esi-1] - sub ecx,edx - call PrintFilename - .skipdp: - mov ecx,[outfile.size] - jecxz .zerolen - shr ecx,9 - inc ecx - shl ecx,9 - .zerolen: - mov eax,512 - pop esi - jmp ZipCrawl.ok - -Octal_str: -; in: esi - ASCIIZ octal string -; ecx - its length -; out: eax - value - push esi ebx ecx - xor ebx,ebx - xor eax,eax - .jec: - jecxz .zero - cmp byte[esi+ecx-1],' ' - jne .lp - dec ecx - jmp .jec - .lp: - lodsb - shl ebx,3 - cmp eax,' ' - je .space - lea ebx,[ebx+eax-'0'] - .space: - loop .lp - mov eax,ebx - .zero: - pop ecx ebx esi - ret - -TRAILING_BUF equ 2048 -SfxParse: - call ResetFile - cmp word[esi],'MZ' - rep_err e, 34 - mov eax,TRAILING_BUF - mov ecx,eax - mov ebx,2 - call FileSeek - mov edi,esi - mov al,'P' - .lp: - repne scasb - cmp dword[edi-1],fhs_end - je .end_found - jecxz .err - jmp .lp - .end_found: - dec edi - mov esi,edi - mov eax,[edi+12] - neg eax - mov ebx,1 - call FileSeek - push dword[esi+42] - pop [arc_base] - .err: - ret - -scanline_calc: - movzx ecx,byte[PNG_info.Color_type] - mov eax,1 - cmp cl,3 - je .palette - test cl,2 - jz .notriple - add eax,2 - .notriple: - test cl,4 - jz .calc_bpp - inc eax - .calc_bpp: - mul [PNG_info.Bit_depth] - .palette: - mov ecx,eax ; in bits - shr eax,3 ; in bytes - test eax,eax - jnz .noz - inc eax - .noz: - mov [png_bpp],eax - mov eax,[PNG_info.Width] - mov ebp,eax - imul ecx - shr eax,3 - test eax,eax - jnz .noz2 - inc eax - .noz2: - ret - -; Created: May 31, 2005 -FiltCall: -dd PngFilter.nofilt,Filt_sub,Filt_up,Filt_av,Filt_paeth,PngFilter.nofilt -PngFilter: -; esi - filtered uncompressed image data -; edi - destination - call scanline_calc - mov [sline_len],eax ; scanline length - push edi - and [Flags],not 1 - mov ecx,[PNG_info.Height] - .scanline: -; Msg 9,1 - push ecx - lodsb - movzx eax,al - cmp eax,5 - jb .f_ok - mov eax,5 - .f_ok: - inc dword[filters+eax*4] - jmp dword[FiltCall+eax*4] - .nofilt: - mov dl,[PNG_info.Color_type] - cmp dl,3 - jne .nopalette - lodsb - mov [cur_byte],eax - mov [bits],8 - mov ecx,ebp - .pixel: - push ecx - movzx ecx,[PNG_info.Bit_depth] - call rb_png - push esi - lea esi,[eax+eax*2] - add esi,PNG_info.Palette - call PngStore - pop esi - pop ecx - loop .pixel - cmp [bits],8 - jne .lp - dec esi - .lp: - pop ecx - loop .sl - jmp .sl2 - .sl: -;// -MV equ 1 -; mov eax,ecx -; and eax,1 shl MOVE_SLINE_LEV-1 -; jnz .scanline -;stop -if MV eq 0 - push ecx - mov ecx,edi - sub ecx,esi - sub [outp],esi - mov edi,output - add [outp],edi - rep movsb - mov esi,output - pop ecx - pop eax - push [outp] -end if -;;// - jmp .scanline - .sl2: -;// -; call MoveScanline - sub edi,[outp] -;// -; sub edi,[esp] - pop eax - ret - - .nopalette: - test dl,2 - jz .notriple1 - .__: - mov ecx,[PNG_info.Width] - .RGBcp: - call PngStore - add esi,[png_bpp] - loop .RGBcp - jmp .lp - .notriple1: - test dl,dl - jz .gray - cmp dl,4 - jne .__ -; Msg 31 -; ud2 - .gray: -; stop - push ecx - mov ecx,[PNG_info.Width] - mov [bits],8 - lodsb - mov [cur_byte],eax - .gray2: - push ecx - movzx ecx,[PNG_info.Bit_depth] - push ecx - call rb_png - pop ecx - cmp ecx,8 - jbe .lo - add esi,2 - shr eax,8 - jmp .stsb - .lo: - neg ecx - add ecx,8 - shl eax,cl - .stsb: - mov ecx,3 - rep stosb - pop ecx - loop .gray2 - dec esi - pop ecx - jmp .lp - -Filt_sub: -; dps '-' - mov ecx,[sline_len] - sub ecx,[png_bpp] - push esi edi - mov edi,esi - add edi,[png_bpp] - .scan: ; esi - previous, edi - current - lodsb - add [edi],al - inc edi - loop .scan - - pop edi esi -; dps '-' - jmp PngFilter.nofilt - -Filt_up: - cmp ecx,[PNG_info.Height] - je PngFilter.nofilt - push esi edi - mov ecx,[sline_len] - mov edi,esi - sub esi,ecx - dec esi - jmp Filt_sub.scan - -Filt_av: - pusha - mov ecx,[sline_len] - mov ebp,[PNG_info.Height] - mov edx,[png_bpp] ; edx-raw - neg edx - mov ebx,ecx - sub ebx,[png_bpp] - mov edi,esi - sub esi,ecx - dec esi ; esi-prior - .lpavg: - xor eax,eax - cmp [esp+24h],ebp - je .1stl - movzx eax,byte[esi] - .1stl: - cmp ecx,ebx - ja .leftbad - push ecx - movzx ecx,byte[edi+edx] - add eax,ecx - pop ecx - .leftbad: - shr eax,1 - add [edi],al - inc esi - inc edi - loop .lpavg - popa - jmp PngFilter.nofilt - -Filt_paeth: - pusha - mov ecx,[sline_len] - mov edx,[png_bpp] - neg edx - lea ebp,[ecx+edx] ; left edge - mov edi,esi - sub esi,ecx - dec esi - .lpaeth: - push ecx - movzx eax,byte[edi+edx] - movzx ebx,byte[esi] - movzx ecx,byte[esi+edx] - push eax - mov eax,[esp+28h] - cmp eax,[PNG_info.Height] ; 1st line - jne .no1stlineok - xor ebx,ebx - xor ecx,ecx - .no1stlineok: - pop eax - cmp [esp],ebp ; ecx - jbe .leftok ; x-bpp>=0 - xor eax,eax - xor ecx,ecx - .leftok: - pusha ; eax-28, ebx-16, ecx-24 - lea edx,[eax+ebx] - sub edx,ecx ; p=edx - sub eax,edx ; pa := abs(p - a) - jge .eaxp - neg eax - .eaxp: - sub ebx,edx ; pb := abs(p - b) - jge .ebxp - neg ebx - .ebxp: - sub ecx,edx ; pc := abs(p - c) - jge .ecxp - neg ecx - .ecxp: - cmp eax,ebx - ja .noa - cmp eax,ecx - jbe .ex ; pa-min - .noa: - cmp ebx,ecx - ja .nob - mov eax,[esp+16] - jmp .ex2 - .nob: - mov eax,[esp+24] - .ex2: - mov [esp+28],eax - .ex: - popa - add [edi],al - inc esi - inc edi - pop ecx - loop .lpaeth - popa - jmp PngFilter.nofilt - -rb_png: ; eax-dest; ecx-count - push ecx - xor eax,eax - .shift: - rol byte[cur_byte],1 - rcl eax,1 - .dec: - dec [bits] - jnz .loop1 - .push: - push dword[esi] - pop [cur_byte] - mov [bits],8 - inc esi - .loop1: - loop .shift - pop ecx - ret - -PngStore: - push esi - cmp [PNG_info.Bit_depth],8 - jbe .lo - add esi,3 - .lo: - if ~ SYS eq win - mov esi,[esi] - bswap esi - shr esi,8 - mov [edi],esi - add edi,3 - else - movsw - movsb - end if - pop esi - ret - -FiltStats: - pusha - xor ebx,ebx - mov edx,23 - mov ecx,6 - .lp: - push ecx edx - Msg edx - mov eax,[filters+ebx*4] - DebugPrintDec - pop edx ecx - inc edx - inc ebx - loop .lp - Newline - popa - ret - +; @RCHER parser and filter routines +; Written in pure assembler by Ivushkin Andrey aka Willow + + fhs_local equ 0x04034b50 + fhs_central equ 0x02014b50 + fhs_end equ 0x06054b50 + fhs_enc equ 0x08074b50 + +SkipASCIIZ: + xor eax,eax + mov ecx,255 + mov edi,esi + repne scasb + mov esi,edi + ret + +PrintFilename: + pusha + mov esi,edx + mov edi,os_work + mov edx,edi + rep movsb + mov dword[edi],0x00a0d + call DebugPrint + popa + call Add2Fat + ret + +Add2Fat: +; edx - ptr, ecx - len + + pusha + test [Flags],LIST_MODE + jz .ex + mov ebp,8 + mov edi,edx + lea ebx,[edx+ecx] + mov ecx,[lpath_len] + cmp ecx,1 + je .lbl + mov esi,[lpath] + repe cmpsb + jne .full + mov eax,[lpath_len] + sub dword[esp+24],eax;path_len-path + cmp edi,ebx + je .full + mov edx,edi + .lbl: + mov ecx,[esp+24] + mov al,'/' + repne scasb + mov eax,[fat_] + mov ecx,[esp+24] + jne .nofol + cmp edi,ebx + jne .full + lea ecx,[edi-1] + sub ecx,edx + or byte[eax+11],0x10 +; sub edx,ecx + .nofol: + + push [fat_fnum] + pop dword[eax+12] + mov edi,eax + mov esi,edx + .lp1: + + mov bl,[esi] + lea edx,[eax+ebp] + inc esi + cmp bl,'.' + jne .nodot + lea edi,[eax+ebp] + mov ebp,11 + jmp .ll + .nodot: + cmp edi,edx + jae .ll + mov [edi],bl + inc edi + .ll: + loop .lp1 + mov ecx,11 + dec eax + .lp2: + cmp byte[eax+ecx],0 + jne .no0 + mov byte[eax+ecx],' ' + .no0: + loop .lp2 + cmp eax,child_stack-1 + jae .full + add [fat_],32 + .full: + inc [fat_fnum] + .ex: + popa + ret + +;path db '/';'fasm/examples/elfexe/' +;path_len: + +; Parse routines: +; out: edx= 0 if all ok, 1 - central dir, 2-EOD +; 50 - encrypted +; 51 - not deflated +; 52 - invalid format +; 53 - dir skipped +; 1 - encrypted + +; **************************************************** +ZipParse: + + call ResetFile + .nxt: + call ZipCrawl + + cmp edx,3 + je .ex + cmp edx,1 + je .skipinc +if IGNORE_DIRS eq 1 + cmp edx,53 + jne .skipinc +end if + inc [file_count] + .skipinc: + cmp edx,52 + je .er1 + cmp edx,50 + jne .seek + .er1: + Msg edx + ret + .seek: + add eax,ecx + mov ebx,1 + call FileSeek + jmp .nxt + .ex: + Msg 2 + mov eax,[file_count] + if ~ SYS eq win + dpd eax + else + pusha + call int2str + mov edx,os_work + call DebugPrint + popa + end if + Newline +; Dump fat,160,os_work + ret + +ZipFindN: +; ecx - file # + Msg 33 + or [Flags],FIND_MODE + cmp ecx,[file_count] + jae .err + push ecx + call ResetFile + .nxt: + + call ZipCrawl + cmp edx,51 + je .ok2 + .noenc: + test edx,edx + jnz .err + .ok2: + add eax,ecx + cmp dword[esp],0 + jz .ok + dec dword[esp] + mov ebx,1 + call FileSeek + jmp .nxt + .err: + mov edx,4 + jmp .ex + .ok: + pop ecx + sub eax,[esi+18] + add esi,eax + mov edx,5 + .ex: + and [Flags],-1-FIND_MODE + push edx + Msg edx + pop edx + ret + +ZipCrawl: + mov edx,52 + cmp dword[esi],fhs_central + jne .noc + mov eax,46 + movzx ecx,word[esi+28] + add eax,ecx + movzx ecx,word[esi+30] + add eax,ecx + movzx ecx,word[esi+32] + mov edx,1 + ret + .noc: + cmp dword[esi],fhs_end + jne .noe + .edx3: + Msg 3 + mov edx,3 + ret + .noe: + cmp dword[esi],fhs_local + je .loc + cmp dword[esi],fhs_enc + jne .err + mov eax,16 + xor ecx,ecx + mov edx,1 + ret + .loc: + push word[esi+6] + pop [gpbf] + push dword[esi+14] + pop [CRC_check] + push dword[esi+22] + pop [unp_size] + movzx ecx,word[esi+26] + mov eax,30 + lea edx,[esi+eax] + add eax,ecx +if IGNORE_DIRS eq 1 + cmp byte[edx+ecx-1],'/' + je .skipdp +end if + test [Flags],FIND_MODE + jnz .skipdp + call PrintFilename + .skipdp: + movzx ecx,word[esi+28] + add eax,[esi+18] + test [gpbf],1 + jz .no_enc + or [Flags],DECRYPT_MODE ; encrypted + mov edx,51 + jmp .err + .no_enc: + test word[esi+8],7 + rep_err z,50 + .ok: + xor edx,edx + .err: + ret + +; *********************************************** +GzipParse: + ID1ID2 equ 0x8b1f + FTEXT equ 1b + FHCRC equ 10b + FEXTRA equ 100b + FNAME equ 1000b + FCOMMENT equ 10000b + mov eax,7 + mov ebx,2 + call FileSeek + push dword[esi] + pop [CRC_check] + push dword[esi+4] + pop [unp_size] + call ResetFile + xor edx,edx + cmp word[esi],ID1ID2 + rep_err e, 52, 15 + cmp byte[esi+2],8 + rep_err e, 52, 50 + mov bl,[esi+3] ; bl - FLG + add esi,10 ; esi->extra + test bl,FEXTRA + jz .noextr + movzx eax,word[esi] + lea esi,[esi+eax+2] ; esi->FNAME + .noextr: + test bl,FNAME + jz .nofname + mov edx,esi + call DebugPrint + call SkipASCIIZ + cmp dword[esi-5],'.tar' + jne .nofname + or [Flags],TAR_MODE + .nofname: ; esi->FCOMMENT + test bl,FCOMMENT + jz .nocomm + call SkipASCIIZ + .nocomm: ; esi->HCRC + test bl,FHCRC + jz .noCRC16 + add esi,2 + .noCRC16: + cmp [unp_size],OUTBUF + jb .sizeok2 + Msg 16 + mov edx,15 + ret + .sizeok2: + xor edx,edx + .err: + ret + +PngParse: + ID1 equ 0x474e5089 + ID2 equ 0x0a1a0a0d + FDICT equ 100000b + InitIDAT equ 2 + mov [IDATcount],InitIDAT + call ResetFile + cmp dword[esi],ID1 + rep_err e, 52, 18 + cmp dword[esi+4],ID2 + rep_err e, 52, 18 + add esi,8 + cmp dword[esi+4],'IHDR' + rep_err e,52, 18 + memcpy_esi PNG_info,13,8 + mov eax,[PNG_info.Width] + bswap eax + mov [PNG_info.Width],eax + mov eax,[PNG_info.Height] + bswap eax + mov ebx,eax + mov [PNG_info.Height],eax + call scanline_calc +; dps 'All=' + cmp [PNG_info.Color_type],3 + jne .nopal + shl eax,3 + inc eax + .nopal: + inc eax + imul eax,ebx + mov [unp_size],eax +; dpd eax + add esi,25 + cmp byte[esi-5],0 + rep_err e,52,29 + or [Flags],PNG_MODE + .nxt_sec: + lodsd + bswap eax ; eax - section size + push eax + lodsd + mov edi,Png_ch + mov ecx,(E_ch-Png_ch) / 4 + repne scasd + pop eax + mov ebx,[esi-4] + mov edx,os_work + mov [edx],ebx + mov dword[edx+4],0x0a0d + .dp: + sub edi,Png_ch + shr edi,2 ; edi- chunk # + if SHOW_PNG_SEC eq 1 + call DebugPrint + end if + cmp edi,1 + jne .noend + mov edx,21 + jmp .err + .noend: + cmp edi,2 + jne .noplte + memcpy_esi PNG_info.Palette,eax + jmp .noidat + .noplte: + cmp edi,3 + jne .noidat + mov [IDATsize],eax + cmp [IDATcount],InitIDAT + jne .ex + mov [bits],8 + if RBLOCK eq 4 + lodsd + else + lodsb + end if + call setcurb + rbits 0,16 + test ah,FDICT + jz .ex + rbits 0,32 + add [IDATcount],4 + jmp .ex + .noidat: + add eax,4 + mov ebx,1 + call FileSeek + jmp .nxt_sec + .ex: + xor edx,edx + .err: + ret + +Png_ch: + dd 'IEND','PLTE','IDAT','????' +E_ch: + +ZipDecrypt: + push edi + mov ecx,3 + mov edi,Dheader + rep movsd + pop edi + call QueryPwd + jecxz .ex + push esi + mov [DKeys], 305419896 + mov [DKeys+4],591751049 + mov [DKeys+8],878082192 + xor eax,eax + mov esi,Dpassword + .enc_init: + lodsb + call UKeys + loop .enc_init + mov ecx,12 + mov esi,Dheader + .dec_header: + call decrypt_byte + xor al,[esi] + call UKeys + mov [esi],al + inc esi + loop .dec_header + mov eax,[CRC_check] + pop esi + .ex: + ret + +QueryPwd: +; out: ecx - passwd len +if SYS eq win + Msg 32 + invoke ReadConsole,[cons_in],Dpassword,PASSW_LEN,cparam1,NULL + test eax,eax + jnz .inp_ok + xor ecx,ecx + jmp .ex + .inp_ok: + mov ecx,[cparam1] + cmp ecx,PASSW_LEN + je .ex + sub ecx,2 +else +end if + .ex: + ret + +UKeys: +; in: al - char + pusha + mov edi,134775813 + mov ebx,DKeys + mov esi,os_work + mov byte[esi],al + mov ecx,1 + push dword[ebx] + pop [_CRC32_] + call UCRC + push [_CRC32_] + pop dword[ebx] + mov eax,[ebx] + and eax,0xff + add eax,[ebx+4] + mul edi + inc eax + mov [ebx+4],eax + shr eax,24 + mov byte[esi],al + push dword[ebx+8] + pop [_CRC32_] + call UCRC + push [_CRC32_] + pop dword[ebx+8] + popa + ret + +decrypt_byte: +; out: al + push ebx edx + movzx ebx,word[DKeys+8] + or ebx,2 + mov eax,ebx + xor eax,1 + mul ebx + shr eax,8 + pop edx ebx + ret + +setcurb: +; in: eax + test [Flags],DECRYPT_MODE + jz .noenc + push eax + call decrypt_byte + xor al,byte[esp] + add esp,4 + call UKeys + .noenc: + mov [cur_byte],eax + ret + +TarParse: + mov esi,output +; call ResetFile + .nxt: + call TarCrawl +; wait + cmp edx,3 + je ZipParse.ex +if IGNORE_DIRS eq 1 + cmp edx,53 + jne .skipinc +end if + inc [file_count] + .skipinc: + add eax,ecx +; mov ebx,1 + add esi,eax +; call FileSeek + jmp .nxt + +TarFindN: +; in: ecx - file number +; ecx - file # + Msg 33 + cmp ecx,[file_count] + jae .err + push ecx + mov esi,output +; call ResetFile + .nxt: + call TarCrawl +if IGNORE_DIRS eq 1 + cmp edx,53 + je .seek +end if + test edx,edx + jnz .err + cmp dword[esp],0 + jz .ok + dec dword[esp] + .seek: + add eax,ecx +; mov ebx,1 + add esi,eax +; call FileSeek + jmp .nxt + .err: + mov edx,4 + jmp .ex + .ok: + pop ecx + add esi,eax + mov edx,5 + .ex: + Msg edx + ret + +TarCrawl: + cmp byte[esi],0 + jz ZipCrawl.edx3 + push esi + mov ecx,11 + add esi,0x7c + call Octal_str + mov esi,[esp] + mov [outfile.size],eax + call SkipASCIIZ +if IGNORE_DIRS eq 1 + cmp byte[esi-2],'/' + je .skipdp +end if + mov edx,[esp] + lea ecx,[esi-1] + sub ecx,edx + call PrintFilename + .skipdp: + mov ecx,[outfile.size] + jecxz .zerolen + shr ecx,9 + inc ecx + shl ecx,9 + .zerolen: + mov eax,512 + pop esi + jmp ZipCrawl.ok + +Octal_str: +; in: esi - ASCIIZ octal string +; ecx - its length +; out: eax - value + push esi ebx ecx + xor ebx,ebx + xor eax,eax + .jec: + jecxz .zero + cmp byte[esi+ecx-1],' ' + jne .lp + dec ecx + jmp .jec + .lp: + lodsb + shl ebx,3 + cmp eax,' ' + je .space + lea ebx,[ebx+eax-'0'] + .space: + loop .lp + mov eax,ebx + .zero: + pop ecx ebx esi + ret + +TRAILING_BUF equ 2048 +SfxParse: + call ResetFile + cmp word[esi],'MZ' + rep_err e, 34 + mov eax,TRAILING_BUF + mov ecx,eax + mov ebx,2 + call FileSeek + mov edi,esi + mov al,'P' + .lp: + repne scasb + cmp dword[edi-1],fhs_end + je .end_found + jecxz .err + jmp .lp + .end_found: + dec edi + mov esi,edi + mov eax,[edi+12] + neg eax + mov ebx,1 + call FileSeek + push dword[esi+42] + pop [arc_base] + .err: + ret + +scanline_calc: + movzx ecx,byte[PNG_info.Color_type] + mov eax,1 + cmp cl,3 + je .palette + test cl,2 + jz .notriple + add eax,2 + .notriple: + test cl,4 + jz .calc_bpp + inc eax + .calc_bpp: + mul [PNG_info.Bit_depth] + .palette: + mov ecx,eax ; in bits + shr eax,3 ; in bytes + test eax,eax + jnz .noz + inc eax + .noz: + mov [png_bpp],eax + mov eax,[PNG_info.Width] + mov ebp,eax + imul ecx + shr eax,3 + test eax,eax + jnz .noz2 + inc eax + .noz2: + ret + +; Created: May 31, 2005 +FiltCall: +dd PngFilter.nofilt,Filt_sub,Filt_up,Filt_av,Filt_paeth,PngFilter.nofilt +PngFilter: +; esi - filtered uncompressed image data +; edi - destination + call scanline_calc + mov [sline_len],eax ; scanline length + push edi + and [Flags],not 1 + mov ecx,[PNG_info.Height] + .scanline: +; Msg 9,1 + push ecx + lodsb + movzx eax,al + cmp eax,5 + jb .f_ok + mov eax,5 + .f_ok: + inc dword[filters+eax*4] + jmp dword[FiltCall+eax*4] + .nofilt: + mov dl,[PNG_info.Color_type] + cmp dl,3 + jne .nopalette + lodsb + mov [cur_byte],eax + mov [bits],8 + mov ecx,ebp + .pixel: + push ecx + movzx ecx,[PNG_info.Bit_depth] + call rb_png + push esi + lea esi,[eax+eax*2] + add esi,PNG_info.Palette + call PngStore + pop esi + pop ecx + loop .pixel + cmp [bits],8 + jne .lp + dec esi + .lp: + pop ecx + loop .sl + jmp .sl2 + .sl: +;// +MV equ 1 +; mov eax,ecx +; and eax,1 shl MOVE_SLINE_LEV-1 +; jnz .scanline +;stop +if MV eq 0 + push ecx + mov ecx,edi + sub ecx,esi + sub [outp],esi + mov edi,output + add [outp],edi + rep movsb + mov esi,output + pop ecx + pop eax + push [outp] +end if +;;// + jmp .scanline + .sl2: +;// +; call MoveScanline + sub edi,[outp] +;// +; sub edi,[esp] + pop eax + ret + + .nopalette: + test dl,2 + jz .notriple1 + .__: + mov ecx,[PNG_info.Width] + .RGBcp: + call PngStore + add esi,[png_bpp] + loop .RGBcp + jmp .lp + .notriple1: + test dl,dl + jz .gray + cmp dl,4 + jne .__ +; Msg 31 +; ud2 + .gray: +; stop + push ecx + mov ecx,[PNG_info.Width] + mov [bits],8 + lodsb + mov [cur_byte],eax + .gray2: + push ecx + movzx ecx,[PNG_info.Bit_depth] + push ecx + call rb_png + pop ecx + cmp ecx,8 + jbe .lo + add esi,2 + shr eax,8 + jmp .stsb + .lo: + neg ecx + add ecx,8 + shl eax,cl + .stsb: + mov ecx,3 + rep stosb + pop ecx + loop .gray2 + dec esi + pop ecx + jmp .lp + +Filt_sub: +; dps '-' + mov ecx,[sline_len] + sub ecx,[png_bpp] + push esi edi + mov edi,esi + add edi,[png_bpp] + .scan: ; esi - previous, edi - current + lodsb + add [edi],al + inc edi + loop .scan + + pop edi esi +; dps '-' + jmp PngFilter.nofilt + +Filt_up: + cmp ecx,[PNG_info.Height] + je PngFilter.nofilt + push esi edi + mov ecx,[sline_len] + mov edi,esi + sub esi,ecx + dec esi + jmp Filt_sub.scan + +Filt_av: + pusha + mov ecx,[sline_len] + mov ebp,[PNG_info.Height] + mov edx,[png_bpp] ; edx-raw + neg edx + mov ebx,ecx + sub ebx,[png_bpp] + mov edi,esi + sub esi,ecx + dec esi ; esi-prior + .lpavg: + xor eax,eax + cmp [esp+24h],ebp + je .1stl + movzx eax,byte[esi] + .1stl: + cmp ecx,ebx + ja .leftbad + push ecx + movzx ecx,byte[edi+edx] + add eax,ecx + pop ecx + .leftbad: + shr eax,1 + add [edi],al + inc esi + inc edi + loop .lpavg + popa + jmp PngFilter.nofilt + +Filt_paeth: + pusha + mov ecx,[sline_len] + mov edx,[png_bpp] + neg edx + lea ebp,[ecx+edx] ; left edge + mov edi,esi + sub esi,ecx + dec esi + .lpaeth: + push ecx + movzx eax,byte[edi+edx] + movzx ebx,byte[esi] + movzx ecx,byte[esi+edx] + push eax + mov eax,[esp+28h] + cmp eax,[PNG_info.Height] ; 1st line + jne .no1stlineok + xor ebx,ebx + xor ecx,ecx + .no1stlineok: + pop eax + cmp [esp],ebp ; ecx + jbe .leftok ; x-bpp>=0 + xor eax,eax + xor ecx,ecx + .leftok: + pusha ; eax-28, ebx-16, ecx-24 + lea edx,[eax+ebx] + sub edx,ecx ; p=edx + sub eax,edx ; pa := abs(p - a) + jge .eaxp + neg eax + .eaxp: + sub ebx,edx ; pb := abs(p - b) + jge .ebxp + neg ebx + .ebxp: + sub ecx,edx ; pc := abs(p - c) + jge .ecxp + neg ecx + .ecxp: + cmp eax,ebx + ja .noa + cmp eax,ecx + jbe .ex ; pa-min + .noa: + cmp ebx,ecx + ja .nob + mov eax,[esp+16] + jmp .ex2 + .nob: + mov eax,[esp+24] + .ex2: + mov [esp+28],eax + .ex: + popa + add [edi],al + inc esi + inc edi + pop ecx + loop .lpaeth + popa + jmp PngFilter.nofilt + +rb_png: ; eax-dest; ecx-count + push ecx + xor eax,eax + .shift: + rol byte[cur_byte],1 + rcl eax,1 + .dec: + dec [bits] + jnz .loop1 + .push: + push dword[esi] + pop [cur_byte] + mov [bits],8 + inc esi + .loop1: + loop .shift + pop ecx + ret + +PngStore: + push esi + cmp [PNG_info.Bit_depth],8 + jbe .lo + add esi,3 + .lo: + if ~ SYS eq win + mov esi,[esi] + bswap esi + shr esi,8 + mov [edi],esi + add edi,3 + else + movsw + movsb + end if + pop esi + ret + +FiltStats: + pusha + xor ebx,ebx + mov edx,23 + mov ecx,6 + .lp: + push ecx edx + Msg edx + mov eax,[filters+ebx*4] + DebugPrintDec + pop edx ecx + inc edx + inc ebx + loop .lp + Newline + popa + ret + diff --git a/programs/other/archer/trunk/sys.inc b/programs/other/outdated/archer/trunk/sys.inc similarity index 94% rename from programs/other/archer/trunk/sys.inc rename to programs/other/outdated/archer/trunk/sys.inc index 02a6155a37..d1b5315a6d 100644 --- a/programs/other/archer/trunk/sys.inc +++ b/programs/other/outdated/archer/trunk/sys.inc @@ -1,357 +1,357 @@ -; @RCHER system-dependent and other stuff -; Written in pure assembler by Ivushkin Andrey aka Willow - -OpenFile: - mov [outp],output - mov esi,area - and [Finfo.block],0 -if SYS eq win - invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \ - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL - inc eax - test eax,eax - jz .ex - dec eax - mov [hnd],eax - invoke GetFileSize,eax,NULL - .ex: - mov ebx,eax - mov [filesize],eax -else - and dword [attrinfo+32], 0 - mcall 70,attrinfo - mov eax,[attrinfo+32] - mov [filesize],ebx - mcall 70,Finfo -end if - ret - -ResetFile: - and [file_count],0 - mov eax,[arc_base] - xor ebx,ebx - mov esi,area - call FileSeek - ret - - -FileSeek: -; eax - offset -; esi - current pointer (in memory!) -; ebx - translation method: 0 - beginning, 1 - current, 2 - end - push eax ecx edx - sub esi,BUFPTR - add esi,[Finfo.block] - cmp ebx,1 - je .cur - jb .begin - mov esi,[filesize] - not eax - .cur: - add eax,esi - .begin: - mov esi,BUFPTR - mov [Finfo.block],eax -if SYS eq win - invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN - invoke ReadFile,[hnd],area,INBUF, os_work, NULL -; add [byte_count],area -else -; pregs -; wait - mov [Finfo.count],BUFSIZE*1024 - mcall 70,Finfo -; mov [byte_count],area+INBUF -end if - pop edx ecx eax - ret - -macro QueryFile -{ -local ex -if SYS eq win - invoke GetOpenFileName,ofstruc -else - opendialog draw_window,QFok,QFcanc,filename - QFok: - xor eax,eax - jmp ex - ret - QFcanc: - mov eax,1 -end if - ex: -} - -RunViewer: - test [Flags],PNG_MODE - jz .ex - if SYS eq win - mov eax,[PNG_info.Width] - call int2str - invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file - mov eax,[PNG_info.Height] - call int2str - invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file - invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\ - NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo - invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF - invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt - invoke FindWindowEx, eax,NULL,NULL,ok_txt - invoke SendMessage,eax,BM_CLICK,NULL,NULL - else - test [Flags],THREAD_YES - jnz .ex - mcall 51,1,thread,child_stack_top;MEMORY - mov [child],eax - end if - .ex: - ret - -if SYS eq win -int2str: -; in: eax - number -; out: formatted string -> os_work - invoke wsprintf,os_work,fmt_str,eax - add esp,12 - ret - -rawwnd_txt db 'Set RAW open parameters',0 -ok_txt db 'OK',0 -ini_sec db 'RAW',0 -ini_rwidth db 'RWidth',0 -ini_rheight db 'RHeight',0 -ini_file db "C:\Program Files\IrfanView\i_view32.ini",0 -fmt_str db "%d",0 -iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"' - db ' "D:\Ivushkin\projects\zip\output.raw"',0 -filt_str: - db 'Pictures (*.png)',0,'*.png',0 - db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0 - db 'All files (*.*)',0,'*.*',0,0 - -suinfo STARTUPINFO -pinfo PROCESS_INFORMATION -cpstruc: -ofstruc: - dd ofstruc_end-ofstruc - dd NULL - dd NULL - dd filt_str - dd NULL - dd NULL - dd 0 - dd filename - dd 256 - dd NULL - dd 0 - dd NULL - dd NULL - dd NULL - dw NULL - dw NULL - dd NULL - dd NULL - dd NULL - dd NULL - dd NULL - dd NULL - dd NULL -ofstruc_end: - - else - mov ebx,-1 - mov ecx,ebx - mov edx,[PNG_info.Width] - add edx,10 - mov esi,[PNG_info.Width] - add esi,30 - mcall 67 - mcall 7,outfile,[outfile.size],10 shl 16+15 - .ext: - ret - -MIN_WIDTH equ 300 -thread: - .red: - mcall 12,1 - mov ebx,[PNG_info.Width] - cmp ebx,MIN_WIDTH - jae .more - mov ebx,MIN_WIDTH - .more: - add ebx,20 - mov ecx,[PNG_info.Height] - add ecx,30 - mcall 0,,,0x3808080 - ;mcall 4,<5,7>,0x10f0f0f0,filename,255 - mcall 71,1,filename,255 ;by Leency - mov ecx,[PNG_info.Width] - shl ecx,16 - add ecx,[PNG_info.Height] - mcall 7,[png_],,10 shl 16+25 - mcall 12,2 - .still: - mcall 10 - cmp eax,1 - je .red - cmp eax,2 - jne .nokey - mcall 2 - cmp ah,27 ; Esc - close - je .close - jmp .still - .nokey: - cmp eax,3 - jne .still - .close: - and [child],0 - mcall 64,1,MEMINIT - mcall -1 - -KillViewer: - pusha - mov edi,[child] - test edi,edi - jz .noth - mcall 9,os_work,-1 - mov ecx,eax - .fchild: - push ecx - mcall 9,os_work - cmp edi,[ebx+30] - jne .lp - mov ecx,[esp] - mcall 18,2 - pop ecx - jmp .noth - .lp: - pop ecx - loop .fchild - .noth: - popa - ret - -macro CmdLine -{ - mov esi,PARAM_PTR - .parse: - lodsb - - test al,al - jnz .noend - or [Flags],STAY_MODE - jmp red - .noend: - cmp al,' ' - je .stay - cmp al,'/' - jne .yespar - dec esi - mov ecx,255 - mov edi,filename - rep movsb - jmp again;cmdl - .yespar: - cmp al,'N' - jne .nonum - call get_6ASCII_num - .fnum: - mov [FileNum],eax - jmp .parse - .nonum: - cmp al,'n' - jne .nonum2 - lodsd - jmp .fnum - .nonum2: - cmp al,'s' - jne .nostay - .stay: - or [Flags],STAY_MODE - jmp .parse - .nostay: - cmp al,'i' - jne .noclPID - lodsd - mov [clientPID],eax - or [Flags],IPC_MODE - jmp .parse - .noclPID: - cmp al,'R' - jne .noraw - or [Flags],RAW_MODE - jmp .parse - .noraw: - cmp al,'q' - jne .noofs - lodsd - .fofs: - mov [arc_base],eax - jmp .parse - .noofs: - cmp al,'Q' - jne .noofs2 - call get_6ASCII_num - jmp .fofs - .noofs2: - cmp al,'L' - jne .nolist - or [Flags],LIST_MODE - .nolist: - jmp .parse - -get_6ASCII_num: -; in: esi - str ptr, out: eax - num - xor edx,edx - mov ebx,10 - mov ecx,6 - .lp: - xor eax,eax - lodsb - sub al,'0' - imul edx,ebx - add edx,eax - loop .lp - mov eax,edx - ret -} - -StartPad: - pusha - mov esi,[outfile.size] -; dpd esi -; convert number in esi to decimal representation - mov ecx, 10 - push -'0' - mov eax, esi -@@: - xor edx, edx - div ecx - push edx - test eax, eax - jnz @b - mov edi, par_fsize -@@: - pop eax - add al, '0' - stosb - jnz @b - mcall 70,fileinfo - mov ecx,eax - mcall 5,20 - mcall 60,2,,[outfile.out];output - mcall 64,1,MEMINIT - popa - ret - -fileinfo: - dd 7 - dd 0 - dd editor_par - dd 0 - dd 0 - db '/sys/TINYPAD',0 -editor_par db '*' -par_fsize rb 11 +; @RCHER system-dependent and other stuff +; Written in pure assembler by Ivushkin Andrey aka Willow + +OpenFile: + mov [outp],output + mov esi,area + and [Finfo.block],0 +if SYS eq win + invoke CreateFile, filename, GENERIC_READ, FILE_SHARE_READ, NULL, \ + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL + inc eax + test eax,eax + jz .ex + dec eax + mov [hnd],eax + invoke GetFileSize,eax,NULL + .ex: + mov ebx,eax + mov [filesize],eax +else + and dword [attrinfo+32], 0 + mcall 70,attrinfo + mov eax,[attrinfo+32] + mov [filesize],ebx + mcall 70,Finfo +end if + ret + +ResetFile: + and [file_count],0 + mov eax,[arc_base] + xor ebx,ebx + mov esi,area + call FileSeek + ret + + +FileSeek: +; eax - offset +; esi - current pointer (in memory!) +; ebx - translation method: 0 - beginning, 1 - current, 2 - end + push eax ecx edx + sub esi,BUFPTR + add esi,[Finfo.block] + cmp ebx,1 + je .cur + jb .begin + mov esi,[filesize] + not eax + .cur: + add eax,esi + .begin: + mov esi,BUFPTR + mov [Finfo.block],eax +if SYS eq win + invoke SetFilePointer,[hnd],eax,NULL,FILE_BEGIN + invoke ReadFile,[hnd],area,INBUF, os_work, NULL +; add [byte_count],area +else +; pregs +; wait + mov [Finfo.count],BUFSIZE*1024 + mcall 70,Finfo +; mov [byte_count],area+INBUF +end if + pop edx ecx eax + ret + +macro QueryFile +{ +local ex +if SYS eq win + invoke GetOpenFileName,ofstruc +else + opendialog draw_window,QFok,QFcanc,filename + QFok: + xor eax,eax + jmp ex + ret + QFcanc: + mov eax,1 +end if + ex: +} + +RunViewer: + test [Flags],PNG_MODE + jz .ex + if SYS eq win + mov eax,[PNG_info.Width] + call int2str + invoke WritePrivateProfileString,ini_sec,ini_rwidth,os_work,ini_file + mov eax,[PNG_info.Height] + call int2str + invoke WritePrivateProfileString,ini_sec,ini_rheight,os_work,ini_file + invoke CreateProcess,NULL,iview_cmd,NULL,NULL,TRUE,\ + NORMAL_PRIORITY_CLASS,NULL,NULL,suinfo,pinfo + invoke WaitForInputIdle,dword[pinfo],0xFFFFFFFF + invoke FindWindowEx, NULL,NULL,NULL,rawwnd_txt + invoke FindWindowEx, eax,NULL,NULL,ok_txt + invoke SendMessage,eax,BM_CLICK,NULL,NULL + else + test [Flags],THREAD_YES + jnz .ex + mcall 51,1,thread,child_stack_top;MEMORY + mov [child],eax + end if + .ex: + ret + +if SYS eq win +int2str: +; in: eax - number +; out: formatted string -> os_work + invoke wsprintf,os_work,fmt_str,eax + add esp,12 + ret + +rawwnd_txt db 'Set RAW open parameters',0 +ok_txt db 'OK',0 +ini_sec db 'RAW',0 +ini_rwidth db 'RWidth',0 +ini_rheight db 'RHeight',0 +ini_file db "C:\Program Files\IrfanView\i_view32.ini",0 +fmt_str db "%d",0 +iview_cmd db '"C:\Program Files\IrfanView\i_view32.exe"' + db ' "D:\Ivushkin\projects\zip\output.raw"',0 +filt_str: + db 'Pictures (*.png)',0,'*.png',0 + db 'Archives (*.zip;*.*gz)',0,'*.zip;*.*gz',0 + db 'All files (*.*)',0,'*.*',0,0 + +suinfo STARTUPINFO +pinfo PROCESS_INFORMATION +cpstruc: +ofstruc: + dd ofstruc_end-ofstruc + dd NULL + dd NULL + dd filt_str + dd NULL + dd NULL + dd 0 + dd filename + dd 256 + dd NULL + dd 0 + dd NULL + dd NULL + dd NULL + dw NULL + dw NULL + dd NULL + dd NULL + dd NULL + dd NULL + dd NULL + dd NULL + dd NULL +ofstruc_end: + + else + mov ebx,-1 + mov ecx,ebx + mov edx,[PNG_info.Width] + add edx,10 + mov esi,[PNG_info.Width] + add esi,30 + mcall 67 + mcall 7,outfile,[outfile.size],10 shl 16+15 + .ext: + ret + +MIN_WIDTH equ 300 +thread: + .red: + mcall 12,1 + mov ebx,[PNG_info.Width] + cmp ebx,MIN_WIDTH + jae .more + mov ebx,MIN_WIDTH + .more: + add ebx,20 + mov ecx,[PNG_info.Height] + add ecx,30 + mcall 0,,,0x3808080 + ;mcall 4,<5,7>,0x10f0f0f0,filename,255 + mcall 71,1,filename,255 ;by Leency + mov ecx,[PNG_info.Width] + shl ecx,16 + add ecx,[PNG_info.Height] + mcall 7,[png_],,10 shl 16+25 + mcall 12,2 + .still: + mcall 10 + cmp eax,1 + je .red + cmp eax,2 + jne .nokey + mcall 2 + cmp ah,27 ; Esc - close + je .close + jmp .still + .nokey: + cmp eax,3 + jne .still + .close: + and [child],0 + mcall 64,1,MEMINIT + mcall -1 + +KillViewer: + pusha + mov edi,[child] + test edi,edi + jz .noth + mcall 9,os_work,-1 + mov ecx,eax + .fchild: + push ecx + mcall 9,os_work + cmp edi,[ebx+30] + jne .lp + mov ecx,[esp] + mcall 18,2 + pop ecx + jmp .noth + .lp: + pop ecx + loop .fchild + .noth: + popa + ret + +macro CmdLine +{ + mov esi,PARAM_PTR + .parse: + lodsb + + test al,al + jnz .noend + or [Flags],STAY_MODE + jmp red + .noend: + cmp al,' ' + je .stay + cmp al,'/' + jne .yespar + dec esi + mov ecx,255 + mov edi,filename + rep movsb + jmp again;cmdl + .yespar: + cmp al,'N' + jne .nonum + call get_6ASCII_num + .fnum: + mov [FileNum],eax + jmp .parse + .nonum: + cmp al,'n' + jne .nonum2 + lodsd + jmp .fnum + .nonum2: + cmp al,'s' + jne .nostay + .stay: + or [Flags],STAY_MODE + jmp .parse + .nostay: + cmp al,'i' + jne .noclPID + lodsd + mov [clientPID],eax + or [Flags],IPC_MODE + jmp .parse + .noclPID: + cmp al,'R' + jne .noraw + or [Flags],RAW_MODE + jmp .parse + .noraw: + cmp al,'q' + jne .noofs + lodsd + .fofs: + mov [arc_base],eax + jmp .parse + .noofs: + cmp al,'Q' + jne .noofs2 + call get_6ASCII_num + jmp .fofs + .noofs2: + cmp al,'L' + jne .nolist + or [Flags],LIST_MODE + .nolist: + jmp .parse + +get_6ASCII_num: +; in: esi - str ptr, out: eax - num + xor edx,edx + mov ebx,10 + mov ecx,6 + .lp: + xor eax,eax + lodsb + sub al,'0' + imul edx,ebx + add edx,eax + loop .lp + mov eax,edx + ret +} + +StartPad: + pusha + mov esi,[outfile.size] +; dpd esi +; convert number in esi to decimal representation + mov ecx, 10 + push -'0' + mov eax, esi +@@: + xor edx, edx + div ecx + push edx + test eax, eax + jnz @b + mov edi, par_fsize +@@: + pop eax + add al, '0' + stosb + jnz @b + mcall 70,fileinfo + mov ecx,eax + mcall 5,20 + mcall 60,2,,[outfile.out];output + mcall 64,1,MEMINIT + popa + ret + +fileinfo: + dd 7 + dd 0 + dd editor_par + dd 0 + dd 0 + db '/sys/TINYPAD',0 +editor_par db '*' +par_fsize rb 11 end if \ No newline at end of file diff --git a/programs/other/outdated/gifview/trunk/build_en.bat b/programs/other/outdated/gifview/trunk/build_en.bat new file mode 100644 index 0000000000..dddd6e5fad --- /dev/null +++ b/programs/other/outdated/gifview/trunk/build_en.bat @@ -0,0 +1,5 @@ +@erase lang.inc +@echo lang fix en >lang.inc +@fasm gifview.asm gifview +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/other/outdated/gifview/trunk/build_ru.bat b/programs/other/outdated/gifview/trunk/build_ru.bat new file mode 100644 index 0000000000..d47b2fb325 --- /dev/null +++ b/programs/other/outdated/gifview/trunk/build_ru.bat @@ -0,0 +1,5 @@ +@erase lang.inc +@echo lang fix ru >lang.inc +@fasm gifview.asm gifview +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/other/outdated/gifview/trunk/gif_lite.inc b/programs/other/outdated/gifview/trunk/gif_lite.inc new file mode 100644 index 0000000000..22322ef959 --- /dev/null +++ b/programs/other/outdated/gifview/trunk/gif_lite.inc @@ -0,0 +1,485 @@ +; GIF LITE v3.0 by Willow +; Written in pure assembler by Ivushkin Andrey aka Willow +; Modified by Diamond +; +; This include file will contain functions to handle GIF image format +; +; Created: August 15, 2004 +; Last changed: June 24, 2007 + +; Requires kglobals.inc (iglobal/uglobal macro) +; (program must 'include "kglobals.inc"' and say 'IncludeUGlobal' +; somewhere in uninitialized data area). + +; Configuration: [changed from program which includes this file] +; 1. The constant COLOR_ORDER: must be one of +; PALETTE - for 8-bit image with palette (sysfunction 65) +; MENUETOS - for MenuetOS and KolibriOS color order (sysfunction 7) +; OTHER - for standard color order +; 2. Define constant GIF_SUPPORT_INTERLACED if you want to support interlaced +; GIFs. +; 3. Single image mode vs multiple image mode: +; if the program defines the variable 'gif_img_count' of type dword +; somewhere, ReadGIF will enter multiple image mode: gif_img_count +; will be initialized with image count, output format is GIF_list, +; the function GetGIFinfo retrieves Nth image info. Otherwise, ReadGIF +; uses single image mode: exit after end of first image, output is +;