DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
src/hardware/nukedopl.h
00001 //
00002 // Copyright (C) 2013-2016 Alexey Khokholov (Nuke.YKT)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 //
00015 //  Nuked OPL3 emulator.
00016 //  Thanks:
00017 //      MAME Development Team(Jarek Burczynski, Tatsuyuki Satoh):
00018 //          Feedback and Rhythm part calculation information.
00019 //      forums.submarine.org.uk(carbon14, opl3):
00020 //          Tremolo and phase generator calculation information.
00021 //      OPLx decapsulated(Matthew Gambrell, Olli Niemitalo):
00022 //          OPL2 ROMs.
00023 //
00024 
00025 #ifndef DOSBOX_NUKEDOPL_H
00026 #define DOSBOX_NUKEDOPL_H
00027 
00028 #include "dosbox.h"
00029 
00030 struct opl3_chip;
00031 struct opl3_slot;
00032 struct opl3_channel;
00033 
00034 struct opl3_slot {
00035     opl3_channel *channel;
00036     opl3_chip *chip;
00037     Bit16s out;
00038     Bit16s fbmod;
00039     Bit16s *mod;
00040     Bit16s prout;
00041     Bit16s eg_rout;
00042     Bit16s eg_out;
00043     Bit8u eg_inc;
00044     Bit8u eg_gen;
00045     Bit8u eg_rate;
00046     Bit8u eg_ksl;
00047     Bit8u *trem;
00048     Bit8u reg_vib;
00049     Bit8u reg_type;
00050     Bit8u reg_ksr;
00051     Bit8u reg_mult;
00052     Bit8u reg_ksl;
00053     Bit8u reg_tl;
00054     Bit8u reg_ar;
00055     Bit8u reg_dr;
00056     Bit8u reg_sl;
00057     Bit8u reg_rr;
00058     Bit8u reg_wf;
00059     Bit8u key;
00060     Bit32u pg_phase;
00061     Bit32u timer;
00062 };
00063 
00064 struct opl3_channel {
00065     opl3_slot *slots[2];
00066     opl3_channel *pair;
00067     opl3_chip *chip;
00068     Bit16s *out[4];
00069     Bit8u chtype;
00070     Bit16u f_num;
00071     Bit8u block;
00072     Bit8u fb;
00073     Bit8u con;
00074     Bit8u alg;
00075     Bit8u ksv;
00076     Bit16u cha, chb;
00077 };
00078 
00079 struct opl3_chip {
00080     opl3_channel channel[18];
00081     opl3_slot slot[36];
00082     Bit16u timer;
00083     Bit8u newm;
00084     Bit8u nts;
00085     Bit8u rhy;
00086     Bit8u vibpos;
00087     Bit8u vibshift;
00088     Bit8u tremolo;
00089     Bit8u tremolopos;
00090     Bit8u tremoloshift;
00091     Bit32u noise;
00092     Bit16s zeromod;
00093     Bit32s mixbuff[2];
00094 
00095     Bit32s rateratio;
00096     Bit32s samplecnt;
00097     Bit16s oldsamples[2];
00098     Bit16s samples[2];
00099 };
00100 
00101 void OPL3_Generate(opl3_chip *chip, Bit16s *buf);
00102 void OPL3_GenerateResampled(opl3_chip *chip, Bit16s *buf);
00103 void OPL3_Reset(opl3_chip *chip, Bit32u samplerate);
00104 void OPL3_WriteReg(opl3_chip *chip, Bit16u reg, Bit8u v);
00105 void OPL3_GenerateStream(opl3_chip *chip, Bit16s *sndptr, Bit32u numsamples);
00106 #endif