/*************************************************************************** * au88x0_eq.c * Aureal Vortex Hardware EQ control/access. * * Sun Jun 8 18:19:19 2003 * 2003 Manuel Jander (mjander@user.sourceforge.net) * * ****************************************************************************/ #include "au88x0.h" /* To be deleted once this makes any sense. */ int this04; /* CEqHw.s */ void vortex_EqHw_SetTimeConsts(vortex_t *vortex, short a, short b) { hwwrite(vortex->mmio, 0x2b3c4, a); hwwrite(vortex->mmio, 0x2b3c8, a); } void vortex_EqHw_GetTimeConsts(vortex_t *vortex, short *a, short *b) { *a = hwread(vortex->mmio, 0x2b3c4); *b = hwread(vortex->mmio, 0x2b3c8); } void vortex_EqHw_SetLeftCoefs(vortex_t *vortex, short *a) { int eax, *edi, ebp, esp10, esp14, esp18, esp1c, esp20, esp24, esp28, esp2c = 0; if (this04 >= esp2c) return; esp28 = 0x2b010; esp24 = a[4]; esp20 = 0x2b00c; esp1c = a[3]; ebp = 0x2b008; edi = &a[2]; esp18 = a[1]; esp14 = 0x2b004; esp10 = 0x2b000; do { hwwrite(vortex->mmio, esp10, a[0]); hwwrite(vortex->mmio, esp14, *esp18); if (this08) { hwwrite(vortex->mmio, ebp, *edi); hwwrite(vortex->mmio, esp28, *esp1c); eax = *esp24; } else { if (*edi == 0x8000) eax = 0x7fff; else eax = ~(*edi) /* unknown opcode: cwtl */; hwwrite(vortex->mmio, ebp, eax & 0xffff); if (*esp1c == 0x8000) eax = 0x7fff; else eax = ~(*esp1c) /* unknown opcode: cwtl */; hwwrite(vortex->mmio, esp28, eax & 0xffff); if (*esp24 == 0x8000) eax = 0x7fff; else eax = ~(*esp24) /* unknown opcode: cwtl */; } hwwrite(vortex->mmio, esp2c, eax); esp28 += 0x30; esp24 += 0xa; esi += 0xa; esp20 += 0x30; esp1c += 0xa; ebp += 0x30; edi += 0xa; esp18 += 0xa; esp14 += 0x30; esp10 += 0x30; esp2c++; } while(esp2c < this04); } void vortex_EqHw_GetLeftCoefs(vortex_t *vortex, short *a) { } void vortex_EqHw_SetRightCoefs(vortex_t *vortex, short *a) { int eax, edi, ebp, esp10, esp14, esp20, esp24, esp28, esp2c = 0; if (this04 >= esp2c) return; esp28 = 0x2b1f0; esp24 = a[4]; esp20 = 0x2b1ec; esp1c = a[3]; ebp = 0x2b1e8; edi = a[2]; esp18 = a[1]; esp14 = 0x2b1e4; esp10 = 0x2b1e0; do { hwwrite(vortex->mmio, esp10, a[0]); hwwrite(vortex->mmio, esp14, *esp18); if (this08) { hwwrite(vortex->mmio, ebp, *edi); hwwrite(vortex->mmio, esp28, *esp1c); eax = *esp24; } else { if (*edi == 0x8000) eax = 0x7fff; else eax = ~(*edi) /* unknown opcode: cwtl */; hwwrite(vortex->mmio, ebp, eax & 0xffff); if (*esp1c == 0x8000) eax = 0x7fff; else eax = ~(*esp1c) /* unknown opcode: cwtl */; hwwrite(vortex->mmio, esp28, eax & 0xffff); if (*esp24 == 0x8000) eax = 0x7fff; else eax = ~(*esp24) /* unknown opcode: cwtl */; } hwwrite(vortex->mmio, esp2c, eax); esp28 += 0x30; esp24 += 0xa; esi += 0xa; esp20 += 0x30; esp1c += 0xa; ebp += 0x30; edi += 0xa; esp18 += 0xa; esp14 += 0x30; esp10 += 0x30; esp2c++; } while(esp2c < this04); } void vortex_EqHw_GetRightCoefs(vortex_t *vortex, short *a) { } void vortex_EqHw_SetLeftStates(vortex_t *vortex, short *a) { int edi, ebx, esi, ebp, esp10, esp14, esp18, esp1c, esp20; hwwrite(vortex->mmio, 0x2b3fc, a[0]); hwwrite(vortex->mmio, 0x2b400, a[1]); if (this04 < 0) return; ebx = 0; esp20 = &a[3]; esp1c = 0x2b020; esp18 = &a[2]; esp14 = 0x2b01c; esp10 = &a[1]; ebp = 0x2b018; edi = 0x2b014; esi = 0; do { hwwrite(vortex->mmio, edi, a[esi]); hwwrite(vortex->mmio, ebp, *esp10); hwwrite(vortex->mmio, esp14, *esp18); hwwrite(vortex->mmio, esp1c, *esp20); ebp += 0x30; edi += 0x30; esi += 0x2; ebx++; esp20 += 0x8; esp1c += 0x30; esp18 += 0x8; esp14 += 0x30; esp10 += 0x8; } while (*(esp28+4) < ebx); } void vortex_EqHw_GetLeftStates(vortex_t *vortex, short *a) { } void vortex_EqHw_SetRightStates(vortex_t *vortex, short *a) { int edi, ebx, esi, ebp, esp10, esp14, esp18, esp1c, esp20; hwwrite(vortex->mmio, 0x2b404, a[0]); hwwrite(vortex->mmio, 0x2b408, a[1]); if (this04 < 0) return; ebx = 0; esp20 = &a[3]; esp1c = 0x2b200; esp18 = &a[2]; esp14 = 0x2b1fc; esp10 = &a[1]; ebp = 0x2b1f8; edi = 0x2b1f4; esi = 0; do { hwwrite(vortex->mmio, edi, a[esi]); hwwrite(vortex->mmio, ebp, *esp10); hwwrite(vortex->mmio, esp14, *esp18); hwwrite(vortex->mmio, esp1c, *esp20); ebp += 0x30; edi += 0x30; esi += 0x2; ebx++; esp20 += 0x8; esp1c += 0x30; esp18 += 0x8; esp14 += 0x30; esp10 += 0x8; } while (*(esp28+4) < ebx); } void vortex_EqHw_GetLeftStates(vortex_t *vortex, short *a) { } void vortex_EqHw_SetBypassGain(vortex_t *vortex, short a, short b) { // this08 = stereo ? if (this08 == 0) { hwwrite(vortex->mmio, 0x2b3d4, a); b = a; } if (a == 0x8000) a = 0x7fff; else a = ~(a) /* unknown opcode: cwtl */; hwwrite(vortex->mmio, 0x2b3d4, a); if (b == 0x8000) b = 0x7fff; else b = ~(b) /* unknown opcode: cwtl */; hwwrite(vortex->mmio, 0x2b3d4, b); } void vortex_EqHw_SetA3DBypassGain(vortex_t *vortex, short a, short b) { hwwrite(vortex->mmio, 0x2b3e0, a); hwwrite(vortex->mmio, 0x2b3f8, b); } void vortex_EqHw_SetCurrBypassGain(vortex_t *vortex, short a, short b) { hwwrite(vortex->mmio, 0x2b3d0, a); hwwrite(vortex->mmio, 0x2b3e8, b); } void vortex_EqHw_SetCurrA3DBypassGain(vortex_t *vortex, short a, short b) { hwwrite(vortex->mmio, 0x2b3dc, a); hwwrite(vortex->mmio, 0x2b3f4, b); } void vortex_EqHw_SetLeftGainsSingleTarge(vortex_t *vortex, short a, short b) { hwwrite(vortex->mmio, 0x2b02c + ((a*3) << 4), b); } void vortex_EqHw_SetRightGainsSingleTarge(vortex_t *vortex, short a, short b) { hwwrite(vortex->mmio, 0x2b20c + ((a*3) << 4), b); } void vortex_EqHw_SetLeftGainsTarget(vortex_t *vortex, short a[]) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b02c; do { hwwrite(vortex->mmio, edi, a[ebx]); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_SetRightGainsTarget(vortex_t *vortex, short a) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b20c; do { hwwrite(vortex->mmio, edi, a[ebx]); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_GetLeftGainsTarget(vortex_t *vortex, short a[]) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b02c; do { a[ebx] = hwread(vortex->mmio, edi); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_GetRightGainsTarget(vortex_t *vortex, short a) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b20c; do { a[ebx] = hwwrite(vortex->mmio, edi); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_SetLeftGainsCurrent(vortex_t *vortex, short a[]) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b028; do { hwwrite(vortex->mmio, edi, a[ebx]); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_SetRightGainsCurrent(vortex_t *vortex, short a) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b208; do { hwwrite(vortex->mmio, edi, a[ebx]); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_GetLeftGainsCurrent(vortex_t *vortex, short a[]) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b028; do { a[ebx] = hwread(vortex->mmio, edi); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_GetRightGainsCurrent(vortex_t *vortex, short a) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b208; do { a[ebx] = hwread(vortex->mmio, edi); edi += 0x30; } while (ebx < this04); } void vortex_EqHw_SetLevels(vortex_t *vortex, short a) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b024; do { hwwrite(vortex->mmio, edi, a[ebx]); edi += 0x30; } while (ebx < this04); hwwrite(vortex->mmio, 0x2b3cc, a[this04]); hwwrite(vortex->mmio, 0x2b3d8, a[this04+1]); if ((this04+2) < ((this04*2)+2)) { edi = 0x2afc4 + (((this_04+2)*3) << 4); do { hwwrite(vortex->mmio, edi, a[ebx+(this04+1)]); edi += 0x30; } while (ebx < (2+(this04*2))); } hwwrite(vortex->mmio, 0x2b3e4, a[2+(this04*2)]); hwwrite(vortex->mmio, 0x2b3f0, a[3+(this04*2)]); } void vortex_EqHw_GetLevels(vortex_t *vortex, short a) { int edi, esi, ebx=0; if (this04 < 0) return; edi = 0x2b024; do { a[ebx] = hwread(vortex->mmio, edi); edi += 0x30; ebx++; } while (ebx < this04); a[this04] = hwread(vortex->mmio, 0x2b3cc); a[this04+1] = hwread(vortex->mmio, 0x2b3d8); if ((this04+2) < ((this04*2)+2)) { edi = 0x2afc4 + (((this_04+2)*3) << 4); do { a[ebx+(this04+1)] = hwread(vortex->mmio, edi); edi += 0x30; ebx++; } while (ebx < (2+(this04*2))); } a[2+(this04*2)] = hwread(vortex->mmio, 0x2b3e4); a[3+(this04*2)] = hwread(vortex->mmio, 0x2b3f0); } void vortex_EqHw_SetControlReg(vortex_t *vortex, unsigned long reg) { hwwrite(vortex->mmio, 0x2b440, reg); } void vortex_EqHw_GetControlReg(vortex_t *vortex, unsigned long *reg) { *reg = hwread(vortex->mmio, 0x2b440); } void vortex_EqHw_SetSampleRate(vortex_t *vortex, int sr) { hwwrite(vortex->mmio, 0x2b440, ((sr & 0x1f) << 3) | 0xb800); } void vortex_EqHw_SetSampleRate(vortex_t *vortex, int *sr) { *sr = (hwread(vortex->mmio, 0x2b440) >> 3) & 0x1f; } void vortex_EqHw_Enable(vortex_t *vortex) { hwwrite(vortex->mmio, 0x2b440, 0xf001); } void vortex_EqHw_Disable(vortex_t *vortex) { hwwrite(vortex->mmio, 0x2b440, 0xf000); } void vortex_EqHw_ZeroIO(vortex_t *vortex) { int i; for (i=0; i<0x8; i++) hwwrite(vortex->mmio, 0x2b410 + (i<<2), 0x0); for (i=0; i<0x4; i++) hwwrite(vortex->mmio, 0x2b430 + (i<<2), 0x0); } void vortex_EqHw_ZeroA3DIO(vortex_t *vortex) { int i; for (i=0; i<0x4; i++) hwwrite(vortex->mmio, 0x2b410 + (i<<2), 0x0); } void vortex_EqHw_ZeroState(vortex_t *vortex) { vortex_EqHw_SetControlReg(vortex, 0); vortex_EqHw_ZeroIO(vortex); hwwrite(vortex->mmio, 0x2b3c0, 0); vortex_EqHw_SetTimeConsts(vortex, 0, 0); vortex_EqHw_SetLeftCoefs(vortex, asEqCoefsZeros); vortex_EqHw_SetRightCoefs(vortex, asEqCoefsZeros); vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_zero); vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_zero); vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_zero); vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_zero); vortex_EqHw_SetBypassGain(vortex, 0, 0); vortex_EqHw_SetA3DBypassGain(vortex, 0, 0); vortex_EqHw_SetLeftStates(vortex, &eq_states_zero, &asEqOutStateZeros); vortex_EqHw_SetRightStates(vortex, &eq_states_zero, &asEqOutStateZeros); vortex_EqHw_SetLevels(vortex, eq_levels); } void vortex_EqHw_ProgramPipe(vortex_t *vortex) { vortex_EqHw_SetTimeConsts(vortex, 0, 0); vortex_EqHw_SetLeftCoefs(vortex, &asEqCoefsPipes); vortex_EqHw_SetRightCoefs(vortex, &asEqCoefsPipes); vortex_EqHw_SetLeftGainsCurrent(vortex, eq_gains_current); vortex_EqHw_SetRightGainsCurrent(vortex, eq_gains_current); vortex_EqHw_SetLeftGainsTarget(vortex, eq_gains_current); vortex_EqHw_SetRightGainsTarget(vortex, eq_gains_current); } void vortex_EqHw_Program10Band(vortex_t *vortex, auxxEqCoeffSet_t * coefset) { vortex_EqHw_SetTimeConsts(vortex, 0xc, 0x7fe0); vortex_EqHw_SetLeftCoefs(vortex, coefset->LeftCoefs); vortex_EqHw_SetRightCoefs(vortex, coefset->RightCoefs); vortex_EqHw_SetLeftGainsCurrent(vortex, coefset->LeftGains); vortex_EqHw_SetRightGainsTarget(vortex, coefset->RightGains); vortex_EqHw_SetLeftGainsTarget(vortex, coefset->LeftGains); vortex_EqHw_SetRightGainsCurrent(vortex, coefset->RightGains); } /* CEqlzr.s */ void vortex_Eqlzr_init(vortex_t *vortex) { eqlzr_t *eq = &(vortex->eq); /* Object constructor */ eq->this04 = 0; eq->this08 = 0; eq->this0a = 0x5999; eq->this0c = 0x5999; eq->this0e = 0x5999; eq->this10 = 0xa; eq->this28 = 0x0; eq->this54 = 0x1; eq->this58 = 0xffff; eq->this5c = 0xffff; /* Actual init. */ eq->this04 = eq->this00[0x60] + 0x14; /* CAsp4Core[0x60] */ /* skip */ vortex_EqHw_ZeroState(vortex); vortex_EqHw_SetSampleRate(vortex, 0x11); vortex_Eqlzr_ReadAndSetActiveCoefSet(vortex); vortex_EqHw_Program10Band(vortex, eq->coefset); vortex_EqHw_SetBypass(vortex, eq->this54); vortex_EqHw_Enable(vortex); } void vortex_Eqlzr_SetBypass(vortex_t *vortex, long bp) { eqlzr_t *eq = &(vortex->eq); if (eq->this28) { vortex_Eqlzr_SetAllBandsFromActiveCoeffSet(vortex); vortex_EqHw_SetBypassGain(vortex, eq->this08, eq->this08); } else { vortex_EqHw_SetLeftGainsTarget(vortex, eq->this14); vortex_EqHw_SetRightGainsTarget(vortex, eq->this14); vortex_EqHw_SetBypassGain(vortex, eq->this0c, eq->this0c); } vortex_Eqlzr_ProgramA3dBypassGain(vortex); } int vortex_Eqlzr_GetLeftGain(vortex_t *vortex, short index, short *gain) { eqlzr_t *eq = &(vortex->eq); if (eq->this28) { *gain = eq->this130[index]; return 0; } return 1; } void vortex_Eqlzr_SetLeftGain(vortex_t *vortex, short a, short b) { }