GBDK sound example

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
jp48
Posts: 45
Joined: Sun Mar 07, 2010 7:15 am
Location: Kitee, North Karelia, Finland
Contact:

GBDK sound example

Post by jp48 »

Hi all,

I'm complete novice with GB programming, I'm only trying to work with sound and keypads. Anyway, I haven't seen any other examples in GBDK package than sound.c, don't understand it, could someone send here a simpler example like:

just one sound, any frequency, duty cycle 25% on first channel, duration 1 second

and perhaps instructions what is needed to use two other channels and noise channel.

I would be eternally grateful, thanks for advance !

-jp
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

Something like this:

Code: Select all

unsigned short freq = 1750;  // approx 440 Hz

NR50 = 0xFF;
NR51 = 0xFF;
NR52 = 0x80;
 
NR10 = 0;         // No frequency sweep
NR11 = 0x40;   // 25% duty cycle
NR12 = 0xF0;   // Maximum volume
NR13 = (unsigned char)freq;
NR14 = 0x80 | (freq>>8); // Start output

// Wait for as long as you want to output sound..

// Mute channel 1 (there are other ways to do this)
NR12 = 0;
NR14 = 0x80;
Refer to pandocs for more info.
jp48
Posts: 45
Joined: Sun Mar 07, 2010 7:15 am
Location: Kitee, North Karelia, Finland
Contact:

Post by jp48 »

Thanks very much, now I will check documents for addresses to other channels, yes, I'm eternally grateful, thanks mic_ !!!


-Jukka


mic_ wrote:Something like this:

Code: Select all

unsigned short freq = 1750;  // approx 440 Hz

NR50 = 0xFF;
NR51 = 0xFF;
NR52 = 0x80;
 
NR10 = 0;         // No frequency sweep
NR11 = 0x40;   // 25% duty cycle
NR12 = 0xF0;   // Maximum volume
NR13 = (unsigned char)freq;
NR14 = 0x80 | (freq>>8); // Start output

// Wait for as long as you want to output sound..

// Mute channel 1 (there are other ways to do this)
NR12 = 0;
NR14 = 0x80;
Refer to pandocs for more info.
Post Reply