filename | src/dream.h |
changeset | 437:2c259474b474 |
prev | 435:7a5d71e8560b |
next | 477:9a373f2ff009 |
author | nkeynes |
date | Tue Oct 23 10:48:24 2007 +0000 (16 years ago) |
permissions | -rw-r--r-- |
last change | Reload BIOS/flash when changed in configuration. Fix mem_load_rom to deal with repeat loads and dodgy files |
view | annotate | diff | log | raw |
1 /**
2 * $Id: dream.h,v 1.15 2007-10-11 08:22:03 nkeynes Exp $
3 *
4 * Miscellaneous application-wide declarations (mainly logging atm)
5 *
6 * Copyright (c) 2005 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #ifndef dream_H
20 #define dream_H 1
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <stdint.h>
25 #include <string.h>
26 #include <glib/gtypes.h>
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 #define APP_NAME "lxDream"
33 #define APP_VERSION "0.8"
35 /************************ Modules ********************************/
36 /**
37 * Basic module structure defining the common operations across all
38 * modules, ie start, stop, reset, etc.
39 */
40 typedef struct dreamcast_module {
41 char *name;
42 /**
43 * Perform all initial module setup (ie register / allocate any
44 * memory required, etc). Only called once during system startup
45 */
46 void (*init)();
47 /**
48 * Reset the module into it's initial system boot state. Will be called
49 * once after init(), as well as whenever the user requests a reset.
50 */
51 void (*reset)();
52 /**
53 * Set the module into a running state (may be NULL)
54 */
55 void (*start)();
56 /**
57 * Execute one time-slice worth of operations, for the given number of
58 * nanoseconds.
59 * @return Number of nanoseconds actually executed
60 */
61 uint32_t (*run_time_slice)( uint32_t nanosecs );
62 /**
63 * Set the module into a stopped state (may be NULL)
64 */
65 void (*stop)();
66 /**
67 * Save the module state to the FILE stream. May be NULL, in which case
68 * the module is considered to have no state.
69 */
70 void (*save)(FILE *);
71 /**
72 * Load the saved module state from the FILE stream. May be NULL, in which
73 * case reset() will be called instead.
74 * @return 0 on success, nonzero on failure.
75 */
76 int (*load)(FILE *);
77 } *dreamcast_module_t;
79 void dreamcast_register_module( dreamcast_module_t );
81 extern struct dreamcast_module mem_module;
82 extern struct dreamcast_module sh4_module;
83 extern struct dreamcast_module asic_module;
84 extern struct dreamcast_module pvr2_module;
85 extern struct dreamcast_module aica_module;
86 extern struct dreamcast_module ide_module;
87 extern struct dreamcast_module maple_module;
88 extern struct dreamcast_module pvr2_module;
89 extern struct dreamcast_module gui_module;
90 extern struct dreamcast_module eventq_module;
91 extern struct dreamcast_module unknown_module;
93 /*************************** Logging **************************/
95 #define EMIT_FATAL 0
96 #define EMIT_ERR 1
97 #define EMIT_WARN 2
98 #define EMIT_INFO 3
99 #define EMIT_DEBUG 4
100 #define EMIT_TRACE 5
102 #ifndef MODULE
103 #define MODULE unknown_module
104 #endif
106 void log_message( void *, int level, const char *source, const char *msg, ... );
108 #define FATAL( ... ) log_message( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )
109 #define ERROR( ... ) log_message( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )
110 #define WARN( ... ) log_message( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )
111 #define INFO( ... ) log_message( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )
112 #define DEBUG( ... ) log_message( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )
113 #define TRACE( ... ) log_message( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )
115 void fwrite_string( const char *s, FILE *f );
116 int fread_string( char *s, int maxlen, FILE *f );
117 void fwrite_dump( unsigned char *buf, unsigned int length, FILE *f );
118 void fwrite_dump32( unsigned int *buf, unsigned int length, FILE *f );
119 void fwrite_dump32v( unsigned int *buf, unsigned int length, int wordsPerLine, FILE *f );
121 typedef uint32_t sh4addr_t;
123 #ifndef max
124 #define max(a,b) ( (a) > (b) ? (a) : (b) )
125 #endif
127 #ifdef __cplusplus
128 }
129 #endif
130 #endif
.