mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 04:51:19 +00:00
new opl3 emulator
This commit is contained in:
parent
601852d224
commit
e9075334a3
7 changed files with 1276 additions and 2 deletions
|
@ -992,6 +992,7 @@ add_executable( zdoom WIN32
|
|||
oplsynth/opl_mus_player.cpp
|
||||
oplsynth/dosbox/opl.cpp
|
||||
oplsynth/OPL3.cpp
|
||||
oplsynth/nukedopl3.cpp
|
||||
resourcefiles/ancientzip.cpp
|
||||
resourcefiles/file_7z.cpp
|
||||
resourcefiles/file_grp.cpp
|
||||
|
|
|
@ -323,7 +323,7 @@ int OPLio::OPLinit(uint numchips, bool stereo, bool initopl3)
|
|||
{
|
||||
assert(numchips >= 1 && numchips <= countof(chips));
|
||||
uint i;
|
||||
IsOPL3 = (opl_core == 1 || opl_core == 2);
|
||||
IsOPL3 = (opl_core == 1 || opl_core == 2 || opl_core == 3);
|
||||
|
||||
memset(chips, 0, sizeof(chips));
|
||||
if (IsOPL3)
|
||||
|
@ -332,7 +332,7 @@ int OPLio::OPLinit(uint numchips, bool stereo, bool initopl3)
|
|||
}
|
||||
for (i = 0; i < numchips; ++i)
|
||||
{
|
||||
OPLEmul *chip = IsOPL3 ? (opl_core == 1 ? DBOPLCreate(stereo) : JavaOPLCreate(stereo)) : YM3812Create(stereo);
|
||||
OPLEmul *chip = IsOPL3 ? (opl_core == 1 ? DBOPLCreate(stereo) : (opl_core == 2 ? JavaOPLCreate(stereo) : NukedOPL3Create(stereo))) : YM3812Create(stereo);
|
||||
if (chip == NULL)
|
||||
{
|
||||
break;
|
||||
|
|
1145
src/oplsynth/nukedopl3.cpp
Normal file
1145
src/oplsynth/nukedopl3.cpp
Normal file
File diff suppressed because it is too large
Load diff
118
src/oplsynth/nukedopl3.h
Normal file
118
src/oplsynth/nukedopl3.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Copyright (C) 2013-2014 Nuke.YKT
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
Nuked Yamaha YMF262(aka OPL3) emulator.
|
||||
Thanks:
|
||||
MAME Development Team:
|
||||
Feedback and Rhythm part calculation information.
|
||||
forums.submarine.org.uk(carbon14, opl3):
|
||||
Tremolo and phase generator calculation information.
|
||||
*/
|
||||
|
||||
//version 1.4.2
|
||||
|
||||
#include "opl.h"
|
||||
#include "muslib.h"
|
||||
|
||||
typedef uintptr_t Bitu;
|
||||
typedef intptr_t Bits;
|
||||
typedef DWORD Bit32u;
|
||||
typedef SDWORD Bit32s;
|
||||
typedef WORD Bit16u;
|
||||
typedef SWORD Bit16s;
|
||||
typedef BYTE Bit8u;
|
||||
typedef SBYTE Bit8s;
|
||||
|
||||
struct channel {
|
||||
Bit8u con;
|
||||
Bit8u chtype;
|
||||
Bit8u alg;
|
||||
Bit16u offset;
|
||||
Bit8u feedback;
|
||||
Bit16u cha, chb, chc, chd;
|
||||
Bit16s out;
|
||||
Bit16u f_number;
|
||||
Bit8u block;
|
||||
Bit8u ksv;
|
||||
float panl;
|
||||
float panr;
|
||||
};
|
||||
|
||||
struct slot {
|
||||
Bit32u PG_pos;
|
||||
Bit32u PG_inc;
|
||||
Bit16s EG_out;
|
||||
Bit8u eg_inc;
|
||||
Bit8u eg_gen;
|
||||
Bit8u eg_gennext;
|
||||
Bit16u EG_mout;
|
||||
Bit8u EG_ksl;
|
||||
Bit8u EG_ar;
|
||||
Bit8u EG_dr;
|
||||
Bit8u EG_sl;
|
||||
Bit8u EG_rr;
|
||||
Bit8u EG_state;
|
||||
Bit8u EG_type;
|
||||
Bit16s out;
|
||||
Bit16s *mod;
|
||||
Bit16s prevout[2];
|
||||
Bit16s fbmod;
|
||||
Bit16u offset;
|
||||
Bit8u mult;
|
||||
Bit8u vibrato;
|
||||
Bit8u tremolo;
|
||||
Bit8u ksr;
|
||||
Bit8u EG_tl;
|
||||
Bit8u ksl;
|
||||
Bit8u key;
|
||||
Bit8u waveform;
|
||||
};
|
||||
|
||||
|
||||
struct chip {
|
||||
Bit8u opl_memory[0x200];
|
||||
Bit8u newm;
|
||||
Bit8u nts;
|
||||
Bit8u rhythm;
|
||||
Bit8u dvb;
|
||||
Bit8u dam;
|
||||
Bit32u noise;
|
||||
Bit16u vib_pos;
|
||||
Bit16u timer;
|
||||
Bit8u trem_inc;
|
||||
Bit8u trem_tval;
|
||||
Bit8u trem_dir;
|
||||
Bit8u trem_val;
|
||||
channel Channels[18];
|
||||
slot OPs[36];
|
||||
Bit16s zm;
|
||||
};
|
||||
|
||||
class NukedOPL3 : public OPLEmul {
|
||||
private:
|
||||
chip opl3;
|
||||
bool FullPan;
|
||||
public:
|
||||
void Reset();
|
||||
void Update(float* sndptr, int numsamples);
|
||||
void WriteReg(int reg, int v);
|
||||
void SetPanning(int c, float left, float right);
|
||||
|
||||
NukedOPL3(bool stereo);
|
||||
};
|
|
@ -20,6 +20,7 @@ public:
|
|||
OPLEmul *YM3812Create(bool stereo);
|
||||
OPLEmul *DBOPLCreate(bool stereo);
|
||||
OPLEmul *JavaOPLCreate(bool stereo);
|
||||
OPLEmul *NukedOPL3Create(bool stereo);
|
||||
|
||||
#define OPL_SAMPLE_RATE 49716.0
|
||||
#define CENTER_PANNING_POWER 0.70710678118 /* [RH] volume at center for EQP */
|
||||
|
|
|
@ -1478,6 +1478,7 @@ OptionValue OplCores
|
|||
0, "MAME OPL2"
|
||||
1, "DOSBox OPL3"
|
||||
2, "Java OPL3"
|
||||
3, "Nuked OPL3"
|
||||
}
|
||||
|
||||
OptionMenu AdvSoundOptions
|
||||
|
|
|
@ -2632,6 +2632,14 @@
|
|||
RelativePath=".\src\oplsynth\opl_mus_player.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\oplsynth\nukedopl3.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\oplsynth\nukedopl3.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="DOSBox"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue