[Scummvm-git-logs] scummvm master -> e6326bfcc11bcac765529ef38616b413eda43243

bluegr noreply at scummvm.org
Tue Mar 22 22:28:59 UTC 2022


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
393d409f8d CHEWY: Cleanup
e6326bfcc1 CHEWY: Hook up the new music player code (still WIP)


Commit: 393d409f8da023ba6f1f6516bc38014fad151e1a
    https://github.com/scummvm/scummvm/commit/393d409f8da023ba6f1f6516bc38014fad151e1a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-03-23T00:28:37+02:00

Commit Message:
CHEWY: Cleanup

Changed paths:
    engines/chewy/dialogs/cinema.cpp


diff --git a/engines/chewy/dialogs/cinema.cpp b/engines/chewy/dialogs/cinema.cpp
index aa795f1ffdc..fd8eff62d5d 100644
--- a/engines/chewy/dialogs/cinema.cpp
+++ b/engines/chewy/dialogs/cinema.cpp
@@ -37,12 +37,6 @@ static const Common::Rect cinematicsHotspots[] = {
 	{ -1,  -1,  -1,  -1 }
 };
 
-static const int16 CINEMA_TBL[4 * 3] = {
-	10,  80,  32, 105,
-	10, 150,  32, 175,
-	36,  64, 310, 188
-};
-
 static const uint8 CINEMA_FLICS[35] = {
 	FCUT_000, FCUT_002, FCUT_006, FCUT_009, FCUT_015,
 	FCUT_012, FCUT_011, FCUT_SPACECHASE_18, FCUT_003, FCUT_048,


Commit: e6326bfcc11bcac765529ef38616b413eda43243
    https://github.com/scummvm/scummvm/commit/e6326bfcc11bcac765529ef38616b413eda43243
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2022-03-23T00:28:37+02:00

Commit Message:
CHEWY: Hook up the new music player code (still WIP)

This is still not finished, but the original music playing code is
broken at the moment, so no music could be heard anyway

Changed paths:
  R engines/chewy/sound_player.cpp
  R engines/chewy/sound_player.h
    engines/chewy/data.cpp
    engines/chewy/data.h
    engines/chewy/defines.h
    engines/chewy/dialogs/main_menu.cpp
    engines/chewy/dialogs/options.cpp
    engines/chewy/globals.h
    engines/chewy/inits.cpp
    engines/chewy/m_event.cpp
    engines/chewy/main.cpp
    engines/chewy/module.mk
    engines/chewy/ngshext.h
    engines/chewy/ngstypes.cpp
    engines/chewy/ngstypes.h
    engines/chewy/r_event.cpp
    engines/chewy/rooms/room43.cpp
    engines/chewy/rooms/room46.cpp
    engines/chewy/rooms/room68.cpp
    engines/chewy/sound.cpp
    engines/chewy/video/cfo_decoder.cpp
    engines/chewy/video/video_player.cpp


diff --git a/engines/chewy/data.cpp b/engines/chewy/data.cpp
index 80a5aa756bd..60b598f1b01 100644
--- a/engines/chewy/data.cpp
+++ b/engines/chewy/data.cpp
@@ -55,38 +55,6 @@ uint16 Data::selectPoolItem(Common::Stream *stream, uint16 nr) {
 	return nr;
 }
 
-uint32 Data::load_tmf(Common::Stream *handle, TmfHeader *song) {
-	Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(handle);
-	uint32 size = 0;
-
-	if (rs) {
-		rs->seek(-ChunkHead::SIZE(), SEEK_CUR);
-		ChunkHead ch;
-		if (!ch.load(rs))
-			error("load_tmf error");
-
-		if (ch.type != TMFDATA)
-			error("load_tmf error");
-
-		assert(ch.size > (uint32)TmfHeader::SIZE());
-
-		if (!song->load(rs))
-			error("load_tmf error");
-
-		size = ch.size + sizeof(TmfHeader);
-		byte *memPtr = (byte *)song + sizeof(TmfHeader);
-		memPtr += ((uint32)song->_patternNr) * 1024l;
-		for (int16 i = 0; i < 31; ++i) {
-			if (song->instrument[i].laenge) {
-				song->ipos[i] = memPtr;
-				memPtr += song->instrument[i].laenge;
-			}
-		}
-	}
-
-	return size;
-}
-
 uint32 Data::getPoolSize(const char *filename, int16 chunkStart, int16 chunkNr) {
 	uint32 size = 0;
 
diff --git a/engines/chewy/data.h b/engines/chewy/data.h
index ec1fb8de7f5..ebc62326144 100644
--- a/engines/chewy/data.h
+++ b/engines/chewy/data.h
@@ -23,7 +23,6 @@
 #define CHEWY_DATA_H
 
 #include "chewy/chewy.h"
-#include "chewy/ngstypes.h"
 
 namespace Chewy {
 
@@ -33,8 +32,6 @@ public:
 	~Data();
 
 	uint16 selectPoolItem(Common::Stream *stream, uint16 nr);
-	uint32 load_tmf(Common::Stream *stream, TmfHeader *song);
-
 	uint32 getPoolSize(const char *filename, int16 chunkStart, int16 chunkNr);
 };
 
diff --git a/engines/chewy/defines.h b/engines/chewy/defines.h
index d59d0dd49fb..64202b9a61b 100644
--- a/engines/chewy/defines.h
+++ b/engines/chewy/defines.h
@@ -52,7 +52,6 @@ enum SetupScreenMode {
 
 #define MIN_FAR_MEM 3000000
 #define MIN_LOW_MEM 100000
-#define MUSIC_SLOT_SIZE 500000
 #define SPEECH_HALF_BUF 25000
 
 #define JXDIFF 180
diff --git a/engines/chewy/dialogs/main_menu.cpp b/engines/chewy/dialogs/main_menu.cpp
index 2d25aab22df..1b8f4da482d 100644
--- a/engines/chewy/dialogs/main_menu.cpp
+++ b/engines/chewy/dialogs/main_menu.cpp
@@ -40,14 +40,12 @@ int MainMenu::_personAni[3];
 void MainMenu::execute() {
 	// Convenience during testing to not keep showing title sequence
 	if (!ConfMan.getBool("skip_title")) {
-		_G(mem)->file->selectPoolItem(_G(music_handle), _G(EndOfPool) - 17);
-		_G(mem)->file->load_tmf(_G(music_handle), (TmfHeader *)_G(Ci).MusicSlot);
-		_G(sndPlayer)->playMod((TmfHeader *)_G(Ci).MusicSlot);
+		g_engine->_sound->playMusic(17);
 
 		// NOTE: Originally, this was set to play video 200, but this actually
 		// jumped to the very last video in the file, so we play it explicitly
 		flic_cut(g_engine->getLanguage() == Common::Language::DE_DEU ? FCUT_155 : FCUT_160);
-		_G(sndPlayer)->stopMod();
+		g_engine->_sound->stopMusic();
 	}
 
 	show_intro();
@@ -243,7 +241,6 @@ void MainMenu::playGame() {
 	_G(cur)->show_cur();
 	_G(spieler_vector)[P_CHEWY].Count = 0;
 	_G(uhr)->resetTimer(0, 0);
-	_G(sndPlayer)->setLoopMode(_G(gameState).soundLoopMode);
 
 	while (!SHOULD_QUIT && !mainLoop(1)) {
 	}
diff --git a/engines/chewy/dialogs/options.cpp b/engines/chewy/dialogs/options.cpp
index 6b92b4c8419..db6025476a6 100644
--- a/engines/chewy/dialogs/options.cpp
+++ b/engines/chewy/dialogs/options.cpp
@@ -184,7 +184,7 @@ void Options::execute(TafInfo *ti) {
 			case 5:
 				if (g_engine->_sound->musicEnabled()) {
 					g_engine->_sound->toggleMusic(false);
-					_G(sndPlayer)->stopMod();
+					g_engine->_sound->stopMusic();
 				} else {
 					g_engine->_sound->toggleMusic(true);
 					_G(currentSong) = -1;
diff --git a/engines/chewy/globals.h b/engines/chewy/globals.h
index a9c97d026fc..7cb8260160c 100644
--- a/engines/chewy/globals.h
+++ b/engines/chewy/globals.h
@@ -33,7 +33,6 @@
 #include "chewy/text.h"
 #include "chewy/object.h"
 #include "chewy/effect.h"
-#include "chewy/sound_player.h"
 
 namespace Chewy {
 
@@ -50,7 +49,6 @@ class InputMgr;
 class IOGame;
 class McgaGraphics;
 class Memory;
-class SoundPlayer;
 
 class Globals {
 	class CurrentScreen : public Graphics::Surface {
@@ -158,8 +156,6 @@ public:
 	int16 _talk_hide_static = -1;
 	int16 _currentSong = -1;
 	bool _savegameFlag = false;
-	Common::Stream *_music_handle = nullptr;
-	int16 _EndOfPool = 0;
 	int _timer_action_ctr = 0;
 
 	AutoMov _auto_mov[MAX_AUTO_MOV];
@@ -246,7 +242,6 @@ public:
 	IOGame *_iog = nullptr;
 	McgaGraphics *_out = nullptr;
 	Cursor *_cur = nullptr;
-	SoundPlayer *_sndPlayer = nullptr;
 	ChewyFont *_font6 = nullptr;
 	ChewyFont *_font8 = nullptr;
 	FontMgr *_fontMgr = nullptr;
diff --git a/engines/chewy/inits.cpp b/engines/chewy/inits.cpp
index 78e11718bba..77f740bed93 100644
--- a/engines/chewy/inits.cpp
+++ b/engines/chewy/inits.cpp
@@ -41,7 +41,6 @@ void standard_init() {
 	_G(uhr) = new Timer(MAX_TIMER_OBJ, _G(ani_timer));
 	_G(det) = new Detail();
 	_G(atds) = new Atdsys();
-	_G(sndPlayer) = new SoundPlayer();
 	_G(mov) = new MovClass();
 
 	_G(out)->init();
@@ -256,7 +255,6 @@ void tidy() {
 	delete _G(iog);
 	delete _G(cur);
 	delete _G(mov);
-	delete _G(sndPlayer);
 	delete _G(atds);
 	delete _G(det);
 	delete _G(uhr);
@@ -272,7 +270,6 @@ void tidy() {
 	_G(iog) = nullptr;
 	_G(cur) = nullptr;
 	_G(mov) = nullptr;
-	_G(sndPlayer) = nullptr;
 	_G(atds) = nullptr;
 	_G(det) = nullptr;
 	_G(uhr) = nullptr;
@@ -287,26 +284,10 @@ void tidy() {
 }
 
 void sound_init() {
-	_G(sndPlayer)->initMixMode();
 	_G(gameState).MusicVol = 63;
 	_G(gameState).SoundVol = 63;
 	g_engine->_sound->setMusicVolume(_G(gameState).MusicVol * Audio::Mixer::kMaxChannelVolume / 120);
 	g_engine->_sound->setSoundVolume(_G(gameState).SoundVol * Audio::Mixer::kMaxChannelVolume / 120);
-
-	_G(music_handle) = _G(room)->open_handle(DETAIL_TVP, R_VOC_DATA);
-
-	Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(_G(music_handle));
-	assert(rs);
-
-	rs->seek(0);
-	_G(EndOfPool) = 0;
-	NewPhead Nph;
-	if (!Nph.load(rs)) {
-		error("sound_init error");
-	} else {
-		_G(EndOfPool) = Nph._poolNr - 1;
-	}
-
 	_G(atds)->setHasSpeech(true);
 }
 
diff --git a/engines/chewy/m_event.cpp b/engines/chewy/m_event.cpp
index 20787827483..d4fc6c8fc43 100644
--- a/engines/chewy/m_event.cpp
+++ b/engines/chewy/m_event.cpp
@@ -30,14 +30,9 @@ namespace Chewy {
 #define PATTERN_PLAY 2
 
 void load_room_music(int16 room_nr) {
-	const int16 seq_start = 0;
-	const int16 seq_end = 0;
-	const int16 pattern = 0;
 	int16 ttp_index = -1;
 	int16 volume = _G(gameState).MusicVol;
-	const int16 lp_mode = 1;
-	const int16 play_mode = NORMAL_PLAY;
-	if (g_engine->_sound->musicEnabled() && (_G(music_handle))) {
+	if (g_engine->_sound->musicEnabled()) {
 		switch (room_nr) {
 		case 0:
 			ttp_index = 0;
@@ -178,7 +173,7 @@ void load_room_music(int16 room_nr) {
 		default:
 			ttp_index = -1;
 			_G(currentSong) = -1;
-			_G(sndPlayer)->stopMod();
+			g_engine->_sound->stopMusic();
 			break;
 		}
 		if (ttp_index != -1) {
@@ -187,24 +182,10 @@ void load_room_music(int16 room_nr) {
 			else if (volume > _G(gameState).MusicVol)
 				volume = _G(gameState).MusicVol;
 			g_engine->_sound->setMusicVolume(volume * Audio::Mixer::kMaxChannelVolume / 120);
-			_G(sndPlayer)->setLoopMode(lp_mode);
 			if (ttp_index != _G(currentSong)) {
-				_G(sndPlayer)->stopMod();
-				while (_G(sndPlayer)->musicPlaying()) {}
-				memset(_G(Ci).MusicSlot, 0, MUSIC_SLOT_SIZE);
-				_G(mem)->file->selectPoolItem(_G(music_handle), _G(EndOfPool) - ttp_index);
-				_G(mem)->file->load_tmf(_G(music_handle), (TmfHeader *)_G(Ci).MusicSlot);
+				g_engine->_sound->stopMusic();
 				_G(currentSong) = ttp_index;
-				if (play_mode == NORMAL_PLAY)
-					_G(sndPlayer)->playMod((TmfHeader *)_G(Ci).MusicSlot);
-				else {
-					_G(sndPlayer)->playMod((TmfHeader *)_G(Ci).MusicSlot);
-					_G(sndPlayer)->stopMod();
-					if (play_mode == SEQUENCE_PLAY)
-						_G(sndPlayer)->playSequence(seq_start, seq_end);
-					else if (play_mode == PATTERN_PLAY)
-						_G(sndPlayer)->playPattern(pattern);
-				}
+				g_engine->_sound->playMusic(ttp_index, true);
 			}
 		}
 	}
diff --git a/engines/chewy/main.cpp b/engines/chewy/main.cpp
index 768d27f5d3e..c3a6a85984b 100644
--- a/engines/chewy/main.cpp
+++ b/engines/chewy/main.cpp
@@ -72,8 +72,6 @@ void alloc_buffers() {
 	_G(pal) = (byte *)MALLOC(768l);
 	_G(Ci).TempArea = (byte *)MALLOC(64004l);
 	_G(det)->set_taf_ani_mem(_G(Ci).TempArea);
-	_G(Ci).MusicSlot = (byte *)MALLOC(MUSIC_SLOT_SIZE);
-	_G(Ci).MaxMusicSize = MUSIC_SLOT_SIZE;
 }
 
 void free_buffers() {
@@ -86,7 +84,6 @@ void free_buffers() {
 	free((char *)_G(chewy));
 
 	free((char *)_G(curtaf));
-	free(_G(Ci).MusicSlot);
 	free(_G(Ci).TempArea);
 	free(_G(pal));
 	free(_G(workpage));
diff --git a/engines/chewy/module.mk b/engines/chewy/module.mk
index 35c5a6a5cbe..cbc67a95ee0 100644
--- a/engines/chewy/module.mk
+++ b/engines/chewy/module.mk
@@ -29,7 +29,6 @@ MODULE_OBJS = \
 	room.o \
 	resource.o \
 	sound.o \
-	sound_player.o \
 	sprite.o \
 	t_event.o \
 	text.o \
diff --git a/engines/chewy/ngshext.h b/engines/chewy/ngshext.h
index 791f0ee65c9..a46a748b060 100644
--- a/engines/chewy/ngshext.h
+++ b/engines/chewy/ngshext.h
@@ -27,6 +27,5 @@
 #include "chewy/mouse.h"
 #include "chewy/io_game.h"
 #include "chewy/cursor.h"
-#include "chewy/sound_player.h"
 
 #endif
diff --git a/engines/chewy/ngstypes.cpp b/engines/chewy/ngstypes.cpp
index 8ae9ff6e10b..e29aa501343 100644
--- a/engines/chewy/ngstypes.cpp
+++ b/engines/chewy/ngstypes.cpp
@@ -32,29 +32,6 @@ bool NewPhead::load(Common::SeekableReadStream *src) {
 	return true;
 }
 
-bool TmfInst::load(Common::SeekableReadStream *src) {
-	finetune = src->readByte();
-	insvol = src->readByte();
-	repstart = src->readUint32LE();
-	replen = src->readUint32LE();
-	laenge = src->readUint32LE();
-
-	return true;
-}
-
-bool TmfHeader::load(Common::SeekableReadStream *src) {
-	src->read(id, 4);
-	for (int i = 0; i < 31; ++i)
-		instrument[i].load(src);
-
-	lied_len = src->readByte();
-	_patternNr = src->readByte();
-	src->read(_sequence, 128);
-	src->skip(4 * 31);
-
-	return true;
-}
-
 bool GedPoolHeader::load(Common::SeekableReadStream *src) {
 	src->read(_id, 4);
 	_nr = src->readUint16LE();
diff --git a/engines/chewy/ngstypes.h b/engines/chewy/ngstypes.h
index 3a91ade10f4..a569d036d26 100644
--- a/engines/chewy/ngstypes.h
+++ b/engines/chewy/ngstypes.h
@@ -51,28 +51,6 @@ struct MouseInfo {
 	int16 _button = 0;
 };
 
-struct TmfInst {
-	uint8 finetune;
-	uint8 insvol;
-	uint32 repstart;
-	uint32 replen;
-	uint32 laenge;
-
-	bool load(Common::SeekableReadStream *src);
-};
-
-struct TmfHeader {
-	char id[4] = { 0 };
-	TmfInst instrument[31];
-	uint8 lied_len = 0;
-	uint8 _patternNr = 0;
-	uint8 _sequence[128] = { 0 };
-	byte *ipos[31] = { nullptr };
-
-	bool load(Common::SeekableReadStream *src);
-	static int SIZE() { return 0x284; }
-};
-
 struct musik_info {
 	int16 musik_playing = 0;
 	int16 play_mode = 0;
@@ -118,8 +96,6 @@ struct ChunkHead {
 
 struct CustomInfo {
 	byte *TempArea = 0;
-	byte *MusicSlot = 0;
-	uint32 MaxMusicSize = 0;
 };
 
 } // namespace Chewy
diff --git a/engines/chewy/r_event.cpp b/engines/chewy/r_event.cpp
index e713dd5638e..4fa629ada12 100644
--- a/engines/chewy/r_event.cpp
+++ b/engines/chewy/r_event.cpp
@@ -845,17 +845,16 @@ void flic_cut(int16 nr) {
 
 	switch (nr) {
 	case FCUT_SPACECHASE_18:
-		_G(sndPlayer)->setLoopMode(1);
-
+		// _G(sndPlayer)->setLoopMode(1)
 		for (i = 0; i < 11 && keepPlaying; i++) {
 			keepPlaying = g_engine->_video->playVideo(FCUT_SPACECHASE_18 + i);
 		}
 
-		_G(sndPlayer)->fadeOut(0);
+		// TODO: Reimplement
+		//_G(sndPlayer)->fadeOut(0);
 		_G(out)->ausblenden(1);
 		_G(out)->cls();
-		while (_G(sndPlayer)->musicPlaying()) {}
-		_G(sndPlayer)->setLoopMode(_G(gameState).soundLoopMode);
+		//while (_G(sndPlayer)->musicPlaying()) {}
 		break;
 
 	case FCUT_058:
@@ -871,19 +870,18 @@ void flic_cut(int16 nr) {
 			g_engine->_video->playVideo(FCUT_062);
 		}
 
-		_G(sndPlayer)->fadeOut(0);
+		// TODO: Reimplement
+		//_G(sndPlayer)->fadeOut(0);
 		_G(out)->ausblenden(1);
 		_G(out)->cls();
-		while (_G(sndPlayer)->musicPlaying() && !SHOULD_QUIT) {}
+		//while (_G(sndPlayer)->musicPlaying() && !SHOULD_QUIT) {}
 		break;
 
 	case FCUT_065:
-		_G(sndPlayer)->stopMod();
+		g_engine->_sound->stopMusic();
 		_G(currentSong) = -1;
 		load_room_music(256);
-		_G(sndPlayer)->setLoopMode(1);
 		Room46::kloppe();
-		_G(sndPlayer)->setLoopMode(_G(gameState).soundLoopMode);
 		_G(currentSong) = -1;
 		break;
 
diff --git a/engines/chewy/rooms/room43.cpp b/engines/chewy/rooms/room43.cpp
index ca574bb1b28..01273d777dc 100644
--- a/engines/chewy/rooms/room43.cpp
+++ b/engines/chewy/rooms/room43.cpp
@@ -34,7 +34,7 @@ void Room43::night_small() {
 	_G(gameState).scrollx = 0;
 	_G(gameState).scrolly = 0;
 	switchRoom(43);
-	_G(sndPlayer)->stopMod();
+	g_engine->_sound->stopMusic();
 	g_engine->_sound->playSound(0);
 	hideCur();
 	_G(flags).NoScroll = true;
@@ -71,7 +71,7 @@ void Room43::catch_pg() {
 	_G(gameState).scrollx = 0;
 	_G(gameState).scrolly = 0;
 	switchRoom(43);
-	_G(sndPlayer)->stopMod();
+	g_engine->_sound->stopMusic();
 	g_engine->_sound->playSound(0);
 	hideCur();
 	_G(flags).NoScroll = true;
diff --git a/engines/chewy/rooms/room46.cpp b/engines/chewy/rooms/room46.cpp
index ffb65ddf45c..81da4e00dc3 100644
--- a/engines/chewy/rooms/room46.cpp
+++ b/engines/chewy/rooms/room46.cpp
@@ -151,6 +151,7 @@ void Room46::bodo() {
 }
 
 void Room46::kloppe() {
+	//_G(sndPlayer)->setLoopMode(1);
 	for (int16 i = 0; i < 4; i++) {
 		g_engine->_video->playVideo(FCUT_065);
 		
@@ -172,12 +173,13 @@ void Room46::kloppe() {
 	}
 
 	g_engine->_video->playVideo(FCUT_066);
-	_G(sndPlayer)->fadeOut(0);
+	// TODO: Reimplement
+	//_G(sndPlayer)->fadeOut(0);
 	_G(out)->cls();
 
-	while (_G(sndPlayer)->musicPlaying() && !SHOULD_QUIT) {
-		EVENTS_UPDATE;
-	}
+	//while (_G(sndPlayer)->musicPlaying() && !SHOULD_QUIT) {
+	//	EVENTS_UPDATE;
+	//}
 }
 
 int16 Room46::use_schloss() {
diff --git a/engines/chewy/rooms/room68.cpp b/engines/chewy/rooms/room68.cpp
index 528721da2e7..f7f54d761ea 100644
--- a/engines/chewy/rooms/room68.cpp
+++ b/engines/chewy/rooms/room68.cpp
@@ -347,8 +347,9 @@ void Room68::kostuem_aad(int16 aad_nr) {
 	else if (!_G(gameState).R67LiedOk)
 		startAadWait(389);
 	else {
-		if (!g_engine->_sound->subtitlesEnabled())
-			_G(sndPlayer)->fadeOut(5);
+		// TODO: Reimplement
+		//if (!g_engine->_sound->subtitlesEnabled())
+		//	_G(sndPlayer)->fadeOut(5);
 		
 		_G(SetUpScreenFunc) = nullptr;
 		delInventory(_G(gameState).AkInvent);
diff --git a/engines/chewy/sound.cpp b/engines/chewy/sound.cpp
index e8bf46b3ca2..c8f64e991c3 100644
--- a/engines/chewy/sound.cpp
+++ b/engines/chewy/sound.cpp
@@ -22,6 +22,7 @@
 #include "audio/audiostream.h"
 #include "audio/mixer.h"
 #include "audio/decoders/raw.h"
+#include "audio/mods/protracker.h"
 #include "common/config-manager.h"
 #include "common/system.h"
 #include "chewy/resource.h"
@@ -110,25 +111,33 @@ void Sound::playMusic(int num, bool loop) {
 	playMusic(data, chunk->size, loop);
 
 	delete[] data;
-	delete chunk;
 }
 
 void Sound::playMusic(uint8 *data, uint32 size, bool loop, DisposeAfterUse::Flag dispose) {
+#if 0
 	uint8 *modData = nullptr;
 	uint32 modSize;
 
+	/*
+	// TODO: Finish and use convertTMFToMod()
 	warning("The current music playing implementation is wrong");
 	modSize = size;
 	modData = (uint8 *)MALLOC(modSize);
 	memcpy(modData, data, size);
-
+	
 	Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
 	                                 Audio::makeRawStream(modData,
 	                                         modSize, 22050, Audio::FLAG_UNSIGNED,
 	                                         dispose),
 	                                 loop ? 0 : 1);
+	*/
+
+	convertTMFToMod(data, size, modData, modSize);
+	Audio::AudioStream *stream = Audio::makeProtrackerStream(
+		new Common::MemoryReadStream(data, size));
 
 	_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, stream);
+#endif
 }
 
 void Sound::pauseMusic() {
@@ -205,7 +214,6 @@ void Sound::stopAll() {
 }
 
 void Sound::convertTMFToMod(uint8 *tmfData, uint32 tmfSize, uint8 *modData, uint32 &modSize) {
-
 	const int maxInstruments = 31;
 
 	modSize = tmfSize + 20 + maxInstruments * 22 + 4;
@@ -272,7 +280,7 @@ void Sound::convertTMFToMod(uint8 *tmfData, uint32 tmfSize, uint8 *modData, uint
 	WRITE_BE_UINT32(modPtr, MKTAG('M', '.', 'K', '.'));
 	modPtr += 4;
 
-	free(modData);
+	// TODO: Finish this
 }
 
 void Sound::waitForSpeechToFinish() {
diff --git a/engines/chewy/sound_player.cpp b/engines/chewy/sound_player.cpp
deleted file mode 100644
index a402bb4edbe..00000000000
--- a/engines/chewy/sound_player.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include "audio/audiostream.h"
-#include "chewy/chewy.h"
-#include "chewy/globals.h"
-#include "chewy/ngsdefs.h"
-#include "chewy/sound_player.h"
-#include "chewy/sound.h"
-
-namespace Chewy {
-
-#define MAX_VOICES 8
-#define NORMAL_PLAYBACK 0
-#define PATTERN_PLAYBACK 1
-#define SEQUENCE_PLAYBACK 2
-#define FADE_OUT 1
-#define FADE_IN 2
-
-static int16 FreqTable[] = {
-	856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480, 453,
-	428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240, 226,
-	214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120, 113,
-	107, 101, 95, 90, 85, 80, 76, 71, 67, 64, 60, 57,
-
-	862, 814, 768, 725, 684, 646, 610, 575, 543, 513, 484, 457,
-	431, 407, 384, 363, 342, 323, 305, 288, 272, 256, 242, 228,
-	216, 203, 192, 181, 171, 161, 152, 144, 136, 128, 121, 114,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	868, 820, 774, 730, 689, 651, 614, 580, 547, 516, 487, 460,
-	434, 410, 387, 365, 345, 325, 307, 290, 274, 258, 244, 230,
-	217, 205, 193, 183, 172, 163, 154, 145, 137, 129, 122, 115,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	875, 826, 779, 736, 694, 655, 619, 584, 551, 520, 491, 463,
-	437, 413, 390, 368, 347, 328, 309, 292, 276, 260, 245, 232,
-	219, 206, 195, 184, 174, 164, 155, 146, 138, 130, 123, 116,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	881, 832, 785, 741, 699, 660, 623, 588, 555, 524, 494, 467,
-	441, 416, 392, 370, 350, 330, 312, 294, 278, 262, 247, 233,
-	220, 208, 196, 185, 175, 165, 156, 147, 139, 131, 123, 117,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	887, 838, 791, 746, 704, 665, 628, 592, 559, 528, 498, 470,
-	444, 419, 395, 373, 352, 332, 314, 296, 280, 264, 249, 235,
-	222, 209, 198, 187, 176, 166, 157, 148, 140, 132, 125, 118,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	894, 844, 796, 752, 709, 670, 632, 597, 563, 532, 502, 474,
-	447, 422, 398, 376, 355, 335, 316, 298, 282, 266, 251, 237,
-	223, 211, 199, 188, 177, 167, 158, 149, 141, 133, 125, 118,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	900, 850, 802, 757, 715, 675, 636, 601, 567, 535, 505, 477,
-	450, 425, 401, 379, 357, 337, 318, 300, 284, 268, 253, 238,
-	225, 212, 200, 189, 179, 169, 159, 150, 142, 134, 126, 119,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	907, 856, 808, 762, 720, 678, 640, 604, 570, 538, 508, 480,
-	453, 428, 404, 381, 360, 339, 320, 302, 285, 269, 254, 240,
-	226, 214, 202, 190, 180, 170, 160, 151, 143, 135, 127, 120,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	814, 768, 725, 684, 646, 610, 575, 543, 513, 484, 457, 431,
-	407, 384, 363, 342, 323, 305, 288, 272, 256, 242, 228, 216,
-	204, 192, 181, 171, 161, 152, 144, 136, 128, 121, 114, 108,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	820, 774, 730, 689, 651, 614, 580, 547, 516, 487, 460, 434,
-	410, 387, 365, 345, 325, 307, 290, 274, 258, 244, 230, 217,
-	205, 193, 183, 172, 163, 154, 145, 137, 129, 122, 115, 109,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	826, 779, 736, 694, 655, 619, 584, 551, 520, 491, 463, 437,
-	413, 390, 368, 347, 328, 309, 292, 276, 260, 245, 232, 219,
-	206, 195, 184, 174, 164, 155, 146, 138, 130, 123, 116, 109,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	832, 785, 741, 699, 660, 623, 588, 555, 524, 495, 467, 441,
-	416, 392, 370, 350, 330, 312, 294, 278, 262, 247, 233, 220,
-	208, 196, 185, 175, 165, 156, 147, 139, 131, 124, 117, 110,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	838, 791, 746, 704, 665, 628, 592, 559, 528, 498, 470, 444,
-	419, 395, 373, 352, 332, 314, 296, 280, 264, 249, 235, 222,
-	209, 198, 187, 176, 166, 157, 148, 140, 132, 125, 118, 111,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	844, 796, 752, 709, 670, 632, 597, 563, 532, 502, 474, 447,
-	422, 398, 376, 355, 335, 316, 298, 282, 266, 251, 237, 224,
-	211, 199, 188, 177, 167, 158, 149, 141, 133, 125, 118, 112,
-	94, 89, 83, 78, 73, 68, 64, 59, 55, 53, 48, 45,
-
-	850, 802, 757, 715, 674, 637, 601, 567, 535, 505, 477, 450,
-	425, 401, 379, 357, 337, 318, 300, 284, 268, 253, 239, 225,
-	213, 201, 189, 179, 169, 159, 150, 142, 134, 126, 119, 113,
-	100, 95, 89, 84, 79, 74, 70, 65, 61, 59, 54, 51,
-};
-static uint16 RealFreq[800] = {0};
-
-void *dig; // FIXME: DIG_DRIVER
-int smp[MAX_VOICES]; // FIXME: HSAMPLE
-int TimerHandle; // FIXME: HTIMER
-int16 TimerEnabled = false;
-int16 RealVoices;
-
-int16 LoopEnable = OFF;
-int16 PlaybackMode = NORMAL_PLAYBACK;
-int16 StartPos = 0;
-int16 EndPos = 0;
-int16 MusicFade = OFF;
-uint16 FadeStart = 0;
-uint16 FadeCounter = 0;
-uint16 FadeVol = 0;
-uint16 GlobalFrequency = 22050;
-
-int16 MusicStatus = OFF;
-int16 InInterrupt = 0;
-int16 PatternCount = 6;
-int16 CurrentTempo = 6;
-int16 FineSpeedV;
-int16 FineSpeedN;
-int16 FineSpeedS;
-TmfInst Instrument[4] = {{ 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0 }};
-uint16 InsFreq[4] = {0};
-char *Sample[4] = {0};
-
-TmfHeader *ActiveSong;
-int16 SeqPointer;
-int16 PatPointer;
-int16 PatLine;
-char *Patterns[128];
-char *CurrentLine;
-int16 StereoPos[8] = {63};
-
-SoundPlayer::SoundPlayer() {
-	MusicFade = false;
-}
-
-SoundPlayer::~SoundPlayer() {
-	warning("STUB: ailclass::~ailclass()");
-}
-
-void SoundPlayer::initMixMode() {
-	warning("STUB: ailclass::initMixMode()");
-
-	initNoteTable(GlobalFrequency);
-#if 0
-	TimerHandle = AIL_register_timer(mod_irq);
-	if (TimerHandle != -1) {
-		AIL_set_timer_frequency(TimerHandle, 50);
-		AIL_start_timer(TimerHandle);
-		TimerEnabled = true;
-	} else
-#endif
-
-	TimerEnabled = false;
-	StereoPos[0] = 7;
-	StereoPos[1] = 120;
-	StereoPos[2] = 30;
-	StereoPos[3] = 90;
-}
-
-void SoundPlayer::playMod(TmfHeader *th) {
-	ActiveSong = th;
-	char *tmp = (char *)ActiveSong;
-	tmp += sizeof(TmfHeader);
-	for (int16 i = 0; i < 128; i++) {
-		Patterns[i] = tmp;
-		tmp += 1024;
-	}
-	SeqPointer = 0;
-	PatLine = 0;
-	PatPointer = ActiveSong->_sequence[SeqPointer];
-	CurrentLine = Patterns[PatPointer];
-	CurrentTempo = 6;
-	PatternCount = 0;
-	FineSpeedV = 1;
-	FineSpeedN = 0;
-	FineSpeedS = 0;
-
-	MusicStatus = ON;
-}
-
-void SoundPlayer::stopMod() {
-	warning("STUB: ailclass::stopMod()");
-
-#if 0
-	int16 i;
-	if (SoundEnable) {
-		for (i = 0; i < 4; i++) {
-			AIL_end_sample(smp[i]);
-			Instrument[i].replen = 0;
-		}
-		MusicStatus = OFF;
-	}
-#endif
-}
-
-void SoundPlayer::continueMusic() {
-	if (!strncmp(ActiveSong->id, "TMF", 3))
-		MusicStatus = ON;
-}
-
-void SoundPlayer::playSequence(int16 startPos, int16 endPos) {
-	if (!strncmp(ActiveSong->id, "TMF", 3)) {
-		StartPos = startPos;
-		EndPos = endPos;
-		SeqPointer = StartPos;
-		PatLine = 0;
-		PatPointer = ActiveSong->_sequence[SeqPointer];
-		CurrentLine = Patterns[PatPointer];
-		MusicStatus = ON;
-	}
-}
-
-void SoundPlayer::playPattern(int16 pattern) {
-	if (!strncmp(ActiveSong->id, "TMF", 3)) {
-		StartPos = 0;
-		EndPos = 0;
-		SeqPointer = 0;
-		PatLine = 0;
-		PatPointer = pattern;
-		CurrentLine = Patterns[PatPointer];
-		MusicStatus = ON;
-	}
-}
-
-void SoundPlayer::setLoopMode(int16 mode) {
-	mode &= 1;
-	LoopEnable = mode;
-}
-
-void SoundPlayer::fadeOut(uint16 delay) {
-	FadeStart = delay;
-	FadeCounter = 0;
-	MusicFade = FADE_OUT;
-	FadeVol = _G(gameState).MusicVol;
-}
-
-void SoundPlayer::getMusicInfo(musik_info *mi) {
-	mi->musik_playing = MusicStatus;
-	mi->play_mode = 0;
-	mi->pattern_line = PatLine;
-	mi->sequence_pos = SeqPointer;
-	mi->cur_pattnr = PatPointer;
-}
-
-int16 SoundPlayer::musicPlaying() {
-	return 0;	// Temporary hack until the music code is finished
-	//return MusicStatus;
-}
-
-void SoundPlayer::initNoteTable(uint16 sfreq) {
-	float TimerFreq = 7093789.2f;
-	for (int j = 0; j < 16; j++) {
-		for (int i = 0; i < 48; i++)
-			RealFreq[(j * 48) + i] = (uint16)(TimerFreq / (float)(FreqTable[(j * 48) + i] << 1));
-
-	}
-}
-
-void mod_irq() {
-	if (!InInterrupt) {
-		++InInterrupt;
-		if (MusicStatus == ON) {
-			if (PatternCount <= 0) {
-				PatternCount = CurrentTempo;
-				DecodePatternLine();
-			}
-			if (MusicFade == FADE_IN) {
-				if (!FadeCounter) {
-					FadeCounter = FadeStart;
-					if ((_G(gameState).MusicVol / 2 + 2) <= FadeVol)
-						_G(gameState).MusicVol += 2;
-					else {
-						MusicFade = OFF;
-						_G(gameState).MusicVol = FadeVol;
-					}
-				} else
-					--FadeCounter;
-			} else if (MusicFade == FADE_OUT) {
-				if (!FadeCounter) {
-					FadeCounter = FadeStart;
-					if (_G(gameState).MusicVol - 2 > 0)
-						_G(gameState).MusicVol -= 2;
-					else {
-						MusicFade = OFF;
-						MusicStatus = OFF;
-						_G(gameState).MusicVol = FadeVol;
-					}
-				} else
-					--FadeCounter;
-			}
-		}
-		PatternCount -= FineSpeedV;
-		FineSpeedS += FineSpeedN;
-		while (FineSpeedS > 1000) {
-			FineSpeedS -= 1000;
-			--PatternCount;
-		}
-	}
-	--InInterrupt;
-}
-
-void DecodePatternLine() {
-	DecodeChannel(0);
-	DecodeChannel(1);
-	DecodeChannel(2);
-	DecodeChannel(3);
-	++PatLine;
-	if (PatLine > 63) {
-		PatLine = 0;
-		++SeqPointer;
-		switch (PlaybackMode) {
-		case NORMAL_PLAYBACK:
-			if (SeqPointer < ActiveSong->lied_len) {
-				PatPointer = ActiveSong->_sequence[SeqPointer];
-				CurrentLine = Patterns[PatPointer];
-			} else {
-				if (LoopEnable == OFF)
-					MusicStatus = OFF;
-				else {
-					PatLine = 0;
-					SeqPointer = 0;
-					PatPointer = ActiveSong->_sequence[SeqPointer];
-					CurrentLine = Patterns[PatPointer];
-				}
-			}
-			break;
-
-		case SEQUENCE_PLAYBACK:
-			if (SeqPointer != EndPos) {
-				PatPointer = ActiveSong->_sequence[SeqPointer];
-				CurrentLine = Patterns[PatPointer];
-			} else {
-				if (LoopEnable == OFF)
-					MusicStatus = OFF;
-				else {
-					PatLine = 0;
-					SeqPointer = StartPos;
-					PatPointer = ActiveSong->_sequence[SeqPointer];
-					CurrentLine = Patterns[PatPointer];
-				}
-			}
-			break;
-
-		case PATTERN_PLAYBACK:
-			if (LoopEnable == OFF)
-				MusicStatus = OFF;
-			else {
-				PatLine = 0;
-				SeqPointer = 0;
-				PatPointer = StartPos;
-				CurrentLine = Patterns[PatPointer];
-			}
-			break;
-		}
-	}
-}
-
-void DecodeChannel(int16 ch) {
-	warning("STUB: ailclass::decode_channel()");
-
-#if 0
-	byte note, effect, inst, effpar;
-	tmf_inst *ti;
-	int16 tmp1;
-	dword tmp2;
-	ch &= 3;
-	ti = &Instrument[ch];
-	note = *CurrentLine;
-	++CurrentLine;
-	inst = *CurrentLine;
-	++CurrentLine;
-	effect = *CurrentLine;
-	++CurrentLine;
-	effpar = *CurrentLine;
-	++CurrentLine;
-	if (note <= 48) {
-		switch (effect) {
-		case 0x9:
-			break;
-
-		case 0xa:
-			if (effpar & 0xf0) {
-				effpar >>= 4;
-				ti->insvol += effpar;
-				if ((byte)ti->insvol > (byte)MusicMasterVol)
-					ti->insvol = (byte)MusicMasterVol;
-			} else {
-				effpar &= 0x0f;
-				if (ti->insvol > effpar)
-					ti->insvol -= effpar;
-				else
-					ti->insvol = 0;
-			}
-			AIL_set_sample_volume(smp[ch], ti->insvol);
-			break;
-
-		case 0xb:
-			PatLine = 63;
-			SeqPointer = effpar;
-			break;
-
-		case 0xc:
-			ti->insvol = effpar;
-			if (ti->insvol > (byte)MusicMasterVol)
-				ti->insvol = (byte)MusicMasterVol;
-			AIL_set_sample_volume(smp[ch], ti->insvol);
-			break;
-
-		case 0xd:
-			PatLine = 63;
-			break;
-
-		case 0xe:
-			break;
-
-		case 0xf:
-			if (effpar >= 0x20) {
-				FineSpeedV = effpar / 125;
-				FineSpeedN = ((effpar % 125) * 1000) / 125;
-			} else {
-				CurrentTempo = (int16) effpar;
-				FineSpeedV = 1;
-				FineSpeedN = 0;
-				FineSpeedS = 0;
-			}
-			break;
-		}
-		if (note < 48) {
-			InsFreq[ch] = RealFreq[note];
-			if (inst > 0) {
-				--inst;
-				memcpy(ti, &ActiveSong->instrument[inst], sizeof(tmf_inst));
-				Sample[ch] = ActiveSong->ipos[inst];
-			}
-
-			if (ti->insvol > (byte)MusicMasterVol)
-				ti->insvol = (byte)MusicMasterVol;
-			AIL_end_sample(smp[ch]);
-			while (AIL_sample_status(smp[ch]) == SMP_PLAYING);
-			AIL_init_sample(smp[ch]);
-			AIL_set_sample_type(smp[ch], DIG_F_MONO_8, 0);
-			AIL_set_sample_address(smp[ch], Sample[ch], ti->laenge);
-			AIL_set_sample_playback_rate(smp[ch], InsFreq[ch]);
-			AIL_set_sample_volume(smp[ch], ti->insvol);
-			AIL_set_sample_pan(smp[ch], StereoPos[ch]);
-			AIL_start_sample(smp[ch]);
-		}
-	}
-#endif
-}
-
-} // namespace Chewy
diff --git a/engines/chewy/sound_player.h b/engines/chewy/sound_player.h
deleted file mode 100644
index f3b4dcef5f5..00000000000
--- a/engines/chewy/sound_player.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef CHEWY_SOUND_PLAYER_H
-#define CHEWY_SOUND_PLAYER_H
-
-#include "audio/mixer.h"
-#include "chewy/ngstypes.h"
-
-namespace Chewy {
-
-void mod_irq();
-void DecodePatternLine();
-void DecodeChannel(int16 ch);
-
-class SoundPlayer {
-public:
-	SoundPlayer();
-	~SoundPlayer();
-
-	void getMusicInfo(musik_info *mi);
-	int16 musicPlaying();
-
-	void initNoteTable(uint16 sfreq);
-	void initMixMode();
-	void playMod(TmfHeader *th);
-	void stopMod();
-	void continueMusic();
-	void playSequence(int16 startPos, int16 endPos);
-	void playPattern(int16 pattern);
-	void setLoopMode(int16 mode);
-	void fadeOut(uint16 delay);
-};
-
-} // namespace Chewy
-
-#endif
diff --git a/engines/chewy/video/cfo_decoder.cpp b/engines/chewy/video/cfo_decoder.cpp
index dde156da8f3..0522651142a 100644
--- a/engines/chewy/video/cfo_decoder.cpp
+++ b/engines/chewy/video/cfo_decoder.cpp
@@ -281,7 +281,8 @@ void CfoDecoder::CfoVideoTrack::handleCustomFrame() {
 		case kChunkMusicFadeOut:
 			// Used in videos 0, 71
 			channel = _fileStream->readUint16LE();
-			_G(sndPlayer)->fadeOut(channel);
+			// TODO: Reimplement
+			//_G(sndPlayer)->fadeOut(channel);
 			break;
 		case kChunkSetBalance:
 			channel = _fileStream->readUint16LE();
diff --git a/engines/chewy/video/video_player.cpp b/engines/chewy/video/video_player.cpp
index ae6da820d54..f057661c4b6 100644
--- a/engines/chewy/video/video_player.cpp
+++ b/engines/chewy/video/video_player.cpp
@@ -37,7 +37,7 @@ bool VideoPlayer::playVideo(uint num, bool stopMusic) {
 	_playCount = 0;
 
 	if (stopMusic) {
-		_G(sndPlayer)->stopMod();
+		g_engine->_sound->stopMusic();
 		_G(currentSong) = -1;
 	}
 




More information about the Scummvm-git-logs mailing list