filename | src/dreamcast.c |
changeset | 372:86aa060ddcec |
prev | 295:6637664291a8 |
next | 422:61a0598e07ff |
author | nkeynes |
date | Wed Sep 12 09:20:38 2007 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Start splitting the common SH4 parts into sh4.c, with sh4core.c to become just the emulation core. |
file | annotate | diff | log | raw |
1.1 --- a/src/dreamcast.c Tue Jan 16 10:34:46 2007 +00001.2 +++ b/src/dreamcast.c Wed Sep 12 09:20:38 2007 +00001.3 @@ -1,5 +1,5 @@1.4 /**1.5 - * $Id: dreamcast.c,v 1.21 2007-01-16 10:34:46 nkeynes Exp $1.6 + * $Id: dreamcast.c,v 1.22 2007-09-08 04:38:38 nkeynes Exp $1.7 * Central switchboard for the system. This pulls all the individual modules1.8 * together into some kind of coherent structure. This is also where you'd1.9 * add Naomi support, if I ever get a board to play with...1.10 @@ -154,6 +154,42 @@1.11 dreamcast_state = STATE_STOPPED;1.12 }1.14 +void dreamcast_run_for( unsigned int seconds, unsigned int nanosecs )1.15 +{1.16 +1.17 + int i;1.18 + if( dreamcast_state != STATE_RUNNING ) {1.19 + for( i=0; i<num_modules; i++ ) {1.20 + if( modules[i]->start != NULL )1.21 + modules[i]->start();1.22 + }1.23 + }1.24 + dreamcast_state = STATE_RUNNING;1.25 + uint32_t nanos = 0;1.26 + if( nanosecs != 0 ) {1.27 + nanos = 1000000000 - nanosecs;1.28 + seconds++;1.29 + }1.30 + while( dreamcast_state == STATE_RUNNING && seconds != 0 ) {1.31 + int time_to_run = timeslice_length;1.32 + for( i=0; i<num_modules; i++ ) {1.33 + if( modules[i]->run_time_slice != NULL )1.34 + time_to_run = modules[i]->run_time_slice( time_to_run );1.35 + }1.36 + nanos += time_to_run;1.37 + if( nanos >= 1000000000 ) {1.38 + nanos -= 1000000000;1.39 + seconds--;1.40 + }1.41 + }1.42 +1.43 + for( i=0; i<num_modules; i++ ) {1.44 + if( modules[i]->stop != NULL )1.45 + modules[i]->stop();1.46 + }1.47 + dreamcast_state = STATE_STOPPED;1.48 +}1.49 +1.50 void dreamcast_stop( void )1.51 {1.52 if( dreamcast_state == STATE_RUNNING )
.