diff --git a/.gitmodules b/.gitmodules
index 2863bf4825c..0953e056c7e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,3 +4,6 @@
[submodule "plugins/zynaddsubfx/zynaddsubfx"]
path = plugins/zynaddsubfx/zynaddsubfx
url = https://github.com/lmms/zynaddsubfx.git
+[submodule "plugins/FreeBoy/game-music-emu"]
+ path = plugins/FreeBoy/game-music-emu
+ url = https://bitbucket.org/mpyne/game-music-emu.git
diff --git a/data/locale/ar.ts b/data/locale/ar.ts
index e618e2877be..8e2bc5284fc 100644
--- a/data/locale/ar.ts
+++ b/data/locale/ar.ts
@@ -8746,7 +8746,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -8841,7 +8841,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/bs.ts b/data/locale/bs.ts
index cd28c14a622..410b601e2d2 100644
--- a/data/locale/bs.ts
+++ b/data/locale/bs.ts
@@ -10913,7 +10913,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -11036,7 +11036,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/ca.ts b/data/locale/ca.ts
index 8432a73e73b..a3b4e31f736 100644
--- a/data/locale/ca.ts
+++ b/data/locale/ca.ts
@@ -8756,7 +8756,7 @@ Fent doble clic a qualsevol connector mostrarà informació sobre els ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -8851,7 +8851,7 @@ Fent doble clic a qualsevol connector mostrarà informació sobre els ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/cs.ts b/data/locale/cs.ts
index 2e4d17c86f1..f880c47679f 100644
--- a/data/locale/cs.ts
+++ b/data/locale/cs.ts
@@ -9093,7 +9093,7 @@ Poklepáním na kterýkoliv modul se zobrazí informace o portech.
- papuInstrument
+ FreeBoyInstrumentSweep timeTrvání sweepu
@@ -9188,7 +9188,7 @@ Poklepáním na kterýkoliv modul se zobrazí informace o portech.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Trvání sweepu:
diff --git a/data/locale/de.ts b/data/locale/de.ts
index 0868efd96e8..63dc63ba57d 100644
--- a/data/locale/de.ts
+++ b/data/locale/de.ts
@@ -9086,7 +9086,7 @@ Doppelklicken auf eines der Plugins zeigt Informaitonen über die Ports an.
- papuInstrument
+ FreeBoyInstrumentSweep timeStreichzeit
@@ -9181,7 +9181,7 @@ Doppelklicken auf eines der Plugins zeigt Informaitonen über die Ports an.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Streichzeit:
diff --git a/data/locale/en.ts b/data/locale/en.ts
index 5096961dc2e..a178cc13558 100644
--- a/data/locale/en.ts
+++ b/data/locale/en.ts
@@ -9034,7 +9034,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -9129,7 +9129,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/es.ts b/data/locale/es.ts
index eb53a66bafb..c4d5178f1cb 100644
--- a/data/locale/es.ts
+++ b/data/locale/es.ts
@@ -9090,7 +9090,7 @@ Haciendo doble click en cualquier complemento se mostrará la información de su
- papuInstrument
+ FreeBoyInstrumentSweep timeDuración del barrido
@@ -9185,7 +9185,7 @@ Haciendo doble click en cualquier complemento se mostrará la información de su
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Duración del barrido:
diff --git a/data/locale/fa.ts b/data/locale/fa.ts
index 7593cb57e0d..9f6ec278b3c 100644
--- a/data/locale/fa.ts
+++ b/data/locale/fa.ts
@@ -8050,7 +8050,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -8145,7 +8145,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/fr.ts b/data/locale/fr.ts
index e2976b684c5..ddfbb1ea36f 100644
--- a/data/locale/fr.ts
+++ b/data/locale/fr.ts
@@ -9089,7 +9089,7 @@ En double-cliquant sur ces greffons vous ferez apparaître des informations sur
- papuInstrument
+ FreeBoyInstrumentSweep timeTemps de balayage
@@ -9184,7 +9184,7 @@ En double-cliquant sur ces greffons vous ferez apparaître des informations sur
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Temps de balayage :
diff --git a/data/locale/gl.ts b/data/locale/gl.ts
index 0956b91731c..a7843d0815b 100644
--- a/data/locale/gl.ts
+++ b/data/locale/gl.ts
@@ -8772,7 +8772,7 @@ Facendo duplo clic sobre calquera dos engadidos mostra información sobre os por
- papuInstrument
+ FreeBoyInstrumentSweep timeTempo da varredura
@@ -8867,7 +8867,7 @@ Facendo duplo clic sobre calquera dos engadidos mostra información sobre os por
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Tempo da varredura:
diff --git a/data/locale/hu_HU.ts b/data/locale/hu_HU.ts
index 6bde2330809..2791c4c75f1 100644
--- a/data/locale/hu_HU.ts
+++ b/data/locale/hu_HU.ts
@@ -8744,7 +8744,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -8839,7 +8839,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/id.ts b/data/locale/id.ts
index 265612fe7ef..da30ec919d3 100644
--- a/data/locale/id.ts
+++ b/data/locale/id.ts
@@ -9055,7 +9055,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -9150,7 +9150,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/it.ts b/data/locale/it.ts
index db919962999..6931b842159 100644
--- a/data/locale/it.ts
+++ b/data/locale/it.ts
@@ -9089,7 +9089,7 @@ Facendo doppio click sui plugin verranno fornite informazioni sulle relative por
- papuInstrument
+ FreeBoyInstrumentSweep timeTempo di sweep
@@ -9184,7 +9184,7 @@ Facendo doppio click sui plugin verranno fornite informazioni sulle relative por
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Tempo di sweep:
diff --git a/data/locale/ja.ts b/data/locale/ja.ts
index 540f52863c2..4355aef588b 100644
--- a/data/locale/ja.ts
+++ b/data/locale/ja.ts
@@ -9040,7 +9040,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -9135,7 +9135,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/ko.ts b/data/locale/ko.ts
index eecf2fbf937..36fe2e21440 100644
--- a/data/locale/ko.ts
+++ b/data/locale/ko.ts
@@ -9046,7 +9046,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -9141,7 +9141,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/nl.ts b/data/locale/nl.ts
index 3186d522507..029ff9f1451 100644
--- a/data/locale/nl.ts
+++ b/data/locale/nl.ts
@@ -9094,7 +9094,7 @@ Dubbelklikken op om het even welke plugins zal informatie geven over de poorten.
- papuInstrument
+ FreeBoyInstrumentSweep timeSweep-tijd
@@ -9189,7 +9189,7 @@ Dubbelklikken op om het even welke plugins zal informatie geven over de poorten.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Sweep-tijd:
diff --git a/data/locale/pl.ts b/data/locale/pl.ts
index 8da01113d56..5d9cc51cd40 100644
--- a/data/locale/pl.ts
+++ b/data/locale/pl.ts
@@ -9095,7 +9095,7 @@ Podwójne kliknięcie na którejkolwiek wtyczce otworzy okienko z informacjami o
- papuInstrument
+ FreeBoyInstrumentSweep timeOkres wobulacji
@@ -9190,7 +9190,7 @@ Podwójne kliknięcie na którejkolwiek wtyczce otworzy okienko z informacjami o
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Okres wobulacji:
diff --git a/data/locale/pt.ts b/data/locale/pt.ts
index 057a0f2dd65..d9c3a7cb2e4 100644
--- a/data/locale/pt.ts
+++ b/data/locale/pt.ts
@@ -9065,7 +9065,7 @@ Clicando duas vezes com o mouse em qualquer plugin, voc6e terá informações so
- papuInstrument
+ FreeBoyInstrumentSweep timeVarredura temporal
@@ -9160,7 +9160,7 @@ Clicando duas vezes com o mouse em qualquer plugin, voc6e terá informações so
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Varredura temporal:
diff --git a/data/locale/ru.ts b/data/locale/ru.ts
index e1ac93408da..1bc94ca9284 100644
--- a/data/locale/ru.ts
+++ b/data/locale/ru.ts
@@ -9100,7 +9100,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep timeВремя распространения
@@ -9195,7 +9195,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Время развёртки:
diff --git a/data/locale/sl.ts b/data/locale/sl.ts
index 57de86f3fc6..951fdb1d837 100644
--- a/data/locale/sl.ts
+++ b/data/locale/sl.ts
@@ -8744,7 +8744,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -8839,7 +8839,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/sr.ts b/data/locale/sr.ts
index 1d38c5d24d9..f746c74d391 100644
--- a/data/locale/sr.ts
+++ b/data/locale/sr.ts
@@ -8655,7 +8655,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -8750,7 +8750,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/sv.ts b/data/locale/sv.ts
index 173b1f76ee7..3b75e54c0e6 100644
--- a/data/locale/sv.ts
+++ b/data/locale/sv.ts
@@ -8749,7 +8749,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -8844,7 +8844,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/uk.ts b/data/locale/uk.ts
index 953cbf2ea12..43931a1736e 100644
--- a/data/locale/uk.ts
+++ b/data/locale/uk.ts
@@ -9096,7 +9096,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep timeЧас поширення
@@ -9191,7 +9191,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:Час розгортки:
diff --git a/data/locale/zh_CN.ts b/data/locale/zh_CN.ts
index 0d0c737e451..b369f844574 100644
--- a/data/locale/zh_CN.ts
+++ b/data/locale/zh_CN.ts
@@ -9069,7 +9069,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -9164,7 +9164,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/data/locale/zh_TW.ts b/data/locale/zh_TW.ts
index 395d40beac9..d2209539eb3 100644
--- a/data/locale/zh_TW.ts
+++ b/data/locale/zh_TW.ts
@@ -9060,7 +9060,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrument
+ FreeBoyInstrumentSweep time
@@ -9155,7 +9155,7 @@ Double clicking any of the plugins will bring up information on the ports.
- papuInstrumentView
+ FreeBoyInstrumentViewSweep Time:
diff --git a/include/DataFile.h b/include/DataFile.h
index 6b6b1a98e6c..9e4ca13e38a 100644
--- a/include/DataFile.h
+++ b/include/DataFile.h
@@ -127,6 +127,7 @@ class EXPORT DataFile : public QDomDocument
void upgrade_1_1_91();
void upgrade_1_2_0_rc3();
void upgrade_1_2_0_rc2_42();
+ void upgrade_1_3_0();
void upgrade();
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index ff807f354df..7d962406aee 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -62,7 +62,7 @@ IF("${PLUGIN_LIST}" STREQUAL "")
nes
opl2
organic
- papu
+ FreeBoy
patman
peak_controller_effect
GigPlayer
diff --git a/plugins/FreeBoy/CMakeLists.txt b/plugins/FreeBoy/CMakeLists.txt
new file mode 100644
index 00000000000..fb5093ee003
--- /dev/null
+++ b/plugins/FreeBoy/CMakeLists.txt
@@ -0,0 +1,21 @@
+INCLUDE(BuildPlugin)
+INCLUDE_DIRECTORIES(game-music-emu/gme)
+
+BUILD_PLUGIN(freeboy
+ FreeBoy.cpp
+ FreeBoy.h
+ Gb_Apu_Buffer.cpp
+ Gb_Apu_Buffer.h
+ game-music-emu/gme/Gb_Apu.cpp
+ game-music-emu/gme/Gb_Apu.h
+ game-music-emu/gme/Gb_Oscs.cpp
+ game-music-emu/gme/Blip_Buffer.cpp
+ game-music-emu/gme/Gb_Oscs.h
+ game-music-emu/gme/blargg_common.h
+ game-music-emu/gme/Blip_Buffer.h
+ game-music-emu/gme/Multi_Buffer.cpp
+ game-music-emu/gme/blargg_source.h
+ game-music-emu/gme/Multi_Buffer.h
+ MOCFILES FreeBoy.h
+ EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png"
+)
diff --git a/plugins/papu/papu_instrument.cpp b/plugins/FreeBoy/FreeBoy.cpp
similarity index 86%
rename from plugins/papu/papu_instrument.cpp
rename to plugins/FreeBoy/FreeBoy.cpp
index 3d4dfcf5d8d..c8aa4b07a4b 100644
--- a/plugins/papu/papu_instrument.cpp
+++ b/plugins/FreeBoy/FreeBoy.cpp
@@ -1,5 +1,5 @@
/*
- * papu_instrument.cpp - GameBoy papu based instrument
+ * FreeBoy.cpp - GameBoy papu based instrument
*
* Copyright (c) 2008 Attila Herman
* Csaba Hruska
@@ -27,9 +27,9 @@
#include
#include
-#include "Basic_Gb_Apu.h"
-
-#include "papu_instrument.h"
+#include "FreeBoy.h"
+#include "Gb_Apu_Buffer.h"
+#include "Multi_Buffer.h"
#include "base64.h"
#include "InstrumentTrack.h"
#include "Knob.h"
@@ -42,9 +42,12 @@
#include "embed.h"
+const blip_time_t FRAME_LENGTH = 70224;
+const long CLOCK_RATE = 4194304;
+
extern "C"
{
-Plugin::Descriptor PLUGIN_EXPORT papu_plugin_descriptor =
+Plugin::Descriptor PLUGIN_EXPORT freeboy_plugin_descriptor =
{
STRINGIFY( PLUGIN_NAME ),
"FreeBoy",
@@ -61,8 +64,8 @@ Plugin::Descriptor PLUGIN_EXPORT papu_plugin_descriptor =
}
-papuInstrument::papuInstrument( InstrumentTrack * _instrument_track ) :
- Instrument( _instrument_track, &papu_plugin_descriptor ),
+FreeBoyInstrument::FreeBoyInstrument( InstrumentTrack * _instrument_track ) :
+ Instrument( _instrument_track, &freeboy_plugin_descriptor ),
m_ch1SweepTimeModel( 4.0f, 0.0f, 7.0f, 1.0f, this, tr( "Sweep time" ) ),
m_ch1SweepDirModel( false, this, tr( "Sweep direction" ) ),
@@ -112,17 +115,19 @@ papuInstrument::papuInstrument( InstrumentTrack * _instrument_track ) :
m_trebleModel( -20.0f, -100.0f, 200.0f, 1.0f, this, tr( "Treble" ) ),
m_bassModel( 461.0f, -1.0f, 600.0f, 1.0f, this, tr( "Bass" ) ),
- m_graphModel( 0, 15, 32, this, false, 1 )
+ m_graphModel( 0, 15, 32, this, false, 1 ),
+
+ m_time(0)
{
}
-papuInstrument::~papuInstrument()
+FreeBoyInstrument::~FreeBoyInstrument()
{
}
-void papuInstrument::saveSettings( QDomDocument & _doc,
+void FreeBoyInstrument::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
m_ch1SweepTimeModel.saveSettings( _doc, _this, "st" );
@@ -165,7 +170,7 @@ void papuInstrument::saveSettings( QDomDocument & _doc,
_this.setAttribute( "sampleShape", sampleString );
}
-void papuInstrument::loadSettings( const QDomElement & _this )
+void FreeBoyInstrument::loadSettings( const QDomElement & _this )
{
m_ch1SweepTimeModel.loadSettings( _this, "st" );
m_ch1SweepDirModel.loadSettings( _this, "sd" );
@@ -207,15 +212,15 @@ void papuInstrument::loadSettings( const QDomElement & _this )
m_graphModel.setSamples( (float*) dst );
}
-QString papuInstrument::nodeName() const
+QString FreeBoyInstrument::nodeName() const
{
- return( papu_plugin_descriptor.name );
+ return( freeboy_plugin_descriptor.name );
}
-/*f_cnt_t papuInstrument::desiredReleaseFrames() const
+/*f_cnt_t FreeBoyInstrument::desiredReleaseFrames() const
{
const float samplerate = Engine::mixer()->processingSampleRate();
int maxrel = 0;
@@ -228,14 +233,14 @@ QString papuInstrument::nodeName() const
return f_cnt_t( float(relTime[maxrel])*samplerate/1000.0 );
}*/
-f_cnt_t papuInstrument::desiredReleaseFrames() const
+f_cnt_t FreeBoyInstrument::desiredReleaseFrames() const
{
return f_cnt_t( 1000 );
}
-void papuInstrument::playNote( NotePlayHandle * _n,
+void FreeBoyInstrument::playNote( NotePlayHandle * _n,
sampleFrame * _working_buffer )
{
const f_cnt_t tfp = _n->totalFramesPlayed();
@@ -248,25 +253,25 @@ void papuInstrument::playNote( NotePlayHandle * _n,
if ( tfp == 0 )
{
- Basic_Gb_Apu *papu = new Basic_Gb_Apu();
- papu->set_sample_rate( samplerate );
+ Gb_Apu_Buffer *papu = new Gb_Apu_Buffer();
+ papu->set_sample_rate( samplerate, CLOCK_RATE );
// Master sound circuitry power control
- papu->write_register( 0xff26, 0x80 );
+ papu->write_register( fakeClock(), 0xff26, 0x80 );
data = m_ch1VolumeModel.value();
data = data<<1;
data += m_ch1VolSweepDirModel.value();
data = data<<3;
data += m_ch1SweepStepLengthModel.value();
- papu->write_register( 0xff12, data );
+ papu->write_register( fakeClock(), 0xff12, data );
data = m_ch2VolumeModel.value();
data = data<<1;
data += m_ch2VolSweepDirModel.value();
data = data<<3;
data += m_ch2SweepStepLengthModel.value();
- papu->write_register( 0xff17, data );
+ papu->write_register( fakeClock(), 0xff17, data );
//channel 4 - noise
data = m_ch4VolumeModel.value();
@@ -274,15 +279,15 @@ void papuInstrument::playNote( NotePlayHandle * _n,
data += m_ch4VolSweepDirModel.value();
data = data<<3;
data += m_ch4SweepStepLengthModel.value();
- papu->write_register( 0xff21, data );
+ papu->write_register( fakeClock(), 0xff21, data );
//channel 4 init
- papu->write_register( 0xff23, 128 );
+ papu->write_register( fakeClock(), 0xff23, 128 );
_n->m_pluginData = papu;
}
- Basic_Gb_Apu *papu = static_cast( _n->m_pluginData );
+ Gb_Apu_Buffer *papu = static_cast( _n->m_pluginData );
papu->treble_eq( m_trebleModel.value() );
papu->bass_freq( m_bassModel.value() );
@@ -293,35 +298,35 @@ void papuInstrument::playNote( NotePlayHandle * _n,
data += m_ch1SweepDirModel.value();
data = data << 3;
data += m_ch1SweepRtShiftModel.value();
- papu->write_register( 0xff10, data );
+ papu->write_register( fakeClock(), 0xff10, data );
data = m_ch1WavePatternDutyModel.value();
data = data<<6;
- papu->write_register( 0xff11, data );
+ papu->write_register( fakeClock(), 0xff11, data );
//channel 2 - square
data = m_ch2WavePatternDutyModel.value();
data = data<<6;
- papu->write_register( 0xff16, data );
+ papu->write_register( fakeClock(), 0xff16, data );
//channel 3 - wave
//data = m_ch3OnModel.value()?128:0;
data = 128;
- papu->write_register( 0xff1a, data );
+ papu->write_register( fakeClock(), 0xff1a, data );
int ch3voldata[4] = { 0, 3, 2, 1 };
data = ch3voldata[(int)m_ch3VolumeModel.value()];
data = data<<5;
- papu->write_register( 0xff1c, data );
+ papu->write_register( fakeClock(), 0xff1c, data );
//controls
data = m_so1VolumeModel.value();
data = data<<4;
data += m_so2VolumeModel.value();
- papu->write_register( 0xff24, data );
+ papu->write_register( fakeClock(), 0xff24, data );
data = m_ch4So2Model.value()?128:0;
data += m_ch3So2Model.value()?64:0;
@@ -331,7 +336,7 @@ void papuInstrument::playNote( NotePlayHandle * _n,
data += m_ch3So1Model.value()?4:0;
data += m_ch2So1Model.value()?2:0;
data += m_ch1So1Model.value()?1:0;
- papu->write_register( 0xff25, data );
+ papu->write_register( fakeClock(), 0xff25, data );
const float * wpm = m_graphModel.samples();
@@ -339,7 +344,7 @@ void papuInstrument::playNote( NotePlayHandle * _n,
{
data = (int)floor(wpm[i*2]) << 4;
data += (int)floor(wpm[i*2+1]);
- papu->write_register( 0xff30 + i, data );
+ papu->write_register( fakeClock(), 0xff30 + i, data );
}
if( ( freq >= 65 ) && ( freq <=4000 ) )
@@ -349,13 +354,13 @@ void papuInstrument::playNote( NotePlayHandle * _n,
data = 2048 - ( ( 4194304 / freq )>>5 );
if( tfp==0 )
{
- papu->write_register( 0xff13, data & 0xff );
- papu->write_register( 0xff14, (data>>8) | initflag );
+ papu->write_register( fakeClock(), 0xff13, data & 0xff );
+ papu->write_register( fakeClock(), 0xff14, (data>>8) | initflag );
}
- papu->write_register( 0xff18, data & 0xff );
- papu->write_register( 0xff19, (data>>8) | initflag );
- papu->write_register( 0xff1d, data & 0xff );
- papu->write_register( 0xff1e, (data>>8) | initflag );
+ papu->write_register( fakeClock(), 0xff18, data & 0xff );
+ papu->write_register( fakeClock(), 0xff19, (data>>8) | initflag );
+ papu->write_register( fakeClock(), 0xff1d, data & 0xff );
+ papu->write_register( fakeClock(), 0xff1e, (data>>8) | initflag );
}
if( tfp == 0 )
@@ -379,7 +384,7 @@ void papuInstrument::playNote( NotePlayHandle * _n,
data += m_ch4ShiftRegWidthModel.value();
data = data << 3;
data += ropt;
- papu->write_register( 0xff22, data );
+ papu->write_register( fakeClock(), 0xff22, data );
}
int const buf_size = 2048;
@@ -391,7 +396,8 @@ void papuInstrument::playNote( NotePlayHandle * _n,
int avail = papu->samples_avail();
if( avail <= 0 )
{
- papu->end_frame();
+ m_time = 0;
+ papu->end_frame(FRAME_LENGTH);
avail = papu->samples_avail();
}
datalen = framesleft>avail?avail:framesleft;
@@ -414,24 +420,24 @@ void papuInstrument::playNote( NotePlayHandle * _n,
-void papuInstrument::deleteNotePluginData( NotePlayHandle * _n )
+void FreeBoyInstrument::deleteNotePluginData( NotePlayHandle * _n )
{
- delete static_cast( _n->m_pluginData );
+ delete static_cast( _n->m_pluginData );
}
-PluginView * papuInstrument::instantiateView( QWidget * _parent )
+PluginView * FreeBoyInstrument::instantiateView( QWidget * _parent )
{
- return( new papuInstrumentView( this, _parent ) );
+ return( new FreeBoyInstrumentView( this, _parent ) );
}
-class papuKnob : public Knob
+class FreeBoyKnob : public Knob
{
public:
- papuKnob( QWidget * _parent ) :
+ FreeBoyKnob( QWidget * _parent ) :
Knob( knobStyled, _parent )
{
setFixedSize( 30, 30 );
@@ -447,7 +453,7 @@ class papuKnob : public Knob
-papuInstrumentView::papuInstrumentView( Instrument * _instrument,
+FreeBoyInstrumentView::FreeBoyInstrumentView( Instrument * _instrument,
QWidget * _parent ) :
InstrumentView( _instrument, _parent )
{
@@ -457,14 +463,14 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
setPalette( pal );
- m_ch1SweepTimeKnob = new papuKnob( this );
+ m_ch1SweepTimeKnob = new FreeBoyKnob( this );
m_ch1SweepTimeKnob->setHintText( tr( "Sweep Time:" ), "" );
m_ch1SweepTimeKnob->move( 5 + 4*32, 106 );
ToolTip::add( m_ch1SweepTimeKnob, tr( "Sweep Time" ) );
m_ch1SweepTimeKnob->setWhatsThis( tr( "The amount of increase or"
" decrease in frequency" ) );
- m_ch1SweepRtShiftKnob = new papuKnob( this );
+ m_ch1SweepRtShiftKnob = new FreeBoyKnob( this );
m_ch1SweepRtShiftKnob->setHintText( tr( "Sweep RtShift amount:" )
, "" );
m_ch1SweepRtShiftKnob->move( 5 + 3*32, 106 );
@@ -472,7 +478,7 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
m_ch1SweepRtShiftKnob->setWhatsThis( tr( "The rate at which increase or"
" decrease in frequency occurs" ) );
- m_ch1WavePatternDutyKnob = new papuKnob( this );
+ m_ch1WavePatternDutyKnob = new FreeBoyKnob( this );
m_ch1WavePatternDutyKnob->setHintText( tr( "Wave pattern duty:" )
, "" );
m_ch1WavePatternDutyKnob->move( 5 + 2*32, 106 );
@@ -481,14 +487,14 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
" the duration (time) that a signal is ON"
" versus the total period of the signal." ) );
- m_ch1VolumeKnob = new papuKnob( this );
+ m_ch1VolumeKnob = new FreeBoyKnob( this );
m_ch1VolumeKnob->setHintText( tr( "Square Channel 1 Volume:" )
, "" );
m_ch1VolumeKnob->move( 5, 106 );
ToolTip::add( m_ch1VolumeKnob, tr( "Square Channel 1 Volume:" ) );
m_ch1VolumeKnob->setWhatsThis( tr( "Square Channel 1 Volume" ) );
- m_ch1SweepStepLengthKnob = new papuKnob( this );
+ m_ch1SweepStepLengthKnob = new FreeBoyKnob( this );
m_ch1SweepStepLengthKnob->setHintText( tr( "Length of each step in sweep:" )
, "" );
m_ch1SweepStepLengthKnob->move( 5 + 32, 106 );
@@ -497,7 +503,7 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
- m_ch2WavePatternDutyKnob = new papuKnob( this );
+ m_ch2WavePatternDutyKnob = new FreeBoyKnob( this );
m_ch2WavePatternDutyKnob->setHintText( tr( "Wave pattern duty:" )
, "" );
m_ch2WavePatternDutyKnob->move( 5 + 2*32, 155 );
@@ -506,14 +512,14 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
" the duration (time) that a signal is ON"
" versus the total period of the signal." ) );
- m_ch2VolumeKnob = new papuKnob( this );
+ m_ch2VolumeKnob = new FreeBoyKnob( this );
m_ch2VolumeKnob->setHintText( tr( "Square Channel 2 Volume:" )
, "" );
m_ch2VolumeKnob->move( 5, 155 );
ToolTip::add( m_ch2VolumeKnob, tr( "Square Channel 2 Volume" ) );
m_ch2VolumeKnob->setWhatsThis( tr( "Square Channel 2 Volume" ) );
- m_ch2SweepStepLengthKnob = new papuKnob( this );
+ m_ch2SweepStepLengthKnob = new FreeBoyKnob( this );
m_ch2SweepStepLengthKnob->setHintText( tr( "Length of each step in sweep:" )
, "" );
m_ch2SweepStepLengthKnob->move( 5 + 32, 155 );
@@ -522,7 +528,7 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
- m_ch3VolumeKnob = new papuKnob( this );
+ m_ch3VolumeKnob = new FreeBoyKnob( this );
m_ch3VolumeKnob->setHintText( tr( "Wave Channel Volume:" ), "" );
m_ch3VolumeKnob->move( 5, 204 );
ToolTip::add( m_ch3VolumeKnob, tr( "Wave Channel Volume" ) );
@@ -530,13 +536,13 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
- m_ch4VolumeKnob = new papuKnob( this );
+ m_ch4VolumeKnob = new FreeBoyKnob( this );
m_ch4VolumeKnob->setHintText( tr( "Noise Channel Volume:" ), "" );
m_ch4VolumeKnob->move( 144, 155 );
ToolTip::add( m_ch4VolumeKnob, tr( "Noise Channel Volume" ) );
m_ch4VolumeKnob->setWhatsThis( tr( "Noise Channel Volume" ) );
- m_ch4SweepStepLengthKnob = new papuKnob( this );
+ m_ch4SweepStepLengthKnob = new FreeBoyKnob( this );
m_ch4SweepStepLengthKnob->setHintText( tr( "Length of each step in sweep:" )
, "" );
m_ch4SweepStepLengthKnob->move( 144 + 32, 155 );
@@ -545,22 +551,22 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
- m_so1VolumeKnob = new papuKnob( this );
+ m_so1VolumeKnob = new FreeBoyKnob( this );
m_so1VolumeKnob->setHintText( tr( "SO1 Volume (Right):" ), "" );
m_so1VolumeKnob->move( 5, 58 );
ToolTip::add( m_so1VolumeKnob, tr( "SO1 Volume (Right)" ) );
- m_so2VolumeKnob = new papuKnob( this );
+ m_so2VolumeKnob = new FreeBoyKnob( this );
m_so2VolumeKnob->setHintText( tr( "SO2 Volume (Left):" ), "" );
m_so2VolumeKnob->move( 5 + 32, 58 );
ToolTip::add( m_so2VolumeKnob, tr( "SO2 Volume (Left)" ) );
- m_trebleKnob = new papuKnob( this );
+ m_trebleKnob = new FreeBoyKnob( this );
m_trebleKnob->setHintText( tr( "Treble:" ), "" );
m_trebleKnob->move( 5 + 2*32, 58 );
ToolTip::add( m_trebleKnob, tr( "Treble" ) );
- m_bassKnob = new papuKnob( this );
+ m_bassKnob = new FreeBoyKnob( this );
m_bassKnob->setHintText( tr( "Bass:" ), "" );
m_bassKnob->move( 5 + 3*32, 58 );
ToolTip::add( m_bassKnob, tr( "Bass" ) );
@@ -689,14 +695,14 @@ papuInstrumentView::papuInstrumentView( Instrument * _instrument,
}
-papuInstrumentView::~papuInstrumentView()
+FreeBoyInstrumentView::~FreeBoyInstrumentView()
{
}
-void papuInstrumentView::modelChanged()
+void FreeBoyInstrumentView::modelChanged()
{
- papuInstrument * p = castModel();
+ FreeBoyInstrument * p = castModel();
m_ch1SweepTimeKnob->setModel( &p->m_ch1SweepTimeModel );
m_ch1SweepDirButton->setModel( &p->m_ch1SweepDirModel );
@@ -740,7 +746,7 @@ extern "C"
// necessary for getting instance out of shared lib
Plugin * PLUGIN_EXPORT lmms_plugin_main( Model *, void * _data )
{
- return( new papuInstrument(
+ return( new FreeBoyInstrument(
static_cast( _data ) ) );
}
diff --git a/plugins/papu/papu_instrument.h b/plugins/FreeBoy/FreeBoy.h
similarity index 86%
rename from plugins/papu/papu_instrument.h
rename to plugins/FreeBoy/FreeBoy.h
index 8ba363c4f69..69c4785050b 100644
--- a/plugins/papu/papu_instrument.h
+++ b/plugins/FreeBoy/FreeBoy.h
@@ -1,5 +1,5 @@
/*
- * papu_Instrument.h - GameBoy papu based instrument
+ * FreeBoyInstrument.h - GameBoy papu based instrument
*
* Copyright (c) 2008
* Csaba Hruska
@@ -23,26 +23,27 @@
*
*/
-#ifndef _PAPU_H
-#define _PAPU_H
+#ifndef FREEBOY_H
+#define FREEBOY_H
#include
#include "Instrument.h"
#include "InstrumentView.h"
#include "Knob.h"
#include "Graph.h"
+#include "Gb_Apu.h"
-class papuInstrumentView;
+class FreeBoyInstrumentView;
class NotePlayHandle;
class PixmapButton;
-class papuInstrument : public Instrument
+class FreeBoyInstrument : public Instrument
{
Q_OBJECT
public:
- papuInstrument( InstrumentTrack * _instrument_track );
- virtual ~papuInstrument();
+ FreeBoyInstrument( InstrumentTrack * _instrument_track );
+ virtual ~FreeBoyInstrument();
virtual void playNote( NotePlayHandle * _n,
sampleFrame * _working_buffer );
@@ -102,16 +103,20 @@ class papuInstrument : public Instrument
graphModel m_graphModel;
- friend class papuInstrumentView;
+ // Fake CPU timing
+ blip_time_t m_time;
+ blip_time_t fakeClock() { return m_time += 4; }
+
+ friend class FreeBoyInstrumentView;
} ;
-class papuInstrumentView : public InstrumentView
+class FreeBoyInstrumentView : public InstrumentView
{
Q_OBJECT
public:
- papuInstrumentView( Instrument * _instrument, QWidget * _parent );
- virtual ~papuInstrumentView();
+ FreeBoyInstrumentView( Instrument * _instrument, QWidget * _parent );
+ virtual ~FreeBoyInstrumentView();
private:
virtual void modelChanged();
diff --git a/plugins/FreeBoy/Gb_Apu_Buffer.cpp b/plugins/FreeBoy/Gb_Apu_Buffer.cpp
new file mode 100644
index 00000000000..0cd8662ac29
--- /dev/null
+++ b/plugins/FreeBoy/Gb_Apu_Buffer.cpp
@@ -0,0 +1,53 @@
+/*
+ * Gb_Apu_Buffer.cpp - Gb_Apu subclass which allows direct buffer access
+ * Copyright (c) 2017 Tres Finocchiaro
+ *
+ * This file is part of LMMS - https://lmms.io
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program (see COPYING); if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ */
+#include "Gb_Apu_Buffer.h"
+
+Gb_Apu_Buffer::Gb_Apu_Buffer() {}
+Gb_Apu_Buffer::~Gb_Apu_Buffer() {}
+
+void Gb_Apu_Buffer::end_frame(blip_time_t end_time) {
+ Gb_Apu::end_frame(end_time);
+ m_buf.end_frame(end_time);
+}
+
+// Sets specified sample rate and clock rate in Multi_Buffer
+blargg_err_t Gb_Apu_Buffer::set_sample_rate(long sample_rate, long clock_rate) {
+ Gb_Apu_Buffer::output(m_buf.center(), m_buf.left(), m_buf.right());
+ m_buf.clock_rate(clock_rate);
+ return m_buf.set_sample_rate(sample_rate);
+}
+
+// Wrap Multi_Buffer::samples_avail()
+long Gb_Apu_Buffer::samples_avail() const {
+ return m_buf.samples_avail();
+}
+
+// Wrap Multi_Buffer::read_samples(...)
+long Gb_Apu_Buffer::read_samples(sample_t* out, long count) {
+ return m_buf.read_samples(out, count);
+}
+
+void Gb_Apu_Buffer::bass_freq(int freq) {
+ m_buf.bass_freq(freq);
+}
+
diff --git a/plugins/FreeBoy/Gb_Apu_Buffer.h b/plugins/FreeBoy/Gb_Apu_Buffer.h
new file mode 100644
index 00000000000..5228b7b8afd
--- /dev/null
+++ b/plugins/FreeBoy/Gb_Apu_Buffer.h
@@ -0,0 +1,48 @@
+/*
+ * Gb_Apu_Buffer.cpp - Gb_Apu subclass which allows direct buffer access
+ * Copyright (c) 2017 Tres Finocchiaro
+ *
+ * This file is part of LMMS - https://lmms.io
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program (see COPYING); if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ */
+#ifndef GB_APU_BUFFER_H
+#define GB_APU_BUFFER_H
+
+#include "Gb_Apu.h"
+#include "Multi_Buffer.h"
+#include "MemoryManager.h"
+
+class Gb_Apu_Buffer : public Gb_Apu {
+ MM_OPERATORS
+public:
+ Gb_Apu_Buffer();
+ ~Gb_Apu_Buffer();
+
+ void end_frame(blip_time_t);
+
+ blargg_err_t set_sample_rate(long sample_rate, long clock_rate);
+ long samples_avail() const;
+ typedef blip_sample_t sample_t;
+ long read_samples(sample_t* out, long count);
+ void bass_freq(int freq);
+private:
+ Stereo_Buffer m_buf;
+};
+
+#endif
+
diff --git a/plugins/papu/artwork.png b/plugins/FreeBoy/artwork.png
similarity index 100%
rename from plugins/papu/artwork.png
rename to plugins/FreeBoy/artwork.png
diff --git a/plugins/papu/btn_15.png b/plugins/FreeBoy/btn_15.png
similarity index 100%
rename from plugins/papu/btn_15.png
rename to plugins/FreeBoy/btn_15.png
diff --git a/plugins/papu/btn_7.png b/plugins/FreeBoy/btn_7.png
similarity index 100%
rename from plugins/papu/btn_7.png
rename to plugins/FreeBoy/btn_7.png
diff --git a/plugins/papu/btn_down.png b/plugins/FreeBoy/btn_down.png
similarity index 100%
rename from plugins/papu/btn_down.png
rename to plugins/FreeBoy/btn_down.png
diff --git a/plugins/papu/btn_off.png b/plugins/FreeBoy/btn_off.png
similarity index 100%
rename from plugins/papu/btn_off.png
rename to plugins/FreeBoy/btn_off.png
diff --git a/plugins/papu/btn_on.png b/plugins/FreeBoy/btn_on.png
similarity index 100%
rename from plugins/papu/btn_on.png
rename to plugins/FreeBoy/btn_on.png
diff --git a/plugins/papu/btn_up.png b/plugins/FreeBoy/btn_up.png
similarity index 100%
rename from plugins/papu/btn_up.png
rename to plugins/FreeBoy/btn_up.png
diff --git a/plugins/FreeBoy/game-music-emu b/plugins/FreeBoy/game-music-emu
new file mode 160000
index 00000000000..21a064ea66a
--- /dev/null
+++ b/plugins/FreeBoy/game-music-emu
@@ -0,0 +1 @@
+Subproject commit 21a064ea66a5cdf71910e207c4756095c266814f
diff --git a/plugins/papu/logo.png b/plugins/FreeBoy/logo.png
similarity index 100%
rename from plugins/papu/logo.png
rename to plugins/FreeBoy/logo.png
diff --git a/plugins/papu/Basic_Gb_Apu.cpp b/plugins/papu/Basic_Gb_Apu.cpp
deleted file mode 100644
index 53c2fab1785..00000000000
--- a/plugins/papu/Basic_Gb_Apu.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-
-// Gb_Snd_Emu 0.1.4. http://www.slack.net/~ant/libs/
-
-#include "Basic_Gb_Apu.h"
-
-/* Copyright (C) 2003-2005 Shay Green. This module is free software; you
-can redistribute it and/or modify it under the terms of the GNU Lesser
-General Public License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version. This
-module is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
-more details. You should have received a copy of the GNU Lesser General
-Public License along with this module; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-blip_time_t const frame_length = 70224;
-
-Basic_Gb_Apu::Basic_Gb_Apu()
-{
- time = 0;
-}
-
-Basic_Gb_Apu::~Basic_Gb_Apu()
-{
-}
-
-blargg_err_t Basic_Gb_Apu::set_sample_rate( long rate )
-{
- apu.output( buf.center(), buf.left(), buf.right() );
- buf.clock_rate( 4194304 );
- return buf.set_sample_rate( rate );
-}
-
-void Basic_Gb_Apu::write_register( blip_time_t addr, int data )
-{
- apu.write_register( clock(), addr, data );
-}
-
-int Basic_Gb_Apu::read_register( blip_time_t addr )
-{
- return apu.read_register( clock(), addr );
-}
-
-void Basic_Gb_Apu::end_frame()
-{
- time = 0;
- apu.end_frame( frame_length );
- buf.end_frame( frame_length );
-}
-
-long Basic_Gb_Apu::samples_avail() const
-{
- return buf.samples_avail();
-}
-
-long Basic_Gb_Apu::read_samples( sample_t* out, long count )
-{
- return buf.read_samples( out, count );
-}
-
-//added by 589 --->
-
-void Basic_Gb_Apu::reset()
-{
- apu.reset();
-}
-
-void Basic_Gb_Apu::treble_eq( const blip_eq_t& eq )
-{
- apu.treble_eq( eq );
-}
-
-void Basic_Gb_Apu::bass_freq( int bf )
-{
- buf.bass_freq( bf );
-}
-
-// <---
diff --git a/plugins/papu/Basic_Gb_Apu.h b/plugins/papu/Basic_Gb_Apu.h
deleted file mode 100644
index b39efe9cfb9..00000000000
--- a/plugins/papu/Basic_Gb_Apu.h
+++ /dev/null
@@ -1,55 +0,0 @@
-
-// Simplified Nintendo Game Boy PAPU sound chip emulator
-
-// Gb_Snd_Emu 0.1.4. Copyright (C) 2003-2005 Shay Green. GNU LGPL license.
-
-#ifndef BASIC_GB_APU_H
-#define BASIC_GB_APU_H
-
-#include "gb_apu/Gb_Apu.h"
-#include "gb_apu/Multi_Buffer.h"
-#include "MemoryManager.h"
-
-class Basic_Gb_Apu {
- MM_OPERATORS
-public:
- Basic_Gb_Apu();
- ~Basic_Gb_Apu();
-
- // Set output sample rate
- blargg_err_t set_sample_rate( long rate );
-
- // Pass reads and writes in the range 0xff10-0xff3f
- void write_register( blip_time_t, int data );
- int read_register( blip_time_t );
-
- // End a 1/60 sound frame and add samples to buffer
- void end_frame();
-
- // Samples are generated in stereo, left first. Sample counts are always
- // a multiple of 2.
-
- // Number of samples in buffer
- long samples_avail() const;
-
- // Read at most 'count' samples out of buffer and return number actually read
- typedef blip_sample_t sample_t;
- long read_samples( sample_t* out, long count );
-
- //added by 589 --->
- void reset();
- void treble_eq( const blip_eq_t& eq );
- void bass_freq( int bf );
- //<---
-
-private:
- Gb_Apu apu;
- Stereo_Buffer buf;
- blip_time_t time;
-
- // faked CPU timing
- blip_time_t clock() { return time += 4; }
-};
-
-#endif
-
diff --git a/plugins/papu/CMakeLists.txt b/plugins/papu/CMakeLists.txt
deleted file mode 100644
index 20d9bbd2033..00000000000
--- a/plugins/papu/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-INCLUDE(BuildPlugin)
-
-BUILD_PLUGIN(papu papu_instrument.cpp papu_instrument.h Basic_Gb_Apu.cpp Basic_Gb_Apu.h gb_apu/Gb_Oscs.cpp gb_apu/Gb_Apu.h gb_apu/Blip_Buffer.cpp gb_apu/Gb_Apu.cpp gb_apu/Gb_Oscs.h gb_apu/blargg_common.h gb_apu/Blip_Buffer.h gb_apu/Multi_Buffer.cpp gb_apu/blargg_source.h gb_apu/Multi_Buffer.h MOCFILES papu_instrument.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
diff --git a/plugins/papu/gb_apu/Blip_Buffer.cpp b/plugins/papu/gb_apu/Blip_Buffer.cpp
deleted file mode 100644
index a46b0e350d4..00000000000
--- a/plugins/papu/gb_apu/Blip_Buffer.cpp
+++ /dev/null
@@ -1,460 +0,0 @@
-// Blip_Buffer 0.4.1. http://www.slack.net/~ant/
-
-#include "Blip_Buffer.h"
-
-#include
-#include
-#include
-#include
-#include
-
-/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
-can redistribute it and/or modify it under the terms of the GNU Lesser
-General Public License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version. This
-module is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-details. You should have received a copy of the GNU Lesser General Public
-License along with this module; if not, write to the Free Software Foundation,
-Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#ifdef BLARGG_ENABLE_OPTIMIZER
- #include BLARGG_ENABLE_OPTIMIZER
-#endif
-
-int const silent_buf_size = 1; // size used for Silent_Blip_Buffer
-
-Blip_Buffer::Blip_Buffer()
-{
- factor_ = (blip_ulong)-1 / 2;
- offset_ = 0;
- buffer_ = 0;
- buffer_size_ = 0;
- sample_rate_ = 0;
- reader_accum_ = 0;
- bass_shift_ = 0;
- clock_rate_ = 0;
- bass_freq_ = 16;
- length_ = 0;
-
- // assumptions code makes about implementation-defined features
- #ifndef NDEBUG
- // right shift of negative value preserves sign
- buf_t_ i = -0x7FFFFFFE;
- assert( (i >> 1) == -0x3FFFFFFF );
-
- // casting to short truncates to 16 bits and sign-extends
- i = 0x18000;
- assert( (short) i == -0x8000 );
- #endif
-}
-
-Blip_Buffer::~Blip_Buffer()
-{
- if ( buffer_size_ != silent_buf_size )
- free( buffer_ );
-}
-
-Silent_Blip_Buffer::Silent_Blip_Buffer()
-{
- factor_ = 0;
- buffer_ = buf;
- buffer_size_ = silent_buf_size;
- memset( buf, 0, sizeof buf ); // in case machine takes exception for signed overflow
-}
-
-void Blip_Buffer::clear( int entire_buffer )
-{
- offset_ = 0;
- reader_accum_ = 0;
- modified_ = 0;
- if ( buffer_ )
- {
- long count = (entire_buffer ? buffer_size_ : samples_avail());
- memset( buffer_, 0, (count + blip_buffer_extra_) * sizeof (buf_t_) );
- }
-}
-
-Blip_Buffer::blargg_err_t Blip_Buffer::set_sample_rate( long new_rate, int msec )
-{
- if ( buffer_size_ == silent_buf_size )
- {
- assert( 0 );
- return "Internal (tried to resize Silent_Blip_Buffer)";
- }
-
- // start with maximum length that resampled time can represent
- long new_size = (UINT_MAX >> BLIP_BUFFER_ACCURACY) - blip_buffer_extra_ - 64;
- if ( msec != blip_max_length )
- {
- long s = (new_rate * (msec + 1) + 999) / 1000;
- if ( s < new_size )
- new_size = s;
- else
- assert( 0 ); // fails if requested buffer length exceeds limit
- }
-
- if ( buffer_size_ != new_size )
- {
- void* p = realloc( buffer_, (new_size + blip_buffer_extra_) * sizeof *buffer_ );
- if ( !p )
- return "Out of memory";
- buffer_ = (buf_t_*) p;
- }
-
- buffer_size_ = new_size;
- assert( buffer_size_ != silent_buf_size );
-
- // update things based on the sample rate
- sample_rate_ = new_rate;
- length_ = new_size * 1000 / new_rate - 1;
- if ( msec )
- assert( length_ == msec ); // ensure length is same as that passed in
- if ( clock_rate_ )
- clock_rate( clock_rate_ );
- bass_freq( bass_freq_ );
-
- clear();
-
- return 0; // success
-}
-
-blip_resampled_time_t Blip_Buffer::clock_rate_factor( long rate ) const
-{
- double ratio = (double) sample_rate_ / rate;
- blip_long factor = (blip_long) floor( ratio * (1L << BLIP_BUFFER_ACCURACY) + 0.5 );
- assert( factor > 0 || !sample_rate_ ); // fails if clock/output ratio is too large
- return (blip_resampled_time_t) factor;
-}
-
-void Blip_Buffer::bass_freq( int freq )
-{
- bass_freq_ = freq;
- int shift = 31;
- if ( freq > 0 )
- {
- shift = 13;
- long f = (freq << 16) / sample_rate_;
- while ( (f >>= 1) && --shift ) { }
- }
- bass_shift_ = shift;
-}
-
-void Blip_Buffer::end_frame( blip_time_t t )
-{
- offset_ += t * factor_;
- assert( samples_avail() <= (long) buffer_size_ ); // time outside buffer length
-}
-
-void Blip_Buffer::remove_silence( long count )
-{
- assert( count <= samples_avail() ); // tried to remove more samples than available
- offset_ -= (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY;
-}
-
-long Blip_Buffer::count_samples( blip_time_t t ) const
-{
- unsigned long last_sample = resampled_time( t ) >> BLIP_BUFFER_ACCURACY;
- unsigned long first_sample = offset_ >> BLIP_BUFFER_ACCURACY;
- return (long) (last_sample - first_sample);
-}
-
-blip_time_t Blip_Buffer::count_clocks( long count ) const
-{
- if ( !factor_ )
- {
- assert( 0 ); // sample rate and clock rates must be set first
- return 0;
- }
-
- if ( count > buffer_size_ )
- count = buffer_size_;
- blip_resampled_time_t time = (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY;
- return (blip_time_t) ((time - offset_ + factor_ - 1) / factor_);
-}
-
-void Blip_Buffer::remove_samples( long count )
-{
- if ( count )
- {
- remove_silence( count );
-
- // copy remaining samples to beginning and clear old samples
- long remain = samples_avail() + blip_buffer_extra_;
- memmove( buffer_, buffer_ + count, remain * sizeof *buffer_ );
- memset( buffer_ + remain, 0, count * sizeof *buffer_ );
- }
-}
-
-// Blip_Synth_
-
-Blip_Synth_Fast_::Blip_Synth_Fast_()
-{
- buf = 0;
- last_amp = 0;
- delta_factor = 0;
-}
-
-void Blip_Synth_Fast_::volume_unit( double new_unit )
-{
- delta_factor = int (new_unit * (1L << blip_sample_bits) + 0.5);
-}
-
-#if !BLIP_BUFFER_FAST
-
-Blip_Synth_::Blip_Synth_( short* p, int w ) :
- impulses( p ),
- width( w )
-{
- volume_unit_ = 0.0;
- kernel_unit = 0;
- buf = 0;
- last_amp = 0;
- delta_factor = 0;
-}
-
-#undef PI
-#define PI 3.1415926535897932384626433832795029
-
-static void gen_sinc( float* out, int count, double oversample, double treble, double cutoff )
-{
- if ( cutoff >= 0.999 )
- cutoff = 0.999;
-
- if ( treble < -300.0 )
- treble = -300.0;
- if ( treble > 5.0 )
- treble = 5.0;
-
- double const maxh = 4096.0;
- double const rolloff = pow( 10.0, 1.0 / (maxh * 20.0) * treble / (1.0 - cutoff) );
- double const pow_a_n = pow( rolloff, maxh - maxh * cutoff );
- double const to_angle = PI / 2 / maxh / oversample;
- for ( int i = 0; i < count; i++ )
- {
- double angle = ((i - count) * 2 + 1) * to_angle;
- double angle_maxh = angle * maxh;
- double angle_maxh_mid = angle_maxh * cutoff;
-
- double y = maxh;
-
- // 0 to Fs/2*cutoff, flat
- if ( angle_maxh_mid ) // unstable at t=0
- y *= sin( angle_maxh_mid ) / angle_maxh_mid;
-
- // Fs/2*cutoff to Fs/2, logarithmic rolloff
- double cosa = cos( angle );
- double den = 1 + rolloff * (rolloff - cosa - cosa);
-
- // Becomes unstable when rolloff is near 1.0 and t is near 0,
- // which is the only time den becomes small
- if ( den > 1e-13 )
- {
- double num =
- (cos( angle_maxh - angle ) * rolloff - cos( angle_maxh )) * pow_a_n -
- cos( angle_maxh_mid - angle ) * rolloff + cos( angle_maxh_mid );
-
- y = y * cutoff + num / den;
- }
-
- out [i] = (float) y;
- }
-}
-
-void blip_eq_t::generate( float* out, int count ) const
-{
- // lower cutoff freq for narrow kernels with their wider transition band
- // (8 points->1.49, 16 points->1.15)
- double oversample = blip_res * 2.25 / count + 0.85;
- double half_rate = sample_rate * 0.5;
- if ( cutoff_freq )
- oversample = half_rate / cutoff_freq;
- double cutoff = rolloff_freq * oversample / half_rate;
-
- gen_sinc( out, count, blip_res * oversample, treble, cutoff );
-
- // apply (half of) hamming window
- double to_fraction = PI / (count - 1);
- for ( int i = count; i--; )
- out [i] *= 0.54f - 0.46f * (float) cos( i * to_fraction );
-}
-
-void Blip_Synth_::adjust_impulse()
-{
- // sum pairs for each phase and add error correction to end of first half
- int const size = impulses_size();
- for ( int p = blip_res; p-- >= blip_res / 2; )
- {
- int p2 = blip_res - 2 - p;
- long error = kernel_unit;
- for ( int i = 1; i < size; i += blip_res )
- {
- error -= impulses [i + p ];
- error -= impulses [i + p2];
- }
- if ( p == p2 )
- error /= 2; // phase = 0.5 impulse uses same half for both sides
- impulses [size - blip_res + p] += (short) error;
- //printf( "error: %ld\n", error );
- }
-
- //for ( int i = blip_res; i--; printf( "\n" ) )
- // for ( int j = 0; j < width / 2; j++ )
- // printf( "%5ld,", impulses [j * blip_res + i + 1] );
-}
-
-void Blip_Synth_::treble_eq( blip_eq_t const& eq )
-{
- float fimpulse [blip_res / 2 * (blip_widest_impulse_ - 1) + blip_res * 2];
-
- int const half_size = blip_res / 2 * (width - 1);
- eq.generate( &fimpulse [blip_res], half_size );
-
- int i;
-
- // need mirror slightly past center for calculation
- for ( i = blip_res; i--; )
- fimpulse [blip_res + half_size + i] = fimpulse [blip_res + half_size - 1 - i];
-
- // starts at 0
- for ( i = 0; i < blip_res; i++ )
- fimpulse [i] = 0.0f;
-
- // find rescale factor
- double total = 0.0;
- for ( i = 0; i < half_size; i++ )
- total += fimpulse [blip_res + i];
-
- //double const base_unit = 44800.0 - 128 * 18; // allows treble up to +0 dB
- //double const base_unit = 37888.0; // allows treble to +5 dB
- double const base_unit = 32768.0; // necessary for blip_unscaled to work
- double rescale = base_unit / 2 / total;
- kernel_unit = (long) base_unit;
-
- // integrate, first difference, rescale, convert to int
- double sum = 0.0;
- double next = 0.0;
- int const impulses_size = this->impulses_size();
- for ( i = 0; i < impulses_size; i++ )
- {
- impulses [i] = (short) floor( (next - sum) * rescale + 0.5 );
- sum += fimpulse [i];
- next += fimpulse [i + blip_res];
- }
- adjust_impulse();
-
- // volume might require rescaling
- double vol = volume_unit_;
- if ( vol )
- {
- volume_unit_ = 0.0;
- volume_unit( vol );
- }
-}
-
-void Blip_Synth_::volume_unit( double new_unit )
-{
- if ( new_unit != volume_unit_ )
- {
- // use default eq if it hasn't been set yet
- if ( !kernel_unit )
- treble_eq( -8.0 );
-
- volume_unit_ = new_unit;
- double factor = new_unit * (1L << blip_sample_bits) / kernel_unit;
-
- if ( factor > 0.0 )
- {
- int shift = 0;
-
- // if unit is really small, might need to attenuate kernel
- while ( factor < 2.0 )
- {
- shift++;
- factor *= 2.0;
- }
-
- if ( shift )
- {
- kernel_unit >>= shift;
- assert( kernel_unit > 0 ); // fails if volume unit is too low
-
- // keep values positive to avoid round-towards-zero of sign-preserving
- // right shift for negative values
- long offset = 0x8000 + (1 << (shift - 1));
- long offset2 = 0x8000 >> shift;
- for ( int i = impulses_size(); i--; )
- impulses [i] = (short) (((impulses [i] + offset) >> shift) - offset2);
- adjust_impulse();
- }
- }
- delta_factor = (int) floor( factor + 0.5 );
- //printf( "delta_factor: %d, kernel_unit: %d\n", delta_factor, kernel_unit );
- }
-}
-#endif
-
-long Blip_Buffer::read_samples( blip_sample_t* BLIP_RESTRICT out, long max_samples, int stereo )
-{
- long count = samples_avail();
- if ( count > max_samples )
- count = max_samples;
-
- if ( count )
- {
- int const bass = BLIP_READER_BASS( *this );
- BLIP_READER_BEGIN( reader, *this );
-
- if ( !stereo )
- {
- for ( blip_long n = count; n; --n )
- {
- blip_long s = BLIP_READER_READ( reader );
- if ( (blip_sample_t) s != s )
- s = 0x7FFF - (s >> 24);
- *out++ = (blip_sample_t) s;
- BLIP_READER_NEXT( reader, bass );
- }
- }
- else
- {
- for ( blip_long n = count; n; --n )
- {
- blip_long s = BLIP_READER_READ( reader );
- if ( (blip_sample_t) s != s )
- s = 0x7FFF - (s >> 24);
- *out = (blip_sample_t) s;
- out += 2;
- BLIP_READER_NEXT( reader, bass );
- }
- }
- BLIP_READER_END( reader, *this );
-
- remove_samples( count );
- }
- return count;
-}
-
-void Blip_Buffer::mix_samples( blip_sample_t const* in, long count )
-{
- if ( buffer_size_ == silent_buf_size )
- {
- assert( 0 );
- return;
- }
-
- buf_t_* out = buffer_ + (offset_ >> BLIP_BUFFER_ACCURACY) + blip_widest_impulse_ / 2;
-
- int const sample_shift = blip_sample_bits - 16;
- int prev = 0;
- while ( count-- )
- {
- blip_long s = (blip_long) *in++ << sample_shift;
- *out += s - prev;
- prev = s;
- ++out;
- }
- *out -= prev;
-}
-
diff --git a/plugins/papu/gb_apu/Blip_Buffer.h b/plugins/papu/gb_apu/Blip_Buffer.h
deleted file mode 100644
index 4cc526d2f1c..00000000000
--- a/plugins/papu/gb_apu/Blip_Buffer.h
+++ /dev/null
@@ -1,488 +0,0 @@
-// Band-limited sound synthesis buffer
-
-// Blip_Buffer 0.4.1
-#ifndef BLIP_BUFFER_H
-#define BLIP_BUFFER_H
-
- // internal
- #include
- #if INT_MAX < 0x7FFFFFFF
- #error "int must be at least 32 bits"
- #endif
-
- typedef int blip_long;
- typedef unsigned blip_ulong;
-
-// Time unit at source clock rate
-typedef blip_long blip_time_t;
-
-// Output samples are 16-bit signed, with a range of -32768 to 32767
-typedef short blip_sample_t;
-enum { blip_sample_max = 32767 };
-
-class Blip_Buffer {
-public:
- typedef const char* blargg_err_t;
-
- // Set output sample rate and buffer length in milliseconds (1/1000 sec, defaults
- // to 1/4 second), then clear buffer. Returns NULL on success, otherwise if there
- // isn't enough memory, returns error without affecting current buffer setup.
- blargg_err_t set_sample_rate( long samples_per_sec, int msec_length = 1000 / 4 );
-
- // Set number of source time units per second
- void clock_rate( long );
-
- // End current time frame of specified duration and make its samples available
- // (along with any still-unread samples) for reading with read_samples(). Begins
- // a new time frame at the end of the current frame.
- void end_frame( blip_time_t time );
-
- // Read at most 'max_samples' out of buffer into 'dest', removing them from from
- // the buffer. Returns number of samples actually read and removed. If stereo is
- // true, increments 'dest' one extra time after writing each sample, to allow
- // easy interleving of two channels into a stereo output buffer.
- long read_samples( blip_sample_t* dest, long max_samples, int stereo = 0 );
-
-// Additional optional features
-
- // Current output sample rate
- long sample_rate() const;
-
- // Length of buffer, in milliseconds
- int length() const;
-
- // Number of source time units per second
- long clock_rate() const;
-
- // Set frequency high-pass filter frequency, where higher values reduce bass more
- void bass_freq( int frequency );
-
- // Number of samples delay from synthesis to samples read out
- int output_latency() const;
-
- // Remove all available samples and clear buffer to silence. If 'entire_buffer' is
- // false, just clears out any samples waiting rather than the entire buffer.
- void clear( int entire_buffer = 1 );
-
- // Number of samples available for reading with read_samples()
- long samples_avail() const;
-
- // Remove 'count' samples from those waiting to be read
- void remove_samples( long count );
-
-// Experimental features
-
- // Count number of clocks needed until 'count' samples will be available.
- // If buffer can't even hold 'count' samples, returns number of clocks until
- // buffer becomes full.
- blip_time_t count_clocks( long count ) const;
-
- // Number of raw samples that can be mixed within frame of specified duration.
- long count_samples( blip_time_t duration ) const;
-
- // Mix 'count' samples from 'buf' into buffer.
- void mix_samples( blip_sample_t const* buf, long count );
-
- // not documented yet
- void set_modified() { modified_ = 1; }
- int clear_modified() { int b = modified_; modified_ = 0; return b; }
- typedef blip_ulong blip_resampled_time_t;
- void remove_silence( long count );
- blip_resampled_time_t resampled_duration( int t ) const { return t * factor_; }
- blip_resampled_time_t resampled_time( blip_time_t t ) const { return t * factor_ + offset_; }
- blip_resampled_time_t clock_rate_factor( long clock_rate ) const;
-public:
- Blip_Buffer();
- ~Blip_Buffer();
-
- // Deprecated
- typedef blip_resampled_time_t resampled_time_t;
- blargg_err_t sample_rate( long r ) { return set_sample_rate( r ); }
- blargg_err_t sample_rate( long r, int msec ) { return set_sample_rate( r, msec ); }
-private:
- // noncopyable
- Blip_Buffer( const Blip_Buffer& );
- Blip_Buffer& operator = ( const Blip_Buffer& );
-public:
- typedef blip_time_t buf_t_;
- blip_ulong factor_;
- blip_resampled_time_t offset_;
- buf_t_* buffer_;
- blip_long buffer_size_;
- blip_long reader_accum_;
- int bass_shift_;
-private:
- long sample_rate_;
- long clock_rate_;
- int bass_freq_;
- int length_;
- int modified_;
- friend class Blip_Reader;
-};
-
-#ifdef HAVE_CONFIG_H
- #include "config.h"
-#endif
-
-// Number of bits in resample ratio fraction. Higher values give a more accurate ratio
-// but reduce maximum buffer size.
-#ifndef BLIP_BUFFER_ACCURACY
- #define BLIP_BUFFER_ACCURACY 16
-#endif
-
-// Number bits in phase offset. Fewer than 6 bits (64 phase offsets) results in
-// noticeable broadband noise when synthesizing high frequency square waves.
-// Affects size of Blip_Synth objects since they store the waveform directly.
-#ifndef BLIP_PHASE_BITS
- #if BLIP_BUFFER_FAST
- #define BLIP_PHASE_BITS 8
- #else
- #define BLIP_PHASE_BITS 6
- #endif
-#endif
-
- // Internal
- typedef blip_ulong blip_resampled_time_t;
- int const blip_widest_impulse_ = 16;
- int const blip_buffer_extra_ = blip_widest_impulse_ + 2;
- int const blip_res = 1 << BLIP_PHASE_BITS;
- class blip_eq_t;
-
- class Blip_Synth_Fast_ {
- public:
- Blip_Buffer* buf;
- int last_amp;
- int delta_factor;
-
- void volume_unit( double );
- Blip_Synth_Fast_();
- void treble_eq( blip_eq_t const& ) { }
- };
-
- class Blip_Synth_ {
- public:
- Blip_Buffer* buf;
- int last_amp;
- int delta_factor;
-
- void volume_unit( double );
- Blip_Synth_( short* impulses, int width );
- void treble_eq( blip_eq_t const& );
- private:
- double volume_unit_;
- short* const impulses;
- int const width;
- blip_long kernel_unit;
- int impulses_size() const { return blip_res / 2 * width + 1; }
- void adjust_impulse();
- };
-
-// Quality level. Start with blip_good_quality.
-const int blip_med_quality = 8;
-const int blip_good_quality = 12;
-const int blip_high_quality = 16;
-
-// Range specifies the greatest expected change in amplitude. Calculate it
-// by finding the difference between the maximum and minimum expected
-// amplitudes (max - min).
-template
-class Blip_Synth {
-public:
- // Set overall volume of waveform
- void volume( double v ) { impl.volume_unit( v * (1.0 / (range < 0 ? -range : range)) ); }
-
- // Configure low-pass filter (see blip_buffer.txt)
- void treble_eq( blip_eq_t const& eq ) { impl.treble_eq( eq ); }
-
- // Get/set Blip_Buffer used for output
- Blip_Buffer* output() const { return impl.buf; }
- void output( Blip_Buffer* b ) { impl.buf = b; impl.last_amp = 0; }
-
- // Update amplitude of waveform at given time. Using this requires a separate
- // Blip_Synth for each waveform.
- void update( blip_time_t time, int amplitude );
-
-// Low-level interface
-
- // Add an amplitude transition of specified delta, optionally into specified buffer
- // rather than the one set with output(). Delta can be positive or negative.
- // The actual change in amplitude is delta * (volume / range)
- void offset( blip_time_t, int delta, Blip_Buffer* ) const;
- void offset( blip_time_t t, int delta ) const { offset( t, delta, impl.buf ); }
-
- // Works directly in terms of fractional output samples. Contact author for more info.
- void offset_resampled( blip_resampled_time_t, int delta, Blip_Buffer* ) const;
-
- // Same as offset(), except code is inlined for higher performance
- void offset_inline( blip_time_t t, int delta, Blip_Buffer* buf ) const {
- offset_resampled( t * buf->factor_ + buf->offset_, delta, buf );
- }
- void offset_inline( blip_time_t t, int delta ) const {
- offset_resampled( t * impl.buf->factor_ + impl.buf->offset_, delta, impl.buf );
- }
-
-private:
-#if BLIP_BUFFER_FAST
- Blip_Synth_Fast_ impl;
-#else
- Blip_Synth_ impl;
- typedef short imp_t;
- imp_t impulses [blip_res * (quality / 2) + 1];
-public:
- Blip_Synth() : impl( impulses, quality ) { }
-#endif
-};
-
-// Low-pass equalization parameters
-class blip_eq_t {
-public:
- // Logarithmic rolloff to treble dB at half sampling rate. Negative values reduce
- // treble, small positive values (0 to 5.0) increase treble.
- blip_eq_t( double treble_db = 0 );
-
- // See blip_buffer.txt
- blip_eq_t( double treble, long rolloff_freq, long sample_rate, long cutoff_freq = 0 );
-
-private:
- double treble;
- long rolloff_freq;
- long sample_rate;
- long cutoff_freq;
- void generate( float* out, int count ) const;
- friend class Blip_Synth_;
-};
-
-int const blip_sample_bits = 30;
-
-// Dummy Blip_Buffer to direct sound output to, for easy muting without
-// having to stop sound code.
-class Silent_Blip_Buffer : public Blip_Buffer {
- buf_t_ buf [blip_buffer_extra_ + 1];
-public:
- // The following cannot be used (an assertion will fail if attempted):
- blargg_err_t set_sample_rate( long samples_per_sec, int msec_length );
- blip_time_t count_clocks( long count ) const;
- void mix_samples( blip_sample_t const* buf, long count );
-
- Silent_Blip_Buffer();
-};
-
- #if defined (__GNUC__) || _MSC_VER >= 1100
- #define BLIP_RESTRICT __restrict
- #else
- #define BLIP_RESTRICT
- #endif
-
-// Optimized reading from Blip_Buffer, for use in custom sample output
-
-// Begin reading from buffer. Name should be unique to the current block.
-#define BLIP_READER_BEGIN( name, blip_buffer ) \
- const Blip_Buffer::buf_t_* BLIP_RESTRICT name##_reader_buf = (blip_buffer).buffer_;\
- blip_long name##_reader_accum = (blip_buffer).reader_accum_
-
-// Get value to pass to BLIP_READER_NEXT()
-#define BLIP_READER_BASS( blip_buffer ) ((blip_buffer).bass_shift_)
-
-// Constant value to use instead of BLIP_READER_BASS(), for slightly more optimal
-// code at the cost of having no bass control
-int const blip_reader_default_bass = 9;
-
-// Current sample
-#define BLIP_READER_READ( name ) (name##_reader_accum >> (blip_sample_bits - 16))
-
-// Current raw sample in full internal resolution
-#define BLIP_READER_READ_RAW( name ) (name##_reader_accum)
-
-// Advance to next sample
-#define BLIP_READER_NEXT( name, bass ) \
- (void) (name##_reader_accum += *name##_reader_buf++ - (name##_reader_accum >> (bass)))
-
-// End reading samples from buffer. The number of samples read must now be removed
-// using Blip_Buffer::remove_samples().
-#define BLIP_READER_END( name, blip_buffer ) \
- (void) ((blip_buffer).reader_accum_ = name##_reader_accum)
-
-
-// Compatibility with older version
-const long blip_unscaled = 65535;
-const int blip_low_quality = blip_med_quality;
-const int blip_best_quality = blip_high_quality;
-
-// Deprecated; use BLIP_READER macros as follows:
-// Blip_Reader r; r.begin( buf ); -> BLIP_READER_BEGIN( r, buf );
-// int bass = r.begin( buf ) -> BLIP_READER_BEGIN( r, buf ); int bass = BLIP_READER_BASS( buf );
-// r.read() -> BLIP_READER_READ( r )
-// r.read_raw() -> BLIP_READER_READ_RAW( r )
-// r.next( bass ) -> BLIP_READER_NEXT( r, bass )
-// r.next() -> BLIP_READER_NEXT( r, blip_reader_default_bass )
-// r.end( buf ) -> BLIP_READER_END( r, buf )
-class Blip_Reader {
-public:
- int begin( Blip_Buffer& );
- blip_long read() const { return accum >> (blip_sample_bits - 16); }
- blip_long read_raw() const { return accum; }
- void next( int bass_shift = 9 ) { accum += *buf++ - (accum >> bass_shift); }
- void end( Blip_Buffer& b ) { b.reader_accum_ = accum; }
-
-private:
- const Blip_Buffer::buf_t_* buf;
- blip_long accum;
-};
-
-// End of public interface
-
-#include
-
-template
-inline void Blip_Synth::offset_resampled( blip_resampled_time_t time,
- int delta, Blip_Buffer* blip_buf ) const
-{
- // Fails if time is beyond end of Blip_Buffer, due to a bug in caller code or the
- // need for a longer buffer as set by set_sample_rate().
- assert( (blip_long) (time >> BLIP_BUFFER_ACCURACY) < blip_buf->buffer_size_ );
- delta *= impl.delta_factor;
- blip_long* BLIP_RESTRICT buf = blip_buf->buffer_ + (time >> BLIP_BUFFER_ACCURACY);
- int phase = (int) (time >> (BLIP_BUFFER_ACCURACY - BLIP_PHASE_BITS) & (blip_res - 1));
-
-#if BLIP_BUFFER_FAST
- blip_long left = buf [0] + delta;
-
- // Kind of crappy, but doing shift after multiply results in overflow.
- // Alternate way of delaying multiply by delta_factor results in worse
- // sub-sample resolution.
- blip_long right = (delta >> BLIP_PHASE_BITS) * phase;
- left -= right;
- right += buf [1];
-
- buf [0] = left;
- buf [1] = right;
-#else
-
- int const fwd = (blip_widest_impulse_ - quality) / 2;
- int const rev = fwd + quality - 2;
- int const mid = quality / 2 - 1;
-
- imp_t const* BLIP_RESTRICT imp = impulses + blip_res - phase;
-
- #if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \
- defined (__x86_64__) || defined (__ia64__) || defined (__i386__)
-
- // straight forward implementation resulted in better code on GCC for x86
-
- #define ADD_IMP( out, in ) \
- buf [out] += (blip_long) imp [blip_res * (in)] * delta
-
- #define BLIP_FWD( i ) {\
- ADD_IMP( fwd + i, i );\
- ADD_IMP( fwd + 1 + i, i + 1 );\
- }
- #define BLIP_REV( r ) {\
- ADD_IMP( rev - r, r + 1 );\
- ADD_IMP( rev + 1 - r, r );\
- }
-
- BLIP_FWD( 0 )
- if ( quality > 8 ) BLIP_FWD( 2 )
- if ( quality > 12 ) BLIP_FWD( 4 )
- {
- ADD_IMP( fwd + mid - 1, mid - 1 );
- ADD_IMP( fwd + mid , mid );
- imp = impulses + phase;
- }
- if ( quality > 12 ) BLIP_REV( 6 )
- if ( quality > 8 ) BLIP_REV( 4 )
- BLIP_REV( 2 )
-
- ADD_IMP( rev , 1 );
- ADD_IMP( rev + 1, 0 );
-
- #else
-
- // for RISC processors, help compiler by reading ahead of writes
-
- #define BLIP_FWD( i ) {\
- blip_long t0 = i0 * delta + buf [fwd + i];\
- blip_long t1 = imp [blip_res * (i + 1)] * delta + buf [fwd + 1 + i];\
- i0 = imp [blip_res * (i + 2)];\
- buf [fwd + i] = t0;\
- buf [fwd + 1 + i] = t1;\
- }
- #define BLIP_REV( r ) {\
- blip_long t0 = i0 * delta + buf [rev - r];\
- blip_long t1 = imp [blip_res * r] * delta + buf [rev + 1 - r];\
- i0 = imp [blip_res * (r - 1)];\
- buf [rev - r] = t0;\
- buf [rev + 1 - r] = t1;\
- }
-
- blip_long i0 = *imp;
- BLIP_FWD( 0 )
- if ( quality > 8 ) BLIP_FWD( 2 )
- if ( quality > 12 ) BLIP_FWD( 4 )
- {
- blip_long t0 = i0 * delta + buf [fwd + mid - 1];
- blip_long t1 = imp [blip_res * mid] * delta + buf [fwd + mid ];
- imp = impulses + phase;
- i0 = imp [blip_res * mid];
- buf [fwd + mid - 1] = t0;
- buf [fwd + mid ] = t1;
- }
- if ( quality > 12 ) BLIP_REV( 6 )
- if ( quality > 8 ) BLIP_REV( 4 )
- BLIP_REV( 2 )
-
- blip_long t0 = i0 * delta + buf [rev ];
- blip_long t1 = *imp * delta + buf [rev + 1];
- buf [rev ] = t0;
- buf [rev + 1] = t1;
- #endif
-
-#endif
-}
-
-#undef BLIP_FWD
-#undef BLIP_REV
-
-template
-#if BLIP_BUFFER_FAST
- inline
-#endif
-void Blip_Synth::offset( blip_time_t t, int delta, Blip_Buffer* buf ) const
-{
- offset_resampled( t * buf->factor_ + buf->offset_, delta, buf );
-}
-
-template
-#if BLIP_BUFFER_FAST
- inline
-#endif
-void Blip_Synth::update( blip_time_t t, int amp )
-{
- int delta = amp - impl.last_amp;
- impl.last_amp = amp;
- offset_resampled( t * impl.buf->factor_ + impl.buf->offset_, delta, impl.buf );
-}
-
-inline blip_eq_t::blip_eq_t( double t ) :
- treble( t ), rolloff_freq( 0 ), sample_rate( 44100 ), cutoff_freq( 0 ) { }
-inline blip_eq_t::blip_eq_t( double t, long rf, long sr, long cf ) :
- treble( t ), rolloff_freq( rf ), sample_rate( sr ), cutoff_freq( cf ) { }
-
-inline int Blip_Buffer::length() const { return length_; }
-inline long Blip_Buffer::samples_avail() const { return (long) (offset_ >> BLIP_BUFFER_ACCURACY); }
-inline long Blip_Buffer::sample_rate() const { return sample_rate_; }
-inline int Blip_Buffer::output_latency() const { return blip_widest_impulse_ / 2; }
-inline long Blip_Buffer::clock_rate() const { return clock_rate_; }
-inline void Blip_Buffer::clock_rate( long cps ) { factor_ = clock_rate_factor( clock_rate_ = cps ); }
-
-inline int Blip_Reader::begin( Blip_Buffer& blip_buf )
-{
- buf = blip_buf.buffer_;
- accum = blip_buf.reader_accum_;
- return blip_buf.bass_shift_;
-}
-
-int const blip_max_length = 0;
-int const blip_default_length = 250;
-
-#endif
diff --git a/plugins/papu/gb_apu/Gb_Apu.cpp b/plugins/papu/gb_apu/Gb_Apu.cpp
deleted file mode 100644
index 866594ddf62..00000000000
--- a/plugins/papu/gb_apu/Gb_Apu.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-// Gb_Snd_Emu 0.1.5. http://www.slack.net/~ant/
-
-#include "Gb_Apu.h"
-
-#include
-
-/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
-can redistribute it and/or modify it under the terms of the GNU Lesser
-General Public License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version. This
-module is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-details. You should have received a copy of the GNU Lesser General Public
-License along with this module; if not, write to the Free Software Foundation,
-Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#include "blargg_source.h"
-
-unsigned const vol_reg = 0xFF24;
-unsigned const status_reg = 0xFF26;
-
-Gb_Apu::Gb_Apu()
-{
- square1.synth = &square_synth;
- square2.synth = &square_synth;
- wave.synth = &other_synth;
- noise.synth = &other_synth;
-
- oscs [0] = &square1;
- oscs [1] = &square2;
- oscs [2] = &wave;
- oscs [3] = &noise;
-
- for ( int i = 0; i < osc_count; i++ )
- {
- Gb_Osc& osc = *oscs [i];
- osc.regs = ®s [i * 5];
- osc.output = 0;
- osc.outputs [0] = 0;
- osc.outputs [1] = 0;
- osc.outputs [2] = 0;
- osc.outputs [3] = 0;
- }
-
- set_tempo( 1.0 );
- volume( 1.0 );
- reset();
-}
-
-void Gb_Apu::treble_eq( const blip_eq_t& eq )
-{
- square_synth.treble_eq( eq );
- other_synth.treble_eq( eq );
-}
-
-void Gb_Apu::osc_output( int index, Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right )
-{
- require( (unsigned) index < osc_count );
- require( (center && left && right) || (!center && !left && !right) );
- Gb_Osc& osc = *oscs [index];
- osc.outputs [1] = right;
- osc.outputs [2] = left;
- osc.outputs [3] = center;
- osc.output = osc.outputs [osc.output_select];
-}
-
-void Gb_Apu::output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right )
-{
- for ( int i = 0; i < osc_count; i++ )
- osc_output( i, center, left, right );
-}
-
-void Gb_Apu::update_volume()
-{
- // TODO: doesn't handle differing left/right global volume (support would
- // require modification to all oscillator code)
- int data = regs [vol_reg - start_addr];
- double vol = (max( data & 7, data >> 4 & 7 ) + 1) * volume_unit;
- square_synth.volume( vol );
- other_synth.volume( vol );
-}
-
-static unsigned char const powerup_regs [0x20] = {
- 0x80,0x3F,0x00,0xFF,0xBF, // square 1
- 0xFF,0x3F,0x00,0xFF,0xBF, // square 2
- 0x7F,0xFF,0x9F,0xFF,0xBF, // wave
- 0xFF,0xFF,0x00,0x00,0xBF, // noise
- 0x00, // left/right enables
- 0x77, // master volume
- 0x80, // power
- 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
-};
-
-void Gb_Apu::set_tempo( double t )
-{
- frame_period = 4194304 / 256; // 256 Hz
- if ( t != 1.0 )
- frame_period = blip_time_t (frame_period / t);
-}
-
-void Gb_Apu::reset()
-{
- next_frame_time = 0;
- last_time = 0;
- frame_count = 0;
-
- square1.reset();
- square2.reset();
- wave.reset();
- noise.reset();
- noise.bits = 1;
- wave.wave_pos = 0;
-
- // avoid click at beginning
- regs [vol_reg - start_addr] = 0x77;
- update_volume();
-
- regs [status_reg - start_addr] = 0x01; // force power
- write_register( 0, status_reg, 0x00 );
-
- static unsigned char const initial_wave [] = {
- 0x84,0x40,0x43,0xAA,0x2D,0x78,0x92,0x3C, // wave table
- 0x60,0x59,0x59,0xB0,0x34,0xB8,0x2E,0xDA
- };
- memcpy( wave.wave, initial_wave, sizeof wave.wave );
-}
-
-void Gb_Apu::run_until( blip_time_t end_time )
-{
- require( end_time >= last_time ); // end_time must not be before previous time
- if ( end_time == last_time )
- return;
-
- while ( true )
- {
- blip_time_t time = next_frame_time;
- if ( time > end_time )
- time = end_time;
-
- // run oscillators
- for ( int i = 0; i < osc_count; ++i )
- {
- Gb_Osc& osc = *oscs [i];
- if ( osc.output )
- {
- osc.output->set_modified(); // TODO: misses optimization opportunities?
- int playing = false;
- if ( osc.enabled && osc.volume &&
- (!(osc.regs [4] & osc.len_enabled_mask) || osc.length) )
- playing = -1;
- switch ( i )
- {
- case 0: square1.run( last_time, time, playing ); break;
- case 1: square2.run( last_time, time, playing ); break;
- case 2: wave .run( last_time, time, playing ); break;
- case 3: noise .run( last_time, time, playing ); break;
- }
- }
- }
- last_time = time;
-
- if ( time == end_time )
- break;
-
- next_frame_time += frame_period;
-
- // 256 Hz actions
- square1.clock_length();
- square2.clock_length();
- wave.clock_length();
- noise.clock_length();
-
- frame_count = (frame_count + 1) & 3;
- if ( frame_count == 0 )
- {
- // 64 Hz actions
- square1.clock_envelope();
- square2.clock_envelope();
- noise.clock_envelope();
- }
-
- if ( frame_count & 1 )
- square1.clock_sweep(); // 128 Hz action
- }
-}
-
-void Gb_Apu::end_frame( blip_time_t end_time )
-{
- if ( end_time > last_time )
- run_until( end_time );
-
- assert( next_frame_time >= end_time );
- next_frame_time -= end_time;
-
- assert( last_time >= end_time );
- last_time -= end_time;
-}
-
-void Gb_Apu::write_register( blip_time_t time, unsigned addr, int data )
-{
- require( (unsigned) data < 0x100 );
-
- int reg = addr - start_addr;
- if ( (unsigned) reg >= register_count )
- return;
-
- run_until( time );
-
- int old_reg = regs [reg];
- regs [reg] = data;
-
- if ( addr < vol_reg )
- {
- write_osc( reg / 5, reg, data );
- }
- else if ( addr == vol_reg && data != old_reg ) // global volume
- {
- // return all oscs to 0
- for ( int i = 0; i < osc_count; i++ )
- {
- Gb_Osc& osc = *oscs [i];
- int amp = osc.last_amp;
- osc.last_amp = 0;
- if ( amp && osc.enabled && osc.output )
- other_synth.offset( time, -amp, osc.output );
- }
-
- if ( wave.outputs [3] )
- other_synth.offset( time, 30, wave.outputs [3] );
-
- update_volume();
-
- if ( wave.outputs [3] )
- other_synth.offset( time, -30, wave.outputs [3] );
-
- // oscs will update with new amplitude when next run
- }
- else if ( addr == 0xFF25 || addr == status_reg )
- {
- int mask = (regs [status_reg - start_addr] & 0x80) ? ~0 : 0;
- int flags = regs [0xFF25 - start_addr] & mask;
-
- // left/right assignments
- for ( int i = 0; i < osc_count; i++ )
- {
- Gb_Osc& osc = *oscs [i];
- osc.enabled &= mask;
- int bits = flags >> i;
- Blip_Buffer* old_output = osc.output;
- osc.output_select = (bits >> 3 & 2) | (bits & 1);
- osc.output = osc.outputs [osc.output_select];
- if ( osc.output != old_output )
- {
- int amp = osc.last_amp;
- osc.last_amp = 0;
- if ( amp && old_output )
- other_synth.offset( time, -amp, old_output );
- }
- }
-
- if ( addr == status_reg && data != old_reg )
- {
- if ( !(data & 0x80) )
- {
- for ( unsigned i = 0; i < sizeof powerup_regs; i++ )
- {
- if ( i != status_reg - start_addr )
- write_register( time, i + start_addr, powerup_regs [i] );
- }
- }
- else
- {
- //debug_printf( "APU powered on\n" );
- }
- }
- }
- else if ( addr >= 0xFF30 )
- {
- int index = (addr & 0x0F) * 2;
- wave.wave [index] = data >> 4;
- wave.wave [index + 1] = data & 0x0F;
- }
-}
-
-int Gb_Apu::read_register( blip_time_t time, unsigned addr )
-{
- run_until( time );
-
- int index = addr - start_addr;
- require( (unsigned) index < register_count );
- int data = regs [index];
-
- if ( addr == status_reg )
- {
- data = (data & 0x80) | 0x70;
- for ( int i = 0; i < osc_count; i++ )
- {
- const Gb_Osc& osc = *oscs [i];
- if ( osc.enabled && (osc.length || !(osc.regs [4] & osc.len_enabled_mask)) )
- data |= 1 << i;
- }
- }
-
- return data;
-}
diff --git a/plugins/papu/gb_apu/Gb_Apu.h b/plugins/papu/gb_apu/Gb_Apu.h
deleted file mode 100644
index e74ebc55b89..00000000000
--- a/plugins/papu/gb_apu/Gb_Apu.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Nintendo Game Boy PAPU sound chip emulator
-
-// Gb_Snd_Emu 0.1.5
-#ifndef GB_APU_H
-#define GB_APU_H
-
-#include "Gb_Oscs.h"
-
-class Gb_Apu {
-public:
-
- // Set overall volume of all oscillators, where 1.0 is full volume
- void volume( double );
-
- // Set treble equalization
- void treble_eq( const blip_eq_t& );
-
- // Outputs can be assigned to a single buffer for mono output, or to three
- // buffers for stereo output (using Stereo_Buffer to do the mixing).
-
- // Assign all oscillator outputs to specified buffer(s). If buffer
- // is NULL, silences all oscillators.
- void output( Blip_Buffer* mono );
- void output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right );
-
- // Assign single oscillator output to buffer(s). Valid indicies are 0 to 3,
- // which refer to Square 1, Square 2, Wave, and Noise. If buffer is NULL,
- // silences oscillator.
- enum { osc_count = 4 };
- void osc_output( int index, Blip_Buffer* mono );
- void osc_output( int index, Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right );
-
- // Reset oscillators and internal state
- void reset();
-
- // Reads and writes at addr must satisfy start_addr <= addr <= end_addr
- enum { start_addr = 0xFF10 };
- enum { end_addr = 0xFF3F };
- enum { register_count = end_addr - start_addr + 1 };
-
- // Write 'data' to address at specified time
- void write_register( blip_time_t, unsigned addr, int data );
-
- // Read from address at specified time
- int read_register( blip_time_t, unsigned addr );
-
- // Run all oscillators up to specified time, end current time frame, then
- // start a new frame at time 0.
- void end_frame( blip_time_t );
-
- void set_tempo( double );
-
-public:
- Gb_Apu();
-private:
- // noncopyable
- Gb_Apu( const Gb_Apu& );
- Gb_Apu& operator = ( const Gb_Apu& );
-
- Gb_Osc* oscs [osc_count];
- blip_time_t next_frame_time;
- blip_time_t last_time;
- blip_time_t frame_period;
- double volume_unit;
- int frame_count;
-
- Gb_Square square1;
- Gb_Square square2;
- Gb_Wave wave;
- Gb_Noise noise;
- BOOST::uint8_t regs [register_count];
- Gb_Square::Synth square_synth; // used by squares
- Gb_Wave::Synth other_synth; // used by wave and noise
-
- void update_volume();
- void run_until( blip_time_t );
- void write_osc( int index, int reg, int data );
-};
-
-inline void Gb_Apu::output( Blip_Buffer* b ) { output( b, b, b ); }
-
-inline void Gb_Apu::osc_output( int i, Blip_Buffer* b ) { osc_output( i, b, b, b ); }
-
-inline void Gb_Apu::volume( double vol )
-{
- volume_unit = 0.60 / osc_count / 15 /*steps*/ / 2 /*?*/ / 8 /*master vol range*/ * vol;
- update_volume();
-}
-
-#endif
diff --git a/plugins/papu/gb_apu/Gb_Oscs.cpp b/plugins/papu/gb_apu/Gb_Oscs.cpp
deleted file mode 100644
index 735653fa9c3..00000000000
--- a/plugins/papu/gb_apu/Gb_Oscs.cpp
+++ /dev/null
@@ -1,336 +0,0 @@
-// Gb_Snd_Emu 0.1.5. http://www.slack.net/~ant/
-
-#include "Gb_Apu.h"
-
-#include
-
-/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
-can redistribute it and/or modify it under the terms of the GNU Lesser
-General Public License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version. This
-module is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-details. You should have received a copy of the GNU Lesser General Public
-License along with this module; if not, write to the Free Software Foundation,
-Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#include "blargg_source.h"
-
-// Gb_Osc
-
-void Gb_Osc::reset()
-{
- delay = 0;
- last_amp = 0;
- length = 0;
- output_select = 3;
- output = outputs [output_select];
-}
-
-void Gb_Osc::clock_length()
-{
- if ( (regs [4] & len_enabled_mask) && length )
- length--;
-}
-
-// Gb_Env
-
-void Gb_Env::clock_envelope()
-{
- if ( env_delay && !--env_delay )
- {
- env_delay = regs [2] & 7;
- int v = volume - 1 + (regs [2] >> 2 & 2);
- if ( (unsigned) v < 15 )
- volume = v;
- }
-}
-
-bool Gb_Env::write_register( int reg, int data )
-{
- switch ( reg )
- {
- case 1:
- length = 64 - (regs [1] & 0x3F);
- break;
-
- case 2:
- if ( !(data >> 4) )
- enabled = false;
- break;
-
- case 4:
- if ( data & trigger )
- {
- env_delay = regs [2] & 7;
- volume = regs [2] >> 4;
- enabled = true;
- if ( length == 0 )
- length = 64;
- return true;
- }
- }
- return false;
-}
-
-// Gb_Square
-
-void Gb_Square::reset()
-{
- phase = 0;
- sweep_freq = 0;
- sweep_delay = 0;
- Gb_Env::reset();
-}
-
-void Gb_Square::clock_sweep()
-{
- int sweep_period = (regs [0] & period_mask) >> 4;
- if ( sweep_period && sweep_delay && !--sweep_delay )
- {
- sweep_delay = sweep_period;
- regs [3] = sweep_freq & 0xFF;
- regs [4] = (regs [4] & ~0x07) | (sweep_freq >> 8 & 0x07);
-
- int offset = sweep_freq >> (regs [0] & shift_mask);
- if ( regs [0] & 0x08 )
- offset = -offset;
- sweep_freq += offset;
-
- if ( sweep_freq < 0 )
- {
- sweep_freq = 0;
- }
- else if ( sweep_freq >= 2048 )
- {
- sweep_delay = 0; // don't modify channel frequency any further
- sweep_freq = 2048; // silence sound immediately
- }
- }
-}
-
-void Gb_Square::run( blip_time_t time, blip_time_t end_time, int playing )
-{
- if ( sweep_freq == 2048 )
- playing = false;
-
- static unsigned char const table [4] = { 1, 2, 4, 6 };
- int const duty = table [regs [1] >> 6];
- int amp = volume & playing;
- if ( phase >= duty )
- amp = -amp;
-
- int frequency = this->frequency();
- if ( unsigned (frequency - 1) > 2040 ) // frequency < 1 || frequency > 2041
- {
- // really high frequency results in DC at half volume
- amp = volume >> 1;
- playing = false;
- }
-
- {
- int delta = amp - last_amp;
- if ( delta )
- {
- last_amp = amp;
- synth->offset( time, delta, output );
- }
- }
-
- time += delay;
- if ( !playing )
- time = end_time;
-
- if ( time < end_time )
- {
- int const period = (2048 - frequency) * 4;
- Blip_Buffer* const output = this->output;
- int phase = this->phase;
- int delta = amp * 2;
- do
- {
- phase = (phase + 1) & 7;
- if ( phase == 0 || phase == duty )
- {
- delta = -delta;
- synth->offset_inline( time, delta, output );
- }
- time += period;
- }
- while ( time < end_time );
-
- this->phase = phase;
- last_amp = delta >> 1;
- }
- delay = time - end_time;
-}
-
-// Gb_Noise
-
-void Gb_Noise::run( blip_time_t time, blip_time_t end_time, int playing )
-{
- int amp = volume & playing;
- int tap = 13 - (regs [3] & 8);
- if ( bits >> tap & 2 )
- amp = -amp;
-
- {
- int delta = amp - last_amp;
- if ( delta )
- {
- last_amp = amp;
- synth->offset( time, delta, output );
- }
- }
-
- time += delay;
- if ( !playing )
- time = end_time;
-
- if ( time < end_time )
- {
- static unsigned char const table [8] = { 8, 16, 32, 48, 64, 80, 96, 112 };
- int period = table [regs [3] & 7] << (regs [3] >> 4);
-
- // keep parallel resampled time to eliminate time conversion in the loop
- Blip_Buffer* const output = this->output;
- const blip_resampled_time_t resampled_period =
- output->resampled_duration( period );
- blip_resampled_time_t resampled_time = output->resampled_time( time );
- unsigned bits = this->bits;
- int delta = amp * 2;
-
- do
- {
- unsigned changed = (bits >> tap) + 1;
- time += period;
- bits <<= 1;
- if ( changed & 2 )
- {
- delta = -delta;
- bits |= 1;
- synth->offset_resampled( resampled_time, delta, output );
- }
- resampled_time += resampled_period;
- }
- while ( time < end_time );
-
- this->bits = bits;
- last_amp = delta >> 1;
- }
- delay = time - end_time;
-}
-
-// Gb_Wave
-
-inline void Gb_Wave::write_register( int reg, int data )
-{
- switch ( reg )
- {
- case 0:
- if ( !(data & 0x80) )
- enabled = false;
- break;
-
- case 1:
- length = 256 - regs [1];
- break;
-
- case 2:
- volume = data >> 5 & 3;
- break;
-
- case 4:
- if ( data & trigger & regs [0] )
- {
- wave_pos = 0;
- enabled = true;
- if ( length == 0 )
- length = 256;
- }
- }
-}
-
-void Gb_Wave::run( blip_time_t time, blip_time_t end_time, int playing )
-{
- int volume_shift = (volume - 1) & 7; // volume = 0 causes shift = 7
- int frequency;
- {
- int amp = (wave [wave_pos] >> volume_shift & playing) * 2;
-
- frequency = this->frequency();
- if ( unsigned (frequency - 1) > 2044 ) // frequency < 1 || frequency > 2045
- {
- amp = 30 >> volume_shift & playing;
- playing = false;
- }
-
- int delta = amp - last_amp;
- if ( delta )
- {
- last_amp = amp;
- synth->offset( time, delta, output );
- }
- }
-
- time += delay;
- if ( !playing )
- time = end_time;
-
- if ( time < end_time )
- {
- Blip_Buffer* const output = this->output;
- int const period = (2048 - frequency) * 2;
- int wave_pos = (this->wave_pos + 1) & (wave_size - 1);
-
- do
- {
- int amp = (wave [wave_pos] >> volume_shift) * 2;
- wave_pos = (wave_pos + 1) & (wave_size - 1);
- int delta = amp - last_amp;
- if ( delta )
- {
- last_amp = amp;
- synth->offset_inline( time, delta, output );
- }
- time += period;
- }
- while ( time < end_time );
-
- this->wave_pos = (wave_pos - 1) & (wave_size - 1);
- }
- delay = time - end_time;
-}
-
-// Gb_Apu::write_osc
-
-void Gb_Apu::write_osc( int index, int reg, int data )
-{
- reg -= index * 5;
- Gb_Square* sq = &square2;
- switch ( index )
- {
- case 0:
- sq = &square1;
- case 1:
- if ( sq->write_register( reg, data ) && index == 0 )
- {
- square1.sweep_freq = square1.frequency();
- if ( (regs [0] & sq->period_mask) && (regs [0] & sq->shift_mask) )
- {
- square1.sweep_delay = 1; // cause sweep to recalculate now
- square1.clock_sweep();
- }
- }
- break;
-
- case 2:
- wave.write_register( reg, data );
- break;
-
- case 3:
- if ( noise.write_register( reg, data ) )
- noise.bits = 0x7FFF;
- }
-}
diff --git a/plugins/papu/gb_apu/Gb_Oscs.h b/plugins/papu/gb_apu/Gb_Oscs.h
deleted file mode 100644
index d7f88ea1450..00000000000
--- a/plugins/papu/gb_apu/Gb_Oscs.h
+++ /dev/null
@@ -1,83 +0,0 @@
-// Private oscillators used by Gb_Apu
-
-// Gb_Snd_Emu 0.1.5
-#ifndef GB_OSCS_H
-#define GB_OSCS_H
-
-#include "blargg_common.h"
-#include "Blip_Buffer.h"
-
-struct Gb_Osc
-{
- enum { trigger = 0x80 };
- enum { len_enabled_mask = 0x40 };
-
- Blip_Buffer* outputs [4]; // NULL, right, left, center
- Blip_Buffer* output;
- int output_select;
- BOOST::uint8_t* regs; // osc's 5 registers
-
- int delay;
- int last_amp;
- int volume;
- int length;
- int enabled;
-
- void reset();
- void clock_length();
- int frequency() const { return (regs [4] & 7) * 0x100 + regs [3]; }
-};
-
-struct Gb_Env : Gb_Osc
-{
- int env_delay;
-
- void reset();
- void clock_envelope();
- bool write_register( int, int );
-};
-
-struct Gb_Square : Gb_Env
-{
- enum { period_mask = 0x70 };
- enum { shift_mask = 0x07 };
-
- typedef Blip_Synth Synth;
- Synth const* synth;
- int sweep_delay;
- int sweep_freq;
- int phase;
-
- void reset();
- void clock_sweep();
- void run( blip_time_t, blip_time_t, int playing );
-};
-
-struct Gb_Noise : Gb_Env
-{
- typedef Blip_Synth Synth;
- Synth const* synth;
- unsigned bits;
-
- void run( blip_time_t, blip_time_t, int playing );
-};
-
-struct Gb_Wave : Gb_Osc
-{
- typedef Blip_Synth Synth;
- Synth const* synth;
- int wave_pos;
- enum { wave_size = 32 };
- BOOST::uint8_t wave [wave_size];
-
- void write_register( int, int );
- void run( blip_time_t, blip_time_t, int playing );
-};
-
-inline void Gb_Env::reset()
-{
- env_delay = 0;
- Gb_Osc::reset();
-}
-
-#endif
diff --git a/plugins/papu/gb_apu/LGPL.txt b/plugins/papu/gb_apu/LGPL.txt
deleted file mode 100644
index b1e3f5a2638..00000000000
--- a/plugins/papu/gb_apu/LGPL.txt
+++ /dev/null
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-
- Copyright (C)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- , 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/plugins/papu/gb_apu/Multi_Buffer.cpp b/plugins/papu/gb_apu/Multi_Buffer.cpp
deleted file mode 100644
index 57f93b31740..00000000000
--- a/plugins/papu/gb_apu/Multi_Buffer.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-// Blip_Buffer 0.4.1. http://www.slack.net/~ant/
-
-#include "Multi_Buffer.h"
-
-/* Copyright (C) 2003-2006 Shay Green. This module is free software; you
-can redistribute it and/or modify it under the terms of the GNU Lesser
-General Public License as published by the Free Software Foundation; either
-version 2.1 of the License, or (at your option) any later version. This
-module is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-details. You should have received a copy of the GNU Lesser General Public
-License along with this module; if not, write to the Free Software Foundation,
-Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
-
-#include "blargg_source.h"
-
-#ifdef BLARGG_ENABLE_OPTIMIZER
- #include BLARGG_ENABLE_OPTIMIZER
-#endif
-
-Multi_Buffer::Multi_Buffer( int spf ) : samples_per_frame_( spf )
-{
- length_ = 0;
- sample_rate_ = 0;
- channels_changed_count_ = 1;
-}
-
-blargg_err_t Multi_Buffer::set_channel_count( int ) { return 0; }
-
-// Silent_Buffer
-
-Silent_Buffer::Silent_Buffer() : Multi_Buffer( 1 ) // 0 channels would probably confuse
-{
- // TODO: better to use empty Blip_Buffer so caller never has to check for NULL?
- chan.left = 0;
- chan.center = 0;
- chan.right = 0;
-}
-
-// Mono_Buffer
-
-Mono_Buffer::Mono_Buffer() : Multi_Buffer( 1 )
-{
- chan.center = &buf;
- chan.left = &buf;
- chan.right = &buf;
-}
-
-Mono_Buffer::~Mono_Buffer() { }
-
-blargg_err_t Mono_Buffer::set_sample_rate( long rate, int msec )
-{
- RETURN_ERR( buf.set_sample_rate( rate, msec ) );
- return Multi_Buffer::set_sample_rate( buf.sample_rate(), buf.length() );
-}
-
-// Stereo_Buffer
-
-Stereo_Buffer::Stereo_Buffer() : Multi_Buffer( 2 )
-{
- chan.center = &bufs [0];
- chan.left = &bufs [1];
- chan.right = &bufs [2];
-}
-
-Stereo_Buffer::~Stereo_Buffer() { }
-
-blargg_err_t Stereo_Buffer::set_sample_rate( long rate, int msec )
-{
- for ( int i = 0; i < buf_count; i++ )
- RETURN_ERR( bufs [i].set_sample_rate( rate, msec ) );
- return Multi_Buffer::set_sample_rate( bufs [0].sample_rate(), bufs [0].length() );
-}
-
-void Stereo_Buffer::clock_rate( long rate )
-{
- for ( int i = 0; i < buf_count; i++ )
- bufs [i].clock_rate( rate );
-}
-
-void Stereo_Buffer::bass_freq( int bass )
-{
- for ( unsigned i = 0; i < buf_count; i++ )
- bufs [i].bass_freq( bass );
-}
-
-void Stereo_Buffer::clear()
-{
- stereo_added = 0;
- was_stereo = false;
- for ( int i = 0; i < buf_count; i++ )
- bufs [i].clear();
-}
-
-void Stereo_Buffer::end_frame( blip_time_t clock_count )
-{
- stereo_added = 0;
- for ( unsigned i = 0; i < buf_count; i++ )
- {
- stereo_added |= bufs [i].clear_modified() << i;
- bufs [i].end_frame( clock_count );
- }
-}
-
-long Stereo_Buffer::read_samples( blip_sample_t* out, long count )
-{
- require( !(count & 1) ); // count must be even
- count = (unsigned) count / 2;
-
- long avail = bufs [0].samples_avail();
- if ( count > avail )
- count = avail;
- if ( count )
- {
- int bufs_used = stereo_added | was_stereo;
- //debug_printf( "%X\n", bufs_used );
- if ( bufs_used <= 1 )
- {
- mix_mono( out, count );
- bufs [0].remove_samples( count );
- bufs [1].remove_silence( count );
- bufs [2].remove_silence( count );
- }
- else if ( bufs_used & 1 )
- {
- mix_stereo( out, count );
- bufs [0].remove_samples( count );
- bufs [1].remove_samples( count );
- bufs [2].remove_samples( count );
- }
- else
- {
- mix_stereo_no_center( out, count );
- bufs [0].remove_silence( count );
- bufs [1].remove_samples( count );
- bufs [2].remove_samples( count );
- }
-
- // to do: this might miss opportunities for optimization
- if ( !bufs [0].samples_avail() )
- {
- was_stereo = stereo_added;
- stereo_added = 0;
- }
- }
-
- return count * 2;
-}
-
-void Stereo_Buffer::mix_stereo( blip_sample_t* out_, blargg_long count )
-{
- blip_sample_t* BLIP_RESTRICT out = out_;
- int const bass = BLIP_READER_BASS( bufs [1] );
- BLIP_READER_BEGIN( left, bufs [1] );
- BLIP_READER_BEGIN( right, bufs [2] );
- BLIP_READER_BEGIN( center, bufs [0] );
-
- for ( ; count; --count )
- {
- int c = BLIP_READER_READ( center );
- blargg_long l = c + BLIP_READER_READ( left );
- blargg_long r = c + BLIP_READER_READ( right );
- if ( (BOOST::int16_t) l != l )
- l = 0x7FFF - (l >> 24);
-
- BLIP_READER_NEXT( center, bass );
- if ( (BOOST::int16_t) r != r )
- r = 0x7FFF - (r >> 24);
-
- BLIP_READER_NEXT( left, bass );
- BLIP_READER_NEXT( right, bass );
-
- out [0] = l;
- out [1] = r;
- out += 2;
- }
-
- BLIP_READER_END( center, bufs [0] );
- BLIP_READER_END( right, bufs [2] );
- BLIP_READER_END( left, bufs [1] );
-}
-
-void Stereo_Buffer::mix_stereo_no_center( blip_sample_t* out_, blargg_long count )
-{
- blip_sample_t* BLIP_RESTRICT out = out_;
- int const bass = BLIP_READER_BASS( bufs [1] );
- BLIP_READER_BEGIN( left, bufs [1] );
- BLIP_READER_BEGIN( right, bufs [2] );
-
- for ( ; count; --count )
- {
- blargg_long l = BLIP_READER_READ( left );
- if ( (BOOST::int16_t) l != l )
- l = 0x7FFF - (l >> 24);
-
- blargg_long r = BLIP_READER_READ( right );
- if ( (BOOST::int16_t) r != r )
- r = 0x7FFF - (r >> 24);
-
- BLIP_READER_NEXT( left, bass );
- BLIP_READER_NEXT( right, bass );
-
- out [0] = l;
- out [1] = r;
- out += 2;
- }
-
- BLIP_READER_END( right, bufs [2] );
- BLIP_READER_END( left, bufs [1] );
-}
-
-void Stereo_Buffer::mix_mono( blip_sample_t* out_, blargg_long count )
-{
- blip_sample_t* BLIP_RESTRICT out = out_;
- int const bass = BLIP_READER_BASS( bufs [0] );
- BLIP_READER_BEGIN( center, bufs [0] );
-
- for ( ; count; --count )
- {
- blargg_long s = BLIP_READER_READ( center );
- if ( (BOOST::int16_t) s != s )
- s = 0x7FFF - (s >> 24);
-
- BLIP_READER_NEXT( center, bass );
- out [0] = s;
- out [1] = s;
- out += 2;
- }
-
- BLIP_READER_END( center, bufs [0] );
-}
diff --git a/plugins/papu/gb_apu/Multi_Buffer.h b/plugins/papu/gb_apu/Multi_Buffer.h
deleted file mode 100644
index 82c8b3ab5af..00000000000
--- a/plugins/papu/gb_apu/Multi_Buffer.h
+++ /dev/null
@@ -1,158 +0,0 @@
-// Multi-channel sound buffer interface, and basic mono and stereo buffers
-
-// Blip_Buffer 0.4.1
-#ifndef MULTI_BUFFER_H
-#define MULTI_BUFFER_H
-
-#include "blargg_common.h"
-#include "Blip_Buffer.h"
-
-// Interface to one or more Blip_Buffers mapped to one or more channels
-// consisting of left, center, and right buffers.
-class Multi_Buffer {
-public:
- Multi_Buffer( int samples_per_frame );
- virtual ~Multi_Buffer() { }
-
- // Set the number of channels available
- virtual blargg_err_t set_channel_count( int );
-
- // Get indexed channel, from 0 to channel count - 1
- struct channel_t {
- Blip_Buffer* center;
- Blip_Buffer* left;
- Blip_Buffer* right;
- };
- enum { type_index_mask = 0xFF };
- enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type };
- virtual channel_t channel( int index, int type ) = 0;
-
- // See Blip_Buffer.h
- virtual blargg_err_t set_sample_rate( long rate, int msec = blip_default_length ) = 0;
- virtual void clock_rate( long ) = 0;
- virtual void bass_freq( int ) = 0;
- virtual void clear() = 0;
- long sample_rate() const;
-
- // Length of buffer, in milliseconds
- int length() const;
-
- // See Blip_Buffer.h
- virtual void end_frame( blip_time_t ) = 0;
-
- // Number of samples per output frame (1 = mono, 2 = stereo)
- int samples_per_frame() const;
-
- // Count of changes to channel configuration. Incremented whenever
- // a change is made to any of the Blip_Buffers for any channel.
- unsigned channels_changed_count() { return channels_changed_count_; }
-
- // See Blip_Buffer.h
- virtual long read_samples( blip_sample_t*, long ) = 0;
- virtual long samples_avail() const = 0;
-
-public:
- BLARGG_DISABLE_NOTHROW
-protected:
- void channels_changed() { channels_changed_count_++; }
-private:
- // noncopyable
- Multi_Buffer( const Multi_Buffer& );
- Multi_Buffer& operator = ( const Multi_Buffer& );
-
- unsigned channels_changed_count_;
- long sample_rate_;
- int length_;
- int const samples_per_frame_;
-};
-
-// Uses a single buffer and outputs mono samples.
-class Mono_Buffer : public Multi_Buffer {
- Blip_Buffer buf;
- channel_t chan;
-public:
- // Buffer used for all channels
- Blip_Buffer* center() { return &buf; }
-
-public:
- Mono_Buffer();
- ~Mono_Buffer();
- blargg_err_t set_sample_rate( long rate, int msec = blip_default_length );
- void clock_rate( long rate ) { buf.clock_rate( rate ); }
- void bass_freq( int freq ) { buf.bass_freq( freq ); }
- void clear() { buf.clear(); }
- long samples_avail() const { return buf.samples_avail(); }
- long read_samples( blip_sample_t* p, long s ) { return buf.read_samples( p, s ); }
- channel_t channel( int, int ) { return chan; }
- void end_frame( blip_time_t t ) { buf.end_frame( t ); }
-};
-
-// Uses three buffers (one for center) and outputs stereo sample pairs.
-class Stereo_Buffer : public Multi_Buffer {
-public:
-
- // Buffers used for all channels
- Blip_Buffer* center() { return &bufs [0]; }
- Blip_Buffer* left() { return &bufs [1]; }
- Blip_Buffer* right() { return &bufs [2]; }
-
-public:
- Stereo_Buffer();
- ~Stereo_Buffer();
- blargg_err_t set_sample_rate( long, int msec = blip_default_length );
- void clock_rate( long );
- void bass_freq( int );
- void clear();
- channel_t channel( int, int ) { return chan; }
- void end_frame( blip_time_t );
-
- long samples_avail() const { return bufs [0].samples_avail() * 2; }
- long read_samples( blip_sample_t*, long );
-
-private:
- enum { buf_count = 3 };
- Blip_Buffer bufs [buf_count];
- channel_t chan;
- int stereo_added;
- int was_stereo;
-
- void mix_stereo_no_center( blip_sample_t*, blargg_long );
- void mix_stereo( blip_sample_t*, blargg_long );
- void mix_mono( blip_sample_t*, blargg_long );
-};
-
-// Silent_Buffer generates no samples, useful where no sound is wanted
-class Silent_Buffer : public Multi_Buffer {
- channel_t chan;
-public:
- Silent_Buffer();
- blargg_err_t set_sample_rate( long rate, int msec = blip_default_length );
- void clock_rate( long ) { }
- void bass_freq( int ) { }
- void clear() { }
- channel_t channel( int, int ) { return chan; }
- void end_frame( blip_time_t ) { }
- long samples_avail() const { return 0; }
- long read_samples( blip_sample_t*, long ) { return 0; }
-};
-
-
-inline blargg_err_t Multi_Buffer::set_sample_rate( long rate, int msec )
-{
- sample_rate_ = rate;
- length_ = msec;
- return 0;
-}
-
-inline blargg_err_t Silent_Buffer::set_sample_rate( long rate, int msec )
-{
- return Multi_Buffer::set_sample_rate( rate, msec );
-}
-
-inline int Multi_Buffer::samples_per_frame() const { return samples_per_frame_; }
-
-inline long Multi_Buffer::sample_rate() const { return sample_rate_; }
-
-inline int Multi_Buffer::length() const { return length_; }
-
-#endif
diff --git a/plugins/papu/gb_apu/blargg_common.h b/plugins/papu/gb_apu/blargg_common.h
deleted file mode 100644
index ed218a8da3a..00000000000
--- a/plugins/papu/gb_apu/blargg_common.h
+++ /dev/null
@@ -1,196 +0,0 @@
-// Sets up common environment for Shay Green's libraries.
-// To change configuration options, modify blargg_config.h, not this file.
-
-#ifndef BLARGG_COMMON_H
-#define BLARGG_COMMON_H
-
-#include
-#include
-#include
-#include
-
-#undef BLARGG_COMMON_H
-// allow blargg_config.h to #include blargg_common.h
-#include "blargg_config.h"
-#ifndef BLARGG_COMMON_H
-#define BLARGG_COMMON_H
-
-// BLARGG_RESTRICT: equivalent to restrict, where supported
-#if __GNUC__ >= 3 || _MSC_VER >= 1100
- #define BLARGG_RESTRICT __restrict
-#else
- #define BLARGG_RESTRICT
-#endif
-
-// STATIC_CAST(T,expr): Used in place of static_cast (expr)
-#ifndef STATIC_CAST
- #define STATIC_CAST(T,expr) ((T) (expr))
-#endif
-
-// blargg_err_t (0 on success, otherwise error string)
-#ifndef blargg_err_t
- typedef const char* blargg_err_t;
-#endif
-
-// blargg_vector - very lightweight vector of POD types (no constructor/destructor)
-template
-class blargg_vector {
- T* begin_;
- size_t size_;
-public:
- blargg_vector() : begin_( 0 ), size_( 0 ) { }
- ~blargg_vector() { free( begin_ ); }
- size_t size() const { return size_; }
- T* begin() const { return begin_; }
- T* end() const { return begin_ + size_; }
- blargg_err_t resize( size_t n )
- {
- void* p = realloc( begin_, n * sizeof (T) );
- if ( !p && n )
- return "Out of memory";
- begin_ = (T*) p;
- size_ = n;
- return 0;
- }
- void clear() { void* p = begin_; begin_ = 0; size_ = 0; free( p ); }
- T& operator [] ( size_t n ) const
- {
- assert( n <= size_ ); // <= to allow past-the-end value
- return begin_ [n];
- }
-};
-
-#ifndef BLARGG_DISABLE_NOTHROW
- // throw spec mandatory in ISO C++ if operator new can return NULL
- #if __cplusplus >= 199711 || __GNUC__ >= 3
- #define BLARGG_THROWS( spec ) throw spec
- #else
- #define BLARGG_THROWS( spec )
- #endif
- #define BLARGG_DISABLE_NOTHROW \
- void* operator new ( size_t s ) BLARGG_THROWS(()) { return malloc( s ); }\
- void operator delete ( void* p ) { free( p ); }
- #define BLARGG_NEW new
-#else
- #include
- #define BLARGG_NEW new (std::nothrow)
-#endif
-
-// BLARGG_4CHAR('a','b','c','d') = 'abcd' (four character integer constant)
-#define BLARGG_4CHAR( a, b, c, d ) \
- ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF))
-
-// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0.
-#ifndef BOOST_STATIC_ASSERT
- #ifdef _MSC_VER
- // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified
- #define BOOST_STATIC_ASSERT( expr ) \
- void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] )
- #else
- // Some other compilers fail when declaring same function multiple times in class,
- // so differentiate them by line
- #define BOOST_STATIC_ASSERT( expr ) \
- void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] )
- #endif
-#endif
-
-// BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1,
-// compiler is assumed to support bool. If undefined, availability is determined.
-#ifndef BLARGG_COMPILER_HAS_BOOL
- #if defined (__MWERKS__)
- #if !__option(bool)
- #define BLARGG_COMPILER_HAS_BOOL 0
- #endif
- #elif defined (_MSC_VER)
- #if _MSC_VER < 1100
- #define BLARGG_COMPILER_HAS_BOOL 0
- #endif
- #elif defined (__GNUC__)
- // supports bool
- #elif __cplusplus < 199711
- #define BLARGG_COMPILER_HAS_BOOL 0
- #endif
-#endif
-#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL
- // If you get errors here, modify your blargg_config.h file
- typedef int bool;
- const bool true = 1;
- const bool false = 0;
-#endif
-
-// blargg_long/blargg_ulong = at least 32 bits, int if it's big enough
-
-#if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF
- typedef long blargg_long;
-#else
- typedef int blargg_long;
-#endif
-
-#if UINT_MAX < 0xFFFFFFFF || ULONG_MAX == 0xFFFFFFFF
- typedef unsigned long blargg_ulong;
-#else
- typedef unsigned blargg_ulong;
-#endif
-
-// BOOST::int8_t etc.
-
-// HAVE_STDINT_H: If defined, use for int8_t etc.
-#if defined (HAVE_STDINT_H)
- #include
- #define BOOST
-
-// HAVE_INTTYPES_H: If defined, use for int8_t etc.
-#elif defined (HAVE_INTTYPES_H)
- #include
- #define BOOST
-
-#else
- struct BOOST
- {
- #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F
- typedef signed char int8_t;
- typedef unsigned char uint8_t;
- #else
- // No suitable 8-bit type available
- typedef struct see_blargg_common_h int8_t;
- typedef struct see_blargg_common_h uint8_t;
- #endif
-
- #if USHRT_MAX == 0xFFFF
- typedef short int16_t;
- typedef unsigned short uint16_t;
- #else
- // No suitable 16-bit type available
- typedef struct see_blargg_common_h int16_t;
- typedef struct see_blargg_common_h uint16_t;
- #endif
-
- #if ULONG_MAX == 0xFFFFFFFF
- typedef long int32_t;
- typedef unsigned long uint32_t;
- #elif UINT_MAX == 0xFFFFFFFF
- typedef int int32_t;
- typedef unsigned int uint32_t;
- #else
- // No suitable 32-bit type available
- typedef struct see_blargg_common_h int32_t;
- typedef struct see_blargg_common_h uint32_t;
- #endif
- };
-#endif
-
-#if __GNUC__ >= 3
- #define BLARGG_DEPRECATED __attribute__ ((deprecated))
-#else
- #define BLARGG_DEPRECATED
-#endif
-
-// Use in place of "= 0;" for a pure virtual, since these cause calls to std C++ lib.
-// During development, BLARGG_PURE( x ) expands to = 0;
-// virtual int func() BLARGG_PURE( { return 0; } )
-#ifndef BLARGG_PURE
- #define BLARGG_PURE( def ) def
-#endif
-
-#endif
-#endif
diff --git a/plugins/papu/gb_apu/blargg_config.h b/plugins/papu/gb_apu/blargg_config.h
deleted file mode 100644
index 377dd2d8c46..00000000000
--- a/plugins/papu/gb_apu/blargg_config.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Library configuration. Modify this file as necessary.
-
-#ifndef BLARGG_CONFIG_H
-#define BLARGG_CONFIG_H
-
-// Uncomment to use zlib for transparent decompression of gzipped files
-//#define HAVE_ZLIB_H
-
-// Uncomment and edit list to support only the listed game music types,
-// so that the others don't get linked in at all.
-/*
-#define GME_TYPE_LIST \
- gme_ay_type,\
- gme_gbs_type,\
- gme_gym_type,\
- gme_hes_type,\
- gme_kss_type,\
- gme_nsf_type,\
- gme_nsfe_type,\
- gme_sap_type,\
- gme_spc_type,\
- gme_vgm_type,\
- gme_vgz_type
-*/
-
-// Uncomment to enable platform-specific optimizations
-//#define BLARGG_NONPORTABLE 1
-
-// Uncomment to use faster, lower quality sound synthesis
-//#define BLIP_BUFFER_FAST 1
-
-// Uncomment if automatic byte-order determination doesn't work
-//#define BLARGG_BIG_ENDIAN 1
-
-// Uncomment if you get errors in the bool section of blargg_common.h
-//#define BLARGG_COMPILER_HAS_BOOL 1
-
-// Use standard config.h if present
-#ifdef HAVE_CONFIG_H
- #include "config.h"
-#endif
-
-#endif
diff --git a/plugins/papu/gb_apu/blargg_source.h b/plugins/papu/gb_apu/blargg_source.h
deleted file mode 100644
index b011777ad8f..00000000000
--- a/plugins/papu/gb_apu/blargg_source.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Included at the beginning of library source files, after all other #include lines.
-Sets up helpful macros and services used in my source code. They don't need
-module an annoying module prefix on their names since they are defined after
-all other #include lines. */
-
-#ifndef BLARGG_SOURCE_H
-#define BLARGG_SOURCE_H
-
-// If debugging is enabled, abort program if expr is false. Meant for checking
-// internal state and consistency. A failed assertion indicates a bug in the module.
-// void assert( bool expr );
-#include
-
-// If debugging is enabled and expr is false, abort program. Meant for checking
-// caller-supplied parameters and operations that are outside the control of the
-// module. A failed requirement indicates a bug outside the module.
-// void require( bool expr );
-#undef require
-#define require( expr ) assert( expr )
-
-// Like printf() except output goes to debug log file. Might be defined to do
-// nothing (not even evaluate its arguments).
-// void debug_printf( const char* format, ... );
-static inline void blargg_dprintf_( const char*, ... ) { }
-#undef debug_printf
-#define debug_printf (1) ? (void) 0 : blargg_dprintf_
-
-// If enabled, evaluate expr and if false, make debug log entry with source file
-// and line. Meant for finding situations that should be examined further, but that
-// don't indicate a problem. In all cases, execution continues normally.
-#undef check
-#define check( expr ) ((void) 0)
-
-// If expr yields error string, return it from current function, otherwise continue.
-#undef RETURN_ERR
-#define RETURN_ERR( expr ) do { \
- blargg_err_t blargg_return_err_ = (expr); \
- if ( blargg_return_err_ ) return blargg_return_err_; \
- } while ( 0 )
-
-// If ptr is 0, return out of memory error string.
-#undef CHECK_ALLOC
-#define CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 )
-
-// Avoid any macros which evaluate their arguments multiple times
-#undef min
-#undef max
-
-#define DEF_MIN_MAX( type ) \
- static inline type min( type x, type y ) { if ( x < y ) return x; return y; }\
- static inline type max( type x, type y ) { if ( y < x ) return x; return y; }
-
-DEF_MIN_MAX( int )
-DEF_MIN_MAX( unsigned )
-DEF_MIN_MAX( long )
-DEF_MIN_MAX( unsigned long )
-DEF_MIN_MAX( float )
-DEF_MIN_MAX( double )
-
-#undef DEF_MIN_MAX
-
-/*
-// using const references generates crappy code, and I am currenly only using these
-// for built-in types, so they take arguments by value
-
-// TODO: remove
-inline int min( int x, int y )
-template
-inline T min( T x, T y )
-{
- if ( x < y )
- return x;
- return y;
-}
-
-template
-inline T max( T x, T y )
-{
- if ( x < y )
- return y;
- return x;
-}
-*/
-
-// TODO: good idea? bad idea?
-#undef byte
-#define byte byte_
-typedef unsigned char byte;
-
-// Setup compiler defines useful for exporting required public API symbols in gme.cpp
-#ifndef BLARGG_EXPORT
- #if defined (_WIN32) && defined(BLARGG_BUILD_DLL)
- #define BLARGG_EXPORT __declspec(dllexport)
- #elif defined (LIBGME_VISIBILITY)
- #define BLARGG_EXPORT __attribute__((visibility ("default")))
- #else
- #define BLARGG_EXPORT
- #endif
-#endif
-
-// deprecated
-#define BLARGG_CHECK_ALLOC CHECK_ALLOC
-#define BLARGG_RETURN_ERR RETURN_ERR
-
-// BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of debug_printf and check
-#ifdef BLARGG_SOURCE_BEGIN
- #include BLARGG_SOURCE_BEGIN
-#endif
-
-#endif
diff --git a/plugins/papu/gb_apu/boost/config.hpp b/plugins/papu/gb_apu/boost/config.hpp
deleted file mode 100644
index f271715c5b8..00000000000
--- a/plugins/papu/gb_apu/boost/config.hpp
+++ /dev/null
@@ -1,13 +0,0 @@
-
-// Boost substitute. For full boost library see http://boost.org
-
-#ifndef BOOST_CONFIG_HPP
-#define BOOST_CONFIG_HPP
-
-#define BOOST_MINIMAL 1
-
-#define BLARGG_BEGIN_NAMESPACE( name )
-#define BLARGG_END_NAMESPACE
-
-#endif
-
diff --git a/plugins/papu/gb_apu/boost/cstdint.hpp b/plugins/papu/gb_apu/boost/cstdint.hpp
deleted file mode 100644
index e446dfdd904..00000000000
--- a/plugins/papu/gb_apu/boost/cstdint.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-
-// Boost substitute. For full boost library see http://boost.org
-
-#ifndef BOOST_CSTDINT_HPP
-#define BOOST_CSTDINT_HPP
-
-#if BLARGG_USE_NAMESPACE
- #include
-#else
- #include
-#endif
-
-BLARGG_BEGIN_NAMESPACE( boost )
-
-#if UCHAR_MAX != 0xFF || SCHAR_MAX != 0x7F
-# error "No suitable 8-bit type available"
-#endif
-
-typedef unsigned char uint8_t;
-typedef signed char int8_t;
-
-#if USHRT_MAX != 0xFFFF
-# error "No suitable 16-bit type available"
-#endif
-
-typedef short int16_t;
-typedef unsigned short uint16_t;
-
-#if ULONG_MAX == 0xFFFFFFFF
- typedef long int32_t;
- typedef unsigned long uint32_t;
-#elif UINT_MAX == 0xFFFFFFFF
- typedef int int32_t;
- typedef unsigned int uint32_t;
-#else
-# error "No suitable 32-bit type available"
-#endif
-
-BLARGG_END_NAMESPACE
-
-#endif
-
diff --git a/plugins/papu/gb_apu/boost/static_assert.hpp b/plugins/papu/gb_apu/boost/static_assert.hpp
deleted file mode 100644
index 66927ccbb7e..00000000000
--- a/plugins/papu/gb_apu/boost/static_assert.hpp
+++ /dev/null
@@ -1,22 +0,0 @@
-
-// Boost substitute. For full boost library see http://boost.org
-
-#ifndef BOOST_STATIC_ASSERT_HPP
-#define BOOST_STATIC_ASSERT_HPP
-
-#if defined (_MSC_VER) && _MSC_VER <= 1200
- // MSVC6 can't handle the ##line concatenation
- #define BOOST_STATIC_ASSERT( expr ) struct { int n [1 / ((expr) ? 1 : 0)]; }
-
-#else
- #define BOOST_STATIC_ASSERT3( expr, line ) \
- typedef int boost_static_assert_##line [1 / ((expr) ? 1 : 0)]
-
- #define BOOST_STATIC_ASSERT2( expr, line ) BOOST_STATIC_ASSERT3( expr, line )
-
- #define BOOST_STATIC_ASSERT( expr ) BOOST_STATIC_ASSERT2( expr, __LINE__ )
-
-#endif
-
-#endif
-
diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp
index dc2b1de5791..9a1d150642e 100644
--- a/src/core/DataFile.cpp
+++ b/src/core/DataFile.cpp
@@ -968,6 +968,26 @@ void DataFile::upgrade_1_2_0_rc2_42()
}
+void DataFile::upgrade_1_3_0()
+{
+ QDomNodeList list = elementsByTagName( "instrument" );
+ for( int i = 0; !list.item( i ).isNull(); ++i )
+ {
+ QDomElement el = list.item( i ).toElement();
+ if( el.attribute( "name" ) == "papu" )
+ {
+ el.setAttribute( "name", "freeboy" );
+ QDomNodeList children = el.elementsByTagName( "papu" );
+ for( int j = 0; !children.item( j ).isNull(); ++j )
+ {
+ QDomElement child = children.item( j ).toElement();
+ child.setTagName( "freeboy" );
+ }
+ }
+ }
+}
+
+
void DataFile::upgrade()
{
ProjectVersion version =
@@ -1049,6 +1069,10 @@ void DataFile::upgrade()
upgrade_1_2_0_rc3();
upgrade_1_2_0_rc2_42();
}
+ if( version < "1.3.0" )
+ {
+ upgrade_1_3_0();
+ }
// update document meta data
documentElement().setAttribute( "version", LDF_VERSION_STRING );