Embed GameResource in NACTINFO

This commit is contained in:
kichikuou
2020-07-12 14:17:31 +09:00
parent 1a3b779ace
commit c03b6cf6b5
7 changed files with 20 additions and 62 deletions
+3 -17
View File
@@ -29,6 +29,7 @@
#include "scenario.h"
#include "font.h"
#include "s39ain.h"
#include "gameresource.h"
#include "selection.h"
#include "message.h"
#include "ags.h"
@@ -123,23 +124,8 @@ typedef struct {
/* ain 関連 */
S39AIN ain;
/* データのファイル名 */
struct {
const char *scenario[2];
const char *graphics[2];
const char *wav[2];
const char *midi[2];
const char *data[2];
const char *resource[2];
const char *bgm[2];
const char *save[27];
const char *savedir;
const char *init;
const char *bgi;
const char *wai;
const char *sact01;
const char *alk[10];
} files;
/* data file names */
GameResource files;
int frame_count;
int cmd_count;
+1 -1
View File
@@ -41,7 +41,7 @@
#define dll nact->ain.dll
#define msg nact->ain.msg
#define fnc nact->ain.fnc
#define path_to_ain nact->ain.path_to_ain
#define path_to_ain nact->files.ain
#define dllnum nact->ain.dllnum
#define fncnum nact->ain.fncnum
#define varnum nact->ain.varnum
-2
View File
@@ -50,8 +50,6 @@ typedef struct {
/* System39.ain 全体の情報 */
typedef struct {
const char *path_to_ain; /* system39.ain へのパス */
int dllnum; /* DLL の数 */
int fncnum; /* FUNC の数 */
int varnum; /* VARI の数 */
+2 -2
View File
@@ -72,7 +72,7 @@ int s39ini_init(void) {
if (vval_max <= 0) return NG;
// Volume.sav があればそれを読み込む
snprintf(fn, sizeof(fn) -1, "%s/Volume.sav", nact->files.savedir);
snprintf(fn, sizeof(fn) -1, "%s/Volume.sav", nact->files.save_path);
if (NULL == (fp = fopen(fn, "rb"))) {
// とりあえず、初期ボリュームは 100
for (i = 0; i < MAXVOLCH; i++) {
@@ -142,7 +142,7 @@ int s39ini_remove() {
vol[i] = vval[i].vol;
}
snprintf(fn, sizeof(fn) -1, "%s/Volume.sav", nact->files.savedir);
snprintf(fn, sizeof(fn) -1, "%s/Volume.sav", nact->files.save_path);
if (NULL == (fp = fopen(fn, "wb"))) {
WARNING("Fail to save Volume.save\n");
return NG;
+8 -20
View File
@@ -43,7 +43,6 @@
#include "message.h"
/* セーブデータ */
static char *saveDataFile[SAVE_MAXNUMBER];
static int savefile_sysvar_cnt = SYSVAR_MAX;
static void* saveStackInfo(Ald_stackHdr *head);
@@ -63,25 +62,14 @@ EM_JS(void, scheduleSync, (), {
#define scheduleSync()
#endif
/* savefile がある directory を登録 */
void save_set_path(const char *path) {
nact->files.savedir = strdup(path);
fc_init(path);
}
/* savefile を登録 */
void save_register_file(const char *name, int index) {
saveDataFile[index] = strdup(name);
}
/* savefile を参照 */
char *save_get_file(int index) {
return saveDataFile[index];
const char *save_get_file(int index) {
return nact->files.save_fname[index];
}
/* savefile を削除 */
int save_delete_file(int index) {
int ret = unlink(saveDataFile[index]);
int ret = unlink(nact->files.save_fname[index]);
if (ret == 0) {
return 1;
@@ -465,8 +453,8 @@ int save_saveAll(int no) {
if (save_base == NULL)
return SAVE_SAVEERR;
fc_backup_oldfile(saveDataFile[no]);
fp = fopen(saveDataFile[no],"wb");
fc_backup_oldfile(nact->files.save_fname[no]);
fp = fopen(nact->files.save_fname[no], "wb");
if (fp == NULL)
return SAVE_SAVEERR;
@@ -712,7 +700,7 @@ static void* loadGameData(int no, int *status, int *size) {
long filesize;
char *buf;
fp = fopen(saveDataFile[no], "rb");
fp = fopen(nact->files.save_fname[no], "rb");
if (fp == NULL)
goto errexit;
fseek(fp, 0L, SEEK_END);
@@ -743,8 +731,8 @@ static int saveGameData(int no, char *buf, int size) {
FILE *fp;
int status = SAVE_SAVEOK1;
fc_backup_oldfile(saveDataFile[no]);
fp = fopen(saveDataFile[no],"wb");
fc_backup_oldfile(nact->files.save_fname[no]);
fp = fopen(nact->files.save_fname[no], "wb");
if (fp == NULL) {
return SAVE_SAVEERR;
}
+1 -3
View File
@@ -125,9 +125,7 @@ extern int save_load_var_with_file(char *filename, int *start, int cnt);
extern int save_save_str_with_file(char *filename, int start, int cnt);
extern int save_load_str_with_file(char *filename, int start, int cnt);
extern BYTE* load_cg_with_file(char *file, int *status, long *filesize);
extern void save_set_path(const char *path);
extern void save_register_file(const char *name, int index);
extern char* save_get_file(int index);
extern const char *save_get_file(int index);
extern int save_delete_file(int index);
#endif /* __SAVEDATA__ */
+5 -17
View File
@@ -564,7 +564,8 @@ static void init_signalhandler() {
}
#endif
static void registerGameFiles(GameResource *gr) {
static void registerGameFiles(void) {
GameResource *gr = &nact->files;
if (gr->cnt[DRIFILE_SCO] == 0) {
SYSERROR("No Scenario data available\n");
}
@@ -584,19 +585,7 @@ static void registerGameFiles(GameResource *gr) {
ald_init(DRIFILE_BGM, gr->game_fname[DRIFILE_BGM], gr->cnt[DRIFILE_BGM], TRUE);
if (gr->save_path)
save_set_path(gr->save_path);
for (int i = 0; i < SAVE_MAXNUMBER; i++) {
if (gr->save_fname[i])
save_register_file(gr->save_fname[i], i);
}
nact->ain.path_to_ain = gr->ain;
nact->files.wai = gr->wai;
nact->files.bgi = gr->bgi;
nact->files.sact01 = gr->sact01;
nact->files.init = gr->init;
for (int i = 0; i < 10; i++)
nact->files.alk[i] = gr->alk[i];
fc_init(gr->save_path);
}
int main(int argc, char **argv) {
@@ -625,10 +614,9 @@ int main(int argc, char **argv) {
}
}
#endif
GameResource gr;
if (!initGameResource(&gr, gameResourceFile))
if (!initGameResource(&nact->files, gameResourceFile))
sys35_usage(TRUE);
registerGameFiles(&gr);
registerGameFiles();
#ifdef HAVE_SIGACTION
init_signalhandler();