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/emu2413.h | |
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/emu2413.h')
-rw-r--r-- | apps/codecs/libgme/emu2413.h | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/apps/codecs/libgme/emu2413.h b/apps/codecs/libgme/emu2413.h new file mode 100644 index 0000000000..9ee4513ff3 --- /dev/null +++ b/apps/codecs/libgme/emu2413.h | |||
@@ -0,0 +1,164 @@ | |||
1 | #ifndef _EMU2413_H_ | ||
2 | #define _EMU2413_H_ | ||
3 | |||
4 | #include "blargg_common.h" | ||
5 | #include "emutypes.h" | ||
6 | |||
7 | #ifdef EMU2413_DLL_EXPORTS | ||
8 | #define EMU2413_API __declspec(dllexport) | ||
9 | #elif defined(EMU2413_DLL_IMPORTS) | ||
10 | #define EMU2413_API __declspec(dllimport) | ||
11 | #else | ||
12 | #define EMU2413_API | ||
13 | #endif | ||
14 | |||
15 | #ifdef __cplusplus | ||
16 | extern "C" { | ||
17 | #endif | ||
18 | |||
19 | #define AUDIO_MONO_BUFFER_SIZE 1024 | ||
20 | |||
21 | #define PI 3.14159265358979323846 | ||
22 | |||
23 | enum OPLL_TONE_ENUM {OPLL_2413_TONE=0, OPLL_VRC7_TONE=1, OPLL_281B_TONE=2} ; | ||
24 | |||
25 | /* voice data */ | ||
26 | typedef struct __OPLL_PATCH { | ||
27 | e_uint32 TL,FB,EG,ML,AR,DR,SL,RR,KR,KL,AM,PM,WF ; | ||
28 | } OPLL_PATCH ; | ||
29 | |||
30 | /* slot */ | ||
31 | typedef struct __OPLL_SLOT { | ||
32 | |||
33 | OPLL_PATCH *patch; | ||
34 | |||
35 | e_int32 type ; /* 0 : modulator 1 : carrier */ | ||
36 | |||
37 | /* OUTPUT */ | ||
38 | e_int32 feedback ; | ||
39 | e_int32 output[2] ; /* Output value of slot */ | ||
40 | |||
41 | /* for Phase Generator (PG) */ | ||
42 | e_uint16 *sintbl ; /* Wavetable */ | ||
43 | e_uint32 phase ; /* Phase */ | ||
44 | e_uint32 dphase ; /* Phase increment amount */ | ||
45 | e_uint32 pgout ; /* output */ | ||
46 | |||
47 | /* for Envelope Generator (EG) */ | ||
48 | e_int32 fnum ; /* F-Number */ | ||
49 | e_int32 block ; /* Block */ | ||
50 | e_int32 volume ; /* Current volume */ | ||
51 | e_int32 sustine ; /* Sustine 1 = ON, 0 = OFF */ | ||
52 | e_uint32 tll ; /* Total Level + Key scale level*/ | ||
53 | e_uint32 rks ; /* Key scale offset (Rks) */ | ||
54 | e_int32 eg_mode ; /* Current state */ | ||
55 | e_uint32 eg_phase ; /* Phase */ | ||
56 | e_uint32 eg_dphase ; /* Phase increment amount */ | ||
57 | e_uint32 egout ; /* output */ | ||
58 | |||
59 | } OPLL_SLOT ; | ||
60 | |||
61 | /* Mask */ | ||
62 | #define OPLL_MASK_CH(x) (1<<(x)) | ||
63 | #define OPLL_MASK_HH (1<<(9)) | ||
64 | #define OPLL_MASK_CYM (1<<(10)) | ||
65 | #define OPLL_MASK_TOM (1<<(11)) | ||
66 | #define OPLL_MASK_SD (1<<(12)) | ||
67 | #define OPLL_MASK_BD (1<<(13)) | ||
68 | #define OPLL_MASK_RHYTHM ( OPLL_MASK_HH | OPLL_MASK_CYM | OPLL_MASK_TOM | OPLL_MASK_SD | OPLL_MASK_BD ) | ||
69 | |||
70 | /* opll */ | ||
71 | typedef struct __OPLL { | ||
72 | |||
73 | e_uint32 adr ; | ||
74 | e_int32 out ; | ||
75 | |||
76 | #ifndef EMU2413_COMPACTION | ||
77 | e_uint32 realstep ; | ||
78 | e_uint32 oplltime ; | ||
79 | e_uint32 opllstep ; | ||
80 | e_int32 prev, next ; | ||
81 | e_int32 sprev[2],snext[2]; | ||
82 | e_uint32 pan[16]; | ||
83 | #endif | ||
84 | |||
85 | /* Register */ | ||
86 | e_uint8 reg[0x40] ; | ||
87 | e_int32 slot_on_flag[18] ; | ||
88 | |||
89 | /* Pitch Modulator */ | ||
90 | e_uint32 pm_phase ; | ||
91 | e_int32 lfo_pm ; | ||
92 | |||
93 | /* Amp Modulator */ | ||
94 | e_int32 am_phase ; | ||
95 | e_int32 lfo_am ; | ||
96 | |||
97 | e_uint32 quality; | ||
98 | |||
99 | /* Noise Generator */ | ||
100 | e_uint32 noise_seed ; | ||
101 | |||
102 | /* Channel Data */ | ||
103 | e_int32 patch_number[9]; | ||
104 | e_int32 key_status[9] ; | ||
105 | |||
106 | /* Slot */ | ||
107 | OPLL_SLOT slot[18] ; | ||
108 | |||
109 | /* Voice Data */ | ||
110 | OPLL_PATCH patch[19*2] ; | ||
111 | e_int32 patch_update[2] ; /* flag for check patch update */ | ||
112 | |||
113 | e_uint32 mask ; | ||
114 | e_uint32 current_mask; | ||
115 | e_uint32 status; | ||
116 | |||
117 | e_uint32 internal_mute; | ||
118 | e_int16 buffer[AUDIO_MONO_BUFFER_SIZE]; | ||
119 | } OPLL ; | ||
120 | |||
121 | /* Create Object */ | ||
122 | EMU2413_API void OPLL_new(OPLL *, e_uint32 clk, e_uint32 rate) ; | ||
123 | EMU2413_API void OPLL_delete(OPLL *) ; | ||
124 | |||
125 | /* Setup */ | ||
126 | EMU2413_API void OPLL_reset(OPLL *) ; | ||
127 | EMU2413_API void OPLL_reset_patch(OPLL *, e_int32) ; | ||
128 | EMU2413_API void OPLL_set_rate(OPLL *opll, e_uint32 r) ; | ||
129 | EMU2413_API void OPLL_set_quality(OPLL *opll, e_uint32 q) ; | ||
130 | EMU2413_API void OPLL_set_pan(OPLL *, e_uint32 ch, e_uint32 pan); | ||
131 | EMU2413_API void OPLL_set_internal_mute(OPLL *, e_uint32 mute); | ||
132 | EMU2413_API e_uint32 OPLL_is_internal_muted(OPLL *); | ||
133 | |||
134 | /* Port/Register access */ | ||
135 | EMU2413_API void OPLL_writeIO(OPLL *, e_uint32 reg, e_uint32 val); ICODE_ATTR | ||
136 | EMU2413_API void OPLL_writeReg(OPLL *, e_uint32 reg, e_uint32 val); ICODE_ATTR | ||
137 | EMU2413_API e_uint32 OPLL_read(OPLL *, e_uint32 port); | ||
138 | |||
139 | /* Synthsize */ | ||
140 | EMU2413_API e_int16 OPLL_calc(OPLL *) ; ICODE_ATTR | ||
141 | EMU2413_API void OPLL_calc_stereo(OPLL *, e_int32 out[2]) ; ICODE_ATTR | ||
142 | EMU2413_API e_int16 *OPLL_update_buffer(OPLL *, e_uint32 length) ; ICODE_ATTR | ||
143 | |||
144 | /* Misc */ | ||
145 | EMU2413_API void OPLL_setPatch(OPLL *, const e_uint8 *dump) ; | ||
146 | EMU2413_API void OPLL_copyPatch(OPLL *, e_int32, OPLL_PATCH *) ; | ||
147 | EMU2413_API void OPLL_forceRefresh(OPLL *) ; | ||
148 | /* Utility */ | ||
149 | EMU2413_API void OPLL_dump2patch(const e_uint8 *dump, OPLL_PATCH *patch) ; | ||
150 | EMU2413_API void OPLL_patch2dump(const OPLL_PATCH *patch, e_uint8 *dump) ; | ||
151 | EMU2413_API void OPLL_getDefaultPatch(e_int32 type, e_int32 num, OPLL_PATCH *) ; | ||
152 | |||
153 | /* Channel Mask */ | ||
154 | EMU2413_API e_uint32 OPLL_setMask(OPLL *, e_uint32 mask) ; | ||
155 | EMU2413_API e_uint32 OPLL_toggleMask(OPLL *, e_uint32 mask) ; | ||
156 | |||
157 | #define dump2patch OPLL_dump2patch | ||
158 | |||
159 | #ifdef __cplusplus | ||
160 | } | ||
161 | #endif | ||
162 | |||
163 | #endif | ||
164 | |||