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

📄 nes_apu.h

📁 一个最快NFC的模拟器
💻 H
📖 第 1 页 / 共 2 页
字号:
	int32 sweepphase;
	int32 envphase;

	uint32 spd;
	uint32 envspd;
	uint32 sweepspd;

	uint32 length;
	uint32 freq;
	uint32 mastervolume;
	uint32 release;

	uint8 regs[4];
	uint8 update;
	uint8 key;
	uint8 adr;
	uint8 envadr;
	uint8 duty;
	uint8 mute;
} MMC5_SQUARE;

typedef struct {
	int32 output;
	uint8 key;
	uint8 mute;
} MMC5_DA;

typedef struct {
	MMC5_SQUARE square[2];
	MMC5_DA da;
} MMC5SOUND;

// ----------------------------------------------------------------------------
// N106 Sound struct

typedef struct {
	uint32 logvol;
	int32 cycles;
	uint32 spd;
	uint32 phase;
	uint32 tlen;
	uint8 update;
	uint8 freql;
	uint8 freqm;
	uint8 freqh;
	uint8 vreg;
	uint8 tadr;
	uint8 nazo;
	uint8 mute;
} N106_WM;

typedef struct {
	uint32 cps;
	uint32 mastervolume;

	N106_WM ch[8];

	uint8 addressauto;
	uint8 address;
	uint8 chinuse;

	uint32 tone[0x100];	/* TONE DATA */
	uint8 data[0x80];
} N106SOUND;

// ----------------------------------------------------------------------------
// FME7 Sound struct

typedef struct {
	uint32 cps;
	int32 cycles;
	uint32 spd;
	uint8 regs[3];
	uint8 update;
	uint8 adr;
	uint8 mute;
	uint8 key;
} PSG_SQUARE;

typedef struct {
	uint32 cps;
	int32 cycles;
	uint32 spd;
	uint32 noiserng;
	uint8 regs[1];
	uint8 update;
	uint8 noiseout;
} PSG_NOISE;

typedef struct {
	uint32 cps;
	int32 cycles;
	uint32 spd;
	uint32 envout;
	int8 *adr;
	uint8 regs[3];
	uint8 update;
} PSG_ENVELOPE;

typedef struct {
	PSG_SQUARE square[3];
	PSG_ENVELOPE envelope;
	PSG_NOISE noise;
	uint32 mastervolume;
	uint32 adr;
} PSGSOUND;

// ----------------------------------------------------------------------------
// APU Sound struct

enum
{
   APU_FILTER_NONE,
   APU_FILTER_LOWPASS,
   APU_FILTER_WEIGHTED
};

#ifdef APU_YANO
enum
{
   APUMODE_IDEAL_TRIANGLE,
   APUMODE_SMOOTH_ENVELOPE,
   APUMODE_SMOOTH_SWEEP
};
#endif /* APU_YANO */

typedef struct
{
   uint32 min_range, max_range;
   uint8 (*read_func)(uint32 address);
} apu_memread;

typedef struct
{
   uint32 min_range, max_range;
   void (*write_func)(uint32 address, uint8 value);
} apu_memwrite;

/* external sound chip stuff */
typedef struct apuext_s
{
   void  (*init)(void);
   void  (*shutdown)(void);
   void  (*reset)(void);
   int32 (*process)(void);
   apu_memread *mem_read;
   apu_memwrite *mem_write;
} apuext_t;


/* APU queue structure */
#define  APUQUEUE_SIZE  4096
#define  APUQUEUE_MASK  (APUQUEUE_SIZE - 1)

/* apu ring buffer member */
typedef struct apudata_s
{
   uint32 timestamp, address;
   uint8 value;
} apudata_t;

/* Added by Rick */
typedef struct apuqueue_s
{
	int q_head, q_tail;
	apudata_t queue[APUQUEUE_SIZE];
} apuqueue_t;

typedef struct apu_s
{
   APUSOUND apus;
   VRC6SOUND vrc6s;
   OPLLSOUND ym2413s;
   FDSSOUND fdssound;
   MMC5SOUND mmc5;
   N106SOUND n106s;
   PSGSOUND psg;

   uint8 enable_reg;
   uint8 enable_reg_cur;

   //apudata_t queue[APUQUEUE_SIZE];
   //int q_head, q_tail;
   apuqueue_t queue;

   // for ExSound
   //apudata_t ex_queue[APUQUEUE_SIZE];
   //int ex_q_head, ex_q_tail;
   apuqueue_t ex_queue;
   uint8 ex_chip;

   uint32 elapsed_cycles;

   void *buffer; /* pointer to output buffer */
   int num_samples;

   boolean mix_enable[6];
   int filter_type;

   int32 cycle_rate;

   int sample_rate;
   int sample_bits;
   int refresh_rate;

   void (*process)(void *buffer, int num_samples);

   /* external sound chip */
   apuext_t *ext;
} apu_t;


#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/* Function prototypes */
extern apu_t *apu_getcontext(void);
extern void apu_setcontext(apu_t *src_apu);

extern apu_t *apu_create(int sample_rate, int refresh_rate, int frag_size,
                         int sample_bits);
extern void apu_destroy(apu_t **apu);
extern void apu_setparams(int sample_rate, int refresh_rate, int frag_size,
                          int sample_bits);

extern void apu_process(void *buffer, int num_samples);
extern void apu_reset(void);

extern void apu_setext(apu_t *apu, apuext_t *ext);
extern void apu_setfilter(int filter_type);
extern void apu_setchan(int chan, boolean enabled);
#ifdef APU_YANO
extern void apu_setmode(int item, int mode);
#endif /* APU_YANO */

extern uint8 apu_read(uint32 address);
extern void apu_write(uint32 address, uint8 value);

extern uint8 ex_read(uint32 address);
extern void ex_write(uint32 address, uint8 value);

extern void apu_write_cur(uint32 address, uint8 value);
extern void sync_apu_register();
extern boolean sync_dmc_register(uint32 cpu_cycles);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /* _NES_APU_H_ */

/*
** $Log: nes_apu.h,v $
** Revision 1.3  2003/06/22 08:30:13  Rick
** minor speed-ups
**
** Revision 1.2  2003/03/24 14:40:29  Rick
** replaced APU code with uonester's one
**
** Revision 2.16  2001/02/18 21:31:00  YANO, takashi
** added $4017:bit7 control
** fixed set chan->enabled
** fixed bug of DPCM last sample in APU_YANO
** trim channel balance again
** fixed APU_BASEFREQ
**
** Revision 2.15  2001/01/04 22:09:10  YANO, takashi
** fixed dmc bug of delta_bit
**
** Revision 2.14  2001/01/03 17:46:00  YANO, takashi
** fixed code for DC balance
** trim noise and dmc volume
**
** Revision 2.13  2000/12/23 02:00:40  YANO, takashi
** added apu_setmode()
**
** Revision 2.12  2000/12/22 23:23:40  YANO, takashi
** trim output volume balance
** re-disabled APU_IDEAL_TRIANGLE
** modify weighted filter
**
** Revision 2.11  2000/12/17 00:08:10  YANO, takashi
** cancel DC offset
** enable APU_IDEAL_TRIANGLE
**
** Revision 2.10  2000/12/12 02:07:46  YANO, takashi
** improve sound purity
**
** Revision 2.09  2000/12/09 11:41:00  TAKEDA, toshiya
** sync DPCM registers
** support DMCP IRQ
**
** Revision 2.08  2000/12/07 00:10:00  TAKEDA, toshiya
** sync DPCM registers
**
** Revision 2.07  2000/11/15 16:32:00  TAKEDA, toshiya
** fixed memory reak of ExtraSound
**
** Revision 2.06  2000/11/02 21:40:00  TAKEDA, toshiya
** fixed read $4015 (triangle.write_latency)
**
** Revision 2.05  2000/11/01 21:44:00  TAKEDA, toshiya
** fixed read $4015
**
** Revision 2.04  2000/10/26 00:05:00  TAKEDA, toshiya
** changed VRC6 volume
** changed chip number
**
** Revision 2.03  2000/10/23 16:06:00  TAKEDA, toshiya
** added ExtraSound Support of MMC5
** sync All ExtraSound
**
** Revision 2.02  2000/10/23 00:07:00  TAKEDA, toshiya
** fixed VRC6 write reg
**
** Revision 2.01  2000/10/22 21:12:00  TAKEDA, toshiya
** added ExtraSound Support of FME7
**
** Revision 2.00  2000/10/22 00:12:15  TAKEDA, toshiya
** added ExtraSound Support of N106, FDS, VRC6, VRC7
**
** ---------------------------------------------------
**
** Revision 1.21  2000/08/11 02:27:21  matt
** general cleanups, plus apu_setparams routine
**
** Revision 1.20  2000/07/30 04:32:59  matt
** no more apu_getcyclerate hack
**
** Revision 1.19  2000/07/27 02:49:50  matt
** eccentricity in sweeping hardware now emulated correctly
**
** Revision 1.18  2000/07/25 02:25:15  matt
** safer apu_destroy
**
** Revision 1.17  2000/07/23 15:10:54  matt
** hacks for win32
**
** Revision 1.16  2000/07/23 00:48:15  neil
** Win32 SDL
**
** Revision 1.15  2000/07/17 01:52:31  matt
** made sure last line of all source files is a newline
**
** Revision 1.14  2000/07/11 02:39:26  matt
** added setcontext() routine
**
** Revision 1.13  2000/07/10 05:29:34  matt
** moved joypad/oam dma from apu to ppu
**
** Revision 1.12  2000/07/04 04:54:48  matt
** minor changes that helped with MAME
**
** Revision 1.11  2000/07/03 02:18:53  matt
** much better external module exporting
**
** Revision 1.10  2000/06/26 05:00:37  matt
** cleanups
**
** Revision 1.9  2000/06/23 03:29:28  matt
** cleaned up external sound inteface
**
** Revision 1.8  2000/06/20 04:06:16  matt
** migrated external sound definition to apu module
**
** Revision 1.7  2000/06/20 00:07:35  matt
** added convenience members to apu_t struct
**
** Revision 1.6  2000/06/09 16:49:02  matt
** removed all floating point from sound generation
**
** Revision 1.5  2000/06/09 15:12:28  matt
** initial revision
**
*/

⌨️ 快捷键说明

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