1.1 --- a/src/dream.h Sun Dec 25 08:24:11 2005 +0000
1.2 +++ b/src/dream.h Tue Mar 14 11:44:29 2006 +0000
1.5 - * $Id: dream.h,v 1.6 2005-12-25 08:24:07 nkeynes Exp $
1.6 + * $Id: dream.h,v 1.7 2005-12-26 03:54:52 nkeynes Exp $
1.8 * Miscellaneous application-wide declarations (mainly logging atm)
1.27 +/************************ Modules ********************************/
1.29 + * Basic module structure defining the common operations across all
1.30 + * modules, ie start, stop, reset, etc.
1.32 +typedef struct dreamcast_module {
1.35 + * Perform all initial module setup (ie register / allocate any
1.36 + * memory required, etc). Only called once during DreamOn startup
1.40 + * Reset the module into it's initial system boot state. Will be called
1.41 + * once after init(), as well as whenever the user requests a reset.
1.45 + * Set the module into a running state (may be NULL)
1.49 + * Execute one time-slice worth of operations, for the given number of
1.51 + * @return Number of nanoseconds actually executed
1.53 + uint32_t (*run_time_slice)( uint32_t nanosecs );
1.55 + * Set the module into a stopped state (may be NULL)
1.59 + * Save the module state to the FILE stream. May be NULL, in which case
1.60 + * the module is considered to have no state.
1.62 + void (*save)(FILE *);
1.64 + * Load the saved module state from the FILE stream. May be NULL, in which
1.65 + * case reset() will be called instead.
1.66 + * @return 0 on success, nonzero on failure.
1.68 + int (*load)(FILE *);
1.69 +} *dreamcast_module_t;
1.71 +void dreamcast_register_module( dreamcast_module_t );
1.73 +extern struct dreamcast_module mem_module;
1.74 +extern struct dreamcast_module sh4_module;
1.75 +extern struct dreamcast_module asic_module;
1.76 +extern struct dreamcast_module pvr2_module;
1.77 +extern struct dreamcast_module aica_module;
1.78 +extern struct dreamcast_module ide_module;
1.79 +extern struct dreamcast_module maple_module;
1.80 +extern struct dreamcast_module pvr2_module;
1.81 +extern struct dreamcast_module gui_module;
1.82 +extern struct dreamcast_module unknown_module;
1.84 +/*************************** Logging **************************/
1.86 #define EMIT_FATAL 0
1.89 #define EMIT_DEBUG 4
1.90 #define EMIT_TRACE 5
1.93 -#define MODULE_ID 0
1.95 +#define MODULE unknown_module
1.98 -void emit( void *, int level, int source, const char *msg, ... );
1.99 +void emit( void *, int level, const char *source, const char *msg, ... );
1.101 -#define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE_ID, __VA_ARGS__ )
1.102 -#define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE_ID, __VA_ARGS__ )
1.103 -#define WARN( ... ) emit( NULL, EMIT_WARN, MODULE_ID, __VA_ARGS__ )
1.104 -#define INFO( ... ) emit( NULL, EMIT_INFO, MODULE_ID, __VA_ARGS__ )
1.105 -#define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE_ID, __VA_ARGS__ )
1.106 -#define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE_ID, __VA_ARGS__ )
1.107 +#define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )
1.108 +#define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )
1.109 +#define WARN( ... ) emit( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )
1.110 +#define INFO( ... ) emit( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )
1.111 +#define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )
1.112 +#define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )
1.114 #define BIOS_PATH "../bios"
1.116 +void fwrite_string( char *s, FILE *f );
1.117 +int fread_string( char *s, int maxlen, FILE *f );