[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [261] branches/fusegl/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2006-12-23 11:00:03
|
Revision: 261 http://svn.sourceforge.net/fuse-for-macosx/?rev=261&view=rev Author: fredm Date: 2006-12-23 03:00:00 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Add CoreAudio sound driver, sort out various timing issues so we can run at 50 or 60 Hz and also at other than 100% speeds. Modified Paths: -------------- branches/fusegl/fuse/TODO branches/fusegl/fuse/event.c branches/fusegl/fuse/event.h 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/FuseController.h branches/fusegl/fuse/fusepb/controllers/FuseController.m branches/fusegl/fuse/fusepb/controllers/PreferencesController.m branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/info.nib branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/keyedobjects.nib branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m branches/fusegl/fuse/machine.c branches/fusegl/fuse/sound/coreaudiosound.c Added Paths: ----------- branches/fusegl/fuse/ui/cocoa/cocoaui.m Removed Paths: ------------- branches/fusegl/fuse/ui/cocoa/cocoaui.c Modified: branches/fusegl/fuse/TODO =================================================================== --- branches/fusegl/fuse/TODO 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/TODO 2006-12-23 11:00:00 UTC (rev 261) @@ -6,7 +6,7 @@ X Add GL renderer X Add native keyboard processing (removes SDL keyboard input dependency from Fuse) -* Add native CoreAudio sound processing (removes SDL sound dependency from Fuse) +X Add native CoreAudio sound processing (removes SDL sound dependency from Fuse) * Fix menus, preferences etc. * Fix scalers * Add native joystick processing (removes SDL joystick input dependency from Modified: branches/fusegl/fuse/event.c =================================================================== --- branches/fusegl/fuse/event.c 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/event.c 2006-12-23 11:00:00 UTC (rev 261) @@ -56,6 +56,9 @@ /* We are at the end of a frame */ int event_frame_end; +/* We've had a timer event */ +int event_timer; + /* The actual list of events */ static GSList* event_list; @@ -84,6 +87,7 @@ event_free=NULL; event_next_event=event_no_events; event_frame_end=0; + event_timer=0; return 0; } @@ -152,6 +156,25 @@ event_do_frame_end(); } +/* Run until target_tstates */ +void +event_do_timer( libspectrum_dword target_tstates ) +{ + if( event_add( target_tstates + tstates, EVENT_TYPE_TIMER ) ) { + /* Some sort of dire error */ + return; + } + event_timer=0; + while( !event_timer ) { + z80_do_opcodes(); + event_do_events(); + if( event_frame_end ) { + event_do_frame_end(); + } + } + event_timer=0; +} + /* Do all events which have passed */ int event_do_events(void) { @@ -174,7 +197,7 @@ case EVENT_TYPE_EDGE: tape_next_edge( ptr->tstates ); break; case EVENT_TYPE_TIMER: - timer_frame( ptr->tstates ); + event_timer = 1; break; case EVENT_TYPE_FRAME: Modified: branches/fusegl/fuse/event.h =================================================================== --- branches/fusegl/fuse/event.h 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/event.h 2006-12-23 11:00:00 UTC (rev 261) @@ -78,6 +78,9 @@ /* Do a single frame */ void event_do_frame(void); +/* Run until the next timer event */ +void event_do_timer( libspectrum_dword target_tstates ); + /* Called at end of frame to reduce T-state count of all entries */ int event_frame( libspectrum_dword tstates_per_frame ); Modified: branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj =================================================================== --- branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2006-12-23 11:00:00 UTC (rev 261) @@ -264,10 +264,10 @@ B6825549091817F30014B5EE /* divide.c in Sources */ = {isa = PBXBuildFile; fileRef = B6825547091817F30014B5EE /* divide.c */; }; B682554A091817F30014B5EE /* divide.h in Headers */ = {isa = PBXBuildFile; fileRef = B6825548091817F30014B5EE /* divide.h */; }; B6A6F0960B3C108C000B88E9 /* coreaudiosound.c in Sources */ = {isa = PBXBuildFile; fileRef = B6A6F0950B3C108C000B88E9 /* coreaudiosound.c */; }; + B6A6F0DA0B3D141B000B88E9 /* cocoaui.m in Sources */ = {isa = PBXBuildFile; fileRef = B6A6F0D90B3D141B000B88E9 /* cocoaui.m */; }; B6CE7F400B2830A300EB65B3 /* cocoadisplay.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3A0B2830A300EB65B3 /* cocoadisplay.c */; }; B6CE7F410B2830A300EB65B3 /* cocoadisplay.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */; }; B6CE7F420B2830A300EB65B3 /* cocoajoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */; }; - B6CE7F430B2830A300EB65B3 /* cocoaui.c in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F3D0B2830A300EB65B3 /* cocoaui.c */; }; B6CE7F440B2830A300EB65B3 /* cocoaui.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7F3E0B2830A300EB65B3 /* cocoaui.h */; }; B6CE7F520B283A0700EB65B3 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = B6CE7F510B283A0700EB65B3 /* main.mm */; }; B6CE7FCD0B28FBD600EB65B3 /* DisplayOpenGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = B6CE7FCB0B28FBD600EB65B3 /* DisplayOpenGLView.h */; }; @@ -449,6 +449,7 @@ B68CB2C603DD920300A804BA /* disassemble.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = disassemble.c; path = ../debugger/disassemble.c; sourceTree = "<group>"; }; B68CB2CC03DD923C00A804BA /* memory.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = memory.c; sourceTree = "<group>"; }; B6A6F0950B3C108C000B88E9 /* coreaudiosound.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = coreaudiosound.c; path = sound/coreaudiosound.c; sourceTree = "<group>"; }; + B6A6F0D90B3D141B000B88E9 /* cocoaui.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = cocoaui.m; sourceTree = "<group>"; }; B6A7F0E904C9A11D001025EB /* NumberFormatter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberFormatter.h; sourceTree = "<group>"; }; B6A7F0EA04C9A11D001025EB /* NumberFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NumberFormatter.m; sourceTree = "<group>"; }; B6AA8A3C03D2FC1C00FED55D /* trdos.rom */ = {isa = PBXFileReference; lastKnownFileType = file; name = trdos.rom; path = ../roms/trdos.rom; sourceTree = SOURCE_ROOT; }; @@ -490,7 +491,6 @@ 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>"; }; - B6CE7F3D0B2830A300EB65B3 /* cocoaui.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = cocoaui.c; sourceTree = "<group>"; }; B6CE7F3E0B2830A300EB65B3 /* cocoaui.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cocoaui.h; sourceTree = "<group>"; }; B6CE7F510B283A0700EB65B3 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; }; B6CE7FCB0B28FBD600EB65B3 /* DisplayOpenGLView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DisplayOpenGLView.h; sourceTree = "<group>"; }; @@ -890,8 +890,8 @@ B6CE7F3A0B2830A300EB65B3 /* cocoadisplay.c */, B6CE7F3B0B2830A300EB65B3 /* cocoadisplay.h */, B6CE7F3C0B2830A300EB65B3 /* cocoajoystick.c */, - B6CE7F3D0B2830A300EB65B3 /* cocoaui.c */, B6CE7F3E0B2830A300EB65B3 /* cocoaui.h */, + B6A6F0D90B3D141B000B88E9 /* cocoaui.m */, B6E0252B0B38AFE500E23A0F /* keysyms.m */, ); path = cocoa; @@ -1437,11 +1437,11 @@ B6403FD80A7E4B1A00E00B11 /* loader.c in Sources */, B6CE7F400B2830A300EB65B3 /* cocoadisplay.c in Sources */, B6CE7F420B2830A300EB65B3 /* cocoajoystick.c in Sources */, - B6CE7F430B2830A300EB65B3 /* cocoaui.c in Sources */, B6CE7F520B283A0700EB65B3 /* main.mm in Sources */, B6CE7FCE0B28FBD600EB65B3 /* DisplayOpenGLView.m in Sources */, B6E0252C0B38AFE500E23A0F /* keysyms.m in Sources */, B6A6F0960B3C108C000B88E9 /* coreaudiosound.c in Sources */, + B6A6F0DA0B3D141B000B88E9 /* cocoaui.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: branches/fusegl/fuse/fusepb/FuseMenus.h =================================================================== --- branches/fusegl/fuse/fusepb/FuseMenus.h 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/FuseMenus.h 2006-12-23 11:00:00 UTC (rev 261) @@ -32,6 +32,7 @@ void CreateTexture(Cocoa_Texture*); void DestroyTexture(void); +void SetEmulationHz(float); void Hide(void); void Open(void); Modified: branches/fusegl/fuse/fusepb/FuseMenus.m =================================================================== --- branches/fusegl/fuse/fusepb/FuseMenus.m 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/FuseMenus.m 2006-12-23 11:00:00 UTC (rev 261) @@ -56,6 +56,11 @@ [[DisplayOpenGLView instance] destroyTexture]; } +void SetEmulationHz( float hz ) +{ + [[DisplayOpenGLView instance] setEmulationHz:hz]; +} + void Hide(void) { [NSApp hide:[FuseController singleton]]; Modified: branches/fusegl/fuse/fusepb/controllers/FuseController.h =================================================================== --- branches/fusegl/fuse/fusepb/controllers/FuseController.h 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/controllers/FuseController.h 2006-12-23 11:00:00 UTC (rev 261) @@ -55,6 +55,7 @@ IBOutlet NSMenuItem *zxcf; IBOutlet NSMenuItem *tapePlay; IBOutlet NSMenu *recentSnaps; + IBOutlet NSWindow *window; IBOutlet id savePanelAccessoryView; IBOutlet NSPopUpButton* saveFileType; @@ -144,6 +145,7 @@ - (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)openRecent:(id)sender; Modified: branches/fusegl/fuse/fusepb/controllers/FuseController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/FuseController.m 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/controllers/FuseController.m 2006-12-23 11:00:00 UTC (rev 261) @@ -1023,6 +1023,11 @@ [if1 setEnabled:active == 0 ? NO : YES]; } +- (int)ui_statusbar_update_speed:(float)speed +{ + [window setTitle:[NSString stringWithFormat:@"Fuse - %3.0f%%", speed]]; +} + - (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem { switch( [menuItem tag] ) { Modified: branches/fusegl/fuse/fusepb/controllers/PreferencesController.m =================================================================== --- branches/fusegl/fuse/fusepb/controllers/PreferencesController.m 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/controllers/PreferencesController.m 2006-12-23 11:00:00 UTC (rev 261) @@ -29,6 +29,7 @@ #include <string.h> #import "FuseController.h" +#import "DisplayOpenGLView.h" #import "JoystickConfigurationController.h" #import "PreferencesController.h" #import "CAMachines.h" @@ -40,6 +41,7 @@ #include "printer.h" #include "settings.h" #include "settings_cocoa.h" +#include "sound.h" #include "machine.h" #include "ui.h" #include "ui/scaler/scaler.h" @@ -120,6 +122,10 @@ [machineRoms release]; 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]; } - (IBAction)chooseFile:(id)sender Modified: branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib =================================================================== --- branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib 2006-12-23 11:00:00 UTC (rev 261) @@ -77,6 +77,7 @@ savePanelAccessoryView = id; simple8Bit = NSMenuItem; tapePlay = NSMenuItem; + window = NSWindow; zxatasp = NSMenuItem; zxcf = NSMenuItem; }; Modified: branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/info.nib =================================================================== --- branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/info.nib 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/info.nib 2006-12-23 11:00:00 UTC (rev 261) @@ -13,8 +13,8 @@ <string>446.1</string> <key>IBOpenObjects</key> <array> + <integer>29</integer> <integer>877</integer> - <integer>29</integer> </array> <key>IBSystem Version</key> <string>8L2127</string> Modified: branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2006-12-23 11:00:00 UTC (rev 261) @@ -51,6 +51,8 @@ int cocoakeyboard_caps_shift_pressed; int cocoakeyboard_symbol_shift_pressed; input_key unicode_keysym; + + CFAbsoluteTime time; } +(DisplayOpenGLView *) instance; +(void) initialize; @@ -59,6 +61,7 @@ -(void) destroyTexture; -(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime; +-(void) setEmulationHz:(float)hz; -(id) initWithFrame:(NSRect)frameRect; -(void) awakeFromNib; Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2006-12-23 11:00:00 UTC (rev 261) @@ -32,14 +32,22 @@ #include "fuse.h" #include "fusepb/main.h" #include "keyboard.h" +#include "settings.h" +#include "sound.h" extern keysyms_map_t unicode_keysyms_map[]; +#include <CoreAudio/AudioHardware.h> +#include "sound/sfifo.h" + +extern sfifo_t sound_fifo; +extern AudioStreamBasicDescription deviceFormat; + @implementation DisplayOpenGLView static DisplayOpenGLView *instance = nil; -+ (DisplayOpenGLView *) instance ++(DisplayOpenGLView *) instance { return instance; } @@ -82,9 +90,9 @@ } -- (id) initWithFrame:(NSRect)frameRect +-(id) initWithFrame:(NSRect)frameRect { - // Init pixel format attribs + /* Init pixel format attribs */ NSOpenGLPixelFormatAttribute attrs[] = { NSOpenGLPFAAccelerated, NSOpenGLPFANoRecovery, @@ -92,7 +100,7 @@ 0 }; - // Get pixel format from OpenGL + /* Get pixel format from OpenGL */ NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; if (!pixFmt) { NSLog(@"No pixel format -- exiting"); @@ -109,9 +117,9 @@ [[self openGLContext] makeCurrentContext]; - timer = [[NSTimer scheduledTimerWithTimeInterval: (1.0f / 50.0f) target: self selector:@selector(drawRect:) userInfo:self repeats:true] retain]; + timer = nil; - // Setup some basic OpenGL stuff + /* Setup some basic OpenGL stuff */ glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -132,30 +140,36 @@ -(void) awakeFromNib { - // FIXME: Do all the stuff that SDLMain.mm used - // to do command line wise, drag-n-drop etc. here? - // FIXME: Don't really like the argc, argv stuff being here... + /* FIXME: Do all the stuff that SDLMain.mm used + * to do command line wise, drag-n-drop etc. here? + */ + /* 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 ); } [self initKeyboard]; + + time = CFAbsoluteTimeGetCurrent(); /* set emulation time start time */ } -- (void)drawRect:(NSRect)aRect +-(void) drawRect:(NSRect)aRect { - // update emulation - [self updateEmulationForTimeDelta:0]; + CFTimeInterval nowTime = CFAbsoluteTimeGetCurrent(); + CFTimeInterval deltaTime = nowTime - time; + if (deltaTime <= 1.0) { /* skip pauses */ + [self updateEmulationForTimeDelta:deltaTime]; + } + time = nowTime; if( NO == screenTexInitialised ) return; - // Need to draw texture to screen here + /* Need to draw texture to screen here */ memcpy(screenTex.pixels, screen.pixels, screenTex.pitch*screenTex.height); - // Make this context current [[self openGLContext] makeCurrentContext]; - // Bind, update and draw new image + /* Bind, update and draw new image */ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1); glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, screenTex.width, @@ -178,14 +192,15 @@ glEnd(); + /* FIXME: Probably still need to glFlush() in fullscreen mode */ //glFlush(); - // Swap buffer to screen + /* Swap buffer to screen */ [[self openGLContext] flushBuffer]; } -// moved or resized -- (void)update +/* moved or resized */ +-(void) update { NSRect rect; @@ -207,8 +222,8 @@ [self setNeedsDisplay:true]; } -// scrolled, moved or resized -- (void)reshape +/* scrolled, moved or resized */ +-(void) reshape { NSRect rect; @@ -235,7 +250,7 @@ GLuint i; if( screenTexInitialised == NO) return; - // May want to have a double buffered texture later + /* FIXME: May want to have a double buffered texture later */ for(i = 0; i < 1; i++) { GLint dt = i+1; glDeleteTextures(1, &dt); @@ -259,7 +274,7 @@ [[self openGLContext] makeCurrentContext]; [[self openGLContext] update]; - // May want to have a double buffered texture later + /* FIXME: May want to have a double buffered texture later */ for(i = 0; i < 1; i++) { glDisable(GL_TEXTURE_2D); @@ -285,22 +300,43 @@ screenTexInitialised = YES; } -// given a delta time in seconds, update overall emulation state -- (void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime +/* given a delta time in seconds, update overall emulation state */ +-(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime { -// Note: will be called 50 or 60 times/frame - if running at non 100% speed will -// want to run a fraction of the normal time - event_do_frame(); + if( sound_enabled ) { + /* emulate until fifo is full */ + while( sfifo_space( &sound_fifo ) >= (sound_stereo+1) * 2 * sound_framesiz ) { + event_do_frame(); + } + } else { + float speed = ( settings_current.emulation_speed < 1 ? + 100.0 : + settings_current.emulation_speed ) / 100.0; + libspectrum_dword time_tstates = deltaTime * + machine_current->timings.processor_speed * + speed + 0.5; + event_do_timer( time_tstates ); + } } -- (void)mouseDragged:(NSEvent *)theEvent +-(void) setEmulationHz:(float)hz { + [timer invalidate]; + [timer release]; + + timer = [[NSTimer scheduledTimerWithTimeInterval: (1.0f / hz) + target:self selector:@selector(drawRect:) + userInfo:self repeats:true] retain]; } -- (void)mouseDown:(NSEvent *)theEvent +-(void) mouseDragged:(NSEvent *)theEvent { } +-(void) mouseDown:(NSEvent *)theEvent +{ +} + -(void) initKeyboard { keysyms_map_t *ptr3; Modified: branches/fusegl/fuse/machine.c =================================================================== --- branches/fusegl/fuse/machine.c 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/machine.c 2006-12-23 11:00:00 UTC (rev 261) @@ -29,6 +29,7 @@ #include <stdlib.h> #include <string.h> +#include "FuseMenus.h" #include "divide.h" #include "event.h" #include "fuse.h" @@ -253,7 +254,6 @@ /* Reset the event stack */ event_reset(); - if( event_add( 0, EVENT_TYPE_TIMER ) ) return 1; if( event_add( machine->timings.tstates_per_frame, EVENT_TYPE_FRAME ) ) return 1; @@ -395,6 +395,10 @@ error = machine_current->memory_map(); if( error ) return error; + /* Select 50 or 60 Hz emulation timer */ + SetEmulationHz( (float)machine_current->timings.processor_speed / + machine_current->timings.tstates_per_frame ); + /* Set up the contention array */ for( i = 0; i < machine_current->timings.tstates_per_frame; i++ ) ula_contention[ i ] = machine_current->ram.contend_delay( i ); Modified: branches/fusegl/fuse/sound/coreaudiosound.c =================================================================== --- branches/fusegl/fuse/sound/coreaudiosound.c 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/sound/coreaudiosound.c 2006-12-23 11:00:00 UTC (rev 261) @@ -30,11 +30,15 @@ #include "event.h" #include "sfifo.h" +#include "settings.h" #include "sound.h" #include "ui/ui.h" sfifo_t sound_fifo; +/* Number of Spectrum frames audio latency to use */ +#define NUM_FRAMES 2 + static OSStatus coreaudiowrite( void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, @@ -44,7 +48,7 @@ AudioBufferList *ioData ); /* info about the format used for writing to output unit */ -static AudioStreamBasicDescription deviceFormat; +AudioStreamBasicDescription deviceFormat; /* converts from Fuse format (signed 16 bit ints) to CoreAudio format (floats) */ @@ -159,8 +163,14 @@ return 1; } - if( ( error = sfifo_init( &sound_fifo, 2 * deviceFormat.mChannelsPerFrame - * deviceBufferSize + 1 ) ) ) { + float hz = (float)machine_current->timings.processor_speed / + machine_current->timings.tstates_per_frame; + + int sound_framesiz = settings_current.sound_freq / hz; + if( ( error = sfifo_init( &sound_fifo, NUM_FRAMES + * deviceFormat.mBytesPerFrame + * deviceFormat.mChannelsPerFrame + * sound_framesiz + 1 ) ) ) { ui_error( UI_ERROR_ERROR, "Problem initialising sound fifo: %s", strerror ( error ) ); return 1; Deleted: branches/fusegl/fuse/ui/cocoa/cocoaui.c =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoaui.c 2006-12-23 01:32:26 UTC (rev 260) +++ branches/fusegl/fuse/ui/cocoa/cocoaui.c 2006-12-23 11:00:00 UTC (rev 261) @@ -1,97 +0,0 @@ -/* cocoaui.c: Routines for dealing with the Mac OS X user interface - Copyright (c) 2006 Fredrick Meunier - - $Id: sdlui.c,v 1.11 2005/06/06 14:24:05 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 <stdio.h> - -#include "display.h" -#include "fuse.h" -#include "ui/ui.h" -#include "ui/uidisplay.h" -#include "pokefinder/pokefinder.h" -#include "settings.h" -#include "cocoaui.h" -#include "tape.h" -#include "ui/scaler/scaler.h" - -int -ui_init( int *argc, char ***argv ) -{ - int error; - - return 0; -} - -int -ui_event( void ) -{ - return 0; -} - -int -ui_end( void ) -{ - int error; - - return 0; -} - -int -ui_statusbar_update_speed( float speed ) -{ - char buffer[15]; - const char fuse[] = "Fuse"; - - snprintf( buffer, 15, "%s - %3.0f%%", fuse, speed ); - - return 0; -} - -int -ui_mouse_grab( int startup ) -{ - return 0; -} - -int -ui_mouse_release( int suspend ) -{ - return 0; -} - -/* Called on machine selection */ -int -ui_widgets_reset( void ) -{ - pokefinder_clear(); - return 0; -} - -void -cocoaui_quit( void ) -{ -} Copied: branches/fusegl/fuse/ui/cocoa/cocoaui.m (from rev 258, branches/fusegl/fuse/ui/cocoa/cocoaui.c) =================================================================== --- branches/fusegl/fuse/ui/cocoa/cocoaui.m (rev 0) +++ branches/fusegl/fuse/ui/cocoa/cocoaui.m 2006-12-23 11:00:00 UTC (rev 261) @@ -0,0 +1,94 @@ +/* cocoaui.c: Routines for dealing with the Mac OS X user interface + Copyright (c) 2006 Fredrick Meunier + + $Id: sdlui.c,v 1.11 2005/06/06 14:24:05 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 <stdio.h> + +#import "FuseController.h" + +#include "display.h" +#include "fuse.h" +#include "ui/ui.h" +#include "ui/uidisplay.h" +#include "pokefinder/pokefinder.h" +#include "settings.h" +#include "cocoaui.h" +#include "tape.h" +#include "ui/scaler/scaler.h" + +int +ui_init( int *argc, char ***argv ) +{ + int error; + + return 0; +} + +int +ui_event( void ) +{ + return 0; +} + +int +ui_end( void ) +{ + int error; + + return 0; +} + +int +ui_statusbar_update_speed( float speed ) +{ + return [[FuseController singleton] ui_statusbar_update_speed:speed]; +} + +int +ui_mouse_grab( int startup ) +{ + return 0; +} + +int +ui_mouse_release( int suspend ) +{ + return 0; +} + +/* Called on machine selection */ +int +ui_widgets_reset( void ) +{ + pokefinder_clear(); + return 0; +} + +void +cocoaui_quit( void ) +{ +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |