ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

dosbox.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 /*
00024  * Based on OPL emulation code of DOSBox
00025  * Copyright (C) 2002-2009  The DOSBox Team
00026  * Licensed under GPLv2+
00027  * http://www.dosbox.com
00028  */
00029 
00030 #ifndef AUDIO_SOFTSYNTH_OPL_DOSBOX_H
00031 #define AUDIO_SOFTSYNTH_OPL_DOSBOX_H
00032 
00033 #ifndef DISABLE_DOSBOX_OPL
00034 
00035 #include "audio/fmopl.h"
00036 
00037 namespace OPL {
00038 namespace DOSBox {
00039 
00040 struct Timer {
00041     double startTime;
00042     double delay;
00043     bool enabled, overflow, masked;
00044     uint8 counter;
00045 
00046     Timer();
00047 
00048     //Call update before making any further changes
00049     void update(double time);
00050 
00051     //On a reset make sure the start is in sync with the next cycle
00052     void reset(double time);
00053 
00054     void stop();
00055 
00056     void start(double time, int scale);
00057 };
00058 
00059 struct Chip {
00060     //Last selected register
00061     Timer timer[2];
00062     //Check for it being a write to the timer
00063     bool write(uint32 addr, uint8 val);
00064     //Read the current timer state, will use current double
00065     uint8 read();
00066 };
00067 
00068 namespace DBOPL {
00069 struct Chip;
00070 } // end of namespace DBOPL
00071 
00072 class OPL : public ::OPL::EmulatedOPL {
00073 private:
00074     Config::OplType _type;
00075     uint _rate;
00076 
00077     DBOPL::Chip *_emulator;
00078     Chip _chip[2];
00079     union {
00080         uint16 normal;
00081         uint8 dual[2];
00082     } _reg;
00083 
00084     void free();
00085     void dualWrite(uint8 index, uint8 reg, uint8 val);
00086 public:
00087     OPL(Config::OplType type);
00088     ~OPL();
00089 
00090     bool init();
00091     void reset();
00092 
00093     void write(int a, int v);
00094     byte read(int a);
00095 
00096     void writeReg(int r, int v);
00097 
00098     bool isStereo() const { return _type != Config::kOpl2; }
00099 
00100 protected:
00101     void generateSamples(int16 *buffer, int length);
00102 };
00103 
00104 } // End of namespace DOSBox
00105 } // End of namespace OPL
00106 
00107 #endif // !DISABLE_DOSBOX_OPL
00108 
00109 #endif


Generated on Sat Mar 23 2019 05:01:32 for ResidualVM by doxygen 1.7.1
curved edge   curved edge