Cleanup endgame.h

See #42
This commit is contained in:
Alexander Batalov 2022-06-18 16:35:38 +03:00
parent c1a31dc998
commit 233a13aee7
2 changed files with 83 additions and 108 deletions

View File

@ -18,6 +18,7 @@
#include "object.h" #include "object.h"
#include "palette.h" #include "palette.h"
#include "pipboy.h" #include "pipboy.h"
#include "platform_compat.h"
#include "random.h" #include "random.h"
#include "stat.h" #include "stat.h"
#include "text_font.h" #include "text_font.h"
@ -37,6 +38,47 @@
#define ENDGAME_ENDING_WINDOW_WIDTH 640 #define ENDGAME_ENDING_WINDOW_WIDTH 640
#define ENDGAME_ENDING_WINDOW_HEIGHT 480 #define ENDGAME_ENDING_WINDOW_HEIGHT 480
typedef struct EndgameDeathEnding {
int gvar;
int value;
int worldAreaKnown;
int worldAreaNotKnown;
int min_level;
int percentage;
char voiceOverBaseName[16];
// This flag denotes that the conditions for this ending is met and it was
// selected as a candidate for final random selection.
bool enabled;
} EndgameDeathEnding;
typedef struct EndgameEnding {
int gvar;
int value;
int art_num;
char voiceOverBaseName[12];
int direction;
} EndgameEnding;
static void endgameEndingRenderPanningScene(int direction, const char* narratorFileName);
static void endgameEndingRenderStaticScene(int fid, const char* narratorFileName);
static int endgameEndingHandleContinuePlaying();
static int endgameEndingSlideshowWindowInit();
static void endgameEndingSlideshowWindowFree();
static void endgameEndingVoiceOverInit(const char* fname);
static void endgameEndingVoiceOverReset();
static void endgameEndingVoiceOverFree();
static void endgameEndingLoadPalette(int type, int id);
static void _endgame_voiceover_callback();
static int endgameEndingSubtitlesLoad(const char* filePath);
static void endgameEndingRefreshSubtitles();
static void endgameEndingSubtitlesFree();
static void _endgame_movie_callback();
static void _endgame_movie_bk_process();
static int endgameEndingInit();
static void endgameEndingFree();
static int endgameDeathEndingValidate(int* percentage);
// 0x50B00C // 0x50B00C
char _aEnglish_2[] = ENGLISH; char _aEnglish_2[] = ENGLISH;
@ -49,56 +91,56 @@ char _aEnglish_2[] = ENGLISH;
// This value does not exceed [ENDGAME_ENDING_SUBTITLES_CAPACITY]. // This value does not exceed [ENDGAME_ENDING_SUBTITLES_CAPACITY].
// //
// 0x518668 // 0x518668
int gEndgameEndingSubtitlesLength = 0; static int gEndgameEndingSubtitlesLength = 0;
// The number of characters in current subtitles file. // The number of characters in current subtitles file.
// //
// This value is used to determine // This value is used to determine
// //
// 0x51866C // 0x51866C
int gEndgameEndingSubtitlesCharactersCount = 0; static int gEndgameEndingSubtitlesCharactersCount = 0;
// 0x518670 // 0x518670
int gEndgameEndingSubtitlesCurrentLine = 0; static int gEndgameEndingSubtitlesCurrentLine = 0;
// 0x518674 // 0x518674
int _endgame_maybe_done = 0; static int _endgame_maybe_done = 0;
// enddeath.txt // enddeath.txt
// //
// 0x518678 // 0x518678
EndgameDeathEnding* gEndgameDeathEndings = NULL; static EndgameDeathEnding* gEndgameDeathEndings = NULL;
// The number of death endings in [gEndgameDeathEndings] array. // The number of death endings in [gEndgameDeathEndings] array.
// //
// 0x51867C // 0x51867C
int gEndgameDeathEndingsLength = 0; static int gEndgameDeathEndingsLength = 0;
// Base file name for death ending. // Base file name for death ending.
// //
// This value does not include extension. // This value does not include extension.
// //
// 0x570A90 // 0x570A90
char gEndgameDeathEndingFileName[40]; static char gEndgameDeathEndingFileName[40];
// This flag denotes whether speech sound was successfully loaded for // This flag denotes whether speech sound was successfully loaded for
// the current slide. // the current slide.
// //
// 0x570AB8 // 0x570AB8
bool gEndgameEndingVoiceOverSpeechLoaded; static bool gEndgameEndingVoiceOverSpeechLoaded;
// 0x570ABC // 0x570ABC
char gEndgameEndingSubtitlesLocalizedPath[COMPAT_MAX_PATH]; static char gEndgameEndingSubtitlesLocalizedPath[COMPAT_MAX_PATH];
// The flag used to denote voice over speech for current slide has ended. // The flag used to denote voice over speech for current slide has ended.
// //
// 0x570BC0 // 0x570BC0
bool gEndgameEndingSpeechEnded; static bool gEndgameEndingSpeechEnded;
// endgame.txt // endgame.txt
// //
// 0x570BC4 // 0x570BC4
EndgameEnding* gEndgameEndings; static EndgameEnding* gEndgameEndings;
// The array of text lines in current subtitles file. // The array of text lines in current subtitles file.
// //
@ -106,32 +148,32 @@ EndgameEnding* gEndgameEndings;
// is [ENDGAME_ENDING_SUBTITLES_CAPACITY]. // is [ENDGAME_ENDING_SUBTITLES_CAPACITY].
// //
// 0x570BC8 // 0x570BC8
char** gEndgameEndingSubtitles; static char** gEndgameEndingSubtitles;
// 0x570BCC // 0x570BCC
bool gEndgameEndingSubtitlesEnabled; static bool gEndgameEndingSubtitlesEnabled;
// The flag used to denote voice over subtitles for current slide has ended. // The flag used to denote voice over subtitles for current slide has ended.
// //
// 0x570BD0 // 0x570BD0
bool gEndgameEndingSubtitlesEnded; static bool gEndgameEndingSubtitlesEnded;
// 0x570BD4 // 0x570BD4
bool _endgame_map_enabled; static bool _endgame_map_enabled;
// 0x570BD8 // 0x570BD8
bool _endgame_mouse_state; static bool _endgame_mouse_state;
// The number of endings in [gEndgameEndings] array. // The number of endings in [gEndgameEndings] array.
// //
// 0x570BDC // 0x570BDC
int gEndgameEndingsLength = 0; static int gEndgameEndingsLength = 0;
// This flag denotes whether subtitles was successfully loaded for // This flag denotes whether subtitles was successfully loaded for
// the current slide. // the current slide.
// //
// 0x570BE0 // 0x570BE0
bool gEndgameEndingVoiceOverSubtitlesLoaded; static bool gEndgameEndingVoiceOverSubtitlesLoaded;
// Reference time is a timestamp when subtitle is first displayed. // Reference time is a timestamp when subtitle is first displayed.
// //
@ -139,7 +181,7 @@ bool gEndgameEndingVoiceOverSubtitlesLoaded;
// determine when next line needs to be displayed. // determine when next line needs to be displayed.
// //
// 0x570BE4 // 0x570BE4
unsigned int gEndgameEndingSubtitlesReferenceTime; static unsigned int gEndgameEndingSubtitlesReferenceTime;
// The array of timings for each line in current subtitles file. // The array of timings for each line in current subtitles file.
// //
@ -147,18 +189,18 @@ unsigned int gEndgameEndingSubtitlesReferenceTime;
// is [ENDGAME_ENDING_SUBTITLES_CAPACITY]. // is [ENDGAME_ENDING_SUBTITLES_CAPACITY].
// //
// 0x570BE8 // 0x570BE8
unsigned int* gEndgameEndingSubtitlesTimings; static unsigned int* gEndgameEndingSubtitlesTimings;
// Font that was current before endgame slideshow window was created. // Font that was current before endgame slideshow window was created.
// //
// 0x570BEC // 0x570BEC
int gEndgameEndingSlideshowOldFont; static int gEndgameEndingSlideshowOldFont;
// 0x570BF0 // 0x570BF0
unsigned char* gEndgameEndingSlideshowWindowBuffer; static unsigned char* gEndgameEndingSlideshowWindowBuffer;
// 0x570BF4 // 0x570BF4
int gEndgameEndingSlideshowWindow; static int gEndgameEndingSlideshowWindow;
// 0x43F788 // 0x43F788
void endgamePlaySlideshow() void endgamePlaySlideshow()
@ -211,7 +253,7 @@ void endgamePlayMovie()
} }
// 0x43F8C4 // 0x43F8C4
int endgameEndingHandleContinuePlaying() static int endgameEndingHandleContinuePlaying()
{ {
bool isoWasEnabled = isoDisable(); bool isoWasEnabled = isoDisable();
@ -264,7 +306,7 @@ int endgameEndingHandleContinuePlaying()
} }
// 0x43FBDC // 0x43FBDC
void endgameEndingRenderPanningScene(int direction, const char* narratorFileName) static void endgameEndingRenderPanningScene(int direction, const char* narratorFileName)
{ {
int fid = buildFid(6, 327, 0, 0, 0); int fid = buildFid(6, 327, 0, 0, 0);
@ -385,7 +427,7 @@ void endgameEndingRenderPanningScene(int direction, const char* narratorFileName
} }
// 0x440004 // 0x440004
void endgameEndingRenderStaticScene(int fid, const char* narratorFileName) static void endgameEndingRenderStaticScene(int fid, const char* narratorFileName)
{ {
CacheEntry* backgroundHandle; CacheEntry* backgroundHandle;
Art* background = artLock(fid, &backgroundHandle); Art* background = artLock(fid, &backgroundHandle);
@ -466,7 +508,7 @@ void endgameEndingRenderStaticScene(int fid, const char* narratorFileName)
} }
// 0x43F99C // 0x43F99C
int endgameEndingSlideshowWindowInit() static int endgameEndingSlideshowWindowInit()
{ {
if (endgameEndingInit() != 0) { if (endgameEndingInit() != 0) {
return -1; return -1;
@ -547,7 +589,7 @@ int endgameEndingSlideshowWindowInit()
} }
// 0x43FB28 // 0x43FB28
void endgameEndingSlideshowWindowFree() static void endgameEndingSlideshowWindowFree()
{ {
if (gEndgameEndingSubtitlesEnabled) { if (gEndgameEndingSubtitlesEnabled) {
endgameEndingSubtitlesFree(); endgameEndingSubtitlesFree();
@ -584,7 +626,7 @@ void endgameEndingSlideshowWindowFree()
} }
// 0x4401A0 // 0x4401A0
void endgameEndingVoiceOverInit(const char* fileBaseName) static void endgameEndingVoiceOverInit(const char* fileBaseName)
{ {
char path[COMPAT_MAX_PATH]; char path[COMPAT_MAX_PATH];
@ -632,7 +674,7 @@ void endgameEndingVoiceOverInit(const char* fileBaseName)
// NOTE: This function was inlined at every call site. // NOTE: This function was inlined at every call site.
// //
// 0x440324 // 0x440324
void endgameEndingVoiceOverReset() static void endgameEndingVoiceOverReset()
{ {
gEndgameEndingSubtitlesEnded = false; gEndgameEndingSubtitlesEnded = false;
gEndgameEndingSpeechEnded = false; gEndgameEndingSpeechEnded = false;
@ -649,7 +691,7 @@ void endgameEndingVoiceOverReset()
// NOTE: This function was inlined at every call site. // NOTE: This function was inlined at every call site.
// //
// 0x44035C // 0x44035C
void endgameEndingVoiceOverFree() static void endgameEndingVoiceOverFree()
{ {
speechDelete(); speechDelete();
endgameEndingSubtitlesFree(); endgameEndingSubtitlesFree();
@ -658,7 +700,7 @@ void endgameEndingVoiceOverFree()
} }
// 0x440378 // 0x440378
void endgameEndingLoadPalette(int type, int id) static void endgameEndingLoadPalette(int type, int id)
{ {
char fileName[13]; char fileName[13];
if (artCopyFileName(type, id, fileName) != 0) { if (artCopyFileName(type, id, fileName) != 0) {
@ -679,7 +721,7 @@ void endgameEndingLoadPalette(int type, int id)
} }
// 0x4403F0 // 0x4403F0
void _endgame_voiceover_callback() static void _endgame_voiceover_callback()
{ {
gEndgameEndingSpeechEnded = true; gEndgameEndingSpeechEnded = true;
} }
@ -687,7 +729,7 @@ void _endgame_voiceover_callback()
// Loads subtitles file. // Loads subtitles file.
// //
// 0x4403FC // 0x4403FC
int endgameEndingSubtitlesLoad(const char* filePath) static int endgameEndingSubtitlesLoad(const char* filePath)
{ {
endgameEndingSubtitlesFree(); endgameEndingSubtitlesFree();
@ -736,7 +778,7 @@ int endgameEndingSubtitlesLoad(const char* filePath)
// Refreshes subtitles. // Refreshes subtitles.
// //
// 0x4404EC // 0x4404EC
void endgameEndingRefreshSubtitles() static void endgameEndingRefreshSubtitles()
{ {
if (gEndgameEndingSubtitlesLength <= gEndgameEndingSubtitlesCurrentLine) { if (gEndgameEndingSubtitlesLength <= gEndgameEndingSubtitlesCurrentLine) {
if (gEndgameEndingVoiceOverSubtitlesLoaded) { if (gEndgameEndingVoiceOverSubtitlesLoaded) {
@ -787,7 +829,7 @@ void endgameEndingRefreshSubtitles()
} }
// 0x4406CC // 0x4406CC
void endgameEndingSubtitlesFree() static void endgameEndingSubtitlesFree()
{ {
for (int index = 0; index < gEndgameEndingSubtitlesLength; index++) { for (int index = 0; index < gEndgameEndingSubtitlesLength; index++) {
if (gEndgameEndingSubtitles[index] != NULL) { if (gEndgameEndingSubtitles[index] != NULL) {
@ -802,13 +844,13 @@ void endgameEndingSubtitlesFree()
} }
// 0x440728 // 0x440728
void _endgame_movie_callback() static void _endgame_movie_callback()
{ {
_endgame_maybe_done = 1; _endgame_maybe_done = 1;
} }
// 0x440734 // 0x440734
void _endgame_movie_bk_process() static void _endgame_movie_bk_process()
{ {
if (_endgame_maybe_done) { if (_endgame_maybe_done) {
backgroundSoundLoad("10labone", 11, 14, 16); backgroundSoundLoad("10labone", 11, 14, 16);
@ -818,7 +860,7 @@ void _endgame_movie_bk_process()
} }
// 0x440770 // 0x440770
int endgameEndingInit() static int endgameEndingInit()
{ {
File* stream; File* stream;
char str[256]; char str[256];
@ -915,7 +957,7 @@ err:
// NOTE: There are no references to this function. It was inlined. // NOTE: There are no references to this function. It was inlined.
// //
// 0x44095C // 0x44095C
void endgameEndingFree() static void endgameEndingFree()
{ {
if (gEndgameEndings != NULL) { if (gEndgameEndings != NULL) {
internal_free(gEndgameEndings); internal_free(gEndgameEndings);
@ -1107,7 +1149,7 @@ void endgameSetupDeathEnding(int reason)
// Always returns 0. // Always returns 0.
// //
// 0x440CF4 // 0x440CF4
int endgameDeathEndingValidate(int* percentage) static int endgameDeathEndingValidate(int* percentage)
{ {
*percentage = 0; *percentage = 0;

View File

@ -1,8 +1,6 @@
#ifndef ENDGAME_H #ifndef ENDGAME_H
#define ENDGAME_H #define ENDGAME_H
#include "platform_compat.h"
typedef enum EndgameDeathEndingReason { typedef enum EndgameDeathEndingReason {
// Dude died. // Dude died.
ENDGAME_DEATH_ENDING_REASON_DEATH = 0, ENDGAME_DEATH_ENDING_REASON_DEATH = 0,
@ -11,78 +9,13 @@ typedef enum EndgameDeathEndingReason {
ENDGAME_DEATH_ENDING_REASON_TIMEOUT = 2, ENDGAME_DEATH_ENDING_REASON_TIMEOUT = 2,
} EndgameDeathEndingReason; } EndgameDeathEndingReason;
typedef struct EndgameDeathEnding {
int gvar;
int value;
int worldAreaKnown;
int worldAreaNotKnown;
int min_level;
int percentage;
char voiceOverBaseName[16];
// This flag denotes that the conditions for this ending is met and it was
// selected as a candidate for final random selection.
bool enabled;
} EndgameDeathEnding;
typedef struct EndgameEnding {
int gvar;
int value;
int art_num;
char voiceOverBaseName[12];
int direction;
} EndgameEnding;
extern char _aEnglish_2[]; extern char _aEnglish_2[];
extern int gEndgameEndingSubtitlesLength;
extern int gEndgameEndingSubtitlesCharactersCount;
extern int gEndgameEndingSubtitlesCurrentLine;
extern int _endgame_maybe_done;
extern EndgameDeathEnding* gEndgameDeathEndings;
extern int gEndgameDeathEndingsLength;
extern char gEndgameDeathEndingFileName[40];
extern bool gEndgameEndingVoiceOverSpeechLoaded;
extern char gEndgameEndingSubtitlesLocalizedPath[COMPAT_MAX_PATH];
extern bool gEndgameEndingSpeechEnded;
extern EndgameEnding* gEndgameEndings;
extern char** gEndgameEndingSubtitles;
extern bool gEndgameEndingSubtitlesEnabled;
extern bool gEndgameEndingSubtitlesEnded;
extern bool _endgame_map_enabled;
extern bool _endgame_mouse_state;
extern int gEndgameEndingsLength;
extern bool gEndgameEndingVoiceOverSubtitlesLoaded;
extern unsigned int gEndgameEndingSubtitlesReferenceTime;
extern unsigned int* gEndgameEndingSubtitlesTimings;
extern int gEndgameEndingSlideshowOldFont;
extern unsigned char* gEndgameEndingSlideshowWindowBuffer;
extern int gEndgameEndingSlideshowWindow;
void endgamePlaySlideshow(); void endgamePlaySlideshow();
void endgamePlayMovie(); void endgamePlayMovie();
void endgameEndingRenderPanningScene(int direction, const char* narratorFileName);
void endgameEndingRenderStaticScene(int fid, const char* narratorFileName);
int endgameEndingHandleContinuePlaying();
int endgameEndingSlideshowWindowInit();
void endgameEndingSlideshowWindowFree();
void endgameEndingVoiceOverInit(const char* fname);
void endgameEndingVoiceOverReset();
void endgameEndingVoiceOverFree();
void endgameEndingLoadPalette(int type, int id);
void _endgame_voiceover_callback();
int endgameEndingSubtitlesLoad(const char* filePath);
void endgameEndingRefreshSubtitles();
void endgameEndingSubtitlesFree();
void _endgame_movie_callback();
void _endgame_movie_bk_process();
int endgameEndingInit();
void endgameEndingFree();
int endgameDeathEndingInit(); int endgameDeathEndingInit();
int endgameDeathEndingExit(); int endgameDeathEndingExit();
void endgameSetupDeathEnding(int reason); void endgameSetupDeathEnding(int reason);
int endgameDeathEndingValidate(int* percentage);
char* endgameDeathEndingGetFileName(); char* endgameDeathEndingGetFileName();
#endif /* ENDGAME_H */ #endif /* ENDGAME_H */