mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-05-01 14:17:58 +03:00
port StartGame
This commit is contained in:
parent
fb43af21bd
commit
161f74bc1d
8 changed files with 930 additions and 823 deletions
1634
docs/progress.svg
1634
docs/progress.svg
File diff suppressed because it is too large
Load diff
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 110 KiB |
|
@ -350,10 +350,12 @@ S_FadeToBlack 0x0041CD10 0x0000003F *
|
|||
S_Wait 0x0041CD50 0x0000004D -
|
||||
SoundStart 0x0041CDA0 0x00000045 *
|
||||
WinPlayFMV 0x0041CDF0 0x0000024A -
|
||||
S_PlayFMV 0x0041D040 0x0000007C -
|
||||
sub_41D0C0 0x0041D0C0 0x000001CA -
|
||||
sub_41D00B 0x0041D00B 0x0000002F -
|
||||
S_PlayFMV 0x0041D040 0x0000007C *
|
||||
sub_41D078 0x0041D078 0x00000044 -
|
||||
|
||||
# game.cpp
|
||||
StartGame 0x0041D0C0 0x000001CA +
|
||||
GameLoop 0x0041D2C0 0x00000065 +
|
||||
LevelCompleteSequence 0x0041D330 0x0000021C -
|
||||
LevelStats 0x0041D5A0 0x00000346 +
|
||||
|
@ -832,8 +834,8 @@ draw_scaled_spriteC 0x004360A0 0x000001FB -
|
|||
|
||||
# setup.cpp
|
||||
InitialiseLevel 0x004362A0 0x00000119 +
|
||||
InitialiseGameFlags ---------- ---------- -
|
||||
InitialiseLevelFlags 0x004363C0 0x00000018 -
|
||||
InitialiseGameFlags ---------- ---------- +
|
||||
InitialiseLevelFlags 0x004363C0 0x00000018 *
|
||||
BaddyObjects 0x004363E0 0x00000C2F +
|
||||
TrapObjects 0x00437010 0x00000356 +
|
||||
ObjectObjects 0x00437370 0x000006D3 +
|
||||
|
|
|
@ -3,25 +3,102 @@
|
|||
#include "game/draw.h"
|
||||
#include "game/game.h"
|
||||
#include "game/savegame.h"
|
||||
#include "game/setup.h"
|
||||
#include "game/text.h"
|
||||
#include "game/vars.h"
|
||||
#include "specific/display.h"
|
||||
#include "specific/frontend.h"
|
||||
#include "specific/input.h"
|
||||
#include "specific/output.h"
|
||||
#include "specific/shed.h"
|
||||
#include "specific/sndpc.h"
|
||||
#include "config.h"
|
||||
#include "util.h"
|
||||
|
||||
void GameLoop(int demo_mode)
|
||||
int32_t StartGame(int level_num)
|
||||
{
|
||||
switch (level_num) {
|
||||
case LV_GYM:
|
||||
S_PlayFMV(FMV_GYM, 1);
|
||||
break;
|
||||
|
||||
case LV_LEVEL1:
|
||||
S_PlayFMV(FMV_SNOW, 1);
|
||||
break;
|
||||
|
||||
case LV_LEVEL4:
|
||||
S_PlayFMV(FMV_LIFT, 1);
|
||||
break;
|
||||
|
||||
case LV_LEVEL8A:
|
||||
S_PlayFMV(FMV_VISION, 1);
|
||||
break;
|
||||
|
||||
case LV_LEVEL10A:
|
||||
S_PlayFMV(FMV_CANYON, 1);
|
||||
break;
|
||||
|
||||
case LV_LEVEL10B:
|
||||
S_PlayFMV(FMV_PYRAMID, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: this probably doesn't belong here
|
||||
CurrentLevel = level_num;
|
||||
TitleLoaded = 0;
|
||||
if (level_num != LV_CURRENT) {
|
||||
InitialiseLevelFlags();
|
||||
}
|
||||
|
||||
if (!InitialiseLevel(level_num)) {
|
||||
CurrentLevel = 0;
|
||||
return GF_EXIT_TO_TITLE;
|
||||
}
|
||||
|
||||
if (GameLoop(0) == GF_EXIT_TO_TITLE) {
|
||||
return GF_EXIT_TO_TITLE;
|
||||
}
|
||||
|
||||
if (LevelComplete) {
|
||||
if (CurrentLevel) {
|
||||
S_FadeInInventory(1);
|
||||
return GF_LEVELCOMPLETE | CurrentLevel;
|
||||
}
|
||||
|
||||
S_FadeToBlack();
|
||||
return GF_EXIT_TO_TITLE;
|
||||
}
|
||||
|
||||
S_FadeToBlack();
|
||||
if (!InventoryChosen) {
|
||||
return GF_EXIT_TO_TITLE;
|
||||
}
|
||||
|
||||
if (InventoryExtraData[0]) {
|
||||
if (InventoryExtraData[0] == 1) {
|
||||
return GF_STARTGAME | LV_LEVEL1;
|
||||
}
|
||||
return GF_EXIT_TO_TITLE;
|
||||
}
|
||||
|
||||
S_LoadGame(SaveGame, sizeof(SAVEGAME_INFO), InventoryExtraData[1]);
|
||||
return GF_STARTGAME | LV_CURRENT;
|
||||
}
|
||||
|
||||
int32_t GameLoop(int demo_mode)
|
||||
{
|
||||
TRACE("");
|
||||
OverlayFlag = 1;
|
||||
InitialiseCamera();
|
||||
|
||||
int32_t nframes = 1;
|
||||
while (!ControlPhase(nframes, demo_mode)) {
|
||||
nframes = DrawPhaseGame();
|
||||
int32_t ret;
|
||||
while (1) {
|
||||
ret = ControlPhase(nframes, demo_mode);
|
||||
if (ret) {
|
||||
break;
|
||||
}
|
||||
nframes = DrawPhaseGame(ret);
|
||||
}
|
||||
|
||||
S_SoundStopAllSamples();
|
||||
|
@ -29,6 +106,8 @@ void GameLoop(int demo_mode)
|
|||
if (OptionMusicVolume) {
|
||||
S_CDVolume(OptionMusicVolume * 25 + 5);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t LevelIsValid(int16_t level_num)
|
||||
|
@ -216,6 +295,7 @@ int32_t S_LoadGame(void* data, int32_t size, int slot)
|
|||
|
||||
void T1MInjectGameGame()
|
||||
{
|
||||
INJECT(0x0041D0C0, StartGame);
|
||||
INJECT(0x0041D2C0, GameLoop);
|
||||
INJECT(0x0041D5A0, LevelStats);
|
||||
INJECT(0x0041D8F0, GetRandomControl);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#define S_SaveGame ((void (*)())0x0041DB70)
|
||||
// clang-format on
|
||||
|
||||
void GameLoop(int demo_mode);
|
||||
int32_t GameLoop(int demo_mode);
|
||||
int32_t LevelIsValid(int16_t level_num);
|
||||
void SeedRandomControl(int32_t seed);
|
||||
void SeedRandomDraw(int32_t seed);
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
// clang-format off
|
||||
#define InitialiseLevelFlags ((void (*)())0x004363C0)
|
||||
// clang-format on
|
||||
|
||||
int32_t InitialiseLevel(int32_t level_num);
|
||||
void InitialiseGameFlags();
|
||||
void BaddyObjects();
|
||||
|
|
|
@ -679,6 +679,21 @@ typedef enum {
|
|||
IF_KILLED_ITEM = 0x8000,
|
||||
} ITEM_FLAGS;
|
||||
|
||||
typedef enum {
|
||||
FMV_INTRO = 0,
|
||||
FMV_GYM = 1,
|
||||
FMV_SNOW = 2,
|
||||
FMV_LIFT = 3,
|
||||
FMV_VISION = 3,
|
||||
FMV_CANYON = 4,
|
||||
FMV_PYRAMID = 5,
|
||||
FMV_PRISON = 6,
|
||||
FMV_ENDSEQ = 7,
|
||||
FMV_CORE = 8,
|
||||
FMV_ESCAPE = 9,
|
||||
NUMBER_OF_FMV
|
||||
} FMV_SEQUENCE;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
// clang-format off
|
||||
#define TempVideoRemove ((void (*)())0x004167D0)
|
||||
#define TempVideoAdjust ((void (*)(int32_t hires, double sizer))0x00416550)
|
||||
#define S_FadeInInventory ((void (*)())0x00416B20)
|
||||
// clang-format on
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define WinVidSpinMessageLoop ((void (*)())0x00437AD0)
|
||||
#define ShowFatalError ((void (*)(const char *message))0x0043D770)
|
||||
#define S_ExitSystem ((void (*)(const char *message))0x0041E260)
|
||||
#define S_PlayFMV ((void (*)(int32_t sequence, int32_t mode))0x0041D040)
|
||||
#define WriteTombAtiSettings ((void (*)())0x00438B60)
|
||||
#define sub_4380E0 ((void (*)(int16_t *unk))0x004380E0)
|
||||
#define InitialiseHardware ((void (*)())0x00408005)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue