2020-02-22 17:47:52 +00:00
|
|
|
|
/* ReC98
|
|
|
|
|
* -----
|
|
|
|
|
* TH04 ZUN.COM -S. Initializes the resident structure and configuration file
|
|
|
|
|
* required in order to run TH04.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-02-01 07:12:52 +00:00
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include "platform.h"
|
2021-01-26 15:33:06 +00:00
|
|
|
|
#include "master.hpp"
|
2021-11-22 10:48:24 +00:00
|
|
|
|
#include "th01/rank.h"
|
2020-02-22 17:47:52 +00:00
|
|
|
|
#include "th04/score.h"
|
|
|
|
|
#include "th04/resident.hpp"
|
|
|
|
|
#include "th04/snd/snd.h"
|
2020-09-06 17:28:52 +00:00
|
|
|
|
#include "th04/formats/cfg.hpp"
|
2020-02-22 17:47:52 +00:00
|
|
|
|
|
|
|
|
|
char debug = 0;
|
|
|
|
|
const cfg_options_t OPTS_DEFAULT = {
|
|
|
|
|
RANK_DEFAULT, CFG_LIVES_DEFAULT, CFG_BOMBS_DEFAULT,
|
|
|
|
|
SND_BGM_FM26, SND_SE_FM, true
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-01 07:12:52 +00:00
|
|
|
|
void cfg_init(resident_t __seg *resident_sgm)
|
2020-02-22 17:47:52 +00:00
|
|
|
|
{
|
|
|
|
|
const char *fn = CFG_FN;
|
|
|
|
|
cfg_options_t opts = OPTS_DEFAULT;
|
|
|
|
|
cfg_t cfg_in;
|
|
|
|
|
|
|
|
|
|
if(!file_ropen(fn)) {
|
|
|
|
|
recreate:
|
|
|
|
|
file_create(fn);
|
|
|
|
|
file_write(&opts, sizeof(opts));
|
|
|
|
|
} else {
|
|
|
|
|
file_read(&cfg_in, sizeof(cfg_in));
|
|
|
|
|
file_close();
|
|
|
|
|
if((
|
|
|
|
|
cfg_in.opts.rank
|
|
|
|
|
+ cfg_in.opts.lives
|
|
|
|
|
+ cfg_in.opts.bombs
|
|
|
|
|
+ cfg_in.opts.bgm_mode
|
|
|
|
|
+ cfg_in.opts.se_mode
|
|
|
|
|
+ cfg_in.opts.turbo_mode
|
|
|
|
|
) != cfg_in.opts_sum) {
|
|
|
|
|
goto recreate;
|
|
|
|
|
}
|
|
|
|
|
file_append(fn);
|
|
|
|
|
file_seek(offsetof(cfg_t, resident), 0);
|
|
|
|
|
}
|
|
|
|
|
file_write(&resident_sgm, sizeof(resident_sgm));
|
|
|
|
|
file_write(&debug, sizeof(debug));
|
|
|
|
|
// Yes, this is uninitialized if the file didn't exist!
|
|
|
|
|
file_write(&cfg_in.opts_sum, sizeof(cfg_in.opts_sum));
|
|
|
|
|
file_close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define LOGO \
|
|
|
|
|
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>z<EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>@ <20>풓<EFBFBD>v<EFBFBD><76><EFBFBD>O<EFBFBD><4F><EFBFBD><EFBFBD><EFBFBD>@RES_HUMA.com Version1.00 (c)zun 1998"
|
|
|
|
|
|
2022-07-09 19:40:53 +00:00
|
|
|
|
#define optimization_barrier()
|
2020-02-22 19:04:53 +00:00
|
|
|
|
|
2020-02-22 17:47:52 +00:00
|
|
|
|
#define RES_INIT_BOTTOM { \
|
2020-02-22 19:04:53 +00:00
|
|
|
|
cfg_init(sgm); \
|
|
|
|
|
\
|
|
|
|
|
resident_t far *resident; \
|
|
|
|
|
resident = reinterpret_cast<resident_t far *>(resident_bytes); \
|
2020-02-22 17:47:52 +00:00
|
|
|
|
if(debug) { \
|
|
|
|
|
resident->debug = true; \
|
|
|
|
|
} \
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-01 07:12:52 +00:00
|
|
|
|
#include "th02/res_init.cpp"
|