aenv.s
10.1 KB
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
/*************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
************************************************************************/
/*
* File: aenv.s
* Creator: byron@sgi.com
* Create Date: 11/1/94
*
* Contains the commands: A_ENV
*
*/
/* These define should be in abi.h with the envelope state struct definition */
#define ENV_STATE (0)
#define INT_VOL_OFFSETL (ENV_STATE)
#define FRAC_VOL_OFFSETL (INT_VOL_OFFSETL + BYTES_PER_VECTOR)
#define INT_VOL_OFFSETR (FRAC_VOL_OFFSETL + BYTES_PER_VECTOR)
#define FRAC_VOL_OFFSETR (INT_VOL_OFFSETR + BYTES_PER_VECTOR)
#define ENV_PARMS_OFFSET (FRAC_VOL_OFFSETR + BYTES_PER_VECTOR)
#define ENV_STATE_SIZE8 (ENV_PARMS_OFFSET + BYTES_PER_VECTOR - 1)
#define ENV_PAD (80 - ENV_STATE_SIZE8)
#define SCRATCH_OUT (ENV_STATE + ENV_STATE_SIZE8 + ENV_PAD)
/* define elements in the channel parameter vector (venvparms) */
/* note the order is also defined in aud_dme.h */
#define VTGTL 0
#define VRTLM 1
#define VRTLL 2
#define VTGTR 3
#define VRTRM 4
#define VRTRL 5
#define VAUXD 6
#define VAUXW 7
#define VTGTLb 0
#define VRTLMb 2
#define VRTLLb 4
#define VTGTRb 6
#define VRTRMb 8
#define VRTRLb 10
#define VAUXDb 12
#define VAUXWb 14
/* macros to clarify accum result storage */
#define vstorem(x) vmadm x, vONE, vZERO[0]
#define vstoren(x) vmadn x, vONE, vZERO[0]
.name updownVolL, $21
.name updownVolR, $20
.name outptrL, $19
.name outptrR, $18
.name auxptrL, $17
.name auxptrR, $16
.name auxincr, $15
.name loopctl, $14
.name inptr, $13
.name flags, $12
.name constbase, $11
.name initflag, $10
.name temp, $9
.name vONE, $v31
.name vRAMP, $v30
.name voutL, $v29
.name voutR, $v28
.name vauxL, $v27
.name vauxR, $v26
.name venvparms, $v24
.name vtemp0, $v23
.name vtemp1, $v22
.name vfcvolL, $v21
.name vicvolL, $v20
.name vfcvolR, $v19
.name vicvolR, $v18
.name vin, $v17
.name vvout, $v16
.name vvaux, $v15
.name vfratL, $v14
.name viratL, $v13
.name vfratR, $v12
.name viratR, $v11
.name vconst, $v10
.name vZERO, $v0
.name dm_state_addr, $1
.name state_addr, $2
.name count, $3
.name mask, $4
.name seg_id, $5
.name seg_addr, $6
case_A_ENVMIX:
#############################################################
#
# get state memory address and count
#
lui mask, 0x00ff
ori mask, mask, 0xffff
and state_addr, aud1, mask
srl seg_id, aud1, 24 # must clear bits
sll seg_id, seg_id, 2 # leave mult. by 4 for offset
lw seg_addr, RSP_SEG_OFFSET(seg_id)
add state_addr, state_addr, seg_addr
addi dm_state_addr, scrbase, ENV_STATE
addi count, zero, ENV_STATE_SIZE8
#
# other useful constants
#
vxor vZERO, vZERO, vZERO
addi constbase, zero, RES_CONST_OFFSET
lqv vONE[0], C_ONE(constbase)
lqv vconst[0], VCONST_OFFSET(zero)
srl flags, aud0, 16
#
# check if A_INIT flag is set
#
andi initflag, flags, A_INIT
beq initflag, zero, env_init_from_state
lqv venvparms[0], RSP_PARAMETER_VOLTGTL(parbase)
j env_load_parameters
nop
env_init_from_state:
#
# A_INIT is clear, do the dma...
#
jal DMAread
nop
ENVwt1:
mfc0 $5, DMA_BUSY
bne $5, zero, ENVwt1
nop
# release the semaphore
mtc0 $0, SP_RESERVED
lqv vicvolL[0], INT_VOL_OFFSETL(scrbase)
lqv vfcvolL[0], FRAC_VOL_OFFSETL(scrbase)
lqv vicvolR[0], INT_VOL_OFFSETR(scrbase)
lqv vfcvolR[0], FRAC_VOL_OFFSETR(scrbase)
lqv venvparms[0], ENV_PARMS_OFFSET(scrbase)
env_load_parameters:
lh inptr, RSP_PARAMETER_DMEMIN(parbase)
lh outptrL, RSP_PARAMETER_DMEMOUT(parbase)
lh outptrR, RSP_PARAMETER_DMOUTR(parbase)
lh auxptrL, RSP_PARAMETER_DMAUXL(parbase)
lh auxptrR, RSP_PARAMETER_DMAUXR(parbase)
lh loopctl, RSP_PARAMETER_COUNT(parbase)
addi auxincr, zero, 16
#
# set run-time flag
#
mfc2 updownVolL, venvparms[VRTLMb]
mfc2 updownVolR, venvparms[VRTRMb]
#
# check AUX flag
#
andi temp, flags, A_AUX
bgtz temp, env_main
nop
#
# no aux buff, load dummy values
#
addi auxptrL, scrbase, SCRATCH_OUT
add auxptrR, zero, auxptrL
addi auxincr, zero, 0
#
#
#############################################################
.unname dm_state_addr
.unname state_addr
.unname count
.unname mask
.unname seg_id
.unname seg_addr
#############################################################
#
# beginning of main processing
#
env_main:
#
# initialize exponential ramp
#
beq initflag, zero, no_update
lqv vRAMP[0], C_RAMP(constbase)
lqv vin[0], 0(inptr)
lqv voutL[0], 0(outptrL)
lqv vauxL[0], 0(auxptrL)
vxor vfcvolL, vfcvolL, vfcvolL # clear fractional volume
lsv vicvolL[14], RSP_PARAMETER_VOLL(parbase)
vmudm vtemp0, vicvolL, venvparms[VRTLL]
vmadh vtemp1, vicvolL, venvparms[VRTLM]
vstoren(vtemp0)
vsubc vtemp0, vtemp0, vfcvolL
vsub vtemp1, vtemp1, vicvolL
vmudl vtemp0, vRAMP, vtemp0[7]
vmadn vtemp0, vRAMP, vtemp1[7]
vstorem(vtemp1)
vmadm vfcvolL, vONE, vfcvolL[7]
vmadh vicvolL, vONE, vicvolL[7]
bgtz updownVolL, env_atkVol1L
vstoren(vfcvolL)
vge vicvolL, vicvolL, venvparms[VTGTL] # clip to target
j env_jp1L
nop
env_atkVol1L:
vcl vicvolL, vicvolL, venvparms[VTGTL] # clamp to target
env_jp1L:
vmulf vvout, vicvolL, venvparms[VAUXD] # scale vol by Aux amt
vmulf vvaux, vicvolL, venvparms[VAUXW]
vmulf voutL, voutL, vconst[6]
vmacf voutL, vin, vvout
vmulf vauxL, vauxL, vconst[6]
vmacf vauxL, vin, vvaux
sqv voutL[0], 0(outptrL)
sqv vauxL[0], 0(auxptrL)
#
# now do right
#
lqv voutR[0], 0(outptrR)
lqv vauxR[0], 0(auxptrR)
vxor vfcvolR, vfcvolR, vfcvolR
lsv vicvolR[14], RSP_PARAMETER_VOLR(parbase)
vmudm vtemp0, vicvolR, venvparms[VRTRL]
vmadh vtemp1, vicvolR, venvparms[VRTRM]
vstoren(vtemp0)
vsubc vtemp0, vtemp0, vfcvolR
vsub vtemp1, vtemp1, vicvolR
vmudl vtemp0, vRAMP, vtemp0[7]
vmadn vtemp0, vRAMP, vtemp1[7]
vstorem(vtemp1)
vmadm vfcvolR, vONE, vfcvolR[7]
vmadh vicvolR, vONE, vicvolR[7]
bgtz updownVolR, env_atkVol1R
vstoren(vfcvolR)
vge vicvolR, vicvolR, venvparms[VTGTR] # clip to target
j env_jp1R
nop
env_atkVol1R:
vcl vicvolR, vicvolR, venvparms[VTGTR] # clamp to target
env_jp1R:
vmulf vvout, vicvolR, venvparms[VAUXD] # scale vol by Aux amt
vmulf vvaux, vicvolR, venvparms[VAUXW]
vmulf voutR, voutR, vconst[6]
vmacf voutR, vin, vvout
vmulf vauxR, vauxR, vconst[6]
vmacf vauxR, vin, vvaux
sqv voutR[0], 0(outptrR)
sqv vauxR[0], 0(auxptrR)
addi loopctl, loopctl, -16
addi inptr, inptr, 16
addi outptrL, outptrL, 16
addi outptrR, outptrR, 16
add auxptrL, auxptrL, auxincr
add auxptrR, auxptrR, auxincr
no_update:
vmudl vtemp0, vfcvolL, venvparms[VRTLL]
vmadm vtemp0, vicvolL, venvparms[VRTLL]
vmadn vtemp0, vfcvolL, venvparms[VRTLM]
vmadh vicvolL, vicvolL, venvparms[VRTLM]
vstoren(vfcvolL)
env_loop:
bgtz updownVolL, env_atkVol2L
lqv vin[0], 0(inptr)
vge vicvolL, vicvolL, venvparms[VTGTL] # clip to target
vmudl vtemp0, vfcvolR, venvparms[VRTRL]
vmadm vtemp0, vicvolR, venvparms[VRTRL]
vmadn vtemp0, vfcvolR, venvparms[VRTRM]
lqv voutL[0], 0(outptrL)
vmadh vicvolR, vicvolR, venvparms[VRTRM]
lqv vauxL[0], 0(auxptrL)
j env_jp2L
vstoren(vfcvolR)
env_atkVol2L:
vcl vicvolL, vicvolL, venvparms[VTGTL] # clamp to target
vmudl vtemp0, vfcvolR, venvparms[VRTRL]
vmadm vtemp0, vicvolR, venvparms[VRTRL]
vmadn vtemp0, vfcvolR, venvparms[VRTRM]
lqv voutL[0], 0(outptrL)
vmadh vicvolR, vicvolR, venvparms[VRTRM]
lqv vauxL[0], 0(auxptrL)
vstoren(vfcvolR)
env_jp2L:
vmulf vvout, vicvolL, venvparms[VAUXD] # scale vol by Aux amt
sqv vicvolL[0], INT_VOL_OFFSETL(scrbase)
vmulf vvaux, vicvolL, venvparms[VAUXW]
sqv vfcvolL[0], FRAC_VOL_OFFSETL(scrbase)
vmulf voutL, voutL, vconst[6]
vmacf voutL, vin, vvout
lqv voutR[0], 0(outptrR)
vmulf vauxL, vauxL, vconst[6]
lqv vauxR[0], 0(auxptrR)
vmacf vauxL, vin, vvaux
bgtz updownVolR, env_atkVol2R
sqv voutL[0], 0(outptrL)
vge vicvolR, vicvolR, venvparms[VTGTR] # clip to target
vmudl vtemp0, vfcvolL, venvparms[VRTLL]
sqv vauxL[0], 0(auxptrL)
vmadm vtemp0, vicvolL, venvparms[VRTLL]
vmadn vtemp0, vfcvolL, venvparms[VRTLM]
vmadh vicvolL, vicvolL, venvparms[VRTLM]
j env_jp2R
vstoren(vfcvolL)
env_atkVol2R:
vcl vicvolR, vicvolR, venvparms[VTGTR] # clamp to target
vmudl vtemp0, vfcvolL, venvparms[VRTLL]
sqv vauxL[0], 0(auxptrL)
vmadm vtemp0, vicvolL, venvparms[VRTLL]
vmadn vtemp0, vfcvolL, venvparms[VRTLM]
vmadh vicvolL, vicvolL, venvparms[VRTLM]
vstoren(vfcvolL)
env_jp2R:
vmulf vvout, vicvolR, venvparms[VAUXD] # scale vol by Aux amt
addi loopctl, loopctl, -16
vmulf vvaux, vicvolR, venvparms[VAUXW]
addi outptrL, outptrL, 16
vmulf voutR, voutR, vconst[6]
add auxptrL, auxptrL, auxincr
vmacf voutR, vin, vvout
addi inptr, inptr, 16
vmulf vauxR, vauxR, vconst[6]
vmacf vauxR, vin, vvaux
sqv voutR[0], 0(outptrR)
addi outptrR, outptrR, 16
blez loopctl, env_fini
sqv vauxR[0], 0(auxptrR)
j env_loop
add auxptrR, auxptrR, auxincr
#
# end of main loop
#
#############################################################
.name dm_state_addr, $1
.name state_addr, $2
.name count, $3
#
# save state memory parameters
#
env_fini:
sqv vicvolR[0], INT_VOL_OFFSETR(scrbase)
sqv vfcvolR[0], FRAC_VOL_OFFSETR(scrbase)
sqv venvparms[0], ENV_PARMS_OFFSET(scrbase)
jal DMAwrite
addi count, zero, ENV_STATE_SIZE8
.unname dm_state_addr
.unname state_addr
.unname count
ENVwt2:
mfc0 $5, DMA_BUSY
bne $5, zero, ENVwt2
nop
j AudDone
# release the semaphore
mtc0 $0, SP_RESERVED
.unname updownVolL
.unname updownVolR
.unname outptrL
.unname outptrR
.unname auxptrL
.unname auxptrR
.unname auxincr
.unname loopctl
.unname inptr
.unname flags
.unname temp
.unname vONE
.unname vRAMP
.unname voutL
.unname voutR
.unname vauxL
.unname vauxR
.unname venvparms
.unname vtemp0
.unname vtemp1
.unname vfcvolL
.unname vicvolL
.unname vfcvolR
.unname vicvolR
.unname vin
.unname vconst
.unname vZERO