aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/player_towns.h
blob: 3a36ea5daf9dba12a4d851cf81b8ddfb20b67e23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/* 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 SCUMM_PLAYER_TOWNS_H
#define SCUMM_PLAYER_TOWNS_H

#include "scumm/scumm.h"
#include "scumm/music.h"
#include "sound/softsynth/fmtowns_pc98/towns_euphony.h"

namespace Scumm {

class Player_Towns {
public:
	Player_Towns(ScummEngine *vm);
	virtual ~Player_Towns() {}

	virtual void saveLoadWithSerializer(Serializer *ser);
	virtual void restoreAfterLoad();

protected:
	void playPcmTrack(int sound, const uint8 *data, int velo = 0, int pan = 64, int note = 0);
	void stopPcmTrack(int sound);

	int getNextFreePcmChannel(int sound, int sfxChanRelIndex);

	struct PcmCurrentSound {
		uint16 index;
		uint16 chan;
		uint8 note;
		uint8 velo;
		uint8 pan;
		uint8 paused;
		uint8 looping;
		uint32 priority;
	} _pcmCurrentSound[9];

	struct SoundOvrParameters {
		uint8 vLeft;
		uint8 vRight;
		uint8 note;
	};

	uint8 _unkFlags;

	SoundOvrParameters *_soundOverride;
	SoundOvrParameters _ovrCur;

	TownsAudioInterface *_intf;
	ScummEngine *_vm;
};

class Player_Towns_v1 : public Player_Towns, public MusicEngine {
public:
	Player_Towns_v1(ScummEngine *vm, Audio::Mixer *mixer);
	virtual ~Player_Towns_v1();

	bool init();

	void setMusicVolume(int vol);
	void setSfxVolume(int vol);
	void startSound(int sound);
	void stopSound(int sound);
	void stopAllSounds();

	int getSoundStatus(int sound) const;
	int getCurrentCdaSound() { return _cdaCurrentSound; } 
	int getCurrentCdaVolume() { return (_cdaVolLeft + _cdaVolRight + 1) >> 1; } 

	int32 doCommand(int numargs, int args[]);

	void setVolumeCD(int left, int right);
	void setSoundVolume(int sound, int left, int right);
	void setSoundNote(int sound, int note);

	void saveLoadWithSerializer(Serializer *ser);
	void restoreAfterLoad();

	TownsEuphonyDriver *driver() { return _driver; }

private:
	void restartLoopingSounds();
	void startSoundEx(int sound, int velo, int pan, int note);
	void stopSoundSuspendLooping(int sound);

	void playEuphonyTrack(int sound, const uint8 *data);
	void playCdaTrack(int sound, const uint8 *data, bool skipTrackVelo = false);

	uint8 _cdaVolLeft;
	uint8 _cdaVolRight;
	
	uint8 _eupCurrentSound;
	uint8 _eupLooping;
	uint8 _eupVolLeft;
	uint8 _eupVolRight;

	uint8 _cdaCurrentSound;
	uint8 _cdaNumLoops;
	uint8 _cdaForceRestart;

	uint8 _cdaCurrentSoundTemp;
	uint8 _cdaNumLoopsTemp;

	TownsEuphonyDriver *_driver;
};

} // End of namespace Scumm

#endif