[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [294] branches/fusegl/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2007-01-20 14:43:22
|
Revision: 294 http://svn.sourceforge.net/fuse-for-macosx/?rev=294&view=rev Author: fredm Date: 2007-01-20 06:43:22 -0800 (Sat, 20 Jan 2007) Log Message: ----------- * Move emulation object to it's own thread and call main thread methods with performSelectorOnMainThread:withObject:waitUntilDone:, call emulation thread methods with DO when emulation is not paused, this should avoid sound glitches when menus are selected or window is minimised * Fix screen updating during fastloading * Make sure that fuse_end is called somewhere on exit Modified Paths: -------------- branches/fusegl/fuse/TODO branches/fusegl/fuse/display.c branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj branches/fusegl/fuse/fusepb/FuseMenus.h branches/fusegl/fuse/fusepb/FuseMenus.m branches/fusegl/fuse/fusepb/controllers/DebuggerController.m branches/fusegl/fuse/fusepb/controllers/FuseController.h branches/fusegl/fuse/fusepb/controllers/FuseController.m branches/fusegl/fuse/fusepb/controllers/LoadBinaryController.m branches/fusegl/fuse/fusepb/controllers/MemoryBrowserController.m branches/fusegl/fuse/fusepb/controllers/PokeFinderController.m branches/fusegl/fuse/fusepb/controllers/PreferencesController.m branches/fusegl/fuse/fusepb/controllers/RollbackController.m branches/fusegl/fuse/fusepb/controllers/SaveBinaryController.m branches/fusegl/fuse/fusepb/controllers/TapeBrowserController.m branches/fusegl/fuse/fusepb/models/Emulator.h branches/fusegl/fuse/fusepb/models/Emulator.m branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m branches/fusegl/fuse/settings.pl branches/fusegl/fuse/ui/cocoa/cocoaui.m Added Paths: ----------- branches/fusegl/fuse/ui/cocoa/cocoadisplay.m Removed Paths: ------------- branches/fusegl/fuse/ui/cocoa/cocoadisplay.c Modified: branches/fusegl/fuse/TODO =================================================================== --- branches/fusegl/fuse/TODO 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/TODO 2007-01-20 14:43:22 UTC (rev 294) @@ -15,17 +15,18 @@ X Add support for bilinear etc. OpenGL filters X Add option to snap window size to 1x, 2x, 3x X Grab mouse in fullscreen mode -X Vend FuseController and DisplayOpenGLView -X Move emulation to it's own object and vend it -* Move emulation to it's own thread and call FuseController and DisplayOpenGLView - through their vended objects -* Use sheets rather than modal dialogs -* Run emulation in seperate thread to avoid sound glitches when menus are - selected or window is minimised +X Move emulation to it's own object +X Move emulation object to it's own thread and call main thread methods with + performSelectorOnMainThread:withObject:waitUntilDone:, call emulation thread + methods with DO when emulation is not paused, this should avoid sound glitches + when menus are selected or window is minimised +X Fix screen updating during fastloading +X Make sure that fuse_end is called somewhere on exit +* Use screenshot style code for minimise icon rather than reading out of GL texture * Restore activity icons * Add native joystick processing (removes SDL joystick input dependency from Fuse) -* Fix screen updating during fastloading +* Use sheets rather than modal dialogs (for Save As) * Put in latest hq[23]x filters (HQ2x_555 from ScummVM should do the trick) * Make border display optional * Quit keyhandling when command key is pressed Modified: branches/fusegl/fuse/display.c =================================================================== --- branches/fusegl/fuse/display.c 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/display.c 2007-01-20 14:43:22 UTC (rev 294) @@ -641,7 +641,7 @@ critical_region_x = beam_x; } -static void +inline static void get_beam_position( int *x, int *y ) { if( tstates < machine_current->line_times[ 0 ] ) { @@ -655,8 +655,8 @@ *x = ( tstates - machine_current->line_times[ *y ] ) / 4; } -void -display_update_critical( int x, int y ) +inline static void +update_critical_internal( int x, int y ) { int beam_x, beam_y; @@ -683,9 +683,15 @@ copy_critical_region( beam_x, beam_y ); } +void +display_update_critical( int x, int y ) +{ + update_critical_internal( x, y ); +} + /* Mark the 8-pixel chunk at (x,y) as maybe dirty and update the critical region as appropriate */ -static void +inline static void display_dirty_chunk( int x, int y ) { /* If the write is between the start of the critical region and the @@ -693,7 +699,7 @@ if( y > critical_region_y || ( y == critical_region_y && x >= critical_region_x ) ) { - display_update_critical( x, y ); + update_critical_internal( x, y ); } display_maybe_dirty[y] |= ( (libspectrum_dword)1 << x ); Modified: branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj =================================================================== --- branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2007-01-20 14:43:22 UTC (rev 294) @@ -273,7 +273,7 @@ B6A6F1200B3EA737000B88E9 /* cocoascreenshot.m in Sources */ = {isa = PBXBuildFile; fileRef = B6A6F11E0B3EA737000B88E9 /* cocoascreenshot.m */; }; B6B076B20B59FE9A00D4F95C /* Emulator.h in Headers */ = {isa = PBXBuildFile; fileRef = B6B076B00B59FE9A00D4F95C /* Emulator.h */; }; B6B076B30B59FE9A00D4F95C /* Emulator.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B076B10B59FE9A00D4F95C /* Emulator.m */; }; - B6CE7F400B2830A300EB65B3 /* cocoadisplay.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3A0B2830A300EB65B3 /* cocoadisplay.c */; }; + B6B99F8A0B5F798700EE408F /* cocoadisplay.m in Sources */ = {isa = PBXBuildFile; fileRef = B6B99F890B5F798700EE408F /* cocoadisplay.m */; }; B6CE7F410B2830A300EB65B3 /* cocoadisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */; }; B6CE7F420B2830A300EB65B3 /* cocoajoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */; }; B6CE7F440B2830A300EB65B3 /* cocoaui.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7F3E0B2830A300EB65B3 /* cocoaui.h */; }; @@ -486,6 +486,7 @@ B6AF242A04156EE700F48F48 /* blank.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = blank.icns; path = resources/blank.icns; sourceTree = SOURCE_ROOT; }; B6B076B00B59FE9A00D4F95C /* Emulator.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Emulator.h; sourceTree = "<group>"; }; B6B076B10B59FE9A00D4F95C /* Emulator.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = Emulator.m; sourceTree = "<group>"; }; + B6B99F890B5F798700EE408F /* cocoadisplay.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = cocoadisplay.m; sourceTree = "<group>"; }; B6BA1A8B04E4F3290017354F /* gcrypt.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = gcrypt.framework; path = ../../libgcrypt/build/Deployment/gcrypt.framework; sourceTree = SOURCE_ROOT; }; B6BA1A9404E4F88F0017354F /* uijoystick.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = uijoystick.h; path = ../ui/uijoystick.h; sourceTree = SOURCE_ROOT; }; B6BA6F0207B1E04200E44C8D /* Preferences.nib */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Preferences.nib; path = nibs/Preferences.nib; sourceTree = "<group>"; }; @@ -503,7 +504,6 @@ B6CC82FF0800E408006EFFB9 /* CAMachines.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CAMachines.h; path = content_arrays/CAMachines.h; sourceTree = SOURCE_ROOT; }; B6CC83000800E408006EFFB9 /* CAMachines.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = CAMachines.m; path = content_arrays/CAMachines.m; sourceTree = SOURCE_ROOT; }; B6CD0B9E06069F4A00847338 /* fuse.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = fuse.cpp; path = ../fuse.cpp; sourceTree = SOURCE_ROOT; }; - B6CE7F3A0B2830A300EB65B3 /* cocoadisplay.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = cocoadisplay.c; sourceTree = "<group>"; }; B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cocoadisplay.h; sourceTree = "<group>"; }; B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = cocoajoystick.c; sourceTree = "<group>"; }; B6CE7F3E0B2830A300EB65B3 /* cocoaui.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cocoaui.h; sourceTree = "<group>"; }; @@ -918,8 +918,8 @@ B6CE7E8A0B28027000EB65B3 /* cocoa */ = { isa = PBXGroup; children = ( - B6CE7F3A0B2830A300EB65B3 /* cocoadisplay.c */, B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */, + B6B99F890B5F798700EE408F /* cocoadisplay.m */, B6A6F10D0B3D6360000B88E9 /* cocoaerror.m */, B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */, B6A6F11D0B3EA737000B88E9 /* cocoascreenshot.h */, @@ -1467,7 +1467,6 @@ B64E29FE0A65337A006863D9 /* NSString+CarbonFSRefCreation.m in Sources */, B64E2A020A6533FD006863D9 /* thumbnail.m in Sources */, B6403FD80A7E4B1A00E00B11 /* loader.c in Sources */, - B6CE7F400B2830A300EB65B3 /* cocoadisplay.c in Sources */, B6CE7F420B2830A300EB65B3 /* cocoajoystick.c in Sources */, B6CE7F520B283A0700EB65B3 /* main.mm in Sources */, B6CE7FCE0B28FBD600EB65B3 /* DisplayOpenGLView.m in Sources */, @@ -1481,6 +1480,7 @@ B6A24E3B0B49C78700AD5B9D /* hq2x.cpp in Sources */, B6A24E3D0B49C78700AD5B9D /* hq3x.cpp in Sources */, B6B076B30B59FE9A00D4F95C /* Emulator.m in Sources */, + B6B99F8A0B5F798700EE408F /* cocoadisplay.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: branches/fusegl/fuse/fusepb/FuseMenus.h =================================================================== --- branches/fusegl/fuse/fusepb/FuseMenus.h 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/FuseMenus.h 2007-01-20 14:43:22 UTC (rev 294) @@ -30,19 +30,6 @@ #include "ui/cocoa/cocoadisplay.h" -void CreateTexture(Cocoa_Texture*); -void DestroyTexture(void); void SetEmulationHz(float); -void Hide(void); -void Open(void); -void SaveAs(void); -void Minimise(void); -void Help(void); -void Keyboard(void); -void TapePlay(void); -void RzxInsertSnap(void); -void RzxRollback(void); -void Preferences(void); - #endif /* #ifndef FUSEMENUS_H */ Modified: branches/fusegl/fuse/fusepb/FuseMenus.m =================================================================== --- branches/fusegl/fuse/fusepb/FuseMenus.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/FuseMenus.m 2007-01-20 14:43:22 UTC (rev 294) @@ -27,97 +27,11 @@ */ -#import "DisplayOpenGLView.h" #import "Emulator.h" #import "FuseController.h" #import "FuseMenus.h" -/* Definition of Mac native keycodes for characters used as menu shortcuts that - bring up a window. */ -#define QZ_m 0x2E -#define QZ_s 0x01 -#define QZ_h 0x04 -#define QZ_SLASH 0x2C -#define QZ_f 0x03 -#define QZ_o 0x1F -#define QZ_p 0x23 -#define QZ_b 0x0b -#define QZ_r 0x0f -#define QZ_k 0x28 -#define QZ_COMMA 0x2B - -void -CreateTexture(Cocoa_Texture* new_screen) -{ - [[DisplayOpenGLView instance] createTexture:new_screen]; -} - -void DestroyTexture(void) -{ - [[DisplayOpenGLView instance] destroyTexture]; -} - void SetEmulationHz( float hz ) { [[Emulator instance] setEmulationHz:hz]; } - -void Hide(void) -{ - [NSApp hide:[FuseController singleton]]; - [[FuseController singleton] releaseCmdKeys:@"h":QZ_h]; -} - -void Open(void) -{ - [[FuseController singleton] open:nil]; - [[FuseController singleton] releaseCmdKeys:@"o":QZ_o]; -} - -void SaveAs(void) -{ - [[FuseController singleton] save_as:nil]; - [[FuseController singleton] releaseCmdKeys:@"s":QZ_s]; -} - -void Minimise(void) -{ - [[NSApp keyWindow] performMiniaturize:[FuseController singleton]]; - [[FuseController singleton] releaseCmdKeys:@"m":QZ_m]; -} - -void Help(void) -{ - [NSApp showHelp:[FuseController singleton]]; - [[FuseController singleton] releaseCmdKeys:@"?":QZ_SLASH]; -} - -void Keyboard(void) -{ - [[FuseController singleton] showKeyboardPane:nil]; - [[FuseController singleton] releaseCmdKeys:@"k":QZ_k]; -} - -void TapePlay(void) -{ - [[FuseController singleton] tape_play:nil]; - [[FuseController singleton] releaseCmdKeys:@"p":QZ_p]; -} - -void RzxInsertSnap(void) -{ - [[FuseController singleton] rzx_insert_snap:nil]; - [[FuseController singleton] releaseCmdKeys:@"b":QZ_b]; -} - -void RzxRollback(void) -{ - [[FuseController singleton] rzx_rollback:nil]; - [[FuseController singleton] releaseCmdKeys:@"r":QZ_r]; -} - -void Preferences(void) -{ - [[FuseController singleton] showPreferencesPane:nil]; - [[FuseController singleton] releaseCmdKeys:@",":QZ_COMMA]; -} Modified: branches/fusegl/fuse/fusepb/controllers/DebuggerController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/DebuggerController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/DebuggerController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -25,6 +25,7 @@ */ #import "DebuggerController.h" +#import "DisplayOpenGLView.h" #include <config.h> @@ -163,7 +164,7 @@ - (void)debugger_activate:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; [singleton showWindow:nil]; @@ -623,7 +624,7 @@ { [NSApp stopModal]; debugger_active = 0; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; return 0; } Modified: branches/fusegl/fuse/fusepb/controllers/FuseController.h =================================================================== --- branches/fusegl/fuse/fusepb/controllers/FuseController.h 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/FuseController.h 2007-01-20 14:43:22 UTC (rev 294) @@ -128,8 +128,6 @@ - (IBAction)saveFileTypeClicked:(id)sender; -- (id)installServer; - - savePanelAccessoryView; - (NSPopUpButton*) saveFileType; @@ -148,12 +146,13 @@ - (void)ui_menu_activate_media_ide_simple8bit:(int)active; - (void)ui_menu_activate_media_ide_zxatasp:(int)active; - (void)ui_menu_activate_media_ide_zxcf:(int)active; -- (int)ui_statusbar_update_speed:(float)speed; -- (void)openFile:(char *)filename; +- (void)openFile:(const char *)filename; - (void)openRecent:(id)sender; +- (void)addRecentSnapshotWithString:(NSString*)file; - (void)addRecentSnapshot:(const char *)filename; - (void)clearRecentSnapshots; +- (void)setTitle:(NSString*)title; - (void)openDisk:(specplus3_drive_number)drive; Modified: branches/fusegl/fuse/fusepb/controllers/FuseController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/FuseController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/FuseController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -40,6 +40,8 @@ #import "SaveBinaryController.h" #import "TapeBrowserController.h" +#import "DisplayOpenGLView.h" + #include "dck.h" #include "debugger/debugger.h" #include "divide.h" @@ -141,22 +143,6 @@ return singleton ? singleton : [[self alloc] init]; } -- (id)installServer -{ - NSConnection *theConnection; - theConnection = [NSConnection defaultConnection]; - NSLog(@"Creating connection..."); - - [theConnection setRootObject:self]; - if ([theConnection registerName:@"FuseControllerSvr"] == NO) { - NSLog(@"FuseController failed to register name\n"); - } - - [theConnection retain]; - NSLog(@"done.\n"); - return self; -} - - (id)init { if ( singleton ) { @@ -228,8 +214,6 @@ recentSnapFileNames = [NSMutableArray arrayWithCapacity:NUM_RECENT_ITEMS]; [recentSnapFileNames retain]; - - [self installServer]; } return singleton; @@ -270,11 +254,11 @@ int error; char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_openpanel_get_filename( @"Insert Timex dock cartridge", dckFileTypes ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } error = dck_insert( filename ); if(error) goto error; @@ -284,16 +268,16 @@ error: free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)dock_eject:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; dck_eject(); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)if2_open:(id)sender @@ -301,11 +285,11 @@ int error; char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_openpanel_get_filename( @"Insert Interface II cartridge", romFileTypes ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } error = if2_insert( filename ); if(error) goto error; @@ -315,16 +299,16 @@ error: free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)if2_eject:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; if2_eject(); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)ide_insert:(id)sender @@ -332,11 +316,11 @@ int error=0; char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_openpanel_get_filename( @"Insert hard disk file", ideFileTypes ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } switch( [sender tag] ) { case 41: error = simpleide_insert( filename, LIBSPECTRUM_IDE_MASTER ); break; @@ -355,12 +339,12 @@ error: free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)ide_commit:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; switch( [sender tag] ) { case 51: simpleide_commit( LIBSPECTRUM_IDE_MASTER ); break; @@ -372,7 +356,7 @@ case 57: divide_commit( LIBSPECTRUM_IDE_SLAVE ); break; } - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)ide_eject:(id)sender @@ -397,10 +381,10 @@ { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_openpanel_get_filename( @"Insert microdrive disk file", mdrFileTypes ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } if1_mdr_insert( filename, [sender tag] - 30 ); @@ -408,7 +392,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)mdr_commit:(id)sender @@ -417,10 +401,10 @@ if( !if1_mdr_sync( NULL, [sender tag] - 30 ) ) return; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_savepanel_get_filename( @"Write Microdrive Cartridge As", [NSArray arrayWithObjects:@"mdr", nil] ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } if1_mdr_sync( filename, [sender tag] - 30 ); @@ -428,7 +412,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)mdr_eject:(id)sender @@ -437,10 +421,10 @@ if( !if1_mdr_eject( NULL, [sender tag] - 30 ) ) return; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_savepanel_get_filename( @"Write Microdrive Cartridge As", [NSArray arrayWithObjects:@"mdr", nil] ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } if1_mdr_eject( filename, [sender tag] - 30 ); @@ -448,7 +432,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)mdr_writep:(id)sender @@ -462,11 +446,11 @@ { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_openpanel_get_filename( @"Open Spectrum File", allFileTypes ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } [self addRecentSnapshot:filename]; @@ -474,28 +458,28 @@ free(filename); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)reset:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; machine_reset(); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)nmi:(id)sender { int error; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; error = event_add( 0, EVENT_TYPE_NMI ); /* Complain if( error ) return error; */ - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)rzx_play:(id)sender @@ -504,11 +488,11 @@ if( rzx_playback || rzx_recording ) return; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; recording = cocoaui_openpanel_get_filename( @"Start Replay", rzxFileTypes ); - if( !recording ) { fuse_emulation_unpause(); return; } + if( !recording ) { [[DisplayOpenGLView instance] unpause]; return; } [self addRecentSnapshot:recording]; @@ -520,7 +504,7 @@ ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)rzx_insert_snap:(id)sender @@ -550,18 +534,18 @@ if( !rzx_recording ) return; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; error = libspectrum_rzx_rollback( rzx, &snap ); - if( error ) { fuse_emulation_unpause(); return; } + if( error ) { [[DisplayOpenGLView instance] unpause]; return; } error = snapshot_copy_from( snap ); - if( error ) { fuse_emulation_unpause(); return; } + if( error ) { [[DisplayOpenGLView instance] unpause]; return; } error = libspectrum_rzx_start_input( rzx, tstates ); - if( error ) { fuse_emulation_unpause(); return; } + if( error ) { [[DisplayOpenGLView instance] unpause]; return; } - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)rzx_start:(id)sender @@ -570,10 +554,10 @@ if( rzx_playback || rzx_recording ) return; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; recording = cocoaui_savepanel_get_filename( @"Start Recording", [NSArray arrayWithObjects:@"rzx", nil] ); - if( !recording ) { fuse_emulation_unpause(); return; } + if( !recording ) { [[DisplayOpenGLView instance] unpause]; return; } rzx_start_recording( recording, 1 ); @@ -581,7 +565,7 @@ ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)rzx_start_snap:(id)sender @@ -590,16 +574,16 @@ if( rzx_playback || rzx_recording ) return; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; snap = cocoaui_openpanel_get_filename( @"Load Snapshot", snapFileTypes ); - if( !snap ) { fuse_emulation_unpause(); return; } + if( !snap ) { [[DisplayOpenGLView instance] unpause]; return; } recording = cocoaui_savepanel_get_filename( @"Start Recording", [NSArray arrayWithObjects:@"rzx", nil] ); - if( !recording ) { free( snap ); fuse_emulation_unpause(); return; } + if( !recording ) { free( snap ); [[DisplayOpenGLView instance] unpause]; return; } if( snapshot_read( snap ) ) { - free( snap ); free( recording ); fuse_emulation_unpause(); return; + free( snap ); free( recording ); [[DisplayOpenGLView instance] unpause]; return; } rzx_start_recording( recording, settings_current.embed_snapshot ); @@ -610,7 +594,7 @@ ui_menu_activate( UI_MENU_ITEM_RECORDING, 1 ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)rzx_stop:(id)sender @@ -627,10 +611,10 @@ if( psg_recording ) return; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; psgfile = cocoaui_savepanel_get_filename( @"Start AY Sound Recording", [NSArray arrayWithObjects:@"psg", nil] ); - if( !psgfile ) { fuse_emulation_unpause(); return; } + if( !psgfile ) { [[DisplayOpenGLView instance] unpause]; return; } psg_start_recording( psgfile ); @@ -640,7 +624,7 @@ ui_menu_activate( UI_MENU_ITEM_AY_LOGGING, 1 ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)psg_stop:(id)sender @@ -655,11 +639,11 @@ { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_savepanel_get_filename( @"Save Snapshot As", [NSArray arrayWithObjects:@"szx", @"z80", @"sna", nil] ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } snapshot_write( filename ); @@ -670,18 +654,18 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)open_screen:(id)sender { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_openpanel_get_filename( @"Open SCR Screenshot", scrFileType ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } screenshot_scr_read( filename ); @@ -691,7 +675,7 @@ display_refresh_all(); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)profiler_start:(id)sender @@ -703,27 +687,27 @@ { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_savepanel_get_filename( @"Save Profile Data As", [NSArray arrayWithObjects:@"profile", nil] ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } profile_finish( filename ); free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)save_screen:(id)sender { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_savepanel_get_filename( @"Save Screenshot As", [NSArray arrayWithObjects:@"scr", nil] ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } screenshot_scr_write( filename ); @@ -734,18 +718,18 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)export_screen:(id)sender { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_savepanel_get_filename( @"Export Screenshot", [NSArray arrayWithObjects:@"png", @"tiff", @"bmp", @"jpg", @"gif", nil] ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } screenshot_write( filename ); @@ -754,7 +738,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)save_options:(id)sender @@ -787,11 +771,11 @@ { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_openpanel_get_filename( @"Open Tape", tapeFileTypes ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } tape_open_default_autoload( filename, NULL ); @@ -799,7 +783,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (IBAction)tape_play:(id)sender @@ -1042,13 +1026,6 @@ [if1 setEnabled:active == 0 ? NO : YES]; } -- (int)ui_statusbar_update_speed:(float)speed -{ - [window setTitle:[NSString stringWithFormat:@"Fuse - %3.0f%%", speed]]; - - return 0; -} - - (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem { switch( [menuItem tag] ) { @@ -1140,13 +1117,11 @@ } } -- (void)openFile:(char *)filename +- (void)openFile:(const char *)filename { - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } - utils_open_file( filename, settings_current.auto_load, NULL ); - - display_refresh_all(); + [[DisplayOpenGLView instance] openFile:filename]; } - (void)openRecent:(id)fileMenu @@ -1159,11 +1134,11 @@ [self addRecentSnapshot:filename]; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; [self openFile:filename]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)generateUniqueLabels:(NSString *)filename @@ -1229,14 +1204,13 @@ } } -- (void)addRecentSnapshot:(const char *)filename +- (void)addRecentSnapshotWithString:(NSString*)file { NSMenuItem *menuItem; - NSString *file = [NSString stringWithUTF8String:filename]; NSFileManager *manager = [NSFileManager defaultManager]; /* We only work with absolute paths */ - if(*filename != '/') return; + if([file characterAtIndex:0] != '/') return; if(![manager fileExistsAtPath:file]) return; @@ -1278,6 +1252,12 @@ } } +- (void)addRecentSnapshot:(const char *)filename +{ + NSString *file = [NSString stringWithUTF8String:filename]; + [self addRecentSnapshotWithString:file]; +} + - (void)clearRecentSnapshots { int numMenuItems = [recentSnaps numberOfItems]; @@ -1289,12 +1269,17 @@ [recentSnapFileNames removeAllObjects]; } +- (void)setTitle:(NSString*)title +{ + [window setTitle:title]; +} + - (void)openDisk:(specplus3_drive_number)drive { char *filename = NULL; NSArray *fileTypes; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; if( machine_current->machine == LIBSPECTRUM_MACHINE_PLUS3 ) { fileTypes = plus3FileTypes; @@ -1307,7 +1292,7 @@ @"Insert disk into drive B:" ), fileTypes ); - if( !filename ) { fuse_emulation_unpause(); return; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return; } [self addRecentSnapshot:filename]; @@ -1319,7 +1304,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)setTapePlayMenu:(ui_statusbar_state)state @@ -1486,11 +1471,13 @@ static void cocoaui_disk_eject( specplus3_drive_number drive, int write ) { + [[DisplayOpenGLView instance] pause]; if( machine_current->machine == LIBSPECTRUM_MACHINE_PLUS3 ) { specplus3_disk_eject( drive, write ); } else { trdos_disk_eject( drive, write ); } + [[DisplayOpenGLView instance] unpause]; } int @@ -1681,11 +1668,11 @@ { char *filename = NULL; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; filename = cocoaui_savepanel_get_filename( @"Write Tape As", [NSArray arrayWithObjects:@"tzx", @"tap", nil] ); - if( !filename ) { fuse_emulation_unpause(); return 1; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return 1; } tape_write( filename ); @@ -1693,7 +1680,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; return 0; } @@ -1710,12 +1697,12 @@ return 0; } - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; NSString *title = [NSString stringWithFormat:@"Write +3 Disk %c: As", drive]; filename = cocoaui_savepanel_get_filename( title, [NSArray arrayWithObjects:@"dsk", nil] ); - if( !filename ) { fuse_emulation_unpause(); return 1; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return 1; } specplus3_disk_write( which, filename ); @@ -1723,7 +1710,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; return 0; } @@ -1741,12 +1728,12 @@ default: drive = '?'; break; } - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; NSString *title = [NSString stringWithFormat:@"Write TR-DOS Disk %c: As", drive]; filename = cocoaui_savepanel_get_filename( title, [NSArray arrayWithObjects:@"trd", nil] ); - if( !filename ) { fuse_emulation_unpause(); return 1; } + if( !filename ) { [[DisplayOpenGLView instance] unpause]; return 1; } trdos_disk_write( which, filename ); @@ -1754,7 +1741,7 @@ free( filename ); - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; return 0; } @@ -1771,7 +1758,7 @@ if( ui_mouse_grabbed ) ui_mouse_grabbed = ui_mouse_release( 1 ); - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; confirm = UI_CONFIRM_SAVE_CANCEL; @@ -1790,7 +1777,7 @@ confirm = UI_CONFIRM_SAVE_CANCEL; } - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; return confirm; } @@ -1851,7 +1838,7 @@ if( ui_mouse_grabbed ) ui_mouse_grabbed = ui_mouse_release( 1 ); - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; confirm = UI_CONFIRM_JOYSTICK_NONE; @@ -1872,7 +1859,7 @@ [alert release]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; return confirm; } @@ -1887,14 +1874,14 @@ if( ui_mouse_grabbed ) ui_mouse_grabbed = ui_mouse_release( 1 ); - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; NSString *m = [NSString stringWithUTF8String:message]; result = NSRunAlertPanel(@"Confirm", m, @"OK", @"Cancel", nil); if( result == NSAlertDefaultReturn ) confirm = 1; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; return confirm; } Modified: branches/fusegl/fuse/fusepb/controllers/LoadBinaryController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/LoadBinaryController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/LoadBinaryController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -27,9 +27,9 @@ #include <config.h> #import "LoadBinaryController.h" +#import "DisplayOpenGLView.h" #import "NumberFormatter.h" -#include "fuse.h" #include "memory.h" #include "spectrum.h" #include <libspectrum.h> @@ -93,12 +93,12 @@ [NSApp stopModal]; [[self window] close]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)showWindow:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; [super showWindow:sender]; Modified: branches/fusegl/fuse/fusepb/controllers/MemoryBrowserController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/MemoryBrowserController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/MemoryBrowserController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -26,7 +26,8 @@ #import "MemoryBrowserController.h" -#include "fuse.h" +#import "DisplayOpenGLView.h" + #include "memory.h" @implementation MemoryBrowserController @@ -67,7 +68,7 @@ [memoryBrowser reloadData]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)showWindow:(id)sender @@ -76,7 +77,7 @@ NSString *address; NSMutableString *hex, *data; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; tableContents = [NSMutableArray arrayWithCapacity:0xfff]; Modified: branches/fusegl/fuse/fusepb/controllers/PokeFinderController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/PokeFinderController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/PokeFinderController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -28,6 +28,7 @@ #import "NumberFormatter.h" #import "PokeFinderController.h" +#import "DisplayOpenGLView.h" #include "fuse.h" #include "debugger/debugger.h" @@ -112,12 +113,12 @@ [matchList reloadData]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)showWindow:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; [super showWindow:sender]; Modified: branches/fusegl/fuse/fusepb/controllers/PreferencesController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/PreferencesController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/PreferencesController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -114,7 +114,7 @@ - (void)showWindow:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; /* Values in Fuse may have been updated, put them in saved settings */ settings_write_config( &settings_current ); @@ -166,11 +166,7 @@ fuse_joystick_end(); fuse_joystick_init(); - fuse_emulation_unpause(); - - /* If we've enabled sound we want to put some data in the buffers before - too long to avoid glitches */ - if( sound_enabled ) [[DisplayOpenGLView instance] updateEmulationForTimeDelta:0]; + [[DisplayOpenGLView instance] unpause]; } - (IBAction)chooseFile:(id)sender Modified: branches/fusegl/fuse/fusepb/controllers/RollbackController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/RollbackController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/RollbackController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -28,10 +28,11 @@ #import "RollbackController.h" +#import "DisplayOpenGLView.h" + #include "machine.h" #include "rzx.h" #include "snapshot.h" -#include "fuse.h" static void add_point_details( gpointer data, void *user_data ); @@ -93,12 +94,12 @@ [NSApp stopModal]; [[self window] close]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)showWindow:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; [super showWindow:sender]; Modified: branches/fusegl/fuse/fusepb/controllers/SaveBinaryController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/SaveBinaryController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/SaveBinaryController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -27,9 +27,9 @@ #include <config.h> #import "SaveBinaryController.h" +#import "DisplayOpenGLView.h" #import "NumberFormatter.h" -#include "fuse.h" #include "memory.h" #include "spectrum.h" #include <libspectrum.h> @@ -97,12 +97,12 @@ [NSApp stopModal]; [[self window] close]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)showWindow:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; [super showWindow:sender]; Modified: branches/fusegl/fuse/fusepb/controllers/TapeBrowserController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/TapeBrowserController.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/controllers/TapeBrowserController.m 2007-01-20 14:43:22 UTC (rev 294) @@ -26,6 +26,7 @@ #include <config.h> +#import "DisplayOpenGLView.h" #import "TapeBrowserController.h" #include "tape.h" @@ -93,20 +94,20 @@ - (void)showWindow:(id)sender { - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; [super showWindow:sender]; [self update:UI_TAPE_BROWSER_NEW_TAPE block:NULL]; - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (void)update:(ui_tape_browser_update_type)change block:(libspectrum_tape_block *)block { int error; - fuse_emulation_pause(); + [[DisplayOpenGLView instance] pause]; if( change == UI_TAPE_BROWSER_NEW_TAPE ) { [tapeController removeObjects:[tapeController arrangedObjects]]; @@ -136,7 +137,7 @@ [[self window] setDocumentEdited:NO]; } - fuse_emulation_unpause(); + [[DisplayOpenGLView instance] unpause]; } - (NSArrayController *)tapeController Modified: branches/fusegl/fuse/fusepb/models/Emulator.h =================================================================== --- branches/fusegl/fuse/fusepb/models/Emulator.h 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/models/Emulator.h 2007-01-20 14:43:22 UTC (rev 294) @@ -30,7 +30,10 @@ @interface Emulator : NSObject { + BOOL isEmulating; NSTimer* timer; + CFAbsoluteTime time; + float timerInterval; GHashTable *unicode_keysyms_hash; @@ -41,21 +44,29 @@ int cocoakeyboard_caps_shift_pressed; int cocoakeyboard_symbol_shift_pressed; input_key unicode_keysym; - - CFAbsoluteTime time; } +(Emulator *) instance; -- (id)installServer; +-(void) connectWithPorts:(NSArray *)portArray; +-(void) stop; +-(BOOL) isEmulating; + +-(void) startEmulationTimer; +-(void) stopEmulationTimer; + -(void) updateEmulation:(NSTimer*)theTimer; -(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime; -(void) setEmulationHz:(float)hz; -/* FIXME: Could do with a setSettings? maybe we just update when paused? */ -/* probably means we need a pause and unpause method here */ +/* FIXME: Could do with a setSettings? maybe we just update settings when + emulation is paused? */ -(id) init; +-(void) openFile:(const char *)filename; +-(void) pause; +-(void) unpause; + -(void) mouseMoved:(NSEvent *)theEvent; -(void) mouseDown:(NSEvent *)theEvent; -(void) mouseUp:(NSEvent *)theEvent; Modified: branches/fusegl/fuse/fusepb/models/Emulator.m =================================================================== --- branches/fusegl/fuse/fusepb/models/Emulator.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/models/Emulator.m 2007-01-20 14:43:22 UTC (rev 294) @@ -33,6 +33,7 @@ #include "settings.h" #include "sound.h" #include "ui/ui.h" +#include "utils.h" extern keysyms_map_t unicode_keysyms_map[]; @@ -49,22 +50,44 @@ return instance; } -- (id)installServer +-(void) connectWithPorts:(NSArray *)portArray { - NSConnection *theConnection; - theConnection = [NSConnection defaultConnection]; - NSLog(@"Creating connection..."); + NSAutoreleasePool *pool; + NSConnection *serverConnection; - [theConnection setRootObject:self]; - if ([theConnection registerName:@"EmulatorSvr"] == NO) { - NSLog(@"Emulator failed to register name\n"); + pool = [[NSAutoreleasePool alloc] init]; + + serverConnection = [NSConnection + connectionWithReceivePort:[portArray objectAtIndex:0] + sendPort:[portArray objectAtIndex:1]]; + [serverConnection setRootObject:self]; + [(id)[serverConnection rootProxy] setServer:self]; + + if( fuse_init( ac, av ) ) { + fprintf( stderr, "%s: error initialising -- giving up!\n", fuse_progname ); } - [theConnection retain]; - NSLog(@"done.\n"); - return self; + while( !fuse_exiting ) { + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode + beforeDate:[NSDate distantFuture]]; + } + + [serverConnection invalidate]; + + fuse_end(); + + instance = nil; + [pool release]; + + return; } +-(void) stop +{ + [self pause]; + fuse_exiting = 1; +} + -(id) init { if ( instance ) { @@ -74,12 +97,12 @@ self = [super init]; instance = self; - [self installServer]; - [self initKeyboard]; } timer = nil; + timerInterval = 1.0f / 50.0f; + isEmulating = NO; optDown = NO; ctrlDown = NO; @@ -102,7 +125,6 @@ [self updateEmulationForTimeDelta:deltaTime]; } time = nowTime; - [[DisplayOpenGLView instance] setNeedsDisplay:YES]; } /* given a delta time in seconds, update overall emulation state */ @@ -126,14 +148,64 @@ -(void) setEmulationHz:(float)hz { - [timer invalidate]; - [timer release]; + [self pause]; + /* Update emulation at double the emulated machines' frame rate for smoother + animation */ + hz = hz * 2.0f; + timerInterval = 1.0f / hz; + [self unpause]; +} - timer = [[NSTimer scheduledTimerWithTimeInterval: (1.0f / hz) - target:self selector:@selector(updateEmulation:) - userInfo:self repeats:true] retain]; +-(void) openFile:(const char *)filename +{ + utils_open_file( filename, settings_current.auto_load, NULL ); + + display_refresh_all(); } +-(void) pause +{ + if( isEmulating ) { + if( timer != nil ) { + [self stopEmulationTimer]; + fuse_emulation_pause(); + } + isEmulating = NO; + } +} + +-(void) unpause +{ + if( !isEmulating ) { + isEmulating = YES; + [self startEmulationTimer]; + fuse_emulation_unpause(); + } +} + +-(BOOL) isEmulating +{ + return isEmulating; +} + +-(void) startEmulationTimer +{ + if( timer == nil ) { + timer = [[NSTimer scheduledTimerWithTimeInterval: timerInterval + target:self selector:@selector(updateEmulation:) + userInfo:self repeats:true] retain]; + } +} + +-(void) stopEmulationTimer +{ + if( timer != nil ) { + [timer invalidate]; + [timer release]; + timer = nil; + } +} + -(void) mouseMoved:(NSEvent *)theEvent { if( ui_mouse_grabbed ) { Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2007-01-20 14:43:22 UTC (rev 294) @@ -43,12 +43,12 @@ float target_ratio; - Emulator *emulator; + Emulator *real_emulator; + Emulator *proxy_emulator; + NSConnection *kitConnection; } +(DisplayOpenGLView *) instance; -- (id)installServer; - -(IBAction) fullscreen:(id)sender; -(IBAction) zoom:(id)sender; @@ -57,9 +57,16 @@ -(void) createTexture:(Cocoa_Texture*)newScreen; -(void) destroyTexture; +-(void) setServer:(id)anObject; -(id) initWithFrame:(NSRect)frameRect; -(void) awakeFromNib; +-(void) setNeedsDisplayYes; + +-(void) openFile:(const char *)filename; +-(void) pause; +-(void) unpause; + -(void) mouseMoved:(NSEvent *)theEvent; -(void) mouseDown:(NSEvent *)theEvent; -(void) mouseUp:(NSEvent *)theEvent; Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2007-01-20 14:43:22 UTC (rev 294) @@ -29,11 +29,6 @@ #include <OpenGL/glext.h> #include <OpenGL/glu.h> -#if 0 -#include "event.h" -#include "keyboard.h" -#include "sound.h" -#endif #include "fuse.h" #include "fusepb/main.h" #include "settings.h" @@ -49,14 +44,15 @@ -(IBAction) fullscreen:(id)sender { - if( settings_current.full_screen == 1 ) { // we need to go back to non-full screen + if( settings_current.full_screen == 1 ) { + /* we need to go back to non-full screen */ [fullscreenWindow close]; [windowedWindow setContentView: self]; [windowedWindow makeKeyAndOrderFront: self]; [windowedWindow makeFirstResponder: self]; settings_current.full_screen = 0; if( ui_mouse_grabbed ) ui_mouse_grabbed = ui_mouse_release( 0 ); - } else { // settings_current.full_screen == 0 + } else { unsigned int windowStyle; NSRect contentRect; @@ -106,20 +102,9 @@ [[self window] setContentSize:size]; } -- (id)installServer +-(void)setServer:(id)anObject { - NSConnection *theConnection; - theConnection = [NSConnection defaultConnection]; - NSLog(@"Creating connection..."); - - [theConnection setRootObject:self]; - if ([theConnection registerName:@"DisplayOpenGLViewSvr"] == NO) { - NSLog(@"DisplayOpenGLView failed to register name\n"); - } - - [theConnection retain]; - NSLog(@"done.\n"); - return self; + proxy_emulator = [anObject retain]; } -(id) initWithFrame:(NSRect)frameRect @@ -146,9 +131,7 @@ self = [super initWithFrame:frameRect pixelFormat:pixFmt]; instance = self; - emulator = [[Emulator alloc] init]; - - [self installServer]; + real_emulator = [[Emulator alloc] init]; } [pixFmt release]; @@ -165,6 +148,22 @@ target_ratio = 4.0f/3.0f; + NSPort *port1; + NSPort *port2; + NSArray *portArray; + + port1 = [NSPort port]; + port2 = [NSPort port]; + + kitConnection = [[NSConnection alloc] initWithReceivePort:port1 sendPort:port2]; + [kitConnection setRootObject:self]; + + /* Ports switched here */ + portArray = [NSArray arrayWithObjects:port2, port1, nil]; + + [NSThread detachNewThreadSelector:@selector(connectWithPorts:) + toTarget:real_emulator withObject:portArray]; + return self; } @@ -172,13 +171,24 @@ { /* keep the window in the standard aspect ratio if the user resizes */ [[self window] setContentAspectRatio:NSMakeSize(4.0,3.0)]; +} - /* FIXME: Don't really like the argc, argv stuff being here... */ - if( fuse_init( ac, av ) ) { - fprintf( stderr, "%s: error initialising -- giving up!\n", fuse_progname ); - } +- (void)windowWillClose:(NSNotification *)notification +{ + [[self window] setDelegate:nil]; + [proxy_emulator stop]; + [proxy_emulator release]; + proxy_emulator = nil; + [real_emulator release]; + real_emulator = nil; + [self release]; } +-(void) setNeedsDisplayYes +{ + [super setNeedsDisplay:YES]; +} + -(void) drawRect:(NSRect)aRect { if( NO == screenTexInitialised ) return; @@ -330,7 +340,6 @@ glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_STORAGE_HINT_APPLE, GL_STORAGE_CACHED_APPLE ); glPixelStorei( GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE ); - /* FIXME: Want GL_NEAREST for exact pixel ratios, GL_LINEAR otherwise */ GLint filter = settings_current.bilinear_filter ? GL_LINEAR : GL_NEAREST; glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MIN_FILTER, filter ); glTexParameteri( GL_TEXTURE_RECTANGLE_EXT, GL_TEXTURE_MAG_FILTER, filter ); @@ -345,44 +354,59 @@ screenTexInitialised = YES; } +-(void) openFile:(const char *)filename +{ + [proxy_emulator openFile:filename]; +} + +-(void) pause +{ + [proxy_emulator pause]; +} + +-(void) unpause +{ + [proxy_emulator unpause]; +} + -(void) mouseMoved:(NSEvent *)theEvent { - [emulator mouseMoved:theEvent]; + [proxy_emulator mouseMoved:theEvent]; } -(void) mouseDown:(NSEvent *)theEvent { - [emulator mouseDown:theEvent]; + [proxy_emulator mouseDown:theEvent]; } -(void) mouseUp:(NSEvent *)theEvent { - [emulator mouseUp:theEvent]; + [proxy_emulator mouseUp:theEvent]; } -(void) rightMouseDown:(NSEvent *)theEvent { - [emulator rightMouseDown:theEvent]; + [proxy_emulator rightMouseDown:theEvent]; } -(void) rightMouseUp:(NSEvent *)theEvent { - [emulator rightMouseUp:theEvent]; + [proxy_emulator rightMouseUp:theEvent]; } -(void) otherMouseDown:(NSEvent *)theEvent { - [emulator otherMouseDown:theEvent]; + [proxy_emulator otherMouseDown:theEvent]; } -(void) otherMouseUp:(NSEvent *)theEvent { - [emulator otherMouseUp:theEvent]; + [proxy_emulator otherMouseUp:theEvent]; } -(void) flagsChanged:(NSEvent *)theEvent { - [emulator flagsChanged:theEvent]; + [proxy_emulator flagsChanged:theEvent]; } -(void) keyDown:(NSEvent *)theEvent @@ -390,19 +414,19 @@ if( settings_current.full_screen ) { unichar c = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; switch (c) { - // [Esc] exits fullScreen mode. + /* [Esc] exits fullScreen mode */ case 27: [self fullscreen:nil]; return; break; } } - [emulator keyDown:theEvent]; + [proxy_emulator keyDown:theEvent]; } -(void) keyUp:(NSEvent *)theEvent { - [emulator keyUp:theEvent]; + [proxy_emulator keyUp:theEvent]; } -(BOOL) acceptsFirstResponder @@ -425,7 +449,7 @@ return YES; } -- (void)copyGLToBackingStore +-(void) copyGLToBackingStore { [[self openGLContext] makeCurrentContext]; Modified: branches/fusegl/fuse/settings.pl =================================================================== --- branches/fusegl/fuse/settings.pl 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/settings.pl 2007-01-20 14:43:22 UTC (rev 294) @@ -243,7 +243,8 @@ id recentFile; while ( (recentFile = [enumerator nextObject]) ) { - [[FuseController singleton] addRecentSnapshot:[recentFile UTF8String]]; + [[FuseController singleton] performSelectorOnMainThread:\@selector(addRecentSnapshotWithString:) + withObject:recentFile waitUntilDone:NO]; } } CODE Deleted: branches/fusegl/fuse/ui/cocoa/cocoadisplay.c =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoadisplay.c 2007-01-14 11:27:54 UTC (rev 293) +++ branches/fusegl/fuse/ui/cocoa/cocoadisplay.c 2007-01-20 14:43:22 UTC (rev 294) @@ -1,410 +0,0 @@ -/* cocoadisplay.c: Routines for dealing with the Cocoa display - Copyright (c) 2006 Fredrick Meunier - - $Id: sdldisplay.c,v 1.40 2006/08/14 13:37:39 fredm Exp $ - - 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 - - Author contact information: - - E-mail: pak...@sr... - Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England - -*/ - -#include <config.h> - -#include <limits.h> -#include <stdio.h> -#include <stdint.h> -#include <string.h> - -#include <OpenGL/gl.h> -#include <OpenGL/glext.h> -#include <OpenGL/glu.h> - -#include <libspectrum.h> - -#include "FuseMenus.h" -#include "cocoadisplay.h" -#include "display.h" -#include "fuse.h" -#include "machine.h" -#include "scld.h" -#include "screenshot.h" -#include "settings.h" -#include "ui/ui.h" -#include "ui/scaler/scaler.h" -#include "ui/uidisplay.h" -#include "utils.h" - -/* The current size of the display (in units of DISPLAY_SCREEN_*) */ -static float display_current_size = 1.0f; - -static int image_width; -static int image_height; - -/* Screen texture */ -Cocoa_Texture* screen = NULL; - -/* Screen texture in native size */ -Cocoa_Texture unscaled_screen; - -/* Screen texture after scaling (only if a transforming scaler is in place) */ -Cocoa_Texture scaled_screen; - -/* Colours are in 1A 5R 5G 5B format */ -static uint16_t colour_values[] = { - 0x0000, - 0x0017, - 0x5c00, - 0x5c17, - 0x02e0, - 0x02f7, - 0x5ee0, - 0x5ef7, - 0x0000, - 0x001f, - 0x7c00, - 0x7c1f, - 0x03e0, - 0x03ff, - 0x7fe0, - 0x7fff -}; - -static uint16_t bw_values[16]; - -static void -init_scalers( void ) -{ - scaler_register_clear(); - - scaler_register( SCALER_NORMAL ); - if( machine_current->timex ) { - scaler_register( SCALER_TIMEXTV ); - } else { - scaler_register( SCALER_TV2X ); - scaler_register( SCALER_2XSAI ); - scaler_register( SCALER_SUPER2XSAI ); - scaler_register( SCALER_SUPEREAGLE ); - scaler_register( SCALER_ADVMAME2X ); - scaler_register( SCALER_ADVMAME3X ); - scaler_register( SCALER_DOTMATRIX ); - scaler_register( SCALER_HQ2X ); - scaler_register( SCALER_HQ3X ); - } - - if( scaler_is_supported( current_scaler ) ) { - scaler_select_scaler( current_scaler ); - } else { - scaler_select_scaler( SCALER_NORMAL ); - } - - scaler_select_bitformat( 555 ); -} - -static int -allocate_screen( Cocoa_Texture* screen, int height, int width, - float scaling_factor ) -{ - screen->image_width = image_width * display_current_size; - screen->image_height = image_height * display_current_size; - - /* Need some extra bytes around when using 2xSaI */ - screen->full_width = screen->image_width+3; - screen->image_xoffset = 1; - screen->full_height = screen->image_height+3; - screen->image_yoffset = 1; - - screen->pixels = calloc( screen->full_width*screen->full_height, sizeof(uint16_t) ); - if( !screen->pixels ) { - fprintf( stderr, "%s: couldn't create screen.pixels\n", fuse_progname ); - return 1; - } - - screen->pitch = screen->full_width * sizeof(uint16_t); - - return 0; -} - -static void -free_screen( Cocoa_Texture* screen ) -{ - if( screen->pixels ) { - free( screen->pixels ); - screen->pixels=NULL; - } -} - -static int -cocoadisplay_load_gfx_mode( void ) -{ - int error; - - display_current_size = scaler_get_scaling_factor( current_scaler ); - - error = allocate_screen( &unscaled_screen, image_height, image_width, 1.0f ); - if( error ) return error; - - screen = &unscaled_screen; - - if( current_scaler != SCALER_NORMAL ) { - error = allocate_screen( &scaled_screen, image_height, image_width, - display_current_size ); - if( error ) return error; - - screen = &scaled_screen; - } - - /* Create OpenGL textures for the image in DisplayOpenGLView */ - CreateTexture( screen ); - - /* Redraw the entire screen... */ - display_refresh_all(); - - return 0; -} - -static int -cocoadisplay_allocate_colours( int numColours, uint16_t *colour_values, - uint16_t *bw_values ) -{ - int i; - uint8_t red, green, blue, grey; - - for( i = 0; i < numColours; i++ ) { - red = (colour_values[i] >> 10) & 0x1f; - green = (colour_values[i] >> 5) & 0x1f; - blue = colour_values[i] & 0x1f; - - /* Addition of 0.5 is to avoid rounding errors */ - grey = ( 0.299 * red + 0.587 * green + 0.114 * blue ) + 0.5; - - bw_values[i] = (grey << 10) | (grey << 5) | grey; - } - - return 0; -} - -int -uidisplay_init( int width, int height ) -{ - int error; - error = cocoadisplay_allocate_colours( sizeof(colour_values) / sizeof(uint16_t), - colour_values, bw_values ); - - image_width = width; - image_height = height; - - init_scalers(); - - if ( scaler_select_scaler( current_scaler ) ) - scaler_select_scaler( SCALER_NORMAL ); - - cocoadisplay_load_gfx_mode(); - - /* We can now output error messages to our output device */ - display_ui_initialised = 1; - - return 0; -} - -void -uidisplay_hotswap_gfx_mode( void ) -{ - fuse_emulation_pause(); - - /* Free the old surfaces */ - free_screen( &unscaled_screen ); - free_screen( &scaled_screen ); - - /* Setup the new GFX mode */ - cocoadisplay_load_gfx_mode(); - - fuse_emulation_unpause(); -} - -/* Set one pixel in the display */ -void -uidisplay_putpixel( int x, int y, int colour ) -{ - uint16_t *dest_base, *dest; - uint16_t *palette_values = settings_current.bw_tv ? bw_values : colour_values; - - uint16_t palette_colour = palette_values[ colour ]; - - if( machine_current->timex ) { - x <<= 1; y <<= 1; - dest_base = dest = (uint16_t*)( (uint8_t*)unscaled_screen.pixels + - (x+unscaled_sc... [truncated message content] |