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 +;
+ +if ~ (COLOR_ORDER in ) +; This message may not appear under MenuetOS, so watch... + display 'Please define COLOR_ORDER: PALETTE, MENUETOS or OTHER',13,10 +end if + +if defined gif_img_count +; virtual structure, used internally + +struct GIF_list + NextImg rd 1 + Left rw 1 + Top rw 1 + Width rw 1 + Height rw 1 + Delay rd 1 + Displacement rd 1 ; 0 = not specified + ; 1 = do not dispose + ; 2 = restore to background color + ; 3 = restore to previous +if COLOR_ORDER eq PALETTE + Image rd 1 +end if +ends + +struct GIF_info + Left rw 1 + Top rw 1 + Width rw 1 + Height rw 1 + Delay rd 1 + Displacement rd 1 +if COLOR_ORDER eq PALETTE + Palette rd 1 +end if +ends + +; **************************************** +; FUNCTION GetGIFinfo - retrieve Nth image info +; **************************************** +; in: +; esi - pointer to image list header +; ecx - image_index (0...img_count-1) +; edi - pointer to GIF_info structure to be filled + +; out: +; eax - pointer to RAW data, or 0, if error + +GetGIFinfo: + push esi ecx edi + xor eax,eax + jecxz .eloop + .lp: + mov esi,[esi] + test esi,esi + jz .error + loop .lp + .eloop: + lodsd + movsd + movsd + movsd + movsd +if COLOR_ORDER eq PALETTE + lodsd + mov [edi],esi +else + mov eax,esi +end if + .error: + pop edi ecx esi + ret + +end if + +_null fix 0x1000 + +; **************************************** +; FUNCTION ReadGIF - unpacks GIF image +; **************************************** +; in: +; esi - pointer to GIF file in memory +; edi - pointer to output image list + +; out: +; eax - 0, all OK; +; eax - 1, invalid signature; +; eax >=8, unsupported image attributes +; + +ReadGIF: + push esi edi + mov [.cur_info],edi + xor eax,eax + mov [.globalColor],eax +if defined gif_img_count + mov [gif_img_count],eax + mov [.anim_delay],eax + mov [.anim_disp],eax +end if + inc eax + cmp dword[esi],'GIF8' + jne .ex ; signature + mov ecx,[esi+0xa] + add esi,0xd + mov edi,esi + test cl,cl + jns .nextblock + mov [.globalColor],esi + call .Gif_skipmap + .nextblock: + cmp byte[edi],0x21 + jne .noextblock + inc edi +if defined gif_img_count + cmp byte[edi],0xf9 ; Graphic Control Ext + jne .no_gc + movzx eax,word [edi+3] + mov [.anim_delay],eax + mov al,[edi+2] + shr al,2 + and eax,7 + mov [.anim_disp],eax + add edi,7 + jmp .nextblock + .no_gc: +end if + inc edi + .block_skip: + movzx eax,byte[edi] + lea edi,[edi+eax+1] + test eax,eax + jnz .block_skip + jmp .nextblock + .noextblock: + mov al,8 + cmp byte[edi],0x2c ; image beginning + jne .ex +if defined gif_img_count + inc [gif_img_count] +end if + inc edi + mov esi,[.cur_info] +if defined gif_img_count + add esi,4 +end if + xchg esi,edi +if defined GIF_SUPPORT_INTERLACED + movzx ecx,word[esi+4] + mov [.width],ecx + movzx eax,word[esi+6] + imul eax,ecx +if ~(COLOR_ORDER eq PALETTE) + lea eax,[eax*3] +end if + mov [.img_end],eax + inc eax + mov [.row_end],eax + and [.pass],0 + test byte[esi+8],40h + jz @f +if ~(COLOR_ORDER eq PALETTE) + lea ecx,[ecx*3] +end if + mov [.row_end],ecx +@@: +end if +if defined gif_img_count + movsd + movsd + mov eax,[.anim_delay] + stosd + mov eax,[.anim_disp] + stosd +else + movzx eax,word[esi+4] + stosd + movzx eax,word[esi+6] + stosd + add esi,8 +end if + push edi + mov ecx,[esi] + inc esi + test cl,cl + js .uselocal + push [.globalColor] + mov edi,esi + jmp .setPal + .uselocal: + call .Gif_skipmap + push esi + .setPal: + movzx ecx,byte[edi] + inc ecx + mov [.codesize],ecx + dec ecx +if ~(COLOR_ORDER eq PALETTE) + pop [.Palette] +end if + lea esi,[edi+1] + mov edi,.gif_workarea + xor eax,eax + lodsb ; eax - block_count + add eax,esi + mov [.block_ofs],eax + mov [.bit_count],8 + mov eax,1 + shl eax,cl + mov [.CC],eax + mov ecx,eax + inc eax + mov [.EOI],eax + mov eax, _null shl 16 + .filltable: + stosd + inc eax + loop .filltable +if COLOR_ORDER eq PALETTE + pop eax + pop edi + push edi + scasd + push esi + mov esi,eax + mov ecx,[.CC] +@@: + lodsd + dec esi + bswap eax + shr eax,8 + stosd + loop @b + pop esi + pop eax + mov [eax],edi +else + pop edi +end if +if defined GIF_SUPPORT_INTERLACED + mov [.img_start],edi + add [.img_end],edi + add [.row_end],edi +end if + .reinit: + mov edx,[.EOI] + inc edx + push [.codesize] + pop [.compsize] + call .Gif_get_sym + cmp eax,[.CC] + je .reinit + call .Gif_output + .cycle: + movzx ebx,ax + call .Gif_get_sym + cmp eax,edx + jae .notintable + cmp eax,[.CC] + je .reinit + cmp eax,[.EOI] + je .end + call .Gif_output + .add: + mov dword [.gif_workarea+edx*4],ebx + cmp edx,0xFFF + jae .cycle + inc edx + bsr ebx,edx + cmp ebx,[.compsize] + jne .noinc + inc [.compsize] + .noinc: + jmp .cycle + .notintable: + push eax + mov eax,ebx + call .Gif_output + push ebx + movzx eax,bx + call .Gif_output + pop ebx eax + jmp .add + .end: +if defined GIF_SUPPORT_INTERLACED + mov edi,[.img_end] +end if +if defined gif_img_count + mov eax,[.cur_info] + mov [eax],edi + mov [.cur_info],edi + add esi,2 + xchg esi,edi + .nxt: + cmp byte[edi],0 + jnz .continue + inc edi + jmp .nxt + .continue: + cmp byte[edi],0x3b + jne .nextblock + xchg esi,edi + and dword [eax],0 +end if + xor eax,eax + .ex: + pop edi esi + ret + +.Gif_skipmap: +; in: ecx - image descriptor, esi - pointer to colormap +; out: edi - pointer to area after colormap + + and ecx,111b + inc ecx ; color map size + mov ebx,1 + shl ebx,cl + lea ebx,[ebx*2+ebx] + lea edi,[esi+ebx] + ret + +.Gif_get_sym: + mov ecx,[.compsize] + push ecx + xor eax,eax + .shift: + ror byte[esi],1 + rcr eax,1 + dec [.bit_count] + jnz .loop1 + inc esi + cmp esi,[.block_ofs] + jb .noblock + push eax + xor eax,eax + lodsb + test eax,eax + jnz .nextbl + mov eax,[.EOI] + sub esi,2 + add esp,8 + jmp .exx + .nextbl: + add eax,esi + mov [.block_ofs],eax + pop eax + .noblock: + mov [.bit_count],8 + .loop1: + loop .shift + pop ecx + rol eax,cl + .exx: + xor ecx,ecx + ret + +.Gif_output: + push esi eax edx + mov edx,.gif_workarea + .next: + push word[edx+eax*4] + mov ax,word[edx+eax*4+2] + inc ecx + cmp ax,_null + jnz .next + shl ebx,16 + mov bx,[esp] + .loop2: + pop ax + + if COLOR_ORDER eq PALETTE + stosb + else + lea esi,[eax+eax*2] + add esi,[.Palette] + + if COLOR_ORDER eq MENUETOS + mov esi,[esi] + bswap esi + shr esi,8 + mov [edi],esi + add edi,3 + else + movsb + movsb + movsb + end if + end if + +if defined GIF_SUPPORT_INTERLACED + cmp edi,[.row_end] + jb .norowend + mov eax,[.width] +if ~(COLOR_ORDER eq PALETTE) + lea eax,[eax*3] +end if + push eax + sub edi,eax + add eax,eax + cmp [.pass],3 + jz @f + add eax,eax + cmp [.pass],2 + jz @f + add eax,eax +@@: + add edi,eax + pop eax + cmp edi,[.img_end] + jb .nextrow + mov edi,[.img_start] + inc [.pass] + add edi,eax + cmp [.pass],3 + jz @f + add edi,eax + cmp [.pass],2 + jz @f + add edi,eax + add edi,eax +@@: +.nextrow: + add eax,edi + mov [.row_end],eax + xor eax,eax +.norowend: +end if + + loop .loop2 + pop edx eax esi + ret + +uglobal +align 4 + ReadGIF.globalColor rd 1 + ReadGIF.cur_info rd 1 ; image table pointer + ReadGIF.codesize rd 1 + ReadGIF.compsize rd 1 + ReadGIF.bit_count rd 1 + ReadGIF.CC rd 1 + ReadGIF.EOI rd 1 +if ~(COLOR_ORDER eq PALETTE) + ReadGIF.Palette rd 1 +end if + ReadGIF.block_ofs rd 1 +if defined GIF_SUPPORT_INTERLACED + ReadGIF.row_end rd 1 + ReadGIF.img_end rd 1 + ReadGIF.img_start rd 1 + ReadGIF.pass rd 1 + ReadGIF.width rd 1 +end if +if defined gif_img_count + ReadGIF.anim_delay rd 1 + ReadGIF.anim_disp rd 1 +end if + ReadGIF.gif_workarea rb 16*1024 +endg diff --git a/programs/other/outdated/gifview/trunk/gifview.asm b/programs/other/outdated/gifview/trunk/gifview.asm new file mode 100644 index 0000000000..7f03a53926 --- /dev/null +++ b/programs/other/outdated/gifview/trunk/gifview.asm @@ -0,0 +1,293 @@ +; GIF VIEWER FOR MENUET v1.0 +; Written in pure assembler by Ivushkin Andrey aka Willow +; +; Uses GIF_LITE 2.0 +; +; Created: August 31, 2004 +; Last changed: August 25, 2006 +; +; COMPILE WITH FASM + +appname equ 'GIF VIEWER' + +; input line dimensions +INP_X equ 5 shl 16+680 +INP_Y equ 5 shl 16+16 +INP_XY equ 10 shl 16+10 + +use32 + + org 0x0 + + db 'MENUET01' + dd 0x01 + dd START + dd I_END + dd 0x400000 + dd 0x400000 + dd filename ;0x0 + dd 0x0 + +include 'lang.inc' +include '..\..\..\macros.inc' ; decrease code size (optional) + +COLOR_ORDER equ PALETTE +GIF_SUPPORT_INTERLACED = 1 +include 'gif_lite.inc' + +START: + cmp [filename],byte 0 + jne openfile2 +; jmp openfile2 +openfile: + xor eax,eax + mov [entered], eax + mov [gif_img_count],eax + mov esi,fn_input + mov edi,filename + mov ecx,[inp_pos] + rep movsb + stosb +openfile2: + mov ebx,file_info + mov eax,70 + mcall + cmp eax,6 + je temp + test eax,eax + jnz ok2 +temp: +; cmp ebx,64 +; jbe ok2 + + xor eax,eax + mov [entered], eax + mov esi,filename + mov edi,fn_input + mov ecx,256/4 ;[filename_len] + rep movsd + + mov edi,fn_input + mov ecx,256 + repne scasb + sub edi,fn_input + mov [inp_pos],edi + +; test eax,eax +; jnz .ok2 +; cmp ebx,64 +; jbe .ok2 + mov esi,workarea + mov edi,Image + call ReadGIF + test eax,eax + jz .ok + and [gif_img_count], 0 + .ok: + ok2: + and dword[img_index],0 + + mov ebx,3 + mov ecx,sc + mov edx,sizeof.system_colors + mov eax,48 + mcall + +red: + +; ********************************************* +; ******* ОПРЕДЕЛЕНИЕ И ОТРИСОВКА ОКНА ******* +; ********************************************* + +draw_window: + + mov ebx,1 + mov eax,12 + mcall + + xor eax,eax + mov ebx,50*65536+700 + mov ecx,50*65536+500 + mov edx,[sc.work] + or edx,0x33000000 + mov edi,title + mcall + + call draw_input + + xor ecx,ecx + call draw_subimage + cmp [gif_img_count],1 + jz @f + + mov ecx,[img_index] + call draw_subimage +@@: + + mov ebx,2 + mov eax,12 + mcall + +still: + cmp [gif_img_count], 1 + jbe .infinite + mov ebx, [cur_anim_delay] + test ebx, ebx + jz .infinite + mov eax, 23 + mcall + jmp @f +.infinite: + mov eax, 10 + mcall +@@: + dec eax + jz red + dec eax + jz key + dec eax + jz button + mov eax,[gif_img_count] + cmp eax,1 + je still + inc [img_index] + cmp eax,[img_index] + jne redsub + and [img_index],0 + redsub: + mov ecx,[img_index] + call draw_subimage + jmp still + + key: + mov eax,2 + mcall + cmp ah,13 + je is_input + jmp still + + button: + mcall 17 + cmp ah,1 + jnz wait_input + + _close: + or eax,-1 + mcall + + is_input: ; simple input line with backspace feature + inc [entered] ; sorry - no cursor + wait_input: + call draw_input + mov eax,10 + mcall + cmp al,2 + jne still + mov edi,[inp_pos] +; mov eax,2 + mcall + shr eax,8 + cmp al,27 + je still + cmp al,13 + je openfile + cmp al,8 + je backsp + mov [fn_input+edi],al + inc [inp_pos] + jmp wait_input + backsp: + test edi,edi + jz wait_input + dec [inp_pos] + jmp wait_input +; jmp still + +;**************************************** +;******* DRAW CONTENTS OF INPUT LINE **** +;**************************************** +draw_input: + mov esi,0xe0e0e0 + cmp [entered],0 + jne highlight + mov esi,0x00aabbcc + highlight: + mov ecx,INP_Y + mov edx,2 + mov ebx,INP_X + mov eax,8 + mcall + mov ecx,0x00107a30 + mov edx,fn_input + mov esi,[inp_pos] + mov ebx,INP_XY + mov eax,4 + mcall + ret + +draw_subimage: + cmp [gif_img_count],0 + jz .enddraw + mov esi,Image + mov edi,gif_inf + call GetGIFinfo + test eax,eax + jz .enddraw + mov ecx, dword [edi+GIF_info.Width-2] + mov cx, [edi+GIF_info.Height] + mov ebx,eax + mov eax, [edi+GIF_info.Delay] + mov [cur_anim_delay],eax + mov edx, dword [edi+GIF_info.Left-2] + mov dx, [edi+GIF_info.Top] + add edx,5 shl 16 +25 + mov esi, 8 + mov edi, [edi+GIF_info.Palette] + xor ebp, ebp + mov eax, 65 + mcall + .enddraw: + ret + +; Здесь находятся данные программы: + +title db appname,0 ; строка заголовка + +inp_pos dd inp_end-fn_input +fn_input: +; db '/hd/1/gif/smileys/sm100000.gif' + db '/sys/meos.gif' +; db '/hd/1/1/tex256.gif',0 +; db '/rd/1/tex256.gif' +inp_end: + rb 256-(inp_end-fn_input) + +file_info: + dd 0 + dd 0 + dd 0 + dd 0x100000;0x200000 + dd workarea;0x100000 +I_END: ; конец программы +filename: +; db '/hd/1/gif/smileys/sm112000.gif',0 +; db '/hd/1/gif/test.gif',0 +; db '/hd/1/gif/explode1.gif',0 +; db '/hd/1/gif/tapeta.gif',0 +; db '/hd/1/gif/meos.gif',0 + rb 257 +;filename_len dd 0 + +entered rd 1 +sc system_colors + +gif_img_count rd 1 +cur_anim_delay rd 1 +img_index rd 1 +gif_inf GIF_info + +IncludeUGlobals + +workarea rb 0x100000 + +Image: diff --git a/programs/other/outdated/jpegview/trunk/build_en.bat b/programs/other/outdated/jpegview/trunk/build_en.bat new file mode 100644 index 0000000000..8d33ac1e1b --- /dev/null +++ b/programs/other/outdated/jpegview/trunk/build_en.bat @@ -0,0 +1,5 @@ +@erase lang.inc +@echo lang fix en >lang.inc +@fasm jpegview.asm jpegview +@erase lang.inc +@pause \ No newline at end of file diff --git a/programs/other/outdated/jpegview/trunk/build_ru.bat b/programs/other/outdated/jpegview/trunk/build_ru.bat new file mode 100644 index 0000000000..2cf6968185 --- /dev/null +++ b/programs/other/outdated/jpegview/trunk/build_ru.bat @@ -0,0 +1,6 @@ +@erase lang.inc +@echo lang fix ru >lang.inc +@fasm jpegview.asm jpegview +@erase lang.inc +@kpack jpegview +@pause \ No newline at end of file diff --git a/programs/other/outdated/jpegview/trunk/filelib.asm b/programs/other/outdated/jpegview/trunk/filelib.asm new file mode 100644 index 0000000000..622eb13b7b --- /dev/null +++ b/programs/other/outdated/jpegview/trunk/filelib.asm @@ -0,0 +1,77 @@ +file_handler: + .operation=0 + .position=4 + .reserved=8 + .n_bytes=12 + .bufer=16 + .name=20 + .st_size=20+1024 + +open: ;esi=name_string + ;retorna eax + pushad + mov ecx,file_handler.st_size + call mallocz + mov [esp+28],edi + push edi + mov ecx,1024 + add edi,file_handler.name + call movedata + pop edi +; test if file exists + lea ebx,[edi+file_handler.operation] + mov byte[ebx],5 + mov dword[ebx+16],fileattr + mov eax,70 + int 0x40 + cmp eax,2 + jz .virtual + test eax,eax + jnz close.b +@@: + clc + popad + ret +.virtual: + mov byte [fileattr], 0x10 + jmp @b + +close: + pushad + .b: + mov edi,[esp+28] + call free + popad + xor eax,eax + ret + + +read: ;(f,bufer,nbytes) eax,edi,ecx ncr + ;retorna bytes leidos en ecx + pushad + lea ebx, [eax+file_handler.operation] + mov byte [ebx], 0 + mov [ebx+12], ecx + mov [ebx+16], edi + mov eax, 70 + int 0x40 + cmp ebx, -1 + sbb ebx, -1 + mov eax, [esp+28] + add [eax+file_handler.position], ebx + mov [esp+24], ebx + popad + ret + +ftell: mov edx,[eax+file_handler.position] + ret +lseek: ;eax=file edx=pos + mov [eax+file_handler.position],edx + ret +skip: ;eax=file edx=bytes to skip + add [eax+file_handler.position],edx + ret + + + + diff --git a/programs/other/outdated/jpegview/trunk/jpegdat.asm b/programs/other/outdated/jpegview/trunk/jpegdat.asm new file mode 100644 index 0000000000..d06f21010f --- /dev/null +++ b/programs/other/outdated/jpegview/trunk/jpegdat.asm @@ -0,0 +1,22 @@ +modes: +dd mcu100,color100,8,8 ;monocromo +dd mcu111,color111,8,8 +dd mcu211,color211,16,8 +dd mcu411,color411,16,16 + +zigzag: +db 0,0, 4+1,0, 32,1, 64,1, 36,2, 8+1,0, 12+1,0, 40,4 +db 68,2, 96,1, 128,1, 100,2, 72,4, 44,8, 16+1,0, 20+1,0 +db 48,16, 76,8, 104,4, 132,2, 160,1, 192,1, 164,2, 136,4 +db 108,8, 80,16, 52,32, 24+1,0, 28+1,0, 56,64, 84,32, 112,16 +db 140,8, 168,4, 196,2, 224,1, 228,2, 200,4, 172,8, 144,16 +db 116,32, 88,64, 60,128, 92,128, 120,64, 148,32, 176,16, 204,8 +db 232,4, 236,8, 208,16, 180,32, 152,64, 124,128, 156,128, 184,64 +db 212,32, 240,16, 244,32, 216,64, 188,128, 220,128, 248,64, 252,128 + +k: +dd 1.41421,1.84776,1.08239,-2.6131 +k2: +dd 0.3535534,0.49039264,0.46193953,0.415734806 +dd 0.3535534,0.277785116,0.191341716,0.0975451609 + diff --git a/programs/other/outdated/jpegview/trunk/jpeglib.asm b/programs/other/outdated/jpegview/trunk/jpeglib.asm new file mode 100644 index 0000000000..fdcabc5865 --- /dev/null +++ b/programs/other/outdated/jpegview/trunk/jpeglib.asm @@ -0,0 +1,1181 @@ +;405 412 586 +; +; +bufer_size=1024*16+2 +fichero=4 +mcu_ptr=8 +color_ptr=12 +estado=16 +color_c=17 +nbits=color_c +idct=20 +tmp_bits=24 +actable=28 +matriz_limit=32 +sourcebits=36 +sourcebits_index=40 +sourcebits_limit=44 +qt_ptrs=48 +ht_dc_ptrs=64 +ht_ac_ptrs=80 +matrices=96 +tmp_bufer=100 +x_org=104 +y_org=108 +x_mcu=112 +y_mcu=116 +x_size=120 +y_size=124 +x_org2=128 +y_org2=132 +x_mcu2=136 +y_mcu2=140 +x_size2=144 +y_size2=148 +q_ptr=152 +dc=164 +position=204 +draw_ptr=208 +struct_size=212 + +jpeg_info: ;fichero en eax + ;retorna ebp + xor ebp,ebp + pushad + mov ebp,esp + mov ecx,6 + sub esp,ecx + mov edi,esp + call read + pop dx + cmp dx,0d8ffh + je .l1 + mov esp,ebp + popad + ret + .l1: push eax + mov ecx,struct_size + call mallocz + mov [edi],ebp + mov ebp,edi + pop dword [ebp+fichero] + pop ax + pop cx + jmp .l3 + .l2: mov ebx,[ebp+tmp_bufer] + add ebx,[ebx-4] + mov cx,[ebx-2] + mov ax,[ebx-4] + .l3: push .l2 + xchg cl,ch + add cx,2 + cmp ch,3 + jnc .l4 + cmp al,0ffh + jne eoi + cmp ah,0dbh + je dqt + cmp ah,0c4h + je dht + cmp ah,0c0h + je sof0 + cmp ah,0dah + je sos + cmp ah,0c2h + je eoi + cmp ah,0c9h + je eoi + cmp ah,0d9h + je eoi + .l4: lea edx,[ecx-4] + xor ecx,ecx + mov eax,[ebp+fichero] + call skip + mov ecx,4 + call READ + cmp ecx,[edi-4] + jne eoi + ret + +eoi: + mov esp,[ebp] +; do not close file - this will be done by caller + and dword [ebp+fichero], 0 + call jpeg_close + popad + xor ebp,ebp + ret + +jpeg_close: + test ebp,ebp + jz .l2 + pushad + mov eax,[ebp+fichero] + call close + mov edi,[ebp+sourcebits] + call free + lea esi,[ebp+qt_ptrs] + mov ecx,14 + .l1: mov edi,[esi] + add esi,4 + call free + loop .l1 + mov edi,ebp + call free + popad + .l2: ret + +dqt: call READ + mov esi,edi + lea eax,[edi+ecx] + push eax + .l1: xor eax,eax + lodsb + cmp al,4 + jnc eoi + lea ebx,[ebp+qt_ptrs+eax*4] + test dword [ebx],-1 + jnz eoi + mov ecx,64 + xor eax,eax + sub esp,128 + mov edi,esp + .l2: lodsb + stosw + loop .l2 + mov ecx,256 + call malloc + mov [ebx],edi + mov eax,esi + mov esi,esp + pushad + mov ebp,zigzag + fninit + mov cl,64 + xor eax,eax + .l3: fild word[esi] + mov al,[ebp] + and al,-2 + add ebp,2 + add esi,2 + mov ebx,eax + and ebx,28 + fmul dword [ebx+k2] + mov ebx,eax + shr ebx,3 + and ebx,4+8+16 + fmul dword [ebx+k2] + fstp dword [edi+eax] + dec cl + jnz .l3 + popad + mov esi,eax + add esp,128 + mov eax,[esp] + sub eax,esi + jc eoi + cmp eax,4 + ja .l1 + jne eoi + pop eax + ret + +sof0: call READ + cmp byte [edi],8 + jne eoi ;precision + mov ax,[edi+1] + xchg al,ah + mov [ebp+y_size],ax + mov ax,[edi+3] + xchg al,ah + mov [ebp+x_size],ax + mov al,[edi+5] ;ncomponentes + mov cl,al + mov [ebp+color_c],al + mov edx,modes + dec al + jz .l1 + dec al + dec al + jnz eoi + mov al,[edi+10] + mov ah,[edi+13] + cmp ax,1111h + jne eoi + mov al,[edi+7] + add edx,16 + cmp al,11h + je .l1 + add edx,16 + cmp al,21h + je .l1 + add edx,16 + cmp al,22h + jne eoi + .l1: lea ebx,[ebp+q_ptr] + lea esi,[ebp+qt_ptrs] + mov [ebp+mcu_ptr],edx + .l2: movzx eax,byte [edi+8] + add edi,3 + cmp al,4 + jnc eoi + lea eax,[eax*4+esi] + mov [ebx],eax + add ebx,16 + dec cl + jnz .l2 + ret + +READ: mov eax,[ebp+fichero] + mov edi,[ebp+tmp_bufer] + movzx ecx,cx + call mresize + mov [ebp+tmp_bufer],edi + jmp read + +dht: call READ + mov esi,edi + lea eax,[edi+ecx] + push eax + .l1: lodsb + mov edi,esi + mov ebx,3+16 + and bl,al + cmp bl,al + jne eoi + shr bl,2 + and al,3 + or bl,al + lea ebx,[ebp+ht_dc_ptrs+ebx*4] + test dword [ebx],-1 + jnz eoi + mov cl,15 + mov al,[edi] + .l2: inc edi ;calcular numero de codigos + add al,[edi] + jc eoi + dec cl + jnz .l2 + movzx ecx,al + lea ecx,[ecx*4+2] + call malloc + mov [ebx],edi + call arbol_hf + mov eax,[esp] + sub eax,ebx + jc eoi + mov esi,ebx + cmp eax,4 + ja .l1 + jne eoi + pop eax + ret + +arbol_hf: ;esi=ht edi=memoria para el arbol + ;retorna en ebx el final de ht + ;codigos: bits 0-3=nbits del siguiente numero + ; bits 4-7=numero de zeros + ; bits 8-14=longitud de este codigo o error si =127 + ; bit 15=codigo/puntero + push ebp + lea ebx,[edi-2] + add ebx,[ebx-2] + mov word [ebx],-1 ;codigo de error si encontrado + push ebx + push esi + lea ebx,[esi+16] + mov ebp,esp + xor ecx,ecx + push edi + push ecx + add edi,2 + mov dx,1 + add dh,[esi] + jz .l3 + jmp .l2 + .l1: push edi + push ecx + add edi,2 + .l2: inc cl + cmp cl,dl + jc .l1 + mov al,[ebx] + inc ebx + mov ah,128 ;marca de codigo + or ah,dl + cmp edi,[ebp+4] + jnc .l5 + stosw + cmp esp,ebp + jnc .l5 + pop ecx + pop esi + lea eax,[edi-2] + sub eax,esi + mov [esi],ax + dec dh + jnz .l2 ;ncodigos + mov esi,[ebp] + .l3: inc esi + inc dl + cmp dl,17 + jnc .l4 + add dh,[esi] + jz .l3 + mov [ebp],esi + jmp .l2 + .l4: lea esp,[ebp+8] + pop ebp + ret + .l5: mov ebp,[ebp+8] + jmp eoi + +sos: sub ecx,4 ;a continuacion vienen los datos de la imagen + call READ + mov eax,[ebp+fichero] + call ftell + mov [ebp+position],edx + mov esi,edi + lea edi,[ebp+q_ptr] + lodsb ;numero de componentes + sub [ebp+color_c],al + jnz eoi + mov dh,al + .l1: mov ebx,[edi] + mov eax,[ebx] + stosd + lodsw + mov cl,ah + and eax,0f00h + and ecx,0f0h + shr eax,6 + shr ecx,2 + lea ebx,[ebp+ht_ac_ptrs+eax] + mov eax,[ebx] + lea ebx,[ebp+ht_dc_ptrs+ecx] + mov ecx,[ebx] + test eax,eax + jz eoi + test ecx,ecx + jz eoi + stosd + mov eax,ecx + stosd + add edi,4 + dec dh + jnz .l1 + mov edx,[ebp+mcu_ptr] + cmp edx,modes + jne .l2 + lea esi,[ebp+q_ptr] + lea edi,[ebp+q_ptr+32] + movsd + movsd + movsd + .l2: + mov esi,edx + push dword [esi] + pop dword [ebp+mcu_ptr] + push dword [esi+4] + pop dword[ebp+color_ptr] + push dword [esi+12] + pop dword [ebp+y_mcu] + push dword [esi+8] + pop dword [ebp+x_mcu] + mov ecx,64*18 + call malloc + mov [ebp+matrices],edi + mov ecx,bufer_size + call malloc + mov [ebp+sourcebits],edi + mov esp,[ebp] + mov [esp+8],ebp + popad + ret + +jpeg_display: + test ebp,ebp + jnz .inicio + ret + .inicio: + pushad + mov [ebp],esp + mov eax,[ebp+fichero] + mov edx,[ebp+position] + call lseek + mov edi,[ebp+sourcebits] + add edi,bufer_size + mov [ebp+sourcebits_index],edi + sub edi,2 + mov [ebp+sourcebits_limit],edi + mov edi,[ebp+matrices] + mov [ebp+matriz_limit],edi + xor eax,eax + mov [esp+8],eax + mov [ebp+estado],eax + mov [ebp+tmp_bits],eax + mov [ebp+dc],eax + mov [ebp+dc+16],eax + mov [ebp+dc+32],eax + + mov eax,[ebp+y_mcu] + mov ecx,[ebp+y_org] + sub ecx,eax + mov [ebp+y_org2],ecx + mov [ebp+y_mcu2],eax + push dword [ebp+y_size] + pop dword [ebp+y_size2] + .l3: push dword [ebp+x_org] + pop dword [ebp+x_org2] + push dword [ebp+x_mcu] + pop dword [ebp+x_mcu2] + push dword [ebp+x_size] + pop dword [ebp+x_size2] + mov eax,[ebp+y_mcu2] + add [ebp+y_org2],eax + sub [ebp+y_size2],eax + jnc .l4 + add eax,[ebp+y_size2] + jnz .cont + mov [esp+8],ebp + popad + ret + .cont: + mov dword [ebp+y_size2],0 + mov [ebp+y_mcu2],eax + .l4: + mov eax,[ebp+x_mcu2] + sub [ebp+x_size2],eax + jnc .l5 + add eax,[ebp+x_size2] + jz .l3 + mov dword [ebp+x_size2],0 + mov [ebp+x_mcu2],eax + call dword [ebp+mcu_ptr] + mov eax,[ebp+x_mcu] + mov ecx,[ebp+x_mcu2] + mov edx,[ebp+y_mcu2] + call recortar + jmp .l6 + .l5: + call dword [ebp+mcu_ptr] + mov ecx,[ebp+x_mcu2] + mov edx,[ebp+y_mcu2] + .l6: + mov eax,[ebp+x_org2] + mov ebx,[ebp+y_org2] + call dword [ebp+draw_ptr] + add [ebp+x_org2],ecx + mov ax,[ebp+estado] + test al,15 + jz .l4 + cmp ah,8 + jnc .l4 + xor edx,edx + mov [ebp+tmp_bits],edx + mov [ebp+dc],edx + mov [ebp+dc+16],edx + mov [ebp+dc+32],edx + add dword [ebp+sourcebits_index],2 + and word [ebp+estado],0c0h + test al,32 + jz .l4 + jmp .l3 + +color100: + push edi + .l1: lodsw + mov dl,ah + mov ah,al + stosw + mov ah,dl + stosb + mov al,dl + stosb + stosw + dec cl + jnz .l1 + pop edi + ret + +color111: + push edi + .l1: lodsw + mov bx,[esi+62] + mov dx,[esi+126] + xchg ah,bh + xchg ah,dl + xchg ah,bl + stosw + mov ax,bx + stosw + mov ax,dx + stosw + dec cl + jnz .l1 + pop edi + mov ecx,64*3 + jmp ybr_bgr + +color411: + push ebp + push edi + lea ebp,[esi+ecx*8] + .l1: push ecx + mov ax,[esi] + mov cx,[ebp] + mov dx,[ebp+64] + add ebp,2 + xchg ch,dl + mov bx,ax + mov ah,cl + mov bl,ch + mov [edi],ax + mov [edi+2],bx + mov [edi+4],cx + mov ax,[esi+8] + mov bh,ah + mov ah,cl + mov [edi+48],ax + mov [edi+48+2],bx + mov [edi+48+4],cx + mov ax,[esi+2] + mov bx,ax + mov ah,dl + mov bl,dh + mov [edi+6],ax + mov [edi+2+6],bx + mov [edi+4+6],dx + mov ax,[esi+8+2] + mov bh,ah + mov ah,dl + mov [edi+48+6],ax + mov [edi+48+2+6],bx + mov [edi+48+4+6],dx + pop ecx + add edi,12 + dec ecx + add esi,4 + test cl,1 + jnz .l1 + add esi,64-8 + test cl,2 + jnz .l1 + sub esi,128-16 + add edi,48 + test cl,15 + jnz .l1 + add esi,64 + test cl,cl + jnz .l1 + pop edi + pop ebp + mov ecx,64*4*3 + jmp ybr_bgr + +color211: + push ebp + push edi + lea ebp,[esi+ecx*4] + .l1: push ecx + mov ax,[esi] + mov cx,[ebp] + mov dx,[ebp+64] + add ebp,2 + xchg ch,dl + mov bx,ax + mov ah,cl + mov bl,ch + mov [edi],ax + mov [edi+2],bx + mov [edi+4],cx + mov ax,[esi+2] + mov bx,ax + mov ah,dl + mov bl,dh + mov [edi+6],ax + mov [edi+2+6],bx + mov [edi+4+6],dx + pop ecx + add edi,12 + dec cl + add esi,4 + test cl,1 + jnz .l1 + add esi,64-8 + test cl,2 + jnz .l1 + sub esi,128-8 + test cl,cl + jnz .l1 + pop edi + pop ebp + mov ecx,64*3*2 + jmp ybr_bgr + + +mcu411: lea ebx,[ebp+q_ptr] + call hufdecode + lea ebx,[ebp+q_ptr] + call hufdecode +mcu211: lea ebx,[ebp+q_ptr] + call hufdecode +mcu111: lea ebx,[ebp+q_ptr] + call hufdecode + lea ebx,[ebp+q_ptr+16] + call hufdecode +mcu100: lea ebx,[ebp+q_ptr+32] + call hufdecode + mov esi,[ebp+matrices] + mov dword [ebp+matriz_limit],esi + mov ecx,32 + lea edi,[esi+64*6] + jmp dword [ebp+color_ptr] + +cargar_bits: ;edx=bits,cl=nbits, + ;bp=data struct + ;cr: cl,edx,eax,si + ;ncr bx,bp,di,ch + + mov esi,[ebp+sourcebits_index] + cmp esi,[ebp+sourcebits_limit] + jnc .l6 + movzx eax,byte [esi] + inc esi + add cl,8 + cmp al,-1 + je .l2 + mov ah,al + lodsb + add cl,8 + cmp al,-1 + je .l2 + .l1: ror eax,cl + or edx,eax + mov [ebp+sourcebits_index],esi + ret + .l2: lodsb + test al,al + jnz .l3 + mov al,-1 + call .l1 + cmp cl,16 + jc cargar_bits + ret + .l3: sub esi,2 + sub cl,8 + sub al,0d0h + cmp al,8 + jc .l4 + sub al,9 + mov al,63 + jz .l4 + mov al,127 + .l4: inc al + or [ebp+estado],al + movzx eax,ah + jmp .l1 + .l5: mov [ebp+sourcebits_limit],edi + mov word [edi],0d9ffh + popad + jmp cargar_bits + .l6: ;read file + pushad + mov ecx,bufer_size-2 + mov edx,[ebp+sourcebits_limit] + mov edi,[ebp+sourcebits] + mov ax,[edx] + sub edx,edi + stosw + sub esi,edx + mov [ebp+sourcebits_index],esi + cmp edx,ecx + jne .l5 + mov eax,[ebp+fichero] + call read + lea ecx,[edi+ecx-2] + mov [ebp+sourcebits_limit],ecx + popad + jmp cargar_bits + + +hufdecode: ;si->dctable [bp+20]->actable di->outbufer edx->bits cl->bits en edx + + + ;[bp+24]->sourcebits + ;[bp+22]=outbufer+128 + ;[bx] q ptr para aa&n + ;[bx+2] a ptr + ;[bx+4] d ptr + ;[bx+8] dc componente + fninit + push dword [ebx] + mov cl,[ebp+nbits] + mov edx,[ebp+tmp_bits] + cmp cl,16 + jnc .l1 + call cargar_bits + .l1: mov eax,[ebx+4] + mov esi,[ebx+8] + mov [ebp+actable],eax + movzx eax,word [esi] + add esi,2 + .l2: add edx,edx + jnc .l3 + add esi,eax + .l3: lodsw + test ax,ax + jns .l2 + ;codigo encontrado + and ax,7f0fh + mov edi,[ebp+matriz_limit] ;arrays + sub cl,ah + jns .l4 + fldz + .error: + xor ecx,ecx + or byte [ebp+estado],32 + jmp .l12 + .l4: cmp cl,al + jnc .l5 + push eax + call cargar_bits + pop eax + .l5: sub cl,al + mov ch,cl + mov cl,al + mov eax,edx + shl edx,cl + sar eax,17 + xor ax,8000h + xor cl,15 + sar ax,cl + mov cl,ch + mov ch,2 + add ax,8000h ;incrementar si negativo + adc ax,8000h + add [ebx+12],ax + fild word [ebx+12] + push ecx + mov ecx,64 + xor eax,eax + add [ebp+matriz_limit],ecx + rep stosd + pop ecx + sub edi,64*4 + mov ebx,[esp] + fmul dword [ebx] + .l6: cmp cl,16 + jnc .l7 + call cargar_bits + .l7: mov esi,[ebp+actable] + movzx eax,word[esi] + add esi,2 + .l8: add edx,edx + jnc .l9 + add esi,eax + .l9: lodsw + test ax,ax + jns .l8 + ;codigo encontrado + and ah,127 + xor ebx,ebx + sub cl,ah + js .error + or bl,al + jz .l12 + and al,0f0h + shr al,3 + add ch,al + js .error + and bl,0fh + jz .l11 + cmp cl,bl + jnc .l10 + call cargar_bits + .l10: sub cl,bl + xchg bl,cl + mov eax,edx + shl edx,cl + sar eax,17 + xor cl,15 + xor ax,8000h + sar ax,cl + add ax,8000h ;incrementar si negativo + adc ax,8000h + mov cl,bl + mov bl,ch + mov [ebp+tmp_bits],ax + mov ax,[ebx+zigzag] + mov ebx,[esp] + fild word [ebp+tmp_bits] + or [ebp+idct],ax + and eax,11111100b + fmul dword [ebx+eax] + fstp dword [edi+eax] + .l11: add ch,2 + jns .l6 + .l12: mov [ebp+nbits],cl + mov [ebp+tmp_bits],edx + xor ebx,ebx + add esp,4 + xchg ebx,[ebp+idct] + cmp ch,2 + je idctf1 + fstp dword [edi] + test bh,0feh + jnz idctf3 +idctf2a: test bh,1 + mov esi,edi + jz .l1 + test bl,1 + jnz idctf3 + push idctf2b + jmp idctf3b + .l1: call idctf3a + mov cl,4 + call limit + mov eax,[edi-8] + mov edx,[edi-4] + mov cl,7 + .l2: mov [edi],eax + mov [edi+4],edx + add edi,8 + dec cl + jnz .l2 + ret + +idctf1: fistp word[edi+64] + mov ax,128 + add ax,[edi+64] + jz .l2 + test ah,ah + jz .l1 + mov al,-1 + js .l2 + .l1: mov ah,al + stosw + stosw + mov eax,[edi-4] + mov ecx,15 + rep stosd + .l2: ret + +idctf3: mov bl,8 + mov esi,edi + .l1: rcr bh,1 + jc .l3 + mov eax,[esi] + test eax,eax + jz .l4 + mov cl,7 + .l2: add esi,32 + mov [esi],eax + dec cl + jnz .l2 + sub esi,32*7-4 + dec bl + jnz .l1 + jmp .l5 + .l3: call idctf3b + .l4: add esi,4 + dec bl + jnz .l1 + .l5: mov esi,edi + mov cl,8 + .l6: call idctf3a + add esi,32 + add edi,16 + dec cl + jnz .l6 + sub edi,128 + mov esi,edi + mov cl,32 +limit: mov dx,[esi] + mov bx,[esi+2] + add esi,4 + add dx,128 + add bx,128 + test dh,dh + mov ax,dx + jz .l1 + mov al,0 + js .l1 + mov al,-1 + .l1: test bh,bh + mov ah,bl + jz .l2 + mov ah,0 + js .l2 + mov ah,-1 + .l2: stosw + dec cl + jnz limit + ret + +idctf2b: + mov dl,8 + .l1: fld dword[esi] + add esi,32 + mov ax,128 + fistp word [edi] + add ax,[edi] + test ah,ah + jz .l2 + mov al,0 + js .l2 + mov al,-1 + .l2: mov ah,al + stosw + stosw + stosw + stosw + dec dl + jnz .l1 + ret + +idctf3a: ;si(d float),di(w int) ncr +fld dword[esi+1*4] ;f1 ;t21=f1+f7 +fld st0 +fld dword[esi+7*4] ;f7 +fadd st2,st0 +fsubp st1,st0 ;t22=f1-f7 +fld dword[esi+5*4] +fld st0 ;f5 ;t23=f5+f3 +fld dword[esi+3*4] ;f3 +fadd st2,st0 +fsubp st1,st0 ;t20=f5-f3 +fld st0 +fadd st0,st3 ;t25=(t20+t22)*k2 +fmul dword[k+4] ;k2 ;t25,t20,t23,t22,t21 +fld st4 ;t7=t21+t23 +fadd st0,st3 ;t7,t25,t20,t23,t22,t21 +fld dword[k+12] ;k4 ;t6=k4*t20+t25-t7 +fmulp st3,st0 +fsub st2,st0 +fld st1 +faddp st3,st0 ;t7,t25,t6,t23,t22,t21 +fld st5 ;t5=(t21-t23)*k1-t6 +fsub st0,st4 +fmul dword[k] ;k1 +fsub st0,st3 +fstp st6 ;t7,t25,t6,t23,t22,t5 +fstp st3 ;t25,t6,t7,t22,t5 +fxch st3 +fmul dword[k+8] ;k3 ;t4=k3*t22-t25+t5 +fadd st0,st4 ;t22*k3+t5,t6,t7,t25,t5 +fsubrp st3,st0 ;t6,t7,t4,t5 +fld dword[esi] ;f0 ;t10=f0+f4 +fst st5 ;f0,t4,t5,t6,t7,f0 +fld dword[esi+4*4] ;f4 +fsub st6,st0 ;t11=f0-f4 +faddp st1,st0 +fld st0 ;t10,t10,t6,t7,t4,t5,t11 +fld dword[esi+2*4] ;f2 ;t13=f2+f6 +fadd dword[esi+6*4] ;f6 ;t13,t10,t10,t6,t7,t4,t5,t11 +fadd st2,st0 ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13 +fsubp st1,st0 ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13 +fld st0 ;p3=t3-t4 +fsub st0,st5 +fistp word [edi+3*2] ;p3 +fadd st0,st4 ;p4=t3+t4 +fld dword[esi+2*4] ;f2 +fstp st5 +fistp word [edi+4*2] ;p4 ;t0,t6,t7,f2,t5,t11 +fld st0 ;p0=t0+t7 +fsub st0,st3 +fistp word [edi+7*2] ;p7 +fadd st0,st2 ;p7=t0-t7 +fistp word [edi] ;p0 ;t6,t7,f2,t5,t11 +fld st2 ;f2 ;f2,t6,t7,f2,t5,t11 ;t12=(f2-f6)*k1-t13 +fld dword[esi+6*4] ;f6 +fadd st4,st0 ;f6,f2,t6,t7,t13,t5,t11 +fsubp st1,st0 +fmul dword[k] ;k1 +fsub st0,st3 +fst st3 ;t12,t6,t7,t12,t5,t11 +fadd st0,st5 ;t1=t11+t12 +fst st2 ;t1,t6,t1,t12,t5,t11 +fadd st0,st1 ;p1=t1+t6 +fistp word [edi+2] ;p1 ;t6,t1,t12,t5,t11 +fsubp st1,st0 ;p6=t1-t6 +fistp word [edi+6*2] ;p6 ;t12,t5,t11 +fsubp st2,st0 ;t2=t11-t12 ;t5,t2 +fld st0 +fadd st0,st2 ;p2=t2+t5 +fistp word [edi+2*2] ;p2 +fsubp st1,st0 ;p5=t2-t5 ;t5,t2 +fistp word [edi+5*2] +ret ;p5 + + + + +idctf3b: ;si ncr +fld dword[esi+1*32] +fld st0 ;f1 ;t21=f1+f7 +fld dword[esi+7*32] +fadd st2,st0 ;f7 +fsubp st1,st0 ;t22=f1-f7 +fld dword[esi+5*32] +fld st0 ;f5 ;t23=f5+f3 +fld dword[esi+3*32] ;f3 +fadd st2,st0 +fsubp st1,st0 +fld st0 ;t20=f5-f3 +fadd st0,st3 ;t25=(t20+t22)*k2 +fmul dword[k+4] ;k2 ;t25,t20,t23,t22,t21 +fld st4 ;t7=t21+t23 +fadd st0,st3 ;t7,t25,t20,t23,t22,t21 +fld dword[k+12] ;k4 ;t6=k4*t20+t25-t7 +fmulp st3,st0 +fsub st2,st0 +fld st1 +faddp st3,st0 ;t7,t25,t6,t23,t22,t21 +fld st5 ;t5=(t21-t23)*k1-t6 +fsub st0,st4 +fmul dword[k] ;k1 +fsub st0,st3 +fstp st6 ;t7,t25,t6,t23,t22,t5 +fstp st3 +fxch st3 ;t25,t6,t7,t22,t5 +fmul dword[k+8] ;k3 ;t4=k3*t22-t25+t5 +fadd st0,st4 ;t22*k3+t5,t6,t7,t25,t5 +fsubrp st3,st0 ;t6,t7,t4,t5 +fld dword[esi] ;f0 ;t10=f0+f4 +fst st5 ;f0,t4,t5,t6,t7,f0 +fld dword[esi+4*32] ;f4 +fsub st6,st0 ;t11=f0-f4 +faddp st1,st0 +fld st0 ;t10,t10,t6,t7,t4,t5,t11 +fld dword[esi+2*32] ;f2 ;t13=f2+f6 +fadd dword[esi+6*32] ;f6 ;t13,t10,t10,t6,t7,t4,t5,t11 +fadd st2,st0 ;t13,t10,t0,t6,t7,t4,t5,t11 ;t0=t10+t13 +fsubp st1,st0 ;t3,t0,t6,t7,t4,t5,t11 ;t3=t10-t13 +fld st0 ;p3=t3-t4 +fsub st0,st5 +fstp dword[esi+3*32] ;p3 +fadd st0,st4 ;p4=t3+t4 +fld dword[esi+2*32] ;f2 +fstp st5 +fstp dword[esi+4*32] ;p4 ;t0,t6,t7,f2,t5,t11 +fld st0 +fsub st0,st3 ;p0=t0+t7 +fstp dword[esi+7*32] ;p7 +fadd st0,st2 ;p7=t0-t7 +fstp dword[esi] ;p0 ;t6,t7,f2,t5,t11 +fld st2 ;f2 ;f2,t6,t7,f2,t5,t11 ;t12=(f2-f6)*k1-t13 +fld dword[esi+6*32] ;f6 +fadd st4,st0 ;f6,f2,t6,t7,t13,t5,t11 +fsubp st1,st0 +fmul dword[k] ;k1 +fsub st0,st3 +fst st3 ;t12,t6,t7,t12,t5,t11 +fadd st0,st5 ;t1=t11+t12 +fst st2 ;t1,t6,t1,t12,t5,t11 +fadd st0,st1 ;p1=t1+t6 +fstp dword[esi+1*32] ;p1 ;t6,t1,t12,t5,t11 +fsubp st1,st0 ;p6=t1-t6 +fstp dword[esi+6*32] ;p6 ;t12,t5,t11 +fsubp st2,st0 +fld st0 ;t2=t11-t12 ;t5,t2 +fadd st0,st2 ;p2=t2+t5 +fstp dword[esi+2*32] ;p2 +fsubp st1,st0 ;p5=t2-t5 ;t5,t2 +fstp dword[esi+5*32] +ret ;p5 + +ybr_bgr: ;edi=bmp ecx=n_BYTES + ;retorna edi+=ecx + pushad + mov esi,edi + add edi,ecx + push edi + mov edi,[colortabla] + .l1: lodsw + movzx ebx,ah + movzx ebp,al + movzx eax,al + movzx ecx,byte[esi] + lea ebx,[ebx*4+edi+1024] + lea ecx,[ecx*4+edi] + add eax,[ebx] ;cb ;solo se usan 16 bits + mov edx,[ebx+2] ;pero el codigo de 32 bits es mas rapido + mov ebx,[ecx] ;cr + add eax,[ecx+2] + add ebx,ebp ;b + add edx,ebp ;r + test ah,ah + jz .l2 + mov al,0 + js .l2 + mov al,-1 + .l2: test dh,dh + jz .l3 + mov dl,0 + js .l3 + mov dl,-1 + .l3: test bh,bh + mov dh,al + jz .l4 + mov bl,0 + js .l4 + mov bl,-1 + .l4: mov [esi-2],dx + mov [esi],bl + inc esi + cmp esi,[esp] + jc .l1 + pop edi + popad + ret + +recortar: ;edi=bufer eax=ancho en pixels (ecx,edx)tamaдo deseado + pushad + dec edx + jz .l2 + lea ebx,[ecx*3] + lea eax,[eax*3] + lea esi,[edi+eax] + add edi,ebx + sub eax,ebx + .l1: mov ecx,ebx + call movedata + add esi,eax + dec edx + jnz .l1 + .l2: popad + ret + +;R = Y + 1.402 *(Cr-128) +;G = Y - 0.34414*(Cb-128) - 0.71414*(Cr-128) +;B = Y + 1.772 *(Cb-128) + +colortabla: dd 0 + +colorprecalc: ;prepara la tabla para convertir ycb a rgb + mov ecx,1024*2 + call malloc + mov [colortabla],edi + fninit + fld dword [.k+4] + fld dword [.k] + mov dl,0 + call .l1 + fld dword [.k+12] + fld dword[.k+8] + .l1: mov cx,-128 + .l2: mov [edi],ecx + inc ecx + fild word[edi] + fld st0 + fmul st0,st2 + fistp word[edi] + fmul st0,st2 + fistp word[edi+2] + add edi,4 + inc dl + jnz .l2 + ret + + .k: dd 1.402,-0.71414,-0.34414,+1.772 diff --git a/programs/other/outdated/jpegview/trunk/jpegview.asm b/programs/other/outdated/jpegview/trunk/jpegview.asm new file mode 100644 index 0000000000..dea7447b36 --- /dev/null +++ b/programs/other/outdated/jpegview/trunk/jpegview.asm @@ -0,0 +1,747 @@ +; IMGVIEW.ASM +; +; This program displays jpeg images. The window can be resized. +; +; Version 0.0 END OF 2003 +; Octavio Vega +; Version 0.1 7th March 2004 +; Mike Hibbett ( very small part! ) +; Version 0.11 7th April 2004 +; Ville Turjanmaa ( 'set_as_bgr' function ) +; Version 0.12 29th May 2004 +; Ivan Poddubny (correct "set_as_bgr"+parameters+boot+...) +; Version 0.12 30 de mayo 2004 +; Octavio Vega +; bugs correction and slideshow +; version 0.13 3 de junio 2004 +; Octavio Vega +; unos retoques +; version 0.14 10th August 2004 +; Mike Hibbett Added setting default colours +; version 0.15 24th August 2006 +; diamond (rewritten to function 70) +; version 0.16 19th May 2007 +; Mario79 +; 1) correction for changed function 15, +; 2) use monochrome background if free memory there are less than 2 MB +; 3) use COL0 - COL9 boot parameter +; 0=black,1=white,2=green,3=lilas,4=grey +; 5=light-blue,6=blue,7=salad,8=pink,9=yellow +; version 0.17 17th June 2007 +; diamond (background definition now uses shared memory) +; version 0.18 9th August 2007 +; Mario79 +; Open file with parameter in patch: +; Size of parameter - 4 bytes. Parameter starts with the character "\", +; the unused characters are filled by a blank (ASCII 20h). +; '\T /hd0/1/1.jpg' - set background, mode: tile +; '\S /hd0/1/1.jpg' - set background, mode: stretch + + memsize=20000h + org 0 + PARAMS = memsize - 1024 + +appname equ 'Jpegview ' +version equ '0.18' + +use32 + + db 'MENUET01' ; 8 byte id + dd 0x01 ; header version + dd START ; start of code + dd I_END ; size of image + dd memsize ; memory for app + dd memsize - 1024 ; esp + dd PARAMS , 0x0 ; I_Param , I_Icon + +stack_size=4096 + 1024 + +include '..\..\..\macros.inc' + +START: ; start of execution + mcall 68,11 ; initialize heap + + cmp [PARAMS], byte 0 + jne check_parameters + + ; Calculate the 'free' memory available + ; to the application, and create the malloc block from it + .l1: + mov ecx,memsize-fin-stack_size + mov edi,fin + call add_mem + + call colorprecalc ;inicializa tablas usadas para pasar de ybr a bgr + call draw_window + call read_string.rs_done + +still: + push still + mov ebx,100 ;1 second + mov eax,23 ; wait here for event + mcall + cmp eax,1 ; redraw request ? + je draw_window + cmp eax,2 ; key in buffer ? + je read_string + cmp eax,3 ; button in buffer ? + je button + jmp display_next + +button: ; BUTTON + mov eax,17 + mcall + cmp ah,3 + je set_as_bgr2 + cmp ah,2 + je slideshow + cmp ah,1 ; CLOSE PROGRAM + jne close_program.exit +close_program: + mov eax,-1 + mcall + .exit: + ret + + ; Put a 'chunk' of the image on the window +put_image: + pushad + + lea ebp,[edx+eax+7] + cmp [winxs],bp + jc .l1 + lea ebp,[ecx+ebx+20+2+17] + cmp [winys],bp + jc .l1 + + add eax,2 ; offset for boarder + add ebx,2 ; offset for title bar + push ax ; pox + push bx ; pos + push cx ; size + push dx ; size + pop ecx + pop edx + mov ebx,edi + mov eax,7 + + mcall ; Put image function +.l1: + popad + ret + + + +;****************************************************************************** + +check_parameters: + cmp [PARAMS], dword "BOOT" ; received BOOT parameter -> goto handler + je boot_set_background + cmp [PARAMS], word "CO" + jne @f + cmp [PARAMS+2], byte "L" + je boot_set_background +@@: + cmp byte [PARAMS], "\" + jne @f + cmp [PARAMS+1], byte "S" + jne .tile + mov [drawing_mode],2 + jmp @f +.tile: + cmp [PARAMS+1], byte "T" + jne @f + mov [drawing_mode],1 +@@: + cmp byte [PARAMS], 1 + jz ipc_service + mov edi, name_string ; clear string with file name + mov al, 0 + mov ecx, 100 + rep stosb + + mov ecx, 100 ; calculate length of parameter string + mov edi, PARAMS + repne scasb + + sub edi, PARAMS + mov ecx, edi + mov esi, PARAMS ; copy parameters to file name + mov edi, name_string + cmp byte [PARAMS], "\" + jne @f + add esi,4 + sub ecx,4 +@@: + cld + rep movsb + + cmp byte [PARAMS], "\" + je boot_set_background.1 + + jmp START.l1 ; return to beggining of the progra +;****************************************************************************** +boot_set_background: + mov [drawing_mode],2 +.1: + mcall 18,16 + cmp eax,1024*2 + jb set_mono + mov ecx,memsize-fin-stack_size ; size + mov edi,fin ; pointer + call add_mem ; mark memory from fin to 0x100000-1024 as free + call colorprecalc ; calculate colors + mov esi,name_string + call open + test eax,eax + jz close_program + call jpeg_info + mov dword [jpeg_st],ebp + call set_as_bgr2 ; set wallpaper + jmp close_program ; close the program right now + +;****************************************************************************** +set_mono: + mov eax, 15 + mov ebx, 1 + mov ecx, 1 + mov edx, 1 + mcall + + cmp [PARAMS], dword "BOOT" ; received BOOT parameter -> goto handler + jne @f +.green: + mov ecx,mono+6 + jmp .set +@@: +; cmp [PARAMS], word "CO" ; received BOOT parameter -> goto handler +; jne .green + xor ecx,ecx + mov cl,[PARAMS+3] + sub cl,0x30 + cmp ecx,0 + jb .green + cmp ecx,9 + ja .green + imul ecx,3 + add ecx,mono +.set: + mcall 15,5, ,0,3 + + ; Stretch the image to fit + mov eax, 15 + mov ebx, 4 + mov ecx, 1 + mcall + + mov eax, 15 + mov ebx, 3 + mcall + jmp close_program + +mono: + db 0,0,0 ; black + db 255,255,255 ; white + db 128,128,0 ; green + db 240,202,166 ; lilas + db 192,192,192 ; grey + db 255,255,0 ; light-blue + db 255,0,0 ; blue + db 192,220,192 ; salad + db 255,0,255 ; pink + db 0,255,255 ; yellow +;****************************************************************************** + +set_as_bgr2: + mov ebp,dword[jpeg_st] + test ebp,ebp + jz .end + + mov eax, 15 + mov ebx, 1 + mov ecx, [ebp + x_size] + mov edx, [ebp + y_size] + mcall + + mov ebx, 6 + mcall + test eax, eax + jz .end + mov [ipc_mem_out], eax + + mov dword [ebp+draw_ptr],put_chunk_to_mem + call jpeg_display + + mov eax, 15 + mov ebx, 7 + mov ecx, [ipc_mem_out] + mcall + + ; Stretch the image to fit + mov eax, 15 + mov ebx, 4 + mov ecx, [drawing_mode] ;2 + mcall + + mov eax, 15 + mov ebx, 3 + mcall + + + .end: + ret + +;****************************************************************************** + +ipc_service: + mov esi, PARAMS+1 + xor eax, eax + xor ecx, ecx +@@: + lodsb + test al, al + jz @f + lea ecx, [ecx*5] + lea ecx, [ecx*2+eax-'0'] + jmp @b +@@: + add ecx, 16 + mov edx, ecx + mcall 68, 12 + test eax, eax + jnz @f +.exit: + mcall -1 +@@: + mov ecx, eax + and dword [ecx], 0 + mov dword [ecx+4], 8 + mov [ipc_mem], ecx + mcall 60, 1 + mcall 40, 1 shl 6 + mcall 23, 500 ; wait up to 5 seconds for IPC message + test eax, eax + jz .exit +; we got message with JPEG data, now decode it + mov eax, [ecx+12] + mov [ipc_mem_size], eax +; init JPEG decoder + mov ecx,memsize-fin-stack_size ; size + mov edi,fin ; pointer + call add_mem ; mark memory from fin to 0x100000-1024 as free + call colorprecalc ; calculate colors +; hook file functions + mov ecx, 4 + call malloc + and dword [edi], 0 + lea eax, [edi-file_handler.position] + mov byte [read], 0xE9 + mov dword [read+1], read_from_mem - (read+5) +; decode + call jpeg_info + mov dword [jpeg_st],ebp + test ebp,ebp + jz .end + + mov eax, [ebp + x_size] + mul dword [ebp + y_size] + lea eax, [eax*3+8] + mov ecx, eax + mcall 68, 12 + test eax, eax + jz .end + add eax, 8 + mov [ipc_mem_out], eax + mov ebx, [ebp + x_size] + mov [eax-8], ebx + mov ebx, [ebp + y_size] + mov [eax-4], ebx + + mov dword [ebp+draw_ptr],put_chunk_to_mem + call jpeg_display + +; IPC response + mov esi, [ebp + x_size] + imul esi, [ebp + y_size] + lea esi, [esi*3+8] + mov edx, [ipc_mem_out] + sub edx, 8 +.response: + mov ecx, [ipc_mem] + mov ecx, [ecx+8] + mcall 60,2 + + jmp close_program ; close the program right now + +.end: + mov esi, 8 + mov edx, x_pointer ; points to 2 null dwords + jmp .response + +read_from_mem: +; in: eax=handle, ecx=size, edi=pointer to buffer +; out: ecx=number of read bytes, buffer filled + pushad + mov esi, [ipc_mem] + add esi, 16 + add esi, [eax+file_handler.position] + add ecx, [eax+file_handler.position] + cmp ecx, [ipc_mem_size] + jb @f + mov ecx, [ipc_mem_size] +@@: + sub ecx, [eax+file_handler.position] + add [eax+file_handler.position], ecx + rep movsb + popad + ret + +;****************************************************************************** + +put_chunk_to_mem: +; in: (eax,ebx) = start coordinates of chunk +; (ecx,edx) = sizes of chunk +; edi -> chunk data + push esi edi edx + mov esi, edi + mov edi, ebx + imul edi, [ebp + x_size] + add edi, eax + lea edi, [edi*3] + add edi, [ipc_mem_out] +@@: + push ecx edi + lea ecx, [ecx*3] + rep movsb + pop edi ecx + add edi, [ebp + x_size] + add edi, [ebp + x_size] + add edi, [ebp + x_size] + dec edx + jnz @b + pop edx edi esi + ret + +;****************************************************************************** + + + +; ********************************************* +; ******* WINDOW DEFINITIONS AND DRAW ******** +; ********************************************* + + +draw_window: + + mov eax,48 + mov ebx,3 + mov ecx,sc + mov edx,sizeof.system_colors + mcall + + mov eax,12 + mov ebx,1 + mcall + + ; Draw the window to the appropriate size - it may have + ; been resized by the user + cmp [winxs], 0 + jne dw_001 + + ; Give the screen some inital defaults + mov [winxs], 400 + mov [winys], 300 + mov ax, 100 + mov [winxo], ax + mov [winyo], ax + jmp dw_002 + +dw_001: + mov eax, 9 + mov ebx, memsize - 1024 + mov ecx, -1 + mcall + mov eax, [ebx + 34] + mov [winxo], ax + mov eax, [ebx + 38] + mov [winyo], ax + mov eax, [ebx + 42] + mov [winxs], ax + mov eax, [ebx + 46] + mov [winys], ax + +dw_002: + mov ebx, dword [winxo-2] + mov bx, [winxs] + mov ecx, dword [winyo-2] + mov cx, [winys] + + xor eax,eax ; DRAW WINDOW + mov edx,[sc.work] + or edx,0x33000000 + mov edi,title ; WINDOW LABEL + mcall + + + mov eax,8 ; BUTTON 2: slideshow + mov ebx,57 + mov cx, [winys] + sub cx, 39 + shl ecx, 16 + add ecx, 12 + mov esi, [sc.work_button] + mov edx,2 + mcall + + mov eax,4 ; Button text + movzx ebx, word [winys] + add ebx, 3 shl 16 - 36 + mov ecx,[sc.work_button_text] + mov edx,setname + mov esi,setnamelen-setname + mcall + + + mov eax,8 ; BUTTON 3: set as background + mov bx, [winxs] + sub bx, 65 + shl ebx, 16 + mov bx,55 + mov cx, [winys] + sub cx, 39 + shl ecx, 16 + add ecx, 12 + mov esi, [sc.work_button] + mov edx,3 + mcall + + mov eax,4 ; Button text + movzx ebx, word [winxs] + sub ebx, 63 + shl ebx,16 + mov bx, word [winys] + sub bx,36 + mov ecx,[sc.work_button_text] + mov edx,setbgr + mov esi,setbgrlen-setbgr + mcall + call print_strings + call load_image + mov eax,12 ; function 12:tell os about windowdraw + mov ebx,2 ; 2, end of draw + mcall + + ret + + + + ; Read in the image file name. +read_string: + movzx edi,byte[name_string.cursor] + add edi,name_string + mov eax,2 + mcall ; Get the key value + shr eax,8 + cmp eax,13 ; Return key ends input + je .rs_done + cmp eax,8 + jnz .nobsl + cmp edi,name_string + je .exit + dec edi + mov [edi],byte 0;'_' + dec byte[name_string.cursor] + jmp print_strings +.exit: ret +.nobsl: + cmp eax,31 + jbe .exit + cmp eax,97 + jb .keyok + sub eax,32 +.keyok: + mov ah,0 + stosw + cmp edi,name_string.end + jnc print_strings + inc byte[name_string.cursor] + jmp print_strings +.rs_done: + call print_strings + mov esi,name_string + call open + test eax,eax + jz .exit + call jpeg_info + test ebp,ebp + jz close + xchg [jpeg_st],ebp + call jpeg_close + +load_image: + + mov eax,13 ; clear picture area + movzx ebx, word [winxs] + add ebx, 1 shl 16 -10 + movzx ecx, word [winys] + sub ecx, 40 + add ecx, 1 shl 16 + + mov edx,[sc.work] + mcall + mov ebp,[jpeg_st] + test ebp,ebp + jz .exit + mov dword [ebp+draw_ptr],put_image + jmp jpeg_display + .exit: ret + +print_strings: + pusha + mov eax,13 ; clear text area + movzx ebx, word [winxs] + add ebx, 59 shl 16 -125 + mov cx, [winys] + sub cx, 39 + shl ecx, 16 + add ecx, 12 + mov edx,0xffffff + mcall + + mov eax,4 ; + movzx ebx, word [winys] + add ebx, 61 shl 16 - 37 + mov ecx,0x000000 + mov edx,name_string + mov esi,60 + mcall + popa + ret + +slideshow: + cmp [file_dir], 0 + jnz .exit + cmp [jpeg_st], 0 + jz .exit + mov esi, name_string + movzx ecx, byte [name_string.cursor] +.l1: + cmp byte [esi+ecx], '/' + jz .l2 + loop .l1 +.exit: + ret +.l2: + mov byte [esi+ecx], 0 + call open + mov byte [esi+ecx], '/' + test eax, eax + jz .exit + test byte [fileattr], 0x10 + jz .exit + mov [file_dir], eax + inc ecx + mov [name_string.cursor], cl +display_next: + mov ebx, [file_dir] + test ebx, ebx + jnz @f + ret +@@: + mov byte [ebx], 1 + mov byte [ebx+12], 1 + mov dword [ebx+16], dirinfo + mov eax, 70 + mcall + mov eax, [file_dir] + inc dword [eax+4] + cmp ebx, 1 + jz @f + mov eax, [file_dir] + and [file_dir], 0 + jmp close +@@: + movzx edi, byte [name_string.cursor] + add edi, name_string + lea esi, [dirinfo+32+40] +@@: + lodsb + stosb + test al, al + jnz @b + mov ecx, name_string.end + sub ecx, edi + rep stosb + call print_strings + mov esi,name_string + call open + test eax,eax + jz display_next + call jpeg_info + test ebp,ebp + jnz .l6 + call close + jmp display_next + .l6: + mov dword[ebp+draw_ptr],put_image + push ebp + xchg [jpeg_st],ebp + call jpeg_close + pop ebp + jmp jpeg_display + + +include 'filelib.asm' +include 'memlib.asm' +include 'jpeglib.asm' + + +; DATA AREA + +wcolor dd 0x000000 +drawing_mode dd 2 +title db appname,version,0 +setname db 'SLIDESHOW' +setnamelen: + +setbgr db ' BGR ' +setbgrlen: + +x_pointer dd 0 +x_offset dd 0 +x_numofbytes dd 0 +x_numofb2 dd 0 +x_counter dd 0 +winxo dw 0 +winyo dw 0 +winxs dw 0 +winys dw 0 +jpeg_st dd 0 +file_dir dd 0 +name_string: db '/sys/jpegview.jpg',0 +rb 256 + .end: + .cursor: db 19 + .cursor2: db 0 + +align 4 + +rgb16: db 0,4,8,13,17,21,25,29,34,38,42,46,50,55,59,63 +rgb4: db 0,21,42,63 + +include 'jpegdat.asm' + +align 4 + +iniciomemoria: + dd -(iniciomemoria+4),-(iniciomemoria+4),(iniciomemoria+4),.l1,0 +.l1 dd 0 + +I_END: +sc system_colors +ipc_mem dd ? +ipc_mem_size dd ? +ipc_mem_out dd ? +fileattr: rb 40 +dirinfo: rb 32+304 +fin: diff --git a/programs/other/outdated/jpegview/trunk/memlib.asm b/programs/other/outdated/jpegview/trunk/memlib.asm new file mode 100644 index 0000000000..65bbc7a480 --- /dev/null +++ b/programs/other/outdated/jpegview/trunk/memlib.asm @@ -0,0 +1,210 @@ + +movedata: + push eax + xor eax,eax + sub eax,edi + and eax,3 + xchg ecx,eax + sub eax,ecx + jle .l1 + rep movsb + mov ecx,eax + shr ecx,2 + rep movsd + and eax,3 + .l1: add ecx,eax + rep movsb + pop eax + ret + +mallocz: + call malloc + pushad + add ecx,3 + xor eax,eax + shr ecx,2 + rep stosd + popad + ret + + mresize1: popad + xor edi,edi + stc + mresize2: ret +mresize: ; puntero en di ncr retorna nuevo puntero en di + test edi,edi + jz malloc + cmp ecx,[edi-4] + je mresize2 + call free +malloc: + mov edi,ecx + jecxz mresize2 + pushad + mov esi,iniciomemoria+4 + lea ebx,[ecx+3] + and ebx,-4 ;redondeo a 4 + .l1: mov edi,esi + add esi,[esi] + jc mresize1 + lodsd + cmp eax,ebx + jc .l1 + cmp esi,[iniciomemoria+8] + jc .l2 + jne mresize1 + lea edx,[ebx+esi+4] + cmp edx,[iniciomemoria+12] + jnc mresize1 + mov [iniciomemoria+8],edx + .l2: pop dword [esi-4] + push esi + sub eax,ebx + je .l3 + sub eax,4 + mov [esi+ebx],eax + jz .l3 + ;fragmentar + add ebx,4 + add [edi],ebx + mov eax,[esi] + sub eax,ebx + mov [esi+ebx],eax + popad + ret + .l3: lodsd + add eax,4 + add [edi],eax + popad + ret + +realloc: test edi,edi + jz malloc + jecxz free + pushad + pop esi + mov eax,[edi-4] + call malloc + push edi + cmp ecx,eax + jc .l1 + mov ecx,eax + .l1: push esi + call movedata + pop edi + call free + popad + .l2: ret +free: ;puntero en di + ;no se comprueban los punteros + ;retorna di=0 , ncr + test edi,edi + jz realloc.l2 + pushad + pop edi + mov ebp,[edi-4] + dec ebp + and ebp,-4 ;redondeo a 4,dx=dx-4 + xor edx,edx + push edx + mov edx,iniciomemoria+4 + mov esi,edx + ;buscar puntero libre anterior + .l1: mov ebx,esi + lodsd + add esi,eax + cmp esi,edi + jc .l1 + ;enlazar + mov ecx,esi + sub ecx,edi + sub eax,ecx + sub ecx,4 + mov [ebx],eax + ;fusionar con el anterior + cmp eax,[ebx-4] + jne .l2 + cmp ebx,edx + je .l2 ;no fusionar con el primero + mov edi,ebx + add eax,4 + add ecx,eax + add ebp,eax + .l2: mov ebx,ebp ;fusionar con bloques de tamaдo 0 + .l3: add ebx,4 + test dword [edi+ebx],-1 + jz .l3 + cmp ebx,ecx + jne .l4 + ;fusionar con el siguiente + add ebx,[esi-4] + add ecx,[esi] + add ebx,4 + add ecx,4 + cmp esi,[edx+4] + jne .l4 + mov [edx+4],edi + .l4: mov [edi-4],ebx + mov [edi],ecx + popad + ret + +add_mem: ;edi,ecx ;el ultimo bloque libre debe ser >8 bytes para poder fragmentarlo + cmp ecx,64 + jc .l1 + add ecx,edi + add edi,3 + and edi,-4 + and ecx,-4 + mov eax,ecx + sub ecx,edi ;redondeo + xchg eax,[iniciomemoria+12] + cmp edi,eax + jna .l1 + lea esi,[edi+4] + mov edx,esi + xchg esi,[iniciomemoria+8] + neg edx + mov [edi],edx + mov [edi+4],edx + lea edx,[edi-4] + sub edi,esi + mov [esi],edi + sub eax,4 + sub eax,esi + mov [esi-4],eax + add esi,eax + sub edx,esi + mov [esi],edx + .l1: ret + +check_mem: ;busqueda de errores en la memoria + ;retorna edx nbloques o 0 si error,ecx memoria libre + ;ncr: ebp,ebx,eax + mov edi,iniciomemoria + mov esi,edi + xor edx,edx + mov ecx,[edi] + neg ecx ;el primer bloque no cuenta + .l1: add ecx,[edi] + add edi,4 + add edi,[edi] + .l2: inc edx + add esi,[esi] + jc .l4 + add esi,7 + jc .l3 + and esi,-4 + cmp esi,edi + jc .l2 + je .l1 + jmp .l4 + .l3: test edi,edi + jnz .l4 + add ecx,[iniciomemoria+12] + ret + .l4: xor edx,edx + stc + ret + + diff --git a/programs/other/kerpack/trunk/build.bat b/programs/other/outdated/kerpack/trunk/build.bat similarity index 100% rename from programs/other/kerpack/trunk/build.bat rename to programs/other/outdated/kerpack/trunk/build.bat diff --git a/programs/other/kerpack/trunk/build.sh b/programs/other/outdated/kerpack/trunk/build.sh old mode 100755 new mode 100644 similarity index 100% rename from programs/other/kerpack/trunk/build.sh rename to programs/other/outdated/kerpack/trunk/build.sh diff --git a/programs/other/kerpack/trunk/calltrick2.inc b/programs/other/outdated/kerpack/trunk/calltrick2.inc similarity index 100% rename from programs/other/kerpack/trunk/calltrick2.inc rename to programs/other/outdated/kerpack/trunk/calltrick2.inc diff --git a/programs/other/kerpack/trunk/kerpack.asm b/programs/other/outdated/kerpack/trunk/kerpack.asm similarity index 100% rename from programs/other/kerpack/trunk/kerpack.asm rename to programs/other/outdated/kerpack/trunk/kerpack.asm diff --git a/programs/other/kerpack/trunk/loader_lzma.inc b/programs/other/outdated/kerpack/trunk/loader_lzma.inc similarity index 100% rename from programs/other/kerpack/trunk/loader_lzma.inc rename to programs/other/outdated/kerpack/trunk/loader_lzma.inc diff --git a/programs/other/kerpack/trunk/lzma_compress.inc b/programs/other/outdated/kerpack/trunk/lzma_compress.inc similarity index 100% rename from programs/other/kerpack/trunk/lzma_compress.inc rename to programs/other/outdated/kerpack/trunk/lzma_compress.inc diff --git a/programs/other/kerpack/trunk/lzma_set_dict_size.inc b/programs/other/outdated/kerpack/trunk/lzma_set_dict_size.inc similarity index 100% rename from programs/other/kerpack/trunk/lzma_set_dict_size.inc rename to programs/other/outdated/kerpack/trunk/lzma_set_dict_size.inc diff --git a/programs/other/mhc/trunk/build_en.bat b/programs/other/outdated/mhc/trunk/build_en.bat similarity index 100% rename from programs/other/mhc/trunk/build_en.bat rename to programs/other/outdated/mhc/trunk/build_en.bat diff --git a/programs/other/mhc/trunk/build_ge.bat b/programs/other/outdated/mhc/trunk/build_ge.bat similarity index 100% rename from programs/other/mhc/trunk/build_ge.bat rename to programs/other/outdated/mhc/trunk/build_ge.bat diff --git a/programs/other/mhc/trunk/mhc.asm b/programs/other/outdated/mhc/trunk/mhc.asm similarity index 93% rename from programs/other/mhc/trunk/mhc.asm rename to programs/other/outdated/mhc/trunk/mhc.asm index c3af1ab22c..8ff56a60e8 100644 --- a/programs/other/mhc/trunk/mhc.asm +++ b/programs/other/outdated/mhc/trunk/mhc.asm @@ -1,1001 +1,1001 @@ -; -; MHC archiver for MenuetOS - very fast compression tool -; -; version 0.09 -; -; Written by Nikita Lesnikov (nlo_one@mail.ru, Republic of Belarus, Sluck) -; - -;============================================================================== - -; -; Brief file format description: -; -; +-----------+------------------------+ -; File structure: | Method ID | Compressed data | -; +-----------+------------------------+ -; -; Methods list: -; -; 0. LZP (order-2 specified specially for *.ASM,*.RAW and MeOS executables) -; -; New methods can be easily added without loss of compatibility -; with older versions -; - -;============================================================================== - -; SYSTEM HEADER - -use32 - - org 0x0 - db "MENUET01" - dd 0x01 - dd ENTRANCE - dd MHC_END - dd 0x300000 ; 3 megs of memory needed - dd 0x2FF000 - dd 0x0 - dd 0x0 - -include 'lang.inc' -include '..\..\..\macros.inc' -; CODE AREA - -ENTRANCE: - -; ======== user interface ========= - - - call draw_window ; draw the window - - still: - - mov eax,10 ; wait for event - mcall - - cmp eax,1 ; redraw? - jnz no_redraw - call draw_window - no_redraw: - - cmp eax,2 ; key pressed? - jz key - - cmp eax,3 ; button pressed? - jz button - - jmp still - - ; Key handler - - key: - mov eax,2 ; read it - mcall - shr eax,8 - - cmp byte [editstate],0 - jz still - - cmp al,8 ; backspace - jnz no_bksp - cmp byte [editpos],0 - jz no_del_last - dec byte [editpos] - xor ebx,ebx - mov bl,byte [editpos] - add ebx,cmfile - cmp byte [editstate],2 - jnz no_add_base_1 - add ebx,12 - no_add_base_1: - mov byte [ebx],32 - no_del_last: - call draw_info - jmp still - no_bksp: - - cmp al,13 ; enter - jnz no_enter - mov byte [editstate],0 - call draw_info - jmp still - no_enter: - - cmp eax,dword 31 - jbe no_lit - cmp eax,dword 95 - jb capital - sub eax,32 - capital: - xor ebx,ebx - mov bl,byte [editpos] - add ebx,cmfile - cmp byte [editstate],2 - jnz no_add_base_2 - add ebx,12 - no_add_base_2: - mov byte [ebx],al - inc byte [editpos] - cmp byte [editpos],12 - jnz no_null_state - mov byte [editstate],0 - no_null_state: - call draw_info - no_lit: - - jmp still - - ; Button handler - - button: - - mov eax,17 - mcall - - cmp ah,1 - jnz no_quit - mov eax,-1 - mcall - no_quit: - - cmp ah,4 - jnz nofirst - cld - mov byte [editstate],1 - mov edi,cmfile - mov eax,0x20202020 - mov ecx,3 - rep stosd - mov byte [editpos],0 - mov byte [msgid],0 - call draw_info - nofirst: - - cmp ah,5 - jnz nosecond - cld - mov byte [editstate],2 - mov edi,iofile - mov eax,0x20202020 - mov ecx,3 - rep stosd - mov byte [editpos],0 - mov byte [msgid],0 - call draw_info - nosecond: - - cmp ah,2 - jnz no_compress - call compress - no_compress: - - cmp ah,3 - jnz no_decompress - call decompress - no_decompress: - - cmp ah,6 - jnz no_delete_io - pusha - mov eax,32 - mov ebx,iofile - mcall - popa - no_delete_io: - - cmp ah,7 - jnz no_delete_archive - pusha - mov eax,32 - mov ebx,cmfile - mcall - popa - no_delete_archive: - - jmp still - - ; WINDOW DRAW - - draw_window: - - mov eax,12 ; Start redrawing - mov ebx,1 - mcall - - xor eax,eax ; Define window - mov ebx,100*65536+240 - mov ecx,100*65536+130 - mov edx,0x04AAAAAA - mov esi,0x80777777 - mov edi,0x00777777 - mcall - - mov eax,4 ; Draw all needed texts - mov ebx,8*65536+8 - mov ecx,0x00FFFFFF - mov edx,title - mov esi,arclab-title - mcall - - xor ecx,ecx - mov edx,arclab - mov esi,unplab-arclab - add ebx,10*65536+28 - mcall - - mov edx,unplab - mov esi,fin_text-unplab - add ebx,18 - mcall - - pusha - -; mov eax,8 ; Buttons -; mov ebx,222*65536+10 -; mov ecx,6*65536+10 -; mov edx,1 -; mov esi,0x555555 -; mcall - - mov eax,8 - mov ebx,15*65536+100 - mov ecx,70*65536+13 - mov edx,2 - mcall - - inc edx - add ebx,110*65536 - mcall - - inc edx - mov ebx,214*65536+11 - mov ecx,33*65536+11 - mcall - - inc edx - add ecx,18*65536 - mcall - - inc edx - mov ebx,15*65536+100 - mov ecx,86*65536+13 - mcall - - inc edx - add ebx,110*65536 - mcall - - popa - - mov ecx,0x00FFFFFF - mov edx,keylab - mov esi,dellab-keylab - add ebx,19 - mcall - - mov edx,dellab - mov esi,title-dellab - add ebx,16 - mcall - - call draw_info - - mov eax,12 ; Finish redrawing - mov ebx,2 - mcall - - ret - - draw_info: ; Draw filenames and compressor state - - activecolor equ 0x00112299 - - pusha ; Save registers - - mov eax,13 ; Clean draw area - mov ebx,127*65536+85 - mov ecx,33*65536+33 - mov edx,0x00AAAAAA - mcall - - mov eax,4 ; Draw filenames - mov ebx,134*65536+36 - mov edx,cmfile - xor ecx,ecx - mov esi,12 - cmp byte [editstate],1 - jnz no_active_1 - mov ecx,activecolor - no_active_1: - mcall - xor ecx,ecx - cmp byte [editstate],2 - jnz no_active_2 - mov ecx,activecolor - no_active_2: - add ebx,18 - add edx,12 - mcall - - mov eax,13 ; Clean info area - mov ebx,14*65536+210 - mov ecx,107*65536+14 - mov edx,0x00AAAAAA - mcall - - cmp byte [msgid],0 ; Draw info string - jz notype - mov ebx,16*65536+110 - xor ecx,ecx - mov esi,16 - mov al, byte [msgid] - dec al - shl al,4 - xor ah,ah - xor edx,edx - mov dx,ax - add edx,msgtable - mov eax,4 - mcall - notype: - - popa ; Restore registers - - ret - - ; interface data - - if lang eq de - keylab db " PACKEN ENTPACKEN" - dellab db " LOESCHE I/O LOESCHE *.MHC" - title db "MHC 0.09" - arclab db "GEOACJTE DATEI:" - unplab db "EIN/AUSGABE DATEI:" - fin_text: - - cmfile db "FILENAME.MHC" - iofile db "FILENAME.XYZ" - - msgtable: - db "PACKE... " - db "ENTPACKE... " - db "KEIN I/O! " - db "KEINE *.MHC! " - db "FALSCHE METHODe!" - - else - keylab db " COMPRESS DECOMPRESS" - dellab db " DELETE I/O DELETE *.MHC" - title db "MHC 0.09" - arclab db "COMPRESSED FILE:" - unplab db "INPUT/OUTPUT FILE:" - fin_text: - - cmfile db "FILENAME.MHC" - iofile db "FILENAME.XYZ" - - msgtable: - db "COMPRESSING... " - db "DECOMPRESSING..." - db "I/O NOT FOUND! " - db "*.MHC NOT FOUND!" - db "INVALID METHOD! " - - end if - - - editstate db 0 - editpos db 0 - msgid db 0 - - -; ======== compression/decompression engine ======== - -; Adresses declaration - - hashtable equ MHC_END - ifile equ hashtable+65536*4 - ofile equ ifile+1000000 - - compress: ; File compression - - call fill_filebufs - - mov eax,6 - mov ebx,iofile - xor ecx,ecx - mov edx,ecx - not edx - mov esi,ifile - mcall - - cmp eax,0xFFFFFFFF - jnz compress_filefound ; i/o file not found - mov byte [msgid],3 - call draw_info - ret - - compress_filefound: - - mov byte [msgid],1 - call draw_info - - jmp lzp_compress ; compress with order-2 LZP - compress_dumpdata: - - push edx - - mov eax,32 - mov ebx,cmfile - mcall - - mov eax,33 - pop edx - mov ebx,cmfile - mov ecx,ofile - xor esi,esi - mcall - - mov byte [msgid],0 - call draw_info - - ret - - - decompress: ; File decompression - - call fill_filebufs - - mov eax,6 - mov ebx,cmfile - xor ecx,ecx - mov edx,ecx - not edx - mov esi,ofile - mcall - - cmp eax,0xFFFFFFFF - jnz decompress_filefound ; *.mhc file not found - mov byte [msgid],4 - call draw_info - ret - - decompress_filefound: - - cmp byte [ofile],0 ; Invalid method! - jz right_method - mov byte [msgid],5 - call draw_info - ret - - right_method: - mov byte [msgid],2 - call draw_info - - jmp lzp_decompress - decompress_dumpdata: - - push edx - - mov eax,32 - mov ebx,iofile - mcall - - mov eax,33 - pop edx - mov ebx,iofile - mov ecx,ifile - xor esi,esi - mcall - - mov byte [msgid],0 - call draw_info - - ret - - fill_filebufs: ; Fill filebufs with garbage to simplify matching - pusha - cld - mov eax,0xF7D9A03F ; <- "magic number" :) just garbage... - mov ecx,2000000/4 - mov edi,ifile - rep stosd - popa - ret - -; ==== algorithms section ==== - -; Method 0: LZP compression algorithm - - lzp_compress: ; EDX - how much bytes to dump - - cld ; clear direction flag - - mov esi,ifile ; init pointers - mov edi,ofile - - push eax ; write header: ID0+4bfilesize => total 5 bytes - xor eax,eax - stosb - pop eax - stosd - - pusha ; fill hash table - mov eax,ifile - mov edi,hashtable - mov ecx,65536 - rep stosd - popa - - add eax,esi ; calculate endpointer - mov dword [endpointer],eax - - movsw ; copy three bytes - movsb - - mov dword [controlp],edi - inc edi - - mov byte [controld],0 - mov byte [controlb],0 - - c_loop: - cmp dword [endpointer],esi ; check end of file - ja c_loop_ok - jmp finish_c_loop - c_loop_ok: - - call chash - call compare - jz two_match_c - - lodsb - mov byte [literal],al - call chash - call compare - jz lit_match_c - - mov al,0 - call putbit - mov al,byte [literal] - stosb - movsb - jmp end_c_loop - - lit_match_c: - mov al,1 - call putbit - mov al,0 - call putbit - mov al,byte [literal] - stosb - jmp encode_match - - two_match_c: - mov al,1 - call putbit - call putbit - - encode_match: - call incpos - call compare - jz one_c - mov al,0 - call putbit - jmp end_c_loop - one_c: - - call incpos - mov al,1 - call putbit - - call compare - jnz ec1 - call incpos - call compare - jnz ec2 - call incpos - call compare - jnz ec3 - call incpos - mov al,1 - call putbit - call putbit - call compare - jnz ec4 - call incpos - call compare - jnz ec5 - call incpos - call compare - jnz ec6 - call incpos - call compare - jnz ec7 - call incpos - call compare - jnz ec8 - call incpos - call compare - jnz ec9 - call incpos - call compare - jnz ec10 - call incpos - - mov al,1 - call putbit - call putbit - call putbit - xor ecx,ecx - - match_loop_c: - cmp esi,dword [endpointer] - jae out_match_loop_c - call compare - jnz out_match_loop_c - inc ecx - call incpos - jmp match_loop_c - out_match_loop_c: - - mov al,0xFF - out_lg: - cmp ecx,255 - jb out_lg_out - stosb - sub ecx,255 - jmp out_lg - out_lg_out: - mov al,cl - stosb - jmp end_c_loop - - ec10: - mov al,1 - call putbit - call putbit - mov al,0 - call putbit - jmp end_c_loop - - ec9: - mov al,1 - call putbit - mov al,0 - call putbit - mov al,1 - call putbit - jmp end_c_loop - - ec8: - mov al,1 - call putbit - mov al,0 - call putbit - call putbit - jmp end_c_loop - - ec7: - mov al,0 - call putbit - mov al,1 - call putbit - call putbit - jmp end_c_loop - - ec6: - mov al,0 - call putbit - mov al,1 - call putbit - mov al,0 - call putbit - jmp end_c_loop - - ec5: - mov al,0 - call putbit - call putbit - mov al,1 - call putbit - jmp end_c_loop - - ec4: - mov al,0 - call putbit - call putbit - call putbit - jmp end_c_loop - - ec3: - mov al,1 - call putbit - mov al,0 - call putbit - jmp end_c_loop - - ec2: - mov al,0 - call putbit - mov al,1 - call putbit - jmp end_c_loop - - ec1: - mov al,0 - call putbit - call putbit - - end_c_loop: - jmp c_loop - - finish_c_loop: - - mov eax,dword [controlp] ; store last tagbyte - mov bl,byte [controld] - mov [eax], byte bl - - sub edi,ofile ; calculate dump size - mov edx,edi - - jmp compress_dumpdata - -; LZP decompression algorithm - - lzp_decompress: ; EDX - how much bytes to dump - - cld - - mov edi,ifile - mov esi,ofile+1 - - pusha ; fill hash table - mov eax,ifile - mov edi,hashtable - mov ecx,65536 - rep stosd - popa - - lodsd - - mov ebx,edi - add ebx,eax - mov dword [endpointer],ebx - - movsw - movsb - - lodsb - mov byte [controld],al - mov byte [controlb],0 - - d_loop: - cmp dword [endpointer],edi - ja d_loop_ok - jmp finish_d_loop - d_loop_ok: - - call getbit - cmp al,0 - jnz match_d - call dhash - movsb - call dhash - movsb - jmp end_d_loop - - match_d: - - call getbit - cmp al,0 - jnz no_literal_before_match - call dhash - movsb - no_literal_before_match: - - call dhash - mov ecx,1 - call copymatch - - call getbit - cmp al,0 - jz end_d_loop - mov ecx,1 - call copymatch - call getbit - cmp al,0 - jz dc2 - mov ecx,2 - call copymatch - call getbit - cmp al,0 - jz end_d_loop - mov ecx,1 - call copymatch - call getbit - cmp al,0 - jz dc4 - mov ecx,4 - call copymatch - call getbit - cmp al,0 - jz dc5 - call getbit - cmp al,0 - jz dc6 - mov ecx,3 - call copymatch - - do: - lodsb - xor ecx,ecx - mov cl,al - call copymatch - cmp al,0xFF - jnz end_do - jmp do - end_do: - jmp end_d_loop - - dc6: - mov ecx,2 - call copymatch - jmp end_d_loop - - dc5: - call getbit - cmp al,0 - jz ndc5 - mov ecx,1 - call copymatch - ndc5: - jmp end_d_loop - - dc4: - call getbit - cmp al,0 - jz ndc4 - call getbit - mov ecx,3 - cmp al,1 - jz ndcc4 - dec ecx - ndcc4: - call copymatch - jmp end_d_loop - ndc4: - call getbit - cmp al,0 - jz ndccc4 - mov ecx,1 - call copymatch - ndccc4: - jmp end_d_loop - - dc2: - call getbit - cmp al,0 - jz ndc2 - mov ecx,1 - call copymatch - ndc2: - - end_d_loop: - jmp d_loop - finish_d_loop: - - mov edx, dword [ofile+1] - - jmp decompress_dumpdata - -; LZP subroutines - - putbit: ; bit -> byte tag, AL holds bit for output - pusha - mov cl,byte [controlb] - shl al,cl - mov bl,byte [controld] - or bl,al - mov byte [controld],bl - inc cl - cmp cl,8 - jnz just_increment - mov byte [controlb],0 - mov byte [controld],0 - push edi - mov edi, dword [controlp] - mov al,bl - stosb - pop edi - mov dword [controlp],edi - popa - inc edi - ret - just_increment: - mov byte [controlb],cl - popa - ret - - getbit: ; tag byte -> bit, AL holds input - push ecx - mov al,byte [controld] - mov cl,byte [controlb] - shr al,cl - and al,1 - inc cl - cmp cl,8 - jnz just_increment_d - mov byte [controlb],0 - push eax - lodsb - mov byte [controld],al - pop eax - pop ecx - ret - just_increment_d: - mov byte [controlb],cl - pop ecx - ret - - chash: ; calculate hash -> mp -> fill position - pusha - xor eax,eax - mov al, byte [esi-1] - mov ah, byte [esi-2] - shl eax,2 - add eax,hashtable - mov edx,dword [eax] - mov dword [mp],edx - mov dword [eax],esi - popa - ret - - dhash: ; calculate hash -> mp -> fill position - pusha - xor eax,eax - mov al, byte [edi-1] - mov ah, byte [edi-2] - shl eax,2 - add eax,hashtable - mov edx,dword [eax] - mov dword [mp],edx - mov dword [eax],edi - popa - ret - - copymatch: ; ECX bytes from [mp] to [rp] - push esi - mov esi,dword [mp] - rep movsb - mov dword [mp],esi - pop esi - ret - - compare: ; compare [mp] with [cpos] - push edi - push esi - mov edi,dword [mp] - cmpsb - pop esi - pop edi - ret - - incpos: - inc dword [mp] - inc esi - ret - - -; LZP algorithm data - - endpointer dd 0 - controlp dd 0 - controlb db 0 - controld db 0 - mp dd 0 - literal db 0 - -MHC_END: ; the end... - Nikita Lesnikov (nlo_one) +; +; MHC archiver for MenuetOS - very fast compression tool +; +; version 0.09 +; +; Written by Nikita Lesnikov (nlo_one@mail.ru, Republic of Belarus, Sluck) +; + +;============================================================================== + +; +; Brief file format description: +; +; +-----------+------------------------+ +; File structure: | Method ID | Compressed data | +; +-----------+------------------------+ +; +; Methods list: +; +; 0. LZP (order-2 specified specially for *.ASM,*.RAW and MeOS executables) +; +; New methods can be easily added without loss of compatibility +; with older versions +; + +;============================================================================== + +; SYSTEM HEADER + +use32 + + org 0x0 + db "MENUET01" + dd 0x01 + dd ENTRANCE + dd MHC_END + dd 0x300000 ; 3 megs of memory needed + dd 0x2FF000 + dd 0x0 + dd 0x0 + +include 'lang.inc' +include '..\..\..\macros.inc' +; CODE AREA + +ENTRANCE: + +; ======== user interface ========= + + + call draw_window ; draw the window + + still: + + mov eax,10 ; wait for event + mcall + + cmp eax,1 ; redraw? + jnz no_redraw + call draw_window + no_redraw: + + cmp eax,2 ; key pressed? + jz key + + cmp eax,3 ; button pressed? + jz button + + jmp still + + ; Key handler + + key: + mov eax,2 ; read it + mcall + shr eax,8 + + cmp byte [editstate],0 + jz still + + cmp al,8 ; backspace + jnz no_bksp + cmp byte [editpos],0 + jz no_del_last + dec byte [editpos] + xor ebx,ebx + mov bl,byte [editpos] + add ebx,cmfile + cmp byte [editstate],2 + jnz no_add_base_1 + add ebx,12 + no_add_base_1: + mov byte [ebx],32 + no_del_last: + call draw_info + jmp still + no_bksp: + + cmp al,13 ; enter + jnz no_enter + mov byte [editstate],0 + call draw_info + jmp still + no_enter: + + cmp eax,dword 31 + jbe no_lit + cmp eax,dword 95 + jb capital + sub eax,32 + capital: + xor ebx,ebx + mov bl,byte [editpos] + add ebx,cmfile + cmp byte [editstate],2 + jnz no_add_base_2 + add ebx,12 + no_add_base_2: + mov byte [ebx],al + inc byte [editpos] + cmp byte [editpos],12 + jnz no_null_state + mov byte [editstate],0 + no_null_state: + call draw_info + no_lit: + + jmp still + + ; Button handler + + button: + + mov eax,17 + mcall + + cmp ah,1 + jnz no_quit + mov eax,-1 + mcall + no_quit: + + cmp ah,4 + jnz nofirst + cld + mov byte [editstate],1 + mov edi,cmfile + mov eax,0x20202020 + mov ecx,3 + rep stosd + mov byte [editpos],0 + mov byte [msgid],0 + call draw_info + nofirst: + + cmp ah,5 + jnz nosecond + cld + mov byte [editstate],2 + mov edi,iofile + mov eax,0x20202020 + mov ecx,3 + rep stosd + mov byte [editpos],0 + mov byte [msgid],0 + call draw_info + nosecond: + + cmp ah,2 + jnz no_compress + call compress + no_compress: + + cmp ah,3 + jnz no_decompress + call decompress + no_decompress: + + cmp ah,6 + jnz no_delete_io + pusha + mov eax,32 + mov ebx,iofile + mcall + popa + no_delete_io: + + cmp ah,7 + jnz no_delete_archive + pusha + mov eax,32 + mov ebx,cmfile + mcall + popa + no_delete_archive: + + jmp still + + ; WINDOW DRAW + + draw_window: + + mov eax,12 ; Start redrawing + mov ebx,1 + mcall + + xor eax,eax ; Define window + mov ebx,100*65536+240 + mov ecx,100*65536+130 + mov edx,0x04AAAAAA + mov esi,0x80777777 + mov edi,0x00777777 + mcall + + mov eax,4 ; Draw all needed texts + mov ebx,8*65536+8 + mov ecx,0x00FFFFFF + mov edx,title + mov esi,arclab-title + mcall + + xor ecx,ecx + mov edx,arclab + mov esi,unplab-arclab + add ebx,10*65536+28 + mcall + + mov edx,unplab + mov esi,fin_text-unplab + add ebx,18 + mcall + + pusha + +; mov eax,8 ; Buttons +; mov ebx,222*65536+10 +; mov ecx,6*65536+10 +; mov edx,1 +; mov esi,0x555555 +; mcall + + mov eax,8 + mov ebx,15*65536+100 + mov ecx,70*65536+13 + mov edx,2 + mcall + + inc edx + add ebx,110*65536 + mcall + + inc edx + mov ebx,214*65536+11 + mov ecx,33*65536+11 + mcall + + inc edx + add ecx,18*65536 + mcall + + inc edx + mov ebx,15*65536+100 + mov ecx,86*65536+13 + mcall + + inc edx + add ebx,110*65536 + mcall + + popa + + mov ecx,0x00FFFFFF + mov edx,keylab + mov esi,dellab-keylab + add ebx,19 + mcall + + mov edx,dellab + mov esi,title-dellab + add ebx,16 + mcall + + call draw_info + + mov eax,12 ; Finish redrawing + mov ebx,2 + mcall + + ret + + draw_info: ; Draw filenames and compressor state + + activecolor equ 0x00112299 + + pusha ; Save registers + + mov eax,13 ; Clean draw area + mov ebx,127*65536+85 + mov ecx,33*65536+33 + mov edx,0x00AAAAAA + mcall + + mov eax,4 ; Draw filenames + mov ebx,134*65536+36 + mov edx,cmfile + xor ecx,ecx + mov esi,12 + cmp byte [editstate],1 + jnz no_active_1 + mov ecx,activecolor + no_active_1: + mcall + xor ecx,ecx + cmp byte [editstate],2 + jnz no_active_2 + mov ecx,activecolor + no_active_2: + add ebx,18 + add edx,12 + mcall + + mov eax,13 ; Clean info area + mov ebx,14*65536+210 + mov ecx,107*65536+14 + mov edx,0x00AAAAAA + mcall + + cmp byte [msgid],0 ; Draw info string + jz notype + mov ebx,16*65536+110 + xor ecx,ecx + mov esi,16 + mov al, byte [msgid] + dec al + shl al,4 + xor ah,ah + xor edx,edx + mov dx,ax + add edx,msgtable + mov eax,4 + mcall + notype: + + popa ; Restore registers + + ret + + ; interface data + + if lang eq de + keylab db " PACKEN ENTPACKEN" + dellab db " LOESCHE I/O LOESCHE *.MHC" + title db "MHC 0.09" + arclab db "GEOACJTE DATEI:" + unplab db "EIN/AUSGABE DATEI:" + fin_text: + + cmfile db "FILENAME.MHC" + iofile db "FILENAME.XYZ" + + msgtable: + db "PACKE... " + db "ENTPACKE... " + db "KEIN I/O! " + db "KEINE *.MHC! " + db "FALSCHE METHODe!" + + else + keylab db " COMPRESS DECOMPRESS" + dellab db " DELETE I/O DELETE *.MHC" + title db "MHC 0.09" + arclab db "COMPRESSED FILE:" + unplab db "INPUT/OUTPUT FILE:" + fin_text: + + cmfile db "FILENAME.MHC" + iofile db "FILENAME.XYZ" + + msgtable: + db "COMPRESSING... " + db "DECOMPRESSING..." + db "I/O NOT FOUND! " + db "*.MHC NOT FOUND!" + db "INVALID METHOD! " + + end if + + + editstate db 0 + editpos db 0 + msgid db 0 + + +; ======== compression/decompression engine ======== + +; Adresses declaration + + hashtable equ MHC_END + ifile equ hashtable+65536*4 + ofile equ ifile+1000000 + + compress: ; File compression + + call fill_filebufs + + mov eax,6 + mov ebx,iofile + xor ecx,ecx + mov edx,ecx + not edx + mov esi,ifile + mcall + + cmp eax,0xFFFFFFFF + jnz compress_filefound ; i/o file not found + mov byte [msgid],3 + call draw_info + ret + + compress_filefound: + + mov byte [msgid],1 + call draw_info + + jmp lzp_compress ; compress with order-2 LZP + compress_dumpdata: + + push edx + + mov eax,32 + mov ebx,cmfile + mcall + + mov eax,33 + pop edx + mov ebx,cmfile + mov ecx,ofile + xor esi,esi + mcall + + mov byte [msgid],0 + call draw_info + + ret + + + decompress: ; File decompression + + call fill_filebufs + + mov eax,6 + mov ebx,cmfile + xor ecx,ecx + mov edx,ecx + not edx + mov esi,ofile + mcall + + cmp eax,0xFFFFFFFF + jnz decompress_filefound ; *.mhc file not found + mov byte [msgid],4 + call draw_info + ret + + decompress_filefound: + + cmp byte [ofile],0 ; Invalid method! + jz right_method + mov byte [msgid],5 + call draw_info + ret + + right_method: + mov byte [msgid],2 + call draw_info + + jmp lzp_decompress + decompress_dumpdata: + + push edx + + mov eax,32 + mov ebx,iofile + mcall + + mov eax,33 + pop edx + mov ebx,iofile + mov ecx,ifile + xor esi,esi + mcall + + mov byte [msgid],0 + call draw_info + + ret + + fill_filebufs: ; Fill filebufs with garbage to simplify matching + pusha + cld + mov eax,0xF7D9A03F ; <- "magic number" :) just garbage... + mov ecx,2000000/4 + mov edi,ifile + rep stosd + popa + ret + +; ==== algorithms section ==== + +; Method 0: LZP compression algorithm + + lzp_compress: ; EDX - how much bytes to dump + + cld ; clear direction flag + + mov esi,ifile ; init pointers + mov edi,ofile + + push eax ; write header: ID0+4bfilesize => total 5 bytes + xor eax,eax + stosb + pop eax + stosd + + pusha ; fill hash table + mov eax,ifile + mov edi,hashtable + mov ecx,65536 + rep stosd + popa + + add eax,esi ; calculate endpointer + mov dword [endpointer],eax + + movsw ; copy three bytes + movsb + + mov dword [controlp],edi + inc edi + + mov byte [controld],0 + mov byte [controlb],0 + + c_loop: + cmp dword [endpointer],esi ; check end of file + ja c_loop_ok + jmp finish_c_loop + c_loop_ok: + + call chash + call compare + jz two_match_c + + lodsb + mov byte [literal],al + call chash + call compare + jz lit_match_c + + mov al,0 + call putbit + mov al,byte [literal] + stosb + movsb + jmp end_c_loop + + lit_match_c: + mov al,1 + call putbit + mov al,0 + call putbit + mov al,byte [literal] + stosb + jmp encode_match + + two_match_c: + mov al,1 + call putbit + call putbit + + encode_match: + call incpos + call compare + jz one_c + mov al,0 + call putbit + jmp end_c_loop + one_c: + + call incpos + mov al,1 + call putbit + + call compare + jnz ec1 + call incpos + call compare + jnz ec2 + call incpos + call compare + jnz ec3 + call incpos + mov al,1 + call putbit + call putbit + call compare + jnz ec4 + call incpos + call compare + jnz ec5 + call incpos + call compare + jnz ec6 + call incpos + call compare + jnz ec7 + call incpos + call compare + jnz ec8 + call incpos + call compare + jnz ec9 + call incpos + call compare + jnz ec10 + call incpos + + mov al,1 + call putbit + call putbit + call putbit + xor ecx,ecx + + match_loop_c: + cmp esi,dword [endpointer] + jae out_match_loop_c + call compare + jnz out_match_loop_c + inc ecx + call incpos + jmp match_loop_c + out_match_loop_c: + + mov al,0xFF + out_lg: + cmp ecx,255 + jb out_lg_out + stosb + sub ecx,255 + jmp out_lg + out_lg_out: + mov al,cl + stosb + jmp end_c_loop + + ec10: + mov al,1 + call putbit + call putbit + mov al,0 + call putbit + jmp end_c_loop + + ec9: + mov al,1 + call putbit + mov al,0 + call putbit + mov al,1 + call putbit + jmp end_c_loop + + ec8: + mov al,1 + call putbit + mov al,0 + call putbit + call putbit + jmp end_c_loop + + ec7: + mov al,0 + call putbit + mov al,1 + call putbit + call putbit + jmp end_c_loop + + ec6: + mov al,0 + call putbit + mov al,1 + call putbit + mov al,0 + call putbit + jmp end_c_loop + + ec5: + mov al,0 + call putbit + call putbit + mov al,1 + call putbit + jmp end_c_loop + + ec4: + mov al,0 + call putbit + call putbit + call putbit + jmp end_c_loop + + ec3: + mov al,1 + call putbit + mov al,0 + call putbit + jmp end_c_loop + + ec2: + mov al,0 + call putbit + mov al,1 + call putbit + jmp end_c_loop + + ec1: + mov al,0 + call putbit + call putbit + + end_c_loop: + jmp c_loop + + finish_c_loop: + + mov eax,dword [controlp] ; store last tagbyte + mov bl,byte [controld] + mov [eax], byte bl + + sub edi,ofile ; calculate dump size + mov edx,edi + + jmp compress_dumpdata + +; LZP decompression algorithm + + lzp_decompress: ; EDX - how much bytes to dump + + cld + + mov edi,ifile + mov esi,ofile+1 + + pusha ; fill hash table + mov eax,ifile + mov edi,hashtable + mov ecx,65536 + rep stosd + popa + + lodsd + + mov ebx,edi + add ebx,eax + mov dword [endpointer],ebx + + movsw + movsb + + lodsb + mov byte [controld],al + mov byte [controlb],0 + + d_loop: + cmp dword [endpointer],edi + ja d_loop_ok + jmp finish_d_loop + d_loop_ok: + + call getbit + cmp al,0 + jnz match_d + call dhash + movsb + call dhash + movsb + jmp end_d_loop + + match_d: + + call getbit + cmp al,0 + jnz no_literal_before_match + call dhash + movsb + no_literal_before_match: + + call dhash + mov ecx,1 + call copymatch + + call getbit + cmp al,0 + jz end_d_loop + mov ecx,1 + call copymatch + call getbit + cmp al,0 + jz dc2 + mov ecx,2 + call copymatch + call getbit + cmp al,0 + jz end_d_loop + mov ecx,1 + call copymatch + call getbit + cmp al,0 + jz dc4 + mov ecx,4 + call copymatch + call getbit + cmp al,0 + jz dc5 + call getbit + cmp al,0 + jz dc6 + mov ecx,3 + call copymatch + + do: + lodsb + xor ecx,ecx + mov cl,al + call copymatch + cmp al,0xFF + jnz end_do + jmp do + end_do: + jmp end_d_loop + + dc6: + mov ecx,2 + call copymatch + jmp end_d_loop + + dc5: + call getbit + cmp al,0 + jz ndc5 + mov ecx,1 + call copymatch + ndc5: + jmp end_d_loop + + dc4: + call getbit + cmp al,0 + jz ndc4 + call getbit + mov ecx,3 + cmp al,1 + jz ndcc4 + dec ecx + ndcc4: + call copymatch + jmp end_d_loop + ndc4: + call getbit + cmp al,0 + jz ndccc4 + mov ecx,1 + call copymatch + ndccc4: + jmp end_d_loop + + dc2: + call getbit + cmp al,0 + jz ndc2 + mov ecx,1 + call copymatch + ndc2: + + end_d_loop: + jmp d_loop + finish_d_loop: + + mov edx, dword [ofile+1] + + jmp decompress_dumpdata + +; LZP subroutines + + putbit: ; bit -> byte tag, AL holds bit for output + pusha + mov cl,byte [controlb] + shl al,cl + mov bl,byte [controld] + or bl,al + mov byte [controld],bl + inc cl + cmp cl,8 + jnz just_increment + mov byte [controlb],0 + mov byte [controld],0 + push edi + mov edi, dword [controlp] + mov al,bl + stosb + pop edi + mov dword [controlp],edi + popa + inc edi + ret + just_increment: + mov byte [controlb],cl + popa + ret + + getbit: ; tag byte -> bit, AL holds input + push ecx + mov al,byte [controld] + mov cl,byte [controlb] + shr al,cl + and al,1 + inc cl + cmp cl,8 + jnz just_increment_d + mov byte [controlb],0 + push eax + lodsb + mov byte [controld],al + pop eax + pop ecx + ret + just_increment_d: + mov byte [controlb],cl + pop ecx + ret + + chash: ; calculate hash -> mp -> fill position + pusha + xor eax,eax + mov al, byte [esi-1] + mov ah, byte [esi-2] + shl eax,2 + add eax,hashtable + mov edx,dword [eax] + mov dword [mp],edx + mov dword [eax],esi + popa + ret + + dhash: ; calculate hash -> mp -> fill position + pusha + xor eax,eax + mov al, byte [edi-1] + mov ah, byte [edi-2] + shl eax,2 + add eax,hashtable + mov edx,dword [eax] + mov dword [mp],edx + mov dword [eax],edi + popa + ret + + copymatch: ; ECX bytes from [mp] to [rp] + push esi + mov esi,dword [mp] + rep movsb + mov dword [mp],esi + pop esi + ret + + compare: ; compare [mp] with [cpos] + push edi + push esi + mov edi,dword [mp] + cmpsb + pop esi + pop edi + ret + + incpos: + inc dword [mp] + inc esi + ret + + +; LZP algorithm data + + endpointer dd 0 + controlp dd 0 + controlb db 0 + controld db 0 + mp dd 0 + literal db 0 + +MHC_END: ; the end... - Nikita Lesnikov (nlo_one)