filename | src/dream.h |
changeset | 180:e6dcf9b65658 |
prev | 135:2b05ea3d87c1 |
next | 220:f72f8a7dff88 |
author | nkeynes |
date | Sat Aug 05 00:18:21 2006 +0000 (17 years ago) |
permissions | -rw-r--r-- |
last change | Add error lines to tests with incomplete polys Split clip tests to separate data file Add tests for cmd bit 23 ("use list size field") |
view | annotate | diff | log | raw |
1 /**
2 * $Id: dream.h,v 1.10 2006-07-02 04:59:00 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"
34 /************************ Modules ********************************/
35 /**
36 * Basic module structure defining the common operations across all
37 * modules, ie start, stop, reset, etc.
38 */
39 typedef struct dreamcast_module {
40 char *name;
41 /**
42 * Perform all initial module setup (ie register / allocate any
43 * memory required, etc). Only called once during system startup
44 */
45 void (*init)();
46 /**
47 * Reset the module into it's initial system boot state. Will be called
48 * once after init(), as well as whenever the user requests a reset.
49 */
50 void (*reset)();
51 /**
52 * Set the module into a running state (may be NULL)
53 */
54 void (*start)();
55 /**
56 * Execute one time-slice worth of operations, for the given number of
57 * nanoseconds.
58 * @return Number of nanoseconds actually executed
59 */
60 uint32_t (*run_time_slice)( uint32_t nanosecs );
61 /**
62 * Set the module into a stopped state (may be NULL)
63 */
64 void (*stop)();
65 /**
66 * Save the module state to the FILE stream. May be NULL, in which case
67 * the module is considered to have no state.
68 */
69 void (*save)(FILE *);
70 /**
71 * Load the saved module state from the FILE stream. May be NULL, in which
72 * case reset() will be called instead.
73 * @return 0 on success, nonzero on failure.
74 */
75 int (*load)(FILE *);
76 } *dreamcast_module_t;
78 void dreamcast_register_module( dreamcast_module_t );
80 extern struct dreamcast_module mem_module;
81 extern struct dreamcast_module sh4_module;
82 extern struct dreamcast_module asic_module;
83 extern struct dreamcast_module pvr2_module;
84 extern struct dreamcast_module aica_module;
85 extern struct dreamcast_module ide_module;
86 extern struct dreamcast_module maple_module;
87 extern struct dreamcast_module pvr2_module;
88 extern struct dreamcast_module gui_module;
89 extern struct dreamcast_module unknown_module;
91 /*************************** Logging **************************/
93 #define EMIT_FATAL 0
94 #define EMIT_ERR 1
95 #define EMIT_WARN 2
96 #define EMIT_INFO 3
97 #define EMIT_DEBUG 4
98 #define EMIT_TRACE 5
100 #ifndef MODULE
101 #define MODULE unknown_module
102 #endif
104 void emit( void *, int level, const char *source, const char *msg, ... );
106 #define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE.name, __VA_ARGS__ )
107 #define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE.name, __VA_ARGS__ )
108 #define WARN( ... ) emit( NULL, EMIT_WARN, MODULE.name, __VA_ARGS__ )
109 #define INFO( ... ) emit( NULL, EMIT_INFO, MODULE.name, __VA_ARGS__ )
110 #define DEBUG( ... ) emit( NULL, EMIT_DEBUG, MODULE.name, __VA_ARGS__ )
111 #define TRACE( ... ) emit( NULL, EMIT_TRACE, MODULE.name, __VA_ARGS__ )
113 void fwrite_string( char *s, FILE *f );
114 int fread_string( char *s, int maxlen, FILE *f );
115 void fwrite_dump( unsigned char *buf, unsigned int length, FILE *f );
117 #ifndef max
118 #define max(a,b) ( (a) > (b) ? (a) : (b) )
119 #endif
121 #ifdef __cplusplus
122 }
123 #endif
124 #endif
.