⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 DC上的GB模拟器源代码
💻 C
字号:
/* Streaming sound driver * * (c)2000 Dan Potter * * This slightly more complicated version allows for sound effect channels, * and full sampling rate, panning, and volume control for each. The two * streaming channels are still always first and always occur at 0x11000 and * 0x21000. All other sample data can begin at 0x31000. "pos" only works for * input on the two streaming channels (which will always have the same * "pos" value). *  */#include "aica.h"#include "aica_cmd_iface.h"//#define BUFFER_SIZE (65536/4)#define BUFFER_SIZE 10000/****************** Timer *******************************************/extern volatile int timer;void timer_wait(int jiffies) {	int fin = timer + jiffies;	while (timer <= fin)		;}/****************** Main Program ************************************//* Set channel id at 0x80280d (byte), read position at 0x802814 (long) */volatile uint32 *cmd = (volatile uint32 *)0x10000;volatile aica_channel *chans = (volatile aica_channel *)0x10004;void start_channel(int chn) {	if (chn == 0) {		aica_play(0, 0x11000, SM_16BIT, 0, BUFFER_SIZE/2, 44100, 240, 0, 1);		aica_play(1, 0x21000, SM_16BIT, 0, BUFFER_SIZE/2, 44100, 240, 255, 1);	} else {		aica_play(chn, chans[chn].pos, SM_16BIT, 0, chans[chn].length,			chans[chn].freq, chans[chn].vol, chans[chn].pan, 0);	}}void stop_channel(int chn) {	if (chn == 0) {		aica_stop(0);		aica_stop(1);	} else {		aica_stop(chn);	}}void process_cmd(uint32 cmd) {	/* cmd is channel to look at +1 */	cmd--;	switch(chans[cmd].cmd) {		case AICA_CMD_NONE:			break;		case AICA_CMD_START:			start_channel(cmd);			break;		case AICA_CMD_STOP:			stop_channel(cmd);			break;	}}int arm_main() {	int cmdl;	/* Initialize the AICA part of the SPU */	aica_init();	/* Observe channel 0 */	SNDREG8(0x280d) = 0;	/* Wait for a command */	while(1) {		/* Check for a command */		cmdl = *cmd;		if (cmdl & AICA_CMD_KICK) {			*cmd = 0;			process_cmd(cmdl & ~AICA_CMD_KICK);		}		/* Update position counters */		chans[0].pos = SNDREG32(0x2814);		/* Little delay to prevent memory lock */		timer_wait(10);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -