Search
lxdream.org :: lxdream/src/dreamcast.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/dreamcast.c
changeset 23:1ec3acd0594d
prev18:9a1b5d75703f
next25:fa2d21d57942
author nkeynes
date Fri Dec 23 11:44:55 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change Start of "real" time slices, general structure in place now
file annotate diff log raw
1.1 --- a/src/dreamcast.c Thu Dec 15 13:33:14 2005 +0000
1.2 +++ b/src/dreamcast.c Fri Dec 23 11:44:55 2005 +0000
1.3 @@ -16,6 +16,13 @@
1.4 static char *dreamcast_config = "DEFAULT";
1.5 dreamcast_module_t modules[MAX_MODULES];
1.6
1.7 +struct save_state_header {
1.8 + char magic[16];
1.9 + uint32_t version;
1.10 + uint32_t module_count;
1.11 +};
1.12 +
1.13 +
1.14 /**
1.15 * This function is responsible for defining how all the pieces of the
1.16 * dreamcast actually fit together. Among other things, this lets us
1.17 @@ -64,6 +71,7 @@
1.18 void dreamcast_init( void )
1.19 {
1.20 dreamcast_configure();
1.21 + dreamcast_state = STATE_STOPPED;
1.22 }
1.23
1.24 void dreamcast_reset( void )
1.25 @@ -75,29 +83,37 @@
1.26 }
1.27 }
1.28
1.29 -void dreamcast_start( void )
1.30 +void dreamcast_run( void )
1.31 {
1.32 int i;
1.33 - for( i=0; i<num_modules; i++ ) {
1.34 - if( modules[i]->start != NULL )
1.35 - modules[i]->start();
1.36 + if( dreamcast_state != STATE_RUNNING ) {
1.37 + for( i=0; i<num_modules; i++ ) {
1.38 + if( modules[i]->start != NULL )
1.39 + modules[i]->start();
1.40 + }
1.41 }
1.42 -}
1.43 -void dreamcast_stop( void )
1.44 -{
1.45 - int i;
1.46 + dreamcast_state = STATE_RUNNING;
1.47 + while( dreamcast_state == STATE_RUNNING ) {
1.48 + for( i=0; i<num_modules; i++ ) {
1.49 + if( modules[i]->run_time_slice != NULL )
1.50 + modules[i]->run_time_slice( TIMESLICE_LENGTH );
1.51 + }
1.52 +
1.53 + }
1.54 +
1.55 for( i=0; i<num_modules; i++ ) {
1.56 if( modules[i]->stop != NULL )
1.57 modules[i]->stop();
1.58 }
1.59 + dreamcast_state = STATE_STOPPED;
1.60 + update_gui();
1.61 }
1.62
1.63 -struct save_state_header {
1.64 - char magic[16];
1.65 - uint32_t version;
1.66 - uint32_t module_count;
1.67 -};
1.68 -
1.69 +void dreamcast_stop( void )
1.70 +{
1.71 + if( dreamcast_state == STATE_RUNNING )
1.72 + dreamcast_state = STATE_STOPPING;
1.73 +}
1.74
1.75 int dreamcast_load_state( const gchar *filename )
1.76 {
.