1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
.align 4
.text
.globl DecodeBlockAsm
/*
;Bit-Rate Expand Waveform
;
;Desc:
; Decompresses a 9-byte bit-rate reduced block into 16 16-bit samples.
; This procedure is designed to be recursively called to decompress a series of blocks.
;In:
; R0=ESI-> Sample Block
; R1=EDI -> Output buffer
; R2=EDX =3D Last sample of previous block (32-bit)
; R3=EBX =3D Next to last sample (sign extended from 16-bits)
;Out:
; R0=ESI -> Next Block
; R1=EDI -> After last sample
; R2=EDX =3D Last sample (32-bit)
; R3=EBX =3D Next to last sample (16-bit)
;Destroys:
; R4=EAX
*/
@ void DecodeBlockAsm2 (int8 *, int16 *, int32 *, int32 *);
@ DecodeBlockAsm2 (compressed, raw, &ch->previous [0], &ch->previous [1]);
.align 4
DecodeBlockAsm:
stmfd sp!, {r2, r3, r4, r5, r6, r7}
LDRB R4,[R0],#1
LDR R2,[R2]
LDR R3,[R3]
CMP R4,#0xD0
MOVHS R5,#0
rsblo r5, r4, #0xcf
MOVLO R5,R5,LSR #4
MOV R6,#8
TST R4,#0xC
BEQ Method0
TST R4,#0x8
BEQ Method1
TST R4,#0x4
BEQ Method2
B Method3 @ ;Must use method 3
/*
ALIGN 16
;[Smp] ----------------------------------*/
Method0:
ADD R5,R5,#16
.macro MMethod0
.endm
Method0loop:
@ two in a go
LDRB R4,[R0],#1
ldrb r7,[r0],#1
MOV R2,R4,LSL #(28)
MOV R4,R4,LSL #(24)
BIC R4,R4,#0x0F000000
MOV R4,R4,ASR R5
MOV R2,R2,ASR R5
STRH R4,[R1],#2
STRH R2,[R1],#2
@SUBS R6,R6,#1
@beq Exit0
@LDRB R4,[R0],#1
MOV R2,R7,LSL #(28)
MOV R4,R7,LSL #(24)
BIC R4,R4,#0x0F000000
MOV R4,R4,ASR R5
MOV R2,R2,ASR R5
STRH R4,[R1],#2
STRH R2,[R1],#2
@SUBS R6,R6,#1
subs r6, r6, #2
BNE Method0loop
mov r3, r4
ldmfd sp!, {r0, r1, r4, r5, r6, r7}
STR R2,[R0]
STR R3,[R1]
bx lr
@ ALIGN 16
@ ;[Delta]+[Smp-1](15/16) -----------------
Method1:
ADD R7,R5,#16
Method1loop:
LDRSB R3,[R0]
BIC R3,R3,#0xF
MOV R3,R3,LSL #8
MOV R3,R3,ASR R5
MOV R4,R2,LSL #16
ADD R3,R3,R4,ASR #16
SUB R3,R3,R4,ASR #20
STRH R3,[R1],#2
LDRSB R2,[R0],#1
MOV R2,R2,LSL #(12+16)
MOV R2,R2,ASR R7
MOV R4,R3,LSL #16
ADD R2,R2,R4,ASR #16
SUB R2,R2,R4,ASR #20
STRH R2,[R1],#2
SUBS R6,R6,#1
BNE Method1loop
MOV R3,R3,LSL #16
MOV R3,R3,ASR #16
ldmfd sp!, {r0, r1, r4, r5, r6, r7}
STR R2,[R0]
STR R3,[R1]
bx lr
@ ;[Delta]+[Smp-1](61/32)-[Smp-2](30/32) --
Method2:
ADD R7,R5,#16
Method2loop:
LDRSB R4,[R0], #1
mov r12, r4
BIC R4,R4,#0xF
MOV R4,R4,LSL #8
MOV R4,R4,ASR R5
SUB R4,R4,R3
ADD R4,R4,R3,ASR #4
MOV R3,R2
BIC R2,R2,#3
ADD R4,R4,R2,LSL #1
SUB R4,R4,R2,ASR #4
SUB R4,R4,R2,ASR #5
STRH R4,[R1],#2
MOV R2,R12,LSL #(12+16)
MOV R2,R2,ASR R7
SUB R2,R2,R3
ADD R2,R2,R3,ASR #4
MOV R3,R4
BIC R4,R4,#3
ADD R2,R2,R4,LSL #1
SUB R2,R2,R4,ASR #4
SUB R2,R2,R4,ASR #5
STRH R2,[R1],#2
SUBS R6,R6,#1
BNE Method2loop
ldmfd sp!, {r0, r1, r4, r5, r6, r7}
STR R2,[R0]
STR R3,[R1]
bx lr
Method3:
ADD R7,R5,#16
Method3loop:
LDRSB R4,[R0], #1
mov r12, r4
BIC R4,R4,#0xF
MOV R4,R4,LSL #8
MOV R4,R4,ASR R5
@ ;Subtract 13/16 of second sample -----
SUB R4,R4,R3
ADD R4,R4,R3,ASR #3
ADD R4,R4,R3,ASR #4
MOV R3,R2
@ ;Add 115/64 of last sample -----------
BIC R2,R2,#3
ADD R4,R4,R2,LSL #1
SUB R4,R4,R2,ASR #3
SUB R4,R4,R2,ASR #4
SUB R4,R4,R2,ASR #6
STRH R4,[R1],#2
MOV R2,R12,LSL #(12+16)
MOV R2,R2,ASR R7
SUB R2,R2,R3
ADD R2,R2,R3,ASR #3
ADD R2,R2,R3,ASR #4
MOV R3,R4
BIC R4,R4,#3
ADD R2,R2,R4,LSL #1
SUB R2,R2,R4,ASR #3
SUB R2,R2,R4,ASR #4
SUB R2,R2,R4,ASR #6
STRH R4,[R1],#2
SUBS R6,R6,#1
BNE Method3loop
ldmfd sp!, {r0, r1, r4, r5, r6, r7}
STR R2,[R0]
STR R3,[R1]
bx lr
.pool
|