~ubuntu-branches/ubuntu/lucid/fceux/lucid

« back to all changes in this revision

Viewing changes to fceu/src/driver.h

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-12-14 08:05:17 UTC
  • Revision ID: james.westby@ubuntu.com-20091214080517-abi5tj8avthfan7c
Tags: upstream-2.1.2+repack
ImportĀ upstreamĀ versionĀ 2.1.2+repack

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __DRIVER_H_
 
2
#define __DRIVER_H_
 
3
 
 
4
#include <stdio.h>
 
5
#include <string>
 
6
#include <iosfwd>
 
7
 
 
8
#include "types.h"
 
9
#include "git.h"
 
10
#include "file.h"
 
11
 
 
12
FILE *FCEUD_UTF8fopen(const char *fn, const char *mode);
 
13
inline FILE *FCEUD_UTF8fopen(const std::string &n, const char *mode) { return FCEUD_UTF8fopen(n.c_str(),mode); }
 
14
std::fstream* FCEUD_UTF8_fstream(const char *n, const char *m);
 
15
inline std::fstream* FCEUD_UTF8_fstream(const std::string &n, const char *m) { return FCEUD_UTF8_fstream(n.c_str(),m); }
 
16
FCEUFILE* FCEUD_OpenArchiveIndex(ArchiveScanRecord& asr, std::string& fname, int innerIndex);
 
17
FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, std::string* innerFilename);
 
18
ArchiveScanRecord FCEUD_ScanArchive(std::string fname);
 
19
 
 
20
//mbg 7/23/06
 
21
const char *FCEUD_GetCompilerString();
 
22
 
 
23
//This makes me feel dirty for some reason.
 
24
void FCEU_printf(char *format, ...);
 
25
#define FCEUI_printf FCEU_printf
 
26
 
 
27
//Video interface
 
28
void FCEUD_SetPalette(uint8 index, uint8 r, uint8 g, uint8 b);
 
29
void FCEUD_GetPalette(uint8 i,uint8 *r, uint8 *g, uint8 *b);
 
30
 
 
31
//Displays an error.  Can block or not.
 
32
void FCEUD_PrintError(const char *s);
 
33
void FCEUD_Message(const char *s);
 
34
 
 
35
//Network interface
 
36
 
 
37
//Call only when a game is loaded.
 
38
int FCEUI_NetplayStart(int nlocal, int divisor);
 
39
 
 
40
// Call when network play needs to stop.
 
41
void FCEUI_NetplayStop(void);
 
42
 
 
43
//Note:  YOU MUST NOT CALL ANY FCEUI_* FUNCTIONS WHILE IN FCEUD_SendData() or FCEUD_RecvData().
 
44
 
 
45
//Return 0 on failure, 1 on success.
 
46
int FCEUD_SendData(void *data, uint32 len);
 
47
int FCEUD_RecvData(void *data, uint32 len);
 
48
 
 
49
//Display text received over the network.
 
50
void FCEUD_NetplayText(uint8 *text);
 
51
 
 
52
//Encode and send text over the network.
 
53
void FCEUI_NetplayText(uint8 *text);
 
54
 
 
55
//Called when a fatal error occurred and network play can't continue.  This function
 
56
//should call FCEUI_NetplayStop() after it has deinitialized the network on the driver
 
57
//side.
 
58
void FCEUD_NetworkClose(void);
 
59
 
 
60
bool FCEUI_BeginWaveRecord(const char *fn);
 
61
int FCEUI_EndWaveRecord(void);
 
62
 
 
63
void FCEUI_ResetNES(void);
 
64
void FCEUI_PowerNES(void);
 
65
 
 
66
void FCEUI_NTSCSELHUE(void);
 
67
void FCEUI_NTSCSELTINT(void);
 
68
void FCEUI_NTSCDEC(void);
 
69
void FCEUI_NTSCINC(void);
 
70
void FCEUI_GetNTSCTH(int *tint, int *hue);
 
71
void FCEUI_SetNTSCTH(int n, int tint, int hue);
 
72
 
 
73
void FCEUI_SetInput(int port, ESI type, void *ptr, int attrib);
 
74
void FCEUI_SetInputFC(ESIFC type, void *ptr, int attrib);
 
75
 
 
76
//tells the emulator whether a fourscore is attached
 
77
void FCEUI_SetInputFourscore(bool attachFourscore);
 
78
//tells whether a fourscore is attached
 
79
bool FCEUI_GetInputFourscore();
 
80
 
 
81
void FCEUI_UseInputPreset(int preset);
 
82
 
 
83
 
 
84
//New interface functions
 
85
 
 
86
//0 to order screen snapshots numerically(0.png), 1 to order them file base-numerically(smb3-0.png).
 
87
//this variable isn't used at all, snap is always name-based
 
88
//void FCEUI_SetSnapName(bool a);
 
89
 
 
90
//0 to keep 8-sprites limitation, 1 to remove it
 
91
void FCEUI_DisableSpriteLimitation(int a);
 
92
 
 
93
void FCEUI_SetRenderPlanes(bool sprites, bool bg);
 
94
void FCEUI_GetRenderPlanes(bool& sprites, bool& bg);
 
95
 
 
96
//name=path and file to load.  returns null if it failed
 
97
FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode);
 
98
 
 
99
//same as FCEUI_LoadGame, except that it can load from a tempfile. 
 
100
//name is the logical path to open; archiveFilename is the archive which contains name
 
101
FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode);
 
102
 
 
103
//general purpose emulator initialization. returns true if successful
 
104
bool FCEUI_Initialize();
 
105
 
 
106
//Emulates a frame.
 
107
void FCEUI_Emulate(uint8 **, int32 **, int32 *, int);
 
108
 
 
109
//Closes currently loaded game
 
110
void FCEUI_CloseGame(void);
 
111
 
 
112
//Deallocates all allocated memory.  Call after FCEUI_Emulate() returns.
 
113
void FCEUI_Kill(void);
 
114
 
 
115
//Enable/Disable game genie. a=true->enabled
 
116
void FCEUI_SetGameGenie(bool a);
 
117
 
 
118
//Set video system a=0 NTSC, a=1 PAL
 
119
void FCEUI_SetVidSystem(int a);
 
120
 
 
121
//Convenience function; returns currently emulated video system(0=NTSC, 1=PAL).
 
122
int FCEUI_GetCurrentVidSystem(int *slstart, int *slend);
 
123
 
 
124
#ifdef FRAMESKIP
 
125
/* Should be called from FCEUD_BlitScreen().  Specifies how many frames
 
126
   to skip until FCEUD_BlitScreen() is called.  FCEUD_BlitScreenDummy()
 
127
   will be called instead of FCEUD_BlitScreen() when when a frame is skipped.
 
128
*/
 
129
void FCEUI_FrameSkip(int x);
 
130
#endif
 
131
 
 
132
//First and last scanlines to render, for ntsc and pal emulation.
 
133
void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall);
 
134
 
 
135
//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory.
 
136
void FCEUI_SetBaseDirectory(std::string const & dir);
 
137
 
 
138
//Tells FCE Ultra to copy the palette data pointed to by pal and use it.
 
139
//Data pointed to by pal needs to be 64*3 bytes in length.
 
140
void FCEUI_SetPaletteArray(uint8 *pal);
 
141
 
 
142
//Sets up sound code to render sound at the specified rate, in samples
 
143
//per second.  Only sample rates of 44100, 48000, and 96000 are currently supported.
 
144
//If "Rate" equals 0, sound is disabled.
 
145
void FCEUI_Sound(int Rate);
 
146
void FCEUI_SetSoundVolume(uint32 volume);
 
147
void FCEUI_SetTriangleVolume(uint32 volume);
 
148
void FCEUI_SetSquare1Volume(uint32 volume);
 
149
void FCEUI_SetSquare2Volume(uint32 volume);
 
150
void FCEUI_SetNoiseVolume(uint32 volume);
 
151
void FCEUI_SetPCMVolume(uint32 volume);
 
152
 
 
153
void FCEUI_SetSoundQuality(int quality);
 
154
 
 
155
void FCEUD_SoundToggle(void);
 
156
void FCEUD_SoundVolumeAdjust(int);
 
157
 
 
158
int FCEUI_SelectState(int, int);
 
159
extern void FCEUI_SelectStateNext(int);
 
160
 
 
161
//"fname" overrides the default save state filename code if non-NULL.
 
162
void FCEUI_SaveState(const char *fname);
 
163
void FCEUI_LoadState(const char *fname);
 
164
 
 
165
void FCEUD_SaveStateAs(void);
 
166
void FCEUD_LoadStateFrom(void);
 
167
 
 
168
//at the minimum, you should call FCEUI_SetInput, FCEUI_SetInputFC, and FCEUI_SetInputFourscore
 
169
//you may also need to maintain your own internal state
 
170
void FCEUD_SetInput(bool fourscore, ESI port0, ESI port1, ESIFC fcexp);
 
171
 
 
172
 
 
173
void FCEUD_MovieRecordTo(void);
 
174
void FCEUD_MovieReplayFrom(void);
 
175
void FCEUD_LuaRunFrom(void);
 
176
 
 
177
int32 FCEUI_GetDesiredFPS(void);
 
178
void FCEUI_SaveSnapshot(void);
 
179
void FCEU_DispMessage(char *format, ...);
 
180
#define FCEUI_DispMessage FCEU_DispMessage
 
181
 
 
182
int FCEUI_DecodePAR(const char *code, int *a, int *v, int *c, int *type);
 
183
int FCEUI_DecodeGG(const char *str, int *a, int *v, int *c);
 
184
int FCEUI_AddCheat(const char *name, uint32 addr, uint8 val, int compare, int type);
 
185
int FCEUI_DelCheat(uint32 which);
 
186
int FCEUI_ToggleCheat(uint32 which);
 
187
 
 
188
int32 FCEUI_CheatSearchGetCount(void);
 
189
void FCEUI_CheatSearchGetRange(uint32 first, uint32 last, int (*callb)(uint32 a, uint8 last, uint8 current));
 
190
void FCEUI_CheatSearchGet(int (*callb)(uint32 a, uint8 last, uint8 current, void *data), void *data);
 
191
void FCEUI_CheatSearchBegin(void);
 
192
void FCEUI_CheatSearchEnd(int type, uint8 v1, uint8 v2);
 
193
void FCEUI_ListCheats(int (*callb)(char *name, uint32 a, uint8 v, int compare, int s, int type, void *data), void *data);
 
194
 
 
195
int FCEUI_GetCheat(uint32 which, char **name, uint32 *a, uint8 *v, int *compare, int *s, int *type);
 
196
int FCEUI_SetCheat(uint32 which, const char *name, int32 a, int32 v, int compare,int s, int type);
 
197
 
 
198
void FCEUI_CheatSearchShowExcluded(void);
 
199
void FCEUI_CheatSearchSetCurrentAsOriginal(void);
 
200
 
 
201
//.rom
 
202
#define FCEUIOD_ROMS    0       //Roms
 
203
#define FCEUIOD_NV      1       //NV = nonvolatile. save data.  
 
204
#define FCEUIOD_STATES  2       //savestates    
 
205
#define FCEUIOD_FDSROM  3       //disksys.rom
 
206
#define FCEUIOD_SNAPS   4       //screenshots
 
207
#define FCEUIOD_CHEATS  5       //cheats
 
208
#define FCEUIOD_MOVIES  6       //.fm2 files
 
209
#define FCEUIOD_MEMW    7       //memory watch fiels
 
210
#define FCEUIOD_BBOT    8       //basicbot, obsolete
 
211
#define FCEUIOD_MACRO   9       //macro files - tasedit, currently not implemented
 
212
#define FCEUIOD_INPUT   10      //input presets
 
213
#define FCEUIOD_LUA     11      //lua scripts
 
214
#define FCEUIOD_AVI             12      //default file for avi output
 
215
#define FCEUIOD__COUNT  13      //base directory override?
 
216
 
 
217
void FCEUI_SetDirOverride(int which, char *n);
 
218
 
 
219
void FCEUI_MemDump(uint16 a, int32 len, void (*callb)(uint16 a, uint8 v));
 
220
uint8 FCEUI_MemSafePeek(uint16 A);
 
221
void FCEUI_MemPoke(uint16 a, uint8 v, int hl);
 
222
void FCEUI_NMI(void);
 
223
void FCEUI_IRQ(void);
 
224
uint16 FCEUI_Disassemble(void *XA, uint16 a, char *stringo);
 
225
void FCEUI_GetIVectors(uint16 *reset, uint16 *irq, uint16 *nmi);
 
226
 
 
227
uint32 FCEUI_CRC32(uint32 crc, uint8 *buf, uint32 len);
 
228
 
 
229
void FCEUI_ToggleTileView(void);
 
230
void FCEUI_SetLowPass(int q);
 
231
 
 
232
void FCEUI_NSFSetVis(int mode);
 
233
int FCEUI_NSFChange(int amount);
 
234
int FCEUI_NSFGetInfo(uint8 *name, uint8 *artist, uint8 *copyright, int maxlen);
 
235
 
 
236
void FCEUI_VSUniToggleDIPView(void);
 
237
void FCEUI_VSUniToggleDIP(int w);
 
238
uint8 FCEUI_VSUniGetDIPs(void);
 
239
void FCEUI_VSUniSetDIP(int w, int state);
 
240
void FCEUI_VSUniCoin(void);
 
241
 
 
242
void FCEUI_FDSInsert(void); //mbg merge 7/17/06 changed to void fn(void) to make it an EMUCMDFN
 
243
//int FCEUI_FDSEject(void);
 
244
void FCEUI_FDSSelect(void);
 
245
 
 
246
int FCEUI_DatachSet(const uint8 *rcode);
 
247
 
 
248
///returns a flag indicating whether emulation is paused
 
249
int FCEUI_EmulationPaused();
 
250
///returns a flag indicating whether a one frame step has been requested
 
251
int FCEUI_EmulationFrameStepped();
 
252
///clears the framestepped flag. use it after youve stepped your one frame
 
253
void FCEUI_ClearEmulationFrameStepped();
 
254
///sets the EmulationPaused flags
 
255
void FCEUI_SetEmulationPaused(int val);
 
256
///toggles the paused bit (bit0) for EmulationPaused. caused FCEUD_DebugUpdate() to fire if the emulation pauses
 
257
void FCEUI_ToggleEmulationPause();
 
258
 
 
259
//indicates whether input aids should be drawn (such as crosshairs, etc; usually in fullscreen mode)
 
260
bool FCEUD_ShouldDrawInputAids();
 
261
 
 
262
///called when the emulator closes a game
 
263
void FCEUD_OnCloseGame(void);
 
264
 
 
265
void FCEUI_FrameAdvance(void);
 
266
void FCEUI_FrameAdvanceEnd(void);
 
267
 
 
268
//AVI Output
 
269
int FCEUI_AviBegin(const char* fname);
 
270
void FCEUI_AviEnd(void);
 
271
void FCEUI_AviVideoUpdate(const unsigned char* buffer);
 
272
void FCEUI_AviSoundUpdate(void* soundData, int soundLen);
 
273
bool FCEUI_AviIsRecording();
 
274
 
 
275
void FCEUD_AviRecordTo(void);
 
276
void FCEUD_AviStop(void);
 
277
 
 
278
///A callback that the emu core uses to poll the state of a given emulator command key
 
279
typedef int TestCommandState(int cmd);
 
280
///Signals the emu core to poll for emulator commands and take actions
 
281
void FCEUI_HandleEmuCommands(TestCommandState* testfn);
 
282
 
 
283
 
 
284
//Emulation speed
 
285
enum EMUSPEED_SET
 
286
{
 
287
        EMUSPEED_SLOWEST=0,
 
288
        EMUSPEED_SLOWER,
 
289
        EMUSPEED_NORMAL,
 
290
        EMUSPEED_FASTER,
 
291
        EMUSPEED_FASTEST
 
292
};
 
293
void FCEUD_SetEmulationSpeed(int cmd);
 
294
void FCEUD_TurboOn(void);
 
295
void FCEUD_TurboOff(void);
 
296
void FCEUD_TurboToggle(void);
 
297
 
 
298
int FCEUD_ShowStatusIcon(void);
 
299
void FCEUD_ToggleStatusIcon(void);
 
300
void FCEUD_HideMenuToggle(void);
 
301
 
 
302
///signals the driver to perform a file open GUI operation
 
303
void FCEUD_CmdOpen(void);
 
304
 
 
305
//new merge-era driver routines here:
 
306
 
 
307
///signals that the cpu core hit a breakpoint. this function should not return until the core is ready for the next cycle
 
308
void FCEUD_DebugBreakpoint();
 
309
 
 
310
///the driver should log the current instruction, if it wants (we should move the code in the win driver that does this to the shared area)
 
311
void FCEUD_TraceInstruction();
 
312
 
 
313
///the driver might should update its NTView (only used if debugging support is compiled in)
 
314
void FCEUD_UpdateNTView(int scanline, bool drawall);
 
315
 
 
316
///the driver might should update its PPUView (only used if debugging support is compiled in)
 
317
void FCEUD_UpdatePPUView(int scanline, int drawall);
 
318
 
 
319
///I am dissatisfied with this method of getting an option from the driver to the core. but that is what we're using for now
 
320
bool FCEUD_PauseAfterPlayback();
 
321
 
 
322
///called when fceu changes something in the video system you might be interested in
 
323
void FCEUD_VideoChanged();
 
324
 
 
325
enum EFCEUI
 
326
{
 
327
        FCEUI_STOPAVI, FCEUI_QUICKSAVE, FCEUI_QUICKLOAD, FCEUI_SAVESTATE, FCEUI_LOADSTATE,
 
328
        FCEUI_NEXTSAVESTATE,FCEUI_PREVIOUSSAVESTATE,FCEUI_VIEWSLOTS,
 
329
        FCEUI_STOPMOVIE, FCEUI_RECORDMOVIE, FCEUI_PLAYMOVIE,
 
330
        FCEUI_OPENGAME, FCEUI_CLOSEGAME,
 
331
        FCEUI_TASEDIT,
 
332
        FCEUI_RESET, FCEUI_POWER,FCEUI_PLAYFROMBEGINNING
 
333
};
 
334
 
 
335
//checks whether an EFCEUI is valid right now
 
336
bool FCEU_IsValidUI(EFCEUI ui);
 
337
 
 
338
#ifdef __cplusplus
 
339
extern "C"
 
340
#endif
 
341
FILE *FCEUI_UTF8fopen_C(const char *n, const char *m);
 
342
 
 
343
#endif //__DRIVER_H_