// For commercial use, separate licencing terms must be obtained.\r
\r
#include <stdio.h>\r
+#include <stdlib.h>\r
#include <string.h>\r
#include <unistd.h>\r
#include <strings.h>\r
extern char *ext_menu, *ext_state;\r
extern int select_exits;\r
extern char *PicoConfigFile;\r
+static int load_state_slot = -1;\r
int mmuhack_status = 0;\r
char **g_argv;\r
\r
else if(strcasecmp(argv[x], "-selectexit") == 0) {\r
select_exits = 1;\r
}\r
+ else if(strcasecmp(argv[x], "-loadstate") == 0) {\r
+ if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }\r
+ }\r
else {\r
unrecognized = 1;\r
break;\r
"-state <param> pass '-state param' to the menu program\n"\r
"-config <file> use specified config file instead of default 'picoconfig.bin'\n"\r
" see currentConfig_t structure in emu.h for the file format\n"\r
- "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n");\r
+ "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n"\r
+ "-loadstate <num> if ROM is specified, try loading slot <num>\n");\r
}\r
}\r
\r
if (argc > 1)\r
parse_cmd_line(argc, argv);\r
\r
+ if (engineState == PGS_ReloadRom)\r
+ {\r
+ if (emu_ReloadRom()) {\r
+ engineState = PGS_Running;\r
+ if (load_state_slot >= 0) {\r
+ state_slot = load_state_slot;\r
+ emu_SaveLoadGame(1, 0);\r
+ }\r
+ }\r
+ }\r
+\r
for (;;)\r
{\r
switch (engineState)\r
// For commercial use, separate licencing terms must be obtained.\r
\r
#include <stdio.h>\r
+#include <stdlib.h>\r
#include <string.h>\r
#include <unistd.h>\r
#include <strings.h>\r
\r
extern int select_exits;\r
extern char *PicoConfigFile;\r
+static int load_state_slot = -1;\r
int mmuhack_status = 0; // TODO rm\r
char **g_argv;\r
\r
else if(strcasecmp(argv[x], "-selectexit") == 0) {\r
select_exits = 1;\r
}\r
+ else if(strcasecmp(argv[x], "-loadstate") == 0) {\r
+ if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }\r
+ }\r
else {\r
unrecognized = 1;\r
break;\r
"-state <param> pass '-state param' to the menu program\n"\r
"-config <file> use specified config file instead of default 'picoconfig.bin'\n"\r
" see currentConfig_t structure in emu.h for the file format\n"\r
- "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n");\r
+ "-selectexit pressing SELECT will exit the emu and start 'menu_path'\n"\r
+ "-loadstate <num> if ROM is specified, try loading slot <num>\n");\r
}\r
}\r
\r
if (argc > 1)\r
parse_cmd_line(argc, argv);\r
\r
+ if (engineState == PGS_ReloadRom)\r
+ {\r
+ if (emu_ReloadRom()) {\r
+ engineState = PGS_Running;\r
+ if (load_state_slot >= 0) {\r
+ state_slot = load_state_slot;\r
+ emu_SaveLoadGame(1, 0);\r
+ }\r
+ }\r
+ }\r
+\r
for (;;)\r
{\r
switch (engineState)\r
#include <sys/stat.h>\r
#include <sys/ioctl.h>\r
#include <sys/soundcard.h>\r
+#include <linux/fb.h>\r
#include <fcntl.h>\r
#include <errno.h>\r
\r
#include "../gp2x/usbjoy.h"\r
#include "../common/arm_utils.h"\r
\r
-static volatile unsigned int *memregs;\r
+static volatile unsigned int *memregs = MAP_FAILED;\r
//static\r
int memdev = 0;\r
-static int sounddev = -1, mixerdev = -1, touchdev = -1;\r
+static int fbdev = -1, sounddev = -1, mixerdev = -1, touchdev = -1;\r
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };\r
\r
//#define SCREEN_MAP_SIZE (((800*(480+11)*2)+0xfff)&~0xfff)\r
#define SCREEN_MAP_SIZE (800*480*2)\r
-static void *screen;\r
+static void *screen = MAP_FAILED;\r
void *gp2x_screen;\r
\r
\r
/* common */\r
void gp2x_init(void)\r
{\r
-// struct fb_fix_screeninfo fbfix;\r
- int fbdev;\r
+ struct fb_fix_screeninfo fbfix;\r
+ int ret;\r
\r
printf("entering init()\n"); fflush(stdout);\r
\r
printf("open(\"/dev/mem\") failed with %i\n", errno);\r
exit(1);\r
}\r
-\r
+/*\r
memregs = mmap(0, 0x01000000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x48000000);\r
if (memregs == MAP_FAILED)\r
{\r
printf("mmap(memregs) failed with %i\n", errno);\r
exit(1);\r
}\r
+*/\r
+ ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);\r
+ if (ret == -1)\r
+ {\r
+ printf("ioctl(fbdev) failed with %i\n", errno);\r
+ exit(1);\r
+ }\r
+\r
+ // squidge hack\r
+ if (fbfix.line_length != 800*2)\r
+ {\r
+ gp2x_screen = malloc(800*640*2);\r
+ return;\r
+ }\r
\r
fbdev = open("/dev/fb0", O_RDWR);\r
if (fbdev == -1)\r
exit(1);\r
}\r
\r
-/*\r
- ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);\r
- if (ret == -1)\r
- {\r
- printf("ioctl(fbdev) failed with %i\n", errno);\r
- exit(1);\r
- }\r
-*/\r
screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);\r
if (screen == MAP_FAILED)\r
{\r
{\r
//gp2x_video_changemode(15);\r
\r
- munmap(screen, SCREEN_MAP_SIZE);\r
- munmap((void *)memregs, 0x10000);\r
+ if (screen != MAP_FAILED)\r
+ munmap(screen, SCREEN_MAP_SIZE);\r
+ if (memregs != MAP_FAILED)\r
+ munmap((void *)memregs, 0x10000);\r
close(memdev);\r
+ if (fbdev >= 0) close(fbdev);\r
if (mixerdev >= 0) close(mixerdev);\r
if (sounddev >= 0) close(sounddev);\r
if (touchdev >= 0) close(touchdev);\r