From fbda2741179c017b3e514ed9850a6a3421182d31 Mon Sep 17 00:00:00 2001 From: rr- Date: Tue, 9 Mar 2021 23:30:30 +0100 Subject: [PATCH] port CreateStartInfo --- docs/progress.svg | 12 +++++----- docs/progress.txt | 2 +- src/game/savegame.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ src/game/savegame.h | 2 +- 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/docs/progress.svg b/docs/progress.svg index b65517962..201519f58 100644 --- a/docs/progress.svg +++ b/docs/progress.svg @@ -570,7 +570,7 @@ VoleControl InitialiseStartInfo ModifyStartInfo -CreateStartInfo +CreateStartInfo CreateSaveGameInfo ExtractSaveGameInfo S_DrawSprite @@ -971,7 +971,7 @@ StartDemo DartsControl Inv_RingDoMotions -CreateStartInfo +CreateStartInfo LavaWedgeControl transA CombatCamera @@ -1463,10 +1463,10 @@ sub_440EF0 KeyGet S_CDVolume -Functions decompiled (count): 68.81% -Functions decompiled (bytesize): 66.90% -Functions not decompiled, but with known names (count): 17.37% -Functions not decompiled, but with known names (bytesize): 17.37% +Functions decompiled (count): 68.95% +Functions decompiled (bytesize): 67.02% +Functions not decompiled, but with known names (count): 17.24% +Functions not decompiled, but with known names (bytesize): 17.25% Functions not decompiled, with unknown names (count): 13.82% Functions not decompiled, with unknown names (bytesize): 15.73% diff --git a/docs/progress.txt b/docs/progress.txt index c8cc51714..dfb9b3918 100644 --- a/docs/progress.txt +++ b/docs/progress.txt @@ -817,7 +817,7 @@ WriteSGLara ---------- ---------- - LoadSaveGameInfo ---------- ---------- - InitialiseStartInfo 0x004344D0 0x00000042 + ModifyStartInfo 0x00434520 0x000000BF + -CreateStartInfo 0x004345E0 0x00000139 * +CreateStartInfo 0x004345E0 0x00000139 + CreateSaveGameInfo 0x00434720 0x00000866 * ExtractSaveGameInfo 0x00434F90 0x00000971 * ResetSG ---------- ---------- - diff --git a/src/game/savegame.c b/src/game/savegame.c index e83f01b0e..6d3e423f2 100644 --- a/src/game/savegame.c +++ b/src/game/savegame.c @@ -1,3 +1,4 @@ +#include "game/inv.h" #include "game/savegame.h" #include "game/vars.h" #include "util.h" @@ -75,8 +76,60 @@ void ModifyStartInfo(int32_t level_num) } } +void CreateStartInfo(int level_num) +{ + START_INFO *start = &SaveGame[0].start[level_num]; + + start->available = 1; + start->costume = 0; + + start->pistol_ammo = 1000; + if (Inv_RequestItem(O_GUN_ITEM)) { + start->got_pistols = 1; + } else { + start->got_pistols = 0; + } + + if (Inv_RequestItem(O_MAGNUM_ITEM)) { + start->magnum_ammo = Lara.magnums.ammo; + start->got_magnums = 1; + } else { + start->magnum_ammo = Inv_RequestItem(O_MAG_AMMO_ITEM) * MAGNUM_AMMO_QTY; + start->got_magnums = 0; + } + + if (Inv_RequestItem(O_UZI_ITEM)) { + start->uzi_ammo = Lara.uzis.ammo; + start->got_uzis = 1; + } else { + start->uzi_ammo = Inv_RequestItem(O_UZI_AMMO_ITEM) * UZI_AMMO_QTY; + start->got_uzis = 0; + } + + if (Inv_RequestItem(O_SHOTGUN_ITEM)) { + start->shotgun_ammo = Lara.shotgun.ammo; + start->got_shotgun = 1; + } else { + start->shotgun_ammo = + Inv_RequestItem(O_SG_AMMO_ITEM) * SHOTGUN_AMMO_QTY; + start->got_shotgun = 0; + } + + start->num_medis = Inv_RequestItem(O_MEDI_ITEM); + start->num_big_medis = Inv_RequestItem(O_BIGMEDI_ITEM); + start->num_scions = Inv_RequestItem(O_SCION_ITEM); + + start->gun_type = Lara.gun_type; + if (Lara.gun_status == LGS_READY) { + start->gun_status = LGS_READY; + } else { + start->gun_status = LGS_ARMLESS; + } +} + void T1MInjectGameSaveGame() { INJECT(0x004344D0, InitialiseStartInfo); INJECT(0x00434520, ModifyStartInfo); + INJECT(0x004345E0, CreateStartInfo) } diff --git a/src/game/savegame.h b/src/game/savegame.h index b457cf25a..34161aa96 100644 --- a/src/game/savegame.h +++ b/src/game/savegame.h @@ -4,13 +4,13 @@ #include // clang-format off -#define CreateStartInfo ((void (*)(int32_t level_num))0x004345E0) #define CreateSaveGameInfo ((void (*)())0x00434720) #define ExtractSaveGameInfo ((void (*)())0x00434F90) // clang-format on void InitialiseStartInfo(); void ModifyStartInfo(int32_t level_num); +void CreateStartInfo(int level_num); void T1MInjectGameSaveGame();