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