DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
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    ch;
00013         SINT32  data;
00014         UINT    i;
00015 
00016         if (tms->enable == 0) {
00017                 return;
00018         }
00019         while(count--) {
00020                 ch = 0;
00021                 data = 0;
00022                 do {                                                                    // centre
00023                         if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
00024                                 for (i=0; i<4; i++) {
00025                                         tms->ch[ch].count += tms->ch[ch].freq;
00026                                         data += (tms->ch[ch].count & 0x10000)?1:-1;
00027                                 }
00028                         }
00029                 } while(++ch < 2);
00030                 pcm[0] += data * tms3631cfg.left;
00031                 pcm[1] += data * tms3631cfg.right;
00032                 do {                                                                    // left
00033                         if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
00034                                 for (i=0; i<4; i++) {
00035                                         tms->ch[ch].count += tms->ch[ch].freq;
00036                                         pcm[0] += tms3631cfg.feet[(tms->ch[ch].count >> 16) & 15];
00037                                 }
00038                         }
00039                 } while(++ch < 5);
00040                 do {                                                                    // right
00041                         if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
00042                                 for (i=0; i<4; i++) {
00043                                         tms->ch[ch].count += tms->ch[ch].freq;
00044                                         pcm[1] += tms3631cfg.feet[(tms->ch[ch].count >> 16) & 15];
00045                                 }
00046                         }
00047                 } while(++ch < 8);
00048                 pcm += 2;
00049         }
00050 }
00051