1 // NES MMC5 sound chip emulator
3 // Nes_Snd_Emu 0.2.0-pre
7 #include "blargg_common.h"
10 enum { mmc5_regs_addr
= 0x5000 };
11 enum { mmc5_regs_size
= 0x16 };
12 enum { mmc5_osc_count
= 3 };
13 enum { mmc5_exram_size
= 1024 };
17 unsigned char exram
[mmc5_exram_size
];
20 static inline void Mmc5_init( struct Nes_Mmc5_Apu
* this )
22 Apu_init( &this->apu
);
25 static inline void Mmc5_set_output( struct Nes_Mmc5_Apu
* this, int i
, struct Blip_Buffer
* b
)
27 // in: square 1, square 2, PCM
28 // out: square 1, square 2, skipped, skipped, PCM
31 Apu_osc_output( &this->apu
, i
, b
);
34 static inline void Mmc5_write_register( struct Nes_Mmc5_Apu
* this, blip_time_t time
, unsigned addr
, int data
)
38 case 0x5015: // channel enables
39 data
&= 0x03; // enable the square waves only
41 case 0x5000: // Square 1
44 case 0x5004: // Square 2
48 Apu_write_register( &this->apu
, time
, addr
- 0x1000, data
);
51 case 0x5010: // some things write to this for some reason
56 dprintf( "Unmapped MMC5 APU write: $%04X <- $%02X\n", addr
, data
);