Wing Commander II
Reconstructed Win32 source (1996)
Toggle main menu visibility
Loading...
Searching...
No Matches
lzo1x.cpp
Go to the documentation of this file.
1
/*
2
* LZO1X decoder used by the packed ix streamer.
3
*
4
* The retail routine is hand-written x86: it keeps input/token state in EBX
5
* and EDX and performs overlapping copies with REP MOVS. It was an /Od
6
* function around an __asm block; its ALIGN 4 directives account for the
7
* padding inside it. The bytes are identical to WC1's decoder. Preserve
8
* that code directly so packed stream chunks decode exactly as they did
9
* originally.
10
*/
11
#include "
ix.h
"
12
#include <stdlib.h>
13
#include <string.h>
14
15
/* Function start: 0x48C290 */
16
extern
"C"
void
ix_lzo1x_decompress
(
17
unsigned
char
*source,
unsigned
char
*destination,
18
unsigned
int
destinationBytes)
19
{
20
__asm {
21
mov ebx, source
22
mov edi, destination
23
or ebx, ebx
24
je lzo_finish_copy
25
xor ecx, ecx
26
jmp lzo_read_token
27
ALIGN 4
28
29
lzo_copy_literals:
30
lea esi, [ebx + 2]
31
rep movsb
32
mov ebx, esi
33
mov ch, dl
34
mov cl, dh
35
and edx, 1ch
36
shr ch, 5
37
shr edx, 2
38
neg ecx
39
lea esi, [edi + ecx - 1]
40
lea ecx, [edx + 3]
41
rep movsb
42
or cl,
byte
ptr [ebx]
43
mov edx, dword ptr [ebx]
44
js lzo_large_token
45
46
lzo_match_tail:
47
and ecx, 3
48
jne lzo_copy_literals
49
lea ebx, [ebx + 2]
50
mov ch, dl
51
mov cl, dh
52
and edx, 1ch
53
shr ch, 5
54
shr edx, 2
55
neg ecx
56
lea esi, [edi + ecx - 1]
57
lea ecx, [edx + 3]
58
rep movsb
59
60
lzo_read_token:
61
or cl,
byte
ptr [ebx]
62
mov edx, dword ptr [ebx]
63
jns lzo_match_tail
64
65
lzo_large_token:
66
add cl, cl
67
js lzo_literal_token
68
mov cl, dh
69
lea esi, [ebx + 3]
70
shr ecx, 6
71
and ecx, 3
72
rep movsb
73
mov ebx, esi
74
mov ecx, edx
75
shr ecx, 10h
76
mov ch, dh
77
and ch, 3fh
78
neg ecx
79
lea esi, [edi + ecx - 1]
80
and edx, 3fh
81
lea ecx, [edx + 4]
82
rep movsb
83
or cl,
byte
ptr [ebx]
84
mov edx, dword ptr [ebx]
85
jns lzo_match_tail
86
jmp lzo_large_token
87
ALIGN 4
88
89
lzo_literal_token:
90
add cl, cl
91
jns lzo_long_match
92
cmp dl, 0fch
93
jae lzo_final_literals
94
and edx, 1fh
95
lea esi, [ebx + 1]
96
lea ecx, [edx + 1]
97
rep movsd
98
mov ebx, esi
99
or cl,
byte
ptr [esi]
100
mov edx, dword ptr [esi]
101
jns lzo_match_tail
102
jmp lzo_large_token
103
ALIGN 4
104
105
lzo_final_literals:
106
mov ecx, edx
107
lea esi, [ebx + 1]
108
and ecx, 3
109
rep movsb
110
111
lzo_finish_copy:
112
jmp lzo_finish
113
ALIGN 4
114
115
lzo_long_match:
116
mov ecx, edx
117
lea esi, [ebx + 4]
118
and ecx, 3
119
rep movsb
120
mov ebx, esi
121
mov ecx, edx
122
mov eax, edx
123
and ecx, 10h
124
shr eax, 8
125
shl ecx, 0ch
126
mov cl, ah
127
mov ch, al
128
neg ecx
129
lea esi, [edi + ecx - 1]
130
rol edx, 8
131
shr dh, 2
132
and edx, 3ffh
133
cmp ecx, -4
134
jge lzo_short_long_match
135
lea ecx, [edx + 5]
136
lea edx, [edx + 5]
137
shr ecx, 2
138
and edx, 3
139
rep movsd
140
mov ecx, edx
141
rep movsb
142
or cl,
byte
ptr [ebx]
143
mov edx, dword ptr [ebx]
144
jns lzo_match_tail
145
jmp lzo_large_token
146
ALIGN 4
147
148
lzo_short_long_match:
149
lea ecx, [edx + 5]
150
rep movsb
151
or cl,
byte
ptr [ebx]
152
mov edx, dword ptr [ebx]
153
jns lzo_match_tail
154
jmp lzo_large_token
155
156
lzo_finish:
157
}
158
}
ix.h
Audio classes, DirectSound interfaces and shared ix state.
ix_lzo1x_decompress
void ix_lzo1x_decompress(unsigned char *source, unsigned char *destination, unsigned int destinationBytes)
Definition
lzo1x.cpp:16
src
ix
lzo1x.cpp
Generated by
1.18.0