aboutsummaryrefslogtreecommitdiff
path: root/morphos
diff options
context:
space:
mode:
authorRuediger Hanke2002-04-18 21:40:24 +0000
committerRuediger Hanke2002-04-18 21:40:24 +0000
commit8a7ca8133c0d9a73609ef29b8f5caefc0f19b707 (patch)
treece508e74f800d2fd21c2bfcadcbee512ab9afeb9 /morphos
parentdf31144cc7b42bf04127566de1b7127ba0d75c09 (diff)
downloadscummvm-rg350-8a7ca8133c0d9a73609ef29b8f5caefc0f19b707.tar.gz
scummvm-rg350-8a7ca8133c0d9a73609ef29b8f5caefc0f19b707.tar.bz2
scummvm-rg350-8a7ca8133c0d9a73609ef29b8f5caefc0f19b707.zip
Reenable MorphOS Midi driver, small updates to CD open code (only when CD audio is requested) and start options
svn-id: r3997
Diffstat (limited to 'morphos')
-rw-r--r--morphos/morphos.cpp58
-rw-r--r--morphos/morphos.h5
-rw-r--r--morphos/morphos_sound.cpp160
-rw-r--r--morphos/morphos_start.cpp47
4 files changed, 129 insertions, 141 deletions
diff --git a/morphos/morphos.cpp b/morphos/morphos.cpp
index 8c2ffe5f57..487ecbd45f 100644
--- a/morphos/morphos.cpp
+++ b/morphos/morphos.cpp
@@ -220,15 +220,16 @@ void OSystem_MorphOS::delay_msecs(uint msecs)
void *OSystem_MorphOS::create_thread(ThreadProc *proc, void *param)
{
-/* MyEmulFunc.Trap = TRAP_FUNC;
- MyEmulFunc.Address = (ULONG)proc;
- MyEmulFunc.StackSize = 8192;
- MyEmulFunc.Extension = 0;
- MyEmulFunc.Arg1 = (ULONG)param;
- MyEmulFunc.Arg2 = (ULONG)ScummMidiUnit;
- MyEmulFunc.Arg3 = (ULONG)args[ USG_NOMUSIC ];
- ScummMusicThread = CreateNewProc( musicProcTags );*/
- return NULL;
+ static EmulFunc ThreadEmulFunc;
+
+ ThreadEmulFunc.Trap = TRAP_FUNC;
+ ThreadEmulFunc.Address = (ULONG)proc;
+ ThreadEmulFunc.StackSize = 16000;
+ ThreadEmulFunc.Extension = 0;
+ ThreadEmulFunc.Arg1 = (ULONG)param;
+ musicProcTags[ 0 ].ti_Data = (ULONG)&ThreadEmulFunc;
+ ScummMusicThread = CreateNewProc( musicProcTags );
+ return ScummMusicThread;
}
uint32 OSystem_MorphOS::property(int param, uint32 value)
@@ -246,32 +247,35 @@ uint32 OSystem_MorphOS::property(int param, uint32 value)
return 1;
case PROP_OPEN_CD:
- FindCDTags[ 0 ].ti_Data = (ULONG)((GameID == GID_LOOM256) ? "LoomCD" : "Monkey1CD");
- if( !CDDABase ) CDDABase = OpenLibrary( "cdda.library", 0 );
- if( CDDABase )
+ if( value )
{
- CDrive = CDDA_FindNextDrive( NULL, FindCDTags );
- if( CDrive )
+ FindCDTags[ 0 ].ti_Data = (ULONG)((GameID == GID_LOOM256) ? "LoomCD" : "Monkey1CD");
+ if( !CDDABase ) CDDABase = OpenLibrary( "cdda.library", 0 );
+ if( CDDABase )
{
- if( !CDDA_ObtainDrive( CDrive, CDDA_SHARED_ACCESS, NULL ) )
- {
- CDrive = NULL;
- warning( "Failed to obtain CD drive - music will not play" );
- }
- else if( GameID == GID_LOOM256 )
+ CDrive = CDDA_FindNextDrive( NULL, FindCDTags );
+ if( CDrive )
{
- // Offset correction *may* be required
- struct CDS_TrackInfo ti;
+ if( !CDDA_ObtainDrive( CDrive, CDDA_SHARED_ACCESS, NULL ) )
+ {
+ CDrive = NULL;
+ warning( "Failed to obtain CD drive - music will not play" );
+ }
+ else if( GameID == GID_LOOM256 )
+ {
+ // Offset correction *may* be required
+ struct CDS_TrackInfo ti;
- if( CDDA_GetTrackInfo( CDrive, 1, 0, &ti ) )
- CDDATrackOffset = ti.ti_TrackStart.tm_Format.tm_Frame-22650;
+ if( CDDA_GetTrackInfo( CDrive, 1, 0, &ti ) )
+ CDDATrackOffset = ti.ti_TrackStart.tm_Format.tm_Frame-22650;
+ }
}
+ else
+ warning( "Could not find game CD inserted in CD-ROM drive - cd audio will not play" );
}
else
- warning( "Could not find game CD inserted in CD-ROM drive - cd audio will not play" );
+ warning( "Failed to open cdda.library - cd audio will not play" );
}
- else
- warning( "Failed to open cdda.library - cd audio will not play" );
break;
case PROP_SHOW_DEFAULT_CURSOR:
diff --git a/morphos/morphos.h b/morphos/morphos.h
index b6259dd326..93dad021fa 100644
--- a/morphos/morphos.h
+++ b/morphos/morphos.h
@@ -188,6 +188,8 @@ class OSystem_MorphOS : public OSystem
};
int morphos_sound_thread( OSystem_MorphOS *syst, ULONG SampleType );
+bool init_morphos_music( ULONG MidiUnit );
+void exit_morphos_music();
int morphos_main( int argc, char *argv[] );
@@ -195,3 +197,6 @@ extern OSystem_MorphOS *TheSystem;
extern struct SignalSemaphore ScummMusicThreadRunning;
extern struct SignalSemaphore ScummSoundThreadRunning;
+extern struct IOMidiRequest *ScummMidiRequest;
+extern struct timerequest *MusicTimerIORequest;
+
diff --git a/morphos/morphos_sound.cpp b/morphos/morphos_sound.cpp
index 43de32f244..c20631ef8f 100644
--- a/morphos/morphos_sound.cpp
+++ b/morphos/morphos_sound.cpp
@@ -25,6 +25,8 @@
#include "stdafx.h"
#include "scumm.h"
+#include "mididrv.h"
+#include "imuse.h"
#include <dos/dos.h>
#include <exec/memory.h>
@@ -53,40 +55,66 @@ static char *ahiBuf[ 2 ] = { NULL, NULL };
static struct MsgPort *ScummMidiPort = NULL;
struct IOMidiRequest *ScummMidiRequest = NULL;
+static struct MsgPort *MusicTimerMsgPort = NULL;
+ struct timerequest *MusicTimerIORequest = NULL;
-bool init_morphos_music( ULONG MidiUnit, bool NoMusic )
+bool init_morphos_music( ULONG MidiUnit )
{
- if( !NoMusic )
+ ScummMidiPort = CreateMsgPort();
+ if( ScummMidiPort )
{
- ScummMidiPort = CreateMsgPort();
- if( ScummMidiPort )
+ ScummMidiRequest = (struct IOMidiRequest *)CreateIORequest( ScummMidiPort, sizeof( struct IOMidiRequest ) );
+ if( ScummMidiRequest )
{
- 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
+ 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
+ {
+ DeleteMsgPort( ScummMidiPort );
+ ScummMidiPort = NULL;
+ }
+ }
- if( !ScummMidiRequest )
+ if( !ScummMidiRequest )
+ {
+ warning( "Could not open AMidi - music will not play" );
+ return false;
+ }
+
+ MusicTimerMsgPort = CreateMsgPort();
+ if( MusicTimerMsgPort )
+ {
+ MusicTimerIORequest = (struct timerequest *)CreateIORequest( MusicTimerMsgPort, sizeof( struct timerequest ) );
+ if( MusicTimerIORequest )
+ {
+ if( OpenDevice( "timer.device", UNIT_MICROHZ, (struct IORequest *)MusicTimerIORequest, 0 ) )
+ {
+ DeleteIORequest( (struct IORequest *)MusicTimerIORequest );
+ DeleteMsgPort( MusicTimerMsgPort );
+ MusicTimerIORequest = NULL;
+ MusicTimerMsgPort = NULL;
+ }
+ }
+ else
{
- warning( "Could not open AMidi - music will not play" );
- return false;
+ DeleteMsgPort( MusicTimerMsgPort );
+ MusicTimerMsgPort = NULL;
}
}
+ if( !MusicTimerIORequest )
+ {
+ warning( "Could not open timer device - music will not play" );
+ return false;
+ }
+
return true;
}
@@ -99,6 +127,13 @@ void exit_morphos_music()
DeleteIORequest( (struct IORequest *)ScummMidiRequest );
DeleteMsgPort( ScummMidiPort );
}
+
+ if( MusicTimerIORequest )
+ {
+ CloseDevice( (struct IORequest *)MusicTimerIORequest );
+ DeleteIORequest( (struct IORequest *)MusicTimerIORequest );
+ DeleteMsgPort( MusicTimerMsgPort );
+ }
}
@@ -177,91 +212,6 @@ static void exit_morphos_sound()
DeleteMsgPort( ahiPort );
}
-
-int morphos_music_thread( Scumm *s, ULONG MidiUnit, bool NoMusic )
-{
-#if 0
- int old_time, cur_time;
- bool initialized;
- bool TimerAvailable = false;
- struct MsgPort *TimerMsgPort;
- struct timerequest *TimerIORequest;
-
- ObtainSemaphore( &ScummMusicThreadRunning );
-
- initialized = init_morphos_music( MidiUnit, NoMusic );
- if( !initialized )
- warning( "Sound could not be initialized" );
-
- TimerMsgPort = CreateMsgPort();
- if( TimerMsgPort )
- {
- TimerIORequest = (struct timerequest *)CreateIORequest( TimerMsgPort, sizeof( struct timerequest ) );
- if( TimerIORequest )
- {
- if( OpenDevice( "timer.device", UNIT_MICROHZ, (struct IORequest *)TimerIORequest, 0 ) == 0 )
- TimerAvailable = true;
- else
- {
- DeleteIORequest( (struct IORequest *)TimerIORequest );
- DeleteMsgPort( TimerMsgPort );
- }
- }
- else
- DeleteMsgPort( TimerMsgPort );
- }
-
- if( !TimerAvailable )
- {
- warning( "ScummVM Music Thread: no timer available! Sound and music will be disabled" );
- Wait( SIGBREAKF_CTRL_F );
- }
- else
- {
- old_time = 0;//GetTicks();
-
- for(;;)
- {
- if( CheckSignal( SIGBREAKF_CTRL_F ) )
- break;
-
-/* if( !snd_driv.wave_based() )
- {
- cur_time = GetTicks();
- while( old_time < cur_time )
- {
- old_time += 10;
- sound.on_timer();
- }*/
-/* TimerIORequest->tr_time.tv_micro = (old_time-cur_time)*1000;
- if( TimerIORequest->tr_time.tv_micro == 0 )
- TimerIORequest->tr_time.tv_micro = 100;*/
-/* TimerIORequest->tr_time.tv_micro = 10000;
- }
- else
- TimerIORequest->tr_time.tv_micro = 10000;*/
-
- TimerIORequest->tr_node.io_Command = TR_ADDREQUEST;
- TimerIORequest->tr_time.tv_secs = 0;
- DoIO( (struct IORequest *)TimerIORequest );
- }
- }
-
- if( TimerAvailable )
- {
- CloseDevice( (struct IORequest *)TimerIORequest );
- DeleteIORequest( (struct IORequest *)TimerIORequest );
- DeleteMsgPort( TimerMsgPort );
- }
-
- exit_morphos_music();
-
- ReleaseSemaphore( &ScummMusicThreadRunning );
- return 0;
-#endif
-}
-
-
int morphos_sound_thread( OSystem_MorphOS *syst, ULONG SampleType )
{
ULONG signals;
diff --git a/morphos/morphos_start.cpp b/morphos/morphos_start.cpp
index 2e4438611c..67d49c52be 100644
--- a/morphos/morphos_start.cpp
+++ b/morphos/morphos_start.cpp
@@ -40,13 +40,14 @@
extern "C" struct WBStartup *_WBenchMsg;
// For command line parsing
-static STRPTR usageTemplate = "STORY/A,DATAPATH/K,WBWINDOW/S,SCALER/K,MIDIUNIT/K/N,NOMUSIC/S,VOLUME/K/N,TEMPO/K/N,ROLANDEMU/S,NOSUBTITLES=NST/S";
-typedef enum { USG_STORY = 0, USG_DATAPATH, USG_WBWINDOW, USG_SCALER, USG_MIDIUNIT, USG_NOMUSIC, USG_VOLUME, USG_TEMPO, USG_ROLANDEMU, USG_NOSUBTITLES } usageFields;
-static LONG args[ 10 ] = { (ULONG)NULL, (ULONG)NULL, FALSE, (ULONG)NULL, (ULONG)NULL, false, (ULONG)NULL, (ULONG)NULL, false, false };
+static STRPTR usageTemplate = "STORY/A,DATAPATH/K,WBWINDOW/S,SCALER/K,AMIGA/S,MIDIUNIT/K/N,MUSIC/K,VOLUME/K/N,TEMPO/K/N,ROLANDEMU/S,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_ROLANDEMU, USG_NOSUBTITLES } usageFields;
+static LONG args[ 11 ] = { (ULONG)NULL, (ULONG)NULL, FALSE, (ULONG)NULL, false, (ULONG)NULL, (ULONG)NULL, (ULONG)NULL, (ULONG)NULL, false, false };
static struct RDArgs *ScummArgs = NULL;
static char*ScummStory = NULL;
static char*ScummPath = NULL;
+static STRPTR ScummMusicDriver = NULL;
static LONG ScummMidiUnit = 0;
static LONG ScummMidiVolume = 0;
static LONG ScummMidiTempo = 0;
@@ -108,7 +109,17 @@ void close_resources()
CloseLibrary( CyberGfxBase );
}
-void ReadToolTypes( struct WBArg *OfFile )
+static STRPTR FindMusicDriver( STRPTR argval )
+{
+ if( !stricmp( argval, "off" ) ) return "-enull";
+ if( !stricmp( argval, "midi" ) ) return "-eamidi";
+ if( !stricmp( argval, "adlib" ) ) return "-eadlib";
+
+ error( "No such music driver supported. Possible values are off, Midi and Adlib." );
+ return NULL;
+}
+
+static void ReadToolTypes( struct WBArg *OfFile )
{
struct DiskObject *dobj;
char *ToolValue;
@@ -157,10 +168,12 @@ void ReadToolTypes( struct WBArg *OfFile )
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "MUSIC" ) )
{
- if( MatchToolValue( ToolValue, "YES" ) )
- args[ USG_NOMUSIC ] = FALSE;
- else if( MatchToolValue( ToolValue, "NO" ) )
- args[ USG_NOMUSIC ] = TRUE;
+ if( !(ScummMusicDriver = FindMusicDriver( ToolValue )) )
+ {
+ FreeDiskObject( dobj );
+ exit( 1 );
+ }
+ args[ USG_MUSIC ] = (ULONG)&ScummMusicDriver;
}
if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "MIDIUNIT" ) )
@@ -198,6 +211,14 @@ void ReadToolTypes( struct WBArg *OfFile )
args[ USG_NOSUBTITLES ] = TRUE;
}
+ if( ToolValue = (char *)FindToolType( dobj->do_ToolTypes, "AMIGA" ) )
+ {
+ if( MatchToolValue( ToolValue, "YES" ) )
+ args[ USG_AMIGA ] = FALSE;
+ else if( MatchToolValue( ToolValue, "NO" ) )
+ args[ USG_AMIGA ] = TRUE;
+ }
+
FreeDiskObject( dobj );
}
@@ -207,7 +228,7 @@ int main()
{
int delta;
int last_time, new_time;
- char *argv[ 10 ];
+ char *argv[ 15 ];
char volume[ 6 ], tempo[ 12 ], scaler[ 14 ];
char *SVMScalers[] = { "", "normal", "2x", "supereagle", "super2xsai" };
int argc = 0;
@@ -253,6 +274,12 @@ int main()
exit( 1 );
}
+ if( args[ USG_MUSIC ] )
+ {
+ if( !(ScummMusicDriver = FindMusicDriver( (char *)args[ USG_MUSIC ] )) )
+ exit( 1 );
+ }
+
if( args[ USG_MIDIUNIT ] )
ScummMidiUnit = *((LONG *)args[ USG_MIDIUNIT ]);
@@ -286,6 +313,8 @@ int main()
if( !args[ USG_WBWINDOW ] ) argv[ argc++ ] = "-f";
if( args[ USG_NOSUBTITLES ] ) argv[ argc++ ] = "-n";
if( args[ USG_ROLANDEMU ] ) argv[ argc++ ] = "-r";
+ if( args[ USG_AMIGA ] ) argv[ argc++ ] = "-a";
+ if( args[ USG_MUSIC ] ) argv[ argc++ ] = ScummMusicDriver;
if( ScummGfxScaler != OSystem_MorphOS::ST_INVALID )
{
sprintf( scaler, "-g%s", SVMScalers[ (int)ScummGfxScaler ] );