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