What's the most basic way to get anything out of the 32x sound?
I've got the same commonly used init code.
Code: Select all
#define SAMPLE_RATE 22050
#define SAMPLE_MIN 2
#define SAMPLE_CENTER 517
#define SAMPLE_MAX 1032
// init the sound hardware
MARS_PWM_MONO = 1;
MARS_PWM_MONO = 1;
MARS_PWM_MONO = 1;
if (MARS_VDP_DISPMODE & MARS_NTSC_FORMAT)
MARS_PWM_CYCLE = (((23011361 << 1) / (SAMPLE_RATE) + 1) >> 1) + 1; // for NTSC clock
else
MARS_PWM_CYCLE = (((22801467 << 1) / (SAMPLE_RATE) + 1) >> 1) + 1; // for PAL clock
MARS_PWM_CTRL = 0x0185; // TM = 1, RTP, RMD = right, LMD = left
unsigned short sample = SAMPLE_MIN;
unsigned short ix;
// ramp up to SAMPLE_CENTER to avoid click in audio (real 32X)
while (sample < SAMPLE_CENTER)
{
for (ix = 0; ix < (SAMPLE_RATE * 2) / (SAMPLE_CENTER - SAMPLE_MIN); ix++)
{
while (MARS_PWM_MONO & 0x8000); // wait while full
MARS_PWM_MONO = sample;
}
sample++;
}
Code: Select all
void main ()
{
while (1)
{
// somehow feed a tone to the audio hardware
// set something to MARS_PWM_MONO, maybe?
}
}
![Smile :)](./images/smilies/icon_smile.gif)