mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
load state ability from command line
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@564 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
0022091ebe
commit
f7c40368a7
3 changed files with 62 additions and 18 deletions
19
gp2x/main.c
19
gp2x/main.c
|
@ -4,6 +4,7 @@
|
||||||
// For commercial use, separate licencing terms must be obtained.
|
// For commercial use, separate licencing terms must be obtained.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
extern char *ext_menu, *ext_state;
|
extern char *ext_menu, *ext_state;
|
||||||
extern int select_exits;
|
extern int select_exits;
|
||||||
extern char *PicoConfigFile;
|
extern char *PicoConfigFile;
|
||||||
|
static int load_state_slot = -1;
|
||||||
int mmuhack_status = 0;
|
int mmuhack_status = 0;
|
||||||
char **g_argv;
|
char **g_argv;
|
||||||
|
|
||||||
|
@ -48,6 +50,9 @@ void parse_cmd_line(int argc, char *argv[])
|
||||||
else if(strcasecmp(argv[x], "-selectexit") == 0) {
|
else if(strcasecmp(argv[x], "-selectexit") == 0) {
|
||||||
select_exits = 1;
|
select_exits = 1;
|
||||||
}
|
}
|
||||||
|
else if(strcasecmp(argv[x], "-loadstate") == 0) {
|
||||||
|
if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
unrecognized = 1;
|
unrecognized = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -73,7 +78,8 @@ void parse_cmd_line(int argc, char *argv[])
|
||||||
"-state <param> pass '-state param' to the menu program\n"
|
"-state <param> pass '-state param' to the menu program\n"
|
||||||
"-config <file> use specified config file instead of default 'picoconfig.bin'\n"
|
"-config <file> use specified config file instead of default 'picoconfig.bin'\n"
|
||||||
" see currentConfig_t structure in emu.h for the file format\n"
|
" see currentConfig_t structure in emu.h for the file format\n"
|
||||||
"-selectexit pressing SELECT will exit the emu and start 'menu_path'\n");
|
"-selectexit pressing SELECT will exit the emu and start 'menu_path'\n"
|
||||||
|
"-loadstate <num> if ROM is specified, try loading slot <num>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +116,17 @@ int main(int argc, char *argv[])
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
parse_cmd_line(argc, argv);
|
parse_cmd_line(argc, argv);
|
||||||
|
|
||||||
|
if (engineState == PGS_ReloadRom)
|
||||||
|
{
|
||||||
|
if (emu_ReloadRom()) {
|
||||||
|
engineState = PGS_Running;
|
||||||
|
if (load_state_slot >= 0) {
|
||||||
|
state_slot = load_state_slot;
|
||||||
|
emu_SaveLoadGame(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (engineState)
|
switch (engineState)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
// For commercial use, separate licencing terms must be obtained.
|
// For commercial use, separate licencing terms must be obtained.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
|
|
||||||
extern int select_exits;
|
extern int select_exits;
|
||||||
extern char *PicoConfigFile;
|
extern char *PicoConfigFile;
|
||||||
|
static int load_state_slot = -1;
|
||||||
int mmuhack_status = 0; // TODO rm
|
int mmuhack_status = 0; // TODO rm
|
||||||
char **g_argv;
|
char **g_argv;
|
||||||
|
|
||||||
|
@ -37,6 +39,9 @@ void parse_cmd_line(int argc, char *argv[])
|
||||||
else if(strcasecmp(argv[x], "-selectexit") == 0) {
|
else if(strcasecmp(argv[x], "-selectexit") == 0) {
|
||||||
select_exits = 1;
|
select_exits = 1;
|
||||||
}
|
}
|
||||||
|
else if(strcasecmp(argv[x], "-loadstate") == 0) {
|
||||||
|
if(x+1 < argc) { ++x; load_state_slot = atoi(argv[x]); }
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
unrecognized = 1;
|
unrecognized = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -62,7 +67,8 @@ void parse_cmd_line(int argc, char *argv[])
|
||||||
"-state <param> pass '-state param' to the menu program\n"
|
"-state <param> pass '-state param' to the menu program\n"
|
||||||
"-config <file> use specified config file instead of default 'picoconfig.bin'\n"
|
"-config <file> use specified config file instead of default 'picoconfig.bin'\n"
|
||||||
" see currentConfig_t structure in emu.h for the file format\n"
|
" see currentConfig_t structure in emu.h for the file format\n"
|
||||||
"-selectexit pressing SELECT will exit the emu and start 'menu_path'\n");
|
"-selectexit pressing SELECT will exit the emu and start 'menu_path'\n"
|
||||||
|
"-loadstate <num> if ROM is specified, try loading slot <num>\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +90,17 @@ int main(int argc, char *argv[])
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
parse_cmd_line(argc, argv);
|
parse_cmd_line(argc, argv);
|
||||||
|
|
||||||
|
if (engineState == PGS_ReloadRom)
|
||||||
|
{
|
||||||
|
if (emu_ReloadRom()) {
|
||||||
|
engineState = PGS_Running;
|
||||||
|
if (load_state_slot >= 0) {
|
||||||
|
state_slot = load_state_slot;
|
||||||
|
emu_SaveLoadGame(1, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
switch (engineState)
|
switch (engineState)
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/soundcard.h>
|
#include <sys/soundcard.h>
|
||||||
|
#include <linux/fb.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
@ -16,15 +17,15 @@
|
||||||
#include "../gp2x/usbjoy.h"
|
#include "../gp2x/usbjoy.h"
|
||||||
#include "../common/arm_utils.h"
|
#include "../common/arm_utils.h"
|
||||||
|
|
||||||
static volatile unsigned int *memregs;
|
static volatile unsigned int *memregs = MAP_FAILED;
|
||||||
//static
|
//static
|
||||||
int memdev = 0;
|
int memdev = 0;
|
||||||
static int sounddev = -1, mixerdev = -1, touchdev = -1;
|
static int fbdev = -1, sounddev = -1, mixerdev = -1, touchdev = -1;
|
||||||
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
|
static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
|
||||||
|
|
||||||
//#define SCREEN_MAP_SIZE (((800*(480+11)*2)+0xfff)&~0xfff)
|
//#define SCREEN_MAP_SIZE (((800*(480+11)*2)+0xfff)&~0xfff)
|
||||||
#define SCREEN_MAP_SIZE (800*480*2)
|
#define SCREEN_MAP_SIZE (800*480*2)
|
||||||
static void *screen;
|
static void *screen = MAP_FAILED;
|
||||||
void *gp2x_screen;
|
void *gp2x_screen;
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,8 +198,8 @@ void gp2x_sound_volume(int l, int r)
|
||||||
/* common */
|
/* common */
|
||||||
void gp2x_init(void)
|
void gp2x_init(void)
|
||||||
{
|
{
|
||||||
// struct fb_fix_screeninfo fbfix;
|
struct fb_fix_screeninfo fbfix;
|
||||||
int fbdev;
|
int ret;
|
||||||
|
|
||||||
printf("entering init()\n"); fflush(stdout);
|
printf("entering init()\n"); fflush(stdout);
|
||||||
|
|
||||||
|
@ -208,13 +209,27 @@ void gp2x_init(void)
|
||||||
printf("open(\"/dev/mem\") failed with %i\n", errno);
|
printf("open(\"/dev/mem\") failed with %i\n", errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
memregs = mmap(0, 0x01000000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x48000000);
|
memregs = mmap(0, 0x01000000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x48000000);
|
||||||
if (memregs == MAP_FAILED)
|
if (memregs == MAP_FAILED)
|
||||||
{
|
{
|
||||||
printf("mmap(memregs) failed with %i\n", errno);
|
printf("mmap(memregs) failed with %i\n", errno);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);
|
||||||
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
printf("ioctl(fbdev) failed with %i\n", errno);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// squidge hack
|
||||||
|
if (fbfix.line_length != 800*2)
|
||||||
|
{
|
||||||
|
gp2x_screen = malloc(800*640*2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fbdev = open("/dev/fb0", O_RDWR);
|
fbdev = open("/dev/fb0", O_RDWR);
|
||||||
if (fbdev == -1)
|
if (fbdev == -1)
|
||||||
|
@ -223,14 +238,6 @@ void gp2x_init(void)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);
|
|
||||||
if (ret == -1)
|
|
||||||
{
|
|
||||||
printf("ioctl(fbdev) failed with %i\n", errno);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
|
screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
|
||||||
if (screen == MAP_FAILED)
|
if (screen == MAP_FAILED)
|
||||||
{
|
{
|
||||||
|
@ -269,9 +276,12 @@ void gp2x_deinit(void)
|
||||||
{
|
{
|
||||||
//gp2x_video_changemode(15);
|
//gp2x_video_changemode(15);
|
||||||
|
|
||||||
munmap(screen, SCREEN_MAP_SIZE);
|
if (screen != MAP_FAILED)
|
||||||
munmap((void *)memregs, 0x10000);
|
munmap(screen, SCREEN_MAP_SIZE);
|
||||||
|
if (memregs != MAP_FAILED)
|
||||||
|
munmap((void *)memregs, 0x10000);
|
||||||
close(memdev);
|
close(memdev);
|
||||||
|
if (fbdev >= 0) close(fbdev);
|
||||||
if (mixerdev >= 0) close(mixerdev);
|
if (mixerdev >= 0) close(mixerdev);
|
||||||
if (sounddev >= 0) close(sounddev);
|
if (sounddev >= 0) close(sounddev);
|
||||||
if (touchdev >= 0) close(touchdev);
|
if (touchdev >= 0) close(touchdev);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue