File:  [RetroPC.NET] / np2 / sound / tms3631g.c
Revision 1.2: download - view: text, annotated - select for diffs
Wed Oct 22 23:13:25 2003 JST (22 years ago) by yui
Branches: MAIN
CVS tags: VER_0_82_x64, VER_0_82, VER_0_81A, VER_0_81, VER_0_80, VER_0_79, VER_0_78, VER_0_77, VER_0_76, VER_0_75, VER_0_74, VER_0_73, VER_0_72, VER_0_71, VER_0_70, HEAD
fix opn, psg (T.Yui)

#include	"compiler.h"
#include	"sound.h"
#include	"tms3631.h"


extern	TMS3631CFG	tms3631cfg;


void SOUNDCALL tms3631_getpcm(TMS3631 tms, SINT32 *pcm, UINT count) {

	UINT	ch;
	SINT32	data;
	UINT	i;

	if (tms->enable == 0) {
		return;
	}
	while(count--) {
		ch = 0;
		data = 0;
		do {									// centre
			if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
				for (i=0; i<4; i++) {
					tms->ch[ch].count += tms->ch[ch].freq;
					data += (tms->ch[ch].count & 0x10000)?1:-1;
				}
			}
		} while(++ch < 2);
		pcm[0] += data * tms3631cfg.left;
		pcm[1] += data * tms3631cfg.right;
		do {									// left
			if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
				for (i=0; i<4; i++) {
					tms->ch[ch].count += tms->ch[ch].freq;
					pcm[0] += tms3631cfg.feet[(tms->ch[ch].count >> 16) & 15];
				}
			}
		} while(++ch < 5);
		do {									// right
			if ((tms->enable & (1 << ch)) && (tms->ch[ch].freq)) {
				for (i=0; i<4; i++) {
					tms->ch[ch].count += tms->ch[ch].freq;
					pcm[1] += tms3631cfg.feet[(tms->ch[ch].count >> 16) & 15];
				}
			}
		} while(++ch < 8);
		pcm += 2;
	}
}


RetroPC.NET-CVS <cvs@retropc.net>