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/gb_apu.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/gb_apu.h')
-rw-r--r-- | apps/codecs/libgme/gb_apu.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/apps/codecs/libgme/gb_apu.h b/apps/codecs/libgme/gb_apu.h new file mode 100644 index 0000000000..f1457a2bbe --- /dev/null +++ b/apps/codecs/libgme/gb_apu.h | |||
@@ -0,0 +1,85 @@ | |||
1 | // Nintendo Game Boy sound hardware emulator with save state support | ||
2 | |||
3 | // Gb_Snd_Emu 0.1.4 | ||
4 | #ifndef GB_APU_H | ||
5 | #define GB_APU_H | ||
6 | |||
7 | #include "gb_oscs.h" | ||
8 | |||
9 | // Clock rate sound hardware runs at | ||
10 | enum { clock_rate = 4194304 * GB_APU_OVERCLOCK }; | ||
11 | |||
12 | // Registers are at io_addr to io_addr+io_size-1 | ||
13 | enum { io_addr = 0xFF10 }; | ||
14 | enum { io_size = 0x30 }; | ||
15 | enum { regs_size = io_size + 0x10 }; | ||
16 | |||
17 | enum gb_mode_t { | ||
18 | mode_dmg, // Game Boy monochrome | ||
19 | mode_cgb, // Game Boy Color | ||
20 | mode_agb // Game Boy Advance | ||
21 | }; | ||
22 | |||
23 | // 0: Square 1, 1: Square 2, 2: Wave, 3: Noise | ||
24 | enum { osc_count = 4 }; // 0 <= chan < osc_count | ||
25 | |||
26 | struct Gb_Apu { | ||
27 | struct Gb_Osc* oscs [osc_count]; | ||
28 | blip_time_t last_time; // time sound emulator has been run to | ||
29 | blip_time_t frame_period; // clocks between each frame sequencer step | ||
30 | double volume_; | ||
31 | bool reduce_clicks_; | ||
32 | |||
33 | struct Gb_Square square1; | ||
34 | struct Gb_Square square2; | ||
35 | struct Gb_Wave wave; | ||
36 | struct Gb_Noise noise; | ||
37 | blip_time_t frame_time; // time of next frame sequencer action | ||
38 | int frame_phase; // phase of next frame sequencer step | ||
39 | |||
40 | uint8_t regs [regs_size];// last values written to registers | ||
41 | |||
42 | // large objects after everything else | ||
43 | struct Blip_Synth synth; | ||
44 | }; | ||
45 | |||
46 | // Basics | ||
47 | |||
48 | // Initializes apu | ||
49 | void Apu_init( struct Gb_Apu* this ); | ||
50 | |||
51 | // Emulates to time t, then writes data to addr | ||
52 | void Apu_write_register( struct Gb_Apu* this, blip_time_t t, int addr, int data ) ICODE_ATTR; | ||
53 | |||
54 | // Emulates to time t, then subtracts t from the current time. | ||
55 | // OK if previous write call had time slightly after t. | ||
56 | void Apu_end_frame( struct Gb_Apu* this,blip_time_t t ) ICODE_ATTR; | ||
57 | |||
58 | // More features | ||
59 | |||
60 | // Emulates to time t, then reads from addr | ||
61 | int Apu_read_register( struct Gb_Apu* this, blip_time_t t, int addr ) ICODE_ATTR; | ||
62 | |||
63 | // Resets hardware to state after power, BEFORE boot ROM runs. Mode selects | ||
64 | // sound hardware. If agb_wave is true, enables AGB's extra wave features. | ||
65 | void Apu_reset( struct Gb_Apu* this, enum gb_mode_t mode, bool agb_wave ); | ||
66 | |||
67 | // Same as set_output(), but for a particular channel | ||
68 | void Apu_set_output( struct Gb_Apu* this, int chan, struct Blip_Buffer* center, | ||
69 | struct Blip_Buffer* left, struct Blip_Buffer* right ); | ||
70 | |||
71 | // Sets overall volume, where 1.0 is normal | ||
72 | void Apu_volume( struct Gb_Apu* this, double v ); | ||
73 | |||
74 | // If true, reduces clicking by disabling DAC biasing. Note that this reduces | ||
75 | // emulation accuracy, since the clicks are authentic. | ||
76 | void Apu_reduce_clicks( struct Gb_Apu* this, bool reduce ); | ||
77 | |||
78 | // Sets frame sequencer rate, where 1.0 is normal. Meant for adjusting the | ||
79 | // tempo in a music player. | ||
80 | void Apu_set_tempo( struct Gb_Apu* this, double t ); | ||
81 | |||
82 | |||
83 | void write_osc( struct Gb_Apu* this, int reg, int old_data, int data ) ICODE_ATTR; | ||
84 | |||
85 | #endif | ||