1 /*
2 * Interfaces over Yamaha OPL3 (YMF262) chip emulators
3 *
4 * Copyright (C) 2017-2018 Vitaly Novichkov (Wohlstand)
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "nuked_opl3_v174.h"
22 #include "nuked/nukedopl3_174.h"
23 #include <cstring>
24
NukedOPL3v174()25 NukedOPL3v174::NukedOPL3v174() :
26 OPLChipBaseT()
27 {
28 m_chip = new opl3_chip;
29 setRate(m_rate);
30 }
31
~NukedOPL3v174()32 NukedOPL3v174::~NukedOPL3v174()
33 {
34 opl3_chip *chip_r = reinterpret_cast<opl3_chip*>(m_chip);
35 delete chip_r;
36 }
37
setRate(uint32_t rate)38 void NukedOPL3v174::setRate(uint32_t rate)
39 {
40 OPLChipBaseT::setRate(rate);
41 opl3_chip *chip_r = reinterpret_cast<opl3_chip*>(m_chip);
42 std::memset(chip_r, 0, sizeof(opl3_chip));
43 OPL3v17_Reset(chip_r, rate);
44 }
45
reset()46 void NukedOPL3v174::reset()
47 {
48 OPLChipBaseT::reset();
49 opl3_chip *chip_r = reinterpret_cast<opl3_chip*>(m_chip);
50 std::memset(chip_r, 0, sizeof(opl3_chip));
51 OPL3v17_Reset(chip_r, m_rate);
52 }
53
writeReg(uint16_t addr,uint8_t data)54 void NukedOPL3v174::writeReg(uint16_t addr, uint8_t data)
55 {
56 opl3_chip *chip_r = reinterpret_cast<opl3_chip*>(m_chip);
57 OPL3v17_WriteReg(chip_r, addr, data);
58 }
59
nativeGenerate(int16_t * frame)60 void NukedOPL3v174::nativeGenerate(int16_t *frame)
61 {
62 opl3_chip *chip_r = reinterpret_cast<opl3_chip*>(m_chip);
63 OPL3v17_Generate(chip_r, frame);
64 }
65
emulatorName()66 const char *NukedOPL3v174::emulatorName()
67 {
68 return "Nuked OPL3 (v 1.7.4)";
69 }
70