Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void
- HandleNoiseMusic()
- {
- u8 a, y, x;
- // The underground and castle music do not use the noise channel. This bitmask is used
- // to check if either of these are the active music
- u8 const NO_NOISE_DATA_MASK = MUSIC_Underground | MUSIC_Castle;
- if ( !( AreaMusicBuffer & (u8)~NO_NOISE_DATA_MASK ) )
- return;
- if ( --Noise_BeatLenCounter == 0 )
- {
- for ( ; ; )
- {
- y = MusicOffset_Noise++;
- a = MusicData[y];
- if ( a != 0 ) // If not end of noise data
- break;
- MusicOffset_Noise = NoiseDataLoopbackOfs;
- }
- x = a;
- Noise_BeatLenCounter = AlternateLengthHandler( a );
- a &= 0b00111110;
- // Hihat
- if ( a == 0x30 )
- {
- a = 0x1c;
- x = 0x03;
- y = 0x58;
- }
- // Kick
- else if ( a == 0x20 )
- {
- a = 0x1c;
- x = 0x0c;
- y = 0x18;
- }
- // Snare
- else if ( a & 0x10 )
- {
- a = 0x1c;
- x = 0x03;
- y = 0x18;
- }
- // Rest (X and Y are not written to since the value in A will silence the channel)
- else
- a = 0x10;
- write_apu_reg( NOIVOL, a );
- write_apu_reg( NOIFREQ, x );
- write_apu_reg( NOILEN, y );
- }
- }
Add Comment
Please, Sign In to add comment