KlbrInWin src uploaded
git-svn-id: svn://kolibrios.org@2292 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a29fff6025
commit
6cfca28b78
7834
programs/emulator/KlbrInWin/I40EMUL.INC
Normal file
7834
programs/emulator/KlbrInWin/I40EMUL.INC
Normal file
File diff suppressed because it is too large
Load Diff
6359
programs/emulator/KlbrInWin/KlbrInWin.asm
Normal file
6359
programs/emulator/KlbrInWin/KlbrInWin.asm
Normal file
File diff suppressed because it is too large
Load Diff
BIN
programs/emulator/KlbrInWin/KlbrInWin.ico
Normal file
BIN
programs/emulator/KlbrInWin/KlbrInWin.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
BIN
programs/emulator/KlbrInWin/config.RES
Normal file
BIN
programs/emulator/KlbrInWin/config.RES
Normal file
Binary file not shown.
1509
programs/emulator/KlbrInWin/config.asm
Normal file
1509
programs/emulator/KlbrInWin/config.asm
Normal file
File diff suppressed because it is too large
Load Diff
80
programs/emulator/KlbrInWin/config.ini
Normal file
80
programs/emulator/KlbrInWin/config.ini
Normal file
@ -0,0 +1,80 @@
|
||||
[Disk]
|
||||
# path to ramdisk, must end with '\'
|
||||
RamDisk=
|
||||
|
||||
# hard disks:
|
||||
# there may be up to 4 physical harddisks,
|
||||
# each may contain 1 or more partitions (but no more than 255)
|
||||
# (sysfunction 18::11 returns this number as byte)
|
||||
# 255 should be enough :-)
|
||||
# Syntax:
|
||||
# hd<i>n = number of partitions for /hd<i>, 0 <= i <= 3
|
||||
# hd<i>_<j> = Win32 path for /hd<i>/<j>, 0 <= i <= 3, 1 <= j <= hd<i>n
|
||||
# must end with '\'; ',readonly' string may follow
|
||||
# (j is represented in decimal system)
|
||||
# (if harddisk /hd<i> is used, all partitions /hd<i>/<j> must be defined)
|
||||
|
||||
[Main]
|
||||
# skin file name
|
||||
Skin=orqua.skn
|
||||
|
||||
# first font must be 9*0x100 bytes, second 10*0x100 bytes
|
||||
Font1=char.mt
|
||||
Font2=char2.mt
|
||||
|
||||
# DO NOT MODIFY THIS PARAMETER UNLESS YOU KNOW WHAT ARE YOU DOING!!!
|
||||
# if this parameter is not empty,
|
||||
# on NT/2k/XP+ administrator rights are required
|
||||
# enables i/o ports for function 46
|
||||
# all ports from this parameter can be reserved with fn46,
|
||||
# and (after reservation) may be accessed via in/out.
|
||||
# DO NOT ADD SYSTEM CRITICAL PORTS!!!
|
||||
# USE THIS PARAMETER ONLY AT YOUR OWN RISK!!!
|
||||
# note that Menuet/Kolibri reserves ports 0-FF for system use
|
||||
# syntax: EnablePorts=port1 port2beg-port2end port3 ...
|
||||
# (when range is used, both begin and end are included)
|
||||
# example (only for syntax demonstration!!!): EnablePorts=A3 B1 92-9f 70-74 269
|
||||
# total length of parameter string is limited to 1024 chars (must be enough :) )
|
||||
EnablePorts=
|
||||
|
||||
# boolean parameters (true/false)
|
||||
# if at least one of these parameters is true,
|
||||
# on NT/2k/XP+ administrator rights are required
|
||||
|
||||
# enables function 68.3
|
||||
AllowReadMSR=false
|
||||
# enables function 62
|
||||
AllowReadPCI=false
|
||||
|
||||
# do not unload driver when exiting
|
||||
KeepLoadedDriver=false
|
||||
|
||||
[Questions]
|
||||
# on set background question
|
||||
# 0=ask, 1=set permanently, 2=set temporarily, 3=don't set
|
||||
SetBgr=0
|
||||
|
||||
[sys_setup]
|
||||
# kernel global variable sound_flag
|
||||
# 0=playnote sound on, 1=off (it is for 55::55 function only)
|
||||
sound_flag=0
|
||||
# 0=min (no sound), 127=max
|
||||
sound_vol=10
|
||||
|
||||
# kernel global variable syslang (see functions 21::5, 26::5)
|
||||
# 1=eng 2=fi 3=ger 4=ru
|
||||
syslang=1
|
||||
|
||||
# kernel global variable keyboard (see functions 21::2::9, 26::2::9)
|
||||
# 1=eng 2=fi 3=ger 4=ru
|
||||
# Note that this definition doesn't affect keymap tables,
|
||||
# it only sets variable for functions above
|
||||
# (in Kolibri application @panel/setup changes keymap tables)
|
||||
keyboard=1
|
||||
|
||||
[DirectScreenAccess]
|
||||
# bits per pixel, currently supported 0 (=disable), 24, 32
|
||||
ColorDepth=32
|
||||
# When the program first accesses [gs:N] data, the snapshot is created.
|
||||
# Other accesses within InvalidateTime milliseconds use this snapshot.
|
||||
DSAInvalidateTime=200
|
21
programs/emulator/KlbrInWin/config_resource.inc
Normal file
21
programs/emulator/KlbrInWin/config_resource.inc
Normal file
@ -0,0 +1,21 @@
|
||||
IDD_DIALOG1 = 101
|
||||
IDI_ICON1 = 103
|
||||
IDC_RAMDISK = 1001
|
||||
IDC_RAMDISK_BROWSE = 1002
|
||||
IDC_PARTITION = 1003
|
||||
IDC_HD_DEV = 1004
|
||||
IDC_HD_PART = 1005
|
||||
IDC_ADD_PARTITION = 1006
|
||||
IDC_DEL_PARTITION = 1007
|
||||
IDC_PARTITION_BROWSE = 1008
|
||||
IDC_CHECK1 = 1009
|
||||
IDC_SKIN = 1010
|
||||
IDC_SKIN_BROWSE = 1011
|
||||
IDC_FONT1 = 1012
|
||||
IDC_FONT1_BROWSE = 1013
|
||||
IDC_FONT2 = 1014
|
||||
IDC_FONT2_BROWSE = 1015
|
||||
IDC_EMPTY_EXT = 1016
|
||||
IDC_NOTEMPTY_EXT = 1017
|
||||
IDC_EXTENSIONS = 1018
|
||||
IDC_PATH_STRING = 1019
|
238
programs/emulator/KlbrInWin/kiw0.asm
Normal file
238
programs/emulator/KlbrInWin/kiw0.asm
Normal file
@ -0,0 +1,238 @@
|
||||
; kiw0.sys - KlbrInWin ring-0 component
|
||||
; (c) diamond, 2006, 2007, 2008
|
||||
; Cb-n#%li.-# @l$i Lkbnbe
|
||||
DRIVER_VERSION = 1
|
||||
format PE native
|
||||
section '.text' code data readable writable executable
|
||||
;section '.text' code readable executable
|
||||
entry start
|
||||
start:
|
||||
push eax
|
||||
push esp
|
||||
push 0
|
||||
push 0
|
||||
push 22h ; FILE_DEVICE_UNKNOWN
|
||||
push devname
|
||||
push 0
|
||||
push dword [esp+20h]
|
||||
call [IoCreateDevice]
|
||||
pop ecx
|
||||
test eax, eax
|
||||
js .ret
|
||||
push ecx
|
||||
push devname
|
||||
push symlinkname
|
||||
call [IoCreateSymbolicLink]
|
||||
pop ecx
|
||||
test eax, eax
|
||||
jns @f
|
||||
push eax
|
||||
push ecx
|
||||
call [IoDeleteDevice]
|
||||
pop eax
|
||||
jmp .ret
|
||||
@@:
|
||||
mov eax, [esp+4]
|
||||
mov dword [eax+38h], DispatchCreateClose
|
||||
mov dword [eax+40h], DispatchCreateClose
|
||||
mov dword [eax+70h], DispatchControl
|
||||
mov dword [eax+34h], DriverUnload
|
||||
push 'kiw0'
|
||||
push 2000h
|
||||
push 0
|
||||
call [ExAllocatePoolWithTag]
|
||||
mov [oldiomap], eax
|
||||
push eax
|
||||
push 1
|
||||
call [Ke386QueryIoAccessMap]
|
||||
xor eax, eax
|
||||
.ret:
|
||||
ret 8
|
||||
|
||||
DriverUnload:
|
||||
push symlinkname
|
||||
call [IoDeleteSymbolicLink]
|
||||
mov eax, [esp+4]
|
||||
push dword [eax+4]
|
||||
call [IoDeleteDevice]
|
||||
push [oldiomap]
|
||||
push 1
|
||||
call [Ke386SetIoAccessMap]
|
||||
push [oldiomap]
|
||||
call [ExFreePool]
|
||||
ret 4
|
||||
|
||||
DispatchCreateClose:
|
||||
mov ecx, [esp+8]
|
||||
xor edx, edx
|
||||
mov [ecx+18h], edx
|
||||
mov [ecx+1Ch], edx
|
||||
call [IofCompleteRequest]
|
||||
xor eax, eax
|
||||
ret 8
|
||||
|
||||
DispatchControl:
|
||||
mov ecx, [esp+8]
|
||||
mov eax, [ecx+60h]
|
||||
cmp dword [eax+0Ch], 0x222000
|
||||
jz .readmsr
|
||||
cmp dword [eax+0Ch], 0x222004
|
||||
jz .readpci
|
||||
cmp dword [eax+0Ch], 0x222008
|
||||
jz .getversion
|
||||
cmp dword [eax+0Ch], 0x22203C
|
||||
jnz .invreq
|
||||
cmp dword [eax+8], 2000h
|
||||
jnz .invreq
|
||||
push ecx
|
||||
push dword [ecx+0Ch]
|
||||
push 1
|
||||
call [Ke386SetIoAccessMap]
|
||||
push 1
|
||||
call [IoGetCurrentProcess]
|
||||
push eax
|
||||
call [Ke386IoSetAccessProcess]
|
||||
str ax
|
||||
sub esp, 6
|
||||
sgdt [esp]
|
||||
pop cx
|
||||
pop ecx
|
||||
movzx eax, ax
|
||||
mov dh, [eax+ecx+7]
|
||||
mov dl, [eax+ecx+4]
|
||||
shl edx, 16
|
||||
mov dx, [eax+ecx+2]
|
||||
mov word [edx+66h], 88h
|
||||
pop ecx
|
||||
xor eax, eax
|
||||
mov [ecx+1Ch], eax
|
||||
jmp .ret
|
||||
.getversion:
|
||||
cmp dword [eax+4], 4
|
||||
jnz .invreq
|
||||
mov eax, [ecx+0Ch]
|
||||
mov dword [eax], DRIVER_VERSION
|
||||
mov dword [ecx+1Ch], 4
|
||||
jmp .ret0
|
||||
.readmsr:
|
||||
cmp dword [eax+8], 4
|
||||
jnz .invreq
|
||||
cmp dword [eax+4], 9
|
||||
jnz .invreq
|
||||
push ecx
|
||||
mov ecx, [ecx+0Ch]
|
||||
mov byte [ecx+8], 0 ; assume OK
|
||||
; rdmsr may throw exception
|
||||
push .exception_handler
|
||||
push dword [fs:0]
|
||||
mov [fs:0], esp
|
||||
push ecx
|
||||
mov ecx, [ecx]
|
||||
rdmsr
|
||||
pop ecx
|
||||
mov [ecx], eax
|
||||
mov [ecx+4], edx
|
||||
.msr_common:
|
||||
pop dword [fs:0]
|
||||
pop ecx
|
||||
pop ecx
|
||||
mov dword [ecx+1Ch], 9
|
||||
.ret0:
|
||||
xor eax, eax
|
||||
jmp .ret
|
||||
.invreq2:
|
||||
pop ecx
|
||||
.invreq:
|
||||
mov eax, 0xC0000010 ; STATUS_INVALID_DEVICE_REQUEST
|
||||
.ret:
|
||||
push eax
|
||||
mov [ecx+18h], eax
|
||||
xor edx, edx
|
||||
call [IofCompleteRequest]
|
||||
pop eax
|
||||
ret 8
|
||||
.exception_handler:
|
||||
mov eax, [esp+12]
|
||||
mov dword [eax+0xB8], .no_msr
|
||||
xor eax, eax
|
||||
ret
|
||||
.no_msr:
|
||||
pop ecx
|
||||
mov byte [ecx+8], 1
|
||||
jmp .msr_common
|
||||
.readpci:
|
||||
cmp dword [eax+8], 4
|
||||
jnz .invreq
|
||||
cmp dword [eax+4], 4
|
||||
jnz .invreq
|
||||
push ecx
|
||||
mov ecx, [ecx+0Ch]
|
||||
movzx eax, byte [ecx]
|
||||
cmp al, 2
|
||||
ja .invreq2
|
||||
jb @f
|
||||
inc eax
|
||||
@@:
|
||||
test byte [ecx+2], al
|
||||
jnz .readpci.unaligned
|
||||
inc eax
|
||||
push eax
|
||||
push eax ; Length
|
||||
movzx eax, byte [ecx+2]
|
||||
push eax ; Offset
|
||||
push ecx ; Buffer
|
||||
movzx eax, byte [ecx+3]
|
||||
ror al, 3
|
||||
push eax ; SlotNumber
|
||||
movzx eax, byte [ecx+1]
|
||||
push eax ; BusNumber
|
||||
push 4 ; PCIConfiguration
|
||||
or dword [ecx], -1
|
||||
call [HalGetBusDataByOffset]
|
||||
pop edx
|
||||
pop ecx
|
||||
mov dword [ecx+1Ch], edx
|
||||
jmp .ret0
|
||||
.readpci.unaligned:
|
||||
or dword [ecx], -1
|
||||
pop ecx
|
||||
mov dword [ecx+1Ch], 4
|
||||
jmp .ret0
|
||||
|
||||
include 'd:\program files\fasm\fasmw16723\include\win32a.inc'
|
||||
data import
|
||||
library ntoskrnl,'ntoskrnl.exe',hal,'hal.dll'
|
||||
import ntoskrnl, \
|
||||
IoCreateDevice, 'IoCreateDevice', \
|
||||
IoCreateSymbolicLink, 'IoCreateSymbolicLink', \
|
||||
IoDeleteDevice, 'IoDeleteDevice', \
|
||||
IoDeleteSymbolicLink, 'IoDeleteSymbolicLink', \
|
||||
IoGetCurrentProcess, 'IoGetCurrentProcess', \
|
||||
Ke386QueryIoAccessMap, 'Ke386QueryIoAccessMap', \
|
||||
Ke386SetIoAccessMap, 'Ke386SetIoAccessMap', \
|
||||
Ke386IoSetAccessProcess, 'Ke386IoSetAccessProcess', \
|
||||
IofCompleteRequest, 'IofCompleteRequest', \
|
||||
ExAllocatePoolWithTag, 'ExAllocatePoolWithTag', \
|
||||
ExFreePool, 'ExFreePool'
|
||||
import hal, HalGetBusDataByOffset, 'HalGetBusDataByOffset'
|
||||
end data
|
||||
|
||||
str1 db 'control code 0x%X',13,10,0
|
||||
str2 db 'kiw0 loaded',13,10,0
|
||||
|
||||
devname:
|
||||
dw 12*2
|
||||
dw 13*2
|
||||
dd @f
|
||||
@@ du '\Device\kiw0',0
|
||||
symlinkname:
|
||||
dw 16*2
|
||||
dw 17*2
|
||||
dd @f
|
||||
@@ du '\DosDevices\kiw0',0
|
||||
|
||||
data fixups
|
||||
end data
|
||||
|
||||
;section '.data' data readable writable
|
||||
oldiomap dd ?
|
492
programs/emulator/KlbrInWin/unpacker.inc
Normal file
492
programs/emulator/KlbrInWin/unpacker.inc
Normal file
@ -0,0 +1,492 @@
|
||||
; void __stdcall unpack(void* packed_data, void* unpacked_data);
|
||||
unpack:
|
||||
pushad
|
||||
mov esi, [esp+32+4]
|
||||
mov edi, [esp+32+8]
|
||||
mov eax, [esi+8]
|
||||
and al, 0xC0
|
||||
cmp al, 0xC0
|
||||
jz .failed
|
||||
mov eax, [esi+8]
|
||||
push eax
|
||||
add esi, 12
|
||||
and al, not 0xC0
|
||||
dec eax
|
||||
jz .lzma
|
||||
.failed:
|
||||
pop eax
|
||||
popad
|
||||
ret 8
|
||||
.lzma:
|
||||
call .lzma_unpack
|
||||
.common:
|
||||
pop eax
|
||||
test al, 0x80
|
||||
jnz .ctr1
|
||||
test al, 0x40
|
||||
jz .ok
|
||||
lodsd
|
||||
mov ecx, eax
|
||||
jecxz .ok
|
||||
mov dl, [esi]
|
||||
mov esi, [esp+32+8]
|
||||
.c1:
|
||||
lodsb
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .c1
|
||||
cmp byte [esi], dl
|
||||
jnz .c1
|
||||
lodsd
|
||||
; "bswap eax" is not supported on i386
|
||||
shr ax, 8
|
||||
ror eax, 16
|
||||
xchg al, ah
|
||||
sub eax, esi
|
||||
add eax, [esp+32+8]
|
||||
mov [esi-4], eax
|
||||
loop .c1
|
||||
.ok:
|
||||
popad
|
||||
ret 8
|
||||
.ctr1:
|
||||
lodsd
|
||||
mov ecx, eax
|
||||
jecxz .ok
|
||||
mov dl, [esi]
|
||||
mov esi, [esp+32+8]
|
||||
.c2:
|
||||
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 .c2
|
||||
@@:
|
||||
cmp byte [esi], dl
|
||||
jnz .c2
|
||||
lodsd
|
||||
shr ax, 8
|
||||
ror eax, 16
|
||||
xchg al, ah
|
||||
sub eax, esi
|
||||
add eax, [esp+32+8]
|
||||
mov [esi-4], eax
|
||||
loop .c2
|
||||
jmp .ok
|
||||
|
||||
.lzma_unpack:
|
||||
|
||||
.pb = 2 ; pos state bits
|
||||
.lp = 0 ; literal pos state bits
|
||||
.lc = 3 ; literal context bits
|
||||
.posStateMask = ((1 shl .pb)-1)
|
||||
.literalPosMask = ((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 = (.IsMatch + (.kNumStates shl .kNumPosBitsMax))
|
||||
.IsRepG0 = (.IsRep + .kNumStates)
|
||||
.IsRepG1 = (.IsRepG0 + .kNumStates)
|
||||
.IsRepG2 = (.IsRepG1 + .kNumStates)
|
||||
.IsRep0Long = (.IsRepG2 + .kNumStates)
|
||||
.PosSlot = (.IsRep0Long + (.kNumStates shl .kNumPosBitsMax))
|
||||
.SpecPos = (.PosSlot + (.kNumLenToPosStates shl .kNumPosSlotBits))
|
||||
.Align_ = (.SpecPos + .kNumFullDistances - .kEndPosModelIndex)
|
||||
.Lencoder = (.Align_ + .kAlignTableSize)
|
||||
.RepLencoder = (.Lencoder + .kNumLenProbs)
|
||||
.Literal = (.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
|
||||
|
||||
push edi
|
||||
; int state=0;
|
||||
xor ebx, ebx
|
||||
mov [.previousByte], bl
|
||||
; unsigned rep0=1,rep1=1,rep2=1,rep3=1;
|
||||
mov eax, 1
|
||||
mov edi, .rep0
|
||||
stosd
|
||||
stosd
|
||||
stosd
|
||||
stosd
|
||||
; int len=0;
|
||||
; result=0;
|
||||
mov ecx, .Literal + (.LZMA_LIT_SIZE shl (.lc+.lp))
|
||||
mov eax, .kBitModelTotal/2
|
||||
mov edi, .p
|
||||
rep stosd
|
||||
; RangeDecoderInit
|
||||
; rd->ExtraBytes = 0
|
||||
; rd->Buffer = stream
|
||||
; rd->BufferLim = stream+bufferSize
|
||||
; rd->Range = 0xFFFFFFFF
|
||||
pop edi
|
||||
mov ebp, [esi-8] ; dest_length
|
||||
add ebp, edi ; ebp = destination limit
|
||||
lodsd
|
||||
; rd->code_ = eax
|
||||
mov [.code_], eax
|
||||
or [.range], -1
|
||||
.main_loop:
|
||||
cmp edi, ebp
|
||||
jae .main_loop_done
|
||||
mov edx, edi
|
||||
and edx, .posStateMask
|
||||
mov eax, ebx
|
||||
shl eax, .kNumPosBitsMax+2
|
||||
lea eax, [.p + .IsMatch*4 + eax + edx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
jc .1
|
||||
movzx eax, [.previousByte]
|
||||
if .literalPosMask
|
||||
mov ah, dl
|
||||
and ah, .literalPosMask
|
||||
end if
|
||||
shr eax, 8-.lc
|
||||
imul eax, .LZMA_LIT_SIZE*4
|
||||
add eax, .p+.Literal*4
|
||||
cmp ebx, .kNumLitStates
|
||||
jb .literal
|
||||
xor edx, edx
|
||||
sub edx, [.rep0]
|
||||
mov dl, [edi + edx]
|
||||
call .LzmaLiteralDecodeMatch
|
||||
jmp @f
|
||||
.literal:
|
||||
call .LzmaLiteralDecode
|
||||
@@:
|
||||
mov [.previousByte], al
|
||||
stosb
|
||||
mov al, bl
|
||||
cmp bl, 4
|
||||
jb @f
|
||||
mov al, 3
|
||||
cmp bl, 10
|
||||
jb @f
|
||||
mov al, 6
|
||||
@@: sub bl, al
|
||||
jmp .main_loop
|
||||
.1:
|
||||
lea eax, [.p + .IsRep*4 + ebx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
jnc .10
|
||||
lea eax, [.p + .IsRepG0*4 + ebx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
jc .111
|
||||
mov eax, ebx
|
||||
shl eax, .kNumPosBitsMax+2
|
||||
lea eax, [.p + .IsRep0Long*4 + eax + edx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
jc .1101
|
||||
cmp bl, 7
|
||||
setae bl
|
||||
lea ebx, [9 + ebx + ebx]
|
||||
xor edx, edx
|
||||
sub edx, [.rep0]
|
||||
mov al, [edi + edx]
|
||||
stosb
|
||||
mov [.previousByte], al
|
||||
jmp .main_loop
|
||||
.111:
|
||||
lea eax, [.p + .IsRepG1*4 + ebx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
mov eax, [.rep1]
|
||||
jnc .l3
|
||||
.l1:
|
||||
lea eax, [.p + .IsRepG2*4 + ebx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
mov eax, [.rep2]
|
||||
jnc .l2
|
||||
xchg [.rep3], eax
|
||||
.l2:
|
||||
push [.rep1]
|
||||
pop [.rep2]
|
||||
.l3:
|
||||
xchg eax, [.rep0]
|
||||
mov [.rep1], eax
|
||||
.1101:
|
||||
mov eax, .p + .RepLencoder*4
|
||||
call .LzmaLenDecode
|
||||
cmp bl, 7
|
||||
setc bl
|
||||
adc bl, bl
|
||||
xor bl, 3
|
||||
add bl, 8
|
||||
jmp .repmovsb
|
||||
.10:
|
||||
mov eax, [.rep0]
|
||||
xchg eax, [.rep1]
|
||||
xchg eax, [.rep2]
|
||||
xchg eax, [.rep3]
|
||||
cmp bl, 7
|
||||
setc bl
|
||||
adc bl, bl
|
||||
xor bl, 3
|
||||
add bl, 7
|
||||
mov eax, .p + .Lencoder*4
|
||||
call .LzmaLenDecode
|
||||
mov eax, .kNumLenToPosStates-1
|
||||
cmp eax, ecx
|
||||
jb @f
|
||||
mov eax, ecx
|
||||
@@:
|
||||
push ecx
|
||||
mov ecx, .kNumPosSlotBits
|
||||
shl eax, cl
|
||||
shl eax, 2
|
||||
add eax, .p+.PosSlot*4
|
||||
call .RangeDecoderBitTreeDecode
|
||||
mov [.rep0], ecx
|
||||
cmp ecx, .kStartPosModelIndex
|
||||
jb .l6
|
||||
push ecx
|
||||
mov eax, ecx
|
||||
and eax, 1
|
||||
shr ecx, 1
|
||||
or eax, 2
|
||||
dec ecx
|
||||
shl eax, cl
|
||||
mov [.rep0], eax
|
||||
pop edx
|
||||
cmp edx, .kEndPosModelIndex
|
||||
jae .l5
|
||||
sub eax, edx
|
||||
shl eax, 2
|
||||
add eax, .p + (.SpecPos - 1)*4
|
||||
call .RangeDecoderReverseBitTreeDecode
|
||||
add [.rep0], ecx
|
||||
jmp .l6
|
||||
.l5:
|
||||
sub ecx, .kNumAlignBits
|
||||
call .RangeDecoderDecodeDirectBits
|
||||
mov ecx, .kNumAlignBits
|
||||
shl eax, cl
|
||||
add [.rep0], eax
|
||||
mov eax, .p+.Align_*4
|
||||
call .RangeDecoderReverseBitTreeDecode
|
||||
add [.rep0], ecx
|
||||
.l6:
|
||||
pop ecx
|
||||
inc [.rep0]
|
||||
jz .main_loop_done
|
||||
.repmovsb:
|
||||
add ecx, .kMatchMinLen
|
||||
push esi
|
||||
mov esi, edi
|
||||
sub esi, [.rep0]
|
||||
rep movsb
|
||||
pop esi
|
||||
mov al, [edi-1]
|
||||
mov [.previousByte], al
|
||||
jmp .main_loop
|
||||
.main_loop_done:
|
||||
ret
|
||||
|
||||
.RangeDecoderBitDecode:
|
||||
; in: eax->prob
|
||||
; out: CF=bit; destroys eax
|
||||
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
|
||||
clc
|
||||
.n:
|
||||
lahf
|
||||
cmp [.range], .kTopValue
|
||||
jae @f
|
||||
shl [.range], 8
|
||||
shl [.code_], 8
|
||||
lodsb
|
||||
mov byte [.code_], al
|
||||
@@:
|
||||
sahf
|
||||
pop edx
|
||||
ret
|
||||
.ae:
|
||||
sub [.range], edx
|
||||
sub [.code_], edx
|
||||
mov edx, [eax]
|
||||
shr edx, .kNumMoveBits
|
||||
sub [eax], edx
|
||||
stc
|
||||
jmp .n
|
||||
|
||||
.RangeDecoderDecodeDirectBits:
|
||||
; in: ecx=numTotalBits
|
||||
; out: eax=result; destroys edx
|
||||
xor eax, eax
|
||||
.l:
|
||||
shr [.range], 1
|
||||
shl eax, 1
|
||||
mov edx, [.code_]
|
||||
sub edx, [.range]
|
||||
jb @f
|
||||
mov [.code_], edx
|
||||
or eax, 1
|
||||
@@:
|
||||
cmp [.range], .kTopValue
|
||||
jae @f
|
||||
shl [.range], 8
|
||||
shl [.code_], 8
|
||||
push eax
|
||||
lodsb
|
||||
mov byte [.code_], al
|
||||
pop eax
|
||||
@@:
|
||||
loop .l
|
||||
ret
|
||||
|
||||
.LzmaLiteralDecode:
|
||||
; in: eax->probs
|
||||
; out: al=byte; destroys edx
|
||||
push ecx
|
||||
mov ecx, 1
|
||||
@@:
|
||||
push eax
|
||||
lea eax, [eax+ecx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
pop eax
|
||||
adc cl, cl
|
||||
jnc @b
|
||||
.LzmaLiteralDecode.ret:
|
||||
mov al, cl
|
||||
pop ecx
|
||||
ret
|
||||
.LzmaLiteralDecodeMatch:
|
||||
; in: eax->probs, dl=matchByte
|
||||
; out: al=byte; destroys edx
|
||||
push ecx
|
||||
mov ecx, 1
|
||||
.LzmaLiteralDecodeMatch.1:
|
||||
add dl, dl
|
||||
setc ch
|
||||
push eax
|
||||
lea eax, [eax+ecx*4+0x100*4]
|
||||
call .RangeDecoderBitDecode
|
||||
pop eax
|
||||
adc cl, cl
|
||||
jc .LzmaLiteralDecode.ret
|
||||
xor ch, cl
|
||||
test ch, 1
|
||||
mov ch, 0
|
||||
jnz @b
|
||||
jmp .LzmaLiteralDecodeMatch.1
|
||||
|
||||
.LzmaLenDecode:
|
||||
; in: eax->prob, edx=posState
|
||||
; out: ecx=len
|
||||
push eax
|
||||
add eax, .LenChoice*4
|
||||
call .RangeDecoderBitDecode
|
||||
pop eax
|
||||
jnc .0
|
||||
push eax
|
||||
add eax, .LenChoice2*4
|
||||
call .RangeDecoderBitDecode
|
||||
pop eax
|
||||
jc @f
|
||||
mov ecx, .kLenNumMidBits
|
||||
shl edx, cl
|
||||
lea eax, [eax + .LenMid*4 + edx*4]
|
||||
call .RangeDecoderBitTreeDecode
|
||||
add ecx, .kLenNumLowSymbols
|
||||
ret
|
||||
@@:
|
||||
add eax, .LenHigh*4
|
||||
mov ecx, .kLenNumHighBits
|
||||
call .RangeDecoderBitTreeDecode
|
||||
add ecx, .kLenNumLowSymbols + .kLenNumMidSymbols
|
||||
ret
|
||||
.0:
|
||||
mov ecx, .kLenNumLowBits
|
||||
shl edx, cl
|
||||
lea eax, [eax + .LenLow*4 + edx*4]
|
||||
.RangeDecoderBitTreeDecode:
|
||||
; in: eax->probs,ecx=numLevels
|
||||
; out: ecx=length; destroys edx
|
||||
push ebx
|
||||
mov edx, 1
|
||||
mov ebx, edx
|
||||
@@:
|
||||
push eax
|
||||
lea eax, [eax+edx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
pop eax
|
||||
adc dl, dl
|
||||
add bl, bl
|
||||
loop @b
|
||||
sub dl, bl
|
||||
pop ebx
|
||||
mov ecx, edx
|
||||
ret
|
||||
.RangeDecoderReverseBitTreeDecode:
|
||||
; in: eax->probs,ecx=numLevels
|
||||
; out: ecx=length; destroys edx
|
||||
push ebx ecx
|
||||
mov edx, 1
|
||||
xor ebx, ebx
|
||||
@@:
|
||||
push eax
|
||||
lea eax, [eax+edx*4]
|
||||
call .RangeDecoderBitDecode
|
||||
lahf
|
||||
adc edx, edx
|
||||
sahf
|
||||
rcr ebx, 1
|
||||
pop eax
|
||||
loop @b
|
||||
pop ecx
|
||||
rol ebx, cl
|
||||
mov ecx, ebx
|
||||
pop ebx
|
||||
ret
|
Loading…
Reference in New Issue
Block a user