[Scummvm-cvs-logs] CVS: scummvm actor.cpp,1.16,1.17 gui.cpp,1.5,1.6 resource.cpp,1.22,1.23 saveload.cpp,1.18,1.19 script.cpp,1.12,1.13 scumm.h,1.31,1.32 scummvm.cpp,1.28,1.29 scummvm.dsp,1.14,1.15 sdl.cpp,1.23,1.24 sound.cpp,1.11,1.12 sound.h,1.1,1.2 sys.cpp,1.4,1.5 windows.cpp,1.20,1.21

Ludvig Strigeus strigeus at users.sourceforge.net
Sat Dec 1 09:07:06 CET 2001


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv8099

Modified Files:
	actor.cpp gui.cpp resource.cpp saveload.cpp script.cpp scumm.h 
	scummvm.cpp scummvm.dsp sdl.cpp sound.cpp sound.h sys.cpp 
	windows.cpp 
Log Message:
adlib sound support, use USE_ADLIB

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/actor.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** actor.cpp	2001/11/27 18:55:35	1.16
--- actor.cpp	2001/12/01 17:06:12	1.17
***************
*** 169,179 ****
  		switch(flags & 7) {
  		case 1:
! 			if (dir >= 180)
! 				return 270;
! 			return 90;
! 		case 2:
! 			if (dir <= 90 || dir>270)
! 				return 0;
! 			return 180;
  		case 3: return 270;
  		case 4: return 90;
--- 169,175 ----
  		switch(flags & 7) {
  		case 1:
! 			return a->walkdata.XYFactor >0 ? 90 : 270;
! 		case 2: 
! 			return a->walkdata.YXFactor >0 ? 180 : 0;
  		case 3: return 270;
  		case 4: return 90;

Index: gui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** gui.cpp	2001/11/26 19:57:57	1.5
--- gui.cpp	2001/12/01 17:06:13	1.6
***************
*** 1,2 ****
--- 1,22 ----
+ /* ScummVM - Scumm Interpreter
+  * Copyright (C) 2001 The ScummVM project
+  *
+  * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+  *
+  * $Header$
+  */
+ 
  #include "stdafx.h"
  #include "scumm.h"

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/resource.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** resource.cpp	2001/11/26 19:57:57	1.22
--- resource.cpp	2001/12/01 17:06:13	1.23
***************
*** 458,471 ****
  
  int Scumm::readSoundResource(int type, int index) {
! 	uint32 resStart, size, tag, size2, basetag;
! 	byte *ptr;
  	int i;
  
  	debug(9, "readSoundResource(%d,%d)", type, index);
  
! 	resStart = 0;
  
  	basetag = fileReadDwordLE();
! 	size = fileReadDwordBE();
  
  #if defined(SAMNMAX) || defined(FULL_THROTTLE)
--- 458,472 ----
  
  int Scumm::readSoundResource(int type, int index) {
! 	uint32 pos, total_size, size, tag,basetag;
  	int i;
+ 	int pri, best_pri;
+ 	uint32 best_size, best_offs;
  
  	debug(9, "readSoundResource(%d,%d)", type, index);
  
! 	pos = 0;
  
  	basetag = fileReadDwordLE();
! 	total_size = fileReadDwordBE();
  
  #if defined(SAMNMAX) || defined(FULL_THROTTLE)
***************
*** 476,496 ****
  	}
  #else
! 	while (size>resStart) {
  		tag = fileReadDword();
! 		size2 = fileReadDwordBE();
! 		
! 		resStart += size2 + 8;
  		
! 		for (i=0,ptr=_soundTagTable; i<_numSoundTags; i++,ptr+=4) {
! /* endian OK, tags are in native format */
! 			if (READ_UINT32_UNALIGNED(ptr) == tag) {
! 				fileSeek(_fileHandle, -8, SEEK_CUR);
! 				fileRead(_fileHandle,createResource(type, index, size2+8), size2+8);
! 				return 1;
! 			}
  		}
  
! 		fileSeek(_fileHandle, size2, SEEK_CUR);
  	}
  #endif
  	res.roomoffs[type][index] = 0xFFFFFFFF;
--- 477,510 ----
  	}
  #else
! 	while (pos < total_size) {
  		tag = fileReadDword();
! 		size = fileReadDwordBE() + 8;
! 		pos += size;
  		
! 		switch(tag) {
! #ifdef USE_ADLIB
! 		case MKID('ADL '): pri = 10; break;
! #else
! 		case MKID('ROL '): pri = 1; break;
! 		case MKID('GMD '): pri = 2; break;
! #endif
! 		default:	pri = -1;
  		}
  
! 		if (pri > best_pri) {
! 			best_pri = pri;
! 			best_size = size;
! 			best_offs = filePos(_fileHandle);
! 		}
! 
! 		fileSeek(_fileHandle, size - 8, SEEK_CUR);
  	}
+ 
+ 	if (best_pri != -1) {
+ 		fileSeek(_fileHandle, best_offs - 8, SEEK_SET);
+ 		fileRead(_fileHandle,createResource(type, index, best_size), best_size);
+ 		return 1;
+ 	}
+ 
  #endif
  	res.roomoffs[type][index] = 0xFFFFFFFF;

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saveload.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** saveload.cpp	2001/11/27 17:56:04	1.18
--- saveload.cpp	2001/12/01 17:06:13	1.19
***************
*** 500,505 ****
  	}
  
! 	if (_soundDriver)
! 		((SoundEngine*)_soundDriver)->save_or_load(s);
  
  }
--- 500,505 ----
  	}
  
! 	if (_soundEngine)
! 		((SoundEngine*)_soundEngine)->save_or_load(s);
  
  }

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/script.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** script.cpp	2001/11/26 19:57:57	1.12
--- script.cpp	2001/12/01 17:06:13	1.13
***************
*** 294,297 ****
--- 294,303 ----
  	debug(9, "readvar=%d", var);
  	if (!(var&0xF000)) {
+ #if defined(BYPASS_COPY_PROT)
+ 		if (var==490 && _gameId == GID_MONKEY2 && !copyprotbypassed) {
+ 			copyprotbypassed = true;
+ 			var = 518;
+ 		}
+ #endif
  		checkRange(_numVariables-1, 0, var, "Variable %d out of range(r)");
  		return _vars[var];
***************
*** 318,328 ****
  		var &= 0xFFF;
  		checkRange(0x10, 0, var, "Local variable %d out of range(r)");
- 
- #if defined(BYPASS_COPY_PROT)
- 		if (!copyprotbypassed && _currentScript==1 && _gameId==GID_MONKEY2 && var==0) {
- 			copyprotbypassed=1;
- 			return 1;
- 		}
- #endif
  		return vm.localvar[_currentScript][var];
  	}
--- 324,327 ----

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** scumm.h	2001/11/27 17:56:04	1.31
--- scumm.h	2001/12/01 17:06:13	1.32
***************
*** 23,26 ****
--- 23,27 ----
  
  #define SWAP(a,b) do{int tmp=a; a=b; b=tmp; } while(0)
+ #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  
  struct Scumm;
***************
*** 937,941 ****
  	int _keyPressed;
  
! 	void *_soundDriver;
  
  	uint16 *_inventory;
--- 938,942 ----
  	int _keyPressed;
  
! 	void *_soundEngine;
  
  	uint16 *_inventory;
***************
*** 1129,1134 ****
  	byte *_shadowPalette;
  	
! 	int _numSoundTags;
! 	byte *_soundTagTable;
  
  	int16 _bootParam;
--- 1130,1135 ----
  	byte *_shadowPalette;
  	
! //	int _numSoundTags;
! //	byte *_soundTagTable;
  
  	int16 _bootParam;
***************
*** 1221,1224 ****
--- 1222,1226 ----
  	void fileRead(void *handle, void *ptr, uint32 size);
  	bool fileEof(void *handle);
+ 	uint32 filePos(void *handle);
  
  	int fileReadByte();

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** scummvm.cpp	2001/11/26 19:57:57	1.28
--- scummvm.cpp	2001/12/01 17:06:13	1.29
***************
*** 197,203 ****
  	}
  
! 	if (_gameId==GID_MONKEY2 && _bootParam==0) {
! 		_bootParam = 10001;
! 	}
  
  	initGraphics(this, _fullScreen);
--- 197,203 ----
  	}
  
! //	if (_gameId==GID_MONKEY2 && _bootParam==0) {
! //		_bootParam = 10001;
! //	}
  
  	initGraphics(this, _fullScreen);

Index: scummvm.dsp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scummvm.dsp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** scummvm.dsp	2001/11/26 19:57:57	1.14
--- scummvm.dsp	2001/12/01 17:06:13	1.15
***************
*** 67,71 ****
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
! # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ALLOW_GDI" /Yu"stdafx.h" /FD /GZ /c
  # SUBTRACT CPP /Fr
  # ADD BASE RSC /l 0x41d /d "_DEBUG"
--- 67,71 ----
  # PROP Target_Dir ""
  # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
! # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "./sound" /I "./" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "ALLOW_GDI" /D "BYPASS_COPY_PROT" /D "USE_ADLIB" /Yu"stdafx.h" /FD /GZ /c
  # SUBTRACT CPP /Fr
  # ADD BASE RSC /l 0x41d /d "_DEBUG"
***************
*** 87,90 ****
--- 87,110 ----
  
  # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ # Begin Group "sound"
+ 
+ # PROP Default_Filter ""
+ # Begin Source File
+ 
+ SOURCE=.\sound\adlib.cpp
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\sound\fmopl.cpp
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\sound\gmidi.cpp
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\imuse.cpp
+ # End Source File
+ # End Group
  # Begin Source File
  
***************
*** 153,160 ****
  # Begin Source File
  
- SOURCE=.\imuse.cpp
- # End Source File
- # Begin Source File
- 
  SOURCE=.\object.cpp
  
--- 173,176 ----
***************
*** 248,251 ****
--- 264,271 ----
  # Begin Source File
  
+ SOURCE=.\sdl.cpp
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\sound.cpp
  
***************
*** 313,324 ****
  
  # End Source File
- # Begin Source File
- 
- SOURCE=.\windows.cpp
- # End Source File
  # End Group
  # Begin Group "Header Files"
  
  # PROP Default_Filter "h;hpp;hxx;hm;inl"
  # Begin Source File
  
--- 333,344 ----
  
  # End Source File
  # End Group
  # Begin Group "Header Files"
  
  # PROP Default_Filter "h;hpp;hxx;hm;inl"
+ # Begin Source File
+ 
+ SOURCE=.\sound\fmopl.h
+ # End Source File
  # Begin Source File
  

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sdl.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** sdl.cpp	2001/11/27 17:56:04	1.23
--- sdl.cpp	2001/12/01 17:06:13	1.24
***************
*** 36,39 ****
--- 36,40 ----
  
  SoundEngine sound;
+ SOUND_DRIVER_TYPE snd_driv;
  
  static SDL_Surface *screen;
***************
*** 480,484 ****
  
  void fill_sound(void *userdata, Uint8 *stream, int len) {
- 	memset(stream, 0, len);
  	scumm.mixWaves((int16*)stream, len>>1);
  }
--- 481,484 ----
***************
*** 502,505 ****
--- 502,506 ----
  }
  
+ 
  void initGraphics(Scumm *s, bool fullScreen) {
  	SDL_AudioSpec desired;
***************
*** 529,534 ****
  	SDL_ShowCursor(SDL_DISABLE);
  
! 	/* Create Music Thread */
! 	SDL_CreateThread((int (*)(void *))&music_thread, &scumm);
  
  #if !defined(SCALEUP_2x2)
--- 530,537 ----
  	SDL_ShowCursor(SDL_DISABLE);
  
! 	if (!snd_driv.wave_based()) {
! 		/* Create Music Thread */
! 		SDL_CreateThread((int (*)(void *))&music_thread, &scumm);
! 	}
  
  #if !defined(SCALEUP_2x2)
***************
*** 558,563 ****
  	int last_time, new_time;
  
! 	sound.initialize(&scumm);
! 	scumm._soundDriver = &sound;
  
  	scumm._gui = &gui;
--- 561,565 ----
  	int last_time, new_time;
  
! 	sound.initialize(&scumm, &snd_driv);
  
  	scumm._gui = &gui;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** sound.cpp	2001/11/29 22:29:38	1.11
--- sound.cpp	2001/12/01 17:06:13	1.12
***************
*** 66,70 ****
  			i += num;
  
! 			se = (SoundEngine*)_soundDriver;
  #if 0
  			debug(1,"processSoundQues(%d,%d,%d,%d,%d,%d,%d,%d,%d)", 
--- 66,70 ----
  			i += num;
  
! 			se = (SoundEngine*)_soundEngine;
  #if 0
  			debug(1,"processSoundQues(%d,%d,%d,%d,%d,%d,%d,%d,%d)", 
***************
*** 90,94 ****
  
  void Scumm::playSound(int sound) {
! 	SoundEngine *se = (SoundEngine*)_soundDriver;
  	if (se) {
  		getResourceAddress(rtSound, sound);
--- 90,94 ----
  
  void Scumm::playSound(int sound) {
! 	SoundEngine *se = (SoundEngine*)_soundEngine;
  	if (se) {
  		getResourceAddress(rtSound, sound);
***************
*** 203,207 ****
  		return 0;
  	
! 	se = (SoundEngine*)_soundDriver;
  	if (!se)
  		return 0;
--- 203,207 ----
  		return 0;
  	
! 	se = (SoundEngine*)_soundEngine;
  	if (!se)
  		return 0;
***************
*** 233,237 ****
  	int i;
  
! 	se = (SoundEngine*)_soundDriver;
  	if (se)
  		se->stop_sound(a);
--- 233,237 ----
  	int i;
  
! 	se = (SoundEngine*)_soundEngine;
  	if (se)
  		se->stop_sound(a);
***************
*** 243,247 ****
  
  void Scumm::stopAllSounds() {
! 	SoundEngine *se = (SoundEngine*)_soundDriver;
  	if (se) {
  		se->stop_all_sounds();
--- 243,247 ----
  
  void Scumm::stopAllSounds() {
! 	SoundEngine *se = (SoundEngine*)_soundEngine;
  	if (se) {
  		se->stop_all_sounds();
***************
*** 289,308 ****
   */
     
- static const uint32 sound_tags[] = {
- 	MKID('GMD ')
- };
- 
  void Scumm::setupSound() {
! 	SoundEngine *se = (SoundEngine*)_soundDriver;
  	if (se)
! 		se->_base_sounds = res.address[rtSound];
  
- 	_soundTagTable = (byte*)sound_tags;
- 	_numSoundTags = 1;
  	_sfxFile = openSfxFile();
  }
  
  void Scumm::pauseSounds(bool pause) {
! 	SoundEngine *se = (SoundEngine*)_soundDriver;
  	if (se)
  		se->pause(pause);
--- 289,302 ----
   */
     
  void Scumm::setupSound() {
! 	SoundEngine *se = (SoundEngine*)_soundEngine;
  	if (se)
! 		se->setBase(res.address[rtSound]);
  
  	_sfxFile = openSfxFile();
  }
  
  void Scumm::pauseSounds(bool pause) {
! 	SoundEngine *se = (SoundEngine*)_soundEngine;
  	if (se)
  		se->pause(pause);
***************
*** 467,473 ****
  	int i;
  
  	if (_soundsPaused)
  		return;
! 
  	for(i=NUM_MIXER-1; i>=0;i--) {
  		_mixer_channel[i].mix(sounds, len);
--- 461,474 ----
  	int i;
  
+ 	memset(sounds, 0,len * sizeof(int16));
+ 
  	if (_soundsPaused)
  		return;
! 	
! 	SoundEngine *se = (SoundEngine*)_soundEngine;
! 	if (se) {
! 		se->driver()->generate_samples(sounds, len);
! 	}
! 	
  	for(i=NUM_MIXER-1; i>=0;i--) {
  		_mixer_channel[i].mix(sounds, len);

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** sound.h	2001/11/14 18:37:38	1.1
--- sound.h	2001/12/01 17:06:13	1.2
***************
*** 18,21 ****
--- 18,24 ----
   * Change Log:
   * $Log$
+  * Revision 1.2  2001/12/01 17:06:13  strigeus
+  * adlib sound support, use USE_ADLIB
+  *
   * Revision 1.1  2001/11/14 18:37:38  strigeus
   * music support,
***************
*** 24,36 ****
   */
  
  struct Part;
  struct MidiChannel;
  struct VolumeFader;
  struct Player;
  struct HookDatas;
  struct SoundEngine;
  
  struct Part {
! 	SoundEngine *_se;
  	Part *_next, *_prev;
  	MidiChannel *_mc;
--- 27,104 ----
   */
  
+ int clamp(int val, int min, int max);
+ 
+ struct FM_OPL;
  struct Part;
  struct MidiChannel;
+ struct MidiChannelAdl;
+ struct MidiChannelGM;
  struct VolumeFader;
  struct Player;
  struct HookDatas;
  struct SoundEngine;
+ struct SoundDriver;
+ struct Instrument;
+ struct AdlibSoundDriver;
+ struct MidiSoundDriver;
+ 
+ #if defined(USE_ADLIB)
+ #define SOUND_DRIVER_TYPE AdlibSoundDriver 
+ #else
+ #define SOUND_DRIVER_TYPE MidiSoundDriver
+ #endif
+ 
+ struct Struct10 {
+ 	byte active;
+ 	int16 cur_val;
+ 	int16 count;
+ 	uint16 param;
+ 	int16 start_value;
+ 	byte loop;
+ 	byte table_a[4];
+ 	byte table_b[4];
+ 	int8 unk3;
+ 	int8 modwheel;
+ 	int8 modwheel_last;
+ 	uint16 speed_lo_max;
+ 	uint16 num_steps;
+ 	int16 speed_hi;
+ 	int8 direction;
+ 	uint16 speed_lo;
+ 	uint16 speed_lo_counter;
+ };
+ 
+ struct Struct11 {
+ 	int16 modify_val;
+ 	byte param,flag0x40,flag0x10;
+ 	Struct10 *s10;
+ };
  
+ struct InstrumentExtra {
+ 	byte a,b,c,d,e,f,g,h;
+ };
+ 
+ struct Instrument {
+ 	byte flags_1;
+ 	byte oplvl_1;
+ 	byte atdec_1;
+ 	byte sustrel_1;
+ 	byte waveform_1;
+ 	byte flags_2;
+ 	byte oplvl_2;
+ 	byte atdec_2;
+ 	byte sustrel_2;
+ 	byte waveform_2;
+ 	byte feedback;
+ 	byte flags_a;
+ 	InstrumentExtra extra_a;
+ 	byte flags_b;
+ 	InstrumentExtra extra_b;
+ 	byte duration;
+ };
+ 
  struct Part {
! 	int _slot;
! 	SOUND_DRIVER_TYPE *_drv;
  	Part *_next, *_prev;
  	MidiChannel *_mc;
***************
*** 51,61 ****
  	byte _effect_level;
  	byte _chorus;
! 	byte _gmidi_5;
! 	byte _gmidi_1;
  
  	void key_on(byte note, byte velocity);
  	void key_off(byte note);
! 	void set_param(int b, byte c) {}
! 	void init(SoundEngine *se);
  	void setup(Player *player);
  	void uninit();
--- 119,129 ----
  	byte _effect_level;
  	byte _chorus;
! 	byte _percussion;
! 	byte _bank;
  
  	void key_on(byte note, byte velocity);
  	void key_off(byte note);
! 	void set_param(byte param, int value);
! 	void init(SoundDriver *_driver);
  	void setup(Player *player);
  	void uninit();
***************
*** 63,72 ****
  	void silence();
  	void set_instrument(uint b);
! 	void set_instrument(byte *data) {}
  
  	void set_transpose(int8 transpose);
  	void set_vol(uint8 volume);
  	void set_detune(int8 detune);
! 	void set_pri(int8 pri, bool recalc);
  	void set_pan(int8 pan);
  	void set_modwheel(uint value);
--- 131,140 ----
  	void silence();
  	void set_instrument(uint b);
! 	void set_instrument(Instrument *data);
  
  	void set_transpose(int8 transpose);
  	void set_vol(uint8 volume);
  	void set_detune(int8 detune);
! 	void set_pri(int8 pri);
  	void set_pan(int8 pan);
  	void set_modwheel(uint value);
***************
*** 77,102 ****
  	void set_chorus(uint chorus);
  	void set_effect_level(uint level);
! 	void set_chan_param(int b, int c) {}
! 	void mod_changed();
! 	void vol_changed();
! 	void pedal_changed();
! 	void modwheel_changed();
! 	void pan_changed();
! 	void effect_level_changed();
! 	void program_changed();
! 	void chorus_changed();
  	int update_actives(uint16 *active);
  	void set_pitchbend_factor(uint8 value);
  	void set_onoff(bool on);
- 
  	void fix_after_load();
  };
  
  struct MidiChannel {
  	Part *_part;
  	byte _chan;
  	uint16 _actives[8];
- 
- 	void init(byte chan);
  };
  
--- 145,184 ----
  	void set_chorus(uint chorus);
  	void set_effect_level(uint level);
! 	
  	int update_actives(uint16 *active);
  	void set_pitchbend_factor(uint8 value);
  	void set_onoff(bool on);
  	void fix_after_load();
+ 
+ 	void update_pris();
+ 
+ 	void changed(byte what);
  };
  
+ 
  struct MidiChannel {
  	Part *_part;
+ 	MidiChannelAdl *adl() { return (MidiChannelAdl*)this; }
+ 	MidiChannelGM *gm() { return (MidiChannelGM*)this; }
+ };
+ 
+ struct MidiChannelAdl : MidiChannel {
+ 	MidiChannelAdl *_next,*_prev;
+ 	byte _waitforpedal;
+ 	byte _note;
+ 	byte _channel;
+ 	byte _twochan;
+ 	byte _vol_1,_vol_2;
+ 	int16 _duration;
+ 
+ 	Struct10 _s10a;
+ 	Struct11 _s11a;
+ 	Struct10 _s10b;
+ 	Struct11 _s11b;
+ };
+ 
+ struct MidiChannelGM : MidiChannel {
  	byte _chan;
  	uint16 _actives[8];
  };
  
***************
*** 189,193 ****
  	void set_pan(int pan);
  	void set_detune(int detune);
! 	void silence_parts();
  	void play_active_notes();
  	void cancel_volume_fade();
--- 271,275 ----
  	void set_pan(int pan);
  	void set_detune(int detune);
! 	void turn_off_parts();
  	void play_active_notes();
  	void cancel_volume_fade();
***************
*** 236,241 ****
  };
  
  struct SoundEngine {
! 	void *_mo; /* midi out */
  
  	byte **_base_sounds;
--- 318,448 ----
  };
  
+ struct SoundDriver {
+ 	enum {
+ 		pcMod = 1,
+ 		pcVolume = 2,
+ 		pcPedal = 4,
+ 		pcModwheel = 8,
+ 		pcPan = 16,
+ 		pcEffectLevel = 32,
+ 		pcProgram = 64,
+ 		pcChorus = 128,
+ 		pcAll = 255,
+ 	};
+ };
+ 
+ struct AdlibSoundDriver : SoundDriver {
+ private:
+ 	FM_OPL *_opl;
+ 	byte *_adlib_reg_cache;
+ 	SoundEngine *_se;
+ 
+ 	int _adlib_timer_counter;
+ 
+ 	uint16 channel_table_2[9];
+ 	int _midichan_index;
+ 	int _next_tick;
+ 	uint16 curnote_table[9];
+ 	MidiChannelAdl _midi_channels[9];
+ 
+ 	Instrument _part_instr[32];
+ 	Instrument _glob_instr[32];
+ 
+ 	void adlib_key_off(int chan);
+ 	void adlib_note_on(int chan, byte note, int mod);
+ 	void adlib_note_on_ex(int chan, byte note, int mod);
+ 	int adlib_read_param(int chan, byte data);
+ 	void adlib_setup_channel(int chan, Instrument *instr, byte vol_1, byte vol_2);
+ 	byte adlib_read(byte port) { return _adlib_reg_cache[port]; }	
+ 	void adlib_set_param(int channel, byte param, int value);
+ 	void adlib_key_onoff(int channel);
+ 	void adlib_write(byte port, byte value);
+ 	void adlib_playnote(int channel, int note);
+ 
+ 	MidiChannelAdl *allocate_midichan(byte pri);
+ 
+ 	void reset_tick();
+ 	void mc_off(MidiChannel *mc);	
+ 
+ 	static void link_mc(Part *part, MidiChannelAdl *mc);
+ 	static void mc_inc_stuff(MidiChannelAdl *mc, Struct10 *s10, Struct11 *s11);
+ 	static void mc_init_stuff(MidiChannelAdl *mc, Struct10 *s10, Struct11 *s11, byte flags, InstrumentExtra *ie);
+ 	static void struct10_init(Struct10 *s10, InstrumentExtra *ie);
+ 	static byte struct10_ontimer(Struct10 *s10, Struct11 *s11);
+ 	static void struct10_setup(Struct10 *s10);
+ 	static int random_nr(int a);
+ 	void mc_key_on(MidiChannel *mc, byte note, byte velocity);
+ 
+ public:
+ 	void uninit();
+ 	void init(SoundEngine *eng);
+ 	void update_pris() { }
+ 	void generate_samples(int16 *buf, int len);
+ 	void on_timer();
+ 	void set_instrument(uint slot, byte *instr);
+ 	void part_set_instrument(Part *part, Instrument *instr);
+ 	void part_key_on(Part *part, byte note, byte velocity);
+ 	void part_key_off(Part *part, byte note);
+ 	void part_set_param(Part *part, byte param, int value);
+ 	void part_changed(Part *part,byte what);
+ 	void part_off(Part *part);
+ 	int part_update_active(Part *part,uint16 *active);
+ 	void adjust_priorities() {}
+ 
+ 	bool wave_based() { return true; }
+ };
+ 
+ struct MidiSoundDriver : SoundDriver {
+ 	HMIDIOUT *_mo;
+ 	bool _mt32emulate;
+ 	SoundEngine *_se;
+ 
+ 	MidiChannelGM _midi_channels[9];
+ 
+ 	int16 _midi_pitchbend_last[16];
+ 	uint8 _midi_volume_last[16];
+ 	bool _midi_pedal_last[16];
+ 	byte _midi_modwheel_last[16];
+ 	byte _midi_effectlevel_last[16];
+ 	byte _midi_chorus_last[16];
+ 	int8 _midi_pan_last[16];
+ 
+ 	void midiPitchBend(byte chan, int16 pitchbend);
+ 	void midiVolume(byte chan, byte volume);
+ 	void midiPedal(byte chan, bool pedal);
+ 	void midiModWheel(byte chan, byte modwheel);
+ 	void midiEffectLevel(byte chan, byte level);
+ 	void midiChorus(byte chan, byte chorus);
+ 	void midiControl0(byte chan, byte value);
+ 	void midiProgram(byte chan, byte program);
+ 	void midiPan(byte chan, int8 pan);
+ 	void midiNoteOn(byte chan, byte note, byte velocity);
+ 	void midiNoteOff(byte chan, byte note);
+ 	void midiSilence(byte chan);
+ 	void midiInit();
+ 
+ public:
+ 	void uninit();
+ 	void init(SoundEngine *eng);
+ 	void update_pris();
+ 	void part_off(Part *part);
+ 	int part_update_active(Part *part,uint16 *active);
+ 
+ 	void generate_samples(int16 *buf, int len) {}
+ 	void on_timer() {}
+ 	void set_instrument(uint slot, byte *instr) {}
+ 	void part_set_instrument(Part *part, Instrument *instr) {}
+ 	void part_set_param(Part *part, byte param, int value) {}
+ 	void part_key_on(Part *part, byte note, byte velocity);
+ 	void part_key_off(Part *part, byte note);
+ 	void part_changed(Part *part,byte what);
+ 
+ 	bool wave_based() { return false; }
+ };
+ 
  struct SoundEngine {
! friend struct Player;
! private:
! 	SOUND_DRIVER_TYPE *_driver;
  
  	byte **_base_sounds;
***************
*** 257,262 ****
  	SustainingNotes *_sustain_notes_head;
  
- 	uint16 _timer_counter_1;
- 
  	byte _queue_marker;
  	byte _queue_cleared;
--- 464,467 ----
***************
*** 273,298 ****
  	VolumeFader _volume_fader[8];
  	Part _parts[32];
! 	MidiChannel _midi_channels[9];
  	uint16 _active_notes[128];
  	CommandQueue _cmd_queue[64];
  
- 	int16 _midi_pitchbend_last[16];
- 	uint8 _midi_volume_last[16];
- 	bool _midi_pedal_last[16];
- 	byte _midi_modwheel_last[16];
- 	byte _midi_effectlevel_last[16];
- 	byte _midi_chorus_last[16];
- 	int8 _midi_pan_last[16];
- 
  	byte *findTag(int sound, char *tag, int index);
- 	int initialize(Scumm *scumm);
- 	int terminate();
- 	int save_or_load(Serializer *ser);
- 	int set_master_volume(uint vol);
- 	int get_master_volume();
- 	bool start_sound(int sound);
- 	int stop_sound(int sound);
- 	int stop_all_sounds();
- 	int get_sound_status(int sound);
  	int get_queue_sound_status(int sound);
  	Player *allocate_player(byte priority);
--- 478,486 ----
  	VolumeFader _volume_fader[8];
  	Part _parts[32];
! 	
  	uint16 _active_notes[128];
  	CommandQueue _cmd_queue[64];
  
  	byte *findTag(int sound, char *tag, int index);
  	int get_queue_sound_status(int sound);
  	Player *allocate_player(byte priority);
***************
*** 305,319 ****
  	void init_queue();
  
- 	void on_timer();
  	void sequencer_timers();
  	void expire_sustain_notes();
  	void expire_volume_faders();
  
- 	void set_instrument(uint slot, byte *data) {}
- 	
- 	int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h);
  	Part *allocate_part(byte pri);
  
- 	int clear_queue();
  	int enqueue_command(int a, int b, int c, int d, int e, int f, int g);
  	int enqueue_trigger(int sound, int marker);
--- 493,502 ----
***************
*** 330,349 ****
  	int set_volchan(int sound, int volchan);
  
- 	void midiPitchBend(byte chan, int16 pitchbend);
- 	void midiVolume(byte chan, byte volume);
- 	void midiPedal(byte chan, bool pedal);
- 	void midiModWheel(byte chan, byte modwheel);
- 	void midiEffectLevel(byte chan, byte level);
- 	void midiChorus(byte chan, byte chorus);
- 	void midiControl0(byte chan, byte value);
- 	void midiProgram(byte chan, byte program);
- 	void midiPan(byte chan, int8 pan);
- 	void midiNoteOn(byte chan, byte note, byte velocity);
- 	void midiNoteOff(byte chan, byte note);
- 	void midiSilence(byte chan);
- 	void midiInit();
- 
- 	void adjust_priorities();
- 
  	void fix_parts_after_load();
  	void fix_players_after_load();
--- 513,516 ----
***************
*** 355,358 ****
--- 522,544 ----
  	void unlock();
  
+ public:
+ 	void on_timer();
+ 	Part *parts_ptr() { return _parts; }
  	void pause(bool paused);
+ 	int initialize(Scumm *scumm, SoundDriver *driver);
+ 	int terminate();
+ 	int save_or_load(Serializer *ser);
+ 	int set_master_volume(uint vol);
+ 	int get_master_volume();
+ 	bool start_sound(int sound);
+ 	int stop_sound(int sound);
+ 	int stop_all_sounds();
+ 	int get_sound_status(int sound);
+ 	int32 do_command(int a, int b, int c, int d, int e, int f, int g, int h);
+ 	int clear_queue();
+ 	void setBase(byte **base) { _base_sounds = base; }
+ 
+ 	SOUND_DRIVER_TYPE *driver() { return _driver; }
  };
+ 
+ 

Index: sys.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sys.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sys.cpp	2001/11/06 20:00:47	1.4
--- sys.cpp	2001/12/01 17:06:13	1.5
***************
*** 56,59 ****
--- 56,63 ----
  }
  
+ uint32 Scumm::filePos(void *handle) {
+ 	return ftell((FILE*)handle);
+ }
+ 
  void Scumm::fileSeek(void *file, long offs, int whence) {
  	switch(_fileMode) {

Index: windows.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/windows.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** windows.cpp	2001/11/27 18:35:58	1.20
--- windows.cpp	2001/12/01 17:06:13	1.21
***************
*** 133,136 ****
--- 133,137 ----
  Gui gui;
  SoundEngine sound;
+ SOUND_DRIVER_TYPE snd_driv;
  
  WndMan wm[1];
***************
*** 847,851 ****
  
  void fill_buffer(int16 *buf, int len) {
- 	memset(buf, 0, len*2);
  	scumm.mixWaves(buf, len);
  }
--- 848,851 ----
***************
*** 892,899 ****
  
  	while (1) {
! 		cur = GetTickCount();
! 		while (time < cur) {
! 			sound.on_timer();
! 			time += 10;
  		}
  
--- 892,902 ----
  
  	while (1) {
! 
! 		if (!snd_driv.wave_based()) {
! 			cur = GetTickCount();
! 			while (time < cur) {
! 				sound.on_timer();
! 				time += 10;
! 			}
  		}
  
***************
*** 918,927 ****
  
  	wm->init();
- 	wm->sound_init();
  	wm->_vgabuf = (byte*)calloc(320,200);
  	wm->_scumm = &scumm;
! 	
! 	sound.initialize(&scumm);
! 	scumm._soundDriver = &sound;
  
  	scumm._gui = &gui;
--- 921,930 ----
  
  	wm->init();
  	wm->_vgabuf = (byte*)calloc(320,200);
  	wm->_scumm = &scumm;
! 
! 	sound.initialize(&scumm,&snd_driv);
! 
! 	wm->sound_init();
  
  	scumm._gui = &gui;





More information about the Scummvm-git-logs mailing list