rlm@0
|
1 /* SNES SPC-700 DSP emulator C interface (also usable from C++) */
|
rlm@0
|
2
|
rlm@0
|
3 /* snes_spc 0.9.0 */
|
rlm@0
|
4 #ifndef DSP_H
|
rlm@0
|
5 #define DSP_H
|
rlm@0
|
6
|
rlm@0
|
7 #include <stddef.h>
|
rlm@0
|
8
|
rlm@0
|
9 #ifdef __cplusplus
|
rlm@0
|
10 extern "C" {
|
rlm@0
|
11 #endif
|
rlm@0
|
12
|
rlm@0
|
13 typedef struct SPC_DSP SPC_DSP;
|
rlm@0
|
14
|
rlm@0
|
15 /* Creates new DSP emulator. NULL if out of memory. */
|
rlm@0
|
16 SPC_DSP* spc_dsp_new( void );
|
rlm@0
|
17
|
rlm@0
|
18 /* Frees DSP emulator */
|
rlm@0
|
19 void spc_dsp_delete( SPC_DSP* );
|
rlm@0
|
20
|
rlm@0
|
21 /* Initializes DSP and has it use the 64K RAM provided */
|
rlm@0
|
22 void spc_dsp_init( SPC_DSP*, void* ram_64k );
|
rlm@0
|
23
|
rlm@0
|
24 /* Sets destination for output samples. If out is NULL or out_size is 0,
|
rlm@0
|
25 doesn't generate any. */
|
rlm@0
|
26 typedef short spc_dsp_sample_t;
|
rlm@0
|
27 void spc_dsp_set_output( SPC_DSP*, spc_dsp_sample_t* out, int out_size );
|
rlm@0
|
28
|
rlm@0
|
29 /* Number of samples written to output since it was last set, always
|
rlm@0
|
30 a multiple of 2. Undefined if more samples were generated than
|
rlm@0
|
31 output buffer could hold. */
|
rlm@0
|
32 int spc_dsp_sample_count( SPC_DSP const* );
|
rlm@0
|
33
|
rlm@0
|
34
|
rlm@0
|
35 /**** Emulation *****/
|
rlm@0
|
36
|
rlm@0
|
37 /* Resets DSP to power-on state */
|
rlm@0
|
38 void spc_dsp_reset( SPC_DSP* );
|
rlm@0
|
39
|
rlm@0
|
40 /* Emulates pressing reset switch on SNES */
|
rlm@0
|
41 void spc_dsp_soft_reset( SPC_DSP* );
|
rlm@0
|
42
|
rlm@0
|
43 /* Reads/writes DSP registers. For accuracy, you must first call spc_dsp_run() */
|
rlm@0
|
44 /* to catch the DSP up to present. */
|
rlm@0
|
45 int spc_dsp_read ( SPC_DSP const*, int addr );
|
rlm@0
|
46 void spc_dsp_write( SPC_DSP*, int addr, int data );
|
rlm@0
|
47
|
rlm@0
|
48 /* Runs DSP for specified number of clocks (~1024000 per second). Every 32 clocks */
|
rlm@0
|
49 /* a pair of samples is be generated. */
|
rlm@0
|
50 void spc_dsp_run( SPC_DSP*, int clock_count );
|
rlm@0
|
51
|
rlm@0
|
52
|
rlm@0
|
53 /**** Sound control *****/
|
rlm@0
|
54
|
rlm@0
|
55 /* Mutes voices corresponding to non-zero bits in mask. Reduces emulation accuracy. */
|
rlm@0
|
56 enum { spc_dsp_voice_count = 8 };
|
rlm@0
|
57 void spc_dsp_mute_voices( SPC_DSP*, int mask );
|
rlm@0
|
58
|
rlm@0
|
59 /* If true, prevents channels and global volumes from being phase-negated.
|
rlm@0
|
60 Only supported by fast DSP; has no effect on accurate DSP. */
|
rlm@0
|
61 void spc_dsp_disable_surround( SPC_DSP*, int disable );
|
rlm@0
|
62
|
rlm@0
|
63
|
rlm@0
|
64 /**** State save/load *****/
|
rlm@0
|
65
|
rlm@0
|
66 /* Resets DSP and uses supplied values to initialize registers */
|
rlm@0
|
67 enum { spc_dsp_register_count = 128 };
|
rlm@0
|
68 void spc_dsp_load( SPC_DSP*, unsigned char const regs [spc_dsp_register_count] );
|
rlm@0
|
69
|
rlm@0
|
70 /* Saves/loads exact emulator state (accurate DSP only) */
|
rlm@0
|
71 enum { spc_dsp_state_size = 640 }; /* maximum space needed when saving */
|
rlm@0
|
72 typedef void (*spc_dsp_copy_func_t)( unsigned char** io, void* state, size_t );
|
rlm@0
|
73 void spc_dsp_copy_state( SPC_DSP*, unsigned char** io, spc_dsp_copy_func_t );
|
rlm@0
|
74
|
rlm@0
|
75 /* Returns non-zero if new key-on events occurred since last call (accurate DSP only) */
|
rlm@0
|
76 int spc_dsp_check_kon( SPC_DSP* );
|
rlm@0
|
77
|
rlm@0
|
78
|
rlm@0
|
79 #ifdef __cplusplus
|
rlm@0
|
80 }
|
rlm@0
|
81 #endif
|
rlm@0
|
82
|
rlm@0
|
83 #endif
|