Fix makefile conditions
[maemo-rb.git] / apps / codecs / libgme / nes_mmc5_apu.h
blobb696b49e974f75941933f56f9fe38733cd29af24
1 // NES MMC5 sound chip emulator
3 // Nes_Snd_Emu 0.2.0-pre
4 #ifndef NES_MMC5_APU_H
5 #define NES_MMC5_APU_H
7 #include "blargg_common.h"
8 #include "nes_apu.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 };
15 struct Nes_Mmc5_Apu {
16 struct Nes_Apu apu;
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
29 if ( i > 1 )
30 i += 2;
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 )
36 switch ( addr )
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;
51 case 0x5010: // some things write to this for some reason
52 break;
54 #ifdef BLARGG_DEBUG_H
55 default:
56 dprintf( "Unmapped MMC5 APU write: $%04X <- $%02X\n", addr, data );
57 #endif
61 #endif