diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
tree | 9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libgme/nes_mmc5_apu.h | |
parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/libgme/nes_mmc5_apu.h')
-rw-r--r-- | lib/rbcodec/codecs/libgme/nes_mmc5_apu.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/nes_mmc5_apu.h b/lib/rbcodec/codecs/libgme/nes_mmc5_apu.h new file mode 100644 index 0000000000..b696b49e97 --- /dev/null +++ b/lib/rbcodec/codecs/libgme/nes_mmc5_apu.h | |||
@@ -0,0 +1,61 @@ | |||
1 | // NES MMC5 sound chip emulator | ||
2 | |||
3 | // Nes_Snd_Emu 0.2.0-pre | ||
4 | #ifndef NES_MMC5_APU_H | ||
5 | #define NES_MMC5_APU_H | ||
6 | |||
7 | #include "blargg_common.h" | ||
8 | #include "nes_apu.h" | ||
9 | |||
10 | enum { mmc5_regs_addr = 0x5000 }; | ||
11 | enum { mmc5_regs_size = 0x16 }; | ||
12 | enum { mmc5_osc_count = 3 }; | ||
13 | enum { mmc5_exram_size = 1024 }; | ||
14 | |||
15 | struct Nes_Mmc5_Apu { | ||
16 | struct Nes_Apu apu; | ||
17 | unsigned char exram [mmc5_exram_size]; | ||
18 | }; | ||
19 | |||
20 | static inline void Mmc5_init( struct Nes_Mmc5_Apu* this ) | ||
21 | { | ||
22 | Apu_init( &this->apu ); | ||
23 | } | ||
24 | |||
25 | static inline void Mmc5_set_output( struct Nes_Mmc5_Apu* this, int i, struct Blip_Buffer* b ) | ||
26 | { | ||
27 | // in: square 1, square 2, PCM | ||
28 | // out: square 1, square 2, skipped, skipped, PCM | ||
29 | if ( i > 1 ) | ||
30 | i += 2; | ||
31 | Apu_osc_output( &this->apu, i, b ); | ||
32 | } | ||
33 | |||
34 | static inline void Mmc5_write_register( struct Nes_Mmc5_Apu* this, blip_time_t time, unsigned addr, int data ) | ||
35 | { | ||
36 | switch ( addr ) | ||
37 | { | ||
38 | case 0x5015: // channel enables | ||
39 | data &= 0x03; // enable the square waves only | ||
40 | // fall through | ||
41 | case 0x5000: // Square 1 | ||
42 | case 0x5002: | ||
43 | case 0x5003: | ||
44 | case 0x5004: // Square 2 | ||
45 | case 0x5006: | ||
46 | case 0x5007: | ||
47 | case 0x5011: // DAC | ||
48 | Apu_write_register( &this->apu, time, addr - 0x1000, data ); | ||
49 | break; | ||
50 | |||
51 | case 0x5010: // some things write to this for some reason | ||
52 | break; | ||
53 | |||
54 | #ifdef BLARGG_DEBUG_H | ||
55 | default: | ||
56 | dprintf( "Unmapped MMC5 APU write: $%04X <- $%02X\n", addr, data ); | ||
57 | #endif | ||
58 | } | ||
59 | } | ||
60 | |||
61 | #endif | ||