|
|
| version 1.4, 2003/10/25 17:29:38 | version 1.8, 2005/02/07 14:46:12 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "parts.h" | |
| #include "sound.h" | #include "sound.h" |
| #include "psggen.h" | #include "psggen.h" |
| extern PSGGENCFG psggencfg; | extern PSGGENCFG psggencfg; |
| // ¥Æ¥¹¥È | |
| static UINT32 rnds; | |
| static UINT psg_rand(void) { | |
| UINT32 rand0; | |
| UINT32 rand1; | |
| UINT c; | |
| rand0 = rnds & 0xffff; | |
| rand1 = rnds >> 16; | |
| rand0 = (rand0 >> 5) + (rand0 << 11); | |
| rand0 += 60043; | |
| rand1 -= 4953 + ((rand0 >> 16) & 1); | |
| c = (rand1 >> 15) & 1; | |
| rand1 = (rand1 << 1) + c; | |
| rand0 += rand1 + c; | |
| rnds = (rand1 << 16) + (rand0 & 0xffff); | |
| return(rand0); | |
| } | |
| void SOUNDCALL psggen_getpcm(PSGGEN psg, SINT32 *pcm, UINT count) { | void SOUNDCALL psggen_getpcm(PSGGEN psg, SINT32 *pcm, UINT count) { |
| SINT32 noisevol; | SINT32 noisevol; |
| BYTE mixer; | UINT8 mixer; |
| UINT noisetbl = 0; | UINT noisetbl = 0; |
| PSGTONE *tone; | PSGTONE *tone; |
| PSGTONE *toneterm; | PSGTONE *toneterm; |
| SINT32 samp; | SINT32 samp; |
| UINT psgvol; | // UINT psgvol; |
| SINT32 vol; | SINT32 vol; |
| UINT i; | UINT i; |
| UINT noise; | UINT noise; |
| Line 70 void SOUNDCALL psggen_getpcm(PSGGEN psg, | Line 50 void SOUNDCALL psggen_getpcm(PSGGEN psg, |
| psg->envcnt = psg->envmax; | psg->envcnt = psg->envmax; |
| psg->envvol = (psg->envvolcnt ^ psg->envmode) & 0x0f; | psg->envvol = (psg->envvolcnt ^ psg->envmode) & 0x0f; |
| } | } |
| psg->evol = psggencfg.volume[psg->envvol]; | |
| } | } |
| } | } |
| mixer = psg->mixer; | mixer = psg->mixer; |
| Line 80 void SOUNDCALL psggen_getpcm(PSGGEN psg, | Line 61 void SOUNDCALL psggen_getpcm(PSGGEN psg, |
| psg->noise.count -= psg->noise.freq; | psg->noise.count -= psg->noise.freq; |
| if (psg->noise.count > countbak) { | if (psg->noise.count > countbak) { |
| // psg->noise.base = GETRAND() & (1 << (1 << PSGADDEDBIT)); | // psg->noise.base = GETRAND() & (1 << (1 << PSGADDEDBIT)); |
| psg->noise.base = psg_rand() & (1 << (1 << PSGADDEDBIT)); | psg->noise.base = rand_get() & (1 << (1 << PSGADDEDBIT)); |
| } | } |
| noisetbl += psg->noise.base; | noisetbl += psg->noise.base; |
| noisetbl >>= 1; | noisetbl >>= 1; |
| Line 88 void SOUNDCALL psggen_getpcm(PSGGEN psg, | Line 69 void SOUNDCALL psggen_getpcm(PSGGEN psg, |
| } | } |
| tone = psg->tone; | tone = psg->tone; |
| toneterm = tone + 3; | toneterm = tone + 3; |
| samp = 0; | |
| do { | do { |
| psgvol = (*(tone->pvol)) & 15; | vol = *(tone->pvol); |
| if (psgvol) { | if (vol) { |
| vol = psggencfg.volume[psgvol]; | samp = 0; |
| switch(mixer & 9) { | switch(mixer & 9) { |
| case 0: // no mix | case 0: // no mix |
| if (tone->puchi) { | if (tone->puchi) { |
| Line 130 void SOUNDCALL psggen_getpcm(PSGGEN psg, | Line 110 void SOUNDCALL psggen_getpcm(PSGGEN psg, |
| } | } |
| break; | break; |
| } | } |
| if (!(tone->pan & 1)) { | |
| pcm[0] += samp; | |
| } | |
| if (!(tone->pan & 2)) { | |
| pcm[1] += samp; | |
| } | |
| } | } |
| mixer >>= 1; | mixer >>= 1; |
| } while(++tone < toneterm); | } while(++tone < toneterm); |
| pcm[0] += samp; | |
| pcm[1] += samp; | |
| pcm += 2; | pcm += 2; |
| } while(--count); | } while(--count); |
| } | } |