diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-07 20:01:04 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-07 20:01:04 +0000 |
commit | acb0917556fc33681c1df5a530cf754193e67705 (patch) | |
tree | 052a47097009a210e4aed9c207bd6aa4828cc000 /apps/codecs/libgme/ym2413_emu.c | |
parent | 93c6f1329a5691a8be158cefe15641bd1daf9ef8 (diff) | |
download | rockbox-acb0917556fc33681c1df5a530cf754193e67705.tar.gz rockbox-acb0917556fc33681c1df5a530cf754193e67705.zip |
Submit initial patch from FS#12176. Adds support for several new game music formats (AY, GBS, HES, KSS, SGC, VGM and VGZ) and replaces the current NSF and NSFE with a new implementation based on a port of the Game Music Emu library 'GME'. This first submit does not cover the full functionality provided by the author's original patch: Coleco-SGV is not supported, some GME-specific m3u-support has been removed and IRAM is not used yet. Further changes are very likely to follow this submit. Thanks to Mauricio Garrido.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30264 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libgme/ym2413_emu.c')
-rw-r--r-- | apps/codecs/libgme/ym2413_emu.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/apps/codecs/libgme/ym2413_emu.c b/apps/codecs/libgme/ym2413_emu.c new file mode 100644 index 0000000000..67870f31dc --- /dev/null +++ b/apps/codecs/libgme/ym2413_emu.c | |||
@@ -0,0 +1,45 @@ | |||
1 | // Game_Music_Emu 0.5.5. http://www.slack.net/~ant/ | ||
2 | |||
3 | #include "ym2413_emu.h" | ||
4 | |||
5 | void Ym2413_init( struct Ym2413_Emu* this ) | ||
6 | { | ||
7 | this->last_time = disabled_time; this->out = 0; | ||
8 | } | ||
9 | |||
10 | int Ym2413_set_rate( struct Ym2413_Emu* this, double sample_rate, double clock_rate ) | ||
11 | { | ||
12 | OPLL_new ( &this->opll, clock_rate, sample_rate ); | ||
13 | OPLL_reset_patch( &this->opll, OPLL_2413_TONE ); | ||
14 | |||
15 | Ym2413_reset( this ); | ||
16 | return 0; | ||
17 | } | ||
18 | |||
19 | void Ym2413_reset( struct Ym2413_Emu* this ) | ||
20 | { | ||
21 | OPLL_reset( &this->opll ); | ||
22 | OPLL_setMask( &this->opll, 0 ); | ||
23 | } | ||
24 | |||
25 | void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ) | ||
26 | { | ||
27 | OPLL_writeIO( &this->opll, 0, addr ); | ||
28 | OPLL_writeIO( &this->opll, 1, data ); | ||
29 | } | ||
30 | |||
31 | void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ) | ||
32 | { | ||
33 | OPLL_setMask( &this->opll, mask ); | ||
34 | } | ||
35 | |||
36 | void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ) | ||
37 | { | ||
38 | while ( pair_count-- ) | ||
39 | { | ||
40 | int s = OPLL_calc( &this->opll ) << 1; | ||
41 | out [0] = s; | ||
42 | out [1] = s; | ||
43 | out += 2; | ||
44 | } | ||
45 | } | ||