~ubuntu-branches/ubuntu/precise/mupen64plus/precise

« back to all changes in this revision

Viewing changes to main/romcache.h

  • Committer: Bazaar Package Importer
  • Author(s): Sven Eckelmann
  • Date: 2009-09-08 22:17:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090908221700-yela0ckgc1xwiqtn
Tags: upstream-1.5+dfsg1
ImportĀ upstreamĀ versionĀ 1.5+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 
2
 *   Mupen64plus - romcache.h                                              *
 
3
 *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
 
4
 *   Copyright (C) 2008 Tillin9                                            *
 
5
 *                                                                         *
 
6
 *   This program is free software; you can redistribute it and/or modify  *
 
7
 *   it under the terms of the GNU General Public License as published by  *
 
8
 *   the Free Software Foundation; either version 2 of the License, or     *
 
9
 *   (at your option) any later version.                                   *
 
10
 *                                                                         *
 
11
 *   This program is distributed in the hope that it will be useful,       *
 
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
14
 *   GNU General Public License for more details.                          *
 
15
 *                                                                         *
 
16
 *   You should have received a copy of the GNU General Public License     *
 
17
 *   along with this program; if not, write to the                         *
 
18
 *   Free Software Foundation, Inc.,                                       *
 
19
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 
20
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
21
 
 
22
#ifndef __ROMCACHE_H__
 
23
#define __ROMCACHE_H__
 
24
 
 
25
#include <limits.h> 
 
26
#include "md5.h"
 
27
 
 
28
#define COMMENT_MAXLENGTH 256
 
29
 
 
30
/* The romdatabase contains the items mupen64plus indexes for each rom. These
 
31
 * include the goodname (from the GoodN64 project), the current status of the rom
 
32
 * in mupen, the N64 savetype used in the original cartridge (often necessary for
 
33
 * booting the rom in mupen), the number of players (including netplay options),
 
34
 * and whether the rom can make use of the N64's rumble feature. Md5, crc1, and
 
35
 * crc2 used for rom lookup. Md5s are unique hashes of the ENTIRE rom. Crcs are not
 
36
 * unique and read from the rom header, meaning corrupt crcs are also a problem.
 
37
 * Crcs were widely used (mainly in the cheat system). Refmd5s allows for a smaller
 
38
 * database file and need not be used outside database loading.
 
39
 */
 
40
typedef struct
 
41
{
 
42
   char* goodname;
 
43
   md5_byte_t md5[16];
 
44
   md5_byte_t* refmd5;
 
45
   unsigned int crc1;
 
46
   unsigned int crc2;
 
47
   unsigned char status; /* Rom status on a scale from 0-5. */
 
48
   unsigned char savetype;
 
49
   unsigned char players; /* Local players 0-4, 2/3/4 way Netplay indicated by 5/6/7. */
 
50
   unsigned char rumble; /* 0 - No, 1 - Yes boolean for rumble support. */
 
51
} romdatabase_entry;
 
52
 
 
53
typedef struct _romdatabase_search
 
54
{
 
55
    romdatabase_entry entry;
 
56
    struct _romdatabase_search* next_entry;
 
57
    struct _romdatabase_search* next_crc;
 
58
    struct _romdatabase_search* next_md5;
 
59
} romdatabase_search;
 
60
 
 
61
typedef struct
 
62
{
 
63
    char* comment;
 
64
    romdatabase_search* crc_lists[256];
 
65
    romdatabase_search* md5_lists[256];
 
66
    romdatabase_search* list;
 
67
} _romdatabase;
 
68
 
 
69
extern romdatabase_entry empty_entry;
 
70
 
 
71
void romdatabase_open(void);
 
72
void romdatabase_close(void);
 
73
romdatabase_entry* ini_search_by_md5(md5_byte_t* md5);
 
74
/* Should be used by current cheat system (isn't), when cheat system is
 
75
 * migrated to md5s, will be fully depreciated.
 
76
 */
 
77
romdatabase_entry* ini_search_by_crc(unsigned int crc1, unsigned int crc2);
 
78
 
 
79
#ifndef NO_GUI
 
80
/* See http://code.google.com/p/mupen64plus/wiki/RomBrowserColumns for details. */
 
81
typedef struct _cache_entry
 
82
{
 
83
    md5_byte_t md5[16];
 
84
    time_t timestamp;
 
85
    char filename[PATH_MAX];
 
86
    char usercomments[COMMENT_MAXLENGTH]; 
 
87
    char internalname[81]; /* Needs to be 4 times +1 (for '\0') for UTF8 conversion. */
 
88
    unsigned char compressiontype; /* Enum for compression type. */
 
89
    unsigned char imagetype; /* Enum for original rom image type. */
 
90
    unsigned char cic; /* N64 boot chip, determined from rom. */
 
91
    unsigned short countrycode; /* Found in rom header. */
 
92
    unsigned int archivefile; /* 0 indexed file number in multirom archive. */
 
93
    unsigned int crc1;
 
94
    unsigned int crc2;
 
95
    int romsize;
 
96
    romdatabase_entry* inientry; /* Persistent pointer to romdatabase.  */
 
97
    struct _cache_entry* next;
 
98
} cache_entry;
 
99
 
 
100
enum
 
101
{
 
102
    RCS_INIT = 1,
 
103
    RCS_RESCAN,
 
104
    RCS_SLEEP,
 
105
    RCS_BUSY,
 
106
    RCS_SHUTDOWN,
 
107
    RCS_WRITE_CACHE /* For quickly saving user comments from GUI frontend. */
 
108
};
 
109
 
 
110
typedef struct
 
111
{
 
112
    unsigned int length; 
 
113
    unsigned char rcstask;  /* Enum for what rcs thread should do. */
 
114
    unsigned char rcspause; /* Bool for pausing after last file, toggled by start/stopping emulation. */
 
115
    unsigned char clear;    /* Bool for clearing on an update. */
 
116
    cache_entry* top;
 
117
    cache_entry* last;
 
118
} rom_cache;
 
119
 
 
120
extern rom_cache g_romcache;
 
121
 
 
122
int rom_cache_system(void* _arg);
 
123
#endif /* NO_GUI */
 
124
 
 
125
#endif /* __ROMCACHE_H__ */
 
126