[Scummvm-cvs-logs] CVS: scummvm/morphos morphos.cpp,1.18,1.19 morphos.h,1.10,1.11 morphos_sound.cpp,1.9,1.10 morphos_start.cpp,1.4,1.5

Ruediger Hanke tomjoad at users.sourceforge.net
Sun May 26 09:38:01 CEST 2002


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

Modified Files:
	morphos.cpp morphos.h morphos_sound.cpp morphos_start.cpp 
Log Message:
Various changes in MorphOS interface

Index: morphos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/morphos/morphos.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- morphos.cpp	9 May 2002 12:45:29 -0000	1.18
+++ morphos.cpp	26 May 2002 16:37:41 -0000	1.19
@@ -125,28 +125,12 @@
 	strcpy( ScummWndTitle, "ScummVM MorphOS" );
 	TimerMsgPort = NULL;
 	TimerIORequest = NULL;
+	SaveTimerMsgPort = NULL;
+	SaveTimerIORequest = NULL;
+	SaveTimerRun = false;
 
-	TimerMsgPort = CreateMsgPort();
-	if( TimerMsgPort == NULL )
-	{
-		puts( "Failed to create message port" );
-		exit( 1 );
-	}
-
-	TimerIORequest = (struct timerequest *)CreateIORequest( TimerMsgPort, sizeof( struct timerequest ) );
-	if( TimerIORequest == NULL )
-	{
-		puts( "Failed to create IO request" );
-		exit( 1 );
-	}
-
-	if( OpenDevice( "timer.device", UNIT_MICROHZ, (struct IORequest *)TimerIORequest, 0 ) )
-	{
-		DeleteIORequest( (struct IORequest *)TimerIORequest );
-		TimerIORequest = NULL;
-		puts( "Failed to open timer device" );
-		exit( 1 );
-	}
+	OpenATimer( &TimerMsgPort, (struct IORequest **)&TimerIORequest, UNIT_MICROHZ );
+	OpenATimer( &SaveTimerMsgPort, (struct IORequest **)&SaveTimerIORequest, UNIT_VBLANK );
 
 	ScummNoCursor = (UWORD *)AllocVec( 16, MEMF_CHIP | MEMF_CLEAR );
 }
@@ -168,6 +152,21 @@
 	if( TimerMsgPort )
 		DeleteMsgPort( TimerMsgPort );
 
+	if( SaveTimerRun )
+	{
+		AbortIO( (struct IORequest *)SaveTimerIORequest );
+		WaitIO( (struct IORequest *)SaveTimerIORequest );
+	}
+
+	if( SaveTimerIORequest )
+	{
+		CloseDevice( (struct IORequest *)SaveTimerIORequest );
+		DeleteIORequest( (struct IORequest *)SaveTimerIORequest );
+	}
+
+	if( SaveTimerMsgPort )
+		DeleteMsgPort( SaveTimerMsgPort );
+
 	if( ScummMusicThread )
 	{
 		Signal( (struct Task *)ScummMusicThread, SIGBREAKF_CTRL_C );
@@ -204,6 +203,31 @@
 	}
 }
 
+void OSystem_MorphOS::OpenATimer( struct MsgPort **port, struct IORequest **req, ULONG unit )
+{
+	*port = CreateMsgPort();
+	if( *port == NULL )
+	{
+		puts( "Failed to create message port" );
+		exit( 1 );
+	}
+
+	*req = (struct IORequest *)CreateIORequest( *port, sizeof( struct timerequest ) );
+	if( *req == NULL )
+	{
+		puts( "Failed to create IO request" );
+		exit( 1 );
+	}
+
+	if( OpenDevice( "timer.device", unit, *req, 0 ) )
+	{
+		DeleteIORequest( *req );
+		*req = NULL;
+		puts( "Failed to open timer device" );
+		exit( 1 );
+	}
+}
+
 uint32 OSystem_MorphOS::get_msecs()
 {
 	int ticks = clock();
@@ -219,6 +243,26 @@
 	DoIO( (struct IORequest *)TimerIORequest );
 }
 
+void OSystem_MorphOS::set_timer(int timer, int (*callback)(int))
+{
+	if( timer )
+	{
+		SaveTimerRun = true;
+		TimerCallback = callback;
+		TimerInterval = timer;
+
+		SaveTimerIORequest->tr_node.io_Command  = TR_ADDREQUEST;
+		SaveTimerIORequest->tr_time.tv_secs  = timer/1000;
+		SaveTimerIORequest->tr_time.tv_micro = timer%1000;
+		SendIO( (struct IORequest *)SaveTimerIORequest );
+	}
+	else
+	{
+		SaveTimerRun = false;
+		TimerInterval = 0;
+	}
+}
+
 void *OSystem_MorphOS::create_thread(ThreadProc *proc, void *param)
 {
 	static EmulFunc ThreadEmulFunc;
@@ -253,6 +297,11 @@
 			if( CDDABase )
 			{
 				CDrive = CDDA_FindNextDrive( NULL, FindCDTags );
+				if( !CDrive && GameID == GID_MONKEY )
+				{
+					FindCDTags[ 0 ].ti_Data = (ULONG)"Madness";
+					CDrive = CDDA_FindNextDrive( NULL, FindCDTags );
+				}
 				if( CDrive )
 				{
 					if( !CDDA_ObtainDrive( CDrive, CDDA_SHARED_ACCESS, NULL ) )
@@ -307,8 +356,6 @@
 	}
 }
 
-// Schedule the music to be stopped after 1/10 sec, unless another
-// track is started in the meantime.
 void OSystem_MorphOS::stop_cdrom()
 {
 	CDDA_Stop( CDrive );
@@ -661,6 +708,13 @@
 bool OSystem_MorphOS::poll_event( Event *event )
 {
 	struct IntuiMessage *ScummMsg;
+
+	if( SaveTimerRun && CheckIO( (struct IORequest *)SaveTimerIORequest ) )
+	{
+		WaitIO( (struct IORequest *)SaveTimerIORequest );
+		TimerInterval = (*TimerCallback)( TimerInterval );
+		set_timer( TimerInterval, TimerCallback );
+	}
 
 	if( ScummMsg = (struct IntuiMessage *)GetMsg( ScummWindow->UserPort ) )
 	{

Index: morphos.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/morphos/morphos.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- morphos.h	9 May 2002 12:45:29 -0000	1.10
+++ morphos.h	26 May 2002 16:37:41 -0000	1.11
@@ -64,6 +64,9 @@
 		// Delay for a specified amount of milliseconds
 		virtual void delay_msecs(uint msecs);
 
+		// Add a new callback timer
+		virtual void set_timer(int timer, int (*callback)(int));
+
 		// Create a thread
 		virtual void *create_thread(ThreadProc *proc, void *param);
 
@@ -121,6 +124,8 @@
 		void   draw_mouse();
 		void   undraw_mouse();
 
+		void   OpenATimer( struct MsgPort **port, struct IORequest **req, ULONG unit );
+
 		/* Display-related attributes */
 		struct Screen  	  *ScummScreen;
 		struct Window  	  *ScummWindow;
@@ -185,6 +190,11 @@
 		/* Timer-related attributes */
 		struct MsgPort 	 *TimerMsgPort;
 		struct timerequest *TimerIORequest;
+		struct MsgPort 	 *SaveTimerMsgPort;
+		struct timerequest *SaveTimerIORequest;
+		int 					(*TimerCallback)(int);
+		bool					  SaveTimerRun;
+		int					  TimerInterval;
 
 		/* Game-related attributes */
 		int   GameID;
@@ -200,7 +210,8 @@
 extern struct SignalSemaphore ScummMusicThreadRunning;
 extern struct SignalSemaphore ScummSoundThreadRunning;
 
-extern LONG ScummMidiUnit;
+extern STRPTR ScummMusicDriver;
+extern LONG   ScummMidiUnit;
 extern struct IOMidiRequest *ScummMidiRequest;
 extern struct timerequest   *MusicTimerIORequest;
 

Index: morphos_sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/morphos/morphos_sound.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- morphos_sound.cpp	21 Apr 2002 16:12:09 -0000	1.9
+++ morphos_sound.cpp	26 May 2002 16:37:41 -0000	1.10
@@ -56,33 +56,36 @@
 
 bool init_morphos_music( ULONG MidiUnit )
 {
-	MidiUnit = ScummMidiUnit;	// Ugly fix, but ...
-	ScummMidiPort = CreateMsgPort();
-	if( ScummMidiPort )
+	if( ScummMusicDriver && !stricmp( ScummMusicDriver, "-eamidi" ) )	  // just as ugly as the line below ...
 	{
-		ScummMidiRequest = (struct IOMidiRequest *)CreateIORequest( ScummMidiPort, sizeof( struct IOMidiRequest ) );
-		if( ScummMidiRequest )
+		MidiUnit = ScummMidiUnit;	// Ugly fix, but ...
+		ScummMidiPort = CreateMsgPort();
+		if( ScummMidiPort )
 		{
-			ScummMidiRequest->amr_Version = 2;
-			if( OpenDevice( "amidi.device", MidiUnit, (struct IORequest *)ScummMidiRequest, AMIDIF_MIDISERVER ) )
+			ScummMidiRequest = (struct IOMidiRequest *)CreateIORequest( ScummMidiPort, sizeof( struct IOMidiRequest ) );
+			if( ScummMidiRequest )
+			{
+				ScummMidiRequest->amr_Version = 2;
+				if( OpenDevice( "amidi.device", MidiUnit, (struct IORequest *)ScummMidiRequest, AMIDIF_MIDISERVER ) )
+				{
+					DeleteIORequest( (struct IORequest *)ScummMidiRequest );
+					DeleteMsgPort( ScummMidiPort );
+					ScummMidiRequest = NULL;
+					ScummMidiPort = NULL;
+				}
+			}
+			else
 			{
-				DeleteIORequest( (struct IORequest *)ScummMidiRequest );
 				DeleteMsgPort( ScummMidiPort );
-				ScummMidiRequest = NULL;
 				ScummMidiPort = NULL;
 			}
 		}
-		else
+
+		if( !ScummMidiRequest )
 		{
-			DeleteMsgPort( ScummMidiPort );
-			ScummMidiPort = NULL;
+			warning( "Could not open AMidi - music will not play" );
+			return false;
 		}
-	}
-
-	if( !ScummMidiRequest )
-	{
-		warning( "Could not open AMidi - music will not play" );
-		return false;
 	}
 
 	MusicTimerMsgPort = CreateMsgPort();

Index: morphos_start.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/morphos/morphos_start.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- morphos_start.cpp	8 May 2002 20:36:12 -0000	1.4
+++ morphos_start.cpp	26 May 2002 16:37:41 -0000	1.5
@@ -40,17 +40,19 @@
 extern "C" struct WBStartup *_WBenchMsg;
 
 // For command line parsing
-static STRPTR usageTemplate = "STORY/A,DATAPATH/K,WBWINDOW/S,SCALER/K,AMIGA/S,MIDIUNIT/K/N,MUSIC/K,VOLUME/K/N,TEMPO/K/N,NOSUBTITLES=NST/S";
-typedef enum 					{ USG_STORY = 0,	USG_DATAPATH, 	USG_WBWINDOW,	USG_SCALER, 	USG_AMIGA,	USG_MIDIUNIT,	USG_MUSIC,	 USG_VOLUME,	 USG_TEMPO,	  USG_NOSUBTITLES } usageFields;
-static LONG	  args[ 11 ] =  { (ULONG)NULL, 	 (ULONG)NULL,	 FALSE, 			 (ULONG)NULL,	false,      (ULONG)NULL,   (ULONG)NULL, (ULONG)NULL,	 (ULONG)NULL, false };
+static STRPTR usageTemplate = "STORY/A,DATAPATH/K,WBWINDOW/S,SCALER/K,AMIGA/S,MIDIUNIT/K/N,MUSIC/K,MUSICVOL/K/N,SFXVOL/K/N,TEMPO/K/N,TALKSPEED/K/N,NOSUBTITLES=NST/S";
+typedef enum 					{ USG_STORY = 0,	USG_DATAPATH, 	USG_WBWINDOW,	USG_SCALER, 	USG_AMIGA,	USG_MIDIUNIT,	USG_MUSIC,	 USG_MUSICVOL,	USG_SFXVOL,	   USG_TEMPO,   USG_TALKSPEED, USG_NOSUBTITLES } usageFields;
+static LONG	  args[ 13 ] =  { (ULONG)NULL, 	 (ULONG)NULL,	 FALSE, 			 (ULONG)NULL,	false,      (ULONG)NULL,   (ULONG)NULL, (ULONG)NULL, (ULONG)NULL,	  (ULONG)NULL,  (ULONG)NULL,   false };
 static struct RDArgs *ScummArgs = NULL;
 
 static char*ScummStory = NULL;
 static char*ScummPath = NULL;
-static STRPTR ScummMusicDriver = NULL;
+	  STRPTR ScummMusicDriver = NULL;
 		 LONG ScummMidiUnit = 0;
 static LONG ScummMidiVolume = 0;
 static LONG ScummMidiTempo = 0;
+static LONG ScummSfxVolume = 0;
+static LONG ScummTalkSpeed = 0;
 static OSystem_MorphOS::SCALERTYPE ScummGfxScaler = OSystem_MorphOS::ST_INVALID;
 
 static BPTR OrigDirLock = 0;
@@ -180,13 +182,23 @@
 	if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "MIDIUNIT" ) )
 		ScummMidiUnit = atoi( ToolValue );
 
-	if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "VOLUME" ) )
+	if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "MUSICVOL" ) )
 	{
 		int vol = atoi( ToolValue );
 		if( vol >= 0 && vol <= 100 )
 		{
 			ScummMidiVolume = vol;
-			args[ USG_VOLUME ] = (ULONG)&ScummMidiVolume;
+			args[ USG_MUSICVOL ] = (ULONG)&ScummMidiVolume;
+		}
+	}
+
+	if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "SFXVOL" ) )
+	{
+		int vol = atoi( ToolValue );
+		if( vol >= 0 && vol <= 255 )
+		{
+			ScummSfxVolume = vol;
+			args[ USG_SFXVOL ] = (ULONG)&ScummSfxVolume;
 		}
 	}
 
@@ -196,6 +208,12 @@
 		args[ USG_TEMPO ] = (ULONG)&ScummMidiTempo;
 	}
 
+	if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "TALKSPEED" ) )
+	{
+		ScummTalkSpeed = atoi( ToolValue );
+		args[ USG_TALKSPEED ] = (ULONG)&ScummMidiTempo;
+	}
+
 	if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "SUBTITLES" ) )
 	{
 		if( MatchToolValue( ToolValue, "YES" ) )
@@ -221,8 +239,8 @@
 {
 	int delta;
 	int last_time, new_time;
-	char *argv[ 15 ];
-	char volume[ 6 ], tempo[ 12 ], scaler[ 14 ];
+	char *argv[ 20 ];
+	char musicvol[ 6 ], sfxvol[ 6 ], talkspeed[ 12 ], tempo[ 12 ], scaler[ 14 ];
 	char *SVMScalers[] = { "", "normal", "2x", "advmame2x", "supereagle", "super2xsai" };
 	int argc = 0;
 
@@ -279,8 +297,14 @@
 		if( args[ USG_TEMPO ] )
 			ScummMidiTempo = *((LONG *)args[ USG_TEMPO ]);
 
-		if( args[ USG_VOLUME ] )
-			ScummMidiVolume = *((LONG *)args[ USG_VOLUME ]);
+		if( args[ USG_MUSICVOL ] )
+			ScummMidiVolume = *((LONG *)args[ USG_MUSICVOL ]);
+
+		if( args[ USG_SFXVOL ] )
+			ScummSfxVolume = *((LONG *)args[ USG_SFXVOL ]);
+
+		if( args[ USG_TALKSPEED ] )
+			ScummTalkSpeed = *((LONG *)args[ USG_TALKSPEED ]);
 	}
 	else
 	{
@@ -313,15 +337,25 @@
 	}
 	else
 		argv[ argc++ ] = "-gsuper2xsai";
-	if( args[ USG_VOLUME ] && ScummMidiVolume >= 0 && ScummMidiVolume <= 100 )
+	if( args[ USG_MUSICVOL ] && ScummMidiVolume >= 0 && ScummMidiVolume <= 100 )
 	{
-		sprintf( volume, "-m%d", ScummMidiVolume );
-		argv[ argc++ ] = volume;
+		sprintf( musicvol, "-m%d", ScummMidiVolume );
+		argv[ argc++ ] = musicvol;
+	}
+	if( args[ USG_SFXVOL ] && ScummSfxVolume >= 0 && ScummSfxVolume <= 255 )
+	{
+		sprintf( sfxvol, "-s%d", ScummSfxVolume );
+		argv[ argc++ ] = sfxvol;
 	}
 	if( args[ USG_TEMPO ] && ScummMidiTempo > 0 )
 	{
 		sprintf( tempo, "-t%lx", ScummMidiTempo );
 		argv[ argc++ ] = tempo;
+	}
+	if( args[ USG_TALKSPEED ] && ScummTalkSpeed >= 0 && ScummTalkSpeed <= 255 )
+	{
+		sprintf( talkspeed, "-y%d", ScummTalkSpeed );
+		argv[ argc++ ] = talkspeed;
 	}
 	argv[ argc++ ] = ScummStory;
 





More information about the Scummvm-git-logs mailing list