Mercurial > spc_convert
diff snes_spc/dsp.h @ 0:e38dacceb958
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 21 Oct 2011 05:53:11 -0700 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/snes_spc/dsp.h Fri Oct 21 05:53:11 2011 -0700 1.3 @@ -0,0 +1,83 @@ 1.4 +/* SNES SPC-700 DSP emulator C interface (also usable from C++) */ 1.5 + 1.6 +/* snes_spc 0.9.0 */ 1.7 +#ifndef DSP_H 1.8 +#define DSP_H 1.9 + 1.10 +#include <stddef.h> 1.11 + 1.12 +#ifdef __cplusplus 1.13 + extern "C" { 1.14 +#endif 1.15 + 1.16 +typedef struct SPC_DSP SPC_DSP; 1.17 + 1.18 +/* Creates new DSP emulator. NULL if out of memory. */ 1.19 +SPC_DSP* spc_dsp_new( void ); 1.20 + 1.21 +/* Frees DSP emulator */ 1.22 +void spc_dsp_delete( SPC_DSP* ); 1.23 + 1.24 +/* Initializes DSP and has it use the 64K RAM provided */ 1.25 +void spc_dsp_init( SPC_DSP*, void* ram_64k ); 1.26 + 1.27 +/* Sets destination for output samples. If out is NULL or out_size is 0, 1.28 +doesn't generate any. */ 1.29 +typedef short spc_dsp_sample_t; 1.30 +void spc_dsp_set_output( SPC_DSP*, spc_dsp_sample_t* out, int out_size ); 1.31 + 1.32 +/* Number of samples written to output since it was last set, always 1.33 +a multiple of 2. Undefined if more samples were generated than 1.34 +output buffer could hold. */ 1.35 +int spc_dsp_sample_count( SPC_DSP const* ); 1.36 + 1.37 + 1.38 +/**** Emulation *****/ 1.39 + 1.40 +/* Resets DSP to power-on state */ 1.41 +void spc_dsp_reset( SPC_DSP* ); 1.42 + 1.43 +/* Emulates pressing reset switch on SNES */ 1.44 +void spc_dsp_soft_reset( SPC_DSP* ); 1.45 + 1.46 +/* Reads/writes DSP registers. For accuracy, you must first call spc_dsp_run() */ 1.47 +/* to catch the DSP up to present. */ 1.48 +int spc_dsp_read ( SPC_DSP const*, int addr ); 1.49 +void spc_dsp_write( SPC_DSP*, int addr, int data ); 1.50 + 1.51 +/* Runs DSP for specified number of clocks (~1024000 per second). Every 32 clocks */ 1.52 +/* a pair of samples is be generated. */ 1.53 +void spc_dsp_run( SPC_DSP*, int clock_count ); 1.54 + 1.55 + 1.56 +/**** Sound control *****/ 1.57 + 1.58 +/* Mutes voices corresponding to non-zero bits in mask. Reduces emulation accuracy. */ 1.59 +enum { spc_dsp_voice_count = 8 }; 1.60 +void spc_dsp_mute_voices( SPC_DSP*, int mask ); 1.61 + 1.62 +/* If true, prevents channels and global volumes from being phase-negated. 1.63 +Only supported by fast DSP; has no effect on accurate DSP. */ 1.64 +void spc_dsp_disable_surround( SPC_DSP*, int disable ); 1.65 + 1.66 + 1.67 +/**** State save/load *****/ 1.68 + 1.69 +/* Resets DSP and uses supplied values to initialize registers */ 1.70 +enum { spc_dsp_register_count = 128 }; 1.71 +void spc_dsp_load( SPC_DSP*, unsigned char const regs [spc_dsp_register_count] ); 1.72 + 1.73 +/* Saves/loads exact emulator state (accurate DSP only) */ 1.74 +enum { spc_dsp_state_size = 640 }; /* maximum space needed when saving */ 1.75 +typedef void (*spc_dsp_copy_func_t)( unsigned char** io, void* state, size_t ); 1.76 +void spc_dsp_copy_state( SPC_DSP*, unsigned char** io, spc_dsp_copy_func_t ); 1.77 + 1.78 +/* Returns non-zero if new key-on events occurred since last call (accurate DSP only) */ 1.79 +int spc_dsp_check_kon( SPC_DSP* ); 1.80 + 1.81 + 1.82 +#ifdef __cplusplus 1.83 + } 1.84 +#endif 1.85 + 1.86 +#endif