Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 3121 → Rev 3122

/programs/other/outdated/archer/trunk/@RCHER.ASM
0,0 → 1,481
; @RCHER - Deflate unpacker v2.0 beta
;
; Written in pure assembler by Ivushkin Andrey aka Willow
;
; Created: May 6, 2005
;
; Last changed: August 26, 2006
;
; Compile with FASM
 
SYS equ meos
OUTBUF equ 4*1024*1024
png_imag = output+OUTBUF
PARAM_PTR = os_work;png_image
MEMINIT=next_code;output
DUMPFILE equ '/hd0/1/out.txt'
 
SHOW_RBLOCK equ 0;1
SHOW_PNG_SEC equ 0;1
SHOW_METH equ 0;1
FILE_NUM equ 15;8
MEMORY equ 0x800000
 
BITS equ 16
BUFSIZE equ 32
BUFPTR equ area
 
PASSW_LEN equ 32
NO_STOPS equ 1
SHOW_CHARS equ 0
BSIZE equ 512
INBUF equ BUFSIZE*BSIZE*2
IGNORE_DIRS equ 0
 
MOVE_SLINE_LEV equ 8
 
DECRYPT_MODE equ 100b
PNG_MODE equ 10b
TAR_MODE equ 1000b
STAY_MODE equ 10000b
IPC_MODE equ 100000b
RAW_MODE equ 1000000b
THREAD_YES equ 10000000b
LIST_MODE equ 100000000b
MEM_MODE equ 1000000000b
FIND_MODE equ 10000000000b
 
if SYS eq win
format PE console
entry start
;match =win,SYS
;{
; include 'D:\Ivushkin\projects\fasmw\INCLUDE\win32a.inc'
;}
else
use32
 
org 0x0
 
db 'MENUET01'
dd 0x01
dd start
dd I_END
dd MEMINIT
dd main_stack_top;MEMORY-2048
if PARAM_PTR eq param
dd 0
else
dd PARAM_PTR
end if
dd 0x0
 
if PARAM_PTR eq param
param db 'N'
db '000015'
db '/hd/1/zip/gz/fasm-1~1.tgz',0
end if
;match =meos,SYS
;{
include "..\..\..\macros.inc"
; purge mov
include "..\..\..\debug.inc"
include 'dump.inc'
;}
end if
 
include 'lang.inc'
language equ lang
 
if SYS eq win
section '.text' code readable executable writeable
end if
 
include "arcmacro.inc"
include "parser.inc"
include "deflate.inc"
include "sys.inc"
 
FileNum dd FILE_NUM
;FNAME equ '/hd/1/zip/pngsuite/s01n3p01.png'
 
start:
if SYS eq win
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov [cons],eax
invoke GetStdHandle, STD_INPUT_HANDLE
mov [cons_in],eax
Msg 0
Msg 1
else
Msg 0
Msg 1
mcall 40,1000101b
; jmp again
CmdLine
cmdl:
test [Flags],LIST_MODE
jz red
 
; Dump [lpath],[lpath_len],os_work
; ud2
red:
call draw_window
mcall 12,2
 
still:
mcall 10
cmp eax,1
je red
cmp eax,2
jne .nokey
mcall 2
cmp ah,9
jz quit
jmp still
.nokey:
cmp eax,3
jne still
mcall 17
cmp ah,1
jne still
mcall 23,30
cmp eax,3
jne .noquit
call KillViewer
mcall -1
.noquit:
mcall 17
mcall 64,1,MEMINIT
QueryFile
mov [FileNum],FILE_NUM
test eax,eax
jnz still
end if
again:
; Dump Flags,4,os_work
mov [fat_],fat
Newline
xor eax,eax
; and [Flags],STAY_MODE
and [_CRC32_],eax
and [IDATsize],eax
mov [Adler32],1
call OpenFile
test ebx,ebx
jnz .sizeok2
.sizebad2:
Msg 14
jmp quit
.sizeok2:
call KillViewer
xor eax,eax
mov ecx,(child_stack-fat)/4
mov edi,fat
rep stosd
mov [filesize],ebx
test [Flags],RAW_MODE
jz .norawm
mov eax,[arc_base]
xor ebx,ebx
call FileSeek
jmp .sizeok
.norawm:
call SfxParse
 
call ZipParse
cmp edx,52
je .notzip
mov ecx,[FileNum]
call ZipFindN
cmp edx,4
je quit
test [Flags],DECRYPT_MODE
jz .nopass
call ZipDecrypt
push esi
mov ecx,31
._:
mov al,[esi]
push eax
call decrypt_byte
xor al,byte[esp]
add esp,4
call UKeys
mov [esi],al
inc esi
loop ._
pop esi
ud2
.nopass:
cmp [unp_size],0
jne .sizeok
.sizebadq:
Msg 13
jmp quit
.notzip:
call GzipParse
test edx,edx
jne .notgzip
jmp .sizeok
.notgzip:
call PngParse
test edx,edx
jz .sizeok1
cmp edx,21
je .sizebad
test [Flags],RAW_MODE
jne .sizeok
Msg 40
jmp exit
.sizebad:
Msg 17
jmp exit
.sizeok1:
if ~ SYS eq win
end if
Msg 39 ; unpacking PNG
mov ecx,[unp_size]
add ecx,output
mov [png_],ecx
mov eax,[PNG_info.Width]
imul eax,[PNG_info.Height]
lea eax,[eax+eax*2]
add ecx,eax
; dps 'Mem='
; dpd ecx
mcall 64,1
test eax,eax
jz .ok
Msg 41
jmp exit
.ok:
mov edi,[outp]
call Deflate.blkbegin
jmp .defl_end
.sizeok:
mov ecx,[unp_size]
dpd ecx
add ecx,output
; mov [png_],ecx
mcall 64,1
test eax,eax
jz .ok2
Msg 41
jmp exit
.ok2:
call Deflate ; <===========
.defl_end:
test [bits],7
jnz .esi_ok
dec esi
.esi_ok:
push dword[esi] ; <- Adler !!!
mov esi,output
sub edi,esi
mov ecx,edi
mov [outfile.size],ecx
test [Flags],RAW_MODE
jnz .skipAdler
test [Flags],PNG_MODE
jnz .skipCRC
push esi ecx
call UCRC
Msg 11
mov eax,[_CRC32_]
mov edx,36
cmp eax,[CRC_check]
je .crcok
dec edx
.crcok:
Msg edx
if SYS eq win
else
dph eax
end if
pop ecx esi
jmp .skipAdler
.skipCRC:
; dps 'Out='
; dpd ecx
call UAdler
Msg 10
mov eax,[Adler32]
bswap eax ; <- calculated Adler !!!
mov edx,36
cmp eax,[esp]
je .adlok
dec edx
.adlok:
Msg edx
if SYS eq win
else
dph eax
end if
.skipAdler:
pop eax
Newline
.nomoreIDAT:
mov ebx,output
if SYS eq win
Msg 37
invoke CloseHandle, [hnd]
 
invoke CreateFile,dumpfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
mov [hnd],eax
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
invoke CloseHandle, [hnd]
else
test [Flags],PNG_MODE
jnz .nosave
test [Flags],LIST_MODE
jnz quit
 
test [Flags],TAR_MODE
jnz .nomsg
Msg 37
.nomsg:
mov [outfile.out],ebx
mcall 70,outfile
; dps 'Before Quit1'
; ud2
test [Flags],TAR_MODE
jz exit.pad
; call StartPad
.nosave:
end if
test [Flags],PNG_MODE
jz NoPng
xor eax,eax
mov edi,filters
mov ecx,6
rep stosd
mov edi,[png_]
mov esi,output
;//
mov [outp],edi
;//
call PngFilter
call FiltStats
mov [outfile.size],edi
mov ebx,[outp];png_image
if SYS eq win
exit:
Msg 12
invoke CreateFile,outfile,GENERIC_WRITE, FILE_SHARE_WRITE, NULL, \
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL
mov [hnd],eax
invoke WriteFile, eax,ebx,[outfile.size],cparam1,NULL
invoke CloseHandle, [hnd]
call RunViewer
and [arc_base],0
and [Flags],STAY_MODE
; dps 'Before Quit2'
quit:
QueryFile
test eax,eax
jnz again
invoke ExitProcess,0
else
exit:
mov [outfile.out],ebx
test [Flags],TAR_MODE
jz .notar
Msg 37
test [Flags],LIST_MODE
jne quit
mcall 70,outfile
.pad:
call StartPad
.notar:
Msg 12
call RunViewer
and [arc_base],0
and [Flags],STAY_MODE
quit:
test [Flags],STAY_MODE
jnz red
mcall -1
end if
 
NoPng:
test [Flags],TAR_MODE
if SYS eq win
jz quit
else
jz still
end if
; Dump output,255,os_work
; ud2
; mov ecx,dumpf_len
; mov esi,dumpfile
; mov edi,filename
; rep movsb
; call OpenFile
; test ebx,ebx
; jz again.sizebadq
call TarParse
mov ecx,[FileNum]
call TarFindN
; dpd [outfile.size]
cmp [outfile.size],0
jz again.sizebadq
mov ebx,esi
jmp exit
 
if ~ SYS eq win
draw_window:
mcall 12,1
mov ebx,15
mov ecx,ebx
mov edx,0x0e26830
mov edi,edx
mcall 0,,,,0x1f2a870
mcall 8,,,1+1 shl 30
mcall 4,<6,5>,0x10d0d0d0,msgs+5,1
mcall ,<5,5>,0x10202020
ret
end if
 
include 'data.inc'
 
if SYS eq win
section '.idata' import data readable writeable
 
library kernel,'KERNEL32.DLL',\
comdlg,'COMDLG32.DLL',\
user,'USER32.DLL'
 
import kernel,\
CreateFile,'CreateFileA',\
GetFileSize,'GetFileSize',\
ReadFile,'ReadFile',\
WriteFile,'WriteFile',\
SetFilePointer,'SetFilePointer',\
CloseHandle,'CloseHandle',\
GetStdHandle,'GetStdHandle',\
WriteConsole,'WriteConsoleA',\
ReadConsole,'ReadConsoleA',\
CreateProcess,'CreateProcessA',\
WritePrivateProfileString,'WritePrivateProfileStringA',\
ExitProcess,'ExitProcess'
 
import comdlg,\
GetOpenFileName,'GetOpenFileNameA'
 
import user,\
wsprintf,'wsprintfA',\
SendMessage,'SendMessageA',\
FindWindowEx,'FindWindowExA',\
WaitForInputIdle,'WaitForInputIdle'
 
section '.reloc' fixups data readable discardable
end if
 
if ~ SYS in <meos,win>
error "Please specify SYS: meos OR win"
end if
 
 
/programs/other/outdated/archer/trunk/archer.txt
0,0 → 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
 
„® ­®¢ëå ¢áâà¥ç!
/programs/other/outdated/archer/trunk/arcmacro.inc
0,0 → 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
 
}
 
/programs/other/outdated/archer/trunk/build_en.bat
0,0 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm @rcher.asm @rcher
@erase lang.inc
@pause
/programs/other/outdated/archer/trunk/build_ru.bat
0,0 → 1,5
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm @rcher.asm @rcher
@erase lang.inc
@pause
/programs/other/outdated/archer/trunk/data.inc
0,0 → 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
/programs/other/outdated/archer/trunk/deflate.inc
0,0 → 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
/programs/other/outdated/archer/trunk/dump.inc
0,0 → 1,61
; Include file for dumping user apps' memory through new debug BOARD
 
; Max amount of bytes to be dumped
IPC_BUF equ 160
 
; Dump macro parameters:
; ptr - pointer to memory dumped
; len - dump length
; workarea - any work area for sysfunc 9
; run_new - if not empty, run BOARD unless it is running already
 
macro Dump ptr, len, workarea,run_new
{
local .exist,.lt
pusha
mov ebx,workarea
call Board_seek
if ~ run_new eq
test edx,edx
jne .exist
mcall 70,Board_seek.board_fn,0
mov edx,eax
mcall 5,20
end if
.exist:
mov esi,len
cmp esi,IPC_BUF
jbe .lt
mov esi,IPC_BUF
.lt:
mcall 60,2,edx,ptr
popa
}
 
if used Board_seek
Board_seek:
; ebx - prcinfo
xor edx,edx
mcall 9,,-1
mov ecx,eax
mov esi,dword[.board_fn]
.lp:
mcall 9
cmp dword[ebx+10],esi
; jne .no
; cmp dword[ebx+42],399
je .ok
.no:
loop .lp
ret
.ok:
mov edx,[ebx+30]
ret
.board_fn:
dd 7
dd 0
dd 0
dd 0
dd 0
db '/sys/develop/BOARD',0
end if
/programs/other/outdated/archer/trunk/parser.inc
0,0 → 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
 
/programs/other/outdated/archer/trunk/sys.inc
0,0 → 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
end if
/programs/other/outdated/archer/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/archer
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/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
/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
/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
; <dd width,height, times width*height[*3] db image>
 
if ~ (COLOR_ORDER in <PALETTE,MENUETOS,OTHER>)
; 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
/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:
/programs/other/outdated/gifview/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/gifview
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/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
/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
/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
 
 
 
 
/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
 
/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
/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:
/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
 
 
/programs/other/outdated/jpegview/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/jpegview
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/kerpack/trunk/build.bat
0,0 → 1,7
@fasm -m 16384 kerpack.asm kerpack
@kpack kerpack
@pause
 
 
 
 
/programs/other/outdated/kerpack/trunk/build.sh
0,0 → 1,13
#!/bin/bash
# This script does for linux the same as build.bat for DOS,
# it compiles the KoOS kernel, hopefully ;-)
 
echo "lang fix en"
echo "lang fix en" > lang.inc
fasm -m 16384 kerpack.asm kerpack
rm -f lang.inc
exit 0
 
 
 
 
/programs/other/outdated/kerpack/trunk/calltrick2.inc
0,0 → 1,32
pop esi
push esi
loader_patch4:
mov ecx, 0 ; will be patched: number of calltrick entries
ctrloop:
lodsb
@@:
cmp al, 0xF
jnz .f
lodsb
cmp al, 80h
jb @b
cmp al, 90h
jb @f
.f:
sub al, 0E8h
cmp al, 1
ja ctrloop
@@:
cmp byte [esi], 0 ; will be patched: code in calltrick entries
loader_patch5:
jnz ctrloop
lodsd
; "bswap eax" is not supported on i386
; mov al,0/bswap eax = 4 bytes, following instructions = 9 bytes
shr ax, 8
ror eax, 16
xchg al, ah
sub eax, esi
add eax, [esp]
mov [esi-4], eax
loop ctrloop
/programs/other/outdated/kerpack/trunk/kerpack.asm
0,0 → 1,417
; Kolibri kernel packer
; (C) copyright diamond 2006, 2007
;
; Disassemled and corrected in 2010 specially for FASM
; by Marat Zakiyanov aka Mario79, aka Mario
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
 
; Uses LZMA compression library by Igor Pavlov
; (for more information on LZMA and 7-Zip visit http://www.7-zip.org)
; (plain-C packer is ported by diamond)
 
;---------------------------------------------------------------------
use32
org 0
 
db 'MENUET01'
dd 1
dd START
dd IM_END
dd I_END
dd stacktop
dd 0 ;params
dd 0 ;cur_dir_path
;---------------------------------------------------------------------
include '../../../macros.inc'
; do not touch "purge mov"!!!
purge mov ; for the correct patch of loader
; do not touch "purge mov"!!!
;*********************************************************************
die_with_err:
pop esi
@@:
lodsb
test al,al
jz @f
 
mov cl,al
mcall 63,1
jmp @b
;*********************************************************************
@@:
mcall 63,,13
mcall ,,10
mcall -1
;*********************************************************************
START:
mcall 70,fn70_read
cmp eax,6
jz read_ok
;--------------------------------------
read_err:
call die_with_err
db 'KerPack: cannot load kernel.mnt',0
;*********************************************************************
read_ok:
push 18
call lzma_set_dict_size
; find jump to 32-bit code
mov edi,infile - 1
;--------------------------------------
@@:
inc edi
cmp dword [edi],0xE88EE08E ; mov fs,ax/mov gs,ax
jnz @b
 
cmp dword [edi+4],0x00BCD08E ; mov ss,ax/mov esp,00xxxxxx
jnz @b
 
add edi,11
mov [inptr],edi
sub edi, infile
mov [indelta],edi
lea eax,[ebx+0x10000]
mov dword [loader_patch3+2],eax
sub ebx,edi
mov [insize],ebx
call preprocess_calltrick2
 
mov al,[cti]
mov [loader_patch5-1],al
mov eax,[ctn]
mov [loader_patch4+1],eax
mov eax,[inptr]
add eax, outfile - infile + loader_size - 5
push workmem
push [insize]
push eax
push [inptr]
call lzma_compress
 
add eax, loader_size-5
mov [loader_patch1+6],eax
add eax,[indelta]
mov [outsize],eax
mov eax,[indelta]
mov ecx,dword [eax + outfile + loader_size - 4]
bswap ecx
mov [loader_patch2+4],ecx
add eax, 0x10000
mov [loader_patch1+1],eax
mov esi,infile
mov edi,outfile
mov ecx,[indelta]
rep movsb
 
mov esi,loader_start
mov ecx,loader_size
rep movsb
 
mcall 70,fn70_write
test eax,eax
jz @f
 
call die_with_err
db 'KerPack: cannot save kernel.mnt',0
;*********************************************************************
@@:
call die_with_err
db 'KerPack: all is OK',0
;*********************************************************************
preprocess_calltrick2:
; input preprocessing
mov edi,ct1
xor eax,eax
push edi
mov ecx,256/4
rep stosd
 
pop edi
mov ecx,ebx
mov esi,[inptr]
mov ebx,inbuftmp
xchg eax,edx
;--------------------------------------
input_pre2:
lodsb
;--------------------------------------
@@:
cmp al,0Fh
jnz ip1
 
dec ecx
jz input_pre_done2
 
lodsb
cmp al,80h
jb @b
 
cmp al,90h
jb @f
;--------------------------------------
ip1:
sub al,0E8h
cmp al,1
ja input_pre_cont2
;--------------------------------------
@@:
cmp ecx,5
jb input_pre_done2
 
lodsd
add eax,esi
sub eax,[inptr]
cmp eax,[insize]
jae xxx2
 
cmp eax,1000000h
jae xxx2
 
sub ecx,4
xchg al,ah
rol eax,16
xchg al,ah
mov [esi-4],eax
inc edx
mov [ebx],esi
add ebx,4
jmp input_pre_cont2
;*********************************************************************
xxx2:
sub esi,4
movzx eax,byte [esi]
mov byte [eax+edi],1
;--------------------------------------
input_pre_cont2:
loop input_pre2
;--------------------------------------
input_pre_done2:
mov [ctn],edx
xor eax,eax
mov ecx,256
repnz scasb
jnz pack_calltrick_done
 
not cl
mov [cti],cl
;--------------------------------------
@@:
cmp ebx,inbuftmp
jz pack_calltrick_done
 
sub ebx,4
mov eax,[ebx]
mov [eax-4],cl
jmp @b
;*********************************************************************
pack_calltrick_done:
ret
;*********************************************************************
;lzma_compress:
include 'lzma_compress.inc'
;---------------------------------------------------------------------
;lzma_set_dict_size:
include 'lzma_set_dict_size.inc'
;---------------------------------------------------------------------
;
include 'loader_lzma.inc'
;*********************************************************************
fn70_read:
dd 0
dd 0
dd 0
dd 200*1024
dd infile
filename db '/rd/1/kernel.mnt',0
 
fn70_write:
dd 2
dd 0
dd 0
outsize dd ?
dd outfile
db 0
dd filename
;---------------------------------------------------------------------
align 4
LiteralNextStates:
db 0,0,0,0,1,2,3,4,5,6,4,5
MatchNextStates:
db 7,7,7,7,7,7,7,10,10,10,10,10
RepNextStates:
db 8,8,8,8,8,8,8,11,11,11,11,11
ShortRepNextStates:
db 9,9,9,9,9,9,9,11,11,11,11,11
;---------------------------------------------------------------------
;*********************************************************************
IM_END:
;*********************************************************************
;params:
; rb 256
;---------------------------------------------------------------------
;cur_dir_path:
; rb 4096
;---------------------------------------------------------------------
align 4
rb 4096
stacktop:
;---------------------------------------------------------------------
align 4
inptr dd ?
indelta dd ?
insize dd ?
ct1 rb 256
ctn dd ?
cti db ?
 
infile rb 200*1024
inbuftmp rb 200*1024
outfile rb 200*1024
workmem rb 6A8000h
;---------------------------------------------------------------------
; Compress data area start
;---------------------------------------------------------------------
align 4
_lenEncoder:
rd 8451
;-----------------------------------------------------
_prices:
rd 4384
rd 17
;-----------------------------------------------------
_finished: rb 1
_writeEndMark: rb 1
_longestMatchWasFound: rb 1
_previousByte: rb 1
_longestMatchLength: rd 1
;-----------------------------------------------------
g_FastPos:
rb 1024
;-----------------------------------------------------
_posSlotPrices:
rd 256
;-----------------------------------------------------
_isRep0Long:
rd 192
;-----------------------------------------------------
distances:
rd 274
;-----------------------------------------------------
_optimumCurrentIndex: rd 1
_additionalOffset: rd 1
;-----------------------------------------------------
_isRepG1:
rd 12
;-----------------------------------------------------
_isMatch:
rd 192
;-----------------------------------------------------
_alignPriceCount: rd 1
_numLiteralContextBits: rd 1
;-----------------------------------------------------
_literalEncoder:
rd 114
;-----------------------------------------------------
nowPos64:
rd 2
;-----------------------------------------------------
_distancesPrices:
rd 512
;-----------------------------------------------------
_repDistances:
rd 4
;-----------------------------------------------------
_posSlotEncoder:
rd 1028
;-----------------------------------------------------
lastPosSlotFillingPos:
rd 2
;-----------------------------------------------------
_numFastBytes: rd 1
_posStateMask: rd 1
;-----------------------------------------------------
_isRepG0:
rd 12
;-----------------------------------------------------
_repMatchLenEncoder:
rd 8451
rd 4384
rd 17
;-----------------------------------------------------
_isRepG2:
rd 12
;-----------------------------------------------------
_dictionarySize: rd 1
_numLiteralPosStateBits: rd 1
_distTableSize: rd 1
_optimumEndIndex: rd 1
;-----------------------------------------------------
;static CState state
state.State: rb 1
state.Prev1IsChar: rb 1
state.Prev2: rb 2
state.PosPrev2: rd 1
state.BackPrev2: rd 1
state.Price: rd 1
state.PosPrev: rd 1
state.BackPrev: rd 1
state.Backs:
rd 4
;----------------------------------------------------
rd 40950
;-----------------------------------------------------
_alignPrices:
rd 16
;-----------------------------------------------------
_isRep:
rd 12
;-----------------------------------------------------
_posAlignEncoder:
rd 256
;-----------------------------------------------------
i_01: rd 1
;-----------------------------------------------------
_state: rb 1
_cache: rb 1
_state.Prev2: rb 2
_posEncoders: rd 1
_numPrevBits: rd 1
_numPosBits: rd 1
_posMask: rd 1
_posStateBits: rd 1
_range: rd 1
_cacheSize: rd 1
_cyclicBufferSize: rd 1
;-----------------------------------------------------
low:
rd 2
;-----------------------------------------------------
Models:
rd 512
;-----------------------------------------------------
_matchMaxLen: rd 1
pack_pos: rd 1
_cutValue: rd 1
_hash: rd 1
;-----------------------------------------------------
crc_table:
rd 256
;-----------------------------------------------------
_buffer: rd 1
_pos: rd 1
_streamPos: rd 1
pack_length: rd 1
;---------------------------------------------------------------------
; Compress data area end
;---------------------------------------------------------------------
I_END:
;---------------------------------------------------------------------
/programs/other/outdated/kerpack/trunk/loader_lzma.inc
0,0 → 1,459
loader_start:
; start address; this code will be injected after the init code
; (some commands below "B32" in the kernel)
mov edi, 0x280000
lea ebx, [edi+loader_size1+16]
lea edx, [ebx+4]
loader_patch1:
mov esi, 0 ; will be patched: start address to copy
mov ecx, 0 ; will be patched: size of data to copy
push esi
rep movsb
jmp edx
loader_size1 = $ - loader_start
 
loader_patch2:
dd 0x280000 + loader_size
dd 0 ; will be patched: start value for code
; (LZMA-specific)
dd -1
dd _RangeDecoderBitDecode_edx - loader_start + 0x280000
dd _RangeDecoderBitDecode - loader_start + 0x280000
RangeDecoderBitDecode equ dword [ebx]
RangeDecoderBitDecode_edx equ dword [ebx-4]
code_ equ ebx-12
range equ ebx-8
 
rep1 equ ebx-28
rep2 equ ebx-24
rep3 equ ebx-20
inptr_ldr equ ebx-16
 
pb equ 2 ; pos state bits
lp equ 0 ; literal pos state bits
lc equ 3 ; literal context bits
posStateMask equ ((1 shl pb)-1)
literalPosMask equ ((1 shl lp)-1)
 
kNumPosBitsMax = 4
kNumPosStatesMax = (1 shl kNumPosBitsMax)
 
kLenNumLowBits = 3
kLenNumLowSymbols = (1 shl kLenNumLowBits)
kLenNumMidBits = 3
kLenNumMidSymbols = (1 shl kLenNumMidBits)
kLenNumHighBits = 8
kLenNumHighSymbols = (1 shl kLenNumHighBits)
 
LenChoice = 0
LenChoice2 = 1
LenLow = 2
LenMid = (LenLow + (kNumPosStatesMax shl kLenNumLowBits))
LenHigh = (LenMid + (kNumPosStatesMax shl kLenNumMidBits))
kNumLenProbs = (LenHigh + kLenNumHighSymbols)
 
kNumStates = 12
kNumLitStates = 7
kStartPosModelIndex = 4
kEndPosModelIndex = 14
kNumFullDistances = (1 shl (kEndPosModelIndex/2))
kNumPosSlotBits = 6
kNumLenToPosStates = 4
kNumAlignBits = 4
kAlignTableSize = (1 shl kNumAlignBits)
kMatchMinLen = 2
 
IsMatch = 0
IsRep = 0xC0 ; (IsMatch + (kNumStates shl kNumPosBitsMax))
IsRepG0 = 0xCC ; (IsRep + kNumStates)
IsRepG1 = 0xD8 ; (IsRepG0 + kNumStates)
IsRepG2 = 0xE4 ; (IsRepG1 + kNumStates)
IsRep0Long = 0xF0 ; (IsRepG2 + kNumStates)
PosSlot = 0x1B0 ; (IsRep0Long + (kNumStates shl kNumPosBitsMax))
SpecPos = 0x2B0 ; (PosSlot + (kNumLenToPosStates shl kNumPosSlotBits))
Align_ = 0x322 ; (SpecPos + kNumFullDistances - kEndPosModelIndex)
Lencoder = 0x332 ; (Align_ + kAlignTableSize)
RepLencoder = 0x534 ; (Lencoder + kNumLenProbs)
Literal = 0x736 ; (RepLencoder + kNumLenProbs)
 
LZMA_BASE_SIZE = 1846 ; must be ==Literal
LZMA_LIT_SIZE = 768
 
kNumTopBits = 24
kTopValue = (1 shl kNumTopBits)
 
kNumBitModelTotalBits = 11
kBitModelTotal = (1 shl kNumBitModelTotalBits)
kNumMoveBits = 5
 
uninit_base = 2C0000h
 
p = uninit_base
 
unpacker:
xor ebp, ebp
xor eax, eax
dec eax
lea edi, [rep1]
stosd
stosd
stosd
 
xchg eax, esi
; mov ecx, Literal + (LZMA_LIT_SIZE shl (lc+lp))
mov ch, (Literal + (LZMA_LIT_SIZE shl (lc+lp)) + 0xFF) shr 8
mov eax, kBitModelTotal/2
mov edi, p
rep stosd
 
pop edi
push edi
loader_patch3:
.main_loop:
cmp edi, dword 0 ; will be patched: end of data to unpack
jae .main_loop_done
 
if posStateMask
mov edx, edi
and edx, posStateMask
else
xor edx, edx
end if
push eax ; al = previous byte
lea eax, [ebp + ((p+IsMatch*4) shr (kNumPosBitsMax+2))]
shl eax, kNumPosBitsMax+2
if posStateMask
call RangeDecoderBitDecode_edx
else
call RangeDecoderBitDecode
end if
pop eax
jc .1
 
movzx eax, al
if literalPosMask
mov ah, dl
and ah, literalPosMask
end if
if ((LZMA_LIT_SIZE*4) and ((1 shl (8-lc)) - 1)) <> 0
shr eax, 8-lc
imul eax, LZMA_LIT_SIZE*4
else
and al, not ((1 shl (8-lc)) - 1)
imul eax, (LZMA_LIT_SIZE*4) shr (8-lc)
end if
add eax, p+Literal*4
mov dl, 1
cmp ebp, kNumLitStates
jb .literal
 
mov cl, [edi + esi]
;--------------------------------------
.lx0:
add cl, cl
adc dh, 1
call RangeDecoderBitDecode_edx
 
adc dl, dl
jc .lx1
 
xor dh, dl
test dh, 1
mov dh, 0
jnz .lx0
;--------------------------------------
.literal:
@@:
call RangeDecoderBitDecode_edx
adc dl, dl
jnc @b
;--------------------------------------
.lx1:
mov eax, ebp
cmp al, 4
jb @f
 
cmp al, 10
mov al, 3
jb @f
 
mov al, 6
@@:
sub ebp, eax
xchg eax, edx
;--------------------------------------
.stosb_main_loop:
stosb
jmp .main_loop
;*********************************************************************
.1:
lea eax, [p + IsRep*4 + ebp*4]
call RangeDecoderBitDecode
jnc .10
 
add eax, (IsRepG0 - IsRep)*4 ;lea eax, [p + IsRepG0*4 + ebp*4]
call RangeDecoderBitDecode
jc .111
 
mov eax, ebp
shl eax, kNumPosBitsMax+2
add eax, p + IsRep0Long*4
call RangeDecoderBitDecode_edx
jc .1101
 
cmp ebp, 7
sbb ebp, ebp
lea ebp, [ebp+ebp+11]
mov al, [edi + esi]
jmp .stosb_main_loop
;*********************************************************************
.111:
add eax, (IsRepG1 - IsRepG0) * 4 ;lea eax, [p + IsRepG1*4 + ebp*4]
call RangeDecoderBitDecode
xchg esi, [rep1]
jnc @f
 
add eax, (IsRepG2 - IsRepG1) * 4 ;lea eax, [p + IsRepG2*4 + ebp*4]
call RangeDecoderBitDecode
xchg esi, [rep2]
jnc @f
 
xchg esi, [rep3]
;--------------------------------------
@@:
.1101:
mov eax, p + RepLencoder*4
call LzmaLenDecode
 
push 8
jmp .rmu
;*********************************************************************
.10:
xchg esi, [rep1]
xchg esi, [rep2]
mov [rep3], esi
mov eax, p + Lencoder*4
call LzmaLenDecode
 
push kNumLenToPosStates-1
pop edx
cmp edx, ecx
jb @f
 
mov edx, ecx
;--------------------------------------
@@:
push ecx
push kNumPosSlotBits
pop ecx
mov eax, p+PosSlot*4
shl edx, cl
call RangeDecoderBitTreeDecode
 
mov esi, ecx
cmp ecx, kStartPosModelIndex
jb .l6
 
mov edx, ecx
xor eax, eax
shr ecx, 1
adc al, 2
dec ecx
shl eax, cl
mov esi, eax
sub eax, edx
lea eax, [p + (SpecPos - 1)*4 + eax*4]
cmp edx, kEndPosModelIndex
jb .l59
; call RangeDecoderDecodeDirectBits
;RangeDecoderDecodeDirectBits:
xor eax, eax
;--------------------------------------
.l:
shr dword [range], 1
add eax, eax
mov edx, [code_]
sub edx, [range]
jb @f
 
mov [code_], edx
add al, 1 shl kNumAlignBits
;--------------------------------------
@@:
call update_decoder
dec ecx
cmp ecx, kNumAlignBits
jnz .l
; ret
add esi, eax
mov eax, p+Align_*4
;--------------------------------------
.l59:
; call RangeDecoderReverseBitTreeDecode_addesi
;_RangeDecoderReverseBitTreeDecode_addesi:
; in: eax->probs,ecx=numLevels
; out: esi+=length; destroys edx
push edi
xor edx, edx
inc edx
mov edi, edx
;--------------------------------------
@@:
call RangeDecoderBitDecode_edx
jnc .591
 
add esi, edi
stc
;--------------------------------------
.591:
adc edx, edx
add edi, edi
loop @b
 
pop edi
; ret
;--------------------------------------
.l6:
pop ecx
not esi
push 7
;--------------------------------------
.rmu:
cmp ebp, 7
pop ebp
jb @f
add ebp, 3
;--------------------------------------
@@:
.repmovsb:
inc ecx
push esi
add esi, edi
rep movsb
 
lodsb
pop esi
jmp .stosb_main_loop
;*********************************************************************
.main_loop_done:
include 'calltrick2.inc'
ret
;*********************************************************************
_RangeDecoderBitDecode:
; in: eax->prob
; out: CF=bit
push edx
mov edx, [range]
shr edx, kNumBitModelTotalBits
imul edx, [eax]
cmp [code_], edx
jae .ae
 
mov [range], edx
mov edx, kBitModelTotal
sub edx, [eax]
shr edx, kNumMoveBits
add [eax], edx
;--------------------------------------
.n:
pushfd
call update_decoder
 
popfd
pop edx
ret
;*********************************************************************
.ae:
sub [range], edx
sub [code_], edx
mov edx, [eax]
shr edx, kNumMoveBits
sub [eax], edx
stc
jmp .n
;*********************************************************************
update_decoder:
cmp byte [range+3], 0 ;cmp dword [range], kTopValue
jnz @f ;jae @f
 
shl dword [range], 8
shl dword [code_], 8
push eax
mov eax, [inptr_ldr]
mov al, [eax]
inc dword [inptr_ldr]
mov byte [code_], al
pop eax
@@:
ret
;*********************************************************************
_RangeDecoderBitDecode_edx:
push eax
lea eax, [eax+edx*4]
call RangeDecoderBitDecode
 
pop eax
ret
;*********************************************************************
LzmaLenDecode:
; in: eax->prob, edx=posState
; out: ecx=len
 
; LenChoice==0
; add eax, LenChoice*4
if kLenNumMidBits <> kLenNumLowBits
error in optimization
end if
mov cl, kLenNumMidBits
call RangeDecoderBitDecode
jnc .0
 
add eax, (LenChoice2-LenChoice)*4
call RangeDecoderBitDecode
jc @f
if (kLenNumMidBits <> 3) | (LenMid-LenChoice2 > 0x7F + kLenNumMidBits)
shl edx, cl
add edx, LenMid-LenChoice2
else
lea edx, [ecx + edx*8 - kLenNumMidBits + LenMid-LenChoice2]
end if
push kLenNumLowSymbols
jmp RangeDecoderBitTreeDecode.1
;*********************************************************************
@@:
mov edx, LenHigh-LenChoice2
mov cl, kLenNumHighBits
push kLenNumLowSymbols + kLenNumMidSymbols
jmp RangeDecoderBitTreeDecode.1
;*********************************************************************
.0:
shl edx, cl
if LenLow = 2
inc edx
inc edx
else
add edx, LenLow
end if
;--------------------------------------
RangeDecoderBitTreeDecode:
; in: eax+edx*4->probs,ecx=numLevels
; out: ecx=length; destroys edx
push 0
.1:
lea eax, [eax+edx*4]
xor edx, edx
inc edx
push ecx
@@:
call RangeDecoderBitDecode_edx
 
adc edx, edx
loop @b
 
pop ecx
btc edx, ecx
pop ecx
add ecx, edx
ret
loader_size = $ - loader_start
;*********************************************************************
/programs/other/outdated/kerpack/trunk/lzma_compress.inc
0,0 → 1,3348
kIfinityPrice equ 0x0FFFFFFF
 
;* Call: ***************************************************************
;lzma_compress(
; const void* source,
; void* destination,
; unsigned length,
; void* workmem)
lzma_compress:
push ebp
mov ebp,esp
and esp,0xFFFFFFF8
sub esp,12
push ebx
push esi
push edi
push 2
pop esi
xor ebx,ebx
mov [esp+20],esi
mov [g_FastPos],bl
mov byte [g_FastPos+1],1
mov [esp+16],esi
;----------------------------------------------------------
.labl_00:
mov ecx,[esp+16]
xor edi,edi
sar ecx,1
dec ecx
inc edi
shl edi,cl
cmp edi,ebx
jbe .labl_01
 
mov eax,[esp+20]
push edi
push dword [esp+20]
lea eax,[eax+g_FastPos]
push eax
call _memset
add esp,12
add [esp+20],edi
;----------------------------------------------------------
.labl_01:
inc dword [esp+16]
cmp dword [esp+16],20
jl .labl_00
 
mov edi,[ebp+20]
push 3
pop eax
mov ecx,edi
and ecx,eax
mov edx,128
mov [_numFastBytes],edx
mov [_posStateBits],esi
mov [_posStateMask],eax
mov [_numLiteralContextBits],eax
mov [_numLiteralPosStateBits],ebx
mov [_writeEndMark],bl
mov [_finished],bl
je .labl_02
 
sub edi,ecx
add edi,4
;----------------------------------------------------------
.labl_02:
;CLiteralEncoder_Create
mov [_numPrevBits],eax
mov eax,[_dictionarySize]
mov [_posEncoders],edi
add edi,0x6000
inc eax
mov [_numPosBits],ebx
mov [_posMask],ebx
;MatchFinder_Create
mov [_matchMaxLen],edx
mov [_cyclicBufferSize],eax
mov [_hash],edi
mov dword [_cutValue],0xFF
call CEncoder_Init
call FillPosSlotPrices
call FillDistancesPrices
call FillAlignPrices
push 127
pop esi
mov [_lenEncoder+0xC88C],esi
mov [esp+16],ebx
;----------------------------------------------------------
.labl_03:
push dword [esp+16]
mov eax,_lenEncoder
call CPriceTableEncoder_UpdateTable
inc dword [esp+16]
cmp dword [esp+16],4
jb .labl_03
 
mov [_repMatchLenEncoder+0xC88C],esi
xor esi,esi
;----------------------------------------------------------
.labl_04:
push esi
mov eax,_repMatchLenEncoder
call CPriceTableEncoder_UpdateTable
inc esi
cmp esi,4
jb .labl_04
 
mov eax,[ebp+8]
mov esi,[ebp+12]
dec eax
mov [_buffer],eax
mov eax,[ebp+16]
inc eax
mov [_streamPos],eax
mov ecx,0x110000
xor eax,eax
mov [lastPosSlotFillingPos],ebx
mov [lastPosSlotFillingPos+4],ebx
mov [nowPos64],ebx
mov [nowPos64+4],ebx
mov [pack_length],esi
mov dword [_pos],1
rep stosd
mov [pack_pos],ebx
;----------------------------------------------------------
;MatchFinder_Init
.labl_08:
push 8
mov eax,ebx
pop ecx
;----------------------------------------------------------
.labl_07:
test al,1
je .labl_05
 
shr eax,1
xor eax,0xEDB88320
jmp .labl_06
;----------------------------------------------------------
.labl_05:
shr eax,1
;----------------------------------------------------------
.labl_06:
dec ecx
jne .labl_07
 
mov [crc_table+ebx*4],eax
inc ebx
cmp ebx,256
jb .labl_08
;----------------------------------------------------------
.labl_09:
call CodeOneBlock
test al,al
jne .labl_09
 
mov eax,[pack_length]
pop edi
sub eax,esi
pop esi
pop ebx
mov esp,ebp
pop ebp
ret 16
;*****************************************************************************
 
;* Call: ***************************************************************
_memset:
push edi
mov edi,[esp+8]
mov al,[esp+12]
mov ecx,[esp+16]
rep stosb
pop edi
ret
;*****************************************************************************
 
;* Call: ***************************************************************
CEncoder_Init:
;RangeEncoder_Init
and dword [low],0
and dword [low+4],0
or dword [_range],0xFFFFFFFF
push ebx
push esi
push edi
xor eax,eax
mov edi,_repDistances
stosd
stosd
xor ebx,ebx
stosd
inc ebx
;CBaseState_Init
mov byte [_state],0
mov byte [_previousByte],0
stosd
mov [_cacheSize],ebx
mov byte [_cache],0
xor ecx,ecx
;----------------------------------------------------------
.labl_00:
mov eax,ebx
shl eax,cl
push 8
pop edx
sub edx,ecx
lea esi,[Models+eax*4]
shl edx,6
;----------------------------------------------------------
.labl_01:
mov edi,eax
shl edi,6
shr edi,cl
add edi,edx
mov [esi],edi
add esi,4
dec eax
jne .labl_01
 
inc ecx
cmp ecx,9
jl .labl_00
 
push 12
pop edx
mov esi,1024
mov eax,esi
mov ecx,edx
mov edi,_isRepG2
rep stosd
mov ecx,edx
mov edi,_isRepG1
rep stosd
mov ecx,edx
mov edi,_isRepG0
rep stosd
mov ecx,edx
mov edi,_isRep
rep stosd
xor ecx,ecx
;----------------------------------------------------------
.labl_02:
lea edi,[ecx+_isRep0Long]
mov eax,esi
stosd
stosd
stosd
stosd
lea edi,[ecx+_isMatch]
mov eax,esi
stosd
stosd
stosd
add ecx,64
cmp ecx,768
stosd
jl .labl_02
 
mov eax,[_numPrevBits]
mov ecx,[_numPosBits]
add ecx,eax
mov eax,ebx
shl eax,cl
test eax,eax
jbe .labl_04
 
xor edx,edx
mov ebx,eax
;----------------------------------------------------------
.labl_03:
mov eax,[_posEncoders]
lea edi,[edx+eax]
mov ecx,768
mov eax,esi
add edx,3072
dec ebx
rep stosd
jne .labl_03
;----------------------------------------------------------
.labl_04:
mov edi,_posSlotEncoder
;----------------------------------------------------------
.labl_05:
push 6
pop ecx
mov eax,edi
call CBitTreeEncoder_Init
add edi,1028
cmp edi,lastPosSlotFillingPos
jl .labl_05
 
push 114
mov eax,esi
pop ecx
mov edi,_literalEncoder
mov esi,_lenEncoder
rep stosd
call CPriceTableEncoder_Init
mov esi,_repMatchLenEncoder
call CPriceTableEncoder_Init
push 4
pop ecx
mov eax,_posAlignEncoder
call CBitTreeEncoder_Init
pop edi
xor eax,eax
pop esi
mov byte [_longestMatchWasFound],0
mov [_optimumEndIndex],eax
mov [_optimumCurrentIndex],eax
mov [_additionalOffset],eax
pop ebx
ret
;*****************************************************************************
 
;* Call: ***************************************************************
CodeOneBlock:
sub esp,0x2C
cmp byte [_finished],0
push ebx
push ebp
push esi
push edi
je .labl_01
;----------------------------------------------------------
.labl_00:
xor al,al
jmp .labl_28
;----------------------------------------------------------
.labl_01:
mov ebp,[nowPos64]
mov edi,[nowPos64+4]
mov eax,ebp
or eax,edi
mov byte [_finished],1
mov [esp+52],ebp
mov [esp+56],edi
jne .labl_04
 
mov eax,[_streamPos]
sub eax,[_pos]
jne .labl_03
 
push 5
pop esi
;----------------------------------------------------------
.labl_02:
call RangeEncoder_ShiftLow
dec esi
jne .labl_02
 
jmp .labl_00
;----------------------------------------------------------
.labl_03:
call ReadMatchDistances
movzx esi,byte [_state]
mov edx,esi
shl edx,6
xor edi,edi
push edi
add edx,_isMatch
call CMyBitEncoder_Encode
mov al,[esi+LiteralNextStates]
mov ecx,[_pos]
mov [_state],al
mov eax,[_buffer]
sub eax,[_additionalOffset]
mov bl,[eax+ecx]
mov al,[_previousByte]
mov [esp+24],bl
push dword [esp+24]
push edi
call CState_IsCharState
imul eax,eax,3072
add eax,[_posEncoders]
push eax
call CLiteralEncoder2_Encode
dec dword [_additionalOffset]
xor ebp,ebp
inc ebp
mov [_previousByte],bl
mov [nowPos64],ebp
mov [nowPos64+4],edi
;----------------------------------------------------------
.labl_04:
mov eax,[_streamPos]
sub eax,[_pos]
jne .labl_06
 
push 5
pop esi
;----------------------------------------------------------
.labl_05:
call RangeEncoder_ShiftLow
dec esi
jne .labl_05
 
jmp .labl_00
;----------------------------------------------------------
.labl_06:
lea eax,[esp+20]
push eax
lea eax,[esp+20]
push eax
mov ebx,ebp
push ebp
and ebx,3
call GetOptimum
cmp dword [esp+20],1
jne .labl_09
 
cmp dword [esp+16],0xFFFFFFFF
jne .labl_09
 
movzx eax,byte [_state]
shl eax,4
add eax,ebx
push 0
lea edx,[_isMatch+eax*4]
call CMyBitEncoder_Encode
mov eax,[_buffer]
mov esi,[_additionalOffset]
mov ebx,[_pos]
sub eax,esi
mov al,[eax+ebx]
mov [esp+24],al
mov al,[_previousByte]
push ebp
call CState_IsCharState
imul eax,eax,3072
add eax,[_posEncoders]
cmp byte [_state],7
push dword [esp+24]
jb .labl_07
 
mov ecx,[_buffer]
sub ecx,[_repDistances]
sub ecx,esi
mov cl,[ecx+ebx-1]
mov [esp+52],cl
push dword [esp+52]
push eax
call CLiteralEncoder2_EncodeMatched
jmp .labl_08
;----------------------------------------------------------
.labl_07:
push eax
call CLiteralEncoder2_Encode
;----------------------------------------------------------
.labl_08:
movzx eax,byte [_state]
mov al,[eax+LiteralNextStates]
mov [_state],al
mov al,[esp+24]
jmp .labl_24
;----------------------------------------------------------
.labl_09:
movzx edi,byte [_state]
mov eax,edi
shl eax,4
add eax,ebx
shl eax,2
push 1
lea edx,[eax+_isMatch]
mov [esp+40],eax
call CMyBitEncoder_Encode
cmp dword [esp+16],4
jnb .labl_17
 
mov esi,edi
shl esi,2
push 1
lea edx,[esi+_isRep]
call CMyBitEncoder_Encode
cmp dword [esp+16],0
lea edx,[esi+_isRepG0]
jne .labl_10
 
push 0
call CMyBitEncoder_Encode
mov edx,[esp+36]
xor eax,eax
cmp dword [esp+20],1
lea edx,[edx+_isRep0Long]
setne al
jmp .labl_12
;----------------------------------------------------------
.labl_10:
push 1
call CMyBitEncoder_Encode
cmp dword [esp+16],1
lea edx,[esi+_isRepG1]
jne .labl_11
 
push 0
jmp .labl_13
;----------------------------------------------------------
.labl_11:
push 1
call CMyBitEncoder_Encode
mov eax,[esp+16]
add eax,0xFFFFFFFE
lea edx,[esi+_isRepG2]
;----------------------------------------------------------
.labl_12:
push eax
;----------------------------------------------------------
.labl_13:
call CMyBitEncoder_Encode
mov eax,[esp+20]
cmp eax,1
jne .labl_14
 
mov al,[edi+ShortRepNextStates]
jmp .labl_15
;----------------------------------------------------------
.labl_14:
add eax,0xFFFFFFFE
mov esi,_repMatchLenEncoder
call CPriceTableEncoder_Encode
mov al,[edi+RepNextStates]
;----------------------------------------------------------
.labl_15:
mov [_state],al
mov eax,[esp+16]
mov ecx,[_repDistances+eax*4]
test eax,eax
je .labl_23
;----------------------------------------------------------
.labl_16:
dec eax
mov edx,[_repDistances+eax*4]
mov [_repDistances+4+eax*4],edx
jne .labl_16
 
mov [_repDistances],ecx
jmp .labl_23
;----------------------------------------------------------
.labl_17:
push 0
lea edx,[_isRep+edi*4]
call CMyBitEncoder_Encode
mov al,[edi+MatchNextStates]
mov edi,[esp+20]
mov [_state],al
add edi,0xFFFFFFFE
mov eax,edi
mov esi,_lenEncoder
call CPriceTableEncoder_Encode
sub dword [esp+16],4
mov eax,[esp+16]
call GetPosSlot
cmp dword [esp+20],6
mov ebx,eax
jb .labl_18
 
push 3
pop edi
;----------------------------------------------------------
.labl_18:
imul edi,edi,1028
push ebx
add edi,_posSlotEncoder
call cm_pr_16
cmp ebx,4
jb .labl_21
 
mov esi,[esp+16]
xor eax,eax
inc eax
mov ecx,ebx
mov edi,ebx
and edi,eax
shr ecx,1
dec ecx
or edi,2
shl edi,cl
sub esi,edi
cmp ebx,14
jnb .labl_20
 
mov [esp+32],esi
mov [esp+28],eax
test ecx,ecx
jle .labl_21
 
mov [esp+36],ecx
;----------------------------------------------------------
.labl_19:
mov edx,[esp+28]
mov esi,[esp+32]
sub edx,ebx
add edx,edi
and esi,1
push esi
lea edx,[_numLiteralContextBits+edx*4]
call CMyBitEncoder_Encode
mov eax,[esp+28]
shr dword [esp+32],1
dec dword [esp+36]
lea eax,[esi+eax*2]
mov [esp+28],eax
jne .labl_19
 
jmp .labl_21
;----------------------------------------------------------
.labl_20:
lea eax,[ecx-4]
mov ecx,esi
shr ecx,4
push ecx
call RangeEncoder_EncodeDirectBits
and esi,0xF
push esi
call CBitTreeEncoder_ReverseEncode
dec dword [_alignPriceCount]
jne .labl_21
 
call FillAlignPrices
;----------------------------------------------------------
.labl_21:
mov eax,_repDistances+12
;----------------------------------------------------------
.labl_22:
mov ecx,[eax-4]
mov [eax],ecx
sub eax,4
cmp eax,_repDistances
jne .labl_22
 
mov eax,[esp+16]
mov [_repDistances],eax
;----------------------------------------------------------
.labl_23:
mov eax,[_buffer]
mov esi,[_additionalOffset]
mov ebx,[_pos]
mov ecx,[esp+20]
mov edi,[nowPos64+4]
sub eax,esi
add eax,ebx
mov al,[eax+ecx-1]
;----------------------------------------------------------
.labl_24:
sub esi,[esp+20]
add ebp,[esp+20]
mov [_previousByte],al
adc edi,0
mov eax,ebp
sub eax,[lastPosSlotFillingPos]
mov ecx,edi
sbb ecx,[lastPosSlotFillingPos+4]
mov [_additionalOffset],esi
mov [nowPos64],ebp
mov [nowPos64+4],edi
mov [esp+40],ecx
jne .labl_25
 
cmp eax,512
jb .labl_26
;----------------------------------------------------------
.labl_25:
call FillPosSlotPrices
call FillDistancesPrices
mov [lastPosSlotFillingPos],ebp
mov [lastPosSlotFillingPos+4],edi
;----------------------------------------------------------
.labl_26:
test esi,esi
jne .labl_06
 
mov eax,[_streamPos]
sub eax,ebx
je .labl_29
 
mov ecx,ebp
sub ecx,[esp+52]
mov eax,edi
sbb eax,[esp+56]
test eax,eax
ja .labl_27
 
jb .labl_06
 
cmp ecx,0x1000
jb .labl_06
;----------------------------------------------------------
.labl_27:
mov byte [_finished],0
mov al,1
;----------------------------------------------------------
.labl_28:
pop edi
pop esi
pop ebp
pop ebx
add esp,44
ret
;----------------------------------------------------------
.labl_29:
push 5
pop esi
;----------------------------------------------------------
.labl_30:
call RangeEncoder_ShiftLow
dec esi
jne .labl_30
 
jmp .labl_00
;*****************************************************************************
 
;* Call: ***************************************************************
GetOptimum:
push ebp
mov ebp,esp
mov ecx,[_optimumCurrentIndex]
sub esp,116
push esi
cmp [_optimumEndIndex],ecx
je .labl_00
 
mov eax,ecx
imul eax,eax,40
add eax,state.State
mov edx,[eax+16]
mov eax,[eax+20]
mov esi,edx
sub esi,ecx
mov ecx,[ebp+16]
mov [ecx],esi
mov ecx,[ebp+12]
mov [ecx],eax
mov [_optimumCurrentIndex],edx
jmp .labl_76
;----------------------------------------------------------
.labl_00:
push edi
xor edi,edi
cmp byte [_longestMatchWasFound],0
mov [_optimumEndIndex],edi
mov [_optimumCurrentIndex],edi
jne .labl_01
 
call ReadMatchDistances
jmp .labl_02
;----------------------------------------------------------
.labl_01:
mov eax,[_longestMatchLength]
mov byte [_longestMatchWasFound],0
;----------------------------------------------------------
.labl_02:
push ebx
mov ebx,[ebp+8]
mov [ebp-16],eax
mov eax,ebx
shl eax,2
mov [ebp-76],eax
;----------------------------------------------------------
.labl_03:
mov esi,edi
shl esi,2
mov eax,[esi+_repDistances]
push eax
mov [ebp+esi-100],eax
push dword 0xFFFFFFFF
mov eax,273
call GetMatchLen
mov [ebp+esi-116],eax
test edi,edi
je .labl_04
 
mov ecx,[ebp-76]
cmp eax,[ebp+ecx-116]
jbe .labl_05
;----------------------------------------------------------
.labl_04:
mov ebx,edi
mov [ebp-76],esi
;----------------------------------------------------------
.labl_05:
inc edi
cmp edi,4
jb .labl_03
 
mov eax,[ebp+ebx*4-116]
mov ecx,128
mov [ebp-68],eax
cmp eax,ecx
jb .labl_06
 
mov ecx,[ebp+12]
mov [ecx],ebx
jmp .labl_07
;----------------------------------------------------------
.labl_06:
cmp [ebp-16],ecx
jb .labl_08
 
mov eax,[distances+512]
mov ecx,[ebp+12]
add eax,4
mov [ecx],eax
mov eax,[ebp-16]
;----------------------------------------------------------
.labl_07:
mov ecx,[ebp+16]
mov [ecx],eax
dec eax
call MovePos
jmp .labl_75
;----------------------------------------------------------
.labl_08:
mov ecx,[_buffer]
mov eax,[_pos]
mov dl,[eax+ecx-1]
sub eax,[_repDistances]
mov bl,[_state]
mov [state.State],bl
mov al,[eax+ecx-2]
mov [ebp-52],al
mov eax,[ebp+8]
and eax,3
movzx ecx,bl
shl ecx,4
add ecx,eax
mov esi,[_isMatch+ecx*4]
mov [ebp-28],eax
cmp bl,7
sbb al,al
mov [ebp-48],dl
push dword [ebp-48]
inc al
push dword [ebp-52]
movzx eax,al
push eax
push dword [ebp+8]
mov al,[_previousByte]
mov [ebp-76],esi
call CLiteralEncoder_GetPrice
or dword [state.BackPrev+40],0xFFFFFFFF
and dword [state.PosPrev+40],0
shr esi,2
add eax,[Models+esi*4]
mov byte [state.Prev1IsChar+40],0
mov [state.Price+40],eax
lea esi,[ebp-100]
mov edi,state.Backs
movsd
movsd
mov eax,2048
mov ecx,eax
sub ecx,[ebp-76]
movsd
shr ecx,2
mov edx,[Models+ecx*4]
movzx ecx,bl
movsd
mov esi,[_isRep+ecx*4]
sub eax,esi
shr eax,2
mov edi,[Models+eax*4]
mov al,[ebp-48]
add edi,edx
mov [ebp-76],edx
cmp [ebp-52],al
jne .labl_09
 
push dword [ebp-28]
mov al,bl
call GetRepLen1Price
add eax,edi
cmp eax,[state.Price+40]
jnb .labl_09
 
and dword [state.BackPrev+40],0
mov [state.Price+40],eax
mov byte [state.Prev1IsChar+40],0
;----------------------------------------------------------
.labl_09:
push 2
pop eax
cmp [ebp-16],eax
jnb .labl_10
 
mov eax,[ebp+12]
mov ecx,[state.BackPrev+40]
mov [eax],ecx
mov eax,[ebp+16]
mov dword [eax],1
jmp .labl_75
;----------------------------------------------------------
.labl_10:
mov ecx,[ebp-16]
shr esi,2
mov esi,[Models+esi*4]
add esi,[ebp-76]
mov [ebp-76],esi
cmp ecx,[ebp-68]
ja .labl_11
 
and dword [ebp-16],0
;----------------------------------------------------------
.labl_11:
mov [ebp-24],eax
cmp [ebp-16],eax
jb .labl_13
 
mov esi,state.BackPrev+40*2
;----------------------------------------------------------
.labl_12:
mov eax,[ebp-24]
mov edx,[distances+eax*4]
push dword [ebp-28]
and dword [esi-4],0
lea ecx,[edx+4]
mov [esi],ecx
call GetPosLenPrice
add eax,[ebp-76]
inc dword [ebp-24]
mov [esi-8],eax
mov eax,[ebp-24]
mov byte [esi-19],0
add esi,40
cmp eax,[ebp-16]
jbe .labl_12
;----------------------------------------------------------
.labl_13:
mov ecx,[ebp-16]
cmp ecx,[ebp-68]
jnb .labl_14
 
mov ecx,[ebp-68]
mov [ebp-16],ecx
;----------------------------------------------------------
.labl_14:
cmp [ebp-24],ecx
ja .labl_16
 
mov eax,[ebp-24]
sub ecx,[ebp-24]
imul eax,eax,40
add eax,state.Price
inc ecx
;----------------------------------------------------------
.labl_15:
mov dword [eax],kIfinityPrice
add eax,40
dec ecx
jne .labl_15
;----------------------------------------------------------
.labl_16:
and dword [ebp-24],0
;----------------------------------------------------------
.labl_17:
mov eax,[ebp-24]
mov eax,[ebp+eax*4-116]
push 2
pop ecx
mov [ebp-32],ecx
cmp eax,ecx
jb .labl_20
 
mov esi,state.Price+40*2
;----------------------------------------------------------
.labl_18:
push dword [ebp-28]
mov edx,[ebp-24]
movzx eax,bl
push eax
mov eax,[ebp-32]
call GetRepPrice
add eax,edi
cmp eax,[esi]
jnb .labl_19
 
and dword [esi+4],0
mov [esi],eax
mov eax,[ebp-24]
mov [esi+8],eax
mov byte [esi-11],0
;----------------------------------------------------------
.labl_19:
inc dword [ebp-32]
mov eax,[ebp-24]
mov ecx,[ebp-32]
add esi,40
cmp ecx,[ebp+eax*4-116]
jbe .labl_18
;----------------------------------------------------------
.labl_20:
inc dword [ebp-24]
cmp dword [ebp-24],4
jb .labl_17
 
mov eax,[ebp-16]
xor ecx,ecx
inc ecx
mov [ebp-8],eax
mov [ebp-12],ecx
cmp eax,ecx
je .labl_74
;----------------------------------------------------------
.labl_21:
mov edi,[ebp-12]
inc dword [ebp+8]
mov ebx,edi
imul ebx,ebx,40
mov dl,[ebx+state.Prev1IsChar]
mov esi,[ebx+state.PosPrev]
test dl,dl
je .labl_25
 
dec esi
cmp byte [ebx+state.Prev2],0
je .labl_23
 
mov eax,[ebx+state.PosPrev2]
imul eax,eax,40
cmp dword [ebx+state.BackPrev2],4
mov al,[eax+state.State]
movzx eax,al
jnb .labl_22
 
mov al,[eax+RepNextStates]
jmp .labl_24
;----------------------------------------------------------
.labl_22:
mov al,[eax+MatchNextStates]
jmp .labl_24
;----------------------------------------------------------
.labl_23:
mov eax,esi
imul eax,eax,40
mov al,[eax+state.State]
;----------------------------------------------------------
.labl_24:
movzx eax,al
mov cl,[eax+LiteralNextStates]
jmp .labl_26
;----------------------------------------------------------
.labl_25:
mov eax,esi
imul eax,eax,40
mov cl,[eax+state.State]
;----------------------------------------------------------
.labl_26:
dec edi
cmp esi,edi
jne .labl_29
 
cmp dword [ebx+state.BackPrev],0
movzx eax,cl
jne .labl_27
 
mov al,[eax+ShortRepNextStates]
jmp .labl_28
;----------------------------------------------------------
.labl_27:
mov al,[eax+LiteralNextStates]
;----------------------------------------------------------
.labl_28:
mov [ebp-20],al
jmp .labl_35
;----------------------------------------------------------
.labl_29:
test dl,dl
je .labl_31
 
cmp byte [ebx+state.Prev2],0
je .labl_31
 
mov esi,[ebx+state.PosPrev2]
mov eax,[ebx+state.BackPrev2]
movzx ecx,cl
;----------------------------------------------------------
.labl_30:
mov cl,[ecx+RepNextStates]
jmp .labl_32
;----------------------------------------------------------
.labl_31:
mov eax,[ebx+state.BackPrev]
movzx ecx,cl
cmp eax,4
jb .labl_30
 
mov cl,[ecx+MatchNextStates]
;----------------------------------------------------------
.labl_32:
imul esi,esi,40
add esi,state.State
mov [ebp-20],cl
mov edx,esi
cmp eax,4
jnb .labl_34
 
mov ecx,[edx+eax*4+24]
xor esi,esi
inc esi
mov [ebp-100],ecx
cmp eax,esi
jb .labl_33
 
lea esi,[edx+24]
mov ecx,eax
lea edi,[ebp-96]
rep movsd
lea esi,[eax+1]
cmp esi,4
jnb .labl_35
;----------------------------------------------------------
.labl_33:
push 4
lea edx,[edx+esi*4+24]
pop ecx
lea edi,[ebp+esi*4-100]
sub ecx,esi
mov esi,edx
rep movsd
jmp .labl_35
;----------------------------------------------------------
.labl_34:
add eax,0xFFFFFFFC
mov [ebp-100],eax
lea esi,[edx+24]
lea edi,[ebp-96]
movsd
movsd
movsd
;----------------------------------------------------------
.labl_35:
mov al,[ebp-20]
mov [ebx+state.State],al
lea edi,[ebx+state.Backs]
lea esi,[ebp-100]
movsd
movsd
movsd
movsd
call ReadMatchDistances
mov [ebp-44],eax
cmp eax,128
jnb .labl_73
 
mov eax,[ebx+state.Price]
mov edi,[_pos]
mov esi,[ebp+8]
mov [ebp-72],eax
mov eax,[_buffer]
lea eax,[edi+eax-1]
mov cl,[eax]
mov [ebp-48],cl
push dword [ebp-48]
mov ecx,eax
sub ecx,[ebp-100]
and esi,3
mov cl,[ecx-1]
mov [ebp-52],cl
movzx ecx,byte [ebp-20]
push dword [ebp-52]
mov [ebp-64],ecx
shl ecx,4
add ecx,esi
mov ecx,[_isMatch+ecx*4]
cmp byte [ebp-20],7
mov [ebp-76],ecx
sbb cl,cl
inc cl
movzx ecx,cl
push ecx
push dword [ebp+8]
mov [ebp-40],eax
mov al,[eax-1]
mov [ebp-28],esi
call CLiteralEncoder_GetPrice
mov esi,eax
mov eax,[ebp-76]
shr eax,2
add esi,[Models+eax*4]
mov byte [ebp-1],0
add esi,[ebp-72]
cmp esi,[ebx+state.Price+40]
jnb .labl_36
 
mov eax,[ebp-12]
or dword [ebx+state.BackPrev+40],0xFFFFFFFF
mov [ebx+state.Price+40],esi
mov [ebx+state.PosPrev+40],eax
mov byte [ebx+state.Prev1IsChar+40],0
mov byte [ebp-1],1
;----------------------------------------------------------
.labl_36:
mov edx,[ebp-64]
mov edx,[_isRep+edx*4]
mov ecx,2048
mov eax,ecx
sub eax,[ebp-76]
sub ecx,edx
shr eax,2
mov eax,[Models+eax*4]
add eax,[ebp-72]
shr ecx,2
mov ecx,[Models+ecx*4]
add ecx,eax
mov [ebp-76],eax
mov al,[ebp-48]
mov [ebp-84],edx
mov [ebp-72],ecx
cmp [ebp-52],al
jne .labl_38
 
mov eax,[ebp-12]
cmp [ebx+state.PosPrev+40],eax
jnb .labl_37
 
cmp dword [ebx+state.BackPrev+40],0
je .labl_38
;----------------------------------------------------------
.labl_37:
push dword [ebp-28]
mov al,[ebp-20]
call GetRepLen1Price
add eax,[ebp-72]
cmp eax,[ebx+state.Price+40]
ja .labl_38
 
and dword [ebx+state.BackPrev+40],0
mov [ebx+state.Price+40],eax
mov eax,[ebp-12]
mov [ebx+state.PosPrev+40],eax
mov byte [ebx+state.Prev1IsChar+40],0
;----------------------------------------------------------
.labl_38:
mov eax,[_streamPos]
sub eax,edi
mov ecx,4095
sub ecx,[ebp-12]
inc eax
mov [ebp-56],eax
cmp eax,ecx
jbe .labl_39
 
mov eax,ecx
mov [ebp-56],ecx
;----------------------------------------------------------
.labl_39:
mov [ebp-36],eax
cmp eax,2
jb .labl_72
 
mov ecx,128
cmp eax,ecx
jbe .labl_40
 
mov [ebp-36],ecx
;----------------------------------------------------------
.labl_40:
cmp dword [ebp-36],3
jb .labl_45
 
cmp byte [ebp-1],0
jne .labl_45
 
mov ecx,[ebp-100]
xor eax,eax
inc eax
inc ecx
cmp [ebp-36],eax
jbe .labl_42
 
mov edi,[ebp-40]
mov edx,edi
sub edx,ecx
;----------------------------------------------------------
.labl_41:
mov cl,[eax+edi]
cmp cl,[edx+eax]
jne .labl_42
 
inc eax
cmp eax,[ebp-36]
jb .labl_41
;----------------------------------------------------------
.labl_42:
dec eax
mov [ebp-32],eax
cmp eax,2
jb .labl_45
 
mov eax,[ebp-64]
mov al,[eax+LiteralNextStates]
mov ecx,[ebp+8]
movzx edx,al
mov [ebp-60],al
mov eax,edx
shl eax,4
inc ecx
mov edi,2048
and ecx,3
add eax,ecx
mov ebx,edi
sub ebx,[_isMatch+eax*4]
mov eax,edi
sub eax,[_isRep+edx*4]
mov edx,[ebp-12]
shr ebx,2
mov edi,[Models+ebx*4]
shr eax,2
add edi,[Models+eax*4]
mov eax,[ebp-32]
add edi,esi
lea esi,[edx+eax]
mov eax,[ebp-8]
lea edx,[esi+1]
cmp eax,edx
jnb .labl_44
 
sub edx,[ebp-8]
imul eax,eax,40
add eax,state.Price
add [ebp-8],edx
;----------------------------------------------------------
.labl_43:
add eax,40
dec edx
mov dword [eax],kIfinityPrice
jne .labl_43
;----------------------------------------------------------
.labl_44:
mov eax,[ebp-32]
push ecx
push dword [ebp-60]
xor edx,edx
call GetRepPrice
imul esi,esi,40
add eax,edi
add esi,state.State+40
cmp eax,[esi+12]
jnb .labl_45
 
mov [esi+12],eax
mov eax,[ebp-12]
inc eax
and dword [esi+20],0
mov [esi+16],eax
mov byte [esi+1],1
mov byte [esi+2],0
;----------------------------------------------------------
.labl_45:
and dword [ebp-24],0
;----------------------------------------------------------
.labl_46:
mov eax,[ebp-24]
mov eax,[ebp+eax*4-100]
mov edx,[ebp-40]
inc eax
mov ecx,edx
sub ecx,eax
mov [ebp-68],eax
mov al,[edx]
mov [ebp-80],ecx
cmp al,[ecx]
jne .labl_58
 
mov al,[edx+1]
cmp al,[ecx+1]
jne .labl_58
 
push 2
pop esi
cmp [ebp-36],esi
jbe .labl_48
;----------------------------------------------------------
.labl_47:
mov al,[edx+esi]
cmp al,[ecx+esi]
jne .labl_48
 
inc esi
cmp esi,[ebp-36]
jb .labl_47
;----------------------------------------------------------
.labl_48:
mov eax,[ebp-12]
lea ebx,[eax+esi]
mov [ebp-32],ebx
imul ebx,ebx,40
mov edi,esi
add ebx,state.Price
;----------------------------------------------------------
.labl_49:
mov eax,[ebp-8]
mov ecx,[ebp-32]
cmp eax,ecx
jnb .labl_51
 
sub ecx,[ebp-8]
imul eax,eax,40
add eax,state.Price
add [ebp-8],ecx
;----------------------------------------------------------
.labl_50:
add eax,40
dec ecx
mov dword [eax],kIfinityPrice
jne .labl_50
;----------------------------------------------------------
.labl_51:
push dword [ebp-28]
mov edx,[ebp-24]
push dword [ebp-20]
mov eax,esi
call GetRepPrice
add eax,[ebp-72]
cmp eax,[ebx]
jnb .labl_52
 
mov [ebx],eax
mov eax,[ebp-12]
mov [ebx+4],eax
mov eax,[ebp-24]
mov [ebx+8],eax
mov byte [ebx-11],0
;----------------------------------------------------------
.labl_52:
dec esi
sub ebx,40
dec dword [ebp-32]
cmp esi,2
jnb .labl_49
 
lea eax,[edi+1]
lea esi,[eax+128]
cmp esi,[ebp-56]
jbe .labl_53
 
mov esi,[ebp-56]
;----------------------------------------------------------
.labl_53:
cmp eax,esi
jnb .labl_55
 
mov edx,[ebp-40]
mov ecx,eax
sub ecx,[ebp-68]
add ecx,edx
;----------------------------------------------------------
.labl_54:
mov bl,[eax+edx]
cmp bl,[ecx]
jne .labl_55
 
inc eax
inc ecx
cmp eax,esi
jb .labl_54
;----------------------------------------------------------
.labl_55:
or ecx,0xFFFFFFFF
sub ecx,edi
add eax,ecx
mov [ebp-16],eax
cmp eax,2
jb .labl_58
 
mov eax,[ebp-64]
mov al,[eax+RepNextStates]
mov edx,[ebp+8]
movzx eax,al
mov ebx,eax
mov al,[eax+LiteralNextStates]
lea ecx,[edi+edx]
mov [ebp-60],al
movzx eax,al
mov esi,ecx
and esi,3
shl ebx,4
add esi,ebx
mov esi,[_isMatch+esi*4]
lea ebx,[edi+edx+1]
mov [ebp-32],eax
mov eax,[ebp-40]
movzx edx,byte [edi+eax]
mov al,[eax+edi-1]
push edx
mov edx,[ebp-80]
movzx edx,byte [edx+edi]
push edx
shr esi,2
mov esi,[Models+esi*4]
push 1
push ecx
mov [ebp-68],esi
and ebx,3
call CLiteralEncoder_GetPrice
push dword [ebp-28]
mov edx,[ebp-24]
push dword [ebp-20]
mov esi,eax
mov eax,edi
call GetRepPrice
mov ecx,[ebp-32]
add esi,eax
shl ecx,4
add ecx,ebx
mov eax,2048
mov edx,eax
sub edx,[_isMatch+ecx*4]
mov ecx,[ebp-32]
sub eax,[_isRep+ecx*4]
mov ecx,[ebp-12]
shr edx,2
add esi,[Models+edx*4]
shr eax,2
add esi,[Models+eax*4]
mov eax,[ebp-16]
add esi,[ebp-68]
lea eax,[eax+edi+1]
add esi,[ebp-72]
add eax,ecx
mov [ebp-68],eax
cmp [ebp-8],eax
jnb .labl_57
 
mov eax,[ebp-8]
mov ecx,[ebp-68]
imul eax,eax,40
sub ecx,[ebp-8]
add eax,state.Price
add [ebp-8],ecx
;----------------------------------------------------------
.labl_56:
add eax,40
dec ecx
mov dword [eax],kIfinityPrice
jne .labl_56
;----------------------------------------------------------
.labl_57:
mov eax,[ebp-16]
push ebx
push dword [ebp-60]
xor edx,edx
call GetRepPrice
mov ecx,[ebp-68]
imul ecx,ecx,40
add eax,esi
add ecx,state.State
cmp eax,[ecx+12]
jnb .labl_58
 
and dword [ecx+20],0
mov [ecx+12],eax
mov eax,[ebp-12]
lea edx,[edi+eax+1]
mov [ecx+4],eax
mov eax,[ebp-24]
mov [ecx+16],edx
mov byte [ecx+1],1
mov byte [ecx+2],1
mov [ecx+8],eax
;----------------------------------------------------------
.labl_58:
inc dword [ebp-24]
cmp dword [ebp-24],4
jb .labl_46
 
mov eax,[ebp-36]
cmp [ebp-44],eax
jbe .labl_59
 
mov [ebp-44],eax
;----------------------------------------------------------
.labl_59:
cmp dword [ebp-44],2
jb .labl_72
 
mov esi,[ebp-44]
cmp esi,2
jne .labl_60
 
cmp dword [distances+8],0x80
jnb .labl_72
;----------------------------------------------------------
.labl_60:
mov eax,[ebp-84]
shr eax,2
mov eax,[Models+eax*4]
add eax,[ebp-76]
mov [ebp-76],eax
mov eax,[ebp-12]
lea ecx,[esi+eax]
cmp [ebp-8],ecx
jnb .labl_62
 
mov eax,[ebp-8]
imul eax,eax,40
mov edx,ecx
sub edx,[ebp-8]
add eax,state.Price
add [ebp-8],edx
;----------------------------------------------------------
.labl_61:
add eax,40
dec edx
mov dword [eax],kIfinityPrice
jne .labl_61
;----------------------------------------------------------
.labl_62:
imul ecx,ecx,40
add ecx,state.Price
lea eax,[distances+4+esi*4]
lea edi,[esi+1]
mov [ebp-36],eax
mov ebx,ecx
mov [ebp-72],ecx
;----------------------------------------------------------
.labl_63:
mov eax,[ebp-36]
mov esi,[eax-4]
push dword [ebp-28]
lea eax,[edi-1]
mov edx,esi
call GetPosLenPrice
add eax,[ebp-76]
mov [ebp-80],eax
cmp eax,[ebx]
jnb .labl_64
 
mov [ebx],eax
mov eax,[ebp-12]
mov [ebx+4],eax
lea eax,[esi+4]
mov [ebx+8],eax
mov byte [ebx-11],0
;----------------------------------------------------------
.labl_64:
lea eax,[edi-1]
cmp eax,[ebp-44]
je .labl_65
 
mov eax,[ebp-36]
cmp esi,[eax]
je .labl_71
;----------------------------------------------------------
.labl_65:
inc esi
lea ecx,[edi+128]
mov [ebp-68],esi
mov [ebp-16],edi
cmp ecx,[ebp-56]
jbe .labl_66
 
mov ecx,[ebp-56]
;----------------------------------------------------------
.labl_66:
cmp edi,ecx
jnb .labl_68
 
mov eax,edi
sub eax,esi
add eax,[ebp-40]
;----------------------------------------------------------
.labl_67:
mov edx,[ebp-16]
mov esi,[ebp-40]
mov dl,[edx+esi]
cmp dl,[eax]
jne .labl_68
 
inc dword [ebp-16]
inc eax
cmp [ebp-16],ecx
jb .labl_67
;----------------------------------------------------------
.labl_68:
or ecx,0xFFFFFFFF
lea eax,[edi-1]
sub ecx,eax
add [ebp-16],ecx
cmp dword [ebp-16],2
jb .labl_71
 
mov eax,[ebp-64]
mov al,[eax+MatchNextStates]
mov ecx,[ebp+8]
movzx eax,al
mov esi,eax
mov al,[eax+LiteralNextStates]
lea edx,[edi+ecx-1]
mov [ebp-60],al
movzx eax,al
shl esi,4
mov ebx,edx
and ebx,3
add esi,ebx
mov esi,[_isMatch+esi*4]
lea ebx,[edi+ecx]
mov [ebp-32],eax
mov eax,[ebp-40]
movzx ecx,byte [edi+eax-1]
push ecx
mov ecx,edi
sub ecx,[ebp-68]
shr esi,2
movzx ecx,byte [ecx+eax-1]
mov esi,[Models+esi*4]
mov al,[edi+eax-2]
push ecx
push 1
push edx
mov [ebp-84],esi
and ebx,3
call CLiteralEncoder_GetPrice
mov ecx,[ebp-32]
mov esi,eax
shl ecx,4
add ecx,ebx
mov eax,2048
mov edx,eax
sub edx,[_isMatch+ecx*4]
mov ecx,[ebp-32]
sub eax,[_isRep+ecx*4]
mov ecx,[ebp-12]
shr edx,2
add esi,[Models+edx*4]
shr eax,2
add esi,[Models+eax*4]
mov eax,[ebp-16]
add esi,[ebp-84]
add eax,edi
add esi,[ebp-80]
add eax,ecx
mov [ebp-32],eax
cmp [ebp-8],eax
jnb .labl_70
 
mov eax,[ebp-8]
mov ecx,[ebp-32]
imul eax,eax,40
sub ecx,[ebp-8]
add eax,state.Price
add [ebp-8],ecx
;----------------------------------------------------------
.labl_69:
add eax,40
dec ecx
mov dword [eax],kIfinityPrice
jne .labl_69
;----------------------------------------------------------
.labl_70:
mov eax,[ebp-16]
push ebx
push dword [ebp-60]
xor edx,edx
call GetRepPrice
mov ecx,[ebp-32]
mov ebx,[ebp-72]
imul ecx,ecx,40
add eax,esi
add ecx,state.State
cmp eax,[ecx+12]
jnb .labl_71
 
and dword [ecx+20],0
mov [ecx+12],eax
mov eax,[ebp-12]
lea edx,[edi+eax]
mov [ecx+4],eax
mov eax,[ebp-68]
add eax,3
mov [ecx+16],edx
mov byte [ecx+1],1
mov byte [ecx+2],1
mov [ecx+8],eax
;----------------------------------------------------------
.labl_71:
sub dword [ebp-36],4
sub ebx,40
dec edi
lea eax,[edi-1]
mov [ebp-72],ebx
cmp eax,2
jnb .labl_63
;----------------------------------------------------------
.labl_72:
inc dword [ebp-12]
mov eax,[ebp-12]
cmp eax,[ebp-8]
jne .labl_21
 
jmp .labl_74
;----------------------------------------------------------
.labl_73:
mov eax,[ebp-44]
mov [_longestMatchLength],eax
mov byte [_longestMatchWasFound],1
;----------------------------------------------------------
.labl_74:
push dword [ebp-12]
push dword [ebp+12]
call Backward
mov ecx,[ebp+16]
mov [ecx],eax
;----------------------------------------------------------
.labl_75:
pop ebx
pop edi
;----------------------------------------------------------
.labl_76:
pop esi
leave
ret 12
;*****************************************************************************
 
;* Call: ***************************************************************
CLiteralEncoder2_EncodeMatched:
push ebp
mov ebp,esp
push ecx
push ebx
push esi
xor ebx,ebx
push edi
inc ebx
mov dword [ebp-4],8
;----------------------------------------------------------
.labl_00:
dec dword [ebp-4]
movzx ecx,byte [ebp-4]
movzx esi,byte [ebp+12]
movzx edi,byte [ebp+16]
shr esi,cl
shr edi,cl
mov ecx,[ebp+8]
and esi,1
lea eax,[esi+1]
shl eax,8
add eax,ebx
and edi,1
push edi
lea edx,[ecx+eax*4]
call CMyBitEncoder_Encode
add ebx,ebx
or ebx,edi
cmp esi,edi
jne .labl_02
 
cmp dword [ebp-4],0
jne .labl_00
 
jmp .labl_03
;----------------------------------------------------------
.labl_01:
dec dword [ebp-4]
movzx esi,byte [ebp+16]
mov cl,[ebp-4]
mov eax,[ebp+8]
shr esi,cl
lea edx,[eax+ebx*4]
and esi,1
push esi
call CMyBitEncoder_Encode
add ebx,ebx
or ebx,esi
;----------------------------------------------------------
.labl_02:
cmp dword [ebp-4],0
jne .labl_01
;----------------------------------------------------------
.labl_03:
pop edi
pop esi
pop ebx
leave
ret 12
;*****************************************************************************
 
;* Call: ***************************************************************
RangeEncoder_EncodeDirectBits:
push esi
mov esi,eax
jmp .labl_02
;----------------------------------------------------------
.labl_00:
mov eax,[esp+8]
shr dword [_range],1
dec esi
mov ecx,esi
shr eax,cl
test al,1
je .labl_01
 
mov eax,[_range]
add [low],eax
adc dword [low+4],0
;----------------------------------------------------------
.labl_01:
cmp dword [_range],0x1000000
jnb .labl_02
 
shl dword [_range],8
call RangeEncoder_ShiftLow
;----------------------------------------------------------
.labl_02:
test esi,esi
jne .labl_00
 
pop esi
ret 4
;*****************************************************************************
 
;* Call: ***************************************************************
CBitTreeEncoder_ReverseEncode:
push esi
xor esi,esi
push edi
mov edi,[i_01]
inc esi
;----------------------------------------------------------
.labl_00:
mov eax,[esp+12]
and eax,1
lea edx,[_posAlignEncoder+esi*4]
push eax
lea esi,[eax+esi*2]
call CMyBitEncoder_Encode
shr dword [esp+12],1
dec edi
jne .labl_00
 
pop edi
pop esi
ret 4
;*****************************************************************************
 
;* Call: ***************************************************************
MovePos:
push esi
mov esi,eax
test esi,esi
je .labl_01
 
add [_additionalOffset],esi
;----------------------------------------------------------
.labl_00:
dec esi
call lz_cm_09
call MatchFinder_MovePos
test esi,esi
jne .labl_00
;----------------------------------------------------------
.labl_01:
pop esi
ret
;*****************************************************************************
 
;* Call: ***************************************************************
Backward:
push ebp
mov ebp,esp
push ecx
mov ecx,[ebp+12]
mov eax,ecx
imul eax,eax,40
mov edx,[eax+state.PosPrev]
mov eax,[eax+state.BackPrev]
push ebx
push esi
mov [_optimumEndIndex],ecx
mov [ebp-4],eax
push edi
;----------------------------------------------------------
.labl_00:
imul ecx,ecx,40
cmp byte [ecx+state.Prev1IsChar],0
je .labl_01
 
mov eax,edx
imul eax,eax,40
or dword [eax+state.BackPrev],0xFFFFFFFF
lea esi,[eax+state.Prev1IsChar]
lea edi,[eax+state.PosPrev]
lea ebx,[edx-1]
mov byte [esi],0
mov [edi],ebx
cmp byte [ecx+state.Prev2],0
je .labl_01
 
mov byte [esi-40],0
mov esi,[ecx+state.PosPrev2]
mov [edi-40],esi
mov ecx,[ecx+state.BackPrev2]
mov [eax+state.BackPrev-40],ecx
;----------------------------------------------------------
.labl_01:
mov ecx,[ebp-4]
mov eax,edx
imul eax,eax,40
mov esi,edx
mov edx,[eax+state.BackPrev]
mov [eax+state.BackPrev],ecx
mov ecx,[ebp+12]
mov [ebp-4],edx
mov edx,[eax+state.PosPrev]
mov [eax+state.PosPrev],ecx
mov ecx,esi
mov [ebp+12],ecx
test esi,esi
jne .labl_00
 
mov eax,[state.BackPrev]
mov ecx,[ebp+8]
pop edi
mov [ecx],eax
mov eax,[state.PosPrev]
pop esi
mov [_optimumCurrentIndex],eax
pop ebx
leave
ret 8
;*****************************************************************************
 
;* Call: ***************************************************************
lz_cm_09:
push ebp
mov ebp,esp
mov edx,[_matchMaxLen]
mov eax,[_pos]
mov ecx,[_streamPos]
sub esp,44
push esi
lea esi,[edx+eax]
cmp esi,ecx
ja .labl_00
 
mov [ebp-24],edx
jmp .labl_01
;----------------------------------------------------------
.labl_00:
sub ecx,eax
mov [ebp-24],ecx
cmp ecx,3
jb .labl_13
;----------------------------------------------------------
.labl_01:
mov ecx,[_cyclicBufferSize]
mov edx,eax
sub edx,ecx
cmp ecx,eax
mov ecx,[_buffer]
lea esi,[ecx+eax]
movzx ecx,byte [esi+2]
push ebx
movzx ebx,word [esi]
push edi
sbb edi,edi
and dword [ebp-28],0
and dword [ebp-40],0
shl ecx,8
and edi,edx
movzx edx,byte [esi]
xor ecx,[crc_table+edx*4]
movzx edx,byte [esi+1]
xor ecx,edx
mov edx,[_hash]
and ecx,0xFFFFF
lea ecx,[edx+ecx*4]
mov [edx+ebx*4+0x400000],eax
mov ebx,[ecx]
mov [ecx],eax
mov ecx,[pack_pos]
lea ecx,[edx+ecx*8+0x440000]
mov [ebp-4],ebx
lea ebx,[ecx+4]
mov [ebp-12],ecx
mov ecx,[_cutValue]
mov [ebp-16],ebx
mov [ebp-20],ecx
cmp [ebp-4],edi
jbe .labl_11
;----------------------------------------------------------
.labl_02:
mov ecx,[ebp-20]
dec dword [ebp-20]
test ecx,ecx
je .labl_11
 
mov ecx,[_buffer]
mov ebx,[ebp-4]
add ecx,ebx
mov [ebp-36],ecx
mov ecx,[ebp-40]
cmp ecx,[ebp-28]
jb .labl_03
 
mov ecx,[ebp-28]
;----------------------------------------------------------
.labl_03:
mov ebx,[ebp-36]
mov [ebp-8],ecx
add ecx,esi
sub ebx,esi
mov [ebp-32],ebx
jmp .labl_05
;----------------------------------------------------------
.labl_04:
mov ecx,[ebp-44]
mov ebx,[ebp-32]
;----------------------------------------------------------
.labl_05:
mov bl,[ebx+ecx]
cmp bl,[ecx]
jne .labl_06
 
inc dword [ebp-8]
inc ecx
mov [ebp-44],ecx
mov ecx,[ebp-8]
cmp ecx,[ebp-24]
jne .labl_04
;----------------------------------------------------------
.labl_06:
mov ecx,[pack_pos]
mov ebx,eax
sub ebx,[ebp-4]
cmp ebx,ecx
ja .labl_07
 
sub ecx,ebx
jmp .labl_08
;----------------------------------------------------------
.labl_07:
sub ecx,ebx
add ecx,[_cyclicBufferSize]
;----------------------------------------------------------
.labl_08:
lea ecx,[edx+ecx*8+0x440000]
mov [ebp-32],ecx
mov ecx,[ebp-8]
cmp ecx,[ebp-24]
je .labl_14
 
mov ebx,[ebp-36]
mov bl,[ecx+ebx]
cmp bl,[ecx+esi]
mov ecx,[ebp-4]
jnb .labl_09
 
mov ebx,[ebp-12]
mov [ebx],ecx
mov ecx,[ebp-32]
mov ebx,[ebp-8]
add ecx,4
mov [ebp-12],ecx
mov [ebp-28],ebx
jmp .labl_10
;----------------------------------------------------------
.labl_09:
mov ebx,[ebp-16]
mov [ebx],ecx
mov ecx,[ebp-32]
mov ebx,[ebp-8]
mov [ebp-16],ecx
mov [ebp-40],ebx
;----------------------------------------------------------
.labl_10:
mov ecx,[ecx]
mov [ebp-4],ecx
cmp ecx,edi
ja .labl_02
;----------------------------------------------------------
.labl_11:
mov eax,[ebp-12]
and dword [eax],0
mov eax,[ebp-16]
and dword [eax],0
;----------------------------------------------------------
.labl_12:
pop edi
pop ebx
;----------------------------------------------------------
.labl_13:
pop esi
leave
ret
;----------------------------------------------------------
.labl_14:
mov eax,[ebp-32]
mov ecx,[eax]
mov edx,[ebp-12]
mov [edx],ecx
mov eax,[eax+4]
mov ecx,[ebp-16]
mov [ecx],eax
jmp .labl_12
;*****************************************************************************
 
;* Call: ***************************************************************
GetPosSlot:
cmp eax,1024
jnb .labl_00
 
movzx eax,byte [eax+g_FastPos]
ret
;----------------------------------------------------------
.labl_00:
cmp eax,0x80000
jnb .labl_01
 
shr eax,9
movzx eax,byte [eax+g_FastPos]
add eax,18
ret
;----------------------------------------------------------
.labl_01:
shr eax,18
movzx eax,byte [eax+g_FastPos]
add eax,36 ;'$'
ret
;*****************************************************************************
 
;* Call: ***************************************************************
CPriceTableEncoder_Init:
push ebx
push edi
mov eax,1024
push 4
mov [esi],eax
mov [esi+4],eax
lea edi,[esi+0x4048]
pop ebx
;----------------------------------------------------------
.labl_00:
push 3
lea eax,[edi-0x4040]
pop ecx
call CBitTreeEncoder_Init
push 3
pop ecx
mov eax,edi
call CBitTreeEncoder_Init
add edi,1028
dec ebx
jne .labl_00
 
push 8
pop ecx
pop edi
lea eax,[esi+0x8088]
pop ebx
jmp CBitTreeEncoder_Init
;*****************************************************************************
 
;* Call: ***************************************************************
CPriceTableEncoder_UpdateTable:
push ebx
push edi
mov edi,eax
xor ebx,ebx
cmp [edi+0xC88C],ebx
jbe .labl_01
 
mov eax,[esp+12]
push esi
lea esi,[edi+eax*4+0x848C]
;----------------------------------------------------------
.labl_00:
mov eax,[esp+16]
mov edx,ebx
call NLength_CEncoder_GetPrice
mov [esi],eax
inc ebx
add esi,64
cmp ebx,[edi+0xC88C]
jb .labl_00
 
pop esi
;----------------------------------------------------------
.labl_01:
mov eax,[edi+0xC88C]
mov ecx,[esp+12]
mov [edi+ecx*4+0xC890],eax
pop edi
pop ebx
ret 4
;*****************************************************************************
 
;* Call: ***************************************************************
NLength_CEncoder_GetPrice:
push ebp
mov ebp,esp
push ecx
push esi
cmp edx,8
jnb .labl_00
 
imul eax,eax,1028
lea esi,[eax+edi+8]
call CBitTreeEncoder_GetPrice
mov ecx,[edi]
shr ecx,2
add eax,[Models+ecx*4]
jmp .labl_03
;----------------------------------------------------------
.labl_00:
push ebx
mov ebx,2048
mov ecx,ebx
sub ecx,[edi]
shr ecx,2
mov ecx,[Models+ecx*4]
mov [ebp-4],ecx
cmp edx,16
jnb .labl_01
 
imul eax,eax,1028
add edx,0xFFFFFFF8
lea esi,[eax+edi+0x4048]
call CBitTreeEncoder_GetPrice
mov ecx,[edi+4]
shr ecx,2
add eax,[Models+ecx*4]
jmp .labl_02
;----------------------------------------------------------
.labl_01:
add edx,0xFFFFFFF0
lea esi,[edi+0x8088]
call CBitTreeEncoder_GetPrice
sub ebx,[edi+4]
shr ebx,2
add eax,[Models+ebx*4]
;----------------------------------------------------------
.labl_02:
add [ebp-4],eax
mov eax,[ebp-4]
pop ebx
;----------------------------------------------------------
.labl_03:
pop esi
leave
ret
;*****************************************************************************
 
;* Call: ***************************************************************
CPriceTableEncoder_Encode:
push edi
mov edi,eax
mov edx,esi
cmp edi,8
jnb .labl_00
 
push 0
call CMyBitEncoder_Encode
mov eax,ebx
imul eax,eax,1028
push edi
lea edi,[eax+esi+8]
jmp .labl_02
;----------------------------------------------------------
.labl_00:
push 1
call CMyBitEncoder_Encode
lea edx,[esi+4]
cmp edi,16
jnb .labl_01
 
push 0
call CMyBitEncoder_Encode
add edi,0xFFFFFFF8
mov eax,ebx
imul eax,eax,1028
push edi
lea edi,[eax+esi+0x4048]
jmp .labl_02
;----------------------------------------------------------
.labl_01:
push 1
call CMyBitEncoder_Encode
add edi,0xFFFFFFF0
push edi
lea edi,[esi+0x8088]
;----------------------------------------------------------
.labl_02:
call cm_pr_16
dec dword [esi+ebx*4+0xC890]
pop edi
jne .labl_03
 
push ebx
mov eax,esi
call CPriceTableEncoder_UpdateTable
;----------------------------------------------------------
.labl_03:
ret
;*****************************************************************************
 
;* Call: ***************************************************************
CLiteralEncoder2_Encode:
push ebx
push esi
push edi
xor edi,edi
push 8
inc edi
pop ebx
;----------------------------------------------------------
.labl_00:
movzx esi,byte [esp+20]
mov eax,[esp+16]
dec ebx
mov cl,bl
shr esi,cl
lea edx,[eax+edi*4]
and esi,1
push esi
call CMyBitEncoder_Encode
add edi,edi
or edi,esi
test ebx,ebx
jne .labl_00
 
pop edi
pop esi
pop ebx
ret 8
;*****************************************************************************
 
;* Call: ***************************************************************
CState_IsCharState:
mov edx,[_numPrevBits]
push esi
mov esi,[_posMask]
and esi,[esp+8]
push 8
pop ecx
movzx eax,al
sub cl,dl
shr eax,cl
mov ecx,edx
shl esi,cl
add eax,esi
pop esi
ret 4
;*****************************************************************************
 
;* Call: ***************************************************************
CLiteralEncoder_GetPrice:
push dword [esp+16]
push dword [esp+16]
push dword [esp+16]
push dword [esp+16]
call CState_IsCharState
imul eax,eax,3072
add eax,[_posEncoders]
push eax
call lz_cm_11
ret 16
;*****************************************************************************
 
;* Call: ***************************************************************
lz_cm_11:
push ebp
mov ebp,esp
push ecx
push ebx
push esi
xor esi,esi
xor eax,eax
inc esi
push edi
mov dword [ebp-4],8
cmp [ebp+12],al
je .labl_02
 
movzx ecx,byte [ebp+20]
mov [ebp+12],ecx
;----------------------------------------------------------
.labl_00:
dec dword [ebp-4]
movzx ecx,byte [ebp-4]
movzx edi,byte [ebp+16]
mov edx,[ebp+12]
mov ebx,[ebp+8]
shr edi,cl
shr edx,cl
and edi,1
mov ecx,edi
shl ecx,8
add ecx,esi
mov ecx,[ebx+ecx*4+1024]
and edx,1
sub ecx,edx
mov ebx,edx
neg ebx
xor ecx,ebx
shr ecx,2
and ecx,0x1FF
add eax,[Models+ecx*4]
add esi,esi
or esi,edx
cmp edi,edx
jne .labl_01
 
cmp dword [ebp-4],0
jne .labl_00
 
jmp .labl_04
;----------------------------------------------------------
.labl_01:
cmp dword [ebp-4],0
je .labl_04
;----------------------------------------------------------
.labl_02:
movzx edi,byte [ebp+20]
;----------------------------------------------------------
.labl_03:
dec dword [ebp-4]
mov cl,[ebp-4]
mov edx,edi
shr edx,cl
mov ecx,[ebp+8]
mov ecx,[ecx+esi*4]
add esi,esi
and edx,1
sub ecx,edx
mov ebx,edx
neg ebx
xor ecx,ebx
shr ecx,2
and ecx,0x1FF
add eax,[Models+ecx*4]
or esi,edx
cmp dword [ebp-4],0
jne .labl_03
;----------------------------------------------------------
.labl_04:
pop edi
pop esi
pop ebx
leave
ret 16
;*****************************************************************************
 
;* Call: ***************************************************************
ReadMatchDistances:
push esi
call GetLongestMatch
mov ecx,eax
mov esi,0x80
cmp ecx,esi
jne .labl_00
 
push dword [distances+512]
lea eax,[esi+17]
push esi
call GetMatchLen
mov ecx,eax
add ecx,esi
;----------------------------------------------------------
.labl_00:
inc dword [_additionalOffset]
call MatchFinder_MovePos
mov eax,ecx
pop esi
ret
;*****************************************************************************
 
;* Call: ***************************************************************
GetLongestMatch:
push ebp
mov ebp,esp
sub esp,0x34
mov edx,[_matchMaxLen]
mov ecx,[_pos]
mov eax,[_streamPos]
and dword [ebp-24],0
push esi
lea esi,[edx+ecx]
cmp esi,eax
ja .labl_02
 
mov [ebp-32],edx
;----------------------------------------------------------
.labl_00:
mov eax,[_cyclicBufferSize]
mov edx,ecx
sub edx,eax
cmp eax,ecx
sbb eax,eax
and eax,edx
mov [ebp-40],eax
mov eax,[_buffer]
push ebx
push edi
lea edi,[eax+ecx]
movzx edx,byte [edi+2]
movzx esi,byte [edi]
movzx eax,word [edi]
shl edx,8
xor edx,[crc_table+esi*4]
movzx esi,byte [edi+1]
xor edx,esi
mov esi,[_hash]
and edx,0xFFFFF
lea edx,[esi+edx*4]
mov ebx,[edx]
lea eax,[esi+eax*4+0x400000]
mov [ebp-8],ebx
mov ebx,[eax]
mov [eax],ecx
or dword [distances+8],0xFFFFFFFF
cmp ebx,[ebp-40]
jbe .labl_01
 
mov eax,ecx
sub eax,ebx
dec eax
mov [distances+8],eax
mov dword [ebp-24],2
;----------------------------------------------------------
.labl_01:
mov ebx,[pack_pos]
and dword [ebp-36],0
mov [edx],ecx
or dword [distances+12],0xFFFFFFFF
and dword [ebp-48],0
lea edx,[esi+ebx*8+0x440000]
lea eax,[edx+4]
mov [ebp-20],eax
mov eax,[_cutValue]
mov [ebp-28],eax
mov eax,[ebp-8]
mov [ebp-16],edx
jmp .labl_13
;----------------------------------------------------------
.labl_02:
sub eax,ecx
mov [ebp-32],eax
cmp eax,3
jnb .labl_00
 
xor eax,eax
jmp .labl_16
;----------------------------------------------------------
.labl_03:
mov eax,[ebp-28]
dec dword [ebp-28]
test eax,eax
je .labl_14
 
mov eax,[_buffer]
mov edx,[ebp-8]
add eax,edx
mov [ebp-44],eax
mov eax,[ebp-48]
cmp eax,[ebp-36]
jb .labl_04
 
mov eax,[ebp-36]
;----------------------------------------------------------
.labl_04:
mov edx,[ebp-44]
mov [ebp-4],eax
add eax,edi
sub edx,edi
mov [ebp-12],edx
jmp .labl_06
;----------------------------------------------------------
.labl_05:
mov edx,[ebp-12]
mov eax,[ebp-52]
;----------------------------------------------------------
.labl_06:
mov dl,[edx+eax]
cmp dl,[eax]
jne .labl_07
 
inc dword [ebp-4]
inc eax
mov [ebp-52],eax
mov eax,[ebp-4]
cmp eax,[ebp-32]
jne .labl_05
;----------------------------------------------------------
.labl_07:
mov eax,ecx
sub eax,[ebp-8]
mov [ebp-12],eax
mov eax,[ebp-24]
cmp eax,[ebp-4]
jnb .labl_09
;----------------------------------------------------------
.labl_08:
mov edx,[ebp-12]
inc eax
dec edx
mov [distances+eax*4],edx
cmp eax,[ebp-4]
jb .labl_08
 
mov [ebp-24],eax
;----------------------------------------------------------
.labl_09:
mov eax,ebx
sub eax,[ebp-12]
cmp [ebp-12],ebx
jbe .labl_10
 
add eax,[_cyclicBufferSize]
;----------------------------------------------------------
.labl_10:
lea eax,[esi+eax*8+0x440000]
mov [ebp-12],eax
mov eax,[ebp-4]
cmp eax,[ebp-32]
je .labl_17
 
mov edx,[ebp-44]
mov dl,[eax+edx]
cmp dl,[eax+edi]
mov eax,[ebp-8]
jnb .labl_11
 
mov edx,[ebp-16]
mov [edx],eax
mov eax,[ebp-12]
mov edx,[ebp-4]
add eax,4
mov [ebp-16],eax
mov [ebp-36],edx
jmp .labl_12
;----------------------------------------------------------
.labl_11:
mov edx,[ebp-20]
mov [edx],eax
mov eax,[ebp-12]
mov edx,[ebp-4]
mov [ebp-20],eax
mov [ebp-48],edx
;----------------------------------------------------------
.labl_12:
mov eax,[eax]
mov [ebp-8],eax
;----------------------------------------------------------
.labl_13:
cmp eax,[ebp-40]
ja .labl_03
;----------------------------------------------------------
.labl_14:
mov eax,[ebp-16]
and dword [eax],0
mov eax,[ebp-20]
and dword [eax],0
;----------------------------------------------------------
.labl_15:
mov eax,[ebp-24]
pop edi
pop ebx
;----------------------------------------------------------
.labl_16:
pop esi
leave
ret
;----------------------------------------------------------
.labl_17:
mov eax,[ebp-12]
mov ecx,[eax]
mov edx,[ebp-16]
mov [edx],ecx
mov eax,[eax+4]
mov ecx,[ebp-20]
mov [ecx],eax
jmp .labl_15
;*****************************************************************************
 
;* Call: ***************************************************************
FillPosSlotPrices:
push ecx
push ebx
push ebp
push esi
push edi
xor ebp,ebp
mov esi,_posSlotEncoder
mov dword [esp+16],4
;----------------------------------------------------------
.labl_00:
xor edi,edi
;----------------------------------------------------------
.labl_01:
mov ebx,[_distTableSize]
cmp edi,ebx
jnb .labl_03
 
mov edx,edi
call CBitTreeEncoder_GetPrice
lea ecx,[edi+ebp]
inc edi
mov [_posSlotPrices+ecx*4],eax
cmp edi,14
jb .labl_01
 
cmp edi,ebx
jnb .labl_03
 
lea ebx,[edi+ebp]
lea ebx,[_posSlotPrices+ebx*4]
;----------------------------------------------------------
.labl_02:
mov edx,edi
call CBitTreeEncoder_GetPrice
mov ecx,edi
shr ecx,1
sub ecx,5
shl ecx,6
add eax,ecx
mov [ebx],eax
inc edi
add ebx,4
cmp edi,[_distTableSize]
jb .labl_02
;----------------------------------------------------------
.labl_03:
add esi,1028
add ebp,64
dec dword [esp+16]
jne .labl_00
 
pop edi
pop esi
pop ebp
pop ebx
pop ecx
ret
;***********************************************************************
 
;* Call: ***************************************************************
FillDistancesPrices:
push ebp
mov ebp,esp
sub esp,36
and dword [ebp-20],0
push ebx
push esi
push edi
push 4
pop ebx
mov dword [ebp-24],_distancesPrices+16
mov dword [ebp-16],_posSlotPrices
mov [ebp-36],ebx
;----------------------------------------------------------
.labl_00:
mov eax,[ebp-24]
mov esi,[ebp-16]
lea edi,[eax-16]
movsd
movsd
movsd
movsd
mov [ebp-4],ebx
mov [ebp-12],eax
;----------------------------------------------------------
.labl_01:
mov esi,[ebp-4]
mov eax,esi
call GetPosSlot
mov edx,eax
mov ecx,edx
xor eax,eax
inc eax
mov [ebp-32],edx
and edx,eax
shr ecx,1
dec ecx
or edx,2
shl edx,cl
xor edi,edi
mov [ebp-8],eax
mov [ebp-28],ecx
sub esi,edx
test ecx,ecx
je .labl_03
;----------------------------------------------------------
.labl_02:
mov eax,[ebp-8]
sub eax,[ebp-32]
mov ecx,esi
add eax,edx
mov eax,[_numLiteralContextBits+eax*4]
and ecx,1
sub eax,ecx
mov ebx,ecx
neg ebx
xor eax,ebx
shr eax,2
and eax,0x1FF
add edi,[Models+eax*4]
mov eax,[ebp-8]
shr esi,1
dec dword [ebp-28]
lea eax,[ecx+eax*2]
mov [ebp-8],eax
jne .labl_02
 
push 4
pop ebx
;----------------------------------------------------------
.labl_03:
mov eax,[ebp-32]
mov ecx,[ebp-20]
add ecx,eax
mov eax,[_posSlotPrices+ecx*4]
mov ecx,[ebp-12]
add [ebp-12],ebx
add eax,edi
inc dword [ebp-4]
cmp dword [ebp-4],0x80
mov [ecx],eax
jb .labl_01
 
add dword [ebp-16],256
add dword [ebp-20],64
add dword [ebp-24],512
dec dword [ebp-36]
jne .labl_00
 
pop edi
pop esi
pop ebx
leave
ret
;***********************************************************************
 
;* Call: ***************************************************************
FillAlignPrices:
push ebp
mov ebp,esp
push ecx
push ecx
push ebx
push esi
xor esi,esi
push edi
mov [ebp-8],esi
;----------------------------------------------------------
.labl_00:
mov eax,[i_01]
xor edx,edx
xor ecx,ecx
inc edx
mov [ebp-4],eax
;----------------------------------------------------------
.labl_01:
mov edi,[_posAlignEncoder+edx*4]
mov eax,esi
and eax,1
sub edi,eax
mov ebx,eax
neg ebx
xor edi,ebx
shr edi,2
and edi,0x1FF
add ecx,[Models+edi*4]
shr esi,1
dec dword [ebp-4]
lea edx,[eax+edx*2]
jne .labl_01
 
mov esi,[ebp-8]
push 16
mov [_alignPrices+esi*4],ecx
inc esi
pop eax
mov [ebp-8],esi
cmp esi,eax
jb .labl_00
 
pop edi
pop esi
mov [_alignPriceCount],eax
pop ebx
leave
ret
;***********************************************************************
 
;* Call: ***************************************************************
GetRepLen1Price:
movzx eax,al
mov edx,[_isRepG0+eax*4]
mov ecx,eax
shl ecx,4
add ecx,[esp+4]
shr edx,2
mov ecx,[_isRep0Long+ecx*4]
shr ecx,2
mov eax,[Models+ecx*4]
add eax,[Models+edx*4]
ret 4
;***********************************************************************
 
;* Call: ***************************************************************
GetRepPrice:
movzx ecx,byte [esp+4]
shl eax,4
add eax,[esp+8]
push esi
mov eax,[_repMatchLenEncoder+0x840C+eax*4]
mov esi,2048
test edx,edx
jne .labl_00
 
mov edx,ecx
mov ecx,[_isRepG0+ecx*4]
shl edx,4
add edx,[esp+12]
sub esi,[_isRep0Long+edx*4]
shr ecx,2
jmp .labl_02
;----------------------------------------------------------
.labl_00:
push edi
shl ecx,2
mov edi,esi
sub edi,[ecx+_isRepG0]
shr edi,2
add eax,[Models+edi*4]
pop edi
cmp edx,1
jne .labl_01
 
mov ecx,[ecx+_isRepG1]
shr ecx,2
add eax,[Models+ecx*4]
jmp .labl_03
;----------------------------------------------------------
.labl_01:
sub esi,[ecx+_isRepG1]
mov ecx,[ecx+_isRepG2]
add edx,0xFFFFFFFE
sub ecx,edx
neg edx
xor ecx,edx
shr ecx,2
and ecx,0x1FF
;----------------------------------------------------------
.labl_02:
shr esi,2
mov edx,[Models+esi*4]
add edx,[Models+ecx*4]
add eax,edx
;----------------------------------------------------------
.labl_03:
pop esi
ret 8
;***********************************************************************
 
;* Call: ***************************************************************
GetPosLenPrice:
push esi
mov esi,eax
mov ecx,0x80
cmp esi,2
jne .labl_00
 
cmp edx,ecx
jb .labl_01
 
mov eax,kIfinityPrice
jmp .labl_09
;----------------------------------------------------------
.labl_00:
cmp esi,6
jnb .labl_02
;----------------------------------------------------------
.labl_01:
lea eax,[esi-2]
jmp .labl_03
;----------------------------------------------------------
.labl_02:
push 3
pop eax
;----------------------------------------------------------
.labl_03:
cmp edx,ecx
jnb .labl_04
 
shl eax,7
add eax,edx
mov ecx,[_distancesPrices+eax*4]
jmp .labl_08
;----------------------------------------------------------
.labl_04:
mov ecx,edx
;GetPosSlot2
cmp edx,0x10000 ;if (pos < (1<<16))
jnb .labl_05
 
shr ecx,6
movzx ecx,byte [ecx+g_FastPos]
add ecx,12
jmp .labl_07
;----------------------------------------------------------
.labl_05:
cmp edx,0x2000000 ;if (pos < (1<<25))
jnb .labl_06
 
shr ecx,15
movzx ecx,byte [ecx+g_FastPos]
add ecx,30
jmp .labl_07
;----------------------------------------------------------
.labl_06:
shr ecx,24
movzx ecx,byte [ecx+g_FastPos]
add ecx,48
;----------------------------------------------------------
.labl_07:
shl eax,6
add eax,ecx
mov ecx,[_posSlotPrices+eax*4]
and edx,15
add ecx,[_alignPrices+edx*4]
;----------------------------------------------------------
.labl_08:
shl esi,4
add esi,[esp+8]
mov eax,[_prices+esi*4]
add eax,ecx
;----------------------------------------------------------
.labl_09:
pop esi
ret 4
;***********************************************************************
 
;* Call: ***************************************************************
RangeEncoder_ShiftLow:
push ecx
push ecx
mov eax,[low]
push esi
mov esi,[low+4]
cmp eax,0xFF000000
jb .labl_00
 
test esi,esi
je .labl_02
;----------------------------------------------------------
.labl_00:
mov cl,[_cache]
and dword [esp+8],0
mov edx,esi
push ebx
;----------------------------------------------------------
.labl_01:
mov bl,dl
add bl,cl
mov ecx,[pack_length]
inc dword [pack_length]
mov [ecx],bl
or cl,0xFF
dec dword [_cacheSize]
jne .labl_01
 
mov cl,[low+3]
mov [_cache],cl
pop ebx
;----------------------------------------------------------
.labl_02:
inc dword [_cacheSize]
shl eax,8
and dword [low+4],0
mov [low],eax
pop esi
pop ecx
pop ecx
ret
;***********************************************************************
 
;* Call: ***************************************************************
CMyBitEncoder_Encode:
mov ecx,[_range]
mov eax,[edx]
shr ecx,0xB
imul ecx,eax
cmp dword [esp+4],0
jne .labl_00
 
mov [_range],ecx
mov ecx,2048
sub ecx,eax
shr ecx,5
add ecx,eax
mov [edx],ecx
jmp .labl_01
;----------------------------------------------------------
.labl_00:
add [low],ecx
adc dword [low+4],0
sub [_range],ecx
mov ecx,eax
shr ecx,5
sub eax,ecx
mov [edx],eax
;----------------------------------------------------------
.labl_01:
cmp dword [_range],0x1000000
jnb .labl_02
 
shl dword [_range],8
call RangeEncoder_ShiftLow
;----------------------------------------------------------
.labl_02:
ret 4
;***********************************************************************
 
;* Call: ***************************************************************
CBitTreeEncoder_Init:
xor edx,edx
inc edx
shl edx,cl
mov [eax+1024],ecx
lea ecx,[edx-1]
test ecx,ecx
jbe .labl_00
 
push edi
lea edi,[eax+4]
mov eax,1024
rep stosd
pop edi
;----------------------------------------------------------
.labl_00:
ret
;***********************************************************************
 
;* Call: ***************************************************************
cm_pr_16:
mov eax,[esp+4]
push ebx
mov ebx,[edi+1024]
push esi
xor esi,esi
inc esi
add eax,eax
mov [esp+12],eax
;----------------------------------------------------------
.labl_00:
mov eax,[esp+12]
mov ecx,ebx
shr eax,cl
lea edx,[edi+esi*4]
and eax,1
push eax
lea esi,[eax+esi*2]
call CMyBitEncoder_Encode
dec ebx
jne .labl_00
 
pop esi
pop ebx
ret 4
;***********************************************************************
 
;* Call: ***************************************************************
CBitTreeEncoder_GetPrice:
mov ecx,[esi+1024]
push edi
xor edi,edi
inc edi
shl edi,cl
xor eax,eax
or edx,edi
;----------------------------------------------------------
.labl_00:
mov ecx,edx
shr edx,1
mov edi,[esi+edx*4]
and ecx,1
sub edi,ecx
neg ecx
xor edi,ecx
shr edi,2
and edi,0x1FF
add eax,[Models+edi*4]
cmp edx,1
jne .labl_00
 
pop edi
ret
;***********************************************************************
 
;* Call: ***************************************************************
GetMatchLen:
mov ecx,[_streamPos]
push edi
mov edi,eax
mov eax,[_pos]
sub ecx,eax
sub ecx,[esp+8]
cmp edi,ecx
jbe .labl_00
 
mov edi,ecx
;----------------------------------------------------------
.labl_00:
mov ecx,[_buffer]
inc dword [esp+12]
add ecx,eax
add ecx,[esp+8]
xor eax,eax
test edi,edi
jbe .labl_03
 
push esi
mov esi,ecx
sub esi,[esp+16]
;----------------------------------------------------------
.labl_01:
mov dl,[eax+ecx]
cmp dl,[esi+eax]
jne .labl_02
 
inc eax
cmp eax,edi
jb .labl_01
;----------------------------------------------------------
.labl_02:
pop esi
;----------------------------------------------------------
.labl_03:
pop edi
ret 8
;***********************************************************************
 
;* Call: ***************************************************************
MatchFinder_MovePos:
inc dword [pack_pos]
mov eax,[pack_pos]
cmp eax,[_cyclicBufferSize]
jne .labl_00
 
and dword [pack_pos],0
;----------------------------------------------------------
.labl_00:
inc dword [_pos]
ret
;***********************************************************************
/programs/other/outdated/kerpack/trunk/lzma_set_dict_size.inc
0,0 → 1,12
;* Call: ***************************************************************
; lzma_set_dict_size(unsigned logdictsize)
lzma_set_dict_size:
mov ecx,[esp+4]
xor eax,eax
inc eax
shl eax,cl
mov [_dictionarySize],eax
lea eax,[ecx+ecx]
mov [_distTableSize],eax
ret 4
;*****************************************************************************
/programs/other/outdated/kerpack/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/kerpack
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/mhc/trunk/build_en.bat
0,0 → 1,5
@erase lang.inc
@echo lang fix en >lang.inc
@fasm mhc.asm mhc
@erase lang.inc
@pause
/programs/other/outdated/mhc/trunk/build_ge.bat
0,0 → 1,5
@erase lang.inc
@echo lang fix ge >lang.inc
@fasm mhc.asm mhc
@erase lang.inc
@pause
/programs/other/outdated/mhc/trunk/mhc.asm
0,0 → 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)
/programs/other/outdated/mhc/trunk
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/mhc
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property
/programs/other/outdated/.
Property changes:
Added: tsvn:logminsize
+5
\ No newline at end of property