summaryrefslogtreecommitdiff
path: root/src/menu.h
blob: c0d102dcd7c35f8c9f2e782f836ee6090638c2b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
#ifndef _MENU_H_
#define _MENU_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <dirent.h>
#include <errno.h>

#ifdef __GIZ__
#define DIR_SEP	"\\"
#define DIR_SEP_BAD "/"	
#define SYSTEM_DIR		"\\SD Card\\DrPocketSnes"
#else
	#ifdef __GP2X__
		#include "gp2x_sdk.h"
	#endif
	#ifdef __WIZ__
	 	#ifdef __CAANOO__
			#include "caanoo_sdk.h"
		#else
			#include "wiz_sdk.h"
		#endif
	#endif

	#define DIR_SEP	"/"
	#define DIR_SEP_BAD "\\"	
	#define SYSTEM_DIR		"/mnt/sd/DrPocketSnes"
#endif

#define SNES_OPTIONS_DIR		"options"
#define SNES_SRAM_DIR			"sram"
#define SNES_SAVESTATE_DIR		"savestate"

#define ROM_LIST_FILENAME			"romlist.bin"
#define SRAM_FILE_EXT				"srm"
#define SAVESTATE_EXT				"sv"
#define MENU_OPTIONS_FILENAME		"menu"
#define MENU_OPTIONS_EXT			"opt"
#define DEFAULT_ROM_DIR_FILENAME	"romdir"
#define DEFAULT_ROM_DIR_EXT			"opt"


//define emulation modes
#define EMU_MODE_NONE	0
#define EMU_MODE_SNES 	1

#define SAVESTATE_MODE_SAVE				0
#define SAVESTATE_MODE_LOAD				1
#define SAVESTATE_MODE_DELETE			2

#define SNES_OPTIONS_VER 			1
#define PSVER	"7.2.0"
#ifdef ASMCPU
	#define DRSNES_VERSION				"v " PSVER " fast"
#else
	#define DRSNES_VERSION				"v " PSVER " compatible"
#endif

#define ROM_SIZE 		0x500000 //ssf2(40mbits)
#define MENU_RGB(r,g,b) 		((r) << 11 | (g) << 6 | (b) << 0 )
#define COLOR_TITLE		MENU_RGB(31, 0, 0)
#define COLOR_FOCUS		MENU_RGB(0, 0, 0)
#define COLOR_ITEM		MENU_RGB(31, 31, 31)
#define COLOR_VERSION		MENU_RGB(0, 0, 31)
#define MAX_ROMS		3000
#define MAX_CPU			39
#ifndef MAX_PATH
#define MAX_PATH    			255
#endif

#if defined(__WIZ__)
	#ifdef	__CAANOO__
		#define MENU_CPU_SPEED 			300
	#else
		#define MENU_CPU_SPEED 			120
	#endif
	#define MENU_FAST_CPU_SPEED		300
#else
	#define MENU_CPU_SPEED 			66
	#define MENU_FAST_CPU_SPEED		200
#endif
enum  FILE_TYPE_ENUM
{
	FILE_TYPE_FILE = 0,
	FILE_TYPE_DIRECTORY
};

enum  MAIN_MENU_ENUM
{
	MAIN_MENU_RETURN = 0,
	MAIN_MENU_ROM_SELECT,
	MAIN_MENU_MANAGE_SAVE_STATE,
	MAIN_MENU_SAVE_SRAM,
	MAIN_MENU_SAVE_SCREENSHOT,
	MAIN_MENU_SNES_OPTIONS,
	MAIN_MENU_RESET_GAME,
	MAIN_MENU_EXIT_APP,
	MAIN_MENU_COUNT
};

enum  LOAD_ROM_ENUM
{
	LOAD_ROM_MENU_SNES = 0,
	LOAD_ROM_MENU_RETURN,
	LOAD_ROM_MENU_COUNT
};

enum SNES_MENU_ENUM
{
	SNES_MENU_SOUND = 0,
	SNES_MENU_SOUND_RATE,
	SNES_MENU_SOUND_VOL,
	SNES_MENU_FRAMESKIP,
	SNES_MENU_REGION,
	SNES_MENU_FPS,
	SNES_MENU_TRANSPARENCY,
#if defined(__GP2X__)
	SNES_MENU_CPUSPEED,
	SNES_MENU_RENDER_MODE,
	SNES_MENU_GAMMA,
	SNES_MENU_ACTION_BUTTONS,
#endif
#if defined(__WIZ__)
	SNES_MENU_CPUSPEED,
	SNES_MENU_RENDER_MODE,
	SNES_MENU_ACTION_BUTTONS,
#endif
	SNES_MENU_EMULATION_TYPE,
	SNES_MENU_LOAD_ROM_ON_INIT,
	SNES_MENU_ADVANCED_HACKS,
	SNES_MENU_AUTO_SAVE_SRAM,
	SNES_MENU_LOAD_GLOBAL,
	SNES_MENU_SAVE_GLOBAL,
	SNES_MENU_DELETE_GLOBAL,
	SNES_MENU_LOAD_CURRENT,
	SNES_MENU_SAVE_CURRENT,
	SNES_MENU_DELETE_CURRENT,
	SNES_MENU_SET_ROMDIR,
	SNES_MENU_CLEAR_ROMDIR,
	SNES_MENU_RETURN,
	SNES_MENU_COUNT
};

enum SAVESTATE_MENU_ENUM
{
	SAVESTATE_MENU_LOAD = 0,
	SAVESTATE_MENU_SAVE,
	SAVESTATE_MENU_DELETE,
	SAVESTATE_MENU_RETURN,
	SAVESTATE_MENU_COUNT
};

enum HACKS_MENU_ENUM
{
	HACKS_MENU_AUDIO = 0,
	HACKS_MENU_SNESADVANCE_DAT,
#ifdef __OLD_RASTER_FX__
	HACKS_MENU_DELAYED_RASTER_FX,
#endif
	HACKS_MENU_PALETTE,
	HACKS_MENU_FIXEDCOL,
	HACKS_MENU_WINDOW,
	HACKS_MENU_ADDSUB,
	HACKS_MENU_OBJ,
	HACKS_MENU_BG0,
	HACKS_MENU_BG1,
	HACKS_MENU_BG2,
	HACKS_MENU_BG3,
	HACKS_MENU_RETURN,
	HACKS_MENU_COUNT
};

enum SRAM_MENU_ENUM
{
	SRAM_MENU_LOAD = 0,
	SRAM_MENU_SAVE,
	SRAM_MENU_DELETE,
	SRAM_MENU_RETURN,
	SRAM_MENU_COUNT,
};

enum EVENT_TYPES
{
	EVENT_NONE = 0,
	EVENT_EXIT_APP,
	EVENT_LOAD_SNES_ROM,
	EVENT_RUN_SNES_ROM,
	EVENT_RESET_SNES_ROM
};

enum RENDER_MODE_ENUM
{
	RENDER_MODE_UNSCALED = 0,
	RENDER_MODE_SCALED,
	RENDER_MODE_HORIZONTAL_SCALED	
};

#define MENU_TILE_WIDTH      64
#define MENU_TILE_HEIGHT     64

#define GP32_GCC

#ifdef __GIZ__
#define INP_BUTTON_MENU_SELECT			INP_BUTTON_PLAY
#define INP_BUTTON_MENU_CANCEL			INP_BUTTON_STOP
#define INP_BUTTON_MENU_ENTER			INP_BUTTON_BRIGHT
#define INP_BUTTON_MENU_DELETE			INP_BUTTON_REWIND
#define INP_BUTTON_MENU_QUICKSAVE1		INP_BUTTON_R
#define INP_BUTTON_MENU_QUICKSAVE2		INP_BUTTON_BRIGHT
#define INP_BUTTON_MENU_QUICKLOAD1		INP_BUTTON_L
#define INP_BUTTON_MENU_QUICKLOAD2		INP_BUTTON_BRIGHT

//Menu Text
#define MENU_TEXT_LOAD_SAVESTATE 		"Press Play to load"
#define MENU_TEXT_OVERWRITE_SAVESTATE	"Press Play to overwrite"
#define MENU_TEXT_DELETE_SAVESTATE 		"Press Play to delete"
#define MENU_TEXT_PREVIEW_SAVESTATE 	"Press R to preview"
#endif

#if defined(__GP2X__) || defined(__WIZ__)
#define INP_BUTTON_MENU_SELECT			INP_BUTTON_B
#define INP_BUTTON_MENU_CANCEL			INP_BUTTON_X
#define INP_BUTTON_MENU_ENTER			INP_BUTTON_SELECT
#define INP_BUTTON_MENU_DELETE			INP_BUTTON_SELECT
#define INP_BUTTON_MENU_QUICKSAVE1		INP_BUTTON_R
#define INP_BUTTON_MENU_QUICKSAVE2		INP_BUTTON_SELECT
#define INP_BUTTON_MENU_QUICKLOAD1		INP_BUTTON_L
#define INP_BUTTON_MENU_QUICKLOAD2		INP_BUTTON_SELECT


//Menu Text
#define MENU_TEXT_LOAD_SAVESTATE 		"Press B to load"
#define MENU_TEXT_OVERWRITE_SAVESTATE	"Press B to overwrite"
#define MENU_TEXT_DELETE_SAVESTATE 		"Press B to delete"
#define MENU_TEXT_PREVIEW_SAVESTATE 	"Press Y to preview"
#endif

typedef struct {
   char name[MAX_ROMS][MAX_PATH];    //  128 entrys,16 Bytes long
   int size[MAX_ROMS];
} DIRDATA;

//Graphics - moved to objects because they get updated with current gamma setting
extern unsigned short menuHeader[];
extern unsigned short menuHeaderOrig[];
extern unsigned short highLightBar[];
extern unsigned short highLightBarOrig[];
extern unsigned short menuTile[];
extern unsigned short menuTileOrig[];

extern unsigned char padConfig[];
extern float soundRates[];
extern char currentWorkingDir[];
extern char snesOptionsDir[];
extern char snesSramDir[];
extern char snesSaveStateDir[];
extern unsigned char gammaConv[];
extern char lastSaveName[];
extern short *soundBuffer;
extern unsigned char *RomData;
extern int currentEmuMode;
extern int lastStage;
extern int currFB;
extern int prevFB;
extern int saveStateSize;
extern int romLoaded;
extern int frames,taken; // Frames and 60hz ticks
extern char showFps;
extern char soundRate;
extern char soundOn;

void UpdateMenuGraphicsGamma(void);
int RoundDouble(double val);
void ClearScreen(unsigned int *buffer,unsigned int data);
void LoadSram(char *path,char *romname,char *ext,char *srammem);
void SaveSram(char *path,char *romname,char *ext,char *srammem);
void DeleteSram(char *path,char *romname,char *ext);
int SaveMenuOptions(char *path, char *filename, char *ext, char *optionsmem, int maxsize, int showMessage);
int LoadMenuOptions(char *path, char *filename, char *ext, char *optionsmem, int maxsize, int showMessage);
int DeleteMenuOptions(char *path, char *filename, char *ext, int showMessage);
void SnesDefaultMenuOptions(void);
#ifdef __GIZ__
void sync(void);
#endif
// menu.cpp
void MenuPause(void);
void MenuFlip(void);
void SplitFilename(char *wholeFilename, char *filename, char *ext);
void CheckDirSep(char *path);
int FileSelect(int mode);
int MainMenu(int prevAction);
void PrintTitle(int flip);
void PrintTile(int flip);
void PrintBar(int flip, unsigned int givenY);

int FileScan();
extern void loadStateFile(char *filename);
extern int quickSavePresent;
extern unsigned short cpuSpeedLookup[];
extern float gammaLookup[];

extern char currentRomFilename[];
extern char romDir[];
extern char snesRomDir[];

struct SNES_MENU_OPTIONS
{
  unsigned char menuVer;
  unsigned char frameSkip;
  unsigned char soundOn;
  unsigned char cpuSpeed;
  unsigned char padConfig[32];
  unsigned char tripleBuffer;
  unsigned char forceRegion;
  unsigned char showFps;
  signed char gamma;
  unsigned char lcdver;
  unsigned char stereo;
  unsigned char soundRate;
  unsigned char autoSram;
  unsigned char renderMode;
  unsigned char volume;
  unsigned char actionButtons;
  unsigned char transparency;
  unsigned char ramSettings;
  unsigned char mmuHack;
  unsigned char region;
  unsigned char soundHack;
  unsigned short graphHacks;
  unsigned char asmspc700;
  unsigned char SpeedHacks;
  unsigned char loadOnInit;
  unsigned char delayedRasterFX;
  unsigned char spare1A;
  unsigned char spare1B;
  unsigned char spare1C;
  unsigned char spare1D;
  unsigned char spare1E;
};

extern struct SNES_MENU_OPTIONS snesMenuOptions;

struct SAVE_STATE
{
  char filename[MAX_PATH+1];
  char fullFilename[MAX_PATH+1];
  unsigned int inUse;
};


extern struct SAVE_STATE saveState[];  // holds the filenames for the savestate and "inuse" flags
extern char saveStateName[];

// Input.cpp
struct INPUT
{
  unsigned int held[32];
  unsigned int repeat[32];
};
extern struct INPUT Inp;

int InputInit();
int InputUpdate(int EnableDiagnals);

#ifdef __cplusplus
}
#endif

#endif /* _MENU_H_ */