mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-23 03:49:26 +01:00
94 lines
1.4 KiB
OpenEdge ABL
94 lines
1.4 KiB
OpenEdge ABL
/*
|
|
* SID_linux.i - 6581 emulation, Linux specific stuff
|
|
*
|
|
* Frodo (C) 1994-1997,2002 Christian Bauer
|
|
* Linux sound stuff by Bernd Schmidt
|
|
*/
|
|
|
|
#include "gcaudio.h"
|
|
|
|
#include "VIC.h"
|
|
|
|
/*
|
|
* Initialization
|
|
*/
|
|
|
|
void DigitalRenderer::init_sound(void)
|
|
{
|
|
this->sndbufsize = 1024;
|
|
|
|
ready = false;
|
|
InitialiseAudio();
|
|
ResetAudio();
|
|
|
|
this->sound_buffer = new int16[this->sndbufsize];
|
|
ready = true;
|
|
}
|
|
|
|
|
|
/*
|
|
* Destructor
|
|
*/
|
|
|
|
DigitalRenderer::~DigitalRenderer()
|
|
{
|
|
StopAudio();
|
|
}
|
|
|
|
|
|
/*
|
|
* Pause sound output
|
|
*/
|
|
|
|
void DigitalRenderer::Pause(void)
|
|
{
|
|
StopAudio();
|
|
}
|
|
|
|
|
|
/*
|
|
* Resume sound output
|
|
*/
|
|
|
|
void DigitalRenderer::Resume(void)
|
|
{
|
|
/* Done by PlayAudio() */
|
|
}
|
|
|
|
|
|
/*
|
|
* Fill buffer, sample volume (for sampled voice)
|
|
*/
|
|
|
|
void DigitalRenderer::EmulateLine(void)
|
|
{
|
|
static int divisor = 0;
|
|
static int to_output = 0;
|
|
static int buffer_pos = 0;
|
|
|
|
if (!ready)
|
|
return;
|
|
|
|
sample_buf[sample_in_ptr] = volume;
|
|
sample_in_ptr = (sample_in_ptr + 1) % SAMPLE_BUF_SIZE;
|
|
|
|
/*
|
|
* Now see how many samples have to be added for this line
|
|
*/
|
|
divisor += SAMPLE_FREQ;
|
|
while (divisor >= 0)
|
|
divisor -= TOTAL_RASTERS*SCREEN_FREQ, to_output++;
|
|
|
|
/*
|
|
* Calculate the sound data only when we have enough to fill
|
|
* the buffer entirely.
|
|
*/
|
|
if ((buffer_pos + to_output) >= sndbufsize) {
|
|
int datalen = sndbufsize - buffer_pos;
|
|
to_output -= datalen;
|
|
calc_buffer(sound_buffer + buffer_pos, datalen*2);
|
|
PlaySound((uint16_t*)sound_buffer, sndbufsize);
|
|
buffer_pos = 0;
|
|
}
|
|
}
|