mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-10-10 08:08:34 +03:00
Refactor savedata, s39ain, s39ini interfaces
This commit is contained in:
+7
-8
@@ -37,7 +37,7 @@
|
||||
/*
|
||||
system39.ain の読み込み
|
||||
*/
|
||||
int s39ain_init(const char *path_to_ain, S39AIN *ain) {
|
||||
bool s39ain_init(const char *path_to_ain, S39AIN *ain) {
|
||||
FILE *fp;
|
||||
long len;
|
||||
char *buf;
|
||||
@@ -46,7 +46,7 @@ int s39ain_init(const char *path_to_ain, S39AIN *ain) {
|
||||
|
||||
if (NULL == (fp = fopen(path_to_ain, "rb"))) {
|
||||
WARNING("fail to open %s", path_to_ain);
|
||||
return NG;
|
||||
return false;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
@@ -57,7 +57,7 @@ int s39ain_init(const char *path_to_ain, S39AIN *ain) {
|
||||
WARNING("%s: %s", path_to_ain, strerror(errno));
|
||||
free(buf);
|
||||
fclose(fp);
|
||||
return NG;
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
@@ -66,7 +66,7 @@ int s39ain_init(const char *path_to_ain, S39AIN *ain) {
|
||||
if (0 != strncmp(p, "AIN", 3)) {
|
||||
WARNING("%s is not ain file", path_to_ain);
|
||||
free(buf);
|
||||
return NG;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* decode .ain file (thanx to Tajiri) */
|
||||
@@ -83,7 +83,7 @@ int s39ain_init(const char *path_to_ain, S39AIN *ain) {
|
||||
if (0 != strncmp(p, "HEL0", 4)) {
|
||||
WARNING("%s is illigal ain file", path_to_ain);
|
||||
free(buf);
|
||||
return NG;
|
||||
return false;
|
||||
}
|
||||
p += 8;
|
||||
ain->dllnum = LittleEndian_getDW(p, 0);
|
||||
@@ -165,13 +165,12 @@ int s39ain_init(const char *path_to_ain, S39AIN *ain) {
|
||||
for (i = 0; i < ain->dllnum; i++)
|
||||
resolve_module(&ain->dll[i]);
|
||||
|
||||
return OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
int s39ain_reset(S39AIN *ain) {
|
||||
void s39ain_reset(S39AIN *ain) {
|
||||
for (int i = 0; i < ain->dllnum; i++) {
|
||||
if (ain->dll[i].reset)
|
||||
ain->dll[i].reset();
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ typedef struct {
|
||||
char **msg; /* MSGI に関する情報 */
|
||||
} S39AIN;
|
||||
|
||||
int s39ain_init(const char *path, S39AIN *ain);
|
||||
int s39ain_reset(S39AIN *ain);
|
||||
bool s39ain_init(const char *path, S39AIN *ain);
|
||||
void s39ain_reset(S39AIN *ain);
|
||||
|
||||
#endif /* __S39AIN_H__ */
|
||||
|
||||
+16
-23
@@ -48,15 +48,15 @@ static GtkWidget *vval_win;
|
||||
#include "menu_gui_volval.c"
|
||||
|
||||
// 初期化
|
||||
int s39ini_init(void) {
|
||||
bool s39ini_init(void) {
|
||||
FILE *fp;
|
||||
char s[256], s1[256];
|
||||
int i, vol[MAXVOLCH] = {0};
|
||||
char fn[256];
|
||||
|
||||
if (nact->files.init == NULL) return NG;
|
||||
if (nact->files.init == NULL) return false;
|
||||
|
||||
if (NULL == (fp = fopen(nact->files.init, "r"))) return NG;
|
||||
if (NULL == (fp = fopen(nact->files.init, "r"))) return false;
|
||||
|
||||
while (fgets(s, 255, fp) != NULL) {
|
||||
s1[0] = '\0';
|
||||
@@ -69,7 +69,7 @@ int s39ini_init(void) {
|
||||
//WARNING("VolumeValancer[%d] = %s", i, vval[i].label);
|
||||
}
|
||||
|
||||
if (vval_max <= 0) return NG;
|
||||
if (vval_max <= 0) return false;
|
||||
|
||||
// Volume.sav があればそれを読み込む
|
||||
snprintf(fn, sizeof(fn) -1, "%s/Volume.sav", nact->files.save_path);
|
||||
@@ -93,64 +93,57 @@ int s39ini_init(void) {
|
||||
vval_win = vval_win_open(vval, vval_max);
|
||||
}
|
||||
|
||||
return OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
// PopupMenuから呼ばれる
|
||||
int s39ini_winopen() {
|
||||
void s39ini_winopen(void) {
|
||||
if (vval_win) {
|
||||
gtk_widget_show(vval_win);
|
||||
nact->popupmenu_opened = true;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
// ボリューム設定Windowが閉じられたときに呼ばれる
|
||||
int s39ini_winclose() {
|
||||
void s39ini_winclose(void) {
|
||||
if (vval_win) {
|
||||
gtk_widget_hide(vval_win);
|
||||
nact->popupmenu_opened = false;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
// ボリューム設定でスケールを動かすたびに呼ばれる
|
||||
int s39ini_setvol() {
|
||||
void s39ini_setvol(void) {
|
||||
int vol[MAXVOLCH] = {0};
|
||||
int i;
|
||||
|
||||
if (vval_win == NULL) return OK;
|
||||
if (vval_win == NULL) return;
|
||||
|
||||
for (i = 0; i < MAXVOLCH; i++) {
|
||||
vol[i] = vval[i].mute ? 0 : vval[i].vol;
|
||||
}
|
||||
|
||||
mus_vol_set_valance(vol, MAXVOLCH);
|
||||
return OK;
|
||||
}
|
||||
|
||||
// Volume Valance をセーブ
|
||||
int s39ini_remove() {
|
||||
void s39ini_remove(void) {
|
||||
int vol[MAXVOLCH] = {0};
|
||||
FILE *fp;
|
||||
char fn[256];
|
||||
int i;
|
||||
|
||||
if (vval_win == NULL) return OK;
|
||||
if (vval_win == NULL) return;
|
||||
|
||||
for (i = 0; i < MAXVOLCH; i++) {
|
||||
for (int i = 0; i < MAXVOLCH; i++) {
|
||||
vol[i] = vval[i].vol;
|
||||
}
|
||||
|
||||
snprintf(fn, sizeof(fn) -1, "%s/Volume.sav", nact->files.save_path);
|
||||
if (NULL == (fp = fopen(fn, "wb"))) {
|
||||
WARNING("Fail to save Volume.save");
|
||||
return NG;
|
||||
FILE *fp = fopen(fn, "wb");
|
||||
if (!fp) {
|
||||
WARNING("Failed to save Volume.sav");
|
||||
return;
|
||||
}
|
||||
|
||||
fwrite(vol, sizeof(int), MAXVOLCH, fp);
|
||||
fclose(fp);
|
||||
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
+7
-5
@@ -24,10 +24,12 @@
|
||||
#ifndef __S39INIT_H__
|
||||
#define __S39INIT_H__
|
||||
|
||||
extern int s39ini_init();
|
||||
extern int s39ini_winopen();
|
||||
extern int s39ini_winclose();
|
||||
extern int s39ini_setvol();
|
||||
extern int s39ini_remove();
|
||||
#include <stdbool.h>
|
||||
|
||||
bool s39ini_init(void);
|
||||
void s39ini_winopen(void);
|
||||
void s39ini_winclose(void);
|
||||
void s39ini_setvol(void);
|
||||
void s39ini_remove(void);
|
||||
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -328,7 +328,7 @@ static int saveGameData(int no, char *buf, int size) {
|
||||
return status;
|
||||
}
|
||||
|
||||
int save_setFormat(const char *format_name) {
|
||||
bool save_setFormat(const char *format_name) {
|
||||
if (!strcmp(format_name, "xsystem35"))
|
||||
save_format = SAVEFMT_XSYS35;
|
||||
else if (!strcmp(format_name, "system36"))
|
||||
@@ -339,9 +339,9 @@ int save_setFormat(const char *format_name) {
|
||||
save_format = SAVEFMT_SYS38;
|
||||
else {
|
||||
WARNING("unknown save format %s", format_name);
|
||||
return NG;
|
||||
return false;
|
||||
}
|
||||
return OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* savefile を参照 */
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ enum save_format {
|
||||
|
||||
struct VarRef;
|
||||
|
||||
int save_setFormat(const char *format_name);
|
||||
bool save_setFormat(const char *format_name);
|
||||
int save_loadAll(int no);
|
||||
int save_saveAll(int no);
|
||||
int save_loadPartial(int no, struct VarRef *vref, int cnt);
|
||||
|
||||
Reference in New Issue
Block a user