|
|
| version 1.6, 2004/08/17 16:52:46 | version 1.7, 2005/02/04 06:42:12 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include <math.h> | |
| #include "sound.h" | #include "sound.h" |
| #include "sndctrl.h" | #include "sndctrl.h" |
| PSGGENCFG psggencfg; | PSGGENCFG psggencfg; |
| static const SINT32 psgvolrate[16] = { | |
| 0, 508, 719, 1017, 1440, 2037, 2883, 4079, | |
| 5772, 8167,11556,16351,23135,32735,46317,65536}; | |
| const UINT8 psggen_deftbl[0x10] = | const UINT8 psggen_deftbl[0x10] = |
| {0, 0, 0, 0, 0, 0, 0, 0xbf, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; | {0, 0, 0, 0, 0, 0, 0, 0xbf, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; |
| Line 30 static const UINT8 psgenv_pat[16] = { | Line 33 static const UINT8 psgenv_pat[16] = { |
| void psggen_initialize(UINT rate) { | void psggen_initialize(UINT rate) { |
| double pom; | |
| UINT i; | UINT i; |
| ZeroMemory(&psggencfg, sizeof(psggencfg)); | ZeroMemory(&psggencfg, sizeof(psggencfg)); |
| psggencfg.rate = rate; | psggencfg.rate = rate; |
| pom = (double)0x0c00; | for (i=0; i<16; i++) { |
| for (i=15; i; i--) { | psggencfg.voltbl[i] = (0x0c00 * psgvolrate[i]) >> 16; |
| psggencfg.voltbl[i] = (SINT32)pom; | |
| pom /= 1.41492; | |
| } | } |
| psggencfg.puchidec = (UINT16)(rate / 11025) * 2; | psggencfg.puchidec = (UINT16)(rate * 2 / 11025); |
| if (psggencfg.puchidec == 0) { | if (psggencfg.puchidec == 0) { |
| psggencfg.puchidec = 1; | psggencfg.puchidec = 1; |
| } | } |