Search
lxdream.org :: lxdream/src/dream.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/dream.h
changeset 561:533f6b478071
prev495:4db4702b0778
next736:a02d1475ccfd
author nkeynes
date Tue Jan 01 05:08:38 2008 +0000 (12 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Enable Id keyword on all source files
file annotate diff log raw
nkeynes@31
     1
/**
nkeynes@561
     2
 * $Id$
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@477
    26
#include "lxdream.h"
nkeynes@2
    27
nkeynes@1
    28
#ifdef __cplusplus
nkeynes@1
    29
extern "C" {
nkeynes@1
    30
#endif
nkeynes@35
    31
nkeynes@35
    32
/************************ Modules ********************************/
nkeynes@35
    33
/**
nkeynes@35
    34
 * Basic module structure defining the common operations across all
nkeynes@35
    35
 * modules, ie start, stop, reset, etc. 
nkeynes@35
    36
 */
nkeynes@35
    37
typedef struct dreamcast_module {
nkeynes@35
    38
    char *name;
nkeynes@35
    39
    /**
nkeynes@35
    40
     * Perform all initial module setup (ie register / allocate any
nkeynes@180
    41
     * memory required, etc). Only called once during system startup
nkeynes@35
    42
     */
nkeynes@35
    43
    void (*init)();
nkeynes@35
    44
    /**
nkeynes@35
    45
     * Reset the module into it's initial system boot state. Will be called
nkeynes@35
    46
     * once after init(), as well as whenever the user requests a reset.
nkeynes@35
    47
     */
nkeynes@35
    48
    void (*reset)();
nkeynes@35
    49
    /**
nkeynes@35
    50
     * Set the module into a running state (may be NULL)
nkeynes@35
    51
     */
nkeynes@35
    52
    void (*start)();
nkeynes@35
    53
    /**
nkeynes@35
    54
     * Execute one time-slice worth of operations, for the given number of
nkeynes@35
    55
     * nanoseconds.
nkeynes@35
    56
     * @return Number of nanoseconds actually executed
nkeynes@35
    57
     */
nkeynes@35
    58
    uint32_t (*run_time_slice)( uint32_t nanosecs );
nkeynes@35
    59
    /**
nkeynes@35
    60
     * Set the module into a stopped state (may be NULL)
nkeynes@35
    61
     */
nkeynes@35
    62
    void (*stop)();
nkeynes@35
    63
    /**
nkeynes@35
    64
     * Save the module state to the FILE stream. May be NULL, in which case
nkeynes@35
    65
     * the module is considered to have no state.
nkeynes@35
    66
     */
nkeynes@35
    67
    void (*save)(FILE *);
nkeynes@35
    68
    /**
nkeynes@35
    69
     * Load the saved module state from the FILE stream. May be NULL, in which
nkeynes@35
    70
     * case reset() will be called instead.
nkeynes@35
    71
     * @return 0 on success, nonzero on failure.
nkeynes@35
    72
     */
nkeynes@35
    73
    int (*load)(FILE *);
nkeynes@35
    74
} *dreamcast_module_t;
nkeynes@35
    75
nkeynes@35
    76
void dreamcast_register_module( dreamcast_module_t );
nkeynes@35
    77
nkeynes@35
    78
extern struct dreamcast_module mem_module;
nkeynes@35
    79
extern struct dreamcast_module sh4_module;
nkeynes@35
    80
extern struct dreamcast_module asic_module;
nkeynes@35
    81
extern struct dreamcast_module pvr2_module;
nkeynes@35
    82
extern struct dreamcast_module aica_module;
nkeynes@35
    83
extern struct dreamcast_module ide_module;
nkeynes@35
    84
extern struct dreamcast_module maple_module;
nkeynes@35
    85
extern struct dreamcast_module pvr2_module;
nkeynes@35
    86
extern struct dreamcast_module gui_module;
nkeynes@265
    87
extern struct dreamcast_module eventq_module;
nkeynes@35
    88
extern struct dreamcast_module unknown_module;
nkeynes@35
    89
nkeynes@422
    90
void fwrite_string( const char *s, FILE *f );
nkeynes@35
    91
int fread_string( char *s, int maxlen, FILE *f );
nkeynes@477
    92
void fwrite_gzip( void *p, size_t size, size_t num, FILE *f );
nkeynes@477
    93
int fread_gzip( void *p, size_t size, size_t num, FILE *f );
nkeynes@220
    94
void fwrite_dump( unsigned char *buf, unsigned int length, FILE *f );
nkeynes@220
    95
void fwrite_dump32( unsigned int *buf, unsigned int length, FILE *f );
nkeynes@220
    96
void fwrite_dump32v( unsigned int *buf, unsigned int length, int wordsPerLine, FILE *f );
nkeynes@35
    97
nkeynes@495
    98
void install_crash_handler(void);
nkeynes@495
    99
nkeynes@477
   100
gboolean write_png_to_stream( FILE *f, frame_buffer_t );
nkeynes@477
   101
frame_buffer_t read_png_from_stream( FILE *f );
nkeynes@135
   102
nkeynes@1
   103
#ifdef __cplusplus
nkeynes@1
   104
}
nkeynes@1
   105
#endif
nkeynes@1
   106
#endif
.