Hi, I wrote this test program, which will be a metronome.
It makes a beep every 3rd of a second.
I'm relying on vertical retrace being 60hz because it's NTSC, as I don't know any other way to measure time in the NES. ( do you? )
It works fine in emulators, but it hangs my PMP after some beeps.
Am I doing something wrong or is just my PMP that is buggy?
It runs most of commercial games very well, although others crash.
PS: I figuerd out how to make sounds somewhat randomly, but it works.
Code: Select all
#include <nes.h>
#define addr(_addr) (*(unsigned char*) (_addr))
void main()
{
unsigned char a = 0;
addr(0x4015) = 1; // init sound
addr(0x4001) = 0;
while(1)
{
waitvblank();
++a;
if( a == 20 )
{
a = 0;
addr(0x4003) = 2; // make a beep
}
}
}