mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-30 14:14:43 +00:00
9c8b465505
- FM-Towns euphony driver completely rewritten based on KYRA FM-Towns and LOOM towns disasm. - Split all the emu and driver code from sound_towns.cpp into different files to make things a bit less confusing. - Move the driver code to common space since the exact same euphony driver is used by LOOM which means we could get rid of the outdated and incomplete ym2612 driver/emu implementation (which doesn't even do things like instrument loading, pan position, etc). I haven't tried to add this to the Scumm engine yet, since I am not familiar with it and my priority was to get the driver finished first. But from the look of disasm it shouldn't be difficult to do. - Introduce a generic FM-Towns audio interface based on FM-Towns system file disasm which was necessary for the euphony driver rewrite. Every FM-Towns game I have seen so far seems to access the audio hardware via these system functions. This interface implementation will also allow reasonably simple creation of new FM-Towns audio drivers (e.g. this could be used for Kings Quest 5 FM-Towns or others). - Move the PC98 driver to common space, too, since I have a strong feeling that this driver is also used in the PC98 version of Future Wars - This also improves KYRA FM-Towns music quality, sound effects accuracy and music fading. svn-id: r51645
179 lines
4.2 KiB
C++
179 lines
4.2 KiB
C++
/* ScummVM - Graphic Adventure Engine
|
|
*
|
|
* ScummVM is the legal property of its developers, whose names
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
* file distributed with this source distribution.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* $URL$
|
|
* $Id$
|
|
*
|
|
*/
|
|
|
|
#ifndef TOWNS_EUP_H
|
|
#define TOWNS_EUP_H
|
|
|
|
#include "sound/softsynth/fmtowns_pc98/towns_audio.h"
|
|
|
|
class TownsEuphonyDriver : public TownsAudioInterfacePluginDriver {
|
|
public:
|
|
TownsEuphonyDriver(Audio::Mixer *mixer);
|
|
virtual ~TownsEuphonyDriver();
|
|
|
|
bool init();
|
|
void reset();
|
|
|
|
void loadInstrument(int chanType, int id, const uint8 *data);
|
|
void loadWaveTable(const uint8 *data);
|
|
void unloadWaveTable(int id);
|
|
void reserveSfxChannels(int num);
|
|
|
|
int setMusicTempo(int tempo);
|
|
int startMusicTrack(const uint8 *data, int trackSize, int startTick);
|
|
void setMusicLoop(bool loop);
|
|
void stopParser();
|
|
|
|
void playSoundEffect(int chan, int note, int velo, const uint8 *data);
|
|
void stopSoundEffect(int chan);
|
|
bool soundEffectIsPlaying(int chan);
|
|
|
|
void chanStereo(int chan, int mode);
|
|
void chanPitch(int chan, int pitch);
|
|
void chanVolume(int chan, int vol);
|
|
|
|
void cdaSetVolume(int a, int vol1, int vol2);
|
|
|
|
int chanEnable(int tableEntry, int val);
|
|
int chanMode(int tableEntry, int val);
|
|
int chanOrdr(int tableEntry, int val);
|
|
int chanLevel(int tableEntry, int val);
|
|
int chanTranspose(int tableEntry, int val);
|
|
|
|
int assignChannel(int chan, int tableEntry);
|
|
|
|
void timerCallback(int timerId);
|
|
|
|
TownsAudioInterface *intf() { return _intf; }
|
|
|
|
private:
|
|
void resetTables();
|
|
|
|
void resetTempo();
|
|
void setTempoIntern(int tempo);
|
|
void setTimerA(bool enable, int tempo);
|
|
void setTimerB(bool enable, int tempo);
|
|
|
|
void updatePulseCount();
|
|
void updateTimeStampBase();
|
|
void updateParser();
|
|
void updateCheckEot();
|
|
|
|
bool parseNext();
|
|
void jumpNextLoop();
|
|
|
|
void updateEventBuffer();
|
|
void flushEventBuffer();
|
|
void processBufferNote(int mode, int evt, int note, int velo);
|
|
|
|
void resetControl();
|
|
void resetControlIntern(int mode, int chan);
|
|
uint8 appendEvent(uint8 evt, uint8 chan);
|
|
|
|
void sendEvent(uint8 mode, uint8 command);
|
|
|
|
typedef bool(TownsEuphonyDriver::*EuphonyOpcode)();
|
|
bool evtSetupNote();
|
|
bool evtPolyphonicAftertouch();
|
|
bool evtControlPitch();
|
|
bool evtInstrumentChanAftertouch();
|
|
bool evtLoadInstrument();
|
|
bool evtAdvanceTimestampOffset();
|
|
bool evtTempo();
|
|
bool evtModeOrdrChange();
|
|
bool evtNotImpl() { return false; }
|
|
|
|
uint8 prepTranspose(uint8 in);
|
|
uint8 prepVelo(uint8 in);
|
|
|
|
void sendNoteOff();
|
|
void sendNoteOn();
|
|
void sendChanVolume();
|
|
void sendPanPosition();
|
|
void sendAllNotesOff();
|
|
void sendSetInstrument();
|
|
void sendPitch();
|
|
|
|
int8 *_activeChannels;
|
|
int8 *_sustainChannels;
|
|
|
|
struct ActiveChannel {
|
|
int8 chan;
|
|
int8 next;
|
|
uint8 note;
|
|
uint8 sub;
|
|
} *_assignedChannels;
|
|
|
|
uint8 *_tEnable;
|
|
uint8 *_tMode;
|
|
uint8 *_tOrdr;
|
|
int8 *_tLevel;
|
|
int8 *_tTranspose;
|
|
|
|
struct DlEvent {
|
|
uint8 evt;
|
|
uint8 mode;
|
|
uint8 note;
|
|
uint8 velo;
|
|
uint16 len;
|
|
} *_eventBuffer;
|
|
int _bufferedEventsCount;
|
|
|
|
uint8 _para[2];
|
|
uint8 _paraCount;
|
|
uint8 _command;
|
|
|
|
uint8 _defaultBaseTickLen;
|
|
uint8 _baseTickLen;
|
|
uint32 _pulseCount;
|
|
int _tempoControlMode;
|
|
int _extraTimingControlRemainder;
|
|
int _extraTimingControl;
|
|
int _timerSetting;
|
|
int8 _tempoDiff;
|
|
int _tempoModifier;
|
|
uint32 _timeStampDest;
|
|
uint32 _timeStampBase;
|
|
int8 _elapsedEvents;
|
|
uint8 _deltaTicks;
|
|
uint32 _tickCounter;
|
|
uint8 _defaultTempo;
|
|
int _trackTempo;
|
|
|
|
bool _loop;
|
|
bool _playing;
|
|
bool _endOfTrack;
|
|
bool _suspendParsing;
|
|
|
|
const uint8 *_musicStart;
|
|
const uint8 *_musicPos;
|
|
uint32 _musicTrackSize;
|
|
|
|
TownsAudioInterface *_intf;
|
|
};
|
|
|
|
#endif
|
|
|