port Level_Initialise

This commit is contained in:
Marcin Kurczewski 2024-05-06 01:50:15 +02:00
parent b16027d4c8
commit 6129c1f979
No known key found for this signature in database
GPG Key ID: CC65E6FD28CAE42A
8 changed files with 186 additions and 10 deletions

View File

@ -69,10 +69,10 @@
</g>
<g transform="translate(0 116)">
<text x="0" y="7.50">Tomb2.exe progress according to the physical function order:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">37.52% (457)</tspan> · <tspan class="known">60.02% (731)</tspan> · <tspan class="todo">0.41% (5)</tspan> · <tspan class="unused">2.05% (25)</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">37.60% (458)</tspan> · <tspan class="known">59.93% (730)</tspan> · <tspan class="todo">0.41% (5)</tspan> · <tspan class="unused">2.05% (25)</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="280.28" height="6" x="0" y="0" class="decompiled"/>
<rect width="448.32" height="6" x="280.28" y="0" class="known"/>
<rect width="280.89" height="6" x="0" y="0" class="decompiled"/>
<rect width="447.71" height="6" x="280.89" y="0" class="known"/>
<rect width="3.07" height="6" x="728.60" y="0" class="todo"/>
<rect width="15.33" height="6" x="731.67" y="0" class="unused"/>
</g>
@ -767,7 +767,7 @@
<rect width="12" height="12" x="555" y="195" class="known"><title>void __cdecl ResetSG(void);</title></rect>
<rect width="12" height="12" x="570" y="195" class="known"><title>void __cdecl WriteSG(void *pointer, int32_t size);</title></rect>
<rect width="12" height="12" x="585" y="195" class="known"><title>void __cdecl ReadSG(void *pointer, int32_t size);</title></rect>
<rect width="12" height="12" x="600" y="195" class="known"><title>int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);</title></rect>
<rect width="12" height="12" x="600" y="195" class="decompiled"><title>int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);</title></rect>
<rect width="12" height="12" x="615" y="195" class="known"><title>void __cdecl InitialiseGameFlags(void);</title></rect>
<rect width="12" height="12" x="630" y="195" class="known"><title>void __cdecl InitialiseLevelFlags(void);</title></rect>
<rect width="12" height="12" x="645" y="195" class="known"><title>void __cdecl BaddyObjects(void);</title></rect>
@ -1299,10 +1299,10 @@
</g>
<g transform="translate(0 546)">
<text x="0" y="7.50">Tomb2.exe progress according to the function sizes:</text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">35.34%</tspan> · <tspan class="known">64.34%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.32%</tspan></tspan></text>
<text class="todo" style="font-size: 12px; " x="747" y="9"><tspan text-anchor="end"><tspan class="decompiled">35.44%</tspan> · <tspan class="known">64.23%</tspan> · <tspan class="todo">0%</tspan> · <tspan class="unused">0.32%</tspan></tspan></text>
<g transform="translate(0 20)">
<rect width="263.96" height="6" x="0" y="0" class="decompiled"/>
<rect width="480.60" height="6" x="263.96" y="0" class="known"/>
<rect width="264.73" height="6" x="0" y="0" class="decompiled"/>
<rect width="479.83" height="6" x="264.73" y="0" class="known"/>
<rect width="0.10" height="6" x="744.56" y="0" class="todo"/>
<rect width="2.40" height="6" x="744.60" y="0" class="unused"/>
</g>
@ -1576,7 +1576,7 @@
<rect width="14.55" height="13.84" x="663.08" y="59.39" class="known"><title>void __cdecl FlameControl(int16_t fx_num);</title></rect>
<rect width="14.45" height="13.84" x="680.63" y="59.39" class="decompiled"><title>void __cdecl Lara_Col_Wade(ITEM_INFO *item, COLL_INFO *coll);</title></rect>
<rect width="14.35" height="13.84" x="698.08" y="59.39" class="decompiled"><title>void __fastcall Output_GourA(int32_t y0, int32_t y1, uint8_t color_idx); // actually, __watcall, which is esoteric and rarely supported</title></rect>
<rect width="14.31" height="13.84" x="715.44" y="59.39" class="known"><title>int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);</title></rect>
<rect width="14.31" height="13.84" x="715.44" y="59.39" class="decompiled"><title>int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);</title></rect>
<rect width="14.26" height="13.84" x="732.74" y="59.39" class="known"><title>void __cdecl Boat_Collision(int16_t item_num, ITEM_INFO *lara_item, COLL_INFO *coll);</title></rect>
<rect width="14.52" height="13.49" x="448.61" y="76.23" class="known"><title>void __cdecl Lara_SwimCollision(ITEM_INFO *item, COLL_INFO *coll);</title></rect>
<rect width="14.31" height="13.49" x="466.13" y="76.23" class="decompiled"><title>void __cdecl Lara_HandleSurface(ITEM_INFO *item, COLL_INFO *coll);</title></rect>

Before

Width:  |  Height:  |  Size: 360 KiB

After

Width:  |  Height:  |  Size: 360 KiB

View File

@ -2010,6 +2010,57 @@ typedef enum {
SF_UNFLIP = 0x80,
} SOUND_FLAG;
typedef enum {
GBUF_TEMP_ALLOC = 0,
GBUF_TEXTURE_PAGES = 1,
GBUF_MESH_POINTERS = 2,
GBUF_MESHES = 3,
GBUF_ANIMS = 4,
GBUF_STRUCTS = 5,
GBUF_ANIM_RANGES = 6,
GBUF_ANIM_COMMANDS = 7,
GBUF_ANIM_BONES = 8,
GBUF_ANIM_FRAMES = 9,
GBUF_ROOM_TEXTURES = 10,
GBUF_ROOM_INFOS = 11,
GBUF_ROOM_MESH = 12,
GBUF_ROOM_DOOR = 13,
GBUF_ROOM_FLOOR = 14,
GBUF_ROOM_LIGHTS = 15,
GBUF_ROOM_STATIC_MESH_INFOS = 16,
GBUF_FLOOR_DATA = 17,
GBUF_ITEMS = 18,
GBUF_CAMERAS = 19,
GBUF_SOUND_FX = 20,
GBUF_BOXES = 21,
GBUF_OVERLAPS = 22,
GBUF_GROUND_ZONE = 23,
GBUF_FLY_ZONE = 24,
GBUF_ANIMATING_TEXTURE_RANGES = 25,
GBUF_CINEMATIC_FRAMES = 26,
GBUF_LOAD_DEMO_BUFFER = 27,
GBUF_SAVE_DEMO_BUFFER = 28,
GBUF_CINEMATIC_EFFECTS = 29,
GBUF_MUMMY_HEAD_TURN = 30,
GBUF_EXTRA_DOOR_STUFF = 31,
GBUF_EFFECTS_ARRAY = 32,
GBUF_CREATURE_DATA = 33,
GBUF_CREATURE_LOT = 34,
GBUF_SAMPLE_INFOS = 35,
GBUF_SAMPLES = 36,
GBUF_SAMPLE_OFFSETS = 37,
GBUF_ROLLING_BALL_STUFF = 38,
GBUF_SKIDOO_STUFF = 39,
GBUF_LOAD_PICTURE_BUFFER = 40,
GBUF_FMV_BUFFERS = 41,
GBUF_POLYGON_BUFFERS = 42,
GBUF_ORDER_TABLES = 43,
GBUF_CLUTS = 44,
GBUF_TEXTURE_INFOS = 45,
GBUF_SPRITE_INFOS = 46,
GBUF_NUM_MALLOC_TYPES = 47,
} GAME_BUFFER;
# FUNCTIONS
# Flags:
# - to do
@ -2795,7 +2846,7 @@ typedef enum {
0x0043A240 0x0035 -R void __cdecl ReadSG(void *pointer, int32_t size);
# game/setup.c
0x0043A280 0x015F - int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);
0x0043A280 0x015F + int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);
0x0043A3E0 0x0061 -R void __cdecl InitialiseGameFlags(void);
0x0043A450 0x0027 -R void __cdecl InitialiseLevelFlags(void);
0x0043A480 0x103B -R void __cdecl BaddyObjects(void);
@ -3659,3 +3710,7 @@ typedef enum {
0x0051E6E0 - int16_t g_SampleLUT[];
0x0051E9C4 - SAMPLE_INFO *g_SampleInfos;
0x004D7C78 - SOUND_SLOT g_SoundSlots[32];
0x004642F0 - int16_t g_GF_MusicTracks[16];
0x00521F48 - char **g_GF_TitleFileNames;
0x00521DC4 - char **g_GF_CutsceneFileNames;
0x00521F54 - char **g_GF_LevelFileNames;

View File

@ -2,11 +2,14 @@
#include "game/camera.h"
#include "game/console.h"
#include "game/effects.h"
#include "game/input.h"
#include "game/inventory.h"
#include "game/items.h"
#include "game/music.h"
#include "game/overlay.h"
#include "game/shell.h"
#include "game/sound.h"
#include "game/text.h"
#include "global/const.h"
#include "global/funcs.h"
@ -1188,3 +1191,65 @@ void __cdecl CutscenePlayerGen_Initialise(const int16_t item_num)
item->rot.y = 0;
item->dynamic_light = 0;
}
int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type)
{
if (level_type != GFL_TITLE && level_type != GFL_CUTSCENE) {
g_CurrentLevel = level_num;
}
g_IsDemoLevelType = level_type == GFL_DEMO;
InitialiseGameFlags();
g_Lara.item_num = NO_ITEM;
g_IsTitleLoaded = false;
bool result;
if (level_type == GFL_TITLE) {
result = S_LoadLevelFile(g_GF_TitleFileNames[0], level_num, level_type);
} else if (level_type == GFL_CUTSCENE) {
result = S_LoadLevelFile(
g_GF_CutsceneFileNames[level_num], level_num, level_type);
} else {
result = S_LoadLevelFile(
g_GF_LevelFileNames[level_num], level_num, level_type);
}
if (!result) {
return result;
}
if (g_Lara.item_num != NO_ITEM) {
Lara_Initialise(level_type);
}
if (level_type == GFL_NORMAL || level_type == GFL_SAVED
|| level_type == GFL_DEMO) {
GetCarriedItems();
}
g_Effects = game_malloc(MAX_EFFECTS * sizeof(FX_INFO), GBUF_EFFECTS_ARRAY);
Effect_InitialiseArray();
InitialiseLOTarray();
InitColours();
Text_Init();
Overlay_InitialisePickUpDisplay();
S_InitialiseScreen(level_type);
g_HealthBarTimer = 100;
Sound_Shutdown();
if (level_type == GFL_SAVED) {
ExtractSaveGameInfo();
} else if (level_type == GFL_NORMAL) {
GF_ModifyInventory(g_CurrentLevel, 0);
}
if (g_Objects[O_FINAL_LEVEL_COUNTER].loaded) {
InitialiseFinalLevel();
}
if (level_type == GFL_NORMAL || level_type == GFL_SAVED
|| level_type == GFL_DEMO) {
if (g_GF_MusicTracks[0]) {
Music_Play(g_GF_MusicTracks[0], 1);
}
}
g_IsAssaultTimerActive = 0;
g_IsAssaultTimerDisplay = 0;
g_Camera.underwater = 0;
return true;
}

View File

@ -67,3 +67,4 @@ void __cdecl CutscenePlayer_Control(int16_t item_num);
void __cdecl Lara_Control_Cutscene(int16_t item_num);
void __cdecl CutscenePlayer1_Initialise(int16_t item_num);
void __cdecl CutscenePlayerGen_Initialise(int16_t item_num);
int32_t __cdecl Level_Initialise(int32_t level_num, int32_t level_type);

View File

@ -366,7 +366,6 @@
#define ResetSG ((void __cdecl (*)(void))0x0043A1D0)
#define WriteSG ((void __cdecl (*)(void *pointer, int32_t size))0x0043A1F0)
#define ReadSG ((void __cdecl (*)(void *pointer, int32_t size))0x0043A240)
#define Level_Initialise ((int32_t __cdecl (*)(int32_t level_num, int32_t level_type))0x0043A280)
#define InitialiseGameFlags ((void __cdecl (*)(void))0x0043A3E0)
#define InitialiseLevelFlags ((void __cdecl (*)(void))0x0043A450)
#define BaddyObjects ((void __cdecl (*)(void))0x0043A480)

View File

@ -2024,4 +2024,55 @@ typedef enum {
SF_UNFLIP = 0x80,
} SOUND_FLAG;
typedef enum {
GBUF_TEMP_ALLOC = 0,
GBUF_TEXTURE_PAGES = 1,
GBUF_MESH_POINTERS = 2,
GBUF_MESHES = 3,
GBUF_ANIMS = 4,
GBUF_STRUCTS = 5,
GBUF_ANIM_RANGES = 6,
GBUF_ANIM_COMMANDS = 7,
GBUF_ANIM_BONES = 8,
GBUF_ANIM_FRAMES = 9,
GBUF_ROOM_TEXTURES = 10,
GBUF_ROOM_INFOS = 11,
GBUF_ROOM_MESH = 12,
GBUF_ROOM_DOOR = 13,
GBUF_ROOM_FLOOR = 14,
GBUF_ROOM_LIGHTS = 15,
GBUF_ROOM_STATIC_MESH_INFOS = 16,
GBUF_FLOOR_DATA = 17,
GBUF_ITEMS = 18,
GBUF_CAMERAS = 19,
GBUF_SOUND_FX = 20,
GBUF_BOXES = 21,
GBUF_OVERLAPS = 22,
GBUF_GROUND_ZONE = 23,
GBUF_FLY_ZONE = 24,
GBUF_ANIMATING_TEXTURE_RANGES = 25,
GBUF_CINEMATIC_FRAMES = 26,
GBUF_LOAD_DEMO_BUFFER = 27,
GBUF_SAVE_DEMO_BUFFER = 28,
GBUF_CINEMATIC_EFFECTS = 29,
GBUF_MUMMY_HEAD_TURN = 30,
GBUF_EXTRA_DOOR_STUFF = 31,
GBUF_EFFECTS_ARRAY = 32,
GBUF_CREATURE_DATA = 33,
GBUF_CREATURE_LOT = 34,
GBUF_SAMPLE_INFOS = 35,
GBUF_SAMPLES = 36,
GBUF_SAMPLE_OFFSETS = 37,
GBUF_ROLLING_BALL_STUFF = 38,
GBUF_SKIDOO_STUFF = 39,
GBUF_LOAD_PICTURE_BUFFER = 40,
GBUF_FMV_BUFFERS = 41,
GBUF_POLYGON_BUFFERS = 42,
GBUF_ORDER_TABLES = 43,
GBUF_CLUTS = 44,
GBUF_TEXTURE_INFOS = 45,
GBUF_SPRITE_INFOS = 46,
GBUF_NUM_MALLOC_TYPES = 47,
} GAME_BUFFER;
// clang-format on

View File

@ -18,6 +18,7 @@ extern const char *g_TR2XVersion;
#define g_AssaultBestTime (*(int32_t*)0x004641F0) // = -1
#define g_EffectRoutines (*((void(__cdecl *(*)[32])(ITEM_INFO *item))0x004641F8))
#define g_GF_NumSecrets (*(int16_t*)0x004642E8) // = 3
#define g_GF_MusicTracks (*(int16_t(*)[16])0x004642F0)
#define g_CineTargetAngle (*(int16_t*)0x00464310) // = 0x4000
#define g_OverlayStatus (*(int32_t*)0x004644E0) // = 1
#define g_Inv_NFrames (*(int32_t*)0x004644F8)
@ -269,7 +270,10 @@ extern const char *g_TR2XVersion;
#define g_NextEffectActive (*(int16_t*)0x005207CA)
#define g_PrevItemActive (*(int16_t*)0x005207CC)
#define g_Pickups (*(PICKUP_INFO(*)[12])0x00521CA0)
#define g_GF_CutsceneFileNames (*(char ***)0x00521DC4)
#define g_GameFlow (*(GAME_FLOW*)0x00521DE0)
#define g_GF_TitleFileNames (*(char ***)0x00521F48)
#define g_GF_LevelFileNames (*(char ***)0x00521F54)
#define g_SoundEffectCount (*(int32_t*)0x00521FDC)
#define g_SoundEffects (*(OBJECT_VECTOR **)0x00521FE0)
#define g_Objects (*(OBJECT_INFO(*)[265])0x00522000)

View File

@ -115,6 +115,7 @@ static void Inject_Decomp(const bool enable)
INJECT(enable, 0x00412530, Lara_Control_Cutscene);
INJECT(enable, 0x004125D0, CutscenePlayer1_Initialise);
INJECT(enable, 0x00412660, CutscenePlayerGen_Initialise);
INJECT(enable, 0x0043A280, Level_Initialise);
}
static void Inject_Camera(const bool enable)