[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx:[769] trunk/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2014-02-04 12:00:38
|
Revision: 769 http://sourceforge.net/p/fuse-for-macosx/code/769 Author: fredm Date: 2014-02-04 12:00:34 +0000 (Tue, 04 Feb 2014) Log Message: ----------- Restore support for playing RZXs with no embedded snapshot. Modified Paths: -------------- trunk/fuse/fusepb/controllers/FuseController.m trunk/fuse/fusepb/models/Emulator.h trunk/fuse/fusepb/models/Emulator.m trunk/fuse/fusepb/views/DisplayOpenGLView.h trunk/fuse/fusepb/views/DisplayOpenGLView.m trunk/fuse/rzx.h Modified: trunk/fuse/fusepb/controllers/FuseController.m =================================================================== --- trunk/fuse/fusepb/controllers/FuseController.m 2013-12-25 23:59:06 UTC (rev 768) +++ trunk/fuse/fusepb/controllers/FuseController.m 2014-02-04 12:00:34 UTC (rev 769) @@ -642,7 +642,10 @@ - (IBAction)rzx_play:(id)sender { - char *recording; + char *recording, *snapshot; + utils_file file; + libspectrum_error libspec_error; int error; + libspectrum_snap* snap; if( rzx_playback || rzx_recording ) return; @@ -652,8 +655,45 @@ if( !recording ) { [[DisplayOpenGLView instance] unpause]; return; } - [self addRecentSnapshot:recording]; + rzx = libspectrum_rzx_alloc(); + error = utils_read_file( recording, &file ); + if( error ) { + free( recording ); + [[DisplayOpenGLView instance] unpause]; + return; + } + + libspec_error = libspectrum_rzx_read( rzx, file.buffer, file.length ); + utils_close_file( &file ); + if( libspec_error != LIBSPECTRUM_ERROR_NONE ) { + free( recording ); + [[DisplayOpenGLView instance] unpause]; + return; + } + + snap = rzx_get_initial_snapshot(); + if( !snap ) { + /* We need to load an external snapshot. */ + snapshot = cocoaui_openpanel_get_filename( @"Load Replay Snapshot", + snapFileTypes ); + if( !snapshot ) { + free( recording ); + [[DisplayOpenGLView instance] unpause]; + return; + } + + [[DisplayOpenGLView instance] snapOpen:snapshot]; + free( snapshot ); + } else { + // FIXME: snapless rzxs loaded from the menu would require a snapshot + // prompt when selecting from the recent files list which would deadlock + // right now + [self addRecentSnapshot:recording]; + } + + libspectrum_rzx_free( rzx ); + [[DisplayOpenGLView instance] rzxStartPlayback:recording]; free( recording ); Modified: trunk/fuse/fusepb/models/Emulator.h =================================================================== --- trunk/fuse/fusepb/models/Emulator.h 2013-12-25 23:59:06 UTC (rev 768) +++ trunk/fuse/fusepb/models/Emulator.h 2014-02-04 12:00:34 UTC (rev 769) @@ -65,6 +65,7 @@ -(id) init; -(void) openFile:(const char *)filename; +-(void) snapOpen:(const char *)filename; -(void) tapeOpen:(const char *)filename; -(void) tapeWrite:(const char *)filename; -(void) tapeTogglePlay; Modified: trunk/fuse/fusepb/models/Emulator.m =================================================================== --- trunk/fuse/fusepb/models/Emulator.m 2013-12-25 23:59:06 UTC (rev 768) +++ trunk/fuse/fusepb/models/Emulator.m 2014-02-04 12:00:34 UTC (rev 769) @@ -199,6 +199,13 @@ display_refresh_all(); } +-(void) snapOpen:(const char *)filename +{ + snapshot_read( filename ); + + display_refresh_all(); +} + -(void) tapeOpen:(const char *)filename { tape_open( filename, 0 ); @@ -513,7 +520,7 @@ -(int) rzxStartPlayback:(const char *)filename { - return rzx_start_playback( filename, 1 ); + return rzx_start_playback( filename, 0 ); } -(void) rzxInsertSnap Modified: trunk/fuse/fusepb/views/DisplayOpenGLView.h =================================================================== --- trunk/fuse/fusepb/views/DisplayOpenGLView.h 2013-12-25 23:59:06 UTC (rev 768) +++ trunk/fuse/fusepb/views/DisplayOpenGLView.h 2014-02-04 12:00:34 UTC (rev 769) @@ -100,6 +100,7 @@ -(void) setNeedsDisplayYes; -(void) openFile:(const char *)filename; +-(void) snapOpen:(const char *)filename; -(void) tapeOpen:(const char *)filename; -(void) tapeWrite:(const char *)filename; -(void) tapeTogglePlay; Modified: trunk/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- trunk/fuse/fusepb/views/DisplayOpenGLView.m 2013-12-25 23:59:06 UTC (rev 768) +++ trunk/fuse/fusepb/views/DisplayOpenGLView.m 2014-02-04 12:00:34 UTC (rev 769) @@ -661,6 +661,11 @@ [proxy_emulator openFile:filename]; } +-(void) snapOpen:(const char *)filename +{ + [proxy_emulator snapOpen:filename]; +} + -(void) tapeOpen:(const char *)filename { [proxy_emulator tapeOpen:filename]; Modified: trunk/fuse/rzx.h =================================================================== --- trunk/fuse/rzx.h 2013-12-25 23:59:06 UTC (rev 768) +++ trunk/fuse/rzx.h 2014-02-04 12:00:34 UTC (rev 769) @@ -84,4 +84,6 @@ GSList* rzx_get_rollback_list( libspectrum_rzx *rzx ); +libspectrum_snap* rzx_get_initial_snapshot( void ); + #endif /* #ifndef FUSE_RZX_H */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |