trunk/src/emu/sound/ay8910.c
r241391 | r241392 | |
431 | 431 | |
432 | 432 | INLINE void build_3D_table(double rl, const ay8910_device::ay_ym_param *par, const ay8910_device::ay_ym_param *par_env, int normalize, double factor, int zero_is_off, INT32 *tab) |
433 | 433 | { |
434 | | int j, j1, j2, j3, e, indx; |
435 | | double rt, rw, n; |
436 | 434 | double min = 10.0, max = 0.0; |
437 | 435 | |
438 | 436 | dynamic_array<double> temp(8*32*32*32); |
439 | 437 | |
440 | | for (e=0; e < 8; e++) |
441 | | for (j1=0; j1 < 32; j1++) |
442 | | for (j2=0; j2 < 32; j2++) |
443 | | for (j3=0; j3 < 32; j3++) |
| 438 | for (int e=0; e < 8; e++) |
| 439 | { |
| 440 | const ay8910_device::ay_ym_param *par_ch1 = (e & 0x01) ? par_env : par; |
| 441 | const ay8910_device::ay_ym_param *par_ch2 = (e & 0x02) ? par_env : par; |
| 442 | const ay8910_device::ay_ym_param *par_ch3 = (e & 0x04) ? par_env : par; |
| 443 | |
| 444 | for (int j1=0; j1 < par_ch1->res_count; j1++) |
| 445 | for (int j2=0; j2 < par_ch2->res_count; j2++) |
| 446 | for (int j3=0; j3 < par_ch3->res_count; j3++) |
444 | 447 | { |
| 448 | double n; |
445 | 449 | if (zero_is_off) |
446 | 450 | { |
447 | 451 | n = (j1 != 0 || (e & 0x01)) ? 1 : 0; |
r241391 | r241392 | |
451 | 455 | else |
452 | 456 | n = 3.0; |
453 | 457 | |
454 | | rt = n / par->r_up + 3.0 / par->r_down + 1.0 / rl; |
455 | | rw = n / par->r_up; |
| 458 | double rt = n / par->r_up + 3.0 / par->r_down + 1.0 / rl; |
| 459 | double rw = n / par->r_up; |
456 | 460 | |
457 | | rw += 1.0 / ( (e & 0x01) ? par_env->res[j1] : par->res[j1]); |
458 | | rt += 1.0 / ( (e & 0x01) ? par_env->res[j1] : par->res[j1]); |
459 | | rw += 1.0 / ( (e & 0x02) ? par_env->res[j2] : par->res[j2]); |
460 | | rt += 1.0 / ( (e & 0x02) ? par_env->res[j2] : par->res[j2]); |
461 | | rw += 1.0 / ( (e & 0x04) ? par_env->res[j3] : par->res[j3]); |
462 | | rt += 1.0 / ( (e & 0x04) ? par_env->res[j3] : par->res[j3]); |
| 461 | rw += 1.0 / par_ch1->res[j1]; |
| 462 | rt += 1.0 / par_ch1->res[j1]; |
| 463 | rw += 1.0 / par_ch2->res[j2]; |
| 464 | rt += 1.0 / par_ch2->res[j2]; |
| 465 | rw += 1.0 / par_ch3->res[j3]; |
| 466 | rt += 1.0 / par_ch3->res[j3]; |
463 | 467 | |
464 | | indx = (e << 15) | (j3<<10) | (j2<<5) | j1; |
| 468 | int indx = (e << 15) | (j3<<10) | (j2<<5) | j1; |
465 | 469 | temp[indx] = rw / rt; |
466 | 470 | if (temp[indx] < min) |
467 | 471 | min = temp[indx]; |
468 | 472 | if (temp[indx] > max) |
469 | 473 | max = temp[indx]; |
470 | 474 | } |
| 475 | } |
471 | 476 | |
472 | 477 | if (normalize) |
473 | 478 | { |
474 | | for (j=0; j < 32*32*32*8; j++) |
| 479 | for (int j=0; j < 32*32*32*8; j++) |
475 | 480 | tab[j] = MAX_OUTPUT * (((temp[j] - min)/(max-min))) * factor; |
476 | 481 | } |
477 | 482 | else |
478 | 483 | { |
479 | | for (j=0; j < 32*32*32*8; j++) |
| 484 | for (int j=0; j < 32*32*32*8; j++) |
480 | 485 | tab[j] = MAX_OUTPUT * temp[j]; |
481 | 486 | } |
482 | 487 | |