ScummVM API documentation
dosbox.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/*
23 * Based on OPL emulation code of DOSBox
24 * Copyright (C) 2002-2009 The DOSBox Team
25 * Licensed under GPLv2+
26 * http://www.dosbox.com
27 */
28
29#ifndef AUDIO_SOFTSYNTH_OPL_DOSBOX_H
30#define AUDIO_SOFTSYNTH_OPL_DOSBOX_H
31
32#ifndef DISABLE_DOSBOX_OPL
33
34#include "audio/fmopl.h"
35
36namespace OPL {
37namespace DOSBox {
38
39struct Timer {
40 double startTime;
41 double delay;
42 bool enabled, overflow, masked;
43 uint8 counter;
44
45 Timer();
46
47 //Call update before making any further changes
48 void update(double time);
49
50 //On a reset make sure the start is in sync with the next cycle
51 void reset(double time);
52
53 void stop();
54
55 void start(double time, int scale);
56};
57
58struct Chip {
59 //Last selected register
60 Timer timer[2];
61 //Check for it being a write to the timer
62 bool write(uint32 addr, uint8 val);
63 //Read the current timer state, will use current double
64 uint8 read();
65};
66
67namespace DBOPL {
68struct Chip;
69} // end of namespace DBOPL
70
71class OPL : public ::OPL::OPL, public Audio::EmulatedChip {
72private:
73 Config::OplType _type;
74 uint _rate;
75
76 DBOPL::Chip *_emulator;
77 ::OPL::DOSBox::Chip _chip[2];
78 union {
79 uint16 normal;
80 uint8 dual[2];
81 } _reg;
82
83 void free();
84 void dualWrite(uint8 index, uint8 reg, uint8 val);
85public:
86 OPL(Config::OplType type);
87 ~OPL();
88
89 bool init() override;
90 void reset() override;
91
92 void write(int a, int v) override;
93
94 void writeReg(int r, int v) override;
95
96 bool isStereo() const override { return _type != Config::kOpl2; }
97
98protected:
99 void generateSamples(int16 *buffer, int length) override;
100};
101
102} // End of namespace DOSBox
103} // End of namespace OPL
104
105#endif // !DISABLE_DOSBOX_OPL
106
107#endif
Definition: chip.h:112
OplType
Definition: fmopl.h:58
Definition: dosbox.h:71
void generateSamples(int16 *buffer, int length) override
bool isStereo() const override
Definition: dosbox.h:96
void reset() override
void write(int a, int v) override
bool init() override
void writeReg(int r, int v) override
Definition: fmopl.h:116
Definition: dosbox.h:58
Definition: dbopl.h:221
Definition: dosbox.h:39