Skip to content

Commit

Permalink
Fixed save states. You can now save and restore your game progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbanes committed Nov 20, 2019
1 parent 1783b67 commit 940bc6f
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ipkg/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: gngeo
Version: 20191117
Version: 20191119
Description: NeoGeo MVS/AES emulator
Section: emus
Priority: optional
Expand Down
5 changes: 1 addition & 4 deletions ipkg/postinst
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/sh

# Make sure that the default directory gets created
mkdir -p /home/retrofw/emus/gngeo/roms
mkdir -p /home/retrofw/roms/neogeo
mkdir -p /home/retrofw/.gngeo

echo "ROM directories created."
2 changes: 1 addition & 1 deletion opkg/default.gcw0.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Type=Game
StartupNotify=true
Icon=gngeo32
Categories=emulators;
Version=201911178
Version=20191119
X-OD-Manual=gngeo.man.txt
X-OD-NeedsDownscaling=true
2 changes: 1 addition & 1 deletion opkg/default.retrofw.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Type=Game
StartupNotify=true
Icon=gngeo
Categories=emulators;
Version=20191117
Version=20191119
X-OD-Manual=gngeo.man.txt
X-OD-NeedsDownscaling=true
21 changes: 17 additions & 4 deletions src/roms.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include "ym2610-940/940shared.h"
#endif

extern int exists(char *path);
extern char* getHomePath(char *subpath);

/* Prototype */
void kof98_decrypt_68k(GAME_ROMS *r);
void kof99_decrypt_68k(GAME_ROMS *r);
Expand Down Expand Up @@ -1908,7 +1911,9 @@ void dr_free_roms(GAME_ROMS *r) {
void open_nvram(char *name) {
char *filename;
size_t totread = 0;
#ifdef EMBEDDED_FS
#ifdef DINGUX
char *gngeo_dir=getHomePath(".gngeo/save/");
#elif EMBEDDED_FS
const char *gngeo_dir = ROOTPATH"save/";
#elif defined(__AMIGA__)
const char *gngeo_dir = "/PROGDIR/save/";
Expand All @@ -1928,11 +1933,15 @@ void open_nvram(char *name) {

}

extern char* getHomePath(char *subpath);

/* TODO: multiple memcard */
void open_memcard(char *name) {
char *filename;
size_t totread = 0;
#ifdef EMBEDDED_FS
#ifdef DINGUX
char *gngeo_dir=getHomePath(".gngeo/save/");
#elif EMBEDDED_FS
const char *gngeo_dir = ROOTPATH"save/";
#elif defined(__AMIGA__)
const char *gngeo_dir = "/PROGDIR/save/";
Expand All @@ -1953,7 +1962,9 @@ void open_memcard(char *name) {

void save_nvram(char *name) {
char *filename;
#ifdef EMBEDDED_FS
#ifdef DINGUX
char *gngeo_dir=getHomePath(".gngeo/save/");
#elif EMBEDDED_FS
const char *gngeo_dir = ROOTPATH"save/";
#elif defined(__AMIGA__)
const char *gngeo_dir = strdup("/PROGDIR/save/");
Expand Down Expand Up @@ -1983,7 +1994,9 @@ void save_nvram(char *name) {

void save_memcard(char *name) {
char *filename;
#ifdef EMBEDDED_FS
#ifdef DINGUX
char *gngeo_dir=getHomePath(".gngeo/save/");
#elif EMBEDDED_FS
const char *gngeo_dir = ROOTPATH"save/";
#elif defined(__AMIGA__)
const char *gngeo_dir = strdup("/PROGDIR/save/");
Expand Down
16 changes: 14 additions & 2 deletions src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "SDL_endian.h"
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#if defined(HAVE_LIBZ) && defined (HAVE_MMAP)
#include <zlib.h>
#endif
Expand Down Expand Up @@ -69,6 +70,10 @@ SDL_Surface *state_img_tmp;
void cpu_68k_mkstate(gzFile gzf,int mode);
void cpu_z80_mkstate(gzFile gzf,int mode);
void ym2610_mkstate(gzFile gzf,int mode);

extern int exists(char *path);
extern char* getHomePath(char *subpath);

#if 0
void create_state_register(ST_MODULE_TYPE module,const char *reg_name,
Uint8 num,void *data,int size,ST_DATA_TYPE type) {
Expand Down Expand Up @@ -148,11 +153,14 @@ void swap_buf32_if_need(Uint8 src_endian,Uint32* buf,Uint32 size)
}
}
#endif

Uint32 how_many_slot(char *game) {
char *st_name;
FILE *f;
// char *st_name_len;
#ifdef EMBEDDED_FS
#ifdef DINGUX
char *gngeo_dir=getHomePath(".gngeo/save/");
#elif EMBEDDED_FS
char *gngeo_dir=ROOTPATH"save/";
#else
char *gngeo_dir=get_gngeo_dir();
Expand All @@ -173,7 +181,9 @@ Uint32 how_many_slot(char *game) {
static gzFile open_state(char *game,int slot,int mode) {
char *st_name;
// char *st_name_len;
#ifdef EMBEDDED_FS
#ifdef DINGUX
char *gngeo_dir=getHomePath(".gngeo/save/");
#elif EMBEDDED_FS
char *gngeo_dir=ROOTPATH"save/";
#else
char *gngeo_dir=get_gngeo_dir();
Expand All @@ -183,6 +193,8 @@ static gzFile open_state(char *game,int slot,int mode) {
gzFile gzf;
int flags;
Uint32 rate;

if(!exists(gngeo_dir)) mkdir(gngeo_dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);

st_name=(char*)alloca(strlen(gngeo_dir)+strlen(game)+5);
sprintf(st_name,"%s%s.%03d",gngeo_dir,game,slot);
Expand Down

0 comments on commit 940bc6f

Please sign in to comment.