Search
lxdream.org :: lxdream/src/modules.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/modules.h
changeset 30:89b30313d757
prev27:1ef09a52cd1e
author nkeynes
date Sun Dec 25 05:57:00 2005 +0000 (15 years ago)
permissions -rw-r--r--
last change Change timeslice to nanoseconds (was microseconds)
Generize single step (now steps through active CPU)
Add lots of header blocks
file annotate diff log raw
nkeynes@30
     1
/**
nkeynes@30
     2
 * $Id: modules.h,v 1.5 2005-12-25 05:56:55 nkeynes Exp $
nkeynes@30
     3
 * 
nkeynes@30
     4
 * Internal dreamcast module structure definition and associated variables.
nkeynes@30
     5
 * Included by all module implementations
nkeynes@30
     6
 *
nkeynes@30
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@30
     8
 *
nkeynes@30
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@30
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@30
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@30
    12
 * (at your option) any later version.
nkeynes@30
    13
 *
nkeynes@30
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@30
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@30
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@30
    17
 * GNU General Public License for more details.
nkeynes@30
    18
 */
nkeynes@15
    19
nkeynes@15
    20
#ifndef dreamcast_modules_H
nkeynes@15
    21
#define dreamcast_modules_H 1
nkeynes@15
    22
nkeynes@30
    23
#include <stdint.h>
nkeynes@15
    24
#include <stdlib.h>
nkeynes@15
    25
#include <stdio.h>
nkeynes@15
    26
nkeynes@15
    27
#ifdef __cplusplus
nkeynes@15
    28
extern "C" {
nkeynes@15
    29
#endif
nkeynes@15
    30
nkeynes@15
    31
/**
nkeynes@15
    32
 * Basic module structure defining the common operations across all
nkeynes@15
    33
 * modules, ie start, stop, reset, etc. Nothing here is time-sensitive.
nkeynes@15
    34
 */
nkeynes@15
    35
typedef struct dreamcast_module {
nkeynes@15
    36
    char *name;
nkeynes@15
    37
    /**
nkeynes@15
    38
     * Perform all initial module setup (ie register / allocate any
nkeynes@15
    39
     * memory required, etc). Only called once during DreamOn startup
nkeynes@15
    40
     */
nkeynes@15
    41
    void (*init)();
nkeynes@15
    42
    /**
nkeynes@15
    43
     * Reset the module into it's initial system boot state. Will be called
nkeynes@15
    44
     * once after init(), as well as whenever the user requests a reset.
nkeynes@15
    45
     */
nkeynes@15
    46
    void (*reset)();
nkeynes@15
    47
    /**
nkeynes@15
    48
     * Set the module into a running state (may be NULL)
nkeynes@15
    49
     */
nkeynes@15
    50
    void (*start)();
nkeynes@15
    51
    /**
nkeynes@23
    52
     * Execute one time-slice worth of operations, for the given number of
nkeynes@30
    53
     * nanoseconds.
nkeynes@30
    54
     * @return Number of nanoseconds actually executed
nkeynes@23
    55
     */
nkeynes@30
    56
    uint32_t (*run_time_slice)( uint32_t nanosecs );
nkeynes@23
    57
    /**
nkeynes@15
    58
     * Set the module into a stopped state (may be NULL)
nkeynes@15
    59
     */
nkeynes@15
    60
    void (*stop)();
nkeynes@15
    61
    /**
nkeynes@15
    62
     * Save the module state to the FILE stream. May be NULL, in which case
nkeynes@15
    63
     * the module is considered to have no state.
nkeynes@15
    64
     */
nkeynes@15
    65
    void (*save)(FILE *);
nkeynes@15
    66
    /**
nkeynes@15
    67
     * Load the saved module state from the FILE stream. May be NULL, in which
nkeynes@15
    68
     * case reset() will be called instead.
nkeynes@17
    69
     * @return 0 on success, nonzero on failure.
nkeynes@15
    70
     */
nkeynes@17
    71
    int (*load)(FILE *);
nkeynes@15
    72
} *dreamcast_module_t;
nkeynes@15
    73
nkeynes@15
    74
void dreamcast_register_module( dreamcast_module_t );
nkeynes@15
    75
nkeynes@15
    76
extern struct dreamcast_module mem_module;
nkeynes@15
    77
extern struct dreamcast_module sh4_module;
nkeynes@15
    78
extern struct dreamcast_module asic_module;
nkeynes@15
    79
extern struct dreamcast_module pvr2_module;
nkeynes@15
    80
extern struct dreamcast_module aica_module;
nkeynes@15
    81
extern struct dreamcast_module ide_module;
nkeynes@15
    82
extern struct dreamcast_module maple_module;
nkeynes@15
    83
extern struct dreamcast_module pvr2_module;
nkeynes@15
    84
extern struct dreamcast_module gui_module;
nkeynes@15
    85
nkeynes@17
    86
void fwrite_string( char *s, FILE *f );
nkeynes@17
    87
int fread_string( char *s, int maxlen, FILE *f );
nkeynes@17
    88
nkeynes@15
    89
#ifdef __cplusplus
nkeynes@15
    90
}
nkeynes@15
    91
#endif
nkeynes@15
    92
nkeynes@15
    93
#endif /* !dreamcast_modules_H */
.