mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-10 21:55:11 +01:00
Fix sound warnings and remove catweasel support
This commit is contained in:
parent
0777b096dd
commit
9e3796d44d
10
Src/SID.cpp
10
Src/SID.cpp
@ -996,11 +996,15 @@ void DigitalRenderer::WriteRegister(uint16 adr, uint8 byte)
|
||||
case 18:
|
||||
voice[v].wave = (byte >> 4) & 0xf;
|
||||
if ((byte & 1) != voice[v].gate)
|
||||
{
|
||||
if (byte & 1) // Gate turned on
|
||||
voice[v].eg_state = EG_ATTACK;
|
||||
else // Gate turned off
|
||||
{
|
||||
if (voice[v].eg_state != EG_IDLE)
|
||||
voice[v].eg_state = EG_RELEASE;
|
||||
}
|
||||
}
|
||||
voice[v].gate = byte & 1;
|
||||
voice[v].mod_by->sync = byte & 2;
|
||||
voice[v].ring = byte & 4;
|
||||
@ -1172,10 +1176,12 @@ void DigitalRenderer::calc_filter(void)
|
||||
|
||||
// Stabilize filter
|
||||
if (fabs(g1) >= g2 + 1.0)
|
||||
{
|
||||
if (g1 > 0.0)
|
||||
g1 = g2 + 0.99;
|
||||
else
|
||||
g1 = -(g2 + 0.99);
|
||||
}
|
||||
|
||||
// Calculate roots (filter characteristic) and input attenuation
|
||||
switch (f_type) {
|
||||
@ -1437,10 +1443,6 @@ void MOS6581::open_close_renderer(int old_type, int new_type)
|
||||
#ifdef AMIGA
|
||||
else if (new_type == SIDTYPE_SIDCARD)
|
||||
the_renderer = new SIDCardRenderer;
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
else if (new_type == SIDTYPE_SIDCARD)
|
||||
the_renderer = new CatweaselRenderer;
|
||||
#endif
|
||||
else
|
||||
the_renderer = NULL;
|
||||
|
@ -23,17 +23,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/soundcard.h>
|
||||
|
||||
// Catweasel ioctls (included here for convenience)
|
||||
#include <linux/ioctl.h>
|
||||
#define CWSID_IOCTL_TYPE ('S')
|
||||
#define CWSID_IOCTL_RESET _IO(CWSID_IOCTL_TYPE, 0)
|
||||
#define CWSID_IOCTL_CARDTYPE _IOR(CWSID_IOCTL_TYPE, 4, int)
|
||||
#define CWSID_IOCTL_PAL _IO(CWSID_IOCTL_TYPE, 0x11)
|
||||
#define CWSID_IOCTL_NTSC _IO(CWSID_IOCTL_TYPE, 0x12)
|
||||
#define CWSID_IOCTL_DOUBLEBUFFER _IOW(CWSID_IOCTL_TYPE, 0x21, int)
|
||||
#define CWSID_IOCTL_DELAY _IOW(CWSID_IOCTL_TYPE, 0x22, int)
|
||||
#define CWSID_MAGIC 0x100
|
||||
#define HAVE_CWSID 1
|
||||
#include "utils.hh"
|
||||
|
||||
#include "VIC.h"
|
||||
#include "Network.h"
|
||||
@ -133,9 +123,13 @@ void DigitalRenderer::PushVolume(uint8 vol)
|
||||
// the buffer entirely
|
||||
if ((buffer_pos + to_output) >= sndbufsize) {
|
||||
int datalen = sndbufsize - buffer_pos;
|
||||
ssize_t written;
|
||||
|
||||
to_output -= datalen;
|
||||
calc_buffer(sound_buffer + buffer_pos, datalen*2);
|
||||
write(devfd, sound_buffer, sndbufsize*2);
|
||||
written = write(devfd, sound_buffer, sndbufsize*2);
|
||||
if (written < 0)
|
||||
warning("Failed to write sound\n");
|
||||
buffer_pos = 0;
|
||||
}
|
||||
}
|
||||
@ -146,77 +140,3 @@ void DigitalRenderer::EmulateLine(void)
|
||||
return;
|
||||
this->PushVolume(volume);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Renderer for Catweasel card
|
||||
*/
|
||||
|
||||
// Renderer class
|
||||
class CatweaselRenderer : public SIDRenderer {
|
||||
public:
|
||||
CatweaselRenderer();
|
||||
virtual ~CatweaselRenderer();
|
||||
|
||||
virtual void Reset(void);
|
||||
virtual void EmulateLine(void) {}
|
||||
virtual void PushVolume(uint8) {}
|
||||
virtual void WriteRegister(uint16 adr, uint8 byte);
|
||||
virtual void NewPrefs(Prefs *prefs) {}
|
||||
virtual void Pause(void) {}
|
||||
virtual void Resume(void) {}
|
||||
|
||||
private:
|
||||
int cwsid_fh; // Catweasel device file handle
|
||||
};
|
||||
|
||||
// Constructor: Open Catweasel device and reset SID
|
||||
CatweaselRenderer::CatweaselRenderer()
|
||||
{
|
||||
cwsid_fh = open("/dev/sid", O_WRONLY);
|
||||
if (cwsid_fh >= 0) {
|
||||
int i;
|
||||
if (ioctl(cwsid_fh, CWSID_IOCTL_CARDTYPE, &i) < 0 || i != CWSID_MAGIC) {
|
||||
close(cwsid_fh);
|
||||
cwsid_fh = -1;
|
||||
} else {
|
||||
ioctl(cwsid_fh, CWSID_IOCTL_RESET);
|
||||
ioctl(cwsid_fh, CWSID_IOCTL_DOUBLEBUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
// Destructor: Reset SID and close Catweasel device
|
||||
CatweaselRenderer::~CatweaselRenderer()
|
||||
{
|
||||
Reset();
|
||||
|
||||
if (cwsid_fh >= 0) {
|
||||
close(cwsid_fh);
|
||||
cwsid_fh = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Reset SID
|
||||
void CatweaselRenderer::Reset(void)
|
||||
{
|
||||
if (cwsid_fh >= 0) {
|
||||
uint8 zero = 0;
|
||||
ioctl(cwsid_fh, CWSID_IOCTL_RESET);
|
||||
lseek(cwsid_fh, 24, SEEK_SET);
|
||||
write(cwsid_fh, &zero, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Write to register
|
||||
void CatweaselRenderer::WriteRegister(uint16 adr, uint8 byte)
|
||||
{
|
||||
if (cwsid_fh >= 0 && adr < 0x1a) {
|
||||
lseek(cwsid_fh, adr, SEEK_SET);
|
||||
write(cwsid_fh, &byte, 1);
|
||||
lseek(cwsid_fh, adr, SEEK_SET);
|
||||
write(cwsid_fh, &byte, 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user