Search
lxdream.org :: lxdream/src/dreamcast.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/dreamcast.c
changeset 26:ad258e3daaa5
prev25:fa2d21d57942
next27:1ef09a52cd1e
author nkeynes
date Sat Dec 24 08:02:18 2005 +0000 (14 years ago)
permissions -rw-r--r--
last change More structure reorgs/fixes
file annotate diff log raw
1.1 --- a/src/dreamcast.c Sat Dec 24 03:33:08 2005 +0000
1.2 +++ b/src/dreamcast.c Sat Dec 24 08:02:18 2005 +0000
1.3 @@ -1,3 +1,22 @@
1.4 +/**
1.5 + * $Id: dreamcast.c,v 1.9 2005-12-24 08:02:14 nkeynes Exp $
1.6 + * Central switchboard for the system. This pulls all the individual modules
1.7 + * together into some kind of coherent structure. This is also where you'd
1.8 + * add Naomi support, if I ever get a board to play with...
1.9 + *
1.10 + * Copyright (c) 2005 Nathan Keynes.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.16 + *
1.17 + * This program is distributed in the hope that it will be useful,
1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + * GNU General Public License for more details.
1.21 + */
1.22 +
1.23 #include <errno.h>
1.24 #include "dream.h"
1.25 #include "mem.h"
1.26 @@ -8,26 +27,24 @@
1.27 #include "maple/maple.h"
1.28 #include "modules.h"
1.29
1.30 -/* Central switchboard for the system */
1.31 +/**
1.32 + * Current state of the DC virtual machine
1.33 + */
1.34 +#define STATE_UNINIT 0
1.35 +#define STATE_RUNNING 1
1.36 +#define STATE_STOPPING 2
1.37 +#define STATE_STOPPED 3
1.38 +static volatile int dreamcast_state = STATE_UNINIT;
1.39 +static uint32_t timeslice_length = DEFAULT_TIMESLICE_LENGTH;
1.40 +static char *dreamcast_config = "DEFAULT";
1.41
1.42 #define MAX_MODULES 32
1.43 static int num_modules = 0;
1.44 -static int dreamcast_state = 0;
1.45 -static char *dreamcast_config = "DEFAULT";
1.46 dreamcast_module_t modules[MAX_MODULES];
1.47
1.48 -struct save_state_header {
1.49 - char magic[16];
1.50 - uint32_t version;
1.51 - uint32_t module_count;
1.52 -};
1.53 -
1.54 -
1.55 /**
1.56 * This function is responsible for defining how all the pieces of the
1.57 - * dreamcast actually fit together. Among other things, this lets us
1.58 - * (reasonably) easily redefine the structure for eg various versions of the
1.59 - * Naomi.
1.60 + * dreamcast actually fit together.
1.61 *
1.62 * Note currently the locations of the various MMIO pages are hard coded in
1.63 * the MMIO definitions - they should probably be moved here.
1.64 @@ -96,7 +113,7 @@
1.65 while( dreamcast_state == STATE_RUNNING ) {
1.66 for( i=0; i<num_modules; i++ ) {
1.67 if( modules[i]->run_time_slice != NULL )
1.68 - modules[i]->run_time_slice( TIMESLICE_LENGTH );
1.69 + modules[i]->run_time_slice( timeslice_length );
1.70 }
1.71
1.72 }
1.73 @@ -115,6 +132,23 @@
1.74 dreamcast_state = STATE_STOPPING;
1.75 }
1.76
1.77 +gboolean dreamcast_is_running( void )
1.78 +{
1.79 + return dreamcast_state == STATE_RUNNING;
1.80 +}
1.81 +
1.82 +
1.83 +/********************************* Save States *****************************/
1.84 +
1.85 +#define DREAMCAST_SAVE_MAGIC "%!-DreamOn!Save\0"
1.86 +#define DREAMCAST_SAVE_VERSION 0x00010000
1.87 +
1.88 +struct save_state_header {
1.89 + char magic[16];
1.90 + uint32_t version;
1.91 + uint32_t module_count;
1.92 +};
1.93 +
1.94 int dreamcast_load_state( const gchar *filename )
1.95 {
1.96 int i,j;
.