[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx:[578] trunk/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2009-01-09 13:06:42
|
Revision: 578 http://fuse-for-macosx.svn.sourceforge.net/fuse-for-macosx/?rev=578&view=rev Author: fredm Date: 2009-01-09 13:06:36 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Fix running with sound off. Modified Paths: -------------- trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj trunk/fuse/fusepb/models/Emulator.h trunk/fuse/fusepb/models/Emulator.m trunk/fuse/spectrum.c Added Paths: ----------- trunk/fuse/fusepb/timer/ trunk/fuse/fusepb/timer/timer.c Modified: trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj =================================================================== --- trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2008-12-18 10:18:38 UTC (rev 577) +++ trunk/fuse/fusepb/Fuse.xcodeproj/project.pbxproj 2009-01-09 13:06:36 UTC (rev 578) @@ -170,8 +170,8 @@ B62B1A2A0DD667EC00D42AAF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B62B1A290DD667EC00D42AAF /* main.m */; }; B63225EC0C66BA1300BB081B /* osname.c in Sources */ = {isa = PBXBuildFile; fileRef = B63225EB0C66BA1300BB081B /* osname.c */; }; B63225EE0C66BA3700BB081B /* paths.c in Sources */ = {isa = PBXBuildFile; fileRef = B63225ED0C66BA3700BB081B /* paths.c */; }; - B63225F50C66BA7400BB081B /* timer.c in Sources */ = {isa = PBXBuildFile; fileRef = B63225F20C66BA7400BB081B /* timer.c */; }; B63225F70C66BA7400BB081B /* unix.c in Sources */ = {isa = PBXBuildFile; fileRef = B63225F40C66BA7400BB081B /* unix.c */; }; + B6374FA50F178298003CE6E2 /* timer.c in Sources */ = {isa = PBXBuildFile; fileRef = B6374FA40F178298003CE6E2 /* timer.c */; }; B639B7680A6BAFCF00927E24 /* csw.icns in Resources */ = {isa = PBXBuildFile; fileRef = B639B7670A6BAFCF00927E24 /* csw.icns */; }; B639B7D10A6BB45600927E24 /* raw.icns in Resources */ = {isa = PBXBuildFile; fileRef = B639B7D00A6BB45600927E24 /* raw.icns */; }; B6403FD80A7E4B1A00E00B11 /* loader.c in Sources */ = {isa = PBXBuildFile; fileRef = B6403FD60A7E4B1A00E00B11 /* loader.c */; }; @@ -339,11 +339,11 @@ B62F3BCF059F5BF300A7009A /* PokeFinderController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PokeFinderController.m; path = controllers/PokeFinderController.m; sourceTree = "<group>"; }; B63225EB0C66BA1300BB081B /* osname.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = osname.c; sourceTree = "<group>"; }; B63225ED0C66BA3700BB081B /* paths.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = paths.c; sourceTree = "<group>"; }; - B63225F20C66BA7400BB081B /* timer.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = timer.c; sourceTree = "<group>"; }; B63225F30C66BA7400BB081B /* timer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = timer.h; sourceTree = "<group>"; }; B63225F40C66BA7400BB081B /* unix.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = unix.c; sourceTree = "<group>"; }; B632C6AE03E5368700A864FD /* DebuggerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DebuggerController.h; path = controllers/DebuggerController.h; sourceTree = "<group>"; }; B632C6AF03E5368700A864FD /* DebuggerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DebuggerController.m; path = controllers/DebuggerController.m; sourceTree = "<group>"; }; + B6374FA40F178298003CE6E2 /* timer.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = timer.c; path = timer/timer.c; sourceTree = SOURCE_ROOT; }; B6379299060AA0D300246736 /* se-0.rom */ = {isa = PBXFileReference; lastKnownFileType = file; name = "se-0.rom"; path = "../roms/se-0.rom"; sourceTree = SOURCE_ROOT; }; B637929A060AA0D300246736 /* se-1.rom */ = {isa = PBXFileReference; lastKnownFileType = file; name = "se-1.rom"; path = "../roms/se-1.rom"; sourceTree = SOURCE_ROOT; }; B639B7670A6BAFCF00927E24 /* csw.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = csw.icns; sourceTree = "<group>"; }; @@ -789,7 +789,7 @@ B63225EF0C66BA4B00BB081B /* timer */ = { isa = PBXGroup; children = ( - B63225F20C66BA7400BB081B /* timer.c */, + B6374FA40F178298003CE6E2 /* timer.c */, B63225F30C66BA7400BB081B /* timer.h */, B63225F40C66BA7400BB081B /* unix.c */, ); @@ -1481,7 +1481,6 @@ B6CADD580C47AD90004BA954 /* Texture.m in Sources */, B63225EC0C66BA1300BB081B /* osname.c in Sources */, B63225EE0C66BA3700BB081B /* paths.c in Sources */, - B63225F50C66BA7400BB081B /* timer.c in Sources */, B63225F70C66BA7400BB081B /* unix.c in Sources */, B6CE3A060CD2160A005ACDC8 /* beta.c in Sources */, B6CE3A080CD2160A005ACDC8 /* crc.c in Sources */, @@ -1499,6 +1498,7 @@ B684A19E0E93A8CD00A5B097 /* event.c in Sources */, B684A1A00E93A8D700A5B097 /* variable.c in Sources */, B684A1A20E93A8FC00A5B097 /* file.c in Sources */, + B6374FA50F178298003CE6E2 /* timer.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: trunk/fuse/fusepb/models/Emulator.h =================================================================== --- trunk/fuse/fusepb/models/Emulator.h 2008-12-18 10:18:38 UTC (rev 577) +++ trunk/fuse/fusepb/models/Emulator.h 2009-01-09 13:06:36 UTC (rev 578) @@ -64,7 +64,7 @@ -(void) stopEmulationTimer; -(void) updateEmulation:(NSTimer*)theTimer; --(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime; +-(void) updateEmulationForTimeDelta:(CFTimeInterval)deltaTime; -(void) setEmulationHz:(float)hz; /* FIXME: Could do with a setSettings? maybe we just update settings when Modified: trunk/fuse/fusepb/models/Emulator.m =================================================================== --- trunk/fuse/fusepb/models/Emulator.m 2008-12-18 10:18:38 UTC (rev 577) +++ trunk/fuse/fusepb/models/Emulator.m 2009-01-09 13:06:36 UTC (rev 578) @@ -148,7 +148,7 @@ } /* given a delta time in seconds, update overall emulation state */ --(void) updateEmulationForTimeDelta:(CFAbsoluteTime)deltaTime +-(void) updateEmulationForTimeDelta:(CFTimeInterval)deltaTime { if( sound_enabled ) { int too_long = 0; Added: trunk/fuse/fusepb/timer/timer.c =================================================================== --- trunk/fuse/fusepb/timer/timer.c (rev 0) +++ trunk/fuse/fusepb/timer/timer.c 2009-01-09 13:06:36 UTC (rev 578) @@ -0,0 +1,136 @@ +/* timer.c: Speed routines for Fuse + Copyright (c) 1999-2007 Philip Kendall, Marek Januszewski, Fredrick Meunier + + $Id: timer.c 3681 2008-06-16 09:40:29Z pak21 $ + + 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., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + Author contact information: + + E-mail: phi...@sh... + +*/ + +#include <config.h> + +#include "event.h" +#include "settings.h" +#include "sound.h" +#include "tape.h" +#include "timer.h" +#include "ui/ui.h" + +/* + * Routines for estimating emulation speed + */ + +/* The actual time at the end of each of the last 10 emulated seconds */ +static timer_type stored_times[10]; + +/* Which is the next entry in 'stored_times' that we will update */ +static size_t next_stored_time; + +/* The number of frames until we next update 'stored_times' */ +static int frames_until_update; + +/* The number of time samples we have for estimating speed */ +static int samples; + +float current_speed = 100.0; + +static timer_type start_time; + +int timer_event; + +static void timer_frame( libspectrum_dword last_tstates, int event GCC_UNUSED, + void *user_data GCC_UNUSED ); + +int +timer_estimate_speed( void ) +{ + timer_type current_time; + float difference; + int error; + + if( frames_until_update-- ) return 0; + + error = timer_get_real_time( ¤t_time ); if( error ) return error; + + if( samples < 10 ) { + + /* If we don't have enough data, assume we're running at the desired + speed :-) */ + current_speed = settings_current.emulation_speed; + + } else { + + difference = + timer_get_time_difference( ¤t_time, + &stored_times[ next_stored_time ] ); + current_speed = 100 * ( 10.0 / difference ); + + } + + ui_statusbar_update_speed( current_speed ); + + stored_times[ next_stored_time ] = current_time; + + next_stored_time = ( next_stored_time + 1 ) % 10; + frames_until_update = + ( machine_current->timings.processor_speed / + machine_current->timings.tstates_per_frame ) - 1; + + samples++; + + return 0; +} + +int +timer_estimate_reset( void ) +{ + int error = timer_get_real_time( &start_time ); if( error ) return error; + samples = 0; + next_stored_time = 0; + frames_until_update = 0; + + return 0; +} + +int +timer_init( void ) +{ + int error = timer_get_real_time( &start_time ); if( error ) return error; + + timer_event = event_register( timer_frame, "Timer" ); + if( timer_event == -1 ) return 1; + + error = event_add( 0, timer_event ); + if( error ) return error; + + return 0; +} + +int +timer_end( void ) +{ + return event_remove_type( timer_event ); +} + +static void +timer_frame( libspectrum_dword last_tstates, int event GCC_UNUSED, + void *user_data GCC_UNUSED ) +{ + event_timer = 1; +} Modified: trunk/fuse/spectrum.c =================================================================== --- trunk/fuse/spectrum.c 2008-12-18 10:18:38 UTC (rev 577) +++ trunk/fuse/spectrum.c 2009-01-09 13:06:36 UTC (rev 578) @@ -275,11 +275,11 @@ void spectrum_do_timer( libspectrum_dword target_tstates ) { + event_timer=0; if( event_add( target_tstates + tstates, timer_event ) ) { /* Some sort of dire error */ return; } - event_timer=0; while( !event_timer ) { z80_do_opcodes(); event_do_events(); @@ -287,5 +287,4 @@ spectrum_do_frame_end(); } } - event_timer=0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |