diff options
-rw-r--r-- | morphos/morphos.cpp | 100 | ||||
-rw-r--r-- | morphos/morphos.h | 13 | ||||
-rw-r--r-- | morphos/morphos_sound.cpp | 39 | ||||
-rw-r--r-- | morphos/morphos_start.cpp | 60 |
4 files changed, 157 insertions, 55 deletions
diff --git a/morphos/morphos.cpp b/morphos/morphos.cpp index 2ec5c98428..a6d9399a70 100644 --- a/morphos/morphos.cpp +++ b/morphos/morphos.cpp @@ -125,28 +125,12 @@ OSystem_MorphOS::OSystem_MorphOS( int game_id, SCALERTYPE gfx_mode, bool full_sc 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 @@ OSystem_MorphOS::~OSystem_MorphOS() 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 @@ OSystem_MorphOS::~OSystem_MorphOS() } } +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 @@ void OSystem_MorphOS::delay_msecs(uint msecs) 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 @@ uint32 OSystem_MorphOS::property(int param, Property *value) 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 @@ void OSystem_MorphOS::play_cdrom( int track, int num_loops, int start_frame, int } } -// 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 ); @@ -662,6 +709,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 ) ) { switch( ScummMsg->Class ) diff --git a/morphos/morphos.h b/morphos/morphos.h index b728e3e830..d0be723318 100644 --- a/morphos/morphos.h +++ b/morphos/morphos.h @@ -64,6 +64,9 @@ class OSystem_MorphOS : public OSystem // 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 @@ class OSystem_MorphOS : public OSystem 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 @@ class OSystem_MorphOS : public OSystem /* 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 OSystem_MorphOS *TheSystem; 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; diff --git a/morphos/morphos_sound.cpp b/morphos/morphos_sound.cpp index da74f786ac..64ed693049 100644 --- a/morphos/morphos_sound.cpp +++ b/morphos/morphos_sound.cpp @@ -56,35 +56,38 @@ static struct MsgPort *MusicTimerMsgPort = NULL; 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(); if( MusicTimerMsgPort ) { diff --git a/morphos/morphos_start.cpp b/morphos/morphos_start.cpp index 3ef15db073..3cd8d28fdd 100644 --- a/morphos/morphos_start.cpp +++ b/morphos/morphos_start.cpp @@ -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 @@ static void ReadToolTypes( struct WBArg *OfFile ) 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 @@ static void ReadToolTypes( struct WBArg *OfFile ) 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 main() { 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 @@ int main() 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,16 +337,26 @@ int main() } 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; return morphos_main( argc, argv ); |