gbsnd.h
来自「ESS3890+SL原代码(1*16内存)」· C头文件 代码 · 共 159 行
H
159 行
/* Copyright 1996, ESS Technology, Inc. *//* SCCSID @(#)gbsnd.h 1.15 03/05/03 *//** VGB: portable GameBoy emulator ***************************//** **//** GBSND.c **//** **//** This file contains definitions and declarations for **//** routines in GBSND.c. **//** **//** Copyright (C) Marat Fayzullin 1995-2001 **//** The contents of this file are property of Marat **//** Fayzullin and should only be used as agreed with **//** him. The file is confidential. Absolutely no **//** distribution allowed. **//*************************************************************/#ifndef GBSND_H#define GBSND_H#define GBSND_BASE 131072 /* Base frequency */#define GBSND_CHANNELS 4 /* Number of channels */#define RECORD_NOTES 8 #define SND_CONSTANT 111861 /* Sound base frequency (Hz) */#define SND_UPDATE 60 /* Sound update frequency (Hz) */#ifndef BYTE_TYPE_DEFINED#define BYTE_TYPE_DEFINEDtypedef unsigned char byte;#endif#ifndef WORD_TYPE_DEFINED#define WORD_TYPE_DEFINEDtypedef unsigned short word;#endif#ifdef VGB/** GBSND ****************************************************//** This data structure stores GameBoy sound chip state. **//*************************************************************/typedef struct{ byte *R; /* Current register contents from FF00h */ /* Sound parameters */ int Count[GBSND_CHANNELS]; /* Counter to the sound's end (ms) */ int Length[GBSND_CHANNELS]; /* Sound length (ms) */ int Freq[GBSND_CHANNELS]; /* Frequency (Hz) */ int Volume[GBSND_CHANNELS]; /* Volume (0..15) */ int ChVolume[GBSND_CHANNELS]; /* Master volume (0..14) */ /* Volume Envelopes */ int VCount[GBSND_CHANNELS]; /* Counter to the next step (ms) */ int VPeriod[GBSND_CHANNELS]; /* Time between steps (ms) */ int VDir[GBSND_CHANNELS]; /* Increment (+1) or decrement (-1) */ /* CH1 Frequency Sweep */ int FCount; /* Counter to the next step (ms) */ int FPeriod; /* Time between steps (ms) */ int FDir; /* Increment (+1) or decrement (-1) */ int FNumber; /* Frequency number 000h-7FFh */ int FStep; /* FNum[t+1]=FNum[t]+FNum[t]/(2^FStep) */ int First; /* First Sound() channel to use */ int rp; int wp; int freq[RECORD_NOTES][GBSND_CHANNELS]; int volume[RECORD_NOTES][GBSND_CHANNELS]; int SOUND_amplify; int lasttimer; int deltatime; int savedvol[GBSND_CHANNELS]; int savedfreq[GBSND_CHANNELS]; int lastvol[GBSND_CHANNELS];} GBSND;GBSND *SNDChip; /* GameBoy sound chip state *//** ResetSND() ***********************************************//** Reset the sound chip and use sound channels from the **//** one given in First. **//*************************************************************/void ResetSND(register GBSND *D,byte *Regs,int First);/** WriteSND() ***********************************************//** Call this function to output a value V into the sound **//** chip register A. **//*************************************************************/byte WriteSND(register GBSND *D,register byte A,register byte V);/** LoopSND() ************************************************//** Call this function periodically to update volume **//** envelopes. Use mS to pass the time since the last call **//** of LoopSND() in milliseconds. **//*************************************************************/int LoopSND(register GBSND *D,int mS);/** SyncSND() ************************************************//** Flush all accumulated changes by issuing Sound() calls **//** and set the synchronization on/off. The second argument **//** should be GBSND_SYNC/GBSND_ASYNC to set/reset sync, or **//** GBSND_FLUSH to leave sync mode as it is. To emulate **//** noise channel with MIDI drums, OR second argument with **//** GBSND_DRUMS. **//*************************************************************/#ifndef CD_GAMEvoid SyncSND();#endif#endif#ifdef INES/* SND structure use GMBY_SNDSTK in memmap.h Total: 200dw Now use: 117dw */typedef struct{ /* Sound parameters */ int Volume[6]; int Freq[6]; /* Sound volumes (0-255) and frequencies (Hz) */ int VSweep[5]; int FSweep[5]; /* Volume and frequency deltas */ int VCount[5]; int FCount[5]; /* Volume envelope and frequency counters */ int VDecay[5]; /* Volume decay */ byte SND[32]; /* Sound chip registers */ int rp; int wp; int freq[RECORD_NOTES][GBSND_CHANNELS]; int volume[RECORD_NOTES][GBSND_CHANNELS]; int SOUND_amplify; int lasttimer; /* use for SoundLoop */ int deltatime; /* use for SoundLoop */ int motor_cnt; /* For TANK game motor sound */ int volume_display; /* For volume bar display */ int volume_display_stime;} NESSND;NESSND *NSNDChip;int *P_Lengths;int *Noise_freq;extern int key0;void SNDOut(register int R,register int V);int SoundLoop(int);#endif/** TrashSound() *********************************************//** Shut down sound. **//*************************************************************/#ifndef CD_GAMEvoid TrashSound(void);int InitSound(int Rate) ;#endif /*CD_GAME*/ #endif /* GBSND_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?