2020-05-24 18:47:51 +00:00
|
|
|
/* ReC98
|
|
|
|
* -----
|
|
|
|
* Code segment #1 of TH01's FUUIN.EXE
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2024-05-20 18:02:24 +00:00
|
|
|
#include "libs/master.lib/master.hpp"
|
2020-11-07 19:16:17 +00:00
|
|
|
#include "th01/resident.hpp"
|
2022-08-11 00:02:09 +00:00
|
|
|
#include "th01/core/initexit.hpp"
|
|
|
|
#include "th01/end/end.hpp"
|
|
|
|
#include "th01/snd/mdrv2.h"
|
2020-05-24 18:47:51 +00:00
|
|
|
|
2023-02-05 06:14:31 +00:00
|
|
|
// Resident structure fields
|
|
|
|
// -------------------------
|
|
|
|
// Not actually redundant because ending previews can run without an allocated
|
|
|
|
// resident structure.
|
|
|
|
|
2023-02-11 11:34:08 +00:00
|
|
|
uscore_t score = 100000;
|
2023-02-05 06:14:31 +00:00
|
|
|
score_t score_highest = 100000;
|
|
|
|
int32_t continues_total;
|
|
|
|
int32_t continues_per_scene[SCENE_COUNT];
|
|
|
|
int8_t credit_lives_extra;
|
2023-02-01 01:55:07 +00:00
|
|
|
end_sequence_t end_flag = ES_NONE;
|
2023-02-05 06:14:31 +00:00
|
|
|
// -------------------------
|
|
|
|
|
2022-08-11 00:02:09 +00:00
|
|
|
bool16 end_init(void)
|
2020-05-24 18:47:51 +00:00
|
|
|
{
|
|
|
|
int i;
|
2023-06-27 20:10:47 +00:00
|
|
|
resident_t __seg *seg = ResData<resident_t>::exist(RES_ID);
|
|
|
|
if(seg) {
|
|
|
|
resident_t* resident = seg;
|
2023-01-29 22:06:56 +00:00
|
|
|
if(resident->end_flag != ES_NONE) {
|
2020-05-24 18:47:51 +00:00
|
|
|
score = resident->score;
|
|
|
|
continues_total = 0;
|
|
|
|
end_flag = resident->end_flag;
|
|
|
|
rank = resident->rank;
|
|
|
|
score_highest = resident->score_highest;
|
|
|
|
|
|
|
|
for(i = 0; i < SCENE_COUNT; i++) {
|
|
|
|
continues_per_scene[i] = resident->continues_per_scene[i];
|
|
|
|
resident->continues_per_scene[i] = 0;
|
|
|
|
continues_total += continues_per_scene[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
random_seed = resident->rand;
|
2023-02-04 20:35:26 +00:00
|
|
|
credit_lives_extra = resident->credit_lives_extra;
|
2020-05-24 18:47:51 +00:00
|
|
|
resident->score = 0;
|
|
|
|
resident->score_highest = 0;
|
|
|
|
} else {
|
2022-08-10 23:44:57 +00:00
|
|
|
puts("ERROR : end_flag is not ture !!");
|
2020-05-24 18:47:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
} else {
|
2022-08-10 23:44:57 +00:00
|
|
|
puts("ERROR : cfg_id is not alloc!!");
|
2020-05-24 18:47:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool16 end_resident_clear(void)
|
|
|
|
{
|
|
|
|
int i;
|
2023-06-27 20:10:47 +00:00
|
|
|
resident_t __seg *seg = ResData<resident_t>::exist(RES_ID);
|
|
|
|
if(seg) {
|
|
|
|
resident_t* resident = seg;
|
2020-05-24 18:47:51 +00:00
|
|
|
resident->score = 0;
|
2022-05-29 23:45:47 +00:00
|
|
|
resident->end_flag = ES_NONE;
|
2020-05-24 18:47:51 +00:00
|
|
|
resident->score_highest = 0;
|
|
|
|
for(i = 0; i < SCENE_COUNT; i++) {
|
|
|
|
resident->continues_per_scene[i] = 0;
|
|
|
|
}
|
2022-08-14 04:21:01 +00:00
|
|
|
resident->stage_id = 0;
|
2020-05-24 18:47:51 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2022-08-11 00:02:09 +00:00
|
|
|
|
2023-02-01 01:55:07 +00:00
|
|
|
int main_cutscene(int argc, const char *argv[])
|
2022-08-11 00:02:09 +00:00
|
|
|
{
|
|
|
|
if(!mdrv2_resident()) {
|
2023-02-01 01:55:07 +00:00
|
|
|
return 1;
|
2022-08-11 00:02:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Should really be checked, but eh, it's Real Mode...
|
|
|
|
(argc);
|
|
|
|
|
|
|
|
// That's a hidden ending preview feature!
|
|
|
|
if(argv[1][0] != 't') {
|
|
|
|
if(!end_init()) {
|
2023-02-01 01:55:07 +00:00
|
|
|
return 2;
|
2022-08-11 00:02:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(argv[1][1] == '1') {
|
|
|
|
end_flag = ES_MAKAI;
|
|
|
|
} else {
|
|
|
|
end_flag = ES_JIGOKU;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-15 16:50:15 +00:00
|
|
|
// ZUN bug: Should be done conditionally based on resident_t::bgm_mode.
|
|
|
|
// This is why you still get music during this binary despite disabling BGM
|
|
|
|
// in the options.
|
|
|
|
mdrv2_enable_if_board_installed();
|
|
|
|
|
2022-08-11 00:02:09 +00:00
|
|
|
game_init();
|
|
|
|
end_and_verdict_and_regist_animate();
|
2023-02-01 01:55:07 +00:00
|
|
|
game_switch_binary(EP_OP);
|
|
|
|
|
|
|
|
return 0;
|
2022-08-11 00:02:09 +00:00
|
|
|
}
|