DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/snd_pc98/sound/tms3631g.c
00001 #include    "np2glue.h"
00002 //#include      "compiler.h"
00003 #include        "sound.h"
00004 #include        "tms3631.h"
00005 
00006 
00007 extern  TMS3631CFG      tms3631cfg;
00008 
00009 
00010 void SOUNDCALL tms3631_getpcm(TMS3631 tms, SINT32 *pcm, UINT count) {
00011 
00012         UINT    i;
00013 
00014         if (tms->enable == 0) {
00015                 return;
00016         }
00017         while(count--) {
00018                 UINT ch = 0;
00019                 SINT32 data = 0;
00020                 do {                                                                    // centre
00021                         if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
00022                                 for (i=0; i<4; i++) {
00023                                         tms->ch[ch].count += tms->ch[ch].freq;
00024                                         data += (tms->ch[ch].count & 0x10000)?1:-1;
00025                                 }
00026                         }
00027                 } while(++ch < 2);
00028                 pcm[0] += data * tms3631cfg.left;
00029                 pcm[1] += data * tms3631cfg.right;
00030                 do {                                                                    // left
00031                         if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
00032                                 for (i=0; i<4; i++) {
00033                                         tms->ch[ch].count += tms->ch[ch].freq;
00034                                         pcm[0] += tms3631cfg.feet[(tms->ch[ch].count >> 16) & 15];
00035                                 }
00036                         }
00037                 } while(++ch < 5);
00038                 do {                                                                    // right
00039                         if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
00040                                 for (i=0; i<4; i++) {
00041                                         tms->ch[ch].count += tms->ch[ch].freq;
00042                                         pcm[1] += tms3631cfg.feet[(tms->ch[ch].count >> 16) & 15];
00043                                 }
00044                         }
00045                 } while(++ch < 8);
00046                 pcm += 2;
00047         }
00048 }
00049